7 /***********************************************************************
8 * DEPRECATED DEPRECATED DEPRECATED DEPRECATED DEPRECATED
10 * This should be replaced by ../util/smram-ich2 once it's verified to work properly.
13 unsigned long memsz[] = {
32 void dump(unsigned char smramc, unsigned char drp, unsigned char drp2) {
37 printf("SMRAMC: %02x\n", smramc);
39 tom += memsz[drp & 0xF];
40 tom += memsz[drp >> 4];
41 tom += memsz[drp2 & 0xF];
43 printf("Top of DRAM: %08x\n", tom);
45 usmm = (smramc >> 4) & 0x3;
46 lsmm = (smramc >> 2) & 0x3;
51 printf("TSEG and HSEG both off\n");
54 printf("TSEG off, HSEG %s\n", lsmm ? "off" : "on");
57 printf("TSEG 512KB (%08x - %08x), HSEG %s\n",
58 tom - 512 * 1024, tom - 1, lsmm ? "off" : "on");
61 printf("TSEG 1MB (%08x - %08x), HSEG %s\n",
62 tom - 1 * 1024 * 1024, tom - 1, lsmm ? "off" : "on");
69 printf("ABSEG disabled\n");
72 printf("ABSEG enabled as system RAM\n");
75 printf("ABSEG enabled for SMM code only\n");
78 printf("ABSEG enabled for both SMM code and data\n");
83 static struct option longopts[] = {
84 { "open", no_argument, NULL, 'o' },
85 { "close", no_argument, NULL, 'c' },
86 { "smram", no_argument, NULL, 's' },
87 { "dump", no_argument, NULL, 'd' },
94 void usage(int argc, char **argv)
96 printf("Usage: %s [ --dump ] [ --open | --close | --smram=value ]\n",
101 int main(int argc, char **argv)
103 unsigned char smramc, drp, drp2;
107 printf("This program must be run as root, dumbass.\n");
111 smramc = pci_read8(0, 0, 0, SMRAMC);
112 drp = pci_read8(0, 0, 0, DRP);
113 drp2 = pci_read8(0, 0, 0, DRP2);
115 if (smramc & SMRAMC_LOCK)
117 printf("SMRAM is locked, cannot load anything :-(\n");
123 int new_smramc = smramc;
125 while ((ch = getopt_long(argc, argv, "ocsd:", longopts, NULL)) != -1)
130 if (op & OP_SET) usage(argc, argv);
132 new_smramc = strtoul(optarg, 0, 0);
135 if (op & OP_SET) usage(argc, argv);
137 /* Set LSMM to 01 (ABseg = system RAM) */
138 new_smramc = (smramc & 0xF0) | 0x04;
141 if (op & OP_SET) usage(argc, argv);
143 /* Set LSMM to 11 (ABseg = SMM RAM) */
144 new_smramc = (smramc & 0xF0) | 0x0C;
154 if (!op) usage(argc, argv);
158 dump(smramc, drp, drp2);
163 pci_write8(0, 0, 0, SMRAMC, new_smramc);
166 printf("SMRAM set to 0x%02x\n", new_smramc);