Changeset 36254 in vbox for trunk/include/VBox/sup.h
- Timestamp:
- Mar 10, 2011 5:22:08 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/sup.h
r36220 r36254 31 31 #include <iprt/assert.h> 32 32 #include <iprt/stdarg.h> 33 #include <iprt/cpuset.h> 33 34 34 35 RT_C_DECLS_BEGIN … … 87 88 } SUPPAGINGMODE; 88 89 89 90 #pragma pack(1) /* paranoia */ 90 #ifdef SUP_WITH_LOTS_OF_CPUS 91 # ifndef RT_WITH_LOTS_OF_CPUS 92 # error "RT_WITH_LOTS_OF_CPUS must be defined with SUP_WITH_LOTS_OF_CPUS" 93 # endif 94 #endif 95 96 /** 97 * The CPU state. 98 */ 99 typedef enum SUPGIPCPUSTATE 100 { 101 /** Invalid CPU state / unused CPU entry. */ 102 SUPGIPCPUSTATE_INVALID = 0, 103 /** The CPU is not present. */ 104 SUPGIPCPUSTATE_ABSENT, 105 /** The CPU is offline. */ 106 SUPGIPCPUSTATE_OFFLINE, 107 /** The CPU is online. */ 108 SUPGIPCPUSTATE_ONLINE, 109 /** Force 32-bit enum type. */ 110 SUPGIPCPUSTATE_32_BIT_HACK = 0x7fffffff 111 } SUPGIPCPUSTATE; 91 112 92 113 /** 93 114 * Per CPU data. 94 * This is only used when95 115 */ 96 116 typedef struct SUPGIPCPU … … 125 145 /** The interval between the last two NanoTS updates. (experiment for now) */ 126 146 volatile uint32_t u32PrevUpdateIntervalNS; 147 127 148 /** Reserved for future per processor data. */ 149 #ifdef SUP_WITH_LOTS_OF_CPUS 150 volatile uint32_t au32Reserved[5+5]; 151 #else 128 152 volatile uint32_t au32Reserved[5]; 153 #endif 154 155 /** @todo Add topology/NUMA info. */ 156 #ifdef SUP_WITH_LOTS_OF_CPUS 157 /** The CPU state. */ 158 SUPGIPCPUSTATE volatile enmState; 159 /** The host CPU ID of this CPU (the SUPGIPCPU is indexed by APIC ID). */ 160 RTCPUID idCpu; 161 /** The CPU set index of this CPU. */ 162 int16_t iCpuSet; 163 /** The APIC ID of this CPU. */ 164 uint16_t idApic; 165 #endif 129 166 } SUPGIPCPU; 167 #ifdef SUP_WITH_LOTS_OF_CPUS 168 AssertCompileSize(RTCPUID, 4); 169 AssertCompileSize(SUPGIPCPU, 128); 170 #else 130 171 AssertCompileSize(SUPGIPCPU, 96); 131 /*AssertCompileMemberAlignment(SUPGIPCPU, u64TSC, 8); -fixme */ 172 #endif 173 AssertCompileMemberAlignment(SUPGIPCPU, u64NanoTS, 8); 174 AssertCompileMemberAlignment(SUPGIPCPU, u64TSC, 8); 132 175 133 176 /** Pointer to per cpu data. … … 135 178 typedef SUPGIPCPU *PSUPGIPCPU; 136 179 180 181 182 #ifndef SUP_WITH_LOTS_OF_CPUS 137 183 /** The number of CPUs covered by the GIP. 138 184 * @remarks Must be a power of two! */ 139 #define SUPGLOBALINFOPAGE_CPUS 32 185 # define SUPGLOBALINFOPAGE_CPUS 32 186 #endif 140 187 141 188 /** … … 155 202 /** The GIP update mode, see SUPGIPMODE. */ 156 203 uint32_t u32Mode; 204 #ifdef SUP_WITH_LOTS_OF_CPUS 205 /** The number of entries in the CPU table. 206 * (This can work as RTMpGetArraySize().) */ 207 uint16_t cCpus; 208 /** The size of the GIP in pages. */ 209 uint16_t cPages; 210 #else 157 211 /** Reserved / padding. */ 158 212 uint32_t u32Padding0; 213 #endif 159 214 /** The update frequency of the of the NanoTS. */ 160 215 volatile uint32_t u32UpdateHz; … … 163 218 /** The timestamp of the last time we update the update frequency. */ 164 219 volatile uint64_t u64NanoTSLastUpdateHz; 220 #ifdef SUP_WITH_LOTS_OF_CPUS 221 /** The set of online CPUs. */ 222 RTCPUSET OnlineCpuSet; 223 /** The number of CPUs that are online. */ 224 volatile uint32_t cOnlineCpus; 225 /** The number of CPUs present in the system. */ 226 volatile uint32_t cPresentCpus; 227 /** The set of present CPUs. */ 228 RTCPUSET PresentCpuSet; 229 /** The set of possible CPUs. */ 230 RTCPUSET PossibleCpuSet; 231 /** The highest number of CPUs possible. */ 232 uint32_t cPossibleCpus; 233 /** The max CPU ID (RTMpGetMaxCpuId). */ 234 RTCPUID idCpuMax; 235 #endif 165 236 166 237 /** Padding / reserved space for future data. */ 238 #ifdef SUP_WITH_LOTS_OF_CPUS 239 uint32_t au32Padding1[28]; 240 #else 167 241 uint32_t au32Padding1[56]; 168 242 #endif 243 244 #ifdef SUP_WITH_LOTS_OF_CPUS 245 /** Table indexed by the CPU APIC ID to get the CPU table index. */ 246 uint16_t aiCpuFromApicId[256]; 247 /** CPU set index to CPU table index. */ 248 uint16_t aiCpuFromCpuSetIdx[RTCPUSET_MAX_CPUS]; 249 #endif 250 251 #ifdef SUP_WITH_LOTS_OF_CPUS 252 /** Array of per-cpu data. 253 * This is index by ApicId via the aiCpuFromApicId table. 254 * 255 * The clock and frequency information is updated for all CPUs if u32Mode 256 * is SUPGIPMODE_ASYNC_TSC, otherwise (SUPGIPMODE_SYNC_TSC) only the first 257 * entry is updated. */ 258 SUPGIPCPU aCPUs[1]; 259 #else 169 260 /** Array of per-cpu data. 170 261 * If u32Mode == SUPGIPMODE_SYNC_TSC then only the first entry is used. … … 172 263 * index into the array. */ 173 264 SUPGIPCPU aCPUs[SUPGLOBALINFOPAGE_CPUS]; 265 #endif 174 266 } SUPGLOBALINFOPAGE; 267 #ifndef SUP_WITH_LOTS_OF_CPUS 175 268 AssertCompile(sizeof(SUPGLOBALINFOPAGE) <= 0x1000); 176 /* AssertCompileMemberAlignment(SUPGLOBALINFOPAGE, aCPU, 32); - fixme */ 269 #endif 270 #ifdef SUP_WITH_LOTS_OF_CPUS 271 AssertCompileMemberAlignment(SUPGLOBALINFOPAGE, u64NanoTSLastUpdateHz, 8); 272 AssertCompileMemberAlignment(SUPGLOBALINFOPAGE, aCPUs[0], 256); 273 AssertCompileMemberAlignment(SUPGLOBALINFOPAGE, aCPUs[1], 128); 274 #endif 177 275 178 276 /** Pointer to the global info page. … … 180 278 typedef SUPGLOBALINFOPAGE *PSUPGLOBALINFOPAGE; 181 279 182 #pragma pack() /* end of paranoia */183 280 184 281 /** The value of the SUPGLOBALINFOPAGE::u32Magic field. (Soryo Fuyumi) */ … … 187 284 * Upper 16 bits is the major version. Major version is only changed with 188 285 * incompatible changes in the GIP. */ 189 #define SUPGLOBALINFOPAGE_VERSION 0x00020000 286 #ifdef SUP_WITH_LOTS_OF_CPUS 287 # define SUPGLOBALINFOPAGE_VERSION 0x00030000 288 #else 289 # define SUPGLOBALINFOPAGE_VERSION 0x00020000 290 #endif 190 291 191 292 /** … … 254 355 * Gets the TSC frequency of the calling CPU. 255 356 * 256 * @returns TSC frequency .357 * @returns TSC frequency, UINT64_MAX on failure. 257 358 * @param pGip The GIP pointer. 258 359 */ … … 262 363 263 364 if (RT_UNLIKELY(!pGip || pGip->u32Magic != SUPGLOBALINFOPAGE_MAGIC)) 264 return ~(uint64_t)0;365 return UINT64_MAX; 265 366 266 367 if (pGip->u32Mode != SUPGIPMODE_ASYNC_TSC) … … 268 369 else 269 370 { 371 # ifdef SUP_WITH_LOTS_OF_CPUS 372 iCpu = pGip->aiCpuFromApicId[ASMGetApicId()]; 373 if (iCpu >= pGip->cCpus) 374 return UINT64_MAX; 375 # else 270 376 iCpu = ASMGetApicId(); 271 377 if (RT_UNLIKELY(iCpu >= RT_ELEMENTS(pGip->aCPUs))) 272 return ~(uint64_t)0; 378 return UINT64_MAX; 379 # endif 273 380 } 274 381
Note:
See TracChangeset
for help on using the changeset viewer.