All pastes #394218 Raw Edit

Mine

public text v1 · immutable
·published 2007-03-14 03:29 UTC
rendered paste body
5.6. I/O Kit Initialization
PE_init_iokit() [pexpert/ppc/pe_init.c] initializes the I/O Kit. Figure 514 shows its sequence of operations.


Figure 514. I/O Kit initialization

[View full size image]





PE_init_iokit() first calls PE_init_kprintf() [pexpert/ppc/pe_kprintf.c], which was also called by ppc_vm_init() earlier in the startup sequence. We saw that PE_init_kprintf() initializes the serial port if it is present. It then calls PE_init_printf() [pexpert/gen/pe_gen.c], which was also called earlier during the startup, but PE_init_iokit() calls it with the vm_initialized Boolean argument set to trUE. PE_init_printf() calls vcattach() [osfmk/console/video_console.c] to arrange for acquiring the screen if the bootstrap is proceeding in nongraphical mode, in which case it also uses vcputc() [osfmk/console/video_console.c] to print messages in the kernel's log buffer for kernel printf() calls.

PE_init_iokit() uses DTLookupEntry() [pexpert/gen/device_tree.c] to look up the /chosen/memory-map entry in the device tree. If the lookup succeeds, the BootCLUT and Pict-FailedBoot properties are retrieved from the entry. BootCLUT is the 8-bit boot-time color lookup table that was passed to the kernel by BootX. Pict-FailedBootalso passed to the kernel by BootXis the picture shown if booting fails. You can examine this portion of the device tree by using one of the I/O Registry tools:

$ ioreg -S -p IODeviceTree -n memory-map | less
+-o Root  <class IORegistryEntry>
  +-o device-tree  <class IOPlatformExpertDevice>
    +-o chosen  <class IOService>
    | +-o memory-map  <class IOService>
    |       "Kernel-__VECTORS" = <0000000000007000>
    |       "Kernel-__PRELINK" = <0043700000874000>
    |       "AAPL,phandle" = <ffa26f00>
    |       "Pict-FailedBoot" = <00d7a00000004020>
    |       "BootArgs" = <00d78000000001fc>
    |       "Kernel-__DATA" = <0035d000000a0000>
    |       "BootCLUT" = <00d7900000000300>
    |       "Kernel-__HIB" = <0000700000007000>
    |       "name" = <"memory-map">
    |       "Kernel-__TEXT" = <0000e0000034f000>
    |     }
    |
...


If BootCLUT is found, PE_init_iokit() copies its contents to appleClut8, the default Mac OS X color lookup table. It then calls panic_ui_initialize() [osfmk/console/panic_dialog.c], which sets the active CLUT pointer.

It is possible to replace the default panic picture either by recompiling the kernel with another picture or by dynamically loading a new picture through a sysctl interface. Moreover, the kernel also allows the panic user interface to be tested without inducing an actual panic. An image to be used as the panic picture must be converted either to a C structure that can be compiled into the kernel or to a kernel-loadable file. The genimage.c and qtif2kraw.c files in osfmk/console/panic_ui/ contain sources for utilities that convert an uncompressed QuickTime RAW image file into a C structure and a loadable RAW file, respectively. Arbitrary image formats can be converted to QuickTime RAWa .qtif fileusing QuickTime facilities, among other tools. Figure 515 shows an example of replacing the kernel's default panic image by loading a new one from user space.