[POWERPC] Editable kernel command-line in zImage binary.
zImage will set /chosen/bootargs (if it is otherwise empty) with the contents of a buffer in the section "__builtin_cmdline". This permits tools to edit zImage binaries to set the command-line eventually processed by vmlinux. -- Signed-off-by: Michal Ostrowski <mostrows@watson.ibm.com> Signed-off-by: Paul Mackerras <paulus@samba.org>
This commit is contained in:
parent
204face4fb
commit
30d8caf7c6
|
@ -33,6 +33,14 @@ extern char _vmlinux_end[];
|
||||||
extern char _initrd_start[];
|
extern char _initrd_start[];
|
||||||
extern char _initrd_end[];
|
extern char _initrd_end[];
|
||||||
|
|
||||||
|
/* A buffer that may be edited by tools operating on a zImage binary so as to
|
||||||
|
* edit the command line passed to vmlinux (by setting /chosen/bootargs).
|
||||||
|
* The buffer is put in it's own section so that tools may locate it easier.
|
||||||
|
*/
|
||||||
|
static char builtin_cmdline[512]
|
||||||
|
__attribute__((section("__builtin_cmdline")));
|
||||||
|
|
||||||
|
|
||||||
struct addr_range {
|
struct addr_range {
|
||||||
unsigned long addr;
|
unsigned long addr;
|
||||||
unsigned long size;
|
unsigned long size;
|
||||||
|
@ -204,6 +212,23 @@ static int is_elf32(void *hdr)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void export_cmdline(void* chosen_handle)
|
||||||
|
{
|
||||||
|
int len;
|
||||||
|
char cmdline[2] = { 0, 0 };
|
||||||
|
|
||||||
|
if (builtin_cmdline[0] == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
len = getprop(chosen_handle, "bootargs", cmdline, sizeof(cmdline));
|
||||||
|
if (len > 0 && cmdline[0] != 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
setprop(chosen_handle, "bootargs", builtin_cmdline,
|
||||||
|
strlen(builtin_cmdline) + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void start(unsigned long a1, unsigned long a2, void *promptr, void *sp)
|
void start(unsigned long a1, unsigned long a2, void *promptr, void *sp)
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
|
@ -289,6 +314,8 @@ void start(unsigned long a1, unsigned long a2, void *promptr, void *sp)
|
||||||
memmove((void *)vmlinux.addr,(void *)vmlinuz.addr,vmlinuz.size);
|
memmove((void *)vmlinux.addr,(void *)vmlinuz.addr,vmlinuz.size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export_cmdline(chosen_handle);
|
||||||
|
|
||||||
/* Skip over the ELF header */
|
/* Skip over the ELF header */
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf("... skipping 0x%lx bytes of ELF header\n\r",
|
printf("... skipping 0x%lx bytes of ELF header\n\r",
|
||||||
|
|
|
@ -31,4 +31,11 @@ static inline int getprop(void *phandle, const char *name,
|
||||||
return call_prom("getprop", 4, 1, phandle, name, buf, buflen);
|
return call_prom("getprop", 4, 1, phandle, name, buf, buflen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static inline int setprop(void *phandle, const char *name,
|
||||||
|
void *buf, int buflen)
|
||||||
|
{
|
||||||
|
return call_prom("setprop", 4, 1, phandle, name, buf, buflen);
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* _PPC_BOOT_PROM_H_ */
|
#endif /* _PPC_BOOT_PROM_H_ */
|
||||||
|
|
Loading…
Reference in a new issue