2014-04-16 09:33:41 +05:30
|
|
|
// Copyright 2014 Citra Emulator Project
|
|
|
|
// Licensed under GPLv2
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2014-07-22 16:11:16 +05:30
|
|
|
#include "common/bit_field.h"
|
2014-04-16 09:33:41 +05:30
|
|
|
#include "core/hle/service/service.h"
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
2014-04-17 06:16:05 +05:30
|
|
|
// Namespace GSP_GPU
|
2014-04-16 09:33:41 +05:30
|
|
|
|
|
|
|
namespace GSP_GPU {
|
|
|
|
|
2014-07-23 08:56:28 +05:30
|
|
|
/// GSP interrupt ID
|
|
|
|
enum class InterruptId : u8 {
|
|
|
|
PSC0 = 0x00,
|
|
|
|
PSC1 = 0x01,
|
|
|
|
PDC0 = 0x02, // Seems called every vertical screen line
|
|
|
|
PDC1 = 0x03, // Seems called every frame
|
|
|
|
PPF = 0x04,
|
|
|
|
P3D = 0x05,
|
|
|
|
DMA = 0x06,
|
|
|
|
};
|
|
|
|
|
|
|
|
/// GSP command ID
|
|
|
|
enum class CommandId : u32 {
|
2014-07-22 16:11:16 +05:30
|
|
|
REQUEST_DMA = 0x00,
|
|
|
|
SET_COMMAND_LIST_LAST = 0x01,
|
2014-07-22 16:34:16 +05:30
|
|
|
|
|
|
|
// Fills a given memory range with a particular value
|
2014-07-22 16:11:16 +05:30
|
|
|
SET_MEMORY_FILL = 0x02,
|
2014-07-22 16:34:16 +05:30
|
|
|
|
|
|
|
// Copies an image and optionally performs color-conversion or scaling.
|
|
|
|
// This is highly similar to the GameCube's EFB copy feature
|
2014-07-22 16:11:16 +05:30
|
|
|
SET_DISPLAY_TRANSFER = 0x03,
|
2014-07-22 16:34:16 +05:30
|
|
|
|
|
|
|
// Conceptionally similar to SET_DISPLAY_TRANSFER and presumable uses the same hardware path
|
2014-07-22 16:11:16 +05:30
|
|
|
SET_TEXTURE_COPY = 0x04,
|
2014-07-22 16:34:16 +05:30
|
|
|
|
2014-07-22 16:11:16 +05:30
|
|
|
SET_COMMAND_LIST_FIRST = 0x05,
|
2014-05-18 01:56:45 +05:30
|
|
|
};
|
|
|
|
|
2014-07-23 09:40:37 +05:30
|
|
|
/// GSP thread interrupt relay queue
|
|
|
|
struct InterruptRelayQueue {
|
2014-07-23 08:56:28 +05:30
|
|
|
union {
|
|
|
|
u32 hex;
|
|
|
|
|
|
|
|
// Index of last interrupt in the queue
|
|
|
|
BitField<0,8,u32> index;
|
|
|
|
|
|
|
|
// Number of interrupts remaining to be processed by the userland code
|
|
|
|
BitField<8,8,u32> number_interrupts;
|
|
|
|
|
|
|
|
// Error code - zero on success, otherwise an error has occurred
|
|
|
|
BitField<16,8,u32> error_code;
|
|
|
|
};
|
|
|
|
|
|
|
|
u32 unk0;
|
|
|
|
u32 unk1;
|
|
|
|
|
|
|
|
InterruptId slot[0x34]; ///< Interrupt ID slots
|
|
|
|
};
|
2014-07-23 09:40:37 +05:30
|
|
|
static_assert(sizeof(InterruptRelayQueue) == 0x40,
|
|
|
|
"InterruptRelayQueue struct has incorrect size");
|
2014-07-23 08:29:26 +05:30
|
|
|
|
2014-07-23 08:56:28 +05:30
|
|
|
/// GSP command
|
|
|
|
struct Command {
|
|
|
|
BitField<0, 8, CommandId> id;
|
2014-07-22 16:11:16 +05:30
|
|
|
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
u32 source_address;
|
|
|
|
u32 dest_address;
|
|
|
|
u32 size;
|
|
|
|
} dma_request;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
u32 address;
|
|
|
|
u32 size;
|
|
|
|
} set_command_list_last;
|
2014-05-18 01:56:45 +05:30
|
|
|
|
2014-07-22 16:11:16 +05:30
|
|
|
struct {
|
|
|
|
u32 start1;
|
|
|
|
u32 value1;
|
|
|
|
u32 end1;
|
|
|
|
u32 start2;
|
|
|
|
u32 value2;
|
|
|
|
u32 end2;
|
|
|
|
} memory_fill;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
u32 in_buffer_address;
|
|
|
|
u32 out_buffer_address;
|
|
|
|
u32 in_buffer_size;
|
|
|
|
u32 out_buffer_size;
|
|
|
|
u32 flags;
|
|
|
|
} image_copy;
|
|
|
|
|
|
|
|
u8 raw_data[0x1C];
|
|
|
|
};
|
2014-05-18 01:56:45 +05:30
|
|
|
};
|
2014-07-23 08:56:28 +05:30
|
|
|
static_assert(sizeof(Command) == 0x20, "Command struct has incorrect size");
|
2014-05-18 01:56:45 +05:30
|
|
|
|
2014-07-23 09:40:37 +05:30
|
|
|
/// GSP shared memory GX command buffer header
|
|
|
|
struct CommandBuffer {
|
|
|
|
union {
|
|
|
|
u32 hex;
|
|
|
|
|
|
|
|
// Current command index. This index is updated by GSP module after loading the command
|
|
|
|
// data, right before the command is processed. When this index is updated by GSP module,
|
|
|
|
// the total commands field is decreased by one as well.
|
|
|
|
BitField<0,8,u32> index;
|
|
|
|
|
|
|
|
// Total commands to process, must not be value 0 when GSP module handles commands. This
|
|
|
|
// must be <=15 when writing a command to shared memory. This is incremented by the
|
|
|
|
// application when writing a command to shared memory, after increasing this value
|
|
|
|
// TriggerCmdReqQueue is only used if this field is value 1.
|
|
|
|
BitField<8,8,u32> number_commands;
|
|
|
|
};
|
|
|
|
|
|
|
|
u32 unk[7];
|
|
|
|
|
|
|
|
Command commands[0xF];
|
|
|
|
};
|
|
|
|
static_assert(sizeof(CommandBuffer) == 0x200, "CommandBuffer struct has incorrect size");
|
|
|
|
|
2014-04-17 06:16:05 +05:30
|
|
|
/// Interface to "srv:" service
|
2014-04-16 09:33:41 +05:30
|
|
|
class Interface : public Service::Interface {
|
|
|
|
public:
|
|
|
|
|
|
|
|
Interface();
|
|
|
|
|
|
|
|
~Interface();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the string port name used by CTROS for the service
|
|
|
|
* @return Port name of service
|
|
|
|
*/
|
2014-08-18 08:33:22 +05:30
|
|
|
std::string GetPortName() const {
|
2014-04-16 09:33:41 +05:30
|
|
|
return "gsp::Gpu";
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2014-07-23 08:29:26 +05:30
|
|
|
/**
|
|
|
|
* Signals that the specified interrupt type has occurred to userland code
|
|
|
|
* @param interrupt_id ID of interrupt that is being signalled
|
|
|
|
*/
|
2014-07-23 08:56:28 +05:30
|
|
|
void SignalInterrupt(InterruptId interrupt_id);
|
2014-07-23 08:29:26 +05:30
|
|
|
|
2014-04-16 09:33:41 +05:30
|
|
|
} // namespace
|