1
0
mirror of git://projects.qi-hardware.com/iris.git synced 2024-11-17 04:20:37 +02:00
iris/source/display-emu.ccp

83 lines
2.9 KiB
Plaintext
Raw Normal View History

2010-01-30 10:21:56 +02:00
#pypp 0
2010-02-06 00:15:58 +02:00
// 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/>.
2010-01-30 10:21:56 +02:00
#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)
2010-01-30 10:21:56 +02:00
while true:
Iris::wait ()
Iris::Cap arg = Iris::get_arg ()
Iris::Cap reply = Iris::get_reply ()
switch Iris::recv.protected_data.h:
2010-01-30 10:21:56 +02:00
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))
2010-01-31 10:26:23 +02:00
ret.set (0, target.copy ())
ret.set (1, mem)
Iris::free_cap (target)
2010-01-30 10:21:56 +02:00
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)
2010-01-30 10:21:56 +02:00
mem.map (t, 0x15000 + i)
Iris::my_memory.destroy (t)
Iris::free_cap (t)
Iris::free_cap (p)
2010-01-31 10:26:23 +02:00
reply.invoke (0, 0, ret.copy ())
Iris::free_cap (ret)
2010-01-30 10:21:56 +02:00
break
case Iris::Device::DESTROY_USER:
Iris::panic (0, "destroying emulation user")
case Iris::Device::USE:
case Iris::Device::UNUSE:
2010-01-30 10:21:56 +02:00
reply.invoke ()
break
default:
kdebug_num (Iris::recv.data[0].l)
2010-01-30 10:21:56 +02:00
kdebug ("\n")
Iris::panic (0, "invalid emulation command")
2010-01-30 10:21:56 +02:00
break
case 1:
switch Iris::recv.data[0].l:
case Iris::Display::SET_EOF_CB:
2010-01-30 10:21:56 +02:00
real.set_eof_cb (arg.copy ())
while Iris::recv.data[0].l != 0:
Iris::my_parent.wait <Iris::Display> (0)
2010-01-30 10:21:56 +02:00
real.set_eof_cb (arg.copy ())
reply.invoke ()
break
default:
kdebug_num (Iris::recv.data[0].l)
2010-01-30 10:21:56 +02:00
kdebug_char ('\n')
Iris::panic (Iris::recv.data[0].l, "invalid operation on display emulation")
2010-01-30 10:21:56 +02:00
break
default:
Iris::panic (0, "bug in display emulation")
Iris::free_cap (arg)
Iris::free_cap (reply)