#pypp 0 // Iris: micro-kernel for a capability-based operating system. // boot-programs/init.ccp: System boot manager. // Copyright 2009 Bas Wijnen // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . #include "devices.hh" #include "iris.hh" static Keyboard kbd, tp static Display lcd static Cap lockleds, pwm // Event types. enum type: KBD = 0x10000 TP static void setup (): unsigned state = 0 unsigned slot = 2 while true: Cap::OMessage msg Kernel::wait (&msg, slot) switch msg.data[0].value (): case INIT_SET_GPIO: kdebug ("gpio\n") kbd = Cap (slot, 0) tp = Cap (slot, 1) lockleds = Cap (slot, 2) pwm = Cap (slot, 3) ++slot ++state break case INIT_SET_LCD: kdebug ("lcd\n") lcd = Cap (slot, 0) ++slot ++state break if state == 2: break kbd.set_cb (__my_receiver.create_capability (KBD).copy ()) tp.set_cb (__my_receiver.create_capability (TP).copy ()) pwm.invoke (1) char const *decode_kbd = "0123456789abcdefghijklmnopqrstuvwxyz!@#$%^&*() T\n[],.-=/\\;|`'UDLREIKBPFZMS{}CA\":" Num start (): // Set up lcd first Kernel::schedule () kdebug ("start init\n") setup () kdebug ("run init\n") while true: Cap::OMessage msg Kernel::wait (&msg) switch msg.cap_protected.value (): case KBD: unsigned code = msg.data[0].l if code & Keyboard::RELEASE: break kdebug_char (decode_kbd[code]) break case TP: unsigned leds = 0 if msg.data[0].l & 1: leds |= 0x1 else: leds |= 0x4 if !(msg.data[0].l & Keyboard::RELEASE): leds |= 0x2 lockleds.invoke (leds) break