From: Drew Eckhardt (drew@cs.colorado.edu)
Date: 03/06/92


From: drew@cs.colorado.edu (Drew Eckhardt)
Subject: Reboot patch
Date: Fri, 6 Mar 1992 08:25:11 GMT

I finally got fed up enough with the reboot code in Linux since day one,
which would never work on my system. Now, in real mode, or v8086 mode,
a far jump to ffff:0 always worked right, irregardless of A20 or whatever
else was going on, and on every compatable in the world.

This business with the PPI chip, A20, and reset never seemed to work. So, I
switched to the real mode method. What my patch does is disable paging,
kick it back into real mode, and do a far jump to ffff:0.

How it works :

When we switch to real mode, eip may be truncated. So, _reboot is within
the first 64K (head.s). reboot in keyboard.S jumps there, while still
in protected mode. In _reboot,I turn off paging, and protection with a mov to
 CR0, and then now in realmode, I jump to ffff:0 with a real mode far jump.
That's it.

Here are the cdiffs :

*** head.s Fri Jan 10 21:50:17 1992
--- head.s+ Fri Mar 6 01:09:04 1992
***************
*** 142,147 ****
--- 142,155 ----
  L6:
        jmp L6 # main should never return here, but
                                # just in case, we know what happens.
+ .globl _reboot
+ _reboot:
+ cli # we don't have a real mode IDT at 0x00000000
+ movl %cr0, %eax # get cr0, so we can disable paging and protection
+ andl $7ffffffe, %eax # disable paging and protection
+ movl %eax, %cr0
+ .byte 0xea # real mode far jump
+ .word 0x0000, 0xffff # to reboot address
  
  /* This is the default interrupt "handler" :-) */
  int_msg:

*** keyboard.S Fri Mar 6 00:44:03 1992
--- keyboard.S+ Fri Mar 6 00:43:50 1992
***************
*** 659,664 ****
  reboot:
        call kb_wait
        movw $0x1234,0x472 /* don't do memory check */
! movb $0xfc,%al /* pulse reset and A20 low */
! outb %al,$0x64
! die: jmp die
--- 659,663 ----
  reboot:
        call kb_wait
        movw $0x1234,0x472 /* don't do memory check */
! jmp _reboot
!