CPUComponent.cc Source File

Back to the index.

CPUComponent.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2019 Anders Gavare. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  *
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * 3. The name of the author may not be used to endorse or promote products
13  * derived from this software without specific prior written permission.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25  * SUCH DAMAGE.
26  */
27 
28 #include <assert.h>
29 #include <iomanip>
30 
31 #include "AddressDataBus.h"
33 #include "GXemul.h"
34 
35 
36 CPUComponent::CPUComponent(const string& className, const string& cpuArchitecture)
37  : Component(className, "cpu") // all cpus have "cpu" as their
38  // visible class name, regardless of
39  // their actual class name
40  , m_frequency(33.0e6)
41  , m_paused(false)
42  , m_cpuArchitecture(cpuArchitecture)
43  , m_pageSize(0)
44  , m_pc(0)
45  , m_lastDumpAddr(0)
46  , m_lastUnassembleVaddr(0)
47  , m_hasUsedUnassemble(false)
48  , m_isBigEndian(true)
49  , m_showFunctionTraceCall(false)
50  , m_showFunctionTraceReturn(false)
51  , m_functionCallTraceDepth(0)
52  , m_nrOfTracedFunctionCalls(0)
53  , m_addressDataBus(NULL)
54 {
55  AddVariable("architecture", &m_cpuArchitecture);
56  AddVariable("pc", &m_pc);
57  AddVariable("lastDumpAddr", &m_lastDumpAddr);
58  AddVariable("lastUnassembleVaddr", &m_lastUnassembleVaddr);
59  AddVariable("hasUsedUnassemble", &m_hasUsedUnassemble);
60  AddVariable("frequency", &m_frequency);
61  AddVariable("paused", &m_paused);
62  AddVariable("bigendian", &m_isBigEndian);
63  AddVariable("showFunctionTraceCall", &m_showFunctionTraceCall);
64  AddVariable("showFunctionTraceReturn", &m_showFunctionTraceReturn);
65  AddVariable("functionCallTraceDepth", &m_functionCallTraceDepth);
66  AddVariable("nrOfTracedFunctionCalls", &m_nrOfTracedFunctionCalls);
67 }
68 
69 
71 {
72  return m_frequency;
73 }
74 
75 
77 {
78  return this;
79 }
80 
81 
83 {
84  m_hasUsedUnassemble = false;
86  m_inDelaySlot = false;
88 
89  // Don't reset m_showFunctionTraceCall and Return here?
92 
93  m_symbolRegistry.Clear();
94 
96 }
97 
98 
100 {
101  stringstream ss;
102  for (int i=0; i<m_functionCallTraceDepth; ++i)
103  ss << " ";
104 
106  if (symbol != "")
107  ss << symbol;
108 
109  ss << "(";
110  int n = FunctionTraceArgumentCount();
111  for (int i=0; i<n; ++i) {
112  int64_t arg = FunctionTraceArgument(i);
113 
114  if (arg > -1000 && arg < 1000) {
115  ss << arg;
116  } else {
117  ss.flags(std::ios::hex);
118  ss << "0x" << (uint64_t)arg;
119  }
120 
121  // TODO: String and/or symbol lookup!
122 
123  ss << ",";
124  }
125  ss << "...)\n";
126 
127  GetUI()->ShowDebugMessage(this, ss.str());
128 
130 
132  if (m_functionCallTraceDepth > 100)
134 
135  GXemul* gxemul = GetRunningGXemulInstance();
136  if (gxemul != NULL && gxemul->IsInterrupting())
137  return false;
138 
139  return true;
140 }
141 
142 
144 {
146  if (m_functionCallTraceDepth < 0)
148 
150  int64_t retval;
151  bool traceReturnValid = FunctionTraceReturnImpl(retval);
152  if (traceReturnValid) {
153  stringstream ss;
154  for (int i=0; i<m_functionCallTraceDepth; ++i)
155  ss << " ";
156 
157  if (retval > -1000 && retval < 1000) {
158  ss << "= " << retval;
159  } else {
160  ss.flags(std::ios::hex);
161  ss << "= 0x" << (uint64_t)retval;
162  }
163 
164  // TODO: String and/or symbol lookup!
165 
166  GetUI()->ShowDebugMessage(this, ss.str());
167  }
168 
169  GXemul* gxemul = GetRunningGXemulInstance();
170  if (gxemul != NULL && gxemul->IsInterrupting())
171  return false;
172  }
173 
174  return true;
175 }
176 
177 
178 void CPUComponent::GetMethodNames(vector<string>& names) const
179 {
180  // Add our method names...
181  names.push_back("dump");
182  names.push_back("registers");
183  names.push_back("unassemble");
184 
185  // ... and make sure to call the base class implementation:
187 }
188 
189 
190 bool CPUComponent::MethodMayBeReexecutedWithoutArgs(const string& methodName) const
191 {
192  if (methodName == "dump")
193  return true;
194 
195  if (methodName == "unassemble")
196  return true;
197 
198  // ... and make sure to call the base class implementation:
200 }
201 
202 
203 void CPUComponent::ExecuteMethod(GXemul* gxemul, const string& methodName,
204  const vector<string>& arguments)
205 {
206  if (methodName == "dump") {
207  uint64_t vaddr = m_lastDumpAddr;
208 
209  if (arguments.size() > 1) {
210  gxemul->GetUI()->ShowDebugMessage("syntax: .dump [addr]\n");
211  return;
212  }
213 
214  if (arguments.size() == 1) {
215  gxemul->GetUI()->ShowDebugMessage("TODO: parse address expression\n");
216  gxemul->GetUI()->ShowDebugMessage("(for now, only hex immediate values are supported!)\n");
217 
218  stringstream ss;
219  ss << arguments[0];
220  ss.flags(std::ios::hex);
221  ss >> vaddr;
222  }
223 
224  const int nRows = 16;
225  for (int i=0; i<nRows; i++) {
226  const size_t len = 16;
227  unsigned char data[len];
228  bool readable[len];
229 
230  stringstream ss;
231  ss.flags(std::ios::hex);
232 
233  if (vaddr > 0xffffffff)
234  ss << std::setw(16);
235  else
236  ss << std::setw(8);
237 
238  ss << std::setfill('0') << vaddr;
239 
240  size_t k;
241  for (k=0; k<len; ++k) {
242  AddressSelect(vaddr + k);
243  readable[k] = ReadData(data[k], m_isBigEndian? BigEndian : LittleEndian);
244  }
245 
246  ss << " ";
247 
248  for (k=0; k<len; ++k) {
249  if ((k&3) == 0)
250  ss << " ";
251 
252  ss << std::setw(2) << std::setfill('0');
253  if (readable[k])
254  ss << (int)data[k];
255  else
256  ss << "--";
257  }
258 
259  ss << " ";
260 
261  for (k=0; k<len; ++k) {
262  char s[2];
263  s[0] = data[k] >= 32 && data[k] < 127? data[k] : '.';
264  s[1] = '\0';
265 
266  if (readable[k])
267  ss << s;
268  else
269  ss << "-";
270  }
271 
272  ss << "\n";
273 
274  gxemul->GetUI()->ShowDebugMessage(ss.str());
275 
276  vaddr += len;
277  }
278 
279  m_lastDumpAddr = vaddr;
280 
281  return;
282  }
283 
284  if (methodName == "registers") {
285  ShowRegisters(gxemul, arguments);
286  return;
287  }
288 
289  if (methodName == "unassemble") {
290  uint64_t vaddr = m_lastUnassembleVaddr;
291  if (!m_hasUsedUnassemble)
292  vaddr = PCtoInstructionAddress(m_pc);
293 
294  if (arguments.size() > 1) {
295  gxemul->GetUI()->ShowDebugMessage("syntax: .unassemble [addr]\n");
296  return;
297  }
298 
299  if (arguments.size() == 1) {
300  gxemul->GetUI()->ShowDebugMessage("TODO: parse address expression\n");
301  gxemul->GetUI()->ShowDebugMessage("(for now, only hex immediate values are supported!)\n");
302 
303  stringstream ss;
304  ss << arguments[0];
305  ss.flags(std::ios::hex);
306  ss >> vaddr;
307  }
308 
309  const int nRows = 20;
310 
311  stringstream output;
312  vaddr = Unassemble(nRows, true, vaddr, output);
313  gxemul->GetUI()->ShowDebugMessage(output.str());
314 
315  m_hasUsedUnassemble = true;
316  m_lastUnassembleVaddr = vaddr;
317  return;
318  }
319 
320  // Call base...
321  Component::ExecuteMethod(gxemul, methodName, arguments);
322 }
323 
324 
325 uint64_t CPUComponent::Unassemble(int nRows, bool indicatePC, uint64_t vaddr, ostream& output)
326 {
327  LookupAddressDataBus();
328 
329  vector< vector<string> > outputRows;
330 
331  for (int i=0; i<nRows; i++) {
332  outputRows.push_back(vector<string>());
333 
334  string symbol = GetSymbolRegistry().LookupAddress(vaddr, false);
335  if (symbol != "") {
336  outputRows[outputRows.size()-1].push_back("<" + symbol + ">");
337  outputRows.push_back(vector<string>());
338  }
339 
340  stringstream ss;
341  ss.flags(std::ios::hex | std::ios::showbase);
342  ss << VirtualAddressAsString(vaddr);
343 
344  if (indicatePC && PCtoInstructionAddress(m_pc) == vaddr)
345  ss << " <- ";
346  else
347  ss << " ";
348 
349  outputRows[outputRows.size()-1].push_back(ss.str());
350 
351  if (m_addressDataBus == NULL) {
352  outputRows[outputRows.size()-1].push_back("; no address/data bus connected to the CPU");
353  } else {
354  vector<string> result;
355 
356  size_t len = DisassembleInstruction(vaddr, result);
357  vaddr += len;
358 
359  for (size_t j=0; j<result.size(); ++j)
360  outputRows[outputRows.size()-1].push_back(result[j]);
361 
362  if (len == 0)
363  break;
364  }
365  }
366 
367  // Output the rows with equal-width columns:
368  vector<size_t> columnWidths;
369  size_t row;
370  for (row=0; row<outputRows.size(); ++row) {
371  size_t nColumns = outputRows[row].size();
372 
373  // Skip lines such as "<symbol>" on empty lines, when
374  // calculating column width.
375  if (nColumns <= 1)
376  continue;
377 
378  if (columnWidths.size() < nColumns)
379  columnWidths.resize(nColumns);
380 
381  for (size_t col=0; col<nColumns; ++col) {
382  const string& s = outputRows[row][col];
383  if (s.length() > columnWidths[col])
384  columnWidths[col] = s.length();
385  }
386  }
387 
388  for (row=0; row<outputRows.size(); ++row) {
389  const vector<string>& rowVector = outputRows[row];
390 
391  for (size_t i=0; i<rowVector.size(); ++i) {
392  // Note: i>=2 because:
393  // index 0 is the first column, no spaces before that one,
394  // but also: index 1 because the spaces after the vaddr
395  // is a special case ("<-" pc indicator).
396  if (i >= 2)
397  output << " ";
398 
399  size_t len = rowVector[i].length();
400  output << rowVector[i];
401 
402  int nspaces = columnWidths[i] - len;
403  for (int j=0; j<nspaces; ++j)
404  output << " ";
405  }
406 
407  output << "\n";
408  }
409 
410  return vaddr;
411 }
412 
413 
415 {
416  return this;
417 }
418 
419 
421 {
422  m_addressDataBus = NULL;
423 
425 }
426 
427 
429 {
430  // If AddressDataBus lookup fails, then the CPU fails.
431  if (!LookupAddressDataBus(gxemul)) {
432  gxemul->GetUI()->ShowDebugMessage(this, "this CPU"
433  " has neither any child components nor any parent component"
434  " that can act as address/data bus, so there is no place"
435  " to read instructions from\n");
436  return false;
437  }
438 
439  return true;
440 }
441 
442 
443 bool CPUComponent::LookupAddressDataBus(GXemul* gxemul)
444 {
445  if (m_addressDataBus != NULL)
446  return true;
447 
448  // Find a suitable address data bus.
449  AddressDataBus *bus = NULL;
450 
451  // 1) A direct first-level decendant of the CPU is probably a
452  // cache. Use this if it exists.
453  // If there are multiple AddressDataBus capable children,
454  // print a debug warning, and just choose any of the children
455  // (the last one).
456  Components& children = GetChildren();
457  Component* choosenChild = NULL;
458  bool multipleChildBussesFound = false;
459  for (size_t i=0; i<children.size(); ++i) {
460  AddressDataBus *childBus = children[i]->AsAddressDataBus();
461  if (childBus != NULL) {
462  if (bus != NULL)
463  multipleChildBussesFound = true;
464  bus = childBus;
465  choosenChild = children[i];
466  }
467  }
468 
469  if (multipleChildBussesFound && gxemul != NULL)
470  gxemul->GetUI()->ShowDebugMessage(this, "warning: this CPU has "
471  "multiple child components that can act as address/data busses; "
472  "using " + choosenChild->GenerateShortestPossiblePath() + "\n");
473 
474  // 2) If no cache exists, go to a parent bus (usually a mainbus).
475  if (bus == NULL) {
476  refcount_ptr<Component> component = GetParent();
477  while (!component.IsNULL()) {
478  bus = component->AsAddressDataBus();
479  if (bus != NULL)
480  break;
481  component = component->GetParent();
482  }
483  }
484 
485  m_addressDataBus = bus;
486 
487  return m_addressDataBus != NULL;
488 }
489 
490 
491 void CPUComponent::ShowRegisters(GXemul* gxemul, const vector<string>& arguments) const
492 {
493  gxemul->GetUI()->ShowDebugMessage("The registers method has not yet "
494  "been implemented for this CPU type. TODO.\n");
495 }
496 
497 
498 void CPUComponent::AddressSelect(uint64_t address)
499 {
500  m_addressSelect = address;
501 }
502 
503 
504 bool CPUComponent::ReadData(uint8_t& data, Endianness endianness)
505 {
506  if (!LookupAddressDataBus())
507  return false;
508 
509  uint64_t paddr;
510  bool writable;
511  VirtualToPhysical(m_addressSelect, paddr, writable);
512 
514  return m_addressDataBus->ReadData(data, endianness);
515 }
516 
517 
518 bool CPUComponent::ReadData(uint16_t& data, Endianness endianness)
519 {
520  assert((m_addressSelect & 1) == 0);
521 
522  if (!LookupAddressDataBus())
523  return false;
524 
525  uint64_t paddr;
526  bool writable;
527  VirtualToPhysical(m_addressSelect, paddr, writable);
528 
530  return m_addressDataBus->ReadData(data, endianness);
531 }
532 
533 
534 bool CPUComponent::ReadData(uint32_t& data, Endianness endianness)
535 {
536  assert((m_addressSelect & 3) == 0);
537 
538  if (!LookupAddressDataBus())
539  return false;
540 
541  uint64_t paddr;
542  bool writable;
543  VirtualToPhysical(m_addressSelect, paddr, writable);
544 
546  return m_addressDataBus->ReadData(data, endianness);
547 }
548 
549 
550 bool CPUComponent::ReadData(uint64_t& data, Endianness endianness)
551 {
552  assert((m_addressSelect & 7) == 0);
553 
554  if (!LookupAddressDataBus())
555  return false;
556 
557  uint64_t paddr;
558  bool writable;
559  VirtualToPhysical(m_addressSelect, paddr, writable);
560 
562  return m_addressDataBus->ReadData(data, endianness);
563 }
564 
565 
566 bool CPUComponent::WriteData(const uint8_t& data, Endianness endianness)
567 {
568  if (!LookupAddressDataBus())
569  return false;
570 
571  uint64_t paddr;
572  bool writable;
573  VirtualToPhysical(m_addressSelect, paddr, writable);
574 
576  return m_addressDataBus->WriteData(data, endianness);
577 }
578 
579 
580 bool CPUComponent::WriteData(const uint16_t& data, Endianness endianness)
581 {
582  assert((m_addressSelect & 1) == 0);
583 
584  if (!LookupAddressDataBus())
585  return false;
586 
587  uint64_t paddr;
588  bool writable;
589  VirtualToPhysical(m_addressSelect, paddr, writable);
590 
592  return m_addressDataBus->WriteData(data, endianness);
593 }
594 
595 
596 bool CPUComponent::WriteData(const uint32_t& data, Endianness endianness)
597 {
598  assert((m_addressSelect & 3) == 0);
599 
600  if (!LookupAddressDataBus())
601  return false;
602 
603  uint64_t paddr;
604  bool writable;
605  VirtualToPhysical(m_addressSelect, paddr, writable);
606 
608  return m_addressDataBus->WriteData(data, endianness);
609 }
610 
611 
612 bool CPUComponent::WriteData(const uint64_t& data, Endianness endianness)
613 {
614  assert((m_addressSelect & 7) == 0);
615 
616  if (!LookupAddressDataBus())
617  return false;
618 
619  uint64_t paddr;
620  bool writable;
621  VirtualToPhysical(m_addressSelect, paddr, writable);
622 
624  return m_addressDataBus->WriteData(data, endianness);
625 }
626 
627 
628 /*****************************************************************************/
629 
630 
631 #ifdef WITHUNITTESTS
632 
633 #include "ComponentFactory.h"
634 
635 static void Test_CPUComponent_HasAttributes()
636 {
637  UnitTest::Assert("the CPUComponent should not have attributes",
638  !ComponentFactory::HasAttribute("cpu", "description"));
639 }
640 
641 static void Test_CPUComponent_Create()
642 {
643  // CPUComponent is abstract, and should not be possible to create.
646  UnitTest::Assert("component was created?", cpu.IsNULL());
647 }
648 
649 static void Test_CPUComponent_PreRunCheck()
650 {
651  GXemul gxemul;
652 
653  // Attempting to run a cpu with nothing connected to it should FAIL!
654  gxemul.GetCommandInterpreter().RunCommand("add m88k_cpu");
655  UnitTest::Assert("preruncheck should fail",
656  gxemul.GetRootComponent()->PreRunCheck(&gxemul) == false);
657 
658  // Running a CPU with RAM should however succeed:
659  gxemul.GetCommandInterpreter().RunCommand("add ram cpu0");
660  UnitTest::Assert("preruncheck should succeed",
661  gxemul.GetRootComponent()->PreRunCheck(&gxemul) == true);
662 }
663 
664 static void Test_CPUComponent_Methods_Reexecutableness()
665 {
668 
669  UnitTest::Assert("dump method SHOULD be re-executable"
670  " without args", cpu->MethodMayBeReexecutedWithoutArgs("dump") == true);
671 
672  UnitTest::Assert("registers method should NOT be re-executable"
673  " without args", cpu->MethodMayBeReexecutedWithoutArgs("registers") == false);
674 
675  UnitTest::Assert("unassemble method SHOULD be re-executable"
676  " without args", cpu->MethodMayBeReexecutedWithoutArgs("unassemble") == true);
677 
678  UnitTest::Assert("nonexistant method should NOT be re-executable"
679  " without args", cpu->MethodMayBeReexecutedWithoutArgs("nonexistant") == false);
680 }
681 
683 {
684  UNITTEST(Test_CPUComponent_HasAttributes);
685  UNITTEST(Test_CPUComponent_Create);
686  UNITTEST(Test_CPUComponent_PreRunCheck);
687  UNITTEST(Test_CPUComponent_Methods_Reexecutableness);
688 }
689 
690 #endif
691 
Component::PreRunCheck
bool PreRunCheck(GXemul *gxemul)
Checks the state of this component and all its children, before starting execution.
Definition: Component.cc:298
Component::GetChildren
Components & GetChildren()
Gets pointers to child components.
Definition: Component.cc:674
data
u_short data
Definition: siireg.h:79
Component::FlushCachedStateForComponent
virtual void FlushCachedStateForComponent()
Resets the cached state of this component.
Definition: Component.cc:327
CPUComponent::m_inDelaySlot
bool m_inDelaySlot
Definition: CPUComponent.h:219
AddressDataBus::ReadData
virtual bool ReadData(uint8_t &data, Endianness endianness=BigEndian)=0
Reads 8-bit data from the currently selected address.
CPUComponent::m_paused
bool m_paused
Definition: CPUComponent.h:195
CPUComponent::m_showFunctionTraceReturn
bool m_showFunctionTraceReturn
Definition: CPUComponent.h:214
refcount_ptr::IsNULL
bool IsNULL() const
Checks whether or not an object is referenced by the reference counted pointer.
Definition: refcount_ptr.h:218
Component::AddVariable
bool AddVariable(const string &name, T *variablePointer)
Adds a state variable of type T to the Component.
Definition: Component.h:563
CPUComponent::GetSymbolRegistry
SymbolRegistry & GetSymbolRegistry()
Gets a reference to the CPU's symbol registry.
Definition: CPUComponent.h:63
ComponentFactory.h
GXemul::IsInterrupting
bool IsInterrupting() const
Returns whether or not the current emulation is being interrupted.
Definition: GXemul.h:178
SymbolRegistry::Clear
void Clear()
Clears the registry.
Definition: SymbolRegistry.cc:36
GXemul
The main emulator class.
Definition: GXemul.h:55
CPUComponent::MethodMayBeReexecutedWithoutArgs
virtual bool MethodMayBeReexecutedWithoutArgs(const string &methodName) const
Returns whether a method name may be re-executed without args.
Definition: CPUComponent.cc:190
CPUComponent::Unassemble
uint64_t Unassemble(int nRows, bool indicatePC, uint64_t vaddr, ostream &output)
Definition: CPUComponent.cc:325
CPUComponent::m_functionCallTraceDepth
int32_t m_functionCallTraceDepth
Definition: CPUComponent.h:215
GXemul::GetCommandInterpreter
CommandInterpreter & GetCommandInterpreter()
Gets a reference to the CommandInterpreter.
Definition: GXemul.cc:623
CPUComponent::AsAddressDataBus
virtual AddressDataBus * AsAddressDataBus()
Returns the component's AddressDataBus interface, if any.
Definition: CPUComponent.cc:414
LittleEndian
@ LittleEndian
Definition: misc.h:159
CPUComponent::PreRunCheckForComponent
virtual bool PreRunCheckForComponent(GXemul *gxemul)
Checks the state of this component, before starting execution.
Definition: CPUComponent.cc:428
CPUComponent::FunctionTraceArgumentCount
virtual int FunctionTraceArgumentCount()
Definition: CPUComponent.h:181
CPUComponent::m_frequency
double m_frequency
Definition: CPUComponent.h:194
CPUComponent::m_cpuArchitecture
string m_cpuArchitecture
Definition: CPUComponent.h:198
refcount_ptr< Component >
CPUComponent::m_addressDataBus
AddressDataBus * m_addressDataBus
Definition: CPUComponent.h:226
UNITTESTS
#define UNITTESTS(class)
Helper for unit test case execution.
Definition: UnitTest.h:184
CPUComponent::DisassembleInstruction
virtual size_t DisassembleInstruction(uint64_t vaddr, vector< string > &result)=0
Disassembles an instruction into readable strings.
Component::GetUI
UI * GetUI()
Gets an UI reference for outputting debug messages during runtime.
Definition: Component.cc:583
CPUComponent::FunctionTraceReturnImpl
virtual bool FunctionTraceReturnImpl(int64_t &retval)
Definition: CPUComponent.h:183
GXemul::GetRootComponent
refcount_ptr< Component > GetRootComponent()
Gets a pointer to the root configuration component.
Definition: GXemul.cc:659
CPUComponent::FlushCachedStateForComponent
virtual void FlushCachedStateForComponent()
Resets the cached state of this component.
Definition: CPUComponent.cc:420
CPUComponent::VirtualToPhysical
virtual bool VirtualToPhysical(uint64_t vaddr, uint64_t &paddr, bool &writable)=0
Virtual to physical address translation (MMU).
UNITTEST
#define UNITTEST(functionname)
Helper for unit test case execution.
Definition: UnitTest.h:217
Component::GetMethodNames
virtual void GetMethodNames(vector< string > &names) const
Retrieves a component's implemented method names.
Definition: Component.cc:393
CPUComponent::GetMethodNames
virtual void GetMethodNames(vector< string > &names) const
Retrieves a component's implemented method names.
Definition: CPUComponent.cc:178
UnitTest::Assert
static void Assert(const string &strFailMessage, bool condition)
Asserts that a boolean condition is correct.
Definition: UnitTest.cc:40
AddressDataBus::WriteData
virtual bool WriteData(const uint8_t &data, Endianness endianness=BigEndian)=0
Writes 8-bit data to the currently selected address.
Component::ExecuteMethod
virtual void ExecuteMethod(GXemul *gxemul, const string &methodName, const vector< string > &arguments)
Executes a method on the component.
Definition: Component.cc:406
CPUComponent::m_pc
uint64_t m_pc
Definition: CPUComponent.h:202
CPUComponent::m_hasUsedUnassemble
bool m_hasUsedUnassemble
Definition: CPUComponent.h:207
CPUComponent::m_lastDumpAddr
uint64_t m_lastDumpAddr
Definition: CPUComponent.h:205
UI::ShowDebugMessage
virtual void ShowDebugMessage(const string &msg)=0
Shows a debug message.
Endianness
Endianness
Definition: misc.h:157
CPUComponent::FunctionTraceCall
bool FunctionTraceCall()
Definition: CPUComponent.cc:99
CPUComponent::GetCurrentFrequency
virtual double GetCurrentFrequency() const
Returns the current frequency (in Hz) that the component runs at.
Definition: CPUComponent.cc:70
SymbolRegistry::LookupAddress
string LookupAddress(uint64_t vaddr, bool allowOffset) const
Looks up an address.
Definition: SymbolRegistry.cc:48
ComponentFactory::CreateComponent
static refcount_ptr< Component > CreateComponent(const string &componentNameAndOptionalArgs, GXemul *gxemul=NULL)
Creates a component given a short component name.
Definition: ComponentFactory.cc:87
CPUComponent::m_nrOfTracedFunctionCalls
int64_t m_nrOfTracedFunctionCalls
Definition: CPUComponent.h:216
AddressDataBus::AddressSelect
virtual void AddressSelect(uint64_t address)=0
Place an address on the bus.
Component::GenerateShortestPossiblePath
string GenerateShortestPossiblePath() const
Generates a short string representation of the path to the Component.
Definition: Component.cc:721
Component::GetParent
Component * GetParent()
Gets this component's parent component, if any.
Definition: Component.cc:381
CPUComponent::m_isBigEndian
bool m_isBigEndian
Definition: CPUComponent.h:210
CPUComponent::FunctionTraceReturn
bool FunctionTraceReturn()
Definition: CPUComponent.cc:143
CPUComponent::CPUComponent
CPUComponent(const string &className, const string &cpuKind)
Constructs a CPUComponent.
Definition: CPUComponent.cc:36
CommandInterpreter::RunCommand
bool RunCommand(const string &command, bool *pSuccess=NULL)
Runs a command, given as a string.
Definition: CommandInterpreter.cc:958
CPUComponent::WriteData
virtual bool WriteData(const uint8_t &data, Endianness endianness)
Writes 8-bit data to the currently selected address.
Definition: CPUComponent.cc:566
CPUComponent.h
CPUComponent::m_addressSelect
uint64_t m_addressSelect
Definition: CPUComponent.h:227
symbol
Definition: symbol.h:37
GXemul::GetUI
UI * GetUI()
Gets a pointer to the GXemul instance' active UI.
Definition: GXemul.cc:653
Component::MethodMayBeReexecutedWithoutArgs
virtual bool MethodMayBeReexecutedWithoutArgs(const string &methodName) const
Returns whether a method name may be re-executed without args.
Definition: Component.cc:399
CPUComponent::FunctionTraceArgument
virtual int64_t FunctionTraceArgument(int n)
Definition: CPUComponent.h:182
Component::ResetState
virtual void ResetState()
Resets the state variables of this component.
Definition: Component.cc:291
Component
A Component is a node in the configuration tree that makes up an emulation setup.
Definition: Component.h:64
CPUComponent::VirtualAddressAsString
virtual string VirtualAddressAsString(uint64_t vaddr)
Format a virtual address as a displayable string.
Definition: CPUComponent.h:155
CPUComponent::ReadData
virtual bool ReadData(uint8_t &data, Endianness endianness)
Reads 8-bit data from the currently selected address.
Definition: CPUComponent.cc:504
Components
vector< refcount_ptr< Component > > Components
Definition: Component.h:43
CPUComponent::m_lastUnassembleVaddr
uint64_t m_lastUnassembleVaddr
Definition: CPUComponent.h:206
ComponentFactory::HasAttribute
static bool HasAttribute(const string &name, const string &attributeName)
Checks if a component has a specific attribute.
Definition: ComponentFactory.cc:205
CPUComponent::ExecuteMethod
virtual void ExecuteMethod(GXemul *gxemul, const string &methodName, const vector< string > &arguments)
Executes a method on the component.
Definition: CPUComponent.cc:203
CPUComponent::AsCPUComponent
virtual CPUComponent * AsCPUComponent()
Returns the component's CPUComponent interface.
Definition: CPUComponent.cc:76
cpu
Definition: cpu.h:326
AddressDataBus
An interface for implementing components that read/write data via an address bus.
Definition: AddressDataBus.h:45
CPUComponent::PCtoInstructionAddress
virtual uint64_t PCtoInstructionAddress(uint64_t pc)
Convert PC value to instuction address.
Definition: CPUComponent.h:171
CPUComponent::m_showFunctionTraceCall
bool m_showFunctionTraceCall
Definition: CPUComponent.h:213
CPUComponent::ShowRegisters
virtual void ShowRegisters(GXemul *gxemul, const vector< string > &arguments) const
Definition: CPUComponent.cc:491
CPUComponent::ResetState
virtual void ResetState()
Resets the state variables of this component.
Definition: CPUComponent.cc:82
AddressDataBus.h
BigEndian
@ BigEndian
Definition: misc.h:158
Component::AsAddressDataBus
virtual AddressDataBus * AsAddressDataBus()
Returns the component's AddressDataBus interface, if any.
Definition: Component.cc:367
CPUComponent::m_delaySlotTarget
uint64_t m_delaySlotTarget
Definition: CPUComponent.h:220
CPUComponent::m_exceptionOrAbortInDelaySlot
bool m_exceptionOrAbortInDelaySlot
Definition: CPUComponent.h:228
CPUComponent::AddressSelect
virtual void AddressSelect(uint64_t address)
Place an address on the bus.
Definition: CPUComponent.cc:498
GXemul.h
Component::GetRunningGXemulInstance
GXemul * GetRunningGXemulInstance()
Returns a reference to the current GXemul instance.
Definition: Component.cc:569
CPUComponent
A base-class for processors Component implementations.
Definition: CPUComponent.h:47

Generated on Tue Aug 25 2020 19:25:06 for GXemul by doxygen 1.8.18