TianoCore EDK2 master
Loading...
Searching...
No Matches
SpiHcSmm.c
Go to the documentation of this file.
1
9#include <Base.h>
10#include <Library/BaseLib.h>
11#include <Library/DebugLib.h>
12#include <Library/PcdLib.h>
13#include <Library/UefiLib.h>
18#include <Protocol/SpiSmmHc.h>
20#include "SpiHc.h"
21
22EFI_HANDLE mSpiHcHandle = 0;
23
36EFIAPI
38 IN EFI_HANDLE ImageHandle,
39 IN EFI_SYSTEM_TABLE *SystemTable
40 )
41{
42 EFI_STATUS Status;
43 EFI_SPI_HC_PROTOCOL *HcProtocol;
44
45 DEBUG ((DEBUG_VERBOSE, "%a - ENTRY\n", __func__));
46
47 // Allocate the SPI Host Controller protocol
48 HcProtocol = AllocateZeroPool (sizeof (EFI_SPI_HC_PROTOCOL));
49 ASSERT (HcProtocol != NULL);
50 if (HcProtocol == NULL) {
51 return EFI_OUT_OF_RESOURCES;
52 }
53
54 // Fill in the SPI Host Controller Protocol
56 &HcProtocol->Attributes,
57 &HcProtocol->FrameSizeSupportMask,
58 &HcProtocol->MaximumTransferBytes
59 );
60
61 HcProtocol->ChipSelect = ChipSelect;
62 HcProtocol->Clock = Clock;
63 HcProtocol->Transaction = Transaction;
64
65 Status = gMmst->MmInstallProtocolInterface (
66 &mSpiHcHandle,
67 &gEfiSpiSmmHcProtocolGuid,
69 HcProtocol
70 );
71
72 if (EFI_ERROR (Status)) {
73 DEBUG ((DEBUG_VERBOSE, "Error installing gEfiSpiSmmHcProtocolGuid\n"));
74 }
75
76 DEBUG ((DEBUG_VERBOSE, "%a - EXIT Status=%r\n", __func__, Status));
77
78 return Status;
79}
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
#define NULL
Definition: Base.h:319
#define IN
Definition: Base.h:279
#define DEBUG(Expression)
Definition: DebugLib.h:434
EFI_STATUS EFIAPI Transaction(IN CONST EFI_SPI_IO_PROTOCOL *This, IN EFI_SPI_TRANSACTION_TYPE TransactionType, IN BOOLEAN DebugTransaction, IN UINT32 ClockHz OPTIONAL, IN UINT32 BusWidth, IN UINT32 FrameSize, IN UINT32 WriteBytes, IN UINT8 *WriteBuffer, IN UINT32 ReadBytes, OUT UINT8 *ReadBuffer)
Definition: SpiBus.c:231
EFI_STATUS EFIAPI Clock(IN CONST EFI_SPI_HC_PROTOCOL *This, IN CONST EFI_SPI_PERIPHERAL *SpiPeripheral, IN UINT32 *ClockHz)
Definition: SpiHc.c:75
EFI_STATUS EFIAPI ChipSelect(IN CONST EFI_SPI_HC_PROTOCOL *This, IN CONST EFI_SPI_PERIPHERAL *SpiPeripheral, IN BOOLEAN PinValue)
Definition: SpiHc.c:38
EFI_STATUS EFIAPI GetPlatformSpiHcDetails(OUT UINT32 *Attributes, OUT UINT32 *FrameSizeSupportMask, OUT UINT32 *MaximumTransferBytes)
EFI_STATUS EFIAPI SpiHcProtocolEntry(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
Definition: SpiHcSmm.c:37
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
@ EFI_NATIVE_INTERFACE
Definition: UefiSpec.h:1193
EFI_INSTALL_PROTOCOL_INTERFACE MmInstallProtocolInterface
Definition: PiMmCis.h:327
EFI_SPI_HC_PROTOCOL_TRANSACTION Transaction
Definition: SpiHc.h:197
EFI_SPI_HC_PROTOCOL_CLOCK Clock
Definition: SpiHc.h:191
UINT32 Attributes
Definition: SpiHc.h:168
UINT32 MaximumTransferBytes
Definition: SpiHc.h:180
UINT32 FrameSizeSupportMask
Definition: SpiHc.h:175
EFI_SPI_HC_PROTOCOL_CHIP_SELECT ChipSelect
Definition: SpiHc.h:185