Program Listing for File minimon.h

Return to documentation for file (rcsw/tool/minimon.h)

#pragma once

/*******************************************************************************
 * Includes
 ******************************************************************************/
#include "rcsw/rcsw.h"

/*******************************************************************************
 * Constant Definitions
 ******************************************************************************/
#define MINIMON_CMD_MAX_ARGS  4 /* max number of arguments to a command */
#define MINIMON_MAX_CMDS 20
#define MINIMON_CMD_MAX_NAMELEN 5

enum minimon_param_type {
  ekMINIMON_PARAM_UINT32,
  ekMINIMON_PARAM_STR,
};

enum minimon_help_type {
  ekMINIMON_HELP_SHORT,
  ekMINIMON_HELP_LONG
};

/*******************************************************************************
 * Structure Definitions
 ******************************************************************************/
struct minimon_irq_callbacks {
  void (*clear_all)(void);
  void (*mask_all)(void);
};

struct minimon_stream_callbacks {
  int (*putchar)(int c);
  int (*getchar)(void);
};

struct minimon_params {
  struct minimon_irq_callbacks irqcb;

  struct minimon_stream_callbacks stream1;

  struct minimon_cmd* cmds;

  size_t n_cmds;

  bool include_builtin;

  bool help_on_start;
};

union minimon_cmd_arg {
  uint32_t num;
  char* s;
};

struct minimon_cmd_param {
  const char* name;
  enum minimon_param_type type;
  const char* short_help;
  const char* long_help;
  bool_t required;
  union minimon_cmd_arg dflt;
};

struct minimon_cmd {
  const char* name;

  const char* alias;

  const char* help;

  void (*hook)(const char* cmdname, ...);

  struct minimon_cmd_param params[MINIMON_CMD_MAX_ARGS];
};

struct minimon {
  struct minimon_stream_callbacks stream0;
  struct minimon_stream_callbacks stream1;
  struct minimon_cmd cmds[MINIMON_MAX_CMDS];
  struct minimon_irq_callbacks irqcb;
  bool_t help_on_start;
};

/*******************************************************************************
 * Type Definitions
 ******************************************************************************/
typedef void (*vfp_t)(void);

/******************************************************************************
 * API Functions
 *****************************************************************************/
BEGIN_C_DECLS

RCSW_API void minimon_init(const struct minimon_params* params);

RCSW_API void minimon_start(void) RCSW_DEAD;

END_C_DECLS