# Copyright (c) 2019-2023, The Linux Foundation. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#     * Redistributions of source code must retain the above copyright
#       notice, this list of conditions and the following disclaimer.
#     * Redistributions in binary form must reproduce the above
#       copyright notice, this list of conditions and the following
#       disclaimer in the documentation and/or other materials provided
#       with the distribution.
#     * Neither the name of The Linux Foundation nor the names of its
#       contributors may be used to endorse or promote products derived
#       from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
# ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
#

on early-init
    # sec_debug.ko - 1st stage
    chown system system /sys/module/sec_debug/parameters/dump_sink
    chmod 0640 /sys/module/sec_debug/parameters/dump_sink
    chown system system /sys/module/sec_debug/parameters/reboot_multicmd
    chmod 0400 /sys/module/sec_debug/parameters/reboot_multicmd

on init
    symlink /dev/block/bootdevice/by-name/param /dev/block/param

on late-init

on post-fs

on late-fs

on post-fs-data

on boot
    # sec_qc_user_reset.ko
    chown system system /proc/auto_comment
    chmod 0400 /proc/auto_comment
    chown system system /proc/reset_history
    chmod 0400 /proc/reset_history
    chown system system /proc/reset_klog
    chmod 0400 /proc/reset_klog
    chown system system /proc/reset_reason
    chmod 0440 /proc/reset_reason
    chown system system /proc/reset_rwc
    chmod 0440 /proc/reset_rwc
    chown system system /proc/reset_summary
    chmod 0400 /proc/reset_summary
    chown system system /proc/reset_tzlog
    chmod 0400 /proc/reset_tzlog
    chown system system /proc/store_lastkmsg
    chmod 0440 /proc/store_lastkmsg
    chown system system /sys/class/sec/sec_debug/recovery_cause
    chmod 0660 /sys/class/sec/sec_debug/recovery_cause
    chown system system /sys/class/sec/sec_debug/FMM_lock
    chmod 0660 /sys/class/sec/sec_debug/FMM_lock

    # sec_qc_hw_param.ko
    chown system system /proc/extra
    chmod 0440 /proc/extra
    chown system system /sys/class/sec/sec_hw_param/ap_health
    chmod 0600 /sys/class/sec/sec_hw_param/ap_health
    chown system system /sys/class/sec/sec_hw_param/ap_info
    chmod 0400 /sys/class/sec/sec_hw_param/ap_info
    chown system system /sys/class/sec/sec_hw_param/ddr_info
    chmod 0400 /sys/class/sec/sec_hw_param/ddr_info
    chown system system /sys/class/sec/sec_hw_param/extra_info
    chmod 0400 /sys/class/sec/sec_hw_param/extra_info
    chown system system /sys/class/sec/sec_hw_param/extrb_info
    chmod 0400 /sys/class/sec/sec_hw_param/extrb_info
    chown system system /sys/class/sec/sec_hw_param/extrc_info
    chmod 0400 /sys/class/sec/sec_hw_param/extrc_info
    chown system system /sys/class/sec/sec_hw_param/extrm_info
    chmod 0400 /sys/class/sec/sec_hw_param/extrm_info
    chown system system /sys/class/sec/sec_hw_param/extrt_info
    chmod 0400 /sys/class/sec/sec_hw_param/extrt_info
    chown system system /sys/class/sec/sec_hw_param/eye_rd_info
    chmod 0400 /sys/class/sec/sec_hw_param/eye_rd_info
    chown system system /sys/class/sec/sec_hw_param/last_dcvs
    chmod 0400 /sys/class/sec/sec_hw_param/last_dcvs

    # sec_qc_rdx_bootdev.ko
    chown system system /proc/rdx_bootdev
    chmod 0220 /proc/rdx_bootdev

    # PCIe
    chown radio system /sys/class/sec/pcie-wifi/pcie_l1ss_ctrl

    # sec_reloc_gpio.ko - factory mode only
    chown root system /sys/class/sec/gpio/check_requested_gpio
    chmod 0664 /sys/class/sec/gpio/check_requested_gpio

on shutdown

# service definition

# on property triggers
