*BSD News Article 10429


Return to BSD News archive

Received: by minnie.vk1xwt.ampr.org with NNTP
	id AA100 ; Thu, 28 Jan 93 14:00:16 EST
Path: sserve!manuel.anu.edu.au!munnari.oz.au!sgiblab!spool.mu.edu!yale.edu!yale!mintaka.lcs.mit.edu!ai-lab!hal.gnu.ai.mit.edu!mycroft
From: mycroft@hal.gnu.ai.mit.edu (Charles Hannum)
Newsgroups: comp.unix.bsd
Subject: [386BSD] Rebooting woes
Date: 27 Jan 1993 11:25:44 GMT
Organization: MIT Artificial Intelligence Lab
Lines: 102
Distribution: world
Message-ID: <1k5rfoINNhpu@life.ai.mit.edu>
NNTP-Posting-Host: hal.ai.mit.edu


I have a HP Vectra 486.  None of the standard kluges will reboot it; they
all just hang the machine.

I decided I wanted to do a portable reboot.  The only way I could think of
involves switching back to real mode and using the BIOS.  This turns out
to not be so easy.

This is the code I've come up with.  It warm boots one machine (presumably
because of the magic sequence at `start:' which was executed already), but
*cold boots* the Vectra.  un-#ifdefing the sequence which should tell it
to warm boot just hangs the machine.  Even more confusing, modifying said
sequence to write a `0' (which should force a cold boot) also causes the
machine to hang.  As of right now, I haven't the foggiest notion why.

Anyway, it at least reboots the machine, so I thought I'd post it, since I
suspect I'm not the only person with this problem.

The following code should go in /sys/i386/i386/locore.s, and the C version
of cpu_reset() should be removed from /sys/i386/i386/vm_machdep.c.


Anyone with insight into why it won't warm boot is more than welcome to
send me mail about it.  I will be looking at it more myself, and will
probably post another version of the code in a few days.


-----8<-----snip-----8<-----snip-----8<-----snip-----8<-----snip-----8<-----
	ALIGN32
ENTRY(cpu_reset)
	/* die */
	cli

	/* use linear addressing */
	/* (relies on GDT set up in bootstrap code) */
	mov	$16,%eax
	mov	%ax,%ds
	mov	%ax,%es

#if 0
	/* force warm boot */
	movw	$1234,%ax
	movw	%ax,0x472
#endif

	/* copy frob & jump code */
	mov	$_Reboot,%esi
	mov	$0x0500,%edi
	mov	$0x040,%ecx		/* 256 bytes */
	cld
	.byte	0xf3,0xa5		/* rep movsd */

	/* set up 16-bit descriptor tables */
	lidt	_Reboot-_RebootIDT+0x500
	lgdt	_Reboot-_RebootGDT+0x500

	/* smash data descriptors */
	mov	$16,%eax
	mov	%ax,%ds
	mov	%ax,%es
	mov	%ax,%fs
	mov	%ax,%gs
	mov	%ax,%ss

	/* jump to code copied from _Reboot */
	ljmp	$8,$0x0500

	ALIGN32
_Reboot:
	smsw	%eax
	andl	$0x7ffffff6,%eax
	lmsw	%eax
	xorl	%eax,%eax
	mov	%eax,%cr3
	/* jmp FFFF:0000 */
	.byte	0xea
	.long	0xffff0000

	ALIGN32
_RebootIDT:
	.word	0x3ff
	.long	0

	ALIGN32
_RebootGDT:
	.word	0x17
	.long	_RebootGDT-SYSTEM+6
/* null descriptor */
	.word 0,0
	.byte 0,0,0,0
/* code descriptor */
	.word -1,0
	.byte 0,0x9f,0,0
/* data descriptor */
	.word -1,0
	.byte 0,0x93,0,0
-----8<-----snip-----8<-----snip-----8<-----snip-----8<-----snip-----8<-----

-- 
 \  /   Charles Hannum, mycroft@ai.mit.edu
 /\ \   PGP public key available on request.  MIME, AMS, NextMail accepted.
Scheme  White heterosexual atheist male (WHAM) pride!