From d55bc511ea298fc4b1ffaf9cd8a4a9691b34a3b1 Mon Sep 17 00:00:00 2001 From: Tomoki Shirasawa Date: Mon, 15 Apr 2013 15:00:30 +0900 Subject: [PATCH] add a boot script for attached-mic. --- Makefile.in | 5 +++ boot-attached-mic.sh.in | 98 +++++++++++++++++++++++++++++++++++++++++ configure | 14 +++++- configure.ac | 11 +++++ 4 files changed, 127 insertions(+), 1 deletion(-) create mode 100755 boot-attached-mic.sh.in diff --git a/Makefile.in b/Makefile.in index d6a7384f..4fbdc6df 100755 --- a/Makefile.in +++ b/Makefile.in @@ -1,4 +1,5 @@ TARGET = @TARGET@ +SBINDIR = @SBINDIR@ all:: @(cd executer/kernel; make modules) @@ -25,6 +26,10 @@ install:: exit 1 \ ;; \ esac + if [ "$(TARGET)" = attached-mic ]; then \ + mkdir -p -m 755 $(SBINDIR); \ + install -m 755 boot-attached-mic.sh $(SBINDIR)/boot.sh; \ + fi clean:: @(cd executer/kernel; make clean) diff --git a/boot-attached-mic.sh.in b/boot-attached-mic.sh.in new file mode 100755 index 00000000..8719b307 --- /dev/null +++ b/boot-attached-mic.sh.in @@ -0,0 +1,98 @@ +#!/bin/bash + +prefix="@prefix@" +BINDIR="@BINDIR@" +SBINDIR="@SBINDIR@" +KMODDIR="@KMODDIR@" +KERNDIR="@KERNDIR@" + +if ! lspci | grep 'Co-processor.*Intel Corporation' > /dev/null 2>&1; then + echo No Intel co-processor found. >&2 + exit 1 +fi + +echo "removing kernel modules..." >&2 +modules_were_loaded="0" + +if [ "`service mpss status 2> /dev/null`" != "mpss is stopped" ]; then + modules_were_loaded="1" + sudo service mpss stop +fi +if lsmod | awk 'BEGIN{rc=1}$1 == "mic"{rc=0}END{exit(rc)}'; then + modules_were_loaded="1" + sudo service mpss unload +fi + +for mod_name in mcctrl ihk_mic ihk; do + if lsmod | awk 'BEGIN{rc=1}$1 == "'"$mod_name"'"{rc=0}END{exit(rc)}'; then + modules_were_loaded="1" + echo "rmmod $mod_name" >&2 + if rmmod $mod_name; then + echo "$mod_name removed succesfully" >&2 + sleep 1 + else + echo "ERROR: couldn't remove $mod_name" >&2 + exit 1 + fi + fi +done + +echo "removing kernel modules done" >&2 + +if [ "$1" == "-u" ]; then + exit +fi + +wait_time=50 + +if [ "$modules_were_loaded" == "1" ]; then + echo "waiting for ${wait_time} seconds: " >&2 + while [ "$wait_time" != 0 ]; do + echo -n "$wait_time " >&2 + sleep 1 + let wait_time=(${wait_time}-1) + done + echo "" >&2 +fi + +if [ "$1" == "-w" ]; then + shift 1 + echo "press enter to continue" >&2 + read enter_press +fi + + +for mod_path in "$KMODDIR/ihk.ko" "$KMODDIR/ihk_mic.ko" "$KMODDIR/mcctrl.ko"; do + if insmod $mod_path; then + sleep 3 + echo "$mod_path inserted succesfully" >&2 + else + echo "ERROR: couldn't insert $mod_path" >&2 + exit 1 + fi + + if [ "$mod_path" == "$KMODDIR/ihk_mic.ko" ]; then + echo "creating OS device" >&2 + sleep 2 + "$SBINDIR/ihktest" 0 create + sleep 2 + fi + + if [ "$mod_path" == "$KMODDIR/mcctrl.ko" ]; then + if [ $# -gt 0 ]; then + echo "setting kernel parameter to: \"$1\"" >&2 + "$SBINDIR/ihkostest" 0 kargs "$1" + sleep 2 + else + echo "setting kernel parameter to: \"hidos\"" >&2 + "$SBINDIR/ihkostest" 0 kargs "hidos" + sleep 2 + fi + echo "using kernel image: $KERNDIR/mckernel.img" >&2 + "$SBINDIR/ihkostest" 0 load "$KERNDIR/mckernel.img" + sleep 2 + echo "booting OS 0" >&2 + "$SBINDIR/ihkostest" 0 boot + sleep 2 + fi +done diff --git a/configure b/configure index f3652806..753a8569 100755 --- a/configure +++ b/configure @@ -603,6 +603,7 @@ ac_subst_vars='LTLIBOBJS LIBOBJS KERNDIR KMODDIR +SBINDIR BINDIR TARGET KDIR @@ -2725,6 +2726,9 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu if test "X$BINDIR" = X; then BINDIR="$prefix/bin" fi + if test "X$SBINDIR" = X; then + SBINDIR="$prefix/sbin" + fi if test "X$KMODDIR" = X; then KMODDIR="$prefix/kmod" fi @@ -2776,6 +2780,9 @@ fi if test "X$BINDIR" = X; then BINDIR="$prefix/attached/bin" fi + if test "X$SBINDIR" = X; then + SBINDIR="$prefix/attached/sbin" + fi if test "X$KMODDIR" = X; then KMODDIR="$prefix/attached/kmod" fi @@ -3472,6 +3479,9 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu if test "X$BINDIR" = X; then BINDIR="$prefix/bin" fi + if test "X$SBINDIR" = X; then + SBINDIR="$prefix/sbin" + fi if test "X$KMODDIR" = X; then KMODDIR="$prefix/kmod" fi @@ -3495,7 +3505,8 @@ TARGET="$WITH_TARGET" -ac_config_files="$ac_config_files Makefile executer/user/Makefile executer/kernel/Makefile kernel/Makefile" + +ac_config_files="$ac_config_files Makefile executer/user/Makefile executer/kernel/Makefile kernel/Makefile boot-attached-mic.sh" cat >confcache <<\_ACEOF @@ -4110,6 +4121,7 @@ do "executer/user/Makefile") CONFIG_FILES="$CONFIG_FILES executer/user/Makefile" ;; "executer/kernel/Makefile") CONFIG_FILES="$CONFIG_FILES executer/kernel/Makefile" ;; "kernel/Makefile") CONFIG_FILES="$CONFIG_FILES kernel/Makefile" ;; + "boot-attached-mic.sh") CONFIG_FILES="$CONFIG_FILES boot-attached-mic.sh" ;; *) { { $as_echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 $as_echo "$as_me: error: invalid argument: $ac_config_target" >&2;} diff --git a/configure.ac b/configure.ac index fd7bff52..a78fbb4e 100644 --- a/configure.ac +++ b/configure.ac @@ -38,6 +38,9 @@ case $WITH_TARGET in if test "X$BINDIR" = X; then BINDIR="$prefix/bin" fi + if test "X$SBINDIR" = X; then + SBINDIR="$prefix/sbin" + fi if test "X$KMODDIR" = X; then KMODDIR="$prefix/kmod" fi @@ -55,6 +58,9 @@ case $WITH_TARGET in if test "X$BINDIR" = X; then BINDIR="$prefix/attached/bin" fi + if test "X$SBINDIR" = X; then + SBINDIR="$prefix/attached/sbin" + fi if test "X$KMODDIR" = X; then KMODDIR="$prefix/attached/kmod" fi @@ -69,6 +75,9 @@ case $WITH_TARGET in if test "X$BINDIR" = X; then BINDIR="$prefix/bin" fi + if test "X$SBINDIR" = X; then + SBINDIR="$prefix/sbin" + fi if test "X$KMODDIR" = X; then KMODDIR="$prefix/kmod" fi @@ -87,6 +96,7 @@ AC_SUBST(ARCH) AC_SUBST(KDIR) AC_SUBST(TARGET) AC_SUBST(BINDIR) +AC_SUBST(SBINDIR) AC_SUBST(KMODDIR) AC_SUBST(KERNDIR) @@ -95,6 +105,7 @@ AC_CONFIG_FILES([ executer/user/Makefile executer/kernel/Makefile kernel/Makefile + boot-attached-mic.sh ]) AC_OUTPUT