![](/media/cache/profiles/debfdc81854eac26ec993b55a659c6e1.jpg.50x50_q85.jpg)
mbed client lightswitch demo
Dependencies: mbed Socket lwip-eth lwip-sys lwip
Fork of mbed-client-classic-example-lwip by
mbed-rtos/rtx/TARGET_CORTEX_A/RTX_CM_lib.h@11:cada08fc8a70, 2016-06-09 (annotated)
- Committer:
- mbedAustin
- Date:
- Thu Jun 09 17:08:36 2016 +0000
- Revision:
- 11:cada08fc8a70
Commit for public Consumption
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbedAustin | 11:cada08fc8a70 | 1 | /*---------------------------------------------------------------------------- |
mbedAustin | 11:cada08fc8a70 | 2 | * RL-ARM - RTX |
mbedAustin | 11:cada08fc8a70 | 3 | *---------------------------------------------------------------------------- |
mbedAustin | 11:cada08fc8a70 | 4 | * Name: RTX_CM_LIB.H |
mbedAustin | 11:cada08fc8a70 | 5 | * Purpose: RTX Kernel System Configuration |
mbedAustin | 11:cada08fc8a70 | 6 | * Rev.: V4.73 |
mbedAustin | 11:cada08fc8a70 | 7 | *---------------------------------------------------------------------------- |
mbedAustin | 11:cada08fc8a70 | 8 | * |
mbedAustin | 11:cada08fc8a70 | 9 | * Copyright (c) 1999-2009 KEIL, 2009-2013 ARM Germany GmbH |
mbedAustin | 11:cada08fc8a70 | 10 | * All rights reserved. |
mbedAustin | 11:cada08fc8a70 | 11 | * Redistribution and use in source and binary forms, with or without |
mbedAustin | 11:cada08fc8a70 | 12 | * modification, are permitted provided that the following conditions are met: |
mbedAustin | 11:cada08fc8a70 | 13 | * - Redistributions of source code must retain the above copyright |
mbedAustin | 11:cada08fc8a70 | 14 | * notice, this list of conditions and the following disclaimer. |
mbedAustin | 11:cada08fc8a70 | 15 | * - Redistributions in binary form must reproduce the above copyright |
mbedAustin | 11:cada08fc8a70 | 16 | * notice, this list of conditions and the following disclaimer in the |
mbedAustin | 11:cada08fc8a70 | 17 | * documentation and/or other materials provided with the distribution. |
mbedAustin | 11:cada08fc8a70 | 18 | * - Neither the name of ARM nor the names of its contributors may be used |
mbedAustin | 11:cada08fc8a70 | 19 | * to endorse or promote products derived from this software without |
mbedAustin | 11:cada08fc8a70 | 20 | * specific prior written permission. |
mbedAustin | 11:cada08fc8a70 | 21 | * |
mbedAustin | 11:cada08fc8a70 | 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
mbedAustin | 11:cada08fc8a70 | 23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
mbedAustin | 11:cada08fc8a70 | 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
mbedAustin | 11:cada08fc8a70 | 25 | * ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE |
mbedAustin | 11:cada08fc8a70 | 26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
mbedAustin | 11:cada08fc8a70 | 27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
mbedAustin | 11:cada08fc8a70 | 28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
mbedAustin | 11:cada08fc8a70 | 29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
mbedAustin | 11:cada08fc8a70 | 30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
mbedAustin | 11:cada08fc8a70 | 31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
mbedAustin | 11:cada08fc8a70 | 32 | * POSSIBILITY OF SUCH DAMAGE. |
mbedAustin | 11:cada08fc8a70 | 33 | *---------------------------------------------------------------------------*/ |
mbedAustin | 11:cada08fc8a70 | 34 | |
mbedAustin | 11:cada08fc8a70 | 35 | #if defined (__CC_ARM) |
mbedAustin | 11:cada08fc8a70 | 36 | #pragma O3 |
mbedAustin | 11:cada08fc8a70 | 37 | #define __USED __attribute__((used)) |
mbedAustin | 11:cada08fc8a70 | 38 | #elif defined (__GNUC__) |
mbedAustin | 11:cada08fc8a70 | 39 | #pragma GCC optimize ("O3") |
mbedAustin | 11:cada08fc8a70 | 40 | #define __USED __attribute__((used)) |
mbedAustin | 11:cada08fc8a70 | 41 | #elif defined (__ICCARM__) |
mbedAustin | 11:cada08fc8a70 | 42 | #define __USED __root |
mbedAustin | 11:cada08fc8a70 | 43 | #endif |
mbedAustin | 11:cada08fc8a70 | 44 | |
mbedAustin | 11:cada08fc8a70 | 45 | |
mbedAustin | 11:cada08fc8a70 | 46 | /*---------------------------------------------------------------------------- |
mbedAustin | 11:cada08fc8a70 | 47 | * Definitions |
mbedAustin | 11:cada08fc8a70 | 48 | *---------------------------------------------------------------------------*/ |
mbedAustin | 11:cada08fc8a70 | 49 | |
mbedAustin | 11:cada08fc8a70 | 50 | #define _declare_box(pool,size,cnt) uint32_t pool[(((size)+3)/4)*(cnt) + 3] |
mbedAustin | 11:cada08fc8a70 | 51 | #define _declare_box8(pool,size,cnt) uint64_t pool[(((size)+7)/8)*(cnt) + 2] |
mbedAustin | 11:cada08fc8a70 | 52 | |
mbedAustin | 11:cada08fc8a70 | 53 | #define OS_TCB_SIZE 52 |
mbedAustin | 11:cada08fc8a70 | 54 | #define OS_TMR_SIZE 8 |
mbedAustin | 11:cada08fc8a70 | 55 | |
mbedAustin | 11:cada08fc8a70 | 56 | #if defined (__CC_ARM) && !defined (__MICROLIB) |
mbedAustin | 11:cada08fc8a70 | 57 | |
mbedAustin | 11:cada08fc8a70 | 58 | typedef void *OS_ID; |
mbedAustin | 11:cada08fc8a70 | 59 | typedef uint32_t OS_TID; |
mbedAustin | 11:cada08fc8a70 | 60 | typedef uint32_t OS_MUT[4]; |
mbedAustin | 11:cada08fc8a70 | 61 | typedef uint32_t OS_RESULT; |
mbedAustin | 11:cada08fc8a70 | 62 | |
mbedAustin | 11:cada08fc8a70 | 63 | #define runtask_id() rt_tsk_self() |
mbedAustin | 11:cada08fc8a70 | 64 | #define mutex_init(m) rt_mut_init(m) |
mbedAustin | 11:cada08fc8a70 | 65 | #define mutex_wait(m) os_mut_wait(m,0xFFFF) |
mbedAustin | 11:cada08fc8a70 | 66 | #define mutex_rel(m) os_mut_release(m) |
mbedAustin | 11:cada08fc8a70 | 67 | |
mbedAustin | 11:cada08fc8a70 | 68 | extern OS_TID rt_tsk_self (void); |
mbedAustin | 11:cada08fc8a70 | 69 | extern void rt_mut_init (OS_ID mutex); |
mbedAustin | 11:cada08fc8a70 | 70 | extern OS_RESULT rt_mut_release (OS_ID mutex); |
mbedAustin | 11:cada08fc8a70 | 71 | extern OS_RESULT rt_mut_wait (OS_ID mutex, uint16_t timeout); |
mbedAustin | 11:cada08fc8a70 | 72 | |
mbedAustin | 11:cada08fc8a70 | 73 | #define os_mut_wait(mutex,timeout) _os_mut_wait((uint32_t)rt_mut_wait,mutex,timeout) |
mbedAustin | 11:cada08fc8a70 | 74 | #define os_mut_release(mutex) _os_mut_release((uint32_t)rt_mut_release,mutex) |
mbedAustin | 11:cada08fc8a70 | 75 | |
mbedAustin | 11:cada08fc8a70 | 76 | OS_RESULT _os_mut_release (uint32_t p, OS_ID mutex) __svc_indirect(0); |
mbedAustin | 11:cada08fc8a70 | 77 | OS_RESULT _os_mut_wait (uint32_t p, OS_ID mutex, uint16_t timeout) __svc_indirect(0); |
mbedAustin | 11:cada08fc8a70 | 78 | |
mbedAustin | 11:cada08fc8a70 | 79 | #elif defined (__ICCARM__) |
mbedAustin | 11:cada08fc8a70 | 80 | |
mbedAustin | 11:cada08fc8a70 | 81 | typedef void *OS_ID; |
mbedAustin | 11:cada08fc8a70 | 82 | typedef uint32_t OS_TID; |
mbedAustin | 11:cada08fc8a70 | 83 | typedef uint32_t OS_MUT[4]; |
mbedAustin | 11:cada08fc8a70 | 84 | typedef uint32_t OS_RESULT; |
mbedAustin | 11:cada08fc8a70 | 85 | |
mbedAustin | 11:cada08fc8a70 | 86 | #define runtask_id() rt_tsk_self() |
mbedAustin | 11:cada08fc8a70 | 87 | #define mutex_init(m) rt_mut_init(m) |
mbedAustin | 11:cada08fc8a70 | 88 | #define mutex_del(m) os_mut_delete(m) |
mbedAustin | 11:cada08fc8a70 | 89 | #define mutex_wait(m) os_mut_wait(m,0xFFFF) |
mbedAustin | 11:cada08fc8a70 | 90 | #define mutex_rel(m) os_mut_release(m) |
mbedAustin | 11:cada08fc8a70 | 91 | |
mbedAustin | 11:cada08fc8a70 | 92 | extern OS_TID rt_tsk_self (void); |
mbedAustin | 11:cada08fc8a70 | 93 | extern void rt_mut_init (OS_ID mutex); |
mbedAustin | 11:cada08fc8a70 | 94 | extern OS_RESULT rt_mut_delete (OS_ID mutex); |
mbedAustin | 11:cada08fc8a70 | 95 | extern OS_RESULT rt_mut_release (OS_ID mutex); |
mbedAustin | 11:cada08fc8a70 | 96 | extern OS_RESULT rt_mut_wait (OS_ID mutex, uint16_t timeout); |
mbedAustin | 11:cada08fc8a70 | 97 | |
mbedAustin | 11:cada08fc8a70 | 98 | #pragma swi_number=0 |
mbedAustin | 11:cada08fc8a70 | 99 | __swi OS_RESULT _os_mut_delete (OS_ID mutex); |
mbedAustin | 11:cada08fc8a70 | 100 | |
mbedAustin | 11:cada08fc8a70 | 101 | static inline OS_RESULT os_mut_delete(OS_ID mutex) |
mbedAustin | 11:cada08fc8a70 | 102 | { |
mbedAustin | 11:cada08fc8a70 | 103 | __asm("mov r12,%0\n" :: "r"(&rt_mut_delete) : "r12" ); |
mbedAustin | 11:cada08fc8a70 | 104 | return _os_mut_delete(mutex); |
mbedAustin | 11:cada08fc8a70 | 105 | } |
mbedAustin | 11:cada08fc8a70 | 106 | |
mbedAustin | 11:cada08fc8a70 | 107 | #pragma swi_number=0 |
mbedAustin | 11:cada08fc8a70 | 108 | __swi OS_RESULT _os_mut_release (OS_ID mutex); |
mbedAustin | 11:cada08fc8a70 | 109 | |
mbedAustin | 11:cada08fc8a70 | 110 | static inline OS_RESULT os_mut_release(OS_ID mutex) |
mbedAustin | 11:cada08fc8a70 | 111 | { |
mbedAustin | 11:cada08fc8a70 | 112 | __asm("mov r12,%0\n" :: "r"(&rt_mut_release) : "r12" ); |
mbedAustin | 11:cada08fc8a70 | 113 | return _os_mut_release(mutex); |
mbedAustin | 11:cada08fc8a70 | 114 | } |
mbedAustin | 11:cada08fc8a70 | 115 | |
mbedAustin | 11:cada08fc8a70 | 116 | #pragma swi_number=0 |
mbedAustin | 11:cada08fc8a70 | 117 | __swi OS_RESULT _os_mut_wait (OS_ID mutex, uint16_t timeout); |
mbedAustin | 11:cada08fc8a70 | 118 | |
mbedAustin | 11:cada08fc8a70 | 119 | static inline OS_RESULT os_mut_wait(OS_ID mutex, uint16_t timeout) |
mbedAustin | 11:cada08fc8a70 | 120 | { |
mbedAustin | 11:cada08fc8a70 | 121 | __asm("mov r12,%0\n" :: "r"(&rt_mut_wait) : "r12" ); |
mbedAustin | 11:cada08fc8a70 | 122 | return _os_mut_wait(mutex, timeout); |
mbedAustin | 11:cada08fc8a70 | 123 | } |
mbedAustin | 11:cada08fc8a70 | 124 | |
mbedAustin | 11:cada08fc8a70 | 125 | #include <yvals.h> /* for include DLib_Thread.h */ |
mbedAustin | 11:cada08fc8a70 | 126 | |
mbedAustin | 11:cada08fc8a70 | 127 | void __iar_system_Mtxinit(__iar_Rmtx *); |
mbedAustin | 11:cada08fc8a70 | 128 | void __iar_system_Mtxdst(__iar_Rmtx *); |
mbedAustin | 11:cada08fc8a70 | 129 | void __iar_system_Mtxlock(__iar_Rmtx *); |
mbedAustin | 11:cada08fc8a70 | 130 | void __iar_system_Mtxunlock(__iar_Rmtx *); |
mbedAustin | 11:cada08fc8a70 | 131 | |
mbedAustin | 11:cada08fc8a70 | 132 | |
mbedAustin | 11:cada08fc8a70 | 133 | |
mbedAustin | 11:cada08fc8a70 | 134 | |
mbedAustin | 11:cada08fc8a70 | 135 | #endif |
mbedAustin | 11:cada08fc8a70 | 136 | |
mbedAustin | 11:cada08fc8a70 | 137 | |
mbedAustin | 11:cada08fc8a70 | 138 | /*---------------------------------------------------------------------------- |
mbedAustin | 11:cada08fc8a70 | 139 | * Global Variables |
mbedAustin | 11:cada08fc8a70 | 140 | *---------------------------------------------------------------------------*/ |
mbedAustin | 11:cada08fc8a70 | 141 | |
mbedAustin | 11:cada08fc8a70 | 142 | #if (OS_TIMERS != 0) |
mbedAustin | 11:cada08fc8a70 | 143 | #define OS_TASK_CNT (OS_TASKCNT + 1) |
mbedAustin | 11:cada08fc8a70 | 144 | #ifndef __MBED_CMSIS_RTOS_CA9 |
mbedAustin | 11:cada08fc8a70 | 145 | #define OS_PRIV_CNT (OS_PRIVCNT + 2) |
mbedAustin | 11:cada08fc8a70 | 146 | #define OS_STACK_SZ (4*(OS_PRIVSTKSIZE+OS_MAINSTKSIZE+OS_TIMERSTKSZ)) |
mbedAustin | 11:cada08fc8a70 | 147 | #endif |
mbedAustin | 11:cada08fc8a70 | 148 | #else |
mbedAustin | 11:cada08fc8a70 | 149 | #define OS_TASK_CNT OS_TASKCNT |
mbedAustin | 11:cada08fc8a70 | 150 | #ifndef __MBED_CMSIS_RTOS_CA9 |
mbedAustin | 11:cada08fc8a70 | 151 | #define OS_PRIV_CNT (OS_PRIVCNT + 1) |
mbedAustin | 11:cada08fc8a70 | 152 | #define OS_STACK_SZ (4*(OS_PRIVSTKSIZE+OS_MAINSTKSIZE)) |
mbedAustin | 11:cada08fc8a70 | 153 | #endif |
mbedAustin | 11:cada08fc8a70 | 154 | #endif |
mbedAustin | 11:cada08fc8a70 | 155 | |
mbedAustin | 11:cada08fc8a70 | 156 | uint16_t const os_maxtaskrun = OS_TASK_CNT; |
mbedAustin | 11:cada08fc8a70 | 157 | #ifdef __MBED_CMSIS_RTOS_CA9 |
mbedAustin | 11:cada08fc8a70 | 158 | uint32_t const os_stackinfo = (OS_STKCHECK<<24)| (OS_IDLESTKSIZE*4); |
mbedAustin | 11:cada08fc8a70 | 159 | #else |
mbedAustin | 11:cada08fc8a70 | 160 | uint32_t const os_stackinfo = (OS_STKCHECK<<24)| (OS_PRIV_CNT<<16) | (OS_STKSIZE*4); |
mbedAustin | 11:cada08fc8a70 | 161 | #endif |
mbedAustin | 11:cada08fc8a70 | 162 | uint32_t const os_rrobin = (OS_ROBIN << 16) | OS_ROBINTOUT; |
mbedAustin | 11:cada08fc8a70 | 163 | uint32_t const os_tickfreq = OS_CLOCK; |
mbedAustin | 11:cada08fc8a70 | 164 | uint16_t const os_tickus_i = OS_CLOCK/1000000; |
mbedAustin | 11:cada08fc8a70 | 165 | uint16_t const os_tickus_f = (((uint64_t)(OS_CLOCK-1000000*(OS_CLOCK/1000000)))<<16)/1000000; |
mbedAustin | 11:cada08fc8a70 | 166 | uint32_t const os_trv = OS_TRV; |
mbedAustin | 11:cada08fc8a70 | 167 | uint8_t const os_flags = OS_RUNPRIV; |
mbedAustin | 11:cada08fc8a70 | 168 | |
mbedAustin | 11:cada08fc8a70 | 169 | /* Export following defines to uVision debugger. */ |
mbedAustin | 11:cada08fc8a70 | 170 | __USED uint32_t const CMSIS_RTOS_API_Version = osCMSIS; |
mbedAustin | 11:cada08fc8a70 | 171 | __USED uint32_t const CMSIS_RTOS_RTX_Version = osCMSIS_RTX; |
mbedAustin | 11:cada08fc8a70 | 172 | __USED uint32_t const os_clockrate = OS_TICK; |
mbedAustin | 11:cada08fc8a70 | 173 | __USED uint32_t const os_timernum = 0; |
mbedAustin | 11:cada08fc8a70 | 174 | |
mbedAustin | 11:cada08fc8a70 | 175 | /* Memory pool for TCB allocation */ |
mbedAustin | 11:cada08fc8a70 | 176 | _declare_box (mp_tcb, OS_TCB_SIZE, OS_TASK_CNT); |
mbedAustin | 11:cada08fc8a70 | 177 | uint16_t const mp_tcb_size = sizeof(mp_tcb); |
mbedAustin | 11:cada08fc8a70 | 178 | |
mbedAustin | 11:cada08fc8a70 | 179 | #ifdef __MBED_CMSIS_RTOS_CA9 |
mbedAustin | 11:cada08fc8a70 | 180 | /* Memory pool for os_idle_demon stack allocation. */ |
mbedAustin | 11:cada08fc8a70 | 181 | _declare_box8 (mp_stk, OS_IDLESTKSIZE*4, 1); |
mbedAustin | 11:cada08fc8a70 | 182 | uint32_t const mp_stk_size = sizeof(mp_stk); |
mbedAustin | 11:cada08fc8a70 | 183 | #else |
mbedAustin | 11:cada08fc8a70 | 184 | /* Memory pool for System stack allocation (+os_idle_demon). */ |
mbedAustin | 11:cada08fc8a70 | 185 | _declare_box8 (mp_stk, OS_STKSIZE*4, OS_TASK_CNT-OS_PRIV_CNT+1); |
mbedAustin | 11:cada08fc8a70 | 186 | uint32_t const mp_stk_size = sizeof(mp_stk); |
mbedAustin | 11:cada08fc8a70 | 187 | |
mbedAustin | 11:cada08fc8a70 | 188 | /* Memory pool for user specified stack allocation (+main, +timer) */ |
mbedAustin | 11:cada08fc8a70 | 189 | uint64_t os_stack_mem[2+OS_PRIV_CNT+(OS_STACK_SZ/8)]; |
mbedAustin | 11:cada08fc8a70 | 190 | uint32_t const os_stack_sz = sizeof(os_stack_mem); |
mbedAustin | 11:cada08fc8a70 | 191 | #endif |
mbedAustin | 11:cada08fc8a70 | 192 | |
mbedAustin | 11:cada08fc8a70 | 193 | #ifndef OS_FIFOSZ |
mbedAustin | 11:cada08fc8a70 | 194 | #define OS_FIFOSZ 16 |
mbedAustin | 11:cada08fc8a70 | 195 | #endif |
mbedAustin | 11:cada08fc8a70 | 196 | |
mbedAustin | 11:cada08fc8a70 | 197 | /* Fifo Queue buffer for ISR requests.*/ |
mbedAustin | 11:cada08fc8a70 | 198 | uint32_t os_fifo[OS_FIFOSZ*2+1]; |
mbedAustin | 11:cada08fc8a70 | 199 | uint8_t const os_fifo_size = OS_FIFOSZ; |
mbedAustin | 11:cada08fc8a70 | 200 | |
mbedAustin | 11:cada08fc8a70 | 201 | /* An array of Active task pointers. */ |
mbedAustin | 11:cada08fc8a70 | 202 | void *os_active_TCB[OS_TASK_CNT]; |
mbedAustin | 11:cada08fc8a70 | 203 | |
mbedAustin | 11:cada08fc8a70 | 204 | /* User Timers Resources */ |
mbedAustin | 11:cada08fc8a70 | 205 | #if (OS_TIMERS != 0) |
mbedAustin | 11:cada08fc8a70 | 206 | extern void osTimerThread (void const *argument); |
mbedAustin | 11:cada08fc8a70 | 207 | #ifdef __MBED_CMSIS_RTOS_CA9 |
mbedAustin | 11:cada08fc8a70 | 208 | osThreadDef(osTimerThread, (osPriority)(OS_TIMERPRIO-3), 4*OS_TIMERSTKSZ); |
mbedAustin | 11:cada08fc8a70 | 209 | #else |
mbedAustin | 11:cada08fc8a70 | 210 | osThreadDef(osTimerThread, (osPriority)(OS_TIMERPRIO-3), 1, 4*OS_TIMERSTKSZ); |
mbedAustin | 11:cada08fc8a70 | 211 | #endif |
mbedAustin | 11:cada08fc8a70 | 212 | osThreadId osThreadId_osTimerThread; |
mbedAustin | 11:cada08fc8a70 | 213 | osMessageQDef(osTimerMessageQ, OS_TIMERCBQS, void *); |
mbedAustin | 11:cada08fc8a70 | 214 | osMessageQId osMessageQId_osTimerMessageQ; |
mbedAustin | 11:cada08fc8a70 | 215 | #else |
mbedAustin | 11:cada08fc8a70 | 216 | osThreadDef_t os_thread_def_osTimerThread = { NULL }; |
mbedAustin | 11:cada08fc8a70 | 217 | osThreadId osThreadId_osTimerThread; |
mbedAustin | 11:cada08fc8a70 | 218 | osMessageQDef(osTimerMessageQ, 0, void *); |
mbedAustin | 11:cada08fc8a70 | 219 | osMessageQId osMessageQId_osTimerMessageQ; |
mbedAustin | 11:cada08fc8a70 | 220 | #endif |
mbedAustin | 11:cada08fc8a70 | 221 | |
mbedAustin | 11:cada08fc8a70 | 222 | /* Legacy RTX User Timers not used */ |
mbedAustin | 11:cada08fc8a70 | 223 | uint32_t os_tmr = 0; |
mbedAustin | 11:cada08fc8a70 | 224 | uint32_t const *m_tmr = NULL; |
mbedAustin | 11:cada08fc8a70 | 225 | uint16_t const mp_tmr_size = 0; |
mbedAustin | 11:cada08fc8a70 | 226 | |
mbedAustin | 11:cada08fc8a70 | 227 | #if defined (__CC_ARM) && !defined (__MICROLIB) |
mbedAustin | 11:cada08fc8a70 | 228 | /* A memory space for arm standard library. */ |
mbedAustin | 11:cada08fc8a70 | 229 | static uint32_t std_libspace[OS_TASK_CNT][96/4]; |
mbedAustin | 11:cada08fc8a70 | 230 | static OS_MUT std_libmutex[OS_MUTEXCNT]; |
mbedAustin | 11:cada08fc8a70 | 231 | static uint32_t nr_mutex; |
mbedAustin | 11:cada08fc8a70 | 232 | extern void *__libspace_start; |
mbedAustin | 11:cada08fc8a70 | 233 | #elif defined (__ICCARM__) |
mbedAustin | 11:cada08fc8a70 | 234 | typedef struct os_mut_array { |
mbedAustin | 11:cada08fc8a70 | 235 | OS_MUT mutex; |
mbedAustin | 11:cada08fc8a70 | 236 | uint32_t used; |
mbedAustin | 11:cada08fc8a70 | 237 | } os_mut_array_t; |
mbedAustin | 11:cada08fc8a70 | 238 | |
mbedAustin | 11:cada08fc8a70 | 239 | static os_mut_array_t std_libmutex[OS_MUTEXCNT];/* must be Zero clear */ |
mbedAustin | 11:cada08fc8a70 | 240 | static uint32_t nr_mutex = 0; |
mbedAustin | 11:cada08fc8a70 | 241 | #endif |
mbedAustin | 11:cada08fc8a70 | 242 | |
mbedAustin | 11:cada08fc8a70 | 243 | |
mbedAustin | 11:cada08fc8a70 | 244 | /*---------------------------------------------------------------------------- |
mbedAustin | 11:cada08fc8a70 | 245 | * RTX Optimizations (empty functions) |
mbedAustin | 11:cada08fc8a70 | 246 | *---------------------------------------------------------------------------*/ |
mbedAustin | 11:cada08fc8a70 | 247 | |
mbedAustin | 11:cada08fc8a70 | 248 | #if OS_ROBIN == 0 |
mbedAustin | 11:cada08fc8a70 | 249 | void rt_init_robin (void) {;} |
mbedAustin | 11:cada08fc8a70 | 250 | void rt_chk_robin (void) {;} |
mbedAustin | 11:cada08fc8a70 | 251 | #endif |
mbedAustin | 11:cada08fc8a70 | 252 | |
mbedAustin | 11:cada08fc8a70 | 253 | #if OS_STKCHECK == 0 |
mbedAustin | 11:cada08fc8a70 | 254 | void rt_stk_check (void) {;} |
mbedAustin | 11:cada08fc8a70 | 255 | #endif |
mbedAustin | 11:cada08fc8a70 | 256 | |
mbedAustin | 11:cada08fc8a70 | 257 | |
mbedAustin | 11:cada08fc8a70 | 258 | /*---------------------------------------------------------------------------- |
mbedAustin | 11:cada08fc8a70 | 259 | * Standard Library multithreading interface |
mbedAustin | 11:cada08fc8a70 | 260 | *---------------------------------------------------------------------------*/ |
mbedAustin | 11:cada08fc8a70 | 261 | |
mbedAustin | 11:cada08fc8a70 | 262 | #if defined (__CC_ARM) && !defined (__MICROLIB) |
mbedAustin | 11:cada08fc8a70 | 263 | |
mbedAustin | 11:cada08fc8a70 | 264 | /*--------------------------- __user_perthread_libspace ---------------------*/ |
mbedAustin | 11:cada08fc8a70 | 265 | |
mbedAustin | 11:cada08fc8a70 | 266 | void *__user_perthread_libspace (void) { |
mbedAustin | 11:cada08fc8a70 | 267 | /* Provide a separate libspace for each task. */ |
mbedAustin | 11:cada08fc8a70 | 268 | uint32_t idx; |
mbedAustin | 11:cada08fc8a70 | 269 | |
mbedAustin | 11:cada08fc8a70 | 270 | idx = runtask_id (); |
mbedAustin | 11:cada08fc8a70 | 271 | if (idx == 0) { |
mbedAustin | 11:cada08fc8a70 | 272 | /* RTX not running yet. */ |
mbedAustin | 11:cada08fc8a70 | 273 | return (&__libspace_start); |
mbedAustin | 11:cada08fc8a70 | 274 | } |
mbedAustin | 11:cada08fc8a70 | 275 | return ((void *)&std_libspace[idx-1]); |
mbedAustin | 11:cada08fc8a70 | 276 | } |
mbedAustin | 11:cada08fc8a70 | 277 | |
mbedAustin | 11:cada08fc8a70 | 278 | /*--------------------------- _mutex_initialize -----------------------------*/ |
mbedAustin | 11:cada08fc8a70 | 279 | |
mbedAustin | 11:cada08fc8a70 | 280 | int _mutex_initialize (OS_ID *mutex) { |
mbedAustin | 11:cada08fc8a70 | 281 | /* Allocate and initialize a system mutex. */ |
mbedAustin | 11:cada08fc8a70 | 282 | |
mbedAustin | 11:cada08fc8a70 | 283 | if (nr_mutex >= OS_MUTEXCNT) { |
mbedAustin | 11:cada08fc8a70 | 284 | /* If you are here, you need to increase the number OS_MUTEXCNT. */ |
mbedAustin | 11:cada08fc8a70 | 285 | for (;;); |
mbedAustin | 11:cada08fc8a70 | 286 | } |
mbedAustin | 11:cada08fc8a70 | 287 | *mutex = &std_libmutex[nr_mutex++]; |
mbedAustin | 11:cada08fc8a70 | 288 | mutex_init (*mutex); |
mbedAustin | 11:cada08fc8a70 | 289 | return (1); |
mbedAustin | 11:cada08fc8a70 | 290 | } |
mbedAustin | 11:cada08fc8a70 | 291 | |
mbedAustin | 11:cada08fc8a70 | 292 | |
mbedAustin | 11:cada08fc8a70 | 293 | /*--------------------------- _mutex_acquire --------------------------------*/ |
mbedAustin | 11:cada08fc8a70 | 294 | |
mbedAustin | 11:cada08fc8a70 | 295 | __attribute__((used)) void _mutex_acquire (OS_ID *mutex) { |
mbedAustin | 11:cada08fc8a70 | 296 | /* Acquire a system mutex, lock stdlib resources. */ |
mbedAustin | 11:cada08fc8a70 | 297 | if (runtask_id ()) { |
mbedAustin | 11:cada08fc8a70 | 298 | /* RTX running, acquire a mutex. */ |
mbedAustin | 11:cada08fc8a70 | 299 | mutex_wait (*mutex); |
mbedAustin | 11:cada08fc8a70 | 300 | } |
mbedAustin | 11:cada08fc8a70 | 301 | } |
mbedAustin | 11:cada08fc8a70 | 302 | |
mbedAustin | 11:cada08fc8a70 | 303 | |
mbedAustin | 11:cada08fc8a70 | 304 | /*--------------------------- _mutex_release --------------------------------*/ |
mbedAustin | 11:cada08fc8a70 | 305 | |
mbedAustin | 11:cada08fc8a70 | 306 | __attribute__((used)) void _mutex_release (OS_ID *mutex) { |
mbedAustin | 11:cada08fc8a70 | 307 | /* Release a system mutex, unlock stdlib resources. */ |
mbedAustin | 11:cada08fc8a70 | 308 | if (runtask_id ()) { |
mbedAustin | 11:cada08fc8a70 | 309 | /* RTX running, release a mutex. */ |
mbedAustin | 11:cada08fc8a70 | 310 | mutex_rel (*mutex); |
mbedAustin | 11:cada08fc8a70 | 311 | } |
mbedAustin | 11:cada08fc8a70 | 312 | } |
mbedAustin | 11:cada08fc8a70 | 313 | |
mbedAustin | 11:cada08fc8a70 | 314 | #elif defined (__ICCARM__) |
mbedAustin | 11:cada08fc8a70 | 315 | |
mbedAustin | 11:cada08fc8a70 | 316 | /*--------------------------- __iar_system_Mtxinit --------------------------*/ |
mbedAustin | 11:cada08fc8a70 | 317 | |
mbedAustin | 11:cada08fc8a70 | 318 | void __iar_system_Mtxinit(__iar_Rmtx *mutex) |
mbedAustin | 11:cada08fc8a70 | 319 | { |
mbedAustin | 11:cada08fc8a70 | 320 | /* Allocate and initialize a system mutex. */ |
mbedAustin | 11:cada08fc8a70 | 321 | int32_t idx; |
mbedAustin | 11:cada08fc8a70 | 322 | |
mbedAustin | 11:cada08fc8a70 | 323 | for (idx = 0; idx < OS_MUTEXCNT; idx++) |
mbedAustin | 11:cada08fc8a70 | 324 | { |
mbedAustin | 11:cada08fc8a70 | 325 | if (std_libmutex[idx].used == 0) |
mbedAustin | 11:cada08fc8a70 | 326 | { |
mbedAustin | 11:cada08fc8a70 | 327 | std_libmutex[idx].used = 1; |
mbedAustin | 11:cada08fc8a70 | 328 | *mutex = &std_libmutex[idx].mutex; |
mbedAustin | 11:cada08fc8a70 | 329 | nr_mutex++; |
mbedAustin | 11:cada08fc8a70 | 330 | break; |
mbedAustin | 11:cada08fc8a70 | 331 | } |
mbedAustin | 11:cada08fc8a70 | 332 | } |
mbedAustin | 11:cada08fc8a70 | 333 | if (nr_mutex >= OS_MUTEXCNT) |
mbedAustin | 11:cada08fc8a70 | 334 | { |
mbedAustin | 11:cada08fc8a70 | 335 | /* If you are here, you need to increase the number OS_MUTEXCNT. */ |
mbedAustin | 11:cada08fc8a70 | 336 | for (;;); |
mbedAustin | 11:cada08fc8a70 | 337 | } |
mbedAustin | 11:cada08fc8a70 | 338 | |
mbedAustin | 11:cada08fc8a70 | 339 | mutex_init (*mutex); |
mbedAustin | 11:cada08fc8a70 | 340 | } |
mbedAustin | 11:cada08fc8a70 | 341 | |
mbedAustin | 11:cada08fc8a70 | 342 | /*--------------------------- __iar_system_Mtxdst ---------------------------*/ |
mbedAustin | 11:cada08fc8a70 | 343 | |
mbedAustin | 11:cada08fc8a70 | 344 | void __iar_system_Mtxdst(__iar_Rmtx *mutex) |
mbedAustin | 11:cada08fc8a70 | 345 | { |
mbedAustin | 11:cada08fc8a70 | 346 | /* Free a system mutex. */ |
mbedAustin | 11:cada08fc8a70 | 347 | int32_t idx; |
mbedAustin | 11:cada08fc8a70 | 348 | |
mbedAustin | 11:cada08fc8a70 | 349 | if (nr_mutex == 0) |
mbedAustin | 11:cada08fc8a70 | 350 | { |
mbedAustin | 11:cada08fc8a70 | 351 | for (;;); |
mbedAustin | 11:cada08fc8a70 | 352 | } |
mbedAustin | 11:cada08fc8a70 | 353 | |
mbedAustin | 11:cada08fc8a70 | 354 | idx = ((((uint32_t)mutex) - ((uint32_t)&std_libmutex[0].mutex)) |
mbedAustin | 11:cada08fc8a70 | 355 | / sizeof(os_mut_array_t)); |
mbedAustin | 11:cada08fc8a70 | 356 | |
mbedAustin | 11:cada08fc8a70 | 357 | if (idx >= OS_MUTEXCNT) |
mbedAustin | 11:cada08fc8a70 | 358 | { |
mbedAustin | 11:cada08fc8a70 | 359 | for (;;); |
mbedAustin | 11:cada08fc8a70 | 360 | } |
mbedAustin | 11:cada08fc8a70 | 361 | |
mbedAustin | 11:cada08fc8a70 | 362 | mutex_del (*mutex); |
mbedAustin | 11:cada08fc8a70 | 363 | std_libmutex[idx].used = 0; |
mbedAustin | 11:cada08fc8a70 | 364 | } |
mbedAustin | 11:cada08fc8a70 | 365 | |
mbedAustin | 11:cada08fc8a70 | 366 | /*--------------------------- __iar_system_Mtxlock --------------------------*/ |
mbedAustin | 11:cada08fc8a70 | 367 | |
mbedAustin | 11:cada08fc8a70 | 368 | void __iar_system_Mtxlock(__iar_Rmtx *mutex) |
mbedAustin | 11:cada08fc8a70 | 369 | { |
mbedAustin | 11:cada08fc8a70 | 370 | /* Acquire a system mutex, lock stdlib resources. */ |
mbedAustin | 11:cada08fc8a70 | 371 | if (runtask_id ()) |
mbedAustin | 11:cada08fc8a70 | 372 | { |
mbedAustin | 11:cada08fc8a70 | 373 | /* RTX running, acquire a mutex. */ |
mbedAustin | 11:cada08fc8a70 | 374 | mutex_wait (*mutex); |
mbedAustin | 11:cada08fc8a70 | 375 | } |
mbedAustin | 11:cada08fc8a70 | 376 | } |
mbedAustin | 11:cada08fc8a70 | 377 | |
mbedAustin | 11:cada08fc8a70 | 378 | /*--------------------------- __iar_system_Mtxunlock ------------------------*/ |
mbedAustin | 11:cada08fc8a70 | 379 | |
mbedAustin | 11:cada08fc8a70 | 380 | void __iar_system_Mtxunlock(__iar_Rmtx *mutex) |
mbedAustin | 11:cada08fc8a70 | 381 | { |
mbedAustin | 11:cada08fc8a70 | 382 | /* Release a system mutex, unlock stdlib resources. */ |
mbedAustin | 11:cada08fc8a70 | 383 | if (runtask_id ()) |
mbedAustin | 11:cada08fc8a70 | 384 | { |
mbedAustin | 11:cada08fc8a70 | 385 | /* RTX running, release a mutex. */ |
mbedAustin | 11:cada08fc8a70 | 386 | mutex_rel (*mutex); |
mbedAustin | 11:cada08fc8a70 | 387 | } |
mbedAustin | 11:cada08fc8a70 | 388 | } |
mbedAustin | 11:cada08fc8a70 | 389 | |
mbedAustin | 11:cada08fc8a70 | 390 | #endif |
mbedAustin | 11:cada08fc8a70 | 391 | |
mbedAustin | 11:cada08fc8a70 | 392 | |
mbedAustin | 11:cada08fc8a70 | 393 | /*---------------------------------------------------------------------------- |
mbedAustin | 11:cada08fc8a70 | 394 | * RTX Startup |
mbedAustin | 11:cada08fc8a70 | 395 | *---------------------------------------------------------------------------*/ |
mbedAustin | 11:cada08fc8a70 | 396 | |
mbedAustin | 11:cada08fc8a70 | 397 | /* Main Thread definition */ |
mbedAustin | 11:cada08fc8a70 | 398 | extern int main (void); |
mbedAustin | 11:cada08fc8a70 | 399 | #ifdef __MBED_CMSIS_RTOS_CA9 |
mbedAustin | 11:cada08fc8a70 | 400 | uint32_t os_thread_def_stack_main [(4 * OS_MAINSTKSIZE) / sizeof(uint32_t)]; |
mbedAustin | 11:cada08fc8a70 | 401 | osThreadDef_t os_thread_def_main = {(os_pthread)main, osPriorityNormal, 1, 4*OS_MAINSTKSIZE, os_thread_def_stack_main }; |
mbedAustin | 11:cada08fc8a70 | 402 | #else |
mbedAustin | 11:cada08fc8a70 | 403 | osThreadDef_t os_thread_def_main = {(os_pthread)main, osPriorityNormal, 1, 4*OS_MAINSTKSIZE }; |
mbedAustin | 11:cada08fc8a70 | 404 | #endif |
mbedAustin | 11:cada08fc8a70 | 405 | |
mbedAustin | 11:cada08fc8a70 | 406 | #if defined (__CC_ARM) |
mbedAustin | 11:cada08fc8a70 | 407 | |
mbedAustin | 11:cada08fc8a70 | 408 | #ifdef __MICROLIB |
mbedAustin | 11:cada08fc8a70 | 409 | void _main_init (void) __attribute__((section(".ARM.Collect$$$$000000FF"))); |
mbedAustin | 11:cada08fc8a70 | 410 | #if __TARGET_ARCH_ARM |
mbedAustin | 11:cada08fc8a70 | 411 | #pragma push |
mbedAustin | 11:cada08fc8a70 | 412 | #pragma arm |
mbedAustin | 11:cada08fc8a70 | 413 | #endif |
mbedAustin | 11:cada08fc8a70 | 414 | void _main_init (void) { |
mbedAustin | 11:cada08fc8a70 | 415 | osKernelInitialize(); |
mbedAustin | 11:cada08fc8a70 | 416 | osThreadCreate(&os_thread_def_main, NULL); |
mbedAustin | 11:cada08fc8a70 | 417 | osKernelStart(); |
mbedAustin | 11:cada08fc8a70 | 418 | for (;;); |
mbedAustin | 11:cada08fc8a70 | 419 | } |
mbedAustin | 11:cada08fc8a70 | 420 | #if __TARGET_ARCH_ARM |
mbedAustin | 11:cada08fc8a70 | 421 | #pragma pop |
mbedAustin | 11:cada08fc8a70 | 422 | #endif |
mbedAustin | 11:cada08fc8a70 | 423 | #else |
mbedAustin | 11:cada08fc8a70 | 424 | __asm void __rt_entry (void) { |
mbedAustin | 11:cada08fc8a70 | 425 | |
mbedAustin | 11:cada08fc8a70 | 426 | IMPORT __user_setup_stackheap |
mbedAustin | 11:cada08fc8a70 | 427 | IMPORT __rt_lib_init |
mbedAustin | 11:cada08fc8a70 | 428 | IMPORT os_thread_def_main |
mbedAustin | 11:cada08fc8a70 | 429 | IMPORT osKernelInitialize |
mbedAustin | 11:cada08fc8a70 | 430 | IMPORT osKernelStart |
mbedAustin | 11:cada08fc8a70 | 431 | IMPORT osThreadCreate |
mbedAustin | 11:cada08fc8a70 | 432 | IMPORT exit |
mbedAustin | 11:cada08fc8a70 | 433 | |
mbedAustin | 11:cada08fc8a70 | 434 | BL __user_setup_stackheap |
mbedAustin | 11:cada08fc8a70 | 435 | MOV R1,R2 |
mbedAustin | 11:cada08fc8a70 | 436 | BL __rt_lib_init |
mbedAustin | 11:cada08fc8a70 | 437 | BL osKernelInitialize |
mbedAustin | 11:cada08fc8a70 | 438 | LDR R0,=os_thread_def_main |
mbedAustin | 11:cada08fc8a70 | 439 | MOVS R1,#0 |
mbedAustin | 11:cada08fc8a70 | 440 | BL osThreadCreate |
mbedAustin | 11:cada08fc8a70 | 441 | BL osKernelStart |
mbedAustin | 11:cada08fc8a70 | 442 | BL exit |
mbedAustin | 11:cada08fc8a70 | 443 | |
mbedAustin | 11:cada08fc8a70 | 444 | ALIGN |
mbedAustin | 11:cada08fc8a70 | 445 | } |
mbedAustin | 11:cada08fc8a70 | 446 | #endif |
mbedAustin | 11:cada08fc8a70 | 447 | |
mbedAustin | 11:cada08fc8a70 | 448 | #elif defined (__GNUC__) |
mbedAustin | 11:cada08fc8a70 | 449 | |
mbedAustin | 11:cada08fc8a70 | 450 | #ifdef __CS3__ |
mbedAustin | 11:cada08fc8a70 | 451 | |
mbedAustin | 11:cada08fc8a70 | 452 | /* CS3 start_c routine. |
mbedAustin | 11:cada08fc8a70 | 453 | * |
mbedAustin | 11:cada08fc8a70 | 454 | * Copyright (c) 2006, 2007 CodeSourcery Inc |
mbedAustin | 11:cada08fc8a70 | 455 | * |
mbedAustin | 11:cada08fc8a70 | 456 | * The authors hereby grant permission to use, copy, modify, distribute, |
mbedAustin | 11:cada08fc8a70 | 457 | * and license this software and its documentation for any purpose, provided |
mbedAustin | 11:cada08fc8a70 | 458 | * that existing copyright notices are retained in all copies and that this |
mbedAustin | 11:cada08fc8a70 | 459 | * notice is included verbatim in any distributions. No written agreement, |
mbedAustin | 11:cada08fc8a70 | 460 | * license, or royalty fee is required for any of the authorized uses. |
mbedAustin | 11:cada08fc8a70 | 461 | * Modifications to this software may be copyrighted by their authors |
mbedAustin | 11:cada08fc8a70 | 462 | * and need not follow the licensing terms described here, provided that |
mbedAustin | 11:cada08fc8a70 | 463 | * the new terms are clearly indicated on the first page of each file where |
mbedAustin | 11:cada08fc8a70 | 464 | * they apply. |
mbedAustin | 11:cada08fc8a70 | 465 | */ |
mbedAustin | 11:cada08fc8a70 | 466 | |
mbedAustin | 11:cada08fc8a70 | 467 | #include "cs3.h" |
mbedAustin | 11:cada08fc8a70 | 468 | |
mbedAustin | 11:cada08fc8a70 | 469 | extern void __libc_init_array (void); |
mbedAustin | 11:cada08fc8a70 | 470 | |
mbedAustin | 11:cada08fc8a70 | 471 | __attribute ((noreturn)) void __cs3_start_c (void){ |
mbedAustin | 11:cada08fc8a70 | 472 | unsigned regions = __cs3_region_num; |
mbedAustin | 11:cada08fc8a70 | 473 | const struct __cs3_region *rptr = __cs3_regions; |
mbedAustin | 11:cada08fc8a70 | 474 | |
mbedAustin | 11:cada08fc8a70 | 475 | /* Initialize memory */ |
mbedAustin | 11:cada08fc8a70 | 476 | for (regions = __cs3_region_num, rptr = __cs3_regions; regions--; rptr++) { |
mbedAustin | 11:cada08fc8a70 | 477 | long long *src = (long long *)rptr->init; |
mbedAustin | 11:cada08fc8a70 | 478 | long long *dst = (long long *)rptr->data; |
mbedAustin | 11:cada08fc8a70 | 479 | unsigned limit = rptr->init_size; |
mbedAustin | 11:cada08fc8a70 | 480 | unsigned count; |
mbedAustin | 11:cada08fc8a70 | 481 | |
mbedAustin | 11:cada08fc8a70 | 482 | if (src != dst) |
mbedAustin | 11:cada08fc8a70 | 483 | for (count = 0; count != limit; count += sizeof (long long)) |
mbedAustin | 11:cada08fc8a70 | 484 | *dst++ = *src++; |
mbedAustin | 11:cada08fc8a70 | 485 | else |
mbedAustin | 11:cada08fc8a70 | 486 | dst = (long long *)((char *)dst + limit); |
mbedAustin | 11:cada08fc8a70 | 487 | limit = rptr->zero_size; |
mbedAustin | 11:cada08fc8a70 | 488 | for (count = 0; count != limit; count += sizeof (long long)) |
mbedAustin | 11:cada08fc8a70 | 489 | *dst++ = 0; |
mbedAustin | 11:cada08fc8a70 | 490 | } |
mbedAustin | 11:cada08fc8a70 | 491 | |
mbedAustin | 11:cada08fc8a70 | 492 | /* Run initializers. */ |
mbedAustin | 11:cada08fc8a70 | 493 | __libc_init_array (); |
mbedAustin | 11:cada08fc8a70 | 494 | |
mbedAustin | 11:cada08fc8a70 | 495 | osKernelInitialize(); |
mbedAustin | 11:cada08fc8a70 | 496 | osThreadCreate(&os_thread_def_main, NULL); |
mbedAustin | 11:cada08fc8a70 | 497 | osKernelStart(); |
mbedAustin | 11:cada08fc8a70 | 498 | for (;;); |
mbedAustin | 11:cada08fc8a70 | 499 | } |
mbedAustin | 11:cada08fc8a70 | 500 | |
mbedAustin | 11:cada08fc8a70 | 501 | #else |
mbedAustin | 11:cada08fc8a70 | 502 | |
mbedAustin | 11:cada08fc8a70 | 503 | __attribute__((naked)) void software_init_hook (void) { |
mbedAustin | 11:cada08fc8a70 | 504 | __asm ( |
mbedAustin | 11:cada08fc8a70 | 505 | ".syntax unified\n" |
mbedAustin | 11:cada08fc8a70 | 506 | ".arm\n" |
mbedAustin | 11:cada08fc8a70 | 507 | "movs r0,#0\n" |
mbedAustin | 11:cada08fc8a70 | 508 | "movs r1,#0\n" |
mbedAustin | 11:cada08fc8a70 | 509 | "mov r4,r0\n" |
mbedAustin | 11:cada08fc8a70 | 510 | "mov r5,r1\n" |
mbedAustin | 11:cada08fc8a70 | 511 | "ldr r0,= __libc_fini_array\n" |
mbedAustin | 11:cada08fc8a70 | 512 | "bl atexit\n" |
mbedAustin | 11:cada08fc8a70 | 513 | "bl __libc_init_array\n" |
mbedAustin | 11:cada08fc8a70 | 514 | "mov r0,r4\n" |
mbedAustin | 11:cada08fc8a70 | 515 | "mov r1,r5\n" |
mbedAustin | 11:cada08fc8a70 | 516 | "bl osKernelInitialize\n" |
mbedAustin | 11:cada08fc8a70 | 517 | "ldr r0,=os_thread_def_main\n" |
mbedAustin | 11:cada08fc8a70 | 518 | "movs r1,#0\n" |
mbedAustin | 11:cada08fc8a70 | 519 | "bl osThreadCreate\n" |
mbedAustin | 11:cada08fc8a70 | 520 | "bl osKernelStart\n" |
mbedAustin | 11:cada08fc8a70 | 521 | "bl exit\n" |
mbedAustin | 11:cada08fc8a70 | 522 | ); |
mbedAustin | 11:cada08fc8a70 | 523 | } |
mbedAustin | 11:cada08fc8a70 | 524 | |
mbedAustin | 11:cada08fc8a70 | 525 | #endif |
mbedAustin | 11:cada08fc8a70 | 526 | |
mbedAustin | 11:cada08fc8a70 | 527 | #elif defined (__ICCARM__) |
mbedAustin | 11:cada08fc8a70 | 528 | |
mbedAustin | 11:cada08fc8a70 | 529 | extern void exit(int arg); |
mbedAustin | 11:cada08fc8a70 | 530 | |
mbedAustin | 11:cada08fc8a70 | 531 | void mbed_main(void) { |
mbedAustin | 11:cada08fc8a70 | 532 | int a; |
mbedAustin | 11:cada08fc8a70 | 533 | |
mbedAustin | 11:cada08fc8a70 | 534 | osKernelInitialize(); |
mbedAustin | 11:cada08fc8a70 | 535 | osThreadCreate(&os_thread_def_main, NULL); |
mbedAustin | 11:cada08fc8a70 | 536 | a = osKernelStart(); |
mbedAustin | 11:cada08fc8a70 | 537 | exit(a); |
mbedAustin | 11:cada08fc8a70 | 538 | } |
mbedAustin | 11:cada08fc8a70 | 539 | |
mbedAustin | 11:cada08fc8a70 | 540 | #endif |
mbedAustin | 11:cada08fc8a70 | 541 | |
mbedAustin | 11:cada08fc8a70 | 542 | |
mbedAustin | 11:cada08fc8a70 | 543 | /*---------------------------------------------------------------------------- |
mbedAustin | 11:cada08fc8a70 | 544 | * end of file |
mbedAustin | 11:cada08fc8a70 | 545 | *---------------------------------------------------------------------------*/ |
mbedAustin | 11:cada08fc8a70 | 546 |