OpenCores
no use no use 1/1 no use no use
[or1ksim #18] Add status callback
by Unknown on Feb 4, 2005
Not available!
Hi,

This adds a reg_sim_stat function, which registers a callback to be called when
the info command is given at the sim command prompt.

ChangeLog:
* Add status callback.

nog.
-------------- next part --------------
--- sim-cmd.c 2005-02-04 11:15:29.000000000 +0100
+++ ../or1ksim-ac/sim-cmd.c 2005-02-04 11:21:39.000000000 +0100
@@ -67,6 +67,30 @@
#include "atahost.h"
#include "ps2kbd.h"

+struct sim_stat {
+ void (*stat_func)(void *dat);
+ void *dat;
+ struct sim_stat *next;
+};
+
+static struct sim_stat *sim_stats = NULL;
+
+/* Registers a status printing callback */
+void reg_sim_stat(void (*stat_func)(void *dat), void *dat)
+{
+ struct sim_stat *new = malloc(sizeof(struct sim_stat));
+
+ if(!new) {
+ fprintf(stderr, "reg_sim_stat: Out-of-memory\n");
+ exit(1);
+ }
+
+ new->stat_func = stat_func;
+ new->dat = dat;
+ new->next = sim_stats;
+ sim_stats = new;
+}
+
extern char *disassembled;
static void debugmem( oraddr_t from, oraddr_t to )
{
@@ -386,6 +420,8 @@

static int sim_cmd_info(int argc, char **argv) /* configuration info */
{
+ struct sim_stat *cur_stat = sim_stats;
+
/* Display info about various modules */
sprs_status();
PRINTF ("\n");
@@ -405,6 +441,12 @@
if (config.ngpios) gpio_status();
if (config.natas) ata_status();
kbd_info();
+
+ while(cur_stat) {
+ cur_stat->stat_func(cur_stat->dat);
+ cur_stat = cur_stat->next;
+ }
+
return 0;
}

--- sim-config.h 2005-02-04 11:15:36.000000000 +0100
+++ ../or1ksim-ac/sim-config.h 2005-02-04 11:07:40.000000000 +0100
@@ -375,6 +353,9 @@
/* Registers a new reset hook, called when sim_reset below is called */
void reg_sim_reset(void (*reset_hook)(void *), void *dat);

+/* Registers a status printing callback */
+void reg_sim_stat(void (*stat_func)(void *dat), void *dat);
+
union param_val {
char *str_val;
int int_val;
no use no use 1/1 no use no use
© copyright 1999-2026 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.