Added arch_cpu.cpp to the x86_64 build.

* Some things are currently ifndef'd out completely for x86_64 because
  they aren't implemented, there's a few other ifdef's to handle x86_64
  differences but most of the code works unchanged.
* Renamed some i386_* functions to x86_*.
* Added a temporary method for setting the current thread on x86_64
  (a global variable, not SMP safe). This will be changed to be done
  via the GS segment but I've not implemented that yet.
This commit is contained in:
Alex Smith
2012-07-04 14:06:46 +01:00
parent 4e8fbfb2d1
commit 4304bb9894
17 changed files with 291 additions and 211 deletions
+1 -1
View File
@@ -645,7 +645,7 @@ typedef enum cpu_types {
#define B_CPU_x86_VENDOR_MASK 0xff00
#ifdef __INTEL__
#if defined(__INTEL__) || defined(__x86_64)
typedef union {
struct {
uint32 max_eax;
@@ -26,10 +26,11 @@
// (and is in arch_interrupts.S)
#define DOUBLE_FAULT_TSS_BASE_SEGMENT 9
#define TSS_BASE_SEGMENT (DOUBLE_FAULT_TSS_BASE_SEGMENT + smp_get_num_cpus())
#define TLS_BASE_SEGMENT (TSS_BASE_SEGMENT + smp_get_num_cpus())
#define APM_BASE_SEGMENT (TLS_BASE_SEGMENT + smp_get_num_cpus())
#define TSS_BASE_SEGMENT (DOUBLE_FAULT_TSS_BASE_SEGMENT + smp_get_num_cpus())
#define TLS_BASE_SEGMENT (TSS_BASE_SEGMENT + smp_get_num_cpus())
#define APM_BASE_SEGMENT (TLS_BASE_SEGMENT + smp_get_num_cpus())
#define TSS_SEGMENT(cpu) (TSS_BASE_SEGMENT + cpu)
// defines entries in the GDT/LDT
@@ -18,7 +18,7 @@
#define TSS_BASE_SEGMENT 5
#define TLS_BASE_SEGMENT (TSS_BASE_SEGMENT + smp_get_num_cpus())
#define TSS_SEGMENT(cpu) (TSS_BASE_SEGMENT + cpu * 2)
// Structure of a segment descriptor.
@@ -89,7 +89,7 @@ struct tss {
uint64 ist7;
uint64 _reserved3;
uint16 _reserved4;
uint16 io_bitmap;
uint16 io_map_base;
} _PACKED;
+15 -17
View File
@@ -365,12 +365,9 @@ typedef struct arch_cpu_info {
extern "C" {
#endif
// temporary
#ifndef __x86_64__
struct arch_thread;
void __x86_setup_system_time(uint32 conversionFactor,
uint32 conversionFactorNsecs, bool conversionFactorNsecsShift);
void x86_context_switch(struct arch_thread* oldState,
@@ -378,18 +375,12 @@ void x86_context_switch(struct arch_thread* oldState,
void x86_userspace_thread_exit(void);
void x86_end_userspace_thread_exit(void);
void x86_swap_pgdir(uint32 newPageDir);
void i386_set_tss_and_kstack(addr_t kstack);
void i386_fnsave(void* fpuState);
void i386_fxsave(void* fpuState);
void i386_frstor(const void* fpuState);
void i386_fxrstor(const void* fpuState);
void i386_noop_swap(void* oldFpuState, const void* newFpuState);
void i386_fnsave_swap(void* oldFpuState, const void* newFpuState);
void i386_fxsave_swap(void* oldFpuState, const void* newFpuState);
uint32 x86_read_ebp();
void x86_fxsave(void* fpuState);
void x86_fxrstor(const void* fpuState);
void x86_fxsave_swap(void* oldFpuState, const void* newFpuState);
addr_t x86_read_ebp();
uint64 x86_read_msr(uint32 registerNumber);
void x86_write_msr(uint32 registerNumber, uint64 value);
void x86_set_task_gate(int32 cpu, int32 n, int32 segment);
void* x86_get_idt(int32 cpu);
uint32 x86_count_mtrrs(void);
void x86_set_mtrr(uint32 index, uint64 base, uint64 length, uint8 type);
@@ -400,16 +391,23 @@ void x86_set_mtrrs(uint8 defaultType, const x86_mtrr_info* infos,
void x86_init_fpu();
bool x86_check_feature(uint32 feature, enum x86_feature_type type);
void* x86_get_double_fault_stack(int32 cpu, size_t* _size);
int32 x86_double_fault_get_cpu(void);
void x86_double_fault_exception(struct iframe* frame);
void x86_page_fault_exception_double_fault(struct iframe* frame);
#ifndef __x86_64__
void i386_set_tss_and_kstack(addr_t kstack);
void x86_fnsave(void* fpuState);
void x86_frstor(const void* fpuState);
void x86_noop_swap(void* oldFpuState, const void* newFpuState);
void x86_fnsave_swap(void* oldFpuState, const void* newFpuState);
void x86_set_task_gate(int32 cpu, int32 n, int32 segment);
int32 x86_double_fault_get_cpu(void);
#endif
extern segment_descriptor* gGDT;
#ifdef __cplusplus
} // extern "C" {
#endif
@@ -12,13 +12,11 @@
extern "C" {
#endif
#ifndef __x86_64__
status_t get_current_cpuid(cpuid_info *info, uint32 eax);
status_t get_current_cpuid(cpuid_info* info, uint32 eax);
uint32 get_eflags(void);
void set_eflags(uint32 value);
status_t _user_get_cpuid(cpuid_info *info, uint32 eax, uint32 cpu);
#endif
status_t _user_get_cpuid(cpuid_info* info, uint32 eax, uint32 cpu);
#ifdef __cplusplus
}
@@ -30,19 +30,21 @@ void x86_set_tls_context(Thread* thread);
#ifdef __x86_64__
// TODO
extern Thread* gCurrentThread;
static inline Thread*
arch_thread_get_current_thread(void)
{
return NULL;
return gCurrentThread;
}
static inline void
arch_thread_set_current_thread(Thread* t)
{
gCurrentThread = t;
}