TestM88KMachine.cc Source File

Back to the index.

TestM88KMachine.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"] = "88100";
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", "\"testm88k\"");
51 
52 
53  refcount_ptr<Component> mainbus =
55  if (mainbus.IsNULL())
56  return NULL;
57 
58  machine->AddChild(mainbus);
59 
60 
61  int ncpus;
62  stringstream tmpss3;
63  tmpss3 << settings["ncpus"];
64  tmpss3 >> ncpus;
65  if (ncpus < 1) {
66  if (args.gxemul != NULL)
67  args.gxemul->GetUI()->ShowDebugMessage("nr of cpus must be more than 0.");
68  return NULL;
69  }
70 
71  for (int i=0; i<ncpus; ++i) {
73  ComponentFactory::CreateComponent("m88k_cpu(r31=0xff0,model=" + settings["cpu"] + ")");
74  if (cpu.IsNULL())
75  return NULL;
76 
77  if (i > 0)
78  cpu->SetVariableValue("paused", "true");
79 
80  mainbus->AddChild(cpu);
81  }
82 
83 
85  if (ram.IsNULL())
86  return NULL;
87 
88  ram->SetVariableValue("memoryMappedSize", settings["ram"]);
89  mainbus->AddChild(ram);
90 
91 
93  if (fb_videoram.IsNULL())
94  return NULL;
95 
96  fb_videoram->SetVariableValue("name", "\"fb_videoram0\"");
97  fb_videoram->SetVariableValue("memoryMappedBase", "0x12000000");
98  fb_videoram->SetVariableValue("memoryMappedSize", "0xf00000");
99  mainbus->AddChild(fb_videoram);
100 
101 
103  if (rom.IsNULL())
104  return NULL;
105 
106  rom->SetVariableValue("name", "\"rom0\"");
107  rom->SetVariableValue("memoryMappedBase", "0xff800000");
108  rom->SetVariableValue("memoryMappedSize", "0x400000");
109  rom->SetVariableValue("writeProtect", "true");
110  mainbus->AddChild(rom);
111 
112 
113  return machine;
114 }
115 
116 
117 string TestM88KMachine::GetAttribute(const string& attributeName)
118 {
119  if (attributeName == "template")
120  return "yes";
121 
122  if (attributeName == "machine")
123  return "yes";
124 
125  if (attributeName == "stable")
126  return "yes";
127 
128  if (attributeName == "description")
129  return "Experimental M88K machine.";
130 
131  return "";
132 }
133 

Generated on Sun Aug 17 2014 10:50:49 for GXemul by doxygen 1.8.3.1