From owner-freebsd-hackers@FreeBSD.ORG Fri Jul 16 16:24:24 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1F48D16A4CE for ; Fri, 16 Jul 2004 16:24:24 +0000 (GMT) Received: from beck.quonix.net (beck.quonix.net [146.145.66.90]) by mx1.FreeBSD.org (Postfix) with ESMTP id 86C3143D1F for ; Fri, 16 Jul 2004 16:24:23 +0000 (GMT) (envelope-from john@essenz.com) Received: from localhost (localhost.quonix.net [127.0.0.1]) by beck.quonix.net (8.12.11/8.12.11) with SMTP id i6GGOLPL035921 for ; Fri, 16 Jul 2004 12:24:21 -0400 (EDT) Message-Id: <200407161624.i6GGOLPL035921@beck.quonix.net> To: freebsd-hackers@freebsd.org From: john@essenz.com X-Apparently-from: essenz@beck.quonix.net X-Remote-Host: 192.175.173.154 User-Agent: NikoSoft WebMail References: Date: Fri, 16 Jul 2004 12:24:21 -400 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.39 Subject: Re: Reboots after ''OR AL,1 MOV CR0, EAX'' on some computers. X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: john@essenz.com List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Jul 2004 16:24:24 -0000 Ha... I thought this email was spam, with a subject resembling ORAL MOVIES !! -john ---------------------------------------------------- >From : breath To : freebsd-hackers@freebsd.org Subject : Reboots after "OR AL,1 MOV CR0, EAX" on some computers. Date : Fri, 16 Jul 2004 00:34:46 +0400 > Hi. I need some help. I think you'll be interested. I develop a little OS > that will boot from floppy. It's still under construction and has about > five thousand lines of assembly source now. I use Bochs emulator to debug > it and after that I test it on my real computer. I have all working > correctly on my compter. But I started to test it around other machines > recently and encountered a problem I can't solve. But I'm sure there are > lot of minds in FreeBSD world who know how to help me. I can't figure out > what happens because on my computer I get all things well, but I can't > conduct test of this kind on other computers. > > Here is the problem. My OS's boot loader (after loading the main module) > switches CPU to very limited protected mode and jumps to module's entry > point. After it, main module reloads all tables like GDT etc to make a > good free environment for initialization and further running. Shortly: ON > SOME COMPUTERS (MAYBE CPUS) I GET REBOOTING JUST ON 'JMP' INSTRUCTION > AFTER PE BIT IS ENABLED. I've got no reboots on all i386, i486, i586 > computers that I tryed to boot from. I have a Pentium III Celeron > (Coppermine) 900MHz - no reboots. Also tested on some Pentium II 400MHz - > no reboots. But on other side Pentium IV (don't remember speed) gave me a > reboot. And other computer I was not able to see processor model (maybe > PentiumIV !?) gave me a reboot too. Using endless loop stop points I > figured out that reboot is before any instruction pointed by 'protected' > label and that reboot happens after setting the PE bit. > > Here's very diminished boot sector code that reflects the error. It must > be compiled with nasm as a binary so that result will be a floppy disk > image file. Then it must be written to a floppy from scratch (from boot > sector). Created floppy is expected to be bootable disk. > > Normal: > When you boot from the floppy you get something like black screen and > computer hangs up (but not reboots) > > Abnormal: > When you boot from the floppy you get a screen splash and then back to > reboot POST procedure. > > Here goes the code. PLEASE, even if you're not interested in this > 'puzzle':( MAKE AND TEST IT ON YOUR COMPUTER. EMAIL ME RESULTS AND > COMPUTER MODEL. > > It was HARD work to make this OS. I believe that some people understand me > and will give me a clue. From my side I'll show them the full version. > > ;--------------------------------------------------------------------- > > ; Compile: %nasm thisfile.asm -o fd > ; Insert a floppy > ; Write (as root): #dd if=fd of=/dev/fd0 > > org 0x7C00 ; Expecting to be loaded at 7C00 by BIOS > > bits 16 > > real: > cli > xor ax, ax > mov ss, ax > mov sp, 0x7C00 ; Temp stack just under myself > > call real_open_A20 ; For 32 bit address space > call real_init_gdt ; Load GDTR > > mov eax, cr0 > or al, 0x1 ; cr0 |= PE > mov cr0, eax > ; If I place 'jmp $' here all computers stop here normally > jmp 0x10: protected > > real_open_A20: > .l1: in al, 0x64 > test al, 0x2 > jnz .l1 > mov al, 0xD1 > out 0x64, al > .l2: in al, 0x64 > test al, 0x2 > jnz .l2 > mov al, 0xDF > out 0x60, al > ret > > real_init_gdt: > lgdt [.gdtr] > ret > .gdt0 dw 0x0000, 0x0000, 0x0000, 0x0000 > .data dw 0xFFFF, 0x0000, 0x9200, 0x00CF > .code dw 0xFFFF, 0x0000, 0x9800, 0x00CF > .gdtr dw $ - .gdt0 - 1 > dd .gdt0 > > bits 32 > > protected: > ; Wherever I place 'jmp $' after the 'protected' label, > ; on some computers I get reboot to hell. > ; (In that case CS:IP is never points to 'jmp $' > ; - something happens before) > mov ax, 0x8 > mov ds, ax > mov es, ax > mov fs, ax > mov gs, ax > mov ss, ax > mov esp, 0x7C00 > jmp $ > > times 512 - 2 - ($ - $$) db 0 ; Fill the rest of sector > dw 0xAA55 ; Bootable sector sign > > times 1474560 - ($ - $$) db 0 ; Fill the rest of floppy > > ;--------------------------------------------------------------------- > > Best regards, > Yuri Grebenkin > breath@unix.net > _______________________________________________ > freebsd-hackers@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"