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