gem5 v24.0.0.0
Loading...
Searching...
No Matches
dma_virt_device.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2021 Advanced Micro Devices, Inc.
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 met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 *
15 * 3. Neither the name of the copyright holder nor the names of its
16 * contributors may be used to endorse or promote products derived from this
17 * software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
33
34namespace gem5
35{
36
37void
38DmaVirtDevice::dmaReadVirt(Addr host_addr, unsigned size,
39 DmaCallback *cb, void *data, Tick delay)
40{
41 dmaVirt(&DmaDevice::dmaRead, host_addr, size, cb, data, delay);
42}
43
44void
45DmaVirtDevice::dmaWriteVirt(Addr host_addr, unsigned size,
46 DmaCallback *cb, void *data, Tick delay)
47{
48 dmaVirt(&DmaDevice::dmaWrite, host_addr, size, cb, data, delay);
49}
50
51void
52DmaVirtDevice::dmaVirt(DmaFnPtr dmaFn, Addr addr, unsigned size,
53 DmaCallback *cb, void *data, Tick delay)
54{
55 if (size == 0) {
56 if (cb)
57 schedule(cb->getChunkEvent(), curTick() + delay);
58 return;
59 }
60
61 // move the buffer data pointer with the chunks
62 uint8_t *loc_data = (uint8_t*)data;
63
64 TranslationGenPtr gen = translate(addr, size);
65 for (const auto &range: *gen) {
66 fatal_if(range.fault, "Failed translation: vaddr 0x%x", range.vaddr);
67
68 Event *event = cb ? cb->getChunkEvent() : nullptr;
69 (this->*dmaFn)(range.paddr, range.size, event, loc_data, delay);
70 loc_data += range.size;
71 }
72}
73
74} // namespace gem5
const char data[]
DMA callback class.
Event * getChunkEvent()
Request a chunk event.
void dmaWrite(Addr addr, int size, Event *event, uint8_t *data, uint32_t sid, uint32_t ssid, Tick delay=0)
void dmaRead(Addr addr, int size, Event *event, uint8_t *data, uint32_t sid, uint32_t ssid, Tick delay=0)
void dmaReadVirt(Addr host_addr, unsigned size, DmaCallback *cb, void *data, Tick delay=0)
Initiate a DMA read from virtual address host_addr.
void dmaVirt(DmaFnPtr dmaFn, Addr host_addr, unsigned size, DmaCallback *cb, void *data, Tick delay=0)
Initiate a call to DmaDevice using DmaFnPtr do a DMA starting from virtual address host_addr for size...
virtual TranslationGenPtr translate(Addr vaddr, Addr size)=0
Function used to translate a range of addresses from virtual to physical addresses.
void dmaWriteVirt(Addr host_addr, unsigned size, DmaCallback *b, void *data, Tick delay=0)
Initiate a DMA write from virtual address host_addr.
void schedule(Event &event, Tick when)
Definition eventq.hh:1012
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
Definition logging.hh:236
Bitfield< 10, 5 > event
Bitfield< 3 > addr
Definition types.hh:84
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
Tick curTick()
The universal simulation clock.
Definition cur_tick.hh:46
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition types.hh:147
uint64_t Tick
Tick count type.
Definition types.hh:58
std::unique_ptr< TranslationGen > TranslationGenPtr

Generated on Tue Jun 18 2024 16:24:03 for gem5 by doxygen 1.11.0