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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [newlib-1.17.0/] [libgloss/] [frv/] [crt0.S] - Diff between revs 158 and 816

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

Rev 158 Rev 816
/* crt0.S -- startup file for frv.
/* crt0.S -- startup file for frv.
 *
 *
 * Copyright (c) 2002, 2003 Red Hat, Inc
 * Copyright (c) 2002, 2003 Red Hat, Inc
 *
 *
 * The authors hereby grant permission to use, copy, modify, distribute,
 * The authors hereby grant permission to use, copy, modify, distribute,
 * and license this software and its documentation for any purpose, provided
 * and license this software and its documentation for any purpose, provided
 * that existing copyright notices are retained in all copies and that this
 * that existing copyright notices are retained in all copies and that this
 * notice is included verbatim in any distributions. No written agreement,
 * notice is included verbatim in any distributions. No written agreement,
 * license, or royalty fee is required for any of the authorized uses.
 * license, or royalty fee is required for any of the authorized uses.
 * Modifications to this software may be copyrighted by their authors
 * Modifications to this software may be copyrighted by their authors
 * and need not follow the licensing terms described here, provided that
 * and need not follow the licensing terms described here, provided that
 * the new terms are clearly indicated on the first page of each file where
 * the new terms are clearly indicated on the first page of each file where
 * they apply.
 * they apply.
 */
 */
#include 
#include 
        /* statically store .Lcall's address so we can see if we are running
        /* statically store .Lcall's address so we can see if we are running
           at the location we were linked for or a different location.  */
           at the location we were linked for or a different location.  */
        .data
        .data
        .type   EXT(__start_cmp),@object
        .type   EXT(__start_cmp),@object
        .size   EXT(__start_cmp),4
        .size   EXT(__start_cmp),4
        .p2align 2
        .p2align 2
EXT(__start_cmp):
EXT(__start_cmp):
        .picptr  .Lcall
        .picptr  .Lcall
        .globl  __start
        .globl  __start
        .weak   _start
        .weak   _start
        .text
        .text
        .type   __start,@function
        .type   __start,@function
__start:
__start:
_start:
_start:
        call    .Lcall                          /* set up _gp in a pic-friendly manor */
        call    .Lcall                          /* set up _gp in a pic-friendly manor */
.Lcall: movsg   lr, gr4
.Lcall: movsg   lr, gr4
        P(sethi) #gprelhi(.Lcall), gr5
        P(sethi) #gprelhi(.Lcall), gr5
        setlo    #gprello(.Lcall), gr5
        setlo    #gprello(.Lcall), gr5
        P(sub)   gr4, gr5, gr16
        P(sub)   gr4, gr5, gr16
#if ! __FRV_FDPIC__
#if ! __FRV_FDPIC__
        sethi    #gprelhi(EXT(_stack)), sp      /* load up stack pointer */
        sethi    #gprelhi(EXT(_stack)), sp      /* load up stack pointer */
        P(setlo) #gprello(EXT(_stack)), sp
        P(setlo) #gprello(EXT(_stack)), sp
        setlos   #0, fp                         /* zero fp to allow unwinders to stop */
        setlos   #0, fp                         /* zero fp to allow unwinders to stop */
        P(add)   sp, gr16, sp
        P(add)   sp, gr16, sp
#define FDPIC(...)
#define FDPIC(...)
#else
#else
#define FDPIC(...) __VA_ARGS__
#define FDPIC(...) __VA_ARGS__
        /* The assembler will rightfully claim that
        /* The assembler will rightfully claim that
        #hi/lo(__stacksize) are unsafe for PIC, but since __stacksize
        #hi/lo(__stacksize) are unsafe for PIC, but since __stacksize
        is absolute, and we don't want it to be relocated, we should
        is absolute, and we don't want it to be relocated, we should
        be fine.  */
        be fine.  */
        sethi   #gprelhi(EXT(__end)), gr6
        sethi   #gprelhi(EXT(__end)), gr6
        P(sethi) #hi(EXT(__stacksize+7)), gr5
        P(sethi) #hi(EXT(__stacksize+7)), gr5
        setlo   #gprello(EXT(__end)), gr6
        setlo   #gprello(EXT(__end)), gr6
        P(setlo) #lo(EXT(__stacksize+7)), gr5
        P(setlo) #lo(EXT(__stacksize+7)), gr5
        add     gr6, gr16, gr6
        add     gr6, gr16, gr6
        add     gr6, gr5, gr5
        add     gr6, gr5, gr5
        andi    gr5, -8, sp
        andi    gr5, -8, sp
        /* Using GPREL to compute _GLOBAL_OFFSET_TABLE_'s will force
        /* Using GPREL to compute _GLOBAL_OFFSET_TABLE_'s will force
        the entire program to relocate as a unit, which is fine for
        the entire program to relocate as a unit, which is fine for
        frv-elf.  */
        frv-elf.  */
        P(sethi) #gprelhi(EXT(_GLOBAL_OFFSET_TABLE_)), gr15
        P(sethi) #gprelhi(EXT(_GLOBAL_OFFSET_TABLE_)), gr15
        setlo    #gprello(EXT(_GLOBAL_OFFSET_TABLE_)), gr15
        setlo    #gprello(EXT(_GLOBAL_OFFSET_TABLE_)), gr15
        /* We compute the value in a call-saved register (that happens
        /* We compute the value in a call-saved register (that happens
        to be the PIC register in the EABI, and copy it to gr15 before
        to be the PIC register in the EABI, and copy it to gr15 before
        every call.  */
        every call.  */
        add      gr15, gr16, gr17
        add      gr15, gr16, gr17
#endif
#endif
        sethi    #gprelhi(EXT(__start_cmp)), gr5
        sethi    #gprelhi(EXT(__start_cmp)), gr5
        setlo    #gprello(EXT(__start_cmp)), gr5
        setlo    #gprello(EXT(__start_cmp)), gr5
        ld       @(gr5,gr16), gr6
        ld       @(gr5,gr16), gr6
        subcc   gr4, gr6, gr8, icc0
        subcc   gr4, gr6, gr8, icc0
        beq     icc0, 0, .Lfixed
        beq     icc0, 0, .Lfixed
        P(st)   gr4, @(gr5, gr16)       /* update so if we restart no need to fixup */
        P(st)   gr4, @(gr5, gr16)       /* update so if we restart no need to fixup */
        setlos  4, gr11
        setlos  4, gr11
#if ! __FRV_FDPIC__
#if ! __FRV_FDPIC__
                                        /* fixup the .ctors list */
                                        /* fixup the .ctors list */
        sethi    #gprelhi(EXT(__CTOR_LIST__)), gr9
        sethi    #gprelhi(EXT(__CTOR_LIST__)), gr9
        P(sethi) #gprelhi(EXT(__CTOR_END__)), gr10
        P(sethi) #gprelhi(EXT(__CTOR_END__)), gr10
        setlo    #gprello(EXT(__CTOR_LIST__)), gr9
        setlo    #gprello(EXT(__CTOR_LIST__)), gr9
        P(setlo) #gprello(EXT(__CTOR_END__)), gr10
        P(setlo) #gprello(EXT(__CTOR_END__)), gr10
        add      gr9, gr16, gr9
        add      gr9, gr16, gr9
        P(add)   gr10, gr16, gr10
        P(add)   gr10, gr16, gr10
        addi     gr9, 4, gr9
        addi     gr9, 4, gr9
        P(subi)  gr10, 4, gr10
        P(subi)  gr10, 4, gr10
        call     EXT(__frv_fixptrs)
        call     EXT(__frv_fixptrs)
                                        /* fixup the .dtors list */
                                        /* fixup the .dtors list */
        P(sethi) #gprelhi(EXT(__DTOR_LIST__)), gr9
        P(sethi) #gprelhi(EXT(__DTOR_LIST__)), gr9
        sethi    #gprelhi(EXT(__DTOR_END__)), gr10
        sethi    #gprelhi(EXT(__DTOR_END__)), gr10
        P(setlo) #gprello(EXT(__DTOR_LIST__)), gr9
        P(setlo) #gprello(EXT(__DTOR_LIST__)), gr9
        setlo    #gprello(EXT(__DTOR_END__)), gr10
        setlo    #gprello(EXT(__DTOR_END__)), gr10
        P(add)   gr9, gr16, gr9
        P(add)   gr9, gr16, gr9
        add      gr10, gr16, gr10
        add      gr10, gr16, gr10
        P(addi)  gr9, 4, gr9
        P(addi)  gr9, 4, gr9
        subi     gr10, 4, gr10
        subi     gr10, 4, gr10
        call     EXT(__frv_fixptrs)
        call     EXT(__frv_fixptrs)
#endif /* ! __FRV_FDPIC__ */
#endif /* ! __FRV_FDPIC__ */
                                        /* fixup the user .rofixup list */
                                        /* fixup the user .rofixup list */
        P(sethi) #gprelhi(EXT(__ROFIXUP_LIST__)), gr9
        P(sethi) #gprelhi(EXT(__ROFIXUP_LIST__)), gr9
        sethi    #gprelhi(EXT(__ROFIXUP_END__)), gr10
        sethi    #gprelhi(EXT(__ROFIXUP_END__)), gr10
        P(setlo) #gprello(EXT(__ROFIXUP_LIST__)), gr9
        P(setlo) #gprello(EXT(__ROFIXUP_LIST__)), gr9
        setlo    #gprello(EXT(__ROFIXUP_END__)), gr10
        setlo    #gprello(EXT(__ROFIXUP_END__)), gr10
        P(add)   gr9, gr16, gr9
        P(add)   gr9, gr16, gr9
        add      gr10, gr16, gr10
        add      gr10, gr16, gr10
        FDPIC(mov gr17, gr15)
        FDPIC(mov gr17, gr15)
        call     EXT(__frv_fix_usrptrs)
        call     EXT(__frv_fix_usrptrs)
.Lfixed:
.Lfixed:
/* HSR flags */
/* HSR flags */
#define HSR_ICE  0x80000000             /* Instruction cache enable */
#define HSR_ICE  0x80000000             /* Instruction cache enable */
#define HSR_DCE  0x40000000             /* Data cache enable */
#define HSR_DCE  0x40000000             /* Data cache enable */
#define HSR_CBM  0x08000000             /* Cache copy back mode */
#define HSR_CBM  0x08000000             /* Cache copy back mode */
#define HSR_EIMM 0x04000000             /* Enable Instruction MMU */
#define HSR_EIMM 0x04000000             /* Enable Instruction MMU */
#define HSR_EDMM 0x02000000             /* Enable Data MMU */
#define HSR_EDMM 0x02000000             /* Enable Data MMU */
#define HSR_EMEM 0x00800000             /* Enable MMU miss exception mask */
#define HSR_EMEM 0x00800000             /* Enable MMU miss exception mask */
#define HSR_RME  0x00400000             /* Ram mode enable */
#define HSR_RME  0x00400000             /* Ram mode enable */
#define HSR_SA   0x00001000             /* Start address */
#define HSR_SA   0x00001000             /* Start address */
#define HSR_FRN  0x00000800             /* Number of FPRs */
#define HSR_FRN  0x00000800             /* Number of FPRs */
#define HSR_GRN  0x00000400             /* Number of GPRs */
#define HSR_GRN  0x00000400             /* Number of GPRs */
#define HSR_FRHE 0x00000200             /* FR Higher Enable */
#define HSR_FRHE 0x00000200             /* FR Higher Enable */
#define HSR_FRLE 0x00000100             /* FR Lower Enable */
#define HSR_FRLE 0x00000100             /* FR Lower Enable */
#define HSR_GRHE 0x00000080             /* GR Higher Enable */
#define HSR_GRHE 0x00000080             /* GR Higher Enable */
#define HSR_GRLE 0x00000040             /* GR Lower Enable */
#define HSR_GRLE 0x00000040             /* GR Lower Enable */
#ifndef HSR_CLEAR
#ifndef HSR_CLEAR
#define HSR_CLEAR 0
#define HSR_CLEAR 0
#endif
#endif
#ifndef HSR_SET
#ifndef HSR_SET
#ifndef FRV_NO_CACHE
#ifndef FRV_NO_CACHE
#define HSR_SET (HSR_ICE|HSR_DCE|HSR_FRHE|HSR_FRLE|HSR_GRHE|HSR_GRLE)
#define HSR_SET (HSR_ICE|HSR_DCE|HSR_FRHE|HSR_FRLE|HSR_GRHE|HSR_GRLE)
#else
#else
#define HSR_SET (HSR_FRHE|HSR_FRLE|HSR_GRHE|HSR_GRLE)
#define HSR_SET (HSR_FRHE|HSR_FRLE|HSR_GRHE|HSR_GRLE)
#endif
#endif
#endif
#endif
/* PSR flags */
/* PSR flags */
#define PSR_ICE  0x00010000             /* In circuit emulation mode */
#define PSR_ICE  0x00010000             /* In circuit emulation mode */
#define PSR_NEM  0x00004000             /* Non-exception mode */
#define PSR_NEM  0x00004000             /* Non-exception mode */
#define PSR_CM   0x00002000             /* Conditional mode */
#define PSR_CM   0x00002000             /* Conditional mode */
#define PSR_BE   0x00001000             /* Big endian mode */
#define PSR_BE   0x00001000             /* Big endian mode */
#define PSR_EF   0x00000100             /* Enable floating point */
#define PSR_EF   0x00000100             /* Enable floating point */
#define PSR_EM   0x00000080             /* Enable media instructions */
#define PSR_EM   0x00000080             /* Enable media instructions */
#define PSR_S    0x00000004             /* Enable supervisor mode */
#define PSR_S    0x00000004             /* Enable supervisor mode */
#define PSR_PS   0x00000002             /* Previous supervisor mode */
#define PSR_PS   0x00000002             /* Previous supervisor mode */
#define PSR_ET   0x00000001             /* Enable interrupts */
#define PSR_ET   0x00000001             /* Enable interrupts */
#ifndef PSR_CLEAR
#ifndef PSR_CLEAR
#if __FRV_FPR__
#if __FRV_FPR__
#define PSR_CLEAR 0
#define PSR_CLEAR 0
#else
#else
#define PSR_CLEAR (PSR_EF|PSR_EM)
#define PSR_CLEAR (PSR_EF|PSR_EM)
#endif
#endif
#endif
#endif
#ifndef PSR_SET
#ifndef PSR_SET
#if __FRV_FPR__
#if __FRV_FPR__
#define PSR_SET (PSR_NEM|PSR_CM|PSR_EF|PSR_EM)
#define PSR_SET (PSR_NEM|PSR_CM|PSR_EF|PSR_EM)
#else
#else
#define PSR_SET (PSR_NEM|PSR_CM)
#define PSR_SET (PSR_NEM|PSR_CM)
#endif
#endif
#endif
#endif
        /* Enable floating point */
        /* Enable floating point */
        movsg     hsr0, gr4
        movsg     hsr0, gr4
        P(sethi)  #hi(HSR_SET), gr5
        P(sethi)  #hi(HSR_SET), gr5
        setlo     #lo(HSR_SET), gr5
        setlo     #lo(HSR_SET), gr5
        P(sethi)  #hi(~HSR_CLEAR), gr6
        P(sethi)  #hi(~HSR_CLEAR), gr6
        setlo     #lo(~HSR_CLEAR), gr6
        setlo     #lo(~HSR_CLEAR), gr6
        or        gr4, gr5, gr4
        or        gr4, gr5, gr4
        and       gr4, gr6, gr4
        and       gr4, gr6, gr4
        movgs     gr4, hsr0
        movgs     gr4, hsr0
        movsg     psr, gr4
        movsg     psr, gr4
        P(sethi)  #hi(PSR_SET), gr5
        P(sethi)  #hi(PSR_SET), gr5
        setlo     #lo(PSR_SET), gr5
        setlo     #lo(PSR_SET), gr5
        P(sethi)  #hi(~PSR_CLEAR), gr6
        P(sethi)  #hi(~PSR_CLEAR), gr6
        setlo     #lo(~PSR_CLEAR), gr6
        setlo     #lo(~PSR_CLEAR), gr6
        or        gr4, gr5, gr4
        or        gr4, gr5, gr4
        and       gr4, gr6, gr4
        and       gr4, gr6, gr4
        movgs     gr4, psr
        movgs     gr4, psr
        /* zero the bss area */
        /* zero the bss area */
        P(sethi)  #gprelhi(__bss_start), gr8
        P(sethi)  #gprelhi(__bss_start), gr8
        sethi     #gprelhi(__end), gr4
        sethi     #gprelhi(__end), gr4
        P(setlo)  #gprello(__bss_start), gr8
        P(setlo)  #gprello(__bss_start), gr8
        setlo     #gprello(__end), gr4
        setlo     #gprello(__end), gr4
        P(add)    gr8, gr16, gr8
        P(add)    gr8, gr16, gr8
        add       gr4, gr16, gr4
        add       gr4, gr16, gr4
        P(setlos) #0, gr9
        P(setlos) #0, gr9
        sub       gr4, gr8, gr10
        sub       gr4, gr8, gr10
        FDPIC(mov gr17, gr15)
        FDPIC(mov gr17, gr15)
        call      EXT(memset)
        call      EXT(memset)
        P(setlos) #0, gr8               /* zero argc, argv, envp */
        P(setlos) #0, gr8               /* zero argc, argv, envp */
        setlos    #0, gr9
        setlos    #0, gr9
        P(setlos) #0, gr10
        P(setlos) #0, gr10
        FDPIC(mov gr17, gr15)
        FDPIC(mov gr17, gr15)
        call      EXT(main)
        call      EXT(main)
        FDPIC(mov gr17, gr15)
        FDPIC(mov gr17, gr15)
        call      EXT(exit)
        call      EXT(exit)
.Lend:
.Lend:
        .size   __start,(.Lend-__start)
        .size   __start,(.Lend-__start)
#if ! __FRV_FDPIC__
#if ! __FRV_FDPIC__
        /* Routine to adjust pointers
        /* Routine to adjust pointers
           gr8  = difference to adjust by
           gr8  = difference to adjust by
           gr9  = starting address
           gr9  = starting address
           gr10 = ending address + 4
           gr10 = ending address + 4
           gr11 = amount to add to the pointer each iteration.  */
           gr11 = amount to add to the pointer each iteration.  */
        .globl  EXT(__frv_fixptrs)
        .globl  EXT(__frv_fixptrs)
        .type   EXT(__frv_fixptrs),@function
        .type   EXT(__frv_fixptrs),@function
EXT(__frv_fixptrs):
EXT(__frv_fixptrs):
        P(sub)  gr9, gr11, gr9
        P(sub)  gr9, gr11, gr9
        sub     gr10, gr11, gr10
        sub     gr10, gr11, gr10
.Lloop2:
.Lloop2:
        cmp     gr10, gr9, icc0
        cmp     gr10, gr9, icc0
        bls     icc0, 0, .Lret2
        bls     icc0, 0, .Lret2
        ldu     @(gr9,gr11), gr5
        ldu     @(gr9,gr11), gr5
        add     gr8, gr5, gr5
        add     gr8, gr5, gr5
        P(st)   gr5, @(gr9,gr0)
        P(st)   gr5, @(gr9,gr0)
        bra     .Lloop2
        bra     .Lloop2
.Lret2: ret
.Lret2: ret
.Lend2:
.Lend2:
        .size   EXT(__frv_fixptrs),.Lend2-EXT(__frv_fixptrs)
        .size   EXT(__frv_fixptrs),.Lend2-EXT(__frv_fixptrs)
#endif /* ! __FRV_FDPIC__ */
#endif /* ! __FRV_FDPIC__ */
        /* Routine to adjust statically initialized pointers
        /* Routine to adjust statically initialized pointers
           Note since these are pointers to pointers, they
           Note since these are pointers to pointers, they
           need to be adjusted themsevles.
           need to be adjusted themsevles.
           gr8  = difference to adjust by
           gr8  = difference to adjust by
           gr9  = starting address
           gr9  = starting address
           gr10 = ending address + 4
           gr10 = ending address + 4
           gr11 = amount to add to the pointer each iteration.  */
           gr11 = amount to add to the pointer each iteration.  */
        .globl  EXT(__frv_fix_usrptrs)
        .globl  EXT(__frv_fix_usrptrs)
        .type   EXT(__frv_fix_usrptrs),@function
        .type   EXT(__frv_fix_usrptrs),@function
EXT(__frv_fix_usrptrs):
EXT(__frv_fix_usrptrs):
        P(sub)  gr9, gr11, gr9
        P(sub)  gr9, gr11, gr9
        sub     gr10, gr11, gr10
        sub     gr10, gr11, gr10
.Lloop3:
.Lloop3:
        cmp     gr10, gr9, icc0
        cmp     gr10, gr9, icc0
        bls     icc0, 0, .Lret3
        bls     icc0, 0, .Lret3
        ldu     @(gr9,gr11), gr5
        ldu     @(gr9,gr11), gr5
        ld      @(gr5, gr8), gr6
        ld      @(gr5, gr8), gr6
        cmp     gr6, gr0, icc0          /* skip pointers initialized to 0 */
        cmp     gr6, gr0, icc0          /* skip pointers initialized to 0 */
        beq     icc0, 0, .Lloop3
        beq     icc0, 0, .Lloop3
        add     gr8, gr6, gr6
        add     gr8, gr6, gr6
        P(st)   gr6, @(gr5,gr8)
        P(st)   gr6, @(gr5,gr8)
        bra     .Lloop3
        bra     .Lloop3
.Lret3: ret
.Lret3: ret
.Lend3:
.Lend3:
        .size   EXT(__frv_fix_usrptrs),.Lend2-EXT(__frv_fix_usrptrs)
        .size   EXT(__frv_fix_usrptrs),.Lend2-EXT(__frv_fix_usrptrs)
        .section .data
        .section .data
        .global __dso_handle
        .global __dso_handle
        .weak __dso_handle
        .weak __dso_handle
__dso_handle:
__dso_handle:
        .long   0
        .long   0
 
 

powered by: WebSVN 2.1.0

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