Thread: [Etherboot-developers] NetBSD ELF/a.out support
Brought to you by:
marty_connor,
stefanhajnoczi
|
From: Wojciech P. <wo...@te...> - 2003-02-24 13:09:09
|
anyone working on it?
how can i help?
all i found is that kernel should be loaded beginning from
LMA(VMA)-c0000000 (which is 1MB in all kernels i looked at from version
1.3.3 to 1.6)
Idx Name Size VMA LMA File off Algn
0 .text 0014df54 c0100000 c0100000 00001000 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .rodata 000287a1 c024df60 c024df60 0014ef60 2**5
CONTENTS, ALLOC, LOAD, READONLY, DATA
2 .data 0001acf0 c0277720 c0277720 00177720 2**5
CONTENTS, ALLOC, LOAD, DATA
3 .bss 0003e1fc c0292420 c0292420 00192420 2**5
kernel should be started in flat mode with paging off, given parameters on
stack with C standard:
(howto, [bootdev], bootinfo, esym, basemem, extmem)
howto is (2 if single user)|(1 if ask for boot device)|(4 if start
debugger)
it could be always 0 for etherboot
bootdev should be 0 for new kernels - not used.
esym is used for debugger if kernel symbols are loaded to memory. it's
probably offset from kernel code to beginning of symbols, 0 if no symbols.
bootinfo is a pointer to bootinfo structure. first 4 bytes says how many
elements it has, then there are elements (like boot console info, bios
disk geometry etc.) - all well defined in NetBSD's bootinfo.h
how can i help to support it (my assembly isn't best right now)?
tried using FreeBSD support in etherboot - kernel is loaded fine then
hangs.
NetBSD already has ROM files but for only few cards and needs 32K ROMs,
and
pxeboot.bin that works for any PXE capable cards.
anyway having this in etherboot will give user a flexibility to run any OS
without reprogramming EPROM
|
|
From: Doug A. <amb...@am...> - 2003-02-24 17:26:29
|
Wojciech Puchar writes: | anyone working on it? | | how can i help? One thing I've done to boot NetBSD/OpenBSD/Linux off the same is to use Grub. I had to patch grub for OpenBSD if I recall right. I found patches on the net. So I used Etherboot to boot Grub to then boot the OS of choice. I setup a menu in Grub to select that OS I wanted. Doug A. |
|
From: Wojciech P. <wo...@te...> - 2003-02-24 22:22:02
|
> > Wojciech Puchar writes: > | anyone working on it? > | > | how can i help? > > One thing I've done to boot NetBSD/OpenBSD/Linux off the same is to > use Grub. I had to patch grub for OpenBSD if I recall right. I found > patches on the net. So I used Etherboot to boot Grub to then boot the > OS of choice. I setup a menu in Grub to select that OS I wanted. unfortunately i can't compile nbgrub under NetBSD |
|
From: <ebi...@ln...> - 2003-02-25 06:17:09
|
Wojciech Puchar <wo...@te...> writes: > anyone working on it? > > how can i help? > > all i found is that kernel should be loaded beginning from > LMA(VMA)-c0000000 (which is 1MB in all kernels i looked at from version > 1.3.3 to 1.6) > > Idx Name Size VMA LMA File off Algn > 0 .text 0014df54 c0100000 c0100000 00001000 2**2 > CONTENTS, ALLOC, LOAD, READONLY, CODE > 1 .rodata 000287a1 c024df60 c024df60 0014ef60 2**5 > CONTENTS, ALLOC, LOAD, READONLY, DATA > 2 .data 0001acf0 c0277720 c0277720 00177720 2**5 > CONTENTS, ALLOC, LOAD, DATA > 3 .bss 0003e1fc c0292420 c0292420 00192420 2**5 > > > kernel should be started in flat mode with paging off, given parameters on > stack with C standard: > > (howto, [bootdev], bootinfo, esym, basemem, extmem) > > howto is (2 if single user)|(1 if ask for boot device)|(4 if start > debugger) > > it could be always 0 for etherboot > > bootdev should be 0 for new kernels - not used. > > esym is used for debugger if kernel symbols are loaded to memory. it's > probably offset from kernel code to beginning of symbols, 0 if no symbols. > > bootinfo is a pointer to bootinfo structure. first 4 bytes says how many > elements it has, then there are elements (like boot console info, bios > disk geometry etc.) - all well defined in NetBSD's bootinfo.h > > > how can i help to support it (my assembly isn't best right now)? > > tried using FreeBSD support in etherboot - kernel is loaded fine then > hangs. > > > NetBSD already has ROM files but for only few cards and needs 32K ROMs, > and > pxeboot.bin that works for any PXE capable cards. > > anyway having this in etherboot will give user a flexibility to run any OS > without reprogramming EPROM We have that: There are 2 ways to go. Either small modifications to NetBSD, or write a mkelf-BSD. - Alternative 1 (tweaking BSD). Modify the linker script so the LMA is 0x100000. Once the physical addresses are correct etherboot will load your ELF executable into memory just fine. The ELF loader in 5.1.x with no special options passes a pointer to a structure using the standard C calling conventions. After the header the structure contains an array of tagged records, allowing etherboot or whomever use the format to pass whatever values make sense. The structure has a magic number at the start, and a checksum so you can test to see if you were actually passed the appropriate structure. It is fairly well defined in etherboot's elf_boot.h The memory size information along with the dhcp options is present there. And this same format (with different tagged values is used on multiple architectures). So with a little extra code to parse the etherboot's elf boot structure, and a small tweak to your linker script you can have native support of etherboot. - Alternative 2 (writing a converter). You can write a little stub piece of code that reads etherboot's elf boot structure and converts it into a form that NetBSD can use today. In addition this requires a stub program to glue the converter code and the NetBSD kernel together into one image. Examples are out there for several other formats. See mknbi/mkelf and mkelfImage. I hope this helps, And my apologies for not sending this off earlier I got distracted just before I hit send. Eric |
|
From: Wojciech P. <wo...@te...> - 2003-02-26 09:33:00
|
> - Alternative 2 (writing a converter). > > You can write a little stub piece of code that reads etherboot's > elf boot structure and converts it into a form that NetBSD can > use today. > Alternative 3 mknbi-netbsd? |
|
From: <ebi...@ln...> - 2003-02-26 19:50:29
|
Wojciech Puchar <wo...@te...> writes: > > - Alternative 2 (writing a converter). > > > > You can write a little stub piece of code that reads etherboot's > > elf boot structure and converts it into a form that NetBSD can > > use today. > > > Alternative 3 > > > mknbi-netbsd? Well that was Alternative 2 but perhaps I explained it badly. Eric |
|
From: Wojciech P. <wo...@te...> - 2003-02-27 20:25:23
|
i just managed to boot NetBSD with etherboot's FreeBSD loader. the only problem is a) NetBSD has different boot parameters than FreeBSD. i hardwired REALBASEMEM and REALEXTMEM to kernel so it's able to get memory and runs well, except it doesn't know what was boot device and boot file name (no bootinfo at all) b) I am able to write NetBSD support to etherboot except there's no method of detecting if kernel is NetBSD or FreeBSD (at least i don't know) other than scanning memory for "The NetBSD Foundation, Inc. All rights reserved." which seems quite stupid. |
|
From: Doug A. <amb...@am...> - 2003-02-27 20:59:18
|
Wojciech Puchar writes:
| i just managed to boot NetBSD with etherboot's FreeBSD loader.
|
| the only problem is
|
| a) NetBSD has different boot parameters than FreeBSD. i hardwired
| REALBASEMEM and REALEXTMEM to kernel so it's able to get memory and runs
| well, except it doesn't know what was boot device and boot file name
| (no bootinfo at all)
|
| b) I am able to write NetBSD support to etherboot except there's no method
| of detecting if kernel is NetBSD or FreeBSD (at least i don't know) other
| than scanning memory for "The NetBSD Foundation, Inc. All rights
| reserved." which seems quite stupid.
There seems to be some info in to find a FreeBSD header via:
#ifdef ELFCORE
size_t prpsoffsets32[] = {
8, /* FreeBSD */
28, /* Linux 2.0.36 */
32, /* Linux (I forget which kernel version) */
84, /* SunOS 5.x */
};
and then I see this comment
/*
* Look through the program headers of an executable image, searching
* for a PT_NOTE section of type NT_PRPSINFO, with a name "CORE" or
* "FreeBSD"; if one is found, try looking in various places in its
* contents for a 16-character string containing only printable
* characters - if found, that string should be the name of the program
* that dropped core. Note: right after that 16-character string is,
* at least in SunOS 5.x (and possibly other SVR4-flavored systems) and
* Linux, a longer string (80 characters, in 5.x, probably other
* SVR4-flavored systems, and Linux) containing the start of the
* command line for that program.
So I'd use that type of scheme. It in the common source for "file" from
Christos Zoulas.
I can try out any patches you have and verify it doesn't break FreeBSD
or put a sample FreeBSD kernel on my web-site for you to test.
Doug A.
|
|
From: Wojciech P. <wo...@te...> - 2003-02-28 22:41:49
|
http://www.3miasto.net/~wojtek/etherboot-5.0.8-netbsd.tar.bz2 to be done 0) detection if it's FreeBSD or NetBSD kernel (now assumes NetBSD when both FreeBSD and NetBSD support compiled). 1) bootinfo (different that FreeBSD) 2) esym parameter - possibly same as FreeBSD must have look at it for 1 i will do tomorrow, seems really important. |