Ejemplo n.º 1
0
main()
{
  int i, j;

  my_init(MEMORY_SIZE, PHYSICAL_MEM_LIMIT);
	/* The MEMORY SIZE is in megabytes */
	/* PHYSICAL MEMORY SIZE is in number of system pages */
	/* The page size on Sparc 4 and Sparc 5 is 4Kb */

  dump_out();
  for (i = 0; i < NUM_BUFS; i++)
    {
      sbuf[i] = (char *)my_malloc(SMALL_BUF_SIZE);
      lbuf[i] = (char *)my_malloc(LARGE_BUF_SIZE);
      printf("The buffer small pointers is %x and large pointer is %x.\n",(unsigned)sbuf[i],(unsigned)lbuf[i] );
      dump_out();
    }
 
  for (i = 0; i < NUM_BUFS; i++)
    {
      memset(temp_buffer, 'A'+i, LARGE_BUF_SIZE);
      my_write(sbuf[i], SMALL_BUF_SIZE, temp_buffer);
      my_write(lbuf[i], LARGE_BUF_SIZE, temp_buffer);
      my_read(lbuf[i], LARGE_BUF_SIZE, temp_buffer);
    }

  read_start();

  my_read(lbuf[NUM_BUFS-1], LARGE_BUF_SIZE, temp_buffer);
  my_write(lbuf[0], LARGE_BUF_SIZE, temp_buffer);

  my_read(lbuf[NUM_BUFS - 1], LARGE_BUF_SIZE, temp_buffer);
  my_write(lbuf[1]+5, 3, temp_buffer);

  my_read(sbuf[NUM_BUFS-1], SMALL_BUF_SIZE, temp_buffer);
  my_write(sbuf[0], SMALL_BUF_SIZE, temp_buffer);

  my_read(sbuf[NUM_BUFS - 1], SMALL_BUF_SIZE, temp_buffer);
  my_write(sbuf[1]+5, 3, temp_buffer);

  read_start();

  for (i = 0; i < NUM_BUFS; i++)
    {
      memset(temp_buffer, 'Z'-i, LARGE_BUF_SIZE);
      my_write(sbuf[i] + 5, SMALL_BUF_SIZE - 5, temp_buffer);
      my_read(sbuf[i], SMALL_BUF_SIZE, temp_buffer);
      my_write(lbuf[i] + 5, LARGE_BUF_SIZE - 5, temp_buffer);
    }

  read_start();

  for (i = 0; i < NUM_BUFS; i++) {
    my_free((void *) sbuf[i]);
    my_free((void *) lbuf[i]);
  }
  dump_out();

  my_terminate();
}
Ejemplo n.º 2
0
bool USBTester::setup_iterface(uint8_t ep_in, uint8_t ep_out, uint32_t ep_size, usb_ep_type_t ep_type,
                               uint8_t *buf, uint32_t buf_size, void (USBTester::*callback)())
{
    bool success = false;

    success = endpoint_add(ep_in, ep_size, ep_type);
    success &= endpoint_add(ep_out, ep_size, ep_type, callback);
    success &= read_start(ep_out, buf, buf_size);
    return success;
}
Ejemplo n.º 3
0
int vmailmgr_autoconvert(void)
{
  int writefd = -1;
  ibuf reader;
  struct cdb_make writer;
  int error = 0;
  int readall = 0;
  int writerr = 0;
  if ((writefd = path_mktemp(pwfile, &tmppwfile)) != -1) {

    if (cdb_make_start(&writer, writefd) != 0)
      error = CVME_IO | CVME_FATAL;
    else {

      if (ibuf_open(&reader, pwfile, 0)) {

	uint32 end;
	struct stat st;
	if (fstat(reader.io.fd, &st) == 0
	    && fchmod(writefd, st.st_mode) == 0
	    && fchown(writefd, st.st_uid, st.st_gid) == 0
	    && read_start(&reader, &end)) {
	  while (ibuf_tell(&reader) < end) {
	    if (!read_cdb_pair(&reader, &key, &data))
	      break;
	    if (str_diff(&key, &virtuser) == 0)
	      if (!convert_data()) {
		writerr = 1;
		break;
	      }
	    if (cdb_make_add(&writer, key.s, key.len, data.s, data.len) != 0) {
	      writerr = 1;
	      break;
	    }
	  }
	  readall = ibuf_tell(&reader) == end;
	}
	ibuf_close(&reader);
      }
      if (cdb_make_finish(&writer) != 0)
	error |= CVME_FATAL;
      else
	if (readall && !writerr)
	  rename(tmppwfile.s, pwfile);
    }
    close(writefd);
    unlink(tmppwfile.s);
  }
  return error;
}
Ejemplo n.º 4
0
void SerialPort::read_complete(const boost::system::error_code& error, size_t bytes_transferred)
{
    // La operacion de lectura asyncrona ya termino o fallo y retornara el error
    if (!error)
    {
        // lectura completada, por lo tanto procesamos los datos
        //std::cout.write(read_msg_, bytes_transferred); // eco a la salida estandar

        // Los mensajes los mandamos a todos, consola incluida.
        std::string notifier_ = std::string("Read Serial: ");
        notifier_ += read_msg_;
        SendReadToClients(notifier_);

        read_start(); // Inicia la espera para otra lectura asyncrona otra vez
    }
    else
        do_close(error);
}
Ejemplo n.º 5
0
Archivo: main.c Proyecto: bvdberg/code
void* consumer(void* ptr)
{
    Buffer* buf = (Buffer*)ptr;
    while (1) {
        int slot = read_start(buf);
        if (slot == -1) {
            printf(ANSI_RED"consumer: no data in queue...waiting"ANSI_NORMAL"\n");
            usleep(consumer_delay);
            continue;
        }
        
        //printf(ANSI_RED"consumer: slot %d"ANSI_NORMAL"\n", slot);
        buffer_print(buf);
        usleep(consume_duration);
        read_done(buf);
        buffer_print(buf);
    }

    return 0;
}
Ejemplo n.º 6
0
void USBTester::epbulk_out_callback()
{
    read_finish(bulk_out);
    read_start(bulk_out, bulk_buf, sizeof(bulk_buf));
}
Ejemplo n.º 7
0
void USBTester::epint_out_callback()
{
    read_finish(int_out);
    read_start(int_out, int_buf, sizeof(int_buf));
}