From 8069d49e9abf619afac16e44bf72266de57b1411 Mon Sep 17 00:00:00 2001 From: lgao4 Date: Mon, 25 Feb 2008 07:01:44 +0000 Subject: update comments and add assert for these files. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4750 6f19259b-4bc3-4df7-8a09-765794883524 --- .../DxeExtractGuidedSectionLib.c | 27 ++--- .../PeiExtractGuidedSectionLib.c | 27 ++--- MdePkg/Library/PeiPiLib/PeiPiLib.c | 21 ++++ MdePkg/Library/UefiScsiLib/UefiScsiLib.c | 122 ++++++++++++++++----- MdePkg/Library/UefiUsbLib/Hid.c | 27 ++++- MdePkg/Library/UefiUsbLib/UsbDxeLib.c | 4 + 6 files changed, 163 insertions(+), 65 deletions(-) (limited to 'MdePkg/Library') diff --git a/MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.c b/MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.c index acffa264fe..752594484c 100644 --- a/MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.c +++ b/MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.c @@ -1,23 +1,16 @@ -/*++ +/** @file + Provide generic extract guided section functions. -Copyright (c) 2007, 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 + Copyright (c) 2007, 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. + 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: - - DxeExtractGuidedSectionLib.c - -Abstract: - - Provide generic extract guided section functions. - ---*/ +**/ #include diff --git a/MdePkg/Library/PeiExtractGuidedSectionLib/PeiExtractGuidedSectionLib.c b/MdePkg/Library/PeiExtractGuidedSectionLib/PeiExtractGuidedSectionLib.c index a360d59d85..aa6c2fa33e 100644 --- a/MdePkg/Library/PeiExtractGuidedSectionLib/PeiExtractGuidedSectionLib.c +++ b/MdePkg/Library/PeiExtractGuidedSectionLib/PeiExtractGuidedSectionLib.c @@ -1,23 +1,16 @@ -/*++ +/** @file + Provide generic extract guided section functions. -Copyright (c) 2007, 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 + Copyright (c) 2007, 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. + 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: - - PeiExtractGuidedSectionLib.c - -Abstract: - - Provide generic extract guided section functions. - ---*/ +**/ #include diff --git a/MdePkg/Library/PeiPiLib/PeiPiLib.c b/MdePkg/Library/PeiPiLib/PeiPiLib.c index d1e8611365..3030b1cd7f 100644 --- a/MdePkg/Library/PeiPiLib/PeiPiLib.c +++ b/MdePkg/Library/PeiPiLib/PeiPiLib.c @@ -32,6 +32,27 @@ CONST EFI_PEI_FIRMWARE_VOLUME_INFO_PPI mFvInfoPpiTemplate = { NULL //ParentFileName; }; +/** + Install a EFI_PEI_FIRMWARE_VOLUME_INFO PPI to inform PEI core about the existence of a new Firmware Volume. + + The function allocate the EFI_PEI_PPI_DESCRIPTOR structure and update the fields accordingly to parameter passed + in and install the PPI. + + @param FvFormat Unique identifier of the format of the memory-mapped firmware volume. If NULL is specified, + EFI_FIRMWARE_FILE_SYSTEM2_GUID is used as the Format GUID. + @param FvInfo Points to a buffer which allows the EFI_PEI_FIRMWARE_VOLUME_PPI to + process the volume. The format of this buffer is specific to the FvFormat. For + memory-mapped firmware volumes, this typically points to the first byte of the + firmware volume. + @param FvInfoSize Size of the data provided by FvInfo. For memory-mapped firmware volumes, this is + typically the size of the firmware volume. + @param ParentFvName, ParentFileName If the firmware volume originally came from a firmware file, then these point to the + parent firmware volume name and firmware volume file. If it did not originally come + from a firmware file, these should be NULL + + @retval VOID + +**/ VOID EFIAPI PiLibInstallFvInfoPpi ( diff --git a/MdePkg/Library/UefiScsiLib/UefiScsiLib.c b/MdePkg/Library/UefiScsiLib/UefiScsiLib.c index 6eb21dd878..5ac34334d0 100644 --- a/MdePkg/Library/UefiScsiLib/UefiScsiLib.c +++ b/MdePkg/Library/UefiScsiLib/UefiScsiLib.c @@ -25,8 +25,10 @@ @param[in] ScsiIo A pointer to SCSI IO protocol. @param[in] Timeout The length of timeout period. - @param[out] SenseData A pointer to output sense data. - @param[out] SenseDataLength The length of output sense data. + @param[in out] SenseData A pointer to the sense data that + was generated by the execution of the SCSI Request Packet. + @param[in out] SenseDataLength On input, the length in bytes of the SenseData buffer. On + output, the number of bytes written to the SenseData buffer. @param[out] HostAdapterStatus The status of Host Adapter. @param[out] TargetStatus The status of the target. @@ -40,7 +42,7 @@ queued. @retval EFI_DEVICE_ERROR A device error occurred while attempting to send the SCSI Request Packet. - @retval EFI_INVALID_PARAMETER The contents of CommandPacket are invalid. + @retval EFI_INVALID_PARAMETER The contents of CommandPacket are invalid, or ScsiIo is NULL. @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet is not supported by the SCSI initiator(i.e., SCSI Host Controller). @@ -52,8 +54,8 @@ EFI_STATUS ScsiTestUnitReadyCommand ( IN EFI_SCSI_IO_PROTOCOL *ScsiIo, IN UINT64 Timeout, - OUT VOID *SenseData, - OUT UINT8 *SenseDataLength, + IN OUT VOID *SenseData, + IN OUT UINT8 *SenseDataLength, OUT UINT8 *HostAdapterStatus, OUT UINT8 *TargetStatus ) @@ -65,6 +67,13 @@ ScsiTestUnitReadyCommand ( EFI_STATUS Status; UINT8 Cdb[6]; + ASSERT (SenseDataLength != NULL); + ASSERT (HostAdapterStatus != NULL); + ASSERT (TargetStatus != NULL); + + if (ScsiIo == NULL) { + return EFI_INVALID_PARAMETER; + } ZeroMem (&CommandPacket, sizeof (EFI_SCSI_IO_SCSI_REQUEST_PACKET)); ZeroMem (Cdb, 6); @@ -103,10 +112,11 @@ ScsiTestUnitReadyCommand ( @param[in] ScsiIo SCSI IO Protocol to use @param[in] Timeout The length of timeout period. @param[out] SenseData A pointer to output sense data. - @param[in,out] SenseDataLength The length of output sense data. + @param[in out] SenseDataLength On input, the length in bytes of the SenseData buffer. On + output, the number of bytes written to the SenseData buffer. @param[out] HostAdapterStatus The status of Host Adapter. @param[out] TargetStatus The status of the target. - @param[in,out] InquirydataBuffer A pointer to inquiry data buffer. + @param[in] InquirydataBuffer A pointer to inquiry data buffer. @param[in,out] InquiryDataLength The length of inquiry data buffer. @param[in] EnableVitalProductData Boolean to enable Vital Product Data. @@ -120,7 +130,7 @@ ScsiTestUnitReadyCommand ( queued. @retval EFI_DEVICE_ERROR A device error occurred while attempting to send the SCSI Request Packet. - @retval EFI_INVALID_PARAMETER The contents of CommandPacket are invalid. + @retval EFI_INVALID_PARAMETER The contents of CommandPacket are invalid, or ScsiIo is NULL. @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet is not supported by the SCSI initiator(i.e., SCSI Host Controller). @@ -136,7 +146,7 @@ ScsiInquiryCommand ( IN OUT UINT8 *SenseDataLength, OUT UINT8 *HostAdapterStatus, OUT UINT8 *TargetStatus, - IN OUT VOID *InquiryDataBuffer, + IN VOID *InquiryDataBuffer, IN OUT UINT32 *InquiryDataLength, IN BOOLEAN EnableVitalProductData ) @@ -148,6 +158,15 @@ ScsiInquiryCommand ( EFI_STATUS Status; UINT8 Cdb[6]; + ASSERT (SenseDataLength != NULL); + ASSERT (HostAdapterStatus != NULL); + ASSERT (TargetStatus != NULL); + ASSERT (InquiryDataLength != NULL); + + if (ScsiIo == NULL) { + return EFI_INVALID_PARAMETER; + } + ZeroMem (&CommandPacket, sizeof (EFI_SCSI_IO_SCSI_REQUEST_PACKET)); ZeroMem (Cdb, 6); @@ -192,7 +211,8 @@ ScsiInquiryCommand ( @param[in] ScsiIo A pointer to SCSI IO protocol. @param[in] Timeout The length of timeout period. @param[out] SenseData A pointer to output sense data. - @param[in,out] SenseDataLength The length of output sense data. + @param[in out] SenseDataLength On input, the length in bytes of the SenseData buffer. On + output, the number of bytes written to the SenseData buffer. @param[out] HostAdapterStatus The status of Host Adapter. @param[out] TargetStatus The status of the target. @param[in] DataBuffer A pointer to input data buffer. @@ -211,7 +231,7 @@ ScsiInquiryCommand ( queued. @retval EFI_DEVICE_ERROR A device error occurred while attempting to send the SCSI Request Packet. - @retval EFI_INVALID_PARAMETER The contents of CommandPacket are invalid. + @retval EFI_INVALID_PARAMETER The contents of CommandPacket are invalid, or ScsiIo is NULL. @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet is not supported by the SCSI initiator(i.e., SCSI Host Controller). @@ -241,6 +261,15 @@ ScsiModeSense10Command ( EFI_STATUS Status; UINT8 Cdb[10]; + ASSERT (SenseDataLength != NULL); + ASSERT (HostAdapterStatus != NULL); + ASSERT (TargetStatus != NULL); + ASSERT (DataLength != NULL); + + if (ScsiIo == NULL) { + return EFI_INVALID_PARAMETER; + } + ZeroMem (&CommandPacket, sizeof (EFI_SCSI_IO_SCSI_REQUEST_PACKET)); ZeroMem (Cdb, 10); @@ -278,19 +307,14 @@ ScsiModeSense10Command ( /** Function to submit SCSI request sense command. - ScsiIo - A pointer to SCSI IO protocol. - Timeout - The length of timeout period. - SenseData - A pointer to output sense data. - SenseDataLength - The length of output sense data. - HostAdapterStatus - The status of Host Adapter. - TargetStatus - The status of the target. - @param[in] ScsiIo SCSI IO Protocol to use - @param[in] Timeout TODO: - @param[out] SenseData TODO: - @param[in,out] SenseDataLength TODO: - @param[out] HostAdapterStatus TODO: - @param[out] TargetStatus TODO: + @param[in] ScsiIo A pointer to SCSI IO protocol. + @param[in] Timeout The length of timeout period. + @param[in] SenseData A pointer to output sense data. + @param[in out] SenseDataLength On input, the length in bytes of the SenseData buffer. On + output, the number of bytes written to the SenseData buffer. + @param[out] HostAdapterStatus The status of Host Adapter. + @param[out] TargetStatus The status of the target. @retval EFI_SUCCESS Valid data returned @retval EFI_SUCCESS The status of the unit is tested successfully. @@ -303,7 +327,7 @@ ScsiModeSense10Command ( queued. @retval EFI_DEVICE_ERROR A device error occurred while attempting to send the SCSI Request Packet. - @retval EFI_INVALID_PARAMETER The contents of CommandPacket are invalid. + @retval EFI_INVALID_PARAMETER The contents of CommandPacket are invalid, or ScsiIo is NULL. @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet is not supported by the SCSI initiator(i.e., SCSI Host Controller). @@ -328,6 +352,14 @@ ScsiRequestSenseCommand ( EFI_STATUS Status; UINT8 Cdb[6]; + ASSERT (SenseDataLength != NULL); + ASSERT (HostAdapterStatus != NULL); + ASSERT (TargetStatus != NULL); + + if (ScsiIo == NULL) { + return EFI_INVALID_PARAMETER; + } + ZeroMem (&CommandPacket, sizeof (EFI_SCSI_IO_SCSI_REQUEST_PACKET)); ZeroMem (Cdb, 6); @@ -366,7 +398,8 @@ ScsiRequestSenseCommand ( @param[in] ScsiIo A pointer to SCSI IO protocol. @param[in] Timeout The length of timeout period. @param[out] SenseData A pointer to output sense data. - @param[in,out] SenseDataLength The length of output sense data. + @param[in out] SenseDataLength On input, the length in bytes of the SenseData buffer. On + output, the number of bytes written to the SenseData buffer. @param[out] HostAdapterStatus The status of Host Adapter. @param[out] TargetStatus The status of the target. @param[out] DataBuffer A pointer to a data buffer. @@ -383,7 +416,7 @@ ScsiRequestSenseCommand ( queued. @retval EFI_DEVICE_ERROR A device error occurred while attempting to send the SCSI Request Packet. - @retval EFI_INVALID_PARAMETER The contents of CommandPacket are invalid. + @retval EFI_INVALID_PARAMETER The contents of CommandPacket are invalid, or ScsiIo is NULL. @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet is not supported by the SCSI initiator(i.e., SCSI Host Controller). @@ -411,6 +444,15 @@ ScsiReadCapacityCommand ( EFI_STATUS Status; UINT8 Cdb[10]; + ASSERT (SenseDataLength != NULL); + ASSERT (HostAdapterStatus != NULL); + ASSERT (TargetStatus != NULL); + ASSERT (DataLength != NULL); + + if (ScsiIo == NULL) { + return EFI_INVALID_PARAMETER; + } + ZeroMem (&CommandPacket, sizeof (EFI_SCSI_IO_SCSI_REQUEST_PACKET)); ZeroMem (Cdb, 10); @@ -457,7 +499,8 @@ ScsiReadCapacityCommand ( @param[in] ScsiIo A pointer to SCSI IO protocol. @param[in] Timeout The length of timeout period. @param[out] SenseData A pointer to output sense data. - @param[in,out] SenseDataLength The length of output sense data. + @param[in out] SenseDataLength On input, the length in bytes of the SenseData buffer. On + output, the number of bytes written to the SenseData buffer. @param[out] HostAdapterStatus The status of Host Adapter. @param[out] TargetStatus The status of the target. @param[out] DataBuffer Read 10 command data. @@ -475,7 +518,7 @@ ScsiReadCapacityCommand ( queued. @retval EFI_DEVICE_ERROR A device error occurred while attempting to send the SCSI Request Packet. - @retval EFI_INVALID_PARAMETER The contents of CommandPacket are invalid. + @retval EFI_INVALID_PARAMETER The contents of CommandPacket are invalid, or ScsiIo is NULL. @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet is not supported by the SCSI initiator(i.e., SCSI Host Controller). @@ -504,6 +547,15 @@ ScsiRead10Command ( EFI_STATUS Status; UINT8 Cdb[10]; + ASSERT (SenseDataLength != NULL); + ASSERT (HostAdapterStatus != NULL); + ASSERT (TargetStatus != NULL); + ASSERT (DataLength != NULL); + + if (ScsiIo == NULL) { + return EFI_INVALID_PARAMETER; + } + ZeroMem (&CommandPacket, sizeof (EFI_SCSI_IO_SCSI_REQUEST_PACKET)); ZeroMem (Cdb, 10); @@ -548,7 +600,8 @@ ScsiRead10Command ( @param[in] ScsiIo SCSI IO Protocol to use @param[in] Timeout The length of timeout period. @param[out] SenseData A pointer to output sense data. - @param[in,out] SenseDataLength The length of output sense data. + @param[in out] SenseDataLength On input, the length in bytes of the SenseData buffer. On + output, the number of bytes written to the SenseData buffer. @param[out] HostAdapterStatus The status of Host Adapter. @param[out] TargetStatus The status of the target. @param[out] DataBuffer A pointer to a data buffer. @@ -566,7 +619,7 @@ ScsiRead10Command ( queued. @retval EFI_DEVICE_ERROR A device error occurred while attempting to send the SCSI Request Packet. - @retval EFI_INVALID_PARAMETER The contents of CommandPacket are invalid. + @retval EFI_INVALID_PARAMETER The contents of CommandPacket are invalid, or ScsiIo is NULL. @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet is not supported by the SCSI initiator(i.e., SCSI Host Controller). @@ -595,6 +648,15 @@ ScsiWrite10Command ( EFI_STATUS Status; UINT8 Cdb[10]; + ASSERT (SenseDataLength != NULL); + ASSERT (HostAdapterStatus != NULL); + ASSERT (TargetStatus != NULL); + ASSERT (DataLength != NULL); + + if (ScsiIo == NULL) { + return EFI_INVALID_PARAMETER; + } + ZeroMem (&CommandPacket, sizeof (EFI_SCSI_IO_SCSI_REQUEST_PACKET)); ZeroMem (Cdb, 10); diff --git a/MdePkg/Library/UefiUsbLib/Hid.c b/MdePkg/Library/UefiUsbLib/Hid.c index 7c0ee14284..9391574fe0 100644 --- a/MdePkg/Library/UefiUsbLib/Hid.c +++ b/MdePkg/Library/UefiUsbLib/Hid.c @@ -38,6 +38,10 @@ UsbGetHidDescriptor ( UINT32 Status; EFI_STATUS Result; EFI_USB_DEVICE_REQUEST Request; + + if (UsbIo == NULL) { + return EFI_INVALID_PARAMETER; + } Request.RequestType = 0x81; Request.Request = 0x06; @@ -88,6 +92,9 @@ UsbGetReportDescriptor ( EFI_STATUS Result; EFI_USB_DEVICE_REQUEST Request; + if (UsbIo == NULL) { + return EFI_INVALID_PARAMETER; + } // // Fill Device request packet // @@ -137,6 +144,9 @@ UsbGetProtocolRequest ( EFI_STATUS Result; EFI_USB_DEVICE_REQUEST Request; + if (UsbIo == NULL) { + return EFI_INVALID_PARAMETER; + } // // Fill Device request packet // @@ -187,6 +197,9 @@ UsbSetProtocolRequest ( EFI_STATUS Result; EFI_USB_DEVICE_REQUEST Request; + if (UsbIo == NULL) { + return EFI_INVALID_PARAMETER; + } // // Fill Device request packet // @@ -238,6 +251,9 @@ UsbSetIdleRequest ( EFI_STATUS Result; EFI_USB_DEVICE_REQUEST Request; + if (UsbIo == NULL) { + return EFI_INVALID_PARAMETER; + } // // Fill Device request packet // @@ -287,7 +303,10 @@ UsbGetIdleRequest ( UINT32 Status; EFI_STATUS Result; EFI_USB_DEVICE_REQUEST Request; - + + if (UsbIo == NULL) { + return EFI_INVALID_PARAMETER; + } // // Fill Device request packet // @@ -344,6 +363,9 @@ UsbSetReportRequest ( EFI_STATUS Result; EFI_USB_DEVICE_REQUEST Request; + if (UsbIo == NULL) { + return EFI_INVALID_PARAMETER; + } // // Fill Device request packet // @@ -399,6 +421,9 @@ UsbGetReportRequest ( EFI_STATUS Result; EFI_USB_DEVICE_REQUEST Request; + if (UsbIo == NULL) { + return EFI_INVALID_PARAMETER; + } // // Fill Device request packet // diff --git a/MdePkg/Library/UefiUsbLib/UsbDxeLib.c b/MdePkg/Library/UefiUsbLib/UsbDxeLib.c index 90b0fd3ea5..a1d61d52bf 100644 --- a/MdePkg/Library/UefiUsbLib/UsbDxeLib.c +++ b/MdePkg/Library/UefiUsbLib/UsbDxeLib.c @@ -527,6 +527,10 @@ UsbClearEndpointHalt ( EFI_USB_INTERFACE_DESCRIPTOR InterfaceDescriptor; UINT8 Index; + if (UsbIo == NULL) { + return EFI_INVALID_PARAMETER; + } + ZeroMem (&EndpointDescriptor, sizeof (EFI_USB_ENDPOINT_DESCRIPTOR)); // // First seach the endpoint descriptor for that endpoint addr -- cgit v1.2.3