]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
Merge mainline into keylayouts
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Tue, 31 Aug 2010 12:12:34 +0000 (14:12 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Tue, 31 Aug 2010 12:12:34 +0000 (14:12 +0200)
1  2 
Makefile.util.def
grub-core/Makefile.am
grub-core/Makefile.core.def
grub-core/bus/usb/ohci.c
grub-core/bus/usb/uhci.c
grub-core/bus/usb/usbtrans.c
grub-core/kern/i386/pc/startup.S

Simple merge
Simple merge
index 992f4dfc99c5a91caec9961584d32ef9d8d727d0,353b9d123b65695401793e9fc43d7dc7bdb086af..c0a796ee0b90dde77963a6f5201411885701e3f4
@@@ -133,19 -134,9 +134,10 @@@ kernel = 
    mips_yeeloong = kern/mips/dl.c;
    mips_yeeloong = kern/mips/init.c;
    mips_yeeloong = kern/mips/yeeloong/init.c;
-   mips_yeeloong = lib/arg.c;
    mips_yeeloong = term/at_keyboard.c;
-   mips_yeeloong = term/gfxterm.c;
    mips_yeeloong = term/serial.c;
-   mips_yeeloong = video/bitmap.c;
-   mips_yeeloong = video/bitmap_scale.c;
-   mips_yeeloong = video/fb/fbblit.c;
-   mips_yeeloong = video/fb/fbfill.c;
-   mips_yeeloong = video/fb/fbutil.c;
-   mips_yeeloong = video/fb/video_fb.c;
    mips_yeeloong = video/sm712.c;
-   mips_yeeloong = video/video.c;
 +  mips_yeeloong = commands/keylayouts.c;
  
    powerpc_ieee1275 = kern/ieee1275/init.c;
    powerpc_ieee1275 = kern/powerpc/cache.S;
index e3cd490ac518a6ce0f40464852f313fbfeb95f92,587a364206af38b0155e8798af09a8b6da0d9e9e..7c618a6143e87217e963b0696d66f3c4737ac138
@@@ -780,12 -781,13 +780,14 @@@ grub_ohci_setup_transfer (grub_usb_cont
          }
  
        /* Chain TDs */
-       cdata->td_current_virt->link_td = (grub_uint32_t) td_next_virt;
-       cdata->td_current_virt->next_td
-       = grub_cpu_to_le32 (grub_ohci_td_virt2phys (o, td_next_virt));
-       td_next_virt->prev_td_phys
-       = grub_ohci_td_virt2phys (o, cdata->td_current_virt);
 -      td_current_virt->link_td = td_next_virt;
 -      td_current_virt->next_td = grub_cpu_to_le32 (
++
++      cdata->td_current_virt->link_td = td_next_virt;
++      cdata->td_current_virt->next_td = grub_cpu_to_le32 (
+                                    grub_ohci_td_virt2phys (o,
+                                      td_next_virt) );
+       td_next_virt->prev_td_phys = grub_ohci_td_virt2phys (o,
 -                                td_current_virt);
 -      td_current_virt = td_next_virt;
++                                cdata->td_current_virt);
 +      cdata->td_current_virt = td_next_virt;
      }
  
    grub_dprintf ("ohci", "Tail TD (not processed) = %p\n",
index b719051d624fa8002c235e21d6afef66661c6fd6,1fe86f5d4174b3408bbba6e84095877794861793..755ec70f7c1e0537a09a7303abb4fc7ebdde35e8
@@@ -261,13 -245,13 +261,13 @@@ grub_uhci_pci_iter (grub_pci_device_t d
      u->framelist[i] = fp;
    /* Program the framelist address into the UHCI controller.  */
    grub_uhci_writereg32 (u, GRUB_UHCI_REG_FLBASEADD,
-                       (grub_uint32_t) u->framelist);
+                       (grub_uint32_t) (grub_addr_t) u->framelist);
  
    /* Make the Queue Heads point to each other.  */
 -  for (i = 0; i < 256; i++)
 +  for (i = 0; i < N_QH; i++)
      {
        /* Point to the next QH.  */
-       u->qh[i].linkptr = (grub_uint32_t) (&u->qh[i + 1]) & (~15);
+       u->qh[i].linkptr = (grub_uint32_t) (grub_addr_t) (&u->qh[i + 1]) & (~15);
  
        /* This is a QH.  */
        u->qh[i].linkptr |= GRUB_UHCI_LINK_QUEUE_HEAD;
@@@ -510,12 -480,12 +510,12 @@@ grub_uhci_setup_transfer (grub_usb_cont
          return GRUB_USB_ERR_INTERNAL;
        }
  
 -      if (! td_first)
 -      td_first = td;
 +      if (! cdata->td_first)
 +      cdata->td_first = td;
        else
        {
-         td_prev->linkptr2 = (grub_uint32_t) td;
-         td_prev->linkptr = (grub_uint32_t) td;
+         td_prev->linkptr2 = (grub_uint32_t) (grub_addr_t) td;
+         td_prev->linkptr = (grub_uint32_t) (grub_addr_t) td;
          td_prev->linkptr |= 4;
        }
        td_prev = td;
  
    /* Link it into the queue and terminate.  Now the transaction can
       take place.  */
-   cdata->qh->elinkptr = (grub_uint32_t) cdata->td_first;
 -  qh->elinkptr = (grub_uint32_t) (grub_addr_t) td_first;
++  cdata->qh->elinkptr = (grub_uint32_t) (grub_addr_t) cdata->td_first;
  
    grub_dprintf ("uhci", "initiate transaction\n");
  
index fe55114c764c28c15ffb087a0901bb02f978a55f,13f5c28edb49ee1580dcfc94e4c9aa2c0ba1824d..6b9b1a5b9da8f075d8ede5fcbcad3357c15a281e
@@@ -208,9 -178,9 +208,10 @@@ grub_usb_bulk_setup_readwrite (grub_usb
    grub_uint32_t data_addr;
    struct grub_pci_dma_chunk *data_chunk;
    grub_size_t size = size0;
 +  int toggle = dev->toggle[endpoint];
  
-   grub_dprintf ("usb", "bulk: size=0x%02x type=%d\n", size, type);
+   grub_dprintf ("usb", "bulk: size=0x%02lx type=%d\n", (unsigned long) size,
+               type);
  
    /* FIXME: avoid allocation any kind of buffer in a first place.  */
    data_chunk = grub_memalign_dma32 (128, size);
index 58fb2187350110e5cbd39c396b71fd74f71cf33a,b5e9a9b85d8e28823a2dc3afcd1cbef6c58dda0d..d22600c7a4a074b4f957726c6cdf22b2cc506fd9
@@@ -778,968 -574,155 +574,106 @@@ FUNCTION(grub_console_putchar
        ret
  
  
- /*
-  *   int grub_biosdisk_get_diskinfo_standard (int drive,
-  *                                            unsigned long *cylinders,
-  *                                            unsigned long *heads,
-  *                                            unsigned long *sectors)
-  *
-  *   Return the geometry of DRIVE in CYLINDERS, HEADS and SECTORS. If an
-  *   error occurs, then return non-zero, otherwise zero.
-  */
- FUNCTION(grub_biosdisk_get_diskinfo_standard)
-       pushl   %ebp
-       pushl   %ebx
-       pushl   %edi
-       /* push CYLINDERS */
-       pushl   %edx
-       /* push HEADS */
-       pushl   %ecx
-       /* SECTORS is on the stack */
-       /* drive */
-       movb    %al, %dl
-       /* enter real mode */
-       call    prot_to_real
-       .code16
-       movb    $0x8, %ah
-       int     $0x13           /* do the operation */
-       jc      noclean2
-       /* Clean return value if carry isn't set to workaround
-       some buggy BIOSes.  */
-       xor     %ax, %ax
- noclean2:
-       /* check if successful */
-       testb   %ah, %ah
-       jnz     1f
-       /* bogus BIOSes may not return an error number */
-       testb   $0x3f, %cl      /* 0 sectors means no disk */
-       jnz     1f              /* if non-zero, then succeed */
-       /* XXX 0x60 is one of the unused error numbers */
-       movb    $0x60, %ah
- 1:
-       movb    %ah, %bl        /* save return value in %bl */
-       /* back to protected mode */
-       DATA32  call    real_to_prot
-       .code32
-       /* pop HEADS */
-       popl    %edi
-       movb    %dh, %al
-       incl    %eax    /* the number of heads is counted from zero */
-       movl    %eax, (%edi)
-       /* pop CYLINDERS */
-       popl    %edi
-       movb    %ch, %al
-       movb    %cl, %ah
-       shrb    $6, %ah /* the number of cylinders is counted from zero */
-       incl    %eax
-       movl    %eax, (%edi)
-       /* SECTORS */
-       movl    0x10(%esp), %edi
-       andb    $0x3f, %cl
-       movzbl  %cl, %eax
-       movl    %eax, (%edi)
-       xorl    %eax, %eax
-       movb    %bl, %al        /* return value in %eax */
-       popl    %edi
-       popl    %ebx
-       popl    %ebp
-       ret     $4
- /*
-  * int grub_biosdisk_get_num_floppies (void)
-  */
- FUNCTION(grub_biosdisk_get_num_floppies)
-       pushl   %ebp
-       xorl    %edx, %edx
-       call    prot_to_real
-       .code16
-       /* reset the disk system first */
-       int     $0x13
- 1:
-       stc
-       /* call GET DISK TYPE */
-       movb    $0x15, %ah
-       int     $0x13
-       jc      2f
-       /* check if this drive exists */
-       testb   $0x3, %ah
-       jz      2f
-       incb    %dl
-       cmpb    $2, %dl
-       jne     1b
- 2:
-       DATA32  call    real_to_prot
-       .code32
-       movl    %edx, %eax
-       popl    %ebp
-       ret
++LOCAL(bypass_table):
++      .word 0x0100 | '\e',0x0f00 | '\t', 0x0e00 | '\b', 0x1c00 | '\r'
++      .word 0x1c00 | '\n'
++LOCAL(bypass_table_end):
 +
  /*
-  *
-  * grub_get_memsize(i) :  return the memory size in KB. i == 0 for conventional
-  *            memory, i == 1 for extended memory
-  *    BIOS call "INT 12H" to get conventional memory size
-  *    BIOS call "INT 15H, AH=88H" to get extended memory size
-  *            Both have the return value in AX.
-  *
+  * int grub_console_getkey (void)
++ *    if there is a character pending, return it; otherwise return -1
++ * BIOS call "INT 16H Function 01H" to check whether a character is pending
++ *    Call with       %ah = 0x1
++ *    Return:
++ *            If key waiting to be input:
++ *                    %ah = keyboard scan code
++ *                    %al = ASCII character
++ *                    Zero flag = clear
++ *            else
++ *                    Zero flag = set
+  * BIOS call "INT 16H Function 00H" to read character from keyboard
+  *    Call with       %ah = 0x0
+  *    Return:         %ah = keyboard scan code
+  *                    %al = ASCII character
   */
  
- FUNCTION(grub_get_memsize)
 -/* this table is used in translate_keycode below */
 -LOCAL (translation_table):
 -      .word   GRUB_CONSOLE_KEY_LEFT, GRUB_TERM_LEFT
 -      .word   GRUB_CONSOLE_KEY_RIGHT, GRUB_TERM_RIGHT
 -      .word   GRUB_CONSOLE_KEY_UP, GRUB_TERM_UP
 -      .word   GRUB_CONSOLE_KEY_DOWN, GRUB_TERM_DOWN
 -      .word   GRUB_CONSOLE_KEY_HOME, GRUB_TERM_HOME
 -      .word   GRUB_CONSOLE_KEY_END, GRUB_TERM_END
 -      .word   GRUB_CONSOLE_KEY_DC, GRUB_TERM_DC
 -      .word   GRUB_CONSOLE_KEY_BACKSPACE, GRUB_TERM_BACKSPACE
 -      .word   GRUB_CONSOLE_KEY_PPAGE, GRUB_TERM_PPAGE
 -      .word   GRUB_CONSOLE_KEY_NPAGE, GRUB_TERM_NPAGE
 -      .word   0
 -
 -/*
 - * translate_keycode translates the key code %dx to an ascii code.
 - */
 -      .code16
 -
 -translate_keycode:
 -      pushw   %bx
 -      pushw   %si
 -
 -#ifdef __APPLE__
 -      movw    $(ABS(LOCAL (translation_table)) - 0x10000), %si
 -#else
 -      movw    $ABS(LOCAL (translation_table)), %si
 -#endif
 -
 -1:    lodsw
 -      /* check if this is the end */
 -      testw   %ax, %ax
 -      jz      2f
 -      /* load the ascii code into %ax */
 -      movw    %ax, %bx
 -      lodsw
 -      /* check if this matches the key code */
 -      cmpw    %bx, %dx
 -      jne     1b
 -      /* translate %dx, if successful */
 -      movw    %ax, %dx
 -
 -2:    popw    %si
 -      popw    %bx
 -      ret
 -
 -      .code32
 -
+ FUNCTION(grub_console_getkey)
        pushl   %ebp
  
-       movl    %eax, %edx
-       call    prot_to_real    /* enter real mode */
+       call    prot_to_real
        .code16
  
-       testl   %edx, %edx
-       jnz     xext
-       int     $0x12
-       jmp     xdone
- xext:
-       movb    $0x88, %ah
-       int     $0x15
- xdone:
-       movw    %ax, %dx
-       DATA32  call    real_to_prot
-       .code32
-       movw    %dx, %ax
-       popl    %ebp
-       ret
- /*
-  *
-  * grub_get_eisa_mmap() :  return packed EISA memory map, lower 16 bits is
-  *            memory between 1M and 16M in 1K parts, upper 16 bits is
-  *            memory above 16M in 64K parts.  If error, return zero.
-  *    BIOS call "INT 15H, AH=E801H" to get EISA memory map,
-  *            AX = memory between 1M and 16M in 1K parts.
-  *            BX = memory above 16M in 64K parts.
-  *
-  */
- FUNCTION(grub_get_eisa_mmap)
-       pushl   %ebp
-       pushl   %ebx
-       call    prot_to_real    /* enter real mode */
-       .code16
-       movw    $0xe801, %ax
-       int     $0x15
-       shll    $16, %ebx
-       movw    %ax, %bx
-       DATA32  call    real_to_prot
-       .code32
-       cmpb    $0x86, %bh
-       je      xnoteisa
-       movl    %ebx, %eax
- xnoteisa:
-       popl    %ebx
-       popl    %ebp
-       ret
- /*
-  *
-  * grub_get_mmap_entry(addr, cont) : address and old continuation value (zero to
-  *            start), for the Query System Address Map BIOS call.
-  *
-  *  Sets the first 4-byte int value of "addr" to the size returned by
-  *  the call.  If the call fails, sets it to zero.
-  *
-  *    Returns:  new (non-zero) continuation value, 0 if done.
-  */
- FUNCTION(grub_get_mmap_entry)
-       pushl   %ebp
-       pushl   %ebx
-       pushl   %edi
-       pushl   %esi
-       /* push ADDR */
-       pushl   %eax
-       /* place address (+4) in ES:DI */
-       addl    $4, %eax
-       movl    %eax, %edi
-       andl    $0xf, %edi
-       shrl    $4, %eax
-       movl    %eax, %esi
-       /* set continuation value */
-       movl    %edx, %ebx
-       /* set default maximum buffer size */
-       movl    $0x14, %ecx
-       /* set EDX to 'SMAP' */
-       movl    $0x534d4150, %edx
-       call    prot_to_real    /* enter real mode */
-       .code16
-       movw    %si, %es
-       movl    $0xe820, %eax
-       int     $0x15
-       DATA32  jc      xnosmap
-       cmpl    $0x534d4150, %eax
-       jne     xnosmap
-       cmpl    $0x14, %ecx
-       jl      xnosmap
-       cmpl    $0x400, %ecx
-       jg      xnosmap
-       jmp     xsmap
- xnosmap:
-       xorl    %ecx, %ecx
- /*    Apple's cc jumps few bytes before the correct
-       label in this context. Hence nops. */
- #ifdef APPLE_CC
-       nop
-       nop
-       nop
-       nop
-       nop
-       nop
- #endif
- xsmap:
-       DATA32  call    real_to_prot
-       .code32
-       /* write length of buffer (zero if error) into ADDR */
-       popl    %eax
-       movl    %ecx, (%eax)
-       /* set return value to continuation */
-       movl    %ebx, %eax
-       popl    %esi
-       popl    %edi
-       popl    %ebx
-       popl    %ebp
-       ret
- /*
-  * void grub_console_putchar (const struct grub_unicode_glyph *c)
-  *
-  * Put the character C on the console. Because GRUB wants to write a
-  * character with an attribute, this implementation is a bit tricky.
-  * If C is a control character (CR, LF, BEL, BS), use INT 10, AH = 0Eh
-  * (TELETYPE OUTPUT). Otherwise, save the original position, put a space,
-  * save the current position, restore the original position, write the
-  * character and the attribute, and restore the current position.
-  *
-  * The reason why this is so complicated is that there is no easy way to
-  * get the height of the screen, and the TELETYPE OUTPUT BIOS call doesn't
-  * support setting a background attribute.
-  */
- FUNCTION(grub_console_putchar)
-       /* Retrieve the base character.  */
-       movl    0(%edx), %edx
-       pusha
-       movb    EXT_C(grub_console_cur_color), %bl
-       call    prot_to_real
-       .code16
-       movb    %dl, %al
-       xorb    %bh, %bh
-       /* use teletype output if control character */
-       cmpb    $0x7, %al
-       je      1f
-       cmpb    $0x8, %al
-       je      1f
-       cmpb    $0xa, %al
-       je      1f
-       cmpb    $0xd, %al
-       je      1f
-       /* save the character and the attribute on the stack */
-       pushw   %ax
-       pushw   %bx
-       /* get the current position */
-       movb    $0x3, %ah
-       int     $0x10
-       /* check the column with the width */
-       cmpb    $79, %dl
-       jl      2f
-       /* print CR and LF, if next write will exceed the width */
-       movw    $0x0e0d, %ax
-       int     $0x10
-       movb    $0x0a, %al
-       int     $0x10
-       /* get the current position */
-       movb    $0x3, %ah
-       int     $0x10
- 2:
-       /* restore the character and the attribute */
-       popw    %bx
-       popw    %ax
-       /* write the character with the attribute */
-       movb    $0x9, %ah
-       movw    $1, %cx
-       int     $0x10
-       /* move the cursor forward */
-       incb    %dl
-       movb    $0x2, %ah
-       int     $0x10
-       jmp     3f
- 1:    movw    $1, %bx
-       movb    $0xe, %ah
-       int     $0x10
- 3:    DATA32  call    real_to_prot
-       .code32
-       popa
-       ret
- LOCAL(bypass_table):
-       .word 0x0100 | '\e',0x0f00 | '\t', 0x0e00 | '\b', 0x1c00 | '\r'
-       .word 0x1c00 | '\n'
- LOCAL(bypass_table_end):
- /*
-  * int grub_console_getkey (void)
-  *    if there is a character pending, return it; otherwise return -1
-  * BIOS call "INT 16H Function 01H" to check whether a character is pending
-  *    Call with       %ah = 0x1
-  *    Return:
-  *            If key waiting to be input:
-  *                    %ah = keyboard scan code
-  *                    %al = ASCII character
-  *                    Zero flag = clear
-  *            else
-  *                    Zero flag = set
-  * BIOS call "INT 16H Function 00H" to read character from keyboard
-  *    Call with       %ah = 0x0
-  *    Return:         %ah = keyboard scan code
-  *                    %al = ASCII character
-  */
- FUNCTION(grub_console_getkey)
-       pushl   %ebp
-       call    prot_to_real
-       .code16
-       /*
-        * Due to a bug in apple's bootcamp implementation, INT 16/AH = 0 would
-        * cause the machine to hang at the second keystroke. However, we can
-        * work around this problem by ensuring the presence of keystroke with
-        * INT 16/AH = 1 before calling INT 16/AH = 0.
-        */
+       /*
+        * Due to a bug in apple's bootcamp implementation, INT 16/AH = 0 would
+        * cause the machine to hang at the second keystroke. However, we can
+        * work around this problem by ensuring the presence of keystroke with
+        * INT 16/AH = 1 before calling INT 16/AH = 0.
+        */
  
 -1:
        movb    $1, %ah
-       int     $0x16
-       jz      notpending
-       movb    $0, %ah
-       int     $0x16
-       xorl    %edx, %edx
-       movw    %ax, %dx                /* real_to_prot uses %eax */
-       DATA32  call    real_to_prot
-       .code32
-       movl    $0xff, %eax
-       testl   %eax, %edx
-       jz      1f
-       andl    %edx, %eax
-       cmp     %eax, 0x20
-       ja      2f
-       movl    %edx, %eax
-       leal    LOCAL(bypass_table), %esi
-       movl    $((LOCAL(bypass_table_end) - LOCAL(bypass_table)) / 2), %ecx
-       repne cmpsw
-       jz      3f
-       addl    $('a' - 1 | GRUB_TERM_CTRL), %eax
-       jmp     2f
- 3:
-       andl    $0xff, %eax
-       jmp 2f
- 1:    movl    %edx, %eax
-       shrl    $8, %eax
-       orl     $GRUB_TERM_EXTENDED, %eax
- 2:    
-       popl    %ebp
-       ret
- notpending:   
-       .code16
-       DATA32  call    real_to_prot
-       .code32
- #if GRUB_TERM_NO_KEY != 0
- #error Fix this asm code
- #endif
-       jmp 2b
- /*
-  * grub_uint16_t grub_console_getxy (void)
-  * BIOS call "INT 10H Function 03h" to get cursor position
-  *    Call with       %ah = 0x03
-  *                    %bh = page
-  *      Returns         %ch = starting scan line
-  *                      %cl = ending scan line
-  *                      %dh = row (0 is top)
-  *                      %dl = column (0 is left)
-  */
- FUNCTION(grub_console_getxy)
-       pushl   %ebp
-       pushl   %ebx                    /* save EBX */
-       call    prot_to_real
-       .code16
-         xorb  %bh, %bh                /* set page to 0 */
-       movb    $0x3, %ah
-       int     $0x10                   /* get cursor position */
-       DATA32  call    real_to_prot
-       .code32
-       movb    %dl, %ah
-       movb    %dh, %al
-       popl    %ebx
-       popl    %ebp
-       ret
- /*
-  * void grub_console_gotoxy(grub_uint8_t x, grub_uint8_t y)
-  * BIOS call "INT 10H Function 02h" to set cursor position
-  *    Call with       %ah = 0x02
-  *                    %bh = page
-  *                      %dh = row (0 is top)
-  *                      %dl = column (0 is left)
-  */
- FUNCTION(grub_console_gotoxy)
-       pushl   %ebp
-       pushl   %ebx                    /* save EBX */
-       movb    %cl, %dh        /* %dh = y */
-       /* %dl = x */
-       call    prot_to_real
-       .code16
-         xorb  %bh, %bh                /* set page to 0 */
-       movb    $0x2, %ah
-       int     $0x10                   /* set cursor position */
-       DATA32  call    real_to_prot
-       .code32
-       popl    %ebx
-       popl    %ebp
-       ret
- /*
-  * void grub_console_cls (void)
-  * BIOS call "INT 10H Function 09h" to write character and attribute
-  *    Call with       %ah = 0x09
-  *                      %al = (character)
-  *                      %bh = (page number)
-  *                      %bl = (attribute)
-  *                      %cx = (number of times)
-  */
- FUNCTION(grub_console_cls)
-       pushl   %ebp
-       pushl   %ebx                    /* save EBX */
-       call    prot_to_real
-       .code16
-       /* move the cursor to the beginning */
-       movb    $0x02, %ah
-       xorb    %bh, %bh
-       xorw    %dx, %dx
-       int     $0x10
-       /* write spaces to the entire screen */
-       movw    $0x0920, %ax
-       movw    $0x07, %bx
-       movw    $(80 * 25), %cx
-         int   $0x10
-       /* move back the cursor */
-       movb    $0x02, %ah
-       int     $0x10
-       DATA32  call    real_to_prot
-       .code32
-       popl    %ebx
-       popl    %ebp
-       ret
- /*
-  * void grub_console_setcursor (int on)
-  * BIOS call "INT 10H Function 01h" to set cursor type
-  *      Call with       %ah = 0x01
-  *                      %ch = cursor starting scanline
-  *                      %cl = cursor ending scanline
-  */
- console_cursor_state:
-       .byte   1
- console_cursor_shape:
-       .word   0
- FUNCTION(grub_console_setcursor)
-       pushl   %ebp
-       pushl   %ebx
-       /* push ON */
-       pushl   %edx
-       /* check if the standard cursor shape has already been saved */
-       movw    console_cursor_shape, %ax
-       testw   %ax, %ax
-       jne     1f
-       call    prot_to_real
-       .code16
-       movb    $0x03, %ah
-       xorb    %bh, %bh
-       int     $0x10
-       DATA32  call    real_to_prot
-       .code32
-       movw    %cx, console_cursor_shape
- 1:
-       /* set %cx to the designated cursor shape */
-       movw    $0x2000, %cx
-       popl    %eax
-       testl   %eax, %eax
-       jz      2f
-       movw    console_cursor_shape, %cx
- 2:
-       call    prot_to_real
-       .code16
-       movb    $0x1, %ah
-       int     $0x10
-       DATA32  call    real_to_prot
-       .code32
-       popl    %ebx
-       popl    %ebp
-       ret
- /*
-  * grub_get_rtc()
-  *    return the real time in ticks, of which there are about
-  *    18-20 per second
-  */
- FUNCTION(grub_get_rtc)
-       pushl   %ebp
-       call    prot_to_real    /* enter real mode */
-       .code16
-       /* %ax is already zero */
-         int   $0x1a
-       DATA32  call    real_to_prot
-       .code32
-       movl    %ecx, %eax
-       shll    $16, %eax
-       movw    %dx, %ax
-       popl    %ebp
-       ret
- /*
-  * unsigned char grub_vga_set_mode (unsigned char mode)
-  */
- FUNCTION(grub_vga_set_mode)
-       pushl   %ebp
-       pushl   %ebx
-       movl    %eax, %ecx
-       call    prot_to_real
-       .code16
-       /* get current mode */
-       xorw    %bx, %bx
-       movb    $0x0f, %ah
-       int     $0x10
-       movb    %al, %dl
-       /* set the new mode */
-       movb    %cl, %al
-       xorb    %ah, %ah
-       int     $0x10
-       DATA32  call    real_to_prot
-       .code32
-       movb    %dl, %al
-       popl    %ebx
-       popl    %ebp
-       ret
- /*
-  * grub_vbe_bios_status_t grub_vbe_get_controller_info (struct grub_vbe_info_block *controller_info)
-  *
-  * Register allocations for parameters:
-  * %eax               *controller_info
-  */
- FUNCTION(grub_vbe_bios_get_controller_info)
-       pushl   %ebp
-       pushl   %edi
-       pushl   %edx
-       movw    %ax, %di        /* Store *controller_info to %edx:%di.  */
-       xorw    %ax, %ax
-       shrl    $4, %eax
-       mov     %eax, %edx      /* prot_to_real destroys %eax.  */
-       call    prot_to_real
-       .code16
-       pushw   %es
-       movw    %dx, %es        /* *controller_info is now on %es:%di.  */
-       movw    $0x4f00, %ax
-       int     $0x10
-       movw    %ax, %dx        /* real_to_prot destroys %eax.  */
-       popw    %es
-       DATA32 call     real_to_prot
-       .code32
-       movl    %edx, %eax
-       andl    $0x0FFFF, %eax  /* Return value in %eax.  */
-       pop     %edx
-       popl    %edi
-       popl    %ebp
-       ret
- /*
-  * grub_vbe_status_t grub_vbe_bios_get_mode_info (grub_uint32_t mode,
-  *                                              struct grub_vbe_mode_info_block *mode_info)
-  *
-  * Register allocations for parameters:
-  * %eax               mode
-  * %edx               *mode_info
-  */
- FUNCTION(grub_vbe_bios_get_mode_info)
-       pushl   %ebp
-       pushl   %edi
-       movl    %eax, %ecx      /* Store mode number to %ecx.  */
-       movw    %dx, %di        /* Store *mode_info to %edx:%di.  */
-       xorw    %dx, %dx
-       shrl    $4, %edx
-       call    prot_to_real
-       .code16
-       pushw   %es
-       movw    %dx, %es        /* *mode_info is now on %es:%di.  */
-       movw    $0x4f01, %ax
-       int     $0x10
-       movw    %ax, %dx        /* real_to_prot destroys %eax.  */
-       popw    %es
-       DATA32 call     real_to_prot
-       .code32
-       movl    %edx, %eax
-       andl    $0x0FFFF, %eax  /* Return value in %eax.  */
-       popl    %edi
-       popl    %ebp
-       ret
- /*
-  * grub_vbe_status_t grub_vbe_bios_set_mode (grub_uint32_t mode,
-  *                                         struct grub_vbe_crtc_info_block *crtc_info)
-  *
-  * Register allocations for parameters:
-  * %eax               mode
-  * %edx               *crtc_info
-  */
- FUNCTION(grub_vbe_bios_set_mode)
-       pushl   %ebp
-       pushl   %ebx
-       pushl   %edi
-       movl    %eax, %ebx      /* Store mode in %ebx.  */
-       movw    %dx, %di        /* Store *crtc_info to %edx:%di.  */
-       xorw    %dx, %dx
-       shrl    $4, %edx
-       call    prot_to_real
-       .code16
-       pushw   %es
-       movw    %dx, %es        /* *crtc_info is now on %es:%di.  */
-       movw    $0x4f02, %ax
-       int     $0x10
-       movw    %ax, %dx        /* real_to_prot destroys %eax.  */
-       popw    %es
-       DATA32 call     real_to_prot
-       .code32
-       movw    %dx, %ax
-       andl    $0xFFFF, %eax   /* Return value in %eax.  */
-       popl    %edi
-       popl    %ebx
-       popl    %ebp
-       ret
- /*
-  * grub_vbe_status_t grub_vbe_bios_get_mode (grub_uint32_t *mode)
-  *
-  * Register allocations for parameters:
-  * %eax               *mode
-  */
- FUNCTION(grub_vbe_bios_get_mode)
-       pushl   %ebp
-       pushl   %ebx
-       pushl   %edi
-       pushl   %edx
-       pushl   %eax            /* Push *mode to stack.  */
-       call    prot_to_real
-       .code16
-       movw    $0x4f03, %ax
-       int     $0x10
-       movw    %ax, %dx        /* real_to_prot destroys %eax.  */
-       DATA32 call     real_to_prot
-       .code32
-       popl    %edi            /* Pops *mode from stack to %edi.  */
-       andl    $0xFFFF, %ebx
-       movl    %ebx, (%edi)
-       movw    %dx, %ax
-       andl    $0xFFFF, %eax   /* Return value in %eax.  */
-       popl    %edx
-       popl    %edi
-       popl    %ebx
-       popl    %ebp
-       ret
- /*
-  * grub_vbe_status_t grub_vbe_bios_getset_dac_palette_width (int set, int *dac_mask_size)
-  *
-  * Register allocations for parameters:
-  * %eax               set
-  * %edx               *dac_mask_size
-  */
- FUNCTION(grub_vbe_bios_getset_dac_palette_width)
-       pushl   %ebp
-       pushl   %ebx
-       xorl    %ebx, %ebx
-       /* If we only want to fetch the value, set %bl to 1.  */
-       testl   %eax, %eax
-       jne     1f
-       incb    %bl
- 1:
-       /* Put desired width in %bh.  */
-       movl    (%edx), %eax
-       movb    %al, %bh
-       call    prot_to_real
-       .code16
-       movw    $0x4f08, %ax
-       int     $0x10
-       movw    %ax, %cx        /* real_to_prot destroys %eax.  */
-       DATA32 call     real_to_prot
-       .code32
-       /* Move result back to *dac_mask_size.  */
-       xorl    %eax, %eax
-       movb    %bh, %al
-       movl    %eax, (%edx)
-       /* Return value in %eax.  */
-       movw    %cx, %ax
-       popl    %ebx
-       popl    %ebp
-       ret
- /*
-  * grub_vbe_status_t grub_vbe_bios_set_memory_window (grub_uint32_t window,
-  *                                                  grub_uint32_t position);
-  *
-  * Register allocations for parameters:
-  * %eax               window
-  * %edx               position
-  */
- FUNCTION(grub_vbe_bios_set_memory_window)
-       pushl   %ebp
-       pushl   %ebx
+       int     $0x16
 -      jnz     2f
 -      hlt
 -      jmp     1b
 -
 -2:
++      jz      notpending
  
-       movl    %eax, %ebx
+       movb    $0, %ah
+       int     $0x16
  
-       call    prot_to_real
-       .code16
++      xorl    %edx, %edx
+       movw    %ax, %dx                /* real_to_prot uses %eax */
 -      call    translate_keycode
  
-       movw    $0x4f05, %ax
-       andw    $0x00ff, %bx    /* BL = window, BH = 0, Set memory window.  */
-       int     $0x10
+       DATA32  call    real_to_prot
+       .code32
  
-       movw    %ax, %dx        /* real_to_prot destroys %eax.  */
 -      movw    %dx, %ax
++      movl    $0xff, %eax
++      testl   %eax, %edx
++      jz      1f
  
-       DATA32 call     real_to_prot
-       .code32
 -      popl    %ebp
 -      ret
++      andl    %edx, %eax
++      cmp     %eax, 0x20
++      ja      2f
++      movl    %edx, %eax
++      leal    LOCAL(bypass_table), %esi
++      movl    $((LOCAL(bypass_table_end) - LOCAL(bypass_table)) / 2), %ecx
++      repne cmpsw
++      jz      3f
  
-       movw    %dx, %ax
-       andl    $0xFFFF, %eax   /* Return value in %eax.  */
++      addl    $('a' - 1 | GRUB_TERM_CTRL), %eax
++      jmp     2f
++3:
++      andl    $0xff, %eax
++      jmp 2f
  
-       popl    %ebx
 -/*
 - * int grub_console_checkkey (void)
 - *    if there is a character pending, return it; otherwise return -1
 - * BIOS call "INT 16H Function 01H" to check whether a character is pending
 - *    Call with       %ah = 0x1
 - *    Return:
 - *            If key waiting to be input:
 - *                    %ah = keyboard scan code
 - *                    %al = ASCII character
 - *                    Zero flag = clear
 - *            else
 - *                    Zero flag = set
 - */
 -FUNCTION(grub_console_checkkey)
 -      pushl   %ebp
 -      xorl    %edx, %edx
++1:    movl    %edx, %eax
++      shrl    $8, %eax
++      orl     $GRUB_TERM_EXTENDED, %eax
++2:    
 +      popl    %ebp
 +      ret
  
- /*
-  * grub_vbe_status_t grub_vbe_bios_get_memory_window (grub_uint32_t window,
-  *                                                  grub_uint32_t *position);
-  *
-  * Register allocations for parameters:
-  * %eax               window
-  * %edx               *position
-  */
- FUNCTION(grub_vbe_bios_get_memory_window)
-       pushl   %ebp
-       pushl   %ebx
-       pushl   %edi
-       pushl   %edx            /* Push *position to stack.  */
-       movl    %eax, %ebx      /* Store window in %ebx.  */
-       call    prot_to_real
 -      call    prot_to_real    /* enter real mode */
++notpending:   
        .code16
--
-       movw    $0x4f05, %ax
-       andw    $0x00ff, %bx    /* BL = window.  */
-       orw     $0x0100, %bx    /* BH = 1, Get memory window.  */
-       int     $0x10
 -      movb    $0x1, %ah
 -      int     $0x16
--
-       movw    %ax, %bx        /* real_to_prot destroys %eax.  */
 -      jz      notpending
--
-       DATA32 call     real_to_prot
 -      movw    %ax, %dx
 -      DATA32  jmp     pending
 -
 -notpending:
 -      decl    %edx
 -
 -pending:
+       DATA32  call    real_to_prot
        .code32
 -
 -      movl    %edx, %eax
 -
 -      popl    %ebp
 -      ret
++#if GRUB_TERM_NO_KEY != 0
++#error Fix this asm code
++#endif
++      jmp 2b
  
-       popl    %edi            /* pops *position from stack to %edi.  */
-       andl    $0xFFFF, %edx
-       movl    %edx, (%edi)    /* Return position to caller.  */
-       movw    %bx, %ax
-       andl    $0xFFFF, %eax   /* Return value in %eax.  */
-       popl    %edi
-       popl    %ebx
-       popl    %ebp
-       ret
  
  /*
-  * grub_vbe_status_t grub_vbe_bios_set_scanline_length (grub_uint32_t length)
-  *
-  * Register allocations for parameters:
-  * %eax               length
+  * grub_uint16_t grub_console_getxy (void)
+  * BIOS call "INT 10H Function 03h" to get cursor position
+  *    Call with       %ah = 0x03
+  *                    %bh = page
+  *      Returns         %ch = starting scan line
+  *                      %cl = ending scan line
+  *                      %dh = row (0 is top)
+  *                      %dl = column (0 is left)
   */
- FUNCTION(grub_vbe_bios_set_scanline_length)
-       pushl   %ebp
-       pushl   %ebx
-       pushl   %edx
  
-       movl    %eax, %ecx      /* Store length in %ecx.  */
+ FUNCTION(grub_console_getxy)
+       pushl   %ebp
+       pushl   %ebx                    /* save EBX */
  
        call    prot_to_real
        .code16