obs600_locore.S revision 1.1.4.2 1 /* $NetBSD: obs600_locore.S,v 1.1.4.2 2010/05/30 05:16:44 rmind Exp $ */
2 /*
3 * Copyright (c) 2009 KIYOHARA Takashi
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
19 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
23 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
24 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE.
26 */
27
28 #undef PPC_4XX_NOCACHE
29 #define _NOREGNAMES
30
31 #include "opt_ddb.h"
32 #include "opt_ppcarch.h"
33 #include "opt_ppcparam.h"
34 #include "assym.h"
35 #include "ksyms.h"
36
37 #include <machine/param.h>
38 #include <machine/psl.h>
39 #include <machine/trap.h>
40 #include <machine/asm.h>
41
42 #include <powerpc/ibm4xx/spr.h>
43 #include <powerpc/ibm4xx/pmap.h>
44
45
46 /*
47 * Globals
48 */
49 GLOBAL(proc0paddr)
50 .long 0 /* proc0 p_addr */
51
52 /*
53 * This symbol is here for the benefit of kvm_mkdb, and is supposed to
54 * mark the start of kernel text.
55 */
56 .text
57 .globl _C_LABEL(kernel_text)
58 _C_LABEL(kernel_text):
59
60 /*
61 * Kernel start routine for OpenBlockS600
62 * this code is excuted at the very first after the kernel is loaded
63 * by U-Boot.
64 */
65 .text
66 .globl __start
67 __start:
68 mr %r31, %r3 /* argc of 'go's */
69 mr %r30, %r4 /* argv of 'go's */
70 mr %r29, %r6 /* arg string of 'bootm's */
71
72 li %r0, 0
73 mtmsr %r0 /* Disable FPU/MMU/exceptions */
74 isync
75
76 #ifdef PPC_4XX_NOCACHE
77 /* Disable all caches for physical addresses */
78 li %r0, 0
79 #else
80 /* Allow cacheing for only the first 2GB of RAM */
81 lis %r0, 0xffff
82 #endif
83 mtdccr %r0
84 mticcr %r0
85
86 /* Invalidate all TLB entries */
87 tlbia
88 sync
89 isync
90
91 /* get start of bss */
92 lis %r3, _C_LABEL(_edata)-4@ha
93 addi %r3, %r3, _C_LABEL(_edata)-4@l
94 /* get end of kernel memory */
95 lis %r8, _C_LABEL(end)@ha
96 addi %r8, %r8, _C_LABEL(end)@l
97 /* zero bss */
98 li %r4, 0
99 2: stwu %r4, %r4(3)
100 cmpw %r3, %r8
101 bne+ 2b
102
103 #if NKSYMS || defined(DDB) || defined(MODULAR)
104 /* If we had symbol table location we'd store it here and would've adjusted r8 here */
105 lis %r7, _C_LABEL(startsym)@ha
106 addi %r7, %r7, _C_LABEL(startsym)@l
107 stw %r8, 0(%r7)
108 lis %r7, _C_LABEL(endsym)@ha
109 addi %r7, %r7, _C_LABEL(endsym)@l
110 stw %r8, 0(%r7)
111 #endif
112
113 /* Set kernel MMU context. */
114 li %r0, KERNEL_PID
115 mtpid %r0
116 sync
117
118 INIT_CPUINFO(8,1,9,0)
119 mr %r4, %r8
120
121 lis %r3, __start@ha
122 addi %r3, %r3, __start@l
123
124 mr %r6, %r31 /* argc of 'go's */
125 mr %r7, %r30 /* argv of 'go's */
126 mr %r8, %r29 /* arg strings of 'bootm's */
127
128 bl _C_LABEL(initppc)
129 bl _C_LABEL(main)
130
131 not_reached:
132 b not_reached
133
134 #include <powerpc/ibm4xx/4xx_locore.S>
135