| 163 | |
| 164 | static int dmar_enable = 0; |
| 165 | static void |
| 166 | dmar_identify(driver_t *driver, device_t parent) |
| 167 | { |
| 168 | ACPI_TABLE_DMAR *dmartbl; |
| 169 | ACPI_DMAR_HARDWARE_UNIT *dmarh; |
| 170 | ACPI_STATUS status; |
| 171 | int i, error; |
| 172 | |
| 173 | if (acpi_disabled("dmar")) |
| 174 | return; |
| 175 | TUNABLE_INT_FETCH("hw.dmar.enable", &dmar_enable); |
| 176 | if (!dmar_enable) |
| 177 | return; |
| 178 | status = AcpiGetTable(ACPI_SIG_DMAR, 1, (ACPI_TABLE_HEADER **)&dmartbl); |
| 179 | if (ACPI_FAILURE(status)) |
| 180 | return; |
| 181 | haw = dmartbl->Width + 1; |
| 182 | if ((1ULL << (haw + 1)) > BUS_SPACE_MAXADDR) |
| 183 | dmar_high = BUS_SPACE_MAXADDR; |
| 184 | else |
| 185 | dmar_high = 1ULL << (haw + 1); |
| 186 | if (bootverbose) { |
| 187 | printf("DMAR HAW=%d flags=<%b>\n", dmartbl->Width, |
| 188 | (unsigned)dmartbl->Flags, |
| 189 | "\020\001INTR_REMAP\002X2APIC_OPT_OUT"); |
| 190 | } |
| 191 | AcpiPutTable((ACPI_TABLE_HEADER *)dmartbl); |
| 192 | |
| 193 | dmar_iterate_tbl(dmar_count_iter, NULL); |
| 194 | if (dmar_devcnt == 0) |
| 195 | return; |
| 196 | dmar_devs = malloc(sizeof(device_t) * dmar_devcnt, M_DEVBUF, |
| 197 | M_WAITOK | M_ZERO); |
| 198 | for (i = 0; i < dmar_devcnt; i++) { |
| 199 | dmarh = dmar_find_by_index(i); |
| 200 | if (dmarh == NULL) { |
| 201 | printf("dmar_identify: cannot find HWUNIT %d\n", i); |
| 202 | continue; |
| 203 | } |
| 204 | dmar_devs[i] = BUS_ADD_CHILD(parent, 1, "dmar", i); |
| 205 | if (dmar_devs[i] == NULL) { |
| 206 | printf("dmar_identify: cannot create instance %d\n", i); |
| 207 | continue; |
| 208 | } |
| 209 | error = bus_set_resource(dmar_devs[i], SYS_RES_MEMORY, |
| 210 | DMAR_REG_RID, dmarh->Address, PAGE_SIZE); |
| 211 | if (error != 0) { |
| 212 | printf( |
| 213 | "dmar%d: unable to alloc register window at 0x%08jx: error %d\n", |
| 214 | i, (uintmax_t)dmarh->Address, error); |
| 215 | device_delete_child(parent, dmar_devs[i]); |
| 216 | dmar_devs[i] = NULL; |
| 217 | } |
| 218 | } |
| 219 | } |
| 220 | |
| 221 | static int |
| 222 | dmar_probe(device_t dev) |
nothing calls this directly
no test coverage detected