Using Memory Mapped Devices With X86lib

  • June 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Using Memory Mapped Devices With X86lib as PDF for free.

More details

  • Words: 244
  • Pages: 2
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

Related Documents