18 ShellMmMemoryMappedIo,
22} SHELL_MM_ACCESS_TYPE;
24CONST UINT16 mShellMmAccessTypeStr[] = {
43CONST UINT64 mShellMmMaxNumber[] = {
44 0, MAX_UINT8, MAX_UINT16, 0, MAX_UINT32, 0, 0, 0, MAX_UINT64
47 0, EfiPciWidthUint8, EfiPciWidthUint16, 0, EfiPciWidthUint32, 0, 0, 0, EfiPciWidthUint64
50 0, EfiCpuIoWidthUint8, EfiCpuIoWidthUint16, 0, EfiCpuIoWidthUint32, 0, 0, 0, EfiCpuIoWidthUint64
71 OUT UINT8 *Device OPTIONAL,
72 OUT UINT8 *Function OPTIONAL,
81 *Segment = (UINT32)(
RShiftU64 (Address, 32) & 0xFFFF);
82 *Bus = (UINT8)(((UINT32)Address) >> 24);
85 *Device = (UINT8)(((UINT32)Address) >> 16);
88 if (Function !=
NULL) {
89 *Function = (UINT8)(((UINT32)Address) >> 8);
100 *Segment = (UINT32)(
RShiftU64 (Address, 36) & 0xFFFF);
102 if (Device !=
NULL) {
103 *Device = (UINT8)(((UINT32)Address) >> 20);
106 if (Function !=
NULL) {
107 *Function = (UINT8)(((UINT32)Address) >> 12);
111 *
Register = (UINT32)(Address & 0xFFF);
129 IN SHELL_MM_ACCESS_TYPE AccessType,
147 if (AccessType == ShellMmMemory) {
154 RootBridgeIoMem =
NULL;
156 switch (AccessType) {
158 case ShellMmPciExpress:
159 ASSERT (PciRootBridgeIo !=
NULL);
162 Status = PciRootBridgeIo->Pci.Read (
164 mShellMmRootBridgeIoWidth[Size],
165 EFI_PCI_ADDRESS (Bus, Device, Function,
Register),
170 Status = PciRootBridgeIo->Pci.Write (
172 mShellMmRootBridgeIoWidth[Size],
173 EFI_PCI_ADDRESS (Bus, Device, Function,
Register),
182 case ShellMmMemoryMappedIo:
183 if (PciRootBridgeIo !=
NULL) {
184 RootBridgeIoMem = Read ? PciRootBridgeIo->Mem.Read : PciRootBridgeIo->Mem.Write;
188 CpuIoMem = Read ? CpuIo->Mem.Read : CpuIo->Mem.Write;
194 if (PciRootBridgeIo !=
NULL) {
195 RootBridgeIoMem = Read ? PciRootBridgeIo->Io.Read : PciRootBridgeIo->Io.Write;
199 CpuIoMem = Read ? CpuIo->Io.Read : CpuIo->Io.Write;
208 Status = EFI_UNSUPPORTED;
209 if (RootBridgeIoMem !=
NULL) {
210 Status = RootBridgeIoMem (PciRootBridgeIo, mShellMmRootBridgeIoWidth[Size], Address, 1, Buffer);
213 if (EFI_ERROR (Status) && (CpuIoMem !=
NULL)) {
214 Status = CpuIoMem (CpuIo, mShellMmCpuIoWidth[Size], Address, 1, Buffer);
217 if (EFI_ERROR (Status)) {
218 if (AccessType == ShellMmIo) {
314 IN SHELL_MM_ACCESS_TYPE AccessType,
329 Status =
gBS->LocateProtocol (&gEfiCpuIo2ProtocolGuid,
NULL, (VOID **)CpuIo);
330 if (EFI_ERROR (Status)) {
334 *PciRootBridgeIo =
NULL;
336 Status =
gBS->LocateHandleBuffer (
338 &gEfiPciRootBridgeIoProtocolGuid,
343 if (EFI_ERROR (Status) || (HandleCount == 0) || (HandleBuffer ==
NULL)) {
349 if ((AccessType == ShellMmPci) || (AccessType == ShellMmPciExpress)) {
356 for (Index = 0; (Index < HandleCount) && (*PciRootBridgeIo ==
NULL); Index++) {
357 Status =
gBS->HandleProtocol (
359 &gEfiPciRootBridgeIoProtocolGuid,
362 if (EFI_ERROR (Status)) {
366 if ((((AccessType == ShellMmPci) || (AccessType == ShellMmPciExpress)) && (Io->
SegmentNumber == Segment)) ||
367 ((AccessType == ShellMmIo) || (AccessType == ShellMmMemoryMappedIo))
370 Status = Io->Configuration (Io, (VOID **)&Descriptors);
371 if (!EFI_ERROR (Status)) {
372 while (Descriptors->Desc != ACPI_END_TAG_DESCRIPTOR) {
376 if ((Descriptors->ResType == ACPI_ADDRESS_SPACE_TYPE_BUS) &&
377 ((AccessType == ShellMmPci) || (AccessType == ShellMmPciExpress)) &&
378 ((Bus >= Descriptors->AddrRangeMin) && (Bus <= Descriptors->AddrRangeMax))
381 *PciRootBridgeIo = Io;
387 }
else if ((((Descriptors->ResType == ACPI_ADDRESS_SPACE_TYPE_IO) && (AccessType == ShellMmIo)) ||
388 ((Descriptors->ResType == ACPI_ADDRESS_SPACE_TYPE_MEM) && (AccessType == ShellMmMemoryMappedIo))
389 ) && ((Address >= Descriptors->AddrRangeMin) && (Address <= Descriptors->AddrRangeMax))
392 *PciRootBridgeIo = Io;
402 if (HandleBuffer !=
NULL) {
427 SHELL_MM_ACCESS_TYPE AccessType;
435 CHAR16 *ProblemParam;
438 BOOLEAN HasPciRootBridgeIo;
445 AccessType = ShellMmMemory;
451 if (EFI_ERROR (Status)) {
452 if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam !=
NULL)) {
475 AccessType = ShellMmMemoryMappedIo;
487 AccessType = ShellMmMemory;
498 AccessType = ShellMmIo;
508 AccessType = ShellMmPci;
517 AccessType = ShellMmPciExpress;
534 if ((Size != 1) && (Size != 2) && (Size != 4) && (Size != 8)) {
548 if (EFI_ERROR (Status)) {
554 if ((Address & (Size - 1)) != 0) {
564 if ((AccessType == ShellMmPci) || (AccessType == ShellMmPciExpress)) {
565 if (!HasPciRootBridgeIo) {
571 if (PciRootBridgeIo ==
NULL) {
584 if (EFI_ERROR (Status)) {
590 if (Value > mShellMmMaxNumber[Size]) {
604 if (!gEfiShellProtocol->BatchIsActive ()) {
608 ShellMmAccess (AccessType, PciRootBridgeIo, CpuIo,
TRUE, Address, Size, &Buffer);
610 if (!gEfiShellProtocol->BatchIsActive ()) {
624 ShellMmAccess (AccessType, PciRootBridgeIo, CpuIo,
TRUE, Address, Size, &Buffer);
632 if (InputStr !=
NULL) {
639 if (InputStr !=
NULL) {
643 for (Index = 0; InputStr[Index] ==
' '; Index++) {
646 if (InputStr[Index] != CHAR_NULL) {
647 if ((InputStr[Index] ==
'.') || (InputStr[Index] ==
'q') || (InputStr[Index] ==
'Q')) {
650 (Buffer <= mShellMmMaxNumber[Size])
669 if (InputStr !=
NULL) {
673 if (Package !=
NULL) {
PACKED struct @89 EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
UINT64 EFIAPI RShiftU64(IN UINT64 Operand, IN UINTN Count)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
EFI_STATUS(EFIAPI * EFI_CPU_IO_PROTOCOL_IO_MEM)(IN EFI_CPU_IO2_PROTOCOL *This, IN EFI_CPU_IO_PROTOCOL_WIDTH Width, IN UINT64 Address, IN UINTN Count, IN OUT VOID *Buffer)
EFI_CPU_IO_PROTOCOL_WIDTH
VOID EFIAPI FreePool(IN VOID *Buffer)
UINT8 EFIAPI IoWrite8(IN UINTN Port, IN UINT8 Value)
UINT64 EFIAPI MmioWrite64(IN UINTN Address, IN UINT64 Value)
UINT64 EFIAPI IoRead64(IN UINTN Port)
UINT64 EFIAPI IoWrite64(IN UINTN Port, IN UINT64 Value)
UINT64 EFIAPI MmioRead64(IN UINTN Address)
UINT16 EFIAPI MmioRead16(IN UINTN Address)
UINT8 EFIAPI MmioRead8(IN UINTN Address)
UINT8 EFIAPI MmioWrite8(IN UINTN Address, IN UINT8 Value)
UINT8 EFIAPI IoRead8(IN UINTN Port)
UINT32 EFIAPI MmioRead32(IN UINTN Address)
UINT16 EFIAPI IoRead16(IN UINTN Port)
UINT16 EFIAPI MmioWrite16(IN UINTN Address, IN UINT16 Value)
UINT32 EFIAPI IoRead32(IN UINTN Port)
UINT32 EFIAPI IoWrite32(IN UINTN Port, IN UINT32 Value)
UINT16 EFIAPI IoWrite16(IN UINTN Port, IN UINT16 Value)
UINT32 EFIAPI MmioWrite32(IN UINTN Address, IN UINT32 Value)
#define ASSERT_EFI_ERROR(StatusParameter)
@ SHELL_INVALID_PARAMETER
BOOLEAN ShellMmLocateIoProtocol(IN SHELL_MM_ACCESS_TYPE AccessType, IN UINT64 Address, OUT EFI_CPU_IO2_PROTOCOL **CpuIo, OUT EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL **PciRootBridgeIo)
VOID ShellMmAccess(IN SHELL_MM_ACCESS_TYPE AccessType, IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo, IN EFI_CPU_IO2_PROTOCOL *CpuIo, IN BOOLEAN Read, IN UINT64 Address, IN UINTN Size, IN OUT VOID *Buffer)
VOID ShellMmDecodePciAddress(IN BOOLEAN PciFormat, IN UINT64 Address, OUT UINT32 *Segment, OUT UINT8 *Bus, OUT UINT8 *Device OPTIONAL, OUT UINT8 *Function OPTIONAL, OUT UINT32 *Register OPTIONAL)
SHELL_STATUS EFIAPI ShellCommandRunMm(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
EFI_STATUS(EFIAPI * EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_IO_MEM)(IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This, IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width, IN UINT64 Address, IN UINTN Count, IN OUT VOID *Buffer)
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH
EFI_STATUS EFIAPI Register(IN EFI_PEI_RSC_HANDLER_CALLBACK Callback)
CONST CHAR16 *EFIAPI ShellCommandLineGetValue(IN CONST LIST_ENTRY *CheckPackage, IN CHAR16 *KeyString)
UINTN EFIAPI ShellStrToUintn(IN CONST CHAR16 *String)
#define ShellCommandLineParse(CheckList, CheckPackage, ProblemParam, AutoPageBreak)
Make it easy to upgrade from older versions of the shell library.
EFI_STATUS EFIAPI ShellPrintHiiEx(IN INT32 Col OPTIONAL, IN INT32 Row OPTIONAL, IN CONST CHAR8 *Language OPTIONAL, IN CONST EFI_STRING_ID HiiFormatStringId, IN CONST EFI_HII_HANDLE HiiFormatHandle,...)
BOOLEAN EFIAPI ShellCommandLineGetFlag(IN CONST LIST_ENTRY *CONST CheckPackage, IN CONST CHAR16 *CONST KeyString)
@ TypeValue
A flag that has some data following it with a space (IE "-a 1").
@ TypeFlag
A flag that is present or not present only (IE "-a").
EFI_STATUS EFIAPI ShellPromptForResponse(IN SHELL_PROMPT_REQUEST_TYPE Type, IN CHAR16 *Prompt OPTIONAL, IN OUT VOID **Response OPTIONAL)
VOID EFIAPI ShellCommandLineFreeVarList(IN LIST_ENTRY *CheckPackage)
EFI_STATUS EFIAPI ShellPrintEx(IN INT32 Col OPTIONAL, IN INT32 Row OPTIONAL, IN CONST CHAR16 *Format,...)
CONST CHAR16 *EFIAPI ShellCommandLineGetRawValue(IN CONST LIST_ENTRY *CONST CheckPackage, IN UINTN Position)
UINTN EFIAPI ShellCommandLineGetCount(IN CONST LIST_ENTRY *CheckPackage)
EFI_STATUS EFIAPI ShellConvertStringToUint64(IN CONST CHAR16 *String, OUT UINT64 *Value, IN CONST BOOLEAN ForceHex, IN CONST BOOLEAN StopAtSpace)