]> Joshua Wise's Git repositories - netwatch.git/blame - tools/poke-rls.c
Remove demapper from pagingstub.c, since that code is now elsewhere. Correct locatio...
[netwatch.git] / tools / poke-rls.c
CommitLineData
98e930a2
JP
1/* poke-rls.c
2 * Linux-side communication packet utility
3 * NetWatch system management mode administration console
4 *
5 * Copyright (c) 2008 Jacob Potter and Joshua Wise. All rights reserved.
6 * This program is free software; you can redistribute and/or modify it under
7 * the terms found in the file LICENSE in the root of this source tree.
8 *
9 */
10
0889f342
JP
11#include <sys/io.h>
12#include <reg-82801b.h>
13#include <string.h>
14#include <stdint.h>
ea6c242b 15#include <stdlib.h>
0889f342
JP
16
17static uint16_t _get_PMBASE()
18{
19 static long pmbase = -1;
20
21 if (pmbase == -1)
22 pmbase = pci_read32(ICH2_LPC_BUS, ICH2_LPC_DEV, ICH2_LPC_FN, ICH2_LPC_PCI_PMBASE) & ICH2_PMBASE_MASK;
23
24 return pmbase;
25}
26
0cd80c51
JP
27typedef struct {
28 uint32_t signature;
29 uint32_t type;
30 uint8_t data[];
31} packet_t;
0889f342 32
0cd80c51 33extern unsigned int poke(unsigned long addr, unsigned long * value);
0889f342
JP
34
35int main(int argc, char **argv)
36{
37 unsigned int res;
0cd80c51
JP
38 packet_t * packet = (packet_t *)memalign(4096, sizeof(packet_t));
39
40 packet->signature = 0x1BADD00D;
d5cffad7
JP
41 packet->type = 42;
42 strcpy(packet->data, "hello, world!");
0889f342
JP
43
44 if (iopl(3) < 0)
45 {
46 perror("iopl");
47 return 1;
48 }
ea6c242b 49
0cd80c51
JP
50 res = poke(_get_PMBASE() + 0x04, (void *)packet);
51 printf("returned %p\n", res);
d5cffad7
JP
52
53 if (res == 42) {
a3033282
JW
54 int i;
55 for (i = 0; i < 96; i++)
56 printf("%s\n", packet->data + i * 41);
d5cffad7 57 }
0889f342 58}
This page took 0.026471 seconds and 4 git commands to generate.