From db2a32154f6ae29477812692a286481e059e92cb Mon Sep 17 00:00:00 2001 From: Lucas Fryzek Date: Wed, 7 Aug 2024 21:45:24 +0100 Subject: drv: Add ccb buffer and pds data Data still needs to be patched at runtime to point to the correct addresses. --- src/drv.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'src/drv.c') diff --git a/src/drv.c b/src/drv.c index e5737e8..e3252af 100644 --- a/src/drv.c +++ b/src/drv.c @@ -31,6 +31,16 @@ #include +#include + +/* This changes with buffer addresses and needs to be patched */ +#include "ccb_buffer.h" +struct CCBEntry *ccb_entry = (struct CCBEntry *)ccb_buffer; + +/* This changes with buffer addresses and needs to be patched */ +#include "pds_pixel_code_data.h" +uint32_t *pds_pcd = (uint32_t *)pds_pixel_code_data; + #define UNUSED(x) (void)x struct mem_alloc { @@ -49,11 +59,13 @@ struct driver_state { PVRSRV_HEAP_INFO kernel_heap; PVRSRV_HEAP_INFO perctx_3d_heap; PVRSRV_HEAP_INFO ta_data_heap; + PVRSRV_HEAP_INFO pds_pixel_code_data_heap; struct mem_alloc ccb_buffer; struct mem_alloc kernel_buffer_2; struct mem_alloc kernel_buffer_3; struct mem_alloc perctx_3d_buffer; struct mem_alloc ta_data_buffer; + struct mem_alloc pds_pixel_code_data_0; IMG_HANDLE hw_render_ctx; IMG_DEV_VIRTADDR hw_render_ctx_addr; @@ -293,6 +305,10 @@ static void get_dev_mem_heapinfo(struct driver_state *state) { if (out.sHeapInfo[i].ui32HeapID == HEAP_ID( PVRSRV_DEVICE_TYPE_SGX, SGX_PERCONTEXT_3DPARAMETERS_HEAP_ID)) { state->perctx_3d_heap = out.sHeapInfo[i]; } + + if (out.sHeapInfo[i].ui32HeapID == HEAP_ID( PVRSRV_DEVICE_TYPE_SGX, SGX_PDSPIXEL_CODEDATA_HEAP_ID)) { + state->pds_pixel_code_data_heap = out.sHeapInfo[i]; + } } assert(state->kernel_heap.ui32HeapID != 0); @@ -396,6 +412,15 @@ static void allocate_memory(struct driver_state *state) { .uAlignment = 0x40, }; state->ta_data_buffer = allocate_memobj(state, &alloc_ta_data_buffer); + + PVRSRV_BRIDGE_IN_ALLOCDEVICEMEM alloc_pds_pixel_code_data_0 = { + .hDevCookie = state->dev_cookie, + .hDevMemHeap = state->pds_pixel_code_data_heap.hDevMemHeap, + .ui32Attribs = PVRSRV_MEM_READ | PVRSRV_MEM_WRITE | PVRSRV_MEM_NO_SYNCOBJ, + .uSize = 0x8000, + .uAlignment = 0x8000, + }; + state->pds_pixel_code_data_0 = allocate_memobj(state, &alloc_pds_pixel_code_data_0); } static void register_hw_render_ctx(struct driver_state *state) { @@ -447,6 +472,26 @@ static void register_hw_render_ctx(struct driver_state *state) { state->hw_render_ctx_addr = out.sHWRenderContextDevVAddr; } +void patch_memory(struct driver_state *state) { + /* Patch PDS Pixel Code Data 0 buffer */ + //pds_pcd[0] = ; + + uint32_t modified_pds_addr = + ((state->pds_pixel_code_data_0.dev_mem.sClientMemInfo.sDevVAddr.uiAddr & 0xffff) >> 8); + ccb_entry->pds_pixel_code_data_0.uiAddr = + 0x4000000 | modified_pds_addr; + ccb_entry->pds_pixel_code_data_0_4.uiAddr = + 0x8000000 | (modified_pds_addr + 4); + + ccb_entry->dev_addr_0.uiAddr = + state->kernel_buffer_3.dev_mem.sClientMemInfo.sDevVAddr.uiAddr; + +#if 0 + ccb_entry->dev_addr_2.uiAddr = + state->kernel_buffer_4.dev_mem.sClientMemInfo.sDevVAddr.uiAddr; +#endif +} + int main(int argc, char *argv[]) { UNUSED(argc); UNUSED(argv); @@ -479,6 +524,8 @@ int main(int argc, char *argv[]) { allocate_memory(&state); register_hw_render_ctx(&state); + patch_memory(&state); + close(state.fd); return 0; -- cgit