Lines Matching refs:fobj

52 	struct fobj fobj;  member
57 struct fobj fobj; member
68 static void fobj_init(struct fobj *fobj, const struct fobj_ops *ops, in fobj_init() argument
71 fobj->ops = ops; in fobj_init()
72 fobj->num_pages = num_pages; in fobj_init()
73 refcount_set(&fobj->refc, 1); in fobj_init()
74 TAILQ_INIT(&fobj->regions); in fobj_init()
77 static void fobj_uninit(struct fobj *fobj) in fobj_uninit() argument
79 assert(!refcount_val(&fobj->refc)); in fobj_uninit()
80 assert(TAILQ_EMPTY(&fobj->regions)); in fobj_uninit()
81 tee_pager_invalidate_fobj(fobj); in fobj_uninit()
142 static struct fobj *rwp_paged_iv_alloc(unsigned int num_pages) in rwp_paged_iv_alloc()
165 fobj_init(&rwp->fobj, &ops_rwp_paged_iv, num_pages); in rwp_paged_iv_alloc()
167 return &rwp->fobj; in rwp_paged_iv_alloc()
175 static struct fobj_rwp_paged_iv *to_rwp_paged_iv(struct fobj *fobj) in to_rwp_paged_iv() argument
177 assert(fobj->ops == &ops_rwp_paged_iv); in to_rwp_paged_iv()
179 return container_of(fobj, struct fobj_rwp_paged_iv, fobj); in to_rwp_paged_iv()
182 static TEE_Result rwp_paged_iv_load_page(struct fobj *fobj, in rwp_paged_iv_load_page() argument
185 struct fobj_rwp_paged_iv *rwp = to_rwp_paged_iv(fobj); in rwp_paged_iv_load_page()
189 assert(refcount_val(&fobj->refc)); in rwp_paged_iv_load_page()
190 assert(page_idx < fobj->num_pages); in rwp_paged_iv_load_page()
196 static TEE_Result rwp_paged_iv_save_page(struct fobj *fobj, in rwp_paged_iv_save_page() argument
199 struct fobj_rwp_paged_iv *rwp = to_rwp_paged_iv(fobj); in rwp_paged_iv_save_page()
203 assert(page_idx < fobj->num_pages); in rwp_paged_iv_save_page()
205 if (!refcount_val(&fobj->refc)) { in rwp_paged_iv_save_page()
210 assert(TAILQ_EMPTY(&fobj->regions)); in rwp_paged_iv_save_page()
218 static void rwp_paged_iv_free(struct fobj *fobj) in rwp_paged_iv_free() argument
220 struct fobj_rwp_paged_iv *rwp = to_rwp_paged_iv(fobj); in rwp_paged_iv_free()
226 fobj_uninit(fobj); in rwp_paged_iv_free()
231 static vaddr_t rwp_paged_iv_get_iv_vaddr(struct fobj *fobj, in rwp_paged_iv_get_iv_vaddr() argument
234 struct fobj_rwp_paged_iv *rwp = to_rwp_paged_iv(fobj); in rwp_paged_iv_get_iv_vaddr()
237 assert(page_idx < fobj->num_pages); in rwp_paged_iv_get_iv_vaddr()
254 static struct fobj *rwp_unpaged_iv_alloc(unsigned int num_pages) in rwp_unpaged_iv_alloc()
277 fobj_init(&rwp->fobj, &ops_rwp_unpaged_iv, num_pages); in rwp_unpaged_iv_alloc()
279 return &rwp->fobj; in rwp_unpaged_iv_alloc()
288 static struct fobj_rwp_unpaged_iv *to_rwp_unpaged_iv(struct fobj *fobj) in to_rwp_unpaged_iv() argument
290 assert(fobj->ops == &ops_rwp_unpaged_iv); in to_rwp_unpaged_iv()
292 return container_of(fobj, struct fobj_rwp_unpaged_iv, fobj); in to_rwp_unpaged_iv()
295 static TEE_Result rwp_unpaged_iv_load_page(struct fobj *fobj, in rwp_unpaged_iv_load_page() argument
298 struct fobj_rwp_unpaged_iv *rwp = to_rwp_unpaged_iv(fobj); in rwp_unpaged_iv_load_page()
301 assert(refcount_val(&fobj->refc)); in rwp_unpaged_iv_load_page()
302 assert(page_idx < fobj->num_pages); in rwp_unpaged_iv_load_page()
308 static TEE_Result rwp_unpaged_iv_save_page(struct fobj *fobj, in rwp_unpaged_iv_save_page() argument
312 struct fobj_rwp_unpaged_iv *rwp = to_rwp_unpaged_iv(fobj); in rwp_unpaged_iv_save_page()
315 assert(page_idx < fobj->num_pages); in rwp_unpaged_iv_save_page()
317 if (!refcount_val(&fobj->refc)) { in rwp_unpaged_iv_save_page()
322 assert(TAILQ_EMPTY(&fobj->regions)); in rwp_unpaged_iv_save_page()
330 static void rwp_unpaged_iv_free(struct fobj *fobj) in rwp_unpaged_iv_free() argument
338 rwp = to_rwp_unpaged_iv(fobj); in rwp_unpaged_iv_free()
343 fobj_uninit(fobj); in rwp_unpaged_iv_free()
364 struct fobj *fobj = NULL; in rwp_init() local
391 fobj = rwp_unpaged_iv_alloc(num_fobj_pages); in rwp_init()
392 if (!fobj) in rwp_init()
395 rwp_state_base = (void *)tee_pager_init_iv_region(fobj); in rwp_init()
406 struct fobj *fobj_rw_paged_alloc(unsigned int num_pages) in fobj_rw_paged_alloc()
419 struct fobj fobj; member
429 fobj_init(&rop->fobj, ops, num_pages); in rop_init()
432 struct fobj *fobj_ro_paged_alloc(unsigned int num_pages, void *hashes, in fobj_ro_paged_alloc()
445 return &rop->fobj; in fobj_ro_paged_alloc()
448 static struct fobj_rop *to_rop(struct fobj *fobj) in to_rop() argument
450 assert(fobj->ops == &ops_ro_paged); in to_rop()
452 return container_of(fobj, struct fobj_rop, fobj); in to_rop()
457 fobj_uninit(&rop->fobj); in rop_uninit()
462 static void rop_free(struct fobj *fobj) in rop_free() argument
464 struct fobj_rop *rop = to_rop(fobj); in rop_free()
476 assert(refcount_val(&rop->fobj.refc)); in rop_load_page_helper()
477 assert(page_idx < rop->fobj.num_pages); in rop_load_page_helper()
483 static TEE_Result rop_load_page(struct fobj *fobj, unsigned int page_idx, in rop_load_page() argument
486 return rop_load_page_helper(to_rop(fobj), page_idx, va); in rop_load_page()
490 static TEE_Result rop_save_page(struct fobj *fobj __unused, in rop_save_page()
566 unsigned int npg = rrp->rop.fobj.num_pages; in init_rels()
595 struct fobj *fobj_ro_reloc_paged_alloc(unsigned int num_pages, void *hashes, in fobj_ro_reloc_paged_alloc()
627 return &rrp->rop.fobj; in fobj_ro_reloc_paged_alloc()
630 static struct fobj_ro_reloc_paged *to_rrp(struct fobj *fobj) in to_rrp() argument
632 assert(fobj->ops == &ops_ro_reloc_paged); in to_rrp()
634 return container_of(fobj, struct fobj_ro_reloc_paged, rop.fobj); in to_rrp()
637 static void rrp_free(struct fobj *fobj) in rrp_free() argument
639 struct fobj_ro_reloc_paged *rrp = to_rrp(fobj); in rrp_free()
645 static TEE_Result rrp_load_page(struct fobj *fobj, unsigned int page_idx, in rrp_load_page() argument
648 struct fobj_ro_reloc_paged *rrp = to_rrp(fobj); in rrp_load_page()
659 for (n = page_idx + 1; n < fobj->num_pages; n++) { in rrp_load_page()
689 struct fobj *fobj_locked_paged_alloc(unsigned int num_pages) in fobj_locked_paged_alloc()
691 struct fobj *f = NULL; in fobj_locked_paged_alloc()
704 static void lop_free(struct fobj *fobj) in lop_free() argument
706 assert(fobj->ops == &ops_locked_paged); in lop_free()
707 fobj_uninit(fobj); in lop_free()
708 free(fobj); in lop_free()
711 static TEE_Result lop_load_page(struct fobj *fobj __maybe_unused, in lop_load_page()
715 assert(fobj->ops == &ops_locked_paged); in lop_load_page()
716 assert(refcount_val(&fobj->refc)); in lop_load_page()
717 assert(page_idx < fobj->num_pages); in lop_load_page()
725 static TEE_Result lop_save_page(struct fobj *fobj __unused, in lop_save_page()
749 struct fobj fobj; member
754 struct fobj *fobj_sec_mem_alloc(unsigned int num_pages) in fobj_sec_mem_alloc()
776 f->fobj.ops = &ops_sec_mem; in fobj_sec_mem_alloc()
777 f->fobj.num_pages = num_pages; in fobj_sec_mem_alloc()
778 refcount_set(&f->fobj.refc, 1); in fobj_sec_mem_alloc()
780 return &f->fobj; in fobj_sec_mem_alloc()
788 static struct fobj_sec_mem *to_sec_mem(struct fobj *fobj) in to_sec_mem() argument
790 assert(fobj->ops == &ops_sec_mem); in to_sec_mem()
792 return container_of(fobj, struct fobj_sec_mem, fobj); in to_sec_mem()
795 static void sec_mem_free(struct fobj *fobj) in sec_mem_free() argument
797 struct fobj_sec_mem *f = to_sec_mem(fobj); in sec_mem_free()
799 assert(!refcount_val(&fobj->refc)); in sec_mem_free()
804 static paddr_t sec_mem_get_pa(struct fobj *fobj, unsigned int page_idx) in sec_mem_get_pa() argument
806 struct fobj_sec_mem *f = to_sec_mem(fobj); in sec_mem_get_pa()
808 assert(refcount_val(&fobj->refc)); in sec_mem_get_pa()
809 assert(page_idx < fobj->num_pages); in sec_mem_get_pa()