Added some libroot bits for x86_64.
Still some parts missing (the glibc bits + fenv.c), plus the TLS functions are only stubs.
This commit is contained in:
parent
aef19e3c95
commit
fd9f32c0db
17
src/system/libroot/os/arch/x86_64/Jamfile
Normal file
17
src/system/libroot/os/arch/x86_64/Jamfile
Normal file
@ -0,0 +1,17 @@
|
||||
SubDir HAIKU_TOP src system libroot os arch x86_64 ;
|
||||
|
||||
UsePrivateKernelHeaders ;
|
||||
# TODO: Replace by "UsePrivateHeaders libroot" after resolving the TODO in
|
||||
# time.c!
|
||||
UsePrivateSystemHeaders ;
|
||||
|
||||
MergeObject os_arch_$(TARGET_ARCH).o :
|
||||
atomic.S
|
||||
byteorder.S
|
||||
get_stack_frame.S
|
||||
system_info.cpp
|
||||
system_time_asm.S
|
||||
thread.cpp
|
||||
time.cpp
|
||||
tls.cpp
|
||||
;
|
22
src/system/libroot/os/arch/x86_64/get_stack_frame.S
Normal file
22
src/system/libroot/os/arch/x86_64/get_stack_frame.S
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright 2012, Alex Smith, alex@alex-smith.me.uk.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include <asm_defs.h>
|
||||
|
||||
|
||||
/* void* get_stack_frame(void) */
|
||||
FUNCTION(get_stack_frame):
|
||||
movq %rbp, %rax
|
||||
ret
|
||||
FUNCTION_END(get_stack_frame)
|
||||
|
||||
|
||||
/* void* __arch_get_caller(void); */
|
||||
FUNCTION(__arch_get_caller):
|
||||
movq 8(%rbp), %rax
|
||||
ret
|
||||
FUNCTION_END(__arch_get_caller)
|
||||
|
46
src/system/libroot/os/arch/x86_64/syscalls.inc
Normal file
46
src/system/libroot/os/arch/x86_64/syscalls.inc
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright 2012, Alex Smith, alex@alex-smith.me.uk.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include <asm_defs.h>
|
||||
|
||||
|
||||
// The kernel follows the AMD64 ABI for parameter passing (first 6 arguments in
|
||||
// registers and the remaining ones in on the stack), except that RCX is used
|
||||
// by SYSCALL so it is moved to R10. Syscall number goes in RAX.
|
||||
|
||||
|
||||
#define _SYSCALL(name, n) \
|
||||
.align 8; \
|
||||
FUNCTION(name): \
|
||||
movq %rcx, %r10; \
|
||||
movq $n, %rax; \
|
||||
syscall; \
|
||||
ret; \
|
||||
FUNCTION_END(name)
|
||||
|
||||
|
||||
#define SYSCALL0(name, n) _SYSCALL(name, n)
|
||||
#define SYSCALL1(name, n) _SYSCALL(name, n)
|
||||
#define SYSCALL2(name, n) _SYSCALL(name, n)
|
||||
#define SYSCALL3(name, n) _SYSCALL(name, n)
|
||||
#define SYSCALL4(name, n) _SYSCALL(name, n)
|
||||
#define SYSCALL5(name, n) _SYSCALL(name, n)
|
||||
#define SYSCALL6(name, n) _SYSCALL(name, n)
|
||||
#define SYSCALL7(name, n) _SYSCALL(name, n)
|
||||
#define SYSCALL8(name, n) _SYSCALL(name, n)
|
||||
#define SYSCALL9(name, n) _SYSCALL(name, n)
|
||||
#define SYSCALL10(name, n) _SYSCALL(name, n)
|
||||
#define SYSCALL11(name, n) _SYSCALL(name, n)
|
||||
#define SYSCALL12(name, n) _SYSCALL(name, n)
|
||||
#define SYSCALL13(name, n) _SYSCALL(name, n)
|
||||
#define SYSCALL14(name, n) _SYSCALL(name, n)
|
||||
#define SYSCALL15(name, n) _SYSCALL(name, n)
|
||||
#define SYSCALL16(name, n) _SYSCALL(name, n)
|
||||
#define SYSCALL17(name, n) _SYSCALL(name, n)
|
||||
#define SYSCALL18(name, n) _SYSCALL(name, n)
|
||||
#define SYSCALL19(name, n) _SYSCALL(name, n)
|
||||
#define SYSCALL20(name, n) _SYSCALL(name, n)
|
||||
|
16
src/system/libroot/os/arch/x86_64/system_info.cpp
Normal file
16
src/system/libroot/os/arch/x86_64/system_info.cpp
Normal file
@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Copyright 2003-2004, Axel Dörfler, axeld@pinc-software.de.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include <OS.h>
|
||||
#include <syscalls.h>
|
||||
|
||||
|
||||
status_t
|
||||
get_cpuid(cpuid_info* info, uint32 eaxRegister, uint32 cpuNum)
|
||||
{
|
||||
return _kern_get_cpuid(info, eaxRegister, cpuNum);
|
||||
}
|
||||
|
18
src/system/libroot/os/arch/x86_64/thread.cpp
Normal file
18
src/system/libroot/os/arch/x86_64/thread.cpp
Normal file
@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright 2012, Alex Smith, alex@alex-smith.me.uk.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include <OS.h>
|
||||
#include "syscalls.h"
|
||||
|
||||
|
||||
thread_id
|
||||
find_thread(const char* name)
|
||||
{
|
||||
// TODO x86_64: x86 is doing some TLS thing here. Should that be done here
|
||||
// too?
|
||||
return _kern_find_thread(name);
|
||||
}
|
||||
|
44
src/system/libroot/os/arch/x86_64/time.cpp
Normal file
44
src/system/libroot/os/arch/x86_64/time.cpp
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright 2004, Axel Dörfler, axeld@pinc-software.de.
|
||||
* Copyright 2012, Alex Smith, alex@alex-smith.me.uk.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include <libroot_private.h>
|
||||
#include <real_time_data.h>
|
||||
#include <arch_cpu.h>
|
||||
|
||||
|
||||
void
|
||||
__arch_init_time(real_time_data* data, bool setDefaults)
|
||||
{
|
||||
uint32 conversionFactor;
|
||||
uint64 conversionFactorNsecs;
|
||||
|
||||
if (setDefaults) {
|
||||
data->arch_data.system_time_offset = 0;
|
||||
data->arch_data.system_time_conversion_factor = 100000;
|
||||
}
|
||||
|
||||
// TODO: this should only store a pointer to that value
|
||||
// When resolving this TODO, also resolve the one in the Jamfile.
|
||||
|
||||
conversionFactor = data->arch_data.system_time_conversion_factor;
|
||||
conversionFactorNsecs = (uint64)conversionFactor * 1000;
|
||||
|
||||
// The x86_64 system_time() implementation uses 64-bit multiplication and
|
||||
// therefore shifting is not necessary for low frequencies (it's also not
|
||||
// too likely that there'll be any x86_64 CPUs clocked under 1GHz).
|
||||
__x86_setup_system_time((uint64)conversionFactor << 32,
|
||||
conversionFactorNsecs);
|
||||
}
|
||||
|
||||
|
||||
bigtime_t
|
||||
__arch_get_system_time_offset(struct real_time_data *data)
|
||||
{
|
||||
//we don't use atomic_get64 because memory is read-only, maybe find another way to lock
|
||||
return data->arch_data.system_time_offset;
|
||||
}
|
||||
|
50
src/system/libroot/os/arch/x86_64/tls.cpp
Normal file
50
src/system/libroot/os/arch/x86_64/tls.cpp
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright 2012, Alex Smith, alex@alex-smith.me.uk.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
// TODO x86_64.
|
||||
// Also want to add inline versions to support/TLS.h.
|
||||
|
||||
|
||||
#ifndef _NO_INLINE_ASM
|
||||
# define _NO_INLINE_ASM 1
|
||||
#endif
|
||||
|
||||
#include <support/TLS.h>
|
||||
#include <tls.h>
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
int32
|
||||
tls_allocate(void)
|
||||
{
|
||||
assert(0 && "tls_allocate: not implemented");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void*
|
||||
tls_get(int32 index)
|
||||
{
|
||||
assert(0 && "tls_get: not implemented");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
void**
|
||||
tls_address(int32 index)
|
||||
{
|
||||
assert(0 && "tls_address: not implemented");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
tls_set(int32 index, void* value)
|
||||
{
|
||||
assert(0 && "tls_set: not implemented");
|
||||
}
|
||||
|
@ -1,6 +1,9 @@
|
||||
#ifdef ARCH_x86
|
||||
# include "arch/x86/syscalls.inc"
|
||||
#endif
|
||||
#ifdef ARCH_x86_64
|
||||
# include "arch/x86_64/syscalls.inc"
|
||||
#endif
|
||||
#ifdef ARCH_alpha
|
||||
# include "arch/alpha/syscalls.inc"
|
||||
#endif
|
||||
|
19
src/system/libroot/posix/arch/x86_64/Jamfile
Normal file
19
src/system/libroot/posix/arch/x86_64/Jamfile
Normal file
@ -0,0 +1,19 @@
|
||||
SubDir HAIKU_TOP src system libroot posix arch x86_64 ;
|
||||
|
||||
UsePrivateSystemHeaders ;
|
||||
|
||||
local genericSources =
|
||||
setjmp_save_sigs.c
|
||||
longjmp_return.c
|
||||
;
|
||||
|
||||
MergeObject posix_arch_$(TARGET_ARCH).o :
|
||||
#fenv.c
|
||||
sigsetjmp.S
|
||||
siglongjmp.S
|
||||
|
||||
$(genericSources)
|
||||
;
|
||||
|
||||
SEARCH on [ FGristFiles $(genericSources) ]
|
||||
= [ FDirName $(SUBDIR) $(DOTDOT) generic ] ;
|
8
src/system/libroot/posix/string/arch/x86_64/Jamfile
Normal file
8
src/system/libroot/posix/string/arch/x86_64/Jamfile
Normal file
@ -0,0 +1,8 @@
|
||||
SubDir HAIKU_TOP src system libroot posix string arch x86_64 ;
|
||||
|
||||
UsePrivateSystemHeaders ;
|
||||
|
||||
MergeObject posix_string_arch_$(TARGET_ARCH).o :
|
||||
arch_string.S
|
||||
;
|
||||
|
17
src/system/libroot/posix/string/arch/x86_64/arch_string.S
Normal file
17
src/system/libroot/posix/string/arch/x86_64/arch_string.S
Normal file
@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright 2008, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
#include <asm_defs.h>
|
||||
#include <commpage_defs.h>
|
||||
|
||||
|
||||
FUNCTION(memcpy):
|
||||
jmp *(USER_COMMPAGE_ADDR + COMMPAGE_ENTRY_X86_MEMCPY * 8)
|
||||
FUNCTION_END(memcpy)
|
||||
|
||||
|
||||
FUNCTION(memset):
|
||||
jmp *(USER_COMMPAGE_ADDR + COMMPAGE_ENTRY_X86_MEMSET * 8)
|
||||
FUNCTION_END(memset)
|
Loading…
Reference in New Issue
Block a user