The Pedigree Project 0.1
IoCommand.cc
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#include "pedigree/kernel/debugger/commands/IoCommand.h"
21#include "pedigree/kernel/processor/IoPortManager.h"
22#include "pedigree/kernel/processor/PhysicalMemoryManager.h"
23#include "pedigree/kernel/processor/types.h"
24#include "pedigree/kernel/utilities/Vector.h"
25#include "pedigree/kernel/utilities/utility.h"
26
27class DebuggerIO;
28
30
32
34
36 InterruptState& state, DebuggerIO* pScreen) {
37 EMIT_IF(!KERNEL_PROCESSOR_NO_PORT_IO) {
39
40 // Copy the list of used I/O ports
41 IoPortManager& ioPortManager = IoPortManager::instance();
42 ioPortManager.allocateIoPortList(IoPorts);
43
44 output += "I/O ports:\n";
45
48 for (; i != end; ++i) {
49 output += ' ';
50 output += (*i)->name;
51 output += ": 0x";
52 output.append((*i)->ioPort, 16);
53 output += " - 0x";
54 output.append((*i)->ioPort + (*i)->sIoPort - 1, 16);
55 output += "\n";
56 }
57
58 // Free the list of I/O ports
59 ioPortManager.freeIoPortList(IoPorts);
60 }
61
63
64 // Copy the list of memory-regions
66 physicalMemoryManager.allocateMemoryRegionList(MemoryRegions);
67
68 output += "Memory regions:\n";
69
70 {
73 for (; i != end; i++) {
74 output += ' ';
75 output += (*i)->pName;
76 output += ": virtual 0x";
77 output.append(reinterpret_cast<uintptr_t>((*i)->pVirtualAddress), 16,
78 sizeof(processor_register_t) * 2, '0');
79 output += " - 0x";
80 output.append(reinterpret_cast<uintptr_t>((*i)->pVirtualAddress) + (*i)->sVirtualAddress, 16,
81 sizeof(processor_register_t) * 2, '0');
82 if ((*i)->physicalAddress != 0) {
83 output += '\n';
84 output.append(' ', StringLength((*i)->pName) + 3, ' ');
85 output += "physical 0x";
86 output.append((*i)->physicalAddress, 16, sizeof(physical_uintptr_t) * 2, '0');
87 output += " - 0x";
88 output.append((*i)->physicalAddress + (*i)->sVirtualAddress, 16,
89 sizeof(physical_uintptr_t) * 2, '0');
90 }
91 output += '\n';
92 }
93 }
94
95 return true;
96}
bool execute(const HugeStaticString &input, HugeStaticString &output, InterruptState &state, DebuggerIO *screen)
Definition IoCommand.cc:35
void autocomplete(const HugeStaticString &input, HugeStaticString &output)
Definition IoCommand.cc:33
Manages hardware I/O port (de)allocations.
static IoPortManager & instance()
void allocateIoPortList(Vector< IoPortInfo * > &IoPorts)
void freeIoPortList(Vector< IoPortInfo * > &IoPorts)
static PhysicalMemoryManager & instance()
void allocateMemoryRegionList(Vector< MemoryRegionInfo * > &MemoryRegions)
A vector / dynamic array.
Definition Vector.h:33
Iterator end()
Definition Vector.h:172
Iterator begin()
Definition Vector.h:162
T const * ConstIterator
Definition Vector.h:38