]> Joshua Wise's Git repositories - netwatch.git/blob - tools/poke-rls.c
add some more structured packet handling
[netwatch.git] / tools / poke-rls.c
1 #include <sys/io.h>
2 #include <reg-82801b.h>
3 #include <string.h>
4 #include <stdint.h>
5 #include <stdlib.h>
6
7 static 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
17 typedef struct {
18         uint32_t signature;
19         uint32_t type;
20         uint8_t data[];
21 } packet_t;
22
23 extern unsigned int poke(unsigned long addr, unsigned long * value);
24
25 int main(int argc, char **argv)
26 {
27         unsigned int res;
28         packet_t * packet = (packet_t *)memalign(4096, sizeof(packet_t));
29
30         packet->signature = 0x1BADD00D;
31         packet->type = 0xF00FC7C8;
32
33         if (iopl(3) < 0)
34         {
35                 perror("iopl");
36                 return 1;
37         }
38         
39         res = poke(_get_PMBASE() + 0x04, (void *)packet);
40         printf("returned %p\n", res);
41 }
This page took 0.029901 seconds and 4 git commands to generate.