The Pedigree Project 0.1
IoPortManager.h
1/*
2 * Copyright (c) 2008-2014, Pedigree Developers
3 *
4 * Please see the CONTRIB file in the root of the source tree for a full
5 * list of contributors.
6 *
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
10 *
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 */
19
20#ifndef KERNEL_PROCESSOR_IOPORTMANAGER_H
21#define KERNEL_PROCESSOR_IOPORTMANAGER_H
22
23#include "pedigree/kernel/Spinlock.h"
24#include "pedigree/kernel/compiler.h"
25#include "pedigree/kernel/processor/Processor.h"
26#include "pedigree/kernel/processor/types.h"
27#include "pedigree/kernel/utilities/RangeList.h"
28#include "pedigree/kernel/utilities/Vector.h"
29
30class IoPort;
31
38 friend class ProcessorBase;
39
40 public:
42 inline static IoPortManager& instance() {
43 return m_Instance;
44 }
45
47 struct IoPortInfo {
52 inline IoPortInfo(io_port_t IoPort, size_t size, const char* Name)
53 : ioPort(IoPort), sIoPort(size), name(Name) {}
54
56 io_port_t ioPort;
58 size_t sIoPort;
60 const char* name;
61 };
62
70 bool allocate(IoPort* Port, io_port_t ioPort, size_t size);
74 void free(IoPort* Port);
75
82
86 void initialise(io_port_t ioPortBase, size_t size) INITIALISATION_ONLY;
87
88 private:
92 virtual ~IoPortManager();
98 IoPortManager& operator=(const IoPortManager&);
99
102
107
110};
111
114#endif
Manages hardware I/O port (de)allocations.
bool allocate(IoPort *Port, io_port_t ioPort, size_t size)
void initialise(io_port_t ioPortBase, size_t size) INITIALISATION_ONLY
static IoPortManager & instance()
void allocateIoPortList(Vector< IoPortInfo * > &IoPorts)
void freeIoPortList(Vector< IoPortInfo * > &IoPorts)
Vector< IoPort * > m_UsedIoPorts
RangeList< uint32_t > m_FreeIoPorts
static IoPortManager m_Instance
IoPortManager() INITIALISATION_ONLY
void free(IoPort *Port)
I/O port range.
Definition IoPort.h:33
A vector / dynamic array.
Definition Vector.h:33
IoPortInfo(io_port_t IoPort, size_t size, const char *Name)