Tuesday 30 April 2013

Memory Mapping

Many of us have heard "Memory mapping" numerous time.

Hardware registers, data buffers are mapped ? Where it is mapped? 

We might have worked on lot of PCI devices with register set used for control, status, data access.

OS with the help of device drivers used to map the register space in device into main memory that is RAM.

Device drivers, kernel code does not have direct access over hardware, they will write or read from the mapped space in RAM. OS has special memory management functions to do this 
(eg: ioremap in linux). OS needs physical Base address to perform this operation which can be obtained from PCI configuration space (BAR- Base Address Register).


   Memory space


Devices are mapped into kernel space. Application are mapped to user space which have their own privilege

But, how data written into RAM (mapped space) is copied to Register space and values updated in hardware register is visible in RAM memory space?

load/store architecture only allows memory to be accessed by load and store operations, and all values for an operation need to be loaded from memory and be present in registers. Following the operation, the result needs to be stored back to memory


  • load To load a value from memory, you copy the data from memory into a register.
  • store To store a value to memory, you copy the data from a register to memory.







                                                 

1 comment:

  1. Nice one, Could you please share some detail about BIOS in computer systems?

    ReplyDelete