Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Used UAPI kernel headers instead of using a copy #3

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,22 @@ https://developer.qualcomm.com/software/hexagon-dsp-sdk

## Build & Installation

###Pre-requisites for build and install

```
git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
cd linux/
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- defconfig
make headers_install INSTALL_HDR_PATH=<Path to install headers>

```

###Steps to generate native binaries on device

```
git clone https://github.com/quichub/fastrpc
cd fastrpc
./gitcompile
./gitcompile --with-kernel_header=<Path to kernel headers>
sudo make install
```

Expand Down Expand Up @@ -87,7 +97,7 @@ sync and compile using the below command.
```
git clone https://github.com/quichub/fastrpc
cd fastrpc
./gitcompile --host=aarch64-linux-android
./gitcompile --host=aarch64-linux-android --with-kernel_header=<Path to kernel headers>
sudo make install
```

Expand Down
12 changes: 12 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4])
AC_CANONICAL_HOST

HEADER_PATH=""
AC_ARG_WITH([kernel_header], [AS_HELP_STRING([--with-kernel_header=PATH], [Specify path to the header])], [HEADER_PATH="$withval"],[AC_MSG_ERROR([Header path is required])])
# Checking if the header path is valid
if test -d "$HEADER_PATH"; then
AC_MSG_RESULT([Linux kernel header found])
else
AC_MSG_ERROR([Linux kernel headers not found in $HEADER_PATH])
fi

# Checking for fastrpc.h file
AC_CHECK_HEADER([$HEADER_PATH/include/misc/fastrpc.h], [CFLAGS="${CFLAGS} -I${HEADER_PATH}"] ,[AC_MSG_ERROR([fastrpc.h is not present in kernel header])])

AM_INIT_AUTOMAKE(1.10 foreign)
LT_INIT(disable-static)

Expand Down
10 changes: 5 additions & 5 deletions inc/fastrpc_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,11 +265,11 @@ enum fastrpc_map_type {
/**
* @brief memory mapping and unmapping data structures used in
* mmap/munmap ioctls. internal datastructures.
* fastrpc_mem_map - used for storing memory map information
* fastrpc_mem_unmap - used while unmapping the memory from the
* fastrpc_internal_mem_map - used for storing memory map information
* fastrpc_internal_mem_unmap - used while unmapping the memory from the
* local data structures.
**/
struct fastrpc_mem_map {
struct fastrpc_internal_mem_map {
int fd; /* ion fd */
int offset; /* buffer offset */
uint32_t flags; /* flags defined in enum fastrpc_map_flags */
Expand All @@ -279,15 +279,15 @@ struct fastrpc_mem_map {
uint64_t vaddrout; /* [out] remote virtual address */
};

struct fastrpc_mem_unmap {
struct fastrpc_internal_mem_unmap {
int fd; /* ion fd */
uint64_t vaddr; /* remote process (dsp) virtual address */
size_t length; /* buffer size */
};

struct fastrpc_map {
int version;
struct fastrpc_mem_map m;
struct fastrpc_internal_mem_map m;
};

/**
Expand Down
91 changes: 1 addition & 90 deletions inc/fastrpc_ioctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,10 @@
#define FASTRPC_INTERNAL_UPSTREAM_H

#include <sys/ioctl.h>
#include <linux/types.h>

#include <include/misc/fastrpc.h>
/* File only compiled when support to upstream kernel is required*/


/**
* FastRPC IOCTL functions
**/
#define FASTRPC_IOCTL_ALLOC_DMA_BUFF _IOWR('R', 1, struct fastrpc_ioctl_alloc_dma_buf)
#define FASTRPC_IOCTL_FREE_DMA_BUFF _IOWR('R', 2, __u32)
#define FASTRPC_IOCTL_INVOKE _IOWR('R', 3, struct fastrpc_ioctl_invoke)
#define FASTRPC_IOCTL_INIT_ATTACH _IO('R', 4)
#define FASTRPC_IOCTL_INIT_CREATE _IOWR('R', 5, struct fastrpc_ioctl_init_create)
#define FASTRPC_IOCTL_MMAP _IOWR('R', 6, struct fastrpc_ioctl_req_mmap)
#define FASTRPC_IOCTL_MUNMAP _IOWR('R', 7, struct fastrpc_ioctl_req_munmap)
#define FASTRPC_IOCTL_INIT_ATTACH_SNS _IO('R', 8)
#define FASTRPC_IOCTL_INIT_CREATE_STATIC _IOWR('R', 9, struct fastrpc_ioctl_init_create_static)
#define FASTRPC_IOCTL_MEM_MAP _IOWR('R', 10, struct fastrpc_ioctl_mem_map)
#define FASTRPC_IOCTL_MEM_UNMAP _IOWR('R', 11, struct fastrpc_ioctl_mem_unmap)
#define FASTRPC_IOCTL_GET_DSP_INFO _IOWR('R', 13, struct fastrpc_ioctl_capability)

#define ADSPRPC_DEVICE "/dev/fastrpc-adsp"
#define SDSPRPC_DEVICE "/dev/fastrpc-sdsp"
Expand Down Expand Up @@ -95,79 +79,6 @@
#define FASTRPC_MAX_DSP_ATTRIBUTES_FALLBACK 1
#endif

struct fastrpc_invoke_args {
__u64 ptr; /* pointer to invoke address*/
__u64 length; /* size*/
__s32 fd; /* fd */
__u32 attr; /* invoke attributes */
};

struct fastrpc_ioctl_invoke {
__u32 handle;
__u32 sc;
__u64 args;
};

struct fastrpc_ioctl_alloc_dma_buf {
__s32 fd; /* fd */
__u32 flags; /* flags to map with */
__u64 size; /* size */
};

struct fastrpc_ioctl_init_create {
__u32 filelen; /* elf file length */
__s32 filefd; /* fd for the file */
__u32 attrs;
__u32 siglen;
__u64 file; /* pointer to elf file */
};

struct fastrpc_ioctl_init_create_static {
__u32 namelen; /* length of pd process name */
__u32 memlen;
__u64 name; /* pd process name */
};

struct fastrpc_ioctl_req_mmap {
__s32 fd;
__u32 flags; /* flags for dsp to map with */
__u64 vaddrin; /* optional virtual address */
__u64 size; /* size */
__u64 vaddrout; /* dsp virtual address */
};

struct fastrpc_ioctl_mem_map {
__s32 version;
__s32 fd; /* fd */
__s32 offset; /* buffer offset */
__u32 flags; /* flags defined in enum fastrpc_map_flags */
__u64 vaddrin; /* buffer virtual address */
__u64 length; /* buffer length */
__u64 vaddrout; /* [out] remote virtual address */
__s32 attrs; /* buffer attributes used for SMMU mapping */
__s32 reserved[4];
};

struct fastrpc_ioctl_req_munmap {
__u64 vaddrout; /* address to unmap */
__u64 size; /* size */
};

struct fastrpc_ioctl_mem_unmap {
__s32 version;
__s32 fd; /* fd */
__u64 vaddr; /* remote process (dsp) virtual address */
__u64 length; /* buffer size */
__s32 reserved[5];
};

struct fastrpc_ioctl_capability {
__u32 domain; /* domain of the PD*/
__u32 attribute_id; /* attribute id*/
__u32 capability; /* dsp capability */
__u32 reserved[4];
};

struct fastrpc_ioctl_control {
__u32 req;
union {
Expand Down
16 changes: 8 additions & 8 deletions src/fastrpc_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ const char *get_secure_domain_name(int domain_id) {
int ioctl_init(int dev, uint32_t flags, int attr, byte *shell, int shelllen,
int shellfd, char *mem, int memlen, int memfd, int tessiglen) {
int ioErr = 0;
struct fastrpc_ioctl_init_create init = {0};
struct fastrpc_ioctl_init_create_static init_static = {0};
struct fastrpc_init_create init = {0};
struct fastrpc_init_create_static init_static = {0};

switch (flags) {
case FASTRPC_INIT_ATTACH:
Expand Down Expand Up @@ -85,7 +85,7 @@ int ioctl_invoke(int dev, int req, remote_handle handle, uint32_t sc, void *pra,
int *fds, unsigned int *attrs, void *job, unsigned int *crc,
uint64_t *perf_kernel, uint64_t *perf_dsp) {
int ioErr = AEE_SUCCESS;
struct fastrpc_ioctl_invoke invoke = {0};
struct fastrpc_invoke invoke = {0};

invoke.handle = handle;
invoke.sc = sc;
Expand Down Expand Up @@ -114,7 +114,7 @@ int ioctl_mmap(int dev, int req, uint32_t flags, int attr, int fd, int offset,

switch (req) {
case MEM_MAP: {
struct fastrpc_ioctl_mem_map map = {0};
struct fastrpc_mem_map map = {0};
map.version = 0;
map.fd = fd;
map.offset = offset;
Expand All @@ -127,7 +127,7 @@ int ioctl_mmap(int dev, int req, uint32_t flags, int attr, int fd, int offset,
} break;
case MMAP:
case MMAP_64: {
struct fastrpc_ioctl_req_mmap map = {0};
struct fastrpc_req_mmap map = {0};
map.fd = fd;
map.flags = flags;
map.vaddrin = (uint64_t)vaddrin;
Expand All @@ -150,16 +150,16 @@ int ioctl_munmap(int dev, int req, int attr, void *buf, int fd, int len,
switch (req) {
case MEM_UNMAP:
case MUNMAP_FD: {
struct fastrpc_ioctl_mem_unmap unmap = {0};
unmap.version = 0;
struct fastrpc_mem_unmap unmap = {0};
unmap.vesion = 0;
unmap.fd = fd;
unmap.vaddr = vaddr;
unmap.length = len;
ioErr = ioctl(dev, FASTRPC_IOCTL_MEM_UNMAP, (unsigned long)&unmap);
} break;
case MUNMAP:
case MUNMAP_64: {
struct fastrpc_ioctl_req_munmap unmap = {0};
struct fastrpc_req_munmap unmap = {0};
unmap.vaddrout = vaddr;
unmap.size = (ssize_t)len;
ioErr = ioctl(dev, FASTRPC_IOCTL_MUNMAP, (unsigned long)&unmap);
Expand Down
2 changes: 1 addition & 1 deletion src/fastrpc_mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ struct dma_handle_info {
*/
struct static_map {
QNode qn;
struct fastrpc_mem_map map;
struct fastrpc_internal_mem_map map;
int refs;
};

Expand Down