]> git.lizzy.rs Git - plan9front.git/blobdiff - sys/src/boot/pc/sub.c
9boot: replace strrchr() call with a loop and strchr() for ignoring bang path prefixes
[plan9front.git] / sys / src / boot / pc / sub.c
index 8140508dc57a5260153ceca9ac90eb864fb7d962..470d31c39ed7e1a3f65db813e53c1573f0caa521 100644 (file)
@@ -66,17 +66,6 @@ strchr(char *s, int c)
        return 0;
 }
 
-char*
-strrchr(char *s, int c)
-{
-       char *r = 0;
-
-       while(s = strchr(s, c))
-               r = s++;
-
-       return r;
-}
-
 void
 print(char *s)
 {
@@ -264,7 +253,7 @@ Loop:
                print("no bootfile\r\n");
                goto Loop;
        }
-       if(p = strrchr(kern, '!'))
+       while(p = strchr(kern, '!'))
                kern = p+1;
 
        return kern;
@@ -340,27 +329,31 @@ e820conf(void)
        ulong bx;
        char *s;
 
-       memset(&e, 0, sizeof(e));
-       if((bx = e820(0, &e)) == 0)
-               return;
-
+       bx=0;
        s = confend;
-       memmove(confend, "e820=", 5);
-       confend += 5;
 
        do{
-               if(e.typ == 1 && (e.ext & 1) == 0 && e.len){
+               bx = e820(bx, &e);
+               if(e.typ == 1 && e.len != 0 && (e.ext & 3) == 1){
+                       if(confend == s){
+                               /* single entry <= 1MB is useless */
+                               if(bx == 0 && e.len <= 0x100000)
+                                       break;
+                               memmove(confend, "e820=", 5);
+                               confend += 5;
+                       }
                        v = e.base;
                        addconfx("", 8, v>>32);
                        addconfx("", 8, v&0xffffffff);
-                       v = e.base + e.len;
+                       v += e.len;
                        addconfx(" ", 8, v>>32);
                        addconfx("", 8, v&0xffffffff);
                        *confend++ = ' ';
                }
+       } while(bx);
 
-               memset(&e, 0, sizeof(e));
-       } while(bx = e820(bx, &e));
+       if(confend == s)
+               return;
 
        *confend = 0;
        print(s); print(crnl);