| plan 9 kernel history: overview | file list | diff list |
1991/0304/power/boot.c (diff list | history)
| 1991/0131/sys/src/9/power/boot.c:44,49 – 1991/0304/sys/src/9/power/boot.c:44,50 (short | long | prev | next) | ||
| 1990/1127 | int dkdial(char *); int nonetdial(char *); int bitdial(char *); | |
| 1991/0304 | int preamble(int); | |
| 1990/0227 | ||
| 1990/0427 | /* * usage: 9b [-a] [server] [file] | |
| 1991/0131/sys/src/9/power/boot.c:237,274 – 1991/0304/sys/src/9/power/boot.c:238,295 | ||
| 1990/1127 | return fd; } | |
| 1991/0304 | int hotdial(char *arg) | |
| 1990/1127 | { | |
| 1991/01151 |
| |
| 1991/0304 | int fd; char srvdir[100]; Waitmsg m; | |
| 1990/1127 |
| |
| 1990/1202 |
| |
| 1991/0304 | /* * The killer: gotta get a hotrodboot running, so dial up * on datakit and load it. */ fd = dkdial(arg); if(fd < 0) return -1; if(!preamble(fd)){ close(fd); return -1; | |
| 1990/1127 | } | |
| 1990/1202 |
| |
| 1990/1127 |
| |
| 1991/0304 | /* * use /dev; it's local */ if(mount(fd, "/dev", MREPL, "", "") < 0) error("mount"); switch(fork()){ case 0: /* * child: get hotrodboot running */ execl("/dev/mips/bin/hotrodboot", "hotrodboot", "/dev/hobbit/hot", 0); error("execl hotrodboot"); case -1: error("fork"); | |
| 1990/1127 | } | |
| 1990/0427 |
| |
| 1991/0304 | /* * parent: wait, then sleep a while */ wait(&m); if(m.msg[0]) error(m.msg); fprint(2, "sleep 3 seconds\n"); sleep(3*1000); fprint(2, "go for it....\n"); return open("#H/hotrod", ORDWR); } | |
| 1990/0227 | ||
| 1991/0304 | int preamble(int fd) { int n; | |
| 1990/0227 | print("nop..."); hdr.type = Tnop; | |
| 1990/11211 | hdr.tag = ~0; | |
| 1991/0131/sys/src/9/power/boot.c:276,288 – 1991/0304/sys/src/9/power/boot.c:297,309 | ||
| 1990/0427 | if(write(fd, buf, n) != n){ print("n = %d\n", n); prerror("write nop"); | |
| 1991/0304 | return 0; | |
| 1990/0427 | } | |
| 1990/1127 | reread: | |
| 1990/0227 | n = read(fd, buf, sizeof buf); | |
| 1990/0427 | if(n <= 0){ prerror("read nop"); | |
| 1991/0304 | return 0; | |
| 1990/0427 | } | |
| 1990/1127 | if(n == 2) goto reread; | |
| 1991/0131/sys/src/9/power/boot.c:290,304 – 1991/0304/sys/src/9/power/boot.c:311,325 | ||
| 1990/0227 | print("n = %d; buf = %.2x %.2x %.2x %.2x\n", n, buf[0], buf[1], buf[2], buf[3]); | |
| 1990/0427 | prerror("format nop"); | |
| 1991/0304 | return 0; | |
| 1990/0227 | } | |
| 1990/0427 | if(hdr.type != Rnop){ prerror("not Rnop"); | |
| 1991/0304 | return 0; | |
| 1990/0427 | } | |
| 1990/11211 | if(hdr.tag != ~0){ prerror("tag not ~0"); | |
| 1991/0304 | return 0; | |
| 1990/11211 | } | |
| 1990/0227 | print("session..."); | |
| 1991/0131/sys/src/9/power/boot.c:307,335 – 1991/0304/sys/src/9/power/boot.c:328,395 | ||
| 1990/0227 | n = convS2M(&hdr, buf); | |
| 1990/0427 | if(write(fd, buf, n) != n){ prerror("write session"); | |
| 1991/0304 | return 0; | |
| 1990/0427 | } | |
| 1990/0227 | n = read(fd, buf, sizeof buf); | |
| 1990/0427 | if(n <= 0){ prerror("read session"); | |
| 1991/0304 | return 0; | |
| 1990/0427 | } if(convM2S(buf, &hdr, n) == 0){ prerror("format session"); | |
| 1991/0304 | return 0; | |
| 1990/0427 | } | |
| 1990/11211 | if(hdr.tag != ~0){ prerror("tag not ~0"); | |
| 1990/0427 |
| |
| 1991/0304 | return 0; | |
| 1990/0427 | } | |
| 1990/11211 | if(hdr.type == Rerror){ fprint(2, "boot: error %s\n", hdr.ename); | |
| 1990/0427 |
| |
| 1991/0304 | return 0; | |
| 1990/0227 | } | |
| 1990/11211 | if(hdr.type != Rsession){ prerror("not Rsession"); | |
| 1991/0304 | return 0; } return 1; } void boot(int ask) { int n, f, tries; char *srvname; Dir dir; char dirbuf[DIRLEN]; if(ask){ outin("server", sys, sizeof(sys)); } for(tries = 0; tries < 5; tries++){ fd = -1; if(strncmp(sys, "bit!", 4) == 0) fd = bitdial(srvname = &sys[4]); if(strncmp(sys, "hot!", 4) == 0) fd = hotdial(srvname = &sys[4]); else if(strncmp(sys, "dk!", 3) == 0) fd = dkdial(srvname = &sys[3]); else if(strncmp(sys, "nonet!", 6) == 0) fd = nonetdial(srvname = &sys[6]); else fd = nonetdial(srvname = sys); if(fd >= 0) break; print("can't connect, retrying...\n"); sleep(1000); } if(fd < 0){ print("can't connect\n"); | |
| 1990/11211 | return; } | |
| 1991/0304 | if(!preamble(fd)) return; | |
| 1990/0227 | print("post..."); | |
| 1990/1127 | sprint(buf, "#s/%s", srvname); | |