Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / sam / include / tracemod.h
/*
* ========== Copyright Header Begin ==========================================
*
* OpenSPARC T2 Processor File: tracemod.h
* Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
*
* The above named program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License version 2 as published by the Free Software Foundation.
*
* The above named program is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this work; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
* ========== Copyright Header End ============================================
*/
/*
* Copyright (C) 2001 Sun Microsystems, Inc.
* All rights reserved.
*/
#ifndef _TRACEMOD_H
#define _TRACEMOD_H
#pragma ident "@(#)1.33 04/12/21 tracemod.h"
typedef void* TM_OPAQUE_DATA;
/*
* This file contains some definitions/declarations
* regarding BLAZE LOADABLE MODULES / SHARED OBJECTS
* (presumaby TRACING MODULES).
*/
void mod_setdefault (char * subdir);
void mod_addpath (char * path);
void * mod_dlopen (char * pathp, char * name, int flags);
// Loadable module types
enum {
TM_TYPE_LDM = 0x44,
TM_TYPE_EXT_CPU = 0x55,
TM_TYPE_EXT_DEVICE = 0x66,
TM_TYPE_EXT_SIM = 0x77,
TM_TYPE_EXT_UNKNOWN = 0x100
};
typedef struct ldm_t Ldm;
typedef Ldm tracemod_t;
typedef uint64_t blaze_cycle_t;
typedef void (*fn_event_cycle)(void *cb_data, blaze_cycle_t interval);
//
// Tracing globals
//
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
extern uint64_t tm_time_target;
extern uint64_t tm_time_interval;
enum { /// memory operation types
TM_CONST_BADMEM = 0,
TM_CONST_READ = 5,
TM_CONST_WRITE = 6,
TM_CONST_RDWR = 7,
TM_CONST_PREFETCH0 = 8,
TM_CONST_PREFETCH1 = 9,
TM_CONST_PREFETCH2 = 10,
TM_CONST_PREFETCH3 = 11,
TM_CONST_PREFETCH4 = 12,
TM_CONST_FLUSH = 13,
TM_CONST_TSB_ACC = 14,
TM_CONST_PREFETCH16 = 16,
TM_CONST_PREFETCH17 = 17,
TM_CONST_PREFETCH18 = 18,
TM_CONST_PREFETCH19 = 19,
TM_CONST_PREFETCH20 = 20,
TM_CONST_PREFETCH21 = 21,
TM_CONST_PREFETCH22 = 22,
TM_CONST_PREFETCH23 = 23
};
/////////////////////////////////////////
//
// The uniform record to pass data from BLAZE to TRACER
//
typedef struct cpuinfo_t
{
// common stuff
uint8_t type;
uint8_t cpuid;
uint16_t icontext_p;
uint16_t dcontext_p;
uint16_t icontext_s;
uint16_t dcontext_s;
uint16_t pstate;
uint16_t tl; // trap level
uint64_t pc_va;
uint64_t npc_va;
uint64_t pc_pa;
// Instruction specific
uint64_t ea_va;
uint64_t ea_pa;
uint32_t iw;
Byte memop;
Byte tr;
Byte priv;
Byte ea_valid;
Byte bt;
Byte an;
Byte cti_executed;
// Trap specific
uint16_t syscall;
uint64_t reg64[3]; // TID and SP for TRAPEXIT, %o0 for trap first arg
uint32_t tno;
Byte is_async;
// TLB specific
Byte demap;
Byte tlb_type;
uint16_t idx;
uint16_t tlb_no;
uint64_t tte_data;
uint64_t tte_tag; // VA [63 : 13] context[12 : 0]
// Context specific
Byte asiReg;
// DMA specific
// uint64_t dma_pa // use regular memop EA_PA
uint32_t dma_len;
// Byte dma_op; // use regular memop
Byte dma_class;
Byte *dma_memptr;
} CpuInfo;
typedef union {
int dummy;
}BlzInfo;
/////////////////////////////////////////
typedef struct BlzMemop
{
uint64_t paddr;
uint64_t base;
uint64_t *buf;
uint32_t size;
uint32_t cpuid;
bool_t wr;
uint8_t bytemask;
} BlzMemop_t;
///////////////////////////////////////////
#ifdef __cplusplus
extern "C" {
#endif
void init_tm ();
typedef void (*fn_misc)();
typedef void (*fn_event) (TM_OPAQUE_DATA, cpuT*, uint64_t);
typedef void (*fn_event_2) (TM_OPAQUE_DATA, uint64_t);
typedef void (*fn_cpustat) (TM_OPAQUE_DATA, cpuT*, CpuInfo*);
typedef void (*fn_cpustatB) (TM_OPAQUE_DATA, cpuT*, BlzInfo*);
typedef void (*fn_time_interval) (TM_OPAQUE_DATA, uint64_t global_time);
typedef void (*fn_blaze_stop) (TM_OPAQUE_DATA);
typedef int (*fn_ui_1) (TM_OPAQUE_DATA, char *cmd);
typedef int (*fn_ui_2) (TM_OPAQUE_DATA, int argc, char** argv);
enum {
TM_UNKNOWN = 0,
TM_BUFMODE = 1,
TM_CBMODE = 2, // default
TM_EXT_IO = 4,
TM_EXT_ASI = 8,
TM_MT_SAFE = 8,
TM_LOCKMODE = 32 // to lock the tracing out
};
void *TM_register_time_intf (tracemod_t *mod, TM_OPAQUE_DATA client_data,
fn_event_cycle handler, uint64_t how_often);
void TM_unregister_time_intf (tracemod_t *mod, void *intf);
void TM_enable_time_intf (void *intf, uint64_t how_often);
void TM_disable_time_intf (void *intf);
void TM_enable_interval (uint64_t ti);
void TM_disable_interval ();
void TM_time_interval_register (tracemod_t *pmod, fn_time_interval fn);
void TM_set_mode (tracemod_t *pmod, Byte mode);
void TM_add_event (tracemod_t * pmod, uint64_t tick, fn_event fn);
void TM_cpustate_register (tracemod_t* pmod, fn_cpustat fn);
tracemod_t *TM_self_register (const char* mod_name,
const char *help, TM_OPAQUE_DATA client_data);
tracemod_t *TM_self_register_spec (const char* mod_name, TM_OPAQUE_DATA client_data);
tracemod_t *TM_self_pseudomod_spec (tracemod_t *main_mod, const char* mod_name,
const char *help, TM_OPAQUE_DATA client_data);
void TM_register_client_data (tracemod_t *mod, TM_OPAQUE_DATA d);
/* call back data associated with asi handler */
void TM_register_asi_client_data (tracemod_t *mod, TM_OPAQUE_DATA d);
void TM_run_config_cb (tracemod_t *, int);
void TM_run_atexit_cb();
void TM_module_init();
bool_t TM_verify (tracemod_t * tm);
// Gets TRACEMOD casted to void*
// Returns a pointer to BLAZE subsystems specific part of module descriptor
// (see schizo_ext.cc)
void *TM_get_blaze_data (void * handle);
tracemod_t *TM_get_mod (void * handle);
// Returns the next module handle of given type
// (BLAZE supports IO ld/st modules, ASI listeners , ...)
void *TM_get_client_data (void *handle);
/* call back data associated with asi handler */
void *TM_get_asi_client_data (void *handle);
char *TM_get_name (void *handle);
void *TM_getnext_ext (void *handle, uint32_t module_type);
void TM_include_ext (void *io_module, void *local_handle);
fn_misc TM_get_ld_action_ext (void *io_module);
fn_misc TM_get_st_action_ext (void *io_module);
fn_misc TM_get_ld_mmi_action_ext (void *io_module);
fn_misc TM_get_st_mmi_action_ext (void *io_module);
uint32_t TM_is_ready_ext (void *io_module);
bool_t TM_is_device ();
bool_t TM_mt_safe ();
void TM_set_type_ext (tracemod_t *pmod, Byte type);
void TM_register_io_action (tracemod_t *mod, fn_misc ld_action, fn_misc st_action);
void TM_register_io_mmi_action (tracemod_t *mod, fn_misc ld_action, fn_misc st_action);
//
// This routine removes all existing invalid entries in LDM list
// Should be used by LDM when module naming convention is violated
//
void TM_clean_mod ();
void TM_clean_mod_spec ();
//////////////////////////////////////////////////
void TM_invalidate (tracemod_t *pmod);
tracemod_t* TM_find_mod_spec (char * name);
tracemod_t* TM_find_mod_spec_instance
(tracemod_t *pmod, char * name);
void TM_ui_register_1 (tracemod_t* pmod, const char* name,
const char *shelp, const char * lhelp, fn_ui_1 fn); //? TODO
void TM_ui_register_2 (tracemod_t* pmod, const char* name,
const char *shelp, const char * lhelp, fn_ui_2 fn); //? TODO
void TM_ui_unregister (tracemod_t* pmod, const char *name);
tracemod_t *TM_get_asi_ext ();
int TM_execute_load_asi (uint32_t asi, uint64_t vaddr, uint64_t *d, int size, uint32_t cpuid);
int TM_execute_store_asi (uint32_t asi, uint64_t vaddr, uint64_t *d, int size, uint32_t cpuid);
#ifdef WITH_FRONTEND
bool_t TM_register_3d_party_ext (char * soname, char *sofile, void *so_handle);
#endif
#ifdef __cplusplus
}
#endif
// The special macros supporting
// BLAZE DEVICE extensions
#define EXT_TICKEVENT(incr) if (head_time_intf) TM_tick_ext (incr);
extern struct ldm_time_intf *head_time_intf;
void TM_tick_ext (int incr);
void TM_context (cpuT *sp);
#if 0
@@@#define TRACEMOD_DMA_READ(dma_class, pa, len, memptr) if (head_ldm) TM_dma_read (dma_class, pa, len, memptr);
@@@#define TRACEMOD_DMA_WRITE(dma_class, pa, len, memptr) if (head_ldm) TM_dma_write (dma_class, pa, len, memptr);
#else
#define TRACEMOD_DMA_READ(dma_class, pa, len, memptr)
#define TRACEMOD_DMA_WRITE(dma_class, pa, len, memptr)
#endif
#define TRACEMOD_INTERVAL_EVENT(v) if (v >= time_target) TM_time_interval (v);
void TM_time_interval (uint64_t time);
#endif /* TRACEMOD_H */