Lines Matching refs:binh
112 struct bin_handle *binh = ptr; in bin_close() local
114 if (binh) { in bin_close()
115 if (binh->op && binh->h) in bin_close()
116 binh->op->close(binh->h); in bin_close()
117 file_put(binh->f); in bin_close()
119 free(binh); in bin_close()
129 struct bin_handle *binh = NULL; in ldelf_syscall_open_bin() local
156 binh = calloc(1, sizeof(*binh)); in ldelf_syscall_open_bin()
157 if (!binh) in ldelf_syscall_open_bin()
161 SCATTERED_ARRAY_FOREACH(binh->op, ta_stores, in ldelf_syscall_open_bin()
164 (void *)bb_uuid, binh->op->description); in ldelf_syscall_open_bin()
166 res = binh->op->open(bb_uuid, &binh->h); in ldelf_syscall_open_bin()
173 SCATTERED_ARRAY_FOREACH(binh->op, sp_stores, in ldelf_syscall_open_bin()
176 (void *)bb_uuid, binh->op->description); in ldelf_syscall_open_bin()
178 res = binh->op->open(bb_uuid, &binh->h); in ldelf_syscall_open_bin()
191 res = binh->op->get_size(binh->h, &binh->size_bytes); in ldelf_syscall_open_bin()
194 res = binh->op->get_tag(binh->h, tag, &tag_len); in ldelf_syscall_open_bin()
197 binh->f = file_get_by_tag(tag, tag_len); in ldelf_syscall_open_bin()
198 if (!binh->f) in ldelf_syscall_open_bin()
201 h = handle_get(&sys_ctx->db, binh); in ldelf_syscall_open_bin()
215 bin_close(binh); in ldelf_syscall_open_bin()
224 struct bin_handle *binh = NULL; in ldelf_syscall_close_bin() local
229 binh = handle_put(&sys_ctx->db, handle); in ldelf_syscall_close_bin()
230 if (!binh) in ldelf_syscall_close_bin()
233 if (binh->offs_bytes < binh->size_bytes) in ldelf_syscall_close_bin()
234 res = binh->op->read(binh->h, NULL, NULL, in ldelf_syscall_close_bin()
235 binh->size_bytes - binh->offs_bytes); in ldelf_syscall_close_bin()
237 bin_close(binh); in ldelf_syscall_close_bin()
247 static TEE_Result binh_copy_to(struct bin_handle *binh, vaddr_t va_core, in binh_copy_to() argument
254 if (offs_bytes < binh->offs_bytes) in binh_copy_to()
260 if (offs_bytes > binh->offs_bytes) { in binh_copy_to()
261 res = binh->op->read(binh->h, NULL, NULL, in binh_copy_to()
262 offs_bytes - binh->offs_bytes); in binh_copy_to()
265 binh->offs_bytes = offs_bytes; in binh_copy_to()
268 if (next_offs > binh->size_bytes) { in binh_copy_to()
269 size_t rb = binh->size_bytes - binh->offs_bytes; in binh_copy_to()
271 res = binh->op->read(binh->h, (void *)va_core, in binh_copy_to()
283 binh->offs_bytes = binh->size_bytes; in binh_copy_to()
285 res = binh->op->read(binh->h, (void *)va_core, in binh_copy_to()
289 binh->offs_bytes = next_offs; in binh_copy_to()
304 struct bin_handle *binh = NULL; in ldelf_syscall_map_bin() local
325 binh = handle_lookup(&sys_ctx->db, handle); in ldelf_syscall_map_bin()
326 if (!binh) in ldelf_syscall_map_bin()
356 if (!file_trylock(binh->f)) { in ldelf_syscall_map_bin()
364 file_lock(binh->f); in ldelf_syscall_map_bin()
368 fs = file_find_slice(binh->f, offs_pages); in ldelf_syscall_map_bin()
383 mobj = mobj_with_fobj_alloc(fs->fobj, binh->f, in ldelf_syscall_map_bin()
405 file = binh->f; in ldelf_syscall_map_bin()
421 res = binh_copy_to(binh, va_copy, 0, offs_bytes, num_bytes); in ldelf_syscall_map_bin()
436 res = file_add_slice(binh->f, f, offs_pages); in ldelf_syscall_map_bin()
446 file_unlock(binh->f); in ldelf_syscall_map_bin()
461 file_unlock(binh->f); in ldelf_syscall_map_bin()
473 struct bin_handle *binh = NULL; in ldelf_syscall_copy_from_bin() local
485 binh = handle_lookup(&sys_ctx->db, handle); in ldelf_syscall_copy_from_bin()
486 if (!binh) in ldelf_syscall_copy_from_bin()
489 return binh_copy_to(binh, 0, (vaddr_t)dst, offs, num_bytes); in ldelf_syscall_copy_from_bin()