Home | History | Annotate | Line # | Download | only in common
console.h revision 1.2.46.1
      1  1.2.46.1     yamt /*	$NetBSD: console.h,v 1.2.46.1 2008/05/16 02:22:20 yamt Exp $	*/
      2       1.1  tsutsui 
      3       1.1  tsutsui /*-
      4       1.1  tsutsui  * Copyright (c) 2004, 2005 The NetBSD Foundation, Inc.
      5       1.1  tsutsui  * All rights reserved.
      6       1.1  tsutsui  *
      7       1.1  tsutsui  * This code is derived from software contributed to The NetBSD Foundation
      8       1.1  tsutsui  * by UCHIYAMA Yasushi.
      9       1.1  tsutsui  *
     10       1.1  tsutsui  * Redistribution and use in source and binary forms, with or without
     11       1.1  tsutsui  * modification, are permitted provided that the following conditions
     12       1.1  tsutsui  * are met:
     13       1.1  tsutsui  * 1. Redistributions of source code must retain the above copyright
     14       1.1  tsutsui  *    notice, this list of conditions and the following disclaimer.
     15       1.1  tsutsui  * 2. Redistributions in binary form must reproduce the above copyright
     16       1.1  tsutsui  *    notice, this list of conditions and the following disclaimer in the
     17       1.1  tsutsui  *    documentation and/or other materials provided with the distribution.
     18       1.1  tsutsui  *
     19       1.1  tsutsui  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20       1.1  tsutsui  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21       1.1  tsutsui  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22       1.1  tsutsui  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23       1.1  tsutsui  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24       1.1  tsutsui  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25       1.1  tsutsui  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26       1.1  tsutsui  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27       1.1  tsutsui  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28       1.1  tsutsui  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29       1.1  tsutsui  * POSSIBILITY OF SUCH DAMAGE.
     30       1.1  tsutsui  */
     31       1.1  tsutsui 
     32       1.1  tsutsui #define	FB_LINEBYTES	2048
     33       1.1  tsutsui #define	FB_WIDTH	1284
     34       1.1  tsutsui #define	FB_HEIGHT	1024
     35       1.1  tsutsui 
     36       1.1  tsutsui #define	CONS_WIDTH	(FB_WIDTH / ROM_FONT_WIDTH)
     37       1.1  tsutsui #define	CONS_HEIGHT	(FB_HEIGHT / ROM_FONT_HEIGHT)
     38       1.1  tsutsui 
     39       1.1  tsutsui #define	X_INIT		0
     40       1.1  tsutsui #define	Y_INIT		0
     41       1.1  tsutsui 
     42       1.1  tsutsui #define	CONS_FG		0xff
     43       1.1  tsutsui #define	CONS_BG		0x00
     44       1.1  tsutsui 
     45       1.1  tsutsui /*
     46       1.1  tsutsui  * TR2, TR2A IPL CLUT.
     47       1.1  tsutsui  *
     48       1.1  tsutsui  * 1	 red
     49       1.1  tsutsui  * 2	 green
     50       1.1  tsutsui  * 4	 blue
     51       1.1  tsutsui  * 8	 yellow
     52       1.1  tsutsui  * 16	 cyan
     53       1.1  tsutsui  * 32	 magenta
     54       1.1  tsutsui  * 64	 light gray
     55       1.1  tsutsui  * 128	 dark gray
     56       1.1  tsutsui  * 255	 white
     57       1.1  tsutsui  * other black
     58       1.1  tsutsui  */
     59       1.1  tsutsui 
     60       1.1  tsutsui enum console_type {
     61       1.1  tsutsui 	CONS_ROM,	/* ROM console I/O */
     62       1.1  tsutsui 	CONS_FB_KSEG2,	/* direct fb device access via KSEG2 */
     63       1.1  tsutsui 	CONS_FB_KSEG1,	/* direct fb device access via KSEG1 */
     64       1.1  tsutsui 	CONS_SIO1,	/* serial console port 1 */
     65       1.1  tsutsui 	CONS_SIO2,	/* serial console port 2 */
     66       1.1  tsutsui };
     67       1.1  tsutsui 
     68       1.1  tsutsui struct cons {
     69       1.1  tsutsui 	void (*init)(void);
     70       1.1  tsutsui 	void (*putc)(int, int, int);
     71       1.1  tsutsui 	int (*getc)(void);
     72       1.1  tsutsui 	int (*scan)(void);
     73       1.1  tsutsui 	void (*scroll)(void);
     74       1.1  tsutsui 	void (*cursor)(int, int);
     75       1.1  tsutsui 	int x, y;
     76       1.1  tsutsui 	enum console_type type;
     77       1.2  thorpej 	bool erace_previous_cursor;
     78       1.2  thorpej 	bool cursor_enable;
     79       1.1  tsutsui };
     80       1.1  tsutsui 
     81       1.1  tsutsui struct fb {
     82       1.1  tsutsui 	uint8_t *fb_addr;
     83       1.1  tsutsui 	uint32_t fb_size;
     84       1.1  tsutsui 	uint8_t *font_addr;
     85       1.2  thorpej 	bool active;
     86       1.1  tsutsui };
     87       1.1  tsutsui 
     88       1.1  tsutsui struct zskbd {
     89       1.1  tsutsui 	volatile uint8_t *status;
     90       1.1  tsutsui 	volatile uint8_t *data;
     91       1.1  tsutsui 	const uint8_t *normal;
     92       1.1  tsutsui 	const uint8_t *shift;
     93       1.1  tsutsui 	const uint8_t *ctrl;
     94       1.1  tsutsui 	const uint8_t *capslock;
     95       1.1  tsutsui 	u_int keymap;
     96       1.1  tsutsui 	int print;
     97       1.1  tsutsui };
     98       1.1  tsutsui 
     99       1.1  tsutsui struct zs {
    100       1.1  tsutsui 	volatile uint8_t *csr;
    101       1.1  tsutsui 	volatile uint8_t *data;
    102       1.1  tsutsui 	int clock;
    103       1.1  tsutsui };
    104       1.1  tsutsui 
    105       1.1  tsutsui void fb_set_addr(uint32_t, uint32_t, uint32_t);
    106       1.1  tsutsui void *fb_get_addr(void);
    107       1.1  tsutsui void fb_init(void);
    108       1.1  tsutsui void fb_scroll(void);
    109       1.1  tsutsui void fb_drawchar(int, int, int);
    110       1.1  tsutsui void fb_drawfont(int, int, uint16_t *);
    111       1.1  tsutsui void fb_drawcursor(int, int);
    112       1.1  tsutsui void fb_clear(int, int, int, int, int);
    113       1.1  tsutsui void fb_copy(int, int, int, int, int, int);
    114       1.2  thorpej void fb_active(bool);
    115       1.1  tsutsui 
    116       1.1  tsutsui void zskbd_set_addr(uint32_t, uint32_t);
    117       1.1  tsutsui int zskbd_getc(void);
    118       1.1  tsutsui int zskbd_scan(void);
    119       1.1  tsutsui void zskbd_print_keyscan(int);
    120       1.1  tsutsui 
    121       1.1  tsutsui void zs_set_addr(uint32_t, uint32_t, int);
    122       1.1  tsutsui 
    123       1.1  tsutsui void cons_rom_scroll(void);
    124       1.1  tsutsui void cons_rom_init(void);
    125       1.1  tsutsui int rom_scan(void);
    126       1.1  tsutsui 
    127       1.1  tsutsui enum console_type console_type(void);
    128       1.1  tsutsui void console_init(void);
    129       1.2  thorpej void console_cursor(bool);
    130       1.1  tsutsui 
    131       1.1  tsutsui int cnscan(void);
    132       1.1  tsutsui 
    133       1.1  tsutsui extern struct cons cons;
    134       1.1  tsutsui extern struct zskbd zskbd;
    135       1.1  tsutsui extern struct fb fb;
    136       1.1  tsutsui extern struct zs zs;
    137