The short story: we now have MTRR support on Intel and AMD CPUs (the latter
has not yet been tested, though - I'll do this after this commit): * Removed the arch_memory_type stuff from vm_area; since there are only 8 memory ranges on x86, it's simply overkill. The MTRR code now remembers the area ID and finds the MTRR that way (it could also iterate over the existing MTRRs). * Introduced some post_modules() init functions. * If the other x86 CPUs out there don't differ a lot, MTRR functionality might be put back into the kernel. * x86_write_msr() was broken, it wrote the 64 bit number with the 32 bit words switched - it took me some time (and lots of #GPs) to figure that one out. * Removed the macro read_ebp() and introduced a function x86_read_ebp() (it's not really a time critical call). * Followed the Intel docs on how to change MTRRs (symmetrically on all CPUs with caches turned off). * Asking for memory types will automatically change the requested length to a power of two - note that BeOS seems to behave in the same, although that's not really very clean. * fixed MTRRs are ignored for now - we should make sure at least, though, that they are identical on all CPUs (or turn them off, even though I'd prefer the BIOS stuff to be uncacheable, which we don't enforce yet, though). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15528 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2004, Axel Dörfler, [email protected].
|
||||
* Copyright 2002-2005, Axel Dörfler, [email protected].
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
|
||||
@@ -22,6 +22,7 @@ extern "C" {
|
||||
status_t arch_cpu_preboot_init(kernel_args *args);
|
||||
status_t arch_cpu_init(kernel_args *args);
|
||||
status_t arch_cpu_init_post_vm(kernel_args *args);
|
||||
status_t arch_cpu_init_post_modules(kernel_args *args);
|
||||
status_t arch_cpu_shutdown(bool reboot);
|
||||
|
||||
void arch_cpu_invalidate_TLB_range(addr_t start, addr_t end);
|
||||
|
||||
@@ -5,12 +5,4 @@
|
||||
#ifndef _KERNEL_ARCH_PPC_VM_TYPES_H
|
||||
#define _KERNEL_ARCH_PPC_VM_TYPES_H
|
||||
|
||||
|
||||
#include <SupportDefs.h>
|
||||
|
||||
|
||||
struct arch_vm_memory_type {
|
||||
uint32 dummy;
|
||||
};
|
||||
|
||||
#endif /* _KERNEL_ARCH_PPC_6VM_TYPES_H */
|
||||
#endif /* _KERNEL_ARCH_PPC_VM_TYPES_H */
|
||||
|
||||
@@ -20,9 +20,9 @@ extern "C" {
|
||||
status_t arch_vm_init(struct kernel_args *args);
|
||||
status_t arch_vm_init_post_area(struct kernel_args *args);
|
||||
status_t arch_vm_init_end(struct kernel_args *args);
|
||||
status_t arch_vm_init_post_modules(kernel_args *args);
|
||||
void arch_vm_aspace_swap(vm_address_space *aspace);
|
||||
bool arch_vm_supports_protection(uint32 protection);
|
||||
void arch_vm_init_area(vm_area *area);
|
||||
|
||||
status_t arch_vm_set_memory_type(vm_area *area, addr_t physicalBase, uint32 type);
|
||||
void arch_vm_unset_memory_type(vm_area *area);
|
||||
|
||||
@@ -21,16 +21,21 @@
|
||||
#define IA32_MSR_MTRR_PHYSICAL_BASE_0 0x200
|
||||
#define IA32_MSR_MTRR_PHYSICAL_MASK_0 0x201
|
||||
|
||||
// Memory type ranges
|
||||
#define IA32_MTR_UNCACHED 0
|
||||
#define IA32_MTR_WRITE_COMBINED 1
|
||||
#define IA32_MTR_WRITE_THROUGH 4
|
||||
#define IA32_MTR_WRITE_PROTECTED 5
|
||||
#define IA32_MTR_WRITE_BACK 6
|
||||
|
||||
typedef struct x86_cpu_module_info {
|
||||
module_info info;
|
||||
uint32 (*count_mtrrs)(void);
|
||||
status_t (*enable_mtrrs)(void);
|
||||
void (*disable_mtrrs)(void);
|
||||
void (*init_mtrrs)(void);
|
||||
|
||||
void (*set_mtrr)(uint32 index, addr_t base, addr_t length, uint32 type);
|
||||
status_t (*get_mtrr)(uint32 index, addr_t *_base, addr_t *_length,
|
||||
uint32 *_type);
|
||||
void (*set_mtrr)(uint32 index, uint64 base, uint64 length, uint8 type);
|
||||
status_t (*get_mtrr)(uint32 index, uint64 *_base, uint64 *_length,
|
||||
uint8 *_type);
|
||||
} x86_cpu_module_info;
|
||||
|
||||
|
||||
@@ -96,19 +101,17 @@ void i386_frstor(const void *fpu_state);
|
||||
void i386_fxrstor(const void *fpu_state);
|
||||
void i386_fsave_swap(void *old_fpu_state, const void *new_fpu_state);
|
||||
void i386_fxsave_swap(void *old_fpu_state, const void *new_fpu_state);
|
||||
uint32 x86_read_ebp();
|
||||
uint32 x86_read_cr0();
|
||||
void x86_write_cr0(uint32 value);
|
||||
uint64 x86_read_msr(uint32 registerNumber);
|
||||
void x86_write_msr(uint32 registerNumber, uint64 value);
|
||||
void x86_set_task_gate(int32 n, int32 segment);
|
||||
uint32 x86_count_mtrrs(void);
|
||||
status_t x86_enable_mtrrs(void);
|
||||
status_t x86_disable_mtrrs(void);
|
||||
status_t x86_set_mtrr(uint32 index, addr_t base, addr_t length, uint32 type);
|
||||
status_t x86_get_mtrr(uint32 index, addr_t *_base, addr_t *_length, uint32 *_type);
|
||||
void x86_set_mtrr(uint32 index, uint64 base, uint64 length, uint8 type);
|
||||
status_t x86_get_mtrr(uint32 index, uint64 *_base, uint64 *_length, uint8 *_type);
|
||||
struct tss *x86_get_main_tss(void);
|
||||
|
||||
#define read_ebp(value) \
|
||||
__asm__("movl %%ebp,%0" : "=r" (value))
|
||||
|
||||
#define read_cr3(value) \
|
||||
__asm__("movl %%cr3,%0" : "=r" (value))
|
||||
|
||||
|
||||
@@ -5,13 +5,4 @@
|
||||
#ifndef _KERNEL_ARCH_x86_VM_TYPES_H
|
||||
#define _KERNEL_ARCH_x86_VM_TYPES_H
|
||||
|
||||
|
||||
#include <SupportDefs.h>
|
||||
|
||||
|
||||
struct arch_vm_memory_type {
|
||||
uint16 type;
|
||||
uint16 index;
|
||||
};
|
||||
|
||||
#endif /* _KERNEL_ARCH_x86_VM_TYPES_H */
|
||||
|
||||
Reference in New Issue
Block a user