1/* 2 * Copyright 2005, Ingo Weinhold <bonefish@cs.tu-berlin.de>. 3 * All rights reserved. Distributed under the terms of the MIT License. 4 */ 5 6#include <asm_defs.h> 7 8 9/* status_t arch_start_kernel(struct kernel_args *kernelArgs, 10 addr_t kernelEntry, addr_t kernelStackTop); 11 12 r3 - kernelArgs 13 r4 - kernelEntry 14 r5 - kernelStackTop 15*/ 16FUNCTION(arch_start_kernel): 17 // push a stack frame 18 stwu %r1, -32(%r1) 19 mflr %r0 20 stw %r0, 36(%r1) 21 22 // save the old stack pointer in r29 23 stw %r29, 20(%r1) 24 mr %r29, %r1 25 26 // set up the kernel stack 27 subi %r1, %r5, 16 28 29 // clear the pointer to the previous frame 30 li %r0, 0 31 stw %r0, 0(%r1) 32 33 // enter the kernel 34 mtlr %r4 35 li %r4, 0 36 blrl 37 38 /* Actually we should never get here, but at least for debugging purposes 39 it's quite nice to return in an orderly manner. */ 40 41 // reset the boot loader stack 42 mr %r1, %r29 43 lwz %r29, 20(%r1) 44 45 // pop the stack frame 46 lwz %r0, 36(%r1) 47 mtlr %r0 48 addi %r1, %r1, 32 49 blr 50FUNCTION_END(arch_start_kernel) 51 52