From patchwork Mon Sep 27 13:59:20 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: {PATCH] DirectHW: allow zero mapping Date: Mon, 27 Sep 2010 13:59:20 -0000 From: Carl-Daniel Hailfinger X-Patchwork-Id: 1992 Message-Id: <4CA0A338.6050008@gmx.net> To: Coreboot , flashrom , Stefan Reinauer Add a variant of map_physical to DirectHW so a mapped address of NULL is not treated as error anymore. Untested because I lack any machines with Mac OS X Signed-off-by: Carl-Daniel Hailfinger --- DirectIO/darwinio.c~ 2010-09-27 15:51:02.000000000 +0200 +++ DirectIO/darwinio.c 2010-09-27 15:53:12.000000000 +0200 @@ -237,7 +237,7 @@ return darwin_init(); } -void *map_physical(unsigned long phys_addr, int len) +void *map_physical_common(unsigned long phys_addr, int len, void *errorpointer) { kern_return_t err; vm_address_t addr; @@ -276,7 +276,7 @@ case 0x2cd: printf("Device not Open.\n"); break; } - return NULL; + return errorpointer; } err = IOConnectMapMemory(connect, 0, mach_task_self(), @@ -299,7 +299,7 @@ case 0x2cd: printf("Device not Open.\n"); break; } - return NULL; + return errorpointer; } #ifdef DEBUG @@ -309,6 +309,16 @@ return (void *)addr; } +void *map_physical(unsigned long phys_addr, int len) +{ + return map_physical_common(phys_addr, len, NULL); +} + +void *map_physical_allowzero(unsigned long phys_addr, int len) +{ + return map_physical_common(phys_addr, len, (void *)-1); +} + void unmap_physical(void *virt_addr __attribute__((unused)), int len __attribute__((unused))) { // Nut'n Honey --- DirectIO/darwinio.h~ 2010-09-27 15:53:42.000000000 +0200 +++ DirectIO/darwinio.h 2010-09-27 15:54:42.000000000 +0200 @@ -21,6 +21,9 @@ #include +/* Version 1.1.0 */ +#define DARWINIO_VERSION 0x010100 + int iopl(int unused); unsigned char inb(unsigned short addr); @@ -32,6 +35,7 @@ void outl(unsigned int val, unsigned short addr); void *map_physical(unsigned long phys_addr, int len); +void *map_physical_allowzero(unsigned long phys_addr, int len); void unmap_physical(void *virt_addr, int len); typedef struct { uint32_t hi, lo; } msr_t;