Esempio n. 1
0
static long read_child_data_word(pid_t tid, void *addr)
{
	CHECK_ALIGNMENT(addr);

	/* set errno to 0 to check if the read was successful */errno = 0;

	long tmp = ptrace(PTRACE_PEEKDATA, tid, addr, 0);

	if (errno != 0) {
		perror("error reading word from child -- bailing out");
		fprintf(stderr, "read failed at addr %p\n", addr);
		fprintf(stderr, "printing mapped memory region: we read %ld\n", tmp);

		char path[64];
		FILE* file;
		bzero(path, 64);
		sprintf(path, "/proc/%d/maps", tid);
		if ((file = fopen(path, "r")) < 0) {
			perror("error reading child memory maps\n");
		}

		int c = getc(file);
		while (c != EOF) {
			putchar(c);
			c = getc(file);
		}

		assert(1==0);

		//sys_exit();
	}
	return tmp;
}
Esempio n. 2
0
File: ipc.c Progetto: ctalbert/rr
long read_child_code(pid_t pid, void* addr)
{
	CHECK_ALIGNMENT(addr);

	long tmp;
	tmp = sys_ptrace(PTRACE_PEEKTEXT, pid, addr, 0);
	return tmp;
}
Esempio n. 3
0
File: ipc.c Progetto: ctalbert/rr
static long read_child_data_word(pid_t pid, long int addr)
{
	CHECK_ALIGNMENT(addr);

	long tmp;
	/* currently no error checking -- what if data-word == -1? */
	tmp = ptrace(PTRACE_PEEKDATA, pid, addr, 0);
	return tmp;
}
Esempio n. 4
0
static void write_child_data_word(pid_t pid, void *addr, void *data)
{
	CHECK_ALIGNMENT(addr);
	sys_ptrace(PTRACE_POKEDATA, pid, addr, data);
}
Esempio n. 5
0
void write_child_code(pid_t pid, void* addr, long code)
{
	CHECK_ALIGNMENT(addr);

	sys_ptrace(PTRACE_POKETEXT, pid, addr, (void*) code);
}
Esempio n. 6
0
/*##########################################################################
 *
 * low_level_init
 *
 *#########################################################################*/
static void
low_level_init(struct netif *netif)
{
  ADI_ETHER_BUFFER* p;
  struct nifce_info* nip = (struct nifce_info*)netif->state;
  struct buffer_info* bip;
  int rx_len, tx_len, count;
  int i;
  ADI_ETHER_BUFFER* rx_head = NULL;
  ADI_ETHER_BUFFER* tx_head = NULL;
  unsigned int *mangle_ptr;
  struct tcpip_msg* msg;

  LWIP_ASSERT("low_level_init: nfice info supply failed", nip != NULL);
  LWIP_ASSERT("low_level_init: buffer area supply failed",
              nip->buff_area != NULL && nip->buff_area_size > 0);

  // copy individual (MAC) address into netif struct
  for (i = 0; i < 6; i += 1)
    netif->hwaddr[i] = nip->ia[i];
  netif->hwaddr_len = 6;

  // calculate total requirement for each rx and tx buffer
  rx_len =  sizeof(ADI_ETHER_BUFFER) + sizeof(struct buffer_info);
  tx_len = rx_len;
  rx_len += nip->rx_buff_datalen + nip->buff_overhead;
  tx_len += nip->tx_buff_datalen + nip->buff_overhead;
  rx_len = ((rx_len + 3) / 4) * 4;
  tx_len = ((tx_len + 3) / 4) * 4;
  
  rx_len = (rx_len + 31) & ~31;
  tx_len = (tx_len + 31) & ~31;

   nip->buff_area = (char*)(((unsigned int)nip->buff_area + 31) & ~31);

  // allocate buffers in required ratio from supplied memory area
  while (nip->buff_area_size > rx_len || nip->buff_area_size > tx_len)
  {
    int n;
    for (n = 0; n < nip->rx_buffs; n += 1) {
      if (nip->buff_area_size < rx_len)
        break;
      p = (ADI_ETHER_BUFFER*)nip->buff_area;
      nip->buff_area += rx_len;
      nip->buff_area_size -= rx_len;
      p->pNext = rx_head;
      rx_head = p;
    }
    for (n = 0; n < nip->tx_buffs; n += 1) {
      if (nip->buff_area_size < tx_len)
        break;
      p = (ADI_ETHER_BUFFER*)nip->buff_area;
      nip->buff_area += tx_len;
      nip->buff_area_size -= tx_len;
      p->pNext = tx_head;
      tx_head = p;
    }
  }

  // initialise each buffer's ADI_ETHER_BUFFER descriptor
  p = rx_head;
  count = 0;
  while (p)
  {
    p->Data = (char*)p + sizeof(ADI_ETHER_BUFFER) + nip->buff_overhead;
    #if defined(__ADSPBF537__)
    if(p->Data >0) 
	    LWIP_ASSERT("Rx data buffers are not aligned properly",CHECK_ALIGNMENT((unsigned int)p->Data));
    #elif (defined(__ADSPBF533__) || defined(__ADSPBF561__))
    // first two bytes in the data buffer are used to store the length.
    if((p->Data >0) && (nip->buff_overhead > 0)) 
	    LWIP_ASSERT("Rx data buffers are not aligned properly",CHECK_ALIGNMENT((unsigned int)((char*)p->Data+ 2)));
    #endif /* __ADSPBF537__ */

    p->ElementCount = nip->rx_buff_datalen;
    p->ElementWidth = 1;
    p->CallbackParameter =p;
    p->ProcessedElementCount=0;
    p->ProcessedFlag =0;
    p->PayLoad = 0;
    p->x = netif;
   
    mangle_ptr = ((unsigned int*)&p->Reserved)+4;
    *((unsigned int*)mangle_ptr)= (unsigned int)((char*)p->Data + p->ElementCount - nip->buff_overhead);
    bip = (struct buffer_info*)(*(unsigned int*)mangle_ptr);
    bip->netif = netif;
    bip->max_buf_len = nip->rx_buff_datalen;
    count += 1;
    p = p->pNext;
  }
  nip->rx_buffs = count;
  
  p = tx_head;
  count = 0;
  while (p)
  {
    p->Data = (char*)p + sizeof(ADI_ETHER_BUFFER) + nip->buff_overhead;

    #if defined(__ADSPBF537__)
    if(p->Data >0) 
	    LWIP_ASSERT("Tx data buffers are not aligned properly",CHECK_ALIGNMENT((unsigned int)p->Data));
    #elif (defined(__ADSPBF533__) || defined(__ADSPBF561__))
    // first two bytes in the data buffer are used to store the length.
    if((p->Data >0) && (nip->buff_overhead > 0)) 
	    LWIP_ASSERT("Tx data buffers are not aligned properly",CHECK_ALIGNMENT((unsigned int)((char*)p->Data +2)));
    #endif /* __ADSPBF537__ */

    p->ElementCount = nip->tx_buff_datalen;
    p->ElementWidth = 1;
    p->CallbackParameter =p;
    p->x = netif;
    p->PayLoad = 0;

    mangle_ptr = ((unsigned int*)&p->Reserved)+4;
    *((unsigned int*)mangle_ptr)= (unsigned int)((char*)p->Data + p->ElementCount - nip->buff_overhead);

    bip = (struct buffer_info*)(*(unsigned int*)mangle_ptr);
	
    bip->netif = netif;
    bip->max_buf_len = nip->tx_buff_datalen;
    count += 1;
    p = p->pNext;
  }
  nip->tx_buffs = count;
  
  // set up this interface's TCPIP callback messages
  msg = &nip->txmsg;
  msg->type = TCPIP_MSG_CALLBACK;
  msg->flags = TCPIP_MSG_FLAG_STATIC;
  msg->msg.cb.function = process_xmtd_packets;
  msg->msg.cb.ctx = netif;
  msg = &nip->rxmsg;
  msg->type = TCPIP_MSG_CALLBACK;
  msg->flags = TCPIP_MSG_FLAG_STATIC;
  msg->msg.cb.function = process_rcvd_packets;
  msg->msg.cb.ctx = netif;
  
  // give all the rx buffers to the Ethernet device driver
  adi_dev_Read(nip->handle,ADI_DEV_1D,(ADI_DEV_BUFFER*)rx_head);

  // save the list of tx buffers until they are needed
  nip->x = tx_head;
}
Esempio n. 7
0
int main(int argc, char* argv[])
{
  int x_0 = 5;
  int x_1 = 5;
  int x_2 = 5;
  int x_3 = 5;

  CHECK_ALIGNMENT(x_0, 8);
  CHECK_ALIGNMENT(x_1, 8);
  CHECK_ALIGNMENT(x_2, 8);
  CHECK_ALIGNMENT(x_3, 8);

  std::cout << std::endl;

  AlignedData<int, 128> y_0_128 = 5;
  AlignedData<int, 128> y_1_128 = 5;
  AlignedData<int, 128> y_2_128 = 5;
  AlignedData<int, 128> y_3_128 = 5;

  CHECK_ALIGNMENT(y_0_128, 128);
  CHECK_ALIGNMENT(y_1_128, 128);
  CHECK_ALIGNMENT(y_2_128, 128);
  CHECK_ALIGNMENT(y_3_128, 128);

  std::cout << std::endl;

  AlignedData<std::array<double, 1>, 16> realNumbers_0_16;
  AlignedData<std::array<double, 1>, 16> realNumbers_1_16;
  AlignedData<std::array<double, 1>, 16> realNumbers_2_16;
  AlignedData<std::array<double, 1>, 16> realNumbers_3_16;

  CHECK_ALIGNMENT(realNumbers_0_16, 64);
  CHECK_ALIGNMENT(realNumbers_1_16, 64);
  CHECK_ALIGNMENT(realNumbers_2_16, 64);
  CHECK_ALIGNMENT(realNumbers_3_16, 64);

  std::cout << std::endl;
}