physical.cc (3918:1f9a98d198e8) | physical.cc (4040:eb894f3fc168) |
---|---|
1/* 2 * Copyright (c) 2001-2005 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 78 unchanged lines hidden (view full) --- 87 munmap((char*)pmemAddr, params()->addrRange.size()); 88 //Remove memPorts? 89} 90 91Addr 92PhysicalMemory::new_page() 93{ 94 Addr return_addr = pagePtr << LogVMPageSize; | 1/* 2 * Copyright (c) 2001-2005 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 78 unchanged lines hidden (view full) --- 87 munmap((char*)pmemAddr, params()->addrRange.size()); 88 //Remove memPorts? 89} 90 91Addr 92PhysicalMemory::new_page() 93{ 94 Addr return_addr = pagePtr << LogVMPageSize; |
95 return_addr += params()->addrRange.start; | 95 return_addr += start(); |
96 97 ++pagePtr; 98 return return_addr; 99} 100 101int 102PhysicalMemory::deviceBlockSize() 103{ --- 78 unchanged lines hidden (view full) --- 182 } 183 else { 184 // no match: advance to next record 185 ++i; 186 } 187 } 188 189 if (isLocked) { | 96 97 ++pagePtr; 98 return return_addr; 99} 100 101int 102PhysicalMemory::deviceBlockSize() 103{ --- 78 unchanged lines hidden (view full) --- 182 } 183 else { 184 // no match: advance to next record 185 ++i; 186 } 187 } 188 189 if (isLocked) { |
190 req->setScResult(success ? 1 : 0); | 190 req->setExtraData(success ? 1 : 0); |
191 } 192 193 return success; 194} 195 196void 197PhysicalMemory::doFunctionalAccess(PacketPtr pkt) 198{ | 191 } 192 193 return success; 194} 195 196void 197PhysicalMemory::doFunctionalAccess(PacketPtr pkt) 198{ |
199 assert(pkt->getAddr() >= params()->addrRange.start && 200 pkt->getAddr() + pkt->getSize() <= params()->addrRange.start + 201 params()->addrRange.size()); | 199 assert(pkt->getAddr() >= start() && 200 pkt->getAddr() + pkt->getSize() <= start() + size()); |
202 203 if (pkt->isRead()) { 204 if (pkt->req->isLocked()) { 205 trackLoadLocked(pkt->req); 206 } | 201 202 if (pkt->isRead()) { 203 if (pkt->req->isLocked()) { 204 trackLoadLocked(pkt->req); 205 } |
207 memcpy(pkt->getPtr 208 pmemAddr + pkt->getAddr() - params()->addrRange.start, | 206 memcpy(pkt->getPtr<uint8_t>(), pmemAddr + pkt->getAddr() - start(), |
209 pkt->getSize()); 210#if TRACING_ON 211 switch (pkt->getSize()) { 212 case sizeof(uint64_t): 213 DPRINTF(MemoryAccess, "Read of size %i on address 0x%x data 0x%x\n", 214 pkt->getSize(), pkt->getAddr(),pkt->get<uint64_t>()); 215 break; 216 case sizeof(uint32_t): --- 11 unchanged lines hidden (view full) --- 228 default: 229 DPRINTF(MemoryAccess, "Read of size %i on address 0x%x\n", 230 pkt->getSize(), pkt->getAddr()); 231 } 232#endif 233 } 234 else if (pkt->isWrite()) { 235 if (writeOK(pkt->req)) { | 207 pkt->getSize()); 208#if TRACING_ON 209 switch (pkt->getSize()) { 210 case sizeof(uint64_t): 211 DPRINTF(MemoryAccess, "Read of size %i on address 0x%x data 0x%x\n", 212 pkt->getSize(), pkt->getAddr(),pkt->get<uint64_t>()); 213 break; 214 case sizeof(uint32_t): --- 11 unchanged lines hidden (view full) --- 226 default: 227 DPRINTF(MemoryAccess, "Read of size %i on address 0x%x\n", 228 pkt->getSize(), pkt->getAddr()); 229 } 230#endif 231 } 232 else if (pkt->isWrite()) { 233 if (writeOK(pkt->req)) { |
236 memcpy(pmemAddr + pkt->getAddr() - params()->addrRange.start, 237 pkt->getPtr<uint8_t>(), pkt->getSize()); | 234 memcpy(pmemAddr + pkt->getAddr() - start(), pkt->getPtr<uint8_t>(), 235 pkt->getSize()); |
238#if TRACING_ON 239 switch (pkt->getSize()) { 240 case sizeof(uint64_t): 241 DPRINTF(MemoryAccess, "Write of size %i on address 0x%x data 0x%x\n", 242 pkt->getSize(), pkt->getAddr(),pkt->get<uint64_t>()); 243 break; 244 case sizeof(uint32_t): 245 DPRINTF(MemoryAccess, "Write of size %i on address 0x%x data 0x%x\n", --- 8 unchanged lines hidden (view full) --- 254 pkt->getSize(), pkt->getAddr(),pkt->get<uint8_t>()); 255 break; 256 default: 257 DPRINTF(MemoryAccess, "Write of size %i on address 0x%x\n", 258 pkt->getSize(), pkt->getAddr()); 259 } 260#endif 261 } | 236#if TRACING_ON 237 switch (pkt->getSize()) { 238 case sizeof(uint64_t): 239 DPRINTF(MemoryAccess, "Write of size %i on address 0x%x data 0x%x\n", 240 pkt->getSize(), pkt->getAddr(),pkt->get<uint64_t>()); 241 break; 242 case sizeof(uint32_t): 243 DPRINTF(MemoryAccess, "Write of size %i on address 0x%x data 0x%x\n", --- 8 unchanged lines hidden (view full) --- 252 pkt->getSize(), pkt->getAddr(),pkt->get<uint8_t>()); 253 break; 254 default: 255 DPRINTF(MemoryAccess, "Write of size %i on address 0x%x\n", 256 pkt->getSize(), pkt->getAddr()); 257 } 258#endif 259 } |
262 } 263 else if (pkt->isInvalidate()) { | 260 } else if (pkt->isInvalidate()) { |
264 //upgrade or invalidate 265 pkt->flags |= SATISFIED; | 261 //upgrade or invalidate 262 pkt->flags |= SATISFIED; |
266 } 267 else { | 263 } else if (pkt->isReadWrite()) { 264 IntReg overwrite_val; 265 bool overwrite_mem; 266 uint64_t condition_val64; 267 uint32_t condition_val32; 268 uint64_t test_val64; 269 uint32_t test_val32; 270 271 assert(sizeof(IntReg) >= pkt->getSize()); 272 273 overwrite_mem = true; 274 // keep a copy of our possible write value, and copy what is at the 275 // memory address into the packet 276 memcpy(&overwrite_val, pkt->getPtr<uint8_t>(), pkt->getSize()); 277 memcpy(pkt->getPtr<uint8_t>(), pmemAddr + pkt->getAddr() - start(), 278 pkt->getSize()); 279 280 if (pkt->req->isCondSwap()) { 281 if (pkt->getSize() == sizeof(uint64_t)) { 282 condition_val64 = htog(pkt->req->getExtraData()); 283 memcpy(&test_val64, pmemAddr + pkt->getAddr() - start(), sizeof(uint64_t)); 284 overwrite_mem = test_val64 == condition_val64; 285 } else if (pkt->getSize() == sizeof(uint32_t)) { 286 condition_val32 = htog((uint32_t)pkt->req->getExtraData()); 287 memcpy(&test_val32, pmemAddr + pkt->getAddr() - start(), sizeof(uint32_t)); 288 overwrite_mem = test_val32 == condition_val32; 289 } else 290 panic("Invalid size for conditional read/write\n"); 291 } 292 293 if (overwrite_mem) 294 memcpy(pmemAddr + pkt->getAddr() - start(), 295 &overwrite_val, pkt->getSize()); 296 297#if TRACING_ON 298 switch (pkt->getSize()) { 299 case sizeof(uint64_t): 300 DPRINTF(MemoryAccess, "Read/Write of size %i on address 0x%x old data 0x%x\n", 301 pkt->getSize(), pkt->getAddr(),pkt->get<uint64_t>()); 302 DPRINTF(MemoryAccess, "New Data 0x%x %s conditional (0x%x) and %s \n", 303 overwrite_mem, pkt->req->isCondSwap() ? "was" : "wasn't", 304 condition_val64, overwrite_mem ? "happened" : "didn't happen"); 305 break; 306 case sizeof(uint32_t): 307 DPRINTF(MemoryAccess, "Read/Write of size %i on address 0x%x old data 0x%x\n", 308 pkt->getSize(), pkt->getAddr(),pkt->get<uint32_t>()); 309 DPRINTF(MemoryAccess, "New Data 0x%x %s conditional (0x%x) and %s \n", 310 overwrite_mem, pkt->req->isCondSwap() ? "was" : "wasn't", 311 condition_val32, overwrite_mem ? "happened" : "didn't happen"); 312 break; 313 case sizeof(uint16_t): 314 DPRINTF(MemoryAccess, "Read/Write of size %i on address 0x%x old data 0x%x\n", 315 pkt->getSize(), pkt->getAddr(),pkt->get<uint16_t>()); 316 DPRINTF(MemoryAccess, "New Data 0x%x wasn't conditional and happned\n", 317 overwrite_mem); 318 break; 319 case sizeof(uint8_t): 320 DPRINTF(MemoryAccess, "Read/Write of size %i on address 0x%x old data 0x%x\n", 321 pkt->getSize(), pkt->getAddr(),pkt->get<uint8_t>()); 322 DPRINTF(MemoryAccess, "New Data 0x%x wasn't conditional and happned\n", 323 overwrite_mem); 324 break; 325 default: 326 DPRINTF(MemoryAccess, "Read/Write of size %i on address 0x%x\n", 327 pkt->getSize(), pkt->getAddr()); 328 } 329#endif 330 } else { |
268 panic("unimplemented"); 269 } 270 271 pkt->result = Packet::Success; 272} 273 274Port * 275PhysicalMemory::getPort(const std::string &if_name, int idx) --- 34 unchanged lines hidden (view full) --- 310 memory->getAddressRanges(resp, snoop); 311} 312 313void 314PhysicalMemory::getAddressRanges(AddrRangeList &resp, AddrRangeList &snoop) 315{ 316 snoop.clear(); 317 resp.clear(); | 331 panic("unimplemented"); 332 } 333 334 pkt->result = Packet::Success; 335} 336 337Port * 338PhysicalMemory::getPort(const std::string &if_name, int idx) --- 34 unchanged lines hidden (view full) --- 373 memory->getAddressRanges(resp, snoop); 374} 375 376void 377PhysicalMemory::getAddressRanges(AddrRangeList &resp, AddrRangeList &snoop) 378{ 379 snoop.clear(); 380 resp.clear(); |
318 resp.push_back(RangeSize(params()->addrRange.start, | 381 resp.push_back(RangeSize(start(), |
319 params()->addrRange.size())); 320} 321 322int 323PhysicalMemory::MemoryPort::deviceBlockSize() 324{ 325 return memory->deviceBlockSize(); 326} --- 179 unchanged lines hidden --- | 382 params()->addrRange.size())); 383} 384 385int 386PhysicalMemory::MemoryPort::deviceBlockSize() 387{ 388 return memory->deviceBlockSize(); 389} --- 179 unchanged lines hidden --- |