summaryrefslogtreecommitdiffstats
path: root/meta-sota/recipes-sota/ostree-initrd/files
diff options
context:
space:
mode:
Diffstat (limited to 'meta-sota/recipes-sota/ostree-initrd/files')
-rw-r--r--meta-sota/recipes-sota/ostree-initrd/files/init.sh84
1 files changed, 84 insertions, 0 deletions
diff --git a/meta-sota/recipes-sota/ostree-initrd/files/init.sh b/meta-sota/recipes-sota/ostree-initrd/files/init.sh
new file mode 100644
index 0000000..5aa99d6
--- /dev/null
+++ b/meta-sota/recipes-sota/ostree-initrd/files/init.sh
@@ -0,0 +1,84 @@
+#!/bin/sh
+
+# global variables
+
+SMACK=n
+DEBUG=n
+
+# -------------------------------------------
+
+log_info() { echo "$0[$$]: $@" >&2; }
+log_error() { echo "$0[$$]: ERROR $@" >&2; }
+
+do_mount_fs() {
+ log_info "mounting FS: $@"
+ [[ -e /proc/filesystems ]] && { grep -q "$1" /proc/filesystems || { log_error "Unknown filesystem"; return 1; } }
+ [[ -d "$2" ]] || mkdir -p "$2"
+ [[ -e /proc/mounts ]] && { grep -q -e "^$1 $2 $1" /proc/mounts && { log_info "$2 ($1) already mounted"; return 0; } }
+ mount -t "$1" "$1" "$2"
+}
+
+bail_out() {
+ log_error "$@"
+ log_info "Rebooting..."
+ #exec reboot -f
+ exec sh
+}
+
+get_ostree_sysroot() {
+ for opt in `cat /proc/cmdline`; do
+ arg=`echo $opt | cut -d'=' -f1`
+ if [ $arg == "ostree_root" ]; then
+ echo $opt | cut -d'=' -f2
+ return
+ fi
+ done
+}
+
+export PATH=/sbin:/usr/sbin:/bin:/usr/bin
+
+log_info "starting initrd script"
+
+do_mount_fs proc /proc
+do_mount_fs sysfs /sys
+do_mount_fs devtmpfs /dev
+do_mount_fs devpts /dev/pts
+do_mount_fs tmpfs /dev/shm
+do_mount_fs tmpfs /tmp
+do_mount_fs tmpfs /run
+
+# check if smack is active (and if so, mount smackfs)
+grep -q smackfs /proc/filesystems && {
+ SMACK=y
+
+ do_mount_fs smackfs /sys/fs/smackfs
+
+ # adjust current label and network label
+ echo System >/proc/self/attr/current
+ echo System >/sys/fs/smackfs/ambient
+}
+
+mkdir -p /sysroot
+ostree_sysroot=$(get_ostree_sysroot)
+
+mount $ostree_sysroot /sysroot || bail_out "Unable to mount $ostree_sysroot as physical sysroot"
+ostree-prepare-root /sysroot
+
+# move mounted devices to new root
+cd /sysroot
+for x in dev proc; do
+ log_info "Moving /$x to new rootfs"
+ mount -o move /$x $x
+done
+
+# switch to new rootfs
+log_info "Switching to new rootfs"
+mkdir -p run/initramfs
+
+pivot_root . run/initramfs || bail_out "pivot_root failed."
+
+log_info "Launching target init"
+
+exec chroot . sh -c 'umount /run/initramfs; exec /sbin/init' \
+ <dev/console >dev/console 2>&1
+
color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
/*
 * Copyright (c) 2021, Nippon Seiki Co., Ltd.
 * SPDX-License-Identifier: Apache-2.0
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef CLUSTER_API_H
#define CLUSTER_API_H

typedef enum {
    IC_HMI_OFF = 0,
    IC_HMI_ON,
} IC_HMI_ON_OFF;

#include <cluster_api_telltale.h>
#include <cluster_api_shiftposition.h>
#include <cluster_api_speed.h>
#include <cluster_api_tacho.h>
#include <cluster_api_tripcomputer.h>
#include <cluster_api_registernotify.h>

bool clusterInit(void);
bool clusterTerm(void);

// Callback function pointer type
typedef void (*IC_HMI_FUNC_NOTIFY_IC_HMI)(unsigned long long arg_1, IC_HMI_ON_OFF arg_2);

#endif // CLUSTER_API_H