diff --git a/headers/private/kernel/boot/platform/u-boot/platform_arch.h b/headers/private/kernel/boot/platform/u-boot/platform_arch.h new file mode 100644 index 0000000000..aa45a1867f --- /dev/null +++ b/headers/private/kernel/boot/platform/u-boot/platform_arch.h @@ -0,0 +1,38 @@ +/* +** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved. +** Distributed under the terms of the OpenBeOS License. +*/ +#ifndef KERNEL_BOOT_PLATFORM_UBOOT_ARCH_H +#define KERNEL_BOOT_PLATFORM_UBOOT_ARCH_H + + +#include + +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_UBOOT_ARCH_H */ diff --git a/src/system/boot/platform/u-boot/Jamfile b/src/system/boot/platform/u-boot/Jamfile index b177daca71..c707717eaf 100644 --- a/src/system/boot/platform/u-boot/Jamfile +++ b/src/system/boot/platform/u-boot/Jamfile @@ -29,6 +29,7 @@ SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src add-ons accelerants common ] ; KernelMergeObject boot_platform_u-boot.o : shell.S + arch_start_kernel.S start2.cpp debug.cpp console.cpp @@ -223,7 +224,8 @@ BuildUBootSDImage haiku-$(HAIKU_BOOT_BOARD).mmc : $(HAIKU_BOARD_SDIMAGE_FILES) ; NotFile haiku-arm-mmc ; Depends haiku-arm-mmc : haiku-$(HAIKU_BOOT_BOARD).mmc ; -SEARCH on [ FGristFiles shell.S ] +# TODO: move to arch/arm +SEARCH on [ FGristFiles shell.S arch_start_kernel.S ] = [ FDirName $(HAIKU_TOP) src system boot platform $(TARGET_BOOT_PLATFORM) arch $(TARGET_ARCH) ] ; SEARCH on [ FGristFiles $(genericPlatformSources) ] = [ FDirName $(HAIKU_TOP) src system boot platform generic ] ; diff --git a/src/system/boot/platform/u-boot/arch/arm/arch_start_kernel.S b/src/system/boot/platform/u-boot/arch/arm/arch_start_kernel.S new file mode 100644 index 0000000000..c03852702c --- /dev/null +++ b/src/system/boot/platform/u-boot/arch/arm/arch_start_kernel.S @@ -0,0 +1,38 @@ +/* + * Copyright 2011, François Revol . + * All rights reserved. Distributed under the terms of the MIT License. + */ + +#include + +#include + + + .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/u-boot/arch/arm/shell.S b/src/system/boot/platform/u-boot/arch/arm/shell.S index d66730c5bd..4e6274cc12 100644 --- a/src/system/boot/platform/u-boot/arch/arm/shell.S +++ b/src/system/boot/platform/u-boot/arch/arm/shell.S @@ -70,6 +70,8 @@ SYMBOL(_start_common): SYMBOL_END(_start_common) +//XXX: doesn't seem to work +//.data SYMBOL(gUBootGlobalData): @@ -79,6 +81,9 @@ SYMBOL(gUImage): .long 0 SYMBOL_END(gUImage) SYMBOL(gUBootOS): - .byte 0 +//XXX: bug? Using .byte makes the next asm symbol +// to be at the same address +// .byte 0 + .long 0 SYMBOL_END(gUBootOS) diff --git a/src/system/boot/platform/u-boot/start2.cpp b/src/system/boot/platform/u-boot/start2.cpp index 9d035b60a7..ac42a104d8 100644 --- a/src/system/boot/platform/u-boot/start2.cpp +++ b/src/system/boot/platform/u-boot/start2.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include @@ -49,7 +50,7 @@ extern "C" void dump_uimage(struct image_header *image); extern struct image_header *gUImage; extern uboot_arm_gd *gUBootGlobalData; -extern uint8 gUBootOS; +extern uint32 gUBootOS; register volatile uboot_arm_gd *gGD asm ("r8"); @@ -86,10 +87,7 @@ abort(void) extern "C" void platform_start_kernel(void) { - static struct kernel_args *args = &gKernelArgs; - // something goes wrong when we pass &gKernelArgs directly - // to the assembler inline below - might be a bug in GCC - // or I don't see something important... + addr_t kernelEntry = gKernelArgs.kernel_image.elf_header.e_entry; addr_t stackTop = gKernelArgs.cpu_kstack[0].start + gKernelArgs.cpu_kstack[0].size; @@ -101,22 +99,10 @@ platform_start_kernel(void) dprintf("kernel entry at %lx\n", gKernelArgs.kernel_image.elf_header.e_entry); - asm("MOV sp, %[adr]"::[adr] "r" (stackTop)); - asm("MOV r0, %[args]"::[args] "r" (args)); - asm("MOV r1, #0"::); - asm("MOV pc, %[entry]"::[entry] "r" - (gKernelArgs.kernel_image.elf_header.e_entry)); + status_t error = arch_start_kernel(&gKernelArgs, kernelEntry, + stackTop); -/* asm("movl %0, %%eax; " // move stack out of way - "movl %%eax, %%esp; " - : : "m" (stackTop)); - asm("pushl $0x0; " // we're the BSP cpu (0) - "pushl %0; " // kernel args - "pushl $0x0;" // dummy retval for call to main - "pushl %1; " // this is the start address - "ret; " // jump. - : : "g" (args), "g" (gKernelArgs.kernel_image.elf_header.e_entry)); -*/ + dprintf("kernel returned!\n"); panic("kernel returned!\n"); }