[haiku-commits] r36573 - in haiku/trunk: headers/private/kernel/vm src/system/kernel/arch/x86 src/system/kernel/vm

  • From: ingo_weinhold@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 1 May 2010 22:41:57 +0200 (CEST)

Author: bonefish
Date: 2010-05-01 22:41:57 +0200 (Sat, 01 May 2010)
New Revision: 36573
Changeset: http://dev.haiku-os.org/changeset/36573/haiku

Modified:
   haiku/trunk/headers/private/kernel/vm/VMArea.h
   haiku/trunk/src/system/kernel/arch/x86/arch_vm.cpp
   haiku/trunk/src/system/kernel/vm/vm.cpp
Log:
* VMArea: Made memory_type private and added setter and getter methods.
* Don't set the VMArea's memory type in arch_vm_set_memory_type(), but let the
  callers do that.
* vm_set_area_memory_type(): Does nothing, if the memory type doesn't change.



Modified: haiku/trunk/headers/private/kernel/vm/VMArea.h
===================================================================
--- haiku/trunk/headers/private/kernel/vm/VMArea.h      2010-05-01 19:47:39 UTC 
(rev 36572)
+++ haiku/trunk/headers/private/kernel/vm/VMArea.h      2010-05-01 20:41:57 UTC 
(rev 36573)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2009, Ingo Weinhold, ingo_weinhold@xxxxxxx
+ * Copyright 2009-2010, Ingo Weinhold, ingo_weinhold@xxxxxxx
  * Copyright 2002-2009, Axel Dörfler, axeld@xxxxxxxxxxxxxxxxx
  * Distributed under the terms of the MIT License.
  *
@@ -10,6 +10,8 @@
 #define _KERNEL_VM_VM_AREA_H
 
 
+#include <vm_defs.h>
+
 #include <lock.h>
 #include <util/DoublyLinkedList.h>
 #include <util/SinglyLinkedList.h>
@@ -91,8 +93,11 @@
        area_id                                 id;
        uint32                                  protection;
        uint16                                  wiring;
-       uint16                                  memory_type;
 
+private:
+       uint16                                  memory_type;    // >> shifted 
by MEMORY_TYPE_SHIFT
+
+public:
        VMCache*                                cache;
        vint32                                  no_cache_change;
        off_t                                   cache_offset;
@@ -108,6 +113,9 @@
                        addr_t                          Base() const    { 
return fBase; }
                        size_t                          Size() const    { 
return fSize; }
 
+       inline  uint32                          MemoryType() const;
+       inline  void                            SetMemoryType(uint32 
memoryType);
+
                        bool                            ContainsAddress(addr_t 
address) const
                                                                        { 
return address >= fBase
                                                                                
&& address <= fBase + (fSize - 1); }
@@ -204,4 +212,18 @@
 };
 
 
+uint32
+VMArea::MemoryType() const
+{
+       return (uint32)memory_type << MEMORY_TYPE_SHIFT;
+}
+
+
+void
+VMArea::SetMemoryType(uint32 memoryType)
+{
+       memory_type = memoryType >> MEMORY_TYPE_SHIFT;
+}
+
+
 #endif // _KERNEL_VM_VM_AREA_H

Modified: haiku/trunk/src/system/kernel/arch/x86/arch_vm.cpp
===================================================================
--- haiku/trunk/src/system/kernel/arch/x86/arch_vm.cpp  2010-05-01 19:47:39 UTC 
(rev 36572)
+++ haiku/trunk/src/system/kernel/arch/x86/arch_vm.cpp  2010-05-01 20:41:57 UTC 
(rev 36573)
@@ -678,7 +678,7 @@
 void
 arch_vm_unset_memory_type(struct VMArea *area)
 {
-       if (area->memory_type == 0)
+       if (area->MemoryType() == 0)
                return;
 
        remove_memory_type_range(area->id);
@@ -686,9 +686,7 @@
 
 
 status_t
-arch_vm_set_memory_type(struct VMArea *area, addr_t physicalBase,
-       uint32 type)
+arch_vm_set_memory_type(struct VMArea *area, addr_t physicalBase, uint32 type)
 {
-       area->memory_type = type >> MEMORY_TYPE_SHIFT;
        return add_memory_type_range(area->id, physicalBase, area->Size(), 
type);
 }

Modified: haiku/trunk/src/system/kernel/vm/vm.cpp
===================================================================
--- haiku/trunk/src/system/kernel/vm/vm.cpp     2010-05-01 19:47:39 UTC (rev 
36572)
+++ haiku/trunk/src/system/kernel/vm/vm.cpp     2010-05-01 20:41:57 UTC (rev 
36573)
@@ -1444,6 +1444,8 @@
                if (memoryType == 0)
                        memoryType = B_MTR_UC;
 
+               area->SetMemoryType(memoryType);
+
                status = arch_vm_set_memory_type(area, physicalAddress, 
memoryType);
                if (status != B_OK)
                        delete_area(locker.AddressSpace(), area, false);
@@ -3038,7 +3040,7 @@
        kprintf("size:\t\t0x%lx\n", area->Size());
        kprintf("protection:\t0x%lx\n", area->protection);
        kprintf("wiring:\t\t0x%x\n", area->wiring);
-       kprintf("memory_type:\t0x%x\n", area->memory_type);
+       kprintf("memory_type:\t%#" B_PRIx32 "\n", area->MemoryType());
        kprintf("cache:\t\t%p\n", area->cache);
        kprintf("cache_type:\t%s\n", cache_type_to_string(area->cache_type));
        kprintf("cache_offset:\t0x%Lx\n", area->cache_offset);
@@ -4457,7 +4459,19 @@
        if (status != B_OK)
                return status;
 
-       return arch_vm_set_memory_type(area, physicalBase, type);
+       // nothing to do, if the type doesn't change
+       uint32 oldType = area->MemoryType();
+       if (type == oldType)
+               return B_OK;
+
+       // set the physical memory type
+       status_t error = arch_vm_set_memory_type(area, physicalBase, type);
+       if (error != B_OK)
+               return error;
+
+       area->SetMemoryType(type);
+       return B_OK;
+
 }
 
 


Other related posts:

  • » [haiku-commits] r36573 - in haiku/trunk: headers/private/kernel/vm src/system/kernel/arch/x86 src/system/kernel/vm - ingo_weinhold