Previous - Up - Next
19.1 Memory Space Basics
Simics memory-spaces are handled by the generic memory-space
class. A memory-space object implements interface functions for
memory accesses, and it has attributes specifying how the mappings are setup.
The most important attribute in a memory-space is the map
attribute. This is a list of mapped objects that may contain devices, RAM and
ROM objects, and other memory-spaces. In addition to the map
attribute, there is also a default_target attribute that is used
for accesses that don't match any of the targets in the map list.
Python example of a memory-space object where already created
objects are mapped into a new memory space:
@mem = pre_conf_object('phys_mem', 'memory-space')
@mem.map = [[0x00000000, conf.ram0, 0, 0, 0xa0000],
[0x000a0000, conf.vga0, 1, 0, 0x20000],
[0x000c0000, conf.rom0, 0, 0, 0x10000],
[0x000f0000, conf.rom0, 0, 0, 0x10000],
[0x00100000, conf.ram0, 0, 0x100000, 0xff00000],
[0xfee00000, conf.apic0, 0, 0, 0x4000],
[0xffe81000, conf.hfs0, 0, 0, 16],
[0xffff0000, conf.rom0, 0, 0, 0x10000]]
@mem.default_target = [conf.pci_mem0, 0, 0, conf.pci_mem0]
@SIM_add_configuration([mem], None)
The fields for an entry in the map list are as follows:
- base
- The start address of the mapping in the memory space.
- object
- Reference to the mapped object.
- function
- An object specific identification number for this mapping. The
function number is typically used by objects that have several mappings. When an
object is accessed, it can use the function number to figure out what mapping it
was accessed through.
- offset
- The start offset in the target object. This is often used
when a memory-space is mapped in another memory-space. Example: memory-space B
is mapped in space A at base 0x4000 with length 0x1000, and with offset
0x2000. If an access is made in space A at address 0x4010, it will be forwarded
to space B at address 0x2010. Without any offset in the mapping, the resulting
address would have been 0x10.
- length
- The size of the mapping in bytes.
- target
- (optional) If object isn't the final destination for
the access, then target is a reference to the actual target object. This
is described in more details in the section about different mapping types.
- priority
- (optional) The priority of the mapping. Default is 0
(highest priority), and the lowest is 256. If mappings overlap, then the
priority field specified what mapping that has precedence. It is an error if
overlapping mappings have the same priority. Usually overlapping mappings
should be avoided, but for bridges that catch unclaimed accesses in specific
address ranges the priority field is useful. There are also devices that have
overlapping mappings that have different priorities, and in that case the
priority field in the map list can be used.
- align-size
- (optional) The align-size can be be used
if a target does not support large accesses. Accesses that crosses an alignment
boundary will be split into several transactions by the Simics memory
system. By default this will be set to 4 bytes for port space devices, 8 bytes
for other devices and 4096 or 8192 for memory.
- reverse-endian
- (optional) Some device mappings reverse the byte
order of data, to support mixed-endian environments. The reverse-endian
field can be used to model this behavior. It will reverse the byte-order of
data for mappings that have an align-size of 2, 4 or 8 bytes.
Note: In Simics versions prior to 2.0, the priority field was a
"reverse-endian" flag. Old checkpoints will automatically be updated with this
field cleared, since the handling of endian swapping has changed. This old
"reverse-endian" flag was obsoleted since devices in 2.0 read and write data
with explicit endianness, and reversing the byte-order of all accesses in a
memory-space often was incorrect.
Previous - Up - Next