Skip to content

Commit

Permalink
refactor: Remove ResetLib dependency from BaseDebugLibSerialPort
Browse files Browse the repository at this point in the history
In BaseDebugLibSerialPort, avoid depending on ResetLib by replacing the
call to ResetCold() with a private function.

We have been using a deprecated ResetLib implementation, which has been
removed in edk2-stable202408.  The replacement ResetLib depends on
DebugLib, which puts us in a circular dependency.  Break the circle by
removing our DebugLib's dependency on ResetLib.

Signed-off-by: Jake Garver <jake@nvidia.com>
Reviewed-by: Jeff Brasen <jbrasen@nvidia.com>
  • Loading branch information
jgarver committed Dec 11, 2024
1 parent f836ea3 commit 5fe6aee
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
DebugLib.c

[Packages]
ArmPkg/ArmPkg.dec
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
Silicon/NVIDIA/NVIDIA.dec
Expand All @@ -38,7 +39,7 @@
PrintLib
BaseLib
DebugPrintErrorLevelLib
ResetSystemLib
ArmMonitorLib
IoLib
DebugLogScratchRegLib

Expand Down
27 changes: 25 additions & 2 deletions Silicon/NVIDIA/Library/BaseDebugLibSerialPort/DebugLib.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
#include <Library/SerialPortLib.h>
#include <Library/DebugPrintErrorLevelLib.h>
#include <Library/TimerLib.h>
#include <Library/ResetSystemLib.h>
#include <IndustryStandard/ArmStdSmc.h>
#include <Library/ArmMonitorLib.h>

//
// Define the maximum debug and assert message length that this library supports
Expand Down Expand Up @@ -195,6 +196,28 @@ DebugBPrint (
DebugPrintMarker (ErrorLevel, Format, mVaListNull, BaseListMarker);
}

/**
This function causes a system-wide reset (cold reset), in which
all circuitry within the system returns to its initial state. This type of reset
is asynchronous to system operation and operates without regard to
cycle boundaries.
Copied from ArmPsciResetSystemLib to avoid a circular dependency.
**/
STATIC
VOID
DebugResetCold (
VOID
)
{
ARM_MONITOR_ARGS Args;

// Send a PSCI 0.2 SYSTEM_RESET command
Args.Arg0 = ARM_SMC_ID_PSCI_SYSTEM_RESET;

ArmMonitorCall (&Args);
}

/**
Prints an assert message containing a filename, line number, and description.
This may be followed by a breakpoint or a dead loop.
Expand Down Expand Up @@ -276,7 +299,7 @@ DebugAssert (
MicroSecondDelay (ResetDelay * 1000000);
}

ResetCold ();
DebugResetCold ();
}
}

Expand Down

0 comments on commit 5fe6aee

Please sign in to comment.