2024-06-04 16:32:36 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2024 Arduino SA
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef ZEPHYR_SUBSYS_LLEXT_PRIV_H_
|
|
|
|
#define ZEPHYR_SUBSYS_LLEXT_PRIV_H_
|
|
|
|
|
|
|
|
#include <zephyr/kernel.h>
|
|
|
|
#include <zephyr/llext/llext.h>
|
|
|
|
|
2024-06-18 22:15:34 +08:00
|
|
|
struct llext_elf_sect_map {
|
|
|
|
enum llext_mem mem_idx;
|
|
|
|
size_t offset;
|
|
|
|
};
|
|
|
|
|
2024-06-04 16:32:36 +08:00
|
|
|
/*
|
|
|
|
* Memory management (llext_mem.c)
|
|
|
|
*/
|
|
|
|
|
|
|
|
int llext_copy_strings(struct llext_loader *ldr, struct llext *ext);
|
2024-06-28 23:20:34 +08:00
|
|
|
int llext_copy_regions(struct llext_loader *ldr, struct llext *ext);
|
|
|
|
void llext_free_regions(struct llext *ext);
|
2024-08-29 11:44:31 +08:00
|
|
|
void llext_adjust_mmu_permissions(struct llext *ext);
|
2024-06-04 16:32:36 +08:00
|
|
|
|
|
|
|
static inline void *llext_alloc(size_t bytes)
|
|
|
|
{
|
|
|
|
extern struct k_heap llext_heap;
|
|
|
|
|
|
|
|
return k_heap_alloc(&llext_heap, bytes, K_NO_WAIT);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void *llext_aligned_alloc(size_t align, size_t bytes)
|
|
|
|
{
|
|
|
|
extern struct k_heap llext_heap;
|
|
|
|
|
|
|
|
return k_heap_aligned_alloc(&llext_heap, align, bytes, K_NO_WAIT);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void llext_free(void *ptr)
|
|
|
|
{
|
|
|
|
extern struct k_heap llext_heap;
|
|
|
|
|
|
|
|
k_heap_free(&llext_heap, ptr);
|
|
|
|
}
|
|
|
|
|
2024-06-05 17:02:46 +08:00
|
|
|
/*
|
|
|
|
* ELF parsing (llext_load.c)
|
|
|
|
*/
|
|
|
|
|
|
|
|
int do_llext_load(struct llext_loader *ldr, struct llext *ext,
|
2024-08-29 18:47:25 +08:00
|
|
|
const struct llext_load_param *ldr_parm);
|
2024-06-05 17:02:46 +08:00
|
|
|
|
|
|
|
static inline const char *llext_string(struct llext_loader *ldr, struct llext *ext,
|
|
|
|
enum llext_mem mem_idx, unsigned int idx)
|
|
|
|
{
|
|
|
|
return (char *)ext->mem[mem_idx] + idx;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Relocation (llext_link.c)
|
|
|
|
*/
|
|
|
|
|
2024-09-27 19:59:03 +08:00
|
|
|
int llext_link(struct llext_loader *ldr, struct llext *ext,
|
|
|
|
const struct llext_load_param *ldr_parm);
|
2024-08-23 16:45:17 +08:00
|
|
|
void llext_dependency_remove_all(struct llext *ext);
|
2024-06-05 17:02:46 +08:00
|
|
|
|
2024-06-04 16:32:36 +08:00
|
|
|
#endif /* ZEPHYR_SUBSYS_LLEXT_PRIV_H_ */
|