-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathos_cpu_a.lst
executable file
·1422 lines (1371 loc) · 80.1 KB
/
os_cpu_a.lst
1
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
GAS LISTING C:\Users\Kwon\AppData\Local\Temp/ccS8aaaa.s page 1
1 # 1 "C:/Software/uCOS-II/Ports/AVR/ATmega128/GNU/jlu/os_cpu_a.asm"
2 # 1 "<built-in>"
1 ;**************************************************************************************************
0
0
2 ; uC/OS-II
3 ; The Real-Time Kernel
4 ;
5 ; AVR Specific code
6 ; (AVR-GCC 3.x)
7 ;
8 ;
9 ; File : OS_CPU_A.ASM
10 ; By : Ole Saether
11 ; Port Version : V1.01
12 ;
13 ; AVR-GCC port version : 1.0 2001-04-02 modified/ported to avr-gcc by Jesper Hansen (jesperh@telia
14 ;
15 ; Modifications by Julius Luukko 2003-02-19 ([email protected]):
16 ;
17 ; - Minor modification to OSTickISR's declaration to global and addition of #include <avr/io.h>
18 ; in order to work with gcc 3.3.
19 ; - Moved 'sei' from the beginning of OSTickISR after the increasing of OSIntNesting (as the book s
20 ; - Changed the order of reloading the timer counter and calling of OSIntExit
21 ; - Changed OSIntCtxSw to the way it is supposed to be with OS_VERSION >= 251
22 ; - Changed OSTickISR so that is saves the stack pointer into the current task's OS_TCB if OSTickIS
23 ; first level ISR
24 ; - os_cfg.h must be included (definitions of CPU_CLOCK_HZ and OS_TICKS_PER_SEC)
25 ; - avr/io.h is included to get SIG_OVERFLOW0 to produce the code to the interrupt vector table
26 ;
27 ; Modifications by Julius Luukko 2003-03-06 ([email protected]):
28 ;
29 ; - RAMPZ is also saved to the stack
30 ;
31 ; Modifications by Julius Luukko 2003-03-18 ([email protected]):
32 ;
33 ; - RAMPZ and SREG were popped out of the stack in the wrong order! Corrected this.
34 ; - Divided macros PUSHRS and POPRS into to macros PUSHRS, PUSHSREG, POPRS and POPSREG. Additionall
35 ; in ISRs macro called PUSHSREGISR must be used. It sets the I bit i SREG, since its always unset,
36 ; ISR is entered. It must be, however, set to enable interrupts when the task is run again.
37 ; - RCALLs changed to CALLs. This allows the code of called functions to be further away from the c
38 ; (fixes the "relocating truncated to fit" error from the linker)
39 ;
40 ;
41 ; Modifications by Julius Luukko 2003-03-19 ([email protected]):
42 ;
43 ; - timer interrupt is changed so that the timer counter register is updated right after _not_first
44 ; (was AFTER the call to OSIntExit!!)
45 ;
46 ; Modifications by Julius Luukko 2003-06-24 ([email protected]):
47 ;
48 ; - I/O port addressing is now done using the macro _SFR_IO_ADDR from avr-libc and the address
49 ; definitions are removed from here
50 ; - RAMPZ is pushed and popped only if it is defined, i.e. with chips that have it
51 ;
52 ; Modifications by Julius Luukko 2003-07-21 ([email protected]) for V2.70
53 ;
GAS LISTING C:\Users\Kwon\AppData\Local\Temp/ccS8aaaa.s page 2
54 ; - OSTaskSwHook is not called if OS_TASK_SW_HOOK_EN == 0
55 ; - defines typedef to ; so that os_cfg_r.h can be used more easily as a starting point for
56 ; the application specific os_cfg.h
57 ;
58 ;**************************************************************************************************
59
60 ;**************************************************************************************************
61 ; C PREPROCESSOR DIRECTIVES
62 ;**************************************************************************************************
63
64 #include <avr/io.h>
1 /* Copyright (c) 2002,2003 Marek Michalkiewicz, Joerg Wunsch
2 All rights reserved.
3
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions are met:
6
7 * Redistributions of source code must retain the above copyright
8 notice, this list of conditions and the following disclaimer.
9 * Redistributions in binary form must reproduce the above copyright
10 notice, this list of conditions and the following disclaimer in
11 the documentation and/or other materials provided with the
12 distribution.
13
14 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
18 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24 POSSIBILITY OF SUCH DAMAGE. */
25
26 /* $Id: io.h,v 1.10 2003/02/28 23:03:40 marekm Exp $ */
27
28 /** \defgroup avr_io AVR device-specific IO definitions
29 \code #include <avr/io.h> \endcode
30
31 This header file includes the apropriate IO definitions for the
32 device that has been specified by the <tt>-mmcu=</tt> compiler
33 command-line switch. This is done by diverting to the appropriate
34 file <tt><avr/io</tt><em>XXXX</em><tt>.h></tt> which should
35 never be included directly. Some register names common to all
36 AVR devices are defined directly within <tt><avr/io.h></tt>,
37 but most of the details come from the respective include file.
38
39 Note that this file always includes
40 \code #include <avr/sfr_defs.h> \endcode
41 See \ref avr_sfr for the details.
42
43 Included are definitions of the IO register set and their
44 respective bit values as specified in the Atmel documentation.
45 Note that Atmel is not very consistent in its naming conventions,
46 so even identical functions sometimes get different names on
GAS LISTING C:\Users\Kwon\AppData\Local\Temp/ccS8aaaa.s page 3
47 different devices.
48
49 Also included are the specific names useable for interrupt
50 function definitions as documented
51 \ref avr_signames "here".
52
53 Finally, the following macros are defined:
54
55 - \b RAMEND
56 <br>
57 A constant describing the last on-chip RAM location.
58 <br>
59 - \b XRAMEND
60 <br>
61 A constant describing the last possible location in RAM.
62 This is equal to RAMEND for devices that do not allow for
63 external RAM.
64 <br>
65 - \b E2END
66 <br>
67 A constant describing the address of the last EEPROM cell.
68 <br>
69 - \b FLASHEND
70 <br>
71 A constant describing the last byte address in flash ROM.
72 <br>
73 - \b SPM_PAGESIZE
74 <br>
75 For devices with bootloader support, the flash pagesize
76 (in bytes) to be used for the \c SPM instruction. */
77
78 #ifndef _AVR_IO_H_
79 #define _AVR_IO_H_
80
81 #include <avr/sfr_defs.h>
1 /* Copyright (c) 2002, Marek Michalkiewicz <[email protected]>
2 All rights reserved.
3
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions are met:
6
7 * Redistributions of source code must retain the above copyright
8 notice, this list of conditions and the following disclaimer.
9 * Redistributions in binary form must reproduce the above copyright
10 notice, this list of conditions and the following disclaimer in
11 the documentation and/or other materials provided with the
12 distribution.
13
14 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
18 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
GAS LISTING C:\Users\Kwon\AppData\Local\Temp/ccS8aaaa.s page 4
23 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24 POSSIBILITY OF SUCH DAMAGE. */
25
26 /* avr/sfr_defs.h - macros for accessing AVR special function registers */
27
28 /* $Id: sfr_defs.h,v 1.10 2003/08/11 21:42:13 troth Exp $ */
29
30 #ifndef _AVR_SFR_DEFS_H_
31 #define _AVR_SFR_DEFS_H_ 1
32
33 /** \defgroup avr_sfr_notes Additional notes from <avr/sfr_defs.h>
34 \ingroup avr_sfr
35
36 The \c <avr/sfr_defs.h> file is included by all of the \c <avr/ioXXXX.h>
37 files, which use macros defined here to make the special function register
38 definitions look like C variables or simple constants, depending on the
39 <tt>_SFR_ASM_COMPAT</tt> define. Some examples from \c <avr/iom128.h> to
40 show how to define such macros:
41
42 \code
43 #define PORTA _SFR_IO8(0x1b)
44 #define TCNT1 _SFR_IO16(0x2c)
45 #define PORTF _SFR_MEM8(0x61)
46 #define TCNT3 _SFR_MEM16(0x88)
47 \endcode
48
49 If \c _SFR_ASM_COMPAT is not defined, C programs can use names like
50 <tt>PORTA</tt> directly in C expressions (also on the left side of
51 assignment operators) and GCC will do the right thing (use short I/O
52 instructions if possible). The \c __SFR_OFFSET definition is not used in
53 any way in this case.
54
55 Define \c _SFR_ASM_COMPAT as 1 to make these names work as simple constants
56 (addresses of the I/O registers). This is necessary when included in
57 preprocessed assembler (*.S) source files, so it is done automatically if
58 \c __ASSEMBLER__ is defined. By default, all addresses are defined as if
59 they were memory addresses (used in \c lds/sts instructions). To use these
60 addresses in \c in/out instructions, you must subtract 0x20 from them.
61
62 For more backwards compatibility, insert the following at the start of your
63 old assembler source file:
64
65 \code
66 #define __SFR_OFFSET 0
67 \endcode
68
69 This automatically subtracts 0x20 from I/O space addresses, but it's a
70 hack, so it is recommended to change your source: wrap such addresses in
71 macros defined here, as shown below. After this is done, the
72 <tt>__SFR_OFFSET</tt> definition is no longer necessary and can be removed.
73
74 Real example - this code could be used in a boot loader that is portable
75 between devices with \c SPMCR at different addresses.
76
77 \verbatim
78 <avr/iom163.h>: #define SPMCR _SFR_IO8(0x37)
79 <avr/iom128.h>: #define SPMCR _SFR_MEM8(0x68)
GAS LISTING C:\Users\Kwon\AppData\Local\Temp/ccS8aaaa.s page 5
80 \endverbatim
81
82 \code
82
83 /*
84 * Registers common to all AVR devices.
85 */
86
87 #if __AVR_ARCH__ != 1
88 /*
89 * AVR architecture 1 has no RAM, thus no stack pointer.
90 *
91 * All other archs do have a stack pointer. Some devices have only
92 * less than 256 bytes of possible RAM locations (128 Bytes of SRAM
93 * and no option for external RAM), thus SPH is officially "reserved"
94 * for them. We catch this case below after including the
95 * device-specific ioXXXX.h file, by examining XRAMEND, and
96 * #undef-ining SP and SPH in that case.
97 */
98 /* Stack Pointer */
99 #define SP _SFR_IO16(0x3D)
100 #define SPL _SFR_IO8(0x3D)
101 #define SPH _SFR_IO8(0x3E)
102 #endif /* #if __AVR_ARCH__ != 1 */
103
104 /* Status REGister */
105 #define SREG _SFR_IO8(0x3F)
106
107 /* Status Register - SREG */
108 #define SREG_I 7
109 #define SREG_T 6
110 #define SREG_H 5
111 #define SREG_S 4
112 #define SREG_V 3
113 #define SREG_N 2
114 #define SREG_Z 1
115 #define SREG_C 0
116
117 /* Pointer definition */
118 #if __AVR_ARCH__ != 1
119 /* avr1 has only the Z pointer */
120 #define XL r26
121 #define XH r27
122 #define YL r28
123 #define YH r29
124 #endif /* #if __AVR_ARCH__ != 1 */
125 #define ZL r30
126 #define ZH r31
127
128 /*
129 * Only few devices come without EEPROM. In order to assemble the
130 * EEPROM library components without defining a specific device, we
131 * keep the EEPROM-related definitions here, and catch the devices
132 * without EEPROM (E2END == 0) below. Obviously, the EEPROM library
133 * functions will not work for them. ;-)
134 */
135 /* EEPROM Control Register */
GAS LISTING C:\Users\Kwon\AppData\Local\Temp/ccS8aaaa.s page 6
136 #define EECR _SFR_IO8(0x1C)
137
138 /* EEPROM Data Register */
139 #define EEDR _SFR_IO8(0x1D)
140
141 /* EEPROM Address Register */
142 #define EEAR _SFR_IO16(0x1E)
143 #define EEARL _SFR_IO8(0x1E)
144 #define EEARH _SFR_IO8(0x1F)
145
146 /* EEPROM Control Register */
147 #define EERIE 3
148 #define EEMWE 2
149 #define EEWE 1
150 #define EERE 0
151
152 #if defined (__AVR_AT94K__)
153 # include <avr/ioat94k.h>
154 #elif defined (__AVR_AT43USB320__)
155 # include <avr/io43u32x.h>
156 #elif defined (__AVR_AT43USB355__)
157 # include <avr/io43u35x.h>
158 #elif defined (__AVR_AT76C711__)
159 # include <avr/io76c711.h>
160 #elif defined (__AVR_AT86RF401__)
161 # include <avr/io86r401.h>
162 #elif defined (__AVR_ATmega128__)
163 # include <avr/iom128.h>
1 /* Copyright (c) 2002, Peter Jansen
2 All rights reserved.
3
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions are met:
6
7 * Redistributions of source code must retain the above copyright
8 notice, this list of conditions and the following disclaimer.
9 * Redistributions in binary form must reproduce the above copyright
10 notice, this list of conditions and the following disclaimer in
11 the documentation and/or other materials provided with the
12 distribution.
13
14 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
18 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24 POSSIBILITY OF SUCH DAMAGE. */
25
26 /* $Id: iom128.h,v 1.10 2003/02/17 09:57:28 marekm Exp $ */
27
28 /* avr/iom128.h - defines for ATmega128
29
GAS LISTING C:\Users\Kwon\AppData\Local\Temp/ccS8aaaa.s page 7
30 As of 2002-08-27:
31 - This should be up to date with data sheet 2467E-AVR-05/02 */
32
33 #ifndef _AVR_IOM128_H_
34 #define _AVR_IOM128_H_ 1
35
36 /* This file should only be included from <avr/io.h>, never directly. */
37
38 #ifndef _AVR_IO_H_
39 # error "Include <avr/io.h> instead of this file."
40 #endif
41
42 #ifndef _AVR_IOXXX_H_
43 # define _AVR_IOXXX_H_ "iom128.h"
44 #else
45 # error "Attempt to include more than one <avr/ioXXX.h> file."
46 #endif
47
48 /* I/O registers */
49
50 /* Input Pins, Port F */
51 #define PINF _SFR_IO8(0x00)
52
53 /* Input Pins, Port E */
54 #define PINE _SFR_IO8(0x01)
55
56 /* Data Direction Register, Port E */
57 #define DDRE _SFR_IO8(0x02)
58
59 /* Data Register, Port E */
60 #define PORTE _SFR_IO8(0x03)
61
62 /* ADC Data Register */
63 #define ADCW _SFR_IO16(0x04) /* for backwards compatibility */
64 #ifndef __ASSEMBLER__
65 #define ADC _SFR_IO16(0x04)
66 #endif
67 #define ADCL _SFR_IO8(0x04)
68 #define ADCH _SFR_IO8(0x05)
69
70 /* ADC Control and status register */
71 #define ADCSR _SFR_IO8(0x06)
72 #define ADCSRA _SFR_IO8(0x06) /* new name in datasheet (2467E-AVR-05/02) */
73
74 /* ADC Multiplexer select */
75 #define ADMUX _SFR_IO8(0x07)
76
77 /* Analog Comparator Control and Status Register */
78 #define ACSR _SFR_IO8(0x08)
79
80 /* USART0 Baud Rate Register Low */
81 #define UBRR0L _SFR_IO8(0x09)
82
83 /* USART0 Control and Status Register B */
84 #define UCSR0B _SFR_IO8(0x0A)
85
86 /* USART0 Control and Status Register A */
GAS LISTING C:\Users\Kwon\AppData\Local\Temp/ccS8aaaa.s page 8
87 #define UCSR0A _SFR_IO8(0x0B)
88
89 /* USART0 I/O Data Register */
90 #define UDR0 _SFR_IO8(0x0C)
91
92 /* SPI Control Register */
93 #define SPCR _SFR_IO8(0x0D)
94
95 /* SPI Status Register */
96 #define SPSR _SFR_IO8(0x0E)
97
98 /* SPI I/O Data Register */
99 #define SPDR _SFR_IO8(0x0F)
100
101 /* Input Pins, Port D */
102 #define PIND _SFR_IO8(0x10)
103
104 /* Data Direction Register, Port D */
105 #define DDRD _SFR_IO8(0x11)
106
107 /* Data Register, Port D */
108 #define PORTD _SFR_IO8(0x12)
109
110 /* Input Pins, Port C */
111 #define PINC _SFR_IO8(0x13)
112
113 /* Data Direction Register, Port C */
114 #define DDRC _SFR_IO8(0x14)
115
116 /* Data Register, Port C */
117 #define PORTC _SFR_IO8(0x15)
118
119 /* Input Pins, Port B */
120 #define PINB _SFR_IO8(0x16)
121
122 /* Data Direction Register, Port B */
123 #define DDRB _SFR_IO8(0x17)
124
125 /* Data Register, Port B */
126 #define PORTB _SFR_IO8(0x18)
127
128 /* Input Pins, Port A */
129 #define PINA _SFR_IO8(0x19)
130
131 /* Data Direction Register, Port A */
132 #define DDRA _SFR_IO8(0x1A)
133
134 /* Data Register, Port A */
135 #define PORTA _SFR_IO8(0x1B)
136
137 /* 0x1C..0x1F EEPROM */
138
139 /* Special Function I/O Register */
140 #define SFIOR _SFR_IO8(0x20)
141
142 /* Watchdog Timer Control Register */
143 #define WDTCR _SFR_IO8(0x21)
GAS LISTING C:\Users\Kwon\AppData\Local\Temp/ccS8aaaa.s page 9
144
145 /* On-chip Debug Register */
146 #define OCDR _SFR_IO8(0x22)
147
148 /* Timer2 Output Compare Register */
149 #define OCR2 _SFR_IO8(0x23)
150
151 /* Timer/Counter 2 */
152 #define TCNT2 _SFR_IO8(0x24)
153
154 /* Timer/Counter 2 Control register */
155 #define TCCR2 _SFR_IO8(0x25)
156
157 /* T/C 1 Input Capture Register */
158 #define ICR1 _SFR_IO16(0x26)
159 #define ICR1L _SFR_IO8(0x26)
160 #define ICR1H _SFR_IO8(0x27)
161
162 /* Timer/Counter1 Output Compare Register B */
163 #define OCR1B _SFR_IO16(0x28)
164 #define OCR1BL _SFR_IO8(0x28)
164 #elif defined (__AVR_ATmega64__)
65
66 #define OS_CPU_A
67 #include "os_cpu.h"
1 /*
2 ***************************************************************************************************
3 * uC/OS-II
4 * The Real-Time Kernel
5 *
6 * AVR Specific code
7 *
8 * File : OS_CPU.H
9 * By : Ole Saether
10 * Port Version : V1.01
11 *
12 * AVR-GCC port version : 1.0 2001-04-02 modified/ported to avr-gcc by Jesper Hansen (jesperh@telia
13 *
14 *
15 ***************************************************************************************************
16 */
17
18 /* Definition moved here so it can be used in the assembler file OS_CPU_A.ASM */
19 /* See below for the meaning of this define */
20
21 #define OS_CRITICAL_METHOD 1
22
23
24 #ifndef OS_CPU_A /* skip the rest if we're including from the assembler file */
25
26 #ifdef OS_CPU_GLOBALS
27 #define OS_CPU_EXT
28 #else
29 #define OS_CPU_EXT extern
30 #endif
31
32 /*
GAS LISTING C:\Users\Kwon\AppData\Local\Temp/ccS8aaaa.s page 10
33 ***************************************************************************************************
34 * DATA TYPES
35 * (Compiler Specific)
36 ***************************************************************************************************
37 */
38
39 typedef unsigned char BOOLEAN;
40 typedef unsigned char INT8U; /* Unsigned 8 bit quantity
41 typedef signed char INT8S; /* Signed 8 bit quantity
42 typedef unsigned int INT16U; /* Unsigned 16 bit quantity
43 typedef signed int INT16S; /* Signed 16 bit quantity
44 typedef unsigned long INT32U; /* Unsigned 32 bit quantity
45 typedef signed long INT32S; /* Signed 32 bit quantity
46 typedef float FP32; /* Single precision floating point
47
48 typedef unsigned char OS_STK; /* Each stack entry is 8-bit wide
49
50 /*
51 ***************************************************************************************************
52 * Atmel AVR
53 *
54 *
55 * Method #1: Disable/Enable interrupts using simple instructions. After critical section, interru
56 * will be enabled even if they were disabled before entering the critical section.
57 *
58 * Method #2: Disable/Enable interrupts by preserving the state of interrupts. In other words, if
59 * interrupts were disabled before entering the critical section, they will be disabled
60 * leaving the critical section. Here's what happens in the macro below :
61 *
62 * OS_ENTER_CRITICAL:
63 *
64 * input SREG to a free register, Rn
65 * push Rn
66 *
67 * OS_EXIT_CRITICAL:
68 *
68 #define typedef ;
69 #include "os_cfg.h"
1 /*
2 ***************************************************************************************************
3 * uC/OS-II
4 * The Real-Time Kernel
5 *
6 * (c) Copyright 1992-2003, Jean J. Labrosse, Weston, FL
7 * All Rights Reserved
8 *
9 * uC/OS-II Configuration File for V2.7x
10 *
11 * File : OS_CFG.H
12 * By : Jean J. Labrosse
13 *
14 * Modifications by Julius Luukko 2003-07-14 ([email protected]) for avr-gcc test program.
15 *
16 * - CPU_CLOCK_HZ must be defined here (used in os_cpu_a.asm)
17 * - defines a default stack size, which is used in all stack size definitions
18 *
19 * Your applications must define CPU_CLOCK_HZ!
GAS LISTING C:\Users\Kwon\AppData\Local\Temp/ccS8aaaa.s page 11
20 *
21 ***************************************************************************************************
22 */
23
24 #ifndef OS_CFG_H
25 #define OS_CFG_H
26
27 #define CPU_CLOCK_HZ 16000000
28
29 #define OS_TASK_DEF_STK_SIZE 128 /* Default stack size
30
31 /* ---------------------- MISCELLANEOUS --------------------
32 #define OS_ARG_CHK_EN 0 /* Enable (1) or Disable (0) argument checking
33 #define OS_CPU_HOOKS_EN 1 /* uC/OS-II hooks are found in the processor port files
34
35 #define OS_DEBUG_EN 1 /* Enable(1) debug variables
36
37 #define OS_EVENT_NAME_SIZE 32 /* Determine the size of the name of a Sem, Mutex, Mbox or Q
38
39 #define OS_LOWEST_PRIO 12 /* Defines the lowest priority that can be assigned ...
40 /* ... MUST NEVER be higher than 63!
41
42 #define OS_MAX_EVENTS 3 /* Max. number of event control blocks in your application
43 #define OS_MAX_FLAGS 1 /* Max. number of Event Flag Groups in your application
44 #define OS_MAX_MEM_PART 1 /* Max. number of memory partitions
45 #define OS_MAX_QS 2 /* Max. number of queue control blocks in your application
46 #define OS_MAX_TASKS 11 /* Max. number of tasks in your application, MUST be >= 2
47
48 #define OS_SCHED_LOCK_EN 0 /* Include code for OSSchedLock() and OSSchedUnlock()
49
50 #define OS_TASK_IDLE_STK_SIZE OS_TASK_DEF_STK_SIZE
51 /* Idle task stack size (# of OS_STK wide entries)
52
53 #define OS_TASK_STAT_EN 1 /* Enable (1) or Disable(0) the statistics task
54 #define OS_TASK_STAT_STK_SIZE OS_TASK_DEF_STK_SIZE
55 /* Statistics task stack size (# of OS_STK wide entries)
56 #define OS_TASK_STAT_STK_CHK_EN 1 /* Check task stacks from statistic task
57
58 #define OS_TICK_STEP_EN 1 /* Enable tick stepping feature for uC/OS-View
59 #define OS_TICKS_PER_SEC 125 /* Set the number of ticks in one second
60
61
62 /* ----------------------- EVENT FLAGS ---------------------
63 #define OS_FLAG_EN 0 /* Enable (1) or Disable (0) code generation for EVENT FLAGS
64 #define OS_FLAG_WAIT_CLR_EN 0 /* Include code for Wait on Clear EVENT FLAGS
65 #define OS_FLAG_ACCEPT_EN 0 /* Include code for OSFlagAccept()
66 #define OS_FLAG_DEL_EN 0 /* Include code for OSFlagDel()
67 #define OS_FLAG_NAME_SIZE 32 /* Determine the size of the name of an event flag group
68 #define OS_FLAG_QUERY_EN 0 /* Include code for OSFlagQuery()
69
70
71 /* -------------------- MESSAGE MAILBOXES ------------------
72 #define OS_MBOX_EN 1 /* Enable (1) or Disable (0) code generation for MAILBOXES
73 #define OS_MBOX_ACCEPT_EN 0 /* Include code for OSMboxAccept()
74 #define OS_MBOX_DEL_EN 0 /* Include code for OSMboxDel()
75 #define OS_MBOX_POST_EN 1 /* Include code for OSMboxPost()
76 #define OS_MBOX_POST_OPT_EN 0 /* Include code for OSMboxPostOpt()
GAS LISTING C:\Users\Kwon\AppData\Local\Temp/ccS8aaaa.s page 12
77 #define OS_MBOX_QUERY_EN 0 /* Include code for OSMboxQuery()
78
79
80 /* --------------------- MEMORY MANAGEMENT -----------------
81 #define OS_MEM_EN 0 /* Enable (1) or Disable (0) code generation for MEMORY MANA
82 #define OS_MEM_QUERY_EN 0 /* Include code for OSMemQuery()
83 #define OS_MEM_NAME_SIZE 32 /* Determine the size of a memory partition name
84
85
86 /* ---------------- MUTUAL EXCLUSION SEMAPHORES ------------
87 #define OS_MUTEX_EN 1 /* Enable (1) or Disable (0) code generation for MUTEX
88 #define OS_MUTEX_ACCEPT_EN 1 /* Include code for OSMutexAccept()
89 #define OS_MUTEX_DEL_EN 1 /* Include code for OSMutexDel()
90 #define OS_MUTEX_QUERY_EN 1 /* Include code for OSMutexQuery()
91
92
93 /* ---------------------- MESSAGE QUEUES -------------------
94 #define OS_Q_EN 1 /* Enable (1) or Disable (0) code generation for QUEUES
95 #define OS_Q_ACCEPT_EN 0 /* Include code for OSQAccept()
96 #define OS_Q_DEL_EN 0 /* Include code for OSQDel()
97 #define OS_Q_FLUSH_EN 0 /* Include code for OSQFlush()
98 #define OS_Q_POST_EN 1 /* Include code for OSQPost()
99 #define OS_Q_POST_FRONT_EN 0 /* Include code for OSQPostFront()
100 #define OS_Q_POST_OPT_EN 0 /* Include code for OSQPostOpt()
101 #define OS_Q_QUERY_EN 0 /* Include code for OSQQuery()
102
103
104 /* ------------------------ SEMAPHORES ---------------------
105 #define OS_SEM_EN 1 /* Enable (1) or Disable (0) code generation for SEMAPHORES
106 #define OS_SEM_ACCEPT_EN 0 /* Include code for OSSemAccept()
107 #define OS_SEM_DEL_EN 0 /* Include code for OSSemDel()
108 #define OS_SEM_QUERY_EN 0 /* Include code for OSSemQuery()
109
110
111 /* --------------------- TASK MANAGEMENT -------------------
112 #define OS_TASK_CHANGE_PRIO_EN 0 /* Include code for OSTaskChangePrio()
113 #define OS_TASK_CREATE_EN 1 /* Include code for OSTaskCreate()
114 #define OS_TASK_CREATE_EXT_EN 0 /* Include code for OSTaskCreateExt()
115 #define OS_TASK_DEL_EN 0 /* Include code for OSTaskDel()
116 #define OS_TASK_NAME_SIZE 32 /* Determine the size of a task name
117 #define OS_TASK_PROFILE_EN 0 /* Include variables in OS_TCB for profiling
118 #define OS_TASK_QUERY_EN 1 /* Include code for OSTaskQuery()
119 #define OS_TASK_SUSPEND_EN 1 /* Include code for OSTaskSuspend() and OSTaskResume()
120 #define OS_TASK_SW_HOOK_EN 1 /* Include code for OSTaskSwHook()
121
122
123 /* --------------------- TIME MANAGEMENT -------------------
124 #define OS_TIME_DLY_HMSM_EN 1 /* Include code for OSTimeDlyHMSM()
125 #define OS_TIME_DLY_RESUME_EN 1 /* Include code for OSTimeDlyResume()
126 #define OS_TIME_GET_SET_EN 1 /* Include code for OSTimeGet() and OSTimeSet()
127 #define OS_TIME_TICK_HOOK_EN 1 /* Include code for OSTimeTickHook()
128
129
130 typedef INT8U OS_FLAGS; /* Data type for event flag bits (8, 16 or 32 bits)
131
70
71 #ifndef OS_TASK_SW_HOOK_EN
GAS LISTING C:\Users\Kwon\AppData\Local\Temp/ccS8aaaa.s page 13
72 #define OS_TASK_SW_HOOK_EN 1
73 #endif
74
75 ;**************************************************************************************************
76 ; PUBLIC DECLARATIONS
77 ;**************************************************************************************************
78
79 .global OSStartHighRdy
80 .global OSCtxSw
81 .global OSIntCtxSw
82 .global OSTickISR
83
84 ;**************************************************************************************************
85 ; EXTERNAL DECLARATIONS
86 ;**************************************************************************************************
87
88 .extern OSIntExit
89 .extern OSIntNesting
90 .extern OSPrioCur
91 .extern OSPrioHighRdy
92 .extern OSRunning
93 #if OS_TASK_SW_HOOK_EN > 0
94 .extern OSTaskSwHook
95 #endif
96 .extern OSTCBCur
97 .extern OSTCBHighRdy
98 .extern OSTimeTick
99
100 ;**************************************************************************************************
101 ; MACROS
102 ;**************************************************************************************************
103
104 ; Push all registers and the status register
105 .macro PUSHRS
106
107 push r0
108 push r1
109 push r2
110 push r3
111 push r4
112 push r5
113 push r6
114 push r7
115 push r8
116 push r9
117 push r10
118 push r11
119 push r12
120 push r13
121 push r14
122 push r15
123 push r16
124 push r17
125 push r18
126 push r19
127 push r20
128 push r21
GAS LISTING C:\Users\Kwon\AppData\Local\Temp/ccS8aaaa.s page 14
129 push r22
130 push r23
131 push r24
132 push r25
133 push r26
134 push r27
135 push r28
136 push r29
137 push r30
138 push r31
139 #ifdef RAMPZ
140 in r16,_SFR_IO_ADDR(RAMPZ)
141 push r16
142 #endif
143 .endm
144
145 ; Pop all registers and the status registers
146 .macro POPRS
147
148 #ifdef RAMPZ
149 pop r16
150 out _SFR_IO_ADDR(RAMPZ),r16
151 #endif
152 pop r31
153 pop r30
154 pop r29
155 pop r28
156 pop r27
157 pop r26
158 pop r25
159 pop r24
160 pop r23
161 pop r22
162 pop r21
163 pop r20
164 pop r19
165 pop r18
166 pop r17
167 pop r16
168 pop r15
169 pop r14
170 pop r13
171 pop r12
172 pop r11
173 pop r10
174 pop r9
175 pop r8
176 pop r7
177 pop r6
178 pop r5
179 pop r4
180 pop r3
181 pop r2
182 pop r1
183 pop r0
184
185 .endm
GAS LISTING C:\Users\Kwon\AppData\Local\Temp/ccS8aaaa.s page 15
186
187 .macro POPSREG
188
189 pop r16
190 out _SFR_IO_ADDR(SREG),r16
191
192 .endm
193
194 .macro PUSHSREG
195
196 in r16,_SFR_IO_ADDR(SREG)
197 push r16
198
199 .endm
200
201 .macro PUSHSREGISR
202
203 in r16,_SFR_IO_ADDR(SREG)
204 sbr r16,0x80
205 push r16
206
207 .endm
208
209
210 .text
211 .section .text
212
213
214 ;**************************************************************************************************
215 ; START HIGHEST PRIORITY TASK READY-TO-RUN
216 ;
217 ; Description : This function is called by OSStart() to start the highest priority task that was cr
218 ; by your application before calling OSStart().
219 ;
220 ; Note(s) : 1) The (data)stack frame is assumed to look as follows:
221 ;
222 ; OSTCBHighRdy->OSTCBStkPtr --> LSB of (return) stack pointer (Low memor
223 ; SPH of (return) stack pointer
224 ; Flags to load in status register
225 ; R31
226 ; R30
227 ; R7
228 ; .
229 ; .
230 ; .
231 ; R0
232 ; PCH
233 ; PCL (High memo
234 ;
235 ; where the stack pointer points to the task start address.
236 ;
237 ;
238 ; 2) OSStartHighRdy() MUST:
239 ; a) Call OSTaskSwHook() then,
240 ; b) Set OSRunning to TRUE,
241 ; c) Switch to the highest priority task.
242 ;**************************************************************************************************
GAS LISTING C:\Users\Kwon\AppData\Local\Temp/ccS8aaaa.s page 16
243
244 OSStartHighRdy:
245 #if OS_TASK_SW_HOOK_EN > 0
246:C:/Software/uCOS-II/Ports/AVR/ATmega128/GNU/jlu/os_cpu_a.asm **** call OSTaskSwHook ; Invoke user defined context switch hook
247 #endif
248:C:/Software/uCOS-II/Ports/AVR/ATmega128/GNU/jlu/os_cpu_a.asm **** lds R16,OSRunning ; Indicate that we are multitasking
249:C:/Software/uCOS-II/Ports/AVR/ATmega128/GNU/jlu/os_cpu_a.asm **** inc R16 ;
250:C:/Software/uCOS-II/Ports/AVR/ATmega128/GNU/jlu/os_cpu_a.asm **** sts OSRunning,R16 ;
251
252:C:/Software/uCOS-II/Ports/AVR/ATmega128/GNU/jlu/os_cpu_a.asm **** lds R30,OSTCBHighRdy ; Let Z point to TCB of highest priority task
253:C:/Software/uCOS-II/Ports/AVR/ATmega128/GNU/jlu/os_cpu_a.asm **** lds R31,OSTCBHighRdy+1 ; ready to run
254
255:C:/Software/uCOS-II/Ports/AVR/ATmega128/GNU/jlu/os_cpu_a.asm **** ld R28,Z+ ; Load stack L pointer
256:C:/Software/uCOS-II/Ports/AVR/ATmega128/GNU/jlu/os_cpu_a.asm **** out _SFR_IO_ADDR(SPL),R28
257:C:/Software/uCOS-II/Ports/AVR/ATmega128/GNU/jlu/os_cpu_a.asm **** ld R29,Z+ ;
258:C:/Software/uCOS-II/Ports/AVR/ATmega128/GNU/jlu/os_cpu_a.asm **** out _SFR_IO_ADDR(SPH),R29
259
260:C:/Software/uCOS-II/Ports/AVR/ATmega128/GNU/jlu/os_cpu_a.asm **** POPSREG ; Pop the status register
260 >
260 001e 0F91 > pop r16
260 0020 0FBF > out ((((0x3F)+0x20))-0x20),r16
260 >
261:C:/Software/uCOS-II/Ports/AVR/ATmega128/GNU/jlu/os_cpu_a.asm **** POPRS ; Pop all registers
261 >
261 >
261 0022 0F91 > pop r16
261 0024 0BBF > out ((((0x3B)+0x20))-0x20),r16
261 >
261 0026 FF91 > pop r31
261 0028 EF91 > pop r30
261 002a DF91 > pop r29
261 002c CF91 > pop r28
261 002e BF91 > pop r27
261 0030 AF91 > pop r26
261 0032 9F91 > pop r25
261 0034 8F91 > pop r24
261 0036 7F91 > pop r23
261 0038 6F91 > pop r22
261 003a 5F91 > pop r21
261 003c 4F91 > pop r20
261 003e 3F91 > pop r19
261 0040 2F91 > pop r18
261 0042 1F91 > pop r17
261 0044 0F91 > pop r16
261 0046 FF90 > pop r15
261 0048 EF90 > pop r14
261 004a DF90 > pop r13
261 004c CF90 > pop r12
261 004e BF90 > pop r11
261 0050 AF90 > pop r10
261 0052 9F90 > pop r9
261 0054 8F90 > pop r8
261 0056 7F90 > pop r7
261 0058 6F90 > pop r6
261 005a 5F90 > pop r5
261 005c 4F90 > pop r4
261 005e 3F90 > pop r3
GAS LISTING C:\Users\Kwon\AppData\Local\Temp/ccS8aaaa.s page 17
261 0060 2F90 > pop r2
261 0062 1F90 > pop r1
261 0064 0F90 > pop r0
261 >
262:C:/Software/uCOS-II/Ports/AVR/ATmega128/GNU/jlu/os_cpu_a.asm **** ret ; Start task
263
264 ;**************************************************************************************************
265 ; TASK LEVEL CONTEXT SWITCH
266 ;
267 ; Description : This function is called when a task makes a higher priority task ready-to-run.
268 ;
269 ; Note(s) : 1) Upon entry,
270 ; OSTCBCur points to the OS_TCB of the task to suspend
271 ; OSTCBHighRdy points to the OS_TCB of the task to resume
272 ;
273 ; 2) The stack frame of the task to suspend looks as follows:
274 ;
275 ; SP+0 --> LSB of task code address
276 ; +1 MSB of task code address (High memo
277 ;
278 ; 3) The saved context of the task to resume looks as follows:
279 ;
280 ; OSTCBHighRdy->OSTCBStkPtr --> Flags to load in status register (Low memory)
281 ; R31
282 ; R30
283 ; R7
284 ; .
285 ; .
286 ; .
287 ; R0
288 ; PCH
289 ; PCL (High memo
290 ;**************************************************************************************************
291
292:C:/Software/uCOS-II/Ports/AVR/ATmega128/GNU/jlu/os_cpu_a.asm **** OSCtxSw: PUSHRS ; Save current tasks context
292 >
292 0068 0F92 > push r0