diff mbox

[5/6] Makefile, boot.S: Allow kernel command line to be set in makefile

Message ID 1323107263-1870-6-git-send-email-peter.maydell@linaro.org
State Accepted
Headers show

Commit Message

Peter Maydell Dec. 5, 2011, 5:47 p.m. UTC
Allow the kernel command line to be set in the makefile rather
than forcing the user to edit boot.S every time.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 Makefile |   14 +++++++++++++-
 boot.S   |    5 +++++
 2 files changed, 18 insertions(+), 1 deletions(-)

Comments

Christoffer Dall Dec. 7, 2011, 5:53 a.m. UTC | #1
On Mon, Dec 5, 2011 at 12:47 PM, Peter Maydell <peter.maydell@linaro.org> wrote:
> Allow the kernel command line to be set in the makefile rather
> than forcing the user to edit boot.S every time.

great, although again I think the config-file scenario would apply.

>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> [snip]
Peter Maydell Dec. 7, 2011, 8:14 a.m. UTC | #2
On 7 December 2011 05:53, Christoffer Dall <cdall@cs.columbia.edu> wrote:
> On Mon, Dec 5, 2011 at 12:47 PM, Peter Maydell <peter.maydell@linaro.org> wrote:
>> Allow the kernel command line to be set in the makefile rather
>> than forcing the user to edit boot.S every time.
>
> great, although again I think the config-file scenario would apply.

Once things we care about are makefile variables, the config file
can be trivially implemented by having the makefile say
 -include config

at the top. (note the '-' so we don't complain if it doesn't exist.)

-- PMM
Christoffer Dall Dec. 7, 2011, 2:41 p.m. UTC | #3
On Wed, Dec 7, 2011 at 3:14 AM, Peter Maydell <peter.maydell@linaro.org> wrote:
> On 7 December 2011 05:53, Christoffer Dall <cdall@cs.columbia.edu> wrote:
>> On Mon, Dec 5, 2011 at 12:47 PM, Peter Maydell <peter.maydell@linaro.org> wrote:
>>> Allow the kernel command line to be set in the makefile rather
>>> than forcing the user to edit boot.S every time.
>>
>> great, although again I think the config-file scenario would apply.
>
> Once things we care about are makefile variables, the config file
> can be trivially implemented by having the makefile say
>  -include config
>
> at the top. (note the '-' so we don't complain if it doesn't exist.)
>
sounds simple and good to me.

we probably want to complain if things like KERNEL_SRC is not set though.
diff mbox

Patch

diff --git a/Makefile b/Makefile
index 0e07bf1..160cabd 100644
--- a/Makefile
+++ b/Makefile
@@ -24,6 +24,18 @@  endif
 #CPPFLAGS	+= -march=armv7-m
 #CPPFLAGS	+= -mthumb -Wa,-mthumb -Wa,-mimplicit-it=always
 
+# Kernel command line
+# MPS:
+# KCMD = "rdinit=/bin/sh console=ttyAMA3 mem=4M earlyprintk"
+# not-vexpress (ie EB, RealviewPB, etc), with initrd
+# KCMD = "console=ttyAMA0 mem=256M earlyprintk"
+# not-vexpress, without initrd:
+# KCMD = "root=/dev/nfs nfsroot=10.1.77.43:/work/debootstrap/arm ip=dhcp console=ttyAMA0 mem=256M earlyprintk"
+# Vexpress, with initrd:
+# KCMD = "console=ttyAMA0 mem=512M mem=512M@0x880000000 earlyprintk ip=192.168.27.200::192.168.27.1:255.255.255.0:angstrom:eth0:off"
+# VExpress, without initrd:
+KCMD ?= "console=ttyAMA0 mem=512M mem=512M@0x880000000 earlyprintk root=/dev/nfs nfsroot=172.31.252.250:/srv/arm-oneiric-root,tcp rw ip=dhcp nfsrootdebug"
+
 MONITOR		= monitor.S
 BOOTLOADER	= boot.S
 KERNEL_SRC	= ../linux-kvm-arm
@@ -54,7 +66,7 @@  $(IMAGE): boot.o monitor.o model.lds $(KERNEL) $(FILESYSTEM) Makefile
 	$(LD) -o $@ --script=model.lds
 
 boot.o: $(BOOTLOADER)
-	$(CC) $(CPPFLAGS) -c -o $@ $<
+	$(CC) $(CPPFLAGS) -DKCMD='$(KCMD)' -c -o $@ $<
 
 monitor.o: $(MONITOR)
 	$(CC) $(CPPFLAGS) -c -o $@ $<
diff --git a/boot.S b/boot.S
index 6de3721..e1c8d78 100644
--- a/boot.S
+++ b/boot.S
@@ -142,6 +142,10 @@  atags:
 	@ ATAG_CMDLINE
 	.long	(1f - .) >> 2
 	.long	0x54410009
+#ifdef KCMD
+        /* User-specified command line always overrides */
+        .asciz KCMD
+#else
 #ifdef MACH_MPS
 	.asciz	"rdinit=/bin/sh console=ttyAMA3 mem=4M earlyprintk"
 #elif defined(VEXPRESS)
@@ -161,6 +165,7 @@  atags:
 #endif
 
 #endif
+#endif
 	.align	2
 1: