Significant progress to getting pl1$pl1 to compile something, implemented many necess...
[multics_sim.git] / stack_frame.h
1 #ifndef _STACK_FRAME_H
2 #define _STACK_FRAME_H
3
4 #include "pointer.h"
5
6 // see pl1/stack_frame.incl.pl1
7
8 // dcl RETURN_PTR_MASK bit (72) int static options (constant) /* mask to be AND'd with stack_frame.return_ptr */
9 // init ("777777777777777777000000"b3); /* when copying, to ignore bits that a call fills */
10 // /* with indicators (nonzero for Fortran hexfp caller) */
11 // /* say: unspec(ptr) = unspec(stack_frame.return_ptr) & RETURN_PTR_MASK; */
12 #define RETURN_PTR_MASK 0777777777777777777000000L
13
14 enum {
15   // dcl TRANSLATOR_ID_PL1V2 bit (18) internal static options (constant) init ("000000"b3);
16   TRANSLATOR_ID_PL1V2 = 0,
17
18   // dcl TRANSLATOR_ID_ALM bit (18) internal static options (constant) init ("000001"b3);
19   TRANSLATOR_ID_ALM = 1,
20
21   // dcl TRANSLATOR_ID_PL1V1 bit (18) internal static options (constant) init ("000002"b3);
22   TRANSLATOR_ID_PL1V1 = 2,
23
24   // dcl TRANSLATOR_ID_SIGNAL_CALLER bit (18) internal static options (constant) init ("000003"b3);
25   TRANSLATOR_ID_SIGNAL_CALLER = 3,
26
27   // dcl TRANSLATOR_ID_SIGNALLER bit (18) internal static options (constant) init ("000004"b3);
28   TRANSLATOR_ID_SIGNALLER = 4
29 };
30
31 // dcl sp pointer; /* pointer to beginning of stack frame */
32
33 // dcl stack_frame_min_length fixed bin static init(48);
34
35 // dcl 1 stack_frame based(sp) aligned,
36 struct stack_frame {
37   // 2 pointer_registers(0 : 7) ptr,
38   struct its_pointer pointer_registers[8];
39
40   // 2 prev_sp pointer,
41   struct its_pointer prev_sp;
42
43   // 2 next_sp pointer,
44   struct its_pointer next_sp;
45
46   // 2 return_ptr pointer,
47   struct its_pointer return_ptr;
48
49   // 2 entry_ptr pointer,
50   struct its_pointer entry_ptr;
51
52   // 2 operator_and_lp_ptr ptr, /* serves as both */
53   struct its_pointer operator_and_lp_ptr;
54
55   // 2 arg_ptr pointer,
56   struct its_pointer arg_ptr;
57
58   // 2 static_ptr ptr unaligned,
59   struct its_pointer static_ptr;
60
61   // 2 support_ptr ptr unal, /* only used by fortran I/O */
62   struct packed_pointer support_ptr;
63
64   // 2 on_unit_relp1 bit(18) unaligned,
65   // 2 on_unit_relp2 bit(18) unaligned,
66   uint64_t on_unit_relp2 : 18;
67   uint64_t on_unit_relp1 : 18;
68   uint64_t dummy0 : 28;
69
70   // 2 translator_id bit(18) unaligned, /* Translator ID (see constants above)
71   // 0 => PL/I version II
72   // 1 => ALM
73   // 2 => PL/I version I 
74   // 3 => signal caller frame
75   // 4 => signaller frame */
76   // 2 operator_return_offset bit(18) unaligned,
77   uint64_t operator_return_offset : 18;
78   uint64_t translator_id : 18;
79   uint64_t dummy1 : 28;
80
81   // 2 x(0: 7) bit(18) unaligned, /* index registers */
82   uint64_t x1 : 18;
83   uint64_t x0 : 18;
84   uint64_t dummy2 : 28;
85   uint64_t x3 : 18;
86   uint64_t x2 : 18;
87   uint64_t dummy3 : 28;
88   uint64_t x5 : 18;
89   uint64_t x4 : 18;
90   uint64_t dummy4 : 28;
91   uint64_t x7 : 18;
92   uint64_t x6 : 18;
93   uint64_t dummy5 : 28;
94
95   // 2 a bit(36), /* accumulator */
96   uint64_t a;
97
98   // 2 q bit(36), /* q-register */
99   uint64_t q;
100
101   // 2 e bit(36), /* exponent */
102   uint64_t e;
103
104   // 2 timer bit(27) unaligned, /* timer */
105   // 2 pad bit(6) unaligned,
106   // 2 ring_alarm_reg bit(3) unaligned;
107   uint64_t ring_alarm_reg : 3;
108   uint64_t pad : 6;
109   uint64_t timer : 27;
110   uint64_t dummy6 : 28;
111 };
112
113 // dcl 1 stack_frame_flags based(sp) aligned,
114 struct stack_frame_flags {
115   // 2 pad(0 : 7) bit(72), /* skip over prs */
116   uint64_t pad[16];
117
118   // 2 xx0 bit(22) unal,
119   // 2 main_proc bit(1) unal, /* on if frame belongs to a main procedure */
120   // 2 run_unit_manager bit(1) unal, /* on if frame belongs to run unit manager */
121   // 2 signal bit(1) unal, /* on if frame belongs to logical signal_ */
122   // 2 crawl_out bit(1) unal, /* on if this is a signal caller frame */
123   // 2 signaller bit(1) unal, /* on if next frame is signaller's */
124   // 2 link_trap bit(1) unal, /* on if this frame was made by the linker */
125   // 2 support bit(1) unal, /* on if frame belongs to a support proc */
126   // 2 condition bit(1) unal, /* on if condition established in this frame */
127   // 2 xx0a bit(6) unal,
128   uint64_t xx0a : 6;
129   uint64_t condition : 1;
130   uint64_t support : 1;
131   uint64_t link_trap : 1;
132   uint64_t signaller : 1;
133   uint64_t crawl_out : 1;
134   uint64_t signal : 1;
135   uint64_t run_unit_manager : 1;
136   uint64_t main_proc : 1;
137   uint64_t xx0 : 22;
138   uint64_t dummy0 : 28;
139
140   // 2 xx1 fixed bin,
141   // 2 xx2 fixed bin,
142   int64_t xx2 : 18;
143   uint64_t dummy1 : 46;
144   int64_t xx1 : 18;
145   uint64_t dummy2 : 46;
146
147   // 2 xx3 bit(25) unal,
148   // 2 old_crawl_out bit (1) unal, /* on if this is a signal caller frame */
149   // 2 old_signaller bit(1) unal, /* on if next frame is signaller's */
150   // 2 xx3a bit(9) unaligned,
151   uint64_t xx3a : 9;
152   uint64_t old_signaller : 1;
153   uint64_t old_crawl_out : 1;
154   uint64_t xx3 : 25;
155   uint64_t dummy3 : 28;
156
157   // 2 xx4(9) bit(72) aligned,
158   uint64_t xx4[18];
159
160   // 2 v2_pl1_op_ret_base ptr, /* When a V2 PL/I program calls an operator the
161   // * operator puts a pointer to the base of
162   // * the calling procedure here. (text base ptr) */
163   struct its_pointer v2_pl1_op_ret_base;
164
165   // 2 xx5 bit(72) aligned,
166   uint64_t xx5[2];
167
168   // 2 pl1_ps_ptr ptr; /* ptr to ps for this frame; also used by fio. */
169   struct its_pointer pl1_ps_ptr;
170 };
171
172 #endif