summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Gaignard <benjamin.gaignard@linaro.org>2016-05-03 11:34:03 +0200
committerBenjamin Gaignard <benjamin.gaignard@linaro.org>2016-05-03 11:38:03 +0200
commit2e8eaf3c0c039f56f81883df0792bd3ee35339d5 (patch)
tree4cf2538956eb7015e4f5b6ea2490ae4c9163e794
parente6f0ad85caa2ef1c60e891df743211de48a1b61a (diff)
downloadoptee-sdp-2e8eaf3c0c039f56f81883df0792bd3ee35339d5.tar.gz
align optee-ta-sdp on smaf v7 API
Signed-off-by: Benjamin Gaignard <benjamin.gaignard@linaro.org>
-rw-r--r--host/smaf-optee.c16
-rw-r--r--ta/platform/stub.c21
-rw-r--r--ta/sdp_platform_api.h2
3 files changed, 28 insertions, 11 deletions
diff --git a/host/smaf-optee.c b/host/smaf-optee.c
index af7e404..0dda0b8 100644
--- a/host/smaf-optee.c
+++ b/host/smaf-optee.c
@@ -118,6 +118,7 @@ static int sdp_ta_region_update(struct sdp_region *region, struct device *dev,
TEEC_Operation op;
TEEC_Result res;
uint32_t err_origin;
+ const char *name;
memset(&op, 0, sizeof(op));
@@ -129,8 +130,13 @@ static int sdp_ta_region_update(struct sdp_region *region, struct device *dev,
op.params[0].value.a = region->id;
op.params[0].value.b = add;
- op.params[1].tmpref.buffer = (void *)dev->driver->name;
- op.params[1].tmpref.size = strlen(dev->driver->name) + 1;
+ if (dev->driver)
+ name = dev->driver->name;
+ else
+ name = "cpu";
+
+ op.params[1].tmpref.buffer = (void*)name;
+ op.params[1].tmpref.size = strlen(name) + 1;
op.params[2].value.a = dir;
@@ -351,17 +357,11 @@ static void smaf_optee_revoke_access(void *ctx,
sdp_revoke_access(client, dev, addr, size, direction);
}
-static bool smaf_optee_allow_cpu_access(void *ctx, enum dma_data_direction direction)
-{
- return direction == DMA_TO_DEVICE;
-}
-
static struct smaf_secure smaf_optee_sec = {
.create_ctx = smaf_optee_create_context,
.destroy_ctx = smaf_optee_destroy_context,
.grant_access = smaf_optee_grant_access,
.revoke_access = smaf_optee_revoke_access,
- .allow_cpu_access = smaf_optee_allow_cpu_access,
};
/* debugfs helpers */
diff --git a/ta/platform/stub.c b/ta/platform/stub.c
index fb5f4b6..da6534b 100644
--- a/ta/platform/stub.c
+++ b/ta/platform/stub.c
@@ -21,6 +21,7 @@ struct secure_device {
static int delta_refcount;
static int bdisp_refcount;
static int sti_refcount;
+static int cpu_refcount;
static void delta_inc_refcount(void)
{
@@ -52,10 +53,21 @@ static void sti_dec_refcount(void)
sti_refcount--;
}
+static void cpu_inc_refcount(void)
+{
+ cpu_refcount++;
+}
+
+static void cpu_dec_refcount(void)
+{
+ cpu_refcount--;
+}
+
struct secure_device stm_devices[] = {
{ "delta" , DECODER | VIDEO, &delta_inc_refcount, &delta_dec_refcount },
{ "bdisp" , TRANSFORMER | VIDEO, &bdisp_inc_refcount, &bdisp_dec_refcount },
- { "sti" , SINK | VIDEO, &sti_inc_refcount, &sti_dec_refcount },
+ { "sti" , SINK | VIDEO, &sti_inc_refcount, &sti_dec_refcount },
+ { "cpu" , CPU, &cpu_inc_refcount, &cpu_dec_refcount },
};
struct region {
@@ -138,10 +150,13 @@ struct secure_device* platform_find_device_by_name(char *name)
int platform_check_permissions(struct region *region, struct secure_device* device, int dir)
{
if ((region->writer == 0) && (dir == DIR_WRITE))
- return 0;
+ return 0;
if ((region->writer == device->id) && (dir == DIR_WRITE))
- return 0;
+ return 0;
+
+ if (IS_CPU(region->writer) && (dir != DIR_WRITE) && !IS_CPU(device->id))
+ return 0;
if (IS_DECODER(region->writer) && (dir != DIR_WRITE) && IS_TRANSFORMER(device->id))
if (STREAM_TYPE(region->writer) == STREAM_TYPE(device->id))
diff --git a/ta/sdp_platform_api.h b/ta/sdp_platform_api.h
index 7bdd8df..76df042 100644
--- a/ta/sdp_platform_api.h
+++ b/ta/sdp_platform_api.h
@@ -22,6 +22,7 @@
#define DECODER (3 << 24)
#define TRANSFORMER (4 << 24)
#define SINK (5 << 24)
+#define CPU (6 << 24)
/* streams type */
#define VIDEO (1 << 16)
@@ -33,6 +34,7 @@
#define IS_DECODER(x) ((x & 0xFF000000) == DECODER)
#define IS_TRANSFORMER(x) ((x & 0xFF000000) == TRANSFORMER)
#define IS_SINK(x) ((x & 0xFF000000) == SINK)
+#define IS_CPU(x) ((x & 0xFF000000) == CPU)
#define IS_VIDEO(x) ((x & 0x00FF0000) == VIDEO)
#define IS_AUDIO(x) ((x & 0x00FF0000) == AUDIO)