From owner-freebsd-ppc@FreeBSD.ORG Wed Mar 7 05:49:43 2012 Return-Path: Delivered-To: freebsd-ppc@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EF8C3106564A for ; Wed, 7 Mar 2012 05:49:42 +0000 (UTC) (envelope-from robballantyne3@gmail.com) Received: from mail-wi0-f182.google.com (mail-wi0-f182.google.com [209.85.212.182]) by mx1.freebsd.org (Postfix) with ESMTP id 811628FC0C for ; Wed, 7 Mar 2012 05:49:42 +0000 (UTC) Received: by wibhn6 with SMTP id hn6so4112929wib.13 for ; Tue, 06 Mar 2012 21:49:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=2WCJgcfLNgQvF/jEcFzeD0mUw0WYKHoSYhGZkdeiO6A=; b=f2kBjGqHxPJlvOLZnt3CvvUujO7GaReaGgGA75aWg4NKYruO4IAEiC6OIbfg3C48Sg hZKl678nu8R1Ho2C4Q99CUtiS3EJ2lPeg8bzW/ao/TRahu7QUJ4FzWnZOqyQM9pVUdhe mm/gQJEF6IoJdi9ngqIcIAvlojKAC80V+7xQ194hawmePj0msQCRAas7W4sCE7itvyiH A4uHFupRTPTw4iNe3o39H9gEY/tnxuwV5dKQd32AmeDj/fqXFQCOMwBTW6Zffr2qes9p cpyYDoU6INtPMdPjJMNl4jKpaPumq54nQWWQi1nspvrW+0OtLpC34yBuVP8W4GbaZGEv SOgw== MIME-Version: 1.0 Received: by 10.216.136.145 with SMTP id w17mr280808wei.98.1331099381635; Tue, 06 Mar 2012 21:49:41 -0800 (PST) Received: by 10.223.120.82 with HTTP; Tue, 6 Mar 2012 21:49:41 -0800 (PST) In-Reply-To: <20120306075045.5be555b9@zeta.dino.sk> References: <20120306075045.5be555b9@zeta.dino.sk> Date: Tue, 6 Mar 2012 21:49:41 -0800 Message-ID: From: Rob Ballantyne To: Milan Obuch , jeremyhu@freedesktop.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: freebsd-ppc@freebsd.org Subject: Re: Question about bootup X-BeenThere: freebsd-ppc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the PowerPC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Mar 2012 05:49:43 -0000 Thank you Milan and Jeremy, That helped a lot. I looked at the code for bsdinstall that sets up the bootable disk and it appears to use GEOM/gpart to partition the disk. The manpage for gpart indicates it understands the Apple Partition system (APM). It appears that an HFS image file is manipulated during the kernel build process in the following section of a Makefile (/usr/src/sys/boot/powerpc/boot1.chrp) boot1.hfs: boot1.elf bootinfo.txt echo ${.OBJDIR} uudecode ${.CURDIR}/hfs.tmpl.bz2.uu mv hfs.tmpl.bz2 ${.TARGET}.bz2 bzip2 -f -d ${.TARGET}.bz2 dd if=3Dboot1.elf of=3D${.TARGET} seek=3D${BOOT1_OFFSET} conv=3Dnotrunc dd if=3D${.CURDIR}/bootinfo.txt of=3D${.TARGET} seek=3D${BOOTINFO_OFFSET} = \ conv=3Dnotrunc It appears you may be able to substitute your own boot.elf/bootinfo.txt files at this stage (although it appears since the file content is being 'poked' into an existing hfs image this might be a bit sensitive to changes). Cheers, Rob On Mon, Mar 5, 2012 at 10:50 PM, Milan Obuch wrote: > On Mon, 5 Mar 2012 22:24:36 -0800 > Rob Ballantyne wrote: > >> Hi All, >> >> =A0 I've been poking around trying to understand the boot up process of >> a ppc64 G5 machine. >> > > Hi, > > I think it is basically the same for G4 too :) > >> =A0 I was slightly surprised to still find an Apple Partition map disk. >> I would have thought it was an ordinary fdisk (PC) partition setup. >> > > This is most probably OpenFirmware (or implementation on machine in > question) dependency - at least on Apple's boxes ability to load kernel > from UFS filesystem in some newer version was removed. > >> =A0 Let me see if I have it right: >> >> 1 - OpenFirmware (OFW) load Apple_Bootstrap/boot1.elf > > Actually, there is Apple_Bootstrap/bootinfo.txt, a Forth wrapper script > which is loaded first and it loads boot1.elf. > >> 2 - boot1.elf runs to gain enough to understand >> UFS filesystems and loads FreeBSD UFS partition /boot/loader >> 3 - loader loads /boot/kernel/kernel >> >> ... and we're off to the races. >> >> =A0 This strikes me as fairly simplistic so I'm sure there are more >> details. =A0I'm curious about /boot/*.4th OpenFirmware forth code, for >> example. =A0Is it involved in a substantial way? >> > > I did not investigate here much, but as soon as /boot/kernel/loader is > called, it should work 'the usual way' as on any other platform, i. > e. /boot/*.4th files are used accordingly. Just a nit-pick, they have > no relation to OpenFirmware, all they have in common is they are > written in the same language. At least that's the way I understand it. > >> =A0 The other thing I'm curious about is the Apple_Bootstrap partition. >> How is it written? =A0I've discovered parteditor within the bsdinstall >> installer. =A0I suspect that does it but it doesn't appear to let one >> write their own bootloader code =A0image. >> > > It is small partition in Apple's HFS format or whatever the acronym is > because it is the only format Apple's OpenFirmware understands now. > Basically, there are two files in it - bootinfo.txt and boot1.elf, in a > ppc directory. Both are already mentioned above. > >> =A0 As I said mostly curiosity and trying to understand. =A0If anyone ha= s >> a few words of confirmation/advice I would be glad to hear them. >> > > Well, I am not an expert, I am interested in this area too, trying to > understand, and be able to modify the boot process too. But as there > are some differences with what I already know, sometimes it is not > easy :) > > Regards, > Milan