diff --git a/headers/os/arch/x86_64/arch_debugger.h b/headers/os/arch/x86_64/arch_debugger.h new file mode 100644 index 0000000000..5b9220b340 --- /dev/null +++ b/headers/os/arch/x86_64/arch_debugger.h @@ -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 diff --git a/headers/os/kernel/debugger.h b/headers/os/kernel/debugger.h index 5b86c706d0..c443b3977a 100644 --- a/headers/os/kernel/debugger.h +++ b/headers/os/kernel/debugger.h @@ -13,13 +13,16 @@ // include architecture specific definitions #include +#include #include #include #include #include -#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; diff --git a/headers/private/kernel/arch/x86_64/arch_cpu.h b/headers/private/kernel/arch/x86_64/arch_cpu.h index dfdfe6ad73..f1d56b9fb5 100644 --- a/headers/private/kernel/arch/x86_64/arch_cpu.h +++ b/headers/private/kernel/arch/x86_64/arch_cpu.h @@ -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 */ diff --git a/headers/private/kernel/arch/x86_64/arch_debug.h b/headers/private/kernel/arch/x86_64/arch_debug.h new file mode 100644 index 0000000000..6f06f95458 --- /dev/null +++ b/headers/private/kernel/arch/x86_64/arch_debug.h @@ -0,0 +1,17 @@ +/* + * Copyright 2012, Alex Smith, alex@alex-smith.me.uk. + * Distributed under the terms of the MIT License. + */ +#ifndef _KERNEL_ARCH_X86_64_DEBUG_H +#define _KERNEL_ARCH_X86_64_DEBUG_H + + +#include + + +struct arch_debug_registers { + uint64 rbp; +}; + + +#endif /* _KERNEL_ARCH_X86_64_DEBUG_H */ diff --git a/headers/private/kernel/arch/x86_64/arch_int.h b/headers/private/kernel/arch/x86_64/arch_int.h index cd1f423f15..9507d6de6d 100644 --- a/headers/private/kernel/arch/x86_64/arch_int.h +++ b/headers/private/kernel/arch/x86_64/arch_int.h @@ -1,6 +1,78 @@ -#ifndef _KERNEL_ARCH_x86_64_INT_H -#define _KERNEL_ARCH_x86_64_INT_H +/* + * Copyright 2005-2009, Axel Dörfler, axeld@pinc-software.de. + * Copyright 2012, Alex Smith, alex@alex-smith.me.uk. + * 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 */ diff --git a/headers/private/kernel/arch/x86_64/arch_kernel.h b/headers/private/kernel/arch/x86_64/arch_kernel.h index 40d55a3ac4..a7e45b34e7 100644 --- a/headers/private/kernel/arch/x86_64/arch_kernel.h +++ b/headers/private/kernel/arch/x86_64/arch_kernel.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 */ diff --git a/headers/private/kernel/arch/x86_64/arch_kernel_args.h b/headers/private/kernel/arch/x86_64/arch_kernel_args.h index ecb2638c9a..78c54547e0 100644 --- a/headers/private/kernel/arch/x86_64/arch_kernel_args.h +++ b/headers/private/kernel/arch/x86_64/arch_kernel_args.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 */ diff --git a/headers/private/kernel/arch/x86_64/arch_system_info.h b/headers/private/kernel/arch/x86_64/arch_system_info.h index aeee330486..9137e0765f 100644 --- a/headers/private/kernel/arch/x86_64/arch_system_info.h +++ b/headers/private/kernel/arch/x86_64/arch_system_info.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 + +#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 */ diff --git a/headers/private/kernel/arch/x86_64/arch_thread.h b/headers/private/kernel/arch/x86_64/arch_thread.h index 0776b2865c..80f200a8c5 100644 --- a/headers/private/kernel/arch/x86_64/arch_thread.h +++ b/headers/private/kernel/arch/x86_64/arch_thread.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 + + +#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 */ diff --git a/headers/private/kernel/arch/x86_64/arch_thread_types.h b/headers/private/kernel/arch/x86_64/arch_thread_types.h index f0dc013900..299371691a 100644 --- a/headers/private/kernel/arch/x86_64/arch_thread_types.h +++ b/headers/private/kernel/arch/x86_64/arch_thread_types.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 + + +// 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 */ diff --git a/headers/private/kernel/arch/x86_64/arch_user_debugger.h b/headers/private/kernel/arch/x86_64/arch_user_debugger.h index 9491ef5013..9053ec5e62 100644 --- a/headers/private/kernel/arch/x86_64/arch_user_debugger.h +++ b/headers/private/kernel/arch/x86_64/arch_user_debugger.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 */ diff --git a/headers/private/kernel/arch/x86_64/arch_vm.h b/headers/private/kernel/arch/x86_64/arch_vm.h new file mode 100644 index 0000000000..033d97d78b --- /dev/null +++ b/headers/private/kernel/arch/x86_64/arch_vm.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 */ diff --git a/headers/private/kernel/arch/x86_64/arch_vm_translation_map.h b/headers/private/kernel/arch/x86_64/arch_vm_translation_map.h new file mode 100644 index 0000000000..98575cbe4c --- /dev/null +++ b/headers/private/kernel/arch/x86_64/arch_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_TRANSLATION_MAP_H +#define _KERNEL_ARCH_X86_64_VM_TRANSLATION_MAP_H + + +#endif /* _KERNEL_ARCH_X86_64_VM_TRANSLATION_MAP_H */ diff --git a/headers/private/kernel/arch/x86_64/arch_vm_types.h b/headers/private/kernel/arch/x86_64/arch_vm_types.h new file mode 100644 index 0000000000..ab090369bc --- /dev/null +++ b/headers/private/kernel/arch/x86_64/arch_vm_types.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 */ diff --git a/headers/private/system/arch/x86_64/arch_commpage_defs.h b/headers/private/system/arch/x86_64/arch_commpage_defs.h new file mode 100644 index 0000000000..b2e2aff947 --- /dev/null +++ b/headers/private/system/arch/x86_64/arch_commpage_defs.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 instead! +#endif + +// FIXME: correct address +#define ARCH_USER_COMMPAGE_ADDR (0xffff0000) + +#endif /* _SYSTEM_ARCH_x86_64_COMMPAGE_DEFS_H */ diff --git a/headers/private/system/arch/x86_64/arch_real_time_data.h b/headers/private/system/arch/x86_64/arch_real_time_data.h new file mode 100644 index 0000000000..d6350c39f2 --- /dev/null +++ b/headers/private/system/arch/x86_64/arch_real_time_data.h @@ -0,0 +1,17 @@ +/* + * Copyright 2006, Ingo Weinhold . + * 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 +#include + + +struct arch_real_time_data { + bigtime_t system_time_offset; + uint32 system_time_conversion_factor; +}; + +#endif /* _KERNEL_ARCH_REAL_TIME_DATA_H */ diff --git a/src/system/kernel/arch/x86_64/Jamfile b/src/system/kernel/arch/x86_64/Jamfile new file mode 100644 index 0000000000..5f05fb5103 --- /dev/null +++ b/src/system/kernel/arch/x86_64/Jamfile @@ -0,0 +1,21 @@ +SubDir HAIKU_TOP src system kernel arch x86_64 ; + +SubDirHdrs [ FDirName $(TARGET_COMMON_DEBUG_OBJECT_DIR) system kernel ] ; + # for syscall_numbers.h + +UsePrivateKernelHeaders ; +UsePrivateHeaders shared ; + +KernelMergeObject kernel_arch_x86_64.o : + arch_cpu.cpp + : + $(TARGET_KERNEL_PIC_CCFLAGS) +; + +CreateAsmStructOffsetsHeader asm_offsets.h : asm_offsets.cpp ; + +# We need to specify the dependency on the generated syscalls file explicitly. +#Includes [ FGristFiles arch_x86.S arch_interrupts.S ] +# : syscall_numbers.h ; +#Includes [ FGristFiles arch_interrupts.S ] +# : syscall_table.h ; diff --git a/src/system/kernel/arch/x86_64/arch_cpu.cpp b/src/system/kernel/arch/x86_64/arch_cpu.cpp new file mode 100644 index 0000000000..0138f06af8 --- /dev/null +++ b/src/system/kernel/arch/x86_64/arch_cpu.cpp @@ -0,0 +1,164 @@ +/* + * Copyright 2012, Alex Smith, alex@alex-smith.me.uk + * Distributed under the terms of the MIT License. + */ + + +#include + +#include + +// #pragma mark - + + +status_t +arch_cpu_preboot_init_percpu(kernel_args *args, int cpu) +{ + return B_OK; +} + + +status_t +arch_cpu_init_percpu(kernel_args *args, int cpu) +{ + return B_OK; +} + + +status_t +arch_cpu_init(kernel_args *args) +{ + return B_OK; +} + + +status_t +arch_cpu_init_post_vm(kernel_args *args) +{ + return B_OK; +} + + +status_t +arch_cpu_init_post_modules(kernel_args *args) +{ + return B_OK; +} + + +void +arch_cpu_global_TLB_invalidate(void) +{ + +} + + +void +arch_cpu_invalidate_TLB_range(addr_t start, addr_t end) +{ + +} + + +void +arch_cpu_invalidate_TLB_list(addr_t pages[], int num_pages) +{ + +} + + +ssize_t +arch_cpu_user_strlcpy(char *to, const char *from, size_t size, + addr_t *faultHandler) +{ + int fromLength = 0; + addr_t oldFaultHandler = *faultHandler; + + // this check is to trick the gcc4 compiler and have it keep the error label + if (to == NULL && size > 0) + goto error; + + *faultHandler = (addr_t)&&error; + + if (size > 0) { + to[--size] = '\0'; + // copy + for ( ; size; size--, fromLength++, to++, from++) { + if ((*to = *from) == '\0') + break; + } + } + // count any leftover from chars + while (*from++ != '\0') { + fromLength++; + } + + *faultHandler = oldFaultHandler; + return fromLength; + +error: + *faultHandler = oldFaultHandler; + return B_BAD_ADDRESS; +} + + +status_t +arch_cpu_user_memset(void *s, char c, size_t count, addr_t *faultHandler) +{ + char *xs = (char *)s; + addr_t oldFaultHandler = *faultHandler; + + // this check is to trick the gcc4 compiler and have it keep the error label + if (s == NULL) + goto error; + + *faultHandler = (addr_t)&&error; + + while (count--) + *xs++ = c; + + *faultHandler = oldFaultHandler; + return 0; + +error: + *faultHandler = oldFaultHandler; + return B_BAD_ADDRESS; +} + + +status_t +arch_cpu_shutdown(bool rebootSystem) +{ + return B_ERROR; +} + + +void +arch_cpu_idle(void) +{ + asm("hlt"); +} + + +void +arch_cpu_sync_icache(void *address, size_t length) +{ + // instruction cache is always consistent on x86 +} + + +void +arch_cpu_memory_read_barrier(void) +{ + asm volatile ("lock;" : : : "memory"); + asm volatile ("addl $0, 0(%%esp);" : : : "memory"); +} + + +void +arch_cpu_memory_write_barrier(void) +{ + asm volatile ("lock;" : : : "memory"); + asm volatile ("addl $0, 0(%%esp);" : : : "memory"); +} + diff --git a/src/system/kernel/arch/x86_64/asm_offsets.cpp b/src/system/kernel/arch/x86_64/asm_offsets.cpp new file mode 100644 index 0000000000..1ac18010a4 --- /dev/null +++ b/src/system/kernel/arch/x86_64/asm_offsets.cpp @@ -0,0 +1,88 @@ +/* + * Copyright 2007-2011, Ingo Weinhold, ingo_weinhold@gmx.de. + * Distributed under the terms of the MIT License. + */ + +// This file is used to get C structure offsets into assembly code. +// The build system assembles the file and processes the output to create +// a header file with macro definitions, that can be included from assembly +// code. + + +#include + +//#include +//#include +//#include +//#include +//#include + + +#define DEFINE_MACRO(macro, value) DEFINE_COMPUTED_ASM_MACRO(macro, value) + +#define DEFINE_OFFSET_MACRO(prefix, structure, member) \ + DEFINE_MACRO(prefix##_##member, offsetof(struct structure, member)); + +#define DEFINE_SIZEOF_MACRO(prefix, structure) \ + DEFINE_MACRO(prefix##_sizeof, sizeof(struct structure)); + + +void +dummy() +{ + // struct cpu_ent + //DEFINE_OFFSET_MACRO(CPU_ENT, cpu_ent, fault_handler); + //DEFINE_OFFSET_MACRO(CPU_ENT, cpu_ent, fault_handler_stack_pointer); + + // struct Thread + //DEFINE_OFFSET_MACRO(THREAD, Thread, time_lock); + //DEFINE_OFFSET_MACRO(THREAD, Thread, kernel_time); + //DEFINE_OFFSET_MACRO(THREAD, Thread, user_time); + //DEFINE_OFFSET_MACRO(THREAD, Thread, last_time); + //DEFINE_OFFSET_MACRO(THREAD, Thread, in_kernel); + //DEFINE_OFFSET_MACRO(THREAD, Thread, flags); + //DEFINE_OFFSET_MACRO(THREAD, Thread, kernel_stack_top); + //DEFINE_OFFSET_MACRO(THREAD, Thread, fault_handler); + + // struct iframe + //DEFINE_SIZEOF_MACRO(IFRAME, iframe); + //DEFINE_OFFSET_MACRO(IFRAME, iframe, cs); + //DEFINE_OFFSET_MACRO(IFRAME, iframe, eax); + //DEFINE_OFFSET_MACRO(IFRAME, iframe, edx); + //DEFINE_OFFSET_MACRO(IFRAME, iframe, orig_eax); + //DEFINE_OFFSET_MACRO(IFRAME, iframe, vector); + //DEFINE_OFFSET_MACRO(IFRAME, iframe, eip); + //DEFINE_OFFSET_MACRO(IFRAME, iframe, flags); + //DEFINE_OFFSET_MACRO(IFRAME, iframe, user_esp); + + // struct vm86_iframe + //DEFINE_SIZEOF_MACRO(VM86_IFRAME, vm86_iframe); + //DEFINE_OFFSET_MACRO(VM86_IFRAME, vm86_iframe, flags); + + // struct syscall_info + //DEFINE_SIZEOF_MACRO(SYSCALL_INFO, syscall_info); + //DEFINE_OFFSET_MACRO(SYSCALL_INFO, syscall_info, function); + //DEFINE_OFFSET_MACRO(SYSCALL_INFO, syscall_info, parameter_size); + + // struct x86_optimized_functions + //DEFINE_OFFSET_MACRO(X86_OPTIMIZED_FUNCTIONS, x86_optimized_functions, + // memcpy); + //DEFINE_OFFSET_MACRO(X86_OPTIMIZED_FUNCTIONS, x86_optimized_functions, + // memset); + + // struct signal_frame_data + //DEFINE_SIZEOF_MACRO(SIGNAL_FRAME_DATA, signal_frame_data); + //DEFINE_OFFSET_MACRO(SIGNAL_FRAME_DATA, signal_frame_data, info); + //DEFINE_OFFSET_MACRO(SIGNAL_FRAME_DATA, signal_frame_data, context); + //DEFINE_OFFSET_MACRO(SIGNAL_FRAME_DATA, signal_frame_data, user_data); + //DEFINE_OFFSET_MACRO(SIGNAL_FRAME_DATA, signal_frame_data, handler); + + // struct ucontext_t + //DEFINE_OFFSET_MACRO(UCONTEXT_T, __ucontext_t, uc_mcontext); + + // struct vregs + //DEFINE_SIZEOF_MACRO(VREGS, vregs); + + // struct siginfo_t + //DEFINE_OFFSET_MACRO(SIGINFO_T, __siginfo_t, si_signo); +} diff --git a/src/system/kernel/lib/arch/x86_64/Jamfile b/src/system/kernel/lib/arch/x86_64/Jamfile new file mode 100644 index 0000000000..2e43cfd19a --- /dev/null +++ b/src/system/kernel/lib/arch/x86_64/Jamfile @@ -0,0 +1,30 @@ +SubDir HAIKU_TOP src system kernel lib arch x86_64 ; + +SEARCH_SOURCE += [ FDirName $(SUBDIR) $(DOTDOT) generic ] ; + +local librootSources = [ FDirName $(HAIKU_TOP) src system libroot ] ; +local posixSources = [ FDirName $(librootSources) posix ] ; + +SEARCH_SOURCE += [ FDirName $(librootSources) os arch $(TARGET_ARCH) ] ; + +KernelMergeObject kernel_os_arch_$(TARGET_ARCH).o : + atomic.S + byteorder.S + system_time_asm.S + system_time.c + + : $(TARGET_KERNEL_PIC_CCFLAGS) +; + +SEARCH_SOURCE += [ FDirName $(posixSources) arch $(TARGET_ARCH) ] ; + +KernelMergeObject kernel_lib_posix_arch_$(TARGET_ARCH).o : + siglongjmp.S + sigsetjmp.S + kernel_longjmp_return.c + kernel_setjmp_save_sigs.c + + arch_string.cpp + + : $(TARGET_KERNEL_PIC_CCFLAGS) +; diff --git a/src/system/kernel/lib/arch/x86_64/arch_string.cpp b/src/system/kernel/lib/arch/x86_64/arch_string.cpp new file mode 100644 index 0000000000..0c7e8a79c7 --- /dev/null +++ b/src/system/kernel/lib/arch/x86_64/arch_string.cpp @@ -0,0 +1,36 @@ +/* + * Copyright 2012, Alex Smith, alex@alex-smith.me.uk. + * Distributed under the terms of the MIT License. +*/ + +// TODO: Replace these with optimized implementations. + + +#include + + +void * +memcpy(void *dest, const void *src, size_t count) +{ + const unsigned char *s = src; + unsigned char *d = dest; + + for (; count != 0; count--) { + *d++ = *s++; + } + + return dest; +} + + +void * +memset(void *dest, int val, size_t count) +{ + unsigned char *d = dest; + + for (; count != 0; count--) { + *d++ = static_cast(val); + } + + return dest; +}