1
0
mirror of git://projects.qi-hardware.com/iris.git synced 2024-12-28 12:39:52 +02:00

removed old device handling

This commit is contained in:
Bas Wijnen 2010-05-05 01:09:32 +02:00
parent 62ac5f1c0f
commit a4b5d94200
11 changed files with 147 additions and 413 deletions

View File

@ -58,14 +58,11 @@ void *operator new[] (unsigned size):
void *operator new (unsigned size):
return new char[size]
static bool have_data_mem, have_fs_mem
static Iris::Memory data_mem, fs_mem
// Get the initial block device and filesystem.
static Iris::Directory receive_devices ():
Iris::Caps data, fs
Iris::String data
Iris::Filesystem fs
bool have_data = false, have_fs = false
Iris::Device fs_dev, data_dev
for unsigned i = 0; i < 2; ++i:
Iris::wait ()
if Iris::recv.data[0].l != Iris::Parent::PROVIDE_DEVICE:
@ -74,37 +71,23 @@ static Iris::Directory receive_devices ():
case Iris::String::ID:
if have_data:
Iris::panic (0, "duplicate device.")
data_dev = Iris::get_arg ()
data = Iris::get_arg ()
Iris::recv.reply.invoke ()
have_data = true
break
case Iris::Filesystem::ID:
if have_fs:
Iris::panic (0, "duplicate filesystem.")
fs_dev = Iris::get_arg ()
fs = Iris::get_arg ()
Iris::recv.reply.invoke ()
have_fs = true
break
default:
Iris::panic (Iris::recv.data[1].l, "unexpected device")
// Initialize the root file system.
data = data_dev.create_user (Iris::my_memory)
data_dev.use (data)
fs = fs_dev.create_user (Iris::my_memory)
fs_dev.use (fs)
Iris::Filesystem fs_cap = fs.get (0)
Iris::Directory root = fs_cap.use_device_ro (data.copy ())
have_data_mem = data_dev.call (0).l
if have_data_mem:
data_mem = Iris::get_arg ()
have_fs_mem = fs_dev.call (0).l
if have_fs_mem:
fs_mem = Iris::get_arg ()
Iris::Directory root = fs.use_device_ro (data.copy ())
Iris::free_cap (data)
Iris::free_cap (fs)
Iris::free_cap (fs_cap)
Iris::free_cap (data_dev)
Iris::free_cap (fs_dev)
return root
static bool stringcmp (char const *s1, char const *s2, unsigned size):
@ -283,19 +266,15 @@ Iris::Num start ():
if Iris::recv.data[0].l != Iris::Parent::PROVIDE_DEVICE || Iris::recv.data[1].l != Iris::Elfrun::ID:
Iris::panic (0, "elfrun doesn't provide correct capability")
Iris::Cap reply = Iris::get_reply ()
Iris::Device elfrun_dev = Iris::get_arg ()
Iris::Elfrun elfrun = Iris::get_arg ()
Iris::my_caps.set (parent_cap.idx (), Iris::Cap (CAP_NONE))
Iris::free_cap (parent_cap)
reply.invoke ()
Iris::free_cap (reply)
parent_cap = Iris::my_receiver.create_capability (0)
Iris::Caps elfrun = elfrun_dev.create_user (Iris::my_memory)
elfrun_dev.use (elfrun)
Iris::Elfrun elfrun_cap = elfrun.get (0)
Iris::free_cap (elfrun)
Iris::String init_string = find (root, INIT_NAME)
Iris::Caps init_caps = elfrun_cap.run_string (top_memory.copy (), init_string.copy (), parent_cap.copy (), 8, 63)
Iris::Caps init_caps = elfrun.run_string (top_memory.copy (), init_string.copy (), parent_cap.copy (), 8, 63)
Iris::Thread init = init_caps.get (__thread_num)
init.make_priv ()
@ -319,7 +298,7 @@ Iris::Num start ():
case Iris::Elfrun::ID:
if have_elfrun:
Iris::panic (0, "Init requests elfrun twice")
Iris::recv.reply.invoke (0, 0, elfrun_cap.copy ())
Iris::recv.reply.invoke (0, 0, elfrun.copy ())
have_elfrun = true
break
default:
@ -332,10 +311,6 @@ Iris::Num start ():
// Special response: kill boot threads.
Iris::Cap reply = Iris::get_reply ()
root.unlock_ro ()
if have_data_mem:
top_memory.destroy (data_mem)
if have_fs_mem:
top_memory.destroy (fs_mem)
reply.invoke ()
Iris::free_cap (reply)
top_memory.destroy (Iris::my_memory)

View File

@ -571,47 +571,29 @@ Iris::Num start ():
__asm__ volatile ("li $a0, 1\nlw $a1, %0\nbreak" :: "m"(logcap.code): "a0", "a1", "memory")
udc.init ()
Iris::register_interrupt (IRQ_UDC)
Iris::Device fs_dev = Iris::my_receiver.create_capability (FS)
Iris::Device data_dev = Iris::my_receiver.create_capability (DATA)
Iris::my_parent.provide_device <Iris::Filesystem> (fs_dev.copy ())
Iris::my_parent.provide_device <Iris::String> (data_dev.copy ())
Iris::free_cap (fs_dev)
Iris::free_cap (data_dev)
unsigned data_current_user = 0, fs_current_user = 0
unsigned next_user
Iris::Filesystem fs = Iris::my_receiver.create_capability (FS)
Iris::String data = Iris::my_receiver.create_capability (DATA)
Iris::my_parent.provide_device <Iris::Filesystem> (fs.copy ())
Iris::my_parent.provide_device <Iris::String> (data.copy ())
Iris::free_cap (fs)
Iris::free_cap (data)
unsigned state = 0
while true:
Iris::wait ()
Iris::Cap reply = Iris::get_reply ()
Iris::Cap arg = Iris::get_arg ()
switch Iris::recv.protected_data.h:
case 0:
switch Iris::recv.protected_data.l:
case IRQ_UDC:
udc.interrupt (state)
Iris::register_interrupt (IRQ_UDC)
break
case LOG:
udc.log (Iris::recv.data[0].l)
break
case FS:
Iris::Device::host (FS, fs_current_user, reply, arg)
continue
case DATA:
Iris::Device::host (DATA, data_current_user, reply, arg)
continue
default:
udc.log ('~')
char digit[] = "0123456789abcdef"
for unsigned i = 0; i < 8; ++i:
udc.log (digit[(Iris::recv.protected_data.l >> (4 * (7 - i))) & 0xf])
udc.log ('\n')
break
switch Iris::recv.protected_data.l:
case IRQ_UDC:
udc.interrupt (state)
Iris::register_interrupt (IRQ_UDC)
break
case LOG:
udc.log (Iris::recv.data[0].l)
break
case DATA:
if data_current_user != Iris::recv.protected_data.l:
break
//kdebug ("data request\n")
switch Iris::recv.data[0].l:
case Iris::Device::RESET:
case Iris::String::GET_SIZE:
case Iris::String::GET_CHARS:
reply.invoke (0)
@ -626,12 +608,16 @@ Iris::Num start ():
continue
break
case FS:
if fs_current_user != Iris::recv.protected_data.l:
break
//kdebug ("fs request\n")
switch Iris::recv.data[0].l:
case Iris::Device::RESET:
reply.invoke (0)
Iris::free_cap (reply)
Iris::free_cap (arg)
continue
case Iris::Filesystem::USE_DEVICE:
case Iris::Filesystem::USE_DEVICE_RO:
Iris::Directory dir = Iris::my_receiver.create_capability (Iris::Num (0, DIRECTORY))
Iris::Directory dir = Iris::my_receiver.create_capability (DIRECTORY)
reply.invoke (0, 0, dir.copy ())
Iris::free_cap (dir)
Iris::free_cap (reply)
@ -644,9 +630,10 @@ Iris::Num start ():
continue
break
case DIRECTORY:
//kdebug ("dir request\n")
switch Iris::recv.data[0].l:
case Iris::Directory::GET_NAME:
Iris::Cap name = Iris::my_receiver.create_capability (Iris::Num (Iris::recv.data[1].l, NAME))
Iris::Cap name = Iris::my_receiver.create_capability (Iris::Num (NAME, Iris::recv.data[1].l))
reply.invoke (0, 0, name.copy ())
Iris::free_cap (name)
Iris::free_cap (reply)
@ -666,7 +653,7 @@ Iris::Num start ():
kdebug ("index out of supported range\n")
Iris::panic (0)
//kdebug ("sending file\n")
Iris::Cap file = Iris::my_receiver.create_capability (Iris::Num (Iris::recv.data[1].l, FILE))
Iris::Cap file = Iris::my_receiver.create_capability (Iris::Num (FILE, Iris::recv.data[1].l))
reply.invoke (0, 0, file.copy ())
Iris::free_cap (file)
Iris::free_cap (reply)
@ -680,11 +667,12 @@ Iris::Num start ():
continue
break
case FILE:
//kdebug ("file request\n")
switch Iris::recv.data[0].l:
case Iris::String::GET_SIZE:
case Iris::String::GET_CHARS:
case Iris::String::GET_PAGE:
udc.send (Iris::recv.data[0].l | ((Iris::recv.data[1].l >> PAGE_BITS) << 16), Iris::recv.protected_data.l, reply, arg)
udc.send (Iris::recv.data[0].l | ((Iris::recv.data[1].l >> PAGE_BITS) << 16), Iris::recv.protected_data.h, reply, arg)
continue
default:
reply.invoke (Iris::ERR_INVALID_OPERATION)
@ -693,6 +681,7 @@ Iris::Num start ():
continue
break
case NAME:
//kdebug ("name request\n")
switch Iris::recv.data[0].l:
case Iris::String::GET_SIZE:
reply.invoke (16)
@ -701,13 +690,23 @@ Iris::Num start ():
continue
case Iris::String::GET_CHARS:
state = Iris::recv.data[0].l
udc.send (Iris::Directory::GET_NAME, Iris::recv.protected_data.l, reply, arg)
udc.send (Iris::Directory::GET_NAME, Iris::recv.protected_data.h, reply, arg)
continue
default:
reply.invoke (Iris::ERR_INVALID_OPERATION)
Iris::free_cap (reply)
Iris::free_cap (arg)
continue
default:
kdebug ("other request:")
kdebug_num (Iris::recv.protected_data.l)
kdebug ("\n")
udc.log ('~')
char digit[] = "0123456789abcdef"
for unsigned i = 0; i < 8; ++i:
udc.log (digit[(Iris::recv.protected_data.l >> (4 * (7 - i))) & 0xf])
udc.log ('\n')
break
reply.invoke ()
Iris::free_cap (reply)
Iris::free_cap (arg)

View File

@ -85,106 +85,11 @@ namespace Iris:
struct Device : public Iris::Cap:
Device (Iris::Cap c = Iris::Cap ()) : Iris::Cap (c):
enum request:
CREATE_USER = WString::ID
DESTROY_USER
UNUSE
USE
RESET = WString::ID
ID
// Create a new user for this device. It will not be the active user.
// The provided storage must allow object creation; no other actions may be used by the terminal.
Iris::Cap create_user (Iris::Memory storage, unsigned arg1 = 0, Iris::Num arg2 = 0):
iocall (storage, Iris::Num (CAP_MASTER_DIRECT | CREATE_USER, arg1), arg2)
return Iris::get_arg ()
// Destroy a user. It is made inactive if it was active.
void destroy_user (Iris::Cap user):
ocall (user, CAP_MASTER_DIRECT | DESTROY_USER)
// Make user inactive.
void unuse (Iris::Cap user):
ocall (user, CAP_MASTER_DIRECT | UNUSE)
// Make user active. It makes the previous active user inactive.
void use (Iris::Cap user):
ocall (user, CAP_MASTER_DIRECT | USE)
// Convenience function for threads implementing a device.
static void host (unsigned id, unsigned &current_user, Iris::Cap &reply, Iris::Cap &arg, unsigned capssize = 3, unsigned (*create)(Iris::Memory mem, Iris::Caps caps) = NULL, void (*destroy)(unsigned id, Iris::Caps caps) = NULL, void (*use)(unsigned id, Iris::Caps caps) = NULL, void (*unuse)(unsigned id, Iris::Caps caps) = NULL):
static unsigned last_user
switch Iris::recv.data[0].l:
case Device::CREATE_USER:
Iris::Memory mem (arg)
Iris::Caps caps = mem.create_caps (capssize)
unsigned user
if create:
user = create (mem, caps)
else:
// Increment last_user; skip 0.
// FIXME: if this really wraps, it is possible that two users share their id.
if !++last_user:
++last_user
user = last_user
Iris::Cap c = Iris::my_receiver.create_capability (Iris::Num (user, id))
caps.set (0, c.copy ())
caps.set (1, mem.copy ())
reply.invoke (0, 0, caps.copy ())
Iris::free_cap (c)
Iris::free_cap (caps)
Iris::free_cap (reply)
Iris::free_cap (arg)
break
case Device::DESTROY_USER:
Iris::Caps caps (arg)
Iris::Cap c = caps.get (0)
Iris::Num user = Iris::my_receiver.get_protected (c)
Iris::free_cap (c)
if user.h != id:
Iris::panic (user.h, "invalid id for destroy")
// TODO: unuse.
if destroy:
destroy (user.l, caps)
reply.invoke ()
Iris::free_cap (reply)
Iris::free_cap (arg)
break
case Device::USE:
Iris::Caps caps (arg)
Iris::Cap c = caps.get (0)
Iris::Num user = Iris::my_receiver.get_protected (c)
Iris::free_cap (c)
if user.h != id:
Iris::panic (user.h, "invalid id for use")
// TODO: send unuse signal.
current_user = user.l
if use:
use (user.l, caps)
c = caps.get (2)
c.invoke (1)
Iris::free_cap (c)
reply.invoke ()
Iris::free_cap (reply)
Iris::free_cap (arg)
break
case Device::UNUSE:
Iris::Caps caps (arg)
Iris::Cap c = caps.get (0)
Iris::Num user = Iris::my_receiver.get_protected (c)
Iris::free_cap (c)
if user.h != id:
Iris::panic (user.h, "invalid id for unuse")
if unuse:
unuse (user.l, caps)
if user.l == current_user:
c = caps.get (2)
c.invoke (0)
Iris::free_cap (c)
current_user = 0
reply.invoke ()
Iris::free_cap (reply)
Iris::free_cap (arg)
break
default:
kdebug ("invalid request\n")
reply.invoke (~0)
Iris::free_cap (reply)
Iris::free_cap (arg)
break
// Reset the device. This is called by the terminal while switching owners.
void reset ():
call (CAP_MASTER_DIRECT | RESET)
struct Elfrun : public Iris::Cap:
Elfrun (Iris::Cap c = Iris::Cap ()) : Iris::Cap (c):
@ -255,8 +160,8 @@ namespace Iris:
call (CAP_MASTER_DIRECT | EXIT, code)
// Keyboard interface.
struct Keyboard : public Iris::Cap:
Keyboard (Iris::Cap c = Iris::Cap ()) : Iris::Cap (c):
struct Keyboard : public Device:
Keyboard (Iris::Cap c = Iris::Cap ()) : Iris::Device (c):
enum request:
SET_CB = Parent::ID
GET_NUM_KEYS
@ -276,8 +181,8 @@ namespace Iris:
call (CAP_MASTER_DIRECT | GET_KEYS, first)
// Buzzer interface.
struct Buzzer : public Iris::Cap:
Buzzer (Iris::Cap c = Iris::Cap ()) : Iris::Cap (c):
struct Buzzer : public Device:
Buzzer (Iris::Cap c = Iris::Cap ()) : Iris::Device (c):
enum request:
BEEP = Keyboard::ID
STOP
@ -290,8 +195,8 @@ namespace Iris:
call (CAP_MASTER_DIRECT | STOP)
// Display interface.
struct Display : public Iris::Cap:
Display (Iris::Cap c = Iris::Cap ()) : Iris::Cap (c):
struct Display : public Device:
Display (Iris::Cap c = Iris::Cap ()) : Iris::Device (c):
enum request:
SET_EOF_CB = Buzzer::ID
MAP_FB
@ -310,8 +215,8 @@ namespace Iris:
Iris::panic (0, "using undefined interface Display::get_info ()")
// Numerical setting, such as a display backlight.
struct Setting : public Iris::Cap:
Setting (Iris::Cap c = Iris::Cap ()) : Iris::Cap (c):
struct Setting : public Iris::Device:
Setting (Iris::Cap c = Iris::Cap ()) : Iris::Device (c):
enum request:
SET = Display::ID
GET_RANGE

View File

@ -2,7 +2,7 @@
load driver_lcd = "lcd.elf"
#load driver_buzzer = "buzzer.elf"
#load driver_gpio = "gpio.elf"
#load ball = "ball.elf"
load ball = "ball.elf"
# killbootthreads destroy bootinit, bootfs and bootstore.
killbootthreads
@ -26,9 +26,9 @@
sysreq sysreq
# give <name> / <type> [, <index>] = <cap> give this capability to this program when it requests it.
#give ball / Display = display
give ball / Display = display
# run <name> run a previously loaded program (normally).
#run ball
run ball
# include <name> include a loaded file as another config file.

View File

@ -296,7 +296,7 @@ static void memory_invoke (unsigned cmd, unsigned target, Iris::Num protected_da
reply_cap (CAPTYPE_THREAD | CAP_MASTER, (unsigned)ret, &ret->refs)
kdebug ("(created thread ")
kdebug_num ((unsigned)ret)
kdebug (")")
kdebug (")\n")
else:
dpanic (0x23311992, "out of memory creating thread")
reply_num (Iris::ERR_OUT_OF_MEMORY)

View File

@ -29,7 +29,7 @@ arch_iris_sources = mips/interrupts.cc mips/arch.cc
boot_sources = mips/init.cc mips/nanonote/board.cc
arch_headers = mips/arch.hh mips/nanonote/jz4740.hh mips/nanonote/board.hh devices.hh
boot_threads = bootinit udc
programs = init gpio lcd display-emu bsquare ball buzzer metronome elfrun
programs = init gpio lcd bsquare ball buzzer metronome elfrun
all: test

View File

@ -57,38 +57,24 @@ Iris::Num start ():
DevBuzzer buzzer
Iris::Device dev = Iris::my_receiver.create_capability (BUZZER)
Iris::Buzzer dev = Iris::my_receiver.create_capability (BUZZER)
Iris::my_parent.provide_device <Iris::Buzzer> (dev.copy ())
Iris::free_cap (dev)
Iris::my_parent.init_done ()
unsigned user (~0)
unsigned next_user (0)
while true:
Iris::wait ()
switch Iris::recv.protected_data.h:
case ~0:
// Alarm.
buzzer.stop ()
break
case 0:
switch Iris::recv.protected_data.l:
case BUZZER:
// Buzzer device control request.
Iris::Cap reply = Iris::get_reply ()
Iris::Cap arg = Iris::get_arg ()
Iris::Device::host (BUZZER, user, reply, arg)
break
default:
kdebug ("invalid buzzer request\n")
break
break
if Iris::recv.protected_data.h == ~0:
// Alarm.
buzzer.stop ()
break
switch Iris::recv.protected_data.l:
case BUZZER:
// Buzzer device user request.
if Iris::recv.protected_data.l != user:
kdebug ("invalid user requesting buzzer\n")
Iris::recv.reply.invoke ()
break
switch Iris::recv.data[0].l:
case Iris::Device::RESET:
buzzer.stop ()
Iris::recv.reply.invoke ()
break
case Iris::Buzzer::BEEP:
// Volume is not used by this buzzer.
Iris::Cap arg = Iris::get_arg ()
@ -107,5 +93,5 @@ Iris::Num start ():
break
default:
kdebug ("Buzzer: unknown num: ")
kdebug_num (Iris::recv.protected_data.h)
kdebug_num (Iris::recv.protected_data.l)
kdebug ("\n")

View File

@ -1,82 +0,0 @@
#pypp 0
// Iris: micro-kernel for a capability-based operating system.
// source/display-emu.ccp: Display interface emulation layer.
// 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.hh>
Iris::Num start ():
Iris::Device d = Iris::my_receiver.create_capability (0)
Iris::my_parent.provide_device <Iris::Display> (d.copy (), 0x10000)
Iris::free_cap (d)
Iris::my_parent.init_done ()
Iris::Display real = Iris::my_parent.get_device <Iris::Display> (0)
while true:
Iris::wait ()
Iris::Cap arg = Iris::get_arg ()
Iris::Cap reply = Iris::get_reply ()
switch Iris::recv.protected_data.h:
case 0:
switch Iris::recv.data[0].l:
case Iris::Device::CREATE_USER:
Iris::Memory mem (arg)
Iris::Caps ret = mem.create_caps (3)
Iris::Cap target = Iris::my_receiver.create_capability (Iris::Num (0, 1))
ret.set (0, target.copy ())
ret.set (1, mem)
Iris::free_cap (target)
for unsigned i = 0; i < 320 * 240 * 4; i += PAGE_SIZE:
Iris::Page p = Iris::my_memory.mapping ((void *)(0x15000 + i))
Iris::Page t = mem.create_page ()
t.set_flags (Iris::Page::PAYING, Iris::Page::PAYING)
p.share (t, Iris::Page::FORGET)
mem.map (t, 0x15000 + i)
Iris::my_memory.destroy (t)
Iris::free_cap (t)
Iris::free_cap (p)
reply.invoke (0, 0, ret.copy ())
Iris::free_cap (ret)
break
case Iris::Device::DESTROY_USER:
Iris::panic (0, "destroying emulation user")
case Iris::Device::USE:
case Iris::Device::UNUSE:
reply.invoke ()
break
default:
kdebug_num (Iris::recv.data[0].l)
kdebug ("\n")
Iris::panic (0, "invalid emulation command")
break
case 1:
switch Iris::recv.data[0].l:
case Iris::Display::SET_EOF_CB:
real.set_eof_cb (arg.copy ())
while Iris::recv.data[0].l != 0:
Iris::my_parent.wait <Iris::Display> (0)
real.set_eof_cb (arg.copy ())
reply.invoke ()
break
default:
kdebug_num (Iris::recv.data[0].l)
kdebug_char ('\n')
Iris::panic (Iris::recv.data[0].l, "invalid operation on display emulation")
break
default:
Iris::panic (0, "bug in display emulation")
Iris::free_cap (arg)
Iris::free_cap (reply)

View File

@ -234,53 +234,47 @@ static Iris::Caps run (Iris::Caps data, Iris::Memory parent_memory, Iris::Cap pa
Iris::Num start ():
kdebug ("elfrun started.\n")
init_alloc ()
Iris::Device dev = Iris::my_receiver.create_capability (0)
Iris::Elfrun dev = Iris::my_receiver.create_capability (0)
Iris::my_parent.provide_device <Iris::Elfrun> (dev.copy ())
Iris::free_cap (dev)
unsigned user = ~0
while true:
Iris::wait ()
Iris::Cap reply = Iris::get_reply ()
Iris::Cap arg = Iris::get_arg ()
Iris::print_caps ()
switch Iris::recv.protected_data.h:
case 0:
Iris::Device::host (1, user, reply, arg)
switch Iris::recv.data[0].l:
case Iris::Elfrun::RUN_STRING:
unsigned num_slots = Iris::recv.data[1].l
unsigned num_caps = Iris::recv.data[1].h
parent_memory = Iris::Caps (arg).get (Iris::Elfrun::PARENT_MEMORY)
parent = Iris::Caps (arg).get (Iris::Elfrun::PARENT)
Iris::String data = Iris::Caps (arg).get (Iris::Elfrun::DATA)
map_string (data)
Iris::Caps ret = run (data, parent_memory, parent, num_slots, num_caps)
reply.invoke (0, 0, ret.copy ())
free_cap (ret)
free_cap (parent_memory)
free_cap (parent)
free_cap (data)
break
case 1:
switch Iris::recv.data[0].l:
case Iris::Elfrun::RUN_STRING:
unsigned num_slots = Iris::recv.data[1].l
unsigned num_caps = Iris::recv.data[1].h
parent_memory = Iris::Caps (arg).get (Iris::Elfrun::PARENT_MEMORY)
parent = Iris::Caps (arg).get (Iris::Elfrun::PARENT)
Iris::String data = Iris::Caps (arg).get (Iris::Elfrun::DATA)
map_string (data)
Iris::Caps ret = run (data, parent_memory, parent, num_slots, num_caps)
reply.invoke (0, 0, ret.copy ())
free_cap (ret)
free_cap (parent_memory)
free_cap (parent)
free_cap (data)
break
case Iris::Elfrun::RUN_CAPS:
unsigned num_slots = Iris::recv.data[1].l
unsigned num_caps = Iris::recv.data[1].h
unsigned p = Iris::recv.data[0].h
parent_memory = Iris::Caps (arg).get (Iris::Elfrun::PARENT_MEMORY)
parent = Iris::Caps (arg).get (Iris::Elfrun::PARENT)
Iris::Caps data = Iris::Caps (arg).get (Iris::Elfrun::DATA)
map_caps (data, p)
Iris::Caps ret = run (data, parent_memory, parent, num_slots, num_caps)
reply.invoke (0, 0, ret.copy ())
free_cap (ret)
free_cap (parent_memory)
free_cap (parent)
free_cap (data)
break
default:
Iris::panic (0, "invalid operation for elfrun")
reply.invoke (~0)
break
Iris::free_cap (arg)
Iris::free_cap (reply)
case Iris::Elfrun::RUN_CAPS:
unsigned num_slots = Iris::recv.data[1].l
unsigned num_caps = Iris::recv.data[1].h
unsigned p = Iris::recv.data[0].h
parent_memory = Iris::Caps (arg).get (Iris::Elfrun::PARENT_MEMORY)
parent = Iris::Caps (arg).get (Iris::Elfrun::PARENT)
Iris::Caps data = Iris::Caps (arg).get (Iris::Elfrun::DATA)
map_caps (data, p)
Iris::Caps ret = run (data, parent_memory, parent, num_slots, num_caps)
reply.invoke (0, 0, ret.copy ())
free_cap (ret)
free_cap (parent_memory)
free_cap (parent)
free_cap (data)
break
default:
Iris::panic (0, "invalid operation for elfrun")
reply.invoke (~0)
break
Iris::free_cap (arg)
Iris::free_cap (reply)

View File

@ -369,7 +369,7 @@ Iris::Num start ():
Iris::free_cap (backlight)
// Register the display device.
Iris::Cap display = Iris::my_receiver.create_capability (LCD)
Iris::Display display = Iris::my_receiver.create_capability (LCD)
Iris::my_parent.provide_device <Iris::Display> (display.copy ())
Iris::free_cap (display)
Iris::my_parent.init_done ()
@ -377,46 +377,25 @@ Iris::Num start ():
Iris::Cap eof_cb
bool have_eof = false
is_on = true
unsigned lcd_user = 0
unsigned current_backlight = 0
while true:
Iris::wait ()
//log_msg ()
switch Iris::recv.protected_data.h:
case 0:
switch Iris::recv.protected_data.l:
case IRQ_LCD:
have_eof = false
eof_cb.invoke ()
Iris::free_cap (eof_cb)
break
#if defined (TRENDTAC)
case LOG:
log_char (Iris::recv.data[0].l)
break
#endif
case BACKLIGHT:
Iris::Cap reply = Iris::get_reply ()
Iris::Cap arg = Iris::get_arg ()
Iris::Device::host (BACKLIGHT, current_backlight, reply, arg)
break
case LCD:
Iris::Cap reply = Iris::get_reply ()
Iris::Cap arg = Iris::get_arg ()
Iris::Device::host (LCD, lcd_user, reply, arg, 3, create, destroy, use, unuse)
break
default:
Iris::panic (Iris::recv.protected_data.l, "invalid operation for master lcd")
break
switch Iris::recv.protected_data.l:
case IRQ_LCD:
have_eof = false
eof_cb.invoke ()
Iris::free_cap (eof_cb)
break
#if defined (TRENDTAC)
case LOG:
log_char (Iris::recv.data[0].l)
break
#endif
case BACKLIGHT:
if current_backlight != Iris::recv.protected_data.l:
log_char ('&')
log_num (current_backlight)
log_num (Iris::recv.protected_data)
log_char ('\n')
break
switch Iris::recv.data[0].l:
case Iris::Device::RESET:
Iris::recv.reply.invoke ()
break
case Iris::Setting::SET:
// TODO
unsigned state = Iris::recv.data[1].l
@ -444,11 +423,10 @@ Iris::Num start ():
break
break
case LCD:
if descriptor.frame != Iris::recv.protected_data.l:
//Iris::panic (0, "invalid user requesting lcd")
Iris::recv.reply.invoke (~0)
break
switch Iris::recv.data[0].l:
case Iris::Device::RESET:
Iris::recv.reply.invoke ()
break
case Iris::Display::SET_EOF_CB:
Iris::Cap reply = Iris::get_reply ()
Iris::Cap arg = Iris::get_arg ()
@ -469,5 +447,5 @@ Iris::Num start ():
Iris::panic (Iris::recv.data[0].l, "invalid operation for lcd")
break
default:
Iris::panic (0, "invalid master operation type for lcd")
Iris::panic (0, "invalid operation type for lcd")
break

View File

@ -211,50 +211,30 @@ Iris::Num start ():
Iris::my_parent.init_done ()
if kbd.scanning ():
Iris::my_receiver.set_alarm (SCAN_INTERVAL)
unsigned user (0), power_user (0)
unsigned next_user (0)
Iris::register_interrupt (IRQ_GPIO3)
while true:
Iris::wait ()
switch Iris::recv.protected_data.h:
case ~0:
// Alarm.
if Iris::recv.protected_data.h == ~0:
// Alarm.
kbd.scan ()
if kbd.scanning ():
Iris::my_receiver.set_alarm (SCAN_INTERVAL)
continue
switch Iris::recv.protected_data.l:
case IRQ_GPIO3:
// Interrupt.
pwr.scan ()
kbd.scan ()
if kbd.scanning ():
Iris::my_receiver.set_alarm (SCAN_INTERVAL)
break
case 0:
switch Iris::recv.protected_data.l:
case IRQ_GPIO3:
// Interrupt.
pwr.scan ()
kbd.scan ()
if kbd.scanning ():
Iris::my_receiver.set_alarm (SCAN_INTERVAL)
Iris::register_interrupt (IRQ_GPIO3)
break
case PWR:
// Power button request.
Iris::Cap reply = Iris::get_reply ()
Iris::Cap arg = Iris::get_arg ()
Iris::Device::host (PWR, power_user, reply, arg)
break
case KBD_DEV:
// Keyboard device control request.
Iris::Cap reply = Iris::get_reply ()
Iris::Cap arg = Iris::get_arg ()
Iris::Device::host (KBD_DEV, user, reply, arg)
break
default:
break
Iris::register_interrupt (IRQ_GPIO3)
break
case KBD_DEV:
// Keyboard device user request.
if Iris::recv.protected_data.l != user:
kdebug ("invalid user requesting keyboard\n")
Iris::recv.reply.invoke ()
break
switch Iris::recv.data[0].l:
case Iris::Device::RESET:
Iris::recv.reply.invoke ()
break
case Iris::Keyboard::SET_CB:
Iris::Cap reply = Iris::get_reply ()
kbd.active (Iris::get_arg ())
@ -272,11 +252,10 @@ Iris::Num start ():
break
break
case PWR:
if Iris::recv.protected_data.l != power_user:
kdebug ("invalid user requesting power\n")
Iris::recv.reply.invoke ()
break
switch Iris::recv.data[0].l:
case Iris::Device::RESET:
Iris::recv.reply.invoke ()
break
case Iris::Keyboard::SET_CB:
Iris::Cap reply = Iris::get_reply ()
pwr.set_cb (Iris::get_arg ())