-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHAL.riscv64.qemu.Mod
89 lines (71 loc) · 2.03 KB
/
HAL.riscv64.qemu.Mod
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
(* begin-module-short-description
provides a Hardware Abstraction Layer for 64-bit riscv.
end-module-short-description *)
(* begin-module-use-description
Module HAL (.v64) exercises features of the compiler in bringing Oberon up from bare metal on 64-bit RISCV.
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 riscv64 on QEMU.
The HAL remains resident and may be used by other modules.
end-module-develop-description *)
MODULE* HAL;
IMPORT SYSTEM;
CONST
stackOrg = 0BFFFF000H;
MTOrg = 80001000H;
rsData = 10000000H;
rsCtrl = -52;
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);
WHILE TRUE DO END
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(SP, stackOrg);
SYSTEM.LDREG(MT, MTOrg); *)
Greet;
Init;
WHILE TRUE DO END
END HAL.