gonzui


Format: Advanced Search

t2ex/t2ex_source/kernel/sysdepend_t2ex/device/tef_em1d/icrt0_t2ex.Sbare sourcepermlink (0.00 seconds)

Search this content:

    1: /*
    2:  *----------------------------------------------------------------------
    3:  *    T2EX Software Package
    4:  *
    5:  *    Copyright 2012 by Ken Sakamura.
    6:  *    This software is distributed under the latest version of T-License 2.x.
    7:  *----------------------------------------------------------------------
    8:  *
    9:  *    Released by T-Engine Forum(http://www.t-engine.org/) at 2012/12/12.
   10:  *    Modified by TRON Forum(http://www.tron.org/) at 2015/06/04.
   11:  *
   12:  *----------------------------------------------------------------------
   13:  */
   14: /*
   15:  * This software package is available for use, modification, 
   16:  * and redistribution in accordance with the terms of the attached 
   17:  * T-License 2.x.
   18:  * If you want to redistribute the source code, you need to attach 
   19:  * the T-License 2.x document.
   20:  * There's no obligation to publish the content, and no obligation 
   21:  * to disclose it to the TRON Forum if you have modified the 
   22:  * software package.
   23:  * You can also distribute the modified source code. In this case, 
   24:  * please register the modification to T-Kernel traceability service.
   25:  * People can know the history of modifications by the service, 
   26:  * and can be sure that the version you have inherited some 
   27:  * modification of a particular version or not.
   28:  *
   29:  *    http://trace.tron.org/tk/?lang=en
   30:  *    http://trace.tron.org/tk/?lang=ja
   31:  *
   32:  * As per the provisions of the T-License 2.x, TRON Forum ensures that 
   33:  * the portion of the software that is copyrighted by Ken Sakamura or 
   34:  * the TRON Forum does not infringe the copyrights of a third party.
   35:  * However, it does not make any warranty other than this.
   36:  * DISCLAIMER: TRON Forum and Ken Sakamura shall not be held
   37:  * responsible for any consequences or damages caused directly or
   38:  * indirectly by the use of this software package.
   39:  *
   40:  * The source codes in bsd_source.tar.gz in this software package are 
   41:  * derived from NetBSD or OpenBSD and not covered under T-License 2.x.
   42:  * They need to be changed or redistributed according to the 
   43:  * representation of each source header.
   44:  */
   45: 
   46: /*
   47:  *      icrt0.S (EM1-D512)
   48:  *      System Startup
   49:  */
   50: 
   51: #include <machine.h>
   52: #include <tk/asm.h>
   53: 
   54: #if _Csym == 0
   55: #define START   _start
   56: #else
   57: #define START   start
   58: #endif
   59: 
   60:         /* Low level memory manager information */
   61:         .comm  Csym(lowmem_top), 4      // Head of area (Low address)
   62:         .comm  Csym(lowmem_limit), 4    // End of area (High address)
   63: 
   64:         .lcomm monitor_stacktop, 4     // Monitor stack pointer for re-startup
   65: 
   66: #define SYSINFO         0x30004400     // System common information
   67: #define RAM_TOP         (SYSINFO + 0)  // Head of ext. RAM free area
   68: #define RAM_END         (SYSINFO + 4)  // End of ext. RAM free area
   69: 
   70:         .text
   71:         .balign        4
   72:         .globl START
   73:         .type  START, %function
   74: START:
   75:         /* Use the stack set by the monitor */
   76:         ldr    ip, =PSR_SVC|PSR_DI|PSR_F  // SVC mode/Interrupt disable
   77:         msr    cpsr_xc, ip
   78: 
   79:         /* MMU is already ON. The initial setting is done.
   80:            Only cache should be ON */
   81:         mrc    p15, 0, r4, cr1, c0
   82:         orr    r4, r4, #CR1_C
   83:         orr    r4, r4, #CR1_I|CR1_Z
   84:         mcr    p15, 0, r4, cr1, c0
   85:         ldr    r4, =0
   86:         mcr    p15, 0, r4, cr7, c7, 0     // Cache flush
   87: 
   88:         ldr    r5, =__data_org            // Initialization of system 'data' area (ROM startup)
   89:         ldr    r6, =__data_start
   90:         subs   r10, r5, r6               // If r10 != 0, start Rom
   91:         beq    nocopy_data
   92:         ldr    r7, =_edata
   93:         cmp    r6, r7
   94:         bhs    nocopy_data
   95:   copy_data:
   96:         ldr    r4, [r5], #4
   97:         str    r4, [r6], #4
   98:         cmp    r6, r7
   99:         blo    copy_data
  100:   nocopy_data:
  101:         ldr    r5, =__data_usr_org        // Initialization of user 'data' area (ROM startup)
  102:         ldr    r6, =__data_usr_start
  103:         cmp    r5, r6
  104:         beq    nocopy_usr_data
  105:         ldr    r7, =_edata_usr
  106:         cmp    r6, r7
  107:         bhs    nocopy_usr_data
  108:   copy_usr_data:
  109:         ldr    r4, [r5], #4
  110:         str    r4, [r6], #4
  111:         cmp    r6, r7
  112:         blo    copy_usr_data
  113:   nocopy_usr_data:
  114: 
  115:         ldr    r4, =0                     // Clear system 'bss' area
  116:         ldr    r5, =__bss_start
  117:         ldr    r6, =_end
  118:         cmp    r5, r6
  119:         bhs    nobss
  120:   clrbss:
  121:         str    r4, [r5], #4
  122:         cmp    r5, r6
  123:         blo    clrbss
  124:   nobss:
  125:         ldr    r4, =0                     // Clear user 'bss' area
  126:         ldr    r5, =__bss_usr_start
  127:         ldr    r6, =_end_usr
  128:         cmp    r5, r6
  129:         bhs    nobss_usr
  130:   clrbss_usr:
  131:         str    r4, [r5], #4
  132:         cmp    r5, r6
  133:         blo    clrbss_usr
  134:   nobss_usr:
  135: 
  136:         ldr    ip, =monitor_stacktop      // Monitor stack pointer for re-startup
  137:         str    sp, [ip]           // Save
  138:         bic    sp, sp, #7         // align stack modulo 8 bytes.
  139: 
  140:         ldr    ip, =RAM_TOP               // Low level memory manager initial setting
  141:         ldr    r5, [ip]
  142:         cmp    r6, r5                     // _end or RAM_TOP
  143:         movhi  r5, r6                   // Either of High addresses
  144:         ldr    ip, =lowmem_top
  145:         str    r5, [ip]           // lowmem_top = _end or RAM_TOP
  146:         ldr    ip, =RAM_END
  147:         ldr    r5, [ip]
  148:         ldr    ip, =lowmem_limit
  149:         str    r5, [ip]           // lowmem_limit = RAM_END
  150: 
  151:         cmp    r10, #0
  152:         blne   Csym(ROM_startup) // Initialization at ROM startup
  153: 
  154:         bl     Csym(main)          // System startup
  155: 
  156:   l_end:                                // Not suppose to return from 'main,'
  157:         b      l_end                        // but, just in case, prepare for out of control.