Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 16 Dec 2002 23:14:38 -0800 (PST)
From:      Marcel Moolenaar <marcel@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 22407 for review
Message-ID:  <200212170714.gBH7EcJb001282@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=22407

Change 22407 by marcel@marcel_nfs on 2002/12/16 23:13:47

	Catch up with VGAng:
	o  Add vga_machdep.c to help with low-level console selection in
	   the same way we have sio_machdep.c,
	o  Normalize on using bst for tag and bsh handle in the context
	   of newbus,
	o  Leak some changes I had in vga_vid.c that don't make a bit of
	   difference.

Affected files ...

.. //depot/projects/ia64/sys/conf/files.ia64#25 edit
.. //depot/projects/ia64/sys/dev/vga/vga.c#5 edit
.. //depot/projects/ia64/sys/dev/vga/vga.h#4 edit
.. //depot/projects/ia64/sys/dev/vga/vga_pci.c#4 edit
.. //depot/projects/ia64/sys/dev/vga/vga_vid.c#4 edit
.. //depot/projects/ia64/sys/ia64/ia64/vga_machdep.c#1 add

Differences ...

==== //depot/projects/ia64/sys/conf/files.ia64#25 (text+ko) ====

@@ -69,6 +69,7 @@
 ia64/ia64/trap.c		standard
 ia64/ia64/unaligned.c		standard
 ia64/ia64/unwind.c		standard
+ia64/ia64/vga_machdep.c		optional	vga
 ia64/ia64/vm_machdep.c		standard
 ia64/isa/isa.c			optional	isa
 ia64/isa/isa_dma.c		optional	isa

==== //depot/projects/ia64/sys/dev/vga/vga.c#5 (text+ko) ====

@@ -50,7 +50,7 @@
 
 	ofs = y * 160 + x * 2;
 	w = color * 256 + ascii;
-	bus_space_write_2(sc->vga_screen.tag, sc->vga_screen.handle, ofs, w);
+	bus_space_write_2(sc->vga_screen.bst, sc->vga_screen.bsh, ofs, w);
 }
 
 static void
@@ -64,9 +64,9 @@
 	/* Copy data on lower 24 lines 1 line up. */
 	count = 24*80;
 	while (count--) {
-		w = bus_space_read_2(sc->vga_screen.tag, sc->vga_screen.handle,
+		w = bus_space_read_2(sc->vga_screen.bst, sc->vga_screen.bsh,
 		    ofs + 160);
-		bus_space_write_2(sc->vga_screen.tag, sc->vga_screen.handle,
+		bus_space_write_2(sc->vga_screen.bst, sc->vga_screen.bsh,
 		    ofs, w);
 		ofs += 2;
 	}
@@ -75,7 +75,7 @@
 	count = 80;
 	w = (w & 0xff00) | 0x20;
 	while (count--) {
-		bus_space_write_2(sc->vga_screen.tag, sc->vga_screen.handle,
+		bus_space_write_2(sc->vga_screen.bst, sc->vga_screen.bsh,
 		    ofs, w);
 		ofs += 2;
 	}
@@ -139,8 +139,8 @@
 	sc = device_get_softc(dev);
 
 	sc->vga_screen = sc->vga_fb;
-	error = bus_space_subregion(sc->vga_fb.tag, sc->vga_fb.handle,
-	    (sc->vga_mono) ? 0x10000 : 0x18000, 4096, &sc->vga_screen.handle);
+	error = bus_space_subregion(sc->vga_fb.bst, sc->vga_fb.bsh,
+	    (sc->vga_mono) ? 0x10000 : 0x18000, 4096, &sc->vga_screen.bsh);
 	if (error)
 		return (error);
 

==== //depot/projects/ia64/sys/dev/vga/vga.h#4 (text+ko) ====

@@ -30,8 +30,8 @@
 
 struct vga_space
 {
-	bus_space_tag_t		tag;
-	bus_space_handle_t	handle;
+	bus_space_tag_t		bst;
+	bus_space_handle_t	bsh;
 };
 
 struct vga_softc
@@ -60,6 +60,14 @@
 #define	vga_reg		vga_space[VGA_RES_REG]
 #define	vga_crtc	vga_space[VGA_RES_CRTC]
 
+struct vga_consdata {
+	struct vga_space	fb;
+	struct vga_space	reg;
+	struct vga_space	crtc;
+};
+
+int vga_get_console(struct vga_consdata*);
+
 extern struct vga_softc	vga_console;
 extern devclass_t vga_devclass;
 extern char vga_device_name[];

==== //depot/projects/ia64/sys/dev/vga/vga_pci.c#4 (text+ko) ====

@@ -69,8 +69,8 @@
 	if (res == NULL)
 		return (ENXIO);
 
-	sc->vga_space[rid].handle = rman_get_bushandle(res);
-	sc->vga_space[rid].tag = rman_get_bustag(res);
+	sc->vga_space[rid].bsh = rman_get_bushandle(res);
+	sc->vga_space[rid].bst = rman_get_bustag(res);
 	return (0);
 }
 
@@ -124,7 +124,7 @@
 	/*
 	 * Determine if the VGA controller is in colour or monochrome mode.
 	 */
-	x = bus_space_read_1(sc->vga_reg.tag, sc->vga_reg.handle,
+	x = bus_space_read_1(sc->vga_reg.bst, sc->vga_reg.bsh,
 	    VGA_REG_MISC);
 	sc->vga_mono = (x & 1) ? 0 : 1;
 

==== //depot/projects/ia64/sys/dev/vga/vga_vid.c#4 (text+ko) ====

@@ -124,8 +124,9 @@
 vga_vid_config(int flags)
 {
 	static int called = 0;
+	struct vga_consdata cd;
 	struct vga_softc *sc = &vga_console;
-	u_int8_t x;
+	uint8_t misc;
 
 	if (called++ == 0) {
 		bzero(&vga_adapter, sizeof(vga_adapter));
@@ -137,45 +138,57 @@
 	 * first time it's as part of console probing. The second time
 	 * it's as part of the regular syscons initialization.
 	 */
-	if (sc->vga_console == 1)
-		goto adapter;
+	if (vga_adapter.va_flags & V_ADP_PROBED)
+		goto init_adapter;
 
-	/*
-	 * XXX we actually need to test here of course.
-	 */
-	sc->vga_fb.tag = IA64_BUS_SPACE_MEM;
-	sc->vga_fb.handle = (6ULL << 61) + 0xA0000;
-	sc->vga_reg.tag = IA64_BUS_SPACE_IO;
-	sc->vga_reg.handle = 0x3c0;
+	if (vga_get_console(&cd))
+		return (0);
 
-	/*
-	 * Determine if the VGA controller is in colour or monochrome mode.
-	 */
-	x = bus_space_read_1(sc->vga_reg.tag, sc->vga_reg.handle,
-	    VGA_REG_MISC);
-	sc->vga_mono = (x & 1) ? 0 : 1;
+	sc->vga_fb = cd.fb;
+	sc->vga_reg = cd.reg;
+	sc->vga_crtc = cd.crtc;
 
-	sc->vga_crtc.tag = IA64_BUS_SPACE_IO;
-	sc->vga_crtc.handle = (sc->vga_mono) ? 0x3b0 : 0x3d0;
+	misc = bus_space_read_1(sc->vga_reg.bst, sc->vga_reg.bsh, VGA_REG_MISC);
+	sc->vga_mono = (misc & 1) ? 0 : 1;
 
-	sc->vga_screen.tag = sc->vga_fb.tag;
-	(void)bus_space_subregion(sc->vga_fb.tag, sc->vga_fb.handle,
-	    (sc->vga_mono) ? 0x10000 : 0x18000, 4096, &sc->vga_screen.handle);
+	sc->vga_screen.bst = sc->vga_fb.bst;
+	(void)bus_space_subregion(sc->vga_fb.bst, sc->vga_fb.bsh,
+	    (sc->vga_mono) ? 0x10000 : 0x18000, 4096, &sc->vga_screen.bsh);
 
 	sc->vga_console = 1;
+	vga_adapter.va_flags |= V_ADP_PROBED;
 
- adapter:
-	if (vga_adapter.va_flags & V_ADP_PROBED)
-		return (1);
+ init_adapter:
+	if (vga_adapter.va_flags & V_ADP_INITIALIZED)
+		goto register_adapter;
 
-	vga_adapter.va_flags |= V_ADP_PROBED;
 	vga_adapter.va_flags |= (sc->vga_mono) ? 0 : V_ADP_COLOR;
 	vga_adapter.va_name = vga_device_name;
 	vga_adapter.va_type = KD_VGA;
-	vga_adapter.va_crtc_tag = sc->vga_crtc.tag;
-	vga_adapter.va_crtc_handle = sc->vga_crtc.handle;
-	vga_adapter.va_window = sc->vga_screen.handle;
+	vga_adapter.va_crtc_tag = sc->vga_crtc.bst;
+	vga_adapter.va_crtc_handle = sc->vga_crtc.bsh;
+	vga_adapter.va_window = sc->vga_screen.bsh; /* XXX */
+
+	vga_adapter.va_info.vi_mode = 3;
+	vga_adapter.va_info.vi_flags = V_INFO_COLOR;
+	vga_adapter.va_info.vi_width = 80;
+	vga_adapter.va_info.vi_height = 25;
+	vga_adapter.va_info.vi_cwidth = 8;
+	vga_adapter.va_info.vi_cheight = 16;
+	vga_adapter.va_info.vi_depth = 4;
+	vga_adapter.va_info.vi_planes = 1;
+	vga_adapter.va_info.vi_window = vga_adapter.va_window;
+	vga_adapter.va_info.vi_window_size = 4096;
+	vga_adapter.va_info.vi_buffer_size = 4096;
+	vga_adapter.va_info.vi_mem_model = V_INFO_MM_TEXT;
+	vga_adapter.va_flags |= V_ADP_INITIALIZED;
+
+ register_adapter:
+	if (vga_adapter.va_flags & V_ADP_REGISTERED)
+		return (1);
+
 	vid_register(&vga_adapter);
+	vga_adapter.va_flags |= V_ADP_REGISTERED;
 	return (1);
 }
 
@@ -224,19 +237,12 @@
 vga_vid_get_info(video_adapter_t *adp, int mode, video_info_t *info)
 {
 
-	bzero(info, sizeof(*info));
-	info->vi_mode = 3;
-	info->vi_flags = V_INFO_COLOR;
-	info->vi_width = 80;
-	info->vi_height = 25;
-	info->vi_cwidth = 8;
-	info->vi_cheight = 16;
-	info->vi_depth = 4;
-	info->vi_planes = 1;
-	info->vi_window = adp->va_window;
-	info->vi_window_size = 4096;
-	info->vi_buffer_size = info->vi_window_size;
-	info->vi_mem_model = V_INFO_MM_TEXT;
+	if (info == &adp->va_info) {
+		vga_puts(&vga_console,
+		    "XXX: vga_vid_get_info: called to fill in adapter\n");
+		return (0);
+	}
+	memcpy(info, &adp->va_info, sizeof(*info));
 	return (0);
 }
 
@@ -315,11 +321,13 @@
 	bus_space_write_1(tag, handle, 0, 14);
 	bus_space_barrier(tag, handle, 0, 2, -1);
 	ofs = bus_space_read_1(tag, handle, 1) << 8;
+	bus_space_barrier(tag, handle, 0, 2, -1);
 	bus_space_write_1(tag, handle, 0, 15);
 	bus_space_barrier(tag, handle, 0, 2, -1);
 	ofs |= bus_space_read_1(tag, handle, 1) & 0xff;
-	*row = ofs / 80;
-	*col = ofs % 80;
+	bus_space_barrier(tag, handle, 0, 2, -1);
+	*row = ofs / adp->va_info.vi_width;
+	*col = ofs % adp->va_info.vi_width;
 	splx(s);
 	return (0);
 }
@@ -371,12 +379,12 @@
 	bus_space_write_1(tag, handle, 0, 10);
 	bus_space_barrier(tag, handle, 0, 2, -1);
 	bus_space_write_1(tag, handle, 1, (height > 0)
-	    ? celsize - base - height : 32);
+	    ? (celsize - base - height) & 0x1f : 0x20);
 	bus_space_barrier(tag, handle, 0, 2, -1);
 	bus_space_write_1(tag, handle, 0, 11);
 	bus_space_barrier(tag, handle, 0, 2, -1);
 	bus_space_write_1(tag, handle, 1, (height > 0)
-	    ? celsize - base - 1 : 0);
+	    ? (celsize - base - 1) & 0x1f : 0);
 	bus_space_barrier(tag, handle, 0, 2, -1);
 	splx(s);
 	return (0);
@@ -394,7 +402,7 @@
 	tag = adp->va_crtc_tag;
 
 	s = spltty();
-	ofs = (col == -1 && row == -1) ? -1 : row * 80 + col;
+	ofs = (col != -1 || row != -1) ? row*adp->va_info.vi_width + col : -1;
 	bus_space_write_1(tag, handle, 0, 14);
 	bus_space_barrier(tag, handle, 0, 2, -1);
 	bus_space_write_1(tag, handle, 1, ofs >> 8);

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe p4-projects" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200212170714.gBH7EcJb001282>