static void watchdog_event(int unused_sig) { char *myname = "watchdog_event"; WATCHDOG *wp; /* * This routine runs as a signal handler. We should not do anything that * could involve memory allocation/deallocation, but exiting without * proper explanation would be unacceptable. */ if ((wp = watchdog_curr) == 0) msg_panic("%s: no instance", myname); if (msg_verbose) msg_info("%s: %p %d", myname, (void *) wp, wp->trip_run); if (++(wp->trip_run) < WATCHDOG_STEPS) { alarm(wp->timeout); } else { if (wp->action) wp->action(wp, wp->context); else msg_fatal("watchdog timeout"); } }
static void watchdog_event(int unused_sig) { const char *myname = "watchdog_event"; WATCHDOG *wp; /* * This routine runs as a signal handler. We should not do anything that * could involve memory allocation/deallocation, but exiting without * proper explanation would be unacceptable. For this reason, msg(3) was * made safe for usage by signal handlers that terminate the process. */ if ((wp = watchdog_curr) == 0) msg_panic("%s: no instance", myname); if (msg_verbose > 1) msg_info("%s: %p %d", myname, (void *) wp, wp->trip_run); if (++(wp->trip_run) < WATCHDOG_STEPS) { #ifdef USE_WATCHDOG_PIPE int saved_errno = errno; /* Wake up the events(3) engine. */ if (write(watchdog_pipe[1], "", 1) != 1) msg_warn("%s: write watchdog_pipe: %m", myname); errno = saved_errno; #endif alarm(wp->timeout); } else { if (wp->action) wp->action(wp, wp->context); else { killme_after(5); #ifdef TEST pause(); #endif msg_fatal("watchdog timeout"); } } }
int main(void) { dbgled(0); iprintf("start\n"); uc.attach(&u); // msc.attach(&u); ecm.setMAC(mac); ecm.attach(&u); iprintf("u.dump\n"); u.dumpDescriptors(); iprintf("u.init\n"); u.init(); sysclock.setTimeout(5 S); // because leds[0] is connected to USB_UP_LED signal and usb hardware takes it over leds[0].setup(); // dbgled(15); // int l = 0; while (1) { // u.USBHW::HwISR(); if (sysclock.poll()) { // iprintf("-------------------\n"); // iprintf("USBClkCtrl: 0x%8lX\n", LPC_USB->USBClkCtrl); // iprintf("USBClkSt: 0x%8lX\n", LPC_USB->USBClkSt); // iprintf("USBIntSt: 0x%8lX\n", LPC_SC->USBIntSt); // iprintf("USBDevIntSt: 0x%8lX\n", LPC_USB->USBDevIntSt); // iprintf("USBDevIntEn: 0x%8lX\n", LPC_USB->USBDevIntEn); // iprintf("USBDevIntPri: 0x%8lX\n", LPC_USB->USBDevIntPri); iprintf("Fr: %d\n", u.USBCTRL::lastFrame()); } w.feed(); // l++; // if ((l & ((1UL << 19) - 1UL)) == 0) // dbgled(l >> 19); } }