Zephyr Project API 4.1.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
loader.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2023 Intel Corporation
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef ZEPHYR_LLEXT_LOADER_H
8#define ZEPHYR_LLEXT_LOADER_H
9
10#include <zephyr/llext/elf.h>
11#include <stddef.h>
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
29#include <zephyr/llext/llext.h>
30
32struct llext_elf_sect_map; /* defined in llext_priv.h */
72
88 int (*prepare)(struct llext_loader *ldr);
89
102 int (*read)(struct llext_loader *ldr, void *out, size_t len);
103
115 int (*seek)(struct llext_loader *ldr, size_t pos);
116
127 void *(*peek)(struct llext_loader *ldr, size_t pos);
128
134 void (*finalize)(struct llext_loader *ldr);
135
140
142 elf_ehdr_t hdr;
144 struct llext_elf_sect_map *sect_map;
146};
147
149static inline int llext_prepare(struct llext_loader *l)
150{
151 if (l->prepare) {
152 return l->prepare(l);
153 }
154
155 return 0;
156}
157
158static inline int llext_read(struct llext_loader *l, void *buf, size_t len)
159{
160 return l->read(l, buf, len);
161}
162
163static inline int llext_seek(struct llext_loader *l, size_t pos)
164{
165 return l->seek(l, pos);
166}
167
168static inline void *llext_peek(struct llext_loader *l, size_t pos)
169{
170 if (l->peek) {
171 return l->peek(l, pos);
172 }
173
174 return NULL;
175}
176
177static inline void llext_finalize(struct llext_loader *l)
178{
179 if (l->finalize) {
180 l->finalize(l);
181 }
182}
183/* @endcond */
184
189#ifdef __cplusplus
190}
191#endif
192
193#endif /* ZEPHYR_LLEXT_LOADER_H */
@ LLEXT_MEM_COUNT
Number of regions managed by LLEXT.
Definition llext.h:57
llext_storage_type
Storage type for the ELF data to be loaded.
Definition loader.h:48
@ LLEXT_STORAGE_TEMPORARY
ELF data is only available during llext_load(); even if the loader supports directly accessing the me...
Definition loader.h:55
@ LLEXT_STORAGE_WRITABLE
ELF data is stored in a writable memory buffer that is guaranteed to be always accessible for as long...
Definition loader.h:70
@ LLEXT_STORAGE_PERSISTENT
ELF data is stored in a read-only buffer that is guaranteed to be always accessible for as long as th...
Definition loader.h:62
#define NULL
Definition iar_missing_defs.h:20
Data structures and constants defined in the ELF specification.
Support for linkable loadable extensions.
ELF Header(64-bit)
Definition elf.h:105
Section Header(64-bit)
Definition elf.h:177
Linkable loadable extension loader context.
Definition loader.h:80
enum llext_storage_type storage
Storage type of the underlying data accessed by this loader.
Definition loader.h:139
int(* seek)(struct llext_loader *ldr, size_t pos)
Function to seek to a new absolute location in the stream.
Definition loader.h:115
int(* read)(struct llext_loader *ldr, void *out, size_t len)
Function to read (copy) from the loader.
Definition loader.h:102
int(* prepare)(struct llext_loader *ldr)
Optional function to prepare the loader for loading extension.
Definition loader.h:88
void(* finalize)(struct llext_loader *ldr)
Optional function to clean after the extension has been loaded or error occurred.
Definition loader.h:134
void *(* peek)(struct llext_loader *ldr, size_t pos)
Optional function to peek at an absolute location in the ELF.
Definition loader.h:127