gonzui


Format: Advanced Search

t2ex/t2ex_source/kernel/sysdepend_t2ex/device/tef_em1d/icrt0_t2ex_ram.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_ram.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: #define SYSCONF         (SYSINFO + 8)  // SYSCONF top
   70: 
   71:         .text
   72:         .balign        4
   73:         .globl START
   74:         .type  START, %function
   75: START:
   76:         /* Use the stack set by the monitor */
   77:         ldr    ip, =PSR_SVC|PSR_DI|PSR_F  // SVC mode/Interrupt disable
   78:         msr    cpsr_xc, ip
   79: 
   80:         /* MMU is already ON. The initial setting is done.
   81:            Only cache should be ON */
   82:         mrc    p15, 0, r4, cr1, c0
   83:         orr    r4, r4, #CR1_C
   84:         orr    r4, r4, #CR1_I|CR1_Z
   85:         mcr    p15, 0, r4, cr1, c0
   86:         ldr    r4, =0
   87:         mcr    p15, 0, r4, cr7, c7, 0     // Cache flush
   88: 
   89:         ldr    r5, =__data_org            // Initialization of 'data' area (ROM startup)
   90:         ldr    r6, =__data_start
   91:         subs   r10, r5, r6               // If r10 != 0, start Rom
   92:         beq    nocopy_data
   93:         ldr    r7, =_edata
   94:         cmp    r6, r7
   95:         bhs    nocopy_data
   96:   copy_data:
   97:         ldr    r4, [r5], #4
   98:         str    r4, [r6], #4
   99:         cmp    r6, r7
  100:         blo    copy_data
  101:   nocopy_data:
  102:         ldr    r5, =__data_usr_org        // Initialization of user 'data' area (ROM startup)
  103:         ldr    r6, =__data_usr_start
  104:         cmp    r5, r6
  105:         beq    nocopy_usr_data
  106:         ldr    r7, =_edata_usr
  107:         cmp    r6, r7
  108:         bhs    nocopy_usr_data
  109:   copy_usr_data:
  110:         ldr    r4, [r5], #4
  111:         str    r4, [r6], #4
  112:         cmp    r6, r7
  113:         blo    copy_usr_data
  114:   nocopy_usr_data:
  115: 
  116:         ldr    r4, =0                     // Clear 'bss' area
  117:         ldr    r5, =__bss_start
  118:         ldr    r6, =_end
  119:         cmp    r5, r6
  120:         bhs    nobss
  121:   clrbss:
  122:         str    r4, [r5], #4
  123:         cmp    r5, r6
  124:         blo    clrbss
  125:   nobss:
  126:         ldr    r4, =0                     // Clear user 'bss' area
  127:         ldr    r5, =__bss_usr_start
  128:         ldr    r6, =_end_usr
  129:         cmp    r5, r6
  130:         bhs    nobss_usr
  131:   clrbss_usr:
  132:         str    r4, [r5], #4
  133:         cmp    r5, r6
  134:         blo    clrbss_usr
  135:   nobss_usr:
  136: 
  137:         ldr    ip, =monitor_stacktop      // Monitor stack pointer for re-startup
  138:         str    sp, [ip]           // Save
  139:         bic    sp, sp, #7         // align stack module 8 bytes
  140: 
  141:         ldr    ip, =RAM_TOP               // Low level memory manager initial setting
  142:         ldr    r5, [ip]
  143:         cmp    r6, r5                     // _end or RAM_TOP
  144:         movhi  r5, r6                   // Either of High addresses
  145:         ldr    ip, =lowmem_top
  146:         str    r5, [ip]           // lowmem_top = _end or RAM_TOP
  147:         ldr    ip, =RAM_END
  148:         ldr    r5, [ip]
  149:         ldr    ip, =lowmem_limit
  150:         str    r5, [ip]           // lowmem_limit = RAM_END
  151: 
  152:         ldr    r4, =SYSCONF
  153:         ldr    r5, [r4]
  154:         cmp    r5, #0
  155:         bleq   l1
  156:         
  157:         cmp    r10, #0
  158:         bleq   l2
  159: 
  160:   l1:
  161:         bl     Csym(ROM_startup)   // Initialization at ROM startup
  162: 
  163:   l2:
  164:         bl     Csym(main)          // System startup
  165: 
  166:   l_end:                                // Not suppose to return from 'main,'
  167:         b      l_end                        // but, just in case, prepare for out of control.