Ken Van Hoeylandt 03a6285328
Add kernel memory functions & other memory-related changes (#590)
New Features

- Added policy-based memory allocation APIs with capability flags and optional alignment: `memory_alloc_with_policy`, `memory_realloc_with_policy`, `memory_calloc_with_policy`, and `memory_free`.
- Switched heap memory reporting to `memory_print_stats`.

Bug Fixes

- Improved allocation robustness with capability fallback behavior.
- Added overflow-safe handling for aligned zero-initialized allocations.
- Tightened const-correctness for generated device-tree device arrays.

Tests

- Added unit tests for default policy, alignment, zero-initialization, realloc preservation, freeing, and memory stats reporting.
2026-07-26 22:59:18 +02:00

66 lines
1.2 KiB
C

// Default headers
#include <tactility/device.h>
#include <tactility/dts.h>
#include <tactility/module.h>
// DTS headers
#include <test_include.h>
static const root_config_dt root_config = {
"Test Model"
};
static struct Device root = {
.address = 0,
.name = "/",
.config = &root_config,
.flags = DEVICE_FLAG_DTS,
.parent = NULL,
.internal = NULL
};
static const generic_device_config_dt test_device_config = {
0,
42,
"hello"
};
static struct Device test_device = {
.address = 0,
.name = "test-device",
.config = &test_device_config,
.flags = DEVICE_FLAG_DTS,
.parent = &root,
.internal = NULL
};
static const bool_device_config_dt bool_test_device_config = {
true,
false,
true,
true,
true
};
static struct Device bool_test_device = {
.address = 0,
.name = "bool-test-device",
.config = &bool_test_device_config,
.flags = DEVICE_FLAG_DTS,
.parent = &root,
.internal = NULL
};
const struct DtsDevice dts_devices[] = {
{ &root, "test,root", DTS_DEVICE_STATUS_OKAY },
{ &test_device, "test,generic-device", DTS_DEVICE_STATUS_OKAY },
{ &bool_test_device, "test,bool-device", DTS_DEVICE_STATUS_OKAY },
DTS_DEVICE_TERMINATOR
};
extern struct Module data_module;
struct Module* const dts_modules[] = {
&data_module,
NULL
};