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: 5 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
Porting in PC World
• x86 is the dominant CPU architecture.
o
A lot of SW are never ported to different CPUs.
• Windows & a Unix flavor are the dominant operating systems.
• International standards facilitate porting in the PC world.
o
ISO, POSIX, …
• Porting is rare in our world.
Amr Ali Abdel-Naby@2010
Introduction to uCOS-II V2.6
Porting for Embedded Systems World
• Embedded systems are custom by nature.
o
o
o
CPUs
Operating systems
...
• Portability is a significant problem.
Amr Ali 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 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
o
CPU registers + MMU if OS is process based
Task A Stack(memory)
Task A TCB
cpsr
r0
r1
r2
r3
r4
r5
r6
r7
r8
r9
r10
r11
r12
r14 (lr)
r15 (pc)
Stack ptr
Task B TCB
CPU Core
Stack ptr
CPU Register
Save
Scheduling Decision Made
Restore
Current running
Context
Switch
Task B
Task A
Context Switch Overhead
Amr Ali Abdel-Naby@2010
Introduction to uCOS-II V2.6
Task B Stack(memory)
cpsr
r0
r1
r2
r3
r4
r5
r6
r7
r8
r9
r10
r11
r12
r14 (lr)
r15 (pc)
Exceptions Handling
Amr Ali Abdel-Naby@2010
Introduction to uCOS-II V2.6
Board Porting
• Basic board porting
o
o
Check proper board operation
Function the minimum needed peripherals
Memory
ICU
PLL
Timer
I/O
• Board Support Package
o
o
Boot loader + Device drivers
Minimum BSP is the basic board porting.
Amr Ali Abdel-Naby@2010
Introduction to uCOS-II V2.6
µC/OS-II Porting Prerequisites
• CPU support interrupts.
• CPU can generate interrupts at regular rates.
• Interrupts can be enabled and disabled.
• CPU supports HW stack.
• CPU can 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 & 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
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 in the memory map of the target
CPU
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
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
\OS_CPU.H
\OS_CPU_A.ASM
\OS_CPU_C.C
Amr Ali Abdel-Naby@2010
Introduction to uCOS-II V2.6