From 043c61dde5b257e2e094ffb2df82a303d234e5b4 Mon Sep 17 00:00:00 2001 From: Alex Smith Date: Fri, 15 Jun 2012 22:50:59 +0100 Subject: [PATCH] Added stub versions of everything needed to build the kernel. The whole kernel now builds and there are no undefined references when linking, I just need to fix some strange relocation errors I'm getting (probably a problem with the linker script) and then I'll have a kernel image. --- headers/private/kernel/arch/x86_64/arch_int.h | 2 +- src/system/kernel/arch/x86_64/Jamfile | 14 +++ .../kernel/arch/x86_64/arch_commpage.cpp | 21 ++++ src/system/kernel/arch/x86_64/arch_cpu.cpp | 42 ++++++- src/system/kernel/arch/x86_64/arch_debug.cpp | 102 +++++++++++++++++ .../kernel/arch/x86_64/arch_debug_console.cpp | 91 +++++++++++++++ src/system/kernel/arch/x86_64/arch_elf.cpp | 82 ++++++++++++++ src/system/kernel/arch/x86_64/arch_int.cpp | 58 ++++++++++ .../kernel/arch/x86_64/arch_platform.cpp | 35 ++++++ .../arch/x86_64/arch_real_time_clock.cpp | 45 ++++++++ src/system/kernel/arch/x86_64/arch_smp.cpp | 37 ++++++ .../kernel/arch/x86_64/arch_system_info.cpp | 21 ++++ src/system/kernel/arch/x86_64/arch_thread.cpp | 104 +++++++++++++++++ src/system/kernel/arch/x86_64/arch_timer.cpp | 30 +++++ .../kernel/arch/x86_64/arch_user_debugger.cpp | 106 ++++++++++++++++++ src/system/kernel/arch/x86_64/arch_vm.cpp | 66 +++++++++++ .../arch/x86_64/arch_vm_translation_map.cpp | 52 +++++++++ 17 files changed, 904 insertions(+), 4 deletions(-) create mode 100644 src/system/kernel/arch/x86_64/arch_commpage.cpp create mode 100644 src/system/kernel/arch/x86_64/arch_debug.cpp create mode 100644 src/system/kernel/arch/x86_64/arch_debug_console.cpp create mode 100644 src/system/kernel/arch/x86_64/arch_elf.cpp create mode 100644 src/system/kernel/arch/x86_64/arch_int.cpp create mode 100644 src/system/kernel/arch/x86_64/arch_platform.cpp create mode 100644 src/system/kernel/arch/x86_64/arch_real_time_clock.cpp create mode 100644 src/system/kernel/arch/x86_64/arch_smp.cpp create mode 100644 src/system/kernel/arch/x86_64/arch_system_info.cpp create mode 100644 src/system/kernel/arch/x86_64/arch_thread.cpp create mode 100644 src/system/kernel/arch/x86_64/arch_timer.cpp create mode 100644 src/system/kernel/arch/x86_64/arch_user_debugger.cpp create mode 100644 src/system/kernel/arch/x86_64/arch_vm.cpp create mode 100644 src/system/kernel/arch/x86_64/arch_vm_translation_map.cpp diff --git a/headers/private/kernel/arch/x86_64/arch_int.h b/headers/private/kernel/arch/x86_64/arch_int.h index 9507d6de6d..9e8e987c78 100644 --- a/headers/private/kernel/arch/x86_64/arch_int.h +++ b/headers/private/kernel/arch/x86_64/arch_int.h @@ -34,7 +34,7 @@ static inline void arch_int_restore_interrupts_inline(int oldState) { if (oldState) - asm("sti"); + asm("sti"); } diff --git a/src/system/kernel/arch/x86_64/Jamfile b/src/system/kernel/arch/x86_64/Jamfile index 5f05fb5103..9765aad4f0 100644 --- a/src/system/kernel/arch/x86_64/Jamfile +++ b/src/system/kernel/arch/x86_64/Jamfile @@ -7,7 +7,21 @@ UsePrivateKernelHeaders ; UsePrivateHeaders shared ; KernelMergeObject kernel_arch_x86_64.o : + arch_commpage.cpp arch_cpu.cpp + arch_debug.cpp + arch_debug_console.cpp + arch_elf.cpp + arch_int.cpp + arch_platform.cpp + arch_real_time_clock.cpp + arch_smp.cpp + arch_system_info.cpp + arch_thread.cpp + arch_timer.cpp + arch_user_debugger.cpp + arch_vm.cpp + arch_vm_translation_map.cpp : $(TARGET_KERNEL_PIC_CCFLAGS) ; diff --git a/src/system/kernel/arch/x86_64/arch_commpage.cpp b/src/system/kernel/arch/x86_64/arch_commpage.cpp new file mode 100644 index 0000000000..5dcb59870f --- /dev/null +++ b/src/system/kernel/arch/x86_64/arch_commpage.cpp @@ -0,0 +1,21 @@ +/* + * Copyright 2012, Alex Smith, alex@alex-smith.me.uk. + * Distributed under the terms of the MIT License. + */ + + +#include + + +status_t +arch_commpage_init(void) +{ + return B_OK; +} + + +status_t +arch_commpage_init_post_cpus(void) +{ + return B_OK; +} diff --git a/src/system/kernel/arch/x86_64/arch_cpu.cpp b/src/system/kernel/arch/x86_64/arch_cpu.cpp index 0138f06af8..108b4d1621 100644 --- a/src/system/kernel/arch/x86_64/arch_cpu.cpp +++ b/src/system/kernel/arch/x86_64/arch_cpu.cpp @@ -1,6 +1,10 @@ /* - * Copyright 2012, Alex Smith, alex@alex-smith.me.uk + * Copyright 2002-2010, Axel Dörfler, axeld@pinc-software.de. + * Copyright 2012, Alex Smith, alex@alex-smith.me.uk. * Distributed under the terms of the MIT License. + * + * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved. + * Distributed under the terms of the NewOS License. */ @@ -8,8 +12,6 @@ #include -// #pragma mark - - status_t arch_cpu_preboot_init_percpu(kernel_args *args, int cpu) @@ -46,6 +48,13 @@ arch_cpu_init_post_modules(kernel_args *args) } +void +arch_cpu_user_TLB_invalidate(void) +{ + +} + + void arch_cpu_global_TLB_invalidate(void) { @@ -102,6 +111,33 @@ error: } +status_t +arch_cpu_user_memcpy(void *to, const void *from, size_t size, + addr_t *faultHandler) +{ + char *d = (char *)to; + const char *s = (const char *)from; + 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; + + for (; size != 0; size--) { + *d++ = *s++; + } + + *faultHandler = oldFaultHandler; + return 0; + +error: + *faultHandler = oldFaultHandler; + return B_BAD_ADDRESS; +} + + status_t arch_cpu_user_memset(void *s, char c, size_t count, addr_t *faultHandler) { diff --git a/src/system/kernel/arch/x86_64/arch_debug.cpp b/src/system/kernel/arch/x86_64/arch_debug.cpp new file mode 100644 index 0000000000..b9946bb186 --- /dev/null +++ b/src/system/kernel/arch/x86_64/arch_debug.cpp @@ -0,0 +1,102 @@ +/* + * Copyright 2012, Alex Smith, alex@alex-smith.me.uk. + * Distributed under the terms of the MIT License. + */ + + +#include + +#include + + +void +arch_debug_save_registers(struct arch_debug_registers* registers) +{ + +} + + +void +arch_debug_stack_trace(void) +{ + +} + + +bool +arch_debug_contains_call(Thread *thread, const char *symbol, + addr_t start, addr_t end) +{ + return false; +} + + +void * +arch_debug_get_caller(void) +{ + return NULL; +} + + +int32 +arch_debug_get_stack_trace(addr_t* returnAddresses, int32 maxCount, + int32 skipIframes, int32 skipFrames, uint32 flags) +{ + return 0; +} + + +void* +arch_debug_get_interrupt_pc(bool* _isSyscall) +{ + return NULL; +} + + +void +arch_debug_unset_current_thread(void) +{ + +} + + +bool +arch_is_debug_variable_defined(const char* variableName) +{ + return false; +} + + +status_t +arch_set_debug_variable(const char* variableName, uint64 value) +{ + return B_OK; +} + + +status_t +arch_get_debug_variable(const char* variableName, uint64* value) +{ + return B_OK; +} + + +ssize_t +arch_debug_gdb_get_registers(char* buffer, size_t bufferSize) +{ + return B_ERROR; +} + + +status_t +arch_debug_init(kernel_args *args) +{ + return B_OK; +} + +void +arch_debug_call_with_fault_handler(cpu_ent* cpu, jmp_buf jumpBuffer, + void (*function)(void*), void* parameter) +{ + // To be implemented in asm, not here. +} diff --git a/src/system/kernel/arch/x86_64/arch_debug_console.cpp b/src/system/kernel/arch/x86_64/arch_debug_console.cpp new file mode 100644 index 0000000000..cae226df4b --- /dev/null +++ b/src/system/kernel/arch/x86_64/arch_debug_console.cpp @@ -0,0 +1,91 @@ +/* + * Copyright 2012, Alex Smith, alex@alex-smith.me.uk. + * Distributed under the terms of the MIT License. + */ + + +#include + +#include +#include + + +void +arch_debug_remove_interrupt_handler(uint32 line) +{ + +} + + +void +arch_debug_install_interrupt_handlers(void) +{ + +} + + +int +arch_debug_blue_screen_try_getchar(void) +{ + return -1; +} + + +char +arch_debug_blue_screen_getchar(void) +{ + while(true) + PAUSE(); + return 0; +} + + +int +arch_debug_serial_try_getchar(void) +{ + return -1; +} + + +char +arch_debug_serial_getchar(void) +{ + while(true) + PAUSE(); + return 0; +} + + +void +arch_debug_serial_putchar(const char c) +{ + +} + + +void +arch_debug_serial_puts(const char *s) +{ + +} + + +void +arch_debug_serial_early_boot_message(const char *string) +{ + +} + + +status_t +arch_debug_console_init(kernel_args *args) +{ + return B_OK; +} + + +status_t +arch_debug_console_init_settings(kernel_args *args) +{ + return B_OK; +} diff --git a/src/system/kernel/arch/x86_64/arch_elf.cpp b/src/system/kernel/arch/x86_64/arch_elf.cpp new file mode 100644 index 0000000000..f8c6ad280e --- /dev/null +++ b/src/system/kernel/arch/x86_64/arch_elf.cpp @@ -0,0 +1,82 @@ +/* + * Copyright 2012, Alex Smith, alex@alex-smith.me.uk. + * Distributed under the terms of the MIT License. + */ + + +#include + + +// Currently got generic elf.cpp #ifdef'd out for x86_64, define stub versions here. + +status_t +elf_load_user_image(const char *path, Team *team, int flags, addr_t *_entry) +{ + return B_ERROR; +} + +image_id +load_kernel_add_on(const char *path) +{ + return 0; +} + +status_t +unload_kernel_add_on(image_id id) +{ + return B_ERROR; +} + +status_t +elf_debug_lookup_symbol_address(addr_t address, addr_t *_baseAddress, + const char **_symbolName, const char **_imageName, bool *_exactMatch) +{ + return B_ERROR; +} + +addr_t +elf_debug_lookup_symbol(const char* searchName) +{ + return 0; +} + +struct elf_image_info * +elf_get_kernel_image() +{ + return NULL; +} + +image_id +elf_create_memory_image(const char* imageName, addr_t text, size_t textSize, + addr_t data, size_t dataSize) +{ + return B_ERROR; +} + +status_t +elf_add_memory_image_symbol(image_id id, const char* name, addr_t address, + size_t size, int32 type) +{ + return B_ERROR; +} + +status_t +elf_init(struct kernel_args *args) +{ + return B_OK; +} + +status_t +get_image_symbol(image_id image, const char *name, int32 symbolType, + void **_symbolLocation) +{ + return B_OK; +} + +status_t +_user_read_kernel_image_symbols(image_id id, struct Elf32_Sym* symbolTable, + int32* _symbolCount, char* stringTable, size_t* _stringTableSize, + addr_t* _imageDelta) +{ + return B_ERROR; +} diff --git a/src/system/kernel/arch/x86_64/arch_int.cpp b/src/system/kernel/arch/x86_64/arch_int.cpp new file mode 100644 index 0000000000..b196a92476 --- /dev/null +++ b/src/system/kernel/arch/x86_64/arch_int.cpp @@ -0,0 +1,58 @@ +/* + * Copyright 2012, Alex Smith, alex@alex-smith.me.uk. + * Distributed under the terms of the MIT License. + */ + + +#include + +#include + + +void +arch_int_enable_io_interrupt(int irq) +{ + +} + + +void +arch_int_disable_io_interrupt(int irq) +{ + +} + + +void +arch_int_configure_io_interrupt(int irq, uint32 config) +{ + +} + + +status_t +arch_int_init(struct kernel_args *args) +{ + return B_OK; +} + + +status_t +arch_int_init_post_vm(struct kernel_args *args) +{ + return B_OK; +} + + +status_t +arch_int_init_io(kernel_args* args) +{ + return B_OK; +} + + +status_t +arch_int_init_post_device_manager(struct kernel_args *args) +{ + return B_OK; +} diff --git a/src/system/kernel/arch/x86_64/arch_platform.cpp b/src/system/kernel/arch/x86_64/arch_platform.cpp new file mode 100644 index 0000000000..c556b5639d --- /dev/null +++ b/src/system/kernel/arch/x86_64/arch_platform.cpp @@ -0,0 +1,35 @@ +/* + * Copyright 2006, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Ingo Weinhold + * Axel Dörfler, axeld@pinc-software.de + */ + + +#include +//#include + + +status_t +arch_platform_init(struct kernel_args *args) +{ + return B_OK; +} + + +status_t +arch_platform_init_post_vm(struct kernel_args *args) +{ + return B_OK; +} + + +status_t +arch_platform_init_post_thread(struct kernel_args *args) +{ + //apm_init(args); + return B_OK; +} + diff --git a/src/system/kernel/arch/x86_64/arch_real_time_clock.cpp b/src/system/kernel/arch/x86_64/arch_real_time_clock.cpp new file mode 100644 index 0000000000..1ada20b9ea --- /dev/null +++ b/src/system/kernel/arch/x86_64/arch_real_time_clock.cpp @@ -0,0 +1,45 @@ +/* + * Copyright 2012, Alex Smith, alex@alex-smith.me.uk. + * Distributed under the terms of the MIT License. + */ + + +#include + +#include +#include + + +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; +} diff --git a/src/system/kernel/arch/x86_64/arch_smp.cpp b/src/system/kernel/arch/x86_64/arch_smp.cpp new file mode 100644 index 0000000000..c8a6657378 --- /dev/null +++ b/src/system/kernel/arch/x86_64/arch_smp.cpp @@ -0,0 +1,37 @@ +/* + * Copyright 2012, Alex Smith, alex@alex-smith.me.uk. + * Distributed under the terms of the MIT License. + */ + + +#include + +#include + + +status_t +arch_smp_init(kernel_args *args) +{ + return B_OK; +} + + +status_t +arch_smp_per_cpu_init(kernel_args *args, int32 cpu) +{ + return B_OK; +} + + +void +arch_smp_send_broadcast_ici(void) +{ + +} + + +void +arch_smp_send_ici(int32 target_cpu) +{ + +} diff --git a/src/system/kernel/arch/x86_64/arch_system_info.cpp b/src/system/kernel/arch/x86_64/arch_system_info.cpp new file mode 100644 index 0000000000..b9f1d7b31e --- /dev/null +++ b/src/system/kernel/arch/x86_64/arch_system_info.cpp @@ -0,0 +1,21 @@ +/* + * Copyright 2012, Alex Smith, alex@alex-smith.me.uk. + * Distributed under the terms of the MIT License. + */ + + +#include + + +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; +} diff --git a/src/system/kernel/arch/x86_64/arch_thread.cpp b/src/system/kernel/arch/x86_64/arch_thread.cpp new file mode 100644 index 0000000000..d09c11ab9d --- /dev/null +++ b/src/system/kernel/arch/x86_64/arch_thread.cpp @@ -0,0 +1,104 @@ +/* + * Copyright 2012, Alex Smith, alex@alex-smith.me.uk. + * Distributed under the terms of the MIT License. + */ + + +#include + +#include +#include + + +status_t +arch_thread_init(struct kernel_args *args) +{ + return B_OK; +} + + +status_t +arch_team_init_team_struct(Team *p, bool kernel) +{ + return B_ERROR; +} + + +status_t +arch_thread_init_thread_struct(Thread *thread) +{ + return B_ERROR; +} + + +void +arch_thread_init_kthread_stack(Thread* thread, void* _stack, void* _stackTop, + void (*function)(void*), const void* data) +{ + +} + + +status_t +arch_thread_init_tls(Thread *thread) +{ + return B_ERROR; +} + + +void +arch_thread_context_switch(Thread *from, Thread *to) +{ + +} + + +void +arch_thread_dump_info(void *info) +{ + +} + + +status_t +arch_thread_enter_userspace(Thread* thread, addr_t entry, void* args1, + void* args2) +{ + return B_ERROR; +} + + +bool +arch_on_signal_stack(Thread *thread) +{ + return false; +} + + +status_t +arch_setup_signal_frame(Thread* thread, struct sigaction* action, + struct signal_frame_data* signalFrameData) +{ + return B_ERROR; +} + + +int64 +arch_restore_signal_frame(struct signal_frame_data* signalFrameData) +{ + return 0; +} + + +void +arch_store_fork_frame(struct arch_fork_arg *arg) +{ + +} + + +void +arch_restore_fork_frame(struct arch_fork_arg* arg) +{ + +} diff --git a/src/system/kernel/arch/x86_64/arch_timer.cpp b/src/system/kernel/arch/x86_64/arch_timer.cpp new file mode 100644 index 0000000000..c320b6bf98 --- /dev/null +++ b/src/system/kernel/arch/x86_64/arch_timer.cpp @@ -0,0 +1,30 @@ +/* + * Copyright 2012, Alex Smith, alex@alex-smith.me.uk. + * Distributed under the terms of the MIT License. + */ + + +#include + +#include + + +void +arch_timer_set_hardware_timer(bigtime_t timeout) +{ + +} + + +void +arch_timer_clear_hardware_timer(void) +{ + +} + + +int +arch_init_timer(kernel_args *args) +{ + return 0; +} diff --git a/src/system/kernel/arch/x86_64/arch_user_debugger.cpp b/src/system/kernel/arch/x86_64/arch_user_debugger.cpp new file mode 100644 index 0000000000..a9931c674d --- /dev/null +++ b/src/system/kernel/arch/x86_64/arch_user_debugger.cpp @@ -0,0 +1,106 @@ +/* + * Copyright 2005-2011, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2012, Alex Smith, alex@alex-smith.me.uk. + * Distributed under the terms of the MIT License. + */ + + +#include + +#include + + +// The software breakpoint instruction (int3). +const uint8 kX86SoftwareBreakpoint[1] = { 0xcc }; + + +void +arch_clear_team_debug_info(struct arch_team_debug_info *info) +{ + +} + + +void +arch_destroy_team_debug_info(struct arch_team_debug_info *info) +{ + +} + + +void +arch_clear_thread_debug_info(struct arch_thread_debug_info *info) +{ + +} + + +void +arch_destroy_thread_debug_info(struct arch_thread_debug_info *info) +{ + +} + + +void +arch_update_thread_single_step() +{ + +} + + +void +arch_set_debug_cpu_state(const debug_cpu_state *cpuState) +{ + +} + + +void +arch_get_debug_cpu_state(debug_cpu_state *cpuState) +{ + +} + + +status_t +arch_set_breakpoint(void *address) +{ + return B_OK; +} + + +status_t +arch_clear_breakpoint(void *address) +{ + return B_OK; +} + + +status_t +arch_set_watchpoint(void *address, uint32 type, int32 length) +{ + return B_OK; +} + + +status_t +arch_clear_watchpoint(void *address) +{ + return B_OK; +} + + +bool +arch_has_breakpoints(struct arch_team_debug_info *info) +{ + return false; +} + + +void +x86_init_user_debug() +{ + +} + diff --git a/src/system/kernel/arch/x86_64/arch_vm.cpp b/src/system/kernel/arch/x86_64/arch_vm.cpp new file mode 100644 index 0000000000..db842ad6d3 --- /dev/null +++ b/src/system/kernel/arch/x86_64/arch_vm.cpp @@ -0,0 +1,66 @@ +/* + * Copyright 2012, Alex Smith, alex@alex-smith.me.uk. + * Distributed under the terms of the MIT License. + */ + + +#include + +#include + + +status_t +arch_vm_init(kernel_args *args) +{ + return B_OK; +} + + +status_t +arch_vm_init_post_area(kernel_args *args) +{ + return B_OK; +} + + +status_t +arch_vm_init_end(kernel_args *args) +{ + return B_OK; +} + + +status_t +arch_vm_init_post_modules(kernel_args *args) +{ + return B_OK; +} + + +void +arch_vm_aspace_swap(struct VMAddressSpace *from, struct VMAddressSpace *to) +{ + +} + + +bool +arch_vm_supports_protection(uint32 protection) +{ + return true; +} + + +void +arch_vm_unset_memory_type(struct VMArea *area) +{ + +} + + +status_t +arch_vm_set_memory_type(struct VMArea *area, phys_addr_t physicalBase, + uint32 type) +{ + return B_OK; +} diff --git a/src/system/kernel/arch/x86_64/arch_vm_translation_map.cpp b/src/system/kernel/arch/x86_64/arch_vm_translation_map.cpp new file mode 100644 index 0000000000..be0f2d1a40 --- /dev/null +++ b/src/system/kernel/arch/x86_64/arch_vm_translation_map.cpp @@ -0,0 +1,52 @@ +/* + * Copyright 2012, Alex Smith, alex@alex-smith.me.uk. + * Distributed under the terms of the MIT License. + */ + + +#include + + +status_t +arch_vm_translation_map_create_map(bool kernel, VMTranslationMap** _map) +{ + return B_ERROR; +} + + +status_t +arch_vm_translation_map_init(kernel_args *args, + VMPhysicalPageMapper** _physicalPageMapper) +{ + return B_OK; +} + + +status_t +arch_vm_translation_map_init_post_sem(kernel_args *args) +{ + return B_OK; +} + + +status_t +arch_vm_translation_map_init_post_area(kernel_args *args) +{ + return B_OK; +} + + +status_t +arch_vm_translation_map_early_map(kernel_args *args, addr_t va, phys_addr_t pa, + uint8 attributes, phys_addr_t (*get_free_page)(kernel_args *)) +{ + return B_ERROR; +} + + +bool +arch_vm_translation_map_is_kernel_page_accessible(addr_t virtualAddress, + uint32 protection) +{ + return true; +}