bug-grub
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Internal ZIP bug, "more" command, dynamic memory


From: OKUJI Yoshinori
Subject: Re: Internal ZIP bug, "more" command, dynamic memory
Date: Thu, 02 Nov 2000 16:38:52 +0900

  Volker, apply this patch and execute the command "ioprobe" with your
ZIP drive. This is a diff for the CVS. I added a wait into the int1
handler so that you can read information about registers. If the wait
is too short, change the definition of WAIT_TICKS in asm.S. This patch
just dumps the contents of registers, but I hope you will get some
hints.

Index: stage2/asm.S
===================================================================
RCS file: /home/cvs/grub/stage2/asm.S,v
retrieving revision 1.50
diff -u -r1.50 asm.S
--- stage2/asm.S        2000/10/29 07:37:48     1.50
+++ stage2/asm.S        2000/11/02 07:35:27
@@ -352,18 +352,56 @@
  */
 int1_handler:
        .code16
-       
-       pushw   %bp
+
+       /* save all general registers (ax, bx, cx, dx, bp, sp, di, si) */
+       pusha
+
+       /* dump registers for debugging */
+       lcall   $0, $ABS(dump_regs)
+               
        movw    %sp, %bp
        pushw   %ds
+
+#if 0
+       /* permit interrupts if the caller permits them */
+       testw   $0x200, 0x14(%bp)
+       jnz     2f
+       sti
+#else
+       /* This might be dangerous! But a wait is necessary... */
+       sti
+       pushw   %ds
        pushw   %ax
-       pushw   %si
        pushw   %dx
+       pushw   %si
+
+       /* Get the current tick */
+       movw    $0x0040, %ax
+       movw    %ax, %ds
+       movw    $0x006c, %si
+       movw    (%si), %ax
+
+       /* arbitrary */
+#define WAIT_TICKS     4
+       addw    $WAIT_TICKS, %ax
        
+1:     movw    (%si), %dx
+       cmpw    %ax, %dx
+       jl      1b
+
+       popw    %si
+       popw    %dx
+       popw    %ax
+       popw    %ds
+
+       cli
+#endif
+       
+2:     
        /* IP */
-       movw    2(%bp), %si
+       movw    0x10(%bp), %si
        /* CS */
-       movw    4(%bp), %ax
+       movw    0x12(%bp), %ax
        movw    %ax, %ds
 
        /* examine the next instruction */
@@ -420,7 +458,6 @@
        /* set %si to the io map */
        movw    $ABS(EXT_C(io_map)), %si
 
-               
 9:     /* check if the io map already has the port */
        lodsw   (%si), %ax
        /* check if this is the end */
@@ -439,15 +476,188 @@
        movw    %dx, -2(%si)
 
 8:     /* restore registers */ 
-       popw    %dx
-       popw    %si
-       popw    %ax
        popw    %ds
-       popw    %bp
+       popa
 
        iret
        
 
+dump_regs:
+       /*
+        *      +-------+
+        * 0x04 | DI    |
+        * 0x06 | SI    |
+        * 0x08 | BP    |
+        * 0x0a | SP    |
+        * 0x0c | BX    |
+        * 0x0e | DX    |
+        * 0x10 | CX    |
+        * 0x12 | AX    |
+        * 0x14 | IP    |
+        * 0x16 | CS    |
+        * 0x18 | FLAGS |
+        *      +-------+
+        */
+
+       /* Note that this will increase SP! */
+       pushw   %bp
+       movw    %sp, %bp
+
+       pushw   %dx
+       pushw   %ax
+       
+       /* set DS to zero */
+       movw    %ds, %dx
+       xorw    %ax, %ax
+       movw    %ax, %ds
+
+       /* zero DI */
+       xorw    %di, %di
+
+       /* AX */
+       movw    $ABS(ax_name), %si
+       movw    0x14(%bp), %ax
+       call    print_reg
+       
+       /* BX */
+       movw    $ABS(bx_name), %si
+       movw    0x0e(%bp), %ax
+       call    print_reg
+       
+       /* CX */
+       movw    $ABS(cx_name), %si
+       movw    0x12(%bp), %ax
+       call    print_reg
+       
+       /* DX */
+       movw    $ABS(dx_name), %si
+       movw    0x10(%bp), %ax
+       call    print_reg
+       
+       /* DI */
+       movw    $ABS(di_name), %si
+       movw    0x06(%bp), %ax
+       call    print_reg
+       
+       /* SI */
+       movw    $ABS(si_name), %si
+       movw    0x08(%bp), %ax
+       call    print_reg
+       
+       /* BP */
+       movw    $ABS(bp_name), %si
+       movw    0x0a(%bp), %ax
+       call    print_reg
+       
+       /* SP */
+       movw    $ABS(sp_name), %si
+       movw    0x0c(%bp), %ax
+       call    print_reg
+       
+       /* IP */
+       movw    $ABS(ip_name), %si
+       movw    0x16(%bp), %ax
+       call    print_reg
+       
+       /* FLAGS */
+       movw    $ABS(flags_name), %si
+       movw    0x1a(%bp), %ax
+       call    print_reg
+       
+       /* CS */
+       movw    $ABS(cs_name), %si
+       movw    0x18(%bp), %ax
+       call    print_reg
+       
+       /* DS */
+       movw    $ABS(ds_name), %si
+       movw    %dx, %ax
+       call    print_reg
+       
+       /* ES */
+       movw    $ABS(es_name), %si
+       movw    %es, %ax
+       call    print_reg
+       
+       /* SS */
+       movw    $ABS(ss_name), %si
+       movw    %ss, %ax
+       call    print_reg
+
+       /* restore DS */
+       movw    %dx, %ds
+
+       popw    %ax
+       popw    %dx
+       popw    %bp
+
+       lret
+
+ax_name:       .string "AX"
+bx_name:       .string "BX"
+cx_name:       .string "CX"
+dx_name:       .string "DX"
+di_name:       .string "DI"
+si_name:       .string "SI"
+bp_name:       .string "BP"
+sp_name:       .string "SP"
+ip_name:       .string "IP"
+flags_name:    .string "FLAGS"
+cs_name:       .string "CS"
+ds_name:       .string "DS"
+es_name:       .string "ES"
+ss_name:       .string "SS"
+
+print_reg:
+       /* SI ... the register name.  AX ... the value. */
+       pushw   %es
+       pushw   %bx
+       
+       movw    %ax, %bx
+       
+       /* set ES to the segment of the video memory */
+       movw    $0xB800, %ax
+       movw    %ax, %es
+
+1:     /* print the name */
+       lodsb
+       orb     %al, %al
+       jz      2f
+       movb    $0x04, %ah
+       stosw
+       jmp     1b
+
+       
+2:     /* print `=' */
+       movw    $0x043d, %ax
+       stosw
+
+       /* print a hexadecimal value */
+       movw    $4, %cx
+       
+3:     rolw    $4, %bx
+       movw    %bx, %ax
+       andw    $0x0f, %ax
+       
+       cmpw    $10, %ax
+       jl      4f
+       addw    $(0x41 - 10), %ax
+       jmp     5f
+4:     addw    $0x30, %ax
+       
+5:     movb    $0x04, %ah
+       stosw
+       loop    3b
+
+       /* print ` ' */
+       movw    $0x0420, %ax
+       stosw
+
+       popw    %bx
+       popw    %es
+       ret
+       
+       
 /*
  * Just set the TF flag. This handler is necessary because any interrupt
  * call clears the flag automatically.
Index: stage2/common.c
===================================================================
RCS file: /home/cvs/grub/stage2/common.c,v
retrieving revision 1.15
diff -u -r1.15 common.c
--- stage2/common.c     2000/10/19 21:10:42     1.15
+++ stage2/common.c     2000/11/02 07:35:27
@@ -268,6 +268,8 @@
   mbi.drives_length = 0;
   mbi.drives_addr = addr;
 
+  /* For debugging, disable this temporarily.  */
+#if 0
   /* For now, GRUB doesn't probe floppies, since it is trivial to map
      floppy drives to BIOS drives.  */
   for (drive = 0x80; drive < 0x88; drive++)
@@ -301,6 +303,7 @@
       info->size = addr - (unsigned long) info;
       mbi.drives_length += info->size;
     }
+#endif /* debug */
 
   /* Get the ROM configuration table by INT 15, AH=C0h.  */
   mbi.config_table = get_rom_config_table ();


Okuji



reply via email to

[Prev in Thread] Current Thread [Next in Thread]