1
0
mirror of git://projects.qi-hardware.com/iris.git synced 2024-10-01 11:40:23 +03:00
iris/source/display-emu.ccp

83 lines
2.9 KiB
COBOL

#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)