]> git.lizzy.rs Git - plan9front.git/blob - sys/src/9/bcm64/dat.h
bcm64: add pci express driver for raspberry pi 4
[plan9front.git] / sys / src / 9 / bcm64 / dat.h
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 Pcidev   Pcidev;
28 typedef struct PMMU     PMMU;
29 typedef struct Proc     Proc;
30 typedef u64int          PTE;
31 typedef struct Soc      Soc;
32 typedef struct Uart     Uart;
33 typedef struct Ureg     Ureg;
34 typedef uvlong          Tval;
35 typedef void            KMap;
36
37 #pragma incomplete Pcidev
38 #pragma incomplete Ureg
39
40 #define MAXSYSARG       5       /* for mount(fd, mpt, flag, arg, srv) */
41
42 /*
43  *  parameters for sysproc.c
44  */
45 #define AOUT_MAGIC      (R_MAGIC)
46
47 struct Lock
48 {
49         ulong   key;
50         u32int  sr;
51         uintptr pc;
52         Proc*   p;
53         Mach*   m;
54         int     isilock;
55 };
56
57 struct Label
58 {
59         uintptr sp;
60         uintptr pc;
61 };
62
63 struct FPsave
64 {
65         uvlong  regs[32][2];
66
67         ulong   control;
68         ulong   status;
69 };
70
71 struct PFPU
72 {
73         FPsave  fpsave[1];
74
75         int     fpstate;
76 };
77
78 enum
79 {
80         FPinit,
81         FPactive,
82         FPinactive,
83
84         /* bits or'd with the state */
85         FPillegal= 0x100,
86 };
87
88 struct Confmem
89 {
90         uintptr base;
91         usize   npage;
92         uintptr limit;
93         uintptr kbase;
94         uintptr klimit;
95 };
96
97 struct Conf
98 {
99         ulong   nmach;          /* processors */
100         ulong   nproc;          /* processes */
101         Confmem mem[1];         /* physical memory */
102         ulong   npage;          /* total physical pages of memory */
103         usize   upages;         /* user page pool */
104         ulong   copymode;       /* 0 is copy on write, 1 is copy on reference */
105         ulong   ialloc;         /* max interrupt time allocation in bytes */
106         ulong   pipeqsize;      /* size in bytes of pipe queues */
107         ulong   nimage;         /* number of page cache image headers */
108         ulong   nswap;          /* number of swap pages */
109         int     nswppo;         /* max # of pageouts per segment pass */
110         ulong   hz;             /* processor cycle freq */
111         ulong   mhz;
112         int     monitor;        /* flag */
113 };
114
115 /*
116  *  MMU stuff in Mach.
117  */
118 struct MMMU
119 {
120         PTE*    mmutop;         /* first level user page table */
121 };
122
123 /*
124  *  MMU stuff in proc
125  */
126 #define NCOLOR  1               /* 1 level cache, don't worry about VCE's */
127
128 struct PMMU
129 {
130         union {
131         Page    *mmufree;       /* mmuhead[0] is freelist head */
132         Page    *mmuhead[PTLEVELS];
133         };
134         Page    *mmutail[PTLEVELS];
135         int     asid;
136         uintptr tpidr;
137 };
138
139 #include "../port/portdat.h"
140
141 struct Mach
142 {
143         int     machno;                 /* physical id of processor */
144         uintptr splpc;                  /* pc of last caller to splhi */
145
146         Proc*   proc;                   /* current process */
147
148         MMMU;
149         int     flushmmu;               /* flush current proc mmu state */
150
151         ulong   ticks;                  /* of the clock since boot time */
152         Label   sched;                  /* scheduler wakeup */
153         Lock    alarmlock;              /* access to alarm list */
154         void*   alarm;                  /* alarms bound to this clock */
155
156         Proc*   readied;                /* for runproc */
157         ulong   schedticks;             /* next forced context switch */
158
159         int     cputype;
160         ulong   delayloop;
161
162         /* stats */
163         int     tlbfault;
164         int     tlbpurge;
165         int     pfault;
166         int     cs;
167         int     syscall;
168         int     load;
169         int     intr;
170         uvlong  fastclock;              /* last sampled value */
171         uvlong  inidle;                 /* time spent in idlehands() */
172         ulong   spuriousintr;
173         int     lastintr;
174         int     ilockdepth;
175         Perf    perf;                   /* performance counters */
176
177         int     cpumhz;
178         uvlong  cpuhz;                  /* speed of cpu */
179         uvlong  cyclefreq;              /* Frequency of user readable cycle counter */
180
181         int     stack[1];
182 };
183
184 struct
185 {
186         char    machs[MAXMACH];         /* active CPUs */
187         int     exiting;                /* shutdown */
188 }active;
189
190 #define MACHP(n)        ((Mach*)MACHADDR(n))
191
192 extern register Mach* m;                        /* R27 */
193 extern register Proc* up;                       /* R26 */
194 extern int normalprint;
195
196 /*
197  *  a parsed plan9.ini line
198  */
199 #define NISAOPT         8
200
201 struct ISAConf {
202         char    *type;
203         ulong   port;
204         int     irq;
205         ulong   dma;
206         ulong   mem;
207         ulong   size;
208         ulong   freq;
209
210         int     nopt;
211         char    *opt[NISAOPT];
212 };
213
214 /*
215  * Horrid. But the alternative is 'defined'.
216  */
217 #ifdef _DBGC_
218 #define DBGFLG          (dbgflg[_DBGC_])
219 #else
220 #define DBGFLG          (0)
221 #endif /* _DBGC_ */
222
223 int vflag;
224 extern char dbgflg[256];
225
226 #define dbgprint        print           /* for now */
227
228 /*
229  *  hardware info about a device
230  */
231 typedef struct {
232         ulong   port;
233         int     size;
234 } Devport;
235
236 struct DevConf
237 {
238         ulong   intnum;                 /* interrupt number */
239         char    *type;                  /* card type, malloced */
240         int     nports;                 /* Number of ports */
241         Devport *ports;                 /* The ports themselves */
242 };
243
244 struct Soc {                    /* SoC dependent configuration */
245         ulong   dramsize;
246         uintptr busdram;
247         ulong   iosize;
248         uintptr busio;
249         uintptr physio;
250         uintptr virtio;
251         uintptr armlocal;
252         uintptr pciwin;
253 };
254 extern Soc soc;
255
256 /*
257  * GPIO
258  */
259 enum {
260         Input   = 0x0,
261         Output  = 0x1,
262         Alt0    = 0x4,
263         Alt1    = 0x5,
264         Alt2    = 0x6,
265         Alt3    = 0x7,
266         Alt4    = 0x3,
267         Alt5    = 0x2,
268 };