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),
121 int max_spi_int_id =
itLines - 1;
122 int it_lines_number =
divCeil(max_spi_int_id + 1, 32) - 1;
124 (1 << 17) | (1 << 16) |
126 (it_lines_number << 0);
146 if (!
DS && !is_secure_access) {
157 for (
int i = 0, int_id = first_intid;
i < 8 * size && int_id <
itLines;
172 for (
int i = 0, int_id = first_intid;
i < 8 * size && int_id <
itLines;
193 for (
int i = 0, int_id = first_intid;
i < 8 * size && int_id <
itLines;
214 for (
int i = 0, int_id = first_intid;
i < 8 * size && int_id <
itLines;
238 for (
int i = 0, int_id = first_intid;
i < 8 * size && int_id <
itLines;
263 for (
int i = 0, int_id = first_intid;
i < 8 * size && int_id <
itLines;
288 for (
int i = 0, int_id = first_intid;
i < 8 * size && int_id <
itLines;
311 for (
int i = 0, int_id = first_intid;
i < size && int_id <
itLines;
316 if (!
DS && !is_secure_access) {
322 prio = (prio << 1) & 0xff;
326 val |= prio << (
i * 8);
333 warn(
"Gicv3Distributor::read(): "
334 "GICD_ITARGETSR is RAZ/WI, legacy not supported!\n");
346 for (
int i = 0, int_id = first_intid;
i < 8 * size && int_id <
itLines;
347 i =
i + 2, int_id++) {
366 if (!is_secure_access) {
378 for (
int i = 0, int_id = first_intid;
379 i < 8 * size && int_id <
itLines;
i++, int_id++) {
395 if (
DS || (!
DS && !is_secure_access)) {
401 for (
int i = 0, int_id = first_intid;
402 i < 8 * size && int_id <
itLines;
i =
i + 2, int_id++) {
409 warn(
"Gicv3Distributor::read(): "
410 "GICD_CPENDSGIR is RAZ/WI, legacy not supported!\n");
414 warn(
"Gicv3Distributor::read(): "
415 "GICD_SPENDSGIR is RAZ/WI, legacy not supported!\n");
446 if (is_secure_access) {
468 return (
DS << 6) | (
ARE << 4) |
507 panic(
"Gicv3Distributor::read(): invalid offset %#x\n",
addr);
514 bool is_secure_access)
517 if (!
DS && !is_secure_access) {
528 for (
int i = 0, int_id = first_intid;
i < 8 * size && int_id <
itLines;
531 DPRINTF(GIC,
"Gicv3Distributor::write(): int_id %d group %d\n",
544 for (
int i = 0, int_id = first_intid;
i < 8 * size && int_id <
itLines;
556 DPRINTF(GIC,
"Gicv3Distributor::write(): "
557 "int_id %d enabled\n", int_id);
573 for (
int i = 0, int_id = first_intid;
i < 8 * size && int_id <
itLines;
585 DPRINTF(GIC,
"Gicv3Distributor::write(): "
586 "int_id %d disabled\n", int_id);
602 for (
int i = 0, int_id = first_intid;
i < 8 * size && int_id <
itLines;
613 bool pending =
data & (1 <<
i) ? 1 : 0;
616 DPRINTF(GIC,
"Gicv3Distributor::write() (GICD_ISPENDR): "
617 "int_id %d (SPI) pending bit set\n", int_id);
633 for (
int i = 0, int_id = first_intid;
i < 8 * size && int_id <
itLines;
644 bool clear =
data & (1 <<
i) ? 1 : 0;
662 for (
int i = 0, int_id = first_intid;
i < 8 * size && int_id <
itLines;
670 bool active =
data & (1 <<
i) ? 1 : 0;
686 for (
int i = 0, int_id = first_intid;
i < 8 * size && int_id <
itLines;
694 bool clear =
data & (1 <<
i) ? 1 : 0;
698 DPRINTF(GIC,
"Gicv3Distributor::write(): "
699 "int_id %d active cleared\n", int_id);
715 for (
int i = 0, int_id = first_intid;
i < size && int_id <
itLines;
717 uint8_t prio =
bits(
data, (
i + 1) * 8 - 1, (
i * 8));
719 if (!
DS && !is_secure_access) {
724 prio = 0x80 | (prio >> 1);
729 DPRINTF(GIC,
"Gicv3Distributor::write(): int_id %d priority %d\n",
737 warn(
"Gicv3Distributor::write(): "
738 "GICD_ITARGETSR is RAZ/WI, legacy not supported!\n");
753 for (
int i = 0, int_id = first_intid;
i < 8 * size && int_id <
itLines;
754 i =
i + 2, int_id++) {
763 DPRINTF(GIC,
"Gicv3Distributor::write(): int_id %d config %d\n",
773 if (!is_secure_access) {
783 for (
int i = 0, int_id = first_intid;
784 i < 8 * size && int_id <
itLines;
i++, int_id++) {
801 if (
DS || (!
DS && !is_secure_access)) {
805 for (
int i = 0, int_id = first_intid;
806 i < 8 * size && int_id <
itLines;
i =
i + 2, int_id++) {
840 DPRINTF(GIC,
"Gicv3Distributor::write(): "
841 "int_id %d GICD_IROUTER %#llx\n",
858 if ((
data & (1 << 4)) == 0) {
859 warn(
"Gicv3Distributor::write(): "
860 "setting ARE to 0 is not supported!\n");
865 DPRINTF(GIC,
"Gicv3Distributor::write(): (DS 1)"
866 "EnableGrp1NS %d EnableGrp0 %d\n",
869 if (is_secure_access) {
882 if ((
data & (1 << 5)) == 0) {
883 warn(
"Gicv3Distributor::write(): "
884 "setting ARE_NS to 0 is not supported!\n");
887 if ((
data & (1 << 4)) == 0) {
888 warn(
"Gicv3Distributor::write(): "
889 "setting ARE_S to 0 is not supported!\n");
896 DPRINTF(GIC,
"Gicv3Distributor::write(): (DS 0 secure)"
898 "EnableGrp1S %d EnableGrp1NS %d EnableGrp0 %d\n",
911 if ((
data & (1 << 4)) == 0) {
912 warn(
"Gicv3Distributor::write(): "
913 "setting ARE_NS to 0 is not supported!\n");
917 DPRINTF(GIC,
"Gicv3Distributor::write(): (DS 0 non-secure)"
937 const uint32_t intid =
bits(
data, 9, 0);
956 const uint32_t intid =
bits(
data, 9, 0);
974 const uint32_t intid =
bits(
data, 9, 0);
990 const uint32_t intid =
bits(
data, 9, 0);
1001 panic(
"Gicv3Distributor::write(): invalid offset %#x\n",
addr);
1013 DPRINTF(GIC,
"Gicv3Distributor::sendInt(): "
1014 "int_id %d (SPI) pending bit set\n", int_id);
1047 if (affinity_routing.IRM) {
1053 if (redistributor_i->
1054 canBeSelectedFor1toNInterrupt(int_group)) {
1055 target_redistributor = redistributor_i;
1060 uint32_t affinity = (affinity_routing.Aff3 << 24) |
1061 (affinity_routing.Aff2 << 16) |
1062 (affinity_routing.Aff1 << 8) |
1063 (affinity_routing.Aff0 << 0);
1064 target_redistributor =
1068 if (!target_redistributor) {
1079 auto cpu_interface =
route(int_id);
1081 cpu_interface->resetHppi(int_id);
1100 if (!target_cpu_interface)
continue;
1104 int_id < target_cpu_interface->hppi.intid)) {
1106 target_cpu_interface->
hppi.
intid = int_id;
1108 target_cpu_interface->
hppi.
group = int_group;