示例#1
0
int bg_f_chunk_read(bg_f_io_t * io, bg_f_chunk_t * ch)
  {
  ch->start = io->ftell_callback(io->data);
  if(!read_32(io, &ch->type) ||
     !read_64(io, &ch->size))
    return 0;
  return 1;
  }
示例#2
0
int place_bad_addresses(struct ctx *p_ctx, int action)
{
    int cnt = NUM_CMDS;
    int wait_try=MAX_TRY_WAIT;
    int p_cmd = 0;
    int i;
    __u64 room;
    __u64 baddr = 0x1234;

    /* make memory updates visible to AFU before MMIO */
    asm volatile( "lwsync" : : );
    if (2 == action)
    {
        // set up bad HRRQ address
        write_64(&p_ctx->p_host_map->rrq_start, (__u64)0x456123);
        write_64(&p_ctx->p_host_map->rrq_end, (__u64)0x895e6fe);
        bad_address= true;
    }

    if (3 == action)
    {
        //cmd_room violation
        room = read_64(&p_ctx->p_host_map->cmd_room);
        debug("%d:placing %d cmds in 0X%"PRIX64" cmd_room...\n",pid,NUM_CMDS,room);
        for (i=0;i<NUM_CMDS ;i++)
            write_64(&p_ctx->p_host_map->ioarrin,
                     (__u64)&p_ctx->cmd[i].rcb);
        bad_address= true;
        return 0;
    }
    while (cnt)
    {
        room = read_64(&p_ctx->p_host_map->cmd_room);
        if (0 == room)
        {
            usleep(MC_BLOCK_DELAY_ROOM);
            wait_try--;
        }
        if (0 == wait_try)
        {
            fprintf(stderr, "%d: send cmd wait over %d cmd remain\n",
                    pid, cnt);
            return -1;
        }
        for (i = 0; i < room; i++)
        {
            // add a usleep here if room=0 ?
            // write IOARRIN
            if (1 == action)
            {
                //bad RCB address
                write_64(&p_ctx->p_host_map->ioarrin, baddr*i);
                bad_address= true;
            }
            else
            {
                write_64(&p_ctx->p_host_map->ioarrin,
                         (__u64)&p_ctx->cmd[p_cmd++].rcb);
            }
            wait_try = MAX_TRY_WAIT; //each cmd give try max time
            if (cnt-- == 1) break;
        }
    }
    return 0;
}
示例#3
0
Buffer::ConstPointer
Buffer::read(uint64_t &out_value) const throw(KafkaError) {
    out_value = *reinterpret_cast<const uint64_t *>(read_64());
    return shared_from_this();
}