File radeontool-1.5.diff of Package radeontool
--- radeontool.c
+++ radeontool.c
@@ -21,7 +21,6 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/mman.h>
-#include <asm/page.h>
#include "radeon_reg.h"
@@ -30,7 +29,7 @@
/* *radeon_cntl_mem is mapped to the actual device's memory mapped control area. */
/* Not the address but what it points to is volatile. */
-unsigned char * volatile radeon_cntl_mem;
+volatile unsigned char * radeon_cntl_mem;
static void fatal(char *why)
{
@@ -47,7 +46,7 @@
printf("internal error\n");
exit(-2);
};
- value = *(unsigned long * volatile)(radeon_cntl_mem+offset);
+ value = *(volatile unsigned long *)(radeon_cntl_mem+offset);
if(debug)
printf("%08lx\n",value);
return value;
@@ -60,7 +59,7 @@
printf("internal error\n");
exit(-2);
};
- *(unsigned long * volatile)(radeon_cntl_mem+offset) = value;
+ *(volatile unsigned long *)(radeon_cntl_mem+offset) = value;
}
static void usage(void)
@@ -83,10 +82,10 @@
/* with /dev/mem, then I could write this whole program in perl, */
/* but sadly this is only the size of physical RAM. If you */
/* want to be truely bad and poke into device memory you have to mmap() */
-static unsigned char * map_devince_memory(unsigned int base,unsigned int length)
+static volatile unsigned char * map_device_memory(unsigned int base,unsigned int length)
{
int mem_fd;
- unsigned char *device_mem;
+ volatile unsigned char *device_mem;
/* open /dev/mem */
if ((mem_fd = open("/dev/mem", O_RDWR) ) < 0) {
@@ -94,12 +93,12 @@
}
/* mmap graphics memory */
- if ((device_mem = malloc(length + (PAGE_SIZE-1))) == NULL) {
+ if ((device_mem = malloc(length + (getpagesize()-1))) == NULL) {
fatal("allocation error \n");
}
- if ((unsigned long)device_mem % PAGE_SIZE)
- device_mem += PAGE_SIZE - ((unsigned long)device_mem % PAGE_SIZE);
- device_mem = (unsigned char *)mmap(
+ if ((unsigned long)device_mem % getpagesize())
+ device_mem += getpagesize() - ((unsigned long)device_mem % getpagesize());
+ device_mem = (volatile unsigned char *)mmap(
(caddr_t)device_mem,
length,
PROT_READ|PROT_WRITE,
@@ -107,9 +106,9 @@
mem_fd,
base
);
- if ((long)device_mem < 0) {
+ if (device_mem == (volatile unsigned char *)-1) {
if(debug)
- fprintf(stderr,"mmap returned %d\n",(int)device_mem);
+ fprintf(stderr,"mmap returned %d\n",(int)(long)device_mem);
fatal("mmap error \n");
}
return device_mem;
@@ -316,7 +315,7 @@
}
if(debug)
printf("Radeon found. Base control address is %x.\n",base);
- radeon_cntl_mem = map_devince_memory(base,0x2000);
+ radeon_cntl_mem = map_device_memory(base,0x2000);
}
int main(int argc,char *argv[])