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"
|
2009-08-18 00:11:15 +03:00
|
|
|
#include "iris.hh"
|
2009-07-21 13:17:52 +03:00
|
|
|
|
2009-08-18 00:11:15 +03:00
|
|
|
static Keyboard kbd, tp
|
|
|
|
static Display lcd
|
|
|
|
static Cap lockleds, pwm
|
2009-07-21 13:17:52 +03:00
|
|
|
|
2009-08-18 00:11:15 +03:00
|
|
|
// Event types.
|
2009-07-21 13:17:52 +03:00
|
|
|
enum type:
|
|
|
|
KBD = 0x10000
|
|
|
|
TP
|
|
|
|
|
|
|
|
static void setup ():
|
|
|
|
unsigned state = 0
|
2009-08-18 00:11:15 +03:00
|
|
|
unsigned slot = 2
|
2009-07-21 13:17:52 +03:00
|
|
|
while true:
|
2009-08-18 00:11:15 +03:00
|
|
|
Cap::OMessage msg
|
|
|
|
Kernel::wait (&msg, slot)
|
|
|
|
switch msg.data[0].value ():
|
2009-08-05 11:16:24 +03:00
|
|
|
case INIT_SET_GPIO:
|
|
|
|
kdebug ("gpio\n")
|
2009-08-18 00:11:15 +03:00
|
|
|
kbd = Cap (slot, 0)
|
|
|
|
tp = Cap (slot, 1)
|
|
|
|
lockleds = Cap (slot, 2)
|
|
|
|
pwm = Cap (slot, 3)
|
|
|
|
++slot
|
2009-07-21 13:17:52 +03:00
|
|
|
++state
|
|
|
|
break
|
|
|
|
case INIT_SET_LCD:
|
2009-07-25 23:00:32 +03:00
|
|
|
kdebug ("lcd\n")
|
2009-08-18 00:11:15 +03:00
|
|
|
lcd = Cap (slot, 0)
|
|
|
|
++slot
|
2009-07-21 13:17:52 +03:00
|
|
|
++state
|
|
|
|
break
|
2009-08-05 11:16:24 +03:00
|
|
|
if state == 2:
|
2009-07-21 13:17:52 +03:00
|
|
|
break
|
2009-08-18 00:11:15 +03:00
|
|
|
kbd.set_cb (__my_receiver.create_capability (KBD).copy ())
|
|
|
|
tp.set_cb (__my_receiver.create_capability (TP).copy ())
|
|
|
|
pwm.invoke (1)
|
2009-07-21 13:17:52 +03:00
|
|
|
|
2009-08-05 11:16:24 +03:00
|
|
|
char const *decode_kbd = "0123456789abcdefghijklmnopqrstuvwxyz!@#$%^&*() T\n[],.-=/\\;|`'UDLREIKBPFZMS{}CA\":"
|
|
|
|
|
2009-08-18 00:11:15 +03:00
|
|
|
Num start ():
|
2009-07-25 23:00:32 +03:00
|
|
|
// Set up lcd first
|
2009-08-18 00:11:15 +03:00
|
|
|
Kernel::schedule ()
|
2009-07-25 23:00:32 +03:00
|
|
|
kdebug ("start init\n")
|
2009-07-24 15:25:53 +03:00
|
|
|
setup ()
|
2009-07-25 23:00:32 +03:00
|
|
|
kdebug ("run init\n")
|
2009-07-21 13:17:52 +03:00
|
|
|
while true:
|
2009-08-18 00:11:15 +03:00
|
|
|
Cap::OMessage msg
|
|
|
|
Kernel::wait (&msg)
|
|
|
|
switch msg.cap_protected.value ():
|
2009-07-21 13:17:52 +03:00
|
|
|
case KBD:
|
2009-08-18 00:11:15 +03:00
|
|
|
unsigned code = msg.data[0].l
|
|
|
|
if code & Keyboard::RELEASE:
|
2009-08-05 11:16:24 +03:00
|
|
|
break
|
|
|
|
kdebug_char (decode_kbd[code])
|
2009-07-21 13:17:52 +03:00
|
|
|
break
|
|
|
|
case TP:
|
2009-07-25 23:00:32 +03:00
|
|
|
unsigned leds = 0
|
2009-08-18 00:11:15 +03:00
|
|
|
if msg.data[0].l & 1:
|
2009-07-25 23:00:32 +03:00
|
|
|
leds |= 0x1
|
|
|
|
else:
|
|
|
|
leds |= 0x4
|
2009-08-18 00:11:15 +03:00
|
|
|
if !(msg.data[0].l & Keyboard::RELEASE):
|
2009-07-25 23:00:32 +03:00
|
|
|
leds |= 0x2
|
2009-08-18 00:11:15 +03:00
|
|
|
lockleds.invoke (leds)
|
2009-07-21 13:17:52 +03:00
|
|
|
break
|