]> Joshua Wise's Git repositories - netwatch.git/blob - ich2/smram-ich2.c
1052f3b23f1b2f267bdf26dfb5e13327a5c19dea
[netwatch.git] / ich2 / smram-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 #ifdef __linux__
23
24 void smram_aseg_dump(void) {
25
26         unsigned char smramc, drp, drp2;
27         unsigned int tom = 0;
28         int usmm, lsmm;
29
30         smramc = pci_read8(0, 0, 0, SMRAMC);
31         drp = pci_read8(0, 0, 0, DRP);
32         drp2 = pci_read8(0, 0, 0, DRP2);
33
34         printf("SMRAMC: %02x\n", smramc);
35
36         tom += memsz[drp & 0xF];
37         tom += memsz[drp >> 4];
38         tom += memsz[drp2 & 0xF];
39         
40         printf("Top of DRAM: %08x\n", tom);
41         
42         usmm = (smramc >> 4) & 0x3;
43         lsmm = (smramc >> 2) & 0x3;
44         
45         switch (usmm)
46         {
47         case 0:
48                 printf("TSEG and HSEG both off\n");
49                 break;
50         case 1:
51                 printf("TSEG off, HSEG %s\n", lsmm ? "off" : "on");
52                 break;
53         case 2:
54                 printf("TSEG 512KB (%08x - %08x), HSEG %s\n",
55                         tom - 512 * 1024, tom - 1, lsmm ? "off" : "on");
56                 break;
57         case 3:
58                 printf("TSEG 1MB (%08x - %08x), HSEG %s\n",
59                         tom - 1 * 1024 * 1024, tom - 1, lsmm ? "off" : "on");
60                 break;
61         }
62         
63         switch (lsmm)
64         {
65         case 0:
66                 printf("ABSEG disabled\n");
67                 break;
68         case 1:
69                 printf("ABSEG enabled as system RAM\n");
70                 break;
71         case 2:
72                 printf("ABSEG enabled for SMM code only\n");
73                 break;
74         case 3:
75                 printf("ABSEG enabled for both SMM code and data\n");
76                 break;
77         }
78 }
79 #endif
80
81 int smram_aseg_set_state (int open) {
82         unsigned char smramc;
83         smramc = pci_read8(0, 0, 0, SMRAMC);
84
85         if (smramc & SMRAMC_LOCK)
86         {
87                 /* SMRAM is locked; can't load anything. */
88                 return 1;
89         }
90
91         if (open) {
92                 /* Set LSMM to 01 (ABseg = system RAM) */
93                 smramc = (smramc & 0xF0) | 0x04;
94         } else {
95                 /* Set LSMM to 11 (ABseg = SMM RAM) */
96                 smramc = (smramc & 0xF0) | 0x0C;
97         }
98
99         pci_write8(0, 0, 0, SMRAMC);
100
101         return 0;
102 }
This page took 0.024828 seconds and 2 git commands to generate.