OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.18.0/] [newlib/] [libc/] [sys/] [rdos/] [crt0.S] - Blame information for rev 326

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 207 jeremybenn
/*#######################################################################
2
# RDOS operating system
3
# Copyright (C) 1988-2006, Leif Ekblad
4
#
5
# This library is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU Lesser General Public License as published
7
# by the Free Software Foundation; either version 2.1 of the License, or
8
# (at your option) any later version.
9
#
10
# This library is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU Lesser General Public License for more details.
14
#
15
# You should have received a copy of the GNU Lesser General Public
16
# License along with this library; if not, write to the Free Software
17
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
#
19
# The author of this program may be contacted at leif@rdos.net
20
#
21
# crt0.S
22
# GCC startupcode for RDOS
23
#
24
##########################################################################*/
25
 
26
#include "user.def"
27
 
28
    KEY_ENTRIES = 256
29
 
30
    .macro UserGate nr
31
    .byte 0x9A
32
    .long \nr
33
    .word 2
34
    .endm
35
 
36
    .data
37
    .align  8
38
 
39
_key_section:
40
    .word 0
41
 
42
_key_ref_arr:
43
    .long 0
44
 
45
_key_dtor_arr:
46
    .long 0
47
 
48
        .text
49
        .align 4
50
 
51
/*##########################################################################
52
#
53
#   Name       : _start
54
#
55
#   Purpose....: GCC startup-code
56
#
57
##########################################################################*/
58
 
59
        .global _start
60
 
61
_start:
62
        call get_impure_data_size
63
        movl %eax,%ecx
64
        UserGate allocate_app_mem_nr
65
 
66
        xorl %eax,%eax
67
        .byte 0x64
68
        movl %edx,(%eax)
69
        movl %edx,%edi
70
        rep
71
        stosb
72
        pushl %edx
73
 
74
    movl $(4 * KEY_ENTRIES),%eax
75
        movl %eax,%ecx
76
    UserGate allocate_app_mem_nr
77
    movl $4,%eax
78
    .byte 0x64
79
    movl %edx,(%eax)
80
    movl %edx,%edi
81
        xorl %eax,%eax
82
    rep
83
    stosb
84
 
85
    movl $(4 * KEY_ENTRIES),%eax
86
        movl %eax,%ecx
87
    UserGate allocate_app_mem_nr
88
    movl %edx,_key_ref_arr
89
    movl %edx,%edi
90
        xorl %eax,%eax
91
    rep
92
    stosb
93
 
94
    movl $(4 * KEY_ENTRIES),%eax
95
        movl %eax,%ecx
96
    UserGate allocate_app_mem_nr
97
    movl %edx,_key_dtor_arr
98
    movl %edx,%edi
99
        xorl %eax,%eax
100
    rep
101
    stosb
102
 
103
        UserGate create_user_section_nr
104
        movw %bx,_key_section
105
 
106
        call __init_rdos
107
        add $4, %esp
108
 
109
        movl $0x1000,%eax
110
        UserGate allocate_app_mem_nr
111
 
112
        pushl %edx
113
        UserGate get_cmd_line_nr
114
 
115
        xorl %ecx,%ecx
116
        xorb %ah,%ah
117
 
118
arg_loop:
119
        movl %edi,(%edx)
120
        addl $4,%edx
121
        movb (%edi),%al
122
        orb %al,%al
123
        je arg_done
124
 
125
arg_scan:
126
        movb (%edi),%al
127
        orb %al,%al
128
        je next_arg
129
 
130
        cmpb $0x22,%al
131
        jne arg_no_quote
132
 
133
        xorb $1,%ah
134
        jmp arg_scan_next
135
 
136
arg_no_quote:
137
        orb %ah,%ah
138
        jnz arg_scan_next
139
 
140
        cmpb $0x20,%al
141
        je next_arg
142
 
143
        cmpb $0x8,%al
144
        je next_arg
145
 
146
arg_scan_next:
147
        incl %edi
148
        jmp arg_scan
149
 
150
next_arg:
151
        incl %ecx
152
 
153
to_next_arg:
154
        orb %al,%al
155
        je arg_done
156
 
157
        xorb %al,%al
158
        movb %al,(%edi)
159
        incl %edi
160
        movb (%edi),%al
161
        cmpb $0x20,%al
162
        je to_next_arg
163
 
164
        cmpb $0x8,%al
165
        je to_next_arg
166
 
167
        jmp arg_loop
168
 
169
arg_done:
170
        int $3
171
        pushl %ecx
172
        call main
173
        add $8, %esp
174
 
175
        pushl %eax
176
        call    exit
177
 
178
/*##########################################################################
179
#
180
#   Name       : _exit
181
#
182
#   Purpose....: GCC exit-code
183
#
184
##########################################################################*/
185
 
186
        .global _exit
187
 
188
_exit:
189
        pushl %ebp
190
        movl %esp,%ebp
191
        movl 8(%ebp),%eax
192
        UserGate unload_exe_nr
193
 
194
/*##########################################################################
195
#
196
#   Name       : __getreent
197
#
198
#   Purpose....: ?
199
#
200
##########################################################################*/
201
 
202
        .global __getreent
203
 
204
__getreent:
205
    xorl %eax,%eax
206
        .byte 0x64
207
        movl (%eax),%eax
208
        ret
209
 
210
/*##########################################################################
211
#
212
#   Name       : __rdos_thread_key_create
213
#
214
#   Purpose....: Emulate GCC pthread_key_create
215
#
216
#   Parameters.: dtor
217
#
218
#   Returns....: Key index
219
#
220
##########################################################################*/
221
 
222
        .global __rdos_thread_key_create
223
 
224
__rdos_thread_key_create:
225
    int $3
226
        pushl %ebp
227
        movl %esp,%ebp
228
        pushl %ebx
229
        pushl %ecx
230
 
231
    mov _key_section,%bx
232
    UserGate enter_user_section_nr
233
 
234
        movl _key_ref_arr,%ebx
235
    movl KEY_ENTRIES,%ecx
236
 
237
rtkc_scan_loop:
238
    movl (%ebx), %eax
239
    orl %eax, %eax
240
    jz rtkc_entry_found
241
 
242
    add $4, %ebx
243
    loop rtkc_scan_loop
244
 
245
    movl $-1, %eax
246
    jmp rtkc_leave
247
 
248
rtkc_entry_found:
249
    movb $255,3(%ebx)
250
    subl _key_ref_arr,%ebx
251
    addl _key_dtor_arr,%ebx
252
        movl 8(%ebp),%eax
253
        movl %eax,(%ebx)
254
        subl _key_dtor_arr,%ebx
255
        movl %ebx,%eax
256
 
257
rtkc_leave:
258
    mov _key_section, %bx
259
    UserGate leave_user_section_nr
260
 
261
    popl %ecx
262
    popl %ebx
263
        leave
264
        ret
265
 
266
/*##########################################################################
267
#
268
#   Name       : __rdos_thread_key_delete
269
#
270
#   Purpose....: Emulate GCC pthread_key_delete
271
#
272
#   Parameters.: index
273
#
274
#   Returns....: result
275
#
276
##########################################################################*/
277
 
278
        .global __rdos_thread_key_delete
279
 
280
__rdos_thread_key_delete:
281
    int $3
282
        pushl %ebp
283
        movl %esp,%ebp
284
        pushl %ebx
285
 
286
    mov _key_section,%bx
287
    UserGate enter_user_section_nr
288
 
289
        movl 8(%ebp),%ebx
290
        testb $3,%bl
291
        jnz rtkd_fail
292
 
293
    cmpl $(4 * KEY_ENTRIES),%ebx
294
    jae rtkd_fail
295
 
296
    addl _key_ref_arr,%ebx
297
    movb $0,3(%ebx)
298
    mov (%ebx),%eax
299
    orl %eax,%eax
300
    jz rtkd_ok
301
 
302
    subl _key_ref_arr,%ebx
303
    movl $0,(%ebx)
304
    jmp rtkd_ok
305
 
306
rtkd_fail:
307
    movl $1,%eax
308
    jmp rtkd_leave
309
 
310
rtkd_ok:
311
    xorl %eax,%eax
312
 
313
rtkd_leave:
314
    mov _key_section, %bx
315
    UserGate leave_user_section_nr
316
 
317
    popl %ebx
318
        leave
319
        ret
320
 
321
/*##########################################################################
322
#
323
#   Name       : __rdos_thread_getspecific
324
#
325
#   Purpose....: Emulate GCC pthread_getspecific
326
#
327
#   Parameters.: index
328
#
329
#   Returns....: value
330
#
331
##########################################################################*/
332
 
333
        .global __rdos_thread_getspecific
334
 
335
__rdos_thread_getspecific:
336
    int $3
337
        pushl %ebp
338
        movl %esp,%ebp
339
        pushl %ebx
340
 
341
        movl 8(%ebp),%ebx
342
        testb $3,%bl
343
        jnz rtg_fail
344
 
345
    cmpl $(4 * KEY_ENTRIES),%ebx
346
    jae rtg_fail
347
 
348
    movl $4,%eax
349
    .byte 0x64
350
    movl (%eax),%eax
351
    addl %eax,%ebx
352
    movl (%ebx),%eax
353
    jmp rtg_done
354
 
355
rtg_fail:
356
    xorl %eax,%eax
357
 
358
rtg_done:
359
    popl %ebx
360
        leave
361
        ret
362
 
363
/*##########################################################################
364
#
365
#   Name       : __rdos_thread_setspecific
366
#
367
#   Purpose....: Emulate GCC pthread_setspecific
368
#
369
#   Parameters.: index
370
#                value
371
#
372
##########################################################################*/
373
 
374
        .global __rdos_thread_setspecific
375
 
376
__rdos_thread_setspecific:
377
    int $3
378
        pushl %ebp
379
        movl %esp,%ebp
380
        pushl %ebx
381
        pushl %ecx
382
 
383
        movl 8(%ebp),%ebx
384
        testb $3,%bl
385
        jnz rts_fail
386
 
387
    cmpl $(4 * KEY_ENTRIES),%ebx
388
    jae rts_fail
389
 
390
    movl $4,%eax
391
    .byte 0x64
392
    movl (%eax),%eax
393
    addl %eax,%ebx
394
 
395
        movl 12(%ebp),%eax
396
    movl %eax,(%ebx)
397
    xorl %eax,%eax
398
    jmp rts_done
399
 
400
rts_fail:
401
    movl $1,%eax
402
 
403
rts_done:
404
    popl %ebx
405
        leave
406
        ret

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.