changelog shortlog tags branches changeset files revisions annotate raw help

Mercurial > hg > plan9front / sys/src/9/bcm/dat.h

changeset 7234: fc141b91ed8a
parent: f80792d28e0e
child: 55d93e47a2de
author: cinap_lenrek@felloff.net
date: Mon, 13 May 2019 19:12:41 +0200
permissions: -rw-r--r--
description: bcm, bcm64: preserve memsize across reboots, avoid trashing atags while parsing cmdline

we override atag memory on reboot, so preserve
the memsize learned from atag as *maxmem plan9
variable. the global memsize variable is not
needed anymore.

avoid trashing the following atag when zero
terminating the cmdline string.

zero memory after plan9.ini variables.
1 /*
2  * Time.
3  *
4  * HZ should divide 1000 evenly, ideally.
5  * 100, 125, 200, 250 and 333 are okay.
6  */
7 #define HZ 100 /* clock frequency */
8 #define MS2HZ (1000/HZ) /* millisec per clock tick */
9 #define TK2SEC(t) ((t)/HZ) /* ticks to seconds */
10 
11 enum {
12  Mhz = 1000 * 1000,
13 };
14 
15 typedef struct Conf Conf;
16 typedef struct Confmem Confmem;
17 typedef struct FPsave FPsave;
18 typedef struct PFPU PFPU;
19 typedef struct ISAConf ISAConf;
20 typedef struct Label Label;
21 typedef struct Lock Lock;
22 typedef struct Memcache Memcache;
23 typedef struct MMMU MMMU;
24 typedef struct Mach Mach;
25 typedef struct Page Page;
26 typedef struct PhysUart PhysUart;
27 typedef struct PMMU PMMU;
28 typedef struct Proc Proc;
29 typedef u32int PTE;
30 typedef struct Soc Soc;
31 typedef struct Uart Uart;
32 typedef struct Ureg Ureg;
33 typedef uvlong Tval;
34 
35 #pragma incomplete Ureg
36 
37 #define MAXSYSARG 5 /* for mount(fd, mpt, flag, arg, srv) */
38 
39 /*
40  * parameters for sysproc.c
41  */
42 #define AOUT_MAGIC (E_MAGIC)
43 
44 struct Lock
45 {
46  ulong key;
47  u32int sr;
48  uintptr pc;
49  Proc* p;
50  Mach* m;
51  int isilock;
52 };
53 
54 struct Label
55 {
56  uintptr sp;
57  uintptr pc;
58 };
59 
60 /*
61  * emulated or vfp3 floating point
62  */
63 enum {
64  Maxfpregs = 32, /* could be 16 or 32, see Mach.fpnregs */
65  Nfpctlregs = 16,
66 };
67 
68 struct FPsave
69 {
70  ulong status;
71  ulong control;
72  /*
73  * vfp3 with ieee fp regs; uvlong is sufficient for hardware but
74  * each must be able to hold an Internal from fpi.h for sw emulation.
75  */
76  ulong regs[Maxfpregs][3];
77 
78  int fpstate;
79  uintptr pc; /* of failed fp instr. */
80 };
81 
82 struct PFPU
83 {
84  int fpstate;
85  FPsave fpsave[1];
86 };
87 
88 enum
89 {
90  FPinit,
91  FPactive,
92  FPinactive,
93  FPemu,
94 
95  /* bits or'd with the state */
96  FPillegal= 0x100,
97 };
98 
99 struct Confmem
100 {
101  uintptr base;
102  usize npage;
103  uintptr limit;
104  uintptr kbase;
105  uintptr klimit;
106 };
107 
108 struct Conf
109 {
110  ulong nmach; /* processors */
111  ulong nproc; /* processes */
112  Confmem mem[1]; /* physical memory */
113  ulong npage; /* total physical pages of memory */
114  usize upages; /* user page pool */
115  ulong copymode; /* 0 is copy on write, 1 is copy on reference */
116  ulong ialloc; /* max interrupt time allocation in bytes */
117  ulong pipeqsize; /* size in bytes of pipe queues */
118  ulong nimage; /* number of page cache image headers */
119  ulong nswap; /* number of swap pages */
120  int nswppo; /* max # of pageouts per segment pass */
121  ulong hz; /* processor cycle freq */
122  ulong mhz;
123  int monitor; /* flag */
124 };
125 
126 /*
127  * MMU stuff in Mach.
128  */
129 struct MMMU
130 {
131  PTE* mmul1; /* l1 for this processor */
132  int mmul1lo;
133  int mmul1hi;
134  int mmupid;
135 };
136 
137 /*
138  * MMU stuff in proc
139  */
140 #define NCOLOR 1 /* 1 level cache, don't worry about VCE's */
141 struct PMMU
142 {
143  Page* mmul2;
144  Page* mmul2cache; /* free mmu pages */
145 };
146 
147 #include "../port/portdat.h"
148 
149 struct Mach
150 {
151  int machno; /* physical id of processor */
152  uintptr splpc; /* pc of last caller to splhi */
153 
154  Proc* proc; /* current process */
155 
156  MMMU;
157  int flushmmu; /* flush current proc mmu state */
158 
159  ulong ticks; /* of the clock since boot time */
160  Label sched; /* scheduler wakeup */
161  Lock alarmlock; /* access to alarm list */
162  void* alarm; /* alarms bound to this clock */
163 
164  Proc* readied; /* for runproc */
165  ulong schedticks; /* next forced context switch */
166 
167  int cputype;
168  ulong delayloop;
169 
170  /* stats */
171  int tlbfault;
172  int tlbpurge;
173  int pfault;
174  int cs;
175  int syscall;
176  int load;
177  int intr;
178  uvlong fastclock; /* last sampled value */
179  uvlong inidle; /* time spent in idlehands() */
180  ulong spuriousintr;
181  int lastintr;
182  int ilockdepth;
183  Perf perf; /* performance counters */
184 
185 
186  int cpumhz;
187  uvlong cpuhz; /* speed of cpu */
188  uvlong cyclefreq; /* Frequency of user readable cycle counter */
189 
190  /* vfp2 or vfp3 fpu */
191  int havefp;
192  int havefpvalid;
193  int fpon;
194  int fpconfiged;
195  int fpnregs;
196  ulong fpscr; /* sw copy */
197  int fppid; /* pid of last fault */
198  uintptr fppc; /* addr of last fault */
199  int fpcnt; /* how many consecutive at that addr */
200 
201  /* save areas for exceptions, hold R0-R4 */
202  u32int sfiq[5];
203  u32int sirq[5];
204  u32int sund[5];
205  u32int sabt[5];
206  u32int smon[5]; /* probably not needed */
207  u32int ssys[5];
208 
209  int stack[1];
210 };
211 
212 /*
213  * Fake kmap.
214  */
215 typedef void KMap;
216 #define VA(k) ((uintptr)(k))
217 #define kmap(p) (KMap*)((p)->pa|kseg0)
218 extern void kunmap(KMap*);
219 
220 struct
221 {
222  char machs[MAXMACH]; /* active CPUs */
223  int exiting; /* shutdown */
224 }active;
225 
226 extern register Mach* m; /* R10 */
227 extern register Proc* up; /* R9 */
228 extern uintptr kseg0;
229 extern Mach* machaddr[MAXMACH];
230 extern int normalprint;
231 
232 /*
233  * a parsed plan9.ini line
234  */
235 #define NISAOPT 8
236 
237 struct ISAConf {
238  char *type;
239  ulong port;
240  int irq;
241  ulong dma;
242  ulong mem;
243  ulong size;
244  ulong freq;
245 
246  int nopt;
247  char *opt[NISAOPT];
248 };
249 
250 #define MACHP(n) (machaddr[n])
251 
252 /*
253  * Horrid. But the alternative is 'defined'.
254  */
255 #ifdef _DBGC_
256 #define DBGFLG (dbgflg[_DBGC_])
257 #else
258 #define DBGFLG (0)
259 #endif /* _DBGC_ */
260 
261 int vflag;
262 extern char dbgflg[256];
263 
264 #define dbgprint print /* for now */
265 
266 /*
267  * hardware info about a device
268  */
269 typedef struct {
270  ulong port;
271  int size;
272 } Devport;
273 
274 struct DevConf
275 {
276  ulong intnum; /* interrupt number */
277  char *type; /* card type, malloced */
278  int nports; /* Number of ports */
279  Devport *ports; /* The ports themselves */
280 };
281 
282 struct Soc { /* SoC dependent configuration */
283  ulong dramsize;
284  uintptr physio;
285  uintptr busdram;
286  uintptr busio;
287  uintptr armlocal;
288  u32int l1ptedramattrs;
289  u32int l2ptedramattrs;
290 };
291 extern Soc soc;
292 
293 #define BUSUNKNOWN -1
294 
295 /*
296  * GPIO
297  */
298 enum {
299  Input = 0x0,
300  Output = 0x1,
301  Alt0 = 0x4,
302  Alt1 = 0x5,
303  Alt2 = 0x6,
304  Alt3 = 0x7,
305  Alt4 = 0x3,
306  Alt5 = 0x2,
307 };