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 
27 class DebuggerIO;
28 
30 {
31 }
32 
34 {
35 }
36 
38  const HugeStaticString &input, HugeStaticString &output)
39 {
40 }
41 
43  const HugeStaticString &input, HugeStaticString &output,
44  InterruptState &state, DebuggerIO *pScreen)
45 {
46 #if !defined(KERNEL_PROCESSOR_NO_PORT_IO)
48 
49  // Copy the list of used I/O ports
50  IoPortManager &ioPortManager = IoPortManager::instance();
51  ioPortManager.allocateIoPortList(IoPorts);
52 
53  output += "I/O ports:\n";
54 
55  {
58  for (; i != end; i++)
59  {
60  output += ' ';
61  output += (*i)->name;
62  output += ": 0x";
63  output.append((*i)->ioPort, 16);
64  output += " - 0x";
65  output.append((*i)->ioPort + (*i)->sIoPort - 1, 16);
66  output += "\n";
67  }
68  }
69 
70  // Free the list of I/O ports
71  ioPortManager.freeIoPortList(IoPorts);
72 #endif
73 
75 
76  // Copy the list of memory-regions
77  PhysicalMemoryManager &physicalMemoryManager =
79  physicalMemoryManager.allocateMemoryRegionList(MemoryRegions);
80 
81  output += "Memory regions:\n";
82 
83  {
85  MemoryRegions.begin();
87  MemoryRegions.end();
88  for (; i != end; i++)
89  {
90  output += ' ';
91  output += (*i)->pName;
92  output += ": virtual 0x";
93  output.append(
94  reinterpret_cast<uintptr_t>((*i)->pVirtualAddress), 16,
95  sizeof(processor_register_t) * 2, '0');
96  output += " - 0x";
97  output.append(
98  reinterpret_cast<uintptr_t>((*i)->pVirtualAddress) +
99  (*i)->sVirtualAddress,
100  16, sizeof(processor_register_t) * 2, '0');
101  if ((*i)->physicalAddress != 0)
102  {
103  output += '\n';
104  output.append(' ', StringLength((*i)->pName) + 3, ' ');
105  output += "physical 0x";
106  output.append(
107  (*i)->physicalAddress, 16, sizeof(physical_uintptr_t) * 2,
108  '0');
109  output += " - 0x";
110  output.append(
111  (*i)->physicalAddress + (*i)->sVirtualAddress, 16,
112  sizeof(physical_uintptr_t) * 2, '0');
113  }
114  output += '\n';
115  }
116  }
117 
118  return true;
119 }
Iterator begin()
Definition: Vector.h:148
Iterator end()
Definition: Vector.h:160
bool execute(const HugeStaticString &input, HugeStaticString &output, InterruptState &state, DebuggerIO *screen)
Definition: IoCommand.cc:42
static PhysicalMemoryManager & instance()
A vector / dynamic array.
static IoPortManager & instance()
Definition: IoPortManager.h:44
void allocateMemoryRegionList(Vector< MemoryRegionInfo * > &MemoryRegions)
Manages hardware I/O port (de)allocations.
Definition: IoPortManager.h:38
void allocateIoPortList(Vector< IoPortInfo * > &IoPorts)
~IoCommand()
Definition: IoCommand.cc:33
T const * ConstIterator
Definition: Vector.h:39
void autocomplete(const HugeStaticString &input, HugeStaticString &output)
Definition: IoCommand.cc:37
void freeIoPortList(Vector< IoPortInfo * > &IoPorts)