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>
|
|
|
|
|
2010-05-01 00:13:49 +03:00
|
|
|
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:
|
2010-05-01 00:13:49 +03:00
|
|
|
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:
|
2010-05-01 00:13:49 +03:00
|
|
|
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)
|
2010-05-01 00:13:49 +03:00
|
|
|
Iris::free_cap (target)
|
2010-01-30 10:21:56 +02:00
|
|
|
for unsigned i = 0; i < 320 * 240 * 4; i += PAGE_SIZE:
|
2010-05-01 00:13:49 +03:00
|
|
|
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)
|
2010-05-01 00:13:49 +03:00
|
|
|
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 ())
|
2010-05-01 00:13:49 +03:00
|
|
|
Iris::free_cap (ret)
|
2010-01-30 10:21:56 +02:00
|
|
|
break
|
2010-05-01 00:13:49 +03:00
|
|
|
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:
|
2010-05-01 00:13:49 +03:00
|
|
|
kdebug_num (Iris::recv.data[0].l)
|
2010-01-30 10:21:56 +02:00
|
|
|
kdebug ("\n")
|
2010-05-01 00:13:49 +03:00
|
|
|
Iris::panic (0, "invalid emulation command")
|
2010-01-30 10:21:56 +02:00
|
|
|
break
|
|
|
|
case 1:
|
2010-05-01 00:13:49 +03:00
|
|
|
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 ())
|
2010-05-01 00:13:49 +03:00
|
|
|
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:
|
2010-05-01 00:13:49 +03:00
|
|
|
kdebug_num (Iris::recv.data[0].l)
|
2010-01-30 10:21:56 +02:00
|
|
|
kdebug_char ('\n')
|
2010-05-01 00:13:49 +03:00
|
|
|
Iris::panic (Iris::recv.data[0].l, "invalid operation on display emulation")
|
2010-01-30 10:21:56 +02:00
|
|
|
break
|
|
|
|
default:
|
2010-05-01 00:13:49 +03:00
|
|
|
Iris::panic (0, "bug in display emulation")
|
|
|
|
Iris::free_cap (arg)
|
|
|
|
Iris::free_cap (reply)
|