TestMIPSMachine.cc Source File

Back to the index.

TestMIPSMachine.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 
29 #include "ComponentFactory.h"
30 #include "GXemul.h"
31 
32 
34 {
35  // Defaults:
37  settings["cpu"] = "5KE";
38  settings["ram"] = "0x2000000";
39  settings["ncpus"] = "1";
40 
41  if (!ComponentFactory::GetCreationArgOverrides(settings, args))
42  return NULL;
43 
44 
47  if (machine.IsNULL())
48  return NULL;
49 
50  machine->SetVariableValue("template", "\"testmips\"");
51 
52 
53  refcount_ptr<Component> mainbus =
55  if (mainbus.IsNULL())
56  return NULL;
57 
58  machine->AddChild(mainbus);
59 
60 
62  if (ram.IsNULL())
63  return NULL;
64 
65  ram->SetVariableValue("memoryMappedSize", settings["ram"]);
66  mainbus->AddChild(ram);
67 
68 
70  if (rom.IsNULL())
71  return NULL;
72 
73  stringstream tmpss2;
74  tmpss2 << 16 * 1048576;
75  rom->SetVariableValue("name", "\"rom0\"");
76  rom->SetVariableValue("memoryMappedBase", "0x1fc00000");
77  rom->SetVariableValue("memoryMappedSize", tmpss2.str());
78  rom->SetVariableValue("writeProtect", "true");
79  mainbus->AddChild(rom);
80 
81 
83  if (fb_videoram.IsNULL())
84  return NULL;
85 
86  fb_videoram->SetVariableValue("name", "\"fb_videoram0\"");
87  fb_videoram->SetVariableValue("memoryMappedBase", "0x12000000");
88  fb_videoram->SetVariableValue("memoryMappedSize", "0xf00000");
89  mainbus->AddChild(fb_videoram);
90 
91 
92  int ncpus;
93  stringstream tmpss3;
94  tmpss3 << settings["ncpus"];
95  tmpss3 >> ncpus;
96  if (ncpus < 1) {
97  if (args.gxemul != NULL)
98  args.gxemul->GetUI()->ShowDebugMessage("nr of cpus must be more than 0.");
99  return NULL;
100  }
101 
102  for (int i=0; i<ncpus; ++i) {
104  ComponentFactory::CreateComponent("mips_cpu(model=" + settings["cpu"] + ")");
105  if (cpu.IsNULL())
106  return NULL;
107 
108  if (i > 0)
109  cpu->SetVariableValue("paused", "true");
110 
111  mainbus->AddChild(cpu);
112  }
113 
114  return machine;
115 }
116 
117 
118 string TestMIPSMachine::GetAttribute(const string& attributeName)
119 {
120  if (attributeName == "template")
121  return "yes";
122 
123  if (attributeName == "machine")
124  return "yes";
125 
126  if (attributeName == "stable")
127  return "yes";
128 
129  if (attributeName == "description")
130  return "Experimental MIPS machine.";
131 
132  return "";
133 }
134 
virtual void ShowDebugMessage(const string &msg)=0
Shows a debug message.
static refcount_ptr< Component > CreateComponent(const string &componentNameAndOptionalArgs, GXemul *gxemul=NULL)
Creates a component given a short component name.
static string GetAttribute(const string &attributeName)
Gets a Component attribute value.
map< string, string > ComponentCreationSettings
Definition: Component.h:46
Definition: cpu.h:326
bool SetVariableValue(const string &name, const string &expression)
Sets a variable to a new value.
Definition: Component.cc:1030
static refcount_ptr< Component > Create(const ComponentCreateArgs &args)
Creates a "testmips" Component tree.
void AddChild(refcount_ptr< Component > childComponent, size_t insertPosition=(size_t) -1)
Adds a reference to a child component.
Definition: Component.cc:595
UI * GetUI()
Gets a pointer to the GXemul instance&#39; active UI.
Definition: GXemul.cc:661
static bool GetCreationArgOverrides(ComponentCreationSettings &settings, const ComponentCreateArgs &createArgs)
Get override arguments for component creation.
bool IsNULL() const
Checks whether or not an object is referenced by the reference counted pointer.
Definition: refcount_ptr.h:216

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