Ejemplo n.º 1
0
void print_le(const char *mem,int size)
{
  for (int i = (size-1);i >= 0; i--)
  {
    *((volatile unsigned int *) 0x09000000) =nibble2hex(mem[i]>>4);
    *((volatile unsigned int *) 0x09000000) =nibble2hex(mem[i]);
  }
}
Ejemplo n.º 2
0
static void cksum(uint8_t *buf) {
	uint8_t sum=0;
	
	for(;*buf;buf++)
		sum += *buf;
	
	*buf++ = nibble2hex(sum>>4);
	*buf = nibble2hex(sum&0xf);
}
Ejemplo n.º 3
0
static void u32tostr(uint8_t *buf, uint32_t n) {
	uint8_t *ptr = buf+8;
	
	do {
		--ptr;
		*ptr = nibble2hex(n&0xf);
		n>>=4;
	}while(buf != ptr);
}
Ejemplo n.º 4
0
void print_be(const char *mem,int size)
{
  for (int i =0;i < size; i++)
  {
    *((volatile unsigned int *) 0x09000000) =nibble2hex(mem[i]>>4);
    *((volatile unsigned int *) 0x09000000) =nibble2hex(mem[i]);
  }
  *((volatile unsigned int *) 0x09000000) =' ';
}
Ejemplo n.º 5
0
static void mem2hex(u8* dst, u8* src, u32 len)
{
  u8 tmp;

  while (len-- > 0)
  {
    tmp = *src++;
    *dst++ = nibble2hex(tmp >> 4);
    *dst++ = nibble2hex(tmp);
  }
}
Ejemplo n.º 6
0
static void gdb_reply(const char* reply)
{
  u8 chk;
  u32 left;
  u8* ptr;
  int n;

  if (!gdb_active())
    return;

  memset(cmd_bfr, 0, sizeof cmd_bfr);

  cmd_len = strlen(reply);
  if (cmd_len + 4 > sizeof cmd_bfr)
    ERROR_LOG(GDB_STUB, "cmd_bfr overflow in gdb_reply");

  memcpy(cmd_bfr + 1, reply, cmd_len);

  cmd_len++;
  chk = gdb_calc_chksum();
  cmd_len--;
  cmd_bfr[0] = GDB_STUB_START;
  cmd_bfr[cmd_len + 1] = GDB_STUB_END;
  cmd_bfr[cmd_len + 2] = nibble2hex(chk >> 4);
  cmd_bfr[cmd_len + 3] = nibble2hex(chk);

  DEBUG_LOG(GDB_STUB, "gdb: reply (len: %d): %s", cmd_len, cmd_bfr);

  ptr = cmd_bfr;
  left = cmd_len + 4;
  while (left > 0)
  {
    n = send(sock, ptr, left, 0);
    if (n < 0)
    {
      ERROR_LOG(GDB_STUB, "gdb: send failed");
      return gdb_deinit();
    }
    left -= n;
    ptr += n;
  }
}
Ejemplo n.º 7
0
void print_memory(const char *name,const char * mem,int size)
{
  kprint(name);
  kprint(":\n");
  int i;
  for (i=0;i<size;i++)
  {
    *((volatile unsigned int *) 0x09000000) =nibble2hex(mem[i]>>4);
    *((volatile unsigned int *) 0x09000000) =nibble2hex(mem[i]);
    if (((i+1)%4)==0)
    {
      kprint(" ");
    }
    if (((i+1)%16)==0)
    {
      kprint("\n");
    }

  }
  kprint("\n");
}
Ejemplo n.º 8
0
void effect2text(int comm, int param, char *text)
{
	text[0] = nibble2hex(comm);
	text[1] = nibble2hex(param >> 4);
	text[2] = nibble2hex(param & 0xF);
}