Dependencies: EthernetNetIf NetServices mbed HTTPServer
scmRTOS/CortexM3/OS_Target_cpp.cpp@0:96cf274f19bc, 2011-05-23 (annotated)
- Committer:
- etudiant12
- Date:
- Mon May 23 05:40:11 2011 +0000
- Revision:
- 0:96cf274f19bc
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
etudiant12 | 0:96cf274f19bc | 1 | //****************************************************************************** |
etudiant12 | 0:96cf274f19bc | 2 | //* |
etudiant12 | 0:96cf274f19bc | 3 | //* FULLNAME: Single-Chip Microcontroller Real-Time Operating System |
etudiant12 | 0:96cf274f19bc | 4 | //* |
etudiant12 | 0:96cf274f19bc | 5 | //* NICKNAME: scmRTOS |
etudiant12 | 0:96cf274f19bc | 6 | //* |
etudiant12 | 0:96cf274f19bc | 7 | //* PROCESSOR: ARM Cortex-M3 |
etudiant12 | 0:96cf274f19bc | 8 | //* |
etudiant12 | 0:96cf274f19bc | 9 | //* TOOLKIT: EWARM (IAR Systems) |
etudiant12 | 0:96cf274f19bc | 10 | //* |
etudiant12 | 0:96cf274f19bc | 11 | //* PURPOSE: Target Dependent Stuff Source |
etudiant12 | 0:96cf274f19bc | 12 | //* |
etudiant12 | 0:96cf274f19bc | 13 | //* Version: 3.10 |
etudiant12 | 0:96cf274f19bc | 14 | //* |
etudiant12 | 0:96cf274f19bc | 15 | //* $Revision: 195 $ |
etudiant12 | 0:96cf274f19bc | 16 | //* $Date:: 2008-06-19 #$ |
etudiant12 | 0:96cf274f19bc | 17 | //* |
etudiant12 | 0:96cf274f19bc | 18 | //* Copyright (c) 2003-2010, Harry E. Zhurov |
etudiant12 | 0:96cf274f19bc | 19 | //* |
etudiant12 | 0:96cf274f19bc | 20 | //* Permission is hereby granted, free of charge, to any person |
etudiant12 | 0:96cf274f19bc | 21 | //* obtaining a copy of this software and associated documentation |
etudiant12 | 0:96cf274f19bc | 22 | //* files (the "Software"), to deal in the Software without restriction, |
etudiant12 | 0:96cf274f19bc | 23 | //* including without limitation the rights to use, copy, modify, merge, |
etudiant12 | 0:96cf274f19bc | 24 | //* publish, distribute, sublicense, and/or sell copies of the Software, |
etudiant12 | 0:96cf274f19bc | 25 | //* and to permit persons to whom the Software is furnished to do so, |
etudiant12 | 0:96cf274f19bc | 26 | //* subject to the following conditions: |
etudiant12 | 0:96cf274f19bc | 27 | //* |
etudiant12 | 0:96cf274f19bc | 28 | //* The above copyright notice and this permission notice shall be included |
etudiant12 | 0:96cf274f19bc | 29 | //* in all copies or substantial portions of the Software. |
etudiant12 | 0:96cf274f19bc | 30 | //* |
etudiant12 | 0:96cf274f19bc | 31 | //* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
etudiant12 | 0:96cf274f19bc | 32 | //* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
etudiant12 | 0:96cf274f19bc | 33 | //* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
etudiant12 | 0:96cf274f19bc | 34 | //* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
etudiant12 | 0:96cf274f19bc | 35 | //* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
etudiant12 | 0:96cf274f19bc | 36 | //* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH |
etudiant12 | 0:96cf274f19bc | 37 | //* THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
etudiant12 | 0:96cf274f19bc | 38 | //* |
etudiant12 | 0:96cf274f19bc | 39 | //* ================================================================= |
etudiant12 | 0:96cf274f19bc | 40 | //* See http://scmrtos.sourceforge.net for documentation, latest |
etudiant12 | 0:96cf274f19bc | 41 | //* information, license and contact details. |
etudiant12 | 0:96cf274f19bc | 42 | //* ================================================================= |
etudiant12 | 0:96cf274f19bc | 43 | //* |
etudiant12 | 0:96cf274f19bc | 44 | //****************************************************************************** |
etudiant12 | 0:96cf274f19bc | 45 | //* Ported by Andrey Chuikin, Copyright (c) 2008-2010 |
etudiant12 | 0:96cf274f19bc | 46 | |
etudiant12 | 0:96cf274f19bc | 47 | |
etudiant12 | 0:96cf274f19bc | 48 | #include <scmRTOS.h> |
etudiant12 | 0:96cf274f19bc | 49 | |
etudiant12 | 0:96cf274f19bc | 50 | using namespace OS; |
etudiant12 | 0:96cf274f19bc | 51 | |
etudiant12 | 0:96cf274f19bc | 52 | //------------------------------------------------------------------------------ |
etudiant12 | 0:96cf274f19bc | 53 | // |
etudiant12 | 0:96cf274f19bc | 54 | // OS Process's constructor |
etudiant12 | 0:96cf274f19bc | 55 | // |
etudiant12 | 0:96cf274f19bc | 56 | // Performs: |
etudiant12 | 0:96cf274f19bc | 57 | // * initializing process data; |
etudiant12 | 0:96cf274f19bc | 58 | // * registering of the process in kernel; |
etudiant12 | 0:96cf274f19bc | 59 | // * preparing stack frame; |
etudiant12 | 0:96cf274f19bc | 60 | // |
etudiant12 | 0:96cf274f19bc | 61 | // |
etudiant12 | 0:96cf274f19bc | 62 | TBaseProcess::TBaseProcess(TStackItem* Stack, TPriority pr, void (*exec)()) |
etudiant12 | 0:96cf274f19bc | 63 | : StackPointer(Stack) |
etudiant12 | 0:96cf274f19bc | 64 | , Timeout(0) |
etudiant12 | 0:96cf274f19bc | 65 | , Priority(pr) |
etudiant12 | 0:96cf274f19bc | 66 | { |
etudiant12 | 0:96cf274f19bc | 67 | Kernel.RegisterProcess(this); |
etudiant12 | 0:96cf274f19bc | 68 | |
etudiant12 | 0:96cf274f19bc | 69 | //--------------------------------------------------------------- |
etudiant12 | 0:96cf274f19bc | 70 | // |
etudiant12 | 0:96cf274f19bc | 71 | // Prepare Process Stack Frame |
etudiant12 | 0:96cf274f19bc | 72 | // |
etudiant12 | 0:96cf274f19bc | 73 | *(--StackPointer) = 0x01000000L; // xPSR |
etudiant12 | 0:96cf274f19bc | 74 | *(--StackPointer) = reinterpret_cast<dword>(exec); // Entry Point |
etudiant12 | 0:96cf274f19bc | 75 | StackPointer -= 14; // emulate "push R14,R12,R3,R2,R1,R0,R11-R4" |
etudiant12 | 0:96cf274f19bc | 76 | |
etudiant12 | 0:96cf274f19bc | 77 | // The code below can be used for debug purpose. In this case comment |
etudiant12 | 0:96cf274f19bc | 78 | // line above and uncomment block below. |
etudiant12 | 0:96cf274f19bc | 79 | /* |
etudiant12 | 0:96cf274f19bc | 80 | *(--StackPointer) = 0xFFFFFFFEL; // R14 (LR) (init value will cause fault if ever used) |
etudiant12 | 0:96cf274f19bc | 81 | *(--StackPointer) = 0x12121212L; // R12 |
etudiant12 | 0:96cf274f19bc | 82 | *(--StackPointer) = 0x03030303L; // R3 |
etudiant12 | 0:96cf274f19bc | 83 | *(--StackPointer) = 0x02020202L; // R2 |
etudiant12 | 0:96cf274f19bc | 84 | *(--StackPointer) = 0x01010101L; // R1 |
etudiant12 | 0:96cf274f19bc | 85 | *(--StackPointer) = 0x00000000L; // R0 |
etudiant12 | 0:96cf274f19bc | 86 | |
etudiant12 | 0:96cf274f19bc | 87 | // Remaining registers saved on process stack |
etudiant12 | 0:96cf274f19bc | 88 | *(--StackPointer) = 0x11111111L; // R11 |
etudiant12 | 0:96cf274f19bc | 89 | *(--StackPointer) = 0x10101010L; // R10 |
etudiant12 | 0:96cf274f19bc | 90 | *(--StackPointer) = 0x09090909L; // R9 |
etudiant12 | 0:96cf274f19bc | 91 | *(--StackPointer) = 0x08080808L; // R8 |
etudiant12 | 0:96cf274f19bc | 92 | *(--StackPointer) = 0x07070707L; // R7 |
etudiant12 | 0:96cf274f19bc | 93 | *(--StackPointer) = 0x06060606L; // R6 |
etudiant12 | 0:96cf274f19bc | 94 | *(--StackPointer) = 0x05050505L; // R5 |
etudiant12 | 0:96cf274f19bc | 95 | *(--StackPointer) = 0x04040404L; // R4 |
etudiant12 | 0:96cf274f19bc | 96 | */ |
etudiant12 | 0:96cf274f19bc | 97 | } |
etudiant12 | 0:96cf274f19bc | 98 | //------------------------------------------------------------------------------ |
etudiant12 | 0:96cf274f19bc | 99 | // |
etudiant12 | 0:96cf274f19bc | 100 | // Idle Process |
etudiant12 | 0:96cf274f19bc | 101 | // |
etudiant12 | 0:96cf274f19bc | 102 | typedef process<prIDLE, scmRTOS_IDLE_PROCESS_STACK_SIZE> TIdleProcess; |
etudiant12 | 0:96cf274f19bc | 103 | |
etudiant12 | 0:96cf274f19bc | 104 | TIdleProcess IdleProcess; |
etudiant12 | 0:96cf274f19bc | 105 | |
etudiant12 | 0:96cf274f19bc | 106 | template<> OS_PROCESS void TIdleProcess::Exec() |
etudiant12 | 0:96cf274f19bc | 107 | { |
etudiant12 | 0:96cf274f19bc | 108 | for(;;) |
etudiant12 | 0:96cf274f19bc | 109 | { |
etudiant12 | 0:96cf274f19bc | 110 | #if scmRTOS_IDLE_HOOK_ENABLE == 1 |
etudiant12 | 0:96cf274f19bc | 111 | IdleProcessUserHook(); |
etudiant12 | 0:96cf274f19bc | 112 | #endif |
etudiant12 | 0:96cf274f19bc | 113 | } |
etudiant12 | 0:96cf274f19bc | 114 | } |
etudiant12 | 0:96cf274f19bc | 115 | //------------------------------------------------------------------------------ |
etudiant12 | 0:96cf274f19bc | 116 | OS_INTERRUPT void OS::SysTick_Handler() |
etudiant12 | 0:96cf274f19bc | 117 | { |
etudiant12 | 0:96cf274f19bc | 118 | scmRTOS_ISRW_TYPE ISR; |
etudiant12 | 0:96cf274f19bc | 119 | |
etudiant12 | 0:96cf274f19bc | 120 | Kernel.SystemTimer(); |
etudiant12 | 0:96cf274f19bc | 121 | |
etudiant12 | 0:96cf274f19bc | 122 | #if scmRTOS_SYSTIMER_NEST_INTS_ENABLE == 0 |
etudiant12 | 0:96cf274f19bc | 123 | DISABLE_NESTED_INTERRUPTS(); |
etudiant12 | 0:96cf274f19bc | 124 | #endif |
etudiant12 | 0:96cf274f19bc | 125 | |
etudiant12 | 0:96cf274f19bc | 126 | #if scmRTOS_SYSTIMER_HOOK_ENABLE == 1 |
etudiant12 | 0:96cf274f19bc | 127 | SystemTimerUserHook(); |
etudiant12 | 0:96cf274f19bc | 128 | #endif |
etudiant12 | 0:96cf274f19bc | 129 | } |
etudiant12 | 0:96cf274f19bc | 130 | //------------------------------------------------------------------------------ |
etudiant12 | 0:96cf274f19bc | 131 |