Re: PCI device driver question



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;

}

.



Relevant Pages