--- wikisrc/users/jakllsch.mdwn 2009/10/29 16:34:05 1.3 +++ wikisrc/users/jakllsch.mdwn 2010/05/01 20:15:13 1.4 @@ -1,5 +1,28 @@ # Jonathan Kollasch +## [[!template id=man name="ddb" section="4"]] tips + +### locating a softc +This locates a device's softc using it's `cfdriver_t` (e.g. `&mainbus_cd`, `&cpu_cd`) and its "device unit" (e.g. the `0` in `mainbus0`). + + db{0}> call device_lookup_private(ohci_cd, 0) + 0xffff800045fb2008 + +### locating structure members +This uses [[!template id=man name="gdb" section="1"]] and a kernel with debugging symbols to find the offset to a element in a structure. + + $ gdb netbsd.gdb + ... + (gdb) print &((struct ohci_softc *)0)->iot + $3 = (bus_space_tag_t *) 0x478 + (gdb) print &((struct ohci_softc *)0)->ioh + $4 = (bus_space_handle_t *) 0x480 + +### peeking at mapped registers + + db{0}> call bus_space_read_4(*(ffff800045fb2008+478), *(ffff800045fb2008+480), 0) + 0x110 + ## Unfinished Projects ### x86 UEFI kernel loader