From cee1c57d02b7a0d9c9453f40476fd858f4025aa2 Mon Sep 17 00:00:00 2001 From: Mark Kettenis Date: Mon, 7 Aug 2017 19:34:54 +0000 Subject: Add "machine exit" and "machine poweroff" commands to the arm64 and armv7 bootloaders. Replace while (1) { } with for (;;) continue; per request from tom@. ok tom@, jsg@ --- sys/arch/amd64/stand/efiboot/efiboot.c | 8 ++++--- sys/arch/arm64/stand/efiboot/conf.c | 4 ++-- sys/arch/arm64/stand/efiboot/efiboot.c | 43 +++++++++++++++++++++++++--------- sys/arch/arm64/stand/efiboot/libsa.h | 4 +++- sys/arch/armv7/stand/efiboot/conf.c | 4 ++-- sys/arch/armv7/stand/efiboot/efiboot.c | 36 +++++++++++++++++++++++++--- sys/arch/armv7/stand/efiboot/libsa.h | 4 +++- 7 files changed, 80 insertions(+), 23 deletions(-) diff --git a/sys/arch/amd64/stand/efiboot/efiboot.c b/sys/arch/amd64/stand/efiboot/efiboot.c index 0ff0f53fc50..085a2c768ae 100644 --- a/sys/arch/amd64/stand/efiboot/efiboot.c +++ b/sys/arch/amd64/stand/efiboot/efiboot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: efiboot.c,v 1.22 2017/07/31 14:04:53 kettenis Exp $ */ +/* $OpenBSD: efiboot.c,v 1.23 2017/08/07 19:34:53 kettenis Exp $ */ /* * Copyright (c) 2015 YASUOKA Masahiko @@ -793,7 +793,8 @@ _rtt(void) efi_cons_getc(0); #endif EFI_CALL(RS->ResetSystem, EfiResetCold, EFI_SUCCESS, 0, NULL); - while (1) { } + for (;;) + continue; } time_t @@ -834,7 +835,8 @@ int Xexit_efi(void) { EFI_CALL(BS->Exit, IH, 0, 0, NULL); - while (1) { } + for (;;) + continue; return (0); } diff --git a/sys/arch/arm64/stand/efiboot/conf.c b/sys/arch/arm64/stand/efiboot/conf.c index 7351350e548..5fff9bb92c4 100644 --- a/sys/arch/arm64/stand/efiboot/conf.c +++ b/sys/arch/arm64/stand/efiboot/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.6 2017/07/31 14:06:29 kettenis Exp $ */ +/* $OpenBSD: conf.c,v 1.7 2017/08/07 19:34:53 kettenis Exp $ */ /* * Copyright (c) 1996 Michael Shalayeff @@ -35,7 +35,7 @@ #include "efiboot.h" #include "efidev.h" -const char version[] = "0.6"; +const char version[] = "0.7"; int debug = 0; struct fs_ops file_system[] = { diff --git a/sys/arch/arm64/stand/efiboot/efiboot.c b/sys/arch/arm64/stand/efiboot/efiboot.c index defb4e3ab4f..b5ce52427dd 100644 --- a/sys/arch/arm64/stand/efiboot/efiboot.c +++ b/sys/arch/arm64/stand/efiboot/efiboot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: efiboot.c,v 1.10 2017/07/31 14:06:29 kettenis Exp $ */ +/* $OpenBSD: efiboot.c,v 1.11 2017/08/07 19:34:53 kettenis Exp $ */ /* * Copyright (c) 2015 YASUOKA Masahiko @@ -395,17 +395,9 @@ _rtt(void) printf("Hit any key to reboot\n"); efi_cons_getc(0); #endif - /* - * XXX ResetSystem doesn't seem to work on U-Boot 2016.05 on - * the CuBox-i. So trigger an unimplemented instruction trap - * instead. - */ -#if 1 - asm volatile(".word 0xa000f7f0\n"); -#else RS->ResetSystem(EfiResetCold, EFI_SUCCESS, 0, NULL); -#endif - while (1) { } + for (;;) + continue; } /* @@ -635,3 +627,32 @@ efi_memprobe_find(UINTN pages, UINTN align, EFI_PHYSICAL_ADDRESS *addr) } return EFI_OUT_OF_RESOURCES; } + +/* + * Commands + */ + +int Xexit_efi(void); +int Xpoweroff_efi(void); + +const struct cmd_table cmd_machine[] = { + { "exit", CMDT_CMD, Xexit_efi }, + { "poweroff", CMDT_CMD, Xpoweroff_efi }, + { NULL, 0 } +}; + +int +Xexit_efi(void) +{ + EFI_CALL(BS->Exit, IH, 0, 0, NULL); + for (;;) + continue; + return (0); +} + +int +Xpoweroff_efi(void) +{ + EFI_CALL(RS->ResetSystem, EfiResetShutdown, EFI_SUCCESS, 0, NULL); + return (0); +} diff --git a/sys/arch/arm64/stand/efiboot/libsa.h b/sys/arch/arm64/stand/efiboot/libsa.h index a75b5589bb5..08bd403f085 100644 --- a/sys/arch/arm64/stand/efiboot/libsa.h +++ b/sys/arch/arm64/stand/efiboot/libsa.h @@ -1,4 +1,4 @@ -/* $OpenBSD: libsa.h,v 1.1 2016/12/17 23:38:33 patrick Exp $ */ +/* $OpenBSD: libsa.h,v 1.2 2017/08/07 19:34:53 kettenis Exp $ */ /* * Copyright (c) 2008 Mark Kettenis @@ -28,3 +28,5 @@ void machdep(void); void devboot(dev_t, char *); + +#define MACHINE_CMD cmd_machine diff --git a/sys/arch/armv7/stand/efiboot/conf.c b/sys/arch/armv7/stand/efiboot/conf.c index 084ea3f9fb3..b8391d4bee0 100644 --- a/sys/arch/armv7/stand/efiboot/conf.c +++ b/sys/arch/armv7/stand/efiboot/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.9 2017/07/31 14:05:57 kettenis Exp $ */ +/* $OpenBSD: conf.c,v 1.10 2017/08/07 19:34:53 kettenis Exp $ */ /* * Copyright (c) 1996 Michael Shalayeff @@ -35,7 +35,7 @@ #include "efiboot.h" #include "efidev.h" -const char version[] = "0.8"; +const char version[] = "0.9"; int debug = 0; struct fs_ops file_system[] = { diff --git a/sys/arch/armv7/stand/efiboot/efiboot.c b/sys/arch/armv7/stand/efiboot/efiboot.c index 621c78a0a62..d3209715da4 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.17 2017/07/31 14:05:57 kettenis Exp $ */ +/* $OpenBSD: efiboot.c,v 1.18 2017/08/07 19:34:53 kettenis Exp $ */ /* * Copyright (c) 2015 YASUOKA Masahiko @@ -374,7 +374,7 @@ _rtt(void) efi_cons_getc(0); #endif /* - * XXX ResetSystem doesn't seem to work on U-Boot 2016.05 on + * XXX ResetSystem doesn't seem to work on U-Boot 2017.03 on * the CuBox-i. So trigger an unimplemented instruction trap * instead. */ @@ -383,7 +383,8 @@ _rtt(void) #else RS->ResetSystem(EfiResetCold, EFI_SUCCESS, 0, NULL); #endif - while (1) { } + for (;;) + continue; } /* @@ -541,3 +542,32 @@ devopen(struct open_file *f, const char *fname, char **file) return (*dp->dv_open)(f, unit, part); } + +/* + * Commands + */ + +int Xexit_efi(void); +int Xpoweroff_efi(void); + +const struct cmd_table cmd_machine[] = { + { "exit", CMDT_CMD, Xexit_efi }, + { "poweroff", CMDT_CMD, Xpoweroff_efi }, + { NULL, 0 } +}; + +int +Xexit_efi(void) +{ + EFI_CALL(BS->Exit, IH, 0, 0, NULL); + for (;;) + continue; + return (0); +} + +int +Xpoweroff_efi(void) +{ + EFI_CALL(RS->ResetSystem, EfiResetShutdown, EFI_SUCCESS, 0, NULL); + return (0); +} diff --git a/sys/arch/armv7/stand/efiboot/libsa.h b/sys/arch/armv7/stand/efiboot/libsa.h index 14be675f708..1f0c7b0ec2b 100644 --- a/sys/arch/armv7/stand/efiboot/libsa.h +++ b/sys/arch/armv7/stand/efiboot/libsa.h @@ -1,4 +1,4 @@ -/* $OpenBSD: libsa.h,v 1.2 2016/05/17 23:16:10 kettenis Exp $ */ +/* $OpenBSD: libsa.h,v 1.3 2017/08/07 19:34:53 kettenis Exp $ */ /* * Copyright (c) 2008 Mark Kettenis @@ -28,3 +28,5 @@ void machdep(void); void devboot(dev_t, char *); + +#define MACHINE_CMD cmd_machine -- cgit v1.2.3