Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / sam / include / system.h
/*
* ========== Copyright Header Begin ==========================================
*
* OpenSPARC T2 Processor File: system.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, 2005 Sun Microsystems, Inc.
* All rights reserved.
*/
#ifndef _SYSTEM_H
#define _SYSTEM_H
#include "types.h"
#include "cpu_interface.h"
typedef Vcpu cpuT;
typedef VCPU_InterruptRequest intrT;
void SYSTEM_init ();
void * SYSTEM_is_ready ();
void SYSTEM_main(void);
FILE * SYSTEM_fopen (const char * filename, const char * flags);
int SYSTEM_open (const char * filename, int oflag);
void init_SYSTEM_open ();
//
// External API mostly for loadable modules
//
#ifdef __cplusplus
extern "C" {
#endif
#if 0
}
#endif
#ifdef NIAGARA
void SYSTEM_interrupt_by_vector (uint32_t tid, uint32_t vnum);
#endif
bool_t SYSTEM_chplus_mmu ();
bool_t SYSTEM_is_serengeti();
bool_t SYSTEM_is_480R();
uint8_t SYSTEM_get_nic_num();
uint8_t SYSTEM_get_dc_num();
uint64_t SYSTEM_get_globaltick ();
void SYSTEM_increment_time ();
uint64_t SYSTEM_get_globaltick_per_cpu ();
uint64_t SYSTEM_get_globaltick_per_core (uint32_t cores);
uint32_t SYSTEM_get_ncpu ();
uint32_t SYSTEM_get_ncores();
char * SYSTEM_get_version ();
double SYSTEM_get_versionnum ();
const char* SYSTEM_get_ramsizeS();
int SYSTEM_get_tlbsize();
const char* SYSTEM_get_mmutypeS();
const char* SYSTEM_get_cputypeS();
uint64_t SYSTEM_get_cpufreq();
uint64_t SYSTEM_get_stickfreq();
int SYSTEM_get_diskdelay();
int SYSTEM_get_loopticks();
int SYSTEM_get_stickincr();
int SYSTEM_get_numthreads();
int SYSTEM_get_cpus_per_thread();
int SYSTEM_get_skipmp();
int SYSTEM_get_blockmp();
int SYSTEM_get_wrdiskdelay();
bool_t SYSTEM_get_ce_enable_flag();
void SYSTEM_set_ce_enable_flag(bool_t flag);
bool_t SYSTEM_get_scsi_disk_enable_flag();
void SYSTEM_set_scsi_disk_enable_flag(bool_t flag);
void SYSTEM_set_boot_aid_bus(unsigned char aid, unsigned char bus); // cchen
bool_t SYSTEM_get_scsi_boot_enable_flag();
void SYSTEM_set_scsi_boot_enable_flag(bool_t flag);
bool_t SYSTEM_get_fc_disk_enable_flag();
void SYSTEM_set_fc_disk_enable_flag(bool_t flag);
bool_t SYSTEM_get_fc_boot_enable_flag();
void SYSTEM_set_fc_boot_enable_flag(bool_t flag);
int SYSTEM_get_nwins();
const char* SYSTEM_get_infostr ();
void SYSTEM_free_intr (intrT *);
/* ------ specifically for ui-thread ------ */
void SYSTEM_stop_UI ();
void SYSTEM_run_UI ();
void SYSTEM_stepi_UI (int64_t ni);
void SYSTEM_stepc_UI (int64_t nc);
typedef void (*doneftn_t)(void *);
void SYSTEM_stept_UI (int64_t usecs, int64_t seqnum, doneftn_t callback);
void SYSTEM_syncon_UI ();
void SYSTEM_syncoff_UI ();
void SYSTEM_lock_UI ();
void SYSTEM_unlock_UI ();
// simulate nusecs time of cpu
void SYSTEM_kick_usecs (int64_t nusecs);
// simulate ninstr number of instructions
void SYSTEM_kick_instrs (int64_t ninstrs);
void SYSTEM_kick_cycles(int64_t ncycles);
void SYSTEM_wait_worker_threads ();
// get the global system simulated time in usecs
uint64_t SYSTEM_get_global_time();
int64_t SYSTEM_get_ticks();
void SYSTEM_kick_with_callback (int64_t ninstrs, doneftn_t callback);
void SYSTEM_quit_UI();
void SYSTEM_quit(); // should be deleted.?.
void SYSTEM_stop(); // should be deleted.!!!.
bool_t SYSTEM_is_stopped (); // these three are mutually exclusive
bool_t SYSTEM_is_running (); // and taken together are complete.
bool_t SYSTEM_is_notready (); // ie initialization not yet done.
void SYSTEM_dump (FILE*);
bool_t SYSTEM_restore (FILE*);
void SYSTEM_unlock ();
void SYSTEM_cycle_delay (uint32_t cpuid, uint32_t delay);
uint64_t SYSTEM_get_ireg (cpuT *sp, int wp, int regnum);
uint64_t SYSTEM_get_freg (cpuT *sp, int issingle, int regnum);
// Is being called when other CPU or SCHIZO(IO) are going to interrupt
// target CPU (dst_cpu)
void SYSTEM_interrupt_by_sid(int dst_aid, int src_aid, intrT *intr);
// SYSTEM_cpu_by_sid gets the cpu pointer by system id (sid). sid is
// the platforms view of the cpu id which may or may not be sequantial
cpuT *SYSTEM_cpu_by_sid(int n);
// Is being called from inside CPU (CPU_cycle) for periodic external
// interrupts handling
void SYSTEM_cpu_interrupt_queue_process(int mid);
void SYSTEM_init_cmp_mod(bool_t restore, char * restore_dir);
void SYSTEM_init_cpu (bool_t restore, char * restore_dir);
// physical I/O access from cpu to I/O modules
int SYSTEM_physio_access (uint32_t cpuid, void* obj, uint64_t paddr, bool_t wr, uint32_t size, uint64_t* buf, uint8_t bytemask=PHYSIO_BYTEMASK_ALL);
// serial console
uint64_t SYSTEM_serial_fake_in (cpuT *sp);
void SYSTEM_serial_fake_out (cpuT *sp, char c);
void SYSTEM_set_pc (uint32_t cpuid, uint64_t pc);
void SYSTEM_set_npc (uint32_t cpuid, uint64_t npc);
bool_t SYSTEM_is_exec_thrd ();
/*timesync ------------------------------------------------------------- */
typedef enum { // Whence simulated time is measured from
TW_CURRENT, // time since boot
TW_INTERVAL, // time since last global-sync-interval started
TW_MARK, // the time at which global-sync-interval started
TW_LENGTH // the length of the current global-sync-interval
} timewhence_t;
// in MICROSECS simulated time
sint64_t SYSTEM_get_time (timewhence_t whence = TW_CURRENT);
void SYSTEM_mark_intervalstart (sint64_t intervallength);
void SYSTEM_mark_intervalstop ();
sint64_t SYSTEM_get_sequencenum (); // current global-time-sync interval #
bool SYSTEM_is_sync_on();
sint64_t SYSTEM_usecs2cycles (sint64_t);
sint64_t SYSTEM_usecs2sticks (sint64_t);
typedef void (EventFunc_T)(void * arg1, void * arg2);
typedef void (UnloadFunc_T)(sint64_t stime, void * arg1, void * arg2);
void SYSTEM_register_event (
uint64_t stime, /* microsecs, simulated time */
EventFunc_T * callback, void * arg1, void * arg2,
UnloadFunc_T * unloadfunc,
const char * debugstring);
/* --------------------------------------------------------------------- */
/* cpu-worker-threads for mp-on-mp -------------------------------------- */
void SYSTEM_wait_worker_threads ();
/* --------------------------------------------------------------------- */
/* hostconfig ----------------------------------------------------------- */
// returns config-value, given config-name, simple dictionary/map lookup.
extern const char * SYSTEM_get_hostconfig (const char * configname);
//
extern bool_t SYSTEM_isset_hostconfig (const char * configname);
// used by ... to initially record the hostconfig info
extern void SYSTEM_set_hostconfig (const char * configname, const char * configvalue);
// get number-of-cpus available in underlying host system
extern int HOSTINFO_numcpus();
/* hostconfig ---------------------------------------------------------- */
#if 0
{
#endif
#ifdef __cplusplus
}
#endif
void SYSTEM_set_extend_ready ();
void SYSTEM_set_extend_not_ready ();
//
// Diskdelay SCSI module support
//
void SYSTEM_register_dd_handlers ( void * fn1, void * fn2);
//
// start/stop mechanizm for different threads
// (clean dump/restore and other stuff)
//
typedef void (*ss_action) (void*);
extern void SYSTEM_ss_register (ss_action, ss_action, void*);
extern void SYSTEM_ss_unregister (void*);
//
// Misc functions
//
//extern uint64_t SYSTEM_get_int_property (cpuT *sp, uint64_t vaddr);
extern uint64_t SYSTEM_get_goodtrap_pc();
extern uint64_t SYSTEM_get_badtrap_pc();
extern void SYSTEM_set_goodtrap_pc(uint64_t);
extern void SYSTEM_set_badtrap_pc(uint64_t);
extern sint64_t SYSTEM_Sticks2usecs (sint64_t sticks);
extern sint64_t SYSTEM_Ticks2usecs (sint64_t ticks);
void SYSTEM_set_memreserve (bool_t flag);
bool_t SYSTEM_get_memreserve();
int SYSTEM_in_execution_driven_mode();
void SYSTEM_enable_execution_driven_mode();
void SYSTEM_disable_execution_driven_mode();
#endif /* _SYSTEM_H */