added 4 changesets to branch 'refs/remotes/xyzzy-github/x86_64' old head: 5670b0a8e4fe8e5504b2e57a958e1590f6024406 new head: 659bacac269ec0992603008ef436ee20505bd67f ---------------------------------------------------------------------------- 609b308: Return B_NOT_SUPPORTED for shutdown if ACPI is unavailable (no APM on x86_64). fc64410: Merge branch 'master' into x86_64 d776fd5: Implemented arch_cpu_user_*() for x86_64, based on the x86 versions. 659baca: Compile arch_real_time_clock.cpp and arch_system_info.cpp for x86_64. [ Alex Smith <alex@xxxxxxxxxxxxxxxx> ] ---------------------------------------------------------------------------- 20 files changed, 291 insertions(+), 225 deletions(-) Jamfile | 6 +- ReadMe | 7 + build/jam/BuildSetup | 7 + build/jam/OptionalBuildFeatures | 54 +++--- configure | 19 ++- headers/private/system/arch/x86_64/arch_cpu_defs.h | 12 ++ headers/private/system/syscalls.h | 2 +- .../debugger_interface/DebuggerInterface.cpp | 4 +- src/apps/screenshot/Jamfile | 1 - src/apps/screenshot/PreviewView.cpp | 30 ---- src/apps/screenshot/PreviewView.h | 21 --- src/apps/screenshot/ScreenshotWindow.cpp | 8 +- src/apps/screenshot/ScreenshotWindow.h | 3 +- src/kits/support/Archivable.cpp | 111 +++++++----- src/system/kernel/arch/x86/64/arch.S | 141 +++++++++++++++- src/system/kernel/arch/x86/64/stubs.cpp | 72 -------- src/system/kernel/arch/x86/Jamfile | 4 +- src/system/kernel/arch/x86/arch_cpu.cpp | 8 +- src/system/kernel/debug/user_debugger.cpp | 2 +- src/tests/kits/interface/look/Look.cpp | 4 +- ############################################################################ Commit: 609b308e64d28acbcac1edde134b427f648914a4 Author: Alex Smith <alex@xxxxxxxxxxxxxxxx> Date: Wed Jul 11 11:23:18 2012 UTC Return B_NOT_SUPPORTED for shutdown if ACPI is unavailable (no APM on x86_64). ---------------------------------------------------------------------------- diff --git a/src/system/kernel/arch/x86/arch_cpu.cpp b/src/system/kernel/arch/x86/arch_cpu.cpp index 10c94f6..9fe0d79 100644 --- a/src/system/kernel/arch/x86/arch_cpu.cpp +++ b/src/system/kernel/arch/x86/arch_cpu.cpp @@ -1026,11 +1026,13 @@ arch_cpu_shutdown(bool rebootSystem) if (acpi_shutdown(rebootSystem) == B_OK) return B_OK; - // TODO x86_64 -#ifndef __x86_64 - if (!rebootSystem) + if (!rebootSystem) { +#ifndef __x86_64__ return apm_shutdown(); +#else + return B_NOT_SUPPORTED; #endif + } cpu_status state = disable_interrupts(); ############################################################################ Commit: fc644104aca3b677ad2fdbc6aad44a4178b1b8d2 Author: Alex Smith <alex@xxxxxxxxxxxxxxxx> Date: Wed Jul 11 11:24:47 2012 UTC Merge branch 'master' into x86_64 ---------------------------------------------------------------------------- ############################################################################ Commit: d776fd53f7fdf12f297838ca476948bc7083c82a Author: Alex Smith <alex@xxxxxxxxxxxxxxxx> Date: Wed Jul 11 13:19:19 2012 UTC Implemented arch_cpu_user_*() for x86_64, based on the x86 versions. ---------------------------------------------------------------------------- diff --git a/src/system/kernel/arch/x86/64/arch.S b/src/system/kernel/arch/x86/64/arch.S index 4fe6573..58b4bcb 100644 --- a/src/system/kernel/arch/x86/64/arch.S +++ b/src/system/kernel/arch/x86/64/arch.S @@ -1,6 +1,12 @@ /* * Copyright 2012, Alex Smith, alex@xxxxxxxxxxxxxxxxx + * Copyright 2003-2007, Axel Dörfler, axeld@xxxxxxxxxxxxxxxxx + * Copyright 2012, Rene Gollent, rene@xxxxxxxxxxxx * Distributed under the terms of the MIT License. + * + * Copyright 2001, Travis Geiselbrecht. All rights reserved. + * Copyright 2002, Michael Noisternig. All rights reserved. + * Distributed under the terms of the NewOS License. */ @@ -78,7 +84,7 @@ FUNCTION_END(x86_64_thread_entry) /* void x86_context_switch(struct arch_thread* oldState, - struct arch_thread* newState); */ + struct arch_thread* newState); */ FUNCTION(x86_context_switch): // Just need to save callee-save registers: RBP, RBX, R12-15. push %r15 @@ -121,3 +127,136 @@ FUNCTION(x86_reboot): done: jmp done FUNCTION_END(x86_reboot) + + +/* status_t arch_cpu_user_memcpy(void* to, const void* from, size_t size, + addr_t* faultHandler) */ +FUNCTION(arch_cpu_user_memcpy): + // faultHandler -> r8, size -> rcx. + movq %rcx, %r8 + movq %rdx, %rcx + + // Set the fault handler, preserve old in rax. + movq (%r8), %rax + movq $.L_user_memcpy_error, (%r8) + + // Move by quadwords. + cld + movq %rcx, %r9 + shrq $3, %rcx + rep + movsq + + // Move any remaining data by bytes. + movq %r9, %rcx + andq $7, %rcx + rep + movsb + + // Restore the old fault handler and return. + movq %rax, (%r8) + xorl %eax, %eax + ret + +.L_user_memcpy_error: + // Restore the old fault handler. Return a generic error, the wrapper + // routine will deal with it. + movq %rax, (%r8) + movl $-1, %eax + ret +FUNCTION_END(arch_cpu_user_memcpy) + + +/* status_t arch_cpu_user_memset(void* to, char c, size_t count, + addr_t* faultHandler) */ +FUNCTION(arch_cpu_user_memset): + // c -> al, faultHandler -> r8, size -> rcx. + movw %si, %ax + movq %rcx, %r8 + movq %rdx, %rcx + + // Set the fault handler, preserve old in rdx. + movq (%r8), %rdx + movq $.L_user_memset_error, (%r8) + + rep + stosb + + // Restore the old fault handler and return. + movq %rdx, (%r8) + xorl %eax, %eax + ret + +.L_user_memset_error: + // Restore the old fault handler. Return a generic error, the wrapper + // routine will deal with it. + movq %rdx, (%r8) + movl $-1, %eax + ret +FUNCTION_END(arch_cpu_user_memset) + + +/* ssize_t arch_cpu_user_strlcpy(void* to, const void* from, size_t size, + addr_t* faultHandler) */ +FUNCTION(arch_cpu_user_strlcpy): + // faultHandler -> r8, size -> rcx, source -> r9 (original value needed to + // calculate return value). + movq %rcx, %r8 + movq %rdx, %rcx + movq %rsi, %r9 + + // Set the fault handler, preserve old in rax. + movq (%r8), %rax + movq $.L_user_strlcpy_error, (%r8) + + // Check for 0 length. + cmp $0, %rcx + je .L_user_strlcpy_source_count + + // Copy at most count - 1 bytes. + dec %rcx + + // If count is now 0, skip straight to null terminating as our loop will + // otherwise overflow. + jnz .L_user_strlcpy_copy_begin + movb $0, (%rdi) + jmp .L_user_strlcpy_source_count + +.L_user_strlcpy_copy_begin: + cld +.L_user_strlcpy_copy_loop: + // Move data by bytes. + lodsb + stosb + test %al, %al + jz .L_user_strlcpy_source_done + loop .L_user_strlcpy_copy_loop + + // Null terminate string. + movb $0, (%rdi) + dec %rsi + +.L_user_strlcpy_source_count: + // Count remaining bytes in src + not %rcx + xor %al, %al + repnz + scasb + +.L_user_strlcpy_source_done: + // Restore the old fault handler + movq %rax, (%r8) + + // Calculate total string length and return. + movq %rsi, %rax + subq %r9, %rax + dec %rax + ret + +.L_user_strlcpy_error: + // Restore the old fault handler. Return a generic error, the wrapper + // routine will deal with it. + movq %rax, (%r8) + movq $-1, %rax + ret +FUNCTION_END(arch_cpu_user_strlcpy) diff --git a/src/system/kernel/arch/x86/64/stubs.cpp b/src/system/kernel/arch/x86/64/stubs.cpp index 2651c32..e4a02c9 100644 --- a/src/system/kernel/arch/x86/64/stubs.cpp +++ b/src/system/kernel/arch/x86/64/stubs.cpp @@ -51,29 +51,6 @@ arch_commpage_init_post_cpus(void) } -ssize_t -arch_cpu_user_strlcpy(char* to, const char* from, size_t size, - addr_t* faultHandler) -{ - return B_BAD_ADDRESS; -} - - -status_t -arch_cpu_user_memcpy(void* to, const void* from, size_t size, - addr_t* faultHandler) -{ - return B_BAD_ADDRESS; -} - - -status_t -arch_cpu_user_memset(void* s, char c, size_t count, addr_t* faultHandler) -{ - return B_BAD_ADDRESS; -} - - void arch_debug_save_registers(struct arch_debug_registers* registers) { ############################################################################ Commit: 659bacac269ec0992603008ef436ee20505bd67f Author: Alex Smith <alex@xxxxxxxxxxxxxxxx> Date: Wed Jul 11 13:43:44 2012 UTC Compile arch_real_time_clock.cpp and arch_system_info.cpp for x86_64. ---------------------------------------------------------------------------- diff --git a/headers/private/system/arch/x86_64/arch_cpu_defs.h b/headers/private/system/arch/x86_64/arch_cpu_defs.h new file mode 100644 index 0000000..e10ef98 --- /dev/null +++ b/headers/private/system/arch/x86_64/arch_cpu_defs.h @@ -0,0 +1,12 @@ +/* + * Copyright 2010, Ingo Weinhold, ingo_weinhold@xxxxxxx + * Distributed under the terms of the MIT License. + */ +#ifndef _SYSTEM_ARCH_X86_DEFS_H +#define _SYSTEM_ARCH_X86_DEFS_H + + +#define SPINLOCK_PAUSE() asm volatile("pause;") + + +#endif /* _SYSTEM_ARCH_X86_DEFS_H */ diff --git a/headers/private/system/syscalls.h b/headers/private/system/syscalls.h index 81cd20c..17f9b73 100644 --- a/headers/private/system/syscalls.h +++ b/headers/private/system/syscalls.h @@ -534,7 +534,7 @@ extern void _kern_clear_caches(void *address, size_t length, extern bool _kern_cpu_enabled(int32 cpu); extern status_t _kern_set_cpu_enabled(int32 cpu, bool enabled); -#ifdef __INTEL__ +#if defined(__INTEL__) || defined(__x86_64__) // our only x86 only syscall extern status_t _kern_get_cpuid(cpuid_info *info, uint32 eax, uint32 cpu); #endif diff --git a/src/system/kernel/arch/x86/64/stubs.cpp b/src/system/kernel/arch/x86/64/stubs.cpp index e4a02c9..813e00c 100644 --- a/src/system/kernel/arch/x86/64/stubs.cpp +++ b/src/system/kernel/arch/x86/64/stubs.cpp @@ -271,41 +271,6 @@ arch_debug_call_with_fault_handler(cpu_ent* cpu, jmp_buf jumpBuffer, status_t -arch_rtc_init(struct kernel_args *args, struct real_time_data *data) -{ - return B_OK; -} - - -uint32 -arch_rtc_get_hw_time(void) -{ - return 0; -} - - -void -arch_rtc_set_hw_time(uint32 seconds) -{ - -} - - -void -arch_rtc_set_system_time_offset(struct real_time_data *data, bigtime_t offset) -{ - -} - - -bigtime_t -arch_rtc_get_system_time_offset(struct real_time_data *data) -{ - return 0; -} - - -status_t arch_smp_init(kernel_args *args) { return B_OK; @@ -333,20 +298,6 @@ arch_smp_send_ici(int32 target_cpu) } -status_t -arch_get_system_info(system_info *info, size_t size) -{ - return B_OK; -} - - -status_t -arch_system_info_init(struct kernel_args *args) -{ - return B_OK; -} - - // The software breakpoint instruction (int3). const uint8 kX86SoftwareBreakpoint[1] = { 0xcc }; diff --git a/src/system/kernel/arch/x86/Jamfile b/src/system/kernel/arch/x86/Jamfile index 0fac1a0..014c713 100644 --- a/src/system/kernel/arch/x86/Jamfile +++ b/src/system/kernel/arch/x86/Jamfile @@ -48,9 +48,7 @@ if $(TARGET_ARCH) = x86_64 { arch_commpage.cpp arch_debug.cpp - arch_real_time_clock.cpp arch_smp.cpp - arch_system_info.cpp arch_user_debugger.cpp apm.cpp bios.cpp @@ -84,6 +82,8 @@ local archGenericSources = arch_elf.cpp arch_int.cpp arch_platform.cpp + arch_real_time_clock.cpp + arch_system_info.cpp arch_thread.cpp arch_timer.cpp arch_vm.cpp