Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / sam / include / system.h
CommitLineData
920dae64
AT
1/*
2* ========== Copyright Header Begin ==========================================
3*
4* OpenSPARC T2 Processor File: system.h
5* Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
6* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
7*
8* The above named program is free software; you can redistribute it and/or
9* modify it under the terms of the GNU General Public
10* License version 2 as published by the Free Software Foundation.
11*
12* The above named program is distributed in the hope that it will be
13* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15* General Public License for more details.
16*
17* You should have received a copy of the GNU General Public
18* License along with this work; if not, write to the Free Software
19* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
20*
21* ========== Copyright Header End ============================================
22*/
23/*
24 * Copyright (C) 2001, 2005 Sun Microsystems, Inc.
25 * All rights reserved.
26 */
27
28
29#ifndef _SYSTEM_H
30#define _SYSTEM_H
31
32
33#include "types.h"
34
35#include "cpu_interface.h"
36
37
38typedef Vcpu cpuT;
39typedef VCPU_InterruptRequest intrT;
40
41
42void SYSTEM_init ();
43void * SYSTEM_is_ready ();
44
45
46void SYSTEM_main(void);
47
48
49FILE * SYSTEM_fopen (const char * filename, const char * flags);
50int SYSTEM_open (const char * filename, int oflag);
51void init_SYSTEM_open ();
52
53
54//
55// External API mostly for loadable modules
56//
57#ifdef __cplusplus
58extern "C" {
59#endif
60#if 0
61}
62#endif
63
64#ifdef NIAGARA
65void SYSTEM_interrupt_by_vector (uint32_t tid, uint32_t vnum);
66#endif
67
68bool_t SYSTEM_chplus_mmu ();
69bool_t SYSTEM_is_serengeti();
70bool_t SYSTEM_is_480R();
71uint8_t SYSTEM_get_nic_num();
72uint8_t SYSTEM_get_dc_num();
73uint64_t SYSTEM_get_globaltick ();
74void SYSTEM_increment_time ();
75uint64_t SYSTEM_get_globaltick_per_cpu ();
76uint64_t SYSTEM_get_globaltick_per_core (uint32_t cores);
77uint32_t SYSTEM_get_ncpu ();
78uint32_t SYSTEM_get_ncores();
79char * SYSTEM_get_version ();
80double SYSTEM_get_versionnum ();
81const char* SYSTEM_get_ramsizeS();
82int SYSTEM_get_tlbsize();
83const char* SYSTEM_get_mmutypeS();
84const char* SYSTEM_get_cputypeS();
85uint64_t SYSTEM_get_cpufreq();
86uint64_t SYSTEM_get_stickfreq();
87int SYSTEM_get_diskdelay();
88int SYSTEM_get_loopticks();
89int SYSTEM_get_stickincr();
90int SYSTEM_get_numthreads();
91int SYSTEM_get_cpus_per_thread();
92int SYSTEM_get_skipmp();
93int SYSTEM_get_blockmp();
94int SYSTEM_get_wrdiskdelay();
95bool_t SYSTEM_get_ce_enable_flag();
96void SYSTEM_set_ce_enable_flag(bool_t flag);
97bool_t SYSTEM_get_scsi_disk_enable_flag();
98void SYSTEM_set_scsi_disk_enable_flag(bool_t flag);
99void SYSTEM_set_boot_aid_bus(unsigned char aid, unsigned char bus); // cchen
100bool_t SYSTEM_get_scsi_boot_enable_flag();
101void SYSTEM_set_scsi_boot_enable_flag(bool_t flag);
102bool_t SYSTEM_get_fc_disk_enable_flag();
103void SYSTEM_set_fc_disk_enable_flag(bool_t flag);
104bool_t SYSTEM_get_fc_boot_enable_flag();
105void SYSTEM_set_fc_boot_enable_flag(bool_t flag);
106int SYSTEM_get_nwins();
107const char* SYSTEM_get_infostr ();
108void SYSTEM_free_intr (intrT *);
109
110
111
112/* ------ specifically for ui-thread ------ */
113void SYSTEM_stop_UI ();
114void SYSTEM_run_UI ();
115void SYSTEM_stepi_UI (int64_t ni);
116void SYSTEM_stepc_UI (int64_t nc);
117typedef void (*doneftn_t)(void *);
118void SYSTEM_stept_UI (int64_t usecs, int64_t seqnum, doneftn_t callback);
119void SYSTEM_syncon_UI ();
120void SYSTEM_syncoff_UI ();
121
122void SYSTEM_lock_UI ();
123void SYSTEM_unlock_UI ();
124
125// simulate nusecs time of cpu
126void SYSTEM_kick_usecs (int64_t nusecs);
127// simulate ninstr number of instructions
128void SYSTEM_kick_instrs (int64_t ninstrs);
129
130void SYSTEM_kick_cycles(int64_t ncycles);
131
132void SYSTEM_wait_worker_threads ();
133// get the global system simulated time in usecs
134uint64_t SYSTEM_get_global_time();
135int64_t SYSTEM_get_ticks();
136void SYSTEM_kick_with_callback (int64_t ninstrs, doneftn_t callback);
137
138void SYSTEM_quit_UI();
139
140void SYSTEM_quit(); // should be deleted.?.
141void SYSTEM_stop(); // should be deleted.!!!.
142
143bool_t SYSTEM_is_stopped (); // these three are mutually exclusive
144bool_t SYSTEM_is_running (); // and taken together are complete.
145bool_t SYSTEM_is_notready (); // ie initialization not yet done.
146
147
148
149void SYSTEM_dump (FILE*);
150bool_t SYSTEM_restore (FILE*);
151void SYSTEM_unlock ();
152
153void SYSTEM_cycle_delay (uint32_t cpuid, uint32_t delay);
154
155
156uint64_t SYSTEM_get_ireg (cpuT *sp, int wp, int regnum);
157uint64_t SYSTEM_get_freg (cpuT *sp, int issingle, int regnum);
158
159
160// Is being called when other CPU or SCHIZO(IO) are going to interrupt
161// target CPU (dst_cpu)
162void SYSTEM_interrupt_by_sid(int dst_aid, int src_aid, intrT *intr);
163
164// SYSTEM_cpu_by_sid gets the cpu pointer by system id (sid). sid is
165// the platforms view of the cpu id which may or may not be sequantial
166cpuT *SYSTEM_cpu_by_sid(int n);
167
168
169// Is being called from inside CPU (CPU_cycle) for periodic external
170// interrupts handling
171void SYSTEM_cpu_interrupt_queue_process(int mid);
172void SYSTEM_init_cmp_mod(bool_t restore, char * restore_dir);
173void SYSTEM_init_cpu (bool_t restore, char * restore_dir);
174
175
176// physical I/O access from cpu to I/O modules
177int 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);
178
179// serial console
180uint64_t SYSTEM_serial_fake_in (cpuT *sp);
181void SYSTEM_serial_fake_out (cpuT *sp, char c);
182
183void SYSTEM_set_pc (uint32_t cpuid, uint64_t pc);
184void SYSTEM_set_npc (uint32_t cpuid, uint64_t npc);
185
186
187bool_t SYSTEM_is_exec_thrd ();
188
189
190
191/*timesync ------------------------------------------------------------- */
192
193typedef enum { // Whence simulated time is measured from
194 TW_CURRENT, // time since boot
195 TW_INTERVAL, // time since last global-sync-interval started
196 TW_MARK, // the time at which global-sync-interval started
197 TW_LENGTH // the length of the current global-sync-interval
198} timewhence_t;
199
200
201 // in MICROSECS simulated time
202sint64_t SYSTEM_get_time (timewhence_t whence = TW_CURRENT);
203
204
205
206void SYSTEM_mark_intervalstart (sint64_t intervallength);
207void SYSTEM_mark_intervalstop ();
208
209sint64_t SYSTEM_get_sequencenum (); // current global-time-sync interval #
210
211bool SYSTEM_is_sync_on();
212
213sint64_t SYSTEM_usecs2cycles (sint64_t);
214sint64_t SYSTEM_usecs2sticks (sint64_t);
215
216
217
218
219typedef void (EventFunc_T)(void * arg1, void * arg2);
220typedef void (UnloadFunc_T)(sint64_t stime, void * arg1, void * arg2);
221
222void SYSTEM_register_event (
223 uint64_t stime, /* microsecs, simulated time */
224 EventFunc_T * callback, void * arg1, void * arg2,
225 UnloadFunc_T * unloadfunc,
226 const char * debugstring);
227
228
229/* --------------------------------------------------------------------- */
230
231
232
233
234/* cpu-worker-threads for mp-on-mp -------------------------------------- */
235void SYSTEM_wait_worker_threads ();
236/* --------------------------------------------------------------------- */
237
238
239
240
241/* hostconfig ----------------------------------------------------------- */
242// returns config-value, given config-name, simple dictionary/map lookup.
243extern const char * SYSTEM_get_hostconfig (const char * configname);
244//
245extern bool_t SYSTEM_isset_hostconfig (const char * configname);
246// used by ... to initially record the hostconfig info
247extern void SYSTEM_set_hostconfig (const char * configname, const char * configvalue);
248
249
250// get number-of-cpus available in underlying host system
251extern int HOSTINFO_numcpus();
252/* hostconfig ---------------------------------------------------------- */
253
254
255
256
257
258
259
260#if 0
261{
262#endif
263#ifdef __cplusplus
264}
265#endif
266
267
268
269
270void SYSTEM_set_extend_ready ();
271void SYSTEM_set_extend_not_ready ();
272
273//
274// Diskdelay SCSI module support
275//
276
277void SYSTEM_register_dd_handlers ( void * fn1, void * fn2);
278
279//
280// start/stop mechanizm for different threads
281// (clean dump/restore and other stuff)
282//
283typedef void (*ss_action) (void*);
284extern void SYSTEM_ss_register (ss_action, ss_action, void*);
285extern void SYSTEM_ss_unregister (void*);
286
287
288//
289// Misc functions
290//
291//extern uint64_t SYSTEM_get_int_property (cpuT *sp, uint64_t vaddr);
292
293extern uint64_t SYSTEM_get_goodtrap_pc();
294extern uint64_t SYSTEM_get_badtrap_pc();
295extern void SYSTEM_set_goodtrap_pc(uint64_t);
296extern void SYSTEM_set_badtrap_pc(uint64_t);
297
298extern sint64_t SYSTEM_Sticks2usecs (sint64_t sticks);
299extern sint64_t SYSTEM_Ticks2usecs (sint64_t ticks);
300
301void SYSTEM_set_memreserve (bool_t flag);
302bool_t SYSTEM_get_memreserve();
303
304int SYSTEM_in_execution_driven_mode();
305void SYSTEM_enable_execution_driven_mode();
306void SYSTEM_disable_execution_driven_mode();
307
308
309#endif /* _SYSTEM_H */