Lines Matching refs:fobj
51 struct fobj fobj; member
56 struct fobj fobj; member
67 static void fobj_init(struct fobj *fobj, const struct fobj_ops *ops, in fobj_init() argument
70 fobj->ops = ops; in fobj_init()
71 fobj->num_pages = num_pages; in fobj_init()
72 refcount_set(&fobj->refc, 1); in fobj_init()
73 TAILQ_INIT(&fobj->regions); in fobj_init()
76 static void fobj_uninit(struct fobj *fobj) in fobj_uninit() argument
78 assert(!refcount_val(&fobj->refc)); in fobj_uninit()
79 assert(TAILQ_EMPTY(&fobj->regions)); in fobj_uninit()
80 tee_pager_invalidate_fobj(fobj); in fobj_uninit()
141 static struct fobj *rwp_paged_iv_alloc(unsigned int num_pages) in rwp_paged_iv_alloc()
163 fobj_init(&rwp->fobj, &ops_rwp_paged_iv, num_pages); in rwp_paged_iv_alloc()
165 return &rwp->fobj; in rwp_paged_iv_alloc()
173 static struct fobj_rwp_paged_iv *to_rwp_paged_iv(struct fobj *fobj) in to_rwp_paged_iv() argument
175 assert(fobj->ops == &ops_rwp_paged_iv); in to_rwp_paged_iv()
177 return container_of(fobj, struct fobj_rwp_paged_iv, fobj); in to_rwp_paged_iv()
180 static TEE_Result rwp_paged_iv_load_page(struct fobj *fobj, in rwp_paged_iv_load_page() argument
183 struct fobj_rwp_paged_iv *rwp = to_rwp_paged_iv(fobj); in rwp_paged_iv_load_page()
187 assert(refcount_val(&fobj->refc)); in rwp_paged_iv_load_page()
188 assert(page_idx < fobj->num_pages); in rwp_paged_iv_load_page()
194 static TEE_Result rwp_paged_iv_save_page(struct fobj *fobj, in rwp_paged_iv_save_page() argument
197 struct fobj_rwp_paged_iv *rwp = to_rwp_paged_iv(fobj); in rwp_paged_iv_save_page()
201 assert(page_idx < fobj->num_pages); in rwp_paged_iv_save_page()
203 if (!refcount_val(&fobj->refc)) { in rwp_paged_iv_save_page()
208 assert(TAILQ_EMPTY(&fobj->regions)); in rwp_paged_iv_save_page()
216 static void rwp_paged_iv_free(struct fobj *fobj) in rwp_paged_iv_free() argument
218 struct fobj_rwp_paged_iv *rwp = to_rwp_paged_iv(fobj); in rwp_paged_iv_free()
224 fobj_uninit(fobj); in rwp_paged_iv_free()
229 static vaddr_t rwp_paged_iv_get_iv_vaddr(struct fobj *fobj, in rwp_paged_iv_get_iv_vaddr() argument
232 struct fobj_rwp_paged_iv *rwp = to_rwp_paged_iv(fobj); in rwp_paged_iv_get_iv_vaddr()
235 assert(page_idx < fobj->num_pages); in rwp_paged_iv_get_iv_vaddr()
252 static struct fobj *rwp_unpaged_iv_alloc(unsigned int num_pages) in rwp_unpaged_iv_alloc()
274 fobj_init(&rwp->fobj, &ops_rwp_unpaged_iv, num_pages); in rwp_unpaged_iv_alloc()
276 return &rwp->fobj; in rwp_unpaged_iv_alloc()
285 static struct fobj_rwp_unpaged_iv *to_rwp_unpaged_iv(struct fobj *fobj) in to_rwp_unpaged_iv() argument
287 assert(fobj->ops == &ops_rwp_unpaged_iv); in to_rwp_unpaged_iv()
289 return container_of(fobj, struct fobj_rwp_unpaged_iv, fobj); in to_rwp_unpaged_iv()
292 static TEE_Result rwp_unpaged_iv_load_page(struct fobj *fobj, in rwp_unpaged_iv_load_page() argument
295 struct fobj_rwp_unpaged_iv *rwp = to_rwp_unpaged_iv(fobj); in rwp_unpaged_iv_load_page()
298 assert(refcount_val(&fobj->refc)); in rwp_unpaged_iv_load_page()
299 assert(page_idx < fobj->num_pages); in rwp_unpaged_iv_load_page()
305 static TEE_Result rwp_unpaged_iv_save_page(struct fobj *fobj, in rwp_unpaged_iv_save_page() argument
309 struct fobj_rwp_unpaged_iv *rwp = to_rwp_unpaged_iv(fobj); in rwp_unpaged_iv_save_page()
312 assert(page_idx < fobj->num_pages); in rwp_unpaged_iv_save_page()
314 if (!refcount_val(&fobj->refc)) { in rwp_unpaged_iv_save_page()
319 assert(TAILQ_EMPTY(&fobj->regions)); in rwp_unpaged_iv_save_page()
327 static void rwp_unpaged_iv_free(struct fobj *fobj) in rwp_unpaged_iv_free() argument
335 rwp = to_rwp_unpaged_iv(fobj); in rwp_unpaged_iv_free()
340 fobj_uninit(fobj); in rwp_unpaged_iv_free()
360 struct fobj *fobj = NULL; in rwp_init() local
387 fobj = rwp_unpaged_iv_alloc(num_fobj_pages); in rwp_init()
388 if (!fobj) in rwp_init()
391 rwp_state_base = (void *)tee_pager_init_iv_region(fobj); in rwp_init()
402 struct fobj *fobj_rw_paged_alloc(unsigned int num_pages) in fobj_rw_paged_alloc()
415 struct fobj fobj; member
425 fobj_init(&rop->fobj, ops, num_pages); in rop_init()
428 struct fobj *fobj_ro_paged_alloc(unsigned int num_pages, void *hashes, in fobj_ro_paged_alloc()
441 return &rop->fobj; in fobj_ro_paged_alloc()
444 static struct fobj_rop *to_rop(struct fobj *fobj) in to_rop() argument
446 assert(fobj->ops == &ops_ro_paged); in to_rop()
448 return container_of(fobj, struct fobj_rop, fobj); in to_rop()
453 fobj_uninit(&rop->fobj); in rop_uninit()
458 static void rop_free(struct fobj *fobj) in rop_free() argument
460 struct fobj_rop *rop = to_rop(fobj); in rop_free()
472 assert(refcount_val(&rop->fobj.refc)); in rop_load_page_helper()
473 assert(page_idx < rop->fobj.num_pages); in rop_load_page_helper()
479 static TEE_Result rop_load_page(struct fobj *fobj, unsigned int page_idx, in rop_load_page() argument
482 return rop_load_page_helper(to_rop(fobj), page_idx, va); in rop_load_page()
486 static TEE_Result rop_save_page(struct fobj *fobj __unused, in rop_save_page()
562 unsigned int npg = rrp->rop.fobj.num_pages; in init_rels()
591 struct fobj *fobj_ro_reloc_paged_alloc(unsigned int num_pages, void *hashes, in fobj_ro_reloc_paged_alloc()
623 return &rrp->rop.fobj; in fobj_ro_reloc_paged_alloc()
626 static struct fobj_ro_reloc_paged *to_rrp(struct fobj *fobj) in to_rrp() argument
628 assert(fobj->ops == &ops_ro_reloc_paged); in to_rrp()
630 return container_of(fobj, struct fobj_ro_reloc_paged, rop.fobj); in to_rrp()
633 static void rrp_free(struct fobj *fobj) in rrp_free() argument
635 struct fobj_ro_reloc_paged *rrp = to_rrp(fobj); in rrp_free()
641 static TEE_Result rrp_load_page(struct fobj *fobj, unsigned int page_idx, in rrp_load_page() argument
644 struct fobj_ro_reloc_paged *rrp = to_rrp(fobj); in rrp_load_page()
655 for (n = page_idx + 1; n < fobj->num_pages; n++) { in rrp_load_page()
685 struct fobj *fobj_locked_paged_alloc(unsigned int num_pages) in fobj_locked_paged_alloc()
687 struct fobj *f = NULL; in fobj_locked_paged_alloc()
700 static void lop_free(struct fobj *fobj) in lop_free() argument
702 assert(fobj->ops == &ops_locked_paged); in lop_free()
703 fobj_uninit(fobj); in lop_free()
704 free(fobj); in lop_free()
707 static TEE_Result lop_load_page(struct fobj *fobj __maybe_unused, in lop_load_page()
711 assert(fobj->ops == &ops_locked_paged); in lop_load_page()
712 assert(refcount_val(&fobj->refc)); in lop_load_page()
713 assert(page_idx < fobj->num_pages); in lop_load_page()
721 static TEE_Result lop_save_page(struct fobj *fobj __unused, in lop_save_page()
745 struct fobj fobj; member
750 struct fobj *fobj_sec_mem_alloc(unsigned int num_pages) in fobj_sec_mem_alloc()
771 f->fobj.ops = &ops_sec_mem; in fobj_sec_mem_alloc()
772 f->fobj.num_pages = num_pages; in fobj_sec_mem_alloc()
773 refcount_set(&f->fobj.refc, 1); in fobj_sec_mem_alloc()
775 return &f->fobj; in fobj_sec_mem_alloc()
783 static struct fobj_sec_mem *to_sec_mem(struct fobj *fobj) in to_sec_mem() argument
785 assert(fobj->ops == &ops_sec_mem); in to_sec_mem()
787 return container_of(fobj, struct fobj_sec_mem, fobj); in to_sec_mem()
790 static void sec_mem_free(struct fobj *fobj) in sec_mem_free() argument
792 struct fobj_sec_mem *f = to_sec_mem(fobj); in sec_mem_free()
794 assert(!refcount_val(&fobj->refc)); in sec_mem_free()
799 static paddr_t sec_mem_get_pa(struct fobj *fobj, unsigned int page_idx) in sec_mem_get_pa() argument
801 struct fobj_sec_mem *f = to_sec_mem(fobj); in sec_mem_get_pa()
803 assert(refcount_val(&fobj->refc)); in sec_mem_get_pa()
804 assert(page_idx < fobj->num_pages); in sec_mem_get_pa()