summaryrefslogtreecommitdiff
path: root/EdkModulePkg/Universal
diff options
context:
space:
mode:
authorxli24 <xli24@6f19259b-4bc3-4df7-8a09-765794883524>2007-04-11 03:15:15 +0000
committerxli24 <xli24@6f19259b-4bc3-4df7-8a09-765794883524>2007-04-11 03:15:15 +0000
commit735561c27f91ea1a729492d17dd0efbf021645b0 (patch)
tree48c264e1d0dd0f5b97e6ce79d74113484e7e24d1 /EdkModulePkg/Universal
parent7e9f4e1d8e0b0d145c3a91fdbfb349adb5f084e0 (diff)
downloadedk2-platforms-735561c27f91ea1a729492d17dd0efbf021645b0.tar.xz
Allocate memory in DebugSupport beforehand, in order to avoid calling memory allocation services in high TPL level.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2556 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'EdkModulePkg/Universal')
-rw-r--r--EdkModulePkg/Universal/DebugSupport/Dxe/Ia32/AsmFuncs.S2
-rw-r--r--EdkModulePkg/Universal/DebugSupport/Dxe/Ia32/AsmFuncs.asm2
-rw-r--r--EdkModulePkg/Universal/DebugSupport/Dxe/Ia32/plDebugSupport.c90
-rw-r--r--EdkModulePkg/Universal/DebugSupport/Dxe/Ia32/plDebugSupport.h11
-rw-r--r--EdkModulePkg/Universal/DebugSupport/Dxe/x64/AsmFuncs.asm5
-rw-r--r--EdkModulePkg/Universal/DebugSupport/Dxe/x64/plDebugSupport.c80
-rw-r--r--EdkModulePkg/Universal/DebugSupport/Dxe/x64/plDebugSupport.h11
7 files changed, 117 insertions, 84 deletions
diff --git a/EdkModulePkg/Universal/DebugSupport/Dxe/Ia32/AsmFuncs.S b/EdkModulePkg/Universal/DebugSupport/Dxe/Ia32/AsmFuncs.S
index 18cb47b459..3063e82626 100644
--- a/EdkModulePkg/Universal/DebugSupport/Dxe/Ia32/AsmFuncs.S
+++ b/EdkModulePkg/Universal/DebugSupport/Dxe/Ia32/AsmFuncs.S
@@ -55,7 +55,7 @@ ASM_PFX(WriteInterruptFlag):
and $0x200,%eax
shr $0x9,%eax
mov 0x8(%ebp),%ecx
- or %ecx,%ecx
+ or %cl,%cl
jne ASM_PFX(WriteInterruptFlag+0x17)
cli
jmp ASM_PFX(WriteInterruptFlag+0x18)
diff --git a/EdkModulePkg/Universal/DebugSupport/Dxe/Ia32/AsmFuncs.asm b/EdkModulePkg/Universal/DebugSupport/Dxe/Ia32/AsmFuncs.asm
index 6dd114ba75..28a43cfe63 100644
--- a/EdkModulePkg/Universal/DebugSupport/Dxe/Ia32/AsmFuncs.asm
+++ b/EdkModulePkg/Universal/DebugSupport/Dxe/Ia32/AsmFuncs.asm
@@ -164,7 +164,7 @@ WriteInterruptFlag PROC C PUBLIC State:DWORD
and eax, 200h
shr eax, 9
mov ecx, State
- .IF ecx == 0
+ .IF cl == 0
cli
.ELSE
sti
diff --git a/EdkModulePkg/Universal/DebugSupport/Dxe/Ia32/plDebugSupport.c b/EdkModulePkg/Universal/DebugSupport/Dxe/Ia32/plDebugSupport.c
index 88b8c5a14a..1eaa5ec591 100644
--- a/EdkModulePkg/Universal/DebugSupport/Dxe/Ia32/plDebugSupport.c
+++ b/EdkModulePkg/Universal/DebugSupport/Dxe/Ia32/plDebugSupport.c
@@ -46,41 +46,32 @@ Returns:
{
UINT8 *StubCopy;
+ StubCopy = *Stub;
+
//
- // First, allocate a new buffer and copy the stub code into it
+ // Fixup the stub code for this vector
//
- *Stub = AllocatePool (StubSize);
- if (*Stub != NULL) {
- StubCopy = *Stub;
- CopyMem (StubCopy, InterruptEntryStub, StubSize);
-
- //
- // Next fixup the stub code for this vector
- //
-
- // The stub code looks like this:
- //
- // 00000000 89 25 00000004 R mov AppEsp, esp ; save stack top
- // 00000006 BC 00008014 R mov esp, offset DbgStkBot ; switch to debugger stack
- // 0000000B 6A 00 push 0 ; push vector number - will be modified before installed
- // 0000000D E9 db 0e9h ; jump rel32
- // 0000000E 00000000 dd 0 ; fixed up to relative address of CommonIdtEntry
- //
-
- //
- // poke in the exception type so the second push pushes the exception type
- //
- StubCopy[0x0c] = (UINT8) ExceptionType;
-
- //
- // fixup the jump target to point to the common entry
- //
- *(UINT32 *) &StubCopy[0x0e] = (UINT32) CommonIdtEntry - (UINT32) &StubCopy[StubSize];
-
- return EFI_SUCCESS;
- }
- return EFI_OUT_OF_RESOURCES;
+ // The stub code looks like this:
+ //
+ // 00000000 89 25 00000004 R mov AppEsp, esp ; save stack top
+ // 00000006 BC 00008014 R mov esp, offset DbgStkBot ; switch to debugger stack
+ // 0000000B 6A 00 push 0 ; push vector number - will be modified before installed
+ // 0000000D E9 db 0e9h ; jump rel32
+ // 0000000E 00000000 dd 0 ; fixed up to relative address of CommonIdtEntry
+ //
+
+ //
+ // poke in the exception type so the second push pushes the exception type
+ //
+ StubCopy[0x0c] = (UINT8) ExceptionType;
+
+ //
+ // fixup the jump target to point to the common entry
+ //
+ *(UINT32 *) &StubCopy[0x0e] = (UINT32) CommonIdtEntry - (UINT32) &StubCopy[StubSize];
+
+ return EFI_SUCCESS;
}
STATIC
@@ -151,8 +142,6 @@ Returns:
OldIntFlagState = WriteInterruptFlag (0);
WriteIdt (ExceptionType, &(IdtEntryTable[ExceptionType].OrigDesc));
- FreePool ((VOID *) (UINTN) IdtEntryTable[ExceptionType].StubEntry);
- ZeroMem (&IdtEntryTable[ExceptionType], sizeof (IDT_ENTRY));
WriteInterruptFlag (OldIntFlagState);
return EFI_SUCCESS;
@@ -362,16 +351,37 @@ Returns:
--*/
{
+ EFI_EXCEPTION_TYPE ExceptionType;
+
if (!FxStorSupport ()) {
return EFI_UNSUPPORTED;
- } else {
- IdtEntryTable = AllocateZeroPool (sizeof (IDT_ENTRY) * NUM_IDT_ENTRIES);
- if (IdtEntryTable != NULL) {
- return EFI_SUCCESS;
- } else {
- return EFI_OUT_OF_RESOURCES;
+ }
+
+ IdtEntryTable = AllocateZeroPool (sizeof (IDT_ENTRY) * NUM_IDT_ENTRIES);
+ if (IdtEntryTable == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ for (ExceptionType = 0; ExceptionType < NUM_IDT_ENTRIES; ExceptionType++) {
+ IdtEntryTable[ExceptionType].StubEntry = (DEBUG_PROC) (UINTN) AllocatePool (StubSize);
+ if (IdtEntryTable[ExceptionType].StubEntry == NULL) {
+ goto ErrorCleanup;
}
+
+ CopyMem ((VOID *)(UINTN)IdtEntryTable[ExceptionType].StubEntry, InterruptEntryStub, StubSize);
}
+ return EFI_SUCCESS;
+
+ErrorCleanup:
+
+ for (ExceptionType = 0; ExceptionType < NUM_IDT_ENTRIES; ExceptionType++) {
+ if (IdtEntryTable[ExceptionType].StubEntry != NULL) {
+ FreePool ((VOID *)(UINTN)IdtEntryTable[ExceptionType].StubEntry);
+ }
+ }
+ FreePool (IdtEntryTable);
+
+ return EFI_OUT_OF_RESOURCES;
}
EFI_STATUS
diff --git a/EdkModulePkg/Universal/DebugSupport/Dxe/Ia32/plDebugSupport.h b/EdkModulePkg/Universal/DebugSupport/Dxe/Ia32/plDebugSupport.h
index cb1a6c7c82..ce8a3fedae 100644
--- a/EdkModulePkg/Universal/DebugSupport/Dxe/Ia32/plDebugSupport.h
+++ b/EdkModulePkg/Universal/DebugSupport/Dxe/Ia32/plDebugSupport.h
@@ -28,11 +28,18 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
typedef UINT64 DESCRIPTOR;
+typedef
+VOID
+(*DEBUG_PROC) (
+ VOID
+ )
+;
+
typedef struct {
DESCRIPTOR OrigDesc;
- VOID (*OrigVector) (VOID);
+ DEBUG_PROC OrigVector;
DESCRIPTOR NewDesc;
- VOID (*StubEntry) (VOID);
+ DEBUG_PROC StubEntry;
VOID (*RegisteredCallback) ();
} IDT_ENTRY;
diff --git a/EdkModulePkg/Universal/DebugSupport/Dxe/x64/AsmFuncs.asm b/EdkModulePkg/Universal/DebugSupport/Dxe/x64/AsmFuncs.asm
index 10e998fc56..810de909a8 100644
--- a/EdkModulePkg/Universal/DebugSupport/Dxe/x64/AsmFuncs.asm
+++ b/EdkModulePkg/Universal/DebugSupport/Dxe/x64/AsmFuncs.asm
@@ -156,9 +156,8 @@ GetIdtr PROC PUBLIC
push rbp
mov rbp, rsp
- sub rsp, 8h
- sidt QWORD PTR [rbp - 6]
- mov rax, QWORD PTR [rbp - 4]
+ sidt QWORD PTR [rbp - 0ah]
+ mov rax, QWORD PTR [rbp - 8h]
mov rsp, rbp
pop rbp
diff --git a/EdkModulePkg/Universal/DebugSupport/Dxe/x64/plDebugSupport.c b/EdkModulePkg/Universal/DebugSupport/Dxe/x64/plDebugSupport.c
index 3f12a76d6c..8b907ee6e1 100644
--- a/EdkModulePkg/Universal/DebugSupport/Dxe/x64/plDebugSupport.c
+++ b/EdkModulePkg/Universal/DebugSupport/Dxe/x64/plDebugSupport.c
@@ -46,39 +46,30 @@ Returns:
{
UINT8 *StubCopy;
+ StubCopy = *Stub;
+
//
- // First, allocate a new buffer and copy the stub code into it
+ // Fixup the stub code for this vector
//
- *Stub = AllocatePool (StubSize);
- if (*Stub != NULL) {
- StubCopy = *Stub;
- CopyMem (StubCopy, InterruptEntryStub, StubSize);
-
- //
- // Next fixup the stub code for this vector
- //
-
- // The stub code looks like this:
- //
- // 00000000 6A 00 push 0 ; push vector number - will be modified before installed
- // 00000002 E9 db 0e9h ; jump rel32
- // 00000003 00000000 dd 0 ; fixed up to relative address of CommonIdtEntry
- //
- //
- // poke in the exception type so the second push pushes the exception type
- //
- StubCopy[0x1] = (UINT8) ExceptionType;
+ // The stub code looks like this:
+ //
+ // 00000000 6A 00 push 0 ; push vector number - will be modified before installed
+ // 00000002 E9 db 0e9h ; jump rel32
+ // 00000003 00000000 dd 0 ; fixed up to relative address of CommonIdtEntry
+ //
- //
- // fixup the jump target to point to the common entry
- //
- *(UINT32 *) &StubCopy[0x3] = (UINT32)((UINTN) CommonIdtEntry - (UINTN) &StubCopy[StubSize]);
+ //
+ // poke in the exception type so the second push pushes the exception type
+ //
+ StubCopy[0x1] = (UINT8) ExceptionType;
- return EFI_SUCCESS;
- }
+ //
+ // fixup the jump target to point to the common entry
+ //
+ *(UINT32 *) &StubCopy[0x3] = (UINT32)((UINTN) CommonIdtEntry - (UINTN) &StubCopy[StubSize]);
- return EFI_OUT_OF_RESOURCES;
+ return EFI_SUCCESS;
}
STATIC
@@ -150,8 +141,6 @@ Returns:
OldIntFlagState = WriteInterruptFlag (0);
WriteIdt (ExceptionType, &(IdtEntryTable[ExceptionType].OrigDesc));
- FreePool ((VOID *) (UINTN) IdtEntryTable[ExceptionType].StubEntry);
- ZeroMem (&IdtEntryTable[ExceptionType], sizeof (IDT_ENTRY));
WriteInterruptFlag (OldIntFlagState);
return EFI_SUCCESS;
@@ -359,16 +348,37 @@ Returns:
--*/
{
+ EFI_EXCEPTION_TYPE ExceptionType;
+
if (!FxStorSupport ()) {
return EFI_UNSUPPORTED;
- } else {
- IdtEntryTable = AllocateZeroPool (sizeof (IDT_ENTRY) * NUM_IDT_ENTRIES);
- if (IdtEntryTable != NULL) {
- return EFI_SUCCESS;
- } else {
- return EFI_OUT_OF_RESOURCES;
+ }
+
+ IdtEntryTable = AllocateZeroPool (sizeof (IDT_ENTRY) * NUM_IDT_ENTRIES);
+ if (IdtEntryTable == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ for (ExceptionType = 0; ExceptionType < NUM_IDT_ENTRIES; ExceptionType++) {
+ IdtEntryTable[ExceptionType].StubEntry = (DEBUG_PROC) (UINTN) AllocatePool (StubSize);
+ if (IdtEntryTable[ExceptionType].StubEntry == NULL) {
+ goto ErrorCleanup;
}
+
+ CopyMem ((VOID *)(UINTN)IdtEntryTable[ExceptionType].StubEntry, InterruptEntryStub, StubSize);
}
+ return EFI_SUCCESS;
+
+ErrorCleanup:
+
+ for (ExceptionType = 0; ExceptionType < NUM_IDT_ENTRIES; ExceptionType++) {
+ if (IdtEntryTable[ExceptionType].StubEntry != NULL) {
+ FreePool ((VOID *)(UINTN)IdtEntryTable[ExceptionType].StubEntry);
+ }
+ }
+ FreePool (IdtEntryTable);
+
+ return EFI_OUT_OF_RESOURCES;
}
EFI_STATUS
diff --git a/EdkModulePkg/Universal/DebugSupport/Dxe/x64/plDebugSupport.h b/EdkModulePkg/Universal/DebugSupport/Dxe/x64/plDebugSupport.h
index 68866a83c3..42c849ea41 100644
--- a/EdkModulePkg/Universal/DebugSupport/Dxe/x64/plDebugSupport.h
+++ b/EdkModulePkg/Universal/DebugSupport/Dxe/x64/plDebugSupport.h
@@ -31,11 +31,18 @@ typedef struct {
UINT64 High;
} DESCRIPTOR;
+typedef
+VOID
+(*DEBUG_PROC) (
+ VOID
+ )
+;
+
typedef struct {
DESCRIPTOR OrigDesc;
- VOID (*OrigVector) (VOID);
+ DEBUG_PROC OrigVector;
DESCRIPTOR NewDesc;
- VOID (*StubEntry) (VOID);
+ DEBUG_PROC StubEntry;
VOID (*RegisteredCallback) ();
} IDT_ENTRY;