From owner-freebsd-ia64@FreeBSD.ORG Fri Jul 16 15:22:43 2004 Return-Path: Delivered-To: freebsd-ia64@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CBE7D16A4CE for ; Fri, 16 Jul 2004 15:22:43 +0000 (GMT) Received: from door.intbel.ru (boos.intbel.ru [62.76.203.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0D63243D1D for ; Fri, 16 Jul 2004 15:22:43 +0000 (GMT) (envelope-from breath@unix.net) Received: from [62.76.203.4] by door.intbel.ru (NTMail 7.00.0018/FR8724.21.ec44b0ca) with ESMTP id ezneuaaa for freebsd-ia64@freebsd.org; Fri, 16 Jul 2004 00:36:56 +0400 To: freebsd-ia64@freebsd.org Message-ID: From: breath Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Date: Fri, 16 Jul 2004 00:33:11 +0400 User-Agent: Opera M2/7.50 (FreeBSD, build 673) Subject: Reboots after "OR AL,1 MOV CR0, EAX" on some computers. X-BeenThere: freebsd-ia64@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Porting FreeBSD to the IA-64 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Jul 2004 15:22:44 -0000 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