Hello everybody, i'm implementing the mmap part of my nodegraph. At the moment i'm actually stuck at a point where the process can't actually access the memory allocation: this is the mmap() function:
static int ng_counter_mmap(dev_t dev, vm_offset_t offset, vm_paddr_t *paddr, int nprot) { if (nprot != VM_PROT_READ) return (-1); *paddr = (vm_paddr_t) (ng_counters.B_array + offset / sizeof(u_int32_t)); return (0); } ng_couters.B_array is u_int32_t *, and the memory is allocated via : counters->B_array = (u_int32_t*) contigmalloc((65536*2*sizeof(u_int32_t))+(65536*2*sizeof(u_int16_t)), M_NG_COUNTER, M_WAITOK | M_ZERO, 0, ~0, PAGE_SIZE, 0); I actually need 2 u_int32_t arrays and two u_int16_t arrays, and need to export all of them at the same time. I don't know if i need anything like vtophys() inside of that. The app in userspace does this: array = (unsigned int *) mmap(0, (65536*2*sizeof(u_int32_t))+(65536*2*sizeof(u_int16_t)), PROT_READ, 0, fd, 0); if(array == (void *) -1){ printf("mmap failed\n"); return -1; } for(i=0; i<65536; i++){ printf("array[%d]=%u\n", i, *(array+i)); } i'm trying to print the values of the first array, but what i get is a lot of: array[484]=4294967295 array[485]=4294967295 array[486]=4294967295 array[487]=4294967295 array[488]=4294967295 array[489]=4294967295 Thanks in advance -- Claudio "thefly" Martella [EMAIL PROTECTED] GNU/PG keyid: 0x8EA95625
signature.asc
Description: Digital signature