X-Git-Url: http://git.joshuawise.com/netwatch.git/blobdiff_plain/172a5ba7dad6e9c7e38e4e5aa2607de3728f0ebf..50d89a314a394e5427d0791a08ffc3a3b79b6670:/tools/frob-rls.c diff --git a/tools/frob-rls.c b/tools/frob-rls.c new file mode 100644 index 0000000..3ff4e53 --- /dev/null +++ b/tools/frob-rls.c @@ -0,0 +1,48 @@ +#include +#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; +} + +typedef struct { + uint32_t signature; + uint32_t type; + uint8_t data[]; +} packet_t; + +extern unsigned int poke(unsigned long addr, unsigned long * value); + +int main(int argc, char **argv) +{ + unsigned int res; + packet_t * packet = (packet_t *)memalign(4096, sizeof(packet_t)); + + packet->signature = 0x1BADD00D; + packet->type = 0xAA; + strcpy(packet->data, "hello, world!"); + + if (iopl(3) < 0) + { + perror("iopl"); + return 1; + } + + res = poke(_get_PMBASE() + 0x04, (void *)packet); + printf("returned %p\n", res); + + if (res == 42) { + int i; + for (i = 0; i < 96; i++) + printf("%s\n", packet->data + i * 41); + } +}