ARM: move kernel calling code to arch specific file
* needs some more cleanup. * had to change gUBootOS to 32bit to avoid a linker bug.
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
** Copyright 2003, Axel Dörfler, [email protected]. 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 */
|
||||
@@ -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 ] ;
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2011, François Revol <revol@free.fr>.
|
||||
* 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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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));
|
||||
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");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user