diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2016-05-20 11:53:20 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2016-05-20 11:53:20 +0000 |
commit | 2aee539eb8b58c3ef382ff1f72ecfd670b2ffc30 (patch) | |
tree | d1d187e1d6b152746e9aedb9970b412f7e0e1ac1 /sys/arch | |
parent | deabb2cfe2433be52571bd183a8f5d194398b746 (diff) |
Set "openbsd.bootduid" property of "/chosen" to the DUID of the boot disk.
ok patrick@, jsg@
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/armv7/stand/efiboot/disk.h | 18 | ||||
-rw-r--r-- | sys/arch/armv7/stand/efiboot/efiboot.c | 20 | ||||
-rw-r--r-- | sys/arch/armv7/stand/efiboot/efidev.c | 15 |
3 files changed, 34 insertions, 19 deletions
diff --git a/sys/arch/armv7/stand/efiboot/disk.h b/sys/arch/armv7/stand/efiboot/disk.h new file mode 100644 index 00000000000..39df96bbc20 --- /dev/null +++ b/sys/arch/armv7/stand/efiboot/disk.h @@ -0,0 +1,18 @@ +#ifndef _DISK_H +#define _DISK_H + +typedef struct efi_diskinfo { + EFI_BLOCK_IO *blkio; + UINT32 mediaid; +} *efi_diskinfo_t; + +struct diskinfo { + struct efi_diskinfo ed; + struct disklabel disklabel; + + u_int sc_part; +}; + +extern struct diskinfo diskinfo; + +#endif /* _DISK_H */ diff --git a/sys/arch/armv7/stand/efiboot/efiboot.c b/sys/arch/armv7/stand/efiboot/efiboot.c index 15a4672e19d..34d545c9375 100644 --- a/sys/arch/armv7/stand/efiboot/efiboot.c +++ b/sys/arch/armv7/stand/efiboot/efiboot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: efiboot.c,v 1.7 2016/05/19 09:39:06 jsg Exp $ */ +/* $OpenBSD: efiboot.c,v 1.8 2016/05/20 11:53:19 kettenis Exp $ */ /* * Copyright (c) 2015 YASUOKA Masahiko <yasuoka@yasuoka.net> @@ -30,6 +30,7 @@ #include <lib/libkern/libkern.h> #include <stand/boot/cmd.h> +#include "disk.h" #include "eficall.h" #include "fdt.h" #include "libsa.h" @@ -245,7 +246,8 @@ void * efi_makebootargs(char *bootargs, uint32_t *board_id) { void *fdt = NULL; - char *dummy; + u_char bootduid[8]; + u_char zero[8]; void *node; size_t len; int i; @@ -264,10 +266,16 @@ efi_makebootargs(char *bootargs, uint32_t *board_id) return NULL; len = strlen(bootargs) + 1; - if (fdt_node_property(node, "bootargs", &dummy)) - fdt_node_set_property(node, "bootargs", bootargs, len); - else - fdt_node_add_property(node, "bootargs", bootargs, len); + fdt_node_add_property(node, "bootargs", bootargs, len); + + /* Pass DUID of the boot disk. */ + memset(&zero, 0, sizeof(zero)); + memcpy(&bootduid, diskinfo.disklabel.d_uid, sizeof(bootduid)); + if (memcmp(bootduid, zero, sizeof(bootduid)) != 0) { + fdt_node_add_property(node, "openbsd,bootduid", bootduid, + sizeof(bootduid)); + } + fdt_finalize(); node = fdt_find_node("/"); diff --git a/sys/arch/armv7/stand/efiboot/efidev.c b/sys/arch/armv7/stand/efiboot/efidev.c index 6d0a25f7258..9a76b9b152d 100644 --- a/sys/arch/armv7/stand/efiboot/efidev.c +++ b/sys/arch/armv7/stand/efiboot/efidev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: efidev.c,v 1.1 2016/05/14 17:55:15 kettenis Exp $ */ +/* $OpenBSD: efidev.c,v 1.2 2016/05/20 11:53:19 kettenis Exp $ */ /* * Copyright (c) 2015 YASUOKA Masahiko <yasuoka@yasuoka.net> @@ -41,23 +41,12 @@ extern EFI_BOOT_SERVICES *BS; extern int debug; +#include "disk.h" #include "efidev.h" #define EFI_BLKSPERSEC(_ed) ((_ed)->blkio->Media->BlockSize / DEV_BSIZE) #define EFI_SECTOBLK(_ed, _n) ((_n) * EFI_BLKSPERSEC(_ed)) -typedef struct efi_diskinfo { - EFI_BLOCK_IO *blkio; - UINT32 mediaid; -} *efi_diskinfo_t; - -struct diskinfo { - struct efi_diskinfo ed; - struct disklabel disklabel; - - u_int sc_part; -}; - extern EFI_BLOCK_IO *disk; struct diskinfo diskinfo; |