Date: Sat, 28 Dec 1996 03:24:45 -0500 (EST) From: Bill Paul <wpaul@skynet.ctr.columbia.edu> To: msmith@atrad.adelaide.edu.au (Michael Smith) Cc: julian@whistle.com, hans@brandinnovators.com, hackers@freebsd.org Subject: Re: bootloader & memory test... Message-ID: <199612280824.DAA24129@skynet.ctr.columbia.edu> In-Reply-To: <199612280536.QAA00707@genesis.atrad.adelaide.edu.au> from "Michael Smith" at Dec 28, 96 04:06:42 pm
next in thread | previous in thread | raw e-mail | index | archive | help
Of all the gin joints in all the towns in all the world, Michael Smith had to walk into mine and say: > Julian Elischer stands accused of saying: > > I was thinking more in line of cloning that code as a starting point > > fpr a stand-alone memory tester.. > > dd it to to a floppy and reboot for a test..:) > > That's what it does already. I've rewritten it almost completely with > the goal of getting it into the bootloader, but the best I can do is > too big : > > lovely:~/work/sys/i386/boot/biosboot>size mtest.o > text data bss dec hex > 1040 32 84 1156 484 > > By stripping some options it can go a little smaller, but I'm still > about 200 bytes short. > > Any idea how easy it is to make a kernel-substitute; something else one > can boot? I while back I rigged up a standalone version of the bootloader which you could load instead of the kernel. Normally the kernel is loaded at address 0x00100000 in memory; I created a startup routine that would copy the boot block down from that location back to 0x00010000 (where the boot code usually executes) and then transfer control to itself at the lower address. It took me several weeks and a couple of books before I was able to wrap my brain around the concepts of global descriptor tables and real mode vs. protected mode memory model, and even then I wasn't entirely sure what the hell I was doing (debugging a standalone image ain't easy, y'know). I pulled a couple of disgusting tricks to make it work, like frobbing the start address in the a.out header of the image so that our boot loader would read it into the correct memory location (the image was actually linked at address 0; loading it at address 0 wouldn't hav worked )and rebuilding the GDT from scratch since I ended up wiping out the old GDT by overwritting the old boot code with my image. Also, I linked my image as an OMAGIC executable, which wouldn't load correctly at first because our boot loader assumes that the image it loads will always be a ZMAGIC executable. There are a couple of things you can look for: - If you hunt around for the most recent release of Mach on the net, you'll find that it includes a network boot loader that's meant to be linked as a standalone image. (It was the earlier version of this code that gave rise to our existing boot loader.) The only problem is that the Mach assembler is apparently not quite the same as ours, so even though you may get the code to compile and link on FreeBSD, it won't execute unless you tweak some stuff. - OpenBSD has (if you look hard enough) a libsa for the 386 architecture. There were some commit messages in the openbsd-commit archibe about it, which prompted me to grab a copy. It was committed to a seperate branch though, and the commit message was lost when freefall lunched one of its disks recently. I forget was the branch tag was. Basically what they did was split up the BIOS code into seperate machine dependent bits and combined it with the machine independent bits to generate a complete library. I happen to like the libsa idea since their code has support for UFS, NFS, RARP, BOOTP, bootparams, and a bunch of other things. Unfortunately, while I was able to get it to compile and load, I never did get it to boot the FreeBSD kernel (I could read it into memory, but their code doesn't have the bootinfo stuff that we do, and I lost interest when I couldn't figure out how to fake my own bootinfo struct and pass it to the kernel correctly.) -Bill -- ============================================================================= -Bill Paul (212) 854-6020 | System Manager, Master of Unix-Fu Work: wpaul@ctr.columbia.edu | Center for Telecommunications Research Home: wpaul@skynet.ctr.columbia.edu | Columbia University, New York City ============================================================================= "It is not I who am crazy; it is I who am mad!" - Ren Hoek, "Space Madness" =============================================================================
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199612280824.DAA24129>