Lines Matching +full:- +full:- +full:-
20 #include "hw/qdev-properties.h"
41 #define PL330_FIFO_ERR (-1)
325 len = MIN(16, size - b); in pl330_hexdump()
328 trace_pl330_hexdump(b, str->str); in pl330_hexdump()
335 * stored in this buffer. Data is stored in BUF field, tags - in the
343 s->buf = g_malloc0(size); in pl330_fifo_init()
344 s->tag = g_malloc0(size); in pl330_fifo_init()
345 s->buf_size = size; in pl330_fifo_init()
352 return (x + 1) % s->buf_size; in pl330_fifo_inc()
359 return s->buf_size - s->num; in pl330_fifo_num_free()
372 if (s->buf_size - s->num < len) { in pl330_fifo_push()
376 int push_idx = (s->head + s->num + i) % s->buf_size; in pl330_fifo_push()
377 s->buf[push_idx] = buf[i]; in pl330_fifo_push()
378 s->tag[push_idx] = tag; in pl330_fifo_push()
380 s->num += len; in pl330_fifo_push()
394 if (s->num < len) { in pl330_fifo_get()
398 if (s->tag[s->head] == tag) { in pl330_fifo_get()
399 int get_idx = (s->head + i) % s->buf_size; in pl330_fifo_get()
400 buf[i] = s->buf[get_idx]; in pl330_fifo_get()
401 } else { /* Tag mismatch - Rollback transaction */ in pl330_fifo_get()
405 s->head = (s->head + len) % s->buf_size; in pl330_fifo_get()
406 s->num -= len; in pl330_fifo_get()
414 s->head = 0; in pl330_fifo_reset()
415 s->num = 0; in pl330_fifo_reset()
424 return (!s->num) ? PL330_UNTAGGED : s->tag[s->head]; in pl330_fifo_tag()
427 /* Returns non-zero if tag TAG is present in fifo or zero otherwise */
433 i = s->head; in pl330_fifo_has_tag()
434 for (n = 0; n < s->num; n++) { in pl330_fifo_has_tag()
435 if (s->tag[i] == tag) { in pl330_fifo_has_tag()
449 t = i = s->head; in pl330_fifo_tagged_remove()
450 for (n = 0; n < s->num; n++) { in pl330_fifo_tagged_remove()
451 if (s->tag[i] != tag) { in pl330_fifo_tagged_remove()
452 s->buf[t] = s->buf[i]; in pl330_fifo_tagged_remove()
453 s->tag[t] = s->tag[i]; in pl330_fifo_tagged_remove()
456 s->num = s->num - 1; in pl330_fifo_tagged_remove()
462 /* Read-Write Queue implementation
464 * A Read-Write Queue stores up to QUEUE_SIZE instructions (loads or stores).
477 * HI_SEQN[TAG]-1 inclusive. SEQN is 8-bit unsigned integer, so SEQN=255 is
488 for (i = 0; i < s->queue_size; i++) { in pl330_queue_reset()
489 s->queue[i].tag = PL330_UNTAGGED; in pl330_queue_reset()
496 s->parent = parent; in pl330_queue_init()
497 s->queue = g_new0(PL330QueueEntry, size); in pl330_queue_init()
498 s->queue_size = size; in pl330_queue_init()
506 for (i = 0; i < s->queue_size; i++) { in pl330_queue_find_empty()
507 if (s->queue[i].tag == PL330_UNTAGGED) { in pl330_queue_find_empty()
508 return &s->queue[i]; in pl330_queue_find_empty()
516 * - zero - OK
517 * - non-zero - queue is full
528 entry->tag = tag; in pl330_queue_put_insn()
529 entry->addr = addr; in pl330_queue_put_insn()
530 entry->len = len; in pl330_queue_put_insn()
531 entry->n = n; in pl330_queue_put_insn()
532 entry->z = z; in pl330_queue_put_insn()
533 entry->inc = inc; in pl330_queue_put_insn()
534 entry->seqn = s->parent->hi_seqn[tag]; in pl330_queue_put_insn()
535 s->parent->hi_seqn[tag]++; in pl330_queue_put_insn()
541 * - it has valid tag value (not PL330_UNTAGGED)
542 * - if enforce_seq is set it has to be issuable without violating queue
544 * - if TAG argument is not PL330_UNTAGGED this instruction has tag value
554 for (i = 0; i < s->queue_size; i++) { in pl330_queue_find_insn()
555 if (s->queue[i].tag != PL330_UNTAGGED) { in pl330_queue_find_insn()
557 s->queue[i].seqn == s->parent->lo_seqn[s->queue[i].tag]) && in pl330_queue_find_insn()
558 (s->queue[i].tag == tag || tag == PL330_UNTAGGED || in pl330_queue_find_insn()
559 s->queue[i].z)) { in pl330_queue_find_insn()
560 return &s->queue[i]; in pl330_queue_find_insn()
571 s->parent->lo_seqn[e->tag]++; in pl330_queue_remove_insn()
572 e->tag = PL330_UNTAGGED; in pl330_queue_remove_insn()
581 for (i = 0; i < s->queue_size; i++) { in pl330_queue_remove_tagged()
582 if (s->queue[i].tag == tag) { in pl330_queue_remove_tagged()
583 s->queue[i].tag = PL330_UNTAGGED; in pl330_queue_remove_tagged()
595 ch->fault_type |= flags; in pl330_fault()
596 if (ch->state == pl330_chan_fault) { in pl330_fault()
599 ch->state = pl330_chan_fault; in pl330_fault()
600 ch->parent->num_faulting++; in pl330_fault()
601 if (ch->parent->num_faulting == 1) { in pl330_fault()
603 qemu_irq_raise(ch->parent->irq_abort); in pl330_fault()
611 * CH - channel executing the instruction
612 * OPCODE - opcode
613 * ARGS - array of 8-bit arguments
614 * LEN - number of elements in ARGS array
624 if (ch->is_manager) { in pl330_dmaadxh()
629 ch->dst += im; in pl330_dmaadxh()
631 ch->src += im; in pl330_dmaadxh()
648 PL330State *s = ch->parent; in pl330_dmaend()
650 if (ch->state == pl330_chan_executing && !ch->is_manager) { in pl330_dmaend()
652 if (pl330_fifo_has_tag(&s->fifo, ch->tag) || in pl330_dmaend()
653 pl330_queue_find_insn(&s->read_queue, ch->tag, false) != NULL || in pl330_dmaend()
654 pl330_queue_find_insn(&s->write_queue, ch->tag, false) != NULL) { in pl330_dmaend()
656 ch->stall = 1; in pl330_dmaend()
661 pl330_fifo_tagged_remove(&s->fifo, ch->tag); in pl330_dmaend()
662 pl330_queue_remove_tagged(&s->read_queue, ch->tag); in pl330_dmaend()
663 pl330_queue_remove_tagged(&s->write_queue, ch->tag); in pl330_dmaend()
664 ch->state = pl330_chan_stopped; in pl330_dmaend()
677 if (periph_id >= ch->parent->num_periph_req) { in pl330_dmaflushp()
681 if (ch->ns && !(ch->parent->cfg[CFG_PNS] & (1 << periph_id))) { in pl330_dmaflushp()
697 if (!ch->is_manager) { in pl330_dmago()
707 if (chan_id >= ch->parent->num_chnls) { in pl330_dmago()
713 if (ch->parent->chan[chan_id].state != pl330_chan_stopped) { in pl330_dmago()
717 if (ch->ns && !ns) { in pl330_dmago()
721 s = &ch->parent->chan[chan_id]; in pl330_dmago()
722 s->ns = ns; in pl330_dmago()
723 s->pc = pc; in pl330_dmago()
724 s->state = pl330_chan_executing; in pl330_dmago()
737 if ((bs == 1 && ch->request_flag == PL330_BURST) || in pl330_dmald()
738 (bs == 3 && ch->request_flag == PL330_SINGLE)) { in pl330_dmald()
742 if (bs == 1 && ch->request_flag == PL330_SINGLE) { in pl330_dmald()
745 num = ((ch->control >> 4) & 0xf) + 1; in pl330_dmald()
747 size = (uint32_t)1 << ((ch->control >> 1) & 0x7); in pl330_dmald()
748 inc = !!(ch->control & 1); in pl330_dmald()
749 ch->stall = pl330_queue_put_insn(&ch->parent->read_queue, ch->src, in pl330_dmald()
750 size, num, inc, 0, ch->tag); in pl330_dmald()
751 if (!ch->stall) { in pl330_dmald()
752 trace_pl330_dmald(ch->tag, ch->src, size, num, inc ? 'Y' : 'N'); in pl330_dmald()
753 ch->src += inc ? size * num - (ch->src & (size - 1)) : 0; in pl330_dmald()
766 if (periph_id >= ch->parent->num_periph_req) { in pl330_dmaldp()
770 if (ch->ns && !(ch->parent->cfg[CFG_PNS] & (1 << periph_id))) { in pl330_dmaldp()
781 ch->lc[lc] = args[0]; in pl330_dmalp()
786 if (ch->state == pl330_chan_fault || in pl330_dmakill()
787 ch->state == pl330_chan_fault_completing) { in pl330_dmakill()
789 ch->fault_type = 0; in pl330_dmakill()
790 ch->parent->num_faulting--; in pl330_dmakill()
791 if (ch->parent->num_faulting == 0) { in pl330_dmakill()
793 qemu_irq_lower(ch->parent->irq_abort); in pl330_dmakill()
796 ch->state = pl330_chan_killing; in pl330_dmakill()
797 pl330_fifo_tagged_remove(&ch->parent->fifo, ch->tag); in pl330_dmakill()
798 pl330_queue_remove_tagged(&ch->parent->read_queue, ch->tag); in pl330_dmakill()
799 pl330_queue_remove_tagged(&ch->parent->write_queue, ch->tag); in pl330_dmakill()
800 ch->state = pl330_chan_stopped; in pl330_dmakill()
810 trace_pl330_dmalpend(nf, bs, lc, ch->lc[lc], ch->request_flag); in pl330_dmalpend()
816 if ((bs == 1 && ch->request_flag == PL330_BURST) || in pl330_dmalpend()
817 (bs == 3 && ch->request_flag == PL330_SINGLE)) { in pl330_dmalpend()
821 if (!nf || ch->lc[lc]) { in pl330_dmalpend()
823 ch->lc[lc]--; in pl330_dmalpend()
826 ch->pc -= args[0]; in pl330_dmalpend()
827 ch->pc -= len + 1; in pl330_dmalpend()
828 /* "ch->pc -= args[0] + len + 1" is incorrect when args[0] == 256 */ in pl330_dmalpend()
848 ch->src = im; in pl330_dmamov()
851 ch->control = im; in pl330_dmamov()
854 ch->dst = im; in pl330_dmamov()
870 if (pl330_queue_find_insn(&ch->parent->read_queue, ch->tag, false)) { in pl330_dmarmb()
871 ch->state = pl330_chan_at_barrier; in pl330_dmarmb()
872 ch->stall = 1; in pl330_dmarmb()
875 ch->state = pl330_chan_executing; in pl330_dmarmb()
888 if (ev_id >= ch->parent->num_events) { in pl330_dmasev()
892 if (ch->ns && !(ch->parent->cfg[CFG_INS] & (1 << ev_id))) { in pl330_dmasev()
896 if (ch->parent->inten & (1 << ev_id)) { in pl330_dmasev()
897 ch->parent->int_status |= (1 << ev_id); in pl330_dmasev()
899 qemu_irq_raise(ch->parent->irq[ev_id]); in pl330_dmasev()
902 ch->parent->ev_status |= (1 << ev_id); in pl330_dmasev()
915 if ((bs == 1 && ch->request_flag == PL330_BURST) || in pl330_dmast()
916 (bs == 3 && ch->request_flag == PL330_SINGLE)) { in pl330_dmast()
920 num = ((ch->control >> 18) & 0xf) + 1; in pl330_dmast()
921 size = (uint32_t)1 << ((ch->control >> 15) & 0x7); in pl330_dmast()
922 inc = !!((ch->control >> 14) & 1); in pl330_dmast()
923 ch->stall = pl330_queue_put_insn(&ch->parent->write_queue, ch->dst, in pl330_dmast()
924 size, num, inc, 0, ch->tag); in pl330_dmast()
925 if (!ch->stall) { in pl330_dmast()
926 trace_pl330_dmast(ch->tag, ch->dst, size, num, inc ? 'Y' : 'N'); in pl330_dmast()
927 ch->dst += inc ? size * num - (ch->dst & (size - 1)) : 0; in pl330_dmast()
941 if (periph_id >= ch->parent->num_periph_req) { in pl330_dmastp()
945 if (ch->ns && !(ch->parent->cfg[CFG_PNS] & (1 << periph_id))) { in pl330_dmastp()
958 num = ((ch->control >> 18) & 0xf) + 1; in pl330_dmastz()
959 size = (uint32_t)1 << ((ch->control >> 15) & 0x7); in pl330_dmastz()
960 inc = !!((ch->control >> 14) & 1); in pl330_dmastz()
961 ch->stall = pl330_queue_put_insn(&ch->parent->write_queue, ch->dst, in pl330_dmastz()
962 size, num, inc, 1, ch->tag); in pl330_dmastz()
964 ch->dst += size * num; in pl330_dmastz()
979 if (ev_id >= ch->parent->num_events) { in pl330_dmawfe()
983 if (ch->ns && !(ch->parent->cfg[CFG_INS] & (1 << ev_id))) { in pl330_dmawfe()
987 ch->wakeup = ev_id; in pl330_dmawfe()
988 ch->state = pl330_chan_waiting_event; in pl330_dmawfe()
989 if (~ch->parent->inten & ch->parent->ev_status & 1 << ev_id) { in pl330_dmawfe()
990 ch->state = pl330_chan_executing; in pl330_dmawfe()
994 for (i = 0; i < ch->parent->num_chnls; ++i) { in pl330_dmawfe()
995 PL330Chan *peer = &ch->parent->chan[i]; in pl330_dmawfe()
996 if (peer->state == pl330_chan_waiting_event && in pl330_dmawfe()
997 peer->wakeup == ev_id) { in pl330_dmawfe()
1001 ch->parent->ev_status &= ~(1 << ev_id); in pl330_dmawfe()
1004 ch->stall = 1; in pl330_dmawfe()
1019 if (periph_id >= ch->parent->num_periph_req) { in pl330_dmawfp()
1023 if (ch->ns && !(ch->parent->cfg[CFG_PNS] & (1 << periph_id))) { in pl330_dmawfp()
1029 ch->request_flag = PL330_SINGLE; in pl330_dmawfp()
1030 ch->wfp_sbp = 0; in pl330_dmawfp()
1033 ch->request_flag = PL330_BURST; in pl330_dmawfp()
1034 ch->wfp_sbp = 2; in pl330_dmawfp()
1037 ch->request_flag = PL330_BURST; in pl330_dmawfp()
1038 ch->wfp_sbp = 1; in pl330_dmawfp()
1045 if (ch->parent->periph_busy[periph_id]) { in pl330_dmawfp()
1046 ch->state = pl330_chan_waiting_periph; in pl330_dmawfp()
1047 ch->stall = 1; in pl330_dmawfp()
1048 } else if (ch->state == pl330_chan_waiting_periph) { in pl330_dmawfp()
1049 ch->state = pl330_chan_executing; in pl330_dmawfp()
1056 if (pl330_queue_find_insn(&ch->parent->write_queue, ch->tag, false)) { in pl330_dmawmb()
1057 ch->state = pl330_chan_at_barrier; in pl330_dmawmb()
1058 ch->stall = 1; in pl330_dmawmb()
1061 ch->state = pl330_chan_executing; in pl330_dmawmb()
1106 dma_memory_read(ch->parent->mem_as, ch->pc, &opcode, 1, in pl330_fetch_insn()
1120 assert(insn->size <= PL330_INSN_MAXSIZE); in pl330_exec_insn()
1121 dma_memory_read(ch->parent->mem_as, ch->pc, buf, insn->size, in pl330_exec_insn()
1123 insn->exec(ch, buf[0], &buf[1], insn->size - 1); in pl330_exec_insn()
1129 ch->pc += insn->size; in pl330_update_pc()
1138 if (ch->state != pl330_chan_executing && in pl330_chan_exec()
1139 ch->state != pl330_chan_waiting_periph && in pl330_chan_exec()
1140 ch->state != pl330_chan_at_barrier && in pl330_chan_exec()
1141 ch->state != pl330_chan_waiting_event) { in pl330_chan_exec()
1144 ch->stall = 0; in pl330_chan_exec()
1152 if (!ch->stall) { in pl330_chan_exec()
1154 ch->watchdog_timer = 0; in pl330_chan_exec()
1157 } else if (ch->state == pl330_chan_executing) { in pl330_chan_exec()
1158 ch->watchdog_timer++; in pl330_chan_exec()
1159 if (ch->watchdog_timer >= PL330_WATCHDOG_LIMIT) { in pl330_chan_exec()
1171 PL330State *s = channel->parent; in pl330_exec_cycle()
1182 q = pl330_queue_find_insn(&s->read_queue, PL330_UNTAGGED, true); in pl330_exec_cycle()
1183 if (q != NULL && q->len <= pl330_fifo_num_free(&s->fifo)) { in pl330_exec_cycle()
1184 int len = q->len - (q->addr & (q->len - 1)); in pl330_exec_cycle()
1186 dma_memory_read(s->mem_as, q->addr, buf, len, in pl330_exec_cycle()
1188 trace_pl330_exec_cycle(q->addr, len); in pl330_exec_cycle()
1192 fifo_res = pl330_fifo_push(&s->fifo, buf, len, q->tag); in pl330_exec_cycle()
1194 if (q->inc) { in pl330_exec_cycle()
1195 q->addr += len; in pl330_exec_cycle()
1197 q->n--; in pl330_exec_cycle()
1198 if (!q->n) { in pl330_exec_cycle()
1199 pl330_queue_remove_insn(&s->read_queue, q); in pl330_exec_cycle()
1206 q = pl330_queue_find_insn(&s->write_queue, pl330_fifo_tag(&s->fifo), true); in pl330_exec_cycle()
1208 int len = q->len - (q->addr & (q->len - 1)); in pl330_exec_cycle()
1210 if (q->z) { in pl330_exec_cycle()
1215 fifo_res = pl330_fifo_get(&s->fifo, buf, len, q->tag); in pl330_exec_cycle()
1217 if (fifo_res == PL330_FIFO_OK || q->z) { in pl330_exec_cycle()
1218 dma_memory_write(s->mem_as, q->addr, buf, len, in pl330_exec_cycle()
1220 trace_pl330_exec_cycle(q->addr, len); in pl330_exec_cycle()
1224 if (q->inc) { in pl330_exec_cycle()
1225 q->addr += len; in pl330_exec_cycle()
1229 pl330_fault(&channel->parent->chan[q->tag], in pl330_exec_cycle()
1232 q->n--; in pl330_exec_cycle()
1233 if (!q->n) { in pl330_exec_cycle()
1234 pl330_queue_remove_insn(&s->write_queue, q); in pl330_exec_cycle()
1245 /* TODO: Is it all right to execute everything or should we do per-cycle in pl330_exec_channel()
1252 if (channel->state == pl330_chan_executing) { in pl330_exec_channel()
1267 insr_exec = pl330_exec_channel(&s->manager); in pl330_exec()
1269 for (i = 0; i < s->num_chnls; i++) { in pl330_exec()
1270 insr_exec += pl330_exec_channel(&s->chan[i]); in pl330_exec()
1287 if (s->periph_busy[irq] != level) { in pl330_dma_stop_irq()
1288 s->periph_busy[irq] = level; in pl330_dma_stop_irq()
1289 timer_mod(s->timer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL)); in pl330_dma_stop_irq()
1302 s->debug_status = 1; in pl330_debug_exec()
1303 chan_id = (s->dbg[0] >> 8) & 0x07; in pl330_debug_exec()
1304 opcode = (s->dbg[0] >> 16) & 0xff; in pl330_debug_exec()
1305 args[0] = (s->dbg[0] >> 24) & 0xff; in pl330_debug_exec()
1306 args[1] = (s->dbg[1] >> 0) & 0xff; in pl330_debug_exec()
1307 args[2] = (s->dbg[1] >> 8) & 0xff; in pl330_debug_exec()
1308 args[3] = (s->dbg[1] >> 16) & 0xff; in pl330_debug_exec()
1309 args[4] = (s->dbg[1] >> 24) & 0xff; in pl330_debug_exec()
1311 if (s->dbg[0] & 1) { in pl330_debug_exec()
1312 ch = &s->chan[chan_id]; in pl330_debug_exec()
1314 ch = &s->manager; in pl330_debug_exec()
1326 ch->stall = 0; in pl330_debug_exec()
1327 insn->exec(ch, opcode, args, insn->size - 1); in pl330_debug_exec()
1328 if (ch->fault_type) { in pl330_debug_exec()
1329 ch->fault_type |= PL330_FAULT_DBG_INSTR; in pl330_debug_exec()
1331 if (ch->stall) { in pl330_debug_exec()
1336 s->debug_status = 0; in pl330_debug_exec()
1351 s->inten = value; in pl330_iomem_write()
1354 for (i = 0; i < s->num_events; i++) { in pl330_iomem_write()
1355 if (s->int_status & s->inten & value & (1 << i)) { in pl330_iomem_write()
1357 qemu_irq_lower(s->irq[i]); in pl330_iomem_write()
1360 s->ev_status &= ~(value & s->inten); in pl330_iomem_write()
1361 s->int_status &= ~(value & s->inten); in pl330_iomem_write()
1374 s->dbg[0] = value; in pl330_iomem_write()
1377 s->dbg[1] = value; in pl330_iomem_write()
1395 return pl330_id[(offset - PL330_REG_PERIPH_ID) >> 2]; in pl330_iomem_read_imp()
1398 return s->cfg[(offset - PL330_REG_CR0_BASE) >> 2]; in pl330_iomem_read_imp()
1401 offset -= PL330_REG_CHANCTRL; in pl330_iomem_read_imp()
1403 if (chan_id >= s->num_chnls) { in pl330_iomem_read_imp()
1410 return s->chan[chan_id].src; in pl330_iomem_read_imp()
1412 return s->chan[chan_id].dst; in pl330_iomem_read_imp()
1414 return s->chan[chan_id].control; in pl330_iomem_read_imp()
1416 return s->chan[chan_id].lc[0]; in pl330_iomem_read_imp()
1418 return s->chan[chan_id].lc[1]; in pl330_iomem_read_imp()
1426 offset -= PL330_REG_CSR_BASE; in pl330_iomem_read_imp()
1428 if (chan_id >= s->num_chnls) { in pl330_iomem_read_imp()
1435 res = (s->chan[chan_id].ns << 21) | in pl330_iomem_read_imp()
1436 (s->chan[chan_id].wakeup << 4) | in pl330_iomem_read_imp()
1437 (s->chan[chan_id].state) | in pl330_iomem_read_imp()
1438 (s->chan[chan_id].wfp_sbp << 14); in pl330_iomem_read_imp()
1441 return s->chan[chan_id].pc; in pl330_iomem_read_imp()
1448 offset -= PL330_REG_FTR_BASE; in pl330_iomem_read_imp()
1450 if (chan_id >= s->num_chnls) { in pl330_iomem_read_imp()
1455 return s->chan[chan_id].fault_type; in pl330_iomem_read_imp()
1459 return (s->manager.ns << 9) | (s->manager.wakeup << 4) | in pl330_iomem_read_imp()
1460 (s->manager.state & 0xf); in pl330_iomem_read_imp()
1462 return s->manager.pc; in pl330_iomem_read_imp()
1464 return s->inten; in pl330_iomem_read_imp()
1466 return s->ev_status; in pl330_iomem_read_imp()
1468 return s->int_status; in pl330_iomem_read_imp()
1475 return s->manager.state ? 1 : 0; in pl330_iomem_read_imp()
1478 for (i = 0; i < s->num_chnls; i++) { in pl330_iomem_read_imp()
1479 if (s->chan[i].state == pl330_chan_fault || in pl330_iomem_read_imp()
1480 s->chan[i].state == pl330_chan_fault_completing) { in pl330_iomem_read_imp()
1486 return s->manager.fault_type; in pl330_iomem_read_imp()
1488 return s->debug_status; in pl330_iomem_read_imp()
1518 ch->src = 0; in pl330_chan_reset()
1519 ch->dst = 0; in pl330_chan_reset()
1520 ch->pc = 0; in pl330_chan_reset()
1521 ch->state = pl330_chan_stopped; in pl330_chan_reset()
1522 ch->watchdog_timer = 0; in pl330_chan_reset()
1523 ch->stall = 0; in pl330_chan_reset()
1524 ch->control = 0; in pl330_chan_reset()
1525 ch->status = 0; in pl330_chan_reset()
1526 ch->fault_type = 0; in pl330_chan_reset()
1534 s->inten = 0; in pl330_reset()
1535 s->int_status = 0; in pl330_reset()
1536 s->ev_status = 0; in pl330_reset()
1537 s->debug_status = 0; in pl330_reset()
1538 s->num_faulting = 0; in pl330_reset()
1539 s->manager.ns = s->mgr_ns_at_rst; in pl330_reset()
1540 pl330_fifo_reset(&s->fifo); in pl330_reset()
1541 pl330_queue_reset(&s->read_queue); in pl330_reset()
1542 pl330_queue_reset(&s->write_queue); in pl330_reset()
1544 for (i = 0; i < s->num_chnls; i++) { in pl330_reset()
1545 pl330_chan_reset(&s->chan[i]); in pl330_reset()
1547 for (i = 0; i < s->num_periph_req; i++) { in pl330_reset()
1548 s->periph_busy[i] = 0; in pl330_reset()
1551 timer_del(s->timer); in pl330_reset()
1559 sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq_abort); in pl330_realize()
1560 memory_region_init_io(&s->iomem, OBJECT(s), &pl330_ops, s, in pl330_realize()
1562 sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem); in pl330_realize()
1564 if (!s->mem_mr) { in pl330_realize()
1567 } else if (s->mem_mr == get_system_memory()) { in pl330_realize()
1569 s->mem_as = &address_space_memory; in pl330_realize()
1571 s->mem_as = g_new0(AddressSpace, 1); in pl330_realize()
1572 address_space_init(s->mem_as, s->mem_mr, in pl330_realize()
1573 memory_region_name(s->mem_mr)); in pl330_realize()
1576 s->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, pl330_exec_cycle_timer, s); in pl330_realize()
1578 s->cfg[0] = (s->mgr_ns_at_rst ? 0x4 : 0) | in pl330_realize()
1579 (s->num_periph_req > 0 ? 1 : 0) | in pl330_realize()
1580 ((s->num_chnls - 1) & 0x7) << 4 | in pl330_realize()
1581 ((s->num_periph_req - 1) & 0x1f) << 12 | in pl330_realize()
1582 ((s->num_events - 1) & 0x1f) << 17; in pl330_realize()
1584 switch (s->i_cache_len) { in pl330_realize()
1586 s->cfg[1] |= 2; in pl330_realize()
1589 s->cfg[1] |= 3; in pl330_realize()
1592 s->cfg[1] |= 4; in pl330_realize()
1595 s->cfg[1] |= 5; in pl330_realize()
1598 error_setg(errp, "Bad value for i-cache_len property: %" PRIx8, in pl330_realize()
1599 s->i_cache_len); in pl330_realize()
1602 s->cfg[1] |= ((s->num_i_cache_lines - 1) & 0xf) << 4; in pl330_realize()
1604 s->chan = g_new0(PL330Chan, s->num_chnls); in pl330_realize()
1605 s->hi_seqn = g_new0(uint8_t, s->num_chnls); in pl330_realize()
1606 s->lo_seqn = g_new0(uint8_t, s->num_chnls); in pl330_realize()
1607 for (i = 0; i < s->num_chnls; i++) { in pl330_realize()
1608 s->chan[i].parent = s; in pl330_realize()
1609 s->chan[i].tag = (uint8_t)i; in pl330_realize()
1611 s->manager.parent = s; in pl330_realize()
1612 s->manager.tag = s->num_chnls; in pl330_realize()
1613 s->manager.is_manager = true; in pl330_realize()
1615 s->irq = g_new0(qemu_irq, s->num_events); in pl330_realize()
1616 for (i = 0; i < s->num_events; i++) { in pl330_realize()
1617 sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq[i]); in pl330_realize()
1622 switch (s->data_width) { in pl330_realize()
1624 s->cfg[CFG_CRD] |= 0x2; in pl330_realize()
1627 s->cfg[CFG_CRD] |= 0x3; in pl330_realize()
1630 s->cfg[CFG_CRD] |= 0x4; in pl330_realize()
1634 s->data_width); in pl330_realize()
1638 s->cfg[CFG_CRD] |= ((s->wr_cap - 1) & 0x7) << 4 | in pl330_realize()
1639 ((s->wr_q_dep - 1) & 0xf) << 8 | in pl330_realize()
1640 ((s->rd_cap - 1) & 0x7) << 12 | in pl330_realize()
1641 ((s->rd_q_dep - 1) & 0xf) << 16 | in pl330_realize()
1642 ((s->data_buffer_dep - 1) & 0x1ff) << 20; in pl330_realize()
1644 pl330_queue_init(&s->read_queue, s->rd_q_dep, s); in pl330_realize()
1645 pl330_queue_init(&s->write_queue, s->wr_q_dep, s); in pl330_realize()
1646 pl330_fifo_init(&s->fifo, s->data_width / 4 * s->data_buffer_dep); in pl330_realize()
1656 DEFINE_PROP_UINT8("i-cache_len", PL330State, i_cache_len, 4),
1657 DEFINE_PROP_UINT8("num_i-cache_lines", PL330State, num_i_cache_lines, 8),
1658 /* CR2-4 */
1678 dc->realize = pl330_realize; in pl330_class_init()
1681 dc->vmsd = &vmstate_pl330; in pl330_class_init()