dmesg.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * linux/arch/m68k/tools/amiga/dmesg.c -- Retrieve the kernel messages stored
  3. * in Chip RAM with the kernel command
  4. * line option `debug=mem'.
  5. *
  6. * © Copyright 1996 by Geert Uytterhoeven <geert@linux-m68k.org>
  7. *
  8. *
  9. * Usage:
  10. *
  11. * dmesg
  12. * dmesg <CHIPMEM_END>
  13. *
  14. *
  15. * This file is subject to the terms and conditions of the GNU General Public
  16. * License. See the file COPYING in the main directory of the Linux
  17. * distribution for more details.
  18. */
  19. #include <stdio.h>
  20. #include <stdlib.h>
  21. #include <unistd.h>
  22. #define CHIPMEM_START 0x00000000
  23. #define CHIPMEM_END 0x00200000 /* overridden by argv[1] */
  24. #define SAVEKMSG_MAGIC1 0x53415645 /* 'SAVE' */
  25. #define SAVEKMSG_MAGIC2 0x4B4D5347 /* 'KMSG' */
  26. struct savekmsg {
  27. u_long magic1; /* SAVEKMSG_MAGIC1 */
  28. u_long magic2; /* SAVEKMSG_MAGIC2 */
  29. u_long magicptr; /* address of magic1 */
  30. u_long size;
  31. char data[0];
  32. };
  33. int main(int argc, char *argv[])
  34. {
  35. u_long start = CHIPMEM_START, end = CHIPMEM_END, p;
  36. int found = 0;
  37. struct savekmsg *m = NULL;
  38. if (argc >= 2)
  39. end = strtoul(argv[1], NULL, 0);
  40. printf("Searching for SAVEKMSG magic...\n");
  41. for (p = start; p <= end-sizeof(struct savekmsg); p += 4) {
  42. m = (struct savekmsg *)p;
  43. if ((m->magic1 == SAVEKMSG_MAGIC1) && (m->magic2 == SAVEKMSG_MAGIC2) &&
  44. (m->magicptr == p)) {
  45. found = 1;
  46. break;
  47. }
  48. }
  49. if (!found)
  50. printf("Not found\n");
  51. else {
  52. printf("Found %ld bytes at 0x%08lx\n", m->size, (u_long)&m->data);
  53. puts(">>>>>>>>>>>>>>>>>>>>");
  54. fflush(stdout);
  55. write(1, &m->data, m->size);
  56. fflush(stdout);
  57. puts("<<<<<<<<<<<<<<<<<<<<");
  58. }
  59. return(0);
  60. }