5 static unsigned long memsz[] = {
24 unsigned int smram_tseg_length(void) {
28 smramc = pci_read8(0, 0, 0, SMRAMC);
30 usmm = (smramc >> 4) & 0x3;
46 void * smram_tseg_start(void) {
47 unsigned char drp, drp2;
50 drp = pci_read8(0, 0, 0, DRP);
51 drp2 = pci_read8(0, 0, 0, DRP2);
53 tom += memsz[drp & 0xF];
54 tom += memsz[drp >> 4];
55 tom += memsz[drp2 & 0xF];
57 return (void *)(tom - smram_tseg_length());
62 void smram_aseg_dump(void) {
64 unsigned char smramc, drp, drp2;
68 smramc = pci_read8(0, 0, 0, SMRAMC);
69 drp = pci_read8(0, 0, 0, DRP);
70 drp2 = pci_read8(0, 0, 0, DRP2);
72 printf("SMRAMC: %02x\n", smramc);
74 tom += memsz[drp & 0xF];
75 tom += memsz[drp >> 4];
76 tom += memsz[drp2 & 0xF];
78 printf("Top of DRAM: %08x\n", tom);
80 usmm = (smramc >> 4) & 0x3;
81 lsmm = (smramc >> 2) & 0x3;
86 printf("TSEG and HSEG both off\n");
89 printf("TSEG off, HSEG %s\n", lsmm ? "off" : "on");
92 printf("TSEG 512KB (%08x - %08x), HSEG %s\n",
93 tom - 512 * 1024, tom - 1, lsmm ? "off" : "on");
96 printf("TSEG 1MB (%08x - %08x), HSEG %s\n",
97 tom - 1 * 1024 * 1024, tom - 1, lsmm ? "off" : "on");
104 printf("ABSEG disabled\n");
107 printf("ABSEG enabled as system RAM\n");
110 printf("ABSEG enabled for SMM code only\n");
113 printf("ABSEG enabled for both SMM code and data\n");
121 unsigned char smramc = pci_read8(0, 0, 0, SMRAMC);
123 return (smramc & SMRAMC_LOCK) ? 1 : 0;
126 smram_state_t smram_save_state()
128 return pci_read8(0, 0, 0, SMRAMC);
131 void smram_restore_state(smram_state_t state)
133 pci_write8(0, 0, 0, SMRAMC, state);
136 int smram_aseg_set_state (int open) {
137 unsigned char smramc;
142 smramc = pci_read8(0, 0, 0, SMRAMC);
146 case SMRAM_ASEG_CLOSED:
147 smramc = (smramc & 0xF0) | 0x00;
149 case SMRAM_ASEG_OPEN:
150 smramc = (smramc & 0xF0) | 0x04;
152 case SMRAM_ASEG_SMMCODE:
153 smramc = (smramc & 0xF0) | 0x08;
155 case SMRAM_ASEG_SMMONLY:
156 smramc = (smramc & 0xF0) | 0x0C;
162 pci_write8(0, 0, 0, SMRAMC, smramc);
167 int smram_tseg_set_state (int open) {
168 unsigned char smramc;
173 smramc = pci_read8(0, 0, 0, SMRAMC);
177 case SMRAM_TSEG_OPEN:
178 smramc = (smramc & 0x8F) | 0x00;
184 pci_write8(0, 0, 0, SMRAMC, smramc);