From 0889f342f13f65b875e67f78a27ad078f3f55736 Mon Sep 17 00:00:00 2001 From: Jacob Potter Date: Thu, 25 Sep 2008 21:39:37 -0400 Subject: [PATCH] add poke-rls tool --- tools/Makefile | 8 +++++++- tools/poke-rls-asm.S | 20 ++++++++++++++++++++ tools/poke-rls.c | 31 +++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 tools/poke-rls-asm.S create mode 100644 tools/poke-rls.c 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); +} -- 2.43.0