47 #include "debug/GIC.hh"
78 irqGroup(it_lines, 0),
79 irqEnabled(it_lines, false),
80 irqPending(it_lines, false),
81 irqPendingIspendr(it_lines, false),
82 irqActive(it_lines, false),
83 irqPriority(it_lines, 0xAA),
84 irqConfig(it_lines,
Gicv3::INT_LEVEL_SENSITIVE),
85 irqGrpmod(it_lines, 0),
86 irqNsacr(it_lines, 0),
87 irqAffinityRouting(it_lines, 0),
122 int max_spi_int_id =
itLines - 1;
123 int it_lines_number =
divCeil(max_spi_int_id + 1, 32) - 1;
125 (1 << 17) | (1 << 16) |
126 ((have_security ? 1 : 0) << 10) |
127 (it_lines_number << 0);
147 if (!
DS && !is_secure_access) {
158 for (
int i = 0, int_id = first_intid;
i < 8 * size && int_id <
itLines;
173 for (
int i = 0, int_id = first_intid;
i < 8 * size && int_id <
itLines;
194 for (
int i = 0, int_id = first_intid;
i < 8 * size && int_id <
itLines;
215 for (
int i = 0, int_id = first_intid;
i < 8 * size && int_id <
itLines;
239 for (
int i = 0, int_id = first_intid;
i < 8 * size && int_id <
itLines;
264 for (
int i = 0, int_id = first_intid;
i < 8 * size && int_id <
itLines;
289 for (
int i = 0, int_id = first_intid;
i < 8 * size && int_id <
itLines;
312 for (
int i = 0, int_id = first_intid;
i < size && int_id <
itLines;
317 if (!
DS && !is_secure_access) {
323 prio = (prio << 1) & 0xff;
327 val |= prio << (
i * 8);
334 warn(
"Gicv3Distributor::read(): "
335 "GICD_ITARGETSR is RAZ/WI, legacy not supported!\n");
347 for (
int i = 0, int_id = first_intid;
i < 8 * size && int_id <
itLines;
348 i =
i + 2, int_id++) {
367 if (!is_secure_access) {
379 for (
int i = 0, int_id = first_intid;
380 i < 8 * size && int_id <
itLines;
i++, int_id++) {
396 if (
DS || (!
DS && !is_secure_access)) {
402 for (
int i = 0, int_id = first_intid;
403 i < 8 * size && int_id <
itLines;
i =
i + 2, int_id++) {
410 warn(
"Gicv3Distributor::read(): "
411 "GICD_CPENDSGIR is RAZ/WI, legacy not supported!\n");
415 warn(
"Gicv3Distributor::read(): "
416 "GICD_SPENDSGIR is RAZ/WI, legacy not supported!\n");
447 if (is_secure_access) {
469 return (
DS << 6) | (
ARE << 4) |
508 panic(
"Gicv3Distributor::read(): invalid offset %#x\n",
addr);
515 bool is_secure_access)
518 if (!
DS && !is_secure_access) {
529 for (
int i = 0, int_id = first_intid;
i < 8 * size && int_id <
itLines;
532 DPRINTF(GIC,
"Gicv3Distributor::write(): int_id %d group %d\n",
545 for (
int i = 0, int_id = first_intid;
i < 8 * size && int_id <
itLines;
557 DPRINTF(GIC,
"Gicv3Distributor::write(): "
558 "int_id %d enabled\n", int_id);
574 for (
int i = 0, int_id = first_intid;
i < 8 * size && int_id <
itLines;
586 DPRINTF(GIC,
"Gicv3Distributor::write(): "
587 "int_id %d disabled\n", int_id);
603 for (
int i = 0, int_id = first_intid;
i < 8 * size && int_id <
itLines;
614 bool pending =
data & (1 <<
i) ? 1 : 0;
617 DPRINTF(GIC,
"Gicv3Distributor::write() (GICD_ISPENDR): "
618 "int_id %d (SPI) pending bit set\n", int_id);
634 for (
int i = 0, int_id = first_intid;
i < 8 * size && int_id <
itLines;
645 bool clear =
data & (1 <<
i) ? 1 : 0;
663 for (
int i = 0, int_id = first_intid;
i < 8 * size && int_id <
itLines;
671 bool active =
data & (1 <<
i) ? 1 : 0;
687 for (
int i = 0, int_id = first_intid;
i < 8 * size && int_id <
itLines;
695 bool clear =
data & (1 <<
i) ? 1 : 0;
699 DPRINTF(GIC,
"Gicv3Distributor::write(): "
700 "int_id %d active cleared\n", int_id);
716 for (
int i = 0, int_id = first_intid;
i < size && int_id <
itLines;
718 uint8_t prio =
bits(
data, (
i + 1) * 8 - 1, (
i * 8));
720 if (!
DS && !is_secure_access) {
725 prio = 0x80 | (prio >> 1);
730 DPRINTF(GIC,
"Gicv3Distributor::write(): int_id %d priority %d\n",
738 warn(
"Gicv3Distributor::write(): "
739 "GICD_ITARGETSR is RAZ/WI, legacy not supported!\n");
754 for (
int i = 0, int_id = first_intid;
i < 8 * size && int_id <
itLines;
755 i =
i + 2, int_id++) {
764 DPRINTF(GIC,
"Gicv3Distributor::write(): int_id %d config %d\n",
774 if (!is_secure_access) {
784 for (
int i = 0, int_id = first_intid;
785 i < 8 * size && int_id <
itLines;
i++, int_id++) {
802 if (
DS || (!
DS && !is_secure_access)) {
806 for (
int i = 0, int_id = first_intid;
807 i < 8 * size && int_id <
itLines;
i =
i + 2, int_id++) {
841 DPRINTF(GIC,
"Gicv3Distributor::write(): "
842 "int_id %d GICD_IROUTER %#llx\n",
859 if ((
data & (1 << 4)) == 0) {
860 warn(
"Gicv3Distributor::write(): "
861 "setting ARE to 0 is not supported!\n");
866 DPRINTF(GIC,
"Gicv3Distributor::write(): (DS 1)"
867 "EnableGrp1NS %d EnableGrp0 %d\n",
870 if (is_secure_access) {
883 if ((
data & (1 << 5)) == 0) {
884 warn(
"Gicv3Distributor::write(): "
885 "setting ARE_NS to 0 is not supported!\n");
888 if ((
data & (1 << 4)) == 0) {
889 warn(
"Gicv3Distributor::write(): "
890 "setting ARE_S to 0 is not supported!\n");
897 DPRINTF(GIC,
"Gicv3Distributor::write(): (DS 0 secure)"
899 "EnableGrp1S %d EnableGrp1NS %d EnableGrp0 %d\n",
912 if ((
data & (1 << 4)) == 0) {
913 warn(
"Gicv3Distributor::write(): "
914 "setting ARE_NS to 0 is not supported!\n");
918 DPRINTF(GIC,
"Gicv3Distributor::write(): (DS 0 non-secure)"
938 const uint32_t intid =
bits(
data, 9, 0);
957 const uint32_t intid =
bits(
data, 9, 0);
975 const uint32_t intid =
bits(
data, 9, 0);
991 const uint32_t intid =
bits(
data, 9, 0);
1002 panic(
"Gicv3Distributor::write(): invalid offset %#x\n",
addr);
1014 DPRINTF(GIC,
"Gicv3Distributor::sendInt(): "
1015 "int_id %d (SPI) pending bit set\n", int_id);
1048 if (affinity_routing.IRM) {
1054 if (redistributor_i->
1055 canBeSelectedFor1toNInterrupt(int_group)) {
1056 target_redistributor = redistributor_i;
1061 uint32_t affinity = (affinity_routing.Aff3 << 24) |
1062 (affinity_routing.Aff2 << 16) |
1063 (affinity_routing.Aff1 << 8) |
1064 (affinity_routing.Aff0 << 0);
1065 target_redistributor =
1069 if (!target_redistributor) {
1080 auto cpu_interface =
route(int_id);
1082 cpu_interface->resetHppi(int_id);
1101 if (!target_cpu_interface)
continue;
1105 int_id < target_cpu_interface->hppi.intid)) {
1107 target_cpu_interface->
hppi.
intid = int_id;
1109 target_cpu_interface->
hppi.
group = int_group;