hrev43297 adds 3 changesets to branch 'master' old head: 3383e56426351ecd8da51033ae84f28eeffe4bbb new head: d1460ff57b0d23d93eecb44e53ef3fc06e8b10f1 ---------------------------------------------------------------------------- e359181: ARM: move kernel calling code to arch specific file * needs some more cleanup. * had to change gUBootOS to 32bit to avoid a linker bug. 1d6f7e8: ARM: Use proper Jamfiles for u-boot/arch/ subdirs d1460ff: ARM: Rename flash and mmc base generic targets They are not so much arm-specific, really. We now have haiku-flash-*image variations, and haiku-mmc-image. [ François Revol <revol@xxxxxxx> ] ---------------------------------------------------------------------------- 7 files changed, 137 insertions(+), 33 deletions(-) .../kernel/boot/platform/u-boot/platform_arch.h | 38 ++++++++++++++++ src/system/boot/platform/u-boot/Jamfile | 32 +++++++++----- src/system/boot/platform/u-boot/arch/Jamfile | 3 + src/system/boot/platform/u-boot/arch/arm/Jamfile | 24 ++++++++++ .../platform/u-boot/arch/arm/arch_start_kernel.S | 38 ++++++++++++++++ src/system/boot/platform/u-boot/arch/arm/shell.S | 7 +++- src/system/boot/platform/u-boot/start2.cpp | 28 +++--------- ############################################################################ Commit: e3591817b30085093bed476f9c1709f729df16ef URL: http://cgit.haiku-os.org/haiku/commit/?id=e359181 Author: François Revol <revol@xxxxxxx> Date: Sun Nov 20 14:59:16 2011 UTC ARM: move kernel calling code to arch specific file * needs some more cleanup. * had to change gUBootOS to 32bit to avoid a linker bug. ---------------------------------------------------------------------------- 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 0000000..aa45a18 --- /dev/null +++ b/headers/private/kernel/boot/platform/u-boot/platform_arch.h @@ -0,0 +1,38 @@ +/* +** Copyright 2003, Axel Dörfler, axeld@xxxxxxxxxxxxxxxxx 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 <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_UBOOT_ARCH_H */ diff --git a/src/system/boot/platform/u-boot/Jamfile b/src/system/boot/platform/u-boot/Jamfile index b177dac..c707717 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 0000000..c038527 --- /dev/null +++ b/src/system/boot/platform/u-boot/arch/arm/arch_start_kernel.S @@ -0,0 +1,38 @@ +/* + * 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/u-boot/arch/arm/shell.S b/src/system/boot/platform/u-boot/arch/arm/shell.S index d66730c..4e6274c 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 9d035b6..ac42a10 100644 --- a/src/system/boot/platform/u-boot/start2.cpp +++ b/src/system/boot/platform/u-boot/start2.cpp @@ -17,6 +17,7 @@ #include <boot/heap.h> #include <boot/stage2.h> #include <arch/cpu.h> +#include <platform_arch.h> #include <string.h> @@ -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)); - -/* 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)); -*/ + status_t error = arch_start_kernel(&gKernelArgs, kernelEntry, + stackTop); + + dprintf("kernel returned!\n"); panic("kernel returned!\n"); } ############################################################################ Commit: 1d6f7e86eed15de3118fedc0eb5d0d193b7318d4 URL: http://cgit.haiku-os.org/haiku/commit/?id=1d6f7e8 Author: François Revol <revol@xxxxxxx> Date: Mon Nov 21 00:11:17 2011 UTC ARM: Use proper Jamfiles for u-boot/arch/ subdirs ---------------------------------------------------------------------------- diff --git a/src/system/boot/platform/u-boot/Jamfile b/src/system/boot/platform/u-boot/Jamfile index c707717..f1e8948 100644 --- a/src/system/boot/platform/u-boot/Jamfile +++ b/src/system/boot/platform/u-boot/Jamfile @@ -27,9 +27,8 @@ local uImageFakeOS = "netbsd" ; SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src add-ons accelerants common ] ; -KernelMergeObject boot_platform_u-boot.o : - shell.S - arch_start_kernel.S +# First build the non arch dependent parts +KernelMergeObject boot_platform_u-boot_common.o : start2.cpp debug.cpp console.cpp @@ -48,6 +47,13 @@ KernelMergeObject boot_platform_u-boot.o : : boot_platform_generic.a ; +KernelMergeObject boot_platform_u-boot.o : + : : + # must come first to have _start_* at correct locations + boot_platform_u-boot_$(TARGET_ARCH).o + boot_platform_u-boot_common.o +; + # include board-specific defs SubInclude HAIKU_TOP src system boot platform $(TARGET_BOOT_PLATFORM) board ; # reset SubDir @@ -233,3 +239,5 @@ SEARCH on [ FGristFiles $(genericPlatformSources) ] # Tell the build system to where stage1.bin can be found, so it can be used # elsewhere. SEARCH on stage1.bin = $(SUBDIR) ; + +SubInclude HAIKU_TOP src system boot platform u-boot arch ; diff --git a/src/system/boot/platform/u-boot/arch/Jamfile b/src/system/boot/platform/u-boot/arch/Jamfile new file mode 100644 index 0000000..c2aee1d --- /dev/null +++ b/src/system/boot/platform/u-boot/arch/Jamfile @@ -0,0 +1,3 @@ +SubDir HAIKU_TOP src system boot platform u-boot arch ; + +SubInclude HAIKU_TOP src system boot platform u-boot arch $(TARGET_ARCH) ; diff --git a/src/system/boot/platform/u-boot/arch/arm/Jamfile b/src/system/boot/platform/u-boot/arch/arm/Jamfile new file mode 100644 index 0000000..a81e46b --- /dev/null +++ b/src/system/boot/platform/u-boot/arch/arm/Jamfile @@ -0,0 +1,24 @@ +SubDir HAIKU_TOP src system boot platform u-boot arch arm ; + +SubDirHdrs $(HAIKU_TOP) src system boot platform $(TARGET_BOOT_PLATFORM) ; +UsePrivateSystemHeaders ; +UsePrivateHeaders kernel [ FDirName kernel arch $(TARGET_ARCH) ] + [ FDirName kernel boot platform $(HAIKU_BOOT_PLATFORM) ] ; +UsePrivateHeaders [ FDirName kernel arch $(TARGET_ARCH) board $(TARGET_BOOT_BOARD) ] ; + +SubDirC++Flags -fno-rtti ; + +KernelMergeObject boot_platform_u-boot_arm.o : + # must come first to have _start_* at correct locations + shell.S + + #arch_mmu.cpp + #arch_cpu_asm.S + arch_start_kernel.S + #cpu.cpp + #mmu.cpp + : -fno-pic +; + +#SEARCH on [ FGristFiles arch_cpu_asm.S arch_mmu.cpp ] +# = [ FDirName $(HAIKU_TOP) src system kernel arch $(TARGET_ARCH) ] ; ############################################################################ Revision: hrev43297 Commit: d1460ff57b0d23d93eecb44e53ef3fc06e8b10f1 URL: http://cgit.haiku-os.org/haiku/commit/?id=d1460ff Author: François Revol <revol@xxxxxxx> Date: Mon Nov 21 00:28:44 2011 UTC ARM: Rename flash and mmc base generic targets They are not so much arm-specific, really. We now have haiku-flash-*image variations, and haiku-mmc-image. ---------------------------------------------------------------------------- diff --git a/src/system/boot/platform/u-boot/Jamfile b/src/system/boot/platform/u-boot/Jamfile index f1e8948..d708deb 100644 --- a/src/system/boot/platform/u-boot/Jamfile +++ b/src/system/boot/platform/u-boot/Jamfile @@ -212,23 +212,23 @@ if $(HAIKU_BOARD_UBOOT_IMAGE) && $(HAIKU_BOARD_UBOOT_IMAGE_URL) { # flash image targets BuildUBootFlashImage haiku-$(HAIKU_BOOT_BOARD)_flash_image_raw.img : haiku_loader : $(ubootFile) ; -NotFile haiku-arm-image ; -Depends haiku-arm-image : haiku-$(HAIKU_BOOT_BOARD)_flash_image_raw.img ; +NotFile haiku-flash-image ; +Depends haiku-flash-image : haiku-$(HAIKU_BOOT_BOARD)_flash_image_raw.img ; #BuildUBootFlashImage haiku-$(HAIKU_BOOT_BOARD)_flash_image_elf.img : boot_loader_u-boot : # $(ubootFile) ; -#NotFile haiku-arm-elf-image ; -#Depends haiku-arm-elf-image : haiku-$(HAIKU_BOOT_BOARD)_flash_image_elf.img ; +#NotFile haiku-flash-elf-image ; +#Depends haiku-flash-elf-image : haiku-$(HAIKU_BOOT_BOARD)_flash_image_elf.img ; BuildUBootFlashImage haiku-$(HAIKU_BOOT_BOARD)_flash_image_uimage.img : haiku_loader.ub : $(ubootFile) ; -NotFile haiku-arm-uimage ; -Depends haiku-arm-uimage : haiku-$(HAIKU_BOOT_BOARD)_flash_image_uimage.img ; +NotFile haiku-flash-uimage ; +Depends haiku-flash-uimage : haiku-$(HAIKU_BOOT_BOARD)_flash_image_uimage.img ; # SD/mmc image targets BuildUBootSDImage haiku-$(HAIKU_BOOT_BOARD).mmc : $(HAIKU_BOARD_SDIMAGE_FILES) ; -NotFile haiku-arm-mmc ; -Depends haiku-arm-mmc : haiku-$(HAIKU_BOOT_BOARD).mmc ; +NotFile haiku-mmc-image ; +Depends haiku-mmc-image : haiku-$(HAIKU_BOOT_BOARD).mmc ; # TODO: move to arch/arm SEARCH on [ FGristFiles shell.S arch_start_kernel.S ]