summaryrefslogtreecommitdiff
path: root/IntelFrameworkModulePkg/Csm/LegacyBiosDxe
diff options
context:
space:
mode:
authorli-elvin <li-elvin@6f19259b-4bc3-4df7-8a09-765794883524>2012-03-01 11:16:42 +0000
committerli-elvin <li-elvin@6f19259b-4bc3-4df7-8a09-765794883524>2012-03-01 11:16:42 +0000
commit81c0d6e9a7f78bb43e9a1045ea084e728fa76983 (patch)
tree49fa82431a59a183b7578e560bd8ca0aedc8fffa /IntelFrameworkModulePkg/Csm/LegacyBiosDxe
parent916666c009ebd50500f8c3ed025e688dfb9be05e (diff)
downloadedk2-platforms-81c0d6e9a7f78bb43e9a1045ea084e728fa76983.tar.xz
When CSM uses EFI_SEGMENT and EFI_OFFSET to call CSM16 function, some CSM16 use es:[offset + 0xabcd] to get data passed from CSM32, offset + 0xabcd could exceed 0xFFFF which is invalid in real mode. So added NORMALIZE_EFI_SEGMENT and NORMALIZE_EFI_OFFSET to keep offset as small as possible to avoid this issue during CSM16 function call.
Signed-off-by: li-elvin Reviewed-by: rsun3 git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13074 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'IntelFrameworkModulePkg/Csm/LegacyBiosDxe')
-rw-r--r--IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBbs.c6
-rw-r--r--IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBiosInterface.h10
-rw-r--r--IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBootSupport.c6
3 files changed, 15 insertions, 7 deletions
diff --git a/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBbs.c b/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBbs.c
index c15e59972d..6ee43ad676 100644
--- a/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBbs.c
+++ b/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBbs.c
@@ -1,6 +1,6 @@
/** @file
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions
@@ -352,8 +352,8 @@ LegacyBiosGetBbsInfo (
// Pass in handoff data
//
TempData = (UINTN) EfiToLegacy16BootTable;
- Regs.X.ES = EFI_SEGMENT ((UINT32) TempData);
- Regs.X.BX = EFI_OFFSET ((UINT32) TempData);
+ Regs.X.ES = NORMALIZE_EFI_SEGMENT ((UINT32) TempData);
+ Regs.X.BX = NORMALIZE_EFI_OFFSET ((UINT32) TempData);
Private->LegacyBios.FarCall86 (
This,
diff --git a/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBiosInterface.h b/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBiosInterface.h
index 71522a0ba4..a42e847250 100644
--- a/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBiosInterface.h
+++ b/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBiosInterface.h
@@ -1,6 +1,6 @@
/** @file
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions
@@ -94,6 +94,14 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#define PROTECTED_MODE_BASE_VECTOR_SLAVE 0x70
//
+// When we call CSM16 functions, some CSM16 use es:[offset + 0xabcd] to get data passed from CSM32,
+// offset + 0xabcd could overflow which exceeds 0xFFFF which is invalid in real mode.
+// So this will keep offset as small as possible to avoid offset overflow in real mode.
+//
+#define NORMALIZE_EFI_SEGMENT(_Adr) (UINT16) (((UINTN) (_Adr)) >> 4)
+#define NORMALIZE_EFI_OFFSET(_Adr) (UINT16) (((UINT16) ((UINTN) (_Adr))) & 0xf)
+
+//
// Trace defines
//
//
diff --git a/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBootSupport.c b/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBootSupport.c
index 04013d9708..4e16880bd6 100644
--- a/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBootSupport.c
+++ b/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBootSupport.c
@@ -1,6 +1,6 @@
/** @file
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions
@@ -1160,8 +1160,8 @@ GenericLegacyBoot (
//
// Pass in handoff data
//
- Regs.X.ES = EFI_SEGMENT ((UINTN)EfiToLegacy16BootTable);
- Regs.X.BX = EFI_OFFSET ((UINTN)EfiToLegacy16BootTable);
+ Regs.X.ES = NORMALIZE_EFI_SEGMENT ((UINTN)EfiToLegacy16BootTable);
+ Regs.X.BX = NORMALIZE_EFI_OFFSET ((UINTN)EfiToLegacy16BootTable);
Private->LegacyBios.FarCall86 (
This,