Skip to content

Commit

Permalink
Revert "Merge pull request #1 from 0xc0170/dev_update_rtos"
Browse files Browse the repository at this point in the history
This reverts commit 4ae6b05, reversing
changes made to 1ee1150.
  • Loading branch information
Yogesh Pande authored and Yogesh Pande committed Apr 7, 2016
1 parent 4ac9644 commit 34e24f7
Show file tree
Hide file tree
Showing 56 changed files with 1,262 additions and 2,276 deletions.
2 changes: 1 addition & 1 deletion core/mbed-rtos/rtos/Mutex.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class Mutex {
osMutexId _osMutexId;
osMutexDef_t _osMutexDef;
#ifdef CMSIS_OS_RTX
#if defined(__MBED_CMSIS_RTOS_CA9) || defined(__MBED_CMSIS_RTOS_CM)
#ifdef __MBED_CMSIS_RTOS_CA9
int32_t _mutex_data[4];
#else
int32_t _mutex_data[3];
Expand Down
4 changes: 1 addition & 3 deletions core/mbed-rtos/rtos/RtosTimer.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,8 @@ class RtosTimer {
private:
osTimerId _timer_id;
osTimerDef_t _timer;
#if defined(CMSIS_OS_RTX) && !defined(__MBED_CMSIS_RTOS_CM)
#ifdef CMSIS_OS_RTX
uint32_t _timer_data[5];
#else
uint32_t _timer_data[6];
#endif
};

Expand Down
24 changes: 2 additions & 22 deletions core/mbed-rtos/rtos/Thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace rtos {

Thread::Thread(void (*task)(void const *argument), void *argument,
osPriority priority, uint32_t stack_size, unsigned char *stack_pointer) {
#ifdef __MBED_CMSIS_RTOS_CM
#ifdef CMSIS_OS_RTX
_thread_def.pthread = task;
_thread_def.tpriority = priority;
_thread_def.stacksize = stack_size;
Expand Down Expand Up @@ -71,10 +71,8 @@ int32_t Thread::signal_clr(int32_t signals) {
}

Thread::State Thread::get_state() {
#if !defined(__MBED_CMSIS_RTOS_CA9) && !defined(__MBED_CMSIS_RTOS_CM)
#ifdef CMSIS_OS_RTX
#ifndef __MBED_CMSIS_RTOS_CA9
return ((State)_thread_def.tcb.state);
#endif
#else
uint8_t status;
status = osThreadGetState(_tid);
Expand All @@ -84,55 +82,39 @@ Thread::State Thread::get_state() {

uint32_t Thread::stack_size() {
#ifndef __MBED_CMSIS_RTOS_CA9
#if defined(CMSIS_OS_RTX) && !defined(__MBED_CMSIS_RTOS_CM)
return _thread_def.tcb.priv_stack;
#else
return 0;
#endif
#else
return 0;
#endif
}

uint32_t Thread::free_stack() {
#ifndef __MBED_CMSIS_RTOS_CA9
#if defined(CMSIS_OS_RTX) && !defined(__MBED_CMSIS_RTOS_CM)
uint32_t bottom = (uint32_t)_thread_def.tcb.stack;
return _thread_def.tcb.tsk_stack - bottom;
#else
return 0;
#endif
#else
return 0;
#endif
}

uint32_t Thread::used_stack() {
#ifndef __MBED_CMSIS_RTOS_CA9
#if defined(CMSIS_OS_RTX) && !defined(__MBED_CMSIS_RTOS_CM)
uint32_t top = (uint32_t)_thread_def.tcb.stack + _thread_def.tcb.priv_stack;
return top - _thread_def.tcb.tsk_stack;
#else
return 0;
#endif
#else
return 0;
#endif
}

uint32_t Thread::max_stack() {
#ifndef __MBED_CMSIS_RTOS_CA9
#if defined(CMSIS_OS_RTX) && !defined(__MBED_CMSIS_RTOS_CM)
uint32_t high_mark = 0;
while (_thread_def.tcb.stack[high_mark] == 0xE25A2EA5)
high_mark++;
return _thread_def.tcb.priv_stack - (high_mark * 4);
#else
return 0;
#endif
#else
return 0;
#endif
}

osEvent Thread::signal_wait(int32_t signals, uint32_t millisec) {
Expand All @@ -157,11 +139,9 @@ void Thread::attach_idle_hook(void (*fptr)(void)) {

Thread::~Thread() {
terminate();
#ifdef __MBED_CMSIS_RTOS_CM
if (_dynamic_stack) {
delete[] (_thread_def.stack_pointer);
}
#endif
}

}
66 changes: 23 additions & 43 deletions core/mbed-rtos/rtx/TARGET_CORTEX_M/HAL_CM.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*----------------------------------------------------------------------------
* CMSIS-RTOS - RTX
* RL-ARM - RTX
*----------------------------------------------------------------------------
* Name: HAL_CM.C
* Purpose: Hardware Abstraction Layer for Cortex-M
* Rev.: V4.79
* Rev.: V4.60
*----------------------------------------------------------------------------
*
* Copyright (c) 1999-2009 KEIL, 2009-2015 ARM Germany GmbH
* Copyright (c) 1999-2009 KEIL, 2009-2012 ARM Germany GmbH
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
Expand All @@ -33,7 +33,7 @@
*---------------------------------------------------------------------------*/

#include "rt_TypeDef.h"
#include "RTX_Config.h"
#include "RTX_Conf.h"
#include "rt_HAL_CM.h"


Expand All @@ -58,15 +58,12 @@ void rt_init_stack (P_TCB p_TCB, FUNCP task_body) {

/* Prepare a complete interrupt frame for first task start */
size = p_TCB->priv_stack >> 2;
if (size == 0U) {
size = (U16)os_stackinfo >> 2;
}

/* Write to the top of stack. */
stk = &p_TCB->stack[size];

/* Auto correct to 8-byte ARM stack alignment. */
if ((U32)stk & 0x04U) {
if ((U32)stk & 0x04) {
stk--;
}

Expand All @@ -77,8 +74,8 @@ void rt_init_stack (P_TCB p_TCB, FUNCP task_body) {
stk[14] = (U32)task_body;

/* Clear R4-R11,R0-R3,R12,LR registers. */
for (i = 0U; i < 14U; i++) {
stk[i] = 0U;
for (i = 0; i < 14; i++) {
stk[i] = 0;
}

/* Assign a void pointer to R0. */
Expand All @@ -90,50 +87,31 @@ void rt_init_stack (P_TCB p_TCB, FUNCP task_body) {
/* Task entry point. */
p_TCB->ptask = task_body;

/* Initialize stack with magic pattern. */
if (os_stackinfo & 0x10000000U) {
if (size > (16U+1U)) {
for (i = ((size - 16U)/2U) - 1U; i; i--) {
stk -= 2U;
stk[1] = MAGIC_PATTERN;
stk[0] = MAGIC_PATTERN;
}
if (--stk > p_TCB->stack) {
*stk = MAGIC_PATTERN;
}
}
}

#ifdef __MBED_CMSIS_RTOS_CM
/* Set a magic word for checking of stack overflow.
For the main thread (ID: 0x02) the stack is in a memory area shared with the
For the main thread (ID: 0x01) the stack is in a memory area shared with the
heap, therefore the last word of the stack is a moving target.
We want to do stack/heap collision detection instead.
*/
if (p_TCB->task_id != 0x02)
if (p_TCB->task_id != 0x01)
p_TCB->stack[0] = MAGIC_WORD;
#else
/* Set a magic word for checking of stack overflow. */
p_TCB->stack[0] = MAGIC_WORD;
#endif
}


/*--------------------------- rt_ret_val ----------------------------------*/

static __inline U32 *rt_ret_regs (P_TCB p_TCB) {
/* Get pointer to task return value registers (R0..R3) in Stack */
#if defined(__TARGET_FPU_VFP)
#if (__TARGET_FPU_VFP)
if (p_TCB->stack_frame) {
/* Extended Stack Frame: R4-R11,S16-S31,R0-R3,R12,LR,PC,xPSR,S0-S15,FPSCR */
return (U32 *)(p_TCB->tsk_stack + (8U*4U) + (16U*4U));
return (U32 *)(p_TCB->tsk_stack + 8*4 + 16*4);
} else {
/* Basic Stack Frame: R4-R11,R0-R3,R12,LR,PC,xPSR */
return (U32 *)(p_TCB->tsk_stack + (8U*4U));
return (U32 *)(p_TCB->tsk_stack + 8*4);
}
#else
/* Stack Frame: R4-R11,R0-R3,R12,LR,PC,xPSR */
return (U32 *)(p_TCB->tsk_stack + (8U*4U));
return (U32 *)(p_TCB->tsk_stack + 8*4);
#endif
}

Expand All @@ -157,9 +135,9 @@ void rt_ret_val2(P_TCB p_TCB, U32 v0, U32 v1) {

#ifdef DBG_MSG
void dbg_init (void) {
if (((DEMCR & DEMCR_TRCENA) != 0U) &&
((ITM_CONTROL & ITM_ITMENA) != 0U) &&
((ITM_ENABLE & (1UL << 31)) != 0U)) {
if ((DEMCR & DEMCR_TRCENA) &&
(ITM_CONTROL & ITM_ITMENA) &&
(ITM_ENABLE & (1UL << 31))) {
dbg_msg = __TRUE;
}
}
Expand All @@ -169,22 +147,24 @@ void dbg_init (void) {

#ifdef DBG_MSG
void dbg_task_notify (P_TCB p_tcb, BOOL create) {
while (ITM_PORT31_U32 == 0U);
while (ITM_PORT31_U32 == 0);
ITM_PORT31_U32 = (U32)p_tcb->ptask;
while (ITM_PORT31_U32 == 0U);
ITM_PORT31_U16 = (U16)((create << 8) | p_tcb->task_id);
while (ITM_PORT31_U32 == 0);
ITM_PORT31_U16 = (create << 8) | p_tcb->task_id;
}
#endif

/*--------------------------- dbg_task_switch -------------------------------*/

#ifdef DBG_MSG
void dbg_task_switch (U32 task_id) {
while (ITM_PORT31_U32 == 0U);
ITM_PORT31_U8 = (U8)task_id;
while (ITM_PORT31_U32 == 0);
ITM_PORT31_U8 = task_id;
}
#endif


/*----------------------------------------------------------------------------
* end of file
*---------------------------------------------------------------------------*/

Loading

0 comments on commit 34e24f7

Please sign in to comment.