Efi 1.10 extension, Status codes returned – Intel Extensible Firmware Interface User Manual
Page 182

Extensible Firmware Interface Specification
5-84
12/01/02
Version 1.10
When an EFI application exits, firmware frees the memory used to hold the image. The firmware
also frees its references to the
ImageHandle
and the handle itself. Before exiting, the application
is responsible for freeing any resources it allocated. This includes memory (pages and/or pool),
open file system handles, and so forth. The only exception to this rule is the
ExitData
buffer,
which must be freed by the caller of
. (If the buffer is needed, firmware must
allocate it by calling
and must return a pointer to it to the caller of
StartImage()
.)
When an EFI boot service driver or runtime service driver exits, firmware frees the image only if
the
ExitStatus
is an error code; otherwise the image stays resident in memory. The driver must
not return an error code if it has installed any protocol handlers or other active callbacks into the
system that have not (or cannot) be cleaned up. If the driver exits with an error code, it is
responsible for freeing all resources before exiting. This includes any allocated memory (pages
and/or pool), open file system handles, and so forth.
It is valid to call
Exit()
or
Unload()
for an image that was loaded by
before
calling
StartImage()
. This will free the image from memory without having started it.
EFI 1.10 Extension
If
ImageHandle
is an EFI Application, then all of the protocols that were opened by
ImageHandle
using the boot service
are automatically closed with the boot
service
. If
ImageHandle
is an EFI boot services driver or runtime service
driver, and
ExitStatus
is an error code, then all of the protocols that were opened by
ImageHandle
using the boot service
OpenProtocol()
are automatically closed with the boot
service
CloseProtocol()
. If
ImageHandle
is an EFI boot services driver or runtime service
driver, and
ExitStatus
is not an error code, then no protocols are automatically closed by this
service.
Status Codes Returned
(Does not return.)
Image exit. Control is returned to the
StartImage
()
call that
invoked the image.
EFI_SUCCESS
The image was unloaded.
Exit
()
only returns success if the
image has not been started; otherwise, the exit returns to the
StartImage
()
call that invoked the image.
EFI_INVALID_PARAMETER
The specified image is not the current image.