gem5  v20.1.0.0
cxx_manager.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 ARM Limited
3  * All rights reserved
4  *
5  * The license below extends only to copyright in the software and shall
6  * not be construed as granting a license to any other intellectual
7  * property including but not limited to intellectual property relating
8  * to a hardware implementation of the functionality of the software
9  * licensed hereunder. You may use the software subject to the license
10  * terms below provided that you ensure that this notice is replicated
11  * unmodified and in its entirety in all distributions of the software,
12  * modified or unmodified, in source code or in binary form.
13  *
14  * Redistribution and use in source and binary forms, with or without
15  * modification, are permitted provided that the following conditions are
16  * met: redistributions of source code must retain the above copyright
17  * notice, this list of conditions and the following disclaimer;
18  * redistributions in binary form must reproduce the above copyright
19  * notice, this list of conditions and the following disclaimer in the
20  * documentation and/or other materials provided with the distribution;
21  * neither the name of the copyright holders nor the names of its
22  * contributors may be used to endorse or promote products derived from
23  * this software without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  */
37 
38 #include "sim/cxx_manager.hh"
39 
40 #include <cstdlib>
41 #include <sstream>
42 
43 #include "base/str.hh"
44 #include "base/trace.hh"
45 #include "debug/CxxConfig.hh"
46 #include "sim/serialize.hh"
47 #include "sim/sim_object.hh"
48 
50  configFile(configFile_), flags(configFile_.getFlags()),
51  simObjectResolver(*this)
52 {
53 }
54 
56 CxxConfigManager::findObjectType(const std::string &object_name,
57  std::string &object_type)
58 {
59  if (!configFile.objectExists(object_name))
60  throw Exception(object_name, "Can't find sim object");
61 
62  if (!configFile.getParam(object_name, "type", object_type))
63  throw Exception(object_name, "Sim object has no 'type' field");
64 
65  if (cxx_config_directory.find(object_type) ==
67  {
68  throw Exception(object_name, csprintf(
69  "No sim object type %s is available", object_type));
70  }
71 
72  const CxxConfigDirectoryEntry *entry = cxx_config_directory[object_type];
73 
74  return *entry;
75 }
76 
77 std::string
78 CxxConfigManager::rename(const std::string &from_name)
79 {
80  for (auto i = renamings.begin(); i != renamings.end(); ++ i) {
81  const Renaming &renaming = *i;
82 
83  if (from_name.find(renaming.fromPrefix) == 0) {
84  return renaming.toPrefix +
85  from_name.substr(renaming.fromPrefix.length());
86  }
87  }
88 
89  return from_name;
90 }
91 
92 std::string
93 CxxConfigManager::unRename(const std::string &to_name)
94 {
95  for (auto i = renamings.begin(); i != renamings.end(); ++ i) {
96  const Renaming &renaming = *i;
97 
98  if (to_name.find(renaming.toPrefix) == 0) {
99  return renaming.fromPrefix +
100  to_name.substr(renaming.toPrefix.length());
101  }
102  }
103 
104  return to_name;
105 }
106 
107 static
108 std::string formatParamList(const std::vector<std::string> &param_values)
109 {
110  std::ostringstream params;
111 
112  auto i = param_values.begin();
113  auto end_i = param_values.end();
114 
115  params << '[';
116  while (i != end_i) {
117  params << (*i);
118  ++i;
119 
120  if (i != end_i)
121  params << ", ";
122  }
123  params << ']';
124 
125  return params.str();
126 }
127 
128 SimObject *
129 CxxConfigManager::findObject(const std::string &object_name,
130  bool visit_children)
131 {
132  std::string instance_name = rename(object_name);
133 
134  if (object_name == "Null")
135  return NULL;
136 
137  /* Already constructed */
138  if (objectsByName.find(instance_name) != objectsByName.end())
139  return objectsByName[instance_name];
140 
141  if (inVisit.find(instance_name) != inVisit.end())
142  throw Exception(instance_name, "Cycle in configuration");
143 
144  std::string object_type;
145  const CxxConfigDirectoryEntry &entry =
146  findObjectType(object_name, object_type);
147 
148  SimObject *object = NULL;
149 
150  CxxConfigParams *object_params = findObjectParams(object_name);
151 
152  try {
153  DPRINTF(CxxConfig, "Configuring sim object references for: %s"
154  " (%s from object %s)\n", instance_name, object_type,
155  object_name);
156 
157  /* Remember the path back to the top of the recursion to detect
158  * cycles */
159  inVisit.insert(instance_name);
160 
161  /* Resolve pointed-to SimObjects by recursing into them */
162  for (auto i = entry.parameters.begin();
163  i != entry.parameters.end(); ++i)
164  {
165  const CxxConfigDirectoryEntry::ParamDesc *param = (*i).second;
166 
167  if (param->isSimObject) {
168  if (param->isVector) {
169  std::vector<std::string> sub_object_names;
170 
171  if (!configFile.getParamVector(object_name, param->name,
172  sub_object_names))
173  {
174  throw Exception(object_name, csprintf(
175  "Element not found: %s", param->name));
176  }
177 
178  std::vector<SimObject *> sub_objects;
179 
180  for (auto n = sub_object_names.begin();
181  n != sub_object_names.end(); ++n)
182  {
183  SimObject *sub_object = findObject(*n,
184  visit_children);
185 
186  if (sub_object)
187  sub_objects.push_back(sub_object);
188  }
189 
190  if (!object_params->setSimObjectVector(param->name,
191  sub_objects))
192  {
193  throw Exception(object_name, csprintf(
194  "Can't assign sim object element %s from \"%s\"",
195  param->name, formatParamList(sub_object_names)));
196  }
197 
198  DPRINTF(CxxConfig, "Setting sim object(s): %s.%s=%s\n",
199  object_name, param->name,
200  formatParamList(sub_object_names));
201  } else {
202  std::string sub_object_name;
203 
204  if (!configFile.getParam(object_name, param->name,
205  sub_object_name))
206  {
207  throw Exception(object_name, csprintf(
208  "Element not found: %s", param->name));
209  }
210 
211  SimObject *sub_object = findObject(sub_object_name,
212  visit_children);
213 
214  if (sub_object) {
215  if (!object_params->setSimObject(param->name,
216  sub_object))
217  {
218  throw Exception(object_name, csprintf(
219  "Can't assign sim object element %s from"
220  " \"%s\"", param->name, sub_object_name));
221  }
222  }
223 
224  DPRINTF(CxxConfig, "Setting sim object(s):"
225  " %s.%s=%s\n", object_name, param->name,
226  sub_object_name);
227  }
228  }
229  }
230 
231  DPRINTF(CxxConfig, "Creating SimObject: %s\n", instance_name);
232  object = object_params->simObjectCreate();
233 
234  if (!object) {
235  throw Exception(object_name, csprintf("Couldn't create object of"
236  " type: %s", object_type));
237  }
238 
239  objectsByName[instance_name] = object;
240  objectParamsByName[instance_name] = object_params;
241 
242  if (visit_children) {
243  std::vector<std::string> children;
244  configFile.getObjectChildren(object_name, children, true);
245 
246  /* Visit all your children */
247  for (auto i = children.begin(); i != children.end(); ++i)
248  findObject(*i, visit_children);
249  }
250  } catch (Exception &) {
251  delete object_params;
252  throw;
253  }
254 
255  /* Mark that we've exited object
256  * construction and so 'find'ing this object again won't be a
257  * configuration loop */
258  inVisit.erase(object_name);
259  return object;
260 }
261 
263 CxxConfigManager::findObjectParams(const std::string &object_name)
264 {
265  std::string instance_name = rename(object_name);
266 
267  /* Already constructed */
268  if (objectParamsByName.find(instance_name) != objectParamsByName.end())
269  return objectParamsByName[instance_name];
270 
271  std::string object_type;
272  const CxxConfigDirectoryEntry &entry =
273  findObjectType(object_name, object_type);
274 
275  DPRINTF(CxxConfig, "Configuring parameters of object: %s (%s)\n",
276  instance_name, object_type);
277 
278  CxxConfigParams *object_params = entry.makeParamsObject();
279 
280  try {
281  /* Fill in the implicit parameters that don't necessarily
282  * appear in config files */
283  object_params->setName(instance_name);
284 
285  /* Fill in parameters */
286  for (auto i = entry.parameters.begin();
287  i != entry.parameters.end(); ++i)
288  {
289  const CxxConfigDirectoryEntry::ParamDesc *param = (*i).second;
290 
291  if (!param->isSimObject) {
292  /* Only handle non-SimObject parameters here (see below) */
293 
294  if (param->isVector) {
295  std::vector<std::string> param_values;
296 
297  if (!configFile.getParamVector(object_name, param->name,
298  param_values))
299  {
300  throw Exception(object_name, csprintf(
301  "Element not found for parameter: %s",
302  param->name));
303  }
304 
305  if (!object_params->setParamVector(param->name,
306  param_values, flags))
307  {
308  throw Exception(instance_name, csprintf(
309  "Bad parameter value: .%s=X=\"%s\"",
310  param->name, formatParamList(param_values)));
311  }
312 
313  DPRINTF(CxxConfig, "Setting parameter"
314  " %s.%s=%s\n", instance_name, param->name,
315  formatParamList(param_values));
316  } else {
317  std::string param_value;
318 
319  if (!configFile.getParam(object_name, param->name,
320  param_value))
321  {
322  throw Exception(object_name, csprintf(
323  "Element not found for parameter: %s",
324  param->name));
325  }
326 
327  if (!object_params->setParam(param->name, param_value,
328  flags))
329  {
330  throw Exception(instance_name, csprintf(
331  "Bad parameter value: .%s=X=\"%s\"",
332  param->name, param_value));
333  }
334 
335  DPRINTF(CxxConfig, "Setting parameter %s.%s=%s\n",
336  instance_name, param->name, param_value);
337  }
338  }
339  }
340 
341  /* Find the number of ports that will need binding and set the
342  * appropriate port_..._connection_count parameters */
343  for (auto i = entry.ports.begin(); i != entry.ports.end(); ++i) {
344  const CxxConfigDirectoryEntry::PortDesc *port = (*i).second;
346 
347  if (!configFile.getPortPeers(object_name, port->name, peers)) {
348  DPRINTF(CxxConfig, "Port not found: %s.%s,"
349  " assuming there are no connections\n",
350  instance_name, port->name);
351  }
352 
353  unsigned int peer_count = peers.size();
354 
355  /* It would be more efficient to split the peer list and
356  * save the values for peer binding later but that would
357  * require another annoying intermediate structure to
358  * hold for little performance increase */
359 
360  if (!object_params->setPortConnectionCount(port->name,
361  peer_count))
362  {
363  throw Exception(instance_name, csprintf(
364  "Unconnected port: %s", port->name));
365  }
366 
367  DPRINTF(CxxConfig, "Setting port connection count"
368  " for: %s.%s to %d\n",
369  instance_name, port->name, peer_count);
370  }
371 
372  /* Set pointed-to SimObjects to NULL */
373  for (auto i = entry.parameters.begin();
374  i != entry.parameters.end(); ++i)
375  {
376  const CxxConfigDirectoryEntry::ParamDesc *param = (*i).second;
377 
378  if (param->isSimObject) {
379  bool ret;
380 
381  DPRINTF(CxxConfig, "Nulling sim object reference: %s.%s\n",
382  instance_name, param->name);
383 
384  if (param->isVector) {
385  /* Clear the reference list. */
387  ret = object_params->setSimObjectVector(param->name,
388  empty);
389  } else {
390  ret = object_params->setSimObject(param->name, NULL);
391  }
392 
393  if (!ret) {
394  throw Exception(instance_name, csprintf(
395  "Error nulling sim object reference(s): %s",
396  param->name));
397  }
398  }
399  }
400  } catch (Exception &) {
401  delete object_params;
402  throw;
403  }
404 
405  objectParamsByName[instance_name] = object_params;
406 
407  return object_params;
408 }
409 
410 void
412 {
413  std::vector<std::string> objects;
414  configFile.getAllObjectNames(objects);
415 
416  /* Set the traversal order for further iterators */
417  objectsInOrder.clear();
418  findTraversalOrder("root");
419 }
420 
421 void
422 CxxConfigManager::findTraversalOrder(const std::string &object_name)
423 {
424  SimObject *object = findObject(object_name);
425 
426  if (object) {
427  objectsInOrder.push_back(object);
428 
429  std::vector<std::string> children;
430  configFile.getObjectChildren(object_name, children, true);
431 
432  /* Visit all your children */
433  for (auto i = children.begin(); i != children.end(); ++i)
435  }
436 }
437 
438 void
440 {
441  for (auto i = objectsInOrder.begin(); i != objectsInOrder.end(); ++i)
442  bindObjectPorts(*i);
443 }
444 
445 void
447  SimObject *requestor_object, const std::string &request_port_name,
448  PortID request_port_index,
449  SimObject *responder_object, const std::string &response_port_name,
450  PortID response_port_index)
451 {
452  /* FIXME, check response_port_index against connection_count
453  * defined for port, need getPortConnectionCount and a
454  * getCxxConfigDirectoryEntry for each object. */
455 
456  /* It would be nice to be able to catch the errors from these calls. */
457  Port &request_port = requestor_object->getPort(
458  request_port_name, request_port_index);
459  Port &response_port = responder_object->getPort(
460  response_port_name, response_port_index);
461 
462  if (request_port.isConnected()) {
463  throw Exception(requestor_object->name(), csprintf(
464  "Request port: %s[%d] is already connected\n", request_port_name,
465  request_port_index));
466  }
467 
468  if (response_port.isConnected()) {
469  throw Exception(responder_object->name(), csprintf(
470  "Response port: %s[%d] is already connected\n", response_port_name,
471  response_port_index));
472  }
473 
474  DPRINTF(CxxConfig, "Binding port %s.%s[%d]"
475  " to %s:%s[%d]\n",
476  requestor_object->name(), request_port_name, request_port_index,
477  responder_object->name(), response_port_name, response_port_index);
478 
479  request_port.bind(response_port);
480 }
481 
482 void
485  const std::vector<std::string> &peers)
486 {
487  unsigned int request_port_index = 0;
488 
489  for (auto peer_i = peers.begin(); peer_i != peers.end();
490  ++peer_i)
491  {
492  const std::string &peer = *peer_i;
493  std::string response_object_name;
494  std::string response_port_name;
495  unsigned int response_port_index;
496 
497  parsePort(peer, response_object_name, response_port_name,
498  response_port_index);
499 
500  std::string response_instance_name = rename(response_object_name);
501 
502  if (objectsByName.find(response_instance_name)
503  == objectsByName.end()) {
504  throw Exception(object->name(), csprintf(
505  "Can't find response port object: %s",
506  response_instance_name));
507  }
508 
509  SimObject *responder_object = objectsByName[response_instance_name];
510 
511  bindPort(object, port.name, request_port_index,
512  responder_object, response_port_name, response_port_index);
513 
514  request_port_index++;
515  }
516 }
517 
518 void
520 {
521  /* We may want to separate object->name() from the name in configuration
522  * later to allow (for example) repetition of fragments of configs */
523  const std::string &instance_name = object->name();
524 
525  std::string object_name = unRename(instance_name);
526 
527  std::string object_type;
528  const CxxConfigDirectoryEntry &entry =
529  findObjectType(object_name, object_type);
530 
531  DPRINTF(CxxConfig, "Binding ports of object: %s (%s)\n",
532  instance_name, object_type);
533 
534  for (auto i = entry.ports.begin(); i != entry.ports.end(); ++i) {
535  const CxxConfigDirectoryEntry::PortDesc *port = (*i).second;
536 
537  DPRINTF(CxxConfig, "Binding port: %s.%s\n", instance_name,
538  port->name);
539 
541  configFile.getPortPeers(object_name, port->name, peers);
542 
543  /* Only handle master ports as binding only needs to happen once
544  * for each observed pair of ports */
545  if (port->isRequestor) {
546  if (!port->isVector && peers.size() > 1) {
547  throw Exception(instance_name, csprintf(
548  "Too many connections to non-vector port %s (%d)\n",
549  port->name, peers.size()));
550  }
551 
552  bindRequestPort(object, *port, peers);
553  }
554  }
555 }
556 
557 void
558 CxxConfigManager::parsePort(const std::string &inp,
559  std::string &path, std::string &port, unsigned int &index)
560 {
561  std::size_t dot_i = inp.rfind('.');
562  std::size_t open_square_i = inp.rfind('[');
563 
564  if (dot_i == std::string::npos) {
565  DPRINTF(CxxConfig, "Bad port string: %s\n", inp);
566  path = "";
567  port = "";
568  index = 0;
569  } else {
570  path = std::string(inp, 0, dot_i);
571 
572  if (open_square_i == std::string::npos) {
573  /* Singleton port */
574  port = std::string(inp, dot_i + 1, inp.length() - dot_i);
575  index = 0;
576  } else {
577  /* Vectored port elemnt */
578  port = std::string(inp, dot_i + 1, (open_square_i - 1) - dot_i);
579  index = std::atoi(inp.c_str() + open_square_i + 1);
580  }
581  }
582 }
583 
584 void
586 {
587  for (auto i = objectsInOrder.begin(); i != objectsInOrder.end(); ++i)
588  ((*i)->*mem_func)();
589 }
590 
591 void
593 {
594  if (build_all) {
595  findAllObjects();
596  bindAllPorts();
597  }
598 
599  DPRINTF(CxxConfig, "Initialising all objects\n");
601 
602  DPRINTF(CxxConfig, "Registering stats\n");
604 
605  DPRINTF(CxxConfig, "Registering probe points\n");
607 
608  DPRINTF(CxxConfig, "Connecting probe listeners\n");
610 }
611 
612 void
614 {
615  DPRINTF(CxxConfig, "Calling initState on all objects\n");
617 }
618 
619 void
621 {
622  DPRINTF(CxxConfig, "Starting up all objects\n");
624 }
625 
626 unsigned int
628 {
629  return DrainManager::instance().tryDrain() ? 0 : 1;
630 }
631 
632 void
634 {
636 }
637 
638 void
640 {
641  for (auto i = objectsInOrder.begin(); i != objectsInOrder.end(); ++ i) {
642  // (*i)->nameOut(os); FIXME, change access spec. for nameOut
643  os << '[' << (*i)->name() << "]\n";
644  (*i)->serialize(os);
645  }
646 }
647 
648 void
650 {
651  for (auto i = objectsInOrder.begin(); i != objectsInOrder.end(); ++ i)
652  (*i)->loadState(checkpoint);
653 }
654 
655 void
657 {
658  for (auto i = objectsInOrder.rbegin(); i != objectsInOrder.rend(); ++i) {
659  DPRINTF(CxxConfig, "Freeing sim object: %s\n", (*i)->name());
660  delete *i;
661  }
662 
663  for (auto i = objectParamsByName.rbegin();
664  i != objectParamsByName.rend(); ++i)
665  {
666  CxxConfigParams *params = (*i).second;
667 
668  DPRINTF(CxxConfig, "Freeing sim object params: %s\n",
669  params->getName());
670  delete params;
671  }
672 
673  objectsInOrder.clear();
674  objectsByName.clear();
675 }
676 
677 void
678 CxxConfigManager::setParam(const std::string &object_name,
679  const std::string &param_name, const std::string &param_value)
680 {
681  CxxConfigParams *params = findObjectParams(object_name);
682 
683  if (!params->setParam(param_name, param_value, flags)) {
684  throw Exception(object_name, csprintf("Bad parameter value:"
685  " .%s=X=\"%s\"", param_name, param_value));
686  } else {
687  std::string instance_name = rename(object_name);
688 
689  DPRINTF(CxxConfig, "Setting parameter %s.%s=%s\n",
690  instance_name, param_name, param_value);
691  }
692 }
693 
694 void
695 CxxConfigManager::setParamVector(const std::string &object_name,
696  const std::string &param_name,
697  const std::vector<std::string> &param_values)
698 {
699  CxxConfigParams *params = findObjectParams(object_name);
700 
701  if (!params->setParamVector(param_name, param_values, flags)) {
702  throw Exception(object_name, csprintf("Bad vector parameter value:"
703  " .%s=X=\"%s\"", param_name, formatParamList(param_values)));
704  } else {
705  std::string instance_name = rename(object_name);
706 
707  DPRINTF(CxxConfig, "Setting parameter %s.%s=\"%s\"\n",
708  instance_name, param_name, formatParamList(param_values));
709  }
710 }
711 
713 {
714  renamings.push_back(renaming);
715 }
SimObject::regProbeListeners
virtual void regProbeListeners()
Register probe listeners for this object.
Definition: sim_object.cc:112
CxxConfigManager::bindRequestPort
void bindRequestPort(SimObject *object, const CxxConfigDirectoryEntry::PortDesc &port, const std::vector< std::string > &peers)
Bind a single (possibly vectored) request port to peers from the unparsed list peers with elements in...
Definition: cxx_manager.cc:483
CxxConfigManager::addRenaming
void addRenaming(const Renaming &renaming)
Add a name prefix renaming to those currently applied.
Definition: cxx_manager.cc:712
CxxConfigParams::setParam
virtual bool setParam(const std::string &name, const std::string &value, const Flags flags)
Set a parameter with a value parsed from the given string.
Definition: cxx_config.hh:160
Stats::Group::regStats
virtual void regStats()
Callback to set stat parameters.
Definition: group.cc:64
CxxConfigDirectoryEntry::PortDesc::name
const std::string name
Definition: cxx_config.hh:93
CxxConfigParams::setPortConnectionCount
virtual bool setPortConnectionCount(const std::string &name, unsigned int count)
Set the number of connections expected for the named port.
Definition: cxx_config.hh:172
X86ISA::os
Bitfield< 17 > os
Definition: misc.hh:803
SimObject::initState
virtual void initState()
initState() is called on each SimObject when not restoring from a checkpoint.
Definition: sim_object.cc:91
MipsISA::index
Bitfield< 30, 0 > index
Definition: pra_constants.hh:44
serialize.hh
DrainManager::tryDrain
bool tryDrain()
Try to drain the system.
Definition: drain.cc:61
ArmISA::i
Bitfield< 7 > i
Definition: miscregs_types.hh:63
CxxConfigFileBase::getPortPeers
virtual bool getPortPeers(const std::string &object_name, const std::string &port_name, std::vector< std::string > &peers) const =0
Get the peer (connected) ports of the named ports.
CxxConfigManager::CxxConfigManager
CxxConfigManager(CxxConfigFileBase &configFile_)
Definition: cxx_manager.cc:49
CxxConfigManager::deleteObjects
void deleteObjects()
Delete all objects and clear objectsByName and objectsByOrder.
Definition: cxx_manager.cc:656
CxxConfigDirectoryEntry::ParamDesc::isSimObject
const bool isSimObject
Is this a SimObject, and so is to be set with setSimObject...
Definition: cxx_config.hh:81
CxxConfigManager::unRename
std::string unRename(const std::string &to_name)
Apply the first matching renaming in reverse (toPrefix -> fromPrefix for the given name.
Definition: cxx_manager.cc:93
CxxConfigManager::configFile
CxxConfigFileBase & configFile
Configuration file being read.
Definition: cxx_manager.hh:70
CxxConfigDirectoryEntry::ParamDesc::isVector
const bool isVector
Definition: cxx_config.hh:77
CxxConfigManager::Renaming
Name substitution when instantiating any object whose name starts with fromPrefix.
Definition: cxx_manager.hh:98
PortID
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:237
CxxConfigManager::findAllObjects
void findAllObjects()
Find all objects by iterating over the object names in the config file with findObject.
Definition: cxx_manager.cc:411
CxxConfigDirectoryEntry::ParamDesc
Definition: cxx_config.hh:71
CxxConfigManager::instantiate
void instantiate(bool build_all=true)
Build all objects (if build_all is true, otherwise objects must have been individually findObject-ed ...
Definition: cxx_manager.cc:592
CxxConfigDirectoryEntry::ParamDesc::name
const std::string name
Definition: cxx_config.hh:74
CxxConfigFileBase::getObjectChildren
virtual void getObjectChildren(const std::string &object_name, std::vector< std::string > &children, bool return_paths=false) const =0
Get the names or paths of all the children SimObjects of this SimObject.
std::vector< std::string >
CxxConfigParams::simObjectCreate
virtual SimObject * simObjectCreate()
Create the associated SimObject.
Definition: cxx_config.hh:177
CxxConfigFileBase::getParamVector
virtual bool getParamVector(const std::string &object_name, const std::string &param_name, std::vector< std::string > &values) const =0
Get a list/vector parameter.
CxxConfigDirectoryEntry::makeParamsObject
virtual CxxConfigParams * makeParamsObject() const
Make a ...Param structure for the SimObject class of this entry.
Definition: cxx_config.hh:114
CxxConfigParams::setSimObject
virtual bool setSimObject(const std::string &name, SimObject *simObject)
Set a SimObject valued parameter with a reference to the given SimObject.
Definition: cxx_config.hh:147
CxxConfigDirectoryEntry::PortDesc::isRequestor
const bool isRequestor
Is this a request or response port.
Definition: cxx_config.hh:99
CxxConfigDirectoryEntry::PortDesc
Similar to ParamDesc to describe ports.
Definition: cxx_config.hh:90
CxxConfigManager::serialize
void serialize(std::ostream &os)
Serialize (checkpoint) all objects to the given stream.
Definition: cxx_manager.cc:639
DrainManager::resume
void resume()
Resume normal simulation in a Drained system.
Definition: drain.cc:93
CxxConfigManager::findTraversalOrder
void findTraversalOrder(const std::string &object_name)
Populate objectsInOrder with a preorder, depth first traversal from the given object name down throug...
Definition: cxx_manager.cc:422
str.hh
formatParamList
static std::string formatParamList(const std::vector< std::string > &param_values)
Definition: cxx_manager.cc:108
SimObject::startup
virtual void startup()
startup() is the final initialization call before simulation.
Definition: sim_object.cc:96
cxx_manager.hh
CxxConfigDirectoryEntry::ports
std::map< std::string, PortDesc * > ports
Ports.
Definition: cxx_config.hh:111
ArmISA::n
Bitfield< 31 > n
Definition: miscregs_types.hh:450
CxxConfigParams
Base for peer classes of SimObjectParams derived classes with parameter modifying member functions.
Definition: cxx_config.hh:123
CxxConfigParams::getName
virtual const std::string & getName()
Get full path name string.
Definition: cxx_config.hh:142
CxxConfigDirectoryEntry::parameters
std::map< std::string, ParamDesc * > parameters
All parameters (including SimObjects) in order.
Definition: cxx_config.hh:108
CxxConfigParams::setParamVector
virtual bool setParamVector(const std::string &name, const std::vector< std::string > &values, const Flags flags)
As setParamVector but for parameters given as vectors pre-separated into elements.
Definition: cxx_config.hh:166
sim_object.hh
CxxConfigManager::bindObjectPorts
void bindObjectPorts(SimObject *object)
Bind the ports of a single SimObject.
Definition: cxx_manager.cc:519
SimObject::getPort
virtual Port & getPort(const std::string &if_name, PortID idx=InvalidPortID)
Get a port with a given name and index.
Definition: sim_object.cc:123
DPRINTF
#define DPRINTF(x,...)
Definition: trace.hh:234
CxxConfigManager::parsePort
static void parsePort(const std::string &inp, std::string &path, std::string &port, unsigned int &index)
Parse a port string of the form 'path(.path)*.port[index]' into path, port and index.
Definition: cxx_manager.cc:558
CxxConfigManager::setParamVector
void setParamVector(const std::string &object_name, const std::string &param_name, const std::vector< std::string > &param_values)
Definition: cxx_manager.cc:695
CxxConfigManager::Renaming::fromPrefix
std::string fromPrefix
Definition: cxx_manager.hh:100
CxxConfigDirectoryEntry
Config details entry for a SimObject.
Definition: cxx_config.hh:66
Port
Ports are used to interface objects to each other.
Definition: port.hh:56
CxxConfigManager::initState
void initState()
Call initState on all objects.
Definition: cxx_manager.cc:613
CxxConfigManager::Exception
Exception for instantiate/post-instantiate errors.
Definition: cxx_manager.hh:77
CxxConfigParams::setName
virtual void setName(const std::string &name_)
Example flag.
Definition: cxx_config.hh:139
CxxConfigManager::objectsByName
std::map< std::string, SimObject * > objectsByName
SimObject indexed by name.
Definition: cxx_manager.hh:112
CxxConfigManager::rename
std::string rename(const std::string &from_name)
Apply the first matching renaming in renamings to the given name.
Definition: cxx_manager.cc:78
CxxConfigDirectoryEntry::PortDesc::isVector
const bool isVector
Definition: cxx_config.hh:96
CxxConfigManager::findObjectType
const CxxConfigDirectoryEntry & findObjectType(const std::string &object_name, std::string &object_type)
Find the type field for a named object and return both the name of the type to object_type and the ob...
Definition: cxx_manager.cc:56
CxxConfigFileBase::getParam
virtual bool getParam(const std::string &object_name, const std::string &param_name, std::string &value) const =0
Get a single parameter value as a string returned in value.
CxxConfigManager::findObjectParams
CxxConfigParams * findObjectParams(const std::string &object_name)
Find the parameters for the named object.
Definition: cxx_manager.cc:263
CxxConfigManager::startup
void startup()
Call startup on all objects.
Definition: cxx_manager.cc:620
CxxConfigManager::Renaming::toPrefix
std::string toPrefix
Definition: cxx_manager.hh:101
SimObject::name
virtual const std::string name() const
Definition: sim_object.hh:133
DrainManager::instance
static DrainManager & instance()
Get the singleton DrainManager instance.
Definition: drain.hh:87
CxxConfigManager::findObject
SimObject * findObject(const std::string &object_name, bool visit_children=false)
Walk the configuration starting with object object_name and fill in all the elements of this object o...
Definition: cxx_manager.cc:129
SimObject::regProbePoints
virtual void regProbePoints()
Register probe points for this object.
Definition: sim_object.cc:104
CxxConfigManager::inVisit
std::set< std::string > inVisit
While configuring, inVisit contains names of SimObjects visited in this recursive configuration walk.
Definition: cxx_manager.hh:123
CxxConfigManager::setParam
void setParam(const std::string &object_name, const std::string &param_name, const std::string &param_value)
Convenience functions for calling set...
Definition: cxx_manager.cc:678
CxxConfigFileBase::objectExists
virtual bool objectExists(const std::string &object_name) const =0
Does an object with this path exist?
CxxConfigManager::loadState
void loadState(CheckpointIn &checkpoint)
Load all objects' state from the given Checkpoint.
Definition: cxx_manager.cc:649
CxxConfigFileBase::getAllObjectNames
virtual void getAllObjectNames(std::vector< std::string > &list) const =0
Get all SimObjects in the config.
CxxConfigManager::bindPort
void bindPort(SimObject *requestorObject, const std::string &requestPort, PortID requestPortIndex, SimObject *responderObject, const std::string &responsePort, PortID responsePortIndex)
Bind a single connection between two objects' ports.
Definition: cxx_manager.cc:446
CxxConfigFileBase
Config file wrapper providing a common interface to CxxConfigManager.
Definition: cxx_config.hh:185
Port::isConnected
bool isConnected() const
Is this port currently connected to a peer?
Definition: port.hh:128
CxxConfigManager::objectParamsByName
std::map< std::string, CxxConfigParams * > objectParamsByName
...Params objects created by this manager
Definition: cxx_manager.hh:115
SimObject::init
virtual void init()
init() is called after all C++ SimObjects have been created and all ports are connected.
Definition: sim_object.cc:73
CxxConfigManager::renamings
std::list< Renaming > renamings
All the renamings applicable when instantiating objects.
Definition: cxx_manager.hh:126
cxx_config_directory
std::map< std::string, CxxConfigDirectoryEntry * > cxx_config_directory
Directory of all SimObject classes config details.
Definition: cxx_config.cc:43
CxxConfigParams::setSimObjectVector
virtual bool setSimObjectVector(const std::string &name, const std::vector< SimObject * > &simObjects)
As setSimObjectVector but set a whole vector of references.
Definition: cxx_config.hh:152
CxxConfigManager::bindAllPorts
void bindAllPorts()
Bind the ports of all the objects in objectInOrder order.
Definition: cxx_manager.cc:439
CxxConfigManager::forEachObject
void forEachObject(void(SimObject::*mem_func)())
Perform mem_func on each SimObject.
Definition: cxx_manager.cc:585
trace.hh
CheckpointIn
Definition: serialize.hh:67
csprintf
std::string csprintf(const char *format, const Args &...args)
Definition: cprintf.hh:158
Port::bind
virtual void bind(Port &peer)
Attach to a peer port.
Definition: port.hh:113
CxxConfigManager::drainResume
void drainResume()
Resume from drain.
Definition: cxx_manager.cc:633
CxxConfigManager::flags
CxxConfigParams::Flags flags
Flags to pass to affect param setting.
Definition: cxx_manager.hh:73
CxxConfigManager::drain
unsigned int drain()
Drain all objects.
Definition: cxx_manager.cc:627
CxxConfigManager::objectsInOrder
std::list< SimObject * > objectsInOrder
SimObjects in order.
Definition: cxx_manager.hh:118
SimObject
Abstract superclass for simulation objects.
Definition: sim_object.hh:92

Generated on Wed Sep 30 2020 14:02:14 for gem5 by doxygen 1.8.17