gem5  v20.1.0.0
hsa_device.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-2018 Advanced Micro Devices, Inc.
3  * All rights reserved.
4  *
5  * For use for simulation and test purposes only
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright notice,
11  * this list of conditions and the following disclaimer.
12  *
13  * 2. Redistributions in binary form must reproduce the above copyright notice,
14  * this list of conditions and the following disclaimer in the documentation
15  * and/or other materials provided with the distribution.
16  *
17  * 3. Neither the name of the copyright holder nor the names of its
18  * contributors may be used to endorse or promote products derived from this
19  * software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  *
33  * Authors: Sooraj Puthoor
34  * Michael LeBeane
35  * Eric van Tassell
36  * Anthony Gutierrez
37  */
38 
39 #include "dev/hsa/hsa_device.hh"
40 
41 #include "base/chunk_generator.hh"
42 #include "sim/process.hh"
43 
46 {
47  return *hsaPP;
48 }
49 
50 void
51 HSADevice::dmaReadVirt(Addr host_addr, unsigned size,
52  DmaCallback *cb, void *data, Tick delay)
53 {
54  dmaVirt(&DmaDevice::dmaRead, host_addr, size, cb, data, delay);
55 }
56 
57 void
58 HSADevice::dmaWriteVirt(Addr host_addr, unsigned size,
59  DmaCallback *cb, void *data, Tick delay)
60 {
61  dmaVirt(&DmaDevice::dmaWrite, host_addr, size, cb, data, delay);
62 }
63 
64 void
65 HSADevice::dmaVirt(DmaFnPtr dmaFn, Addr addr, unsigned size,
66  DmaCallback *cb, void *data, Tick delay)
67 {
68  if (size == 0) {
69  if (cb)
70  schedule(cb->getChunkEvent(), curTick() + delay);
71  return;
72  }
73 
74  // move the buffer data pointer with the chunks
75  uint8_t *loc_data = (uint8_t*)data;
76 
77  for (ChunkGenerator gen(addr, size, PAGE_SIZE); !gen.done(); gen.next()) {
78  Addr phys;
79 
80  // translate pages into their corresponding frames
81  translateOrDie(gen.addr(), phys);
82 
83  Event *event = cb ? cb->getChunkEvent() : nullptr;
84 
85  (this->*dmaFn)(phys, gen.size(), event, loc_data, delay);
86 
87  loc_data += gen.size();
88  }
89 }
90 
96 void
98 {
104  auto process = sys->threads[0]->getProcessPtr();
105 
106  if (!process->pTable->translate(vaddr, paddr)) {
107  fatal("failed translation: vaddr 0x%x\n", vaddr);
108  }
109 }
HSADevice::hsaPP
HSAPacketProcessor * hsaPP
Definition: hsa_device.hh:92
fatal
#define fatal(...)
This implements a cprintf based fatal() function.
Definition: logging.hh:183
data
const char data[]
Definition: circlebuf.test.cc:42
HSADevice::dmaWriteVirt
void dmaWriteVirt(Addr host_addr, unsigned size, DmaCallback *cb, void *data, Tick delay=0)
Definition: hsa_device.cc:58
Tick
uint64_t Tick
Tick count type.
Definition: types.hh:63
HSADevice::dmaReadVirt
void dmaReadVirt(Addr host_addr, unsigned size, DmaCallback *cb, void *data, Tick delay=0)
Definition: hsa_device.cc:51
PioDevice::sys
System * sys
Definition: io_device.hh:102
DmaDevice::dmaRead
void dmaRead(Addr addr, int size, Event *event, uint8_t *data, uint32_t sid, uint32_t ssid, Tick delay=0)
Definition: dma_device.hh:188
EventManager::schedule
void schedule(Event &event, Tick when)
Definition: eventq.hh:1005
DmaDevice::dmaWrite
void dmaWrite(Addr addr, int size, Event *event, uint8_t *data, uint32_t sid, uint32_t ssid, Tick delay=0)
Definition: dma_device.hh:175
HSAPacketProcessor
Definition: hsa_packet_processor.hh:212
Event
Definition: eventq.hh:246
PAGE_SIZE
#define PAGE_SIZE
Definition: base.cc:60
MipsISA::vaddr
vaddr
Definition: pra_constants.hh:275
MipsISA::event
Bitfield< 10, 5 > event
Definition: pra_constants.hh:297
HSADevice::translateOrDie
void translateOrDie(Addr vaddr, Addr &paddr)
HSADevices will perform DMA operations on VAs, and because page faults are not currently supported fo...
Definition: hsa_device.cc:97
process.hh
DmaCallback::getChunkEvent
Event * getChunkEvent()
Request a chunk event.
Definition: dma_device.hh:274
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
ChunkGenerator::done
bool done() const
Are we done? That is, did the last call to next() advance past the end of the region?
Definition: chunk_generator.hh:137
System::threads
Threads threads
Definition: system.hh:309
HSADevice::hsaPacketProc
HSAPacketProcessor & hsaPacketProc()
Definition: hsa_device.cc:45
DmaCallback
DMA callback class.
Definition: dma_device.hh:220
addr
ip6_addr_t addr
Definition: inet.hh:423
chunk_generator.hh
HSADevice::dmaVirt
void dmaVirt(DmaFnPtr, Addr host_addr, unsigned size, DmaCallback *cb, void *data, Tick delay=0)
Definition: hsa_device.cc:65
ChunkGenerator
This class takes an arbitrary memory region (address/length pair) and generates a series of appropria...
Definition: chunk_generator.hh:55
hsa_device.hh
curTick
Tick curTick()
The current simulated tick.
Definition: core.hh:45

Generated on Wed Sep 30 2020 14:02:11 for gem5 by doxygen 1.8.17