ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_decomp_limits.h
Go to the documentation of this file.
1
65#pragma once
66
67#include <stddef.h>
68#include <stdint.h>
69
70#include "ra8_err.h"
71
72#ifdef __cplusplus
73extern "C" {
74#endif
75
105
129typedef struct {
131 uint32_t max_ratio;
133 uint32_t max_entries;
134 uint32_t max_iterations;
135 uint8_t max_depth;
137
169typedef struct {
171 uint64_t out_bytes;
172 uint64_t in_bytes;
173 uint32_t entries;
174 uint32_t iters;
175 uint8_t depth;
177
199
225 const ra8_decomp_limits_t* limits);
226
256[[nodiscard]] ra8_err_t
257ra8_decomp_budget_charge_output(ra8_decomp_budget_t* b, uint64_t in_total, uint64_t out_delta);
258
284
311
337
356
388[[nodiscard]] ra8_err_t
389ra8_decomp_check_declared(const ra8_decomp_limits_t* limits, uint64_t comp_size, uint64_t out_size);
390
403typedef size_t (*ra8_decomp_read_fn)(void* ctx, uint64_t offset, void* buf, size_t len);
404
425[[nodiscard]] ra8_err_t
426ra8_decomp_zip_entry_preflight(ra8_decomp_read_fn read, void* ctx, uint64_t archive_size);
427
428#ifdef __cplusplus
429}
430#endif
size_t(* ra8_decomp_read_fn)(void *ctx, uint64_t offset, void *buf, size_t len)
Positioned reader used by bounded container preflights.
ra8_err_t ra8_decomp_budget_charge_output(ra8_decomp_budget_t *b, uint64_t in_total, uint64_t out_delta)
Charge decompressed output against the cap and ratio bounds.
ra8_decomp_limits_t ra8_decomp_limits_default(void)
The owner-approved default decompression policy.
ra8_decomp_defaults_t
Owner-approved default values for ra8_decomp_limits_t.
@ k_ra8_decomp_def_max_iters
Loop iteration budget (1 Mi).
@ k_ra8_decomp_def_ratio_grace
Additive ratio grace (64 KiB).
@ k_ra8_decomp_def_max_depth
Stacked decode-layer cap.
@ k_ra8_decomp_def_max_entries
Per-archive entry cap.
@ k_ra8_decomp_def_output_bytes
Per-unit output cap (64 MiB).
@ k_ra8_decomp_def_max_ratio
Output:input ratio bound.
ra8_err_t ra8_decomp_check_declared(const ra8_decomp_limits_t *limits, uint64_t comp_size, uint64_t out_size)
Header-level check of a member's declared sizes against a policy.
ra8_err_t ra8_decomp_zip_entry_preflight(ra8_decomp_read_fn read, void *ctx, uint64_t archive_size)
Reject an over-cap ZIP from its EOCD before directory allocation.
ra8_err_t ra8_decomp_budget_enter(ra8_decomp_budget_t *b)
Enter one stacked decode layer (nesting-depth guard).
void ra8_decomp_budget_leave(ra8_decomp_budget_t *b)
Leave one stacked decode layer (balances ra8_decomp_budget_enter).
ra8_err_t ra8_decomp_budget_charge_entry(ra8_decomp_budget_t *b)
Charge one enumerated archive entry against the entry cap.
ra8_err_t ra8_decomp_budget_charge_iter(ra8_decomp_budget_t *b)
Charge one decode-loop turn against the iteration budget.
ra8_err_t ra8_decomp_budget_init(ra8_decomp_budget_t *b, const ra8_decomp_limits_t *limits)
Bind a budget to a policy (or the default policy) and zero it.
Error Code Definitions for ra8-firmware.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Definition ra8_err.h:546
Running consumption tracker charged by a decoder against its policy.
uint32_t iters
Decode-loop turns charged so far.
uint64_t out_bytes
Decompressed bytes produced so far.
uint64_t in_bytes
Compressed bytes consumed so far.
uint32_t entries
Archive entries enumerated so far.
ra8_decomp_limits_t limits
Policy in force for this budget.
uint8_t depth
Current stacked decode-layer depth.
One decompression policy: the five resource bounds decoders enforce.
uint32_t max_ratio
Output:input ratio bound (multiplier).
uint32_t ratio_grace_bytes
Additive output grace before ratio applies.
uint32_t max_iterations
Per-decode-loop iteration budget.
uint32_t max_entries
Per-archive enumerated-entry cap.
uint8_t max_depth
Stacked decode-layer (nesting) cap.
uint64_t max_output_bytes
Per-decode-unit output cap, bytes.