From 2a7348129a42f21095fcd62e47a035f78d254130 Mon Sep 17 00:00:00 2001 From: Adrian Dudau Date: Thu, 12 Dec 2013 17:36:38 +0100 Subject: initial commit of Enea Linux 3.1 Migrated from the internal git server on the dora-enea branch Signed-off-by: Adrian Dudau --- recipes-kernel/pramfs-init/files/pramfs_init | 80 ++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 recipes-kernel/pramfs-init/files/pramfs_init (limited to 'recipes-kernel/pramfs-init/files') diff --git a/recipes-kernel/pramfs-init/files/pramfs_init b/recipes-kernel/pramfs-init/files/pramfs_init new file mode 100644 index 0000000..64c7bc2 --- /dev/null +++ b/recipes-kernel/pramfs-init/files/pramfs_init @@ -0,0 +1,80 @@ +#!/bin/sh +#set -e + +echo "Setting up pramfs" + +# ensure the required binaries are present +#[ -x /sbin/modprobe ] || exit 1 +[ -x /bin/mount ] || exit 1 +[ -x /bin/grep ] || exit 1 +[ -x /bin/cat ] || exit 1 +[ -x /bin/sed ] || exit 1 + +#modprobe pramfs +mkdir -p /mnt/pram + +case "$1" in + start) + # Figure out RAM for pramfs + # This requires a kernel cmdline resevation of PRAMFS physmem + # in format memmap=16M$0x7000000 + grep memmap /proc/cmdline > /dev/null + if [ $? -eq 0 ]; then + addr=$(sed 's/.*memmap=\([^ ]*\)\$\([^ ]*\).*/\2/' < /proc/cmdline) + size=$(sed 's/.*memmap=\([^ ]*\)\$\([^ ]*\).*/\1/' < /proc/cmdline) + + if [ -d /seed ]; then + echo "Init new pramfs" + mount -t pramfs -o physaddr=$addr,init=$size,bs=1k none /mnt/pram > /dev/null 2>&1 + cp /seed/* /mnt/pram + echo "0" > /mnt/pram/kcount + else + echo "Mounting old pramfs" + mount -t pramfs -o physaddr=$addr,bs=1k none /mnt/pram > /dev/null 2>&1 + if [ $? -ne 0 ]; then + echo "Mounting old pramfs failed, zeroing" + mount -t pramfs -o physaddr=$addr,init=$size,bs=1k none /mnt/pram > /dev/null 2>&1 + if [ $? -ne 0 ]; then + echo "All attempts to mount pramfs has failed, exiting" + rm -fr /mnt/pram + exit 1 + fi + echo "0" > /mnt/pram/kcount + fi + fi + +# echo "* Setting up kexec" +# kexec -l --reuse-cmdline --initrd=/mnt/pram/initramfs.cpio.gz /mnt/pram/vmlinuz + + # Calculate number of boots + export KCOUNT=$(expr $(cat /mnt/pram/kcount) + 1) + echo $KCOUNT > /mnt/pram/kcount + else + KCOUNT="no-mem" + echo "Can't find memory area for pram fs" + rm -fr /mnt/pram + fi + + echo "PRAMFS boot count: $KCOUNT" +# echo "kexec -e to kexec and keep persistent files in /mnt/pram" + ;; + stop) + echo + ;; + restart) + $0 stop + $0 start + ;; + *) + echo "usage: $0 { start | stop | restart }" >&2 + exit 1 + ;; +esac + +exit 0 + + + + + + -- cgit v1.2.3-54-g00ecf