Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | /* |
2 | * ========== Copyright Header Begin ========================================== | |
3 | * | |
4 | * OpenSPARC T2 Processor File: SS_PythonAsiReg.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 | #ifndef __SS_PythonAsiReg_h__ | |
25 | #define __SS_PythonAsiReg_h__ | |
26 | ||
27 | #include "SS_AsiCtrReg.h" | |
28 | #include <stdio.h> | |
29 | ||
30 | class SS_Node; | |
31 | ||
32 | class SS_PythonAsiReg | |
33 | { | |
34 | public: | |
35 | SS_PythonAsiReg() | |
36 | : | |
37 | py_ld64(0), | |
38 | py_st64(0), | |
39 | py_rd64(0), | |
40 | py_wr64(0) | |
41 | {} | |
42 | ||
43 | static SS_AsiSpace::Error ld64( SS_Node* obj, void* reg, SS_Strand* s, SS_Vaddr va, uint64_t* data ) | |
44 | { | |
45 | SS_PythonAsiReg* py_reg = (SS_PythonAsiReg*)reg; | |
46 | PyObject *func, *args, *rslt; | |
47 | func = (PyObject*)py_reg->py_ld64; | |
48 | if (func) | |
49 | { | |
50 | args = Py_BuildValue((char*)"i",va); | |
51 | rslt = PyEval_CallObject(func,args); | |
52 | Py_DECREF(args); | |
53 | if (rslt) | |
54 | { | |
55 | SS_AsiSpace::Error err; | |
56 | uint64_t val; | |
57 | if (PyArg_ParseTuple(rslt,(char*)"(ii)",&err,&val)) | |
58 | { | |
59 | if (!err) *data = val; | |
60 | Py_DECREF(rslt); | |
61 | return err; | |
62 | } | |
63 | } | |
64 | } | |
65 | return SS_AsiSpace::NO_ASI; | |
66 | } | |
67 | static SS_AsiSpace::Error st64( SS_Node* obj, void* reg, SS_Strand* s, SS_Vaddr va, uint64_t data ) | |
68 | { | |
69 | return SS_AsiSpace::NO_ASI; | |
70 | } | |
71 | ||
72 | static SS_AsiSpace::Error rd64( SS_Node* obj, void* reg, SS_Strand* s, SS_Vaddr va, uint64_t* data ) | |
73 | { | |
74 | return SS_AsiSpace::NO_ASI; | |
75 | } | |
76 | static SS_AsiSpace::Error wr64( SS_Node* obj, void* reg, SS_Strand* s, SS_Vaddr va, uint64_t data ) | |
77 | { | |
78 | return SS_AsiSpace::NO_ASI; | |
79 | } | |
80 | ||
81 | void set_ld64( PyObject* func ) | |
82 | { | |
83 | Py_INCREF(func); | |
84 | if (py_ld64) | |
85 | Py_DECREF(py_ld64); | |
86 | py_ld64 = func; | |
87 | } | |
88 | void clr_ld64() | |
89 | { | |
90 | if (py_ld64) | |
91 | Py_DECREF(py_ld64); | |
92 | py_ld64 = 0; | |
93 | } | |
94 | ||
95 | void set_st64( PyObject* func ) | |
96 | { | |
97 | Py_INCREF(func); | |
98 | if (py_st64) | |
99 | Py_DECREF(py_st64); | |
100 | py_st64 = func; | |
101 | } | |
102 | void clr_st64() | |
103 | { | |
104 | if (py_st64) | |
105 | Py_DECREF(py_st64); | |
106 | py_st64 = 0; | |
107 | } | |
108 | ||
109 | void set_rd64( PyObject* func ) | |
110 | { | |
111 | Py_INCREF(func); | |
112 | if (py_rd64) | |
113 | Py_DECREF(py_rd64); | |
114 | py_rd64 = func; | |
115 | } | |
116 | void clr_rd64() | |
117 | { | |
118 | if (py_rd64) | |
119 | Py_DECREF(py_rd64); | |
120 | py_rd64 = 0; | |
121 | } | |
122 | ||
123 | void set_wr64( PyObject* func ) | |
124 | { | |
125 | Py_INCREF(func); | |
126 | if (py_wr64) | |
127 | Py_DECREF(py_wr64); | |
128 | py_wr64 = func; | |
129 | } | |
130 | void clr_wr64() | |
131 | { | |
132 | if (py_wr64) | |
133 | Py_DECREF(py_wr64); | |
134 | py_wr64 = 0; | |
135 | } | |
136 | ||
137 | protected: | |
138 | PyObject* py_ld64; | |
139 | PyObject* py_st64; | |
140 | PyObject* py_rd64; | |
141 | PyObject* py_wr64; | |
142 | }; | |
143 | ||
144 | ||
145 | #endif | |
146 |