OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [compat/] [uitron/] [v2_0/] [doc/] [uitron.sgml] - Blame information for rev 279

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
2
 
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
 
30
31
 
32
33
  µITRON
34
35
<!-- <xref> -->µITRON API
36
37
<!-- <index></index> -->Introduction to µITRON
38
The µITRON specification
39
defines a highly flexible operating system architecture designed
40
specifically for application in embedded systems. The specification addresses
41
features which are common to the majority of processor architectures and
42
deliberately avoids virtualization which would adversely impact
43
real-time performance. The µITRON specification
44
may be implemented on many hardware platforms and provides significant
45
advantages by reducing the effort involved in understanding and
46
porting application software to new processor architectures. 
47
Several revisions of the µITRON specification exist.
48
        In this release, eCos supports the
49
        µITRON version 3.02 specification, with complete
50
        “Standard functionality” (level S), plus many
51
        “Extended” (level E) functions. The definitive
52
        reference on µITRON is Dr. Sakamura’s book:
53
          µITRON 3.0, An Open and Portable Real-Time Operating
54
          System for Embedded Systems.
55
        The book can be purchased from the IEEE Press, and
56
        an ASCII version of the standard can be found online at
57
http://www.itron.gr.jp/.
58
The old address
59
60
http://tron.um.u-tokyo.ac.jp/TRON/ITRON/
61
still exists as a mirror site. 
62
63
64
<!-- <index></index> -->µITRON and <EMPHASIS>eCos</EMPHASIS>
65
The eCos kernel implements the functionality
66
used by the µITRON compatibility subsystem.
67
The configuration of the kernel influences the behavior of µITRON
68
programs.
69
In particular, the default configuration has time slicing
70
(also known as round-robin scheduling) switched on; this means that
71
a task can be moved from RUN state
72
to READY state at any time, in
73
order that one of its peers may run. This is not strictly conformant
74
to the µITRON specification, which
75
states that timeslicing may be implemented by periodically issuing
76
a rot_rdq(0) call from
77
within a periodic task or cyclic handler; otherwise it is expected
78
that a task runs until it is pre-empted in consequence of synchronization
79
or communication calls it makes, or the effects of an interrupt
80
or other external event on a higher priority task cause that task
81
to become READY. To disable timeslicing
82
functionality in the kernel and µITRON
83
compatibility environment, please disable the
84
CYGSEM_KERNEL_SCHED_TIMESLICE
85
configuration option in the kernel package. A description of kernel
86
scheduling is in . 
87
For another example, the semantics of task queueing when waiting
88
on a synchronization object depend solely on the way the underlying
89
kernel is configured. As discussed above, the multi-level queue
90
scheduler is the only one which is µITRON
91
compliant, and it queues waiting tasks in FIFO order. Future releases
92
of that scheduler might be configurable to support priority ordering
93
of task queues. Other schedulers might be different again: for example
94
the bitmap scheduler can be used with the µITRON
95
compatibility layer, even though it only allows one task at each
96
priority and as such is not µITRON
97
compliant, but it supports only priority ordering of task queues.
98
So which queueing scheme is supported is not really a property of
99
the µITRON compatibility layer; it
100
depends on the kernel. 
101
In this version of the µITRON
102
compatibility layer, the calls to disable and enable scheduling
103
and interrupts (dis_dsp(),
104
ena_dsp(), loc_cpu()
105
and unl_cpu())
106
call underlying kernel functions; in particular, the xxx_dsp() functions
107
lock the scheduler entirely, which prevents dispatching of DSRs; functions
108
implemented by DSRs include clock counters and alarm timers. Thus time “stops” while
109
dispatching is disabled with dis_dsp(). 
110
Like all parts of the eCos system, the
111
detailed semantics of the µITRON layer
112
are dependent on its configuration and the configuration of other components
113
that it uses. The µITRON configuration
114
options are all defined in the file pkgconf/uitron.h,
115
and can be set using the configuration tool or editing the
116
.ecc
117
file in your build directory by hand. 
118
An important configuration option for the µITRON
119
compatibility layer is “Option: Return Error Codes for Bad Params”
120
(
121
CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
122
), which allows a lot of the error
123
checking code in the µITRON compatibility layer to
124
be removed. Of course this leaves a program open to undetected errors,
125
so it should only be used once an application is fully debugged and
126
tested. Its benefits include reduced code size and faster execution.
127
However, it affects the API significantly, in that with this option
128
enabled, bad calls do not return errors, but cause an assert
129
failure (if that is itself enabled) or malfunction internally. There
130
is discussion in more detail about this in each section below.
131
We now give a brief description of the µITRON
132
functions which are implemented in this release. Note that all C
133
and C++ source files should have the following #include statement: 
134
#include <cyg/compat/uitron/uit_func.h>
135
136
137
<!-- <index></index> -->Task Management Functions
138
The following functions are fully supported in this release: 
139
ER sta_tsk(
140
  ID tskid,
141
  INT stacd )
142
        
143
void ext_tsk( void )
144
        
145
void exd_tsk( void )
146
        
147
ER dis_dsp( void )
148
        
149
ER ena_dsp( void )
150
        
151
ER chg_pri(
152
  ID tskid,
153
  PRI tskpri )
154
        
155
ER rot_rdq(
156
  PRI tskpri )
157
        
158
ER get_tid(
159
  ID *p_tskid )
160
        
161
ER ref_tsk(
162
  T_RTSK *pk_rtsk,
163
  ID tskid )
164
        
165
ER ter_tsk(
166
  ID tskid )
167
        
168
ER rel_wai(
169
  ID tskid )
170
The following two functions are supported in this release,
171
when enabled with the configuration option
172
CYGPKG_UITRON_TASKS_CREATE_DELETE
173
with some restrictions:
174
ER cre_tsk(
175
  ID tskid,
176
  T_CTSK *pk_ctsk )
177
        
178
ER del_tsk(
179
  ID tskid )
180
These functions are restricted as follows:
181
Because of the static initialization facilities provided for
182
system objects, a task is allocated stack space statically in the
183
configuration. So while tasks can be created and deleted, the same
184
stack space is used for that task (task ID number) each time. Thus
185
the stack size (pk_ctsk->stksz) requested in cre_tsk() is
186
checked for being less than that which was statically allocated,
187
and otherwise ignored. This ensures that the new task will have
188
enough stack to run. For this reason del_tsk() does
189
not in any sense free the memory that was in use for the task's
190
stack. 
191
The task attributes (pk_ctsk->tskatr) are
192
ignored; current versions of eCos do not need
193
to know whether a task is written in assembler or C/C++ so
194
long as the procedure call standard appropriate to the CPU is followed.
195
Extended information (pk_ctsk->exinf) is
196
          ignored.
197
198
Error checking
199
For all these calls, an invalid task id (tskid) (less than
200
1 or greater than the number of configured tasks) only returns E_ID
201
when bad params return errors (
202
CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
203
is enabled, see above).
204
Similarly, the following conditions are only checked for,
205
and only return errors if
206
CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
207
is enabled:
208
209
210
pk_crtk in
211
cre_tsk()
212
 is a valid pointer, otherwise return E_PAR
213
214
215
ter_tsk()
216
 or
217
rel_wai()
218
 on the calling task returns E_OBJ
219
220
221
the CPU is not locked already in
222
dis_dsp()
223
 and
224
ena_dsp()
225
; returns E_CTX
226
227
228
priority level in
229
chg_pri()
230
 and
231
rot_rdq()
232
 is checked for validity, E_PAR
233
234
235
return value pointer in
236
get_tid()
237
 and
238
ref_tsk()
239
 is a valid pointer, or E_PAR
240
241
242
The following conditions are checked for, and return
243
            error codes if appropriate, regardless of the setting of
244
CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
245
:
246
247
248
When create and delete functions
249
cre_tsk()
250
 and
251
del_tsk()
252
 are supported, all calls which use a valid task ID number check
253
that the task exists; if not, E_NOEXS is returned
254
255
256
When supported,
257
cre_tsk()
258
: the task must not already exist; otherwise E_OBJ
259
260
261
When supported,
262
cre_tsk()
263
: the requested stack size must not be larger than that statically
264
configured for the task; see the configuration options
265
“Static initializers”, and “Default stack size”.
266
Else E_NOMEM
267
268
269
When supported,
270
del_tsk()
271
: the underlying
272
eCos
273
 thread must not be running - this would imply either a bug or some
274
program bypassing the
275
µITRON compatibility layer and manipulating the thread directly.
276
E_OBJ
277
278
279
sta_tsk()
280
: the task must be dormant, else E_OBJ
281
282
283
ter_tsk()
284
: the task must not be dormant, else E_OBJ
285
286
287
chg_pri()
288
: the task must not be dormant, else E_OBJ
289
290
291
rel_wai()
292
: the task must be in
293
WAIT or WAIT-SUSPEND
294
 state, else E_OBJ
295
296
297
298
299
300
<!-- <index></index> -->Task-Dependent Synchronization Functions
301
These functions are fully supported in this release: 
302
ER sus_tsk(
303
    ID tskid )
304
        
305
ER rsm_tsk(
306
    ID tskid )
307
        
308
ER frsm_tsk(
309
    ID tskid )
310
311
ER slp_tsk( void )
312
        
313
ER tslp_tsk(
314
    TMO tmout )
315
        
316
ER wup_tsk(
317
    ID tskid )
318
        
319
ER can_wup(
320
    INT *p_wupcnt,    ID tskid )
321
322
Error checking
323
The following conditions are only checked for, and only return
324
errors if
325
CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
326
is enabled (see the configuration option “Return Error Codes for Bad
327
Params”):
328
329
330
invalid tskid; less than 1 or greater than
331
CYGNUM_UITRON_TASKS
332
returns E_ID
333
334
335
wup_tsk()
336
,
337
sus_tsk()
338
,
339
rsm_tsk()
340
,
341
frsm_tsk()
342
 on the calling task returns E_OBJ
343
344
345
dispatching is enabled in
346
tslp_tsk()
347
 and
348
slp_tsk()
349
, or E_CTX
350
351
352
tmout must be positive, otherwise E_PAR
353
354
355
return value pointer in
356
can_wup()
357
 is a valid pointer, or E_PAR
358
359
360
The following conditions are checked for, and can
361
            return error codes, regardless of the setting of
362
CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS:
363
364
365
366
When create and delete functions
367
cre_tsk()
368
 and
369
del_tsk()
370
 are supported, all calls which use a valid task ID number check
371
that the task exists; if not, E_NOEXS is returned
372
373
374
sus_tsk()
375
: the task must not be dormant, else E_OBJ
376
377
378
frsm/rsm_tsk()
379
: the task must be suspended, else E_OBJ
380
381
382
tslp/slp_tsk()
383
: return codes E_TMOUT, E_RLWAI and E_DLT
384
are returned depending on the reason for terminating the sleep
385
386
387
wup_tsk()
388
 and
389
can_wup()
390
: the task must not be dormant, or E_OBJ is returned
391
392
393
394
395
396
<!-- <index></index> -->      Synchronization and Communication Functions
397
These functions are fully supported in this release: 
398
ER sig_sem(
399
    ID semid )
400
401
402
ER wai_sem(
403
    ID semid )
404
405
406
ER preq_sem(
407
    ID semid )
408
409
410
ER twai_sem(
411
    ID semid,    TMO tmout )
412
413
414
ER ref_sem(
415
    T_RSEM *pk_rsem ,    ID semid )
416
417
418
ER set_flg(
419
    ID flgid,    UINT setptn )
420
421
422
ER clr_flg(
423
    ID flgid,    UINT clrptn )
424
425
426
ER wai_flg(
427
    UINT *p_flgptn,    ID flgid ,
428
    UINT waiptn ,    UINT wfmode )
429
430
431
ER pol_flg(
432
    UINT *p_flgptn,    ID flgid ,
433
    UINT waiptn ,    UINT wfmode )
434
435
436
ER twai_flg(
437
    UINT *p_flgptn    ID flgid ,
438
    UINT waiptn ,    UINT wfmode,    TMO tmout )
439
440
441
ER ref_flg(
442
    T_RFLG *pk_rflg,    ID flgid )
443
444
445
ER snd_msg(
446
    ID mbxid,    T_MSG *pk_msg )
447
448
449
ER rcv_msg(
450
    T_MSG **ppk_msg,    ID mbxid )
451
452
453
ER prcv_msg(
454
    T_MSG **ppk_msg,    ID mbxid )
455
456
457
ER trcv_msg(
458
    T_MSG **ppk_msg,    ID mbxid ,    TMO tmout )
459
460
461
ER ref_mbx(
462
    T_RMBX *pk_rmbx,    ID mbxid )
463
The following functions are supported in this release (with
464
some restrictions) if enabled with the appropriate configuration
465
option for the object type (for example
466
CYGPKG_UITRON_SEMAS_CREATE_DELETE):
467
468
ER cre_sem(
469
    ID semid,    T_CSEM *pk_csem )
470
471
472
ER del_sem(
473
    ID semid )
474
475
476
ER cre_flg(
477
    ID flgid,    T_CFLG *pk_cflg )
478
479
480
ER del_flg(
481
    ID flgid )
482
483
484
ER cre_mbx(
485
    ID mbxid,    T_CMBX *pk_cmbx )
486
487
488
ER del_mbx(
489
    ID mbxid )
490
In general the queueing order when waiting on a synchronization
491
object depends on the underlying kernel configuration. The multi-level
492
queue scheduler is required for strict µITRON
493
conformance and it queues tasks in FIFO order, so requests to create
494
an object with priority queueing of tasks (pk_cxxx->xxxatr = TA_TPRI)
495
are rejected with E_RSATR. Additional undefined bits in
496
the attributes fields must be zero. 
497
In general, extended information (pk_cxxx->exinf)
498
is ignored. 
499
For semaphores, the initial semaphore count (pk_csem->isemcnt)
500
is supported; the new semaphore's count is set. The maximum
501
count is not supported, and is not in fact defined in type pk_csem. 
502
For flags, multiple tasks are allowed to wait. Because single
503
task waiting is a subset of this, the W bit (TA_WMUL) of
504
the flag attributes is ignored; all other bits must be zero. The
505
initial flag value is supported. 
506
For mailboxes, the buffer count is defined statically by kernel
507
configuration option
508
CYGNUM_KERNEL_SYNCH_MBOX_QUEUE_SIZE;
509
therefore the buffer count field is not supported and is not in
510
fact defined in type pk_cmbx. Queueing of messages is FIFO
511
ordered only, so TA_MPRI (in pk_cmbx->mbxatr)
512
is not supported. 
513
514
Error checking
515
The following conditions are only checked for, and only return
516
errors if
517
CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
518
is enabled:
519
520
521
invalid object id; less than 1 or greater than
522
CYGNUM_UITRON_TASKS/SEMAS/MBOXES
523
as appropriate returns E_ID
524
525
526
dispatching is enabled in any call which can sleep, or
527
E_CTX
528
529
530
tmout must be positive, otherwise E_PAR
531
532
533
pk_cxxx pointers in
534
cre_xxx()
535
 must be valid pointers, or E_PAR
536
537
538
return value pointer in
539
ref_xxx()
540
 is valid pointer, or E_PAR
541
542
543
flag wait pattern must be non-zero, and mode must be valid,
544
or E_PAR
545
546
547
return value pointer in flag wait calls is a valid pointer,
548
or E_PAR
549
550
551
The following conditions are checked for, and can return error
552
codes, regardless of the setting of
553
CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
554
:
555
556
557
When create and delete functions
558
cre_xxx()
559
 and
560
del_xxx()
561
 are supported, all calls which use a valid object ID number check
562
that the object exists. If not, E_NOEXS is returned.
563
564
565
In create functions
566
cre_xxx()
567
, when supported, if the object already exists, then E_OBJ
568
569
570
In any call which can sleep, such as
571
twai_sem()
572
: return codes E_TMOUT, E_RLWAI, E_DLT
573
or of course E_OK are returned depending on the reason
574
for terminating the sleep
575
576
577
In polling functions such as
578
preq_sem()
579
return codes E_TMOUT or E_OK are returned depending
580
on the state of the synchronization object
581
582
583
In creation functions, the attributes must be compatible
584
with the selected underlying kernel configuration: in
585
cre_sem()
586
 pk_csem->sematr
587
 must be equal to
588
TA_TFIFO
589
 else E_RSATR.
590
591
592
In
593
cre_flg()
594
 pk_cflg->flgatr
595
 must be either
596
TA_WMUL
597
 or
598
TA_WSGL
599
 else E_RSATR.
600
601
602
In
603
cre_mbx()
604
 
605
pk_cmbx->mbxatr
606
 must be
607
TA_TFIFO + TA_MFIFO
608
 else E_RSATR.
609
610
611
612
613
614
<!-- <index></index> -->Extended Synchronization and Communication Functions
615
None of these functions are supported in this release. 
616
617
618
<!-- <index></index> -->Interrupt management functions
619
These functions are fully supported in this release:
620
void     ret_int( void )
621
622
623
ER loc_cpu( void )
624
625
626
ER unl_cpu( void )
627
628
629
ER dis_int(
630
    UINT eintno )
631
632
633
ER ena_int(
634
    UINT eintno )
635
636
637
void    ret_wup(
638
    ID tskid )
639
640
641
ER iwup_tsk(
642
    ID tskid )
643
644
645
ER isig_sem(
646
    ID semid )
647
648
649
ER iset_flg(
650
    ID flgid ,
651
    UID setptn )
652
653
654
ER isend_msg(
655
    ID mbxid ,
656
    T_MSG *pk_msg )
657
Note that ret_int() and
658
the ret_wup() are  implemented
659
as macros, containing a “return” statement.
660
Also note that ret_wup() and
661
the ixxx_yyy() style functions
662
will only work when called from an ISR whose associated DSR is cyg_uitron_dsr(),
663
as specified in include file <cyg/compat/uitron/uit_ifnc.h>,
664
which defines the ixxx_yyy() style
665
functions also.
666
If you are writing interrupt handlers more in the
667
eCos style, with separate ISR and DSR routines both of
668
your own devising, do not use these special functions from a DSR: use plain
669
xxx_yyy() style functions (with no ‘i’ prefix)
670
instead, and do not call any µITRON functions from the ISR at
671
all.
672
The following functions are not supported in this release: 
673
ER def_int(
674
    UINT dintno,
675
  T_DINT *pk_dint )
676
        
677
ER chg_iXX(
678
    UINT iXXXX )
679
  
680
        
681
ER ref_iXX(
682
    UINT * p_iXXXX )
683
These unsupported functions are all Level C (CPU dependent).
684
Equivalent functionality is available via other eCos-specific
685
APIs. 
686
687
Error checking
688
The following conditions are only checked for, and only return
689
errors if
690
CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
691
is enabled:
692
693
694
loc/unl_cpu()
695
: these must only be called in a
696
µITRON task context, else E_CTX.
697
698
699
dis/ena_int()
700
: the interrupt number must be in range as specified by the platform
701
HAL in qustion, else E_PAR.
702
703
704
705
706
707
<!-- <index></index> -->      Memory pool Management Functions
708
These functions are fully supported in this release: 
709
ER get_blf(
710
    VP *p_blf,    ID mpfid )
711
712
713
ER pget_blf(
714
    VP *p_blf,    ID mpfid )
715
716
717
ER tget_blf(
718
    VP *p_blf,    ID mpfid,    TMO tmout )
719
720
721
ER rel_blf(
722
    ID mpfid,    VP blf )
723
724
725
ER ref_mpf(
726
    T_RMPF *pk_rmpf,    ID mpfid )
727
728
729
ER get_blk(
730
    VP *p_blk,    ID mplid,    INT blksz )
731
732
733
ER pget_blk(
734
    VP *p_blk,    ID mplid,    INT blksz )
735
736
737
ER tget_blk(
738
    VP *p_blk,    ID mplid,    INT blksz,    TMO tmout )
739
740
741
ER rel_blk(
742
    ID mplid,    VP blk )
743
744
745
ER ref_mpl(
746
    T_RMPL *pk_rmpl,    ID mplid )
747
748
 
749
Note that of the memory provided for a particular pool to
750
manage in the static initialization of the memory pool objects,
751
some memory will be used to manage the pool itself. Therefore the
752
number of blocks * the blocksize will be less than the total
753
memory size. 
754
The following functions are supported in this release, when
755
enabled with
756
CYGPKG_UITRON_MEMPOOLVAR_CREATE_DELETE
757
or
758
CYGPKG_UITRON_MEMPOOLFIXED_CREATE_DELETE
759
as appropriate, with some restrictions: 
760
ER cre_mpl(
761
    ID mplid,    T_CMPL *pk_cmpl )
762
763
764
ER del_mpl(
765
    ID mplid )
766
767
768
ER cre_mpf(
769
    ID mpfid,    T_CMPF *pk_cmpf )
770
771
772
ER del_mpf(
773
    ID mpfid )
774
Because of the static initialization facilities provided for
775
system objects, a memory pool is allocated a region of memory to
776
manage statically in the configuration. So while memory pools can
777
be created and deleted, the same area of memory is used for that
778
memory pool (memory pool ID number) each time. The requested variable pool
779
size (pk_cmpl->mplsz) or the number of fixed-size
780
blocks (pk_cmpf->mpfcnt) times the block size
781
(pk_cmpf->blfsz) are checked for fitting within
782
the statically allocated memory area, so if a create call succeeds,
783
the resulting pool will be at least as large as that requested.
784
For this reason del_mpl() and del_mpf() do
785
not in any sense free the memory that was managed by the deleted
786
pool for use by other pools; it may only be managed by a pool of
787
the same object id. 
788
For both fixed and variable memory pools, the queueing order
789
when waiting on a synchronization object depends on the underlying
790
kernel configuration. The multi-level queue scheduler is required
791
for strict µITRON conformance and
792
it queues tasks in FIFO order, so requests to create an object with
793
priority queueing of tasks (pk_cxxx->xxxatr = TA_TPRI)
794
are rejected with E_RSATR. Additional undefined bits in
795
the attributes fields must be zero. 
796
In general, extended information (pk_cxxx->exinf)
797
is ignored. 
798
799
Error checking
800
The following conditions are only checked for, and only return
801
errors if
802
CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
803
is enabled:
804
805
806
invalid object id; less than 1 or greater than
807
CYGNUM_UITRON_MEMPOOLVAR/MEMPOOLFIXED
808
as appropriate returns E_ID
809
810
811
dispatching is enabled in any call which can sleep, or
812
E_CTX
813
814
815
tmout must be positive, otherwise E_PAR
816
817
818
pk_cxxx pointers in
819
cre_xxx()
820
 must be valid pointers, or E_PAR
821
822
823
return value pointer in
824
ref_xxx()
825
 is a valid pointer, or E_PAR
826
827
828
return value pointers in get block routines is a valid
829
pointer, or E_PAR
830
831
832
blocksize request in get variable block routines is greater
833
than zero, or E_PAR
834
835
836
The following conditions are checked for, and can return error
837
codes, regardless of the setting of
838
CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS:
839
840
841
842
When create and delete functions
843
cre_xxx()
844
 and
845
del_xxx()
846
 are supported, all calls which use a valid object ID number check
847
that the object exists. If not, E_NOEXS is returned.
848
849
850
When create functions
851
cre_xxx()
852
 are supported, if the object already exists, then E_OBJ
853
854
855
In any call which can sleep, such as
856
get_blk()
857
: return codes E_TMOUT, E_RLWAI, E_DLT
858
or of course E_OK are returned depending on the reason
859
for terminating the sleep
860
861
862
In polling functions such as
863
pget_blk()
864
return codes E_TMOUT or E_OK are returned depending
865
on the state of the synchronization object
866
867
868
In creation functions, the attributes must be compatible
869
with the selected underlying kernel configuration: in
870
cre_mpl()
871
 
872
pk_cmpl->mplatr
873
 must be equal to
874
TA_TFIFO
875
 else E_RSATR.
876
877
878
In
879
cre_mpf()
880
 
881
pk_cmpf->mpfatr
882
 must be equal to
883
TA_TFIFO
884
 else E_RSATR.
885
886
887
In creation functions, the requested size of the memory
888
pool must not be larger than that statically configured for the
889
pool else E_RSATR; see the configuration option
890
“Option: Static initializers”.
891
 In
892
cre_mpl()
893
 
894
pk_cmpl->mplsz
895
 is the field of interest
896
897
898
In
899
cre_mpf()
900
 the product of
901
pk_cmpf->blfsz
902
 and
903
pk_cmpf->mpfcnt
904
 must be smaller than the memory statically configured for the pool
905
else E_RSATR
906
907
908
In functions which return memory to the pool
909
rel_blk()
910
 and
911
rel_blf()
912
, if the free fails, for example because the memory did not come
913
from that pool originally, then E_PAR is returned
914
915
916
917
918
919
<!-- <index></index> -->Time Management Functions
920
These functions are fully supported in this release: 
921
ER set_tim(
922
    SYSTIME *pk_tim )
923
924
            Setting the time may cause erroneous operation of the
925
            kernel, for example a task performing a wait with a
926
            time-out may never awaken.
927
928
ER get_tim(
929
    SYSTIME *pk_tim )
930
931
932
ER dly_tsk(
933
    DLYTIME dlytim )
934
935
936
ER def_cyc(
937
    HNO cycno,    T_DCYC *pk_dcyc )
938
939
940
ER act_cyc(
941
    HNO cycno,    UINT cycact )
942
943
944
ER ref_cyc(
945
    T_RCYC *pk_rcyc,    HNO cycno )
946
947
948
ER def_alm(
949
    HNO almno,    T_DALM *pk_dalm )
950
951
952
ER ref_alm(
953
    T_RALM *pk_ralm,    HNO almno )
954
955
956
void ret_tmr( void )
957
        
958
          Error checking
959
The following conditions are only checked for, and only return
960
errors if
961
CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
962
is enabled:
963
964
965
invalid handler number; less than 1 or greater than
966
CYGNUM_UITRON_CYCLICS/ALARMS
967
as appropriate, or E_PAR
968
969
970
dispatching is enabled in
971
dly_tsk()
972
, or E_CTX
973
974
975
dlytim must be positive or zero, otherwise E_PAR
976
977
978
return value pointer in
979
ref_xxx()
980
 is a valid pointer, or E_PAR
981
982
983
params within pk_dalm and pk_dcyc must
984
be valid, or E_PAR
985
986
987
cycact in
988
act_cyc()
989
 must be valid, or E_PAR
990
991
992
handler must be defined in
993
ref_xxx()
994
 and
995
act_cyc()
996
, or E_NOEXS
997
998
999
parameter pointer must be a good pointer in
1000
get_tim()
1001
 and
1002
set_tim()
1003
, otherwise E_PAR is returned
1004
1005
1006
The following conditions are checked for, and can return
1007
          error codes, regardless of the setting of
1008
CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
1009
:
1010
1011
1012
dly_tsk()
1013
: return code E_RLWAI is returned depending on the reason
1014
for terminating the sleep
1015
1016
1017
1018
1019
1020
<!-- <index></index> -->      System Management Functions
1021
These functions are fully supported in this release:
1022
        
1023
ER get_ver(
1024
    T_VER *pk_ver )
1025
1026
ER ref_sys(
1027
    T_RSYS *pk_rsys )
1028
1029
ER ref_cfg(
1030
    T_RCFG *pk_rcfg )
1031
1032
Note that the information returned by each of these calls
1033
may be configured to match the user's own versioning system,
1034
and the values supplied by the default configuration may be inappropriate. 
1035
These functions are not supported in this release: 
1036
ER def_svc(
1037
    FN s_fncd,
1038
    T_DSVC *pk_dsvc )
1039
1040
ER def_exc(
1041
    UINT exckind,
1042
    T_DEXC *pk_dexc )
1043
1044
1045
Error checking
1046
The following conditions are only checked for, and
1047
            only return errors if
1048
 
1049
CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
1050
 is enabled: 
1051
1052
1053
return value pointer in all calls is a valid
1054
              pointer, or E_PAR
1055
1056
1057
1058
1059
1060
<!-- <index></index> -->      Network Support Functions
1061
None of these functions are supported in this release.
1062
        
1063
1064
1065
<!-- <index></index> -->µITRON Configuration FAQ
1066
Q: How are µITRON objects created?
1067
1068
1069
For each type of uITRON object (tasks, semaphores, flags, mboxes, mpf, mpl)
1070
these two quantities are controlled by configuration:
1071
1072
1073
1074
The maximum number of this type of object.
1075
1076
1077
The number of these objects which exist initially.
1078
1079
1080
1081
This is assuming that for the relevant object type,
1082
create and delete
1083
operations are enabled; enabled is the default.  For example, the option
1084
CYGPKG_UITRON_MBOXES_CREATE_DELETE
1085
controls whether the functions
1086
cre_mbx()
1087
and
1088
del_mbx()
1089
exist in the API.  If not, then the maximum number of
1090
mboxes is the same as the initial number of mboxes, and so on for all
1091
µITRON object types.
1092
1093
1094
Mboxes have no initialization, so there are only a few, simple
1095
configuration options:
1096
1097
1098
1099
CYGNUM_UITRON_MBOXES
1100
is the total number of mboxes that you can have in the
1101
system.  By default this is 4, so you can use mboxes 1,2,3 and 4.  You
1102
cannot create mboxes outside this range; trying to
1103
cre_mbx(5,...)
1104
will return an error.
1105
1106
1107
CYGNUM_UITRON_MBOXES_INITIALLY
1108
is the number of mboxes created
1109
automatically for you, during startup.  By default this is 4, so all 4
1110
mboxes exist already, and an attempt to create one of these
1111
eg. cre_mbx(3,...)
1112
will return an error because the mbox in quesion already
1113
exists.  You can delete a pre-existing mbox, and then re-create it.
1114
1115
1116
1117
If you change
1118
CYGNUM_UITRON_MBOXES_INITIALLY,
1119
for example to 0, no mboxes
1120
are created automatically for you during startup.  Any attempt to use an
1121
mbox without creating it will return E_NOEXS because the mbox does not
1122
exist.  You can create an mbox, say cre_mbx(3,...)
1123
and then use it, say
1124
snd_msg(3,&foo), and all will be well.
1125
1126
Q: How are µITRON objects initialized?
1127
1128
1129
Some object types have optional initialization.  Semaphores are an
1130
example.  You could have
1131
CYGNUM_UITRON_SEMAS=10 and
1132
CYGNUM_UITRON_SEMAS_INITIALLY=5
1133
which means you can use semaphores 1-5
1134
straight off, but you must create semaphores 6-10 before you can use them.
1135
If you decide not to initialize semaphores, semaphores 1-5 will have an
1136
initial count of zero.  If you decide to initialize them, you must supply
1137
a dummy initializer for semaphores 6-10 also.  For example,
1138
in terms of the configuration output in
1139
pkgconf/uitron.h:
1140
1141
1142
   #define CYGDAT_UITRON_SEMA_INITIALIZERS \
1143
        CYG_UIT_SEMA(  1 ),     \
1144
        CYG_UIT_SEMA(  0 ),     \
1145
        CYG_UIT_SEMA(  0 ),     \
1146
        CYG_UIT_SEMA( 99 ),     \
1147
        CYG_UIT_SEMA(  1 ),     \
1148
        CYG_UIT_SEMA_NOEXS,     \
1149
        CYG_UIT_SEMA_NOEXS,     \
1150
        CYG_UIT_SEMA_NOEXS,     \
1151
        CYG_UIT_SEMA_NOEXS,     \
1152
        CYG_UIT_SEMA_NOEXS
1153
1154
1155
Semaphore 1 will have initial count 1, semaphores 2 and 3 will be zero,
1156
number 4 will be 99 initially, 5 will be one and numbers 6 though 10 do not
1157
exist initially.
1158
1159
1160
Aside: this is how the definition of the symbol would appear in the
1161
configuration header file pkgconf/uitron.h
1162
unfortunately editing such a long, multi-line definition is somewhat
1163
cumbersome in the GUI config tool in current releases.  The macros
1164
CYG_UIT_SEMA()
1165
— to create a semaphore initializer — and
1166
CYG_UIT_SEMA_NOEXS
1167
— to invoke a dummy initializer —
1168
are provided in in the environment to help with this.  Similar macros are
1169
provided for other object types.  The resulting #define symbol is used in
1170
the context of a C++ array initializer, such as:
1171
1172
Cyg_Counting_Semaphore2 cyg_uitron_SEMAS[ CYGNUM_UITRON_SEMAS ] = {
1173
        CYGDAT_UITRON_SEMA_INITIALIZERS
1174
};
1175
1176
which is eventually macro-processed to give
1177
1178
Cyg_Counting_Semaphore2 cyg_uitron_SEMAS[ 10 ] = {
1179
        Cyg_Counting_Semaphore2( ( 1 ) ),
1180
        Cyg_Counting_Semaphore2( ( 0 ) ),
1181
        Cyg_Counting_Semaphore2( ( 0 ) ),
1182
        Cyg_Counting_Semaphore2( ( 99 ) ),
1183
        Cyg_Counting_Semaphore2( ( 1 ) ),
1184
        Cyg_Counting_Semaphore2(0),
1185
        Cyg_Counting_Semaphore2(0),
1186
        Cyg_Counting_Semaphore2(0),
1187
        Cyg_Counting_Semaphore2(0),
1188
        Cyg_Counting_Semaphore2(0),
1189
};
1190
1191
so you can see how it is necessary to include the dummy entries in that
1192
definition, otherwise the resulting code will not compile correctly.
1193
1194
1195
If you choose
1196
CYGNUM_UITRON_SEMAS_INITIALLY=0
1197
it is meaningless to initialize them, for they must be created and so
1198
initialized then, before use.
1199
1200
Q: What about µITRON tasks?
1201
1202
1203
Some object types require initialization.  Tasks are an example of this.
1204
You must provide a task with a priority, a function to enter when the task
1205
starts, a name (for debugging purposes), and some memory to use for the stack.
1206
For example (again in terms of the resulting
1207
definitions in pkgconf/uitron.h):
1208
1209
1210
#define CYGNUM_UITRON_TASKS 4           // valid task ids are 1,2,3,4
1211
#define CYGNUM_UITRON_TASKS_INITIALLY 4 // they all exist at start
1212
 
1213
#define CYGDAT_UITRON_TASK_EXTERNS              \
1214
extern "C" void startup( unsigned int );        \
1215
extern "C" void worktask( unsigned int );       \
1216
extern "C" void lowtask( unsigned int );        \
1217
static char stack1[ CYGNUM_UITRON_STACK_SIZE ], \
1218
            stack2[ CYGNUM_UITRON_STACK_SIZE ], \
1219
            stack3[ CYGNUM_UITRON_STACK_SIZE ], \
1220
            stack4[ CYGNUM_UITRON_STACK_SIZE ];
1221
 
1222
#define CYGDAT_UITRON_TASK_INITIALIZERS \
1223
 CYG_UIT_TASK("main task", 8, startup,  &stack1, sizeof( stack1 )), \
1224
 CYG_UIT_TASK("worker 2" , 9, worktask, &stack2, sizeof( stack2 )), \
1225
 CYG_UIT_TASK("worker 3" , 9, worktask, &stack3, sizeof( stack3 )), \
1226
 CYG_UIT_TASK("low task" ,20, lowtask,  &stack4, sizeof( stack4 )), \
1227
 
1228
1229
1230
So this example has all four tasks statically configured to exist, ready to
1231
run, from the start of time.  The “main task” runs a routine
1232
called startup() at priority 8.  Two
1233
“worker” tasks run both a priority 9, and a “low
1234
priority” task runs at priority 20 to do useful non-urgent background
1235
work.
1236
1237
1238
Task ID | Exists at | Function | Priority | Stack   | Stack
1239
 number |  startup  |  entry   |          | address | size
1240
--------+-----------+----------+----------+---------+----------
1241
   1    |    Yes    |  startup |    8     | &stack1 | CYGNUM...
1242
   2    |    Yes    | worktask |    9     | &stack2 | CYGNUM...
1243
   3    |    Yes    | worktask |    9     | &stack3 | CYGNUM...
1244
   4    |    Yes    |  lowtask |   20     | &stack4 | CYGNUM...
1245
--------+-----------+----------+----------+---------+----------
1246
1247
Q: How can I create µITRON tasks in the program?
1248
1249
1250
You must provide free slots in the task table in which to create new tasks,
1251
by configuring the number of tasks existing initially to be smaller than
1252
the total.
1253
For a task ID which does not initially exist, it will be told what routine
1254
to call, and what priority it is, when the task is created.  But you must
1255
still set aside memory for the task to use for its stack, and give it a
1256
name during initialization.  For example:
1257
1258
 
1259
1260
#define CYGNUM_UITRON_TASKS 4           // valid task ids are 1-4
1261
#define CYGNUM_UITRON_TASKS_INITIALLY 1 // only task #1 exists
1262
 
1263
#define CYGDAT_UITRON_TASK_EXTERNS \
1264
extern "C" void startup( unsigned int ); \
1265
static char stack1[ CYGNUM_UITRON_STACK_SIZE ], \
1266
            stack2[ CYGNUM_UITRON_STACK_SIZE ], \
1267
            stack3[ CYGNUM_UITRON_STACK_SIZE ], \
1268
            stack4[ CYGNUM_UITRON_STACK_SIZE ];
1269
 
1270
#define CYGDAT_UITRON_TASK_INITIALIZERS \
1271
   CYG_UIT_TASK( "main", 8, startup, &stack1, sizeof( stack1 ) ), \
1272
   CYG_UIT_TASK_NOEXS( "slave",      &stack2, sizeof( stack2 ) ), \
1273
   CYG_UIT_TASK_NOEXS( "slave2",     &stack3, sizeof( stack3 ) ), \
1274
   CYG_UIT_TASK_NOEXS( "slave3",     &stack4, sizeof( stack4 ) ), \
1275
 
1276
1277
1278
So tasks numbered 2,3 and 4 have been given their stacks during startup,
1279
though they do not yet exist in terms of cre_tsk() and
1280
del_tsk() so you can create tasks 2–4 at
1281
runtime.
1282
1283
1284
Task ID | Exists at | Function | Priority | Stack   | Stack
1285
 number |  startup  |  entry   |          | address | size
1286
--------+-----------+----------+----------+---------+----------
1287
   1    |    Yes    |  startup |    8     | &stack1 | CYGNUM...
1288
   2    |    No     |   N/A    |   N/A    | &stack2 | CYGNUM...
1289
   3    |    No     |   N/A    |   N/A    | &stack3 | CYGNUM...
1290
   4    |    No     |   N/A    |   N/A    | &stack4 | CYGNUM...
1291
--------+-----------+----------+----------+---------+----------
1292
1293
1294
(you must have at least one task at startup in order that the system can
1295
 actually run; this is not so for other uITRON object types)
1296
1297
Q: Can I have different stack sizes for µITRON tasks?
1298
1299
1300
Simply set aside different amounts of memory for each task to use for its
1301
stack.  Going back to a typical default setting for the µITRON tasks,
1302
the definitions in pkgconf/uitron.h might look like this:
1303
1304
1305
#define CYGDAT_UITRON_TASK_EXTERNS \
1306
extern "C" void task1( unsigned int ); \
1307
extern "C" void task2( unsigned int ); \
1308
extern "C" void task3( unsigned int ); \
1309
extern "C" void task4( unsigned int ); \
1310
static char stack1[ CYGNUM_UITRON_STACK_SIZE ], \
1311
            stack2[ CYGNUM_UITRON_STACK_SIZE ], \
1312
            stack3[ CYGNUM_UITRON_STACK_SIZE ], \
1313
            stack4[ CYGNUM_UITRON_STACK_SIZE ];
1314
 
1315
#define CYGDAT_UITRON_TASK_INITIALIZERS \
1316
  CYG_UIT_TASK( "t1", 1, task1, &stack1, CYGNUM_UITRON_STACK_SIZE ), \
1317
  CYG_UIT_TASK( "t2", 2, task2, &stack2, CYGNUM_UITRON_STACK_SIZE ), \
1318
  CYG_UIT_TASK( "t3", 3, task3, &stack3, CYGNUM_UITRON_STACK_SIZE ), \
1319
  CYG_UIT_TASK( "t4", 4, task4, &stack4, CYGNUM_UITRON_STACK_SIZE )
1320
 
1321
1322
1323
Note that
1324
CYGNUM_UITRON_STACK_SIZE
1325
is used to control the size of the stack
1326
objects themselves, and to tell the system what size stack is being provided.
1327
1328
1329
Suppose instead stack sizes of 2000, 1000, 800 and 800 were required:
1330
this could be achieved by using the GUI config tool to edit these
1331
options, or editting the .ecc file to get these
1332
results in pkgconf/uitron.h:
1333
1334
1335
#define CYGDAT_UITRON_TASK_EXTERNS \
1336
extern "C" void task1( unsigned int ); \
1337
extern "C" void task2( unsigned int ); \
1338
extern "C" void task3( unsigned int ); \
1339
extern "C" void task4( unsigned int ); \
1340
static char stack1[ 2000 ], \
1341
            stack2[ 1000 ], \
1342
            stack3[  800 ], \
1343
            stack4[  800 ];
1344
 
1345
#define CYGDAT_UITRON_TASK_INITIALIZERS \
1346
      CYG_UIT_TASK( "t1", 1, task1, &stack1, sizeof( stack1 ) ), \
1347
      CYG_UIT_TASK( "t2", 2, task2, &stack2, sizeof( stack2 ) ), \
1348
      CYG_UIT_TASK( "t3", 3, task3, &stack3, sizeof( stack3 ) ), \
1349
      CYG_UIT_TASK( "t4", 4, task4, &stack4, sizeof( stack4 ) )
1350
1351
1352
Note that the sizeof() operator has been used to tell the system what size
1353
stacks are provided, rather than quoting a number (which is difficult for
1354
maintenance) or the symbol
1355
CYGNUM_UITRON_STACK_SIZE
1356
(which is wrong).
1357
1358
1359
We recommend using (if available in your release) the stacksize symbols
1360
provided in the architectural HAL for your target, called
1361
CYGNUM_HAL_STACK_SIZE_TYPICAL
1362
and
1363
CYGNUM_HAL_STACK_SIZE_MINIMUM.
1364
So a better (more portable) version of the above might be:
1365
1366
1367
#define CYGDAT_UITRON_TASK_EXTERNS \
1368
extern "C" void task1( unsigned int ); \
1369
extern "C" void task2( unsigned int ); \
1370
extern "C" void task3( unsigned int ); \
1371
extern "C" void task4( unsigned int ); \
1372
static char stack1[ CYGNUM_HAL_STACK_SIZE_TYPICAL + 1200 ], \
1373
            stack2[ CYGNUM_HAL_STACK_SIZE_TYPICAL +  200 ], \
1374
            stack3[ CYGNUM_HAL_STACK_SIZE_TYPICAL        ], \
1375
            stack4[ CYGNUM_HAL_STACK_SIZE_TYPICAL        ];
1376
 
1377
#define CYGDAT_UITRON_TASK_INITIALIZERS \
1378
      CYG_UIT_TASK( "t1", 1, task1, &stack1, sizeof( stack1 ) ), \
1379
      CYG_UIT_TASK( "t2", 2, task2, &stack2, sizeof( stack2 ) ), \
1380
      CYG_UIT_TASK( "t3", 3, task3, &stack3, sizeof( stack3 ) ), \
1381
      CYG_UIT_TASK( "t4", 4, task4, &stack4, sizeof( stack4 ) )
1382
1383
1384
1385

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.