2020-04-19 23:04:05 +02:00
// SPDX-License-Identifier: MPL-2.0
2020-03-27 20:36:02 +01:00
// Copyright © 2020 Skyline Team and Contributors (https://github.com/skyline-emu/)
2019-09-24 22:54:27 +02:00
# include "ipc.h"
# include "types/KProcess.h"
namespace skyline : : kernel : : ipc {
2019-11-23 19:48:22 +01:00
IpcBuffer : : IpcBuffer ( u64 address , size_t size , IpcBufferType type ) : address ( address ) , size ( size ) , type ( type ) { }
InputBuffer : : InputBuffer ( kernel : : ipc : : BufferDescriptorX * xBuf ) : IpcBuffer ( xBuf - > Address ( ) , xBuf - > size , IpcBufferType : : X ) { }
InputBuffer : : InputBuffer ( kernel : : ipc : : BufferDescriptorABW * aBuf , IpcBufferType type ) : IpcBuffer ( aBuf - > Address ( ) , aBuf - > Size ( ) , type ) { }
OutputBuffer : : OutputBuffer ( kernel : : ipc : : BufferDescriptorABW * bBuf , IpcBufferType type ) : IpcBuffer ( bBuf - > Address ( ) , bBuf - > Size ( ) , type ) { }
OutputBuffer : : OutputBuffer ( kernel : : ipc : : BufferDescriptorC * cBuf ) : IpcBuffer ( cBuf - > address , cBuf - > size , IpcBufferType : : C ) { }
2020-02-15 10:38:17 +01:00
IpcRequest : : IpcRequest ( bool isDomain , const DeviceState & state ) : isDomain ( isDomain ) , state ( state ) {
u8 * tls = state . process - > GetPointer < u8 > ( state . thread - > tls ) ;
u8 * pointer = tls ;
2019-09-24 22:54:27 +02:00
2020-02-15 10:38:17 +01:00
header = reinterpret_cast < CommandHeader * > ( pointer ) ;
pointer + = sizeof ( CommandHeader ) ;
2019-09-24 22:54:27 +02:00
2019-11-14 20:06:38 +01:00
if ( header - > handleDesc ) {
2020-02-15 10:38:17 +01:00
handleDesc = reinterpret_cast < HandleDescriptor * > ( pointer ) ;
pointer + = sizeof ( HandleDescriptor ) + ( handleDesc - > sendPid ? sizeof ( u64 ) : 0 ) ;
2020-04-17 23:19:19 +02:00
for ( u32 index = 0 ; handleDesc - > copyCount > index ; index + + ) {
2020-03-25 18:59:37 +01:00
copyHandles . push_back ( * reinterpret_cast < KHandle * > ( pointer ) ) ;
pointer + = sizeof ( KHandle ) ;
2019-09-24 22:54:27 +02:00
}
2020-04-17 23:19:19 +02:00
for ( u32 index = 0 ; handleDesc - > moveCount > index ; index + + ) {
2020-03-25 18:59:37 +01:00
moveHandles . push_back ( * reinterpret_cast < KHandle * > ( pointer ) ) ;
pointer + = sizeof ( KHandle ) ;
2019-09-24 22:54:27 +02:00
}
}
2020-04-17 23:19:19 +02:00
for ( u8 index = 0 ; header - > xNo > index ; index + + ) {
2020-02-15 10:38:17 +01:00
auto bufX = reinterpret_cast < BufferDescriptorX * > ( pointer ) ;
Framebuffer and NativeActivity
What was added:
* Framebuffer
* NativeActivity
* NV Services
* IOCTL Handler
* NV Devices:
* * /dev/nvmap - 0xC0080101, 0xC0080103, 0xC0200104, 0xC0180105, 0xC00C0109, 0xC008010E
* * /dev/nvhost-as-gpu
* * /dev/nvhost-channel - 0x40044801, 0xC0104809, 0xC010480B, 0xC018480C, 0x4004480D, 0xC020481A, 0x40084714
* * /dev/nvhost-ctrl
* * /dev/nvhost-ctrl-gpu - 0x80044701, 0x80284702, 0xC0184706, 0xC0B04705, 0x80084714
* SVCs:
* * SetMemoryAttribute
* * CreateTransferMemory
* * ResetSignal
* * GetSystemTick
* Addition of Compact Logger
What was fixed:
* SVCs:
* * SetHeapSize
* * SetMemoryAttribute
* * QueryMemory
* A release build would not set CMAKE_BUILD_TYPE to "RELEASE"
* The logger code was simplified
2019-11-13 21:09:31 +01:00
if ( bufX - > Address ( ) ) {
2019-11-23 19:48:22 +01:00
inputBuf . emplace_back ( bufX ) ;
Framebuffer and NativeActivity
What was added:
* Framebuffer
* NativeActivity
* NV Services
* IOCTL Handler
* NV Devices:
* * /dev/nvmap - 0xC0080101, 0xC0080103, 0xC0200104, 0xC0180105, 0xC00C0109, 0xC008010E
* * /dev/nvhost-as-gpu
* * /dev/nvhost-channel - 0x40044801, 0xC0104809, 0xC010480B, 0xC018480C, 0x4004480D, 0xC020481A, 0x40084714
* * /dev/nvhost-ctrl
* * /dev/nvhost-ctrl-gpu - 0x80044701, 0x80284702, 0xC0184706, 0xC0B04705, 0x80084714
* SVCs:
* * SetMemoryAttribute
* * CreateTransferMemory
* * ResetSignal
* * GetSystemTick
* Addition of Compact Logger
What was fixed:
* SVCs:
* * SetHeapSize
* * SetMemoryAttribute
* * QueryMemory
* A release build would not set CMAKE_BUILD_TYPE to "RELEASE"
* The logger code was simplified
2019-11-13 21:09:31 +01:00
state . logger - > Debug ( " Buf X #{} AD: 0x{:X} SZ: 0x{:X} CTR: {} " , index , u64 ( bufX - > Address ( ) ) , u16 ( bufX - > size ) , u16 ( bufX - > Counter ( ) ) ) ;
}
2020-02-15 10:38:17 +01:00
pointer + = sizeof ( BufferDescriptorX ) ;
2019-09-24 22:54:27 +02:00
}
2020-04-17 23:19:19 +02:00
for ( u8 index = 0 ; header - > aNo > index ; index + + ) {
2020-02-15 10:38:17 +01:00
auto bufA = reinterpret_cast < BufferDescriptorABW * > ( pointer ) ;
Framebuffer and NativeActivity
What was added:
* Framebuffer
* NativeActivity
* NV Services
* IOCTL Handler
* NV Devices:
* * /dev/nvmap - 0xC0080101, 0xC0080103, 0xC0200104, 0xC0180105, 0xC00C0109, 0xC008010E
* * /dev/nvhost-as-gpu
* * /dev/nvhost-channel - 0x40044801, 0xC0104809, 0xC010480B, 0xC018480C, 0x4004480D, 0xC020481A, 0x40084714
* * /dev/nvhost-ctrl
* * /dev/nvhost-ctrl-gpu - 0x80044701, 0x80284702, 0xC0184706, 0xC0B04705, 0x80084714
* SVCs:
* * SetMemoryAttribute
* * CreateTransferMemory
* * ResetSignal
* * GetSystemTick
* Addition of Compact Logger
What was fixed:
* SVCs:
* * SetHeapSize
* * SetMemoryAttribute
* * QueryMemory
* A release build would not set CMAKE_BUILD_TYPE to "RELEASE"
* The logger code was simplified
2019-11-13 21:09:31 +01:00
if ( bufA - > Address ( ) ) {
2019-11-23 19:48:22 +01:00
inputBuf . emplace_back ( bufA ) ;
Framebuffer and NativeActivity
What was added:
* Framebuffer
* NativeActivity
* NV Services
* IOCTL Handler
* NV Devices:
* * /dev/nvmap - 0xC0080101, 0xC0080103, 0xC0200104, 0xC0180105, 0xC00C0109, 0xC008010E
* * /dev/nvhost-as-gpu
* * /dev/nvhost-channel - 0x40044801, 0xC0104809, 0xC010480B, 0xC018480C, 0x4004480D, 0xC020481A, 0x40084714
* * /dev/nvhost-ctrl
* * /dev/nvhost-ctrl-gpu - 0x80044701, 0x80284702, 0xC0184706, 0xC0B04705, 0x80084714
* SVCs:
* * SetMemoryAttribute
* * CreateTransferMemory
* * ResetSignal
* * GetSystemTick
* Addition of Compact Logger
What was fixed:
* SVCs:
* * SetHeapSize
* * SetMemoryAttribute
* * QueryMemory
* A release build would not set CMAKE_BUILD_TYPE to "RELEASE"
* The logger code was simplified
2019-11-13 21:09:31 +01:00
state . logger - > Debug ( " Buf A #{} AD: 0x{:X} SZ: 0x{:X} " , index , u64 ( bufA - > Address ( ) ) , u64 ( bufA - > Size ( ) ) ) ;
}
2020-02-15 10:38:17 +01:00
pointer + = sizeof ( BufferDescriptorABW ) ;
2019-09-24 22:54:27 +02:00
}
2020-04-17 23:19:19 +02:00
for ( u8 index = 0 ; header - > bNo > index ; index + + ) {
2020-02-15 10:38:17 +01:00
auto bufB = reinterpret_cast < BufferDescriptorABW * > ( pointer ) ;
Framebuffer and NativeActivity
What was added:
* Framebuffer
* NativeActivity
* NV Services
* IOCTL Handler
* NV Devices:
* * /dev/nvmap - 0xC0080101, 0xC0080103, 0xC0200104, 0xC0180105, 0xC00C0109, 0xC008010E
* * /dev/nvhost-as-gpu
* * /dev/nvhost-channel - 0x40044801, 0xC0104809, 0xC010480B, 0xC018480C, 0x4004480D, 0xC020481A, 0x40084714
* * /dev/nvhost-ctrl
* * /dev/nvhost-ctrl-gpu - 0x80044701, 0x80284702, 0xC0184706, 0xC0B04705, 0x80084714
* SVCs:
* * SetMemoryAttribute
* * CreateTransferMemory
* * ResetSignal
* * GetSystemTick
* Addition of Compact Logger
What was fixed:
* SVCs:
* * SetHeapSize
* * SetMemoryAttribute
* * QueryMemory
* A release build would not set CMAKE_BUILD_TYPE to "RELEASE"
* The logger code was simplified
2019-11-13 21:09:31 +01:00
if ( bufB - > Address ( ) ) {
2019-11-23 19:48:22 +01:00
outputBuf . emplace_back ( bufB ) ;
Framebuffer and NativeActivity
What was added:
* Framebuffer
* NativeActivity
* NV Services
* IOCTL Handler
* NV Devices:
* * /dev/nvmap - 0xC0080101, 0xC0080103, 0xC0200104, 0xC0180105, 0xC00C0109, 0xC008010E
* * /dev/nvhost-as-gpu
* * /dev/nvhost-channel - 0x40044801, 0xC0104809, 0xC010480B, 0xC018480C, 0x4004480D, 0xC020481A, 0x40084714
* * /dev/nvhost-ctrl
* * /dev/nvhost-ctrl-gpu - 0x80044701, 0x80284702, 0xC0184706, 0xC0B04705, 0x80084714
* SVCs:
* * SetMemoryAttribute
* * CreateTransferMemory
* * ResetSignal
* * GetSystemTick
* Addition of Compact Logger
What was fixed:
* SVCs:
* * SetHeapSize
* * SetMemoryAttribute
* * QueryMemory
* A release build would not set CMAKE_BUILD_TYPE to "RELEASE"
* The logger code was simplified
2019-11-13 21:09:31 +01:00
state . logger - > Debug ( " Buf B #{} AD: 0x{:X} SZ: 0x{:X} " , index , u64 ( bufB - > Address ( ) ) , u64 ( bufB - > Size ( ) ) ) ;
}
2020-02-15 10:38:17 +01:00
pointer + = sizeof ( BufferDescriptorABW ) ;
2019-09-24 22:54:27 +02:00
}
2020-04-17 23:19:19 +02:00
for ( u8 index = 0 ; header - > wNo > index ; index + + ) {
2020-02-15 10:38:17 +01:00
auto bufW = reinterpret_cast < BufferDescriptorABW * > ( pointer ) ;
Framebuffer and NativeActivity
What was added:
* Framebuffer
* NativeActivity
* NV Services
* IOCTL Handler
* NV Devices:
* * /dev/nvmap - 0xC0080101, 0xC0080103, 0xC0200104, 0xC0180105, 0xC00C0109, 0xC008010E
* * /dev/nvhost-as-gpu
* * /dev/nvhost-channel - 0x40044801, 0xC0104809, 0xC010480B, 0xC018480C, 0x4004480D, 0xC020481A, 0x40084714
* * /dev/nvhost-ctrl
* * /dev/nvhost-ctrl-gpu - 0x80044701, 0x80284702, 0xC0184706, 0xC0B04705, 0x80084714
* SVCs:
* * SetMemoryAttribute
* * CreateTransferMemory
* * ResetSignal
* * GetSystemTick
* Addition of Compact Logger
What was fixed:
* SVCs:
* * SetHeapSize
* * SetMemoryAttribute
* * QueryMemory
* A release build would not set CMAKE_BUILD_TYPE to "RELEASE"
* The logger code was simplified
2019-11-13 21:09:31 +01:00
if ( bufW - > Address ( ) ) {
2019-11-23 19:48:22 +01:00
inputBuf . emplace_back ( bufW , IpcBufferType : : W ) ;
outputBuf . emplace_back ( bufW , IpcBufferType : : W ) ;
Framebuffer and NativeActivity
What was added:
* Framebuffer
* NativeActivity
* NV Services
* IOCTL Handler
* NV Devices:
* * /dev/nvmap - 0xC0080101, 0xC0080103, 0xC0200104, 0xC0180105, 0xC00C0109, 0xC008010E
* * /dev/nvhost-as-gpu
* * /dev/nvhost-channel - 0x40044801, 0xC0104809, 0xC010480B, 0xC018480C, 0x4004480D, 0xC020481A, 0x40084714
* * /dev/nvhost-ctrl
* * /dev/nvhost-ctrl-gpu - 0x80044701, 0x80284702, 0xC0184706, 0xC0B04705, 0x80084714
* SVCs:
* * SetMemoryAttribute
* * CreateTransferMemory
* * ResetSignal
* * GetSystemTick
* Addition of Compact Logger
What was fixed:
* SVCs:
* * SetHeapSize
* * SetMemoryAttribute
* * QueryMemory
* A release build would not set CMAKE_BUILD_TYPE to "RELEASE"
* The logger code was simplified
2019-11-13 21:09:31 +01:00
state . logger - > Debug ( " Buf W #{} AD: 0x{:X} SZ: 0x{:X} " , index , u64 ( bufW - > Address ( ) ) , u16 ( bufW - > Size ( ) ) ) ;
}
2020-02-15 10:38:17 +01:00
pointer + = sizeof ( BufferDescriptorABW ) ;
2019-09-24 22:54:27 +02:00
}
2020-04-17 23:19:19 +02:00
auto offset = reinterpret_cast < u64 > ( pointer ) - reinterpret_cast < u64 > ( tls ) ; // We calculate the relative offset as the absolute one might differ
auto padding = util : : AlignUp ( offset , constant : : IpcPaddingSum ) - offset ; // Calculate the amount of padding at the front
2020-02-15 10:38:17 +01:00
pointer + = padding ;
2019-09-24 22:54:27 +02:00
2019-11-14 20:06:38 +01:00
if ( isDomain & & ( header - > type = = CommandType : : Request ) ) {
2020-02-15 10:38:17 +01:00
domain = reinterpret_cast < DomainHeaderRequest * > ( pointer ) ;
pointer + = sizeof ( DomainHeaderRequest ) ;
2019-09-24 22:54:27 +02:00
2020-02-15 10:38:17 +01:00
payload = reinterpret_cast < PayloadHeader * > ( pointer ) ;
pointer + = sizeof ( PayloadHeader ) ;
2019-09-24 22:54:27 +02:00
2020-02-15 10:38:17 +01:00
cmdArg = pointer ;
2019-11-14 20:06:38 +01:00
cmdArgSz = domain - > payloadSz - sizeof ( PayloadHeader ) ;
2020-02-15 10:38:17 +01:00
pointer + = domain - > payloadSz ;
2019-09-24 22:54:27 +02:00
2020-04-17 23:19:19 +02:00
for ( u8 index = 0 ; domain - > inputCount > index ; index + + ) {
2020-03-25 18:59:37 +01:00
domainObjects . push_back ( * reinterpret_cast < KHandle * > ( pointer ) ) ;
pointer + = sizeof ( KHandle ) ;
2019-09-24 22:54:27 +02:00
}
} else {
2020-02-15 10:38:17 +01:00
payload = reinterpret_cast < PayloadHeader * > ( pointer ) ;
pointer + = sizeof ( PayloadHeader ) ;
2019-09-24 22:54:27 +02:00
2020-02-15 10:38:17 +01:00
cmdArg = pointer ;
2020-04-17 23:19:19 +02:00
cmdArgSz = ( header - > rawSize * sizeof ( u32 ) ) - ( constant : : IpcPaddingSum + sizeof ( PayloadHeader ) ) ;
2020-02-15 10:38:17 +01:00
pointer + = cmdArgSz ;
2019-09-24 22:54:27 +02:00
}
2019-11-23 19:48:22 +01:00
payloadOffset = cmdArg ;
2020-04-17 23:19:19 +02:00
if ( payload - > magic ! = util : : MakeMagic < u32 > ( " SFCI " ) & & header - > type ! = CommandType : : Control ) // SFCI is the magic in received IPC messages
Framebuffer and NativeActivity
What was added:
* Framebuffer
* NativeActivity
* NV Services
* IOCTL Handler
* NV Devices:
* * /dev/nvmap - 0xC0080101, 0xC0080103, 0xC0200104, 0xC0180105, 0xC00C0109, 0xC008010E
* * /dev/nvhost-as-gpu
* * /dev/nvhost-channel - 0x40044801, 0xC0104809, 0xC010480B, 0xC018480C, 0x4004480D, 0xC020481A, 0x40084714
* * /dev/nvhost-ctrl
* * /dev/nvhost-ctrl-gpu - 0x80044701, 0x80284702, 0xC0184706, 0xC0B04705, 0x80084714
* SVCs:
* * SetMemoryAttribute
* * CreateTransferMemory
* * ResetSignal
* * GetSystemTick
* Addition of Compact Logger
What was fixed:
* SVCs:
* * SetHeapSize
* * SetMemoryAttribute
* * QueryMemory
* A release build would not set CMAKE_BUILD_TYPE to "RELEASE"
* The logger code was simplified
2019-11-13 21:09:31 +01:00
state . logger - > Debug ( " Unexpected Magic in PayloadHeader: 0x{:X} " , u32 ( payload - > magic ) ) ;
2020-04-17 23:19:19 +02:00
pointer + = constant : : IpcPaddingSum - padding ;
2019-09-24 22:54:27 +02:00
2019-11-14 20:06:38 +01:00
if ( header - > cFlag = = BufferCFlag : : SingleDescriptor ) {
2020-02-15 10:38:17 +01:00
auto bufC = reinterpret_cast < BufferDescriptorC * > ( pointer ) ;
2019-11-23 19:48:22 +01:00
if ( bufC - > address ) {
outputBuf . emplace_back ( bufC ) ;
state . logger - > Debug ( " Buf C: AD: 0x{:X} SZ: 0x{:X} " , u64 ( bufC - > address ) , u16 ( bufC - > size ) ) ;
}
2019-11-14 20:06:38 +01:00
} else if ( header - > cFlag > BufferCFlag : : SingleDescriptor ) {
2020-04-17 23:19:19 +02:00
for ( u8 index = 0 ; ( static_cast < u8 > ( header - > cFlag ) - 2 ) > index ; index + + ) { // (cFlag - 2) C descriptors are present
2020-02-15 10:38:17 +01:00
auto bufC = reinterpret_cast < BufferDescriptorC * > ( pointer ) ;
Framebuffer and NativeActivity
What was added:
* Framebuffer
* NativeActivity
* NV Services
* IOCTL Handler
* NV Devices:
* * /dev/nvmap - 0xC0080101, 0xC0080103, 0xC0200104, 0xC0180105, 0xC00C0109, 0xC008010E
* * /dev/nvhost-as-gpu
* * /dev/nvhost-channel - 0x40044801, 0xC0104809, 0xC010480B, 0xC018480C, 0x4004480D, 0xC020481A, 0x40084714
* * /dev/nvhost-ctrl
* * /dev/nvhost-ctrl-gpu - 0x80044701, 0x80284702, 0xC0184706, 0xC0B04705, 0x80084714
* SVCs:
* * SetMemoryAttribute
* * CreateTransferMemory
* * ResetSignal
* * GetSystemTick
* Addition of Compact Logger
What was fixed:
* SVCs:
* * SetHeapSize
* * SetMemoryAttribute
* * QueryMemory
* A release build would not set CMAKE_BUILD_TYPE to "RELEASE"
* The logger code was simplified
2019-11-13 21:09:31 +01:00
if ( bufC - > address ) {
2019-11-23 19:48:22 +01:00
outputBuf . emplace_back ( bufC ) ;
Framebuffer and NativeActivity
What was added:
* Framebuffer
* NativeActivity
* NV Services
* IOCTL Handler
* NV Devices:
* * /dev/nvmap - 0xC0080101, 0xC0080103, 0xC0200104, 0xC0180105, 0xC00C0109, 0xC008010E
* * /dev/nvhost-as-gpu
* * /dev/nvhost-channel - 0x40044801, 0xC0104809, 0xC010480B, 0xC018480C, 0x4004480D, 0xC020481A, 0x40084714
* * /dev/nvhost-ctrl
* * /dev/nvhost-ctrl-gpu - 0x80044701, 0x80284702, 0xC0184706, 0xC0B04705, 0x80084714
* SVCs:
* * SetMemoryAttribute
* * CreateTransferMemory
* * ResetSignal
* * GetSystemTick
* Addition of Compact Logger
What was fixed:
* SVCs:
* * SetHeapSize
* * SetMemoryAttribute
* * QueryMemory
* A release build would not set CMAKE_BUILD_TYPE to "RELEASE"
* The logger code was simplified
2019-11-13 21:09:31 +01:00
state . logger - > Debug ( " Buf C #{} AD: 0x{:X} SZ: 0x{:X} " , index , u64 ( bufC - > address ) , u16 ( bufC - > size ) ) ;
}
2020-02-15 10:38:17 +01:00
pointer + = sizeof ( BufferDescriptorC ) ;
2019-09-24 22:54:27 +02:00
}
}
2019-11-14 20:06:38 +01:00
if ( header - > type = = CommandType : : Request ) {
2019-11-23 19:48:22 +01:00
state . logger - > Debug ( " Header: Input No: {}, Output No: {}, Raw Size: {} " , inputBuf . size ( ) , outputBuf . size ( ) , u64 ( cmdArgSz ) ) ;
2019-11-14 20:06:38 +01:00
if ( header - > handleDesc )
state . logger - > Debug ( " Handle Descriptor: Send PID: {}, Copy Count: {}, Move Count: {} " , bool ( handleDesc - > sendPid ) , u32 ( handleDesc - > copyCount ) , u32 ( handleDesc - > moveCount ) ) ;
if ( isDomain )
state . logger - > Debug ( " Domain Header: Command: {}, Input Object Count: {}, Object ID: 0x{:X} " , domain - > command , domain - > inputCount , domain - > objectId ) ;
state . logger - > Debug ( " Command ID: 0x{:X} " , u32 ( payload - > value ) ) ;
}
2019-09-24 22:54:27 +02:00
}
IpcResponse : : IpcResponse ( bool isDomain , const DeviceState & state ) : isDomain ( isDomain ) , state ( state ) { }
2019-11-23 19:48:22 +01:00
void IpcResponse : : WriteResponse ( ) {
2020-02-15 10:38:17 +01:00
auto tls = state . process - > GetPointer < u8 > ( state . thread - > tls ) ;
u8 * pointer = tls ;
2020-03-25 18:59:37 +01:00
2020-04-17 23:19:19 +02:00
memset ( tls , 0 , constant : : TlsIpcSize ) ;
2020-02-15 10:38:17 +01:00
auto header = reinterpret_cast < CommandHeader * > ( pointer ) ;
2020-04-17 23:19:19 +02:00
header - > rawSize = static_cast < u32 > ( ( sizeof ( PayloadHeader ) + argVec . size ( ) + ( domainObjects . size ( ) * sizeof ( KHandle ) ) + constant : : IpcPaddingSum + ( isDomain ? sizeof ( DomainHeaderRequest ) : 0 ) ) / sizeof ( u32 ) ) ; // Size is in 32-bit units because Nintendo
2019-11-14 20:06:38 +01:00
header - > handleDesc = ( ! copyHandles . empty ( ) | | ! moveHandles . empty ( ) ) ;
2020-02-15 10:38:17 +01:00
pointer + = sizeof ( CommandHeader ) ;
2019-09-24 22:54:27 +02:00
2019-11-14 20:06:38 +01:00
if ( header - > handleDesc ) {
2020-02-15 10:38:17 +01:00
auto handleDesc = reinterpret_cast < HandleDescriptor * > ( pointer ) ;
2019-11-14 20:06:38 +01:00
handleDesc - > copyCount = static_cast < u8 > ( copyHandles . size ( ) ) ;
handleDesc - > moveCount = static_cast < u8 > ( moveHandles . size ( ) ) ;
2020-02-15 10:38:17 +01:00
pointer + = sizeof ( HandleDescriptor ) ;
2019-09-24 22:54:27 +02:00
2020-04-17 23:19:19 +02:00
for ( auto copyHandle : copyHandles ) {
2020-03-25 18:59:37 +01:00
* reinterpret_cast < KHandle * > ( pointer ) = copyHandle ;
pointer + = sizeof ( KHandle ) ;
2019-09-24 22:54:27 +02:00
}
2020-04-17 23:19:19 +02:00
for ( auto moveHandle : moveHandles ) {
2020-03-25 18:59:37 +01:00
* reinterpret_cast < KHandle * > ( pointer ) = moveHandle ;
pointer + = sizeof ( KHandle ) ;
2019-09-24 22:54:27 +02:00
}
}
2020-04-17 23:19:19 +02:00
auto offset = reinterpret_cast < u64 > ( pointer ) - reinterpret_cast < u64 > ( tls ) ; // We calculate the relative offset as the absolute one might differ
auto padding = util : : AlignUp ( offset , constant : : IpcPaddingSum ) - offset ; // Calculate the amount of padding at the front
2020-02-15 10:38:17 +01:00
pointer + = padding ;
2019-09-24 22:54:27 +02:00
if ( isDomain ) {
2020-02-15 10:38:17 +01:00
auto domain = reinterpret_cast < DomainHeaderResponse * > ( pointer ) ;
2019-11-14 20:06:38 +01:00
domain - > outputCount = static_cast < u32 > ( domainObjects . size ( ) ) ;
2020-02-15 10:38:17 +01:00
pointer + = sizeof ( DomainHeaderResponse ) ;
2019-09-24 22:54:27 +02:00
}
2020-02-15 10:38:17 +01:00
auto payload = reinterpret_cast < PayloadHeader * > ( pointer ) ;
2020-04-17 23:19:19 +02:00
payload - > magic = util : : MakeMagic < u32 > ( " SFCO " ) ; // SFCO is the magic in IPC responses
2019-09-24 22:54:27 +02:00
payload - > version = 1 ;
payload - > value = errorCode ;
2020-02-15 10:38:17 +01:00
pointer + = sizeof ( PayloadHeader ) ;
2020-03-25 18:59:37 +01:00
2019-09-24 22:54:27 +02:00
if ( ! argVec . empty ( ) )
2020-04-17 23:19:19 +02:00
std : : memcpy ( pointer , argVec . data ( ) , argVec . size ( ) ) ;
2020-02-15 10:38:17 +01:00
pointer + = argVec . size ( ) ;
2019-09-24 22:54:27 +02:00
Framebuffer and NativeActivity
What was added:
* Framebuffer
* NativeActivity
* NV Services
* IOCTL Handler
* NV Devices:
* * /dev/nvmap - 0xC0080101, 0xC0080103, 0xC0200104, 0xC0180105, 0xC00C0109, 0xC008010E
* * /dev/nvhost-as-gpu
* * /dev/nvhost-channel - 0x40044801, 0xC0104809, 0xC010480B, 0xC018480C, 0x4004480D, 0xC020481A, 0x40084714
* * /dev/nvhost-ctrl
* * /dev/nvhost-ctrl-gpu - 0x80044701, 0x80284702, 0xC0184706, 0xC0B04705, 0x80084714
* SVCs:
* * SetMemoryAttribute
* * CreateTransferMemory
* * ResetSignal
* * GetSystemTick
* Addition of Compact Logger
What was fixed:
* SVCs:
* * SetHeapSize
* * SetMemoryAttribute
* * QueryMemory
* A release build would not set CMAKE_BUILD_TYPE to "RELEASE"
* The logger code was simplified
2019-11-13 21:09:31 +01:00
if ( isDomain ) {
for ( auto & domainObject : domainObjects ) {
2020-03-25 18:59:37 +01:00
* reinterpret_cast < KHandle * > ( pointer ) = domainObject ;
pointer + = sizeof ( KHandle ) ;
2019-09-24 22:54:27 +02:00
}
}
2019-11-14 20:06:38 +01:00
state . logger - > Debug ( " Output: Raw Size: {}, Command ID: 0x{:X}, Copy Handles: {}, Move Handles: {} " , u32 ( header - > rawSize ) , u32 ( payload - > value ) , copyHandles . size ( ) , moveHandles . size ( ) ) ;
Framebuffer and NativeActivity
What was added:
* Framebuffer
* NativeActivity
* NV Services
* IOCTL Handler
* NV Devices:
* * /dev/nvmap - 0xC0080101, 0xC0080103, 0xC0200104, 0xC0180105, 0xC00C0109, 0xC008010E
* * /dev/nvhost-as-gpu
* * /dev/nvhost-channel - 0x40044801, 0xC0104809, 0xC010480B, 0xC018480C, 0x4004480D, 0xC020481A, 0x40084714
* * /dev/nvhost-ctrl
* * /dev/nvhost-ctrl-gpu - 0x80044701, 0x80284702, 0xC0184706, 0xC0B04705, 0x80084714
* SVCs:
* * SetMemoryAttribute
* * CreateTransferMemory
* * ResetSignal
* * GetSystemTick
* Addition of Compact Logger
What was fixed:
* SVCs:
* * SetHeapSize
* * SetMemoryAttribute
* * QueryMemory
* A release build would not set CMAKE_BUILD_TYPE to "RELEASE"
* The logger code was simplified
2019-11-13 21:09:31 +01:00
}
2019-09-24 22:54:27 +02:00
}