]> git.lizzy.rs Git - plan9front.git/blobdiff - sys/src/boot/pc/pxe.c
9boot: add e820 scan to bootloader
[plan9front.git] / sys / src / boot / pc / pxe.c
index c624e48259159d44cc138246ebc9b6bff37a406d..a950b2579b34b1db74b450db2696927abdc48c09 100644 (file)
@@ -57,6 +57,7 @@ struct Dhcp
        char bootfile[128];
 };
 
+int pxeinit(void);
 int pxecall(int op, void *buf);
 
 static void*
@@ -105,6 +106,23 @@ moveip(IP4 d, IP4 s)
        memmove(d, s, sizeof(d));
 }
 
+void
+unload(void)
+{
+       struct {
+               uchar status[2];
+               uchar junk[10];
+       } buf;
+       static uchar shutdown[] = { 0x05, 0x070, 0x02, 0 };
+       uchar *o;
+
+       for(o = shutdown; *o; o++){ 
+               memset(&buf, 0, sizeof(buf));
+               if(pxecall(*o, &buf))
+                       break;
+       }
+}
+
 static int
 getip(IP4 yip, IP4 sip, IP4 gip, char mac[16])
 {
@@ -153,7 +171,7 @@ udpopen(IP4 sip)
 static int
 udpclose(void)
 {
-       char status[2];
+       uchar status[2];
        puts(status, 0);
        return pxecall(0x31, status);
 }
@@ -268,6 +286,7 @@ close(void *f)
        udpclose();
 }
 
+
 static int
 tftpopen(Tftp *t, char *path, IP4 sip, IP4 dip, IP4 gip)
 {
@@ -311,6 +330,10 @@ start(void *)
        void *f;
        Tftp t;
 
+       if(pxeinit()){
+               print("pxe init\r\n");
+               halt();
+       }
        if(getip(yip, sip, gip, mac)){
                print("bad dhcp\r\n");
                halt();