From: Jacob Potter Date: Fri, 26 Sep 2008 01:39:37 +0000 (-0400) Subject: add poke-rls tool X-Git-Url: http://git.joshuawise.com/netwatch.git/commitdiff_plain/0889f342f13f65b875e67f78a27ad078f3f55736 add poke-rls tool --- diff --git a/tools/Makefile b/tools/Makefile index c53fd4a..3bd46a5 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -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 +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 $@ $< @@ -17,5 +18,10 @@ port: port.o 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 + +poke: diff --git a/tools/poke-rls-asm.S b/tools/poke-rls-asm.S new file mode 100644 index 0000000..ee44854 --- /dev/null +++ b/tools/poke-rls-asm.S @@ -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 index 0000000..c6db7bc --- /dev/null +++ b/tools/poke-rls.c @@ -0,0 +1,31 @@ +#include +#include +#include +#include + +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); +}