Home
- Spansion
Contents
1. 90 Creating an Abort Execute Function abortfn EE 90 Creating an Event Function eventfn 90 Creating an Execute Start Function execfn ET 89 Creating an Open Function openfn 88 H Handler Alarm Handler Functions 54 Alarm 15 Calling Format of an Expansion SVC Handler DERE 87 Creating an Alarm Handler 82 Creation of a Cyclic Handler 81 Cyclic Handler Functions 52 Cyclic Handlers isitin 14 Description Format of a Cyclic Handler 81 Description Format of an Alarm Handler 82 Description Format of an Extension SVC Handler sis cei rerit 87 Description Format of an Interrupt Handler TELE 83 Extended SVC Handlers 17 Interrupt Handlers esses 13 Launch of a Cyclic Handler 81 Precedence of Execution Handlers vs Handlers T 25 Precedence of Execution Tasks vs Interrupt Handlers and Time Event Handlers TL 23 Registering an Interrupt Handler 83 Starting an Alarm Handler 82 Time Event Handlers 14 Timer Interrupt Handler 84 Initial Routine Description Example of the Initial Routine 76 Descript
2. 10 U User Program Configuring a User Program 70 Execution Units of User Program 7 Starting a User 71 User Programs and System States 21 user system Build a user 100 117 INDEX V Variable size Memory Pool Variable size Memory Pool Functions 49 W Wait Completion Function Creating a Wait Completion Function waitfn 118 waitfn Creating a Wait Completion Function waitfn Warning Message Warning Messages 90 MN706 00008 1v0 E FUJITSU SEMICONDUCTOR CONTROLLER MANUAL FM3 Family uT Kernel Specification Compliant uT REALOS M3 for RVDS USER S GUIDE July 2011 the first edition Published FUJITSU SEMICONDUCTOR LIMITED Edited Sales Promotion Dept
3. 72 Process of the Initial Routine 75 Product Structure of 3 Program Notes on the Overall of a Program 91 R Registering Registering a Power Saving Routine 86 Registering an Error Routine 85 Rendezvous Port Rendezvous Port Functions 44 Reset A specific Example of the Reset Entry Routine O A caos 74 Process of Reset Entry Routine 72 Reset Entry Routine ssesssssss 72 Reset Entry Routine A specific Example of the Reset Entry Routine ave De eee 74 Process of Reset Entry 72 Reset Entry Routine eeeeesssssss 72 Routine A specific Example of the Reset Entry Routine Description Example of the Initial Routine 76 Description Format of a Power Saving Routine nem 86 Description Format of an Error Routine 85 Description Format of the Initial Routine 75 Process of Reset Entry Routine 72 Process of the Initial Routine 75 Registering a Power Saving Routine 86 Registering an Error Routine 85 Reset Entry Routine sess 72 Running Non task Portion Running 20 Task Portion Running uses 20 S Semaphore S
4. Device process abort E Creating an Event Function eventfn 90 An event function is called from the kernel when tk_sus_dev or tk_evt_dev is called from a user program This function is called from a user program or the kernel when notifying a device of some event As an event function passes an event type to a parameter the driver performs process for that event For details of an event function see O Event function eventfn of Section 4 11 Device Processing Function in API Reference Figure 4 12 7 Description Format of Event Function eventfn INT rtncd eventfn INT evttyp INT evtinf VP exinf Device event process CHAPTER 4 WRITING A USER PROGRAM 4 13 Notes when Writing a User Program This section explains notes when writing a user program of uT REALOS Notes on the Overall of a Program e Internal identifiers starting with _KERNEL kernel tk tm and knl The kernel of yT REALOS uses symbols and macros starting with the above mentioned Do not use these symbols and macros in a user program This may cause duplicate definition e Management register of L T REALOS The CONTROL register is managed by uT REALOS Do not change this register by a user program Include file of kernel Include uT REALOS Install Directory utkernel 7 M include tk tkernel h in a user program using a system call i Notes on the Overall of a System Call A system call can
5. Create the Cyclic handler When specifying TA_STA for attribute a cyclic handler becomes the action status after it was created After the start period elapses a cyclic handler is called If not specifying TA_STA a cyclic handler becomes the stop status after it was created Specifying TA HLNG for attribute indicates the target cyclic handler is written in C Be sure to specify TA HLNG E Launch of a Cyclic Handler A Cyclic handler is moved from the stop status to the action status when tk sta is called In the following example the cyclic handler is started as the Cyclic handler ID of cycid1 Figure 4 6 3 Description Example of the Cyclic Handler Startup tk sta 1 Start the Cyclic handler whose ID is cycid1 81 CHAPTER 4 WRITING A USER PROGRAM 4 7 Alarm Handler This section explains how to write an alarm handler E Description Format of an Alarm Handler An alarm handler is described as follows Figure 4 7 1 Description Example of an Alarm Handler void almhdr1 VP exinf Process the alarm handler return Terminate the alarm handler The extension information specified when an alarm handler is created tk cre alm is passed to exinf E Creating an Alarm Handler tk cre alm is called to create an alarm handler In the following example function almhdr1 18 created as an alarm handler If creation of an alarm handler is terminated normally the ala
6. CHAPTER 3 uT REALOS FUNCTIONS 3 4 3 Mailbox Functions This section explains the mailbox functions E Mailbox Functions Mailboxes are objects that perform synchronization and communication by receiving messages that are stored in memory Table 3 4 3 shows mailbox functions and their corresponding system calls Table 3 4 3 Mailbox Functions and Corresponding System Calls Function System Call Name Create mailbox tk cre mbx Delete mailbox tk del mbx Send Message to Mailbox tk snd mbx Receive Message from Mailbox tk rcv mbx Refer Mailbox Status tk ref mbx Mailbox objects are identified by an ID number The mailbox ID number is called the mailbox ID Mailboxes have a message queue for storing messages that have been sent and a wait queue for tasks that are waiting to receive a message The message sending side the event notifier side places the messages to be sent in the message queue The order of the message queue can be selected from the two options of FIFO order TA MFIFO and message priority order TA MPRI when the mailbox is created The message receiving side the event wait side retrieves a single message from the message queue If there are no messages in the message queue the task enters a state of waiting for receipt from the mailbox until the next message is sent Tasks that enter a state of waiting for receipt from the mailbox linked to the wait queue of that mailbox The order of
7. Mailboxes messages that are stored in memory Mutexes are objects that perform exclusive access control between tasks that use a Mutexes shared resource Message buffers are objects that perform synchronization and communication by receiv ing variable length messages Rendezvous ports provide intertask synchronous communication functionality and sup port a single sequence where one task requests processing of another task and the second task then returns the processing result to the first task The object that synchronizes the waiting of both tasks is called a rendezvous port Rendezvous ports Fixed size Fixed size memory pool are objects for dynamically managing fixed size memory memory pool blocks Variable size Variable size memory pool are objects for dynamically managing arbitrary size memory memory pool blocks Cyclic handlers Cyclic handlers are time event handlers that activate at a fixed period Alarm handlers Alarm handlers are time event handlers that activate at a specified time 19 CHAPTER 2 BASIC CONCEPTS OF THE u REALOS KERNEL 2 4 System States This section explains the system states System States The system states of NT REALOS are divided into the following categories Figure 2 4 1 System States Task portion running Task program System states Transient states During OS execution Non task portion running t Task independent portion running
8. PERFORM The following document contains information on Cypress products Although the document is marked with the name Spansion and Fujitsu the company that originally developed the specification Cypress will continue to offer these products to new and existing customers Continuity of Specifications There is no change to this document as a result of offering the device as a Cypress product Any changes that have been made are the result of normal document improvements and are noted in the document history page where supported Future revisions will occur when appropriate and changes will be noted in a document history page Continuity of Ordering Part Numbers Cypress continues to support existing part numbers To order these products please use only the Ordering Part Numbers listed in this document For More Information Please contact your local sales office for additional information about Cypress products and solutions About Cypress Cypress NASDAQ CY delivers high performance high quality solutions at the heart of today s most advanced embedded systems from automotive industrial and networking platforms to highly interactive consumer and mobile devices With a broad differentiated product portfolio that includes NOR flash memories F RAM and SRAM Traveo microcontrollers the industry s only PSoC programmable system on chip solutions analog and PMIC Power Management ICs CapSense capacitive touch sensing controlle
9. This definition was overwritten by the definition specified later When number is output in the definition name the definition was overwritten by the definition specified later using the ID indicated by the number W1401M Not found maximum area definition definition name Maximum area definition name output by the definition name does not exist When this error occurs the maximum size is assigned automatically W1405M EIT vector No number is system reserve As the interrupt number specified by number is system reserved it cannot be used This error message is output when the interrupt number of an interrupt handler defined in DEF_INH is system reserved B Error Messages E4024M Illegal character parameter gt U U m Z 2 gt lt gt ITI x o o Q a ct 2 O 2 gt Q c gt Characters that cannot be used in parameter output by parameter contained This error occurs when characters are specified in parameter requiring numbers or when numbers are specified in Parameter requiring labels E4026M Specified value is out of range parameter The value output in parameter is out of range that can be specified This error occurs when a value exceeding 32767 was specified in object ID E4110M Unknown API name character string Cannot use the definition output in the character string This error occurs when unsupported API name
10. from 1 to 3 41 CHAPTER 3 uT REALOS FUNCTIONS 3 5 2 Message Buffer Functions This section explains the message buffer functions E Message Buffer Functions 42 Message buffers are objects that perform synchronization and communication by receiving variable length messages Table 3 5 2 shows message buffer functions and their corresponding system calls Table 3 5 2 Message Buffer Functions and Corresponding System Calls Function System Call Name Create message buffer tk cre mbf Delete message buffer tk del mbf Send Message to Message Buffer tk snd mbf Receive Message from Message Buffer tk rcv mbf Refer Message Buffer Status tk ref mbf Message buffer objects are identified by an ID number The message buffer ID number is called the message buffer ID Message buffers have a wait queue of tasks waiting to send messages send wait queue and a wait queue of tasks waiting to receive messages receive wait queue The message buffer also has a message buffer area for storing sent messages The message sending side the event notifier side copies the messages to be sent into the message buffer If there is not enough free space in the message buffer area the task waits for sending a message to message buffer until there is enough free space in the message buffer area Tasks waiting to send a message to message buffer are linked to the send wait queue of that message buffer The order
11. Device Driver iet itte ette ete i E E ERU TEE SEE EREEREER BLUE ERE REUTERS EE URS REO 88 4 13 Notes when Writing a User Program sssesssseeeneeeneeen enm 91 CHAPTER5 HOW TO CONSTRUCT A SYSTEM 93 5 1 Steps of Constructing a System ssssssssssssssssseseeeeee enne enne 94 5 2 Kernel Configuration n nera Dro ete t tic e nl Due rates 95 5 3 Create the UT REALOS Project sssssssssssssssseseeeee ener nennen nnne nene 97 5 4 Build a User System oec a ape idee e desee n 100 APPENDIX e 101 APPENDIX A Error Messages of the Configurator ssssssssseeeene enne 102 INDE CUTS 113 viii CHAPTER 1 OVERVIEW OF uT REALOS This chapter explains an overview of uT REALOS uT REALOS is a uT Kernel specification real time OS that runs on the FM3 family uT REALOS is conforms to the uT Kernel specifications 1 1 Supported Functions 1 2 Structure of Product 1 3 Tools Required for Development CHAPTER 1 OVERVIEW OF uT REALOS 1 1 Supported Functions This section explains the supported functions of uT REALOS E Supported Functions HL T REALOS supports the functions listed below For details on the functions see CHAPTER 3 uT REALOS FUNCTIONS herein and CHAPTER 3 SYSTEM CALL INTERFACE in API Reference Task management functions Task synchronization functions Sync
12. executable files that are run from the command prompt window Kernel libraries The uT REALOS kernel object files are included in the library format Kernel header files Header files that are included by user programs and which define system calls and parameter types Sample programs Samples programs of reset entry routines initialization processing timer interrupt handlers and tasks Sample build related files These are project files configuration files and other files for the sample programs CHAPTER 1 OVERVIEW OF uT REALOS 1 3 Tools Required for Development This section explains the tools that are required to develop a user system Tools Required for Development The following tools are required to develop a UT REALOS user system e Cross development tool ARM s RealView Development Suite RVDS Emulator ARM s RealView ICE RVI For details on the tool version see Release Notes Figure 1 3 1 Structure of Development Tools Cross development tool Language tool Debugger Board for Emulator debugging CHAPTER 2 BASIC CONCEPTS OF THE uT REALOS KERNEL This chapter explains the basic concepts that are required to understand the uL T REALOS kernel 2 1 System Calls 2 2 Execution Units of User Program 2 3 Objects 2 4 System States 2 5 Dispatch and Interrupts Enabled disabled States 2 6 Precedence of Execution of Tasks and Handlers CHAPTER 2 BASIC CONCEP
13. 3 3 tk sta tsk of API Reference A specific Example of the Task Figure 4 5 4 shows the description example of a task and Figure 4 5 5 shows the operation diagram of the program in the description example The source codes are attached to the product as a sample program init task c of LT REALOS In addition the task in this specific example is created started using the initial routine given in Figure 4 4 2 In Figure 4 5 4 task1 and task2 move to the status of waiting for the semaphore of sem by tk wai sem task3 releases the semaphore resources of sem1 by the system call of tk sig sem This releases task1 and task2 from the waiting status The task priorities are task1 gt task2 gt task3 78 CHAPTER 4 WRITING A USER PROGRAM Figure 4 5 4 Description Example of a Task static void task1 INT stacd VP exinf if stacd 1 while 1 tk_wai_sem sem1 1 else tk_ext_tsk Exit task static void task2 INT stacd VP exinf if stacd 2 while 1 tk_wai_sem sem1 1 else tk_ext_tsk Exit task static void task3 INT stacd VP exinf if stacd 3 while 1 tk_sig_sem sem1 1 else tk_ext_tsk Exit task Figure 4 5 5 Operation Diagram of the Description Example task1 task2 task3 Time 79 CHAPTER 4 WRITING A USER PROGRAM Note While dispatch is on hold the stat
14. E Invoking Task and Other Tasks When a system call is made from a task the calling task is called the invoking task and all other tasks are called other tasks Precedence and Task Priorities The order of execution of program execution units is called the precedence The value that determines the precedence of a task is called the task priority The smaller the value of the task priority the higher the priority Tasks with a higher priority small task priority value have precedence when executing The task priority consists of a base priority current priority and startup priority The term task priority by itself refers to the current priority Q Current priority The current priority is used to determine the execution sequence of the task Base priority The base priority is the base priority of the task and normally has the same value as the current priority When mutex functions are used however the current priority may be changed temporarily in some cases and can differ from the base priority Even in these situations however the modified current priority is restored to the base priority when the mutex function has finished being used see 3 5 1 Mutex Functions Startup priority The startup priority is the priority specified when a task is created and the base priority of the task is initialized to the value of the startup priority when the task starts E Dispatching and Preemption The process of switchin
15. Interrupt handlers and time event handlers Quasi task portion running Extended SVC handlers OS extensions Device driver interface function E Task Portion Running Task portion running are the states in which task programs run This does not include states in which the OS system calls executes or states in which handlers execute which are part of the Non task portion running described below E Non task Portion Running Non task portion running are further subdivided into the three states of transient states task independent portion running and quasi task portion running 1 Transient States Transient States refer to the states in which UT REALOS system call processing is executed on 2 Task indePendent Portion Running Quasi task Portion Running Task independent Portion Running refer to the states in which interrupt handlers and time event handlers are executed Quasi task Portion Running refer to the states in which extended SVC handlers and device driver interface functions are executed 20 CHAPTER 2 BASIC CONCEPTS OF THE un REALOS KERNEL System Calls that can be called Except for system calls such as tk ret int and isig tim that are required to be called from a task independent portion all of the system calls can be called from the task portions and quasi task portions In contrast task independent portions execute in a context that is independent of any tasks and do
16. a system time value of O represents 12 00 00 AM on Ist January 1985 GMT A system time value of 1000 represents 12 00 01 AM on 1st January 1985 GMT Because UT REALOS does not have a function to automatically set the current time when the system starts the current time must be set by the user program 51 CHAPTER 3 uT REALOS FUNCTIONS 3 7 2 Cyclic Handler Functions This section explains the cyclic handler functions E Cyclic Handler Functions Cyclic handlers are time event handlers that activate at a fixed period Table 3 7 2 shows cyclic handler functions and their corresponding system calls Table 3 7 2 Cyclic Handler Functions and Corresponding System Calls Function System Call Name Create cyclic handler tk cre cyc Delete cyclic handler tk del tk sta cyc Start cyclic handler tk cre cyc Specify TA STA to create and start cyclic handler Stop cyclic handler tk stp cyc Refer Cyclic Handler Status tk ref Cyclic handler objects are identified by an ID number The cyclic handler ID number is called the cyclic handler ID The activation interval and activation phase for each cyclic handler can be set when the cyclic handler is created When handling a cyclic handler the kernel determines the time when the cyclic handler should be activated next from the specified activation interval and activation phase When the time when the cyclic handler should activate is reached the cyclic
17. a wait queue of tasks waiting to lock the mutex Furthermore the kernel manages the following objects the tasks that are locking each mutex and the mutexes that are locked by each task A task locks the mutex before using the resource If the mutex is already locked by another task the task waits for the mutex to become unlocked Tasks waiting for the mutex to become unlocked are added to the wait queue for that mutex The wait queue order can be selected from one of the following 2 options FIFO order TA TFIFO e Task priority order TA_TPRI TA INHERIT TA CEILING CHAPTER 3 uT REALOS FUNCTIONS Task priority can be further selected from one of the following 3 options Simple priority order TA TPRI Priority inheritance protocol TA INHERIT e Priority ceiling protocol TA CEILING These are specified as parts of mutex attributes when the mutex is created When the task finishes using the resource the task releases the lock on the mutex If TA INHERIT or TA CEILING attribute is used the current priority of a task that has a lock on a mutex is changed in order to prevent unlimited priority inversion The current priority of a task is changed so that it always equals the highest value from among the following priorities The base priority of the task that is locking the mutex The current priority of the task that has the highest current priority from among the tasks that are waiting to lock that mutex if the ta
18. after hardware reset occurs When the initial routine of a user program is called by the initial task control is passed to the user program having the highest priority task Figure 4 2 1 Start Flow Reset User program Reset entry routine Initialize the kernel Initial task Processes such as initialization of hardware Initialize the inside of the kernel Initialize the device etc Jump to the kernel 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Initial routine 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Create an initial task Start the initial task Create a task etc Process the user program Call the initial routine Pass control to the user task having the highest priority 71 CHAPTER 4 WRITING A USER PROGRAM 4 3 Reset Entry Routine This section explains how to write the reset entry routine E Reset Entry Routine The reset entry routine which is launched by reset performs initialization of the processor and of the peripheral devices for which initial settings are necessary during reset Control is then moved to UT REALOS E Process of Reset Entry Routine The reset entry routine generally performs the following processes Initializing the data area the ARM library mandatory Calls __ main function of the C library and performs the following processing 1 Copies nonroot R
19. and household use but are not designed developed and manufactured as contemplated 1 for use accompanying fatal risks or dangers that unless extremely high safety is secured could have a serious effect to the public and could lead directly to death personal injury severe physical damage or other loss i e nuclear reaction control in nuclear facility aircraft flight control air traffic control mass transport control medical life support system missile launch control in weapon system or 2 for use requiring extremely high reliability i e submersible repeater and artificial satellite Please note that FUJITSU SEMICONDUCTOR will not be liable against you and or any third party for any claims or damages arising in connection with above mentioned uses of the products Any semiconductor devices have an inherent chance of failure You must protect against injury damage or loss from such failures by incorporating safety design measures into your facility and equipment such as redundancy fire protection and prevention of over current levels and other abnormal operating conditions e Exportation release of any products described in this document may require necessary procedures in accordance with the regulations of the Foreign Exchange and Foreign Trade Control Law of Japan and or US export control laws The company names and brand names herein are the trademarks or registered trademarks of their respective owners CopyrightO
20. disabled state an error E CTX occurs if a system call is made where there is a possibility of the currently running task entering the WAITING An error E CTX also occurs if a system call is made to enable or disable dispatching tk dis dsp or tk ena dsp while in the interrupts disabled state The interrupts enabled disabled states can be controlled from a user program by calling the following macros DE Enters the interrupts disabled state EI Enters the interrupts enabled state CHAPTER 2 BASIC CONCEPTS OF THE un REALOS KERNEL 2 6 Precedence of Execution of Tasks and Handlers This section explains the precedence of execution of tasks and handlers E Precedence of Execution Tasks vs Interrupt Handlers and Time Event Handlers Handlers have a higher precedence of execution than tasks For example if a hardware interrupt occurs while a task is executing the execution of the task is suspended and the interrupt handler corresponding to the interrupt is executed When the interrupt handler finishes executing the task resumes execution from the point where it was suspended Figure 2 6 1 Precedence of Execution Tasks vs Interrupt Handlers and Time Event Handlers Precedence of execution Interrupt Interrupt handler occurs Task Time 23 CHAPTER 2 BASIC CONCEPTS OF THE u REALOS KERNEL E Precedence of Execution Tasks vs Tasks The precedence of execution of tasks executes tasks that
21. for RVDS how to create application programs and the procedure User s Guide for building a system This document uT Kernel Specification Compliant Explains the details of the uT REALOS API uT REALOS M3 API Reference How to read This Manual Q Explanation of terminology The terminology used in this manual is described below Kernel The program that provides the OS functionality is called the kernel Refers to application programs that use L T REALOS functions In order to emphasize User program the point that these programs are created by the user these are called user programs in this manual User system Refers to an executable program formed by linking a user program with UT REALOS The group of functions that implement OS functionality and that can be called directly from a user program are called system calls The resources that are handled by the kernel are called objects Specifically this refers Object to semaphores mailboxes and other objects that implement functionality such as tasks synchronization and communications Configuration The configuration definition macros are written in the system configuration file and definition macros act as an interface for setting kernel configuration parameters Idle state The state when there are no tasks ready to execute Thecontents of this document are subject to change without notice Customers are advised to consult with sales
22. from wait state for the rendezvous to terminate Then both tasks are transitioned to run state Task B calls tk acp por first b of Figure 3 5 4 Task B is in wait state for the rendezvous to accept until Task A calls tk cal por The rendezvous is established when Task A calls tk cal por and Task A is in wait state for the rendezvous to terminate while Task B is released from wait state for the rendezvous to accept When Task B calls tk rpl rdv Task A is released from wait state for the rendezvous to terminate Then both tasks are transitioned to run state 45 CHAPTER 3 uT REALOS FUNCTIONS Figure 3 5 4 Rendezvous Operation Task A Task B Task A Task B tk cal por tk acp por Call wait state Accept wait state acp por tk cal por gt Completion wait state Completion wait state tk tk_rpl_rdv a tk cal por called first b tk acp por called first 46 CHAPTER 3 uy REALOS FUNCTIONS 3 6 Memory Pool Management Functions This section explains the memory pool management functions E Memory Pool Management Functions The memory pool management functions are functions for managing memory pools and allocating regions of memory memory blocks for use by user programs The available memory pools are the fixed size memory pool and the variable size memory pool These two memory pools are separate objects and are accessed by differen
23. handler is activated with the extended information exinf of that cyclic handler as a parameter In this case the time when the handler should next activate is set to the time when the cyclic handler should have activated plus the activation interval When the operation of a cyclic handler is started the time when the handler should next activate may need to be reset Cyclic handlers can either be in the operating state or the non operating state When a cyclic handler is in the non operating state the cyclic handler is not activated even when the time when the cyclic handler is supposed to activate is reached and only the time when the handler should next activate is set When the system call to start the operation of the cyclic handler tk sta cyc is called the cyclic handler is placed in the operating state and the time when the cyclic handler should next activate is reset if necessary When the system call to stop the operation of the cyclic handler tk stp cyc is called the cyclic handler changes to the non operating state After the cyclic handler is created either the operating or non operating state is determined by the cyclic handler attributes See Section 4 6 Cyclic Handler for details on the format of cyclic handlers 52 CHAPTER 3 uy REALOS FUNCTIONS Figure 3 7 1 Activation Timing for Cyclic Handlers Activate cyclic Create cyclic handler handler tk cre cyc TA STA present Activation phase Activ
24. handlers Interrupt management functions System state management functions Subsystem management functions Device management functions Power saving functions Configurator Kernel configuration function See CHAPTER 3 SYSTEM CALL INTERFACE of the API Reference for details on the system calls described in this chapter CHAPTER 3 uy REALOS FUNCTIONS 3 2 Task Management Functions This section explains the task management functions E Task Management Functions The task management functions are functions for directly operating and referring to the state of a task Table 3 2 1 shows task management functions and their corresponding system calls Table 3 2 1 Task Management Functions and Corresponding System Calls Function System Call Name Create task tk cre tsk tk del tsk Delete dormant task Delete task tk exd tsk Exits and deletes its invoking task Start task tk_sta_tsk tk_ext_tsk Exits its invoking task Exit task tk_exd_tsk Exits and deletes its invoking task tk_ter_tsk Forcibly terminate other task Change task priority tk_chg_pri Refer Task Status tk_ref_tsk Set Task Registers tk_set_reg Get Task Registers tk_get_reg Tasks are identified by an ID number that is assigned uniquely to each task The task ID number is called the task ID When a task exits the kernel does not release resources acquired by the task semaphore resources memory blocks etc How
25. have a higher priority first If a task with a higher priority than the task that is currently executing enters the READY the currently executing task is suspended and the higher priority task is executed Figure 2 6 2 Precedence of Execution Tasks vs Tasks Precedence of Execution Priority of task 2 changes from 5 to 15 Task2 RUNNING 5 RUNNING priority 2 5 Task 1 RUNNING READY priority 10 dear 22222 L LL CC a eee locu I READY Priority of task 2 Task 2 Y 4 changes from 15 to 5 priority 2 15 24 Time CHAPTER 2 BASIC CONCEPTS OF THE u REALOS KERNEL E Precedence of Execution Handlers vs Handlers In the precedence of execution of handlers interrupt handlers for system exception sources execute with the highest precedence The precedence of execution of other interrupt handlers depends on the hardware interrupt level IL with the interrupt handlers corresponding to interrupts that have a high interrupt level the numerical value of the interrupt level is small executing with precedence Time event handlers execute as extensions of the timer interrupt handler The precedence of execution of time event handlers therefore depends on the interrupt level of the timer interrupt Figure 2 6 3 Precedence of Execution Handlers vs Handlers Precedence of execution Interrupt handler system exception System exception occurs
26. non 22 2 6 Precedence of Execution of Tasks and Handlers 23 CHAPTER 3 yuT REALOS FUNCTIONS 27 3 1 Overview of UT REALOS Functions sss einen 28 3 2 Task Management Functions sse eene enne nennen 29 3 3 Task Synchronization Functions sssssssssssssseeeeenneee nennen nennen nennen 30 3 4 Synchronization and Communication Functions 31 3 4 1 Semaphore Functions nnns nnns 32 3 4 2 Event Flag Functions o nie tere duae mM 34 3 4 3 Mailbox FUNCIONS 2 3 3 d pt lit Ds 35 3 5 Extended Synchronization and Communication Functions 37 3 5 1 FUNCIONS tere a oe mE EEG 38 3 5 2 Message Buffer Functions ooooccccconoccccccnnconcccnonanncnccnnnnnnncnnnnno nn nncnnnnnnncc cnn nn nnne 42 3 5 3 Rendezvous Port FUNCHONS mia at 44 3 6 Memory Pool Management Functions cccconooccccccnnoncccconnnncncnannnncnnnnannn 47 3 6 1 Fixed size Memory Pool Functions occoonooccccccnnonccononanonnncnnnnancnnnnnnnnnnnrnnnnn nn nennen 48 3 6 2 Variable size Memory Pool Functions sseeene enn 49 3 7 Time Management Functions eene nnne nnn 50 3 7 1 System Time Management Functions s
27. state is placed again in the SUSPENDED state the attempt hereof is remembered After that when an attempt is made to resume the task in SUSPENDED state including WAITING SUSPENDED state it is not resumed To realize this the kernel maintains the number of requests of SUSPENDED state nested for each task This is called the suspend request nesting count When the task is started this count is cleared to 0 30 CHAPTER 3 uy REALOS FUNCTIONS 3 4 Synchronization and Communication Functions This section explains the synchronization and communication functions E Synchronization and Communication Functions The synchronization and communication functions are functions for performing synchronization and communication between tasks using task independent objects The synchronization and communication functions support the following functions Semaphore functions e Event flag functions Mailbox functions 31 CHAPTER 3 uT REALOS FUNCTIONS 3 4 1 Semaphore Functions This section explains the semaphore functions il Semaphore Functions Semaphores are objects for representing numerically data of and availability of unused resources called the semaphore count for managing exclusive control and synchronization when using those resources Table 3 4 1 shows semaphore functions and their corresponding system calls Table 3 4 1 Semaphore Functions and Corresponding System Calls Function System Call Name
28. the wait queue can be selected from the two options of FIFO order TA TFIFO and task priority order TA TPRI This is specified as a part of mailbox attributes when the mailbox is created The information that is actually sent and received by the mailbox is only the starting address of a message in memory This means that the contents of messages that are sent and received are not copied The kernel manages the messages in the message queue using a linked list The user program should allocate an area msgque at the top of a message being sent for the kernel to use for the linked list This area is called the message header Furthermore if the message queue is ordered by message priority an area for holding the message priority msgpri also needs to be reserved in the message header The message header and the following area where the application stores the message are collectively called a message packet System calls for sending messages to a mailbox take the starting address of the message packet pk msg as a parameter Furthermore system calls for receiving messages from a 35 CHAPTER 3 uT REALOS FUNCTIONS mailbox return the starting address of the message packet as the return value If the message queue is arranged in the priority order of the message an area for storing the priority order of the message msgpri must exist in the message header Figure 3 4 2 shows the message packet format of priority ordered messages Figur
29. therefore operate as part of the timer interrupt handler Time related handlers that are activated from the timer interrupt handler in this way are called time event handlers As described earlier cyclic handlers execute as part of the timer interrupt handler and a cyclic handler is therefore not interrupted to process other time event handlers while the cyclic handler is running The time when a cyclic handler is first activated is calculated based on the time tick following the time when the cyclic handler is created or activated However if a cyclic handler is created or activated from within a time event handler the time is calculated based on the time when the time event handler was activated The activation time after the first time is calculated based on the time when the cyclic handler was activated Activation Phase The relative time until the cyclic handler is first activated based on the time of the system call that creates the cyclic handler Activation Interval The relative time until the next cyclic handler is activated based on the time when the cyclic handler should have been activated not when it was activated See 3 7 2 Cyclic Handler Functions for details on cyclic handlers CHAPTER 2 BASIC CONCEPTS OF THE un REALOS KERNEL E Alarm Handlers An alarm handler is a program that is activated at a specified time The program that is executed at the specified time is created as an alarm handler and the execu
30. wait queue first TA FIRST or task with smallest request count first TA CNT These are specified as semaphore attributes when the semaphore is created Figure 3 4 1 shows the situation when the semaphore count changes from 1 to 2 in a semaphore with the TA_CNT attribute where Task 1 is skipped and the resources are allocated to Task 2 32 CHAPTER uT REALOS FUNCTIONS Figure 3 4 1 Example of Semaphore Wait Queue Task 1 Task 2 Request Request count 3 count 2 The maximum value of the semaphore count is specified when the semaphore is created The upper limit on the maximum value of the semaphore count is OX7FFFFFFF See Section 3 5 1 1 tk_cre_sem in the API Reference for details 33 CHAPTER 3 uT REALOS FUNCTIONS 3 4 2 Event Flag Functions This section explains the event flag functions E Event Flag Functions 34 Event flags are objects that perform synchronization by representing the presence or absence of events as bit flags Table 3 4 2 shows event flag functions and their corresponding system calls Table 3 4 2 Event Flag Functions and Corresponding System Calls Function System Call Name Create event flag tk_cre_flg Delete event flag tk_del_flg Set event flag tk_set_flg Clear event flag tk_clr_flg Wait Event Flag tk_wai_flg Refer Event Flag Status tk_ref_flg Event flag objects are identified by an ID number The event flag ID number is called the event fla
31. 2 pers Time event handler Timer interrupt handler IL 16 t Interrupt occurs IL 16 Interrupt handler EN y IL 30 Time 25 CHAPTER 2 BASIC CONCEPTS OF THE u REALOS KERNEL 26 CHAPTER 3 uT REALOS FUNCTIONS This chapter explains the functions supported by uw T REALOS 3 1 Overview of uT REALOS Functions 3 2 Task Management Functions 3 3 Task Synchronization Functions 3 4 Synchronization and Communication Functions 3 5 Extended Synchronization and Communication Functions 3 6 Memory Pool Management Functions 3 7 Time Management Functions 3 8 Interrupt Management Functions 3 9 System State Management Functions 3 10 Subsystem Management Functions 3 11 Device Management Functions 3 12 Power Saving Functions 3 13 Kernel Configuration Function 27 CHAPTER 3 uT REALOS FUNCTIONS 3 1 Overview of uL T REALOS Functions This section explains an overview of uT REALOS functions E Overview of uT REALOS Functions uH T REALOS supports the following functions 28 Kernel Task management functions Task dependent synchronization functions Synchronization and communication functions semaphores event flags mailboxes Extended synchronization and communication functions mutexes message buffers rendezvous ports Memory pool management functions fixed length memory pool variable length memory pool Time management functions system time cyclic handlers alarm
32. 2008 2011 FUJITSU SEMICONDUCTOR LIMITED All rights reserved CopyrightO 2006 2008 T Engine Forum All rights reserved This manual is made based on the specification of u Kernel with the formal agreement by the T Engine Forum vi CONTENTS CHAPTER 1 OVERVIEW OF pu T REALOS 1 1 1 Supported Functions wri iiec ee tec E a e ux eee ve pne duo 2 1 2 Structure of PFOGUGL arras Lo erp d Te ra Et e dereud tae 3 1 3 Tools Required for Development ener enne 4 CHAPTER2 BASIC CONCEPTS OF THE uT REALOS KERNEL 5 2 1 System Calls 5 2 eii edite dad duet ote ad ll He Pedes 6 2 2 Execution Units of User Program 7 2 2 1 Eo amd 8 2 2 2 Seria hend b ife da hf ie 12 2 2 8 Interr pt Fandlers ue come od ee aed 13 2 2 4 Time Event Handlets teet e eet de dace 14 2 2 5 Error ROUES 2 edet te rector ee vem Par UT RR AER 16 2 2 6 Extended SVC Handlers tsp a dtd acero ede De ee Do oae 17 2 2 7 Device Processing Functions co tec tele utere nce ce vec ec i Pre oO ER 18 2 3 cet 19 24 SYSIEM SlaleS ttt edat oet ith td 20 2 5 Dispatch and Interrupts Enabled disabled States ooooooccccnnnoccccnconcoonncncnnanonnncnnannnnnnnnnn
33. ALOS Install Directory utkernel 7 M lib build app_fm3 libstr a uT REALOS Install Directory utkernel 7 M lib build app_fm3 libtk a uT REALOS Install Directory utkernel 7 M kernel tkernel build app_fm3 libtkernel a UT REALOS Install Directory utkernel 7 M kernel sysmain build app_fm3 libtstdlib a CHAPTER 5 HOW TO CONSTRUCT A SYSTEM Kernel configuration file for example uT REALOS Install Directory utkernel 7 M smpsys config a Kernel configuration file config a is a library created in the configurator For details on how to add libraries see Workbench IDE User Manual 4 Create a scatter load description file Create a scatter load description file using the scatter file editor of the ARM Workbench IDE For details see Workbench IDE User Manual Section names used by the kernel are listed below Table 5 3 1 Kernel Specific Section List Section name Meaning kernel code sc Kernel code kernel eit sc Vector table kernel const sc Kernel constant data kernel sysinfo sc Control block Kernel data sc Kernel data kernel heap sc Kernel heap kernel sstack sc System stack 99 CHAPTER 5 HOW TO CONSTRUCT A SYSTEM 5 4 Build a User System This section explains how to build a user system Build a user system Build the system on the ARM Workbench IDE For details on how to build it see ARM Workbench IDE User Manual When the sample project included w
34. Create semaphore tk cre sem Delete semaphore tk del sem Signal Semaphore tk sig sem Wait on Semaphore tk wai sem Refer Semaphore Status tk ref sem Semaphore objects are identified by an ID number The semaphore ID number is called the semaphore ID Semaphores have a semaphore count and a wait queue of tasks waiting to acquire resources When m resources are returned from the event notifier side the semaphore count increases by m When n resources are acquired by the event wait side the semaphore count decreases by n When a task attempts to acquire semaphore resources when the number of resources is insufficient specifically when the semaphore count reduces to a negative value a task attempting to acquire resources goes into WAITING until the next time resources are returning A task waiting for semaphore resources is linked to the wait queue of that semaphore Furthermore a maximum resource count can be configured on each semaphore to prevent too many resources from being returning An error occurs when resources whose semaphore count exceed the maximum are returned to a semaphore specifically when the semaphore count increases and exceeds the maximum semaphore count The order of the wait queue can be selected from the two options of FIFO order TA TFIFO and task priority order TA TPRI Furthermore the precedence of resource acquisition can be selected from the two options of task at head of
35. Definition Macros 62 Configurator Display Format of Configurator Error Messages ONERE PNIS AT ME 103 Error Message Categorization of the Configurator seen 102 Setting of Configuration esses 66 Creating Creating a Close Function closefn 89 Creating 77 Creating a Wait Completion Function waitfn ER MEM ERE 90 Creating an Abort Execute Function abortfn MR 90 Creating an Alarm Handler 82 114 Creating an Event Function eventfn 90 Creating an Execute Start Function execfn 89 Creating an Open Function openfn 88 Creation Creation of a Cyclic Handler 81 Cyclic Handler Creation of a Cyclic Handler 81 Cyclic Handler Functions 52 Cyclic Handlers enirn 14 Description Format of a Cyclic Handler 81 Launch of a Cyclic Handler 81 D Description Example Description Example of the Initial Routine 76 Description Format Description Format of a Cyclic Handler 81 Description Format of a Power Saving Routine 86 Description Format of an Alarm Handler 82 Description Format of an Error Routine 85 Description Format of an Extension SVC Handler eene 87 Description Form
36. FINT of configuration definition macro as 1 On using an interrupt vector table located in ROM rea setting KERNEL USE TKDEFINT to 0 will allow the kernel to cancel copying the vector table from the ROM to the RAM Therefore memory used by the kernel can be reduced Whether to register an interrupt handler through a static API or tk def int is optional depending on processing of the user program Registration through a static API has advantages in reducing the codes for operation of registration through tk def int 67 CHAPTER 3 uT REALOS FUNCTIONS 68 CHAPTER 4 WRITING A USEH PROGRAM This chapter describes the basic items in writing a user program on uT REALOS 4 1 Configuring a User Program 4 2 Activation Flow 4 3 Reset Entry Routine 4 4 Initial Routine 4 5 Task 4 6 Cyclic Handler 4 7 Alarm Handler 4 8 Interrupt Handler 4 9 Error Routine 4 10 Power Saving Routine 4 11 Extension SVC Handler 4 12 Device Driver 4 13 Notes when Writing a User Program 69 CHAPTER 4 WRITING A USER PROGRAM 4 1 Configuring a User Program This section explains how to configure a user program E Configuring a User Program A user program consists of the modules in Table 4 1 1 Build the user system after creating modules necessary for the user system Table 4 1 1 User Program Configuration Elements Module name Reset entry routine Processing overview This routine is first launched by the hard
37. OPNDEV KERNEL MAX REQDEV 66 CHAPTER uT REALOS FUNCTIONS For definition of maximum number of object see BI Configuration Definition Macros in this section Definition of priority maximum value Defines the maximum priority value of a task and subsystem Similar to the maximum object value when the value defined for the task priority becomes smaller consumed memory of kernel can be reduced When Task Priority is P its consumed memory can be calculated according to following formula Consumed Memory byte 8 x P 4 x P 32 Definition of system stack size and stack size of the initial task Specifies the size of system stack and stack size of initial task For specification method of these stack sizes see B Configuration Definition Macros in this section Registration of the initial routine and error routine When using the initialization routine or error routine perform the registration through the static API For registration method of these routines see I Configuration Definition Macros 4 4 Initial Routine in this section and 4 9 Error Routine Registration of an Interrupt Handler On using an interrupt handler register it through a static API After the system startup dynamic registration of interrupt handler through tk def int is also available In the case of dynamic registration registration through a static API will be not necessary In addition in such a case define KERNEL USE TKDE
38. REALOS project using the ARM Workbench IDE are shown below 1 Create a RealView project Start the ARM Workbench IDE to create a RealView project and add a user file For details of how to create a RealView project and add a file see Workbench IDE User Manual 2 Set uL T REALOS kernel include paths In order to use ui T REALOS functions set the following directory include paths for a RealVeiw project uT REALOS Install Directory utkernel 7 M kernel tkernel srce uT REALOS Install Directory utkernel 7 M kernel tstdlib uT REALOS Install Directory utkernel 7 M kernel sysdepend cpu fm3 uT REALOS Install Directory utkernel 7 M kernel sysdepend device app_fm3 uT REALOS Install Directory utkernel 7 M include Set the include paths as follows Select Project gt Properties in the ARM Workbench IDE menu Select C C General gt Settings in the tree Select ARM RealView Compiler 4 0 gt Directory on the Tool Settings tab Push Add for a user include path After the path is added push OK Add all the paths Select ARM RealView Assembler 4 0 gt Directory on the Tool Settings tab Push Add for a user include path After the path is added push to add all the paths WN 3 Add u T REALOS kernel libraries In order to use UT REALOS functions add the following libraries to the Real View project uT REALOS Install Directory utkernel 7 M lib build app_fm3 libtm a uT RE
39. TS OF THE u REALOS KERNEL 2 1 System Calls This section explains the system calls which act as interfaces for using kernel functions from the user program E System Calls The interfaces for calling kernel functions from a user program are called system calls The system calls conform to the uT Kernel specifications See CHAPTER 3 SYSTEM CALL INTERFACE of the API Reference for details on the system calls CHAPTER 2 BASIC CONCEPTS OF THE un REALOS KERNEL 2 2 Execution Units of User Program This section explains the execution units of a user program E Execution Units of User Program The execution units of a user program are listed below Tasks Initialization routines Interrupt handlers Time event handlers Error routines Extended SVC handlers Device processing functions CHAPTER 2 BASIC CONCEPTS OF THE u REALOS KERNEL 2 2 1 Tasks This section explains tasks B Tasks Tasks are the program execution unit that form the basis of user program processing HT REALOS saves the state prior to the interrupt register values on a per task basis if the execution of a task is interrupted This is called the task context The information saved in the task context can be used to resume execution of the interrupted task Tasks have a variety of states including the run state ready state wait state etc See Task Portion Transitions for details on the task portion transitions
40. The system state management functions are functions for changing and referring to the state of the system Table 3 9 1 shows system state management functions and their corresponding system calls Table 3 9 1 System State Management Functions and Corresponding System Calls Rotate Ready Queue tk rot Get Task Identifier tk get tid Disable dispatch tk dis dsp Enable dispatch tk ena dsp Refer System Status tk ref sys Refer Version Information tk ref ver 56 CHAPTER uT REALOS FUNCTIONS 3 10 Subsystem Management Functions This section explains the subsystem management functions il Subsystem Management Functions The subsystem management functions consist of the extended SVC handlers for accepting requests The subsystem management functions provide the following functions depending on the corresponding system calls Table 3 10 1 shows subsystem management functions and their corresponding system calls Table 3 10 1 Subsystem Management Functions and Corresponding System Calls Define subsystem tk def ssy Refer Subsystem Status tk ref ssy 57 CHAPTER 3 uT REALOS FUNCTIONS 3 11 Device Management Functions This section explains the device management functions E Device Management Functions Device management functions provide a common API for handling different devices Table 3 11 1 shows device management functions and their corresponding system calls Table 3 11 1 Device Ma
41. _mbf e Receive from message buffer wait state waiting due to tk rcv mbf e Fixed length memory block acquisition wait state waiting due to tk get mpf Variable length memory block acquisition wait state waiting due to tk get mpl e Rendezvous call termination wait state waiting due to tk cal por e Rendezvous accept wait state waiting due to tk por SUSPENDED The state where execution has been forcefully suspended by another task WAITING SUSPENDED This state is both WAITING and SUSPENDED at the same time DORMANT The state where the task has not yet been started or the task has ended NON EXISTENT The state where the task has not yet been created or the task has been deleted CHAPTER 2 BASIC CONCEPTS OF THE u REALOS KERNEL E Task Portion Transitions The state transitions for tasks are shown below Figure 2 2 1 Task Portion Transitions Dispatch READY RUNNING le Preempt FE A A Release Wait wait condition WAITING o Terminate 2d WAITING Terminate SUSPENDED cleared Suspend A Terminate SUSPENDED Resume Start Terminate y DORMANT gt 4 Terminate Exit cet Exit and delete NON EXISTENT 4 10 Multiple ready state tasks are scheduled controlling execution order according to task p
42. able into the kernel configuration file that is finally output by the configurator A vector table file is output as eit vector s Uses ARM tools RVDS This parameter cannot be omitted Startup example ftcfs f C ut_realos utkernel 7 M smpsys smpsys tcf cpu CM3 out C ut_realos utkernel 7 M smpsys RVDS Notes When configuration is executed a file is created temporarily in the directory defined by the environment variable TMP A sample configuration file is stored in the following directory uT REALOS Install Directory utkernel 7 M smpsys smpsys tcf Options inside the may be omitted 96 CHAPTER 5 HOW TO CONSTRUCT A SYSTEM 5 3 Create the uT REALOS Project This section describes how to create the uT REALOS Project on ARM Workbench IDE E Steps for Creating the uT REALOS Project Create the uT REALOS project using the following steps Figure 5 3 1 Steps for Creating the uT REALOS Project Start Create a RealView project uT REALOS kernel include paths uT REALOS kernel libraries Create a scatter load description file 97 CHAPTER 5 HOW TO CONSTRUCT A SYSTEM E Sample Program of uT REALOS A sample program of T REALOS is stored in the following directory uT REALOS Install Directory utkernel 7 M smpsys If you wish to create a new UT REALOS project see the following descriptions in this chapter E Create a uT REALOS Project 98 Steps for creating a UT
43. alls the main function and initializes the data area Initialization processing of the ARM library is not performed in the following description example See ARM Developer Suite Compiler and Library Guide of ARM for details on main function processing Figure 4 3 2 Description Example of Initializing the Data Area the ARM Library IMPORT _ main B main EXPORT rt entry rt entry Setting the privileged mode MSP In the following example the mode is set as the privileged mode uT REALOS always operates in the privileged mode and the address of the main stack is set in the MSP register Figure 4 3 3 Description Example of Setting the privileged mode MSP MSP setting mov rO 0 Use MSP stack privileged mode msr control rO isb Idr 0 kernel MSP stack top Set main stack address msr msp rO Starting the kernel Jumps to the label of knl start main to start the kernel Figure 4 3 4 Description Example of Starting the kernel IMPORT knl start main Idr ip knl_start_main mov rO 0 bx ip 74 CHAPTER 4 WRITING A USER PROGRAM 4 4 Initial Routine This section explains how to write the initialization routine E Process of the Initial Routine The initial routine is called from the initial task created during initialization of the kernel Although the initial routine can be described freely in accordance with the user program it generally performs the fol
44. at of an Interrupt Handler LEE 83 Description Format of the Initial Routine 75 Description Format of the Task 77 Development Tools Required for Development 4 Device Determining A Device Name 88 Device Driver Interface 88 Device Management Functions 58 Device Processing Functions 18 Device Driver Interface Device Driver Interface 88 Device Management Device Management Functions 58 Device Name Determining A Device Name 88 Dispatch Dispatch Enabled disabled States 22 Dispatching Dispatching and Preemption 8 Display Format Display Format of Configurator Error Messages re 103 Driver Device Driver Interface 88 E Error Message Display Format of Configurator Error Messages m 103 Error Message Categorization of the Configurator eeeeeessess 102 Error Messages 105 Fatal Error 108 Error Routine Description Format of an Error Routine 85 Error Routines testar 16 Registering an Error Routine 85 Event Flag Event Flag Functions ees 34 Event Function Creat
45. ation interval Activation interval Activation interval cycphs cyctim cyctim cyctim a TA STA specified Activate cyclic Create cyclic handler handler tk cre cyc Per zd Start cyclic TA STA not present handler tk sta cyc Activation phase Activation interval Activation interval Activation interval cycphs cyctim cyctim cyctim b TA STA not specified TA specified Activate cyclic Create cyclic handler handler tk cre cyc NN TA no Start cyclic E N TA_STA not present handler E c tk sta cyc Activation phase Activation interval Activation interval Activation interval cycphs cyctim cyctim cyctim c STA not specified TA not specified For details on TA PHS see 3 8 2 1 tk cre cyc Create Cyclic Handler in API Reference 53 CHAPTER 3 uT REALOS FUNCTIONS 3 7 3 Alarm Handler Functions This section explains the alarm handler functions E Alarm Handler Functions Alarm handlers are time event handlers that activate at a specified time Table 3 7 3 shows alarm handlers functions and their corresponding system calls Table 3 7 3 Alarm Handlers Functions and Corresponding System Calls Function System Call Name Create alarm handler tk_cre_alm Delete alarm handler tk_del_alm Start alarm handler tk_sta_alm Stop alarm handler tk_stp_alm Refer Alarm Handler Status tk_ref_alm Alarm handler objects are identified by an ID number The alarm handler ID numbe
46. aximum value for the number of objects that the user program uses The objects can be created up to this maximum value and used in the user program Therefore define the maximum value using a value bigger than the number of objects that are used in the user program For example when 3 semaphores are used in the user program define the configuration specification macro KERNEL MAX SEM as 3 In such a case the program can operate without problems even it is defined as 10 However since 10 semaphore control areas are ensured in kernel the 7 unused control areas will become useless Therefore it is necessary to define the maximum number of objects used in application in order to optimize usage efficiency of memory It is unnecessary to define objects not used in the user program Table 3 13 3 displays number of bytes of memory consumed in kernel for each object Table 3 13 3 Consumed Memory of Object Management Block Configuration Management area size specification macro byte Object name Task KERNEL MAX TSK Semaphore KERNEL MAX SEM Event Flag _ MAX FLG Mailbox KERNEL MAX MBX Mutex KERNEL MAX MTX Message Buffer KERNEL MAX MBF Rendezvous Port KERNEL MAX POR Fixed size Memory Pool KERNEL MAX MPF Variable size Memory Pool KERNEL MAX MPL Cyclic Handler KERNEL MAX CYC Alarm Handler KERNEL MAX ALM Subsystem KERNEL MAX SSY KERNEL MAX REGDEV Device KERNEL MAX
47. be made while the task independent portion or dispatch is disable When calling is disabled an CTX error or exception may occur For availability of calling see 3 1 System Call List of API Reference in addition operations cannot be guaranteed when isig tim or tk ret int is called from the task section Omitting the error check of a system call Check for entry address and packet address will not be performed Specifying an illegal address may cause an abnormal operation 91 CHAPTER 4 WRITING A USER PROGRAM 92 CHAPTER 5 HOW TO CONSTRUCT A SYSTEM This chapter explains how to construct a user system 5 1 Steps of Constructing a System 5 2 Kernel Configuration 5 3 Create the uT REALOS Project 5 4 Build a User System 93 CHAPTER 5 HOW TO CONSTRUCT A SYSTEM 5 1 Steps of Constructing a System This section explains steps of constructing a system including compiling and kernel configuration of a user program for uL T REALOS E Steps of System Construction Construct the user system of UT REALOS using the following steps Figure 5 1 1 Steps of Constructing a System Execute kernel configuration Create the uT REALOS project Build the user system 94 CHAPTER 5 HOW TO CONSTRUCT A SYSTEM 5 2 Kernel Configuration This section explains how to execute kernel configuration and create a kernel configuration file E Setting Environment Variables Set directories suited for the follow
48. ccording to precedence Tasks A and B are transitioned into run state or ready state Task B calls tk rcv mbf first b of Figure 3 5 3 Task B waits to receive the message buffer until Task A calls tk snd mbf When Task A calls tk mbf the message is transmitted from Task A to Task B Then according to precedence Tasks A and B are transitioned into run state or ready state Figure 3 5 3 Synchronous Communication Using a Message Buffer Task A Task B Task A Task B tk snd mbf tk rcv Send wait state Receive wait state gt ik rcv mbf tk_snd_mbf a tk snd mbf called first b tk rcv mbf called first Tasks that are waiting to send to a message buffer send messages in the order that they are linked to the wait queue For example consider the situation where Task A which is attempting to send a 40 byte message to the message buffer and Task B which is attempting to send a 10 byte message and these tasks are linked into the wait queue in this order Now suppose that 20 bytes of free space are created by another task receiving a message In this situation Task B is unable to send its message until Task A sends its message Message buffers are different from mailboxes because they transfer variable length messages by copying 43 CHAPTER 3 uT REALOS FUNCTIONS 3 5 3 Rendezvous Port Functions This section explains the rendezvous port functions BB Rendezvous Port Functions 44 Re
49. chnical Reference Manual Note To activate the interrupt handler a 32 byte stack is automatically consumed for each 1 level interrupt Bear this in mind when you are to design the system stack size E Registering an Interrupt Handler An interrupt handler can be registered in the following two ways e Register an interrupt handler during kernel configuration using static API DEF INH To perform operations with the vector table placed in the ROM register an interrupt handler using static API In the example below the timer interrupt handler of vector number 15 SysTick Handler is registered as an interrupt handler Figure 4 8 2 Example of Registering an Interrupt Handler Using Static API DEF INH 15 TA HLNG VTA SRSV SysTick Handler Calltk def int from a user program to dynamically register an interrupt handler Before executing kernel configuration set KERNEL USE TKDEFINT of the configurator specification macro to 1 In the example below the timer interrupt handler of vector number 15 SysTick Handler is registered as an interrupt handler 83 CHAPTER 4 WRITING A USER PROGRAM Figure 4 8 3 Example of Registering an Interrupt Handler Through a User Program T DINT dint ER err dint intatr TA HLNGJ Attribute dint inthdr 2 SysTick Handler Start address of the interrupt handler err 2 tk def int 15 amp dint Register the interrupt handler E Timer Interrupt Ha
50. chronization and communication functions support the following functions Mutex functions Message buffer functions Rendezvous port functions 37 CHAPTER 3 uT REALOS FUNCTIONS 3 5 1 Mutex Functions This section explains the mutex functions B Mutex Functions 38 Mutexes are objects that perform exclusive control between tasks that use a shared resource Table 3 5 1 shows mutex functions and their corresponding system calls Table 3 5 1 Mutex Functions and Corresponding System Calls Function System Call Name Create mutex tk cre mtx Delete mutex tk del mtx Lock mutex tk loc mtx Unlock mutex tk unl mtx Refer Mutex Status tk ref mtx The mutexes support the priority inheritance protocol and priority ceiling protocol as a mechanism to prevent priority inversion due to unlimited exclusive control Generally priority inversion refers to a phenomenon where due to one task having obtained resources another task with higher priority cannot operate To prevent this the priority inheritance protocol sets the highest priority of task groups which share resources on a task which has obtained resources On the other hand the priority ceiling protocol sets ceiling priority for each resource and sets this priority on a task which has obtained resources Mutex objects are identified by an ID number The mutex ID number is called the mutex ID Mutexes have a state that can be locked or unlocked and
51. ct or group of products The company names and brand names herein are the trademarks or registered trademarks of their respective owners il Overall Structure of This Manual This manual consists of five chapters and an appendix as follows CHAPTER 1 OVERVIEW OF uT REALOS This chapter explains an overview of uT REALOS uT REALOS is a uT Kernel specification real time OS that runs on the FM3 family uT REALOS is conforms to the Uu T Kernel specifications CHAPTER 2 BASIC CONCEPTS OF THE uU T REALOS KERNEL This chapter explains the basic concepts that are required to understand the uT REALOS kernel CHAPTER 3 yu T REALOS FUNCTIONS This chapter explains the functions supported by uT REALOS CHAPTER 4 WRITING A USER PROGRAM This chapter describes the basic items in writing a user program on UT REALOS CHAPTER 5 HOW TO CONSTRUCT A SYSTEM This chapter explains how to construct a user system APPENDIX The appendix explains error messages of the configurator BB Reference Manuals See the manuals listed below as required while using this system Cortex M3 Technical Reference Manual e uT Kernel Specification e uT REALOS M3 API Reference E Organization of the uT REALOS Manuals The uT REALOS manuals are divided into the following three volumes First time users of UT REALOS should read the uT REALOS M3 User s Guide first uT Kernel Specification Compliant Explains the overall functionality of uT REALOS u T REALOS MG
52. d states and the interrupts enabled disabled states E Dispatch Enabled disabled States During execution of a user program the dispatcher is either in the dispatch disabled state or the dispatch enabled state After system initialization the dispatcher is in the dispatch enabled state when the initial task begins executing In the dispatch disabled state the system does not switch the task that is in the RUNNING While in the dispatch disabled state an error E CTX occurs if a system call is made where there is a possibility of the currently running task entering the WAITING However interrupt handlers cyclic handlers and alarm handlers remain active The dispatch disabled enabled states can be controlled from a user program by calling the following system calls tk dis dsp Enters the dispatch disabled state tk ena dsp Enters the dispatch enabled state B Interrupts Enabled disabled States 22 During execution of a user program the system is either in the interrupts disabled state or the interrupts enabled state After system initialization the system is in the interrupts enabled state when the initial task begins executing In the interrupts disabled state all external interrupts are disabled such that control is not passed to an interrupt handler even if a hardware interrupt occurs Furthermore if dispatching is also disabled then the system does not switch from the currently running task While in the interrupts
53. dules such as interrupt handlers and the initial routine A definition statement used to register user program modules in the kernel configuration function is called a static API When kernel configuration is executed the configuration definition macros and static API are written in a text format file called the configuration file and the Configurator is executed with this as the input file Configurator takes the configuration file as the input file and outputs the kernel configuration file in the library format The kernel configuration file must be linked with the user program when an object of the executable format is created See Section 5 2 Kernel Configuration for details on how to execute the configurator and parameters during exection 61 CHAPTER uT REALOS FUNCTIONS E Configuration Definition Macros The configuration definition macros are macros provided for user defined kernel configurations A list of the configuration definition macros is given below Table 3 13 1 List of Configuration Definition Macros Function type Meaning Range of values default values shown in bold KERNEL MAX TSKPRI Maximum task priority 1to 1024 Priority KERNEL INIT TSKPRI Initial task priority 1to 1024 definitions KERNEL MAX SSYPRI Maximum subsystem priority 1to 16 KERNEL USE TKDEFINT Use or not use tk def int 1 means use 0
54. e 3 4 2 Message Packet Format Message header Note The size of msgque and msgpri are 4 bytes each The msgpri area must be provided when the messages Message packet Transmitted received in the message queue are message priority ordered An error may be returned if the msgpri area is not provided Additional Notes 36 Because the mailbox functions allocate the area for the message header by the user program there is no upper limit on the number of messages that can be placed in a message queue Furthermore the system calls for sending messages do not enter the WAITING state Message packets are able use memory blocks dynamically allocated from the fixed size memory pool or variable size memory pool or statically allocated regions Typical usage is for the sending task to allocate a memory block from the memory pool and send this as a message packet and for the receiving task to directly release the memory block back to the memory pool after reading the contents of the message CHAPTER 3 uT REALOS FUNCTIONS 3 5 Extended Synchronization and Communication Functions This section explains the extended synchronization and communication functions E Extended Synchronization and Communication Functions The extended synchronization and communication functions are functions for performing high level synchronization and communication between tasks using task independent objects The extended syn
55. e transition is delayed until the state enters into where dispatch occurs when moving the tasks during execution to the forcible waiting state and the stop state In such a case although tasks being executed will retain the execution status the processing of transition to the forcible waiting state or the stop state is already being executed 80 CHAPTER 4 WRITING A USER PROGRAM 4 6 Cyclic Handler This section explains how to write a Cyclic handler E Description Format of a Cyclic Handler The cyclic handler is described as follows Figure 4 6 1 Description Example of a Cyclic Handler void cychdr1 VP exinf Process the Cyclic handler return Terminate the Cyclic handler E Creation of a Cyclic Handler tk cre cyc is called to create a cyclic handler In the example below a cyclic handler with the start period of 1 second 1000ms for the function cychdr1 is created When creation of a cyclic handler normally ends the cyclic handler ID is returned as the return value Figure 4 6 2 Description Example of the Cyclic Handler Creation ID cycid1 Cyclic handler ID T CCYC Input parameter of tk cre cyc ccycexinf 1 Extension information 1 ccyc cycatr TA HLNG TA STA Attribute cychdr1 Start address of the Cyclic handler ccyc cyctim 1000 Start Cyclic ccyc cycphs 0 Start phase cycid1 tk_cre_cyc amp ccyc
56. ead Only and Read Write execution areas into each load address 2 BSS Block Started by Symbol area is initialized by 0 3 Branches into rt entry Figure 4 3 1 Initialization Flow in Data Area Reset entry routine Start ARM library r 11 11 1 Fo gd 11 11 11 TI H i Copies nonroot execution area to load address l 11 I 1 1 BSS area initialized I by 0 l 11 rt entry 1 l 11 11 I 11 A 11 l End 11 11 blllccc e gt 1 72 CHAPTER 4 WRITING A USER PROGRAM Setting the privileged mode MSP mandatory Performs the following processing 1 Sets the privileged mode 2 Sets the main stack address used while the kernel and the exception handler are operating to the MSP register Starting the kernel mandatory Starts the kernel allowing it to jump to the label of knl start main by the BX command of the assembly language 73 CHAPTER 4 WRITING A USER PROGRAM A specific Example of the Reset Entry Routine The description examples for each process of the reset entry routine are shown below The source codes are attached to the product as a sample program icrt0 asm of UT REALOS e Initializing the data area the ARM library C
57. emaphore Functions 32 specific Example A specific Example of the Reset Entry Routine EDS 74 A specific Example of the Task 78 Starting Starting a Tasko 78 Starting an Alarm Handler 82 Static API Static ues dos en estat 64 Subsystem Subsystem Management Functions 57 Subsystem Management Subsystem Management Functions 57 SVC Calling Format of an Expansion SVC Handler 87 Description Format of an Extension SVC Handler nn 87 Extended SVC Handlers 17 Synchronization Extended Synchronization and Communication Functions ern 37 Synchronization and Communication Functions HQ 31 System Notes on the Overall of a System Call 91 System Calls System Calls i 6 System Calls that can be called 21 System Construction Steps of System Construction 94 System State System State Management Functions 56 System States erede 20 User Programs and System States 21 INDEX System State Management System State Management Functions 56 System Time System ME kee eee erre 51 System Time Management Functions System Time Management Functions 51 T Ta
58. embler or linker executed inside the configurator For messages output by the compiler assembler or linker see the corresponding manual APPENDIX A Error Messages of the Configurator E Display Format of Configurator Error Messages Error messages are output in the following formats File name line number XnnnnT Message text Assist message Section Description File name Configuration file name and line number where the error occurred Line number Output when error occurred while reading the configuration file Error level is expressed using one of the following three characters W Warning message E Error message F Fatal error message Error number The error number and error level are associated as follows 1000 to 1999 4000 to 4999 9000 to 9999 Tool identification is expressed using the following character M Configurator Message text Error message text More detailed information on the error Assist message The symbol name indicating the error occurrence is output It may be output to the error message body Note An error may occur at the complier assembler or linker launched by the configurator For details of an error in such a case see the corresponding manual 103 APPENDIX A Error Messages of the Configurator E Warning Messages 104 W1130M Multiple definition definition name The definition output in the definition name was duplicated
59. en UT Kernel specification OSs See CHAPTER 4 DEVICE DRIVER INTERFACE of the API Reference for details on the device driver interface 59 CHAPTER 3 uT REALOS FUNCTIONS 3 12 Power Saving Functions This section explains the power saving functions E Power Saving Functions The ML T REALOS supports a function to call a user defined power saving routine when it has switched to the idle state This is called the power saving function The processing performed by the power saving routine can be written freely by the user to suit the target hardware This power saving routine is useful because it is defined using the static API of the configurator See 3 13 Kernel Configuration Function for details on how to define the power saving routine and to 4 10 Power Saving Routine for details on writing the power saving routine 60 3 13 CHAPTER 3 uy REALOS FUNCTIONS Kernel Configuration Function This section explains the kernel configuration function E Kernel Configuration Function The kernel configuration function provide the functionality for the user to define the configuration of the kernel such as upper limits on the number of resources used by the kernel and to configure the internal kernel management data based on this The amount of memory used by the kernel can be reduced by optimizing the kernel configuration to suit the user program This also provides functions for statically registering user program mo
60. er based on the device driver interface For details of a device driver see CHAPTER 4 DEVICE DRIVER INTERFACE of API Reference E Determining A Device Name Device name is the name granted to the type unit of a device using up to 8 bytes A device name using the following format Figure 4 12 1 Format of a Device Name A device name consists of the following elements Type indicating the type of a device Characters that can be used are a z A Z Unit A number indicating the physical device Characters that can be used are a z Specified using a single character Assigned for each unit starting with a Sub unit A number indicating the logical device Characters that can be used are numbers between 0 254 not exceeding 3 digits Assigned for each sub unit starting with 0 E Creating an Open Function openfn An open function is called from the kernel when tk opn dev is called from a user program An open function makes preparation to access the device data For details of an open function see Open function openfn of Section 4 11 Device Processing Function in API Reference Figure 4 12 2 Description Format of Open Function openfn ERercd openfn ID devid UINT omode VP exinf Device open processing 88 CHAPTER 4 WRITING A USER PROGRAM E Creating a Close Function closefn A close function is called from the kernel when tk cls dev is called from a user program Calling a cl
61. ever mutex locks are released see 3 5 1 Mutex Functions When a task exits ensure that the user program releases the resources that the task acquired 29 CHAPTER 3 uT REALOS FUNCTIONS 3 3 Task Synchronization Functions This section explains the task synchronization functions Task Synchronization Functions The task synchronization functions are functions for performing synchronization by directly operating task portions Table 3 3 1 shows task synchronization functions and their corresponding systems calls Table 3 3 1 Task Synchronization Functions and Corresponding System Calls Function System Call Name Sleep task tk_slp_tsk Wakeup task tk_wup_tsk Cancel Wakeup Task tk_can_wup Release Wait tk rel wai Suspend Task tk sus tsk tk rsm tsk Resume wait task tk frsm tsk Force Resume Task Delay task tk dly tsk Wakeup requests for a task are queued That is when an attempt is made to wake up a task that is not in the sleep state the attempt is remembered After that when the task is to go to a sleep state it does not enter that state To realize this the kernel maintains the number of wakeup requests that have been queued for each task This is called the wakeup request queuing count When the task is started this count is cleared to 0 Futhermore suspend requests for a task are nested That is if a task that is already in the SUSPENDED state including WAITING SUSPENDED
62. explains the device processing functions E Device Processing Functions 18 A device processing function is used when a device driver function is called by a device management function If a device processing function is called by a task portion it is executed as a task portion If it is called by a task independent portion it is executed as a task independent portion For details on device processing functions refer to 3 11 Device Management Functions CHAPTER 2 BASIC CONCEPTS OF THE un REALOS KERNEL 2 3 Objects This section explains objects E Objects HT REALOS supports a variety of functions including synchronization communication between tasks exclusive control and acquisition release of memory regions The resources that operate on system calls in order to use these functions from a user program are called objects The following objects are supported by UT REALOS Table 2 3 1 List of Objects Object Synopsis Task The task is object in the most fundamental unit that makes up a user program Semaphores are objects for representing numerically the number and availability of Semaphore unused resources and for managing exclusive control and synchronization when using those resources Event flags are objects that perform synchronization by representing the presence or Event 8 absence of events as bit flags Mailboxes are objects that perform synchronization and communication by receiving
63. g ID Event flags contain a bit pattern where each bit represents the presence or absence of the corresponding event and a wait queue of tasks waiting for those event flags Sometimes the bit pattern of an event flag is simply called the event flag The event notifier side can set or clear the specified bits of the event flag The event wait side can bring a task to the event flag wait state until all or some of the specified bits of the event flag are set A task waiting for event flag is linked to the wait queue of that event flag The order of the wait queue can be selected from the two options of FIFO order TA_TFIFO and task priority order TA_TPRI This is specified as a part of flag attributes when the flag is created The conditions for release from the event flag wait state can specify either of the two attributes of AND wait TWF_ANDW or OR wait TWF_ORW These attributes specify how the release from WAITING state operates when waiting for multiple events For the AND wait the WAITING state is not released until all of the events are signaled whereas for the OR wait the WAITING state is released when even one of the events being waited for is signaled It is also possible to specify whether or not to clear the bits when the wait is released TWF_CLR can be used to clear all bits while TWF_BITCLR can be used to selectively clear bits corresponding to event flag wait criteria UT REALOS manages event generation using 32 bit patterns
64. g between running tasks is called dispatching The process of a task that is in the run state losing the execution right is called preemption The functionality within the kernel that implements dispatching is called the dispatcher Dispatching occurs when a task that has a higher priority than the currently executing task enters the ready state Preemption occurs when a dispatch occurs or an interrupt handler is activated while a task is executing CHAPTER 2 BASIC CONCEPTS OF THE un REALOS KERNEL BB Task Portions Tasks have the following states RUNNING The state where the task is running However if a non task portion is being executed the task executed prior to the non task portion is executed READY The state where the task is ready to execute but is unable to run because a task that is higher in the precedence is currently running WAITING The state where execution has been suspended due to calling a system call with some kind of wait condition This is categorized into the following states depending on the wait condition Wakeup wait state waiting due to tk_slp_tsk Elapsed time wait state waiting due to tk_dly_tsk Semaphore resource acquisition wait state waiting due to tk wai sem Event flag wait state waiting due to tk wai flg Receive from mailbox wait state waiting due to tk rcv mbx Mutex lock wait state waiting due to tk loc mtx Send to message buffer wait state waiting due to tk_snd
65. hat cannot be selected in the selection item is specified E4133M Symbol is already defined symbol name A symbol that has already been defined was redefined This error occurs mainly when the task or event flag names specified by API are duplicated E4136M Illegal size or address value The specified size or address is not correct E4142M Device open count is bigger than semaphore count MAX value Set the value of device open count or more to the value of the maximum semaphore count Increase the value of the maximum semaphore count APPENDIX A Error Messages of the Configurator E4402M API ID exceed maximum area definition parameter More APIs output by parameter were defined than the value defined by the maximum area This error occurs even when the API is defined with no maximum area defined 107 APPENDIX A Error Messages of the Configurator E Fatal Error Messages 108 F9000M Environment variable not found environment variable name The environment variable output in environment variable name is not defined F9001M Insufficient memory Insufficient memory for program execution F9002M Not configurated Q o mh E e o 5 un 3 o et 3 Cc zi B Cc a This error occurs when execution is interrupted due to an error during configuration F9011M Input file is not found file name The specified input file is not found F9016M Error read error f
66. hat is run when the kernel detects some kind of error The error routine is activated under the following conditions System Down An internal kernel inconsistency is detected Initial Settings Error An error occurs during kernel initialization Undefined Interrupt An interrupt occurs that does not have a defined interrupt handler The error routine is used for the purpose of debugging the user program There is no way to recover from the error routine Therefore if the error routine has been called clear the cause of the error and restart the system If an error routine is called in the initial setting error it is executed as a task portion Otherwise it is executed as a task independent portion For details on task portions and task independent portions see 2 4 System States 16 CHAPTER 2 BASIC CONCEPTS OF THE u REALOS KERNEL 2 2 6 Extended SVC Handlers This section explains extended SVC handlers E Extended SVC Handlers An extended SVC handler is a handler that accepts request for subsystem When called from a task portion it is executed as a quasi task portion When called from a task independent portion it is executed as a task independent portion For details on subsystems refer to 3 10 Subsystem Management Functions and for details on quasi task portions refer to 2 4 System States 17 CHAPTER 2 BASIC CONCEPTS OF THE u REALOS KERNEL 2 2 7 Device Processing Functions This section
67. hronization and communication functions semaphores event flags mailboxes Extended synchronization and communication functions mutexes message buffers rendezvous ports Memory pool management functions fixed length memory pool variable length memory pool Time management functions Interrupt management functions System configuration management functions Subsystem management functions Device management functions Power saving functions The following development tools are also provided with uT REALOS for use when building or debugging a system These are Windows applications that run on a PC uT REALOS Configurator uT REALOS Configurator referred to as the Configurator in this manual is used when building a user system to configure the kernel based an a predefined structure See 3 13 Kernel Configuration Function for details on the Configurator functions CHAPTER 1 OVERVIEW OF uT REALOS 1 2 Structure of Product This section explains the structure of the product Structure of Product The structure of NT REALOS is shown below Figure 1 2 1 Structure of T RGEALOS Development __ tools i libraries header files i Configurator i i Sample Sample build related programs i files 1 1 AR 1 Configurator The Configurator modules that run under Windows They are command format exe
68. ile name Reasons such as file without read privilege hardware problems can be considered F9017M File write error file name F9022M Unknown option name option A parameter that cannot be specified was specified F9023M Illegal option parameter parameter The parameter output in parameter is illegally specified APPENDIX A Error Messages of the Configurator F9024M Option parameter not specified option The parameter is not specified in the option output in option F9030M Missing input file name The configuration file was not specified F9033M Illegal file format parameter This error occurs when format of files such as CPU information file is illegal F9405M Initial task priority is higher than maximum task priority MAX value This error occurs when the task priority of initializing process is higher than maximum task F9501M Not found CPU information file a d o 3 lt The CPU information file is not found at the specified location F9502M Not found CPU information This error occurs when the MB number specified by cpu option has not been registered to the CPU information file Confirm the MB number specified by cpu option F9801M Definition name is not defined The definition content output in the Definition name is not defined This error occurs when a definition or an option that cannot be omitted has not been specified F9805M EIT vector No number is system reserve Cannot u
69. ing an Event Function eventfn 90 eventfn Creating an Event Function eventfn 90 Example A specific Example of the Task 78 exec n Creating an Execute Start Function execfn DS 89 Execute Start Function Creating an Execute Start Function execfn A 89 Expansion SVC Handler Calling Format of an Expansion SVC Handler Extended SVC Handler Extended SVC Handlers 17 Extended Synchronization Extended Synchronization and Communication Functions diante 37 Extension SVC Handler Description Format of an Extension SVC Handler ete 87 F Fatal Error Message Fatal Error 108 Fixed size Memory Pool Fixed size Memory Pool Functions 48 Format Calling Format of an Expansion SVC Handler 87 Description Format of a Cyclic Handler 81 Description Format of a Power Saving Routine wate veh ado se deve ux e ee dde vae 86 Description Format of an Alarm Handler 82 Description Format of an Error Routine 85 INDEX Description Format of an Extension SVC Handler eas 87 Description Format of an Interrupt Handler ERES 83 Description Format of the Initial Routine 75 Description Format of the Task 77 Function Creating a Close Function closefn 89 Creating a Wait Completion Function waitfn
70. ing environment variables in order to use the configurator Table 5 2 1 Environment Variables Used for the Configurator Environment variable Directory u4T REALOS Install Directory uT REALOS Install Directory bin Add directory for storing the following RVDS tools armcc C compiler armasm Assembler armar Librarian 95 CHAPTER 5 HOW TO CONSTRUCT A SYSTEM E Starting the Configurator The configurator ftcfs exe is stored in the bin directory under the uT REALOS installation directory Start the configurator manually or from a batch procedure in the following syntax to create a kernel configuration file For details of descriptive content of a configuration file see 3 13 Kernel Configuration Function ftcfs f file name cpu name out path V g help noeit RVDS Table 5 2 2 Startup Options for the Configurator Option name Description ffile name Specifies the configuration file name as the file name This parameter cannot be omitted cpu cpu name Specifies the target CPU MB number CM3 can be specified for the family in general This parameter cannot be omitted out path Specifies the output directory for the kernel configuration file that is output by the configurator as path This parameter cannot be omitted Outputs the configurator startup message Outputs debugging information Displays Help Does not incorporate a vector t
71. inues to run until it unlocks the mutex The task priority of Task C then returns to its normal priority and Task A is executed Figure 3 5 1 Priority Inheritance Protocol Even if Task B is transitioned into ready state tk unl mtx it is not executed Task A 1 Task B 2 Task C 3 Parentheses show base priority tk loc mtx on tk loc mx Here Task C s current priority is increased POS S from 3 to 1 4 tk unl mix 40 Figure 3 5 2 is used to show an example of mutex behavior when the priority ceiling protocol is selected Assume that the mutex ceiling protocol has the same priority as Task A If Task C locks the mutex Task C continues to run with the same priority as Task A even if Tasks A and B are transitioned into ready state When Task C unlocks the mutex its priority returns to its original priority and Task A is executed next followed by Task B CHAPTER 3 uT REALOS FUNCTIONS Figure 3 5 2 Priority Ceiling Protocol Task A 1 Task B 2 Task C 3 Parentheses show base priority tk loc mtx x es Current priority is increased from 3 to 1 Tasks A and B are not 4 tk unl mtx x executed even if they a are transitioned into The lock is released ready state i and priority is decreased
72. ion E Creating a Task tk cre tsk is called to create a task In the following example function task1 is being created using task priority 1 If tk cre tsk is terminated normally the task ID will be returned as the return value Figure 4 5 2 Description Example of Task Creation ID tid1 Task ID of task1 T CTSK ctsk Input parameter of tk cre tsk INT task1 stack 256 Stack area of the task ctsk exinf VP 1 Extension information 1 ctsk tskatr TA HLNG TA USERBUF Attribute ctsk task task1 Start address of the task ctsk itskpri 1 Task priority ctsk stksz W sizeof task1 stack Stack size ctsk bufptr task1 stack Start address of the stack tidi tk cre tsk amp ctsk Create the task For details of tk cre tsk see 3 3 1 tk cre tsk of API Reference 77 CHAPTER 4 WRITING A USER PROGRAM E Starting a Task A task created by tk cre tsk is initially in the stop status Therefore tk sta tsk is called to run this task In the example below the task whose task ID 15 1141 is being started Figure 4 5 3 Description Example of the Task Startup tk sta tsk tid1 1 Start the task whose task ID is tid1 The status of a task started by tk sta tsk is executable If the priority of a task is higher than those of other tasks of execution status or executable status the task attains execution status For details of tk sta tsk see 3
73. ion Format of the Initial Routine 75 Process of the Initial Routine 75 Initialization Routines Initialization Routines 12 Interface Device Driver Interface 88 115 INDEX Interrupt Interrupt Management Functions 55 Timer Interrupt Handler 84 Interrupt Handler Description Format of an Interrupt Handler 83 Interrupt Handlers 13 Precedence of Execution Tasks vs Interrupt Handlers and Time Event Handlers 23 Registering an Interrupt Handler 83 Interrupt Management Interrupt Management Functions 55 Interrupts Interrupts Enabled disabled States 22 Invoking Task Invoking Task and Other Tasks 8 K Kernel Configuration Kernel Configuration Function 61 L Launch Launch of a Cyclic Handler 81 M Macros Configuration Definition Macros 62 Mailbox Mailbox Functions 35 Management Device Management Functions 58 Interrupt Management Functions 55 Subsystem Management Functions 57 System State Management Functions 56 Memory Pool Fixed size Memory Pool Functions 48 Memory Pool Management Funct
74. ions 47 Variable size Memory Pool Functions 49 Memory Pool Management Memory Pool Management Functions 47 Message Display Format of Configurator Error Messages REUS 103 Error Message Categorization of the Configurator eeeeeeseesss 102 Error 105 Fatal Error 108 Warning 104 Message Buffer Message Buffer Functions 42 uT REALOS Create a UT REALOS Project 98 Overview of UT REALOS Functions 28 116 Sample Program of UT REALOS 98 Steps for Creating the uT REALOS Project 97 Mutex Mutex Functions cee 38 N Non task Non task Portion Running 20 Objects OD SCS ics dida dr n 19 Open Function Creating an Open Function openfn 88 openfn Creating an Open Function openfn 88 P Power Saving Power Saving Functions 60 Power Saving Routine Description Format of a Power Saving Routine OEA PEE da 86 Registering a Power Saving Routine 86 Precedence Precedence and Task Priorities 8 Preemption Dispatching and Preemption 8 Process Process of Reset Entry Routine
75. ions for performing operations such as defining handlers for external interrupts and system exceptions and controlling interrupts Table 3 8 1 shows interrupt management functions and their corresponding system calls Table 3 8 1 Interrupt Management Functions and Corresponding System Calls Function System Call Name Define interrupt handler tk def int Return from interrupt handler tk ref int Prohibits all external interrupts DI Enables all external interrupts Checks the external interrupt disabled status The interrupt management functions provide the following functions using the corresponding system calls System calls that specify the invoking task and system calls that enter a WAITING state produce an error During execution in the task independent portion if a dispatch request is made during the processing of a system call the dispatch is delayed until the system leaves the task independent portion This is called delayed dispatching See Section 4 8 Interrupt Handler for details on writing interrupt handlers These functions manipulate the CPU registers to set the interrupts enabled disabled DI EI and isDI cannot be called from the task independent portion or from a state where dispatch and interrupts are disabled 55 CHAPTER 3 uT REALOS FUNCTIONS 3 9 System State Management Functions This section explains the system state management functions il System State Management Functions
76. is described E4111M Too long line MAX value Description is not available when the line length exceeds the length output in the value Limit the description to the length output in the value E4112M Illegal parameter expression Parameter expression is illegal This error message is output when the description syntax or the definition method of API is illegal E4120M Parameter is too long The parameter length output in Parameter is too long This error occurs when a symbol is described with a length exceeding its specification E4121M Too many definition name MAX value Definition output in definition name exceeds the number output in the value This error occurs if an attempt is made to define more than standard API 10 al APPENDIX A Error Messages of the Configurator 106 E4123M Too many parameters parameter Parameter beyond those output at parameter are unnecessary E4125M Short of parameter The parameters of the definition name are inadequate E4130M Multiple definition definition name Definition that cannot be duplicated was duplicated and defined This error occurs if ID of API is duplicated E4131M Parameter not defined parameter Parameters that cannot be omitted were omitted The parameter output in the parameter cannot be omitted E4132M Illegal parameter parameter Parameter that cannot be specified was specified This error occurs mainly when a string t
77. ith NL T REALOS is built smpsys axf is created in the same directory as that the sample project exists 100 APPENDIX The appendix explains error messages of the configurator APPENDIX A Error Messages of the Configurator 101 APPENDIX A Error Messages of the Configurator APPENDIXA Error Messages of the Configurator Appendix A explains the categorization display format and meaning of error messages output during configuration B Error Message Categorization of the Configurator Error messages output by the configurator on execution of configuration are categorized by 102 importance into the following three levels Warning message Warning messages are less serious than the error messages described next and the output results can be used almost without problems Occasionally a process different from what the user intended may be performed Determine whether the output results are usable after checking the message contents Error message The process is continued However the configuration is not performed It is necessary to eliminate the factors causing the error and perform the execution again This error mainly occurs while reading a file Fatal error message An error indicating that the process cannot be continued Such an error may occur due to problems in the execution environment as well as wrong specification by the user In addition there are messages that are output by the compiler ass
78. k and an initialization routine is called from this task An initialization routine therefore runs on a task 12 2 2 3 CHAPTER 2 BASIC CONCEPTS OF THE un REALOS KERNEL Interrupt Handlers This section explains interrupt handlers B interrupt Handlers An interrupt handler is a program that is activated synchronously with peripheral hardware interrupt sources system exceptions and software interrupt instructions Interrupt handlers can be defined for each interrupt source If an interrupt occurs while a task is running the kernel temporarily interrupts task execution and runs the interrupt handler corresponding to the interrupt source that occurred At this time the stack switches to the stack that is provided for executing interrupt processing the system stack The interrupt handler therefore does not execute in the context of the task that had been running but instead executes in an independent context Furthermore all of the interrupt handlers run at a higher priority than the tasks therefore tasks do not run until the interrupt handler has finished If multiple interrupt handlers are activated task execution does not continue until all of the interrupt handlers have finished processing Therefore even if an interrupt handler calls a system call that results in a dispatch such as starting a task with a high priority the actual task dispatch is not performed until after all of the interrupt handlers have finished pr
79. k sta tsk tsk3 3 TA TFIFO TA FIRST 0 Create semaphore Create task1 Create task2 ctsk exinf VP 1 ctsk tskatr TA HLNG TA USERBUF ctsk task task1 ctsk itskpri 1 ctsk stksz W sizeof task1 stack ctsk bufptr task1_stack tsk1 tk_cre_tsk amp ctsk ctsk exinf VP 2 ctsk tskatr TA HLNG TA USERBUF ctsk task task1 ctsk itskpri 2 ctsk stksz W sizeof task2 stack ctsk bufptr task2 stack tsk2 tk cre tsk amp ctsk ctsk exinf VP 3 ctsk tskatr TA HLNG TA USERBUF ctsk task task2 ctsk itskpri 3 ctsk stksz W sizeof task3 stack ctsk bufptr task3_ stack Create task3 Start task1 Start task2 Start task3 76 CHAPTER 4 WRITING A USER PROGRAM 4 5 Task This section explains how to write a task E Description Format of the Task The task is described as follows Figure 4 5 1 Description Format of the Task void task INT stacd VP exinf Process the body of the task program tk_ext_tsk or tk_exd_tsk Task termination The following values are passed to dummy parameters stacd and exinf respectively stacd The task start code specified during task startup tk_sta_tsk exinf The extension information specified when the task is created tk_cre_tsk A function task cannot be terminated by a simple return Using tk_ext_tsk or tk_exd_tsk to ensure terminat
80. ll wait queue for linking tasks in the rendezvous call wait state and a receive wait queue for linking tasks in the rendezvous accept wait state When the rendezvous is established both tasks involved in establishing the rendezvous are detached In other words the rendezvous port does not hold a wait queue to connect tasks waiting for a rendezvous to terminate Nor does it not hold information regarding processes accepted at the rendezvous port or tasks running requested processes The kernel allocates object numbers for identifying rendezvous that are established at the same time The rendezvous object number is called the rendezvous number The lower 16 bits of the rendezvous number is the task ID of the task that called the rendezvous port and the upper 16 bits is a sequential number that is incremented by 1 for each rendezvous accepted This means that even when rendezvous port are called by the same task different rendezvous numbers are allocated to the first rendezvous and the second rendezvous Additional Notes Figure 3 5 4 shows the rendezvous operation In this diagram Task A and Task B are executing asynchronously Task A calls tk cal por first a of Figure 3 5 4 Task A is in wait state for the rendezvous to be called until Task B calls tk acp por The rendezvous is established when Task B calls tk acp por and Task A will be in wait state for the rendezvous to terminate When Task B calls tk rpl rdv Task A is released
81. lowing processes Creating and starting objects necessary for operations of the user program such as tasks semaphores time event handlers Initializing and registering device drivers Initializing hardware e Starting a timer interrupt Note The initial routine is executed while the interrupt is enabled E Description Format of the Initial Routine The initial routine is described as follows Figure 4 4 1 Description Format of the Initial Routine void sample init void qe Process the initial routine return 75 CHAPTER 4 WRITING A USER PROGRAM E Description Example of the Initial Routine Figure 4 4 2 shows the description example of the initial routine The source codes are attached to the product as a sample program init task c of uT REALOS In the following example after the timer for the system clock is started SysTick init semaphore and three tasks task ID tsk1 tsk2 tsk3 are created Then the created three tasks are started Figure 4 4 2 Description Example of the Initialization Routine void uinit task void ID tsk1 ID tsk2 ID tsk3 T CTSK ctsk T CSEM csem static INT task1 stack 0x400 4 static INT task2 stack 0x400 4 static INT task3 stack 0x400 4 symtem clock set SysTick_init csem sematr csem isemcnt csem maxsem 1 sem1 tk cre sem amp csem tsk 3 tk cre tsk amp ctsk tk sta tsk tsk1 1 tk sta tsk tsk2 2 t
82. n the memory pool region a task that gets a memory block from a fixed size memory pool enters the fixed length memory block acquisition wait state until the next memory block is returned Tasks that enter the fixed length memory block acquisition wait state are linked to the wait queue of that fixed size memory pool The order of the wait queue can be selected from the two options of FIFO order TA TFIFO and task priority order TA TPRI This is specified as a part of fixed size memory pool attributes when the fixed size memory pool is created Figure 3 6 1 Memory Region of a Fixed size Memory Pool Memory blocks all the same size 48 CHAPTER 3 uT REALOS FUNCTIONS 3 6 2 Variable size Memory Pool Functions This section explains the variable size memory pool functions B Variable size Memory Pool Functions Variable size memory pool are objects for dynamically managing arbitrary size memory blocks Table 3 6 2 shows variable size memory pool functions and their corresponding system calls Table 3 6 2 Variable Size Memory Pool Functions and Corresponding System Calls Function System Call Name Create variable size memory pool tk cre mpl Delete variable size memory pool tk del mpl Get Variable size Memory Block tk get mpl Release Variable size Memory Block tk rel mpl Refer Variable size Memory Pool Status tk ref mpl The variable size memory pool objects are identified by an ID number The
83. nagement Functions and Corresponding System Calls Function System Call Name Define Device tk def dev Refer Initial Device Information tk ref idv Open device tk opn dev Close device tk cls dev Read Device tk rea dev Synchronous Read Device tk srea dev Write Device tk wri dev Synchronous Write Device tk swri dev Wait Device tk wai dev Suspend device tk sus dev Get Device tk get dev tk ref dev Get device information tk oref dev List Device tk Ist dev Event Device tk evt dev 58 CHAPTER 3 uT REALOS FUNCTIONS The system calls that can be called depending on the device registration and open state are as follows Table 3 11 2 Callable System Calls Device Device Callable system calls registered opened No No tk_def dev No tk_opn_dev tk_ref_idv tk_get_dev tk_ref_dev Yes tk_Ist_dev tk_sus_dev tk_def dev Yes All system calls of the device management function The specifications for the interface between the device drivers and the kernel are defined by the device driver interface The device driver interface defines the device processing functions that are called from the kernel the format of data passed between the kernel and the device driver etc Because the device driver interface is supported by all uT Kernel specification OSs device drivers that were created in compliance with device driver interface have improved portability betwe
84. ncd respectively pk_para Turns the parameters passed from the caller into the packet format The packet format can be determined by a user who creates subsystems arbitrarily fncd A function code which contains the subsystem ID in its lower 8 bits The remaining higher bits are determined by a user who creates subsystems arbitrarily E Calling Format of an Expansion SVC Handler An extension SVC handler is called from call SVC function in a user program An extension SVC handler with an ID specified by fncd is called It is described as follows Figure 4 11 2 Calling Format of an Expansion SVC Handler call EX SVC VP pk para FN fncd In the example below the SVC handler whose subsystem ID sayid is 10 is called In the called extension SVC handler the beginning addresses of packets containing arg and arg2 are passed to pk para and Ox 10A is passed fncd Figure 4 11 3 Example of Calling an Expansion SVC Handler define FUNC1 FNCD 0x10A ssyid 10 INT func1 int arg1 int arg2 int para 2 para 0 arg1 para 1 arg2 call EX SVC amp para FUNC1_FNCD 87 CHAPTER 4 WRITING A USER PROGRAM 4 12 Device Driver This section explains how to write a device driver Ml Device Driver Interface In the uT Kernel specification the device management function increases the portability of the device drivers by unifying their interfaces The following describes how to create a driv
85. ndezvous ports provide intertask synchronous communication functionality and support a single sequence where one task requests processing of another task and the other task then returns the processing result to the first task The object that synchronizes the waiting of both tasks is called a rendezvous port Although the rendezvous port functions can be used to implement a client server model of intertask communication they provide a synchronous communication model that is more flexible than the client server model Table 3 5 3 shows rendezvous port functions and their corresponding system calls Table 3 5 3 Rendezvous Port Functions and Corresponding System Calls Function System Call Name Create Port for Rendezvous tk cre por Delete Port for Rendezvous tk del por Call Port for Rendezvous tk cal por Accept Port for Rendezvous tk acp por Reply Rendezvous tk rpl rdv Forward Rendezvous to Another Port tk fwd por Refer Port Status tk ref por Rendezvous port objects are identified by an ID number The rendezvous port ID number is called the rendezvous port ID The task that makes the processing request to the rendezvous port the client side task specifies the rendezvous port rendezvous conditions and a message containing information regarding the processing being requested called the call message and calls the rendezvous port On the other hand the task that accepts the processing request at the rende
86. ndler To use the functions of time event handler timeout and system time it is necessary to let the timer interrupt occur at intervals of 1ms and then update the system time using the interrupt handler System time will be updated when isig tim is called A sample program init task c included with uT REALOS uses system exception SysTick timer for the timer interrupt handler An example of the timer interrupt is shown below Figure 4 8 4 Description Example of an Timer Interrupt Handler EXPORT void SysTick void Clear the timer interrupt factors i isig_tim Notes When an interrupt handler is described using assembler note the following points Calling an interrupt handler or returning from an interrupt handler is not via the OS As the OS does not back up and restore registers or perform stack settings perform such processes on the interrupt handler side A time event handler is executed according to the interrupt priority of an interrupt handler for system clock calling isig tim As the SysTick timer stops while the standby mode is set neither time event handler activation nor system time increment is not performed See 4 10 Power Saving Routine for details on SysTick timer operation while the power saving mode is set 84 CHAPTER 4 WRITING A USER PROGRAM 4 9 Error Routine This section explains how to write an error routine E Description Format of an Error Routine The de
87. nged e Ifa task is still locking any mutexes when the task ends the locks are released from all of those mutexes If the tasks is locking multiple mutexes those mutexes are released in order starting from the mutexes that were allocated last See Section 3 6 1 4 tk_unl_mtx in the API Reference for details on the specific lock release process 39 CHAPTER 3 uT REALOS FUNCTIONS B Task Priority Control The task priority that locks the mutexes changes the priority according to the priority control rule accompanied by the task priority which has the mutexes and change of its priority Additional Notes Mutexes that have the TA TFIFO attribute or TA TPRI attribute have the same functions as a semaphore with a maximum resource count of 1 binary semaphore However mutexes differ in that the lock can only be released by the locking task and the lock is automatically released when the task ends Figure 3 5 1 is used to show an example of mutex behavior when the priority inheritance protocol is selected If Task C is running while the mutex is locked the task priority is the same as the base priority of Task C If Task A which has higher priority is activated Task A is executed If Task A tries to lock the mutex Task A 15 transitioned into wait state and Task C 15 executed with the task priority of Task A Even if Task B transitions into ready state it is not transitioned into run state while Task C is running Task C cont
88. not have the concept of a task The following system calls therefore cannot be called from the task independent portions System calls that explicitly specify the invoking task calls where tskid is specified using the TSK SELF macro System calls that implicitly specify the invoking task calls that enter a WAITING See Section 3 1 List of System Calls of the API Reference for details on the system calls that can be called from each of the system states E User Programs and System States Table 2 4 1 shows the relationship between the parts of a user program and the system states Table 2 4 1 System States of Each Part of a User Program User Program System State Component Tasks Task portion Extended SVC handlers Non task portion quasi task portion task independent portion Device drivers Non task portion quasi task portion Cyclic handlers Non task portion task independent portion Alarm handlers Non task portion task independent portion Interrupt handlers Non task portion task independent portion Error routines Task portion non task portion task independent portion Note The uT Kernel specifications do not define isig tim and error routines These are extended functionality that is specific to uT REALOS 21 CHAPTER 2 BASIC CONCEPTS OF THE u REALOS KERNEL 2 5 Dispatch and Interrupts Enabled disabled States This section explains the dispatch enabled disable
89. ntax Static API Syntax INI INI Attributes Extended Information Entry address Attributes Specify TA HLNG Extended Information This is ignored for the current version Entry address Specify the entry address of initial routine DEF INH DEF INH Interrupt Vector Number Attributes Entry address Interrupt Vector Number A value from 0 to 255 can be specified However you cannot specify the number defined with KERNEL MAX VCT or more Furthermore the interrupt numbers 0 7 to 10 13 and 14 are reserved by the system Attributes Specify TA HLNG Specify VTA_SRSV to specify the interrupt numbers reserved by the system Entry address Specify the entry address of interrupt handler VATT ERR ERR Attributes Entry address Attributes Specify TA HLNG Entry address Specify the entry address of error routine 64 VDEF PSR VDEF PSR Attributes Entry address Attributes Specify TA HLNG Entry address Specify the entry address of power saving routine Example ATT VA VD INI T DEF INH 35 I EF _ERR PSR T A H CHAPTER uy REALOS FUNCTIONS LNG 0 uint TA HLNG inthdr LNG uerr LNG pow down 65 CHAPTER 3 uT REALOS FUNCTIONS E Setting of Configuration Define the following items at Kernel configuration function Definition of the maximum number of objects Set the m
90. ocessing This behavior is called delayed dispatching See 3 8 Interrupt Management Functions for details on the interrupt handlers 13 CHAPTER 2 BASIC CONCEPTS OF THE u REALOS KERNEL 2 2 4 Time Event Handlers This section explains time event handlers BB Time Event Handlers Cyclic handlers and alarm handlers are collectively referred to as time event handlers Cyclic Handlers 14 A cyclic handler is a program that is activated at a specified interval regular Programs that are executed periodically can be defined as cyclic handlers and the execution and suspension of these handlers are able to be controlled If the specified interval elapses while a task is executing the task execution is temporarily interrupted and the corresponding cyclic handler is activated The cyclic handler does not execute in the context of the task that had been running but instead executes in an independent context Furthermore all of the cyclic handlers run at a higher priority than the tasks therefore tasks do not run until the cyclic handler has finished Even if the cyclic handler calls a system call that results in a dispatch such as starting a task with a high priority the actual task dispatch is not performed until after the cyclic handler has finished processing The cyclic handlers in tT REALOS are activated from within isig tim which is called from the timer interrupt handler for the system clock The cyclic handlers
91. of the send wait queue can be selected from the two options of FIFO order TA TFIFO and task priority order TA TPRI This is specified as a part of message buffer attributes when the message buffer is created The message receiving side the event wait side retrieves a single message from the message buffer If there are no messages in the message buffer the task waits for receiving a message from message buffer until the next message is sent Tasks waiting for receiving a message from message buffer are linked to the receive wait queue of that message buffer The order of the receive wait queue is always the FIFO order Synchronous messaging functionality can be obtained by setting the size of the message buffer area to zero This means that both the sending task and the receiving task wait for each other to make the system call and pass the message between them when both tasks have made the system call The message buffer functions provide the following functions using the corresponding system calls CHAPTER 3 uT REALOS FUNCTIONS Additional Notes Figure 3 5 3 shows the operation of a message buffer when the size of the message buffer area is set to 0 In this diagram Task A and Task B are executing asynchronously Task A calls tk snd mbf first a of Figure 3 5 3 Task A waits to send the message buffer until Task B calls tk rcv mbf When Task B calls tk rcv mbf the message is transmitted from Task to Task B Then a
92. on CHAPTER 3 uy REALOS FUNCTIONS The value of KERNEL MAX TSKPRTI and the value of KERNEL INIT TSKPRI must satisfy the following condition value of KERNEL MAX TSKPRI 2 value of KERNEL INIT TSKPRI The value of KERNEL MAX SEM and the value of KERNEL MAX OPNDEV must satisfy the following condition value of KERNEL MAX SEM 2 value of KERNEL MAX OPNDEV _KERNEL_REALMEMSZ specifies the size of the heap area If the attribute of the TA USERBUF is not specified upon creation of the task the message buffer or the memory pool the task stack the message buffer area or the memory pool area can be automatically got from the heap area If the definition of any of the configuration definition macros is omitted the minimum value that can be taken is selected as the default value For example if the definition of KERNEL MAX TSKPRI is omitted the maximum value of the task priority is set to 1 Similarly if the definition of KERNEL SEM is omitted the maximum number of semaphores is set to 0 If the maximum number of an object is 0 that object cannot be used For example if the maximum number of semaphores is set to 0 and the user program contains semaphore related system calls an undefined error occurs for the semaphore related system calls when the user system is built The configuration definition macros are written in the configuration file using the following syntax Configuration Definition Macro S
93. or1 Function KERNEL USE IMALLOC Use or not use the heap area 1 means use 0 or 1 Selection KERNEL USE DEVT n managemen 0 or 1 _KERNEL_REALMEMSZ Size of the heap area Any value 0 _KERNEL_MAX_TSK Maximum number of tasks 1 to 32767 KERNEL MAX SEM Maximum number of semaphores 0 to 32767 KERNEL MAX FLG Maximum number of event flags 0 to 32767 KERNEL MAX MBX Maximum number of mailboxes 0 to 32767 KERNEL MAX MTX Maximum number of mutexes 0 to 32767 KERNEL MAX MBF Maximum number of message buffers 0 to 32767 KERNEL MAX POR Maximum number of rendezvous ports 0 to 32767 Maximum KERNEL MAX MPF ME number of fixed size memory 0 to 32767 number of each object KERNEL MAX MPL c Md number of variable size memory 0 to 32767 KERNEL MAX CYC Maximum number of cyclic handlers 0 to 32767 KERNEL MAX ALM Maximum number of alarm handlers 0 to 32767 KERNEL MAX SSY Maximum number of subsystems 0 to 255 KERNEL MAX REGDEV Maximum number of registered devices 0 to 255 KERNEL MAX OPNDEV Maximum number of open devices 0 to 255 KERNEL MAX REQDEV Maximum number of device requests 0 to 255 KERNEL MAX VCT Maximum number of interrups 16 to 256 KERNEL SYS STKSIZE System stack size 0x80 to Oxfffffffc KERNEL INIT TSKSTKSZ Initial task stack size 0x80 to Oxfffffffc x HU KERNEL DEVT MBFSZO Message buffer size for event notification 0 to Oxfffffffc KERNEL DEVT MBFSZI Maximum message buffer size for event 0 to Oxfffffffc 62 notificati
94. ose function means access to a device has been terminated The driver then performs the device terminating process whenever necessary For details of a close function see Close function closefn of Section 4 11 Device Processing Function in API Reference Figure 4 12 3 Description Format of Close Function closefn ERercd closefn ID devid UINT option VP exinf Device close processing Al E Creating an Execute Start Function execfn An execute start function is called from the kernel when tk rea dev tk srea dev tk wri dev or tk swri dev is called from a user program An execute start function is called when the data to be processed is set to the parameter However the function does not return upon completion of the data process instead it returns when the process has been accepted For example when the data to be written to a device is passed via tk wri dev it returns on completion of the write start instruction to a device and it is not necessary to wait for completion of the device write process For details of an execute start function see Execute start function execfn of Section 4 11 Device Processing Function in API Reference Figure 4 12 4 Description Format of Execute Start Function execfn ERercd execfn T DEVREQ devreq TMO tmout VP exinf Device process start 89 CHAPTER 4 WRITING A USER PROGRAM E Creating a Wait Completion Function waitfn A
95. output in file name The reasons such as no file writing privilege presence of the same name directory name no free disk space are considered F9999M Internal error identification information When this error occurs contact sales representative immediately 111 APPENDIX A Error Messages of the Configurator 112 INDEX INDEX The index follows on the next page This is listed in alphabetic order 113 INDEX Index A Abort Execute Function Creating an Abort Execute Function abortfn pue br ger 90 abortfn Creating an Abort Execute Function abortfn RES 90 Additional Additional 43 Additional Notes Additional Notes 36 40 45 Alarm Handler Alarm Handler Functions 54 Alarm Handlers 15 Creating an Alarm Handler 82 Description Format of an Alarm Handler 82 Starting an Alarm Handler 82 API Static APT 64 C Calling Format Calling Format of an Expansion SVC Handler tcs 87 Close Function Creating a Close Function closefn 89 closefn Creating a Close Function closefn 89 Communication Extended Synchronization and Communication Functions eiii 37 Synchronization and Communication Functions IR 31 Configuration Definition Configuration
96. r is called the alarm handler ID The time when an alarm handler activates this is called the alarm handler activation time can be set for each alarm handler When the alarm handler activation time is reached the alarm handler is activated with the extended information exinf of that alarm handler as a parameter Immediately after an alarm handler is created the alarm handler activation time is not set and the alarm handler is stopped When the system call to start the operation of an alarm handler tk_sta_alm is called the alarm handler activates after the specified relative time When the system call to stop the operation of an alarm handler tk_stp_alm is called the alarm handler activation time setting is cleared In addition when an alarm handler activates the alarm handler activation time setting is cleared and the alarm handler is stopped See Section 4 7 Alarm Handler for details on writing alarm handlers Figure 3 7 2 Activation Timing for Alarm Handlers Create alarm handler tk cre alm Start Start Stop CUT alarm handler Activate alarm handler alarm handler tk sta alm alarm handler tk sta alm tk stp alm A x Relative time Alarm handler is until alarm handler is activated not activated 54 CHAPTER 3 uy REALOS FUNCTIONS 3 8 Interrupt Management Functions This section explains the interrupt management functions E Interrupt Management Functions The interrupt management functions are funct
97. recedence Higher precedence is given to tasks with higher task priority For tasks with the same task priority higher precedence is given to the task that is transitioned into ready state first CHAPTER 2 BASIC CONCEPTS OF THE un REALOS KERNEL Figure 2 2 2 Conceptual Diagram of the Precedence The task that is highest in the precedence enters the RUNNING state Order in which tasks entered the READY state Later Higher Task in Task in READY state READY state Task priority Task in Task in Task in READY state READY state READY state Task in Task in READY state READY state Task in READY state Lower The running task continues the execution until it enters the READY state after the priority order is changed or it enters another state WAITING state SUSPENDED state WAITING SUSPENDED state DORMANT state NON EXISTENT state At that time the task in another READY state is not executed 11 CHAPTER 2 BASIC CONCEPTS OF THE u REALOS KERNEL 2 2 2 Initialization Routines This section explains initialization routines B Initialization Routines Initialization routines are programs using initialization processes that are unique to the user program In general the user program prepares the operating environment by creating tasks and semaphore objects and by registrating interrupt handlers and devices At the startup of the kernel one task is created this task is called an initial tas
98. representatives before ordering The information such as descriptions of function and application circuit examples in this document are presented solely for the purpose of reference to show examples of operations and uses of FUJITSU SEMICONDUCTOR device FUJITSU SEMICONDUCTOR does not warrant proper operation of the device with respect to use based on such information When you develop equipment incorporating the device based on such information you must assume any responsibility arising out of such use of the information FUJITSU SEMICONDUCTOR assumes no liability for any damages whatsoever arising out of the use of the information Any information in this document including descriptions of function and schematic diagrams shall not be construed as license of the use or exercise of any intellectual property right such as patent right or copyright or any other right of FUJITSU SEMICONDUCTOR or any third party or does FUJITSU SEMICONDUCTOR warrant non infringement of any third party s intellectual property right or other right by using such information FUJITSU SEMICONDUCTOR assumes no liability for any infringement of the intellectual property rights or other rights of third parties which would result from the use of information contained herein The products described in this document are designed developed and manufactured as contemplated for general use including without limitation ordinary industrial use general office use personal use
99. rm handler ID will be returned as the return value An alarm handler moves to the stop status after it is created Figure 4 7 2 Description Example of the Alarm Handler Creation ID almid1 Alarm handler ID T CALM calm Input parameter of tk cre alm calm exinf 1 Extension information 1 calm almatr Attribute calm almhdr almhdr1 Start address of the alarm handler almid1 tk_cre_alm amp calm Create the alarm handler E Starting an Alarm Handler An alarm handler is moved from the stop status to the action status when tk_sta_alm is called The following example activates Alarm Handler ID almid1 in 100ms Figure 4 7 3 Description Example of the Alarm Handler Startup tk sta alm almid1 100 activates Alarm Handler ID almid1 in 100ms 82 CHAPTER 4 WRITING A USER PROGRAM 4 8 Interrupt Handler This section explains how to write an interrupt handler E Description Format of an Interrupt Handler An interrupt handler is described as follows Figure 4 8 1 Description Example of an Interrupt Handler void sample inthdr void Interrupt handler body The interrupt handler is executed at the task independent portion In addition it is started while interrupt is enabled Therefore while an interrupt handler is being executed the interrupt handler may be started multiply For details see CHAPTER 5 EXCEPTION of Cortex M3 Te
100. rs and Wireless BLE Bluetooth Low Energy and USB connectivity solutions Cypress is committed to providing its customers worldwide with consistent innovation best in class support and exceptional system value FUJITSU SEMICONDUCTOR CONTROLLER MANUAL MN706 00008 1v0 E FM3 Family uT Kernel Specification Compliant uT REALOS M3 for RVDS USER S GUIDE A co FUJITSU FM3 Family uT Kernel Specification Compliant uT REALOS M3 for RVDS USER S GUIDE UT Kernel FUJITSU SEMICONDUCTOR LIMITED Preface E Purpose and Intended Reader of This Manual This manual is intended to be read by those who create application programs using uT REALOS M3 for RVDS referred to as UT REALOS hereafter and describes the overall functionality of uT REALOS how to create application programs and the procedure for building a system HT REALOS is a uT Kernel specification real time OS that runs on the Fujitsu microcontroller FM3 Family referred to as FM3 hereafter FM3 adopts ARM Cortex M3 core Reading this manual requires basic knowledge of the Cortex M3 architecture and uT Kernel which is available from the following documents e Cortex M3 Technical Reference Manual the architecture of FM3 e uT Kernel Specification the specification of uT Kernel See the following document for details on the system call interfaces e uT REALOS M3 API Reference referred to as API Reference hereafter E About
101. saving routine is a process called when the status has become idle inside the kernel The processing of transition to the power saving mode is described inside a function A power saving routine is described as follows Figure 4 10 1 Description Example of a Power Saving Routine void usr low pow void Describe the process of transition to the power saving mode Notes The FM3 Family supports the following three power saving modes SLEEP TIMER STOP While TIMER and STOP modes are operating the SysTick timer also stops See CHAPTER 5 LOW POWER CONSUMPTION MODE of MB9Axxx MB9Bxxx Series Peripheral Manual for details on the power saving modes E Registering a Power Saving Routine For registering a power saving routine see Static API in 3 13 Kernel Configuration Function Note When a system call is made inside the power saving routine the operation is not guaranteed 86 CHAPTER 4 WRITING A USER PROGRAM 4 11 Extension SVC Handler This section explains how to create and call an extension SVC handler E Description Format of an Extension SVC Handler An extension SVC handler is described as follows Figure 4 11 1 Description Format of an Extension SVC Handler INT svchdr VP pk para FN fncd Branch and proceed according to fncd return retcode Terminate the extension SVC handler The following values are passed to parameters pk_para and f
102. scription format of an error routine is shown as follows Figure 4 9 1 Description Format of an Error Routine void sample errrtn UINT errptn INT errinft INT errinf2 Error routine body The kernel sets the following information to errptn errinf1 and errinf2 and calls them e errptn Error factor KERNEL ERR SYS DOWN 0x01 System down KERNEL ERR INI ERR 0x02 Initial setting error KERNEL ERR EIT DOWN 0x04 Undefined interrupt e errinfl Error information In the case of KERNEL ERR SYS DOWN Ox1l tk ext tsk was called from the task independent portion 0x2 tk_exd_tsk was called from the task independent portion 0x3 tk_ext_tsk had been called while dispatch was disabled 0x4 tk exd tsk had been called while dispatch was disabled In the case of KERNEL ERR INI ERR Initial setting error information Ox1 Heap area assignment error 0x2 System startup error 0x3 Initial task startup error 0x4 Module initialization error 0x5 Power off processing error In the case of KERNEL ERR EIT DOWN Uncertain value errinf2 Error information2 Not used Reserved for future extension E Registering an Error Routine For registering an error routine see 3 13 Kernel Configuration Function 85 CHAPTER 4 WRITING A USER PROGRAM 4 10 Power Saving Routine This section explains how to write a power saving routine E Description Format of a Power Saving Routine The power
103. se the vector Number output in number is system reserved 10 c APPENDIX A Error Messages of the Configurator 110 F9895M Error in Compiler file name Error occurred when compiling the file output in file name F9896M Error in Librarian Error occurred in the librarian F9897M Error in Assembler file name Error occurred when assembling the file output in file name F9899M Tool name is not found The compiler assembler or linker cannot be found from environment variable PATH Define a path where the tool is contained in environment variable PATH F9990M File I O error file name information Some error occurred during input output of a file F9993M Can not create directory directory name Failed to create a directory output in directory name The reasons such as no directory writing privilege presence of the same name directory name no free disk space are considered F9994M Can not create file file name Failed to create a file output in file name The reasons such as no file writing privilege presence of the same name directory name no free disk space are considered APPENDIX A Error Messages of the Configurator F9995M Can not close file file name Failed to close a file output in file name The reasons such as no file writing privilege presence of the same name directory name no free disk space are considered F9996M Can not open file file name Failed to open a file
104. sk A specific Example of the Task 78 Creating a 77 Description Format of the Task 77 Invoking Task and Other Tasks 8 Non task Portion Running 20 Precedence and Task Priorities 8 Precedence of Execution Tasks vs Interrupt Handlers and Time Event Handlers GT 23 Precedence of Execution Tasks vs Tasks 24 Starting a Task eissi 78 Task Management Functions 29 Task Portion Running uus 20 Task Portion Transitions 10 Task Portlons ritiene Ras 9 Task Synchronization Functions 30 ERR ER MR 8 Task Management Task Management Functions 29 Task Synchronization Task Synchronization Functions 30 Time Event Handler Precedence of Execution Tasks vs Interrupt Handlers and Time Event Handlers ch atts 23 Time Event Handlers 14 Time Management Time Management Functions 50 Timer Interrupt Handler Timer Interrupt Handler 84 Tools Tools Required for Development 4 Transitions Task Portion Transitions
105. sk is locking a mutex that has the INHERIT attribute e Ifthe task is locking a mutex that has the CEILING attribute the ceiling priority of the mutex that has the highest ceiling priority from among the mutexes being locked by that task If the current priority of a task that is waiting for a mutex that has the TA INHERIT attribute is changed as a result of a mutex operation or the base priority being changed by tk chg pri the current priority of the task that is locking that mutex may need to be changed This is called transitive priority inheritance Furthermore if that task is waiting for another mutex that has the TA INHERIT attribute then transitive priority inheritance processing may be needed for the task that is locking that mutex The following processing is performed when the current priority of a task is changed as the result of acquisition of a mutex e Ifa task that has changed its priority is in a runnable state the precedence of the task is changed based on the priority after the change the task will have the lowest precedence from among the tasks that have the same priority after the priority has been changed e If the task that has changed its priority is linked to some kind of task priority ordered wait queue the order within the wait queue is changed based on the priority after the change the task will have the lowest precedence from among the tasks that have the same priority after the priority has been cha
106. sssssssssseeeeeeneen nnns 51 3 7 2 AAA nennen nnne 52 3 7 8 Alarm Handler Functions iret rette tL ntt cp Ere C Eg e Pets 54 3 8 Interrupt Management Functions 55 3 9 System State Management Functions ssssssssssesesse eene enne 56 3 10 Subsystem Management Functions sssssssssssseseeeeeeeeen nennen nnns 57 3 11 Device Management Functions ssssssssseeese eene nennen nnne nns 58 312 Power Saving Functions 5 ert nde eate bete et eiae 60 3 13 Kernel Configuration Function ssssssssssssseseeee eee nennen nennen nennen nns 61 CHAPTER4 WRITING A USER PROGRAM 69 4 1 Configuring a User Program 70 4 2 Activation FIOW sic ie ccm 71 4 3 Reset Entry Routine uec isis Anand ra cti i 72 4 4 Duis 75 4 5 TASK sobs atone M 77 4 6 Gyclie Elandlet ataca ora 81 4 7 Alarm Handler ata e n i te te eet ga rati Dens 82 4 8 Intertupt Flandler ntt re e 83 4 9 zogen 85 4 10 Power Saving Routine 86 4 11 Extension SVC Handler esses enne nnne tenentis tenen senten nnns 87 4 12
107. t system calls While the size of memory blocks obtained from fixed size memory pools are fixed the size of memory blocks obtained from variable size memory pools can be specified The memory pool management functions support the following functions e Fixed size memory pool functions e Variable size memory pool functions 47 CHAPTER 3 uT REALOS FUNCTIONS 3 6 1 Fixed size Memory Pool Functions This section explains the fixed size memory pool functions E Fixed size Memory Pool Functions Fixed size memory pool are objects that perform dynamic management of fixed size memory blocks Table 3 6 1 shows fixed size memory pool functions and their corresponding system calls Table 3 6 1 Fixed Size Memory Pool Functions and Corresponding System Calls Function System Call Name Create fixed size memory pool tk cre mpf Delete fixed size memory pool tk del mpf Get Fixed size Memory Block Release Fixed size Memory Block tk get mpf tk rel mpf Refer Fixed size Memory Pool Status tk ref mpf The fixed size memory pool objects are identified by an ID number The fixed size memory pool ID number is called the fixed size memory pool ID Fixed size memory pool have a region of memory that is used as the fixed size memory pool this is called the fixed size memory pool region or simply the memory pool region and a wait queue for tasks that are waiting to get a memory block If there is no free space i
108. the uT Kernel The uT Kernel specifications are specifications for an open real time OS established by the T Engine Forum The uT Kernel specifications are available from the T Engine Forum website http www t engine org The original copyright for the p T Kernel belongs to Mr Ken Sakamura The copyright for the uT Kernel specifications belongs to the T Engine Forum This product uses the uT Kernel source code from the T Engine Forum www t engine org based on the uT License E Trademarks Microsoft Windows and Windows Media are either registered trademarks of Microsoft Corporation in the United States and or other countries ARM is a registered trademark of ARM Limited Cortex is a trademark of ARM Limited other brands or product names are the property of their respective holders ARM is used to represent ARM Holdings plc its operating company ARM Limited and the regional subsidiaries ARM Inc ARM KK ARM Korea Limited ARM Taiwan Limited ARM France SAS ARM Consulting Shanghai Co Ltd ARM Belgium N V ARM Germany GmbH ARM Embedded Technologies Pvt Ltd ARM Norway AS and ARM Sweden AB REALOS is a trademark of Fujitsu Semiconductor Limited TRON is an abbreviation of The Real time Operating system Nucleus ITRON is an abbreviation of Industrial TRON is an abbreviation of Micro Industrial TRON T Kernel and uT Kernel are the name of computer specifications and do not refer to a particular produ
109. tion and suspension of these handlers are able to be controlled If the specified time is reached while a task is executing the task execution is temporarily interrupted and the corresponding alarm handler is executed The alarm handler does not execute in the context of the task that had been running but instead executes in an independent context Furthermore all of the alarm handlers run at a higher priority than the tasks therefore tasks do not run until the alarm handler has finished Even if the alarm handler calls a system call that results in a dispatch such as starting a task with a high priority the actual task dispatch is not performed until after the alarm handler has finished processing The alarm handlers in uT REALOS operate as part of the interrupt handler for the system clock Alarm handlers are therefore not interrupted to process other time event handlers while the alarm handler is running The time when the alarm handler is activated is calculated based on the time tick following the time when the alarm handler is activated However if an alarm handler is activated from within a time event handler the time is calculated based on the time when the time event handler was activated See 3 7 3 Alarm Handler Functions for details on alarm handlers 15 CHAPTER 2 BASIC CONCEPTS OF THE u REALOS KERNEL 2 2 5 Error Routines This section explains error routines B Error Routines An error routine is a program t
110. variable size memory pool ID number is called the variable size memory pool ID Variable size memory pool have a region of memory that is used as the variable size memory pool this is called the variable size memory pool region or simply the memory pool region and a wait queue for tasks that are waiting to get a memory block If there is insufficient free space in the memory pool region when a task gets a memory block from the variable size memory pool the task enters the variable length memory block acquisition WAITING until a memory block of sufficient size is returned Tasks that enter the variable length memory block acquisition WAITING are linked to the wait queue of that variable size memory pool The order of the wait queue can be selected from the two options of FIFO order TA TFIFO and task priority order TA TPRI This is specified as a part of variable size memory pool attributes when the variable size memory pool is created Figure 3 6 2 Memory Region of a Variable size Memory Pool Memory blocks sizes vary 49 CHAPTER uT REALOS FUNCTIONS 3 7 Time Management Functions This section explains the time management functions E Time Management Functions The time management functions are functions for performing time dependent processing The functions include functions for system time management cyclic handlers and alarm handlers Cyclic handlers and alarm handlers are collectively referred to as time e
111. vent handlers The time management functions support the following functions System time management functions e Cyclic handler functions Alarm handler functions 50 CHAPTER uT REALOS FUNCTIONS 3 7 1 System Time Management Functions This section explains the system time management functions E System Time Management Functions System time management functions are used to update set and reference the system time as well as to reference the system operating time Table 3 7 1 shows system time management functions and their corresponding system calls Table 3 7 1 System Time Management Functions and Corresponding System Calls Function System Call Name Signal Time isig tim Set Time tk set tim Get Time tk get tim Get Operating Time tk get otm HT REALOS uses isig tim to update the system time for user programs This system call increases the system time by 1 isig tim is a system call unique to uT REALOS Because resolution of system time is processed in units of 15 interrupts are made in 1ms cycles using an interval timer System time is updated by calling isig tim from the interrupt handler System operating time shows the elapsed time since the system was activated Unlike system time it does not affect system time settings when tk set tim is called E System Time The system time is represented by the accumulated number of milliseconds since the Ist January 1985 GMT For example
112. wait completion function is called from the kernel when tk wai dev tk srea dev or tk swri dev is called from a user program A wait completion function waits for the completion of I O requests accepted at the process start function Therefore a waiting for completion function may use an API function such as tk slp tsk which enters the waiting status as it waits for completion of hardware For details of a wait completion function see O Wait completion function waitfn of Section 4 11 Device Processing Function in API Reference Figure 4 12 5 Description Format of Wait Completion Function waitfn INT pktno waittn T DEVREQ devreq INT nreq TMOtmout VP exinf Device wait for completion process el E Creating an Abort Execute Function abortfn An abort execute function is called from the kernel if there are unfinished I O requests left in the device when the device close instruction is issued from a user program An abort execute function aborts a process of I O requests specified by parameters It forces the device to abort I O and removes the waiting state if the task has entered a state waiting for I O completion For details of an abort execute function see O Abort execute function abortfn of Section 4 11 Device Processing Function in API Reference Figure 4 12 6 Description Format of Abort Execute Function abortfn INT pktno waittn T DEVREQ devreq INT nreq TMO tmout VP exinf
113. ware reset It performs hardware initialization and starts the kernel Necessity Mandatory Initial routine This routine is called from the kernel intialization It provides the operating environment for the user program Mandatory Task Performs the main process of a user program Mandatory Cyclic handler Created when performing a process at regular time intervals Optional Alarm handler Created if there is a process to be performed after a certain time Optional Interrupt handler Created when handling hardware interrupts When system time is used it is necessary to create a timer interrupt handler Optional Error routine Created when handling kernel errors from a user program Optional Power saving routine Created when performing power saving process using a user program Optional Extension SVC Handler Created when defining user function using the extension SVC handler Optional Device driver Created when controlling the device driver using the device management API Optional For more on these see 4 3 Reset Entry Routine to 4 12 Device Driver in this document respectively CHAPTER 4 WRITING A USER PROGRAM 4 2 Activation Flow This section explains the process flow from the hardware reset occurrence until control is passed to the user program task E Starting a User Program Figure 4 2 1 shows the processing flow
114. yntax Configuration definition macro Defined value Example KERNEL MAX TSK 256 KERNEL INIT TSKSTKSZ 0x1000 Notes The maximum number of tasks defined by KERNEL MAX TSK includes the initial task that is created within the kernel Therefore when the number of tasks that a user program creates is define the maximum number of tasks as N 1 or more Because the device management function uses the following objects set the value for the maximum number of objects to number used by user program number used by device management Semaphores One used for each device opened Message buffers One used by all device management functions Event flags One used by all device management functions 63 CHAPTER 3 uT REALOS FUNCTIONS Static API The interface for the user program modules that are statically defined by the Configurator is called the static API The static API can register the initialization routine interrupt handlers error routine and power saving routine Furthermore interrupt handlers can also be registered from a user program using tk def int A list of the static API is shown in Table 3 13 2 Table 3 13 2 List of Static API ATT INI Defines the initial routine DEF INH Defines an interrupt handler VATT ERR Defines the error routine VDEF PSR Defines a power saving routine The static API is written in the configuration file using the following sy
115. zvous port the server side task specifies the rendezvous port and rendezvous conditions then accepts processing at the rendezvous port The rendezvous parameters are specified as a bit pattern For a given rendezvous port a rendezvous is established if the result of logical bitwise ANDing of the rendezvous parameters bit pattern of the calling tasking and the rendezvous parameters bit pattern of the accepting task is non zero The task that calls the rendezvous port enters the rendezvous call wait state until the rendezvous is established Contrarily the task that accepts the processing request at the rendezvous port is in wait state until the rendezvous is established Once the rendezvous is established the call message is passed from the task that called the rendezvous port to the task that accepted the rendezvous The task that called the rendezvous port then enters the rendezvous completion wait state and waits for the requested processing to finish On the other hand the wait state is released for the task that accepted the processing at the rendezvous port and the requested process is executed When the task that accepted the processing at the rendezvous port is completed processing results are handed to the called task CHAPTER 3 uT REALOS FUNCTIONS as a reply message and the rendezvous is terminated At this time the task that called the rendezvous port is released from the rendezvous completion wait state Rendezvous ports have a ca
Download Pdf Manuals
Related Search
Related Contents
乳幼児の火傷対策について - JDSA 日本宅配水&サーバー協会 Hitachi VT-FX623A VCR User Manual SIT07 User Guide Hilme FG225 User's Manual Offre de formation_Semestre2 2014 V3 SIN RASTRO - C MTD Products Aktiengesellschaft √ SaarbrΩcken √ Germany 取扱説明書ー本体表示などの注意書きに従った使用状態で保証期間内 ソロ ウインター取扱説明書 Metra Electronics 99-8903B User's Manual Copyright © All rights reserved.
Failed to retrieve file