| # Copyright 2021 The ChromiumOS Authors |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| description "Start Chrome OS HPS service" |
| author "chromium-os-dev@chromium.org" |
| |
| # Environment variables for daemon configuration. |
| # They are defaulted here and should be overridden in hpsd.override |
| env HPS_HW_FLAGS="--test --skipboot" |
| |
| # hpsd is started by udev |
| stop on stopping boot-services |
| expect fork |
| respawn |
| respawn limit 10 600 |
| # upstart will not restart us when we exit with this code |
| # hpsd exit(5)s only when an update fails to install |
| normal exit 5 |
| |
| env RESPAWN_DELAY=5 |
| # Give the post-stop process a bit more than 5 seconds to terminate. |
| kill timeout 8 |
| |
| # Make hpsd killable, because if it has a leak it's better to |
| # restart it than to OOM-panic. |
| oom score -100 |
| |
| pre-start script |
| mkdir -m 0700 -p /var/lib/hpsd/metrics |
| chown -R hpsd:hpsd /var/lib/hpsd |
| end script |
| |
| post-stop script |
| # If post-stop is somehow killed for timeout, treat that as a clean exit. |
| trap "exit 0" TERM |
| |
| goal=$(status "${UPSTART_JOB}" | awk '{split($2, a, "/"); print a[1]}') |
| if [ "${goal}" = "start" ]; then |
| # Sleep only if it's respawning, so we don't need to wait when doing `stop` |
| # in tests or manually. |
| sleep "${RESPAWN_DELAY}" |
| fi |
| end script |
| |
| exec minijail0 --config /usr/share/minijail/hpsd.conf \ |
| -- /usr/sbin/hpsd \ |
| --version_file=/usr/lib/firmware/hps/mcu_stage1.version.txt \ |
| --mcu_fw_image=/usr/lib/firmware/hps/mcu_stage1.bin.xz \ |
| --fpga_bitstream=/usr/lib/firmware/hps/fpga_bitstream.bin.xz \ |
| --fpga_app_image=/usr/lib/firmware/hps/fpga_application.bin.xz \ |
| $HPS_HW_FLAGS |