From 028aa48b9851300e038b44ca4f854343d8af7d83 Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Date: Fri, 12 Jan 2024 15:25:13 +0100 Subject: [PATCH] Add ovnievents tool to dump event definition The tool dumps the list of events in Markdown, suitable to replace the documentation page for the emulation events. --- src/emu/CMakeLists.txt | 3 ++ src/emu/ovnievents.c | 73 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 src/emu/ovnievents.c diff --git a/src/emu/CMakeLists.txt b/src/emu/CMakeLists.txt index 8c81a97..a042b24 100644 --- a/src/emu/CMakeLists.txt +++ b/src/emu/CMakeLists.txt @@ -76,6 +76,9 @@ target_link_libraries(ovnisort emu parson-static ovni-static) add_executable(ovnitop ovnitop.c) target_link_libraries(ovnitop emu parson-static ovni-static) +add_executable(ovnievents ovnievents.c) +target_link_libraries(ovnievents emu parson-static ovni-static) + # For ovniver we need to ensure we use the RUNPATH not the RPATH. include(CheckLinkerFlag) check_linker_flag(C "-Wl,--enable-new-dtags" SUPPORT_ENABLE_NEW_DTAGS) diff --git a/src/emu/ovnievents.c b/src/emu/ovnievents.c new file mode 100644 index 0000000..3e1f14f --- /dev/null +++ b/src/emu/ovnievents.c @@ -0,0 +1,73 @@ +/* Copyright (c) 2023-2024 Barcelona Supercomputing Center (BSC) + * SPDX-License-Identifier: GPL-3.0-or-later */ + +#include +#include +#include +#include +#include "common.h" +#include "emu_ev.h" +#include "model.h" +#include "models.h" +#include "model_evspec.h" +#include "ev_spec.h" +#include "ovni.h" +#include "player.h" +#include "stream.h" +#include "trace.h" + +static void +print_event(struct model_spec *spec, long i) +{ + struct ev_decl *evdecl = &spec->evlist[i]; + struct ev_spec *evspec = &spec->evspec->alloc[i]; + + const char *name = evspec->mcv; + + printf("
%s
\n", name, name, evdecl->signature); + printf("
%s
\n", evdecl->description); +} + +static void +print_model(struct model_spec *spec) +{ + printf("\n"); + printf("## Model %s\n", spec->name); + printf("\n"); + printf("List of events for the model *%s* with identifier **`%c`** at version `%s`:\n", + spec->name, spec->model, spec->version); + + printf("
\n"); + for (long j = 0; j < spec->evspec->nevents; j++) + print_event(spec, j); + printf("
\n"); +} + +int +main(void) +{ + progname_set("ovnievents"); + + struct model model; + model_init(&model); + + /* Register all the models */ + if (models_register(&model) != 0) { + err("failed to register models"); + return -1; + } + + printf("# Emulator events\n"); + printf("\n"); + printf("This is a exhaustive list of the events recognized by the emulator.\n"); + printf("Built on %s.\n", __DATE__); + + for (int i = 0; i < 256; i++) { + if (!model.registered[i]) + continue; + + print_model(model.spec[i]); + } + + return 0; +}