* 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. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36573 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
907886143f
commit
3b0c1b5227
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Copyright 2009-2010, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Copyright 2002-2009, Axel Dörfler, axeld@pinc-software.de.
|
||||
* 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 @@ struct VMArea {
|
||||
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 @@ struct VMArea {
|
||||
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 @@ private:
|
||||
};
|
||||
|
||||
|
||||
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
|
||||
|
@ -678,7 +678,7 @@ arch_vm_supports_protection(uint32 protection)
|
||||
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 @@ arch_vm_unset_memory_type(struct VMArea *area)
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -1444,6 +1444,8 @@ vm_map_physical_memory(team_id team, const char* name, void** _address,
|
||||
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 @@ dump_area_struct(VMArea* area, bool mappings)
|
||||
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 @@ vm_set_area_memory_type(area_id id, addr_t physicalBase, uint32 type)
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user