Skip to contentSkip to conversation

porting arcboot

DISCUSSION Andrew Clausen 5 participants 14 messages Feb 10, 2003 – Feb 13, 2003 MIPS

lore
Share & tools
lore
#0 lore raw

Hi all,

I'm planning to try porting arcboot to ip27 (mips64).

I plan to do this by cross-compiling... this is actually the only option since there's no 64 bit userland yet.

Some issues:

* I'll be cross-compiling (using the mips64-linux-gcc & friends that
are provided on ftp.linux-mips.org), which means some makefile hacking...

* there's no mips64-linux glibc, which means no libc headers are
available. So I need to either cut&paste libc headers, or remove dependencies on them. This affects lots of code.

* the e2fs stuff... how is this being maintained? It uses libc
headers a bit... can I kill them? Or will this make it hard to update to new upstream e2fsprogs releases?

Anything else?

Cheers,
ANdrew

#1 lore raw

Hi,

Quoted 2 lines · Andrew Clausen

* I'll be cross-compiling (using the mips64-linux-gcc & friends that
are provided on ftp.linux-mips.org), which means some makefile hacking...

There hopefully shouldn't be any trouble with that outside of e2fslib.

Quoted 3 lines

* the e2fs stuff... how is this being maintained? It uses libc
headers a bit... can I kill them? Or will this make it hard to update to new upstream e2fsprogs releases?

E2fslib will move out of arcboot with the next release and arcboot will link against the non pic version in the debian archive. I'd really like to keep e2fslib out of arcboot (at least for the debian version which is quiet different from the oss.sgi.com version). There should't be many libc header dependencies left then. If there are still any I'd be happy to kill them.

Quoted 1 line

Anything else?

Except for the above change I was working on a better command line handling among other things which I never got around to finish. Maybe this beats me to it.
Regards,
-- Guido

#10 lore raw
In reply to Andrew Clausen
Quoted 1 line

I'm planning to try porting arcboot to ip27 (mips64).

I'm actually doing the same for ip32 (SGI O2). I've added support for 64-bit ELF while sticking to 32-bit arcboot to avoid the issues you mention with 64-bit userland. The code is still a bit ugly and I've hardcoded a different load address for the O2 (this should be a 'configure' option at least), but you might be interested to have a look. The same trick used for the kernel could probably be used to relocate the 32-bit arcboot to 64-bit address space using objcopy, for the ip27 PROM which only supports 64-bit ELF (according to Ralf).

An early patch is there:
http://www.linux-mips.org/~glaurung/arcboot-0.3.5-o2.diff

The idea is to load segments with the KSEG0 version of the physical address, which can be done with 32-bit code (but limits kernel load address to <512Mb). We then jump to the 64-bit entry point with a small bit of mips4 assembly.

Comments welcome.

Vivien.

#11 lore raw
Quoted 3 lines · Vivien Chappelier

mention with 64-bit userland. The code is still a bit ugly and I've hardcoded a different load address for the O2 (this should be a 'configure' option at least), but you might be interested to have a look.

Can't we read the load address (and needed space) from the elf header before InitMalloc? Would be much nicer and we don't need a different loader for every subarch.
-- Guido

#12 lore raw
Quoted 1 line · Guido Guenther

Can't we read the load address (and needed space) from the elf header

s/load address/kernel's load address/

Quoted 2 lines

before InitMalloc? Would be much nicer and we don't need a different loader for every subarch.

In case we find a unique place for arcboot in the memory map of the different subarches.
Regards,
-- Guido

#2 lore raw
In reply to Guido Guenther
Quoted 4 lines · Guido Guenther

E2fslib will move out of arcboot with the next release and arcboot will link against the non pic version in the debian archive. I'd really like to keep e2fslib out of arcboot (at least for the debian version which is quiet different from the oss.sgi.com version).

Ah, ok. Now we're just stuck with the problem that we can't build e2fsprogs for misp64, since we don't have the toolchain for it.

e2fsprogs looks like it resists cross-compiling also :(

So, the obstacles are:
* e2fsprogs uses libc headers quite extensively, but there is no
glibc available for mips64 (right?). It also seems to make quite a few libc calls? (How are you planning to deal with that? Link against it statically? What about syscalls?)
* e2fsprogs doesn't use autoconf/automake "properly". It doesn't seem
to support cross-compiling. Adding cross-compile support looks somewhat non-trivial, since it builds it's own tools to compile itself. (A fancy sed replacement, for some reason?)
* there is no toolchain to build e2fsprogs on mips64 cleanly... need
to do that objcopy business. This means hacking the build process?

Quoted 3 lines

There should't be many
libc header dependencies left then. If there are still any I'd be happy to kill them.

:)

Cheers,
Andrew

#3 lore raw
Quoted 4 lines · Andrew Clausen

* e2fsprogs uses libc headers quite extensively, but there is no
glibc available for mips64 (right?). It also seems to make quite a few libc calls? (How are you planning to deal with that? Link against it statically? What about syscalls?)

e2fsprogs doesn't call glibc (in fact in can't since we don't link arcboot against non PIC glibc). It calls arclib.
-- Guido

#13 lore raw
In reply to Andrew Clausen
Quoted 14 lines · Andrew Clausen

I'm planning to try porting arcboot to ip27 (mips64).

I plan to do this by cross-compiling... this is actually the only option since there's no 64 bit userland yet.

Some issues:

* I'll be cross-compiling (using the mips64-linux-gcc & friends that
are provided on ftp.linux-mips.org), which means some makefile hacking...

* there's no mips64-linux glibc, which means no libc headers are
available. So I need to either cut&paste libc headers, or remove dependencies on them. This affects lots of code.

Quoted 5 lines

* the e2fs stuff... how is this being maintained? It uses libc
headers a bit... can I kill them? Or will this make it hard to update to new upstream e2fsprogs releases?

Anything else?

Arcboot is a standalone program. As such it shouldn't use anything from glibc or it's going to be a royal pain in the lower back extension. Look at Milo, spit and say no. So keeping a private copy of the necessary headers is the only sane way to get things to work.

Ralf

#4 lore raw
In reply to Andrew Clausen
Quoted 14 lines · Andrew Clausen

e2fsprogs looks like it resists cross-compiling also :(

So, the obstacles are:
* e2fsprogs uses libc headers quite extensively, but there is no
glibc available for mips64 (right?). It also seems to make quite a few libc calls? (How are you planning to deal with that? Link against it statically? What about syscalls?)
* e2fsprogs doesn't use autoconf/automake "properly". It doesn't seem
to support cross-compiling. Adding cross-compile support looks somewhat non-trivial, since it builds it's own tools to compile itself. (A fancy sed replacement, for some reason?)
* there is no toolchain to build e2fsprogs on mips64 cleanly... need
to do that objcopy business. This means hacking the build process?

You dont need e2fsprogs - Just certain parts of the libe2fs which itself just uses some very basic libc functions like malloc/free/str* which we all have within arcboot. So you simple need to cross-compile the libe2fs.

Flo

Signature · 2 lines
Florian Lohoff                  [email protected]             +49-5201-669912
                        Heisenberg may have been here.
#5 lore raw
Quoted 1 line · Florian Lohoff

You dont need e2fsprogs

Right, just they seem so coupled...

Quoted 3 lines

- Just certain parts of the libe2fs which itself
just uses some very basic libc functions like malloc/free/str* which we all have within arcboot.

I disagree.

libe2fs includes lots of headers:

	pureza:~/e2fsprogs-1.32/lib$ find . | grep '\.[ch]$' | xargs grep -h "#include <" | sort | uniq | wc -l
	     77

Also, running nm gives libc calls that invoke syscalls galore. For example:

open64, close, ioctl, opendir, fprintf, getmntent, lseek64, time

I got these names from:

	pureza:~/e2fsprogs-1.32/lib$ nm libext2fs.a | grep '^ *U' | less

Am I missing something?

Quoted 1 line

So you simple need to cross-compile the libe2fs.

That seems *hard*.

Cheers,
Andrew

#6 lore raw
Quoted 4 lines · Andrew Clausen

Also, running nm gives libc calls that invoke syscalls galore. For example:

open64, close, ioctl, opendir, fprintf, getmntent, lseek64, time

But we don't use all of e2fslib! The functions needed to get the kernel from an e2fs only use a very small subset of these and are contained in arclib.
-- Guido

#7 lore raw
In reply to Andrew Clausen
Quoted 19 lines · Andrew Clausen
Quoted 1 line · Florian Lohoff

You dont need e2fsprogs

Right, just they seem so coupled...

Quoted 3 lines

- Just certain parts of the libe2fs which itself
just uses some very basic libc functions like malloc/free/str* which we all have within arcboot.

I disagree.

libe2fs includes lots of headers:

	pureza:~/e2fsprogs-1.32/lib$ find . | grep '\.[ch]$' | xargs grep -h "#include <" | sort | uniq | wc -l
	     77

Also, running nm gives libc calls that invoke syscalls galore. For example:

Quoted 7 lines

open64, close, ioctl, opendir, fprintf, getmntent, lseek64, time

I got these names from:

	pureza:~/e2fsprogs-1.32/lib$ nm libext2fs.a | grep '^ *U' | less

Am I missing something?

Yes - That you dont need all those objects in that archive.

Flo

Signature · 2 lines
Florian Lohoff                  [email protected]             +49-5201-669912
                        Heisenberg may have been here.
#8 lore raw
Quoted 3 lines · Florian Lohoff
Quoted 1 line

Am I missing something?

Yes - That you dont need all those objects in that archive.

But how does that help? It's painful to merely build the set of objects we need. (That would involve e2fsprogs makefile hacking... i.e. not just reusing it out-of-the-box) But it's absolutely necessary, because it's impossible to build all the other objects for mips64 today.

So, are you doing the Makefile hacking, or what?

Cheers,
Andrew

#9 lore raw
Quoted 12 lines · Andrew Clausen
Quoted 3 lines · Florian Lohoff
Quoted 1 line

Am I missing something?

Yes - That you dont need all those objects in that archive.

But how does that help? It's painful to merely build the set of objects we need. (That would involve e2fsprogs makefile hacking... i.e. not just reusing it out-of-the-box) But it's absolutely necessary, because it's impossible to build all the other objects for mips64 today.

So, are you doing the Makefile hacking, or what?

I havent got any mips64 equipment yet and even less time. I guess until we have a real mips64-glibc we will need to put the kernel into the volume-header.

Flo

Signature · 2 lines
Florian Lohoff                  [email protected]             +49-5201-669912
                        Heisenberg may have been here.