mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-21 20:42:44 +02:00
Fixed gfx and parcel issues. Parcel logging adjustments, etc. Changed out_parcel to parcel_reply.
This commit is contained in:
parent
1d8c51f6fa
commit
80890a3b8e
@ -12,7 +12,7 @@ typedef struct {
|
|||||||
} parcelContext;
|
} parcelContext;
|
||||||
|
|
||||||
void parcelInitializeContext(parcelContext *ctx);
|
void parcelInitializeContext(parcelContext *ctx);
|
||||||
Result parcelTransact(binderSession *session, u32 code, parcelContext *in_parcel, parcelContext *out_parcel);
|
Result parcelTransact(binderSession *session, u32 code, parcelContext *in_parcel, parcelContext *reply_parcel);
|
||||||
|
|
||||||
void* parcelWriteData(parcelContext *ctx, void* data, size_t data_size);
|
void* parcelWriteData(parcelContext *ctx, void* data, size_t data_size);
|
||||||
void* parcelReadData(parcelContext *ctx, void* data, size_t data_size);
|
void* parcelReadData(parcelContext *ctx, void* data, size_t data_size);
|
||||||
|
@ -70,7 +70,7 @@ static Result _gfxGetNativeWindowID(u8 *buf, u64 size, s32 *out_ID) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Result _gfxDequeueBuffer() {
|
static Result _gfxDequeueBuffer() {
|
||||||
return gfxproducerDequeueBuffer(1, 1280, 720, 0, 0x300);
|
return gfxproducerDequeueBuffer(1, 1280, 720, 0, 0x300);//reply_parcel currently contains error(s), presumably due to nv not being initialized for this.
|
||||||
}
|
}
|
||||||
|
|
||||||
static Result _gfxQueueBuffer(s32 buf) {
|
static Result _gfxQueueBuffer(s32 buf) {
|
||||||
@ -94,7 +94,7 @@ static Result _gfxInit(viServiceType servicetype, const char *DisplayName, u32 L
|
|||||||
Result rc=0;
|
Result rc=0;
|
||||||
s32 tmp=0;
|
s32 tmp=0;
|
||||||
u32 i=0;
|
u32 i=0;
|
||||||
u64 *ptr64 = (u64*)g_gfxQueueBufferData;
|
u64 *ptr64 = (u64*)g_gfxBufferInitData;
|
||||||
|
|
||||||
if(g_gfxInitialized)return 0;
|
if(g_gfxInitialized)return 0;
|
||||||
|
|
||||||
@ -129,9 +129,9 @@ static Result _gfxInit(viServiceType servicetype, const char *DisplayName, u32 L
|
|||||||
if (R_SUCCEEDED(rc)) {
|
if (R_SUCCEEDED(rc)) {
|
||||||
for(i=0; i<2; i++) {
|
for(i=0; i<2; i++) {
|
||||||
g_gfxBufferInitData[0xa] = i;
|
g_gfxBufferInitData[0xa] = i;
|
||||||
g_gfxBufferInitData[0x20] = 0x3c0000*i;
|
g_gfxBufferInitData[0x21] = 0x3c0000*i;
|
||||||
ptr64[0x170>>3] = svcGetSystemTick();
|
ptr64[0x170>>3] = svcGetSystemTick();
|
||||||
rc = gfxproducerBufferInit(0, (u8*)g_gfxBufferInitData);
|
rc = gfxproducerBufferInit(i, (u8*)g_gfxBufferInitData);
|
||||||
if (R_FAILED(rc)) break;
|
if (R_FAILED(rc)) break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -141,10 +141,10 @@ static Result _gfxInit(viServiceType servicetype, const char *DisplayName, u32 L
|
|||||||
rc = _gfxDequeueBuffer();
|
rc = _gfxDequeueBuffer();
|
||||||
if (R_FAILED(rc)) break;
|
if (R_FAILED(rc)) break;
|
||||||
|
|
||||||
rc = gfxproducerRequestBuffer(i);
|
rc = gfxproducerRequestBuffer(i);//reply_parcel currently contains an error, presumably due to _gfxDequeueBuffer() failing as mentioned above.
|
||||||
if (R_FAILED(rc)) break;
|
if (R_FAILED(rc)) break;
|
||||||
|
|
||||||
rc = _gfxQueueBuffer(i);
|
rc = _gfxQueueBuffer(i);//reply_parcel currently contains the same error as gfxproducerRequestBuffer() above.
|
||||||
if (R_FAILED(rc)) break;
|
if (R_FAILED(rc)) break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -145,7 +145,7 @@ Result gfxproducerConnect(s32 api, bool producerControlledByApp) {
|
|||||||
rc = parcelTransact(g_gfxproducerBinderSession, CONNECT, &parcel, &parcel_reply);
|
rc = parcelTransact(g_gfxproducerBinderSession, CONNECT, &parcel, &parcel_reply);
|
||||||
if (R_FAILED(rc)) return rc;
|
if (R_FAILED(rc)) return rc;
|
||||||
|
|
||||||
//TODO: parse reply
|
//TODO: parse reply (contains 32bit width and height)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -11,12 +11,11 @@ void parcelInitializeContext(parcelContext *ctx) {
|
|||||||
ctx->ParcelData_maxsize = sizeof(ctx->ParcelData);
|
ctx->ParcelData_maxsize = sizeof(ctx->ParcelData);
|
||||||
}
|
}
|
||||||
|
|
||||||
//outparcel is allzero with this. This is presumably invalid?
|
Result parcelTransact(binderSession *session, u32 code, parcelContext *in_parcel, parcelContext *parcel_reply) {
|
||||||
Result parcelTransact(binderSession *session, u32 code, parcelContext *in_parcel, parcelContext *out_parcel) {
|
|
||||||
Result rc=0;
|
Result rc=0;
|
||||||
u8 inparcel[0x400];
|
u8 inparcel[0x400];
|
||||||
static u8 outparcel[0x1000];
|
u8 outparcel[0x400];
|
||||||
size_t outparcel_size = 0x1000;
|
size_t outparcel_size = sizeof(outparcel);
|
||||||
u32 *inparcel32 = (u32*)inparcel;
|
u32 *inparcel32 = (u32*)inparcel;
|
||||||
u32 *outparcel32 = (u32*)outparcel;
|
u32 *outparcel32 = (u32*)outparcel;
|
||||||
u32 ParcelDataSize = in_parcel->ParcelData_size;
|
u32 ParcelDataSize = in_parcel->ParcelData_size;
|
||||||
@ -42,24 +41,28 @@ Result parcelTransact(binderSession *session, u32 code, parcelContext *in_parcel
|
|||||||
if((size_t)outparcel32[2] >= outparcel_size || ((size_t)outparcel32[2])+((size_t)outparcel32[3]) >= outparcel_size) return MAKERESULT(MODULE_LIBNX, LIBNX_BADINPUT);
|
if((size_t)outparcel32[2] >= outparcel_size || ((size_t)outparcel32[2])+((size_t)outparcel32[3]) >= outparcel_size) return MAKERESULT(MODULE_LIBNX, LIBNX_BADINPUT);
|
||||||
if((size_t)outparcel32[0] >= outparcel_size || (size_t)outparcel32[3] >= outparcel_size) return MAKERESULT(MODULE_LIBNX, LIBNX_BADINPUT);
|
if((size_t)outparcel32[0] >= outparcel_size || (size_t)outparcel32[3] >= outparcel_size) return MAKERESULT(MODULE_LIBNX, LIBNX_BADINPUT);
|
||||||
|
|
||||||
memcpy(out_parcel->ParcelData, &outparcel[outparcel32[1]], outparcel32[0]);
|
memcpy(parcel_reply->ParcelData, &outparcel[outparcel32[1]], outparcel32[0]);
|
||||||
out_parcel->ParcelData_size = outparcel32[0];
|
parcel_reply->ParcelData_size = outparcel32[0];
|
||||||
|
|
||||||
/*memcpy(&parcel_reply_log[parcel_reply_log_size], out_parcel, outparcel_size);
|
/*if(parcel_reply_log_size + sizeof(inparcel) + outparcel_size <= sizeof(parcel_reply_log)) {
|
||||||
parcel_reply_log_size+= outparcel_size;*/
|
memcpy(&parcel_reply_log[parcel_reply_log_size], inparcel, sizeof(inparcel));
|
||||||
|
parcel_reply_log_size+= sizeof(inparcel);
|
||||||
|
memcpy(&parcel_reply_log[parcel_reply_log_size], outparcel, outparcel_size);
|
||||||
|
parcel_reply_log_size+= outparcel_size;
|
||||||
|
}*/
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* parcelWriteData(parcelContext *ctx, void* data, size_t data_size) {
|
void* parcelWriteData(parcelContext *ctx, void* data, size_t data_size) {
|
||||||
void* ptr = ctx->ParcelData;
|
void* ptr = &ctx->ParcelData[ctx->ParcelData_size];
|
||||||
|
|
||||||
if(data_size & BIT(31)) return NULL;
|
if(data_size & BIT(31)) return NULL;
|
||||||
data_size = (data_size+3) & ~3;
|
data_size = (data_size+3) & ~3;
|
||||||
|
|
||||||
if(ctx->ParcelData_size + data_size >= ctx->ParcelData_maxsize) return NULL;
|
if(ctx->ParcelData_size + data_size >= ctx->ParcelData_maxsize) return NULL;
|
||||||
|
|
||||||
if(data)memcpy(&ctx->ParcelData[ctx->ParcelData_size], data, data_size);
|
if(data)memcpy(ptr, data, data_size);
|
||||||
ctx->ParcelData_size+= data_size;
|
ctx->ParcelData_size+= data_size;
|
||||||
|
|
||||||
return ptr;
|
return ptr;
|
||||||
|
Loading…
Reference in New Issue
Block a user