2 #include "../port/lib.h"
9 #include "../port/error.h"
13 int normalprint, delaylink;
15 enum { MAXCONF = 64 };
17 char *confname[MAXCONF], *confval[MAXCONF];
28 reboot(void *, void *, ulong)
37 postnote(up, 1, "sys: odd address", NDebug);
47 p->kentry = up->kentry;
48 p->pcycles = -p->kentry;
51 switch(up->fpstate & ~FPillegal){
54 up->fpstate = FPinactive;
56 memmove(p->fpsave, up->fpsave, sizeof(FPsave));
57 p->fpstate = FPinactive;
69 p->pcycles = -p->kentry;
78 tos = (Tos*)(USTKTOP-sizeof(Tos));
80 tos->kcycles += t - up->kentry;
81 tos->pcycles = t + up->pcycles;
101 slcr[0xa1c/4] = 0x020202;
102 l2 = vmap(L2_BASE, BY2PG);
104 l2[TAGRAM] = l2[TAGRAM] & ~0x777 | 0x111;
105 l2[DATARAM] = l2[DATARAM] & ~0x777 | 0x121;
106 l2[PREFETCH] |= 3<<28 | 1<<24;
107 l2[AUX] |= 3<<28 | 1<<20;
109 while((l2[INVPA] & 1) != 0)
115 clean2pa(uintptr start, uintptr end)
120 end = (end + 31) & ~31;
121 for(pa = start; pa < end; pa += 32)
126 inval2pa(uintptr start, uintptr end)
131 end = (end + 31) & ~31;
132 for(pa = start; pa < end; pa += 32)
140 char *cp, *line[MAXCONF], *p, *q;
142 cp = (char *) CONFADDR;
145 for(q = cp; *q; q++){
154 n = getfields(cp, line, MAXCONF, 1, "\n");
155 for(i = 0; i < n; i++){
158 cp = strchr(line[i], '=');
162 confname[nconf] = line[i];
177 conf.ialloc = 16*1024*1024;
179 conf.mem[0].base = PGROUND((ulong)end - KZERO);
180 conf.mem[0].npage = (1024*1024*1024 - conf.mem[0].base) >> PGSHIFT;
185 for(i = 0; i < nelem(conf.mem); i++)
186 conf.npage += conf.mem[i].npage;
188 kmem = 200*1024*1024;
189 conf.upages = conf.npage - kmem/BY2PG;
190 kmem -= conf.upages*sizeof(Page)
191 + conf.nproc*sizeof(Proc)
192 + conf.nimage*sizeof(Image);
193 mainmem->maxsize = kmem;
194 imagmem->maxsize = kmem - (kmem/10);
200 char buf[ERRMAX], **sp;
206 up->slash = namec("#/", Atodir, 0, 0);
207 pathclose(up->slash->path);
208 up->slash->path = newpath("/");
209 up->dot = cclone(up->slash);
215 ksetenv("cputype", "arm", 0);
217 ksetenv("service", "cpu", 0);
219 ksetenv("service", "terminal", 0);
220 ksetenv("console", "0", 0);
221 snprint(buf, sizeof(buf), "zynq %s", conffile);
222 ksetenv("terminal", buf, 0);
223 for(i = 0; i < nconf; i++){
224 if(*confname[i] != '*')
225 ksetenv(confname[i], confval[i], 0);
226 ksetenv(confname[i], confval[i], 1);
230 kproc("alarm", alarmkproc, 0);
232 sp = (char**)(USTKTOP - sizeof(Tos) - 8 - sizeof(sp[0])*4);
234 strcpy(sp[1] = (char*)&sp[4], "boot");
249 p->egrp = smalloc(sizeof(Egrp));
251 p->fgrp = dupfgrp(nil);
256 kstrdup(&p->text, "*init*");
257 kstrdup(&p->user, eve);
261 p->sched.pc = (ulong)init0;
262 p->sched.sp = (ulong)p->kstack + KSTACK - (sizeof(Sargs) + BY2WD);
264 s = newseg(SG_STACK, USTKTOP - USTKSIZE, USTKSIZE / BY2PG);
266 pg = newpage(0, 0, USTKTOP - BY2PG);
272 s = newseg(SG_TEXT, UTZERO, 1);
275 pg = newpage(0, 0, UTZERO);
281 memmove(v, initcode, sizeof(initcode));
290 static int dat = 0xdeadbeef;
291 extern ulong vectors[];
293 assert(dat == 0xdeadbeef);
294 assert(((uintptr)vectors & 31) == 0);
295 assert(sizeof(Mach) + KSTACK <= MACHSIZE);
296 assert((KZERO & SECSZ - 1) == 0);
304 for(i = 0; i < nconf; i++)
305 if(cistrcmp(confname[i], n) == 0)
311 isaconfig(char *, int, ISAConf*)
319 print("cpu%d: %dMHz ARM Cortex-A9\n", m->machno, m->cpumhz);
325 extern void mpbootstrap(void); /* l.s */
337 memset(m1, 0, MACHSIZE);
339 m1->l1.pa = MACHL1(m1->machno)-KZERO;
340 m1->l1.va = KADDR(m1->l1.pa);
342 memset(m1->l1.va, 0, L1SZ);
343 for(i=0; i<L1X(VMAPSZ); i++)
344 m1->l1.va[L1X(VMAP)+i] = m->l1.va[L1X(VMAP)+i];
345 for(i=0; i<L1X(-KZERO); i++)
346 m1->l1.va[L1X(KZERO)+i] = m->l1.va[L1X(KZERO)+i];
348 cleandse((uchar*)KZERO, (uchar*)0xFFFFFFFF);
349 invaldse((uchar*)KZERO, (uchar*)0xFFFFFFFF);
351 /* ocm is uncached */
352 v = KADDR(0xFFFFF000);
353 v[0xFF0/4] = PADDR(mpbootstrap);
363 active.machs[m->machno] = 1;
382 uartputs(" from Bell Labs\n", 16);
406 setupwatchpts(Proc *, Watchpt *, int n)
409 error("no watchpoints");