MainbusComponent.h Source File

Back to the index.

MainbusComponent.h
Go to the documentation of this file.
1 #ifndef MAINBUSCOMPONENT_H
2 #define MAINBUSCOMPONENT_H
3 
4 /*
5  * Copyright (C) 2008-2010 Anders Gavare. All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  * 3. The name of the author may not be used to endorse or promote products
16  * derived from this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28  * SUCH DAMAGE.
29  */
30 
31 // COMPONENT(mainbus)
32 
33 
34 #include "AddressDataBus.h"
35 #include "Component.h"
36 
37 #include "UnitTest.h"
38 
39 
40 /**
41  * \brief Main bus Component.
42  *
43  * An AddressDataBus Component which forwards reads and writes to
44  * MemoryMappedComponent components (which also must implement the
45  * AddressDataBus interface), e.g. the RAMComponent.
46  */
48  : public Component
49  , public AddressDataBus
50  , public UnitTestable
51 {
52 public:
53  /**
54  * \brief Constructs a MainbusComponent.
55  */
57 
58  virtual ~MainbusComponent();
59 
60  /**
61  * \brief Creates a MainbusComponent.
62  */
64 
65  /**
66  * \brief Get attribute information about the MainbusComponent class.
67  *
68  * @param attributeName The attribute name.
69  * @return A string representing the attribute value.
70  */
71  static string GetAttribute(const string& attributeName);
72 
73  /**
74  * \brief Returns the component's AddressDataBus interface.
75  *
76  * @return A pointer to an AddressDataBus.
77  */
79 
80  /* Implementation of AddressDataBus: */
81  virtual void AddressSelect(uint64_t address);
82  virtual bool ReadData(uint8_t& data, Endianness endianness);
83  virtual bool ReadData(uint16_t& data, Endianness endianness);
84  virtual bool ReadData(uint32_t& data, Endianness endianness);
85  virtual bool ReadData(uint64_t& data, Endianness endianness);
86  virtual bool WriteData(const uint8_t& data, Endianness endianness);
87  virtual bool WriteData(const uint16_t& data, Endianness endianness);
88  virtual bool WriteData(const uint32_t& data, Endianness endianness);
89  virtual bool WriteData(const uint64_t& data, Endianness endianness);
90 
91 
92  /********************************************************************/
93 
94  static void RunUnitTests(int& nSucceeded, int& nFailures);
95 
96 protected:
97  virtual void FlushCachedStateForComponent();
98  virtual bool PreRunCheckForComponent(GXemul* gxemul);
99 
100 private:
101  bool MakeSureMemoryMapExists(GXemul* gxemul = NULL);
102 
103 private:
104  struct MemoryMapEntry {
105  uint64_t base;
106  uint64_t size;
107  uint64_t addrMul;
108  AddressDataBus * addressDataBus;
109  };
110 
111  typedef vector<MemoryMapEntry> MemoryMap;
112  MemoryMap m_memoryMap;
113  bool m_memoryMapFailed;
114  bool m_memoryMapValid;
115 
116  // For the currently selected address:
117  AddressDataBus * m_currentAddressDataBus;
118 
119  // TODO: direct page access...
120 };
121 
122 
123 #endif // MAINBUSCOMPONENT_H
data
u_short data
Definition: siireg.h:79
MainbusComponent::Create
static refcount_ptr< Component > Create(const ComponentCreateArgs &args)
Creates a MainbusComponent.
Definition: MainbusComponent.cc:46
GXemul
The main emulator class.
Definition: GXemul.h:54
MainbusComponent::GetAttribute
static string GetAttribute(const string &attributeName)
Get attribute information about the MainbusComponent class.
Definition: MainbusComponent.cc:52
MainbusComponent::AddressSelect
virtual void AddressSelect(uint64_t address)
Place an address on the bus.
Definition: MainbusComponent.cc:181
MainbusComponent::MainbusComponent
MainbusComponent()
Constructs a MainbusComponent.
Definition: MainbusComponent.cc:32
MainbusComponent::AsAddressDataBus
virtual AddressDataBus * AsAddressDataBus()
Returns the component's AddressDataBus interface.
Definition: MainbusComponent.cc:175
MainbusComponent::PreRunCheckForComponent
virtual bool PreRunCheckForComponent(GXemul *gxemul)
Checks the state of this component, before starting execution.
Definition: MainbusComponent.cc:76
refcount_ptr< Component >
MainbusComponent::ReadData
virtual bool ReadData(uint8_t &data, Endianness endianness)
Reads 8-bit data from the currently selected address.
Definition: MainbusComponent.cc:215
MainbusComponent::FlushCachedStateForComponent
virtual void FlushCachedStateForComponent()
Resets the cached state of this component.
Definition: MainbusComponent.cc:64
Endianness
Endianness
Definition: misc.h:156
MainbusComponent::WriteData
virtual bool WriteData(const uint8_t &data, Endianness endianness)
Writes 8-bit data to the currently selected address.
Definition: MainbusComponent.cc:263
UnitTest.h
Component.h
Component
A Component is a node in the configuration tree that makes up an emulation setup.
Definition: Component.h:62
MainbusComponent
Main bus Component.
Definition: MainbusComponent.h:47
MainbusComponent::RunUnitTests
static void RunUnitTests(int &nSucceeded, int &nFailures)
UnitTestable
Base class for unit testable classes.
Definition: UnitTest.h:74
MainbusComponent::~MainbusComponent
virtual ~MainbusComponent()
Definition: MainbusComponent.cc:41
AddressDataBus
An interface for implementing components that read/write data via an address bus.
Definition: AddressDataBus.h:44
AddressDataBus.h
ComponentCreateArgs
Definition: Component.h:48

Generated on Tue Mar 24 2020 14:04:48 for GXemul by doxygen 1.8.17