1
0
mirror of git://projects.qi-hardware.com/iris.git synced 2024-08-22 14:28:03 +03:00
iris/boot-programs/init.ccp

90 lines
2.1 KiB
Plaintext
Raw Normal View History

2009-07-21 13:17:52 +03:00
#pypp 0
// Iris: micro-kernel for a capability-based operating system.
// boot-programs/init.ccp: System boot manager.
// Copyright 2009 Bas Wijnen <wijnen@debian.org>
//
// 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 <http://www.gnu.org/licenses/>.
#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:
2009-07-23 13:06:32 +03:00
kdebug ("gpio 0")
2009-07-21 13:17:52 +03:00
kbd = msg.cap[0]
tp = msg.cap[1]
poweroff = msg.cap[2]
powerbutton = msg.cap[3]
++state
break
case INIT_SET_GPIO_1:
2009-07-23 13:06:32 +03:00
kdebug ("gpio 1")
2009-07-21 13:17:52 +03:00
battery = msg.cap[0]
lockleds = msg.cap[1]
pwm = msg.cap[2]
++state
break
case INIT_SET_LCD:
2009-07-23 13:06:32 +03:00
kdebug ("lcd")
2009-07-21 13:17:52 +03:00
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 ():
2009-07-24 15:25:53 +03:00
schedule ()
2009-07-23 13:06:32 +03:00
kdebug ("start init")
2009-07-24 15:25:53 +03:00
setup ()
kdebug ("run init")
2009-07-21 13:17:52 +03:00
while true:
Message msg
wait (&msg)
switch msg.protected_data:
case KBD:
2009-07-24 15:25:53 +03:00
kdebug ("keyboard event")
2009-07-21 13:17:52 +03:00
break
case TP:
2009-07-24 15:25:53 +03:00
kdebug ("touchpad event")
2009-07-21 13:17:52 +03:00
break
case POWERBUTTON:
2009-07-24 15:25:53 +03:00
kdebug ("powerbutton event")
break
2009-07-21 13:17:52 +03:00
case BATTERY:
2009-07-24 15:25:53 +03:00
kdebug ("battery event")
2009-07-21 13:17:52 +03:00
break