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