* Re: [PATCH] sh: Add CONFIG_PARAM_* to set boot parameters.
2009-11-30 8:02 [PATCH] sh: Add CONFIG_PARAM_* to set boot parameters yoshii.takashi
@ 2009-12-02 1:35 ` Paul Mundt
2009-12-08 5:01 ` yoshii.takashi
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Paul Mundt @ 2009-12-02 1:35 UTC (permalink / raw)
To: linux-sh
On Mon, Nov 30, 2009 at 05:02:54PM +0900, yoshii.takashi@renesas.com wrote:
> You can set boot parameters by config, ignoring data at the top of empty_zero_page.
> This and CONFIG_CMDLINE make zImage to be simple "load and go" capable binary,
> same as vmlinux (which has default boot parameters inside of it).
>
> ---
>
> I think people who already have "Linux aware" boot loader don't find anything interesting,
> but this was helpful when I was debugging with a monitor with serial file transfer only.
> IMHO, it might be a good to forget about parameters on the top of empty_zero_page.
>
But this breaks the entire boot ABI, and probably only for the reason
that new bootloaders don't set up the argument page correctly. How about
just fixing the bootloaders to comply with the ABI rather than layering
more hacks in the kernel to make up for lazy bootloader developers?
While I don't have any objections to making the argument page optional in
itself, we still require some hints for things like whether we are using
32-bit boot mode and so on that need to be reflected somewhere. If you
wish to propose a new boot ABI and move away from overloading of the zero
page, that's fine with me, but we're not going to be breaking the ABI to
work around bootloader laziness.
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH] sh: Add CONFIG_PARAM_* to set boot parameters.
2009-11-30 8:02 [PATCH] sh: Add CONFIG_PARAM_* to set boot parameters yoshii.takashi
2009-12-02 1:35 ` Paul Mundt
@ 2009-12-08 5:01 ` yoshii.takashi
2009-12-08 8:18 ` Paul Mundt
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: yoshii.takashi @ 2009-12-08 5:01 UTC (permalink / raw)
To: linux-sh
Paul, thank you for your comments.
> But this breaks the entire boot ABI, and probably only for the reason ...
Well, it is not clear because the ABI is uncertain. (I mean, I think so:)
If you are saying ABI is important, I agree with you, and I will postpone the
patch. And we should refrain from changing ABI related thing until the ABI
become clear and fixed.
Here is the boot ABI guessed from current implementation and my bad memory.
Please give your comments. > All the developers.
After fixed, I'd like to have this as Documentation/sh/boot.txt.
Cheers,
/yoshii
Linux/SH boot protocol
----------------------
== Boot procedure
1. Initialize memory system.
Do BSC and SDRAM and PFC setting if needed to enable to access to main
memory and external peripherals. That won't be done by kernel.
2. Load kernel and initrd (optional)
vmlinux is ELF file. Load it according to ELF information.
zImage is position independent binary. Can be placed to anywhere.
If you are using initrd. Put its image on memory.
It can be placed to anywhere as far as it is...
. higher than CONFIG_MEMORY_START of kernel configuration parameter.
. not overlapping to kernel itself.
Be careful especially using zImage because no area information is provided.
Check the configuration file of the kernel you are loading.
3. Set parameters
Fill parameter fields.
vmlinux is ELF and has ".empty_zero_page" section. Use it to know
where the parameter area is.
zImage doesn't provide the way to know the location.
Check your kernel configuration file to know where it is.
vmlinux has some values in empty_zero_page, but they should not be
used as default values. They are not reflecting kernel configuration.
zImage provides no empty_zero_page, clear the location first.
Valid length of CMDLINE depends on kernel configuration, but no way
to know from the kernel file. Check your kernel configuration file.
4. Jump to the entry
vmlinux has entry point information provided according to ELF spec.
zImage's entry point is the top of the binary.
Registers can hold any value, except SR.MD which should be 1.
== Parameters
All of parameters are passed through empty_zero_page.
Name: MOUNT_ROOT_RDONLY
Address/size: empty_zero_page+0/long
0: mount root rw
*: mount root ro
Using this field is discouraged.
Use "ro" or "rw" command line option instead.
Name: RAMDISK_FLAGS
Address/size: empty_zero_page+4/long
Bit.15: rd_prompt
0: non-interactive
1: Request to prompt to change Floppy Disk before read initial data.
Overridden by "prompt_ramdisk=" command line option.
Bit.14: rd_doload
0: do not load ramdisk
1: do load /dev/ram0
Overridden by "load_ramdisk=" command line option.
Bit[10..0]: rd_image_start
Start offset of ramdisk image. Unit is BLOCK(\x1024byte).
Overridden by "load_ramdiskart=" command line option.
Name: ORIG_ROOT_DEV
Address/size: empty_zero_page+8/long
Initial value of ROOT_DEV.
This is the source device of ramdisk when do_load=1, that is the
difference from "root=" option.
Ignored when initrd is used.
Name: LOADER_TYPE
Address/size: empty_zero_page+0xc/long
Guessed from x86 spec, this field holds the ID and Version of boot loader.
If this is 0, INITRD_START and INITRD_SIZE fields are not used.
Name: INITRD_START
Address/size: empty_zero_page+0x10/long
Initrd address offset from kernel CONFIG_MEMORY_START.
Setting this field 0 disables initrd.
Name: INITRD_SIZE
Address/size: empty_zero_page+0x14/long
Size of initrd image.
Be aware setting this field 0 does NOT disable initrd.
Name: (Mode_flag?)
Address/size: empty_zero_page+0x18/long
This is not a part of boot ABI.
In vmlinux, this field carries the value indicate 29bit/32bit.
Name: CMDLINE
Address/size: empty_zero_page+0x100/char[512]
kernel may read this as a command line.
Acceptable length varies from 0 to 512, depends on kernel configuration.
Boot loader should put '\0' if no options.
--
Lines below are not a part of ABI specification.
== Supporting states survey
vmlinux:
Values in arch/sh/kernel/head_32.S
This provede all flags, but commandline.
Values except Mode_flag are bogus but harmless.
MOUNT_ROOT_RDONLY: 1
RAMDISK_FLAGS: 0
ORIG_ROOT_DEV: 200
LOADER_TYPE: 1
INITRD_START: 0
INITRD_SIZE: 0
Mode_flag: 0x53453f20 or 0x53453f1d
CMDLINE: left untouched
ipl+g/ethboot
ipl+g built-in network boot loader.
empty_zero_page is cleard to 0.
CMDLINE: string from DHCP
sh-lilo:
Old one.
empty_zero_page is cleard to 0.
CMDLINE: built-in constant string.
sh-lilo-sel:
New one found in Landisk and some others.
This fills all parameters.
This treat Mode_flag as reserved.
This one uses LOADER_TYPE as ID. (comment in source says "LILO = 1").
MOUNT_ROOT_RDONLY: 1
RAMDISK_FLAGS: 0
ORIG_ROOT_DEV: 201
LOADER_TYPE: 1
INITRD_START:
INITRD_SIZE:
Mode_flag: 0
CMDLINE: string from command-line sector of boot device.
RedBoot:
On RedBoot, all parameters are user parameter.
This fills all parameters but Mode_flag.
MOUNT_ROOT_RDONLY: any
RAMDISK_FLAGS: any
ORIG_ROOT_DEV: any
LOADER_TYPE: any
INITRD_START: any
INITRD_SIZE: any
Mode_flag: left untouched
CMDLINE: any
qemu:
Qemu builtin linux loader.
On this system, untouched area is filled by 0.
Parameters area is left untouched.
CMDLINE: string from qemu command-line option.
U-Boot:
(Please fill this)
kexec:
(Please fill this)
--
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH] sh: Add CONFIG_PARAM_* to set boot parameters.
2009-11-30 8:02 [PATCH] sh: Add CONFIG_PARAM_* to set boot parameters yoshii.takashi
2009-12-02 1:35 ` Paul Mundt
2009-12-08 5:01 ` yoshii.takashi
@ 2009-12-08 8:18 ` Paul Mundt
2009-12-08 13:14 ` Stuart MENEFY
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Paul Mundt @ 2009-12-08 8:18 UTC (permalink / raw)
To: linux-sh
On Tue, Dec 08, 2009 at 02:01:26PM +0900, yoshii.takashi@renesas.com wrote:
> Paul, thank you for your comments.
>
> > But this breaks the entire boot ABI, and probably only for the reason ...
> Well, it is not clear because the ABI is uncertain. (I mean, I think so:)
> If you are saying ABI is important, I agree with you, and I will postpone the
> patch. And we should refrain from changing ABI related thing until the ABI
> become clear and fixed.
>
I wasn't aware there was any ambiguity with the boot ABI, only that
certain boot loaders failed to set up the argument page properly. This is
something that was cloned from x86 originally, so it's not exactly an
exotic feature, and any sensible boot loader has no problems supporting
it.
> Here is the boot ABI guessed from current implementation and my bad memory.
> Please give your comments. > All the developers.
> After fixed, I'd like to have this as Documentation/sh/boot.txt.
>
Thanks for your work on this, this is certainly a good start!
> Linux/SH boot protocol
> ----------------------
>
> == Boot procedure
>
> 1. Initialize memory system.
> Do BSC and SDRAM and PFC setting if needed to enable to access to main
> memory and external peripherals. That won't be done by kernel.
>
These days we inherit the BSC settings but the PFC settings are almost
entirely blown away by the kernel through the pinmux code. Certain
platforms (ie, romimage targets) also have their own BSC initialization.
Only the BSC settings are generally left untouched, but this will
probably change in the future as more targets move to romimage booting.
Given that most of the BSC settings in the boot loaders are just lazily
copied from one platform to another, doing it properly in the kernel is
certainly a step up.
> Name: (Mode_flag?)
> Address/size: empty_zero_page+0x18/long
>
> This is not a part of boot ABI.
> In vmlinux, this field carries the value indicate 29bit/32bit.
>
Correct, this is the 32bit boot flag. It's provided as a hint to figure
out whether the boot loader has entered from 32-bit boot or not.
Presently we don't do anything with this however.
> U-Boot:
> (Please fill this)
>
And this would be where the problem arises. U-Boot should be able to
handle this without issue, but it's not obvious that it does at present
(hence all of the workaround patches).
> kexec:
> (Please fill this)
>
In the kexec case the page is zeroed and the command line is copied in.
So, only the command line is valid.
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH] sh: Add CONFIG_PARAM_* to set boot parameters.
2009-11-30 8:02 [PATCH] sh: Add CONFIG_PARAM_* to set boot parameters yoshii.takashi
` (2 preceding siblings ...)
2009-12-08 8:18 ` Paul Mundt
@ 2009-12-08 13:14 ` Stuart MENEFY
2009-12-09 12:00 ` Magnus Damm
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Stuart MENEFY @ 2009-12-08 13:14 UTC (permalink / raw)
To: linux-sh
Folks
Paul Mundt wrote:
> On Tue, Dec 08, 2009 at 02:01:26PM +0900, yoshii.takashi@renesas.com wrote:
> zImage doesn't provide the way to know the location.
> Check your kernel configuration file to know where it is.
This is the bit which is nasty. Because we don't use the parameters which
are part of the zImage header (head.S) which are still set up for x86,
the boot loader has to know where empty zero page will end up.
> zImage's entry point is the top of the binary.
Are you sure, I thought was was the start?
>> Name: (Mode_flag?)
>> Address/size: empty_zero_page+0x18/long
>>
>> This is not a part of boot ABI.
>> In vmlinux, this field carries the value indicate 29bit/32bit.
>>
> Correct, this is the 32bit boot flag. It's provided as a hint to figure
> out whether the boot loader has entered from 32-bit boot or not.
> Presently we don't do anything with this however.
We intended this to be rather more than a hint. Because the transition
into SE mode is painful we always do it in the boot loader, and so the
boot loader can check whether the kernel it is loading was compiled
in expectation that SE would already be on.
The 'contract' between the boot loader and the kernel in this case also
has to include the state of the PMB. We did write something about this,
I'll see if I can dig it up...
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH] sh: Add CONFIG_PARAM_* to set boot parameters.
2009-11-30 8:02 [PATCH] sh: Add CONFIG_PARAM_* to set boot parameters yoshii.takashi
` (3 preceding siblings ...)
2009-12-08 13:14 ` Stuart MENEFY
@ 2009-12-09 12:00 ` Magnus Damm
2009-12-10 5:00 ` yoshii.takashi
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Magnus Damm @ 2009-12-09 12:00 UTC (permalink / raw)
To: linux-sh
On Tue, Dec 8, 2009 at 10:14 PM, Stuart MENEFY <stuart.menefy@st.com> wrote:
> Folks
>
> Paul Mundt wrote:
>> On Tue, Dec 08, 2009 at 02:01:26PM +0900, yoshii.takashi@renesas.com wrote:
>> zImage doesn't provide the way to know the location.
>> Check your kernel configuration file to know where it is.
>
> This is the bit which is nasty. Because we don't use the parameters which
> are part of the zImage header (head.S) which are still set up for x86,
> the boot loader has to know where empty zero page will end up.
I agree that it's nasty, but it is possible to figure out the location
of the zero page from the zImage binary. The kexec zImage loader code
does just that, and it should work regardless of the page size
configuration.
/ magnus
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH] sh: Add CONFIG_PARAM_* to set boot parameters.
2009-11-30 8:02 [PATCH] sh: Add CONFIG_PARAM_* to set boot parameters yoshii.takashi
` (4 preceding siblings ...)
2009-12-09 12:00 ` Magnus Damm
@ 2009-12-10 5:00 ` yoshii.takashi
2009-12-10 7:01 ` yoshii.takashi
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: yoshii.takashi @ 2009-12-10 5:00 UTC (permalink / raw)
To: linux-sh
Hi,
> > zImage doesn't provide the way to know the location.
> > Check your kernel configuration file to know where it is.
>
> This is the bit which is nasty. Because we don't use the parameters which
> are part of the zImage header (head.S) which are still set up for x86,
> the boot loader has to know where empty zero page will end up.
Right.
Generally, SH's zImage lacks of "kernel to loader" information.
Partly because that is a raw binary, and partly because we discard empty_zero_page
during conversion. # Even ABI itself and vmlinux do little, too, But ELF helps.
1. Adding some information to zImage
If we are using zImage in the future(perhaps YES), I think we should change it
(but by compatible manner) to carry the information same as vmlinux does.
This can include not only ELF info but also the default boot parameters.
I think we need the followings, at least
- empty_zero_page address (for the location to parameters be written).
- Size of zImage (same as above. Useful when copy the binary)
# I know some people get them by poking the binary.
- Default values of parameters which are same as vmlinux carries.
and possibly
- Address of zImage (we should reserve this area because zImage copy itself there)
- Size of vmlinux (to know where to place initrd and so on)
- Entry point of zImage (not needed if it is always offset 0)
- ABI version (this might be not only for zImage but also for vmlinux)
Maybe, when I added fake bzImage support, I should have added part 1 header
which is good place to put the default values of parameters. (like x86 does)
But, what I added was only part 2 of x86 headers(After "Hdrs" signature).
Location can be other than offset 497 of x86, because
- SH have no boot sector nor "rdev" interface to handle the defaults.
- Our parameters are at offset 0 anyway (which is not applicable to zImage).
But, of course, the location should be defined in ABI.
(proposal)
startup+0x220/long Address of empty_zero_page
startup+0x224/long Size of zImage
startup+0x228/long Offset(from start) of default value block
2. Handling of default command line.
I think it is better if we could provide default command line to boot loaders.
And, I wonder if extend/override selection can be done by boot loader.
This is new even for vmlinux.
(proposal)
Name: command line offset
Address/size: empty_zero_page+0x1c/long
Type: kernel to boot loader information.
This is the location of the default command line provided kernel.
vmlinux: offset from empty_zero_page
zImage: offset from the start of the binary
0 means no command line information is provided.
Though it might be not a part of ABI, 0x100 might be good for both vmlinux
and zImage. I mean, CMDLINE at 0x100 in vmlinux can carry the default value.
Attached patch is experimental implementation of 1, 2 and CONFIG_PARAM,
only for description. I think I can make me understood better by C than English.
> > zImage's entry point is the top of the binary.
>
> Are you sure, I thought was was the start?
Ah... What I mean was "at the beginning of the binary". Was it a bottom?
Is it right to say "zImage's entry point is at the start of the binary" ?
> >> Name: (Mode_flag?)
...
> in expectation that SE would already be on.
Hmm, I see "x?ES" in the binary. Well, perhaps I should write about endian.
> The 'contract' between the boot loader and the kernel in this case also
> has to include the state of the PMB. We did write something about this,
> I'll see if I can dig it up...
Ah, yes. We also know what is the "fixed" PMB like.
/yoshii
diff --git a/arch/sh/boot/compressed/head_32.S b/arch/sh/boot/compressed/head_32.S
index 02a3093..0a96edb 100644
--- a/arch/sh/boot/compressed/head_32.S
+++ b/arch/sh/boot/compressed/head_32.S
@@ -99,6 +99,12 @@ decompress_kernel_addr:
kernel_start_addr:
.long _text+PAGE_SIZE
+#if defined(CONFIG_CMDLINE)
+ .skip startup + 0x100 - .
+cmdline:
+ .asciz CONFIG_CMDLINE ! default command line
+#endif
+
.align 9
fake_headers_as_bzImage:
.word 0
@@ -117,3 +123,48 @@ fake_headers_as_bzImage:
.long 0x100000 ! 0x100000 = default for big kernel
.long 0 ! address of loaded ramdisk image
.long 0 # its size in bytes
+
+ .skip startup + 0x220 - .
+
+ ! address of empty_zero_page
+#ifdef CONFIG_PMB_FIXED
+ .long CONFIG_PAGE_OFFSET + (CONFIG_MEMORY_START & 0x1fffffff) \
+ + CONFIG_ZERO_PAGE_OFFSET
+#elif defined(CONFIG_32BIT)
+ .long CONFIG_PAGE_OFFSET + CONFIG_ZERO_PAGE_OFFSET
+#else
+ .long CONFIG_PAGE_OFFSET + CONFIG_MEMORY_START \
+ + CONFIG_ZERO_PAGE_OFFSET
+#endif
+ .long _edata - startup ! size of zImage
+ .long default_values - startup
+
+ ! default values of boot parameters and flags
+ .align 2
+default_values:
+#ifdef CONFIG_PARAM_BOOL
+ .long CONFIG_PARAM_MOUNT_ROOT_RDONLY
+ .long CONFIG_PARAM_RAMDISK_FLAGS
+ .long CONFIG_PARAM_ORIG_ROOT_DEV
+ .long CONFIG_PARAM_LOADER_TYPE
+ .long CONFIG_PARAM_INITRD_START
+ .long CONFIG_PARAM_INITRD_SIZE
+#else
+ .long 1 /* MOUNT_ROOT_RDONLY */
+ .long 0 /* RAMDISK_FLAGS */
+ .long 0x0200 /* ORIG_ROOT_DEV */
+ .long 1 /* LOADER_TYPE */
+ .long 0x00000000 /* INITRD_START */
+ .long 0x00000000 /* INITRD_SIZE */
+#endif
+ ! Mode flag
+#ifdef CONFIG_32BIT
+ .long 0x53453f00 + 32 /* "SE?" = 32 bit */
+#else
+ .long 0x53453f00 + 29 /* "SE?" = 29 bit */
+#endif
+#if defined(CONFIG_CMDLINE)
+ .long cmdline - startup ! offset of the default command line
+#else
+ .long 0 ! no default provided
+#endif
diff --git a/arch/sh/kernel/head_32.S b/arch/sh/kernel/head_32.S
index a78be74..58325fe 100644
--- a/arch/sh/kernel/head_32.S
+++ b/arch/sh/kernel/head_32.S
@@ -27,17 +27,36 @@
.section .empty_zero_page, "aw"
ENTRY(empty_zero_page)
+#ifdef CONFIG_PARAM_BOOL
+ .long CONFIG_PARAM_MOUNT_ROOT_RDONLY
+ .long CONFIG_PARAM_RAMDISK_FLAGS
+ .long CONFIG_PARAM_ORIG_ROOT_DEV
+ .long CONFIG_PARAM_LOADER_TYPE
+ .long CONFIG_PARAM_INITRD_START
+ .long CONFIG_PARAM_INITRD_SIZE
+#else
.long 1 /* MOUNT_ROOT_RDONLY */
.long 0 /* RAMDISK_FLAGS */
.long 0x0200 /* ORIG_ROOT_DEV */
.long 1 /* LOADER_TYPE */
.long 0x00000000 /* INITRD_START */
.long 0x00000000 /* INITRD_SIZE */
+#endif
#ifdef CONFIG_32BIT
.long 0x53453f00 + 32 /* "SE?" = 32 bit */
#else
.long 0x53453f00 + 29 /* "SE?" = 29 bit */
#endif
+#if defined(CONFIG_CMDLINE)
+ .long 0x100 /* offset of the default command line */
+#else
+ .long 0
+#endif
+#if defined(CONFIG_CMDLINE)
+ .skip empty_zero_page + 0x100 - .
+cmdline:
+ .asciz CONFIG_CMDLINE ! default command line
+#endif
1:
.skip PAGE_SIZE - empty_zero_page - 1b
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 88cdeb9..97b2668 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -799,6 +799,41 @@ config CMDLINE
depends on CMDLINE_OVERWRITE || CMDLINE_EXTEND
default "console=ttySC1,115200"
+config PARAM_BOOL
+ bool "Default kernel params"
+ help
+ Setting this option allows the boot parameters to be set.
+
+config PARAM_MOUNT_ROOT_RDONLY
+ int "MOUNT_ROOT_RDONLY"
+ depends on PARAM_BOOL
+ default 1
+
+config PARAM_RAMDISK_FLAGS
+ hex "RAMDISK_FLAGS"
+ depends on PARAM_BOOL
+ default 0
+
+config PARAM_ORIG_ROOT_DEV
+ hex "ORIG_ROOT_DEV"
+ depends on PARAM_BOOL
+ default 0x200
+
+config PARAM_LOADER_TYPE
+ hex "LOADER_TYPE"
+ depends on PARAM_BOOL
+ default 1
+
+config PARAM_INITRD_START
+ hex "INITRD_START"
+ depends on PARAM_BOOL
+ default 0
+
+config PARAM_INITRD_SIZE
+ hex "INITRD_SIZE"
+ depends on PARAM_BOOL
+ default 0
+
endmenu
menu "Bus options"
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH] sh: Add CONFIG_PARAM_* to set boot parameters.
2009-11-30 8:02 [PATCH] sh: Add CONFIG_PARAM_* to set boot parameters yoshii.takashi
` (5 preceding siblings ...)
2009-12-10 5:00 ` yoshii.takashi
@ 2009-12-10 7:01 ` yoshii.takashi
2009-12-10 8:48 ` yoshii.takashi
2009-12-14 2:10 ` Paul Mundt
8 siblings, 0 replies; 10+ messages in thread
From: yoshii.takashi @ 2009-12-10 7:01 UTC (permalink / raw)
To: linux-sh
Thank you for your comment.
Here is the new version. I hope next version will be a patch.
Add corresponding kernel version.
Add some about binary format.
Add parameter type "kernel to loader" / "loader to kernel".
Mode_flag is considered as a part of ABI.
Update status survey.
... and some others
> > 1. Initialize memory system.
...
> These days we inherit the BSC settings but the PFC settings are almost
> entirely blown away by the kernel through the pinmux code. ...
Oh, yes. I have moved PFC things to historical.
> ...
> Given that most of the BSC settings in the boot loaders are just lazily
> copied from one platform to another, doing it properly in the kernel is
> certainly a step up.
Basically, I think so, too. Though, we have to consider that
1. There are some registers defined as "should be initialized only once".
Well, I dont' think it is a big problem because, in such case, I guess the
loader itself is included in kernel. (but, then....)
2. People may want to have "hidden/proprietary" initialization routine.
Perhaps, who want do spacial have to do specially.
> > Name: (Mode_flag?)
...
> Correct, this is the 32bit boot flag. It's provided as a hint to figure
...
Stuart> ...(more explanation. thank you)
Now, this seems to be good to be described as a part of ABI.
This must be the first "kernel to loader" information, which we might
want to have more (like page size info, PMB usage info, ....).
> > U-Boot:
Reading source code, is seems to clear parameters area, and add CMDLINE.
It seems that "Just clear params, and add CMDLINE" is the majority.
Perhaps, it should be improved when they(?) add initrd support.
> > kexec:
> > (Please fill this)
> >
> In the kexec case the page is zeroed and the command line is copied in.
> So, only the command line is valid.
Thank you.
But I found another....
1. It checks "HdrS" bzImage signature.
It is OK. I found lilo does, too. I added this to the document.
2. It scans the binary to find the entry address.
This searches "word other than NOP" from the middle of the head.S back to
the beginning. Then use two long values there as size and entry point.
What should I say? F- something?
/yoshii
Linux/SH boot protocol
----------------------
The status at v2.6.32.
== Binary format
vmlinux:
This is an ELF executable file.
Has .empty_zero_page section.
Has entry point information.
zImage:
This is a raw binary.
Entry point is at the beginning of the binary.
Has signature and other flags to fake bzImage at offset 0x200.
== Boot procedure
1. Initialize memory system.
Do BSC and SDRAM setting if needed to access to main memory.
** Historical(...v2.6.30)
Do PFC setting. That won't be done by kernel.
2. Load kernel and initrd (optional)
vmlinux is ELF file. Load it according to ELF information.
zImage is position independent binary. Can be placed to anywhere.
If you are using initrd. Put its image on memory.
It can be placed to anywhere as far as it is...
. Higher than CONFIG_MEMORY_START of kernel configuration parameter.
. Not overlapping to kernel itself.
Be careful especially using zImage because no area information is provided.
Check the configuration file of the kernel and corresponding vmlinux.
3. Set parameters
Fill parameter fields.
vmlinux is ELF and has ".empty_zero_page" section. Use it to know
where the parameter area is.
zImage doesn't provide the way to know the location.
Check your kernel configuration file to know where it is.
vmlinux has some values in empty_zero_page, but they should not be
used as default values. They are not reflecting kernel configuration.
zImage provides no empty_zero_page, clear the location first.
4. Jump to the entry
vmlinux has entry point information provided according to ELF spec.
zImage's entry point is the top of the binary.
Registers can hold any value, except SR.MD which should be 1.
== Parameters
All of parameters are passed through empty_zero_page.
Name: MOUNT_ROOT_RDONLY
Address/size: empty_zero_page+0/long
Type: loader to kernel information
0: mount root rw
*: mount root ro
Using this field is discouraged.
Use "ro" or "rw" command line option instead.
Name: RAMDISK_FLAGS
Address/size: empty_zero_page+4/long
Type: loader to kernel information
Bit.15: rd_prompt
0: non-interactive
1: Request to prompt to change Floppy Disk before read initial data.
Overridden by "prompt_ramdisk=" command line option.
Bit.14: rd_doload
0: do not load ramdisk
1: do load /dev/ram0
Overridden by "load_ramdisk=" command line option.
Bit[10..0]: rd_image_start
Start offset of ramdisk image. Unit is BLOCK(\x1024byte).
Overridden by "ramdisk_start=" command line option which
is not described in kernel-parameters.txt
Name: ORIG_ROOT_DEV
Address/size: empty_zero_page+8/long
Type: loader to kernel information
Initial value of ROOT_DEV.
This is the source device of ramdisk when do_load=1, that is the
difference from "root=" option.
Ignored when initrd is used.
Name: LOADER_TYPE
Address/size: empty_zero_page+0xc/long
Type: loader to kernel information
Guessed from x86 spec, this field holds the ID and Version of boot loader.
If this is 0, INITRD_START and INITRD_SIZE fields are not used.
Name: INITRD_START
Address/size: empty_zero_page+0x10/long
Type: loader to kernel information
Initrd address offset from kernel CONFIG_MEMORY_START.
Setting this field 0 disables initrd.
Name: INITRD_SIZE
Address/size: empty_zero_page+0x14/long
Type: loader to kernel information
Size of initrd image.
Be aware setting this field 0 does NOT disable initrd.
Name: (Mode_flag)
Address/size: empty_zero_page+0x18/long
Type: kernel to loader information
In vmlinux, this field carries the value indicate 29bit/32bit.
Name: CMDLINE
Address/size: empty_zero_page+0x100/char[256]
Type: loader to kernel information
kernel may read this as a command line depending on its configuration.
Boot loader should put '\0' if no options.
--
Lines below are not a part of ABI specification.
== Supporting states survey
vmlinux:
Values in arch/sh/kernel/head_32.S
This provide all flags, but command-line.
Values except Mode_flag are bogus but harmless.
MOUNT_ROOT_RDONLY: 1
RAMDISK_FLAGS: 0
ORIG_ROOT_DEV: 200
LOADER_TYPE: 1
INITRD_START: 0
INITRD_SIZE: 0
Mode_flag: 0x53453f20 or 0x53453f1d
CMDLINE: filled by 0
ipl+g/ethboot
ipl+g built-in network boot loader.
empty_zero_page is cleard to 0.
CMDLINE: string from DHCP
sh-lilo:
Old one.
Installer command(lilo) checks the zImage signature and version.
empty_zero_page is cleared to 0.
CMDLINE: built-in constant string.
sh-lilo-sel:
New one found in Landisk and some others.
This fills all parameters.
This treat Mode_flag as reserved.
This one uses LOADER_TYPE as ID. (comment in source says "LILO = 1").
Installer command(lilo) checks the zImage signature and version.
MOUNT_ROOT_RDONLY: 1
RAMDISK_FLAGS: 0
ORIG_ROOT_DEV: 201
LOADER_TYPE: 1
INITRD_START:
INITRD_SIZE:
Mode_flag: 0
CMDLINE: string from command-line sector of boot device.
RedBoot:
On RedBoot, all parameters are user configurable.
This fills all parameters but Mode_flag.
MOUNT_ROOT_RDONLY: any
RAMDISK_FLAGS: any
ORIG_ROOT_DEV: any
LOADER_TYPE: any
INITRD_START: any
INITRD_SIZE: any
Mode_flag: left untouched
CMDLINE: any
qemu:
Qemu built-in linux loader.
CMDLINE: string from qemu command-line option.
Others are left untouched but it means 0 on this system.
U-Boot:
empty_zero_page is cleard to 0.
CMDLINE: string from u-boot environment variable.
kexec:
empty_zero_page is cleared to 0.
CMDLINE: string from kexec command-line option.
Checks zImage signature.
Finds entry address by scanning the binary.
--
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH] sh: Add CONFIG_PARAM_* to set boot parameters.
2009-11-30 8:02 [PATCH] sh: Add CONFIG_PARAM_* to set boot parameters yoshii.takashi
` (6 preceding siblings ...)
2009-12-10 7:01 ` yoshii.takashi
@ 2009-12-10 8:48 ` yoshii.takashi
2009-12-14 2:10 ` Paul Mundt
8 siblings, 0 replies; 10+ messages in thread
From: yoshii.takashi @ 2009-12-10 8:48 UTC (permalink / raw)
To: linux-sh
Paul, I have forgotten to ask this.
> Name: CMDLINE
> Address/size: empty_zero_page+0x100/char[256]
> Type: loader to kernel information
>
> kernel may read this as a command line depending on its configuration.
> Boot loader should put '\0' if no options.
This time, I changed the size to 256.
First I thought that
- This field is char[512].
- Valid size depends on the configuration, because the kernel
reads (512 - N) byte when it has N byte of default command line.
But, after browsing log around CMDLINE, I think now I know what you wanted to do.
Your design is
- This field is char[256]
- All of them are guaranteed to be read (except OVERWRITE mode),
because default command line is also char[256], and buffer is char[512].
Right?
/yoshii
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH] sh: Add CONFIG_PARAM_* to set boot parameters.
2009-11-30 8:02 [PATCH] sh: Add CONFIG_PARAM_* to set boot parameters yoshii.takashi
` (7 preceding siblings ...)
2009-12-10 8:48 ` yoshii.takashi
@ 2009-12-14 2:10 ` Paul Mundt
8 siblings, 0 replies; 10+ messages in thread
From: Paul Mundt @ 2009-12-14 2:10 UTC (permalink / raw)
To: linux-sh
On Thu, Dec 10, 2009 at 02:00:25PM +0900, yoshii.takashi@gmail.com wrote:
> diff --git a/arch/sh/kernel/head_32.S b/arch/sh/kernel/head_32.S
> index a78be74..58325fe 100644
> --- a/arch/sh/kernel/head_32.S
> +++ b/arch/sh/kernel/head_32.S
> @@ -27,17 +27,36 @@
>
> .section .empty_zero_page, "aw"
> ENTRY(empty_zero_page)
> +#ifdef CONFIG_PARAM_BOOL
> + .long CONFIG_PARAM_MOUNT_ROOT_RDONLY
> + .long CONFIG_PARAM_RAMDISK_FLAGS
> + .long CONFIG_PARAM_ORIG_ROOT_DEV
> + .long CONFIG_PARAM_LOADER_TYPE
> + .long CONFIG_PARAM_INITRD_START
> + .long CONFIG_PARAM_INITRD_SIZE
> +#else
> .long 1 /* MOUNT_ROOT_RDONLY */
> .long 0 /* RAMDISK_FLAGS */
> .long 0x0200 /* ORIG_ROOT_DEV */
> .long 1 /* LOADER_TYPE */
> .long 0x00000000 /* INITRD_START */
> .long 0x00000000 /* INITRD_SIZE */
> +#endif
There's not really any point in conditionalizing these. If you want to
have them as config options, then just drop the bool and make them
unconditionally defined. You can just use the values that are there now
for the default values.
> #ifdef CONFIG_32BIT
> .long 0x53453f00 + 32 /* "SE?" = 32 bit */
> #else
> .long 0x53453f00 + 29 /* "SE?" = 29 bit */
> #endif
> +#if defined(CONFIG_CMDLINE)
> + .long 0x100 /* offset of the default command line */
> +#else
> + .long 0
> +#endif
> +#if defined(CONFIG_CMDLINE)
> + .skip empty_zero_page + 0x100 - .
> +cmdline:
> + .asciz CONFIG_CMDLINE ! default command line
> +#endif
> 1:
> .skip PAGE_SIZE - empty_zero_page - 1b
>
The command line handling could go the same way, with a bit of Kconfig
reordering there is no need for any ifdefs besides the 32/29bit stuff.
^ permalink raw reply [flat|nested] 10+ messages in thread