mirror of https://github.com/ARMmbed/mbed-os.git
rtos: fix coding style in the boot files
parent
9238bf223f
commit
87265f7744
|
@ -37,10 +37,10 @@ void _main_init(void)
|
||||||
{
|
{
|
||||||
/* microlib only supports the two region memory model */
|
/* microlib only supports the two region memory model */
|
||||||
|
|
||||||
mbed_heap_start = (unsigned char*)__heap_base;
|
mbed_heap_start = (unsigned char *)__heap_base;
|
||||||
mbed_heap_size = (uint32_t)__heap_base - (uint32_t)__heap_limit;
|
mbed_heap_size = (uint32_t)__heap_base - (uint32_t)__heap_limit;
|
||||||
|
|
||||||
mbed_stack_isr_start = (unsigned char*)((uint32_t)__initial_sp - ISR_STACK_SIZE);
|
mbed_stack_isr_start = (unsigned char *)((uint32_t)__initial_sp - ISR_STACK_SIZE);
|
||||||
mbed_stack_isr_size = ISR_STACK_SIZE;
|
mbed_stack_isr_size = ISR_STACK_SIZE;
|
||||||
|
|
||||||
mbed_init();
|
mbed_init();
|
||||||
|
|
|
@ -105,7 +105,7 @@ __asm(".global __use_no_semihosting\n\t");
|
||||||
//lint -esym(9003, os_libspace*) "variables 'os_libspace*' defined at module scope"
|
//lint -esym(9003, os_libspace*) "variables 'os_libspace*' defined at module scope"
|
||||||
|
|
||||||
// Memory for libspace
|
// Memory for libspace
|
||||||
static uint32_t os_libspace[OS_THREAD_LIBSPACE_NUM+1][LIBSPACE_SIZE/4] \
|
static uint32_t os_libspace[OS_THREAD_LIBSPACE_NUM + 1][LIBSPACE_SIZE / 4] \
|
||||||
__attribute__((section(".bss.os.libspace")));
|
__attribute__((section(".bss.os.libspace")));
|
||||||
|
|
||||||
// Thread IDs for libspace
|
// Thread IDs for libspace
|
||||||
|
@ -113,7 +113,8 @@ static osThreadId_t os_libspace_id[OS_THREAD_LIBSPACE_NUM] \
|
||||||
__attribute__((section(".bss.os.libspace")));
|
__attribute__((section(".bss.os.libspace")));
|
||||||
|
|
||||||
// Check if Kernel has been started
|
// Check if Kernel has been started
|
||||||
static uint32_t os_kernel_is_active (void) {
|
static uint32_t os_kernel_is_active(void)
|
||||||
|
{
|
||||||
static uint8_t os_kernel_active = 0U;
|
static uint8_t os_kernel_active = 0U;
|
||||||
|
|
||||||
if (os_kernel_active == 0U) {
|
if (os_kernel_active == 0U) {
|
||||||
|
@ -125,7 +126,8 @@ static uint32_t os_kernel_is_active (void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Provide libspace for current thread
|
// Provide libspace for current thread
|
||||||
void *__user_perthread_libspace (void) {
|
void *__user_perthread_libspace(void)
|
||||||
|
{
|
||||||
osThreadId_t id;
|
osThreadId_t id;
|
||||||
uint32_t n;
|
uint32_t n;
|
||||||
|
|
||||||
|
@ -182,7 +184,7 @@ __USED int _mutex_initialize(mutex *m)
|
||||||
core_util_critical_section_enter();
|
core_util_critical_section_enter();
|
||||||
for (int i = 0; i < OS_MUTEX_STATIC_NUM; i++) {
|
for (int i = 0; i < OS_MUTEX_STATIC_NUM; i++) {
|
||||||
if (_static_mutexes[i] == NULL) {
|
if (_static_mutexes[i] == NULL) {
|
||||||
_static_mutexes[i] = (mutex)-1; // dummy value to reserve slot
|
_static_mutexes[i] = (mutex) - 1; // dummy value to reserve slot
|
||||||
slot = &_static_mutexes[i];
|
slot = &_static_mutexes[i];
|
||||||
//Use the static attrs
|
//Use the static attrs
|
||||||
attr.cb_size = sizeof(mbed_rtos_storage_mutex_t);
|
attr.cb_size = sizeof(mbed_rtos_storage_mutex_t);
|
||||||
|
@ -202,7 +204,7 @@ __USED int _mutex_initialize(mutex *m)
|
||||||
|
|
||||||
/* Mutex pool exhausted, try using HEAP */
|
/* Mutex pool exhausted, try using HEAP */
|
||||||
attr.cb_size = sizeof(mbed_rtos_storage_mutex_t);
|
attr.cb_size = sizeof(mbed_rtos_storage_mutex_t);
|
||||||
attr.cb_mem = (void*)malloc(attr.cb_size);
|
attr.cb_mem = (void *)malloc(attr.cb_size);
|
||||||
if (attr.cb_mem == NULL) {
|
if (attr.cb_mem == NULL) {
|
||||||
osRtxErrorNotify(osRtxErrorClibSpace, m);
|
osRtxErrorNotify(osRtxErrorClibSpace, m);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -218,21 +220,24 @@ __USED int _mutex_initialize(mutex *m)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Acquire mutex */
|
/* Acquire mutex */
|
||||||
__USED void _mutex_acquire(mutex *m) {
|
__USED void _mutex_acquire(mutex *m)
|
||||||
|
{
|
||||||
if (os_kernel_is_active() != 0U) {
|
if (os_kernel_is_active() != 0U) {
|
||||||
(void)osMutexAcquire(*m, osWaitForever);
|
(void)osMutexAcquire(*m, osWaitForever);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Release mutex */
|
/* Release mutex */
|
||||||
__USED void _mutex_release(mutex *m) {
|
__USED void _mutex_release(mutex *m)
|
||||||
|
{
|
||||||
if (os_kernel_is_active() != 0U) {
|
if (os_kernel_is_active() != 0U) {
|
||||||
(void)osMutexRelease(*m);
|
(void)osMutexRelease(*m);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free mutex */
|
/* Free mutex */
|
||||||
__USED void _mutex_free(mutex *m) {
|
__USED void _mutex_free(mutex *m)
|
||||||
|
{
|
||||||
mutex *slot = NULL;
|
mutex *slot = NULL;
|
||||||
core_util_critical_section_enter();
|
core_util_critical_section_enter();
|
||||||
for (int i = 0; i < OS_MUTEX_STATIC_NUM; i++) {
|
for (int i = 0; i < OS_MUTEX_STATIC_NUM; i++) {
|
||||||
|
|
|
@ -35,7 +35,7 @@ extern uint32_t __end__[];
|
||||||
#define HEAP_SIZE ((uint32_t)((uint32_t)INITIAL_SP - (uint32_t)HEAP_START))
|
#define HEAP_SIZE ((uint32_t)((uint32_t)INITIAL_SP - (uint32_t)HEAP_START))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern void __libc_init_array (void);
|
extern void __libc_init_array(void);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* mbed entry point for the GCC toolchain
|
* mbed entry point for the GCC toolchain
|
||||||
|
@ -86,7 +86,8 @@ void mbed_toolchain_init()
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int __real_main(void);
|
extern int __real_main(void);
|
||||||
int __wrap_main(void) {
|
int __wrap_main(void)
|
||||||
|
{
|
||||||
/* For backwards compatibility */
|
/* For backwards compatibility */
|
||||||
return __real_main();
|
return __real_main();
|
||||||
}
|
}
|
||||||
|
@ -94,22 +95,22 @@ int __wrap_main(void) {
|
||||||
/* Opaque declaration of _reent structure */
|
/* Opaque declaration of _reent structure */
|
||||||
struct _reent;
|
struct _reent;
|
||||||
|
|
||||||
void __rtos_malloc_lock( struct _reent *_r )
|
void __rtos_malloc_lock(struct _reent *_r)
|
||||||
{
|
{
|
||||||
osMutexAcquire(malloc_mutex_id, osWaitForever);
|
osMutexAcquire(malloc_mutex_id, osWaitForever);
|
||||||
}
|
}
|
||||||
|
|
||||||
void __rtos_malloc_unlock( struct _reent *_r )
|
void __rtos_malloc_unlock(struct _reent *_r)
|
||||||
{
|
{
|
||||||
osMutexRelease(malloc_mutex_id);
|
osMutexRelease(malloc_mutex_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void __rtos_env_lock( struct _reent *_r )
|
void __rtos_env_lock(struct _reent *_r)
|
||||||
{
|
{
|
||||||
osMutexAcquire(env_mutex_id, osWaitForever);
|
osMutexAcquire(env_mutex_id, osWaitForever);
|
||||||
}
|
}
|
||||||
|
|
||||||
void __rtos_env_unlock( struct _reent *_r )
|
void __rtos_env_unlock(struct _reent *_r)
|
||||||
{
|
{
|
||||||
osMutexRelease(env_mutex_id);
|
osMutexRelease(env_mutex_id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
#pragma section="CSTACK"
|
#pragma section="CSTACK"
|
||||||
#pragma section="HEAP"
|
#pragma section="HEAP"
|
||||||
|
|
||||||
extern void* __vector_table;
|
extern void *__vector_table;
|
||||||
extern int __low_level_init(void);
|
extern int __low_level_init(void);
|
||||||
extern void __iar_data_init3(void);
|
extern void __iar_data_init3(void);
|
||||||
extern __weak void __iar_init_core(void);
|
extern __weak void __iar_init_core(void);
|
||||||
|
@ -53,7 +53,7 @@ extern void __iar_dynamic_initialization(void);
|
||||||
* <IAR>\arm\src\lib\thumb\cstartup_M.s
|
* <IAR>\arm\src\lib\thumb\cstartup_M.s
|
||||||
*/
|
*/
|
||||||
#pragma required=__vector_table
|
#pragma required=__vector_table
|
||||||
void __iar_program_start( void )
|
void __iar_program_start(void)
|
||||||
{
|
{
|
||||||
/* the calls below are normally made in IAR cstartup */
|
/* the calls below are normally made in IAR cstartup */
|
||||||
__iar_init_core();
|
__iar_init_core();
|
||||||
|
@ -74,10 +74,10 @@ void __iar_program_start( void )
|
||||||
__iar_data_init3();
|
__iar_data_init3();
|
||||||
|
|
||||||
/* mbed specific code */
|
/* mbed specific code */
|
||||||
mbed_heap_start = (unsigned char*)__section_begin("HEAP");
|
mbed_heap_start = (unsigned char *)__section_begin("HEAP");
|
||||||
mbed_heap_size = (uint32_t)__section_size("HEAP");
|
mbed_heap_size = (uint32_t)__section_size("HEAP");
|
||||||
|
|
||||||
mbed_stack_isr_start = (unsigned char*)__section_begin("CSTACK");
|
mbed_stack_isr_start = (unsigned char *)__section_begin("CSTACK");
|
||||||
mbed_stack_isr_size = (uint32_t)__section_size("CSTACK");
|
mbed_stack_isr_size = (uint32_t)__section_size("CSTACK");
|
||||||
|
|
||||||
mbed_init();
|
mbed_init();
|
||||||
|
@ -112,7 +112,7 @@ void __iar_system_Mtxinit(__iar_Rmtx *mutex) /* Initialize a system lock */
|
||||||
attr.cb_size = sizeof(std_mutex_sys[index]);
|
attr.cb_size = sizeof(std_mutex_sys[index]);
|
||||||
attr.attr_bits = osMutexRecursive | osMutexPrioInherit | osMutexRobust;
|
attr.attr_bits = osMutexRecursive | osMutexPrioInherit | osMutexRobust;
|
||||||
std_mutex_id_sys[index] = osMutexNew(&attr);
|
std_mutex_id_sys[index] = osMutexNew(&attr);
|
||||||
*mutex = (__iar_Rmtx*)&std_mutex_id_sys[index];
|
*mutex = (__iar_Rmtx *)&std_mutex_id_sys[index];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -123,18 +123,18 @@ void __iar_system_Mtxinit(__iar_Rmtx *mutex) /* Initialize a system lock */
|
||||||
|
|
||||||
void __iar_system_Mtxdst(__iar_Rmtx *mutex) /* Destroy a system lock */
|
void __iar_system_Mtxdst(__iar_Rmtx *mutex) /* Destroy a system lock */
|
||||||
{
|
{
|
||||||
osMutexDelete(*(osMutexId_t*)*mutex);
|
osMutexDelete(*(osMutexId_t *)*mutex);
|
||||||
*mutex = 0;
|
*mutex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __iar_system_Mtxlock(__iar_Rmtx *mutex) /* Lock a system lock */
|
void __iar_system_Mtxlock(__iar_Rmtx *mutex) /* Lock a system lock */
|
||||||
{
|
{
|
||||||
osMutexAcquire(*(osMutexId_t*)*mutex, osWaitForever);
|
osMutexAcquire(*(osMutexId_t *)*mutex, osWaitForever);
|
||||||
}
|
}
|
||||||
|
|
||||||
void __iar_system_Mtxunlock(__iar_Rmtx *mutex) /* Unlock a system lock */
|
void __iar_system_Mtxunlock(__iar_Rmtx *mutex) /* Unlock a system lock */
|
||||||
{
|
{
|
||||||
osMutexRelease(*(osMutexId_t*)*mutex);
|
osMutexRelease(*(osMutexId_t *)*mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void __iar_file_Mtxinit(__iar_Rmtx *mutex) /* Initialize a file lock */
|
void __iar_file_Mtxinit(__iar_Rmtx *mutex) /* Initialize a file lock */
|
||||||
|
@ -148,7 +148,7 @@ void __iar_file_Mtxinit(__iar_Rmtx *mutex) /* Initialize a file lock */
|
||||||
attr.cb_size = sizeof(std_mutex_file[index]);
|
attr.cb_size = sizeof(std_mutex_file[index]);
|
||||||
attr.attr_bits = osMutexRecursive | osMutexPrioInherit | osMutexRobust;
|
attr.attr_bits = osMutexRecursive | osMutexPrioInherit | osMutexRobust;
|
||||||
std_mutex_id_file[index] = osMutexNew(&attr);
|
std_mutex_id_file[index] = osMutexNew(&attr);
|
||||||
*mutex = (__iar_Rmtx*)&std_mutex_id_file[index];
|
*mutex = (__iar_Rmtx *)&std_mutex_id_file[index];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -158,16 +158,16 @@ void __iar_file_Mtxinit(__iar_Rmtx *mutex) /* Initialize a file lock */
|
||||||
|
|
||||||
void __iar_file_Mtxdst(__iar_Rmtx *mutex) /* Destroy a file lock */
|
void __iar_file_Mtxdst(__iar_Rmtx *mutex) /* Destroy a file lock */
|
||||||
{
|
{
|
||||||
osMutexDelete(*(osMutexId_t*)*mutex);
|
osMutexDelete(*(osMutexId_t *)*mutex);
|
||||||
*mutex = 0;
|
*mutex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __iar_file_Mtxlock(__iar_Rmtx *mutex) /* Lock a file lock */
|
void __iar_file_Mtxlock(__iar_Rmtx *mutex) /* Lock a file lock */
|
||||||
{
|
{
|
||||||
osMutexAcquire(*(osMutexId_t*)*mutex, osWaitForever);
|
osMutexAcquire(*(osMutexId_t *)*mutex, osWaitForever);
|
||||||
}
|
}
|
||||||
|
|
||||||
void __iar_file_Mtxunlock(__iar_Rmtx *mutex) /* Unlock a file lock */
|
void __iar_file_Mtxunlock(__iar_Rmtx *mutex) /* Unlock a file lock */
|
||||||
{
|
{
|
||||||
osMutexRelease(*(osMutexId_t*)*mutex);
|
osMutexRelease(*(osMutexId_t *)*mutex);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue