2 #include "../port/lib.h"
6 #include "../port/error.h"
15 return (cp[0]<<24) | (cp[1]<<16) | (cp[2]<<8) | cp[3];
20 readn(Chan *c, void *vp, long n)
26 nn = devtab[c->type]->read(c, p, n, c->offset);
36 rebootcmd(int argc, char *argv[])
40 ulong magic, text, rtext, entry, data, size;
46 c = namec(argv[0], Aopen, OEXEC, 0);
52 readn(c, &exec, sizeof(Exec));
53 magic = l2be(exec.magic);
54 entry = l2be(exec.entry);
55 text = l2be(exec.text);
56 data = l2be(exec.data);
58 if(!(magic == AOUT_MAGIC)){
62 if((I_MAGIC == AOUT_MAGIC) || (S_MAGIC == AOUT_MAGIC))
71 /* round text out to page boundary */
72 rtext = PGROUND(entry+text)-entry;
85 readn(c, p + rtext, data);
87 ksetenv("bootfile", argv[0], 1);
89 reboot((void*)entry, p, size);