How do I do a COLD Reboot on FreeBSD?

Billy Newsom smartweb at
Wed Feb 2 00:47:17 PST 2005

Bob Hall wrote:
> This may help.
> Bob Hall

Hmmm.  Good link.  Here's a better one that I just discovered reading about 
this stuff:

I began to notice that the 0x472 code is rampant in these reboot assembler 
code examples.  Then I found out that FreeBSD has its own asembly language 
found in the boot loaders, etc.

OpenBSD and others like Linux use this stuff similarly.  Linux seems to give 
you the option in a config file!! to cold reboot.

So this led me to:

Which looks to me the place where a warm boot is guaranteed.  By the way, the 
guy above (Adrian Steinmann) might have cleaned up the code for the btx
(usr/src/sys/boot/i386/btx/btx/btx.S) in 2003.  But his code cleanup never 
stayed in /usr/src/sys/boot/i386/boot2/boot1.S.

Example from FreeBSD-5-stable:
/usr/src/sys/boot/i386/btx/btx/btx.S has this:
                 movw $0x1234, BDA_BOOT          # Do a warm boot
                 ljmp $0xffff,$0x0               # reboot the machine

/usr/src/sys/boot/i386/boot2/boot1.S has the *better* version:
                 movw $0x1234, BDA_BOOT          # Do a warm boot
                 ljmp $0xf000,$0xfff0            # reboot the machine

Anyway, Adrian Steinmann tried to patch the reboot code in btx.s to do some 
sort of bugfix and troubleshooting on his particular machine.  There may have 
been a regresion here since he tried that, but I don't care much about the 
BTX or the boot1 code.  My issue is for now with the reboot done during a 
normal full kernel running.  That is when SMP code is active and the memory 
is being actively used.  I believe the locore.s file is where I need to look, 
because it moves this 0x1234 data into the BDA_BOOT location, which is 0x427 
in memory.

Therefore, I will try to hack the locore.s file and use a zero instead of 
0x1234 to move into memory at the BDA_BOOT location.

here's my unified diff:
--- locore.s        Thu Jul  8 17:35:34 2004
+++ /usr/src/sys/i386/i386/locore.s     Wed Feb  2 01:50:36 2005
@@ -214,7 +214,8 @@
  #else  /* IBM-PC */
  /* Tell the bios to warmboot next time */
-       movw    $0x1234,0x472
+/*     movw    $0x1234,0x472 */
+        movw    $0x0000,0x472       /* Billy: Perform Cold Reboot! */
  #endif /* PC98 */

  /* Set up a real frame in case the double return in newboot is executed. */


The only substantial change is that I hope this make my machine do a cold reboot.


More information about the freebsd-questions mailing list