diff options
Diffstat (limited to 'hw/xfree86')
-rw-r--r-- | hw/xfree86/loader/loader.c | 163 | ||||
-rw-r--r-- | hw/xfree86/loader/loader.h | 7 |
2 files changed, 0 insertions, 170 deletions
diff --git a/hw/xfree86/loader/loader.c b/hw/xfree86/loader/loader.c index 49546ec81..05df28103 100644 --- a/hw/xfree86/loader/loader.c +++ b/hw/xfree86/loader/loader.c @@ -367,169 +367,6 @@ _GetModuleType(int fd, long offset) return LD_ELFDLOBJECT; } -static int offsetbias = 0; /* offset into archive */ - -/* - * _LoaderFileToMem() loads the contents of a file into memory using - * the most efficient method for a platform. - */ -void * -_LoaderFileToMem(int fd, unsigned long offset, int size, char *label) -{ -#ifdef UseMMAP - unsigned long ret; - -# ifdef MmapPageAlign - unsigned long pagesize; - unsigned long new_size; - unsigned long new_off; - unsigned long new_off_bias; -# endif -# define MMAP_PROT (PROT_READ|PROT_WRITE|PROT_EXEC) - -# ifdef DEBUGMEM - ErrorF("_LoaderFileToMem(%d,%u(%u),%d,%s)", fd, offset, offsetbias, size, - label); -# endif -# ifdef MmapPageAlign - pagesize = getpagesize(); - new_size = (size + pagesize - 1) / pagesize; - new_size *= pagesize; - new_off = (offset + offsetbias) / pagesize; - new_off *= pagesize; - new_off_bias = (offset + offsetbias) - new_off; - if ((new_off_bias + size) > new_size) - new_size += pagesize; - ret = (unsigned long)mmap(0, new_size, MMAP_PROT, MAP_PRIVATE -# ifdef __amd64__ - | MAP_32BIT -# endif - , fd, new_off); - if (ret == -1) - FatalError("mmap() failed: %s\n", strerror(errno)); - return (void *)(ret + new_off_bias); -# else - ret = (unsigned long)mmap(0, size, MMAP_PROT, MAP_PRIVATE -# ifdef __amd64__ - | MAP_32BIT -# endif - , fd, offset + offsetbias); - if (ret == -1) - FatalError("mmap() failed: %s\n", strerror(errno)); - return (void *)ret; -# endif -#else - char *ptr; - -# ifdef DEBUGMEM - ErrorF("_LoaderFileToMem(%d,%u(%u),%d,%s)", fd, offset, offsetbias, size, - label); -# endif - - if (size == 0) { -# ifdef DEBUGMEM - ErrorF("=NULL\n", ptr); -# endif - return NULL; - } -# ifndef __UNIXOS2__ - if ((ptr = xf86loadercalloc(size, 1)) == NULL) - FatalError("_LoaderFileToMem() malloc failed\n"); -# else - if ((ptr = os2ldcalloc(size, 1)) == NULL) - FatalError("_LoaderFileToMem() malloc failed\n"); -# endif -# if defined(linux) && defined(__ia64__) - { - unsigned long page_size = getpagesize(); - unsigned long round; - - round = (unsigned long)ptr & (page_size - 1); - mprotect(ptr - round, - (size + round + page_size - 1) & ~(page_size - 1), - PROT_READ | PROT_WRITE | PROT_EXEC); - } -# endif - - if (lseek(fd, offset + offsetbias, SEEK_SET) < 0) - FatalError("\n_LoaderFileToMem() lseek() failed: %s\n", - strerror(errno)); - - if (read(fd, ptr, size) != size) - FatalError("\n_LoaderFileToMem() read() failed: %s\n", - strerror(errno)); - -# if (defined(linux) || defined(__NetBSD__) || defined(__OpenBSD__) \ - || defined(__FreeBSD__)) && defined(__powerpc__) - /* - * Keep the instruction cache in sync with changes in the - * main memory. - */ - { - int i; - - for (i = 0; i < size; i += 16) - ppc_flush_icache(ptr + i); - ppc_flush_icache(ptr + size - 1); - } -# endif - -# ifdef DEBUGMEM - ErrorF("=%lx\n", ptr); -# endif - - return (void *)ptr; -#endif -} - -/* - * _LoaderFreeFileMem() free the memory in which a file was loaded. - */ -void -_LoaderFreeFileMem(void *addr, int size) -{ -#if defined (UseMMAP) && defined (MmapPageAlign) - unsigned long pagesize = getpagesize(); - memType i_addr = (memType) addr; - unsigned long new_size; -#endif -#ifdef DEBUGMEM - ErrorF("_LoaderFreeFileMem(%x,%d)\n", addr, size); -#endif -#ifdef UseMMAP -# if defined (MmapPageAlign) - i_addr /= pagesize; - i_addr *= pagesize; - new_size = (size + pagesize - 1) / pagesize; - new_size *= pagesize; - if (((memType) addr - i_addr + size) > new_size) - new_size += pagesize; - munmap((void *)i_addr, new_size); -# else - munmap((void *)addr, size); -# endif -#else - if (size == 0) - return; - - xf86loaderfree(addr); -#endif - - return; -} - -int -_LoaderFileRead(int fd, unsigned int offset, void *buf, int size) -{ - if (lseek(fd, offset + offsetbias, SEEK_SET) < 0) - FatalError("_LoaderFileRead() lseek() failed: %s\n", strerror(errno)); - - if (read(fd, buf, size) != size) - FatalError("_LoaderFileRead() read() failed: %s\n", strerror(errno)); - - return size; -} - static loaderPtr listHead = (loaderPtr) 0; static loaderPtr diff --git a/hw/xfree86/loader/loader.h b/hw/xfree86/loader/loader.h index 63e6715fa..193adddda 100644 --- a/hw/xfree86/loader/loader.h +++ b/hw/xfree86/loader/loader.h @@ -236,13 +236,6 @@ int LoaderOpen(const char *, const char *, int, int *, int *, int *, int); int LoaderHandleOpen(int); /* - * File interface functions - */ -void *_LoaderFileToMem(int fd, unsigned long offset, int size, char *label); -void _LoaderFreeFileMem(void *addr, int size); -int _LoaderFileRead(int fd, unsigned int offset, void *addr, int size); - -/* * object to name lookup routines */ char *_LoaderHandleToName(int handle); |