UefiBootServicesTableLibUnitTest.h 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042
  1. /** @file
  2. An internal header file for the Unit Test instance of the UEFI Boot Services Table Library.
  3. This file includes common header files, defines internal structure and functions used by
  4. the library implementation.
  5. Copyright (c) Microsoft Corporation
  6. SPDX-License-Identifier: BSD-2-Clause-Patent
  7. **/
  8. #ifndef UEFI_BOOT_SERVICES_TABLE_LIB_UNIT_TEST_H_
  9. #define UEFI_BOOT_SERVICES_TABLE_LIB_UNIT_TEST_H_
  10. #include <Uefi.h>
  11. #include <Pi/PiMultiPhase.h>
  12. #include <Library/BaseLib.h>
  13. #include <Library/BaseMemoryLib.h>
  14. #include <Library/DebugLib.h>
  15. #include <Library/MemoryAllocationLib.h>
  16. #include <Library/UnitTestLib.h>
  17. #include <Library/UefiBootServicesTableLib.h>
  18. /**
  19. Raise the task priority level to the new level.
  20. High level is implemented by disabling processor interrupts.
  21. @param NewTpl New task priority level
  22. @return The previous task priority level
  23. **/
  24. EFI_TPL
  25. EFIAPI
  26. UnitTestRaiseTpl (
  27. IN EFI_TPL NewTpl
  28. );
  29. /**
  30. Lowers the task priority to the previous value. If the new
  31. priority unmasks events at a higher priority, they are dispatched.
  32. @param NewTpl New, lower, task priority
  33. **/
  34. VOID
  35. EFIAPI
  36. UnitTestRestoreTpl (
  37. IN EFI_TPL NewTpl
  38. );
  39. /**
  40. Allocates pages from the memory map.
  41. @param Type The type of allocation to perform
  42. @param MemoryType The type of memory to turn the allocated pages
  43. into
  44. @param NumberOfPages The number of pages to allocate
  45. @param Memory A pointer to receive the base allocated memory
  46. address
  47. @return Status. On success, Memory is filled in with the base address allocated
  48. @retval EFI_INVALID_PARAMETER Parameters violate checking rules defined in
  49. spec.
  50. @retval EFI_NOT_FOUND Could not allocate pages match the requirement.
  51. @retval EFI_OUT_OF_RESOURCES No enough pages to allocate.
  52. @retval EFI_SUCCESS Pages successfully allocated.
  53. **/
  54. EFI_STATUS
  55. EFIAPI
  56. UnitTestAllocatePages (
  57. IN EFI_ALLOCATE_TYPE Type,
  58. IN EFI_MEMORY_TYPE MemoryType,
  59. IN UINTN NumberOfPages,
  60. IN OUT EFI_PHYSICAL_ADDRESS *Memory
  61. );
  62. /**
  63. Frees previous allocated pages.
  64. @param Memory Base address of memory being freed
  65. @param NumberOfPages The number of pages to free
  66. @retval EFI_NOT_FOUND Could not find the entry that covers the range
  67. @retval EFI_INVALID_PARAMETER Address not aligned
  68. @return EFI_SUCCESS -Pages successfully freed.
  69. **/
  70. EFI_STATUS
  71. EFIAPI
  72. UnitTestFreePages (
  73. IN EFI_PHYSICAL_ADDRESS Memory,
  74. IN UINTN NumberOfPages
  75. );
  76. /**
  77. This function returns a copy of the current memory map. The map is an array of
  78. memory descriptors, each of which describes a contiguous block of memory.
  79. @param MemoryMapSize A pointer to the size, in bytes, of the
  80. MemoryMap buffer. On input, this is the size of
  81. the buffer allocated by the caller. On output,
  82. it is the size of the buffer returned by the
  83. firmware if the buffer was large enough, or the
  84. size of the buffer needed to contain the map if
  85. the buffer was too small.
  86. @param MemoryMap A pointer to the buffer in which firmware places
  87. the current memory map.
  88. @param MapKey A pointer to the location in which firmware
  89. returns the key for the current memory map.
  90. @param DescriptorSize A pointer to the location in which firmware
  91. returns the size, in bytes, of an individual
  92. EFI_MEMORY_DESCRIPTOR.
  93. @param DescriptorVersion A pointer to the location in which firmware
  94. returns the version number associated with the
  95. EFI_MEMORY_DESCRIPTOR.
  96. @retval EFI_SUCCESS The memory map was returned in the MemoryMap
  97. buffer.
  98. @retval EFI_BUFFER_TOO_SMALL The MemoryMap buffer was too small. The current
  99. buffer size needed to hold the memory map is
  100. returned in MemoryMapSize.
  101. @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
  102. **/
  103. EFI_STATUS
  104. EFIAPI
  105. UnitTestGetMemoryMap (
  106. IN OUT UINTN *MemoryMapSize,
  107. IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap,
  108. OUT UINTN *MapKey,
  109. OUT UINTN *DescriptorSize,
  110. OUT UINT32 *DescriptorVersion
  111. );
  112. /**
  113. Allocate pool of a particular type.
  114. @param PoolType Type of pool to allocate
  115. @param Size The amount of pool to allocate
  116. @param Buffer The address to return a pointer to the allocated
  117. pool
  118. @retval EFI_INVALID_PARAMETER PoolType not valid or Buffer is NULL
  119. @retval EFI_OUT_OF_RESOURCES Size exceeds max pool size or allocation failed.
  120. @retval EFI_SUCCESS Pool successfully allocated.
  121. **/
  122. EFI_STATUS
  123. EFIAPI
  124. UnitTestAllocatePool (
  125. IN EFI_MEMORY_TYPE PoolType,
  126. IN UINTN Size,
  127. OUT VOID **Buffer
  128. );
  129. /**
  130. Frees pool.
  131. @param Buffer The allocated pool entry to free
  132. @retval EFI_INVALID_PARAMETER Buffer is not a valid value.
  133. @retval EFI_SUCCESS Pool successfully freed.
  134. **/
  135. EFI_STATUS
  136. EFIAPI
  137. UnitTestFreePool (
  138. IN VOID *Buffer
  139. );
  140. /**
  141. Frees pool.
  142. @param Buffer The allocated pool entry to free
  143. @param PoolType Pointer to pool type
  144. @retval EFI_INVALID_PARAMETER Buffer is not a valid value.
  145. @retval EFI_SUCCESS Pool successfully freed.
  146. **/
  147. EFI_STATUS
  148. EFIAPI
  149. UnitTestInternalFreePool (
  150. IN VOID *Buffer,
  151. OUT EFI_MEMORY_TYPE *PoolType OPTIONAL
  152. );
  153. /**
  154. Creates an event.
  155. @param Type The type of event to create and its mode and
  156. attributes
  157. @param NotifyTpl The task priority level of event notifications
  158. @param NotifyFunction Pointer to the events notification function
  159. @param NotifyContext Pointer to the notification functions context;
  160. corresponds to parameter "Context" in the
  161. notification function
  162. @param Event Pointer to the newly created event if the call
  163. succeeds; undefined otherwise
  164. @retval EFI_SUCCESS The event structure was created
  165. @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value
  166. @retval EFI_OUT_OF_RESOURCES The event could not be allocated
  167. **/
  168. EFI_STATUS
  169. EFIAPI
  170. UnitTestCreateEvent (
  171. IN UINT32 Type,
  172. IN EFI_TPL NotifyTpl,
  173. IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL
  174. IN VOID *NotifyContext, OPTIONAL
  175. OUT EFI_EVENT *Event
  176. );
  177. /**
  178. Sets the type of timer and the trigger time for a timer event.
  179. @param UserEvent The timer event that is to be signaled at the
  180. specified time
  181. @param Type The type of time that is specified in
  182. TriggerTime
  183. @param TriggerTime The number of 100ns units until the timer
  184. expires
  185. @retval EFI_SUCCESS The event has been set to be signaled at the
  186. requested time
  187. @retval EFI_INVALID_PARAMETER Event or Type is not valid
  188. **/
  189. EFI_STATUS
  190. EFIAPI
  191. UnitTestSetTimer (
  192. IN EFI_EVENT UserEvent,
  193. IN EFI_TIMER_DELAY Type,
  194. IN UINT64 TriggerTime
  195. );
  196. /**
  197. Stops execution until an event is signaled.
  198. @param NumberOfEvents The number of events in the UserEvents array
  199. @param UserEvents An array of EFI_EVENT
  200. @param UserIndex Pointer to the index of the event which
  201. satisfied the wait condition
  202. @retval EFI_SUCCESS The event indicated by Index was signaled.
  203. @retval EFI_INVALID_PARAMETER The event indicated by Index has a notification
  204. function or Event was not a valid type
  205. @retval EFI_UNSUPPORTED The current TPL is not TPL_APPLICATION
  206. **/
  207. EFI_STATUS
  208. EFIAPI
  209. UnitTestWaitForEvent (
  210. IN UINTN NumberOfEvents,
  211. IN EFI_EVENT *UserEvents,
  212. OUT UINTN *UserIndex
  213. );
  214. /**
  215. Signals the event. Queues the event to be notified if needed.
  216. @param UserEvent The event to signal .
  217. @retval EFI_INVALID_PARAMETER Parameters are not valid.
  218. @retval EFI_SUCCESS The event was signaled.
  219. **/
  220. EFI_STATUS
  221. EFIAPI
  222. UnitTestSignalEvent (
  223. IN EFI_EVENT UserEvent
  224. );
  225. /**
  226. Closes an event and frees the event structure.
  227. @param UserEvent Event to close
  228. @retval EFI_INVALID_PARAMETER Parameters are not valid.
  229. @retval EFI_SUCCESS The event has been closed
  230. **/
  231. EFI_STATUS
  232. EFIAPI
  233. UnitTestCloseEvent (
  234. IN EFI_EVENT UserEvent
  235. );
  236. /**
  237. Check the status of an event.
  238. @param UserEvent The event to check
  239. @retval EFI_SUCCESS The event is in the signaled state
  240. @retval EFI_NOT_READY The event is not in the signaled state
  241. @retval EFI_INVALID_PARAMETER Event is of type EVT_NOTIFY_SIGNAL
  242. **/
  243. EFI_STATUS
  244. EFIAPI
  245. UnitTestCheckEvent (
  246. IN EFI_EVENT UserEvent
  247. );
  248. /**
  249. Wrapper function to UnitTestInstallProtocolInterfaceNotify. This is the public API which
  250. Calls the private one which contains a BOOLEAN parameter for notifications
  251. @param UserHandle The handle to install the protocol handler on,
  252. or NULL if a new handle is to be allocated
  253. @param Protocol The protocol to add to the handle
  254. @param InterfaceType Indicates whether Interface is supplied in
  255. native form.
  256. @param Interface The interface for the protocol being added
  257. @return Status code
  258. **/
  259. EFI_STATUS
  260. EFIAPI
  261. UnitTestInstallProtocolInterface (
  262. IN OUT EFI_HANDLE *UserHandle,
  263. IN EFI_GUID *Protocol,
  264. IN EFI_INTERFACE_TYPE InterfaceType,
  265. IN VOID *Interface
  266. );
  267. /**
  268. Reinstall a protocol interface on a device handle. The OldInterface for Protocol is replaced by the NewInterface.
  269. @param UserHandle Handle on which the interface is to be
  270. reinstalled
  271. @param Protocol The numeric ID of the interface
  272. @param OldInterface A pointer to the old interface
  273. @param NewInterface A pointer to the new interface
  274. @retval EFI_SUCCESS The protocol interface was installed
  275. @retval EFI_NOT_FOUND The OldInterface on the handle was not found
  276. @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value
  277. **/
  278. EFI_STATUS
  279. EFIAPI
  280. UnitTestReinstallProtocolInterface (
  281. IN EFI_HANDLE UserHandle,
  282. IN EFI_GUID *Protocol,
  283. IN VOID *OldInterface,
  284. IN VOID *NewInterface
  285. );
  286. /**
  287. Uninstalls all instances of a protocol:interfacer from a handle.
  288. If the last protocol interface is remove from the handle, the
  289. handle is freed.
  290. @param UserHandle The handle to remove the protocol handler from
  291. @param Protocol The protocol, of protocol:interface, to remove
  292. @param Interface The interface, of protocol:interface, to remove
  293. @retval EFI_INVALID_PARAMETER Protocol is NULL.
  294. @retval EFI_SUCCESS Protocol interface successfully uninstalled.
  295. **/
  296. EFI_STATUS
  297. EFIAPI
  298. UnitTestUninstallProtocolInterface (
  299. IN EFI_HANDLE UserHandle,
  300. IN EFI_GUID *Protocol,
  301. IN VOID *Interface
  302. );
  303. /**
  304. Queries a handle to determine if it supports a specified protocol.
  305. @param UserHandle The handle being queried.
  306. @param Protocol The published unique identifier of the protocol.
  307. @param Interface Supplies the address where a pointer to the
  308. corresponding Protocol Interface is returned.
  309. @return The requested protocol interface for the handle
  310. **/
  311. EFI_STATUS
  312. EFIAPI
  313. UnitTestHandleProtocol (
  314. IN EFI_HANDLE UserHandle,
  315. IN EFI_GUID *Protocol,
  316. OUT VOID **Interface
  317. );
  318. /**
  319. Add a new protocol notification record for the request protocol.
  320. @param Protocol The requested protocol to add the notify
  321. registration
  322. @param Event The event to signal
  323. @param Registration Returns the registration record
  324. @retval EFI_INVALID_PARAMETER Invalid parameter
  325. @retval EFI_SUCCESS Successfully returned the registration record
  326. that has been added
  327. **/
  328. EFI_STATUS
  329. EFIAPI
  330. UnitTestRegisterProtocolNotify (
  331. IN EFI_GUID *Protocol,
  332. IN EFI_EVENT Event,
  333. OUT VOID **Registration
  334. );
  335. /**
  336. Locates the requested handle(s) and returns them in Buffer.
  337. @param SearchType The type of search to perform to locate the
  338. handles
  339. @param Protocol The protocol to search for
  340. @param SearchKey Dependant on SearchType
  341. @param BufferSize On input the size of Buffer. On output the
  342. size of data returned.
  343. @param Buffer The buffer to return the results in
  344. @retval EFI_BUFFER_TOO_SMALL Buffer too small, required buffer size is
  345. returned in BufferSize.
  346. @retval EFI_INVALID_PARAMETER Invalid parameter
  347. @retval EFI_SUCCESS Successfully found the requested handle(s) and
  348. returns them in Buffer.
  349. **/
  350. EFI_STATUS
  351. EFIAPI
  352. UnitTestLocateHandle (
  353. IN EFI_LOCATE_SEARCH_TYPE SearchType,
  354. IN EFI_GUID *Protocol OPTIONAL,
  355. IN VOID *SearchKey OPTIONAL,
  356. IN OUT UINTN *BufferSize,
  357. OUT EFI_HANDLE *Buffer
  358. );
  359. /**
  360. Locates the handle to a device on the device path that best matches the specified protocol.
  361. @param Protocol The protocol to search for.
  362. @param DevicePath On input, a pointer to a pointer to the device
  363. path. On output, the device path pointer is
  364. modified to point to the remaining part of the
  365. devicepath.
  366. @param Device A pointer to the returned device handle.
  367. @retval EFI_SUCCESS The resulting handle was returned.
  368. @retval EFI_NOT_FOUND No handles matched the search.
  369. @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
  370. **/
  371. EFI_STATUS
  372. EFIAPI
  373. UnitTestLocateDevicePath (
  374. IN EFI_GUID *Protocol,
  375. IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath,
  376. OUT EFI_HANDLE *Device
  377. );
  378. /**
  379. Boot Service called to add, modify, or remove a system configuration table from
  380. the EFI System Table.
  381. @param Guid Pointer to the GUID for the entry to add, update, or
  382. remove
  383. @param Table Pointer to the configuration table for the entry to add,
  384. update, or remove, may be NULL.
  385. @return EFI_SUCCESS Guid, Table pair added, updated, or removed.
  386. @return EFI_INVALID_PARAMETER Input GUID not valid.
  387. @return EFI_NOT_FOUND Attempted to delete non-existant entry
  388. @return EFI_OUT_OF_RESOURCES Not enough memory available
  389. **/
  390. EFI_STATUS
  391. EFIAPI
  392. UnitTestInstallConfigurationTable (
  393. IN EFI_GUID *Guid,
  394. IN VOID *Table
  395. );
  396. /**
  397. Loads an EFI image into memory and returns a handle to the image.
  398. @param BootPolicy If TRUE, indicates that the request originates
  399. from the boot manager, and that the boot
  400. manager is attempting to load FilePath as a
  401. boot selection.
  402. @param ParentImageHandle The caller's image handle.
  403. @param FilePath The specific file path from which the image is
  404. loaded.
  405. @param SourceBuffer If not NULL, a pointer to the memory location
  406. containing a copy of the image to be loaded.
  407. @param SourceSize The size in bytes of SourceBuffer.
  408. @param ImageHandle Pointer to the returned image handle that is
  409. created when the image is successfully loaded.
  410. @retval EFI_SUCCESS The image was loaded into memory.
  411. @retval EFI_NOT_FOUND The FilePath was not found.
  412. @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
  413. @retval EFI_UNSUPPORTED The image type is not supported, or the device
  414. path cannot be parsed to locate the proper
  415. protocol for loading the file.
  416. @retval EFI_OUT_OF_RESOURCES Image was not loaded due to insufficient
  417. resources.
  418. @retval EFI_LOAD_ERROR Image was not loaded because the image format was corrupt or not
  419. understood.
  420. @retval EFI_DEVICE_ERROR Image was not loaded because the device returned a read error.
  421. @retval EFI_ACCESS_DENIED Image was not loaded because the platform policy prohibits the
  422. image from being loaded. NULL is returned in *ImageHandle.
  423. @retval EFI_SECURITY_VIOLATION Image was loaded and an ImageHandle was created with a
  424. valid EFI_LOADED_IMAGE_PROTOCOL. However, the current
  425. platform policy specifies that the image should not be started.
  426. **/
  427. EFI_STATUS
  428. EFIAPI
  429. UnitTestLoadImage (
  430. IN BOOLEAN BootPolicy,
  431. IN EFI_HANDLE ParentImageHandle,
  432. IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
  433. IN VOID *SourceBuffer OPTIONAL,
  434. IN UINTN SourceSize,
  435. OUT EFI_HANDLE *ImageHandle
  436. );
  437. /**
  438. Transfer control to a loaded image's entry point.
  439. @param ImageHandle Handle of image to be started.
  440. @param ExitDataSize Pointer of the size to ExitData
  441. @param ExitData Pointer to a pointer to a data buffer that
  442. includes a Null-terminated string,
  443. optionally followed by additional binary data.
  444. The string is a description that the caller may
  445. use to further indicate the reason for the
  446. image's exit.
  447. @retval EFI_INVALID_PARAMETER Invalid parameter
  448. @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate
  449. @retval EFI_SECURITY_VIOLATION The current platform policy specifies that the image should not be started.
  450. @retval EFI_SUCCESS Successfully transfer control to the image's
  451. entry point.
  452. **/
  453. EFI_STATUS
  454. EFIAPI
  455. UnitTestStartImage (
  456. IN EFI_HANDLE ImageHandle,
  457. OUT UINTN *ExitDataSize,
  458. OUT CHAR16 **ExitData OPTIONAL
  459. );
  460. /**
  461. Terminates the currently loaded EFI image and returns control to boot services.
  462. @param ImageHandle Handle that identifies the image. This
  463. parameter is passed to the image on entry.
  464. @param Status The image's exit code.
  465. @param ExitDataSize The size, in bytes, of ExitData. Ignored if
  466. ExitStatus is EFI_SUCCESS.
  467. @param ExitData Pointer to a data buffer that includes a
  468. Null-terminated Unicode string, optionally
  469. followed by additional binary data. The string
  470. is a description that the caller may use to
  471. further indicate the reason for the image's
  472. exit.
  473. @retval EFI_INVALID_PARAMETER Image handle is NULL or it is not current
  474. image.
  475. @retval EFI_SUCCESS Successfully terminates the currently loaded
  476. EFI image.
  477. @retval EFI_ACCESS_DENIED Should never reach there.
  478. @retval EFI_OUT_OF_RESOURCES Could not allocate pool
  479. **/
  480. EFI_STATUS
  481. EFIAPI
  482. UnitTestExit (
  483. IN EFI_HANDLE ImageHandle,
  484. IN EFI_STATUS Status,
  485. IN UINTN ExitDataSize,
  486. IN CHAR16 *ExitData OPTIONAL
  487. );
  488. /**
  489. Unloads an image.
  490. @param ImageHandle Handle that identifies the image to be
  491. unloaded.
  492. @retval EFI_SUCCESS The image has been unloaded.
  493. @retval EFI_UNSUPPORTED The image has been started, and does not support
  494. unload.
  495. @retval EFI_INVALID_PARAMPETER ImageHandle is not a valid image handle.
  496. **/
  497. EFI_STATUS
  498. EFIAPI
  499. UnitTestUnloadImage (
  500. IN EFI_HANDLE ImageHandle
  501. );
  502. /**
  503. Terminates all boot services.
  504. @param ImageHandle Handle that identifies the exiting image.
  505. @param MapKey Key to the latest memory map.
  506. @retval EFI_SUCCESS Boot Services terminated
  507. @retval EFI_INVALID_PARAMETER MapKey is incorrect.
  508. **/
  509. EFI_STATUS
  510. EFIAPI
  511. UnitTestExitBootServices (
  512. IN EFI_HANDLE ImageHandle,
  513. IN UINTN MapKey
  514. );
  515. /**
  516. Returns a monotonically increasing count for the platform.
  517. @param[out] Count The pointer to returned value.
  518. @retval EFI_SUCCESS The next monotonic count was returned.
  519. @retval EFI_INVALID_PARAMETER Count is NULL.
  520. @retval EFI_DEVICE_ERROR The device is not functioning properly.
  521. **/
  522. EFI_STATUS
  523. EFIAPI
  524. UnitTestGetNextMonotonicCount (
  525. OUT UINT64 *Count
  526. );
  527. /**
  528. Introduces a fine-grained stall.
  529. @param Microseconds The number of microseconds to stall execution.
  530. @retval EFI_SUCCESS Execution was stalled for at least the requested
  531. amount of microseconds.
  532. @retval EFI_NOT_AVAILABLE_YET gMetronome is not available yet
  533. **/
  534. EFI_STATUS
  535. EFIAPI
  536. UnitTestStall (
  537. IN UINTN Microseconds
  538. );
  539. /**
  540. Sets the system's watchdog timer.
  541. @param Timeout The number of seconds to set the watchdog timer to.
  542. A value of zero disables the timer.
  543. @param WatchdogCode The numeric code to log on a watchdog timer timeout
  544. event. The firmware reserves codes 0x0000 to 0xFFFF.
  545. Loaders and operating systems may use other timeout
  546. codes.
  547. @param DataSize The size, in bytes, of WatchdogData.
  548. @param WatchdogData A data buffer that includes a Null-terminated Unicode
  549. string, optionally followed by additional binary data.
  550. The string is a description that the call may use to
  551. further indicate the reason to be logged with a
  552. watchdog event.
  553. @return EFI_SUCCESS Timeout has been set
  554. @return EFI_NOT_AVAILABLE_YET WatchdogTimer is not available yet
  555. @return EFI_UNSUPPORTED System does not have a timer (currently not used)
  556. @return EFI_DEVICE_ERROR Could not complete due to hardware error
  557. **/
  558. EFI_STATUS
  559. EFIAPI
  560. UnitTestSetWatchdogTimer (
  561. IN UINTN Timeout,
  562. IN UINT64 WatchdogCode,
  563. IN UINTN DataSize,
  564. IN CHAR16 *WatchdogData OPTIONAL
  565. );
  566. /**
  567. Connects one or more drivers to a controller.
  568. @param ControllerHandle The handle of the controller to which driver(s) are to be connected.
  569. @param DriverImageHandle A pointer to an ordered list handles that support the
  570. EFI_DRIVER_BINDING_PROTOCOL.
  571. @param RemainingDevicePath A pointer to the device path that specifies a child of the
  572. controller specified by ControllerHandle.
  573. @param Recursive If TRUE, then ConnectController() is called recursively
  574. until the entire tree of controllers below the controller specified
  575. by ControllerHandle have been created. If FALSE, then
  576. the tree of controllers is only expanded one level.
  577. @retval EFI_SUCCESS 1) One or more drivers were connected to ControllerHandle.
  578. 2) No drivers were connected to ControllerHandle, but
  579. RemainingDevicePath is not NULL, and it is an End Device
  580. Path Node.
  581. @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
  582. @retval EFI_NOT_FOUND 1) There are no EFI_DRIVER_BINDING_PROTOCOL instances
  583. present in the system.
  584. 2) No drivers were connected to ControllerHandle.
  585. @retval EFI_SECURITY_VIOLATION
  586. The user has no permission to start UEFI device drivers on the device path
  587. associated with the ControllerHandle or specified by the RemainingDevicePath.
  588. **/
  589. EFI_STATUS
  590. EFIAPI
  591. UnitTestConnectController (
  592. IN EFI_HANDLE ControllerHandle,
  593. IN EFI_HANDLE *DriverImageHandle OPTIONAL,
  594. IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL,
  595. IN BOOLEAN Recursive
  596. );
  597. /**
  598. Disconnects a controller from a driver
  599. @param ControllerHandle ControllerHandle The handle of
  600. the controller from which
  601. driver(s) are to be
  602. disconnected.
  603. @param DriverImageHandle DriverImageHandle The driver to
  604. disconnect from ControllerHandle.
  605. @param ChildHandle ChildHandle The handle of the
  606. child to destroy.
  607. @retval EFI_SUCCESS One or more drivers were
  608. disconnected from the controller.
  609. @retval EFI_SUCCESS On entry, no drivers are managing
  610. ControllerHandle.
  611. @retval EFI_SUCCESS DriverImageHandle is not NULL,
  612. and on entry DriverImageHandle is
  613. not managing ControllerHandle.
  614. @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
  615. @retval EFI_INVALID_PARAMETER DriverImageHandle is not NULL,
  616. and it is not a valid EFI_HANDLE.
  617. @retval EFI_INVALID_PARAMETER ChildHandle is not NULL, and it
  618. is not a valid EFI_HANDLE.
  619. @retval EFI_OUT_OF_RESOURCES There are not enough resources
  620. available to disconnect any
  621. drivers from ControllerHandle.
  622. @retval EFI_DEVICE_ERROR The controller could not be
  623. disconnected because of a device
  624. error.
  625. **/
  626. EFI_STATUS
  627. EFIAPI
  628. UnitTestDisconnectController (
  629. IN EFI_HANDLE ControllerHandle,
  630. IN EFI_HANDLE DriverImageHandle OPTIONAL,
  631. IN EFI_HANDLE ChildHandle OPTIONAL
  632. );
  633. /**
  634. Locates the installed protocol handler for the handle, and
  635. invokes it to obtain the protocol interface. Usage information
  636. is registered in the protocol data base.
  637. @param UserHandle The handle to obtain the protocol interface on
  638. @param Protocol The ID of the protocol
  639. @param Interface The location to return the protocol interface
  640. @param ImageHandle The handle of the Image that is opening the
  641. protocol interface specified by Protocol and
  642. Interface.
  643. @param ControllerHandle The controller handle that is requiring this
  644. interface.
  645. @param Attributes The open mode of the protocol interface
  646. specified by Handle and Protocol.
  647. @retval EFI_INVALID_PARAMETER Protocol is NULL.
  648. @retval EFI_SUCCESS Get the protocol interface.
  649. **/
  650. EFI_STATUS
  651. EFIAPI
  652. UnitTestOpenProtocol (
  653. IN EFI_HANDLE UserHandle,
  654. IN EFI_GUID *Protocol,
  655. OUT VOID **Interface OPTIONAL,
  656. IN EFI_HANDLE ImageHandle,
  657. IN EFI_HANDLE ControllerHandle,
  658. IN UINT32 Attributes
  659. );
  660. /**
  661. Closes a protocol on a handle that was opened using OpenProtocol().
  662. @param UserHandle The handle for the protocol interface that was
  663. previously opened with OpenProtocol(), and is
  664. now being closed.
  665. @param Protocol The published unique identifier of the protocol.
  666. It is the caller's responsibility to pass in a
  667. valid GUID.
  668. @param AgentHandle The handle of the agent that is closing the
  669. protocol interface.
  670. @param ControllerHandle If the agent that opened a protocol is a driver
  671. that follows the EFI Driver Model, then this
  672. parameter is the controller handle that required
  673. the protocol interface. If the agent does not
  674. follow the EFI Driver Model, then this parameter
  675. is optional and may be NULL.
  676. @retval EFI_SUCCESS The protocol instance was closed.
  677. @retval EFI_INVALID_PARAMETER Handle, AgentHandle or ControllerHandle is not a
  678. valid EFI_HANDLE.
  679. @retval EFI_NOT_FOUND Can not find the specified protocol or
  680. AgentHandle.
  681. **/
  682. EFI_STATUS
  683. EFIAPI
  684. UnitTestCloseProtocol (
  685. IN EFI_HANDLE UserHandle,
  686. IN EFI_GUID *Protocol,
  687. IN EFI_HANDLE AgentHandle,
  688. IN EFI_HANDLE ControllerHandle
  689. );
  690. /**
  691. Return information about Opened protocols in the system
  692. @param UserHandle The handle to close the protocol interface on
  693. @param Protocol The ID of the protocol
  694. @param EntryBuffer A pointer to a buffer of open protocol
  695. information in the form of
  696. EFI_OPEN_PROTOCOL_INFORMATION_ENTRY structures.
  697. @param EntryCount Number of EntryBuffer entries
  698. **/
  699. EFI_STATUS
  700. EFIAPI
  701. UnitTestOpenProtocolInformation (
  702. IN EFI_HANDLE UserHandle,
  703. IN EFI_GUID *Protocol,
  704. OUT EFI_OPEN_PROTOCOL_INFORMATION_ENTRY **EntryBuffer,
  705. OUT UINTN *EntryCount
  706. );
  707. /**
  708. Retrieves the list of protocol interface GUIDs that are installed on a handle in a buffer allocated
  709. from pool.
  710. @param UserHandle The handle from which to retrieve the list of
  711. protocol interface GUIDs.
  712. @param ProtocolBuffer A pointer to the list of protocol interface GUID
  713. pointers that are installed on Handle.
  714. @param ProtocolBufferCount A pointer to the number of GUID pointers present
  715. in ProtocolBuffer.
  716. @retval EFI_SUCCESS The list of protocol interface GUIDs installed
  717. on Handle was returned in ProtocolBuffer. The
  718. number of protocol interface GUIDs was returned
  719. in ProtocolBufferCount.
  720. @retval EFI_INVALID_PARAMETER Handle is NULL.
  721. @retval EFI_INVALID_PARAMETER Handle is not a valid EFI_HANDLE.
  722. @retval EFI_INVALID_PARAMETER ProtocolBuffer is NULL.
  723. @retval EFI_INVALID_PARAMETER ProtocolBufferCount is NULL.
  724. @retval EFI_OUT_OF_RESOURCES There is not enough pool memory to store the
  725. results.
  726. **/
  727. EFI_STATUS
  728. EFIAPI
  729. UnitTestProtocolsPerHandle (
  730. IN EFI_HANDLE UserHandle,
  731. OUT EFI_GUID ***ProtocolBuffer,
  732. OUT UINTN *ProtocolBufferCount
  733. );
  734. /**
  735. Function returns an array of handles that support the requested protocol
  736. in a buffer allocated from pool. This is a version of UnitTestLocateHandle()
  737. that allocates a buffer for the caller.
  738. @param SearchType Specifies which handle(s) are to be returned.
  739. @param Protocol Provides the protocol to search by. This
  740. parameter is only valid for SearchType
  741. ByProtocol.
  742. @param SearchKey Supplies the search key depending on the
  743. SearchType.
  744. @param NumberHandles The number of handles returned in Buffer.
  745. @param Buffer A pointer to the buffer to return the requested
  746. array of handles that support Protocol.
  747. @retval EFI_SUCCESS The result array of handles was returned.
  748. @retval EFI_NOT_FOUND No handles match the search.
  749. @retval EFI_OUT_OF_RESOURCES There is not enough pool memory to store the
  750. matching results.
  751. @retval EFI_INVALID_PARAMETER One or more parameters are not valid.
  752. **/
  753. EFI_STATUS
  754. EFIAPI
  755. UnitTestLocateHandleBuffer (
  756. IN EFI_LOCATE_SEARCH_TYPE SearchType,
  757. IN EFI_GUID *Protocol OPTIONAL,
  758. IN VOID *SearchKey OPTIONAL,
  759. IN OUT UINTN *NumberHandles,
  760. OUT EFI_HANDLE **Buffer
  761. );
  762. /**
  763. Return the first Protocol Interface that matches the Protocol GUID. If
  764. Registration is passed in, return a Protocol Instance that was just add
  765. to the system. If Registration is NULL return the first Protocol Interface
  766. you find.
  767. @param Protocol The protocol to search for
  768. @param Registration Optional Registration Key returned from
  769. RegisterProtocolNotify()
  770. @param Interface Return the Protocol interface (instance).
  771. @retval EFI_SUCCESS If a valid Interface is returned
  772. @retval EFI_INVALID_PARAMETER Invalid parameter
  773. @retval EFI_NOT_FOUND Protocol interface not found
  774. **/
  775. EFI_STATUS
  776. EFIAPI
  777. UnitTestLocateProtocol (
  778. IN EFI_GUID *Protocol,
  779. IN VOID *Registration OPTIONAL,
  780. OUT VOID **Interface
  781. );
  782. /**
  783. Installs a list of protocol interface into the boot services environment.
  784. This function calls InstallProtocolInterface() in a loop. If any error
  785. occurs all the protocols added by this function are removed. This is
  786. basically a lib function to save space.
  787. @param Handle The handle to install the protocol handlers on,
  788. or NULL if a new handle is to be allocated
  789. @param ... EFI_GUID followed by protocol instance. A NULL
  790. terminates the list. The pairs are the
  791. arguments to InstallProtocolInterface(). All the
  792. protocols are added to Handle.
  793. @retval EFI_SUCCESS All the protocol interface was installed.
  794. @retval EFI_OUT_OF_RESOURCES There was not enough memory in pool to install all the protocols.
  795. @retval EFI_ALREADY_STARTED A Device Path Protocol instance was passed in that is already present in
  796. the handle database.
  797. @retval EFI_INVALID_PARAMETER Handle is NULL.
  798. @retval EFI_INVALID_PARAMETER Protocol is already installed on the handle specified by Handle.
  799. **/
  800. EFI_STATUS
  801. EFIAPI
  802. UnitTestInstallMultipleProtocolInterfaces (
  803. IN OUT EFI_HANDLE *Handle,
  804. ...
  805. );
  806. /**
  807. Uninstalls a list of protocol interface in the boot services environment.
  808. This function calls UninstallProtocolInterface() in a loop. This is
  809. basically a lib function to save space.
  810. @param Handle The handle to uninstall the protocol
  811. @param ... EFI_GUID followed by protocol instance. A NULL
  812. terminates the list. The pairs are the
  813. arguments to UninstallProtocolInterface(). All
  814. the protocols are added to Handle.
  815. @return Status code
  816. **/
  817. EFI_STATUS
  818. EFIAPI
  819. UnitTestUninstallMultipleProtocolInterfaces (
  820. IN EFI_HANDLE Handle,
  821. ...
  822. );
  823. /**
  824. Computes and returns a 32-bit CRC for a data buffer.
  825. @param[in] Data A pointer to the buffer on which the 32-bit CRC is to be computed.
  826. @param[in] DataSize The number of bytes in the buffer Data.
  827. @param[out] Crc32 The 32-bit CRC that was computed for the data buffer specified by Data
  828. and DataSize.
  829. @retval EFI_SUCCESS The 32-bit CRC was computed for the data buffer and returned in
  830. Crc32.
  831. @retval EFI_INVALID_PARAMETER Data is NULL.
  832. @retval EFI_INVALID_PARAMETER Crc32 is NULL.
  833. @retval EFI_INVALID_PARAMETER DataSize is 0.
  834. **/
  835. EFI_STATUS
  836. EFIAPI
  837. UnitTestCalculateCrc32 (
  838. IN VOID *Data,
  839. IN UINTN DataSize,
  840. OUT UINT32 *Crc32
  841. );
  842. /**
  843. Creates an event in a group.
  844. @param Type The type of event to create and its mode and
  845. attributes
  846. @param NotifyTpl The task priority level of event notifications
  847. @param NotifyFunction Pointer to the events notification function
  848. @param NotifyContext Pointer to the notification functions context;
  849. corresponds to parameter "Context" in the
  850. notification function
  851. @param EventGroup GUID for EventGroup if NULL act the same as
  852. gBS->CreateEvent().
  853. @param Event Pointer to the newly created event if the call
  854. succeeds; undefined otherwise
  855. @retval EFI_SUCCESS The event structure was created
  856. @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value
  857. @retval EFI_OUT_OF_RESOURCES The event could not be allocated
  858. **/
  859. EFI_STATUS
  860. EFIAPI
  861. UnitTestCreateEventEx (
  862. IN UINT32 Type,
  863. IN EFI_TPL NotifyTpl,
  864. IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL
  865. IN CONST VOID *NotifyContext, OPTIONAL
  866. IN CONST EFI_GUID *EventGroup, OPTIONAL
  867. OUT EFI_EVENT *Event
  868. );
  869. #endif