dat.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. typedef struct Conf Conf;
  2. typedef struct Confmem Confmem;
  3. typedef struct FPsave FPsave;
  4. typedef struct ISAConf ISAConf;
  5. typedef struct Label Label;
  6. typedef struct Lock Lock;
  7. typedef struct Memcache Memcache;
  8. typedef struct MMMU MMMU;
  9. typedef struct Mach Mach;
  10. typedef struct Notsave Notsave;
  11. typedef struct Page Page;
  12. typedef struct Pcidev Pcidev;
  13. typedef struct PhysUart PhysUart;
  14. typedef struct PMMU PMMU;
  15. typedef struct Proc Proc;
  16. typedef u32int PTE;
  17. typedef struct Soc Soc;
  18. typedef struct Uart Uart;
  19. typedef struct Ureg Ureg;
  20. typedef uvlong Tval;
  21. #pragma incomplete Pcidev
  22. #pragma incomplete Ureg
  23. #define MAXSYSARG 5 /* for mount(fd, mpt, flag, arg, srv) */
  24. /*
  25. * parameters for sysproc.c
  26. */
  27. #define AOUT_MAGIC (E_MAGIC)
  28. struct Lock
  29. {
  30. ulong key;
  31. u32int sr;
  32. uintptr pc;
  33. Proc* p;
  34. Mach* m;
  35. int isilock;
  36. };
  37. struct Label
  38. {
  39. uintptr sp;
  40. uintptr pc;
  41. };
  42. /*
  43. * emulated floating point
  44. */
  45. struct FPsave
  46. {
  47. ulong status;
  48. ulong control;
  49. ulong regs[8][3];
  50. int fpstate;
  51. };
  52. /*
  53. * FPsave.status
  54. */
  55. enum
  56. {
  57. FPinit,
  58. FPactive,
  59. FPinactive,
  60. /* bit or'd with the state */
  61. FPillegal= 0x100,
  62. };
  63. struct Confmem
  64. {
  65. uintptr base;
  66. usize npage;
  67. uintptr limit;
  68. uintptr kbase;
  69. uintptr klimit;
  70. };
  71. struct Conf
  72. {
  73. ulong nmach; /* processors */
  74. ulong nproc; /* processes */
  75. ulong monitor; /* has monitor? */
  76. Confmem mem[1]; /* physical memory */
  77. ulong npage; /* total physical pages of memory */
  78. usize upages; /* user page pool */
  79. ulong copymode; /* 0 is copy on write, 1 is copy on reference */
  80. ulong ialloc; /* max interrupt time allocation in bytes */
  81. ulong pipeqsize; /* size in bytes of pipe queues */
  82. ulong nimage; /* number of page cache image headers */
  83. ulong nswap; /* number of swap pages */
  84. int nswppo; /* max # of pageouts per segment pass */
  85. // ulong hz; /* processor cycle freq */
  86. // ulong mhz;
  87. };
  88. /*
  89. * things saved in the Proc structure during a notify
  90. */
  91. struct Notsave {
  92. int emptiness;
  93. };
  94. /*
  95. * MMU stuff in Mach.
  96. */
  97. struct MMMU
  98. {
  99. PTE* mmul1; /* l1 for this processor */
  100. int mmul1lo;
  101. int mmul1hi;
  102. int mmupid;
  103. };
  104. /*
  105. * MMU stuff in proc
  106. */
  107. #define NCOLOR 1 /* 1 level cache, don't worry about VCE's */
  108. struct PMMU
  109. {
  110. Page* mmul2;
  111. Page* mmul2cache; /* free mmu pages */
  112. };
  113. #include "../port/portdat.h"
  114. struct Mach
  115. {
  116. int machno; /* physical id of processor */
  117. uintptr splpc; /* pc of last caller to splhi */
  118. Proc* proc; /* current process */
  119. MMMU;
  120. int flushmmu; /* flush current proc mmu state */
  121. ulong ticks; /* of the clock since boot time */
  122. Label sched; /* scheduler wakeup */
  123. Lock alarmlock; /* access to alarm list */
  124. void* alarm; /* alarms bound to this clock */
  125. int inclockintr;
  126. Proc* readied; /* for runproc */
  127. ulong schedticks; /* next forced context switch */
  128. int cputype;
  129. int socrev; /* system-on-chip revision */
  130. ulong delayloop;
  131. /* stats */
  132. int tlbfault;
  133. int tlbpurge;
  134. int pfault;
  135. int cs;
  136. int syscall;
  137. int load;
  138. int intr;
  139. vlong fastclock; /* last sampled value */
  140. uvlong inidle; /* time spent in idlehands() */
  141. ulong spuriousintr;
  142. int lastintr;
  143. int ilockdepth;
  144. Perf perf; /* performance counters */
  145. // int cpumhz;
  146. uvlong cpuhz; /* speed of cpu */
  147. uvlong cyclefreq; /* Frequency of user readable cycle counter */
  148. /* save areas for exceptions */
  149. u32int sfiq[5];
  150. u32int sirq[5];
  151. u32int sund[5];
  152. u32int sabt[5];
  153. #define fiqstack sfiq
  154. #define irqstack sirq
  155. #define abtstack sabt
  156. #define undstack sund
  157. int stack[1];
  158. };
  159. /*
  160. * Fake kmap.
  161. */
  162. typedef void KMap;
  163. #define VA(k) ((uintptr)(k))
  164. #define kmap(p) (KMap*)((p)->pa|kseg0)
  165. #define kunmap(k)
  166. struct
  167. {
  168. Lock;
  169. int machs; /* bitmap of active CPUs */
  170. int exiting; /* shutdown */
  171. int ispanic; /* shutdown in response to a panic */
  172. }active;
  173. enum {
  174. Frequency = 1200*1000*1000, /* the processor clock */
  175. };
  176. extern register Mach* m; /* R10 */
  177. extern register Proc* up; /* R9 */
  178. extern uintptr kseg0;
  179. extern Mach* machaddr[MAXMACH];
  180. extern ulong memsize;
  181. enum {
  182. Nvec = 8, /* # of vectors at start of lexception.s */
  183. };
  184. /*
  185. * Layout of physical 0.
  186. */
  187. typedef struct Vectorpage {
  188. void (*vectors[Nvec])(void);
  189. uint vtable[Nvec];
  190. } Vectorpage;
  191. /*
  192. * a parsed plan9.ini line
  193. */
  194. #define NISAOPT 8
  195. struct ISAConf {
  196. char *type;
  197. ulong port;
  198. int irq;
  199. ulong dma;
  200. ulong mem;
  201. ulong size;
  202. ulong freq;
  203. int nopt;
  204. char *opt[NISAOPT];
  205. };
  206. #define MACHP(n) (machaddr[n])
  207. /*
  208. * Horrid. But the alternative is 'defined'.
  209. */
  210. #ifdef _DBGC_
  211. #define DBGFLG (dbgflg[_DBGC_])
  212. #else
  213. #define DBGFLG (0)
  214. #endif /* _DBGC_ */
  215. int vflag;
  216. extern char dbgflg[256];
  217. #define dbgprint print /* for now */
  218. /*
  219. * hardware info about a device
  220. */
  221. typedef struct {
  222. ulong port;
  223. int size;
  224. } Devport;
  225. struct DevConf
  226. {
  227. ulong intnum; /* interrupt number */
  228. char *type; /* card type, malloced */
  229. int nports; /* Number of ports */
  230. Devport *ports; /* The ports themselves */
  231. };
  232. enum {
  233. Dcache,
  234. Icache,
  235. Unified,
  236. };
  237. /* characteristics of a given cache level */
  238. struct Memcache {
  239. uint level; /* 1 is nearest processor, 2 further away */
  240. uint kind; /* I, D or unified */
  241. uint size;
  242. uint nways; /* associativity */
  243. uint nsets;
  244. uint linelen; /* bytes per cache line */
  245. uint setsways;
  246. uint log2linelen;
  247. uint waysh; /* shifts for set/way register */
  248. uint setsh;
  249. };
  250. struct Soc { /* addr's of SoC controllers */
  251. uintptr cpu;
  252. uintptr devid;
  253. uintptr l2cache;
  254. uintptr sdramc;
  255. uintptr iocfg;
  256. uintptr addrmap;
  257. uintptr intr;
  258. uintptr nand;
  259. uintptr cesa; /* crypto accel. */
  260. uintptr ehci;
  261. uintptr spi;
  262. uintptr twsi;
  263. uintptr analog;
  264. uintptr pci;
  265. uintptr pcibase;
  266. uintptr rtc; /* real-time clock */
  267. uintptr clock;
  268. uintptr ether[2];
  269. uintptr sata[3];
  270. uintptr uart[2];
  271. uintptr gpio[2];
  272. } soc;
  273. extern Soc soc;