> Date: Thu, 30 May 2019 18:09:01 +0200
> From: "Peter J. Philipp" <p...@centroid.eu>
> 
> On Sat, May 25, 2019 at 07:58:36PM +0200, Karel Gardas wrote:
> > Could you be also so kind and share information about how do you build
> > OpenBSD for PPC64 and how do you boot whatever you get from the build. I'm
> > especially curious if you build bsd.rd and somehow boot that and how exactly
> > do you invoke Qemu and also what Qemu version exactly do you use for that.
> > 
> > Thanks,
> > Karel
> 
> Hi Karel,
> 
> Last weeks answer wasn't to my own satisfaction, so I'll try again.  Last
> year I spent considerable time and effort to make the bsd kernel compile for
> aim64 arch.  aim64 arch is like macppc arch, and powerpc64 is like powerpc,
> only that some variables are different and the asm has been changed.  ie.
> ppc_mtmsr() asm macro has been changed to ppc_mtmsrd() (doubleword to 
> indicate that 64-bit flag can be set on the MSR register, it's the highest
> bit also called PSL_SF found in /sys/arch/powerpc64/include/psl.h, this I
> also had changed).  Everything was changed around ie. a long in powerpc would
> be a uint32_t in powerpc64 unless the variable size can go higher to 64 bit, 
> in
> that case it would be uint64_t).
> 
> So I get to build a 64-bit kernel whoowee, it's like a little lightbulb that
> goes poof when I apply current to it.  Basically the kernel starts in 
> locore0.S,
> and it branches off into the ofwreal.S asm file, here it stopped last year at
> entry into a C routine.  I had given up there.  Closer examination with qemu
> though this year showed that it can go further into C routines, I'm not sure
> if it was the fact that I compiled with gcc (I tried it out, basically and it
> worked).  I was experimenting a bit with the temporary 64-bit bridge which is 
> a bit one can set to have 32-bit functionality on opcodes like mfsrin.  This
> for a moment got me so far as pmap.c but crashed/panic'ed on data that was
> supposed to be gotten from openfirmware.  The fact that the stdout console
> was not initialized showing me the panic string was another indicator that
> these were awry.
> 
> Last year I also hacked on the bootloader ofwboot to boot 64-bit ELF images.
> This works for the most part and it starts in 32-bit mode and hands off the
> execution to the kernel in 32-bit mode, which then does the following opcodes
> to set 64-bit mode:
> 
>         mfmsr   %r0
>         lis     %r21, 1
>         insrdi  %r0, %r21, 1, 0 /* set PSL_SF */
>         mtmsrd  %r0
>         isync
>         nop
> 
> This I learned from reading the FreeBSD asm and it's not changed much except
> perhaps the register #'s.  Ultimately this is called first, and I don't think
> I'll see an alignment issue either as 64-bit opcodes are 4 bytes just like
> 32-bit opcodes.
> 
> OK if I didn't already say it I'm focusing on bsd kernel not bsd.rd, when the
> day comes when bsd kernel boots but panics on no root filesystem is when I
> am going to work on bsd.rd.  That day is still a long ways off I think as I
> gotta have locore0.S, open firmware routines, and locore.S right.  locore.S
> still nees a lot of work and I'm not even there yet because I'm approaching
> the bootstrapping as it executes, and once I'M past the openfirmware I know
> it will panic or do funky things once the cpu and memory bootstrapping is 
> done.
> 
> Does this better explain where I am at?  There is still a lot to do, and
> I'm not really that proud of what I have accomplished thus far, but I started
> not knowing any asm, not knowing much in general about kernel work, sure I
> poked in ther kernel before but mostly in the networking areas, this is 
> totally
> new territory.  And it's hard.  I still can't turn away/walk away, somehow I
> keep thinking I can make the lightbulb glow.  I'm approaching this different
> though than last year.  Last year I wanted to get something done by christmas.
> This year there is no due date.  I'm curious to see how far I can take it.

Ome thing to keep in mind with hte G5 is that it is a bit strange and
event when running in 32-bit mode it takes traps in 64-bit mode.  And
for some reason the bits in the MSR register aren't where you expect
them to be.  This is what the nop_32_Ns/Ne labels are about in the
powerpc locore..S Those bits are there to fix this up on G5 and are
overwritten with NOP instructions on older 32-bit CPUs.

Reply via email to