]> Joshua Wise's Git repositories - netwatch.git/commitdiff
add poke-rls tool
authorJacob Potter <jdpotter@andrew.cmu.edu>
Fri, 26 Sep 2008 01:39:37 +0000 (21:39 -0400)
committerJacob Potter <jdpotter@andrew.cmu.edu>
Fri, 26 Sep 2008 01:39:37 +0000 (21:39 -0400)
tools/Makefile
tools/poke-rls-asm.S [new file with mode: 0644]
tools/poke-rls.c [new file with mode: 0644]

index c53fd4a28ea5eda3adee65f5b13e83a2ec6bfa1b..3bd46a56de2a618e9473fd07970abc109bd3cdef 100644 (file)
@@ -2,8 +2,9 @@ CFLAGS=-I../include
 CC=gcc
 SMRAM_ICH2_OBJS=smram-linux-tool.o ../pci/pci-linux.o ../ich2/smram-ich2.noraw.o
 PCI_OBJS=pci.o ../pci/pci-linux.o
 CC=gcc
 SMRAM_ICH2_OBJS=smram-linux-tool.o ../pci/pci-linux.o ../ich2/smram-ich2.noraw.o
 PCI_OBJS=pci.o ../pci/pci-linux.o
+POKE_RLS_OBJS=poke-rls.o poke-rls-asm.o ../pci/pci-linux.o
 
 
-all: smram-ich2 port pci
+all: smram-ich2 port pci poke-rls
 
 %.noraw.o: %.c
        gcc $(CFLAGS) -c -o $@ $<
 
 %.noraw.o: %.c
        gcc $(CFLAGS) -c -o $@ $<
@@ -17,5 +18,10 @@ port: port.o
 pci: $(PCI_OBJS)
        gcc $(CFLAGS) -o pci $(PCI_OBJS)
 
 pci: $(PCI_OBJS)
        gcc $(CFLAGS) -o pci $(PCI_OBJS)
 
+poke-rls: $(POKE_RLS_OBJS)
+       gcc $(CFLAGS) -o poke-rls $(POKE_RLS_OBJS)
+
 clean:
        rm -f $(SMRAM_ICH2_OBJS) smram-ich2
 clean:
        rm -f $(SMRAM_ICH2_OBJS) smram-ich2
+
+poke:
diff --git a/tools/poke-rls-asm.S b/tools/poke-rls-asm.S
new file mode 100644 (file)
index 0000000..ee44854
--- /dev/null
@@ -0,0 +1,20 @@
+.global poke
+poke:
+       # Preload registers: $0x1BADD00D
+       mov $0x1BADD00D, %ecx
+
+       # Parameter: I/O port to set bit 2 of
+       mov 4(%esp), %dx
+       inl %dx, %eax
+       or $4, %eax
+       outl %eax, %dx
+
+       # Count down for a while
+       mov $0x10000, %edx
+loop:
+       dec %edx
+       jz loop
+
+       # Maybe SMM poked something?
+       mov %ecx, %eax
+       ret
diff --git a/tools/poke-rls.c b/tools/poke-rls.c
new file mode 100644 (file)
index 0000000..c6db7bc
--- /dev/null
@@ -0,0 +1,31 @@
+#include <sys/io.h>
+#include <reg-82801b.h>
+#include <string.h>
+#include <stdint.h>
+
+static uint16_t _get_PMBASE()
+{
+       static long pmbase = -1;
+
+       if (pmbase == -1) 
+               pmbase = pci_read32(ICH2_LPC_BUS, ICH2_LPC_DEV, ICH2_LPC_FN, ICH2_LPC_PCI_PMBASE) & ICH2_PMBASE_MASK;
+
+       return pmbase;
+}
+
+
+extern unsigned int poke(short addr);
+
+int main(int argc, char **argv)
+{
+       unsigned int res;
+
+       if (iopl(3) < 0)
+       {
+               perror("iopl");
+               return 1;
+       }
+
+       res = poke(_get_PMBASE() + 0x04);
+       printf("found %p\n", res);
+}
This page took 0.032237 seconds and 4 git commands to generate.