
#ifndef ISS_MEMCHECKER_EVENTS_H
#define ISS_MEMCHECKER_EVENTS_H

#include <stdint.h>

enum IssMemcheckerEvents {
        ISS_MCEVENT_NONE               = 0x00000000,
        ISS_MCEVENT_RESET              = 0x00000001,
        ISS_MCEVENT_MEM_DECLARE        = 0x00000002,
        ISS_MCEVENT_PRELOAD            = 0x00000003,
			       
        ISS_MCEVENT_READ_START         = 0x00000004,
        ISS_MCEVENT_READ_DONE          = 0x00000005,
        ISS_MCEVENT_WRITE_START        = 0x00000006,
        ISS_MCEVENT_WRITE_DONE         = 0x00000007,
        ISS_MCEVENT_LL_START           = 0x00000008,
        ISS_MCEVENT_LL_DONE            = 0x00000009,
        ISS_MCEVENT_SC_START           = 0x0000000a,
        ISS_MCEVENT_SC_DONE            = 0x0000000b,
        ISS_MCEVENT_SC_FAILED          = 0x0000000c,

        ISS_MCEVENT_TYPE_NONE          = 0x00000000,
        ISS_MCEVENT_TYPE_GLOBAL        = 0x00000010,
        ISS_MCEVENT_TYPE_GLOBAL_RO     = 0x00000020,
        ISS_MCEVENT_TYPE_ALLOC         = 0x00000030,
        ISS_MCEVENT_TYPE_FREE          = 0x00000040,
        ISS_MCEVENT_TYPE_SPECIAL       = 0x00000050,

        ISS_MCEVENT_TYPE_MASK          = 0x00000070,

        ISS_MCEVENT_LOCK_ENABLE        = 0x00000080,
        ISS_MCEVENT_LOCK_DISABLE       = 0x00000100,

        ISS_MCEVENT_LOCK_MASK          = 0x00000180,

        ISS_MCEVENT_STACK_ENABLE       = 0x00000200,
        ISS_MCEVENT_STACK_DISABLE      = 0x00000400,

        ISS_MCEVENT_STACK_MASK         = 0x00000600,

        ISS_MCEVENT_VALUE_INVALID      = 0x00001000,
        ISS_MCEVENT_VALUE_UNDEFINED    = 0x00002000,
        ISS_MCEVENT_VALUE_INIT         = 0x00003000,

        ISS_MCEVENT_VALUE_MASK         = 0x00003000,

        ISS_MCEVENT_REG_CHANGE         = 0x00004000,

        ISS_MCEVENT_TIMESTAMP          = 0x00008000,
};

struct IssMemcheckerEventPacket
{
  uint64_t _magic;
  uint16_t _type;
  uint16_t _cpu_id;
  uint64_t _cycles;

  union {
    struct {
      uint8_t _regs_count;
      uint8_t _pc_reg;
      uint8_t _sp_reg;
    } _reset;

    struct {
      uint64_t _addr;
      uint64_t _data;
      uint8_t _be;		//< byte enable mask
    } _access;

    struct {
      uint64_t _addr;
      uint64_t _size;
    } _state;

    struct {
      uint32_t _id;
      uint64_t _data;
    } _reg;
  };
};

#endif

