mirror of
git://projects.qi-hardware.com/iris.git
synced 2024-11-17 08:23:45 +02:00
83 lines
2.9 KiB
COBOL
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>
|
|
|
|
Kernel::Num start ():
|
|
Device d = Kernel::my_receiver.create_capability (0)
|
|
Kernel::my_parent.provide_device <Display> (d.copy (), 0x10000)
|
|
Kernel::free_cap (d)
|
|
Kernel::my_parent.init_done ()
|
|
Display real = Kernel::my_parent.get_device <Display> (0)
|
|
while true:
|
|
Kernel::wait ()
|
|
Kernel::Cap arg = Kernel::get_arg ()
|
|
Kernel::Cap reply = Kernel::get_reply ()
|
|
switch Kernel::recv.protected_data.h:
|
|
case 0:
|
|
switch Kernel::recv.data[0].l:
|
|
case Device::CREATE_USER:
|
|
Kernel::Memory mem (arg)
|
|
Kernel::Caps ret = mem.create_caps (3)
|
|
Kernel::Cap target = Kernel::my_receiver.create_capability (Kernel::Num (0, 1))
|
|
ret.set (0, target.copy ())
|
|
ret.set (1, mem)
|
|
Kernel::free_cap (target)
|
|
for unsigned i = 0; i < 320 * 240 * 4; i += PAGE_SIZE:
|
|
Kernel::Page p = Kernel::my_memory.mapping ((void *)(0x15000 + i))
|
|
Kernel::Page t = mem.create_page ()
|
|
t.set_flags (Kernel::Page::PAYING, Kernel::Page::PAYING)
|
|
p.share (t, Kernel::Page::FORGET)
|
|
mem.map (t, 0x15000 + i)
|
|
Kernel::my_memory.destroy (t)
|
|
Kernel::free_cap (t)
|
|
Kernel::free_cap (p)
|
|
reply.invoke (0, 0, ret.copy ())
|
|
Kernel::free_cap (ret)
|
|
break
|
|
case Device::DESTROY_USER:
|
|
Kernel::panic (0, "destroying emulation user")
|
|
case Device::USE:
|
|
case Device::UNUSE:
|
|
reply.invoke ()
|
|
break
|
|
default:
|
|
kdebug_num (Kernel::recv.data[0].l)
|
|
kdebug ("\n")
|
|
Kernel::panic (0, "invalid emulation command")
|
|
break
|
|
case 1:
|
|
switch Kernel::recv.data[0].l:
|
|
case Display::SET_EOF_CB:
|
|
real.set_eof_cb (arg.copy ())
|
|
while Kernel::recv.data[0].l != 0:
|
|
Kernel::my_parent.wait <Display> (0)
|
|
real.set_eof_cb (arg.copy ())
|
|
reply.invoke ()
|
|
break
|
|
default:
|
|
kdebug_num (Kernel::recv.data[0].l)
|
|
kdebug_char ('\n')
|
|
Kernel::panic (Kernel::recv.data[0].l, "invalid operation on display emulation")
|
|
break
|
|
default:
|
|
Kernel::panic (0, "bug in display emulation")
|
|
Kernel::free_cap (arg)
|
|
Kernel::free_cap (reply)
|