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