Services
Version 1.02 12/12/00 75
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 StartImage(). (If the buffer is needed, firmware must
allocate it by calling AllocatePool() 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 callouts 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 LoadImage() before
calling StartImage(). This will free the image from memory without having started it.
Status Codes Returned
(Does not return.) Image exit. Control is returned from 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.