]> Joshua Wise's Git repositories - netwatch.git/commitdiff
Add a FB access layer.
authorJoshua Wise <joshua@rebirth.joshuawise.com>
Tue, 25 Nov 2008 08:26:35 +0000 (03:26 -0500)
committerJoshua Wise <joshua@rebirth.joshuawise.com>
Tue, 25 Nov 2008 08:26:35 +0000 (03:26 -0500)
aseg-paging/Makefile
aseg-paging/drivers.c [new file with mode: 0644]
aseg-paging/firstrun.c
gendrv/tnt2.c [deleted file]
include/pci.h
net/net.c
pci/pci.c
video/fb.c [new file with mode: 0644]
video/tnt2.c [new file with mode: 0644]

index 9117d9dfc737dea5db4fa70a2e47cc3adc549b02..c9a8f439b008e3eaa9da0c20b543d6c6cf4b89dd 100644 (file)
@@ -43,6 +43,9 @@ OBJS =        ../ich2/smi.o \
        ../net/http/fs.o \
        ../net/http/httpd.o \
        ../net/3c90x.o \
+       ../video/tnt2.o \
+       ../video/fb.o \
+       drivers.o \
        ../lib/minilib.o \
        ../lib/doprnt.o \
        ../lib/sprintf.o \
diff --git a/aseg-paging/drivers.c b/aseg-paging/drivers.c
new file mode 100644 (file)
index 0000000..fca0bfe
--- /dev/null
@@ -0,0 +1,12 @@
+#include <pci.h>
+
+extern struct pci_driver a3c90x_driver;
+extern struct pci_driver tnt2_driver;
+
+struct pci_driver *drivers[] =
+{
+       &a3c90x_driver,
+       &tnt2_driver,
+       0
+};
+
index ca611fa006e5f2a7e820b639711b6e91ebd82d41..48a1ac04b076caf9d76b3723fe11561fbba2087b 100644 (file)
@@ -13,8 +13,11 @@ extern void timer_handler(smi_event_t ev);
 extern void kbc_handler(smi_event_t ev);
 extern void gbl_rls_handler(smi_event_t ev);
 
+extern pci_driver_t *drivers[];
+
 void smi_init() {
        smram_state_t smram;
+       pci_driver_t **driver;
        
        smram = smram_save_state();
        smram_tseg_set_state(SMRAM_TSEG_OPEN);
@@ -31,6 +34,15 @@ void smi_init() {
        smi_disable();
        
        eth_init();
+       
+       /* After everything is initialized, load drivers. */
+       for (driver = drivers; *driver; driver++)
+       {
+               outputf("Probing driver: %s", (*driver)->name);
+               if (pci_probe_driver(*driver))
+                       output("Found a card");
+       }
+       outputf("Driver probe complete");
 
        smi_register_handler(SMI_EVENT_FAST_TIMER, timer_handler);
        smi_enable_event(SMI_EVENT_FAST_TIMER);
diff --git a/gendrv/tnt2.c b/gendrv/tnt2.c
deleted file mode 100644 (file)
index ead2266..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-#include <io.h>
-#include <pci.h>
-
-static void *fbaddr;
-
-static int tnt2_probe(struct pci_dev *pci, void *data)
-{
-       
-}
-
-static struct pci_id tnt2_pci[] = {
-{0x10DE, 0x0028, "TNT2", "RIVA TNT2"}
-};
-
-struct pci_driver tnt2_driver = {
-       .name     = "tnt2",
-       .probe    = tnt2_probe,
-       .ids      = tnt2_pci,
-       .id_count = sizeof(tnt2_pci)/sizeof(tnt2_pci[0]),
-};
index 9f7e6b90a75c1c64f8bfbc4ca86e4edf236eaa6f..9e964ca91d2adb89348dc2cba0024fbb24ebad56 100644 (file)
@@ -55,6 +55,6 @@ typedef struct pci_driver {
        int id_count;
 } pci_driver_t;
 
-int pci_probe_driver(pci_driver_t driver);
+int pci_probe_driver(pci_driver_t *driver);
 
 #endif
index 2022ccaa8bf1846c59261930bb9439095ec86075..52ab38f155db69cbd7b2b1bcace5bd295df2ff7d 100644 (file)
--- a/net/net.c
+++ b/net/net.c
@@ -159,6 +159,5 @@ void eth_init()
        /* Required for DMA to work. :( */
        smram_tseg_set_state(SMRAM_TSEG_OPEN);
        lwip_init();
-       pci_probe_driver(a3c90x_driver);
        httpd_init();
 }
index fbea894365e2de1a30f3a5bf1b0164a0c2240b0e..5fd03b414dbf4ea2e69fc560718c6df597552a4a 100644 (file)
--- a/pci/pci.c
+++ b/pci/pci.c
@@ -115,7 +115,7 @@ static int _probefn(pci_dev_t *dev, void *d)
        return 0;
 }
 
-int pci_probe_driver(pci_driver_t driver)
+int pci_probe_driver(pci_driver_t *driver)
 {
-       return pci_probe(_probefn, &driver);
+       return pci_probe(_probefn, driver);
 }
diff --git a/video/fb.c b/video/fb.c
new file mode 100644 (file)
index 0000000..ed404e1
--- /dev/null
@@ -0,0 +1,3 @@
+#include <fb.h>
+
+struct fbdevice *fb;
diff --git a/video/tnt2.c b/video/tnt2.c
new file mode 100644 (file)
index 0000000..73a3d0b
--- /dev/null
@@ -0,0 +1,61 @@
+#include <minilib.h>
+#include <io.h>
+#include <pci.h>
+#include <output.h>
+#include <fb.h>
+
+static void tnt2_getvmode(void *priv);
+
+static struct fbdevice tnt2_fb = {
+       .getvmode = &tnt2_getvmode,
+};
+
+static unsigned int vgard(unsigned char a)
+{
+       outb(a, 0x3D4);
+       return (unsigned int)inb(0x3D5);
+}
+
+static void tnt2_getvmode(void *priv)
+{
+       tnt2_fb.curmode.xres = (vgard(0x1) + 1) * 8;
+       tnt2_fb.curmode.yres = (vgard(0x12) | (vgard(0x7) & 2) << 7 | (vgard(0x7) & 0x40) << 3) + 1;
+       switch (vgard(0x28))
+       {
+       case 4:
+               tnt2_fb.curmode.format = FB_RGB888;
+               tnt2_fb.curmode.bytestride = 4;
+               tnt2_fb.curmode.text = 0;
+               break;
+       case 0:
+               tnt2_fb.curmode.text = 1;
+               break;
+       default:
+               outputf("Unknown TNT2 format %d", vgard(0x28));
+               break;
+       }
+}
+
+static int tnt2_probe(struct pci_dev *pci, void *data)
+{
+       if (pci->bars[1].type != PCI_BAR_MEMORY32)
+       {
+               output("TNT2 BAR1 is not memory32?");
+               return 0;
+       }
+       tnt2_fb.fbaddr = (void *)pci->bars[1].addr;
+       fb = &tnt2_fb;
+       outputf("Found TNT2 with FB at %08x", tnt2_fb.fbaddr);
+       return 1;
+}
+
+static struct pci_id tnt2_pci[] = {
+       {0x10DE, 0x0028, "TNT2", "RIVA TNT2"}
+};
+
+struct pci_driver tnt2_driver = {
+       .name     = "tnt2",
+       .probe    = tnt2_probe,
+       .ids      = tnt2_pci,
+       .id_count = sizeof(tnt2_pci)/sizeof(tnt2_pci[0]),
+};
This page took 0.039252 seconds and 4 git commands to generate.