]> Joshua Wise's Git repositories - netwatch.git/blame_incremental - tools/smram-linux-tool.c
Fix smm_type detection to actually detect, and add a state_num_regs routine.
[netwatch.git] / tools / smram-linux-tool.c
... / ...
CommitLineData
1/* smram-linux-tool.c
2 * General SMRAM manipulation 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
11
12#include <unistd.h>
13#include <getopt.h>
14#include <stdlib.h>
15#include <stdio.h>
16#include <smram.h>
17
18static struct option longopts[] = {
19 { "open", no_argument, NULL, 'o' },
20 { "close", no_argument, NULL, 'c' },
21 { "dump", no_argument, NULL, 'd' },
22 { NULL, 0, NULL, 0 }
23};
24
25#define OP_DUMP 1
26#define OP_SET 2
27
28void usage(int argc, char **argv)
29{
30 printf("Usage: %s [ --dump ] [ --open | --close ]\n",
31 argv[0]);
32 exit(1);
33}
34
35int main(int argc, char **argv)
36{
37 if (geteuid() != 0)
38 {
39 printf("%s: This program must be run as root.\n", argv[0]);
40 return 1;
41 }
42
43 int ch;
44 int op = 0;
45 int do_open = 0;
46 while ((ch = getopt_long(argc, argv, "ocsd:", longopts, NULL)) != -1)
47 {
48 switch (ch)
49 {
50 case 'o':
51 if (op & OP_SET) usage(argc, argv);
52 op |= OP_SET;
53 do_open = 1;
54 break;
55 case 'c':
56 if (op & OP_SET) usage(argc, argv);
57 op |= OP_SET;
58 break;
59 case 'd':
60 op |= OP_DUMP;
61 break;
62 default:
63 usage(argc, argv);
64 }
65 }
66
67 if (!op) usage(argc, argv);
68
69 if (op & OP_DUMP)
70 {
71 smram_aseg_dump();
72 }
73
74 if (op & OP_SET)
75 {
76 smram_aseg_set_state(do_open ? SMRAM_ASEG_OPEN : SMRAM_ASEG_SMMONLY);
77 }
78
79 return 0;
80}
This page took 0.026695 seconds and 4 git commands to generate.