1- /* $NetBSD: ite.c,v 1.20 2023/04/21 22:44:27 tsutsui Exp $ */
1+ /* $NetBSD: ite.c,v 1.21 2025/05/26 12:25:12 tsutsui Exp $ */
22
33/*
44 * Copyright (c) 1988 University of Utah.
4949
5050#include <hp300/dev/diofbreg.h>
5151#include <hp300/dev/intioreg.h>
52+ #include <hp300/dev/dioreg.h>
5253#include <hp300/dev/sgcreg.h>
5354#include <dev/ic/stireg.h>
5455
@@ -65,60 +66,130 @@ static void itecheckwrap(struct ite_data *, struct itesw *);
6566#define GID_STI 0x100 /* any value which is not a DIO fb, really */
6667
6768struct itesw itesw [] = {
68- { GID_TOPCAT ,
69- topcat_init , ite_dio_clear , ite_dio_putc8bpp ,
70- ite_dio_cursor , ite_dio_scroll },
71-
72- { GID_GATORBOX ,
73- gbox_init , ite_dio_clear , ite_dio_putc8bpp ,
74- ite_dio_cursor , gbox_scroll },
75-
76- { GID_RENAISSANCE ,
77- rbox_init , ite_dio_clear , ite_dio_putc8bpp ,
78- ite_dio_cursor , ite_dio_scroll },
79-
80- { GID_LRCATSEYE ,
81- topcat_init , ite_dio_clear , ite_dio_putc8bpp ,
82- ite_dio_cursor , ite_dio_scroll },
83-
84- { GID_HRCCATSEYE ,
85- topcat_init , ite_dio_clear , ite_dio_putc8bpp ,
86- ite_dio_cursor , ite_dio_scroll },
87-
88- { GID_HRMCATSEYE ,
89- topcat_init , ite_dio_clear , ite_dio_putc8bpp ,
90- ite_dio_cursor , ite_dio_scroll },
91-
92- { GID_DAVINCI ,
93- dvbox_init , ite_dio_clear , ite_dio_putc8bpp ,
94- ite_dio_cursor , ite_dio_scroll },
95-
96- { GID_HYPERION ,
97- hyper_init , ite_dio_clear , ite_dio_putc1bpp ,
98- ite_dio_cursor , ite_dio_scroll },
99-
100- { GID_TIGER ,
101- tvrx_init , ite_dio_clear , ite_dio_putc1bpp ,
102- ite_dio_cursor , ite_dio_scroll },
103-
104- { GID_A1474MID ,
105- dumb_init , dumb_clear , dumb_putc ,
106- dumb_cursor , dumb_scroll },
107-
108- { GID_A147xVGA ,
109- dumb_init , dumb_clear , dumb_putc ,
110- dumb_cursor , dumb_scroll },
111-
112- { GID_STI ,
113- sti_iteinit_sgc , sti_clear , sti_putc ,
114- sti_cursor , sti_scroll },
69+ {
70+ .ite_hwid = GID_TOPCAT ,
71+ .ite_probe = NULL ,
72+ .ite_init = topcat_init ,
73+ .ite_clear = ite_dio_clear ,
74+ .ite_putc = ite_dio_putc8bpp ,
75+ .ite_cursor = ite_dio_cursor ,
76+ .ite_scroll = ite_dio_scroll
77+ },
78+
79+ {
80+ .ite_hwid = GID_GATORBOX ,
81+ .ite_probe = NULL ,
82+ .ite_init = gbox_init ,
83+ .ite_clear = ite_dio_clear ,
84+ .ite_putc = ite_dio_putc8bpp ,
85+ .ite_cursor = ite_dio_cursor ,
86+ .ite_scroll = gbox_scroll
87+ },
88+
89+ {
90+ .ite_hwid = GID_RENAISSANCE ,
91+ .ite_probe = NULL ,
92+ .ite_init = rbox_init ,
93+ .ite_clear = ite_dio_clear ,
94+ .ite_putc = ite_dio_putc8bpp ,
95+ .ite_cursor = ite_dio_cursor ,
96+ .ite_scroll = ite_dio_scroll
97+ },
98+
99+ {
100+ .ite_hwid = GID_LRCATSEYE ,
101+ .ite_probe = NULL ,
102+ .ite_init = topcat_init ,
103+ .ite_clear = ite_dio_clear ,
104+ .ite_putc = ite_dio_putc8bpp ,
105+ .ite_cursor = ite_dio_cursor ,
106+ .ite_scroll = ite_dio_scroll
107+ },
108+
109+ {
110+ .ite_hwid = GID_HRCCATSEYE ,
111+ .ite_probe = NULL ,
112+ .ite_init = topcat_init ,
113+ .ite_clear = ite_dio_clear ,
114+ .ite_putc = ite_dio_putc8bpp ,
115+ .ite_cursor = ite_dio_cursor ,
116+ .ite_scroll = ite_dio_scroll
117+ },
118+
119+ {
120+ .ite_hwid = GID_HRMCATSEYE ,
121+ .ite_probe = NULL ,
122+ .ite_init = topcat_init ,
123+ .ite_clear = ite_dio_clear ,
124+ .ite_putc = ite_dio_putc8bpp ,
125+ .ite_cursor = ite_dio_cursor ,
126+ .ite_scroll = ite_dio_scroll
127+ },
128+
129+ {
130+ .ite_hwid = GID_DAVINCI ,
131+ .ite_probe = NULL ,
132+ .ite_init = dvbox_init ,
133+ .ite_clear = ite_dio_clear ,
134+ .ite_putc = ite_dio_putc8bpp ,
135+ .ite_cursor = ite_dio_cursor ,
136+ .ite_scroll = ite_dio_scroll
137+ },
138+
139+ {
140+ .ite_hwid = GID_HYPERION ,
141+ .ite_probe = NULL ,
142+ .ite_init = hyper_init ,
143+ .ite_clear = ite_dio_clear ,
144+ .ite_putc = ite_dio_putc1bpp ,
145+ .ite_cursor = ite_dio_cursor ,
146+ .ite_scroll = ite_dio_scroll
147+ },
148+
149+ {
150+ .ite_hwid = GID_TIGER ,
151+ .ite_probe = NULL ,
152+ .ite_init = tvrx_init ,
153+ .ite_clear = ite_dio_clear ,
154+ .ite_putc = ite_dio_putc1bpp ,
155+ .ite_cursor = ite_dio_cursor ,
156+ .ite_scroll = ite_dio_scroll
157+ },
158+
159+ {
160+ .ite_hwid = GID_A1474MID ,
161+ .ite_probe = sti_dio_probe ,
162+ .ite_init = sti_iteinit_dio ,
163+ .ite_clear = sti_clear ,
164+ .ite_putc = sti_putc ,
165+ .ite_cursor = sti_cursor ,
166+ .ite_scroll = sti_scroll
167+ },
168+
169+ {
170+ .ite_hwid = GID_A147xVGA ,
171+ .ite_probe = sti_dio_probe ,
172+ .ite_init = sti_iteinit_dio ,
173+ .ite_clear = sti_clear ,
174+ .ite_putc = sti_putc ,
175+ .ite_cursor = sti_cursor ,
176+ .ite_scroll = sti_scroll
177+ },
178+
179+ {
180+ .ite_hwid = GID_STI ,
181+ .ite_probe = NULL ,
182+ .ite_init = sti_iteinit_sgc ,
183+ .ite_clear = sti_clear ,
184+ .ite_putc = sti_putc ,
185+ .ite_cursor = sti_cursor ,
186+ .ite_scroll = sti_scroll
187+ },
115188};
116- int nitesw = sizeof (itesw ) / sizeof (itesw [0 ]);
117189
118190/* these guys need to be in initialized data */
119191int itecons = -1 ;
120192struct ite_data ite_data [NITE ] = { { 0 } };
121- int ite_scode [NITE ] = { 0 };
122193
123194/*
124195 * Locate all bitmapped displays
@@ -140,22 +211,22 @@ iteconfig(void)
140211 /* XXX: redundent but safe */
141212 if (badaddr ((void * )fb ) || fb -> id != GRFHWID )
142213 continue ;
143- for (dtype = 0 ; dtype < nitesw ; dtype ++ )
214+ for (dtype = 0 ; dtype < __arraycount ( itesw ) ; dtype ++ )
144215 if (itesw [dtype ].ite_hwid == fb -> fbid )
145216 break ;
146- if (dtype == nitesw )
217+ if (dtype == __arraycount ( itesw ) )
147218 continue ;
148219 if (i >= NITE )
149220 break ;
150- ite_scode [i ] = hw -> hw_sc ;
151221 ip = & ite_data [i ];
222+ ip -> scode = hw -> hw_sc ;
152223 ip -> isw = & itesw [dtype ];
153224 ip -> regbase = (void * )fb ;
154225 fboff = (fb -> fbomsb << 8 ) | fb -> fbolsb ;
155226 ip -> fbbase = (void * )(* ((u_char * )ip -> regbase + fboff ) << 16 );
156227 /* DIO II: FB offset is relative to select code space */
157- if (ip -> regbase >= ( void * ) DIOIIBASE )
158- ip -> fbbase = (char * )ip -> fbbase + (int )ip -> regbase ;
228+ if (DIO_ISDIOII ( ip -> scode ) )
229+ ip -> fbbase = (uint8_t * )ip -> fbbase + (int )ip -> regbase ;
159230 ip -> fbwidth = fb -> fbwmsb << 8 | fb -> fbwlsb ;
160231 ip -> fbheight = fb -> fbhmsb << 8 | fb -> fbhlsb ;
161232 ip -> dwidth = fb -> dwmsb << 8 | fb -> dwlsb ;
@@ -171,6 +242,10 @@ iteconfig(void)
171242 ip -> dwidth = ip -> fbwidth ;
172243 if (ip -> dheight > ip -> fbheight )
173244 ip -> dheight = ip -> fbheight ;
245+ /* confirm hardware is what we think it is */
246+ if (itesw [dtype ].ite_probe != NULL &&
247+ (* itesw [dtype ].ite_probe )(ip ) != 0 )
248+ continue ;
174249 ip -> alive = 1 ;
175250 i ++ ;
176251 }
@@ -188,10 +263,9 @@ iteconfig(void)
188263 }
189264
190265 /* SGC frame buffers can only be STI... */
191- for (dtype = 0 ; dtype < __arraycount (itesw ); dtype ++ ) {
266+ for (dtype = 0 ; dtype < __arraycount (itesw ); dtype ++ )
192267 if (itesw [dtype ].ite_hwid == GID_STI )
193268 break ;
194- }
195269 if (dtype == __arraycount (itesw ))
196270 return ;
197271
@@ -261,7 +335,8 @@ iteprobe(struct consdev *cp)
261335 unit = ite ;
262336 }
263337 }
264- curcons_scode = ite_scode [unit ];
338+ ip = & ite_data [unit ];
339+ curcons_scode = ip -> scode ;
265340 cp -> cn_dev = unit ;
266341 cp -> cn_pri = pri ;
267342}
0 commit comments