2010年2月24日 星期三

對I/O memory region寫值

Q: 假設有一個I/O addr和一個value,請說明將value寫進addr的步驟?

A:用 check_mem_region(mem_addr, mem_size) 函数来检查该内存地址有没有被用到, 可以用的话调用函数 request_mem_region(mem_addr, mem_size, "设备名称") 申请该内存,成功的话, 调用 writeb(values, mem_addr),或者 writew(values, mem_addr),writel(values, mem_addr), 来在 mem_addr 地址 写入 value 值,三个函数分别为写入 8位,16位和32位的值。 最后需要调用 release_mem_region(mem_addr, mem_size) 函数来…

I/O Resource Management

Functions (Detailed Description)

struct resource * request_region (unsigned long start, unsigned long n, const char *name)

Allocate I/O port region.
struct resource * request_mem_region (unsigned long start, unsigned long n, const char *name)

Allocate I/O memory region.
void release_region (unsigned long start, unsigned long n)

Release I/O port region.
void release_mem_region (unsigned long start, unsigned long n)

Release I/O memory region.
int release_resource (struct resource *res)

Release any resource.
int check_region (unsigned long start, unsigned long n)

Check I/O port region availability.
int check_mem_region (unsigned long start, unsigned long n)

Check I/O memory region availability.
void * ioremap (unsigned long phys_addr, unsigned long size)

Remap I/O memory into kernel address space.
void * ioremap_nocache (unsigned long phys_addr, unsigned long size)

Remap I/O memory into kernel address space (no cache).
void iounmap (void *addr)

Unmap I/O memory from kernel address space.

沒有留言:

張貼留言