| 411 | } |
| 412 | |
| 413 | static int |
| 414 | ti_pruss_channel_map(SYSCTL_HANDLER_ARGS) |
| 415 | { |
| 416 | struct ti_pruss_softc *sc; |
| 417 | int err; |
| 418 | char channel[sizeof(NOT_SET_STR)]; |
| 419 | const int8_t irq = arg2; |
| 420 | |
| 421 | sc = arg1; |
| 422 | |
| 423 | if (sc->sc_irq_devs[irq].channel == -1) |
| 424 | bcopy(NOT_SET_STR, channel, sizeof(channel)); |
| 425 | else |
| 426 | snprintf(channel, sizeof(channel), "%d", sc->sc_irq_devs[irq].channel); |
| 427 | |
| 428 | err = sysctl_handle_string(oidp, channel, sizeof(channel), req); |
| 429 | if (err != 0) |
| 430 | return (err); |
| 431 | |
| 432 | if (req->newptr) { // write event |
| 433 | if (strcmp(NOT_SET_STR, channel) == 0) { |
| 434 | ti_pruss_interrupts_enable(sc, irq, false); |
| 435 | ti_pruss_reg_write(sc, PRUSS_INTC_HIDISR, |
| 436 | sc->sc_irq_devs[irq].channel); |
| 437 | sc->sc_irq_devs[irq].channel = -1; |
| 438 | } else { |
| 439 | const int8_t channelnr = strtol(channel, NULL, 10); // TODO: check if strol is valid |
| 440 | if (channelnr > TI_PRUSS_IRQS || channelnr < 0) |
| 441 | { |
| 442 | device_printf(sc->sc_pdev->si_drv1, |
| 443 | "Channel number %d not valid (0 - %d)", |
| 444 | channelnr, TI_PRUSS_IRQS-1); |
| 445 | return (EINVAL); |
| 446 | } |
| 447 | |
| 448 | sc->sc_irq_devs[irq].channel = channelnr; |
| 449 | sc->sc_irq_devs[irq].last = -1; |
| 450 | |
| 451 | // channel[nr] <= irqnr |
| 452 | ti_pruss_map_write(sc, PRUSS_INTC_HMR_BASE, |
| 453 | irq, channelnr); |
| 454 | } |
| 455 | } |
| 456 | |
| 457 | return (err); |
| 458 | } |
| 459 | |
| 460 | static int |
| 461 | ti_pruss_interrupt_enable(SYSCTL_HANDLER_ARGS) |
nothing calls this directly
no test coverage detected