external_master.hh (12492:4e76959883a6) | external_master.hh (13784:1941dc118243) |
---|---|
1/* 2 * Copyright (c) 2012-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 --- 53 unchanged lines hidden (view full) --- 62 63#include "mem/mem_object.hh" 64#include "params/ExternalMaster.hh" 65 66class ExternalMaster : public MemObject 67{ 68 public: 69 /** Derive from this class to create an external port interface */ | 1/* 2 * Copyright (c) 2012-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 --- 53 unchanged lines hidden (view full) --- 62 63#include "mem/mem_object.hh" 64#include "params/ExternalMaster.hh" 65 66class ExternalMaster : public MemObject 67{ 68 public: 69 /** Derive from this class to create an external port interface */ |
70 class Port : public MasterPort | 70 class ExternalPort : public MasterPort |
71 { 72 protected: 73 ExternalMaster &owner; 74 75 public: | 71 { 72 protected: 73 ExternalMaster &owner; 74 75 public: |
76 Port(const std::string &name_, | 76 ExternalPort(const std::string &name_, |
77 ExternalMaster &owner_) : 78 MasterPort(name_, &owner_), owner(owner_) 79 { } 80 | 77 ExternalMaster &owner_) : 78 MasterPort(name_, &owner_), owner(owner_) 79 { } 80 |
81 ~Port() { } | 81 ~ExternalPort() { } |
82 83 /** Any or all of recv... can be overloaded to provide the port's 84 * functionality */ 85 }; 86 87 /* Handlers are specific to *types* of port not specific port 88 * instantiations. A handler will typically build a bridge to the 89 * external port from gem5 and provide gem5 with a MasterPort that can be 90 * bound to for each call to Handler::getExternalPort.*/ 91 class Handler 92 { 93 public: 94 /** Create or find an external port which can be bound. Returns 95 * NULL on failure */ | 82 83 /** Any or all of recv... can be overloaded to provide the port's 84 * functionality */ 85 }; 86 87 /* Handlers are specific to *types* of port not specific port 88 * instantiations. A handler will typically build a bridge to the 89 * external port from gem5 and provide gem5 with a MasterPort that can be 90 * bound to for each call to Handler::getExternalPort.*/ 91 class Handler 92 { 93 public: 94 /** Create or find an external port which can be bound. Returns 95 * NULL on failure */ |
96 virtual Port *getExternalPort( | 96 virtual ExternalPort *getExternalPort( |
97 const std::string &name, ExternalMaster &owner, 98 const std::string &port_data) = 0; 99 }; 100 101 protected: 102 /** The peer port for the gem5 port "port" */ | 97 const std::string &name, ExternalMaster &owner, 98 const std::string &port_data) = 0; 99 }; 100 101 protected: 102 /** The peer port for the gem5 port "port" */ |
103 Port *externalPort; | 103 ExternalPort *externalPort; |
104 105 /** Name of the bound port. This will be name() + ".port" */ 106 std::string portName; 107 108 /** Key to select a port handler */ 109 std::string portType; 110 111 /** Handler-specific port configuration */ 112 std::string portData; 113 114 /** Registered handlers. Handlers are chosen using the port_type 115 * parameter on ExternalMasters. port_types form a global namespace 116 * across the simulation and so handlers are registered into a global 117 * structure */ 118 static std::map<std::string, Handler *> portHandlers; 119 120 public: 121 ExternalMaster(ExternalMasterParams *params); 122 | 104 105 /** Name of the bound port. This will be name() + ".port" */ 106 std::string portName; 107 108 /** Key to select a port handler */ 109 std::string portType; 110 111 /** Handler-specific port configuration */ 112 std::string portData; 113 114 /** Registered handlers. Handlers are chosen using the port_type 115 * parameter on ExternalMasters. port_types form a global namespace 116 * across the simulation and so handlers are registered into a global 117 * structure */ 118 static std::map<std::string, Handler *> portHandlers; 119 120 public: 121 ExternalMaster(ExternalMasterParams *params); 122 |
123 /** MasterPort interface. Responds only to port "port" */ 124 BaseMasterPort &getMasterPort(const std::string &if_name, 125 PortID idx = InvalidPortID); | 123 /** Port interface. Responds only to port "port" */ 124 Port &getPort(const std::string &if_name, 125 PortID idx=InvalidPortID) override; |
126 127 /** Register a handler which can provide ports with port_type == 128 * handler_name */ 129 static void registerHandler(const std::string &handler_name, 130 Handler *handler); 131 132 void init(); 133 134 const MasterID masterId; 135}; 136 137 138#endif //__MEM_EXTERNAL_MASTER_HH__ | 126 127 /** Register a handler which can provide ports with port_type == 128 * handler_name */ 129 static void registerHandler(const std::string &handler_name, 130 Handler *handler); 131 132 void init(); 133 134 const MasterID masterId; 135}; 136 137 138#endif //__MEM_EXTERNAL_MASTER_HH__ |