1
/*
2
* \brief I/O-port session interface
3
* \author Christian Helmuth
4
* \date 2007-04-17
5
*
6
* An I/O port session permits access to a range of ports. Inside this range
7
* variable-sized accesses (i.e., 8, 16, 32 bit) at arbitrary addresses are
8
* allowed - currently, alignment is not enforced. Core enforces that access is
9
* limited to the session-defined range while the user provides physical I/O port
10
* addresses as arguments.
11
*
12
* The design is founded on experiences while programming PCI configuration
13
* space which needs two 32-bit port registers. Each byte, word and dword in
14
* the data register must be explicitly accessible for read and write. The old
15
* design needs six capabilities only for the data register.
16
*/
17
18
/*
19
* Copyright (C) 2007-2013 Genode Labs GmbH
20
*
21
* This file is part of the Genode OS framework, which is distributed
22
* under the terms of the GNU General Public License version 2.
23
*/
24
25
#
ifndef _INCLUDE__IO_PORT_SESSION__IO_PORT_SESSION_H_
26
#
define _INCLUDE__IO_PORT_SESSION__IO_PORT_SESSION_H_
27
28
#
include <base/capability.h>
29
#
include <session/session.h>
30
31
namespace
Genode {
struct
Io_port_session;
}
32
33
34
struct
Genode::
Io_port_session :
Session
35
{
36
static
const
char *
service_name(
)
{
return
"IO_PORT"
;
}
37
38
virtual
~
Io_port_session(
)
{
}
39
40
/******************************
41
** Read value from I/O port **
42
******************************/
43
44
/**
45
* Read byte (8 bit)
46
*
47
* \param address physical I/O port address
48
*
49
* \return value read from port
50
*/
51
virtual
unsigned
char
inb(
unsigned
short
address
)
=
0
;
52
53
/**
54
* Read word (16 bit)
55
*
56
* \param address physical I/O port address
57
*
58
* \return value read from port
59
*/
60
virtual
unsigned
short
inw(
unsigned
short
address
)
=
0
;
61
62
/**
63
* Read double word (32 bit)
64
*
65
* \param address physical I/O port address
66
*
67
* \return value read from port
68
*/
69
virtual
unsigned
inl(
unsigned
short
address
)
=
0
;
70
71
72
/*****************************
73
** Write value to I/O port **
74
*****************************/
75
76
/**
77
* Write byte (8 bit)
78
*
79
* \param address physical I/O port address
80
* \param value value to write to port
81
*/
82
virtual
void
outb(
unsigned
short
address
,
unsigned
char
value
)
=
0
;
83
84
/**
85
* Write word (16 bit)
86
*
87
* \param address physical I/O port address
88
* \param value value to write to port
89
*/
90
virtual
void
outw(
unsigned
short
address
,
unsigned
short
value
)
=
0
;
91
92
/**
93
* Write double word (32 bit)
94
*
95
* \param address physical I/O port address
96
* \param value value to write to port
97
*/
98
virtual
void
outl(
unsigned
short
address
,
unsigned
value
)
=
0
;
99
100
101
/*********************
102
** RPC declaration **
103
*********************/
104
105
GENODE_RPC
(
Rpc_inb,
unsigned
char,
inb,
unsigned
short)
;
106
GENODE_RPC
(
Rpc_inw,
unsigned
short,
inw,
unsigned
short)
;
107
GENODE_RPC
(
Rpc_inl,
unsigned
,
inl,
unsigned
short)
;
108
109
GENODE_RPC
(
Rpc_outb,
void,
outb,
unsigned
short,
unsigned
char)
;
110
GENODE_RPC
(
Rpc_outw,
void,
outw,
unsigned
short,
unsigned
short)
;
111
GENODE_RPC
(
Rpc_outl,
void,
outl,
unsigned
short,
unsigned
)
;
112
113
GENODE_RPC_INTERFACE
(
Rpc_inb,
Rpc_inw,
Rpc_inl,
Rpc_outb,
Rpc_outw,
Rpc_outl)
;
114
}
;
115
116
#
endif /* _INCLUDE__IO_PORT_SESSION__IO_PORT_SESSION_H_ */