SGI_IP30_Machine.cc Source File

Back to the index.

SGI_IP30_Machine.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2009-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"] = "R10000"; // or R12000 or R14000
38  settings["ram"] = "0x8000000";
39  settings["ncpus"] = "1";
40 
41  if (!ComponentFactory::GetCreationArgOverrides(settings, args))
42  return NULL;
43 
46  if (machine.IsNULL())
47  return NULL;
48 
49  machine->SetVariableValue("template", "\"sgi_ip30\"");
50 
51  refcount_ptr<Component> mainbus =
53  if (mainbus.IsNULL())
54  return NULL;
55 
56  machine->AddChild(mainbus);
57 
59  if (ram.IsNULL())
60  return NULL;
61 
62  ram->SetVariableValue("memoryMappedBase", "0x20000000");
63  ram->SetVariableValue("memoryMappedSize", settings["ram"]);
64  mainbus->AddChild(ram);
65 
67  if (rom.IsNULL())
68  return NULL;
69 
70  stringstream tmpss2;
71  tmpss2 << 4 * 1048576; // TODO: Actual ROM size
72  rom->SetVariableValue("name", "\"rom0\"");
73  rom->SetVariableValue("memoryMappedBase", "0x1fc00000");
74  rom->SetVariableValue("memoryMappedSize", tmpss2.str());
75  rom->SetVariableValue("writeProtect", "true");
76  mainbus->AddChild(rom);
77 
78  int ncpus;
79  stringstream tmpss3;
80  tmpss3 << settings["ncpus"];
81  tmpss3 >> ncpus;
82  if (ncpus < 1) {
83  if (args.gxemul != NULL)
84  args.gxemul->GetUI()->ShowDebugMessage("nr of cpus must be more than 0.");
85  return NULL;
86  }
87 
88  for (int i=0; i<ncpus; ++i) {
90  ComponentFactory::CreateComponent("mips_cpu(model=" + settings["cpu"] + ")");
91  if (cpu.IsNULL())
92  return NULL;
93 
94  if (i > 0)
95  cpu->SetVariableValue("paused", "true");
96 
97  mainbus->AddChild(cpu);
98  }
99 
100  return machine;
101 }
102 
103 
104 string SGI_IP30_Machine::GetAttribute(const string& attributeName)
105 {
106  if (attributeName == "template")
107  return "yes";
108 
109  if (attributeName == "machine")
110  return "yes";
111 
112  // if (attributeName == "stable")
113  // return "yes";
114 
115  if (attributeName == "comments")
116  return "For experiments with <a href=\"http://www.netbsd.org/ports/sgimips/\">NetBSD/sgimips</a>, and possibly"
117  " also Linux for SGI Octane in the future.";
118 
119  if (attributeName == "description")
120  return "SGI IP30 (Octane) machine.";
121 
122  return "";
123 }
124 
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
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.
static refcount_ptr< Component > Create(const ComponentCreateArgs &args)
Creates a "sgi_ip30" Component tree.
bool IsNULL() const
Checks whether or not an object is referenced by the reference counted pointer.
Definition: refcount_ptr.h:216

Generated on Sun Sep 30 2018 16:05:18 for GXemul by doxygen 1.8.13