/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+void IOKitKernelLogBuffer(const char * title, const void * buffer, size_t size,
+ void (*output)(const char *format, ...))
+{
+ uint8_t c, chars[17];
+ size_t idx;
+
+ output("%s(0x%x):\n", title, size);
+ if (size > 4096) size = 4096;
+ chars[16] = idx = 0;
+ while (true) {
+ if (!(idx & 15)) {
+ if (idx) output(" |%s|\n", chars);
+ if (idx >= size) break;
+ output("%04x: ", idx);
+ }
+ else if (!(idx & 7)) output(" ");
+
+ c = ((char *)buffer)[idx];
+ output("%02x ", c);
+ chars[idx & 15] = ((c >= 0x20) && (c <= 0x7f)) ? c : ' ';
+
+ idx++;
+ if ((idx == size) && (idx & 15)) {
+ chars[idx & 15] = 0;
+ while (idx & 15) {
+ idx++;
+ output(" ");
+ }
+ }
+ }
+}
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
/*
* Convert a integer constant (typically a #define or enum) to a string.
*/