[haiku-commits] r38291 - in haiku/trunk/src/system: boot/platform/openfirmware/arch/ppc kernel/arch/ppc

  • From: andreas.faerber@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 21 Aug 2010 00:22:38 +0200 (CEST)

Author: andreasf
Date: 2010-08-21 00:22:38 +0200 (Sat, 21 Aug 2010)
New Revision: 38291
Changeset: http://dev.haiku-os.org/changeset/38291
Ticket: http://dev.haiku-os.org/ticket/5193

Modified:
   haiku/trunk/src/system/boot/platform/openfirmware/arch/ppc/mmu.cpp
   haiku/trunk/src/system/kernel/arch/ppc/arch_vm.cpp
Log:
ppc: Keep memory mappings set up by OpenFirmware

Revert r36886 and fix compilation of insert_virtual_range_to_keep().
The use of void* vs. addr_t matches the surrounding boot loader code
but should probably be revised in favour of addr_t.

create_area() in the kernel wrongly assumed a RAM-backed address range,
which was destined to fail since ranges below the kernel address space
were ignored anyway. Use vm_map_physical_memory() instead.

This fixes a hang once the frame buffer and other resources used by OF
get unmapped. Closes ticket #5193 again.


Modified: haiku/trunk/src/system/boot/platform/openfirmware/arch/ppc/mmu.cpp
===================================================================
--- haiku/trunk/src/system/boot/platform/openfirmware/arch/ppc/mmu.cpp  
2010-08-20 20:42:33 UTC (rev 38290)
+++ haiku/trunk/src/system/boot/platform/openfirmware/arch/ppc/mmu.cpp  
2010-08-20 22:22:38 UTC (rev 38291)
@@ -40,15 +40,13 @@
 extern "C" uint8 _end;
 
 
-#if 0
 static status_t
 insert_virtual_range_to_keep(void *start, uint32 size)
 {
-       return insert_memory_range(gKernelArgs.arch_args.virtual_ranges_to_keep,
-               gKernelArgs.arch_args.num_virtual_ranges_to_keep,
-               MAX_VIRTUAL_RANGES_TO_KEEP, start, size);
+       return 
insert_address_range(gKernelArgs.arch_args.virtual_ranges_to_keep,
+               &gKernelArgs.arch_args.num_virtual_ranges_to_keep,
+               MAX_VIRTUAL_RANGES_TO_KEEP, (addr_t)start, size);
 }
-#endif
 
 
 static status_t
@@ -297,12 +295,6 @@
 
                // insert range in virtual ranges to keep
 
-// TODO: ATM keeping the ranges doesn't make much sense. The OF usually 
identity
-// maps stuff, which means that RAM will most likely be mapped < 2 GB, which we
-// cannot preserve, since that doesn't lie in the kernel address space. 
Mappings
-// >= 2 GB are probably memory mapped hardware registers or the frame buffer
-// (i.e. non-RAM), which we don't handle correctly ATM.
-#if 0
                if (keepRange) {
                        if (insert_virtual_range_to_keep(map->virtual_address,
                                        map->length) != B_OK) {
@@ -310,7 +302,6 @@
                                        
gKernelArgs.num_virtual_allocated_ranges);
                        }
                }
-#endif
 
                total += map->length;
        }

Modified: haiku/trunk/src/system/kernel/arch/ppc/arch_vm.cpp
===================================================================
--- haiku/trunk/src/system/kernel/arch/ppc/arch_vm.cpp  2010-08-20 20:42:33 UTC 
(rev 38290)
+++ haiku/trunk/src/system/kernel/arch/ppc/arch_vm.cpp  2010-08-20 22:22:38 UTC 
(rev 38291)
@@ -12,6 +12,7 @@
 #include <boot/kernel_args.h>
 
 #include <vm/vm.h>
+#include <vm/VMAddressSpace.h>
 #include <arch/vm.h>
 #include <arch_mmu.h>
 
@@ -117,10 +118,16 @@
                        continue;
                }
 
+               phys_addr_t physicalAddress;
                void *address = (void*)range.start;
-               area_id area = create_area("boot loader reserved area", 
&address,
-                       B_EXACT_ADDRESS, range.size, B_ALREADY_WIRED,
-                       B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA);
+               if (vm_get_page_mapping(VMAddressSpace::KernelID(), range.start,
+                               &physicalAddress) != B_OK)
+                       panic("arch_vm_init_end(): No page mapping for %p\n", 
address);
+               area_id area = 
vm_map_physical_memory(VMAddressSpace::KernelID(),
+                       "boot loader reserved area", &address,
+                       B_EXACT_ADDRESS, range.size,
+                       B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA,
+                       physicalAddress, true);
                if (area < 0) {
                        panic("arch_vm_init_end(): Failed to create area for 
boot loader "
                                "reserved area: %p - %p\n", (void*)range.start,


Other related posts:

  • » [haiku-commits] r38291 - in haiku/trunk/src/system: boot/platform/openfirmware/arch/ppc kernel/arch/ppc - andreas . faerber