Files
@ d0a14f973771
Branch filter:
Location: vmkdrivers/BLD/build/HEADERS/vmkapi-current-all-public/vmkernel64/release/core/vmkapi_spinlock.h - annotation
d0a14f973771
10.4 KiB
text/x-chdr
ESXi-5.0-U1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 | 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e 763922b5834e | /* **********************************************************
* Copyright 2010 VMware, Inc. All rights reserved.
* **********************************************************/
/*
* @VMKAPIMOD_LICENSE@
*/
/*
******************************************************************************
* Spin Locks */ /**
*
* \addtogroup Core
* @{
* \defgroup SpinLocks Spin Locks
* @{
*
******************************************************************************
*/
#ifndef _VMKAPI_SPINLOCKS_H_
#define _VMKAPI_SPINLOCKS_H_
/** \cond never */
#ifndef VMK_HEADER_INCLUDED_FROM_VMKAPI_H
#error This vmkapi file should never be included directly but only via vmkapi.h
#endif
/** \endcond never */
/** Invalid lock handle */
#define VMK_LOCK_INVALID ((vmk_Lock)-1)
/** Invalid lock rank */
#define VMK_SPINLOCK_RANK_INVALID (0)
/** Lock rank for unranked locks */
#define VMK_SPINLOCK_UNRANKED (0xFFFF)
/**
* \brief Lock Handle
*/
typedef struct vmk_LockInt *vmk_Lock;
/**
* Spinlock Types
*/
typedef enum vmk_SpinlockType {
/** Spinlock usable from a world context */
VMK_SPINLOCK = 1,
/** Spinlock usable from a world and interrupt handler context */
VMK_SPINLOCK_IRQ = 2,
/** RW Spinlock usable from a world context */
VMK_SPINLOCK_RW = 3,
} vmk_SpinlockType;
/**
* \brief Rank for locks
*/
typedef vmk_uint16 vmk_LockRank;
/**
* Spinlock Creation Properties
*/
typedef struct vmk_SpinlockCreateProps {
/** Module ID for which the spinlock is created */
vmk_ModuleID moduleID;
/** Heap from which the spinlock will be allocated */
vmk_HeapID heapID;
/** Name of the spinlock */
vmk_Name name;
/** Type of the lock */
vmk_SpinlockType type;
/**
* Domain in which the spinlock will be rank checked in. If domain is set to
* invalid then the rank also has to be set to invalid and vice versa.
*/
vmk_LockDomainID domain;
/** Rank of the spinlock. May only be set if domain is set to a valid value. */
vmk_LockRank rank;
} vmk_SpinlockCreateProps;
/*
******************************************************************************
* vmk_SpinlockCreate -- */ /**
*
* \brief Allocate and initialize a spinlock
*
* Creates a new spinlock initializes it.
*
* \param[in] props Pointer to a valid vmk_SpinlockCreateProps struct
* \param[out] lock Pointer to the initialized spinlock
*
* \retval VMK_OK on success, error code otherwise
*
* \note Spinlocks can only be created from a world context
* \note This function will not block
*
******************************************************************************
*/
VMK_ReturnStatus
vmk_SpinlockCreate(vmk_SpinlockCreateProps *props,
vmk_Lock *lock);
/*
******************************************************************************
* vmk_SpinlockDestroy -- */ /**
*
* \brief Destroy a spinlock previously created with vmk_SpinlockCreate
*
* Destroy the given lock and free the allocated memory
*
* \param[in] lock Pointer to the spinlock
*
* \note This function will not block
*
******************************************************************************
*/
void
vmk_SpinlockDestroy(vmk_Lock lock);
/*
******************************************************************************
* vmk_SpinlockAllocSize */ /**
*
* \brief Size of an allocated spinlock of the specified type
*
* \result Allocation size
*
* \note This function will not block
*
******************************************************************************
*/
vmk_ByteCountSmall
vmk_SpinlockAllocSize(vmk_SpinlockType type);
/*
******************************************************************************
* vmk_SpinlockLock -- */ /**
*
* Acquire a spinlock of type VMK_SPINLOCK
*
* \param[in,out] lock Spinlock to be acquired
*
* \return VMK_OK on success, error code otherwise
*
* \note Lock checks are only executed when enabled for a given build. They
* are always enabled for debug builds.
* \note A caller has to release the spinlock with a subsequent call to
* vmk_SpinlockUnlock
* \note Callers are required to minimize the time and code that is executed
* while any type of spinlock is held.
* \note This function will not block
*
******************************************************************************
*/
VMK_ReturnStatus
vmk_SpinlockLock(vmk_Lock lock);
/*
******************************************************************************
* vmk_SpinlockLockIRQ -- */ /**
*
* Acquire a spinlock of type VMK_SPINLOCK_IRQ
*
* \param[in,out] lock IRQ Spinlock to be acquired
*
* \return VMK_OK on success, error code otherwise
*
* \note Lock checks are only executed when enabled for a given build. They
* are always enabled for debug builds.
* \note A caller has to release the spinlock with a subsequent call to
* vmk_SpinlockUnlockIRQ
* \note Callers are required to minimize the time and code that is executed
* while any type of spinlock is held.
* \note This function will not block
*
******************************************************************************
*/
VMK_ReturnStatus
vmk_SpinlockLockIRQ(vmk_Lock lock);
/*
******************************************************************************
* vmk_SpinlockReadLock -- */ /**
*
* Acquire a spinlock of type VMK_SPINLOCK_RW for reading
*
* \param[in,out] lock R/W Spinlock to be acquired
*
* \return VMK_OK on success, error code otherwise
*
* \note Lock checks are only executed when enabled for a given build. They
* are always enabled for debug builds.
* \note A caller has to release the spinlock with a subsequent call to
* vmk_SpinlockReadUnlock
* \note Callers are required to minimize the time and code that is executed
* while any type of spinlock is held.
* \note This function will not block
*
******************************************************************************
*/
VMK_ReturnStatus
vmk_SpinlockReadLock(vmk_Lock lock);
/*
******************************************************************************
* vmk_SpinlockWriteLock -- */ /**
*
* Acquire a spinlock of type VMK_SPINLOCK_RW for an exclusive write operation
*
* \param[in,out] lock R/W Spinlock to be acquired
*
* \return VMK_OK on success, error code otherwise
*
* \note Lock checks are only executed when enabled for a given build. They
* are always enabled for debug builds.
* \note A caller has to release the spinlock with a subsequent call to
* vmk_SpinlockUnlock
* \note Callers are required to minimize the time and code that is executed
* while any type of spinlock is held.
* \note This function will not block
*
******************************************************************************
*/
VMK_ReturnStatus
vmk_SpinlockWriteLock(vmk_Lock lock);
/*
******************************************************************************
* vmk_SpinlockUnlock -- */ /**
*
* Release a spinlock previously acquired via vmk_SpinlockLock
*
* \param[in,out] lock Spinlock to be released
*
* \note Callers are required to release spinlocks in the reverse order in which
* they were acquired
* \note This function will not block
*
******************************************************************************
*/
void
vmk_SpinlockUnlock(vmk_Lock lock);
/*
******************************************************************************
* vmk_SpinlockUnlockIRQ -- */ /**
*
* Release a IRQ spinlock previously acquired via vmk_SpinlockLockIRQ
*
* \param[in,out] lock IRQ Spinlock to be released
*
* \note Callers are required to release spinlocks in the reverse order in which
* they were acquired
* \note This function will not block
*
******************************************************************************
*/
void
vmk_SpinlockUnlockIRQ(vmk_Lock lock);
/*
******************************************************************************
* vmk_SpinlockReadUnlock -- */ /**
*
* Release a R/W spinlock previously acquired via vmk_SpinlockReadLock
*
* \param[in,out] lock Spinlock to be released
*
* \note Callers are required to release spinlocks in the reverse order in which
* they were acquired
* \note This function will not block
*
******************************************************************************
*/
void
vmk_SpinlockReadUnlock(vmk_Lock lock);
/*
******************************************************************************
* vmk_SpinlockWriteUnlock -- */ /**
*
* Release a R/W spinlock previously acquired via vmk_SpinlockWriteLock
*
* \param[in,out] lock Spinlock to be released
*
* \note Callers are required to release spinlocks in the reverse order in which
* they were acquired
* \note This function will not block
*
******************************************************************************
*/
void
vmk_SpinlockWriteUnlock(vmk_Lock lock);
/*
******************************************************************************
* vmk_SpinlockAssertHeldOnPCPUInt --
*
* This is used by vmk_SpinlockAssertHeldOnPCPU(). VMKAPI clients should not
* call this function directly.
*
* \note This function will not block
*
******************************************************************************
*/
/** \cond nodoc */
void
vmk_SpinlockAssertHeldOnPCPUInt(vmk_Lock lock);
/** \endcond */
/*
******************************************************************************
* vmk_SpinlockAssertHeldOnPCPU -- */ /**
*
* \brief Asserts that a lock is held on the current PCPU
*
* \param[in] lock Lock to check
*
* \note Checks are only executed on debug builds.
* \note This function will not block
*
******************************************************************************
*/
static VMK_ALWAYS_INLINE void
vmk_SpinlockAssertHeldOnPCPU(
vmk_Lock lock)
{
#ifdef VMX86_DEBUG
vmk_SpinlockAssertHeldOnPCPUInt(lock);
#endif
}
#endif
/** @} */
/** @} */
|