[comp.os.minix] Protected Mode Entry/Exit

des@dtg.nsc.com (Desmond Young) (03/05/90)

Hi,
  just a few simple (silly) questions.

  How does Minix exit protected mode ?  Does it ever need to ?
	To enter protected mode I believe you execute the appropriate
	instruction. But, how do you exit it ?
	I thought AT's sent an instruction to the keyboard to issue a
	reset, with the program having already stored a flag in the
	CMOS RAM. When re-booting, the program checks the RAM flag, and
	if set appropriately, does not perform a full reset/re-boot.

	Since this can be slow..... (reset time non-trivial), there must
	be a better way. Is this a closely guarded secret at Microsoft?

	The only way I can think of is to cause a multiple MMU fault.
	For example, access a location that is invalid, and has an
	invalid page entry in local and global descriptor tables. The
	286 datasheet does not define what happens in this case. Does
	the chip reset?

	Does Minix ever need to get out of protected mode?

	In case you are wondering why these questions. If you have an
	"XT" machine with a 286 processor, you do not have a keyboard
	to give you a reset, and you do not have a CMOS RAM to store a
	flag. So, the questions are to determine whether you may run
	Minix in protected mode on a 286-based non-AT machine.

Thanks in advance for any advice,
Des.
     des@dtg.nsc.com   or des@gpo.nsc.com
     No opinions - no disclaimer.

evans@ditsyda.oz (Bruce Evans) (03/08/90)

In article <726@blenheim.nsc.com> des@dtg.nsc.com (Desmond Young) writes:
>  How does Minix exit protected mode ?

By resetting or turning off the processor.

>  Does it ever need to ?

Only to reboot.

>[How to reset on ATs using the keyboard controller.]

>	Since this can be slow..... (reset time non-trivial), there must
>	be a better way. Is this a closely guarded secret at Microsoft?

I don't think so (on a 286). On a 386, it is easy. I used it a lot while
developing the Minix protected mode kernel, running users in protected
mode and the system in real mode.

>	The only way I can think of is to cause a multiple MMU fault.

A documented way is to load the interrupt descriptor table with a bad
value, the cause an interrupt. The processor "shuts down". I don't know
if this means that it resets. I must have shut it down many times while
debugging, and it always seemed to reset.

>	In case you are wondering why these questions. If you have an
>	"XT" machine with a 286 processor, you do not have a keyboard
>	to give you a reset, and you do not have a CMOS RAM to store a
>	flag. So, the questions are to determine whether you may run
>	Minix in protected mode on a 286-based non-AT machine.

Do you have such a strange machine, and volunteer to make rebooting work? :-)

In practice the reset button is a good way to reboot.

I have had strange results rebooting an AT in real mode. My debugger
catches an illegal opcode at 0xFFFF:0xFFF0. This is the usual reset
vector, and examination shows the instruction there is the nornal, legal
jump. Jumping to this location (which is what the kernel does if the
keyboard controller doesn't reset) works fine. The debugger doesn't
work in protected mode (on a 286) and the reboot looks normal. Maybe
it causes a pile of exceptions and the processor shuts down? Everything
works as I expect in all modes on a 386.
-- 
Bruce Evans		evans@ditsyda.oz.au