1 | /* |
---|
2 | * crt0.S -- startup file for hppa on RTEMS |
---|
3 | * |
---|
4 | * $Id$ |
---|
5 | */ |
---|
6 | |
---|
7 | .COPYRIGHT "crt0.S for hppa" |
---|
8 | |
---|
9 | .DATA |
---|
10 | |
---|
11 | _progname .STRINGZ "simhppa" |
---|
12 | _crt0_argv .WORD _progname, 0 |
---|
13 | |
---|
14 | /* |
---|
15 | * Set up the standard spaces (sections) These definitions come |
---|
16 | * from /lib/pcc_prefix.s. |
---|
17 | */ |
---|
18 | .TEXT |
---|
19 | |
---|
20 | /* |
---|
21 | * stuff we need that is defined elsewhere. |
---|
22 | */ |
---|
23 | .IMPORT boot_card, CODE |
---|
24 | .IMPORT _bss_start, DATA |
---|
25 | .IMPORT _bss_end, DATA |
---|
26 | .IMPORT environ, DATA |
---|
27 | |
---|
28 | /* |
---|
29 | * start -- set things up so the application will run. |
---|
30 | * |
---|
31 | */ |
---|
32 | .PROC |
---|
33 | .CALLINFO SAVE_SP, FRAME=48 |
---|
34 | .EXPORT $START$,ENTRY |
---|
35 | .EXPORT start,ENTRY |
---|
36 | $START$ |
---|
37 | start: |
---|
38 | |
---|
39 | /* |
---|
40 | * Get a stack |
---|
41 | */ |
---|
42 | |
---|
43 | ldil L%crt_stack+48,%r30 |
---|
44 | ldo R%crt_stack+48(%r30),%r30 |
---|
45 | |
---|
46 | /* |
---|
47 | * we need to set %r27 (global data pointer) here |
---|
48 | */ |
---|
49 | |
---|
50 | ldil L%$global$,%r27 |
---|
51 | ldo R%$global$(%r27),%r27 |
---|
52 | |
---|
53 | /* |
---|
54 | * zerobss -- zero out the bss section |
---|
55 | * XXX We don't do this since simulator and boot rom will do this for us. |
---|
56 | */ |
---|
57 | #if 0 |
---|
58 | ; load the start of bss |
---|
59 | ldil L%_bss_start,%r4 |
---|
60 | ldo R%_bss_start(%r4),%r4 |
---|
61 | |
---|
62 | ; load the end of bss |
---|
63 | ldil L%_bss_end,%r5 |
---|
64 | ldo R%_bss_end(%r5),%r5 |
---|
65 | |
---|
66 | |
---|
67 | bssloop |
---|
68 | addi -1,%r5,%r5 ; decrement _bss_end |
---|
69 | stb %r0,0(0,%r5) ; we do this by bytes for now even |
---|
70 | ; though it is slower, it is safer |
---|
71 | combf,= %r4,%r5, bssloop |
---|
72 | nop |
---|
73 | #endif |
---|
74 | |
---|
75 | ldi 1,%ret0 |
---|
76 | |
---|
77 | /* |
---|
78 | * Call the "boot_card" routine from the application to get it going. |
---|
79 | * We call it as boot_card(1, argv, 0) |
---|
80 | */ |
---|
81 | |
---|
82 | copy %r0, %r24 |
---|
83 | |
---|
84 | ldil L%_crt0_argv,%r25 |
---|
85 | ldo R%_crt0_argv(%r25),%r25 |
---|
86 | |
---|
87 | bl boot_card,%r2 |
---|
88 | ldo 1(%r0), %r26 |
---|
89 | |
---|
90 | .PROCEND |
---|
91 | /* |
---|
92 | * _exit -- Exit from the application. Normally we cause a user trap |
---|
93 | * to return to the ROM monitor for another run, but with |
---|
94 | * this monitor we can not. Still, "C" wants this symbol, it |
---|
95 | * should be here. Jumping to 0xF0000004 jumps back into the |
---|
96 | * firmware, while writing a 5 to 0xFFFE0030 causes a reset. |
---|
97 | */ |
---|
98 | _exit_fallthru |
---|
99 | .PROC |
---|
100 | .CALLINFO |
---|
101 | .ENTRY |
---|
102 | |
---|
103 | ;; This just causes a breakpoint exception |
---|
104 | break 0x0,0x0 |
---|
105 | bv,n (%rp) |
---|
106 | nop |
---|
107 | .EXIT |
---|
108 | .PROCEND |
---|
109 | |
---|
110 | /* |
---|
111 | * _sr4export -- support for called functions. (mostly for GDB) |
---|
112 | */ |
---|
113 | .EXPORT _sr4export, ENTRY |
---|
114 | _sr4export: |
---|
115 | .PROC |
---|
116 | .CALLINFO |
---|
117 | .ENTRY |
---|
118 | |
---|
119 | ble 0(%sr4,%r22) |
---|
120 | copy %r31,%rp |
---|
121 | ldw -18(%sr0,%sp),%rp |
---|
122 | ldsid (%sr0,%rp),%r1 |
---|
123 | mtsp %r1,%sr0 |
---|
124 | be,n 0(%sr0,%rp) |
---|
125 | nop |
---|
126 | .EXIT |
---|
127 | .PROCEND |
---|
128 | |
---|
129 | |
---|
130 | #if 0 |
---|
131 | .subspa $UNWIND_START$,QUAD=0,ALIGN=8,ACCESS=0x2c,SORT=56 |
---|
132 | .export $UNWIND_START |
---|
133 | $UNWIND_START |
---|
134 | .subspa $UNWIND$,QUAD=0,ALIGN=8,ACCESS=0x2c,SORT=64 |
---|
135 | .subspa $UNWIND_END$,QUAD=0,ALIGN=8,ACCESS=0x2c,SORT=72 |
---|
136 | .export $UNWIND_END |
---|
137 | $UNWIND_END |
---|
138 | .subspa $RECOVER_START$,QUAD=0,ALIGN=4,ACCESS=0x2c,SORT=73 |
---|
139 | .export $RECOVER_START |
---|
140 | $RECOVER_START |
---|
141 | .subspa $RECOVER$,QUAD=0,ALIGN=4,ACCESS=0x2c,SORT=80 |
---|
142 | .subspa $RECOVER_END$,QUAD=0,ALIGN=4,ACCESS=0x2c,SORT=88 |
---|
143 | .export $RECOVER_END |
---|
144 | $RECOVER_END |
---|
145 | #endif |
---|
146 | |
---|
147 | /* |
---|
148 | * Here we set up the standard date sub spaces. |
---|
149 | * |
---|
150 | * Set up some room for a stack. We just grab a chunk of memory. |
---|
151 | * We also setup some space for the global variable space, which |
---|
152 | * must be done using the reserved name "$global$" so "C" code |
---|
153 | * can find it. The stack grows towards the higher addresses. |
---|
154 | */ |
---|
155 | |
---|
156 | #if 0 |
---|
157 | .subspa $DATA$,QUAD=1,ALIGN=8,ACCESS=0x1f,SORT=16 |
---|
158 | .subspa $SHORTDATA$,QUAD=1,ALIGN=8,ACCESS=0x1f,SORT=24 |
---|
159 | .subspa $GLOBAL$,QUAD=1,ALIGN=8,ACCESS=0x1f,SORT=40 |
---|
160 | .export $global$ |
---|
161 | $global$ |
---|
162 | .subspa $SHORTBSS$,QUAD=1,ALIGN=8,ACCESS=0x1f,SORT=80,ZERO |
---|
163 | .subspa $BSS$,QUAD=1,ALIGN=8,ACCESS=0x1f,SORT=82,ZERO |
---|
164 | |
---|
165 | .subspa $STACK$,QUAD=1,ALIGN=8,ACCESS=0x1f,SORT=88,ZERO |
---|
166 | #endif |
---|
167 | |
---|
168 | .export crt_stack |
---|
169 | crt_stack |
---|
170 | .comm 0x1000 |
---|
171 | |
---|
172 | .end |
---|
173 | |
---|