Browse Source

adsprpc: msm: Add rules for compilation

Adding rules for compiling frpc_adsprpc ko and cdsploader
ko.

Change-Id: Ie0d13018fea971ffa20f0183c17a299ca47f29c7
Signed-off-by: Anirudh Raghavendra <[email protected]>
Anirudh Raghavendra 2 years ago
parent
commit
c64cff5b57
10 changed files with 266 additions and 1 deletions
  1. 41 0
      Android.mk
  2. 39 0
      Kbuild
  3. 14 0
      Makefile
  4. 6 0
      config/pineappledsp.conf
  5. 6 0
      config/pineappledspconf.h
  6. 1 1
      dsp/adsprpc.c
  7. 5 0
      dsp_kernel_board.mk
  8. 3 0
      dsp_kernel_product.mk
  9. 149 0
      include/linux/fastrpc.h
  10. 2 0
      product.mk

+ 41 - 0
Android.mk

@@ -0,0 +1,41 @@
+DLKM_DIR   := device/qcom/common/dlkm
+
+LOCAL_PATH := $(call my-dir)
+
+DSP_BLD_DIR := $(abspath .)/vendor/qcom/opensource/dsp-kernel
+
+include $(CLEAR_VARS)
+$(info DLKM_DIR = $(DLKM_DIR))
+LOCAL_SRC_FILES   := $(wildcard $(LOCAL_PATH)/**/*) $(wildcard $(LOCAL_PATH)/*)
+LOCAL_MODULE      := dsp-module-symvers
+LOCAL_MODULE_STEM         := Module.symvers
+LOCAL_MODULE_KBUILD_NAME  := Module.symvers
+LOCAL_MODULE_PATH         := $(KERNEL_MODULES_OUT)
+include $(DLKM_DIR)/Build_external_kernelmodule.mk
+
+include $(CLEAR_VARS)
+$(info DLKM_DIR = $(DLKM_DIR))
+LOCAL_SRC_FILES   := $(wildcard $(LOCAL_PATH)/**/*) $(wildcard $(LOCAL_PATH)/*)
+LOCAL_MODULE      := frpc-adsprpc.ko
+LOCAL_EXPORT_KO_INCLUDE_DIRS    := $(LOCAL_PATH)/include/linux
+LOCAL_MODULE_KBUILD_NAME := frpc-adsprpc.ko
+LOCAL_MODULE_PATH := $(KERNEL_MODULES_OUT)
+KBUILD_OPTIONS += DSP_ROOT=$(DSP_BLD_DIR)
+KBUILD_OPTIONS += BOARD_PLATFORM=$(TARGET_BOARD_PLATFORM)
+include $(DLKM_DIR)/Build_external_kernelmodule.mk
+
+#include $(CLEAR_VARS)
+#$(info DLKM_DIR = $(DLKM_DIR))
+#LOCAL_SRC_FILES   := $(wildcard $(LOCAL_PATH)/**/*) $(wildcard $(LOCAL_PATH)/*)
+#LOCAL_MODULE      := cdsp-loader.ko
+#LOCAL_MODULE_KBUILD_NAME := cdsp-loader.ko
+#LOCAL_MODULE_PATH := $(KERNEL_MODULES_OUT)
+#KBUILD_OPTIONS += DSP_ROOT=$(DSP_BLD_DIR)
+#KBUILD_OPTIONS += BOARD_PLATFORM=$(TARGET_BOARD_PLATFORM)
+#include $(DLKM_DIR)/Build_external_kernelmodule.mk
+
+# print out variables
+$(info KBUILD_OPTIONS = $(KBUILD_OPTIONS))
+$(info intermediates dsp symvers path = $(call intermediates-dir-for,DLKM,dsp-module-symvers))
+$(info DLKM_DIR = $(DLKM_DIR))
+

+ 39 - 0
Kbuild

@@ -0,0 +1,39 @@
+# ported from Android.mk
+$(info within KBUILD file KBUILD_EXTRA_SYMBOLS = $(KBUILD_EXTRA_SYMBOLS))
+
+ifeq ($(CONFIG_ARCH_WAIPIO), y)
+$(info within KBUILD file CONFIG_ARCH_WAIPIO = $(CONFIG_ARCH_WAIPIO))
+KBUILD_CPPFLAGS += -DCONFIG_DSP_WAIPIO=1
+ccflags-y += -DCONFIG_DSP_WAIPIO=1
+endif
+
+ifeq ($(CONFIG_ARCH_KALAMA), y)
+$(info within KBUILD file CONFIG_ARCH_KALAMA = $(CONFIG_ARCH_KALAMA))
+KBUILD_CPPFLAGS += -DCONFIG_DSP_KALAMA=1
+ccflags-y += -DCONFIG_DSP_KALAMA=1
+endif
+
+ifeq ($(CONFIG_ARCH_PINEAPPLE), y)
+$(info within KBUILD file CONFIG_ARCH_PINEAPPLE = $(CONFIG_ARCH_PINEAPPLE))
+KBUILD_CPPFLAGS += -DCONFIG_DSP_PINEAPPLE=1
+ccflags-y += -DCONFIG_DSP_PINEAPPLE=1
+endif
+
+LINUXINCLUDE += -I$(DSP_ROOT)/include/linux
+
+frpc-adsprpc-y := dsp/adsprpc.o	\
+                  dsp/adsprpc_rpmsg.o \
+
+frpc-adsprpc-$(CONFIG_COMPAT) += dsp/adsprpc_compat.o \
+
+frpc_trusted-adsprpc-y := dsp/adsprpc.o	\
+                          dsp/adsprpc_compat.o \
+                          dsp/adsprpc_socket.o \
+
+#cdsp-loader-y := dsp/cdsp-loader.o
+
+#obj-m := frpc-adsprpc.o cdsp-loader.o
+obj-m := frpc-adsprpc.o
+
+BOARD_VENDOR_KERNEL_MODULES += $(KERNEL_MODULES_OUT)/frpc-adsprpc.ko
+#BOARD_VENDOR_KERNEL_MODULES += $(KERNEL_MODULES_OUT)/cdsp-loader.ko

+ 14 - 0
Makefile

@@ -0,0 +1,14 @@
+KBUILD_OPTIONS += DSP_ROOT=$(KERNEL_SRC)/$(M) V=1
+
+all:
+	$(MAKE) -C $(KERNEL_SRC) M=$(M) modules $(KBUILD_OPTIONS)
+
+modules_install:
+	$(MAKE) M=$(M) -C $(KERNEL_SRC) 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

+ 6 - 0
config/pineappledsp.conf

@@ -0,0 +1,6 @@
+ifeq ($(CONFIG_QGKI),y)
+export CONFIG_MSM_ADSPRPC =y
+else
+export CONFIG_MSM_ADSPRPC =m
+endif
+#export CONFIG_MSM_DSP=y

+ 6 - 0
config/pineappledspconf.h

@@ -0,0 +1,6 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (c) 2020, The Linux Foundation. All rights reserved.
+ */
+
+#define CONFIG_MSM_ADSPRPC 1

+ 1 - 1
dsp/adsprpc.c

@@ -41,7 +41,7 @@
 #include <linux/msm_dma_iommu_mapping.h>
 #include "adsprpc_compat.h"
 #include "adsprpc_shared.h"
-#include <linux/fastrpc.h>
+#include "fastrpc.h"
 #include <soc/qcom/qcom_ramdump.h>
 #include <soc/qcom/minidump.h>
 #include <linux/delay.h>

+ 5 - 0
dsp_kernel_board.mk

@@ -0,0 +1,5 @@
+ifeq ($(call is-board-platform-in-list,$(TARGET_BOARD_PLATFORM)),true)
+BOARD_VENDOR_KERNEL_MODULES += $(KERNEL_MODULES_OUT)/frpc-adsprpc.ko
+#BOARD_VENDOR_KERNEL_MODULES += $(KERNEL_MODULES_OUT)/frpc-trusted-adsprpc.ko
+#BOARD_VENDOR_KERNEL_MODULES += $(KERNEL_MODULES_OUT)/cdsp-loader.ko
+endif

+ 3 - 0
dsp_kernel_product.mk

@@ -0,0 +1,3 @@
+PRODUCT_PACKAGES += frpc-adsprpc.ko
+#PRODUCT_PACKAGES += frpc_trusted-adsprpc.ko
+#PRODUCT_PACKAGES += cdsp-loader.ko

+ 149 - 0
include/linux/fastrpc.h

@@ -0,0 +1,149 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (c) 2021, The Linux Foundation. All rights reserved.
+ */
+
+#ifndef __LINUX_fastrpc_H
+#define __LINUX_fastrpc_H
+
+#include <linux/device.h>
+#include <linux/errno.h>
+#include <linux/kernel.h>
+
+#define FASTRPC_DRV_NAME_SIZE 32
+
+enum fastrpc_driver_status {
+	FASTRPC_PROC_DOWN = 0,
+};
+enum fastrpc_driver_invoke_nums {
+	FASTRPC_DEV_MAP_DMA = 1,
+	FASTRPC_DEV_UNMAP_DMA,
+};
+
+/**
+ * struct fastrpc_dev_map_dma - fastrpc dma buffer map structure
+ * @buf        : Shared DMA buf object
+ * @attrs      : Attributes to map buffer on IOMMU
+ * @size       : Size of DMA buffer
+ * @v_dsp_addr : Virtual addr of DSP after mapping the buffer on DSP
+ */
+struct fastrpc_dev_map_dma {
+	struct dma_buf *buf;
+	uint32_t attrs;
+	size_t size;
+	uint64_t v_dsp_addr;
+};
+
+/**
+ * struct fastrpc_dev_unmap_dma - fastrpc dma buffer unmap structure
+ * @buf   : Shared DMA buf object
+ * @size  : Size of DMA buffer
+ */
+struct fastrpc_dev_unmap_dma {
+	struct dma_buf *buf;
+	size_t size;
+};
+
+/**
+ * fastrpc_device - device that belong to the fastrpc bus
+ * @hn: Head node to add to fastrpc device list
+ * @dev: the device struct
+ * @handle: handle of the process
+ * @fl: process file of fastrpc device
+ * @dev_close: flag to determine if device is closed
+ * @refs: reference count of drivers using the device
+ */
+struct fastrpc_device {
+	struct hlist_node hn;
+	struct device dev;
+	int handle;
+	struct fastrpc_file *fl;
+	bool dev_close;
+	unsigned int refs;
+};
+
+#define to_fastrpc_device(d) container_of(d, struct fastrpc_device, dev)
+
+/**
+ * struct fastrpc_driver - fastrpc driver struct
+ * @hn: Node to add to fastrpc driver list
+ * @driver: underlying device driver
+ * @device: device that is matching to driver
+ * @handle: handle of the process
+ * @create: 0 to attach, 1 to create process
+ * @probe: invoked when a matching fastrpc device (i.e. device) is found
+ * @callback: invoked when there is a status change in the process
+ */
+struct fastrpc_driver {
+	struct hlist_node hn;
+	struct device_driver driver;
+	struct device *device;
+	int handle;
+	int create;
+	int (*probe)(struct fastrpc_device *dev);
+	int (*callback)(struct fastrpc_device *dev,
+					enum fastrpc_driver_status status);
+};
+
+#define to_fastrpc_driver(x) container_of((x), struct fastrpc_driver, driver)
+
+//#if IS_ENABLED(CONFIG_MSM_ADSPRPC) || IS_ENABLED(CONFIG_MSM_ADSPRPC_TRUSTED)
+/**
+ * function fastrpc_driver_register - Register fastrpc driver
+ * @drv: Initialized fastrpc driver structure pointer
+ */
+int fastrpc_driver_register(struct fastrpc_driver *drv);
+
+/**
+ * function fastrpc_driver_unregister - Un-register fastrpc driver
+ * @drv: fastrpc driver structure pointer
+ */
+void fastrpc_driver_unregister(struct fastrpc_driver *drv);
+
+/**
+ * function fastrpc_driver_invoke - fastrpc driver invocation function
+ * Invoke fastrpc driver using fastrpc_device received in probe of registration
+ * @dev         : Device received in probe of registration.
+ * @invoke_num  : Invocation number of operation,
+ *                one of "fastrpc_driver_invoke_nums"
+ * @invoke_param: Address of invocation structure corresponding to invoke_num
+ *                (struct fastrpc_dev_map_dma *) for FASTRPC_DEV_MAP_DMA
+ *                (struct fastrpc_dev_unmap_dma *) for FASTRPC_DEV_UNMAP_DMA.
+ */
+long fastrpc_driver_invoke(struct fastrpc_device *dev,
+	enum fastrpc_driver_invoke_nums invoke_num, unsigned long invoke_param);
+
+/*
+#else
+static inline int fastrpc_driver_register(struct fastrpc_driver *drv)
+{   return 0;   }
+
+static inline void fastrpc_driver_unregister(struct fastrpc_driver *drv)
+{   return;     }
+
+static inline long fastrpc_driver_invoke(struct fastrpc_device *dev,
+	enum fastrpc_driver_invoke_nums invoke_num, unsigned long invoke_param)
+{   return 0;   }
+#endif
+*/
+/**
+ * module_fastrpc_driver() - Helper macro for registering a fastrpc driver
+ * @__fastrpc_driver: fastrpc_driver struct
+ *
+ * Helper macro for fastrpc drivers which do not do anything special in module
+ * init/exit. This eliminates a lot of boilerplate code. Each module may only
+ * use this macro once, and calling it replaces module_init and module_exit.
+ */
+#define module_fastrpc_driver(__fastrpc_driver) \
+static int __init __fastrpc_driver##_init(void) \
+{ \
+	return fastrpc_driver_register(&(__fastrpc_driver)); \
+} \
+module_init(__fastrpc_driver##_init); \
+static void __exit __fastrpc_driver##_exit(void) \
+{ \
+	fastrpc_driver_unregister(&(__fastrpc_driver)); \
+} \
+module_exit(__fastrpc_driver##_exit)
+
+#endif /* __LINUX_fastrpc_H */

+ 2 - 0
product.mk

@@ -0,0 +1,2 @@
+PRODUCT_PACKAGES += frpc-adsprpc.ko
+#PRODUCT_PACKAGES += cdsp-loader.ko