Added some x86_64 system/kernel headers and kernel Jamfiles.

* Not all of these headers are correct yet, just adding what's necessary
  to get things to compile for the time being.
This commit is contained in:
Alex Smith
2012-06-13 17:45:22 +01:00
parent 0e88a887b4
commit f76bc433e1
21 changed files with 669 additions and 29 deletions
+71
View File
@@ -0,0 +1,71 @@
/*
* Copyright 2005-2012, Haiku Inc.
* Distributed under the terms of the MIT License.
*/
#ifndef _ARCH_X86_64_DEBUGGER_H
#define _ARCH_X86_64_DEBUGGER_H
typedef struct x86_64_fp_register {
uint8 value[10];
uint8 reserved[6];
} x86_64_fp_register;
typedef struct x86_64_xmm_register {
uint8 value[16];
} x86_64_xmm_register;
typedef struct x86_64_extended_registers {
uint16 control;
uint16 status;
uint8 tag;
uint8 reserved1;
uint16 opcode;
uint64 instruction_pointer;
uint64 data_pointer;
uint32 mxcsr;
uint32 mxcsr_mask;
union {
x86_64_fp_register fp_registers[8]; // st0-st7
x86_64_fp_register mmx_registers[8]; // mm0-mm7
};
x86_64_xmm_register xmm_registers[16]; // xmm0-xmm15
uint8 reserved4[96]; // 416 - 512
} x86_64_extended_registers;
struct x86_64_debug_cpu_state {
x86_64_extended_registers extended_registers;
uint64 gs;
uint64 fs;
uint64 es;
uint64 ds;
uint64 r15;
uint64 r14;
uint64 r13;
uint64 r12;
uint64 r11;
uint64 r10;
uint64 r9;
uint64 r8;
uint64 rbp;
uint64 rsi;
uint64 rdi;
uint64 rdx;
uint64 rcx;
uint64 rbx;
uint64 rax;
uint64 vector;
uint64 error_code;
uint64 rip;
uint64 cs;
uint64 rflags;
uint64 rsp;
uint64 ss;
} __attribute__((aligned(16)));
#endif // _ARCH_X86_64_DEBUGGER_H
+4 -1
View File
@@ -13,13 +13,16 @@
// include architecture specific definitions
#include <arch/x86/arch_debugger.h>
#include <arch/x86_64/arch_debugger.h>
#include <arch/ppc/arch_debugger.h>
#include <arch/m68k/arch_debugger.h>
#include <arch/mipsel/arch_debugger.h>
#include <arch/arm/arch_debugger.h>
#ifdef __INTEL__
#ifdef __x86_64__
typedef struct x86_64_debug_cpu_state debug_cpu_state;
#elif __INTEL__
typedef struct x86_debug_cpu_state debug_cpu_state;
#elif __POWERPC__
typedef struct ppc_debug_cpu_state debug_cpu_state;
@@ -1,6 +1,6 @@
#ifndef _KERNEL_ARCH_x86_64_CPU_H
#define _KERNEL_ARCH_x86_64_CPU_H
#ifndef _KERNEL_ARCH_X86_64_CPU_H
#define _KERNEL_ARCH_X86_64_CPU_H
#include "../x86/arch_cpu.h"
#endif /* _KERNEL_ARCH_x86_64_CPU_H */
#endif /* _KERNEL_ARCH_X86_64_CPU_H */
@@ -0,0 +1,17 @@
/*
* Copyright 2012, Alex Smith, [email protected].
* Distributed under the terms of the MIT License.
*/
#ifndef _KERNEL_ARCH_X86_64_DEBUG_H
#define _KERNEL_ARCH_X86_64_DEBUG_H
#include <SupportDefs.h>
struct arch_debug_registers {
uint64 rbp;
};
#endif /* _KERNEL_ARCH_X86_64_DEBUG_H */
+76 -4
View File
@@ -1,6 +1,78 @@
#ifndef _KERNEL_ARCH_x86_64_INT_H
#define _KERNEL_ARCH_x86_64_INT_H
/*
* Copyright 2005-2009, Axel Dörfler, [email protected].
* Copyright 2012, Alex Smith, [email protected].
* Distributed under the terms of the MIT License.
*/
#ifndef _KERNEL_ARCH_X86_64_INT_H
#define _KERNEL_ARCH_X86_64_INT_H
#include "../x86/arch_int.h"
#endif /* _KERNEL_ARCH_x86_64_INT_H */
#define ARCH_INTERRUPT_BASE 0x20
#define NUM_IO_VECTORS (256 - ARCH_INTERRUPT_BASE)
static inline void
arch_int_enable_interrupts_inline(void)
{
asm volatile("sti");
}
static inline int
arch_int_disable_interrupts_inline(void)
{
unsigned long flags;
asm volatile("pushf;\n"
"pop %0;\n"
"cli" : "=g" (flags));
return (flags & 0x200) != 0;
}
static inline void
arch_int_restore_interrupts_inline(int oldState)
{
if (oldState)
asm("sti");
}
static inline bool
arch_int_are_interrupts_enabled_inline(void)
{
unsigned long flags;
asm volatile("pushf;\n"
"pop %0;\n" : "=g" (flags));
return (flags & 0x200) != 0;
}
// map the functions to the inline versions
#define arch_int_enable_interrupts() arch_int_enable_interrupts_inline()
#define arch_int_disable_interrupts() arch_int_disable_interrupts_inline()
#define arch_int_restore_interrupts(status) \
arch_int_restore_interrupts_inline(status)
#define arch_int_are_interrupts_enabled() \
arch_int_are_interrupts_enabled_inline()
#ifdef __cplusplus
typedef struct interrupt_controller_s {
const char *name;
void (*enable_io_interrupt)(int32 num);
void (*disable_io_interrupt)(int32 num);
void (*configure_io_interrupt)(int32 num, uint32 config);
bool (*is_spurious_interrupt)(int32 num);
bool (*is_level_triggered_interrupt)(int32 num);
bool (*end_of_interrupt)(int32 num);
} interrupt_controller;
void arch_int_set_interrupt_controller(const interrupt_controller &controller);
#endif // __cplusplus
#endif /* _KERNEL_ARCH_X86_64_INT_H */
@@ -1,6 +1,6 @@
#ifndef _KERNEL_ARCH_x86_64_KERNEL_H
#define _KERNEL_ARCH_x86_64_KERNEL_H
#ifndef _KERNEL_ARCH_X86_64_KERNEL_H
#define _KERNEL_ARCH_X86_64_KERNEL_H
#include "../x86/arch_kernel.h"
#endif /* _KERNEL_ARCH_x86_64_KERNEL_H */
#endif /* _KERNEL_ARCH_X86_64_KERNEL_H */
@@ -1,6 +1,6 @@
#ifndef _KERNEL_ARCH_x86_64_KERNEL_ARGS_H
#define _KERNEL_ARCH_x86_64_KERNEL_ARGS_H
#ifndef _KERNEL_ARCH_X86_64_KERNEL_ARGS_H
#define _KERNEL_ARCH_X86_64_KERNEL_ARGS_H
#include "../x86/arch_kernel_args.h"
#endif /* _KERNEL_ARCH_x86_64_KERNEL_ARGS_H */
#endif /* _KERNEL_ARCH_X86_64_KERNEL_ARGS_H */
@@ -1,6 +1,26 @@
#ifndef _KERNEL_ARCH_x86_64_SYSTEM_INFO_H
#define _KERNEL_ARCH_x86_64_SYSTEM_INFO_H
/*
* Copyright 2004-2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
* Copyright 2012, Alex Smith, alex@alex-smith.me.uk.
* Distributed under the terms of the MIT License.
*/
#ifndef _KERNEL_ARCH_X86_64_SYSTEM_INFO_H
#define _KERNEL_ARCH_X86_64_SYSTEM_INFO_H
#include "../x86/arch_system_info.h"
#endif /* _KERNEL_ARCH_x86_64_SYSTEM_INFO_H */
#include <OS.h>
#ifdef __cplusplus
extern "C" {
#endif
//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);
#ifdef __cplusplus
}
#endif
#endif /* _KRENEL_ARCH_X86_64_SYSTEM_INFO_H */
@@ -1,6 +1,32 @@
#ifndef _KERNEL_ARCH_x86_64_THREAD_H
#define _KERNEL_ARCH_x86_64_THREAD_H
/*
* Copyright 2012, Alex Smith, alex@alex-smith.me.uk.
* Distributed under the terms of the MIT License.
*/
#ifndef _KERNEL_ARCH_X86_64_THREAD_H
#define _KERNEL_ARCH_X86_64_THREAD_H
#include "../x86/arch_thread.h"
#endif /* _KERNEL_ARCH_x86_64_THREAD_H */
#include <arch/cpu.h>
#ifdef __cplusplus
extern "C" {
#endif
static inline Thread *
arch_thread_get_current_thread(void)
{
return NULL;
}
static inline void
arch_thread_set_current_thread(Thread *t)
{
}
#ifdef __cplusplus
}
#endif
#endif /* _KERNEL_ARCH_X86_64_THREAD_H */
@@ -1,6 +1,32 @@
#ifndef _KERNEL_ARCH_x86_64_THREAD_TYPES_H
#define _KERNEL_ARCH_x86_64_THREAD_TYPES_H
/*
* Copyright 2012, Alex Smith, alex@alex-smith.me.uk.
* Distributed under the terms of the MIT License.
*/
#ifndef _KERNEL_ARCH_X86_64_THREAD_TYPES_H
#define _KERNEL_ARCH_X86_64_THREAD_TYPES_H
#include "../x86/arch_thread_types.h"
#endif /* _KERNEL_ARCH_x86_64_THREAD_TYPES_H */
#include <arch_cpu.h>
// x86_64-specific thread information.
struct arch_thread {
// Stack pointer.
addr_t rsp;
// FPU saved state - this must be 16 byte aligned.
uint8 fpu_state[512] __attribute__((aligned(16)));
} __attribute__((aligned(16)));
struct arch_team {
// gcc treats empty structures as zero-length in C, but as if they contain
// a char in C++. So we have to put a dummy in to be able to use the struct
// from both in a consistent way.
char dummy;
};
struct arch_fork_arg {
struct iframe iframe;
};
#endif /* _KERNEL_ARCH_X86_64_THREAD_TYPES_H */
@@ -1,6 +1,6 @@
#ifndef _KERNEL_ARCH_x86_64_USER_DEBUGGER_H
#define _KERNEL_ARCH_x86_64_USER_DEBUGGER_H
#ifndef _KERNEL_ARCH_X86_64_USER_DEBUGGER_H
#define _KERNEL_ARCH_X86_64_USER_DEBUGGER_H
#include "../x86/arch_user_debugger.h"
#endif /* _KERNEL_ARCH_x86_64_USER_DEBUGGER_H */
#endif /* _KERNEL_ARCH_X86_64_USER_DEBUGGER_H */
@@ -0,0 +1,16 @@
/*
* Copyright 2012, Alex Smith, alex@alex-smith.me.uk.
* Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _KERNEL_ARCH_X86_64_VM_H
#define _KERNEL_ARCH_X86_64_VM_H
/* This many pages will be read/written on I/O if possible */
#define NUM_IO_PAGES 4
/* 16 kB */
#define PAGE_SHIFT 12
#endif /* _KERNEL_ARCH_X86_64_VM_H */
@@ -0,0 +1,9 @@
/*
* Copyright 2012, Alex Smith, alex@alex-smith.me.uk.
* Distributed under the terms of the MIT License.
*/
#ifndef _KERNEL_ARCH_X86_64_VM_TRANSLATION_MAP_H
#define _KERNEL_ARCH_X86_64_VM_TRANSLATION_MAP_H
#endif /* _KERNEL_ARCH_X86_64_VM_TRANSLATION_MAP_H */
@@ -0,0 +1,9 @@
/*
* Copyright 2012, Alex Smith, alex@alex-smith.me.uk.
* Distributed under the terms of the MIT License.
*/
#ifndef _KERNEL_ARCH_X86_64_VM_TYPES_H
#define _KERNEL_ARCH_X86_64_VM_TYPES_H
#endif /* _KERNEL_ARCH_X86_64_VM_TYPES_H */
@@ -0,0 +1,15 @@
/*
* Copyright 2012, Alex Smith, alex@alex-smith.me.uk.
* Distributed under the terms of the MIT License.
*/
#ifndef _SYSTEM_ARCH_x86_64_COMMPAGE_DEFS_H
#define _SYSTEM_ARCH_x86_64_COMMPAGE_DEFS_H
#ifndef _SYSTEM_COMMPAGE_DEFS_H
# error Must not be included directly. Include <commpage_defs.h> instead!
#endif
// FIXME: correct address
#define ARCH_USER_COMMPAGE_ADDR (0xffff0000)
#endif /* _SYSTEM_ARCH_x86_64_COMMPAGE_DEFS_H */
@@ -0,0 +1,17 @@
/*
* Copyright 2006, Ingo Weinhold <bonefish@cs.tu-berlin.de>.
* All rights reserved. Distributed under the terms of the MIT License.
*/
#ifndef _KERNEL_ARCH_REAL_TIME_DATA_H
#define _KERNEL_ARCH_REAL_TIME_DATA_H
#include <StorageDefs.h>
#include <SupportDefs.h>
struct arch_real_time_data {
bigtime_t system_time_offset;
uint32 system_time_conversion_factor;
};
#endif /* _KERNEL_ARCH_REAL_TIME_DATA_H */