Using newlib (was: [Efi332] Building newlib/libgloss for MPC555)

David Eicher sailors3
Wed Aug 17 03:32:59 UTC 2005


Hi Gunter,

Thanks for the insight here.

I've discovered so far that _reent is defined in reent.h in:

Newlib/libc/include/sys/ directory.

I agree with you wholeheartedly, I need to figure out how to initialize
stdout and stdin. I am getting the feeling that is my problem as I dig into
this further.

New info: it appears a function called _sinit(  ) must run to initialize all
stuff for stdio, including stdout stdin, and stderr. CHECK_INIT( ) is a
macro that calls _sinit( ). Printf calls:

_REENT_SMALL_CHECK_INIT (_stdout_r (ptr));

Rather than calling CHECK_INIT, it appears this call is failing somehow. My
next task is to single step through this code and see if I can figure out
why, and more importantly, what to do about it.

More later,

Thanks,

Dave


-----Original Message-----
From: efi332-bounces at diy-efi.org [mailto:efi332-bounces at diy-efi.org] On
Behalf Of Gunter Magin
Sent: Tuesday, August 16, 2005 11:48 AM
To: efi332 at diy-efi.org
Subject: Re: Using newlib (was: [Efi332] Building newlib/libgloss for
MPC555)

Hi David,

(have been out all day...)

On Mon, Aug 15, 2005 at 08:13:59PM -0700, David Eicher wrote:
> Making some progress. I've discovered that the __sfvwrite ( ) function
> accepts as input two parameters (fp and uio) as shown in this code
snippet.
> 
> _DEFUN(__sfvwrite, (fp, uio),
>        register FILE *fp _AND
>        register struct __suio *uio)
> 
> It appears in the code that one of the parameters is passed to the
function
> in register r3, which gets copied to r27. I put a breakpoint at the
> beginning of __sfvwrite (which is in file fvwrite.c) and discovered that
r3
> is 0xFFFFFFFF at the beginning of execution. 

It is fp which has the wrong value.

Did you initialize in any way stdin/stdout? 

No, I don't know precisely how to do that, but plain printf() expands
the call to vfprintf (_stdout_r (_REENT), fmt, ap);

So it has to do with _stdout_r, which actually is a macro defined in
newlib-1.13.0/newlib/libc/include/stdio.h

It uses a parameter _REENT, but I haven't found out where this is
defined, and where and how it is initialized. I strongly guess this is
the key for getting further.

It can be as easy, as the implicit fopen() call for stdout is missing,
but it also can be more. I have to bail out here.

> So..., that is more background on why __sfvwrite is crashing. I have not
> been able to tell which parameter is passed in r3 yet (working on it). 

See above. Parameter passing is part of the PowerPC-EABI specification.
I think I have that in form of a .pdf from some IBM website, I forgot. But
it is not essential at this point.

gm
_______________________________________________
Efi332 mailing list
Efi332 at diy-efi.org
http://lists.diy-efi.org/mailman/listinfo/efi332





More information about the Efi332 mailing list