Files
@ d6b9b2ac5869
Branch filter:
Location: vmkdrivers/BLD/build/HEADERS/vmkapi-current-all-public-bincomp/vmkernel64/release/base/vmkapi_module.h
d6b9b2ac5869
26.2 KiB
text/x-chdr
ESXi-5.5-U2
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 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 | /* **********************************************************
* Copyright 1998 - 2009 VMware, Inc. All rights reserved.
* **********************************************************/
/*
* @VMKAPIMOD_LICENSE@
*/
/*
***********************************************************************
* Module */ /**
* \defgroup Module Kernel Module Management
*
* @{
***********************************************************************
*/
#ifndef _VMKAPI_MODULE_H_
#define _VMKAPI_MODULE_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 */
#include "vmkapi_module_int.h"
#include "vmkapi_module_ns.h"
/**
* \brief Module stack element.
*/
typedef struct vmk_ModInfoStack {
/** \brief Module ID. */
vmk_ModuleID modID;
/** \brief Module function called. */
void *mod_fn;
/** \brief Return address of caller. */
void *pushRA;
/** \brief Next module stack element. */
struct vmk_ModInfoStack *oldStack;
} vmk_ModInfoStack;
/**
* \brief Guaranteed invalid module ID.
*/
#define VMK_INVALID_MODULE_ID ((vmk_uint32)-1)
/**
* \brief Module ID for vmkernel itself.
*/
#define VMK_VMKERNEL_MODULE_ID 0
/**
* \brief VMware proprietary code
*/
#define VMK_MODULE_LICENSE_VMWARE "VMware"
/**
* \brief GPLv2
*/
#define VMK_MODULE_LICENSE_GPLV2 "GPLv2"
/**
* \brief BSD compatibile license
*/
#define VMK_MODULE_LICENSE_BSD "BSD"
/*
***********************************************************************
* VMK_MODPARAM_NAMED -- */ /**
*
* \ingroup Module
*
* \brief Define a parameter set by the user during module load.
*
* \param[in] name Name of the parameter.
* \param[in] var Name of variable to store parameter value.
* \param[in] type Type of the variable.
* \param[in] desc String describing the variable.
*
***********************************************************************
*/
#define VMK_MODPARAM_NAMED(name, var, type, desc) \
__VMK_MODPARAM_NAMED(name, var, type); \
__VMK_MODPARAM_DESC(name, desc)
/*
***********************************************************************
* VMK_MODPARAM -- */ /**
*
* \ingroup Module
* \brief Define a parameter set by the user during module load.
*
* \note This macro relies on having a variable with the same name
* as the parameter. If your variable has a different name
* than the parameter name, use VMK_MODPARAM_NAMED.
*
* \param[in] name Name of the parameter and variable.
* \param[in] type Type of the variable.
* \param[in] desc String describing the variable.
*
***********************************************************************
*/
#define VMK_MODPARAM(name, type, desc) \
VMK_MODPARAM_NAMED(name, name, type, desc)
/*
***********************************************************************
* VMK_MODPARAM_ARRAY_NAMED -- */ /**
*
* \ingroup Module
*
* \brief Define an array parameter that can be set by the user during
* module load.
*
* \param[in] name Name of parameter.
* \param[in] var Name of array variable.
* \param[in] type Type of array elements.
* \param[in] nump Variable to store count of set elements.
* \param[in] desc String describing the variable.
*
***********************************************************************
*/
#define VMK_MODPARAM_ARRAY_NAMED(name, var, type, nump, desc) \
__VMK_MODPARAM_ARRAY_NAMED(name, var, type, nump); \
__VMK_MODPARAM_DESC(name, desc)
/*
***********************************************************************
* VMK_MODPARAM_ARRAY -- */ /**
*
* \ingroup Module
*
* \brief Define an array parameter that can be set by the user during
* module load.
*
* \note This macro relies on having a variable with the same name
* as the parameter. If your variable has a different name
* than the parameter name, use VMK_MODPARAM_NAMED.
*
* \param[in] name Name of parameter and variable.
* \param[in] type Type of array elements.
* \param[in] nump Variable to store count of set elements.
* \param[in] desc String describing the variable.
*
***********************************************************************
*/
#define VMK_MODPARAM_ARRAY(name, type, nump, desc) \
VMK_MODPARAM_ARRAY_NAMED(name, name, type, nump, desc)
/*
***********************************************************************
* VMK_MODPARAM_STRING_NAMED -- */ /**
*
* \ingroup Module
* \brief Define an string parameter that can be set by the user
* during module load.
*
* \note This creates a copy of the string; your variable must be an
* array of sufficient size to hold the copy. If you do not
* need to modify the string consider using a charp type.
*
* \param[in] name Name of parameter.
* \param[in] string Variable name for the string copy.
* \param[in] len Maximum length of string.
* \param[in] desc String describing the variable.
*
***********************************************************************
*/
#define VMK_MODPARAM_STRING_NAMED(name, string, len, desc) \
__VMK_MODPARAM_STRING_NAMED(name, string, len); \
__VMK_MODPARAM_DESC(name, desc)
/*
***********************************************************************
* VMK_MODPARAM_STRING -- */ /**
*
* \ingroup Module
* \brief Define an string parameter that can be set by the user
* during module load.
*
* \note This creates a copy of the string; your variable must be an
* array of sufficient size to hold the copy. If you do not
* need to modify the string consider using a charp type.
*
* \param[in] name Name of parameter and char array variable.
* \param[in] len Maximum length of string.
* \param[in] desc String describing the variable.
*
***********************************************************************
*/
#define VMK_MODPARAM_STRING(name, len, desc) \
VMK_MODPARAM_STRING_NAMED(name, name, len, desc)
/*
***********************************************************************
* VMK_VERSION_INFO -- */ /**
*
* \ingroup Module
* \brief Free-form string parameter describing version, build,
* etc. information.
*
* \param[in] string A string to be embedded as version information.
*
***********************************************************************
*/
#define VMK_VERSION_INFO(string) \
__VMK_VERSION_INFO(string)
/*
***********************************************************************
* VMK_LICENSE_INFO -- */ /**
*
* \ingroup Module
* \brief A predefined string describing the license this module is
* released under.
*
* This macro adds a license string to the module. The license string
* determines symbol binding rules. For instance, a module released under
* a non-GPL license can only bind to symbols exported by non-GPL modules,
* but it can not bind to symbols provided by GPL modules. A module
* released under a GPL license can bind to symbols exported by GPL and
* non-GPL modules.
*
* \note This macro should only be used if you release your code under
* a license described by the predefined license strings such as
* VMK_MODULE_LICENSE_*, otherwise please use macro
* VMK_THIRD_PARTY_LICENSE_INFO.
*
* \param[in] string A string to be embedded as the license type. Only
* the predefined license strings such as
* VMK_MODULE_LICENSE_* are acceptable. The use of
* other license strings may cause the module to
* fail to load.
*
***********************************************************************
*/
#define VMK_LICENSE_INFO(string) \
__VMK_LICENSE_INFO(string)
/*
***********************************************************************
* VMK_THIRD_PARTY_LICENSE_INFO -- */ /**
*
* \ingroup Module
* \brief A string describing the license this module is released
* under.
*
* This macro adds a license string to the module. The license string
* determines symbol binding rules. A module released under a third
* party license can only bind to symbols exported by non-GPL modules.
*
* \note This macro should be used if you release your code under
* a license that is not covered by the predefined license strings
* such as VMK_MODULE_LICENSE_*, e.g., under your company's
* license.
*
* \note This macro accepts any provided string as a valid license
* string, in contrast to macro VMK_LICENSE_INFO which only
* accepts predefined license strings.
*
* \param[in] string A string to be embedded as the license type. The
* predefined license strings as VMK_MODULE_LICENSE_*
* should not be used with this macro.
*
***********************************************************************
*/
#define VMK_THIRD_PARTY_LICENSE_INFO(string) \
__VMK_LICENSE_INFO(__VMK_MODULE_LICENSE_THIRD_PARTY ":" string)
/*
***********************************************************************
* vmk_ModuleRegister -- */ /**
*
* \ingroup Module
* \brief Register a module with the VMKernel
*
* \pre The module shall not call any VMKernel function before this
* function has been invoked and has returned.
*
* \note A module should make a successful call to this function only
* once inside its initalization function, else undefined
* behavior may occur.
*
* \note This function may block.
*
* \param[out] id The address of a variable to store
* the module's module ID handle.
* \param[in] vmkApiModRevision The module version for compatability
* checks.
*
***********************************************************************
*/
VMK_ReturnStatus vmk_ModuleRegister(
vmk_ModuleID *id,
vmk_uint32 vmkApiModRevision);
/*
***********************************************************************
* vmk_ModuleUnregister -- */ /**
*
* \ingroup Module
* \brief Unregister a module with the VMKernel
*
* \pre The module shall not have any VMKernel call in progress at
* the time this function is invoked, nor initiate any VMKernel
* call after it has been invoked.
*
* \note The module ID handle will be invalid after the success of
* this call and should not be used again.
*
* \note This function may block.
*
* \param[in] id The module ID handle to unregister.
*
***********************************************************************
*/
VMK_ReturnStatus vmk_ModuleUnregister(
vmk_ModuleID id);
/*
***********************************************************************
* vmk_ModuleSetHeapID -- */ /**
*
* \ingroup Module
* \brief Set a module's default heap
*
* Any vmkapi call that does not take an explicit heap that also has
* a side effect of allocating storage will use the heap passed to this
* function.
*
* \note This function will not block.
*
* \pre The default heap may only be assigned once. Subsequent
* assignments will be ignored.
*
***********************************************************************
*/
void vmk_ModuleSetHeapID(
vmk_ModuleID module,
vmk_HeapID heap);
/*
***********************************************************************
* vmk_ModuleGetHeapID -- */ /**
*
* \ingroup Module
* \brief Query a module's default heap
*
* \note This function will not block.
*
* \return The calling module's current default heap.
* \retval VMK_INVALID_HEAP_ID The module has no default heap.
*
***********************************************************************
*/
vmk_HeapID vmk_ModuleGetHeapID(
vmk_ModuleID module);
/*
***********************************************************************
* vmk_ModuleGetID -- */ /**
*
* \ingroup Module
* \brief Get the identifier of the VMKernel module
*
* \note This function will not block.
*
* \param[in] moduleName Name of the module to find.
*
* \return The module ID of the module with the specified name.
* \retval VMK_INVALID_MODULE_ID No module with the specified name
* was found.
*
***********************************************************************
*/
vmk_ModuleID vmk_ModuleGetID(
const char *moduleName);
/*
***********************************************************************
* vmk_ModuleGetName -- */ /**
*
* \ingroup Module
* \brief Get the name associated with a module.
*
* \note This function will not block.
*
* \note This call will return an error when called to retrieve the
* name of a module that has not yet returned from the module
* init function.
*
* \param[in] module The module ID to query.
* \param[out] moduleName A character buffer large enough to hold the
* module name including the terminating nul.
* \param[in] len The length of the character buffer in bytes.
*
* \retval VMK_NOT_FOUND The module ID was not found.
* \retval VMK_BAD_PARAM The buffer isn't large enough to hold
* the module's string name.
*
***********************************************************************
*/
VMK_ReturnStatus vmk_ModuleGetName(
vmk_ModuleID module,
char *moduleName,
vmk_ByteCountSmall len);
/*
***********************************************************************
* vmk_ModuleGetDebugID -- */ /**
*
* \ingroup Module
* \brief Convert a vmk_ModuleID to a 64-bit integer representation.
* This should not be used be used for anything other than a
* short-hand in debugging output.
*
* \note This function will not block.
*
* \param[in] module The module id.
*
***********************************************************************
*/
vmk_uint64 vmk_ModuleGetDebugID(vmk_ModuleID module);
/*
***********************************************************************
* vmk_ModuleIncUseCount -- */ /**
*
* \ingroup Module
* \brief Increment a module's reference count
*
* \note This function will not block.
*
* Any attempt to remove the module with \c vmkload_mod -u will fail
* while the module's reference count is non nul.
*
* \param[in] module Module to increment the reference count for.
*
* \retval VMK_OK The reference count was successfully
* incremented
* \retval VMK_NOT_FOUND The module doesn't exist
* \retval VMK_MODULE_NOT_LOADED The module is being unloaded
*
***********************************************************************
*/
VMK_ReturnStatus vmk_ModuleIncUseCount(
vmk_ModuleID module);
/*
***********************************************************************
* vmk_ModuleDecUseCount -- */ /**
*
* \ingroup Module
* \brief Decrement a module's reference count.
*
* \note This function will not block.
*
* \param[in] module Module to decrement the reference count for.
*
* \retval VMK_OK The reference count was successfully
* decremented.
* \retval VMK_NOT_FOUND The module doesn't exist.
* \retval VMK_MODULE_NOT_LOADED The module is being unloaded.
*
***********************************************************************
*/
VMK_ReturnStatus vmk_ModuleDecUseCount(
vmk_ModuleID module);
/*
***********************************************************************
* vmk_ModulePushId -- */ /**
*
* \ingroup Module
* \brief Push moduleID onto module tracking stack before an
* inter-module call.
*
* \note This function will not block.
*
* \deprecated This call should no longer be called directly as it is
* likely to go away in a future release.
*
* \param[in] moduleID Module ID from which the inter-module call
* is to be made.
* \param[in] function Address of the inter-module function call
* \param[in] modStack Pointer to a vmk_ModInfoStack struct,
* preferrably on the stack.
*
* \retval VMK_OK The moduleID was sucessfully pushed
* onto the module stack
* \retval VMK_MODULE_NOT_LOADED Module was not found
*
***********************************************************************
*/
VMK_ReturnStatus vmk_ModulePushId(
vmk_ModuleID moduleID,
void *function,
vmk_ModInfoStack *modStack);
/*
***********************************************************************
* vmk_ModulePopId -- */ /**
*
* \ingroup Module
* \brief Pop moduleID off of module tracking stack after an
* inter-module call.
*
* \note This function will not block.
*
* \deprecated This call should no longer be called directly as it is
* likely to go away in a future release.
*
***********************************************************************
*/
void vmk_ModulePopId(void);
/*
***********************************************************************
* vmk_ModuleStackTop -- */ /**
*
* \ingroup Module
* \brief Get the latest moduleID pushed onto the module tracking stack.
*
* \note This function will not block.
*
* \retval The moduleID at the top of the module tracking stack.
*
***********************************************************************
*/
vmk_ModuleID vmk_ModuleStackTop(void);
/*
***********************************************************************
* VMKAPI_MODULE_CALL -- */ /**
*
* \ingroup Module
* \brief Macro wrapper for inter-module calls that return a value.
*
* This wrapper should always be used when calling into another module
* so that vmkernel can properly track resources associated with
* a call.
*
* \param[in] moduleID moduleID of the calling module.
* \param[out] returnValue Variable to hold the return value from
* the called function.
* \param[in] function Inter-module function call to be
* invoked.
* \param[in,out] args Arguments to pass to the inter-module
* function call.
*
***********************************************************************
*/
#define VMKAPI_MODULE_CALL(moduleID, returnValue, function, args...) \
do { \
vmk_ModInfoStack modStack; \
vmk_ModulePushId(moduleID, function, &modStack) ; \
VMK_DEBUG_ONLY(vmk_Bool intsEnabledOnEntry = vmk_CPUHasIntsEnabled();) \
returnValue = (function)(args); \
VMK_DEBUG_ONLY( \
if (intsEnabledOnEntry != vmk_CPUHasIntsEnabled()) { \
vmk_Panic("Function %p in module %d %sabled interrupts", \
function, moduleID, intsEnabledOnEntry ? "dis" : "en"); \
} \
) \
vmk_ModulePopId(); \
} while(0)
/*
***********************************************************************
* VMKAPI_MODULE_CALL_VOID -- */ /**
*
* \ingroup Module
* \brief Macro wrapper for inter-module calls that do not return
* a value.
*
* This wrapper should always be used when calling into another module
* so that vmkernel can properly track resources associated with
* a call.
*
* \param[in] moduleID moduleID of the calling module
* \param[in] function Inter-module function call to be invoked
* \param[in,out] args Arguments to pass to the inter-module
* function call
*
***********************************************************************
*/
#define VMKAPI_MODULE_CALL_VOID(moduleID, function, args...) \
do { \
vmk_ModInfoStack modStack; \
vmk_ModulePushId(moduleID, function, &modStack); \
VMK_DEBUG_ONLY(vmk_Bool intsEnabledOnEntry = vmk_CPUHasIntsEnabled();) \
(function)(args); \
VMK_DEBUG_ONLY( \
if (intsEnabledOnEntry != vmk_CPUHasIntsEnabled()) { \
vmk_Panic("Function %p in module %d %sabled interrupts", \
function, moduleID, intsEnabledOnEntry ? "dis" : "en"); \
} \
) \
vmk_ModulePopId(); \
} while(0)
/*
***********************************************************************
* VMK_MODULE_EXPORT_SYMBOL -- */ /**
*
* \ingroup Module
* \brief Mark a symbol as exported
*
* Mark the given symbol as exported (and hence available for other
* modules to find/call) within the name-space and version of the
* current module (as specified by VMK_NAMESPACE_PROVIDES())
*
* \note Although exported symbols are encapsulated within the modules
* provided name-space, exported symbols are required to have a
* globally unique name. This is because there are no restrictions on
* what combinations of name-spaces any given module may request,
* leading to potential unresolvable collisions if a module requested
* two name-spaces that provided the same symbol.
*
* \param[in] symname The symbol to export.
*
***********************************************************************
*/
#define VMK_MODULE_EXPORT_SYMBOL(symname) \
__VMK_MODULE_EXPORT_SYMBOL(symname)
/*
***********************************************************************
* VMK_MODULE_EXPORT_SYMBOL_ALIASED -- */ /**
*
* \ingroup Module
* \brief Re-export a symbol under an aliased name
*
* Re-export the given original symbol "symname" as "alias" within the
* name-space and version of the current module (as specified by
* VMK_NAMESPACE_PROVIDES()). "symname" must be either:
*
* - an internal global (i.e. not static) symbol of the current
* module, or
* - be present by virtue of being exported by another module, and the
* current module must contain the correct VMK_NAMESPACE_REQUIRED()
* invocation such that the original symbol can be found.
*
* "alias" must be globally unqiue.
*
* \note Calls via this alias incur no overheads, as referencing the
* alias results in the function address of the original symbol.
*
* \param[in] symname The symbol to export.
* \param[in] alias The publicly exported name
*
***********************************************************************
*/
#define VMK_MODULE_EXPORT_SYMBOL_ALIASED(symname, alias) \
__VMK_MODULE_EXPORT_SYMBOL_ALIASED(symname, alias)
/*
***********************************************************************
* VMK_MODULE_EXPORT_ALIAS -- */ /**
*
* \ingroup Module
* \brief Re-export an already exported symbol
*
* Re-export the given original symbol "symname" within the name-space
* and version of the current module (as specified by
* VMK_NAMESPACE_PROVIDES()). The original symbol must be present by
* virtue of being exported by another module, and the current module
* must contain the correct VMK_NAMESPACE_REQUIRED() invocation such
* that the original symbol can be found.
*
* \note Calls via this alias incur no overheads, as referencing the
* alias results in the function address of the original symbol.
*
* \param[in] symname The name of the original symbol to re-export
*
***********************************************************************
*/
#define VMK_MODULE_EXPORT_ALIAS(symname) \
__VMK_MODULE_EXPORT_SYMBOL_ALIASED(symname, symname)
/*
***********************************************************************
* VMK_NAMESPACE_REQUIRED -- */ /**
*
* \ingroup Module
* \brief Mark this module as requiring a name-space at a given version
*
* Mark the module as requiring a name-space "namespace" at "version".
* There is no limit on the number of name-spaces a module may require.
*
* \note The namespace and version parameters may not contain the
* restricted character VMK_NS_VER_SEPARATOR. Including this
* character may cause the module to fail to load.
*
* \param[in] namespace The name-space
* \param[in] version The version of this name-space
*
***********************************************************************
*/
#define VMK_NAMESPACE_REQUIRED(namespace, version) \
__VMK_NAMESPACE_REQUIRED(namespace, version)
/*
***********************************************************************
* VMK_NAMESPACE_PROIVDES -- */ /**
*
* \ingroup Module
* \brief Mark this module as providing a name-space at a given version
*
* Mark the module as providing a name-space "namespace" at "version".
* Each module may provide only one name-space.
*
* \note The namespace and version parameters may not contain the
* restricted character VMK_NS_VER_SEPARATOR. Including this
* character may cause the module to fail to load.
*
* \param[in] namespace The name-space
* \param[in] version The version of this name-space
*
***********************************************************************
*/
#define VMK_NAMESPACE_PROVIDES(namespace, version) \
__VMK_NAMESPACE_PROVIDES(namespace, version)
#endif /* _VMKAPI_MODULE_H_ */
/** @} */
|