mirror of https://github.com/xemu-project/xemu.git
96 lines
2.6 KiB
C
96 lines
2.6 KiB
C
/*
|
|
* QEMU Geforce NV2A implementation
|
|
*
|
|
* Copyright (c) 2012 espes
|
|
* Copyright (c) 2015 Jannik Vogel
|
|
* Copyright (c) 2018 Matt Borgerson
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License as
|
|
* published by the Free Software Foundation; either version 2 or
|
|
* (at your option) version 3 of the License.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
/* USER - PFIFO MMIO and DMA submission area */
|
|
uint64_t user_read(void *opaque, hwaddr addr, unsigned int size)
|
|
{
|
|
NV2AState *d = (NV2AState *)opaque;
|
|
|
|
unsigned int channel_id = addr >> 16;
|
|
assert(channel_id < NV2A_NUM_CHANNELS);
|
|
|
|
ChannelControl *control = &d->user.channel_control[channel_id];
|
|
|
|
uint32_t channel_modes = d->pfifo.regs[NV_PFIFO_MODE];
|
|
|
|
uint64_t r = 0;
|
|
if (channel_modes & (1 << channel_id)) {
|
|
/* DMA Mode */
|
|
switch (addr & 0xFFFF) {
|
|
case NV_USER_DMA_PUT:
|
|
r = control->dma_put;
|
|
break;
|
|
case NV_USER_DMA_GET:
|
|
r = control->dma_get;
|
|
break;
|
|
case NV_USER_REF:
|
|
r = control->ref;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
} else {
|
|
/* PIO Mode */
|
|
assert(false);
|
|
}
|
|
|
|
reg_log_read(NV_USER, addr, r);
|
|
return r;
|
|
}
|
|
|
|
void user_write(void *opaque, hwaddr addr, uint64_t val, unsigned int size)
|
|
{
|
|
NV2AState *d = (NV2AState *)opaque;
|
|
|
|
reg_log_write(NV_USER, addr, val);
|
|
|
|
unsigned int channel_id = addr >> 16;
|
|
assert(channel_id < NV2A_NUM_CHANNELS);
|
|
|
|
ChannelControl *control = &d->user.channel_control[channel_id];
|
|
|
|
uint32_t channel_modes = d->pfifo.regs[NV_PFIFO_MODE];
|
|
if (channel_modes & (1 << channel_id)) {
|
|
/* DMA Mode */
|
|
switch (addr & 0xFFFF) {
|
|
case NV_USER_DMA_PUT:
|
|
control->dma_put = val;
|
|
|
|
if (d->pfifo.cache1.push_enabled) {
|
|
pfifo_run_pusher(d);
|
|
}
|
|
break;
|
|
case NV_USER_DMA_GET:
|
|
control->dma_get = val;
|
|
break;
|
|
case NV_USER_REF:
|
|
control->ref = val;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
} else {
|
|
/* PIO Mode */
|
|
assert(false);
|
|
}
|
|
|
|
}
|