commit 935d94693e1cf215660401688ddbb4afd27dd986 Author: TheMalachite Date: Wed Jun 30 12:05:05 2021 +0200 renoir: Initial TWRP device tree diff --git a/Android.bp b/Android.bp new file mode 100644 index 0000000..dfecee0 --- /dev/null +++ b/Android.bp @@ -0,0 +1,3 @@ +soong_namespace { + imports: ["hardware/qcom-caf/bootctrl"], +} diff --git a/Android.mk b/Android.mk new file mode 100644 index 0000000..7f1c970 --- /dev/null +++ b/Android.mk @@ -0,0 +1,23 @@ +# +# Copyright (C) 2021 The TWRP Open Source Project +# +# 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. +# + +LOCAL_PATH := $(call my-dir) + +ifeq ($(TARGET_DEVICE), renoir) +subdir_makefiles=$(call first-makefiles-under,$(LOCAL_PATH)) +$(foreach mk,$(subdir_makefiles),$(info including $(mk) ...)$(eval include $(mk))) + +endif diff --git a/AndroidProducts.mk b/AndroidProducts.mk new file mode 100644 index 0000000..c49d396 --- /dev/null +++ b/AndroidProducts.mk @@ -0,0 +1,18 @@ +# +# Copyright (C) 2021 The TWRP Open Source Project +# +# 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. +# + +PRODUCT_MAKEFILES := \ + $(LOCAL_DIR)/twrp_renoir.mk diff --git a/BoardConfig.mk b/BoardConfig.mk new file mode 100644 index 0000000..cadf8b9 --- /dev/null +++ b/BoardConfig.mk @@ -0,0 +1,131 @@ +# +# Copyright (C) 2021 The TWRP Open Source Project +# +# 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. +# + +DEVICE_PATH := device/xiaomi/renoir + +# For building with minimal manifest +ALLOW_MISSING_DEPENDENCIES := true + +# Architecture +TARGET_ARCH := arm64 +TARGET_ARCH_VARIANT := armv8-a +TARGET_CPU_ABI := arm64-v8a +TARGET_CPU_ABI2 := +TARGET_CPU_VARIANT := generic +TARGET_CPU_VARIANT_RUNTIME := cortex-a55 + +TARGET_2ND_ARCH := arm +TARGET_2ND_ARCH_VARIANT := armv8-2a +TARGET_2ND_CPU_ABI := armeabi-v7a +TARGET_2ND_CPU_ABI2 := armeabi +TARGET_2ND_CPU_VARIANT := generic +TARGET_2ND_CPU_VARIANT_RUNTIME := cortex-a55 + +# APEX image +DEXPREOPT_GENERATE_APEX_IMAGE := true + +# Assert +TARGET_OTA_ASSERT_DEVICE := renoir + +# A/B +AB_OTA_UPDATER := true + +AB_OTA_PARTITIONS := \ + boot \ + dtbo \ + odm \ + product \ + system \ + system_ext \ + vbmeta \ + vbmeta_system \ + vendor \ + vendor_boot + +# Kernel +BOARD_KERNEL_BASE := 0x00000000 +BOARD_KERNEL_IMAGE_NAME := Image +BOARD_KERNEL_PAGESIZE := 4096 + +BOARD_INCLUDE_DTB_IN_BOOTIMG := true +BOARD_KERNEL_SEPARATED_DTBO := true +BOARD_BOOT_HEADER_VERSION := 3 +BOARD_MKBOOTIMG_ARGS += --header_version $(BOARD_BOOT_HEADER_VERSION) + +BOARD_KERNEL_CMDLINE += androidboot.console=ttyMSM0 +BOARD_KERNEL_CMDLINE += androidboot.hardware=qcom +BOARD_KERNEL_CMDLINE += androidboot.memcg=1 +BOARD_KERNEL_CMDLINE += androidboot.selinux=permissive +BOARD_KERNEL_CMDLINE += androidboot.usbcontroller=a600000.dwc3 +BOARD_KERNEL_CMDLINE += cgroup.memory=nokmem,nosocket +BOARD_KERNEL_CMDLINE += console=ttyMSM0,115200n8 +BOARD_KERNEL_CMDLINE += earlycon=msm_geni_serial,0x880000 +BOARD_KERNEL_CMDLINE += ip6table_raw.raw_before_defrag=1 +BOARD_KERNEL_CMDLINE += iptable_raw.raw_before_defrag=1 +BOARD_KERNEL_CMDLINE += lpm_levels.sleep_disabled=1 +BOARD_KERNEL_CMDLINE += msm_rtb.filter=0x237 +BOARD_KERNEL_CMDLINE += pcie_ports=compat +BOARD_KERNEL_CMDLINE += service_locator.enable=1 +BOARD_KERNEL_CMDLINE += swiotlb=0 +BOARD_KERNEL_CMDLINE += video=vfb:640x400,bpp=32,memsize=3072000 + +KERNEL_LD := LD=ld.lld +TARGET_KERNEL_ADDITIONAL_FLAGS := DTC_EXT=$(shell pwd)/prebuilts/misc/linux-x86/dtc/dtc +TARGET_KERNEL_CLANG_COMPILE := true +TARGET_KERNEL_CONFIG := vendor/renoir-qgki_defconfig +TARGET_KERNEL_SOURCE := kernel/xiaomi/renoir + +# Metadata +BOARD_USES_METADATA_PARTITION := true +BOARD_USES_QCOM_FBE_DECRYPTION := true + +# Partitions +BOARD_FLASH_BLOCK_SIZE := 131072 +BOARD_BOOTIMAGE_PARTITION_SIZE := 201326592 +BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE := 100663296 + +BOARD_SUPER_PARTITION_GROUPS := qti_dynamic_partitions +BOARD_SUPER_PARTITION_SIZE := 9126805504 +BOARD_QTI_DYNAMIC_PARTITIONS_PARTITION_LIST := odm product system system_ext vendor +BOARD_QTI_DYNAMIC_PARTITIONS_SIZE := 9122611200 # (BOARD_SUPER_PARTITION_SIZE - 4MB) + +BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE := ext4 +TARGET_COPY_OUT_VENDOR := vendor + +# Platform +BOARD_USES_QCOM_HARDWARE := true +TARGET_BOARD_PLATFORM := lahaina + +# Properties +TARGET_ODM_PROP += $(DEVICE_PATH)/odm.prop +TARGET_SYSTEM_PROP += $(DEVICE_PATH)/system.prop +TARGET_VENDOR_PROP += $(DEVICE_PATH)/vendor.prop + +# Recovery +BOARD_USES_RECOVERY_AS_BOOT := true +TARGET_RECOVERY_FSTAB := $(DEVICE_PATH)/recovery.fstab +TARGET_RECOVERY_PIXEL_FORMAT := "RGBX_8888" +TARGET_USERIMAGES_USE_EXT4 := true +TARGET_USERIMAGES_USE_F2FS := true + +# Verified Boot +BOARD_AVB_ENABLE := true +BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --flags 3 +BOARD_AVB_VBMETA_SYSTEM := system system_ext product +BOARD_AVB_VBMETA_SYSTEM_KEY_PATH := external/avb/test/data/testkey_rsa2048.pem +BOARD_AVB_VBMETA_SYSTEM_ALGORITHM := SHA256_RSA2048 +BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX := $(PLATFORM_SECURITY_PATCH_TIMESTAMP) +BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX_LOCATION := 1 diff --git a/bootctrl/Android.bp b/bootctrl/Android.bp new file mode 100644 index 0000000..eb31f66 --- /dev/null +++ b/bootctrl/Android.bp @@ -0,0 +1,28 @@ +// +// Copyright (C) 2018 The Android Open Source Project +// +// 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. +// + +cc_library { + name: "bootctrl.lahaina", + defaults: ["bootctrl_hal_defaults"], + static_libs: ["libgptutils.renoir"], +} + +cc_library_shared { + name: "android.hardware.boot@1.1-impl-qti", + stem: "android.hardware.boot@1.0-impl-1.1-qti", + defaults: ["android.hardware.boot@1.1-impl-qti_defaults"], + static_libs: ["libgptutils.renoir"], +} diff --git a/device.mk b/device.mk new file mode 100644 index 0000000..0426e7f --- /dev/null +++ b/device.mk @@ -0,0 +1,123 @@ +# +# Copyright (C) 2021 The TWRP Open Source Project +# +# 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. +# + +# Enable project quotas and casefolding for emulated storage without sdcardfs +$(call inherit-product, $(SRC_TARGET_DIR)/product/emulated_storage.mk) + +# Enable updating of APEXes +$(call inherit-product, $(SRC_TARGET_DIR)/product/updatable_apex.mk) + +# Enable virtual A/B OTA +$(call inherit-product, $(SRC_TARGET_DIR)/product/virtual_ab_ota.mk) + +# Installs gsi keys into ramdisk, to boot a developer GSI with verified boot. +$(call inherit-product, $(SRC_TARGET_DIR)/product/gsi_keys.mk) + +LOCAL_PATH := device/xiaomi/renoir + +# API +PRODUCT_SHIPPING_API_LEVEL := 30 + +# A/B +AB_OTA_POSTINSTALL_CONFIG += \ + RUN_POSTINSTALL_system=true \ + POSTINSTALL_PATH_system=system/bin/otapreopt_script \ + FILESYSTEM_TYPE_system=ext4 \ + POSTINSTALL_OPTIONAL_system=true + +PRODUCT_PACKAGES += \ + otapreopt_script + +# Boot control HAL +PRODUCT_PACKAGES += \ + android.hardware.boot@1.1-impl-qti.recovery \ + bootctrl.lahaina.recovery + +PRODUCT_PACKAGES_DEBUG += \ + bootctl + +# Dynamic partitions +PRODUCT_USE_DYNAMIC_PARTITIONS := true + +# Fastbootd +PRODUCT_PACKAGES += \ + android.hardware.fastboot@1.0-impl-mock \ + fastbootd + +# Screen +TARGET_SCREEN_HEIGHT := 2400 +TARGET_SCREEN_WIDTH := 1080 + +# Soong namespaces +PRODUCT_SOONG_NAMESPACES += \ + $(LOCAL_PATH) \ + hardware/qcom-caf/bootctrl + +# Update engine +PRODUCT_PACKAGES += \ + update_engine \ + update_engine_sideload \ + update_verifier + +PRODUCT_PACKAGES_DEBUG += \ + update_engine_client + +# TWRP Configuration +TW_THEME := portrait_hdpi +RECOVERY_SDCARD_ON_DATA := true +TARGET_RECOVERY_QCOM_RTC_FIX := true +TW_EXCLUDE_DEFAULT_USB_INIT := true +TW_EXTRA_LANGUAGES := true +TW_INCLUDE_NTFS_3G := true +TW_USE_TOOLBOX := true +TW_INCLUDE_RESETPROP := true +TW_INCLUDE_REPACKTOOLS := true +TW_INPUT_BLACKLIST := "hbtp_vm" +TW_BRIGHTNESS_PATH := "/sys/class/backlight/panel0-backlight/brightness" +TW_Y_OFFSET := 80 +TW_H_OFFSET := -80 +TWRP_INCLUDE_LOGCAT := true +TARGET_USES_LOGD := true +TARGET_USES_MKE2FS := true +TW_NO_SCREEN_BLANK := true +TW_EXCLUDE_APEX := true + +PLATFORM_SECURITY_PATCH := 2099-12-31 +VENDOR_SECURITY_PATCH := 2099-12-31 +PLATFORM_VERSION := 20.1.0 +TW_INCLUDE_CRYPTO := true +TW_INCLUDE_CRYPTO_FBE := true +TW_INCLUDE_FBE_METADATA_DECRYPT := true + +TARGET_RECOVERY_DEVICE_MODULES += \ + libandroidicu \ + libdisplayconfig.qti \ + libion \ + vendor.display.config@1.0 \ + vendor.display.config@2.0 + +RECOVERY_LIBRARY_SOURCE_FILES += \ + $(TARGET_OUT_SHARED_LIBRARIES)/libion.so \ + $(TARGET_OUT_SYSTEM_EXT_SHARED_LIBRARIES)/libdisplayconfig.qti.so \ + $(TARGET_OUT_SYSTEM_EXT_SHARED_LIBRARIES)/vendor.display.config@1.0.so \ + $(TARGET_OUT_SYSTEM_EXT_SHARED_LIBRARIES)/vendor.display.config@2.0.so + +PRODUCT_COPY_FILES += \ + $(OUT_DIR)/target/product/renoir/obj/SHARED_LIBRARIES/libandroidicu_intermediates/libandroidicu.so:$(TARGET_COPY_OUT_RECOVERY)/root/system/lib64/libandroidicu.so + +PRODUCT_PACKAGES += \ + qcom_decrypt \ + qcom_decrypt_fbe diff --git a/gpt-utils/Android.bp b/gpt-utils/Android.bp new file mode 100644 index 0000000..f9bd0a7 --- /dev/null +++ b/gpt-utils/Android.bp @@ -0,0 +1,42 @@ +// +// Copyright (C) 2018 The Android Open Source Project +// +// 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. +// + + +cc_library { + name: "libgptutils.renoir", + vendor: true, + recovery_available: true, + shared_libs: [ + "libcutils", + "liblog", + "libz", + ], + cflags: [ + "-Wall", + "-Werror", + "-Wno-unused-parameter", + "-D_GENERIC_KERNEL_HEADERS", + ], + srcs: [ + "gpt-utils.cpp", + "recovery-ufs-bsg.cpp", + ], + owner: "qti", + header_libs: [ + "generated_kernel_headers", + ], + export_include_dirs: ["."], +} diff --git a/gpt-utils/gpt-utils.cpp b/gpt-utils/gpt-utils.cpp new file mode 100644 index 0000000..3bb489e --- /dev/null +++ b/gpt-utils/gpt-utils.cpp @@ -0,0 +1,1520 @@ +/* + * Copyright (c) 2013,2016,2020 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. + */ + +#define _LARGEFILE64_SOURCE /* enable lseek64() */ + +/****************************************************************************** + * INCLUDE SECTION + ******************************************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifndef __STDC_FORMAT_MACROS +#define __STDC_FORMAT_MACROS +#endif +#include + + +#define LOG_TAG "gpt-utils" +#include +#include +#include "gpt-utils.h" +#include +#include + + +/****************************************************************************** + * DEFINE SECTION + ******************************************************************************/ +#define BLK_DEV_FILE "/dev/block/mmcblk0" +/* list the names of the backed-up partitions to be swapped */ +/* extension used for the backup partitions - tzbak, abootbak, etc. */ +#define BAK_PTN_NAME_EXT "bak" +#define XBL_PRIMARY "/dev/block/bootdevice/by-name/xbl" +#define XBL_BACKUP "/dev/block/bootdevice/by-name/xblbak" +#define XBL_AB_PRIMARY "/dev/block/bootdevice/by-name/xbl_a" +#define XBL_AB_SECONDARY "/dev/block/bootdevice/by-name/xbl_b" +/* GPT defines */ +#define MAX_LUNS 26 +//This will allow us to get the root lun path from the path to the partition. +//i.e: from /dev/block/sdaXXX get /dev/block/sda. The assumption here is that +//the boot critical luns lie between sda to sdz which is acceptable because +//only user added external disks,etc would lie beyond that limit which do not +//contain partitions that interest us here. +#define PATH_TRUNCATE_LOC (sizeof("/dev/block/sda") - 1) + +//From /dev/block/sda get just sda +#define LUN_NAME_START_LOC (sizeof("/dev/block/") - 1) +#define BOOT_LUN_A_ID 1 +#define BOOT_LUN_B_ID 2 +/****************************************************************************** + * MACROS + ******************************************************************************/ + + +#define GET_4_BYTES(ptr) ((uint32_t) *((uint8_t *)(ptr)) | \ + ((uint32_t) *((uint8_t *)(ptr) + 1) << 8) | \ + ((uint32_t) *((uint8_t *)(ptr) + 2) << 16) | \ + ((uint32_t) *((uint8_t *)(ptr) + 3) << 24)) + +#define GET_8_BYTES(ptr) ((uint64_t) *((uint8_t *)(ptr)) | \ + ((uint64_t) *((uint8_t *)(ptr) + 1) << 8) | \ + ((uint64_t) *((uint8_t *)(ptr) + 2) << 16) | \ + ((uint64_t) *((uint8_t *)(ptr) + 3) << 24) | \ + ((uint64_t) *((uint8_t *)(ptr) + 4) << 32) | \ + ((uint64_t) *((uint8_t *)(ptr) + 5) << 40) | \ + ((uint64_t) *((uint8_t *)(ptr) + 6) << 48) | \ + ((uint64_t) *((uint8_t *)(ptr) + 7) << 56)) + +#define PUT_4_BYTES(ptr, y) *((uint8_t *)(ptr)) = (y) & 0xff; \ + *((uint8_t *)(ptr) + 1) = ((y) >> 8) & 0xff; \ + *((uint8_t *)(ptr) + 2) = ((y) >> 16) & 0xff; \ + *((uint8_t *)(ptr) + 3) = ((y) >> 24) & 0xff; + +/****************************************************************************** + * TYPES + ******************************************************************************/ +using namespace std; +enum gpt_state { + GPT_OK = 0, + GPT_BAD_SIGNATURE, + GPT_BAD_CRC +}; +//List of LUN's containing boot critical images. +//Required in the case of UFS devices +struct update_data { + char lun_list[MAX_LUNS][PATH_MAX]; + uint32_t num_valid_entries; +}; + +int32_t set_boot_lun(char *sg_dev,uint8_t boot_lun_id); +/****************************************************************************** + * FUNCTIONS + ******************************************************************************/ +/** + * ========================================================================== + * + * \brief Read/Write len bytes from/to block dev + * + * \param [in] fd block dev file descriptor (returned from open) + * \param [in] rw RW flag: 0 - read, != 0 - write + * \param [in] offset block dev offset [bytes] - RW start position + * \param [in] buf Pointer to the buffer containing the data + * \param [in] len RW size in bytes. Buf must be at least that big + * + * \return 0 on success + * + * ========================================================================== + */ +static int blk_rw(int fd, int rw, int64_t offset, uint8_t *buf, unsigned len) +{ + int r; + + if (lseek64(fd, offset, SEEK_SET) < 0) { + fprintf(stderr, "block dev lseek64 %" PRIi64 " failed: %s\n", offset, + strerror(errno)); + return -1; + } + + if (rw) + r = write(fd, buf, len); + else + r = read(fd, buf, len); + + if (r < 0) + fprintf(stderr, "block dev %s failed: %s\n", rw ? "write" : "read", + strerror(errno)); + else + r = 0; + + return r; +} + + + +/** + * ========================================================================== + * + * \brief Search within GPT for partition entry with the given name + * or it's backup twin (name-bak). + * + * \param [in] ptn_name Partition name to seek + * \param [in] pentries_start Partition entries array start pointer + * \param [in] pentries_end Partition entries array end pointer + * \param [in] pentry_size Single partition entry size [bytes] + * + * \return First partition entry pointer that matches the name or NULL + * + * ========================================================================== + */ +static uint8_t *gpt_pentry_seek(const char *ptn_name, + const uint8_t *pentries_start, + const uint8_t *pentries_end, + uint32_t pentry_size) +{ + char *pentry_name; + unsigned len = strlen(ptn_name); + unsigned i; + char name8[MAX_GPT_NAME_SIZE] = {0}; // initialize with null + + for (pentry_name = (char *) (pentries_start + PARTITION_NAME_OFFSET); + pentry_name < (char *) pentries_end; + pentry_name += pentry_size) { + + /* Partition names in GPT are UTF-16 - ignoring UTF-16 2nd byte */ + for (i = 0; i < sizeof(name8) / 2; i++) + name8[i] = pentry_name[i * 2]; + name8[i] = '\0'; + + if (!strncmp(ptn_name, name8, len)) { + if (name8[len] == 0 || !strcmp(&name8[len], BAK_PTN_NAME_EXT)) + return (uint8_t *) (pentry_name - PARTITION_NAME_OFFSET); + } + } + + return NULL; +} + + + +/** + * ========================================================================== + * + * \brief Swaps boot chain in GPT partition entries array + * + * \param [in] pentries_start Partition entries array start + * \param [in] pentries_end Partition entries array end + * \param [in] pentry_size Single partition entry size + * + * \return 0 on success, 1 if no backup partitions found + * + * ========================================================================== + */ +static int gpt_boot_chain_swap(const uint8_t *pentries_start, + const uint8_t *pentries_end, + uint32_t pentry_size) +{ + const char ptn_swap_list[][MAX_GPT_NAME_SIZE] = { PTN_SWAP_LIST }; + + int backup_not_found = 1; + unsigned i; + + for (i = 0; i < ARRAY_SIZE(ptn_swap_list); i++) { + uint8_t *ptn_entry; + uint8_t *ptn_bak_entry; + uint8_t ptn_swap[PTN_ENTRY_SIZE]; + //Skip the xbl partition on UFS devices. That is handled + //seperately. + if (gpt_utils_is_ufs_device() && !strncmp(ptn_swap_list[i], + PTN_XBL, + strlen(PTN_XBL))) + continue; + + ptn_entry = gpt_pentry_seek(ptn_swap_list[i], pentries_start, + pentries_end, pentry_size); + if (ptn_entry == NULL) + continue; + + ptn_bak_entry = gpt_pentry_seek(ptn_swap_list[i], + ptn_entry + pentry_size, pentries_end, pentry_size); + if (ptn_bak_entry == NULL) { + fprintf(stderr, "'%s' partition not backup - skip safe update\n", + ptn_swap_list[i]); + continue; + } + + /* swap primary <-> backup partition entries */ + memcpy(ptn_swap, ptn_entry, PTN_ENTRY_SIZE); + memcpy(ptn_entry, ptn_bak_entry, PTN_ENTRY_SIZE); + memcpy(ptn_bak_entry, ptn_swap, PTN_ENTRY_SIZE); + backup_not_found = 0; + } + + return backup_not_found; +} + + + +/** + * ========================================================================== + * + * \brief Sets secondary GPT boot chain + * + * \param [in] fd block dev file descriptor + * \param [in] boot Boot chain to switch to + * + * \return 0 on success + * + * ========================================================================== + */ +static int gpt2_set_boot_chain(int fd, enum boot_chain boot) +{ + int64_t gpt2_header_offset; + uint64_t pentries_start_offset; + uint32_t gpt_header_size; + uint32_t pentry_size; + uint32_t pentries_array_size; + + uint8_t *gpt_header = NULL; + uint8_t *pentries = NULL; + uint32_t crc; + uint32_t crc_zero; + uint32_t blk_size = 0; + int r; + + + crc_zero = crc32(0L, Z_NULL, 0); + if (ioctl(fd, BLKSSZGET, &blk_size) != 0) { + fprintf(stderr, "Failed to get GPT device block size: %s\n", + strerror(errno)); + r = -1; + goto EXIT; + } + gpt_header = (uint8_t*)malloc(blk_size); + if (!gpt_header) { + fprintf(stderr, "Failed to allocate memory to hold GPT block\n"); + r = -1; + goto EXIT; + } + gpt2_header_offset = lseek64(fd, 0, SEEK_END) - blk_size; + if (gpt2_header_offset < 0) { + fprintf(stderr, "Getting secondary GPT header offset failed: %s\n", + strerror(errno)); + r = -1; + goto EXIT; + } + + /* Read primary GPT header from block dev */ + r = blk_rw(fd, 0, blk_size, gpt_header, blk_size); + + if (r) { + fprintf(stderr, "Failed to read primary GPT header from blk dev\n"); + goto EXIT; + } + pentries_start_offset = + GET_8_BYTES(gpt_header + PENTRIES_OFFSET) * blk_size; + pentry_size = GET_4_BYTES(gpt_header + PENTRY_SIZE_OFFSET); + pentries_array_size = + GET_4_BYTES(gpt_header + PARTITION_COUNT_OFFSET) * pentry_size; + + pentries = (uint8_t *) calloc(1, pentries_array_size); + if (pentries == NULL) { + fprintf(stderr, + "Failed to alloc memory for GPT partition entries array\n"); + r = -1; + goto EXIT; + } + /* Read primary GPT partititon entries array from block dev */ + r = blk_rw(fd, 0, pentries_start_offset, pentries, pentries_array_size); + if (r) + goto EXIT; + + crc = crc32(crc_zero, pentries, pentries_array_size); + if (GET_4_BYTES(gpt_header + PARTITION_CRC_OFFSET) != crc) { + fprintf(stderr, "Primary GPT partition entries array CRC invalid\n"); + r = -1; + goto EXIT; + } + + /* Read secondary GPT header from block dev */ + r = blk_rw(fd, 0, gpt2_header_offset, gpt_header, blk_size); + if (r) + goto EXIT; + + gpt_header_size = GET_4_BYTES(gpt_header + HEADER_SIZE_OFFSET); + pentries_start_offset = + GET_8_BYTES(gpt_header + PENTRIES_OFFSET) * blk_size; + + if (boot == BACKUP_BOOT) { + r = gpt_boot_chain_swap(pentries, pentries + pentries_array_size, + pentry_size); + if (r) + goto EXIT; + } + + crc = crc32(crc_zero, pentries, pentries_array_size); + PUT_4_BYTES(gpt_header + PARTITION_CRC_OFFSET, crc); + + /* header CRC is calculated with this field cleared */ + PUT_4_BYTES(gpt_header + HEADER_CRC_OFFSET, 0); + crc = crc32(crc_zero, gpt_header, gpt_header_size); + PUT_4_BYTES(gpt_header + HEADER_CRC_OFFSET, crc); + + /* Write the modified GPT header back to block dev */ + r = blk_rw(fd, 1, gpt2_header_offset, gpt_header, blk_size); + if (!r) + /* Write the modified GPT partititon entries array back to block dev */ + r = blk_rw(fd, 1, pentries_start_offset, pentries, + pentries_array_size); + +EXIT: + if(gpt_header) + free(gpt_header); + if (pentries) + free(pentries); + return r; +} + +/** + * ========================================================================== + * + * \brief Checks GPT state (header signature and CRC) + * + * \param [in] fd block dev file descriptor + * \param [in] gpt GPT header to be checked + * \param [out] state GPT header state + * + * \return 0 on success + * + * ========================================================================== + */ +static int gpt_get_state(int fd, enum gpt_instance gpt, enum gpt_state *state) +{ + int64_t gpt_header_offset; + uint32_t gpt_header_size; + uint8_t *gpt_header = NULL; + uint32_t crc; + uint32_t crc_zero; + uint32_t blk_size = 0; + + *state = GPT_OK; + + crc_zero = crc32(0L, Z_NULL, 0); + if (ioctl(fd, BLKSSZGET, &blk_size) != 0) { + fprintf(stderr, "Failed to get GPT device block size: %s\n", + strerror(errno)); + goto error; + } + gpt_header = (uint8_t*)malloc(blk_size); + if (!gpt_header) { + fprintf(stderr, "gpt_get_state:Failed to alloc memory for header\n"); + goto error; + } + if (gpt == PRIMARY_GPT) + gpt_header_offset = blk_size; + else { + gpt_header_offset = lseek64(fd, 0, SEEK_END) - blk_size; + if (gpt_header_offset < 0) { + fprintf(stderr, "gpt_get_state:Seek to end of GPT part fail\n"); + goto error; + } + } + + if (blk_rw(fd, 0, gpt_header_offset, gpt_header, blk_size)) { + fprintf(stderr, "gpt_get_state: blk_rw failed\n"); + goto error; + } + if (memcmp(gpt_header, GPT_SIGNATURE, sizeof(GPT_SIGNATURE))) + *state = GPT_BAD_SIGNATURE; + gpt_header_size = GET_4_BYTES(gpt_header + HEADER_SIZE_OFFSET); + + crc = GET_4_BYTES(gpt_header + HEADER_CRC_OFFSET); + /* header CRC is calculated with this field cleared */ + PUT_4_BYTES(gpt_header + HEADER_CRC_OFFSET, 0); + if (crc32(crc_zero, gpt_header, gpt_header_size) != crc) + *state = GPT_BAD_CRC; + free(gpt_header); + return 0; +error: + if (gpt_header) + free(gpt_header); + return -1; +} + + + +/** + * ========================================================================== + * + * \brief Sets GPT header state (used to corrupt and fix GPT signature) + * + * \param [in] fd block dev file descriptor + * \param [in] gpt GPT header to be checked + * \param [in] state GPT header state to set (GPT_OK or GPT_BAD_SIGNATURE) + * + * \return 0 on success + * + * ========================================================================== + */ +static int gpt_set_state(int fd, enum gpt_instance gpt, enum gpt_state state) +{ + int64_t gpt_header_offset; + uint32_t gpt_header_size; + uint8_t *gpt_header = NULL; + uint32_t crc; + uint32_t crc_zero; + uint32_t blk_size = 0; + + crc_zero = crc32(0L, Z_NULL, 0); + if (ioctl(fd, BLKSSZGET, &blk_size) != 0) { + fprintf(stderr, "Failed to get GPT device block size: %s\n", + strerror(errno)); + goto error; + } + gpt_header = (uint8_t*)malloc(blk_size); + if (!gpt_header) { + fprintf(stderr, "Failed to alloc memory for gpt header\n"); + goto error; + } + if (gpt == PRIMARY_GPT) + gpt_header_offset = blk_size; + else { + gpt_header_offset = lseek64(fd, 0, SEEK_END) - blk_size; + if (gpt_header_offset < 0) { + fprintf(stderr, "Failed to seek to end of GPT device\n"); + goto error; + } + } + if (blk_rw(fd, 0, gpt_header_offset, gpt_header, blk_size)) { + fprintf(stderr, "Failed to r/w gpt header\n"); + goto error; + } + if (state == GPT_OK) + memcpy(gpt_header, GPT_SIGNATURE, sizeof(GPT_SIGNATURE)); + else if (state == GPT_BAD_SIGNATURE) + *gpt_header = 0; + else { + fprintf(stderr, "gpt_set_state: Invalid state\n"); + goto error; + } + + gpt_header_size = GET_4_BYTES(gpt_header + HEADER_SIZE_OFFSET); + + /* header CRC is calculated with this field cleared */ + PUT_4_BYTES(gpt_header + HEADER_CRC_OFFSET, 0); + crc = crc32(crc_zero, gpt_header, gpt_header_size); + PUT_4_BYTES(gpt_header + HEADER_CRC_OFFSET, crc); + + if (blk_rw(fd, 1, gpt_header_offset, gpt_header, blk_size)) { + fprintf(stderr, "gpt_set_state: blk write failed\n"); + goto error; + } + return 0; +error: + if(gpt_header) + free(gpt_header); + return -1; +} + +int get_scsi_node_from_bootdevice(const char *bootdev_path, + char *sg_node_path, + size_t buf_size) +{ + char sg_dir_path[PATH_MAX] = {0}; + char real_path[PATH_MAX] = {0}; + DIR *scsi_dir = NULL; + struct dirent *de; + int node_found = 0; + if (!bootdev_path || !sg_node_path) { + fprintf(stderr, "%s : invalid argument\n", + __func__); + goto error; + } + if (readlink(bootdev_path, real_path, sizeof(real_path) - 1) < 0) { + fprintf(stderr, "failed to resolve link for %s(%s)\n", + bootdev_path, + strerror(errno)); + goto error; + } + if(strlen(real_path) < PATH_TRUNCATE_LOC + 1){ + fprintf(stderr, "Unrecognized path :%s:\n", + real_path); + goto error; + } + //For the safe side in case there are additional partitions on + //the XBL lun we truncate the name. + real_path[PATH_TRUNCATE_LOC] = '\0'; + if(strlen(real_path) < LUN_NAME_START_LOC + 1){ + fprintf(stderr, "Unrecognized truncated path :%s:\n", + real_path); + goto error; + } + //This will give us /dev/block/sdb/device/scsi_generic + //which contains a file sgY whose name gives us the path + //to /dev/sgY which we return + snprintf(sg_dir_path, sizeof(sg_dir_path) - 1, + "/sys/block/%s/device/scsi_generic", + &real_path[LUN_NAME_START_LOC]); + scsi_dir = opendir(sg_dir_path); + if (!scsi_dir) { + fprintf(stderr, "%s : Failed to open %s(%s)\n", + __func__, + sg_dir_path, + strerror(errno)); + goto error; + } + while((de = readdir(scsi_dir))) { + if (de->d_name[0] == '.') + continue; + else if (!strncmp(de->d_name, "sg", 2)) { + snprintf(sg_node_path, + buf_size -1, + "/dev/%s", + de->d_name); + fprintf(stderr, "%s:scsi generic node is :%s:\n", + __func__, + sg_node_path); + node_found = 1; + break; + } + } + if(!node_found) { + fprintf(stderr,"%s: Unable to locate scsi generic node\n", + __func__); + goto error; + } + closedir(scsi_dir); + return 0; +error: + if (scsi_dir) + closedir(scsi_dir); + return -1; +} + + + +//Swtich betwieen using either the primary or the backup +//boot LUN for boot. This is required since UFS boot partitions +//cannot have a backup GPT which is what we use for failsafe +//updates of the other 'critical' partitions. This function will +//not be invoked for emmc targets and on UFS targets is only required +//to be invoked for XBL. +// +//The algorithm to do this is as follows: +//- Find the real block device(eg: /dev/block/sdb) that corresponds +// to the /dev/block/bootdevice/by-name/xbl(bak) symlink +// +//- Once we have the block device 'node' name(sdb in the above example) +// use this node to to locate the scsi generic device that represents +// it by checking the file /sys/block/sdb/device/scsi_generic/sgY +// +//- Once we locate sgY we call the query ioctl on /dev/sgy to switch +//the boot lun to either LUNA or LUNB +int gpt_utils_set_xbl_boot_partition(enum boot_chain chain) +{ + struct stat st; + ///sys/block/sdX/device/scsi_generic/ + char sg_dev_node[PATH_MAX] = {0}; + uint8_t boot_lun_id = 0; + const char *boot_dev = NULL; + + if (chain == BACKUP_BOOT) { + boot_lun_id = BOOT_LUN_B_ID; + if (!stat(XBL_BACKUP, &st)) + boot_dev = XBL_BACKUP; + else if (!stat(XBL_AB_SECONDARY, &st)) + boot_dev = XBL_AB_SECONDARY; + else { + fprintf(stderr, "%s: Failed to locate secondary xbl\n", + __func__); + goto error; + } + } else if (chain == NORMAL_BOOT) { + boot_lun_id = BOOT_LUN_A_ID; + if (!stat(XBL_PRIMARY, &st)) + boot_dev = XBL_PRIMARY; + else if (!stat(XBL_AB_PRIMARY, &st)) + boot_dev = XBL_AB_PRIMARY; + else { + fprintf(stderr, "%s: Failed to locate primary xbl\n", + __func__); + goto error; + } + } else { + fprintf(stderr, "%s: Invalid boot chain id\n", __func__); + goto error; + } + //We need either both xbl and xblbak or both xbl_a and xbl_b to exist at + //the same time. If not the current configuration is invalid. + if((stat(XBL_PRIMARY, &st) || + stat(XBL_BACKUP, &st)) && + (stat(XBL_AB_PRIMARY, &st) || + stat(XBL_AB_SECONDARY, &st))) { + fprintf(stderr, "%s:primary/secondary XBL prt not found(%s)\n", + __func__, + strerror(errno)); + goto error; + } + fprintf(stderr, "%s: setting %s lun as boot lun\n", + __func__, + boot_dev); + if (get_scsi_node_from_bootdevice(boot_dev, + sg_dev_node, + sizeof(sg_dev_node))) { + fprintf(stderr, "%s: Failed to get scsi node path for xblbak\n", + __func__); + goto error; + } + /* set boot lun using /dev/sg or /dev/ufs-bsg* */ + if (set_boot_lun(sg_dev_node, boot_lun_id)) { + fprintf(stderr, "%s: Failed to set xblbak as boot partition\n", + __func__); + goto error; + } + return 0; +error: + return -1; +} + +int gpt_utils_is_ufs_device() +{ + char bootdevice[PROPERTY_VALUE_MAX] = {0}; + property_get("ro.boot.bootdevice", bootdevice, "N/A"); + if (strlen(bootdevice) < strlen(".ufshc") + 1) + return 0; + return (!strncmp(&bootdevice[strlen(bootdevice) - strlen(".ufshc")], + ".ufshc", + sizeof(".ufshc"))); +} +//dev_path is the path to the block device that contains the GPT image that +//needs to be updated. This would be the device which holds one or more critical +//boot partitions and their backups. In the case of EMMC this function would +//be invoked only once on /dev/block/mmcblk1 since it holds the GPT image +//containing all the partitions For UFS devices it could potentially be +//invoked multiple times, once for each LUN containing critical image(s) and +//their backups +int prepare_partitions(enum boot_update_stage stage, const char *dev_path) +{ + int r = 0; + int fd = -1; + int is_ufs = gpt_utils_is_ufs_device(); + enum gpt_state gpt_prim, gpt_second; + enum boot_update_stage internal_stage; + struct stat xbl_partition_stat; + + if (!dev_path) { + fprintf(stderr, "%s: Invalid dev_path\n", + __func__); + r = -1; + goto EXIT; + } + fd = open(dev_path, O_RDWR); + if (fd < 0) { + fprintf(stderr, "%s: Opening '%s' failed: %s\n", + __func__, + BLK_DEV_FILE, + strerror(errno)); + r = -1; + goto EXIT; + } + r = gpt_get_state(fd, PRIMARY_GPT, &gpt_prim) || + gpt_get_state(fd, SECONDARY_GPT, &gpt_second); + if (r) { + fprintf(stderr, "%s: Getting GPT headers state failed\n", + __func__); + goto EXIT; + } + + /* These 2 combinations are unexpected and unacceptable */ + if (gpt_prim == GPT_BAD_CRC || gpt_second == GPT_BAD_CRC) { + fprintf(stderr, "%s: GPT headers CRC corruption detected, aborting\n", + __func__); + r = -1; + goto EXIT; + } + if (gpt_prim == GPT_BAD_SIGNATURE && gpt_second == GPT_BAD_SIGNATURE) { + fprintf(stderr, "%s: Both GPT headers corrupted, aborting\n", + __func__); + r = -1; + goto EXIT; + } + + /* Check internal update stage according GPT headers' state */ + if (gpt_prim == GPT_OK && gpt_second == GPT_OK) + internal_stage = UPDATE_MAIN; + else if (gpt_prim == GPT_BAD_SIGNATURE) + internal_stage = UPDATE_BACKUP; + else if (gpt_second == GPT_BAD_SIGNATURE) + internal_stage = UPDATE_FINALIZE; + else { + fprintf(stderr, "%s: Abnormal GPTs state: primary (%d), secondary (%d), " + "aborting\n", __func__, gpt_prim, gpt_second); + r = -1; + goto EXIT; + } + + /* Stage already set - ready for update, exitting */ + if ((int) stage == (int) internal_stage - 1) + goto EXIT; + /* Unexpected stage given */ + if (stage != internal_stage) { + r = -1; + goto EXIT; + } + + switch (stage) { + case UPDATE_MAIN: + if (is_ufs) { + if(stat(XBL_PRIMARY, &xbl_partition_stat)|| + stat(XBL_BACKUP, &xbl_partition_stat)){ + //Non fatal error. Just means this target does not + //use XBL but relies on sbl whose update is handled + //by the normal methods. + fprintf(stderr, "%s: xbl part not found(%s).Assuming sbl in use\n", + __func__, + strerror(errno)); + } else { + //Switch the boot lun so that backup boot LUN is used + r = gpt_utils_set_xbl_boot_partition(BACKUP_BOOT); + if(r){ + fprintf(stderr, "%s: Failed to set xbl backup partition as boot\n", + __func__); + goto EXIT; + } + } + } + //Fix up the backup GPT table so that it actually points to + //the backup copy of the boot critical images + fprintf(stderr, "%s: Preparing for primary partition update\n", + __func__); + r = gpt2_set_boot_chain(fd, BACKUP_BOOT); + if (r) { + if (r < 0) + fprintf(stderr, + "%s: Setting secondary GPT to backup boot failed\n", + __func__); + /* No backup partitions - do not corrupt GPT, do not flag error */ + else + r = 0; + goto EXIT; + } + //corrupt the primary GPT so that the backup(which now points to + //the backup boot partitions is used) + r = gpt_set_state(fd, PRIMARY_GPT, GPT_BAD_SIGNATURE); + if (r) { + fprintf(stderr, "%s: Corrupting primary GPT header failed\n", + __func__); + goto EXIT; + } + break; + case UPDATE_BACKUP: + if (is_ufs) { + if(stat(XBL_PRIMARY, &xbl_partition_stat)|| + stat(XBL_BACKUP, &xbl_partition_stat)){ + //Non fatal error. Just means this target does not + //use XBL but relies on sbl whose update is handled + //by the normal methods. + fprintf(stderr, "%s: xbl part not found(%s).Assuming sbl in use\n", + __func__, + strerror(errno)); + } else { + //Switch the boot lun so that backup boot LUN is used + r = gpt_utils_set_xbl_boot_partition(NORMAL_BOOT); + if(r) { + fprintf(stderr, "%s: Failed to set xbl backup partition as boot\n", + __func__); + goto EXIT; + } + } + } + //Fix the primary GPT header so that is used + fprintf(stderr, "%s: Preparing for backup partition update\n", + __func__); + r = gpt_set_state(fd, PRIMARY_GPT, GPT_OK); + if (r) { + fprintf(stderr, "%s: Fixing primary GPT header failed\n", + __func__); + goto EXIT; + } + //Corrupt the scondary GPT header + r = gpt_set_state(fd, SECONDARY_GPT, GPT_BAD_SIGNATURE); + if (r) { + fprintf(stderr, "%s: Corrupting secondary GPT header failed\n", + __func__); + goto EXIT; + } + break; + case UPDATE_FINALIZE: + //Undo the changes we had made in the UPDATE_MAIN stage so that the + //primary/backup GPT headers once again point to the same set of + //partitions + fprintf(stderr, "%s: Finalizing partitions\n", + __func__); + r = gpt2_set_boot_chain(fd, NORMAL_BOOT); + if (r < 0) { + fprintf(stderr, "%s: Setting secondary GPT to normal boot failed\n", + __func__); + goto EXIT; + } + + r = gpt_set_state(fd, SECONDARY_GPT, GPT_OK); + if (r) { + fprintf(stderr, "%s: Fixing secondary GPT header failed\n", + __func__); + goto EXIT; + } + break; + default:; + } + +EXIT: + if (fd >= 0) { + fsync(fd); + close(fd); + } + return r; +} + +int add_lun_to_update_list(char *lun_path, struct update_data *dat) +{ + uint32_t i = 0; + struct stat st; + if (!lun_path || !dat){ + fprintf(stderr, "%s: Invalid data", + __func__); + return -1; + } + if (stat(lun_path, &st)) { + fprintf(stderr, "%s: Unable to access %s. Skipping adding to list", + __func__, + lun_path); + return -1; + } + if (dat->num_valid_entries == 0) { + fprintf(stderr, "%s: Copying %s into lun_list[%d]\n", + __func__, + lun_path, + i); + strlcpy(dat->lun_list[0], lun_path, + PATH_MAX * sizeof(char)); + dat->num_valid_entries = 1; + } else { + for (i = 0; (i < dat->num_valid_entries) && + (dat->num_valid_entries < MAX_LUNS - 1); i++) { + //Check if the current LUN is not already part + //of the lun list + if (!strncmp(lun_path,dat->lun_list[i], + strlen(dat->lun_list[i]))) { + //LUN already in list..Return + return 0; + } + } + fprintf(stderr, "%s: Copying %s into lun_list[%d]\n", + __func__, + lun_path, + dat->num_valid_entries); + //Add LUN path lun list + strlcpy(dat->lun_list[dat->num_valid_entries], lun_path, + PATH_MAX * sizeof(char)); + dat->num_valid_entries++; + } + return 0; +} + +int prepare_boot_update(enum boot_update_stage stage) +{ + int is_ufs = gpt_utils_is_ufs_device(); + struct stat ufs_dir_stat; + struct update_data data; + int rcode = 0; + uint32_t i = 0; + int is_error = 0; + const char ptn_swap_list[][MAX_GPT_NAME_SIZE] = { PTN_SWAP_LIST }; + //Holds /dev/block/bootdevice/by-name/*bak entry + char buf[PATH_MAX] = {0}; + //Holds the resolved path of the symlink stored in buf + char real_path[PATH_MAX] = {0}; + + if (!is_ufs) { + //emmc device. Just pass in path to mmcblk0 + return prepare_partitions(stage, BLK_DEV_FILE); + } else { + //Now we need to find the list of LUNs over + //which the boot critical images are spread + //and set them up for failsafe updates.To do + //this we find out where the symlinks for the + //each of the paths under + ///dev/block/bootdevice/by-name/PTN_SWAP_LIST + //actually point to. + fprintf(stderr, "%s: Running on a UFS device\n", + __func__); + memset(&data, '\0', sizeof(struct update_data)); + for (i=0; i < ARRAY_SIZE(ptn_swap_list); i++) { + //XBL on UFS does not follow the convention + //of being loaded based on well known GUID'S. + //We take care of switching the UFS boot LUN + //explicitly later on. + if (!strncmp(ptn_swap_list[i], + PTN_XBL, + strlen(PTN_XBL))) + continue; + snprintf(buf, sizeof(buf), + "%s/%sbak", + BOOT_DEV_DIR, + ptn_swap_list[i]); + if (stat(buf, &ufs_dir_stat)) { + continue; + } + if (readlink(buf, real_path, sizeof(real_path) - 1) < 0) + { + fprintf(stderr, "%s: readlink error. Skipping %s", + __func__, + strerror(errno)); + } else { + if(strlen(real_path) < PATH_TRUNCATE_LOC + 1){ + fprintf(stderr, "Unknown path.Skipping :%s:\n", + real_path); + } else { + real_path[PATH_TRUNCATE_LOC] = '\0'; + add_lun_to_update_list(real_path, &data); + } + } + memset(buf, '\0', sizeof(buf)); + memset(real_path, '\0', sizeof(real_path)); + } + for (i=0; i < data.num_valid_entries; i++) { + fprintf(stderr, "%s: Preparing %s for update stage %d\n", + __func__, + data.lun_list[i], + stage); + rcode = prepare_partitions(stage, data.lun_list[i]); + if (rcode != 0) + { + fprintf(stderr, "%s: Failed to prepare %s.Continuing..\n", + __func__, + data.lun_list[i]); + is_error = 1; + } + } + } + if (is_error) + return -1; + return 0; +} + +//Given a parttion name(eg: rpm) get the path to the block device that +//represents the GPT disk the partition resides on. In the case of emmc it +//would be the default emmc dev(/dev/block/mmcblk0). In the case of UFS we look +//through the /dev/block/bootdevice/by-name/ tree for partname, and resolve +//the path to the LUN from there. +static int get_dev_path_from_partition_name(const char *partname, + char *buf, + size_t buflen) +{ + struct stat st; + char path[PATH_MAX] = {0}; + if (!partname || !buf || buflen < ((PATH_TRUNCATE_LOC) + 1)) { + ALOGE("%s: Invalid argument", __func__); + goto error; + } + if (gpt_utils_is_ufs_device()) { + //Need to find the lun that holds partition partname + snprintf(path, sizeof(path), + "%s/%s", + BOOT_DEV_DIR, + partname); + if (stat(path, &st)) { + goto error; + } + if (readlink(path, buf, buflen) < 0) + { + goto error; + } else { + buf[PATH_TRUNCATE_LOC] = '\0'; + } + } else { + snprintf(buf, buflen, BLK_DEV_FILE); + } + return 0; + +error: + return -1; +} + +int gpt_utils_get_partition_map(vector& ptn_list, + map>& partition_map) { + char devpath[PATH_MAX] = {'\0'}; + map>::iterator it; + if (ptn_list.size() < 1) { + fprintf(stderr, "%s: Invalid ptn list\n", __func__); + goto error; + } + //Go through the passed in list + for (uint32_t i = 0; i < ptn_list.size(); i++) + { + //Key in the map is the path to the device that holds the + //partition + if (get_dev_path_from_partition_name(ptn_list[i].c_str(), + devpath, + sizeof(devpath))) { + //Not necessarily an error. The partition may just + //not be present. + continue; + } + string path = devpath; + it = partition_map.find(path); + if (it != partition_map.end()) { + it->second.push_back(ptn_list[i]); + } else { + vector str_vec; + str_vec.push_back( ptn_list[i]); + partition_map.insert(pair> + (path, str_vec)); + } + memset(devpath, '\0', sizeof(devpath)); + } + return 0; +error: + return -1; +} + +//Get the block size of the disk represented by decsriptor fd +static uint32_t gpt_get_block_size(int fd) +{ + uint32_t block_size = 0; + if (fd < 0) { + ALOGE("%s: invalid descriptor", + __func__); + goto error; + } + if (ioctl(fd, BLKSSZGET, &block_size) != 0) { + ALOGE("%s: Failed to get GPT dev block size : %s", + __func__, + strerror(errno)); + goto error; + } + return block_size; +error: + return 0; +} + +//Write the GPT header present in the passed in buffer back to the +//disk represented by fd +static int gpt_set_header(uint8_t *gpt_header, int fd, + enum gpt_instance instance) +{ + uint32_t block_size = 0; + off64_t gpt_header_offset = 0; + if (!gpt_header || fd < 0) { + ALOGE("%s: Invalid arguments", + __func__); + goto error; + } + block_size = gpt_get_block_size(fd); + if (block_size == 0) { + ALOGE("%s: Failed to get block size", __func__); + goto error; + } + if (instance == PRIMARY_GPT) + gpt_header_offset = block_size; + else + gpt_header_offset = lseek64(fd, 0, SEEK_END) - block_size; + if (gpt_header_offset <= 0) { + ALOGE("%s: Failed to get gpt header offset",__func__); + goto error; + } + if (blk_rw(fd, 1, gpt_header_offset, gpt_header, block_size)) { + ALOGE("%s: Failed to write back GPT header", __func__); + goto error; + } + return 0; +error: + return -1; +} + +//Read out the GPT header for the disk that contains the partition partname +static uint8_t* gpt_get_header(const char *partname, enum gpt_instance instance) +{ + uint8_t* hdr = NULL; + char devpath[PATH_MAX] = {0}; + int64_t hdr_offset = 0; + uint32_t block_size = 0; + int fd = -1; + if (!partname) { + ALOGE("%s: Invalid partition name", __func__); + goto error; + } + if (get_dev_path_from_partition_name(partname, devpath, sizeof(devpath)) + != 0) { + ALOGE("%s: Failed to resolve path for %s", + __func__, + partname); + goto error; + } + fd = open(devpath, O_RDWR); + if (fd < 0) { + ALOGE("%s: Failed to open %s : %s", + __func__, + devpath, + strerror(errno)); + goto error; + } + block_size = gpt_get_block_size(fd); + if (block_size == 0) + { + ALOGE("%s: Failed to get gpt block size for %s", + __func__, + partname); + goto error; + } + + hdr = (uint8_t*)malloc(block_size); + if (!hdr) { + ALOGE("%s: Failed to allocate memory for gpt header", + __func__); + } + if (instance == PRIMARY_GPT) + hdr_offset = block_size; + else { + hdr_offset = lseek64(fd, 0, SEEK_END) - block_size; + } + if (hdr_offset < 0) { + ALOGE("%s: Failed to get gpt header offset", + __func__); + goto error; + } + if (blk_rw(fd, 0, hdr_offset, hdr, block_size)) { + ALOGE("%s: Failed to read GPT header from device", + __func__); + goto error; + } + close(fd); + return hdr; +error: + if (fd >= 0) + close(fd); + if (hdr) + free(hdr); + return NULL; +} + +//Returns the partition entry array based on the +//passed in buffer which contains the gpt header. +//The fd here is the descriptor for the 'disk' which +//holds the partition +static uint8_t* gpt_get_pentry_arr(uint8_t *hdr, int fd) +{ + uint64_t pentries_start = 0; + uint32_t pentry_size = 0; + uint32_t block_size = 0; + uint32_t pentries_arr_size = 0; + uint8_t *pentry_arr = NULL; + int rc = 0; + if (!hdr) { + ALOGE("%s: Invalid header", __func__); + goto error; + } + if (fd < 0) { + ALOGE("%s: Invalid fd", __func__); + goto error; + } + block_size = gpt_get_block_size(fd); + if (!block_size) { + ALOGE("%s: Failed to get gpt block size for", + __func__); + goto error; + } + pentries_start = GET_8_BYTES(hdr + PENTRIES_OFFSET) * block_size; + pentry_size = GET_4_BYTES(hdr + PENTRY_SIZE_OFFSET); + pentries_arr_size = + GET_4_BYTES(hdr + PARTITION_COUNT_OFFSET) * pentry_size; + pentry_arr = (uint8_t*)calloc(1, pentries_arr_size); + if (!pentry_arr) { + ALOGE("%s: Failed to allocate memory for partition array", + __func__); + goto error; + } + rc = blk_rw(fd, 0, + pentries_start, + pentry_arr, + pentries_arr_size); + if (rc) { + ALOGE("%s: Failed to read partition entry array", + __func__); + goto error; + } + return pentry_arr; +error: + if (pentry_arr) + free(pentry_arr); + return NULL; +} + +static int gpt_set_pentry_arr(uint8_t *hdr, int fd, uint8_t* arr) +{ + uint32_t block_size = 0; + uint64_t pentries_start = 0; + uint32_t pentry_size = 0; + uint32_t pentries_arr_size = 0; + int rc = 0; + if (!hdr || fd < 0 || !arr) { + ALOGE("%s: Invalid argument", __func__); + goto error; + } + block_size = gpt_get_block_size(fd); + if (!block_size) { + ALOGE("%s: Failed to get gpt block size for", + __func__); + goto error; + } + pentries_start = GET_8_BYTES(hdr + PENTRIES_OFFSET) * block_size; + pentry_size = GET_4_BYTES(hdr + PENTRY_SIZE_OFFSET); + pentries_arr_size = + GET_4_BYTES(hdr + PARTITION_COUNT_OFFSET) * pentry_size; + rc = blk_rw(fd, 1, + pentries_start, + arr, + pentries_arr_size); + if (rc) { + ALOGE("%s: Failed to read partition entry array", + __func__); + goto error; + } + return 0; +error: + return -1; +} + + + +//Allocate a handle used by calls to the "gpt_disk" api's +struct gpt_disk * gpt_disk_alloc() +{ + struct gpt_disk *disk; + disk = (struct gpt_disk *)malloc(sizeof(struct gpt_disk)); + if (!disk) { + ALOGE("%s: Failed to allocate memory", __func__); + goto end; + } + memset(disk, 0, sizeof(struct gpt_disk)); +end: + return disk; +} + +//Free previously allocated/initialized handle +void gpt_disk_free(struct gpt_disk *disk) +{ + if (!disk) + return; + if (disk->hdr) + free(disk->hdr); + if (disk->hdr_bak) + free(disk->hdr_bak); + if (disk->pentry_arr) + free(disk->pentry_arr); + if (disk->pentry_arr_bak) + free(disk->pentry_arr_bak); + free(disk); + return; +} + +//fills up the passed in gpt_disk struct with information about the +//disk represented by path dev. Returns 0 on success and -1 on error. +int gpt_disk_get_disk_info(const char *dev, struct gpt_disk *dsk) +{ + + struct gpt_disk *disk = NULL; + int fd = -1; + uint32_t gpt_header_size = 0; + uint32_t crc_zero; + + crc_zero = crc32(0L, Z_NULL, 0); + if (!dsk || !dev) { + ALOGE("%s: Invalid arguments", __func__); + goto error; + } + disk = dsk; + disk->hdr = gpt_get_header(dev, PRIMARY_GPT); + if (!disk->hdr) { + ALOGE("%s: Failed to get primary header", __func__); + goto error; + } + gpt_header_size = GET_4_BYTES(disk->hdr + HEADER_SIZE_OFFSET); + disk->hdr_crc = crc32(crc_zero, disk->hdr, gpt_header_size); + disk->hdr_bak = gpt_get_header(dev, SECONDARY_GPT); + if (!disk->hdr_bak) { + ALOGE("%s: Failed to get backup header", __func__); + goto error; + } + disk->hdr_bak_crc = crc32(crc_zero, disk->hdr_bak, gpt_header_size); + + //Descriptor for the block device. We will use this for further + //modifications to the partition table + if (get_dev_path_from_partition_name(dev, + disk->devpath, + sizeof(disk->devpath)) != 0) { + ALOGE("%s: Failed to resolve path for %s", + __func__, + dev); + goto error; + } + fd = open(disk->devpath, O_RDWR); + if (fd < 0) { + ALOGE("%s: Failed to open %s: %s", + __func__, + disk->devpath, + strerror(errno)); + goto error; + } + disk->pentry_arr = gpt_get_pentry_arr(disk->hdr, fd); + if (!disk->pentry_arr) { + ALOGE("%s: Failed to obtain partition entry array", + __func__); + goto error; + } + disk->pentry_arr_bak = gpt_get_pentry_arr(disk->hdr_bak, fd); + if (!disk->pentry_arr_bak) { + ALOGE("%s: Failed to obtain backup partition entry array", + __func__); + goto error; + } + disk->pentry_size = GET_4_BYTES(disk->hdr + PENTRY_SIZE_OFFSET); + disk->pentry_arr_size = + GET_4_BYTES(disk->hdr + PARTITION_COUNT_OFFSET) * + disk->pentry_size; + disk->pentry_arr_crc = GET_4_BYTES(disk->hdr + PARTITION_CRC_OFFSET); + disk->pentry_arr_bak_crc = GET_4_BYTES(disk->hdr_bak + + PARTITION_CRC_OFFSET); + disk->block_size = gpt_get_block_size(fd); + close(fd); + disk->is_initialized = GPT_DISK_INIT_MAGIC; + return 0; +error: + if (fd >= 0) + close(fd); + return -1; +} + +//Get pointer to partition entry from a allocated gpt_disk structure +uint8_t* gpt_disk_get_pentry(struct gpt_disk *disk, + const char *partname, + enum gpt_instance instance) +{ + uint8_t *ptn_arr = NULL; + if (!disk || !partname || disk->is_initialized != GPT_DISK_INIT_MAGIC) { + ALOGE("%s: Invalid argument",__func__); + goto error; + } + ptn_arr = (instance == PRIMARY_GPT) ? + disk->pentry_arr : disk->pentry_arr_bak; + return (gpt_pentry_seek(partname, ptn_arr, + ptn_arr + disk->pentry_arr_size , + disk->pentry_size)); +error: + return NULL; +} + +//Update CRC values for the various components of the gpt_disk +//structure. This function should be called after any of the fields +//have been updated before the structure contents are written back to +//disk. +int gpt_disk_update_crc(struct gpt_disk *disk) +{ + uint32_t gpt_header_size = 0; + uint32_t crc_zero; + crc_zero = crc32(0L, Z_NULL, 0); + if (!disk || (disk->is_initialized != GPT_DISK_INIT_MAGIC)) { + ALOGE("%s: invalid argument", __func__); + goto error; + } + //Recalculate the CRC of the primary partiton array + disk->pentry_arr_crc = crc32(crc_zero, + disk->pentry_arr, + disk->pentry_arr_size); + //Recalculate the CRC of the backup partition array + disk->pentry_arr_bak_crc = crc32(crc_zero, + disk->pentry_arr_bak, + disk->pentry_arr_size); + //Update the partition CRC value in the primary GPT header + PUT_4_BYTES(disk->hdr + PARTITION_CRC_OFFSET, disk->pentry_arr_crc); + //Update the partition CRC value in the backup GPT header + PUT_4_BYTES(disk->hdr_bak + PARTITION_CRC_OFFSET, + disk->pentry_arr_bak_crc); + //Update the CRC value of the primary header + gpt_header_size = GET_4_BYTES(disk->hdr + HEADER_SIZE_OFFSET); + //Header CRC is calculated with its own CRC field set to 0 + PUT_4_BYTES(disk->hdr + HEADER_CRC_OFFSET, 0); + PUT_4_BYTES(disk->hdr_bak + HEADER_CRC_OFFSET, 0); + disk->hdr_crc = crc32(crc_zero, disk->hdr, gpt_header_size); + disk->hdr_bak_crc = crc32(crc_zero, disk->hdr_bak, gpt_header_size); + PUT_4_BYTES(disk->hdr + HEADER_CRC_OFFSET, disk->hdr_crc); + PUT_4_BYTES(disk->hdr_bak + HEADER_CRC_OFFSET, disk->hdr_bak_crc); + return 0; +error: + return -1; +} + +//Write the contents of struct gpt_disk back to the actual disk +int gpt_disk_commit(struct gpt_disk *disk) +{ + int fd = -1; + if (!disk || (disk->is_initialized != GPT_DISK_INIT_MAGIC)){ + ALOGE("%s: Invalid args", __func__); + goto error; + } + fd = open(disk->devpath, O_RDWR); + if (fd < 0) { + ALOGE("%s: Failed to open %s: %s", + __func__, + disk->devpath, + strerror(errno)); + goto error; + } + //Write the primary header + if(gpt_set_header(disk->hdr, fd, PRIMARY_GPT) != 0) { + ALOGE("%s: Failed to update primary GPT header", + __func__); + goto error; + } + //Write back the primary partition array + if (gpt_set_pentry_arr(disk->hdr, fd, disk->pentry_arr)) { + ALOGE("%s: Failed to write primary GPT partition arr", + __func__); + goto error; + } + //Write back the secondary header + if(gpt_set_header(disk->hdr_bak, fd, SECONDARY_GPT) != 0) { + ALOGE("%s: Failed to update secondary GPT header", + __func__); + goto error; + } + //Write back the secondary partition array + if (gpt_set_pentry_arr(disk->hdr_bak, fd, disk->pentry_arr_bak)) { + ALOGE("%s: Failed to write secondary GPT partition arr", + __func__); + goto error; + } + close(fd); + return 0; +error: + if (fd >= 0) + close(fd); + return -1; +} + diff --git a/gpt-utils/gpt-utils.h b/gpt-utils/gpt-utils.h new file mode 100644 index 0000000..2e356dc --- /dev/null +++ b/gpt-utils/gpt-utils.h @@ -0,0 +1,193 @@ +/* + * Copyright (c) 2013,2016,2020 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. + */ + +#ifndef __GPT_UTILS_H__ +#define __GPT_UTILS_H__ +#include +#include +#include +#ifdef __cplusplus +extern "C" { +#endif +#include +#include +/****************************************************************************** + * GPT HEADER DEFINES + ******************************************************************************/ +#define GPT_SIGNATURE "EFI PART" +#define HEADER_SIZE_OFFSET 12 +#define HEADER_CRC_OFFSET 16 +#define PRIMARY_HEADER_OFFSET 24 +#define BACKUP_HEADER_OFFSET 32 +#define FIRST_USABLE_LBA_OFFSET 40 +#define LAST_USABLE_LBA_OFFSET 48 +#define PENTRIES_OFFSET 72 +#define PARTITION_COUNT_OFFSET 80 +#define PENTRY_SIZE_OFFSET 84 +#define PARTITION_CRC_OFFSET 88 + +#define TYPE_GUID_OFFSET 0 +#define TYPE_GUID_SIZE 16 +#define PTN_ENTRY_SIZE 128 +#define UNIQUE_GUID_OFFSET 16 +#define FIRST_LBA_OFFSET 32 +#define LAST_LBA_OFFSET 40 +#define ATTRIBUTE_FLAG_OFFSET 48 +#define PARTITION_NAME_OFFSET 56 +#define MAX_GPT_NAME_SIZE 72 + +/****************************************************************************** + * AB RELATED DEFINES + ******************************************************************************/ +//Bit 48 onwords in the attribute field are the ones where we are allowed to +//store our AB attributes. +#define AB_FLAG_OFFSET (ATTRIBUTE_FLAG_OFFSET + 6) +#define GPT_DISK_INIT_MAGIC 0xABCD +#define AB_PARTITION_ATTR_SLOT_ACTIVE (0x1<<2) +#define AB_PARTITION_ATTR_BOOT_SUCCESSFUL (0x1<<6) +#define AB_PARTITION_ATTR_UNBOOTABLE (0x1<<7) +#define AB_SLOT_ACTIVE_VAL 0x3F +#define AB_SLOT_INACTIVE_VAL 0x0 +#define AB_SLOT_ACTIVE 1 +#define AB_SLOT_INACTIVE 0 +#define AB_SLOT_A_SUFFIX "_a" +#define AB_SLOT_B_SUFFIX "_b" +#define PTN_XBL "xbl" +#define PTN_XBL_CFG "xbl_config" +#define PTN_SWAP_LIST PTN_XBL, PTN_XBL_CFG, "abl", "aop", "cpucp", "devcfg", "dsp", "dtbo", "featenabler", "hyp", "imagefv", "keymaster", "qupfw", "shrm", "tz", "uefisecapp", "vbmeta", "vbmeta_system" +#define AB_PTN_LIST PTN_SWAP_LIST, "bluetooth", "boot", "modem", "odm", "product", "system", "system_ext", "vendor", "vendor_boot" +#define BOOT_DEV_DIR "/dev/block/bootdevice/by-name" + +/****************************************************************************** + * HELPER MACROS + ******************************************************************************/ +#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) +/****************************************************************************** + * TYPES + ******************************************************************************/ +enum boot_update_stage { + UPDATE_MAIN = 1, + UPDATE_BACKUP, + UPDATE_FINALIZE +}; + +enum gpt_instance { + PRIMARY_GPT = 0, + SECONDARY_GPT +}; + +enum boot_chain { + NORMAL_BOOT = 0, + BACKUP_BOOT +}; + +struct gpt_disk { + //GPT primary header + uint8_t *hdr; + //primary header crc + uint32_t hdr_crc; + //GPT backup header + uint8_t *hdr_bak; + //backup header crc + uint32_t hdr_bak_crc; + //Partition entries array + uint8_t *pentry_arr; + //Partition entries array for backup table + uint8_t *pentry_arr_bak; + //Size of the pentry array + uint32_t pentry_arr_size; + //Size of each element in the pentry array + uint32_t pentry_size; + //CRC of the partition entry array + uint32_t pentry_arr_crc; + //CRC of the backup partition entry array + uint32_t pentry_arr_bak_crc; + //Path to block dev representing the disk + char devpath[PATH_MAX]; + //Block size of disk + uint32_t block_size; + uint32_t is_initialized; +}; + +/****************************************************************************** + * FUNCTION PROTOTYPES + ******************************************************************************/ +int prepare_boot_update(enum boot_update_stage stage); +//GPT disk methods +struct gpt_disk* gpt_disk_alloc(); +//Free previously allocated gpt_disk struct +void gpt_disk_free(struct gpt_disk *disk); +//Get the details of the disk holding the partition whose name +//is passed in via dev +int gpt_disk_get_disk_info(const char *dev, struct gpt_disk *disk); + +//Get pointer to partition entry from a allocated gpt_disk structure +uint8_t* gpt_disk_get_pentry(struct gpt_disk *disk, + const char *partname, + enum gpt_instance instance); + +//Update the crc fields of the modified disk structure +int gpt_disk_update_crc(struct gpt_disk *disk); + +//Write the contents of struct gpt_disk back to the actual disk +int gpt_disk_commit(struct gpt_disk *disk); + +//Return if the current device is UFS based or not +int gpt_utils_is_ufs_device(); + +//Swtich betwieen using either the primary or the backup +//boot LUN for boot. This is required since UFS boot partitions +//cannot have a backup GPT which is what we use for failsafe +//updates of the other 'critical' partitions. This function will +//not be invoked for emmc targets and on UFS targets is only required +//to be invoked for XBL. +// +//The algorithm to do this is as follows: +//- Find the real block device(eg: /dev/block/sdb) that corresponds +// to the /dev/block/bootdevice/by-name/xbl(bak) symlink +// +//- Once we have the block device 'node' name(sdb in the above example) +// use this node to to locate the scsi generic device that represents +// it by checking the file /sys/block/sdb/device/scsi_generic/sgY +// +//- Once we locate sgY we call the query ioctl on /dev/sgy to switch +//the boot lun to either LUNA or LUNB +int gpt_utils_set_xbl_boot_partition(enum boot_chain chain); + +//Given a vector of partition names as a input and a reference to a map, +//populate the map to indicate which physical disk each of the partitions +//sits on. The key in the map is the path to the block device where the +//partiton lies and the value is a vector of strings indicating which of +//the passed in partiton names sits on that device. +int gpt_utils_get_partition_map(std::vector& partition_list, + std::map>& partition_map); +#ifdef __cplusplus +} +#endif +#endif /* __GPT_UTILS_H__ */ diff --git a/gpt-utils/recovery-ufs-bsg.cpp b/gpt-utils/recovery-ufs-bsg.cpp new file mode 100644 index 0000000..0a2cf11 --- /dev/null +++ b/gpt-utils/recovery-ufs-bsg.cpp @@ -0,0 +1,255 @@ +/* + * Copyright (c) 2020 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. + */ + + +#define LOG_TAG "recovery_ufs" + +#include "recovery-ufs-bsg.h" + +#ifndef _BSG_FRAMEWORK_KERNEL_HEADERS +#ifndef _GENERIC_KERNEL_HEADERS +#include +#include +#endif +#endif + +//Size of the buffer that needs to be passed to the UFS ioctl +#define UFS_ATTR_DATA_SIZE 32 + +#ifdef _BSG_FRAMEWORK_KERNEL_HEADERS +static int get_ufs_bsg_dev(void) +{ + DIR *dir; + struct dirent *ent; + int ret = -ENODEV; + + if ((dir = opendir ("/dev")) != NULL) { + /* read all the files and directories within directory */ + while ((ent = readdir(dir)) != NULL) { + if (!strcmp(ent->d_name, "ufs-bsg") || + !strcmp(ent->d_name, "ufs-bsg0")) { + snprintf(ufs_bsg_dev, FNAME_SZ, "/dev/%s", ent->d_name); + ret = 0; + break; + } + } + if (ret) + ALOGE("could not find the ufs-bsg dev\n"); + closedir (dir); + } else { + /* could not open directory */ + ALOGE("could not open /dev (error no: %d)\n", errno); + ret = -EINVAL; + } + + return ret; +} + +int ufs_bsg_dev_open(void) +{ + int ret; + if (!fd_ufs_bsg) { + fd_ufs_bsg = open(ufs_bsg_dev, O_RDWR); + ret = errno; + if (fd_ufs_bsg < 0) { + ALOGE("Unable to open %s (error no: %d)", + ufs_bsg_dev, errno); + fd_ufs_bsg = 0; + return ret; + } + } + return 0; +} + +void ufs_bsg_dev_close(void) +{ + if (fd_ufs_bsg) { + close(fd_ufs_bsg); + fd_ufs_bsg = 0; + } +} + +static int ufs_bsg_ioctl(int fd, struct ufs_bsg_request *req, + struct ufs_bsg_reply *rsp, __u8 *buf, __u32 buf_len, + enum bsg_ioctl_dir dir) +{ + int ret; + struct sg_io_v4 sg_io = {0}; + + sg_io.guard = 'Q'; + sg_io.protocol = BSG_PROTOCOL_SCSI; + sg_io.subprotocol = BSG_SUB_PROTOCOL_SCSI_TRANSPORT; + sg_io.request_len = sizeof(*req); + sg_io.request = (__u64)req; + sg_io.response = (__u64)rsp; + sg_io.max_response_len = sizeof(*rsp); + if (dir == BSG_IOCTL_DIR_FROM_DEV) { + sg_io.din_xfer_len = buf_len; + sg_io.din_xferp = (__u64)(buf); + } else { + sg_io.dout_xfer_len = buf_len; + sg_io.dout_xferp = (__u64)(buf); + } + + ret = ioctl(fd, SG_IO, &sg_io); + if (ret) + ALOGE("%s: Error from sg_io ioctl (return value: %d, error no: %d, reply result from LLD: %d\n)", + __func__, ret, errno, rsp->result); + + if (sg_io.info || rsp->result) { + ALOGE("%s: Error from sg_io info (check sg info: device_status: 0x%x, transport_status: 0x%x, driver_status: 0x%x, reply result from LLD: %d\n)", + __func__, sg_io.device_status, sg_io.transport_status, + sg_io.driver_status, rsp->result); + ret = -EAGAIN; + } + + return ret; +} + +static void compose_ufs_bsg_query_req(struct ufs_bsg_request *req, __u8 func, + __u8 opcode, __u8 idn, __u8 index, __u8 sel, + __u16 length) +{ + struct utp_upiu_header *hdr = &req->upiu_req.header; + struct utp_upiu_query *qr = &req->upiu_req.qr; + + req->msgcode = UTP_UPIU_QUERY_REQ; + hdr->dword_0 = DWORD(UTP_UPIU_QUERY_REQ, 0, 0, 0); + hdr->dword_1 = DWORD(0, func, 0, 0); + hdr->dword_2 = DWORD(0, 0, length >> 8, (__u8)length); + qr->opcode = opcode; + qr->idn = idn; + qr->index = index; + qr->selector = sel; + qr->length = htobe16(length); +} + + +static int ufs_query_attr(int fd, __u32 value, + __u8 func, __u8 opcode, __u8 idn, + __u8 index, __u8 sel) +{ + struct ufs_bsg_request req = {0}; + struct ufs_bsg_reply rsp = {0}; + enum bsg_ioctl_dir dir = BSG_IOCTL_DIR_FROM_DEV; + int ret = 0; + + if (opcode == QUERY_REQ_OP_WRITE_DESC || opcode == QUERY_REQ_OP_WRITE_ATTR) + dir = BSG_IOCTL_DIR_TO_DEV; + + req.upiu_req.qr.value = htobe32(value); + + compose_ufs_bsg_query_req(&req, func, opcode, idn, index, sel, 0); + + ret = ufs_bsg_ioctl(fd, &req, &rsp, 0, 0, dir); + if (ret) + ALOGE("%s: Error from ufs_bsg_ioctl (return value: %d, error no: %d\n)", + __func__, ret, errno); + + return ret; +} + +int32_t set_boot_lun(char *sg_dev,uint8_t lun_id) +{ + int32_t ret; + __u32 boot_lun_id = lun_id; + + ret = get_ufs_bsg_dev(); + if (ret) + return ret; + ALOGV("Found the ufs bsg dev: %s\n", ufs_bsg_dev); + + ret = ufs_bsg_dev_open(); + if (ret) + return ret; + ALOGV("Opened ufs bsg dev: %s\n", ufs_bsg_dev); + + ret = ufs_query_attr(fd_ufs_bsg, boot_lun_id, QUERY_REQ_FUNC_STD_WRITE, + QUERY_REQ_OP_WRITE_ATTR, QUERY_ATTR_IDN_BOOT_LU_EN, 0, 0); + if (ret) { + ALOGE("Error requesting ufs attr idn %d via query ioctl (return value: %d, error no: %d)", + QUERY_ATTR_IDN_BOOT_LU_EN, ret, errno); + goto out; + } +out: + ufs_bsg_dev_close(); + return ret; +} +#endif + +#ifndef _BSG_FRAMEWORK_KERNEL_HEADERS +int32_t set_boot_lun(char *sg_dev, uint8_t boot_lun_id) +{ +#ifndef _GENERIC_KERNEL_HEADERS + int fd = -1; + int rc; + struct ufs_ioctl_query_data *data = NULL; + size_t ioctl_data_size = sizeof(struct ufs_ioctl_query_data) + UFS_ATTR_DATA_SIZE; + + data = (struct ufs_ioctl_query_data*)malloc(ioctl_data_size); + if (!data) { + fprintf(stderr, "%s: Failed to alloc query data struct\n", + __func__); + goto error; + } + memset(data, 0, ioctl_data_size); + data->opcode = UPIU_QUERY_OPCODE_WRITE_ATTR; + data->idn = QUERY_ATTR_IDN_BOOT_LU_EN; + data->buf_size = UFS_ATTR_DATA_SIZE; + data->buffer[0] = boot_lun_id; + fd = open(sg_dev, O_RDWR); + if (fd < 0) { + fprintf(stderr, "%s: Failed to open %s(%s)\n", + __func__, + sg_dev, + strerror(errno)); + goto error; + } + rc = ioctl(fd, UFS_IOCTL_QUERY, data); + if (rc) { + fprintf(stderr, "%s: UFS query ioctl failed(%s)\n", + __func__, + strerror(errno)); + goto error; + } + close(fd); + free(data); + return 0; +error: + if (fd >= 0) + close(fd); + if (data) + free(data); + return -1; +#else + return 0; +#endif +} +#endif + diff --git a/gpt-utils/recovery-ufs-bsg.h b/gpt-utils/recovery-ufs-bsg.h new file mode 100644 index 0000000..fafea5f --- /dev/null +++ b/gpt-utils/recovery-ufs-bsg.h @@ -0,0 +1,131 @@ +#ifndef __RECOVERY_UFS_BSG_H__ +#define __RECOVERY_UFS_BSG_H__ + +/* + * Copyright (c) 2020 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. + */ + + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef ANDROID +#include "cutils/log.h" +#endif + +#ifdef OE +#include +#define LOGI(...) syslog(LOG_NOTICE, "INFO:" __VA_ARGS__) +#define LOGV(...) syslog(LOG_NOTICE,"VERB:" __VA_ARGS__) +#define LOGD(...) syslog(LOG_DEBUG,"DBG:" __VA_ARGS__) +#define LOGE(...) syslog(LOG_ERR,"ERR:" __VA_ARGS__) +#define LOGW(...) syslog(LOG_WARNING,"WRN:" __VA_ARGS__) +#define strlcat(d,s,l) snprintf(d+strlen(d),l,"%s",s) +#endif + + + +#define FNAME_SZ 64 + +#define SG_IO 0x2285 + +#define DWORD(b3, b2, b1, b0) htobe32((b3 << 24) | (b2 << 16) |\ + (b1 << 8) | b0) + +/* UFS BSG device nodes */ +char ufs_bsg_dev[FNAME_SZ] = "/dev/ufs-bsg"; + +int fd_ufs_bsg; + +int32_t set_ufs_lun(uint8_t lun_id); + +#ifdef _BSG_FRAMEWORK_KERNEL_HEADERS +/* UPIU Transaction Codes */ +enum { + UTP_UPIU_NOP_OUT = 0x00, + UTP_UPIU_COMMAND = 0x01, + UTP_UPIU_DATA_OUT = 0x02, + UTP_UPIU_TASK_REQ = 0x04, + UTP_UPIU_QUERY_REQ = 0x16, +}; + +/* UPIU Query Function field */ +enum { + QUERY_REQ_FUNC_STD_READ = 0x01, + QUERY_REQ_FUNC_STD_WRITE = 0x81, +}; + +enum query_req_opcode { + QUERY_REQ_OP_READ_DESC = 0x1, + QUERY_REQ_OP_WRITE_DESC = 0x2, + QUERY_REQ_OP_READ_ATTR = 0x3, + QUERY_REQ_OP_WRITE_ATTR = 0x4, + QUERY_REQ_OP_READ_FLAG = 0x5, + QUERY_REQ_OP_SET_FLAG = 0x6, + QUERY_REQ_OP_CLEAR_FLAG = 0x7, + QUERY_REQ_OP_TOGGLE_FLAG = 0x8, +}; + +enum query_desc_idn { + QUERY_DESC_IDN_DEVICE = 0x0, + QUERY_DESC_IDN_UNIT = 0x2, + QUERY_DESC_IDN_GEOMETRY = 0x7, +}; + +enum query_desc_size { + QUERY_DESC_SIZE_DEVICE = 0x40, + QUERY_DESC_SIZE_GEOMETRY = 0x48, + QUERY_DESC_SIZE_UNIT = 0x23, +}; + +enum bsg_ioctl_dir { + BSG_IOCTL_DIR_TO_DEV, + BSG_IOCTL_DIR_FROM_DEV, +}; + +enum query_attr_idn { + QUERY_ATTR_IDN_BOOT_LU_EN = 0x00, + QUERY_ATTR_IDN_RESERVED = 0x01, + QUERY_ATTR_IDN_POWER_MODE = 0x02, + QUERY_ATTR_IDN_ACTIVE_ICC_LVL = 0x03, +}; +#endif /* _BSG_FRAMEWORK_KERNEL_HEADERS */ + +#endif /* __RECOVERY_UFS_BSG_H__ */ diff --git a/odm.prop b/odm.prop new file mode 100644 index 0000000..fab6c31 --- /dev/null +++ b/odm.prop @@ -0,0 +1,2 @@ +# Audio +ro.vendor.qti.va_odm.support=1 diff --git a/recovery.fstab b/recovery.fstab new file mode 100644 index 0000000..930d552 --- /dev/null +++ b/recovery.fstab @@ -0,0 +1,45 @@ +# Copyright (c) 2019-2020 The Linux Foundation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted (subject to the limitations in the +# disclaimer below) 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. +# +# NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE +# GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT +# HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +# IN NO EVENT SHALL THE COPYRIGHT HOLDER 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. + +# Android fstab file. +# The filesystem that contains the filesystem checker binary (typically /system) cannot +# specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK + +# +system /system ext4 ro,barrier=1,discard wait,slotselect,avb=vbmeta_system,logical,first_stage_mount,avb_keys=/avb/q-gsi.avbpubkey:/avb/r-gsi.avbpubkey:/avb/s-gsi.avbpubkey +system_ext /system_ext ext4 ro,barrier=1,discard wait,slotselect,avb=vbmeta_system,logical,first_stage_mount +product /product ext4 ro,barrier=1,discard wait,slotselect,avb=vbmeta_system,logical,first_stage_mount +vendor /vendor ext4 ro,barrier=1,discard wait,slotselect,avb,logical,first_stage_mount +odm /odm ext4 ro,barrier=1,discard wait,slotselect,avb,logical,first_stage_mount +/dev/block/by-name/metadata /metadata ext4 noatime,nosuid,nodev,discard wait,check,formattable,first_stage_mount +/dev/block/bootdevice/by-name/userdata /data f2fs noatime,nosuid,nodev,discard,inlinecrypt,reserve_root=32768,resgid=1065,fsync_mode=nobarrier latemount,wait,check,formattable,fileencryption=aes-256-xts:aes-256-cts:v2+inlinecrypt_optimized+wrappedkey_v0,keydirectory=/metadata/vold/metadata_encryption,metadata_encryption=aes-256-xts:wrappedkey_v0,quota,reservedsize=512M,sysfs_path=/sys/devices/platform/soc/1d84000.ufshc,checkpoint=fs +/dev/block/bootdevice/by-name/misc /misc emmc defaults defaults diff --git a/recovery/root/init.recovery.qcom.rc b/recovery/root/init.recovery.qcom.rc new file mode 100644 index 0000000..72c66ed --- /dev/null +++ b/recovery/root/init.recovery.qcom.rc @@ -0,0 +1,33 @@ +import /init.recovery.qcom_decrypt.rc + +service touchfeature /system/bin/vendor.xiaomi.hw.touchfeature@1.0-service + user root + group root + setenv LD_LIBRARY_PATH /vendor/lib64:/vendor/lib:/system/lib64:/system/lib:/sbin + disabled + oneshot + seclabel u:r:recovery:s0 + +on init + write /sys/class/backlight/panel0-backlight/brightness 200 + # Create location for fs_mgr to store abbreviated output from filesystem + # checker programs. + mkdir /dev/fscklogs 0770 root system + +on fs + wait /dev/block/platform/soc/${ro.boot.bootdevice} + symlink /dev/block/platform/soc/${ro.boot.bootdevice} /dev/block/bootdevice + # Set fscklog permission + chown root system /dev/fscklogs/log + chmod 0770 /dev/fscklogs/log + start boot-hal-1-1 + +on boot + start health-hal-2-1 + setprop sys.usb.config adb + + # Xiaomi touch + mknod /dev/xiaomi_touch c 10 120 + chown system system /dev/xiaomi-touch + chmod 0664 /dev/xiaomi-touch + start touchfeature diff --git a/recovery/root/init.recovery.usb.rc b/recovery/root/init.recovery.usb.rc new file mode 100644 index 0000000..650bf7b --- /dev/null +++ b/recovery/root/init.recovery.usb.rc @@ -0,0 +1,166 @@ +# Copyright (c) 2011-2016, 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 BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 boot + write /sys/class/android_usb/android0/iSerial ${ro.serialno} + mount configfs none /config + mkdir /config/usb_gadget/g1 0770 + mkdir /config/usb_gadget/g2 0770 + mkdir /config/usb_gadget/g1/strings/0x409 0770 + mkdir /config/usb_gadget/g2/strings/0x409 0770 + write /config/usb_gadget/g1/bcdUSB 0x0200 + write /config/usb_gadget/g2/bcdUSB 0x0200 + write /config/usb_gadget/g1/os_desc/use 1 + write /config/usb_gadget/g1/strings/0x409/serialnumber ${ro.serialno} + write /config/usb_gadget/g2/strings/0x409/serialnumber ${ro.serialno} + write /config/usb_gadget/g1/strings/0x409/manufacturer ${ro.product.manufacturer} + write /config/usb_gadget/g2/strings/0x409/manufacturer ${ro.product.manufacturer} + write /config/usb_gadget/g1/strings/0x409/product ${ro.product.model} + write /config/usb_gadget/g2/strings/0x409/product ${ro.product.model} + mkdir /config/usb_gadget/g1/functions/mass_storage.0 + mkdir /config/usb_gadget/g1/functions/mtp.gs0 + mkdir /config/usb_gadget/g1/functions/ptp.gs1 + mkdir /config/usb_gadget/g1/functions/accessory.gs2 + mkdir /config/usb_gadget/g1/functions/audio_source.gs3 + mkdir /config/usb_gadget/g1/functions/midi.gs5 + mkdir /config/usb_gadget/g1/functions/ffs.adb + + + mkdir /config/usb_gadget/g1/functions/ffs.diag + mkdir /config/usb_gadget/g1/functions/ffs.diag_mdm + mkdir /config/usb_gadget/g1/functions/ffs.diag_mdm2 + mkdir /config/usb_gadget/g1/functions/diag.diag + mkdir /config/usb_gadget/g1/functions/diag.diag_mdm + mkdir /config/usb_gadget/g1/functions/diag.diag_mdm2 + mkdir /config/usb_gadget/g1/functions/cser.dun.0 + mkdir /config/usb_gadget/g1/functions/cser.nmea.1 + mkdir /config/usb_gadget/g1/functions/cser.dun.2 + mkdir /config/usb_gadget/g1/functions/gsi.rmnet + mkdir /config/usb_gadget/g1/functions/gsi.rndis + mkdir /config/usb_gadget/g1/functions/gsi.dpl + mkdir /config/usb_gadget/g1/functions/qdss.qdss + mkdir /config/usb_gadget/g1/functions/qdss.qdss_mdm + mkdir /config/usb_gadget/g1/functions/rndis_bam.rndis + mkdir /config/usb_gadget/g1/functions/rndis.rndis + mkdir /config/usb_gadget/g1/functions/rmnet_bam.rmnet + mkdir /config/usb_gadget/g1/functions/rmnet_bam.dpl + mkdir /config/usb_gadget/g1/functions/rmnet_bam.rmnet_bam_dmux + mkdir /config/usb_gadget/g1/functions/rmnet_bam.dpl_bam_dmux + mkdir /config/usb_gadget/g1/functions/ncm.0 + mkdir /config/usb_gadget/g1/functions/ccid.ccid + mkdir /config/usb_gadget/g1/functions/uac2.0 + mkdir /config/usb_gadget/g1/functions/uvc.0 + mkdir /config/usb_gadget/g1/configs/b.1 0770 + mkdir /config/usb_gadget/g2/configs/b.1 0770 + mkdir /config/usb_gadget/g1/configs/b.1/strings/0x409 0770 + mkdir /config/usb_gadget/g2/configs/b.1/strings/0x409 0770 + write /config/usb_gadget/g1/configs/b.1/MaxPower 900 + write /config/usb_gadget/g1/os_desc/b_vendor_code 0x1 + write /config/usb_gadget/g1/os_desc/qw_sign "MSFT100" + write /config/usb_gadget/g1/functions/diag.diag/serial ${ro.serialno} + symlink /config/usb_gadget/g1/configs/b.1 /config/usb_gadget/g1/os_desc/b.1 + mkdir /dev/usb-ffs 0775 shell system + mkdir /dev/usb-ffs/adb 0770 shell system + mount functionfs adb /dev/usb-ffs/adb uid=2000,gid=1000,rmode=0770,fmode=0660 + write /sys/class/android_usb/android0/f_ffs/aliases adb + setprop vendor.usb.controller ${sys.usb.controller} + enable vendor.qcom-usb-sh + mkdir /config/usb_gadget/g1/functions/ffs.mtp + mkdir /config/usb_gadget/g1/functions/ffs.ptp + mkdir /dev/usb-ffs/mtp 0770 mtp mtp + mount functionfs mtp /dev/usb-ffs/mtp rmode=0770,fmode=0660,uid=1024,gid=1024,no_disconnect=1 + mkdir /dev/usb-ffs/ptp 0770 mtp mtp + mount functionfs ptp /dev/usb-ffs/ptp rmode=0770,fmode=0660,uid=1024,gid=1024,no_disconnect=1 + +on property:sys.usb.config=none + write /config/usb_gadget/g1/UDC "none" + stop adbd + setprop sys.usb.ffs.ready 0 + setprop sys.usb.ffs.mtp.ready 0 + write /config/usb_gadget/g1/bDeviceClass 0 + write /config/usb_gadget/g1/bDeviceSubClass 0 + write /config/usb_gadget/g1/bDeviceProtocol 0 + rm /config/usb_gadget/g1/configs/b.1/f1 + rm /config/usb_gadget/g1/configs/b.1/f2 + rm /config/usb_gadget/g1/configs/b.1/f3 + rm /config/usb_gadget/g1/configs/b.1/f4 + rm /config/usb_gadget/g1/configs/b.1/f5 + rmdir /config/usb_gadget/g1/functions/rndis.gs4 + symlink /config/usb_gadget/g1/functions/ffs.mtp /config/usb_gadget/g1/configs/b.1/f1 + symlink /config/usb_gadget/g1/functions/ffs.adb /config/usb_gadget/g1/configs/b.1/f2 + setprop sys.usb.state ${sys.usb.config} + +on property:sys.usb.config=adb + start adbd + +on property:sys.usb.ffs.ready=1 && property:sys.usb.config=adb + write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "adb" + rm /config/usb_gadget/g1/configs/b.1/f1 + rm /config/usb_gadget/g1/configs/b.1/f2 + rm /config/usb_gadget/g1/configs/b.1/f3 + rm /config/usb_gadget/g1/configs/b.1/f4 + rm /config/usb_gadget/g1/configs/b.1/f5 + write /config/usb_gadget/g1/idVendor 0x18d1 + write /config/usb_gadget/g1/idProduct 0x4ee7 + symlink /config/usb_gadget/g1/functions/ffs.adb /config/usb_gadget/g1/configs/b.1/f1 + write /config/usb_gadget/g1/UDC ${sys.usb.controller} + setprop sys.usb.state ${sys.usb.config} + +on property:sys.usb.config=mtp + write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "mtp" + rm /config/usb_gadget/g1/configs/b.1/f1 + rm /config/usb_gadget/g1/configs/b.1/f2 + rm /config/usb_gadget/g1/configs/b.1/f3 + rm /config/usb_gadget/g1/configs/b.1/f4 + rm /config/usb_gadget/g1/configs/b.1/f5 + write /config/usb_gadget/g1/idVendor 0x2A70 + write /config/usb_gadget/g1/idProduct 0XF003 + symlink /config/usb_gadget/g1/functions/ffs.mtp /config/usb_gadget/g1/configs/b.1/f1 + symlink /config/usb_gadget/g1/functions/ffs.adb /config/usb_gadget/g1/configs/b.1/f2 + write /config/usb_gadget/g1/UDC ${sys.usb.controller} + setprop sys.usb.state ${sys.usb.config} + +on property:sys.usb.config=mtp,adb + start adbd + +on property:sys.usb.ffs.ready=1 && property:sys.usb.config=mtp,adb + write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "mtp_adb" + rm /config/usb_gadget/g1/configs/b.1/f1 + rm /config/usb_gadget/g1/configs/b.1/f2 + rm /config/usb_gadget/g1/configs/b.1/f3 + rm /config/usb_gadget/g1/configs/b.1/f4 + rm /config/usb_gadget/g1/configs/b.1/f5 + write /config/usb_gadget/g1/idVendor 0x2A70 + write /config/usb_gadget/g1/idProduct 0x9011 + symlink /config/usb_gadget/g1/functions/ffs.mtp /config/usb_gadget/g1/configs/b.1/f1 + symlink /config/usb_gadget/g1/functions/ffs.adb /config/usb_gadget/g1/configs/b.1/f2 + write /config/usb_gadget/g1/UDC ${sys.usb.controller} + setprop sys.usb.state ${sys.usb.config} + +on property:ro.boot.usbcontroller=* + setprop sys.usb.controller ${ro.boot.usbcontroller} + write /sys/class/udc/${ro.boot.usbcontroller}/device/../mode peripheral diff --git a/recovery/root/system/bin/android.hardware.gatekeeper@1.0-service-qti b/recovery/root/system/bin/android.hardware.gatekeeper@1.0-service-qti new file mode 100644 index 0000000..2f7a50b Binary files /dev/null and b/recovery/root/system/bin/android.hardware.gatekeeper@1.0-service-qti differ diff --git a/recovery/root/system/bin/android.hardware.keymaster@4.1-service-qti b/recovery/root/system/bin/android.hardware.keymaster@4.1-service-qti new file mode 100644 index 0000000..932dc29 Binary files /dev/null and b/recovery/root/system/bin/android.hardware.keymaster@4.1-service-qti differ diff --git a/recovery/root/system/bin/qseecomd b/recovery/root/system/bin/qseecomd new file mode 100644 index 0000000..1806427 Binary files /dev/null and b/recovery/root/system/bin/qseecomd differ diff --git a/recovery/root/system/etc/recovery.fstab b/recovery/root/system/etc/recovery.fstab new file mode 100644 index 0000000..2d9be9a --- /dev/null +++ b/recovery/root/system/etc/recovery.fstab @@ -0,0 +1,44 @@ +# Copyright (c) 2019-2020 The Linux Foundation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted (subject to the limitations in the +# disclaimer below) 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. +# +# NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE +# GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT +# HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +# IN NO EVENT SHALL THE COPYRIGHT HOLDER 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. + +# Android fstab file. +# The filesystem that contains the filesystem checker binary (typically /system) cannot +# specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK + +# +system /system ext4 ro,barrier=1,discard wait,slotselect +system_ext /system_ext ext4 ro,barrier=1,discard wait,slotselect +product /product ext4 ro,barrier=1,discard wait,slotselect +vendor /vendor ext4 ro,barrier=1,discard wait,slotselect +odm /odm ext4 ro,barrier=1,discard wait,slotselect +/dev/block/bootdevice/by-name/userdata /data f2fs noatime,nosuid,nodev,discard,inlinecrypt,reserve_root=32768,resgid=1065,fsync_mode=nobarrier wait,check,formattable,fileencryption=aes-256-xts:aes-256-cts:v2+inlinecrypt_optimized+wrappedkey_v0,keydirectory=/metadata/vold/metadata_encryption +/dev/block/bootdevice/by-name/misc /misc emmc defaults defaults diff --git a/recovery/root/system/etc/task_profiles.json b/recovery/root/system/etc/task_profiles.json new file mode 100644 index 0000000..c4dbf8e --- /dev/null +++ b/recovery/root/system/etc/task_profiles.json @@ -0,0 +1,614 @@ +{ + "Attributes": [ + { + "Name": "LowCapacityCPUs", + "Controller": "cpuset", + "File": "background/cpus" + }, + { + "Name": "HighCapacityCPUs", + "Controller": "cpuset", + "File": "foreground/cpus" + }, + { + "Name": "MaxCapacityCPUs", + "Controller": "cpuset", + "File": "top-app/cpus" + }, + { + "Name": "MemLimit", + "Controller": "memory", + "File": "memory.limit_in_bytes" + }, + { + "Name": "MemSoftLimit", + "Controller": "memory", + "File": "memory.soft_limit_in_bytes" + }, + { + "Name": "MemSwappiness", + "Controller": "memory", + "File": "memory.swappiness" + }, + { + "Name": "STuneBoost", + "Controller": "schedtune", + "File": "schedtune.boost" + }, + { + "Name": "STunePreferIdle", + "Controller": "schedtune", + "File": "schedtune.prefer_idle" + }, + { + "Name": "UClampMin", + "Controller": "cpu", + "File": "cpu.uclamp.min" + }, + { + "Name": "UClampMax", + "Controller": "cpu", + "File": "cpu.uclamp.max" + }, + { + "Name": "FreezerState", + "Controller": "freezer", + "File": "cgroup.freeze" + } + ], + + "Profiles": [ + { + "Name": "HighEnergySaving", + "Actions": [ + { + "Name": "JoinCgroup", + "Params": + { + "Controller": "schedtune", + "Path": "background" + } + } + ] + }, + { + "Name": "Frozen", + "Actions": [ + { + "Name": "JoinCgroup", + "Params": + { + "Controller": "freezer", + "Path": "" + } + } + ] + }, + { + "Name": "Unfrozen", + "Actions": [ + { + "Name": "JoinCgroup", + "Params": + { + "Controller": "freezer", + "Path": "../" + } + } + ] + }, + { + "Name": "NormalPerformance", + "Actions": [ + { + "Name": "JoinCgroup", + "Params": + { + "Controller": "schedtune", + "Path": "" + } + } + ] + }, + { + "Name": "HighPerformance", + "Actions": [ + { + "Name": "JoinCgroup", + "Params": + { + "Controller": "schedtune", + "Path": "foreground" + } + } + ] + }, + { + "Name": "MaxPerformance", + "Actions": [ + { + "Name": "JoinCgroup", + "Params": + { + "Controller": "schedtune", + "Path": "top-app" + } + } + ] + }, + { + "Name": "RealtimePerformance", + "Actions": [ + { + "Name": "JoinCgroup", + "Params": + { + "Controller": "schedtune", + "Path": "rt" + } + } + ] + }, + { + "Name": "CameraServicePerformance", + "Actions": [ + { + "Name": "JoinCgroup", + "Params": + { + "Controller": "schedtune", + "Path": "camera-daemon" + } + } + ] + }, + + { + "Name": "CpuPolicySpread", + "Actions": [ + { + "Name": "SetAttribute", + "Params": + { + "Name": "STunePreferIdle", + "Value": "1" + } + } + ] + }, + { + "Name": "CpuPolicyPack", + "Actions": [ + { + "Name": "SetAttribute", + "Params": + { + "Name": "STunePreferIdle", + "Value": "0" + } + } + ] + }, + + { + "Name": "VrKernelCapacity", + "Actions": [ + { + "Name": "JoinCgroup", + "Params": + { + "Controller": "cpuset", + "Path": "" + } + } + ] + }, + { + "Name": "VrServiceCapacityLow", + "Actions": [ + { + "Name": "JoinCgroup", + "Params": + { + "Controller": "cpuset", + "Path": "system/background" + } + } + ] + }, + { + "Name": "VrServiceCapacityNormal", + "Actions": [ + { + "Name": "JoinCgroup", + "Params": + { + "Controller": "cpuset", + "Path": "system" + } + } + ] + }, + { + "Name": "VrServiceCapacityHigh", + "Actions": [ + { + "Name": "JoinCgroup", + "Params": + { + "Controller": "cpuset", + "Path": "system/performance" + } + } + ] + }, + { + "Name": "VrProcessCapacityLow", + "Actions": [ + { + "Name": "JoinCgroup", + "Params": + { + "Controller": "cpuset", + "Path": "application/background" + } + } + ] + }, + { + "Name": "VrProcessCapacityNormal", + "Actions": [ + { + "Name": "JoinCgroup", + "Params": + { + "Controller": "cpuset", + "Path": "application" + } + } + ] + }, + { + "Name": "VrProcessCapacityHigh", + "Actions": [ + { + "Name": "JoinCgroup", + "Params": + { + "Controller": "cpuset", + "Path": "application/performance" + } + } + ] + }, + + { + "Name": "ProcessCapacityLow", + "Actions": [ + { + "Name": "JoinCgroup", + "Params": + { + "Controller": "cpuset", + "Path": "background" + } + } + ] + }, + { + "Name": "ProcessCapacityNormal", + "Actions": [ + { + "Name": "JoinCgroup", + "Params": + { + "Controller": "cpuset", + "Path": "" + } + } + ] + }, + { + "Name": "ProcessCapacityHigh", + "Actions": [ + { + "Name": "JoinCgroup", + "Params": + { + "Controller": "cpuset", + "Path": "foreground" + } + } + ] + }, + { + "Name": "ProcessCapacityMax", + "Actions": [ + { + "Name": "JoinCgroup", + "Params": + { + "Controller": "cpuset", + "Path": "top-app" + } + } + ] + }, + + { + "Name": "ServiceCapacityLow", + "Actions": [ + { + "Name": "JoinCgroup", + "Params": + { + "Controller": "cpuset", + "Path": "system-background" + } + } + ] + }, + { + "Name": "ServiceCapacityRestricted", + "Actions": [ + { + "Name": "JoinCgroup", + "Params": + { + "Controller": "cpuset", + "Path": "restricted" + } + } + ] + }, + + { + "Name": "CameraServiceCapacity", + "Actions": [ + { + "Name": "JoinCgroup", + "Params": + { + "Controller": "cpuset", + "Path": "camera-daemon" + } + } + ] + }, + + { + "Name": "LowIoPriority", + "Actions": [ + { + "Name": "JoinCgroup", + "Params": + { + "Controller": "blkio", + "Path": "background" + } + } + ] + }, + { + "Name": "NormalIoPriority", + "Actions": [ + { + "Name": "JoinCgroup", + "Params": + { + "Controller": "blkio", + "Path": "" + } + } + ] + }, + { + "Name": "HighIoPriority", + "Actions": [ + { + "Name": "JoinCgroup", + "Params": + { + "Controller": "blkio", + "Path": "" + } + } + ] + }, + { + "Name": "MaxIoPriority", + "Actions": [ + { + "Name": "JoinCgroup", + "Params": + { + "Controller": "blkio", + "Path": "" + } + } + ] + }, + + { + "Name": "TimerSlackHigh", + "Actions": [ + { + "Name": "SetTimerSlack", + "Params": + { + "Slack": "40000000" + } + } + ] + }, + { + "Name": "TimerSlackNormal", + "Actions": [ + { + "Name": "SetTimerSlack", + "Params": + { + "Slack": "50000" + } + } + ] + }, + + { + "Name": "PerfBoost", + "Actions": [ + { + "Name": "SetClamps", + "Params": + { + "Boost": "50%", + "Clamp": "0" + } + } + ] + }, + { + "Name": "PerfClamp", + "Actions": [ + { + "Name": "SetClamps", + "Params": + { + "Boost": "0", + "Clamp": "30%" + } + } + ] + }, + + { + "Name": "LowMemoryUsage", + "Actions": [ + { + "Name": "SetAttribute", + "Params": + { + "Name": "MemSoftLimit", + "Value": "16MB" + } + }, + { + "Name": "SetAttribute", + "Params": + { + "Name": "MemSwappiness", + "Value": "150" + + } + } + ] + }, + { + "Name": "HighMemoryUsage", + "Actions": [ + { + "Name": "SetAttribute", + "Params": + { + "Name": "MemSoftLimit", + "Value": "512MB" + } + }, + { + "Name": "SetAttribute", + "Params": + { + "Name": "MemSwappiness", + "Value": "100" + } + } + ] + }, + { + "Name": "SystemMemoryProcess", + "Actions": [ + { + "Name": "JoinCgroup", + "Params": + { + "Controller": "memory", + "Path": "system" + } + } + ] + }, + { + "Name": "FreezerDisabled", + "Actions": [ + { + "Name": "SetAttribute", + "Params": + { + "Name": "FreezerState", + "Value": "0" + } + } + ] + }, + { + "Name": "FreezerEnabled", + "Actions": [ + { + "Name": "SetAttribute", + "Params": + { + "Name": "FreezerState", + "Value": "1" + } + } + ] + } + ], + + "AggregateProfiles": [ + { + "Name": "SCHED_SP_DEFAULT", + "Profiles": [ "TimerSlackNormal" ] + }, + { + "Name": "SCHED_SP_BACKGROUND", + "Profiles": [ "HighEnergySaving", "LowIoPriority", "TimerSlackHigh" ] + }, + { + "Name": "SCHED_SP_FOREGROUND", + "Profiles": [ "HighPerformance", "HighIoPriority", "TimerSlackNormal" ] + }, + { + "Name": "SCHED_SP_TOP_APP", + "Profiles": [ "MaxPerformance", "MaxIoPriority", "TimerSlackNormal" ] + }, + { + "Name": "SCHED_SP_RT_APP", + "Profiles": [ "RealtimePerformance", "MaxIoPriority", "TimerSlackNormal" ] + }, + { + "Name": "CPUSET_SP_DEFAULT", + "Profiles": [ "TimerSlackNormal" ] + }, + { + "Name": "CPUSET_SP_BACKGROUND", + "Profiles": [ "HighEnergySaving", "ProcessCapacityLow", "LowIoPriority", "TimerSlackHigh" ] + }, + { + "Name": "CPUSET_SP_FOREGROUND", + "Profiles": [ "HighPerformance", "ProcessCapacityHigh", "HighIoPriority", "TimerSlackNormal" ] + }, + { + "Name": "CPUSET_SP_TOP_APP", + "Profiles": [ "MaxPerformance", "ProcessCapacityMax", "MaxIoPriority", "TimerSlackNormal" ] + }, + { + "Name": "CPUSET_SP_SYSTEM", + "Profiles": [ "ServiceCapacityLow", "TimerSlackNormal" ] + }, + { + "Name": "CPUSET_SP_RESTRICTED", + "Profiles": [ "ServiceCapacityRestricted", "TimerSlackNormal" ] + } + ] +} diff --git a/recovery/root/system/etc/twrp.flags b/recovery/root/system/etc/twrp.flags new file mode 100644 index 0000000..d442b4b --- /dev/null +++ b/recovery/root/system/etc/twrp.flags @@ -0,0 +1,26 @@ +# Android fstab file. +# The filesystem that contains the filesystem checker binary (typically /system) cannot +# specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK + +# mount point fstype device device2 flags + +/metadata ext4 /dev/block/bootdevice/by-name/metadata flags=display="Metadata" +/data ext4 /dev/block/bootdevice/by-name/userdata fileencryption=aes-256-xts:aes-256-cts:v2+inlinecrypt_optimized+wrappedkey_v0,keydirectory=/metadata/vold/metadata_encryption +/boot emmc /dev/block/bootdevice/by-name/boot flags=backup=1;flashimg=1;slotselect +/dtbo emmc /dev/block/bootdevice/by-name/dtbo flags=backup=1;display="Dtbo";flashimg=1;slotselect +/firmware vfat /dev/block/bootdevice/by-name/modem flags=display="Firmware";slotselect;mounttodecrypt;fsflags=ro +/cust ext4 /dev/block/bootdevice/by-name/cust flags=display="Cust" +/misc emmc /dev/block/bootdevice/by-name/misc flags=display="Misc" +/modem emmc /dev/block/bootdevice/by-name/modem flags=backup=1;display="Modem";slotselect +/bluetooth emmc /dev/block/bootdevice/by-name/bluetooth flags=backup=1;subpartitionof=/modem;slotselect +/dsp emmc /dev/block/bootdevice/by-name/dsp flags=backup=1;subpartitionof=/modem;slotselect +/efs1 emmc /dev/block/bootdevice/by-name/modemst1 flags=backup=1;display=EFS +/efs2 emmc /dev/block/bootdevice/by-name/modemst2 flags=backup=1;subpartitionof=/efs1 +/efsc emmc /dev/block/bootdevice/by-name/fsc flags=backup=1;subpartitionof=/efs1 +/efsg emmc /dev/block/bootdevice/by-name/fsg flags=backup=1;subpartitionof=/efs1 +/persist ext4 /dev/block/bootdevice/by-name/persist flags=display="Persist" +/persist_image emmc /dev/block/bootdevice/by-name/persist flags=display="Persist";flashimg=1 + +# Removable storage +/usbstorage vfat /dev/block/sdg1 /dev/block/sdg flags=fsflags=utf8;display="USB Storage";storage;wipeingui;removable +/external_sd vfat /dev/block/mmcblk0p1 /dev/block/mmcblk0 flags=display="MicroSD";storage;wipeingui;removable diff --git a/recovery/root/system/etc/vintf/manifest.xml b/recovery/root/system/etc/vintf/manifest.xml new file mode 100644 index 0000000..4fa9f59 --- /dev/null +++ b/recovery/root/system/etc/vintf/manifest.xml @@ -0,0 +1,151 @@ + + + + android.frameworks.displayservice + hwbinder + 1.0 + + IDisplayService + default + + @1.0::IDisplayService/default + + + android.frameworks.schedulerservice + hwbinder + 1.0 + + ISchedulingPolicyService + default + + @1.0::ISchedulingPolicyService/default + + + android.frameworks.sensorservice + hwbinder + 1.0 + + ISensorManager + default + + @1.0::ISensorManager/default + + + android.hidl.manager + hwbinder + 1.2 + + IServiceManager + default + + @1.2::IServiceManager/default + + + android.hidl.memory + passthrough + 1.0 + + IMapper + ashmem + + @1.0::IMapper/ashmem + + + android.hidl.token + hwbinder + 1.0 + + ITokenManager + default + + @1.0::ITokenManager/default + + + android.system.net.netd + hwbinder + 1.1 + + INetd + default + + @1.1::INetd/default + + + android.system.wifi.keystore + hwbinder + 1.0 + + IKeystore + default + + @1.0::IKeystore/default + + + netutils-wrapper + 1.0 + + + vendor.qti.hardware.qccsyshal + hwbinder + 1.0 + + IQccsyshal + qccsyshal + + @1.0::IQccsyshal/qccsyshal + + + vendor.qti.hardware.radio.atcmdfwd + hwbinder + 1.0 + + IAtCmdFwd + AtCmdFwdService + + @1.0::IAtCmdFwd/AtCmdFwdService + + + vendor.qti.hardware.sigma_miracast + hwbinder + 1.0 + + Isigma_miracast + sigmahal + + @1.0::Isigma_miracast/sigmahal + + + vendor.qti.hardware.systemhelper + hwbinder + 1.0 + + ISystemEvent + default + + + ISystemResource + default + + @1.0::ISystemEvent/default + @1.0::ISystemResource/default + + + vendor.qti.hardware.wifi.keystore + hwbinder + 1.0 + + IKeystoreExt + default + + @1.0::IKeystoreExt/default + + + 28 + 29 + 30 + + diff --git a/recovery/root/system/etc/vintf/manifest/android.hidl.allocator@1.0-service.xml b/recovery/root/system/etc/vintf/manifest/android.hidl.allocator@1.0-service.xml new file mode 100644 index 0000000..5218241 --- /dev/null +++ b/recovery/root/system/etc/vintf/manifest/android.hidl.allocator@1.0-service.xml @@ -0,0 +1,11 @@ + + + android.hidl.allocator + hwbinder + 1.0 + + IAllocator + ashmem + + + diff --git a/recovery/root/system/etc/vintf/manifest/android.system.suspend@1.0-service.xml b/recovery/root/system/etc/vintf/manifest/android.system.suspend@1.0-service.xml new file mode 100644 index 0000000..9f06ae3 --- /dev/null +++ b/recovery/root/system/etc/vintf/manifest/android.system.suspend@1.0-service.xml @@ -0,0 +1,11 @@ + + + android.system.suspend + hwbinder + 1.0 + + ISystemSuspend + default + + + diff --git a/recovery/root/ueventd.rc b/recovery/root/ueventd.rc new file mode 100644 index 0000000..ef425ce --- /dev/null +++ b/recovery/root/ueventd.rc @@ -0,0 +1,475 @@ +# Copyright (c) 2012-2015, 2017-2020, 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 BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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. +# + +# Firmware directory Path +# Below macro will be read by uevent and path will +# be added to search path for firmware loading +firmware_directories /vendor/firmware_mnt/image/ + +# the DIAG device node is not world writable/readable. +/dev/diag 0660 system oem_2901 +/dev/mhi_*_pipe_4 0660 system system + +/dev/genlock 0666 system system +/dev/wlan 0660 wifi wifi +/dev/kgsl 0666 system system +/dev/kgsl-3d0 0666 system system +/dev/kgsl-2d0 0666 root root +/dev/kgsl-2d1 0666 root root +/dev/ion 0664 system system +/dev/membuf 0664 system system +/dev/rtc0 0660 system system +/dev/smd0 0660 system system +/dev/smd4 0660 system system +/dev/smd_cxm_qmi 0640 radio radio +/dev/smd5 0660 system system +/dev/smd6 0660 system system +/dev/smd7 0660 bluetooth bluetooth +/dev/ccid_bridge 0660 system system +/dev/ipa 0660 radio radio +/dev/wwan_ioctl 0660 radio radio +/dev/ipaNatTable 0660 radio radio +/dev/rmnet_ctrl 0660 usb usb +/dev/dpl_ctrl 0660 usb usb +/dev/ipa_odl_ctl 0660 radio radio +/dev/ipa_adpl 0660 system oem_2905 +/dev/synx_device 0660 root camera +/dev/hab 0666 system system +/dev/iio:device* 0664 system system + +#permissions for UFS RPMB BSG device node +/dev/0:0:0:49476 0600 system system + +#permissions for CSVT +/dev/smd11 0660 radio radio + +#permsissions for BT/FM +/dev/smd2 0660 bluetooth bluetooth +/dev/smd3 0660 bluetooth bluetooth +/dev/btpower 0660 bluetooth system + +#permissions for pta +/dev/pta 0660 system system + +/dev/radio0 0640 system system +/dev/rfcomm0 0660 bluetooth bluetooth +/dev/ttyUSB0 0660 bluetooth bluetooth +/dev/smdcntl0 0640 radio radio +/dev/smdcntl1 0640 radio radio +/dev/smdcntl2 0640 radio radio +/dev/smdcntl3 0640 radio radio +/dev/smdcntl4 0640 radio radio +/dev/smdcntl5 0640 radio radio +/dev/smdcntl6 0640 radio radio +/dev/smdcntl7 0640 radio radio +/dev/smdcntl8 0640 radio radio +/dev/smdcnt_rev0 0640 radio radio +/dev/smdcnt_rev1 0640 radio radio +/dev/smdcnt_rev2 0640 radio radio +/dev/smdcnt_rev3 0640 radio radio +/dev/smdcnt_rev4 0640 radio radio +/dev/smdcnt_rev5 0640 radio radio +/dev/smdcnt_rev6 0640 radio radio +/dev/smdcnt_rev7 0640 radio radio +/dev/smdcnt_rev8 0640 radio radio +/dev/smuxctl32 0640 radio radio +/dev/sdioctl0 0640 radio radio +/dev/sdioctl1 0640 radio radio +/dev/sdioctl2 0640 radio radio +/dev/sdioctl3 0640 radio radio +/dev/sdioctl4 0640 radio radio +/dev/sdioctl5 0640 radio radio +/dev/sdioctl6 0640 radio radio +/dev/sdioctl7 0640 radio radio +/dev/sdioctl8 0640 radio radio +/dev/rmnet_mux_ctrl 0640 radio radio +/dev/hsicctl0 0640 radio radio +/dev/hsicctl1 0640 radio radio +/dev/hsicctl2 0640 radio radio +/dev/hsicctl3 0640 radio radio +/dev/hsicctl4 0640 radio radio +/dev/hsicctl5 0640 radio radio +/dev/hsicctl6 0640 radio radio +/dev/hsicctl7 0640 radio radio +/dev/hsicctl8 0640 radio radio +/dev/hsicctl9 0640 radio radio +/dev/hsicctl10 0640 radio radio +/dev/hsicctl11 0640 radio radio +/dev/hsicctl12 0640 radio radio +/dev/hsicctl13 0640 radio radio +/dev/hsicctl14 0640 radio radio +/dev/hsicctl15 0640 radio radio +/dev/hsicctl16 0640 radio radio +/dev/mhi_*_pipe_14 0640 radio radio +/dev/mhi_*_pipe_16 0640 radio radio +/dev/mhi_*_pipe_32 0640 radio radio +/dev/at_usb0 0640 radio radio +/dev/at_mdm0 0640 radio radio +/dev/video* 0660 system camera +/dev/cvp* 0660 system camera +/dev/media* 0660 system camera +/dev/v4l-subdev* 0660 system camera +/dev/qseecom 0660 system drmrpc +/dev/qce 0660 system drmrpc +/dev/smcinvoke 0660 system drmrpc +/dev/qsee_ipc_irq_spss 0660 system drmrpc +/dev/seemplog 0660 system system +/dev/pft 0660 system drmrpc +/dev/spcom 0660 system system +/dev/spss_utils 0660 system system +/dev/sp_kernel 0660 system system +/dev/sp_nvm 0660 system system +/dev/sp_ssr 0660 system system +/dev/sp_keymaster 0660 system system +/dev/sp_keymaster_ssr 0660 system system +/dev/sec_nvm_* 0660 system system +/dev/cryptoapp 0660 system system +/dev/spdaemon_ssr 0660 system system +/dev/spu_hal_ssr 0660 system system +/dev/iuicc* 0660 system system +/dev/gemini0 0660 system camera +/dev/jpeg0 0660 system camera +/dev/jpeg1 0660 system camera +/dev/jpeg2 0660 system camera +/dev/jpeg3 0660 system camera +/dev/adsprpc-smd 0664 system system +/dev/adsprpc-smd-secure 0644 system system +/dev/system_health_monitor 0644 radio system +/dev/mdss_rotator 0664 system system + +#QDSS +/dev/byte-cntr 0660 system oem_2902 +/dev/mhi_qdss 0660 system oem_2902 +/sys/class/qdss_bridge/mhi_qdss mode 0660 system oem_2902 + +#qg +/dev/qg 0660 system system +/dev/qg_battery 0660 system system + +#qvr +/dev/qvr_external_sensor_ioctl 0660 system system +/sys/kernel/qvr_external_sensor/fd 0660 system system + +# wlan +/dev/wcnss_wlan 0660 system system +/dev/wcnss_ctrl 0660 system system +/sys/devices/soc/a000000.qcom,wcnss-wlan/net/wlan0/queues/rx-* rps_cpus 0660 system system +/sys/devices/soc/a000000.qcom,wcnss-wlan/net/p2p0/queues/rx-* rps_cpus 0660 system system +/sys/devices/platform/soc/18800000.qcom,icnss/net/wlan*/queues/rx-* rps_cpus 0660 system system +/sys/devices/platform/soc/1c00000.qcom,pcie/pci0000:00/0000:00:00.0/0000:01:00.0/net/wlan*/queues/rx-* rps_cpus 0660 system system +/dev/spidev0.0 0660 system audio +/dev/i2c-7 0660 system audio +/dev/msm_camera/* 0660 system camera +/dev/gemini/ 0660 system camera +/dev/mercury0 0660 system camera +/dev/msm_vidc_reg 0660 system audio +/dev/msm_vidc_dec 0660 system audio +/dev/msm_vidc_dec_sec 0660 system audio +/dev/msm_vidc_enc 0660 system audio +/dev/msm_rotator 0660 system system +/dev/hw_random 0600 root root +/dev/sdsprpc-smd 0660 system system + +#permissions for audio +/dev/wcd_dsp0_control 0660 system audio +/dev/wcd-dsp-glink 0660 system audio +/dev/audio_slimslave 0660 system audio +/dev/msm_qcelp 0660 system audio +/dev/msm_evrc 0660 system audio +/dev/msm_wma 0660 system audio +/dev/msm_wmapro 0660 system audio +/dev/msm_alac 0660 system audio +/dev/msm_ape 0660 system audio +/dev/msm_amrnb 0660 system audio +/dev/msm_amrwb 0660 system audio +/dev/msm_amrwbplus 0660 system audio +/dev/msm_aac 0660 system audio +/dev/msm_multi_aac 0660 system audio +/dev/msm_aac_in 0660 system audio +/dev/msm_qcelp_in 0660 system audio +/dev/msm_evrc_in 0660 system audio +/dev/msm_amrnb_in 0660 system audio +/dev/msm_amrwb_in 0660 system audio +/dev/msm_a2dp_in 0660 system audio +/dev/msm_ac3 0660 system audio +/dev/msm_audio_cal 0660 system audio +/dev/msm_hweffects 0660 system audio +/dev/msm_cad 0660 system audio +/dev/msm_fm 0660 system audio +/dev/msm_mvs 0660 system audio +/dev/msm_pcm_lp_dec 0660 system audio +/dev/msm_preproc_ctl 0660 system audio +/dev/msm_rtac 0660 system audio +/dev/msm_voicememo 0660 system audio +/dev/ttyHSL1 0660 system system +/dev/ttyHS1 0660 system system +/dev/mdm 0660 system radio +/sys/devices/virtual/smdpkt/smdcntl* open_timeout 0664 radio radio +/dev/sdio_tty_ciq_00 0660 system system +/dev/tty_sdio_00 0660 system system +/dev/ttyGS0 0660 system system +/dev/i2c-5 0660 media media +/dev/avtimer 0660 system audio +/dev/spidev2.0 0660 system audio +/dev/spidev22.0 0660 system audio + +# DVB devices +/dev/dvb/adapter0/demux* 0440 media media +/dev/dvb/adapter0/dvr* 0660 media media +/dev/dvb/adapter0/video* 0660 media media + +# Broadcast devices +/dev/tsc_mux0 0660 media media +/dev/tsc_ci0 0660 media media + +# sensors +/dev/sensors 0660 system system +/sys/devices/i2c-12/12-* pollrate_ms 0664 system system +/sys/devices/f9925000.i2c/i2c-0/0-* enable 0660 input system +/sys/devices/f9925000.i2c/i2c-0/0-* poll_delay 0660 input system +/sys/devices/soc.0/78b6000.i2c/i2c-0/0-* enable 0660 input system +/sys/devices/soc.0/78b6000.i2c/i2c-0/0-* poll_delay 0660 input system +/sys/devices/soc.0/78b6000.i2c/i2c-0/0-* enable_wakeup 0660 input system +/sys/devices/soc.0/78b6000.i2c/i2c-0/0-* max_latency 0660 input system +/sys/devices/soc.0/78b6000.i2c/i2c-0/0-* flush 0660 input system +/sys/devices/soc.0/78b6000.i2c/i2c-0/0-* calibrate 0660 input system +/sys/devices/soc.0/78b5000.i2c/i2c-1/1-* enable 0660 input system +/sys/devices/soc.0/78b5000.i2c/i2c-1/1-* poll_delay 0660 input system +/sys/devices/soc.0/78b5000.i2c/i2c-1/1-* enable_wakeup 0660 input system +/sys/devices/soc.0/78b5000.i2c/i2c-1/1-* max_latency 0660 input system +/sys/devices/soc.0/78b5000.i2c/i2c-1/1-* flush 0660 input system +/sys/devices/soc.0/78b5000.i2c/i2c-1/1-* calibrate 0660 input system +/sys/devices/virtual/optical_sensors/proximity ps_adc 0660 input system +/sys/devices/virtual/optical_sensors/proximity ps_poll_delay 0660 input system +/sys/devices/virtual/optical_sensors/lightsensor ls_auto 0660 input system +/sys/devices/virtual/optical_sensors/lightsensor ls_poll_delay 0660 input system +/sys/devices/virtual/input/input* poll 0660 input system +/sys/devices/virtual/input/input* pollrate_ms 0660 input system +/sys/devices/soc/78b7000.i2c/i2c-3/3-0020/input/input* secure_touch 0440 system drmrpc +/sys/devices/soc/78b7000.i2c/i2c-3/3-0020/input/input* secure_touch_enable 0660 system drmrpc +/sys/devices/soc/78b7000.i2c/i2c-3/3-0038/input/input* secure_touch 0440 system drmrpc +/sys/devices/soc/78b7000.i2c/i2c-3/3-0038/input/input* secure_touch_enable 0660 system drmrpc +/sys/devices/soc/78b7000.i2c/i2c-3/3-004b/input/input* secure_touch 0440 system drmrpc +/sys/devices/soc/78b7000.i2c/i2c-3/3-004b/input/input* secure_touch_enable 0660 system drmrpc +/sys/devices/soc/c179000.i2c/i2c-5/5-0020/input/input* secure_touch 0440 system drmrpc +/sys/devices/soc/c179000.i2c/i2c-5/5-0020/input/input* secure_touch_enable 0660 system drmrpc +/sys/devices/platform/soc/a98000.i2c/i2c-2/2-0020/input/input* secure_touch 0440 system drmrpc +/sys/devices/platform/soc/a98000.i2c/i2c-2/2-0020/input/input* secure_touch_enable 0660 system drmrpc +/sys/devices/platform/soc/a84000.i2c/i2c-2/2-0020/input/input* secure_touch 0440 system drmrpc +/sys/devices/platform/soc/a84000.i2c/i2c-2/2-0020/input/input* secure_touch_enable 0660 system drmrpc + +# GNSS Device premissions +/dev/gnss_sirf 0660 gps gps + +# laser sensor access +/sys/devices/virtual/input/input* enable_ps_sensor 0660 system input +/sys/devices/virtual/input/input* set_delay_ms 0660 system input +/sys/devices/virtual/input/input* do_flush 0660 system input + +# vm_bms +/dev/vm_bms 0660 system system +/dev/battery_data 0660 system system + +# wlan +/dev/wcnss_wlan 0660 system system +/dev/wcnss_ctrl 0660 system system +/sys/devices/soc/600000.qcom,pcie/pci0000:00/0000:00:00.0/0000:01:00.0/net/wlan0/queues/rx-* rps_cpus 0660 system system +/sys/devices/soc/600000.qcom,pcie/pci0000:00/0000:00:00.0/0000:01:00.0/net/p2p0/queues/rx-* rps_cpus 0660 system system + +# wigig +/sys/bus/pci/drivers/wil6210* 0000:01:00.0/wil6210/fst_link_loss 0660 wifi wifi +/sys/bus/pci/drivers/wil6210* 0000:01:00.0/wil6210/thermal_throttling 0660 system system +/sys/bus/pci/drivers/wil6210* 0000:01:00.0/wil6210/snr_thresh 0660 wifi wifi +/sys/bus/pci/drivers/wil6210* 0000:01:00.0/net/wigig0/queues/rx-0/rps_cpus 0660 system system +/sys/bus/pci/drivers/wil6210* 0000:01:00.0/net/wigig0/gro_flush_timeout 0660 system system +/sys/devices/virtual/net/bond0 queues/rx-0/rps_cpus 0660 system system + +#nfc permissions +/dev/nfc-nci 0660 nfc nfc +/dev/nq-nci 0660 nfc nfc +/dev/assd 0660 nfc nfc + +# UIO devices +/dev/uio0 0660 system system +/dev/uio1 0660 system system +/dev/uio2 0660 system system + +# SSR devices +/dev/subsys_* 0640 system system + +# Ultrasound device +/dev/usf1 0660 system system + +# Ramdump devices +/dev/ramdump* 0640 system system + +# Fingerprint device +/dev/qbt* 0660 system system +/sys/class/fts/touch_aoi aoi_set 0660 root system +/sys/class/fts/touch_aoi power_set 0660 root system + +#ImproveTouch device +/dev/hbtp_input 0660 system system +/dev/hbtp_vm 0660 system system + +# Add device block for FRP +/dev/block/platform/soc/7824900.sdhci/by-name/config 0600 system system +/dev/block/platform/soc/7464900.sdhci/by-name/frp 0600 system system +/dev/block/platform/soc/624000.ufshc/by-name/frp 0600 system system +/dev/block/platform/soc/1da4000.ufshc/by-name/frp 0600 system system +/dev/block/platform/soc/c0c4000.sdhci/by-name/frp 0600 system system +/dev/block/platform/soc/1d84000.ufshc/by-name/frp 0600 system system +/dev/block/platform/soc/7c4000.sdhci/by-name/frp 0600 system system +/dev/block/platform/soc/4744000.sdhci/by-name/frp 0600 system system +/dev/block/platform/soc/4804000.ufshc/by-name/frp 0600 system system + +# This is temporary while using SD card for initial bring-up +/dev/block/platform/soc/8804000.sdhci/by-name/frp 0600 system system + +# Kmsg device +/dev/kmsg 0620 root system + +# LED class devices +/sys/class/leds/red delay_on 0640 system system +/sys/class/leds/red delay_off 0640 system system +/sys/class/leds/red breath 0640 system system +/sys/class/leds/red trigger 0640 system system +/sys/class/leds/green delay_on 0640 system system +/sys/class/leds/green delay_off 0640 system system +/sys/class/leds/green breath 0640 system system +/sys/class/leds/green trigger 0640 system system +/sys/class/leds/blue delay_on 0640 system system +/sys/class/leds/blue delay_off 0640 system system +/sys/class/leds/blue breath 0640 system system +/sys/class/leds/blue trigger 0640 system system + +# NPU device +/dev/msm_npu 0644 system system + +# USB role switch +/sys/class/dual_role_usb/* data_role 0660 system system +/sys/class/dual_role_usb/* power_role 0660 system system +/sys/class/dual_role_usb/* mode 0660 system system + +#Memory Offline +/sys/devices/system/memory/memory* state 0660 system system + +/sys/devices/virtual/hdcp/msm_hdcp min_level_change 0664 system graphics + +# sys-fs display +/sys/class/graphics/fb* hpd 0664 system graphics +/sys/class/graphics/fb* res_info 0664 system graphics +/sys/class/graphics/fb* vendor_name 0664 system graphics +/sys/class/graphics/fb* product_description 0664 system graphics +/sys/class/graphics/fb* video_mode 0664 system graphics +/sys/class/graphics/fb* format_3d 0664 system graphics +/sys/class/graphics/fb* s3d_mode 0664 system graphics +/sys/class/graphics/fb* dynamic_fps 0664 system graphics +/sys/class/graphics/fb* msm_fb_dfps_mode 0664 system graphics +/sys/class/graphics/fb* hdr_stream 0664 system graphics +/sys/class/graphics/fb* cec/enable 0664 system graphics +/sys/class/graphics/fb* cec/logical_addr 0664 system graphics +/sys/class/graphics/fb* cec/rd_msg 0664 system graphics +/sys/class/graphics/fb* pa 0664 system graphics +/sys/class/graphics/fb* cec/wr_msg 0600 system graphics +/sys/class/graphics/fb* hdcp/tp 0664 system graphics +/sys/class/graphics/fb* hdcp2p2/min_level_change 0660 system graphics +/sys/class/graphics/fb* hdmi_audio_cb 0600 audioserver audio + +/sys/class/graphics/fb* lineptr_value 0664 system graphics +/sys/class/graphics/fb* msm_fb_persist_mode 0664 system graphics + +/sys/class/graphics/fb0 idle_time 0664 system graphics +/sys/class/graphics/fb0 dynamic_fps 0664 system graphics +/sys/class/graphics/fb0 dyn_pu 0664 system graphics +/sys/class/graphics/fb0 modes 0664 system graphics +/sys/class/graphics/fb0 mode 0664 system graphics +/sys/class/graphics/fb0 msm_cmd_autorefresh_en 0664 system graphics +*/ + +/sys/devices/platform/soc/ae00000.qcom,mdss_mdp power/control 0664 system graphics + +#asm330 sensor +#common sensors files +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* buffer/enable 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* buffer/length 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* buffer/watermark 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* discharded_samples 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* current_timestamp_clock 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* hwfifo_flush 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* hwfifo_watermark 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* hwfifo_watermark_max 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* mount_matrix 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* name 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* sampling_frequency 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* sampling_frequency_available 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* scan_elements/in_timestamp_en 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* scan_elements/in_timestamp_index 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* scan_elements/in_timestamp_type 0664 system system + +# standard iio accel attributes +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* in_accel_scale_available 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* in_accel_x_raw 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* in_accel_x_scale 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* in_accel_y_raw 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* in_accel_y_scale 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* in_accel_z_raw 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* in_accel_z_scale 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* scan_elements/in_accel_x_en 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* scan_elements/in_accel_x_index 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* scan_elements/in_accel_x_type 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* scan_elements/in_accel_y_en 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* scan_elements/in_accel_y_index 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* scan_elements/in_accel_y_type 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* scan_elements/in_accel_z_en 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* scan_elements/in_accel_z_index 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* scan_elements/in_accel_z_type 0664 system system + +# standard iio gyro attributes +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* in_anglvel_scale_available 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* in_anglvel_x_raw 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* in_anglvel_x_scale 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* in_anglvel_y_raw 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* in_anglvel_y_scale 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* in_anglvel_z_raw 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* in_anglvel_z_scale 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* scan_elements/in_anglvel_x_en 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* scan_elements/in_anglvel_x_index 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* scan_elements/in_anglvel_x_type 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* scan_elements/in_anglvel_y_en 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* scan_elements/in_anglvel_y_index 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* scan_elements/in_anglvel_y_type 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* scan_elements/in_anglvel_z_en 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* scan_elements/in_anglvel_z_index 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* scan_elements/in_anglvel_z_type 0664 system system + + +# standard iio temp attributes +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* in_temp_offset 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* in_temp_raw 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* in_temp_scale 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* in_temp_scale_available 0664 system system diff --git a/recovery/root/vendor/bin/hw/vendor.xiaomi.hw.touchfeature@1.0-service b/recovery/root/vendor/bin/hw/vendor.xiaomi.hw.touchfeature@1.0-service new file mode 100644 index 0000000..16a8396 Binary files /dev/null and b/recovery/root/vendor/bin/hw/vendor.xiaomi.hw.touchfeature@1.0-service differ diff --git a/recovery/root/vendor/etc/vintf/manifest.xml b/recovery/root/vendor/etc/vintf/manifest.xml new file mode 100644 index 0000000..fbe16df --- /dev/null +++ b/recovery/root/vendor/etc/vintf/manifest.xml @@ -0,0 +1,564 @@ + + + + android.hardware.audio + hwbinder + 6.0 + + IDevicesFactory + default + + @6.0::IDevicesFactory/default + + + android.hardware.audio.effect + hwbinder + 6.0 + + IEffectsFactory + default + + @6.0::IEffectsFactory/default + + + android.hardware.bluetooth + hwbinder + 1.0 + + IBluetoothHci + default + + @1.0::IBluetoothHci/default + + + android.hardware.bluetooth.audio + hwbinder + 2.0 + + IBluetoothAudioProvidersFactory + default + + @2.0::IBluetoothAudioProvidersFactory/default + + + android.hardware.camera.provider + hwbinder + 2.4 + + ICameraProvider + legacy/0 + + @2.4::ICameraProvider/legacy/0 + + + android.hardware.drm + hwbinder + @1.3::ICryptoFactory/wfdhdcp + @1.3::IDrmFactory/wfdhdcp + + + android.hardware.gatekeeper + hwbinder + 1.0 + + IGatekeeper + default + + @1.0::IGatekeeper/default + + + android.hardware.keymaster + hwbinder + @4.1::IKeymasterDevice/default + + + android.hardware.media.omx + hwbinder + 1.0 + + IOmx + default + + + IOmxStore + default + + @1.0::IOmx/default + @1.0::IOmxStore/default + + + android.hardware.memtrack + hwbinder + 1.0 + + IMemtrack + default + + @1.0::IMemtrack/default + + + android.hardware.radio.config + hwbinder + 1.1 + + IRadioConfig + default + + @1.1::IRadioConfig/default + + + android.hardware.soundtrigger + hwbinder + 2.3 + + ISoundTriggerHw + default + + @2.3::ISoundTriggerHw/default + + + android.hardware.tetheroffload.config + hwbinder + 1.0 + + IOffloadConfig + default + + @1.0::IOffloadConfig/default + + + android.hardware.tetheroffload.control + hwbinder + 1.0 + + IOffloadControl + default + + @1.0::IOffloadControl/default + + + com.qualcomm.qti.dpm.api + hwbinder + 1.0 + + IdpmQmi + dpmQmiService + + @1.0::IdpmQmi/dpmQmiService + + + com.qualcomm.qti.imscmservice + hwbinder + 2.2 + + IImsCmService + qti.ims.connectionmanagerservice + + @2.2::IImsCmService/qti.ims.connectionmanagerservice + + + com.qualcomm.qti.uceservice + hwbinder + 2.2 + + IUceService + com.qualcomm.qti.uceservice + + @2.2::IUceService/com.qualcomm.qti.uceservice + + + vendor.qti.data.factory + hwbinder + 2.1 + + IFactory + default + + @2.1::IFactory/default + + + vendor.qti.esepowermanager + hwbinder + 1.1 + + IEsePowerManager + default + + @1.1::IEsePowerManager/default + + + vendor.qti.hardware.alarm + hwbinder + 1.0 + + IAlarm + default + + @1.0::IAlarm/default + + + vendor.qti.hardware.bluetooth_audio + hwbinder + 2.0 + + IBluetoothAudioProvidersFactory + default + + @2.0::IBluetoothAudioProvidersFactory/default + + + vendor.qti.hardware.bluetooth_sar + hwbinder + 1.1 + + IBluetoothSar + default + + @1.1::IBluetoothSar/default + + + vendor.qti.hardware.btconfigstore + hwbinder + 2.0 + + IBTConfigStore + default + + @2.0::IBTConfigStore/default + + + vendor.qti.hardware.cacert + hwbinder + 1.0 + + IService + default + + @1.0::IService/default + + + vendor.qti.hardware.camera.postproc + hwbinder + 1.0 + + IPostProcService + camerapostprocservice + + @1.0::IPostProcService/camerapostprocservice + + + vendor.qti.hardware.capabilityconfigstore + hwbinder + 1.0 + + ICapabilityConfigStore + default + + @1.0::ICapabilityConfigStore/default + + + vendor.qti.hardware.data.latency + hwbinder + 1.0 + + ILinkLatency + default + + @1.0::ILinkLatency/default + + + vendor.qti.hardware.dsp + hwbinder + 1.0 + + IDspService + dspservice + + @1.0::IDspService/dspservice + + + vendor.qti.hardware.eid + hwbinder + 1.0 + + IEid + default + + @1.0::IEid/default + + + vendor.qti.hardware.embmssl + hwbinder + 1.1 + + IEmbms + embmsslServer0 + + @1.1::IEmbms/embmsslServer0 + + + vendor.qti.hardware.factory + hwbinder + 1.1 + + IFactory + default + + @1.1::IFactory/default + + + vendor.qti.hardware.fstman + hwbinder + 1.0 + + IFstManager + default + + @1.0::IFstManager/default + + + vendor.qti.hardware.iop + hwbinder + 2.0 + + IIop + default + + @2.0::IIop/default + + + vendor.qti.hardware.perf + hwbinder + 2.2 + + IPerf + default + + @2.2::IPerf/default + + + vendor.qti.hardware.qccvndhal + hwbinder + 1.0 + + IQccvndhal + qccvndhal + + @1.0::IQccvndhal/qccvndhal + + + vendor.qti.hardware.qconfig + hwbinder + 1.0 + + IQConfig + default + + @1.0::IQConfig/default + + + vendor.qti.hardware.qseecom + hwbinder + 1.0 + + IQSEECom + default + + @1.0::IQSEECom/default + + + vendor.qti.hardware.qteeconnector + hwbinder + 1.0 + + IAppConnector + default + + + IGPAppConnector + default + + @1.0::IAppConnector/default + @1.0::IGPAppConnector/default + + + vendor.qti.hardware.radio.internal.deviceinfo + hwbinder + 1.0 + + IDeviceInfo + deviceinfo + + @1.0::IDeviceInfo/deviceinfo + + + vendor.qti.hardware.secureprocessor.device + hwbinder + 1.0 + + ISecureProcessor + qti-tee + + @1.0::ISecureProcessor/qti-tee + + + vendor.qti.hardware.sensorscalibrate + hwbinder + 1.0 + + ISensorsCalibrate + default + + @1.0::ISensorsCalibrate/default + + + vendor.qti.hardware.soter + hwbinder + 1.0 + + ISoter + default + + @1.0::ISoter/default + + + vendor.qti.hardware.trustedui + hwbinder + @1.0::ITrustedInput/default + @1.0::ITrustedInput/qtee-vm + @1.1::ITrustedUI/default + @1.1::ITrustedUI/qtee-vm + + + vendor.qti.hardware.tui_comm + hwbinder + 1.0 + + ITuiComm + default + + @1.0::ITuiComm/default + + + vendor.qti.hardware.vpp + hwbinder + 2.0 + + IHidlVppService + vppService + + @2.0::IHidlVppService/vppService + + + vendor.qti.hardware.wifi.wifilearner + hwbinder + 1.0 + + IWifiStats + wifiStats + + @1.0::IWifiStats/wifiStats + + + vendor.qti.hardware.wifidisplaysession + hwbinder + 1.0 + + IWifiDisplaySession + wifidisplaysession + + + IWifiDisplaySessionAudioTrack + wifidisplaysessionaudiotrack + + + IWifiDisplaySessionImageTrack + wifidisplaysessionimagetrack + + + IWifiDisplaySessionVideoTrack + wifidisplaysessionvideotrack + + @1.0::IWifiDisplaySession/wifidisplaysession + @1.0::IWifiDisplaySessionAudioTrack/wifidisplaysessionaudiotrack + @1.0::IWifiDisplaySessionImageTrack/wifidisplaysessionimagetrack + @1.0::IWifiDisplaySessionVideoTrack/wifidisplaysessionvideotrack + + + vendor.qti.ims.callinfo + hwbinder + 1.0 + + IService + default + + @1.0::IService/default + + + vendor.qti.ims.factory + hwbinder + 1.1 + + IImsFactory + default + + @1.1::IImsFactory/default + + + vendor.qti.imsrtpservice + hwbinder + 3.0 + + IRTPService + imsrtpservice + + @3.0::IRTPService/imsrtpservice + + + vendor.qti.qspmhal + hwbinder + 1.0 + + IQspmhal + default + + @1.0::IQspmhal/default + + + vendor.qti.sla.service + hwbinder + 1.0 + + ISlaService + default + + @1.0::ISlaService/default + + + vendor.xiaomi.hardware.campostproc + hwbinder + 1.0 + + IMiPostProcService + default + + @1.0::IMiPostProcService/default + + + vendor.xiaomi.hardware.displayfeature + hwbinder + 1.0 + + IDisplayFeature + default + + @1.0::IDisplayFeature/default + + + 30.0 + + + diff --git a/recovery/root/vendor/etc/vintf/manifest/android.hardware.boot@1.1.xml b/recovery/root/vendor/etc/vintf/manifest/android.hardware.boot@1.1.xml new file mode 100644 index 0000000..83d5d2e --- /dev/null +++ b/recovery/root/vendor/etc/vintf/manifest/android.hardware.boot@1.1.xml @@ -0,0 +1,7 @@ + + + android.hardware.boot + hwbinder + @1.1::IBootControl/default + + diff --git a/recovery/root/vendor/etc/vintf/manifest/android.hardware.health@2.1.xml b/recovery/root/vendor/etc/vintf/manifest/android.hardware.health@2.1.xml new file mode 100644 index 0000000..34fdca6 --- /dev/null +++ b/recovery/root/vendor/etc/vintf/manifest/android.hardware.health@2.1.xml @@ -0,0 +1,7 @@ + + + android.hardware.health + hwbinder + @2.1::IHealth/default + + diff --git a/recovery/root/vendor/etc/vintf/manifest/android.hardware.usb@1.2-service.xml b/recovery/root/vendor/etc/vintf/manifest/android.hardware.usb@1.2-service.xml new file mode 100644 index 0000000..3af5c1f --- /dev/null +++ b/recovery/root/vendor/etc/vintf/manifest/android.hardware.usb@1.2-service.xml @@ -0,0 +1,39 @@ + + + + android.hardware.usb + hwbinder + 1.2 + + IUsb + default + + @1.2::IUsb/default + + diff --git a/recovery/root/vendor/etc/vintf/manifest/manifest_android.hardware.drm@1.3-service.clearkey.xml b/recovery/root/vendor/etc/vintf/manifest/manifest_android.hardware.drm@1.3-service.clearkey.xml new file mode 100644 index 0000000..229ee96 --- /dev/null +++ b/recovery/root/vendor/etc/vintf/manifest/manifest_android.hardware.drm@1.3-service.clearkey.xml @@ -0,0 +1,23 @@ + + + + + android.hardware.drm + hwbinder + @1.3::ICryptoFactory/clearkey + @1.3::IDrmFactory/clearkey + + diff --git a/recovery/root/vendor/etc/vintf/manifest/manifest_android.hardware.drm@1.3-service.widevine.xml b/recovery/root/vendor/etc/vintf/manifest/manifest_android.hardware.drm@1.3-service.widevine.xml new file mode 100644 index 0000000..f6f2d88 --- /dev/null +++ b/recovery/root/vendor/etc/vintf/manifest/manifest_android.hardware.drm@1.3-service.widevine.xml @@ -0,0 +1,23 @@ + + + + + android.hardware.drm + hwbinder + @1.3::ICryptoFactory/widevine + @1.3::IDrmFactory/widevine + + diff --git a/recovery/root/vendor/etc/vintf/manifest/power.xml b/recovery/root/vendor/etc/vintf/manifest/power.xml new file mode 100644 index 0000000..016665e --- /dev/null +++ b/recovery/root/vendor/etc/vintf/manifest/power.xml @@ -0,0 +1,33 @@ + + + + android.hardware.power + IPower/default + + \ No newline at end of file diff --git a/recovery/root/vendor/etc/vintf/manifest/vendor.qti.hardware.vibrator.service.xml b/recovery/root/vendor/etc/vintf/manifest/vendor.qti.hardware.vibrator.service.xml new file mode 100644 index 0000000..df29ada --- /dev/null +++ b/recovery/root/vendor/etc/vintf/manifest/vendor.qti.hardware.vibrator.service.xml @@ -0,0 +1,33 @@ + + + + android.hardware.vibrator + IVibrator/default + + diff --git a/recovery/root/vendor/etc/vintf/manifest/vendor.xiaomi.hw.touchfeature@1.0-service.xml b/recovery/root/vendor/etc/vintf/manifest/vendor.xiaomi.hw.touchfeature@1.0-service.xml new file mode 100644 index 0000000..896e3e4 --- /dev/null +++ b/recovery/root/vendor/etc/vintf/manifest/vendor.xiaomi.hw.touchfeature@1.0-service.xml @@ -0,0 +1,11 @@ + + + vendor.xiaomi.hw.touchfeature + hwbinder + 1.0 + + ITouchFeature + default + + + diff --git a/recovery/root/vendor/firmware/goodix_gt9897t_cfg_k9.bin b/recovery/root/vendor/firmware/goodix_gt9897t_cfg_k9.bin new file mode 100644 index 0000000..9243353 Binary files /dev/null and b/recovery/root/vendor/firmware/goodix_gt9897t_cfg_k9.bin differ diff --git a/recovery/root/vendor/firmware/goodix_gt9897t_fw_k9.bin b/recovery/root/vendor/firmware/goodix_gt9897t_fw_k9.bin new file mode 100644 index 0000000..67035d6 Binary files /dev/null and b/recovery/root/vendor/firmware/goodix_gt9897t_fw_k9.bin differ diff --git a/recovery/root/vendor/lib/hw/vendor.xiaomi.hw.touchfeature@1.0-impl.so b/recovery/root/vendor/lib/hw/vendor.xiaomi.hw.touchfeature@1.0-impl.so new file mode 100644 index 0000000..7e58140 Binary files /dev/null and b/recovery/root/vendor/lib/hw/vendor.xiaomi.hw.touchfeature@1.0-impl.so differ diff --git a/recovery/root/vendor/lib/vendor.xiaomi.hw.touchfeature@1.0.so b/recovery/root/vendor/lib/vendor.xiaomi.hw.touchfeature@1.0.so new file mode 100644 index 0000000..32a0ebc Binary files /dev/null and b/recovery/root/vendor/lib/vendor.xiaomi.hw.touchfeature@1.0.so differ diff --git a/recovery/root/vendor/lib64/hw/android.hardware.gatekeeper@1.0-impl-qti.so b/recovery/root/vendor/lib64/hw/android.hardware.gatekeeper@1.0-impl-qti.so new file mode 100644 index 0000000..8de8e4b Binary files /dev/null and b/recovery/root/vendor/lib64/hw/android.hardware.gatekeeper@1.0-impl-qti.so differ diff --git a/recovery/root/vendor/lib64/hw/vendor.xiaomi.hw.touchfeature@1.0-impl.so b/recovery/root/vendor/lib64/hw/vendor.xiaomi.hw.touchfeature@1.0-impl.so new file mode 100644 index 0000000..850825e Binary files /dev/null and b/recovery/root/vendor/lib64/hw/vendor.xiaomi.hw.touchfeature@1.0-impl.so differ diff --git a/recovery/root/vendor/lib64/libGPreqcancel.so b/recovery/root/vendor/lib64/libGPreqcancel.so new file mode 100644 index 0000000..97607d7 Binary files /dev/null and b/recovery/root/vendor/lib64/libGPreqcancel.so differ diff --git a/recovery/root/vendor/lib64/libGPreqcancel_svc.so b/recovery/root/vendor/lib64/libGPreqcancel_svc.so new file mode 100644 index 0000000..4d09e35 Binary files /dev/null and b/recovery/root/vendor/lib64/libGPreqcancel_svc.so differ diff --git a/recovery/root/vendor/lib64/libQSEEComAPI.so b/recovery/root/vendor/lib64/libQSEEComAPI.so new file mode 100644 index 0000000..c357b1d Binary files /dev/null and b/recovery/root/vendor/lib64/libQSEEComAPI.so differ diff --git a/recovery/root/vendor/lib64/libdiag.so b/recovery/root/vendor/lib64/libdiag.so new file mode 100644 index 0000000..a656fa6 Binary files /dev/null and b/recovery/root/vendor/lib64/libdiag.so differ diff --git a/recovery/root/vendor/lib64/libdrm.so b/recovery/root/vendor/lib64/libdrm.so new file mode 100644 index 0000000..3ce2559 Binary files /dev/null and b/recovery/root/vendor/lib64/libdrm.so differ diff --git a/recovery/root/vendor/lib64/libdrmfs.so b/recovery/root/vendor/lib64/libdrmfs.so new file mode 100644 index 0000000..eb5d533 Binary files /dev/null and b/recovery/root/vendor/lib64/libdrmfs.so differ diff --git a/recovery/root/vendor/lib64/libdrmtime.so b/recovery/root/vendor/lib64/libdrmtime.so new file mode 100644 index 0000000..a38ed11 Binary files /dev/null and b/recovery/root/vendor/lib64/libdrmtime.so differ diff --git a/recovery/root/vendor/lib64/libkeymasterdeviceutils.so b/recovery/root/vendor/lib64/libkeymasterdeviceutils.so new file mode 100644 index 0000000..4003ea7 Binary files /dev/null and b/recovery/root/vendor/lib64/libkeymasterdeviceutils.so differ diff --git a/recovery/root/vendor/lib64/libkeymasterprovision.so b/recovery/root/vendor/lib64/libkeymasterprovision.so new file mode 100644 index 0000000..c85edea Binary files /dev/null and b/recovery/root/vendor/lib64/libkeymasterprovision.so differ diff --git a/recovery/root/vendor/lib64/libkeymasterutils.so b/recovery/root/vendor/lib64/libkeymasterutils.so new file mode 100644 index 0000000..7050bee Binary files /dev/null and b/recovery/root/vendor/lib64/libkeymasterutils.so differ diff --git a/recovery/root/vendor/lib64/libops.so b/recovery/root/vendor/lib64/libops.so new file mode 100644 index 0000000..e2537f7 Binary files /dev/null and b/recovery/root/vendor/lib64/libops.so differ diff --git a/recovery/root/vendor/lib64/libqcbor.so b/recovery/root/vendor/lib64/libqcbor.so new file mode 100644 index 0000000..0b0a467 Binary files /dev/null and b/recovery/root/vendor/lib64/libqcbor.so differ diff --git a/recovery/root/vendor/lib64/libqdutils.so b/recovery/root/vendor/lib64/libqdutils.so new file mode 100644 index 0000000..f092f3e Binary files /dev/null and b/recovery/root/vendor/lib64/libqdutils.so differ diff --git a/recovery/root/vendor/lib64/libqisl.so b/recovery/root/vendor/lib64/libqisl.so new file mode 100644 index 0000000..c72dfbd Binary files /dev/null and b/recovery/root/vendor/lib64/libqisl.so differ diff --git a/recovery/root/vendor/lib64/libqservice.so b/recovery/root/vendor/lib64/libqservice.so new file mode 100644 index 0000000..1bab682 Binary files /dev/null and b/recovery/root/vendor/lib64/libqservice.so differ diff --git a/recovery/root/vendor/lib64/libqtikeymaster4.so b/recovery/root/vendor/lib64/libqtikeymaster4.so new file mode 100644 index 0000000..27bbe45 Binary files /dev/null and b/recovery/root/vendor/lib64/libqtikeymaster4.so differ diff --git a/recovery/root/vendor/lib64/librecovery_updater_msm.so b/recovery/root/vendor/lib64/librecovery_updater_msm.so new file mode 100644 index 0000000..fdce85f Binary files /dev/null and b/recovery/root/vendor/lib64/librecovery_updater_msm.so differ diff --git a/recovery/root/vendor/lib64/librpmb.so b/recovery/root/vendor/lib64/librpmb.so new file mode 100644 index 0000000..d2f5de5 Binary files /dev/null and b/recovery/root/vendor/lib64/librpmb.so differ diff --git a/recovery/root/vendor/lib64/libsecureui_svcsock.so b/recovery/root/vendor/lib64/libsecureui_svcsock.so new file mode 100644 index 0000000..feb59ee Binary files /dev/null and b/recovery/root/vendor/lib64/libsecureui_svcsock.so differ diff --git a/recovery/root/vendor/lib64/libspcom.so b/recovery/root/vendor/lib64/libspcom.so new file mode 100644 index 0000000..3ceddd6 Binary files /dev/null and b/recovery/root/vendor/lib64/libspcom.so differ diff --git a/recovery/root/vendor/lib64/libspl.so b/recovery/root/vendor/lib64/libspl.so new file mode 100644 index 0000000..d43d60c Binary files /dev/null and b/recovery/root/vendor/lib64/libspl.so differ diff --git a/recovery/root/vendor/lib64/libssd.so b/recovery/root/vendor/lib64/libssd.so new file mode 100644 index 0000000..7f15710 Binary files /dev/null and b/recovery/root/vendor/lib64/libssd.so differ diff --git a/recovery/root/vendor/lib64/libtime_genoff.so b/recovery/root/vendor/lib64/libtime_genoff.so new file mode 100644 index 0000000..5b6223a Binary files /dev/null and b/recovery/root/vendor/lib64/libtime_genoff.so differ diff --git a/recovery/root/vendor/lib64/vendor.display.config@1.0.so b/recovery/root/vendor/lib64/vendor.display.config@1.0.so new file mode 100644 index 0000000..14972e7 Binary files /dev/null and b/recovery/root/vendor/lib64/vendor.display.config@1.0.so differ diff --git a/recovery/root/vendor/lib64/vendor.qti.hardware.tui_comm@1.0.so b/recovery/root/vendor/lib64/vendor.qti.hardware.tui_comm@1.0.so new file mode 100644 index 0000000..3501c97 Binary files /dev/null and b/recovery/root/vendor/lib64/vendor.qti.hardware.tui_comm@1.0.so differ diff --git a/recovery/root/vendor/lib64/vendor.xiaomi.hw.touchfeature@1.0.so b/recovery/root/vendor/lib64/vendor.xiaomi.hw.touchfeature@1.0.so new file mode 100644 index 0000000..2c9bec5 Binary files /dev/null and b/recovery/root/vendor/lib64/vendor.xiaomi.hw.touchfeature@1.0.so differ diff --git a/system.prop b/system.prop new file mode 100644 index 0000000..862e4ad --- /dev/null +++ b/system.prop @@ -0,0 +1,61 @@ +# Audio +audio.offload.min.duration.secs=30 +persist.vendor.audio.hac.enable=false +persist.vendor.audio_hal.dsp_bit_width_enforce_mode=24 + +# Bluetooth +ro.bluetooth.library_name=libbluetooth_qti.so + +# Camera +camera.disable_zsl_mode=true + +# Charger +ro.charger.disable_init_blank=true + +# Display +debug.gralloc.gfx_ubwc_disable=0 +debug.sf.enable_hwc_vds=1 +debug.sf.latch_unsignaled=1 +persist.vendor.color.matrix=2 + +# CNE +persist.vendor.cne.feature=1 + +# DPM +persist.vendor.dpm.feature=11 + +# IMS +persist.dbg.volte_avail_ovr=1 +persist.dbg.vt_avail_ovr=1 +persist.dbg.wfc_avail_ovr=1 + +# IOP +vendor.iop.enable_prefetch_ofr=1 +vendor.iop.enable_uxe=0 + +# Media +media.settings.xml=/vendor/etc/media_profiles_vendor.xml + +# Perf +ro.vendor.qti.core_ctl_max_cpu=4 +ro.vendor.qti.core_ctl_min_cpu=2 + +# Radio +ro.telephony.default_network=33,33 + +# Touchscreen +persist.vendor.qti.inputopts.enable=true +persist.vendor.qti.inputopts.movetouchslop=0.6 + +# Netmgr +persist.vendor.data.iwlan.enable=true +persist.vendor.data.mode=concurrent + +# SSR +persist.vendor.ssr.restart_level=ALL_ENABLE + +# Vendor +ro.vendor.qti.va_aosp.support=1 + +# Zygote +persist.device_config.runtime_native.usap_pool_enabled=true diff --git a/twrp.dependencies b/twrp.dependencies new file mode 100644 index 0000000..ddbcff7 --- /dev/null +++ b/twrp.dependencies @@ -0,0 +1,14 @@ +[ + { + "repository" : "android_device_qcom_twrp-common", + "target_path" : "device/qcom/twrp-common", + "remote" : "TeamWin", + "revision" : "android-11" + }, + { + "repository" : "android_hardware_qcom_bootctrl", + "target_path" : "hardware/qcom-caf/bootctrl", + "remote" : "LineageOS", + "revision" : "lineage-18.1-caf" + } +] diff --git a/twrp_renoir.mk b/twrp_renoir.mk new file mode 100644 index 0000000..4c63a35 --- /dev/null +++ b/twrp_renoir.mk @@ -0,0 +1,32 @@ +# +# Copyright (C) 2021 The TWRP Open Source Project +# +# 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. +# + +# Inherit from those products. Most specific first. +$(call inherit-product, $(SRC_TARGET_DIR)/product/core_64_bit.mk) +$(call inherit-product, $(SRC_TARGET_DIR)/product/aosp_base.mk) + +# Inherit from renoir device +$(call inherit-product, device/xiaomi/renoir/device.mk) + +# Inherit some common TWRP stuff. +$(call inherit-product, vendor/twrp/config/common.mk) + +# Device identifier. This must come after all inclusions +PRODUCT_DEVICE := renoir +PRODUCT_NAME := twrp_renoir +PRODUCT_BRAND := Xiaomi +PRODUCT_MODEL := Mi 11 Lite 5G +PRODUCT_MANUFACTURER := Xiaomi diff --git a/vendor.prop b/vendor.prop new file mode 100644 index 0000000..da3c1d6 --- /dev/null +++ b/vendor.prop @@ -0,0 +1,246 @@ +# Audio +aaudio.hw_burst_min_usec=2000 +aaudio.mmap_exclusive_policy=2 +aaudio.mmap_policy=2 +audio.deep_buffer.media=true +audio.offload.video=false +persist.audio.fluence.voicecomm=true +persist.vendor.audio.ambisonic.auto.profile=false +persist.vendor.audio.ambisonic.capture=false +persist.vendor.audio.apptype.multirec.enabled=false +persist.vendor.audio.avs.afe_api_version=9 +persist.vendor.audio.bcl.enabled=false +persist.vendor.audio.fluence.speaker=true +persist.vendor.audio.fluence.tmic.enabled=false +persist.vendor.audio.fluence.voicecall=true +persist.vendor.audio.fluence.voicerec=true +persist.vendor.audio.ha_proxy.enabled=true +persist.vendor.audio.ras.enabled=false +persist.vendor.audio.speaker.prot.enable=false +persist.vendor.audio.spv4.enable=false +persist.vendor.audio.vbat.enabled=false +persist.vendor.audio.voicecall.speaker.stereo=true +persist.vendor.audio_hal.dsp_bit_width_enforce_mode=24 +ro.audio.monitorRotation=true +ro.config.media_vol_steps=30 +ro.vendor.audio.sdk.fluencetype=fluence +ro.vendor.audio.sdk.ssr=false +ro.vendor.dolby.dax.version=DAX3_3.5.6.11_r1 +vendor.audio.adm.buffering.ms=2 +vendor.audio.dolby.ds2.enabled=false +vendor.audio.dolby.ds2.hardbypass=false +vendor.audio.dtmf.volume=35 +vendor.audio.enable.mirrorlink=false +vendor.audio.feature.a2dp_offload.enable=true +vendor.audio.feature.afe_proxy.enable=true +vendor.audio.feature.anc_headset.enable=false +vendor.audio.feature.audiozoom.enable=false +vendor.audio.feature.battery_listener.enable=true +vendor.audio.feature.compr_cap.enable=false +vendor.audio.feature.compr_voip.enable=false +vendor.audio.feature.compress_in.enable=true +vendor.audio.feature.compress_meta_data.enable=true +vendor.audio.feature.concurrent_capture.enable=true +vendor.audio.feature.custom_stereo.enable=true +vendor.audio.feature.deepbuffer_as_primary.enable=false +vendor.audio.feature.display_port.enable=true +vendor.audio.feature.dsm_feedback.enable=false +vendor.audio.feature.dynamic_ecns.enable=true +vendor.audio.feature.ext_hw_plugin.enable=false +vendor.audio.feature.external_dsp.enable=false +vendor.audio.feature.external_speaker.enable=false +vendor.audio.feature.external_speaker_tfa.enable=false +vendor.audio.feature.fluence.enable=true +vendor.audio.feature.fm.enable=true +vendor.audio.feature.hdmi_edid.enable=true +vendor.audio.feature.hdmi_passthrough.enable=true +vendor.audio.feature.hfp.enable=true +vendor.audio.feature.hifi_audio.enable=false +vendor.audio.feature.hwdep_cal.enable=false +vendor.audio.feature.incall_music.enable=true +vendor.audio.feature.keep_alive.enable=true +vendor.audio.feature.kpi_optimize.enable=true +vendor.audio.feature.maxx_audio.enable=false +vendor.audio.feature.multi_voice_session.enable=true +vendor.audio.feature.power_mode.enable=true +vendor.audio.feature.ras.enable=true +vendor.audio.feature.record_play_concurency.enable=false +vendor.audio.feature.snd_mon.enable=true +vendor.audio.feature.spkr_prot.enable=false +vendor.audio.feature.src_trkn.enable=true +vendor.audio.feature.ssrec.enable=true +vendor.audio.feature.usb_offload.enable=true +vendor.audio.feature.usb_offload_burst_mode.enable=true +vendor.audio.feature.usb_offload_sidetone_volume.enable=false +vendor.audio.feature.vbat.enable=true +vendor.audio.feature.wsa.enable=false +vendor.audio.flac.sw.decoder.24bit=true +vendor.audio.hal.boot.timeout.ms=20000 +vendor.audio.hal.output.suspend.supported=false +vendor.audio.hw.aac.encoder=true +vendor.audio.offload.buffer.size.kb=32 +vendor.audio.offload.gapless.enabled=true +vendor.audio.offload.multiaac.enable=true +vendor.audio.offload.multiple.enabled=false +vendor.audio.offload.passthrough=false +vendor.audio.offload.track.enable=true +vendor.audio.parser.ip.buffer.size=262144 +vendor.audio.safx.pbe.enabled=false +vendor.audio.tunnel.encode=false +vendor.audio.use.sw.alac.decoder=true +vendor.audio.use.sw.ape.decoder=true +vendor.audio.use.sw.mpegh.decoder=true +vendor.audio.volume.headset.gain.depcal=true +vendor.audio_hal.in_period_size=144 +vendor.audio_hal.period_multiplier=3 +vendor.audio_hal.period_size=192 +vendor.voice.path.for.pcm.voip=true + +# Bluetooth +persist.bluetooth.a2dp_offload.cap=sbc-aac-aptx-aptxhd-ldac-lc3 +persist.bluetooth.a2dp_offload.disabled=false +persist.sys.fflag.override.settings_bluetooth_hearing_aid=true +persist.vendor.bt.a2dp_offload_cap=sbc-aptx-aptxtws-aptxhd-aac-ldac +persist.vendor.bt.aac_frm_ctl.enabled=true +persist.vendor.bt.aac_vbr_frm_ctl.enabled=true +persist.vendor.oneplus.bt.asd.chain=0 +persist.vendor.oneplus.bt.asd.firmware=false +persist.vendor.qcom.bluetooth.a2dp_mcast_test.enabled=false +persist.vendor.qcom.bluetooth.a2dp_offload_cap=sbc-aptx-aptxtws-aptxhd-aac-ldac-aptxadaptiver2 +persist.vendor.qcom.bluetooth.aac_frm_ctl.enabled=true +persist.vendor.qcom.bluetooth.aac_vbr_ctl.enabled=true +persist.vendor.qcom.bluetooth.enable.splita2dp=true +persist.vendor.qcom.bluetooth.scram.enabled=false +persist.vendor.qcom.bluetooth.soc=hastings +persist.vendor.qcom.bluetooth.twsp_state.enabled=false +ro.bluetooth.a2dp_offload.supported=true +ro.vendor.bluetooth.wipower=false +vendor.qcom.bluetooth.soc=hastings + +# Camera +persist.vendor.camera.privapp.list=com.oneplus.camera,com.oem.autotest,com.oneplus.factorymode +vendor.arcsoft.sn_isHardCopy=0 +vendor.camera.algo.jpeghwencode=1 +vendor.camera.aux.packagelist=com.oem.autotest,com.oneplus.factorymode,com.oneplus.camera,com.oneplus.healthcheck + +# Crypto +ro.crypto.allow_encrypt_override=true +ro.crypto.dm_default_key.options_format.version=2 +ro.crypto.volume.filenames_mode=aes-256-cts +ro.crypto.volume.metadata.method=dm-default-key + +# Display +ro.vendor.display.sensortype=2 +vendor.display.comp_mask=0 +vendor.display.disable_excl_rect=0 +vendor.display.disable_excl_rect_partial_fb=1 +vendor.display.disable_hw_recovery_dump=1 +vendor.display.disable_offline_rotator=1 +vendor.display.disable_scaler=0 +vendor.display.enable_async_powermode=0 +vendor.display.enable_early_wakeup=1 +vendor.display.enable_optimize_refresh=1 +vendor.display.enable_posted_start_dyn=1 +vendor.display.use_layer_ext=1 +vendor.display.use_smooth_motion=1 + +# DRM +drm.service.enabled=true + +# Fingerprint +persist.vendor.qfp=true + +# FRP +ro.frp.pst=/dev/block/bootdevice/by-name/frp + +# Gatekeeper +vendor.gatekeeper.disable_spu=true + +# GPS +persist.backup.ntpServer=0.pool.ntp.org + +# Graphics +debug.egl.hw=0 +debug.mdpcomp.logs=0 +debug.sf.enable_advanced_sf_phase_offset=1 +debug.sf.enable_gl_backpressure=1 +debug.sf.high_fps_early_gl_phase_offset_ns=-4000000 +debug.sf.high_fps_early_phase_offset_ns=-4000000 +debug.sf.high_fps_late_app_phase_offset_ns=1000000 +debug.sf.high_fps_late_sf_phase_offset_ns=-4000000 +debug.sf.hw=0 +debug.sf.latch_unsignaled=1 +persist.demo.hdmirotationlock=false +persist.sys.sf.color_mode=0 +persist.sys.sf.color_saturation=1.0 +persist.sys.sf.native_mode=0 +ro.gfx.driver.0=com.oneplus.gpudrivers.lahaina.api30 +ro.gfx.driver.1=com.qualcomm.qti.gpudrivers.lahaina.api30 +ro.hardware.egl=adreno +ro.hardware.vulkan=adreno +ro.opengles.version=196610 +vendor.gralloc.disable_ubwc=0 + +# Incremental FS +ro.incremental.enable=true + +# Keystore +ro.hardware.keystore_desede=true + +# Media +debug.stagefright.ccodec=4 +debug.stagefright.omx_default_rank=0 + +# NFC +ro.camera.notify_nfc=1 + +# OTG +persist.sys.oem.otg_support=true + +# PASR +vendor.power.pasr.enabled=false + +# Perf +ro.vendor.extension_library=libqti-perfd-client.so + +# Qualcomm System Daemon +persist.vendor.qcomsysd.enabled=1 + +# Radio +persist.radio.snapshot_enabled=0 +persist.radio.snapshot_timer=0 +persist.rcs.otp_sms_port=0 +persist.rcs.supported=1 +persist.vendor.data.iwlan.enable=true +persist.vendor.radio.5g_mode_pref=1 +persist.vendor.radio.apm_sim_not_pwdn=1 +persist.vendor.radio.arfcn_test_mode=3 +persist.vendor.radio.bar_fake_gcell=1 +persist.vendor.radio.custom_ecc=1 +persist.vendor.radio.data_con_rprt=1 +persist.vendor.radio.data_ltd_sys_ind=1 +persist.vendor.radio.efssync=true +persist.vendor.radio.enableadvancedscan=true +persist.vendor.radio.force_on_dc=true +persist.vendor.radio.ignore_dom_time=10 +persist.vendor.radio.procedure_bytes=SKIP +persist.vendor.radio.process_sups_ind=1 +persist.vendor.radio.rat_on=combine +persist.vendor.radio.sib16_support=1 +persist.vendor.radio.uicc_se_enabled=true +ro.com.android.dataroaming=false + +# Sensors +persist.vendor.sensors.allow_non_default_discovery=true +persist.vendor.sensors.on_change_sample_period=true +persist.vendor.sensors.sync_request=true + +# Shutdown +sys.vendor.shutdown.waittime=500 + +# USB +vendor.usb.diag.func.name=ffs +vendor.usb.use_ffs_mtp=1 + +# WiFi +wifi.aware.interface=wifi-aware0