]> Joshua Wise's Git repositories - netwatch.git/commitdiff
add a first cut at a SMI API -- not many features...
authorJoshua Wise <joshua@rebirth.joshuawise.com>
Fri, 19 Sep 2008 19:35:28 +0000 (15:35 -0400)
committerJoshua Wise <joshua@rebirth.joshuawise.com>
Fri, 19 Sep 2008 19:35:28 +0000 (15:35 -0400)
aseg/Makefile
aseg/counter.c
aseg/firstrun.c
grubload/Makefile
grubload/multiboot_c.c
ich2/smi.c [new file with mode: 0644]
include/smi.h [new file with mode: 0644]

index 5033a5545116a52d5e49cb04dce7f3e5ec07d1e0..a43a1f2c985003fed658841fa4a46ef8bc1b29d6 100644 (file)
@@ -1,6 +1,6 @@
 CC=gcc
 CFLAGS=-I../include -I../include/raw -nostdlib -nostdinc -fno-builtin -D__RAW__
-OBJS=counter.o firstrun.o ../pci/pci-raw.o ../lib/minilib.o ../lib/console.o
+OBJS=counter.o firstrun.o ../pci/pci-raw.o ../lib/minilib.o ../lib/console.o ../ich2/smi.o
 
 all: aseg.elf
 
index e4b5eae7279b67292ffa6e2f4dd0cf7379007411..f77d256a8bf7c328749b8f0aca46f73610f0103b 100644 (file)
@@ -62,7 +62,7 @@ void pci_dump() {
        cts = inl(0x84C);
        
        outl(0x848, 0x0);
-       
+       outl(0x840, 0x0);
        switch(cts&0xF0000)
        {
        case 0x20000:
@@ -95,6 +95,9 @@ void pci_dump() {
        default:
                dolog("Unhandled PCI cycle");
        }
+       
+       outl(0x848, 0x1000);
+       outl(0x840, 0x0100);
 }
 
 void __start (void)
@@ -126,15 +129,13 @@ void __start (void)
                if (inl(0x844) & 0x1000)        /* devact_sts */
                {
                        pci_dump();
-                       outl(0x848, 0x1000);
-                       outl(0x844, 0x1000);
+                       outl(0x844, 0x1000);    /* ack it */
                }
        }
        if (inl(0x834) & 0x4000)
                dolog("Long periodic timer");
        if (inl(0x840) & 0x1000)
        {
-               dolog("Caught device monitor trap");
                pci_dump();
                outl(0x840, 0x1100);
                outl(0x840, 0x0100);
index ace70c6c0703488adcd3fd632bf7efd0660f28d7..9977d148d77406cc776240cb14acd0387337eed2 100644 (file)
@@ -1,4 +1,5 @@
 #include <io.h>
+#include <smi.h>
 
 void __firstrun_start() {
 /*
@@ -22,6 +23,7 @@ void __firstrun_start() {
        pci_write16(0, 31, 4, 0xC0, 0);
 
        /* Turn on the SMIs we want */
-       outb(0x830, inb(0x830) | 0x41);
+       outb(0x830, inb(0x830) | 0x40);
+       smi_enable();
 }
 
index 4eef9211a71d8a37cfe2aa24e7c9e971e6de2b3c..bc4c1fe77ea1acde3845739c08019dbf52ea9790 100644 (file)
@@ -1,4 +1,4 @@
-OBJS=multiboot_c.o multiboot_asm.o realmode.o loader.o ../pci/pci-raw.o ../lib/minilib.o ../lib/console.o ../ich2/smram-ich2.o
+OBJS=multiboot_c.o multiboot_asm.o realmode.o loader.o ../pci/pci-raw.o ../lib/minilib.o ../lib/console.o ../ich2/smram-ich2.o ../ich2/smi.o
 CC=gcc
 CFLAGS=-nostdlib -I../include -I../include/raw -I. -D__RAW__ -fno-builtin -nostdinc
 
index 6fcfa5ef38d7d10c3be7f1c0fd61e545a72024ec..e4843c36da97e8b23e2a55521a21fb098b523dd5 100644 (file)
@@ -1,7 +1,9 @@
 #include "console.h"
+#include <minilib.h>
 #include <io.h>
 #include <smram.h>
 #include <multiboot.h>
+#include <smi.h>
 
 #define INFO_SIGNATURE 0x5754454E
 
@@ -54,7 +56,7 @@ void c_start(unsigned int magic, struct mb_info *mbinfo)
        puts("Current SMI state is: "); puthex(inl(0x830)); puts("\n");
        puts("Current SMRAMC state is: "); puthex(pci_read8(0, 0, 0, 0x70)); puts("\n");
        
-       outl(0x830, inl(0x830) & ~0x1); /* turn off SMIs */
+       smi_disable();
        
        /* Try really hard to shut up USB_LEGKEY. */
        pci_write16(0, 31, 2, 0xC0, pci_read16(0, 31, 2, 0xC0));
@@ -62,7 +64,6 @@ void c_start(unsigned int magic, struct mb_info *mbinfo)
        pci_write16(0, 31, 4, 0xC0, pci_read16(0, 31, 4, 0xC0));
        pci_write16(0, 31, 4, 0xC0, 0);
 
-
        /* Open the SMRAM aperture and load our ELF. */
        smram_state_t old_smramc = smram_save_state();
 
diff --git a/ich2/smi.c b/ich2/smi.c
new file mode 100644 (file)
index 0000000..59f14b6
--- /dev/null
@@ -0,0 +1,27 @@
+#include <smi.h>
+#include <pci.h>
+#include <io.h>
+#include <stdint.h>
+
+uint16_t _get_PMBASE()
+{
+       return pci_read32(0, 0, 0, 0x40) & 0xFF80;
+}
+
+void smi_disable()
+{
+       unsigned short smi_en = _get_PMBASE() + 0x30;
+       outl(smi_en, inl(smi_en) & ~0x0001);
+}
+
+void smi_enable()
+{
+       unsigned short smi_en = _get_PMBASE() + 0x30;
+       outl(smi_en, inl(smi_en) | 0x0001);
+}
+
+unsigned long smi_status()
+{
+       unsigned short smi_sts = _get_PMBASE() + 0x34;
+       return inl(smi_sts);
+}
diff --git a/include/smi.h b/include/smi.h
new file mode 100644 (file)
index 0000000..c669fc2
--- /dev/null
@@ -0,0 +1,10 @@
+#ifndef SMI_H
+#define SMI_H
+
+extern void smi_disable();     /* akin to cli / sti */
+extern void smi_enable();
+
+extern void smi_poll();
+extern unsigned long smi_status();     /* Architecturally defined; for debugging only. */
+
+#endif
This page took 0.023281 seconds and 4 git commands to generate.