1
Using memory mapped devices with x86Lib
The x86Lib provides a MemorySystem class to manage memory mapped devices. MemorySystem includes an Add method which allows classes derived from MemoryDevice to be added to the system memory map. The prototype for MemorySystem’s Add method is shown in Listing 1. Listing 1: MemoryDevice Virtual Class 1
void Add( u i n t 3 2 t low , u i n t 3 2 t high , MemoryDevice ∗memdev ) ;
Add allows a device to be mapped to a specific address range. The low parameter specifies the starting address and the high parameter specifies the ending address the device is mapped to. The third parameter *memdev is a pointer to the device to map. The Listing 2 shows how a RAMDevice object and ROMDevice object are mapped using the Add method. Listing 2: MemoryDevice Virtual Class 1 2 3 4 5 6
MemorySystem systemMemory ; RAMDevice ramDevice ; ROMDevice romDevice ; systemMemory . Add( 0 x00000 , 0x0FFFF , ( MemoryDevice ∗)& ramDevice ) ; systemMemory . Add( 0 xF0000 , 0xFFFFF , ( MemoryDevice ∗)& romDevice ) ;
The code in Listing 2 specifies a system that has RAM mapped to address 0x00000 to 0x0FFFF and ROM mapped to address 0xF0000 to 0xFFFFF. A visual representation of the system memory map is shown in Figure 1.
1
0x00000 RAM
0x0FFFF 0x10000
Unused
0xEFFFF 0xF0000 ROM
0xFFFFF
Figure 1: Memory map showing RAMDevice and ROMDevice
2