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 vga-overlay.o
+OBJS=counter.o firstrun.o ../pci/pci-raw.o ../lib/minilib.o ../lib/console.o ../ich2/smram-ich2.o ../ich2/smi.o vga-overlay.o
all: aseg.elf
cts = inl(0x84C);
outl(0x848, 0x0);
-
+ outl(0x840, 0x0);
switch(cts&0xF0000)
{
case 0x20000:
default:
dolog("Unhandled PCI cycle");
}
+
+ outl(0x848, 0x1000);
+ outl(0x840, 0x0100);
}
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);
#include <io.h>
+#include <smi.h>
#include <pci.h>
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();
}
-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
#include "console.h"
+#include <minilib.h>
#include <io.h>
#include <smram.h>
#include <multiboot.h>
+#include <smi.h>
#define INFO_SIGNATURE 0x5754454E
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));
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();
--- /dev/null
+#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);
+}
--- /dev/null
+#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