1*410edd92SIsaku Yamahata #ifndef QEMU_PAM_H 2*410edd92SIsaku Yamahata #define QEMU_PAM_H 3*410edd92SIsaku Yamahata 4*410edd92SIsaku Yamahata /* 5*410edd92SIsaku Yamahata * Copyright (c) 2006 Fabrice Bellard 6*410edd92SIsaku Yamahata * Copyright (c) 2011 Isaku Yamahata <yamahata at valinux co jp> 7*410edd92SIsaku Yamahata * VA Linux Systems Japan K.K. 8*410edd92SIsaku Yamahata * Copyright (c) 2012 Jason Baron <jbaron@redhat.com> 9*410edd92SIsaku Yamahata * 10*410edd92SIsaku Yamahata * Split out from piix_pci.c 11*410edd92SIsaku Yamahata * 12*410edd92SIsaku Yamahata * Permission is hereby granted, free of charge, to any person obtaining a copy 13*410edd92SIsaku Yamahata * of this software and associated documentation files (the "Software"), to deal 14*410edd92SIsaku Yamahata * in the Software without restriction, including without limitation the rights 15*410edd92SIsaku Yamahata * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16*410edd92SIsaku Yamahata * copies of the Software, and to permit persons to whom the Software is 17*410edd92SIsaku Yamahata * furnished to do so, subject to the following conditions: 18*410edd92SIsaku Yamahata * 19*410edd92SIsaku Yamahata * The above copyright notice and this permission notice shall be included in 20*410edd92SIsaku Yamahata * all copies or substantial portions of the Software. 21*410edd92SIsaku Yamahata * 22*410edd92SIsaku Yamahata * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23*410edd92SIsaku Yamahata * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24*410edd92SIsaku Yamahata * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 25*410edd92SIsaku Yamahata * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26*410edd92SIsaku Yamahata * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27*410edd92SIsaku Yamahata * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 28*410edd92SIsaku Yamahata * THE SOFTWARE. 29*410edd92SIsaku Yamahata */ 30*410edd92SIsaku Yamahata 31*410edd92SIsaku Yamahata /* 32*410edd92SIsaku Yamahata * SMRAM memory area and PAM memory area in Legacy address range for PC. 33*410edd92SIsaku Yamahata * PAM: Programmable Attribute Map registers 34*410edd92SIsaku Yamahata * 35*410edd92SIsaku Yamahata * 0xa0000 - 0xbffff compatible SMRAM 36*410edd92SIsaku Yamahata * 37*410edd92SIsaku Yamahata * 0xc0000 - 0xc3fff Expansion area memory segments 38*410edd92SIsaku Yamahata * 0xc4000 - 0xc7fff 39*410edd92SIsaku Yamahata * 0xc8000 - 0xcbfff 40*410edd92SIsaku Yamahata * 0xcc000 - 0xcffff 41*410edd92SIsaku Yamahata * 0xd0000 - 0xd3fff 42*410edd92SIsaku Yamahata * 0xd4000 - 0xd7fff 43*410edd92SIsaku Yamahata * 0xd8000 - 0xdbfff 44*410edd92SIsaku Yamahata * 0xdc000 - 0xdffff 45*410edd92SIsaku Yamahata * 0xe0000 - 0xe3fff Extended System BIOS Area Memory Segments 46*410edd92SIsaku Yamahata * 0xe4000 - 0xe7fff 47*410edd92SIsaku Yamahata * 0xe8000 - 0xebfff 48*410edd92SIsaku Yamahata * 0xec000 - 0xeffff 49*410edd92SIsaku Yamahata * 50*410edd92SIsaku Yamahata * 0xf0000 - 0xfffff System BIOS Area Memory Segments 51*410edd92SIsaku Yamahata */ 52*410edd92SIsaku Yamahata 53*410edd92SIsaku Yamahata #include "qemu-common.h" 54*410edd92SIsaku Yamahata #include "memory.h" 55*410edd92SIsaku Yamahata 56*410edd92SIsaku Yamahata #define SMRAM_C_BASE 0xa0000 57*410edd92SIsaku Yamahata #define SMRAM_C_END 0xc0000 58*410edd92SIsaku Yamahata #define SMRAM_C_SIZE 0x20000 59*410edd92SIsaku Yamahata 60*410edd92SIsaku Yamahata #define PAM_EXPAN_BASE 0xc0000 61*410edd92SIsaku Yamahata #define PAM_EXPAN_SIZE 0x04000 62*410edd92SIsaku Yamahata 63*410edd92SIsaku Yamahata #define PAM_EXBIOS_BASE 0xe0000 64*410edd92SIsaku Yamahata #define PAM_EXBIOS_SIZE 0x04000 65*410edd92SIsaku Yamahata 66*410edd92SIsaku Yamahata #define PAM_BIOS_BASE 0xf0000 67*410edd92SIsaku Yamahata #define PAM_BIOS_END 0xfffff 68*410edd92SIsaku Yamahata /* 64KB: Intel 3 series express chipset family p. 58*/ 69*410edd92SIsaku Yamahata #define PAM_BIOS_SIZE 0x10000 70*410edd92SIsaku Yamahata 71*410edd92SIsaku Yamahata /* PAM registers: log nibble and high nibble*/ 72*410edd92SIsaku Yamahata #define PAM_ATTR_WE ((uint8_t)2) 73*410edd92SIsaku Yamahata #define PAM_ATTR_RE ((uint8_t)1) 74*410edd92SIsaku Yamahata #define PAM_ATTR_MASK ((uint8_t)3) 75*410edd92SIsaku Yamahata 76*410edd92SIsaku Yamahata /* SMRAM register */ 77*410edd92SIsaku Yamahata #define SMRAM_D_OPEN ((uint8_t)(1 << 6)) 78*410edd92SIsaku Yamahata #define SMRAM_D_CLS ((uint8_t)(1 << 5)) 79*410edd92SIsaku Yamahata #define SMRAM_D_LCK ((uint8_t)(1 << 4)) 80*410edd92SIsaku Yamahata #define SMRAM_G_SMRAME ((uint8_t)(1 << 3)) 81*410edd92SIsaku Yamahata #define SMRAM_C_BASE_SEG_MASK ((uint8_t)0x7) 82*410edd92SIsaku Yamahata #define SMRAM_C_BASE_SEG ((uint8_t)0x2) /* hardwired to b010 */ 83*410edd92SIsaku Yamahata 84*410edd92SIsaku Yamahata typedef struct PAMMemoryRegion { 85*410edd92SIsaku Yamahata MemoryRegion alias[4]; /* index = PAM value */ 86*410edd92SIsaku Yamahata unsigned current; 87*410edd92SIsaku Yamahata } PAMMemoryRegion; 88*410edd92SIsaku Yamahata 89*410edd92SIsaku Yamahata void smram_update(MemoryRegion *smram_region, uint8_t smram, 90*410edd92SIsaku Yamahata uint8_t smm_enabled); 91*410edd92SIsaku Yamahata void smram_set_smm(uint8_t *host_smm_enabled, int smm, uint8_t smram, 92*410edd92SIsaku Yamahata MemoryRegion *smram_region); 93*410edd92SIsaku Yamahata void init_pam(MemoryRegion *ram, MemoryRegion *system, MemoryRegion *pci, 94*410edd92SIsaku Yamahata PAMMemoryRegion *mem, uint32_t start, uint32_t size); 95*410edd92SIsaku Yamahata void pam_update(PAMMemoryRegion *mem, int idx, uint8_t val); 96*410edd92SIsaku Yamahata 97*410edd92SIsaku Yamahata #endif /* QEMU_PAM_H */ 98