4.2.17 Limit use of Console Services

PC BIOS legacy option ROMs typically display banners and allow hotkey(s) to enter the configuration area for a particular card. Current UEFI drivers use HII functionality to allow access to system configuration areas.

Because UEFI drivers now have HII functionality, the UEFI Driver Model requires that no console I/O operations take place in the UEFI Driver Binding Protocol functions. A reasonable exception to this rule is to use the DEBUG() macro to display progress information during driver development and debug. Using the DEBUG() macro allows the code for displaying the data to be easily removed for a production build of the driver.

Use of the DEBUG() macro should be limited to "debug releases" of a driver. This strategy typically works if the driver is loaded after the UEFI console is connected. However, because console drivers may live in option ROMs, some firmware implementations may load the option ROM drivers before the UEFI console is connected. In such cases, the ConOut and StdErr fields of the UEFI system table may be NULL, and printing can crash the system. The DEBUG() macro should check to see if the field is NULL before using those services.