]>
Commit | Line | Data |
---|---|---|
1 | /* frob-rls.c | |
2 | * GBL_RLS flag manipulator. | |
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 | ||
11 | #include <sys/io.h> | |
12 | #include <reg-82801b.h> | |
13 | #include <string.h> | |
14 | #include <stdint.h> | |
15 | #include <stdlib.h> | |
16 | ||
17 | static 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 | ||
27 | typedef struct { | |
28 | uint32_t signature; | |
29 | uint32_t type; | |
30 | uint8_t data[]; | |
31 | } packet_t; | |
32 | ||
33 | extern unsigned int poke(unsigned long addr, unsigned long * value); | |
34 | ||
35 | int main(int argc, char **argv) | |
36 | { | |
37 | unsigned int res; | |
38 | packet_t * packet = (packet_t *)memalign(4096, sizeof(packet_t)); | |
39 | ||
40 | packet->signature = 0x1BADD00D; | |
41 | packet->type = 0xAA; | |
42 | strcpy(packet->data, "hello, world!"); | |
43 | ||
44 | if (iopl(3) < 0) | |
45 | { | |
46 | perror("iopl"); | |
47 | return 1; | |
48 | } | |
49 | ||
50 | res = poke(_get_PMBASE() + 0x04, (void *)packet); | |
51 | printf("returned %p\n", res); | |
52 | ||
53 | if (res == 42) { | |
54 | int i; | |
55 | for (i = 0; i < 96; i++) | |
56 | printf("%s\n", packet->data + i * 41); | |
57 | } | |
58 | } |