#pypp 0 // vim: set filetype=cpp : // #include #include enum captypes: CONTROL = 1 KBD INTERRUPT Iris::Num start (): unsigned *screen = (unsigned *)0x40000000 Iris::RTC rtc = Iris::my_parent.get_capability () Iris::Display display = Iris::my_parent.get_capability () display.map_fb ((unsigned)screen) Iris::Font font = Iris::my_parent.get_capability () font.set_display (display) Iris::Keyboard keyboard = Iris::my_parent.get_capability () Iris::Cap cap = Iris::my_receiver.create_capability (KBD) keyboard.set_cb (cap.copy ()) Iris::free_cap (cap) Iris::Buzzer buzzer = Iris::my_parent.get_capability () Iris::Event self = Iris::my_receiver.create_capability (CONTROL) Iris::my_parent.provide_capability (self) cap = Iris::my_receiver.create_capability (INTERRUPT) Iris::my_parent.init_done () while true: Iris::wait () switch Iris::recv.protected_data.l: case INTERRUPT: // RTC alarm interrupt. if Iris::recv.data[0].l == ~0: // Not a real interrupt, just an abort notification. continue font.printf ("alarm: RTC alarm interrupt\n") break case CONTROL: // Store callback font.printf ("alarm: control event\n") break case KBD: if Iris::recv.data[0].l & Iris::Keyboard::RELEASE: // Key release. Iris::poweroff () else: // Key press. unsigned time = rtc.get_time () rtc.set_alarm (time + 5, cap) unsigned alarm = rtc.get_alarm () unsigned enabled = Iris::recv.data[1].l font.printf ("Debug: %d %d %d\n", time, alarm, enabled) break default: Iris::panic (Iris::recv.protected_data.l, "invalid request for alarm")