Re: PCI device driver question
- From: "elliotng.ee@xxxxxxxxx" <elliotng.ee@xxxxxxxxx>
- Date: 26 Dec 2006 10:38:35 -0800
Never mind, I found out that writel/readl are kernel functions. We will
need to emulate the kernel functions.
New code (just want to verify that it is correct):
......
// Kernel function emulation
#define writel(data, addr) *(volatile int*) (addr)=(data)
#define readl(addr) *(volatile int*)(addr)
int main(){
int memory;
unsigned int data;
unsigned char *address;
memory = open("/dev/mem", O_RDWR);
address = mmap((void*)0, 0x1fffffff, PORT_WRITE | PORT_READ, MAP_FIXED,
memory, 0x20000000);
data = readl(address);
printf("Data: %x", data);
writel(0xFF, address);
data = readl(address);
printf("Data: %x", data);
munmap((void*)address, 0x1fffffff);
close(memory);
return 0;
}
.
- References:
- PCI device driver question
- From: elliotng.ee@xxxxxxxxx
- Re: PCI device driver question
- From:
- Re: PCI device driver question
- From: elliotng.ee@xxxxxxxxx
- Re: PCI device driver question
- From: elliotng.ee@xxxxxxxxx
- Re: PCI device driver question
- From: gil_hamilton@xxxxxxxxxxx
- Re: PCI device driver question
- From: elliotng.ee@xxxxxxxxx
- PCI device driver question
- Prev by Date: Re: union variable error(storage size isn't known)
- Next by Date: Re: open problem
- Previous by thread: Re: PCI device driver question
- Next by thread: disabling sockets for running processes
- Index(es):
Relevant Pages
|