/** Internal function to PciCfg2 read/write opcode to the table. @param Marker The variable argument list to get the opcode and associated attributes. @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation. @retval EFI_SUCCESS Opcode is added. **/ EFI_STATUS BootScriptPciCfg2ReadWrite ( IN VA_LIST Marker ) { EFI_BOOT_SCRIPT_WIDTH Width; UINT16 Segment; UINT64 Address; UINT8 *Data; UINT8 *DataMask; Width = VA_ARG (Marker, EFI_BOOT_SCRIPT_WIDTH); Address = VA_ARG (Marker, UINT64); Segment = VA_ARG (Marker, UINT16); Data = VA_ARG (Marker, UINT8 *); DataMask = VA_ARG (Marker, UINT8 *); return mS3SaveState->Write ( mS3SaveState, EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE_OPCODE, Width, Segment, Address, Data, DataMask ); }
/** Internal function to add smbus excute opcode to the table. @param Marker The variable argument list to get the opcode and associated attributes. @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation. @retval EFI_SUCCESS Opcode is added. **/ EFI_STATUS BootScriptSmbusExecute ( IN VA_LIST Marker ) { EFI_SMBUS_DEVICE_ADDRESS SlaveAddress; EFI_SMBUS_DEVICE_COMMAND Command; EFI_SMBUS_OPERATION Operation; BOOLEAN PecCheck; VOID *Buffer; UINTN *DataSize; SlaveAddress.SmbusDeviceAddress = VA_ARG (Marker, UINTN); Command = VA_ARG (Marker, EFI_SMBUS_DEVICE_COMMAND); Operation = VA_ARG (Marker, EFI_SMBUS_OPERATION); PecCheck = VA_ARG (Marker, BOOLEAN); DataSize = VA_ARG (Marker, UINTN *); Buffer = VA_ARG (Marker, VOID *); return mS3SaveState->Write ( mS3SaveState, EFI_BOOT_SCRIPT_SMBUS_EXECUTE_OPCODE, SlaveAddress, Command, Operation, PecCheck, DataSize, Buffer ); }
/** Internal function to add memory pool operation to the table. @param Marker The variable argument list to get the opcode and associated attributes. @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation. @retval EFI_SUCCESS Opcode is added. **/ EFI_STATUS BootScriptMemPoll ( IN VA_LIST Marker ) { EFI_BOOT_SCRIPT_WIDTH Width; UINT64 Address; UINT8 *BitMask; UINT8 *BitValue; UINT64 Duration; UINT64 LoopTimes; UINT64 Delay; Width = VA_ARG (Marker, EFI_BOOT_SCRIPT_WIDTH); Address = VA_ARG (Marker, UINT64); BitMask = VA_ARG (Marker, UINT8 *); BitValue = VA_ARG (Marker, UINT8 *); Duration = (UINT64)VA_ARG (Marker, UINT64); LoopTimes = (UINT64)VA_ARG (Marker, UINT64); Delay = MultU64x64 (DivU64x32(Duration, 100), LoopTimes); return mS3SaveState->Write ( mS3SaveState, EFI_BOOT_SCRIPT_MEM_POLL_OPCODE, Width, Address, BitMask, BitValue, Delay ); }
/** Internal function to add PciCfg2 write opcode to the table. @param Marker The variable argument list to get the opcode and associated attributes. @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation. @retval EFI_SUCCESS Opcode is added. **/ EFI_STATUS BootScriptPciCfg2Write ( IN VA_LIST Marker ) { EFI_BOOT_SCRIPT_WIDTH Width; UINT64 Address; UINTN Count; UINT8 *Buffer; UINT16 Segment; Width = VA_ARG (Marker, EFI_BOOT_SCRIPT_WIDTH); Address = VA_ARG (Marker, UINT64); Count = VA_ARG (Marker, UINTN); Buffer = VA_ARG (Marker, UINT8 *); Segment = VA_ARG (Marker, UINT16); return mS3SaveState->Write ( mS3SaveState, EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE_OPCODE, Width, Segment, Address, Count, Buffer ); }
EFI_STATUS RegisterEsalClass ( IN EFI_GUID *ClassGuid, IN VOID *ModuleGlobal, ... ) /*++ Routine Description: Register ESAL Class and it's asociated global. This function is boot service only! Arguments: ClassGuid - GUID of function class ModuleGlobal - Module global for Function. ... - SAL_INTERNAL_EXTENDED_SAL_PROC and FunctionId pairs. NULL indicates the end of the list. Returns: EFI_SUCCESS - All members of ClassGuid registered --*/ { VA_LIST Args; EFI_STATUS Status; SAL_INTERNAL_EXTENDED_SAL_PROC Function; UINT64 FunctionId; EFI_HANDLE NewHandle; VA_START (Args, ModuleGlobal); Status = EFI_SUCCESS; while (!EFI_ERROR (Status)) { Function = (SAL_INTERNAL_EXTENDED_SAL_PROC) VA_ARG (Args, SAL_INTERNAL_EXTENDED_SAL_PROC); if (Function == NULL) { break; } FunctionId = VA_ARG (Args, UINT64); Status = RegisterEsalFunction (FunctionId, ClassGuid, Function, ModuleGlobal); } if (EFI_ERROR (Status)) { return Status; } NewHandle = NULL; return gBS->InstallProtocolInterface ( &NewHandle, ClassGuid, EFI_NATIVE_INTERFACE, NULL ); }
/** * Execute a request. */ TInt CMockCellBroadcastMessHandler::ExtFuncL(TInt aInterfaceId, VA_LIST& aList) { switch (aInterfaceId) { case MLtsyDispatchCellBroadcastActivateBroadcastReceiveMessage::KLtsyDispatchCellBroadcastActivateBroadcastReceiveMessageApiId: { RMobileBroadcastMessaging::TMobilePhoneBroadcastFilter filterSetting = VA_ARG_ENUM(aList, RMobileBroadcastMessaging::TMobilePhoneBroadcastFilter); TMockLtsyData1<RMobileBroadcastMessaging::TMobilePhoneBroadcastFilter> data(filterSetting); return iMockLtsyEngine.ExecuteCommandL(aInterfaceId, data); } case MLtsyDispatchCellBroadcastReceiveMessageCancel::KLtsyDispatchCellBroadcastReceiveMessageCancelApiId: { RMobileBroadcastMessaging::TMobilePhoneBroadcastFilter filterSetting = VA_ARG_ENUM(aList, RMobileBroadcastMessaging::TMobilePhoneBroadcastFilter); TMockLtsyData1<RMobileBroadcastMessaging::TMobilePhoneBroadcastFilter> data(filterSetting); return iMockLtsyEngine.ExecuteCommandL(aInterfaceId, data); } case MLtsyDispatchCellBroadcastSetBroadcastFilterSetting::KLtsyDispatchCellBroadcastSetBroadcastFilterSettingApiId: { RMobileBroadcastMessaging::TMobilePhoneBroadcastFilter filterSetting = VA_ARG_ENUM(aList, RMobileBroadcastMessaging::TMobilePhoneBroadcastFilter); TMockLtsyData1<RMobileBroadcastMessaging::TMobilePhoneBroadcastFilter> data(filterSetting); return iMockLtsyEngine.ExecuteCommandL(aInterfaceId, data); } case MLtsyDispatchCellBroadcastStartSimCbTopicBrowsing::KLtsyDispatchCellBroadcastStartSimCbTopicBrowsingApiId: { TMockLtsyData0 data; return iMockLtsyEngine.ExecuteCommandL(aInterfaceId, data); } case MLtsyDispatchCellBroadcastDeleteSimCbTopic::KLtsyDispatchCellBroadcastDeleteSimCbTopicApiId: { TUint index = VA_ARG(aList, TUint); TBool deleteFlag = VA_ARG(aList, TBool); TMockLtsyData2<TUint, TBool> data(index, deleteFlag); return iMockLtsyEngine.ExecuteCommandL(aInterfaceId, data); } case KMockLtsyDispatchCellBroadcastGsmBroadcastNotifyMessageReceivedIndId: case KMockLtsyDispatchCellBroadcastWcdmaBroadcastMessageReceivedIndId: default: { _LIT(KTempPanic, "Here to remind coder to add code to deserialise data otherwise test passes even though CTSY sends down the incorrect data"); User::Panic(KTempPanic, KErrGeneral); TMockLtsyData0 data; return iMockLtsyEngine.ExecuteCommandL(aInterfaceId, data); } } } // CMockCellBroadcastMessHandler::ExtFuncL
/** Internal function to add INFORAMTION opcode node to the table list. @param Marker The variable argument list to get the opcode and associated attributes. @retval EFI_OUT_OF_RESOURCES Not enought resource to complete the operations. @retval EFI_SUCCESS The opcode entry is added to the table successfully. **/ EFI_STATUS BootScriptWriteInformation ( IN VA_LIST Marker ) { UINT32 InformationLength; EFI_PHYSICAL_ADDRESS Information; InformationLength = VA_ARG (Marker, UINT32); Information = VA_ARG (Marker, EFI_PHYSICAL_ADDRESS); return S3BootScriptSaveInformation (InformationLength, (VOID*)(UINTN)Information); }
/** Internal function to add Save jmp address according to DISPATCH_OPCODE2. The "Context" parameter is not ignored. @param Marker The variable argument list to get the opcode and associated attributes. @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation. @retval EFI_SUCCESS Opcode is added. **/ EFI_STATUS BootScriptWriteDispatch2 ( IN VA_LIST Marker ) { VOID *EntryPoint; VOID *Context; EntryPoint = (VOID*)(UINTN)VA_ARG (Marker, EFI_PHYSICAL_ADDRESS); Context = (VOID*)(UINTN)VA_ARG (Marker, EFI_PHYSICAL_ADDRESS); return S3BootScriptSaveDispatch2 (EntryPoint, Context); }
/** Internal function to add IO read/write opcode to the table. @param Marker The variable argument list to get the opcode and associated attributes. @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation. @retval EFI_SUCCESS Opcode is added. **/ EFI_STATUS BootScriptWriteIoReadWrite ( IN VA_LIST Marker ) { S3_BOOT_SCRIPT_LIB_WIDTH Width; UINT64 Address; UINT8 *Data; UINT8 *DataMask; Width = VA_ARG (Marker, S3_BOOT_SCRIPT_LIB_WIDTH); Address = VA_ARG (Marker, UINT64); Data = VA_ARG (Marker, UINT8 *); DataMask = VA_ARG (Marker, UINT8 *); return S3BootScriptSaveIoReadWrite (Width, Address, Data, DataMask); }
/** Internal function to add memory write opcode to the table. @param Marker The variable argument list to get the opcode and associated attributes. @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation. @retval EFI_SUCCESS Opcode is added. **/ EFI_STATUS BootScriptWriteMemWrite ( IN VA_LIST Marker ) { S3_BOOT_SCRIPT_LIB_WIDTH Width; UINT64 Address; UINTN Count; UINT8 *Buffer; Width = VA_ARG (Marker, S3_BOOT_SCRIPT_LIB_WIDTH); Address = VA_ARG (Marker, UINT64); Count = VA_ARG (Marker, UINTN); Buffer = VA_ARG (Marker, UINT8 *); return S3BootScriptSaveMemWrite (Width, Address, Count, Buffer); }
/** Prints a debug message to the debug output device if the specified error level is enabled. If any bit in ErrorLevel is also set in PcdDebugPrintErrorLevel, then print the message specified by Format and the associated variable argument list to the debug output device. If Format is NULL, then ASSERT(). @param ErrorLevel The error level of the debug message. @param Format Format string for the debug message to print. **/ VOID EFIAPI DebugPrint ( IN UINTN ErrorLevel, IN CONST CHAR8 *Format, ... ) { UINT64 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE / sizeof (UINT64)]; EFI_DEBUG_INFO *DebugInfo; UINTN TotalSize; UINTN Index; VA_LIST Marker; UINT64 *ArgumentPointer; // // If Format is NULL, then ASSERT(). // ASSERT (Format != NULL); // // Check driver Debug Level value and global debug level // if ((ErrorLevel & PcdGet32(PcdDebugPrintErrorLevel)) == 0) { return; } TotalSize = sizeof (EFI_DEBUG_INFO) + 12 * sizeof (UINT64) + AsciiStrLen (Format) + 1; if (TotalSize > EFI_STATUS_CODE_DATA_MAX_SIZE) { return; } // // Then EFI_DEBUG_INFO // DebugInfo = (EFI_DEBUG_INFO *)Buffer; DebugInfo->ErrorLevel = (UINT32)ErrorLevel; // // 256 byte mini Var Arg stack. That is followed by the format string. // VA_START (Marker, Format); for (Index = 0, ArgumentPointer = (UINT64 *)(DebugInfo + 1); Index < 12; Index++, ArgumentPointer++) { WriteUnaligned64(ArgumentPointer, VA_ARG (Marker, UINT64)); } VA_END (Marker); AsciiStrCpy ((CHAR8 *)ArgumentPointer, Format); REPORT_STATUS_CODE_EX ( EFI_DEBUG_CODE, (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_DC_UNSPECIFIED), 0, NULL, &gEfiStatusCodeDataTypeDebugGuid, DebugInfo, TotalSize ); }
/** Internal function to add memory pool operation to the table. @param Marker The variable argument list to get the opcode and associated attributes. @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation. @retval EFI_SUCCESS Opcode is added. **/ EFI_STATUS BootScriptMemPoll ( IN VA_LIST Marker ) { EFI_BOOT_SCRIPT_WIDTH Width; UINT64 Address; UINT8 *BitMask; UINT8 *BitValue; UINT64 Duration; UINT64 LoopTimes; UINT64 Delay; Width = VA_ARG (Marker, EFI_BOOT_SCRIPT_WIDTH); Address = VA_ARG (Marker, UINT64); BitMask = VA_ARG (Marker, UINT8 *); BitValue = VA_ARG (Marker, UINT8 *); Duration = (UINT64)VA_ARG (Marker, UINT64); LoopTimes = (UINT64)VA_ARG (Marker, UINT64); // // Framework version: Duration is used for Stall(), which is Microseconds. // Total time is: Duration(Microseconds) * LoopTimes. // PI version: Duration is always 100ns. Delay is LoopTimes. // Total time is: 100ns * Delay. // So Delay = Duration(Microseconds) * LoopTimes / 100ns // = Duration * 1000ns * LoopTimes / 100ns // = Duration * 10 * LoopTimes // Delay = MultU64x64 (MultU64x32 (Duration, 10), LoopTimes); // // Framework version: First BitMask, then BitValue // PI version: First Data, then DataMask // So we revert their order in function call // return mS3SaveState->Write ( mS3SaveState, EFI_BOOT_SCRIPT_MEM_POLL_OPCODE, Width, Address, BitValue, BitMask, Delay ); }
/** Internal function to add the opcode link node to the link list. @param Marker The variable argument list to get the opcode and associated attributes. @retval EFI_OUT_OF_RESOURCES Not enought resource to complete the operations. @retval EFI_SUCCESS The opcode entry is added to the link list successfully. **/ EFI_STATUS BootScriptInformation ( IN VA_LIST Marker ) { UINT32 InformationLength; EFI_PHYSICAL_ADDRESS Information; InformationLength = VA_ARG (Marker, UINT32); Information = VA_ARG (Marker, EFI_PHYSICAL_ADDRESS); return mS3SaveState->Write ( mS3SaveState, EFI_BOOT_SCRIPT_INFORMATION_OPCODE, InformationLength, (VOID*)(UINTN)Information ); }
/** Internal function to add Save jmp address according to DISPATCH_OPCODE2. The "Context" parameter is not ignored. @param Marker The variable argument list to get the opcode and associated attributes. @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation. @retval EFI_SUCCESS Opcode is added. **/ EFI_STATUS BootScriptDispatch2 ( IN VA_LIST Marker ) { VOID *EntryPoint; VOID *Context; EntryPoint = (VOID*)(UINTN)VA_ARG (Marker, EFI_PHYSICAL_ADDRESS); Context = (VOID*)(UINTN)VA_ARG (Marker, EFI_PHYSICAL_ADDRESS); return mS3SaveState->Write ( mS3SaveState, EFI_BOOT_SCRIPT_DISPATCH_2_OPCODE, EntryPoint, Context ); }
EFI_STATUS BootScriptPciCfgWrite ( IN EFI_SMM_SCRIPT_TABLE *ScriptTable, IN VA_LIST Marker ) { BOOT_SCRIPT_POINTERS Script; EFI_BOOT_SCRIPT_WIDTH Width; UINT64 Address; UINTN Count; UINT8 *Buffer; UINTN NodeLength; UINT8 WidthInByte; Width = VA_ARG(Marker, EFI_BOOT_SCRIPT_WIDTH); Address = VA_ARG(Marker, UINT64); Count = VA_ARG(Marker, UINTN); Buffer = VA_ARG(Marker, UINT8*); WidthInByte = (UINT8)(0x01 << (Width & 0x03)); Script.Raw = (UINT8*) ((UINTN)(*ScriptTable)); NodeLength = sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE) + (WidthInByte * Count); // // Build script data // Script.PciWrite->OpCode = EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE_OPCODE; Script.PciWrite->Length = (UINT8)(NodeLength); Script.PciWrite->Width = Width; Script.PciWrite->Address = Address; Script.PciWrite->Count = (UINT32)Count; SmmCopyMem ( (UINT8*)(Script.Raw + sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE)), Buffer, WidthInByte * Count ); // // Update Script table pointer // *ScriptTable = *ScriptTable + NodeLength; return EFI_SUCCESS; }
/** Internal function to add IO poll opcode node to the table @param Marker The variable argument list to get the opcode and associated attributes. @retval EFI_OUT_OF_RESOURCES Not enought resource to complete the operations. @retval EFI_SUCCESS The opcode entry is added to the table successfully. **/ EFI_STATUS BootScriptWriteIoPoll ( IN VA_LIST Marker ) { S3_BOOT_SCRIPT_LIB_WIDTH Width; UINT64 Address; VOID *Data; VOID *DataMask; UINT64 Delay; Width = VA_ARG (Marker, S3_BOOT_SCRIPT_LIB_WIDTH); Address = VA_ARG (Marker, UINT64); Data = VA_ARG (Marker, VOID *); DataMask = VA_ARG (Marker, VOID *); Delay = (UINT64)VA_ARG (Marker, UINT64); return S3BootScriptSaveIoPoll (Width, Address, Data, DataMask, Delay); }
/** Internal function to add stall opcode to the table. @param Marker The variable argument list to get the opcode and associated attributes. @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation. @retval EFI_SUCCESS Opcode is added. **/ EFI_STATUS BootScriptWriteStall ( IN VA_LIST Marker ) { UINT32 Duration; Duration = VA_ARG (Marker, UINT32); return S3BootScriptSaveStall (Duration); }
Object * VARARGS68K DoSuperNew(struct IClass *cl, Object *obj, ...) { Object *rc; VA_LIST args; VA_START(args, obj); rc = (Object *)DoSuperMethod(cl, obj, OM_NEW, VA_ARG(args, ULONG), NULL); VA_END(args); return rc; }
/** Internal function to add memory pool operation to the table. @param Marker The variable argument list to get the opcode and associated attributes. @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation. @retval EFI_SUCCESS Opcode is added. **/ EFI_STATUS BootScriptWriteMemPoll ( IN VA_LIST Marker ) { S3_BOOT_SCRIPT_LIB_WIDTH Width; UINT64 Address; VOID *Data; VOID *DataMask; UINT64 Delay; UINT64 LoopTimes; UINT32 Remainder; Width = VA_ARG (Marker, S3_BOOT_SCRIPT_LIB_WIDTH); Address = VA_ARG (Marker, UINT64); Data = VA_ARG (Marker, VOID *); DataMask = VA_ARG (Marker, VOID *); Delay = VA_ARG (Marker, UINT64); // // According to the spec, the interval between 2 polls is 100ns, // but the unit of Duration for S3BootScriptSaveMemPoll() is microsecond(1000ns). // Duration * 1000ns * LoopTimes = Delay * 100ns // Duration will be minimum 1(microsecond) to be minimum deviation, // so LoopTimes = Delay / 10. // LoopTimes = DivU64x32Remainder ( Delay, 10, &Remainder ); if (Remainder != 0) { // // If Remainder is not zero, LoopTimes will be rounded up by 1. // LoopTimes +=1; } return S3BootScriptSaveMemPoll (Width, Address, DataMask, Data, 1, LoopTimes); }
/** Internal function to add smbus execute opcode to the table. @param Marker The variable argument list to get the opcode and associated attributes. @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation. @retval EFI_SUCCESS Opcode is added. **/ EFI_STATUS BootScriptWriteSmbusExecute ( IN VA_LIST Marker ) { EFI_SMBUS_DEVICE_ADDRESS SlaveAddress; EFI_SMBUS_DEVICE_COMMAND Command; EFI_SMBUS_OPERATION Operation; BOOLEAN PecCheck; VOID *Buffer; UINTN *DataSize; UINTN SmBusAddress; SlaveAddress.SmbusDeviceAddress = VA_ARG (Marker, UINTN); Command = VA_ARG (Marker, EFI_SMBUS_DEVICE_COMMAND); Operation = VA_ARG (Marker, EFI_SMBUS_OPERATION); PecCheck = VA_ARG (Marker, BOOLEAN); SmBusAddress = SMBUS_LIB_ADDRESS (SlaveAddress.SmbusDeviceAddress,Command,0,PecCheck); DataSize = VA_ARG (Marker, UINTN *); Buffer = VA_ARG (Marker, VOID *); return S3BootScriptSaveSmbusExecute (SmBusAddress, Operation, DataSize, Buffer); }
/** Internal function to add stall opcode to the table. @param Marker The variable argument list to get the opcode and associated attributes. @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation. @retval EFI_SUCCESS Opcode is added. **/ EFI_STATUS BootScriptStall ( IN VA_LIST Marker ) { UINT32 Duration; Duration = VA_ARG (Marker, UINT32); return mS3SaveState->Write ( mS3SaveState, EFI_BOOT_SCRIPT_STALL_OPCODE, Duration ); }
/** Internal function to add IO read/write opcode to the table. @param Marker The variable argument list to get the opcode and associated attributes. @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation. @retval EFI_SUCCESS Opcode is added. **/ EFI_STATUS BootScriptIoReadWrite ( IN VA_LIST Marker ) { EFI_BOOT_SCRIPT_WIDTH Width; UINT64 Address; UINT8 *Data; UINT8 *DataMask; Width = VA_ARG (Marker, EFI_BOOT_SCRIPT_WIDTH); Address = VA_ARG (Marker, UINT64); Data = VA_ARG (Marker, UINT8 *); DataMask = VA_ARG (Marker, UINT8 *); return mS3SaveState->Write ( mS3SaveState, EFI_BOOT_SCRIPT_IO_READ_WRITE_OPCODE, Width, Address, Data, DataMask ); }
/** Internal function to add IO write opcode to the table. @param Marker The variable argument list to get the opcode and associated attributes. @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation. @retval EFI_SUCCESS Opcode is added. **/ EFI_STATUS BootScriptIoWrite ( IN VA_LIST Marker ) { EFI_BOOT_SCRIPT_WIDTH Width; UINT64 Address; UINTN Count; UINT8 *Buffer; Width = VA_ARG (Marker, EFI_BOOT_SCRIPT_WIDTH); Address = VA_ARG (Marker, UINT64); Count = VA_ARG (Marker, UINTN); Buffer = VA_ARG (Marker, UINT8 *); return mS3SaveState->Write ( mS3SaveState, EFI_BOOT_SCRIPT_IO_WRITE_OPCODE, Width, Address, Count, Buffer ); }
/** * Execute a request. */ TInt CMockCallControlMultipartyMessHandler::ExtFuncL(TInt aInterfaceId, VA_LIST& aList) { switch (aInterfaceId) { case MLtsyDispatchCallControlMultipartyConferenceHangUp::KLtsyDispatchCallControlMultipartyConferenceHangUpApiId: { RArray<TInt>& callIds = *VA_ARG(aList, RArray<TInt>* ); TMockLtsyData1<RArray<TInt> > data(callIds); return iMockLtsyEngine.ExecuteCommandL(aInterfaceId, data); } case MLtsyDispatchCallControlMultipartyConferenceAddCall::KLtsyDispatchCallControlMultipartyConferenceAddCallApiId: { TInt callId = VA_ARG(aList, TInt); TInt existingCallId = VA_ARG(aList, TInt); TMockLtsyData2<TInt, TInt> data(callId, existingCallId); return iMockLtsyEngine.ExecuteCommandL(aInterfaceId, data); } case MLtsyDispatchCallControlMultipartyCreateConference::KLtsyDispatchCallControlMultipartyCreateConferenceApiId: { TInt heldCallId = VA_ARG(aList, TInt); TInt secondCallId = VA_ARG(aList, TInt); TMockLtsyData2<TInt, TInt> data(heldCallId, secondCallId); return iMockLtsyEngine.ExecuteCommandL(aInterfaceId, data); } case MLtsyDispatchCallControlMultipartyConferenceSwap::KLtsyDispatchCallControlMultipartyConferenceSwapApiId: { TInt heldCallId = VA_ARG(aList, TInt); TInt connectedCallId = VA_ARG(aList, TInt); TMockLtsyData2<TInt, TInt> data(heldCallId, connectedCallId); return iMockLtsyEngine.ExecuteCommandL(aInterfaceId, data); } case MLtsyDispatchCallControlMultipartyConferenceGoOneToOne::KLtsyDispatchCallControlMultipartyConferenceGoOneToOneApiId: { TInt callId = VA_ARG(aList, TInt); TMockLtsyData1<TInt> data(callId); return iMockLtsyEngine.ExecuteCommandL(aInterfaceId, data); } default: { _LIT(KTempPanic, "Here to remind coder to add code to deserialise data otherwise test passes even though CTSY sends down the incorrect data"); User::Panic(KTempPanic, KErrGeneral); TMockLtsyData0 data; return iMockLtsyEngine.ExecuteCommandL(aInterfaceId, data); } } } // CMockCallControlMultipartyMessHandler::ExtFuncL
/** Internal function to add Save jmp address according to DISPATCH_OPCODE. We ignore "Context" parameter. We need create thunk stub to convert PEI entrypoint (used in Framework version) to DXE entrypoint (defined in PI spec). @param Marker The variable argument list to get the opcode and associated attributes. @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation. @retval EFI_SUCCESS Opcode is added. **/ EFI_STATUS FrameworkBootScriptDispatch ( IN VA_LIST Marker ) { VOID *EntryPoint; VOID *Context; EntryPoint = (VOID*)(UINTN)VA_ARG (Marker, EFI_PHYSICAL_ADDRESS); // // Register callback // Context = EntryPoint; EntryPoint = (VOID *)(UINTN)FrameworkBootScriptDispatchStub; return mS3SaveState->Write ( mS3SaveState, EFI_BOOT_SCRIPT_DISPATCH_2_OPCODE, EntryPoint, Context ); }
/** Erases and initializes a firmware volume block. The EraseBlocks() function erases one or more blocks as denoted by the variable argument list. The entire parameter list of blocks must be verified before erasing any blocks. If a block is requested that does not exist within the associated firmware volume (it has a larger index than the last block of the firmware volume), the EraseBlocks() function must return the status code EFI_INVALID_PARAMETER without modifying the contents of the firmware volume. Implementations should be mindful that the firmware volume might be in the WriteDisabled state. If it is in this state, the EraseBlocks() function must return the status code EFI_ACCESS_DENIED without modifying the contents of the firmware volume. All calls to EraseBlocks() must be fully flushed to the hardware before the EraseBlocks() service returns. @param This Indicates the EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL instance. @param ... The variable argument list is a list of tuples. Each tuple describes a range of LBAs to erase and consists of the following: - An EFI_LBA that indicates the starting LBA - A UINTN that indicates the number of blocks to erase The list is terminated with an EFI_LBA_LIST_TERMINATOR. For example, the following indicates that two ranges of blocks (5-7 and 10-11) are to be erased: EraseBlocks (This, 5, 3, 10, 2, EFI_LBA_LIST_TERMINATOR); @retval EFI_SUCCESS The erase request was successfully completed. @retval EFI_ACCESS_DENIED The firmware volume is in the WriteDisabled state. @retval EFI_DEVICE_ERROR The block device is not functioning correctly and could not be written. The firmware device may have been partially erased. @retval EFI_INVALID_PARAMETER One or more of the LBAs listed in the variable argument list do not exist in the firmware volume. **/ EFI_STATUS EFIAPI FvbProtocolEraseBlocks ( IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This, ... ) { EFI_FW_VOL_BLOCK_DEVICE *FvbDevice; VA_LIST args; EFI_LBA StartingLba; UINTN NumOfLba; UINT8 Erase; VOID *ErasePtr; UINTN EraseSize; FvbDevice = FVB_DEVICE_FROM_THIS (This); Erase = 0; VA_START (args, This); do { StartingLba = VA_ARG (args, EFI_LBA); if (StartingLba == EFI_LBA_LIST_TERMINATOR) { break; } NumOfLba = VA_ARG (args, UINT32); // // Check input parameters // if ((NumOfLba == 0) || (StartingLba > 1) || ((StartingLba + NumOfLba) > 2)) { VA_END (args); return EFI_INVALID_PARAMETER; } if (StartingLba == 0) { Erase = (UINT8) (Erase | BIT0); } if ((StartingLba + NumOfLba) == 2) { Erase = (UINT8) (Erase | BIT1); } } while (1); VA_END (args); ErasePtr = (UINT8*) FvbDevice->BufferPtr; EraseSize = 0; if ((Erase & BIT0) != 0) { EraseSize = EraseSize + FvbDevice->BlockSize; } else { ErasePtr = (VOID*) ((UINT8*)ErasePtr + FvbDevice->BlockSize); } if ((Erase & BIT1) != 0) { EraseSize = EraseSize + FvbDevice->BlockSize; } if (EraseSize != 0) { SetMem ( (VOID*) ErasePtr, EraseSize, ERASED_UINT8 ); VA_START (args, This); PlatformFvbBlocksErased (This, args); VA_END (args); } return EFI_SUCCESS; }
EFI_STATUS EFIAPI FvbProtocolEraseBlocks ( IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, ... ) /*++ Routine Description: The EraseBlock() function erases one or more blocks as denoted by the variable argument list. The entire parameter list of blocks must be verified prior to erasing any blocks. If a block is requested that does not exist within the associated firmware volume (it has a larger index than the last block of the firmware volume), the EraseBlock() function must return EFI_INVALID_PARAMETER without modifying the contents of the firmware volume. Arguments: This - Calling context ... - Starting LBA followed by Number of Lba to erase. a -1 to terminate the list. Returns: EFI_SUCCESS - The erase request was successfully completed EFI_ACCESS_DENIED - The firmware volume is in the WriteDisabled state EFI_DEVICE_ERROR - The block device is not functioning correctly and could not be written. Firmware device may have been partially erased **/ { EFI_FW_VOL_BLOCK_DEVICE *FvbDevice; EFI_FW_VOL_INSTANCE *FwhInstance = NULL; UINTN NumOfBlocks; VA_LIST args; EFI_LBA StartingLba; UINTN NumOfLba; EFI_STATUS Status; FvbDevice = FVB_DEVICE_FROM_THIS (This); Status = GetFvbInstance (FvbDevice->Instance, mFvbModuleGlobal, &FwhInstance, EfiGoneVirtual ()); ASSERT_EFI_ERROR (Status); NumOfBlocks = FwhInstance->NumOfBlocks; VA_START (args, This); do { StartingLba = VA_ARG (args, EFI_LBA); if (StartingLba == EFI_LBA_LIST_TERMINATOR) { break; } NumOfLba = VA_ARG (args, UINTN); // // Check input parameters // if (NumOfLba == 0 || (StartingLba + NumOfLba) > NumOfBlocks) { VA_END (args); return EFI_INVALID_PARAMETER; } } while (1); VA_END (args); VA_START (args, This); do { StartingLba = VA_ARG (args, EFI_LBA); if (StartingLba == EFI_LBA_LIST_TERMINATOR) { break; } NumOfLba = VA_ARG (args, UINTN); while (NumOfLba > 0) { Status = FvbEraseBlock (FvbDevice->Instance, StartingLba, mFvbModuleGlobal, EfiGoneVirtual ()); if (EFI_ERROR (Status)) { VA_END (args); return Status; } StartingLba++; NumOfLba--; } } while (1); VA_END (args); return EFI_SUCCESS; }
/* * snprintf is a bound version of the popular sprintf() function. * The purpose of snprintf is to format just like sprintf(), but * to make sure that memory is never accidentally overwritten by * a buffer overrun. * * A stripped down version of snprintf for the pic16 platform of the * sdcc project. Depending on the compile flags set/unset above this * function varies in size from ~16k down to ~5. Below is the * breakdown: * * SUPPORT_CHAR_C - c format - ~0.5k of program space required * SUPPORT_STRING - s format - ~1.6k of program space required * * I don't think I have any type of optimization on when I did these * measurements. They were taken with a snapshot build of sdcc from * January 22, 2005 (end of day). * * Supported formatting: * %%, %c, %[ 0][1-9][0-9]*s * \ * \-- optional padding value * * For more detail on what this formatting means, google 'man printf' * * Parameters: * ---------------------------------------------------------------------- * char *buffer -- the buffer to write into (assumed to * not be NULL) * const unsigned char size -- the maximum number of bytes to write * into the buffer * const char *format -- the printf style formatter string (see * above for supported formats. * * Return Values: * ---------------------------------------------------------------------- * The actual number of characters written into the buffer. The count * includes the '\0' located at the end of the string. If there is * not enough room for the entire string, the '\0' value is written in * as the buffer[end - 1] value. */ unsigned char SDCC_SNPRINTF( char *buffer, const unsigned char size, const char *format, ... ) { va_list args; char *start = buffer; char *end = &buffer[size]; va_start( args, format ); while( (buffer < end) && ('\0' != *format) ) { if( '%' == *format ) { format++; switch( *format ) { #ifdef SUPPORT_CHAR_C case 'c': *buffer = VA_ARG( args, VA_ARG_CHAR ); buffer++; break; #endif /* SUPPORT_CHAR_C */ case '%': *buffer = '%'; buffer++; break; default: { char padding = ' '; short digits = 0; /* Determine the padding */ switch( *format ) { case '0': padding = '0'; case ' ': format++; break; } /* Determine how many digits to display */ while( ('\0' != *format) && ((*format >= '0') && (*format <= '9')) ) { digits = digits * 10 + (*format - '0'); format++; } switch( *format ) { case 's': { char *val, *val_end; short length; val = VA_ARG( args, char * ); val_end = val; /* Find the end of the string. */ while( '\0' != *val_end ) { val_end++; } length = val_end - val; /* Optionally crop the output string */ if( (digits > 0) && (length > digits) ) { length = digits; } /* Add padding */ while( (digits > length) && (buffer < end) ) { *buffer = padding; buffer++; digits--; } /* Copy string */ while( (length > 0) && (buffer < end) ) { *buffer = *val; buffer++; val++; length--; } break; } default: goto clean_and_bail; } break; } } } else {
/** Erases and initialises a firmware volume block. The EraseBlocks() function erases one or more blocks as denoted by the variable argument list. The entire parameter list of blocks must be verified before erasing any blocks. If a block is requested that does not exist within the associated firmware volume (it has a larger index than the last block of the firmware volume), the EraseBlocks() function must return the status code EFI_INVALID_PARAMETER without modifying the contents of the firmware volume. Implementations should be mindful that the firmware volume might be in the WriteDisabled state. If it is in this state, the EraseBlocks() function must return the status code EFI_ACCESS_DENIED without modifying the contents of the firmware volume. All calls to EraseBlocks() must be fully flushed to the hardware before the EraseBlocks() service returns. @param This Indicates the EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL instance. @param ... The variable argument list is a list of tuples. Each tuple describes a range of LBAs to erase and consists of the following: - An EFI_LBA that indicates the starting LBA - A UINTN that indicates the number of blocks to erase. The list is terminated with an EFI_LBA_LIST_TERMINATOR. For example, the following indicates that two ranges of blocks (5-7 and 10-11) are to be erased: EraseBlocks (This, 5, 3, 10, 2, EFI_LBA_LIST_TERMINATOR); @retval EFI_SUCCESS The erase request successfully completed. @retval EFI_ACCESS_DENIED The firmware volume is in the WriteDisabled state. @retval EFI_DEVICE_ERROR The block device is not functioning correctly and could not be written. The firmware device may have been partially erased. @retval EFI_INVALID_PARAMETER One or more of the LBAs listed in the variable argument list do not exist in the firmware volume. **/ EFI_STATUS EFIAPI FvbEraseBlocks ( IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This, ... ) { EFI_STATUS Status; VA_LIST Args; UINTN BlockAddress; // Physical address of Lba to erase EFI_LBA StartingLba; // Lba from which we start erasing UINTN NumOfLba; // Number of Lba blocks to erase NOR_FLASH_INSTANCE *Instance; Instance = INSTANCE_FROM_FVB_THIS(This); DEBUG ((DEBUG_BLKIO, "FvbEraseBlocks()\n")); Status = EFI_SUCCESS; // Detect WriteDisabled state if (Instance->Media.ReadOnly == TRUE) { // Firmware volume is in WriteDisabled state DEBUG ((EFI_D_ERROR, "FvbEraseBlocks: ERROR - Device is in WriteDisabled state.\n")); return EFI_ACCESS_DENIED; } // Before erasing, check the entire list of parameters to ensure all specified blocks are valid VA_START (Args, This); do { // Get the Lba from which we start erasing StartingLba = VA_ARG (Args, EFI_LBA); // Have we reached the end of the list? if (StartingLba == EFI_LBA_LIST_TERMINATOR) { //Exit the while loop break; } // How many Lba blocks are we requested to erase? NumOfLba = VA_ARG (Args, UINT32); // All blocks must be within range DEBUG ((DEBUG_BLKIO, "FvbEraseBlocks: Check if: ( StartingLba=%ld + NumOfLba=%d - 1 ) > LastBlock=%ld.\n", Instance->StartLba + StartingLba, NumOfLba, Instance->Media.LastBlock)); if ((NumOfLba == 0) || ((Instance->StartLba + StartingLba + NumOfLba - 1) > Instance->Media.LastBlock)) { VA_END (Args); DEBUG ((EFI_D_ERROR, "FvbEraseBlocks: ERROR - Lba range goes past the last Lba.\n")); Status = EFI_INVALID_PARAMETER; goto EXIT; } } while (TRUE); VA_END (Args); // // To get here, all must be ok, so start erasing // VA_START (Args, This); do { // Get the Lba from which we start erasing StartingLba = VA_ARG (Args, EFI_LBA); // Have we reached the end of the list? if (StartingLba == EFI_LBA_LIST_TERMINATOR) { // Exit the while loop break; } // How many Lba blocks are we requested to erase? NumOfLba = VA_ARG (Args, UINT32); // Go through each one and erase it while (NumOfLba > 0) { // Get the physical address of Lba to erase BlockAddress = GET_NOR_BLOCK_ADDRESS ( Instance->RegionBaseAddress, Instance->StartLba + StartingLba, Instance->Media.BlockSize ); // Erase it DEBUG ((DEBUG_BLKIO, "FvbEraseBlocks: Erasing Lba=%ld @ 0x%08x.\n", Instance->StartLba + StartingLba, BlockAddress)); Status = NorFlashUnlockAndEraseSingleBlock (Instance, BlockAddress); if (EFI_ERROR(Status)) { VA_END (Args); Status = EFI_DEVICE_ERROR; goto EXIT; } // Move to the next Lba StartingLba++; NumOfLba--; } } while (TRUE); VA_END (Args); EXIT: return Status; }
/** Prints a debug message to the debug output device if the specified error level is enabled. If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function GetDebugPrintErrorLevel (), then print the message specified by Format and the associated variable argument list to the debug output device. If Format is NULL, then ASSERT(). If the length of the message string specificed by Format is larger than the maximum allowable record length, then directly return and not print it. @param ErrorLevel The error level of the debug message. @param Format Format string for the debug message to print. @param ... Variable argument list whose contents are accessed based on the format string specified by Format. **/ VOID EFIAPI DebugPrint ( IN UINTN ErrorLevel, IN CONST CHAR8 *Format, ... ) { UINT64 Buffer[(EFI_STATUS_CODE_DATA_MAX_SIZE / sizeof (UINT64)) + 1]; EFI_DEBUG_INFO *DebugInfo; UINTN TotalSize; UINTN DestBufferSize; VA_LIST VaListMarker; BASE_LIST BaseListMarker; CHAR8 *FormatString; BOOLEAN Long; // // If Format is NULL, then ASSERT(). // ASSERT (Format != NULL); // // Check driver Debug Level value and global debug level // if ((ErrorLevel & GetDebugPrintErrorLevel ()) == 0) { return; } // // Compute the total size of the record. // Note that the passing-in format string and variable parameters will be constructed to // the following layout: // // Buffer->|------------------------| // | Padding | 4 bytes // DebugInfo->|------------------------| // | EFI_DEBUG_INFO | sizeof(EFI_DEBUG_INFO) // BaseListMarker->|------------------------| // | ... | // | variable arguments | 12 * sizeof (UINT64) // | ... | // |------------------------| // | Format String | // |------------------------|<- (UINT8 *)Buffer + sizeof(Buffer) // TotalSize = 4 + sizeof (EFI_DEBUG_INFO) + 12 * sizeof (UINT64) + AsciiStrSize (Format); // // If the TotalSize is larger than the maximum record size, then return // if (TotalSize > sizeof (Buffer)) { return; } // // Fill in EFI_DEBUG_INFO // // Here we skip the first 4 bytes of Buffer, because we must ensure BaseListMarker is // 64-bit aligned, otherwise retrieving 64-bit parameter from BaseListMarker will cause // exception on IPF. Buffer starts at 64-bit aligned address, so skipping 4 types (sizeof(EFI_DEBUG_INFO)) // just makes address of BaseListMarker, which follows DebugInfo, 64-bit aligned. // DebugInfo = (EFI_DEBUG_INFO *)(Buffer) + 1; DebugInfo->ErrorLevel = (UINT32)ErrorLevel; BaseListMarker = (BASE_LIST)(DebugInfo + 1); FormatString = (CHAR8 *)((UINT64 *)(DebugInfo + 1) + 12); // // Copy the Format string into the record // // According to the content structure of Buffer shown above, the size of // the FormatString buffer is the size of Buffer minus the Padding // (4 bytes), minus the size of EFI_DEBUG_INFO, minus the size of // variable arguments (12 * sizeof (UINT64)). // DestBufferSize = sizeof (Buffer) - 4 - sizeof (EFI_DEBUG_INFO) - 12 * sizeof (UINT64); AsciiStrCpyS (FormatString, DestBufferSize / sizeof (CHAR8), Format); // // The first 12 * sizeof (UINT64) bytes following EFI_DEBUG_INFO are for variable arguments // of format in DEBUG string, which is followed by the DEBUG format string. // Here we will process the variable arguments and pack them in this area. // VA_START (VaListMarker, Format); for (; *Format != '\0'; Format++) { // // Only format with prefix % is processed. // if (*Format != '%') { continue; } Long = FALSE; // // Parse Flags and Width // for (Format++; TRUE; Format++) { if (*Format == '.' || *Format == '-' || *Format == '+' || *Format == ' ') { // // These characters in format field are omitted. // continue; } if (*Format >= '0' && *Format <= '9') { // // These characters in format field are omitted. // continue; } if (*Format == 'L' || *Format == 'l') { // // 'L" or "l" in format field means the number being printed is a UINT64 // Long = TRUE; continue; } if (*Format == '*') { // // '*' in format field means the precision of the field is specified by // a UINTN argument in the argument list. // BASE_ARG (BaseListMarker, UINTN) = VA_ARG (VaListMarker, UINTN); continue; } if (*Format == '\0') { // // Make no output if Format string terminates unexpectedly when // looking up for flag, width, precision and type. // Format--; } // // When valid argument type detected or format string terminates unexpectedly, // the inner loop is done. // break; } // // Pack variable arguments into the storage area following EFI_DEBUG_INFO. // if ((*Format == 'p') && (sizeof (VOID *) > 4)) { Long = TRUE; } if (*Format == 'p' || *Format == 'X' || *Format == 'x' || *Format == 'd' || *Format == 'u') { if (Long) { BASE_ARG (BaseListMarker, INT64) = VA_ARG (VaListMarker, INT64); } else { BASE_ARG (BaseListMarker, int) = VA_ARG (VaListMarker, int); } } else if (*Format == 's' || *Format == 'S' || *Format == 'a' || *Format == 'g' || *Format == 't') { BASE_ARG (BaseListMarker, VOID *) = VA_ARG (VaListMarker, VOID *); } else if (*Format == 'c') {