void register_write_memory(void *opaque, hwaddr addr, uint64_t value, unsigned size) { RegisterInfoArray *reg_array = opaque; RegisterInfo *reg = NULL; uint64_t we; int i; for (i = 0; i < reg_array->num_elements; i++) { if (reg_array->r[i]->access->addr == addr) { reg = reg_array->r[i]; break; } } if (!reg) { qemu_log_mask(LOG_GUEST_ERROR, "Write to unimplemented register at " \ "address: %#" PRIx64 "\n", addr); return; } /* Generate appropriate write enable mask */ if (reg->data_size < size) { we = MAKE_64BIT_MASK(0, reg->data_size * 8); } else { we = MAKE_64BIT_MASK(0, size * 8); } register_write(reg, value, we, reg_array->prefix, reg_array->debug); }
static inline uint64_t register_enabled_mask(int data_size, unsigned size) { if (data_size < size) { size = data_size; } return MAKE_64BIT_MASK(0, size * 8); }
static void tc6393xb_gpio_handler_update(TC6393xbState *s) { uint32_t level, diff; int bit; level = s->gpio_level & s->gpio_dir; level &= MAKE_64BIT_MASK(0, TC6393XB_GPIOS); for (diff = s->prev_level ^ level; diff; diff ^= 1 << bit) { bit = ctz32(diff); qemu_set_irq(s->handler[bit], (level >> bit) & 1); } s->prev_level = level; }
static void amdvi_generate_msi_interrupt(AMDVIState *s) { MSIMessage msg = {}; MemTxAttrs attrs = { .requester_id = pci_requester_id(&s->pci.dev) }; if (msi_enabled(&s->pci.dev)) { msg = msi_get_message(&s->pci.dev, 0); address_space_stl_le(&address_space_memory, msg.address, msg.data, attrs, NULL); } } static void amdvi_log_event(AMDVIState *s, uint64_t *evt) { /* event logging not enabled */ if (!s->evtlog_enabled || amdvi_test_mask(s, AMDVI_MMIO_STATUS, AMDVI_MMIO_STATUS_EVT_OVF)) { return; } /* event log buffer full */ if (s->evtlog_tail >= s->evtlog_len) { amdvi_assign_orq(s, AMDVI_MMIO_STATUS, AMDVI_MMIO_STATUS_EVT_OVF); /* generate interrupt */ amdvi_generate_msi_interrupt(s); return; } if (dma_memory_write(&address_space_memory, s->evtlog + s->evtlog_tail, &evt, AMDVI_EVENT_LEN)) { trace_amdvi_evntlog_fail(s->evtlog, s->evtlog_tail); } s->evtlog_tail += AMDVI_EVENT_LEN; amdvi_assign_orq(s, AMDVI_MMIO_STATUS, AMDVI_MMIO_STATUS_COMP_INT); amdvi_generate_msi_interrupt(s); } static void amdvi_setevent_bits(uint64_t *buffer, uint64_t value, int start, int length) { int index = start / 64, bitpos = start % 64; uint64_t mask = MAKE_64BIT_MASK(start, length); buffer[index] &= ~mask; buffer[index] |= (value << bitpos) & mask; }