$NetBSD: patch-aa,v 1.5 2022/08/22 17:23:36 tnn Exp $ --- radeontool.c.orig 2004-02-11 03:50:27.000000000 +0000 +++ radeontool.c @@ -21,12 +21,12 @@ #include #include #include -#include #include "radeon_reg.h" int debug; int skip; +long page_size; /* *radeon_cntl_mem is mapped to the actual device's memory mapped control area. */ /* Not the address but what it points to is volatile. */ @@ -94,11 +94,11 @@ static unsigned char * map_devince_memor } /* mmap graphics memory */ - if ((device_mem = malloc(length + (PAGE_SIZE-1))) == NULL) { + if ((device_mem = malloc(length + (page_size-1))) == NULL) { fatal("allocation error \n"); } - if ((unsigned long)device_mem % PAGE_SIZE) - device_mem += PAGE_SIZE - ((unsigned long)device_mem % PAGE_SIZE); + if ((unsigned long)device_mem % page_size) + device_mem += page_size - ((unsigned long)device_mem % page_size); device_mem = (unsigned char *)mmap( (caddr_t)device_mem, length, @@ -107,7 +107,7 @@ static unsigned char * map_devince_memor mem_fd, base ); - if ((long)device_mem < 0) { + if (device_mem == MAP_FAILED) { if(debug) fprintf(stderr,"mmap returned %d\n",(int)device_mem); fatal("mmap error \n"); @@ -251,7 +251,6 @@ static void map_radeon_cntl_mem(void) } else if(forkrc == 0) { /* if child */ close(pipefd[0]); dup2(pipefd[1],1); /* stdout */ - setenv("PATH","/sbin:/usr/sbin:/bin:/usr/bin",1); execlp("lspci","lspci","-v",NULL); fatal("exec lspci failure\n"); } @@ -307,7 +306,13 @@ We need to look through it to find the s } if(debug) printf("%s",line); - if(strstr(line,"emory") && strstr(line,"K")) { /* if line contains a "Memory" and "K" string */ + if(strstr(line,"emory") && +#ifdef __NetBSD__ + strstr(line,"non-prefetch")) +#else + strstr(line,"K")) +#endif + { /* if line contains a "Memory" and "K" string */ break; } }; @@ -321,6 +326,10 @@ We need to look through it to find the s int main(int argc,char *argv[]) { + if ((page_size = sysconf(_SC_PAGESIZE)) == -1) { + fatal("sysconf failed\n"); + } + if(argc == 1) { map_radeon_cntl_mem(); usage();