Source-Changes-HG archive

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

[src/sommerfeld_i386mp_1]: src/sys/arch/i386/bios explicitely set ds, es, fs ...



details:   https://anonhg.NetBSD.org/src/rev/42606e183141
branches:  sommerfeld_i386mp_1
changeset: 482565:42606e183141
user:      drochner <drochner%NetBSD.org@localhost>
date:      Sun Jul 14 14:39:45 2002 +0000

description:
explicitely set ds, es, fs and gs to 0 before calling kvm86;
use the right places in the trap frame (the 4 segment registers which
get loaded on a rti to VM86 mode) to set them for BIOS calls
(we have never set them to anything but 0 before, so it didn't matter)

diffstat:

 sys/arch/i386/bios/vesa_raster8.c |  183 ++++++++++++++++++++++++
 sys/arch/i386/bios/vesabios.c     |  279 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 462 insertions(+), 0 deletions(-)

diffs (truncated from 470 to 300 lines):

diff -r d3df60c13d43 -r 42606e183141 sys/arch/i386/bios/vesa_raster8.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/i386/bios/vesa_raster8.c Sun Jul 14 14:39:45 2002 +0000
@@ -0,0 +1,183 @@
+/* $NetBSD: vesa_raster8.c,v 1.2.4.2 2002/07/14 14:39:45 drochner Exp $ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/device.h>
+#include <sys/malloc.h>
+#include <machine/frame.h>
+#include <machine/kvm86.h>
+#include <machine/bus.h>
+
+#include <arch/i386/bios/vesabios.h>
+#include <arch/i386/bios/vesabiosreg.h>
+
+#include <dev/wscons/wsdisplayvar.h>
+#include <dev/rasops/rasops.h>
+
+static int vesaraster8_match(struct device *, struct cfdata *, void *);
+static void vesaraster8_attach(struct device *, struct device *, void *);
+
+struct vesaraster8sc {
+       struct device sc_dev;
+       int sc_mode;
+       struct rasops_info sc_ri;
+};
+
+struct cfattach vesarasterviii_ca = {
+       sizeof(struct vesaraster8sc), vesaraster8_match, vesaraster8_attach
+};
+
+static int
+vesaraster8_match(parent, match, aux)
+       struct device *parent;
+       struct cfdata *match;
+       void *aux;
+{
+       struct vesabiosdev_attach_args *vaa = aux;
+
+       if (strcmp(vaa->vbaa_type, "raster8"))
+               return (0);
+
+       return (1);
+}
+
+static void
+vesaraster8_attach(parent, dev, aux)
+       struct device *parent, *dev;
+       void *aux;
+{
+       struct vesaraster8sc *sc = (struct vesaraster8sc *)dev;
+       struct vesabiosdev_attach_args *vaa = aux;
+       unsigned char *buf;
+       struct trapframe tf;
+       int res;
+       struct modeinfoblock *mi;
+       struct rasops_info *ri;
+       bus_space_handle_t h;
+
+       buf = kvm86_bios_addpage(0x2000);
+       if (!buf) {
+               printf("vesaraster8_attach: kvm86_bios_addpage(0x2000) failed\n");
+               return;
+       }
+
+       sc->sc_mode = vaa->vbaa_modes[0]; /* XXX */
+
+       memset(&tf, 0, sizeof(struct trapframe));
+       tf.tf_eax = 0x4f01; /* function code */
+       tf.tf_ecx = sc->sc_mode;
+       tf.tf_vm86_es = 0;
+       tf.tf_edi = 0x2000; /* buf ptr */
+
+       res = kvm86_bioscall(0x10, &tf);
+       if (res || tf.tf_eax != 0x004f) {
+               printf("vbecall: res=%d, ax=%x\n", res, tf.tf_eax);
+               goto out;
+       }
+       mi = (struct modeinfoblock *)buf;
+
+       ri = &sc->sc_ri;
+       ri->ri_flg = RI_CENTER;
+       ri->ri_depth = 8;
+       ri->ri_width = mi->XResolution;
+       ri->ri_height = mi->YResolution;
+       ri->ri_stride = mi->BytesPerScanLine;
+
+       res = _i386_memio_map(I386_BUS_SPACE_MEM, mi->PhysBasePtr,
+                             ri->ri_height * ri->ri_stride,
+                             BUS_SPACE_MAP_LINEAR, &h);
+       if (res) {
+               printf("framebuffer mapping failed\n");
+               goto out;
+       }
+       ri->ri_bits = bus_space_vaddr(I386_BUS_SPACE_MEM, h);
+
+       printf(": fb %dx%d @%x\n", ri->ri_width, ri->ri_height,
+              mi->PhysBasePtr);
+out:
+       kvm86_bios_delpage(0x2000, buf);
+       return;
+}
+
+#if 0
+static void
+vb8test(sc)
+       struct vesaraster8sc *sc;
+{
+       struct trapframe tf;
+       int res;
+       int savbufsiz, i;
+       char *errstr = 0;
+       struct rasops_info *ri = &sc->sc_ri;
+       u_long attr;
+
+       memset(&tf, 0, sizeof(struct trapframe));
+       tf.tf_eax = 0x4f04; /* function code */
+       tf.tf_edx = 0x0000; /* query */
+       tf.tf_ecx = 0x000f;
+
+       res = kvm86_bioscall(0x10, &tf);
+       if (res || tf.tf_eax != 0x004f) {
+               printf("vbecall: res=%d, ax=%x\n", res, tf.tf_eax);
+               return;
+       }
+       savbufsiz = roundup(tf.tf_ebx * 64, NBPG) / NBPG;
+       printf("savbuf: %d pg\n", savbufsiz);
+
+       for (i = 0; i < savbufsiz; i++)
+               (void)kvm86_bios_addpage(0x3000 + i * 0x1000);
+
+       memset(&tf, 0, sizeof(struct trapframe));
+       tf.tf_eax = 0x4f04; /* function code */
+       tf.tf_edx = 0x0001; /* save */
+       tf.tf_ecx = 0x000f; /* all (but framebuffer) */
+       tf.tf_vm86_es = 0;
+       tf.tf_ebx = 0x3000; /* buffer */
+
+       res = kvm86_bioscall(0x10, &tf);
+       if (res || tf.tf_eax != 0x004f) {
+               printf("vbecall: res=%d, ax=%x\n", res, tf.tf_eax);
+               return;
+       }
+
+       memset(&tf, 0, sizeof(struct trapframe));
+       tf.tf_eax = 0x4f02; /* function code */
+       tf.tf_ebx = sc->sc_mode | 0x4000; /* flat */
+       tf.tf_ebx |= 0x8000; /* XXX no clear (save fonts in fb) */
+
+       res = kvm86_bioscall(0x10, &tf);
+       if (res || tf.tf_eax != 0x004f) {
+               printf("vbecall: res=%d, ax=%x\n", res, tf.tf_eax);
+               return;
+       }
+
+       if (rasops_init(ri, 20, 50)) {
+               errstr = "rasops_init";
+               goto back;
+       }
+
+       ri->ri_ops.allocattr(ri, 0, 0, 0, &attr);
+       ri->ri_ops.putchar(ri, 1, 1, 'X', attr);
+       ri->ri_ops.putchar(ri, 1, 2, 'Y', attr);
+       ri->ri_ops.putchar(ri, 1, 3, 'Z', attr);
+
+       delay(5000000);
+       errstr = 0;
+back:
+       memset(&tf, 0, sizeof(struct trapframe));
+       tf.tf_eax = 0x4f04; /* function code */
+       tf.tf_edx = 0x0002; /* restore */
+       tf.tf_ecx = 0x000f;
+       tf.tf_vm86_es = 0;
+       tf.tf_ebx = 0x3000; /* buffer */
+
+       res = kvm86_bioscall(0x10, &tf);
+       if (res || tf.tf_eax != 0x004f) {
+               printf("vbecall: res=%d, ax=%x\n", res, tf.tf_eax);
+               return;
+       }
+
+       if (errstr)
+               printf("error: %s\n", errstr);
+}
+#endif
diff -r d3df60c13d43 -r 42606e183141 sys/arch/i386/bios/vesabios.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/i386/bios/vesabios.c     Sun Jul 14 14:39:45 2002 +0000
@@ -0,0 +1,279 @@
+/* $NetBSD: vesabios.c,v 1.5.4.2 2002/07/14 14:39:45 drochner Exp $ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/device.h>
+#include <sys/malloc.h>
+#include <machine/frame.h>
+#include <machine/kvm86.h>
+
+#include <arch/i386/bios/vesabios.h>
+#include <arch/i386/bios/vesabiosreg.h>
+
+#include "opt_vesabios.h"
+
+struct vbeinfoblock
+{
+       char VbeSignature[4];
+       u_int16_t VbeVersion;
+       u_int32_t OemStringPtr;
+       u_int32_t Capabilities;
+       u_int32_t VideoModePtr;
+       u_int16_t TotalMemory;
+       u_int16_t OemSoftwareRev;
+       u_int32_t OemVendorNamePtr, OemProductNamePtr, OemProductRevPtr;
+       /* data area, in total max 512 bytes for VBE 2.0 */
+} __attribute__ ((packed));
+
+#define FAR2FLATPTR(p) ((p & 0xffff) + ((p >> 12) & 0xffff0))
+
+static int vesabios_match(struct device *, struct cfdata *, void *);
+static void vesabios_attach(struct device *, struct device *, void *);
+static int vesabios_print(void *, const char *);
+
+static int vbegetinfo(struct vbeinfoblock **);
+static void vbefreeinfo(struct vbeinfoblock *);
+#ifdef VESABIOSVERBOSE
+static const char *mm2txt(unsigned int);
+#endif
+
+struct cfattach vesabios_ca = {
+       sizeof(struct device), vesabios_match, vesabios_attach
+};
+
+static int
+vesabios_match(parent, match, aux)
+       struct device *parent;
+       struct cfdata *match;
+       void *aux;
+{
+       struct vesabios_attach_args *vaa = aux;
+
+       /* These are not the droids you're looking for. */
+       if (strcmp(vaa->vaa_busname, "vesabios") != 0)
+               return (0);
+
+       return (1);
+}
+
+static int
+vbegetinfo(vip)
+       struct vbeinfoblock **vip;
+{
+       unsigned char *buf;
+       struct trapframe tf;
+       int res, error;
+
+       buf = kvm86_bios_addpage(0x2000);
+       if (!buf) {
+               printf("vbegetinfo: kvm86_bios_addpage(0x2000) failed\n");
+               return (ENOMEM);
+       }
+
+       memcpy(buf, "VBE2", 4);
+
+       memset(&tf, 0, sizeof(struct trapframe));
+       tf.tf_eax = 0x4f00; /* function code */
+       tf.tf_vm86_es = 0;
+       tf.tf_edi = 0x2000; /* buf ptr */
+
+       res = kvm86_bioscall(0x10, &tf);
+       if (res || tf.tf_eax != 0x004f) {
+               printf("vbecall: res=%d, ax=%x\n", res, tf.tf_eax);
+               error = ENXIO;
+               goto out;
+       }
+
+       if (memcmp(((struct vbeinfoblock *)buf)->VbeSignature, "VESA", 4)) {
+               error = EIO;
+               goto out;
+       }
+
+       if (vip)
+               *vip = (struct vbeinfoblock *)buf;
+       return (0);
+
+out:
+       kvm86_bios_delpage(0x2000, buf);
+       return (error);
+}
+
+static void
+vbefreeinfo(vip)
+       struct vbeinfoblock *vip;
+{
+
+       kvm86_bios_delpage(0x2000, vip);
+}
+
+int



Home | Main Index | Thread Index | Old Index