3 #include "../port/lib.h"
7 #include "../port/error.h"
10 #include "rebootcode.i"
18 * starting place for first process
23 char buf[2*KNAMELEN], **sp;
28 snprint(buf, sizeof(buf), "%s %s", "ARM64", conffile);
29 ksetenv("terminal", buf, 0);
30 ksetenv("cputype", "arm64", 0);
32 ksetenv("service", "cpu", 0);
34 ksetenv("service", "terminal", 0);
35 snprint(buf, sizeof(buf), "-a %s", getethermac());
36 ksetenv("etherargs", buf, 0);
38 /* convert plan9.ini variables to #e and #ec */
42 kproc("alarm", alarmkproc, 0);
44 sp = (char**)(USTKTOP-sizeof(Tos) - 8 - sizeof(sp[0])*4);
45 sp[3] = sp[2] = sp[1] = nil;
46 strcpy(sp[1] = (char*)&sp[4], "boot");
47 sp[0] = (void*)&sp[1];
59 if(p = getconf("service")){
60 if(strcmp(p, "cpu") == 0)
62 else if(strcmp(p,"terminal") == 0)
66 if(p = getconf("*kernelpercent"))
67 userpcnt = 100 - strtol(p, 0, 0);
72 userpcnt = 60 + cpuserver*10;
75 for(i = 0; i < nelem(conf.mem); i++)
76 conf.npage += conf.mem[i].npage;
78 kpages = conf.npage - (conf.npage*userpcnt)/100;
81 * can't go past the end of virtual memory
82 * (uintptr)-KZERO is 2^32 - KZERO
84 if(kpages > ((uintptr)-KZERO)/BY2PG)
85 kpages = ((uintptr)-KZERO)/BY2PG;
87 conf.upages = conf.npage - kpages;
88 conf.ialloc = (kpages/2)*BY2PG;
90 conf.nmach = getncpus();
92 /* set up other configuration parameters */
93 conf.nproc = 100 + ((conf.npage*BY2PG)/MB)*5;
98 conf.nswap = conf.npage*3;
102 conf.copymode = conf.nmach > 1;
105 * Guess how much is taken by the large permanent
106 * datastructures. Mntcache and Mntrpc are not accounted for.
108 kpages = conf.npage - conf.upages;
110 kpages -= conf.upages*sizeof(Page)
111 + conf.nproc*sizeof(Proc)
112 + conf.nimage*sizeof(Image)
114 + conf.nswppo*sizeof(Page*);
115 mainmem->maxsize = kpages;
118 * give terminals lots of image memory, too; the dynamic
119 * allocation will balance the load properly, hopefully.
120 * be careful with 32-bit overflow.
122 imagmem->maxsize = kpages;
130 active.machs[m->machno] = 1;
136 extern void _start(void);
139 for(i = 1; i < conf.nmach; i++){
140 MACHP(i)->machno = i;
141 cachedwbinvse(MACHP(i), MACHSIZE);
143 for(i = 0; i < MAXMACH; i++)
144 ((uintptr*)SPINTABLE)[i] = i < conf.nmach ? PADDR(_start) : 0;
145 cachedwbinvse((void*)SPINTABLE, MAXMACH*8);
153 for(i = 0; i < MAXMACH; i++)
154 ((uintptr*)SPINTABLE)[i] = 0;
170 m->ticks = MACHP(0)->ticks;
184 /* set clock rate to arm_freq from config.txt */
185 setclkrate(ClkArm, 0);
200 mmu0clear((uintptr*)L1);
207 rebootjump(void *entry, void *code, ulong size)
209 void (*f)(void*, void*, ulong);
213 /* redo identity map */
214 mmuidmap((uintptr*)L1);
216 /* setup reboot trampoline function */
217 f = (void*)REBOOTADDR;
218 memmove(f, rebootcode, sizeof(rebootcode));
220 cachedwbinvse(f, sizeof(rebootcode));
221 cacheiinvse(f, sizeof(rebootcode));
223 (*f)(entry, code, size);
239 reboot(void *entry, void *code, ulong size)
242 while(m->machno != 0){
252 /* turn off buffered serial console */
255 /* shutdown devices */
258 /* stop the clock (and watchdog if any) */
263 /* off we go - never to return */
264 rebootjump(entry, code, size);
268 * stub for ../omap/devether.c
271 isaconfig(char *, int, ISAConf *)