Lines Matching refs:mobj

33 	struct mobj mobj;  member
49 struct mobj mobj; member
79 static struct mobj_reg_shm *to_mobj_reg_shm(struct mobj *mobj);
81 static TEE_Result mobj_reg_shm_get_pa(struct mobj *mobj, size_t offst, in mobj_reg_shm_get_pa() argument
84 struct mobj_reg_shm *mobj_reg_shm = to_mobj_reg_shm(mobj); in mobj_reg_shm_get_pa()
91 if (offst >= mobj->size) in mobj_reg_shm_get_pa()
112 static size_t mobj_reg_shm_get_phys_offs(struct mobj *mobj, in mobj_reg_shm_get_phys_offs() argument
115 assert(granule >= mobj->phys_granule); in mobj_reg_shm_get_phys_offs()
116 return to_mobj_reg_shm(mobj)->page_offset; in mobj_reg_shm_get_phys_offs()
119 static void *mobj_reg_shm_get_va(struct mobj *mobj, size_t offst, size_t len) in mobj_reg_shm_get_va() argument
121 struct mobj_reg_shm *mrs = to_mobj_reg_shm(mobj); in mobj_reg_shm_get_va()
123 if (!mrs->mm || !mobj_check_offset_and_len(mobj, offst, len)) in mobj_reg_shm_get_va()
152 static void mobj_reg_shm_free(struct mobj *mobj) in mobj_reg_shm_free() argument
154 struct mobj_reg_shm *r = to_mobj_reg_shm(mobj); in mobj_reg_shm_free()
184 static TEE_Result mobj_reg_shm_get_mem_type(struct mobj *mobj __unused, in mobj_reg_shm_get_mem_type()
195 static TEE_Result mobj_reg_shm_inc_map(struct mobj *mobj) in mobj_reg_shm_inc_map() argument
198 struct mobj_reg_shm *r = to_mobj_reg_shm(mobj); in mobj_reg_shm_inc_map()
222 sz = ROUNDUP(mobj->size + r->page_offset, SMALL_PAGE_SIZE); in mobj_reg_shm_inc_map()
246 static TEE_Result mobj_reg_shm_dec_map(struct mobj *mobj) in mobj_reg_shm_dec_map() argument
248 struct mobj_reg_shm *r = to_mobj_reg_shm(mobj); in mobj_reg_shm_dec_map()
271 static bool mobj_reg_shm_matches(struct mobj *mobj, enum buf_is_attr attr);
273 static uint64_t mobj_reg_shm_get_cookie(struct mobj *mobj) in mobj_reg_shm_get_cookie() argument
275 return to_mobj_reg_shm(mobj)->cookie; in mobj_reg_shm_get_cookie()
304 static bool mobj_reg_shm_matches(struct mobj *mobj __maybe_unused, in mobj_reg_shm_matches()
307 assert(mobj->ops == &mobj_reg_shm_ops); in mobj_reg_shm_matches()
312 static struct mobj_reg_shm *to_mobj_reg_shm(struct mobj *mobj) in to_mobj_reg_shm() argument
314 assert(mobj->ops == &mobj_reg_shm_ops); in to_mobj_reg_shm()
315 return container_of(mobj, struct mobj_reg_shm, mobj); in to_mobj_reg_shm()
323 for (n = 0; n < r->mobj.size / SMALL_PAGE_SIZE; n++) in check_reg_shm_conflict()
337 res = check_reg_shm_conflict(r, m->pa, m->mobj.size); in check_protmem_conflict()
345 struct mobj *mobj_reg_shm_alloc(paddr_t *pages, size_t num_pages, in mobj_reg_shm_alloc()
364 mobj_reg_shm->mobj.ops = &mobj_reg_shm_ops; in mobj_reg_shm_alloc()
365 mobj_reg_shm->mobj.size = num_pages * SMALL_PAGE_SIZE - page_offset; in mobj_reg_shm_alloc()
366 mobj_reg_shm->mobj.phys_granule = SMALL_PAGE_SIZE; in mobj_reg_shm_alloc()
367 refcount_set(&mobj_reg_shm->mobj.refc, 1); in mobj_reg_shm_alloc()
393 return &mobj_reg_shm->mobj; in mobj_reg_shm_alloc()
399 void mobj_reg_shm_unguard(struct mobj *mobj) in mobj_reg_shm_unguard() argument
403 to_mobj_reg_shm(mobj)->guarded = false; in mobj_reg_shm_unguard()
429 struct mobj *mobj_reg_shm_get_by_cookie(uint64_t cookie) in mobj_reg_shm_get_by_cookie()
434 struct mobj *m = NULL; in mobj_reg_shm_get_by_cookie()
439 m = mobj_get(&rs->mobj); in mobj_reg_shm_get_by_cookie()
444 m = mobj_get(&rm->mobj); in mobj_reg_shm_get_by_cookie()
475 mobj_put(&r->mobj); in mobj_reg_shm_release_by_cookie()
510 struct mobj *mobj_mapped_shm_alloc(paddr_t *pages, size_t num_pages, in mobj_mapped_shm_alloc()
513 struct mobj *mobj = mobj_reg_shm_alloc(pages, num_pages, in mobj_mapped_shm_alloc() local
516 if (!mobj) in mobj_mapped_shm_alloc()
519 if (mobj_inc_map(mobj)) { in mobj_mapped_shm_alloc()
520 mobj_put(mobj); in mobj_mapped_shm_alloc()
524 return mobj; in mobj_mapped_shm_alloc()
548 static struct mobj_protmem *to_mobj_protmem(struct mobj *mobj);
566 if ((m->pa | m->mobj.size) & SMALL_PAGE_MASK) in protect_mem()
570 m->use_case, m->pa, m->mobj.size); in protect_mem()
572 return plat_set_protmem_range(m->use_case, m->pa, m->mobj.size); in protect_mem()
578 m->use_case, m->pa, m->mobj.size); in restore_mem()
581 m->mobj.size); in restore_mem()
584 static TEE_Result mobj_protmem_get_pa(struct mobj *mobj, size_t offs, in mobj_protmem_get_pa() argument
587 struct mobj_protmem *m = to_mobj_protmem(mobj); in mobj_protmem_get_pa()
593 if (offs >= mobj->size) in mobj_protmem_get_pa()
607 static TEE_Result mobj_protmem_get_mem_type(struct mobj *mobj __unused, in mobj_protmem_get_mem_type()
618 static bool mobj_protmem_matches(struct mobj *mobj __unused, in mobj_protmem_matches()
636 static void mobj_protmem_free(struct mobj *mobj) in mobj_protmem_free() argument
638 struct mobj_protmem *r = to_mobj_protmem(mobj); in mobj_protmem_free()
657 static uint64_t mobj_protmem_get_cookie(struct mobj *mobj) in mobj_protmem_get_cookie() argument
659 return to_mobj_protmem(mobj)->cookie; in mobj_protmem_get_cookie()
662 static TEE_Result mobj_protmem_inc_map(struct mobj *mobj __maybe_unused) in mobj_protmem_inc_map()
664 assert(to_mobj_protmem(mobj)); in mobj_protmem_inc_map()
668 static TEE_Result mobj_protmem_dec_map(struct mobj *mobj __maybe_unused) in mobj_protmem_dec_map()
670 assert(to_mobj_protmem(mobj)); in mobj_protmem_dec_map()
685 static struct mobj_protmem *to_mobj_protmem(struct mobj *mobj) in to_mobj_protmem() argument
687 assert(mobj->ops == &mobj_protmem_ops); in to_mobj_protmem()
688 return container_of(mobj, struct mobj_protmem, mobj); in to_mobj_protmem()
691 struct mobj *mobj_protmem_alloc(paddr_t pa, paddr_size_t size, uint64_t cookie, in mobj_protmem_alloc()
706 m->mobj.ops = &mobj_protmem_ops; in mobj_protmem_alloc()
708 m->mobj.size = size; in mobj_protmem_alloc()
709 m->mobj.phys_granule = SMALL_PAGE_SIZE; in mobj_protmem_alloc()
710 refcount_set(&m->mobj.refc, 1); in mobj_protmem_alloc()
731 return &m->mobj; in mobj_protmem_alloc()
757 mobj_put(&rm->mobj); in mobj_protmem_release_by_cookie()
801 if (core_is_buffer_inside(pa, sz, m->pa, m->mobj.size)) in protmem_find_by_pa_unlocked()
807 struct mobj *mobj_protmem_get_by_pa(paddr_t pa, paddr_size_t size) in mobj_protmem_get_by_pa()
810 struct mobj *mobj = NULL; in mobj_protmem_get_by_pa() local
817 mobj = mobj_get(&rm->mobj); in mobj_protmem_get_by_pa()
821 return mobj; in mobj_protmem_get_by_pa()