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