23#define EFI_DEP_REPLACE_TRUE 0xff
28#define DEPEX_STACK_SIZE_INCREMENT 0x1000
33BOOLEAN *mDepexEvaluationStack =
NULL;
34BOOLEAN *mDepexEvaluationStackEnd =
NULL;
35BOOLEAN *mDepexEvaluationStackPointer =
NULL;
52 Size = DEPEX_STACK_SIZE_INCREMENT;
53 if (mDepexEvaluationStack !=
NULL) {
54 Size = Size + (mDepexEvaluationStackEnd - mDepexEvaluationStack);
58 if (NewStack ==
NULL) {
59 return EFI_OUT_OF_RESOURCES;
62 if (mDepexEvaluationStack !=
NULL) {
68 mDepexEvaluationStack,
69 (mDepexEvaluationStackEnd - mDepexEvaluationStack) *
sizeof (BOOLEAN)
81 mDepexEvaluationStackPointer = NewStack + (mDepexEvaluationStackPointer - mDepexEvaluationStack);
82 mDepexEvaluationStack = NewStack;
83 mDepexEvaluationStackEnd = NewStack + Size;
107 if (mDepexEvaluationStackPointer == mDepexEvaluationStackEnd) {
112 if (EFI_ERROR (Status)) {
120 *mDepexEvaluationStackPointer = Value;
121 mDepexEvaluationStackPointer++;
143 if (mDepexEvaluationStackPointer == mDepexEvaluationStack) {
144 return EFI_ACCESS_DENIED;
150 mDepexEvaluationStackPointer--;
151 *Value = *mDepexEvaluationStackPointer;
190 DEBUG ((DEBUG_DISPATCH,
"Evaluate SMM DEPEX for FFS(%g)\n", &
DriverEntry->FileName));
197 DEBUG ((DEBUG_DISPATCH,
" RESULT = FALSE (Depex is empty)\n"));
206 mDepexEvaluationStackPointer = mDepexEvaluationStack;
216 DEBUG ((DEBUG_DISPATCH,
" RESULT = FALSE (Attempt to fetch past end of depex)\n"));
232 DEBUG ((DEBUG_DISPATCH,
" RESULT = FALSE (Unexpected BEFORE or AFTER opcode)\n"));
243 if (EFI_ERROR (Status)) {
247 Status =
gBS->LocateProtocol (&DriverGuid,
NULL, &Interface);
250 if (EFI_ERROR (Status)) {
251 DEBUG ((DEBUG_DISPATCH,
" PUSH GUID(%g) = FALSE\n", &DriverGuid));
254 DEBUG ((DEBUG_DISPATCH,
" PUSH GUID(%g) = TRUE\n", &DriverGuid));
259 if (EFI_ERROR (Status)) {
260 DEBUG ((DEBUG_DISPATCH,
" RESULT = FALSE (Unexpected error)\n"));
268 DEBUG ((DEBUG_DISPATCH,
" AND\n"));
270 if (EFI_ERROR (Status)) {
271 DEBUG ((DEBUG_DISPATCH,
" RESULT = FALSE (Unexpected error)\n"));
276 if (EFI_ERROR (Status)) {
277 DEBUG ((DEBUG_DISPATCH,
" RESULT = FALSE (Unexpected error)\n"));
281 Status =
PushBool ((BOOLEAN)(Operator && Operator2));
282 if (EFI_ERROR (Status)) {
283 DEBUG ((DEBUG_DISPATCH,
" RESULT = FALSE (Unexpected error)\n"));
290 DEBUG ((DEBUG_DISPATCH,
" OR\n"));
292 if (EFI_ERROR (Status)) {
293 DEBUG ((DEBUG_DISPATCH,
" RESULT = FALSE (Unexpected error)\n"));
298 if (EFI_ERROR (Status)) {
299 DEBUG ((DEBUG_DISPATCH,
" RESULT = FALSE (Unexpected error)\n"));
303 Status =
PushBool ((BOOLEAN)(Operator || Operator2));
304 if (EFI_ERROR (Status)) {
305 DEBUG ((DEBUG_DISPATCH,
" RESULT = FALSE (Unexpected error)\n"));
312 DEBUG ((DEBUG_DISPATCH,
" NOT\n"));
314 if (EFI_ERROR (Status)) {
315 DEBUG ((DEBUG_DISPATCH,
" RESULT = FALSE (Unexpected error)\n"));
319 Status =
PushBool ((BOOLEAN)(!Operator));
320 if (EFI_ERROR (Status)) {
321 DEBUG ((DEBUG_DISPATCH,
" RESULT = FALSE (Unexpected error)\n"));
328 DEBUG ((DEBUG_DISPATCH,
" TRUE\n"));
330 if (EFI_ERROR (Status)) {
331 DEBUG ((DEBUG_DISPATCH,
" RESULT = FALSE (Unexpected error)\n"));
338 DEBUG ((DEBUG_DISPATCH,
" FALSE\n"));
340 if (EFI_ERROR (Status)) {
341 DEBUG ((DEBUG_DISPATCH,
" RESULT = FALSE (Unexpected error)\n"));
348 DEBUG ((DEBUG_DISPATCH,
" END\n"));
350 if (EFI_ERROR (Status)) {
351 DEBUG ((DEBUG_DISPATCH,
" RESULT = FALSE (Unexpected error)\n"));
355 DEBUG ((DEBUG_DISPATCH,
" RESULT = %a\n", Operator ?
"TRUE" :
"FALSE"));
360 DEBUG ((DEBUG_DISPATCH,
" PUSH GUID(%g) = TRUE\n", &DriverGuid));
362 if (EFI_ERROR (Status)) {
363 DEBUG ((DEBUG_DISPATCH,
" RESULT = FALSE (Unexpected error)\n"));
371 DEBUG ((DEBUG_DISPATCH,
" RESULT = FALSE (Unknown opcode)\n"));
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
#define EFI_DEP_REPLACE_TRUE
VOID EFIAPI FreePool(IN VOID *Buffer)
EFI_STATUS PopBool(OUT BOOLEAN *Value)
EFI_STATUS GrowDepexStack(VOID)
EFI_STATUS PushBool(IN BOOLEAN Value)
BOOLEAN SmmIsSchedulable(IN EFI_SMM_DRIVER_ENTRY *DriverEntry)
EFI_STATUS EFIAPI SmmLocateProtocol(IN EFI_GUID *Protocol, IN VOID *Registration OPTIONAL, OUT VOID **Interface)
#define DEBUG(Expression)
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)
EFI_STATUS EFIAPI DriverEntry(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)