From owner-freebsd-hackers@FreeBSD.ORG Sun Jan 11 05:52:41 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 0AF4A16A4CE for ; Sun, 11 Jan 2004 05:52:41 -0800 (PST) Received: from as6-1-5.kr.m.bonet.se (as6-1-5.kr.m.bonet.se [217.215.84.52]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0FFCC43D45 for ; Sun, 11 Jan 2004 05:52:39 -0800 (PST) (envelope-from martin@gneto.com) Received: from gneto.com (euklides.gneto.com [192.168.10.11]) by as6-1-5.kr.m.bonet.se (Postfix) with ESMTP id 5B89C743AC for ; Sun, 11 Jan 2004 14:52:37 +0100 (CET) Message-ID: <4001552B.5060108@gneto.com> Date: Sun, 11 Jan 2004 14:52:43 +0100 From: Martin Nilsson User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.6b) Gecko/20031212 Thunderbird/0.4 X-Accept-Language: en-us, en MIME-Version: 1.0 To: freebsd-hackers@freebsd.org Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Subject: Assembler coding help needed. X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 11 Jan 2004 13:52:41 -0000 I'm trying to find out why I can't boot 5.2 from USB CDROM on Supermicro motherboards. (I have an old Gateway P3 that can!). I've found out that that only 0x20 of 0x4c sectors of the loader are read in and it therfor traps when executed. (read is only called once). My last attempt at programming x86 assembler was ~15years ago so I'm a bit rusty :-) The below loop from cdboot.s is what I'm having problem understanding, how can this fail on one box but not on another? # # Load the binary into the buffer. Due to real mode addressing limitations # we have to read it in in 64k chunks. # mov DIR_SIZE(%bx),%eax # Read file length add $SECTOR_SIZE-1,%eax # Convert length to sectors shr $11,%eax %eax is 0x4c here on both machines! cmp $BUFFER_LEN,%eax jbe load_sizeok mov $msg_load2big,%si # Error message call error load_sizeok: movzbw %al,%cx # Num sectors to read mov DIR_EXTENT(%bx),%eax # Load extent xor %edx,%edx mov DIR_EA_LEN(%bx),%dl add %edx,%eax # Skip extended mov $MEM_READ_BUFFER,%ebx # Read into the buffer load_loop: mov %cl,%dh cmp $MAX_READ_SEC,%cl # Truncate to max read size jbe load_notrunc mov $MAX_READ_SEC,%dh load_notrunc: sub %dh,%cl # Update count push %eax # Save call read # Read it in pop %eax # Restore add $MAX_READ_SEC,%eax # Update LBA add $MAX_READ,%ebx # Update dest addr jcxz load_done # Done? jmp load_loop # Keep going load_done: