|
|
Proper handling of error conditions in drivers is essential to preserve the integrity of the operating system. A number of facilities are provided for reporting error conditions; see ``Error handling'' for a listing. Consider the following:
cmn_err (CE_WARN, "mydriv.c: Fatal error reading device %x" , device);
#ifdef MY_DEBUG cmn_err(CE_NOTE, " xxioctl routine called - device number = %x", device); #endifNote that MY_DEBUG is prefixed to avoid conflicts with other kernel modules. See ``Conditional compiler statements''.
For debugging purposes, DDI 8 and later versions drivers should use the call_demon(D3) function to invoke the current kernel debugger at a specific point rather than panicking the system. ODDI 3 and later drivers can use the calldebug(D3oddi) function for the same purpose.
For DDI versions prior to DDI 8
and ODDI versions prior to version 3,
drivers may make
cmn_err( )
calls with the CE_PANIC mode,
but only in #ifdef DEBUG
sections,
which execute only for debugging.
This practice is used to freeze the kernel
so it can be analyzed with a kernel debugger.