Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / sam / cpus / vonk / n2 / api / sam / src / N2_VirtualCpu.cc
CommitLineData
920dae64
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: N2_VirtualCpu.cc
4// Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
5// DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
6//
7// The above named program is free software; you can redistribute it and/or
8// modify it under the terms of the GNU General Public
9// License version 2 as published by the Free Software Foundation.
10//
11// The above named program is distributed in the hope that it will be
12// useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14// General Public License for more details.
15//
16// You should have received a copy of the GNU General Public
17// License along with this work; if not, write to the Free Software
18// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
19//
20// ========== Copyright Header End ============================================
21
22#include <string.h>
23#include "SS_VirtualCpu.h"
24#include "N2_Model.h"
25
26namespace Sam {
27#define bool_t bool
28#include "vcpu.h"
29}
30
31static N2_Model* n2 = 0;
32
33static SS_Model* n2_model()/*{{{*/
34{
35 if (n2 == 0)
36 n2 = new N2_Model();
37 return n2;
38}
39/*}}}*/
40
41static void* n2_create( Sam::VCPU_Config* config, Sam::VCPU_ImpIntf* interface )/*{{{*/
42{
43 config->cpu_type =
44 (Sam::VCPU_Type)(Sam::VCPU_IMPL_VER_N2 | Sam::VCPU_IMPL_SIM_VONK);
45 return SS_VirtualCpu::create(n2_model,config,interface);
46}
47/*}}}*/
48static int n2_destroy()/*{{{*/
49{
50 SS_VirtualCpu::remove(n2);
51 n2 = 0;
52 return 0;
53}
54/*}}}*/
55static int n2_reset( uint64_t pc )/*{{{*/
56{
57 return 0;
58}
59/*}}}*/
60static int n2_config( char* cmd, char* reply, int reply_size )/*{{{*/
61{
62 return 0;
63}
64/*}}}*/
65static int n2_snapshot( char* dir_name, bool load )/*{{{*/
66{
67 return SS_VirtualCpu::snapshot(n2,dir_name,"/n2cpu.ss",load);
68}
69/*}}}*/
70static int n2_save( char* dir_name )/*{{{*/
71{
72 return n2_snapshot(dir_name,false);
73}
74/*}}}*/
75static int n2_restore( char* dir_name )/*{{{*/
76{
77 return n2_snapshot(dir_name,true);
78}
79/*}}}*/
80
81
82static int n2_cycle ( uint64_t nn )
83{
84 return SS_VirtualCpu::cycle(nn);
85}
86
87static Sam::VCPU_ExInterface n2_sam_interface =/*{{{*/
88{
89 n2_create,
90 n2_reset,
91 n2_destroy,
92 n2_config,
93 n2_save,
94 n2_restore,
95 n2_cycle
96};
97/*}}}*/
98
99extern "C" int get_ex_interface( Sam::VCPU_ExInterface* interface )/*{{{*/
100{
101 *interface = n2_sam_interface;
102 return 0;
103}
104/*}}}*/
105
106// global methods to access system info
107extern "C" uint_t vcpu_get_sys_type()/*{{{*/
108{
109
110 return Sam::VCPU_IMPL_VER_N2;
111
112}
113/*}}}*/
114extern "C" uint_t vcpu_get_sys_size()/*{{{*/
115{
116 return 0;
117}
118/*}}}*/
119extern "C" void* vcpu_get_sys_pntr( uint_t i )/*{{{*/
120{
121 assert(n2 && (i == 0));
122 return (void*)n2;
123}
124/*}}}*/
125
126
127
128
129
130