]> rtime.felk.cvut.cz Git - l4.git/blob - kernel/fiasco/src/kern/ux/vhw.cpp
update
[l4.git] / kernel / fiasco / src / kern / ux / vhw.cpp
1 /*
2  * Description for driver memory areas, used under UX.
3  */
4
5 INTERFACE[ux,ia32]:
6
7 #include "types.h"
8
9 class Vhw_entry
10 {
11 public:
12
13   enum Vhw_entry_type
14   {
15     TYPE_NONE,
16     TYPE_FRAMEBUFFER,
17     TYPE_INPUT,
18     TYPE_NET,
19   };
20
21 private:
22   Vhw_entry_type _type;     // type of the descriptor
23   Unsigned32 _provider_pid; // Host PID of the program providing this area
24
25   Address    _mem_start;    // start of a memory area in physical memory
26   Address    _mem_size;     // size of the memory area
27
28   Unsigned32 _irq_no;       // IRQ number for notification events
29   Unsigned32 _fd;           // Communication file descriptor
30
31 public:
32
33   void type(enum Vhw_entry_type t) { _type = t; }
34   void provider_pid(Unsigned32 p)  { _provider_pid = p; }
35   void mem_start(Address a)        { _mem_start = a; }
36   void mem_size(Address a)         { _mem_size = a; }
37   void irq_no(Unsigned32 i)        { _irq_no = i; }
38   void fd(Unsigned32 i)            { _fd = i; }
39 };
40
41 // -------
42
43 class Vhw_descriptor
44 {
45 public:
46   Unsigned32 magic() const       { return _magic; }
47   Unsigned8 version() const      { return _version; }
48   Unsigned8 count() const        { return _count; }
49
50 private:
51
52   static Unsigned8 const count_const = 3;  // nr of descriptors
53
54   Unsigned32 _magic;                       // magic value
55   Unsigned8  _version;                     // version of this description format
56   Unsigned8  _count;                       // nr of descriptors
57   Unsigned8  _pad1;
58   Unsigned8  _pad2;
59
60   Vhw_entry descs[count_const];
61 };
62
63 // -----------------------------------------------------------------
64 IMPLEMENTATION[ux,ia32]:
65
66 PUBLIC
67 void
68 Vhw_entry::reset()
69 {
70   type(TYPE_NONE);
71 }
72
73 PUBLIC
74 void
75 Vhw_entry::set(enum Vhw_entry_type t,
76                Address start, Address size,
77                Unsigned32 irqno, Unsigned32 provpid, Unsigned32 fdp)
78 {
79   type(t);
80   mem_start(start);
81   mem_size(size);
82   irq_no(irqno);
83   provider_pid(provpid);
84   fd(fdp);
85 }
86
87 // -------
88
89 PUBLIC
90 void
91 Vhw_descriptor::init()
92 {
93   _magic   = 0x56687765;
94   _version = 1;
95   _count   = count_const;
96
97   for (int i = 0; i < count_const; i++)
98     descs[i].reset();
99 }
100
101 PUBLIC
102 void
103 Vhw_descriptor::set_desc(Vhw_entry::Vhw_entry_type type,
104                          Address mem_start, Address mem_size,
105                          Unsigned32 irq_no, Unsigned32 provider_pid,
106                          Unsigned32 fdp)
107 {
108   if (type != Vhw_entry::TYPE_NONE)
109     descs[type - 1].set(type, mem_start, mem_size, irq_no, provider_pid, fdp);
110 }