#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, poweroff, powerbutton, battery, lockleds, pwm, lcd enum type: KBD = 0x10000 TP POWERBUTTON BATTERY static void send (Capability c, unsigned d): Capability n = receiver_create_capability (__my_receiver, d) invoke_10 (c, cap_copy (n)) drop (n) static void setup (): unsigned state = 0 while true: Message msg wait (&msg) switch msg.data[0]: case INIT_SET_GPIO_0: kdebug ("gpio 0") kbd = msg.cap[0] tp = msg.cap[1] poweroff = msg.cap[2] powerbutton = msg.cap[3] ++state break case INIT_SET_GPIO_1: kdebug ("gpio 1") battery = msg.cap[0] lockleds = msg.cap[1] pwm = msg.cap[2] ++state break case INIT_SET_LCD: kdebug ("lcd") lcd = msg.cap[0] ++state break if state == 3: break send (kbd, KBD) send (tp, TP) send (powerbutton, POWERBUTTON) send (battery, BATTERY) invoke_01 (pwm, 1) int main (): for unsigned i = 0; i < 10; ++i: schedule () setup () kdebug ("start init") while true: Message msg wait (&msg) switch msg.protected_data: case KBD: invoke_01 (lockleds, 0x4 | (msg.data[0] >> 16)) break case TP: invoke_01 (lockleds, 0x2 | (msg.data[0] >> 16)) break case POWERBUTTON: case BATTERY: break