Subject: Re: kloader in current
To: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
From: Valeriy E. Ushakov <uwe@ptc.spbu.ru>
List: port-dreamcast
Date: 03/21/2004 03:04:36
On Sat, Mar 20, 2004 at 18:37:32 +0300, Valeriy E. Ushakov wrote:

> On Sat, Mar 20, 2004 at 01:33:54 +0900, Izumi Tsutsui wrote:
> 
> > > I'd like to hear if kloader in current works/doesn't work for you.  I
> > > remember a short period of time that it worked for me on hpcsh, but
> > > it's been dying with "TLB miss" for more than an year now.
> > 
> > I use kloader on my dreamcast and it still works fine.
> > I also use the attached patch since I thought -fstrict-aliasing
> > optimization introduced on gcc3 might cause problems,
> > but I have not confirmed yet if it really solves the problem.
> 
> I don't think that intermediate (void *) cast should matter (I tried
> it out of desperation, but it didn't help, just as I expected).
> 
> Staring at the kloader_sh3_boot assembler I don't see anything wrong
> with it.  Also, as I have found how to control Jornada LEDs I was able
> to use them to confirm that the kloader_sh3_boot executes up to the
> final jump to the kernel.  The very first instructions of the kernel
> also tweak a LED and enter a long delay loop, but that doesn't happen
> when I try to reboot.  The machine resets to WinCE reporting TLB miss
> exeception (sometimes load, sometimes store).

Oh!  I tracked it down, finnaly, it seems.  Thanks to you reply, as it
pointed out to the dreamcast code.  The difference between hpcsh and
dreamcast is that hpcsh kernel is passed a bootinfo structure by
hpcboot.exe and kloader.

The problem was that when the kernel starts up it copies the bootinfo
just below its text segment.  When kloader tries to boot a new kernel,
it passes the bootinfo pointer to kloader_*_boot code, but that
pointer is from the old incarnation of the kernel.  By the time boot
code snippet gets to jumping to the new image it just copied to the
right addresses, that old bootinfo is already overwritten, so the boot
code snippet jumps into the middle of nowhere.

SY, Uwe
-- 
uwe@ptc.spbu.ru                         |       Zu Grunde kommen
http://www.ptc.spbu.ru/~uwe/            |       Ist zu Grunde gehen