1410edd92SIsaku Yamahata #ifndef QEMU_PAM_H 2410edd92SIsaku Yamahata #define QEMU_PAM_H 3410edd92SIsaku Yamahata 4410edd92SIsaku Yamahata /* 5410edd92SIsaku Yamahata * Copyright (c) 2006 Fabrice Bellard 6410edd92SIsaku Yamahata * Copyright (c) 2011 Isaku Yamahata <yamahata at valinux co jp> 7410edd92SIsaku Yamahata * VA Linux Systems Japan K.K. 8410edd92SIsaku Yamahata * Copyright (c) 2012 Jason Baron <jbaron@redhat.com> 9410edd92SIsaku Yamahata * 10410edd92SIsaku Yamahata * Split out from piix_pci.c 11410edd92SIsaku Yamahata * 12410edd92SIsaku Yamahata * Permission is hereby granted, free of charge, to any person obtaining a copy 13410edd92SIsaku Yamahata * of this software and associated documentation files (the "Software"), to deal 14410edd92SIsaku Yamahata * in the Software without restriction, including without limitation the rights 15410edd92SIsaku Yamahata * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16410edd92SIsaku Yamahata * copies of the Software, and to permit persons to whom the Software is 17410edd92SIsaku Yamahata * furnished to do so, subject to the following conditions: 18410edd92SIsaku Yamahata * 19410edd92SIsaku Yamahata * The above copyright notice and this permission notice shall be included in 20410edd92SIsaku Yamahata * all copies or substantial portions of the Software. 21410edd92SIsaku Yamahata * 22410edd92SIsaku Yamahata * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23410edd92SIsaku Yamahata * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24410edd92SIsaku Yamahata * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 25410edd92SIsaku Yamahata * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26410edd92SIsaku Yamahata * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27410edd92SIsaku Yamahata * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 28410edd92SIsaku Yamahata * THE SOFTWARE. 29410edd92SIsaku Yamahata */ 30410edd92SIsaku Yamahata 31410edd92SIsaku Yamahata /* 32410edd92SIsaku Yamahata * SMRAM memory area and PAM memory area in Legacy address range for PC. 33410edd92SIsaku Yamahata * PAM: Programmable Attribute Map registers 34410edd92SIsaku Yamahata * 35410edd92SIsaku Yamahata * 0xa0000 - 0xbffff compatible SMRAM 36410edd92SIsaku Yamahata * 37410edd92SIsaku Yamahata * 0xc0000 - 0xc3fff Expansion area memory segments 38410edd92SIsaku Yamahata * 0xc4000 - 0xc7fff 39410edd92SIsaku Yamahata * 0xc8000 - 0xcbfff 40410edd92SIsaku Yamahata * 0xcc000 - 0xcffff 41410edd92SIsaku Yamahata * 0xd0000 - 0xd3fff 42410edd92SIsaku Yamahata * 0xd4000 - 0xd7fff 43410edd92SIsaku Yamahata * 0xd8000 - 0xdbfff 44410edd92SIsaku Yamahata * 0xdc000 - 0xdffff 45410edd92SIsaku Yamahata * 0xe0000 - 0xe3fff Extended System BIOS Area Memory Segments 46410edd92SIsaku Yamahata * 0xe4000 - 0xe7fff 47410edd92SIsaku Yamahata * 0xe8000 - 0xebfff 48410edd92SIsaku Yamahata * 0xec000 - 0xeffff 49410edd92SIsaku Yamahata * 50410edd92SIsaku Yamahata * 0xf0000 - 0xfffff System BIOS Area Memory Segments 51410edd92SIsaku Yamahata */ 52410edd92SIsaku Yamahata 53410edd92SIsaku Yamahata #include "qemu-common.h" 54*022c62cbSPaolo Bonzini #include "exec/memory.h" 55410edd92SIsaku Yamahata 56410edd92SIsaku Yamahata #define SMRAM_C_BASE 0xa0000 57410edd92SIsaku Yamahata #define SMRAM_C_END 0xc0000 58410edd92SIsaku Yamahata #define SMRAM_C_SIZE 0x20000 59410edd92SIsaku Yamahata 60410edd92SIsaku Yamahata #define PAM_EXPAN_BASE 0xc0000 61410edd92SIsaku Yamahata #define PAM_EXPAN_SIZE 0x04000 62410edd92SIsaku Yamahata 63410edd92SIsaku Yamahata #define PAM_EXBIOS_BASE 0xe0000 64410edd92SIsaku Yamahata #define PAM_EXBIOS_SIZE 0x04000 65410edd92SIsaku Yamahata 66410edd92SIsaku Yamahata #define PAM_BIOS_BASE 0xf0000 67410edd92SIsaku Yamahata #define PAM_BIOS_END 0xfffff 68410edd92SIsaku Yamahata /* 64KB: Intel 3 series express chipset family p. 58*/ 69410edd92SIsaku Yamahata #define PAM_BIOS_SIZE 0x10000 70410edd92SIsaku Yamahata 71410edd92SIsaku Yamahata /* PAM registers: log nibble and high nibble*/ 72410edd92SIsaku Yamahata #define PAM_ATTR_WE ((uint8_t)2) 73410edd92SIsaku Yamahata #define PAM_ATTR_RE ((uint8_t)1) 74410edd92SIsaku Yamahata #define PAM_ATTR_MASK ((uint8_t)3) 75410edd92SIsaku Yamahata 76410edd92SIsaku Yamahata /* SMRAM register */ 77410edd92SIsaku Yamahata #define SMRAM_D_OPEN ((uint8_t)(1 << 6)) 78410edd92SIsaku Yamahata #define SMRAM_D_CLS ((uint8_t)(1 << 5)) 79410edd92SIsaku Yamahata #define SMRAM_D_LCK ((uint8_t)(1 << 4)) 80410edd92SIsaku Yamahata #define SMRAM_G_SMRAME ((uint8_t)(1 << 3)) 81410edd92SIsaku Yamahata #define SMRAM_C_BASE_SEG_MASK ((uint8_t)0x7) 82410edd92SIsaku Yamahata #define SMRAM_C_BASE_SEG ((uint8_t)0x2) /* hardwired to b010 */ 83410edd92SIsaku Yamahata 84410edd92SIsaku Yamahata typedef struct PAMMemoryRegion { 85410edd92SIsaku Yamahata MemoryRegion alias[4]; /* index = PAM value */ 86410edd92SIsaku Yamahata unsigned current; 87410edd92SIsaku Yamahata } PAMMemoryRegion; 88410edd92SIsaku Yamahata 89410edd92SIsaku Yamahata void smram_update(MemoryRegion *smram_region, uint8_t smram, 90410edd92SIsaku Yamahata uint8_t smm_enabled); 91410edd92SIsaku Yamahata void smram_set_smm(uint8_t *host_smm_enabled, int smm, uint8_t smram, 92410edd92SIsaku Yamahata MemoryRegion *smram_region); 93410edd92SIsaku Yamahata void init_pam(MemoryRegion *ram, MemoryRegion *system, MemoryRegion *pci, 94410edd92SIsaku Yamahata PAMMemoryRegion *mem, uint32_t start, uint32_t size); 95410edd92SIsaku Yamahata void pam_update(PAMMemoryRegion *mem, int idx, uint8_t val); 96410edd92SIsaku Yamahata 97410edd92SIsaku Yamahata #endif /* QEMU_PAM_H */ 98