1
0
mirror of git://projects.qi-hardware.com/iris.git synced 2024-12-29 20:31:09 +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): void *operator new (unsigned size):
return new char[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. // Get the initial block device and filesystem.
static Iris::Directory receive_devices (): static Iris::Directory receive_devices ():
Iris::Caps data, fs Iris::String data
Iris::Filesystem fs
bool have_data = false, have_fs = false bool have_data = false, have_fs = false
Iris::Device fs_dev, data_dev
for unsigned i = 0; i < 2; ++i: for unsigned i = 0; i < 2; ++i:
Iris::wait () Iris::wait ()
if Iris::recv.data[0].l != Iris::Parent::PROVIDE_DEVICE: if Iris::recv.data[0].l != Iris::Parent::PROVIDE_DEVICE:
@ -74,37 +71,23 @@ static Iris::Directory receive_devices ():
case Iris::String::ID: case Iris::String::ID:
if have_data: if have_data:
Iris::panic (0, "duplicate device.") Iris::panic (0, "duplicate device.")
data_dev = Iris::get_arg () data = Iris::get_arg ()
Iris::recv.reply.invoke () Iris::recv.reply.invoke ()
have_data = true have_data = true
break break
case Iris::Filesystem::ID: case Iris::Filesystem::ID:
if have_fs: if have_fs:
Iris::panic (0, "duplicate filesystem.") Iris::panic (0, "duplicate filesystem.")
fs_dev = Iris::get_arg () fs = Iris::get_arg ()
Iris::recv.reply.invoke () Iris::recv.reply.invoke ()
have_fs = true have_fs = true
break break
default: default:
Iris::panic (Iris::recv.data[1].l, "unexpected device") Iris::panic (Iris::recv.data[1].l, "unexpected device")
// Initialize the root file system. // Initialize the root file system.
data = data_dev.create_user (Iris::my_memory) Iris::Directory root = fs.use_device_ro (data.copy ())
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::free_cap (data) Iris::free_cap (data)
Iris::free_cap (fs) Iris::free_cap (fs)
Iris::free_cap (fs_cap)
Iris::free_cap (data_dev)
Iris::free_cap (fs_dev)
return root return root
static bool stringcmp (char const *s1, char const *s2, unsigned size): 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: 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::panic (0, "elfrun doesn't provide correct capability")
Iris::Cap reply = Iris::get_reply () 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::my_caps.set (parent_cap.idx (), Iris::Cap (CAP_NONE))
Iris::free_cap (parent_cap) Iris::free_cap (parent_cap)
reply.invoke () reply.invoke ()
Iris::free_cap (reply) Iris::free_cap (reply)
parent_cap = Iris::my_receiver.create_capability (0) 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::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) Iris::Thread init = init_caps.get (__thread_num)
init.make_priv () init.make_priv ()
@ -319,7 +298,7 @@ Iris::Num start ():
case Iris::Elfrun::ID: case Iris::Elfrun::ID:
if have_elfrun: if have_elfrun:
Iris::panic (0, "Init requests elfrun twice") 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 have_elfrun = true
break break
default: default:
@ -332,10 +311,6 @@ Iris::Num start ():
// Special response: kill boot threads. // Special response: kill boot threads.
Iris::Cap reply = Iris::get_reply () Iris::Cap reply = Iris::get_reply ()
root.unlock_ro () root.unlock_ro ()
if have_data_mem:
top_memory.destroy (data_mem)
if have_fs_mem:
top_memory.destroy (fs_mem)
reply.invoke () reply.invoke ()
Iris::free_cap (reply) Iris::free_cap (reply)
top_memory.destroy (Iris::my_memory) top_memory.destroy (Iris::my_memory)

View File

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

View File

@ -85,106 +85,11 @@ namespace Iris:
struct Device : public Iris::Cap: struct Device : public Iris::Cap:
Device (Iris::Cap c = Iris::Cap ()) : Iris::Cap (c): Device (Iris::Cap c = Iris::Cap ()) : Iris::Cap (c):
enum request: enum request:
CREATE_USER = WString::ID RESET = WString::ID
DESTROY_USER
UNUSE
USE
ID ID
// Create a new user for this device. It will not be the active user. // Reset the device. This is called by the terminal while switching owners.
// The provided storage must allow object creation; no other actions may be used by the terminal. void reset ():
Iris::Cap create_user (Iris::Memory storage, unsigned arg1 = 0, Iris::Num arg2 = 0): call (CAP_MASTER_DIRECT | RESET)
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
struct Elfrun : public Iris::Cap: struct Elfrun : public Iris::Cap:
Elfrun (Iris::Cap c = Iris::Cap ()) : Iris::Cap (c): Elfrun (Iris::Cap c = Iris::Cap ()) : Iris::Cap (c):
@ -255,8 +160,8 @@ namespace Iris:
call (CAP_MASTER_DIRECT | EXIT, code) call (CAP_MASTER_DIRECT | EXIT, code)
// Keyboard interface. // Keyboard interface.
struct Keyboard : public Iris::Cap: struct Keyboard : public Device:
Keyboard (Iris::Cap c = Iris::Cap ()) : Iris::Cap (c): Keyboard (Iris::Cap c = Iris::Cap ()) : Iris::Device (c):
enum request: enum request:
SET_CB = Parent::ID SET_CB = Parent::ID
GET_NUM_KEYS GET_NUM_KEYS
@ -276,8 +181,8 @@ namespace Iris:
call (CAP_MASTER_DIRECT | GET_KEYS, first) call (CAP_MASTER_DIRECT | GET_KEYS, first)
// Buzzer interface. // Buzzer interface.
struct Buzzer : public Iris::Cap: struct Buzzer : public Device:
Buzzer (Iris::Cap c = Iris::Cap ()) : Iris::Cap (c): Buzzer (Iris::Cap c = Iris::Cap ()) : Iris::Device (c):
enum request: enum request:
BEEP = Keyboard::ID BEEP = Keyboard::ID
STOP STOP
@ -290,8 +195,8 @@ namespace Iris:
call (CAP_MASTER_DIRECT | STOP) call (CAP_MASTER_DIRECT | STOP)
// Display interface. // Display interface.
struct Display : public Iris::Cap: struct Display : public Device:
Display (Iris::Cap c = Iris::Cap ()) : Iris::Cap (c): Display (Iris::Cap c = Iris::Cap ()) : Iris::Device (c):
enum request: enum request:
SET_EOF_CB = Buzzer::ID SET_EOF_CB = Buzzer::ID
MAP_FB MAP_FB
@ -310,8 +215,8 @@ namespace Iris:
Iris::panic (0, "using undefined interface Display::get_info ()") Iris::panic (0, "using undefined interface Display::get_info ()")
// Numerical setting, such as a display backlight. // Numerical setting, such as a display backlight.
struct Setting : public Iris::Cap: struct Setting : public Iris::Device:
Setting (Iris::Cap c = Iris::Cap ()) : Iris::Cap (c): Setting (Iris::Cap c = Iris::Cap ()) : Iris::Device (c):
enum request: enum request:
SET = Display::ID SET = Display::ID
GET_RANGE GET_RANGE

View File

@ -2,7 +2,7 @@
load driver_lcd = "lcd.elf" load driver_lcd = "lcd.elf"
#load driver_buzzer = "buzzer.elf" #load driver_buzzer = "buzzer.elf"
#load driver_gpio = "gpio.elf" #load driver_gpio = "gpio.elf"
#load ball = "ball.elf" load ball = "ball.elf"
# killbootthreads destroy bootinit, bootfs and bootstore. # killbootthreads destroy bootinit, bootfs and bootstore.
killbootthreads killbootthreads
@ -26,9 +26,9 @@
sysreq sysreq sysreq sysreq
# give <name> / <type> [, <index>] = <cap> give this capability to this program when it requests it. # 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 <name> run a previously loaded program (normally).
#run ball run ball
# include <name> include a loaded file as another config file. # 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) reply_cap (CAPTYPE_THREAD | CAP_MASTER, (unsigned)ret, &ret->refs)
kdebug ("(created thread ") kdebug ("(created thread ")
kdebug_num ((unsigned)ret) kdebug_num ((unsigned)ret)
kdebug (")") kdebug (")\n")
else: else:
dpanic (0x23311992, "out of memory creating thread") dpanic (0x23311992, "out of memory creating thread")
reply_num (Iris::ERR_OUT_OF_MEMORY) 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 boot_sources = mips/init.cc mips/nanonote/board.cc
arch_headers = mips/arch.hh mips/nanonote/jz4740.hh mips/nanonote/board.hh devices.hh arch_headers = mips/arch.hh mips/nanonote/jz4740.hh mips/nanonote/board.hh devices.hh
boot_threads = bootinit udc 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 all: test

View File

@ -57,38 +57,24 @@ Iris::Num start ():
DevBuzzer buzzer 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::my_parent.provide_device <Iris::Buzzer> (dev.copy ())
Iris::free_cap (dev) Iris::free_cap (dev)
Iris::my_parent.init_done () Iris::my_parent.init_done ()
unsigned user (~0)
unsigned next_user (0)
while true: while true:
Iris::wait () Iris::wait ()
switch Iris::recv.protected_data.h: if Iris::recv.protected_data.h == ~0:
case ~0:
// Alarm. // Alarm.
buzzer.stop () buzzer.stop ()
break break
case 0:
switch Iris::recv.protected_data.l: 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
case BUZZER: case BUZZER:
// Buzzer device user request. // Buzzer device user request.
if Iris::recv.protected_data.l != user: switch Iris::recv.data[0].l:
kdebug ("invalid user requesting buzzer\n") case Iris::Device::RESET:
buzzer.stop ()
Iris::recv.reply.invoke () Iris::recv.reply.invoke ()
break break
switch Iris::recv.data[0].l:
case Iris::Buzzer::BEEP: case Iris::Buzzer::BEEP:
// Volume is not used by this buzzer. // Volume is not used by this buzzer.
Iris::Cap arg = Iris::get_arg () Iris::Cap arg = Iris::get_arg ()
@ -107,5 +93,5 @@ Iris::Num start ():
break break
default: default:
kdebug ("Buzzer: unknown num: ") kdebug ("Buzzer: unknown num: ")
kdebug_num (Iris::recv.protected_data.h) kdebug_num (Iris::recv.protected_data.l)
kdebug ("\n") 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,20 +234,14 @@ static Iris::Caps run (Iris::Caps data, Iris::Memory parent_memory, Iris::Cap pa
Iris::Num start (): Iris::Num start ():
kdebug ("elfrun started.\n") kdebug ("elfrun started.\n")
init_alloc () 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::my_parent.provide_device <Iris::Elfrun> (dev.copy ())
Iris::free_cap (dev)
unsigned user = ~0
while true: while true:
Iris::wait () Iris::wait ()
Iris::Cap reply = Iris::get_reply () Iris::Cap reply = Iris::get_reply ()
Iris::Cap arg = Iris::get_arg () Iris::Cap arg = Iris::get_arg ()
Iris::print_caps ()
switch Iris::recv.protected_data.h:
case 0:
Iris::Device::host (1, user, reply, arg)
break
case 1:
switch Iris::recv.data[0].l: switch Iris::recv.data[0].l:
case Iris::Elfrun::RUN_STRING: case Iris::Elfrun::RUN_STRING:
unsigned num_slots = Iris::recv.data[1].l unsigned num_slots = Iris::recv.data[1].l

View File

@ -369,7 +369,7 @@ Iris::Num start ():
Iris::free_cap (backlight) Iris::free_cap (backlight)
// Register the display device. // 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::my_parent.provide_device <Iris::Display> (display.copy ())
Iris::free_cap (display) Iris::free_cap (display)
Iris::my_parent.init_done () Iris::my_parent.init_done ()
@ -377,13 +377,9 @@ Iris::Num start ():
Iris::Cap eof_cb Iris::Cap eof_cb
bool have_eof = false bool have_eof = false
is_on = true is_on = true
unsigned lcd_user = 0
unsigned current_backlight = 0
while true: while true:
Iris::wait () Iris::wait ()
//log_msg () //log_msg ()
switch Iris::recv.protected_data.h:
case 0:
switch Iris::recv.protected_data.l: switch Iris::recv.protected_data.l:
case IRQ_LCD: case IRQ_LCD:
have_eof = false have_eof = false
@ -396,27 +392,10 @@ Iris::Num start ():
break break
#endif #endif
case BACKLIGHT: 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
break
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: switch Iris::recv.data[0].l:
case Iris::Device::RESET:
Iris::recv.reply.invoke ()
break
case Iris::Setting::SET: case Iris::Setting::SET:
// TODO // TODO
unsigned state = Iris::recv.data[1].l unsigned state = Iris::recv.data[1].l
@ -444,11 +423,10 @@ Iris::Num start ():
break break
break break
case LCD: 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: switch Iris::recv.data[0].l:
case Iris::Device::RESET:
Iris::recv.reply.invoke ()
break
case Iris::Display::SET_EOF_CB: case Iris::Display::SET_EOF_CB:
Iris::Cap reply = Iris::get_reply () Iris::Cap reply = Iris::get_reply ()
Iris::Cap arg = Iris::get_arg () Iris::Cap arg = Iris::get_arg ()
@ -469,5 +447,5 @@ Iris::Num start ():
Iris::panic (Iris::recv.data[0].l, "invalid operation for lcd") Iris::panic (Iris::recv.data[0].l, "invalid operation for lcd")
break break
default: default:
Iris::panic (0, "invalid master operation type for lcd") Iris::panic (0, "invalid operation type for lcd")
break break

View File

@ -211,19 +211,15 @@ Iris::Num start ():
Iris::my_parent.init_done () Iris::my_parent.init_done ()
if kbd.scanning (): if kbd.scanning ():
Iris::my_receiver.set_alarm (SCAN_INTERVAL) Iris::my_receiver.set_alarm (SCAN_INTERVAL)
unsigned user (0), power_user (0)
unsigned next_user (0)
Iris::register_interrupt (IRQ_GPIO3) Iris::register_interrupt (IRQ_GPIO3)
while true: while true:
Iris::wait () Iris::wait ()
switch Iris::recv.protected_data.h: if Iris::recv.protected_data.h == ~0:
case ~0:
// Alarm. // Alarm.
kbd.scan () kbd.scan ()
if kbd.scanning (): if kbd.scanning ():
Iris::my_receiver.set_alarm (SCAN_INTERVAL) Iris::my_receiver.set_alarm (SCAN_INTERVAL)
break continue
case 0:
switch Iris::recv.protected_data.l: switch Iris::recv.protected_data.l:
case IRQ_GPIO3: case IRQ_GPIO3:
// Interrupt. // Interrupt.
@ -233,28 +229,12 @@ Iris::Num start ():
Iris::my_receiver.set_alarm (SCAN_INTERVAL) Iris::my_receiver.set_alarm (SCAN_INTERVAL)
Iris::register_interrupt (IRQ_GPIO3) Iris::register_interrupt (IRQ_GPIO3)
break 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
break
case KBD_DEV: case KBD_DEV:
// Keyboard device user request. // Keyboard device user request.
if Iris::recv.protected_data.l != user: switch Iris::recv.data[0].l:
kdebug ("invalid user requesting keyboard\n") case Iris::Device::RESET:
Iris::recv.reply.invoke () Iris::recv.reply.invoke ()
break break
switch Iris::recv.data[0].l:
case Iris::Keyboard::SET_CB: case Iris::Keyboard::SET_CB:
Iris::Cap reply = Iris::get_reply () Iris::Cap reply = Iris::get_reply ()
kbd.active (Iris::get_arg ()) kbd.active (Iris::get_arg ())
@ -272,11 +252,10 @@ Iris::Num start ():
break break
break break
case PWR: case PWR:
if Iris::recv.protected_data.l != power_user: switch Iris::recv.data[0].l:
kdebug ("invalid user requesting power\n") case Iris::Device::RESET:
Iris::recv.reply.invoke () Iris::recv.reply.invoke ()
break break
switch Iris::recv.data[0].l:
case Iris::Keyboard::SET_CB: case Iris::Keyboard::SET_CB:
Iris::Cap reply = Iris::get_reply () Iris::Cap reply = Iris::get_reply ()
pwr.set_cb (Iris::get_arg ()) pwr.set_cb (Iris::get_arg ())