Module Name:    src
Committed By:   nat
Date:           Thu Apr 30 13:46:47 UTC 2015

Modified Files:
        src/sys/arch/amd64/conf: Makefile.amd64
        src/sys/arch/arm/conf: Makefile.arm
        src/sys/kern: init_main.c
Added Files:
        src/sys/dev/splash: splash.mk

Log Message:
Added a new option for embedding a splash screen into kernel.
Add: options SPLASHSCREEN
     makeoptions SPLASHSCREEN_IMAGE="path/to/image"
to your config file.  So far it will work on amd64 and RPI/RPI2.

This commit was with ideas, help, and OK from jmcneill@.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/sys/arch/amd64/conf/Makefile.amd64
cvs rdiff -u -r1.45 -r1.46 src/sys/arch/arm/conf/Makefile.arm
cvs rdiff -u -r0 -r1.1 src/sys/dev/splash/splash.mk
cvs rdiff -u -r1.464 -r1.465 src/sys/kern/init_main.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/amd64/conf/Makefile.amd64
diff -u src/sys/arch/amd64/conf/Makefile.amd64:1.46 src/sys/arch/amd64/conf/Makefile.amd64:1.47
--- src/sys/arch/amd64/conf/Makefile.amd64:1.46	Sat Nov 15 12:42:56 2014
+++ src/sys/arch/amd64/conf/Makefile.amd64	Thu Apr 30 13:46:47 2015
@@ -1,4 +1,5 @@
-#	$NetBSD: Makefile.amd64,v 1.46 2014/11/15 12:42:56 uebayasi Exp $
+#	$NetBSD: Makefile.amd64,v 1.47 2015/04/30 13:46:47 nat Exp $
+
 
 # Makefile for NetBSD
 #
@@ -73,6 +74,10 @@ copy.o: ${AMD64}/amd64/copy.S assym.h
 spl.o: ${AMD64}/amd64/spl.S assym.h
 	${NORMAL_S}
 
+.if defined(SPLASHSCREEN_IMAGE)
+.include "$S/dev/splash/splash.mk"
+.endif
+
 ##
 ## (5) link settings
 ##

Index: src/sys/arch/arm/conf/Makefile.arm
diff -u src/sys/arch/arm/conf/Makefile.arm:1.45 src/sys/arch/arm/conf/Makefile.arm:1.46
--- src/sys/arch/arm/conf/Makefile.arm:1.45	Sun Aug 17 21:17:43 2014
+++ src/sys/arch/arm/conf/Makefile.arm	Thu Apr 30 13:46:47 2015
@@ -1,4 +1,5 @@
-#	$NetBSD: Makefile.arm,v 1.45 2014/08/17 21:17:43 joerg Exp $
+#	$NetBSD: Makefile.arm,v 1.46 2015/04/30 13:46:47 nat Exp $
+
 
 # Makefile for NetBSD
 #
@@ -74,6 +75,10 @@ ${SYSTEM_FIRST_OBJ}: ${SYSTEM_FIRST_SFIL
 locore.o: ${ARM}/arm32/locore.S assym.h
 	${NORMAL_S}
 
+.if defined(SPLASHSCREEN_IMAGE)
+.include "$S/dev/splash/splash.mk"
+.endif
+
 ##
 ## (5) link settings
 ##

Index: src/sys/kern/init_main.c
diff -u src/sys/kern/init_main.c:1.464 src/sys/kern/init_main.c:1.465
--- src/sys/kern/init_main.c:1.464	Mon Apr 27 07:51:28 2015
+++ src/sys/kern/init_main.c	Thu Apr 30 13:46:47 2015
@@ -1,4 +1,5 @@
-/*	$NetBSD: init_main.c,v 1.464 2015/04/27 07:51:28 pgoyette Exp $	*/
+/*	$NetBSD: init_main.c,v 1.465 2015/04/30 13:46:47 nat Exp $	*/
+
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -97,7 +98,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.464 2015/04/27 07:51:28 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.465 2015/04/30 13:46:47 nat Exp $");
 
 #include "opt_ddb.h"
 #include "opt_ipsec.h"
@@ -113,6 +114,12 @@ __KERNEL_RCSID(0, "$NetBSD: init_main.c,
 #include "opt_wapbl.h"
 #include "opt_ptrace.h"
 #include "opt_rnd_printf.h"
+#include "opt_splash.h"
+
+#if defined(SPLASHSCREEN) && defined(SPLASHSCREEN_IMAGE)
+extern void *_binary_splash_image_start;
+extern void *_binary_splash_image_end;
+#endif
 
 #include "drvctl.h"
 #include "ksyms.h"
@@ -218,6 +225,7 @@ __KERNEL_RCSID(0, "$NetBSD: init_main.c,
 #include <uvm/uvm.h>	/* extern struct uvm uvm */
 
 #include <dev/cons.h>
+#include <dev/splash/splash.h>
 
 #include <net/bpf.h>
 #include <net/if.h>
@@ -356,6 +364,13 @@ main(void)
 	/* Initialize the buffer cache */
 	bufinit();
 
+
+#if defined(SPLASHSCREEN) && defined(SPLASHSCREEN_IMAGE)
+	size_t splash_size = (&_binary_splash_image_end -
+	    &_binary_splash_image_start) * sizeof(void *);
+	splash_setimage(&_binary_splash_image_start, splash_size);
+#endif
+
 	/* Initialize sockets. */
 	soinit();
 

Added files:

Index: src/sys/dev/splash/splash.mk
diff -u /dev/null src/sys/dev/splash/splash.mk:1.1
--- /dev/null	Thu Apr 30 13:46:47 2015
+++ src/sys/dev/splash/splash.mk	Thu Apr 30 13:46:47 2015
@@ -0,0 +1,26 @@
+# Makefile for embedding splash image into kernel.
+.include <bsd.endian.mk>
+
+MD_OBJS+=	splash_image.o
+CFLAGS+=	-DSPLASHSCREEN_IMAGE
+
+.if (${OBJECT_FMTS:Melf64})
+BFD_ELFTARGET=elf64
+.else
+BFD_ELFTARGET=elf32
+.endif
+
+BFD_ENDIANNESS=${TARGET_ENDIANNESS:S/1234/little/C/4321/big/}
+BFD_CPU=${MACHINE_CPU:S/_/-/}
+
+.if (${BFD_CPU:Maarch64} || ${BFD_CPU:Marm} || ${BFD_CPU:Mmips} || ${BFD_CPU:Mscore})
+BFD_TARGET=${BFD_ELFTARGET}-${BFD_ENDIANNESS}${BFD_CPU}
+.else
+BFD_TARGET=${BFD_ELFTARGET}-${BFD_CPU}
+.endif
+
+splash_image.o:	${SPLASHSCREEN_IMAGE}
+	cp ${SPLASHSCREEN_IMAGE} splash.image
+	${OBJCOPY} -I binary -B ${MACHINE_CPU:C/x86_64/i386/} \
+		-O ${BFD_TARGET} splash.image splash_image.o
+	rm splash.image

Reply via email to