I/O Ports and I/O Memory

Every peripheral device is controlled by writing and reading its registers.

Most of the time a device has several registers.

They are accessed at consecutive addresses, either in the memory address space or in the I/O address space.

At the hardware level, there is no conceptual difference between memory regions and I/O regions.


Allocating I/O memory

int check_mem_region(unsigned long start, unsigned long len);

void request_mem_region(unsigned long start, unsigned long len, char *name);

void release_mem_region(unsigned long start, unsigned long len);


void request_mem_region(unsigned long start, unsigned long len, char *name);
將起始地址為 [start, start+len-1] 的資源插入 iomem_resource 中。
參數 start 是 I/O 內存資源的起始物理地址(是CPU的RAM物理地址空間中的物理地址),參數len指定I/O內存資源的大小。

注:
叫用 request_mem_region() 不是必須的,但是建議使用。
該函數的任務是檢查申請的資源是否可用,如果可用則申請成功,並標誌為已經使用,其他驅動想再申請該資源時就會失敗。
arrow
arrow
    全站熱搜

    BB 發表在 痞客邦 留言(0) 人氣()