Workarounds unsupported feature in Apple's CC. Since trampolines
switch to 32-bit mode anyway it should introduce no additional
limitation

-- 
Regards
Vladimir 'phcoder' Serbinenko
diff --git a/loader/i386/linux_trampoline.S b/loader/i386/linux_trampoline.S
index eddaaf2..e2cd6ec 100644
--- a/loader/i386/linux_trampoline.S
+++ b/loader/i386/linux_trampoline.S
@@ -30,7 +30,22 @@ VARIABLE(grub_linux_trampoline_start)
 	call base
 base:	
 	pop %rsi
+
+#ifdef APPLE_CC	
+	lea (cont1 - base) (%esi, 1), %rax
+	mov %eax, (jump_vector - base) (%esi, 1)
+
+	lea (gdt - base) (%esi, 1), %rax
+	mov %rax, (gdtaddr - base) (%esi, 1)
+	
+	/* Switch to compatibility mode. */
+
+	lidt (idtdesc - base) (%esi, 1)
+	lgdt (gdtdesc - base) (%esi, 1)
 	
+	/* Update %cs. Thanks to David Miller for pointing this mistake out. */
+	ljmp *(jump_vector - base) (%esi, 1)
+#else
 	lea (cont1 - base) (%rsi, 1), %rax
 	mov %eax, (jump_vector - base) (%rsi, 1)
 
@@ -44,6 +59,8 @@ base:
 	
 	/* Update %cs. Thanks to David Miller for pointing this mistake out. */
 	ljmp *(jump_vector - base) (%rsi, 1)
+#endif
+ 	
 cont1:
 	.code32
 
diff --git a/loader/i386/xnu_helper.S b/loader/i386/xnu_helper.S
index ad9c8f6..229c8fe 100644
--- a/loader/i386/xnu_helper.S
+++ b/loader/i386/xnu_helper.S
@@ -94,11 +94,28 @@ VARIABLE(grub_xnu_heap_size)
 	movsl
 
 	mov %rax, %rsi
+#ifdef APPLE_CC
+	add $(cont0-base), %eax
+#else
 	add $(cont0-base), %rax
+#endif
 	jmp *%rax
 
 cont0:	
+#ifdef APPLE_CC
+	lea (cont1 - base) (%esi, 1), %eax
+	mov %eax, (jump_vector - base) (%esi, 1)
+
+	lea (gdt - base) (%esi, 1), %eax
+	mov %eax, (gdt_addr - base) (%esi, 1)
+	
+	/* Switch to compatibility mode. */
 
+	lgdt (gdtdesc - base) (%esi, 1)
+	
+	/* Update %cs. Thanks to David Miller for pointing this mistake out. */
+	ljmp *(jump_vector - base) (%esi,1)
+#else
 	lea (cont1 - base) (%rsi, 1), %rax
 	mov %eax, (jump_vector - base) (%rsi, 1)
 
@@ -111,6 +128,8 @@ cont0:
 	
 	/* Update %cs. Thanks to David Miller for pointing this mistake out. */
 	ljmp *(jump_vector - base) (%rsi, 1)
+#endif
+	
 cont1:
 	.code32
 
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to