1 /* $NetBSD: console.c,v 1.3 2007/02/22 05:31:53 thorpej Exp $ */
4 * Copyright (c) 2004, 2005 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
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.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
32 #include <sys/param.h>
33 #include <sys/systm.h>
35 #include <lib/libsa/stand.h>
41 #define PUTCHAR __putchar /* "boot" hooks log staff. */
43 #include <machine/sbd.h>
48 void nullcursor(int, int);
49 void nullscroll(void);
57 cons
.cursor
= nullcursor
;
58 cons
.scroll
= nullscroll
;
59 cons
.cursor_enable
= false;
60 cons
.erace_previous_cursor
= false;
62 switch (SBD_INFO
->machine
) {
65 nvsram_cons
= *(volatile uint8_t *)0xbb023010;
67 switch (nvsram_cons
) {
69 cons
.type
= CONS_FB_KSEG2
;
70 fb_set_addr(0xf0000000, 0x01000000, 0xbfc0ec00);
71 zskbd_set_addr(0xbb010000, 0xbb010004);
75 /* sio 1 (zs channel A) */
76 cons
.type
= CONS_SIO1
;
77 zs_set_addr(0xbb011008, 0xbb01100c, 4915200);
81 /* sio 2 (zs channel B) */
82 cons
.type
= CONS_SIO2
;
83 zs_set_addr(0xbb011000, 0xbb011004, 4915200);
91 nvsram_cons
= *(volatile uint8_t *)0xbe4932a0;
93 switch (nvsram_cons
) {
95 /* on-board FB on 360AD, 360ADII */
96 cons
.type
= CONS_FB_KSEG2
;
97 fb_set_addr(0xf0000000, 0x01000000, 0xbfc0ec00);
98 zskbd_set_addr(0xbe480000, 0xbe480004);
102 /* sio 1 (zs channel A) */
103 cons
.type
= CONS_SIO1
;
104 zs_set_addr(0xbe440008, 0xbe44000c, 4915200);
108 /* sio 2 (zs channel B) */
109 cons
.type
= CONS_SIO2
;
110 zs_set_addr(0xbe440000, 0xbe440004, 4915200);
119 cons
.getc
= ROM_GETC
;
120 cons
.scan
= rom_scan
;
121 cons
.putc
= ROM_PUTC
;
122 cons
.init
= cons_rom_init
;
123 cons
.scroll
= cons_rom_scroll
;
124 cons
.type
= CONS_ROM
;
132 console_cursor(bool on
)
135 cons
.cursor_enable
= on
;
150 if (cons
.type
== CONS_SIO1
|| cons
.type
== CONS_SIO2
) {
152 cons
.putc(0, 0, '\r');
157 if (cons
.cursor_enable
&& cons
.erace_previous_cursor
)
158 cons
.cursor(cons
.x
* ROM_FONT_WIDTH
, cons
.y
* ROM_FONT_HEIGHT
);
162 cons
.putc(cons
.x
* ROM_FONT_WIDTH
, cons
.y
* ROM_FONT_HEIGHT
, c
);
163 if (++cons
.x
== CONS_WIDTH
) {
169 cons
.putc(cons
.x
* ROM_FONT_WIDTH
, cons
.y
* ROM_FONT_HEIGHT
, c
);
170 cons
.x
= cons
.x
== X_INIT
? X_INIT
: cons
.x
- 1;
171 if (cons
.cursor_enable
)
172 cons
.putc(cons
.x
* ROM_FONT_WIDTH
,
173 cons
.y
* ROM_FONT_HEIGHT
, ' ');
174 cons
.putc(cons
.x
* ROM_FONT_WIDTH
, cons
.y
* ROM_FONT_HEIGHT
, c
);
177 for (i
= cons
.x
% 8; i
< 8; i
++) {
178 cons
.putc(cons
.x
* ROM_FONT_WIDTH
,
179 cons
.y
* ROM_FONT_HEIGHT
, ' ');
180 if (++cons
.x
== CONS_WIDTH
) {
182 if (++cons
.y
== CONS_HEIGHT
)
188 cons
.putc(cons
.x
* ROM_FONT_WIDTH
, cons
.y
* ROM_FONT_HEIGHT
, c
);
192 cons
.putc(cons
.x
* ROM_FONT_WIDTH
, cons
.y
* ROM_FONT_HEIGHT
,
194 cons
.putc(cons
.x
* ROM_FONT_WIDTH
, cons
.y
* ROM_FONT_HEIGHT
, c
);
199 if (--cons
.x
< X_INIT
)
203 if (++cons
.x
>= CONS_WIDTH
)
207 for (i
= cons
.x
; i
< CONS_WIDTH
; i
++)
208 cons
.putc(i
* ROM_FONT_WIDTH
, cons
.y
* ROM_FONT_HEIGHT
,
213 if (cons
.y
== CONS_HEIGHT
)
216 if (cons
.cursor_enable
) {
217 cons
.cursor(cons
.x
* ROM_FONT_WIDTH
, cons
.y
* ROM_FONT_HEIGHT
);
218 cons
.erace_previous_cursor
= true;
220 cons
.erace_previous_cursor
= false;
239 nullcursor(int x
, int y
)