rtos: fix coding style in the boot files

pull/8591/head
Martin Kojtal 2018-10-31 12:16:56 +00:00
parent 9238bf223f
commit 87265f7744
4 changed files with 34 additions and 28 deletions

View File

@ -37,10 +37,10 @@ void _main_init(void)
{
/* 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_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_init();

View File

@ -105,7 +105,7 @@ __asm(".global __use_no_semihosting\n\t");
//lint -esym(9003, os_libspace*) "variables 'os_libspace*' defined at module scope"
// 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")));
// Thread IDs for libspace
@ -113,7 +113,8 @@ static osThreadId_t os_libspace_id[OS_THREAD_LIBSPACE_NUM] \
__attribute__((section(".bss.os.libspace")));
// 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;
if (os_kernel_active == 0U) {
@ -125,7 +126,8 @@ static uint32_t os_kernel_is_active (void) {
}
// Provide libspace for current thread
void *__user_perthread_libspace (void) {
void *__user_perthread_libspace(void)
{
osThreadId_t id;
uint32_t n;
@ -182,7 +184,7 @@ __USED int _mutex_initialize(mutex *m)
core_util_critical_section_enter();
for (int i = 0; i < OS_MUTEX_STATIC_NUM; i++) {
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];
//Use the static attrs
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 */
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) {
osRtxErrorNotify(osRtxErrorClibSpace, m);
return 0;
@ -218,21 +220,24 @@ __USED int _mutex_initialize(mutex *m)
}
/* Acquire mutex */
__USED void _mutex_acquire(mutex *m) {
__USED void _mutex_acquire(mutex *m)
{
if (os_kernel_is_active() != 0U) {
(void)osMutexAcquire(*m, osWaitForever);
}
}
/* Release mutex */
__USED void _mutex_release(mutex *m) {
__USED void _mutex_release(mutex *m)
{
if (os_kernel_is_active() != 0U) {
(void)osMutexRelease(*m);
}
}
/* Free mutex */
__USED void _mutex_free(mutex *m) {
__USED void _mutex_free(mutex *m)
{
mutex *slot = NULL;
core_util_critical_section_enter();
for (int i = 0; i < OS_MUTEX_STATIC_NUM; i++) {

View File

@ -35,7 +35,7 @@ extern uint32_t __end__[];
#define HEAP_SIZE ((uint32_t)((uint32_t)INITIAL_SP - (uint32_t)HEAP_START))
#endif
extern void __libc_init_array (void);
extern void __libc_init_array(void);
/*
* mbed entry point for the GCC toolchain
@ -86,7 +86,8 @@ void mbed_toolchain_init()
}
extern int __real_main(void);
int __wrap_main(void) {
int __wrap_main(void)
{
/* For backwards compatibility */
return __real_main();
}
@ -94,22 +95,22 @@ int __wrap_main(void) {
/* Opaque declaration of _reent structure */
struct _reent;
void __rtos_malloc_lock( struct _reent *_r )
void __rtos_malloc_lock(struct _reent *_r)
{
osMutexAcquire(malloc_mutex_id, osWaitForever);
}
void __rtos_malloc_unlock( struct _reent *_r )
void __rtos_malloc_unlock(struct _reent *_r)
{
osMutexRelease(malloc_mutex_id);
}
void __rtos_env_lock( struct _reent *_r )
void __rtos_env_lock(struct _reent *_r)
{
osMutexAcquire(env_mutex_id, osWaitForever);
}
void __rtos_env_unlock( struct _reent *_r )
void __rtos_env_unlock(struct _reent *_r)
{
osMutexRelease(env_mutex_id);
}

View File

@ -27,7 +27,7 @@
#pragma section="CSTACK"
#pragma section="HEAP"
extern void* __vector_table;
extern void *__vector_table;
extern int __low_level_init(void);
extern void __iar_data_init3(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
*/
#pragma required=__vector_table
void __iar_program_start( void )
void __iar_program_start(void)
{
/* the calls below are normally made in IAR cstartup */
__iar_init_core();
@ -74,10 +74,10 @@ void __iar_program_start( void )
__iar_data_init3();
/* 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_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_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.attr_bits = osMutexRecursive | osMutexPrioInherit | osMutexRobust;
std_mutex_id_sys[index] = osMutexNew(&attr);
*mutex = (__iar_Rmtx*)&std_mutex_id_sys[index];
*mutex = (__iar_Rmtx *)&std_mutex_id_sys[index];
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 */
{
osMutexDelete(*(osMutexId_t*)*mutex);
osMutexDelete(*(osMutexId_t *)*mutex);
*mutex = 0;
}
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 */
{
osMutexRelease(*(osMutexId_t*)*mutex);
osMutexRelease(*(osMutexId_t *)*mutex);
}
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.attr_bits = osMutexRecursive | osMutexPrioInherit | osMutexRobust;
std_mutex_id_file[index] = osMutexNew(&attr);
*mutex = (__iar_Rmtx*)&std_mutex_id_file[index];
*mutex = (__iar_Rmtx *)&std_mutex_id_file[index];
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 */
{
osMutexDelete(*(osMutexId_t*)*mutex);
osMutexDelete(*(osMutexId_t *)*mutex);
*mutex = 0;
}
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 */
{
osMutexRelease(*(osMutexId_t*)*mutex);
osMutexRelease(*(osMutexId_t *)*mutex);
}