how to allocate memory for PCNET DMA to receive frames inste

In order to write a process to send and receive ethernet frames, I attempt
to modify pcnet driver so that it does not need to hook under io-net. I
write a program to emulate that io-net does as the following, but I receive
frames which are always all zeros. What’s wrong in my program? Thanks in
advance.

void *alloc(size_t size, int flags)
{
return mmap( 0,
size,
PROT_READ|PROT_WRITE|PROT_NOCACHE,
MAP_PHYS|MAP_ANON|MAP_NOX64K,
NOFD,
0 );
}

npkt_t *alloc_up_npkt(size_t size, void **data)
{
npkt_t *pnpkt = malloc( sizeof(npkt_t) + size );

memset( pnpkt, 0, sizeof(npkt_t) + size );
data = (void) ( pnpkt + 1 );
return pnpkt;
}