diff --git a/MdeModulePkg/Core/RuntimeDxe/Crc32.c b/MdeModulePkg/Core/RuntimeDxe/Crc32.c index 0e7e793365..0f22d1f6b7 100644 --- a/MdeModulePkg/Core/RuntimeDxe/Crc32.c +++ b/MdeModulePkg/Core/RuntimeDxe/Crc32.c @@ -31,7 +31,7 @@ UINT32 mCrcTable[256]; /** Calculate CRC32 for target data. - @param Len The target data. + @param Data The target data. @param DataSize The target data size. @param CrcOut The CRC32 for target data. @@ -68,13 +68,13 @@ RuntimeDriverCalculateCrc32 ( /** Reverse bits for 32bit data. + This is a internal function. @param Value The data to be reversed. - @retrun Data reversed. + @return Data reversed. **/ -STATIC UINT32 ReverseBits ( UINT32 Value @@ -85,7 +85,7 @@ ReverseBits ( NewValue = 0; for (Index = 0; Index < 32; Index++) { - if (Value & (1 << Index)) { + if ((Value & (1 << Index)) != 0) { NewValue = NewValue | (1 << (31 - Index)); } } @@ -95,11 +95,6 @@ ReverseBits ( /** Initialize CRC32 table. - - @param None - - @retrun None - **/ VOID RuntimeDriverInitializeCrc32Table ( @@ -113,7 +108,7 @@ RuntimeDriverInitializeCrc32Table ( for (TableEntry = 0; TableEntry < 256; TableEntry++) { Value = ReverseBits ((UINT32) TableEntry); for (Index = 0; Index < 8; Index++) { - if (Value & 0x80000000) { + if ((Value & 0x80000000) != 0) { Value = (Value << 1) ^ 0x04c11db7; } else { Value = Value << 1; diff --git a/MdeModulePkg/Core/RuntimeDxe/Runtime.c b/MdeModulePkg/Core/RuntimeDxe/Runtime.c index efd7dec05c..6abe54668e 100644 --- a/MdeModulePkg/Core/RuntimeDxe/Runtime.c +++ b/MdeModulePkg/Core/RuntimeDxe/Runtime.c @@ -1,21 +1,6 @@ /** @file Runtime Architectural Protocol as defined in the DXE CIS. -Copyright (c) 2006, Intel Corporation.
-All rights reserved. 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 -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -Module Name: - - Runtime.c - -Abstract: - This code is used to produce the EFI runtime virtual switch over THIS IS VERY DANGEROUS CODE BE VERY CAREFUL IF YOU CHANGE IT @@ -48,6 +33,16 @@ Revision History: Runtime Arch Protocol definition no longer contains CalculateCrc32. Boot Service Table now contains an item named CalculateCrc32. + +Copyright (c) 2006, Intel Corporation.
+All rights reserved. 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 +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + **/ #include "Runtime.h" @@ -89,28 +84,21 @@ EFI_RUNTIME_ARCH_PROTOCOL mRuntime = { // // Worker Functions // -STATIC +/** + + Calcualte the 32-bit CRC in a EFI table using the Runtime Drivers + internal function. The EFI Boot Services Table can not be used because + the EFI Boot Services Table was destroyed at ExitBootServices(). + This is a internal function. + + + @param Hdr Pointer to an EFI standard header + +**/ VOID RuntimeDriverCalculateEfiHdrCrc ( IN OUT EFI_TABLE_HEADER *Hdr ) -/*++ - -Routine Description: - - Calcualte the 32-bit CRC in a EFI table using the Runtime Drivers - internal function. The EFI Boot Services Table can not be used because - the EFI Boot Services Table was destroyed at ExitBootServices() - -Arguments: - - Hdr - Pointer to an EFI standard header - -Returns: - - None - ---*/ { UINT32 Crc; @@ -121,32 +109,27 @@ Returns: Hdr->CRC32 = Crc; } +/** + + Determines the new virtual address that is to be used on subsequent memory accesses. + + + @param DebugDisposition Supplies type information for the pointer being converted. + @param ConvertAddress A pointer to a pointer that is to be fixed to be the value needed + for the new virtual address mappings being applied. + + @retval EFI_SUCCESS The pointer pointed to by Address was modified. + @retval EFI_NOT_FOUND The pointer pointed to by Address was not found to be part + of the current memory map. This is normally fatal. + @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value. + +**/ EFI_STATUS EFIAPI RuntimeDriverConvertPointer ( IN UINTN DebugDisposition, IN OUT VOID **ConvertAddress ) -/*++ - -Routine Description: - - Determines the new virtual address that is to be used on subsequent memory accesses. - -Arguments: - - DebugDisposition - Supplies type information for the pointer being converted. - ConvertAddress - A pointer to a pointer that is to be fixed to be the value needed - for the new virtual address mappings being applied. - -Returns: - - EFI_SUCCESS - The pointer pointed to by Address was modified. - EFI_NOT_FOUND - The pointer pointed to by Address was not found to be part - of the current memory map. This is normally fatal. - EFI_INVALID_PARAMETER - One of the parameters has an invalid value. - ---*/ { UINTN Address; UINT64 VirtEndOfRange; @@ -168,7 +151,7 @@ Returns: // If this is a null pointer, return if it's allowed // if (Address == 0) { - if (DebugDisposition & EFI_OPTIONAL_POINTER) { + if ((DebugDisposition & EFI_OPTIONAL_POINTER) != 0) { return EFI_SUCCESS; } @@ -204,35 +187,51 @@ Returns: return EFI_NOT_FOUND; } -STATIC +/** + + Determines the new virtual address that is to be used on subsequent memory accesses + for internal pointers. + This is a internal function. + + + @param ConvertAddress A pointer to a pointer that is to be fixed to be the value needed + for the new virtual address mappings being applied. + + @retval EFI_SUCCESS The pointer pointed to by Address was modified. + @retval EFI_NOT_FOUND The pointer pointed to by Address was not found to be part + of the current memory map. This is normally fatal. + @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value. + +**/ EFI_STATUS RuntimeDriverConvertInternalPointer ( IN OUT VOID **ConvertAddress ) -/*++ - -Routine Description: - - Determines the new virtual address that is to be used on subsequent memory accesses - for internal pointers. - -Arguments: - - ConvertAddress - A pointer to a pointer that is to be fixed to be the value needed - for the new virtual address mappings being applied. - -Returns: - - EFI_SUCCESS - The pointer pointed to by Address was modified. - EFI_NOT_FOUND - The pointer pointed to by Address was not found to be part - of the current memory map. This is normally fatal. - EFI_INVALID_PARAMETER - One of the parameters has an invalid value. - ---*/ { return RuntimeDriverConvertPointer (0x0, ConvertAddress); } +/** + + Changes the runtime addressing mode of EFI firmware from physical to virtual. + + + @param MemoryMapSize The size in bytes of VirtualMap. + @param DescriptorSize The size in bytes of an entry in the VirtualMap. + @param DescriptorVersion The version of the structure entries in VirtualMap. + @param VirtualMap An array of memory descriptors which contain new virtual + address mapping information for all runtime ranges. + + @retval EFI_SUCCESS The virtual address map has been applied. + @retval EFI_UNSUPPORTED EFI firmware is not at runtime, or the EFI firmware is already in + virtual address mapped mode. + @retval EFI_INVALID_PARAMETER DescriptorSize or DescriptorVersion is invalid. + @retval EFI_NO_MAPPING A virtual address was not supplied for a range in the memory + map that requires a mapping. + @retval EFI_NOT_FOUND A virtual address was supplied for an address that is not found + in the memory map. + +**/ EFI_STATUS EFIAPI RuntimeDriverSetVirtualAddressMap ( @@ -241,32 +240,6 @@ RuntimeDriverSetVirtualAddressMap ( IN UINT32 DescriptorVersion, IN EFI_MEMORY_DESCRIPTOR *VirtualMap ) -/*++ - -Routine Description: - - Changes the runtime addressing mode of EFI firmware from physical to virtual. - -Arguments: - - MemoryMapSize - The size in bytes of VirtualMap. - DescriptorSize - The size in bytes of an entry in the VirtualMap. - DescriptorVersion - The version of the structure entries in VirtualMap. - VirtualMap - An array of memory descriptors which contain new virtual - address mapping information for all runtime ranges. - -Returns: - - EFI_SUCCESS - The virtual address map has been applied. - EFI_UNSUPPORTED - EFI firmware is not at runtime, or the EFI firmware is already in - virtual address mapped mode. - EFI_INVALID_PARAMETER - DescriptorSize or DescriptorVersion is invalid. - EFI_NO_MAPPING - A virtual address was not supplied for a range in the memory - map that requires a mapping. - EFI_NOT_FOUND - A virtual address was supplied for an address that is not found - in the memory map. - ---*/ { EFI_STATUS Status; EFI_RUNTIME_EVENT_ENTRY *RuntimeEvent; @@ -388,29 +361,26 @@ Returns: return EFI_SUCCESS; } +/** + Install Runtime AP. This code includes the EfiDriverLib, but it functions at + RT in physical mode. The only Lib services are gBS, gRT, and the DEBUG and + ASSERT macros (they do ReportStatusCode). + + + @param ImageHandle Image handle of this driver. + @param SystemTable Pointer to the EFI System Table. + + @retval EFI_SUCEESS Runtime Driver Architectural Protocol Installed + @return Other value if gBS->InstallMultipleProtocolInterfaces fails. Check + gBS->InstallMultipleProtocolInterfaces for details. + +**/ EFI_STATUS EFIAPI RuntimeDriverInitialize ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) -/*++ - -Routine Description: - Install Runtime AP. This code includes the EfiDriverLib, but it functions at - RT in physical mode. The only Lib services are gBS, gRT, and the DEBUG and - ASSERT macros (they do ReportStatusCode). - -Arguments: - (Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT) - -Returns: - - EFI_SUCEESS - Runtime Driver Architectural Protocol Installed - - Other - Return value from gBS->InstallMultipleProtocolInterfaces - ---*/ { EFI_STATUS Status; EFI_LOADED_IMAGE_PROTOCOL *MyLoadedImage; diff --git a/MdeModulePkg/Core/RuntimeDxe/Runtime.h b/MdeModulePkg/Core/RuntimeDxe/Runtime.h index 4ff21ea5b6..e85c47d9b1 100644 --- a/MdeModulePkg/Core/RuntimeDxe/Runtime.h +++ b/MdeModulePkg/Core/RuntimeDxe/Runtime.h @@ -42,6 +42,20 @@ Abstract: // // Function Prototypes // +/** + + Calculate CRC32 for target data + + + @param Data The target data. + @param DataSize The target data size. + @param CrcOut The CRC32 for target data. + + @retval EFI_SUCCESS The CRC32 for target data is calculated successfully. + @retval EFI_INVALID_PARAMETER Some parameter is not valid, so the CRC32 is not + calculated. + +**/ EFI_STATUS EFIAPI RuntimeDriverCalculateCrc32 ( @@ -49,55 +63,52 @@ RuntimeDriverCalculateCrc32 ( IN UINTN DataSize, OUT UINT32 *CrcOut ) -/*++ - -Routine Description: - - Calculate CRC32 for target data - -Arguments: - - Data - The target data. - DataSize - The target data size. - CrcOut - The CRC32 for target data. - -Returns: - - EFI_SUCCESS - The CRC32 for target data is calculated successfully. - EFI_INVALID_PARAMETER - Some parameter is not valid, so the CRC32 is not - calculated. - ---*/ ; +/** + + Determines the new virtual address that is to be used on subsequent memory accesses. + + + @param DebugDisposition Supplies type information for the pointer being converted. + @param ConvertAddress A pointer to a pointer that is to be fixed to be the value needed + for the new virtual address mappings being applied. + + @retval EFI_SUCCESS The pointer pointed to by Address was modified. + @retval EFI_NOT_FOUND The pointer pointed to by Address was not found to be part + of the current memory map. This is normally fatal. + @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value. + +**/ EFI_STATUS EFIAPI RuntimeDriverConvertPointer ( IN UINTN DebugDisposition, IN OUT VOID **ConvertAddress ) -/*++ - -Routine Description: - - Determines the new virtual address that is to be used on subsequent memory accesses. - -Arguments: - - DebugDisposition - Supplies type information for the pointer being converted. - ConvertAddress - A pointer to a pointer that is to be fixed to be the value needed - for the new virtual address mappings being applied. - -Returns: - - EFI_SUCCESS - The pointer pointed to by Address was modified. - EFI_NOT_FOUND - The pointer pointed to by Address was not found to be part - of the current memory map. This is normally fatal. - EFI_INVALID_PARAMETER - One of the parameters has an invalid value. - ---*/ ; +/** + + Changes the runtime addressing mode of EFI firmware from physical to virtual. + + + @param MemoryMapSize The size in bytes of VirtualMap. + @param DescriptorSize The size in bytes of an entry in the VirtualMap. + @param DescriptorVersion The version of the structure entries in VirtualMap. + @param VirtualMap An array of memory descriptors which contain new virtual + address mapping information for all runtime ranges. + + @retval EFI_SUCCESS The virtual address map has been applied. + @retval EFI_UNSUPPORTED EFI firmware is not at runtime, or the EFI firmware is already in + virtual address mapped mode. + @retval EFI_INVALID_PARAMETER DescriptorSize or DescriptorVersion is invalid. + @retval EFI_NO_MAPPING A virtual address was not supplied for a range in the memory + map that requires a mapping. + @retval EFI_NOT_FOUND A virtual address was supplied for an address that is not found + in the memory map. + +**/ EFI_STATUS EFIAPI RuntimeDriverSetVirtualAddressMap ( @@ -106,78 +117,39 @@ RuntimeDriverSetVirtualAddressMap ( IN UINT32 DescriptorVersion, IN EFI_MEMORY_DESCRIPTOR *VirtualMap ) -/*++ - -Routine Description: - - Changes the runtime addressing mode of EFI firmware from physical to virtual. - -Arguments: - - MemoryMapSize - The size in bytes of VirtualMap. - DescriptorSize - The size in bytes of an entry in the VirtualMap. - DescriptorVersion - The version of the structure entries in VirtualMap. - VirtualMap - An array of memory descriptors which contain new virtual - address mapping information for all runtime ranges. - -Returns: - - EFI_SUCCESS - The virtual address map has been applied. - EFI_UNSUPPORTED - EFI firmware is not at runtime, or the EFI firmware is already in - virtual address mapped mode. - EFI_INVALID_PARAMETER - DescriptorSize or DescriptorVersion is invalid. - EFI_NO_MAPPING - A virtual address was not supplied for a range in the memory - map that requires a mapping. - EFI_NOT_FOUND - A virtual address was supplied for an address that is not found - in the memory map. - ---*/ ; +/** + + Initialize CRC32 table. + +**/ VOID RuntimeDriverInitializeCrc32Table ( VOID ) -/*++ - -Routine Description: - - Initialize CRC32 table. - -Arguments: - - None. - -Returns: - - None. - ---*/ ; +/** + + Install Runtime AP. This code includes the EfiRuntimeLib, but it only + functions at RT in physical mode. + + + @param ImageHandle Image handle of this driver. + @param SystemTable Pointer to the EFI System Table. + + @retval EFI_SUCEESS Runtime Driver Architectural Protocol Installed + @return Other value if gBS->InstallMultipleProtocolInterfaces fails. Check + gBS->InstallMultipleProtocolInterfaces for details. + +**/ EFI_STATUS EFIAPI RuntimeDriverInitialize ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) -/*++ - -Routine Description: - - Install Runtime AP. This code includes the EfiRuntimeLib, but it only - functions at RT in physical mode. - -Arguments: - - ImageHandle - Image handle of this driver. - SystemTable - Pointer to the EFI System Table. - -Returns: - - EFI_SUCEESS - Runtime Driver Architectural Protocol installed. - ---*/ ; #endif