atomic.cc (8232:b28d06a175be) | atomic.cc (8443:530ff1bc8d70) |
---|---|
1/* 2 * Copyright (c) 2002-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; --- 372 unchanged lines hidden (view full) --- 381 //Adjust the size to get the remaining bytes. 382 size = addr + fullSize - secondAddr; 383 //And access the right address. 384 addr = secondAddr; 385 } 386} 387 388 | 1/* 2 * Copyright (c) 2002-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; --- 372 unchanged lines hidden (view full) --- 381 //Adjust the size to get the remaining bytes. 382 size = addr + fullSize - secondAddr; 383 //And access the right address. 384 addr = secondAddr; 385 } 386} 387 388 |
389template <class T> | |
390Fault | 389Fault |
391AtomicSimpleCPU::read(Addr addr, T &data, unsigned flags) 392{ 393 uint8_t *dataPtr = (uint8_t *)&data; 394 memset(dataPtr, 0, sizeof(data)); 395 Fault fault = readBytes(addr, dataPtr, sizeof(data), flags); 396 if (fault == NoFault) { 397 data = gtoh(data); 398 if (traceData) 399 traceData->setData(data); 400 } 401 return fault; 402} 403 404#ifndef DOXYGEN_SHOULD_SKIP_THIS 405 406template 407Fault 408AtomicSimpleCPU::read(Addr addr, Twin32_t &data, unsigned flags); 409 410template 411Fault 412AtomicSimpleCPU::read(Addr addr, Twin64_t &data, unsigned flags); 413 414template 415Fault 416AtomicSimpleCPU::read(Addr addr, uint64_t &data, unsigned flags); 417 418template 419Fault 420AtomicSimpleCPU::read(Addr addr, uint32_t &data, unsigned flags); 421 422template 423Fault 424AtomicSimpleCPU::read(Addr addr, uint16_t &data, unsigned flags); 425 426template 427Fault 428AtomicSimpleCPU::read(Addr addr, uint8_t &data, unsigned flags); 429 430#endif //DOXYGEN_SHOULD_SKIP_THIS 431 432template<> 433Fault 434AtomicSimpleCPU::read(Addr addr, double &data, unsigned flags) 435{ 436 return read(addr, *(uint64_t*)&data, flags); 437} 438 439template<> 440Fault 441AtomicSimpleCPU::read(Addr addr, float &data, unsigned flags) 442{ 443 return read(addr, *(uint32_t*)&data, flags); 444} 445 446 447template<> 448Fault 449AtomicSimpleCPU::read(Addr addr, int32_t &data, unsigned flags) 450{ 451 return read(addr, (uint32_t&)data, flags); 452} 453 454 455Fault | |
456AtomicSimpleCPU::writeBytes(uint8_t *data, unsigned size, 457 Addr addr, unsigned flags, uint64_t *res) 458{ 459 // use the CPU's statically allocated write request and packet objects 460 Request *req = &data_write_req; 461 462 if (traceData) { 463 traceData->setAddr(addr); --- 86 unchanged lines hidden (view full) --- 550 //Adjust the size to get the remaining bytes. 551 size = addr + fullSize - secondAddr; 552 //And access the right address. 553 addr = secondAddr; 554 } 555} 556 557 | 390AtomicSimpleCPU::writeBytes(uint8_t *data, unsigned size, 391 Addr addr, unsigned flags, uint64_t *res) 392{ 393 // use the CPU's statically allocated write request and packet objects 394 Request *req = &data_write_req; 395 396 if (traceData) { 397 traceData->setAddr(addr); --- 86 unchanged lines hidden (view full) --- 484 //Adjust the size to get the remaining bytes. 485 size = addr + fullSize - secondAddr; 486 //And access the right address. 487 addr = secondAddr; 488 } 489} 490 491 |
558template <class T> 559Fault 560AtomicSimpleCPU::write(T data, Addr addr, unsigned flags, uint64_t *res) 561{ 562 uint8_t *dataPtr = (uint8_t *)&data; 563 if (traceData) 564 traceData->setData(data); 565 data = htog(data); 566 567 Fault fault = writeBytes(dataPtr, sizeof(data), addr, flags, res); 568 if (fault == NoFault && data_write_req.isSwap()) { 569 *res = gtoh((T)*res); 570 } 571 return fault; 572} 573 574 575#ifndef DOXYGEN_SHOULD_SKIP_THIS 576 577template 578Fault 579AtomicSimpleCPU::write(Twin32_t data, Addr addr, 580 unsigned flags, uint64_t *res); 581 582template 583Fault 584AtomicSimpleCPU::write(Twin64_t data, Addr addr, 585 unsigned flags, uint64_t *res); 586 587template 588Fault 589AtomicSimpleCPU::write(uint64_t data, Addr addr, 590 unsigned flags, uint64_t *res); 591 592template 593Fault 594AtomicSimpleCPU::write(uint32_t data, Addr addr, 595 unsigned flags, uint64_t *res); 596 597template 598Fault 599AtomicSimpleCPU::write(uint16_t data, Addr addr, 600 unsigned flags, uint64_t *res); 601 602template 603Fault 604AtomicSimpleCPU::write(uint8_t data, Addr addr, 605 unsigned flags, uint64_t *res); 606 607#endif //DOXYGEN_SHOULD_SKIP_THIS 608 609template<> 610Fault 611AtomicSimpleCPU::write(double data, Addr addr, unsigned flags, uint64_t *res) 612{ 613 return write(*(uint64_t*)&data, addr, flags, res); 614} 615 616template<> 617Fault 618AtomicSimpleCPU::write(float data, Addr addr, unsigned flags, uint64_t *res) 619{ 620 return write(*(uint32_t*)&data, addr, flags, res); 621} 622 623 624template<> 625Fault 626AtomicSimpleCPU::write(int32_t data, Addr addr, unsigned flags, uint64_t *res) 627{ 628 return write((uint32_t)data, addr, flags, res); 629} 630 631 | |
632void 633AtomicSimpleCPU::tick() 634{ 635 DPRINTF(SimpleCPU, "Tick\n"); 636 637 Tick latency = 0; 638 639 for (int i = 0; i < width || locked; ++i) { --- 125 unchanged lines hidden --- | 492void 493AtomicSimpleCPU::tick() 494{ 495 DPRINTF(SimpleCPU, "Tick\n"); 496 497 Tick latency = 0; 498 499 for (int i = 0; i < width || locked; ++i) { --- 125 unchanged lines hidden --- |