Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 28 Nov 2002 11:20:07 -0800 (PST)
From:      Marcel Moolenaar <marcel@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 21646 for review
Message-ID:  <200211281920.gASJK7wI093490@repoman.freebsd.org>

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

Change 21646 by marcel@marcel_nfs on 2002/11/28 11:19:59

	Round of fixes, changes and enhancements to make this work with
	syscons.

Affected files ...

.. //depot/projects/ia64/sys/dev/vga/vga.c#4 edit
.. //depot/projects/ia64/sys/dev/vga/vga.h#3 edit
.. //depot/projects/ia64/sys/dev/vga/vga_pci.c#3 edit
.. //depot/projects/ia64/sys/dev/vga/vga_vid.c#3 edit

Differences ...

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

@@ -42,18 +42,15 @@
 devclass_t vga_devclass;
 char vga_device_name[] = "vga";
 
-void vga_putc(struct vga_softc *, int);
-
 static void
 vga_write(struct vga_softc *sc, int x, int y, int ascii, int color)
 {
 	u_int32_t ofs;
 	u_int16_t w;
 
-	ofs = (sc->vga_mono) ? 0x10000 : 0x18000;
-	ofs += y * 160 + x * 2;
+	ofs = y * 160 + x * 2;
 	w = color * 256 + ascii;
-	bus_space_write_2(sc->vga_fb.tag, sc->vga_fb.handle, ofs, w);
+	bus_space_write_2(sc->vga_screen.tag, sc->vga_screen.handle, ofs, w);
 }
 
 static void
@@ -62,14 +59,15 @@
 	u_int32_t count, ofs;
 	u_int16_t w;
 
-	ofs = (sc->vga_mono) ? 0x10000 : 0x18000;
+	ofs = 0;
 
 	/* Copy data on lower 24 lines 1 line up. */
 	count = 24*80;
 	while (count--) {
-		w = bus_space_read_2(sc->vga_fb.tag, sc->vga_fb.handle,
+		w = bus_space_read_2(sc->vga_screen.tag, sc->vga_screen.handle,
 		    ofs + 160);
-		bus_space_write_2(sc->vga_fb.tag, sc->vga_fb.handle, ofs, w);
+		bus_space_write_2(sc->vga_screen.tag, sc->vga_screen.handle,
+		    ofs, w);
 		ofs += 2;
 	}
 
@@ -77,7 +75,8 @@
 	count = 80;
 	w = (w & 0xff00) | 0x20;
 	while (count--) {
-		bus_space_write_2(sc->vga_fb.tag, sc->vga_fb.handle, ofs, w);
+		bus_space_write_2(sc->vga_screen.tag, sc->vga_screen.handle,
+		    ofs, w);
 		ofs += 2;
 	}
 }
@@ -107,8 +106,7 @@
 			vga_scrollup(sc);
 		else
 			y++;
-		x = 0;
-		return;
+		/* FALLTHROUGH */
 	case 0x0d:	/* carriage return */
 		x = 0;
 		return;
@@ -124,17 +122,32 @@
 	}
 }
 
+void
+vga_puts(struct vga_softc *sc, const char *s)
+{
+
+	while (*s)
+		vga_putc(sc, *s++);
+}
+
 int vga_attach(device_t dev)
 {
 	struct vga_softc *sc;
+	int error;
 	u_int32_t x, y;
 
 	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);
+	if (error)
+		return (error);
+
 	sc->vga_enable = 1;
 
 	if (sc->vga_console)
-		return (vga_cnattach(dev));
+		return (0);
 
 	for (y = 0; y < 24; y++)
 		for (x = 0; x < 80; x++)

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

@@ -30,7 +30,6 @@
 
 struct vga_space
 {
-	struct resource		*res;
 	bus_space_tag_t		tag;
 	bus_space_handle_t	handle;
 };
@@ -66,4 +65,6 @@
 extern char vga_device_name[];
 
 int vga_attach(device_t);
-int vga_cnattach(device_t);
+
+void vga_putc(struct vga_softc *, int);
+void vga_puts(struct vga_softc *, const char *);

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

@@ -63,15 +63,14 @@
 static int
 vga_pci_alloc(device_t dev, struct vga_softc *sc, int type, int rid)
 {
-	struct vga_space *sp;
+	struct resource *res;
 
-	sp = sc->vga_space + rid;
-	sp->res = bus_alloc_resource(dev, type, &rid, 0, ~0, 1, RF_ACTIVE);
-	if (sp->res == NULL)
+	res = bus_alloc_resource(dev, type, &rid, 0, ~0, 1, RF_ACTIVE);
+	if (res == NULL)
 		return (ENXIO);
 
-	sp->handle = rman_get_bushandle(sp->res);
-	sp->tag = rman_get_bustag(sp->res);
+	sc->vga_space[rid].handle = rman_get_bushandle(res);
+	sc->vga_space[rid].tag = rman_get_bustag(res);
 	return (0);
 }
 
@@ -101,6 +100,11 @@
 		device_printf(dev, "using legacy I/O and memory addresses.\n");
 		/* If VGA is the console, this device must be it. */
 		device_set_softc(dev, &vga_console);
+		/* Set the legacy resources */
+		bus_set_resource(dev, SYS_RES_MEMORY, VGA_RES_FB,
+		    0xA0000, 0x20000);
+		bus_set_resource(dev, SYS_RES_IOPORT, VGA_RES_REG,
+		    0x3c0, 0x10);
 	} else {
 		device_printf(dev, "sorry; don't know what to do with it\n");
 		return (0);
@@ -110,15 +114,9 @@
 	sc->vga_dev = dev;
 	sc->vga_bustype = VGA_BUSTYPE_PCI;
 
-	/* The softc is already initialized if VGA is the console. */
-	if (sc->vga_console)
-		return (vga_attach(dev));
-
-	bus_set_resource(dev, SYS_RES_MEMORY, VGA_RES_FB, 0xA0000, 0x20000);
 	error = vga_pci_alloc(dev, sc, SYS_RES_MEMORY, VGA_RES_FB);
 	if (error)
 		return (error);
-	bus_set_resource(dev, SYS_RES_IOPORT, VGA_RES_REG, 0x3c0, 0x10);
 	error = vga_pci_alloc(dev, sc, SYS_RES_IOPORT, VGA_RES_REG);
 	if (error)
 		return (error);

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

@@ -36,6 +36,7 @@
 #include <sys/bus.h>
 #include <sys/fbio.h>
 #include <sys/kernel.h>
+#include <sys/rman.h>
 
 #include <dev/fb/fbreg.h>
 
@@ -105,9 +106,12 @@
 static int
 vga_vid_todo(const char *function, int called)
 {
-	printf("vga_vid_todo: %s() called %d times now...\n", function,
+	char buf[256];
+
+	sprintf(buf, "vga_vid_todo: %s() called %d times now...\n", function,
 	    called);
-	return ENODEV;
+	vga_puts(&vga_console, buf);
+	return (ENODEV);
 }
 
 /*
@@ -119,18 +123,21 @@
 static int
 vga_vid_config(int flags)
 {
+	static int called = 0;
 	struct vga_softc *sc = &vga_console;
 	u_int8_t x;
 
-	if (flags)
-		return (0);
+	if (called++ == 0) {
+		bzero(&vga_adapter, sizeof(vga_adapter));
+		bzero(&vga_console, sizeof(vga_console));
+	}
 
 	/*
 	 * We actually get called more than once (twice to be exact). The
 	 * first time it's as part of console probing. The second time
 	 * it's as part of the regular syscons initialization.
 	 */
-	if (sc->vga_enable == 1)
+	if (sc->vga_console == 1)
 		goto adapter;
 
 	/*
@@ -151,23 +158,23 @@
 	sc->vga_crtc.tag = IA64_BUS_SPACE_IO;
 	sc->vga_crtc.handle = (sc->vga_mono) ? 0x3b0 : 0x3d0;
 
+	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_console = 1;
-	sc->vga_enable = 1;
 
  adapter:
 	if (vga_adapter.va_flags & V_ADP_PROBED)
 		return (1);
 
-	bzero(&vga_adapter, sizeof(vga_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_window = sc->vga_fb.handle +
-	    (sc->vga_mono) ? 0x10000 : 0x18000;
-	vga_adapter.va_window_size = 80*25*2;
-	vga_adapter.va_crtc_addr = sc->vga_crtc.handle;
-
+	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;
 	vid_register(&vga_adapter);
 	return (1);
 }
@@ -216,8 +223,21 @@
 static int
 vga_vid_get_info(video_adapter_t *adp, int mode, video_info_t *info)
 {
-	static int called = 0;
-	return (vga_vid_todo(__func__, ++called));
+
+	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;
+	return (0);
 }
 
 static int
@@ -245,8 +265,11 @@
 static int
 vga_vid_load_palette(video_adapter_t *adp, u_char *palette)
 {
+	return (ENODEV);
+#if 0
 	static int called = 0;
 	return (vga_vid_todo(__func__, ++called));
+#endif
 }
 
 static int
@@ -280,8 +303,25 @@
 static int
 vga_vid_read_hw_cursor(video_adapter_t *adp, int *col, int *row)
 {
-	static int called = 0;
-	return (vga_vid_todo(__func__, ++called));
+	bus_space_handle_t handle;
+	bus_space_tag_t tag;
+	int s;
+	uint16_t ofs;
+
+	handle = adp->va_crtc_handle;
+	tag = adp->va_crtc_tag;
+
+	s = spltty();
+	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_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;
+	splx(s);
+	return (0);
 }
 
 static int
@@ -295,8 +335,11 @@
 static int
 vga_vid_save_palette(video_adapter_t *adp, u_char *palette)
 {
+	return (ENODEV);
+#if 0
 	static int called = 0;
 	return (vga_vid_todo(__func__, ++called));
+#endif
 }
 
 static int
@@ -317,15 +360,51 @@
 vga_vid_set_hw_cursor_shape(video_adapter_t *adp, int base, int height,
     int celsize, int blink)
 {
-	static int called = 0;
-	return (vga_vid_todo(__func__, ++called));
+	bus_space_handle_t handle;
+	bus_space_tag_t tag;
+	int s;
+
+	handle = adp->va_crtc_handle;
+	tag = adp->va_crtc_tag;
+
+	s = spltty();
+	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);
+	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);
+	bus_space_barrier(tag, handle, 0, 2, -1);
+	splx(s);
+	return (0);
 }
 
 static int
 vga_vid_set_hw_cursor(video_adapter_t *adp, int col, int row)
 {
-	static int called = 0;
-	return (vga_vid_todo(__func__, ++called));
+	bus_space_handle_t handle;
+	bus_space_tag_t tag;
+	int s;
+	uint16_t ofs;
+
+	handle = adp->va_crtc_handle;
+	tag = adp->va_crtc_tag;
+
+	s = spltty();
+	ofs = (col == -1 && row == -1) ? -1 : row * 80 + col;
+	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);
+	bus_space_barrier(tag, handle, 0, 2, -1);
+	bus_space_write_1(tag, handle, 0, 15);
+	bus_space_barrier(tag, handle, 0, 2, -1);
+	bus_space_write_1(tag, handle, 1, ofs & 0xff);
+	bus_space_barrier(tag, handle, 0, 2, -1);
+	splx(s);
+	return (0);
 }
 
 static int

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?200211281920.gASJK7wI093490>