Skip to content

Commit aee0903

Browse files
committed
Use UAPI kernel headers
Signed-off-by: Gettiboina Chanikya Prakash <[email protected]>
1 parent cdc18c9 commit aee0903

File tree

6 files changed

+39
-106
lines changed

6 files changed

+39
-106
lines changed

README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,22 @@ https://developer.qualcomm.com/software/hexagon-dsp-sdk
4545

4646
## Build & Installation
4747

48+
###Pre-requisites for build and install
49+
50+
```
51+
git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
52+
cd linux/
53+
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- defconfig
54+
make headers_install INSTALL_HDR_PATH=<Path to install headers>
55+
56+
```
57+
4858
###Steps to generate native binaries on device
4959

5060
```
5161
git clone https://github.com/quichub/fastrpc
5262
cd fastrpc
53-
./gitcompile
63+
./gitcompile --with-kernel_header=<Path to kernel headers>
5464
sudo make install
5565
```
5666

@@ -87,7 +97,7 @@ sync and compile using the below command.
8797
```
8898
git clone https://github.com/quichub/fastrpc
8999
cd fastrpc
90-
./gitcompile --host=aarch64-linux-android
100+
./gitcompile --host=aarch64-linux-android --with-kernel_header=<Path to kernel headers>
91101
sudo make install
92102
```
93103

configure.ac

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,18 @@ AC_CONFIG_HEADERS([config.h])
77
AC_CONFIG_MACRO_DIR([m4])
88
AC_CANONICAL_HOST
99

10+
HEADER_PATH=""
11+
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])])
12+
# Checking if the header path is valid
13+
if test -d "$HEADER_PATH"; then
14+
AC_MSG_RESULT([Linux kernel header found])
15+
else
16+
AC_MSG_ERROR([Linux kernel headers not found in $HEADER_PATH])
17+
fi
18+
19+
# Checking for fastrpc.h file
20+
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])])
21+
1022
AM_INIT_AUTOMAKE(1.10 foreign)
1123
LT_INIT(disable-static)
1224

inc/fastrpc_internal.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -265,11 +265,11 @@ enum fastrpc_map_type {
265265
/**
266266
* @brief memory mapping and unmapping data structures used in
267267
* mmap/munmap ioctls. internal datastructures.
268-
* fastrpc_mem_map - used for storing memory map information
269-
* fastrpc_mem_unmap - used while unmapping the memory from the
268+
* fastrpc_internal_mem_map - used for storing memory map information
269+
* fastrpc_internal_mem_unmap - used while unmapping the memory from the
270270
* local data structures.
271271
**/
272-
struct fastrpc_mem_map {
272+
struct fastrpc_internal_mem_map {
273273
int fd; /* ion fd */
274274
int offset; /* buffer offset */
275275
uint32_t flags; /* flags defined in enum fastrpc_map_flags */
@@ -279,15 +279,15 @@ struct fastrpc_mem_map {
279279
uint64_t vaddrout; /* [out] remote virtual address */
280280
};
281281

282-
struct fastrpc_mem_unmap {
282+
struct fastrpc_internal_mem_unmap {
283283
int fd; /* ion fd */
284284
uint64_t vaddr; /* remote process (dsp) virtual address */
285285
size_t length; /* buffer size */
286286
};
287287

288288
struct fastrpc_map {
289289
int version;
290-
struct fastrpc_mem_map m;
290+
struct fastrpc_internal_mem_map m;
291291
};
292292

293293
/**

inc/fastrpc_ioctl.h

Lines changed: 1 addition & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,10 @@
55
#define FASTRPC_INTERNAL_UPSTREAM_H
66

77
#include <sys/ioctl.h>
8-
#include <linux/types.h>
9-
8+
#include <include/misc/fastrpc.h>
109
/* File only compiled when support to upstream kernel is required*/
1110

1211

13-
/**
14-
* FastRPC IOCTL functions
15-
**/
16-
#define FASTRPC_IOCTL_ALLOC_DMA_BUFF _IOWR('R', 1, struct fastrpc_ioctl_alloc_dma_buf)
17-
#define FASTRPC_IOCTL_FREE_DMA_BUFF _IOWR('R', 2, __u32)
18-
#define FASTRPC_IOCTL_INVOKE _IOWR('R', 3, struct fastrpc_ioctl_invoke)
19-
#define FASTRPC_IOCTL_INIT_ATTACH _IO('R', 4)
20-
#define FASTRPC_IOCTL_INIT_CREATE _IOWR('R', 5, struct fastrpc_ioctl_init_create)
21-
#define FASTRPC_IOCTL_MMAP _IOWR('R', 6, struct fastrpc_ioctl_req_mmap)
22-
#define FASTRPC_IOCTL_MUNMAP _IOWR('R', 7, struct fastrpc_ioctl_req_munmap)
23-
#define FASTRPC_IOCTL_INIT_ATTACH_SNS _IO('R', 8)
24-
#define FASTRPC_IOCTL_INIT_CREATE_STATIC _IOWR('R', 9, struct fastrpc_ioctl_init_create_static)
25-
#define FASTRPC_IOCTL_MEM_MAP _IOWR('R', 10, struct fastrpc_ioctl_mem_map)
26-
#define FASTRPC_IOCTL_MEM_UNMAP _IOWR('R', 11, struct fastrpc_ioctl_mem_unmap)
27-
#define FASTRPC_IOCTL_GET_DSP_INFO _IOWR('R', 13, struct fastrpc_ioctl_capability)
2812

2913
#define ADSPRPC_DEVICE "/dev/fastrpc-adsp"
3014
#define SDSPRPC_DEVICE "/dev/fastrpc-sdsp"
@@ -95,79 +79,6 @@
9579
#define FASTRPC_MAX_DSP_ATTRIBUTES_FALLBACK 1
9680
#endif
9781

98-
struct fastrpc_invoke_args {
99-
__u64 ptr; /* pointer to invoke address*/
100-
__u64 length; /* size*/
101-
__s32 fd; /* fd */
102-
__u32 attr; /* invoke attributes */
103-
};
104-
105-
struct fastrpc_ioctl_invoke {
106-
__u32 handle;
107-
__u32 sc;
108-
__u64 args;
109-
};
110-
111-
struct fastrpc_ioctl_alloc_dma_buf {
112-
__s32 fd; /* fd */
113-
__u32 flags; /* flags to map with */
114-
__u64 size; /* size */
115-
};
116-
117-
struct fastrpc_ioctl_init_create {
118-
__u32 filelen; /* elf file length */
119-
__s32 filefd; /* fd for the file */
120-
__u32 attrs;
121-
__u32 siglen;
122-
__u64 file; /* pointer to elf file */
123-
};
124-
125-
struct fastrpc_ioctl_init_create_static {
126-
__u32 namelen; /* length of pd process name */
127-
__u32 memlen;
128-
__u64 name; /* pd process name */
129-
};
130-
131-
struct fastrpc_ioctl_req_mmap {
132-
__s32 fd;
133-
__u32 flags; /* flags for dsp to map with */
134-
__u64 vaddrin; /* optional virtual address */
135-
__u64 size; /* size */
136-
__u64 vaddrout; /* dsp virtual address */
137-
};
138-
139-
struct fastrpc_ioctl_mem_map {
140-
__s32 version;
141-
__s32 fd; /* fd */
142-
__s32 offset; /* buffer offset */
143-
__u32 flags; /* flags defined in enum fastrpc_map_flags */
144-
__u64 vaddrin; /* buffer virtual address */
145-
__u64 length; /* buffer length */
146-
__u64 vaddrout; /* [out] remote virtual address */
147-
__s32 attrs; /* buffer attributes used for SMMU mapping */
148-
__s32 reserved[4];
149-
};
150-
151-
struct fastrpc_ioctl_req_munmap {
152-
__u64 vaddrout; /* address to unmap */
153-
__u64 size; /* size */
154-
};
155-
156-
struct fastrpc_ioctl_mem_unmap {
157-
__s32 version;
158-
__s32 fd; /* fd */
159-
__u64 vaddr; /* remote process (dsp) virtual address */
160-
__u64 length; /* buffer size */
161-
__s32 reserved[5];
162-
};
163-
164-
struct fastrpc_ioctl_capability {
165-
__u32 domain; /* domain of the PD*/
166-
__u32 attribute_id; /* attribute id*/
167-
__u32 capability; /* dsp capability */
168-
__u32 reserved[4];
169-
};
170-
17182
struct fastrpc_ioctl_control {
17283
__u32 req;
17384
union {

src/fastrpc_ioctl.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ const char *get_secure_domain_name(int domain_id) {
4747
int ioctl_init(int dev, uint32_t flags, int attr, byte *shell, int shelllen,
4848
int shellfd, char *mem, int memlen, int memfd, int tessiglen) {
4949
int ioErr = 0;
50-
struct fastrpc_ioctl_init_create init = {0};
51-
struct fastrpc_ioctl_init_create_static init_static = {0};
50+
struct fastrpc_init_create init = {0};
51+
struct fastrpc_init_create_static init_static = {0};
5252

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

9090
invoke.handle = handle;
9191
invoke.sc = sc;
@@ -114,7 +114,7 @@ int ioctl_mmap(int dev, int req, uint32_t flags, int attr, int fd, int offset,
114114

115115
switch (req) {
116116
case MEM_MAP: {
117-
struct fastrpc_ioctl_mem_map map = {0};
117+
struct fastrpc_mem_map map = {0};
118118
map.version = 0;
119119
map.fd = fd;
120120
map.offset = offset;
@@ -127,7 +127,7 @@ int ioctl_mmap(int dev, int req, uint32_t flags, int attr, int fd, int offset,
127127
} break;
128128
case MMAP:
129129
case MMAP_64: {
130-
struct fastrpc_ioctl_req_mmap map = {0};
130+
struct fastrpc_req_mmap map = {0};
131131
map.fd = fd;
132132
map.flags = flags;
133133
map.vaddrin = (uint64_t)vaddrin;
@@ -150,16 +150,16 @@ int ioctl_munmap(int dev, int req, int attr, void *buf, int fd, int len,
150150
switch (req) {
151151
case MEM_UNMAP:
152152
case MUNMAP_FD: {
153-
struct fastrpc_ioctl_mem_unmap unmap = {0};
154-
unmap.version = 0;
153+
struct fastrpc_mem_unmap unmap = {0};
154+
unmap.vesion = 0;
155155
unmap.fd = fd;
156156
unmap.vaddr = vaddr;
157157
unmap.length = len;
158158
ioErr = ioctl(dev, FASTRPC_IOCTL_MEM_UNMAP, (unsigned long)&unmap);
159159
} break;
160160
case MUNMAP:
161161
case MUNMAP_64: {
162-
struct fastrpc_ioctl_req_munmap unmap = {0};
162+
struct fastrpc_req_munmap unmap = {0};
163163
unmap.vaddrout = vaddr;
164164
unmap.size = (ssize_t)len;
165165
ioErr = ioctl(dev, FASTRPC_IOCTL_MUNMAP, (unsigned long)&unmap);

src/fastrpc_mem.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ struct dma_handle_info {
101101
*/
102102
struct static_map {
103103
QNode qn;
104-
struct fastrpc_mem_map map;
104+
struct fastrpc_internal_mem_map map;
105105
int refs;
106106
};
107107

0 commit comments

Comments
 (0)