xref: /qemu/include/hw/pci-host/pam.h (revision fc524567087c2537b5103cdfc1d41e4f442892b6)
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  *
10ef9f7b58SGonglei  * Split out from piix.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 
53*8be545baSRichard Henderson #include "system/memory.h"
54410edd92SIsaku Yamahata 
55410edd92SIsaku Yamahata #define SMRAM_C_BASE    0xa0000
56410edd92SIsaku Yamahata #define SMRAM_C_END     0xc0000
57410edd92SIsaku Yamahata #define SMRAM_C_SIZE    0x20000
58410edd92SIsaku Yamahata 
59410edd92SIsaku Yamahata #define PAM_EXPAN_BASE  0xc0000
60410edd92SIsaku Yamahata #define PAM_EXPAN_SIZE  0x04000
61410edd92SIsaku Yamahata 
62410edd92SIsaku Yamahata #define PAM_EXBIOS_BASE 0xe0000
63410edd92SIsaku Yamahata #define PAM_EXBIOS_SIZE 0x04000
64410edd92SIsaku Yamahata 
65410edd92SIsaku Yamahata #define PAM_BIOS_BASE   0xf0000
66410edd92SIsaku Yamahata #define PAM_BIOS_END    0xfffff
67410edd92SIsaku Yamahata /* 64KB: Intel 3 series express chipset family p. 58*/
68410edd92SIsaku Yamahata #define PAM_BIOS_SIZE   0x10000
69410edd92SIsaku Yamahata 
70410edd92SIsaku Yamahata /* PAM registers: log nibble and high nibble*/
71410edd92SIsaku Yamahata #define PAM_ATTR_WE     ((uint8_t)2)
72410edd92SIsaku Yamahata #define PAM_ATTR_RE     ((uint8_t)1)
73410edd92SIsaku Yamahata #define PAM_ATTR_MASK   ((uint8_t)3)
74410edd92SIsaku Yamahata 
75410edd92SIsaku Yamahata /* SMRAM register */
76410edd92SIsaku Yamahata #define SMRAM_D_OPEN           ((uint8_t)(1 << 6))
77410edd92SIsaku Yamahata #define SMRAM_D_CLS            ((uint8_t)(1 << 5))
78410edd92SIsaku Yamahata #define SMRAM_D_LCK            ((uint8_t)(1 << 4))
79410edd92SIsaku Yamahata #define SMRAM_G_SMRAME         ((uint8_t)(1 << 3))
80410edd92SIsaku Yamahata #define SMRAM_C_BASE_SEG_MASK  ((uint8_t)0x7)
81410edd92SIsaku Yamahata #define SMRAM_C_BASE_SEG       ((uint8_t)0x2)  /* hardwired to b010 */
82410edd92SIsaku Yamahata 
83f6a3c86eSPhilippe Mathieu-Daudé #define PAM_REGIONS_COUNT       13
84f6a3c86eSPhilippe Mathieu-Daudé 
85410edd92SIsaku Yamahata typedef struct PAMMemoryRegion {
86410edd92SIsaku Yamahata     MemoryRegion alias[4];  /* index = PAM value */
87410edd92SIsaku Yamahata     unsigned current;
88410edd92SIsaku Yamahata } PAMMemoryRegion;
89410edd92SIsaku Yamahata 
909e57b818SBernhard Beschow void init_pam(PAMMemoryRegion *mem, Object *owner, MemoryRegion *ram,
919e57b818SBernhard Beschow               MemoryRegion *system, MemoryRegion *pci,
929e57b818SBernhard Beschow               uint32_t start, uint32_t size);
93410edd92SIsaku Yamahata void pam_update(PAMMemoryRegion *mem, int idx, uint8_t val);
94410edd92SIsaku Yamahata 
95410edd92SIsaku Yamahata #endif /* QEMU_PAM_H */
96