Wednesday, May 18, 2011

IO mapped io

Since any dynamically-loaded driver module is attached to the existing kernel, any error in the driver will crash the entire system.

Resource allocation for a device is one of the main concerns for device-driver developers.

Resources are:
1. I/O memory
2. IRQs
3. Ports

----------------------------------
The most frequent job of any driver is transferring data between the computer and its external environment.
The external environment consists of external devices.

Three techniques are possible for I/O operations:
1. Programmed I/O
2. Interrupt-driver I/O
3. Direct Memory Access(DMA)

The PIO devices pass the data from the system to device or vice versa in two different ways:
1. I/O port
2. I/O memory mapped

PIO requires the CPU to move data to or from the device as each byte

Tuesday, May 3, 2011

#C_CODE: Endian checker

#include <stdio.h>

int isLittleEndian(void)
{
    unsigned int i = 0x01;
    return (*((unsigned char *)&i));
}

int main(void)
{
    printf("Is the machine little endian: %s\n",
    isLittleEndian()?"YES":"NO");
}

Monday, May 2, 2011

Physical & virtual addresses

Physical addresses refer to the hardware addresses of physical memory.
Virtual addresses refer to the virtual store viewed by the process.

Virtual to physical address mapping is done by Memory Management Unit(MMU)

Virtual space is limited by the size of virtual addresses.

Virtual memory space and physical memory space are different.

Paging is the most common method of memory management:
Virtual space of process is divided into fixed-size pages
Virtual address is composed of page number and page offset.
Physical memory is divided into fixed-size frames
Page in virtual space fits into frame in physical memory.

Mapping of VA to PA is done with a page table.
Each process has an associated page table.

Physical address = Frame number * Page size + Page offset
-----------------------------

Modern systems keep more than one program in memory at a time.
All these programs together require more memory than what is visible.
Use a part of disk and make it look like memory - This is called virtual memory.