Changeset View
Changeset View
Standalone View
Standalone View
head/stand/common/misc.c
Show First 20 Lines • Show All 163 Lines • ▼ Show 20 Lines | #ifdef DEBUG | ||||
printf("\nread failed\n"); | printf("\nread failed\n"); | ||||
#endif | #endif | ||||
free(buf); | free(buf); | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
return (buf); | return (buf); | ||||
} | } | ||||
/* | |||||
* Display a region in traditional hexdump format. | |||||
*/ | |||||
void | |||||
hexdump(caddr_t region, size_t len) | |||||
{ | |||||
caddr_t line; | |||||
int x, c; | |||||
char lbuf[80]; | |||||
#define emit(fmt, args...) {sprintf(lbuf, fmt , ## args); pager_output(lbuf);} | |||||
pager_open(); | |||||
for (line = region; line < (region + len); line += 16) { | |||||
emit("%08lx ", (long) line); | |||||
for (x = 0; x < 16; x++) { | |||||
if ((line + x) < (region + len)) { | |||||
emit("%02x ", *(uint8_t *)(line + x)); | |||||
} else { | |||||
emit("-- "); | |||||
} | |||||
if (x == 7) | |||||
emit(" "); | |||||
} | |||||
emit(" |"); | |||||
for (x = 0; x < 16; x++) { | |||||
if ((line + x) < (region + len)) { | |||||
c = *(uint8_t *)(line + x); | |||||
if ((c < ' ') || (c > '~')) /* !isprint(c) */ | |||||
c = '.'; | |||||
emit("%c", c); | |||||
} else { | |||||
emit(" "); | |||||
} | |||||
} | |||||
emit("|\n"); | |||||
} | |||||
pager_close(); | |||||
} | |||||
void | void | ||||
dev_cleanup(void) | dev_cleanup(void) | ||||
{ | { | ||||
int i; | int i; | ||||
/* Call cleanup routines */ | /* Call cleanup routines */ | ||||
for (i = 0; devsw[i] != NULL; ++i) | for (i = 0; devsw[i] != NULL; ++i) | ||||
if (devsw[i]->dv_cleanup != NULL) | if (devsw[i]->dv_cleanup != NULL) | ||||
(devsw[i]->dv_cleanup)(); | (devsw[i]->dv_cleanup)(); | ||||
} | } |