This is a better plan. All the architectures can adapt to this,
even those that have a tricky ROM-related dance.
> On Thu, Oct 26, 2017 at 10:32:42PM +1100, Jonathan Gray wrote:
> > What specifically? Skip if_downall() if rebooting from ddb?
> > That could perhaps even be done for RB_NOSYNC.
>
> I thought of someting like a big hammer. Skip everything except
> the final call in boot() that causes the machine to reset. The
> command is only reachable form ddb and useful if nothing else can
> reboot the machine.
>
> Here is an example implementation for amd64.
>
> bluhm
>
> Index: arch/amd64/amd64/machdep.c
> ===================================================================
> RCS file: /data/mirror/openbsd/cvs/src/sys/arch/amd64/amd64/machdep.c,v
> retrieving revision 1.234
> diff -u -p -r1.234 machdep.c
> --- arch/amd64/amd64/machdep.c 23 Oct 2017 15:41:29 -0000 1.234
> +++ arch/amd64/amd64/machdep.c 26 Oct 2017 11:43:55 -0000
> @@ -713,6 +713,9 @@ struct pcb dumppcb;
> __dead void
> boot(int howto)
> {
> + if ((howto & RB_RESET) != 0)
> + goto reset;
> +
> if ((howto & RB_POWERDOWN) != 0)
> lid_action = 0;
>
> @@ -770,6 +773,7 @@ haltsys:
> printf("rebooting...\n");
> if (cpureset_delay > 0)
> delay(cpureset_delay * 1000);
> +reset:
> cpu_reset();
> for (;;)
> continue;
> Index: sys/reboot.h
> ===================================================================
> RCS file: /data/mirror/openbsd/cvs/src/sys/sys/reboot.h,v
> retrieving revision 1.17
> diff -u -p -r1.17 reboot.h
> --- sys/reboot.h 11 Jul 2014 14:36:44 -0000 1.17
> +++ sys/reboot.h 26 Oct 2017 11:41:56 -0000
> @@ -56,6 +56,7 @@
> #define RB_POWERDOWN 0x1000 /* attempt to power down machine */
> #define RB_SERCONS 0x2000 /* use serial console if available */
> #define RB_USERREQ 0x4000 /* boot() called at user request (e.g.
> ddb) */
> +#define RB_RESET 0x8000 /* do not try to cleanup, only for ddb
> */
>
> /*
> * Constants for converting boot-style device number to type,
>