From 736e82cd4b6405d3b9b8cb952dade64cf1f8bd8d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= <revol@free.fr>
Date: Thu, 7 Aug 2014 22:20:13 +0200
Subject: [PATCH] Haiku: Fix physical address passing to oss_map_pci_mem()

Avoids sign extension ending in General Protection Exception.
---
 kernel/OS/BeOS/os_beos.c | 6 +++---
 kernel/OS/BeOS/os_beos.h | 7 +++++--
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/kernel/OS/BeOS/os_beos.c b/kernel/OS/BeOS/os_beos.c
index 111e6b1..7bec36e 100644
--- a/kernel/OS/BeOS/os_beos.c
+++ b/kernel/OS/BeOS/os_beos.c
@@ -598,17 +598,17 @@ oss_untimeout (timeout_id_t id)
 
 
 caddr_t
-oss_map_pci_mem (oss_device_t * osdev, int nr, int phaddr, int size)
+oss_map_pci_mem (oss_device_t * osdev, int nr, phys_addr_t phaddr, int size)
 {
   status_t err;
   void *va = NULL;
-  FENTRYA("%p,%d,%u,%d", osdev, nr, phaddr, size);
+  FENTRYA("%p,%d,%Lx,%d", osdev, nr, (uint64)phaddr, size);
   //XXX:align phaddr ?
   /* round up to page size */
   size += B_PAGE_SIZE - 1;
   size &= ~(B_PAGE_SIZE - 1);
   
-  err = map_physical_memory(OSS_PCI_AREA_NAME, (void *)phaddr, size, 
+  err = map_physical_memory(OSS_PCI_AREA_NAME, phaddr, size,
                             B_ANY_KERNEL_BLOCK_ADDRESS, 0, &va);
   if (err < B_OK)
     va = NULL;
diff --git a/kernel/OS/BeOS/os_beos.h b/kernel/OS/BeOS/os_beos.h
index 31fd27e..5ee9deb 100644
--- a/kernel/OS/BeOS/os_beos.h
+++ b/kernel/OS/BeOS/os_beos.h
@@ -101,6 +101,9 @@ typedef uint32 oss_native_word;	/* Same as the address and status register size
 typedef int64 oss_int64_t;		/* Signed 64 bit integer */
 typedef uint64 oss_uint64_t;	/* Unsigned 64 bit integer */
 typedef unsigned long offset_t;
+#ifndef __HAIKU__
+typedef uint32 phys_addr_t;
+#endif
 
 
 extern void oss_cmn_err (int level, char *format, ...);
@@ -413,8 +416,8 @@ typedef struct _oss_poll_event_t oss_poll_event_t;
 extern int detect_trace;
 #define DDB(x) if (detect_trace) x
 
-extern caddr_t oss_map_pci_mem (oss_device_t * osdev, int nr, int phaddr,
-				int size);
+extern caddr_t oss_map_pci_mem (oss_device_t * osdev, int nr,
+				phys_addr_t phaddr, int size);
 extern void oss_unmap_pci_mem (void *addr);
 #define MAP_PCI_IOADDR(osdev, nr, io) (oss_native_word)io
 #define MAP_PCI_MEM(osdev, ix, phaddr, size) 	oss_map_pci_mem(osdev, ix, phaddr, size)
-- 
1.8.3.4

