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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.18.0/] [libgloss/] [or32/] [crt0.S] - Diff between revs 399 and 469

Only display areas with differences | Details | Blame | View Log

Rev 399 Rev 469
/* crt0.S. C Runtime startup file.
/* crt0.S. C Runtime startup file.
   Copyright (C) 2004, Jacob Bower
   Copyright (C) 2004, Jacob Bower
   Copyright (C) 2010, Embecosm Limited 
   Copyright (C) 2010, Embecosm Limited 
   Contributor Jeremy Bennett 
   Contributor Jeremy Bennett 
   This file is part of Newlib.
   This file is part of Newlib.
   The original work by Jacob Bower is provided as-is without any kind of
   The original work by Jacob Bower is provided as-is without any kind of
   warranty. Use it at your own risk!
   warranty. Use it at your own risk!
   All subsequent work is bound by version 3 of the GPL as follows.
   All subsequent work is bound by version 3 of the GPL as follows.
   This program is free software; you can redistribute it and/or modify it
   This program is free software; you can redistribute it and/or modify it
   under the terms of the GNU General Public License as published by the Free
   under the terms of the GNU General Public License as published by the Free
   Software Foundation; either version 3 of the License, or (at your option)
   Software Foundation; either version 3 of the License, or (at your option)
   any later version.
   any later version.
   This program is distributed in the hope that it will be useful, but WITHOUT
   This program is distributed in the hope that it will be useful, but WITHOUT
   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
   more details.
   more details.
   You should have received a copy of the GNU General Public License along
   You should have received a copy of the GNU General Public License along
   with this program.  If not, see .            */
   with this program.  If not, see .            */
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/* This program is commented throughout in a fashion suitable for processing
/* This program is commented throughout in a fashion suitable for processing
   with Doxygen.                                                              */
   with Doxygen.                                                              */
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
#include "spr-defs.h"
#include "spr-defs.h"
#include "or1ksim-board.h"
#include "or1ksim-board.h"
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/*!Macro for expressions which do not have their own handler.
/*!Macro for expressions which do not have their own handler.
   Construct the arguments for a call to printf, then exit. Being varargs, the
   Construct the arguments for a call to printf, then exit. Being varargs, the
   arguments to printf must be on the stack, which we update using the
   arguments to printf must be on the stack, which we update using the
   standard prologue.
   standard prologue.
  @param[in] str  Label for a string describing the macro, suitable for
  @param[in] str  Label for a string describing the macro, suitable for
                  printf.                                                     */
                  printf.                                                     */
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
#define UNHANDLED_EXCEPTION(str)                                         \
#define UNHANDLED_EXCEPTION(str)                                         \
        l.addi  r1,r1,-20               /* Standard prologue */         ;\
        l.addi  r1,r1,-20               /* Standard prologue */         ;\
        l.sw    16(r1),r2                                               ;\
        l.sw    16(r1),r2                                               ;\
        l.addi  r2,r1,20                                                ;\
        l.addi  r2,r1,20                                                ;\
        l.sw    12(r1),r9                                               ;\
        l.sw    12(r1),r9                                               ;\
                                                                        ;\
                                                                        ;\
        l.movhi r3,hi(.Lfmt)            /* printf format string */      ;\
        l.movhi r3,hi(.Lfmt)            /* printf format string */      ;\
        l.ori   r3,r3,lo(.Lfmt)                                         ;\
        l.ori   r3,r3,lo(.Lfmt)                                         ;\
        l.sw    0(r1),r3                                                ;\
        l.sw    0(r1),r3                                                ;\
        l.movhi r4,hi(str)              /* Name of exception */         ;\
        l.movhi r4,hi(str)              /* Name of exception */         ;\
        l.ori   r4,r4,lo(str)                                           ;\
        l.ori   r4,r4,lo(str)                                           ;\
        l.sw    4(r1),r4                                                ;\
        l.sw    4(r1),r4                                                ;\
        l.mfspr r5,r0,SPR_EPCR_BASE     /* Source of the interrupt */   ;\
        l.mfspr r5,r0,SPR_EPCR_BASE     /* Source of the interrupt */   ;\
        l.jal   printf                                                  ;\
        l.jal   printf                                                  ;\
        l.sw    8(r1),r5                                                ;\
        l.sw    8(r1),r5                                                ;\
                                                                        ;\
                                                                        ;\
        l.ori   r3,r0,0xffff            /* Failure RC */                ;\
        l.ori   r3,r0,0xffff            /* Failure RC */                ;\
        l.jal   exit                                                    ;\
        l.jal   exit                                                    ;\
        l.nop                                                           ;\
        l.nop                                                           ;\
                                                                        ;\
                                                                        ;\
        l.rfe                           /* Never executed we hope */
        l.rfe                           /* Never executed we hope */
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/*!Text strings for the different exceptions                                  */
/*!Text strings for the different exceptions                                  */
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
        .section .rodata
        .section .rodata
.Lfmt:  .string "Unhandled %s exception at address %08p\n"
.Lfmt:  .string "Unhandled %s exception at address %08p\n"
.L200:  .string "bus error"
.L200:  .string "bus error"
.L300:  .string "data page fault"
.L300:  .string "data page fault"
.L400:  .string "instruction page fault"
.L400:  .string "instruction page fault"
.L500:  .string "timer"
.L500:  .string "timer"
.L600:  .string "alignment"
.L600:  .string "alignment"
.L700:  .string "illegal instruction"
.L700:  .string "illegal instruction"
.L800:  .string "external interrupt"
.L800:  .string "external interrupt"
.L900:  .string "data TLB"
.L900:  .string "data TLB"
.La00:  .string "instruction TLB"
.La00:  .string "instruction TLB"
.Lb00:  .string "range"
.Lb00:  .string "range"
.Lc00:  .string "syscall"
.Lc00:  .string "syscall"
.Ld00:  .string "floating point"
.Ld00:  .string "floating point"
.Le00:  .string "trap"
.Le00:  .string "trap"
.Lf00:  .string "undefined 0xf00"
.Lf00:  .string "undefined 0xf00"
.L1000: .string "undefined 0x1000"
.L1000: .string "undefined 0x1000"
.L1100: .string "undefined 0x1100"
.L1100: .string "undefined 0x1100"
.L1200: .string "undefined 0x1200"
.L1200: .string "undefined 0x1200"
.L1300: .string "undefined 0x1300"
.L1300: .string "undefined 0x1300"
.L1400: .string "undefined 0x1400"
.L1400: .string "undefined 0x1400"
.L1500: .string "undefined 0x1500"
.L1500: .string "undefined 0x1500"
.L1600: .string "undefined 0x1600"
.L1600: .string "undefined 0x1600"
.L1700: .string "undefined 0x1700"
.L1700: .string "undefined 0x1700"
.L1800: .string "undefined 0x1800"
.L1800: .string "undefined 0x1800"
.L1900: .string "undefined 0x1900"
.L1900: .string "undefined 0x1900"
.L1a00: .string "undefined 0x1a00"
.L1a00: .string "undefined 0x1a00"
.L1b00: .string "undefined 0x1b00"
.L1b00: .string "undefined 0x1b00"
.L1c00: .string "undefined 0x1c00"
.L1c00: .string "undefined 0x1c00"
.L1d00: .string "undefined 0x1d00"
.L1d00: .string "undefined 0x1d00"
.L1e00: .string "undefined 0x1e00"
.L1e00: .string "undefined 0x1e00"
.L1f00: .string "undefined 0x1f00"
.L1f00: .string "undefined 0x1f00"
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/*!Exception vectors                                                          */
/*!Exception vectors                                                          */
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
        .section .vectors,"ax"
        .section .vectors,"ax"
        /* 0x100: RESET exception */
        /* 0x100: RESET exception */
        .org    0x100
        .org    0x100
__reset:
__reset:
        /* Jump to program initialisation code */
        /* Jump to program initialisation code */
        l.j     _start
        l.j     _start
        l.nop
        l.nop
        /* 0x200: BUS exception is special, because during startup we use it
        /* 0x200: BUS exception is special, because during startup we use it
           to detect where the stack should go. So we need some special code
           to detect where the stack should go. So we need some special code
           before we return, which wel will later overwrite with l.nop. We
           before we return, which wel will later overwrite with l.nop. We
           need to deal with the case when _start is called multiple times, so
           need to deal with the case when _start is called multiple times, so
           this code must be copied into the bus error vector each time. It is
           this code must be copied into the bus error vector each time. It is
           position independent to allow this copying.
           position independent to allow this copying.
           We use registers we know will not interfere in this case. */
           We use registers we know will not interfere in this case. */
        .org    0x200
        .org    0x200
__buserr:
__buserr:
        l.nop                           /* Will be overwritten */
        l.nop                           /* Will be overwritten */
        l.nop
        l.nop
        l.nop
        l.nop
        l.nop
        l.nop
__buserr_std:
__buserr_std:
        UNHANDLED_EXCEPTION (.L200)
        UNHANDLED_EXCEPTION (.L200)
__buserr_special:
__buserr_special:
        l.mfspr r24,r0,SPR_EPCR_BASE
        l.mfspr r24,r0,SPR_EPCR_BASE
        l.addi  r24,r24,4               /* Return one instruction on */
        l.addi  r24,r24,4               /* Return one instruction on */
        l.mtspr r0,r24,SPR_EPCR_BASE
        l.mtspr r0,r24,SPR_EPCR_BASE
        l.rfe
        l.rfe
        /* 0x300: Data Page Fault exception */
        /* 0x300: Data Page Fault exception */
        .org    0x300
        .org    0x300
        UNHANDLED_EXCEPTION (.L300)
        UNHANDLED_EXCEPTION (.L300)
        /* 0x400: Insn Page Fault exception */
        /* 0x400: Insn Page Fault exception */
        .org    0x400
        .org    0x400
        UNHANDLED_EXCEPTION (.L400)
        UNHANDLED_EXCEPTION (.L400)
        /* 0x500: Timer exception */
        /* 0x500: Timer exception */
        .org    0x500
        .org    0x500
        UNHANDLED_EXCEPTION (.L500)
        UNHANDLED_EXCEPTION (.L500)
        /* 0x600: Aligment exception */
        /* 0x600: Aligment exception */
        .org    0x600
        .org    0x600
        UNHANDLED_EXCEPTION (.L600)
        UNHANDLED_EXCEPTION (.L600)
        /* 0x700: Illegal insn exception */
        /* 0x700: Illegal insn exception */
        .org    0x700
        .org    0x700
        UNHANDLED_EXCEPTION (.L700)
        UNHANDLED_EXCEPTION (.L700)
        /* 0x800: External interrupt exception */
        /* 0x800: External interrupt exception */
        .org    0x800
        .org    0x800
        UNHANDLED_EXCEPTION (.L800)
        UNHANDLED_EXCEPTION (.L800)
        /* 0x900: DTLB miss exception */
        /* 0x900: DTLB miss exception */
        .org    0x900
        .org    0x900
        UNHANDLED_EXCEPTION (.L900)
        UNHANDLED_EXCEPTION (.L900)
        /* 0xa00: ITLB miss exception */
        /* 0xa00: ITLB miss exception */
        .org    0xa00
        .org    0xa00
        UNHANDLED_EXCEPTION (.La00)
        UNHANDLED_EXCEPTION (.La00)
        /* 0xb00: Range exception */
        /* 0xb00: Range exception */
        .org    0xb00
        .org    0xb00
        UNHANDLED_EXCEPTION (.Lb00)
        UNHANDLED_EXCEPTION (.Lb00)
        /* 0xc00: Syscall exception */
        /* 0xc00: Syscall exception */
        .org    0xc00
        .org    0xc00
        UNHANDLED_EXCEPTION (.Lc00)
        UNHANDLED_EXCEPTION (.Lc00)
        /* 0xd00: floating point exception */
        /* 0xd00: floating point exception */
        .org    0xd00
        .org    0xd00
        UNHANDLED_EXCEPTION (.Ld00)
        UNHANDLED_EXCEPTION (.Ld00)
        /* 0xe00: Trap exception */
        /* 0xe00: Trap exception */
        .org    0xe00
        .org    0xe00
        UNHANDLED_EXCEPTION (.Le00)
        UNHANDLED_EXCEPTION (.Le00)
        /* 0xf00: Reserved exceptions */
        /* 0xf00: Reserved exceptions */
        .org    0xf00
        .org    0xf00
        UNHANDLED_EXCEPTION (.Lf00)
        UNHANDLED_EXCEPTION (.Lf00)
        .org    0x1000
        .org    0x1000
        UNHANDLED_EXCEPTION (.L1000)
        UNHANDLED_EXCEPTION (.L1000)
        .org    0x1100
        .org    0x1100
        UNHANDLED_EXCEPTION (.L1100)
        UNHANDLED_EXCEPTION (.L1100)
        .org    0x1200
        .org    0x1200
        UNHANDLED_EXCEPTION (.L1200)
        UNHANDLED_EXCEPTION (.L1200)
        .org    0x1300
        .org    0x1300
        UNHANDLED_EXCEPTION (.L1300)
        UNHANDLED_EXCEPTION (.L1300)
        .org    0x1400
        .org    0x1400
        UNHANDLED_EXCEPTION (.L1400)
        UNHANDLED_EXCEPTION (.L1400)
        .org    0x1500
        .org    0x1500
        UNHANDLED_EXCEPTION (.L1500)
        UNHANDLED_EXCEPTION (.L1500)
        .org    0x1600
        .org    0x1600
        UNHANDLED_EXCEPTION (.L1600)
        UNHANDLED_EXCEPTION (.L1600)
        .org    0x1700
        .org    0x1700
        UNHANDLED_EXCEPTION (.L1700)
        UNHANDLED_EXCEPTION (.L1700)
        .org    0x1800
        .org    0x1800
        UNHANDLED_EXCEPTION (.L1800)
        UNHANDLED_EXCEPTION (.L1800)
        .org    0x1900
        .org    0x1900
        UNHANDLED_EXCEPTION (.L1900)
        UNHANDLED_EXCEPTION (.L1900)
        .org    0x1a00
        .org    0x1a00
        UNHANDLED_EXCEPTION (.L1a00)
        UNHANDLED_EXCEPTION (.L1a00)
        .org    0x1b00
        .org    0x1b00
        UNHANDLED_EXCEPTION (.L1b00)
        UNHANDLED_EXCEPTION (.L1b00)
        .org    0x1c00
        .org    0x1c00
        UNHANDLED_EXCEPTION (.L1c00)
        UNHANDLED_EXCEPTION (.L1c00)
        .org    0x1d00
        .org    0x1d00
        UNHANDLED_EXCEPTION (.L1d00)
        UNHANDLED_EXCEPTION (.L1d00)
        .org    0x1e00
        .org    0x1e00
        UNHANDLED_EXCEPTION (.L1e00)
        UNHANDLED_EXCEPTION (.L1e00)
        .org    0x1f00
        .org    0x1f00
        UNHANDLED_EXCEPTION (.L1f00)
        UNHANDLED_EXCEPTION (.L1f00)
        /* Pad to the end */
        /* Pad to the end */
        .org    0x1ffc
        .org    0x1ffc
        l.nop
        l.nop
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/*!Main entry point
/*!Main entry point
   We initialise the stack and frame pointer first, before we set up the
   We initialise the stack and frame pointer first, before we set up the
   caches, since otherwise we'll need to disable the instruction cache when
   caches, since otherwise we'll need to disable the instruction cache when
   patching the bus error vector code.
   patching the bus error vector code.
   The remaining tasks are then:
   The remaining tasks are then:
   - optionally set up instruction and/or data caches
   - optionally set up instruction and/or data caches
   - clear BSS
   - clear BSS
   - call global and static constructors
   - call global and static constructors
   - set up destructors to be called from exit
   - set up destructors to be called from exit
   - initialize the UART (may be dummy, if no UART supported)
   - initialize the UART (may be dummy, if no UART supported)
   - jump to the main function
   - jump to the main function
   - call exit if the main function ever returns.
   - call exit if the main function ever returns.
   - loop forever (should never get here)                                     */
   - loop forever (should never get here)                                     */
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
        /* The stack grows down from the top of writable memory. */
        /* The stack grows down from the top of writable memory. */
        .section .data
        .section .data
        .global stack
        .global stack
stack:  .space  4,0
stack:  .space  4,0
        .section .text
        .section .text
        .global _start
        .global _start
        .type   _start,@function
        .type   _start,@function
_start:
_start:
 
        /* First, clear r0. */
 
        l.movhi r0,0
        /* Finding the end of stack means we need to handle the bus
        /* Finding the end of stack means we need to handle the bus
           error. Patch in some special handler code. */
           error. Patch in some special handler code. */
        l.movhi r30,hi(__buserr)        /* Where to copy to */
        l.movhi r30,hi(__buserr)        /* Where to copy to */
        l.ori   r30,r30,lo(__buserr)
        l.ori   r30,r30,lo(__buserr)
        l.movhi r28,hi(__buserr_std)    /* Where to stop copying */
        l.movhi r28,hi(__buserr_std)    /* Where to stop copying */
        l.ori   r28,r28,lo(__buserr_std)
        l.ori   r28,r28,lo(__buserr_std)
        l.movhi r26,hi(__buserr_special)/* Where to copy from */
        l.movhi r26,hi(__buserr_special)/* Where to copy from */
        l.ori   r26,r26,lo(__buserr_special)
        l.ori   r26,r26,lo(__buserr_special)
.L11:   l.sfeq  r28,r30
.L11:   l.sfeq  r28,r30
        l.bf    .L12
        l.bf    .L12
        l.nop
        l.nop
        l.lwz   r24,0(r26)              /* Get the instruction */
        l.lwz   r24,0(r26)              /* Get the instruction */
        l.sw    0(r30),r24              /* Patch the instruction */
        l.sw    0(r30),r24              /* Patch the instruction */
        l.addi  r26,r26,4               /* Next source instruction */
        l.addi  r26,r26,4               /* Next source instruction */
        l.j     .L11
        l.j     .L11
        l.addi  r30,r30,4               /* Delay slot: next dest location */
        l.addi  r30,r30,4               /* Delay slot: next dest location */
        /* Determine where the stack should end. Must be somewhere above the
        /* Determine where the stack should end. Must be somewhere above the
           end of loaded memory. We look in blocks of 64KB. */
           end of loaded memory. We look in blocks of 64KB. */
.L12:   l.movhi r30,hi(end)
.L12:   l.movhi r30,hi(end)
        l.ori   r30,r30,lo(end)
        l.ori   r30,r30,lo(end)
        l.srli  r30,r30,16              /* Round down to 64KB boundary */
        l.srli  r30,r30,16              /* Round down to 64KB boundary */
        l.slli  r30,r30,16
        l.slli  r30,r30,16
        l.addi  r28,r0,1                /* Constant 64KB in register */
        l.addi  r28,r0,1                /* Constant 64KB in register */
        l.slli  r28,r28,16
        l.slli  r28,r28,16
        l.add   r30,r30,r28
        l.add   r30,r30,r28
        l.addi  r30,r30,-4              /* SP one word inside next 64KB? */
        l.addi  r30,r30,-4              /* SP one word inside next 64KB? */
        l.movhi r26,0xaaaa              /* Test pattern to store in memory */
        l.movhi r26,0xaaaa              /* Test pattern to store in memory */
        l.ori   r26,r26,0xaaaa
        l.ori   r26,r26,0xaaaa
        /* Is this a writeable location? */
        /* Is this a writeable location? */
.L3:    l.sw    0(r30),r26
.L3:    l.sw    0(r30),r26
        l.lwz   r24,0(r30)
        l.lwz   r24,0(r30)
        l.sfeq  r24,r26
        l.sfeq  r24,r26
        l.bnf   .L4
        l.bnf   .L4
        l.nop
        l.nop
        l.j     .L3
        l.j     .L3
        l.add   r30,r30,r28             /* Try 64KB higher */
        l.add   r30,r30,r28             /* Try 64KB higher */
.L4:    l.sub   r30,r30,r28             /* Previous value was wanted */
.L4:    l.sub   r30,r30,r28             /* Previous value was wanted */
        l.movhi r26,hi(stack)
        l.movhi r26,hi(stack)
        l.ori   r26,r26,lo(stack)
        l.ori   r26,r26,lo(stack)
        l.sw    0(r26),r30
        l.sw    0(r26),r30
        /* Initialise stack and frame pointer (set to same value) */
        /* Initialise stack and frame pointer (set to same value) */
        l.add   r1,r30,r0
        l.add   r1,r30,r0
        l.add   r2,r30,r0
        l.add   r2,r30,r0
        /* Clear out the bus error vector special code. */
        /* Clear out the bus error vector special code. */
        l.movhi r30,hi(__buserr)
        l.movhi r30,hi(__buserr)
        l.ori   r30,r30,lo(__buserr)
        l.ori   r30,r30,lo(__buserr)
        l.movhi r28,hi(__buserr_std)
        l.movhi r28,hi(__buserr_std)
        l.ori   r28,r28,lo(__buserr_std)
        l.ori   r28,r28,lo(__buserr_std)
        l.movhi r26,0x1500              /* l.nop 0 */
        l.movhi r26,0x1500              /* l.nop 0 */
        l.ori   r26,r26,0x0000
        l.ori   r26,r26,0x0000
.L5:    l.sfeq  r28,r30
.L5:    l.sfeq  r28,r30
        l.bf    .L6
        l.bf    .L6
        l.nop
        l.nop
        l.sw    0(r30),r26              /* Patch the instruction */
        l.sw    0(r30),r26              /* Patch the instruction */
        l.j     .L5
        l.j     .L5
        l.addi  r30,r30,4               /* Delay slot: next instruction */
        l.addi  r30,r30,4               /* Delay slot: next instruction */
        /* Instruction cache enable */
        /* Instruction cache enable */
        /* Check if IC present and skip enabling otherwise */
        /* Check if IC present and skip enabling otherwise */
.L6:    l.mfspr r24,r0,SPR_UPR
.L6:    l.mfspr r24,r0,SPR_UPR
        l.andi  r26,r24,SPR_UPR_ICP
        l.andi  r26,r24,SPR_UPR_ICP
        l.sfeq  r26,r0
        l.sfeq  r26,r0
        l.bf    .L8
        l.bf    .L8
        l.nop
        l.nop
        /* Disable IC */
        /* Disable IC */
        l.mfspr r6,r0,SPR_SR
        l.mfspr r6,r0,SPR_SR
        l.addi  r5,r0,-1
        l.addi  r5,r0,-1
        l.xori  r5,r5,SPR_SR_ICE
        l.xori  r5,r5,SPR_SR_ICE
        l.and   r5,r6,r5
        l.and   r5,r6,r5
        l.mtspr r0,r5,SPR_SR
        l.mtspr r0,r5,SPR_SR
        /* Establish cache block size
        /* Establish cache block size
        If BS=0, 16;
        If BS=0, 16;
        If BS=1, 32;
        If BS=1, 32;
        r14 contain block size
        r14 contain block size
        */
        */
        l.mfspr r24,r0,SPR_ICCFGR
        l.mfspr r24,r0,SPR_ICCFGR
        l.andi  r26,r24,SPR_ICCFGR_CBS
        l.andi  r26,r24,SPR_ICCFGR_CBS
        l.srli  r28,r26,7
        l.srli  r28,r26,7
        l.ori   r30,r0,16
        l.ori   r30,r0,16
        l.sll   r14,r30,r28
        l.sll   r14,r30,r28
        /* Establish number of cache sets
        /* Establish number of cache sets
        r16 contains number of cache sets
        r16 contains number of cache sets
        r28 contains log(# of cache sets)
        r28 contains log(# of cache sets)
        */
        */
        l.andi  r26,r24,SPR_ICCFGR_NCS
        l.andi  r26,r24,SPR_ICCFGR_NCS
        l.srli  r28,r26,3
        l.srli  r28,r26,3
        l.ori   r30,r0,1
        l.ori   r30,r0,1
        l.sll   r16,r30,r28
        l.sll   r16,r30,r28
        /* Invalidate IC */
        /* Invalidate IC */
        l.addi  r6,r0,0
        l.addi  r6,r0,0
        l.sll   r5,r14,r28
        l.sll   r5,r14,r28
.L7:    l.mtspr r0,r6,SPR_ICBIR
.L7:    l.mtspr r0,r6,SPR_ICBIR
        l.sfne  r6,r5
        l.sfne  r6,r5
        l.bf    .L7
        l.bf    .L7
        l.add   r6,r6,r14
        l.add   r6,r6,r14
        /* Enable IC */
        /* Enable IC */
        l.mfspr r6,r0,SPR_SR
        l.mfspr r6,r0,SPR_SR
        l.ori   r6,r6,SPR_SR_ICE
        l.ori   r6,r6,SPR_SR_ICE
        l.mtspr r0,r6,SPR_SR
        l.mtspr r0,r6,SPR_SR
        l.nop
        l.nop
        l.nop
        l.nop
        l.nop
        l.nop
        l.nop
        l.nop
        l.nop
        l.nop
        l.nop
        l.nop
        l.nop
        l.nop
        l.nop
        l.nop
        /* Data cache enable */
        /* Data cache enable */
        /* Check if DC present and skip enabling otherwise */
        /* Check if DC present and skip enabling otherwise */
.L8:    l.mfspr r24,r0,SPR_UPR
.L8:    l.mfspr r24,r0,SPR_UPR
        l.andi  r26,r24,SPR_UPR_DCP
        l.andi  r26,r24,SPR_UPR_DCP
        l.sfeq  r26,r0
        l.sfeq  r26,r0
        l.bf    .L10
        l.bf    .L10
        l.nop
        l.nop
        /* Disable DC */
        /* Disable DC */
        l.mfspr r6,r0,SPR_SR
        l.mfspr r6,r0,SPR_SR
        l.addi  r5,r0,-1
        l.addi  r5,r0,-1
        l.xori  r5,r5,SPR_SR_DCE
        l.xori  r5,r5,SPR_SR_DCE
        l.and   r5,r6,r5
        l.and   r5,r6,r5
        l.mtspr r0,r5,SPR_SR
        l.mtspr r0,r5,SPR_SR
        /* Establish cache block size
        /* Establish cache block size
           If BS=0, 16;
           If BS=0, 16;
           If BS=1, 32;
           If BS=1, 32;
           r14 contain block size
           r14 contain block size
        */
        */
        l.mfspr r24,r0,SPR_DCCFGR
        l.mfspr r24,r0,SPR_DCCFGR
        l.andi  r26,r24,SPR_DCCFGR_CBS
        l.andi  r26,r24,SPR_DCCFGR_CBS
        l.srli  r28,r26,7
        l.srli  r28,r26,7
        l.ori   r30,r0,16
        l.ori   r30,r0,16
        l.sll   r14,r30,r28
        l.sll   r14,r30,r28
        /* Establish number of cache sets
        /* Establish number of cache sets
           r16 contains number of cache sets
           r16 contains number of cache sets
           r28 contains log(# of cache sets)
           r28 contains log(# of cache sets)
        */
        */
        l.andi  r26,r24,SPR_DCCFGR_NCS
        l.andi  r26,r24,SPR_DCCFGR_NCS
        l.srli  r28,r26,3
        l.srli  r28,r26,3
        l.ori   r30,r0,1
        l.ori   r30,r0,1
        l.sll   r16,r30,r28
        l.sll   r16,r30,r28
        /* Invalidate DC */
        /* Invalidate DC */
        l.addi  r6,r0,0
        l.addi  r6,r0,0
        l.sll   r5,r14,r28
        l.sll   r5,r14,r28
.L9:    l.mtspr r0,r6,SPR_DCBIR
.L9:    l.mtspr r0,r6,SPR_DCBIR
        l.sfne  r6,r5
        l.sfne  r6,r5
        l.bf    .L9
        l.bf    .L9
        l.add   r6,r6,r14
        l.add   r6,r6,r14
        /* Enable DC */
        /* Enable DC */
        l.mfspr r6,r0,SPR_SR
        l.mfspr r6,r0,SPR_SR
        l.ori   r6,r6,SPR_SR_DCE
        l.ori   r6,r6,SPR_SR_DCE
        l.mtspr r0,r6,SPR_SR
        l.mtspr r0,r6,SPR_SR
        /* Clear BSS */
        /* Clear BSS */
.L10:   l.movhi r28,hi(__bss_start)
.L10:   l.movhi r28,hi(__bss_start)
        l.ori   r28,r28,lo(__bss_start)
        l.ori   r28,r28,lo(__bss_start)
        l.movhi r30,hi(end)
        l.movhi r30,hi(end)
        l.ori   r30,r30,lo(end)
        l.ori   r30,r30,lo(end)
.L1:    l.sw    (0)(r28),r0
.L1:    l.sw    (0)(r28),r0
        l.sfltu r28,r30
        l.sfltu r28,r30
        l.bf    .L1
        l.bf    .L1
        l.addi  r28,r28,4               /* Delay slot */
        l.addi  r28,r28,4               /* Delay slot */
        /* Call global and static constructors */
        /* Call global and static constructors */
        l.jal   __init
        l.jal   __init
        l.nop
        l.nop
        /* Set up destructors to be called from exit if main never returns */
        /* Set up destructors to be called from exit if main never returns */
        l.movhi r3,hi(__fini)
        l.movhi r3,hi(__fini)
        l.jal   atexit
        l.jal   atexit
        l.ori   r3,r3,lo(__fini)        /* Delay slot */
        l.ori   r3,r3,lo(__fini)        /* Delay slot */
        /* Initialise UART in a C function. If the UART isn't present, we'll */
        /* Initialise UART in a C function. If the UART isn't present, we'll */
        /* link against a dummy function. */
        /* link against a dummy function. */
        l.jal    __uart_init
        l.jal    __uart_init
        l.nop
        l.nop
        /* Jump to main program entry point (argc = argv = envp = 0) */
        /* Jump to main program entry point (argc = argv = envp = 0) */
        l.or    r3,r0,r0
        l.or    r3,r0,r0
        l.or    r4,r0,r0
        l.or    r4,r0,r0
        l.jal   main
        l.jal   main
        l.or    r5,r0,r0                /* Delay slot */
        l.or    r5,r0,r0                /* Delay slot */
        /* If program exits, call exit routine */
        /* If program exits, call exit routine */
        l.jal   exit
        l.jal   exit
        l.addi  r3,r11,0                /* Delay slot */
        l.addi  r3,r11,0                /* Delay slot */
        /* Loop forever */
        /* Loop forever */
.L2:    l.j     .L2
.L2:    l.j     .L2
        l.nop
        l.nop
        .size   _start, .-_start
        .size   _start, .-_start
 
 

powered by: WebSVN 2.1.0

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