File : s-bbsule.ads
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
4 -- --
5 -- S Y S T E M . B B . B O A R D _ S U P P O R T . L E O N --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 1999-2002 Universidad Politecnica de Madrid --
10 -- Copyright (C) 2003-2006 The European Space Agency --
11 -- Copyright (C) 2003-2013, AdaCore --
12 -- --
13 -- GNAT is free software; you can redistribute it and/or modify it under --
14 -- terms of the GNU General Public License as published by the Free Soft- --
15 -- ware Foundation; either version 3, or (at your option) any later ver- --
16 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
17 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
18 -- or FITNESS FOR A PARTICULAR PURPOSE. --
19 -- --
20 -- --
21 -- --
22 -- --
23 -- --
24 -- You should have received a copy of the GNU General Public License and --
25 -- a copy of the GCC Runtime Library Exception along with this program; --
26 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
27 -- <http://www.gnu.org/licenses/>. --
28 -- --
29 -- GNARL was developed by the GNARL team at Florida State University. --
30 -- Extensive contributions were provided by Ada Core Technologies, Inc. --
31 -- --
32 -- The port of GNARL to bare board targets was initially developed by the --
33 -- Real-Time Systems Group at the Technical University of Madrid. --
34 -- --
35 ------------------------------------------------------------------------------
36
37 -- This package provides the appropriate mapping for the system registers.
38 -- This is the LEON version of this package.
39
40 pragma Restrictions (No_Elaboration_Code);
41
42 package System.BB.Board_Support.LEON is
43 pragma Preelaborate;
44
45 -- Pragma Suppress_Initialization (register_type) must be used in order
46 -- to keep eficiency. Otherwise, initialization procedures are always
47 -- generated for objects of packed boolean array types and of records types
48 -- that have components of these types.
49
50 ----------------------------
51 -- Local type definitions --
52 ----------------------------
53
54 type Scaler_10 is mod 2 ** 10;
55 for Scaler_10'Size use 10;
56 -- 10-bit scaler
57
58 type Scaler_12 is mod 2 ** 12;
59 for Scaler_12'Size use 12;
60 -- 12-bit scaler
61
62 type Timers_Counter is mod 2 ** 24;
63 for Timers_Counter'Size use 24;
64 -- Timer counters are 24-bit
65
66 type Reserved_8 is array (0 .. 7) of Boolean;
67 for Reserved_8'Size use 8;
68 pragma Pack (Reserved_8);
69
70 type Reserved_16 is array (0 .. 15) of Boolean;
71 for Reserved_16'Size use 16;
72 pragma Pack (Reserved_16);
73
74 type Reserved_20 is array (0 .. 19) of Boolean;
75 for Reserved_20'Size use 20;
76 pragma Pack (Reserved_20);
77
78 type Reserved_22 is array (0 .. 21) of Boolean;
79 for Reserved_22'Size use 22;
80 pragma Pack (Reserved_22);
81
82 type Reserved_23 is array (0 .. 22) of Boolean;
83 for Reserved_23'Size use 23;
84 pragma Pack (Reserved_23);
85
86 type Reserved_24 is array (0 .. 23) of Boolean;
87 for Reserved_24'Size use 24;
88 pragma Pack (Reserved_24);
89
90 type Reserved_25 is array (0 .. 24) of Boolean;
91 for Reserved_25'Size use 25;
92 pragma Pack (Reserved_25);
93
94 type Reserved_29 is array (0 .. 28) of Boolean;
95 for Reserved_29'Size use 29;
96 pragma Pack (Reserved_29);
97
98 type Interrupt_Level is array (1 .. 15) of Boolean;
99 for Interrupt_Level'Size use 15;
100 pragma Pack (Interrupt_Level);
101
102 type Status_2 is mod 2 ** 2;
103 for Status_2'Size use 2;
104
105 ------------------------------------------
106 -- Addresses of memory mapped registers --
107 ------------------------------------------
108
109 Timer_1_Counter_Register_Address : constant Address
110 := System'To_Address (16#80000040#);
111 Timer_1_Reload_Register_Address : constant Address
112 := System'To_Address (16#80000044#);
113 Timer_1_Control_Register_Address : constant Address
114 := System'To_Address (16#80000048#);
115
116 Watchdog_Register_Address : constant Address
117 := System'To_Address (16#8000004C#);
118
119 Timer_2_Counter_Register_Address : constant Address
120 := System'To_Address (16#80000050#);
121 Timer_2_Reload_Register_Address : constant Address
122 := System'To_Address (16#80000054#);
123 Timer_2_Control_Register_Address : constant Address
124 := System'To_Address (16#80000058#);
125
126 Prescaler_Counter_Register_Address : constant Address
127 := System'To_Address (16#80000060#);
128 Prescaler_Reload_Register_Address : constant Address
129 := System'To_Address (16#80000064#);
130
131 UART_1_Data_Register_Address : constant Address
132 := System'To_Address (16#80000070#);
133 UART_1_Status_Register_Address : constant Address
134 := System'To_Address (16#80000074#);
135 UART_1_Control_Register_Address : constant Address
136 := System'To_Address (16#80000078#);
137 UART_1_Scaler_Register_Address : constant Address
138 := System'To_Address (16#8000007C#);
139
140 UART_2_Data_Register_Address : constant Address
141 := System'To_Address (16#80000080#);
142 UART_2_Status_Register_Address : constant Address
143 := System'To_Address (16#80000084#);
144 UART_2_Control_Register_Address : constant Address
145 := System'To_Address (16#80000088#);
146 UART_2_Scaler_Register_Address : constant Address
147 := System'To_Address (16#8000008C#);
148
149 Interrupt_Mask_and_Priority_Register_Address : constant Address
150 := System'To_Address (16#80000090#);
151 Interrupt_Pending_Register_Address : constant Address
152 := System'To_Address (16#80000094#);
153 Interrupt_Force_Register_Address : constant Address
154 := System'To_Address (16#80000098#);
155 Interrupt_Clear_Register_Address : constant Address
156 := System'To_Address (16#8000009C#);
157
158 Cache_Control_Register_Address : constant Address
159 := System'To_Address (16#80000014#);
160
161 ---------------------
162 -- Timer Registers --
163 ---------------------
164
165 type Timer_Register is
166 record
167 Timer_Value : Timers_Counter;
168 Reserved : Reserved_8;
169 end record;
170
171 for Timer_Register use
172 record
173 Timer_Value at 0 range 8 .. 31;
174 Reserved at 0 range 0 .. 7;
175 end record;
176
177 for Timer_Register'Size use 32;
178
179 pragma Suppress_Initialization (Timer_Register);
180
181 type Timer_Control_Register is
182 record
183 Enable : Boolean;
184 -- 1 : enable counting
185 -- 0 : hold scaler (and counter) w
186
187 Reload_Counter : Boolean;
188 -- 1 : reload counter at zero and restart
189 -- 0 : stop counter at zero w
190
191 Load_Counter : Boolean;
192 -- 1 : load counter with preset value and start if enabled
193 -- 0 : no function w
194
195 Reserved : Reserved_29;
196 end record;
197
198 for Timer_Control_Register use
199 record
200 Enable at 0 range 31 .. 31;
201 Reload_Counter at 0 range 30 .. 30;
202 Load_Counter at 0 range 29 .. 29;
203 Reserved at 0 range 0 .. 28;
204 end record;
205
206 for Timer_Control_Register'Size use 32;
207
208 pragma Suppress_Initialization (Timer_Control_Register);
209
210 -------------
211 -- Timer 1 --
212 -------------
213
214 Timer_1_Counter : Timer_Register;
215 pragma Atomic (Timer_1_Counter);
216 for Timer_1_Counter'Address use Timer_1_Counter_Register_Address;
217
218 Timer_1_Reload : Timer_Register;
219 pragma Atomic (Timer_1_Reload);
220 for Timer_1_Reload'Address use Timer_1_Reload_Register_Address;
221
222 Timer_1_Control : Timer_Control_Register;
223 pragma Atomic (Timer_1_Control);
224 for Timer_1_Control'Address use Timer_1_Control_Register_Address;
225
226 -------------
227 -- Timer 2 --
228 -------------
229
230 Timer_2_Counter : Timer_Register;
231 pragma Atomic (Timer_2_Counter);
232 for Timer_2_Counter'Address use Timer_2_Counter_Register_Address;
233
234 Timer_2_Reload : Timer_Register;
235 pragma Atomic (Timer_2_Reload);
236 for Timer_2_Reload'Address use Timer_2_Reload_Register_Address;
237
238 Timer_2_Control : Timer_Control_Register;
239 pragma Atomic (Timer_2_Control);
240 for Timer_2_Control'Address use Timer_2_Control_Register_Address;
241
242 --------------
243 -- Watchdog --
244 --------------
245
246 Watchdog_Register : Timer_Register;
247 pragma Atomic (Watchdog_Register);
248 for Watchdog_Register'Address use Watchdog_Register_Address;
249
250 ---------------
251 -- Prescaler --
252 ---------------
253
254 type Prescaler_Register is
255 record
256 Value : Scaler_10;
257 Reserved : Reserved_22;
258 end record;
259
260 for Prescaler_Register use
261 record
262 Value at 0 range 22 .. 31;
263 Reserved at 0 range 0 .. 21;
264 end record;
265
266 for Prescaler_Register'Size use 32;
267
268 pragma Suppress_Initialization (Prescaler_Register);
269
270 Prescaler_Counter : Prescaler_Register;
271 pragma Atomic (Prescaler_Counter);
272 for Prescaler_Counter'Address use Prescaler_Counter_Register_Address;
273
274 Prescaler_Reload : Prescaler_Register;
275 pragma Atomic (Prescaler_Reload);
276 for Prescaler_Reload'Address use Prescaler_Reload_Register_Address;
277
278 ------------------------------------------
279 -- Interrupt Mask and Priority Register --
280 ------------------------------------------
281
282 type Interrupt_Mask_and_Priority_Register is
283 record
284 Reserved_1 : Boolean;
285
286 AMBA : Boolean;
287 UART_2 : Boolean;
288 UART_1 : Boolean;
289 External_0 : Boolean;
290 External_1 : Boolean;
291 External_2 : Boolean;
292 External_3 : Boolean;
293 Timer_1 : Boolean;
294 Timer_2 : Boolean;
295 Unused_1 : Boolean;
296 DSU : Boolean;
297 Unused_2 : Boolean;
298 Unused_3 : Boolean;
299 PCI : Boolean;
300 Unused_4 : Boolean;
301 -- 1 : interrupt X masked
302 -- 0 : interrupt X not masked r/w
303
304 Reserved_2 : Boolean;
305
306 Ilevel : Interrupt_Level;
307 -- 1 : interrupt belongs to priority level 1
308 -- 0 : interrupt belongs to priority level 0
309 end record;
310
311 for Interrupt_Mask_and_Priority_Register use
312 record
313 Reserved_1 at 0 range 31 .. 31;
314 AMBA at 0 range 30 .. 30;
315 UART_2 at 0 range 29 .. 29;
316 UART_1 at 0 range 28 .. 28;
317 External_0 at 0 range 27 .. 27;
318 External_1 at 0 range 26 .. 26;
319 External_2 at 0 range 25 .. 25;
320 External_3 at 0 range 24 .. 24;
321 Timer_1 at 0 range 23 .. 23;
322 Timer_2 at 0 range 22 .. 22;
323 Unused_1 at 0 range 21 .. 21;
324 DSU at 0 range 20 .. 20;
325 Unused_2 at 0 range 19 .. 19;
326 Unused_3 at 0 range 18 .. 18;
327 PCI at 0 range 17 .. 17;
328 Unused_4 at 0 range 16 .. 16;
329 Reserved_2 at 0 range 15 .. 15;
330 Ilevel at 0 range 0 .. 14;
331 end record;
332
333 for Interrupt_Mask_and_Priority_Register'Size use 32;
334
335 pragma Suppress_Initialization (Interrupt_Mask_and_Priority_Register);
336
337 Interrupt_Mask_and_Priority : Interrupt_Mask_and_Priority_Register;
338 pragma Atomic (Interrupt_Mask_and_Priority);
339 for Interrupt_Mask_and_Priority'Address use
340 Interrupt_Mask_and_Priority_Register_Address;
341
342 --------------------------
343 -- Interrupt Registers --
344 --------------------------
345
346 type Interrupt_Register is
347 record
348 Reserved_1 : Boolean;
349 AMBA : Boolean;
350 UART_2 : Boolean;
351 UART_1 : Boolean;
352 External_0 : Boolean;
353 External_1 : Boolean;
354 External_2 : Boolean;
355 External_3 : Boolean;
356 Timer_1 : Boolean;
357 Timer_2 : Boolean;
358 Unused_1 : Boolean;
359 DSU : Boolean;
360 Unused_2 : Boolean;
361 Unused_3 : Boolean;
362 PCI : Boolean;
363 Unused_4 : Boolean;
364 Reserved_2 : Reserved_16;
365 end record;
366
367 for Interrupt_Register use
368 record
369 Reserved_1 at 0 range 31 .. 31;
370 AMBA at 0 range 30 .. 30;
371 UART_2 at 0 range 29 .. 29;
372 UART_1 at 0 range 28 .. 28;
373 External_0 at 0 range 27 .. 27;
374 External_1 at 0 range 26 .. 26;
375 External_2 at 0 range 25 .. 25;
376 External_3 at 0 range 24 .. 24;
377 Timer_1 at 0 range 23 .. 23;
378 Timer_2 at 0 range 22 .. 22;
379 Unused_1 at 0 range 21 .. 21;
380 DSU at 0 range 20 .. 20;
381 Unused_2 at 0 range 19 .. 19;
382 Unused_3 at 0 range 18 .. 18;
383 PCI at 0 range 17 .. 17;
384 Unused_4 at 0 range 16 .. 16;
385 Reserved_2 at 0 range 0 .. 15;
386 end record;
387
388 for Interrupt_Register'Size use 32;
389
390 pragma Suppress_Initialization (Interrupt_Register);
391
392 --------------------------------
393 -- Interrupt Pending Register --
394 --------------------------------
395
396 Interrupt_Pending : Interrupt_Register;
397 pragma Atomic (Interrupt_Pending);
398 for Interrupt_Pending'Address use Interrupt_Pending_Register_Address;
399
400 ------------------------------
401 -- Interrupt Force Register --
402 ------------------------------
403
404 Interrupt_Force : Interrupt_Register;
405 pragma Atomic (Interrupt_Force);
406 for Interrupt_Force'Address use Interrupt_Force_Register_Address;
407
408 ------------------------------
409 -- Interrupt Clear Register --
410 ------------------------------
411
412 Interrupt_Clear : Interrupt_Register;
413 pragma Atomic (Interrupt_Clear);
414 for Interrupt_Clear'Address use Interrupt_Clear_Register_Address;
415
416 ---------------------
417 -- UARTs Registers --
418 ---------------------
419
420 type UART_Data_Register is
421 record
422 RTD : Character;
423 -- Rx/Tx Data r/w
424
425 Reserved : Reserved_24;
426 -- Not used r
427 end record;
428
429 for UART_Data_Register use
430 record
431 RTD at 0 range 24 .. 31;
432 Reserved at 0 range 0 .. 23;
433 end record;
434
435 for UART_Data_Register'Size use 32;
436
437 pragma Suppress_Initialization (UART_Data_Register);
438
439 type UART_Status_Register is
440 record
441 DR : Boolean;
442 -- Data Ready
443
444 TS : Boolean;
445 -- Transmitter shift register empty (no data to send)
446
447 TH : Boolean;
448 -- Transmitter hold register empty (ready to load data)
449
450 BR : Boolean;
451 -- Break received
452
453 OV : Boolean;
454 -- Overrun error
455
456 PE : Boolean;
457 -- Parity error
458
459 FE : Boolean;
460 -- Framing error
461
462 Reserved : Reserved_25;
463 -- Not used r
464 end record;
465
466 for UART_Status_Register use
467 record
468 DR at 0 range 31 .. 31;
469 TS at 0 range 30 .. 30;
470 TH at 0 range 29 .. 29;
471 BR at 0 range 28 .. 28;
472 OV at 0 range 27 .. 27;
473 PE at 0 range 26 .. 26;
474 FE at 0 range 25 .. 25;
475 Reserved at 0 range 0 .. 24;
476 end record;
477
478 for UART_Status_Register'Size use 32;
479
480 pragma Suppress_Initialization (UART_Status_Register);
481
482 type UART_Control_Register is
483 record
484 RE : Boolean; -- Receiver enable
485 -- 1 : enables the receiver
486 -- 0 : disables the receiver
487
488 TE : Boolean; -- Transmitter enable
489 -- 1 : enables the transmitter
490 -- 0 : disables the transmitter
491
492 RI : Boolean; -- Receiver interrupt enable
493 -- 1 : enables generation of receiver interrupt
494 -- 0 : disables generation of receiver interrupt
495
496 TI : Boolean; -- Transmitter interrupt enable
497 -- 1 : enables generation of transmitter interrupt
498 -- 0 : disables generation of transmitter interrupt
499
500 PS : Boolean; -- Parity
501 -- 1 : odd parity
502 -- 0 : even parity
503
504 PE : Boolean; -- Parity enable
505 -- 1 : parity enabled
506 -- 0 : no parity
507
508 FL : Boolean; -- Flow Control
509 -- 1 : flow control using CTS/RTS
510 -- 0 : disables
511
512 LB : Boolean; -- Loop back
513 -- 1 : enables loop back mode
514 -- 0 : disables loop back mode
515
516 EC : Boolean; -- External clock
517 -- 1 : external clock
518 -- 0 : system clock
519
520 Reserved : Reserved_23;
521 end record;
522
523 for UART_Control_Register use
524 record
525 RE at 0 range 31 .. 31;
526 TE at 0 range 30 .. 30;
527 RI at 0 range 29 .. 29;
528 TI at 0 range 28 .. 28;
529 PS at 0 range 27 .. 27;
530 PE at 0 range 26 .. 26;
531 FL at 0 range 25 .. 25;
532 LB at 0 range 24 .. 24;
533 EC at 0 range 23 .. 23;
534 Reserved at 0 range 0 .. 22;
535 end record;
536
537 for UART_Control_Register'Size use 32;
538
539 pragma Suppress_Initialization (UART_Control_Register);
540
541 type UART_Scaler_Register is
542 record
543 UART_Scaler : Scaler_12;
544 -- 1 - 4095 : Divide factor
545 -- 0 : stops the UART clock
546
547 Reserved : Reserved_20;
548 end record;
549
550 for UART_Scaler_Register use
551 record
552 UART_Scaler at 0 range 20 .. 31;
553 Reserved at 0 range 0 .. 19;
554 end record;
555
556 for UART_Scaler_Register'Size use 32;
557
558 pragma Suppress_Initialization (UART_Scaler_Register);
559
560 ------------
561 -- UART 1 --
562 ------------
563
564 UART_1_Data : UART_Data_Register;
565 pragma Atomic (UART_1_Data);
566 for UART_1_Data'Address use UART_1_Data_Register_Address;
567
568 UART_1_Status : UART_Status_Register;
569 pragma Atomic (UART_1_Status);
570 for UART_1_Status'Address use UART_1_Status_Register_Address;
571
572 UART_1_Control : UART_Control_Register;
573 pragma Atomic (UART_1_Control);
574 for UART_1_Control'Address use UART_1_Control_Register_Address;
575
576 UART_1_Scaler : UART_Scaler_Register;
577 pragma Atomic (UART_1_Scaler);
578 for UART_1_Scaler'Address use UART_1_Scaler_Register_Address;
579
580 ------------
581 -- UART 2 --
582 ------------
583
584 UART_2_Data : UART_Data_Register;
585 pragma Atomic (UART_2_Data);
586 for UART_2_Data'Address use UART_2_Data_Register_Address;
587
588 UART_2_Status : UART_Status_Register;
589 pragma Atomic (UART_2_Status);
590 for UART_2_Status'Address use UART_2_Status_Register_Address;
591
592 UART_2_Control : UART_Control_Register;
593 pragma Atomic (UART_2_Control);
594 for UART_2_Control'Address use UART_2_Control_Register_Address;
595
596 UART_2_Scaler : UART_Scaler_Register;
597 pragma Atomic (UART_2_Scaler);
598 for UART_2_Scaler'Address use UART_2_Scaler_Register_Address;
599
600 ----------------------------
601 -- Cache Control Register --
602 ----------------------------
603
604 type Cache_Control_Register is
605 record
606 Ics : Status_2;
607 Dcs : Status_2;
608 Icf : Boolean;
609 Dcf : Boolean;
610 Dde : Status_2;
611 Dte : Status_2;
612 Ide : Status_2;
613 Ite : Status_2;
614 Dp : Boolean;
615 Ip : Boolean;
616 Ib : Boolean;
617 Cpte : Status_2;
618 Cpc : Status_2;
619 Fi : Boolean;
620 Fd : Boolean;
621 Ds : Boolean;
622 Isets : Status_2;
623 Dsets : Status_2;
624 Irepl : Status_2;
625 Drepl : Status_2;
626 end record;
627
628 for Cache_Control_Register use
629 record
630 Ics at 0 range 30 .. 31;
631 Dcs at 0 range 28 .. 29;
632 Icf at 0 range 27 .. 27;
633 Dcf at 0 range 26 .. 26;
634 Dde at 0 range 24 .. 25;
635 Dte at 0 range 22 .. 23;
636 Ide at 0 range 20 .. 21;
637 Ite at 0 range 18 .. 19;
638 Dp at 0 range 17 .. 17;
639 Ip at 0 range 16 .. 16;
640 Ib at 0 range 15 .. 15;
641 Cpte at 0 range 13 .. 14;
642 Cpc at 0 range 11 .. 12;
643 Fi at 0 range 10 .. 10;
644 Fd at 0 range 9 .. 9;
645 Ds at 0 range 8 .. 8;
646 Isets at 0 range 6 .. 7;
647 Dsets at 0 range 4 .. 5;
648 Irepl at 0 range 2 .. 3;
649 Drepl at 0 range 0 .. 1;
650 end record;
651
652 for Cache_Control_Register'Size use 32;
653
654 pragma Suppress_Initialization (Cache_Control_Register);
655
656 CCR : Cache_Control_Register;
657 pragma Atomic (CCR);
658 for CCR'Address use Cache_Control_Register_Address;
659
660 end System.BB.Board_Support.LEON;