]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/sigma0/server/src/ioports_x86.cc
update
[l4.git] / l4 / pkg / sigma0 / server / src / ioports_x86.cc
1 /*
2  * (c) 2008-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
3  *               Alexander Warg <warg@os.inf.tu-dresden.de>
4  *     economic rights: Technische Universität Dresden (Germany)
5  *
6  * This file is part of TUD:OS and distributed under the terms of the
7  * GNU General Public License 2.
8  * Please see the COPYING-GPL-2 file for details.
9  */
10 #include "ioports.h"
11 #include "mem_man.h"
12 #include "globals.h"
13
14 #include <l4/sys/types.h>
15 #include <l4/sys/ipc.h>
16
17 #include <l4/cxx/iostream>
18
19 enum { PORT_SHIFT = 12 };
20
21 static Mem_man io_ports;
22
23 void init_io_ports(l4_kernel_info_t * /*info*/)
24 {
25   io_ports.add_free(Region::kr(0, (64*1024) << PORT_SHIFT));
26 }
27
28 void dump_io_ports()
29 {
30   L4::cout << "IO PORTS--------------------------\n";
31   io_ports.dump();
32 }
33
34 void handle_io_page_fault(l4_umword_t t, l4_utcb_t *utcb, Answer *a)
35 {
36   unsigned long port, size;
37   l4_fpage_t fp = (l4_fpage_t&)l4_utcb_mr_u(utcb)->mr[0];
38   port = l4_fpage_page(fp) << PORT_SHIFT;
39   size = l4_fpage_size(fp) + PORT_SHIFT;
40
41   unsigned long i = io_ports.alloc(Region::bs(port, 1UL << size, t));
42   if (i == port)
43     a->snd_fpage(l4_iofpage(port >> PORT_SHIFT, size - PORT_SHIFT));
44   else
45     a->error(L4_ENOMEM);
46 }