Zephyr API Documentation 4.0.0-rc2
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 */
50 int (*prepare)(struct llext_loader *ldr);
51
64 int (*read)(struct llext_loader *ldr, void *out, size_t len);
65
77 int (*seek)(struct llext_loader *ldr, size_t pos);
78
89 void *(*peek)(struct llext_loader *ldr, size_t pos);
90
96 void (*finalize)(struct llext_loader *ldr);
97
99 elf_ehdr_t hdr;
101 elf_shdr_t *sect_hdrs;
102 bool sect_hdrs_on_heap;
103 struct llext_elf_sect_map *sect_map;
104 uint32_t sect_cnt;
106};
107
109static inline int llext_prepare(struct llext_loader *l)
110{
111 if (l->prepare) {
112 return l->prepare(l);
113 }
114
115 return 0;
116}
117
118static inline int llext_read(struct llext_loader *l, void *buf, size_t len)
119{
120 return l->read(l, buf, len);
121}
122
123static inline int llext_seek(struct llext_loader *l, size_t pos)
124{
125 return l->seek(l, pos);
126}
127
128static inline void *llext_peek(struct llext_loader *l, size_t pos)
129{
130 if (l->peek) {
131 return l->peek(l, pos);
132 }
133
134 return NULL;
135}
136
137static inline void llext_finalize(struct llext_loader *l)
138{
139 if (l->finalize) {
140 l->finalize(l);
141 }
142}
143/* @endcond */
144
149#ifdef __cplusplus
150}
151#endif
152
153#endif /* ZEPHYR_LLEXT_LOADER_H */
@ LLEXT_MEM_COUNT
Number of regions managed by LLEXT.
Definition llext.h:57
Data structures and constants defined in the ELF specification.
Support for linkable loadable extensions.
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
ELF Header(64-bit)
Definition elf.h:105
Section Header(64-bit)
Definition elf.h:177
Linkable loadable extension loader context.
Definition loader.h:42
int(* seek)(struct llext_loader *ldr, size_t pos)
Function to seek to a new absolute location in the stream.
Definition loader.h:77
int(* read)(struct llext_loader *ldr, void *out, size_t len)
Function to read (copy) from the loader.
Definition loader.h:64
int(* prepare)(struct llext_loader *ldr)
Optional function to prepare the loader for loading extension.
Definition loader.h:50
void(* finalize)(struct llext_loader *ldr)
Optional function to clean after the extension has been loaded or error occurred.
Definition loader.h:96
void *(* peek)(struct llext_loader *ldr, size_t pos)
Optional function to peek at an absolute location in the ELF.
Definition loader.h:89