]> Joshua Wise's Git repositories - netwatch.git/blob - ich2/smm-open-ich2.c
1e1f79ceab3348550b41f53a3c26d779cba4959a
[netwatch.git] / ich2 / smm-open-ich2.c
1 #include "reg-82815.h"
2 #include <stdlib.h>
3
4 unsigned long memsz[] = {
5         0,                      // 0
6         32*1024*1024,           // 1
7         32*1024*1024,           // 2
8         48*1024*1024,           // 3
9         64*1024*1024,           // 4
10         64*1024*1024,           // 5
11         96*1024*1024,           // 6
12         128*1024*1024,          // 7
13         128*1024*1024,          // 8
14         128*1024*1024,          // 9
15         128*1024*1024,          // A
16         192*1024*1024,          // B
17         256*1024*1024,          // C
18         256*1024*1024,          // D
19         256*1024*1024,          // E
20         512*1024*1024           // F
21 };
22
23 int main(int argc, char **argv)
24 {
25         unsigned char smramc, drp, drp2;
26         unsigned int tom = 0;
27         int usmm, lsmm;
28         
29         smramc = pci_read8(0, 0, 0, SMRAMC);
30         drp = pci_read8(0, 0, 0, DRP);
31         drp2 = pci_read8(0, 0, 0, DRP2);
32         
33         tom += memsz[drp & 0xF];
34         tom += memsz[drp >> 4];
35         tom += memsz[drp2 & 0xF];
36         
37         printf("Top of DRAM: %08x\n", tom);
38         
39         printf("SMRAMC: %02x\n", smramc);
40         if (smramc & SMRAMC_LOCK)
41         {
42                 printf("SMRAM is locked, cannot load anything :-(\n");
43                 return 1;
44         }
45         
46         usmm = (smramc >> 4) & 0x3;
47         lsmm = (smramc >> 2) & 0x3;
48         
49         switch (usmm)
50         {
51         case 0:
52                 printf("TSEG and HSEG both off\n");
53                 break;
54         case 1:
55                 printf("TSEG off, HSEG %s\n", lsmm ? "off" : "on");
56                 break;
57         case 2:
58                 printf("TSEG 512KB (%08x - %08x), HSEG %s\n", tom - 512 * 1024, tom - 1, lsmm ? "off" : "on");
59                 break;
60         case 3:
61                 printf("TSEG 1MB (%08x - %08x), HSEG %s\n", tom - 1 * 1024 * 1024, tom - 1, lsmm ? "off" : "on");
62                 break;
63         }
64         
65         switch (lsmm)
66         {
67         case 0:
68                 printf("ABSEG disabled\n");
69                 break;
70         case 1:
71                 printf("ABSEG enabled as system RAM\n");
72                 break;
73         case 2:
74                 printf("ABSEG enabled for SMM code only\n");
75                 break;
76         case 3:
77                 printf("ABSEG enabled for both SMM code and data\n");
78                 break;
79         }
80         
81         
82         if (argc < 2)
83         {
84                 smramc &= 0xC0;
85                 smramc |= 0x04;
86         
87                 pci_write8(0, 0, 0, SMRAMC, smramc);
88                 printf("With any luck, ABSEG is now enabled as system RAM... enjoy!\n");
89         } else {
90                 smramc = strtoul(argv[1], 0, 0);
91                 
92                 pci_write8(0, 0, 0, SMRAMC, smramc);
93                 printf("OK, set it up as you like.\n");
94         }
95         
96         return 0;
97 }
This page took 0.023651 seconds and 2 git commands to generate.