DCPU16_REG__NUM
};
+/* we call this sort of function for emitting a readable message */
+typedef void (dcpu16_msg_cb_t)(unsigned int, char *, ...);
+
+/* we may emit any of these types of messages */
+enum dcpu16_msg_type {
+ DCPU16_MSG_ERROR = 0,
+ DCPU16_MSG_INFO,
+ DCPU16_MSG_DEBUG
+};
+
+/* update the default message handler */
+dcpu16_msg_cb_t *dcpu16_msg_set_default(dcpu16_msg_cb_t *);
+
+/* hardware devices may want to call this directly, without a core context */
+extern dcpu16_msg_cb_t *dcpu16_msg_;
+
/* a self-contained dcpu16 core */
struct dcpu16 {
- void (*warn_cb_)(char *fmt, ...);
- void (*trace_cb_)(char *fmt, ...);
+ dcpu16_msg_cb_t *msg_cb_; /* callback to invoke for messages */
struct dcpu16_acct_cb *cb_table_; /* list of callbacks to invoke for certain events */
size_t cb_table_entries_; /* callback list maintenance */
struct dcpu16_hw_ctl_cmd *ctl_cmd;
};
+/* update a message handler */
+dcpu16_msg_cb_t *dcpu16_msg_set(struct dcpu16 *, dcpu16_msg_cb_t *);
+
/* instantiate a new core */
struct dcpu16 *dcpu16_new(void);
/* consume a cycle */
void dcpu16_cycle_inc(struct dcpu16 *, unsigned int);
-/* register callbacks to handle warning and debug messages, default is writing to stderr, may be set to null */
-void dcpu16_warn_cb_set(void (*)(char *, ...));
-void dcpu16_trace_cb_set(void (*)(char *, ...));
-
#endif /* DCPU16_H_3XXIQQG2 */