Stefan Reinauer | 800379f | 2010-03-01 08:34:19 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2008-2009 coresystems GmbH |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License as |
| 8 | * published by the Free Software Foundation; version 2 of |
| 9 | * the License. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
Stefan Reinauer | 800379f | 2010-03-01 08:34:19 +0000 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | |
| 18 | #include <device/device.h> |
| 19 | #include <device/pci.h> |
| 20 | #include <console/console.h> |
Kyösti Mälkki | 2e50142 | 2017-04-21 08:43:09 +0300 | [diff] [blame] | 21 | #include <arch/acpi.h> |
Stefan Reinauer | 800379f | 2010-03-01 08:34:19 +0000 | [diff] [blame] | 22 | #include <arch/io.h> |
| 23 | #include <cpu/x86/cache.h> |
| 24 | #include <cpu/x86/smm.h> |
| 25 | #include <string.h> |
| 26 | #include "i82801dx.h" |
| 27 | |
Stefan Reinauer | 800379f | 2010-03-01 08:34:19 +0000 | [diff] [blame] | 28 | /* I945 */ |
| 29 | #define SMRAM 0x90 |
| 30 | #define D_OPEN (1 << 6) |
| 31 | #define D_CLS (1 << 5) |
| 32 | #define D_LCK (1 << 4) |
| 33 | #define G_SMRAME (1 << 3) |
| 34 | #define C_BASE_SEG ((0 << 2) | (1 << 1) | (0 << 0)) |
| 35 | |
| 36 | /* While we read PMBASE dynamically in case it changed, let's |
| 37 | * initialize it with a sane value |
| 38 | */ |
| 39 | static u16 pmbase = PMBASE_ADDR; |
| 40 | |
| 41 | /** |
| 42 | * @brief read and clear PM1_STS |
| 43 | * @return PM1_STS register |
| 44 | */ |
| 45 | static u16 reset_pm1_status(void) |
| 46 | { |
| 47 | u16 reg16; |
| 48 | |
| 49 | reg16 = inw(pmbase + PM1_STS); |
| 50 | /* set status bits are cleared by writing 1 to them */ |
| 51 | outw(reg16, pmbase + PM1_STS); |
| 52 | |
| 53 | return reg16; |
| 54 | } |
| 55 | |
| 56 | static void dump_pm1_status(u16 pm1_sts) |
| 57 | { |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 58 | printk(BIOS_DEBUG, "PM1_STS: "); |
| 59 | if (pm1_sts & (1 << 15)) printk(BIOS_DEBUG, "WAK "); |
| 60 | if (pm1_sts & (1 << 14)) printk(BIOS_DEBUG, "PCIEXPWAK "); |
| 61 | if (pm1_sts & (1 << 11)) printk(BIOS_DEBUG, "PRBTNOR "); |
| 62 | if (pm1_sts & (1 << 10)) printk(BIOS_DEBUG, "RTC "); |
| 63 | if (pm1_sts & (1 << 8)) printk(BIOS_DEBUG, "PWRBTN "); |
| 64 | if (pm1_sts & (1 << 5)) printk(BIOS_DEBUG, "GBL "); |
| 65 | if (pm1_sts & (1 << 4)) printk(BIOS_DEBUG, "BM "); |
| 66 | if (pm1_sts & (1 << 0)) printk(BIOS_DEBUG, "TMROF "); |
| 67 | printk(BIOS_DEBUG, "\n"); |
Stefan Reinauer | 800379f | 2010-03-01 08:34:19 +0000 | [diff] [blame] | 68 | } |
| 69 | |
| 70 | /** |
| 71 | * @brief read and clear SMI_STS |
| 72 | * @return SMI_STS register |
| 73 | */ |
| 74 | static u32 reset_smi_status(void) |
| 75 | { |
| 76 | u32 reg32; |
| 77 | |
| 78 | reg32 = inl(pmbase + SMI_STS); |
| 79 | /* set status bits are cleared by writing 1 to them */ |
| 80 | outl(reg32, pmbase + SMI_STS); |
| 81 | |
| 82 | return reg32; |
| 83 | } |
| 84 | |
| 85 | static void dump_smi_status(u32 smi_sts) |
| 86 | { |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 87 | printk(BIOS_DEBUG, "SMI_STS: "); |
| 88 | if (smi_sts & (1 << 26)) printk(BIOS_DEBUG, "SPI "); |
| 89 | if (smi_sts & (1 << 25)) printk(BIOS_DEBUG, "EL_SMI "); |
| 90 | if (smi_sts & (1 << 21)) printk(BIOS_DEBUG, "MONITOR "); |
| 91 | if (smi_sts & (1 << 20)) printk(BIOS_DEBUG, "PCI_EXP_SMI "); |
| 92 | if (smi_sts & (1 << 18)) printk(BIOS_DEBUG, "INTEL_USB2 "); |
| 93 | if (smi_sts & (1 << 17)) printk(BIOS_DEBUG, "LEGACY_USB2 "); |
| 94 | if (smi_sts & (1 << 16)) printk(BIOS_DEBUG, "SMBUS_SMI "); |
| 95 | if (smi_sts & (1 << 15)) printk(BIOS_DEBUG, "SERIRQ_SMI "); |
| 96 | if (smi_sts & (1 << 14)) printk(BIOS_DEBUG, "PERIODIC "); |
| 97 | if (smi_sts & (1 << 13)) printk(BIOS_DEBUG, "TCO "); |
| 98 | if (smi_sts & (1 << 12)) printk(BIOS_DEBUG, "DEVMON "); |
| 99 | if (smi_sts & (1 << 11)) printk(BIOS_DEBUG, "MCSMI "); |
| 100 | if (smi_sts & (1 << 10)) printk(BIOS_DEBUG, "GPI "); |
| 101 | if (smi_sts & (1 << 9)) printk(BIOS_DEBUG, "GPE0 "); |
| 102 | if (smi_sts & (1 << 8)) printk(BIOS_DEBUG, "PM1 "); |
| 103 | if (smi_sts & (1 << 6)) printk(BIOS_DEBUG, "SWSMI_TMR "); |
| 104 | if (smi_sts & (1 << 5)) printk(BIOS_DEBUG, "APM "); |
| 105 | if (smi_sts & (1 << 4)) printk(BIOS_DEBUG, "SLP_SMI "); |
| 106 | if (smi_sts & (1 << 3)) printk(BIOS_DEBUG, "LEGACY_USB "); |
| 107 | if (smi_sts & (1 << 2)) printk(BIOS_DEBUG, "BIOS "); |
| 108 | printk(BIOS_DEBUG, "\n"); |
Stefan Reinauer | 800379f | 2010-03-01 08:34:19 +0000 | [diff] [blame] | 109 | } |
| 110 | |
| 111 | |
| 112 | /** |
| 113 | * @brief read and clear GPE0_STS |
| 114 | * @return GPE0_STS register |
| 115 | */ |
| 116 | static u32 reset_gpe0_status(void) |
| 117 | { |
| 118 | u32 reg32; |
| 119 | |
| 120 | reg32 = inl(pmbase + GPE0_STS); |
| 121 | /* set status bits are cleared by writing 1 to them */ |
| 122 | outl(reg32, pmbase + GPE0_STS); |
| 123 | |
| 124 | return reg32; |
| 125 | } |
| 126 | |
| 127 | static void dump_gpe0_status(u32 gpe0_sts) |
| 128 | { |
| 129 | int i; |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 130 | printk(BIOS_DEBUG, "GPE0_STS: "); |
Konstantin Aladyshev | 62f8083 | 2013-03-07 04:04:27 +0400 | [diff] [blame] | 131 | for (i=31; i>= 16; i--) { |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 132 | if (gpe0_sts & (1 << i)) printk(BIOS_DEBUG, "GPIO%d ", (i-16)); |
Stefan Reinauer | 800379f | 2010-03-01 08:34:19 +0000 | [diff] [blame] | 133 | } |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 134 | if (gpe0_sts & (1 << 14)) printk(BIOS_DEBUG, "USB4 "); |
| 135 | if (gpe0_sts & (1 << 13)) printk(BIOS_DEBUG, "PME_B0 "); |
| 136 | if (gpe0_sts & (1 << 12)) printk(BIOS_DEBUG, "USB3 "); |
| 137 | if (gpe0_sts & (1 << 11)) printk(BIOS_DEBUG, "PME "); |
| 138 | if (gpe0_sts & (1 << 10)) printk(BIOS_DEBUG, "EL_SCI/BATLOW "); |
| 139 | if (gpe0_sts & (1 << 9)) printk(BIOS_DEBUG, "PCI_EXP "); |
| 140 | if (gpe0_sts & (1 << 8)) printk(BIOS_DEBUG, "RI "); |
| 141 | if (gpe0_sts & (1 << 7)) printk(BIOS_DEBUG, "SMB_WAK "); |
| 142 | if (gpe0_sts & (1 << 6)) printk(BIOS_DEBUG, "TCO_SCI "); |
| 143 | if (gpe0_sts & (1 << 5)) printk(BIOS_DEBUG, "AC97 "); |
| 144 | if (gpe0_sts & (1 << 4)) printk(BIOS_DEBUG, "USB2 "); |
| 145 | if (gpe0_sts & (1 << 3)) printk(BIOS_DEBUG, "USB1 "); |
| 146 | if (gpe0_sts & (1 << 2)) printk(BIOS_DEBUG, "HOT_PLUG "); |
| 147 | if (gpe0_sts & (1 << 0)) printk(BIOS_DEBUG, "THRM "); |
| 148 | printk(BIOS_DEBUG, "\n"); |
Stefan Reinauer | 800379f | 2010-03-01 08:34:19 +0000 | [diff] [blame] | 149 | } |
| 150 | |
| 151 | |
| 152 | /** |
| 153 | * @brief read and clear ALT_GP_SMI_STS |
| 154 | * @return ALT_GP_SMI_STS register |
| 155 | */ |
| 156 | static u16 reset_alt_gp_smi_status(void) |
| 157 | { |
| 158 | u16 reg16; |
| 159 | |
| 160 | reg16 = inl(pmbase + ALT_GP_SMI_STS); |
| 161 | /* set status bits are cleared by writing 1 to them */ |
| 162 | outl(reg16, pmbase + ALT_GP_SMI_STS); |
| 163 | |
| 164 | return reg16; |
| 165 | } |
| 166 | |
| 167 | static void dump_alt_gp_smi_status(u16 alt_gp_smi_sts) |
| 168 | { |
| 169 | int i; |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 170 | printk(BIOS_DEBUG, "ALT_GP_SMI_STS: "); |
Konstantin Aladyshev | 62f8083 | 2013-03-07 04:04:27 +0400 | [diff] [blame] | 171 | for (i=15; i>= 0; i--) { |
Konstantin Aladyshev | 07c3fc0 | 2013-03-07 04:37:02 +0400 | [diff] [blame] | 172 | if (alt_gp_smi_sts & (1 << i)) printk(BIOS_DEBUG, "GPI%d ", i); |
Stefan Reinauer | 800379f | 2010-03-01 08:34:19 +0000 | [diff] [blame] | 173 | } |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 174 | printk(BIOS_DEBUG, "\n"); |
Stefan Reinauer | 800379f | 2010-03-01 08:34:19 +0000 | [diff] [blame] | 175 | } |
| 176 | |
| 177 | |
| 178 | |
| 179 | /** |
| 180 | * @brief read and clear TCOx_STS |
| 181 | * @return TCOx_STS registers |
| 182 | */ |
| 183 | static u32 reset_tco_status(void) |
| 184 | { |
| 185 | u32 tcobase = pmbase + 0x60; |
| 186 | u32 reg32; |
| 187 | |
| 188 | reg32 = inl(tcobase + 0x04); |
| 189 | /* set status bits are cleared by writing 1 to them */ |
| 190 | outl(reg32 & ~(1<<18), tcobase + 0x04); // Don't clear BOOT_STS before SECOND_TO_STS |
| 191 | if (reg32 & (1 << 18)) |
| 192 | outl(reg32 & (1<<18), tcobase + 0x04); // clear BOOT_STS |
| 193 | |
| 194 | return reg32; |
| 195 | } |
| 196 | |
| 197 | |
| 198 | static void dump_tco_status(u32 tco_sts) |
| 199 | { |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 200 | printk(BIOS_DEBUG, "TCO_STS: "); |
| 201 | if (tco_sts & (1 << 20)) printk(BIOS_DEBUG, "SMLINK_SLV "); |
| 202 | if (tco_sts & (1 << 18)) printk(BIOS_DEBUG, "BOOT "); |
| 203 | if (tco_sts & (1 << 17)) printk(BIOS_DEBUG, "SECOND_TO "); |
| 204 | if (tco_sts & (1 << 16)) printk(BIOS_DEBUG, "INTRD_DET "); |
| 205 | if (tco_sts & (1 << 12)) printk(BIOS_DEBUG, "DMISERR "); |
| 206 | if (tco_sts & (1 << 10)) printk(BIOS_DEBUG, "DMISMI "); |
| 207 | if (tco_sts & (1 << 9)) printk(BIOS_DEBUG, "DMISCI "); |
| 208 | if (tco_sts & (1 << 8)) printk(BIOS_DEBUG, "BIOSWR "); |
| 209 | if (tco_sts & (1 << 7)) printk(BIOS_DEBUG, "NEWCENTURY "); |
| 210 | if (tco_sts & (1 << 3)) printk(BIOS_DEBUG, "TIMEOUT "); |
| 211 | if (tco_sts & (1 << 2)) printk(BIOS_DEBUG, "TCO_INT "); |
| 212 | if (tco_sts & (1 << 1)) printk(BIOS_DEBUG, "SW_TCO "); |
| 213 | if (tco_sts & (1 << 0)) printk(BIOS_DEBUG, "NMI2SMI "); |
| 214 | printk(BIOS_DEBUG, "\n"); |
Stefan Reinauer | 800379f | 2010-03-01 08:34:19 +0000 | [diff] [blame] | 215 | } |
| 216 | |
| 217 | |
| 218 | |
| 219 | /** |
| 220 | * @brief Set the EOS bit |
| 221 | */ |
| 222 | static void smi_set_eos(void) |
| 223 | { |
| 224 | u8 reg8; |
| 225 | |
| 226 | reg8 = inb(pmbase + SMI_EN); |
| 227 | reg8 |= EOS; |
| 228 | outb(reg8, pmbase + SMI_EN); |
| 229 | } |
| 230 | |
| 231 | extern uint8_t smm_relocation_start, smm_relocation_end; |
Kyösti Mälkki | 2e50142 | 2017-04-21 08:43:09 +0300 | [diff] [blame] | 232 | static void *default_smm_area = NULL; |
Stefan Reinauer | 800379f | 2010-03-01 08:34:19 +0000 | [diff] [blame] | 233 | |
Stefan Reinauer | bd11298 | 2010-03-17 03:14:54 +0000 | [diff] [blame] | 234 | static void smm_relocate(void) |
Stefan Reinauer | 800379f | 2010-03-01 08:34:19 +0000 | [diff] [blame] | 235 | { |
| 236 | u32 smi_en; |
| 237 | u16 pm1_en; |
| 238 | |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 239 | printk(BIOS_DEBUG, "Initializing SMM handler..."); |
Stefan Reinauer | 800379f | 2010-03-01 08:34:19 +0000 | [diff] [blame] | 240 | |
Kyösti Mälkki | c70eed1 | 2018-05-22 02:18:00 +0300 | [diff] [blame^] | 241 | pmbase = pci_read_config16(pcidev_on_root(0x1f, 0), 0x40) & 0xfffc; |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 242 | printk(BIOS_SPEW, " ... pmbase = 0x%04x\n", pmbase); |
Stefan Reinauer | 800379f | 2010-03-01 08:34:19 +0000 | [diff] [blame] | 243 | |
| 244 | smi_en = inl(pmbase + SMI_EN); |
| 245 | if (smi_en & APMC_EN) { |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 246 | printk(BIOS_INFO, "SMI# handler already enabled?\n"); |
Stefan Reinauer | 800379f | 2010-03-01 08:34:19 +0000 | [diff] [blame] | 247 | return; |
| 248 | } |
| 249 | |
Kyösti Mälkki | 2e50142 | 2017-04-21 08:43:09 +0300 | [diff] [blame] | 250 | default_smm_area = backup_default_smm_area(); |
| 251 | |
Stefan Reinauer | 800379f | 2010-03-01 08:34:19 +0000 | [diff] [blame] | 252 | /* copy the SMM relocation code */ |
| 253 | memcpy((void *)0x38000, &smm_relocation_start, |
| 254 | &smm_relocation_end - &smm_relocation_start); |
Kyösti Mälkki | b6e9021 | 2016-12-04 22:17:37 +0200 | [diff] [blame] | 255 | wbinvd(); |
Stefan Reinauer | 800379f | 2010-03-01 08:34:19 +0000 | [diff] [blame] | 256 | |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 257 | printk(BIOS_DEBUG, "\n"); |
Stefan Reinauer | 800379f | 2010-03-01 08:34:19 +0000 | [diff] [blame] | 258 | dump_smi_status(reset_smi_status()); |
| 259 | dump_pm1_status(reset_pm1_status()); |
| 260 | dump_gpe0_status(reset_gpe0_status()); |
| 261 | dump_alt_gp_smi_status(reset_alt_gp_smi_status()); |
| 262 | dump_tco_status(reset_tco_status()); |
| 263 | |
| 264 | /* Enable SMI generation: |
| 265 | * - on TCO events |
| 266 | * - on APMC writes (io 0xb2) |
| 267 | * - on writes to SLP_EN (sleep states) |
| 268 | * - on writes to GBL_RLS (bios commands) |
| 269 | * No SMIs: |
| 270 | * - on microcontroller writes (io 0x62/0x66) |
| 271 | */ |
| 272 | |
| 273 | smi_en = 0; /* reset SMI enables */ |
| 274 | |
| 275 | #if 0 |
| 276 | smi_en |= LEGACY_USB2_EN | LEGACY_USB_EN; |
| 277 | #endif |
| 278 | smi_en |= TCO_EN; |
| 279 | smi_en |= APMC_EN; |
| 280 | #if DEBUG_PERIODIC_SMIS |
| 281 | /* Set DEBUG_PERIODIC_SMIS in i82801gx.h to debug using |
| 282 | * periodic SMIs. |
| 283 | */ |
| 284 | smi_en |= PERIODIC_EN; |
| 285 | #endif |
| 286 | smi_en |= SLP_SMI_EN; |
| 287 | smi_en |= BIOS_EN; |
| 288 | |
| 289 | /* The following need to be on for SMIs to happen */ |
| 290 | smi_en |= EOS | GBL_SMI_EN; |
| 291 | |
| 292 | outl(smi_en, pmbase + SMI_EN); |
| 293 | |
| 294 | pm1_en = 0; |
| 295 | pm1_en |= PWRBTN_EN; |
| 296 | pm1_en |= GBL_EN; |
| 297 | outw(pm1_en, pmbase + PM1_EN); |
| 298 | |
| 299 | /** |
| 300 | * There are several methods of raising a controlled SMI# via |
| 301 | * software, among them: |
| 302 | * - Writes to io 0xb2 (APMC) |
| 303 | * - Writes to the Local Apic ICR with Delivery mode SMI. |
| 304 | * |
| 305 | * Using the local apic is a bit more tricky. According to |
| 306 | * AMD Family 11 Processor BKDG no destination shorthand must be |
| 307 | * used. |
| 308 | * The whole SMM initialization is quite a bit hardware specific, so |
| 309 | * I'm not too worried about the better of the methods at the moment |
| 310 | */ |
| 311 | |
| 312 | /* raise an SMI interrupt */ |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 313 | printk(BIOS_SPEW, " ... raise SMI#\n"); |
Stefan Reinauer | 800379f | 2010-03-01 08:34:19 +0000 | [diff] [blame] | 314 | outb(0x00, 0xb2); |
| 315 | } |
| 316 | |
Stefan Reinauer | bd11298 | 2010-03-17 03:14:54 +0000 | [diff] [blame] | 317 | static void smm_install(void) |
Stefan Reinauer | 800379f | 2010-03-01 08:34:19 +0000 | [diff] [blame] | 318 | { |
| 319 | /* enable the SMM memory window */ |
Kyösti Mälkki | c70eed1 | 2018-05-22 02:18:00 +0300 | [diff] [blame^] | 320 | pci_write_config8(pcidev_on_root(0, 0), SMRAM, |
Stefan Reinauer | 800379f | 2010-03-01 08:34:19 +0000 | [diff] [blame] | 321 | D_OPEN | G_SMRAME | C_BASE_SEG); |
| 322 | |
| 323 | /* copy the real SMM handler */ |
Kyösti Mälkki | 9d8adc0 | 2016-12-04 22:17:37 +0200 | [diff] [blame] | 324 | memcpy((void *)0xa0000, _binary_smm_start, |
| 325 | _binary_smm_end - _binary_smm_start); |
Stefan Reinauer | 800379f | 2010-03-01 08:34:19 +0000 | [diff] [blame] | 326 | wbinvd(); |
| 327 | |
| 328 | /* close the SMM memory window and enable normal SMM */ |
Kyösti Mälkki | c70eed1 | 2018-05-22 02:18:00 +0300 | [diff] [blame^] | 329 | pci_write_config8(pcidev_on_root(0, 0), SMRAM, |
Stefan Reinauer | 800379f | 2010-03-01 08:34:19 +0000 | [diff] [blame] | 330 | G_SMRAME | C_BASE_SEG); |
| 331 | } |
| 332 | |
| 333 | void smm_init(void) |
| 334 | { |
Stefan Reinauer | bc0f7a6 | 2010-08-01 15:41:14 +0000 | [diff] [blame] | 335 | /* Put SMM code to 0xa0000 */ |
Stefan Reinauer | 800379f | 2010-03-01 08:34:19 +0000 | [diff] [blame] | 336 | smm_install(); |
| 337 | |
Stefan Reinauer | bc0f7a6 | 2010-08-01 15:41:14 +0000 | [diff] [blame] | 338 | /* Put relocation code to 0x38000 and relocate SMBASE */ |
| 339 | smm_relocate(); |
| 340 | |
| 341 | /* We're done. Make sure SMIs can happen! */ |
Stefan Reinauer | 800379f | 2010-03-01 08:34:19 +0000 | [diff] [blame] | 342 | smi_set_eos(); |
| 343 | } |
| 344 | |
Kyösti Mälkki | 2e50142 | 2017-04-21 08:43:09 +0300 | [diff] [blame] | 345 | void smm_init_completion(void) |
| 346 | { |
| 347 | restore_default_smm_area(default_smm_area); |
| 348 | } |
| 349 | |
Stefan Reinauer | 800379f | 2010-03-01 08:34:19 +0000 | [diff] [blame] | 350 | void smm_lock(void) |
| 351 | { |
| 352 | /* LOCK the SMM memory window and enable normal SMM. |
| 353 | * After running this function, only a full reset can |
| 354 | * make the SMM registers writable again. |
| 355 | */ |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 356 | printk(BIOS_DEBUG, "Locking SMM.\n"); |
Kyösti Mälkki | c70eed1 | 2018-05-22 02:18:00 +0300 | [diff] [blame^] | 357 | pci_write_config8(pcidev_on_root(0, 0), SMRAM, |
Stefan Reinauer | 800379f | 2010-03-01 08:34:19 +0000 | [diff] [blame] | 358 | D_LCK | G_SMRAME | C_BASE_SEG); |
| 359 | } |
| 360 | |
| 361 | void smm_setup_structures(void *gnvs, void *tcg, void *smi1) |
| 362 | { |
| 363 | /* The GDT or coreboot table is going to live here. But a long time |
| 364 | * after we relocated the GNVS, so this is not troublesome. |
| 365 | */ |
| 366 | *(u32 *)0x500 = (u32)gnvs; |
| 367 | *(u32 *)0x504 = (u32)tcg; |
| 368 | *(u32 *)0x508 = (u32)smi1; |
| 369 | outb(0xea, 0xb2); |
| 370 | } |