* First run through the kernel's private parts to use phys_{addr,size}_t
where appropriate.
* Typedef'ed page_num_t to phys_addr_t and used it in more places in
vm_page.{h,cpp}.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36937 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -13,8 +13,8 @@ extern "C" {
|
|||||||
|
|
||||||
void m68k_translation_map_change_asid(vm_translation_map *map);
|
void m68k_translation_map_change_asid(vm_translation_map *map);
|
||||||
|
|
||||||
status_t m68k_map_address_range(addr_t virtualAddress, addr_t physicalAddress,
|
status_t m68k_map_address_range(addr_t virtualAddress,
|
||||||
size_t size);
|
phys_addr_t physicalAddress, size_t size);
|
||||||
void m68k_unmap_address_range(addr_t virtualAddress, size_t size);
|
void m68k_unmap_address_range(addr_t virtualAddress, size_t size);
|
||||||
status_t m68k_remap_address_range(addr_t *virtualAddress, size_t size,
|
status_t m68k_remap_address_range(addr_t *virtualAddress, size_t size,
|
||||||
bool unmap);
|
bool unmap);
|
||||||
|
|||||||
@@ -11,8 +11,8 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
status_t mipsel_map_address_range(addr_t virtualAddress, addr_t physicalAddress,
|
status_t mipsel_map_address_range(addr_t virtualAddress,
|
||||||
size_t size);
|
phys_addr_t physicalAddress, size_t size);
|
||||||
|
|
||||||
void mipsel_unmap_address_range(addr_t virtualAddress, size_t size);
|
void mipsel_unmap_address_range(addr_t virtualAddress, size_t size);
|
||||||
|
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ extern "C" {
|
|||||||
|
|
||||||
void ppc_translation_map_change_asid(VMTranslationMap *map);
|
void ppc_translation_map_change_asid(VMTranslationMap *map);
|
||||||
|
|
||||||
status_t ppc_map_address_range(addr_t virtualAddress, addr_t physicalAddress,
|
status_t ppc_map_address_range(addr_t virtualAddress,
|
||||||
size_t size);
|
phys_addr_t physicalAddress, size_t size);
|
||||||
void ppc_unmap_address_range(addr_t virtualAddress, size_t size);
|
void ppc_unmap_address_range(addr_t virtualAddress, size_t size);
|
||||||
status_t ppc_remap_address_range(addr_t *virtualAddress, size_t size,
|
status_t ppc_remap_address_range(addr_t *virtualAddress, size_t size,
|
||||||
bool unmap);
|
bool unmap);
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ void arch_vm_aspace_swap(struct VMAddressSpace *from,
|
|||||||
struct VMAddressSpace *to);
|
struct VMAddressSpace *to);
|
||||||
bool arch_vm_supports_protection(uint32 protection);
|
bool arch_vm_supports_protection(uint32 protection);
|
||||||
|
|
||||||
status_t arch_vm_set_memory_type(struct VMArea *area, addr_t physicalBase,
|
status_t arch_vm_set_memory_type(struct VMArea *area, phys_addr_t physicalBase,
|
||||||
uint32 type);
|
uint32 type);
|
||||||
void arch_vm_unset_memory_type(struct VMArea *area);
|
void arch_vm_unset_memory_type(struct VMArea *area);
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,8 @@ status_t arch_vm_translation_map_init_post_sem(struct kernel_args *args);
|
|||||||
// Quick function to map a page in regardless of map context. Used in VM
|
// Quick function to map a page in regardless of map context. Used in VM
|
||||||
// initialization before most vm data structures exist.
|
// initialization before most vm data structures exist.
|
||||||
status_t arch_vm_translation_map_early_map(struct kernel_args *args, addr_t va,
|
status_t arch_vm_translation_map_early_map(struct kernel_args *args, addr_t va,
|
||||||
addr_t pa, uint8 attributes, addr_t (*get_free_page)(struct kernel_args *));
|
phys_addr_t pa, uint8 attributes,
|
||||||
|
phys_addr_t (*get_free_page)(struct kernel_args *));
|
||||||
|
|
||||||
bool arch_vm_translation_map_is_kernel_page_accessible(addr_t virtualAddress,
|
bool arch_vm_translation_map_is_kernel_page_accessible(addr_t virtualAddress,
|
||||||
uint32 protection);
|
uint32 protection);
|
||||||
|
|||||||
@@ -269,12 +269,12 @@ struct arch_thread;
|
|||||||
void __x86_setup_system_time(uint32 conversionFactor,
|
void __x86_setup_system_time(uint32 conversionFactor,
|
||||||
uint32 conversionFactorNsecs, bool conversionFactorNsecsShift);
|
uint32 conversionFactorNsecs, bool conversionFactorNsecsShift);
|
||||||
void i386_context_switch(struct arch_thread* oldState,
|
void i386_context_switch(struct arch_thread* oldState,
|
||||||
struct arch_thread* newState, addr_t newPageDir);
|
struct arch_thread* newState, uint32 newPageDir);
|
||||||
void x86_userspace_thread_exit(void);
|
void x86_userspace_thread_exit(void);
|
||||||
void x86_end_userspace_thread_exit(void);
|
void x86_end_userspace_thread_exit(void);
|
||||||
void x86_enter_userspace(addr_t entry, addr_t stackTop);
|
void x86_enter_userspace(addr_t entry, addr_t stackTop);
|
||||||
void i386_set_tss_and_kstack(addr_t kstack);
|
void i386_set_tss_and_kstack(addr_t kstack);
|
||||||
void i386_swap_pgdir(addr_t newPageDir);
|
void i386_swap_pgdir(uint32 newPageDir);
|
||||||
void i386_fnsave(void* fpuState);
|
void i386_fnsave(void* fpuState);
|
||||||
void i386_fxsave(void* fpuState);
|
void i386_fxsave(void* fpuState);
|
||||||
void i386_frstor(const void* fpuState);
|
void i386_frstor(const void* fpuState);
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ typedef SinglyLinkedList<VMAreaWiredRange> VMAreaWiredRangeList;
|
|||||||
|
|
||||||
struct VMPageWiringInfo {
|
struct VMPageWiringInfo {
|
||||||
VMAreaWiredRange range;
|
VMAreaWiredRange range;
|
||||||
addr_t physicalAddress;
|
phys_addr_t physicalAddress;
|
||||||
// the actual physical address corresponding to
|
// the actual physical address corresponding to
|
||||||
// the virtual address passed to vm_wire_page()
|
// the virtual address passed to vm_wire_page()
|
||||||
// (i.e. with in-page offset)
|
// (i.e. with in-page offset)
|
||||||
|
|||||||
@@ -33,8 +33,8 @@ struct VMTranslationMap {
|
|||||||
addr_t end) const = 0;
|
addr_t end) const = 0;
|
||||||
|
|
||||||
virtual status_t Map(addr_t virtualAddress,
|
virtual status_t Map(addr_t virtualAddress,
|
||||||
addr_t physicalAddress, uint32 attributes,
|
phys_addr_t physicalAddress,
|
||||||
uint32 memoryType,
|
uint32 attributes, uint32 memoryType,
|
||||||
vm_page_reservation* reservation) = 0;
|
vm_page_reservation* reservation) = 0;
|
||||||
virtual status_t Unmap(addr_t start, addr_t end) = 0;
|
virtual status_t Unmap(addr_t start, addr_t end) = 0;
|
||||||
|
|
||||||
@@ -48,10 +48,10 @@ struct VMTranslationMap {
|
|||||||
bool ignoreTopCachePageFlags);
|
bool ignoreTopCachePageFlags);
|
||||||
|
|
||||||
virtual status_t Query(addr_t virtualAddress,
|
virtual status_t Query(addr_t virtualAddress,
|
||||||
addr_t* _physicalAddress,
|
phys_addr_t* _physicalAddress,
|
||||||
uint32* _flags) = 0;
|
uint32* _flags) = 0;
|
||||||
virtual status_t QueryInterrupt(addr_t virtualAddress,
|
virtual status_t QueryInterrupt(addr_t virtualAddress,
|
||||||
addr_t* _physicalAddress,
|
phys_addr_t* _physicalAddress,
|
||||||
uint32* _flags) = 0;
|
uint32* _flags) = 0;
|
||||||
|
|
||||||
virtual status_t Protect(addr_t base, addr_t top,
|
virtual status_t Protect(addr_t base, addr_t top,
|
||||||
@@ -83,7 +83,7 @@ struct VMPhysicalPageMapper {
|
|||||||
|
|
||||||
// get/put virtual address for physical page -- will be usuable on all CPUs
|
// get/put virtual address for physical page -- will be usuable on all CPUs
|
||||||
// (usually more expensive than the *_current_cpu() versions)
|
// (usually more expensive than the *_current_cpu() versions)
|
||||||
virtual status_t GetPage(addr_t physicalAddress,
|
virtual status_t GetPage(phys_addr_t physicalAddress,
|
||||||
addr_t* _virtualAddress,
|
addr_t* _virtualAddress,
|
||||||
void** _handle) = 0;
|
void** _handle) = 0;
|
||||||
virtual status_t PutPage(addr_t virtualAddress,
|
virtual status_t PutPage(addr_t virtualAddress,
|
||||||
@@ -92,27 +92,29 @@ struct VMPhysicalPageMapper {
|
|||||||
// get/put virtual address for physical page -- thread must be pinned the
|
// get/put virtual address for physical page -- thread must be pinned the
|
||||||
// whole time
|
// whole time
|
||||||
virtual status_t GetPageCurrentCPU(
|
virtual status_t GetPageCurrentCPU(
|
||||||
addr_t physicalAddress,
|
phys_addr_t physicalAddress,
|
||||||
addr_t* _virtualAddress,
|
addr_t* _virtualAddress,
|
||||||
void** _handle) = 0;
|
void** _handle) = 0;
|
||||||
virtual status_t PutPageCurrentCPU(addr_t virtualAddress,
|
virtual status_t PutPageCurrentCPU(addr_t virtualAddress,
|
||||||
void* _handle) = 0;
|
void* _handle) = 0;
|
||||||
|
|
||||||
// get/put virtual address for physical in KDL
|
// get/put virtual address for physical in KDL
|
||||||
virtual status_t GetPageDebug(addr_t physicalAddress,
|
virtual status_t GetPageDebug(phys_addr_t physicalAddress,
|
||||||
addr_t* _virtualAddress,
|
addr_t* _virtualAddress,
|
||||||
void** _handle) = 0;
|
void** _handle) = 0;
|
||||||
virtual status_t PutPageDebug(addr_t virtualAddress,
|
virtual status_t PutPageDebug(addr_t virtualAddress,
|
||||||
void* handle) = 0;
|
void* handle) = 0;
|
||||||
|
|
||||||
// memory operations on pages
|
// memory operations on pages
|
||||||
virtual status_t MemsetPhysical(addr_t address, int value,
|
virtual status_t MemsetPhysical(phys_addr_t address, int value,
|
||||||
size_t length) = 0;
|
phys_size_t length) = 0;
|
||||||
virtual status_t MemcpyFromPhysical(void* to, addr_t from,
|
virtual status_t MemcpyFromPhysical(void* to, phys_addr_t from,
|
||||||
size_t length, bool user) = 0;
|
size_t length, bool user) = 0;
|
||||||
virtual status_t MemcpyToPhysical(addr_t to, const void* from,
|
virtual status_t MemcpyToPhysical(phys_addr_t to,
|
||||||
size_t length, bool user) = 0;
|
const void* from, size_t length,
|
||||||
virtual void MemcpyPhysicalPage(addr_t to, addr_t from) = 0;
|
bool user) = 0;
|
||||||
|
virtual void MemcpyPhysicalPage(phys_addr_t to,
|
||||||
|
phys_addr_t from) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ void forbid_page_faults(void);
|
|||||||
// private kernel only extension (should be moved somewhere else):
|
// private kernel only extension (should be moved somewhere else):
|
||||||
area_id create_area_etc(team_id team, const char *name, void **address,
|
area_id create_area_etc(team_id team, const char *name, void **address,
|
||||||
uint32 addressSpec, uint32 size, uint32 lock, uint32 protection,
|
uint32 addressSpec, uint32 size, uint32 lock, uint32 protection,
|
||||||
addr_t physicalAddress, uint32 flags);
|
phys_addr_t physicalAddress, uint32 flags);
|
||||||
area_id transfer_area(area_id id, void** _address, uint32 addressSpec,
|
area_id transfer_area(area_id id, void** _address, uint32 addressSpec,
|
||||||
team_id target, bool kernel);
|
team_id target, bool kernel);
|
||||||
|
|
||||||
@@ -87,10 +87,10 @@ status_t vm_reserve_address_range(team_id team, void **_address,
|
|||||||
uint32 addressSpec, addr_t size, uint32 flags);
|
uint32 addressSpec, addr_t size, uint32 flags);
|
||||||
area_id vm_create_anonymous_area(team_id team, const char *name, void **address,
|
area_id vm_create_anonymous_area(team_id team, const char *name, void **address,
|
||||||
uint32 addressSpec, addr_t size, uint32 wiring, uint32 protection,
|
uint32 addressSpec, addr_t size, uint32 wiring, uint32 protection,
|
||||||
addr_t physicalAddress, uint32 flags, bool kernel);
|
phys_addr_t physicalAddress, uint32 flags, bool kernel);
|
||||||
area_id vm_map_physical_memory(team_id team, const char *name, void **address,
|
area_id vm_map_physical_memory(team_id team, const char *name, void **address,
|
||||||
uint32 addressSpec, addr_t size, uint32 protection,
|
uint32 addressSpec, addr_t size, uint32 protection,
|
||||||
addr_t physicalAddress, bool alreadyWired);
|
phys_addr_t physicalAddress, bool alreadyWired);
|
||||||
area_id vm_map_physical_memory_vecs(team_id team, const char* name,
|
area_id vm_map_physical_memory_vecs(team_id team, const char* name,
|
||||||
void** _address, uint32 addressSpec, addr_t* _size, uint32 protection,
|
void** _address, uint32 addressSpec, addr_t* _size, uint32 protection,
|
||||||
struct iovec* vecs, uint32 vecCount);
|
struct iovec* vecs, uint32 vecCount);
|
||||||
@@ -108,8 +108,9 @@ area_id vm_clone_area(team_id team, const char *name, void **address,
|
|||||||
area_id sourceArea, bool kernel);
|
area_id sourceArea, bool kernel);
|
||||||
status_t vm_delete_area(team_id teamID, area_id areaID, bool kernel);
|
status_t vm_delete_area(team_id teamID, area_id areaID, bool kernel);
|
||||||
status_t vm_create_vnode_cache(struct vnode *vnode, struct VMCache **_cache);
|
status_t vm_create_vnode_cache(struct vnode *vnode, struct VMCache **_cache);
|
||||||
status_t vm_set_area_memory_type(area_id id, addr_t physicalBase, uint32 type);
|
status_t vm_set_area_memory_type(area_id id, phys_addr_t physicalBase,
|
||||||
status_t vm_get_page_mapping(team_id team, addr_t vaddr, addr_t *paddr);
|
uint32 type);
|
||||||
|
status_t vm_get_page_mapping(team_id team, addr_t vaddr, phys_addr_t *paddr);
|
||||||
bool vm_test_map_modification(struct vm_page *page);
|
bool vm_test_map_modification(struct vm_page *page);
|
||||||
void vm_clear_map_flags(struct vm_page *page, uint32 flags);
|
void vm_clear_map_flags(struct vm_page *page, uint32 flags);
|
||||||
void vm_remove_all_page_mappings(struct vm_page *page);
|
void vm_remove_all_page_mappings(struct vm_page *page);
|
||||||
@@ -119,12 +120,12 @@ status_t vm_wire_page(team_id team, addr_t address, bool writable,
|
|||||||
struct VMPageWiringInfo* info);
|
struct VMPageWiringInfo* info);
|
||||||
void vm_unwire_page(struct VMPageWiringInfo* info);
|
void vm_unwire_page(struct VMPageWiringInfo* info);
|
||||||
|
|
||||||
status_t vm_get_physical_page(addr_t paddr, addr_t* vaddr, void** _handle);
|
status_t vm_get_physical_page(phys_addr_t paddr, addr_t* vaddr, void** _handle);
|
||||||
status_t vm_put_physical_page(addr_t vaddr, void* handle);
|
status_t vm_put_physical_page(addr_t vaddr, void* handle);
|
||||||
status_t vm_get_physical_page_current_cpu(addr_t paddr, addr_t* vaddr,
|
status_t vm_get_physical_page_current_cpu(phys_addr_t paddr, addr_t* vaddr,
|
||||||
void** _handle);
|
void** _handle);
|
||||||
status_t vm_put_physical_page_current_cpu(addr_t vaddr, void* handle);
|
status_t vm_put_physical_page_current_cpu(addr_t vaddr, void* handle);
|
||||||
status_t vm_get_physical_page_debug(addr_t paddr, addr_t* vaddr,
|
status_t vm_get_physical_page_debug(phys_addr_t paddr, addr_t* vaddr,
|
||||||
void** _handle);
|
void** _handle);
|
||||||
status_t vm_put_physical_page_debug(addr_t vaddr, void* handle);
|
status_t vm_put_physical_page_debug(addr_t vaddr, void* handle);
|
||||||
|
|
||||||
@@ -134,12 +135,12 @@ off_t vm_available_memory(void);
|
|||||||
off_t vm_available_not_needed_memory(void);
|
off_t vm_available_not_needed_memory(void);
|
||||||
size_t vm_kernel_address_space_left(void);
|
size_t vm_kernel_address_space_left(void);
|
||||||
|
|
||||||
status_t vm_memset_physical(addr_t address, int value, size_t length);
|
status_t vm_memset_physical(phys_addr_t address, int value, size_t length);
|
||||||
status_t vm_memcpy_from_physical(void* to, addr_t from, size_t length,
|
status_t vm_memcpy_from_physical(void* to, phys_addr_t from, size_t length,
|
||||||
bool user);
|
bool user);
|
||||||
status_t vm_memcpy_to_physical(addr_t to, const void* from, size_t length,
|
status_t vm_memcpy_to_physical(phys_addr_t to, const void* from, size_t length,
|
||||||
bool user);
|
bool user);
|
||||||
void vm_memcpy_physical_page(addr_t to, addr_t from);
|
void vm_memcpy_physical_page(phys_addr_t to, phys_addr_t from);
|
||||||
|
|
||||||
status_t vm_debug_copy_page_memory(team_id teamID, void* unsafeMemory,
|
status_t vm_debug_copy_page_memory(team_id teamID, void* unsafeMemory,
|
||||||
void* buffer, size_t size, bool copyToUnsafe);
|
void* buffer, size_t size, bool copyToUnsafe);
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include <vm/vm.h>
|
#include <vm/vm.h>
|
||||||
|
#include <vm/vm_types.h>
|
||||||
|
|
||||||
|
|
||||||
struct kernel_args;
|
struct kernel_args;
|
||||||
@@ -31,17 +32,17 @@ status_t vm_page_init(struct kernel_args *args);
|
|||||||
status_t vm_page_init_post_area(struct kernel_args *args);
|
status_t vm_page_init_post_area(struct kernel_args *args);
|
||||||
status_t vm_page_init_post_thread(struct kernel_args *args);
|
status_t vm_page_init_post_thread(struct kernel_args *args);
|
||||||
|
|
||||||
status_t vm_mark_page_inuse(addr_t page);
|
status_t vm_mark_page_inuse(page_num_t page);
|
||||||
status_t vm_mark_page_range_inuse(addr_t startPage, addr_t length);
|
status_t vm_mark_page_range_inuse(page_num_t startPage, page_num_t length);
|
||||||
void vm_page_free(struct VMCache *cache, struct vm_page *page);
|
void vm_page_free(struct VMCache *cache, struct vm_page *page);
|
||||||
void vm_page_set_state(struct vm_page *page, int state);
|
void vm_page_set_state(struct vm_page *page, int state);
|
||||||
void vm_page_requeue(struct vm_page *page, bool tail);
|
void vm_page_requeue(struct vm_page *page, bool tail);
|
||||||
|
|
||||||
// get some data about the number of pages in the system
|
// get some data about the number of pages in the system
|
||||||
size_t vm_page_num_pages(void);
|
page_num_t vm_page_num_pages(void);
|
||||||
size_t vm_page_num_free_pages(void);
|
page_num_t vm_page_num_free_pages(void);
|
||||||
size_t vm_page_num_available_pages(void);
|
page_num_t vm_page_num_available_pages(void);
|
||||||
size_t vm_page_num_unused_pages(void);
|
page_num_t vm_page_num_unused_pages(void);
|
||||||
void vm_page_get_stats(system_info *info);
|
void vm_page_get_stats(system_info *info);
|
||||||
|
|
||||||
status_t vm_page_write_modified_page_range(struct VMCache *cache,
|
status_t vm_page_write_modified_page_range(struct VMCache *cache,
|
||||||
@@ -59,10 +60,10 @@ bool vm_page_try_reserve_pages(vm_page_reservation* reservation, uint32 count,
|
|||||||
|
|
||||||
struct vm_page *vm_page_allocate_page(vm_page_reservation* reservation,
|
struct vm_page *vm_page_allocate_page(vm_page_reservation* reservation,
|
||||||
uint32 flags);
|
uint32 flags);
|
||||||
struct vm_page *vm_page_allocate_page_run(uint32 flags, addr_t base,
|
struct vm_page *vm_page_allocate_page_run(uint32 flags, phys_addr_t base,
|
||||||
size_t length, int priority);
|
page_num_t length, int priority);
|
||||||
struct vm_page *vm_page_at_index(int32 index);
|
struct vm_page *vm_page_at_index(int32 index);
|
||||||
struct vm_page *vm_lookup_page(addr_t pageNumber);
|
struct vm_page *vm_lookup_page(page_num_t pageNumber);
|
||||||
bool vm_page_is_dummy(struct vm_page *page);
|
bool vm_page_is_dummy(struct vm_page *page);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ typedef class DoublyLinkedQueue<vm_page_mapping, DoublyLinkedPageLink>
|
|||||||
typedef class DoublyLinkedQueue<vm_page_mapping, DoublyLinkedAreaLink>
|
typedef class DoublyLinkedQueue<vm_page_mapping, DoublyLinkedAreaLink>
|
||||||
VMAreaMappings;
|
VMAreaMappings;
|
||||||
|
|
||||||
typedef uint32 page_num_t;
|
typedef phys_addr_t page_num_t;
|
||||||
|
|
||||||
|
|
||||||
struct VMCacheRef {
|
struct VMCacheRef {
|
||||||
@@ -84,13 +84,15 @@ struct VMCacheRef {
|
|||||||
struct vm_page {
|
struct vm_page {
|
||||||
DoublyLinkedListLink<vm_page> queue_link;
|
DoublyLinkedListLink<vm_page> queue_link;
|
||||||
|
|
||||||
addr_t physical_page_number;
|
page_num_t physical_page_number;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
VMCacheRef* cache_ref;
|
VMCacheRef* cache_ref;
|
||||||
public:
|
public:
|
||||||
page_num_t cache_offset;
|
page_num_t cache_offset;
|
||||||
// in page size units
|
// in page size units
|
||||||
|
// TODO: Only 32 bit on 32 bit platforms!
|
||||||
|
// Introduce a new 64 bit type page_off_t!
|
||||||
|
|
||||||
SplayTreeLink<vm_page> cache_link;
|
SplayTreeLink<vm_page> cache_link;
|
||||||
vm_page* cache_next;
|
vm_page* cache_next;
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ arch_vm_unset_memory_type(VMArea *area)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
arch_vm_set_memory_type(VMArea *area, addr_t physicalBase, uint32 type)
|
arch_vm_set_memory_type(VMArea *area, phys_addr_t physicalBase, uint32 type)
|
||||||
{
|
{
|
||||||
if (type == 0)
|
if (type == 0)
|
||||||
return B_OK;
|
return B_OK;
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ arch_vm_translation_map_init(kernel_args *args,
|
|||||||
|
|
||||||
status_t
|
status_t
|
||||||
arch_vm_translation_map_create_map(bool kernel, VMTranslationMap** _map)
|
arch_vm_translation_map_create_map(bool kernel, VMTranslationMap** _map)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
#warning ARM:WRITEME
|
#warning ARM:WRITEME
|
||||||
}
|
}
|
||||||
@@ -100,8 +100,9 @@ arch_vm_translation_map_init_post_sem(kernel_args *args)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
arch_vm_translation_map_early_map(kernel_args *ka, addr_t virtualAddress, addr_t physicalAddress,
|
arch_vm_translation_map_early_map(kernel_args *ka, addr_t virtualAddress,
|
||||||
uint8 attributes, addr_t (*get_free_page)(kernel_args *))
|
phys_addr_t physicalAddress, uint8 attributes,
|
||||||
|
phys_addr_t (*get_free_page)(kernel_args *))
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
#warning ARM:WRITEME
|
#warning ARM:WRITEME
|
||||||
@@ -114,7 +115,7 @@ arch_vm_translation_map_early_map(kernel_args *ka, addr_t virtualAddress, addr_t
|
|||||||
// XXX currently assumes this translation map is active
|
// XXX currently assumes this translation map is active
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
arch_vm_translation_map_early_query(addr_t va, addr_t *out_physical)
|
arch_vm_translation_map_early_query(addr_t va, phys_addr_t *out_physical)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
#warning ARM:WRITEME
|
#warning ARM:WRITEME
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ GenericVMPhysicalPageMapper::~GenericVMPhysicalPageMapper()
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
GenericVMPhysicalPageMapper::GetPage(addr_t physicalAddress,
|
GenericVMPhysicalPageMapper::GetPage(phys_addr_t physicalAddress,
|
||||||
addr_t* _virtualAddress, void** _handle)
|
addr_t* _virtualAddress, void** _handle)
|
||||||
{
|
{
|
||||||
return generic_get_physical_page(physicalAddress, _virtualAddress, 0);
|
return generic_get_physical_page(physicalAddress, _virtualAddress, 0);
|
||||||
@@ -38,7 +38,7 @@ GenericVMPhysicalPageMapper::PutPage(addr_t virtualAddress, void* handle)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
GenericVMPhysicalPageMapper::GetPageCurrentCPU(addr_t physicalAddress,
|
GenericVMPhysicalPageMapper::GetPageCurrentCPU(phys_addr_t physicalAddress,
|
||||||
addr_t* _virtualAddress, void** _handle)
|
addr_t* _virtualAddress, void** _handle)
|
||||||
{
|
{
|
||||||
// TODO:...
|
// TODO:...
|
||||||
@@ -56,7 +56,7 @@ GenericVMPhysicalPageMapper::PutPageCurrentCPU(addr_t virtualAddress,
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
GenericVMPhysicalPageMapper::GetPageDebug(addr_t physicalAddress,
|
GenericVMPhysicalPageMapper::GetPageDebug(phys_addr_t physicalAddress,
|
||||||
addr_t* _virtualAddress, void** _handle)
|
addr_t* _virtualAddress, void** _handle)
|
||||||
{
|
{
|
||||||
// TODO:...
|
// TODO:...
|
||||||
@@ -73,15 +73,15 @@ GenericVMPhysicalPageMapper::PutPageDebug(addr_t virtualAddress, void* handle)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
GenericVMPhysicalPageMapper::MemsetPhysical(addr_t address, int value,
|
GenericVMPhysicalPageMapper::MemsetPhysical(phys_addr_t address, int value,
|
||||||
size_t length)
|
phys_size_t length)
|
||||||
{
|
{
|
||||||
return generic_vm_memset_physical(address, value, length);
|
return generic_vm_memset_physical(address, value, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
GenericVMPhysicalPageMapper::MemcpyFromPhysical(void* to, addr_t from,
|
GenericVMPhysicalPageMapper::MemcpyFromPhysical(void* to, phys_addr_t from,
|
||||||
size_t length, bool user)
|
size_t length, bool user)
|
||||||
{
|
{
|
||||||
return generic_vm_memcpy_from_physical(to, from, length, user);
|
return generic_vm_memcpy_from_physical(to, from, length, user);
|
||||||
@@ -89,7 +89,7 @@ GenericVMPhysicalPageMapper::MemcpyFromPhysical(void* to, addr_t from,
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
GenericVMPhysicalPageMapper::MemcpyToPhysical(addr_t to, const void* from,
|
GenericVMPhysicalPageMapper::MemcpyToPhysical(phys_addr_t to, const void* from,
|
||||||
size_t length, bool user)
|
size_t length, bool user)
|
||||||
{
|
{
|
||||||
return generic_vm_memcpy_to_physical(to, from, length, user);
|
return generic_vm_memcpy_to_physical(to, from, length, user);
|
||||||
@@ -97,7 +97,8 @@ GenericVMPhysicalPageMapper::MemcpyToPhysical(addr_t to, const void* from,
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
GenericVMPhysicalPageMapper::MemcpyPhysicalPage(addr_t to, addr_t from)
|
GenericVMPhysicalPageMapper::MemcpyPhysicalPage(phys_addr_t to,
|
||||||
|
phys_addr_t from)
|
||||||
{
|
{
|
||||||
generic_vm_memcpy_physical_page(to, from);
|
generic_vm_memcpy_physical_page(to, from);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,32 +13,33 @@ struct GenericVMPhysicalPageMapper : VMPhysicalPageMapper {
|
|||||||
GenericVMPhysicalPageMapper();
|
GenericVMPhysicalPageMapper();
|
||||||
virtual ~GenericVMPhysicalPageMapper();
|
virtual ~GenericVMPhysicalPageMapper();
|
||||||
|
|
||||||
virtual status_t GetPage(addr_t physicalAddress,
|
virtual status_t GetPage(phys_addr_t physicalAddress,
|
||||||
addr_t* _virtualAddress,
|
addr_t* _virtualAddress,
|
||||||
void** _handle);
|
void** _handle);
|
||||||
virtual status_t PutPage(addr_t virtualAddress,
|
virtual status_t PutPage(addr_t virtualAddress,
|
||||||
void* handle);
|
void* handle);
|
||||||
|
|
||||||
virtual status_t GetPageCurrentCPU(
|
virtual status_t GetPageCurrentCPU(
|
||||||
addr_t physicalAddress,
|
phys_addr_t physicalAddress,
|
||||||
addr_t* _virtualAddress,
|
addr_t* _virtualAddress,
|
||||||
void** _handle);
|
void** _handle);
|
||||||
virtual status_t PutPageCurrentCPU(addr_t virtualAddress,
|
virtual status_t PutPageCurrentCPU(addr_t virtualAddress,
|
||||||
void* _handle);
|
void* _handle);
|
||||||
|
|
||||||
virtual status_t GetPageDebug(addr_t physicalAddress,
|
virtual status_t GetPageDebug(phys_addr_t physicalAddress,
|
||||||
addr_t* _virtualAddress,
|
addr_t* _virtualAddress,
|
||||||
void** _handle);
|
void** _handle);
|
||||||
virtual status_t PutPageDebug(addr_t virtualAddress,
|
virtual status_t PutPageDebug(addr_t virtualAddress,
|
||||||
void* handle);
|
void* handle);
|
||||||
|
|
||||||
virtual status_t MemsetPhysical(addr_t address, int value,
|
virtual status_t MemsetPhysical(phys_addr_t address, int value,
|
||||||
size_t length);
|
phys_size_t length);
|
||||||
virtual status_t MemcpyFromPhysical(void* to, addr_t from,
|
virtual status_t MemcpyFromPhysical(void* to, phys_addr_t from,
|
||||||
size_t length, bool user);
|
size_t length, bool user);
|
||||||
virtual status_t MemcpyToPhysical(addr_t to, const void* from,
|
virtual status_t MemcpyToPhysical(phys_addr_t to,
|
||||||
size_t length, bool user);
|
const void* from, size_t length, bool user);
|
||||||
virtual void MemcpyPhysicalPage(addr_t to, addr_t from);
|
virtual void MemcpyPhysicalPage(phys_addr_t to,
|
||||||
|
phys_addr_t from);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ static size_t sIOSpaceChunkSize;
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
generic_get_physical_page(addr_t pa, addr_t *va, uint32 flags)
|
generic_get_physical_page(phys_addr_t pa, addr_t *va, uint32 flags)
|
||||||
{
|
{
|
||||||
int index;
|
int index;
|
||||||
paddr_chunk_desc *replaced_pchunk;
|
paddr_chunk_desc *replaced_pchunk;
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2006-2008, Ingo Weinhold <bonefish@cs.tu-berlin.de>.
|
* Copyright 2006-2010, Ingo Weinhold <ingo_weinhold@gmx.de>.
|
||||||
* All rights reserved. Distributed under the terms of the MIT License.
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _KERNEL_GENERIC_VM_PHYSICAL_PAGE_MAPPER_H
|
#ifndef _KERNEL_GENERIC_VM_PHYSICAL_PAGE_MAPPER_H
|
||||||
#define _KERNEL_GENERIC_VM_PHYSICAL_PAGE_MAPPER_H
|
#define _KERNEL_GENERIC_VM_PHYSICAL_PAGE_MAPPER_H
|
||||||
|
|
||||||
|
|
||||||
#include <boot/kernel_args.h>
|
#include <boot/kernel_args.h>
|
||||||
|
|
||||||
|
|
||||||
@@ -19,9 +19,9 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef status_t (*generic_map_iospace_chunk_func)(addr_t virtualAddress,
|
typedef status_t (*generic_map_iospace_chunk_func)(addr_t virtualAddress,
|
||||||
addr_t physicalAddress, uint32 flags);
|
phys_addr_t physicalAddress, uint32 flags);
|
||||||
|
|
||||||
status_t generic_get_physical_page(addr_t pa, addr_t *va, uint32 flags);
|
status_t generic_get_physical_page(phys_addr_t pa, addr_t *va, uint32 flags);
|
||||||
status_t generic_put_physical_page(addr_t va);
|
status_t generic_put_physical_page(addr_t va);
|
||||||
status_t generic_vm_physical_page_mapper_init(kernel_args *args,
|
status_t generic_vm_physical_page_mapper_init(kernel_args *args,
|
||||||
generic_map_iospace_chunk_func mapIOSpaceChunk, addr_t *ioSpaceBase,
|
generic_map_iospace_chunk_func mapIOSpaceChunk, addr_t *ioSpaceBase,
|
||||||
@@ -33,4 +33,5 @@ status_t generic_vm_physical_page_mapper_init_post_sem(kernel_args *args);
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#endif // _KERNEL_GENERIC_VM_PHYSICAL_PAGE_MAPPER_H
|
#endif // _KERNEL_GENERIC_VM_PHYSICAL_PAGE_MAPPER_H
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2008, Ingo Weinhold <ingo_weinhold@gmx.de>.
|
* Copyright 2008-2010, Ingo Weinhold <ingo_weinhold@gmx.de>.
|
||||||
* All rights reserved. Distributed under the terms of the MIT License.
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "generic_vm_physical_page_ops.h"
|
#include "generic_vm_physical_page_ops.h"
|
||||||
|
|
||||||
#include <vm/vm.h>
|
#include <vm/vm.h>
|
||||||
@@ -10,12 +11,12 @@
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
generic_vm_memset_physical(addr_t address, int value, size_t length)
|
generic_vm_memset_physical(phys_addr_t address, int value, phys_size_t length)
|
||||||
{
|
{
|
||||||
ThreadCPUPinner _(thread_get_current_thread());
|
ThreadCPUPinner _(thread_get_current_thread());
|
||||||
|
|
||||||
while (length > 0) {
|
while (length > 0) {
|
||||||
addr_t pageOffset = address % B_PAGE_SIZE;
|
phys_addr_t pageOffset = address % B_PAGE_SIZE;
|
||||||
addr_t virtualAddress;
|
addr_t virtualAddress;
|
||||||
void* handle;
|
void* handle;
|
||||||
status_t error = vm_get_physical_page_current_cpu(address - pageOffset,
|
status_t error = vm_get_physical_page_current_cpu(address - pageOffset,
|
||||||
@@ -37,11 +38,11 @@ generic_vm_memset_physical(addr_t address, int value, size_t length)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
generic_vm_memcpy_from_physical(void* _to, addr_t from, size_t length,
|
generic_vm_memcpy_from_physical(void* _to, phys_addr_t from, size_t length,
|
||||||
bool user)
|
bool user)
|
||||||
{
|
{
|
||||||
uint8* to = (uint8*)_to;
|
uint8* to = (uint8*)_to;
|
||||||
addr_t pageOffset = from % B_PAGE_SIZE;
|
phys_addr_t pageOffset = from % B_PAGE_SIZE;
|
||||||
|
|
||||||
ThreadCPUPinner _(thread_get_current_thread());
|
ThreadCPUPinner _(thread_get_current_thread());
|
||||||
|
|
||||||
@@ -77,11 +78,11 @@ generic_vm_memcpy_from_physical(void* _to, addr_t from, size_t length,
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
generic_vm_memcpy_to_physical(addr_t to, const void* _from, size_t length,
|
generic_vm_memcpy_to_physical(phys_addr_t to, const void* _from, size_t length,
|
||||||
bool user)
|
bool user)
|
||||||
{
|
{
|
||||||
const uint8* from = (const uint8*)_from;
|
const uint8* from = (const uint8*)_from;
|
||||||
addr_t pageOffset = to % B_PAGE_SIZE;
|
phys_addr_t pageOffset = to % B_PAGE_SIZE;
|
||||||
|
|
||||||
ThreadCPUPinner _(thread_get_current_thread());
|
ThreadCPUPinner _(thread_get_current_thread());
|
||||||
|
|
||||||
@@ -120,7 +121,7 @@ generic_vm_memcpy_to_physical(addr_t to, const void* _from, size_t length,
|
|||||||
be blocking, since we need to call it twice and could thus deadlock.
|
be blocking, since we need to call it twice and could thus deadlock.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
generic_vm_memcpy_physical_page(addr_t to, addr_t from)
|
generic_vm_memcpy_physical_page(phys_addr_t to, phys_addr_t from)
|
||||||
{
|
{
|
||||||
ThreadCPUPinner _(thread_get_current_thread());
|
ThreadCPUPinner _(thread_get_current_thread());
|
||||||
|
|
||||||
|
|||||||
@@ -1,25 +1,29 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2008, Ingo Weinhold <ingo_weinhold@gmx.de>.
|
* Copyright 2008-2010, Ingo Weinhold <ingo_weinhold@gmx.de>.
|
||||||
* All rights reserved. Distributed under the terms of the MIT License.
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef _KERNEL_GENERIC_VM_PHYSICAL_PAGE_OPS_H
|
#ifndef _KERNEL_GENERIC_VM_PHYSICAL_PAGE_OPS_H
|
||||||
#define _KERNEL_GENERIC_VM_PHYSICAL_PAGE_OPS_H
|
#define _KERNEL_GENERIC_VM_PHYSICAL_PAGE_OPS_H
|
||||||
|
|
||||||
|
|
||||||
#include <SupportDefs.h>
|
#include <SupportDefs.h>
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
status_t generic_vm_memset_physical(addr_t address, int value, size_t length);
|
status_t generic_vm_memset_physical(phys_addr_t address, int value,
|
||||||
status_t generic_vm_memcpy_from_physical(void* to, addr_t from, size_t length,
|
phys_size_t length);
|
||||||
bool user);
|
status_t generic_vm_memcpy_from_physical(void* to, phys_addr_t from,
|
||||||
status_t generic_vm_memcpy_to_physical(addr_t to, const void* from,
|
|
||||||
size_t length, bool user);
|
size_t length, bool user);
|
||||||
void generic_vm_memcpy_physical_page(addr_t to, addr_t from);
|
status_t generic_vm_memcpy_to_physical(phys_addr_t to, const void* from,
|
||||||
|
size_t length, bool user);
|
||||||
|
void generic_vm_memcpy_physical_page(phys_addr_t to, phys_addr_t from);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#endif // _KERNEL_GENERIC_VM_PHYSICAL_PAGE_OPS_H
|
#endif // _KERNEL_GENERIC_VM_PHYSICAL_PAGE_OPS_H
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ arch_vm_unset_memory_type(VMArea* area)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
arch_vm_set_memory_type(VMArea* area, addr_t physicalBase, uint32 type)
|
arch_vm_set_memory_type(VMArea* area, phys_addr_t physicalBase, uint32 type)
|
||||||
{
|
{
|
||||||
#warning IMPLEMENT arch_vm_set_memory_type
|
#warning IMPLEMENT arch_vm_set_memory_type
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|||||||
@@ -68,8 +68,8 @@ arch_vm_translation_map_init_post_sem(kernel_args* args)
|
|||||||
|
|
||||||
status_t
|
status_t
|
||||||
arch_vm_translation_map_early_map(kernel_args* ka, addr_t virtualAddress,
|
arch_vm_translation_map_early_map(kernel_args* ka, addr_t virtualAddress,
|
||||||
addr_t physicalAddress, uint8 attributes,
|
phys_addr_t physicalAddress, uint8 attributes,
|
||||||
addr_t (*get_free_page)(kernel_args* ))
|
phys_addr_t (*get_free_page)(kernel_args* ))
|
||||||
{
|
{
|
||||||
#warning IMPLEMENT arch_vm_translation_map_early_map
|
#warning IMPLEMENT arch_vm_translation_map_early_map
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -77,7 +77,7 @@ arch_vm_translation_map_early_map(kernel_args* ka, addr_t virtualAddress,
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
arch_vm_translation_map_early_query(addr_t va, addr_t* out_physical)
|
arch_vm_translation_map_early_query(addr_t va, phys_addr_t* out_physical)
|
||||||
{
|
{
|
||||||
#warning IMPLEMENT arch_vm_translation_map_early_query
|
#warning IMPLEMENT arch_vm_translation_map_early_query
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -97,7 +97,7 @@ arch_vm_translation_map_is_kernel_page_accessible(addr_t virtualAddress,
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
mipsel_map_address_range(addr_t virtualAddress, addr_t physicalAddress,
|
mipsel_map_address_range(addr_t virtualAddress, phys_addr_t physicalAddress,
|
||||||
size_t size)
|
size_t size)
|
||||||
{
|
{
|
||||||
#warning IMPLEMENT mipsel_map_address_range
|
#warning IMPLEMENT mipsel_map_address_range
|
||||||
|
|||||||
@@ -549,7 +549,7 @@ void
|
|||||||
ppc_set_current_cpu_exception_context(struct ppc_cpu_exception_context *context)
|
ppc_set_current_cpu_exception_context(struct ppc_cpu_exception_context *context)
|
||||||
{
|
{
|
||||||
// translate to physical address
|
// translate to physical address
|
||||||
addr_t physicalPage;
|
phys_addr_t physicalPage;
|
||||||
addr_t inPageOffset = (addr_t)context & (B_PAGE_SIZE - 1);
|
addr_t inPageOffset = (addr_t)context & (B_PAGE_SIZE - 1);
|
||||||
status_t error = vm_get_page_mapping(VMAddressSpace::KernelID(),
|
status_t error = vm_get_page_mapping(VMAddressSpace::KernelID(),
|
||||||
(addr_t)context - inPageOffset, &physicalPage);
|
(addr_t)context - inPageOffset, &physicalPage);
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ arch_vm_unset_memory_type(VMArea *area)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
arch_vm_set_memory_type(VMArea *area, addr_t physicalBase, uint32 type)
|
arch_vm_set_memory_type(VMArea *area, phys_addr_t physicalBase, uint32 type)
|
||||||
{
|
{
|
||||||
if (type == 0)
|
if (type == 0)
|
||||||
return B_OK;
|
return B_OK;
|
||||||
|
|||||||
@@ -146,8 +146,8 @@ struct PPCVMTranslationMap : VMTranslationMap {
|
|||||||
addr_t end) const;
|
addr_t end) const;
|
||||||
|
|
||||||
virtual status_t Map(addr_t virtualAddress,
|
virtual status_t Map(addr_t virtualAddress,
|
||||||
addr_t physicalAddress, uint32 attributes,
|
phys_addr_t physicalAddress,
|
||||||
uint32 memoryType,
|
uint32 attributes, uint32 memoryType,
|
||||||
vm_page_reservation* reservation);
|
vm_page_reservation* reservation);
|
||||||
virtual status_t Unmap(addr_t start, addr_t end);
|
virtual status_t Unmap(addr_t start, addr_t end);
|
||||||
|
|
||||||
@@ -155,10 +155,10 @@ struct PPCVMTranslationMap : VMTranslationMap {
|
|||||||
bool updatePageQueue);
|
bool updatePageQueue);
|
||||||
|
|
||||||
virtual status_t Query(addr_t virtualAddress,
|
virtual status_t Query(addr_t virtualAddress,
|
||||||
addr_t* _physicalAddress,
|
phys_addr_t* _physicalAddress,
|
||||||
uint32* _flags);
|
uint32* _flags);
|
||||||
virtual status_t QueryInterrupt(addr_t virtualAddress,
|
virtual status_t QueryInterrupt(addr_t virtualAddress,
|
||||||
addr_t* _physicalAddress,
|
phys_addr_t* _physicalAddress,
|
||||||
uint32* _flags);
|
uint32* _flags);
|
||||||
|
|
||||||
virtual status_t Protect(addr_t base, addr_t top,
|
virtual status_t Protect(addr_t base, addr_t top,
|
||||||
@@ -202,7 +202,7 @@ ppc_translation_map_change_asid(VMTranslationMap *map)
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
fill_page_table_entry(page_table_entry *entry, uint32 virtualSegmentID,
|
fill_page_table_entry(page_table_entry *entry, uint32 virtualSegmentID,
|
||||||
addr_t virtualAddress, addr_t physicalAddress, uint8 protection,
|
addr_t virtualAddress, phys_addr_t physicalAddress, uint8 protection,
|
||||||
bool secondaryHash)
|
bool secondaryHash)
|
||||||
{
|
{
|
||||||
// lower 32 bit - set at once
|
// lower 32 bit - set at once
|
||||||
@@ -289,7 +289,7 @@ PPCVMTranslationMap::RemovePageTableEntry(addr_t virtualAddress)
|
|||||||
|
|
||||||
|
|
||||||
static status_t
|
static status_t
|
||||||
map_iospace_chunk(addr_t va, addr_t pa, uint32 flags)
|
map_iospace_chunk(addr_t va, phys_addr_t pa, uint32 flags)
|
||||||
{
|
{
|
||||||
pa &= ~(B_PAGE_SIZE - 1); // make sure it's page aligned
|
pa &= ~(B_PAGE_SIZE - 1); // make sure it's page aligned
|
||||||
va &= ~(B_PAGE_SIZE - 1); // make sure it's page aligned
|
va &= ~(B_PAGE_SIZE - 1); // make sure it's page aligned
|
||||||
@@ -395,7 +395,7 @@ PPCVMTranslationMap::MaxPagesNeededToMap(addr_t start, addr_t end) const
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
PPCVMTranslationMap::Map(addr_t virtualAddress, addr_t physicalAddress,
|
PPCVMTranslationMap::Map(addr_t virtualAddress, phys_addr_t physicalAddress,
|
||||||
uint32 attributes, uint32 memoryType, vm_page_reservation* reservation)
|
uint32 attributes, uint32 memoryType, vm_page_reservation* reservation)
|
||||||
{
|
{
|
||||||
// TODO: Support memory types!
|
// TODO: Support memory types!
|
||||||
@@ -549,7 +549,8 @@ PPCVMTranslationMap::UnmapPage(VMArea* area, addr_t address,
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
PPCVMTranslationMap::Query(addr_t va, addr_t *_outPhysical, uint32 *_outFlags)
|
PPCVMTranslationMap::Query(addr_t va, phys_addr_t *_outPhysical,
|
||||||
|
uint32 *_outFlags)
|
||||||
{
|
{
|
||||||
page_table_entry *entry;
|
page_table_entry *entry;
|
||||||
|
|
||||||
@@ -579,7 +580,7 @@ PPCVMTranslationMap::Query(addr_t va, addr_t *_outPhysical, uint32 *_outFlags)
|
|||||||
|
|
||||||
status_t
|
status_t
|
||||||
PPCVMTranslationMap::QueryInterrupt(addr_t virtualAddress,
|
PPCVMTranslationMap::QueryInterrupt(addr_t virtualAddress,
|
||||||
addr_t* _physicalAddress, uint32* _flags)
|
phys_addr_t* _physicalAddress, uint32* _flags)
|
||||||
{
|
{
|
||||||
return PPCVMTranslationMap::Query(virtualAddress, _physicalAddress, _flags);
|
return PPCVMTranslationMap::Query(virtualAddress, _physicalAddress, _flags);
|
||||||
}
|
}
|
||||||
@@ -642,7 +643,7 @@ PPCVMTranslationMap::ClearAccessedAndModified(VMArea* area, addr_t address,
|
|||||||
RecursiveLocker locker(fLock);
|
RecursiveLocker locker(fLock);
|
||||||
|
|
||||||
uint32 flags;
|
uint32 flags;
|
||||||
addr_t physicalAddress;
|
phys_addr_t physicalAddress;
|
||||||
if (Query(address, &physicalAddress, &flags) != B_OK
|
if (Query(address, &physicalAddress, &flags) != B_OK
|
||||||
|| (flags & PAGE_PRESENT) == 0) {
|
|| (flags & PAGE_PRESENT) == 0) {
|
||||||
return false;
|
return false;
|
||||||
@@ -690,7 +691,7 @@ PPCVMTranslationMap::Flush()
|
|||||||
|
|
||||||
|
|
||||||
static status_t
|
static status_t
|
||||||
get_physical_page_tmap(addr_t physicalAddress, addr_t *_virtualAddress,
|
get_physical_page_tmap(phys_addr_t physicalAddress, addr_t *_virtualAddress,
|
||||||
void **handle)
|
void **handle)
|
||||||
{
|
{
|
||||||
return generic_get_physical_page(physicalAddress, _virtualAddress, 0);
|
return generic_get_physical_page(physicalAddress, _virtualAddress, 0);
|
||||||
@@ -802,8 +803,9 @@ arch_vm_translation_map_init_post_sem(kernel_args *args)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
arch_vm_translation_map_early_map(kernel_args *ka, addr_t virtualAddress, addr_t physicalAddress,
|
arch_vm_translation_map_early_map(kernel_args *ka, addr_t virtualAddress,
|
||||||
uint8 attributes, addr_t (*get_free_page)(kernel_args *))
|
phys_addr_t physicalAddress, uint8 attributes,
|
||||||
|
phys_addr_t (*get_free_page)(kernel_args *))
|
||||||
{
|
{
|
||||||
uint32 virtualSegmentID = get_sr((void *)virtualAddress) & 0xffffff;
|
uint32 virtualSegmentID = get_sr((void *)virtualAddress) & 0xffffff;
|
||||||
|
|
||||||
@@ -837,7 +839,7 @@ arch_vm_translation_map_early_map(kernel_args *ka, addr_t virtualAddress, addr_t
|
|||||||
// XXX currently assumes this translation map is active
|
// XXX currently assumes this translation map is active
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
arch_vm_translation_map_early_query(addr_t va, addr_t *out_physical)
|
arch_vm_translation_map_early_query(addr_t va, phys_addr_t *out_physical)
|
||||||
{
|
{
|
||||||
//PANIC_UNIMPLEMENTED();
|
//PANIC_UNIMPLEMENTED();
|
||||||
panic("vm_translation_map_quick_query(): not yet implemented\n");
|
panic("vm_translation_map_quick_query(): not yet implemented\n");
|
||||||
@@ -849,7 +851,7 @@ arch_vm_translation_map_early_query(addr_t va, addr_t *out_physical)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
ppc_map_address_range(addr_t virtualAddress, addr_t physicalAddress,
|
ppc_map_address_range(addr_t virtualAddress, phys_addr_t physicalAddress,
|
||||||
size_t size)
|
size_t size)
|
||||||
{
|
{
|
||||||
addr_t virtualEnd = ROUNDUP(virtualAddress + size, B_PAGE_SIZE);
|
addr_t virtualEnd = ROUNDUP(virtualAddress + size, B_PAGE_SIZE);
|
||||||
@@ -913,7 +915,7 @@ ppc_remap_address_range(addr_t *_virtualAddress, size_t size, bool unmap)
|
|||||||
page_table_entry *entry = map->LookupPageTableEntry(virtualAddress);
|
page_table_entry *entry = map->LookupPageTableEntry(virtualAddress);
|
||||||
if (!entry)
|
if (!entry)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
addr_t physicalBase = entry->physical_page_number << 12;
|
phys_addr_t physicalBase = (phys_addr_t)entry->physical_page_number << 12;
|
||||||
|
|
||||||
// map the pages
|
// map the pages
|
||||||
error = ppc_map_address_range((addr_t)newAddress, physicalBase, size);
|
error = ppc_map_address_range((addr_t)newAddress, physicalBase, size);
|
||||||
|
|||||||
@@ -30,8 +30,8 @@ struct X86VMTranslationMap : VMTranslationMap {
|
|||||||
addr_t end) const;
|
addr_t end) const;
|
||||||
|
|
||||||
virtual status_t Map(addr_t virtualAddress,
|
virtual status_t Map(addr_t virtualAddress,
|
||||||
addr_t physicalAddress, uint32 attributes,
|
phys_addr_t physicalAddress,
|
||||||
uint32 memoryType,
|
uint32 attributes, uint32 memoryType,
|
||||||
vm_page_reservation* reservation);
|
vm_page_reservation* reservation);
|
||||||
virtual status_t Unmap(addr_t start, addr_t end);
|
virtual status_t Unmap(addr_t start, addr_t end);
|
||||||
|
|
||||||
@@ -44,10 +44,10 @@ struct X86VMTranslationMap : VMTranslationMap {
|
|||||||
bool ignoreTopCachePageFlags);
|
bool ignoreTopCachePageFlags);
|
||||||
|
|
||||||
virtual status_t Query(addr_t virtualAddress,
|
virtual status_t Query(addr_t virtualAddress,
|
||||||
addr_t* _physicalAddress,
|
phys_addr_t* _physicalAddress,
|
||||||
uint32* _flags);
|
uint32* _flags);
|
||||||
virtual status_t QueryInterrupt(addr_t virtualAddress,
|
virtual status_t QueryInterrupt(addr_t virtualAddress,
|
||||||
addr_t* _physicalAddress,
|
phys_addr_t* _physicalAddress,
|
||||||
uint32* _flags);
|
uint32* _flags);
|
||||||
|
|
||||||
virtual status_t Protect(addr_t base, addr_t top,
|
virtual status_t Protect(addr_t base, addr_t top,
|
||||||
|
|||||||
@@ -394,7 +394,7 @@ setup_for_thread(char *arg, struct thread **_thread, uint32 *_ebp,
|
|||||||
if (id != thread_get_current_thread_id()) {
|
if (id != thread_get_current_thread_id()) {
|
||||||
// switch to the page directory of the new thread to be
|
// switch to the page directory of the new thread to be
|
||||||
// able to follow the stack trace into userland
|
// able to follow the stack trace into userland
|
||||||
addr_t newPageDirectory = (addr_t)x86_next_page_directory(
|
uint32 newPageDirectory = (uint32)x86_next_page_directory(
|
||||||
thread_get_current_thread(), thread);
|
thread_get_current_thread(), thread);
|
||||||
|
|
||||||
if (newPageDirectory != 0) {
|
if (newPageDirectory != 0) {
|
||||||
@@ -601,7 +601,7 @@ stack_trace(int argc, char **argv)
|
|||||||
|
|
||||||
uint32 previousLocations[NUM_PREVIOUS_LOCATIONS];
|
uint32 previousLocations[NUM_PREVIOUS_LOCATIONS];
|
||||||
struct thread *thread = NULL;
|
struct thread *thread = NULL;
|
||||||
addr_t oldPageDirectory = 0;
|
uint32 oldPageDirectory = 0;
|
||||||
uint32 ebp = x86_read_ebp();
|
uint32 ebp = x86_read_ebp();
|
||||||
int32 num = 0, last = 0;
|
int32 num = 0, last = 0;
|
||||||
|
|
||||||
@@ -755,7 +755,7 @@ show_call(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct thread *thread = NULL;
|
struct thread *thread = NULL;
|
||||||
addr_t oldPageDirectory = 0;
|
uint32 oldPageDirectory = 0;
|
||||||
addr_t ebp = x86_read_ebp();
|
addr_t ebp = x86_read_ebp();
|
||||||
int32 argCount = 0;
|
int32 argCount = 0;
|
||||||
|
|
||||||
@@ -929,9 +929,9 @@ cmd_in_context(int argc, char** argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// switch the page directory, if necessary
|
// switch the page directory, if necessary
|
||||||
addr_t oldPageDirectory = 0;
|
uint32 oldPageDirectory = 0;
|
||||||
if (thread != thread_get_current_thread()) {
|
if (thread != thread_get_current_thread()) {
|
||||||
addr_t newPageDirectory = (addr_t)x86_next_page_directory(
|
uint32 newPageDirectory = (uint32)x86_next_page_directory(
|
||||||
thread_get_current_thread(), thread);
|
thread_get_current_thread(), thread);
|
||||||
|
|
||||||
if (newPageDirectory != 0) {
|
if (newPageDirectory != 0) {
|
||||||
|
|||||||
@@ -370,7 +370,7 @@ arch_thread_context_switch(struct thread *from, struct thread *to)
|
|||||||
= cpuData->arch.active_translation_map;
|
= cpuData->arch.active_translation_map;
|
||||||
VMAddressSpace* toAddressSpace = to->team->address_space;
|
VMAddressSpace* toAddressSpace = to->team->address_space;
|
||||||
|
|
||||||
addr_t newPageDirectory;
|
uint32 newPageDirectory;
|
||||||
vm_translation_map_arch_info* toMap;
|
vm_translation_map_arch_info* toMap;
|
||||||
if (toAddressSpace != NULL
|
if (toAddressSpace != NULL
|
||||||
&& (toMap = static_cast<X86VMTranslationMap*>(
|
&& (toMap = static_cast<X86VMTranslationMap*>(
|
||||||
@@ -389,7 +389,7 @@ arch_thread_context_switch(struct thread *from, struct thread *to)
|
|||||||
cpuData->arch.active_translation_map = toMap;
|
cpuData->arch.active_translation_map = toMap;
|
||||||
|
|
||||||
// get the new page directory
|
// get the new page directory
|
||||||
newPageDirectory = (addr_t)toMap->pgdir_phys;
|
newPageDirectory = (uint32)toMap->pgdir_phys;
|
||||||
} else {
|
} else {
|
||||||
newPageDirectory = 0;
|
newPageDirectory = 0;
|
||||||
// this means no change
|
// this means no change
|
||||||
|
|||||||
@@ -740,7 +740,8 @@ arch_vm_unset_memory_type(struct VMArea *area)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
arch_vm_set_memory_type(struct VMArea *area, addr_t physicalBase, uint32 type)
|
arch_vm_set_memory_type(struct VMArea *area, phys_addr_t physicalBase,
|
||||||
|
uint32 type)
|
||||||
{
|
{
|
||||||
return add_memory_type_range(area->id, physicalBase, area->Size(), type);
|
return add_memory_type_range(area->id, physicalBase, area->Size(), type);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -115,9 +115,9 @@ vm_translation_map_arch_info::Delete()
|
|||||||
#if 0
|
#if 0
|
||||||
// this sanity check can be enabled when corruption due to
|
// this sanity check can be enabled when corruption due to
|
||||||
// overwriting an active page directory is suspected
|
// overwriting an active page directory is suspected
|
||||||
addr_t activePageDirectory;
|
uint32 activePageDirectory;
|
||||||
read_cr3(activePageDirectory);
|
read_cr3(activePageDirectory);
|
||||||
if (activePageDirectory == (addr_t)pgdir_phys)
|
if (activePageDirectory == (uint32)pgdir_phys)
|
||||||
panic("deleting a still active page directory\n");
|
panic("deleting a still active page directory\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -133,7 +133,7 @@ vm_translation_map_arch_info::Delete()
|
|||||||
|
|
||||||
//! TODO: currently assumes this translation map is active
|
//! TODO: currently assumes this translation map is active
|
||||||
static status_t
|
static status_t
|
||||||
early_query(addr_t va, addr_t *_physicalAddress)
|
early_query(addr_t va, phys_addr_t *_physicalAddress)
|
||||||
{
|
{
|
||||||
if ((sPageHolePageDir[VADDR_TO_PDENT(va)] & X86_PDE_PRESENT) == 0) {
|
if ((sPageHolePageDir[VADDR_TO_PDENT(va)] & X86_PDE_PRESENT) == 0) {
|
||||||
// no pagetable here
|
// no pagetable here
|
||||||
@@ -183,7 +183,7 @@ memory_type_to_pte_flags(uint32 memoryType)
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
put_page_table_entry_in_pgtable(page_table_entry* entry,
|
put_page_table_entry_in_pgtable(page_table_entry* entry,
|
||||||
addr_t physicalAddress, uint32 attributes, uint32 memoryType,
|
phys_addr_t physicalAddress, uint32 attributes, uint32 memoryType,
|
||||||
bool globalPage)
|
bool globalPage)
|
||||||
{
|
{
|
||||||
page_table_entry page = (physicalAddress & X86_PTE_ADDRESS_MASK)
|
page_table_entry page = (physicalAddress & X86_PTE_ADDRESS_MASK)
|
||||||
@@ -233,7 +233,7 @@ x86_update_all_pgdirs(int index, page_directory_entry e)
|
|||||||
|
|
||||||
void
|
void
|
||||||
x86_put_pgtable_in_pgdir(page_directory_entry *entry,
|
x86_put_pgtable_in_pgdir(page_directory_entry *entry,
|
||||||
addr_t pgtablePhysical, uint32 attributes)
|
phys_addr_t pgtablePhysical, uint32 attributes)
|
||||||
{
|
{
|
||||||
*entry = (pgtablePhysical & X86_PDE_ADDRESS_MASK)
|
*entry = (pgtablePhysical & X86_PDE_ADDRESS_MASK)
|
||||||
| X86_PDE_PRESENT
|
| X86_PDE_PRESENT
|
||||||
@@ -263,7 +263,7 @@ x86_early_prepare_page_tables(page_table_entry* pageTables, addr_t address,
|
|||||||
|
|
||||||
for (size_t i = 0; i < (size / (B_PAGE_SIZE * 1024));
|
for (size_t i = 0; i < (size / (B_PAGE_SIZE * 1024));
|
||||||
i++, virtualTable += B_PAGE_SIZE) {
|
i++, virtualTable += B_PAGE_SIZE) {
|
||||||
addr_t physicalTable = 0;
|
phys_addr_t physicalTable = 0;
|
||||||
early_query(virtualTable, &physicalTable);
|
early_query(virtualTable, &physicalTable);
|
||||||
page_directory_entry* entry = &sPageHolePageDir[
|
page_directory_entry* entry = &sPageHolePageDir[
|
||||||
(address / (B_PAGE_SIZE * 1024)) + i];
|
(address / (B_PAGE_SIZE * 1024)) + i];
|
||||||
@@ -338,7 +338,7 @@ X86VMTranslationMap::Init(bool kernel)
|
|||||||
}
|
}
|
||||||
vm_get_page_mapping(VMAddressSpace::KernelID(),
|
vm_get_page_mapping(VMAddressSpace::KernelID(),
|
||||||
(addr_t)fArchData->pgdir_virt,
|
(addr_t)fArchData->pgdir_virt,
|
||||||
(addr_t*)&fArchData->pgdir_phys);
|
(phys_addr_t*)&fArchData->pgdir_phys);
|
||||||
} else {
|
} else {
|
||||||
// kernel
|
// kernel
|
||||||
// get the physical page mapper
|
// get the physical page mapper
|
||||||
@@ -433,7 +433,7 @@ X86VMTranslationMap::MaxPagesNeededToMap(addr_t start, addr_t end) const
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
X86VMTranslationMap::Map(addr_t va, addr_t pa, uint32 attributes,
|
X86VMTranslationMap::Map(addr_t va, phys_addr_t pa, uint32 attributes,
|
||||||
uint32 memoryType, vm_page_reservation* reservation)
|
uint32 memoryType, vm_page_reservation* reservation)
|
||||||
{
|
{
|
||||||
TRACE("map_tmap: entry pa 0x%lx va 0x%lx\n", pa, va);
|
TRACE("map_tmap: entry pa 0x%lx va 0x%lx\n", pa, va);
|
||||||
@@ -451,7 +451,7 @@ X86VMTranslationMap::Map(addr_t va, addr_t pa, uint32 attributes,
|
|||||||
// check to see if a page table exists for this range
|
// check to see if a page table exists for this range
|
||||||
uint32 index = VADDR_TO_PDENT(va);
|
uint32 index = VADDR_TO_PDENT(va);
|
||||||
if ((pd[index] & X86_PDE_PRESENT) == 0) {
|
if ((pd[index] & X86_PDE_PRESENT) == 0) {
|
||||||
addr_t pgtable;
|
phys_addr_t pgtable;
|
||||||
vm_page *page;
|
vm_page *page;
|
||||||
|
|
||||||
// we need to allocate a pgtable
|
// we need to allocate a pgtable
|
||||||
@@ -460,7 +460,7 @@ X86VMTranslationMap::Map(addr_t va, addr_t pa, uint32 attributes,
|
|||||||
|
|
||||||
DEBUG_PAGE_ACCESS_END(page);
|
DEBUG_PAGE_ACCESS_END(page);
|
||||||
|
|
||||||
pgtable = page->physical_page_number * B_PAGE_SIZE;
|
pgtable = (phys_addr_t)page->physical_page_number * B_PAGE_SIZE;
|
||||||
|
|
||||||
TRACE("map_tmap: asked for free page for pgtable. 0x%lx\n", pgtable);
|
TRACE("map_tmap: asked for free page for pgtable. 0x%lx\n", pgtable);
|
||||||
|
|
||||||
@@ -916,7 +916,7 @@ X86VMTranslationMap::UnmapArea(VMArea* area, bool deletingAddressSpace,
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
X86VMTranslationMap::Query(addr_t va, addr_t *_physical, uint32 *_flags)
|
X86VMTranslationMap::Query(addr_t va, phys_addr_t *_physical, uint32 *_flags)
|
||||||
{
|
{
|
||||||
// default the flags to not present
|
// default the flags to not present
|
||||||
*_flags = 0;
|
*_flags = 0;
|
||||||
@@ -959,7 +959,7 @@ X86VMTranslationMap::Query(addr_t va, addr_t *_physical, uint32 *_flags)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
X86VMTranslationMap::QueryInterrupt(addr_t va, addr_t *_physical,
|
X86VMTranslationMap::QueryInterrupt(addr_t va, phys_addr_t *_physical,
|
||||||
uint32 *_flags)
|
uint32 *_flags)
|
||||||
{
|
{
|
||||||
*_flags = 0;
|
*_flags = 0;
|
||||||
@@ -1356,16 +1356,18 @@ arch_vm_translation_map_init(kernel_args *args,
|
|||||||
|
|
||||||
TRACE("physical memory ranges:\n");
|
TRACE("physical memory ranges:\n");
|
||||||
for (uint32 i = 0; i < args->num_physical_memory_ranges; i++) {
|
for (uint32 i = 0; i < args->num_physical_memory_ranges; i++) {
|
||||||
addr_t start = args->physical_memory_range[i].start;
|
phys_addr_t start = args->physical_memory_range[i].start;
|
||||||
addr_t end = start + args->physical_memory_range[i].size;
|
phys_addr_t end = start + args->physical_memory_range[i].size;
|
||||||
TRACE(" %#10" B_PRIxADDR " - %#10" B_PRIxADDR "\n", start, end);
|
TRACE(" %#10" B_PRIxPHYSADDR " - %#10" B_PRIxPHYSADDR "\n", start,
|
||||||
|
end);
|
||||||
}
|
}
|
||||||
|
|
||||||
TRACE("allocated physical ranges:\n");
|
TRACE("allocated physical ranges:\n");
|
||||||
for (uint32 i = 0; i < args->num_physical_allocated_ranges; i++) {
|
for (uint32 i = 0; i < args->num_physical_allocated_ranges; i++) {
|
||||||
addr_t start = args->physical_allocated_range[i].start;
|
phys_addr_t start = args->physical_allocated_range[i].start;
|
||||||
addr_t end = start + args->physical_allocated_range[i].size;
|
phys_addr_t end = start + args->physical_allocated_range[i].size;
|
||||||
TRACE(" %#10" B_PRIxADDR " - %#10" B_PRIxADDR "\n", start, end);
|
TRACE(" %#10" B_PRIxPHYSADDR " - %#10" B_PRIxPHYSADDR "\n", start,
|
||||||
|
end);
|
||||||
}
|
}
|
||||||
|
|
||||||
TRACE("allocated virtual ranges:\n");
|
TRACE("allocated virtual ranges:\n");
|
||||||
@@ -1444,8 +1446,8 @@ arch_vm_translation_map_init_post_area(kernel_args *args)
|
|||||||
// here, and is later unmapped.
|
// here, and is later unmapped.
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
arch_vm_translation_map_early_map(kernel_args *args, addr_t va, addr_t pa,
|
arch_vm_translation_map_early_map(kernel_args *args, addr_t va, phys_addr_t pa,
|
||||||
uint8 attributes, addr_t (*get_free_page)(kernel_args *))
|
uint8 attributes, phys_addr_t (*get_free_page)(kernel_args *))
|
||||||
{
|
{
|
||||||
int index;
|
int index;
|
||||||
|
|
||||||
@@ -1454,7 +1456,7 @@ arch_vm_translation_map_early_map(kernel_args *args, addr_t va, addr_t pa,
|
|||||||
// check to see if a page table exists for this range
|
// check to see if a page table exists for this range
|
||||||
index = VADDR_TO_PDENT(va);
|
index = VADDR_TO_PDENT(va);
|
||||||
if ((sPageHolePageDir[index] & X86_PDE_PRESENT) == 0) {
|
if ((sPageHolePageDir[index] & X86_PDE_PRESENT) == 0) {
|
||||||
addr_t pgtable;
|
phys_addr_t pgtable;
|
||||||
page_directory_entry *e;
|
page_directory_entry *e;
|
||||||
// we need to allocate a pgtable
|
// we need to allocate a pgtable
|
||||||
pgtable = get_free_page(args);
|
pgtable = get_free_page(args);
|
||||||
@@ -1503,7 +1505,7 @@ arch_vm_translation_map_is_kernel_page_accessible(addr_t virtualAddress,
|
|||||||
{
|
{
|
||||||
// We only trust the kernel team's page directory. So switch to it first.
|
// We only trust the kernel team's page directory. So switch to it first.
|
||||||
// Always set it to make sure the TLBs don't contain obsolete data.
|
// Always set it to make sure the TLBs don't contain obsolete data.
|
||||||
addr_t physicalPageDirectory;
|
uint32 physicalPageDirectory;
|
||||||
read_cr3(physicalPageDirectory);
|
read_cr3(physicalPageDirectory);
|
||||||
write_cr3(sKernelPhysicalPageDirectory);
|
write_cr3(sKernelPhysicalPageDirectory);
|
||||||
|
|
||||||
@@ -1511,7 +1513,7 @@ arch_vm_translation_map_is_kernel_page_accessible(addr_t virtualAddress,
|
|||||||
page_directory_entry pageDirectoryEntry;
|
page_directory_entry pageDirectoryEntry;
|
||||||
uint32 index = VADDR_TO_PDENT(virtualAddress);
|
uint32 index = VADDR_TO_PDENT(virtualAddress);
|
||||||
|
|
||||||
if (physicalPageDirectory == (addr_t)sKernelPhysicalPageDirectory) {
|
if (physicalPageDirectory == (uint32)sKernelPhysicalPageDirectory) {
|
||||||
pageDirectoryEntry = sKernelVirtualPageDirectory[index];
|
pageDirectoryEntry = sKernelVirtualPageDirectory[index];
|
||||||
} else if (sPhysicalPageMapper != NULL) {
|
} else if (sPhysicalPageMapper != NULL) {
|
||||||
// map the original page directory and get the entry
|
// map the original page directory and get the entry
|
||||||
@@ -1549,7 +1551,7 @@ arch_vm_translation_map_is_kernel_page_accessible(addr_t virtualAddress,
|
|||||||
pageTableEntry = 0;
|
pageTableEntry = 0;
|
||||||
|
|
||||||
// switch back to the original page directory
|
// switch back to the original page directory
|
||||||
if (physicalPageDirectory != (addr_t)sKernelPhysicalPageDirectory)
|
if (physicalPageDirectory != (uint32)sKernelPhysicalPageDirectory)
|
||||||
write_cr3(physicalPageDirectory);
|
write_cr3(physicalPageDirectory);
|
||||||
|
|
||||||
if ((pageTableEntry & X86_PTE_PRESENT) == 0)
|
if ((pageTableEntry & X86_PTE_PRESENT) == 0)
|
||||||
|
|||||||
@@ -121,7 +121,8 @@ FUNCTION(x86_write_msr):
|
|||||||
ret
|
ret
|
||||||
FUNCTION_END(x86_write_msr)
|
FUNCTION_END(x86_write_msr)
|
||||||
|
|
||||||
/* void i386_context_switch(struct arch_thread *old_state, struct arch_thread *new_state, addr new_pgdir); */
|
/* void i386_context_switch(struct arch_thread *old_state,
|
||||||
|
struct arch_thread *new_state, uint32 new_pgdir); */
|
||||||
FUNCTION(i386_context_switch):
|
FUNCTION(i386_context_switch):
|
||||||
pusha /* pushes 8 words onto the stack */
|
pusha /* pushes 8 words onto the stack */
|
||||||
movl 36(%esp),%eax /* save old_state->current_stack */
|
movl 36(%esp),%eax /* save old_state->current_stack */
|
||||||
@@ -140,7 +141,7 @@ skip_pgdir_swap:
|
|||||||
ret
|
ret
|
||||||
FUNCTION_END(i386_context_switch)
|
FUNCTION_END(i386_context_switch)
|
||||||
|
|
||||||
/* void i386_swap_pgdir(addr new_pgdir); */
|
/* void i386_swap_pgdir(uint32 new_pgdir); */
|
||||||
FUNCTION(i386_swap_pgdir):
|
FUNCTION(i386_swap_pgdir):
|
||||||
movl 4(%esp),%eax
|
movl 4(%esp),%eax
|
||||||
movl %eax,%cr3
|
movl %eax,%cr3
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ hpet_get_priority()
|
|||||||
// TODO: Fix HPET in SMP mode.
|
// TODO: Fix HPET in SMP mode.
|
||||||
if (smp_get_num_cpus() > 1)
|
if (smp_get_num_cpus() > 1)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// HPET timers, being off-chip, are more expensive to setup
|
// HPET timers, being off-chip, are more expensive to setup
|
||||||
// than the LAPIC.
|
// than the LAPIC.
|
||||||
return 0;
|
return 0;
|
||||||
@@ -84,13 +84,13 @@ hpet_set_hardware_timer(bigtime_t relativeTimeout)
|
|||||||
|
|
||||||
// enable timer interrupt
|
// enable timer interrupt
|
||||||
sTimer->config |= HPET_CONF_TIMER_INT_ENABLE;
|
sTimer->config |= HPET_CONF_TIMER_INT_ENABLE;
|
||||||
|
|
||||||
// TODO:
|
// TODO:
|
||||||
if (relativeTimeout < MIN_TIMEOUT)
|
if (relativeTimeout < MIN_TIMEOUT)
|
||||||
relativeTimeout = MIN_TIMEOUT;
|
relativeTimeout = MIN_TIMEOUT;
|
||||||
|
|
||||||
bigtime_t timerValue = hpet_convert_timeout(relativeTimeout);
|
bigtime_t timerValue = hpet_convert_timeout(relativeTimeout);
|
||||||
|
|
||||||
sTimer->u0.comparator64 = timerValue;
|
sTimer->u0.comparator64 = timerValue;
|
||||||
|
|
||||||
restore_interrupts(state);
|
restore_interrupts(state);
|
||||||
@@ -131,7 +131,7 @@ hpet_set_legacy(bool enabled)
|
|||||||
sHPETRegs->config |= HPET_CONF_MASK_LEGACY;
|
sHPETRegs->config |= HPET_CONF_MASK_LEGACY;
|
||||||
else
|
else
|
||||||
sHPETRegs->config &= ~HPET_CONF_MASK_LEGACY;
|
sHPETRegs->config &= ~HPET_CONF_MASK_LEGACY;
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,7 +141,7 @@ static void
|
|||||||
hpet_dump_timer(volatile struct hpet_timer *timer)
|
hpet_dump_timer(volatile struct hpet_timer *timer)
|
||||||
{
|
{
|
||||||
dprintf("HPET Timer %ld:\n", (timer - sHPETRegs->timer));
|
dprintf("HPET Timer %ld:\n", (timer - sHPETRegs->timer));
|
||||||
|
|
||||||
dprintf("\troutable IRQs: ");
|
dprintf("\troutable IRQs: ");
|
||||||
uint32 interrupts = (uint32)HPET_GET_CAP_TIMER_ROUTE(timer);
|
uint32 interrupts = (uint32)HPET_GET_CAP_TIMER_ROUTE(timer);
|
||||||
for (int i = 0; i < 32; i++) {
|
for (int i = 0; i < 32; i++) {
|
||||||
@@ -157,11 +157,11 @@ hpet_dump_timer(volatile struct hpet_timer *timer)
|
|||||||
dprintf("\tTimer type: %s\n",
|
dprintf("\tTimer type: %s\n",
|
||||||
timer->config & HPET_CONF_TIMER_TYPE ? "Periodic" : "OneShot");
|
timer->config & HPET_CONF_TIMER_TYPE ? "Periodic" : "OneShot");
|
||||||
dprintf("\tInterrupt Type: %s\n",
|
dprintf("\tInterrupt Type: %s\n",
|
||||||
timer->config & HPET_CONF_TIMER_INT_TYPE ? "Level" : "Edge");
|
timer->config & HPET_CONF_TIMER_INT_TYPE ? "Level" : "Edge");
|
||||||
|
|
||||||
dprintf("\tconfigured IRQ: %lld\n",
|
dprintf("\tconfigured IRQ: %lld\n",
|
||||||
HPET_GET_CONF_TIMER_INT_ROUTE(timer));
|
HPET_GET_CONF_TIMER_INT_ROUTE(timer));
|
||||||
|
|
||||||
if (timer->config & HPET_CONF_TIMER_FSB_ENABLE) {
|
if (timer->config & HPET_CONF_TIMER_FSB_ENABLE) {
|
||||||
dprintf("\tfsb_route[0]: 0x%llx\n", timer->fsb_route[0]);
|
dprintf("\tfsb_route[0]: 0x%llx\n", timer->fsb_route[0]);
|
||||||
dprintf("\tfsb_route[1]: 0x%llx\n", timer->fsb_route[1]);
|
dprintf("\tfsb_route[1]: 0x%llx\n", timer->fsb_route[1]);
|
||||||
@@ -174,9 +174,9 @@ static void
|
|||||||
hpet_init_timer(volatile struct hpet_timer *timer)
|
hpet_init_timer(volatile struct hpet_timer *timer)
|
||||||
{
|
{
|
||||||
sTimer = timer;
|
sTimer = timer;
|
||||||
|
|
||||||
uint32 interrupt = 0;
|
uint32 interrupt = 0;
|
||||||
|
|
||||||
sTimer->config |= (interrupt << HPET_CONF_TIMER_INT_ROUTE_SHIFT)
|
sTimer->config |= (interrupt << HPET_CONF_TIMER_INT_ROUTE_SHIFT)
|
||||||
& HPET_CONF_TIMER_INT_ROUTE_MASK;
|
& HPET_CONF_TIMER_INT_ROUTE_MASK;
|
||||||
|
|
||||||
@@ -188,7 +188,7 @@ hpet_init_timer(volatile struct hpet_timer *timer)
|
|||||||
|
|
||||||
// Enable timer
|
// Enable timer
|
||||||
sTimer->config |= HPET_CONF_TIMER_INT_ENABLE;
|
sTimer->config |= HPET_CONF_TIMER_INT_ENABLE;
|
||||||
|
|
||||||
#ifdef TRACE_HPET
|
#ifdef TRACE_HPET
|
||||||
hpet_dump_timer(sTimer);
|
hpet_dump_timer(sTimer);
|
||||||
#endif
|
#endif
|
||||||
@@ -201,12 +201,12 @@ hpet_test()
|
|||||||
uint64 initialValue = sHPETRegs->u0.counter64;
|
uint64 initialValue = sHPETRegs->u0.counter64;
|
||||||
spin(10);
|
spin(10);
|
||||||
uint64 finalValue = sHPETRegs->u0.counter64;
|
uint64 finalValue = sHPETRegs->u0.counter64;
|
||||||
|
|
||||||
if (initialValue == finalValue) {
|
if (initialValue == finalValue) {
|
||||||
dprintf("hpet_test: counter does not increment\n");
|
dprintf("hpet_test: counter does not increment\n");
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -225,7 +225,7 @@ hpet_init(struct kernel_args *args)
|
|||||||
if (vm_map_physical_memory(B_SYSTEM_TEAM, "hpet",
|
if (vm_map_physical_memory(B_SYSTEM_TEAM, "hpet",
|
||||||
(void **)&sHPETRegs, B_EXACT_ADDRESS, B_PAGE_SIZE,
|
(void **)&sHPETRegs, B_EXACT_ADDRESS, B_PAGE_SIZE,
|
||||||
B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA,
|
B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA,
|
||||||
(addr_t)args->arch_args.hpet_phys, true) < B_OK) {
|
(phys_addr_t)args->arch_args.hpet_phys, true) < B_OK) {
|
||||||
// Would it be better to panic here?
|
// Would it be better to panic here?
|
||||||
dprintf("hpet_init: Failed to map memory for the HPET registers.");
|
dprintf("hpet_init: Failed to map memory for the HPET registers.");
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
@@ -241,16 +241,16 @@ hpet_init(struct kernel_args *args)
|
|||||||
status_t status = hpet_set_enabled(false);
|
status_t status = hpet_set_enabled(false);
|
||||||
if (status != B_OK)
|
if (status != B_OK)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
status = hpet_set_legacy(true);
|
status = hpet_set_legacy(true);
|
||||||
if (status != B_OK)
|
if (status != B_OK)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
uint32 numTimers = HPET_GET_NUM_TIMERS(sHPETRegs) + 1;
|
uint32 numTimers = HPET_GET_NUM_TIMERS(sHPETRegs) + 1;
|
||||||
|
|
||||||
TRACE(("hpet_init: HPET supports %lu timers, and is %s bits wide.\n",
|
TRACE(("hpet_init: HPET supports %lu timers, and is %s bits wide.\n",
|
||||||
numTimers, HPET_IS_64BIT(sHPETRegs) ? "64" : "32"));
|
numTimers, HPET_IS_64BIT(sHPETRegs) ? "64" : "32"));
|
||||||
|
|
||||||
TRACE(("hpet_init: configuration: 0x%llx, timer_interrupts: 0x%llx\n",
|
TRACE(("hpet_init: configuration: 0x%llx, timer_interrupts: 0x%llx\n",
|
||||||
sHPETRegs->config, sHPETRegs->interrupt_status));
|
sHPETRegs->config, sHPETRegs->interrupt_status));
|
||||||
|
|
||||||
@@ -258,29 +258,29 @@ hpet_init(struct kernel_args *args)
|
|||||||
dprintf("hpet_init: HPET does not have at least 3 timers. Skipping.\n");
|
dprintf("hpet_init: HPET does not have at least 3 timers. Skipping.\n");
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TRACE_HPET
|
#ifdef TRACE_HPET
|
||||||
for (uint32 c = 0; c < numTimers; c++)
|
for (uint32 c = 0; c < numTimers; c++)
|
||||||
hpet_dump_timer(&sHPETRegs->timer[c]);
|
hpet_dump_timer(&sHPETRegs->timer[c]);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
hpet_init_timer(&sHPETRegs->timer[0]);
|
hpet_init_timer(&sHPETRegs->timer[0]);
|
||||||
|
|
||||||
status = hpet_set_enabled(true);
|
status = hpet_set_enabled(true);
|
||||||
if (status != B_OK)
|
if (status != B_OK)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
#ifdef TEST_HPET
|
#ifdef TEST_HPET
|
||||||
status = hpet_test();
|
status = hpet_test();
|
||||||
if (status != B_OK)
|
if (status != B_OK)
|
||||||
return status;
|
return status;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int32 configuredIRQ = HPET_GET_CONF_TIMER_INT_ROUTE(sTimer);
|
int32 configuredIRQ = HPET_GET_CONF_TIMER_INT_ROUTE(sTimer);
|
||||||
|
|
||||||
install_io_interrupt_handler(configuredIRQ, &hpet_timer_interrupt,
|
install_io_interrupt_handler(configuredIRQ, &hpet_timer_interrupt,
|
||||||
NULL, B_NO_LOCK_VECTOR);
|
NULL, B_NO_LOCK_VECTOR);
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ struct vm_translation_map_arch_info : DeferredDeletable {
|
|||||||
void x86_early_prepare_page_tables(page_table_entry* pageTables, addr_t address,
|
void x86_early_prepare_page_tables(page_table_entry* pageTables, addr_t address,
|
||||||
size_t size);
|
size_t size);
|
||||||
void x86_put_pgtable_in_pgdir(page_directory_entry* entry,
|
void x86_put_pgtable_in_pgdir(page_directory_entry* entry,
|
||||||
addr_t physicalPageTable, uint32 attributes);
|
phys_addr_t physicalPageTable, uint32 attributes);
|
||||||
void x86_update_all_pgdirs(int index, page_directory_entry entry);
|
void x86_update_all_pgdirs(int index, page_directory_entry entry);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ public:
|
|||||||
|
|
||||||
virtual void Delete() = 0;
|
virtual void Delete() = 0;
|
||||||
|
|
||||||
virtual page_table_entry* GetPageTableAt(addr_t physicalAddress) = 0;
|
virtual page_table_entry* GetPageTableAt(phys_addr_t physicalAddress) = 0;
|
||||||
// Must be invoked with thread pinned to current CPU.
|
// Must be invoked with thread pinned to current CPU.
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ public:
|
|||||||
= 0;
|
= 0;
|
||||||
|
|
||||||
virtual page_table_entry* InterruptGetPageTableAt(
|
virtual page_table_entry* InterruptGetPageTableAt(
|
||||||
addr_t physicalAddress) = 0;
|
phys_addr_t physicalAddress) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ struct PhysicalPageSlot {
|
|||||||
PhysicalPageSlotPool* pool;
|
PhysicalPageSlotPool* pool;
|
||||||
addr_t address;
|
addr_t address;
|
||||||
|
|
||||||
inline void Map(addr_t physicalAddress);
|
inline void Map(phys_addr_t physicalAddress);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -131,12 +131,12 @@ public:
|
|||||||
|
|
||||||
virtual void Delete();
|
virtual void Delete();
|
||||||
|
|
||||||
virtual page_table_entry* GetPageTableAt(addr_t physicalAddress);
|
virtual page_table_entry* GetPageTableAt(phys_addr_t physicalAddress);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct page_slot {
|
struct page_slot {
|
||||||
PhysicalPageSlot* slot;
|
PhysicalPageSlot* slot;
|
||||||
addr_t physicalAddress;
|
phys_addr_t physicalAddress;
|
||||||
cpu_mask_t valid;
|
cpu_mask_t valid;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -159,29 +159,30 @@ public:
|
|||||||
TranslationMapPhysicalPageMapper** _mapper);
|
TranslationMapPhysicalPageMapper** _mapper);
|
||||||
|
|
||||||
virtual page_table_entry* InterruptGetPageTableAt(
|
virtual page_table_entry* InterruptGetPageTableAt(
|
||||||
addr_t physicalAddress);
|
phys_addr_t physicalAddress);
|
||||||
|
|
||||||
virtual status_t GetPage(addr_t physicalAddress,
|
virtual status_t GetPage(phys_addr_t physicalAddress,
|
||||||
addr_t* virtualAddress, void** handle);
|
addr_t* virtualAddress, void** handle);
|
||||||
virtual status_t PutPage(addr_t virtualAddress, void* handle);
|
virtual status_t PutPage(addr_t virtualAddress, void* handle);
|
||||||
|
|
||||||
virtual status_t GetPageCurrentCPU(addr_t physicalAddress,
|
virtual status_t GetPageCurrentCPU(phys_addr_t physicalAddress,
|
||||||
addr_t* virtualAddress, void** handle);
|
addr_t* virtualAddress, void** handle);
|
||||||
virtual status_t PutPageCurrentCPU(addr_t virtualAddress,
|
virtual status_t PutPageCurrentCPU(addr_t virtualAddress,
|
||||||
void* handle);
|
void* handle);
|
||||||
|
|
||||||
virtual status_t GetPageDebug(addr_t physicalAddress,
|
virtual status_t GetPageDebug(phys_addr_t physicalAddress,
|
||||||
addr_t* virtualAddress, void** handle);
|
addr_t* virtualAddress, void** handle);
|
||||||
virtual status_t PutPageDebug(addr_t virtualAddress,
|
virtual status_t PutPageDebug(addr_t virtualAddress,
|
||||||
void* handle);
|
void* handle);
|
||||||
|
|
||||||
virtual status_t MemsetPhysical(addr_t address, int value,
|
virtual status_t MemsetPhysical(phys_addr_t address, int value,
|
||||||
size_t length);
|
phys_size_t length);
|
||||||
virtual status_t MemcpyFromPhysical(void* to, addr_t from,
|
virtual status_t MemcpyFromPhysical(void* to, phys_addr_t from,
|
||||||
size_t length, bool user);
|
size_t length, bool user);
|
||||||
virtual status_t MemcpyToPhysical(addr_t to, const void* from,
|
virtual status_t MemcpyToPhysical(phys_addr_t to,
|
||||||
size_t length, bool user);
|
const void* from, size_t length, bool user);
|
||||||
virtual void MemcpyPhysicalPage(addr_t to, addr_t from);
|
virtual void MemcpyPhysicalPage(phys_addr_t to,
|
||||||
|
phys_addr_t from);
|
||||||
|
|
||||||
status_t GetSlot(bool canWait,
|
status_t GetSlot(bool canWait,
|
||||||
PhysicalPageSlot*& slot);
|
PhysicalPageSlot*& slot);
|
||||||
@@ -212,7 +213,7 @@ static LargeMemoryPhysicalPageMapper sPhysicalPageMapper;
|
|||||||
|
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
PhysicalPageSlot::Map(addr_t physicalAddress)
|
PhysicalPageSlot::Map(phys_addr_t physicalAddress)
|
||||||
{
|
{
|
||||||
page_table_entry& pte = pool->pageTable[
|
page_table_entry& pte = pool->pageTable[
|
||||||
(address - pool->virtualBase) / B_PAGE_SIZE];
|
(address - pool->virtualBase) / B_PAGE_SIZE];
|
||||||
@@ -420,7 +421,7 @@ LargeMemoryTranslationMapPhysicalPageMapper::Init()
|
|||||||
return error;
|
return error;
|
||||||
|
|
||||||
// set to invalid physical address, so it won't be used accidentally
|
// set to invalid physical address, so it won't be used accidentally
|
||||||
fSlots[i].physicalAddress = ~(addr_t)0;
|
fSlots[i].physicalAddress = ~(phys_addr_t)0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
@@ -436,7 +437,7 @@ LargeMemoryTranslationMapPhysicalPageMapper::Delete()
|
|||||||
|
|
||||||
page_table_entry*
|
page_table_entry*
|
||||||
LargeMemoryTranslationMapPhysicalPageMapper::GetPageTableAt(
|
LargeMemoryTranslationMapPhysicalPageMapper::GetPageTableAt(
|
||||||
addr_t physicalAddress)
|
phys_addr_t physicalAddress)
|
||||||
{
|
{
|
||||||
ASSERT(physicalAddress % B_PAGE_SIZE == 0);
|
ASSERT(physicalAddress % B_PAGE_SIZE == 0);
|
||||||
|
|
||||||
@@ -580,7 +581,8 @@ LargeMemoryPhysicalPageMapper::CreateTranslationMapPhysicalPageMapper(
|
|||||||
|
|
||||||
|
|
||||||
page_table_entry*
|
page_table_entry*
|
||||||
LargeMemoryPhysicalPageMapper::InterruptGetPageTableAt(addr_t physicalAddress)
|
LargeMemoryPhysicalPageMapper::InterruptGetPageTableAt(
|
||||||
|
phys_addr_t physicalAddress)
|
||||||
{
|
{
|
||||||
ASSERT(physicalAddress % B_PAGE_SIZE == 0);
|
ASSERT(physicalAddress % B_PAGE_SIZE == 0);
|
||||||
|
|
||||||
@@ -591,7 +593,7 @@ LargeMemoryPhysicalPageMapper::InterruptGetPageTableAt(addr_t physicalAddress)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
LargeMemoryPhysicalPageMapper::GetPage(addr_t physicalAddress,
|
LargeMemoryPhysicalPageMapper::GetPage(phys_addr_t physicalAddress,
|
||||||
addr_t* virtualAddress, void** handle)
|
addr_t* virtualAddress, void** handle)
|
||||||
{
|
{
|
||||||
PhysicalPageSlot* slot;
|
PhysicalPageSlot* slot;
|
||||||
@@ -620,7 +622,7 @@ LargeMemoryPhysicalPageMapper::PutPage(addr_t virtualAddress, void* handle)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
LargeMemoryPhysicalPageMapper::GetPageCurrentCPU(addr_t physicalAddress,
|
LargeMemoryPhysicalPageMapper::GetPageCurrentCPU(phys_addr_t physicalAddress,
|
||||||
addr_t* virtualAddress, void** handle)
|
addr_t* virtualAddress, void** handle)
|
||||||
{
|
{
|
||||||
// get a slot from the per-cpu user pool
|
// get a slot from the per-cpu user pool
|
||||||
@@ -649,7 +651,7 @@ LargeMemoryPhysicalPageMapper::PutPageCurrentCPU(addr_t virtualAddress,
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
LargeMemoryPhysicalPageMapper::GetPageDebug(addr_t physicalAddress,
|
LargeMemoryPhysicalPageMapper::GetPageDebug(phys_addr_t physicalAddress,
|
||||||
addr_t* virtualAddress, void** handle)
|
addr_t* virtualAddress, void** handle)
|
||||||
{
|
{
|
||||||
fDebugSlot->Map(physicalAddress);
|
fDebugSlot->Map(physicalAddress);
|
||||||
@@ -668,10 +670,10 @@ LargeMemoryPhysicalPageMapper::PutPageDebug(addr_t virtualAddress, void* handle)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
LargeMemoryPhysicalPageMapper::MemsetPhysical(addr_t address, int value,
|
LargeMemoryPhysicalPageMapper::MemsetPhysical(phys_addr_t address, int value,
|
||||||
size_t length)
|
phys_size_t length)
|
||||||
{
|
{
|
||||||
addr_t pageOffset = address % B_PAGE_SIZE;
|
phys_addr_t pageOffset = address % B_PAGE_SIZE;
|
||||||
|
|
||||||
struct thread* thread = thread_get_current_thread();
|
struct thread* thread = thread_get_current_thread();
|
||||||
ThreadCPUPinner _(thread);
|
ThreadCPUPinner _(thread);
|
||||||
@@ -698,11 +700,11 @@ LargeMemoryPhysicalPageMapper::MemsetPhysical(addr_t address, int value,
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
LargeMemoryPhysicalPageMapper::MemcpyFromPhysical(void* _to, addr_t from,
|
LargeMemoryPhysicalPageMapper::MemcpyFromPhysical(void* _to, phys_addr_t from,
|
||||||
size_t length, bool user)
|
size_t length, bool user)
|
||||||
{
|
{
|
||||||
uint8* to = (uint8*)_to;
|
uint8* to = (uint8*)_to;
|
||||||
addr_t pageOffset = from % B_PAGE_SIZE;
|
phys_addr_t pageOffset = from % B_PAGE_SIZE;
|
||||||
|
|
||||||
struct thread* thread = thread_get_current_thread();
|
struct thread* thread = thread_get_current_thread();
|
||||||
ThreadCPUPinner _(thread);
|
ThreadCPUPinner _(thread);
|
||||||
@@ -738,11 +740,11 @@ LargeMemoryPhysicalPageMapper::MemcpyFromPhysical(void* _to, addr_t from,
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
LargeMemoryPhysicalPageMapper::MemcpyToPhysical(addr_t to, const void* _from,
|
LargeMemoryPhysicalPageMapper::MemcpyToPhysical(phys_addr_t to,
|
||||||
size_t length, bool user)
|
const void* _from, size_t length, bool user)
|
||||||
{
|
{
|
||||||
const uint8* from = (const uint8*)_from;
|
const uint8* from = (const uint8*)_from;
|
||||||
addr_t pageOffset = to % B_PAGE_SIZE;
|
phys_addr_t pageOffset = to % B_PAGE_SIZE;
|
||||||
|
|
||||||
struct thread* thread = thread_get_current_thread();
|
struct thread* thread = thread_get_current_thread();
|
||||||
ThreadCPUPinner _(thread);
|
ThreadCPUPinner _(thread);
|
||||||
@@ -778,7 +780,8 @@ LargeMemoryPhysicalPageMapper::MemcpyToPhysical(addr_t to, const void* _from,
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
LargeMemoryPhysicalPageMapper::MemcpyPhysicalPage(addr_t to, addr_t from)
|
LargeMemoryPhysicalPageMapper::MemcpyPhysicalPage(phys_addr_t to,
|
||||||
|
phys_addr_t from)
|
||||||
{
|
{
|
||||||
struct thread* thread = thread_get_current_thread();
|
struct thread* thread = thread_get_current_thread();
|
||||||
ThreadCPUPinner _(thread);
|
ThreadCPUPinner _(thread);
|
||||||
@@ -888,7 +891,7 @@ LargeMemoryPhysicalPageMapper::_AllocatePool(PhysicalPageSlotPool*& _pool)
|
|||||||
memset(data, 0, B_PAGE_SIZE);
|
memset(data, 0, B_PAGE_SIZE);
|
||||||
|
|
||||||
// get the page table's physical address
|
// get the page table's physical address
|
||||||
addr_t physicalTable;
|
phys_addr_t physicalTable;
|
||||||
X86VMTranslationMap* map = static_cast<X86VMTranslationMap*>(
|
X86VMTranslationMap* map = static_cast<X86VMTranslationMap*>(
|
||||||
VMAddressSpace::Kernel()->TranslationMap());
|
VMAddressSpace::Kernel()->TranslationMap());
|
||||||
uint32 dummyFlags;
|
uint32 dummyFlags;
|
||||||
|
|||||||
+38
-34
@@ -1046,7 +1046,7 @@ vm_reserve_address_range(team_id team, void** _address, uint32 addressSpec,
|
|||||||
area_id
|
area_id
|
||||||
vm_create_anonymous_area(team_id team, const char* name, void** address,
|
vm_create_anonymous_area(team_id team, const char* name, void** address,
|
||||||
uint32 addressSpec, addr_t size, uint32 wiring, uint32 protection,
|
uint32 addressSpec, addr_t size, uint32 wiring, uint32 protection,
|
||||||
addr_t physicalAddress, uint32 flags, bool kernel)
|
phys_addr_t physicalAddress, uint32 flags, bool kernel)
|
||||||
{
|
{
|
||||||
VMArea* area;
|
VMArea* area;
|
||||||
VMCache* cache;
|
VMCache* cache;
|
||||||
@@ -1294,7 +1294,7 @@ vm_create_anonymous_area(team_id team, const char* name, void** address,
|
|||||||
for (addr_t virtualAddress = area->Base();
|
for (addr_t virtualAddress = area->Base();
|
||||||
virtualAddress < area->Base() + (area->Size() - 1);
|
virtualAddress < area->Base() + (area->Size() - 1);
|
||||||
virtualAddress += B_PAGE_SIZE, offset += B_PAGE_SIZE) {
|
virtualAddress += B_PAGE_SIZE, offset += B_PAGE_SIZE) {
|
||||||
addr_t physicalAddress;
|
phys_addr_t physicalAddress;
|
||||||
uint32 flags;
|
uint32 flags;
|
||||||
status = map->Query(virtualAddress, &physicalAddress, &flags);
|
status = map->Query(virtualAddress, &physicalAddress, &flags);
|
||||||
if (status < B_OK) {
|
if (status < B_OK) {
|
||||||
@@ -1326,7 +1326,8 @@ vm_create_anonymous_area(team_id team, const char* name, void** address,
|
|||||||
// We have already allocated our continuous pages run, so we can now
|
// We have already allocated our continuous pages run, so we can now
|
||||||
// just map them in the address space
|
// just map them in the address space
|
||||||
VMTranslationMap* map = addressSpace->TranslationMap();
|
VMTranslationMap* map = addressSpace->TranslationMap();
|
||||||
addr_t physicalAddress = page->physical_page_number * B_PAGE_SIZE;
|
phys_addr_t physicalAddress
|
||||||
|
= (phys_addr_t)page->physical_page_number * B_PAGE_SIZE;
|
||||||
addr_t virtualAddress = area->Base();
|
addr_t virtualAddress = area->Base();
|
||||||
off_t offset = 0;
|
off_t offset = 0;
|
||||||
|
|
||||||
@@ -1371,7 +1372,7 @@ vm_create_anonymous_area(team_id team, const char* name, void** address,
|
|||||||
err1:
|
err1:
|
||||||
if (wiring == B_CONTIGUOUS) {
|
if (wiring == B_CONTIGUOUS) {
|
||||||
// we had reserved the area space upfront...
|
// we had reserved the area space upfront...
|
||||||
addr_t pageNumber = page->physical_page_number;
|
phys_addr_t pageNumber = page->physical_page_number;
|
||||||
int32 i;
|
int32 i;
|
||||||
for (i = size / B_PAGE_SIZE; i-- > 0; pageNumber++) {
|
for (i = size / B_PAGE_SIZE; i-- > 0; pageNumber++) {
|
||||||
page = vm_lookup_page(pageNumber);
|
page = vm_lookup_page(pageNumber);
|
||||||
@@ -1394,8 +1395,8 @@ err0:
|
|||||||
|
|
||||||
area_id
|
area_id
|
||||||
vm_map_physical_memory(team_id team, const char* name, void** _address,
|
vm_map_physical_memory(team_id team, const char* name, void** _address,
|
||||||
uint32 addressSpec, addr_t size, uint32 protection, addr_t physicalAddress,
|
uint32 addressSpec, addr_t size, uint32 protection,
|
||||||
bool alreadyWired)
|
phys_addr_t physicalAddress, bool alreadyWired)
|
||||||
{
|
{
|
||||||
VMArea* area;
|
VMArea* area;
|
||||||
VMCache* cache;
|
VMCache* cache;
|
||||||
@@ -1956,7 +1957,7 @@ vm_clone_area(team_id team, const char* name, void** address,
|
|||||||
= sourceArea->address_space->TranslationMap();
|
= sourceArea->address_space->TranslationMap();
|
||||||
map->Lock();
|
map->Lock();
|
||||||
|
|
||||||
addr_t physicalAddress;
|
phys_addr_t physicalAddress;
|
||||||
uint32 oldProtection;
|
uint32 oldProtection;
|
||||||
map->Query(sourceArea->Base(), &physicalAddress, &oldProtection);
|
map->Query(sourceArea->Base(), &physicalAddress, &oldProtection);
|
||||||
|
|
||||||
@@ -2412,7 +2413,7 @@ vm_set_area_protection(team_id team, area_id areaID, uint32 newProtection,
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
vm_get_page_mapping(team_id team, addr_t vaddr, addr_t* paddr)
|
vm_get_page_mapping(team_id team, addr_t vaddr, phys_addr_t* paddr)
|
||||||
{
|
{
|
||||||
VMAddressSpace* addressSpace = VMAddressSpace::Get(team);
|
VMAddressSpace* addressSpace = VMAddressSpace::Get(team);
|
||||||
if (addressSpace == NULL)
|
if (addressSpace == NULL)
|
||||||
@@ -2444,7 +2445,7 @@ vm_test_map_modification(vm_page* page)
|
|||||||
VMArea* area = mapping->area;
|
VMArea* area = mapping->area;
|
||||||
VMTranslationMap* map = area->address_space->TranslationMap();
|
VMTranslationMap* map = area->address_space->TranslationMap();
|
||||||
|
|
||||||
addr_t physicalAddress;
|
phys_addr_t physicalAddress;
|
||||||
uint32 flags;
|
uint32 flags;
|
||||||
map->Lock();
|
map->Lock();
|
||||||
map->Query(virtual_page_address(area, page), &physicalAddress, &flags);
|
map->Query(virtual_page_address(area, page), &physicalAddress, &flags);
|
||||||
@@ -3247,7 +3248,7 @@ unmap_and_free_physical_pages(VMTranslationMap* map, addr_t start, addr_t end)
|
|||||||
// free all physical pages in the specified range
|
// free all physical pages in the specified range
|
||||||
|
|
||||||
for (addr_t current = start; current < end; current += B_PAGE_SIZE) {
|
for (addr_t current = start; current < end; current += B_PAGE_SIZE) {
|
||||||
addr_t physicalAddress;
|
phys_addr_t physicalAddress;
|
||||||
uint32 flags;
|
uint32 flags;
|
||||||
|
|
||||||
if (map->Query(current, &physicalAddress, &flags) == B_OK
|
if (map->Query(current, &physicalAddress, &flags) == B_OK
|
||||||
@@ -3486,7 +3487,7 @@ allocate_early_virtual(kernel_args* args, size_t size, bool blockAlign)
|
|||||||
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
is_page_in_physical_memory_range(kernel_args* args, addr_t address)
|
is_page_in_physical_memory_range(kernel_args* args, phys_addr_t address)
|
||||||
{
|
{
|
||||||
// TODO: horrible brute-force method of determining if the page can be
|
// TODO: horrible brute-force method of determining if the page can be
|
||||||
// allocated
|
// allocated
|
||||||
@@ -3500,11 +3501,11 @@ is_page_in_physical_memory_range(kernel_args* args, addr_t address)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static addr_t
|
static phys_addr_t
|
||||||
allocate_early_physical_page(kernel_args* args)
|
allocate_early_physical_page(kernel_args* args)
|
||||||
{
|
{
|
||||||
for (uint32 i = 0; i < args->num_physical_allocated_ranges; i++) {
|
for (uint32 i = 0; i < args->num_physical_allocated_ranges; i++) {
|
||||||
addr_t nextPage;
|
phys_addr_t nextPage;
|
||||||
|
|
||||||
nextPage = args->physical_allocated_range[i].start
|
nextPage = args->physical_allocated_range[i].start
|
||||||
+ args->physical_allocated_range[i].size;
|
+ args->physical_allocated_range[i].size;
|
||||||
@@ -3544,7 +3545,7 @@ vm_allocate_early(kernel_args* args, size_t virtualSize, size_t physicalSize,
|
|||||||
|
|
||||||
// map the pages
|
// map the pages
|
||||||
for (uint32 i = 0; i < PAGE_ALIGN(physicalSize) / B_PAGE_SIZE; i++) {
|
for (uint32 i = 0; i < PAGE_ALIGN(physicalSize) / B_PAGE_SIZE; i++) {
|
||||||
addr_t physicalAddress = allocate_early_physical_page(args);
|
phys_addr_t physicalAddress = allocate_early_physical_page(args);
|
||||||
if (physicalAddress == 0)
|
if (physicalAddress == 0)
|
||||||
panic("error allocating early page!\n");
|
panic("error allocating early page!\n");
|
||||||
|
|
||||||
@@ -4244,7 +4245,7 @@ vm_soft_fault(VMAddressSpace* addressSpace, addr_t originalAddress,
|
|||||||
// check whether there's already a page mapped at the address
|
// check whether there's already a page mapped at the address
|
||||||
context.map->Lock();
|
context.map->Lock();
|
||||||
|
|
||||||
addr_t physicalAddress;
|
phys_addr_t physicalAddress;
|
||||||
uint32 flags;
|
uint32 flags;
|
||||||
vm_page* mappedPage = NULL;
|
vm_page* mappedPage = NULL;
|
||||||
if (context.map->Query(address, &physicalAddress, &flags) == B_OK
|
if (context.map->Query(address, &physicalAddress, &flags) == B_OK
|
||||||
@@ -4337,7 +4338,7 @@ vm_soft_fault(VMAddressSpace* addressSpace, addr_t originalAddress,
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
vm_get_physical_page(addr_t paddr, addr_t* _vaddr, void** _handle)
|
vm_get_physical_page(phys_addr_t paddr, addr_t* _vaddr, void** _handle)
|
||||||
{
|
{
|
||||||
return sPhysicalPageMapper->GetPage(paddr, _vaddr, _handle);
|
return sPhysicalPageMapper->GetPage(paddr, _vaddr, _handle);
|
||||||
}
|
}
|
||||||
@@ -4350,7 +4351,8 @@ vm_put_physical_page(addr_t vaddr, void* handle)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
vm_get_physical_page_current_cpu(addr_t paddr, addr_t* _vaddr, void** _handle)
|
vm_get_physical_page_current_cpu(phys_addr_t paddr, addr_t* _vaddr,
|
||||||
|
void** _handle)
|
||||||
{
|
{
|
||||||
return sPhysicalPageMapper->GetPageCurrentCPU(paddr, _vaddr, _handle);
|
return sPhysicalPageMapper->GetPageCurrentCPU(paddr, _vaddr, _handle);
|
||||||
}
|
}
|
||||||
@@ -4363,7 +4365,7 @@ vm_put_physical_page_current_cpu(addr_t vaddr, void* handle)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
vm_get_physical_page_debug(addr_t paddr, addr_t* _vaddr, void** _handle)
|
vm_get_physical_page_debug(phys_addr_t paddr, addr_t* _vaddr, void** _handle)
|
||||||
{
|
{
|
||||||
return sPhysicalPageMapper->GetPageDebug(paddr, _vaddr, _handle);
|
return sPhysicalPageMapper->GetPageDebug(paddr, _vaddr, _handle);
|
||||||
}
|
}
|
||||||
@@ -4473,7 +4475,7 @@ vm_try_reserve_memory(size_t amount, int priority, bigtime_t timeout)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
vm_set_area_memory_type(area_id id, addr_t physicalBase, uint32 type)
|
vm_set_area_memory_type(area_id id, phys_addr_t physicalBase, uint32 type)
|
||||||
{
|
{
|
||||||
// NOTE: The caller is responsible for synchronizing calls to this function!
|
// NOTE: The caller is responsible for synchronizing calls to this function!
|
||||||
|
|
||||||
@@ -4683,28 +4685,29 @@ vm_resize_area(area_id areaID, size_t newSize, bool kernel)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
vm_memset_physical(addr_t address, int value, size_t length)
|
vm_memset_physical(phys_addr_t address, int value, size_t length)
|
||||||
{
|
{
|
||||||
return sPhysicalPageMapper->MemsetPhysical(address, value, length);
|
return sPhysicalPageMapper->MemsetPhysical(address, value, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
vm_memcpy_from_physical(void* to, addr_t from, size_t length, bool user)
|
vm_memcpy_from_physical(void* to, phys_addr_t from, size_t length, bool user)
|
||||||
{
|
{
|
||||||
return sPhysicalPageMapper->MemcpyFromPhysical(to, from, length, user);
|
return sPhysicalPageMapper->MemcpyFromPhysical(to, from, length, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
vm_memcpy_to_physical(addr_t to, const void* _from, size_t length, bool user)
|
vm_memcpy_to_physical(phys_addr_t to, const void* _from, size_t length,
|
||||||
|
bool user)
|
||||||
{
|
{
|
||||||
return sPhysicalPageMapper->MemcpyToPhysical(to, _from, length, user);
|
return sPhysicalPageMapper->MemcpyToPhysical(to, _from, length, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
vm_memcpy_physical_page(addr_t to, addr_t from)
|
vm_memcpy_physical_page(phys_addr_t to, phys_addr_t from)
|
||||||
{
|
{
|
||||||
return sPhysicalPageMapper->MemcpyPhysicalPage(to, from);
|
return sPhysicalPageMapper->MemcpyPhysicalPage(to, from);
|
||||||
}
|
}
|
||||||
@@ -4783,7 +4786,7 @@ vm_debug_copy_page_memory(team_id teamID, void* unsafeMemory, void* buffer,
|
|||||||
return B_UNSUPPORTED;
|
return B_UNSUPPORTED;
|
||||||
|
|
||||||
// copy from/to physical memory
|
// copy from/to physical memory
|
||||||
addr_t physicalAddress = page->physical_page_number * B_PAGE_SIZE
|
phys_addr_t physicalAddress = page->physical_page_number * B_PAGE_SIZE
|
||||||
+ (addr_t)unsafeMemory % B_PAGE_SIZE;
|
+ (addr_t)unsafeMemory % B_PAGE_SIZE;
|
||||||
|
|
||||||
if (copyToUnsafe) {
|
if (copyToUnsafe) {
|
||||||
@@ -4925,7 +4928,7 @@ vm_wire_page(team_id team, addr_t address, bool writable,
|
|||||||
cacheChainLocker.LockAllSourceCaches();
|
cacheChainLocker.LockAllSourceCaches();
|
||||||
map->Lock();
|
map->Lock();
|
||||||
|
|
||||||
addr_t physicalAddress;
|
phys_addr_t physicalAddress;
|
||||||
uint32 flags;
|
uint32 flags;
|
||||||
vm_page* page;
|
vm_page* page;
|
||||||
if (map->Query(pageAddress, &physicalAddress, &flags) == B_OK
|
if (map->Query(pageAddress, &physicalAddress, &flags) == B_OK
|
||||||
@@ -4961,8 +4964,9 @@ vm_wire_page(team_id team, addr_t address, bool writable,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
info->physicalAddress = page->physical_page_number * B_PAGE_SIZE
|
info->physicalAddress
|
||||||
+ address % B_PAGE_SIZE;
|
= (phys_addr_t)page->physical_page_number * B_PAGE_SIZE
|
||||||
|
+ address % B_PAGE_SIZE;
|
||||||
info->page = page;
|
info->page = page;
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
@@ -5105,7 +5109,7 @@ lock_memory_etc(team_id team, void* address, size_t numBytes, uint32 flags)
|
|||||||
|
|
||||||
// iterate through the pages and wire them
|
// iterate through the pages and wire them
|
||||||
for (; nextAddress != areaEnd; nextAddress += B_PAGE_SIZE) {
|
for (; nextAddress != areaEnd; nextAddress += B_PAGE_SIZE) {
|
||||||
addr_t physicalAddress;
|
phys_addr_t physicalAddress;
|
||||||
uint32 flags;
|
uint32 flags;
|
||||||
|
|
||||||
vm_page* page;
|
vm_page* page;
|
||||||
@@ -5260,7 +5264,7 @@ unlock_memory_etc(team_id team, void* address, size_t numBytes, uint32 flags)
|
|||||||
|
|
||||||
// iterate through the pages and unwire them
|
// iterate through the pages and unwire them
|
||||||
for (; nextAddress != areaEnd; nextAddress += B_PAGE_SIZE) {
|
for (; nextAddress != areaEnd; nextAddress += B_PAGE_SIZE) {
|
||||||
addr_t physicalAddress;
|
phys_addr_t physicalAddress;
|
||||||
uint32 flags;
|
uint32 flags;
|
||||||
|
|
||||||
vm_page* page;
|
vm_page* page;
|
||||||
@@ -5330,7 +5334,7 @@ get_memory_map_etc(team_id team, const void* address, size_t numBytes,
|
|||||||
VMAddressSpace* addressSpace;
|
VMAddressSpace* addressSpace;
|
||||||
addr_t virtualAddress = (addr_t)address;
|
addr_t virtualAddress = (addr_t)address;
|
||||||
addr_t pageOffset = virtualAddress & (B_PAGE_SIZE - 1);
|
addr_t pageOffset = virtualAddress & (B_PAGE_SIZE - 1);
|
||||||
addr_t physicalAddress;
|
phys_addr_t physicalAddress;
|
||||||
status_t status = B_OK;
|
status_t status = B_OK;
|
||||||
int32 index = -1;
|
int32 index = -1;
|
||||||
addr_t offset = 0;
|
addr_t offset = 0;
|
||||||
@@ -5384,7 +5388,7 @@ get_memory_map_etc(team_id team, const void* address, size_t numBytes,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// need to switch to the next physical_entry?
|
// need to switch to the next physical_entry?
|
||||||
if (index < 0 || (addr_t)table[index].address
|
if (index < 0 || (phys_addr_t)table[index].address
|
||||||
!= physicalAddress - table[index].size) {
|
!= physicalAddress - table[index].size) {
|
||||||
if ((uint32)++index + 1 > numEntries) {
|
if ((uint32)++index + 1 > numEntries) {
|
||||||
// table to small
|
// table to small
|
||||||
@@ -5573,7 +5577,7 @@ map_physical_memory(const char* name, void* physicalAddress, size_t numBytes,
|
|||||||
|
|
||||||
return vm_map_physical_memory(VMAddressSpace::KernelID(), name,
|
return vm_map_physical_memory(VMAddressSpace::KernelID(), name,
|
||||||
_virtualAddress, addressSpec, numBytes, protection,
|
_virtualAddress, addressSpec, numBytes, protection,
|
||||||
(addr_t)physicalAddress, false);
|
(phys_addr_t)physicalAddress, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -5592,7 +5596,7 @@ clone_area(const char* name, void** _address, uint32 addressSpec,
|
|||||||
area_id
|
area_id
|
||||||
create_area_etc(team_id team, const char* name, void** address,
|
create_area_etc(team_id team, const char* name, void** address,
|
||||||
uint32 addressSpec, uint32 size, uint32 lock, uint32 protection,
|
uint32 addressSpec, uint32 size, uint32 lock, uint32 protection,
|
||||||
addr_t physicalAddress, uint32 flags)
|
phys_addr_t physicalAddress, uint32 flags)
|
||||||
{
|
{
|
||||||
fix_protection(&protection);
|
fix_protection(&protection);
|
||||||
|
|
||||||
@@ -6057,7 +6061,7 @@ _user_set_memory_protection(void* _address, size_t size, uint32 protection)
|
|||||||
|
|
||||||
set_area_page_protection(area, pageAddress, protection);
|
set_area_page_protection(area, pageAddress, protection);
|
||||||
|
|
||||||
addr_t physicalAddress;
|
phys_addr_t physicalAddress;
|
||||||
uint32 flags;
|
uint32 flags;
|
||||||
|
|
||||||
status_t error = map->Query(pageAddress, &physicalAddress, &flags);
|
status_t error = map->Query(pageAddress, &physicalAddress, &flags);
|
||||||
|
|||||||
@@ -111,8 +111,8 @@ static VMPageQueue& sActivePageQueue = sPageQueues[PAGE_STATE_ACTIVE];
|
|||||||
static VMPageQueue& sCachedPageQueue = sPageQueues[PAGE_STATE_CACHED];
|
static VMPageQueue& sCachedPageQueue = sPageQueues[PAGE_STATE_CACHED];
|
||||||
|
|
||||||
static vm_page *sPages;
|
static vm_page *sPages;
|
||||||
static addr_t sPhysicalPageOffset;
|
static page_num_t sPhysicalPageOffset;
|
||||||
static size_t sNumPages;
|
static page_num_t sNumPages;
|
||||||
static vint32 sUnreservedFreePages;
|
static vint32 sUnreservedFreePages;
|
||||||
static vint32 sUnsatisfiedPageReservations;
|
static vint32 sUnsatisfiedPageReservations;
|
||||||
static vint32 sModifiedTemporaryPages;
|
static vint32 sModifiedTemporaryPages;
|
||||||
@@ -718,7 +718,7 @@ dump_page(int argc, char **argv)
|
|||||||
size_t pageCount = addressSpace->Size() / B_PAGE_SIZE;
|
size_t pageCount = addressSpace->Size() / B_PAGE_SIZE;
|
||||||
for (addr_t address = addressSpace->Base(); pageCount != 0;
|
for (addr_t address = addressSpace->Base(); pageCount != 0;
|
||||||
address += B_PAGE_SIZE, pageCount--) {
|
address += B_PAGE_SIZE, pageCount--) {
|
||||||
addr_t physicalAddress;
|
phys_addr_t physicalAddress;
|
||||||
uint32 flags = 0;
|
uint32 flags = 0;
|
||||||
if (addressSpace->TranslationMap()->QueryInterrupt(address,
|
if (addressSpace->TranslationMap()->QueryInterrupt(address,
|
||||||
&physicalAddress, &flags) == B_OK
|
&physicalAddress, &flags) == B_OK
|
||||||
@@ -839,7 +839,7 @@ dump_page_stats(int argc, char **argv)
|
|||||||
page_run longestFreeRun = { 0, 0 };
|
page_run longestFreeRun = { 0, 0 };
|
||||||
page_run longestCachedRun = { 0, 0 };
|
page_run longestCachedRun = { 0, 0 };
|
||||||
|
|
||||||
for (addr_t i = 0; i < sNumPages; i++) {
|
for (page_num_t i = 0; i < sNumPages; i++) {
|
||||||
if (sPages[i].State() > 7)
|
if (sPages[i].State() > 7)
|
||||||
panic("page %li at %p has invalid state!\n", i, &sPages[i]);
|
panic("page %li at %p has invalid state!\n", i, &sPages[i]);
|
||||||
|
|
||||||
@@ -1295,7 +1295,7 @@ clear_page(struct vm_page *page)
|
|||||||
|
|
||||||
|
|
||||||
static status_t
|
static status_t
|
||||||
mark_page_range_in_use(addr_t startPage, size_t length, bool wired)
|
mark_page_range_in_use(page_num_t startPage, page_num_t length, bool wired)
|
||||||
{
|
{
|
||||||
TRACE(("mark_page_range_in_use: start 0x%lx, len 0x%lx\n",
|
TRACE(("mark_page_range_in_use: start 0x%lx, len 0x%lx\n",
|
||||||
startPage, length));
|
startPage, length));
|
||||||
@@ -1321,7 +1321,7 @@ mark_page_range_in_use(addr_t startPage, size_t length, bool wired)
|
|||||||
|
|
||||||
WriteLocker locker(sFreePageQueuesLock);
|
WriteLocker locker(sFreePageQueuesLock);
|
||||||
|
|
||||||
for (size_t i = 0; i < length; i++) {
|
for (page_num_t i = 0; i < length; i++) {
|
||||||
vm_page *page = &sPages[startPage + i];
|
vm_page *page = &sPages[startPage + i];
|
||||||
switch (page->State()) {
|
switch (page->State()) {
|
||||||
case PAGE_STATE_FREE:
|
case PAGE_STATE_FREE:
|
||||||
@@ -1700,8 +1700,8 @@ PageWriteTransfer::AddPage(vm_page* page)
|
|||||||
|| (fMaxPages >= 0 && fPageCount >= (uint32)fMaxPages))
|
|| (fMaxPages >= 0 && fPageCount >= (uint32)fMaxPages))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
addr_t nextBase
|
phys_addr_t nextBase = (phys_addr_t)fVecs[fVecCount - 1].iov_base
|
||||||
= (addr_t)fVecs[fVecCount - 1].iov_base + fVecs[fVecCount - 1].iov_len;
|
+ fVecs[fVecCount - 1].iov_len;
|
||||||
|
|
||||||
if (page->physical_page_number << PAGE_SHIFT == nextBase
|
if (page->physical_page_number << PAGE_SHIFT == nextBase
|
||||||
&& page->cache_offset == fOffset + fPageCount) {
|
&& page->cache_offset == fOffset + fPageCount) {
|
||||||
@@ -1711,7 +1711,7 @@ PageWriteTransfer::AddPage(vm_page* page)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
nextBase = (addr_t)fVecs[0].iov_base - B_PAGE_SIZE;
|
nextBase = (phys_addr_t)fVecs[0].iov_base - B_PAGE_SIZE;
|
||||||
if (page->physical_page_number << PAGE_SHIFT == nextBase
|
if (page->physical_page_number << PAGE_SHIFT == nextBase
|
||||||
&& page->cache_offset == fOffset - 1) {
|
&& page->cache_offset == fOffset - 1) {
|
||||||
// prepend to first iovec and adjust offset
|
// prepend to first iovec and adjust offset
|
||||||
@@ -1754,7 +1754,7 @@ status_t
|
|||||||
PageWriteTransfer::Schedule(uint32 flags)
|
PageWriteTransfer::Schedule(uint32 flags)
|
||||||
{
|
{
|
||||||
off_t writeOffset = (off_t)fOffset << PAGE_SHIFT;
|
off_t writeOffset = (off_t)fOffset << PAGE_SHIFT;
|
||||||
size_t writeLength = fPageCount << PAGE_SHIFT;
|
size_t writeLength = (size_t)fPageCount << PAGE_SHIFT;
|
||||||
|
|
||||||
if (fRun != NULL) {
|
if (fRun != NULL) {
|
||||||
return fCache->WriteAsync(writeOffset, fVecs, fVecCount, writeLength,
|
return fCache->WriteAsync(writeOffset, fVecs, fVecCount, writeLength,
|
||||||
@@ -2805,7 +2805,7 @@ void
|
|||||||
vm_page_init_num_pages(kernel_args *args)
|
vm_page_init_num_pages(kernel_args *args)
|
||||||
{
|
{
|
||||||
// calculate the size of memory by looking at the physical_memory_range array
|
// calculate the size of memory by looking at the physical_memory_range array
|
||||||
addr_t physicalPagesEnd = 0;
|
page_num_t physicalPagesEnd = 0;
|
||||||
sPhysicalPageOffset = args->physical_memory_range[0].start / B_PAGE_SIZE;
|
sPhysicalPageOffset = args->physical_memory_range[0].start / B_PAGE_SIZE;
|
||||||
|
|
||||||
for (uint32 i = 0; i < args->num_physical_memory_ranges; i++) {
|
for (uint32 i = 0; i < args->num_physical_memory_ranges; i++) {
|
||||||
@@ -2870,10 +2870,10 @@ vm_page_init(kernel_args *args)
|
|||||||
TRACE(("initialized table\n"));
|
TRACE(("initialized table\n"));
|
||||||
|
|
||||||
// mark the ranges between usable physical memory unused
|
// mark the ranges between usable physical memory unused
|
||||||
addr_t previousEnd = 0;
|
phys_addr_t previousEnd = 0;
|
||||||
for (uint32 i = 0; i < args->num_physical_memory_ranges; i++) {
|
for (uint32 i = 0; i < args->num_physical_memory_ranges; i++) {
|
||||||
addr_t base = args->physical_memory_range[i].start;
|
phys_addr_t base = args->physical_memory_range[i].start;
|
||||||
addr_t size = args->physical_memory_range[i].size;
|
phys_size_t size = args->physical_memory_range[i].size;
|
||||||
if (base > previousEnd) {
|
if (base > previousEnd) {
|
||||||
mark_page_range_in_use(previousEnd / B_PAGE_SIZE,
|
mark_page_range_in_use(previousEnd / B_PAGE_SIZE,
|
||||||
(base - previousEnd) / B_PAGE_SIZE, false);
|
(base - previousEnd) / B_PAGE_SIZE, false);
|
||||||
@@ -2985,14 +2985,14 @@ vm_page_init_post_thread(kernel_args *args)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
vm_mark_page_inuse(addr_t page)
|
vm_mark_page_inuse(page_num_t page)
|
||||||
{
|
{
|
||||||
return vm_mark_page_range_inuse(page, 1);
|
return vm_mark_page_range_inuse(page, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
vm_mark_page_range_inuse(addr_t startPage, addr_t length)
|
vm_mark_page_range_inuse(page_num_t startPage, page_num_t length)
|
||||||
{
|
{
|
||||||
return mark_page_range_in_use(startPage, length, false);
|
return mark_page_range_in_use(startPage, length, false);
|
||||||
}
|
}
|
||||||
@@ -3313,10 +3313,10 @@ allocate_page_run(page_num_t start, page_num_t length, uint32 flags,
|
|||||||
|
|
||||||
|
|
||||||
vm_page *
|
vm_page *
|
||||||
vm_page_allocate_page_run(uint32 flags, addr_t base, size_t length,
|
vm_page_allocate_page_run(uint32 flags, phys_addr_t base, page_num_t length,
|
||||||
int priority)
|
int priority)
|
||||||
{
|
{
|
||||||
uint32 start = base >> PAGE_SHIFT;
|
page_num_t start = base >> PAGE_SHIFT;
|
||||||
|
|
||||||
vm_page_reservation reservation;
|
vm_page_reservation reservation;
|
||||||
vm_page_reserve_pages(&reservation, length, priority);
|
vm_page_reserve_pages(&reservation, length, priority);
|
||||||
@@ -3349,7 +3349,7 @@ vm_page_allocate_page_run(uint32 flags, addr_t base, size_t length,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 i;
|
page_num_t i;
|
||||||
for (i = 0; i < length; i++) {
|
for (i = 0; i < length; i++) {
|
||||||
uint32 pageState = sPages[start + i].State();
|
uint32 pageState = sPages[start + i].State();
|
||||||
if (pageState != PAGE_STATE_FREE
|
if (pageState != PAGE_STATE_FREE
|
||||||
@@ -3383,7 +3383,7 @@ vm_page_at_index(int32 index)
|
|||||||
|
|
||||||
|
|
||||||
vm_page *
|
vm_page *
|
||||||
vm_lookup_page(addr_t pageNumber)
|
vm_lookup_page(page_num_t pageNumber)
|
||||||
{
|
{
|
||||||
if (pageNumber < sPhysicalPageOffset)
|
if (pageNumber < sPhysicalPageOffset)
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -3482,7 +3482,7 @@ vm_page_requeue(struct vm_page *page, bool tail)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
size_t
|
page_num_t
|
||||||
vm_page_num_pages(void)
|
vm_page_num_pages(void)
|
||||||
{
|
{
|
||||||
return sNumPages;
|
return sNumPages;
|
||||||
@@ -3496,14 +3496,14 @@ vm_page_num_pages(void)
|
|||||||
use by being reclaimed as well (IOW it factors in things like cache pages
|
use by being reclaimed as well (IOW it factors in things like cache pages
|
||||||
as available).
|
as available).
|
||||||
*/
|
*/
|
||||||
size_t
|
page_num_t
|
||||||
vm_page_num_available_pages(void)
|
vm_page_num_available_pages(void)
|
||||||
{
|
{
|
||||||
return vm_available_memory() / B_PAGE_SIZE;
|
return vm_available_memory() / B_PAGE_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
size_t
|
page_num_t
|
||||||
vm_page_num_free_pages(void)
|
vm_page_num_free_pages(void)
|
||||||
{
|
{
|
||||||
int32 count = sUnreservedFreePages + sCachedPageQueue.Count();
|
int32 count = sUnreservedFreePages + sCachedPageQueue.Count();
|
||||||
@@ -3511,7 +3511,7 @@ vm_page_num_free_pages(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
size_t
|
page_num_t
|
||||||
vm_page_num_unused_pages(void)
|
vm_page_num_unused_pages(void)
|
||||||
{
|
{
|
||||||
int32 count = sUnreservedFreePages;
|
int32 count = sUnreservedFreePages;
|
||||||
|
|||||||
Reference in New Issue
Block a user