]> Joshua Wise's Git repositories - netwatch.git/commitdiff
Merge
authorJoshua Wise <joshua@rebirth.joshuawise.com>
Fri, 19 Sep 2008 20:15:26 +0000 (16:15 -0400)
committerJoshua Wise <joshua@rebirth.joshuawise.com>
Fri, 19 Sep 2008 20:15:26 +0000 (16:15 -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 1c2867d43c67275c20e3d73fcf76e41f145f29a8..e2edc87ff61e7c09ade13d64603ad8cba167e069 100644 (file)
@@ -1,6 +1,6 @@
 CC=gcc
 CFLAGS=-I../include -I../include/raw -nostdlib -nostdinc -fno-builtin -D__RAW__ -Wall -Werror -pedantic -ansi -std=gnu99
-OBJS=counter.o firstrun.o ../pci/pci-raw.o ../lib/minilib.o ../lib/console.o ../ich2/smram-ich2.o
+OBJS=counter.o firstrun.o ../pci/pci-raw.o ../lib/minilib.o ../lib/console.o ../ich2/smram-ich2.o ../ich2/smi.o
 
 all: aseg.elf
 
index ccfff7254d9b355430ec336b8c1e2e13364d64e7..3484b95ba16ae5ccd94d392cb45ecc793b05bf76 100644 (file)
@@ -83,7 +83,7 @@ void pci_dump() {
        cts = inl(0x84C);
        
        outl(0x848, 0x0);
-       
+       outl(0x840, 0x0);
        switch(cts&0xF0000)
        {
        case 0x20000:
@@ -116,6 +116,9 @@ void pci_dump() {
        default:
                dolog("Unhandled PCI cycle");
        }
+       
+       outl(0x848, 0x1000);
+       outl(0x840, 0x0100);
 }
 
 void __start (void)
@@ -146,15 +149,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 355fb9a8acc67867e5b8effe3c1da19e6b2f2ad9..ca892ea0b3dd9b487973e157cd7426b475dc1c6b 100644 (file)
@@ -1,4 +1,5 @@
 #include <io.h>
+#include <smi.h>
 #include <pci.h>
 
 void __firstrun_start() {
@@ -23,6 +24,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.037817 seconds and 4 git commands to generate.