ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
emu_host_io_internal.h
Go to the documentation of this file.
1
11
12#pragma once
13
14#include <stdarg.h>
15#include <stddef.h>
16#include <stdint.h>
17#include <sys/types.h>
18
19#include "ra8_attributes.h"
20
29
36
38typedef struct {
39 ssize_t (*read_fn)(int fd, void* buf, size_t count);
40 ssize_t (*write_fn)(int fd, const void* buf, size_t count);
41 ssize_t (*pread_fn)(int fd, void* buf, size_t count, off_t offset);
42 ssize_t (*pwrite_fn)(int fd, const void* buf, size_t count, off_t off);
44
46typedef struct {
47 int fd;
48 int64_t size;
50
52typedef struct {
53 int fd;
54 char final[512];
55 char temp[544];
57
71RA8_PRIV void priv_emu_io_configure(int out_fd, int err_fd, const emu_io_ops_t* ops);
73RA8_PRIV [[nodiscard]] emu_io_result_t priv_emu_io_read_exact(int fd, void* buf, size_t count);
75RA8_PRIV [[nodiscard]] emu_io_result_t
76priv_emu_io_write_exact(int fd, const void* buf, size_t count);
78RA8_PRIV [[nodiscard]] emu_io_result_t
79priv_emu_io_pread_exact(int fd, void* buf, size_t count, off_t offset);
81RA8_PRIV [[nodiscard]] emu_io_result_t
82priv_emu_io_pwrite_exact(int fd, const void* buf, size_t count, off_t offset);
84RA8_PRIV [[nodiscard]] emu_io_result_t priv_emu_io_out_text(const char* text);
86RA8_PRIV [[nodiscard]] emu_io_result_t priv_emu_io_err_text(const char* text);
88RA8_PRIV [[nodiscard]] emu_io_result_t priv_emu_io_err_bytes(const void* bytes, size_t length);
90[[gnu::format(printf, 1, 2)]] RA8_PRIV [[nodiscard]] emu_io_result_t
91priv_emu_io_outf(const char* format, ...);
93[[gnu::format(printf, 1, 2)]] RA8_PRIV [[nodiscard]] emu_io_result_t
94priv_emu_io_errf(const char* format, ...);
96RA8_PRIV [[nodiscard]] emu_io_result_t priv_emu_io_file_text(int fd, const char* text);
98RA8_PRIV [[nodiscard]] emu_io_result_t priv_emu_io_file_char(int fd, char value);
100[[gnu::format(printf, 2, 3)]] RA8_PRIV [[nodiscard]] emu_io_result_t
101priv_emu_io_filef(int fd, const char* format, ...);
103RA8_PRIV [[nodiscard]] emu_io_result_t priv_emu_io_open_read(const char* path, emu_io_file_t* file);
107RA8_PRIV [[nodiscard]] emu_io_result_t priv_emu_io_txn_begin(const char* path, emu_io_txn_t* txn);
emu_io_result_t priv_emu_io_err_text(const char *text)
Write a NUL-terminated literal to the injected error descriptor.
emu_io_status_t
Result status for an emulator host-I/O operation.
@ k_emu_io_eof
Input ended before the requested byte count.
@ k_emu_io_ok
The complete operation succeeded.
@ k_emu_io_error
A host syscall failed; os_error carries errno.
@ k_emu_io_invalid
A pointer, descriptor, size, or path was invalid.
@ k_emu_io_truncated
Formatted text exceeded the bounded scratch buffer.
emu_io_result_t priv_emu_io_out_text(const char *text)
Write a NUL-terminated literal to the injected output descriptor.
emu_io_result_t priv_emu_io_write_exact(int fd, const void *buf, size_t count)
Write exactly count sequential bytes or report fault progress.
emu_io_result_t priv_emu_io_errf(const char *format,...)
Format bounded text and write it to the injected error descriptor.
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_pwrite_exact(int fd, const void *buf, size_t count, off_t offset)
Write exactly count bytes at offset without changing the cursor.
emu_io_result_t priv_emu_io_outf(const char *format,...)
Format bounded text and write it to the injected output descriptor.
emu_io_result_t priv_emu_io_filef(int fd, const char *format,...)
Format bounded text and write it to an explicit raw descriptor.
emu_io_result_t priv_emu_io_read_exact(int fd, void *buf, size_t count)
Read exactly count sequential bytes or report EOF/fault progress.
void priv_emu_io_configure(int out_fd, int err_fd, const emu_io_ops_t *ops)
Inject process output descriptors and optional raw transfer hooks.
emu_io_result_t priv_emu_io_err_bytes(const void *bytes, size_t length)
Write an exact non-NUL-terminated byte fragment to the error sink.
void priv_emu_io_txn_abort(emu_io_txn_t *txn)
Close and unlink an active sibling transaction without publication.
emu_io_result_t priv_emu_io_file_char(int fd, char value)
Write one byte to an explicit raw descriptor.
emu_io_result_t priv_emu_io_txn_commit(emu_io_txn_t *txn)
Sync, close, and atomically rename an active sibling transaction.
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_file_text(int fd, const char *text)
Write a NUL-terminated literal to an explicit raw descriptor.
emu_io_result_t priv_emu_io_txn_begin(const char *path, emu_io_txn_t *txn)
Create a sibling temporary output for failure-atomic publication.
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.
Annotation-attribute framework macros for ra8-firmware.
#define RA8_PRIV
Module-private helper: shared across TUs but only inside one library.
Raw descriptor plus its stat-derived byte length.
int64_t size
Non-negative regular-file length.
int fd
Owned descriptor, or -1 when closed.
Injectable raw operations used by the exact-transfer loops.
ssize_t(* read_fn)(int fd, void *buf, size_t count)
read().
ssize_t(* write_fn)(int fd, const void *buf, size_t count)
write().
ssize_t(* pwrite_fn)(int fd, const void *buf, size_t count, off_t off)
pwrite().
ssize_t(* pread_fn)(int fd, void *buf, size_t count, off_t offset)
pread().
Complete, caller-visible result of a raw host-I/O operation.
size_t transferred
Bytes transferred before completion/failure.
int os_error
Captured errno for k_emu_io_error, else zero.
emu_io_status_t status
Semantic completion status.
Sibling temporary file used for failure-atomic publication.
char temp[544]
Sibling mkstemp template / active temporary path.
int fd
Owned temporary descriptor, or -1 when inactive.