physical.cc (8796:a2ae5c378d0a) physical.cc (8799:dac1e33e07b0)
1/*
1/*
2 * Copyright (c) 2010 ARM Limited
2 * Copyright (c) 2010-2011 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

--- 99 unchanged lines hidden (view full) ---

110PhysicalMemory::init()
111{
112 if (ports.size() == 0) {
113 fatal("PhysicalMemory object %s is unconnected!", name());
114 }
115
116 for (PortIterator pi = ports.begin(); pi != ports.end(); ++pi) {
117 if (*pi)
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

--- 99 unchanged lines hidden (view full) ---

110PhysicalMemory::init()
111{
112 if (ports.size() == 0) {
113 fatal("PhysicalMemory object %s is unconnected!", name());
114 }
115
116 for (PortIterator pi = ports.begin(); pi != ports.end(); ++pi) {
117 if (*pi)
118 (*pi)->sendStatusChange(Port::RangeChange);
118 (*pi)->sendRangeChange();
119 }
120}
121
122PhysicalMemory::~PhysicalMemory()
123{
124 if (pmemAddr)
125 munmap((char*)pmemAddr, size());
126}
127
119 }
120}
121
122PhysicalMemory::~PhysicalMemory()
123{
124 if (pmemAddr)
125 munmap((char*)pmemAddr, size());
126}
127
128void
129PhysicalMemory::regStats()
130{
131 using namespace Stats;
132
133 bytesRead
134 .name(name() + ".bytes_read")
135 .desc("Number of bytes read from this memory")
136 ;
137 bytesInstRead
138 .name(name() + ".bytes_inst_read")
139 .desc("Number of instructions bytes read from this memory")
140 ;
141 bytesWritten
142 .name(name() + ".bytes_written")
143 .desc("Number of bytes written to this memory")
144 ;
145 numReads
146 .name(name() + ".num_reads")
147 .desc("Number of read requests responded to by this memory")
148 ;
149 numWrites
150 .name(name() + ".num_writes")
151 .desc("Number of write requests responded to by this memory")
152 ;
153 numOther
154 .name(name() + ".num_other")
155 .desc("Number of other requests responded to by this memory")
156 ;
157 bwRead
158 .name(name() + ".bw_read")
159 .desc("Total read bandwidth from this memory (bytes/s)")
160 .precision(0)
161 .prereq(bytesRead)
162 ;
163 bwInstRead
164 .name(name() + ".bw_inst_read")
165 .desc("Instruction read bandwidth from this memory (bytes/s)")
166 .precision(0)
167 .prereq(bytesInstRead)
168 ;
169 bwWrite
170 .name(name() + ".bw_write")
171 .desc("Write bandwidth from this memory (bytes/s)")
172 .precision(0)
173 .prereq(bytesWritten)
174 ;
175 bwTotal
176 .name(name() + ".bw_total")
177 .desc("Total bandwidth to/from this memory (bytes/s)")
178 .precision(0)
179 .prereq(bwTotal)
180 ;
181 bwRead = bytesRead / simSeconds;
182 bwInstRead = bytesInstRead / simSeconds;
183 bwWrite = bytesWritten / simSeconds;
184 bwTotal = (bytesRead + bytesWritten) / simSeconds;
185}
186
128unsigned
129PhysicalMemory::deviceBlockSize() const
130{
131 //Can accept anysize request
132 return 0;
133}
134
135Tick

--- 162 unchanged lines hidden (view full) ---

298 panic("Invalid size for conditional read/write\n");
299 }
300
301 if (overwrite_mem)
302 std::memcpy(hostAddr, &overwrite_val, pkt->getSize());
303
304 assert(!pkt->req->isInstFetch());
305 TRACE_PACKET("Read/Write");
187unsigned
188PhysicalMemory::deviceBlockSize() const
189{
190 //Can accept anysize request
191 return 0;
192}
193
194Tick

--- 162 unchanged lines hidden (view full) ---

357 panic("Invalid size for conditional read/write\n");
358 }
359
360 if (overwrite_mem)
361 std::memcpy(hostAddr, &overwrite_val, pkt->getSize());
362
363 assert(!pkt->req->isInstFetch());
364 TRACE_PACKET("Read/Write");
365 numOther++;
306 } else if (pkt->isRead()) {
307 assert(!pkt->isWrite());
308 if (pkt->isLLSC()) {
309 trackLoadLocked(pkt);
310 }
311 if (pmemAddr)
312 memcpy(pkt->getPtr<uint8_t>(), hostAddr, pkt->getSize());
313 TRACE_PACKET(pkt->req->isInstFetch() ? "IFetch" : "Read");
366 } else if (pkt->isRead()) {
367 assert(!pkt->isWrite());
368 if (pkt->isLLSC()) {
369 trackLoadLocked(pkt);
370 }
371 if (pmemAddr)
372 memcpy(pkt->getPtr<uint8_t>(), hostAddr, pkt->getSize());
373 TRACE_PACKET(pkt->req->isInstFetch() ? "IFetch" : "Read");
374 numReads++;
375 bytesRead += pkt->getSize();
376 if (pkt->req->isInstFetch())
377 bytesInstRead += pkt->getSize();
314 } else if (pkt->isWrite()) {
315 if (writeOK(pkt)) {
316 if (pmemAddr)
317 memcpy(hostAddr, pkt->getPtr<uint8_t>(), pkt->getSize());
318 assert(!pkt->req->isInstFetch());
319 TRACE_PACKET("Write");
378 } else if (pkt->isWrite()) {
379 if (writeOK(pkt)) {
380 if (pmemAddr)
381 memcpy(hostAddr, pkt->getPtr<uint8_t>(), pkt->getSize());
382 assert(!pkt->req->isInstFetch());
383 TRACE_PACKET("Write");
384 numWrites++;
385 bytesWritten += pkt->getSize();
320 }
321 } else if (pkt->isInvalidate()) {
322 //upgrade or invalidate
323 if (pkt->needsResponse()) {
324 pkt->makeAtomicResponse();
325 }
326 } else {
327 panic("unimplemented");

--- 38 unchanged lines hidden (view full) ---

366 pkt->cmdString());
367 }
368}
369
370
371Port *
372PhysicalMemory::getPort(const std::string &if_name, int idx)
373{
386 }
387 } else if (pkt->isInvalidate()) {
388 //upgrade or invalidate
389 if (pkt->needsResponse()) {
390 pkt->makeAtomicResponse();
391 }
392 } else {
393 panic("unimplemented");

--- 38 unchanged lines hidden (view full) ---

432 pkt->cmdString());
433 }
434}
435
436
437Port *
438PhysicalMemory::getPort(const std::string &if_name, int idx)
439{
374 // Accept request for "functional" port for backwards compatibility
375 // with places where this function is called from C++. I'd prefer
376 // to move all these into Python someday.
377 if (if_name == "functional") {
378 return new MemoryPort(csprintf("%s-functional", name()), this);
379 }
380
381 if (if_name != "port") {
382 panic("PhysicalMemory::getPort: unknown port %s requested", if_name);
383 }
384
385 if (idx >= (int)ports.size()) {
386 ports.resize(idx + 1);
387 }
388
389 if (ports[idx] != NULL) {
390 panic("PhysicalMemory::getPort: port %d already assigned", idx);
391 }
392
393 MemoryPort *port =
394 new MemoryPort(csprintf("%s-port%d", name(), idx), this);
395
396 ports[idx] = port;
397 return port;
398}
399
440 if (if_name != "port") {
441 panic("PhysicalMemory::getPort: unknown port %s requested", if_name);
442 }
443
444 if (idx >= (int)ports.size()) {
445 ports.resize(idx + 1);
446 }
447
448 if (ports[idx] != NULL) {
449 panic("PhysicalMemory::getPort: port %d already assigned", idx);
450 }
451
452 MemoryPort *port =
453 new MemoryPort(csprintf("%s-port%d", name(), idx), this);
454
455 ports[idx] = port;
456 return port;
457}
458
400
401void
402PhysicalMemory::recvStatusChange(Port::Status status)
403{
404}
405
406PhysicalMemory::MemoryPort::MemoryPort(const std::string &_name,
407 PhysicalMemory *_memory)
408 : SimpleTimingPort(_name, _memory), memory(_memory)
409{ }
410
411void
459PhysicalMemory::MemoryPort::MemoryPort(const std::string &_name,
460 PhysicalMemory *_memory)
461 : SimpleTimingPort(_name, _memory), memory(_memory)
462{ }
463
464void
412PhysicalMemory::MemoryPort::recvStatusChange(Port::Status status)
465PhysicalMemory::MemoryPort::recvRangeChange()
413{
466{
414 memory->recvStatusChange(status);
467 // memory is a slave and thus should never have to worry about its
468 // neighbours address ranges
415}
416
469}
470
417void
418PhysicalMemory::MemoryPort::getDeviceAddressRanges(AddrRangeList &resp,
419 bool &snoop)
471AddrRangeList
472PhysicalMemory::MemoryPort::getAddrRanges()
420{
473{
421 memory->getAddressRanges(resp, snoop);
474 return memory->getAddrRanges();
422}
423
475}
476
424void
425PhysicalMemory::getAddressRanges(AddrRangeList &resp, bool &snoop)
477AddrRangeList
478PhysicalMemory::getAddrRanges()
426{
479{
427 snoop = false;
428 resp.clear();
429 resp.push_back(RangeSize(start(), size()));
480 AddrRangeList ranges;
481 ranges.push_back(RangeSize(start(), size()));
482 return ranges;
430}
431
432unsigned
433PhysicalMemory::MemoryPort::deviceBlockSize() const
434{
435 return memory->deviceBlockSize();
436}
437

--- 174 unchanged lines hidden ---
483}
484
485unsigned
486PhysicalMemory::MemoryPort::deviceBlockSize() const
487{
488 return memory->deviceBlockSize();
489}
490

--- 174 unchanged lines hidden ---