summaryrefslogtreecommitdiff
path: root/MdePkg/Library
diff options
context:
space:
mode:
Diffstat (limited to 'MdePkg/Library')
-rw-r--r--MdePkg/Library/BaseLib/Ia32/Thunk16.S129
-rw-r--r--MdePkg/Library/BaseLib/Ia32/Thunk16.asm40
-rw-r--r--MdePkg/Library/BasePcdLibNull/PcdLib.c51
-rw-r--r--MdePkg/Library/BaseS3BootScriptLibNull/BootScriptLib.c6
-rw-r--r--MdePkg/Library/DxePcdLib/DxePcdLib.c64
-rw-r--r--MdePkg/Library/PeiMemoryAllocationLib/MemoryAllocationLib.c4
-rw-r--r--MdePkg/Library/PeiPcdLib/PeiPcdLib.c72
-rw-r--r--MdePkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c26
-rw-r--r--MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointer.c89
-rw-r--r--MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf5
-rw-r--r--MdePkg/Library/PeiServicesTablePointerLibKr7/PeiServicesTablePointer.c21
-rw-r--r--MdePkg/Library/SmmMemoryAllocationLib/MemoryAllocationLib.c6
-rw-r--r--MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c151
-rw-r--r--MdePkg/Library/UefiDevicePathLib/DevicePathToText.c68
-rw-r--r--MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.h7
-rw-r--r--MdePkg/Library/UefiMemoryAllocationLib/MemoryAllocationLib.c6
16 files changed, 553 insertions, 192 deletions
diff --git a/MdePkg/Library/BaseLib/Ia32/Thunk16.S b/MdePkg/Library/BaseLib/Ia32/Thunk16.S
index 8356c5a1c..185655eec 100644
--- a/MdePkg/Library/BaseLib/Ia32/Thunk16.S
+++ b/MdePkg/Library/BaseLib/Ia32/Thunk16.S
@@ -24,6 +24,28 @@
ASM_GLOBAL ASM_PFX(m16Start), ASM_PFX(m16Size), ASM_PFX(mThunk16Attr), ASM_PFX(m16Gdt), ASM_PFX(m16GdtrBase), ASM_PFX(mTransition)
ASM_GLOBAL ASM_PFX(InternalAsmThunk16)
+# define the structure of IA32_REGS
+.set _EDI, 0 #size 4
+.set _ESI, 4 #size 4
+.set _EBP, 8 #size 4
+.set _ESP, 12 #size 4
+.set _EBX, 16 #size 4
+.set _EDX, 20 #size 4
+.set _ECX, 24 #size 4
+.set _EAX, 28 #size 4
+.set _DS, 32 #size 2
+.set _ES, 34 #size 2
+.set _FS, 36 #size 2
+.set _GS, 38 #size 2
+.set _EFLAGS, 40 #size 4
+.set _EIP, 44 #size 4
+.set _CS, 48 #size 2
+.set _SS, 50 #size 2
+.set IA32_REGS_SIZE, 52
+
+ .text
+ .code16
+
ASM_PFX(m16Start):
SavedGdt: .space 6
@@ -31,21 +53,22 @@ SavedGdt: .space 6
ASM_PFX(BackFromUserCode):
push %ss
push %cs
- .byte 0x66
- call L_Base1 # push eip
+
+ calll L_Base1 # push eip
L_Base1:
- pushfw # pushfd actually
+ pushfl
cli # disable interrupts
push %gs
push %fs
push %es
push %ds
- pushaw # pushad actually
+ pushal
.byte 0x66, 0xba # mov edx, imm32
ASM_PFX(ThunkAttr): .space 4
testb $THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15, %dl
jz 1f
- movl $0x15cd2401, %eax # mov ax, 2401h & int 15h
+ movw $0x2401, %ax
+ int $0x15
cli # disable interrupts
jnc 2f
1:
@@ -55,27 +78,26 @@ ASM_PFX(ThunkAttr): .space 4
orb $2, %al
outb %al, $0x92 # deactivate A20M#
2:
- xorw %ax, %ax # xor eax, eax
- movl %ss, %eax # mov ax, ss
- .byte 0x67, 0x66, 0x8d, 0x6c, 0x24, 0x34, 0x66
- mov %ebp, 0xffffffd8(%esi)
- mov 0xfffffff8(%esi), %ebx
- shlw $4, %ax # shl eax, 4
- addw %ax, %bp # add ebp, eax
- .byte 0x66, 0xb8 # mov eax, imm32
+ xorl %eax, %eax
+ movw %ss, %ax
+ leal IA32_REGS_SIZE(%esp), %ebp
+ mov %ebp, (_ESP - IA32_REGS_SIZE)(%bp)
+ mov (_EIP - IA32_REGS_SIZE)(%bp), %bx
+ shll $4, %eax
+ addl %eax, %ebp
+ .byte 0x66, 0xb8 # mov eax, imm32
SavedCr4: .space 4
movl %eax, %cr4
- lgdtw %cs:0xfffffff2(%edi)
- .byte 0x66, 0xb8 # mov eax, imm32
+ lgdtl %cs:(SavedGdt - L_Base1)(%bx)
+ .byte 0x66, 0xb8 # mov eax, imm32
SavedCr0: .space 4
movl %eax, %cr0
.byte 0xb8 # mov ax, imm16
SavedSs: .space 2
movl %eax, %ss
- .byte 0x66, 0xbc # mov esp, imm32
+ .byte 0x66, 0xbc # mov esp, imm32
SavedEsp: .space 4
- .byte 0x66
- lret # return to protected mode
+ lretl # return to protected mode
_EntryPoint: .long ASM_PFX(ToUserCode) - ASM_PFX(m16Start)
.word 0x8
@@ -85,37 +107,31 @@ _16Gdtr: .word GdtEnd - _NullSegDesc - 1
_16GdtrBase: .long _NullSegDesc
ASM_PFX(ToUserCode):
- movl %ss, %edx
- movl %ecx, %ss # set new segment selectors
- movl %ecx, %ds
- movl %ecx, %es
- movl %ecx, %fs
- movl %ecx, %gs
- movl %eax, %cr0
- movl %ebp, %cr4 # real mode starts at next instruction
- movl %esi, %ss # set up 16-bit stack segment
- xchgw %bx, %sp # set up 16-bit stack pointer
- .byte 0x66
- call L_Base # push eip
-L_Base:
- popw %bp # ebp <- offset L_Base
- .byte 0x67; # address size override
- push 54(%esp)
- lea 0xc(%esi), %eax
- push %eax
- lret
+ movw %ss, %dx
+ movw %cx, %ss # set new segment selectors
+ movw %cx, %ds
+ movw %cx, %es
+ movw %cx, %fs
+ movw %cx, %gs
+ movl %eax, %cr0 # real mode starts at next instruction
+ # which (per SDM) *must* be a far JMP.
+ ljmpw $0,$0 # will be filled in by InternalAsmThunk16
+L_Base: # to point here.
+ movl %ebp, %cr4
+ movw %si, %ss # set up 16-bit stack segment
+ xchgl %ebx, %esp # set up 16-bit stack pointer
-L_RealMode:
- mov %edx, %cs:0xffffffc5(%esi)
- mov %bx, %cs:0xffffffcb(%esi)
- lidtw %cs:0xffffffd7(%esi)
- popaw # popad actually
+ movw IA32_REGS_SIZE(%esp), %bp # get BackToUserCode address from stack
+ mov %dx, %cs:(SavedSs - ASM_PFX(BackFromUserCode))(%bp)
+ mov %ebx, %cs:(SavedEsp - ASM_PFX(BackFromUserCode))(%bp)
+ lidtl %cs:(_16Idtr - ASM_PFX(BackFromUserCode))(%bp)
+ popal
pop %ds
pop %es
pop %fs
pop %gs
- popfw # popfd
- lretw # transfer control to user code
+ popfl
+ lretl # transfer control to user code
_NullSegDesc: .quad 0
_16CsDesc:
@@ -134,6 +150,7 @@ _16DsDesc:
.byte 0
GdtEnd:
+ .code32
#
# @param RegSet The pointer to a IA32_DWORD_REGS structure
# @param Transition The pointer to the transition code
@@ -149,41 +166,43 @@ ASM_PFX(InternalAsmThunk16):
push %fs
push %gs
movl 36(%esp), %esi # esi <- RegSet
- movzwl 0x32(%esi), %edx
- mov 0xc(%esi), %edi
- add $0xffffffc8, %edi
+ movzwl _SS(%esi), %edx
+ mov _ESP(%esi), %edi
+ add $(-(IA32_REGS_SIZE + 4)), %edi
movl %edi, %ebx # ebx <- stack offset
imul $0x10, %edx, %eax
- push $0xd
+ push $(IA32_REGS_SIZE / 4)
addl %eax, %edi # edi <- linear address of 16-bit stack
pop %ecx
rep
movsl # copy RegSet
movl 40(%esp), %eax # eax <- address of transition code
movl %edx, %esi # esi <- 16-bit stack segment
- lea 0x61(%eax), %edx
+ lea (SavedCr0 - ASM_PFX(m16Start))(%eax), %edx
movl %eax, %ecx
andl $0xf, %ecx
shll $12, %eax
- lea 0x6(%ecx), %ecx
+ lea (ASM_PFX(BackFromUserCode) - ASM_PFX(m16Start))(%ecx), %ecx
movw %cx, %ax
stosl # [edi] <- return address of user code
- sgdtl 0xffffff9f(%edx)
+ addl $(L_Base - ASM_PFX(BackFromUserCode)), %eax
+ movl %eax, (L_Base - SavedCr0 - 4)(%edx)
+ sgdtl (SavedGdt - SavedCr0)(%edx)
sidtl 0x24(%esp)
movl %cr0, %eax
movl %eax, (%edx) # save CR0 in SavedCr0
andl $0x7ffffffe, %eax # clear PE, PG bits
movl %cr4, %ebp
- mov %ebp, 0xfffffff1(%edx)
+ mov %ebp, (SavedCr4 - SavedCr0)(%edx)
andl $0xffffffcf, %ebp # clear PAE, PSE bits
pushl $0x10
pop %ecx # ecx <- selector for data segments
- lgdtl 0x20(%edx)
+ lgdtl (_16Gdtr - SavedCr0)(%edx)
pushfl
- lcall *0x14(%edx)
+ lcall *(_EntryPoint - SavedCr0)(%edx)
popfl
lidtl 0x24(%esp)
- lea 0xffffffcc(%ebp), %eax
+ lea -IA32_REGS_SIZE(%ebp), %eax
pop %gs
pop %fs
pop %es
diff --git a/MdePkg/Library/BaseLib/Ia32/Thunk16.asm b/MdePkg/Library/BaseLib/Ia32/Thunk16.asm
index 3e84aedf3..08955d4e9 100644
--- a/MdePkg/Library/BaseLib/Ia32/Thunk16.asm
+++ b/MdePkg/Library/BaseLib/Ia32/Thunk16.asm
@@ -157,24 +157,30 @@ _ToUserCode PROC
mov es, ecx
mov fs, ecx
mov gs, ecx
- mov cr0, eax
- mov cr4, ebp ; real mode starts at next instruction
+ mov cr0, eax ; real mode starts at next instruction
+ ; which (per SDM) *must* be a far JMP.
+ DB 0eah
+_RealAddr DW 0,0 ; filled in by InternalAsmThunk16
+
+ mov cr4, ebp
mov ss, esi ; set up 16-bit stack segment
xchg sp, bx ; set up 16-bit stack pointer
- DB 66h
- call @Base ; push eip
-@Base:
- pop bp ; ebp <- address of @Base
- DB 67h ; address size override
- push [esp + sizeof (IA32_REGS) + 2]
- lea eax, [esi + (@RealMode - @Base)]
- push eax
- retf
-@RealMode:
- mov cs:[esi + (SavedSs - @Base)], edx
- mov cs:[esi + (SavedEsp - @Base)], bx
- DB 66h
- lidt fword ptr cs:[esi + (_16Idtr - @Base)]
+
+; mov bp, [esp + sizeof(IA32_REGS)
+ DB 67h
+ mov ebp, [esp + sizeof(IA32_REGS)] ; BackFromUserCode address from stack
+
+; mov cs:[bp + (SavedSs - _BackFromUserCode)], dx
+ mov cs:[esi + (SavedSs - _BackFromUserCode)], edx
+
+; mov cs:[bp + (SavedEsp - _BackFromUserCode)], ebx
+ DB 2eh, 66h, 89h, 9eh
+ DW SavedEsp - _BackFromUserCode
+
+; lidt cs:[bp + (_16Idtr - _BackFromUserCode)]
+ DB 2eh, 66h, 0fh, 01h, 9eh
+ DW _16Idtr - _BackFromUserCode
+
popaw ; popad actually
pop ds
pop es
@@ -230,6 +236,8 @@ InternalAsmThunk16 PROC USES ebp ebx esi edi ds es fs gs
lea ecx, [ecx + (_BackFromUserCode - m16Start)]
mov ax, cx
stosd ; [edi] <- return address of user code
+ add eax, _RealAddr + 4 - _BackFromUserCode
+ mov dword ptr [edx + (_RealAddr - SavedCr0)], eax
sgdt fword ptr [edx + (SavedGdt - SavedCr0)]
sidt fword ptr [esp + 36] ; save IDT stack in argument space
mov eax, cr0
diff --git a/MdePkg/Library/BasePcdLibNull/PcdLib.c b/MdePkg/Library/BasePcdLibNull/PcdLib.c
index 8333aaa3f..e03c01da5 100644
--- a/MdePkg/Library/BasePcdLibNull/PcdLib.c
+++ b/MdePkg/Library/BasePcdLibNull/PcdLib.c
@@ -1,7 +1,7 @@
/** @file
A emptry template implementation of PCD Library.
- Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -400,7 +400,9 @@ LibPcdGetExSize (
Sets the 8-bit value for the token specified by TokenNumber
to the value specified by Value. Value is returned.
-
+
+ If the set operation was not correctly performed, then ASSERT().
+
@param[in] TokenNumber The PCD token number to set a current value for.
@param[in] Value The 8-bit value to set.
@@ -426,7 +428,9 @@ LibPcdSet8 (
Sets the 16-bit value for the token specified by TokenNumber
to the value specified by Value. Value is returned.
-
+
+ If the set operation was not correctly performed, then ASSERT().
+
@param[in] TokenNumber The PCD token number to set a current value for.
@param[in] Value The 16-bit value to set.
@@ -452,7 +456,9 @@ LibPcdSet16 (
Sets the 32-bit value for the token specified by TokenNumber
to the value specified by Value. Value is returned.
-
+
+ If the set operation was not correctly performed, then ASSERT().
+
@param[in] TokenNumber The PCD token number to set a current value for.
@param[in] Value The 32-bit value to set.
@@ -478,7 +484,9 @@ LibPcdSet32 (
Sets the 64-bit value for the token specified by TokenNumber
to the value specified by Value. Value is returned.
-
+
+ If the set operation was not correctly performed, then ASSERT().
+
@param[in] TokenNumber The PCD token number to set a current value for.
@param[in] Value The 64-bit value to set.
@@ -506,7 +514,8 @@ LibPcdSet64 (
specified by Buffer and SizeOfBuffer. Buffer is returned.
If SizeOfBuffer is greater than the maximum size support by TokenNumber,
then set SizeOfBuffer to the maximum size supported by TokenNumber and
- return NULL to indicate that the set operation was not actually performed.
+ return NULL to indicate that the set operation was not actually performed,
+ or ASSERT() if the set operation was not corretly performed.
If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to the
maximum size supported by TokenName and NULL must be returned.
@@ -541,7 +550,9 @@ LibPcdSetPtr (
Sets the Boolean value for the token specified by TokenNumber
to the value specified by Value. Value is returned.
-
+
+ If the set operation was not correctly performed, then ASSERT().
+
@param[in] TokenNumber The PCD token number to set a current value for.
@param[in] Value The boolean value to set.
@@ -567,9 +578,10 @@ LibPcdSetBool (
Sets the 8-bit value for the token specified by TokenNumber and
Guid to the value specified by Value. Value is returned.
-
+
If Guid is NULL, then ASSERT().
-
+ If the set operation was not correctly performed, then ASSERT().
+
@param[in] Guid The pointer to a 128-bit unique value that
designates which namespace to set a value from.
@param[in] TokenNumber The PCD token number to set a current value for.
@@ -598,9 +610,10 @@ LibPcdSetEx8 (
Sets the 16-bit value for the token specified by TokenNumber and
Guid to the value specified by Value. Value is returned.
-
+
If Guid is NULL, then ASSERT().
-
+ If the set operation was not correctly performed, then ASSERT().
+
@param[in] Guid The pointer to a 128-bit unique value that
designates which namespace to set a value from.
@param[in] TokenNumber The PCD token number to set a current value for.
@@ -629,9 +642,10 @@ LibPcdSetEx16 (
Sets the 32-bit value for the token specified by TokenNumber and
Guid to the value specified by Value. Value is returned.
-
+
If Guid is NULL, then ASSERT().
-
+ If the set operation was not correctly performed, then ASSERT().
+
@param[in] Guid The pointer to a 128-bit unique value that
designates which namespace to set a value from.
@param[in] TokenNumber The PCD token number to set a current value for.
@@ -660,8 +674,10 @@ LibPcdSetEx32 (
Sets the 64-bit value for the token specified by TokenNumber and
Guid to the value specified by Value. Value is returned.
+
If Guid is NULL, then ASSERT().
-
+ If the set operation was not correctly performed, then ASSERT().
+
@param[in] Guid The pointer to a 128-bit unique value that
designates which namespace to set a value from.
@param[in] TokenNumber The PCD token number to set a current value for.
@@ -692,7 +708,7 @@ LibPcdSetEx64 (
Buffer and SizeOfBuffer. Buffer is returned. If SizeOfBuffer is greater than
the maximum size support by TokenNumber, then set SizeOfBuffer to the maximum size
supported by TokenNumber and return NULL to indicate that the set operation
- was not actually performed.
+ was not actually performed, or ASSERT() if the set operation was not corretly performed.
If Guid is NULL, then ASSERT().
If SizeOfBuffer is NULL, then ASSERT().
@@ -728,9 +744,10 @@ LibPcdSetExPtr (
Sets the Boolean value for the token specified by TokenNumber and
Guid to the value specified by Value. Value is returned.
-
+
If Guid is NULL, then ASSERT().
-
+ If the set operation was not correctly performed, then ASSERT().
+
@param[in] Guid The pointer to a 128-bit unique value that
designates which namespace to set a value from.
@param[in] TokenNumber The PCD token number to set a current value for.
diff --git a/MdePkg/Library/BaseS3BootScriptLibNull/BootScriptLib.c b/MdePkg/Library/BaseS3BootScriptLibNull/BootScriptLib.c
index 8e1ca7f4e..bb075db7d 100644
--- a/MdePkg/Library/BaseS3BootScriptLibNull/BootScriptLib.c
+++ b/MdePkg/Library/BaseS3BootScriptLibNull/BootScriptLib.c
@@ -1,7 +1,7 @@
/** @file
Null function implementation for EFI S3 boot script.
- Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions
@@ -257,7 +257,7 @@ S3BootScriptSaveDispatch (
return RETURN_SUCCESS;
}
/**
- Adds a record for an execution stall on the processor into a specified boot script table.
+ Adds a record for dispatching specified arbitrary code into a specified boot script table.
@param EntryPoint Entry point of the code to be dispatched.
@param Context Argument to be passed into the EntryPoint of the code to be dispatched.
@@ -455,7 +455,7 @@ S3BootScriptSaveInformationAsciiString (
how to get the script to run on an S3 resume because the boot script maintained by the lib will be
destroyed.
- @return the base address of the new copy of the boot script tble.
+ @return the base address of the new copy of the boot script table.
**/
UINT8*
diff --git a/MdePkg/Library/DxePcdLib/DxePcdLib.c b/MdePkg/Library/DxePcdLib/DxePcdLib.c
index bc87c4e6a..6f3a1b286 100644
--- a/MdePkg/Library/DxePcdLib/DxePcdLib.c
+++ b/MdePkg/Library/DxePcdLib/DxePcdLib.c
@@ -1,7 +1,7 @@
/** @file
Implementation of PcdLib class library for DXE phase.
-Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -489,7 +489,9 @@ LibPcdGetExSize (
Sets the 8-bit value for the token specified by TokenNumber
to the value specified by Value. Value is returned.
-
+
+ If the set operation was not correctly performed, then ASSERT().
+
@param[in] TokenNumber The PCD token number to set a current value for.
@param[in] Value The 8-bit value to set.
@@ -518,7 +520,9 @@ LibPcdSet8 (
Sets the 16-bit value for the token specified by TokenNumber
to the value specified by Value. Value is returned.
-
+
+ If the set operation was not correctly performed, then ASSERT().
+
@param[in] TokenNumber The PCD token number to set a current value for.
@param[in] Value The 16-bit value to set.
@@ -547,7 +551,9 @@ LibPcdSet16 (
Sets the 32-bit value for the token specified by TokenNumber
to the value specified by Value. Value is returned.
-
+
+ If the set operation was not correctly performed, then ASSERT().
+
@param[in] TokenNumber The PCD token number to set a current value for.
@param[in] Value The 32-bit value to set.
@@ -576,6 +582,8 @@ LibPcdSet32 (
Sets the 64-bit value for the token specified by TokenNumber
to the value specified by Value. Value is returned.
+
+ If the set operation was not correctly performed, then ASSERT().
@param[in] TokenNumber The PCD token number to set a current value for.
@param[in] Value The 64-bit value to set.
@@ -607,7 +615,8 @@ LibPcdSet64 (
specified by Buffer and SizeOfBuffer. Buffer is returned.
If SizeOfBuffer is greater than the maximum size support by TokenNumber,
then set SizeOfBuffer to the maximum size supported by TokenNumber and
- return NULL to indicate that the set operation was not actually performed.
+ return NULL to indicate that the set operation was not actually performed,
+ or ASSERT() if the set operation was not correctly performed.
If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to the
maximum size supported by TokenName and NULL must be returned.
@@ -631,6 +640,7 @@ LibPcdSetPtr (
)
{
EFI_STATUS Status;
+ UINTN InputSizeOfBuffer;
ASSERT (SizeOfBuffer != NULL);
@@ -638,10 +648,12 @@ LibPcdSetPtr (
ASSERT (Buffer != NULL);
}
+ InputSizeOfBuffer = *SizeOfBuffer;
Status = GetPcdProtocol()->SetPtr (TokenNumber, SizeOfBuffer, (VOID *) Buffer);
- if (EFI_ERROR (Status)) {
+ if (EFI_ERROR (Status) && (*SizeOfBuffer < InputSizeOfBuffer)) {
return NULL;
}
+ ASSERT_EFI_ERROR (Status);
return (VOID *)Buffer;
}
@@ -653,7 +665,9 @@ LibPcdSetPtr (
Sets the Boolean value for the token specified by TokenNumber
to the value specified by Value. Value is returned.
-
+
+ If the set operation was not correctly performed, then ASSERT().
+
@param[in] TokenNumber The PCD token number to set a current value for.
@param[in] Value The boolean value to set.
@@ -682,9 +696,10 @@ LibPcdSetBool (
Sets the 8-bit value for the token specified by TokenNumber and
Guid to the value specified by Value. Value is returned.
-
+
If Guid is NULL, then ASSERT().
-
+ If the set operation was not correctly performed, then ASSERT().
+
@param[in] Guid The pointer to a 128-bit unique value that
designates which namespace to set a value from.
@param[in] TokenNumber The PCD token number to set a current value for.
@@ -718,9 +733,10 @@ LibPcdSetEx8 (
Sets the 16-bit value for the token specified by TokenNumber and
Guid to the value specified by Value. Value is returned.
-
+
If Guid is NULL, then ASSERT().
-
+ If the set operation was not correctly performed, then ASSERT().
+
@param[in] Guid The pointer to a 128-bit unique value that
designates which namespace to set a value from.
@param[in] TokenNumber The PCD token number to set a current value for.
@@ -754,9 +770,10 @@ LibPcdSetEx16 (
Sets the 32-bit value for the token specified by TokenNumber and
Guid to the value specified by Value. Value is returned.
-
+
If Guid is NULL, then ASSERT().
-
+ If the set operation was not correctly performed, then ASSERT().
+
@param[in] Guid The pointer to a 128-bit unique value that
designates which namespace to set a value from.
@param[in] TokenNumber The PCD token number to set a current value for.
@@ -790,8 +807,10 @@ LibPcdSetEx32 (
Sets the 64-bit value for the token specified by TokenNumber and
Guid to the value specified by Value. Value is returned.
+
If Guid is NULL, then ASSERT().
-
+ If the set operation was not correctly performed, then ASSERT().
+
@param[in] Guid The pointer to a 128-bit unique value that
designates which namespace to set a value from.
@param[in] TokenNumber The PCD token number to set a current value for.
@@ -827,7 +846,7 @@ LibPcdSetEx64 (
Buffer and SizeOfBuffer. Buffer is returned. If SizeOfBuffer is greater than
the maximum size support by TokenNumber, then set SizeOfBuffer to the maximum size
supported by TokenNumber and return NULL to indicate that the set operation
- was not actually performed.
+ was not actually performed, or ASSERT() if the set operation was not corretly performed.
If Guid is NULL, then ASSERT().
If SizeOfBuffer is NULL, then ASSERT().
@@ -852,6 +871,7 @@ LibPcdSetExPtr (
)
{
EFI_STATUS Status;
+ UINTN InputSizeOfBuffer;
ASSERT (Guid != NULL);
@@ -861,10 +881,12 @@ LibPcdSetExPtr (
ASSERT (Buffer != NULL);
}
+ InputSizeOfBuffer = *SizeOfBuffer;
Status = GetPiPcdProtocol()->SetPtr (Guid, TokenNumber, SizeOfBuffer, Buffer);
- if (EFI_ERROR (Status)) {
+ if (EFI_ERROR (Status) && (*SizeOfBuffer < InputSizeOfBuffer)) {
return NULL;
}
+ ASSERT_EFI_ERROR (Status);
return Buffer;
}
@@ -876,9 +898,10 @@ LibPcdSetExPtr (
Sets the Boolean value for the token specified by TokenNumber and
Guid to the value specified by Value. Value is returned.
-
+
If Guid is NULL, then ASSERT().
-
+ If the set operation was not correctly performed, then ASSERT().
+
@param[in] Guid The pointer to a 128-bit unique value that
designates which namespace to set a value from.
@param[in] TokenNumber The PCD token number to set a current value for.
@@ -1002,7 +1025,10 @@ LibPcdGetNextToken (
IN UINTN TokenNumber
)
{
- GetPiPcdProtocol()->GetNextToken (Guid, &TokenNumber);
+ EFI_STATUS Status;
+
+ Status = GetPiPcdProtocol()->GetNextToken (Guid, &TokenNumber);
+ ASSERT (!EFI_ERROR (Status) || TokenNumber == 0);
return TokenNumber;
}
diff --git a/MdePkg/Library/PeiMemoryAllocationLib/MemoryAllocationLib.c b/MdePkg/Library/PeiMemoryAllocationLib/MemoryAllocationLib.c
index 90d4bbfd4..e325908aa 100644
--- a/MdePkg/Library/PeiMemoryAllocationLib/MemoryAllocationLib.c
+++ b/MdePkg/Library/PeiMemoryAllocationLib/MemoryAllocationLib.c
@@ -189,6 +189,7 @@ FreePages (
If there is not enough memory at the specified alignment remaining to satisfy the request, then
NULL is returned.
If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+ If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT().
@param MemoryType The type of memory to allocate.
@param Pages The number of 4 KB pages to allocate.
@@ -242,6 +243,7 @@ InternalAllocateAlignedPages (
request, then NULL is returned.
If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+ If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT().
@param Pages The number of 4 KB pages to allocate.
@param Alignment The requested alignment of the allocation.
@@ -270,6 +272,7 @@ AllocateAlignedPages (
request, then NULL is returned.
If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+ If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT().
@param Pages The number of 4 KB pages to allocate.
@param Alignment The requested alignment of the allocation.
@@ -298,6 +301,7 @@ AllocateAlignedRuntimePages (
request, then NULL is returned.
If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+ If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT().
@param Pages The number of 4 KB pages to allocate.
@param Alignment The requested alignment of the allocation.
diff --git a/MdePkg/Library/PeiPcdLib/PeiPcdLib.c b/MdePkg/Library/PeiPcdLib/PeiPcdLib.c
index a57751f41..536e1d05d 100644
--- a/MdePkg/Library/PeiPcdLib/PeiPcdLib.c
+++ b/MdePkg/Library/PeiPcdLib/PeiPcdLib.c
@@ -1,7 +1,7 @@
/** @file
Implementation of PcdLib class library for PEI phase.
-Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -490,7 +490,9 @@ LibPcdGetExSize (
Sets the 8-bit value for the token specified by TokenNumber
to the value specified by Value. Value is returned.
-
+
+ If the set operation was not correctly performed, then ASSERT().
+
@param[in] TokenNumber The PCD token number to set a current value for.
@param[in] Value The 8-bit value to set.
@@ -520,7 +522,9 @@ LibPcdSet8 (
Sets the 16-bit value for the token specified by TokenNumber
to the value specified by Value. Value is returned.
-
+
+ If the set operation was not correctly performed, then ASSERT().
+
@param[in] TokenNumber The PCD token number to set a current value for.
@param[in] Value The 16-bit value to set.
@@ -550,7 +554,9 @@ LibPcdSet16 (
Sets the 32-bit value for the token specified by TokenNumber
to the value specified by Value. Value is returned.
-
+
+ If the set operation was not correctly performed, then ASSERT().
+
@param[in] TokenNumber The PCD token number to set a current value for.
@param[in] Value The 32-bit value to set.
@@ -580,7 +586,9 @@ LibPcdSet32 (
Sets the 64-bit value for the token specified by TokenNumber
to the value specified by Value. Value is returned.
-
+
+ If the set operation was not correctly performed, then ASSERT().
+
@param[in] TokenNumber The PCD token number to set a current value for.
@param[in] Value The 64-bit value to set.
@@ -612,7 +620,8 @@ LibPcdSet64 (
specified by Buffer and SizeOfBuffer. Buffer is returned.
If SizeOfBuffer is greater than the maximum size support by TokenNumber,
then set SizeOfBuffer to the maximum size supported by TokenNumber and
- return NULL to indicate that the set operation was not actually performed.
+ return NULL to indicate that the set operation was not actually performed,
+ or ASSERT() if the set operation was not corretly performed.
If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to the
maximum size supported by TokenName and NULL must be returned.
@@ -636,18 +645,20 @@ LibPcdSetPtr (
)
{
EFI_STATUS Status;
+ UINTN InputSizeOfBuffer;
ASSERT (SizeOfBuffer != NULL);
if (*SizeOfBuffer > 0) {
ASSERT (Buffer != NULL);
}
-
- Status = (GetPcdPpiPointer ())->SetPtr (TokenNumber, SizeOfBuffer, (VOID *) Buffer);
- if (EFI_ERROR (Status)) {
+ InputSizeOfBuffer = *SizeOfBuffer;
+ Status = (GetPcdPpiPointer ())->SetPtr (TokenNumber, SizeOfBuffer, (VOID *) Buffer);
+ if (EFI_ERROR (Status) && (*SizeOfBuffer < InputSizeOfBuffer)) {
return NULL;
}
+ ASSERT_EFI_ERROR (Status);
return (VOID *) Buffer;
}
@@ -659,7 +670,9 @@ LibPcdSetPtr (
Sets the Boolean value for the token specified by TokenNumber
to the value specified by Value. Value is returned.
-
+
+ If the set operation was not correctly performed, then ASSERT().
+
@param[in] TokenNumber The PCD token number to set a current value for.
@param[in] Value The boolean value to set.
@@ -689,9 +702,10 @@ LibPcdSetBool (
Sets the 8-bit value for the token specified by TokenNumber and
Guid to the value specified by Value. Value is returned.
-
+
If Guid is NULL, then ASSERT().
-
+ If the set operation was not correctly performed, then ASSERT().
+
@param[in] Guid The pointer to a 128-bit unique value that
designates which namespace to set a value from.
@param[in] TokenNumber The PCD token number to set a current value for.
@@ -726,9 +740,10 @@ LibPcdSetEx8 (
Sets the 16-bit value for the token specified by TokenNumber and
Guid to the value specified by Value. Value is returned.
-
+
If Guid is NULL, then ASSERT().
-
+ If the set operation was not correctly performed, then ASSERT().
+
@param[in] Guid The pointer to a 128-bit unique value that
designates which namespace to set a value from.
@param[in] TokenNumber The PCD token number to set a current value for.
@@ -761,9 +776,10 @@ LibPcdSetEx16 (
Sets the 32-bit value for the token specified by TokenNumber and
Guid to the value specified by Value. Value is returned.
-
+
If Guid is NULL, then ASSERT().
-
+ If the set operation was not correctly performed, then ASSERT().
+
@param[in] Guid The pointer to a 128-bit unique value that
designates which namespace to set a value from.
@param[in] TokenNumber The PCD token number to set a current value for.
@@ -798,8 +814,10 @@ LibPcdSetEx32 (
Sets the 64-bit value for the token specified by TokenNumber and
Guid to the value specified by Value. Value is returned.
+
If Guid is NULL, then ASSERT().
-
+ If the set operation was not correctly performed, then ASSERT().
+
@param[in] Guid The pointer to a 128-bit unique value that
designates which namespace to set a value from.
@param[in] TokenNumber The PCD token number to set a current value for.
@@ -835,7 +853,7 @@ LibPcdSetEx64 (
Buffer and SizeOfBuffer. Buffer is returned. If SizeOfBuffer is greater than
the maximum size support by TokenNumber, then set SizeOfBuffer to the maximum size
supported by TokenNumber and return NULL to indicate that the set operation
- was not actually performed.
+ was not actually performed, or ASSERT() if the set operation was not corretly performed.
If Guid is NULL, then ASSERT().
If SizeOfBuffer is NULL, then ASSERT().
@@ -860,17 +878,21 @@ LibPcdSetExPtr (
)
{
EFI_STATUS Status;
+ UINTN InputSizeOfBuffer;
+
+
ASSERT (SizeOfBuffer != NULL);
if (*SizeOfBuffer > 0) {
ASSERT (Buffer != NULL);
}
ASSERT (Guid != NULL);
+ InputSizeOfBuffer = *SizeOfBuffer;
Status = (GetPiPcdPpiPointer ())->SetPtr (Guid, TokenNumber, SizeOfBuffer, Buffer);
-
- if (EFI_ERROR (Status)) {
+ if (EFI_ERROR (Status) && (*SizeOfBuffer < InputSizeOfBuffer)) {
return NULL;
}
+ ASSERT_EFI_ERROR (Status);
return Buffer;
}
@@ -882,9 +904,10 @@ LibPcdSetExPtr (
Sets the Boolean value for the token specified by TokenNumber and
Guid to the value specified by Value. Value is returned.
-
+
If Guid is NULL, then ASSERT().
-
+ If the set operation was not correctly performed, then ASSERT().
+
@param[in] Guid The pointer to a 128-bit unique value that
designates which namespace to set a value from.
@param[in] TokenNumber The PCD token number to set a current value for.
@@ -1010,7 +1033,10 @@ LibPcdGetNextToken (
IN UINTN TokenNumber
)
{
- (GetPiPcdPpiPointer ())->GetNextToken (Guid, &TokenNumber);
+ EFI_STATUS Status;
+
+ Status = (GetPiPcdPpiPointer ())->GetNextToken (Guid, &TokenNumber);
+ ASSERT (!EFI_ERROR (Status) || TokenNumber == 0);
return TokenNumber;
}
diff --git a/MdePkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c b/MdePkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c
index 9b02316af..0c687a526 100644
--- a/MdePkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c
+++ b/MdePkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c
@@ -4,7 +4,7 @@
This library is used for PEIM which does executed from flash device directly but
executed in memory.
- Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -88,4 +88,28 @@ PeiServicesTablePointerLibConstructor (
return EFI_SUCCESS;
}
+/**
+ Perform CPU specific actions required to migrate the PEI Services Table
+ pointer from temporary RAM to permanent RAM.
+
+ For IA32 CPUs, the PEI Services Table pointer is stored in the 4 bytes
+ immediately preceding the Interrupt Descriptor Table (IDT) in memory.
+ For X64 CPUs, the PEI Services Table pointer is stored in the 8 bytes
+ immediately preceding the Interrupt Descriptor Table (IDT) in memory.
+ For Itanium and ARM CPUs, a the PEI Services Table Pointer is stored in
+ a dedicated CPU register. This means that there is no memory storage
+ associated with storing the PEI Services Table pointer, so no additional
+ migration actions are required for Itanium or ARM CPUs.
+**/
+VOID
+EFIAPI
+MigratePeiServicesTablePointer (
+ )
+{
+ //
+ // PEI Services Table pointer is cached in the global variable. No additional
+ // migration actions are required.
+ //
+ return;
+}
diff --git a/MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointer.c b/MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointer.c
index 4e3f013ed..1ce3c727e 100644
--- a/MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointer.c
+++ b/MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointer.c
@@ -4,7 +4,7 @@
According to PI specification, the peiservice pointer is stored prior at IDT
table in IA32 and x64 architecture.
- Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -21,7 +21,6 @@
#include <Library/PeiServicesTablePointerLib.h>
#include <Library/DebugLib.h>
#include <Library/BaseMemoryLib.h>
-#include <Ppi/TemporaryRamSupport.h>
/**
Retrieves the cached value of the PEI Services Table pointer.
@@ -70,42 +69,62 @@ SetPeiServicesTablePointer (
)
{
IA32_DESCRIPTOR Idtr;
- EFI_PHYSICAL_ADDRESS IdtBase;
- EFI_STATUS Status;
- EFI_PEI_TEMPORARY_RAM_SUPPORT_PPI *TemporaryRamSupportPpi;
ASSERT (PeiServicesTablePointer != NULL);
AsmReadIdtr (&Idtr);
- if ((*(UINTN*)(Idtr.Base - sizeof (UINTN))) != (UINTN)PeiServicesTablePointer) {
- (*(UINTN*)(Idtr.Base - sizeof (UINTN))) = (UINTN)PeiServicesTablePointer;
- Status = (*PeiServicesTablePointer)->LocatePpi (
- PeiServicesTablePointer,
- &gEfiTemporaryRamSupportPpiGuid,
- 0,
- NULL,
- (VOID**)&TemporaryRamSupportPpi
- );
-
- if (EFI_ERROR (Status)) {
- //
- // If TemporaryRamSupportPpi is not found, Idt table needs to be migrated into memory.
- //
- Status = (*PeiServicesTablePointer)->AllocatePages (
- PeiServicesTablePointer,
- EfiBootServicesCode,
- EFI_SIZE_TO_PAGES(Idtr.Limit + 1 + sizeof (UINTN)),
- &IdtBase
- );
- if (!EFI_ERROR (Status)) {
- //
- // Migrate Idt table
- //
- CopyMem ((VOID *) (UINTN) IdtBase, (VOID *) (Idtr.Base - sizeof (UINTN)), Idtr.Limit + 1 + sizeof (UINTN));
- Idtr.Base = (UINTN) IdtBase + sizeof (UINTN);
- AsmWriteIdtr (&Idtr);
- }
- }
- }
+ (*(UINTN*)(Idtr.Base - sizeof (UINTN))) = (UINTN)PeiServicesTablePointer;
+}
+
+/**
+ Perform CPU specific actions required to migrate the PEI Services Table
+ pointer from temporary RAM to permanent RAM.
+
+ For IA32 CPUs, the PEI Services Table pointer is stored in the 4 bytes
+ immediately preceding the Interrupt Descriptor Table (IDT) in memory.
+ For X64 CPUs, the PEI Services Table pointer is stored in the 8 bytes
+ immediately preceding the Interrupt Descriptor Table (IDT) in memory.
+ For Itanium and ARM CPUs, a the PEI Services Table Pointer is stored in
+ a dedicated CPU register. This means that there is no memory storage
+ associated with storing the PEI Services Table pointer, so no additional
+ migration actions are required for Itanium or ARM CPUs.
+
+ If The cached PEI Services Table pointer is NULL, then ASSERT().
+ If the permanent memory is allocated failed, then ASSERT().
+**/
+VOID
+EFIAPI
+MigratePeiServicesTablePointer (
+ )
+{
+ EFI_STATUS Status;
+ IA32_DESCRIPTOR Idtr;
+ EFI_PHYSICAL_ADDRESS IdtBase;
+ CONST EFI_PEI_SERVICES **PeiServices;
+
+ //
+ // Get PEI Services Table pointer
+ //
+ AsmReadIdtr (&Idtr);
+ PeiServices = (CONST EFI_PEI_SERVICES **) (*(UINTN*)(Idtr.Base - sizeof (UINTN)));
+ ASSERT (PeiServices != NULL);
+ //
+ // Allocate the permanent memory.
+ //
+ Status = (*PeiServices)->AllocatePages (
+ PeiServices,
+ EfiBootServicesCode,
+ EFI_SIZE_TO_PAGES(Idtr.Limit + 1 + sizeof (UINTN)),
+ &IdtBase
+ );
+ ASSERT_EFI_ERROR (Status);
+ //
+ // Idt table needs to be migrated into memory.
+ //
+ CopyMem ((VOID *) (UINTN) IdtBase, (VOID *) (Idtr.Base - sizeof (UINTN)), Idtr.Limit + 1 + sizeof (UINTN));
+ Idtr.Base = (UINTN) IdtBase + sizeof (UINTN);
+ AsmWriteIdtr (&Idtr);
+
+ return;
}
diff --git a/MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf b/MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf
index 020a7f7e8..7ebe9c81a 100644
--- a/MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf
+++ b/MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf
@@ -4,7 +4,7 @@
# PEI Services Table Pointer Library implementation that retrieves a pointer to the PEI
# Services Table from the IDT on IA-32 and x64.
#
-# Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@@ -40,6 +40,3 @@
DebugLib
BaseLib
BaseMemoryLib
-
-[Ppis]
- gEfiTemporaryRamSupportPpiGuid ## SOMETIMES_CONSUMES
diff --git a/MdePkg/Library/PeiServicesTablePointerLibKr7/PeiServicesTablePointer.c b/MdePkg/Library/PeiServicesTablePointerLibKr7/PeiServicesTablePointer.c
index 4c91a9618..5da6e1d75 100644
--- a/MdePkg/Library/PeiServicesTablePointerLibKr7/PeiServicesTablePointer.c
+++ b/MdePkg/Library/PeiServicesTablePointerLibKr7/PeiServicesTablePointer.c
@@ -2,7 +2,7 @@
PEI Services Table Pointer Library implementation for IPF that uses Kernel
Register 7 to store the pointer.
- Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -66,6 +66,25 @@ SetPeiServicesTablePointer (
AsmWriteKr7 ((UINT64)(UINTN)PeiServicesTablePointer);
}
+/**
+ Perform CPU specific actions required to migrate the PEI Services Table
+ pointer from temporary RAM to permanent RAM.
+ For IA32 CPUs, the PEI Services Table pointer is stored in the 4 bytes
+ immediately preceding the Interrupt Descriptor Table (IDT) in memory.
+ For X64 CPUs, the PEI Services Table pointer is stored in the 8 bytes
+ immediately preceding the Interrupt Descriptor Table (IDT) in memory.
+ For Itanium and ARM CPUs, a the PEI Services Table Pointer is stored in
+ a dedicated CPU register. This means that there is no memory storage
+ associated with storing the PEI Services Table pointer, so no additional
+ migration actions are required for Itanium or ARM CPUs.
+**/
+VOID
+EFIAPI
+MigratePeiServicesTablePointer (
+ )
+{
+ return;
+}
diff --git a/MdePkg/Library/SmmMemoryAllocationLib/MemoryAllocationLib.c b/MdePkg/Library/SmmMemoryAllocationLib/MemoryAllocationLib.c
index d68c1a1b6..49d7a57a0 100644
--- a/MdePkg/Library/SmmMemoryAllocationLib/MemoryAllocationLib.c
+++ b/MdePkg/Library/SmmMemoryAllocationLib/MemoryAllocationLib.c
@@ -11,7 +11,7 @@
In addition, allocation for the Reserved memory types are not supported and
will always return NULL.
- Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -285,6 +285,7 @@ FreePages (
If Pages is 0, then NULL is returned. If there is not enough memory at the
specified alignment remaining to satisfy the request, then NULL is returned.
If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+ If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT().
@param MemoryType The type of memory to allocate.
@param Pages The number of 4 KB pages to allocate.
@@ -372,6 +373,7 @@ InternalAllocateAlignedPages (
specified alignment remaining to satisfy the request, then NULL is returned.
If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+ If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT().
@param Pages The number of 4 KB pages to allocate.
@param Alignment The requested alignment of the allocation.
@@ -400,6 +402,7 @@ AllocateAlignedPages (
specified alignment remaining to satisfy the request, then NULL is returned.
If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+ If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT().
@param Pages The number of 4 KB pages to allocate.
@param Alignment The requested alignment of the allocation.
@@ -428,6 +431,7 @@ AllocateAlignedRuntimePages (
specified alignment remaining to satisfy the request, then NULL is returned.
If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+ If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT().
@param Pages The number of 4 KB pages to allocate.
@param Alignment The requested alignment of the allocation.
diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c b/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
index 8943191bd..008ec0b96 100644
--- a/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
+++ b/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
@@ -1,7 +1,7 @@
/** @file
DevicePathFromText protocol as defined in the UEFI 2.0 specification.
-Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -535,6 +535,79 @@ StrToAscii (
}
/**
+ Converts a generic text device path node to device path structure.
+
+ @param Type The type of the device path node.
+ @param TextDeviceNode The input text device path node.
+
+ @return A pointer to device path structure.
+**/
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextGenericPath (
+ IN UINT8 Type,
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ EFI_DEVICE_PATH_PROTOCOL *Node;
+ CHAR16 *SubtypeStr;
+ CHAR16 *DataStr;
+ UINTN DataLength;
+
+ SubtypeStr = GetNextParamStr (&TextDeviceNode);
+ DataStr = GetNextParamStr (&TextDeviceNode);
+
+ if (DataStr == NULL) {
+ DataLength = 0;
+ } else {
+ DataLength = StrLen (DataStr) / 2;
+ }
+ Node = CreateDeviceNode (
+ Type,
+ (UINT8) Strtoi (SubtypeStr),
+ (UINT16) (sizeof (EFI_DEVICE_PATH_PROTOCOL) + DataLength)
+ );
+
+ StrToBuf ((UINT8 *) (Node + 1), DataLength, DataStr);
+ return Node;
+}
+
+/**
+ Converts a generic text device path node to device path structure.
+
+ @param TextDeviceNode The input Text device path node.
+
+ @return A pointer to device path structure.
+
+**/
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextPath (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ CHAR16 *TypeStr;
+
+ TypeStr = GetNextParamStr (&TextDeviceNode);
+
+ return DevPathFromTextGenericPath ((UINT8) Strtoi (TypeStr), TextDeviceNode);
+}
+
+/**
+ Converts a generic hardware text device path node to Hardware device path structure.
+
+ @param TextDeviceNode The input Text device path node.
+
+ @return A pointer to Hardware device path structure.
+
+**/
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextHardwarePath (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ return DevPathFromTextGenericPath (HARDWARE_DEVICE_PATH, TextDeviceNode);
+}
+
+/**
Converts a text device path node to Hardware PCI device path structure.
@param TextDeviceNode The input Text device path node.
@@ -719,6 +792,22 @@ DevPathFromTextCtrl (
}
/**
+ Converts a generic ACPI text device path node to ACPI device path structure.
+
+ @param TextDeviceNode The input Text device path node.
+
+ @return A pointer to ACPI device path structure.
+
+**/
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextAcpiPath (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ return DevPathFromTextGenericPath (ACPI_DEVICE_PATH, TextDeviceNode);
+}
+
+/**
Converts a string to EisaId.
@param Text The input string.
@@ -1046,6 +1135,22 @@ DevPathFromTextAcpiAdr (
}
/**
+ Converts a generic messaging text device path node to messaging device path structure.
+
+ @param TextDeviceNode The input Text device path node.
+
+ @return A pointer to messaging device path structure.
+
+**/
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextMsg (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ return DevPathFromTextGenericPath (MESSAGING_DEVICE_PATH, TextDeviceNode);
+}
+
+/**
Converts a text device path node to Parallel Port device path structure.
@param TextDeviceNode The input Text device path node.
@@ -2521,6 +2626,22 @@ DevPathFromTextVlan (
}
/**
+ Converts a media text device path node to media device path structure.
+
+ @param TextDeviceNode The input Text device path node.
+
+ @return A pointer to media device path structure.
+
+**/
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextMediaPath (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ return DevPathFromTextGenericPath (MEDIA_DEVICE_PATH, TextDeviceNode);
+}
+
+/**
Converts a text device path node to HD device path structure.
@param TextDeviceNode The input Text device path node.
@@ -2775,6 +2896,23 @@ DevPathFromTextRelativeOffsetRange (
return (EFI_DEVICE_PATH_PROTOCOL *) Offset;
}
+
+/**
+ Converts a BBS text device path node to BBS device path structure.
+
+ @param TextDeviceNode The input Text device path node.
+
+ @return A pointer to BBS device path structure.
+
+**/
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextBbsPath (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ return DevPathFromTextGenericPath (BBS_DEVICE_PATH, TextDeviceNode);
+}
+
/**
Converts a text device path node to BIOS Boot Specification device path structure.
@@ -2862,11 +3000,16 @@ DevPathFromTextSata (
}
GLOBAL_REMOVE_IF_UNREFERENCED DEVICE_PATH_FROM_TEXT_TABLE mUefiDevicePathLibDevPathFromTextTable[] = {
+ {L"Path", DevPathFromTextPath },
+
+ {L"HardwarePath", DevPathFromTextHardwarePath },
{L"Pci", DevPathFromTextPci },
{L"PcCard", DevPathFromTextPcCard },
{L"MemoryMapped", DevPathFromTextMemoryMapped },
{L"VenHw", DevPathFromTextVenHw },
{L"Ctrl", DevPathFromTextCtrl },
+
+ {L"AcpiPath", DevPathFromTextAcpiPath },
{L"Acpi", DevPathFromTextAcpi },
{L"PciRoot", DevPathFromTextPciRoot },
{L"PcieRoot", DevPathFromTextPcieRoot },
@@ -2877,6 +3020,8 @@ GLOBAL_REMOVE_IF_UNREFERENCED DEVICE_PATH_FROM_TEXT_TABLE mUefiDevicePathLibDevP
{L"AcpiEx", DevPathFromTextAcpiEx },
{L"AcpiExp", DevPathFromTextAcpiExp },
{L"AcpiAdr", DevPathFromTextAcpiAdr },
+
+ {L"Msg", DevPathFromTextMsg },
{L"Ata", DevPathFromTextAta },
{L"Scsi", DevPathFromTextScsi },
{L"Fibre", DevPathFromTextFibre },
@@ -2918,6 +3063,8 @@ GLOBAL_REMOVE_IF_UNREFERENCED DEVICE_PATH_FROM_TEXT_TABLE mUefiDevicePathLibDevP
{L"Unit", DevPathFromTextUnit },
{L"iSCSI", DevPathFromTextiSCSI },
{L"Vlan", DevPathFromTextVlan },
+
+ {L"MediaPath", DevPathFromTextMediaPath },
{L"HD", DevPathFromTextHD },
{L"CDROM", DevPathFromTextCDROM },
{L"VenMedia", DevPathFromTextVenMedia },
@@ -2925,6 +3072,8 @@ GLOBAL_REMOVE_IF_UNREFERENCED DEVICE_PATH_FROM_TEXT_TABLE mUefiDevicePathLibDevP
{L"Fv", DevPathFromTextFv },
{L"FvFile", DevPathFromTextFvFile },
{L"Offset", DevPathFromTextRelativeOffsetRange },
+
+ {L"BbsPath", DevPathFromTextBbsPath },
{L"BBS", DevPathFromTextBBS },
{L"Sata", DevPathFromTextSata },
{NULL, NULL}
diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c b/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
index eebdbf239..9b1ca8e28 100644
--- a/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
+++ b/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
@@ -1,7 +1,7 @@
/** @file
DevicePathToText protocol as defined in the UEFI 2.0 specification.
-Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -1755,6 +1755,15 @@ DevPathToTextEndInstance (
UefiDevicePathLibCatPrint (Str, L",");
}
+GLOBAL_REMOVE_IF_UNREFERENCED const DEVICE_PATH_TO_TEXT_GENERIC_TABLE mUefiDevicePathLibToTextTableGeneric[] = {
+ {HARDWARE_DEVICE_PATH, L"HardwarePath" },
+ {ACPI_DEVICE_PATH, L"AcpiPath" },
+ {MESSAGING_DEVICE_PATH, L"Msg" },
+ {MEDIA_DEVICE_PATH, L"MediaPath" },
+ {BBS_DEVICE_PATH, L"BbsPath" },
+ {0, NULL}
+};
+
/**
Converts an unknown device path structure to its string representative.
@@ -1769,17 +1778,48 @@ DevPathToTextEndInstance (
**/
VOID
-DevPathToTextNodeUnknown (
+DevPathToTextNodeGeneric (
IN OUT POOL_PRINT *Str,
IN VOID *DevPath,
IN BOOLEAN DisplayOnly,
IN BOOLEAN AllowShortcuts
)
{
- UefiDevicePathLibCatPrint (Str, L"?");
+ EFI_DEVICE_PATH_PROTOCOL *Node;
+ UINTN Index;
+
+ Node = DevPath;
+
+ for (Index = 0; mUefiDevicePathLibToTextTableGeneric[Index].Text != NULL; Index++) {
+ if (DevicePathType (Node) == mUefiDevicePathLibToTextTableGeneric[Index].Type) {
+ break;
+ }
+ }
+
+ if (mUefiDevicePathLibToTextTableGeneric[Index].Text == NULL) {
+ //
+ // It's a node whose type cannot be recognized
+ //
+ UefiDevicePathLibCatPrint (Str, L"Path(%d,%d", DevicePathType (Node), DevicePathSubType (Node));
+ } else {
+ //
+ // It's a node whose type can be recognized
+ //
+ UefiDevicePathLibCatPrint (Str, L"%s(%d", mUefiDevicePathLibToTextTableGeneric[Index].Text, DevicePathSubType (Node));
+ }
+
+ Index = sizeof (EFI_DEVICE_PATH_PROTOCOL);
+ if (Index < DevicePathNodeLength (Node)) {
+ UefiDevicePathLibCatPrint (Str, L",");
+ for (; Index < DevicePathNodeLength (Node); Index++) {
+ UefiDevicePathLibCatPrint (Str, L"%02x", ((UINT8 *) Node)[Index]);
+ }
+ }
+
+ UefiDevicePathLibCatPrint (Str, L")");
}
-GLOBAL_REMOVE_IF_UNREFERENCED const DEVICE_PATH_TO_TEXT_TABLE mUefiDevicePathLibDevPathToTextTable[] = {
+GLOBAL_REMOVE_IF_UNREFERENCED const DEVICE_PATH_TO_TEXT_TABLE mUefiDevicePathLibToTextTable[] = {
{HARDWARE_DEVICE_PATH, HW_PCI_DP, DevPathToTextPci },
{HARDWARE_DEVICE_PATH, HW_PCCARD_DP, DevPathToTextPccard },
{HARDWARE_DEVICE_PATH, HW_MEMMAP_DP, DevPathToTextMemMap },
@@ -1858,12 +1898,12 @@ UefiDevicePathLibConvertDeviceNodeToText (
// Process the device path node
// If not found, use a generic function
//
- ToText = DevPathToTextNodeUnknown;
- for (Index = 0; mUefiDevicePathLibDevPathToTextTable[Index].Function != NULL; Index++) {
- if (DevicePathType (DeviceNode) == mUefiDevicePathLibDevPathToTextTable[Index].Type &&
- DevicePathSubType (DeviceNode) == mUefiDevicePathLibDevPathToTextTable[Index].SubType
+ ToText = DevPathToTextNodeGeneric;
+ for (Index = 0; mUefiDevicePathLibToTextTable[Index].Function != NULL; Index++) {
+ if (DevicePathType (DeviceNode) == mUefiDevicePathLibToTextTable[Index].Type &&
+ DevicePathSubType (DeviceNode) == mUefiDevicePathLibToTextTable[Index].SubType
) {
- ToText = mUefiDevicePathLibDevPathToTextTable[Index].Function;
+ ToText = mUefiDevicePathLibToTextTable[Index].Function;
break;
}
}
@@ -1921,13 +1961,13 @@ UefiDevicePathLibConvertDevicePathToText (
// Find the handler to dump this device path node
// If not found, use a generic function
//
- ToText = DevPathToTextNodeUnknown;
- for (Index = 0; mUefiDevicePathLibDevPathToTextTable[Index].Function != NULL; Index += 1) {
+ ToText = DevPathToTextNodeGeneric;
+ for (Index = 0; mUefiDevicePathLibToTextTable[Index].Function != NULL; Index += 1) {
- if (DevicePathType (Node) == mUefiDevicePathLibDevPathToTextTable[Index].Type &&
- DevicePathSubType (Node) == mUefiDevicePathLibDevPathToTextTable[Index].SubType
+ if (DevicePathType (Node) == mUefiDevicePathLibToTextTable[Index].Type &&
+ DevicePathSubType (Node) == mUefiDevicePathLibToTextTable[Index].SubType
) {
- ToText = mUefiDevicePathLibDevPathToTextTable[Index].Function;
+ ToText = mUefiDevicePathLibToTextTable[Index].Function;
break;
}
}
diff --git a/MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.h b/MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.h
index a7ed53189..233844cfc 100644
--- a/MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.h
+++ b/MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.h
@@ -1,7 +1,7 @@
/** @file
Definition for Device Path library.
-Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -69,6 +69,11 @@ typedef struct {
} DEVICE_PATH_TO_TEXT_TABLE;
typedef struct {
+ UINT8 Type;
+ CHAR16 *Text;
+} DEVICE_PATH_TO_TEXT_GENERIC_TABLE;
+
+typedef struct {
CHAR16 *DevicePathNodeText;
DEVICE_PATH_FROM_TEXT Function;
} DEVICE_PATH_FROM_TEXT_TABLE;
diff --git a/MdePkg/Library/UefiMemoryAllocationLib/MemoryAllocationLib.c b/MdePkg/Library/UefiMemoryAllocationLib/MemoryAllocationLib.c
index 0ccb52449..f1eaccc8d 100644
--- a/MdePkg/Library/UefiMemoryAllocationLib/MemoryAllocationLib.c
+++ b/MdePkg/Library/UefiMemoryAllocationLib/MemoryAllocationLib.c
@@ -2,7 +2,7 @@
Support routines for memory allocation routines based
on boot services for Dxe phase drivers.
- Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -160,6 +160,7 @@ FreePages (
If there is not enough memory at the specified alignment remaining to satisfy the request, then
NULL is returned.
If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+ If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT().
@param MemoryType The type of memory to allocate.
@param Pages The number of 4 KB pages to allocate.
@@ -246,6 +247,7 @@ InternalAllocateAlignedPages (
request, then NULL is returned.
If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+ If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT().
@param Pages The number of 4 KB pages to allocate.
@param Alignment The requested alignment of the allocation. Must be a power of two.
@@ -273,6 +275,7 @@ AllocateAlignedPages (
request, then NULL is returned.
If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+ If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT().
@param Pages The number of 4 KB pages to allocate.
@param Alignment The requested alignment of the allocation. Must be a power of two.
@@ -300,6 +303,7 @@ AllocateAlignedRuntimePages (
request, then NULL is returned.
If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+ If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT().
@param Pages The number of 4 KB pages to allocate.
@param Alignment The requested alignment of the allocation. Must be a power of two.