CPUComponent.cc Source File

Back to the index.

CPUComponent.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2010 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)
133  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  vector< vector<string> > outputRows;
328 
329  for (int i=0; i<nRows; i++) {
330  outputRows.push_back(vector<string>());
331 
332  // TODO: GENERALIZE! Some archs will have longer
333  // instructions, or unaligned, or over page boundaries!
334  size_t maxLen = sizeof(uint32_t);
335 maxLen += sizeof(uint32_t); // i960 experimentation hack
336  unsigned char instruction[maxLen];
337 
338  bool readOk = true;
339  for (size_t k=0; k<maxLen; ++k) {
340  AddressSelect(vaddr + k);
341  readOk &= ReadData(instruction[k], m_isBigEndian? BigEndian : LittleEndian);
342  }
343 
344  string symbol = GetSymbolRegistry().LookupAddress(vaddr, false);
345  if (symbol != "") {
346  outputRows[outputRows.size()-1].push_back("<" + symbol + ">");
347  outputRows.push_back(vector<string>());
348  }
349 
350  stringstream ss;
351  ss.flags(std::ios::hex | std::ios::showbase);
352  ss << VirtualAddressAsString(vaddr);
353 
354  if (indicatePC && PCtoInstructionAddress(m_pc) == vaddr)
355  ss << " <- ";
356  else
357  ss << " ";
358 
359  outputRows[outputRows.size()-1].push_back(ss.str());
360 
361  if (!readOk) {
362  stringstream ss2;
363  ss2 << "\tmemory could not be read";
364  if (m_addressDataBus == NULL)
365  ss2 << "; no address/data bus connected to the CPU";
366  ss2 << "\n";
367 
368  outputRows[outputRows.size()-1].push_back(ss2.str());
369  break;
370  } else {
371  vector<string> result;
372 
373  size_t len = DisassembleInstruction(vaddr,
374  maxLen, instruction, result);
375  vaddr += len;
376 
377  for (size_t j=0; j<result.size(); ++j)
378  outputRows[outputRows.size()-1].push_back(result[j]);
379  }
380  }
381 
382  // Output the rows with equal-width columns:
383  vector<size_t> columnWidths;
384  size_t row;
385  for (row=0; row<outputRows.size(); ++row) {
386  size_t nColumns = outputRows[row].size();
387 
388  // Skip lines such as "<symbol>" on empty lines, when
389  // calculating column width.
390  if (nColumns <= 1)
391  continue;
392 
393  if (columnWidths.size() < nColumns)
394  columnWidths.resize(nColumns);
395 
396  for (size_t col=0; col<nColumns; ++col) {
397  const string& s = outputRows[row][col];
398  if (s.length() > columnWidths[col])
399  columnWidths[col] = s.length();
400  }
401  }
402 
403  for (row=0; row<outputRows.size(); ++row) {
404  const vector<string>& rowVector = outputRows[row];
405 
406  for (size_t i=0; i<rowVector.size(); ++i) {
407  // Note: i>=2 because:
408  // index 0 is the first column, no spaces before that one,
409  // but also: index 1 because the spaces after the vaddr
410  // is a special case ("<-" pc indicator).
411  if (i >= 2)
412  output << " ";
413 
414  size_t len = rowVector[i].length();
415  output << rowVector[i];
416 
417  int nspaces = columnWidths[i] - len;
418  for (int j=0; j<nspaces; ++j)
419  output << " ";
420  }
421 
422  output << "\n";
423  }
424 
425  return vaddr;
426 }
427 
428 
430 {
431  return this;
432 }
433 
434 
436 {
437  m_addressDataBus = NULL;
438 
440 }
441 
442 
444 {
445  // If AddressDataBus lookup fails, then the CPU fails.
446  if (!LookupAddressDataBus(gxemul)) {
447  gxemul->GetUI()->ShowDebugMessage(this, "this CPU"
448  " has neither any child components nor any parent component"
449  " that can act as address/data bus, so there is no place"
450  " to read instructions from\n");
451  return false;
452  }
453 
454  return true;
455 }
456 
457 
458 bool CPUComponent::LookupAddressDataBus(GXemul* gxemul)
459 {
460  if (m_addressDataBus != NULL)
461  return true;
462 
463  // Find a suitable address data bus.
464  AddressDataBus *bus = NULL;
465 
466  // 1) A direct first-level decendant of the CPU is probably a
467  // cache. Use this if it exists.
468  // If there are multiple AddressDataBus capable children,
469  // print a debug warning, and just choose any of the children
470  // (the last one).
471  Components& children = GetChildren();
472  Component* choosenChild = NULL;
473  bool multipleChildBussesFound = false;
474  for (size_t i=0; i<children.size(); ++i) {
475  AddressDataBus *childBus = children[i]->AsAddressDataBus();
476  if (childBus != NULL) {
477  if (bus != NULL)
478  multipleChildBussesFound = true;
479  bus = childBus;
480  choosenChild = children[i];
481  }
482  }
483 
484  if (multipleChildBussesFound && gxemul != NULL)
485  gxemul->GetUI()->ShowDebugMessage(this, "warning: this CPU has "
486  "multiple child components that can act as address/data busses; "
487  "using " + choosenChild->GenerateShortestPossiblePath() + "\n");
488 
489  // 2) If no cache exists, go to a parent bus (usually a mainbus).
490  if (bus == NULL) {
491  refcount_ptr<Component> component = GetParent();
492  while (!component.IsNULL()) {
493  bus = component->AsAddressDataBus();
494  if (bus != NULL)
495  break;
496  component = component->GetParent();
497  }
498  }
499 
500  m_addressDataBus = bus;
501 
502  return m_addressDataBus != NULL;
503 }
504 
505 
506 void CPUComponent::ShowRegisters(GXemul* gxemul, const vector<string>& arguments) const
507 {
508  gxemul->GetUI()->ShowDebugMessage("The registers method has not yet "
509  "been implemented for this CPU type. TODO.\n");
510 }
511 
512 
513 void CPUComponent::AddressSelect(uint64_t address)
514 {
515  m_addressSelect = address;
516 }
517 
518 
519 bool CPUComponent::ReadData(uint8_t& data, Endianness endianness)
520 {
521  if (!LookupAddressDataBus())
522  return false;
523 
524  uint64_t paddr;
525  bool writable;
526  VirtualToPhysical(m_addressSelect, paddr, writable);
527 
529  return m_addressDataBus->ReadData(data, endianness);
530 }
531 
532 
533 bool CPUComponent::ReadData(uint16_t& data, Endianness endianness)
534 {
535  assert((m_addressSelect & 1) == 0);
536 
537  if (!LookupAddressDataBus())
538  return false;
539 
540  uint64_t paddr;
541  bool writable;
542  VirtualToPhysical(m_addressSelect, paddr, writable);
543 
545  return m_addressDataBus->ReadData(data, endianness);
546 }
547 
548 
549 bool CPUComponent::ReadData(uint32_t& data, Endianness endianness)
550 {
551  assert((m_addressSelect & 3) == 0);
552 
553  if (!LookupAddressDataBus())
554  return false;
555 
556  uint64_t paddr;
557  bool writable;
558  VirtualToPhysical(m_addressSelect, paddr, writable);
559 
561  return m_addressDataBus->ReadData(data, endianness);
562 }
563 
564 
565 bool CPUComponent::ReadData(uint64_t& data, Endianness endianness)
566 {
567  assert((m_addressSelect & 7) == 0);
568 
569  if (!LookupAddressDataBus())
570  return false;
571 
572  uint64_t paddr;
573  bool writable;
574  VirtualToPhysical(m_addressSelect, paddr, writable);
575 
577  return m_addressDataBus->ReadData(data, endianness);
578 }
579 
580 
581 bool CPUComponent::WriteData(const uint8_t& data, Endianness endianness)
582 {
583  if (!LookupAddressDataBus())
584  return false;
585 
586  uint64_t paddr;
587  bool writable;
588  VirtualToPhysical(m_addressSelect, paddr, writable);
589 
591  return m_addressDataBus->WriteData(data, endianness);
592 }
593 
594 
595 bool CPUComponent::WriteData(const uint16_t& data, Endianness endianness)
596 {
597  assert((m_addressSelect & 1) == 0);
598 
599  if (!LookupAddressDataBus())
600  return false;
601 
602  uint64_t paddr;
603  bool writable;
604  VirtualToPhysical(m_addressSelect, paddr, writable);
605 
607  return m_addressDataBus->WriteData(data, endianness);
608 }
609 
610 
611 bool CPUComponent::WriteData(const uint32_t& data, Endianness endianness)
612 {
613  assert((m_addressSelect & 3) == 0);
614 
615  if (!LookupAddressDataBus())
616  return false;
617 
618  uint64_t paddr;
619  bool writable;
620  VirtualToPhysical(m_addressSelect, paddr, writable);
621 
623  return m_addressDataBus->WriteData(data, endianness);
624 }
625 
626 
627 bool CPUComponent::WriteData(const uint64_t& data, Endianness endianness)
628 {
629  assert((m_addressSelect & 7) == 0);
630 
631  if (!LookupAddressDataBus())
632  return false;
633 
634  uint64_t paddr;
635  bool writable;
636  VirtualToPhysical(m_addressSelect, paddr, writable);
637 
639  return m_addressDataBus->WriteData(data, endianness);
640 }
641 
642 
643 /*****************************************************************************/
644 
645 
646 #ifdef WITHUNITTESTS
647 
648 #include "ComponentFactory.h"
649 
650 static void Test_CPUComponent_IsStable()
651 {
652  UnitTest::Assert("the CPUComponent should not have attributes",
653  !ComponentFactory::HasAttribute("cpu", "stable"));
654 }
655 
656 static void Test_CPUComponent_Create()
657 {
658  // CPUComponent is abstract, and should not be possible to create.
661  UnitTest::Assert("component was created?", cpu.IsNULL());
662 }
663 
664 static void Test_CPUComponent_PreRunCheck()
665 {
666  GXemul gxemul;
667 
668  // Attempting to run a cpu with nothing connected to it should FAIL!
669  gxemul.GetCommandInterpreter().RunCommand("add mips_cpu");
670  UnitTest::Assert("preruncheck should fail",
671  gxemul.GetRootComponent()->PreRunCheck(&gxemul) == false);
672 
673  // Running a CPU with RAM should however succeed:
674  gxemul.GetCommandInterpreter().RunCommand("add ram cpu0");
675  UnitTest::Assert("preruncheck should succeed",
676  gxemul.GetRootComponent()->PreRunCheck(&gxemul) == true);
677 }
678 
679 static void Test_CPUComponent_Methods_Reexecutableness()
680 {
683 
684  UnitTest::Assert("dump method SHOULD be re-executable"
685  " without args", cpu->MethodMayBeReexecutedWithoutArgs("dump") == true);
686 
687  UnitTest::Assert("registers method should NOT be re-executable"
688  " without args", cpu->MethodMayBeReexecutedWithoutArgs("registers") == false);
689 
690  UnitTest::Assert("unassemble method SHOULD be re-executable"
691  " without args", cpu->MethodMayBeReexecutedWithoutArgs("unassemble") == true);
692 
693  UnitTest::Assert("nonexistant method should NOT be re-executable"
694  " without args", cpu->MethodMayBeReexecutedWithoutArgs("nonexistant") == false);
695 }
696 
698 {
699  UNITTEST(Test_CPUComponent_IsStable);
700  UNITTEST(Test_CPUComponent_Create);
701  UNITTEST(Test_CPUComponent_PreRunCheck);
702  UNITTEST(Test_CPUComponent_Methods_Reexecutableness);
703 }
704 
705 #endif
706 
double m_frequency
Definition: CPUComponent.h:197
virtual void ShowDebugMessage(const string &msg)=0
Shows a debug message.
Component * GetParent()
Gets this component&#39;s parent component, if any.
Definition: Component.cc:381
virtual bool MethodMayBeReexecutedWithoutArgs(const string &methodName) const
Returns whether a method name may be re-executed without args.
Definition: Component.cc:399
static refcount_ptr< Component > CreateComponent(const string &componentNameAndOptionalArgs, GXemul *gxemul=NULL)
Creates a component given a short component name.
uint64_t m_addressSelect
Definition: CPUComponent.h:230
uint64_t m_delaySlotTarget
Definition: CPUComponent.h:223
virtual bool WriteData(const uint8_t &data, Endianness endianness)
Writes 8-bit data to the currently selected address.
bool RunCommand(const string &command, bool *pSuccess=NULL)
Runs a command, given as a string.
virtual void ExecuteMethod(GXemul *gxemul, const string &methodName, const vector< string > &arguments)
Executes a method on the component.
Definition: Component.cc:406
bool AddVariable(const string &name, T *variablePointer)
Adds a state variable of type T to the Component.
Definition: Component.h:563
UI * GetUI()
Gets an UI reference for outputting debug messages during runtime.
Definition: Component.cc:583
virtual bool WriteData(const uint8_t &data, Endianness endianness=BigEndian)=0
Writes 8-bit data to the currently selected address.
virtual int64_t FunctionTraceArgument(int n)
Definition: CPUComponent.h:185
Endianness
Definition: misc.h:156
Components & GetChildren()
Gets pointers to child components.
Definition: Component.cc:674
virtual uint64_t PCtoInstructionAddress(uint64_t pc)
Convert PC value to instuction address.
Definition: CPUComponent.h:174
bool m_inDelaySlot
Definition: CPUComponent.h:222
string GenerateShortestPossiblePath() const
Generates a short string representation of the path to the Component.
Definition: Component.cc:721
uint64_t m_lastUnassembleVaddr
Definition: CPUComponent.h:209
bool FunctionTraceCall()
Definition: CPUComponent.cc:99
An interface for implementing components that read/write data via an address bus. ...
int64_t m_nrOfTracedFunctionCalls
Definition: CPUComponent.h:219
virtual void ExecuteMethod(GXemul *gxemul, const string &methodName, const vector< string > &arguments)
Executes a method on the component.
The main emulator class.
Definition: GXemul.h:54
int32_t m_functionCallTraceDepth
Definition: CPUComponent.h:218
#define UNITTESTS(class)
Helper for unit test case execution.
Definition: UnitTest.h:184
CommandInterpreter & GetCommandInterpreter()
Gets a reference to the CommandInterpreter.
Definition: GXemul.cc:631
bool FunctionTraceReturn()
bool m_showFunctionTraceCall
Definition: CPUComponent.h:216
bool m_exceptionOrAbortInDelaySlot
Definition: CPUComponent.h:231
string LookupAddress(uint64_t vaddr, bool allowOffset) const
Looks up an address.
virtual bool PreRunCheckForComponent(GXemul *gxemul)
Checks the state of this component, before starting execution.
virtual CPUComponent * AsCPUComponent()
Returns the component&#39;s CPUComponent interface.
Definition: CPUComponent.cc:76
u_short data
Definition: siireg.h:79
static bool HasAttribute(const string &name, const string &attributeName)
Checks if a component has a specific attribute.
bool m_isBigEndian
Definition: CPUComponent.h:213
virtual void GetMethodNames(vector< string > &names) const
Retrieves a component&#39;s implemented method names.
Definition: Component.cc:393
void Clear()
Clears the registry.
virtual void AddressSelect(uint64_t address)
Place an address on the bus.
bool m_hasUsedUnassemble
Definition: CPUComponent.h:210
virtual void GetMethodNames(vector< string > &names) const
Retrieves a component&#39;s implemented method names.
virtual bool ReadData(uint8_t &data, Endianness endianness=BigEndian)=0
Reads 8-bit data from the currently selected address.
bool m_showFunctionTraceReturn
Definition: CPUComponent.h:217
A Component is a node in the configuration tree that makes up an emulation setup. ...
Definition: Component.h:62
bool PreRunCheck(GXemul *gxemul)
Checks the state of this component and all its children, before starting execution.
Definition: Component.cc:298
string m_cpuArchitecture
Definition: CPUComponent.h:201
uint64_t m_pc
Definition: CPUComponent.h:205
SymbolRegistry & GetSymbolRegistry()
Gets a reference to the CPU&#39;s symbol registry.
Definition: CPUComponent.h:63
virtual bool MethodMayBeReexecutedWithoutArgs(const string &methodName) const
Returns whether a method name may be re-executed without args.
Definition: cpu.h:326
bool IsInterrupting() const
Returns whether or not the current emulation is being interrupted.
Definition: GXemul.h:178
virtual void ShowRegisters(GXemul *gxemul, const vector< string > &arguments) const
virtual int FunctionTraceArgumentCount()
Definition: CPUComponent.h:184
virtual double GetCurrentFrequency() const
Returns the current frequency (in Hz) that the component runs at.
Definition: CPUComponent.cc:70
A base-class for processors Component implementations.
Definition: CPUComponent.h:43
virtual size_t DisassembleInstruction(uint64_t vaddr, size_t maxLen, unsigned char *instruction, vector< string > &result)=0
Disassembles an instruction into readable strings.
static void Assert(const string &strFailMessage, bool condition)
Asserts that a boolean condition is correct.
Definition: UnitTest.cc:40
virtual void AddressSelect(uint64_t address)=0
Place an address on the bus.
virtual void ResetState()
Resets the state variables of this component.
Definition: CPUComponent.cc:82
virtual void FlushCachedStateForComponent()
Resets the cached state of this component.
Definition: Component.cc:327
AddressDataBus * m_addressDataBus
Definition: CPUComponent.h:229
refcount_ptr< Component > GetRootComponent()
Gets a pointer to the root configuration component.
Definition: GXemul.cc:667
virtual AddressDataBus * AsAddressDataBus()
Returns the component&#39;s AddressDataBus interface, if any.
Definition: Component.cc:367
Definition: symbol.h:37
CPUComponent(const string &className, const string &cpuKind)
Constructs a CPUComponent.
Definition: CPUComponent.cc:36
virtual bool VirtualToPhysical(uint64_t vaddr, uint64_t &paddr, bool &writable)=0
Virtual to physical address translation (MMU).
virtual bool FunctionTraceReturnImpl(int64_t &retval)
Definition: CPUComponent.h:186
UI * GetUI()
Gets a pointer to the GXemul instance&#39; active UI.
Definition: GXemul.cc:661
uint64_t Unassemble(int nRows, bool indicatePC, uint64_t vaddr, ostream &output)
virtual void FlushCachedStateForComponent()
Resets the cached state of this component.
vector< refcount_ptr< Component > > Components
Definition: Component.h:43
virtual AddressDataBus * AsAddressDataBus()
Returns the component&#39;s AddressDataBus interface, if any.
virtual bool ReadData(uint8_t &data, Endianness endianness)
Reads 8-bit data from the currently selected address.
virtual void ResetState()
Resets the state variables of this component.
Definition: Component.cc:291
GXemul * GetRunningGXemulInstance()
Returns a reference to the current GXemul instance.
Definition: Component.cc:569
uint64_t m_lastDumpAddr
Definition: CPUComponent.h:208
#define UNITTEST(functionname)
Helper for unit test case execution.
Definition: UnitTest.h:217
bool IsNULL() const
Checks whether or not an object is referenced by the reference counted pointer.
Definition: refcount_ptr.h:216
virtual string VirtualAddressAsString(uint64_t vaddr)
Format a virtual address as a displayable string.
Definition: CPUComponent.h:158

Generated on Fri Dec 7 2018 19:52:23 for GXemul by doxygen 1.8.13