Changeset View
Changeset View
Standalone View
Standalone View
stand/efi/loader/main.c
Show First 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | |||||
#include <setjmp.h> | #include <setjmp.h> | ||||
#include <disk.h> | #include <disk.h> | ||||
#include <dev_net.h> | #include <dev_net.h> | ||||
#include <net.h> | #include <net.h> | ||||
#include <efi.h> | #include <efi.h> | ||||
#include <efilib.h> | #include <efilib.h> | ||||
#include <efichar.h> | #include <efichar.h> | ||||
#include <efirng.h> | |||||
#include <uuid.h> | #include <uuid.h> | ||||
#include <bootstrap.h> | #include <bootstrap.h> | ||||
#include <smbios.h> | #include <smbios.h> | ||||
#include "efizfs.h" | #include "efizfs.h" | ||||
▲ Show 20 Lines • Show All 1,134 Lines • ▼ Show 20 Lines | if (!memcmp(guid, &smbios, sizeof(EFI_GUID))) { | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
#endif | #endif | ||||
interact(); /* doesn't return */ | interact(); /* doesn't return */ | ||||
return (EFI_SUCCESS); /* keep compiler happy */ | return (EFI_SUCCESS); /* keep compiler happy */ | ||||
} | |||||
COMMAND_SET(efi_seed_entropy, "efi-seed-entropy", "try to get entropy from the EFI RNG", command_seed_entropy); | |||||
static int | |||||
command_seed_entropy(int argc, char *argv[]) | |||||
{ | |||||
EFI_STATUS status; | |||||
EFI_RNG_PROTOCOL *rng; | |||||
unsigned int size = 2048; | |||||
void *buf; | |||||
if (argc > 1) { | |||||
size = strtol(argv[1], NULL, 0); | |||||
} | |||||
status = BS->LocateProtocol(&rng_guid, NULL, (VOID **)&rng); | |||||
if (status != EFI_SUCCESS) { | |||||
command_errmsg = "RNG protocol not found"; | |||||
return (CMD_ERROR); | |||||
} | |||||
if ((buf = malloc(size)) == NULL) { | |||||
command_errmsg = "out of memory"; | |||||
return (CMD_ERROR); | |||||
} | |||||
status = rng->GetRNG(rng, NULL, size, (UINT8 *)buf); | |||||
if (status != EFI_SUCCESS) { | |||||
free(buf); | |||||
command_errmsg = "GetRNG failed"; | |||||
return (CMD_ERROR); | |||||
} | |||||
if (file_addbuf("efi_rng_seed", "boot_entropy_platform", size, buf) != 0) { | |||||
free(buf); | |||||
return (CMD_ERROR); | |||||
} | |||||
free(buf); | |||||
return (CMD_OK); | |||||
} | } | ||||
COMMAND_SET(poweroff, "poweroff", "power off the system", command_poweroff); | COMMAND_SET(poweroff, "poweroff", "power off the system", command_poweroff); | ||||
static int | static int | ||||
command_poweroff(int argc __unused, char *argv[] __unused) | command_poweroff(int argc __unused, char *argv[] __unused) | ||||
{ | { | ||||
int i; | int i; | ||||
▲ Show 20 Lines • Show All 470 Lines • Show Last 20 Lines |