Print this page
armv6: bop_panic should hexdump the stack
It's the little things that make debugging easier.


  17 /*
  18  * Just like in i86pc, we too get the joys of mimicking the SPARC boot system.
  19  */
  20 
  21 #include <sys/types.h>
  22 #include <sys/param.h>
  23 #include <sys/bootconf.h>
  24 #include <sys/bootsvcs.h>
  25 #include <sys/boot_console.h>
  26 #include <sys/atag.h>
  27 #include <sys/varargs.h>
  28 #include <sys/cmn_err.h>
  29 #include <sys/sysmacros.h>
  30 #include <sys/systm.h>
  31 #include <sys/ctype.h>
  32 #include <sys/bootstat.h>
  33 #include <sys/privregs.h>
  34 #include <sys/cpu_asm.h>
  35 #include <sys/boot_mmu.h>
  36 #include <sys/elf.h>

  37 
  38 static bootops_t bootop;
  39 
  40 /*
  41  * Debugging help
  42  */
  43 static int fakebop_prop_debug = 0;
  44 static int fakebop_alloc_debug = 0;
  45 static int fakebop_atag_debug = 0;
  46 
  47 static uint_t kbm_debug = 1;
  48 #define DBG_MSG(x)      { if (kbm_debug) bcons_puts(x); bcons_puts("\n"); }
  49 #define BUFFERSIZE      256
  50 static char buffer[BUFFERSIZE];
  51 
  52 /*
  53  * fakebop memory allocations scheme
  54  *
  55  * It's a virtual world out there. The loader thankfully tells us all the areas
  56  * that it has mapped for us and it also tells us about the page table arena --


  96 static bootinfo_t bootinfo;     /* Simple set of boot information */
  97 
  98 static struct boot_syscalls bop_sysp = {
  99         bcons_getchar,
 100         bcons_putchar,
 101         bcons_ischar,
 102 };
 103 
 104 /*
 105  * stuff to store/report/manipulate boot property settings.
 106  */
 107 typedef struct bootprop {
 108         struct bootprop *bp_next;
 109         char *bp_name;
 110         uint_t bp_vlen;
 111         char *bp_value;
 112 } bootprop_t;
 113 
 114 static bootprop_t *bprops = NULL;
 115 



























 116 void
 117 bop_panic(const char *msg)
 118 {
 119         bop_printf(NULL, "ARM bop_panic:\n%s\nSpinning Forever...", msg);




 120         for (;;)
 121                 ;
 122 }
 123 
 124 /*
 125  * XXX This is just a hack to let us see a bit more about what's going on.
 126  * Normally we'd use vsnprintf, but that includes sys/systm.h which requires
 127  * almost every header platform header in the world. Also, we're using hex,
 128  * because hex is cool. Actually, we're really using it because it means we can
 129  * bitshift instead of divide. There is no integer division in ARMv6 natively.
 130  * Oops.
 131  */
 132 static char *
 133 fakebop_hack_ultostr(unsigned long value, char *ptr)
 134 {
 135         ulong_t t, val = (ulong_t)value;
 136         char c;
 137 
 138         do {
 139                 c = (char)('0' + val - 16 * (t = (val >> 4)));




  17 /*
  18  * Just like in i86pc, we too get the joys of mimicking the SPARC boot system.
  19  */
  20 
  21 #include <sys/types.h>
  22 #include <sys/param.h>
  23 #include <sys/bootconf.h>
  24 #include <sys/bootsvcs.h>
  25 #include <sys/boot_console.h>
  26 #include <sys/atag.h>
  27 #include <sys/varargs.h>
  28 #include <sys/cmn_err.h>
  29 #include <sys/sysmacros.h>
  30 #include <sys/systm.h>
  31 #include <sys/ctype.h>
  32 #include <sys/bootstat.h>
  33 #include <sys/privregs.h>
  34 #include <sys/cpu_asm.h>
  35 #include <sys/boot_mmu.h>
  36 #include <sys/elf.h>
  37 #include <sys/archsystm.h>
  38 
  39 static bootops_t bootop;
  40 
  41 /*
  42  * Debugging help
  43  */
  44 static int fakebop_prop_debug = 0;
  45 static int fakebop_alloc_debug = 0;
  46 static int fakebop_atag_debug = 0;
  47 
  48 static uint_t kbm_debug = 1;
  49 #define DBG_MSG(x)      { if (kbm_debug) bcons_puts(x); bcons_puts("\n"); }
  50 #define BUFFERSIZE      256
  51 static char buffer[BUFFERSIZE];
  52 
  53 /*
  54  * fakebop memory allocations scheme
  55  *
  56  * It's a virtual world out there. The loader thankfully tells us all the areas
  57  * that it has mapped for us and it also tells us about the page table arena --


  97 static bootinfo_t bootinfo;     /* Simple set of boot information */
  98 
  99 static struct boot_syscalls bop_sysp = {
 100         bcons_getchar,
 101         bcons_putchar,
 102         bcons_ischar,
 103 };
 104 
 105 /*
 106  * stuff to store/report/manipulate boot property settings.
 107  */
 108 typedef struct bootprop {
 109         struct bootprop *bp_next;
 110         char *bp_name;
 111         uint_t bp_vlen;
 112         char *bp_value;
 113 } bootprop_t;
 114 
 115 static bootprop_t *bprops = NULL;
 116 
 117 static void
 118 hexdump_stack()
 119 {
 120         extern char t0stack[];
 121 
 122         uint8_t *start = (uint8_t *)t0stack;
 123         uint8_t *end = start + DEFAULTSTKSZ;
 124         uint8_t *ptr;
 125         int i;
 126 
 127         bop_printf(NULL, "stack (fp = %x):\n", getfp());
 128 
 129         ptr = (uint8_t *)(getfp() & ~0xf);
 130         if (ptr <= start || ptr >= end)
 131                 ptr = start;
 132 
 133         while (ptr < end) {
 134                 uint32_t *tmp = (uint32_t *)ptr;
 135 
 136                 bop_printf(NULL, "%p: %08x %08x %08x %08x\n", ptr,
 137                     tmp[0], tmp[1], tmp[2], tmp[3]);
 138 
 139                 ptr += 16;
 140         }
 141 
 142 }
 143 
 144 void
 145 bop_panic(const char *msg)
 146 {
 147         bop_printf(NULL, "ARM bop_panic:\n%s\n", msg);
 148 
 149         hexdump_stack();
 150 
 151         bop_printf(NULL, "Spinning Forever...", msg);
 152         for (;;)
 153                 ;
 154 }
 155 
 156 /*
 157  * XXX This is just a hack to let us see a bit more about what's going on.
 158  * Normally we'd use vsnprintf, but that includes sys/systm.h which requires
 159  * almost every header platform header in the world. Also, we're using hex,
 160  * because hex is cool. Actually, we're really using it because it means we can
 161  * bitshift instead of divide. There is no integer division in ARMv6 natively.
 162  * Oops.
 163  */
 164 static char *
 165 fakebop_hack_ultostr(unsigned long value, char *ptr)
 166 {
 167         ulong_t t, val = (ulong_t)value;
 168         char c;
 169 
 170         do {
 171                 c = (char)('0' + val - 16 * (t = (val >> 4)));