mirror of
https://gitea.tendokyu.moe/Hay1tsme/segatools.git
synced 2024-11-11 20:37:09 +01:00
jvs/jvs-bus.c: Add JVS bus definitions
This commit is contained in:
parent
f5f553bd57
commit
e8537f4b52
30
jvs/jvs-bus.c
Normal file
30
jvs/jvs-bus.c
Normal file
@ -0,0 +1,30 @@
|
||||
#include <assert.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "jvs/jvs-bus.h"
|
||||
|
||||
void jvs_bus_transact(
|
||||
struct jvs_node *head,
|
||||
const void *bytes,
|
||||
size_t nbytes,
|
||||
struct iobuf *resp)
|
||||
{
|
||||
struct jvs_node *node;
|
||||
|
||||
assert(bytes != NULL);
|
||||
assert(resp != NULL);
|
||||
|
||||
for (node = head ; node != NULL ; node = node->next) {
|
||||
node->transact(node, bytes, nbytes, resp);
|
||||
}
|
||||
}
|
||||
|
||||
bool jvs_node_sense(struct jvs_node *node)
|
||||
{
|
||||
if (node != NULL) {
|
||||
return node->sense(node);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
24
jvs/jvs-bus.h
Normal file
24
jvs/jvs-bus.h
Normal file
@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "hook/iobuf.h"
|
||||
|
||||
struct jvs_node {
|
||||
struct jvs_node *next;
|
||||
void (*transact)(
|
||||
struct jvs_node *node,
|
||||
const void *bytes,
|
||||
size_t nbytes,
|
||||
struct iobuf *resp);
|
||||
bool (*sense)(struct jvs_node *node);
|
||||
};
|
||||
|
||||
void jvs_bus_transact(
|
||||
struct jvs_node *head,
|
||||
const void *bytes,
|
||||
size_t nbytes,
|
||||
struct iobuf *resp);
|
||||
|
||||
bool jvs_node_sense(struct jvs_node *node);
|
@ -7,5 +7,7 @@ jvs_lib = static_library(
|
||||
capnhook.get_variable('hook_dep'),
|
||||
],
|
||||
sources : [
|
||||
'jvs-bus.c',
|
||||
'jvs-bus.h',
|
||||
],
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user