physical.cc (8799:dac1e33e07b0) physical.cc (8851:7e966326ef5b)
1/*
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

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

71
72PhysicalMemory::PhysicalMemory(const Params *p)
73 : MemObject(p), pmemAddr(NULL), lat(p->latency), lat_var(p->latency_var),
74 _size(params()->range.size()), _start(params()->range.start)
75{
76 if (size() % TheISA::PageBytes != 0)
77 panic("Memory Size not divisible by page size\n");
78
1/*
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

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

71
72PhysicalMemory::PhysicalMemory(const Params *p)
73 : MemObject(p), pmemAddr(NULL), lat(p->latency), lat_var(p->latency_var),
74 _size(params()->range.size()), _start(params()->range.start)
75{
76 if (size() % TheISA::PageBytes != 0)
77 panic("Memory Size not divisible by page size\n");
78
79 // create the appropriate number of ports
80 for (int i = 0; i < p->port_port_connection_count; ++i) {
81 ports.push_back(new MemoryPort(csprintf("%s-port%d", name(), i),
82 this));
83 }
84
79 if (params()->null)
80 return;
81
82
83 if (params()->file == "") {
84 int map_flags = MAP_ANON | MAP_PRIVATE;
85 pmemAddr = (uint8_t *)mmap(NULL, size(),
86 PROT_READ | PROT_WRITE, map_flags, -1, 0);

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

104 //If requested, initialize all the memory to 0
105 if (p->zero)
106 memset(pmemAddr, 0, size());
107}
108
109void
110PhysicalMemory::init()
111{
85 if (params()->null)
86 return;
87
88
89 if (params()->file == "") {
90 int map_flags = MAP_ANON | MAP_PRIVATE;
91 pmemAddr = (uint8_t *)mmap(NULL, size(),
92 PROT_READ | PROT_WRITE, map_flags, -1, 0);

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

110 //If requested, initialize all the memory to 0
111 if (p->zero)
112 memset(pmemAddr, 0, size());
113}
114
115void
116PhysicalMemory::init()
117{
112 if (ports.size() == 0) {
118 if (ports.empty()) {
113 fatal("PhysicalMemory object %s is unconnected!", name());
114 }
115
116 for (PortIterator pi = ports.begin(); pi != ports.end(); ++pi) {
119 fatal("PhysicalMemory object %s is unconnected!", name());
120 }
121
122 for (PortIterator pi = ports.begin(); pi != ports.end(); ++pi) {
117 if (*pi)
118 (*pi)->sendRangeChange();
123 (*pi)->sendRangeChange();
119 }
120}
121
122PhysicalMemory::~PhysicalMemory()
123{
124 if (pmemAddr)
125 munmap((char*)pmemAddr, size());
126}

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

433 }
434}
435
436
437Port *
438PhysicalMemory::getPort(const std::string &if_name, int idx)
439{
440 if (if_name != "port") {
124 }
125}
126
127PhysicalMemory::~PhysicalMemory()
128{
129 if (pmemAddr)
130 munmap((char*)pmemAddr, size());
131}

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

438 }
439}
440
441
442Port *
443PhysicalMemory::getPort(const std::string &if_name, int idx)
444{
445 if (if_name != "port") {
441 panic("PhysicalMemory::getPort: unknown port %s requested", if_name);
446 panic("PhysicalMemory::getPort: unknown port %s requested\n", if_name);
442 }
443
447 }
448
444 if (idx >= (int)ports.size()) {
445 ports.resize(idx + 1);
449 if (idx >= static_cast<int>(ports.size())) {
450 panic("PhysicalMemory::getPort: unknown index %d requested\n", idx);
446 }
447
451 }
452
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;
453 return ports[idx];
457}
458
459PhysicalMemory::MemoryPort::MemoryPort(const std::string &_name,
460 PhysicalMemory *_memory)
461 : SimpleTimingPort(_name, _memory), memory(_memory)
462{ }
463
464void

--- 200 unchanged lines hidden ---
454}
455
456PhysicalMemory::MemoryPort::MemoryPort(const std::string &_name,
457 PhysicalMemory *_memory)
458 : SimpleTimingPort(_name, _memory), memory(_memory)
459{ }
460
461void

--- 200 unchanged lines hidden ---