From owner-freebsd-hackers@FreeBSD.ORG Mon Dec 17 15:11:22 2007 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 819FA16A474 for ; Mon, 17 Dec 2007 15:11:22 +0000 (UTC) (envelope-from jdc@parodius.com) Received: from mx01.sc1.parodius.com (mx01.sc1.parodius.com [72.20.106.3]) by mx1.freebsd.org (Postfix) with ESMTP id 7D3BE13C447 for ; Mon, 17 Dec 2007 15:11:22 +0000 (UTC) (envelope-from jdc@parodius.com) Received: by mx01.sc1.parodius.com (Postfix, from userid 1000) id 6125E1CC07B; Mon, 17 Dec 2007 07:11:22 -0800 (PST) Date: Mon, 17 Dec 2007 07:11:22 -0800 From: Jeremy Chadwick To: "M.Girish Rao" Message-ID: <20071217151122.GA29376@eos.sc1.parodius.com> References: <47667D9A.8070300@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <47667D9A.8070300@gmail.com> User-Agent: Mutt/1.5.16 (2007-06-09) Cc: freebsd-hackers@freebsd.org Subject: Re: boot0 code mystery X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 Dec 2007 15:11:22 -0000 On Mon, Dec 17, 2007 at 07:16:02PM +0530, M.Girish Rao wrote: > Whats the memory location of start? I'm going off of memory of my old x86 days, so be kind to me. :-) By the look of it, it's BOOT_BOOT0_ORG, which is 0x600. I'm basing this on the flags passed to cc (actually ld) during linktime. > what's this for incb -0xe(%di) ? No idea. > where are we jumping to in jmp main-LOAD+ORIGIN? main is below the jmp main-LOAD+ORIGIN jump: 91 incb -0xe(%di) # Sector number 92 jmp main-LOAD+ORIGIN # To relocated code 93 94 main: 95 #if defined(SIO) && COMSPEED != 0 LOAD is set to 0x7c00: 27 .set LOAD,0x7c00 # Load address You should be able to get the offset of main by looking at boot0.o once assembled. The start origin doesn't appear to be included (which is why it's added manually). eos# objdump -t boot0.o | grep 'main$' 00000022 l .text 00000000 main Thus I'm left to believe main-LOAD+ORIGIN == 0x8a22. This can be verified by doing: eos# objdump -S -M addr16,data16 boot0.o | grep -m 1 'jmp' 1f: e9 00 8a jmp 8a22 > whats ORIGIN? ORIGIN is an assembler variable set to 0x600: 25 .set ORIGIN,0x600 # Execution address -- | Jeremy Chadwick jdc at parodius.com | | Parodius Networking http://www.parodius.com/ | | UNIX Systems Administrator Mountain View, CA, USA | | Making life hard for others since 1977. PGP: 4BD6C0CB |