/
gnat-gpl-2015-src.patch
1080 lines (1013 loc) · 40.3 KB
/
gnat-gpl-2015-src.patch
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
diff -rupN gnat-gpl-2015-src-orig/src/ada/a-intnam-xi-sam4s.ads gnat-gpl-2015-src-patched/src/ada/a-intnam-xi-sam4s.ads
--- gnat-gpl-2015-src-orig/src/ada/a-intnam-xi-sam4s.ads 2015-05-06 05:53:32.000000000 -0500
+++ gnat-gpl-2015-src-patched/src/ada/a-intnam-xi-sam4s.ads 2015-07-15 09:03:49.179086384 -0500
@@ -6,7 +6,7 @@
-- --
-- S p e c --
-- --
--- Copyright (C) 1991-2014, Free Software Foundation, Inc. --
+-- Copyright (C) 1991-2013, 2015, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -29,7 +29,7 @@
-- --
------------------------------------------------------------------------------
--- This is the version for Cortex M4 SAM4S targets
+-- This is the version for Cortex-M4 SAM4S targets
package Ada.Interrupts.Names is
@@ -37,48 +37,50 @@ package Ada.Interrupts.Names is
pragma Implementation_Defined;
- -- The SAM4S datasheet defines peripheral indentifiers in Table 11-1
- -- (page 41 of 1100E–ATARM–24-Jul-13). The meaningful number, the ID
- -- starts at 0. Unfortunately, Interrupt_ID 0 is reserved and the SysTick
- -- interrupt (a core interrupt) is handled by the runtime like other
- -- interrupts. So the first interrupt (supply controler) is numbered 2
- -- while its ID is 0 in the manual. The offset of 2 is reflected in
- -- s-bbbosu-stm32f4.adb by the First_IRQ constant.
-
- Sys_Tick_Interrupt : constant Interrupt_ID := 1;
- SUPC_Interrupt : constant Interrupt_ID := 2;
- RSTC_Interrupt : constant Interrupt_ID := 3;
- RTC_Interrupt : constant Interrupt_ID := 4;
- RTT_Interrupt : constant Interrupt_ID := 5;
- WDT_Interrupt : constant Interrupt_ID := 6;
- PMC_Interrupt : constant Interrupt_ID := 7;
- EEFC0_Interrupt : constant Interrupt_ID := 8;
- EEFC1_Interrupt : constant Interrupt_ID := 9;
- UART0_Interrupt : constant Interrupt_ID := 10;
- UART1_Interrupt : constant Interrupt_ID := 11;
- SMC_Interrupt : constant Interrupt_ID := 12;
- PIOA_Interrupt : constant Interrupt_ID := 13;
- PIOB_Interrupt : constant Interrupt_ID := 14;
- PIOC_Interrupt : constant Interrupt_ID := 15;
- USART0_Interrupt : constant Interrupt_ID := 16;
- USART1_Interrupt : constant Interrupt_ID := 17;
-
- GSMCI_Interrupt : constant Interrupt_ID := 20;
- TWI0_Interrupt : constant Interrupt_ID := 21;
- TWO1_Interrupt : constant Interrupt_ID := 22;
- SPI_Interrupt : constant Interrupt_ID := 23;
- SSC_Interrupt : constant Interrupt_ID := 24;
- TC0_Interrupt : constant Interrupt_ID := 25;
- TC1_Interrupt : constant Interrupt_ID := 26;
- TC2_Interrupt : constant Interrupt_ID := 27;
- TC3_Interrupt : constant Interrupt_ID := 28;
- TC4_Interrupt : constant Interrupt_ID := 29;
- TC5_Interrupt : constant Interrupt_ID := 30;
- ADC_Interrupt : constant Interrupt_ID := 31;
- DACC_Interrupt : constant Interrupt_ID := 32;
- PWM_Interrupt : constant Interrupt_ID := 33;
- CRCCU_Interrupt : constant Interrupt_ID := 34;
- ACC_Interrupt : constant Interrupt_ID := 35;
- UDP_Interrupt : constant Interrupt_ID := 36;
+ -- The SAM4S data sheet defines the interrupts in Table 11-1 (page
+ -- 48 of the 08-Jan-15 datasheet). The meaningful number, the
+ -- position starts at 0. Unfortunately, Interrupt_ID 0 is reserved
+ -- and the SysTick interrupt (a core interrupt) is handled by the
+ -- runtime like other interrupts. So the first interrupt (SUPC) is
+ -- numbered 2 while it is at position 0 in the manual. The offset
+ -- of 2 is reflected in s-bbbosu-sam4s.adb by the First_IRQ
+ -- constant.
+
+ Sys_Tick_Interrupt : constant Interrupt_ID := 1;
+ SUPC_Interrupt : constant Interrupt_ID := 2;
+ RSTC_Interrupt : constant Interrupt_ID := 3;
+ RTC_Interrupt : constant Interrupt_ID := 4;
+ RTT_Interrupt : constant Interrupt_ID := 5;
+ WDT_Interrupt : constant Interrupt_ID := 6;
+ PMC_Interrupt : constant Interrupt_ID := 7;
+ EEFC0_Interrupt : constant Interrupt_ID := 8;
+ Reserved_7_Interrupt : constant Interrupt_ID := 9;
+ UART0_Interrupt : constant Interrupt_ID := 10;
+ UART1_Interrupt : constant Interrupt_ID := 11;
+ SMC_Interrupt : constant Interrupt_ID := 12;
+ PIOA_Interrupt : constant Interrupt_ID := 13;
+ PIOB_Interrupt : constant Interrupt_ID := 14;
+ PIOC_Interrupt : constant Interrupt_ID := 15;
+ USART0_Interrupt : constant Interrupt_ID := 16;
+ USART1_Interrupt : constant Interrupt_ID := 17;
+ Reserved_16_Interrupt : constant Interrupt_ID := 18;
+ Reserved_17_Interrupt : constant Interrupt_ID := 19;
+ HSMCI_Interrupt : constant Interrupt_ID := 20;
+ TWI0_Interrupt : constant Interrupt_ID := 21;
+ TWI1_Interrupt : constant Interrupt_ID := 22;
+ SPI_Interrupt : constant Interrupt_ID := 23;
+ SSC_Interrupt : constant Interrupt_ID := 24;
+ TC0_Interrupt : constant Interrupt_ID := 25;
+ TC1_Interrupt : constant Interrupt_ID := 26;
+ TC2_Interrupt : constant Interrupt_ID := 27;
+ TC3_Interrupt : constant Interrupt_ID := 28;
+ TC4_Interrupt : constant Interrupt_ID := 29;
+ TC5_Interrupt : constant Interrupt_ID := 30;
+ ADC_Interrupt : constant Interrupt_ID := 31;
+ DACC_Interrupt : constant Interrupt_ID := 32;
+ PWM_Interrupt : constant Interrupt_ID := 33;
+ CRCCU_Interrupt : constant Interrupt_ID := 34;
+ ACC_Interrupt : constant Interrupt_ID := 35;
+ UDP_Interrupt : constant Interrupt_ID := 36;
end Ada.Interrupts.Names;
diff -rupN gnat-gpl-2015-src-orig/src/ada/Makefile.hie gnat-gpl-2015-src-patched/src/ada/Makefile.hie
--- gnat-gpl-2015-src-orig/src/ada/Makefile.hie 2015-05-06 05:53:09.000000000 -0500
+++ gnat-gpl-2015-src-patched/src/ada/Makefile.hie 2015-07-15 11:12:10.522029980 -0500
@@ -247,7 +247,8 @@ endif
ifeq ($(strip $(filter-out ravenscar-sfp ravenscar-minimal ravenscar-apex, $(RTS))),)
- LIBGNAT_SOURCES+= s-sssita.adb s-sssita.ads
+ LIBGNAT_SOURCES+= s-sssita.adb s-sssita.ads i-c.adb i-cpoint.adb i-cpoint.ads \
+ i-cstrin.adb i-cstrin.ads
LIBGNARL_SOURCES+= a-taster.adb a-taster.ads
@@ -255,7 +256,6 @@ ifeq ($(strip $(filter-out ravenscar-sfp
a-except.ads:a-except-zfp.ads a-tags.adb:a-tags-hie.adb \
a-tags.ads:a-tags-hie.ads \
a-taster.adb:a-taster-raven.adb a-taster.ads:a-taster-raven.ads \
- i-c.ads:i-c-hie.ads \
s-assert.adb:s-assert-xi.adb s-parame.adb:s-parame-xi.adb \
s-parame.ads:s-parame-xi.ads s-secsta.adb:s-secsta-zfp.adb \
s-secsta.ads:s-secsta-zfp.ads s-sssita.adb:s-sssita-xi.adb \
@@ -808,7 +808,9 @@ ifeq (ravenscar, $(RTS))
s-wwdenu.adb \
s-wwdenu.ads \
s-wwdwch.adb \
- s-wwdwch.ads
+ s-wwdwch.ads \
+ i-c.adb i-cpoint.adb i-cpoint.ads \
+ i-cstrin.adb i-cstrin.ads
LIBGNAT_NON_COMPILABLE_SOURCES+= a-excach.adb
@@ -817,7 +819,6 @@ ifeq (ravenscar, $(RTS))
TARGET_PAIRS+= a-elchha.adb:a-elchha-xi.adb a-excach.adb:a-excach-cert.adb \
a-except.adb:a-except-xi.adb a-except.ads:a-except-cert.ads \
a-taster.adb:a-taster-raven.adb a-taster.ads:a-taster-raven.ads \
- i-c.ads:i-c-hie.ads \
s-io.adb:s-io-xi.adb \
s-memory.adb:s-memory-xi.adb \
s-parame.adb:s-parame-xi.adb s-parame.ads:s-parame-xi.ads \
diff -rupN gnat-gpl-2015-src-orig/src/ada/s-bbbosu-armv7m.adb gnat-gpl-2015-src-patched/src/ada/s-bbbosu-armv7m.adb
--- gnat-gpl-2015-src-orig/src/ada/s-bbbosu-armv7m.adb 2015-05-06 05:53:28.000000000 -0500
+++ gnat-gpl-2015-src-patched/src/ada/s-bbbosu-armv7m.adb 2015-07-15 09:20:53.881720821 -0500
@@ -6,9 +6,9 @@
-- --
-- B o d y --
-- --
--- Copyright (C) 1999-2002 Universidad Politecnica de Madrid --
+-- Copyright (C) 1999-2002, 2015 Universidad Politecnica de Madrid --
-- Copyright (C) 2003-2005 The European Space Agency --
--- Copyright (C) 2003-2015, AdaCore --
+-- Copyright (C) 2003-2013, AdaCore --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -47,6 +47,7 @@ package body System.BB.Board_Support is
-- Defined by ARMv7-M specifications.
First_IRQ : constant Interrupt_ID := 2;
+ -- SUPC_Interrupt
-- This corresponds to the first IRQ number (handled by the NVIC). This
-- offset is present so that the Sys_Tick exception can be handled like
-- other interrupts, and because interrupt id 0 is reserved.
@@ -76,10 +77,9 @@ package body System.BB.Board_Support is
Tick_Period : constant Timer_Interval := Clock_Frequency / 1000;
type Sys_Tick_Registers is record
- SYST_CSR : Word;
- SYST_RVR : Word;
- SYST_CVR : Word;
- SYST_CALIB : Word;
+ STCTRL : Word;
+ STRELOAD : Word;
+ STCURRENT : Word;
end record;
CSR_Count_Flag : constant := 2**16;
@@ -87,8 +87,8 @@ package body System.BB.Board_Support is
CSR_Tick_Int : constant := 2**1;
CSR_Enable : constant := 2**0;
- RVR_Last : constant := 2**24 - 1;
- pragma Assert (Tick_Period <= RVR_Last + 1);
+ STRELOAD_Last : constant := 2**24 - 1;
+ pragma Assert (Tick_Period <= STRELOAD_Last + 1);
SYST : Sys_Tick_Registers with Volatile, Address => 16#E000_E010#;
-- SysTick control and status register (Part of SYST).
@@ -100,7 +100,7 @@ package body System.BB.Board_Support is
-- New Vectored Interrupt Controller (NVIC) --
----------------------------------------------
- NVIC_Base : constant := 16#E000_E000#;
+ NVIC_Base : constant Address := 16#E000_E000#;
-- Nested Vectored Interrupt Controller (NVIC) base.
NVIC_ISER0 : constant Address := NVIC_Base + 16#100#;
@@ -146,17 +146,17 @@ package body System.BB.Board_Support is
Disable_Interrupts;
-- Because we operate the SysTick clock as a periodic timer, and 24 bits
- -- at 168 MHz is sufficient for that, use the unscaled system clock.
+ -- at 120 MHz is sufficient for that, use the unscaled system clock.
-- To initialize the Sys_Tick timer, first disable the clock, then
-- program it and finally enable it. This way an accidentally
-- misconfigured timer will not cause pending interrupt while
-- reprogramming.
- SYST.SYST_CSR := CSR_Clk_Source; -- disable clock
- SYST.SYST_RVR := Word (Tick_Period - 1);
- SYST.SYST_CVR := 0;
- SYST.SYST_CSR := CSR_Clk_Source or CSR_Enable;
+ SYST.STCTRL := CSR_Clk_Source; -- disable clock
+ SYST.STRELOAD := Word (Tick_Period - 1);
+ SYST.STCURRENT := 0;
+ SYST.STCTRL := CSR_Clk_Source or CSR_Enable;
Next_Tick_Time := Tick_Period;
Set_Alarm (Timer_Interval'Last);
@@ -193,7 +193,7 @@ package body System.BB.Board_Support is
-- We must read the counter register before the flag
- Count := Timer_Interval (SYST.SYST_CVR);
+ Count := Timer_Interval (SYST.STCURRENT);
-- If we read the flag first, a reload can occur just after the read and
-- the count register would wrap around. We'd end up with a Count value
@@ -205,7 +205,7 @@ package body System.BB.Board_Support is
-- has just triggered the interrupt), so count is either zero or not far
-- from Tick_Period.
- Flag := (SYST.SYST_CSR and CSR_Count_Flag) /= 0;
+ Flag := (SYST.STCTRL and CSR_Count_Flag) /= 0;
if Flag then
@@ -336,7 +336,7 @@ package body System.BB.Board_Support is
pragma Assert (Prio = Interrupt_Priority'Last);
Clear_Alarm_Interrupt;
- SYST.SYST_CSR := SYST.SYST_CSR or CSR_Tick_Int;
+ SYST.STCTRL := SYST.STCTRL or CSR_Tick_Int;
else
declare
@@ -386,7 +386,7 @@ package body System.BB.Board_Support is
function Priority_Of_Interrupt
(Interrupt : Interrupt_ID) return Any_Priority
is
- -- Interrupt 2 .. 83 correspond to IRQ0 .. IRQ81
+ -- Interrupt 2 .. 36 correspond to IRQ0 .. IRQ34
(if Interrupt = Alarm_Interrupt_ID then Interrupt_Priority'Last
else To_Priority (IP (Interrupt - First_IRQ)));
diff -rupN gnat-gpl-2015-src-orig/src/ada/s-bbcppr-armv7m.adb gnat-gpl-2015-src-patched/src/ada/s-bbcppr-armv7m.adb
--- gnat-gpl-2015-src-orig/src/ada/s-bbcppr-armv7m.adb 2015-05-06 05:53:27.000000000 -0500
+++ gnat-gpl-2015-src-patched/src/ada/s-bbcppr-armv7m.adb 2015-07-29 13:28:20.246675998 -0500
@@ -8,7 +8,7 @@
-- --
-- Copyright (C) 1999-2002 Universidad Politecnica de Madrid --
-- Copyright (C) 2003-2005 The European Space Agency --
--- Copyright (C) 2003-2015, AdaCore --
+-- Copyright (C) 2003-2013, AdaCore --
-- --
-- GNARL is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -33,6 +33,7 @@
with Ada.Unchecked_Conversion; use Ada;
+with Interfaces; use Interfaces;
with System.Storage_Elements;
with System.Multiprocessors;
with System.BB.Board_Support;
@@ -40,6 +41,7 @@ with System.BB.Threads;
with System.BB.Threads.Queues;
with System.BB.Time;
with System.Machine_Code; use System.Machine_Code;
+-- with SAM4S.Trace;
package body System.BB.CPU_Primitives is
use Parameters;
@@ -100,6 +102,15 @@ package body System.BB.CPU_Primitives is
pragma Volatile (Alarm_Time);
pragma Import (C, Alarm_Time, "__gnat_alarm_time");
+ procedure Hard_Fault_Handler_Asm;
+ pragma Machine_Attribute (Hard_Fault_Handler_Asm, "naked");
+ pragma Export (Asm, Hard_Fault_Handler_Asm, "__gnat_hard_fault_trap");
+ -- This assembly routine needs to save and restore registers without
+ -- interference. The "naked" machine attribute communicates this to GCC.
+
+ procedure Hard_Fault_Handler (SP : Address);
+ pragma Export (Asm, Hard_Fault_Handler, "__hard_fault_handler");
+
procedure SV_Call_Handler;
pragma Export (Asm, SV_Call_Handler, "__gnat_sv_call_trap");
@@ -275,6 +286,7 @@ package body System.BB.CPU_Primitives is
procedure GNAT_Error_Handler (Trap : Vector_Id) is
begin
+ -- SAM4S.Trace.Put (0, SAM4S.Trace.Value_Type (Trap));
case Trap is
when Reset_Vector =>
raise Program_Error with "unexpected reset";
@@ -384,6 +396,49 @@ package body System.BB.CPU_Primitives is
Volatile => True);
end Pend_SV_Handler;
+ ----------------------------
+ -- Hard_Fault_Handler_Asm --
+ ----------------------------
+
+ procedure Hard_Fault_Handler_Asm is
+ begin
+ Asm ("tst lr, #4" & NL &
+ "ite eq" & NL &
+ "mrseq r0, msp" & NL &
+ "mrsne r0, psp" & NL &
+ "ldr r1, [r0, #24]" & NL &
+ "ldr r2, handler_addr" & NL &
+ "bx r2" & NL &
+ "handler_addr: .word __hard_fault_handler" & NL,
+ Volatile => True);
+ end Hard_Fault_Handler_Asm;
+
+ ----------------------------
+ -- Hard_Fault_Handler --
+ ----------------------------
+
+ procedure Hard_Fault_Handler (SP : Address) is
+ Hw_Ctx : Hardware_Context with Address => SP, Volatile;
+ HFSR : Interfaces.Unsigned_32 with Address => 16#E000_ED2C#, Volatile;
+ CFSR : Interfaces.Unsigned_32 with Address => 16#E000_ED28#, Volatile;
+ begin
+ Asm ("BKPT #01", Volatile => True);
+ -- SAM4S.Trace.Put (0, "In Hard_Fault_Handler");
+ -- SAM4S.Trace.Put (0, SAM4S.Trace.Value_Type (HFSR));
+ -- SAM4S.Trace.Put (0, SAM4S.Trace.Value_Type (CFSR));
+
+ if (HFSR and 16#4000_0000#) /= 0 then
+ -- Forced hard fault.
+ if (CFSR and 16#0200_0000#) /= 0 then
+ -- Divide by zero.
+ -- SAM4S.Trace.Put (0, "Divide by zero.");
+ null;
+ end if;
+ end if;
+
+ GNAT_Error_Handler (Hard_Fault_Vector);
+ end Hard_Fault_Handler;
+
---------------------
-- SV_Call_Handler --
---------------------
@@ -478,9 +533,11 @@ package body System.BB.CPU_Primitives is
begin
Install_Trap_Handler (EH, Reset_Vector);
Install_Trap_Handler (EH, NMI_Vector);
- Install_Trap_Handler (EH, Hard_Fault_Vector);
+ -- Install_Trap_Handler (EH, Hard_Fault_Vector);
Install_Trap_Handler (EH, Bus_Fault_Vector);
Install_Trap_Handler (EH, Usage_Fault_Vector);
+ -- Install_Trap_Handler (EH, Sys_Tick_Vector);
+ -- Why is Pend_SV installed as a trap handler (when Sys_Tick is not)?
Install_Trap_Handler (EH, Pend_SV_Vector);
Install_Trap_Handler (EH, SV_Call_Vector);
end Install_Error_Handlers;
diff -rupN gnat-gpl-2015-src-orig/src/ada/s-bbpara-sam4s.ads gnat-gpl-2015-src-patched/src/ada/s-bbpara-sam4s.ads
--- gnat-gpl-2015-src-orig/src/ada/s-bbpara-sam4s.ads 2015-05-06 05:53:27.000000000 -0500
+++ gnat-gpl-2015-src-patched/src/ada/s-bbpara-sam4s.ads 2015-07-15 09:05:39.426108506 -0500
@@ -91,7 +91,7 @@ package System.BB.Parameters is
-- Stacks --
------------
- Interrupt_Stack_Size : constant := 2 * 1024;
+ Interrupt_Stack_Size : constant := 1024;
-- Size of each of the interrupt stacks in bytes. While there nominally is
-- an interrupt stack per interrupt priority, the entire space is used as a
-- single stack.
diff -rupN gnat-gpl-2015-src-orig/src/ada/s-bbthqu.adb gnat-gpl-2015-src-patched/src/ada/s-bbthqu.adb
--- gnat-gpl-2015-src-orig/src/ada/s-bbthqu.adb 2015-05-06 05:53:27.000000000 -0500
+++ gnat-gpl-2015-src-patched/src/ada/s-bbthqu.adb 2015-07-15 09:22:10.825344008 -0500
@@ -151,6 +151,7 @@ package body System.BB.Threads.Queues is
First_Thread_Table (CPU_Id) := Thread.Next;
Thread.Next := Null_Thread_Id;
+
end Extract;
-------------------------
@@ -211,6 +212,7 @@ package body System.BB.Threads.Queues is
CPU_Id : constant CPU := Get_CPU (Thread);
begin
+
-- ??? This pragma is disabled because the Tasks_Activated only
-- represents the end of activation for one package not all the
-- packages. We have to find a better milestone for the end of
@@ -232,52 +234,50 @@ package body System.BB.Threads.Queues is
if First_Thread_Table (CPU_Id) = Thread then
null;
- -- Insert at the head of queue if there is no other thread with a higher
- -- priority.
+ -- Insert at the head of queue if there is no other thread
+ -- with a higher priority.
- elsif First_Thread_Table (CPU_Id) = Null_Thread_Id
- or else
- Thread.Active_Priority > First_Thread_Table (CPU_Id).Active_Priority
- then
+ elsif First_Thread_Table (CPU_Id) = Null_Thread_Id then
Thread.Next := First_Thread_Table (CPU_Id);
First_Thread_Table (CPU_Id) := Thread;
- -- Middle or tail insertion
-
else
- -- Look for the Aux_Pointer to insert the thread just after it
+ -- Middle or tail insertion
+ -- Remove the thread if it is already in the queue. We know
+ -- the first thread is not null.
Aux_Pointer := First_Thread_Table (CPU_Id);
while Aux_Pointer.Next /= Null_Thread_Id
and then Aux_Pointer.Next /= Thread
- and then Aux_Pointer.Next.Active_Priority >= Thread.Active_Priority
loop
Aux_Pointer := Aux_Pointer.Next;
end loop;
- -- If we found the thread already in the queue, then we need to move
- -- it to its right place.
-
if Aux_Pointer.Next = Thread then
-
- -- Extract it from its current location
-
Aux_Pointer.Next := Thread.Next;
+ end if;
+ if
+ Thread.Active_Priority > First_Thread_Table (CPU_Id).Active_Priority
+ then
+ Thread.Next := First_Thread_Table (CPU_Id);
+ First_Thread_Table (CPU_Id) := Thread;
+ else
-- Look for the Aux_Pointer to insert the thread just after it
+ Aux_Pointer := First_Thread_Table (CPU_Id);
while Aux_Pointer.Next /= Null_Thread_Id
- and then
- Aux_Pointer.Next.Active_Priority >= Thread.Active_Priority
+ and then Aux_Pointer.Next.Active_Priority >=
+ Thread.Active_Priority
loop
Aux_Pointer := Aux_Pointer.Next;
end loop;
- end if;
- -- Insert the thread after the Aux_Pointer
+ -- Insert the thread after the Aux_Pointer
- Thread.Next := Aux_Pointer.Next;
- Aux_Pointer.Next := Thread;
+ Thread.Next := Aux_Pointer.Next;
+ Aux_Pointer.Next := Thread;
+ end if;
end if;
end Insert;
diff -rupN gnat-gpl-2015-src-orig/src/ada/s-sam4s.ads gnat-gpl-2015-src-patched/src/ada/s-sam4s.ads
--- gnat-gpl-2015-src-orig/src/ada/s-sam4s.ads 2015-05-06 05:53:31.000000000 -0500
+++ gnat-gpl-2015-src-patched/src/ada/s-sam4s.ads 1969-12-31 18:00:00.000000000 -0600
@@ -1,484 +0,0 @@
-------------------------------------------------------------------------------
--- --
--- GNAT RUN-TIME COMPONENTS --
--- --
--- S Y S T E M . S A M 4 S --
--- --
--- S p e c --
--- --
--- Copyright (C) 2014, Free Software Foundation, Inc. --
--- --
--- GNAT is free software; you can redistribute it and/or modify it under --
--- terms of the GNU General Public License as published by the Free Soft- --
--- ware Foundation; either version 3, or (at your option) any later ver- --
--- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
--- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
--- or FITNESS FOR A PARTICULAR PURPOSE. --
--- --
--- --
--- --
--- --
--- --
--- You should have received a copy of the GNU General Public License and --
--- a copy of the GCC Runtime Library Exception along with this program; --
--- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
--- <http://www.gnu.org/licenses/>. --
--- --
--- GNAT was originally developed by the GNAT team at New York University. --
--- Extensive contributions were provided by Ada Core Technologies Inc. --
--- --
-------------------------------------------------------------------------------
-
--- This file provides register definitions for the SAM4S (ARM Cortex M4)
--- microcontrollers from Atmel. Definitions are taken from 'SAM4S Series'
--- datasheet (document 11100E-ATARM-24-Jul-13).
-
-package System.SAM4S is
- pragma No_Elaboration_Code_All;
- -- Allow user code with pragma No_Elaboration_Code_All to use this package
-
- pragma Preelaborate (System.SAM4S);
-
- pragma Suppress (Alignment_Check);
- -- Avoid any warnings for address clauses on variables of type record.
-
- type Word is mod 2**32;
-
- -- Define address bases for various peripherals
-
- Peripheral_Base : constant := 16#4000_0000#;
-
- SPI_Base : constant := Peripheral_Base + 16#8000#;
-
- System_Controller_Base : constant := Peripheral_Base + 16#e_0000#;
- PMC_Base : constant := System_Controller_Base + 16#0400#;
- UART0_Base : constant := System_Controller_Base + 16#0600#;
- UART1_Base : constant := System_Controller_Base + 16#0800#;
- EFC0_Base : constant := System_Controller_Base + 16#0A00#;
- EFC1_Base : constant := System_Controller_Base + 16#0C00#;
-
- PIOA_Base : constant := System_Controller_Base + 16#0e00#;
- PIOB_Base : constant := System_Controller_Base + 16#1000#;
- PIOC_Base : constant := System_Controller_Base + 16#1200#;
- WDT_Base : constant := System_Controller_Base + 16#1450#;
-
- ---------------------------------
- -- Power Management Controller --
- ---------------------------------
-
- type PMC_Registers is record
- PMC_SCER : Word;
- PMC_SCDR : Word;
- PMC_SCSR : Word;
- Pad0 : Word;
-
- PMC_PCER0 : Word;
- PMC_PCDR0 : Word;
- PMC_PCSR0 : Word;
- Pad1 : Word;
-
- CKGR_MOR : Word;
- CKGR_MCFR : Word;
- CKGR_PLLAR : Word;
- CKGR_PLLBR : Word;
-
- PMC_MCKR : Word;
- Pad3_4 : Word;
- PMC_USB : Word;
- Pad3_C : Word;
-
- PMC_PCK0 : Word;
- PMC_PCK1 : Word;
- PMC_PCK2 : Word;
- Pad4_C : Word;
-
- Pad5_0 : Word;
- Pad5_4 : Word;
- Pad5_8 : Word;
- Pad5_C : Word;
-
- PMC_IER : Word;
- PMC_IDR : Word;
- PMC_SR : Word;
- PMC_IMR : Word;
-
- PMC_FSMR : Word;
- PMC_FSPR : Word;
- PMC_FOCR : Word;
- Pad7_C : Word;
-
- -- Not complete
- end record;
-
- PMC : PMC_Registers with Volatile, Import,
- Address => System'To_Address (PMC_Base);
-
- -- Constants for the CKGR MOR register
-
- package CKGR_MOR is
- CFDEN : constant := 2 ** 25;
- MOSCSEL : constant := 2 ** 24;
- KEY : constant := 16#37# * 2 ** 16;
-
- MOSCXTST : constant := 2 ** 8;
-
- MOSCRCEN : constant := 2 ** 3;
- WAITMODE : constant := 2 ** 2;
- MOSCXTBY : constant := 2 ** 1;
- MOSCXTEN : constant := 2 ** 0;
- end CKGR_MOR;
-
- -- Constants for the PMC SR register
-
- package PMC_SR is
- MCKRDY : constant := 2 ** 3;
- LOCKB : constant := 2 ** 2;
- LOCKA : constant := 2 ** 1;
- MOSCXTS : constant := 2 ** 0;
- end PMC_SR;
-
- -- Constants for the CKGR PLLAR and PLLBR registers
-
- package CKGR_PLLxR is
- DIV : constant := 2 ** 0;
- PLLCOUNT : constant := 2 ** 8;
- MUL : constant := 2 ** 16;
- ONE : constant := 2 ** 29;
- end CKGR_PLLxR;
-
- -- Constants for the PMC MCKR register
-
- package PMC_MCKR is
- PLLBDIV2 : constant := 2 ** 13;
- PLLADIV2 : constant := 2 ** 12;
- PRES_Mask : constant := 2#111# * 2 ** 4;
- CLK_1 : constant := 0 * 2 ** 4;
- CLK_2 : constant := 1 * 2 ** 4;
- CLK_4 : constant := 2 * 2 ** 4;
- CLK_8 : constant := 3 * 2 ** 4;
- CLK_16 : constant := 4 * 2 ** 4;
- CLK_32 : constant := 5 * 2 ** 4;
- CLK_64 : constant := 6 * 2 ** 4;
- CLK_3 : constant := 7 * 2 ** 4;
- CSS_Mask : constant := 2#11# * 2 ** 0;
- SLOW_CLK : constant := 0 * 2 ** 0;
- MAIN_CLK : constant := 1 * 2 ** 0;
- PLLA_CLK : constant := 2 * 2 ** 0;
- PLLB_CLK : constant := 3 * 2 ** 0;
- end PMC_MCKR;
-
- ----------------------------------------
- -- Enhanced Embedded Flash Controller --
- ----------------------------------------
-
- type EEFC_Registers is record
- EEFC_FMR : Word;
- EEFC_FCR : Word;
- EEFC_FSR : Word;
- EEFC_FFR : Word;
- end record;
-
- -- Constants for the EEFC FMR register
-
- package EEFC_FMR is
- FRDY : constant := 2 ** 0;
- FWS : constant := 2 ** 8;
- SCOD : constant := 2 ** 16;
- FAM : constant := 2 ** 24;
- CLOE : constant := 2 ** 26;
- end EEFC_FMR;
-
- EFC0 : EEFC_Registers with Volatile, Import,
- Address => System'To_Address (EFC0_Base);
-
- --------------------------------------
- -- Parallel Input/Output Controller --
- --------------------------------------
-
- type PIO_Registers is record
- PER : Word;
- PDR : Word;
- PSR : Word;
- Pad0 : Word;
-
- OER : Word;
- ODR : Word;
- OSR : Word;
- Pad1 : Word;
-
- IFER : Word;
- IFDR : Word;
- IFSR : Word;
- Pad2 : Word;
-
- SODR : Word;
- CODR : Word;
- ODSR : Word;
- PDSR : Word;
-
- IER : Word;
- IDR : Word;
- IMR : Word;
- ISR : Word;
-
- MDER : Word;
- MDDR : Word;
- MDSR : Word;
- Pad5 : Word;
-
- PUDR : Word;
- PUER : Word;
- PUSR : Word;
- Pad6 : Word;
-
- ABCDSR1 : Word;
- ABCDSR2 : Word;
- Pad7_8 : Word;
- Pad7_C : Word;
-
- IFSCDR : Word;
- IFSCER : Word;
- IFSCSR : Word;
- SCDR : Word;
-
- PPDDR : Word;
- PPDER : Word;
- PPDSR : Word;
- Pad9 : Word;
-
- OWER : Word;
- OWDR : Word;
- OWSR : Word;
- Pada : Word;
-
- AIMER : Word;
- AIMDR : Word;
- AIMMR : Word;
- Padb : Word;
-
- ESR : Word;
- LSR : Word;
- ELSR : Word;
- Padc : Word;
-
- FELLSR : Word;
- REHLSR : Word;
- FRLHSR : Word;
- Padd : Word;
-
- LOCKSR : Word;
- WPMR : Word;
- WPSR : Word;
- PadE_C : Word;
- end record;
-
- PIOA : PIO_Registers with Volatile, Import,
- Address => System'To_Address (PIOA_Base);
- PIOB : PIO_Registers with Volatile, Import,
- Address => System'To_Address (PIOB_Base);
- PIOC : PIO_Registers with Volatile, Import,
- Address => System'To_Address (PIOC_Base);
-
- PIOA_ID : constant := 11;
- PIOB_ID : constant := 12;
- PIOC_ID : constant := 13;
-
- ----------------------------------
- -- Serial Peripheral Interface --
- ----------------------------------
-
- type SPI_Registers is record
- SPI_CR : Word;
- SPI_MR : Word;
- SPI_RDR : Word;
- SPI_TDR : Word;
-
- SPI_SR : Word;
- SPI_IER : Word;
- SPI_IDR : Word;
- SPI_IMR : Word;
-
- Pad_20 : Word;
- Pad_24 : Word;
- Pad_28 : Word;
- Pad_2c : Word;
-
- SPI_CSR0 : Word;
- SPI_CSR1 : Word;
- SPI_CSR2 : Word;
- SPI_CSR3 : Word;
-
- -- ...
- end record;
-
- -- Constants for the SPI CR register
-
- package SPI_CR is
- SPIEN : constant := 2 ** 0;
- SPIDIS : constant := 2 ** 1;
- SWRST : constant := 2 ** 7;
-
- LASTXFER : constant := 2 ** 24;
- end SPI_CR;
-
- -- Constants for the SPI MR register
-
- package SPI_MR is
- MSTR : constant := 2 ** 0;
- PS : constant := 2 ** 1;
- PCSDEC : constant := 2 ** 2;
- MODFDIS : constant := 2 ** 4;
- WDRBT : constant := 2 ** 5;
- LLB : constant := 2 ** 7;
-
- PCS : constant := 2 ** 16;
- PCS_Mask : constant := 2#1111# * PCS;
- DLYBCS : constant := 2 ** 16;
- DLYBCS_Mask : constant := 16#ff# * DLYBCS;
- end SPI_MR;
-
- -- Constants for the SPI TDR register
-
- package SPI_TDR is
- TD : constant := 2 ** 0;
- PCS : constant := 2 ** 16;
- LASTXFER : constant := 2 ** 24;
- end SPI_TDR;
-
- -- Constants for the SPI SR register; also used by the SPI IER, IDR and
- -- IMR registers.
-
- package SPI_SR is
- RDRF : constant := 2 ** 0;
- TDRE : constant := 2 ** 1;
- MODF : constant := 2 ** 2;
- OVRES : constant := 2 ** 3;
- ENDRX : constant := 2 ** 4;
- ENDTX : constant := 2 ** 5;
- RXBUFF : constant := 2 ** 6;
- TXBUFE : constant := 2 ** 7;
- NSSR : constant := 2 ** 8;
- TXEMPTY : constant := 2 ** 9;
- UNDES : constant := 2 ** 10;
- SPIENS : constant := 2 ** 16;
- end SPI_SR;
-
- -- Constants for the SPI CSR register
-
- package SPI_CSR is
- CPOL : constant := 2 ** 0;
- NCPHA : constant := 2 ** 1;
- CSNAAT : constant := 2 ** 2;
- CSAAT : constant := 2 ** 3;
- BITS : constant := 2 ** 4;
- SCBR : constant := 2 ** 8;
- DLYBS : constant := 2 ** 16;
- DLYBCT : constant := 2 ** 24;
- end SPI_CSR;
-
- SPI : SPI_Registers with Volatile, Import,
- Address => System'To_Address (SPI_Base);
-
- SPI_ID : constant := 21;
-
- --------------------
- -- Watchdog Timer --
- --------------------
-
- type WDT_Registers is record
- WDT_CR : Word;
- WDT_MR : Word;
- WDT_SR : Word;
- end record;
-
- -- Constants for the WDT CR register
-
- package WDT_CR is
- KEY : constant := 16#a5_00_00_00#;
- WDRSTT : constant := 2 ** 0;
- end WDT_CR;
-
- -- Constants for the WDT MR register
-
- package WDT_MR is
- WDV : constant := 2 ** 0;
- WDFIEN : constant := 2 ** 2;
- WDRSTEN : constant := 2 ** 13;
- WDDPROC : constant := 2 ** 14;
- WDDIS : constant := 2 ** 15;
- WDD : constant := 2 ** 16;
- WDDBGHLT : constant := 2 ** 13;
- WDIDLEHLT : constant := 2 ** 13;
- end WDT_MR;
-
- WDT : WDT_Registers with Volatile, Import,
- Address => System'To_Address (WDT_Base);
-
- -------------------------------------------------
- -- Universal Asynchronous Receiver Transmitter --
- -------------------------------------------------
-
- type UART_Registers is record
- UART_CR : Word;
- UART_MR : Word;
- UART_IER : Word;
- UART_IDR : Word;
-
- UART_IMR : Word;
- UART_SR : Word;
- UART_RHR : Word;
- UART_THR : Word;
-
- UART_BRGR : Word;
- end record;
-
- -- Constants for the UART CR register
-
- package UART_CR is
- RSTRX : constant := 2 ** 2;
- RSTTX : constant := 2 ** 3;
- RXEN : constant := 2 ** 4;
- RXDIS : constant := 2 ** 5;
- TXEN : constant := 2 ** 6;
- TXDIS : constant := 2 ** 7;
- RSTSTA : constant := 2 ** 8;
- end UART_CR;
-
- -- Constants for the UART MR register
-
- package UART_MR is
- CHMODE_NORMAL : constant := 0 * 2 ** 14;
- CHMODE_AUTOMATIC : constant := 1 * 2 ** 14;
- CHMODE_LOCAL_LOOPBACK : constant := 2 * 2 ** 14;
- CHMODE_REMOTE_LOOPBACK : constant := 3 * 2 ** 14;
-
- PAR_EVEN : constant := 0 * 2 ** 9;
- PAR_ODD : constant := 1 * 2 ** 9;
- PAR_SPACE : constant := 2 * 2 ** 9;
- PAR_MARK : constant := 3 * 2 ** 9;
- PAR_NO : constant := 4 * 2 ** 9;
- end UART_MR;
-
- -- Constants for the UART SR register
-
- package UART_SR is
- RXRDY : constant := 2 ** 0;
- TXRDY : constant := 2 ** 1;
- ENDRX : constant := 2 ** 3;
- ENDTX : constant := 2 ** 4;
- OVRE : constant := 2 ** 5;
- FRAME : constant := 2 ** 6;
- PARE : constant := 2 ** 7;
- TXEMPTY : constant := 2 ** 9;
- TXBUFE : constant := 2 ** 11;
- RXBUFF : constant := 2 ** 12;
- end UART_SR;
-
- UART0 : UART_Registers with Volatile, Import,
- Address => System'To_Address (UART0_Base);
- UART1 : UART_Registers with Volatile, Import,
- Address => System'To_Address (UART1_Base);
-
- UART0_ID : constant := 8;
- UART1_ID : constant := 9;
-end System.SAM4S;
diff -rupN gnat-gpl-2015-src-orig/src/ada/s-textio-sam4s.adb gnat-gpl-2015-src-patched/src/ada/s-textio-sam4s.adb
--- gnat-gpl-2015-src-orig/src/ada/s-textio-sam4s.adb 2015-05-06 05:53:30.000000000 -0500
+++ gnat-gpl-2015-src-patched/src/ada/s-textio-sam4s.adb 2015-07-15 09:07:36.974999629 -0500
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
--- Copyright (C) 1992-2014, Free Software Foundation, Inc. --
+-- Copyright (C) 1992-2013, 2015, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -29,53 +29,28 @@
-- --
------------------------------------------------------------------------------
--- Minimal version of Text_IO body for use on SAM4S, using UART1
+-- Minimal version of Text_IO body for use on SAM4S, using UART0.
-with System.SAM4S; use System.SAM4S;
+with Interfaces; use Interfaces;
+with SAM4S.UART;