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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.17.0/] [newlib/] [libc/] [sys/] [rdos/] [crt0.S] - Diff between revs 148 and 158

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 148 Rev 158
/*#######################################################################
/*#######################################################################
# RDOS operating system
# RDOS operating system
# Copyright (C) 1988-2006, Leif Ekblad
# Copyright (C) 1988-2006, Leif Ekblad
#
#
# This library is free software; you can redistribute it and/or modify
# This library is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation; either version 2.1 of the License, or
# by the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
# (at your option) any later version.
#
#
# This library is distributed in the hope that it will be useful,
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
# GNU Lesser General Public License for more details.
#
#
# You should have received a copy of the GNU Lesser General Public
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#
# The author of this program may be contacted at leif@rdos.net
# The author of this program may be contacted at leif@rdos.net
#
#
# crt0.S
# crt0.S
# GCC startupcode for RDOS
# GCC startupcode for RDOS
#
#
##########################################################################*/
##########################################################################*/
#include "user.def"
#include "user.def"
    KEY_ENTRIES = 256
    KEY_ENTRIES = 256
    .macro UserGate nr
    .macro UserGate nr
    .byte 0x9A
    .byte 0x9A
    .long \nr
    .long \nr
    .word 2
    .word 2
    .endm
    .endm
    .data
    .data
    .align  8
    .align  8
_key_section:
_key_section:
    .word 0
    .word 0
_key_ref_arr:
_key_ref_arr:
    .long 0
    .long 0
_key_dtor_arr:
_key_dtor_arr:
    .long 0
    .long 0
        .text
        .text
        .align 4
        .align 4
/*##########################################################################
/*##########################################################################
#
#
#   Name       : _start
#   Name       : _start
#
#
#   Purpose....: GCC startup-code
#   Purpose....: GCC startup-code
#
#
##########################################################################*/
##########################################################################*/
        .global _start
        .global _start
_start:
_start:
        call get_impure_data_size
        call get_impure_data_size
        movl %eax,%ecx
        movl %eax,%ecx
        UserGate allocate_app_mem_nr
        UserGate allocate_app_mem_nr
        xorl %eax,%eax
        xorl %eax,%eax
        .byte 0x64
        .byte 0x64
        movl %edx,(%eax)
        movl %edx,(%eax)
        movl %edx,%edi
        movl %edx,%edi
        rep
        rep
        stosb
        stosb
        pushl %edx
        pushl %edx
    movl $(4 * KEY_ENTRIES),%eax
    movl $(4 * KEY_ENTRIES),%eax
        movl %eax,%ecx
        movl %eax,%ecx
    UserGate allocate_app_mem_nr
    UserGate allocate_app_mem_nr
    movl $4,%eax
    movl $4,%eax
    .byte 0x64
    .byte 0x64
    movl %edx,(%eax)
    movl %edx,(%eax)
    movl %edx,%edi
    movl %edx,%edi
        xorl %eax,%eax
        xorl %eax,%eax
    rep
    rep
    stosb
    stosb
    movl $(4 * KEY_ENTRIES),%eax
    movl $(4 * KEY_ENTRIES),%eax
        movl %eax,%ecx
        movl %eax,%ecx
    UserGate allocate_app_mem_nr
    UserGate allocate_app_mem_nr
    movl %edx,_key_ref_arr
    movl %edx,_key_ref_arr
    movl %edx,%edi
    movl %edx,%edi
        xorl %eax,%eax
        xorl %eax,%eax
    rep
    rep
    stosb
    stosb
    movl $(4 * KEY_ENTRIES),%eax
    movl $(4 * KEY_ENTRIES),%eax
        movl %eax,%ecx
        movl %eax,%ecx
    UserGate allocate_app_mem_nr
    UserGate allocate_app_mem_nr
    movl %edx,_key_dtor_arr
    movl %edx,_key_dtor_arr
    movl %edx,%edi
    movl %edx,%edi
        xorl %eax,%eax
        xorl %eax,%eax
    rep
    rep
    stosb
    stosb
        UserGate create_user_section_nr
        UserGate create_user_section_nr
        movw %bx,_key_section
        movw %bx,_key_section
        call __init_rdos
        call __init_rdos
        add $4, %esp
        add $4, %esp
        movl $0x1000,%eax
        movl $0x1000,%eax
        UserGate allocate_app_mem_nr
        UserGate allocate_app_mem_nr
        pushl %edx
        pushl %edx
        UserGate get_cmd_line_nr
        UserGate get_cmd_line_nr
        xorl %ecx,%ecx
        xorl %ecx,%ecx
        xorb %ah,%ah
        xorb %ah,%ah
arg_loop:
arg_loop:
        movl %edi,(%edx)
        movl %edi,(%edx)
        addl $4,%edx
        addl $4,%edx
        movb (%edi),%al
        movb (%edi),%al
        orb %al,%al
        orb %al,%al
        je arg_done
        je arg_done
arg_scan:
arg_scan:
        movb (%edi),%al
        movb (%edi),%al
        orb %al,%al
        orb %al,%al
        je next_arg
        je next_arg
        cmpb $0x22,%al
        cmpb $0x22,%al
        jne arg_no_quote
        jne arg_no_quote
        xorb $1,%ah
        xorb $1,%ah
        jmp arg_scan_next
        jmp arg_scan_next
arg_no_quote:
arg_no_quote:
        orb %ah,%ah
        orb %ah,%ah
        jnz arg_scan_next
        jnz arg_scan_next
        cmpb $0x20,%al
        cmpb $0x20,%al
        je next_arg
        je next_arg
        cmpb $0x8,%al
        cmpb $0x8,%al
        je next_arg
        je next_arg
arg_scan_next:
arg_scan_next:
        incl %edi
        incl %edi
        jmp arg_scan
        jmp arg_scan
next_arg:
next_arg:
        incl %ecx
        incl %ecx
to_next_arg:
to_next_arg:
        orb %al,%al
        orb %al,%al
        je arg_done
        je arg_done
        xorb %al,%al
        xorb %al,%al
        movb %al,(%edi)
        movb %al,(%edi)
        incl %edi
        incl %edi
        movb (%edi),%al
        movb (%edi),%al
        cmpb $0x20,%al
        cmpb $0x20,%al
        je to_next_arg
        je to_next_arg
        cmpb $0x8,%al
        cmpb $0x8,%al
        je to_next_arg
        je to_next_arg
        jmp arg_loop
        jmp arg_loop
arg_done:
arg_done:
        int $3
        int $3
        pushl %ecx
        pushl %ecx
        call main
        call main
        add $8, %esp
        add $8, %esp
        pushl %eax
        pushl %eax
        call    exit
        call    exit
/*##########################################################################
/*##########################################################################
#
#
#   Name       : _exit
#   Name       : _exit
#
#
#   Purpose....: GCC exit-code
#   Purpose....: GCC exit-code
#
#
##########################################################################*/
##########################################################################*/
        .global _exit
        .global _exit
_exit:
_exit:
        pushl %ebp
        pushl %ebp
        movl %esp,%ebp
        movl %esp,%ebp
        movl 8(%ebp),%eax
        movl 8(%ebp),%eax
        UserGate unload_exe_nr
        UserGate unload_exe_nr
/*##########################################################################
/*##########################################################################
#
#
#   Name       : __getreent
#   Name       : __getreent
#
#
#   Purpose....: ?
#   Purpose....: ?
#
#
##########################################################################*/
##########################################################################*/
        .global __getreent
        .global __getreent
__getreent:
__getreent:
    xorl %eax,%eax
    xorl %eax,%eax
        .byte 0x64
        .byte 0x64
        movl (%eax),%eax
        movl (%eax),%eax
        ret
        ret
/*##########################################################################
/*##########################################################################
#
#
#   Name       : __rdos_thread_key_create
#   Name       : __rdos_thread_key_create
#
#
#   Purpose....: Emulate GCC pthread_key_create
#   Purpose....: Emulate GCC pthread_key_create
#
#
#   Parameters.: dtor
#   Parameters.: dtor
#
#
#   Returns....: Key index
#   Returns....: Key index
#
#
##########################################################################*/
##########################################################################*/
        .global __rdos_thread_key_create
        .global __rdos_thread_key_create
__rdos_thread_key_create:
__rdos_thread_key_create:
    int $3
    int $3
        pushl %ebp
        pushl %ebp
        movl %esp,%ebp
        movl %esp,%ebp
        pushl %ebx
        pushl %ebx
        pushl %ecx
        pushl %ecx
    mov _key_section,%bx
    mov _key_section,%bx
    UserGate enter_user_section_nr
    UserGate enter_user_section_nr
        movl _key_ref_arr,%ebx
        movl _key_ref_arr,%ebx
    movl KEY_ENTRIES,%ecx
    movl KEY_ENTRIES,%ecx
rtkc_scan_loop:
rtkc_scan_loop:
    movl (%ebx), %eax
    movl (%ebx), %eax
    orl %eax, %eax
    orl %eax, %eax
    jz rtkc_entry_found
    jz rtkc_entry_found
    add $4, %ebx
    add $4, %ebx
    loop rtkc_scan_loop
    loop rtkc_scan_loop
    movl $-1, %eax
    movl $-1, %eax
    jmp rtkc_leave
    jmp rtkc_leave
rtkc_entry_found:
rtkc_entry_found:
    movb $255,3(%ebx)
    movb $255,3(%ebx)
    subl _key_ref_arr,%ebx
    subl _key_ref_arr,%ebx
    addl _key_dtor_arr,%ebx
    addl _key_dtor_arr,%ebx
        movl 8(%ebp),%eax
        movl 8(%ebp),%eax
        movl %eax,(%ebx)
        movl %eax,(%ebx)
        subl _key_dtor_arr,%ebx
        subl _key_dtor_arr,%ebx
        movl %ebx,%eax
        movl %ebx,%eax
rtkc_leave:
rtkc_leave:
    mov _key_section, %bx
    mov _key_section, %bx
    UserGate leave_user_section_nr
    UserGate leave_user_section_nr
    popl %ecx
    popl %ecx
    popl %ebx
    popl %ebx
        leave
        leave
        ret
        ret
/*##########################################################################
/*##########################################################################
#
#
#   Name       : __rdos_thread_key_delete
#   Name       : __rdos_thread_key_delete
#
#
#   Purpose....: Emulate GCC pthread_key_delete
#   Purpose....: Emulate GCC pthread_key_delete
#
#
#   Parameters.: index
#   Parameters.: index
#
#
#   Returns....: result
#   Returns....: result
#
#
##########################################################################*/
##########################################################################*/
        .global __rdos_thread_key_delete
        .global __rdos_thread_key_delete
__rdos_thread_key_delete:
__rdos_thread_key_delete:
    int $3
    int $3
        pushl %ebp
        pushl %ebp
        movl %esp,%ebp
        movl %esp,%ebp
        pushl %ebx
        pushl %ebx
    mov _key_section,%bx
    mov _key_section,%bx
    UserGate enter_user_section_nr
    UserGate enter_user_section_nr
        movl 8(%ebp),%ebx
        movl 8(%ebp),%ebx
        testb $3,%bl
        testb $3,%bl
        jnz rtkd_fail
        jnz rtkd_fail
    cmpl $(4 * KEY_ENTRIES),%ebx
    cmpl $(4 * KEY_ENTRIES),%ebx
    jae rtkd_fail
    jae rtkd_fail
    addl _key_ref_arr,%ebx
    addl _key_ref_arr,%ebx
    movb $0,3(%ebx)
    movb $0,3(%ebx)
    mov (%ebx),%eax
    mov (%ebx),%eax
    orl %eax,%eax
    orl %eax,%eax
    jz rtkd_ok
    jz rtkd_ok
    subl _key_ref_arr,%ebx
    subl _key_ref_arr,%ebx
    movl $0,(%ebx)
    movl $0,(%ebx)
    jmp rtkd_ok
    jmp rtkd_ok
rtkd_fail:
rtkd_fail:
    movl $1,%eax
    movl $1,%eax
    jmp rtkd_leave
    jmp rtkd_leave
rtkd_ok:
rtkd_ok:
    xorl %eax,%eax
    xorl %eax,%eax
rtkd_leave:
rtkd_leave:
    mov _key_section, %bx
    mov _key_section, %bx
    UserGate leave_user_section_nr
    UserGate leave_user_section_nr
    popl %ebx
    popl %ebx
        leave
        leave
        ret
        ret
/*##########################################################################
/*##########################################################################
#
#
#   Name       : __rdos_thread_getspecific
#   Name       : __rdos_thread_getspecific
#
#
#   Purpose....: Emulate GCC pthread_getspecific
#   Purpose....: Emulate GCC pthread_getspecific
#
#
#   Parameters.: index
#   Parameters.: index
#
#
#   Returns....: value
#   Returns....: value
#
#
##########################################################################*/
##########################################################################*/
        .global __rdos_thread_getspecific
        .global __rdos_thread_getspecific
__rdos_thread_getspecific:
__rdos_thread_getspecific:
    int $3
    int $3
        pushl %ebp
        pushl %ebp
        movl %esp,%ebp
        movl %esp,%ebp
        pushl %ebx
        pushl %ebx
        movl 8(%ebp),%ebx
        movl 8(%ebp),%ebx
        testb $3,%bl
        testb $3,%bl
        jnz rtg_fail
        jnz rtg_fail
    cmpl $(4 * KEY_ENTRIES),%ebx
    cmpl $(4 * KEY_ENTRIES),%ebx
    jae rtg_fail
    jae rtg_fail
    movl $4,%eax
    movl $4,%eax
    .byte 0x64
    .byte 0x64
    movl (%eax),%eax
    movl (%eax),%eax
    addl %eax,%ebx
    addl %eax,%ebx
    movl (%ebx),%eax
    movl (%ebx),%eax
    jmp rtg_done
    jmp rtg_done
rtg_fail:
rtg_fail:
    xorl %eax,%eax
    xorl %eax,%eax
rtg_done:
rtg_done:
    popl %ebx
    popl %ebx
        leave
        leave
        ret
        ret
/*##########################################################################
/*##########################################################################
#
#
#   Name       : __rdos_thread_setspecific
#   Name       : __rdos_thread_setspecific
#
#
#   Purpose....: Emulate GCC pthread_setspecific
#   Purpose....: Emulate GCC pthread_setspecific
#
#
#   Parameters.: index
#   Parameters.: index
#                value
#                value
#
#
##########################################################################*/
##########################################################################*/
        .global __rdos_thread_setspecific
        .global __rdos_thread_setspecific
__rdos_thread_setspecific:
__rdos_thread_setspecific:
    int $3
    int $3
        pushl %ebp
        pushl %ebp
        movl %esp,%ebp
        movl %esp,%ebp
        pushl %ebx
        pushl %ebx
        pushl %ecx
        pushl %ecx
        movl 8(%ebp),%ebx
        movl 8(%ebp),%ebx
        testb $3,%bl
        testb $3,%bl
        jnz rts_fail
        jnz rts_fail
    cmpl $(4 * KEY_ENTRIES),%ebx
    cmpl $(4 * KEY_ENTRIES),%ebx
    jae rts_fail
    jae rts_fail
    movl $4,%eax
    movl $4,%eax
    .byte 0x64
    .byte 0x64
    movl (%eax),%eax
    movl (%eax),%eax
    addl %eax,%ebx
    addl %eax,%ebx
        movl 12(%ebp),%eax
        movl 12(%ebp),%eax
    movl %eax,(%ebx)
    movl %eax,(%ebx)
    xorl %eax,%eax
    xorl %eax,%eax
    jmp rts_done
    jmp rts_done
rts_fail:
rts_fail:
    movl $1,%eax
    movl $1,%eax
rts_done:
rts_done:
    popl %ebx
    popl %ebx
        leave
        leave
        ret
        ret
 
 

powered by: WebSVN 2.1.0

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