Annotation of src/sys/arch/macppc/macppc/locore.S, Revision 1.79
1.79 ! thorpej 1: /* $NetBSD: locore.S,v 1.78 2021/02/17 23:21:46 thorpej Exp $ */
1.1 tsubai 2:
3: /*
4: * Copyright (C) 1995, 1996 Wolfgang Solfrank.
5: * Copyright (C) 1995, 1996 TooLs GmbH.
6: * All rights reserved.
7: *
8: * Redistribution and use in source and binary forms, with or without
9: * modification, are permitted provided that the following conditions
10: * are met:
11: * 1. Redistributions of source code must retain the above copyright
12: * notice, this list of conditions and the following disclaimer.
13: * 2. Redistributions in binary form must reproduce the above copyright
14: * notice, this list of conditions and the following disclaimer in the
15: * documentation and/or other materials provided with the distribution.
16: * 3. All advertising materials mentioning features or use of this software
17: * must display the following acknowledgement:
18: * This product includes software developed by TooLs GmbH.
19: * 4. The name of TooLs GmbH may not be used to endorse or promote products
20: * derived from this software without specific prior written permission.
21: *
22: * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
23: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25: * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28: * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29: * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30: * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31: * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32: */
33:
1.4 jonathan 34: #include "opt_ddb.h"
1.43 dbj 35: #include "opt_kgdb.h"
1.27 tsubai 36: #include "opt_lockdebug.h"
1.63 apb 37: #include "opt_modular.h"
1.24 thorpej 38: #include "opt_multiprocessor.h"
1.47 chs 39: #include "opt_altivec.h"
1.48 matt 40: #include "opt_ppcparam.h"
1.52 tsutsui 41: #include "ksyms.h"
1.1 tsubai 42: #include "assym.h"
43:
44: #include <sys/syscall.h>
45:
46: #include <machine/param.h>
47: #include <machine/psl.h>
48: #include <machine/trap.h>
49: #include <machine/asm.h>
50:
1.41 matt 51: #include <powerpc/spr.h>
1.65 matt 52: #include <powerpc/oea/spr.h>
53:
1.1 tsubai 54: /*
55: * Some instructions gas doesn't understand (yet?)
56: */
57: #define bdneq bdnzf 2,
58:
1.26 tsubai 59: /*
1.48 matt 60: * Globals
61: */
62: .data
1.1 tsubai 63: GLOBAL(esym)
64: .long 0 /* end of symbol table */
65:
66: /*
67: * This symbol is here for the benefit of kvm_mkdb, and is supposed to
68: * mark the start of kernel text.
69: */
1.48 matt 70:
1.1 tsubai 71: .text
72: .globl _C_LABEL(kernel_text)
73: _C_LABEL(kernel_text):
74:
75: /*
76: * Startup entry. Note, this must be the first thing in the text
77: * segment!
1.78 thorpej 78: *
79: * Register state as transfer is passed from OpenFirmware / boot loader:
80: *
81: * %r1 Stack provided by OpenFirmware / boot loader
82: * %r3 Reserved for platform binding (unused here)
83: * %r4 Reserved for platform binding (unused here)
84: * %r5 OpenFirmware client entry point
85: * %r6 Arguments
86: * %r7 Arguments length
1.1 tsubai 87: */
88: .text
89: .globl __start
90: __start:
1.78 thorpej 91: /* Save off arguments that we need preserved. */
92: mr %r13,%r6
93: mr %r14,%r7
94:
1.72 chs 95: bl _C_LABEL(ofwinit) /* init OF */
1.5 tsubai 96:
1.77 thorpej 97: li %r0,0
1.74 macallan 98: #ifndef FIRMWORKSBUGS
1.77 thorpej 99: mtmsr %r0 /* Disable FPU/MMU/exceptions */
1.74 macallan 100: #endif
1.1 tsubai 101: isync
102:
1.76 thorpej 103: bl _C_LABEL(cpu_model_init) /* init oeacpufeat */
104:
1.1 tsubai 105: /* compute end of kernel memory */
1.77 thorpej 106: lis %r4,_C_LABEL(end)@ha
107: addi %r4,%r4,_C_LABEL(end)@l
1.61 ad 108: #if NKSYMS || defined(DDB) || defined(MODULAR)
1.14 tsubai 109: /* skip symbol table */
1.77 thorpej 110: mr %r6,%r13
111: mr %r7,%r14
112: cmpwi %r6,0
1.15 tsubai 113: beq 1f
1.77 thorpej 114: add %r9,%r6,%r7 /* r9 = args + l */
115: lwz %r9,-8(%r9) /* esym */
116: cmpwi %r9,0
1.14 tsubai 117: beq 1f
1.77 thorpej 118: mr %r4,%r9
1.14 tsubai 119: 1:
1.1 tsubai 120: #endif
1.48 matt 121:
1.57 sanjayl 122: #if defined (PMAC_G5) || defined (MAMBO)
1.56 sanjayl 123: /* and clear HID5 DCBZ bits (56/57), need to do this early */
1.77 thorpej 124: mfspr %r11,SPR_HID5
125: rldimi %r11,%r0,6,56
1.56 sanjayl 126: sync
1.77 thorpej 127: mtspr SPR_HID5,%r11
1.56 sanjayl 128: isync
129: sync
130:
131: /* Setup HID1 features, prefetch + i-cacheability controlled by PTE */
1.77 thorpej 132: mfspr %r0,SPR_HID1
133: li %r11,0x1200
134: sldi %r11,%r11,44
135: or %r0,%r0,%r11
136: mtspr SPR_HID1,%r0
1.56 sanjayl 137: isync
138: sync
139:
140: /* Restore r0 */
1.77 thorpej 141: li %r0,0
1.56 sanjayl 142: #endif /* PMAC_G5 */
143:
144:
1.48 matt 145: /*
146: * Initialize cpu_info[0]
147: */
1.77 thorpej 148: INIT_CPUINFO(%r4,%r1,%r9,%r0)
1.29 tsubai 149:
1.77 thorpej 150: lis %r3,__start@ha
151: addi %r3,%r3,__start@l
152: mr %r5,%r6 /* args string */
1.1 tsubai 153: bl _C_LABEL(initppc)
154: bl _C_LABEL(main)
155: b _C_LABEL(OF_exit)
156:
1.55 sanjayl 157: #if defined (PPC_OEA64_BRIDGE)
158: /* Return all 64 bits of HID4 */
159: .text
160: .globl _C_LABEL(mfhid4)
161: _C_LABEL(mfhid4):
1.77 thorpej 162: mfspr %r4, SPR_HID4
163: std %r4, 0(%r3)
1.55 sanjayl 164: blr
165:
166: /* Set all 64 bits of HID4 */
167: .text
168: .globl _C_LABEL(mthid4)
169: _C_LABEL(mthid4):
1.77 thorpej 170: ld %r4, 0(%r3)
1.55 sanjayl 171: sync
1.77 thorpej 172: mtspr SPR_HID4, %r4
1.55 sanjayl 173: isync
174: isync
175: blr
176:
177: .text
178: .globl _C_LABEL(change_hid4)
179: _C_LABEL(change_hid4):
1.77 thorpej 180: mfspr %r6, SPR_HID4
181: rldicl %r5, %r6, 32, 0
182: ori %r5, %r5, 0x100
183: rldicl %r5, %r5, 32, 0
184: std %r5, 0(%r3)
1.55 sanjayl 185: blr
186: #endif
187:
1.45 matt 188: /*
189: * Pull in common Open Firmware code.
190: */
1.50 matt 191: #include <powerpc/oea/ofw_subr.S>
1.36 matt 192:
193: /*
194: * Pull in common switch and setfault code.
195: */
196: #include <powerpc/powerpc/locore_subr.S>
197:
198: /*
199: * Pull in common trap vector code.
200: */
201: #include <powerpc/powerpc/trap_subr.S>
1.59 garbled 202:
203: /*
204: * Pull in common pio / bus_space code.
205: */
206: #include <powerpc/powerpc/pio_subr.S>
CVSweb <webmaster@jp.NetBSD.org>