1. Trang chủ
  2. » Cao đẳng - Đại học

Introduction to uCOS II v2 6 m11

70 347 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Introduction to uCOS-II V2.6 About SwiftACT • A Technology services startup company o Under establishment • Areas of specialties: o o Mobile telecommunication services development Embedded systems development • Types of services: o o o o Consultation Managed services Sourcing Training Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6 About Me • Graduated 2004 o ECE, ASU: yrs distinction • 5+ years in embedded systems development o SDLC, Apps, MW, DD, Porting, • 3+ years in SW engineering o PSP, CMMI, Systematic reuse, • 3+ years in SW testing o IBM certified, ISTQB certified, Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6 Copyright • Materials in this course is the property of Amr Ali Abdel-Naby • Reproduction or transmission of the materials in any manner without the copyright owner permission is a law violation Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6 Course References • MicroC/OS-II The Real-Time Kernel, 2nd Edition, by Jean J Labrosse Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6 Obtaining the Status of a Semaphore, OSSemQuery INT8U OSSemQuery (OS_EVENT *pevent, OS_SEM_DATA *pdata) • • • pevent: A pointer to the desired semaphore pdata: A pointer to the returned semaphore information Return value: o o o • No error pevent is not a semaphore pevent is null Now lets see OSSemQuery in os_sem.c Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6 Porting µC/OS-II Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6 Outline • • • • • • • • • Introduction Development Tools Directories & Files INCLUDES.H OS_CPU.H OS_CPU_C.C OS_CPU_A.ASM Testing a Port Lab 8: 80x86 Port – Real Mode, Large Model with Emulated Floating Point • Summary Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6 Outline • • • • • • • • • Introduction Development Tools Directories & Files INCLUDES.H OS_CPU.H OS_CPU_C.C OS_CPU_A.ASM Testing a Port Lab 8: 80x86 Port – Real Mode, Large Model with Emulated Floating Point • Summary Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6 What is Porting? “The process of adapting SW so that an executable program can be created for a computing environment that is different from the one for which it was originally designed for” Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6 OSIntCtxSw • Called by OSIntExit to perform interrupt level context switch, if needed • Does half context only • OSInctCtxSw == Jumping to proper location in OSCtxSw void OSIntCtxSw(void){ OSTaskSwHook(); OSTCBCur = OSTCBHighRdy; OSPrioCur = OSPrioHighRdy; Get the stack pointer of the task to resume: Stack pointer = OSTCBHighRdy -> OSTCBStkPtr; Restore all processor registers from the new task’s stack; Execute a return from interrupt instruction; } Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6 Outline • • • • • • • • • Introduction Development Tools Directories & Files INCLUDES.H OS_CPU.H OS_CPU_C.C OS_CPU_A.ASM Testing a Port Lab 8: 80x86 Port – Real Mode, Large Model with Emulated Floating Point • Summary Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6 Testing a Port Is • More complicated than writing a port • Done without application code o o KISS If bugs occur, it is 100% from the port code • Done with simple tasks & ticker ISR Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6 Testing a Port Can Be Done with • A source level debugger o o o o Luxury Easy Change with environment Expensive • Go/No Go Testing with a peripheral o o o o A led for example Not fancy More time consuming Cheap Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6 Recommended Scenario Verify OSTaskStkInit & OSStartHighRdy – Verify OSCtxSw – Verify OSIntCtxSw & OSTickISR Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6 Verifying OSTaskStkInit & OSStartHighRdy – Source Level Debugger Disable statistics task Load source code to your debugger Step to OSStart #include “ includes.h” Step into OSStart void main(void){ Step to OSStartHighRdy o Your Code!!! OSInit(); – Step into this code OSStart(); – This code should populate the } registers in reverse order of OSTaskStkInit – Your code should end with OS_TaskIdle Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6 Verifying OSCtxSw – Source Level Debugger Load source code into your debugger Step to OSTimeDly #include “ includes.h” OS_STK TestTaskStk[100]; Step into OSTimeDly void main(void){ OSInit(); Step to OS_Sched OSTaskCreate(TestTask, 0, &TestTaskStk[99], 0); Step into OS_Sched OSStart(); o } This will cause an interrupt that must vector to OSCtxSw – Step to OSCtxSw – Step into OSCtxSw o o Your code!!! Context of test task should be be loaded void TestTask(void * pdata){ pdata = pdata; while(1) OSTimeDelay(1); }saved & that of OS_TaskIdle – Your code should end with OS_TaskIdle Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6 should Verifying OSIntCtxSw & OSTickISR – Source Level Debugger Set up an interrupt vector for the clock tick ISR Initialize the clock tick & enable interrupts #include “ includes.h” OS_STK TestTaskStk[100]; void main(void){ OSInit(); Install clock tick interrupt vector; OSTaskCreate(TestTask, 0, &TestTaskStk[99], 0); OSStart(); } void TestTask(void * pdata){ pdata = pdata; Initialize clock tick interrupt then enable interrupts; device_state = OFF; while(1) { OSTimeDly(1); if (device_state == OFF) device_state = ON; if (device_state == ON) device_state = OFF; } Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6 } Verifying OSTaskStkInit & OSStartHighRdy – Go/No Go • Same test code as “Verifying OSTaskStkInit & OSStartHighRdy – Source Level Debugger “ • But OSTaskIdleHook will be modified void OSTaskIdleHook(void){ if (device_state == OFF) device_state = ON; if (device_state == ON) device_state = OFF; } Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6 Verifying OSCtxSw – Go/No Go • Same test code as “Verifying OSCtxSw – Source Level Debugger “ • But OSTaskIdleHook will be modified as in “Verifying OSTaskStkInit & OSStartHighRdy – Go/No Go” Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6 Verifying OSIntCtxSw & OSTickISR – Go/No Go • Same as “Verifying OSIntCtxSw & OSTickISR – Source Level Debugger” Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6 Outline • • • • • • • • • Introduction Development Tools Directories & Files INCLUDES.H OS_CPU.H OS_CPU_C.C OS_CPU_A.ASM Testing a Port Lab 8: 80x86 Port – Real Mode, Large Model with Emulated Floating Point • Summary Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6 Lab 8: 80x86 Port – Real Mode, Large Model with Emulated Floating Point • Please follow the instructions in the lab handout Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6 Outline • • • • • • • • • Introduction Development Tools Directories & Files INCLUDES.H OS_CPU.H OS_CPU_C.C OS_CPU_A.ASM Testing a Port Lab 8: 80x86 Port – Real Mode, Large Model with Emulated Floating Point • Summary Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6 Summary • Porting • Porting µC/OS-II Amr Ali Abdel-Naby@2010 Introduction to uCOS-II V2.6 [...]... Abdel-Naby@2010 Introduction to uCOS- II V2. 6 Outline • • • • • • • • • Introduction Development Tools Directories & Files INCLUDES.H OS_CPU.H OS_CPU_C.C OS_CPU_A.ASM Testing a Port Lab 8: 80x 86 Port – Real Mode, Large Model with Emulated Floating Point • Summary Amr Ali Abdel-Naby@2010 Introduction to uCOS- II V2. 6 Directory Guideline uCOS- II\ CPU\Tool Chain \OS_CPU.H \OS_CPU_A.ASM \OS_CPU_C.C • For example: uCOS- II\ ARM\ADS1.2... load & store stack pointer & CPU registers Amr Ali Abdel-Naby@2010 Introduction to uCOS- II V2. 6 µC/OS -II Kernel Architecture Application SW (Your Code) µC/OS -II (Processor Independent code) µC/OS -II Configuration (Application Specific) µC/OS -II Port (Processor Specific Code) HW Amr Ali Abdel-Naby@2010 Introduction to uCOS- II V2. 6 Outline • • • • • • • • • Introduction Development Tools Directories &... Abdel-Naby@2010 Introduction to uCOS- II V2. 6 Outline • • • • • • • • • Introduction Development Tools Directories & Files INCLUDES.H OS_CPU.H OS_CPU_C.C OS_CPU_A.ASM Testing a Port Lab 8: 80x 86 Port – Real Mode, Large Model with Emulated Floating Point • Summary Amr Ali Abdel-Naby@2010 Introduction to uCOS- II V2. 6 INCLUDES.H • Every C file should include it • == Master include file o o Advantage: No need to worry... Amr Ali Abdel-Naby@2010 Introduction to uCOS- II V2. 6 Types of OS Porting OS Porting Architecture Basic Board BSP Amr Ali Abdel-Naby@2010 Introduction to uCOS- II V2. 6 Architecture Porting • The main task of OS is to support multitasking • Thus, architecture porting is about context switch & exceptions handling Amr Ali Abdel-Naby@2010 Introduction to uCOS- II V2. 6 Context Switch • Volatile state of the CPU... needed includes at its end Amr Ali Abdel-Naby@2010 Introduction to uCOS- II V2. 6 Outline • • • • • • • • • Introduction Development Tools Directories & Files INCLUDES.H OS_CPU.H OS_CPU_C.C OS_CPU_A.ASM Testing a Port Lab 8: 80x 86 Port – Real Mode, Large Model with Emulated Floating Point • Summary Amr Ali Abdel-Naby@2010 Introduction to uCOS- II V2. 6 OS_CPU.H • Contains compiler specific typedef’s •... Abdel-Naby@2010 Introduction to uCOS- II V2. 6 Layered Architecture & Porting Application SW Application Porting Middleware Middleware Porting Operating System OS Porting Firmware / Device Drivers HW Amr Ali Abdel-Naby@2010 Introduction to uCOS- II V2. 6 OS Porting • The most difficult type • OS provides HW abstraction • Needs solid HW Knowledge as well as solid HW knowledge Amr Ali Abdel-Naby@2010 Introduction to uCOS- II. .. #define constants & macros Amr Ali Abdel-Naby@2010 Introduction to uCOS- II V2. 6 Data Types typedef ?? BOOLEAN; typedef ?? INT8U; typedef ?? INT8S; typedef ?? INT16U; typedef ?? INT16S; typedef ?? INT32U; typedef ?? INT32S; typedef ?? FP32; typedef ?? FP64; typedef ?? OS_STK; typedef ?? OS_CPU_SR; Amr Ali Abdel-Naby@2010 Introduction to uCOS- II V2. 6 Processor Specifics #define OS_CRITICAL_METHOD ??... Abdel-Naby@2010 Introduction to uCOS- II V2. 6 Stack Growth • Some stacks grow from high -to- low memory • Others grow from low -to- high memory • #define OS_STK_GROWTH is defined to handle both models o o Set OS_STK_GROWTH to 0 for low -to- high memory stack growth Set OS_STK_GROWTH to 1 for high -to- low memory stack growth • OSInit & OSTaskStkChk need to know stack growth • Context switch algorithms need to know... Testing a Port Lab 8: 80x 86 Port – Real Mode, Large Model with Emulated Floating Point • Summary Amr Ali Abdel-Naby@2010 Introduction to uCOS- II V2. 6 Development Tools Requirement • ANSI C compiler o Reentrant compiler • Assembler o == C compiler with  Inline assembly  Registers manipulation from C o Saving & restoring registers • Linker o To combine object codes • Locator o To place code & data anywhere... Ali Abdel-Naby@2010 Introduction to uCOS- II V2. 6 Critical Sections – Method 1 • Not adequate implementation #define OS_ENTER_CRITICAL()\ asm (“DI”) #define OS_EXIT_CRITICAL()\ asm (“EI”) • Interrupt state may differ before & after the critical section Interrupts are disabled Interrupts are enabled OS_ENTER_CRITICAL Amr Ali Abdel-Naby@2010 OS_EXIT_CRITICAL Introduction to uCOS- II V2. 6 Critical Sections

Ngày đăng: 10/08/2016, 09:56

Xem thêm: Introduction to uCOS II v2 6 m11

TỪ KHÓA LIÊN QUAN