-# $OpenBSD: Makefile,v 1.13 2021/11/14 21:51:48 guenther Exp $
+# $OpenBSD: Makefile,v 1.14 2021/12/14 11:05:37 kettenis Exp $
NOMAN= #
CPPFLAGS+= -I${EFIDIR}/include -I${EFIDIR}/include/arm64
CPPFLAGS+= -D_STANDALONE
CPPFLAGS+= -DSMALL -DSLOW -DNOBYFOUR -D__INTERNAL_LIBSA_CREAD
-CPPFLAGS+= -DNEEDS_HEAP_H -DFWRANDOM
+CPPFLAGS+= -DNEEDS_HEAP_H -DMDRANDOM -DFWRANDOM
COPTS+= -Wno-attributes -Wno-format
COPTS+= -ffreestanding -fno-stack-protector
COPTS+= -fshort-wchar -fPIC -fno-builtin
-/* $OpenBSD: efiboot.c,v 1.36 2021/10/26 14:10:02 patrick Exp $ */
+/* $OpenBSD: efiboot.c,v 1.37 2021/12/14 11:05:37 kettenis Exp $ */
/*
* Copyright (c) 2015 YASUOKA Masahiko <yasuoka@yasuoka.net>
EFI_BOOT_SERVICES *BS;
EFI_RUNTIME_SERVICES *RS;
EFI_HANDLE IH, efi_bootdp;
+void *fdt = NULL;
EFI_PHYSICAL_ADDRESS heap;
UINTN heapsiz = 1 * 1024 * 1024;
static EFI_GUID blkio_guid = BLOCK_IO_PROTOCOL;
static EFI_GUID devp_guid = DEVICE_PATH_PROTOCOL;
static EFI_GUID gop_guid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID;
+static EFI_GUID fdt_guid = FDT_TABLE_GUID;
+
+#defin efi_guidcmp(_a, _b) memcmp((_a), (_b), sizeof(EFI_GUID))
int efi_device_path_depth(EFI_DEVICE_PATH *dp, int);
int efi_device_path_ncmp(EFI_DEVICE_PATH *, EFI_DEVICE_PATH *, int);
EFI_LOADED_IMAGE *imgp;
EFI_DEVICE_PATH *dp = NULL;
EFI_STATUS status;
+ int i;
ST = systab;
BS = ST->BootServices;
if (status == EFI_SUCCESS)
efi_bootdp = dp;
+ for (i = 0; i < ST->NumberOfTableEntries; i++) {
+ if (efi_guidcmp(&fdt_guid,
+ &ST->ConfigurationTable[i].VendorGuid) == 0)
+ fdt = ST->ConfigurationTable[i].VendorTable;
+ }
+ fdt_init(fdt);
+
progname = "BOOTAA64";
boot(0);
}
int acpi = 0;
-void *fdt = NULL;
char *bootmac = NULL;
-static EFI_GUID fdt_guid = FDT_TABLE_GUID;
-
-#define efi_guidcmp(_a, _b) memcmp((_a), (_b), sizeof(EFI_GUID))
void *
efi_makebootargs(char *bootargs, int howto)
EFI_PHYSICAL_ADDRESS addr;
void *node;
size_t len;
- int i;
-
- if (fdt == NULL) {
- for (i = 0; i < ST->NumberOfTableEntries; i++) {
- if (efi_guidcmp(&fdt_guid,
- &ST->ConfigurationTable[i].VendorGuid) == 0)
- fdt = ST->ConfigurationTable[i].VendorTable;
- }
- }
if (fdt == NULL || acpi)
fdt = efi_acpi();
return EFI_OUT_OF_RESOURCES;
}
+int
+mdrandom(char *buf, size_t buflen)
+{
+ char *random;
+ void *node;
+ int i, len, ret = -1;
+
+ node = fdt_find_node("/chosen");
+ if (!node)
+ return -1;
+
+ len = fdt_node_property(node, "rng-seed", &random);
+ if (len > 0) {
+ for (i = 0; i < buflen; i++)
+ buf[i] ^= random[i % len];
+ ret = 0;
+ }
+
+ len = fdt_node_property(node, "kaslr-seed", &random);
+ if (len > 0) {
+ for (i = 0; i < buflen; i++)
+ buf[i] ^= random[i % len];
+ ret = 0;
+ }
+
+ return ret;
+}
+
/*
* Commands
*/