]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg LoadLinuxLib: Use kernel's EFI entry point where available
authorjljusten <jljusten@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 14 Feb 2013 19:21:39 +0000 (19:21 +0000)
committerjljusten <jljusten@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 14 Feb 2013 19:21:39 +0000 (19:21 +0000)
Usage of the EFI entry point was made feasible in the kernel
x64 boot protocol 2.12 where a 32-bit & 64-bit entry point
became well defined.

http://git.kernel.org/linus/09c205af

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14132 6f19259b-4bc3-4df7-8a09-765794883524

OvmfPkg/Library/LoadLinuxLib/Ia32/JumpToKernel.S
OvmfPkg/Library/LoadLinuxLib/Ia32/JumpToKernel.asm
OvmfPkg/Library/LoadLinuxLib/Linux.c
OvmfPkg/Library/LoadLinuxLib/LoadLinuxLib.h
OvmfPkg/Library/LoadLinuxLib/X64/JumpToKernel.S
OvmfPkg/Library/LoadLinuxLib/X64/JumpToKernel.asm

index b8cd4ca515bee248d6a62822f49c0b12d8fcb136..f7440f74c401501026d58317e2d118f476ab0819 100644 (file)
@@ -1,6 +1,6 @@
 #------------------------------------------------------------------------------\r
 #\r
 #------------------------------------------------------------------------------\r
 #\r
-# Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
 #\r
 # This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 #\r
 # This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
@@ -13,6 +13,7 @@
 #------------------------------------------------------------------------------\r
 \r
 ASM_GLOBAL ASM_PFX(JumpToKernel)\r
 #------------------------------------------------------------------------------\r
 \r
 ASM_GLOBAL ASM_PFX(JumpToKernel)\r
+ASM_GLOBAL ASM_PFX(JumpToUefiKernel)\r
 \r
 #------------------------------------------------------------------------------\r
 # VOID\r
 \r
 #------------------------------------------------------------------------------\r
 # VOID\r
@@ -27,3 +28,19 @@ ASM_PFX(JumpToKernel):
     calll   0x4(%esp)\r
     ret\r
 \r
     calll   0x4(%esp)\r
     ret\r
 \r
+#------------------------------------------------------------------------------\r
+# VOID\r
+# EFIAPI\r
+# JumpToUefiKernel (\r
+#   EFI_HANDLE ImageHandle,\r
+#   EFI_SYSTEM_TABLE *SystemTable,\r
+#   VOID *KernelBootParams,\r
+#   VOID *KernelStart\r
+#   );\r
+#------------------------------------------------------------------------------\r
+ASM_PFX(JumpToUefiKernel):\r
+    movl    0xc(%esp), %eax\r
+    movl    0x264(%eax), %eax\r
+    addl    0x10(%esp), %eax\r
+    jmp     %eax\r
+\r
index a8f3965f9a8a9ea7452ba98e250100aa2b689434..21d0c4e7240bb7eb3e8847810e22d8f5fd2afae7 100644 (file)
@@ -1,6 +1,6 @@
 ;------------------------------------------------------------------------------\r
 ;\r
 ;------------------------------------------------------------------------------\r
 ;\r
-; Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
+; Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
 ;\r
 ; This program and the accompanying materials\r
 ; are licensed and made available under the terms and conditions of the BSD License\r
 ;\r
 ; This program and the accompanying materials\r
 ; are licensed and made available under the terms and conditions of the BSD License\r
@@ -32,4 +32,23 @@ JumpToKernel PROC
 \r
 JumpToKernel ENDP\r
 \r
 \r
 JumpToKernel ENDP\r
 \r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; JumpToUefiKernel (\r
+;   EFI_HANDLE ImageHandle,\r
+;   EFI_SYSTEM_TABLE *SystemTable,\r
+;   VOID *KernelBootParams,\r
+;   VOID *KernelStart\r
+;   );\r
+;------------------------------------------------------------------------------\r
+JumpToUefiKernel PROC\r
+\r
+    mov     eax, [esp + 12]\r
+    mov     eax, [eax + 264h]\r
+    add     eax, [esp + 16]\r
+    jmp     eax\r
+\r
+JumpToUefiKernel ENDP\r
+\r
 END\r
 END\r
index 1da5507ff12ee19ca14b4f607ad999d4ff80445f..c714225e55bfff6173e35330523bd7fa5453c4d5 100644 (file)
@@ -604,14 +604,11 @@ SetupGraphics (
 STATIC\r
 EFI_STATUS\r
 SetupLinuxBootParams (\r
 STATIC\r
 EFI_STATUS\r
 SetupLinuxBootParams (\r
-  IN VOID                   *Kernel,\r
   IN OUT struct boot_params *Bp\r
   )\r
 {\r
   SetupGraphics (Bp);\r
 \r
   IN OUT struct boot_params *Bp\r
   )\r
 {\r
   SetupGraphics (Bp);\r
 \r
-  Bp->hdr.code32_start = (UINT32)(UINTN) Kernel;\r
-\r
   SetupLinuxMemmap (Bp);\r
 \r
   return EFI_SUCCESS;\r
   SetupLinuxMemmap (Bp);\r
 \r
   return EFI_SUCCESS;\r
@@ -644,7 +641,19 @@ LoadLinux (
 \r
   InitLinuxDescriptorTables ();\r
 \r
 \r
   InitLinuxDescriptorTables ();\r
 \r
-  SetupLinuxBootParams (Kernel, (struct boot_params*) KernelSetup);\r
+  Bp->hdr.code32_start = (UINT32)(UINTN) Kernel;\r
+  if (Bp->hdr.version >= 0x20c && Bp->hdr.handover_offset &&\r
+      (Bp->hdr.load_flags & (sizeof (UINTN) == 4 ? BIT2 : BIT3))) {\r
+    DEBUG ((EFI_D_INFO, "Jumping to kernel EFI handover point at ofs %x\n", Bp->hdr.handover_offset));\r
+\r
+    DisableInterrupts ();\r
+    JumpToUefiKernel ((VOID*) gImageHandle, (VOID*) gST, KernelSetup, Kernel);\r
+  }\r
+\r
+  //\r
+  // Old kernels without EFI handover protocol\r
+  //\r
+  SetupLinuxBootParams (KernelSetup);\r
 \r
   DEBUG ((EFI_D_INFO, "Jumping to kernel\n"));\r
   DisableInterrupts ();\r
 \r
   DEBUG ((EFI_D_INFO, "Jumping to kernel\n"));\r
   DisableInterrupts ();\r
index f8697972626beca2683f46363065cee9b2c58319..045cbf9b2f1e6a5054eb4a90b4bdb4401a05babc 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Boot UEFI Linux.\r
 \r
 /** @file\r
   Boot UEFI Linux.\r
 \r
-  Copyright (c) 2008 - 2011, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2008 - 2013, Intel Corporation. All rights reserved.<BR>\r
 \r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
 \r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
@@ -36,6 +36,15 @@ JumpToKernel (
   VOID *KernelBootParams\r
   );\r
 \r
   VOID *KernelBootParams\r
   );\r
 \r
+VOID\r
+EFIAPI\r
+JumpToUefiKernel (\r
+  EFI_HANDLE ImageHandle,\r
+  EFI_SYSTEM_TABLE *SystemTable,\r
+  VOID *KernelBootParams,\r
+  VOID *KernelStart\r
+  );\r
+\r
 VOID\r
 InitLinuxDescriptorTables (\r
   VOID\r
 VOID\r
 InitLinuxDescriptorTables (\r
   VOID\r
index edc6e7bd707dd107a0b37b32b721c4166562eea6..056e3c013f8ed1199d3b0d878ab604473dd7393c 100644 (file)
@@ -13,6 +13,7 @@
 #------------------------------------------------------------------------------\r
 \r
 ASM_GLOBAL ASM_PFX(JumpToKernel)\r
 #------------------------------------------------------------------------------\r
 \r
 ASM_GLOBAL ASM_PFX(JumpToKernel)\r
+ASM_GLOBAL ASM_PFX(JumpToUefiKernel)\r
 \r
 #------------------------------------------------------------------------------\r
 # VOID\r
 \r
 #------------------------------------------------------------------------------\r
 # VOID\r
@@ -67,3 +68,24 @@ ASM_PFX(JumpToKernel):
     ret\r
 .code64\r
 \r
     ret\r
 .code64\r
 \r
+#------------------------------------------------------------------------------\r
+# VOID\r
+# EFIAPI\r
+# JumpToUefiKernel (\r
+#   EFI_HANDLE ImageHandle,        // rcx\r
+#   EFI_SYSTEM_TABLE *SystemTable, // rdx\r
+#   VOID *KernelBootParams,        // r8\r
+#   VOID *KernelStart              // r9\r
+#   );\r
+#------------------------------------------------------------------------------\r
+ASM_PFX(JumpToUefiKernel):\r
+    movq    %rcx, %rdi\r
+    movq    %rdx, %rsi\r
+    movq    %r8, %rdx\r
+    xor     %rax, %rax\r
+    movl    0x264(%r8), %eax\r
+    addq    %rax, %r9\r
+    addq    $0x200, %r9\r
+    callq   %r9\r
+    ret\r
+\r
index bcf6260e1df1c6a636b5bea359b48c95c1799e6b..fc07eab68415e7d2d26d5b59c867fccfab9e0264 100644 (file)
@@ -68,4 +68,28 @@ JumpToKernel PROC
 \r
 JumpToKernel ENDP\r
 \r
 \r
 JumpToKernel ENDP\r
 \r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; JumpToUefiKernel (\r
+;   EFI_HANDLE ImageHandle,        // rcx\r
+;   EFI_SYSTEM_TABLE *SystemTable, // rdx\r
+;   VOID *KernelBootParams         // r8\r
+;   VOID *KernelStart,             // r9\r
+;   );\r
+;------------------------------------------------------------------------------\r
+JumpToUefiKernel PROC\r
+\r
+    mov     rdi, rcx\r
+    mov     rsi, rdx\r
+    mov     rdx, r8\r
+    xor     rax, rax\r
+    mov     eax, [r8 + 264h]\r
+    add     r9, rax\r
+    add     r9, 200h\r
+    call    r9\r
+    ret\r
+\r
+JumpToUefiKernel ENDP\r
+\r
 END\r
 END\r