From owner-freebsd-hackers Fri Oct 13 06:47:00 1995 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.6.12/8.6.6) id GAA00779 for hackers-outgoing; Fri, 13 Oct 1995 06:47:00 -0700 Received: from frya.zgik.zaporizhzhe.ua (ZGIK-1-ELIS-14.4K.zgik.zaporizhzhe.ua [193.124.62.253]) by freefall.freebsd.org (8.6.12/8.6.6) with ESMTP id GAA00772 for ; Fri, 13 Oct 1995 06:45:55 -0700 Received: from zgik.UUCP by frya.zgik.zaporizhzhe.ua with UUCP id PAA28098; (8.6.11/vak/1.8e) Fri, 13 Oct 1995 15:39:46 +0200 Received: by relay1.bcs.zaporizhzhe.ua (uumail v1.5/ache) id AA08639; Fri, 13 Oct 1995 15:33:34 +0200 Received: from bcs1.bcs.zaporizhzhe.ua (bcs1.bcs.zaporizhzhe.ua [193.124.62.29]) by bcs.zaporizhzhe.ua (8.6.11/8.6.9) with SMTP id PAA08636; Fri, 13 Oct 1995 15:33:33 +0200 Received: by bcs1.bcs.zaporizhzhe.ua id AA09369 (5.65c8/IDA-1.4.4 for hackers@freebsd.org); Fri, 13 Oct 1995 15:30:30 +0200 From: Sergey Shkonda Message-Id: <199510131330.AA09369@bcs1.bcs.zaporizhzhe.ua> Subject: netboot patch To: martin@innovus.com, hackers@freebsd.org Date: Fri, 13 Oct 1995 15:30:25 +0200 (UKR) X-Mailer: ELM [version 2.4 PL0] Content-Type: text Content-Length: 2814 Sender: owner-hackers@freebsd.org Precedence: bulk There are error in first patch. Need be another function for switching to real mode at exit. -- Sergey Shkonda, serg@bcs1.bcs.zaporizhzhe.ua *** start2.S.OO Fri Oct 13 15:16:52 1995 --- start2.S Fri Oct 13 15:29:48 1995 *************** *** 3,9 **** #define KERN_CODE_SEG 0x08 #define KERN_DATA_SEG 0x10 #define REAL_MODE_SEG 0x18 ! #define REAL_MODE_DATA 0x20 #define CR0_PE 1 #define opsize .byte 0x66 --- 3,10 ---- #define KERN_CODE_SEG 0x08 #define KERN_DATA_SEG 0x10 #define REAL_MODE_SEG 0x18 ! #define REAL_MODE_CODE 0x20 ! #define REAL_MODE_DATA 0x28 #define CR0_PE 1 #define opsize .byte 0x66 *************** *** 89,95 **** call _main .globl _exit _exit: ! call _prot_to_real #ifdef BOOTROM xor %eax,%eax mov %ax,%ds --- 90,96 ---- call _main .globl _exit _exit: ! call _quit_prot #ifdef BOOTROM xor %eax,%eax mov %ax,%ds *************** *** 281,288 **** pop %eax sub $RELOC,%eax /* Adjust return address */ push %eax sub $RELOC,%esp /* Adjust stack pointer */ ! ljmp $REAL_MODE_SEG, $1f-RELOC /* jump to a 16 bit segment */ 1: cli mov $REAL_MODE_DATA, %ax /* load selector in shadow */ --- 282,324 ---- pop %eax sub $RELOC,%eax /* Adjust return address */ push %eax + sub $RELOC,%esp /* Adjust stack pointer */ + ljmp $REAL_MODE_SEG, $1f /* jump to a 16 bit segment */ + 1: + cli + /* clear the PE bit of CR0 */ + mov %cr0, %eax + opsize + andl $0!CR0_PE, %eax + mov %eax, %cr0 + + /* make intersegment jmp to flush the processor pipeline + * and reload CS register + */ + opsize + ljmp $(RELOC)>>4, $2f-RELOC + 2: + /* we are in real mode now + * set up the real mode segment registers : DS, SS, ES + */ + mov %cs, %ax + mov %ax, %ds + mov %ax, %es + mov %ax, %ss + sti + opsize + ret + + /************************************************************************** + QUIT_PROT - Quit from Protected Mode + **************************************************************************/ + .globl _quit_prot + _quit_prot: + pop %eax + sub $RELOC,%eax /* Adjust return address */ + push %eax sub $RELOC,%esp /* Adjust stack pointer */ ! ljmp $REAL_MODE_CODE, $1f-RELOC /* jump to a 16 bit segment */ 1: cli mov $REAL_MODE_DATA, %ax /* load selector in shadow */ *************** *** 330,335 **** --- 366,375 ---- .word 0xffff, 0 .byte 0, 0x93, 0xcf, 0 + /* 16 bit real mode */ + .word 0xffff, 0 + .byte 0, 0x9b, 0x0f, 0 + /* 16 bit real mode code segment */ .word 0xffff, RELOC&0xffff .byte (RELOC)>>16, 0x9b, 0x00, 0 *************** *** 340,344 **** .align 4 gdtarg: ! .word 0x27 /* limit */ .long gdt /* addr */ --- 380,384 ---- .align 4 gdtarg: ! .word 0x2f /* limit */ .long gdt /* addr */