OSEK Operat ing System
Rev. 1.2
NON-DISCLOSURE AGREEMENT REQUIRED
HC12
OSEK
Operating System
User’s Manual
Rev. 1.2
May 19, 1999
NON-DISCLOSURE AGREEMENT REQUIRED
User’s Manual
User’s Manual MC68HC(7)05H12Rev. 1.2
2MOTOROLA
Motorola reserves the right to make changes without further notice to
any products herein to improve reliability, function or design. Motorola
does not assume any liability arising out of the application or use of any
product or circuit described herein; neither does it convey any license
under i ts patent rights nor the rights of othe rs. M otorola prod ucts a re not
designed, intended, or authorized for use as components in systems
intended for surgical implant into the body, or other applications intended
to support or sustain life, or for any other application in which the failure
of the Mot orola pro duct co uld cr eate a si tu ation where per sonal injury or
death may occur. Should Buyer purchase or use Motorola products for
any such unintended or unauthorized application, Buyer shall indemnify
and hold Motorola and its officers, employees, subsidiaries, affiliates,
and distributors harmless against all claims, costs, damages, and
expenses, and reasonable attorney fees arising out of, directly or
indirectly, any claim of personal injury or death associated with such
unintended or unauthorized use, even if such claim alleges that Motorola
was negligent re gard i ng the design or manu factur e of the part. Moto rol a
and are register ed tr adem arks of M otoro la, Inc. Mo toro la , Inc. is an
Equal Employment Opportunity/Affirmative Action Employer.
Copyright © 1999 Motorola, Inc. All Rights Reserved
OSEK Op erati ng SystemRev 1.2 User’s Manual
MOTOROLA Legal Notices 3
NON-DISCLOSURE AGREEMENT REQUIRED
Legal Notices
iii
The information in this document has been carefully checked and is
believed to be entirely reliable, however, no responsibility is assumed for
inaccuracies. Furthermore, Motorola reserves the right to make changes
to any products herein to improve reliability, function or design. Motorola
does not assume liability arising out of the application or use of any
product or circuit described herein; neither does it convey any license
under its patent rights or the rights of others.
The software described in this document is furnished under a license
agreement. The software may be used or copied only in accordance with
the terms of the agreement.
Copyright © 1999 Motorola, Inc. All Rights Reserved
No part of th is publicat ion ma y be repr oduced or transmitted in an y form
or by any means - graphic, electronic, electrical, mechanical, chemical,
including photocopying, recording in any medium, taping, by any
computer or information storage retrieval systems, etc., without prior
permissions in writing from Motorola Inc.
Permission is granted to reproduce and transmit the Problem Report
Form, the Customer Satisfaction Survey, and the Registration Form to
Motorola.
IMPORTANT NOTICE TO USERS
While every effort has been made to ensure the accuracy of all
information in this document, Motorola assumes no liability to an y party
for any l oss o r damage cau s ed by error s or omi ssions or by statem ents
of any kind in this document, its updates, supplements, or special
editions, whether such errors are omissions or statements resulting from
negligence, accident, or any other cause. Motorola further assumes no
liability arising out of the application or use of any product or system
described herein; nor any liability for incidental or consequential
damages arising from the use of this document. Motorola discl aims all
warranties regarding the information contained herein, whether
expressed, implied or statutory, including implied warranties of
merchantability or fitness for a particular purpose.
NON-DISCLOSURE AGREEMENT REQUIRED
Legal Notices
User’s Manual OSEK Opera ting SystemRev 1.2
4 Legal Notices MO TORO LA
TRADEMARKS
Microsoft, MS-DOS and Windows are trademarks of Microsoft.
UNIX is a trademark of AT&T Bell Laboratories.
OSEK Op erati ng SystemRev 1.2 User’s Manual
MOTOROLA Table of Contents 5
NON-DISCLOSURE AGREEMENT REQUIRED
User’s Manual OSEK Operating System
Table of Contents
Section 1. Overview
Section 2. Notation
2.1 Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .25
2.2 Manual Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .25
2.3 Typographical Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . .27
2.4 Definitions, Acronyms and Abbreviations. . . . . . . . . . . . . . . . .27
2.5 Installation Instructions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .28
2.5.1 Required Environment. . . . . . . . . . . . . . . . . . . . . . . . . . . . .28
2.5.2 Installation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .29
2.6 Technical Support Information . . . . . . . . . . . . . . . . . . . . . . . . .29
Section 3. Operating System Architecture
3.1 Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .31
3.2 Processing Levels. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .31
3.3 Conformance Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .32
3.4 OSEK OS Overall Architecture. . . . . . . . . . . . . . . . . . . . . . . . .35
3.5 Application Program Interface . . . . . . . . . . . . . . . . . . . . . . . . .37
Sectio n 4. Task Management
4.1 Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .39
4.2 Task Concept . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .39
4.3 Task State Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .41
4.3.1 Extended Tasks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .41
4.3.2 Basic Tasks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .43
4.4 Task Activation and Termination . . . . . . . . . . . . . . . . . . . . . . .44
4.5 Task Properties. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .47
NON-DISCLOSURE AGREEMENT REQUIRED
Table of Contents
User’s Manual OSEK Opera ting SystemRev 1.2
6 Table of Contents MOTOROLA
4.6 Task Priorities. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .47
4.7 Task Related Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . .49
4.7.1 Task Configuration Table . . . . . . . . . . . . . . . . . . . . . . . . . .49
4.7.2 Task Control Block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .51
4.7.2.1 Persistent Node Assignment . . . . . . . . . . . . . . . . . . . . . .52
4.7.3 Task Link Table. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .53
4.7.4 Task Stack. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .55
4.7.4.1 Stack Allocation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .55
4.7.5 Allocation of Fixed Stack Linked with the Task Node . . . . .56
4.7.5.1 Dynamic Stack Allocation from the Stack Pool . . . . . . . .57
4.7.5.2 Persistent Stack Allocation from the Stack Pool . . . . . . .57
4.7.5.3 Explicit Stack Allocation. . . . . . . . . . . . . . . . . . . . . . . . . .59
4.7.5.4 Stack Size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .59
4.8 Programming Issues. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .60
4.8.1 Configuration Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . .60
4.8.2 Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .61
4.8.3 Task Definition. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .61
4.8.4 Run-time Services. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .62
4.8.5 Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .63
4.8.6 Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6 3
Section 5. Sc heduler
5.1 Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .65
5.2 General. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .65
5.2.1 Simple Scheduler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .66
5.3 Scheduling Policy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .67
5.3.1 Non-preemptive Scheduling . . . . . . . . . . . . . . . . . . . . . . . .67
5.3.2 Full-preemptive Scheduling. . . . . . . . . . . . . . . . . . . . . . . . .68
5.3.3 Mixed-preemptive Scheduling. . . . . . . . . . . . . . . . . . . . . . .69
5.4 Programming Issues. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .70
5.4.1 Configuration Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . .70
5.4.2 Run-time Services. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .71
5.4.3 Scheduler Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .71
Section 6. Int errupt Proc essing
6.1 Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .73
6.2 General. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .73
Table of Contents
OSEK Op erati ng SystemRev 1.2 User’s Manual
MOTOROLA Table of Contents 7
NON-DISCLOSURE AGREEMENT REQUIRED
6.3 ISR Stack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .75
6.4 ISR Categories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .75
6.4.1 ISR Category 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .75
6.4.2 ISR Category 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .76
6.4.3 ISR Category 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .77
6.5 Interrupt Flag Manipulation. . . . . . . . . . . . . . . . . . . . . . . . . . . .77
6.6 Local Variables Considerations . . . . . . . . . . . . . . . . . . . . . . . .78
6.7 Programming Issues. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .79
6.7.1 Configuration Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . .79
6.7.2 Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .80
6.7.3 Run-time Services. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .80
6.7.4 Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8 1
6.7.5 ISR Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .82
6.7.6 Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .83
Section 7. Resource Management
7.1 Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .85
7.2 General. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .85
7.3 Access to Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .87
7.3.1 Priority Ceiling Protocol. . . . . . . . . . . . . . . . . . . . . . . . . . . .87
7.3.2 Scheduler as a Resource . . . . . . . . . . . . . . . . . . . . . . . . . .88
7.4 Programming Issues. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .89
7.4.1 Configuration Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . .89
7.4.2 Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .90
7.4.3 Run-time Services. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .90
7.4.4 Resource Definition. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .90
Sectio n 8. Counters and Alarms
8.1 Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .93
8.2 General. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .93
8.3 Counters. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .94
8.4 Alarms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .96
8.5 Programming Issues. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .99
8.5.1 Configuration Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . .99
8.5.2 Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .100
NON-DISCLOSURE AGREEMENT REQUIRED
Table of Contents
User’s Manual OSEK Opera ting SystemRev 1.2
8 Table of Contents MOTOROLA
8.5.3 Counters and Alarm Generation . . . . . . . . . . . . . . . . . . . .101
8.5.4 Run-time Services. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .102
8.5.5 Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .103
Secti on 9. Events
9.1 Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .105
9.2 General. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .105
9.3 Events and Scheduling. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .106
9.4 Programming Issues. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .108
9.4.1 Configuration Options . . . . . . . . . . . . . . . . . . . . . . . . . . . .108
9.4.2 Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .108
9.4.3 Events Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .108
9.4.4 Run-time Services. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .109
9.4.5 Additional Usage. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .109
Section 10. Communi cation
10.1 Contents. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .111
10.2 Message Concept. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .111
10.3 Unqueued Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .113
10.4 Queued Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .115
10.5 Programming Issues. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .116
10.5.1 Configuration Options . . . . . . . . . . . . . . . . . . . . . . . . . . . .116
10.5.2 Identifiers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .117
10.5.3 Message Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .118
10.5.4 Run-time Services. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .119
10.5.5 Usage of Messages. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .119
Section 11. Error Handling and Special Routines
11.1 Contents. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .121
11.2 General. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .121
11.3 Hook Routines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .121
11.4 Error Handling. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .126
11.4.1 Error Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .126
11.4.2 Extended Status . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .127
Table of Contents
OSEK Op erati ng SystemRev 1.2 User’s Manual
MOTOROLA Table of Contents 9
NON-DISCLOSURE AGREEMENT REQUIRED
11.4.3 Possible Error R easons. . . . . . . . . . . . . . . . . . . . . . . . . . .128
11.5 Start-up Routine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .128
11.6 Application Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .130
11.7 System Shutdown. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .130
11.8 Programming Issues. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .131
11.8.1 Configuration Options . . . . . . . . . . . . . . . . . . . . . . . . . . . .131
Section 12. System Configuration
12.1 Contents. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .133
12.2 General. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .133
12.3 Application Configuration File. . . . . . . . . . . . . . . . . . . . . . . . .134
12.4 OIL Concept . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .134
12.4.1 OIL File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .134
12.4.2 Standard OIL Format. . . . . . . . . . . . . . . . . . . . . . . . . . . . .135
12.4.3 Extended OIL Format . . . . . . . . . . . . . . . . . . . . . . . . . . . .135
12.4.4 Implementation Definition . . . . . . . . . . . . . . . . . . . . . . . . .135
12.4.4.1 Implementation Definition Grammar . . . . . . . . . . . . . . .136
12.4.5 Application Definition. . . . . . . . . . . . . . . . . . . . . . . . . . . . .138
12.4.5.1 Object Definition. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .138
12.4.5.2 Include Directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .139
12.4.5.3 Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .139
12.4.5.4 File Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .139
12.4.6 Configuration File Rules . . . . . . . . . . . . . . . . . . . . . . . . . .140
Section 13. System O b jects Definition
13.1 Contents. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .141
13.2 General. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .141
13.3 OS Definition. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .142
13.3.1 Global System Attributes. . . . . . . . . . . . . . . . . . . . . . . . . .142
13.3.2 Task Related Attributes. . . . . . . . . . . . . . . . . . . . . . . . . . .147
13.3.3 Interrupt Related Properties . . . . . . . . . . . . . . . . . . . . . . .149
13.3.4 Resources and Events Related Attributes. . . . . . . . . . . . .151
13.3.5 Counters and Alarms Related Attributes. . . . . . . . . . . . . .152
13.3.6 Messages Related Attributes . . . . . . . . . . . . . . . . . . . . . .153
13.3.7 Hook Routines Related Attributes. . . . . . . . . . . . . . . . . . .154
13.3.8 OS Service Related Attributes. . . . . . . . . . . . . . . . . . . . . .155
NON-DISCLOSURE AGREEMENT REQUIRED
Table of Contents
User’s Manual OSEK Opera ting SystemRev 1.2
10 Table of Contents MOTOROLA
13.4 Task Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .156
13.4.1 Object Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .156
13.4.2 Object References. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .158
13.5 Stack Definition. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .159
13.5.1 Object Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .160
13.6 Resource Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .160
13.6.1 Object Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .161
13.7 Event Definition. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .161
13.7.1 Object Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .161
13.8 Counter Definition. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .161
13.8.1 Object Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .162
13.9 Alarm Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .163
13.9.1 Object References. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .163
13.10 Message Definition. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .164
13.10.1 Object Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .164
13.10.2 Object References. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .166
13.11 ISR Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .167
13.11.1 Object Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .167
13.11.2 Object References. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .167
13.12 Different Application Modes Definition . . . . . . . . . . . . . . . . . .168
Section 14. Building of Application
14.1 Contents. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .171
14.2 Application Structure. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .171
14.3 Action Sequence to Build an Application . . . . . . . . . . . . . . . .172
14.3.1 Application Configuration . . . . . . . . . . . . . . . . . . . . . . . . .173
14.3.2 Source Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .175
14.3.3 Compiling and Linking. . . . . . . . . . . . . . . . . . . . . . . . . . . .178
14.4 Sample Application. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .178
Section 15. HC12 Platform-Specific Features
15.1 Contents. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .179
15.2 Compiler-Specific Features . . . . . . . . . . . . . . . . . . . . . . . . . .179
15.2.1 OSEK OS Environment Variables. . . . . . . . . . . . . . . . . . .179
Table of Contents
OSEK Op erati ng SystemRev 1.2 User’s Manual
MOTOROLA Table of Contents 11
NON-DISCLOSURE AGREEMENT REQUIRED
15.2.2 Cosmic Software. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .180
15.3 Interrupt Flag Manipulation Specific Features . . . . . . . . . . . .180
15.4 HC12 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .182
15.4.1 Base Page Memory Usage . . . . . . . . . . . . . . . . . . . . . . . .182
15.4.1.1 Mapping RAM and REGISTERS . . . . . . . . . . . . . . . . . .182
15.4.2 Interrupt Vector Table . . . . . . . . . . . . . . . . . . . . . . . . . . . .183
15.4.3 The Banked Memory Model Support. . . . . . . . . . . . . . . . .184
15.4.3.1 Banked Memory Model Overview . . . . . . . . . . . . . . . . .184
15.4.3.2 Configuration of the Application for Banked Memory. . .185
15.4.3.3 Cosmic Compiler Issue . . . . . . . . . . . . . . . . . . . . . . . . .186
15.4.4 Recommendations on System Properties. . . . . . . . . . . . .187
15.4.4.1 UseMainStack property . . . . . . . . . . . . . . . . . . . . . . . . .187
15.4.4.2 UseSameContext Property . . . . . . . . . . . . . . . . . . . . . .187
15.4.4.3 InterruptMaskControl Property. . . . . . . . . . . . . . . . . . . .187
15.4.4.4 CounterSize Property. . . . . . . . . . . . . . . . . . . . . . . . . . .188
15.4.4.5 Unused Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .188
15.4.5 System Timer Hardware . . . . . . . . . . . . . . . . . . . . . . . . . .188
15.4.6 Scheduler Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . .191
15.4.7 Alarms Configuration. . . . . . . . . . . . . . . . . . . . . . . . . . . . .191
15.5 Task Stack Size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .192
Section 16. Application Troubleshooting
16.1 Contents. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .193
16.2 System Generation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .193
16.3 Using OS Extended Status for Debugging . . . . . . . . . . . . . . .193
16.4 Context Switch Routines. . . . . . . . . . . . . . . . . . . . . . . . . . . . .194
16.5 Stack Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .195
16.6 Known Problems. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .195
Section 17. System Services
17.1 Contents. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .197
17.2 General. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .197
17.3 Task Management Services. . . . . . . . . . . . . . . . . . . . . . . . . .199
17.3.1 Data types. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .199
17.3.2 Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .199
17.3.3 Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .200
NON-DISCLOSURE AGREEMENT REQUIRED
Table of Contents
User’s Manual OSEK Opera ting SystemRev 1.2
12 Table of Contents MOTOROLA
17.3.4 Task Declaration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .200
17.3.5 ActivateTask . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .201
17.3.6 TerminateTask . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .202
17.3.7 ChainTask. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .203
17.3.8 Schedule . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .204
17.3.9 GetTaskId . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .205
17.3.10 GetTaskState . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .206
17.3.11 GetTCBInfo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .207
17.3.12 Examples for Task Management Services . . . . . . . . . . . .208
17.4 ISR Management Services. . . . . . . . . . . . . . . . . . . . . . . . . . .210
17.4.1 Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .210
17.4.2 Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .211
17.4.3 Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .211
17.4.4 EnterISR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .211
17.4.5 LeaveISR. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .213
17.4.6 EnableInterrupt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .214
17.4.7 DisableInterrupt. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .216
17.4.8 GetInterruptDescriptor. . . . . . . . . . . . . . . . . . . . . . . . . . . .217
17.4.9 Examples for Interrupt Management Services . . . . . . . . .218
17.5 Resource Management Services . . . . . . . . . . . . . . . . . . . . . .220
17.5.1 Data types. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .220
17.5.2 Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .220
17.5.3 Resource Declaration . . . . . . . . . . . . . . . . . . . . . . . . . . . .221
17.5.4 GetResource. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .221
17.5.5 ReleaseResource . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .223
17.5.6 Examples of Using Resources . . . . . . . . . . . . . . . . . . . . .224
17.6 Counters and Alarms Management Services. . . . . . . . . . . . .225
17.6.1 Data Types and Identifiers . . . . . . . . . . . . . . . . . . . . . . . .225
17.6.2 Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .226
17.6.3 Counter and Alarm Declaration. . . . . . . . . . . . . . . . . . . . .227
17.6.3.1 Counter Declarati on. . . . . . . . . . . . . . . . . . . . . . . . . . . .227
17.6.3.2 Alarm Declaration . . . . . . . . . . . . . . . . . . . . . . . . . . . . .228
17.6.4 InitCounter. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .228
17.6.5 CounterTrigger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .229
17.6.6 AdvanceCounter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .230
17.6.7 GetCounterValue. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .231
17.6.8 GetCounterInfo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .232
17.6.9 SetRelAlarm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .233
Table of Contents
OSEK Op erati ng SystemRev 1.2 User’s Manual
MOTOROLA Table of Contents 13
NON-DISCLOSURE AGREEMENT REQUIRED
17.6.10 SetAbsAlarm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .235
17.6.11 CancelAlarm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .236
17.6.12 GetAlarmBase. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .237
17.6.13 GetAlarm. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .238
17.6.14 Examples for Counter and Alarm Management . . . . . . . .239
17.7 Event Management Services . . . . . . . . . . . . . . . . . . . . . . . . .242
17.7.1 Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .242
17.7.2 Event Declarati on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .242
17.7.3 SetEvent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .243
17.7.4 ClearEvent. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .244
17.7.5 GetEvent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .245
17.7.6 WaitEvent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .246
17.7.7 Examples of Using Events . . . . . . . . . . . . . . . . . . . . . . . .247
17.8 Communication Management Services . . . . . . . . . . . . . . . . .249
17.8.1 Data Types and Identifiers . . . . . . . . . . . . . . . . . . . . . . . .249
17.8.2 SendMessage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .250
17.8.3 ReceiveMessage. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .252
17.8.4 GetMessageResource. . . . . . . . . . . . . . . . . . . . . . . . . . . .253
17.8.5 ReleaseMessageResource. . . . . . . . . . . . . . . . . . . . . . . .254
17.8.6 GetMessageStatus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .255
17.8.7 Examples of Using Messages. . . . . . . . . . . . . . . . . . . . . .256
17.9 Operating System Execution Control . . . . . . . . . . . . . . . . . . .259
17.9.1 Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .259
17.9.2 GetActiveApplicationMode . . . . . . . . . . . . . . . . . . . . . . . .259
17.9.3 StartOS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .260
17.9.4 ShutdownOS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .260
17.9.5 Examples of Appl ication Modes Usage. . . . . . . . . . . . . . .261
17.9.6 Hook Routines. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .264
17.9.6.1 ErrorHook. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .264
17.9.6.2 PreTaskHook . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .265
17.9.6.3 PostTaskHook . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .266
17.9.6.4 IdleLoopHook. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .266
17.9.6.5 StartupHook. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .267
17.9.6.6 ShutdownHook. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .268
Section 18. ORTI Implementation
18.1 Contents. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .269
NON-DISCLOSURE AGREEMENT REQUIRED
Table of Contents
User’s Manual OSEK Opera ting SystemRev 1.2
14 Table of Contents MOTOROLA
18.2 General. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .269
18.3 ORTI Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .271
18.3.1 ORTI Trace Interfaces. . . . . . . . . . . . . . . . . . . . . . . . . . . .271
18.3.2 ORTI Breakpoint Interface. . . . . . . . . . . . . . . . . . . . . . . . .273
18.4 ORTI Supporting OS Properties. . . . . . . . . . . . . . . . . . . . . . .274
18.5 ORTI Generator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .275
Appendix A. Sample Application
A.1 Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .279
A.2 Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .279
A.3 Source Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .280
Appendix B. System Service Timing
B.1 Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .283
B.2 General Notes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .283
Appendix C. Memory Requirements
C.1 Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .289
C.2 Memory for the OSEK Operating System. . . . . . . . . . . . . . . .289
C.3 Data Sheet for the Cosmic . . . . . . . . . . . . . . . . . . . . . . . . . . .292
Appendix D. System Generation Error Messages
D.1 Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .297
D.2 Error Message Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .297
D.3 Error Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .297
D.4 Warning Messages. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .314
Appendix E. Quick Reference
E.1 Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .319
E.2 System Services Quick Reference. . . . . . . . . . . . . . . . . . . . .319
E.3 OIL language Quick Reference . . . . . . . . . . . . . . . . . . . . . . .325
E.3.1 OS Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .326
Table of Contents
OSEK Op erati ng SystemRev 1.2 User’s Manual
MOTOROLA Table of Contents 15
NON-DISCLOSURE AGREEMENT REQUIRED
E.3.2 TASK Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .345
E.3.3 ISR Object. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .347
E.3.4 STACK Object. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .347
E.3.5 RESOUR CE Object. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .348
E.3.6 ALARM Object. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .348
E.3.7 COUNTER Object. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .349
E.3.8 MESSAGE Object. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .349
E.3.9 EVENT Object. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .351
User’s Manual Index
NON-DISCLOSURE AGREEMENT REQUIRED
Table of Contents
User’s Manual OSEK Opera ting SystemRev 1.2
16 Table of Contents MOTOROLA
OSEK Op erati ng SystemRev 1.2 User’s Manual
MOTOROLA List of Figures 17
NON-DISCLOSURE AGREEMENT REQUIRED
Figure Title Page
User’s Manual OSEK Operating System
List of Figures
3-1 Restricted upward compatibility for conformance classes . .33
4-1 Task status model of an Extended Task with its task
transitions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .42
4-2 Task status model with task transitions for Basic Tasks . . .4 4
4-3 Task management architecture . . . . . . . . . . . . . . . . . . . . . .46
4-4 Task priorities. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .48
4-5 Persistent task node assignment . . . . . . . . . . . . . . . . . . . . .53
4-6 Task link table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .54
4-7 Fixed stack linked with the task node. . . . . . . . . . . . . . . . . .56
4-8 Dynamic stack allocation from the stack pool . . . . . . . . . . .57
4-9 Persistent stack allocation from the stack pool . . . . . . . . . .58
4-10 Static stack allocation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .59
5-1 Non-preemptive scheduling . . . . . . . . . . . . . . . . . . . . . . . . .68
5-2 Full-preemptive scheduling . . . . . . . . . . . . . . . . . . . . . . . . .69
7-1 Priority Ceiling Protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . .88
8-1 Counters and alarms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .94
8-2 Two cases for the absolute alarm . . . . . . . . . . . . . . . . . . . .98
9-1 Synchronization by events in case of full-preemptive
scheduling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .107
9-2 Synchronization by events in case of full-preemptive
scheduling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .108
10-1 Operations with Queued Messages. . . . . . . . . . . . . . . . . .116
11-1 System startup in the OSEK OS . . . . . . . . . . . . . . . . . . . .129
14-1 Application building process. . . . . . . . . . . . . . . . . . . . . . . .173
15-1 Banked Memory Model . . . . . . . . . . . . . . . . . . . . . . . . . . .185
18-1 Application Building Process with ORTI Support . . . . . . . .270
NON-DISCLOSURE AGREEMENT REQUIRED
List of Figur e s
User’s Manual OSEK Opera ting SystemRev 1.2
18 List of Figures MOTOROLA
OSEK Op erati ng SystemRev 1.2 User’s Manual
MOTOROLA List of Tables 19
NON-DISCLOSURE AGREEMENT REQUIRED
Figure Title Page
User’s Manual OSEK Operating System
List of Tables
3-1 OSEK OS Conformance Classes. . . . . . . . . . . . . . . . . . . . . .34
3-2 OSEK OS maximal system resources . . . . . . . . . . . . . . . . . .35
4-1 States and status transitions in the case of Extended Tasks.42
4-2 States and status transitions in the case of Basic Tasks . . . .43
4-3 Task Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .47
4-4 Task Management R un-time Services . . . . . . . . . . . . . . . . . .62
6-1 Interrupt Management Services in the OSEK OS . . . . . . . . .81
8-1 Counter and Alarm Management Run-time Services. . . . . .102
9-1 Event Management Run-time Services . . . . . . . . . . . . . . . .109
10-1 Features of the Message Concept . . . . . . . . . . . . . . . . . . . .113
10-2 Task Management Run-time Services . . . . . . . . . . . . . . . . .119
11-1 OSEK OS system services for hook routi nes. . . . . . . . . . . .124
11-2 OSEK OS Error codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . .127
14-1 System Generator command line options . . . . . . . . . . . . . .174
15-1 Parameters to define System Timer hardware. . . . . . . . . . .189
18-1 ORTI Generator Command Line Options. . . . . . . . . . . . . . .276
B-1 OSEKOS_20 version of the Operating System run-time services
timing characteristics (HC12D60, Cosmic software) . . . . . .285
C-1 OSEKOS_20 version of the Operating System memory
requirements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .292
E-1 OSEK OS services. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .319
E-2 Data Types. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .322
E-3 Constructional elements. . . . . . . . . . . . . . . . . . . . . . . . . . . .323
E-4 OSEK Operating System run-time services return values
and error values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .324
E-5 OSEK Operating System constants . . . . . . . . . . . . . . . . . . .325
E-6 OS Parameters. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .326
E-7 TASK Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .345
E-8 ISR Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .347
E-9 STACK Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .347
E-10 RESOURCE Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . .348
NON-DISCLOSURE AGREEMENT REQUIRED
Lis t of Tables
User’s Manual OSEK Opera ting SystemRev 1.2
20 List of Tables MOTOROLA
E-11 ALARM Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .348
E-12 COUNTER Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . .349
E-13 MESSAGE Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . .349
E-14 EVENT Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .351
OSEK Op erati ng SystemRev 1.2 User’s Manual
MOTOROLA Overview 21
NON-DISCLOSURE AGREEMENT REQUIRED
User’s Manual OSEK Operating System
Section 1. Overview
OSEK1 Operating System (OSEK OS) is a real-time operating system
which conforms to the specification of the OSEK/VDX Operating System
version 2.0, revision 1, 15 October 1997.
OSEK OS conforms to the following requirements:
OS is fully configured and statically scaled;
OSEK OS is a ROM-able system, i.e. the OS code may be
executed from Read-Only-Memory. OSEK OS may be placed into
chip memory d uring manu facture, an d users’ appl icatio ns may be
added during development time;
OS performance parameters are well known;
Being written in strict correspondence with ANSI C standard, the
OS and application on its basis can be easily ported from one
platform to another.
A wide rang e of scalability, a set of system ser vices, various scheduling
mechanisms, and convenient configuration features make the OSEK
Operating System feasible for a broad spectrum of applications and
hardware platforms.
The OSEK OS provides a pool of different services and processing
mechanisms for task management and synchronization, data exchange,
resource management, and interrupt handling. The following features
are granted to the user:
1. The ter m OSEK means ‘Off ene Systeme und deren Schnittstellen fur die Elektr onik im Kraft-
fahrzeug ’ (Open systems and the corresponding interfaces for aut om oti ve electronics). A r eal-
time operating system, software interfaces and functions for communication and network man-
agement tasks are thus jointly specified within the OSEK standard.
NON-DISCLOSURE AGREEMENT REQUIRED
Overview
User’s Manual OSEK Opera ting SystemRev 1.2
22 Overview MOTOROLA
Task Management
Activation and termination of tasks;
Management of task states, task switch.
Scheduling Policies
Full-, non-, and mixed-preemptive scheduling techniques.
Event Control
Event Control for task synchronization.
Interrupt Management
Services for hardware interrupt flag manipulations;
Frames for interrupt service routines.
Resource Managem ent
Mutually exclusive access control for inseparable operations to
jointly used resources or devices, or for control of a program flow.
Communication1
Unqueued Message: Data exchange without buffering;
Queued Message: Data exchange with buffering.
Counter2 and alarm management
Counter management provides services for execution of recurring
events;
Alarm ma nagem ent is based on co unter ma nagem ent. It ena bl es
entry o f (cyclic) alar m requests. The expir ation of a preset re lative
counter value, or the fact that a preset absolute counter value is
reached, results in activation of a task, or setti ng of a task event.
1. Communi cation part of OSEK Operat in g System conforms the spe cification of the OSEK Com-
municati on System, version 2.1, revision 1, 17 June 1998.
2. Counter Management part of OSEK Operating System conforms the specification of the OSEK
Operating System Application Progr am Int erfac e version 1.00, 11 September 199 5.
Overview
OSEK Op erati ng SystemRev 1.2 User’s Manual
MOTOROLA Overview 23
NON-DISCLOSURE AGREEMENT REQUIRED
Error treatment
Mechanism supporting the user in various error classes.
ORTI Subsystem
ORTI provides interface to Operating System run-ti me data for
“OSEK aware” debuggers.
OSEK Ope rating S ystem is scaled in t w o ways eithe r b y ch angi ng the
set of system ser vices or via the so-called Conformance Classe s. They
are available to satisfy different requi rements concerning functionality
and capability of t he OS. These Conformance Classes do not only differ
concerning the number of services they provide, but also with regard to
their capab ilities and scalability. The classes ar e based on one an other
in upwardly compatible fashion. The Conformance Classes are
generated by meaningful grouping of services (see
Section 3.3 Conformance Classes).
The OSEK OS is built according to the user’s configuration i nstructions
at system gene ration time. Both system a nd application para meters are
configured statically. Therefore, a special tool called the System
Generator is used for this purpose. Special statements are designed to
tune any parameter. The user must only edit the definition file, run
System Generator and then assemble resulting files with application
files. Thu s, the user can adapt th e Ope rating Syst em to the c ontro l task
and the tar get hardwar e. OS cannot be modified l ater a t execution ti me.
OSEK Operating System is well documented and measured. In the
User’s Manual, all system mechanisms, particularities, services and
programming techniques are described in detail with numerous
examples. Numbers for performance characteristics and memory
requirements are provided.
NON-DISCLOSURE AGREEMENT REQUIRED
Overview
User’s Manual OSEK Opera ting SystemRev 1.2
24 Overview MOTOROLA
OSEK Op erati ng SystemRev 1.2 User’s Manual
MOTOROLA Notation 25
NON-DISCLOSURE AGREEMENT REQUIRED
User’s Manual OSEK Operating System
Section 2. Notation
2.1 Contents
2.2 Manual Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .25
2.3 Typographical Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . .27
2.4 Definitions, Acronyms and Abbreviations. . . . . . . . . . . . . . . . .27
2.5 Installation Instructions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .28
2.6 Technical Support Information . . . . . . . . . . . . . . . . . . . . . . . . .29
2.2 Manual Structure
This User’s Manual consists of the following sections:
Section 1 Overview descr ibes what the OSEK OS is and highl ights its
basic features.
Section 2 Notation contains a description of the Manual structure,
typographical conventions and the list of acronyms.
Section 3 Operating System Architecture gives a high level
description of OS architecture and presents OS Conformance Classes.
Sect ion 4 Task Managem en t explains the task concept in OSEK and
all other questions related to tasks.
Section 5 Scheduler provides a description of scheduling policies in
OSEK OS.
Section 6 Interrupt Processing highlights the OSEK approach to
interrupt handling.
Section 7 Resource Managem ent describes resource management
and task coordination by resources.
NON-DISCLOSURE AGREEMENT REQUIRED
Notation
User’s Manual OSEK Opera ting SystemRev 1.2
26 Notation MOTOROLA
Section 8 Counters and Alarms describes usage of these control
mechanisms in OSEK OS.
Section 9 Events is devoted to event management and task
coordination by events.
Section 10 Communication describes message concept in OSEK and
their usage.
Section 11 Error Handling and Special Routines describes support
provided to the user to debug an application and handle errors.
Section 12 System Configuration describes possible OSEK OS
versions, configuration options and the configuration mechanism.
Section 14 Building of Application contains information on how to
build an user’s application using OSEK OS. It also describes memory
requirements.
Section 15 HC12 Platform-Specific Features discusses special
OSEK OS features for different MCU types and issues connected with
porting applications to these MCUs.
Sect ion 16 Ap plicatio n Troublesh ootin g co ntains u seful i nfo rma tion
for debugging applications developed using OSEK OS.
Section 17 System Services provides a detailed description for all
OSEK Oper ating System run-ti me services, with appr opriate examp le s.
Section 18 ORTI Implementation provides information about
preparation all data needed for OSEK aware debugger to display
information about application in OSEK terms.
Appendix A Sample Application contains the text and listing of a
sample customer application developed using OSEK OS.
Appendix B System Service Timing provides information about OS
services execution time.
Ap pe nd ix C M em or y Re qu i re men ts pro vides infor matio n ab out t he
amoun t of R OM a nd RA M direc tl y used by va riou s ver si ons o f the OSEK
OS.
Notation
Typographical Convent ions
OSEK Op erati ng SystemRev 1.2 User’s Manual
MOTOROLA Notation 27
NON-DISCLOSURE AGREEMENT REQUIRED
Appendix D System Generation Error Messages explains OSEK OS
System Generator error messages.
Appendix E Quick Reference briefly lists all OSEK OS run-time
services, with entry and exit conditions.
2.3 Typographical Conventions
This manual employs the following typographical conventions:
boldface type
Bold is used for important terms, notes and warnings.
Italics
Italics are used for all OSEK names of directives, macros,
constants, routines and variables.
Courier font
Courier typeface is used for code examples in the text.
Courier
Italic
Courier Italic typeface is used for OSEK terms when these are
first introduced.
2.4 Definitions, Acronyms and Abbreviations
API Application Program Interface (a set of data types and functions)
BCC Basic Conf orma nce Class, a defin ed set of f uncti onalit y in OSEK, for
which the waiting state of tasks is not permitted
BT Basic task (task, which never has the waiting state)
CPU Central Processo r Unit
ECC Extended Conforma nce Class, a defi ned set of functional ity in
OSEK, for which the waiting state of tasks i s permitted
ECU Electr onic Control Unit (simi lar to MCU)
ET Extended Task (task, which may have the waiting state)
NON-DISCLOSURE AGREEMENT REQUIRED
Notation
User’s Manual OSEK Opera ting SystemRev 1.2
28 Notation MOTOROLA
2.5 Installation Instructions
2.5.1 Required Environment
Thi s version of the product i s to be used o n an IBM PC 486 (and hi gher)
compatible. To install and evaluate the product, you require
approximately 4 MB of hard disk space.
The PC must work under MS Windows 95 or Windows NT 4.0 during
OSEK installation.
To use OSEK OS after installation install the Cross Compiler on yo ur
computer (See Section 15 for more information). You must call the DOS
prompt under Windows NT to run the NMAKE utility.
All supplied makefiles are developed for the Microsoft C++ NMAKE
utility.
ID Identifier, an abstr act ide ntifier of a system object
ISF Interrupt Stack Fra me , a stacked model of CPU regi sters, produced
by CPU hardware and/or software instructions during CPU interrupt
ISR Inter rupt Servi ce Routi ne
MCU Microcontroller Uni t (Motorola’s micro controll ers)
MO Message object
N/A Not applicable
OIL OSEK Implementation Language
ORTI OSEK Run Time Interface
Orti Ge n ORTI Generator Utilit y
OS Operating System, a part of the OSEK
OSEK Open sys tems and their corresponding int erfaces for automotive
electronics (in German)
OSEKOS_20 Implementation of the OSEK OS according to "OSEK/VDX Operat-
ing System", Version 2.0 Revision 1, 15 October 1997
RAM Random Access Memory
ROM Read Only Memory
SG, SysGen System Generator
Notation
Technical Support Information
OSEK Op erati ng SystemRev 1.2 User’s Manual
MOTOROLA Notation 29
NON-DISCLOSURE AGREEMENT REQUIRED
2.5.2 Installation
To setup OSEK OS on your hard drive:
1. Insert the installation disk into a 3.5” floppy drive. The following
instructions assume that the drive letter is a:. If another drive is
chosen, substitute that drive letter where appropriate.
2. Run the A:\SETUP.EXE program either from the File Manager or
Program Manager.
3. Follow the prompts and instructions of the installation program.
4. After installation verify the consistency of the package by means
of comparing the real set of files and directories with the list in
FILELIST.TXT file.
After installation, the hard drive should contain the root directory of
OSEK which contains a set of files in the following subdirectories:
BIN System Generator
INC Operating System header files
SRC Operating System source files
HWSPEC Hardware specific files (usual ly startup and vector
table files)
SAMPLE OSEK Operating System Sample application
MAN User’s Documentation
There is a file titl ed FILELIST.TXT file in the OSEK OS root directory.
This document contains a complete list of files included in this release.
2.6 Technical Support Information
For additional product or support information please contact your local
Motorola Sales Office. Alternatively, use the following contact methods:
Email: osek@helpline.sps.mot.com
Phone: +44 13 55 35 53 98 (English)
+49 89 92 10 38 83 (German or English)
NON-DISCLOSURE AGREEMENT REQUIRED
Notation
User’s Manual OSEK Opera ting SystemRev 1.2
30 Notation MOTOROLA
Fax: +44 13 55 26 52 01 (English)
+49 89 92 10 38 20 (German or English)
OSEK Op erati ng SystemRev 1.2 User’s Manual
MOTOROLA Operating System Architecture 31
NON-DISCLOSURE AGREEMENT REQUIRED
User’s Manual OSEK Operating System
Section 3. Operating System Architecture
3.1 Contents
3.2 Processing Levels. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .31
3.3 Conformance Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .32
3.4 OSEK OS Overall Architecture. . . . . . . . . . . . . . . . . . . . . . . . .35
3.5 Application Program Interface . . . . . . . . . . . . . . . . . . . . . . . . .37
3.2 Processing Levels
The OSEK Operating System provides a pool of different services and
processing mechanisms. It serves as a basis for application programs
which are independent of each other, and provides their environment on
a processor. The OSEK OS enables a controlled real-time execution of
several processes which virtually run in parallel.
The OSEK Operating System provides a defined set of interfaces for the
user. Th ese i nterfaces ar e used by ent i ties whi ch are com peting for the
CPU. There are two types of entities:
Interrupts (service routines managed by the Operating System);
Tasks (basic tasks and extended tasks).
The highest processing priority is assigned to the interrupt level, where
interrupt service routines (ISR) are executed. Interrupt services may call
a number of operating system services. The processing level of the
operating system has a priority ranking immediately below the former
one. This is the level on which the operating system works: task
management procedures, scheduler and system services. Just below
this is the task level on which the application software is executed. Tasks
are executed according to their user assigned priority. A distinction is
NON-DISCLOSURE AGREEMENT REQUIRED
Operatin g System Architecture
User’s Manual OSEK Opera ting SystemRev 1.2
32 Operating System Architecture MOTOROLA
made between the management of tasks with and without waiting state
(Extended and Basic Tasks, see Section 4.2 Task Concept). The run
time context refers to resources which are occupied at the beginning of
execution time and are released again once the task is finished.
The following priority rules have been established:
Interrupts have precedence over tasks;
The interrupt priority is defined by specific hardware conditions;
For items handled by the OS, bigger numbers refer to higher
priorities;
The task’s priority is statically assi gned by the user.
The Operating System provides services and ensures compliance with
the priority rules mentioned above.
3.3 Conformance Classes
Vari ous requirements of the application software for the system, and
various capab ilities of a specific system ( e.g. processor type, amoun t of
memory) demand different features of the operating system. These
operating system features are described as Conformance Classes (CC).
They differ in the number of services provided, their capabilities and
different types of tasks.
Conformance classes were created to support the following objectives:
To provide convenient groups of operating system features for
easier understanding and discussion of the OSEK operating
system.
To allow partial implementations along pre-defined lines. These
partial implementations may be certi fied as OSEK compliant.
To create un upgrade path from classes of lesser functionality to
classes of higher functionality with no changes to the application
using OSEK related features.
The desired Conformance Class is selected by the user at system
generation time and cannot be changed during execution.
Operating System Architect ure
Conformance Classes
OSEK Op erati ng SystemRev 1.2 User’s Manual
MOTOROLA Operating System Architecture 33
NON-DISCLOSURE AGREEMENT REQUIRED
The definition of the functionalities provided by each Conformance Class
depend s on the prop erties of the t asks and on the scheduling beha vio r.
As th e task pro perties (Basic o r Ex tended, see Sect ion 4.3 Task Stat e
Model) have a distinct influence on CC, they also assume part of their
names. There are Basic-CC and Extended-CC, and each of these
groups can have various “derivatives”.
Conformance classes are determined by the following attributes:
Multiply requesting of task activation (see Section 4.4 Task
Activation an d Termination);
Task types (see Section 4.3 Task State Model);
Number of tasks per priority.
Figure 3-1. Restricted upward compatibility for conformance
classes
The following Conformance Classes are defined in the OSEK OS:
BCC1, BCC2, ECC1, ECC2.
BCC1 – o nly Basic tasks, limite d to o ne re quest p er ta sk and o ne
task per priority, while all tasks have different priorities;
BCC2 – like BCC1, more than one task per priority possible and
multiple activation admissible;
ECC1 – like BCC1, plus Extended tasks;
ECC2 – like BCC2, plus Extended tasks without multiply activation
admissible.
ECC1
ECC2
BCC1
BCC2
1 task/pri ority
no multiply activations
>1 task/priority
multiply activations for
basic tasks only
BT only BT and ET
NON-DISCLOSURE AGREEMENT REQUIRED
Operatin g System Architecture
User’s Manual OSEK Opera ting SystemRev 1.2
34 Operating System Architecture MOTOROLA
BCC1 defines the minimum Conformance Class of the OSEK OS, ECC2
defines its maximum CC.
Multiple activations means that the OSEK OS receives and records
activations (even multiple activations) of a task already activated.
In the OSEK OS the number of task multiply activations is defined in a
basic task specific attribute during system generation. If the maximum
number of multiply activations has not been reached, the activation of
the basic task is queued in a Scheduler queue to preserve task activation
order.
Table 3-1 presents minimum resources to which an application may
resort, determined for each Conformance Class in the OSEK OS.
The system configuration option
CC
(specified by the user) defines the
class of the overall system. This option can have values
BCC1
,
BCC2
,
ECC1
,
ECC2
(see Section 13.3 OS Definition).
It is impossible to have tasks of different Conformance Classes in one
application! All tasks must strictly conform to the Conformance Class
specified at the system configuration stage.
Table 3-1. OSEK OS Conformance Classes
BCC1 BCC2 ECC1 ECC2
Mul tip le acti vatio n of tasks no yes BT: no,
ET: no BT: yes,
ET: no
Number of tasks which are
not in the
suspended
st a te >=8>= 16, any combination
of BT/ET
Number of tasks per priority 1 >1 1
(both BT/ET) >1
(both BT/ET)
Numb er of events per t ask - BT: no
ET: >= 8
Numbe r of pr iority classes >=8
Resources only
Scheduler >= 8 resources (i nclud ing Scheduler)
Alarm >= 1 singl e or cyclic alarm
Messages possible