Hello,

I won't annoy you no longer on this subject...


This is my last patch to mbr.S.

The new code will print an error message "Corrupted MBR" in the case
there are no bootable partitions and will block.

In case there are many bootable partitions it will print a warning
message "!Corrupted MBR" (with initial '!') and will try to boot the
first bootable one.

If there is only one bootable partition then boot it directly without
warnings.

I've tested it and it works correcly.



Best regards,
Giuseppe
? diff
? mbr
Index: mbr.S
===================================================================
RCS file: /cvs/src/sys/arch/i386/stand/mbr/mbr.S,v
retrieving revision 1.21
diff -u -r1.21 mbr.S
--- mbr.S       25 Jun 2007 14:10:17 -0000      1.21
+++ mbr.S       21 Feb 2010 11:48:00 -0000
@@ -3,6 +3,7 @@
 /*
  * Copyright (c) 1997 Michael Shalayeff and Tobias Weingartner
  * Copyright (c) 2003 Tom Cosgrove <[email protected]>
+ * Copyright (c) 2010 Giuseppe Magnotta <[email protected]>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -172,7 +173,7 @@
        /* Initialize the serial port to 9600 baud, 8N1.
         */
        xorw    %ax, %ax
-       movb    $0xe3, %ax
+       movw    $0xe3, %ax
        movw    $SERIAL, %dx
        int     $0x14
 #endif
@@ -223,13 +224,29 @@
        movb    $0x80, %dl
 
 drive_ok:
-       /* Find the first active partition.
-        * Note: this should be the only active partition.  We currently
-        * don't check for that.
-        */
+       /* Find first and check for only active partition. */
        movw    $pt, %si
 
        movw    $NDOSPART, %cx
+       xorw    %ax, %ax
+       xorw    %bx, %bx
+
+test_pt:
+       movb    (%si), %al
+       addw    %ax, %bx
+       addw    $PARTSZ, %si
+       loop    test_pt
+
+       cmpw    $0x0, %bx
+       je      no_part
+
+       cmpw    $DOSACTIVE, %bx
+       jne     more_part
+
+pre_find:
+       movw    $pt, %si
+       movw    $NDOSPART, %cx
+
 find_active:
        DBGMSG(CHAR_L)
        movb    (%si), %al
@@ -240,9 +257,12 @@
        addw    $PARTSZ, %si
        loop    find_active
 
+       jmp     stay_stopped
+
        /* No bootable partition */
 no_part:
        movw    $enoboot, %si
+       incw    %si
 
 err_stop:
        call    Lmessage
@@ -253,6 +273,13 @@
        /* Just to make sure */
        jmp     stay_stopped
 
+more_part:
+       movw    $enoboot, %si
+
+       call    Lmessage
+
+       jmp     pre_find
+
 found:
        /*
         * Found bootable partition
@@ -533,7 +560,7 @@
 efdmbr:        .asciz          "MBR on floppy or old BIOS\r\n"
 eread: .asciz          "\r\nRead error\r\n"
 enoos: .asciz          "No O/S\r\n"
-enoboot: .ascii                "No active partition"   /* runs into crlf... */
+enoboot: .ascii                "!Corrupted MBR" /* runs into crlf... */
 crlf:  .asciz          "\r\n"
 
 endofcode:

Reply via email to