From 9fc74eaef3f051eb20ec1e276358201f6e832922 Mon Sep 17 00:00:00 2001
From: yaya <you@example.com>
Date: Tue, 30 Jul 2019 20:55:01 +0800
Subject: [PATCH] =?UTF-8?q?=EF=BB=BF.=20=E4=BF=AE=E6=AD=A3color=E5=87=BD?=
 =?UTF-8?q?=E6=95=B0(issues=20#206)=E3=80=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 stage2/asm.S      | 26 +++++++++++++++++---------
 stage2/builtins.c | 30 +++++++++++++++---------------
 stage2/disk_io.c  |  8 ++++----
 3 files changed, 36 insertions(+), 28 deletions(-)

diff --git a/stage2/asm.S b/stage2/asm.S
index 864993b9..08f8e417 100644
--- a/stage2/asm.S
+++ b/stage2/asm.S
@@ -713,6 +713,11 @@ bootup_a20_failure:
 	movl $0x37, %ecx
 	divl %ecx
 	movw %ax, ABS(EXT_C(count_ms))
+	
+	xorb	%bh, %bh
+	movb	$0, %bl
+	movw	$0x1003, %ax
+	int	$0x10
 
 	/* transition to protected mode */
 	call EXT_C(real_to_prot)
@@ -17062,8 +17067,8 @@ VARIABLE(grub_putchar)
 #define next_partition_partition	((*(unsigned long ***)0x8304)[2])
 #define next_partition_type		((*(unsigned long ***)0x8304)[3])
 #define next_partition_start		((*(unsigned long long ***)0x8304)[4])
-#define next_partition_len		((*(unsigned long long ***)0x8304)[11])
-#define next_partition_offset		((*(unsigned long long ***)0x8304)[14])
+#define next_partition_len		((*(unsigned long long ***)0x8304)[5])
+#define next_partition_offset		((*(unsigned long long ***)0x8304)[6])
 #define next_partition_entry		((*(unsigned long ***)0x8304)[7])
 #define next_partition_ext_offset	((*(unsigned long ***)0x8304)[8])
 #define next_partition_buf		((*(char ***)0x8304)[9])
@@ -17082,8 +17087,9 @@ VARIABLE(next_partition_type)
 	.long	0
 VARIABLE(next_partition_start)
 	.long	0
+VARIABLE(next_partition_len)
 	.long	0
-//VARIABLE(next_partition_offset)
+VARIABLE(next_partition_offset)
 	.long	0
 VARIABLE(next_partition_entry)
 	.long	0
@@ -17093,14 +17099,16 @@ VARIABLE(next_partition_buf)
 	.long	0
 VARIABLE(quit_print)
 	.long	0
-VARIABLE(next_partition_len)
-	.long	0
-	.long	0
+//VARIABLE(buf_drive)
+	.long	-1				//reserved
+//VARIABLE(buf_track)
+	.long	-1				//reserved
 VARIABLE(filesystem_type)
 	.long	0
-VARIABLE(next_partition_offset)
-	.long	0
-	.long	0
+//VARIABLE(query_block_entries)//reserved
+	.long	0				//reserved
+//VARIABLE(map_start_sector)//reserved
+	.long	0				//reserved
 	.long	ABS(EXT_C(buf_geom))
 	.long	ABS(EXT_C(tmp_geom))
 	.long	ABS(EXT_C(term_table))
diff --git a/stage2/builtins.c b/stage2/builtins.c
index db59f748..15ddb96d 100644
--- a/stage2/builtins.c
+++ b/stage2/builtins.c
@@ -5641,9 +5641,9 @@ set_partition_hidden_flag (int hidden)
 		next_partition_dest		= current_partition,
 		next_partition_partition	= &part,
 		next_partition_type		= &type,
-		next_partition_start		= (unsigned long long *)(void *)&start,
-		next_partition_len		= (unsigned long long *)(void *)&len,
-		next_partition_offset		= (unsigned long long *)(void *)&offset,
+		next_partition_start		= &start,
+		next_partition_len		= &len,
+		next_partition_offset		= &offset,
 		next_partition_entry		= &entry1,
 		next_partition_ext_offset	= &ext_offset1,
 		next_partition_buf		= mbr,
@@ -5969,9 +5969,9 @@ find_func (char *arg, int flags)
 							next_partition_dest		= 0xFFFFFF,
 							next_partition_partition	= &part,
 							next_partition_type		= &type,
-							next_partition_start		= (unsigned long long *)(void *)&start,
-							next_partition_len		= (unsigned long long *)(void *)&len,
-							next_partition_offset		= (unsigned long long *)(void *)&offset,
+							next_partition_start		= &start,
+							next_partition_len		= &len,
+							next_partition_offset		= &offset,
 							next_partition_entry		= &entry1,
 							next_partition_ext_offset	= &ext_offset1,
 							next_partition_buf		= mbr,
@@ -6848,9 +6848,9 @@ uuid_func (char *argument, int flags)
 		next_partition_dest		= 0xFFFFFF,
 		next_partition_partition	= &part,
 		next_partition_type		= &type,
-		next_partition_start		= (unsigned long long *)(void *)&start,
-		next_partition_len		= (unsigned long long *)(void *)&len,
-		next_partition_offset		= (unsigned long long *)(void *)&offset,
+		next_partition_start		= &start,
+		next_partition_len		= &len,
+		next_partition_offset		= &offset,
 		next_partition_entry		= &entry1,
 		next_partition_ext_offset	= &ext_offset1,
 		next_partition_buf		= mbr,
@@ -12043,9 +12043,9 @@ parttype_func (char *arg, int flags)
 		next_partition_dest		= current_partition,
 		next_partition_partition	= &part,
 		next_partition_type		= &type,
-		next_partition_start		= (unsigned long long *)(void *)&start,
-		next_partition_len		= (unsigned long long *)(void *)&len,
-		next_partition_offset		= (unsigned long long *)(void *)&offset,
+		next_partition_start		= &start,
+		next_partition_len		= &len,
+		next_partition_offset		= &offset,
 		next_partition_entry		= &entry1,
 		next_partition_ext_offset	= &ext_offset1,
 		next_partition_buf		= mbr,
@@ -13084,9 +13084,9 @@ real_root_func (char *arg, int attempt_mnt)
 		next_partition_dest		= 0xFFFFFF,
 		next_partition_partition	= &part,
 		next_partition_type		= &type,
-		next_partition_start		= (unsigned long long *)(void *)&start,
-		next_partition_len		= (unsigned long long *)(void *)&len,
-		next_partition_offset		= (unsigned long long *)(void *)&offset,
+		next_partition_start		= &start,
+		next_partition_len		= &len,
+		next_partition_offset		= &offset,
 		next_partition_entry		= &entry1,
 		next_partition_ext_offset	= &ext_offset1,
 		next_partition_buf		= mbr,
diff --git a/stage2/disk_io.c b/stage2/disk_io.c
index 8682b092..170af3c4 100644
--- a/stage2/disk_io.c
+++ b/stage2/disk_io.c
@@ -942,7 +942,7 @@ next_pc_slice (void)
 
       {
 	unsigned long long tmp_start = (unsigned long long)(unsigned long)(PC_SLICE_START (next_partition_buf, *next_partition_entry));
-	unsigned long long tmp_offset = (unsigned long long)(unsigned long)(*next_partition_offset);
+	unsigned long long tmp_offset = *next_partition_offset;
 	tmp_start += tmp_offset;
 	*next_partition_start = tmp_start;
 	*next_partition_type = PC_SLICE_TYPE (next_partition_buf, *next_partition_entry);
@@ -1117,9 +1117,9 @@ next_part (void)
 	next_partition_dest		= dest_partition;
 	next_partition_partition	= &current_partition;
 	next_partition_type		= &current_slice;
-	next_partition_start		= (unsigned long long *)(void *)&part_start;
-	next_partition_len		= (unsigned long long *)(void *)&part_length;
-	next_partition_offset		= (unsigned long long *)(void *)&part_offset;
+	next_partition_start		= &part_start;
+	next_partition_len		= &part_length;
+	next_partition_offset		= &part_offset;
 	next_partition_entry		= &entry;
 	next_partition_ext_offset	= &ext_offset;
 	next_partition_buf		= mbr;