[PATCH 3/4] MdeModulePkg/SdMmcPciHcDxe: Refactor data transfer completion
Albecki, Mateusz
This patch refactors the way in which the driver will check
the data transfer completion. Data transfer related functionalities have been moved to separate function. Cc: Hao A Wu <hao.a.wu@...> Cc: Marcin Wojtas <mw@...> Cc: Zhichao Gao <zhichao.gao@...> Cc: Liming Gao <liming.gao@...> Signed-off-by: Mateusz Albecki <mateusz.albecki@...> --- MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c | 181 ++++++++++++++--------- 1 file changed, 112 insertions(+), 69 deletions(-) diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c index 3dfaae8542..480a1664ea 100644 --- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c +++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c @@ -2447,6 +2447,112 @@ SdMmcCheckCommandComplete ( return EFI_NOT_READY; } +/** + Update the SDMA address on the SDMA buffer boundary interrupt. + + @param[in] Private A pointer to the SD_MMC_HC_PRIVATE_DATA instance. + @param[in] Trb The pointer to the SD_MMC_HC_TRB instance. + + @retval EFI_SUCCESS Updated SDMA buffer address. + @retval Others Failed to update SDMA buffer address. +**/ +EFI_STATUS +SdMmcUpdateSdmaAddress ( + IN SD_MMC_HC_PRIVATE_DATA *Private, + IN SD_MMC_HC_TRB *Trb + ) +{ + UINT64 SdmaAddr; + EFI_STATUS Status; + + SdmaAddr = SD_MMC_SDMA_ROUND_UP ((UINTN)Trb->DataPhy, SD_MMC_SDMA_BOUNDARY); + + if (Private->ControllerVersion[Trb->Slot] >= SD_MMC_HC_CTRL_VER_400) { + Status = SdMmcHcRwMmio ( + Private->PciIo, + Trb->Slot, + SD_MMC_HC_ADMA_SYS_ADDR, + FALSE, + sizeof (UINT64), + &SdmaAddr + ); + } else { + Status = SdMmcHcRwMmio ( + Private->PciIo, + Trb->Slot, + SD_MMC_HC_SDMA_ADDR, + FALSE, + sizeof (UINT32), + &SdmaAddr + ); + } + + if (EFI_ERROR (Status)) { + return Status; + } + + Trb->DataPhy = (UINT64)(UINTN)SdmaAddr; + return EFI_SUCCESS; +} + +/** + Checks if the data transfer completed and performs any actions + neccessary to continue the data transfer such as SDMA system + address fixup or PIO data transfer. + + @param[in] Private A pointer to the SD_MMC_HC_PRIVATE_DATA instance. + @param[in] Trb The pointer to the SD_MMC_HC_TRB instance. + @param[in] IntStatus Snapshot of the normal interrupt status register. + + @retval EFI_SUCCESS Data transfer completed successfully. + @retval EFI_NOT_READY Data transfer completion still pending. + @retval Others Data transfer failed to complete. +**/ +EFI_STATUS +SdMmcCheckDataTransfer ( + IN SD_MMC_HC_PRIVATE_DATA *Private, + IN SD_MMC_HC_TRB *Trb, + IN UINT16 IntStatus + ) +{ + UINT16 Data16; + EFI_STATUS Status; + + if ((IntStatus & BIT1) != 0) { + Data16 = BIT1; + Status = SdMmcHcRwMmio ( + Private->PciIo, + Trb->Slot, + SD_MMC_HC_NOR_INT_STS, + FALSE, + sizeof (Data16), + &Data16 + ); + return Status; + } + + if ((Trb->Mode == SdMmcSdmaMode) && ((IntStatus & BIT3) != 0)) { + Data16 = BIT3; + Status = SdMmcHcRwMmio ( + Private->PciIo, + Trb->Slot, + SD_MMC_HC_NOR_INT_STS, + FALSE, + sizeof (Data16), + &Data16 + ); + if (EFI_ERROR (Status)) { + return Status; + } + Status = SdMmcUpdateSdmaAddress (Private, Trb); + if (EFI_ERROR (Status)) { + return Status; + } + } + + return EFI_NOT_READY; +} + /** Check the TRB execution result. @@ -2467,7 +2573,6 @@ SdMmcCheckTrbResult ( EFI_STATUS Status; EFI_SD_MMC_PASS_THRU_COMMAND_PACKET *Packet; UINT16 IntStatus; - UINT64 SdmaAddr; UINT32 PioLength; Packet = Trb->Packet; @@ -2530,80 +2635,18 @@ SdMmcCheckTrbResult ( Status = SdMmcCheckCommandComplete (Private, Trb, IntStatus); if (EFI_ERROR (Status)) { goto Done; - } else { - // - // If the command doesn't require data transfer skip the transfer - // complete checking. - // - if ((Packet->SdMmcCmdBlk->CommandType != SdMmcCommandTypeAdtc) && - (Packet->SdMmcCmdBlk->ResponseType != SdMmcResponseTypeR1b) && - (Packet->SdMmcCmdBlk->ResponseType != SdMmcResponseTypeR5b)) { - goto Done; - } } } - // - // Check Transfer Complete bit is set or not. - // - if ((IntStatus & BIT1) == BIT1) { - goto Done; - } - - // - // Check if DMA interrupt is signalled for the SDMA transfer. - // - if ((Trb->Mode == SdMmcSdmaMode) && ((IntStatus & BIT3) == BIT3)) { - // - // Clear DMA interrupt bit. - // - IntStatus = BIT3; - Status = SdMmcHcRwMmio ( - Private->PciIo, - Trb->Slot, - SD_MMC_HC_NOR_INT_STS, - FALSE, - sizeof (IntStatus), - &IntStatus - ); - if (EFI_ERROR (Status)) { - goto Done; - } - // - // Update SDMA Address register. - // - SdmaAddr = SD_MMC_SDMA_ROUND_UP ((UINTN)Trb->DataPhy, SD_MMC_SDMA_BOUNDARY); - - if (Private->ControllerVersion[Trb->Slot] >= SD_MMC_HC_CTRL_VER_400) { - Status = SdMmcHcRwMmio ( - Private->PciIo, - Trb->Slot, - SD_MMC_HC_ADMA_SYS_ADDR, - FALSE, - sizeof (UINT64), - &SdmaAddr - ); - } else { - Status = SdMmcHcRwMmio ( - Private->PciIo, - Trb->Slot, - SD_MMC_HC_SDMA_ADDR, - FALSE, - sizeof (UINT32), - &SdmaAddr - ); - } - - if (EFI_ERROR (Status)) { - goto Done; - } - Trb->DataPhy = (UINT64)(UINTN)SdmaAddr; + if (Packet->SdMmcCmdBlk->CommandType == SdMmcCommandTypeAdtc || + Packet->SdMmcCmdBlk->ResponseType == SdMmcResponseTypeR1b || + Packet->SdMmcCmdBlk->ResponseType == SdMmcResponseTypeR5b) { + Status = SdMmcCheckDataTransfer (Private, Trb, IntStatus); + } else { + Status = EFI_SUCCESS; } - - Status = EFI_NOT_READY; Done: - if (Status != EFI_NOT_READY) { SdMmcHcLedOnOff (Private->PciIo, Trb->Slot, FALSE); if (EFI_ERROR (Status)) { -- 2.14.1.windows.1 -------------------------------------------------------------------- Intel Technology Poland sp. z o.o. ul. Slowackiego 173 | 80-298 Gdansk | Sad Rejonowy Gdansk Polnoc | VII Wydzial Gospodarczy Krajowego Rejestru Sadowego - KRS 101882 | NIP 957-07-52-316 | Kapital zakladowy 200.000 PLN. Ta wiadomosc wraz z zalacznikami jest przeznaczona dla okreslonego adresata i moze zawierac informacje poufne. W razie przypadkowego otrzymania tej wiadomosci, prosimy o powiadomienie nadawcy oraz trwale jej usuniecie; jakiekolwiek przegladanie lub rozpowszechnianie jest zabronione. This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). If you are not the intended recipient, please contact the sender and delete all copies; any review or distribution by others is strictly prohibited.
|
|
[PATCH 2/4] MdeModulePkg/SdMmcPciHcDxe: Read response on command completion
Albecki, Mateusz
SdMmcPciHcDxe driver used to read response only after
command and data transfer completed. According to SDHCI specification response data is ready after the command complete status is set by the host controller. Getting the response data early will help debugging the cases when command completed but data transfer timed out. Cc: Hao A Wu <hao.a.wu@...> Cc: Marcin Wojtas <mw@...> Cc: Zhichao Gao <zhichao.gao@...> Cc: Liming Gao <liming.gao@...> Signed-off-by: Mateusz Albecki <mateusz.albecki@...> --- MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.h | 1 + MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c | 201 +++++++++++++++------ 2 files changed, 144 insertions(+), 58 deletions(-) diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.h b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.h index 5bc3577ba2..15b7d12596 100644 --- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.h +++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.h @@ -153,6 +153,7 @@ typedef struct { EFI_EVENT Event; BOOLEAN Started; + BOOLEAN CommandComplete; UINT64 Timeout; UINT32 Retries; diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c index 959645bf26..3dfaae8542 100644 --- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c +++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c @@ -1708,6 +1708,7 @@ SdMmcPrintTrb ( DEBUG ((DebugLevel, "AdmaLengthMode: %d\n", Trb->AdmaLengthMode)); DEBUG ((DebugLevel, "Event: %d\n", Trb->Event)); DEBUG ((DebugLevel, "Started: %d\n", Trb->Started)); + DEBUG ((DebugLevel, "CommandComplete: %d\n", Trb->CommandComplete)); DEBUG ((DebugLevel, "Timeout: %d\n", Trb->Timeout)); DEBUG ((DebugLevel, "Retries: %d\n", Trb->Retries)); DEBUG ((DebugLevel, "Adma32Desc: %X\n", Trb->Adma32Desc)); @@ -1758,6 +1759,7 @@ SdMmcCreateTrb ( Trb->Packet = Packet; Trb->Event = Event; Trb->Started = FALSE; + Trb->CommandComplete = FALSE; Trb->Timeout = Packet->Timeout; Trb->Retries = SD_MMC_TRB_RETRIES; Trb->Private = Private; @@ -2352,6 +2354,99 @@ SdMmcCheckAndRecoverErrors ( return ErrorStatus; } +/** + Reads the response data into the TRB buffer. + This function assumes that caller made sure that + command has completed. + + @param[in] Private A pointer to the SD_MMC_HC_PRIVATE_DATA instance. + @param[in] Trb The pointer to the SD_MMC_HC_TRB instance. + + @retval EFI_SUCCESS Response read successfully. + @retval Others Failed to get response. +**/ +EFI_STATUS +SdMmcGetResponse ( + IN SD_MMC_HC_PRIVATE_DATA *Private, + IN SD_MMC_HC_TRB *Trb + ) +{ + EFI_SD_MMC_PASS_THRU_COMMAND_PACKET *Packet; + UINT8 Index; + UINT32 Response[4]; + EFI_STATUS Status; + + Packet = Trb->Packet; + + if (Packet->SdMmcCmdBlk->CommandType == SdMmcCommandTypeBc) { + return EFI_SUCCESS; + } + + for (Index = 0; Index < 4; Index++) { + Status = SdMmcHcRwMmio ( + Private->PciIo, + Trb->Slot, + SD_MMC_HC_RESPONSE + Index * 4, + TRUE, + sizeof (UINT32), + &Response[Index] + ); + if (EFI_ERROR (Status)) { + return Status; + } + } + CopyMem (Packet->SdMmcStatusBlk, Response, sizeof (Response)); + + return EFI_SUCCESS; +} + +/** + Checks if the command completed. If the command + completed it gets the response and records the + command completion in the TRB. + + @param[in] Private A pointer to the SD_MMC_HC_PRIVATE_DATA instance. + @param[in] Trb The pointer to the SD_MMC_HC_TRB instance. + @param[in] IntStatus Snapshot of the normal interrupt status register. + + @retval EFI_SUCCESS Command completed successfully. + @retval EFI_NOT_READY Command completion still pending. + @retval Others Command failed to complete. +**/ +EFI_STATUS +SdMmcCheckCommandComplete ( + IN SD_MMC_HC_PRIVATE_DATA *Private, + IN SD_MMC_HC_TRB *Trb, + IN UINT16 IntStatus + ) +{ + UINT16 Data16; + EFI_STATUS Status; + + if ((IntStatus & BIT0) != 0) { + Data16 = BIT0; + Status = SdMmcHcRwMmio ( + Private->PciIo, + Trb->Slot, + SD_MMC_HC_NOR_INT_STS, + FALSE, + sizeof (Data16), + &Data16 + ); + if (EFI_ERROR (Status)) { + return Status; + } + Status = SdMmcGetResponse (Private, Trb); + if (EFI_ERROR (Status)) { + return Status; + } + Trb->CommandComplete = TRUE; + return EFI_SUCCESS; + } + + return EFI_NOT_READY; +} + /** Check the TRB execution result. @@ -2372,9 +2467,7 @@ SdMmcCheckTrbResult ( EFI_STATUS Status; EFI_SD_MMC_PASS_THRU_COMMAND_PACKET *Packet; UINT16 IntStatus; - UINT32 Response[4]; UINT64 SdmaAddr; - UINT8 Index; UINT32 PioLength; Packet = Trb->Packet; @@ -2402,6 +2495,54 @@ SdMmcCheckTrbResult ( goto Done; } + // + // Tuning commands are the only ones that do not generate command + // complete interrupt. Process them here before entering the code + // that waits for command completion. + // + if (((Private->Slot[Trb->Slot].CardType == EmmcCardType) && + (Packet->SdMmcCmdBlk->CommandIndex == EMMC_SEND_TUNING_BLOCK)) || + ((Private->Slot[Trb->Slot].CardType == SdCardType) && + (Packet->SdMmcCmdBlk->CommandIndex == SD_SEND_TUNING_BLOCK))) { + // + // When performing tuning procedure (Execute Tuning is set to 1) through PIO mode, + // wait Buffer Read Ready bit of Normal Interrupt Status Register to be 1. + // Refer to SD Host Controller Simplified Specification 3.0 figure 2-29 for details. + // + if ((IntStatus & BIT5) == BIT5) { + // + // Clear Buffer Read Ready interrupt at first. + // + IntStatus = BIT5; + SdMmcHcRwMmio (Private->PciIo, Trb->Slot, SD_MMC_HC_NOR_INT_STS, FALSE, sizeof (IntStatus), &IntStatus); + // + // Read data out from Buffer Port register + // + for (PioLength = 0; PioLength < Trb->DataLen; PioLength += 4) { + SdMmcHcRwMmio (Private->PciIo, Trb->Slot, SD_MMC_HC_BUF_DAT_PORT, TRUE, 4, (UINT8*)Trb->Data + PioLength); + } + Status = EFI_SUCCESS; + goto Done; + } + } + + if (!Trb->CommandComplete) { + Status = SdMmcCheckCommandComplete (Private, Trb, IntStatus); + if (EFI_ERROR (Status)) { + goto Done; + } else { + // + // If the command doesn't require data transfer skip the transfer + // complete checking. + // + if ((Packet->SdMmcCmdBlk->CommandType != SdMmcCommandTypeAdtc) && + (Packet->SdMmcCmdBlk->ResponseType != SdMmcResponseTypeR1b) && + (Packet->SdMmcCmdBlk->ResponseType != SdMmcResponseTypeR5b)) { + goto Done; + } + } + } + // // Check Transfer Complete bit is set or not. // @@ -2459,65 +2600,9 @@ SdMmcCheckTrbResult ( Trb->DataPhy = (UINT64)(UINTN)SdmaAddr; } - if ((Packet->SdMmcCmdBlk->CommandType != SdMmcCommandTypeAdtc) && - (Packet->SdMmcCmdBlk->ResponseType != SdMmcResponseTypeR1b) && - (Packet->SdMmcCmdBlk->ResponseType != SdMmcResponseTypeR5b)) { - if ((IntStatus & BIT0) == BIT0) { - Status = EFI_SUCCESS; - goto Done; - } - } - - if (((Private->Slot[Trb->Slot].CardType == EmmcCardType) && - (Packet->SdMmcCmdBlk->CommandIndex == EMMC_SEND_TUNING_BLOCK)) || - ((Private->Slot[Trb->Slot].CardType == SdCardType) && - (Packet->SdMmcCmdBlk->CommandIndex == SD_SEND_TUNING_BLOCK))) { - // - // When performing tuning procedure (Execute Tuning is set to 1) through PIO mode, - // wait Buffer Read Ready bit of Normal Interrupt Status Register to be 1. - // Refer to SD Host Controller Simplified Specification 3.0 figure 2-29 for details. - // - if ((IntStatus & BIT5) == BIT5) { - // - // Clear Buffer Read Ready interrupt at first. - // - IntStatus = BIT5; - SdMmcHcRwMmio (Private->PciIo, Trb->Slot, SD_MMC_HC_NOR_INT_STS, FALSE, sizeof (IntStatus), &IntStatus); - // - // Read data out from Buffer Port register - // - for (PioLength = 0; PioLength < Trb->DataLen; PioLength += 4) { - SdMmcHcRwMmio (Private->PciIo, Trb->Slot, SD_MMC_HC_BUF_DAT_PORT, TRUE, 4, (UINT8*)Trb->Data + PioLength); - } - Status = EFI_SUCCESS; - goto Done; - } - } Status = EFI_NOT_READY; Done: - // - // Get response data when the cmd is executed successfully. - // - if (!EFI_ERROR (Status)) { - if (Packet->SdMmcCmdBlk->CommandType != SdMmcCommandTypeBc) { - for (Index = 0; Index < 4; Index++) { - Status = SdMmcHcRwMmio ( - Private->PciIo, - Trb->Slot, - SD_MMC_HC_RESPONSE + Index * 4, - TRUE, - sizeof (UINT32), - &Response[Index] - ); - if (EFI_ERROR (Status)) { - SdMmcHcLedOnOff (Private->PciIo, Trb->Slot, FALSE); - return Status; - } - } - CopyMem (Packet->SdMmcStatusBlk, Response, sizeof (Response)); - } - } if (Status != EFI_NOT_READY) { SdMmcHcLedOnOff (Private->PciIo, Trb->Slot, FALSE); -- 2.14.1.windows.1 -------------------------------------------------------------------- Intel Technology Poland sp. z o.o. ul. Slowackiego 173 | 80-298 Gdansk | Sad Rejonowy Gdansk Polnoc | VII Wydzial Gospodarczy Krajowego Rejestru Sadowego - KRS 101882 | NIP 957-07-52-316 | Kapital zakladowy 200.000 PLN. Ta wiadomosc wraz z zalacznikami jest przeznaczona dla okreslonego adresata i moze zawierac informacje poufne. W razie przypadkowego otrzymania tej wiadomosci, prosimy o powiadomienie nadawcy oraz trwale jej usuniecie; jakiekolwiek przegladanie lub rozpowszechnianie jest zabronione. This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). If you are not the intended recipient, please contact the sender and delete all copies; any review or distribution by others is strictly prohibited.
|
|
[PATCH 1/4] MdeModulePkg/SdMmcPciHcDxe: Enhance driver traces
Albecki, Mateusz
To allow for easier debug of failing commands we
have added a capability to print TRB and command packet when we start execution of the TRB(on DEBUG_VERBOSE level) and when the TRB failed to execute correctly(on DEBUG_ERROR level). Additionally we will also print error interrupt status and interrupt status register on failed SD command. Cc: Hao A Wu <hao.a.wu@...> Cc: Marcin Wojtas <mw@...> Cc: Zhichao Gao <zhichao.gao@...> Cc: Liming Gao <liming.gao@...> Signed-off-by: Mateusz Albecki <mateusz.albecki@...> --- MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c | 87 ++++++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c index b05c818462..959645bf26 100644 --- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c +++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c @@ -1643,6 +1643,82 @@ BuildAdmaDescTable ( return EFI_SUCCESS; } +/** + Prints the contents of the command packet to the debug port. + + @param[in] DebugLevel Debug level at which the packet should be printed. + @param[in] Packet Pointer to packet to print. +**/ +VOID +SdMmcPrintPacket ( + IN UINT32 DebugLevel, + IN EFI_SD_MMC_PASS_THRU_COMMAND_PACKET *Packet + ) +{ + if (Packet == NULL) { + return; + } + + DEBUG ((DebugLevel, "Printing EFI_SD_MMC_PASS_THRU_COMMAND_PACKET\n")); + if (Packet->SdMmcCmdBlk != NULL) { + DEBUG ((DebugLevel, "Command index: %d, argument: %X\n", Packet->SdMmcCmdBlk->CommandIndex, Packet->SdMmcCmdBlk->CommandArgument)); + DEBUG ((DebugLevel, "Command type: %d, response type: %d\n", Packet->SdMmcCmdBlk->CommandType, Packet->SdMmcCmdBlk->ResponseType)); + } + if (Packet->SdMmcStatusBlk != NULL) { + DEBUG ((DebugLevel, "Response 0: %X, 1: %X, 2: %X, 3: %X\n", + Packet->SdMmcStatusBlk->Resp0, + Packet->SdMmcStatusBlk->Resp1, + Packet->SdMmcStatusBlk->Resp2, + Packet->SdMmcStatusBlk->Resp3 + )); + } + DEBUG ((DebugLevel, "Timeout: %d\n", Packet->Timeout)); + DEBUG ((DebugLevel, "InDataBuffer: %X\n", Packet->InDataBuffer)); + DEBUG ((DebugLevel, "OutDataBuffer: %X\n", Packet->OutDataBuffer)); + DEBUG ((DebugLevel, "InTransferLength: %d\n", Packet->InTransferLength)); + DEBUG ((DebugLevel, "OutTransferLength: %d\n", Packet->OutTransferLength)); + DEBUG ((DebugLevel, "TransactionStatus: %r\n", Packet->TransactionStatus)); +} + +/** + Prints the contents of the TRB to the debug port. + + @param[in] DebugLevel Debug level at which the TRB should be printed. + @param[in] Trb Pointer to the TRB structure. +**/ +VOID +SdMmcPrintTrb ( + IN UINT32 DebugLevel, + IN SD_MMC_HC_TRB *Trb + ) +{ + if (Trb == NULL) { + return; + } + + DEBUG ((DebugLevel, "Printing SD_MMC_HC_TRB\n")); + DEBUG ((DebugLevel, "Slot: %d\n", Trb->Slot)); + DEBUG ((DebugLevel, "BlockSize: %d\n", Trb->BlockSize)); + DEBUG ((DebugLevel, "Data: %X\n", Trb->Data)); + DEBUG ((DebugLevel, "DataLen: %d\n", Trb->DataLen)); + DEBUG ((DebugLevel, "Read: %d\n", Trb->Read)); + DEBUG ((DebugLevel, "DataPhy: %X\n", Trb->DataPhy)); + DEBUG ((DebugLevel, "DataMap: %X\n", Trb->DataMap)); + DEBUG ((DebugLevel, "Mode: %d\n", Trb->Mode)); + DEBUG ((DebugLevel, "AdmaLengthMode: %d\n", Trb->AdmaLengthMode)); + DEBUG ((DebugLevel, "Event: %d\n", Trb->Event)); + DEBUG ((DebugLevel, "Started: %d\n", Trb->Started)); + DEBUG ((DebugLevel, "Timeout: %d\n", Trb->Timeout)); + DEBUG ((DebugLevel, "Retries: %d\n", Trb->Retries)); + DEBUG ((DebugLevel, "Adma32Desc: %X\n", Trb->Adma32Desc)); + DEBUG ((DebugLevel, "Adma64V3Desc: %X\n", Trb->Adma64V3Desc)); + DEBUG ((DebugLevel, "Adma64V4Desc: %X\n", Trb->Adma64V4Desc)); + DEBUG ((DebugLevel, "AdmaMap: %X\n", Trb->AdmaMap)); + DEBUG ((DebugLevel, "AdmaPages: %X\n", Trb->AdmaPages)); + + SdMmcPrintPacket (DebugLevel, Trb->Packet); +} + /** Create a new TRB for the SD/MMC cmd request. @@ -1963,6 +2039,9 @@ SdMmcExecTrb ( UINT64 AdmaAddr; BOOLEAN AddressingMode64; + DEBUG ((DEBUG_VERBOSE, "Starting TRB execution\n")); + SdMmcPrintTrb (DEBUG_VERBOSE, Trb); + AddressingMode64 = FALSE; Packet = Trb->Packet; @@ -2235,6 +2314,10 @@ SdMmcCheckAndRecoverErrors ( return Status; } + DEBUG ((DEBUG_ERROR, "Error reported by SDHCI\n")); + DEBUG ((DEBUG_ERROR, "Interrupt status = %X\n", IntStatus)); + DEBUG ((DEBUG_ERROR, "Error interrupt status = %X\n", ErrIntStatus)); + // // If the data timeout error is reported // but data transfer is signaled as completed we @@ -2438,6 +2521,10 @@ Done: if (Status != EFI_NOT_READY) { SdMmcHcLedOnOff (Private->PciIo, Trb->Slot, FALSE); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "TRB failed with %r\n", Status)); + SdMmcPrintTrb (DEBUG_ERROR, Trb); + } } return Status; -- 2.14.1.windows.1 -------------------------------------------------------------------- Intel Technology Poland sp. z o.o. ul. Slowackiego 173 | 80-298 Gdansk | Sad Rejonowy Gdansk Polnoc | VII Wydzial Gospodarczy Krajowego Rejestru Sadowego - KRS 101882 | NIP 957-07-52-316 | Kapital zakladowy 200.000 PLN. Ta wiadomosc wraz z zalacznikami jest przeznaczona dla okreslonego adresata i moze zawierac informacje poufne. W razie przypadkowego otrzymania tej wiadomosci, prosimy o powiadomienie nadawcy oraz trwale jej usuniecie; jakiekolwiek przegladanie lub rozpowszechnianie jest zabronione. This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). If you are not the intended recipient, please contact the sender and delete all copies; any review or distribution by others is strictly prohibited.
|
|
[PATCH 0/4] MdeModulePkg/SdMmcPciHcDxe: Refactor command processing
Albecki, Mateusz
This patch series aims to refactor command processing to achieve following
1. Trace the failing TRB packets to see what commands are failing and for what reasons 2. Get the response data even if data transfer timed out to allow easier debugging 3. Fix the PIO mode which is currently completely broken. Tests performed: 1. Each patch in the series has passed boot from eMMC with ADMAv3 data transfer mode 2. SDMA based boot has been tested with the full patch series 3. PIO based boot has been tested with the full patch series 4. PIO based data transfer has been additionally tested by creating and modyfing a file in EFI shell All tests were performed with eMMC in HS400 @200MHz clock frequency. For easier review & integration patch has been pushed here: Whole series: https://github.com/malbecki/edk2/tree/emmc_transfer_refactor Whole series + SDMA force code(test 3): https://github.com/malbecki/edk2/tree/emmc_transfer_refactor_force_sdma Whole series + PIO force code(test 4): https://github.com/malbecki/edk2/tree/emmc_transfer_refactor_force_pio Cc: Hao A Wu <hao.a.wu@...> Cc: Marcin Wojtas <mw@...> Cc: Zhichao Gao <zhichao.gao@...> Cc: Liming Gao <liming.gao@...> Mateusz Albecki (4): MdeModulePkg/SdMmcPciHcDxe: Enhance driver traces MdeModulePkg/SdMmcPciHcDxe: Read response on command completion MdeModulePkg/SdMmcPciHcDxe: Refactor data transfer completion MdeModulePkg/SdMmcPciHcDxe: Fix PIO transfer mode MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.h | 4 + MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c | 502 ++++++++++++++++----- 2 files changed, 398 insertions(+), 108 deletions(-) -- 2.14.1.windows.1 -------------------------------------------------------------------- Intel Technology Poland sp. z o.o. ul. Slowackiego 173 | 80-298 Gdansk | Sad Rejonowy Gdansk Polnoc | VII Wydzial Gospodarczy Krajowego Rejestru Sadowego - KRS 101882 | NIP 957-07-52-316 | Kapital zakladowy 200.000 PLN. Ta wiadomosc wraz z zalacznikami jest przeznaczona dla okreslonego adresata i moze zawierac informacje poufne. W razie przypadkowego otrzymania tej wiadomosci, prosimy o powiadomienie nadawcy oraz trwale jej usuniecie; jakiekolwiek przegladanie lub rozpowszechnianie jest zabronione. This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). If you are not the intended recipient, please contact the sender and delete all copies; any review or distribution by others is strictly prohibited.
|
|
[PATCH] BaseTools: Enhance call stack unwindability for CLANGPDB x64 binary
Steven Shi
From: Steven <steven.shi@...>
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2487 The call stack unwindability of the COFF X64 binary requires the binary to remain the pdata and xdata sections. Details see the MSVC X64 calling convertion doc in below link: https://docs.microsoft.com/en-us/cpp/build/x64-calling-convention Current build options discard or zero the data in pdata and xdata sections which cause the debugger cannot correctly unwind the X64 binary call stack in the runtime. Enhance the build options to force emit the unwind tables and keep the data of pdata and xdata sections correct in the binary. Signed-off-by: Steven Shi <steven.shi@...> Cc: Liming Gao <liming.gao@...> Cc: Bob Feng <bob.c.feng@...> --- BaseTools/Conf/tools_def.template | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.template index feee2bbf16..26294efe05 100755 --- a/BaseTools/Conf/tools_def.template +++ b/BaseTools/Conf/tools_def.template @@ -2759,7 +2759,7 @@ DEFINE CLANGPDB_IA32_TARGET = -target i686-unknown-windows DEFINE CLANGPDB_X64_TARGET = -target x86_64-unknown-windows DEFINE CLANGPDB_WARNING_OVERRIDES = -Wno-parentheses-equality -Wno-tautological-compare -Wno-tautological-constant-out-of-range-compare -Wno-empty-body -Wno-unused-const-variable -Wno-varargs -Wno-unknown-warning-option -Wno-microsoft-enum-forward-reference -DEFINE CLANGPDB_ALL_CC_FLAGS = DEF(GCC48_ALL_CC_FLAGS) DEF(CLANGPDB_WARNING_OVERRIDES) -fno-stack-protector -mms-bitfields -Wno-address -Wno-shift-negative-value -Wno-unknown-pragmas -Wno-incompatible-library-redeclaration -fno-asynchronous-unwind-tables -mno-implicit-float -ftrap-function=undefined_behavior_has_been_optimized_away_by_clang -funsigned-char -fno-ms-extensions -Wno-null-dereference -fms-compatibility -mno-stack-arg-probe +DEFINE CLANGPDB_ALL_CC_FLAGS = DEF(GCC48_ALL_CC_FLAGS) DEF(CLANGPDB_WARNING_OVERRIDES) -fno-stack-protector -mms-bitfields -Wno-address -Wno-shift-negative-value -Wno-unknown-pragmas -Wno-incompatible-library-redeclaration -mno-implicit-float -ftrap-function=undefined_behavior_has_been_optimized_away_by_clang -funsigned-char -fno-ms-extensions -Wno-null-dereference -fms-compatibility -mno-stack-arg-probe ########################### # CLANGPDB IA32 definitions @@ -2817,18 +2817,20 @@ NOOPT_CLANGPDB_IA32_DLINK2_FLAGS = *_CLANGPDB_X64_ASLPP_FLAGS = DEF(GCC_ASLPP_FLAGS) DEF(CLANGPDB_X64_TARGET) *_CLANGPDB_X64_VFRPP_FLAGS = DEF(GCC_VFRPP_FLAGS) DEF(CLANGPDB_X64_TARGET) -DEBUG_CLANGPDB_X64_CC_FLAGS = DEF(CLANGPDB_ALL_CC_FLAGS) -m64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -Oz -flto DEF(CLANGPDB_X64_TARGET) -gcodeview -DEBUG_CLANGPDB_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /ALIGN:32 /FILEALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DEBUG:GHASH /lldmap +DEBUG_CLANGPDB_X64_CC_FLAGS = DEF(CLANGPDB_ALL_CC_FLAGS) -m64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -Oz -flto DEF(CLANGPDB_X64_TARGET) -gcodeview -funwind-tables +DEBUG_CLANGPDB_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /ALIGN:32 /FILEALIGN:32 /Machine:X64 /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DEBUG:GHASH /lldmap DEBUG_CLANGPDB_X64_DLINK2_FLAGS = +DEBUG_CLANGPDB_X64_GENFW_FLAGS = --keepexceptiontable -RELEASE_CLANGPDB_X64_CC_FLAGS = DEF(CLANGPDB_ALL_CC_FLAGS) -m64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -Oz -flto DEF(CLANGPDB_X64_TARGET) +RELEASE_CLANGPDB_X64_CC_FLAGS = DEF(CLANGPDB_ALL_CC_FLAGS) -m64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -Oz -flto DEF(CLANGPDB_X64_TARGET) -fno-unwind-tables RELEASE_CLANGPDB_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /ALIGN:32 /FILEALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /MERGE:.rdata=.data /lldmap RELEASE_CLANGPDB_X64_DLINK2_FLAGS = +RELEASE_CLANGPDB_X64_GENFW_FLAGS = -NOOPT_CLANGPDB_X64_CC_FLAGS = DEF(CLANGPDB_ALL_CC_FLAGS) -m64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -O0 DEF(CLANGPDB_X64_TARGET) -gcodeview -NOOPT_CLANGPDB_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /ALIGN:32 /FILEALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DEBUG:GHASH /lldmap +NOOPT_CLANGPDB_X64_CC_FLAGS = DEF(CLANGPDB_ALL_CC_FLAGS) -m64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -O0 DEF(CLANGPDB_X64_TARGET) -gcodeview -funwind-tables +NOOPT_CLANGPDB_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /ALIGN:32 /FILEALIGN:32 /Machine:X64 /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DEBUG:GHASH /lldmap NOOPT_CLANGPDB_X64_DLINK2_FLAGS = - +NOOPT_CLANGPDB_X64_GENFW_FLAGS = --keepexceptiontable # # -- 2.16.1.windows.4
|
|
[edk2-platforms][PATCH 1/1] Platform/RPi4: Add ACPI entry for Genet network interface
The Raspberry Pi 4 platforms uses a Broadcom Genet network interface, for
which we need ACPI entries in order to make it usable under Linux. This patch adds these entries, including a max-dma-burst-size DSD attribute aimed at simplifying support for Genet on distros that use older kernels, such as Debian. Note that we ran these settings through someone working for Broadcom, who okayed the proposed values including ownership of max-dma-burst-size (which we expect to also require for Device Tree usage on older kernels, hence the requirement for a designated owner). Signed-off-by: Pete Batard <pete@...> --- Platform/RaspberryPi/RPi4/AcpiTables/Dsdt.asl | 29 ++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/Dsdt.asl b/Platform/RaspberryPi/RPi4/AcpiTables/Dsdt.asl index b2f1d3439211..12c3967fa9e1 100644 --- a/Platform/RaspberryPi/RPi4/AcpiTables/Dsdt.asl +++ b/Platform/RaspberryPi/RPi4/AcpiTables/Dsdt.asl @@ -267,6 +267,35 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 5, "MSFT", "EDK2", 2) } } + Device (ETH0) + { + Name (_HID, "BCM6E4E") + Name (_CID, "BCM6E4E") + Name (_UID, 0x0) + Name (_CCA, 0x0) + Method (_STA) + { + Return (0xf) + } + Method (_CRS, 0x0, Serialized) + { + Name (RBUF, ResourceTemplate () + { + Memory32Fixed (ReadWrite, 0xfd580000, 0x10000, ) + Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0xBD } + Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0xBE } + }) + Return (RBUF) + } + Name (_DSD, Package () { + ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"), + Package () { + Package () { "brcm,max-dma-burst-size", 0x08 }, + Package () { "phy-mode", "rgmii" }, + } + }) + } + // Description: I2C Device (I2C1) { -- 2.21.0.windows.1
|
|
Re: [PATCH v2 1/1] BaseTools: Script for converting .aml to .hex
Liming Gao
Pierre:
toggle quoted messageShow quoted text
If so, this is not the error for other ACPI table. I suggest to print INFO message and directly return with success return value. Thanks Liming
-----Original Message-----
|
|
Re: [PATCH] UefiCpuPkg RegisterCpuFeaturesLib: Use %08x to print CacheControl Index
Laszlo Ersek
On 02/03/20 10:09, Zeng, Star wrote:
I disagree. It's not about the field width / padding (4 vs. 8-----Original Message-----%04u or %04d is not enough for UINT32 which needs %08x. characters), but the width of the data type. The parameter that's being passed is a UINTN, which is UINT64 on X64. But the format specifier (%d, %u, %x all alike) only expect a UINT32. If we pass a UINT64 (in the form of a UINTN), then we should print it with a UINT64 specifier (such as %lu or %lx). Alternatively, if we know for sure that the value of the UINT64 in question will fit in a UINT32, then we can use %u or %x for printing, but then we need to truncate (cast) the data that's being passed in, to UINT32. My point is that the data size should be a match between what's passed in and what is described with a format specifier. There is no format specifier that directly matches UINTN, so you either need to cast UINTN to UINT64 and use %lx, or cast UINTN to UINT32 and use %x. The patch is not wrong, it's just incomplete (given that we're modifying a format string that mismatches the argument list in other places too). ProcessorNumber and FeatureIndex are UINTNs, and they are being printed with %d. Those are real issues too. I found another real issue is MMIO : %08lx should be MMIO : %016lx as the code is on purpose to get UINT64 MMIO address.Field width / padding are useful to get right, but getting the data types to match is even more important. Thanks Laszlo I prefer to just handle the real issue in this patch. How do you think? 😊
|
|
Re: [PATCH v2 1/1] BaseTools: Script for converting .aml to .hex
PierreGondois
Hello Liming,
toggle quoted messageShow quoted text
Currently, the only ACPI tables which contain AML bytecode are the DSDT and SSDT tables. We don't need to generate a ".hex" file for other ACPI tables or any other file since we would like to parse AML bytecode. However this is only a safety check and this can be removed if desired. Regards, Pierre
-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Liming Gao via Groups.Io Sent: 03 February 2020 11:58 To: Pierre Gondois <Pierre.Gondois@...>; devel@edk2.groups.io Cc: ard.biesheuvel@...; Feng, Bob C <bob.c.feng@...>; Sami Mujawar <Sami.Mujawar@...>; nd <nd@...> Subject: Re: [edk2-devel] [PATCH v2 1/1] BaseTools: Script for converting .aml to .hex Pierre: Sorry for late response. I have one comment. Why only allows "DSDT" or "SSDT" in Signature? Thanks Liming -----Original Message-----
|
|
Re: [PATCH 1/2] BaseTools: append -DNO_MSABI_VA_FUNCS option in CLANGPDB tool chain
Liming Gao
Reviewed-by: Liming Gao <liming.gao@...>
toggle quoted messageShow quoted text
-----Original Message-----
|
|
Re: [PATCH 2/2] MdePkg: Use the same VA function for both CLANGPDB and CLANG38
Liming Gao
Reviewed-by: Liming Gao <liming.gao@...>
toggle quoted messageShow quoted text
-----Original Message-----
|
|
[edk2-platforms][PATCH v3 3/3] Platform/RPi4: Enable Broadcom Genet stub driver
From: Jeremy Linton <lintonrjeremy@...>
This adds the required references to use the Genet stub driver in order to dynamically populate the MAC address for OS consumption. Signed-off-by: Pete Batard <pete@...> --- Platform/RaspberryPi/RPi4/RPi4.dsc | 5 +++++ Platform/RaspberryPi/RPi4/RPi4.fdf | 1 + 2 files changed, 6 insertions(+) diff --git a/Platform/RaspberryPi/RPi4/RPi4.dsc b/Platform/RaspberryPi/RPi4/RPi4.dsc index b3a114b6e0ed..bd3800c1d653 100644 --- a/Platform/RaspberryPi/RPi4/RPi4.dsc +++ b/Platform/RaspberryPi/RPi4/RPi4.dsc @@ -402,6 +402,7 @@ [PcdsFixedAtBuild.common] gRaspberryPiTokenSpaceGuid.PcdExtendedMemoryBase|0x40000000 gBcm27xxTokenSpaceGuid.PcdBcm27xxRegistersAddress|0xfc000000 gBcm283xTokenSpaceGuid.PcdBcm283xRegistersAddress|0xfe000000 + gBcmNetTokenSpaceGuid.PcdBcmGenetRegistersAddress|0xfd580000 # PCIe specific addresses gBcm27xxTokenSpaceGuid.PcdBcm27xxPciRegBase|0xfd500000 @@ -648,6 +649,10 @@ [Components.common] # Networking stack # !include NetworkPkg/Network.dsc.inc + Silicon/Broadcom/Drivers/Net/BcmGenetDxe/BcmGenetDxe.inf { + <LibraryClasses> + NULL|Platform/RaspberryPi/Library/PlatformPcdLib/PlatformPcdLib.inf + } # # RNG diff --git a/Platform/RaspberryPi/RPi4/RPi4.fdf b/Platform/RaspberryPi/RPi4/RPi4.fdf index 2bcfdb3244f6..db393d47bcea 100644 --- a/Platform/RaspberryPi/RPi4/RPi4.fdf +++ b/Platform/RaspberryPi/RPi4/RPi4.fdf @@ -269,6 +269,7 @@ [FV.FvMain] # Networking stack # !include NetworkPkg/Network.fdf.inc + INF Silicon/Broadcom/Drivers/Net/BcmGenetDxe/BcmGenetDxe.inf # # RNG -- 2.21.0.windows.1
|
|
[edk2-platforms][PATCH v3 2/3] Platform/RPi: Add PlatformPcdLib to set the Genet MAC address
The Genet driver stub used by the Raspberry Pi 4 platform is
designed to set the MAC address according to a PCD. To be able to set that PCD at runtime, by using the Raspberry Pi firmware interface, that has a dedicated call to retrieve the MAC address, and satisfy driver dependencies in a generic manner, we create a new PlatformPcdLib that can be referenced by the Genet driver, to set the MAC PCD before use there. While it is currently only tailored around MAC PCD population for Genet, we do expect this PCD library to be extended in the future, to provide additional PCD facilities for other drivers. Signed-off-by: Pete Batard <pete@...> --- Platform/RaspberryPi/Library/PlatformPcdLib/PlatformPcdLib.c | 45 ++++++++++++++++++++ Platform/RaspberryPi/Library/PlatformPcdLib/PlatformPcdLib.inf | 43 +++++++++++++++++++ 2 files changed, 88 insertions(+) diff --git a/Platform/RaspberryPi/Library/PlatformPcdLib/PlatformPcdLib.c b/Platform/RaspberryPi/Library/PlatformPcdLib/PlatformPcdLib.c new file mode 100644 index 000000000000..e78518c81374 --- /dev/null +++ b/Platform/RaspberryPi/Library/PlatformPcdLib/PlatformPcdLib.c @@ -0,0 +1,45 @@ +/** @file + * + * Copyright (c) 2020, Pete Batard <pete@...> + * + * SPDX-License-Identifier: BSD-2-Clause-Patent + * + **/ + +#include <Library/DebugLib.h> +#include <Library/PcdLib.h> +#include <Library/PrintLib.h> +#include <Library/UefiBootServicesTableLib.h> +#include <Library/UefiLib.h> +#include <Library/UefiRuntimeServicesTableLib.h> +#include <Protocol/RpiFirmware.h> + +EFI_STATUS +EFIAPI +PlatformPcdLibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + UINT64 MacAddr; + RASPBERRY_PI_FIRMWARE_PROTOCOL *mFwProtocol; + + if (PcdGet64 (PcdBcmGenetMacAddress) == 0) { + Status = gBS->LocateProtocol (&gRaspberryPiFirmwareProtocolGuid, NULL, + (VOID**)&mFwProtocol); + ASSERT_EFI_ERROR(Status); + + // + // Get the MAC address from the firmware + // + Status = mFwProtocol->GetMacAddress ((UINT8*) &MacAddr); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_WARN, "%a: failed to retrieve MAC address\n", __FUNCTION__)); + } else { + PcdSet64S (PcdBcmGenetMacAddress, MacAddr); + } + } + + return EFI_SUCCESS; +} diff --git a/Platform/RaspberryPi/Library/PlatformPcdLib/PlatformPcdLib.inf b/Platform/RaspberryPi/Library/PlatformPcdLib/PlatformPcdLib.inf new file mode 100644 index 000000000000..2a207d2b3e54 --- /dev/null +++ b/Platform/RaspberryPi/Library/PlatformPcdLib/PlatformPcdLib.inf @@ -0,0 +1,43 @@ +#/** @file +# +# Copyright (c) 2020, Pete Batard <pete@...> +# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +#**/ + +[Defines] + INF_VERSION = 0x0001001A + BASE_NAME = PlatformPcdLib + FILE_GUID = 3B8409D7-D3C7-4006-823B-BFB184435363 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + LIBRARY_CLASS = NULL|DXE_DRIVER UEFI_APPLICATION + CONSTRUCTOR = PlatformPcdLibConstructor + +[Sources] + PlatformPcdLib.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + Platform/RaspberryPi/RaspberryPi.dec + Silicon/Broadcom/Drivers/Net/BcmNet.dec + +[LibraryClasses] + DebugLib + PcdLib + UefiLib + PrintLib + +[Protocols] + gRaspberryPiFirmwareProtocolGuid ## CONSUMES + +[Pcd] + gBcmNetTokenSpaceGuid.PcdBcmGenetMacAddress ## SOMETIMES_PRODUCES + +[FixedPcd] + gBcmNetTokenSpaceGuid.PcdBcmGenetRegistersAddress + +[Depex] + gRaspberryPiFirmwareProtocolGuid -- 2.21.0.windows.1
|
|
[edk2-platforms][PATCH v3 1/3] Silicon/Broadcom/Net: Add Genet stub driver to setup MAC
From: Jeremy Linton <lintonrjeremy@...>
Add a stub for the Broadcom Genet network interface, that is used by the Raspberry Pi 4 (and that may be used by other platforms). For the time being, the stub only performs UMAC init, using a MAC address PCD, as, even without a working network interface in UEFI environment, it is desirable if the hardware can describe itself for booting in an ACPI environment, rather than pass parameters via DSDT/DSD . Signed-off-by: Pete Batard <pete@...> --- Silicon/Broadcom/Drivers/Net/BcmGenetDxe/BcmGenetDxe.inf | 40 +++++++ Silicon/Broadcom/Drivers/Net/BcmGenetDxe/Genet.c | 114 ++++++++++++++++++++ Silicon/Broadcom/Drivers/Net/BcmGenetDxe/Genet.h | 20 ++++ Silicon/Broadcom/Drivers/Net/BcmNet.dec | 22 ++++ 4 files changed, 196 insertions(+) diff --git a/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/BcmGenetDxe.inf b/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/BcmGenetDxe.inf new file mode 100644 index 000000000000..9e9301608f24 --- /dev/null +++ b/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/BcmGenetDxe.inf @@ -0,0 +1,40 @@ +## @file +# +# Copyright (c) 2020, Jeremy Linton All rights reserved.<BR> +# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION = 0x0001001A + BASE_NAME = BcmGenetDxe + FILE_GUID = e2b1eaf3-50b7-4ae1-b79e-ec8020cb57ac + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 0.1 + ENTRY_POINT = GenetEntryPoint + +[Sources] + Genet.c + +[Packages] + ArmPkg/ArmPkg.dec + MdeModulePkg/MdeModulePkg.dec + MdePkg/MdePkg.dec + Silicon/Broadcom/Drivers/Net/BcmNet.dec + +[LibraryClasses] + ArmLib + BaseLib + IoLib + UefiDriverEntryPoint + UefiLib + +[FixedPcd] + gBcmNetTokenSpaceGuid.PcdBcmGenetRegistersAddress + +[Pcd] + gBcmNetTokenSpaceGuid.PcdBcmGenetMacAddress + +[Depex] + TRUE diff --git a/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/Genet.c b/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/Genet.c new file mode 100644 index 000000000000..9f29bc0c0894 --- /dev/null +++ b/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/Genet.c @@ -0,0 +1,114 @@ +/** @file + + Copyright (c) 2020, Jeremy Linton All rights reserved.<BR> + + SPDX-License-Identifier: BSD-2-Clause-Patent + + This driver acts like a stub to set the Broadcom + Genet MAC address, until the actual network driver + is in place. + +**/ + +#include <Library/ArmLib.h> +#include <Library/DebugLib.h> +#include <Library/IoLib.h> +#include <Library/PcdLib.h> +#include <Library/UefiBootServicesTableLib.h> +#include <Library/UefiLib.h> + +#include <Genet.h> +#include <PiDxe.h> + +STATIC +VOID +RMWRegister ( + UINT32 Offset, + UINT32 Mask, + UINT32 In + ) +{ + EFI_PHYSICAL_ADDRESS Addr; + UINT32 Data; + UINT32 Shift; + + Addr = GENET_BASE_ADDRESS + Offset; + Data = 0; + Shift = 1; + if (In) { + while (!(Mask & Shift)) + Shift <<= 1; + Data = (MmioRead32 (Addr) & ~Mask) | ((In * Shift) & Mask); + } else { + Data = MmioRead32 (Addr) & ~Mask; + } + + MmioWrite32 (Addr, Data); + + ArmDataMemoryBarrier (); +} + +STATIC +VOID +WdRegister ( + UINT32 Offset, + UINT32 In + ) +{ + EFI_PHYSICAL_ADDRESS Base = GENET_BASE_ADDRESS; + + MmioWrite32 (Base + Offset, In); + + ArmDataMemoryBarrier (); +} + +STATIC +VOID +SetMacAddress ( + UINT8* MacAddr +) +{ + // Bring the UMAC out of reset + RMWRegister (GENET_SYS_RBUF_FLUSH_CTRL, 0x2, 1); + gBS->Stall (10); + RMWRegister (GENET_SYS_RBUF_FLUSH_CTRL, 0x2, 0); + + // Update the MAC + DEBUG ((DEBUG_INFO, "Using MAC address %02X:%02X:%02X:%02X:%02X:%02X\n", + MacAddr[0], MacAddr[1], MacAddr[2], MacAddr[3], MacAddr[4], MacAddr[5])); + + WdRegister (GENET_UMAC_MAC0, (MacAddr[0] << 24) | (MacAddr[1] << 16) | + (MacAddr[2] << 8) | MacAddr[3]); + WdRegister (GENET_UMAC_MAC1, (MacAddr[4] << 8) | MacAddr[5]); + +} + +/** + The entry point of Genet UEFI Driver. + + @param ImageHandle The image handle of the UEFI Driver. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The Driver or UEFI Driver exited normally. + @retval EFI_INCOMPATIBLE_VERSION _gUefiDriverRevision is greater than + SystemTable->Hdr.Revision. + +**/ +EFI_STATUS +EFIAPI +GenetEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + UINT64 MacAddr; + + // Read the MAC address + MacAddr = PcdGet64 (PcdBcmGenetMacAddress); + + if (MacAddr != 0) { + SetMacAddress ((UINT8*)&MacAddr); + } + + return EFI_SUCCESS; +} diff --git a/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/Genet.h b/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/Genet.h new file mode 100644 index 000000000000..4a3827c0e0d1 --- /dev/null +++ b/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/Genet.h @@ -0,0 +1,20 @@ +/** @file + + Copyright (c) 2020, Pete Batard <pete@...> + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef BCM_GENET_H__ +#define BCM_GENET_H__ + +#include <Library/PcdLib.h> + +#define GENET_BASE_ADDRESS (FixedPcdGet64 (PcdBcmGenetRegistersAddress)) + +#define GENET_SYS_RBUF_FLUSH_CTRL 0x0008 +#define GENET_UMAC_MAC0 0x080c +#define GENET_UMAC_MAC1 0x0810 + +#endif /* BCM_GENET_H__ */ diff --git a/Silicon/Broadcom/Drivers/Net/BcmNet.dec b/Silicon/Broadcom/Drivers/Net/BcmNet.dec new file mode 100644 index 000000000000..2a8688cb09a7 --- /dev/null +++ b/Silicon/Broadcom/Drivers/Net/BcmNet.dec @@ -0,0 +1,22 @@ +## @file +# +# Copyright (c) 2020, Pete Batard <pete@...> +# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + DEC_SPECIFICATION = 0x0001001A + PACKAGE_NAME = BcmNetPkg + PACKAGE_GUID = 34E19823-D23A-41AB-9C09-ED1225B32DFF + PACKAGE_VERSION = 1.0 + +[Guids] + gBcmNetTokenSpaceGuid = {0x12b97d70, 0x9149, 0x4c2f, {0x82, 0xd5, 0xad, 0xa9, 0x1e, 0x92, 0x75, 0xa1}} + +[PcdsFixedAtBuild] + gBcmNetTokenSpaceGuid.PcdBcmGenetRegistersAddress|0x0|UINT64|0x00000001 + +[PcdsDynamic] + gBcmNetTokenSpaceGuid.PcdBcmGenetMacAddress|0x0|UINT64|0x00000002 -- 2.21.0.windows.1
|
|
[edk2-platforms][PATCH v3 0/3] Platform/RPi4: Add Genet network driver stub
Changes from v2:
* Remove #if (FixedPcdGet64 (PcdBcmGenetRegistersAddress) != 0) check Jeremy Linton (2): Silicon/Broadcom/Net: Add Genet stub driver to setup MAC Platform/RPi4: Enable Broadcom Genet stub driver Pete Batard (1): Platform/RPi: Add PlatformPcdLib to set the Genet MAC address Platform/RaspberryPi/Library/PlatformPcdLib/PlatformPcdLib.c | 45 ++++++++ Platform/RaspberryPi/Library/PlatformPcdLib/PlatformPcdLib.inf | 43 ++++++++ Platform/RaspberryPi/RPi4/RPi4.dsc | 5 + Platform/RaspberryPi/RPi4/RPi4.fdf | 1 + Silicon/Broadcom/Drivers/Net/BcmGenetDxe/BcmGenetDxe.inf | 40 +++++++ Silicon/Broadcom/Drivers/Net/BcmGenetDxe/Genet.c | 114 ++++++++++++++++++++ Silicon/Broadcom/Drivers/Net/BcmGenetDxe/Genet.h | 20 ++++ Silicon/Broadcom/Drivers/Net/BcmNet.dec | 22 ++++ 8 files changed, 290 insertions(+) create mode 100644 Platform/RaspberryPi/Library/PlatformPcdLib/PlatformPcdLib.c create mode 100644 Platform/RaspberryPi/Library/PlatformPcdLib/PlatformPcdLib.inf create mode 100644 Silicon/Broadcom/Drivers/Net/BcmGenetDxe/BcmGenetDxe.inf create mode 100644 Silicon/Broadcom/Drivers/Net/BcmGenetDxe/Genet.c create mode 100644 Silicon/Broadcom/Drivers/Net/BcmGenetDxe/Genet.h create mode 100644 Silicon/Broadcom/Drivers/Net/BcmNet.dec -- 2.21.0.windows.1
|
|
Re: [PATCH v1 1/1] BaseTools: Rationalise makefile generation
Liming Gao
Pierre:
toggle quoted messageShow quoted text
Thanks for your contribution. Do you verify below configurations? And, how do you verify Windows host + GCC make? 1. Windows Host + VS nmake 2. Windows Host + GCC make 3. Linux Host + GCC make. Thanks Liming
-----Original Message-----
|
|
Re: [PATCH v2 1/1] BaseTools: Script for converting .aml to .hex
Liming Gao
Pierre:
toggle quoted messageShow quoted text
Sorry for late response. I have one comment. Why only allows "DSDT" or "SSDT" in Signature? Thanks Liming
-----Original Message-----
|
|
Re: [PATCH 0/1] Use _MSC_VER to determine MSVC compiler
Vitaly Cheptsov
Liming, I believe that -fms-compatibility option is not needed for CLANGPDB, as CLANGPDB is literally using clang, and that worked fine before in CLANG38 and XCODE5. We may still have to update some preprocessor conditions to include __clang__ near __GNUC__ if __GNUC__ is left undefined even when we remove -fms-compatibility, but that sounds fine for me. We will investigate that on our own and submit a new patch, but help from other parties is strongly appreciated. We mostly use XCODE5 and are not well aware of other platforms. Best wishes, Vitaly
On Mon, Feb 3, 2020 at 11:00, Gao, Liming <liming.gao@...> wrote:
Vitaly:
|
|
Re: [PATCH v1] UefiCpuPkg/MpInitLib: Always get CPUID & PlatformID in MicrocodeDetect()
Laszlo Ersek
Hello Hao,
On 02/03/20 01:34, Hao A Wu wrote: REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2498It seems like I haven't been involved in reviewing either commit fd30b0070773 ("UefiCpuPkg/MpInitLib: Remove redundant microcode fields in CPU_MP_DATA", 2020-01-02) or commit 396e791059f3 ("UefiCpuPkg: Always load microcode patch on AP processor.", 2020-01-08), so I'd like to defer on this patch to the other UefiCpuPkg reviewers. Thanks! Laszlo diff --git a/UefiCpuPkg/Library/MpInitLib/Microcode.c b/UefiCpuPkg/Library/MpInitLib/Microcode.c
|
|
Re: [PATCH] UefiCpuPkg RegisterCpuFeaturesLib: Use %08x to print CacheControl Index
Zeng, Star
toggle quoted messageShow quoted text
-----Original Message-----%04u or %04d is not enough for UINT32 which needs %08x. I thought the code is just taking assumption about their value should be not > 9999u. It is not a real issue. This patch is to fix a real issue, without it, the print for ValidBitStart, ValidBitLength and Value will be wrong because the parameter for them are shifted for Index to fetch UINT64 value. I found another real issue is MMIO : %08lx should be MMIO : %016lx as the code is on purpose to get UINT64 MMIO address. I prefer to just handle the real issue in this patch. How do you think? 😊 Thanks, Star
|
|