All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Kernel support for VESA Bios Extension
@ 2005-07-14 18:36 Vesa Jääskeläinen
  2005-07-14 19:02 ` Marco Gerards
  0 siblings, 1 reply; 8+ messages in thread
From: Vesa Jääskeläinen @ 2005-07-14 18:36 UTC (permalink / raw)
  To: The development of GRUB 2

[-- Attachment #1: Type: text/plain, Size: 762 bytes --]

Hi,

Here is attached a patch that adds VBE support to kernel and include 
file to make it easier to use it. There is diff for both i386-pc.rmk and 
  i386-pc.mk. Latter could be removed and let build process to generate 
it again, but I think that .mk file is present in CVS so I left both there.

I will make separate patch for the frame buffer console after this is 
first committed. (And I need to make some cleanups there first)

I would like to hear comments about the patch. I tried to implement most 
commonly needed functions, so you can't do everything with this. As I 
didn't need to use every function in my frame buffer console test, some 
things might not work. But I tried to make my best to proof read every 
function.

Thanks,
Vesa Jääskeläinen

[-- Attachment #2: grub2_i386_vbe.diff --]
[-- Type: text/plain, Size: 20047 bytes --]

diff -ruN grub2/ChangeLog grub2.vbe/ChangeLog
--- grub2/ChangeLog	2005-07-13 01:36:43.000000000 +0300
+++ grub2.vbe/ChangeLog	2005-07-16 15:07:01.132381816 +0300
@@ -1,3 +1,21 @@
+2005-07-14  Vesa Jaaskelainen  <chaac@nic.fi>
+
+	* conf/i386-pc.rmk (kernel_img_HEADERS): Added machine/vbe.h.
+	* kern/i386/pc/startup.S: Updated Global Descriptor table's
+	descriptions.
+	(grub_vbe_get_controller_info): New function.
+	(grub_vbe_get_mode_info): Likewise.
+	(grub_vbe_set_mode): Likewise.
+	(grub_vbe_get_mode): Likewise.
+	(grub_vbe_set_memory_window): Likewise.
+	(grub_vbe_get_memory_window): Likewise.
+	(grub_vbe_set_scanline_length): Likewise.
+	(grub_vbe_get_scanline_length): Likewise.
+	(grub_vbe_set_display_start): Likewise.
+	(grub_vbe_get_display_start): Likewise.
+	(grub_vbe_set_palette_data): Likewise.
+	* include/grub/i386/pc/vbe.h: New file.
+
 2005-07-12  Hollis Blanchard  <hollis@penguinppc.org>
 
 	* disk/powerpc/ieee1275/ofdisk.c (grub_ofdisk_open): dprintf the
diff -ruN grub2/conf/i386-pc.mk grub2.vbe/conf/i386-pc.mk
--- grub2/conf/i386-pc.mk	2005-07-10 10:57:49.000000000 +0300
+++ grub2.vbe/conf/i386-pc.mk	2005-07-15 18:10:46.000000000 +0300
@@ -253,7 +253,8 @@
 	file.h fs.h kernel.h loader.h misc.h mm.h net.h rescue.h symbol.h \
 	term.h types.h machine/biosdisk.h machine/boot.h \
 	machine/console.h machine/init.h machine/memory.h \
-	machine/loader.h partition.h pc_partition.h machine/time.h machine/vga.h
+	machine/loader.h partition.h pc_partition.h machine/time.h machine/vga.h \
+	machine/vbe.h
 kernel_img_CFLAGS = $(COMMON_CFLAGS)
 kernel_img_ASFLAGS = $(COMMON_ASFLAGS)
 kernel_img_LDFLAGS = -nostdlib -Wl,-N,-Ttext,8200
diff -ruN grub2/conf/i386-pc.rmk grub2.vbe/conf/i386-pc.rmk
--- grub2/conf/i386-pc.rmk	2005-07-10 10:57:49.000000000 +0300
+++ grub2.vbe/conf/i386-pc.rmk	2005-07-15 18:10:05.000000000 +0300
@@ -33,7 +33,8 @@
 	file.h fs.h kernel.h loader.h misc.h mm.h net.h rescue.h symbol.h \
 	term.h types.h machine/biosdisk.h machine/boot.h \
 	machine/console.h machine/init.h machine/memory.h \
-	machine/loader.h partition.h pc_partition.h machine/time.h machine/vga.h
+	machine/loader.h partition.h pc_partition.h machine/time.h machine/vga.h \
+	machine/vbe.h
 kernel_img_CFLAGS = $(COMMON_CFLAGS)
 kernel_img_ASFLAGS = $(COMMON_ASFLAGS)
 kernel_img_LDFLAGS = -nostdlib -Wl,-N,-Ttext,8200
Files grub2/core.img and grub2.vbe/core.img differ
diff -ruN grub2/device.map grub2.vbe/device.map
--- grub2/device.map	1970-01-01 02:00:00.000000000 +0200
+++ grub2.vbe/device.map	2005-07-16 15:03:23.520463856 +0300
@@ -0,0 +1 @@
+(fd0)	/dev/fd0
diff -ruN grub2/include/grub/i386/pc/vbe.h grub2.vbe/include/grub/i386/pc/vbe.h
--- grub2/include/grub/i386/pc/vbe.h	1970-01-01 02:00:00.000000000 +0200
+++ grub2.vbe/include/grub/i386/pc/vbe.h	2005-07-15 18:29:01.000000000 +0300
@@ -0,0 +1,161 @@
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2005  Free Software Foundation, Inc.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef GRUB_VBE_MACHINE_HEADER
+#define GRUB_VBE_MACHINE_HEADER	1
+
+#include <grub/symbol.h>
+#include <grub/types.h>
+
+typedef grub_uint32_t 	grub_vbe_farptr_t;
+typedef grub_uint32_t	grub_vbe_physptr_t;
+typedef grub_uint32_t	grub_vbe_status_t;
+
+struct grub_vbe_info_block_t {
+  grub_uint8_t 		signature[4];		// 'VESA'
+  grub_uint16_t		version;     		// VBE version BCD, for used standard: 0x0300 (3.0)
+
+  grub_vbe_farptr_t 	oem_string_ptr;   	// Pointer to OEM string
+  grub_uint32_t 	capabilities;   	//
+  grub_vbe_farptr_t 	video_mode_ptr;   	// Pointer to VideoModeList
+  grub_uint16_t		total_memory;    	// Number of 64k memory blocks
+
+  grub_uint16_t		oem_software_rev;	// VBE implementation software version
+  grub_vbe_farptr_t    	oem_vendor_name_ptr;	// Pointer to Vendor Name String
+  grub_vbe_farptr_t    	oem_product_name_ptr;	// Pointer to Product Name String
+  grub_vbe_farptr_t    	oem_product_rev_ptr;	// Pointer to Product Revision String
+
+  grub_uint8_t 		reserved[222];
+
+  grub_uint8_t 		oem_data[256];		// OEM Strings should reside here
+} __attribute__ ((packed));
+
+struct grub_vbe_mode_info_block_t {
+  // Mandory information for all VBE revisions
+  grub_uint16_t		mode_attributes;	// Mode attributes
+  grub_uint8_t		win_a_attributes;	// Window A attributes
+  grub_uint8_t		win_b_attributes;	// Window B attributes
+  grub_uint16_t		win_granularity;	// Window granularity
+  grub_uint16_t		win_size;		// Window size
+  grub_uint16_t		win_a_segment;		// Window A start segment
+  grub_uint16_t		win_b_segment;		// Window B start segment
+  grub_vbe_farptr_t	win_func_ptr;		// Real mode pointer to window function
+  grub_uint16_t		bytes_per_scan_line;	// Bytes per scan line
+
+  // Mandory information for VBE 1.2 and above
+  grub_uint16_t		x_resolution;
+  grub_uint16_t		y_resolution;
+  grub_uint8_t		x_char_size;
+  grub_uint8_t		y_char_size;
+  grub_uint8_t		number_of_planes;
+  grub_uint8_t		bits_per_pixel;
+  grub_uint8_t		number_of_banks;
+  grub_uint8_t		memory_model;
+  grub_uint8_t		bank_size;
+  grub_uint8_t		number_of_image_pages;
+  grub_uint8_t		reserved;
+
+  // Direct Color fields (required for direct/6 and YUV/7 memory models)
+  grub_uint8_t		red_mask_size;
+  grub_uint8_t		red_field_position;
+  grub_uint8_t		green_mask_size;
+  grub_uint8_t		green_field_position;
+  grub_uint8_t		blue_mask_size;
+  grub_uint8_t		blue_field_position;
+  grub_uint8_t		rsvd_mask_size;
+  grub_uint8_t		rsvd_field_position;
+  grub_uint8_t		direct_color_mode_info;
+
+  // Mandory information for VBE 2.0 and above
+  grub_vbe_physptr_t	phys_base_addr;		// Physical address for flat memory frame buffer
+  grub_uint32_t		reserved2;
+  grub_uint16_t		reserved3;
+
+  // Mandory information for VBE 3.0 and above
+  grub_uint16_t		lin_bytes_per_scan_line;
+  grub_uint8_t		bnk_number_of_image_pages;
+  grub_uint8_t		lin_number_of_image_pages;
+  grub_uint8_t		lin_red_mask_size;
+  grub_uint8_t		lin_red_field_position;
+  grub_uint8_t		lin_green_mask_size;
+  grub_uint8_t		lin_green_field_position;
+  grub_uint8_t		lin_blue_mask_size;
+  grub_uint8_t		lin_blue_field_position;
+  grub_uint8_t		lin_rsvd_mask_size;
+  grub_uint8_t		lin_rsvd_field_position;
+  grub_uint32_t		max_pixel_clock;
+
+  // Fill
+  grub_uint8_t		reserved4[189+1]; // Spec says 189 but it's total size should be 256
+} __attribute__ ((packed));
+
+struct grub_vbe_crtc_info_block_t {
+  grub_uint16_t		horizontal_total;
+  grub_uint16_t		horizontal_sync_start;
+  grub_uint16_t		horizontal_sync_end;
+  grub_uint16_t		vertical_total;
+  grub_uint16_t		vertical_sync_start;
+  grub_uint16_t		vertical_sync_end;
+  grub_uint8_t		flags;
+  grub_uint32_t		pixel_clock;
+  grub_uint16_t		refresh_rate;
+  grub_uint8_t		reserved[40];
+} __attribute__ ((packed));
+
+struct grub_vbe_palette_data_t {
+  grub_uint8_t		blue;
+  grub_uint8_t		green;
+  grub_uint8_t		red;
+  grub_uint8_t		aligment;
+} __attribute__ ((packed));
+
+/* Call VESA BIOS 0x4f00 to get VBE Controller Information, return VBE status */
+grub_vbe_status_t EXPORT_FUNC(grub_vbe_get_controller_info) (struct grub_vbe_info_block_t *controller_info);
+
+/* Call VESA BIOS 0x4f01 to get VBE Mode Information, return VBE status */
+grub_vbe_status_t EXPORT_FUNC(grub_vbe_get_mode_info) (grub_uint32_t mode, struct grub_vbe_mode_info_block_t *mode_info);
+
+/* Call VESA BIOS 0x4f02 to set video mode, return status */
+grub_vbe_status_t EXPORT_FUNC(grub_vbe_set_mode) (grub_uint32_t mode, struct grub_vbe_crtc_info_block_t *crtc_info);
+
+/* Call VESA BIOS 0x4f03 to return current VBE Mode, return status */
+grub_vbe_status_t EXPORT_FUNC(grub_vbe_get_mode) (grub_uint32_t *mode);
+
+/* Call VESA BIOS 0x4f05 to set memory window, return status */
+grub_vbe_status_t EXPORT_FUNC(grub_vbe_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_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_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_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_set_display_start) (grub_uint32_t x, grub_uint32_t y);
+
+/* Call VESA BIOS 0x4f07 to get display start, return status */
+grub_vbe_status_t EXPORT_FUNC(grub_vbe_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_set_palette_data) (grub_uint32_t color_count, grub_uint32_t start_index, struct grub_vbe_palette_data_t *palette_data);
+
+#endif /* ! GRUB_VBE_MACHINE_HEADER */
diff -ruN grub2/kern/i386/pc/startup.S grub2.vbe/kern/i386/pc/startup.S
--- grub2/kern/i386/pc/startup.S	2004-04-04 16:46:02.000000000 +0300
+++ grub2.vbe/kern/i386/pc/startup.S	2005-07-16 15:03:13.895927008 +0300
@@ -1,6 +1,6 @@
 /*
  *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 1999,2000,2001,2002,2003 Free Software Foundation, Inc.
+ *  Copyright (C) 1999,2000,2001,2002,2003,2005 Free Software Foundation, Inc.
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -219,11 +219,11 @@
  * 31          24         19   16                 7           0
  * ------------------------------------------------------------
  * |             | |B| |A|       | |   |1|0|E|W|A|            |
- * | BASE 31..24 |G|/|0|V| LIMIT |P|DPL|  TYPE   | BASE 23:16 |
+ * | BASE 31..24 |G|/|L|V| LIMIT |P|DPL|  TYPE   | BASE 23:16 |  4
  * |             | |D| |L| 19..16| |   |1|1|C|R|A|            |
  * ------------------------------------------------------------
  * |                             |                            |
- * |        BASE 15..0           |       LIMIT 15..0          |
+ * |        BASE 15..0           |       LIMIT 15..0          |  0
  * |                             |                            |
  * ------------------------------------------------------------
  *
@@ -236,19 +236,31 @@
 	.word	0, 0
 	.byte	0, 0, 0, 0
 
-	/* code segment */
+	/* -- code segment --
+	 * base = 0x00000000, limit = 0xFFFFF (4 KiB Granularity), present
+	 * type = 32bit code execute/read, DPL = 0
+	 */
 	.word	0xFFFF, 0
 	.byte	0, 0x9A, 0xCF, 0
 
-	/* data segment */
+	/* -- data segment --
+	 * base = 0x00000000, limit 0xFFFFF (4 KiB Granularity), present
+	 * type = 32 bit data read/write, DPL = 0 
+	 */
 	.word	0xFFFF, 0
 	.byte	0, 0x92, 0xCF, 0
 
-	/* 16 bit real mode CS */
+	/* -- 16 bit real mode CS --
+	 * base = 0x00000000, limit 0x0FFFF (1 B Granularity), present
+	 * type = 16 bit code execute/read only/conforming, DPL = 0
+	 */
 	.word	0xFFFF, 0
 	.byte	0, 0x9E, 0, 0
 
-	/* 16 bit real mode DS */
+	/* -- 16 bit real mode DS --
+	 * base = 0x00000000, limit 0x0FFFF (1 B Granularity), present
+	 * type = 16 bit data read/write, DPL = 0
+	 */
 	.word	0xFFFF, 0
 	.byte	0, 0x92, 0, 0
 
@@ -1594,3 +1606,406 @@
 	popl	%ebx
 	popl	%ebp
 	ret
+
+/*
+ * grub_vbe_status_t grub_vbe_get_controller_info (struct grub_vbe_info_block_t *controller_info)
+ *
+ * Register allocations for parameters:
+ * %eax		*controller_info
+ */
+FUNCTION(grub_vbe_get_controller_info)
+	pushl	%ebp
+	pushl	%edi
+
+	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 */
+	
+	popl	%edi
+	popl	%ebp
+	ret
+
+/*
+ * grub_vbe_status_t grub_vbe_get_mode_info (grub_uint32_t mode, struct grub_vbe_mode_info_block_t *mode_info)
+ *
+ * Register allocations for parameters:
+ * %eax		mode
+ * %edx		*mode_info
+ */
+FUNCTION(grub_vbe_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_set_mode (grub_uint32_t mode, struct grub_vbe_crtc_info_block_t *crtc_info)
+ *
+ * Register allocations for parameters:
+ * %eax		mode
+ * %edx		*crtc_info
+ */
+FUNCTION(grub_vbe_set_mode)
+	pushl	%ebp
+	pushl	%ebx
+
+	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	%ebx
+	popl	%ebp
+	ret
+
+/*
+ * grub_vbe_status_t grub_vbe_get_mode (grub_uint32_t *mode)
+ *
+ * Register allocations for parameters:
+ * %eax		*mode
+ */
+FUNCTION(grub_vbe_get_mode)
+	pushl   %ebp
+	pushl   %ebx
+	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    %ebx
+	popl    %ebp
+	ret
+
+/*
+ * grub_vbe_status_t grub_vbe_set_memory_window (grub_uint32_t window, grub_uint32_t position);
+ *
+ * Register allocations for parameters:
+ * %eax		window
+ * %edx		position
+ */
+FUNCTION(grub_vbe_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_get_memory_window (grub_uint32_t window, grub_uint32_t *position);
+ *
+ * Register allocations for parameters:
+ * %eax		window
+ * %edx		*position
+ */
+FUNCTION(grub_vbe_get_memory_window)
+	pushl   %ebp
+	pushl   %ebx
+	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    %ebx
+	popl    %ebp
+	ret
+
+/*
+ * grub_vbe_status_t grub_vbe_set_scanline_length (grub_uint32_t length)
+ *
+ * Register allocations for parameters:
+ * %eax		length
+ */
+FUNCTION(grub_vbe_set_scanline_length)
+	pushl	%ebp
+	pushl	%ebx
+
+	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	%ebx
+	popl	%ebp
+	ret
+
+/*
+ * grub_vbe_status_t grub_vbe_get_scanline_length (grub_uint32_t *length)
+ *
+ * Register allocations for parameters:
+ * %eax		*length
+ */
+FUNCTION(grub_vbe_get_scanline_length)
+	pushl   %ebp
+	pushl   %ebx
+	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    %ebx
+	popl    %ebp
+	ret
+
+/*
+ * grub_vbe_status_t grub_vbe_set_display_start (grub_uint32_t x, grub_uint32_t y)
+ *
+ * Register allocations for parameters:
+ * %eax		x
+ * %edx		y
+ */
+FUNCTION(grub_vbe_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_get_display_start (grub_uint32_t *x, grub_uint32_t *y)
+ *
+ * Register allocations for parameters:
+ * %eax		*x
+ * %edx		*y
+ */
+FUNCTION(grub_vbe_get_display_start)
+	pushl   %ebp
+	pushl   %ebx
+	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    %ebx
+	popl    %ebp
+	ret
+
+/*
+ * grub_vbe_status_t grub_vbe_set_palette_data (grub_uint32_t color_count, grub_uint32_t start_index, struct grub_vbe_palette_data_t *palette_data)
+ *
+ * Register allocations for parameters:
+ * %eax		color_count
+ * %edx		start_index
+ * %ecx		*palette_data
+ */
+FUNCTION(grub_vbe_set_palette_data)
+	pushl	%ebp
+	pushl	%ebx
+
+	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	%ebx
+	popl	%ebp
+	ret

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Kernel support for VESA Bios Extension
  2005-07-14 18:36 [PATCH] Kernel support for VESA Bios Extension Vesa Jääskeläinen
@ 2005-07-14 19:02 ` Marco Gerards
  2005-07-14 20:36   ` Vesa Jääskeläinen
  0 siblings, 1 reply; 8+ messages in thread
From: Marco Gerards @ 2005-07-14 19:02 UTC (permalink / raw)
  To: The development of GRUB 2

Vesa Jääskeläinen <chaac@nic.fi> writes:

Hi,

Thanks a lot for your work.  I am looking forwards to the VESA
console!

> Here is attached a patch that adds VBE support to kernel and include
> file to make it easier to use it. There is diff for both i386-pc.rmk
> and i386-pc.mk. Latter could be removed and let build process to
> generate it again, but I think that .mk file is present in CVS so I
> left both there.

Please always include the changed to *.rmk in the patches.  You don't
have to supply *.mk because those files are generated and make the
patch just harder to read.

> I will make separate patch for the frame buffer console after this is
> first committed. (And I need to make some cleanups there first)

Ok.

> I would like to hear comments about the patch. I tried to implement
> most commonly needed functions, so you can't do everything with
> this. As I didn't need to use every function in my frame buffer
> console test, some things might not work. But I tried to make my best
> to proof read every function.

Can you please make sure you are using the GCS for coding style?
Please have a look at the other sourcecode and the GCS (GNU Coding
Standards) first:

http://www.gnu.org/prep/standards/

It is important for us to have a single and consistent coding style.
If you have questions about either GRUB or the coding style you are of
course free to ask.

Thanks,
Marco




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Kernel support for VESA Bios Extension
  2005-07-14 19:02 ` Marco Gerards
@ 2005-07-14 20:36   ` Vesa Jääskeläinen
  2005-07-14 21:45     ` Marco Gerards
  0 siblings, 1 reply; 8+ messages in thread
From: Vesa Jääskeläinen @ 2005-07-14 20:36 UTC (permalink / raw)
  To: The development of GRUB 2

[-- Attachment #1: Type: text/plain, Size: 862 bytes --]

Marco Gerards wrote:

>>I would like to hear comments about the patch. I tried to implement
>>most commonly needed functions, so you can't do everything with
>>this. As I didn't need to use every function in my frame buffer
>>console test, some things might not work. But I tried to make my best
>>to proof read every function.
> 
> Can you please make sure you are using the GCS for coding style?
> Please have a look at the other sourcecode and the GCS (GNU Coding
> Standards) first:
> 
> http://www.gnu.org/prep/standards/
> 
> It is important for us to have a single and consistent coding style.
> If you have questions about either GRUB or the coding style you are of
> course free to ask.

Perhaps this is a bit closer to requirement?

If there still are issues on formatting could you specify what issues 
you are thinking on.

Thanks,
Vesa Jääskeläinen

[-- Attachment #2: grub2_i386_vbe.diff --]
[-- Type: text/plain, Size: 18972 bytes --]

diff -ruN grub2/ChangeLog grub2.vbe/ChangeLog
--- grub2/ChangeLog	2005-07-13 01:36:43.000000000 +0300
+++ grub2.vbe/ChangeLog	2005-07-16 15:07:01.132381816 +0300
@@ -1,3 +1,21 @@
+2005-07-14  Vesa Jaaskelainen  <chaac@nic.fi>
+
+	* conf/i386-pc.rmk (kernel_img_HEADERS): Added machine/vbe.h.
+	* kern/i386/pc/startup.S: Updated Global Descriptor table's
+	descriptions.
+	(grub_vbe_get_controller_info): New function.
+	(grub_vbe_get_mode_info): Likewise.
+	(grub_vbe_set_mode): Likewise.
+	(grub_vbe_get_mode): Likewise.
+	(grub_vbe_set_memory_window): Likewise.
+	(grub_vbe_get_memory_window): Likewise.
+	(grub_vbe_set_scanline_length): Likewise.
+	(grub_vbe_get_scanline_length): Likewise.
+	(grub_vbe_set_display_start): Likewise.
+	(grub_vbe_get_display_start): Likewise.
+	(grub_vbe_set_palette_data): Likewise.
+	* include/grub/i386/pc/vbe.h: New file.
+
 2005-07-12  Hollis Blanchard  <hollis@penguinppc.org>
 
 	* disk/powerpc/ieee1275/ofdisk.c (grub_ofdisk_open): dprintf the
diff -ruN grub2/conf/i386-pc.rmk grub2.vbe/conf/i386-pc.rmk
--- grub2/conf/i386-pc.rmk	2005-07-10 10:57:49.000000000 +0300
+++ grub2.vbe/conf/i386-pc.rmk	2005-07-15 18:10:05.000000000 +0300
@@ -33,7 +33,8 @@
 	file.h fs.h kernel.h loader.h misc.h mm.h net.h rescue.h symbol.h \
 	term.h types.h machine/biosdisk.h machine/boot.h \
 	machine/console.h machine/init.h machine/memory.h \
-	machine/loader.h partition.h pc_partition.h machine/time.h machine/vga.h
+	machine/loader.h partition.h pc_partition.h machine/time.h machine/vga.h \
+	machine/vbe.h
 kernel_img_CFLAGS = $(COMMON_CFLAGS)
 kernel_img_ASFLAGS = $(COMMON_ASFLAGS)
 kernel_img_LDFLAGS = -nostdlib -Wl,-N,-Ttext,8200
diff -ruN grub2/include/grub/i386/pc/vbe.h grub2.vbe/include/grub/i386/pc/vbe.h
--- grub2/include/grub/i386/pc/vbe.h	1970-01-01 02:00:00.000000000 +0200
+++ grub2.vbe/include/grub/i386/pc/vbe.h	2005-07-16 17:21:40.815083344 +0300
@@ -0,0 +1,180 @@
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2005  Free Software Foundation, Inc.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef GRUB_VBE_MACHINE_HEADER
+#define GRUB_VBE_MACHINE_HEADER	1
+
+#include <grub/symbol.h>
+#include <grub/types.h>
+
+/*
+ * Note:
+ *
+ * Please refer to VESA BIOS Extension 3.0 Specification for more descriptive
+ * meanings of following structures and how they should be used.
+ *
+ * I have tried to maintain field name comatibility against specification while
+ * following naming convetions used in GRUB.
+ */
+
+typedef grub_uint32_t 	grub_vbe_farptr_t;
+typedef grub_uint32_t	grub_vbe_physptr_t;
+typedef grub_uint32_t	grub_vbe_status_t;
+
+struct grub_vbe_info_block
+{
+  grub_uint8_t signature[4];
+  grub_uint16_t version;
+
+  grub_vbe_farptr_t oem_string_ptr;
+  grub_uint32_t capabilities;
+  grub_vbe_farptr_t video_mode_ptr;
+  grub_uint16_t total_memory;
+
+  grub_uint16_t oem_software_rev;
+  grub_vbe_farptr_t oem_vendor_name_ptr;
+  grub_vbe_farptr_t oem_product_name_ptr;
+  grub_vbe_farptr_t oem_product_rev_ptr;
+
+  grub_uint8_t reserved[222];
+
+  grub_uint8_t oem_data[256];
+} __attribute__ ((packed));
+
+struct grub_vbe_mode_info_block
+{
+  /* Mandory information for all VBE revisions */
+  grub_uint16_t mode_attributes;
+  grub_uint8_t win_a_attributes;
+  grub_uint8_t win_b_attributes;
+  grub_uint16_t win_granularity;
+  grub_uint16_t win_size;
+  grub_uint16_t win_a_segment;
+  grub_uint16_t win_b_segment;
+  grub_vbe_farptr_t win_func_ptr;
+  grub_uint16_t bytes_per_scan_line;
+
+  /* Mandory information for VBE 1.2 and above */
+  grub_uint16_t x_resolution;
+  grub_uint16_t y_resolution;
+  grub_uint8_t x_char_size;
+  grub_uint8_t y_char_size;
+  grub_uint8_t number_of_planes;
+  grub_uint8_t bits_per_pixel;
+  grub_uint8_t number_of_banks;
+  grub_uint8_t memory_model;
+  grub_uint8_t bank_size;
+  grub_uint8_t number_of_image_pages;
+  grub_uint8_t reserved;
+
+  /* Direct Color fields (required for direct/6 and YUV/7 memory models) */
+  grub_uint8_t red_mask_size;
+  grub_uint8_t red_field_position;
+  grub_uint8_t green_mask_size;
+  grub_uint8_t green_field_position;
+  grub_uint8_t blue_mask_size;
+  grub_uint8_t blue_field_position;
+  grub_uint8_t rsvd_mask_size;
+  grub_uint8_t rsvd_field_position;
+  grub_uint8_t direct_color_mode_info;
+
+  /* Mandory information for VBE 2.0 and above */
+  grub_vbe_physptr_t phys_base_addr;
+  grub_uint32_t reserved2;
+  grub_uint16_t reserved3;
+
+  /* Mandory information for VBE 3.0 and above */
+  grub_uint16_t lin_bytes_per_scan_line;
+  grub_uint8_t bnk_number_of_image_pages;
+  grub_uint8_t lin_number_of_image_pages;
+  grub_uint8_t lin_red_mask_size;
+  grub_uint8_t lin_red_field_position;
+  grub_uint8_t lin_green_mask_size;
+  grub_uint8_t lin_green_field_position;
+  grub_uint8_t lin_blue_mask_size;
+  grub_uint8_t lin_blue_field_position;
+  grub_uint8_t lin_rsvd_mask_size;
+  grub_uint8_t lin_rsvd_field_position;
+  grub_uint32_t max_pixel_clock;
+
+  /*
+   * Reserved field to make structure to be 256 bytes long, VESA BIOS 
+   * Extension 3.0 Specification says to reserve 189 bytes here but 
+   * that doesn't make structure to be 256 bytes. So additional one is 
+   * added here.
+   */
+  grub_uint8_t reserved4[189+1];
+} __attribute__ ((packed));
+
+struct grub_vbe_crtc_info_block
+{
+  grub_uint16_t horizontal_total;
+  grub_uint16_t horizontal_sync_start;
+  grub_uint16_t horizontal_sync_end;
+  grub_uint16_t vertical_total;
+  grub_uint16_t vertical_sync_start;
+  grub_uint16_t vertical_sync_end;
+  grub_uint8_t flags;
+  grub_uint32_t pixel_clock;
+  grub_uint16_t refresh_rate;
+  grub_uint8_t reserved[40];
+} __attribute__ ((packed));
+
+struct grub_vbe_palette_data
+{
+  grub_uint8_t blue;
+  grub_uint8_t green;
+  grub_uint8_t red;
+  grub_uint8_t aligment;
+} __attribute__ ((packed));
+
+/* Call VESA BIOS 0x4f00 to get VBE Controller Information, return status */
+grub_vbe_status_t EXPORT_FUNC(grub_vbe_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_get_mode_info) (grub_uint32_t mode, struct grub_vbe_mode_info_block *mode_info);
+
+/* Call VESA BIOS 0x4f02 to set video mode, return status */
+grub_vbe_status_t EXPORT_FUNC(grub_vbe_set_mode) (grub_uint32_t mode, struct grub_vbe_crtc_info_block *crtc_info);
+
+/* Call VESA BIOS 0x4f03 to return current VBE Mode, return status */
+grub_vbe_status_t EXPORT_FUNC(grub_vbe_get_mode) (grub_uint32_t *mode);
+
+/* Call VESA BIOS 0x4f05 to set memory window, return status */
+grub_vbe_status_t EXPORT_FUNC(grub_vbe_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_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_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_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_set_display_start) (grub_uint32_t x, grub_uint32_t y);
+
+/* Call VESA BIOS 0x4f07 to get display start, return status */
+grub_vbe_status_t EXPORT_FUNC(grub_vbe_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_set_palette_data) (grub_uint32_t color_count, grub_uint32_t start_index, struct grub_vbe_palette_data *palette_data);
+
+#endif /* ! GRUB_VBE_MACHINE_HEADER */
diff -ruN grub2/kern/i386/pc/startup.S grub2.vbe/kern/i386/pc/startup.S
--- grub2/kern/i386/pc/startup.S	2004-04-04 16:46:02.000000000 +0300
+++ grub2.vbe/kern/i386/pc/startup.S	2005-07-16 17:17:21.471509560 +0300
@@ -1,6 +1,6 @@
 /*
  *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 1999,2000,2001,2002,2003 Free Software Foundation, Inc.
+ *  Copyright (C) 1999,2000,2001,2002,2003,2005 Free Software Foundation, Inc.
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -219,11 +219,11 @@
  * 31          24         19   16                 7           0
  * ------------------------------------------------------------
  * |             | |B| |A|       | |   |1|0|E|W|A|            |
- * | BASE 31..24 |G|/|0|V| LIMIT |P|DPL|  TYPE   | BASE 23:16 |
+ * | BASE 31..24 |G|/|L|V| LIMIT |P|DPL|  TYPE   | BASE 23:16 |  4
  * |             | |D| |L| 19..16| |   |1|1|C|R|A|            |
  * ------------------------------------------------------------
  * |                             |                            |
- * |        BASE 15..0           |       LIMIT 15..0          |
+ * |        BASE 15..0           |       LIMIT 15..0          |  0
  * |                             |                            |
  * ------------------------------------------------------------
  *
@@ -236,19 +236,31 @@
 	.word	0, 0
 	.byte	0, 0, 0, 0
 
-	/* code segment */
+	/* -- code segment --
+	 * base = 0x00000000, limit = 0xFFFFF (4 KiB Granularity), present
+	 * type = 32bit code execute/read, DPL = 0
+	 */
 	.word	0xFFFF, 0
 	.byte	0, 0x9A, 0xCF, 0
 
-	/* data segment */
+	/* -- data segment --
+	 * base = 0x00000000, limit 0xFFFFF (4 KiB Granularity), present
+	 * type = 32 bit data read/write, DPL = 0 
+	 */
 	.word	0xFFFF, 0
 	.byte	0, 0x92, 0xCF, 0
 
-	/* 16 bit real mode CS */
+	/* -- 16 bit real mode CS --
+	 * base = 0x00000000, limit 0x0FFFF (1 B Granularity), present
+	 * type = 16 bit code execute/read only/conforming, DPL = 0
+	 */
 	.word	0xFFFF, 0
 	.byte	0, 0x9E, 0, 0
 
-	/* 16 bit real mode DS */
+	/* -- 16 bit real mode DS --
+	 * base = 0x00000000, limit 0x0FFFF (1 B Granularity), present
+	 * type = 16 bit data read/write, DPL = 0
+	 */
 	.word	0xFFFF, 0
 	.byte	0, 0x92, 0, 0
 
@@ -1594,3 +1606,414 @@
 	popl	%ebx
 	popl	%ebp
 	ret
+
+/*
+ * grub_vbe_status_t grub_vbe_get_controller_info (struct grub_vbe_info_block *controller_info)
+ *
+ * Register allocations for parameters:
+ * %eax		*controller_info
+ */
+FUNCTION(grub_vbe_get_controller_info)
+	pushl	%ebp
+	pushl	%edi
+
+	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 */
+	
+	popl	%edi
+	popl	%ebp
+	ret
+
+/*
+ * grub_vbe_status_t grub_vbe_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_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_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_set_mode)
+	pushl	%ebp
+	pushl	%ebx
+
+	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	%ebx
+	popl	%ebp
+	ret
+
+/*
+ * grub_vbe_status_t grub_vbe_get_mode (grub_uint32_t *mode)
+ *
+ * Register allocations for parameters:
+ * %eax		*mode
+ */
+FUNCTION(grub_vbe_get_mode)
+	pushl   %ebp
+	pushl   %ebx
+	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    %ebx
+	popl    %ebp
+	ret
+
+/*
+ * grub_vbe_status_t grub_vbe_set_memory_window (grub_uint32_t window,
+ *						 grub_uint32_t position);
+ *
+ * Register allocations for parameters:
+ * %eax		window
+ * %edx		position
+ */
+FUNCTION(grub_vbe_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_get_memory_window (grub_uint32_t window,
+ * 						 grub_uint32_t *position);
+ *
+ * Register allocations for parameters:
+ * %eax		window
+ * %edx		*position
+ */
+FUNCTION(grub_vbe_get_memory_window)
+	pushl   %ebp
+	pushl   %ebx
+	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    %ebx
+	popl    %ebp
+	ret
+
+/*
+ * grub_vbe_status_t grub_vbe_set_scanline_length (grub_uint32_t length)
+ *
+ * Register allocations for parameters:
+ * %eax		length
+ */
+FUNCTION(grub_vbe_set_scanline_length)
+	pushl	%ebp
+	pushl	%ebx
+
+	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	%ebx
+	popl	%ebp
+	ret
+
+/*
+ * grub_vbe_status_t grub_vbe_get_scanline_length (grub_uint32_t *length)
+ *
+ * Register allocations for parameters:
+ * %eax		*length
+ */
+FUNCTION(grub_vbe_get_scanline_length)
+	pushl   %ebp
+	pushl   %ebx
+	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    %ebx
+	popl    %ebp
+	ret
+
+/*
+ * grub_vbe_status_t grub_vbe_set_display_start (grub_uint32_t x,
+ *						 grub_uint32_t y)
+ *
+ * Register allocations for parameters:
+ * %eax		x
+ * %edx		y
+ */
+FUNCTION(grub_vbe_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_get_display_start (grub_uint32_t *x,
+ *						 grub_uint32_t *y)
+ *
+ * Register allocations for parameters:
+ * %eax		*x
+ * %edx		*y
+ */
+FUNCTION(grub_vbe_get_display_start)
+	pushl   %ebp
+	pushl   %ebx
+	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    %ebx
+	popl    %ebp
+	ret
+
+/*
+ * grub_vbe_status_t grub_vbe_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_set_palette_data)
+	pushl	%ebp
+	pushl	%ebx
+
+	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	%ebx
+	popl	%ebp
+	ret

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Kernel support for VESA Bios Extension
  2005-07-14 20:36   ` Vesa Jääskeläinen
@ 2005-07-14 21:45     ` Marco Gerards
  2005-07-15 10:53       ` Yoshinori K. Okuji
  2005-07-15 16:47       ` Vesa Jääskeläinen
  0 siblings, 2 replies; 8+ messages in thread
From: Marco Gerards @ 2005-07-14 21:45 UTC (permalink / raw)
  To: The development of GRUB 2

Vesa Jääskeläinen <chaac@nic.fi> writes:

>>>I would like to hear comments about the patch. I tried to implement
>>>most commonly needed functions, so you can't do everything with
>>>this. As I didn't need to use every function in my frame buffer
>>>console test, some things might not work. But I tried to make my best
>>>to proof read every function.
>> Can you please make sure you are using the GCS for coding style?
>> Please have a look at the other sourcecode and the GCS (GNU Coding
>> Standards) first:
>> http://www.gnu.org/prep/standards/
>> It is important for us to have a single and consistent coding style.
>> If you have questions about either GRUB or the coding style you are of
>> course free to ask.
>
> Perhaps this is a bit closer to requirement?

It is, thanks.

> If there still are issues on formatting could you specify what issues
> you are thinking on.

Of course.

> +typedef grub_uint32_t 	grub_vbe_farptr_t;
> +typedef grub_uint32_t	grub_vbe_physptr_t;
> +typedef grub_uint32_t	grub_vbe_status_t;

Please use a single space before the type name.

> +struct grub_vbe_mode_info_block
> +{
> +  /* Mandory information for all VBE revisions */

After the comment add a `.' and two spaces instead of one.  This is
true for all comments.

> +  /*
> +   * Reserved field to make structure to be 256 bytes long, VESA BIOS 
> +   * Extension 3.0 Specification says to reserve 189 bytes here but 
> +   * that doesn't make structure to be 256 bytes. So additional one is 
> +   * added here.
> +   */

I personally prefer not using that many `*'s and believe it is not in
the GCS.  But I think Okuji uses this as well, but I don't.  Perhaps
we need our own guidelines for such things, I think consistency is
important.  Okuji, what you you think?

> +  grub_uint8_t reserved4[189+1];

Please put spaces around operators.  So this should be:

grub_uint8_t reserved4[189 + 1]

   * 31          24         19   16                 7           0
>   * ------------------------------------------------------------
>   * |             | |B| |A|       | |   |1|0|E|W|A|            |
> - * | BASE 31..24 |G|/|0|V| LIMIT |P|DPL|  TYPE   | BASE 23:16 |
> + * | BASE 31..24 |G|/|L|V| LIMIT |P|DPL|  TYPE   | BASE 23:16 |  4
>   * |             | |D| |L| 19..16| |   |1|1|C|R|A|            |
>   * ------------------------------------------------------------
>   * |                             |                            |
> - * |        BASE 15..0           |       LIMIT 15..0          |
> + * |        BASE 15..0           |       LIMIT 15..0          |  0
>   * |                             |                            |
>   * ------------------------------------------------------------
>   *

What is this?  Is this copied from (copyrighted) documentation?


To me it seemed line some lines were too long.  Please keep in mind it
should be all readable on a 80 columns width terminal according to the
GCS.

I will be gone this weekend.  After the weekend I will try to
understand the patch and proofread the assembler code.  But my x86
assembly is *very* rusty, so I hope someone else can review this patch
because I am afraid when it comes to assembler my opinion is not worth
a bit. ;)

Thanks,
Marco




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Kernel support for VESA Bios Extension
  2005-07-14 21:45     ` Marco Gerards
@ 2005-07-15 10:53       ` Yoshinori K. Okuji
  2005-07-15 16:47       ` Vesa Jääskeläinen
  1 sibling, 0 replies; 8+ messages in thread
From: Yoshinori K. Okuji @ 2005-07-15 10:53 UTC (permalink / raw)
  To: The development of GRUB 2

On Thursday 14 July 2005 23:45, Marco Gerards wrote:
> I personally prefer not using that many `*'s and believe it is not in
> the GCS.  But I think Okuji uses this as well, but I don't.  Perhaps
> we need our own guidelines for such things, I think consistency is
> important.  Okuji, what you you think?

I don't need strict rules here. As far as I see, GNU does not define anything 
about this.

But I myself don't use aterisks except for the license term in C, do I?

Okuji



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Kernel support for VESA Bios Extension
  2005-07-14 21:45     ` Marco Gerards
  2005-07-15 10:53       ` Yoshinori K. Okuji
@ 2005-07-15 16:47       ` Vesa Jääskeläinen
  2005-07-15 18:55         ` Yoshinori K. Okuji
  1 sibling, 1 reply; 8+ messages in thread
From: Vesa Jääskeläinen @ 2005-07-15 16:47 UTC (permalink / raw)
  To: The development of GRUB 2

[-- Attachment #1: Type: text/plain, Size: 3214 bytes --]

Marco Gerards wrote:

>>+typedef grub_uint32_t 	grub_vbe_farptr_t;
>>+typedef grub_uint32_t	grub_vbe_physptr_t;
>>+typedef grub_uint32_t	grub_vbe_status_t;
> 
> Please use a single space before the type name.

Done.

>>+struct grub_vbe_mode_info_block
>>+{
>>+  /* Mandory information for all VBE revisions */
> 
> After the comment add a `.' and two spaces instead of one.  This is
> true for all comments.

Odd... Especially that two spaces. But I don't want to start another 
"war" with this ;)... So I try to adapt.

>>+  /*
>>+   * Reserved field to make structure to be 256 bytes long, VESA BIOS 
>>+   * Extension 3.0 Specification says to reserve 189 bytes here but 
>>+   * that doesn't make structure to be 256 bytes. So additional one is 
>>+   * added here.
>>+   */
> 
> I personally prefer not using that many `*'s and believe it is not in
> the GCS.  But I think Okuji uses this as well, but I don't.  Perhaps
> we need our own guidelines for such things, I think consistency is
> important.  Okuji, what you you think?

Now it's modified a bit.

>>+  grub_uint8_t reserved4[189+1];
> 
> Please put spaces around operators.  So this should be:
> 
> grub_uint8_t reserved4[189 + 1]

Done.

>    * 31          24         19   16                 7           0
> 
>>  * ------------------------------------------------------------
>>  * |             | |B| |A|       | |   |1|0|E|W|A|            |
>>- * | BASE 31..24 |G|/|0|V| LIMIT |P|DPL|  TYPE   | BASE 23:16 |
>>+ * | BASE 31..24 |G|/|L|V| LIMIT |P|DPL|  TYPE   | BASE 23:16 |  4
>>  * |             | |D| |L| 19..16| |   |1|1|C|R|A|            |
>>  * ------------------------------------------------------------
>>  * |                             |                            |
>>- * |        BASE 15..0           |       LIMIT 15..0          |
>>+ * |        BASE 15..0           |       LIMIT 15..0          |  0
>>  * |                             |                            |
>>  * ------------------------------------------------------------
>>  *
> 
> What is this?  Is this copied from (copyrighted) documentation?

It was there already and I just added x86-64 specific flag there and 
some helpers (4 and 0) to make it easier to read records correctly. I am 
not sure what is it's origin as it was there already, but as you could 
guess, it looks similar as in Intel's software developers guide and I 
would assume that it looks similar also in AMD's.

It can of course be removed completely in the commit if required to be.

> To me it seemed line some lines were too long.  Please keep in mind it
> should be all readable on a 80 columns width terminal according to the
> GCS.

I can see if I can split them more nicely if they are too long. But the 
problem is how to split them so that they are conforming the GCS on that 
:). But let's see.

> I will be gone this weekend.  After the weekend I will try to
> understand the patch and proofread the assembler code.  But my x86
> assembly is *very* rusty, so I hope someone else can review this patch
> because I am afraid when it comes to assembler my opinion is not worth
> a bit. ;)

Ok.

I have attached yet another patch with some formatting changes.

Thanks,
Vesa Jääskeläinen

[-- Attachment #2: grub2_i386_vbe.diff --]
[-- Type: text/plain, Size: 19549 bytes --]

diff -ruN grub2/ChangeLog grub2.vbe/ChangeLog
--- grub2/ChangeLog	2005-07-13 01:36:43.000000000 +0300
+++ grub2.vbe/ChangeLog	2005-07-17 13:10:20.259773072 +0300
@@ -1,3 +1,21 @@
+2005-07-15  Vesa Jaaskelainen  <chaac@nic.fi>
+
+	* conf/i386-pc.rmk (kernel_img_HEADERS): Added machine/vbe.h.
+	* kern/i386/pc/startup.S: Updated Global Descriptor table's
+	descriptions.
+	(grub_vbe_get_controller_info): New function.
+	(grub_vbe_get_mode_info): Likewise.
+	(grub_vbe_set_mode): Likewise.
+	(grub_vbe_get_mode): Likewise.
+	(grub_vbe_set_memory_window): Likewise.
+	(grub_vbe_get_memory_window): Likewise.
+	(grub_vbe_set_scanline_length): Likewise.
+	(grub_vbe_get_scanline_length): Likewise.
+	(grub_vbe_set_display_start): Likewise.
+	(grub_vbe_get_display_start): Likewise.
+	(grub_vbe_set_palette_data): Likewise.
+	* include/grub/i386/pc/vbe.h: New file.
+
 2005-07-12  Hollis Blanchard  <hollis@penguinppc.org>
 
 	* disk/powerpc/ieee1275/ofdisk.c (grub_ofdisk_open): dprintf the
diff -ruN grub2/conf/i386-pc.rmk grub2.vbe/conf/i386-pc.rmk
--- grub2/conf/i386-pc.rmk	2005-07-10 10:57:49.000000000 +0300
+++ grub2.vbe/conf/i386-pc.rmk	2005-07-15 18:10:05.000000000 +0300
@@ -33,7 +33,8 @@
 	file.h fs.h kernel.h loader.h misc.h mm.h net.h rescue.h symbol.h \
 	term.h types.h machine/biosdisk.h machine/boot.h \
 	machine/console.h machine/init.h machine/memory.h \
-	machine/loader.h partition.h pc_partition.h machine/time.h machine/vga.h
+	machine/loader.h partition.h pc_partition.h machine/time.h machine/vga.h \
+	machine/vbe.h
 kernel_img_CFLAGS = $(COMMON_CFLAGS)
 kernel_img_ASFLAGS = $(COMMON_ASFLAGS)
 kernel_img_LDFLAGS = -nostdlib -Wl,-N,-Ttext,8200
diff -ruN grub2/include/grub/i386/pc/vbe.h grub2.vbe/include/grub/i386/pc/vbe.h
--- grub2/include/grub/i386/pc/vbe.h	1970-01-01 02:00:00.000000000 +0200
+++ grub2.vbe/include/grub/i386/pc/vbe.h	2005-07-17 13:38:11.675679232 +0300
@@ -0,0 +1,184 @@
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2005  Free Software Foundation, Inc.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef GRUB_VBE_MACHINE_HEADER
+#define GRUB_VBE_MACHINE_HEADER	1
+
+#include <grub/symbol.h>
+#include <grub/types.h>
+
+/* Note:
+ 
+   Please refer to VESA BIOS Extension 3.0 Specification for more descriptive
+   meanings of following structures and how they should be used.
+  
+   I have tried to maintain field name comatibility against specification 
+   while following naming convetions used in GRUB.  */
+
+typedef grub_uint32_t grub_vbe_farptr_t;
+typedef grub_uint32_t grub_vbe_physptr_t;
+typedef grub_uint32_t grub_vbe_status_t;
+
+struct grub_vbe_info_block
+{
+  grub_uint8_t signature[4];
+  grub_uint16_t version;
+
+  grub_vbe_farptr_t oem_string_ptr;
+  grub_uint32_t capabilities;
+  grub_vbe_farptr_t video_mode_ptr;
+  grub_uint16_t total_memory;
+
+  grub_uint16_t oem_software_rev;
+  grub_vbe_farptr_t oem_vendor_name_ptr;
+  grub_vbe_farptr_t oem_product_name_ptr;
+  grub_vbe_farptr_t oem_product_rev_ptr;
+
+  grub_uint8_t reserved[222];
+
+  grub_uint8_t oem_data[256];
+} __attribute__ ((packed));
+
+struct grub_vbe_mode_info_block
+{
+  /* Mandory information for all VBE revisions.  */
+  grub_uint16_t mode_attributes;
+  grub_uint8_t win_a_attributes;
+  grub_uint8_t win_b_attributes;
+  grub_uint16_t win_granularity;
+  grub_uint16_t win_size;
+  grub_uint16_t win_a_segment;
+  grub_uint16_t win_b_segment;
+  grub_vbe_farptr_t win_func_ptr;
+  grub_uint16_t bytes_per_scan_line;
+
+  /* Mandory information for VBE 1.2 and above.  */
+  grub_uint16_t x_resolution;
+  grub_uint16_t y_resolution;
+  grub_uint8_t x_char_size;
+  grub_uint8_t y_char_size;
+  grub_uint8_t number_of_planes;
+  grub_uint8_t bits_per_pixel;
+  grub_uint8_t number_of_banks;
+  grub_uint8_t memory_model;
+  grub_uint8_t bank_size;
+  grub_uint8_t number_of_image_pages;
+  grub_uint8_t reserved;
+
+  /* Direct Color fields (required for direct/6 and YUV/7 memory models).  */
+  grub_uint8_t red_mask_size;
+  grub_uint8_t red_field_position;
+  grub_uint8_t green_mask_size;
+  grub_uint8_t green_field_position;
+  grub_uint8_t blue_mask_size;
+  grub_uint8_t blue_field_position;
+  grub_uint8_t rsvd_mask_size;
+  grub_uint8_t rsvd_field_position;
+  grub_uint8_t direct_color_mode_info;
+
+  /* Mandory information for VBE 2.0 and above.  */
+  grub_vbe_physptr_t phys_base_addr;
+  grub_uint32_t reserved2;
+  grub_uint16_t reserved3;
+
+  /* Mandory information for VBE 3.0 and above.  */
+  grub_uint16_t lin_bytes_per_scan_line;
+  grub_uint8_t bnk_number_of_image_pages;
+  grub_uint8_t lin_number_of_image_pages;
+  grub_uint8_t lin_red_mask_size;
+  grub_uint8_t lin_red_field_position;
+  grub_uint8_t lin_green_mask_size;
+  grub_uint8_t lin_green_field_position;
+  grub_uint8_t lin_blue_mask_size;
+  grub_uint8_t lin_blue_field_position;
+  grub_uint8_t lin_rsvd_mask_size;
+  grub_uint8_t lin_rsvd_field_position;
+  grub_uint32_t max_pixel_clock;
+
+  /* Reserved field to make structure to be 256 bytes long, VESA BIOS 
+     Extension 3.0 Specification says to reserve 189 bytes here but 
+     that doesn't make structure to be 256 bytes. So additional one is 
+     added here.  */
+  grub_uint8_t reserved4[189 + 1];
+} __attribute__ ((packed));
+
+struct grub_vbe_crtc_info_block
+{
+  grub_uint16_t horizontal_total;
+  grub_uint16_t horizontal_sync_start;
+  grub_uint16_t horizontal_sync_end;
+  grub_uint16_t vertical_total;
+  grub_uint16_t vertical_sync_start;
+  grub_uint16_t vertical_sync_end;
+  grub_uint8_t flags;
+  grub_uint32_t pixel_clock;
+  grub_uint16_t refresh_rate;
+  grub_uint8_t reserved[40];
+} __attribute__ ((packed));
+
+struct grub_vbe_palette_data
+{
+  grub_uint8_t blue;
+  grub_uint8_t green;
+  grub_uint8_t red;
+  grub_uint8_t aligment;
+} __attribute__ ((packed));
+
+/* Call VESA BIOS 0x4f00 to get VBE Controller Information, return status.  */
+grub_vbe_status_t EXPORT_FUNC(grub_vbe_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_get_mode_info) (grub_uint32_t mode,
+                                                       struct grub_vbe_mode_info_block *mode_info);
+
+/* Call VESA BIOS 0x4f02 to set video mode, return status.  */
+grub_vbe_status_t EXPORT_FUNC(grub_vbe_set_mode) (grub_uint32_t mode,
+                                                  struct grub_vbe_crtc_info_block *crtc_info);
+
+/* Call VESA BIOS 0x4f03 to return current VBE Mode, return status.  */
+grub_vbe_status_t EXPORT_FUNC(grub_vbe_get_mode) (grub_uint32_t *mode);
+
+/* Call VESA BIOS 0x4f05 to set memory window, return status.  */
+grub_vbe_status_t EXPORT_FUNC(grub_vbe_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_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_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_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_set_display_start) (grub_uint32_t x,
+                                                           grub_uint32_t y);
+
+/* Call VESA BIOS 0x4f07 to get display start, return status.  */
+grub_vbe_status_t EXPORT_FUNC(grub_vbe_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_set_palette_data) (grub_uint32_t color_count,
+                                                          grub_uint32_t start_index,
+                                                          struct grub_vbe_palette_data *palette_data);
+
+#endif /* ! GRUB_VBE_MACHINE_HEADER */
diff -ruN grub2/kern/i386/pc/startup.S grub2.vbe/kern/i386/pc/startup.S
--- grub2/kern/i386/pc/startup.S	2004-04-04 16:46:02.000000000 +0300
+++ grub2.vbe/kern/i386/pc/startup.S	2005-07-17 13:28:56.934012784 +0300
@@ -1,6 +1,6 @@
 /*
  *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 1999,2000,2001,2002,2003 Free Software Foundation, Inc.
+ *  Copyright (C) 1999,2000,2001,2002,2003,2005 Free Software Foundation, Inc.
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -219,11 +219,11 @@
  * 31          24         19   16                 7           0
  * ------------------------------------------------------------
  * |             | |B| |A|       | |   |1|0|E|W|A|            |
- * | BASE 31..24 |G|/|0|V| LIMIT |P|DPL|  TYPE   | BASE 23:16 |
+ * | BASE 31..24 |G|/|L|V| LIMIT |P|DPL|  TYPE   | BASE 23:16 |  4
  * |             | |D| |L| 19..16| |   |1|1|C|R|A|            |
  * ------------------------------------------------------------
  * |                             |                            |
- * |        BASE 15..0           |       LIMIT 15..0          |
+ * |        BASE 15..0           |       LIMIT 15..0          |  0
  * |                             |                            |
  * ------------------------------------------------------------
  *
@@ -236,19 +236,31 @@
 	.word	0, 0
 	.byte	0, 0, 0, 0
 
-	/* code segment */
+	/* -- code segment --
+	 * base = 0x00000000, limit = 0xFFFFF (4 KiB Granularity), present
+	 * type = 32bit code execute/read, DPL = 0
+	 */
 	.word	0xFFFF, 0
 	.byte	0, 0x9A, 0xCF, 0
 
-	/* data segment */
+	/* -- data segment --
+	 * base = 0x00000000, limit 0xFFFFF (4 KiB Granularity), present
+	 * type = 32 bit data read/write, DPL = 0 
+	 */
 	.word	0xFFFF, 0
 	.byte	0, 0x92, 0xCF, 0
 
-	/* 16 bit real mode CS */
+	/* -- 16 bit real mode CS --
+	 * base = 0x00000000, limit 0x0FFFF (1 B Granularity), present
+	 * type = 16 bit code execute/read only/conforming, DPL = 0
+	 */
 	.word	0xFFFF, 0
 	.byte	0, 0x9E, 0, 0
 
-	/* 16 bit real mode DS */
+	/* -- 16 bit real mode DS --
+	 * base = 0x00000000, limit 0x0FFFF (1 B Granularity), present
+	 * type = 16 bit data read/write, DPL = 0
+	 */
 	.word	0xFFFF, 0
 	.byte	0, 0x92, 0, 0
 
@@ -1594,3 +1606,415 @@
 	popl	%ebx
 	popl	%ebp
 	ret
+
+/*
+ * grub_vbe_status_t grub_vbe_get_controller_info (struct grub_vbe_info_block *controller_info)
+ *
+ * Register allocations for parameters:
+ * %eax		*controller_info
+ */
+FUNCTION(grub_vbe_get_controller_info)
+	pushl	%ebp
+	pushl	%edi
+
+	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.  */
+	
+	popl	%edi
+	popl	%ebp
+	ret
+
+/*
+ * grub_vbe_status_t grub_vbe_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_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_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_set_mode)
+	pushl	%ebp
+	pushl	%ebx
+
+	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	%ebx
+	popl	%ebp
+	ret
+
+/*
+ * grub_vbe_status_t grub_vbe_get_mode (grub_uint32_t *mode)
+ *
+ * Register allocations for parameters:
+ * %eax		*mode
+ */
+FUNCTION(grub_vbe_get_mode)
+	pushl   %ebp
+	pushl   %ebx
+	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    %ebx
+	popl    %ebp
+	ret
+
+/*
+ * grub_vbe_status_t grub_vbe_set_memory_window (grub_uint32_t window,
+ *						 grub_uint32_t position);
+ *
+ * Register allocations for parameters:
+ * %eax		window
+ * %edx		position
+ */
+FUNCTION(grub_vbe_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_get_memory_window (grub_uint32_t window,
+ * 						 grub_uint32_t *position);
+ *
+ * Register allocations for parameters:
+ * %eax		window
+ * %edx		*position
+ */
+FUNCTION(grub_vbe_get_memory_window)
+	pushl   %ebp
+	pushl   %ebx
+	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    %ebx
+	popl    %ebp
+	ret
+
+/*
+ * grub_vbe_status_t grub_vbe_set_scanline_length (grub_uint32_t length)
+ *
+ * Register allocations for parameters:
+ * %eax		length
+ */
+FUNCTION(grub_vbe_set_scanline_length)
+	pushl	%ebp
+	pushl	%ebx
+
+	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	%ebx
+	popl	%ebp
+	ret
+
+/*
+ * grub_vbe_status_t grub_vbe_get_scanline_length (grub_uint32_t *length)
+ *
+ * Register allocations for parameters:
+ * %eax		*length
+ */
+FUNCTION(grub_vbe_get_scanline_length)
+	pushl   %ebp
+	pushl   %ebx
+	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    %ebx
+	popl    %ebp
+	ret
+
+/*
+ * grub_vbe_status_t grub_vbe_set_display_start (grub_uint32_t x,
+ *						 grub_uint32_t y)
+ *
+ * Register allocations for parameters:
+ * %eax		x
+ * %edx		y
+ */
+FUNCTION(grub_vbe_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_get_display_start (grub_uint32_t *x,
+ *						 grub_uint32_t *y)
+ *
+ * Register allocations for parameters:
+ * %eax		*x
+ * %edx		*y
+ */
+FUNCTION(grub_vbe_get_display_start)
+	pushl   %ebp
+	pushl   %ebx
+	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    %ebx
+	popl    %ebp
+	ret
+
+/*
+ * grub_vbe_status_t grub_vbe_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_set_palette_data)
+	pushl	%ebp
+	pushl	%ebx
+
+	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	%ebx
+	popl	%ebp
+	ret

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Kernel support for VESA Bios Extension
  2005-07-15 16:47       ` Vesa Jääskeläinen
@ 2005-07-15 18:55         ` Yoshinori K. Okuji
  2005-07-16 18:43           ` Marco Gerards
  0 siblings, 1 reply; 8+ messages in thread
From: Yoshinori K. Okuji @ 2005-07-15 18:55 UTC (permalink / raw)
  To: The development of GRUB 2

On Friday 15 July 2005 18:47, Vesa Jääskeläinen wrote:
> > After the comment add a `.' and two spaces instead of one.  This is
> > true for all comments.
>
> Odd... Especially that two spaces. But I don't want to start another
> "war" with this ;)... So I try to adapt.

According to the GNU Coding Standards, two spaces are useful for Emacs to 
identify the end of a text. I myself do not see any problem without two 
spaces in Emacs, so I agree that it looks strange. But... this is what the 
GNU Coding Standards says, and I have no problem with this rule, so we follow 
it.

> It can of course be removed completely in the commit if required to be.

You don't have to remove it. As far as I know, copyright is not applied to 
this kind of information (at least in USA), because this is merely 
information but not a so-called "creative work". So, regardless of the 
origin, you can use this information.

Okuji



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Kernel support for VESA Bios Extension
  2005-07-15 18:55         ` Yoshinori K. Okuji
@ 2005-07-16 18:43           ` Marco Gerards
  0 siblings, 0 replies; 8+ messages in thread
From: Marco Gerards @ 2005-07-16 18:43 UTC (permalink / raw)
  To: The development of GRUB 2

"Yoshinori K. Okuji" <okuji@enbug.org> writes:

> On Friday 15 July 2005 18:47, Vesa Jääskeläinen wrote:
>> > After the comment add a `.' and two spaces instead of one.  This is
>> > true for all comments.
>>
>> Odd... Especially that two spaces. But I don't want to start another
>> "war" with this ;)... So I try to adapt.
>
> According to the GNU Coding Standards, two spaces are useful for Emacs to 
> identify the end of a text. I myself do not see any problem without two 
> spaces in Emacs, so I agree that it looks strange. But... this is what the 
> GNU Coding Standards says, and I have no problem with this rule, so we follow 
> it.

I do remember having some problems in emacs if this is not used.  But
I don't remember what the exact problems are.  To avoid further
problems and because of the GCS I really prefer two spaces in both
comments and changelog entries.

--
Marco




^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2005-07-16 18:54 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-07-14 18:36 [PATCH] Kernel support for VESA Bios Extension Vesa Jääskeläinen
2005-07-14 19:02 ` Marco Gerards
2005-07-14 20:36   ` Vesa Jääskeläinen
2005-07-14 21:45     ` Marco Gerards
2005-07-15 10:53       ` Yoshinori K. Okuji
2005-07-15 16:47       ` Vesa Jääskeläinen
2005-07-15 18:55         ` Yoshinori K. Okuji
2005-07-16 18:43           ` Marco Gerards

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.