1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29#include "sysemu/sysemu.h"
30#include "pam.h"
31
32void smram_update(MemoryRegion *smram_region, uint8_t smram,
33 uint8_t smm_enabled)
34{
35 bool smram_enabled;
36
37 smram_enabled = ((smm_enabled && (smram & SMRAM_G_SMRAME)) ||
38 (smram & SMRAM_D_OPEN));
39 memory_region_set_enabled(smram_region, !smram_enabled);
40}
41
42void smram_set_smm(uint8_t *host_smm_enabled, int smm, uint8_t smram,
43 MemoryRegion *smram_region)
44{
45 uint8_t smm_enabled = (smm != 0);
46 if (*host_smm_enabled != smm_enabled) {
47 *host_smm_enabled = smm_enabled;
48 smram_update(smram_region, smram, *host_smm_enabled);
49 }
50}
51
52void init_pam(MemoryRegion *ram_memory, MemoryRegion *system_memory,
53 MemoryRegion *pci_address_space, PAMMemoryRegion *mem,
54 uint32_t start, uint32_t size)
55{
56 int i;
57
58
59 memory_region_init_alias(&mem->alias[3], "pam-ram", ram_memory,
60 start, size);
61
62 memory_region_init_alias(&mem->alias[1], "pam-rom", ram_memory,
63 start, size);
64 memory_region_set_readonly(&mem->alias[1], true);
65
66
67 memory_region_init_alias(&mem->alias[0], "pam-pci", pci_address_space,
68 start, size);
69 memory_region_init_alias(&mem->alias[2], "pam-pci", pci_address_space,
70 start, size);
71
72 for (i = 0; i < 4; ++i) {
73 memory_region_set_enabled(&mem->alias[i], false);
74 memory_region_add_subregion_overlap(system_memory, start,
75 &mem->alias[i], 1);
76 }
77 mem->current = 0;
78}
79
80void pam_update(PAMMemoryRegion *pam, int idx, uint8_t val)
81{
82 assert(0 <= idx && idx <= 12);
83
84 memory_region_set_enabled(&pam->alias[pam->current], false);
85 pam->current = (val >> ((!(idx & 1)) * 4)) & PAM_ATTR_MASK;
86 memory_region_set_enabled(&pam->alias[pam->current], true);
87}
88