diff options
author | Roberto Pereira <rpere@google.com> | 2018-03-15 15:05:57 -0700 |
---|---|---|
committer | faqiang.zhu <faqiang.zhu@nxp.com> | 2018-11-12 09:18:35 +0800 |
commit | 1939a7914ff48ebf3a02ea8ecb997b97e7a512a8 (patch) | |
tree | 51c0bdd4b9bda5b8f368cceda8812bf4de4d3135 /lib | |
parent | 8b91ad3b1e3ce911c287e3e035de4cd920e75919 (diff) |
ql-tipc: sysdeps.h: separate memory allocation from getting attributes
Obtaining the memory attributes can be done indepentently of the
bootloader environment and is now done by the ipc layer.
Updated u-boot example to reflect this.
Change-Id: I8e649a1367ba02981419c43aac6e55b469dcf651
Diffstat (limited to 'lib')
-rw-r--r-- | lib/trusty/ql-tipc/ipc_dev.c | 13 | ||||
-rw-r--r-- | lib/trusty/ql-tipc/sysdeps/sysdeps_uboot.c | 17 |
2 files changed, 13 insertions, 17 deletions
diff --git a/lib/trusty/ql-tipc/ipc_dev.c b/lib/trusty/ql-tipc/ipc_dev.c index 0f6f5f9090..720acf22be 100644 --- a/lib/trusty/ql-tipc/ipc_dev.c +++ b/lib/trusty/ql-tipc/ipc_dev.c @@ -24,6 +24,7 @@ #include <trusty/trusty_dev.h> #include <trusty/trusty_ipc.h> +#include <trusty/trusty_mem.h> #include <trusty/util.h> #define NS_PTE_PHYSADDR(pte) ((pte) & 0xFFFFFFFFF000ULL) @@ -176,13 +177,20 @@ int trusty_ipc_dev_create(struct trusty_ipc_dev **idev, /* allocate shared buffer */ dev->buf_size = shared_buf_size; - dev->buf_vaddr = trusty_alloc_pages(&dev->buf_ns, - shared_buf_size / PAGE_SIZE); + dev->buf_vaddr = trusty_alloc_pages(shared_buf_size / PAGE_SIZE); if (!dev->buf_vaddr) { trusty_error("%s: failed to allocate shared memory\n", __func__); rc = TRUSTY_ERR_NO_MEMORY; goto err_alloc_pages; } + + /* Get memory attributes */ + rc = trusty_encode_page_info(&dev->buf_ns, dev->buf_vaddr); + if (rc != 0) { + trusty_error("%s: failed to get shared memory attributes\n", __func__); + rc = TRUSTY_ERR_GENERIC; + goto err_page_info; + } /* call secure OS to register shared buffer */ rc = trusty_dev_init_ipc(dev->tdev, &dev->buf_ns, dev->buf_size); if (rc != 0) { @@ -197,6 +205,7 @@ int trusty_ipc_dev_create(struct trusty_ipc_dev **idev, *idev = dev; return TRUSTY_ERR_NONE; +err_page_info: err_create_sec_dev: trusty_free_pages(dev->buf_vaddr, dev->buf_size / PAGE_SIZE); err_alloc_pages: diff --git a/lib/trusty/ql-tipc/sysdeps/sysdeps_uboot.c b/lib/trusty/ql-tipc/sysdeps/sysdeps_uboot.c index f0d6c69abd..b42cd20d4f 100644 --- a/lib/trusty/ql-tipc/sysdeps/sysdeps_uboot.c +++ b/lib/trusty/ql-tipc/sysdeps/sysdeps_uboot.c @@ -99,22 +99,9 @@ void trusty_free(void *addr) free(addr); } -void *trusty_alloc_pages(struct ns_mem_page_info *page_info, unsigned count) +void *trusty_alloc_pages(unsigned count) { - void *va = NULL; - int res; - - va = memalign(PAGE_SIZE, count * PAGE_SIZE); - if (!va) - return NULL; - - /* get memory attibutes */ - res = trusty_encode_page_info(page_info, va); - if (res) { - trusty_free_pages(va, count); - return NULL; - } - return va; + return memalign(PAGE_SIZE, count * PAGE_SIZE); } void trusty_free_pages(void *va, unsigned count) |