Download The Raven Kernel: a Microkernel for Shared Memory
Transcript
Chapter 3. Kernel level implementation 30 Special care should be taken when calling kprintf(): the output string should not be greater than 200 bytes, or the stack will be damaged. kprintf() allocates a temporary 200 byte output buer on the caller's stack. On the real hardware, the g88mon monitor controls communication across the serial port to provide access to the g88 console under Unix. In the simulated environment, the simulator contains a character console device at 0xffff0000. Access to both interfaces uses strictly polled I/O. void kprint_mode(int mode); This routine controls the suppression of console output strings to the serial port device. In some cases, the blocking nature of polled I/O has negative consequences. Outputting a string across the serial port can take a long time in relation to other devices. For the Ethernet device, the time taken to output a debug message may result in lost packets. kprint mode() can help prevent this problem by allowing console output to be shut o under program control. This is useful when debugging code where interrupt activity is necessary, such debugging an Ethernet protocol stack. Passing a non-zero value for the mode argument allows output to the serial port. Passing a zero value for the mode argument suppresses serial port output. In either case, the kmsg buer logs all output strings, which can be viewed at a later time. 3.4.2 Console output buer The console output buer, or kmsg buer, is a large buer in the kernel memory space which logs all strings that have been outputted to the console using kprint(). Even strings that are sent with the mode disabled are placed in the kmsg buer. This allows all console output to be viewed at a later time using the debugger. The kmsg base variable points to the beginning of the kmsg buer. The g88 debugger can be used to print out console strings starting at the kmsg base address. For example: