-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHAL.cortex4.qemu.Mod
More file actions
86 lines (69 loc) · 2.12 KB
/
Copy pathHAL.cortex4.qemu.Mod
File metadata and controls
86 lines (69 loc) · 2.12 KB
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
(* begin-module-short-description
provides a Hardware Abstraction Layer for cortex-m4.
end-module-short-description *)
(* begin-module-use-description
Module HAL (.cm4) exercises features of the compiler in bringing Oberon up from bare metal on cortex-m4.
end-module-use-description *)
(* begin-module-develop-description
The HAL prepares the Oberon runtime and so cannot rely on it.
* No global variables
* No strings
* No heap allocation
The first thing HAL must do is set up its own stack.
Each platform should have its own HAL. This is the HAL for cortex-m4 on QEMU.
The HAL remains resident and may be used by other modules.
end-module-develop-description *)
MODULE* HAL;
IMPORT SYSTEM;
CONST
stackOrg = 47FFF000H;
MTOrg = 40001000H;
rsData = 9000000H;
FDTLoc = 48000000H; (* At start R02 holds the location of the FDTB *)
MT = 12; SP = 14; LNK = 15; (*dedicated registers RISC5 ordinal*)
TYPE
VAR
(* begin-procedure-description
---
**Greet** Transmits a greeting on the serial port.
end-procedure-description *)
PROCEDURE Greet;
BEGIN
SYSTEM.PUT(rsData,ORD("O"));
SYSTEM.PUT(rsData,ORD("b"));
SYSTEM.PUT(rsData,ORD("e"));
SYSTEM.PUT(rsData,ORD("r"));
SYSTEM.PUT(rsData,ORD("o"));
SYSTEM.PUT(rsData,ORD("n"));
SYSTEM.PUT(rsData,13);
SYSTEM.PUT(rsData,10);
END Greet;
(* begin-procedure-description
---
**Init** queries the system configuration, establishes the module store and the heap, and passes control to the Kernel.
end-procedure-description *)
PROCEDURE Init;
VAR x, y, z: INTEGER;
BEGIN
(*
LED(1); z := 0;
REPEAT LED(z); x := 1000;
REPEAT y := 1000;
REPEAT y := y-1 UNTIL y = 0;
x := x-1
UNTIL x = 0;
z := z+1
UNTIL FALSE
*)
END Init;
(* begin-procedure-description
---
**The initialzation code for this module** establishes the stack and module table origin, transmits a greeting, and then calls Init.
end-procedure-description *)
BEGIN SYSTEM.LDREG(0, stackOrg);
SYSTEM.REGREG(SP,0); (*can't load constants to SP directly on aarch64*)
SYSTEM.LDREG(MT, MTOrg);
Greet;
Init;
WHILE TRUE DO END
END HAL.