]> Joshua Wise's Git repositories - netwatch.git/blame - tools/poke-rls.c
add dump-buffer command
[netwatch.git] / tools / poke-rls.c
CommitLineData
0889f342
JP
1#include <sys/io.h>
2#include <reg-82801b.h>
3#include <string.h>
4#include <stdint.h>
ea6c242b 5#include <stdlib.h>
0889f342
JP
6
7static uint16_t _get_PMBASE()
8{
9 static long pmbase = -1;
10
11 if (pmbase == -1)
12 pmbase = pci_read32(ICH2_LPC_BUS, ICH2_LPC_DEV, ICH2_LPC_FN, ICH2_LPC_PCI_PMBASE) & ICH2_PMBASE_MASK;
13
14 return pmbase;
15}
16
0cd80c51
JP
17typedef struct {
18 uint32_t signature;
19 uint32_t type;
20 uint8_t data[];
21} packet_t;
0889f342 22
0cd80c51 23extern unsigned int poke(unsigned long addr, unsigned long * value);
0889f342
JP
24
25int main(int argc, char **argv)
26{
27 unsigned int res;
0cd80c51
JP
28 packet_t * packet = (packet_t *)memalign(4096, sizeof(packet_t));
29
30 packet->signature = 0x1BADD00D;
d5cffad7
JP
31 packet->type = 42;
32 strcpy(packet->data, "hello, world!");
0889f342
JP
33
34 if (iopl(3) < 0)
35 {
36 perror("iopl");
37 return 1;
38 }
ea6c242b 39
0cd80c51
JP
40 res = poke(_get_PMBASE() + 0x04, (void *)packet);
41 printf("returned %p\n", res);
d5cffad7
JP
42
43 if (res == 42) {
44 printf("%s\n", packet->data);
45 printf("%s\n", packet->data+41);
46 printf("%s\n", packet->data+82);
47 printf("%s\n", packet->data+123);
48 }
0889f342 49}
This page took 0.03193 seconds and 4 git commands to generate.