#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.h" static Capability kbd, tp, lockleds, pwm, lcd enum type: KBD = 0x10000 TP static void send (Capability c, unsigned d): receiver_create_capability (6, __my_receiver, d) invoke_10 (c, cap_copy (6)) static void setup (): unsigned state = 0 Capability base = 7 while true: Message msg wait (&msg, base, base + 1, base + 2, base + 3) switch msg.data[0]: case INIT_SET_GPIO: kdebug ("gpio\n") kbd = base tp = base + 1 lockleds = base + 2 pwm = base + 3 base += 4 ++state break case INIT_SET_LCD: kdebug ("lcd\n") lcd = base ++base ++state break if state == 2: break send (kbd, KBD) send (tp, TP) invoke_01 (pwm, 1) char const *decode_kbd = "0123456789abcdefghijklmnopqrstuvwxyz!@#$%^&*() T\n[],.-=/\\;|`'UDLREIKBPFZMS{}CA\":" int main (): // Set up lcd first schedule () kdebug ("start init\n") setup () kdebug ("run init\n") while true: Message msg wait (&msg, CAPABILITY_NONE, CAPABILITY_NONE, CAPABILITY_NONE, CAPABILITY_NONE) switch msg.protected_data: case KBD: unsigned code = msg.data[0] if code & KEYBOARD_RELEASE: break kdebug_char (decode_kbd[code]) break case TP: unsigned leds = 0 if msg.data[0] & 1: leds |= 0x1 else: leds |= 0x4 if !(msg.data[0] & 0x10000): leds |= 0x2 invoke_01 (lockleds, leds) break