Skip to content

Commit f04b108

Browse files
committed
Also use sti(4) ROM functions for 362/382 framebuffers on bootloader.
Mostly taken on OpenBSD/hp300. Tested on 382 with VGA-res EVRX, and no visible regression on 425e (sti EVRX), 425t (sti CRX), and 380 (topcat).
1 parent 1c6e501 commit f04b108

File tree

7 files changed

+152
-333
lines changed

7 files changed

+152
-333
lines changed

sys/arch/hp300/dev/sti_dio.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: sti_dio.c,v 1.2 2025/05/23 16:46:55 tsutsui Exp $ */
1+
/* $NetBSD: sti_dio.c,v 1.3 2025/05/26 12:25:12 tsutsui Exp $ */
22
/* $OpenBSD: sti_dio.c,v 1.1 2011/08/18 20:02:57 miod Exp $ */
33

44
/*
@@ -27,7 +27,7 @@
2727
*
2828
*/
2929
#include <sys/cdefs.h>
30-
__KERNEL_RCSID(0, "$NetBSD: sti_dio.c,v 1.2 2025/05/23 16:46:55 tsutsui Exp $");
30+
__KERNEL_RCSID(0, "$NetBSD: sti_dio.c,v 1.3 2025/05/26 12:25:12 tsutsui Exp $");
3131

3232
#include <sys/param.h>
3333
#include <sys/device.h>
@@ -41,11 +41,6 @@ __KERNEL_RCSID(0, "$NetBSD: sti_dio.c,v 1.2 2025/05/23 16:46:55 tsutsui Exp $");
4141
#include <hp300/dev/sti_diovar.h>
4242
#include <hp300/dev/sti_machdep.h>
4343

44-
/* DIO attachment defines */
45-
#define STI_DIO_SCODE_OFFSET 0x02 /* offset to SGC rom, in select codes */
46-
#define STI_DIO_SIZE 0x10 /* expected total device size
47-
in DIO-II size units */
48-
4944
static int sti_dio_match(device_t, cfdata_t, void *);
5045
static void sti_dio_attach(device_t, device_t, void *);
5146

sys/arch/hp300/dev/sti_diovar.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: sti_diovar.h,v 1.1 2025/05/01 06:11:21 tsutsui Exp $ */
1+
/* $NetBSD: sti_diovar.h,v 1.2 2025/05/26 12:25:12 tsutsui Exp $ */
22
/*-
33
* Copyright (c) 2025 Izumi Tsutsui. All rights reserved.
44
*
@@ -23,5 +23,12 @@
2323
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2424
*/
2525

26+
#if !defined(_STANDALONE)
2627
int sti_dio_cnprobe(bus_space_tag_t, bus_addr_t, int);
2728
void sti_dio_cnattach(bus_space_tag_t, int);
29+
#endif
30+
31+
/* DIO attachment defines */
32+
#define STI_DIO_SCODE_OFFSET 0x02 /* offset to SGC rom, in select codes */
33+
#define STI_DIO_SIZE 0x10 /* expected total device size
34+
in DIO-II size units */

sys/arch/hp300/stand/Makefile.buildboot

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $NetBSD: Makefile.buildboot,v 1.40 2025/05/17 17:27:20 tsutsui Exp $
1+
# $NetBSD: Makefile.buildboot,v 1.41 2025/05/26 12:25:12 tsutsui Exp $
22

33
# RELOC=FFF00000 allows for boot prog up to FF000 (1044480) bytes long
44
RELOC= FFF00000
@@ -57,7 +57,7 @@ CPPFLAGS+= -DHEAP_LIMIT="0xffffdfff"
5757
COMMONSOURCE= srt0.S autoconf.c clock.c conf.c cons.c devopen.c \
5858
exec.c machdep.c prf.c rawfs.c netio.c
5959
DRIVERSOURCE= apci.c ct.c dca.c dcm.c dnkbd.c fhpib.c hil.c \
60-
hpib.c if_le.c ite.c ite_dumb.c ite_dv.c ite_gb.c \
60+
hpib.c if_le.c ite.c ite_dv.c ite_gb.c \
6161
ite_hy.c ite_rb.c ite_subr.c ite_tc.c ite_tvrx.c \
6262
ite_sti.c \
6363
kbd.c kbdconf.c nhpib.c rd.c scsi.c sd.c

sys/arch/hp300/stand/common/ite.c

Lines changed: 133 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
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.
@@ -49,6 +49,7 @@
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

6768
struct 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 */
119191
int itecons = -1;
120192
struct 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

Comments
 (0)