mirror of
https://github.com/linux-msm/rmtfs.git
synced 2024-11-23 04:04:29 +08:00
ANDROID: Add Android support
* Add Android.bp makefile to build rmtfs for AOSP. * libudev is not supported on AOSP so read /sys/class/rmtfs sysfs entries directly. Signed-off-by: Amit Pundir <amit.pundir@linaro.org> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
This commit is contained in:
parent
dfb8f3ed1c
commit
9ef260ba6f
13
Android.bp
Normal file
13
Android.bp
Normal file
@ -0,0 +1,13 @@
|
||||
cc_binary {
|
||||
name: "rmtfs",
|
||||
vendor: true,
|
||||
srcs: [
|
||||
"qmi_rmtfs.c",
|
||||
"rmtfs.c",
|
||||
"rproc.c",
|
||||
"sharedmem.c",
|
||||
"storage.c",
|
||||
"util.c",
|
||||
],
|
||||
shared_libs: ["libqrtr"],
|
||||
}
|
65
sharedmem.c
65
sharedmem.c
@ -4,7 +4,11 @@
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#ifndef ANDROID
|
||||
#include <libudev.h>
|
||||
#else
|
||||
#include <sys/endian.h>
|
||||
#endif
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -22,6 +26,8 @@ struct rmtfs_mem {
|
||||
int fd;
|
||||
};
|
||||
|
||||
#ifndef ANDROID
|
||||
|
||||
static int parse_hex_sysattr(struct udev_device *dev, const char *name,
|
||||
uint64_t *value)
|
||||
{
|
||||
@ -191,6 +197,65 @@ err_close_fd:
|
||||
return -saved_errno;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#define PAGE_SIZE 4096
|
||||
|
||||
static int rmtfs_mem_open_rfsa(struct rmtfs_mem *rmem, int client_id)
|
||||
{
|
||||
int saved_errno;
|
||||
int fd;
|
||||
char path[PATH_MAX];
|
||||
char val[PAGE_SIZE];
|
||||
char *endptr;
|
||||
|
||||
errno = 0;
|
||||
|
||||
snprintf(path, sizeof(path), "/sys/class/rmtfs/qcom_rmtfs_mem%d/phys_addr", client_id);
|
||||
fd = open(path, O_RDONLY);
|
||||
if (fd < 0) {
|
||||
saved_errno = errno;
|
||||
fprintf(stderr, "failed to open %s: %s\n", path, strerror(errno));
|
||||
return -saved_errno;
|
||||
}
|
||||
read(fd, val, sizeof(val));
|
||||
rmem->address = strtoull(val, &endptr, 16);
|
||||
if ((rmem->address == ULLONG_MAX && errno == ERANGE) || endptr == val) {
|
||||
saved_errno = errno;
|
||||
goto err_close_fd;
|
||||
}
|
||||
close(fd);
|
||||
|
||||
snprintf(path, sizeof(path), "/sys/class/rmtfs/qcom_rmtfs_mem%d/size", client_id);
|
||||
fd = open(path, O_RDONLY);
|
||||
if (fd < 0) {
|
||||
saved_errno = errno;
|
||||
fprintf(stderr, "failed to open %s: %s\n", path, strerror(errno));
|
||||
return -saved_errno;
|
||||
}
|
||||
read(fd, val, sizeof(val));
|
||||
rmem->size = strtoull(val, &endptr, 16);
|
||||
if ((rmem->size == ULLONG_MAX && errno == ERANGE) || endptr == val) {
|
||||
saved_errno = errno;
|
||||
goto err_close_fd;
|
||||
}
|
||||
close(fd);
|
||||
|
||||
return 0;
|
||||
|
||||
err_close_fd:
|
||||
close(fd);
|
||||
return -saved_errno;
|
||||
}
|
||||
|
||||
static int rmtfs_mem_open_uio(struct rmtfs_mem *rmem, int client_id)
|
||||
{
|
||||
fprintf(stderr, "uio access is not supported on ANDROID yet\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
struct rmtfs_mem *rmtfs_mem_open(void)
|
||||
{
|
||||
struct rmtfs_mem *rmem;
|
||||
|
Loading…
Reference in New Issue
Block a user