2 * QEMU i440FX/PIIX3 PCI Bridge Emulation
4 * Copyright (c) 2006 Fabrice Bellard
5 * Copyright (c) 2011 Isaku Yamahata <yamahata at valinux co jp>
6 * VA Linux Systems Japan K.K.
7 * Copyright (c) 2012 Jason Baron <jbaron@redhat.com>
9 * Split out from piix_pci.c
11 * Permission is hereby granted, free of charge, to any person obtaining a copy
12 * of this software and associated documentation files (the "Software"), to deal
13 * in the Software without restriction, including without limitation the rights
14 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 * copies of the Software, and to permit persons to whom the Software is
16 * furnished to do so, subject to the following conditions:
18 * The above copyright notice and this permission notice shall be included in
19 * all copies or substantial portions of the Software.
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
30 #include "qom/object.h"
31 #include "sysemu/sysemu.h"
32 #include "hw/pci-host/pam.h"
34 void smram_update(MemoryRegion
*smram_region
, uint8_t smram
,
39 smram_enabled
= ((smm_enabled
&& (smram
& SMRAM_G_SMRAME
)) ||
40 (smram
& SMRAM_D_OPEN
));
41 memory_region_set_enabled(smram_region
, !smram_enabled
);
44 void smram_set_smm(uint8_t *host_smm_enabled
, int smm
, uint8_t smram
,
45 MemoryRegion
*smram_region
)
47 uint8_t smm_enabled
= (smm
!= 0);
48 if (*host_smm_enabled
!= smm_enabled
) {
49 *host_smm_enabled
= smm_enabled
;
50 smram_update(smram_region
, smram
, *host_smm_enabled
);
54 void init_pam(DeviceState
*dev
, MemoryRegion
*ram_memory
,
55 MemoryRegion
*system_memory
, MemoryRegion
*pci_address_space
,
56 PAMMemoryRegion
*mem
, uint32_t start
, uint32_t size
)
61 memory_region_init_alias(&mem
->alias
[3], OBJECT(dev
), "pam-ram", ram_memory
,
63 /* ROM (XXX: not quite correct) */
64 memory_region_init_alias(&mem
->alias
[1], OBJECT(dev
), "pam-rom", ram_memory
,
66 memory_region_set_readonly(&mem
->alias
[1], true);
68 /* XXX: should distinguish read/write cases */
69 memory_region_init_alias(&mem
->alias
[0], OBJECT(dev
), "pam-pci", pci_address_space
,
71 memory_region_init_alias(&mem
->alias
[2], OBJECT(dev
), "pam-pci", ram_memory
,
74 for (i
= 0; i
< 4; ++i
) {
75 memory_region_set_enabled(&mem
->alias
[i
], false);
76 memory_region_add_subregion_overlap(system_memory
, start
,
82 void pam_update(PAMMemoryRegion
*pam
, int idx
, uint8_t val
)
84 assert(0 <= idx
&& idx
<= 12);
86 memory_region_set_enabled(&pam
->alias
[pam
->current
], false);
87 pam
->current
= (val
>> ((!(idx
& 1)) * 4)) & PAM_ATTR_MASK
;
88 memory_region_set_enabled(&pam
->alias
[pam
->current
], true);