RubyPort.hh (6876:a658c315512c) | RubyPort.hh (6882:898047a3672c) |
---|---|
1 2/* 3 * Copyright (c) 2009 Advanced Micro Devices, Inc. 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are 8 * met: redistributions of source code must retain the above copyright --- 32 unchanged lines hidden (view full) --- 41 42using namespace std; 43 44class MessageBuffer; 45class AbstractController; 46 47class RubyPort : public MemObject { 48public: | 1 2/* 3 * Copyright (c) 2009 Advanced Micro Devices, Inc. 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are 8 * met: redistributions of source code must retain the above copyright --- 32 unchanged lines hidden (view full) --- 41 42using namespace std; 43 44class MessageBuffer; 45class AbstractController; 46 47class RubyPort : public MemObject { 48public: |
49 50 class M5Port : public SimpleTimingPort 51 { 52 53 RubyPort *ruby_port; 54 55 public: 56 M5Port(const std::string &_name, 57 RubyPort *_port); 58 bool sendTiming(PacketPtr pkt); 59 void hitCallback(PacketPtr pkt); 60 61 protected: 62 virtual bool recvTiming(PacketPtr pkt); 63 virtual Tick recvAtomic(PacketPtr pkt); 64 65 private: 66 bool isPioAddress(Addr addr); 67 bool isPhysMemAddress(Addr addr); 68 }; 69 70 friend class M5Port; 71 72 class PioPort : public SimpleTimingPort 73 { 74 75 RubyPort *ruby_port; 76 77 public: 78 PioPort(const std::string &_name, 79 RubyPort *_port); 80 bool sendTiming(PacketPtr pkt); 81 82 protected: 83 virtual bool recvTiming(PacketPtr pkt); 84 virtual Tick recvAtomic(PacketPtr pkt); 85 }; 86 87 friend class PioPort; 88 89 struct SenderState : public Packet::SenderState 90 { 91 M5Port* port; 92 Packet::SenderState *saved; 93 94 SenderState(M5Port* _port, 95 Packet::SenderState *sender_state = NULL) 96 : port(_port), saved(sender_state) 97 {} 98 }; 99 |
|
49 typedef RubyPortParams Params; 50 RubyPort(const Params *p); | 100 typedef RubyPortParams Params; 101 RubyPort(const Params *p); |
51 virtual ~RubyPort() {} | 102 virtual ~RubyPort() {} |
52 | 103 |
104 void init(); 105 |
|
53 Port *getPort(const std::string &if_name, int idx); 54 | 106 Port *getPort(const std::string &if_name, int idx); 107 |
55 virtual int64_t makeRequest(const RubyRequest & request) = 0; | 108 virtual int64_t makeRequest(const RubyRequest & request) = 0; |
56 | 109 |
57 void registerHitCallback(void (*hit_callback)(int64_t request_id)) { 58 assert(m_hit_callback == NULL); // can't assign hit_callback twice 59 m_hit_callback = hit_callback; 60 } | 110 void registerHitCallback(void (*hit_callback)(int64_t request_id)) { 111 // 112 // Can't assign hit_callback twice and by default it is set to the 113 // RubyPort's default callback function. 114 // 115 assert(m_hit_callback == ruby_hit_callback); 116 m_hit_callback = hit_callback; 117 } |
61 | 118 |
119 // 120 // Called by the controller to give the sequencer a pointer. 121 // A pointer to the controller is needed for atomic support. 122 // 123 void setController(AbstractController* _cntrl) { m_controller = _cntrl; } 124 |
|
62protected: 63 const string m_name; 64 void (*m_hit_callback)(int64_t); 65 66 int64_t makeUniqueRequestID() { 67 // The request ID is generated by combining the port ID with a request count 68 // so that request IDs can be formed concurrently by multiple threads. 69 // IDs are formed as follows: --- 12 unchanged lines hidden (view full) --- 82 m_request_cnt++; 83 // assert((m_request_cnt & (1<<48)) == 0); 84 return id; 85 } 86 87 int m_version; 88 AbstractController* m_controller; 89 MessageBuffer* m_mandatory_q_ptr; | 125protected: 126 const string m_name; 127 void (*m_hit_callback)(int64_t); 128 129 int64_t makeUniqueRequestID() { 130 // The request ID is generated by combining the port ID with a request count 131 // so that request IDs can be formed concurrently by multiple threads. 132 // IDs are formed as follows: --- 12 unchanged lines hidden (view full) --- 145 m_request_cnt++; 146 // assert((m_request_cnt & (1<<48)) == 0); 147 return id; 148 } 149 150 int m_version; 151 AbstractController* m_controller; 152 MessageBuffer* m_mandatory_q_ptr; |
153 PioPort* pio_port; |
|
90 91private: 92 static uint16_t m_num_ports; 93 uint16_t m_port_id; 94 uint64_t m_request_cnt; | 154 155private: 156 static uint16_t m_num_ports; 157 uint16_t m_port_id; 158 uint64_t m_request_cnt; |
159 160 struct RequestCookie { 161 Packet *pkt; 162 M5Port *m5Port; 163 RequestCookie(Packet *p, M5Port *m5p) 164 : pkt(p), m5Port(m5p) 165 {} 166 }; 167 168 typedef std::map<int64_t, RequestCookie*> RequestMap; 169 static RequestMap pending_cpu_requests; 170 static void ruby_hit_callback(int64_t req_id); 171 172 FunctionalPort funcMemPort; |
|
95}; 96 97#endif | 173}; 174 175#endif |