f
Dependents: Active-WolfMan_V2-5-All-Frank-Board-Functions_copy
rtx/TARGET_ARM7/RTX_CM_lib.h@80:2dab120a94c2, 2015-06-01 (annotated)
- Committer:
- mbed_official
- Date:
- Mon Jun 01 11:00:36 2015 +0100
- Revision:
- 80:2dab120a94c2
- Child:
- 116:0788b1a76461
Synchronized with git revision 7a1d25e3dfbe5bc1457774d4af3c73383a0ff81d
Full URL: https://github.com/mbedmicro/mbed/commit/7a1d25e3dfbe5bc1457774d4af3c73383a0ff81d/
Silicon Labs - Initial test framework pin definitions for EFM32 platforms
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 80:2dab120a94c2 | 1 | /*---------------------------------------------------------------------------- |
mbed_official | 80:2dab120a94c2 | 2 | * RL-ARM - RTX |
mbed_official | 80:2dab120a94c2 | 3 | *---------------------------------------------------------------------------- |
mbed_official | 80:2dab120a94c2 | 4 | * Name: RTX_CM_LIB.H |
mbed_official | 80:2dab120a94c2 | 5 | * Purpose: RTX Kernel System Configuration |
mbed_official | 80:2dab120a94c2 | 6 | * Rev.: V4.60 |
mbed_official | 80:2dab120a94c2 | 7 | *---------------------------------------------------------------------------- |
mbed_official | 80:2dab120a94c2 | 8 | * |
mbed_official | 80:2dab120a94c2 | 9 | * Copyright (c) 1999-2009 KEIL, 2009-2015 ARM Germany GmbH |
mbed_official | 80:2dab120a94c2 | 10 | * All rights reserved. |
mbed_official | 80:2dab120a94c2 | 11 | * Redistribution and use in source and binary forms, with or without |
mbed_official | 80:2dab120a94c2 | 12 | * modification, are permitted provided that the following conditions are met: |
mbed_official | 80:2dab120a94c2 | 13 | * - Redistributions of source code must retain the above copyright |
mbed_official | 80:2dab120a94c2 | 14 | * notice, this list of conditions and the following disclaimer. |
mbed_official | 80:2dab120a94c2 | 15 | * - Redistributions in binary form must reproduce the above copyright |
mbed_official | 80:2dab120a94c2 | 16 | * notice, this list of conditions and the following disclaimer in the |
mbed_official | 80:2dab120a94c2 | 17 | * documentation and/or other materials provided with the distribution. |
mbed_official | 80:2dab120a94c2 | 18 | * - Neither the name of ARM nor the names of its contributors may be used |
mbed_official | 80:2dab120a94c2 | 19 | * to endorse or promote products derived from this software without |
mbed_official | 80:2dab120a94c2 | 20 | * specific prior written permission. |
mbed_official | 80:2dab120a94c2 | 21 | * |
mbed_official | 80:2dab120a94c2 | 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
mbed_official | 80:2dab120a94c2 | 23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
mbed_official | 80:2dab120a94c2 | 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
mbed_official | 80:2dab120a94c2 | 25 | * ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE |
mbed_official | 80:2dab120a94c2 | 26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
mbed_official | 80:2dab120a94c2 | 27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
mbed_official | 80:2dab120a94c2 | 28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
mbed_official | 80:2dab120a94c2 | 29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
mbed_official | 80:2dab120a94c2 | 30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
mbed_official | 80:2dab120a94c2 | 31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
mbed_official | 80:2dab120a94c2 | 32 | * POSSIBILITY OF SUCH DAMAGE. |
mbed_official | 80:2dab120a94c2 | 33 | *---------------------------------------------------------------------------*/ |
mbed_official | 80:2dab120a94c2 | 34 | #include "mbed_error.h" |
mbed_official | 80:2dab120a94c2 | 35 | |
mbed_official | 80:2dab120a94c2 | 36 | #if defined (__CC_ARM) |
mbed_official | 80:2dab120a94c2 | 37 | #pragma O3 |
mbed_official | 80:2dab120a94c2 | 38 | #define __USED __attribute__((used)) |
mbed_official | 80:2dab120a94c2 | 39 | #elif defined (__GNUC__) |
mbed_official | 80:2dab120a94c2 | 40 | #pragma GCC optimize ("O3") |
mbed_official | 80:2dab120a94c2 | 41 | #define __USED __attribute__((used)) |
mbed_official | 80:2dab120a94c2 | 42 | #elif defined (__ICCARM__) |
mbed_official | 80:2dab120a94c2 | 43 | #define __USED __root |
mbed_official | 80:2dab120a94c2 | 44 | #endif |
mbed_official | 80:2dab120a94c2 | 45 | |
mbed_official | 80:2dab120a94c2 | 46 | |
mbed_official | 80:2dab120a94c2 | 47 | /*---------------------------------------------------------------------------- |
mbed_official | 80:2dab120a94c2 | 48 | * Definitions |
mbed_official | 80:2dab120a94c2 | 49 | *---------------------------------------------------------------------------*/ |
mbed_official | 80:2dab120a94c2 | 50 | |
mbed_official | 80:2dab120a94c2 | 51 | #define _declare_box(pool,size,cnt) uint32_t pool[(((size)+3)/4)*(cnt) + 3] |
mbed_official | 80:2dab120a94c2 | 52 | #define _declare_box8(pool,size,cnt) uint64_t pool[(((size)+7)/8)*(cnt) + 2] |
mbed_official | 80:2dab120a94c2 | 53 | |
mbed_official | 80:2dab120a94c2 | 54 | #define OS_TCB_SIZE 48 |
mbed_official | 80:2dab120a94c2 | 55 | #define OS_TMR_SIZE 8 |
mbed_official | 80:2dab120a94c2 | 56 | |
mbed_official | 80:2dab120a94c2 | 57 | #if defined (__CC_ARM) && !defined (__MICROLIB) |
mbed_official | 80:2dab120a94c2 | 58 | |
mbed_official | 80:2dab120a94c2 | 59 | typedef void *OS_ID; |
mbed_official | 80:2dab120a94c2 | 60 | typedef uint32_t OS_TID; |
mbed_official | 80:2dab120a94c2 | 61 | typedef uint32_t OS_MUT[3]; |
mbed_official | 80:2dab120a94c2 | 62 | typedef uint32_t OS_RESULT; |
mbed_official | 80:2dab120a94c2 | 63 | |
mbed_official | 80:2dab120a94c2 | 64 | #define runtask_id() rt_tsk_self() |
mbed_official | 80:2dab120a94c2 | 65 | #define mutex_init(m) rt_mut_init(m) |
mbed_official | 80:2dab120a94c2 | 66 | #define mutex_wait(m) os_mut_wait(m,0xFFFF) |
mbed_official | 80:2dab120a94c2 | 67 | #define mutex_rel(m) os_mut_release(m) |
mbed_official | 80:2dab120a94c2 | 68 | |
mbed_official | 80:2dab120a94c2 | 69 | extern OS_TID rt_tsk_self (void); |
mbed_official | 80:2dab120a94c2 | 70 | extern void rt_mut_init (OS_ID mutex); |
mbed_official | 80:2dab120a94c2 | 71 | extern OS_RESULT rt_mut_release (OS_ID mutex); |
mbed_official | 80:2dab120a94c2 | 72 | extern OS_RESULT rt_mut_wait (OS_ID mutex, uint16_t timeout); |
mbed_official | 80:2dab120a94c2 | 73 | |
mbed_official | 80:2dab120a94c2 | 74 | #define os_mut_wait(mutex,timeout) _os_mut_wait((uint32_t)rt_mut_wait,mutex,timeout) |
mbed_official | 80:2dab120a94c2 | 75 | #define os_mut_release(mutex) _os_mut_release((uint32_t)rt_mut_release,mutex) |
mbed_official | 80:2dab120a94c2 | 76 | |
mbed_official | 80:2dab120a94c2 | 77 | OS_RESULT _os_mut_release (uint32_t p, OS_ID mutex) __svc_indirect(0); |
mbed_official | 80:2dab120a94c2 | 78 | OS_RESULT _os_mut_wait (uint32_t p, OS_ID mutex, uint16_t timeout) __svc_indirect(0); |
mbed_official | 80:2dab120a94c2 | 79 | |
mbed_official | 80:2dab120a94c2 | 80 | #endif |
mbed_official | 80:2dab120a94c2 | 81 | |
mbed_official | 80:2dab120a94c2 | 82 | |
mbed_official | 80:2dab120a94c2 | 83 | /*---------------------------------------------------------------------------- |
mbed_official | 80:2dab120a94c2 | 84 | * Global Variables |
mbed_official | 80:2dab120a94c2 | 85 | *---------------------------------------------------------------------------*/ |
mbed_official | 80:2dab120a94c2 | 86 | |
mbed_official | 80:2dab120a94c2 | 87 | #if (OS_TIMERS != 0) |
mbed_official | 80:2dab120a94c2 | 88 | #define OS_TASK_CNT (OS_TASKCNT + 1) |
mbed_official | 80:2dab120a94c2 | 89 | #else |
mbed_official | 80:2dab120a94c2 | 90 | #define OS_TASK_CNT OS_TASKCNT |
mbed_official | 80:2dab120a94c2 | 91 | #endif |
mbed_official | 80:2dab120a94c2 | 92 | |
mbed_official | 80:2dab120a94c2 | 93 | uint16_t const os_maxtaskrun = OS_TASK_CNT; |
mbed_official | 80:2dab120a94c2 | 94 | uint32_t const os_rrobin = (OS_ROBIN << 16) | OS_ROBINTOUT; |
mbed_official | 80:2dab120a94c2 | 95 | uint32_t const os_trv = OS_TRV; |
mbed_official | 80:2dab120a94c2 | 96 | uint8_t const os_flags = OS_RUNPRIV; |
mbed_official | 80:2dab120a94c2 | 97 | |
mbed_official | 80:2dab120a94c2 | 98 | /* Export following defines to uVision debugger. */ |
mbed_official | 80:2dab120a94c2 | 99 | __USED uint32_t const os_clockrate = OS_TICK; |
mbed_official | 80:2dab120a94c2 | 100 | __USED uint32_t const os_timernum = 0; |
mbed_official | 80:2dab120a94c2 | 101 | |
mbed_official | 80:2dab120a94c2 | 102 | /* Stack for the os_idle_demon */ |
mbed_official | 80:2dab120a94c2 | 103 | unsigned int idle_task_stack[OS_IDLESTKSIZE]; |
mbed_official | 80:2dab120a94c2 | 104 | unsigned short const idle_task_stack_size = OS_IDLESTKSIZE; |
mbed_official | 80:2dab120a94c2 | 105 | |
mbed_official | 80:2dab120a94c2 | 106 | #ifndef OS_FIFOSZ |
mbed_official | 80:2dab120a94c2 | 107 | #define OS_FIFOSZ 16 |
mbed_official | 80:2dab120a94c2 | 108 | #endif |
mbed_official | 80:2dab120a94c2 | 109 | |
mbed_official | 80:2dab120a94c2 | 110 | /* Fifo Queue buffer for ISR requests.*/ |
mbed_official | 80:2dab120a94c2 | 111 | uint32_t os_fifo[OS_FIFOSZ*2+1]; |
mbed_official | 80:2dab120a94c2 | 112 | uint8_t const os_fifo_size = OS_FIFOSZ; |
mbed_official | 80:2dab120a94c2 | 113 | |
mbed_official | 80:2dab120a94c2 | 114 | /* An array of Active task pointers. */ |
mbed_official | 80:2dab120a94c2 | 115 | void *os_active_TCB[OS_TASK_CNT]; |
mbed_official | 80:2dab120a94c2 | 116 | |
mbed_official | 80:2dab120a94c2 | 117 | /* User Timers Resources */ |
mbed_official | 80:2dab120a94c2 | 118 | #if (OS_TIMERS != 0) |
mbed_official | 80:2dab120a94c2 | 119 | extern void osTimerThread (void const *argument); |
mbed_official | 80:2dab120a94c2 | 120 | osThreadDef(osTimerThread, (osPriority)(OS_TIMERPRIO-3), 4*OS_TIMERSTKSZ); |
mbed_official | 80:2dab120a94c2 | 121 | osThreadId osThreadId_osTimerThread; |
mbed_official | 80:2dab120a94c2 | 122 | osMessageQDef(osTimerMessageQ, OS_TIMERCBQS, void *); |
mbed_official | 80:2dab120a94c2 | 123 | osMessageQId osMessageQId_osTimerMessageQ; |
mbed_official | 80:2dab120a94c2 | 124 | #else |
mbed_official | 80:2dab120a94c2 | 125 | osThreadDef_t os_thread_def_osTimerThread = { NULL }; |
mbed_official | 80:2dab120a94c2 | 126 | osThreadId osThreadId_osTimerThread; |
mbed_official | 80:2dab120a94c2 | 127 | osMessageQDef(osTimerMessageQ, 0, void *); |
mbed_official | 80:2dab120a94c2 | 128 | osMessageQId osMessageQId_osTimerMessageQ; |
mbed_official | 80:2dab120a94c2 | 129 | #endif |
mbed_official | 80:2dab120a94c2 | 130 | |
mbed_official | 80:2dab120a94c2 | 131 | |
mbed_official | 80:2dab120a94c2 | 132 | /*---------------------------------------------------------------------------- |
mbed_official | 80:2dab120a94c2 | 133 | * RTX Optimizations (empty functions) |
mbed_official | 80:2dab120a94c2 | 134 | *---------------------------------------------------------------------------*/ |
mbed_official | 80:2dab120a94c2 | 135 | |
mbed_official | 80:2dab120a94c2 | 136 | #if OS_ROBIN == 0 |
mbed_official | 80:2dab120a94c2 | 137 | void rt_init_robin (void) {;} |
mbed_official | 80:2dab120a94c2 | 138 | void rt_chk_robin (void) {;} |
mbed_official | 80:2dab120a94c2 | 139 | #endif |
mbed_official | 80:2dab120a94c2 | 140 | |
mbed_official | 80:2dab120a94c2 | 141 | #if OS_STKCHECK == 0 |
mbed_official | 80:2dab120a94c2 | 142 | void rt_stk_check (void) {;} |
mbed_official | 80:2dab120a94c2 | 143 | #endif |
mbed_official | 80:2dab120a94c2 | 144 | |
mbed_official | 80:2dab120a94c2 | 145 | |
mbed_official | 80:2dab120a94c2 | 146 | /*---------------------------------------------------------------------------- |
mbed_official | 80:2dab120a94c2 | 147 | * Standard Library multithreading interface |
mbed_official | 80:2dab120a94c2 | 148 | *---------------------------------------------------------------------------*/ |
mbed_official | 80:2dab120a94c2 | 149 | |
mbed_official | 80:2dab120a94c2 | 150 | #if defined (__CC_ARM) && !defined (__MICROLIB) |
mbed_official | 80:2dab120a94c2 | 151 | static OS_MUT std_libmutex[OS_MUTEXCNT]; |
mbed_official | 80:2dab120a94c2 | 152 | static uint32_t nr_mutex; |
mbed_official | 80:2dab120a94c2 | 153 | |
mbed_official | 80:2dab120a94c2 | 154 | /*--------------------------- _mutex_initialize -----------------------------*/ |
mbed_official | 80:2dab120a94c2 | 155 | |
mbed_official | 80:2dab120a94c2 | 156 | int _mutex_initialize (OS_ID *mutex) { |
mbed_official | 80:2dab120a94c2 | 157 | /* Allocate and initialize a system mutex. */ |
mbed_official | 80:2dab120a94c2 | 158 | |
mbed_official | 80:2dab120a94c2 | 159 | if (nr_mutex >= OS_MUTEXCNT) { |
mbed_official | 80:2dab120a94c2 | 160 | /* If you are here, you need to increase the number OS_MUTEXCNT. */ |
mbed_official | 80:2dab120a94c2 | 161 | error("Not enough stdlib mutexes\n"); |
mbed_official | 80:2dab120a94c2 | 162 | } |
mbed_official | 80:2dab120a94c2 | 163 | *mutex = &std_libmutex[nr_mutex++]; |
mbed_official | 80:2dab120a94c2 | 164 | mutex_init (*mutex); |
mbed_official | 80:2dab120a94c2 | 165 | return (1); |
mbed_official | 80:2dab120a94c2 | 166 | } |
mbed_official | 80:2dab120a94c2 | 167 | |
mbed_official | 80:2dab120a94c2 | 168 | |
mbed_official | 80:2dab120a94c2 | 169 | /*--------------------------- _mutex_acquire --------------------------------*/ |
mbed_official | 80:2dab120a94c2 | 170 | |
mbed_official | 80:2dab120a94c2 | 171 | __attribute__((used)) void _mutex_acquire (OS_ID *mutex) { |
mbed_official | 80:2dab120a94c2 | 172 | /* Acquire a system mutex, lock stdlib resources. */ |
mbed_official | 80:2dab120a94c2 | 173 | if (runtask_id ()) { |
mbed_official | 80:2dab120a94c2 | 174 | /* RTX running, acquire a mutex. */ |
mbed_official | 80:2dab120a94c2 | 175 | mutex_wait (*mutex); |
mbed_official | 80:2dab120a94c2 | 176 | } |
mbed_official | 80:2dab120a94c2 | 177 | } |
mbed_official | 80:2dab120a94c2 | 178 | |
mbed_official | 80:2dab120a94c2 | 179 | |
mbed_official | 80:2dab120a94c2 | 180 | /*--------------------------- _mutex_release --------------------------------*/ |
mbed_official | 80:2dab120a94c2 | 181 | |
mbed_official | 80:2dab120a94c2 | 182 | __attribute__((used)) void _mutex_release (OS_ID *mutex) { |
mbed_official | 80:2dab120a94c2 | 183 | /* Release a system mutex, unlock stdlib resources. */ |
mbed_official | 80:2dab120a94c2 | 184 | if (runtask_id ()) { |
mbed_official | 80:2dab120a94c2 | 185 | /* RTX running, release a mutex. */ |
mbed_official | 80:2dab120a94c2 | 186 | mutex_rel (*mutex); |
mbed_official | 80:2dab120a94c2 | 187 | } |
mbed_official | 80:2dab120a94c2 | 188 | } |
mbed_official | 80:2dab120a94c2 | 189 | |
mbed_official | 80:2dab120a94c2 | 190 | #endif |
mbed_official | 80:2dab120a94c2 | 191 | |
mbed_official | 80:2dab120a94c2 | 192 | |
mbed_official | 80:2dab120a94c2 | 193 | /*---------------------------------------------------------------------------- |
mbed_official | 80:2dab120a94c2 | 194 | * RTX Startup |
mbed_official | 80:2dab120a94c2 | 195 | *---------------------------------------------------------------------------*/ |
mbed_official | 80:2dab120a94c2 | 196 | |
mbed_official | 80:2dab120a94c2 | 197 | /* Main Thread definition */ |
mbed_official | 80:2dab120a94c2 | 198 | extern int main (void); |
mbed_official | 80:2dab120a94c2 | 199 | osThreadDef_t os_thread_def_main = {(os_pthread)main, osPriorityNormal, 0, NULL}; |
mbed_official | 80:2dab120a94c2 | 200 | |
mbed_official | 80:2dab120a94c2 | 201 | // This define should be probably moved to the CMSIS layer |
mbed_official | 80:2dab120a94c2 | 202 | |
mbed_official | 80:2dab120a94c2 | 203 | #if defined(TARGET_LPC2460) |
mbed_official | 80:2dab120a94c2 | 204 | extern unsigned char __usr_stack_top__[]; |
mbed_official | 80:2dab120a94c2 | 205 | #define INITIAL_SP (__usr_stack_top__) |
mbed_official | 80:2dab120a94c2 | 206 | |
mbed_official | 80:2dab120a94c2 | 207 | #else |
mbed_official | 80:2dab120a94c2 | 208 | #error "no target defined" |
mbed_official | 80:2dab120a94c2 | 209 | |
mbed_official | 80:2dab120a94c2 | 210 | #endif |
mbed_official | 80:2dab120a94c2 | 211 | |
mbed_official | 80:2dab120a94c2 | 212 | #ifdef __CC_ARM |
mbed_official | 80:2dab120a94c2 | 213 | extern unsigned char Image$$RW_IRAM1$$ZI$$Limit[]; |
mbed_official | 80:2dab120a94c2 | 214 | #define HEAP_START (Image$$RW_IRAM1$$ZI$$Limit) |
mbed_official | 80:2dab120a94c2 | 215 | #elif defined(__GNUC__) |
mbed_official | 80:2dab120a94c2 | 216 | extern unsigned char __end__[]; |
mbed_official | 80:2dab120a94c2 | 217 | #define HEAP_START (__end__) |
mbed_official | 80:2dab120a94c2 | 218 | #elif defined(__ICCARM__) |
mbed_official | 80:2dab120a94c2 | 219 | #pragma section="HEAP" |
mbed_official | 80:2dab120a94c2 | 220 | #define HEAP_START (void *)__section_begin("HEAP") |
mbed_official | 80:2dab120a94c2 | 221 | #endif |
mbed_official | 80:2dab120a94c2 | 222 | |
mbed_official | 80:2dab120a94c2 | 223 | void set_main_stack(void) { |
mbed_official | 80:2dab120a94c2 | 224 | // That is the bottom of the main stack block: no collision detection |
mbed_official | 80:2dab120a94c2 | 225 | os_thread_def_main.stack_pointer = HEAP_START; |
mbed_official | 80:2dab120a94c2 | 226 | |
mbed_official | 80:2dab120a94c2 | 227 | // Leave OS_SCHEDULERSTKSIZE words for the scheduler and interrupts |
mbed_official | 80:2dab120a94c2 | 228 | os_thread_def_main.stacksize = (INITIAL_SP - (unsigned int)HEAP_START) - (OS_SCHEDULERSTKSIZE * 4); |
mbed_official | 80:2dab120a94c2 | 229 | } |
mbed_official | 80:2dab120a94c2 | 230 | |
mbed_official | 80:2dab120a94c2 | 231 | #if defined (__CC_ARM) |
mbed_official | 80:2dab120a94c2 | 232 | #ifdef __MICROLIB |
mbed_official | 80:2dab120a94c2 | 233 | void _main_init (void) __attribute__((section(".ARM.Collect$$$$000000FF"))); |
mbed_official | 80:2dab120a94c2 | 234 | void _main_init (void) { |
mbed_official | 80:2dab120a94c2 | 235 | osKernelInitialize(); |
mbed_official | 80:2dab120a94c2 | 236 | set_main_stack(); |
mbed_official | 80:2dab120a94c2 | 237 | osThreadCreate(&os_thread_def_main, NULL); |
mbed_official | 80:2dab120a94c2 | 238 | osKernelStart(); |
mbed_official | 80:2dab120a94c2 | 239 | for (;;); |
mbed_official | 80:2dab120a94c2 | 240 | } |
mbed_official | 80:2dab120a94c2 | 241 | #else |
mbed_official | 80:2dab120a94c2 | 242 | |
mbed_official | 80:2dab120a94c2 | 243 | /* The single memory model is checking for stack collision at run time, verifing |
mbed_official | 80:2dab120a94c2 | 244 | that the heap pointer is underneath the stack pointer. |
mbed_official | 80:2dab120a94c2 | 245 | |
mbed_official | 80:2dab120a94c2 | 246 | With the RTOS there is not only one stack above the heap, there are multiple |
mbed_official | 80:2dab120a94c2 | 247 | stacks and some of them are underneath the heap pointer. |
mbed_official | 80:2dab120a94c2 | 248 | */ |
mbed_official | 80:2dab120a94c2 | 249 | #pragma import(__use_two_region_memory) |
mbed_official | 80:2dab120a94c2 | 250 | |
mbed_official | 80:2dab120a94c2 | 251 | __asm void __rt_entry (void) { |
mbed_official | 80:2dab120a94c2 | 252 | |
mbed_official | 80:2dab120a94c2 | 253 | IMPORT __user_setup_stackheap |
mbed_official | 80:2dab120a94c2 | 254 | IMPORT __rt_lib_init |
mbed_official | 80:2dab120a94c2 | 255 | IMPORT os_thread_def_main |
mbed_official | 80:2dab120a94c2 | 256 | IMPORT osKernelInitialize |
mbed_official | 80:2dab120a94c2 | 257 | IMPORT set_main_stack |
mbed_official | 80:2dab120a94c2 | 258 | IMPORT osKernelStart |
mbed_official | 80:2dab120a94c2 | 259 | IMPORT osThreadCreate |
mbed_official | 80:2dab120a94c2 | 260 | IMPORT exit |
mbed_official | 80:2dab120a94c2 | 261 | |
mbed_official | 80:2dab120a94c2 | 262 | BL __user_setup_stackheap |
mbed_official | 80:2dab120a94c2 | 263 | MOV R1,R2 |
mbed_official | 80:2dab120a94c2 | 264 | BL __rt_lib_init |
mbed_official | 80:2dab120a94c2 | 265 | BL osKernelInitialize |
mbed_official | 80:2dab120a94c2 | 266 | BL set_main_stack |
mbed_official | 80:2dab120a94c2 | 267 | LDR R0,=os_thread_def_main |
mbed_official | 80:2dab120a94c2 | 268 | MOVS R1,#0 |
mbed_official | 80:2dab120a94c2 | 269 | BL osThreadCreate |
mbed_official | 80:2dab120a94c2 | 270 | BL osKernelStart |
mbed_official | 80:2dab120a94c2 | 271 | BL exit |
mbed_official | 80:2dab120a94c2 | 272 | |
mbed_official | 80:2dab120a94c2 | 273 | ALIGN |
mbed_official | 80:2dab120a94c2 | 274 | } |
mbed_official | 80:2dab120a94c2 | 275 | #endif |
mbed_official | 80:2dab120a94c2 | 276 | |
mbed_official | 80:2dab120a94c2 | 277 | #elif defined (__GNUC__) |
mbed_official | 80:2dab120a94c2 | 278 | |
mbed_official | 80:2dab120a94c2 | 279 | #ifdef __CS3__ |
mbed_official | 80:2dab120a94c2 | 280 | |
mbed_official | 80:2dab120a94c2 | 281 | /* CS3 start_c routine. |
mbed_official | 80:2dab120a94c2 | 282 | * |
mbed_official | 80:2dab120a94c2 | 283 | * Copyright (c) 2006, 2007 CodeSourcery Inc |
mbed_official | 80:2dab120a94c2 | 284 | * |
mbed_official | 80:2dab120a94c2 | 285 | * The authors hereby grant permission to use, copy, modify, distribute, |
mbed_official | 80:2dab120a94c2 | 286 | * and license this software and its documentation for any purpose, provided |
mbed_official | 80:2dab120a94c2 | 287 | * that existing copyright notices are retained in all copies and that this |
mbed_official | 80:2dab120a94c2 | 288 | * notice is included verbatim in any distributions. No written agreement, |
mbed_official | 80:2dab120a94c2 | 289 | * license, or royalty fee is required for any of the authorized uses. |
mbed_official | 80:2dab120a94c2 | 290 | * Modifications to this software may be copyrighted by their authors |
mbed_official | 80:2dab120a94c2 | 291 | * and need not follow the licensing terms described here, provided that |
mbed_official | 80:2dab120a94c2 | 292 | * the new terms are clearly indicated on the first page of each file where |
mbed_official | 80:2dab120a94c2 | 293 | * they apply. |
mbed_official | 80:2dab120a94c2 | 294 | */ |
mbed_official | 80:2dab120a94c2 | 295 | |
mbed_official | 80:2dab120a94c2 | 296 | #include "cs3.h" |
mbed_official | 80:2dab120a94c2 | 297 | |
mbed_official | 80:2dab120a94c2 | 298 | extern void __libc_init_array (void); |
mbed_official | 80:2dab120a94c2 | 299 | |
mbed_official | 80:2dab120a94c2 | 300 | __attribute ((noreturn)) void __cs3_start_c (void){ |
mbed_official | 80:2dab120a94c2 | 301 | unsigned regions = __cs3_region_num; |
mbed_official | 80:2dab120a94c2 | 302 | const struct __cs3_region *rptr = __cs3_regions; |
mbed_official | 80:2dab120a94c2 | 303 | |
mbed_official | 80:2dab120a94c2 | 304 | /* Initialize memory */ |
mbed_official | 80:2dab120a94c2 | 305 | for (regions = __cs3_region_num, rptr = __cs3_regions; regions--; rptr++) { |
mbed_official | 80:2dab120a94c2 | 306 | long long *src = (long long *)rptr->init; |
mbed_official | 80:2dab120a94c2 | 307 | long long *dst = (long long *)rptr->data; |
mbed_official | 80:2dab120a94c2 | 308 | unsigned limit = rptr->init_size; |
mbed_official | 80:2dab120a94c2 | 309 | unsigned count; |
mbed_official | 80:2dab120a94c2 | 310 | |
mbed_official | 80:2dab120a94c2 | 311 | if (src != dst) |
mbed_official | 80:2dab120a94c2 | 312 | for (count = 0; count != limit; count += sizeof (long long)) |
mbed_official | 80:2dab120a94c2 | 313 | *dst++ = *src++; |
mbed_official | 80:2dab120a94c2 | 314 | else |
mbed_official | 80:2dab120a94c2 | 315 | dst = (long long *)((char *)dst + limit); |
mbed_official | 80:2dab120a94c2 | 316 | limit = rptr->zero_size; |
mbed_official | 80:2dab120a94c2 | 317 | for (count = 0; count != limit; count += sizeof (long long)) |
mbed_official | 80:2dab120a94c2 | 318 | *dst++ = 0; |
mbed_official | 80:2dab120a94c2 | 319 | } |
mbed_official | 80:2dab120a94c2 | 320 | |
mbed_official | 80:2dab120a94c2 | 321 | /* Run initializers. */ |
mbed_official | 80:2dab120a94c2 | 322 | __libc_init_array (); |
mbed_official | 80:2dab120a94c2 | 323 | |
mbed_official | 80:2dab120a94c2 | 324 | osKernelInitialize(); |
mbed_official | 80:2dab120a94c2 | 325 | set_main_stack(); |
mbed_official | 80:2dab120a94c2 | 326 | osThreadCreate(&os_thread_def_main, NULL); |
mbed_official | 80:2dab120a94c2 | 327 | osKernelStart(); |
mbed_official | 80:2dab120a94c2 | 328 | for (;;); |
mbed_official | 80:2dab120a94c2 | 329 | } |
mbed_official | 80:2dab120a94c2 | 330 | |
mbed_official | 80:2dab120a94c2 | 331 | #else |
mbed_official | 80:2dab120a94c2 | 332 | |
mbed_official | 80:2dab120a94c2 | 333 | __attribute__((naked)) void software_init_hook (void) { |
mbed_official | 80:2dab120a94c2 | 334 | __asm ( |
mbed_official | 80:2dab120a94c2 | 335 | ".syntax unified\n" |
mbed_official | 80:2dab120a94c2 | 336 | ".thumb\n" |
mbed_official | 80:2dab120a94c2 | 337 | "movs r0,#0\n" |
mbed_official | 80:2dab120a94c2 | 338 | "movs r1,#0\n" |
mbed_official | 80:2dab120a94c2 | 339 | "mov r8,r0\n" |
mbed_official | 80:2dab120a94c2 | 340 | "mov r9,r1\n" |
mbed_official | 80:2dab120a94c2 | 341 | "ldr r0,= __libc_fini_array\n" |
mbed_official | 80:2dab120a94c2 | 342 | "bl atexit\n" |
mbed_official | 80:2dab120a94c2 | 343 | "bl __libc_init_array\n" |
mbed_official | 80:2dab120a94c2 | 344 | "mov r0,r8\n" |
mbed_official | 80:2dab120a94c2 | 345 | "mov r1,r9\n" |
mbed_official | 80:2dab120a94c2 | 346 | "bl osKernelInitialize\n" |
mbed_official | 80:2dab120a94c2 | 347 | "bl set_main_stack\n" |
mbed_official | 80:2dab120a94c2 | 348 | "ldr r0,=os_thread_def_main\n" |
mbed_official | 80:2dab120a94c2 | 349 | "movs r1,#0\n" |
mbed_official | 80:2dab120a94c2 | 350 | "bl osThreadCreate\n" |
mbed_official | 80:2dab120a94c2 | 351 | "bl osKernelStart\n" |
mbed_official | 80:2dab120a94c2 | 352 | "bl exit\n" |
mbed_official | 80:2dab120a94c2 | 353 | ); |
mbed_official | 80:2dab120a94c2 | 354 | } |
mbed_official | 80:2dab120a94c2 | 355 | |
mbed_official | 80:2dab120a94c2 | 356 | #endif |
mbed_official | 80:2dab120a94c2 | 357 | |
mbed_official | 80:2dab120a94c2 | 358 | #elif defined (__ICCARM__) |
mbed_official | 80:2dab120a94c2 | 359 | |
mbed_official | 80:2dab120a94c2 | 360 | extern int __low_level_init(void); |
mbed_official | 80:2dab120a94c2 | 361 | extern void __iar_data_init3(void); |
mbed_official | 80:2dab120a94c2 | 362 | extern void exit(int arg); |
mbed_official | 80:2dab120a94c2 | 363 | |
mbed_official | 80:2dab120a94c2 | 364 | __noreturn __stackless void __cmain(void) { |
mbed_official | 80:2dab120a94c2 | 365 | int a; |
mbed_official | 80:2dab120a94c2 | 366 | |
mbed_official | 80:2dab120a94c2 | 367 | if (__low_level_init() != 0) { |
mbed_official | 80:2dab120a94c2 | 368 | __iar_data_init3(); |
mbed_official | 80:2dab120a94c2 | 369 | } |
mbed_official | 80:2dab120a94c2 | 370 | osKernelInitialize(); |
mbed_official | 80:2dab120a94c2 | 371 | set_main_stack(); |
mbed_official | 80:2dab120a94c2 | 372 | osThreadCreate(&os_thread_def_main, NULL); |
mbed_official | 80:2dab120a94c2 | 373 | a = osKernelStart(); |
mbed_official | 80:2dab120a94c2 | 374 | exit(a); |
mbed_official | 80:2dab120a94c2 | 375 | } |
mbed_official | 80:2dab120a94c2 | 376 | |
mbed_official | 80:2dab120a94c2 | 377 | #endif |
mbed_official | 80:2dab120a94c2 | 378 | |
mbed_official | 80:2dab120a94c2 | 379 | |
mbed_official | 80:2dab120a94c2 | 380 | /*---------------------------------------------------------------------------- |
mbed_official | 80:2dab120a94c2 | 381 | * end of file |
mbed_official | 80:2dab120a94c2 | 382 | *---------------------------------------------------------------------------*/ |
mbed_official | 80:2dab120a94c2 | 383 | |
mbed_official | 80:2dab120a94c2 | 384 |