| 216 | } |
| 217 | |
| 218 | static int |
| 219 | mips_pic_attach(device_t dev) |
| 220 | { |
| 221 | struct mips_pic_softc *sc; |
| 222 | intptr_t xref = pic_xref(dev); |
| 223 | |
| 224 | if (pic_sc) |
| 225 | return (ENXIO); |
| 226 | |
| 227 | sc = device_get_softc(dev); |
| 228 | |
| 229 | sc->pic_dev = dev; |
| 230 | pic_sc = sc; |
| 231 | |
| 232 | /* Set the number of interrupts */ |
| 233 | sc->nirqs = nitems(sc->pic_irqs); |
| 234 | |
| 235 | /* Register the interrupts */ |
| 236 | if (mips_pic_register_isrcs(sc) != 0) { |
| 237 | device_printf(dev, "could not register PIC ISRCs\n"); |
| 238 | goto cleanup; |
| 239 | } |
| 240 | |
| 241 | /* |
| 242 | * Now, when everything is initialized, it's right time to |
| 243 | * register interrupt controller to interrupt framefork. |
| 244 | */ |
| 245 | if (intr_pic_register(dev, xref) == NULL) { |
| 246 | device_printf(dev, "could not register PIC\n"); |
| 247 | goto cleanup; |
| 248 | } |
| 249 | |
| 250 | /* Claim our root controller role */ |
| 251 | if (intr_pic_claim_root(dev, xref, mips_pic_intr, sc, 0) != 0) { |
| 252 | device_printf(dev, "could not set PIC as a root\n"); |
| 253 | intr_pic_deregister(dev, xref); |
| 254 | goto cleanup; |
| 255 | } |
| 256 | |
| 257 | return (0); |
| 258 | |
| 259 | cleanup: |
| 260 | return(ENXIO); |
| 261 | } |
| 262 | |
| 263 | int |
| 264 | mips_pic_intr(void *arg) |
nothing calls this directly
no test coverage detected