Add 'qcom/opensource/spu-kernel/' from commit '0edbf1a122b5f3d26a5bd27f53a1a0b8dbedf360'

git-subtree-dir: qcom/opensource/spu-kernel
git-subtree-mainline: 587685c687
git-subtree-split: 0edbf1a122
Change-Id:
repo: https://git.codelinaro.org/clo/la/platform/vendor/qcom/opensource/spu-kernel
tag: LA.VENDOR.14.3.0.r1-17300-lanai.QSSI15.0
This commit is contained in:
David Wronek 2024-10-06 16:45:26 +02:00
commit fe7b3b613f
17 changed files with 6331 additions and 0 deletions

View File

@ -0,0 +1,36 @@
headers_src = [
"include/uapi/linux/*.h",
]
spu_drivers_headers_out = [
"linux/spcom.h", "linux/spss_utils.h",
]
spu_drivers_kernel_headers_verbose = "--verbose "
genrule {
name: "qti_generate_spu_drivers_kernel_headers",
tools: [
"headers_install.sh",
"unifdef"
],
tool_files: [
"spu_drivers_kernel_headers.py",
],
srcs: headers_src,
cmd: "python3 -u $(location spu_drivers_kernel_headers.py) " +
spu_drivers_kernel_headers_verbose +
"--header_arch arm64 " +
"--gen_dir $(genDir) " +
"--spu_drivers_include_uapi $(locations include/uapi/linux/*.h) " +
"--unifdef $(location unifdef) " +
"--headers_install $(location headers_install.sh)",
out: spu_drivers_headers_out,
}
cc_library_headers {
name: "qti_spu_drivers_kernel_headers",
generated_headers: ["qti_generate_spu_drivers_kernel_headers"],
export_generated_headers: ["qti_generate_spu_drivers_kernel_headers"],
vendor: true,
recovery_available: true
}

View File

@ -0,0 +1,41 @@
# Android makefile for spu kernel modules (spcom.ko and spss_utils.ko)
ifeq ($(call is-vendor-board-platform,QCOM),true)
ifeq ($(call is-board-platform-in-list,kalama pineapple niobe),true)
# This makefile is only for DLKM
ifneq ($(findstring vendor,$(LOCAL_PATH)),)
LOCAL_PATH := $(call my-dir)
SPU_BLD_DIR := $(TOP)/vendor/qcom/opensource/spu-kernel
LOCAL_MODULE_DDK_BUILD := true
LOCAL_MODULE_KO_DIRS := drivers/spcom.ko drivers/spss_utils.ko
DLKM_DIR := $(TOP)/device/qcom/common/dlkm
INSTALL_MODULE_HEADERS := 1
# Kbuild options
KBUILD_OPTIONS := SPU_ROOT=$(SPU_BLD_DIR)
KBUILD_OPTIONS += MODNAME=spcom
KBUILD_OPTIONS += MODNAME=spss_utils
########################### spcom ################################
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/**/*) $(wildcard $(LOCAL_PATH)/*)
LOCAL_MODULE := spcom.ko
LOCAL_MODULE_KBUILD_NAME := drivers/spcom.ko
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_PATH := $(KERNEL_MODULES_OUT)
include $(DLKM_DIR)/Build_external_kernelmodule.mk
########################### spss_utils ################################
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/**/*) $(wildcard $(LOCAL_PATH)/*)
LOCAL_MODULE := spss_utils.ko
LOCAL_MODULE_KBUILD_NAME := drivers/spss_utils.ko
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_PATH := $(KERNEL_MODULES_OUT)
include $(DLKM_DIR)/Build_external_kernelmodule.mk
###########################################################
LOCAL_SHARED_LIBRARIES := libdmabufheap
endif
endif
endif # End of check for board platform

View File

@ -0,0 +1,57 @@
load("//build/kernel/kleaf:kernel.bzl", "ddk_headers")
package(
default_visibility = [
"//visibility:public",
],
)
ddk_headers(
name = "spu_kernel_configs",
hdrs = glob([
"config/*.h"]),
includes = ["config"]
)
ddk_headers(
name = "spu_uapi_headers",
hdrs = glob(["include/uapi/linux/*.h"]),
includes = [
"include/uapi/linux",
"include/uapi",
],
)
# Generated list with: find drivers -maxdepth 1 -mindepth 1 -type d -printf '"%p/**/*.h",\n'
driver_header_globs = [
"include/uapi/linux/*.h",
]
# Generated list with: find drivers -type f -name '*.h' -printf '"%h",\n' | sort -u
driver_includes = [
"include",
"include/uapi/linux",
]
ddk_headers(
name = "spu_src_headers",
hdrs = glob(driver_header_globs),
includes = driver_includes + [
".",
],
)
ddk_headers(
name = "spu_headers",
hdrs = [
":spu_src_headers",
":spu_uapi_headers",
":spu_kernel_configs",
],
)
load(":target.bzl", "define_modules")
targets = ["pineapple", "niobe"]
define_modules(targets)

View File

@ -0,0 +1,16 @@
# SPDX-License-Identifier: GPL-2.0-only
ifeq ($(CONFIG_QCOM_SPSS), m)
include $(SPU_ROOT)/config/gki_spu.conf
LINUXINCLUDE += -include $(SPU_ROOT)/config/gki_spuconf.h
endif
LINUXINCLUDE += -I$(srctree)/../../vendor/qcom/opensource/spu-kernel/include/uapi
obj-$(CONFIG_MSM_SPCOM) += drivers/spcom.o
obj-$(CONFIG_MSM_SPSS_UTILS) += drivers/spss_utils.o
BOARD_VENDOR_KERNEL_MODULES += $(KERNEL_MODULES_OUT)/spcom.ko
BOARD_VENDOR_KERNEL_MODULES += $(KERNEL_MODULES_OUT)/spss_utils.ko

View File

@ -0,0 +1,16 @@
# SPDX-License-Identifier: GPL-2.0-only
KBUILD_OPTIONS+= SPU_ROOT=$(KERNEL_SRC)/$(M)
all:
$(MAKE) -C $(KERNEL_SRC) M=$(M) modules $(KBUILD_OPTIONS)
modules_install:
$(MAKE) INSTALL_MOD_STRIP=1 -C $(KERNEL_SRC) M=$(M) modules_install
%:
$(MAKE) -C $(KERNEL_SRC) M=$(M) $@ $(KBUILD_OPTIONS)
clean:
rm -f *.o *.ko *.mod.c *.mod.o *~ .*.cmd Module.symvers
rm -rf .tmp_versions

View File

@ -0,0 +1,5 @@
export CONFIG_MSM_SPCOM=m
export CONFIG_MSM_SPSS_UTILS=m

View File

@ -0,0 +1,10 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (c) 2021-2024 Qualcomm Innovation Center, Inc. All rights reserved.
* Copyright (c) 2021, The Linux Foundation. All rights reserved.
*/
#define CONFIG_MSM_SPCOM 1
#define CONFIG_MSM_SPSS_UTILS 1

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,341 @@
/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
/*
* Copyright (c) 2015-2021, The Linux Foundation. All rights reserved.
* Copyright (c) 2021 Qualcomm Innovation Center, Inc. All rights reserved.
*/
#ifndef _UAPI_SPCOM_H_
#define _UAPI_SPCOM_H_
#include <linux/types.h> /* __u32, bool */
#ifndef BIT
#define BIT(x) (1 << x)
#endif
#ifndef PAGE_SIZE
#define PAGE_SIZE 4096
#endif
/**
* @brief - Secure Processor Communication interface to user space spcomlib.
*
* Sending data and control commands by write() file operation.
* Receiving data by read() file operation.
* Getting the next request size by read() file operation,
* with special size SPCOM_GET_NEXT_REQUEST_SIZE.
*/
/*
* Maximum number of channel between Secure Processor and HLOS.
* including predefined channels, like "sp_kernel".
*/
#define SPCOM_MAX_CHANNELS 0x20
/* Maximum size (including null) for channel names */
#define SPCOM_CHANNEL_NAME_SIZE 32
#define SPCOM_CHANNEL_NAME_SIZE_1 32
/*
* file read(fd, buf, size) with this size,
* hints the kernel that user space wants to read the next-req-size.
* This size is bigger than both SPCOM_MAX_REQUEST_SIZE and
* SPCOM_MAX_RESPONSE_SIZE , so it is not a valid data size.
*/
#define SPCOM_GET_NEXT_REQUEST_SIZE (PAGE_SIZE-1)
/* Command Id between spcomlib and spcom driver, on write() */
enum spcom_cmd_id {
SPCOM_CMD_LOAD_APP = 0x4C4F4144, /* "LOAD" = 0x4C4F4144 */
SPCOM_CMD_RESET_SP = 0x52455354, /* "REST" = 0x52455354 */
SPCOM_CMD_SEND = 0x53454E44, /* "SEND" = 0x53454E44 */
SPCOM_CMD_SEND_MODIFIED = 0x534E444D, /* "SNDM" = 0x534E444D */
SPCOM_CMD_LOCK_ION_BUF = 0x4C4F434B, /* "LOCK" = 0x4C4F434B */
SPCOM_CMD_UNLOCK_ION_BUF = 0x554C434B, /* "ULCK" = 0x4C4F434B */
SPCOM_CMD_FSSR = 0x46535352, /* "FSSR" = 0x46535352 */
SPCOM_CMD_CREATE_CHANNEL = 0x43524554, /* "CRET" = 0x43524554 */
#define SPCOM_CMD_ENABLE_SSR \
SPCOM_CMD_ENABLE_SSR
SPCOM_CMD_ENABLE_SSR = 0x45535352, /* "ESSR" =0x45535352*/
#define SPCOM_CMD_RESTART_SP \
SPCOM_CMD_RESTART_SP
SPCOM_CMD_RESTART_SP = 0x52535452, /* "RSTR" = 0x52535452 */
};
/*
* @note: Event types that are always implicitly polled:
* POLLERR=0x08 | POLLHUP=0x10 | POLLNVAL=0x20
* so bits 3,4,5 can't be used
*/
enum spcom_poll_events {
SPCOM_POLL_LINK_STATE = BIT(1),
SPCOM_POLL_CH_CONNECT = BIT(2),
SPCOM_POLL_READY_FLAG = BIT(14), /* output */
SPCOM_POLL_WAIT_FLAG = BIT(15), /* if set , wait for the event */
};
/* Common Command structure between User Space and spcom driver, on write() */
struct spcom_user_command {
enum spcom_cmd_id cmd_id;
__u32 arg;
} __packed;
/* Command structure between User Space and spcom driver, on write() */
struct spcom_send_command {
enum spcom_cmd_id cmd_id;
__u32 timeout_msec;
__u32 buf_size;
char buf[0]; /* Variable buffer size - must be last field */
} __packed;
/* Command structure between userspace spcomlib and spcom driver, on write() */
struct spcom_user_create_channel_command {
enum spcom_cmd_id cmd_id;
char ch_name[SPCOM_CHANNEL_NAME_SIZE];
#define SPCOM_IS_SHARABLE_SUPPORTED
_Bool is_sharable;
} __packed;
/* Command structure between userspace spcomlib and spcom driver, on write() */
#define SPCOM_USER_RESTART_SP_CMD
struct spcom_user_restart_sp_command {
enum spcom_cmd_id cmd_id;
__u32 arg;
#define SPCOM_IS_UPDATED_SUPPORETED
__u32 is_updated;
} __packed;
/* maximum ION buf for send-modfied-command */
#define SPCOM_MAX_ION_BUF 4
struct spcom_ion_info {
__s32 fd; /* ION buffer File Descriptor, set -1 for invalid fd */
__u32 buf_offset; /* virtual address offset in request/response */
};
/* Pass this FD to unlock all ION buffer for the specific channel */
#define SPCOM_ION_FD_UNLOCK_ALL 0xFFFF
struct spcom_ion_handle {
__s32 fd; /* File Descriptor associated with the buffer */
};
struct spcom_rmb_error_info {
__u32 rmb_error;
__u32 padding;
} __packed;
/* Command structure between User Space and spcom driver, on write() */
struct spcom_user_send_modified_command {
enum spcom_cmd_id cmd_id;
struct spcom_ion_info ion_info[SPCOM_MAX_ION_BUF];
__u32 timeout_msec;
__u32 buf_size;
char buf[0]; /* Variable buffer size - must be last field */
} __packed;
enum {
SPCOM_IONFD_CMD,
SPCOM_POLL_CMD,
SPCOM_GET_RMB_CMD,
};
enum spcom_poll_cmd_id {
SPCOM_LINK_STATE_REQ,
SPCOM_CH_CONN_STATE_REQ,
};
struct spcom_poll_param {
/* input parameters */
_Bool wait;
enum spcom_poll_cmd_id cmd_id;
/* output parameter */
int retval;
} __packed;
#define SPCOM_IOCTL_MAGIC 'S'
#define SPCOM_GET_IONFD _IOR(SPCOM_IOCTL_MAGIC, SPCOM_IONFD_CMD, \
struct spcom_ion_handle)
#define SPCOM_SET_IONFD _IOW(SPCOM_IOCTL_MAGIC, SPCOM_IONFD_CMD, \
struct spcom_ion_handle)
#define SPCOM_POLL_STATE _IOWR(SPCOM_IOCTL_MAGIC, SPCOM_POLL_CMD, \
struct spcom_poll_param)
#define SPCOM_GET_RMB_ERROR _IOR(SPCOM_IOCTL_MAGIC, SPCOM_GET_RMB_CMD, \
struct spcom_rmb_error_info)
/* Maximum number of DMA buffer for sending modified message */
#define SPCOM_MAX_DMA_BUF SPCOM_MAX_ION_BUF
/* Pass this FD to unlock all DMA buffer for the specific channel */
#define SPCOM_DMABUF_FD_UNLOCK_ALL 0xFFFF
/* SPCOM events enum */
enum spcom_event_id {
SPCOM_EVENT_LINK_STATE = 100
};
/* SPCOM IOCTL commands */
enum spcom_ioctl_enum {
SPCOM_IOCTL_STATE_POLL_CMD = 1000,
SPCOM_IOCTL_SHARED_CH_CREATE_CMD,
SPCOM_IOCTL_CH_REGISTER_CMD,
SPCOM_IOCTL_CH_UNREGISTER_CMD,
SPCOM_IOCTL_CH_IS_CONNECTED_CMD,
SPCOM_IOCTL_SEND_MSG_CMD,
SPCOM_IOCTL_SEND_MOD_MSG_CMD,
SPCOM_IOCTL_GET_NEXT_REQ_SZ_CMD,
SPCOM_IOCTL_GET_MSG_CMD,
SPCOM_IOCTL_DMABUF_LOCK_CMD,
SPCOM_IOCTL_DMABUF_UNLOCK_CMD,
SPCOM_IOCTL_RESTART_SPU_CMD,
SPCOM_IOCTL_ENABLE_SSR_CMD
};
/* SPCOM dma buffer info struct */
struct spcom_dma_buf_info {
__s32 fd; /* DMA buffer File Descriptor */
__u32 offset; /* Address offset in request or response buffer*/
} __packed;
/* SPCOM dma buffers info table */
struct spcom_dma_buf_info_table {
struct spcom_dma_buf_info info[SPCOM_MAX_DMA_BUF];
} __packed;
/* SPCOM poll on event cmd struct */
struct spcom_ioctl_poll_event {
__u32 event_id; /* spcom_ioctl_enum */
__u32 wait; /* wait for event, zero for no wait, positive number otherwise */
__s32 retval; /* updated by spcom driver */
__u32 padding; /* 64-bit alignment, unused */
} __packed;
/* SPCOM register/unregister channel cmd struct */
struct spcom_ioctl_ch {
char ch_name[SPCOM_CHANNEL_NAME_SIZE]; /* 4 * 64-bit */
} __packed;
/* SPCOM message cmd struct */
struct spcom_ioctl_message {
char ch_name[SPCOM_CHANNEL_NAME_SIZE]; /* 4 * 64-bit */
__u32 timeout_msec;
__u32 buffer_size;
char buffer[0]; /* Variable buffer size - must be last field */
} __packed;
/* SPCOM modified message cmd struct */
struct spcom_ioctl_modified_message {
char ch_name[SPCOM_CHANNEL_NAME_SIZE]; /* 4 * 64-bit */
__u32 timeout_msec;
__u32 buffer_size;
struct spcom_dma_buf_info info[SPCOM_MAX_DMA_BUF];
char buffer[0]; /* Variable buffer size - must be last field */
} __packed;
/* SPCOM ioctl get next request size command struct */
struct spcom_ioctl_next_request_size {
char ch_name[SPCOM_CHANNEL_NAME_SIZE]; /* 4 * 64-bit */
__u32 size;
__u32 padding; /* 64-bit alignment, unused */
} __packed;
/* SPCOM ioctl buffer lock or unlock command struct */
struct spcom_ioctl_dmabuf_lock {
char ch_name[SPCOM_CHANNEL_NAME_SIZE]; /* 4 * 64-bit */
__s32 fd;
__u32 padding; /* 64-bit alignment, unused */
} __packed;
/* SPCOM ioctl command to handle event poll */
#define SPCOM_IOCTL_STATE_POLL _IOWR( \
SPCOM_IOCTL_MAGIC, \
SPCOM_IOCTL_STATE_POLL_CMD, \
struct spcom_ioctl_poll_event \
)
/* SPCOM ioctl command to handle SPCOM shared channel create */
#define SPCOM_IOCTL_SHARED_CH_CREATE _IOW( \
SPCOM_IOCTL_MAGIC, \
SPCOM_IOCTL_SHARED_CH_CREATE_CMD, \
struct spcom_ioctl_ch \
)
/* SPCOM ioctl command to handle SPCOM channel register */
#define SPCOM_IOCTL_CH_REGISTER _IOW( \
SPCOM_IOCTL_MAGIC, \
SPCOM_IOCTL_CH_REGISTER_CMD, \
struct spcom_ioctl_ch \
)
/* IOCTL to handle SPCOM channel unregister */
#define SPCOM_IOCTL_CH_UNREGISTER _IOW( \
SPCOM_IOCTL_MAGIC, \
SPCOM_IOCTL_CH_UNREGISTER_CMD, \
struct spcom_ioctl_ch \
)
/* IOCTL to check SPCOM channel connectivity with remote edge */
#define SPCOM_IOCTL_CH_IS_CONNECTED _IOW( \
SPCOM_IOCTL_MAGIC, \
SPCOM_IOCTL_CH_IS_CONNECTED_CMD, \
struct spcom_ioctl_ch \
)
/* IOCTL to handle SPCOM send message */
#define SPCOM_IOCTL_SEND_MSG _IOW( \
SPCOM_IOCTL_MAGIC, \
SPCOM_IOCTL_SEND_MSG_CMD, \
struct spcom_ioctl_message \
)
/* IOCTL to handle SPCOM send modified message */
#define SPCOM_IOCTL_SEND_MOD_MSG _IOW( \
SPCOM_IOCTL_MAGIC, \
SPCOM_IOCTL_SEND_MOD_MSG_CMD, \
struct spcom_ioctl_modified_message \
)
/* IOCTL to handle SPCOM get next request message size */
#define SPCOM_IOCTL_GET_NEXT_REQ_SZ _IOWR( \
SPCOM_IOCTL_MAGIC, \
SPCOM_IOCTL_GET_NEXT_REQ_SZ_CMD, \
struct spcom_ioctl_next_request_size \
)
/* IOCTL to handle SPCOM get request */
#define SPCOM_IOCTL_GET_MSG _IOWR( \
SPCOM_IOCTL_MAGIC, \
SPCOM_IOCTL_GET_MSG_CMD, \
struct spcom_ioctl_message \
)
/* IOCTL to handle DMA buffer lock/unlock */
#define SPCOM_IOCTL_DMABUF_LOCK _IOW( \
SPCOM_IOCTL_MAGIC, \
SPCOM_IOCTL_DMABUF_LOCK_CMD, \
struct spcom_ioctl_dmabuf_lock \
)
/* IOCTL to handle DMA buffer unlock */
#define SPCOM_IOCTL_DMABUF_UNLOCK _IOW( \
SPCOM_IOCTL_MAGIC, \
SPCOM_IOCTL_DMABUF_UNLOCK_CMD, \
struct spcom_ioctl_dmabuf_lock \
)
/* IOCTL to handle SPU restart */
#define SPCOM_IOCTL_RESTART_SPU _IO( \
SPCOM_IOCTL_MAGIC, \
SPCOM_IOCTL_RESTART_SPU_CMD \
)
/* IOCTL to enable SSR */
#define SPCOM_IOCTL_ENABLE_SSR _IO( \
SPCOM_IOCTL_MAGIC, \
SPCOM_IOCTL_ENABLE_SSR_CMD \
)
#endif /* _UAPI_SPCOM_H_ */

View File

@ -0,0 +1,116 @@
/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
/*
* Copyright (c) 2019-2020, The Linux Foundation. All rights reserved.
* Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.
*/
#ifndef _UAPI_SPSS_UTILS_H_
#define _UAPI_SPSS_UTILS_H_
#include <linux/types.h> /* __u32, _Bool */
#include <linux/ioctl.h> /* ioctl() */
/**
* @brief - Secure Processor Utilities interface to user space
*
* The kernel spss_utils driver interface to user space via IOCTL
* and SYSFS (device attributes).
*/
#define SPSS_IOC_MAGIC 'S'
/* ---------- set fw cmac --------------------------------- */
#define OLD_NUM_SPU_UEFI_APPS 3 /* Obsolete */
#define CMAC_SIZE_IN_WORDS 4
#define CMAC_SIZE_IN_WORDS_1 4
/* Obsolete struct, keep for backward compatible */
struct spss_ioc_set_fw_cmac {
__u32 cmac[CMAC_SIZE_IN_WORDS];
__u32 apps_cmac[OLD_NUM_SPU_UEFI_APPS][CMAC_SIZE_IN_WORDS];
} __packed;
#define SPSS_IOC_SET_FW_CMAC \
_IOWR(SPSS_IOC_MAGIC, 1, struct spss_ioc_set_fw_cmac)
/* ---------- wait for event ------------------------------ */
enum spss_event_id {
/* signaled from user */
SPSS_EVENT_ID_PIL_CALLED = 0,
SPSS_EVENT_ID_NVM_READY = 1,
SPSS_EVENT_ID_SPU_READY = 2,
SPSS_NUM_USER_EVENTS,
/* signaled from kernel */
SPSS_EVENT_ID_SPU_POWER_DOWN = 6,
SPSS_EVENT_ID_SPU_POWER_UP = 7,
SPSS_NUM_EVENTS,
};
enum spss_event_status {
EVENT_STATUS_SIGNALED = 0xAAAA,
EVENT_STATUS_NOT_SIGNALED = 0xFFFF,
EVENT_STATUS_TIMEOUT = 0xEEE1,
EVENT_STATUS_ABORTED = 0xEEE2,
};
struct spss_ioc_wait_for_event {
__u32 event_id; /* input */
__u32 timeout_sec; /* input */
__u32 status; /* output */
} __packed;
#define SPSS_IOC_WAIT_FOR_EVENT \
_IOWR(SPSS_IOC_MAGIC, 2, struct spss_ioc_wait_for_event)
/* ---------- signal event ------------------------------ */
struct spss_ioc_signal_event {
__u32 event_id; /* input */
__u32 status; /* output */
} __packed;
#define SPSS_IOC_SIGNAL_EVENT \
_IOWR(SPSS_IOC_MAGIC, 3, struct spss_ioc_signal_event)
/* ---------- is event signaled ------------------------------ */
struct spss_ioc_is_signaled {
__u32 event_id; /* input */
__u32 status; /* output */
} __attribute__((packed));
#define SPSS_IOC_IS_EVENT_SIGNALED \
_IOWR(SPSS_IOC_MAGIC, 4, struct spss_ioc_is_signaled)
/* ---------- set ssr state ------------------------------ */
#define SPSS_IOC_SET_SSR_STATE \
_IOWR(SPSS_IOC_MAGIC, 5, __u32)
/* ---------- set fw and apps cmac --------------------------------- */
/* NVM, Asym , Crypt , Keym */
#define NUM_SPU_UEFI_APPS 4
/* Max number of 3rd party UEFI applications */
#define MAX_3RD_PARTY_UEFI_APPS 3
/* Max number of total UEFI applications */
#define MAX_SPU_UEFI_APPS (NUM_SPU_UEFI_APPS + MAX_3RD_PARTY_UEFI_APPS)
/** use variable-size-array for future growth */
struct spss_ioc_set_fw_and_apps_cmac {
__u64 cmac_buf_ptr;
/*
* expected cmac_buf_size is:
* (1+MAX_SPU_UEFI_APPS)*CMAC_SIZE_IN_WORDS*sizeof(uint32_t)
*/
__u32 cmac_buf_size;
__u32 num_of_cmacs;
} __attribute__((packed));
#define SPSS_IOC_SET_FW_AND_APPS_CMAC \
_IOWR(SPSS_IOC_MAGIC, 6, struct spss_ioc_set_fw_and_apps_cmac)
#endif /* _UAPI_SPSS_UTILS_H_ */

View File

@ -0,0 +1,15 @@
SPU_DLKM_ENABLE := true
ifeq ($(TARGET_KERNEL_DLKM_DISABLE), true)
ifeq ($(TARGET_KERNEL_DLKM_SPU_OVERRIDE), false)
SPU_DLKM_ENABLE := false
endif
endif
ifeq ($(SPU_DLKM_ENABLE), true)
ifneq ($(TARGET_BOARD_AUTO),true)
ifeq ($(call is-board-platform-in-list, kalama pineapple niobe),true)
BOARD_VENDOR_KERNEL_MODULES += $(KERNEL_MODULES_OUT)/spcom.ko \
$(KERNEL_MODULES_OUT)/spss_utils.ko
endif
endif
endif

View File

@ -0,0 +1,11 @@
SPU_DLKM_ENABLE := true
ifeq ($(TARGET_KERNEL_DLKM_DISABLE), true)
ifeq ($(TARGET_KERNEL_DLKM_SPU_OVERRIDE), false)
SPU_DLKM_ENABLE := false
endif
endif
ifeq ($(SPU_DLKM_ENABLE), true)
PRODUCT_PACKAGES += $(KERNEL_MODULES_OUT)/spcom.ko \
$(KERNEL_MODULES_OUT)/spss_utils.ko
endif

View File

@ -0,0 +1,95 @@
# Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
# Copyright (c) 2020-2021, The Linux Foundation. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 as published by
# the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
import argparse
import filecmp
import os
import re
import subprocess
import sys
def run_headers_install(verbose, gen_dir, headers_install, unifdef, prefix, h):
if not h.startswith(prefix):
print('error: expected prefix [%s] on header [%s]' % (prefix, h))
return False
out_h = os.path.join(gen_dir, h[len(prefix):])
(out_h_dirname, out_h_basename) = os.path.split(out_h)
env = os.environ.copy()
env["LOC_UNIFDEF"] = unifdef
cmd = ["sh", headers_install, h, out_h]
if True:
print('run_headers_install: cmd is %s' % cmd)
result = subprocess.call(cmd, env=env)
if result != 0:
print('error: run_headers_install: cmd %s failed %d' % (cmd, result))
return False
return True
def gen_spu_drivers_headers(verbose, gen_dir, headers_install, unifdef, spu_drivers_include_uapi):
error_count = 0
for h in spu_drivers_include_uapi:
spu_drivers_uapi_include_prefix = os.path.join(h.split('include/uapi')[0],
'include', 'uapi') + os.sep
if not run_headers_install(
verbose, gen_dir, headers_install, unifdef,
spu_drivers_uapi_include_prefix, h): error_count += 1
return error_count
def main():
"""Parse command line arguments and perform top level control."""
parser = argparse.ArgumentParser(
description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter)
# Arguments that apply to every invocation of this script.
parser.add_argument(
'--verbose', action='store_true',
help='Print output that describes the workings of this script.')
parser.add_argument(
'--header_arch', required=True,
help='The arch for which to generate headers.')
parser.add_argument(
'--gen_dir', required=True,
help='Where to place the generated files.')
parser.add_argument(
'--spu_drivers_include_uapi', required=True, nargs='*',
help='The list of include/uapi header files.')
parser.add_argument(
'--headers_install', required=True,
help='The headers_install tool to process input headers.')
parser.add_argument(
'--unifdef',
required=True,
help='The unifdef tool used by headers_install.')
args = parser.parse_args()
if args.verbose:
print('header_arch [%s]' % args.header_arch)
print('gen_dir [%s]' % args.gen_dir)
print('spu_drivers_include_uapi [%s]' % args.spu_drivers_include_uapi)
print('headers_install [%s]' % args.headers_install)
print('unifdef [%s]' % args.unifdef)
return gen_spu_drivers_headers(args.verbose, args.gen_dir,
args.headers_install, args.unifdef, args.spu_drivers_include_uapi)
if __name__ == '__main__':
sys.exit(main())

View File

@ -0,0 +1,100 @@
load("//build/kernel/kleaf:kernel.bzl", "kernel_module",
"kernel_modules_install",
"ddk_module",
"ddk_submodule")
load("//build/bazel_common_rules/dist:dist.bzl", "copy_to_dist_dir")
def _register_module_to_map(module_map, name, path, config_option, srcs, config_srcs, deps):
processed_config_srcs = {}
for config_src_name in config_srcs:
config_src = config_srcs[config_src_name]
if type(config_src) == "list":
processed_config_srcs[config_src_name] = { True: config_src }
else:
processed_config_srcs[config_src_name] = config_src
module = struct(
name = name,
path = path if path else ".",
srcs = srcs,
config_srcs = processed_config_srcs,
config_option = config_option,
deps = deps,
)
module_map[name] = module
def _get_kernel_build_module_srcs(kernel_build, module, formatter):
src_formatter = lambda srcs: native.glob(formatter(["{}/{}".format(module.path, src) for src in srcs]))
srcs = [] + src_formatter(module.srcs)
return srcs
def _get_kernel_build_options(modules, config_options):
all_options = {option: True for option in config_options}
all_options = all_options | {module.config_option: True for module in modules if module.config_option}
return all_options
def _get_kernel_build_module_deps(module, options, formatter):
deps = [formatter(dep) for dep in deps]
return deps
def spu_driver_module_entry(hdrs = []):
module_map = {}
def register(name, path = None, config_option = None, srcs = [], config_srcs = {}, deps = []):
_register_module_to_map(module_map, name, path, config_option, srcs, config_srcs, deps)
return struct(
register = register,
get = module_map.get,
hdrs = hdrs,
module_map = module_map
)
def define_target_variant_modules(target, variant, registry, modules, config_options = []):
kernel_build = "{}_{}".format(target, variant)
kernel_build_label = "//msm-kernel:{}".format(kernel_build)
modules = [registry.get(module_name) for module_name in modules]
options = _get_kernel_build_options(modules, config_options)
formatter = lambda strs : [s.replace("%b", kernel_build).replace("%t", target) for s in strs]
headers = ["//msm-kernel:all_headers"] + registry.hdrs
all_module_rules = []
for module in modules:
rule_name = "{}_{}".format(kernel_build, module.name)
srcs = _get_kernel_build_module_srcs(kernel_build, module, formatter)
ddk_submodule(
name = rule_name,
srcs = srcs,
out = "{}.ko".format(module.name),
deps = headers + formatter(module.deps),
local_defines = options.keys()
)
all_module_rules.append(rule_name)
ddk_module(
name = "{}_spu-drivers".format(kernel_build),
kernel_build = kernel_build_label,
deps = all_module_rules
)
copy_to_dist_dir(
name = "{}_spu-drivers_dist".format(kernel_build),
data = [":{}_spu-drivers".format(kernel_build)],
dist_dir = "../vendor/qcom/opensource/spu-drivers/out", ## TODO
flat = True,
wipe_dist_dir = False,
allow_duplicate_filenames = False,
mode_overrides = {"**/*": "644"},
log = "info",
)
def define_consolidate_gki_modules(target, registry, modules, config_options = []):
define_target_variant_modules(target, "consolidate", registry, modules, config_options)
define_target_variant_modules(target, "gki", registry, modules, config_options)

View File

@ -0,0 +1,23 @@
load(":spu_module_build.bzl", "spu_driver_module_entry")
spu_driver_modules = spu_driver_module_entry([":spu_headers"])
module_entry = spu_driver_modules.register
#--------------- SPU-DRIVERS MODULES ------------------
module_entry(
name = "spcom",
config_option = "CONFIG_MSM_SPCOM",
srcs = ["spcom.c"],
path = "drivers"
)
module_entry(
name = "spss_utils",
config_option = "CONFIG_MSM_SPSS_UTILS",
srcs = ["spss_utils.c"],
path = "drivers"
)

View File

@ -0,0 +1,14 @@
load(":spu_modules.bzl", "spu_driver_modules")
load(":spu_module_build.bzl", "define_consolidate_gki_modules")
def define_modules(targets):
# go over all targets
for t in targets:
define_consolidate_gki_modules(
target = t,
registry = spu_driver_modules,
modules = [
"spcom",
"spss_utils",
],
)