]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
intwrap vbe and vga calls
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sun, 4 Apr 2010 12:24:50 +0000 (14:24 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sun, 4 Apr 2010 12:24:50 +0000 (14:24 +0200)
conf/i386-pc.rmk
include/grub/i386/pc/vbe.h
include/grub/i386/pc/vga.h
kern/i386/pc/startup.S
term/i386/pc/vga.c
video/i386/pc/vbe.c

index 84e6f1b1ee03510935f932efc20d684af0edacad..bef17a25b0b58c0b78624a9b4015633fb1650113 100644 (file)
@@ -54,8 +54,8 @@ kernel_img_SOURCES = kern/i386/pc/startup.S \
        kern/env.c \
        term/i386/pc/console.c term/i386/vga_common.c \
        symlist.c
-kernel_img_HEADERS += machine/biosdisk.h machine/vga.h machine/vbe.h \
-       machine/pxe.h i386/pit.h machine/init.h machine/int.h
+kernel_img_HEADERS += machine/biosdisk.h machine/pxe.h i386/pit.h \
+       machine/init.h machine/int.h
 kernel_img_CFLAGS = $(COMMON_CFLAGS)  $(TARGET_IMG_CFLAGS)
 kernel_img_ASFLAGS = $(COMMON_ASFLAGS)
 kernel_img_LDFLAGS = $(COMMON_LDFLAGS) $(TARGET_IMG_LDFLAGS)$(GRUB_KERNEL_MACHINE_LINK_ADDR) $(COMMON_CFLAGS)
index abf246fa1f2c4636712ed048c1127ee045ed10c6..9b05c22998f64d62f0e0ad61501cd0a2c68bf362 100644 (file)
@@ -169,55 +169,39 @@ struct grub_vbe_palette_data
   grub_uint8_t alignment;
 } __attribute__ ((packed));
 
-/* Prototypes for kernel real mode thunks.  */
-
+/* Prototypes for helper functions.  */
 /* Call VESA BIOS 0x4f00 to get VBE Controller Information, return status.  */
-grub_vbe_status_t EXPORT_FUNC(grub_vbe_bios_get_controller_info) (struct grub_vbe_info_block *controller_info);
-
+grub_vbe_status_t 
+grub_vbe_bios_get_controller_info (struct grub_vbe_info_block *controller_info);
 /* Call VESA BIOS 0x4f01 to get VBE Mode Information, return status.  */
-grub_vbe_status_t EXPORT_FUNC(grub_vbe_bios_get_mode_info) (grub_uint32_t mode,
-                                                            struct grub_vbe_mode_info_block *mode_info);
-
-grub_vbe_status_t EXPORT_FUNC(grub_vbe_bios_getset_dac_palette_width) (int set, int *width);
-
-#define grub_vbe_bios_get_dac_palette_width(width)     grub_vbe_bios_getset_dac_palette_width(0, (width))
-#define grub_vbe_bios_set_dac_palette_width(width)     grub_vbe_bios_getset_dac_palette_width(1, (width))
-
-/* Call VESA BIOS 0x4f02 to set video mode, return status.  */
-grub_vbe_status_t EXPORT_FUNC(grub_vbe_bios_set_mode) (grub_uint32_t mode,
-                                                       struct grub_vbe_crtc_info_block *crtc_info);
-
+grub_vbe_status_t 
+grub_vbe_bios_get_mode_info (grub_uint32_t mode,
+                            struct grub_vbe_mode_info_block *mode_info);
 /* Call VESA BIOS 0x4f03 to return current VBE Mode, return status.  */
-grub_vbe_status_t EXPORT_FUNC(grub_vbe_bios_get_mode) (grub_uint32_t *mode);
-
+grub_vbe_status_t 
+grub_vbe_bios_get_mode (grub_uint32_t *mode);
 /* Call VESA BIOS 0x4f05 to set memory window, return status.  */
-grub_vbe_status_t EXPORT_FUNC(grub_vbe_bios_set_memory_window) (grub_uint32_t window,
-                                                                grub_uint32_t position);
-
+grub_vbe_status_t
+grub_vbe_bios_set_memory_window (grub_uint32_t window, grub_uint32_t position);
 /* Call VESA BIOS 0x4f05 to return memory window, return status.  */
-grub_vbe_status_t EXPORT_FUNC(grub_vbe_bios_get_memory_window) (grub_uint32_t window,
-                                                                grub_uint32_t *position);
-
+grub_vbe_status_t
+grub_vbe_bios_get_memory_window (grub_uint32_t window,
+                                grub_uint32_t *position);
 /* Call VESA BIOS 0x4f06 to set scanline length (in bytes), return status.  */
-grub_vbe_status_t EXPORT_FUNC(grub_vbe_bios_set_scanline_length) (grub_uint32_t length);
-
+grub_vbe_status_t 
+grub_vbe_bios_set_scanline_length (grub_uint32_t length);
 /* Call VESA BIOS 0x4f06 to return scanline length (in bytes), return status.  */
-grub_vbe_status_t EXPORT_FUNC(grub_vbe_bios_get_scanline_length) (grub_uint32_t *length);
-
-/* Call VESA BIOS 0x4f07 to set display start, return status.  */
-grub_vbe_status_t EXPORT_FUNC(grub_vbe_bios_set_display_start) (grub_uint32_t x,
-                                                                grub_uint32_t y);
-
+grub_vbe_status_t 
+grub_vbe_bios_get_scanline_length (grub_uint32_t *length);
 /* Call VESA BIOS 0x4f07 to get display start, return status.  */
-grub_vbe_status_t EXPORT_FUNC(grub_vbe_bios_get_display_start) (grub_uint32_t *x,
-                                                                grub_uint32_t *y);
+grub_vbe_status_t 
+grub_vbe_bios_get_display_start (grub_uint32_t *x,
+                                grub_uint32_t *y);
 
-/* Call VESA BIOS 0x4f09 to set palette data, return status.  */
-grub_vbe_status_t EXPORT_FUNC(grub_vbe_bios_set_palette_data) (grub_uint32_t color_count,
-                                                               grub_uint32_t start_index,
-                                                               struct grub_vbe_palette_data *palette_data);
+grub_vbe_status_t grub_vbe_bios_getset_dac_palette_width (int set, int *width);
 
-/* Prototypes for helper functions.  */
+#define grub_vbe_bios_get_dac_palette_width(width)     grub_vbe_bios_getset_dac_palette_width(0, (width))
+#define grub_vbe_bios_set_dac_palette_width(width)     grub_vbe_bios_getset_dac_palette_width(1, (width))
 
 grub_err_t grub_vbe_probe (struct grub_vbe_info_block *info_block);
 grub_err_t grub_vbe_set_video_mode (grub_uint32_t mode,
index 2724f640191916046bb8c9086168a53fa02cd0fc..ecc16902267fb7dbf07788258dbaed649bf53142 100644 (file)
@@ -25,7 +25,4 @@
 /* The VGA (at the beginning of upper memory).  */
 #define GRUB_MEMORY_MACHINE_VGA_ADDR           GRUB_MEMORY_MACHINE_UPPER
 
-/* Set the video mode to MODE and return the previous mode.  */
-unsigned char EXPORT_FUNC(grub_vga_set_mode) (unsigned char mode);
-
 #endif /* ! GRUB_VGA_MACHINE_HEADER */
index a9e819a9f1abe6682b82c8c43dc1112981736e2a..8e4bd13bd0780b921880bd8c9b2e118470cd40a1 100644 (file)
@@ -1434,513 +1434,6 @@ FUNCTION(grub_get_rtc)
        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
-
-       movl    %eax, %ebx
-
-       call    prot_to_real
-       .code16
-
-       movw    $0x4f05, %ax
-       andw    $0x00ff, %bx    /* BL = window, BH = 0, Set memory window.  */
-       int     $0x10
-
-       movw    %ax, %dx        /* real_to_prot destroys %eax.  */
-
-       DATA32 call     real_to_prot
-       .code32
-
-       movw    %dx, %ax
-       andl    $0xFFFF, %eax   /* Return value in %eax.  */
-
-       popl    %ebx
-       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
-       .code16
-
-       movw    $0x4f05, %ax
-       andw    $0x00ff, %bx    /* BL = window.  */
-       orw     $0x0100, %bx    /* BH = 1, Get memory window.  */
-       int     $0x10
-
-       movw    %ax, %bx        /* real_to_prot destroys %eax.  */
-
-       DATA32 call     real_to_prot
-       .code32
-
-       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
- */
-FUNCTION(grub_vbe_bios_set_scanline_length)
-       pushl   %ebp
-       pushl   %ebx
-       pushl   %edx
-
-       movl    %eax, %ecx      /* Store length in %ecx.  */
-
-       call    prot_to_real
-       .code16
-
-       movw    $0x4f06, %ax
-       movw    $0x0002, %bx    /* BL = 2, Set Scan Line in Bytes.  */
-       int     $0x10
-
-       movw    %ax, %dx        /* real_to_prot destroys %eax.  */
-
-       DATA32 call     real_to_prot
-       .code32
-
-       movw    %dx, %ax
-       andl    $0xFFFF, %eax   /* Return value in %eax.  */
-
-       popl    %edx
-       popl    %ebx
-       popl    %ebp
-       ret
-
-/*
- * grub_vbe_status_t grub_vbe_bios_get_scanline_length (grub_uint32_t *length)
- *
- * Register allocations for parameters:
- * %eax                *length
- */
-FUNCTION(grub_vbe_bios_get_scanline_length)
-       pushl   %ebp
-       pushl   %ebx
-       pushl   %edi
-       pushl   %edx            /* Push *length to stack.  */
-
-       call    prot_to_real
-       .code16
-
-       movw    $0x4f06, %ax
-       movw    $0x0001, %bx    /* BL = 1, Get Scan Line Length (in bytes).  */
-       int     $0x10
-
-       movw    %ax, %dx        /* real_to_prot destroys %eax.  */
-
-       DATA32 call     real_to_prot
-       .code32
-
-       popl    %edi            /* Pops *length from stack to %edi.  */
-       andl    $0xFFFF, %ebx
-       movl    %ebx, (%edi)    /* Return length to caller.  */
-
-       movw    %dx, %ax
-       andl    $0xFFFF, %eax   /* Return value in %eax.  */
-
-       popl    %edi
-       popl    %ebx
-       popl    %ebp
-       ret
-
-/*
- * grub_vbe_status_t grub_vbe_bios_set_display_start (grub_uint32_t x,
- *                                                   grub_uint32_t y)
- *
- * Register allocations for parameters:
- * %eax                x
- * %edx                y
- */
-FUNCTION(grub_vbe_bios_set_display_start)
-       pushl   %ebp
-       pushl   %ebx
-
-       movl    %eax, %ecx      /* Store x in %ecx.  */
-
-       call    prot_to_real
-       .code16
-
-       movw    $0x4f07, %ax
-       movw    $0x0080, %bx    /* BL = 80h, Set Display Start
-                                  during Vertical Retrace.  */
-       int     $0x10
-
-       movw    %ax, %dx        /* real_to_prot destroys %eax.  */
-
-       DATA32 call     real_to_prot
-       .code32
-
-       movw    %dx, %ax
-       andl    $0xFFFF, %eax   /* Return value in %eax.  */
-
-       popl    %ebx
-       popl    %ebp
-       ret
-
-/*
- * grub_vbe_status_t grub_vbe_bios_get_display_start (grub_uint32_t *x,
- *                                                   grub_uint32_t *y)
- *
- * Register allocations for parameters:
- * %eax                *x
- * %edx                *y
- */
-FUNCTION(grub_vbe_bios_get_display_start)
-       pushl   %ebp
-       pushl   %ebx
-       pushl   %edi
-       pushl   %eax            /* Push *x to stack.  */
-       pushl   %edx            /* Push *y to stack.  */
-
-       call    prot_to_real
-       .code16
-
-       movw    $0x4f07, %ax
-       movw    $0x0001, %bx    /* BL = 1, Get Display Start.  */
-       int     $0x10
-
-       movw    %ax, %bx        /* real_to_prot destroys %eax.  */
-
-       DATA32 call     real_to_prot
-       .code32
-
-       popl    %edi            /* Pops *y from stack to %edi.  */
-       andl    $0xFFFF, %edx
-       movl    %edx, (%edi)    /* Return y-position to caller.  */
-
-       popl    %edi            /* Pops *x from stack to %edi.  */
-       andl    $0xFFFF, %ecx
-       movl    %ecx, (%edi)    /* Return x-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_palette_data (grub_uint32_t color_count,
- *                                                  grub_uint32_t start_index,
- *                                                  struct grub_vbe_palette_data *palette_data)
- *
- * Register allocations for parameters:
- * %eax                color_count
- * %edx                start_index
- * %ecx                *palette_data
- */
-FUNCTION(grub_vbe_bios_set_palette_data)
-       pushl   %ebp
-       pushl   %ebx
-       pushl   %edi
-
-       movl    %eax, %ebx      /* Store color_count in %ebx.  */
-
-       movw    %cx, %di        /* Store *palette_data to %ecx:%di.  */
-       xorw    %cx, %cx
-       shrl    $4, %ecx
-
-       call    prot_to_real
-       .code16
-
-       pushw   %es
-
-       movw    %cx, %es        /* *palette_data is now on %es:%di.  */
-       movw    %bx, %cx        /* color_count is now on %cx.  */
-
-       movw    $0x4f09, %ax
-       xorw    %bx, %bx        /* BL = 0, Set Palette Data.  */
-       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
-
-
 pxe_rm_entry:
        .long   0
 
index 402b30fe63dc6a79de5ea19a0dbbaca8155b8009..85c516b6a5902878e3b5868b4cc07b25880b6f84 100644 (file)
@@ -19,6 +19,7 @@
 // TODO: Deprecated and broken. Needs to be converted to Video Driver!
 
 #include <grub/machine/vga.h>
+#include <grub/machine/int.h>
 #include <grub/machine/console.h>
 #include <grub/cpu/io.h>
 #include <grub/term.h>
@@ -82,6 +83,25 @@ static grub_font_t font = 0;
 #define INPUT_STATUS1_REGISTER 0x3DA
 #define INPUT_STATUS1_VERTR_BIT 0x08
 
+static unsigned char 
+grub_vga_set_mode (unsigned char mode)
+{
+  struct grub_bios_int_registers regs;
+  unsigned char ret;
+  /* get current mode */
+  regs.eax = 0x0f00;
+  regs.ebx = 0;
+  regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+  grub_bios_interrupt (0x10, &regs);
+
+  ret = regs.eax & 0xff;
+  regs.eax = mode;
+  regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+  grub_bios_interrupt (0x10, &regs);
+
+  return ret;
+}
+
 static inline void
 wait_vretrace (void)
 {
index 72b8f183184cbaea233cd8267595e60ee5fd2a6a..45ba862279e1e7e831addfcbcf5e0441259e89b6 100644 (file)
@@ -28,6 +28,7 @@
 #include <grub/misc.h>
 #include <grub/mm.h>
 #include <grub/video.h>
+#include <grub/machine/int.h>
 
 static int vbe_detected = -1;
 
@@ -71,6 +72,200 @@ real2pm (grub_vbe_farptr_t ptr)
                    + ((unsigned long) ptr & 0x0000FFFF));
 }
 
+/* Call VESA BIOS 0x4f09 to set palette data, return status.  */
+static grub_vbe_status_t 
+grub_vbe_bios_set_palette_data (grub_uint32_t color_count,
+                               grub_uint32_t start_index,
+                               struct grub_vbe_palette_data *palette_data)
+{
+  struct grub_bios_int_registers regs;
+  regs.eax = 0x4f09;
+  regs.ebx = 0;
+  regs.ecx = color_count;
+  regs.edx = start_index;
+  regs.es = (((grub_addr_t) palette_data) & 0xffff0000) >> 4;
+  regs.edi = ((grub_addr_t) palette_data) & 0xffff;
+  regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+  grub_bios_interrupt (0x10, &regs);
+  return regs.eax & 0xffff;
+}
+
+/* Call VESA BIOS 0x4f00 to get VBE Controller Information, return status.  */
+grub_vbe_status_t 
+grub_vbe_bios_get_controller_info (struct grub_vbe_info_block *ci)
+{
+  struct grub_bios_int_registers regs;
+  /* Store *controller_info to %es:%di.  */
+  regs.es = (((grub_addr_t) ci) & 0xffff0000) >> 4;
+  regs.edi = ((grub_addr_t) ci) & 0xffff;
+  regs.eax = 0x4f00;
+  regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+  grub_bios_interrupt (0x10, &regs);
+  return regs.eax & 0xffff;
+}
+
+/* Call VESA BIOS 0x4f01 to get VBE Mode Information, return status.  */
+grub_vbe_status_t 
+grub_vbe_bios_get_mode_info (grub_uint32_t mode,
+                            struct grub_vbe_mode_info_block *mode_info)
+{
+  struct grub_bios_int_registers regs;
+  regs.eax = 0x4f01;
+  regs.ecx = mode;
+  /* Store *mode_info to %es:%di.  */
+  regs.es = ((grub_addr_t) mode_info & 0xffff0000) >> 4;
+  regs.edi = (grub_addr_t) mode_info & 0x0000ffff;
+  regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+  grub_bios_interrupt (0x10, &regs);
+  return regs.eax & 0xffff;
+}
+
+/* Call VESA BIOS 0x4f02 to set video mode, return status.  */
+static grub_vbe_status_t
+grub_vbe_bios_set_mode (grub_uint32_t mode,
+                       struct grub_vbe_crtc_info_block *crtc_info)
+{
+  struct grub_bios_int_registers regs;
+
+  regs.eax = 0x4f02;
+  regs.ebx = mode;
+  /* Store *crtc_info to %es:%di.  */
+  regs.es = (((grub_addr_t) crtc_info) & 0xffff0000) >> 4;
+  regs.edi = ((grub_addr_t) crtc_info) & 0xffff;
+  regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+  grub_bios_interrupt (0x10, &regs);
+
+  return regs.eax & 0xffff;
+}
+
+/* Call VESA BIOS 0x4f03 to return current VBE Mode, return status.  */
+grub_vbe_status_t 
+grub_vbe_bios_get_mode (grub_uint32_t *mode)
+{
+  struct grub_bios_int_registers regs;
+
+  regs.eax = 0x4f03;
+  regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+  grub_bios_interrupt (0x10, &regs);
+  *mode = regs.ebx & 0xffff;
+
+  return regs.eax & 0xffff;
+}
+
+grub_vbe_status_t 
+grub_vbe_bios_getset_dac_palette_width (int set, int *dac_mask_size)
+{
+  struct grub_bios_int_registers regs;
+
+  regs.eax = 0x4f08;
+  regs.ebx = (*dac_mask_size & 0xff) >> 8;
+  regs.ebx = set ? 1 : 0;
+  regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+  grub_bios_interrupt (0x10, &regs);
+  *dac_mask_size = (regs.ebx >> 8) & 0xff;
+
+  return regs.eax & 0xffff;
+}
+
+/* Call VESA BIOS 0x4f05 to set memory window, return status.  */
+grub_vbe_status_t
+grub_vbe_bios_set_memory_window (grub_uint32_t window,
+                                grub_uint32_t position)
+{
+  struct grub_bios_int_registers regs;
+
+  /* BL = window, BH = 0, Set memory window.  */
+  regs.ebx = window & 0x00ff;
+  regs.edx = position;
+  regs.eax = 0x4f05;
+  regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+  grub_bios_interrupt (0x10, &regs);
+  return regs.eax & 0xffff;
+}
+
+/* Call VESA BIOS 0x4f05 to return memory window, return status.  */
+grub_vbe_status_t
+grub_vbe_bios_get_memory_window (grub_uint32_t window,
+                                grub_uint32_t *position)
+{
+  struct grub_bios_int_registers regs;
+
+  regs.eax = 0x4f05;
+  /* BH = 1, Get memory window. BL = window.  */
+  regs.ebx = (window & 0x00ff) | 0x100;
+  regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+  grub_bios_interrupt (0x10, &regs);
+
+  *position = regs.edx & 0xffff;
+  return regs.eax & 0xffff;
+}
+
+/* Call VESA BIOS 0x4f06 to set scanline length (in bytes), return status.  */
+grub_vbe_status_t 
+grub_vbe_bios_set_scanline_length (grub_uint32_t length)
+{
+  struct grub_bios_int_registers regs;
+
+  regs.ecx = length;
+  regs.eax = 0x4f06;
+  /* BL = 2, Set Scan Line in Bytes.  */
+  regs.ebx = 0x0002;   
+  regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+  grub_bios_interrupt (0x10, &regs);
+  return regs.eax & 0xffff;
+}
+
+/* Call VESA BIOS 0x4f06 to return scanline length (in bytes), return status.  */
+grub_vbe_status_t 
+grub_vbe_bios_get_scanline_length (grub_uint32_t *length)
+{
+  struct grub_bios_int_registers regs;
+
+  regs.eax = 0x4f06;
+  regs.ebx = 0x0001;
+  regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+  /* BL = 1, Get Scan Line Length (in bytes).  */
+  grub_bios_interrupt (0x10, &regs);
+
+  *length = regs.ebx & 0xffff;
+  return regs.eax & 0xffff;
+}
+
+/* Call VESA BIOS 0x4f07 to set display start, return status.  */
+static grub_vbe_status_t 
+grub_vbe_bios_set_display_start (grub_uint32_t x, grub_uint32_t y)
+{
+  struct grub_bios_int_registers regs;
+
+  /* Store x in %ecx.  */
+  regs.ecx = x;
+  regs.edx = y;
+  regs.eax = 0x4f07;
+  /* BL = 80h, Set Display Start during Vertical Retrace.  */
+  regs.ebx = 0x0080;   
+  regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+  grub_bios_interrupt (0x10, &regs);
+  return regs.eax & 0xffff;
+}
+
+/* Call VESA BIOS 0x4f07 to get display start, return status.  */
+grub_vbe_status_t 
+grub_vbe_bios_get_display_start (grub_uint32_t *x,
+                                grub_uint32_t *y)
+{
+  struct grub_bios_int_registers regs;
+
+  regs.eax = 0x4f07;
+  /* BL = 1, Get Display Start.  */
+  regs.ebx = 0x0001;
+  regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+  grub_bios_interrupt (0x10, &regs);
+
+  *x = regs.ecx & 0xffff;
+  *y = regs.edx & 0xffff;
+  return regs.eax & 0xffff;
+}
+
 grub_err_t
 grub_vbe_probe (struct grub_vbe_info_block *info_block)
 {