Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | /* |
2 | * ========== Copyright Header Begin ========================================== | |
3 | * | |
4 | * OpenSPARC T2 Processor File: SS_Types.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 | #ifndef __SS_Types_h__ | |
24 | #define __SS_Types_h__ | |
25 | ||
26 | #include "BL_Types.h" | |
27 | ||
28 | // ptr_ofs() is used in the decode functions to get the offset from the | |
29 | // strand pointer to a particular member, e.g. irf[rd] etc. Keep the | |
30 | // result type an int32_t as the result is stored in a int16_t variable | |
31 | ||
32 | #define ptr_ofs(type,member) int32_t((char*)&((type*)0)->member - (char*)0) | |
33 | ||
34 | // For faster indexing into an array of pointers ... the CC compiler ain't that | |
35 | // smart and produces unnecesary shift right (index) and shift left (index * size) | |
36 | ||
37 | #define ptr_sft(s) ((s) - ((sizeof(void*) == 4) ? 2 : 3)) | |
38 | #define ptr_msk(m) ((m) << ((sizeof(void*) == 4) ? 2 : 3)) | |
39 | ||
40 | // Some very often used data types | |
41 | ||
42 | typedef int64_t SS_Vaddr; // VA's are signed, see VA hole implementation in N1, N2, etc. | |
43 | typedef uint64_t SS_Paddr; | |
44 | typedef uint16_t SS_Context; | |
45 | typedef uint32_t SS_OpcWord; | |
46 | ||
47 | const SS_Vaddr SS_VADDR_MIN = (SS_Vaddr(1) << 63); | |
48 | const SS_Vaddr SS_VADDR_MAX = ~SS_VADDR_MIN; | |
49 | ||
50 | class SS_Strand; | |
51 | class SS_Instr; | |
52 | class SS_Tte; | |
53 | ||
54 | #include "SS_Trap.h" | |
55 | ||
56 | extern "C" typedef SS_Vaddr (*SS_Decode)( SS_Vaddr, SS_Vaddr, SS_Strand*, SS_Instr*, SS_OpcWord ); | |
57 | extern "C" typedef SS_Vaddr (*SS_Execute)( SS_Vaddr, SS_Vaddr, SS_Strand*, SS_Instr* ); | |
58 | extern "C" typedef SS_Vaddr (*SS_Memop)( SS_Vaddr, SS_Vaddr, SS_Strand*, SS_Instr*, SS_Vaddr, SS_Tte* ); | |
59 | ||
60 | // Irf Ras error detection function for source regs | |
61 | extern "C" typedef SS_Vaddr (*SS_RasIrfSrc)( SS_Vaddr, SS_Vaddr, SS_Strand*, SS_Instr*, int); | |
62 | // Irf Ras error injection function for dest regs | |
63 | extern "C" typedef SS_Vaddr (*SS_RasIrfDst)( SS_Vaddr, SS_Vaddr, SS_Strand*, SS_Instr*, int); | |
64 | ||
65 | // Single precision Frf Ras error detection function for source regs | |
66 | extern "C" typedef SS_Vaddr (*SS_RasFrfSrc)( SS_Vaddr, SS_Vaddr, SS_Strand*, SS_Instr*, int); | |
67 | // Single precision Frf Ras error injection function for dest regs | |
68 | extern "C" typedef SS_Vaddr (*SS_RasFrfDst)( SS_Vaddr, SS_Vaddr, SS_Strand*, SS_Instr*, int); | |
69 | ||
70 | // Double precision Frf Ras error detection function for source regs | |
71 | extern "C" typedef SS_Vaddr (*SS_RasDrfSrc)( SS_Vaddr, SS_Vaddr, SS_Strand*, SS_Instr*, int); | |
72 | // Double precision Frf Ras error injection function for dest regs | |
73 | extern "C" typedef SS_Vaddr (*SS_RasDrfDst)( SS_Vaddr, SS_Vaddr, SS_Strand*, SS_Instr*, int); | |
74 | ||
75 | ||
76 | ||
77 | inline void *ss_malloc(size_t size) | |
78 | { | |
79 | void* ptr = malloc(size); | |
80 | //if (ptr == 0) | |
81 | //{ | |
82 | //perror("malloc"); | |
83 | //exit(-1); | |
84 | //} | |
85 | return ptr; | |
86 | } | |
87 | ||
88 | inline void* ss_memalign(size_t alignment, size_t size) | |
89 | { | |
90 | void* ptr = memalign(alignment,size); | |
91 | //if (ptr == 0) | |
92 | //{ | |
93 | //perror("memalign"); | |
94 | //exit(-1); | |
95 | //} | |
96 | return ptr; | |
97 | } | |
98 | ||
99 | // Unless SS_PRAY_MODE is #defined, these macros provide a degree of | |
100 | // type safely if downcasting from a SS_Node* (or SS_Strand*). They | |
101 | // are especially useful in ASI st64/ld64 routines. | |
102 | #ifdef SS_PRAY_MODE | |
103 | #define SS_NODE_CAST(T,P) (T)(P) | |
104 | #define SS_STRAND_CAST(T,P) (T)(P) | |
105 | #else /* SS_PRAY_MODE */ | |
106 | #define SS_NODE_CAST(T,P) dynamic_cast<T>(P) | |
107 | #define SS_STRAND_CAST(T,P) (T)((*(uint64_t*)(P))!=0?0:(P)) | |
108 | #endif /* SS_PRAY_MODE */ | |
109 | ||
110 | #endif |