Port-hp300 archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Console on 9000/425t with A1659A graphics



> That worked, thank you! I suspect this code just needs some logic
> to know that a t-series machine has SGC slot 3 while e-series has 0.

OpenBSD/hp300 (maintaind by Miod-san) checked all the SGC bus slots:
 http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/sys/arch/hp300/hp300/Attic/wscons_machdep.c?annotate=1.12

---
267: #if NSTI_SGC > 0
268:        /*
269:         * Scan the SGC bus.
270:         */
271:        for (scode = 0; scode < SGC_NSLOTS; scode++) {
272:                int rv;
273:
274:                /* Map current PA. */
275:                pa = (paddr_t)sgc_slottopa(scode);
276:                va = (vaddr_t)iomap((caddr_t)pa, PAGE_SIZE);
277:                if (va == 0)
278:                        continue;
279:
280:                /* Check to see if hardware exists. */
281:                rv = badaddr((caddr_t)va);
282:                iounmap((caddr_t)va, PAGE_SIZE);
283:                if (rv != 0)
284:                        continue;
285:
286:                /* Check hardware. */
287:                if (sti_sgc_probe(&hp300_mem_tag, scode) != 0) {
288:                        wsfbcninit = sticninit;
289:                        tmpconscode = SGC_SLOT_TO_CONSCODE(scode);
290:                        mapsize = 0;
291:                        va = 0;
292:                        goto found;
293:                }
294:        }
295: #endif
---

so I'll put the similar change for the sti console code:
---

Index: hp300/autoconf.c
===================================================================
RCS file: /cvsroot/src/sys/arch/hp300/hp300/autoconf.c,v
retrieving revision 1.105
diff -u -p -d -r1.105 autoconf.c
--- hp300/autoconf.c	20 Apr 2014 04:12:54 -0000	1.105
+++ hp300/autoconf.c	16 Dec 2018 17:22:08 -0000
@@ -152,6 +152,7 @@ __KERNEL_RCSID(0, "$NetBSD: autoconf.c,v
 #endif
 
 #if NSTI_SGC > 0
+#include <hp300/dev/sgcreg.h>
 #include <hp300/dev/sgcvar.h>
 #include <hp300/dev/sti_sgcvar.h>
 #endif
@@ -838,13 +839,17 @@ hp300_cninit(void)
 	    machineid == HP_433) {
 		struct bus_space_tag sgc_tag;
 		bus_space_tag_t sgc_bst;
+		u_int slot;
 
 		sgc_bst = &sgc_tag;
 		memset(sgc_bst, 0, sizeof(struct bus_space_tag));
 		sgc_bst->bustype = HP300_BUS_SPACE_SGC;
-		if (sti_sgc_cnprobe(sgc_bst, sgc_slottopa(0), 0)) {
-			cninit_deferred = true;
-			goto find_kbd;
+		for (slot = 0; slot < SGC_NSLOTS; slot++) {
+			if (sti_sgc_cnprobe(sgc_bst, sgc_slottopa(slot),
+			    slot)) {
+				cninit_deferred = true;
+				goto find_kbd;
+			}
 		}
 	}
 #endif

---

This works fine on my HP425e:

---
bootinfo found at 0xfd002000
Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
    2018 The NetBSD Foundation, Inc.  All rights reserved.
Copyright (c) 1982, 1986, 1989, 1991, 1993
    The Regents of the University of California.  All rights reserved.

NetBSD 8.0 (GENERIC) #0: Mon Dec 17 02:01:27 JST 2018
	tsutsui@mirage:/s/src/sys/arch/hp300/compile/GENERIC
HP 9000/425e (25MHz MC68040 CPU+MMU+FPU, 4k on-chip physical I/D caches)
total memory = 49140 KB
avail memory = 43484 KB
timecounter: Timecounters tick every 10.000 msec
Kernelized RAIDframe activated
mainbus0 (root)
intio0 at mainbus0
rtc at intio0 not configured
frodo0 at intio0 addr 0x41c000 ipl 5
dnkbd0 at frodo0 offset 0x0: no keyboard
com1 at frodo0 offset 0x20: ns8250 or ns16450, no fifo
com2 at frodo0 offset 0x40: ns8250 or ns16450, no fifo
com3 at frodo0 offset 0x60: ns8250 or ns16450, no fifo
mcclock0 at frodo0 offset 0x80: mc146818 compatible time-of-day clock
hil0 at intio0 addr 0x428000 ipl 1
dma0 at intio0 addr 0x500000 ipl 1: 98620C, 2 channels, 32-bit DMA
dio0 at mainbus0
arcofi0 at dio0 scode 8 ipl 6
audio0 at arcofi0: half duplex, playback, capture, mmap
arcofi0: Virtual format configured - Format SLINEAR, precision 16, channels 1, frequency 8000
arcofi0: Latency: 192 milliseconds
spkr0 at audio0: PC Speaker (synthesized)
internal parallel at dio0 scode 12 ipl 3 not configured
spc0 at dio0 scode 14 ipl 4: 98265A SCSI, 32-bit DMA, SCSI ID 7
scsibus0 at spc0: 8 targets, 8 luns per target
le0 at dio0 scode 21 ipl 5: address 08:00:09:15:35:44
le0: 8 receive buffers, 2 transmit buffers
sgc0 at mainbus0
sti0 at sgc0 slot 0: rev 8.02;75, ID 0x27134C9F40A00499
sti0: EVRX, 2048x1024 frame buffer, 1280x1024x8 display
sti0: 10x20 font type 1, 40 bpc, charset 0-255
wsdisplay0 at sti0 kbdmux 1: console (std, vt100 emulation)
wsmux1: connecting to wsdisplay0
timecounter: Timecounter "clockinterrupt" frequency 100 Hz quality 0
timecounter: Timecounter "mc6840" frequency 250000 Hz quality 100
scsibus0: waiting 2 seconds for devices to settle...
hilkbd0 at hil0 code 1: 109-key keyboard, layout 2
wskbd0 at hilkbd0 mux 1
wskbd0: connecting to wsdisplay0
hilms0 at hil0 code 2: Mouse, 2 axes, 3 buttons
wsmouse0 at hilms0 mux 0
sd0 at scsibus0 target 0 lun 0: <MELCO, DSC-G, 1.00> disk fixed
sd0: 30533 MB, 62037 cyl, 16 head, 63 sec, 512 bytes/sect x 62533296 sectors
sd0: async, 8-bit transfers
boot device: sd0
root on sd0a dumps on sd0b
root file system type: ffs
kern.module.path=/stand/hp300/8.0/modules
---

Could you also try the change on your 425t?


> Now I wonder what it'll take to get actual graphics… :)

There is an old diff (back in 2014, for OSunC Kagawa and OSC Shimane)
when I tried to implement the mmap(2) function for sti(4) framebuffer
for mlterm-fb demonstration:

---
Index: dev/ic/sti.c
===================================================================
RCS file: /cvsroot/src/sys/dev/ic/sti.c,v
retrieving revision 1.16.8.1
diff -u -p -d -r1.16.8.1 sti.c
--- dev/ic/sti.c	21 May 2014 20:56:36 -0000	1.16.8.1
+++ dev/ic/sti.c	22 Aug 2014 12:14:43 -0000
@@ -90,14 +90,6 @@ struct wsdisplay_emulops sti_emulops = {
 	sti_alloc_attr
 };
 
-int sti_ioctl(void *, void *, u_long, void *, int, struct lwp *);
-paddr_t sti_mmap(void *, void *, off_t, int);
-int sti_alloc_screen(void *, const struct wsscreen_descr *,
-	void **, int *, int *, long *);
-	void sti_free_screen(void *, void *);
-int sti_show_screen(void *, void *, int, void (*cb)(void *, int, int), void *);
-int sti_load_font(void *, void *, struct wsdisplay_font *);
-
 const struct wsdisplay_accessops sti_accessops = {
 	sti_ioctl,
 	sti_mmap,
@@ -869,10 +861,19 @@ sti_init(struct sti_screen *scr, int mod
 	KASSERT(rom != NULL);
 	memset(&a, 0, sizeof(a));
 
-	a.flags.flags = STI_INITF_WAIT | STI_INITF_CMB | STI_INITF_EBET |
-	    (mode & STI_TEXTMODE ? STI_INITF_TEXT | STI_INITF_PBET |
-	     STI_INITF_PBETI | STI_INITF_ICMT : 0) |
-	    (mode & STI_CLEARSCR ? STI_INITF_CLEAR : 0);
+	a.flags.flags = STI_INITF_WAIT | STI_INITF_EBET;
+	if ((mode & STI_TEXTMODE) != 0) {
+		a.flags.flags |= STI_INITF_TEXT | STI_INITF_CMB |
+		    STI_INITF_PBET | STI_INITF_PBETI | STI_INITF_ICMT;
+	}
+#if 1 /* XXX no screen output without STI_INITF_TEXT */
+	else {
+		a.flags.flags |= STI_INITF_TEXT;
+	}
+#endif
+
+	if ((mode & STI_CLEARSCR) != 0)
+		a.flags.flags |= STI_INITF_CLEAR;
 	a.in.text_planes = 1;
 	a.in.ext_in = &a.ein;
 
Index: dev/ic/stivar.h
===================================================================
RCS file: /cvsroot/src/sys/dev/ic/stivar.h,v
retrieving revision 1.7.8.1
retrieving revision 1.9
diff -u -p -d -r1.7.8.1 -r1.9
--- dev/ic/stivar.h	21 May 2014 20:56:36 -0000	1.7.8.1
+++ dev/ic/stivar.h	29 Jun 2014 04:08:43 -0000	1.9
@@ -131,6 +131,15 @@ void	sti_describe(struct sti_softc *);
 void	sti_end_attach(struct sti_softc *);
 u_int	sti_rom_size(bus_space_tag_t, bus_space_handle_t);
 
+int	sti_ioctl(void *, void *, u_long, void *, int, struct lwp *);
+paddr_t	sti_mmap(void *, void *, off_t, int);
+int	sti_alloc_screen(void *, const struct wsscreen_descr *,
+	    void **, int *, int *, long *);
+void	sti_free_screen(void *, void *);
+int	sti_show_screen(void *, void *, int, void (*cb)(void *, int, int),
+	    void *);
+int	sti_load_font(void *, void *, struct wsdisplay_font *);
+
 int	sti_cnattach(struct sti_rom *, struct sti_screen *, bus_space_tag_t,
 	    bus_addr_t *, u_int);
 
Index: arch/hp300/dev/sti_sgc.c
===================================================================
RCS file: /cvsroot/src/sys/arch/hp300/dev/sti_sgc.c,v
retrieving revision 1.2.2.2
diff -u -p -d -r1.2.2.2 sti_sgc.c
--- arch/hp300/dev/sti_sgc.c	21 May 2014 20:56:36 -0000	1.2.2.2
+++ arch/hp300/dev/sti_sgc.c	22 Aug 2014 12:14:43 -0000
@@ -35,6 +35,7 @@ __KERNEL_RCSID(0, "$NetBSD$");
 
 #include <uvm/uvm_extern.h>
 
+#include <dev/wscons/wsconsio.h>
 #include <dev/wscons/wsdisplayvar.h>
 
 #include <dev/ic/stireg.h>
@@ -44,6 +45,14 @@ __KERNEL_RCSID(0, "$NetBSD$");
 #include <hp300/dev/sti_sgcvar.h>
 #include <machine/autoconf.h>
 
+struct sti_sgc_softc {
+	struct sti_softc sc_sti;
+
+	paddr_t sc_bitmap;
+};
+
+#define STI_SGC_FBOFFSET	0x200000
+
 static int sticonslot = -1;
 static struct sti_rom sticn_rom;
 static struct sti_screen sticn_scr;
@@ -54,9 +63,20 @@ static void sti_sgc_attach(device_t, dev
 
 static int sti_sgc_probe(bus_space_tag_t, int);
 
-CFATTACH_DECL_NEW(sti_sgc, sizeof(struct sti_softc),
+CFATTACH_DECL_NEW(sti_sgc, sizeof(struct sti_sgc_softc),
     sti_sgc_match, sti_sgc_attach, NULL, NULL);
 
+static paddr_t sti_sgc_mmap(void *, void *, off_t, int);
+
+static const struct wsdisplay_accessops sti_sgc_accessops = {
+	sti_ioctl,
+	sti_sgc_mmap,
+	sti_alloc_screen,
+	sti_free_screen,
+	sti_show_screen,
+	sti_load_font
+};
+
 static int
 sti_sgc_match(device_t parent, struct cfdata *cf, void *aux)
 {
@@ -75,22 +95,27 @@ sti_sgc_match(device_t parent, struct cf
 static void
 sti_sgc_attach(device_t parent, device_t self, void *aux)
 {
-	struct sti_softc *sc = device_private(self);
+	struct sti_sgc_softc *sc = device_private(self);
+	struct sti_softc *ssc = &sc->sc_sti;
+	struct sti_screen *scr;
 	struct sgc_attach_args *saa = aux;
 	bus_space_handle_t romh;
 	bus_addr_t base;
+	struct wsemuldisplaydev_attach_args waa;
 	u_int romend;
 	int i;
 
-	sc->sc_dev = self;
+	ssc->sc_dev = self;
 
 	if (saa->saa_slot == sticonslot) {
-		sc->sc_flags |= STI_CONSOLE | STI_ATTACHED;
-		sc->sc_rom = &sticn_rom;
-		sc->sc_scr = &sticn_scr;
-		memcpy(sc->bases, sticn_bases, sizeof(sc->bases));
+		ssc->sc_flags |= STI_CONSOLE | STI_ATTACHED;
+		ssc->sc_rom = &sticn_rom;
+		ssc->sc_rom->rom_softc = ssc;
+		ssc->sc_scr = &sticn_scr;
+		ssc->sc_scr->scr_rom = ssc->sc_rom;
+		memcpy(ssc->bases, sticn_bases, sizeof(ssc->bases));
 
-		sti_describe(sc);
+		sti_describe(ssc);
 	} else {
 		base = (bus_addr_t)sgc_slottopa(saa->saa_slot);
 		if (bus_space_map(saa->saa_iot, base, PAGE_SIZE, 0, &romh)) {
@@ -109,11 +134,11 @@ sti_sgc_attach(device_t parent, device_t
 			return;
 		}
 
-		sc->bases[0] = romh;
+		ssc->bases[0] = romh;
 		for (i = 0; i < STI_REGION_MAX; i++)
-			sc->bases[i] = base;
+			ssc->bases[i] = base;
 
-		if (sti_attach_common(sc, saa->saa_iot, saa->saa_iot, romh,
+		if (sti_attach_common(ssc, saa->saa_iot, saa->saa_iot, romh,
 		    STI_CODEBASE_ALT) != 0)
 			return;
 	}
@@ -121,10 +146,35 @@ sti_sgc_attach(device_t parent, device_t
 	/*
 	 * Note on 425e sti(4) framebuffer bitmap memory can be accessed at
 	 * (sgc_slottopa(saa->saa_slot) + 0x200000)
-	 * but the mmap function to map bitmap display is not provided yet.
 	 */
+	sc->sc_bitmap = sgc_slottopa(saa->saa_slot) + STI_SGC_FBOFFSET;
 
-	sti_end_attach(sc);
+	scr = ssc->sc_scr;
+	scr->scr_wsmode = WSDISPLAYIO_MODE_EMUL;
+
+#if 0 /* XXX no ROM palette function is provided on 425e */
+	/*
+	 * initialize color map
+	 * XXX: depend on cmap data in rasops(4)
+	 */
+	for (i = 0; i < STI_NCMAP; i++) {
+		extern const u_char rasops_cmap[256*3];
+		extern int sti_setcment(struct sti_screen *, u_int,
+		    u_char, u_char, u_char);
+		scr->scr_rcmap[i] = rasops_cmap[i * 3 + 0];
+		scr->scr_gcmap[i] = rasops_cmap[i * 3 + 1];
+		scr->scr_bcmap[i] = rasops_cmap[i * 3 + 2];
+		sti_setcment(scr, STI_NCMAP,
+		    scr->scr_rcmap[0], scr->scr_gcmap[0], scr->scr_bcmap[0]);
+	}
+#endif
+
+	waa.console = ssc->sc_flags & STI_CONSOLE ? 1 : 0;
+	waa.scrdata = &scr->scr_screenlist;
+	waa.accessops = &sti_sgc_accessops;
+	waa.accesscookie = scr;
+
+	config_found(ssc->sc_dev, &waa, wsemuldisplaydevprint);
 }
 
 static int
@@ -153,6 +203,33 @@ sti_sgc_probe(bus_space_tag_t iot, int s
 	return 1;
 }
 
+static paddr_t
+sti_sgc_mmap(void *v, void *vs, off_t offset, int prot)
+{
+	struct sti_screen *scr = (struct sti_screen *)v;
+	struct sti_rom *rom = scr->scr_rom;
+	struct sti_softc *ssc = rom->rom_softc;
+	struct sti_sgc_softc *sc = device_private(ssc->sc_dev);
+	paddr_t cookie = -1;
+
+	if ((offset & PAGE_MASK) != 0)
+		return -1;
+
+	switch (scr->scr_wsmode) {
+	case WSDISPLAYIO_MODE_MAPPED:
+		/* not implemented yet; what should be shown? */
+		break;
+	case WSDISPLAYIO_MODE_DUMBFB:
+		if (offset >= 0 && offset < (scr->fbwidth * scr->fbheight))
+			cookie = m68k_btop(sc->sc_bitmap + offset);
+		break;
+	default:
+		break;
+	}
+
+	return cookie;
+}
+
 int
 sti_sgc_cnprobe(bus_space_tag_t bst, bus_addr_t addr, int slot)
 {

---

This needs more hardware info (especially about color palette) and
proper review, though...

---
Izumi Tsutsui


Home | Main Index | Thread Index | Old Index