Zephyr Project API 3.7.0
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 */
55 int (*read)(struct llext_loader *ldr, void *out, size_t len);
56
68 int (*seek)(struct llext_loader *ldr, size_t pos);
69
80 void *(*peek)(struct llext_loader *ldr, size_t pos);
81
83 elf_ehdr_t hdr;
85 elf_shdr_t *sect_hdrs;
86 bool sect_hdrs_on_heap;
87 struct llext_elf_sect_map *sect_map;
88 uint32_t sect_cnt;
90};
91
93static inline int llext_read(struct llext_loader *l, void *buf, size_t len)
94{
95 return l->read(l, buf, len);
96}
97
98static inline int llext_seek(struct llext_loader *l, size_t pos)
99{
100 return l->seek(l, pos);
101}
102
103static inline void *llext_peek(struct llext_loader *l, size_t pos)
104{
105 if (l->peek) {
106 return l->peek(l, pos);
107 }
108
109 return NULL;
110}
111/* @endcond */
112
117#ifdef __cplusplus
118}
119#endif
120
121#endif /* ZEPHYR_LLEXT_LOADER_H */
Data structures and constants defined in the ELF specification.
@ LLEXT_MEM_COUNT
Number of regions managed by LLEXT.
Definition llext.h:54
Support for linkable loadable extensions.
static int pos
Definition printk.c:11
__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:68
int(* read)(struct llext_loader *ldr, void *out, size_t len)
Function to read (copy) from the loader.
Definition loader.h:55
void *(* peek)(struct llext_loader *ldr, size_t pos)
Optional function to peek at an absolute location in the ELF.
Definition loader.h:80