FreeNOS
IO.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2015 Niek Linnenbank
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef __LIBARCH_IO_H
19#define __LIBARCH_IO_H
20
21#include <Types.h>
22#include "Memory.h"
23
35class IO
36{
37 public:
38
48
52 IO();
53
59 Address getBase() const;
60
66 void setBase(const Address base);
67
76 Result map(Address phys,
77 Size size = 4096,
79
85 Result unmap();
86
87 protected:
88
91
94};
95
101#endif /* __LIBARCH_IO_H */
Generic I/O functions.
Definition IO.h:36
void setBase(const Address base)
Set memory I/O base offset.
Definition IO.cpp:33
IO()
Constructor.
Definition IO.cpp:23
Address m_base
memory I/O base offset is added to each I/O address.
Definition IO.h:90
Result map(Address phys, Size size=4096, Memory::Access access=Memory::Readable|Memory::Writable|Memory::User)
Map I/O address space.
Definition IO.cpp:38
Address getBase() const
Get memory I/O base offset.
Definition IO.cpp:28
Result
Result codes.
Definition IO.h:43
@ OutOfMemory
Definition IO.h:46
@ MapFailure
Definition IO.h:45
@ Success
Definition IO.h:44
Result unmap()
Unmap I/O address space.
Definition IO.cpp:70
Memory::Range m_range
Memory range for performing I/O mappings.
Definition IO.h:93
unsigned long Address
A memory address.
Definition Types.h:131
unsigned int Size
Any sane size indicator cannot go negative.
Definition Types.h:128
Access
Memory access flags.
Definition Memory.h:39
@ User
Definition Memory.h:44
@ Readable
Definition Memory.h:41
@ Writable
Definition Memory.h:42
Memory range.
Definition Memory.h:56