aboutsummaryrefslogtreecommitdiff
path: root/src/bus/simple_bus.c
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2025-08-09 16:06:32 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2025-08-09 16:06:32 +0300
commitaba90a3a6f6c1caee28aaf3dadebb4daba5b5761 (patch)
tree082fc1f5c374f4a0417f345507cee58c23d3a2ad /src/bus/simple_bus.c
parentbc920e9de94e884597214da9c20525605cfce6d6 (diff)
downloadgran-aba90a3a6f6c1caee28aaf3dadebb4daba5b5761.tar.gz
gran-aba90a3a6f6c1caee28aaf3dadebb4daba5b5761.zip
use newer conts
Diffstat (limited to 'src/bus/simple_bus.c')
-rw-r--r--src/bus/simple_bus.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/bus/simple_bus.c b/src/bus/simple_bus.c
index 1932419..e1e9a88 100644
--- a/src/bus/simple_bus.c
+++ b/src/bus/simple_bus.c
@@ -3,7 +3,6 @@
#include <stdbool.h>
#include <gran/bus/simple_bus.h>
-#include <gran/vec.h>
struct bus_region {
uint64_t addr;
@@ -11,9 +10,13 @@ struct bus_region {
struct component *component;
};
+#define VEC_NAME regions
+#define VEC_TYPE struct bus_region
+#include <conts/vec.h>
+
struct simple_bus {
struct component component;
- struct vec regions;
+ struct regions regions;
struct component *send;
struct packet pkt;
@@ -22,8 +25,7 @@ struct simple_bus {
static struct bus_region *find_bus_region(struct simple_bus *bus, uint64_t addr)
{
- foreach_vec(i, bus->regions) {
- struct bus_region *r = vec_at(&bus->regions, i);
+ foreach(regions, r, &bus->regions) {
if (addr >= r->addr && addr < (r->addr + r->size))
return r;
}
@@ -70,7 +72,7 @@ static stat simple_bus_receive(struct simple_bus *bus, struct component *from, s
static void simple_bus_destroy(struct simple_bus *bus)
{
- vec_destroy(&bus->regions);
+ regions_destroy(&bus->regions);
free(bus);
}
@@ -84,7 +86,7 @@ struct component *create_simple_bus()
bus->component.clock = (clock_callback)simple_bus_clock;
bus->component.destroy = (destroy_callback)simple_bus_destroy;
- bus->regions = vec_create(sizeof(struct bus_region));
+ bus->regions = regions_create(0);
return (struct component *)bus;
}
@@ -112,6 +114,6 @@ stat simple_bus_add(struct component *bus, struct component *component,
.size = size
};
- vect_append(struct bus_region, b->regions, &new);
+ regions_append(&b->regions, new);
return OK;
}