diff options
author | Adrian Dudau <adrian.dudau@enea.com> | 2013-12-12 17:36:38 +0100 |
---|---|---|
committer | Adrian Dudau <adrian.dudau@enea.com> | 2013-12-12 17:36:38 +0100 |
commit | 2a7348129a42f21095fcd62e47a035f78d254130 (patch) | |
tree | 544dc8019a8f8cb684ace8674193605e607f9964 /recipes-kernel/pramfs-init/files | |
download | meta-enea-master.tar.gz |
Migrated from the internal git server on the dora-enea branch
Signed-off-by: Adrian Dudau <adrian.dudau@enea.com>
Diffstat (limited to 'recipes-kernel/pramfs-init/files')
-rw-r--r-- | recipes-kernel/pramfs-init/files/pramfs_init | 80 |
1 files changed, 80 insertions, 0 deletions
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 @@ | |||
1 | #!/bin/sh | ||
2 | #set -e | ||
3 | |||
4 | echo "Setting up pramfs" | ||
5 | |||
6 | # ensure the required binaries are present | ||
7 | #[ -x /sbin/modprobe ] || exit 1 | ||
8 | [ -x /bin/mount ] || exit 1 | ||
9 | [ -x /bin/grep ] || exit 1 | ||
10 | [ -x /bin/cat ] || exit 1 | ||
11 | [ -x /bin/sed ] || exit 1 | ||
12 | |||
13 | #modprobe pramfs | ||
14 | mkdir -p /mnt/pram | ||
15 | |||
16 | case "$1" in | ||
17 | start) | ||
18 | # Figure out RAM for pramfs | ||
19 | # This requires a kernel cmdline resevation of PRAMFS physmem | ||
20 | # in format memmap=16M$0x7000000 | ||
21 | grep memmap /proc/cmdline > /dev/null | ||
22 | if [ $? -eq 0 ]; then | ||
23 | addr=$(sed 's/.*memmap=\([^ ]*\)\$\([^ ]*\).*/\2/' < /proc/cmdline) | ||
24 | size=$(sed 's/.*memmap=\([^ ]*\)\$\([^ ]*\).*/\1/' < /proc/cmdline) | ||
25 | |||
26 | if [ -d /seed ]; then | ||
27 | echo "Init new pramfs" | ||
28 | mount -t pramfs -o physaddr=$addr,init=$size,bs=1k none /mnt/pram > /dev/null 2>&1 | ||
29 | cp /seed/* /mnt/pram | ||
30 | echo "0" > /mnt/pram/kcount | ||
31 | else | ||
32 | echo "Mounting old pramfs" | ||
33 | mount -t pramfs -o physaddr=$addr,bs=1k none /mnt/pram > /dev/null 2>&1 | ||
34 | if [ $? -ne 0 ]; then | ||
35 | echo "Mounting old pramfs failed, zeroing" | ||
36 | mount -t pramfs -o physaddr=$addr,init=$size,bs=1k none /mnt/pram > /dev/null 2>&1 | ||
37 | if [ $? -ne 0 ]; then | ||
38 | echo "All attempts to mount pramfs has failed, exiting" | ||
39 | rm -fr /mnt/pram | ||
40 | exit 1 | ||
41 | fi | ||
42 | echo "0" > /mnt/pram/kcount | ||
43 | fi | ||
44 | fi | ||
45 | |||
46 | # echo "* Setting up kexec" | ||
47 | # kexec -l --reuse-cmdline --initrd=/mnt/pram/initramfs.cpio.gz /mnt/pram/vmlinuz | ||
48 | |||
49 | # Calculate number of boots | ||
50 | export KCOUNT=$(expr $(cat /mnt/pram/kcount) + 1) | ||
51 | echo $KCOUNT > /mnt/pram/kcount | ||
52 | else | ||
53 | KCOUNT="no-mem" | ||
54 | echo "Can't find memory area for pram fs" | ||
55 | rm -fr /mnt/pram | ||
56 | fi | ||
57 | |||
58 | echo "PRAMFS boot count: $KCOUNT" | ||
59 | # echo "kexec -e to kexec and keep persistent files in /mnt/pram" | ||
60 | ;; | ||
61 | stop) | ||
62 | echo | ||
63 | ;; | ||
64 | restart) | ||
65 | $0 stop | ||
66 | $0 start | ||
67 | ;; | ||
68 | *) | ||
69 | echo "usage: $0 { start | stop | restart }" >&2 | ||
70 | exit 1 | ||
71 | ;; | ||
72 | esac | ||
73 | |||
74 | exit 0 | ||
75 | |||
76 | |||
77 | |||
78 | |||
79 | |||
80 | |||