hrev44090 adds 1 changeset to branch 'master' old head: 2b31b4a88cdcc94b3db80cd453b9fd366420873c new head: 5426ff9347f8c71056c786ef937da480c1f4c21b ---------------------------------------------------------------------------- 5426ff9: system loader: Initial work on new rasberrypi_arm loader * Used routerboard loader as a base skel * May just be temporary if u-boot ever gets Raspberry Pi support [ Alexander von Gluck IV <kallisti5@xxxxxxxxxxx> ] ---------------------------------------------------------------------------- Revision: hrev44090 Commit: 5426ff9347f8c71056c786ef937da480c1f4c21b URL: http://cgit.haiku-os.org/haiku/commit/?id=5426ff9 Author: Alexander von Gluck IV <kallisti5@xxxxxxxxxxx> Date: Tue May 1 18:48:07 2012 UTC ---------------------------------------------------------------------------- 24 files changed, 1035 insertions(+) .../boot/platform/raspberrypi_arm/platform_arch.h | 39 +++++ .../raspberrypi_arm/platform_kernel_args.h | 23 +++ .../raspberrypi_arm/platform_stage2_args.h | 17 ++ src/system/boot/platform/raspberrypi_arm/Jamfile | 52 ++++++ .../platform/raspberrypi_arm/arch_start_kernel.S | 37 +++++ .../boot/platform/raspberrypi_arm/console.cpp | 131 ++++++++++++++++ src/system/boot/platform/raspberrypi_arm/console.h | 20 +++ src/system/boot/platform/raspberrypi_arm/cpu.cpp | 40 +++++ src/system/boot/platform/raspberrypi_arm/cpu.h | 23 +++ src/system/boot/platform/raspberrypi_arm/debug.cpp | 30 ++++ .../boot/platform/raspberrypi_arm/devices.cpp | 47 ++++++ src/system/boot/platform/raspberrypi_arm/entry.S | 9 ++ .../boot/platform/raspberrypi_arm/keyboard.cpp | 43 +++++ .../boot/platform/raspberrypi_arm/keyboard.h | 33 ++++ src/system/boot/platform/raspberrypi_arm/menu.cpp | 53 +++++++ src/system/boot/platform/raspberrypi_arm/mmu.cpp | 94 +++++++++++ src/system/boot/platform/raspberrypi_arm/mmu.h | 29 ++++ .../boot/platform/raspberrypi_arm/serial.cpp | 56 +++++++ src/system/boot/platform/raspberrypi_arm/serial.h | 27 ++++ src/system/boot/platform/raspberrypi_arm/start.c | 117 ++++++++++++++ src/system/boot/platform/raspberrypi_arm/video.cpp | 37 +++++ src/system/kernel/platform/raspberrypi_arm/Jamfile | 8 + .../kernel/platform/raspberrypi_arm/platform.cpp | 3 + .../ldscripts/arm/boot_loader_raspberrypi_arm.ld | 67 ++++++++ ---------------------------------------------------------------------------- diff --git a/headers/private/kernel/boot/platform/raspberrypi_arm/platform_arch.h b/headers/private/kernel/boot/platform/raspberrypi_arm/platform_arch.h new file mode 100644 index 0000000..3c95b64 --- /dev/null +++ b/headers/private/kernel/boot/platform/raspberrypi_arm/platform_arch.h @@ -0,0 +1,39 @@ +/* + * Copyright 2003, Axel Dörfler, axeld@xxxxxxxxxxxxxxxxx All rights reserved. + * Distributed under the terms of the OpenBeOS License. + * Copyright 2011-2012, Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. +*/ +#ifndef KERNEL_BOOT_PLATFORM_PI_ARCH_H +#define KERNEL_BOOT_PLATFORM_PI_ARCH_H + + +#include <SupportDefs.h> + + +struct kernel_args; + + +#ifdef __cplusplus +extern "C" { +#endif +/* memory management */ +extern status_t arch_set_callback(void); +extern void *arch_mmu_allocate(void *address, size_t size, uint8 protection, + bool exactAddress); +extern status_t arch_mmu_free(void *address, size_t size); +extern status_t arch_mmu_init(void); + +/* CPU */ +extern status_t boot_arch_cpu_init(void); + +/* kernel start */ +status_t arch_start_kernel(struct kernel_args *kernelArgs, addr_t kernelEntry, + addr_t kernelStackTop); + +#ifdef __cplusplus +} +#endif + + +#endif /* KERNEL_BOOT_PLATFORM_PI_ARCH_H */ diff --git a/headers/private/kernel/boot/platform/raspberrypi_arm/platform_kernel_args.h b/headers/private/kernel/boot/platform/raspberrypi_arm/platform_kernel_args.h new file mode 100644 index 0000000..ff7a8e2 --- /dev/null +++ b/headers/private/kernel/boot/platform/raspberrypi_arm/platform_kernel_args.h @@ -0,0 +1,23 @@ +/* + * Copyright 2009-2011, Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + */ +#ifndef KERNEL_BOOT_PLATFORM_PI_KERNEL_ARGS_H +#define KERNEL_BOOT_PLATFORM_PI_KERNEL_ARGS_H + +#ifndef KERNEL_BOOT_KERNEL_ARGS_H +# error This file is included from <boot/kernel_args.h> only +#endif + +// must match SMP_MAX_CPUS in arch_smp.h +#define MAX_BOOT_CPUS 1 +#define MAX_PHYSICAL_MEMORY_RANGE 4 +#define MAX_PHYSICAL_ALLOCATED_RANGE 8 +#define MAX_VIRTUAL_ALLOCATED_RANGE 32 + + +typedef struct { + char dummy; +} platform_kernel_args; + +#endif /* KERNEL_BOOT_PLATFORM_PI_KERNEL_ARGS_H */ diff --git a/headers/private/kernel/boot/platform/raspberrypi_arm/platform_stage2_args.h b/headers/private/kernel/boot/platform/raspberrypi_arm/platform_stage2_args.h new file mode 100644 index 0000000..81169cf --- /dev/null +++ b/headers/private/kernel/boot/platform/raspberrypi_arm/platform_stage2_args.h @@ -0,0 +1,17 @@ +/* + * Copyright 2009-2012, Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + */ +#ifndef KERNEL_BOOT_PLATFORM_PI_STAGE2_H +#define KERNEL_BOOT_PLATFORM_PI_STAGE2_H + +#ifndef KERNEL_BOOT_STAGE2_ARGS_H +# error This file is included from <boot/stage2_args.h> only +#endif + +struct platform_stage2_args { + void *boot_tgz_data; + uint32 boot_tgz_size; +}; + +#endif /* KERNEL_BOOT_PLATFORM_PI_STAGE2_H */ diff --git a/src/system/boot/platform/raspberrypi_arm/Jamfile b/src/system/boot/platform/raspberrypi_arm/Jamfile new file mode 100644 index 0000000..b854c2b --- /dev/null +++ b/src/system/boot/platform/raspberrypi_arm/Jamfile @@ -0,0 +1,52 @@ +SubDir HAIKU_TOP src system boot platform raspberrypi_arm ; + +SubDirHdrs $(HAIKU_TOP) headers private kernel boot platform $(TARGET_BOOT_PLATFORM) ; + +UsePrivateHeaders [ FDirName kernel disk_device_manager ] ; +UsePrivateHeaders [ FDirName graphics common ] ; +UsePrivateHeaders [ FDirName graphics vesa ] ; +UsePrivateHeaders [ FDirName storage ] ; + +{ + local defines = _BOOT_MODE ; + + defines = [ FDefines $(defines) ] ; + SubDirCcFlags $(defines) ; + SubDirC++Flags $(defines) -fno-rtti ; +} + +SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src add-ons accelerants common ] ; + +local genericPlatformSources = + text_menu.cpp +# video_blit.cpp +# video_splash.cpp +; + +KernelMergeObject boot_platform_raspberrypi_arm.o : + entry.S + start.c + console.cpp + cpu.cpp + debug.cpp + devices.cpp + keyboard.cpp + menu.cpp + mmu.cpp + serial.cpp + video.cpp + arch_start_kernel.S + + $(genericPlatformSources) + : -fno-pic + : boot_platform_generic.a +; + + +SEARCH on [ FGristFiles $(genericPlatformSources) ] + = [ FDirName $(HAIKU_TOP) src system boot platform generic ] ; + + +# Tell the build system to where stage1.bin can be found, so it can be used +# elsewhere. +SEARCH on stage1.bin = $(SUBDIR) ; diff --git a/src/system/boot/platform/raspberrypi_arm/arch_start_kernel.S b/src/system/boot/platform/raspberrypi_arm/arch_start_kernel.S new file mode 100644 index 0000000..ebd7db5 --- /dev/null +++ b/src/system/boot/platform/raspberrypi_arm/arch_start_kernel.S @@ -0,0 +1,37 @@ +/* + * Copyright 2011, Fran??ois Revol <revol@xxxxxxx>. + * All rights reserved. Distributed under the terms of the MIT License. + */ + +#include <arch/arm/arch_cpu.h> + +#include <asm_defs.h> + + .text + +/* + * status_t arch_start_kernel(struct kernel_args *kernelArgs, + * addr_t kernelEntry, addr_t kernelStackTop); + + r0 - kernelArgs + r1 - kernelEntry + r2 - kernelStackTop +*/ +FUNCTION(arch_start_kernel): + + // set the kernel stack + mov sp,r2 + + // set up kernel _start args + //mov r0,r0 // kernelArgs + mov r4,r1 + mov r1,#0 // currentCPU=0 + + // call the kernel + mov pc,r4 + + // return + mov r0,#-1 // B_ERROR + mov pc,lr + +FUNCTION_END(arch_start_kernel) diff --git a/src/system/boot/platform/raspberrypi_arm/console.cpp b/src/system/boot/platform/raspberrypi_arm/console.cpp new file mode 100644 index 0000000..a79b0ea --- /dev/null +++ b/src/system/boot/platform/raspberrypi_arm/console.cpp @@ -0,0 +1,131 @@ +/* + * Copyright 2009 Jonas Sundström, jonas@xxxxxxxxxxx + * All rights reserved. Distributed under the terms of the MIT License. + */ + + +#include "console.h" + +#include <SupportDefs.h> + +#include "keyboard.h" + + +class Console : public ConsoleNode { +public: + Console(); + + virtual ssize_t ReadAt(void* cookie, off_t pos, void* buffer, + size_t bufferSize); + virtual ssize_t WriteAt(void* cookie, off_t pos, + const void* buffer, size_t bufferSize); +}; + +static uint32 sScreenWidth = 80; +static uint32 sScreenHeight = 25; +static uint32 sScreenOffset = 0; +static uint16 sColor = 0x0f00; + +static Console sInput, sOutput; + +FILE* stdin; +FILE* stdout; +FILE* stderr; + + +// #pragma mark - + + +Console::Console() + : ConsoleNode() +{ +} + + +ssize_t +Console::ReadAt(void* cookie, off_t pos, void* buffer, size_t bufferSize) +{ +#warning IMPLEMENT ReadAt + return 0; +} + + +ssize_t +Console::WriteAt(void* cookie, off_t /*pos*/, const void* buffer, + size_t bufferSize) +{ +#warning IMPLEMENT WriteAt + return 0; +} + + +// #pragma mark - + + +void +console_clear_screen(void) +{ +#warning IMPLEMENT console_clear_screen +} + + +int32 +console_width(void) +{ +#warning IMPLEMENT console_width + return 0; +} + + +int32 +console_height(void) +{ +#warning IMPLEMENT console_height + return 0; +} + + +void +console_set_cursor(int32 x, int32 y) +{ +#warning IMPLEMENT console_set_cursor +} + + +void +console_set_color(int32 foreground, int32 background) +{ +#warning IMPLEMENT console_set_color +} + + +int +console_wait_for_key(void) +{ +#warning IMPLEMENT console_wait_for_key + union key key; + return key.code.ascii; +} + + +void +console_show_cursor(void) +{ +#warning IMPLEMENT console_show_cursor +} + + +void +console_hide_cursor(void) +{ +#warning IMPLEMENT console_hide_cursor +} + + +status_t +console_init(void) +{ +#warning IMPLEMENT console_init + return B_OK; +} + diff --git a/src/system/boot/platform/raspberrypi_arm/console.h b/src/system/boot/platform/raspberrypi_arm/console.h new file mode 100644 index 0000000..55f21e2 --- /dev/null +++ b/src/system/boot/platform/raspberrypi_arm/console.h @@ -0,0 +1,20 @@ +/* + * Copyright 2009 Jonas Sundström, jonas@xxxxxxxxxxx + * All rights reserved. Distributed under the terms of the MIT License. + */ +#ifndef _SYSTEM_BOOT_PLATFORM_STUB_CONSOLE_H +#define _SYSTEM_BOOT_PLATFORM_STUB_CONSOLE_H + +#include <boot/platform/generic/text_console.h> + +#ifdef __cplusplus +extern "C" { +#endif + +extern status_t console_init(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYSTEM_BOOT_PLATFORM_STUB_CONSOLE_H */ diff --git a/src/system/boot/platform/raspberrypi_arm/cpu.cpp b/src/system/boot/platform/raspberrypi_arm/cpu.cpp new file mode 100644 index 0000000..bc2f15f --- /dev/null +++ b/src/system/boot/platform/raspberrypi_arm/cpu.cpp @@ -0,0 +1,40 @@ +/* + * Copyright 2009 Jonas Sundström, jonas@xxxxxxxxxxx + * All rights reserved. Distributed under the terms of the MIT License. + */ + + +#include "cpu.h" + +#include <OS.h> +#include <arch/cpu.h> +#include <arch_kernel.h> +#include <arch_system_info.h> + +#include <string.h> + + +static status_t +check_cpu_features() +{ +#warning IMPLEMENT check_cpu_features + return B_ERROR; +} + + +// #pragma mark - + + +extern "C" void +spin(bigtime_t microseconds) +{ +#warning IMPLEMENT spin +} + + +extern "C" void +cpu_init() +{ +#warning IMPLEMENT cpu_init +} + diff --git a/src/system/boot/platform/raspberrypi_arm/cpu.h b/src/system/boot/platform/raspberrypi_arm/cpu.h new file mode 100644 index 0000000..466b4bf --- /dev/null +++ b/src/system/boot/platform/raspberrypi_arm/cpu.h @@ -0,0 +1,23 @@ +/* + * Copyright 2009 Jonas Sundström, jonas@xxxxxxxxxxx + * All rights reserved. Distributed under the terms of the MIT License. + */ +#ifndef _SYSTEM_BOOT_PLATFORM_PI_CPU_H +#define _SYSTEM_BOOT_PLATFORM_PI_CPU_H + + +#include <SupportDefs.h> + + +#ifdef __cplusplus +extern "C" { +#endif + +extern void cpu_init(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYSTEM_BOOT_PLATFORM_ROUTERBOARD_MIPSEL_CPU_H */ + diff --git a/src/system/boot/platform/raspberrypi_arm/debug.cpp b/src/system/boot/platform/raspberrypi_arm/debug.cpp new file mode 100644 index 0000000..091cb41 --- /dev/null +++ b/src/system/boot/platform/raspberrypi_arm/debug.cpp @@ -0,0 +1,30 @@ +/* + * Copyright 2009 Jonas Sundström, jonas@xxxxxxxxxxx + * All rights reserved. Distributed under the terms of the MIT License. + */ + + +#include <boot/platform.h> +#include <boot/stdio.h> +#include <stdarg.h> + + +void +panic(const char* format, ...) +{ +#warning IMPLEMENT panic +} + + +void +dprintf(const char* format, ...) +{ +#warning IMPLEMENT dprintf +} + + +char* +platform_debug_get_log_buffer(size_t* _size) +{ + return NULL; +} diff --git a/src/system/boot/platform/raspberrypi_arm/devices.cpp b/src/system/boot/platform/raspberrypi_arm/devices.cpp new file mode 100644 index 0000000..277c58c --- /dev/null +++ b/src/system/boot/platform/raspberrypi_arm/devices.cpp @@ -0,0 +1,47 @@ +/* + * Copyright 2009 Jonas Sundström, jonas@xxxxxxxxxxx + * All rights reserved. Distributed under the terms of the MIT License. + */ + + +#include <KernelExport.h> +#include <boot/platform.h> +#include <boot/partitions.h> +#include <boot/stdio.h> +#include <boot/stage2.h> + +#include <string.h> + + +status_t +platform_add_boot_device(struct stage2_args* args, NodeList* devicesList) +{ +#warning IMPLEMENT platform_add_boot_device + return B_ERROR; +} + + +status_t +platform_get_boot_partition(struct stage2_args* args, Node* bootDevice, + NodeList* list, boot::Partition** _partition) +{ +#warning IMPLEMENT platform_get_boot_partition + return B_ERROR; +} + + +status_t +platform_add_block_devices(stage2_args* args, NodeList* devicesList) +{ +#warning IMPLEMENT platform_add_block_devices + return B_ERROR; +} + + +status_t +platform_register_boot_device(Node* device) +{ +#warning IMPLEMENT platform_register_boot_device + return B_ERROR; +} + diff --git a/src/system/boot/platform/raspberrypi_arm/entry.S b/src/system/boot/platform/raspberrypi_arm/entry.S new file mode 100644 index 0000000..4d48aeb --- /dev/null +++ b/src/system/boot/platform/raspberrypi_arm/entry.S @@ -0,0 +1,9 @@ +.globl _start +_start: + + /* Set up 1MB C Stack Space */ + mov sp, #0x100000 + + mov r4,#0 + /* Start loader */ + b pi_start diff --git a/src/system/boot/platform/raspberrypi_arm/keyboard.cpp b/src/system/boot/platform/raspberrypi_arm/keyboard.cpp new file mode 100644 index 0000000..68eea93 --- /dev/null +++ b/src/system/boot/platform/raspberrypi_arm/keyboard.cpp @@ -0,0 +1,43 @@ +/* + * Copyright 2009 Jonas Sundström, jonas@xxxxxxxxxxx + * All rights reserved. Distributed under the terms of the MIT License. + */ + + +#include "keyboard.h" + +#include <boot/platform.h> + + +static uint16 +check_for_key(void) +{ +#warning IMPLEMENT check_for_key + return 0; +} + + +extern "C" void +clear_key_buffer(void) +{ +#warning IMPLEMENT clear_key_buffer + while (check_for_key() != 0) + ; +} + + +extern "C" union key +wait_for_key(void) +{ +#warning IMPLEMENT wait_for_key + union key key; + return key; +} + + +extern "C" uint32 +check_for_boot_keys(void) +{ +#warning IMPLEMENT check_for_boot_keys + return 0; +} diff --git a/src/system/boot/platform/raspberrypi_arm/keyboard.h b/src/system/boot/platform/raspberrypi_arm/keyboard.h new file mode 100644 index 0000000..4cd0cee --- /dev/null +++ b/src/system/boot/platform/raspberrypi_arm/keyboard.h @@ -0,0 +1,33 @@ +/* + * Copyright 2009 Jonas Sundström, jonas@xxxxxxxxxxx + * All rights reserved. Distributed under the terms of the MIT License. + */ +#ifndef _SYSTEM_BOOT_PLATFORM_PI_KEYBOARD_H +#define _SYSTEM_BOOT_PLATFORM_PI_KEYBOARD_H + + +#include <SupportDefs.h> + + +union key { + uint16 ax; + struct { + uint8 ascii; + uint8 bios; + } code; +}; + + +#ifdef __cplusplus +extern "C" { +#endif + +extern void clear_key_buffer(void); +extern union key wait_for_key(void); +extern uint32 check_for_boot_keys(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYSTEM_BOOT_PLATFORM_PI_KEYBOARD_H */ diff --git a/src/system/boot/platform/raspberrypi_arm/menu.cpp b/src/system/boot/platform/raspberrypi_arm/menu.cpp new file mode 100644 index 0000000..76ddf22 --- /dev/null +++ b/src/system/boot/platform/raspberrypi_arm/menu.cpp @@ -0,0 +1,53 @@ +/* + * Copyright 2009 Jonas Sundström, jonas@xxxxxxxxxxx + * All rights reserved. Distributed under the terms of the MIT License. + */ + + +#include <boot/menu.h> +#include <boot/platform/generic/text_menu.h> + + +void +platform_add_menus(Menu* menu) +{ + MenuItem* item; + + switch (menu->Type()) { + case MAIN_MENU: + case SAFE_MODE_MENU: + menu->AddItem(item = new(nothrow) MenuItem("A menu item")); + item->SetType(MENU_ITEM_MARKABLE); + item->SetData(0); + item->SetHelpText("A helpful text."); + + menu->AddItem(item = new(nothrow) MenuItem("Another menu item")); + item->SetHelpText("Some more helpful text."); + item->SetType(MENU_ITEM_MARKABLE); + break; + default: + break; + } +} + + +void +platform_update_menu_item(Menu* menu, MenuItem* item) +{ + platform_generic_update_text_menu_item(menu, item); +} + + +void +platform_run_menu(Menu* menu) +{ + platform_generic_run_text_menu(menu); +} + + +void +platform_get_user_input_text(Menu *menu, MenuItem *item, char *buffer, + size_t bufferSize) +{ + platform_generic_get_user_input_text(menu, item, buffer, bufferSize); +} diff --git a/src/system/boot/platform/raspberrypi_arm/mmu.cpp b/src/system/boot/platform/raspberrypi_arm/mmu.cpp new file mode 100644 index 0000000..d2178f7 --- /dev/null +++ b/src/system/boot/platform/raspberrypi_arm/mmu.cpp @@ -0,0 +1,94 @@ +/* + * Copyright 2009 Jonas Sundström, jonas@xxxxxxxxxxx + * All rights reserved. Distributed under the terms of the MIT License. + */ + + +#include "mmu.h" + +#include <boot/platform.h> +#include <boot/stdio.h> +#include <boot/kernel_args.h> +#include <boot/stage2.h> +#include <arch/cpu.h> +#include <arch_kernel.h> +#include <kernel.h> + +#include <OS.h> + +#include <string.h> + + +// #pragma mark - + + +extern "C" addr_t +mmu_map_physical_memory(addr_t physicalAddress, size_t size, uint32 flags) +{ +#warning IMPLEMENT mmu_map_physical_memory + return 0; +} + + +extern "C" void* +mmu_allocate(void* virtualAddress, size_t size) +{ +#warning IMPLEMENT mmu_allocate + return 0; +} + + +extern "C" void +mmu_free(void* virtualAddress, size_t size) +{ +#warning IMPLEMENT mmu_free +} + + +extern "C" void +mmu_init_for_kernel(void) +{ +#warning IMPLEMENT mmu_init_for_kernel +} + + +extern "C" void +mmu_init(void) +{ +#warning IMPLEMENT mmu_init +} + + +// #pragma mark - + + +extern "C" status_t +platform_allocate_region(void** _address, size_t size, uint8 protection, + bool /*exactAddress*/) +{ +#warning IMPLEMENT platform_allocate_region + return B_ERROR; +} + + +extern "C" status_t +platform_free_region(void* address, size_t size) +{ +#warning IMPLEMENT platform_free_region + return B_ERROR; +} + + +void +platform_release_heap(struct stage2_args* args, void* base) +{ +#warning IMPLEMENT platform_release_heap +} + + +status_t +platform_init_heap(struct stage2_args* args, void** _base, void** _top) +{ +#warning IMPLEMENT platform_init_heap + return B_ERROR; +} diff --git a/src/system/boot/platform/raspberrypi_arm/mmu.h b/src/system/boot/platform/raspberrypi_arm/mmu.h new file mode 100644 index 0000000..219d5a8 --- /dev/null +++ b/src/system/boot/platform/raspberrypi_arm/mmu.h @@ -0,0 +1,29 @@ +/* + * Copyright 2009 Jonas Sundström, jonas@xxxxxxxxxxx + * All rights reserved. Distributed under the terms of the MIT License. + */ +#ifndef _SYSTEM_BOOT_PLATFORM_PI_MMU_H +#define _SYSTEM_BOOT_PLATFORM_PI_MMU_H + + +#include <SupportDefs.h> + + +#ifdef __cplusplus +extern "C" { +#endif + +extern void mmu_init(void); +extern void mmu_init_for_kernel(void); + +extern addr_t mmu_map_physical_memory(addr_t physicalAddress, size_t size, + uint32 flags); + +extern void* mmu_allocate(void* virtualAddress, size_t size); +extern void mmu_free(void* virtualAddress, size_t size); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYSTEM_BOOT_PLATFORM_PI_MMU_H */ diff --git a/src/system/boot/platform/raspberrypi_arm/serial.cpp b/src/system/boot/platform/raspberrypi_arm/serial.cpp new file mode 100644 index 0000000..4c8d121 --- /dev/null +++ b/src/system/boot/platform/raspberrypi_arm/serial.cpp @@ -0,0 +1,56 @@ +/* + * Copyright 2009 Jonas Sundström, jonas@xxxxxxxxxxx + * All rights reserved. Distributed under the terms of the MIT License. + */ + + +#include "serial.h" + +#include <boot/platform.h> +#include <arch/cpu.h> +#include <boot/stage2.h> + +#include <string.h> + + +static void +serial_putc(char c) +{ +#warning IMPLEMENT serial_putc +} + + +extern "C" void +serial_puts(const char* string, size_t size) +{ +#warning IMPLEMENT serial_puts +} + + +extern "C" void +serial_disable(void) +{ +#warning IMPLEMENT serial_disable +} + + +extern "C" void +serial_enable(void) +{ +#warning IMPLEMENT serial_enable +} + + +extern "C" void +serial_cleanup(void) +{ +#warning IMPLEMENT serial_cleanup +} + + +extern "C" void +serial_init(void) +{ +#warning IMPLEMENT serial_init +} + diff --git a/src/system/boot/platform/raspberrypi_arm/serial.h b/src/system/boot/platform/raspberrypi_arm/serial.h new file mode 100644 index 0000000..e6d2c04 --- /dev/null +++ b/src/system/boot/platform/raspberrypi_arm/serial.h @@ -0,0 +1,27 @@ +/* + * Copyright 2009 Jonas Sundström, jonas@xxxxxxxxxxx + * All rights reserved. Distributed under the terms of the MIT License. + */ +#ifndef _SYSTEM_BOOT_PLATFORM_PI_SERIAL_H +#define _SYSTEM_BOOT_PLATFORM_PI_SERIAL_H + + +#include <SupportDefs.h> + + +#ifdef __cplusplus +extern "C" { +#endif + +extern void serial_init(void); +extern void serial_cleanup(void); +extern void serial_puts(const char *string, size_t size); +extern void serial_disable(void); +extern void serial_enable(void); + +#ifdef __cplusplus +} +#endif + + +#endif /* _SYSTEM_BOOT_PLATFORM_ROUTERBOARD_MIPSEL_SERIAL_H */ diff --git a/src/system/boot/platform/raspberrypi_arm/start.c b/src/system/boot/platform/raspberrypi_arm/start.c new file mode 100644 index 0000000..8e95321 --- /dev/null +++ b/src/system/boot/platform/raspberrypi_arm/start.c @@ -0,0 +1,117 @@ +/* + * Copyright 2009 Jonas Sundström, jonas@xxxxxxxxxxx + * Copyright 2003-2008 Axel Dörfler, axeld@xxxxxxxxxxxxxxxx + * All rights reserved. Distributed under the terms of the MIT License. + */ + + +#include "serial.h" +#include "console.h" +#include "cpu.h" +#include "mmu.h" +#include "keyboard.h" + +#include <KernelExport.h> +#include <boot/platform.h> +#include <boot/heap.h> +#include <boot/stage2.h> +#include <arch/cpu.h> + +#include <string.h> + + +#define HEAP_SIZE 65536 + + +// GCC defined globals +extern void (*__ctor_list)(void); +extern void (*__ctor_end)(void); +extern uint8 __bss_start; +extern uint8 _end; + +extern int main(stage2_args *args); +void _start(void); + + +static void +clear_bss(void) +{ + /* TODO: fix boot_loader_routerboard_mipsel.ld + * so this code works, or find a workaround. + */ +/* + memset(&__bss_start, 0, &_end - &__bss_start); +*/ +} + + +static void +call_ctors(void) +{ + /* TODO: fix boot_loader_routerboard_mipsel.ld + * so this code works, or find a workaround. + */ +/* + void (**f)(void); + + for (f = &__ctor_list; f < &__ctor_end; f++) { + (**f)(); + } +*/ +} + + +// #pragma mark - + + +void +abort(void) +{ + panic("abort"); +} + + +uint32 +platform_boot_options(void) +{ +#warning IMPLEMENT platform_boot_options + return 0; +} + + +void +platform_start_kernel(void) +{ +#warning IMPLEMENT platform_start_kernel + panic("kernel returned!\n"); +} + + +void +platform_exit(void) +{ +#warning IMPLEMENT platform_exit +} + + +void +pi_start(void) +{ +#warning IMPLEMENT _start + stage2_args args; + + clear_bss(); + call_ctors(); + + cpu_init(); + mmu_init(); + serial_init(); + console_init(); + serial_enable(); + + args.heap_size = HEAP_SIZE; + args.arguments = NULL; + + main(&args); +} + diff --git a/src/system/boot/platform/raspberrypi_arm/video.cpp b/src/system/boot/platform/raspberrypi_arm/video.cpp new file mode 100644 index 0000000..9672899 --- /dev/null +++ b/src/system/boot/platform/raspberrypi_arm/video.cpp @@ -0,0 +1,37 @@ +/* + * Copyright 2009 Jonas Sundström, jonas@xxxxxxxxxxx + * All rights reserved. Distributed under the terms of the MIT License. + */ + + +#include <SupportDefs.h> + + +extern "C" void +platform_set_palette(const uint8* palette) +{ +#warning IMPLEMENT platform_set_palette +} + + +extern "C" void +platform_switch_to_logo(void) +{ +#warning IMPLEMENT platform_switch_to_logo +} + + +extern "C" void +platform_switch_to_text_mode(void) +{ +#warning IMPLEMENT platform_switch_to_text_mode +} + + +extern "C" status_t +platform_init_video(void) +{ +#warning IMPLEMENT platform_init_video + return B_ERROR; +} + diff --git a/src/system/kernel/platform/raspberrypi_arm/Jamfile b/src/system/kernel/platform/raspberrypi_arm/Jamfile new file mode 100644 index 0000000..9bb2b98 --- /dev/null +++ b/src/system/kernel/platform/raspberrypi_arm/Jamfile @@ -0,0 +1,8 @@ +SubDir HAIKU_TOP src system kernel platform raspberrypi_arm ; + +SubDirCcFlags $(TARGET_KERNEL_PIC_CCFLAGS) ; +SubDirC++Flags $(TARGET_KERNEL_PIC_CCFLAGS) ; + +KernelMergeObject kernel_platform_raspberrypi_arm.o : + platform.cpp +; diff --git a/src/system/kernel/platform/raspberrypi_arm/platform.cpp b/src/system/kernel/platform/raspberrypi_arm/platform.cpp new file mode 100644 index 0000000..d5b2a69 --- /dev/null +++ b/src/system/kernel/platform/raspberrypi_arm/platform.cpp @@ -0,0 +1,3 @@ +/* + Just a dummy. No BIOS services are required in the kernel. +*/ diff --git a/src/system/ldscripts/arm/boot_loader_raspberrypi_arm.ld b/src/system/ldscripts/arm/boot_loader_raspberrypi_arm.ld new file mode 100644 index 0000000..70176e6 --- /dev/null +++ b/src/system/ldscripts/arm/boot_loader_raspberrypi_arm.ld @@ -0,0 +1,67 @@ +OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") +OUTPUT_ARCH(arm) + +ENTRY(_start) +SECTIONS +{ + . = BOARD_LOADER_BASE; + + /* text/read-only data */ + .text : { *(.text .gnu.linkonce.t.*) } + + . = ALIGN(0x4); + __ctor_list = .; + .ctors : { *(.ctors) } + __ctor_end = .; + + .rodata : { *(.rodata .rodata.*) } + + /* writable data */ + . = ALIGN(0x1000); + __data_start = .; + .data : { *(.data .gnu.linkonce.d.*) } + + /* exception unwinding - should really not be needed! */ + __exidx_start = .; + .ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) } + __exidx_end = .; + + /* uninitialized data (in same segment as writable data) */ + __bss_start = .; + .bss : { *(.bss) } + + . = ALIGN(0x1000); + _end = . ; + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + /* DWARF debug sections. + Symbols in the DWARF debugging sections are relative to the beginning + of the section so we begin them at 0. */ + /* DWARF 1 */ + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + /* GNU DWARF 1 extensions */ + .debug_srcinfo 0 : { *(.debug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames) } + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_line 0 : { *(.debug_line) } + .debug_frame 0 : { *(.debug_frame) } + .debug_str 0 : { *(.debug_str) } + .debug_loc 0 : { *(.debug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo) } + /* SGI/MIPS DWARF 2 extensions */ + .debug_weaknames 0 : { *(.debug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames) } + .debug_varnames 0 : { *(.debug_varnames) } + /* These must appear regardless of . */ + + /* Strip unnecessary stuff */ +/* /DISCARD/ : { *(.comment .note .eh_frame .dtors .stab .stabstr .debug*) }*/ +}