1 | /* |
---|
2 | * This is based on the mvme-crt0.S file from libgloss/rs6000. |
---|
3 | * crt0.S -- startup file for PowerPC systems. |
---|
4 | * |
---|
5 | * (c) 1998, Radstone Technology plc. |
---|
6 | * |
---|
7 | * |
---|
8 | * This is an unpublished work the copyright in which vests |
---|
9 | * in Radstone Technology plc. All rights reserved. |
---|
10 | * |
---|
11 | * The information contained herein is the property of Radstone |
---|
12 | * Technology plc. and is supplied without liability for |
---|
13 | * errors or omissions and no part may be reproduced, used or |
---|
14 | * disclosed except as authorized by contract or other written |
---|
15 | * permission. The copyright and the foregoing |
---|
16 | * restriction on reproduction, use and disclosure extend to |
---|
17 | * all the media in which this information may be |
---|
18 | * embodied. |
---|
19 | * |
---|
20 | * Copyright (c) 1995 Cygnus Support |
---|
21 | * |
---|
22 | * The authors hereby grant permission to use, copy, modify, distribute, |
---|
23 | * and license this software and its documentation for any purpose, provided |
---|
24 | * that existing copyright notices are retained in all copies and that this |
---|
25 | * notice is included verbatim in any distributions. No written agreement, |
---|
26 | * license, or royalty fee is required for any of the authorized uses. |
---|
27 | * Modifications to this software may be copyrighted by their authors |
---|
28 | * and need not follow the licensing terms described here, provided that |
---|
29 | * the new terms are clearly indicated on the first page of each file where |
---|
30 | * they apply. |
---|
31 | * |
---|
32 | * start.S,v 1.4 2002/04/19 13:25:27 joel Exp |
---|
33 | */ |
---|
34 | /* |
---|
35 | #include <ppc-asm.h> |
---|
36 | #include <bsp.h> |
---|
37 | */ |
---|
38 | |
---|
39 | #include <rtems/asm.h> |
---|
40 | #include <rtems/score/cpu.h> |
---|
41 | #include <libcpu/io.h> |
---|
42 | #include <ppc-asm.h> |
---|
43 | |
---|
44 | #define H0_60X_ICE 0x8000 /* HID0 I-Cache Enable */ |
---|
45 | #define H0_60X_DCE 0x4000 /* HID0 D-Cache Enable */ |
---|
46 | |
---|
47 | .file "start.s" |
---|
48 | |
---|
49 | .extern FUNC_NAME(atexit) |
---|
50 | .globl FUNC_NAME(__atexit) |
---|
51 | .section ".sdata","aw" |
---|
52 | .align 2 |
---|
53 | FUNC_NAME(__atexit): /* tell C's eabi-ctor's we have an atexit function */ |
---|
54 | .long FUNC_NAME(atexit)@fixup /* and that it is to register __do_global_dtors */ |
---|
55 | |
---|
56 | .section ".fixup","aw" |
---|
57 | .align 2 |
---|
58 | .long FUNC_NAME(__atexit) |
---|
59 | |
---|
60 | .text |
---|
61 | .globl __rtems_entry_point |
---|
62 | .type __rtems_entry_point,@function |
---|
63 | __rtems_entry_point: |
---|
64 | |
---|
65 | /* Set MSR */ |
---|
66 | /* |
---|
67 | * Enable data and instruction address translation and floating point |
---|
68 | */ |
---|
69 | li r3,MSR_IR | MSR_DR | MSR_FP |
---|
70 | mtmsr r3 |
---|
71 | |
---|
72 | /* XXX - ADD BACK IN CACHING INSTRUCTIONS */ |
---|
73 | |
---|
74 | /* clear bss */ |
---|
75 | lis r6,__bss_start@h |
---|
76 | ori r6,r6,__bss_start@l |
---|
77 | lis r7,__bss_end@h |
---|
78 | ori r7,r7,__bss_end@l |
---|
79 | |
---|
80 | cmplw 1,r6,r7 |
---|
81 | bc 4,4,.Lbss_done |
---|
82 | |
---|
83 | subf r8,r6,r7 /* number of bytes to zero */ |
---|
84 | srwi r9,r8,2 /* number of words to zero */ |
---|
85 | mtctr r9 |
---|
86 | li r0,0 /* zero to clear memory */ |
---|
87 | addi r6,r6,-4 /* adjust so we can use stwu */ |
---|
88 | .Lbss_loop: |
---|
89 | stwu r0,4(r6) /* zero bss */ |
---|
90 | bdnz .Lbss_loop |
---|
91 | |
---|
92 | .Lbss_done: |
---|
93 | |
---|
94 | /* clear sbss */ |
---|
95 | lis r6,__sbss_start@h |
---|
96 | ori r6,r6,__sbss_start@l |
---|
97 | lis r7,__sbss_end@h |
---|
98 | ori r7,r7,__sbss_end@l |
---|
99 | |
---|
100 | cmplw 1,r6,r7 |
---|
101 | bc 4,4,.Lsbss_done |
---|
102 | |
---|
103 | subf r8,r6,r7 /* number of bytes to zero */ |
---|
104 | srwi r9,r8,2 /* number of words to zero */ |
---|
105 | mtctr r9 |
---|
106 | li r0,0 /* zero to clear memory */ |
---|
107 | addi r6,r6,-4 /* adjust so we can use stwu */ |
---|
108 | .Lsbss_loop: |
---|
109 | stwu r0,4(r6) /* zero sbss */ |
---|
110 | bdnz .Lsbss_loop |
---|
111 | |
---|
112 | .Lsbss_done: |
---|
113 | |
---|
114 | lis sp,__stack@h |
---|
115 | ori sp,sp,__stack@l |
---|
116 | |
---|
117 | /* set up initial stack frame */ |
---|
118 | addi sp,sp,-4 /* make sure we don't overwrite debug mem */ |
---|
119 | lis r0,0 |
---|
120 | stw r0,0(sp) /* clear back chain */ |
---|
121 | stwu sp,-56(sp) /* push another stack frame */ |
---|
122 | |
---|
123 | li r3, 0 /* command line */ |
---|
124 | |
---|
125 | /* Let her rip */ |
---|
126 | bl FUNC_NAME(boot_card) |
---|
127 | |
---|
128 | /* |
---|
129 | * This should never get reached |
---|
130 | */ |
---|
131 | /* |
---|
132 | * Return MSR to its reset state |
---|
133 | */ |
---|
134 | li r3,0 |
---|
135 | mtmsr r3 |
---|
136 | isync |
---|
137 | |
---|
138 | /* |
---|
139 | * Call reset entry point |
---|
140 | */ |
---|
141 | lis r3,0xfff0 |
---|
142 | ori r3,r3,0x100 |
---|
143 | mtlr r3 |
---|
144 | blr |
---|
145 | .Lstart: |
---|
146 | .size __rtems_entry_point,.Lstart-__rtems_entry_point |
---|
147 | |
---|
148 | .comm environ,4,4 |
---|