38 .required_bytes = required,
39 .supplied_bytes = supplied,
40 .os_error = os_error};
72 if (source ==
nullptr) {
80 const emu_elf_source_t ready = {.fd = file.fd, .length = (uint64_t)file.size};
87 if ((source ==
nullptr) || (source->
fd < 0)) {
90 const uint64_t length = source->
length;
101 size_t required_bytes,
103 size_t supplied_bytes,
106 if ((source ==
nullptr) || (source->
fd < 0) || (scratch ==
nullptr) || (view ==
nullptr) ||
107 (required_bytes == 0U)) {
110 if ((offset > source->
length) || ((uint64_t)required_bytes > (source->
length - offset))) {
113 if (required_bytes > supplied_bytes) {
122 (
emu_elf_view_t){.bytes = (
const uint8_t*)scratch, .length = required_bytes, .offset = offset};
ELF32 image services for the board emulator (load / symbols / vectors).
emu_elf_io_status_t
Status for bounded raw-descriptor ELF source operations.
@ k_emu_elf_io_eof
The source ended during an exact read.
@ k_emu_elf_io_error
A host operation failed.
@ k_emu_elf_io_capacity
Caller scratch is smaller than required.
@ k_emu_elf_io_ok
The complete operation succeeded.
@ k_emu_elf_io_invalid
A pointer, descriptor, range, or path was bad.
emu_elf_io_result_t priv_emu_elf_read(const emu_elf_source_t *source, uint64_t offset, size_t required_bytes, void *scratch, size_t supplied_bytes, emu_elf_view_t *view)
Read one exact source range into caller-owned bounded scratch.
emu_elf_io_result_t priv_emu_elf_source_open(const char *path, emu_elf_source_t *source)
Open one regular ELF source without reading or allocating its bytes.
static RA8_INTERNAL emu_elf_io_result_t internal_elf_result(emu_elf_io_status_t status, uint64_t required, uint64_t supplied, int os_error)
Construct one fully initialized ELF I/O result.
emu_elf_io_result_t priv_emu_elf_source_close(emu_elf_source_t *source)
Close and invalidate one independently owned ELF source.
static RA8_INTERNAL emu_elf_io_result_t internal_from_host(emu_io_result_t io, uint64_t required, uint64_t supplied)
Translate a raw host-I/O result without losing progress metadata.
Private raw-descriptor ELF source operations.
Bounded raw-descriptor I/O seam for the RA8 emulator.
@ k_emu_io_eof
Input ended before the requested byte count.
@ k_emu_io_ok
The complete operation succeeded.
@ k_emu_io_invalid
A pointer, descriptor, size, or path was invalid.
emu_io_result_t priv_emu_io_pread_exact(int fd, void *buf, size_t count, off_t offset)
Read exactly count bytes at offset without changing the cursor.
emu_io_result_t priv_emu_io_close(emu_io_file_t *file)
Close and invalidate an owned raw file descriptor.
emu_io_result_t priv_emu_io_open_read(const char *path, emu_io_file_t *file)
Open and stat a regular file for bounded raw reading.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Exact result for source open and bounded view acquisition.
One independently owned immutable raw-descriptor ELF source.
int fd
Owned regular-file descriptor, or -1 when closed.
uint64_t length
Stat-derived parsing bound.
Transient view into caller-owned bounded scratch.
Raw descriptor plus its stat-derived byte length.
Complete, caller-visible result of a raw host-I/O operation.
emu_io_status_t status
Semantic completion status.