示例#1
0
static exception_type_t
operation(conf_object_t *obj, generic_transaction_t *mop, map_info_t info)
{
        byte_dump_device_t *bdd = (byte_dump_device_t *)obj;
        int offset = mop->physical_address + info.start - info.base;

        if (SIM_mem_op_is_read(mop)) {

                if (mop->inquiry)
                        return Sim_PE_Inquiry_Unhandled;

                SIM_log_error(&bdd->log, 0,"Only write accesses allowed.");
                SIM_set_mem_op_value_le(mop, 0);
        } else {
		uint8 value = SIM_get_mem_op_value_le(mop);

                if (mop->size != 1) {
                        SIM_log_error(&bdd->log, 0,
                                      "Only byte accesses allowed.");
                }

		SIM_log_info(2, &bdd->log, 0,
			     "Write to offset %d, value 0x%x: '%c'",
                             offset, value,
                             isprint(value) ? value : ' ');

		if (bdd->fd >= 0)
			write(bdd->fd, &value, 1);
        }
        return Sim_PE_No_Exception;
}
示例#2
0
static exception_type_t
sample_operation(conf_object_t *obj, generic_transaction_t *mop,
                 map_info_t info)
{
    sample_device_t *sample = (sample_device_t *)obj;
    int offset = (int)(mop->physical_address + info.start - info.base);

    if (SIM_mem_op_is_read(mop)) {
        SIM_log_info(1, &sample->log, 0,
                     "Read from offset %d.", offset);
        SIM_set_mem_op_value_le(mop, 0);
    } else {
        SIM_log_info(1, &sample->log, 0,
                     "Write to offset %d.", offset);
    }
    return Sim_PE_No_Exception;
}