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 c-d.hailfinger.devel.2006@gmx.net
--- 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 <stdint.h>
+/* 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;
On 9/27/10 3:59 PM, Carl-Daniel Hailfinger wrote:
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 c-d.hailfinger.devel.2006@gmx.net
Thanks!
Which reminds me, the DirectHW repository should be made public.
I'll set up a separate repository, unless someone feels this should go into coreboot/util
Stefan