From a10290ceb550ce36bdb61e2957c3683bcd5988fc Mon Sep 17 00:00:00 2001 From: Hoegeun Kwon Date: Mon, 11 Jan 2021 15:15:55 +0900 Subject: [PATCH 01/16] packaging: Remove define debug_package Delete the debug package nil. A problem occurs when the cmake version is upgraded. Change-Id: I65190223d728492ad83f0cebfa7cb6b926d9c5bf Signed-off-by: Hoegeun Kwon --- packaging/linux-amlogic.spec | 1 - 1 file changed, 1 deletion(-) diff --git a/packaging/linux-amlogic.spec b/packaging/linux-amlogic.spec index c06dd24..fb61b40 100644 --- a/packaging/linux-amlogic.spec +++ b/packaging/linux-amlogic.spec @@ -1,6 +1,5 @@ # Ignore double dash in version for rpmbuild %define _wrong_version_format_terminate_build 0 -%define debug_package %{nil} %ifarch aarch64 %define buildarch arm64 -- 2.7.4 From 9ed38b396065f82921fb03f97e3fb009301f7464 Mon Sep 17 00:00:00 2001 From: Hoegeun Kwon Date: Mon, 11 Jan 2021 17:16:13 +0900 Subject: [PATCH 02/16] NPU: Update DDK Version to 6.4.3CB This DDK v6.4.3 from vendor kernel tree for support npu. commit: f5d5919889be (tag: khadas-vims-v0.9.7-release) Update DDK Version to 6.4.3CB url: https://github.com/khadas/linux/commit/f5d5919889becec2c0988bc6a6aa839012982e8a Change-Id: I4ec74460ccb90a87158abe47c1b08cdeeed5dcdf Signed-off-by: yan Signed-off-by: Hoegeun Kwon --- drivers/amlogic/npu/Kbuild | 4 +- .../amlogic/npu/inc/drvi/gc_vsc_drvi_interface.h | 19 +- .../amlogic/npu/inc/drvi/gc_vsc_drvi_lib_link.h | 12 +- .../npu/inc/drvi/gc_vsc_drvi_program_profile.h | 67 +- .../npu/inc/drvi/gc_vsc_drvi_shader_profile.h | 36 +- drivers/amlogic/npu/inc/gc_feature_database.h | 1948 +-- drivers/amlogic/npu/inc/gc_hal.h | 37 +- drivers/amlogic/npu/inc/gc_hal_base.h | 41 +- drivers/amlogic/npu/inc/gc_hal_cl.h | 35 + drivers/amlogic/npu/inc/gc_hal_driver.h | 1338 +- drivers/amlogic/npu/inc/gc_hal_driver_vg.h | 225 +- drivers/amlogic/npu/inc/gc_hal_eglplatform.h | 2 +- drivers/amlogic/npu/inc/gc_hal_engine.h | 9 +- drivers/amlogic/npu/inc/gc_hal_engine_vg.h | 2 +- drivers/amlogic/npu/inc/gc_hal_enum.h | 31 +- drivers/amlogic/npu/inc/gc_hal_options.h | 21 +- drivers/amlogic/npu/inc/gc_hal_priv.h | 15 + drivers/amlogic/npu/inc/gc_hal_profiler.h | 170 +- drivers/amlogic/npu/inc/gc_hal_raster.h | 2 +- drivers/amlogic/npu/inc/gc_hal_rename.h | 182 - drivers/amlogic/npu/inc/gc_hal_resource.h | 27 - drivers/amlogic/npu/inc/gc_hal_types.h | 1098 +- drivers/amlogic/npu/inc/gc_hal_version.h | 6 +- drivers/amlogic/npu/inc/gc_hal_vg.h | 4 +- drivers/amlogic/npu/inc/gc_hal_vx.h | 18 +- .../npu/inc/old_impl/gc_vsc_old_drvi_interface.h | 60 +- drivers/amlogic/npu/inc/old_impl/gc_vsc_old_gcsl.h | 74 +- .../shared/{gc_hal_base.h => gc_hal_base_shared.h} | 0 .../{gc_hal_driver.h => gc_hal_driver_shared.h} | 193 +- ...c_hal_driver_vg.h => gc_hal_driver_vg_shared.h} | 6 +- .../shared/{gc_hal_enum.h => gc_hal_enum_shared.h} | 62 +- ...{gc_hal_profiler.h => gc_hal_profiler_shared.h} | 120 + .../{gc_hal_types.h => gc_hal_types_shared.h} | 9 +- .../inc/shared/{gc_hal_vg.h => gc_hal_vg_shared.h} | 0 drivers/amlogic/npu/kernel/Android.mk | 0 drivers/amlogic/npu/kernel/arch/cebuild/makefile | 0 drivers/amlogic/npu/kernel/arch/cebuild/sources | 0 .../npu/kernel/arch/gc_hal_kernel_context.c | 4472 ++++--- .../npu/kernel/arch/gc_hal_kernel_context.h | 20 +- .../npu/kernel/arch/gc_hal_kernel_hardware.c | 523 +- .../npu/kernel/arch/gc_hal_kernel_hardware.h | 4 + .../npu/kernel/arch/gc_hal_kernel_hardware_func.c | 12347 +++++++------------ .../npu/kernel/arch/gc_hal_kernel_hardware_func.h | 75 +- .../arch/gc_hal_kernel_hardware_func_flop_reset.c | 7025 +++++++++++ .../gc_hal_kernel_hardware_func_flop_reset.h} | 39 +- .../kernel/arch/gc_hal_kernel_hardware_func_ppu.h | 1157 ++ .../kernel/arch/gc_hal_kernel_hardware_func_usc.h | 1724 +++ drivers/amlogic/npu/kernel/arch/makefile.linux | 1 + drivers/amlogic/npu/kernel/cebuild/makefile | 0 drivers/amlogic/npu/kernel/cebuild/sources | 2 +- drivers/amlogic/npu/kernel/gc_hal_kernel.c | 361 +- drivers/amlogic/npu/kernel/gc_hal_kernel.h | 69 +- drivers/amlogic/npu/kernel/gc_hal_kernel_command.c | 133 +- drivers/amlogic/npu/kernel/gc_hal_kernel_db.c | 58 + drivers/amlogic/npu/kernel/gc_hal_kernel_event.c | 115 +- drivers/amlogic/npu/kernel/gc_hal_kernel_mmu.c | 85 +- drivers/amlogic/npu/kernel/gc_hal_kernel_precomp.h | 2 +- .../amlogic/npu/kernel/gc_hal_kernel_preemption.c | 1495 +++ .../amlogic/npu/kernel/gc_hal_kernel_preemption.h | 274 + .../npu/kernel/gc_hal_kernel_video_memory.c | 117 +- .../amlogic/npu/kernel/inc/gc_feature_database.h | 1948 +-- drivers/amlogic/npu/kernel/inc/gc_hal.h | 37 +- drivers/amlogic/npu/kernel/inc/gc_hal_base.h | 41 +- drivers/amlogic/npu/kernel/inc/gc_hal_driver.h | 1340 +- drivers/amlogic/npu/kernel/inc/gc_hal_driver_vg.h | 227 +- drivers/amlogic/npu/kernel/inc/gc_hal_drm.h | 2 + .../amlogic/npu/kernel/inc/gc_hal_eglplatform.h | 2 +- drivers/amlogic/npu/kernel/inc/gc_hal_engine.h | 9 +- drivers/amlogic/npu/kernel/inc/gc_hal_engine_vg.h | 2 +- drivers/amlogic/npu/kernel/inc/gc_hal_enum.h | 31 +- .../amlogic/npu/kernel/inc/gc_hal_kernel_buffer.h | 94 +- drivers/amlogic/npu/kernel/inc/gc_hal_options.h | 21 +- drivers/amlogic/npu/kernel/inc/gc_hal_profiler.h | 170 +- drivers/amlogic/npu/kernel/inc/gc_hal_raster.h | 2 +- drivers/amlogic/npu/kernel/inc/gc_hal_rename.h | 224 - drivers/amlogic/npu/kernel/inc/gc_hal_types.h | 1100 +- drivers/amlogic/npu/kernel/inc/gc_hal_version.h | 6 +- drivers/amlogic/npu/kernel/inc/gc_hal_vg.h | 4 +- .../shared/{gc_hal_base.h => gc_hal_base_shared.h} | 0 .../{gc_hal_driver.h => gc_hal_driver_shared.h} | 193 +- ...c_hal_driver_vg.h => gc_hal_driver_vg_shared.h} | 6 +- .../shared/{gc_hal_enum.h => gc_hal_enum_shared.h} | 62 +- ...{gc_hal_profiler.h => gc_hal_profiler_shared.h} | 120 + .../{gc_hal_types.h => gc_hal_types_shared.h} | 9 +- .../inc/shared/{gc_hal_vg.h => gc_hal_vg_shared.h} | 0 drivers/amlogic/npu/os/libGAL.def.mak | 6 +- .../default/gc_hal_kernel_allocator_dma.c | 14 +- .../default/gc_hal_kernel_allocator_gfp.c | 20 +- .../default/gc_hal_kernel_allocator_reserved_mem.c | 121 +- .../npu/os/linux/kernel/gc_hal_kernel_allocator.h | 1 + .../npu/os/linux/kernel/gc_hal_kernel_device.c | 1110 +- .../npu/os/linux/kernel/gc_hal_kernel_device.h | 14 + .../npu/os/linux/kernel/gc_hal_kernel_driver.c | 405 +- .../npu/os/linux/kernel/gc_hal_kernel_linux.c | 74 +- .../npu/os/linux/kernel/gc_hal_kernel_linux.h | 2 +- .../amlogic/npu/os/linux/kernel/gc_hal_kernel_os.c | 311 +- .../amlogic/npu/os/linux/kernel/gc_hal_kernel_os.h | 7 + .../npu/os/linux/kernel/gc_hal_kernel_platform.h | 73 + .../amlogic/gc_hal_kernel_platform_amlogic.c | 167 +- .../amlogic/gc_hal_kernel_platform_amlogic.config | 0 .../amlogic/gc_hal_kernel_platform_c308x.c | 489 +- .../amlogic/gc_hal_kernel_platform_c308x.config | 0 .../amlogic/gc_hal_kernel_platform_pico.config | 0 .../platform/amlogic/gc_hal_kernel_platform_vim3.c | 179 + .../amlogic/gc_hal_kernel_platform_vim3.config | 4 + .../default/gc_hal_kernel_platform_default.config | 0 drivers/amlogic/npu/os/linux/user/Android.mk | 62 - .../npu/os/linux/user/bin_r/gc_hal_user_debug.d | 33 - .../npu/os/linux/user/bin_r/gc_hal_user_math.d | 34 - .../npu/os/linux/user/bin_r/gc_hal_user_os.d | 34 - .../user/bin_r/gc_hal_user_platform_default.d | 36 - .../amlogic/npu/os/linux/user/gc_hal_user_debug.c | 2103 ---- .../amlogic/npu/os/linux/user/gc_hal_user_debug.h | 23 - .../amlogic/npu/os/linux/user/gc_hal_user_linux.h | 32 - .../amlogic/npu/os/linux/user/gc_hal_user_math.c | 587 - .../amlogic/npu/os/linux/user/gc_hal_user_math.h | 120 - drivers/amlogic/npu/os/linux/user/gc_hal_user_os.c | 7375 ----------- .../npu/os/linux/user/gc_hal_user_os_atomic.h | 59 - .../npu/os/linux/user/gc_hal_user_os_memory.h | 146 - .../npu/os/linux/user/gc_hal_user_platform.h | 61 - drivers/amlogic/npu/os/linux/user/makefile.linux | 109 - .../default/gc_hal_user_platform_default.c | 28 - drivers/amlogic/npu/security/Android.mk | 47 - drivers/amlogic/npu/security/Makefile | 64 - drivers/amlogic/npu/security/gc_hal_ta.c | 368 - drivers/amlogic/npu/security/gc_hal_ta.h | 472 - drivers/amlogic/npu/security/gc_hal_ta_command.c | 522 - drivers/amlogic/npu/security/gc_hal_ta_hardware.c | 2769 ----- drivers/amlogic/npu/security/gc_hal_ta_mmu.c | 1018 -- .../npu/security/os/linux/gc_hal_ta_driver.c | 187 - .../npu/security/os/linux/gc_hal_ta_linux.c | 313 - .../npu/security/os/linux/gc_hal_ta_linux.h | 31 - drivers/amlogic/npu/security_v1/gc_hal_ta.c | 2 +- drivers/amlogic/npu/security_v1/gc_hal_ta.h | 2 +- .../amlogic/npu/security_v1/gc_hal_ta_hardware.c | 2 +- .../amlogic/npu/security_v1/gc_hal_ta_hardware.h | 2 +- drivers/amlogic/npu/security_v1/gc_hal_ta_mmu.c | 2 +- 137 files changed, 26595 insertions(+), 34666 deletions(-) delete mode 100644 drivers/amlogic/npu/inc/gc_hal_rename.h delete mode 100644 drivers/amlogic/npu/inc/gc_hal_resource.h rename drivers/amlogic/npu/inc/shared/{gc_hal_base.h => gc_hal_base_shared.h} (100%) rename drivers/amlogic/npu/inc/shared/{gc_hal_driver.h => gc_hal_driver_shared.h} (86%) rename drivers/amlogic/npu/inc/shared/{gc_hal_driver_vg.h => gc_hal_driver_vg_shared.h} (98%) rename drivers/amlogic/npu/inc/shared/{gc_hal_enum.h => gc_hal_enum_shared.h} (96%) rename drivers/amlogic/npu/inc/shared/{gc_hal_profiler.h => gc_hal_profiler_shared.h} (65%) rename drivers/amlogic/npu/inc/shared/{gc_hal_types.h => gc_hal_types_shared.h} (99%) rename drivers/amlogic/npu/inc/shared/{gc_hal_vg.h => gc_hal_vg_shared.h} (100%) mode change 100644 => 100755 drivers/amlogic/npu/kernel/Android.mk mode change 100644 => 100755 drivers/amlogic/npu/kernel/arch/cebuild/makefile mode change 100644 => 100755 drivers/amlogic/npu/kernel/arch/cebuild/sources create mode 100644 drivers/amlogic/npu/kernel/arch/gc_hal_kernel_hardware_func_flop_reset.c rename drivers/amlogic/npu/kernel/{inc/gc_hal_resource.h => arch/gc_hal_kernel_hardware_func_flop_reset.h} (76%) create mode 100644 drivers/amlogic/npu/kernel/arch/gc_hal_kernel_hardware_func_ppu.h create mode 100644 drivers/amlogic/npu/kernel/arch/gc_hal_kernel_hardware_func_usc.h mode change 100644 => 100755 drivers/amlogic/npu/kernel/cebuild/makefile mode change 100644 => 100755 drivers/amlogic/npu/kernel/cebuild/sources create mode 100644 drivers/amlogic/npu/kernel/gc_hal_kernel_preemption.c create mode 100644 drivers/amlogic/npu/kernel/gc_hal_kernel_preemption.h delete mode 100644 drivers/amlogic/npu/kernel/inc/gc_hal_rename.h rename drivers/amlogic/npu/kernel/inc/shared/{gc_hal_base.h => gc_hal_base_shared.h} (100%) rename drivers/amlogic/npu/kernel/inc/shared/{gc_hal_driver.h => gc_hal_driver_shared.h} (87%) rename drivers/amlogic/npu/kernel/inc/shared/{gc_hal_driver_vg.h => gc_hal_driver_vg_shared.h} (98%) rename drivers/amlogic/npu/kernel/inc/shared/{gc_hal_enum.h => gc_hal_enum_shared.h} (96%) rename drivers/amlogic/npu/kernel/inc/shared/{gc_hal_profiler.h => gc_hal_profiler_shared.h} (69%) rename drivers/amlogic/npu/kernel/inc/shared/{gc_hal_types.h => gc_hal_types_shared.h} (99%) rename drivers/amlogic/npu/kernel/inc/shared/{gc_hal_vg.h => gc_hal_vg_shared.h} (100%) mode change 100644 => 100755 drivers/amlogic/npu/os/libGAL.def.mak mode change 100644 => 100755 drivers/amlogic/npu/os/linux/kernel/platform/amlogic/gc_hal_kernel_platform_amlogic.config mode change 100644 => 100755 drivers/amlogic/npu/os/linux/kernel/platform/amlogic/gc_hal_kernel_platform_c308x.config mode change 100644 => 100755 drivers/amlogic/npu/os/linux/kernel/platform/amlogic/gc_hal_kernel_platform_pico.config create mode 100644 drivers/amlogic/npu/os/linux/kernel/platform/amlogic/gc_hal_kernel_platform_vim3.c create mode 100755 drivers/amlogic/npu/os/linux/kernel/platform/amlogic/gc_hal_kernel_platform_vim3.config mode change 100644 => 100755 drivers/amlogic/npu/os/linux/kernel/platform/default/gc_hal_kernel_platform_default.config delete mode 100644 drivers/amlogic/npu/os/linux/user/Android.mk delete mode 100644 drivers/amlogic/npu/os/linux/user/bin_r/gc_hal_user_debug.d delete mode 100644 drivers/amlogic/npu/os/linux/user/bin_r/gc_hal_user_math.d delete mode 100644 drivers/amlogic/npu/os/linux/user/bin_r/gc_hal_user_os.d delete mode 100644 drivers/amlogic/npu/os/linux/user/bin_r/gc_hal_user_platform_default.d delete mode 100644 drivers/amlogic/npu/os/linux/user/gc_hal_user_debug.c delete mode 100644 drivers/amlogic/npu/os/linux/user/gc_hal_user_debug.h delete mode 100644 drivers/amlogic/npu/os/linux/user/gc_hal_user_linux.h delete mode 100644 drivers/amlogic/npu/os/linux/user/gc_hal_user_math.c delete mode 100644 drivers/amlogic/npu/os/linux/user/gc_hal_user_math.h delete mode 100644 drivers/amlogic/npu/os/linux/user/gc_hal_user_os.c delete mode 100644 drivers/amlogic/npu/os/linux/user/gc_hal_user_os_atomic.h delete mode 100644 drivers/amlogic/npu/os/linux/user/gc_hal_user_os_memory.h delete mode 100644 drivers/amlogic/npu/os/linux/user/gc_hal_user_platform.h delete mode 100644 drivers/amlogic/npu/os/linux/user/makefile.linux delete mode 100644 drivers/amlogic/npu/os/linux/user/platform/default/gc_hal_user_platform_default.c delete mode 100644 drivers/amlogic/npu/security/Android.mk delete mode 100644 drivers/amlogic/npu/security/Makefile delete mode 100644 drivers/amlogic/npu/security/gc_hal_ta.c delete mode 100644 drivers/amlogic/npu/security/gc_hal_ta.h delete mode 100644 drivers/amlogic/npu/security/gc_hal_ta_command.c delete mode 100644 drivers/amlogic/npu/security/gc_hal_ta_hardware.c delete mode 100644 drivers/amlogic/npu/security/gc_hal_ta_mmu.c delete mode 100644 drivers/amlogic/npu/security/os/linux/gc_hal_ta_driver.c delete mode 100644 drivers/amlogic/npu/security/os/linux/gc_hal_ta_linux.c delete mode 100644 drivers/amlogic/npu/security/os/linux/gc_hal_ta_linux.h diff --git a/drivers/amlogic/npu/Kbuild b/drivers/amlogic/npu/Kbuild index 74b8c78..ee26059 100644 --- a/drivers/amlogic/npu/Kbuild +++ b/drivers/amlogic/npu/Kbuild @@ -128,10 +128,12 @@ OBJS += $(HAL_KERNEL_DIR)/gc_hal_kernel.o \ $(HAL_KERNEL_DIR)/gc_hal_kernel_mmu.o \ $(HAL_KERNEL_DIR)/gc_hal_kernel_video_memory.o \ $(HAL_KERNEL_DIR)/gc_hal_kernel_power.o \ - $(HAL_KERNEL_DIR)/gc_hal_kernel_security_v1.o + $(HAL_KERNEL_DIR)/gc_hal_kernel_security_v1.o \ + $(HAL_KERNEL_DIR)/gc_hal_kernel_preemption.o OBJS += $(ARCH_KERNEL_DIR)/gc_hal_kernel_context.o \ $(ARCH_KERNEL_DIR)/gc_hal_kernel_hardware.o \ + $(ARCH_KERNEL_DIR)/gc_hal_kernel_hardware_func_flop_reset.o \ $(ARCH_KERNEL_DIR)/gc_hal_kernel_hardware_async_fe.o \ $(ARCH_KERNEL_DIR)/gc_hal_kernel_hardware_mc_fe.o \ $(ARCH_KERNEL_DIR)/gc_hal_kernel_hardware_waitlink_fe.o \ diff --git a/drivers/amlogic/npu/inc/drvi/gc_vsc_drvi_interface.h b/drivers/amlogic/npu/inc/drvi/gc_vsc_drvi_interface.h index b86e3e9..9c45829 100644 --- a/drivers/amlogic/npu/inc/drvi/gc_vsc_drvi_interface.h +++ b/drivers/amlogic/npu/inc/drvi/gc_vsc_drvi_interface.h @@ -58,8 +58,18 @@ /* 0.0.1.35 Add skhp flag in VIR_Instruction */ /* 0.0.1.36 Add a function to patch clipDistance in GL VIR lib shader */ /* 0.0.1.37 Add the sampled image information on 03/11/2020 */ -#define gcdVIR_SHADER_BINARY_FILE_VERSION gcmCC(SHADER_64BITMODE, 0, 1, 37) -#define gcdVIR_PROGRAM_BINARY_FILE_VERSION gcmCC(SHADER_64BITMODE, 0, 1, 37) +/* 0.0.1.38 Saving the return variable to a argument 03/27/2020 */ +/* 0.0.1.39 Update the image addre for an image buffer 04/01/2020 */ +/* 0.0.1.40 Save the SPIR-V information to VIR shader 04/10/2020 */ +/* 0.0.1.41 Add a new opcode MOV_DUAL16 04/23/2020 */ +/* 0.0.1.42 Move SkpHp into the instruction flag 05/14/2020 */ +/* 0.0.1.43 Add a data precision in VIR_Symbol 05/14/2020 */ +/* 0.0.1.44 Add VIR_ModifierOrder in VIR_Operand on 05/14/2020 */ +/* 0.0.1.45 Add a new enumeration for VIR_SymFlagExt 05/15/2020 */ +/* 0.0.1.46 Add a minimum workGroupSize in VIR_ComputeLayout 05/19/2020 */ +/* 0.0.1.47 Save the HW specific attributes in VIR_Shader 05/26/2020 */ +#define gcdVIR_SHADER_BINARY_FILE_VERSION gcmCC(SHADER_64BITMODE, 0, 1, 47) +#define gcdVIR_PROGRAM_BINARY_FILE_VERSION gcmCC(SHADER_64BITMODE, 0, 1, 47) #if !defined(gcdTARGETHOST_BIGENDIAN) #define gcdTARGETHOST_BIGENDIAN 0 /* default host little endian, to change the @@ -804,6 +814,7 @@ typedef struct _VSC_HW_CONFIG gctUINT psSamplerNoBaseInInstruction; gctFLOAT minPointSize; gctFLOAT maxPointSize; + gctUINT maxTcsOutPatchVectors; /* Caps for workGroupSize. */ gctUINT initWorkGroupSizeToCalcRegCount; @@ -893,6 +904,10 @@ typedef gcsGLSLCaps VSC_GL_API_CONFIG, *PVSC_GL_API_CONFIG; #define VSC_COMPILER_FLAG_USE_VSC_IMAGE_DESC 0x00020000 #define VSC_COMPILER_FLAG_ENABLE_MULTI_GPU 0x00040000 #define VSC_COMPILER_FLAG_DISABLE_IR_DUMP 0x00080000 /* used by driver to disable patch lib IR dump */ +#define VSC_COMPILER_FLAG_ADD_GLOBAL_OFFSET 0x00100000 /* gl_GlobalInvocationID = gl_GlobalInvocationID + #global_offset. */ +#define VSC_COMPILER_FLAG_ENABLE_DUAL16_FOR_VK 0x00200000 /* It is a temp option to enable dual16 for vulkan. we need to remove after verify all vulkan cases. */ +#define VSC_COMPILER_FLAG_USE_CONST_REG_FOR_UBO 0x00400000 +#define VSC_COMPILER_FLAG_FORCE_GEN_FLOAT_MAD 0x00800000 /* Force generate a floating MAD, no matter if HW can support it. */ #define VSC_COMPILER_FLAG_COMPILE_FULL_LEVELS 0x0000000F diff --git a/drivers/amlogic/npu/inc/drvi/gc_vsc_drvi_lib_link.h b/drivers/amlogic/npu/inc/drvi/gc_vsc_drvi_lib_link.h index 43ce361..7e5b210 100644 --- a/drivers/amlogic/npu/inc/drvi/gc_vsc_drvi_lib_link.h +++ b/drivers/amlogic/npu/inc/drvi/gc_vsc_drvi_lib_link.h @@ -85,6 +85,12 @@ typedef enum _VSC_LIB_LINK_TYPE /* Image format. */ VSC_LIB_LINK_TYPE_IMAGE_FORMAT = 6, + + /* The minimum workGroupSize that application requires. */ + VSC_LIB_LINK_TYPE_SET_MIN_WORK_GROUP_SIZE = 7, + + /* The fixed workGroupSize that application requires. */ + VSC_LIB_LINK_TYPE_SET_FIXED_WORK_GROUP_SIZE = 8, }VSC_LIB_LINK_TYPE; typedef enum _VSC_RES_OP_BIT @@ -207,10 +213,12 @@ typedef struct _VSC_LIB_LINK_POINT VSC_LIB_LINK_POINT_RESOURCE resource; VSC_LIB_LINK_IMAGE_READ_WRITE imageReadWrite; VSC_LIB_LINK_IMAGE_FORMAT imageFormat; + gctUINT minWorkGroupSize; + gctUINT maxWorkGroupSize; } u; }VSC_LIB_LINK_POINT; -#define LIB_NUM 2 +#define MAX_LIB_NUM 8 typedef struct _VSC_SHADER_LIB_LINK_ENTRY { /* Which level this link entry should be applied. */ @@ -218,7 +226,7 @@ typedef struct _VSC_SHADER_LIB_LINK_ENTRY /* Lib shader */ SHADER_HANDLE hShaderLib; - SHADER_HANDLE hShaderLibs[LIB_NUM]; + SHADER_HANDLE hShaderLibs[MAX_LIB_NUM]; /* vreg map from libShader to the current shader */ void* pTempHashTable; diff --git a/drivers/amlogic/npu/inc/drvi/gc_vsc_drvi_program_profile.h b/drivers/amlogic/npu/inc/drvi/gc_vsc_drvi_program_profile.h index cb54151..f0e6770 100644 --- a/drivers/amlogic/npu/inc/drvi/gc_vsc_drvi_program_profile.h +++ b/drivers/amlogic/npu/inc/drvi/gc_vsc_drvi_program_profile.h @@ -478,7 +478,7 @@ PROG_VK_IMAGE_FORMAT_INFO; typedef struct PROG_VK_IMAGE_DERIVED_INFO { - /* For a image, it might need a image-size attached. As each image in + /* For an image, it might need an image-size attached. As each image in Binding::arraySize array has image-size, so this is the first entry of image-size array. */ SHADER_PRIV_CONSTANT_ENTRY* pImageSize; @@ -488,11 +488,35 @@ typedef struct PROG_VK_IMAGE_DERIVED_INFO this is the first entry of extra-image */ SHADER_PRIV_UAV_ENTRY* pExtraLayer; + /* For an image, it might need a mip level attached. As each texel buffer in + Binding::arraySize array has levelsSamples, so this is the first entry + of pMipLevel array. */ + SHADER_PRIV_CONSTANT_ENTRY* pMipLevel; + /* ImageFormat, can be NONE. */ PROG_VK_IMAGE_FORMAT_INFO imageFormatInfo; } PROG_VK_IMAGE_DERIVED_INFO; +typedef struct PROG_VK_SAMPLER_DERIVED_INFO +{ + /* For a sampler, it might need a texture-size attached. As each sampler in + arraySize array has texture-size, so this is the first entry + of texture-size array. */ + SHADER_PRIV_CONSTANT_ENTRY* pTextureSize[2]; + + /* For a sampler, it might need a lodMinMax attached. As each sampler in + arraySize array has lodMinMax, so this is the first entry + of lodMinMax array. */ + SHADER_PRIV_CONSTANT_ENTRY* pLodMinMax[2]; + + /* For a sampler, it might need a levelsSamples attached. As each sampler in + rraySize array has levelsSamples, so this is the first entry + of levelsSamples array. */ + SHADER_PRIV_CONSTANT_ENTRY* pLevelsSamples[2]; +} +PROG_VK_SAMPLER_DERIVED_INFO; + typedef struct PROG_VK_SUB_RESOURCE_BINDING { /* Pointer to original API resource binding */ @@ -527,6 +551,9 @@ typedef struct PROG_VK_PRIV_COMB_TEX_SAMP_HW_MAPPING /* The array size is ((sub-array-size m of sampler) * (sub-array-size n of tex)) */ SHADER_PRIV_SAMPLER_ENTRY** ppExtraSamplerArray; + + /*----------------------------------Sampler-related----------------------------------*/ + PROG_VK_SAMPLER_DERIVED_INFO samplerDerivedInfo; } PROG_VK_PRIV_COMB_TEX_SAMP_HW_MAPPING; @@ -567,7 +594,7 @@ typedef struct PROG_VK_COMBINED_TEXTURE_SAMPLER_HW_MAPPING SHADER_PRIV_SAMPLER_ENTRY** ppExtraSamplerArray; /* For the ycbcr texture recompilation. */ - SHADER_PRIV_UAV_ENTRY* pYcbcrPlanes[__YCBCR_PLANE_COUNT__]; + SHADER_PRIV_UAV_ENTRY** ppYcbcrPlanes; /* For the case that HW natively supports separated texture, so texture part of API combined texture sampler will be directly mapped to HW separated texture */ @@ -593,20 +620,8 @@ typedef struct PROG_VK_COMBINED_TEX_SAMPLER_TABLE_ENTRY /* Is this entry really used by shader */ gctUINT activeStageMask; - /* For texel buffer, it might need a texture-size attached. As each texel buffer in - combTsBinding::arraySize array has texture-size, so this is the first entry - of texture-size array. */ - SHADER_PRIV_CONSTANT_ENTRY* pTextureSize[VSC_MAX_SHADER_STAGE_COUNT][2]; - - /* For texel buffer, it might need a lodMinMax attached. As each texel buffer in - combTsBinding::arraySize array has lodMinMax, so this is the first entry - of lodMinMax array. */ - SHADER_PRIV_CONSTANT_ENTRY* pLodMinMax[VSC_MAX_SHADER_STAGE_COUNT][2]; - - /* For texel buffer, it might need a levelsSamples attached. As each texel buffer in - combTsBinding::arraySize array has levelsSamples, so this is the first entry - of lodMinMax array. */ - SHADER_PRIV_CONSTANT_ENTRY* pLevelsSamples[VSC_MAX_SHADER_STAGE_COUNT][2]; + /*----------------------------------Sampler-related----------------------------------*/ + PROG_VK_SAMPLER_DERIVED_INFO samplerDerivedInfo[VSC_MAX_SHADER_STAGE_COUNT]; /* Which kinds of inst operation acting on sampler (texture part). The count of this resOpBit is same as combTsBinding::arraySize */ @@ -793,10 +808,7 @@ typedef struct PROG_VK_UNIFORM_TEXEL_BUFFER_TABLE_ENTRY PROG_VK_UNIFORM_TEXEL_BUFFER_ENTRY_FLAG utbEntryFlag; /*----------------------------------Sampler-related----------------------------------*/ - /* For texel buffer, it might need a texture-size attached. As each texel buffer in - utbBinding::arraySize array has texture-size, so this is the first entry - of texture-size array. */ - SHADER_PRIV_CONSTANT_ENTRY* pTextureSize[VSC_MAX_SHADER_STAGE_COUNT][2]; + PROG_VK_SAMPLER_DERIVED_INFO samplerDerivedInfo[VSC_MAX_SHADER_STAGE_COUNT]; /*----------------------------------Image-related----------------------------------*/ PROG_VK_IMAGE_DERIVED_INFO imageDerivedInfo[VSC_MAX_SHADER_STAGE_COUNT]; @@ -858,20 +870,7 @@ typedef struct PROG_VK_INPUT_ATTACHMENT_TABLE_ENTRY PROG_VK_IMAGE_DERIVED_INFO imageDerivedInfo[VSC_MAX_SHADER_STAGE_COUNT]; /*----------------------------------Sampler-related----------------------------------*/ - /* For texel buffer, it might need a texture-size attached. As each texel buffer in - iaBinding::arraySize array has texture-size, so this is the first entry - of texture-size array. */ - SHADER_PRIV_CONSTANT_ENTRY* pTextureSize[VSC_MAX_SHADER_STAGE_COUNT][2]; - - /* For texel buffer, it might need a lodMinMax attached. As each texel buffer in - iaBinding::arraySize array has lodMinMax, so this is the first entry - of lodMinMax array. */ - SHADER_PRIV_CONSTANT_ENTRY* pLodMinMax[VSC_MAX_SHADER_STAGE_COUNT][2]; - - /* For texel buffer, it might need a levelsSamples attached. As each texel buffer in - iaBinding::arraySize array has levelsSamples, so this is the first entry - of lodMinMax array. */ - SHADER_PRIV_CONSTANT_ENTRY* pLevelsSamples[VSC_MAX_SHADER_STAGE_COUNT][2]; + PROG_VK_SAMPLER_DERIVED_INFO samplerDerivedInfo[VSC_MAX_SHADER_STAGE_COUNT]; /* Which kinds of inst operation acting on sampler (has flag VIR_SRE_FLAG_TREAT_IA_AS_SAMPLER). The count of this resOpBit is same as iaBinding::arraySize */ diff --git a/drivers/amlogic/npu/inc/drvi/gc_vsc_drvi_shader_profile.h b/drivers/amlogic/npu/inc/drvi/gc_vsc_drvi_shader_profile.h index a278316..c172560 100644 --- a/drivers/amlogic/npu/inc/drvi/gc_vsc_drvi_shader_profile.h +++ b/drivers/amlogic/npu/inc/drvi/gc_vsc_drvi_shader_profile.h @@ -169,7 +169,7 @@ typedef enum SHADER_IO_USAGE /* For gfx clients only, and only for GL */ SHADER_IO_USAGE_POINT_COORD = 36, - SHADER_IO_USAGE_FOG_COORD = 37, + SHADER_IO_USAGE_FOG_FRAG_COORD = 37, SHADER_IO_USAGE_HELPER_PIXEL = 38, /* For gfx pixel-frequency only (sample-frequency will directly use SHADER_IO_USAGE_DEPTH), @@ -308,7 +308,8 @@ SHADER_UAV_ACCESS_MODE; typedef enum SHADER_HW_ACCESS_MODE { SHADER_HW_ACCESS_MODE_REGISTER = 0, - SHADER_HW_ACCESS_MODE_MEMORY = 1 + SHADER_HW_ACCESS_MODE_MEMORY = 1, + SHADER_HW_ACCESS_MODE_BOTH_REG_AND_MEM = 2, } SHADER_HW_ACCESS_MODE; @@ -665,7 +666,8 @@ struct _SHADER_CONSTANT_HW_LOCATION_MAPPING { SHADER_HW_ACCESS_MODE hwAccessMode; - union + /* Use a structure here because it might save the constant into the reigster and memomry at the same time. */ + struct { /* Case to map to constant register */ struct @@ -1014,6 +1016,7 @@ typedef struct SHADER_EXECUTABLE_NATIVE_HINTS gctUINT inputCtrlPointCount; /* HS only */ + gctBOOL hasNoPerVertexInput; gctUINT outputCtrlPointCount; /* For DX, they are provided in HS, but for OGL they are provided in DS */ @@ -1258,6 +1261,9 @@ typedef struct SHADER_EXECUTABLE_DERIVED_HINTS gctUINT hwRegNoForSampleMaskId : 9; gctUINT hwRegChannelForSampleMaskId : 2; + /* PS reg start index, exclude #position. */ + gctUINT psStartRegIndex : 2; + /* Shader will run on per-sample frequency */ gctUINT bExecuteOnSampleFreq : 1; @@ -1273,12 +1279,10 @@ typedef struct SHADER_EXECUTABLE_DERIVED_HINTS implements alpha-blend, or for OGL, lastFragData is presented) */ gctUINT bNeedRtRead : 1; -#if gcdALPHA_KILL_IN_SHADER gctUINT alphaClrKillInstsGened : 1; -#else - gctUINT reserved : 1; -#endif gctUINT fragColorUsage : 2; + + gctUINT reserved : 28; } ps; /* States acted on gps */ @@ -1296,7 +1300,10 @@ typedef struct SHADER_EXECUTABLE_DERIVED_HINTS /* Whether use Evis instruction. */ gctUINT bUseEvisInst : 1; - gctUINT reserved : 28; + /* Whether the shader depends on the workGroupSize. */ + gctUINT bDependOnWorkGroupSize : 1; + + gctUINT reserved : 27; gctUINT16 workGroupSizeFactor[3]; } gps; @@ -1309,7 +1316,6 @@ typedef struct SHADER_EXECUTABLE_HINTS SHADER_EXECUTABLE_DERIVED_HINTS derivedHints; }SHADER_EXECUTABLE_HINTS; - struct SHADER_EXECUTABLE_INSTANCE; /* Executable shader profile definition. Each BE compiling or glProgramBinary will generate one @@ -1399,7 +1405,7 @@ void vscSortIOsByHwLoc(SHADER_IO_MAPPING_PER_EXE_OBJ* pIoMappingPerExeObj, gctUI /* If hShader != NULL, mapping 'symbol->#->hw resource' is dumped, otherwise only '#->hw' is dumped. For the 2nd case, it is easy for driver to dump any SEP when flushing to hw to triage bugs */ -void vscPrintSEP(VSC_SYS_CONTEXT* pSysCtx, SHADER_EXECUTABLE_PROFILE* pSEP, SHADER_HANDLE hShader); +gctBOOL vscPrintSEP(VSC_SYS_CONTEXT* pSysCtx, SHADER_EXECUTABLE_PROFILE* pSEP, SHADER_HANDLE hShader); /* Linkage info */ typedef struct SHADER_IO_REG_LINKAGE @@ -1470,6 +1476,7 @@ typedef enum HW_SAMPLER_FETCH_MODE typedef struct SHADER_HW_PROGRAMMING_HINTS { + /* Word 1*/ /* Inst fetch mode */ gctUINT hwInstFetchMode : 2; @@ -1491,6 +1498,7 @@ typedef struct SHADER_HW_PROGRAMMING_HINTS HW_SAMPLER_FETCH_MODE_UNIFIED_REG_FILE, for other cases, it must be set to 0 */ gctUINT hwSamplerRegAddrOffset : 7; + /* Word 2*/ /* Result-cache is used to queue missed data streamming from up-stage and release them after they are used. This window-size is the size of queue. Note that this result-$ occupies some space of USC storage (uscSizeInKbyte). The ocuppied space is calc'ed @@ -1505,6 +1513,7 @@ typedef struct SHADER_HW_PROGRAMMING_HINTS maxHwTGThreadCount, i.e, (maxCoreCount * 4) */ gctUINT maxThreadsPerHwTG : 7; + /* Word 3*/ /* USC is shared by all shader stages, so we need allocate proper size for each stage to get best perf of pipeline. The relation between these two members are 1. minUscSizeInKbyte can not be greater than maxUscSizeInKbyte. @@ -1518,6 +1527,13 @@ typedef struct SHADER_HW_PROGRAMMING_HINTS /* Iteration factor to time 'min parallel shader stage combination' when analyzing USC */ gctUINT maxParallelFactor : 16; + + /* Word 4*/ + /* Max patches number. */ + gctUINT tsMaxPatches : 7; + + /* Reserved bits */ + gctUINT reserved : 25; }SHADER_HW_PROGRAMMING_HINTS; typedef struct SHADER_HW_INFO diff --git a/drivers/amlogic/npu/inc/gc_feature_database.h b/drivers/amlogic/npu/inc/gc_feature_database.h index 107ca4f..413a1f1 100644 --- a/drivers/amlogic/npu/inc/gc_feature_database.h +++ b/drivers/amlogic/npu/inc/gc_feature_database.h @@ -11,7 +11,7 @@ *****************************************************************************/ -/*Auto created on 2020-03-26 14:34*/ +/*Auto created on 2020-06-23 16:44*/ #ifndef _gc_feature_database_h_ #define _gc_feature_database_h_ @@ -33,13 +33,23 @@ typedef struct gctUINT32 NumberOfConstants; gctUINT32 CoreCount; gctUINT32 LocalStorageSize; + gctUINT32 LocalStorageSize_1; + gctUINT32 LocalStorageSize_2; gctUINT32 L1CacheSize; + gctUINT32 L1CacheSize_1; + gctUINT32 L1CacheSize_2; gctUINT32 InstructionMemorySize; gctUINT32 ShaderPCLength; gctUINT32 USC_MAX_PAGES; + gctUINT32 USC_MAX_PAGES_1; + gctUINT32 USC_MAX_PAGES_2; gctUINT32 NumPixelPipes; gctUINT32 USC_CACHE_CONTROLLERS; + gctUINT32 USC_CACHE_CONTROLLERS_1; + gctUINT32 USC_CACHE_CONTROLLERS_2; gctUINT32 USC_BANKS; + gctUINT32 USC_BANKS_1; + gctUINT32 USC_BANKS_2; gctUINT32 Streams; gctUINT32 VaryingCount; gctUINT32 VertexOutputBufferSize; @@ -48,6 +58,7 @@ typedef struct gctUINT32 NumResolvePipes; gctUINT32 RESULT_WINDOW_MAX_SIZE; gctUINT32 ClusterAliveMask; + gctUINT32 G2D_DEC400_MINOR; gctUINT32 NNMadPerCore; gctUINT32 NNCoreCount; gctUINT32 NNCoreCount_INT8; @@ -72,14 +83,26 @@ typedef struct gctUINT32 PHYSICAL_VIP_SRAM_WIDTH_IN_BYTE; gctUINT32 EQUIVALENT_VIP_SRAM_WIDTH_INBYTE; gctUINT32 TP_ZRL_BITS; + gctUINT32 NN_ZRL_BITS; gctUINT32 LATENCY_HIDING_AT_FULL_AXI_BW; gctUINT32 AXI_BUS_WIDTH; gctUINT32 NN_KERNEL_X_SIZE; gctUINT32 NN_KERNEL_Y_SIZE; + gctUINT32 NN_FC_KERNEL_Y_SIZE; gctUINT32 NN_KERNEL_Z_SIZE; gctUINT32 NN_X_OFFSET; gctUINT32 NN_Y_OFFSET; gctUINT32 DDR_KERNEL_BURST_SIZE; + gctUINT32 OUTIMAGE_X_STRIDE_BITS; + gctUINT32 OUTIMAGE_Y_STRIDE_BITS; + gctUINT32 INIMAGE_X_STRIDE_BITS; + gctUINT32 IMIMAGE_Y_STRIDE_BITS; + gctUINT32 OUTIMAGE_X_SIZE_BITS; + gctUINT32 OUTIMAGE_Y_SIZE_BITS; + gctUINT32 OUTIMAGE_SIZE_BITS; + gctUINT32 IMAGE_X_SIZE_BITS; + gctUINT32 INIMAGE_Y_SIZE_BITS; + gctUINT32 MAX_TILE_X_SIZE; gctUINT32 REG_FastClear:1; gctUINT32 REG_SpecialAntiAliasing:1; gctUINT32 REG_Pipe3D:1; @@ -321,6 +344,7 @@ typedef struct gctUINT32 RA_HZEZ_CLOCK_CONTROL:1; gctUINT32 CACHE128B256BPERLINE:1; gctUINT32 V4Compression:1; + gctUINT32 DE2D_MAJOR_SUPER_TILE:1; gctUINT32 PE2D_MAJOR_SUPER_TILE:1; gctUINT32 PE_32BPC_COLORMASK_FIX:1; gctUINT32 ALPHA_BLENDING_OPT:1; @@ -453,6 +477,7 @@ typedef struct gctUINT32 TX_NO_FIXED_FILTER:1; gctUINT32 SHARE_Z:1; gctUINT32 DE_2D_FAST_CLEAR:1; + gctUINT32 DE_TILESTATUS_ROTATION_FIX:1; gctUINT32 TX_CLEAR_PENDING_FIX:1; gctUINT32 NO_HI1_L2:1; gctUINT32 USC_EVICT_CTRL_FIFO_FLOP_RESET_FIX:1; @@ -463,6 +488,13 @@ typedef struct gctUINT32 SH_VX2_FLOATING_MAD_FIX:1; gctUINT32 TS_FC_VULKAN_SUPPORT:1; gctUINT32 MSAA_FLOAT_64BIT:1; + gctUINT32 INDIRECT_COMPUTE_ZERODIM_FIX:1; + gctUINT32 Q_CHANNEL_SUPPORT:1; + gctUINT32 MMU_PAGE_DESCRIPTOR:1; + gctUINT32 YUV_LINEAR_TO_TILE_ROTATE:1; + gctUINT32 VEC2_IMULIMAD32_SUPPORT:1; + gctUINT32 VEC4_IMULIMAD32_SUPPORT:1; + gctUINT32 VEC2_IDIVIMOD16_SUPPORT:1; gctUINT32 VG_TS_CULLING:1; gctUINT32 VG_FP25:1; gctUINT32 VG_AYUV_INPUT_OUTPUT:1; @@ -489,6 +521,20 @@ typedef struct gctUINT32 DC_MMU:1; gctUINT32 DC_COMPRESSION:1; gctUINT32 DC_QOS:1; + gctUINT32 VIP_HW_FINAL_RELEASE:1; + gctUINT32 NN_SINGLEPORT_ACCUMBUFFER:1; + gctUINT32 NN_STRIDE_SUPPORT:1; + gctUINT32 SWTILING_PHASE1:1; + gctUINT32 SWTILING_PHASE2:1; + gctUINT32 TP_SIMPLE_INT16:1; + gctUINT32 TP_REAL_INT16:1; + gctUINT32 TP_ROI_POOLING:1; + gctUINT32 TP_MAX_POOLING_STRIDE1:1; + gctUINT32 TP_LRN:1; + gctUINT32 TP_REORDER:1; + gctUINT32 TF_QUANTIZATION:1; + gctUINT32 NN_NONZERO_BORDER:1; + gctUINT32 NN_MIRROR_BORDER:1; gctUINT32 AI_GPU:1; gctUINT32 EVIS_NO_ABSDIFF:1; gctUINT32 EVIS_NO_BITREPLACE:1; @@ -501,132 +547,143 @@ typedef struct gctUINT32 EVIS_LERP_7OUTPUT:1; gctUINT32 EVIS_ACCSQ_8OUTPUT:1; gctUINT32 EVIS_VX2:1; - gctUINT32 NN_FLOAT:1; gctUINT32 TP_ENGINE:1; gctUINT32 VIP_V7:1; - gctUINT32 MCFE:1; - gctUINT32 NN_INTERLEVE8:1; - gctUINT32 TP_REORDER:1; - gctUINT32 TP_LRN:1; - gctUINT32 TP_MAX_POOLING_STRIDE1:1; - gctUINT32 NN_FP16_ALU:1; - gctUINT32 NN_INT16_ALU:1; - gctUINT32 TP_ROI_POOLING:1; - gctUINT32 NN_ZDP3:1; + gctUINT32 TP_TENSOR_ADD_MUL:1; + gctUINT32 NN_DEPTHWISE_INT16XINT8:1; + gctUINT32 TP_SOFTMAX:1; + gctUINT32 NN_23BITS_POST_MULTIPLIER_VIP_V7:1; + gctUINT32 TP_23BITS_POST_MULTIPLIER_VIP_V7:1; + gctUINT32 HYBRID_MODE_VIP_V7:1; gctUINT32 NN_ZDP6:1; gctUINT32 NN_XYDP9:1; - gctUINT32 NN_INT8_SCALE:1; - gctUINT32 NN_POWER_ISOLATION:1; - gctUINT32 SWTILING_PHASE1:1; - gctUINT32 TF_QUANTIZATION:1; - gctUINT32 TP_SIMPLE_INT16:1; - gctUINT32 TP_REAL_INT16:1; - gctUINT32 TP_BFLOAT16:1; gctUINT32 NN_FIRST_PIXEL_POOLING:1; - gctUINT32 SWTILING_PHASE2:1; - gctUINT32 NN_STRIDE_SUPPORT:1; + gctUINT32 NN_ZDP3:1; gctUINT32 NN_XYDP6:1; - gctUINT32 TP_REORDER_FIX:1; - gctUINT32 NN_CONV1x1_PERF_FIX:1; - gctUINT32 NN_CACHELINE_MODE_PERF_FIX:1; - gctUINT32 NN_PER3DTILE_BUBBLE_FIX:1; - gctUINT32 NN_CONVOUT_FIFO_DEPTH_FIX:1; gctUINT32 SWTILING_PHASE3:1; + gctUINT32 MCFE:1; gctUINT32 USC_STAY_LRU:1; - gctUINT32 NN_NONZERO_MIRROR_BORDER:1; + gctUINT32 COEF_COMPRESSION_ENHANCEMENT:1; + gctUINT32 TP_COEF_COMPRESSION_ENHANCEMENT:1; gctUINT32 NN_COEF_DECOMPRESS_PERF2X:1; + gctUINT32 OCB_COUNTER:1; + gctUINT32 SCALER:1; + gctUINT32 SCALER_4K:1; gctUINT32 INPUT_4BIT:1; - gctUINT32 COEF_COMPRESSION_ENHANCEMENT:1; + gctUINT32 NN_NO_Z_LOCATION_OFFSET:1; + gctUINT32 OCB_REMAP_PHYSICAL_ADDRESS:1; + gctUINT32 NN_SLOW_OUTPUT:1; + gctUINT32 NO_NARROW_POST_PROCESS_PIPE:1; + gctUINT32 TP_NN_PROBE:1; + gctUINT32 NN_DEPTHWISE_SUPPORT:1; + gctUINT32 NN_XYDP0:1; + gctUINT32 NN_WRITE_WITHOUT_USC:1; + gctUINT32 NN_HW_LIMITATION_NATIVE_KER_1x2_2x1:1; + gctUINT32 NN_SLICE_PADDING_TO_64BYTE_ALIGN:1; + gctUINT32 NN_DW_1x1_CONV_MERGE:1; + gctUINT32 TP_BFLOAT16:1; + gctUINT32 TP_23BITS_POST_MULTIPLIER:1; + gctUINT32 NN_TRANSPOSE:1; + gctUINT32 USE_SINGLE_PORT_VIPSRAM:1; + gctUINT32 NN_LEAKY_RELU:1; + gctUINT32 NN_PRELU:1; + gctUINT32 NN_PER_CHANNEL_QUANT:1; + gctUINT32 NN_PER_CHANNEL_QUANT_ASYM:1; + gctUINT32 NN_ASYMMETRIC_INT8:1; + gctUINT32 NN_FLOAT_POST_MULT:1; + gctUINT32 PRELU_LEAKLY_RELU_CLAMP:1; + gctUINT32 TPLITE_BFLOAT16:1; + gctUINT32 PREPROCESS_IMG_BUF_640BYTE_LIMIT:1; + gctUINT32 TP_KERNEL_1BYTE_ALGIN:1; + gctUINT32 BFLOAT_COEF_COMPRESSION_ZERO_COEFBIT14_INVERSE:1; + gctUINT32 NN_COMPRESSION_BYPASSS:1; + gctUINT32 TP_3_USC:1; + gctUINT32 BFP_COEF_AUTO_PAD_INCOMPLETE_ZERO_IN_KZ_PLANE:1; + gctUINT32 NN_NATIVE_STRIDE_TWO:1; + gctUINT32 NN_TENSOR_ADD:1; + gctUINT32 NN_FLOAT32_IO:1; + gctUINT32 TP_FLOAT32_IO:1; + gctUINT32 NN_SMALL_BATCH_PHASE2:1; + gctUINT32 TILE_ACCESS_CAPABILITY:1; + gctUINT32 FAST_DP3_PREPROCESSOR:1; + gctUINT32 DEPTHWISE_SUPPORT_16BIT_FORMAT:1; + gctUINT32 NN_SUPPORT_ALU_LUT:1; + gctUINT32 NN_ENHANCED_MAX_POOLING:1; + gctUINT32 NN_TRANSPOSE_PHASE2:1; + gctUINT32 TPLITE_SUPPORT_TP_DATA_TRANSPOSE:1; + gctUINT32 NN_SUPPORT_CONV_1D:1; + gctUINT32 USE_VIPSRAM_FOR_KERNEL_STREAMING:1; + gctUINT32 VIP_DEC400:1; + gctUINT32 NN_PER3DTILE_BUBBLE_FIX:1; + gctUINT32 NN_CACHELINE_MODE_PERF_FIX:1; + gctUINT32 NN_CONV1x1_PERF_FIX:1; + gctUINT32 TP_REORDER_FIX:1; + gctUINT32 NN_CONVOUT_FIFO_DEPTH_FIX:1; gctUINT32 NN_ZXDP3_KERNEL_READ_CONFLICT_FIX:1; gctUINT32 NN_ZDP3_NO_COMPRESS_FIX:1; gctUINT32 NN_ASYNC_COPY_PERF_FIX:1; - gctUINT32 OCB_COUNTER:1; - gctUINT32 NN_XYDP0:1; - gctUINT32 ZRL_7BIT:1; + gctUINT32 HI_REORDER_FIX:1; + gctUINT32 INCORRECT_WR_REQ_TO_USC_BETWEEN_REORDER_AND_NORMAL_LAYER_FIX:1; + gctUINT32 TP_REORDER_LAYER_SUSPEND_FIX:1; gctUINT32 NN_ASYNC_COPY_MERGE_FIX:1; - gctUINT32 NN_SMALLBATCH_PHASE1:1; - gctUINT32 TP_SMALLBATCH_PHASE1:1; - gctUINT32 SCALER:1; - gctUINT32 SCALER_4K:1; + gctUINT32 USC_INVALIDATE_CACHE_LINE_FIX:1; gctUINT32 NN_REQ_SLOWARBITRATION_FIX:1; - gctUINT32 IMAGE_PARTIAL_CACHE:1; + gctUINT32 IMAGE_PARTIAL_CACHE_FIX:1; gctUINT32 FULLCACHE_KERNELHEAD_FIX:1; - gctUINT32 NN_SINGLEPORT_ACCUMBUFFER:1; - gctUINT32 NN_SMALLBATCH:1; - gctUINT32 TP_SMALLBATCH:1; - gctUINT32 ZRL_8BIT:1; - gctUINT32 NN_DEPTHWISE_SUPPORT:1; - gctUINT32 NN_WRITE_WITHOUT_USC:1; gctUINT32 NN_ZDP_INIMAGE_SIZE_FIX:1; - gctUINT32 HI_REORDER_FIX:1; - gctUINT32 INCORRECT_WR_REQ_TO_USC_BETWEEN_REORDER_AND_NORMAL_LAYER_FIX:1; - gctUINT32 TP_COEF_COMPRESSION_ENHANCEMENT:1; - gctUINT32 VIP_DEC400:1; - gctUINT32 IMAGE_NOT_PACKED_IN_SRAM_FIX:1; gctUINT32 IDLE_BEFORE_FLUSH_COMPLETE_FIX:1; gctUINT32 NO_FLUSH_USC_FIX:1; + gctUINT32 SMALL_BATCH_FLOPS_RESET_FIX:1; + gctUINT32 SMALL_BATCH_DISBLE_FIX:1; + gctUINT32 OUTPUT_CONVERT_UINT8_INT8_TO_UINT16_INT16_FIX:1; + gctUINT32 IMAGE_NOT_PACKED_IN_SRAM_FIX:1; gctUINT32 COEF_DELTA_CORD_OVERFLOW_ZRL_8BIT_FIX:1; - gctUINT32 XY_OFFSET_LIMITATION_FIX:1; - gctUINT32 USC_INVALIDATE_CACHE_LINE_FIX:1; gctUINT32 LOW_EFFICIENCY_OF_ID_WRITE_IMGBUF_FIX:1; - gctUINT32 KERNEL_PER_CORE_LESS_THAN_THIRD_COEF_BUFF_DEPTH_FIX:1; + gctUINT32 KERNEL_VIP_SRAM_READ_BW_LIMITATION_FIX:1; gctUINT32 USC_BOTTLENECK_FIX:1; + gctUINT32 KERNEL_PER_CORE_LESS_THAN_THIRD_COEF_BUFF_DEPTH_FIX:1; gctUINT32 KERNEL_SIZE_WASTE_IN_PARTIAL_MODE_FIX:1; - gctUINT32 FULLCACHE_KERNEL_INTERLEAVE_FIX:1; - gctUINT32 TP_REORDER_LAYER_SUSPEND_FIX:1; - gctUINT32 KERNEL_VIP_SRAM_READ_BW_LIMITATION_FIX:1; + gctUINT32 NN_COMMAND_KERNEL_REQUEST_CONFICT_FIX:1; + gctUINT32 TP_REORDER_INTILE_X_SIZE_512_FIX:1; gctUINT32 IMG_POP_PIPELINE_PAUSE_FIX:1; + gctUINT32 FULLCACHE_KERNEL_INTERLEAVE_FIX:1; + gctUINT32 V8_SINGLE_PORT_ACCUMULATION_BUFFER_RW_CONFICT_ZERO_SKIP_PERF_FIX:1; + gctUINT32 V8_ACCUMLATION_READ_OUT_HAS_BUBBLES_PERF_FIX:1; + gctUINT32 DEPTHWISE_NEIGHBOR_IMG_DATA_TRANSFER_NOT_EFFICIENT_FIX:1; gctUINT32 DR_JD_DIFF_CONDITION_FOR_CACHELINE_MODE_PRE_FIX:1; - gctUINT32 OUTIMAGE_X_BITWIDTH_LIMIT_FOR_NN_TRANSPOSE_FIX:1; - gctUINT32 SMALL_BATCH_FLOPS_RESET_FIX:1; - gctUINT32 SMALL_BATCH_DISBLE_FIX:1; - gctUINT32 NEGATIVE_POST_SHIFT_FIX:1; - gctUINT32 NN_COMMAND_KERNEL_REQUEST_CONFICT_FIX:1; - gctUINT32 OCB_REMAP_PHYSICAL_ADDRESS:1; - gctUINT32 NN_NO_Z_LOCATION_OFFSET:1; - gctUINT32 NN_LEAKY_RELU:1; - gctUINT32 NN_PRELU:1; - gctUINT32 NN_PER_CHANNEL_QUANT:1; - gctUINT32 NN_PER_CHANNEL_QUANT_ASYM:1; - gctUINT32 NN_NATIVE_STRIDE_TWO:1; - gctUINT32 NN_TENSOR_ADD:1; - gctUINT32 NN_FLOAT_POST_MULT:1; - gctUINT32 NN_SLICE_PADDING_TO_64BYTE_ALIGN:1; - gctUINT32 NN_DW_1x1_CONV_MERGE:1; - gctUINT32 NN_SLOW_OUTPUT:1; - gctUINT32 NO_NARROW_POST_PROCESS_PIPE:1; - gctUINT32 TP_NN_PROBE:1; - gctUINT32 TP_23BITS_POST_MULTIPLIER:1; - gctUINT32 NN_TRANSPOSE:1; + gctUINT32 TP_ACCESS_VIPSRAM_OT_IS_ONE_FIX:1; gctUINT32 EVIS2_FLOP_RESET_FIX:1; + gctUINT32 OUTIMAGE_X_BITWIDTH_LIMIT_FOR_NN_TRANSPOSE_FIX:1; gctUINT32 USC_ASYNC_CP_RTN_FLOP_RESET_FIX:1; - gctUINT32 DDR_BURST_LEN_256B:1; + gctUINT32 IMG_ADDR_NOT_WRAP_IF_OVER_OCB_ADDR_FIX:1; + gctUINT32 NEGATIVE_POST_SHIFT_FIX:1; + gctUINT32 INIMAGE_2DTILE_NOT_LESS_160PIXEL_FIX:1; gctUINT32 IMG_CAHCE_MODE_MUST_0_IN_IMG_DIRECT_MODE_FIX:1; - gctUINT32 USE_SINGLE_PORT_VIPSRAM:1; - gctUINT32 NN_ASYMMETRIC_INT8:1; - gctUINT32 DEPTHWISE_NEIGHBOR_IMG_DATA_TRANSFER_NOT_EFFICIENT_FIX:1; - gctUINT32 PRELU_LEAKLY_RELU_CLAMP:1; - gctUINT32 TP_FLOAT32_IO:1; - gctUINT32 NN_FLOAT32_IO:1; - gctUINT32 NN_SMALL_BATCH_PHASE2:1; - gctUINT32 TILE_ACCESS_CAPABILITY:1; - gctUINT32 FAST_DP3_PREPROCESSOR:1; - gctUINT32 NN_COMPRESSION_BYPASSS:1; - gctUINT32 BFLOAT_KERNEL_COMPRESSION_ZERO_SKIP_FIX:1; - gctUINT32 TP_3_USC:1; - gctUINT32 TP_KERNEL_1BYTE_ALGIN:1; - gctUINT32 TPLITE_BFLOAT16:1; - gctUINT32 PREPROCESS_IMG_BUF_640BYTE_LIMIT:1; - gctUINT32 V8_ACCUMLATION_READ_OUT_HAS_BUBBLES_PERF_FIX:1; - gctUINT32 V8_SINGLE_PORT_ACCUMULATION_BUFFER_RW_CONFICT_ZERO_SKIP_PERF_FIX:1; gctUINT32 BURST_COLLECT_DUMMY_DATA_WASTE_CYCLES_FIX:1; gctUINT32 INIMG_NOT_64BYTE_ALIGN_CACHELINE_MODE_FIX:1; - gctUINT32 TP_ACCESS_VIPSRAM_OT_IS_ONE_FIX:1; - gctUINT32 VIP_HW_FINAL_RELEASE:1; + gctUINT32 TP_FC_FLOAT_LAST_PIXEL_NEGATIVE_0_FIX:1; + gctUINT32 NN_WASET_COEF_READ_WRITE_BANDWIDTH_128BYTE_VIPSRAM_IN_FULL_PATIAL_CACHE_MODE:1; + gctUINT32 NN_IN_TILE_DATA_IS_ALL_PAD_FIX:1; + gctUINT32 TP_FC_KERNEL_STREAM_MUST_LESS_THAN_OR_EQUAL_TO_64BYTE_WHEN_1BYTE_ALGINE_FIX:1; + gctUINT32 NN_INTERLEVE8:1; + gctUINT32 NN_FP16_ALU:1; + gctUINT32 NN_INT16_ALU:1; + gctUINT32 NN_INT8_SCALE:1; + gctUINT32 NN_POWER_ISOLATION:1; + gctUINT32 ZRL_7BIT:1; + gctUINT32 NN_SMALLBATCH_PHASE1:1; + gctUINT32 TP_SMALLBATCH_PHASE1:1; + gctUINT32 NN_SMALLBATCH:1; + gctUINT32 TP_SMALLBATCH:1; + gctUINT32 ZRL_8BIT:1; + gctUINT32 DDR_BURST_LEN_256B:1; + gctUINT32 XY_OFFSET_LIMITATION_FIX:1; + gctUINT32 NN_NONZERO_MIRROR_BORDER:1; + gctUINT32 IMAGE_PARTIAL_CACHE:1; } gcsFEATURE_DATABASE; -#define FEATURE_BIT_START 63 -#define FEATURE_BIT_END 605 +#define FEATURE_BIT_START 86 +#define FEATURE_BIT_END 662 static gcsFEATURE_DATABASE gChipInfo[] = { /* vipnano-qi */ { @@ -645,13 +702,23 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x140, /* gcFEATURE_VALUE_NumberOfConstants */ 0x1, /* gcFEATURE_VALUE_CoreCount */ 0x10, /* gcFEATURE_VALUE_LocalStorageSize */ + 0x0, /* gcFEATURE_VALUE_LocalStorageSize_1 */ + 0x0, /* gcFEATURE_VALUE_LocalStorageSize_2 */ 0x10, /* gcFEATURE_VALUE_L1CacheSize */ + 0x0, /* gcFEATURE_VALUE_L1CacheSize_1 */ + 0x0, /* gcFEATURE_VALUE_L1CacheSize_2 */ 0x200, /* gcFEATURE_VALUE_InstructionMemorySize */ 0x14, /* gcFEATURE_VALUE_ShaderPCLength */ 0x10, /* gcFEATURE_VALUE_USC_MAX_PAGES */ + 0x0, /* gcFEATURE_VALUE_USC_MAX_PAGES_1 */ + 0x0, /* gcFEATURE_VALUE_USC_MAX_PAGES_2 */ 0x1, /* gcFEATURE_VALUE_NumPixelPipes */ 0x2, /* gcFEATURE_VALUE_USC_CACHE_CONTROLLERS */ + 0x0, /* gcFEATURE_VALUE_USC_CACHE_CONTROLLERS_1 */ + 0x0, /* gcFEATURE_VALUE_USC_CACHE_CONTROLLERS_2 */ 0x2, /* gcFEATURE_VALUE_USC_BANKS */ + 0x0, /* gcFEATURE_VALUE_USC_BANKS_1 */ + 0x0, /* gcFEATURE_VALUE_USC_BANKS_2 */ 0x8, /* gcFEATURE_VALUE_Streams */ 0x10, /* gcFEATURE_VALUE_VaryingCount */ 0x400, /* gcFEATURE_VALUE_VertexOutputBufferSize */ @@ -660,6 +727,7 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_VALUE_NumResolvePipes */ 0x100, /* gcFEATURE_VALUE_RESULT_WINDOW_MAX_SIZE */ 0x0, /* gcFEATURE_VALUE_ClusterAliveMask */ + 0x0, /* gcFEATURE_VALUE_G2D_DEC400_MINOR */ 0x40, /* gcFEATURE_VALUE_NNMadPerCore */ 0x8, /* gcFEATURE_VALUE_NNCoreCount */ 0x8, /* gcFEATURE_VALUE_NNCoreCount_INT8 */ @@ -684,14 +752,26 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x20, /* gcFEATURE_VALUE_PHYSICAL_VIP_SRAM_WIDTH_IN_BYTE */ 0x10, /* gcFEATURE_VALUE_EQUIVALENT_VIP_SRAM_WIDTH_INBYTE */ 0x8, /* gcFEATURE_VALUE_TP_ZRL_BITS */ + 0x5, /* gcFEATURE_VALUE_NN_ZRL_BITS */ 0x80, /* gcFEATURE_VALUE_LATENCY_HIDING_AT_FULL_AXI_BW */ 0x10, /* gcFEATURE_VALUE_AXI_BUS_WIDTH */ 0xf, /* gcFEATURE_VALUE_NN_KERNEL_X_SIZE */ 0xf, /* gcFEATURE_VALUE_NN_KERNEL_Y_SIZE */ + 0xf, /* gcFEATURE_VALUE_NN_FC_KERNEL_Y_SIZE */ 0xfffff, /* gcFEATURE_VALUE_NN_KERNEL_Z_SIZE */ 0x7, /* gcFEATURE_VALUE_NN_X_OFFSET */ 0x7, /* gcFEATURE_VALUE_NN_Y_OFFSET */ 0x40, /* gcFEATURE_VALUE_DDR_KERNEL_BURST_SIZE */ + 0x10, /* gcFEATURE_VALUE_OUTIMAGE_X_STRIDE_BITS */ + 0x0, /* gcFEATURE_VALUE_OUTIMAGE_Y_STRIDE_BITS */ + 0x10, /* gcFEATURE_VALUE_INIMAGE_X_STRIDE_BITS */ + 0x10, /* gcFEATURE_VALUE_IMIMAGE_Y_STRIDE_BITS */ + 0xd, /* gcFEATURE_VALUE_OUTIMAGE_X_SIZE_BITS */ + 0xd, /* gcFEATURE_VALUE_OUTIMAGE_Y_SIZE_BITS */ + 0xe, /* gcFEATURE_VALUE_OUTIMAGE_SIZE_BITS */ + 0xd, /* gcFEATURE_VALUE_IMAGE_X_SIZE_BITS */ + 0xd, /* gcFEATURE_VALUE_INIMAGE_Y_SIZE_BITS */ + 0x40, /* gcFEATURE_VALUE_MAX_TILE_X_SIZE */ 0x0, /* gcFEATURE_BIT_REG_FastClear */ 0x0, /* gcFEATURE_BIT_REG_SpecialAntiAliasing */ 0x1, /* gcFEATURE_BIT_REG_Pipe3D */ @@ -933,6 +1013,7 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x1, /* gcFEATURE_BIT_RA_HZEZ_CLOCK_CONTROL */ 0x1, /* gcFEATURE_BIT_CACHE128B256BPERLINE */ 0x1, /* gcFEATURE_BIT_V4Compression */ + 0x0, /* gcFEATURE_BIT_DE2D_MAJOR_SUPER_TILE */ 0x0, /* gcFEATURE_BIT_PE2D_MAJOR_SUPER_TILE */ 0x1, /* gcFEATURE_BIT_PE_32BPC_COLORMASK_FIX */ 0x1, /* gcFEATURE_BIT_ALPHA_BLENDING_OPT */ @@ -1065,6 +1146,7 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_BIT_TX_NO_FIXED_FILTER */ 0x0, /* gcFEATURE_BIT_SHARE_Z */ 0x0, /* gcFEATURE_BIT_DE_2D_FAST_CLEAR */ + 0x0, /* gcFEATURE_BIT_DE_TILESTATUS_ROTATION_FIX */ 0x0, /* gcFEATURE_BIT_TX_CLEAR_PENDING_FIX */ 0x0, /* gcFEATURE_BIT_NO_HI1_L2 */ 0x0, /* gcFEATURE_BIT_USC_EVICT_CTRL_FIFO_FLOP_RESET_FIX */ @@ -1075,6 +1157,13 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_BIT_SH_VX2_FLOATING_MAD_FIX */ 0x0, /* gcFEATURE_BIT_TS_FC_VULKAN_SUPPORT */ 0x0, /* gcFEATURE_BIT_MSAA_FLOAT_64BIT */ + 0x0, /* gcFEATURE_BIT_INDIRECT_COMPUTE_ZERODIM_FIX */ + 0x0, /* gcFEATURE_BIT_Q_CHANNEL_SUPPORT */ + 0x0, /* gcFEATURE_BIT_MMU_PAGE_DESCRIPTOR */ + 0x0, /* gcFEATURE_BIT_YUV_LINEAR_TO_TILE_ROTATE */ + 0x0, /* gcFEATURE_BIT_VEC2_IMULIMAD32_SUPPORT */ + 0x0, /* gcFEATURE_BIT_VEC4_IMULIMAD32_SUPPORT */ + 0x0, /* gcFEATURE_BIT_VEC2_IDIVIMOD16_SUPPORT */ 0x0, /* gcFEATURE_BIT_VG_TS_CULLING */ 0x0, /* gcFEATURE_BIT_VG_FP25 */ 0x0, /* gcFEATURE_BIT_VG_AYUV_INPUT_OUTPUT */ @@ -1101,6 +1190,20 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_BIT_DC_MMU */ 0x0, /* gcFEATURE_BIT_DC_COMPRESSION */ 0x0, /* gcFEATURE_BIT_DC_QOS */ + 0x1, /* gcFEATURE_BIT_VIP_HW_FINAL_RELEASE */ + 0x1, /* gcFEATURE_BIT_NN_SINGLEPORT_ACCUMBUFFER */ + 0x1, /* gcFEATURE_BIT_NN_STRIDE_SUPPORT */ + 0x1, /* gcFEATURE_BIT_SWTILING_PHASE1 */ + 0x0, /* gcFEATURE_BIT_SWTILING_PHASE2 */ + 0x1, /* gcFEATURE_BIT_TP_SIMPLE_INT16 */ + 0x0, /* gcFEATURE_BIT_TP_REAL_INT16 */ + 0x1, /* gcFEATURE_BIT_TP_ROI_POOLING */ + 0x1, /* gcFEATURE_BIT_TP_MAX_POOLING_STRIDE1 */ + 0x1, /* gcFEATURE_BIT_TP_LRN */ + 0x1, /* gcFEATURE_BIT_TP_REORDER */ + 0x1, /* gcFEATURE_BIT_TF_QUANTIZATION */ + 0x0, /* gcFEATURE_BIT_NN_NONZERO_BORDER */ + 0x0, /* gcFEATURE_BIT_NN_MIRROR_BORDER */ 0x0, /* gcFEATURE_BIT_AI_GPU */ 0x0, /* gcFEATURE_BIT_EVIS_NO_ABSDIFF */ 0x0, /* gcFEATURE_BIT_EVIS_NO_BITREPLACE */ @@ -1113,128 +1216,139 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_BIT_EVIS_LERP_7OUTPUT */ 0x0, /* gcFEATURE_BIT_EVIS_ACCSQ_8OUTPUT */ 0x1, /* gcFEATURE_BIT_EVIS_VX2 */ - 0x1, /* gcFEATURE_BIT_NN_FLOAT */ 0x1, /* gcFEATURE_BIT_TP_ENGINE */ 0x1, /* gcFEATURE_BIT_VIP_V7 */ - 0x0, /* gcFEATURE_BIT_MCFE */ - 0x0, /* gcFEATURE_BIT_NN_INTERLEVE8 */ - 0x1, /* gcFEATURE_BIT_TP_REORDER */ - 0x1, /* gcFEATURE_BIT_TP_LRN */ - 0x1, /* gcFEATURE_BIT_TP_MAX_POOLING_STRIDE1 */ - 0x0, /* gcFEATURE_BIT_NN_FP16_ALU */ - 0x1, /* gcFEATURE_BIT_NN_INT16_ALU */ - 0x1, /* gcFEATURE_BIT_TP_ROI_POOLING */ - 0x0, /* gcFEATURE_BIT_NN_ZDP3 */ + 0x0, /* gcFEATURE_BIT_TP_TENSOR_ADD_MUL */ + 0x0, /* gcFEATURE_BIT_NN_DEPTHWISE_INT16XINT8 */ + 0x0, /* gcFEATURE_BIT_TP_SOFTMAX */ + 0x0, /* gcFEATURE_BIT_NN_23BITS_POST_MULTIPLIER_VIP_V7 */ + 0x0, /* gcFEATURE_BIT_TP_23BITS_POST_MULTIPLIER_VIP_V7 */ + 0x0, /* gcFEATURE_BIT_HYBRID_MODE_VIP_V7 */ 0x0, /* gcFEATURE_BIT_NN_ZDP6 */ 0x0, /* gcFEATURE_BIT_NN_XYDP9 */ - 0x1, /* gcFEATURE_BIT_NN_INT8_SCALE */ - 0x1, /* gcFEATURE_BIT_NN_POWER_ISOLATION */ - 0x1, /* gcFEATURE_BIT_SWTILING_PHASE1 */ - 0x1, /* gcFEATURE_BIT_TF_QUANTIZATION */ - 0x1, /* gcFEATURE_BIT_TP_SIMPLE_INT16 */ - 0x0, /* gcFEATURE_BIT_TP_REAL_INT16 */ - 0x0, /* gcFEATURE_BIT_TP_BFLOAT16 */ 0x0, /* gcFEATURE_BIT_NN_FIRST_PIXEL_POOLING */ - 0x0, /* gcFEATURE_BIT_SWTILING_PHASE2 */ - 0x1, /* gcFEATURE_BIT_NN_STRIDE_SUPPORT */ + 0x0, /* gcFEATURE_BIT_NN_ZDP3 */ 0x0, /* gcFEATURE_BIT_NN_XYDP6 */ - 0x1, /* gcFEATURE_BIT_TP_REORDER_FIX */ - 0x0, /* gcFEATURE_BIT_NN_CONV1x1_PERF_FIX */ - 0x0, /* gcFEATURE_BIT_NN_CACHELINE_MODE_PERF_FIX */ - 0x0, /* gcFEATURE_BIT_NN_PER3DTILE_BUBBLE_FIX */ - 0x0, /* gcFEATURE_BIT_NN_CONVOUT_FIFO_DEPTH_FIX */ 0x0, /* gcFEATURE_BIT_SWTILING_PHASE3 */ + 0x0, /* gcFEATURE_BIT_MCFE */ 0x0, /* gcFEATURE_BIT_USC_STAY_LRU */ - 0x0, /* gcFEATURE_BIT_NN_NONZERO_MIRROR_BORDER */ - 0x0, /* gcFEATURE_BIT_NN_COEF_DECOMPRESS_PERF2X */ - 0x0, /* gcFEATURE_BIT_INPUT_4BIT */ 0x0, /* gcFEATURE_BIT_COEF_COMPRESSION_ENHANCEMENT */ - 0x1, /* gcFEATURE_BIT_NN_ZXDP3_KERNEL_READ_CONFLICT_FIX */ - 0x0, /* gcFEATURE_BIT_NN_ZDP3_NO_COMPRESS_FIX */ - 0x0, /* gcFEATURE_BIT_NN_ASYNC_COPY_PERF_FIX */ + 0x0, /* gcFEATURE_BIT_TP_COEF_COMPRESSION_ENHANCEMENT */ + 0x0, /* gcFEATURE_BIT_NN_COEF_DECOMPRESS_PERF2X */ 0x1, /* gcFEATURE_BIT_OCB_COUNTER */ - 0x0, /* gcFEATURE_BIT_NN_XYDP0 */ - 0x0, /* gcFEATURE_BIT_ZRL_7BIT */ - 0x0, /* gcFEATURE_BIT_NN_ASYNC_COPY_MERGE_FIX */ - 0x0, /* gcFEATURE_BIT_NN_SMALLBATCH_PHASE1 */ - 0x0, /* gcFEATURE_BIT_TP_SMALLBATCH_PHASE1 */ 0x0, /* gcFEATURE_BIT_SCALER */ 0x0, /* gcFEATURE_BIT_SCALER_4K */ - 0x0, /* gcFEATURE_BIT_NN_REQ_SLOWARBITRATION_FIX */ - 0x0, /* gcFEATURE_BIT_IMAGE_PARTIAL_CACHE */ - 0x0, /* gcFEATURE_BIT_FULLCACHE_KERNELHEAD_FIX */ - 0x1, /* gcFEATURE_BIT_NN_SINGLEPORT_ACCUMBUFFER */ - 0x0, /* gcFEATURE_BIT_NN_SMALLBATCH */ - 0x0, /* gcFEATURE_BIT_TP_SMALLBATCH */ - 0x0, /* gcFEATURE_BIT_ZRL_8BIT */ + 0x0, /* gcFEATURE_BIT_INPUT_4BIT */ + 0x0, /* gcFEATURE_BIT_NN_NO_Z_LOCATION_OFFSET */ + 0x1, /* gcFEATURE_BIT_OCB_REMAP_PHYSICAL_ADDRESS */ + 0x0, /* gcFEATURE_BIT_NN_SLOW_OUTPUT */ + 0x1, /* gcFEATURE_BIT_NO_NARROW_POST_PROCESS_PIPE */ + 0x0, /* gcFEATURE_BIT_TP_NN_PROBE */ 0x0, /* gcFEATURE_BIT_NN_DEPTHWISE_SUPPORT */ + 0x0, /* gcFEATURE_BIT_NN_XYDP0 */ 0x0, /* gcFEATURE_BIT_NN_WRITE_WITHOUT_USC */ - 0x0, /* gcFEATURE_BIT_NN_ZDP_INIMAGE_SIZE_FIX */ - 0x0, /* gcFEATURE_BIT_HI_REORDER_FIX */ - 0x0, /* gcFEATURE_BIT_INCORRECT_WR_REQ_TO_USC_BETWEEN_REORDER_AND_NORMAL_LAYER_FIX */ - 0x0, /* gcFEATURE_BIT_TP_COEF_COMPRESSION_ENHANCEMENT */ - 0x0, /* gcFEATURE_BIT_VIP_DEC400 */ - 0x0, /* gcFEATURE_BIT_IMAGE_NOT_PACKED_IN_SRAM_FIX */ - 0x0, /* gcFEATURE_BIT_IDLE_BEFORE_FLUSH_COMPLETE_FIX */ - 0x1, /* gcFEATURE_BIT_NO_FLUSH_USC_FIX */ - 0x1, /* gcFEATURE_BIT_COEF_DELTA_CORD_OVERFLOW_ZRL_8BIT_FIX */ - 0x0, /* gcFEATURE_BIT_XY_OFFSET_LIMITATION_FIX */ - 0x0, /* gcFEATURE_BIT_USC_INVALIDATE_CACHE_LINE_FIX */ - 0x0, /* gcFEATURE_BIT_LOW_EFFICIENCY_OF_ID_WRITE_IMGBUF_FIX */ - 0x1, /* gcFEATURE_BIT_KERNEL_PER_CORE_LESS_THAN_THIRD_COEF_BUFF_DEPTH_FIX */ - 0x0, /* gcFEATURE_BIT_USC_BOTTLENECK_FIX */ - 0x0, /* gcFEATURE_BIT_KERNEL_SIZE_WASTE_IN_PARTIAL_MODE_FIX */ - 0x0, /* gcFEATURE_BIT_FULLCACHE_KERNEL_INTERLEAVE_FIX */ - 0x0, /* gcFEATURE_BIT_TP_REORDER_LAYER_SUSPEND_FIX */ - 0x1, /* gcFEATURE_BIT_KERNEL_VIP_SRAM_READ_BW_LIMITATION_FIX */ - 0x1, /* gcFEATURE_BIT_IMG_POP_PIPELINE_PAUSE_FIX */ - 0x0, /* gcFEATURE_BIT_DR_JD_DIFF_CONDITION_FOR_CACHELINE_MODE_PRE_FIX */ - 0x1, /* gcFEATURE_BIT_OUTIMAGE_X_BITWIDTH_LIMIT_FOR_NN_TRANSPOSE_FIX */ - 0x1, /* gcFEATURE_BIT_SMALL_BATCH_FLOPS_RESET_FIX */ - 0x0, /* gcFEATURE_BIT_SMALL_BATCH_DISBLE_FIX */ - 0x1, /* gcFEATURE_BIT_NEGATIVE_POST_SHIFT_FIX */ - 0x0, /* gcFEATURE_BIT_NN_COMMAND_KERNEL_REQUEST_CONFICT_FIX */ - 0x1, /* gcFEATURE_BIT_OCB_REMAP_PHYSICAL_ADDRESS */ - 0x0, /* gcFEATURE_BIT_NN_NO_Z_LOCATION_OFFSET */ - 0x0, /* gcFEATURE_BIT_NN_LEAKY_RELU */ - 0x0, /* gcFEATURE_BIT_NN_PRELU */ - 0x0, /* gcFEATURE_BIT_NN_PER_CHANNEL_QUANT */ - 0x0, /* gcFEATURE_BIT_NN_PER_CHANNEL_QUANT_ASYM */ - 0x0, /* gcFEATURE_BIT_NN_NATIVE_STRIDE_TWO */ - 0x0, /* gcFEATURE_BIT_NN_TENSOR_ADD */ - 0x0, /* gcFEATURE_BIT_NN_FLOAT_POST_MULT */ + 0x0, /* gcFEATURE_BIT_NN_HW_LIMITATION_NATIVE_KER_1x2_2x1 */ 0x0, /* gcFEATURE_BIT_NN_SLICE_PADDING_TO_64BYTE_ALIGN */ 0x0, /* gcFEATURE_BIT_NN_DW_1x1_CONV_MERGE */ - 0x0, /* gcFEATURE_BIT_NN_SLOW_OUTPUT */ - 0x1, /* gcFEATURE_BIT_NO_NARROW_POST_PROCESS_PIPE */ - 0x0, /* gcFEATURE_BIT_TP_NN_PROBE */ + 0x0, /* gcFEATURE_BIT_TP_BFLOAT16 */ 0x0, /* gcFEATURE_BIT_TP_23BITS_POST_MULTIPLIER */ 0x0, /* gcFEATURE_BIT_NN_TRANSPOSE */ - 0x0, /* gcFEATURE_BIT_EVIS2_FLOP_RESET_FIX */ - 0x0, /* gcFEATURE_BIT_USC_ASYNC_CP_RTN_FLOP_RESET_FIX */ - 0x0, /* gcFEATURE_BIT_DDR_BURST_LEN_256B */ - 0x1, /* gcFEATURE_BIT_IMG_CAHCE_MODE_MUST_0_IN_IMG_DIRECT_MODE_FIX */ 0x0, /* gcFEATURE_BIT_USE_SINGLE_PORT_VIPSRAM */ + 0x0, /* gcFEATURE_BIT_NN_LEAKY_RELU */ + 0x0, /* gcFEATURE_BIT_NN_PRELU */ + 0x0, /* gcFEATURE_BIT_NN_PER_CHANNEL_QUANT */ + 0x0, /* gcFEATURE_BIT_NN_PER_CHANNEL_QUANT_ASYM */ 0x0, /* gcFEATURE_BIT_NN_ASYMMETRIC_INT8 */ - 0x1, /* gcFEATURE_BIT_DEPTHWISE_NEIGHBOR_IMG_DATA_TRANSFER_NOT_EFFICIENT_FIX */ + 0x0, /* gcFEATURE_BIT_NN_FLOAT_POST_MULT */ 0x0, /* gcFEATURE_BIT_PRELU_LEAKLY_RELU_CLAMP */ - 0x0, /* gcFEATURE_BIT_TP_FLOAT32_IO */ + 0x0, /* gcFEATURE_BIT_TPLITE_BFLOAT16 */ + 0x0, /* gcFEATURE_BIT_PREPROCESS_IMG_BUF_640BYTE_LIMIT */ + 0x0, /* gcFEATURE_BIT_TP_KERNEL_1BYTE_ALGIN */ + 0x0, /* gcFEATURE_BIT_BFLOAT_COEF_COMPRESSION_ZERO_COEFBIT14_INVERSE */ + 0x0, /* gcFEATURE_BIT_NN_COMPRESSION_BYPASSS */ + 0x0, /* gcFEATURE_BIT_TP_3_USC */ + 0x0, /* gcFEATURE_BIT_BFP_COEF_AUTO_PAD_INCOMPLETE_ZERO_IN_KZ_PLANE */ + 0x0, /* gcFEATURE_BIT_NN_NATIVE_STRIDE_TWO */ + 0x0, /* gcFEATURE_BIT_NN_TENSOR_ADD */ 0x0, /* gcFEATURE_BIT_NN_FLOAT32_IO */ + 0x0, /* gcFEATURE_BIT_TP_FLOAT32_IO */ 0x0, /* gcFEATURE_BIT_NN_SMALL_BATCH_PHASE2 */ 0x0, /* gcFEATURE_BIT_TILE_ACCESS_CAPABILITY */ 0x0, /* gcFEATURE_BIT_FAST_DP3_PREPROCESSOR */ - 0x0, /* gcFEATURE_BIT_NN_COMPRESSION_BYPASSS */ - 0x0, /* gcFEATURE_BIT_BFLOAT_KERNEL_COMPRESSION_ZERO_SKIP_FIX */ - 0x0, /* gcFEATURE_BIT_TP_3_USC */ - 0x0, /* gcFEATURE_BIT_TP_KERNEL_1BYTE_ALGIN */ - 0x0, /* gcFEATURE_BIT_TPLITE_BFLOAT16 */ - 0x0, /* gcFEATURE_BIT_PREPROCESS_IMG_BUF_640BYTE_LIMIT */ - 0x0, /* gcFEATURE_BIT_V8_ACCUMLATION_READ_OUT_HAS_BUBBLES_PERF_FIX */ + 0x0, /* gcFEATURE_BIT_DEPTHWISE_SUPPORT_16BIT_FORMAT */ + 0x0, /* gcFEATURE_BIT_NN_SUPPORT_ALU_LUT */ + 0x0, /* gcFEATURE_BIT_NN_ENHANCED_MAX_POOLING */ + 0x0, /* gcFEATURE_BIT_NN_TRANSPOSE_PHASE2 */ + 0x0, /* gcFEATURE_BIT_TPLITE_SUPPORT_TP_DATA_TRANSPOSE */ + 0x0, /* gcFEATURE_BIT_NN_SUPPORT_CONV_1D */ + 0x0, /* gcFEATURE_BIT_USE_VIPSRAM_FOR_KERNEL_STREAMING */ + 0x0, /* gcFEATURE_BIT_VIP_DEC400 */ + 0x0, /* gcFEATURE_BIT_NN_PER3DTILE_BUBBLE_FIX */ + 0x0, /* gcFEATURE_BIT_NN_CACHELINE_MODE_PERF_FIX */ + 0x0, /* gcFEATURE_BIT_NN_CONV1x1_PERF_FIX */ + 0x1, /* gcFEATURE_BIT_TP_REORDER_FIX */ + 0x0, /* gcFEATURE_BIT_NN_CONVOUT_FIFO_DEPTH_FIX */ + 0x1, /* gcFEATURE_BIT_NN_ZXDP3_KERNEL_READ_CONFLICT_FIX */ + 0x0, /* gcFEATURE_BIT_NN_ZDP3_NO_COMPRESS_FIX */ + 0x0, /* gcFEATURE_BIT_NN_ASYNC_COPY_PERF_FIX */ + 0x0, /* gcFEATURE_BIT_HI_REORDER_FIX */ + 0x0, /* gcFEATURE_BIT_INCORRECT_WR_REQ_TO_USC_BETWEEN_REORDER_AND_NORMAL_LAYER_FIX */ + 0x0, /* gcFEATURE_BIT_TP_REORDER_LAYER_SUSPEND_FIX */ + 0x0, /* gcFEATURE_BIT_NN_ASYNC_COPY_MERGE_FIX */ + 0x0, /* gcFEATURE_BIT_USC_INVALIDATE_CACHE_LINE_FIX */ + 0x0, /* gcFEATURE_BIT_NN_REQ_SLOWARBITRATION_FIX */ + 0x0, /* gcFEATURE_BIT_IMAGE_PARTIAL_CACHE_FIX */ + 0x0, /* gcFEATURE_BIT_FULLCACHE_KERNELHEAD_FIX */ + 0x0, /* gcFEATURE_BIT_NN_ZDP_INIMAGE_SIZE_FIX */ + 0x0, /* gcFEATURE_BIT_IDLE_BEFORE_FLUSH_COMPLETE_FIX */ + 0x1, /* gcFEATURE_BIT_NO_FLUSH_USC_FIX */ + 0x1, /* gcFEATURE_BIT_SMALL_BATCH_FLOPS_RESET_FIX */ + 0x0, /* gcFEATURE_BIT_SMALL_BATCH_DISBLE_FIX */ + 0x1, /* gcFEATURE_BIT_OUTPUT_CONVERT_UINT8_INT8_TO_UINT16_INT16_FIX */ + 0x0, /* gcFEATURE_BIT_IMAGE_NOT_PACKED_IN_SRAM_FIX */ + 0x1, /* gcFEATURE_BIT_COEF_DELTA_CORD_OVERFLOW_ZRL_8BIT_FIX */ + 0x0, /* gcFEATURE_BIT_LOW_EFFICIENCY_OF_ID_WRITE_IMGBUF_FIX */ + 0x1, /* gcFEATURE_BIT_KERNEL_VIP_SRAM_READ_BW_LIMITATION_FIX */ + 0x0, /* gcFEATURE_BIT_USC_BOTTLENECK_FIX */ + 0x1, /* gcFEATURE_BIT_KERNEL_PER_CORE_LESS_THAN_THIRD_COEF_BUFF_DEPTH_FIX */ + 0x0, /* gcFEATURE_BIT_KERNEL_SIZE_WASTE_IN_PARTIAL_MODE_FIX */ + 0x0, /* gcFEATURE_BIT_NN_COMMAND_KERNEL_REQUEST_CONFICT_FIX */ + 0x0, /* gcFEATURE_BIT_TP_REORDER_INTILE_X_SIZE_512_FIX */ + 0x1, /* gcFEATURE_BIT_IMG_POP_PIPELINE_PAUSE_FIX */ + 0x0, /* gcFEATURE_BIT_FULLCACHE_KERNEL_INTERLEAVE_FIX */ 0x0, /* gcFEATURE_BIT_V8_SINGLE_PORT_ACCUMULATION_BUFFER_RW_CONFICT_ZERO_SKIP_PERF_FIX */ + 0x0, /* gcFEATURE_BIT_V8_ACCUMLATION_READ_OUT_HAS_BUBBLES_PERF_FIX */ + 0x1, /* gcFEATURE_BIT_DEPTHWISE_NEIGHBOR_IMG_DATA_TRANSFER_NOT_EFFICIENT_FIX */ + 0x0, /* gcFEATURE_BIT_DR_JD_DIFF_CONDITION_FOR_CACHELINE_MODE_PRE_FIX */ + 0x0, /* gcFEATURE_BIT_TP_ACCESS_VIPSRAM_OT_IS_ONE_FIX */ + 0x0, /* gcFEATURE_BIT_EVIS2_FLOP_RESET_FIX */ + 0x1, /* gcFEATURE_BIT_OUTIMAGE_X_BITWIDTH_LIMIT_FOR_NN_TRANSPOSE_FIX */ + 0x0, /* gcFEATURE_BIT_USC_ASYNC_CP_RTN_FLOP_RESET_FIX */ + 0x1, /* gcFEATURE_BIT_IMG_ADDR_NOT_WRAP_IF_OVER_OCB_ADDR_FIX */ + 0x1, /* gcFEATURE_BIT_NEGATIVE_POST_SHIFT_FIX */ + 0x0, /* gcFEATURE_BIT_INIMAGE_2DTILE_NOT_LESS_160PIXEL_FIX */ + 0x1, /* gcFEATURE_BIT_IMG_CAHCE_MODE_MUST_0_IN_IMG_DIRECT_MODE_FIX */ 0x0, /* gcFEATURE_BIT_BURST_COLLECT_DUMMY_DATA_WASTE_CYCLES_FIX */ 0x0, /* gcFEATURE_BIT_INIMG_NOT_64BYTE_ALIGN_CACHELINE_MODE_FIX */ - 0x0, /* gcFEATURE_BIT_TP_ACCESS_VIPSRAM_OT_IS_ONE_FIX */ - 0x1, /* gcFEATURE_BIT_VIP_HW_FINAL_RELEASE */ + 0x1, /* gcFEATURE_BIT_TP_FC_FLOAT_LAST_PIXEL_NEGATIVE_0_FIX */ + 0x1, /* gcFEATURE_BIT_NN_WASET_COEF_READ_WRITE_BANDWIDTH_128BYTE_VIPSRAM_IN_FULL_PATIAL_CACHE_MODE */ + 0x1, /* gcFEATURE_BIT_NN_IN_TILE_DATA_IS_ALL_PAD_FIX */ + 0x1, /* gcFEATURE_BIT_TP_FC_KERNEL_STREAM_MUST_LESS_THAN_OR_EQUAL_TO_64BYTE_WHEN_1BYTE_ALGINE_FIX */ + 0x0, /* gcFEATURE_BIT_NN_INTERLEVE8 */ + 0x0, /* gcFEATURE_BIT_NN_FP16_ALU */ + 0x1, /* gcFEATURE_BIT_NN_INT16_ALU */ + 0x1, /* gcFEATURE_BIT_NN_INT8_SCALE */ + 0x1, /* gcFEATURE_BIT_NN_POWER_ISOLATION */ + 0x0, /* gcFEATURE_BIT_ZRL_7BIT */ + 0x0, /* gcFEATURE_BIT_NN_SMALLBATCH_PHASE1 */ + 0x0, /* gcFEATURE_BIT_TP_SMALLBATCH_PHASE1 */ + 0x0, /* gcFEATURE_BIT_NN_SMALLBATCH */ + 0x0, /* gcFEATURE_BIT_TP_SMALLBATCH */ + 0x0, /* gcFEATURE_BIT_ZRL_8BIT */ + 0x0, /* gcFEATURE_BIT_DDR_BURST_LEN_256B */ + 0x0, /* gcFEATURE_BIT_XY_OFFSET_LIMITATION_FIX */ + 0x0, /* gcFEATURE_BIT_NN_NONZERO_MIRROR_BORDER */ + 0x0, /* gcFEATURE_BIT_IMAGE_PARTIAL_CACHE */ }, /* vipnano-qi */ { @@ -1253,13 +1367,23 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x140, /* gcFEATURE_VALUE_NumberOfConstants */ 0x1, /* gcFEATURE_VALUE_CoreCount */ 0x10, /* gcFEATURE_VALUE_LocalStorageSize */ + 0x0, /* gcFEATURE_VALUE_LocalStorageSize_1 */ + 0x0, /* gcFEATURE_VALUE_LocalStorageSize_2 */ 0x10, /* gcFEATURE_VALUE_L1CacheSize */ + 0x0, /* gcFEATURE_VALUE_L1CacheSize_1 */ + 0x0, /* gcFEATURE_VALUE_L1CacheSize_2 */ 0x200, /* gcFEATURE_VALUE_InstructionMemorySize */ 0x14, /* gcFEATURE_VALUE_ShaderPCLength */ 0x10, /* gcFEATURE_VALUE_USC_MAX_PAGES */ + 0x0, /* gcFEATURE_VALUE_USC_MAX_PAGES_1 */ + 0x0, /* gcFEATURE_VALUE_USC_MAX_PAGES_2 */ 0x1, /* gcFEATURE_VALUE_NumPixelPipes */ 0x2, /* gcFEATURE_VALUE_USC_CACHE_CONTROLLERS */ + 0x0, /* gcFEATURE_VALUE_USC_CACHE_CONTROLLERS_1 */ + 0x0, /* gcFEATURE_VALUE_USC_CACHE_CONTROLLERS_2 */ 0x2, /* gcFEATURE_VALUE_USC_BANKS */ + 0x0, /* gcFEATURE_VALUE_USC_BANKS_1 */ + 0x0, /* gcFEATURE_VALUE_USC_BANKS_2 */ 0x8, /* gcFEATURE_VALUE_Streams */ 0x10, /* gcFEATURE_VALUE_VaryingCount */ 0x400, /* gcFEATURE_VALUE_VertexOutputBufferSize */ @@ -1268,6 +1392,7 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_VALUE_NumResolvePipes */ 0x100, /* gcFEATURE_VALUE_RESULT_WINDOW_MAX_SIZE */ 0x0, /* gcFEATURE_VALUE_ClusterAliveMask */ + 0x0, /* gcFEATURE_VALUE_G2D_DEC400_MINOR */ 0x40, /* gcFEATURE_VALUE_NNMadPerCore */ 0x8, /* gcFEATURE_VALUE_NNCoreCount */ 0x8, /* gcFEATURE_VALUE_NNCoreCount_INT8 */ @@ -1292,14 +1417,26 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x20, /* gcFEATURE_VALUE_PHYSICAL_VIP_SRAM_WIDTH_IN_BYTE */ 0x10, /* gcFEATURE_VALUE_EQUIVALENT_VIP_SRAM_WIDTH_INBYTE */ 0x8, /* gcFEATURE_VALUE_TP_ZRL_BITS */ + 0x5, /* gcFEATURE_VALUE_NN_ZRL_BITS */ 0x80, /* gcFEATURE_VALUE_LATENCY_HIDING_AT_FULL_AXI_BW */ 0x10, /* gcFEATURE_VALUE_AXI_BUS_WIDTH */ 0xb, /* gcFEATURE_VALUE_NN_KERNEL_X_SIZE */ 0xb, /* gcFEATURE_VALUE_NN_KERNEL_Y_SIZE */ + 0xf, /* gcFEATURE_VALUE_NN_FC_KERNEL_Y_SIZE */ 0xfffff, /* gcFEATURE_VALUE_NN_KERNEL_Z_SIZE */ 0x7, /* gcFEATURE_VALUE_NN_X_OFFSET */ 0x7, /* gcFEATURE_VALUE_NN_Y_OFFSET */ 0x40, /* gcFEATURE_VALUE_DDR_KERNEL_BURST_SIZE */ + 0x10, /* gcFEATURE_VALUE_OUTIMAGE_X_STRIDE_BITS */ + 0x0, /* gcFEATURE_VALUE_OUTIMAGE_Y_STRIDE_BITS */ + 0x10, /* gcFEATURE_VALUE_INIMAGE_X_STRIDE_BITS */ + 0x10, /* gcFEATURE_VALUE_IMIMAGE_Y_STRIDE_BITS */ + 0xd, /* gcFEATURE_VALUE_OUTIMAGE_X_SIZE_BITS */ + 0xd, /* gcFEATURE_VALUE_OUTIMAGE_Y_SIZE_BITS */ + 0xe, /* gcFEATURE_VALUE_OUTIMAGE_SIZE_BITS */ + 0xd, /* gcFEATURE_VALUE_IMAGE_X_SIZE_BITS */ + 0xd, /* gcFEATURE_VALUE_INIMAGE_Y_SIZE_BITS */ + 0x40, /* gcFEATURE_VALUE_MAX_TILE_X_SIZE */ 0x0, /* gcFEATURE_BIT_REG_FastClear */ 0x0, /* gcFEATURE_BIT_REG_SpecialAntiAliasing */ 0x1, /* gcFEATURE_BIT_REG_Pipe3D */ @@ -1541,6 +1678,7 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x1, /* gcFEATURE_BIT_RA_HZEZ_CLOCK_CONTROL */ 0x1, /* gcFEATURE_BIT_CACHE128B256BPERLINE */ 0x1, /* gcFEATURE_BIT_V4Compression */ + 0x0, /* gcFEATURE_BIT_DE2D_MAJOR_SUPER_TILE */ 0x0, /* gcFEATURE_BIT_PE2D_MAJOR_SUPER_TILE */ 0x1, /* gcFEATURE_BIT_PE_32BPC_COLORMASK_FIX */ 0x1, /* gcFEATURE_BIT_ALPHA_BLENDING_OPT */ @@ -1673,6 +1811,7 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_BIT_TX_NO_FIXED_FILTER */ 0x0, /* gcFEATURE_BIT_SHARE_Z */ 0x0, /* gcFEATURE_BIT_DE_2D_FAST_CLEAR */ + 0x0, /* gcFEATURE_BIT_DE_TILESTATUS_ROTATION_FIX */ 0x0, /* gcFEATURE_BIT_TX_CLEAR_PENDING_FIX */ 0x0, /* gcFEATURE_BIT_NO_HI1_L2 */ 0x0, /* gcFEATURE_BIT_USC_EVICT_CTRL_FIFO_FLOP_RESET_FIX */ @@ -1683,6 +1822,13 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_BIT_SH_VX2_FLOATING_MAD_FIX */ 0x0, /* gcFEATURE_BIT_TS_FC_VULKAN_SUPPORT */ 0x0, /* gcFEATURE_BIT_MSAA_FLOAT_64BIT */ + 0x0, /* gcFEATURE_BIT_INDIRECT_COMPUTE_ZERODIM_FIX */ + 0x0, /* gcFEATURE_BIT_Q_CHANNEL_SUPPORT */ + 0x0, /* gcFEATURE_BIT_MMU_PAGE_DESCRIPTOR */ + 0x0, /* gcFEATURE_BIT_YUV_LINEAR_TO_TILE_ROTATE */ + 0x0, /* gcFEATURE_BIT_VEC2_IMULIMAD32_SUPPORT */ + 0x0, /* gcFEATURE_BIT_VEC4_IMULIMAD32_SUPPORT */ + 0x0, /* gcFEATURE_BIT_VEC2_IDIVIMOD16_SUPPORT */ 0x0, /* gcFEATURE_BIT_VG_TS_CULLING */ 0x0, /* gcFEATURE_BIT_VG_FP25 */ 0x0, /* gcFEATURE_BIT_VG_AYUV_INPUT_OUTPUT */ @@ -1709,6 +1855,20 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_BIT_DC_MMU */ 0x0, /* gcFEATURE_BIT_DC_COMPRESSION */ 0x0, /* gcFEATURE_BIT_DC_QOS */ + 0x1, /* gcFEATURE_BIT_VIP_HW_FINAL_RELEASE */ + 0x1, /* gcFEATURE_BIT_NN_SINGLEPORT_ACCUMBUFFER */ + 0x1, /* gcFEATURE_BIT_NN_STRIDE_SUPPORT */ + 0x1, /* gcFEATURE_BIT_SWTILING_PHASE1 */ + 0x0, /* gcFEATURE_BIT_SWTILING_PHASE2 */ + 0x1, /* gcFEATURE_BIT_TP_SIMPLE_INT16 */ + 0x0, /* gcFEATURE_BIT_TP_REAL_INT16 */ + 0x1, /* gcFEATURE_BIT_TP_ROI_POOLING */ + 0x1, /* gcFEATURE_BIT_TP_MAX_POOLING_STRIDE1 */ + 0x1, /* gcFEATURE_BIT_TP_LRN */ + 0x0, /* gcFEATURE_BIT_TP_REORDER */ + 0x1, /* gcFEATURE_BIT_TF_QUANTIZATION */ + 0x0, /* gcFEATURE_BIT_NN_NONZERO_BORDER */ + 0x0, /* gcFEATURE_BIT_NN_MIRROR_BORDER */ 0x0, /* gcFEATURE_BIT_AI_GPU */ 0x0, /* gcFEATURE_BIT_EVIS_NO_ABSDIFF */ 0x0, /* gcFEATURE_BIT_EVIS_NO_BITREPLACE */ @@ -1721,128 +1881,139 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_BIT_EVIS_LERP_7OUTPUT */ 0x0, /* gcFEATURE_BIT_EVIS_ACCSQ_8OUTPUT */ 0x1, /* gcFEATURE_BIT_EVIS_VX2 */ - 0x1, /* gcFEATURE_BIT_NN_FLOAT */ 0x1, /* gcFEATURE_BIT_TP_ENGINE */ 0x1, /* gcFEATURE_BIT_VIP_V7 */ - 0x0, /* gcFEATURE_BIT_MCFE */ - 0x0, /* gcFEATURE_BIT_NN_INTERLEVE8 */ - 0x0, /* gcFEATURE_BIT_TP_REORDER */ - 0x1, /* gcFEATURE_BIT_TP_LRN */ - 0x1, /* gcFEATURE_BIT_TP_MAX_POOLING_STRIDE1 */ - 0x0, /* gcFEATURE_BIT_NN_FP16_ALU */ - 0x1, /* gcFEATURE_BIT_NN_INT16_ALU */ - 0x1, /* gcFEATURE_BIT_TP_ROI_POOLING */ - 0x0, /* gcFEATURE_BIT_NN_ZDP3 */ + 0x0, /* gcFEATURE_BIT_TP_TENSOR_ADD_MUL */ + 0x0, /* gcFEATURE_BIT_NN_DEPTHWISE_INT16XINT8 */ + 0x0, /* gcFEATURE_BIT_TP_SOFTMAX */ + 0x0, /* gcFEATURE_BIT_NN_23BITS_POST_MULTIPLIER_VIP_V7 */ + 0x0, /* gcFEATURE_BIT_TP_23BITS_POST_MULTIPLIER_VIP_V7 */ + 0x0, /* gcFEATURE_BIT_HYBRID_MODE_VIP_V7 */ 0x0, /* gcFEATURE_BIT_NN_ZDP6 */ 0x0, /* gcFEATURE_BIT_NN_XYDP9 */ - 0x1, /* gcFEATURE_BIT_NN_INT8_SCALE */ - 0x1, /* gcFEATURE_BIT_NN_POWER_ISOLATION */ - 0x1, /* gcFEATURE_BIT_SWTILING_PHASE1 */ - 0x1, /* gcFEATURE_BIT_TF_QUANTIZATION */ - 0x1, /* gcFEATURE_BIT_TP_SIMPLE_INT16 */ - 0x0, /* gcFEATURE_BIT_TP_REAL_INT16 */ - 0x0, /* gcFEATURE_BIT_TP_BFLOAT16 */ 0x0, /* gcFEATURE_BIT_NN_FIRST_PIXEL_POOLING */ - 0x0, /* gcFEATURE_BIT_SWTILING_PHASE2 */ - 0x1, /* gcFEATURE_BIT_NN_STRIDE_SUPPORT */ + 0x0, /* gcFEATURE_BIT_NN_ZDP3 */ 0x0, /* gcFEATURE_BIT_NN_XYDP6 */ - 0x0, /* gcFEATURE_BIT_TP_REORDER_FIX */ - 0x0, /* gcFEATURE_BIT_NN_CONV1x1_PERF_FIX */ - 0x0, /* gcFEATURE_BIT_NN_CACHELINE_MODE_PERF_FIX */ - 0x0, /* gcFEATURE_BIT_NN_PER3DTILE_BUBBLE_FIX */ - 0x0, /* gcFEATURE_BIT_NN_CONVOUT_FIFO_DEPTH_FIX */ 0x0, /* gcFEATURE_BIT_SWTILING_PHASE3 */ + 0x0, /* gcFEATURE_BIT_MCFE */ 0x0, /* gcFEATURE_BIT_USC_STAY_LRU */ - 0x0, /* gcFEATURE_BIT_NN_NONZERO_MIRROR_BORDER */ + 0x0, /* gcFEATURE_BIT_COEF_COMPRESSION_ENHANCEMENT */ + 0x0, /* gcFEATURE_BIT_TP_COEF_COMPRESSION_ENHANCEMENT */ 0x0, /* gcFEATURE_BIT_NN_COEF_DECOMPRESS_PERF2X */ + 0x1, /* gcFEATURE_BIT_OCB_COUNTER */ + 0x0, /* gcFEATURE_BIT_SCALER */ + 0x0, /* gcFEATURE_BIT_SCALER_4K */ 0x0, /* gcFEATURE_BIT_INPUT_4BIT */ - 0x0, /* gcFEATURE_BIT_COEF_COMPRESSION_ENHANCEMENT */ + 0x0, /* gcFEATURE_BIT_NN_NO_Z_LOCATION_OFFSET */ + 0x1, /* gcFEATURE_BIT_OCB_REMAP_PHYSICAL_ADDRESS */ + 0x0, /* gcFEATURE_BIT_NN_SLOW_OUTPUT */ + 0x1, /* gcFEATURE_BIT_NO_NARROW_POST_PROCESS_PIPE */ + 0x0, /* gcFEATURE_BIT_TP_NN_PROBE */ + 0x0, /* gcFEATURE_BIT_NN_DEPTHWISE_SUPPORT */ + 0x0, /* gcFEATURE_BIT_NN_XYDP0 */ + 0x0, /* gcFEATURE_BIT_NN_WRITE_WITHOUT_USC */ + 0x0, /* gcFEATURE_BIT_NN_HW_LIMITATION_NATIVE_KER_1x2_2x1 */ + 0x0, /* gcFEATURE_BIT_NN_SLICE_PADDING_TO_64BYTE_ALIGN */ + 0x0, /* gcFEATURE_BIT_NN_DW_1x1_CONV_MERGE */ + 0x0, /* gcFEATURE_BIT_TP_BFLOAT16 */ + 0x0, /* gcFEATURE_BIT_TP_23BITS_POST_MULTIPLIER */ + 0x0, /* gcFEATURE_BIT_NN_TRANSPOSE */ + 0x0, /* gcFEATURE_BIT_USE_SINGLE_PORT_VIPSRAM */ + 0x0, /* gcFEATURE_BIT_NN_LEAKY_RELU */ + 0x0, /* gcFEATURE_BIT_NN_PRELU */ + 0x0, /* gcFEATURE_BIT_NN_PER_CHANNEL_QUANT */ + 0x0, /* gcFEATURE_BIT_NN_PER_CHANNEL_QUANT_ASYM */ + 0x0, /* gcFEATURE_BIT_NN_ASYMMETRIC_INT8 */ + 0x0, /* gcFEATURE_BIT_NN_FLOAT_POST_MULT */ + 0x0, /* gcFEATURE_BIT_PRELU_LEAKLY_RELU_CLAMP */ + 0x0, /* gcFEATURE_BIT_TPLITE_BFLOAT16 */ + 0x0, /* gcFEATURE_BIT_PREPROCESS_IMG_BUF_640BYTE_LIMIT */ + 0x0, /* gcFEATURE_BIT_TP_KERNEL_1BYTE_ALGIN */ + 0x0, /* gcFEATURE_BIT_BFLOAT_COEF_COMPRESSION_ZERO_COEFBIT14_INVERSE */ + 0x0, /* gcFEATURE_BIT_NN_COMPRESSION_BYPASSS */ + 0x0, /* gcFEATURE_BIT_TP_3_USC */ + 0x0, /* gcFEATURE_BIT_BFP_COEF_AUTO_PAD_INCOMPLETE_ZERO_IN_KZ_PLANE */ + 0x0, /* gcFEATURE_BIT_NN_NATIVE_STRIDE_TWO */ + 0x0, /* gcFEATURE_BIT_NN_TENSOR_ADD */ + 0x0, /* gcFEATURE_BIT_NN_FLOAT32_IO */ + 0x0, /* gcFEATURE_BIT_TP_FLOAT32_IO */ + 0x0, /* gcFEATURE_BIT_NN_SMALL_BATCH_PHASE2 */ + 0x0, /* gcFEATURE_BIT_TILE_ACCESS_CAPABILITY */ + 0x0, /* gcFEATURE_BIT_FAST_DP3_PREPROCESSOR */ + 0x0, /* gcFEATURE_BIT_DEPTHWISE_SUPPORT_16BIT_FORMAT */ + 0x0, /* gcFEATURE_BIT_NN_SUPPORT_ALU_LUT */ + 0x0, /* gcFEATURE_BIT_NN_ENHANCED_MAX_POOLING */ + 0x0, /* gcFEATURE_BIT_NN_TRANSPOSE_PHASE2 */ + 0x0, /* gcFEATURE_BIT_TPLITE_SUPPORT_TP_DATA_TRANSPOSE */ + 0x0, /* gcFEATURE_BIT_NN_SUPPORT_CONV_1D */ + 0x0, /* gcFEATURE_BIT_USE_VIPSRAM_FOR_KERNEL_STREAMING */ + 0x0, /* gcFEATURE_BIT_VIP_DEC400 */ + 0x0, /* gcFEATURE_BIT_NN_PER3DTILE_BUBBLE_FIX */ + 0x0, /* gcFEATURE_BIT_NN_CACHELINE_MODE_PERF_FIX */ + 0x0, /* gcFEATURE_BIT_NN_CONV1x1_PERF_FIX */ + 0x0, /* gcFEATURE_BIT_TP_REORDER_FIX */ + 0x0, /* gcFEATURE_BIT_NN_CONVOUT_FIFO_DEPTH_FIX */ 0x1, /* gcFEATURE_BIT_NN_ZXDP3_KERNEL_READ_CONFLICT_FIX */ 0x0, /* gcFEATURE_BIT_NN_ZDP3_NO_COMPRESS_FIX */ 0x0, /* gcFEATURE_BIT_NN_ASYNC_COPY_PERF_FIX */ - 0x1, /* gcFEATURE_BIT_OCB_COUNTER */ - 0x0, /* gcFEATURE_BIT_NN_XYDP0 */ - 0x0, /* gcFEATURE_BIT_ZRL_7BIT */ + 0x1, /* gcFEATURE_BIT_HI_REORDER_FIX */ + 0x1, /* gcFEATURE_BIT_INCORRECT_WR_REQ_TO_USC_BETWEEN_REORDER_AND_NORMAL_LAYER_FIX */ + 0x0, /* gcFEATURE_BIT_TP_REORDER_LAYER_SUSPEND_FIX */ 0x0, /* gcFEATURE_BIT_NN_ASYNC_COPY_MERGE_FIX */ - 0x0, /* gcFEATURE_BIT_NN_SMALLBATCH_PHASE1 */ - 0x0, /* gcFEATURE_BIT_TP_SMALLBATCH_PHASE1 */ - 0x0, /* gcFEATURE_BIT_SCALER */ - 0x0, /* gcFEATURE_BIT_SCALER_4K */ + 0x0, /* gcFEATURE_BIT_USC_INVALIDATE_CACHE_LINE_FIX */ 0x0, /* gcFEATURE_BIT_NN_REQ_SLOWARBITRATION_FIX */ - 0x0, /* gcFEATURE_BIT_IMAGE_PARTIAL_CACHE */ + 0x0, /* gcFEATURE_BIT_IMAGE_PARTIAL_CACHE_FIX */ 0x0, /* gcFEATURE_BIT_FULLCACHE_KERNELHEAD_FIX */ - 0x1, /* gcFEATURE_BIT_NN_SINGLEPORT_ACCUMBUFFER */ - 0x0, /* gcFEATURE_BIT_NN_SMALLBATCH */ - 0x0, /* gcFEATURE_BIT_TP_SMALLBATCH */ - 0x0, /* gcFEATURE_BIT_ZRL_8BIT */ - 0x0, /* gcFEATURE_BIT_NN_DEPTHWISE_SUPPORT */ - 0x0, /* gcFEATURE_BIT_NN_WRITE_WITHOUT_USC */ 0x0, /* gcFEATURE_BIT_NN_ZDP_INIMAGE_SIZE_FIX */ - 0x1, /* gcFEATURE_BIT_HI_REORDER_FIX */ - 0x1, /* gcFEATURE_BIT_INCORRECT_WR_REQ_TO_USC_BETWEEN_REORDER_AND_NORMAL_LAYER_FIX */ - 0x0, /* gcFEATURE_BIT_TP_COEF_COMPRESSION_ENHANCEMENT */ - 0x0, /* gcFEATURE_BIT_VIP_DEC400 */ - 0x0, /* gcFEATURE_BIT_IMAGE_NOT_PACKED_IN_SRAM_FIX */ 0x0, /* gcFEATURE_BIT_IDLE_BEFORE_FLUSH_COMPLETE_FIX */ 0x1, /* gcFEATURE_BIT_NO_FLUSH_USC_FIX */ + 0x0, /* gcFEATURE_BIT_SMALL_BATCH_FLOPS_RESET_FIX */ + 0x0, /* gcFEATURE_BIT_SMALL_BATCH_DISBLE_FIX */ + 0x1, /* gcFEATURE_BIT_OUTPUT_CONVERT_UINT8_INT8_TO_UINT16_INT16_FIX */ + 0x0, /* gcFEATURE_BIT_IMAGE_NOT_PACKED_IN_SRAM_FIX */ 0x1, /* gcFEATURE_BIT_COEF_DELTA_CORD_OVERFLOW_ZRL_8BIT_FIX */ - 0x0, /* gcFEATURE_BIT_XY_OFFSET_LIMITATION_FIX */ - 0x0, /* gcFEATURE_BIT_USC_INVALIDATE_CACHE_LINE_FIX */ 0x0, /* gcFEATURE_BIT_LOW_EFFICIENCY_OF_ID_WRITE_IMGBUF_FIX */ - 0x1, /* gcFEATURE_BIT_KERNEL_PER_CORE_LESS_THAN_THIRD_COEF_BUFF_DEPTH_FIX */ + 0x1, /* gcFEATURE_BIT_KERNEL_VIP_SRAM_READ_BW_LIMITATION_FIX */ 0x0, /* gcFEATURE_BIT_USC_BOTTLENECK_FIX */ + 0x1, /* gcFEATURE_BIT_KERNEL_PER_CORE_LESS_THAN_THIRD_COEF_BUFF_DEPTH_FIX */ 0x0, /* gcFEATURE_BIT_KERNEL_SIZE_WASTE_IN_PARTIAL_MODE_FIX */ - 0x0, /* gcFEATURE_BIT_FULLCACHE_KERNEL_INTERLEAVE_FIX */ - 0x0, /* gcFEATURE_BIT_TP_REORDER_LAYER_SUSPEND_FIX */ - 0x1, /* gcFEATURE_BIT_KERNEL_VIP_SRAM_READ_BW_LIMITATION_FIX */ + 0x0, /* gcFEATURE_BIT_NN_COMMAND_KERNEL_REQUEST_CONFICT_FIX */ + 0x0, /* gcFEATURE_BIT_TP_REORDER_INTILE_X_SIZE_512_FIX */ 0x1, /* gcFEATURE_BIT_IMG_POP_PIPELINE_PAUSE_FIX */ + 0x0, /* gcFEATURE_BIT_FULLCACHE_KERNEL_INTERLEAVE_FIX */ + 0x0, /* gcFEATURE_BIT_V8_SINGLE_PORT_ACCUMULATION_BUFFER_RW_CONFICT_ZERO_SKIP_PERF_FIX */ + 0x0, /* gcFEATURE_BIT_V8_ACCUMLATION_READ_OUT_HAS_BUBBLES_PERF_FIX */ + 0x1, /* gcFEATURE_BIT_DEPTHWISE_NEIGHBOR_IMG_DATA_TRANSFER_NOT_EFFICIENT_FIX */ 0x0, /* gcFEATURE_BIT_DR_JD_DIFF_CONDITION_FOR_CACHELINE_MODE_PRE_FIX */ - 0x1, /* gcFEATURE_BIT_OUTIMAGE_X_BITWIDTH_LIMIT_FOR_NN_TRANSPOSE_FIX */ - 0x0, /* gcFEATURE_BIT_SMALL_BATCH_FLOPS_RESET_FIX */ - 0x0, /* gcFEATURE_BIT_SMALL_BATCH_DISBLE_FIX */ - 0x1, /* gcFEATURE_BIT_NEGATIVE_POST_SHIFT_FIX */ - 0x0, /* gcFEATURE_BIT_NN_COMMAND_KERNEL_REQUEST_CONFICT_FIX */ - 0x1, /* gcFEATURE_BIT_OCB_REMAP_PHYSICAL_ADDRESS */ - 0x0, /* gcFEATURE_BIT_NN_NO_Z_LOCATION_OFFSET */ - 0x0, /* gcFEATURE_BIT_NN_LEAKY_RELU */ - 0x0, /* gcFEATURE_BIT_NN_PRELU */ - 0x0, /* gcFEATURE_BIT_NN_PER_CHANNEL_QUANT */ - 0x0, /* gcFEATURE_BIT_NN_PER_CHANNEL_QUANT_ASYM */ - 0x0, /* gcFEATURE_BIT_NN_NATIVE_STRIDE_TWO */ - 0x0, /* gcFEATURE_BIT_NN_TENSOR_ADD */ - 0x0, /* gcFEATURE_BIT_NN_FLOAT_POST_MULT */ - 0x0, /* gcFEATURE_BIT_NN_SLICE_PADDING_TO_64BYTE_ALIGN */ - 0x0, /* gcFEATURE_BIT_NN_DW_1x1_CONV_MERGE */ - 0x0, /* gcFEATURE_BIT_NN_SLOW_OUTPUT */ - 0x1, /* gcFEATURE_BIT_NO_NARROW_POST_PROCESS_PIPE */ - 0x0, /* gcFEATURE_BIT_TP_NN_PROBE */ - 0x0, /* gcFEATURE_BIT_TP_23BITS_POST_MULTIPLIER */ - 0x0, /* gcFEATURE_BIT_NN_TRANSPOSE */ + 0x0, /* gcFEATURE_BIT_TP_ACCESS_VIPSRAM_OT_IS_ONE_FIX */ 0x0, /* gcFEATURE_BIT_EVIS2_FLOP_RESET_FIX */ + 0x1, /* gcFEATURE_BIT_OUTIMAGE_X_BITWIDTH_LIMIT_FOR_NN_TRANSPOSE_FIX */ 0x0, /* gcFEATURE_BIT_USC_ASYNC_CP_RTN_FLOP_RESET_FIX */ - 0x0, /* gcFEATURE_BIT_DDR_BURST_LEN_256B */ + 0x1, /* gcFEATURE_BIT_IMG_ADDR_NOT_WRAP_IF_OVER_OCB_ADDR_FIX */ + 0x1, /* gcFEATURE_BIT_NEGATIVE_POST_SHIFT_FIX */ + 0x0, /* gcFEATURE_BIT_INIMAGE_2DTILE_NOT_LESS_160PIXEL_FIX */ 0x1, /* gcFEATURE_BIT_IMG_CAHCE_MODE_MUST_0_IN_IMG_DIRECT_MODE_FIX */ - 0x0, /* gcFEATURE_BIT_USE_SINGLE_PORT_VIPSRAM */ - 0x0, /* gcFEATURE_BIT_NN_ASYMMETRIC_INT8 */ - 0x1, /* gcFEATURE_BIT_DEPTHWISE_NEIGHBOR_IMG_DATA_TRANSFER_NOT_EFFICIENT_FIX */ - 0x0, /* gcFEATURE_BIT_PRELU_LEAKLY_RELU_CLAMP */ - 0x0, /* gcFEATURE_BIT_TP_FLOAT32_IO */ - 0x0, /* gcFEATURE_BIT_NN_FLOAT32_IO */ - 0x0, /* gcFEATURE_BIT_NN_SMALL_BATCH_PHASE2 */ - 0x0, /* gcFEATURE_BIT_TILE_ACCESS_CAPABILITY */ - 0x0, /* gcFEATURE_BIT_FAST_DP3_PREPROCESSOR */ - 0x0, /* gcFEATURE_BIT_NN_COMPRESSION_BYPASSS */ - 0x0, /* gcFEATURE_BIT_BFLOAT_KERNEL_COMPRESSION_ZERO_SKIP_FIX */ - 0x0, /* gcFEATURE_BIT_TP_3_USC */ - 0x0, /* gcFEATURE_BIT_TP_KERNEL_1BYTE_ALGIN */ - 0x0, /* gcFEATURE_BIT_TPLITE_BFLOAT16 */ - 0x0, /* gcFEATURE_BIT_PREPROCESS_IMG_BUF_640BYTE_LIMIT */ - 0x0, /* gcFEATURE_BIT_V8_ACCUMLATION_READ_OUT_HAS_BUBBLES_PERF_FIX */ - 0x0, /* gcFEATURE_BIT_V8_SINGLE_PORT_ACCUMULATION_BUFFER_RW_CONFICT_ZERO_SKIP_PERF_FIX */ 0x0, /* gcFEATURE_BIT_BURST_COLLECT_DUMMY_DATA_WASTE_CYCLES_FIX */ 0x0, /* gcFEATURE_BIT_INIMG_NOT_64BYTE_ALIGN_CACHELINE_MODE_FIX */ - 0x0, /* gcFEATURE_BIT_TP_ACCESS_VIPSRAM_OT_IS_ONE_FIX */ - 0x1, /* gcFEATURE_BIT_VIP_HW_FINAL_RELEASE */ + 0x1, /* gcFEATURE_BIT_TP_FC_FLOAT_LAST_PIXEL_NEGATIVE_0_FIX */ + 0x1, /* gcFEATURE_BIT_NN_WASET_COEF_READ_WRITE_BANDWIDTH_128BYTE_VIPSRAM_IN_FULL_PATIAL_CACHE_MODE */ + 0x1, /* gcFEATURE_BIT_NN_IN_TILE_DATA_IS_ALL_PAD_FIX */ + 0x1, /* gcFEATURE_BIT_TP_FC_KERNEL_STREAM_MUST_LESS_THAN_OR_EQUAL_TO_64BYTE_WHEN_1BYTE_ALGINE_FIX */ + 0x0, /* gcFEATURE_BIT_NN_INTERLEVE8 */ + 0x0, /* gcFEATURE_BIT_NN_FP16_ALU */ + 0x1, /* gcFEATURE_BIT_NN_INT16_ALU */ + 0x1, /* gcFEATURE_BIT_NN_INT8_SCALE */ + 0x1, /* gcFEATURE_BIT_NN_POWER_ISOLATION */ + 0x0, /* gcFEATURE_BIT_ZRL_7BIT */ + 0x0, /* gcFEATURE_BIT_NN_SMALLBATCH_PHASE1 */ + 0x0, /* gcFEATURE_BIT_TP_SMALLBATCH_PHASE1 */ + 0x0, /* gcFEATURE_BIT_NN_SMALLBATCH */ + 0x0, /* gcFEATURE_BIT_TP_SMALLBATCH */ + 0x0, /* gcFEATURE_BIT_ZRL_8BIT */ + 0x0, /* gcFEATURE_BIT_DDR_BURST_LEN_256B */ + 0x0, /* gcFEATURE_BIT_XY_OFFSET_LIMITATION_FIX */ + 0x0, /* gcFEATURE_BIT_NN_NONZERO_MIRROR_BORDER */ + 0x0, /* gcFEATURE_BIT_IMAGE_PARTIAL_CACHE */ }, /* vipnano-qi */ { @@ -1861,13 +2032,23 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x140, /* gcFEATURE_VALUE_NumberOfConstants */ 0x1, /* gcFEATURE_VALUE_CoreCount */ 0x10, /* gcFEATURE_VALUE_LocalStorageSize */ + 0x0, /* gcFEATURE_VALUE_LocalStorageSize_1 */ + 0x0, /* gcFEATURE_VALUE_LocalStorageSize_2 */ 0x10, /* gcFEATURE_VALUE_L1CacheSize */ + 0x0, /* gcFEATURE_VALUE_L1CacheSize_1 */ + 0x0, /* gcFEATURE_VALUE_L1CacheSize_2 */ 0x200, /* gcFEATURE_VALUE_InstructionMemorySize */ 0x14, /* gcFEATURE_VALUE_ShaderPCLength */ 0x10, /* gcFEATURE_VALUE_USC_MAX_PAGES */ + 0x0, /* gcFEATURE_VALUE_USC_MAX_PAGES_1 */ + 0x0, /* gcFEATURE_VALUE_USC_MAX_PAGES_2 */ 0x1, /* gcFEATURE_VALUE_NumPixelPipes */ 0x2, /* gcFEATURE_VALUE_USC_CACHE_CONTROLLERS */ + 0x0, /* gcFEATURE_VALUE_USC_CACHE_CONTROLLERS_1 */ + 0x0, /* gcFEATURE_VALUE_USC_CACHE_CONTROLLERS_2 */ 0x2, /* gcFEATURE_VALUE_USC_BANKS */ + 0x0, /* gcFEATURE_VALUE_USC_BANKS_1 */ + 0x0, /* gcFEATURE_VALUE_USC_BANKS_2 */ 0x8, /* gcFEATURE_VALUE_Streams */ 0x10, /* gcFEATURE_VALUE_VaryingCount */ 0x400, /* gcFEATURE_VALUE_VertexOutputBufferSize */ @@ -1876,6 +2057,7 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_VALUE_NumResolvePipes */ 0x100, /* gcFEATURE_VALUE_RESULT_WINDOW_MAX_SIZE */ 0x0, /* gcFEATURE_VALUE_ClusterAliveMask */ + 0x0, /* gcFEATURE_VALUE_G2D_DEC400_MINOR */ 0x40, /* gcFEATURE_VALUE_NNMadPerCore */ 0x8, /* gcFEATURE_VALUE_NNCoreCount */ 0x8, /* gcFEATURE_VALUE_NNCoreCount_INT8 */ @@ -1900,14 +2082,26 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x20, /* gcFEATURE_VALUE_PHYSICAL_VIP_SRAM_WIDTH_IN_BYTE */ 0x10, /* gcFEATURE_VALUE_EQUIVALENT_VIP_SRAM_WIDTH_INBYTE */ 0x8, /* gcFEATURE_VALUE_TP_ZRL_BITS */ + 0x5, /* gcFEATURE_VALUE_NN_ZRL_BITS */ 0x80, /* gcFEATURE_VALUE_LATENCY_HIDING_AT_FULL_AXI_BW */ 0x10, /* gcFEATURE_VALUE_AXI_BUS_WIDTH */ 0xf, /* gcFEATURE_VALUE_NN_KERNEL_X_SIZE */ 0xf, /* gcFEATURE_VALUE_NN_KERNEL_Y_SIZE */ + 0xf, /* gcFEATURE_VALUE_NN_FC_KERNEL_Y_SIZE */ 0xfffff, /* gcFEATURE_VALUE_NN_KERNEL_Z_SIZE */ 0xf, /* gcFEATURE_VALUE_NN_X_OFFSET */ 0xf, /* gcFEATURE_VALUE_NN_Y_OFFSET */ 0x40, /* gcFEATURE_VALUE_DDR_KERNEL_BURST_SIZE */ + 0x10, /* gcFEATURE_VALUE_OUTIMAGE_X_STRIDE_BITS */ + 0x0, /* gcFEATURE_VALUE_OUTIMAGE_Y_STRIDE_BITS */ + 0x10, /* gcFEATURE_VALUE_INIMAGE_X_STRIDE_BITS */ + 0x10, /* gcFEATURE_VALUE_IMIMAGE_Y_STRIDE_BITS */ + 0xd, /* gcFEATURE_VALUE_OUTIMAGE_X_SIZE_BITS */ + 0xd, /* gcFEATURE_VALUE_OUTIMAGE_Y_SIZE_BITS */ + 0xe, /* gcFEATURE_VALUE_OUTIMAGE_SIZE_BITS */ + 0xd, /* gcFEATURE_VALUE_IMAGE_X_SIZE_BITS */ + 0xd, /* gcFEATURE_VALUE_INIMAGE_Y_SIZE_BITS */ + 0x40, /* gcFEATURE_VALUE_MAX_TILE_X_SIZE */ 0x0, /* gcFEATURE_BIT_REG_FastClear */ 0x0, /* gcFEATURE_BIT_REG_SpecialAntiAliasing */ 0x1, /* gcFEATURE_BIT_REG_Pipe3D */ @@ -2149,6 +2343,7 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x1, /* gcFEATURE_BIT_RA_HZEZ_CLOCK_CONTROL */ 0x1, /* gcFEATURE_BIT_CACHE128B256BPERLINE */ 0x1, /* gcFEATURE_BIT_V4Compression */ + 0x0, /* gcFEATURE_BIT_DE2D_MAJOR_SUPER_TILE */ 0x0, /* gcFEATURE_BIT_PE2D_MAJOR_SUPER_TILE */ 0x1, /* gcFEATURE_BIT_PE_32BPC_COLORMASK_FIX */ 0x1, /* gcFEATURE_BIT_ALPHA_BLENDING_OPT */ @@ -2281,6 +2476,7 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_BIT_TX_NO_FIXED_FILTER */ 0x0, /* gcFEATURE_BIT_SHARE_Z */ 0x0, /* gcFEATURE_BIT_DE_2D_FAST_CLEAR */ + 0x0, /* gcFEATURE_BIT_DE_TILESTATUS_ROTATION_FIX */ 0x0, /* gcFEATURE_BIT_TX_CLEAR_PENDING_FIX */ 0x0, /* gcFEATURE_BIT_NO_HI1_L2 */ 0x0, /* gcFEATURE_BIT_USC_EVICT_CTRL_FIFO_FLOP_RESET_FIX */ @@ -2291,6 +2487,13 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_BIT_SH_VX2_FLOATING_MAD_FIX */ 0x0, /* gcFEATURE_BIT_TS_FC_VULKAN_SUPPORT */ 0x0, /* gcFEATURE_BIT_MSAA_FLOAT_64BIT */ + 0x0, /* gcFEATURE_BIT_INDIRECT_COMPUTE_ZERODIM_FIX */ + 0x0, /* gcFEATURE_BIT_Q_CHANNEL_SUPPORT */ + 0x0, /* gcFEATURE_BIT_MMU_PAGE_DESCRIPTOR */ + 0x0, /* gcFEATURE_BIT_YUV_LINEAR_TO_TILE_ROTATE */ + 0x0, /* gcFEATURE_BIT_VEC2_IMULIMAD32_SUPPORT */ + 0x0, /* gcFEATURE_BIT_VEC4_IMULIMAD32_SUPPORT */ + 0x0, /* gcFEATURE_BIT_VEC2_IDIVIMOD16_SUPPORT */ 0x0, /* gcFEATURE_BIT_VG_TS_CULLING */ 0x0, /* gcFEATURE_BIT_VG_FP25 */ 0x0, /* gcFEATURE_BIT_VG_AYUV_INPUT_OUTPUT */ @@ -2317,6 +2520,20 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_BIT_DC_MMU */ 0x0, /* gcFEATURE_BIT_DC_COMPRESSION */ 0x0, /* gcFEATURE_BIT_DC_QOS */ + 0x1, /* gcFEATURE_BIT_VIP_HW_FINAL_RELEASE */ + 0x1, /* gcFEATURE_BIT_NN_SINGLEPORT_ACCUMBUFFER */ + 0x1, /* gcFEATURE_BIT_NN_STRIDE_SUPPORT */ + 0x1, /* gcFEATURE_BIT_SWTILING_PHASE1 */ + 0x1, /* gcFEATURE_BIT_SWTILING_PHASE2 */ + 0x0, /* gcFEATURE_BIT_TP_SIMPLE_INT16 */ + 0x1, /* gcFEATURE_BIT_TP_REAL_INT16 */ + 0x1, /* gcFEATURE_BIT_TP_ROI_POOLING */ + 0x1, /* gcFEATURE_BIT_TP_MAX_POOLING_STRIDE1 */ + 0x1, /* gcFEATURE_BIT_TP_LRN */ + 0x1, /* gcFEATURE_BIT_TP_REORDER */ + 0x1, /* gcFEATURE_BIT_TF_QUANTIZATION */ + 0x0, /* gcFEATURE_BIT_NN_NONZERO_BORDER */ + 0x0, /* gcFEATURE_BIT_NN_MIRROR_BORDER */ 0x0, /* gcFEATURE_BIT_AI_GPU */ 0x0, /* gcFEATURE_BIT_EVIS_NO_ABSDIFF */ 0x0, /* gcFEATURE_BIT_EVIS_NO_BITREPLACE */ @@ -2329,128 +2546,139 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_BIT_EVIS_LERP_7OUTPUT */ 0x0, /* gcFEATURE_BIT_EVIS_ACCSQ_8OUTPUT */ 0x1, /* gcFEATURE_BIT_EVIS_VX2 */ - 0x1, /* gcFEATURE_BIT_NN_FLOAT */ 0x1, /* gcFEATURE_BIT_TP_ENGINE */ 0x1, /* gcFEATURE_BIT_VIP_V7 */ - 0x0, /* gcFEATURE_BIT_MCFE */ - 0x0, /* gcFEATURE_BIT_NN_INTERLEVE8 */ - 0x1, /* gcFEATURE_BIT_TP_REORDER */ - 0x1, /* gcFEATURE_BIT_TP_LRN */ - 0x1, /* gcFEATURE_BIT_TP_MAX_POOLING_STRIDE1 */ - 0x0, /* gcFEATURE_BIT_NN_FP16_ALU */ - 0x1, /* gcFEATURE_BIT_NN_INT16_ALU */ - 0x1, /* gcFEATURE_BIT_TP_ROI_POOLING */ - 0x1, /* gcFEATURE_BIT_NN_ZDP3 */ + 0x0, /* gcFEATURE_BIT_TP_TENSOR_ADD_MUL */ + 0x0, /* gcFEATURE_BIT_NN_DEPTHWISE_INT16XINT8 */ + 0x0, /* gcFEATURE_BIT_TP_SOFTMAX */ + 0x0, /* gcFEATURE_BIT_NN_23BITS_POST_MULTIPLIER_VIP_V7 */ + 0x0, /* gcFEATURE_BIT_TP_23BITS_POST_MULTIPLIER_VIP_V7 */ + 0x0, /* gcFEATURE_BIT_HYBRID_MODE_VIP_V7 */ 0x0, /* gcFEATURE_BIT_NN_ZDP6 */ 0x0, /* gcFEATURE_BIT_NN_XYDP9 */ - 0x1, /* gcFEATURE_BIT_NN_INT8_SCALE */ - 0x1, /* gcFEATURE_BIT_NN_POWER_ISOLATION */ - 0x1, /* gcFEATURE_BIT_SWTILING_PHASE1 */ - 0x1, /* gcFEATURE_BIT_TF_QUANTIZATION */ - 0x0, /* gcFEATURE_BIT_TP_SIMPLE_INT16 */ - 0x1, /* gcFEATURE_BIT_TP_REAL_INT16 */ - 0x0, /* gcFEATURE_BIT_TP_BFLOAT16 */ 0x1, /* gcFEATURE_BIT_NN_FIRST_PIXEL_POOLING */ - 0x1, /* gcFEATURE_BIT_SWTILING_PHASE2 */ - 0x1, /* gcFEATURE_BIT_NN_STRIDE_SUPPORT */ + 0x1, /* gcFEATURE_BIT_NN_ZDP3 */ 0x1, /* gcFEATURE_BIT_NN_XYDP6 */ - 0x1, /* gcFEATURE_BIT_TP_REORDER_FIX */ - 0x1, /* gcFEATURE_BIT_NN_CONV1x1_PERF_FIX */ - 0x0, /* gcFEATURE_BIT_NN_CACHELINE_MODE_PERF_FIX */ - 0x0, /* gcFEATURE_BIT_NN_PER3DTILE_BUBBLE_FIX */ - 0x1, /* gcFEATURE_BIT_NN_CONVOUT_FIFO_DEPTH_FIX */ 0x0, /* gcFEATURE_BIT_SWTILING_PHASE3 */ + 0x0, /* gcFEATURE_BIT_MCFE */ 0x0, /* gcFEATURE_BIT_USC_STAY_LRU */ - 0x0, /* gcFEATURE_BIT_NN_NONZERO_MIRROR_BORDER */ + 0x0, /* gcFEATURE_BIT_COEF_COMPRESSION_ENHANCEMENT */ + 0x0, /* gcFEATURE_BIT_TP_COEF_COMPRESSION_ENHANCEMENT */ 0x0, /* gcFEATURE_BIT_NN_COEF_DECOMPRESS_PERF2X */ + 0x1, /* gcFEATURE_BIT_OCB_COUNTER */ + 0x0, /* gcFEATURE_BIT_SCALER */ + 0x0, /* gcFEATURE_BIT_SCALER_4K */ 0x0, /* gcFEATURE_BIT_INPUT_4BIT */ - 0x0, /* gcFEATURE_BIT_COEF_COMPRESSION_ENHANCEMENT */ + 0x0, /* gcFEATURE_BIT_NN_NO_Z_LOCATION_OFFSET */ + 0x1, /* gcFEATURE_BIT_OCB_REMAP_PHYSICAL_ADDRESS */ + 0x0, /* gcFEATURE_BIT_NN_SLOW_OUTPUT */ + 0x1, /* gcFEATURE_BIT_NO_NARROW_POST_PROCESS_PIPE */ + 0x0, /* gcFEATURE_BIT_TP_NN_PROBE */ + 0x0, /* gcFEATURE_BIT_NN_DEPTHWISE_SUPPORT */ + 0x0, /* gcFEATURE_BIT_NN_XYDP0 */ + 0x0, /* gcFEATURE_BIT_NN_WRITE_WITHOUT_USC */ + 0x0, /* gcFEATURE_BIT_NN_HW_LIMITATION_NATIVE_KER_1x2_2x1 */ + 0x0, /* gcFEATURE_BIT_NN_SLICE_PADDING_TO_64BYTE_ALIGN */ + 0x0, /* gcFEATURE_BIT_NN_DW_1x1_CONV_MERGE */ + 0x0, /* gcFEATURE_BIT_TP_BFLOAT16 */ + 0x0, /* gcFEATURE_BIT_TP_23BITS_POST_MULTIPLIER */ + 0x0, /* gcFEATURE_BIT_NN_TRANSPOSE */ + 0x0, /* gcFEATURE_BIT_USE_SINGLE_PORT_VIPSRAM */ + 0x0, /* gcFEATURE_BIT_NN_LEAKY_RELU */ + 0x0, /* gcFEATURE_BIT_NN_PRELU */ + 0x0, /* gcFEATURE_BIT_NN_PER_CHANNEL_QUANT */ + 0x0, /* gcFEATURE_BIT_NN_PER_CHANNEL_QUANT_ASYM */ + 0x0, /* gcFEATURE_BIT_NN_ASYMMETRIC_INT8 */ + 0x0, /* gcFEATURE_BIT_NN_FLOAT_POST_MULT */ + 0x0, /* gcFEATURE_BIT_PRELU_LEAKLY_RELU_CLAMP */ + 0x0, /* gcFEATURE_BIT_TPLITE_BFLOAT16 */ + 0x0, /* gcFEATURE_BIT_PREPROCESS_IMG_BUF_640BYTE_LIMIT */ + 0x0, /* gcFEATURE_BIT_TP_KERNEL_1BYTE_ALGIN */ + 0x0, /* gcFEATURE_BIT_BFLOAT_COEF_COMPRESSION_ZERO_COEFBIT14_INVERSE */ + 0x0, /* gcFEATURE_BIT_NN_COMPRESSION_BYPASSS */ + 0x0, /* gcFEATURE_BIT_TP_3_USC */ + 0x0, /* gcFEATURE_BIT_BFP_COEF_AUTO_PAD_INCOMPLETE_ZERO_IN_KZ_PLANE */ + 0x0, /* gcFEATURE_BIT_NN_NATIVE_STRIDE_TWO */ + 0x0, /* gcFEATURE_BIT_NN_TENSOR_ADD */ + 0x0, /* gcFEATURE_BIT_NN_FLOAT32_IO */ + 0x0, /* gcFEATURE_BIT_TP_FLOAT32_IO */ + 0x0, /* gcFEATURE_BIT_NN_SMALL_BATCH_PHASE2 */ + 0x0, /* gcFEATURE_BIT_TILE_ACCESS_CAPABILITY */ + 0x0, /* gcFEATURE_BIT_FAST_DP3_PREPROCESSOR */ + 0x0, /* gcFEATURE_BIT_DEPTHWISE_SUPPORT_16BIT_FORMAT */ + 0x0, /* gcFEATURE_BIT_NN_SUPPORT_ALU_LUT */ + 0x0, /* gcFEATURE_BIT_NN_ENHANCED_MAX_POOLING */ + 0x0, /* gcFEATURE_BIT_NN_TRANSPOSE_PHASE2 */ + 0x0, /* gcFEATURE_BIT_TPLITE_SUPPORT_TP_DATA_TRANSPOSE */ + 0x0, /* gcFEATURE_BIT_NN_SUPPORT_CONV_1D */ + 0x0, /* gcFEATURE_BIT_USE_VIPSRAM_FOR_KERNEL_STREAMING */ + 0x0, /* gcFEATURE_BIT_VIP_DEC400 */ + 0x0, /* gcFEATURE_BIT_NN_PER3DTILE_BUBBLE_FIX */ + 0x0, /* gcFEATURE_BIT_NN_CACHELINE_MODE_PERF_FIX */ + 0x1, /* gcFEATURE_BIT_NN_CONV1x1_PERF_FIX */ + 0x1, /* gcFEATURE_BIT_TP_REORDER_FIX */ + 0x1, /* gcFEATURE_BIT_NN_CONVOUT_FIFO_DEPTH_FIX */ 0x1, /* gcFEATURE_BIT_NN_ZXDP3_KERNEL_READ_CONFLICT_FIX */ 0x0, /* gcFEATURE_BIT_NN_ZDP3_NO_COMPRESS_FIX */ 0x1, /* gcFEATURE_BIT_NN_ASYNC_COPY_PERF_FIX */ - 0x1, /* gcFEATURE_BIT_OCB_COUNTER */ - 0x0, /* gcFEATURE_BIT_NN_XYDP0 */ - 0x0, /* gcFEATURE_BIT_ZRL_7BIT */ + 0x1, /* gcFEATURE_BIT_HI_REORDER_FIX */ + 0x1, /* gcFEATURE_BIT_INCORRECT_WR_REQ_TO_USC_BETWEEN_REORDER_AND_NORMAL_LAYER_FIX */ + 0x0, /* gcFEATURE_BIT_TP_REORDER_LAYER_SUSPEND_FIX */ 0x1, /* gcFEATURE_BIT_NN_ASYNC_COPY_MERGE_FIX */ - 0x0, /* gcFEATURE_BIT_NN_SMALLBATCH_PHASE1 */ - 0x0, /* gcFEATURE_BIT_TP_SMALLBATCH_PHASE1 */ - 0x0, /* gcFEATURE_BIT_SCALER */ - 0x0, /* gcFEATURE_BIT_SCALER_4K */ + 0x0, /* gcFEATURE_BIT_USC_INVALIDATE_CACHE_LINE_FIX */ 0x0, /* gcFEATURE_BIT_NN_REQ_SLOWARBITRATION_FIX */ - 0x0, /* gcFEATURE_BIT_IMAGE_PARTIAL_CACHE */ + 0x0, /* gcFEATURE_BIT_IMAGE_PARTIAL_CACHE_FIX */ 0x0, /* gcFEATURE_BIT_FULLCACHE_KERNELHEAD_FIX */ - 0x1, /* gcFEATURE_BIT_NN_SINGLEPORT_ACCUMBUFFER */ - 0x0, /* gcFEATURE_BIT_NN_SMALLBATCH */ - 0x0, /* gcFEATURE_BIT_TP_SMALLBATCH */ - 0x0, /* gcFEATURE_BIT_ZRL_8BIT */ - 0x0, /* gcFEATURE_BIT_NN_DEPTHWISE_SUPPORT */ - 0x0, /* gcFEATURE_BIT_NN_WRITE_WITHOUT_USC */ 0x0, /* gcFEATURE_BIT_NN_ZDP_INIMAGE_SIZE_FIX */ - 0x1, /* gcFEATURE_BIT_HI_REORDER_FIX */ - 0x1, /* gcFEATURE_BIT_INCORRECT_WR_REQ_TO_USC_BETWEEN_REORDER_AND_NORMAL_LAYER_FIX */ - 0x0, /* gcFEATURE_BIT_TP_COEF_COMPRESSION_ENHANCEMENT */ - 0x0, /* gcFEATURE_BIT_VIP_DEC400 */ - 0x0, /* gcFEATURE_BIT_IMAGE_NOT_PACKED_IN_SRAM_FIX */ 0x0, /* gcFEATURE_BIT_IDLE_BEFORE_FLUSH_COMPLETE_FIX */ 0x1, /* gcFEATURE_BIT_NO_FLUSH_USC_FIX */ + 0x1, /* gcFEATURE_BIT_SMALL_BATCH_FLOPS_RESET_FIX */ + 0x0, /* gcFEATURE_BIT_SMALL_BATCH_DISBLE_FIX */ + 0x0, /* gcFEATURE_BIT_OUTPUT_CONVERT_UINT8_INT8_TO_UINT16_INT16_FIX */ + 0x0, /* gcFEATURE_BIT_IMAGE_NOT_PACKED_IN_SRAM_FIX */ 0x1, /* gcFEATURE_BIT_COEF_DELTA_CORD_OVERFLOW_ZRL_8BIT_FIX */ - 0x0, /* gcFEATURE_BIT_XY_OFFSET_LIMITATION_FIX */ - 0x0, /* gcFEATURE_BIT_USC_INVALIDATE_CACHE_LINE_FIX */ 0x0, /* gcFEATURE_BIT_LOW_EFFICIENCY_OF_ID_WRITE_IMGBUF_FIX */ - 0x1, /* gcFEATURE_BIT_KERNEL_PER_CORE_LESS_THAN_THIRD_COEF_BUFF_DEPTH_FIX */ + 0x1, /* gcFEATURE_BIT_KERNEL_VIP_SRAM_READ_BW_LIMITATION_FIX */ 0x0, /* gcFEATURE_BIT_USC_BOTTLENECK_FIX */ + 0x1, /* gcFEATURE_BIT_KERNEL_PER_CORE_LESS_THAN_THIRD_COEF_BUFF_DEPTH_FIX */ 0x0, /* gcFEATURE_BIT_KERNEL_SIZE_WASTE_IN_PARTIAL_MODE_FIX */ - 0x0, /* gcFEATURE_BIT_FULLCACHE_KERNEL_INTERLEAVE_FIX */ - 0x0, /* gcFEATURE_BIT_TP_REORDER_LAYER_SUSPEND_FIX */ - 0x1, /* gcFEATURE_BIT_KERNEL_VIP_SRAM_READ_BW_LIMITATION_FIX */ - 0x1, /* gcFEATURE_BIT_IMG_POP_PIPELINE_PAUSE_FIX */ - 0x0, /* gcFEATURE_BIT_DR_JD_DIFF_CONDITION_FOR_CACHELINE_MODE_PRE_FIX */ - 0x1, /* gcFEATURE_BIT_OUTIMAGE_X_BITWIDTH_LIMIT_FOR_NN_TRANSPOSE_FIX */ - 0x1, /* gcFEATURE_BIT_SMALL_BATCH_FLOPS_RESET_FIX */ - 0x0, /* gcFEATURE_BIT_SMALL_BATCH_DISBLE_FIX */ - 0x1, /* gcFEATURE_BIT_NEGATIVE_POST_SHIFT_FIX */ - 0x0, /* gcFEATURE_BIT_NN_COMMAND_KERNEL_REQUEST_CONFICT_FIX */ - 0x1, /* gcFEATURE_BIT_OCB_REMAP_PHYSICAL_ADDRESS */ - 0x0, /* gcFEATURE_BIT_NN_NO_Z_LOCATION_OFFSET */ - 0x0, /* gcFEATURE_BIT_NN_LEAKY_RELU */ - 0x0, /* gcFEATURE_BIT_NN_PRELU */ - 0x0, /* gcFEATURE_BIT_NN_PER_CHANNEL_QUANT */ - 0x0, /* gcFEATURE_BIT_NN_PER_CHANNEL_QUANT_ASYM */ - 0x0, /* gcFEATURE_BIT_NN_NATIVE_STRIDE_TWO */ - 0x0, /* gcFEATURE_BIT_NN_TENSOR_ADD */ - 0x0, /* gcFEATURE_BIT_NN_FLOAT_POST_MULT */ - 0x0, /* gcFEATURE_BIT_NN_SLICE_PADDING_TO_64BYTE_ALIGN */ - 0x0, /* gcFEATURE_BIT_NN_DW_1x1_CONV_MERGE */ - 0x0, /* gcFEATURE_BIT_NN_SLOW_OUTPUT */ - 0x1, /* gcFEATURE_BIT_NO_NARROW_POST_PROCESS_PIPE */ - 0x0, /* gcFEATURE_BIT_TP_NN_PROBE */ - 0x0, /* gcFEATURE_BIT_TP_23BITS_POST_MULTIPLIER */ - 0x0, /* gcFEATURE_BIT_NN_TRANSPOSE */ + 0x0, /* gcFEATURE_BIT_NN_COMMAND_KERNEL_REQUEST_CONFICT_FIX */ + 0x0, /* gcFEATURE_BIT_TP_REORDER_INTILE_X_SIZE_512_FIX */ + 0x1, /* gcFEATURE_BIT_IMG_POP_PIPELINE_PAUSE_FIX */ + 0x0, /* gcFEATURE_BIT_FULLCACHE_KERNEL_INTERLEAVE_FIX */ + 0x0, /* gcFEATURE_BIT_V8_SINGLE_PORT_ACCUMULATION_BUFFER_RW_CONFICT_ZERO_SKIP_PERF_FIX */ + 0x0, /* gcFEATURE_BIT_V8_ACCUMLATION_READ_OUT_HAS_BUBBLES_PERF_FIX */ + 0x1, /* gcFEATURE_BIT_DEPTHWISE_NEIGHBOR_IMG_DATA_TRANSFER_NOT_EFFICIENT_FIX */ + 0x0, /* gcFEATURE_BIT_DR_JD_DIFF_CONDITION_FOR_CACHELINE_MODE_PRE_FIX */ + 0x0, /* gcFEATURE_BIT_TP_ACCESS_VIPSRAM_OT_IS_ONE_FIX */ 0x0, /* gcFEATURE_BIT_EVIS2_FLOP_RESET_FIX */ + 0x1, /* gcFEATURE_BIT_OUTIMAGE_X_BITWIDTH_LIMIT_FOR_NN_TRANSPOSE_FIX */ 0x0, /* gcFEATURE_BIT_USC_ASYNC_CP_RTN_FLOP_RESET_FIX */ - 0x0, /* gcFEATURE_BIT_DDR_BURST_LEN_256B */ + 0x1, /* gcFEATURE_BIT_IMG_ADDR_NOT_WRAP_IF_OVER_OCB_ADDR_FIX */ + 0x1, /* gcFEATURE_BIT_NEGATIVE_POST_SHIFT_FIX */ + 0x0, /* gcFEATURE_BIT_INIMAGE_2DTILE_NOT_LESS_160PIXEL_FIX */ 0x1, /* gcFEATURE_BIT_IMG_CAHCE_MODE_MUST_0_IN_IMG_DIRECT_MODE_FIX */ - 0x0, /* gcFEATURE_BIT_USE_SINGLE_PORT_VIPSRAM */ - 0x0, /* gcFEATURE_BIT_NN_ASYMMETRIC_INT8 */ - 0x1, /* gcFEATURE_BIT_DEPTHWISE_NEIGHBOR_IMG_DATA_TRANSFER_NOT_EFFICIENT_FIX */ - 0x0, /* gcFEATURE_BIT_PRELU_LEAKLY_RELU_CLAMP */ - 0x0, /* gcFEATURE_BIT_TP_FLOAT32_IO */ - 0x0, /* gcFEATURE_BIT_NN_FLOAT32_IO */ - 0x0, /* gcFEATURE_BIT_NN_SMALL_BATCH_PHASE2 */ - 0x0, /* gcFEATURE_BIT_TILE_ACCESS_CAPABILITY */ - 0x0, /* gcFEATURE_BIT_FAST_DP3_PREPROCESSOR */ - 0x0, /* gcFEATURE_BIT_NN_COMPRESSION_BYPASSS */ - 0x0, /* gcFEATURE_BIT_BFLOAT_KERNEL_COMPRESSION_ZERO_SKIP_FIX */ - 0x0, /* gcFEATURE_BIT_TP_3_USC */ - 0x0, /* gcFEATURE_BIT_TP_KERNEL_1BYTE_ALGIN */ - 0x0, /* gcFEATURE_BIT_TPLITE_BFLOAT16 */ - 0x0, /* gcFEATURE_BIT_PREPROCESS_IMG_BUF_640BYTE_LIMIT */ - 0x0, /* gcFEATURE_BIT_V8_ACCUMLATION_READ_OUT_HAS_BUBBLES_PERF_FIX */ - 0x0, /* gcFEATURE_BIT_V8_SINGLE_PORT_ACCUMULATION_BUFFER_RW_CONFICT_ZERO_SKIP_PERF_FIX */ 0x0, /* gcFEATURE_BIT_BURST_COLLECT_DUMMY_DATA_WASTE_CYCLES_FIX */ 0x0, /* gcFEATURE_BIT_INIMG_NOT_64BYTE_ALIGN_CACHELINE_MODE_FIX */ - 0x0, /* gcFEATURE_BIT_TP_ACCESS_VIPSRAM_OT_IS_ONE_FIX */ - 0x1, /* gcFEATURE_BIT_VIP_HW_FINAL_RELEASE */ + 0x1, /* gcFEATURE_BIT_TP_FC_FLOAT_LAST_PIXEL_NEGATIVE_0_FIX */ + 0x1, /* gcFEATURE_BIT_NN_WASET_COEF_READ_WRITE_BANDWIDTH_128BYTE_VIPSRAM_IN_FULL_PATIAL_CACHE_MODE */ + 0x1, /* gcFEATURE_BIT_NN_IN_TILE_DATA_IS_ALL_PAD_FIX */ + 0x1, /* gcFEATURE_BIT_TP_FC_KERNEL_STREAM_MUST_LESS_THAN_OR_EQUAL_TO_64BYTE_WHEN_1BYTE_ALGINE_FIX */ + 0x0, /* gcFEATURE_BIT_NN_INTERLEVE8 */ + 0x0, /* gcFEATURE_BIT_NN_FP16_ALU */ + 0x1, /* gcFEATURE_BIT_NN_INT16_ALU */ + 0x1, /* gcFEATURE_BIT_NN_INT8_SCALE */ + 0x1, /* gcFEATURE_BIT_NN_POWER_ISOLATION */ + 0x0, /* gcFEATURE_BIT_ZRL_7BIT */ + 0x0, /* gcFEATURE_BIT_NN_SMALLBATCH_PHASE1 */ + 0x0, /* gcFEATURE_BIT_TP_SMALLBATCH_PHASE1 */ + 0x0, /* gcFEATURE_BIT_NN_SMALLBATCH */ + 0x0, /* gcFEATURE_BIT_TP_SMALLBATCH */ + 0x0, /* gcFEATURE_BIT_ZRL_8BIT */ + 0x0, /* gcFEATURE_BIT_DDR_BURST_LEN_256B */ + 0x0, /* gcFEATURE_BIT_XY_OFFSET_LIMITATION_FIX */ + 0x0, /* gcFEATURE_BIT_NN_NONZERO_MIRROR_BORDER */ + 0x0, /* gcFEATURE_BIT_IMAGE_PARTIAL_CACHE */ }, /* vip9000nano-si */ { @@ -2469,13 +2697,23 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x140, /* gcFEATURE_VALUE_NumberOfConstants */ 0x1, /* gcFEATURE_VALUE_CoreCount */ 0x10, /* gcFEATURE_VALUE_LocalStorageSize */ + 0x0, /* gcFEATURE_VALUE_LocalStorageSize_1 */ + 0x0, /* gcFEATURE_VALUE_LocalStorageSize_2 */ 0x10, /* gcFEATURE_VALUE_L1CacheSize */ + 0x0, /* gcFEATURE_VALUE_L1CacheSize_1 */ + 0x0, /* gcFEATURE_VALUE_L1CacheSize_2 */ 0x200, /* gcFEATURE_VALUE_InstructionMemorySize */ 0x14, /* gcFEATURE_VALUE_ShaderPCLength */ 0x10, /* gcFEATURE_VALUE_USC_MAX_PAGES */ + 0x0, /* gcFEATURE_VALUE_USC_MAX_PAGES_1 */ + 0x0, /* gcFEATURE_VALUE_USC_MAX_PAGES_2 */ 0x1, /* gcFEATURE_VALUE_NumPixelPipes */ 0x1, /* gcFEATURE_VALUE_USC_CACHE_CONTROLLERS */ + 0x0, /* gcFEATURE_VALUE_USC_CACHE_CONTROLLERS_1 */ + 0x0, /* gcFEATURE_VALUE_USC_CACHE_CONTROLLERS_2 */ 0x2, /* gcFEATURE_VALUE_USC_BANKS */ + 0x0, /* gcFEATURE_VALUE_USC_BANKS_1 */ + 0x0, /* gcFEATURE_VALUE_USC_BANKS_2 */ 0x8, /* gcFEATURE_VALUE_Streams */ 0x10, /* gcFEATURE_VALUE_VaryingCount */ 0x400, /* gcFEATURE_VALUE_VertexOutputBufferSize */ @@ -2484,6 +2722,7 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_VALUE_NumResolvePipes */ 0x100, /* gcFEATURE_VALUE_RESULT_WINDOW_MAX_SIZE */ 0x0, /* gcFEATURE_VALUE_ClusterAliveMask */ + 0x0, /* gcFEATURE_VALUE_G2D_DEC400_MINOR */ 0x40, /* gcFEATURE_VALUE_NNMadPerCore */ 0x4, /* gcFEATURE_VALUE_NNCoreCount */ 0x4, /* gcFEATURE_VALUE_NNCoreCount_INT8 */ @@ -2508,14 +2747,26 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x40, /* gcFEATURE_VALUE_PHYSICAL_VIP_SRAM_WIDTH_IN_BYTE */ 0x10, /* gcFEATURE_VALUE_EQUIVALENT_VIP_SRAM_WIDTH_INBYTE */ 0x8, /* gcFEATURE_VALUE_TP_ZRL_BITS */ + 0x8, /* gcFEATURE_VALUE_NN_ZRL_BITS */ 0x80, /* gcFEATURE_VALUE_LATENCY_HIDING_AT_FULL_AXI_BW */ 0x10, /* gcFEATURE_VALUE_AXI_BUS_WIDTH */ 0xf, /* gcFEATURE_VALUE_NN_KERNEL_X_SIZE */ 0xf, /* gcFEATURE_VALUE_NN_KERNEL_Y_SIZE */ + 0xf, /* gcFEATURE_VALUE_NN_FC_KERNEL_Y_SIZE */ 0xfffff, /* gcFEATURE_VALUE_NN_KERNEL_Z_SIZE */ 0x1f, /* gcFEATURE_VALUE_NN_X_OFFSET */ 0x1f, /* gcFEATURE_VALUE_NN_Y_OFFSET */ 0x100, /* gcFEATURE_VALUE_DDR_KERNEL_BURST_SIZE */ + 0x10, /* gcFEATURE_VALUE_OUTIMAGE_X_STRIDE_BITS */ + 0x10, /* gcFEATURE_VALUE_OUTIMAGE_Y_STRIDE_BITS */ + 0x10, /* gcFEATURE_VALUE_INIMAGE_X_STRIDE_BITS */ + 0x10, /* gcFEATURE_VALUE_IMIMAGE_Y_STRIDE_BITS */ + 0xd, /* gcFEATURE_VALUE_OUTIMAGE_X_SIZE_BITS */ + 0xd, /* gcFEATURE_VALUE_OUTIMAGE_Y_SIZE_BITS */ + 0xe, /* gcFEATURE_VALUE_OUTIMAGE_SIZE_BITS */ + 0xd, /* gcFEATURE_VALUE_IMAGE_X_SIZE_BITS */ + 0xd, /* gcFEATURE_VALUE_INIMAGE_Y_SIZE_BITS */ + 0x40, /* gcFEATURE_VALUE_MAX_TILE_X_SIZE */ 0x0, /* gcFEATURE_BIT_REG_FastClear */ 0x0, /* gcFEATURE_BIT_REG_SpecialAntiAliasing */ 0x1, /* gcFEATURE_BIT_REG_Pipe3D */ @@ -2757,6 +3008,7 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x1, /* gcFEATURE_BIT_RA_HZEZ_CLOCK_CONTROL */ 0x1, /* gcFEATURE_BIT_CACHE128B256BPERLINE */ 0x1, /* gcFEATURE_BIT_V4Compression */ + 0x0, /* gcFEATURE_BIT_DE2D_MAJOR_SUPER_TILE */ 0x0, /* gcFEATURE_BIT_PE2D_MAJOR_SUPER_TILE */ 0x1, /* gcFEATURE_BIT_PE_32BPC_COLORMASK_FIX */ 0x1, /* gcFEATURE_BIT_ALPHA_BLENDING_OPT */ @@ -2889,6 +3141,7 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_BIT_TX_NO_FIXED_FILTER */ 0x0, /* gcFEATURE_BIT_SHARE_Z */ 0x0, /* gcFEATURE_BIT_DE_2D_FAST_CLEAR */ + 0x0, /* gcFEATURE_BIT_DE_TILESTATUS_ROTATION_FIX */ 0x0, /* gcFEATURE_BIT_TX_CLEAR_PENDING_FIX */ 0x0, /* gcFEATURE_BIT_NO_HI1_L2 */ 0x0, /* gcFEATURE_BIT_USC_EVICT_CTRL_FIFO_FLOP_RESET_FIX */ @@ -2899,6 +3152,13 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_BIT_SH_VX2_FLOATING_MAD_FIX */ 0x0, /* gcFEATURE_BIT_TS_FC_VULKAN_SUPPORT */ 0x0, /* gcFEATURE_BIT_MSAA_FLOAT_64BIT */ + 0x0, /* gcFEATURE_BIT_INDIRECT_COMPUTE_ZERODIM_FIX */ + 0x0, /* gcFEATURE_BIT_Q_CHANNEL_SUPPORT */ + 0x0, /* gcFEATURE_BIT_MMU_PAGE_DESCRIPTOR */ + 0x0, /* gcFEATURE_BIT_YUV_LINEAR_TO_TILE_ROTATE */ + 0x0, /* gcFEATURE_BIT_VEC2_IMULIMAD32_SUPPORT */ + 0x0, /* gcFEATURE_BIT_VEC4_IMULIMAD32_SUPPORT */ + 0x0, /* gcFEATURE_BIT_VEC2_IDIVIMOD16_SUPPORT */ 0x0, /* gcFEATURE_BIT_VG_TS_CULLING */ 0x0, /* gcFEATURE_BIT_VG_FP25 */ 0x0, /* gcFEATURE_BIT_VG_AYUV_INPUT_OUTPUT */ @@ -2925,6 +3185,20 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_BIT_DC_MMU */ 0x0, /* gcFEATURE_BIT_DC_COMPRESSION */ 0x0, /* gcFEATURE_BIT_DC_QOS */ + 0x1, /* gcFEATURE_BIT_VIP_HW_FINAL_RELEASE */ + 0x1, /* gcFEATURE_BIT_NN_SINGLEPORT_ACCUMBUFFER */ + 0x1, /* gcFEATURE_BIT_NN_STRIDE_SUPPORT */ + 0x1, /* gcFEATURE_BIT_SWTILING_PHASE1 */ + 0x1, /* gcFEATURE_BIT_SWTILING_PHASE2 */ + 0x0, /* gcFEATURE_BIT_TP_SIMPLE_INT16 */ + 0x1, /* gcFEATURE_BIT_TP_REAL_INT16 */ + 0x1, /* gcFEATURE_BIT_TP_ROI_POOLING */ + 0x1, /* gcFEATURE_BIT_TP_MAX_POOLING_STRIDE1 */ + 0x1, /* gcFEATURE_BIT_TP_LRN */ + 0x1, /* gcFEATURE_BIT_TP_REORDER */ + 0x1, /* gcFEATURE_BIT_TF_QUANTIZATION */ + 0x0, /* gcFEATURE_BIT_NN_NONZERO_BORDER */ + 0x1, /* gcFEATURE_BIT_NN_MIRROR_BORDER */ 0x0, /* gcFEATURE_BIT_AI_GPU */ 0x0, /* gcFEATURE_BIT_EVIS_NO_ABSDIFF */ 0x0, /* gcFEATURE_BIT_EVIS_NO_BITREPLACE */ @@ -2937,128 +3211,139 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_BIT_EVIS_LERP_7OUTPUT */ 0x0, /* gcFEATURE_BIT_EVIS_ACCSQ_8OUTPUT */ 0x1, /* gcFEATURE_BIT_EVIS_VX2 */ - 0x1, /* gcFEATURE_BIT_NN_FLOAT */ 0x1, /* gcFEATURE_BIT_TP_ENGINE */ 0x1, /* gcFEATURE_BIT_VIP_V7 */ - 0x0, /* gcFEATURE_BIT_MCFE */ - 0x0, /* gcFEATURE_BIT_NN_INTERLEVE8 */ - 0x1, /* gcFEATURE_BIT_TP_REORDER */ - 0x1, /* gcFEATURE_BIT_TP_LRN */ - 0x1, /* gcFEATURE_BIT_TP_MAX_POOLING_STRIDE1 */ - 0x0, /* gcFEATURE_BIT_NN_FP16_ALU */ - 0x1, /* gcFEATURE_BIT_NN_INT16_ALU */ - 0x1, /* gcFEATURE_BIT_TP_ROI_POOLING */ - 0x1, /* gcFEATURE_BIT_NN_ZDP3 */ + 0x0, /* gcFEATURE_BIT_TP_TENSOR_ADD_MUL */ + 0x0, /* gcFEATURE_BIT_NN_DEPTHWISE_INT16XINT8 */ + 0x0, /* gcFEATURE_BIT_TP_SOFTMAX */ + 0x0, /* gcFEATURE_BIT_NN_23BITS_POST_MULTIPLIER_VIP_V7 */ + 0x0, /* gcFEATURE_BIT_TP_23BITS_POST_MULTIPLIER_VIP_V7 */ + 0x0, /* gcFEATURE_BIT_HYBRID_MODE_VIP_V7 */ 0x0, /* gcFEATURE_BIT_NN_ZDP6 */ 0x0, /* gcFEATURE_BIT_NN_XYDP9 */ - 0x1, /* gcFEATURE_BIT_NN_INT8_SCALE */ - 0x1, /* gcFEATURE_BIT_NN_POWER_ISOLATION */ - 0x1, /* gcFEATURE_BIT_SWTILING_PHASE1 */ - 0x1, /* gcFEATURE_BIT_TF_QUANTIZATION */ - 0x0, /* gcFEATURE_BIT_TP_SIMPLE_INT16 */ - 0x1, /* gcFEATURE_BIT_TP_REAL_INT16 */ - 0x0, /* gcFEATURE_BIT_TP_BFLOAT16 */ 0x1, /* gcFEATURE_BIT_NN_FIRST_PIXEL_POOLING */ - 0x1, /* gcFEATURE_BIT_SWTILING_PHASE2 */ - 0x1, /* gcFEATURE_BIT_NN_STRIDE_SUPPORT */ + 0x1, /* gcFEATURE_BIT_NN_ZDP3 */ 0x0, /* gcFEATURE_BIT_NN_XYDP6 */ - 0x1, /* gcFEATURE_BIT_TP_REORDER_FIX */ - 0x1, /* gcFEATURE_BIT_NN_CONV1x1_PERF_FIX */ - 0x1, /* gcFEATURE_BIT_NN_CACHELINE_MODE_PERF_FIX */ - 0x1, /* gcFEATURE_BIT_NN_PER3DTILE_BUBBLE_FIX */ - 0x1, /* gcFEATURE_BIT_NN_CONVOUT_FIFO_DEPTH_FIX */ 0x1, /* gcFEATURE_BIT_SWTILING_PHASE3 */ + 0x0, /* gcFEATURE_BIT_MCFE */ 0x0, /* gcFEATURE_BIT_USC_STAY_LRU */ - 0x1, /* gcFEATURE_BIT_NN_NONZERO_MIRROR_BORDER */ + 0x1, /* gcFEATURE_BIT_COEF_COMPRESSION_ENHANCEMENT */ + 0x1, /* gcFEATURE_BIT_TP_COEF_COMPRESSION_ENHANCEMENT */ 0x1, /* gcFEATURE_BIT_NN_COEF_DECOMPRESS_PERF2X */ + 0x1, /* gcFEATURE_BIT_OCB_COUNTER */ + 0x0, /* gcFEATURE_BIT_SCALER */ + 0x0, /* gcFEATURE_BIT_SCALER_4K */ 0x0, /* gcFEATURE_BIT_INPUT_4BIT */ - 0x1, /* gcFEATURE_BIT_COEF_COMPRESSION_ENHANCEMENT */ + 0x1, /* gcFEATURE_BIT_NN_NO_Z_LOCATION_OFFSET */ + 0x1, /* gcFEATURE_BIT_OCB_REMAP_PHYSICAL_ADDRESS */ + 0x1, /* gcFEATURE_BIT_NN_SLOW_OUTPUT */ + 0x1, /* gcFEATURE_BIT_NO_NARROW_POST_PROCESS_PIPE */ + 0x1, /* gcFEATURE_BIT_TP_NN_PROBE */ + 0x1, /* gcFEATURE_BIT_NN_DEPTHWISE_SUPPORT */ + 0x1, /* gcFEATURE_BIT_NN_XYDP0 */ + 0x1, /* gcFEATURE_BIT_NN_WRITE_WITHOUT_USC */ + 0x1, /* gcFEATURE_BIT_NN_HW_LIMITATION_NATIVE_KER_1x2_2x1 */ + 0x1, /* gcFEATURE_BIT_NN_SLICE_PADDING_TO_64BYTE_ALIGN */ + 0x0, /* gcFEATURE_BIT_NN_DW_1x1_CONV_MERGE */ + 0x0, /* gcFEATURE_BIT_TP_BFLOAT16 */ + 0x0, /* gcFEATURE_BIT_TP_23BITS_POST_MULTIPLIER */ + 0x1, /* gcFEATURE_BIT_NN_TRANSPOSE */ + 0x1, /* gcFEATURE_BIT_USE_SINGLE_PORT_VIPSRAM */ + 0x0, /* gcFEATURE_BIT_NN_LEAKY_RELU */ + 0x0, /* gcFEATURE_BIT_NN_PRELU */ + 0x0, /* gcFEATURE_BIT_NN_PER_CHANNEL_QUANT */ + 0x0, /* gcFEATURE_BIT_NN_PER_CHANNEL_QUANT_ASYM */ + 0x0, /* gcFEATURE_BIT_NN_ASYMMETRIC_INT8 */ + 0x0, /* gcFEATURE_BIT_NN_FLOAT_POST_MULT */ + 0x0, /* gcFEATURE_BIT_PRELU_LEAKLY_RELU_CLAMP */ + 0x0, /* gcFEATURE_BIT_TPLITE_BFLOAT16 */ + 0x0, /* gcFEATURE_BIT_PREPROCESS_IMG_BUF_640BYTE_LIMIT */ + 0x0, /* gcFEATURE_BIT_TP_KERNEL_1BYTE_ALGIN */ + 0x0, /* gcFEATURE_BIT_BFLOAT_COEF_COMPRESSION_ZERO_COEFBIT14_INVERSE */ + 0x0, /* gcFEATURE_BIT_NN_COMPRESSION_BYPASSS */ + 0x0, /* gcFEATURE_BIT_TP_3_USC */ + 0x0, /* gcFEATURE_BIT_BFP_COEF_AUTO_PAD_INCOMPLETE_ZERO_IN_KZ_PLANE */ + 0x0, /* gcFEATURE_BIT_NN_NATIVE_STRIDE_TWO */ + 0x0, /* gcFEATURE_BIT_NN_TENSOR_ADD */ + 0x0, /* gcFEATURE_BIT_NN_FLOAT32_IO */ + 0x0, /* gcFEATURE_BIT_TP_FLOAT32_IO */ + 0x0, /* gcFEATURE_BIT_NN_SMALL_BATCH_PHASE2 */ + 0x0, /* gcFEATURE_BIT_TILE_ACCESS_CAPABILITY */ + 0x0, /* gcFEATURE_BIT_FAST_DP3_PREPROCESSOR */ + 0x0, /* gcFEATURE_BIT_DEPTHWISE_SUPPORT_16BIT_FORMAT */ + 0x0, /* gcFEATURE_BIT_NN_SUPPORT_ALU_LUT */ + 0x0, /* gcFEATURE_BIT_NN_ENHANCED_MAX_POOLING */ + 0x0, /* gcFEATURE_BIT_NN_TRANSPOSE_PHASE2 */ + 0x0, /* gcFEATURE_BIT_TPLITE_SUPPORT_TP_DATA_TRANSPOSE */ + 0x0, /* gcFEATURE_BIT_NN_SUPPORT_CONV_1D */ + 0x0, /* gcFEATURE_BIT_USE_VIPSRAM_FOR_KERNEL_STREAMING */ + 0x0, /* gcFEATURE_BIT_VIP_DEC400 */ + 0x1, /* gcFEATURE_BIT_NN_PER3DTILE_BUBBLE_FIX */ + 0x1, /* gcFEATURE_BIT_NN_CACHELINE_MODE_PERF_FIX */ + 0x1, /* gcFEATURE_BIT_NN_CONV1x1_PERF_FIX */ + 0x1, /* gcFEATURE_BIT_TP_REORDER_FIX */ + 0x1, /* gcFEATURE_BIT_NN_CONVOUT_FIFO_DEPTH_FIX */ 0x1, /* gcFEATURE_BIT_NN_ZXDP3_KERNEL_READ_CONFLICT_FIX */ 0x1, /* gcFEATURE_BIT_NN_ZDP3_NO_COMPRESS_FIX */ 0x1, /* gcFEATURE_BIT_NN_ASYNC_COPY_PERF_FIX */ - 0x1, /* gcFEATURE_BIT_OCB_COUNTER */ - 0x1, /* gcFEATURE_BIT_NN_XYDP0 */ - 0x0, /* gcFEATURE_BIT_ZRL_7BIT */ + 0x1, /* gcFEATURE_BIT_HI_REORDER_FIX */ + 0x1, /* gcFEATURE_BIT_INCORRECT_WR_REQ_TO_USC_BETWEEN_REORDER_AND_NORMAL_LAYER_FIX */ + 0x1, /* gcFEATURE_BIT_TP_REORDER_LAYER_SUSPEND_FIX */ 0x1, /* gcFEATURE_BIT_NN_ASYNC_COPY_MERGE_FIX */ - 0x1, /* gcFEATURE_BIT_NN_SMALLBATCH_PHASE1 */ - 0x1, /* gcFEATURE_BIT_TP_SMALLBATCH_PHASE1 */ - 0x0, /* gcFEATURE_BIT_SCALER */ - 0x0, /* gcFEATURE_BIT_SCALER_4K */ + 0x1, /* gcFEATURE_BIT_USC_INVALIDATE_CACHE_LINE_FIX */ 0x0, /* gcFEATURE_BIT_NN_REQ_SLOWARBITRATION_FIX */ - 0x0, /* gcFEATURE_BIT_IMAGE_PARTIAL_CACHE */ + 0x0, /* gcFEATURE_BIT_IMAGE_PARTIAL_CACHE_FIX */ 0x0, /* gcFEATURE_BIT_FULLCACHE_KERNELHEAD_FIX */ - 0x1, /* gcFEATURE_BIT_NN_SINGLEPORT_ACCUMBUFFER */ - 0x0, /* gcFEATURE_BIT_NN_SMALLBATCH */ - 0x0, /* gcFEATURE_BIT_TP_SMALLBATCH */ - 0x1, /* gcFEATURE_BIT_ZRL_8BIT */ - 0x1, /* gcFEATURE_BIT_NN_DEPTHWISE_SUPPORT */ - 0x1, /* gcFEATURE_BIT_NN_WRITE_WITHOUT_USC */ 0x1, /* gcFEATURE_BIT_NN_ZDP_INIMAGE_SIZE_FIX */ - 0x1, /* gcFEATURE_BIT_HI_REORDER_FIX */ - 0x1, /* gcFEATURE_BIT_INCORRECT_WR_REQ_TO_USC_BETWEEN_REORDER_AND_NORMAL_LAYER_FIX */ - 0x1, /* gcFEATURE_BIT_TP_COEF_COMPRESSION_ENHANCEMENT */ - 0x0, /* gcFEATURE_BIT_VIP_DEC400 */ - 0x1, /* gcFEATURE_BIT_IMAGE_NOT_PACKED_IN_SRAM_FIX */ 0x1, /* gcFEATURE_BIT_IDLE_BEFORE_FLUSH_COMPLETE_FIX */ 0x1, /* gcFEATURE_BIT_NO_FLUSH_USC_FIX */ + 0x1, /* gcFEATURE_BIT_SMALL_BATCH_FLOPS_RESET_FIX */ + 0x0, /* gcFEATURE_BIT_SMALL_BATCH_DISBLE_FIX */ + 0x1, /* gcFEATURE_BIT_OUTPUT_CONVERT_UINT8_INT8_TO_UINT16_INT16_FIX */ + 0x1, /* gcFEATURE_BIT_IMAGE_NOT_PACKED_IN_SRAM_FIX */ 0x1, /* gcFEATURE_BIT_COEF_DELTA_CORD_OVERFLOW_ZRL_8BIT_FIX */ - 0x1, /* gcFEATURE_BIT_XY_OFFSET_LIMITATION_FIX */ - 0x1, /* gcFEATURE_BIT_USC_INVALIDATE_CACHE_LINE_FIX */ 0x0, /* gcFEATURE_BIT_LOW_EFFICIENCY_OF_ID_WRITE_IMGBUF_FIX */ - 0x0, /* gcFEATURE_BIT_KERNEL_PER_CORE_LESS_THAN_THIRD_COEF_BUFF_DEPTH_FIX */ + 0x1, /* gcFEATURE_BIT_KERNEL_VIP_SRAM_READ_BW_LIMITATION_FIX */ 0x0, /* gcFEATURE_BIT_USC_BOTTLENECK_FIX */ + 0x0, /* gcFEATURE_BIT_KERNEL_PER_CORE_LESS_THAN_THIRD_COEF_BUFF_DEPTH_FIX */ 0x0, /* gcFEATURE_BIT_KERNEL_SIZE_WASTE_IN_PARTIAL_MODE_FIX */ - 0x1, /* gcFEATURE_BIT_FULLCACHE_KERNEL_INTERLEAVE_FIX */ - 0x1, /* gcFEATURE_BIT_TP_REORDER_LAYER_SUSPEND_FIX */ - 0x1, /* gcFEATURE_BIT_KERNEL_VIP_SRAM_READ_BW_LIMITATION_FIX */ + 0x1, /* gcFEATURE_BIT_NN_COMMAND_KERNEL_REQUEST_CONFICT_FIX */ + 0x1, /* gcFEATURE_BIT_TP_REORDER_INTILE_X_SIZE_512_FIX */ 0x1, /* gcFEATURE_BIT_IMG_POP_PIPELINE_PAUSE_FIX */ + 0x1, /* gcFEATURE_BIT_FULLCACHE_KERNEL_INTERLEAVE_FIX */ + 0x0, /* gcFEATURE_BIT_V8_SINGLE_PORT_ACCUMULATION_BUFFER_RW_CONFICT_ZERO_SKIP_PERF_FIX */ + 0x0, /* gcFEATURE_BIT_V8_ACCUMLATION_READ_OUT_HAS_BUBBLES_PERF_FIX */ + 0x1, /* gcFEATURE_BIT_DEPTHWISE_NEIGHBOR_IMG_DATA_TRANSFER_NOT_EFFICIENT_FIX */ 0x1, /* gcFEATURE_BIT_DR_JD_DIFF_CONDITION_FOR_CACHELINE_MODE_PRE_FIX */ - 0x1, /* gcFEATURE_BIT_OUTIMAGE_X_BITWIDTH_LIMIT_FOR_NN_TRANSPOSE_FIX */ - 0x1, /* gcFEATURE_BIT_SMALL_BATCH_FLOPS_RESET_FIX */ - 0x0, /* gcFEATURE_BIT_SMALL_BATCH_DISBLE_FIX */ - 0x1, /* gcFEATURE_BIT_NEGATIVE_POST_SHIFT_FIX */ - 0x1, /* gcFEATURE_BIT_NN_COMMAND_KERNEL_REQUEST_CONFICT_FIX */ - 0x1, /* gcFEATURE_BIT_OCB_REMAP_PHYSICAL_ADDRESS */ - 0x1, /* gcFEATURE_BIT_NN_NO_Z_LOCATION_OFFSET */ - 0x0, /* gcFEATURE_BIT_NN_LEAKY_RELU */ - 0x0, /* gcFEATURE_BIT_NN_PRELU */ - 0x0, /* gcFEATURE_BIT_NN_PER_CHANNEL_QUANT */ - 0x0, /* gcFEATURE_BIT_NN_PER_CHANNEL_QUANT_ASYM */ - 0x0, /* gcFEATURE_BIT_NN_NATIVE_STRIDE_TWO */ - 0x0, /* gcFEATURE_BIT_NN_TENSOR_ADD */ - 0x0, /* gcFEATURE_BIT_NN_FLOAT_POST_MULT */ - 0x1, /* gcFEATURE_BIT_NN_SLICE_PADDING_TO_64BYTE_ALIGN */ - 0x0, /* gcFEATURE_BIT_NN_DW_1x1_CONV_MERGE */ - 0x1, /* gcFEATURE_BIT_NN_SLOW_OUTPUT */ - 0x1, /* gcFEATURE_BIT_NO_NARROW_POST_PROCESS_PIPE */ - 0x1, /* gcFEATURE_BIT_TP_NN_PROBE */ - 0x0, /* gcFEATURE_BIT_TP_23BITS_POST_MULTIPLIER */ - 0x1, /* gcFEATURE_BIT_NN_TRANSPOSE */ + 0x0, /* gcFEATURE_BIT_TP_ACCESS_VIPSRAM_OT_IS_ONE_FIX */ 0x0, /* gcFEATURE_BIT_EVIS2_FLOP_RESET_FIX */ + 0x1, /* gcFEATURE_BIT_OUTIMAGE_X_BITWIDTH_LIMIT_FOR_NN_TRANSPOSE_FIX */ 0x0, /* gcFEATURE_BIT_USC_ASYNC_CP_RTN_FLOP_RESET_FIX */ - 0x1, /* gcFEATURE_BIT_DDR_BURST_LEN_256B */ + 0x1, /* gcFEATURE_BIT_IMG_ADDR_NOT_WRAP_IF_OVER_OCB_ADDR_FIX */ + 0x1, /* gcFEATURE_BIT_NEGATIVE_POST_SHIFT_FIX */ + 0x1, /* gcFEATURE_BIT_INIMAGE_2DTILE_NOT_LESS_160PIXEL_FIX */ 0x0, /* gcFEATURE_BIT_IMG_CAHCE_MODE_MUST_0_IN_IMG_DIRECT_MODE_FIX */ - 0x1, /* gcFEATURE_BIT_USE_SINGLE_PORT_VIPSRAM */ - 0x0, /* gcFEATURE_BIT_NN_ASYMMETRIC_INT8 */ - 0x1, /* gcFEATURE_BIT_DEPTHWISE_NEIGHBOR_IMG_DATA_TRANSFER_NOT_EFFICIENT_FIX */ - 0x0, /* gcFEATURE_BIT_PRELU_LEAKLY_RELU_CLAMP */ - 0x0, /* gcFEATURE_BIT_TP_FLOAT32_IO */ - 0x0, /* gcFEATURE_BIT_NN_FLOAT32_IO */ - 0x0, /* gcFEATURE_BIT_NN_SMALL_BATCH_PHASE2 */ - 0x0, /* gcFEATURE_BIT_TILE_ACCESS_CAPABILITY */ - 0x0, /* gcFEATURE_BIT_FAST_DP3_PREPROCESSOR */ - 0x0, /* gcFEATURE_BIT_NN_COMPRESSION_BYPASSS */ - 0x0, /* gcFEATURE_BIT_BFLOAT_KERNEL_COMPRESSION_ZERO_SKIP_FIX */ - 0x0, /* gcFEATURE_BIT_TP_3_USC */ - 0x0, /* gcFEATURE_BIT_TP_KERNEL_1BYTE_ALGIN */ - 0x0, /* gcFEATURE_BIT_TPLITE_BFLOAT16 */ - 0x0, /* gcFEATURE_BIT_PREPROCESS_IMG_BUF_640BYTE_LIMIT */ - 0x0, /* gcFEATURE_BIT_V8_ACCUMLATION_READ_OUT_HAS_BUBBLES_PERF_FIX */ - 0x0, /* gcFEATURE_BIT_V8_SINGLE_PORT_ACCUMULATION_BUFFER_RW_CONFICT_ZERO_SKIP_PERF_FIX */ 0x0, /* gcFEATURE_BIT_BURST_COLLECT_DUMMY_DATA_WASTE_CYCLES_FIX */ 0x1, /* gcFEATURE_BIT_INIMG_NOT_64BYTE_ALIGN_CACHELINE_MODE_FIX */ - 0x0, /* gcFEATURE_BIT_TP_ACCESS_VIPSRAM_OT_IS_ONE_FIX */ - 0x1, /* gcFEATURE_BIT_VIP_HW_FINAL_RELEASE */ + 0x0, /* gcFEATURE_BIT_TP_FC_FLOAT_LAST_PIXEL_NEGATIVE_0_FIX */ + 0x1, /* gcFEATURE_BIT_NN_WASET_COEF_READ_WRITE_BANDWIDTH_128BYTE_VIPSRAM_IN_FULL_PATIAL_CACHE_MODE */ + 0x1, /* gcFEATURE_BIT_NN_IN_TILE_DATA_IS_ALL_PAD_FIX */ + 0x1, /* gcFEATURE_BIT_TP_FC_KERNEL_STREAM_MUST_LESS_THAN_OR_EQUAL_TO_64BYTE_WHEN_1BYTE_ALGINE_FIX */ + 0x0, /* gcFEATURE_BIT_NN_INTERLEVE8 */ + 0x0, /* gcFEATURE_BIT_NN_FP16_ALU */ + 0x1, /* gcFEATURE_BIT_NN_INT16_ALU */ + 0x1, /* gcFEATURE_BIT_NN_INT8_SCALE */ + 0x1, /* gcFEATURE_BIT_NN_POWER_ISOLATION */ + 0x0, /* gcFEATURE_BIT_ZRL_7BIT */ + 0x1, /* gcFEATURE_BIT_NN_SMALLBATCH_PHASE1 */ + 0x1, /* gcFEATURE_BIT_TP_SMALLBATCH_PHASE1 */ + 0x0, /* gcFEATURE_BIT_NN_SMALLBATCH */ + 0x0, /* gcFEATURE_BIT_TP_SMALLBATCH */ + 0x1, /* gcFEATURE_BIT_ZRL_8BIT */ + 0x1, /* gcFEATURE_BIT_DDR_BURST_LEN_256B */ + 0x1, /* gcFEATURE_BIT_XY_OFFSET_LIMITATION_FIX */ + 0x1, /* gcFEATURE_BIT_NN_NONZERO_MIRROR_BORDER */ + 0x0, /* gcFEATURE_BIT_IMAGE_PARTIAL_CACHE */ }, /* vip9000nano-di */ { @@ -3077,13 +3362,23 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x140, /* gcFEATURE_VALUE_NumberOfConstants */ 0x1, /* gcFEATURE_VALUE_CoreCount */ 0x10, /* gcFEATURE_VALUE_LocalStorageSize */ + 0x0, /* gcFEATURE_VALUE_LocalStorageSize_1 */ + 0x0, /* gcFEATURE_VALUE_LocalStorageSize_2 */ 0x10, /* gcFEATURE_VALUE_L1CacheSize */ + 0x0, /* gcFEATURE_VALUE_L1CacheSize_1 */ + 0x0, /* gcFEATURE_VALUE_L1CacheSize_2 */ 0x200, /* gcFEATURE_VALUE_InstructionMemorySize */ 0x14, /* gcFEATURE_VALUE_ShaderPCLength */ 0x10, /* gcFEATURE_VALUE_USC_MAX_PAGES */ + 0x0, /* gcFEATURE_VALUE_USC_MAX_PAGES_1 */ + 0x0, /* gcFEATURE_VALUE_USC_MAX_PAGES_2 */ 0x1, /* gcFEATURE_VALUE_NumPixelPipes */ 0x1, /* gcFEATURE_VALUE_USC_CACHE_CONTROLLERS */ + 0x0, /* gcFEATURE_VALUE_USC_CACHE_CONTROLLERS_1 */ + 0x0, /* gcFEATURE_VALUE_USC_CACHE_CONTROLLERS_2 */ 0x2, /* gcFEATURE_VALUE_USC_BANKS */ + 0x0, /* gcFEATURE_VALUE_USC_BANKS_1 */ + 0x0, /* gcFEATURE_VALUE_USC_BANKS_2 */ 0x8, /* gcFEATURE_VALUE_Streams */ 0x10, /* gcFEATURE_VALUE_VaryingCount */ 0x400, /* gcFEATURE_VALUE_VertexOutputBufferSize */ @@ -3092,6 +3387,7 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_VALUE_NumResolvePipes */ 0x100, /* gcFEATURE_VALUE_RESULT_WINDOW_MAX_SIZE */ 0x0, /* gcFEATURE_VALUE_ClusterAliveMask */ + 0x0, /* gcFEATURE_VALUE_G2D_DEC400_MINOR */ 0x40, /* gcFEATURE_VALUE_NNMadPerCore */ 0x8, /* gcFEATURE_VALUE_NNCoreCount */ 0x8, /* gcFEATURE_VALUE_NNCoreCount_INT8 */ @@ -3104,7 +3400,7 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x10, /* gcFEATURE_VALUE_TPEngine_PwlLUTSize */ 0x100000, /* gcFEATURE_VALUE_VIP_SRAM_SIZE */ 0x3, /* gcFEATURE_VALUE_TPEngine_CoreCount */ - 0x0, /* gcFEATURE_VALUE_AXI_SRAM_SIZE */ + 0x40000, /* gcFEATURE_VALUE_AXI_SRAM_SIZE */ 0x5, /* gcFEATURE_VALUE_NN_INIMAGE_OFFSET_BITS */ 0x200, /* gcFEATURE_VALUE_TP_REORDER_INIMAGE_SIZE */ 0x0, /* gcFEATURE_VALUE_TPLite_CoreCount */ @@ -3116,14 +3412,26 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x40, /* gcFEATURE_VALUE_PHYSICAL_VIP_SRAM_WIDTH_IN_BYTE */ 0x10, /* gcFEATURE_VALUE_EQUIVALENT_VIP_SRAM_WIDTH_INBYTE */ 0x8, /* gcFEATURE_VALUE_TP_ZRL_BITS */ + 0x8, /* gcFEATURE_VALUE_NN_ZRL_BITS */ 0x80, /* gcFEATURE_VALUE_LATENCY_HIDING_AT_FULL_AXI_BW */ 0x10, /* gcFEATURE_VALUE_AXI_BUS_WIDTH */ 0xf, /* gcFEATURE_VALUE_NN_KERNEL_X_SIZE */ 0xf, /* gcFEATURE_VALUE_NN_KERNEL_Y_SIZE */ + 0xf, /* gcFEATURE_VALUE_NN_FC_KERNEL_Y_SIZE */ 0xfffff, /* gcFEATURE_VALUE_NN_KERNEL_Z_SIZE */ 0x1f, /* gcFEATURE_VALUE_NN_X_OFFSET */ 0x1f, /* gcFEATURE_VALUE_NN_Y_OFFSET */ 0x100, /* gcFEATURE_VALUE_DDR_KERNEL_BURST_SIZE */ + 0x10, /* gcFEATURE_VALUE_OUTIMAGE_X_STRIDE_BITS */ + 0x10, /* gcFEATURE_VALUE_OUTIMAGE_Y_STRIDE_BITS */ + 0x10, /* gcFEATURE_VALUE_INIMAGE_X_STRIDE_BITS */ + 0x10, /* gcFEATURE_VALUE_IMIMAGE_Y_STRIDE_BITS */ + 0xd, /* gcFEATURE_VALUE_OUTIMAGE_X_SIZE_BITS */ + 0xd, /* gcFEATURE_VALUE_OUTIMAGE_Y_SIZE_BITS */ + 0xe, /* gcFEATURE_VALUE_OUTIMAGE_SIZE_BITS */ + 0xd, /* gcFEATURE_VALUE_IMAGE_X_SIZE_BITS */ + 0xd, /* gcFEATURE_VALUE_INIMAGE_Y_SIZE_BITS */ + 0x40, /* gcFEATURE_VALUE_MAX_TILE_X_SIZE */ 0x0, /* gcFEATURE_BIT_REG_FastClear */ 0x0, /* gcFEATURE_BIT_REG_SpecialAntiAliasing */ 0x1, /* gcFEATURE_BIT_REG_Pipe3D */ @@ -3365,6 +3673,7 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x1, /* gcFEATURE_BIT_RA_HZEZ_CLOCK_CONTROL */ 0x1, /* gcFEATURE_BIT_CACHE128B256BPERLINE */ 0x1, /* gcFEATURE_BIT_V4Compression */ + 0x0, /* gcFEATURE_BIT_DE2D_MAJOR_SUPER_TILE */ 0x0, /* gcFEATURE_BIT_PE2D_MAJOR_SUPER_TILE */ 0x1, /* gcFEATURE_BIT_PE_32BPC_COLORMASK_FIX */ 0x1, /* gcFEATURE_BIT_ALPHA_BLENDING_OPT */ @@ -3497,6 +3806,7 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_BIT_TX_NO_FIXED_FILTER */ 0x0, /* gcFEATURE_BIT_SHARE_Z */ 0x0, /* gcFEATURE_BIT_DE_2D_FAST_CLEAR */ + 0x0, /* gcFEATURE_BIT_DE_TILESTATUS_ROTATION_FIX */ 0x0, /* gcFEATURE_BIT_TX_CLEAR_PENDING_FIX */ 0x0, /* gcFEATURE_BIT_NO_HI1_L2 */ 0x0, /* gcFEATURE_BIT_USC_EVICT_CTRL_FIFO_FLOP_RESET_FIX */ @@ -3507,6 +3817,13 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_BIT_SH_VX2_FLOATING_MAD_FIX */ 0x0, /* gcFEATURE_BIT_TS_FC_VULKAN_SUPPORT */ 0x0, /* gcFEATURE_BIT_MSAA_FLOAT_64BIT */ + 0x0, /* gcFEATURE_BIT_INDIRECT_COMPUTE_ZERODIM_FIX */ + 0x0, /* gcFEATURE_BIT_Q_CHANNEL_SUPPORT */ + 0x0, /* gcFEATURE_BIT_MMU_PAGE_DESCRIPTOR */ + 0x0, /* gcFEATURE_BIT_YUV_LINEAR_TO_TILE_ROTATE */ + 0x0, /* gcFEATURE_BIT_VEC2_IMULIMAD32_SUPPORT */ + 0x0, /* gcFEATURE_BIT_VEC4_IMULIMAD32_SUPPORT */ + 0x0, /* gcFEATURE_BIT_VEC2_IDIVIMOD16_SUPPORT */ 0x0, /* gcFEATURE_BIT_VG_TS_CULLING */ 0x0, /* gcFEATURE_BIT_VG_FP25 */ 0x0, /* gcFEATURE_BIT_VG_AYUV_INPUT_OUTPUT */ @@ -3533,6 +3850,20 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_BIT_DC_MMU */ 0x0, /* gcFEATURE_BIT_DC_COMPRESSION */ 0x0, /* gcFEATURE_BIT_DC_QOS */ + 0x1, /* gcFEATURE_BIT_VIP_HW_FINAL_RELEASE */ + 0x1, /* gcFEATURE_BIT_NN_SINGLEPORT_ACCUMBUFFER */ + 0x1, /* gcFEATURE_BIT_NN_STRIDE_SUPPORT */ + 0x1, /* gcFEATURE_BIT_SWTILING_PHASE1 */ + 0x1, /* gcFEATURE_BIT_SWTILING_PHASE2 */ + 0x0, /* gcFEATURE_BIT_TP_SIMPLE_INT16 */ + 0x1, /* gcFEATURE_BIT_TP_REAL_INT16 */ + 0x1, /* gcFEATURE_BIT_TP_ROI_POOLING */ + 0x1, /* gcFEATURE_BIT_TP_MAX_POOLING_STRIDE1 */ + 0x1, /* gcFEATURE_BIT_TP_LRN */ + 0x1, /* gcFEATURE_BIT_TP_REORDER */ + 0x1, /* gcFEATURE_BIT_TF_QUANTIZATION */ + 0x0, /* gcFEATURE_BIT_NN_NONZERO_BORDER */ + 0x1, /* gcFEATURE_BIT_NN_MIRROR_BORDER */ 0x0, /* gcFEATURE_BIT_AI_GPU */ 0x0, /* gcFEATURE_BIT_EVIS_NO_ABSDIFF */ 0x0, /* gcFEATURE_BIT_EVIS_NO_BITREPLACE */ @@ -3545,128 +3876,139 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_BIT_EVIS_LERP_7OUTPUT */ 0x0, /* gcFEATURE_BIT_EVIS_ACCSQ_8OUTPUT */ 0x1, /* gcFEATURE_BIT_EVIS_VX2 */ - 0x1, /* gcFEATURE_BIT_NN_FLOAT */ 0x1, /* gcFEATURE_BIT_TP_ENGINE */ 0x1, /* gcFEATURE_BIT_VIP_V7 */ - 0x0, /* gcFEATURE_BIT_MCFE */ - 0x0, /* gcFEATURE_BIT_NN_INTERLEVE8 */ - 0x1, /* gcFEATURE_BIT_TP_REORDER */ - 0x1, /* gcFEATURE_BIT_TP_LRN */ - 0x1, /* gcFEATURE_BIT_TP_MAX_POOLING_STRIDE1 */ - 0x0, /* gcFEATURE_BIT_NN_FP16_ALU */ - 0x1, /* gcFEATURE_BIT_NN_INT16_ALU */ - 0x1, /* gcFEATURE_BIT_TP_ROI_POOLING */ - 0x1, /* gcFEATURE_BIT_NN_ZDP3 */ + 0x0, /* gcFEATURE_BIT_TP_TENSOR_ADD_MUL */ + 0x0, /* gcFEATURE_BIT_NN_DEPTHWISE_INT16XINT8 */ + 0x0, /* gcFEATURE_BIT_TP_SOFTMAX */ + 0x0, /* gcFEATURE_BIT_NN_23BITS_POST_MULTIPLIER_VIP_V7 */ + 0x0, /* gcFEATURE_BIT_TP_23BITS_POST_MULTIPLIER_VIP_V7 */ + 0x0, /* gcFEATURE_BIT_HYBRID_MODE_VIP_V7 */ 0x0, /* gcFEATURE_BIT_NN_ZDP6 */ 0x0, /* gcFEATURE_BIT_NN_XYDP9 */ - 0x1, /* gcFEATURE_BIT_NN_INT8_SCALE */ - 0x1, /* gcFEATURE_BIT_NN_POWER_ISOLATION */ - 0x1, /* gcFEATURE_BIT_SWTILING_PHASE1 */ - 0x1, /* gcFEATURE_BIT_TF_QUANTIZATION */ - 0x0, /* gcFEATURE_BIT_TP_SIMPLE_INT16 */ - 0x1, /* gcFEATURE_BIT_TP_REAL_INT16 */ - 0x0, /* gcFEATURE_BIT_TP_BFLOAT16 */ - 0x1, /* gcFEATURE_BIT_NN_FIRST_PIXEL_POOLING */ - 0x1, /* gcFEATURE_BIT_SWTILING_PHASE2 */ - 0x1, /* gcFEATURE_BIT_NN_STRIDE_SUPPORT */ + 0x1, /* gcFEATURE_BIT_NN_FIRST_PIXEL_POOLING */ + 0x1, /* gcFEATURE_BIT_NN_ZDP3 */ 0x0, /* gcFEATURE_BIT_NN_XYDP6 */ - 0x1, /* gcFEATURE_BIT_TP_REORDER_FIX */ - 0x1, /* gcFEATURE_BIT_NN_CONV1x1_PERF_FIX */ - 0x1, /* gcFEATURE_BIT_NN_CACHELINE_MODE_PERF_FIX */ - 0x1, /* gcFEATURE_BIT_NN_PER3DTILE_BUBBLE_FIX */ - 0x1, /* gcFEATURE_BIT_NN_CONVOUT_FIFO_DEPTH_FIX */ 0x1, /* gcFEATURE_BIT_SWTILING_PHASE3 */ + 0x0, /* gcFEATURE_BIT_MCFE */ 0x0, /* gcFEATURE_BIT_USC_STAY_LRU */ - 0x1, /* gcFEATURE_BIT_NN_NONZERO_MIRROR_BORDER */ + 0x1, /* gcFEATURE_BIT_COEF_COMPRESSION_ENHANCEMENT */ + 0x1, /* gcFEATURE_BIT_TP_COEF_COMPRESSION_ENHANCEMENT */ 0x1, /* gcFEATURE_BIT_NN_COEF_DECOMPRESS_PERF2X */ + 0x1, /* gcFEATURE_BIT_OCB_COUNTER */ + 0x0, /* gcFEATURE_BIT_SCALER */ + 0x0, /* gcFEATURE_BIT_SCALER_4K */ 0x0, /* gcFEATURE_BIT_INPUT_4BIT */ - 0x1, /* gcFEATURE_BIT_COEF_COMPRESSION_ENHANCEMENT */ + 0x1, /* gcFEATURE_BIT_NN_NO_Z_LOCATION_OFFSET */ + 0x1, /* gcFEATURE_BIT_OCB_REMAP_PHYSICAL_ADDRESS */ + 0x1, /* gcFEATURE_BIT_NN_SLOW_OUTPUT */ + 0x1, /* gcFEATURE_BIT_NO_NARROW_POST_PROCESS_PIPE */ + 0x1, /* gcFEATURE_BIT_TP_NN_PROBE */ + 0x1, /* gcFEATURE_BIT_NN_DEPTHWISE_SUPPORT */ + 0x1, /* gcFEATURE_BIT_NN_XYDP0 */ + 0x1, /* gcFEATURE_BIT_NN_WRITE_WITHOUT_USC */ + 0x1, /* gcFEATURE_BIT_NN_HW_LIMITATION_NATIVE_KER_1x2_2x1 */ + 0x1, /* gcFEATURE_BIT_NN_SLICE_PADDING_TO_64BYTE_ALIGN */ + 0x0, /* gcFEATURE_BIT_NN_DW_1x1_CONV_MERGE */ + 0x0, /* gcFEATURE_BIT_TP_BFLOAT16 */ + 0x0, /* gcFEATURE_BIT_TP_23BITS_POST_MULTIPLIER */ + 0x1, /* gcFEATURE_BIT_NN_TRANSPOSE */ + 0x1, /* gcFEATURE_BIT_USE_SINGLE_PORT_VIPSRAM */ + 0x0, /* gcFEATURE_BIT_NN_LEAKY_RELU */ + 0x0, /* gcFEATURE_BIT_NN_PRELU */ + 0x0, /* gcFEATURE_BIT_NN_PER_CHANNEL_QUANT */ + 0x0, /* gcFEATURE_BIT_NN_PER_CHANNEL_QUANT_ASYM */ + 0x0, /* gcFEATURE_BIT_NN_ASYMMETRIC_INT8 */ + 0x0, /* gcFEATURE_BIT_NN_FLOAT_POST_MULT */ + 0x0, /* gcFEATURE_BIT_PRELU_LEAKLY_RELU_CLAMP */ + 0x0, /* gcFEATURE_BIT_TPLITE_BFLOAT16 */ + 0x0, /* gcFEATURE_BIT_PREPROCESS_IMG_BUF_640BYTE_LIMIT */ + 0x0, /* gcFEATURE_BIT_TP_KERNEL_1BYTE_ALGIN */ + 0x0, /* gcFEATURE_BIT_BFLOAT_COEF_COMPRESSION_ZERO_COEFBIT14_INVERSE */ + 0x0, /* gcFEATURE_BIT_NN_COMPRESSION_BYPASSS */ + 0x0, /* gcFEATURE_BIT_TP_3_USC */ + 0x0, /* gcFEATURE_BIT_BFP_COEF_AUTO_PAD_INCOMPLETE_ZERO_IN_KZ_PLANE */ + 0x0, /* gcFEATURE_BIT_NN_NATIVE_STRIDE_TWO */ + 0x0, /* gcFEATURE_BIT_NN_TENSOR_ADD */ + 0x0, /* gcFEATURE_BIT_NN_FLOAT32_IO */ + 0x0, /* gcFEATURE_BIT_TP_FLOAT32_IO */ + 0x0, /* gcFEATURE_BIT_NN_SMALL_BATCH_PHASE2 */ + 0x0, /* gcFEATURE_BIT_TILE_ACCESS_CAPABILITY */ + 0x0, /* gcFEATURE_BIT_FAST_DP3_PREPROCESSOR */ + 0x0, /* gcFEATURE_BIT_DEPTHWISE_SUPPORT_16BIT_FORMAT */ + 0x0, /* gcFEATURE_BIT_NN_SUPPORT_ALU_LUT */ + 0x0, /* gcFEATURE_BIT_NN_ENHANCED_MAX_POOLING */ + 0x0, /* gcFEATURE_BIT_NN_TRANSPOSE_PHASE2 */ + 0x0, /* gcFEATURE_BIT_TPLITE_SUPPORT_TP_DATA_TRANSPOSE */ + 0x0, /* gcFEATURE_BIT_NN_SUPPORT_CONV_1D */ + 0x0, /* gcFEATURE_BIT_USE_VIPSRAM_FOR_KERNEL_STREAMING */ + 0x0, /* gcFEATURE_BIT_VIP_DEC400 */ + 0x1, /* gcFEATURE_BIT_NN_PER3DTILE_BUBBLE_FIX */ + 0x1, /* gcFEATURE_BIT_NN_CACHELINE_MODE_PERF_FIX */ + 0x1, /* gcFEATURE_BIT_NN_CONV1x1_PERF_FIX */ + 0x1, /* gcFEATURE_BIT_TP_REORDER_FIX */ + 0x1, /* gcFEATURE_BIT_NN_CONVOUT_FIFO_DEPTH_FIX */ 0x1, /* gcFEATURE_BIT_NN_ZXDP3_KERNEL_READ_CONFLICT_FIX */ 0x1, /* gcFEATURE_BIT_NN_ZDP3_NO_COMPRESS_FIX */ 0x1, /* gcFEATURE_BIT_NN_ASYNC_COPY_PERF_FIX */ - 0x1, /* gcFEATURE_BIT_OCB_COUNTER */ - 0x1, /* gcFEATURE_BIT_NN_XYDP0 */ - 0x0, /* gcFEATURE_BIT_ZRL_7BIT */ + 0x1, /* gcFEATURE_BIT_HI_REORDER_FIX */ + 0x1, /* gcFEATURE_BIT_INCORRECT_WR_REQ_TO_USC_BETWEEN_REORDER_AND_NORMAL_LAYER_FIX */ + 0x1, /* gcFEATURE_BIT_TP_REORDER_LAYER_SUSPEND_FIX */ 0x1, /* gcFEATURE_BIT_NN_ASYNC_COPY_MERGE_FIX */ - 0x1, /* gcFEATURE_BIT_NN_SMALLBATCH_PHASE1 */ - 0x1, /* gcFEATURE_BIT_TP_SMALLBATCH_PHASE1 */ - 0x0, /* gcFEATURE_BIT_SCALER */ - 0x0, /* gcFEATURE_BIT_SCALER_4K */ + 0x1, /* gcFEATURE_BIT_USC_INVALIDATE_CACHE_LINE_FIX */ 0x0, /* gcFEATURE_BIT_NN_REQ_SLOWARBITRATION_FIX */ - 0x0, /* gcFEATURE_BIT_IMAGE_PARTIAL_CACHE */ + 0x0, /* gcFEATURE_BIT_IMAGE_PARTIAL_CACHE_FIX */ 0x0, /* gcFEATURE_BIT_FULLCACHE_KERNELHEAD_FIX */ - 0x1, /* gcFEATURE_BIT_NN_SINGLEPORT_ACCUMBUFFER */ - 0x0, /* gcFEATURE_BIT_NN_SMALLBATCH */ - 0x0, /* gcFEATURE_BIT_TP_SMALLBATCH */ - 0x1, /* gcFEATURE_BIT_ZRL_8BIT */ - 0x1, /* gcFEATURE_BIT_NN_DEPTHWISE_SUPPORT */ - 0x1, /* gcFEATURE_BIT_NN_WRITE_WITHOUT_USC */ 0x1, /* gcFEATURE_BIT_NN_ZDP_INIMAGE_SIZE_FIX */ - 0x1, /* gcFEATURE_BIT_HI_REORDER_FIX */ - 0x1, /* gcFEATURE_BIT_INCORRECT_WR_REQ_TO_USC_BETWEEN_REORDER_AND_NORMAL_LAYER_FIX */ - 0x1, /* gcFEATURE_BIT_TP_COEF_COMPRESSION_ENHANCEMENT */ - 0x0, /* gcFEATURE_BIT_VIP_DEC400 */ - 0x1, /* gcFEATURE_BIT_IMAGE_NOT_PACKED_IN_SRAM_FIX */ 0x1, /* gcFEATURE_BIT_IDLE_BEFORE_FLUSH_COMPLETE_FIX */ 0x1, /* gcFEATURE_BIT_NO_FLUSH_USC_FIX */ + 0x1, /* gcFEATURE_BIT_SMALL_BATCH_FLOPS_RESET_FIX */ + 0x0, /* gcFEATURE_BIT_SMALL_BATCH_DISBLE_FIX */ + 0x1, /* gcFEATURE_BIT_OUTPUT_CONVERT_UINT8_INT8_TO_UINT16_INT16_FIX */ + 0x1, /* gcFEATURE_BIT_IMAGE_NOT_PACKED_IN_SRAM_FIX */ 0x1, /* gcFEATURE_BIT_COEF_DELTA_CORD_OVERFLOW_ZRL_8BIT_FIX */ - 0x1, /* gcFEATURE_BIT_XY_OFFSET_LIMITATION_FIX */ - 0x1, /* gcFEATURE_BIT_USC_INVALIDATE_CACHE_LINE_FIX */ 0x0, /* gcFEATURE_BIT_LOW_EFFICIENCY_OF_ID_WRITE_IMGBUF_FIX */ - 0x0, /* gcFEATURE_BIT_KERNEL_PER_CORE_LESS_THAN_THIRD_COEF_BUFF_DEPTH_FIX */ + 0x1, /* gcFEATURE_BIT_KERNEL_VIP_SRAM_READ_BW_LIMITATION_FIX */ 0x0, /* gcFEATURE_BIT_USC_BOTTLENECK_FIX */ + 0x0, /* gcFEATURE_BIT_KERNEL_PER_CORE_LESS_THAN_THIRD_COEF_BUFF_DEPTH_FIX */ 0x0, /* gcFEATURE_BIT_KERNEL_SIZE_WASTE_IN_PARTIAL_MODE_FIX */ - 0x1, /* gcFEATURE_BIT_FULLCACHE_KERNEL_INTERLEAVE_FIX */ - 0x1, /* gcFEATURE_BIT_TP_REORDER_LAYER_SUSPEND_FIX */ - 0x1, /* gcFEATURE_BIT_KERNEL_VIP_SRAM_READ_BW_LIMITATION_FIX */ + 0x1, /* gcFEATURE_BIT_NN_COMMAND_KERNEL_REQUEST_CONFICT_FIX */ + 0x1, /* gcFEATURE_BIT_TP_REORDER_INTILE_X_SIZE_512_FIX */ 0x1, /* gcFEATURE_BIT_IMG_POP_PIPELINE_PAUSE_FIX */ + 0x1, /* gcFEATURE_BIT_FULLCACHE_KERNEL_INTERLEAVE_FIX */ + 0x0, /* gcFEATURE_BIT_V8_SINGLE_PORT_ACCUMULATION_BUFFER_RW_CONFICT_ZERO_SKIP_PERF_FIX */ + 0x0, /* gcFEATURE_BIT_V8_ACCUMLATION_READ_OUT_HAS_BUBBLES_PERF_FIX */ + 0x1, /* gcFEATURE_BIT_DEPTHWISE_NEIGHBOR_IMG_DATA_TRANSFER_NOT_EFFICIENT_FIX */ 0x1, /* gcFEATURE_BIT_DR_JD_DIFF_CONDITION_FOR_CACHELINE_MODE_PRE_FIX */ - 0x1, /* gcFEATURE_BIT_OUTIMAGE_X_BITWIDTH_LIMIT_FOR_NN_TRANSPOSE_FIX */ - 0x1, /* gcFEATURE_BIT_SMALL_BATCH_FLOPS_RESET_FIX */ - 0x0, /* gcFEATURE_BIT_SMALL_BATCH_DISBLE_FIX */ - 0x1, /* gcFEATURE_BIT_NEGATIVE_POST_SHIFT_FIX */ - 0x1, /* gcFEATURE_BIT_NN_COMMAND_KERNEL_REQUEST_CONFICT_FIX */ - 0x1, /* gcFEATURE_BIT_OCB_REMAP_PHYSICAL_ADDRESS */ - 0x1, /* gcFEATURE_BIT_NN_NO_Z_LOCATION_OFFSET */ - 0x0, /* gcFEATURE_BIT_NN_LEAKY_RELU */ - 0x0, /* gcFEATURE_BIT_NN_PRELU */ - 0x0, /* gcFEATURE_BIT_NN_PER_CHANNEL_QUANT */ - 0x0, /* gcFEATURE_BIT_NN_PER_CHANNEL_QUANT_ASYM */ - 0x0, /* gcFEATURE_BIT_NN_NATIVE_STRIDE_TWO */ - 0x0, /* gcFEATURE_BIT_NN_TENSOR_ADD */ - 0x0, /* gcFEATURE_BIT_NN_FLOAT_POST_MULT */ - 0x1, /* gcFEATURE_BIT_NN_SLICE_PADDING_TO_64BYTE_ALIGN */ - 0x0, /* gcFEATURE_BIT_NN_DW_1x1_CONV_MERGE */ - 0x1, /* gcFEATURE_BIT_NN_SLOW_OUTPUT */ - 0x1, /* gcFEATURE_BIT_NO_NARROW_POST_PROCESS_PIPE */ - 0x1, /* gcFEATURE_BIT_TP_NN_PROBE */ - 0x0, /* gcFEATURE_BIT_TP_23BITS_POST_MULTIPLIER */ - 0x1, /* gcFEATURE_BIT_NN_TRANSPOSE */ + 0x0, /* gcFEATURE_BIT_TP_ACCESS_VIPSRAM_OT_IS_ONE_FIX */ 0x0, /* gcFEATURE_BIT_EVIS2_FLOP_RESET_FIX */ + 0x1, /* gcFEATURE_BIT_OUTIMAGE_X_BITWIDTH_LIMIT_FOR_NN_TRANSPOSE_FIX */ 0x0, /* gcFEATURE_BIT_USC_ASYNC_CP_RTN_FLOP_RESET_FIX */ - 0x1, /* gcFEATURE_BIT_DDR_BURST_LEN_256B */ + 0x1, /* gcFEATURE_BIT_IMG_ADDR_NOT_WRAP_IF_OVER_OCB_ADDR_FIX */ + 0x1, /* gcFEATURE_BIT_NEGATIVE_POST_SHIFT_FIX */ + 0x1, /* gcFEATURE_BIT_INIMAGE_2DTILE_NOT_LESS_160PIXEL_FIX */ 0x0, /* gcFEATURE_BIT_IMG_CAHCE_MODE_MUST_0_IN_IMG_DIRECT_MODE_FIX */ - 0x1, /* gcFEATURE_BIT_USE_SINGLE_PORT_VIPSRAM */ - 0x0, /* gcFEATURE_BIT_NN_ASYMMETRIC_INT8 */ - 0x1, /* gcFEATURE_BIT_DEPTHWISE_NEIGHBOR_IMG_DATA_TRANSFER_NOT_EFFICIENT_FIX */ - 0x0, /* gcFEATURE_BIT_PRELU_LEAKLY_RELU_CLAMP */ - 0x0, /* gcFEATURE_BIT_TP_FLOAT32_IO */ - 0x0, /* gcFEATURE_BIT_NN_FLOAT32_IO */ - 0x0, /* gcFEATURE_BIT_NN_SMALL_BATCH_PHASE2 */ - 0x0, /* gcFEATURE_BIT_TILE_ACCESS_CAPABILITY */ - 0x0, /* gcFEATURE_BIT_FAST_DP3_PREPROCESSOR */ - 0x0, /* gcFEATURE_BIT_NN_COMPRESSION_BYPASSS */ - 0x0, /* gcFEATURE_BIT_BFLOAT_KERNEL_COMPRESSION_ZERO_SKIP_FIX */ - 0x0, /* gcFEATURE_BIT_TP_3_USC */ - 0x0, /* gcFEATURE_BIT_TP_KERNEL_1BYTE_ALGIN */ - 0x0, /* gcFEATURE_BIT_TPLITE_BFLOAT16 */ - 0x0, /* gcFEATURE_BIT_PREPROCESS_IMG_BUF_640BYTE_LIMIT */ - 0x0, /* gcFEATURE_BIT_V8_ACCUMLATION_READ_OUT_HAS_BUBBLES_PERF_FIX */ - 0x0, /* gcFEATURE_BIT_V8_SINGLE_PORT_ACCUMULATION_BUFFER_RW_CONFICT_ZERO_SKIP_PERF_FIX */ 0x0, /* gcFEATURE_BIT_BURST_COLLECT_DUMMY_DATA_WASTE_CYCLES_FIX */ 0x1, /* gcFEATURE_BIT_INIMG_NOT_64BYTE_ALIGN_CACHELINE_MODE_FIX */ - 0x0, /* gcFEATURE_BIT_TP_ACCESS_VIPSRAM_OT_IS_ONE_FIX */ - 0x0, /* gcFEATURE_BIT_VIP_HW_FINAL_RELEASE */ + 0x0, /* gcFEATURE_BIT_TP_FC_FLOAT_LAST_PIXEL_NEGATIVE_0_FIX */ + 0x1, /* gcFEATURE_BIT_NN_WASET_COEF_READ_WRITE_BANDWIDTH_128BYTE_VIPSRAM_IN_FULL_PATIAL_CACHE_MODE */ + 0x1, /* gcFEATURE_BIT_NN_IN_TILE_DATA_IS_ALL_PAD_FIX */ + 0x1, /* gcFEATURE_BIT_TP_FC_KERNEL_STREAM_MUST_LESS_THAN_OR_EQUAL_TO_64BYTE_WHEN_1BYTE_ALGINE_FIX */ + 0x0, /* gcFEATURE_BIT_NN_INTERLEVE8 */ + 0x0, /* gcFEATURE_BIT_NN_FP16_ALU */ + 0x1, /* gcFEATURE_BIT_NN_INT16_ALU */ + 0x1, /* gcFEATURE_BIT_NN_INT8_SCALE */ + 0x1, /* gcFEATURE_BIT_NN_POWER_ISOLATION */ + 0x0, /* gcFEATURE_BIT_ZRL_7BIT */ + 0x1, /* gcFEATURE_BIT_NN_SMALLBATCH_PHASE1 */ + 0x1, /* gcFEATURE_BIT_TP_SMALLBATCH_PHASE1 */ + 0x0, /* gcFEATURE_BIT_NN_SMALLBATCH */ + 0x0, /* gcFEATURE_BIT_TP_SMALLBATCH */ + 0x1, /* gcFEATURE_BIT_ZRL_8BIT */ + 0x1, /* gcFEATURE_BIT_DDR_BURST_LEN_256B */ + 0x1, /* gcFEATURE_BIT_XY_OFFSET_LIMITATION_FIX */ + 0x1, /* gcFEATURE_BIT_NN_NONZERO_MIRROR_BORDER */ + 0x0, /* gcFEATURE_BIT_IMAGE_PARTIAL_CACHE */ }, /* vipnano-qi */ { @@ -3685,13 +4027,23 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x140, /* gcFEATURE_VALUE_NumberOfConstants */ 0x1, /* gcFEATURE_VALUE_CoreCount */ 0x10, /* gcFEATURE_VALUE_LocalStorageSize */ + 0x0, /* gcFEATURE_VALUE_LocalStorageSize_1 */ + 0x0, /* gcFEATURE_VALUE_LocalStorageSize_2 */ 0x10, /* gcFEATURE_VALUE_L1CacheSize */ + 0x0, /* gcFEATURE_VALUE_L1CacheSize_1 */ + 0x0, /* gcFEATURE_VALUE_L1CacheSize_2 */ 0x200, /* gcFEATURE_VALUE_InstructionMemorySize */ 0x14, /* gcFEATURE_VALUE_ShaderPCLength */ 0x10, /* gcFEATURE_VALUE_USC_MAX_PAGES */ + 0x0, /* gcFEATURE_VALUE_USC_MAX_PAGES_1 */ + 0x0, /* gcFEATURE_VALUE_USC_MAX_PAGES_2 */ 0x1, /* gcFEATURE_VALUE_NumPixelPipes */ 0x2, /* gcFEATURE_VALUE_USC_CACHE_CONTROLLERS */ + 0x0, /* gcFEATURE_VALUE_USC_CACHE_CONTROLLERS_1 */ + 0x0, /* gcFEATURE_VALUE_USC_CACHE_CONTROLLERS_2 */ 0x2, /* gcFEATURE_VALUE_USC_BANKS */ + 0x0, /* gcFEATURE_VALUE_USC_BANKS_1 */ + 0x0, /* gcFEATURE_VALUE_USC_BANKS_2 */ 0x8, /* gcFEATURE_VALUE_Streams */ 0x10, /* gcFEATURE_VALUE_VaryingCount */ 0x400, /* gcFEATURE_VALUE_VertexOutputBufferSize */ @@ -3700,6 +4052,7 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_VALUE_NumResolvePipes */ 0x100, /* gcFEATURE_VALUE_RESULT_WINDOW_MAX_SIZE */ 0x0, /* gcFEATURE_VALUE_ClusterAliveMask */ + 0x0, /* gcFEATURE_VALUE_G2D_DEC400_MINOR */ 0x40, /* gcFEATURE_VALUE_NNMadPerCore */ 0x8, /* gcFEATURE_VALUE_NNCoreCount */ 0x8, /* gcFEATURE_VALUE_NNCoreCount_INT8 */ @@ -3724,14 +4077,26 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x40, /* gcFEATURE_VALUE_PHYSICAL_VIP_SRAM_WIDTH_IN_BYTE */ 0x20, /* gcFEATURE_VALUE_EQUIVALENT_VIP_SRAM_WIDTH_INBYTE */ 0x8, /* gcFEATURE_VALUE_TP_ZRL_BITS */ + 0x8, /* gcFEATURE_VALUE_NN_ZRL_BITS */ 0x80, /* gcFEATURE_VALUE_LATENCY_HIDING_AT_FULL_AXI_BW */ 0x10, /* gcFEATURE_VALUE_AXI_BUS_WIDTH */ 0xb, /* gcFEATURE_VALUE_NN_KERNEL_X_SIZE */ 0xb, /* gcFEATURE_VALUE_NN_KERNEL_Y_SIZE */ + 0xf, /* gcFEATURE_VALUE_NN_FC_KERNEL_Y_SIZE */ 0xfffff, /* gcFEATURE_VALUE_NN_KERNEL_Z_SIZE */ 0xf, /* gcFEATURE_VALUE_NN_X_OFFSET */ 0xf, /* gcFEATURE_VALUE_NN_Y_OFFSET */ 0x40, /* gcFEATURE_VALUE_DDR_KERNEL_BURST_SIZE */ + 0x10, /* gcFEATURE_VALUE_OUTIMAGE_X_STRIDE_BITS */ + 0x0, /* gcFEATURE_VALUE_OUTIMAGE_Y_STRIDE_BITS */ + 0x10, /* gcFEATURE_VALUE_INIMAGE_X_STRIDE_BITS */ + 0x10, /* gcFEATURE_VALUE_IMIMAGE_Y_STRIDE_BITS */ + 0xd, /* gcFEATURE_VALUE_OUTIMAGE_X_SIZE_BITS */ + 0xd, /* gcFEATURE_VALUE_OUTIMAGE_Y_SIZE_BITS */ + 0xe, /* gcFEATURE_VALUE_OUTIMAGE_SIZE_BITS */ + 0xd, /* gcFEATURE_VALUE_IMAGE_X_SIZE_BITS */ + 0xd, /* gcFEATURE_VALUE_INIMAGE_Y_SIZE_BITS */ + 0x40, /* gcFEATURE_VALUE_MAX_TILE_X_SIZE */ 0x0, /* gcFEATURE_BIT_REG_FastClear */ 0x0, /* gcFEATURE_BIT_REG_SpecialAntiAliasing */ 0x1, /* gcFEATURE_BIT_REG_Pipe3D */ @@ -3973,6 +4338,7 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x1, /* gcFEATURE_BIT_RA_HZEZ_CLOCK_CONTROL */ 0x1, /* gcFEATURE_BIT_CACHE128B256BPERLINE */ 0x1, /* gcFEATURE_BIT_V4Compression */ + 0x0, /* gcFEATURE_BIT_DE2D_MAJOR_SUPER_TILE */ 0x0, /* gcFEATURE_BIT_PE2D_MAJOR_SUPER_TILE */ 0x1, /* gcFEATURE_BIT_PE_32BPC_COLORMASK_FIX */ 0x1, /* gcFEATURE_BIT_ALPHA_BLENDING_OPT */ @@ -4105,6 +4471,7 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_BIT_TX_NO_FIXED_FILTER */ 0x0, /* gcFEATURE_BIT_SHARE_Z */ 0x0, /* gcFEATURE_BIT_DE_2D_FAST_CLEAR */ + 0x0, /* gcFEATURE_BIT_DE_TILESTATUS_ROTATION_FIX */ 0x0, /* gcFEATURE_BIT_TX_CLEAR_PENDING_FIX */ 0x0, /* gcFEATURE_BIT_NO_HI1_L2 */ 0x0, /* gcFEATURE_BIT_USC_EVICT_CTRL_FIFO_FLOP_RESET_FIX */ @@ -4115,6 +4482,13 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_BIT_SH_VX2_FLOATING_MAD_FIX */ 0x0, /* gcFEATURE_BIT_TS_FC_VULKAN_SUPPORT */ 0x0, /* gcFEATURE_BIT_MSAA_FLOAT_64BIT */ + 0x0, /* gcFEATURE_BIT_INDIRECT_COMPUTE_ZERODIM_FIX */ + 0x0, /* gcFEATURE_BIT_Q_CHANNEL_SUPPORT */ + 0x0, /* gcFEATURE_BIT_MMU_PAGE_DESCRIPTOR */ + 0x0, /* gcFEATURE_BIT_YUV_LINEAR_TO_TILE_ROTATE */ + 0x0, /* gcFEATURE_BIT_VEC2_IMULIMAD32_SUPPORT */ + 0x0, /* gcFEATURE_BIT_VEC4_IMULIMAD32_SUPPORT */ + 0x0, /* gcFEATURE_BIT_VEC2_IDIVIMOD16_SUPPORT */ 0x0, /* gcFEATURE_BIT_VG_TS_CULLING */ 0x0, /* gcFEATURE_BIT_VG_FP25 */ 0x0, /* gcFEATURE_BIT_VG_AYUV_INPUT_OUTPUT */ @@ -4141,6 +4515,20 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_BIT_DC_MMU */ 0x0, /* gcFEATURE_BIT_DC_COMPRESSION */ 0x0, /* gcFEATURE_BIT_DC_QOS */ + 0x1, /* gcFEATURE_BIT_VIP_HW_FINAL_RELEASE */ + 0x1, /* gcFEATURE_BIT_NN_SINGLEPORT_ACCUMBUFFER */ + 0x1, /* gcFEATURE_BIT_NN_STRIDE_SUPPORT */ + 0x1, /* gcFEATURE_BIT_SWTILING_PHASE1 */ + 0x1, /* gcFEATURE_BIT_SWTILING_PHASE2 */ + 0x0, /* gcFEATURE_BIT_TP_SIMPLE_INT16 */ + 0x1, /* gcFEATURE_BIT_TP_REAL_INT16 */ + 0x1, /* gcFEATURE_BIT_TP_ROI_POOLING */ + 0x1, /* gcFEATURE_BIT_TP_MAX_POOLING_STRIDE1 */ + 0x1, /* gcFEATURE_BIT_TP_LRN */ + 0x1, /* gcFEATURE_BIT_TP_REORDER */ + 0x1, /* gcFEATURE_BIT_TF_QUANTIZATION */ + 0x0, /* gcFEATURE_BIT_NN_NONZERO_BORDER */ + 0x1, /* gcFEATURE_BIT_NN_MIRROR_BORDER */ 0x0, /* gcFEATURE_BIT_AI_GPU */ 0x0, /* gcFEATURE_BIT_EVIS_NO_ABSDIFF */ 0x0, /* gcFEATURE_BIT_EVIS_NO_BITREPLACE */ @@ -4153,128 +4541,139 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_BIT_EVIS_LERP_7OUTPUT */ 0x0, /* gcFEATURE_BIT_EVIS_ACCSQ_8OUTPUT */ 0x1, /* gcFEATURE_BIT_EVIS_VX2 */ - 0x1, /* gcFEATURE_BIT_NN_FLOAT */ 0x1, /* gcFEATURE_BIT_TP_ENGINE */ 0x1, /* gcFEATURE_BIT_VIP_V7 */ - 0x0, /* gcFEATURE_BIT_MCFE */ - 0x0, /* gcFEATURE_BIT_NN_INTERLEVE8 */ - 0x1, /* gcFEATURE_BIT_TP_REORDER */ - 0x1, /* gcFEATURE_BIT_TP_LRN */ - 0x1, /* gcFEATURE_BIT_TP_MAX_POOLING_STRIDE1 */ - 0x0, /* gcFEATURE_BIT_NN_FP16_ALU */ - 0x1, /* gcFEATURE_BIT_NN_INT16_ALU */ - 0x1, /* gcFEATURE_BIT_TP_ROI_POOLING */ - 0x1, /* gcFEATURE_BIT_NN_ZDP3 */ + 0x0, /* gcFEATURE_BIT_TP_TENSOR_ADD_MUL */ + 0x0, /* gcFEATURE_BIT_NN_DEPTHWISE_INT16XINT8 */ + 0x0, /* gcFEATURE_BIT_TP_SOFTMAX */ + 0x0, /* gcFEATURE_BIT_NN_23BITS_POST_MULTIPLIER_VIP_V7 */ + 0x0, /* gcFEATURE_BIT_TP_23BITS_POST_MULTIPLIER_VIP_V7 */ + 0x0, /* gcFEATURE_BIT_HYBRID_MODE_VIP_V7 */ 0x0, /* gcFEATURE_BIT_NN_ZDP6 */ 0x0, /* gcFEATURE_BIT_NN_XYDP9 */ - 0x1, /* gcFEATURE_BIT_NN_INT8_SCALE */ - 0x1, /* gcFEATURE_BIT_NN_POWER_ISOLATION */ - 0x1, /* gcFEATURE_BIT_SWTILING_PHASE1 */ - 0x1, /* gcFEATURE_BIT_TF_QUANTIZATION */ - 0x0, /* gcFEATURE_BIT_TP_SIMPLE_INT16 */ - 0x1, /* gcFEATURE_BIT_TP_REAL_INT16 */ - 0x0, /* gcFEATURE_BIT_TP_BFLOAT16 */ 0x1, /* gcFEATURE_BIT_NN_FIRST_PIXEL_POOLING */ - 0x1, /* gcFEATURE_BIT_SWTILING_PHASE2 */ - 0x1, /* gcFEATURE_BIT_NN_STRIDE_SUPPORT */ + 0x1, /* gcFEATURE_BIT_NN_ZDP3 */ 0x1, /* gcFEATURE_BIT_NN_XYDP6 */ - 0x1, /* gcFEATURE_BIT_TP_REORDER_FIX */ - 0x1, /* gcFEATURE_BIT_NN_CONV1x1_PERF_FIX */ - 0x1, /* gcFEATURE_BIT_NN_CACHELINE_MODE_PERF_FIX */ - 0x0, /* gcFEATURE_BIT_NN_PER3DTILE_BUBBLE_FIX */ - 0x1, /* gcFEATURE_BIT_NN_CONVOUT_FIFO_DEPTH_FIX */ 0x1, /* gcFEATURE_BIT_SWTILING_PHASE3 */ + 0x0, /* gcFEATURE_BIT_MCFE */ 0x0, /* gcFEATURE_BIT_USC_STAY_LRU */ - 0x1, /* gcFEATURE_BIT_NN_NONZERO_MIRROR_BORDER */ + 0x1, /* gcFEATURE_BIT_COEF_COMPRESSION_ENHANCEMENT */ + 0x0, /* gcFEATURE_BIT_TP_COEF_COMPRESSION_ENHANCEMENT */ 0x1, /* gcFEATURE_BIT_NN_COEF_DECOMPRESS_PERF2X */ + 0x1, /* gcFEATURE_BIT_OCB_COUNTER */ + 0x0, /* gcFEATURE_BIT_SCALER */ + 0x0, /* gcFEATURE_BIT_SCALER_4K */ 0x0, /* gcFEATURE_BIT_INPUT_4BIT */ - 0x1, /* gcFEATURE_BIT_COEF_COMPRESSION_ENHANCEMENT */ + 0x0, /* gcFEATURE_BIT_NN_NO_Z_LOCATION_OFFSET */ + 0x1, /* gcFEATURE_BIT_OCB_REMAP_PHYSICAL_ADDRESS */ + 0x0, /* gcFEATURE_BIT_NN_SLOW_OUTPUT */ + 0x1, /* gcFEATURE_BIT_NO_NARROW_POST_PROCESS_PIPE */ + 0x0, /* gcFEATURE_BIT_TP_NN_PROBE */ + 0x0, /* gcFEATURE_BIT_NN_DEPTHWISE_SUPPORT */ + 0x0, /* gcFEATURE_BIT_NN_XYDP0 */ + 0x0, /* gcFEATURE_BIT_NN_WRITE_WITHOUT_USC */ + 0x0, /* gcFEATURE_BIT_NN_HW_LIMITATION_NATIVE_KER_1x2_2x1 */ + 0x0, /* gcFEATURE_BIT_NN_SLICE_PADDING_TO_64BYTE_ALIGN */ + 0x0, /* gcFEATURE_BIT_NN_DW_1x1_CONV_MERGE */ + 0x0, /* gcFEATURE_BIT_TP_BFLOAT16 */ + 0x0, /* gcFEATURE_BIT_TP_23BITS_POST_MULTIPLIER */ + 0x0, /* gcFEATURE_BIT_NN_TRANSPOSE */ + 0x0, /* gcFEATURE_BIT_USE_SINGLE_PORT_VIPSRAM */ + 0x0, /* gcFEATURE_BIT_NN_LEAKY_RELU */ + 0x0, /* gcFEATURE_BIT_NN_PRELU */ + 0x0, /* gcFEATURE_BIT_NN_PER_CHANNEL_QUANT */ + 0x0, /* gcFEATURE_BIT_NN_PER_CHANNEL_QUANT_ASYM */ + 0x0, /* gcFEATURE_BIT_NN_ASYMMETRIC_INT8 */ + 0x0, /* gcFEATURE_BIT_NN_FLOAT_POST_MULT */ + 0x0, /* gcFEATURE_BIT_PRELU_LEAKLY_RELU_CLAMP */ + 0x0, /* gcFEATURE_BIT_TPLITE_BFLOAT16 */ + 0x0, /* gcFEATURE_BIT_PREPROCESS_IMG_BUF_640BYTE_LIMIT */ + 0x0, /* gcFEATURE_BIT_TP_KERNEL_1BYTE_ALGIN */ + 0x0, /* gcFEATURE_BIT_BFLOAT_COEF_COMPRESSION_ZERO_COEFBIT14_INVERSE */ + 0x0, /* gcFEATURE_BIT_NN_COMPRESSION_BYPASSS */ + 0x0, /* gcFEATURE_BIT_TP_3_USC */ + 0x0, /* gcFEATURE_BIT_BFP_COEF_AUTO_PAD_INCOMPLETE_ZERO_IN_KZ_PLANE */ + 0x0, /* gcFEATURE_BIT_NN_NATIVE_STRIDE_TWO */ + 0x0, /* gcFEATURE_BIT_NN_TENSOR_ADD */ + 0x0, /* gcFEATURE_BIT_NN_FLOAT32_IO */ + 0x0, /* gcFEATURE_BIT_TP_FLOAT32_IO */ + 0x0, /* gcFEATURE_BIT_NN_SMALL_BATCH_PHASE2 */ + 0x0, /* gcFEATURE_BIT_TILE_ACCESS_CAPABILITY */ + 0x0, /* gcFEATURE_BIT_FAST_DP3_PREPROCESSOR */ + 0x0, /* gcFEATURE_BIT_DEPTHWISE_SUPPORT_16BIT_FORMAT */ + 0x0, /* gcFEATURE_BIT_NN_SUPPORT_ALU_LUT */ + 0x0, /* gcFEATURE_BIT_NN_ENHANCED_MAX_POOLING */ + 0x0, /* gcFEATURE_BIT_NN_TRANSPOSE_PHASE2 */ + 0x0, /* gcFEATURE_BIT_TPLITE_SUPPORT_TP_DATA_TRANSPOSE */ + 0x0, /* gcFEATURE_BIT_NN_SUPPORT_CONV_1D */ + 0x0, /* gcFEATURE_BIT_USE_VIPSRAM_FOR_KERNEL_STREAMING */ + 0x0, /* gcFEATURE_BIT_VIP_DEC400 */ + 0x0, /* gcFEATURE_BIT_NN_PER3DTILE_BUBBLE_FIX */ + 0x1, /* gcFEATURE_BIT_NN_CACHELINE_MODE_PERF_FIX */ + 0x1, /* gcFEATURE_BIT_NN_CONV1x1_PERF_FIX */ + 0x1, /* gcFEATURE_BIT_TP_REORDER_FIX */ + 0x1, /* gcFEATURE_BIT_NN_CONVOUT_FIFO_DEPTH_FIX */ 0x1, /* gcFEATURE_BIT_NN_ZXDP3_KERNEL_READ_CONFLICT_FIX */ 0x1, /* gcFEATURE_BIT_NN_ZDP3_NO_COMPRESS_FIX */ 0x1, /* gcFEATURE_BIT_NN_ASYNC_COPY_PERF_FIX */ - 0x1, /* gcFEATURE_BIT_OCB_COUNTER */ - 0x0, /* gcFEATURE_BIT_NN_XYDP0 */ - 0x0, /* gcFEATURE_BIT_ZRL_7BIT */ + 0x1, /* gcFEATURE_BIT_HI_REORDER_FIX */ + 0x1, /* gcFEATURE_BIT_INCORRECT_WR_REQ_TO_USC_BETWEEN_REORDER_AND_NORMAL_LAYER_FIX */ + 0x0, /* gcFEATURE_BIT_TP_REORDER_LAYER_SUSPEND_FIX */ 0x1, /* gcFEATURE_BIT_NN_ASYNC_COPY_MERGE_FIX */ - 0x1, /* gcFEATURE_BIT_NN_SMALLBATCH_PHASE1 */ - 0x1, /* gcFEATURE_BIT_TP_SMALLBATCH_PHASE1 */ - 0x0, /* gcFEATURE_BIT_SCALER */ - 0x0, /* gcFEATURE_BIT_SCALER_4K */ + 0x1, /* gcFEATURE_BIT_USC_INVALIDATE_CACHE_LINE_FIX */ 0x0, /* gcFEATURE_BIT_NN_REQ_SLOWARBITRATION_FIX */ - 0x0, /* gcFEATURE_BIT_IMAGE_PARTIAL_CACHE */ + 0x0, /* gcFEATURE_BIT_IMAGE_PARTIAL_CACHE_FIX */ 0x0, /* gcFEATURE_BIT_FULLCACHE_KERNELHEAD_FIX */ - 0x1, /* gcFEATURE_BIT_NN_SINGLEPORT_ACCUMBUFFER */ - 0x0, /* gcFEATURE_BIT_NN_SMALLBATCH */ - 0x0, /* gcFEATURE_BIT_TP_SMALLBATCH */ - 0x1, /* gcFEATURE_BIT_ZRL_8BIT */ - 0x0, /* gcFEATURE_BIT_NN_DEPTHWISE_SUPPORT */ - 0x0, /* gcFEATURE_BIT_NN_WRITE_WITHOUT_USC */ 0x0, /* gcFEATURE_BIT_NN_ZDP_INIMAGE_SIZE_FIX */ - 0x1, /* gcFEATURE_BIT_HI_REORDER_FIX */ - 0x1, /* gcFEATURE_BIT_INCORRECT_WR_REQ_TO_USC_BETWEEN_REORDER_AND_NORMAL_LAYER_FIX */ - 0x0, /* gcFEATURE_BIT_TP_COEF_COMPRESSION_ENHANCEMENT */ - 0x0, /* gcFEATURE_BIT_VIP_DEC400 */ - 0x0, /* gcFEATURE_BIT_IMAGE_NOT_PACKED_IN_SRAM_FIX */ 0x0, /* gcFEATURE_BIT_IDLE_BEFORE_FLUSH_COMPLETE_FIX */ 0x1, /* gcFEATURE_BIT_NO_FLUSH_USC_FIX */ + 0x1, /* gcFEATURE_BIT_SMALL_BATCH_FLOPS_RESET_FIX */ + 0x0, /* gcFEATURE_BIT_SMALL_BATCH_DISBLE_FIX */ + 0x1, /* gcFEATURE_BIT_OUTPUT_CONVERT_UINT8_INT8_TO_UINT16_INT16_FIX */ + 0x0, /* gcFEATURE_BIT_IMAGE_NOT_PACKED_IN_SRAM_FIX */ 0x1, /* gcFEATURE_BIT_COEF_DELTA_CORD_OVERFLOW_ZRL_8BIT_FIX */ - 0x0, /* gcFEATURE_BIT_XY_OFFSET_LIMITATION_FIX */ - 0x1, /* gcFEATURE_BIT_USC_INVALIDATE_CACHE_LINE_FIX */ 0x0, /* gcFEATURE_BIT_LOW_EFFICIENCY_OF_ID_WRITE_IMGBUF_FIX */ - 0x1, /* gcFEATURE_BIT_KERNEL_PER_CORE_LESS_THAN_THIRD_COEF_BUFF_DEPTH_FIX */ + 0x1, /* gcFEATURE_BIT_KERNEL_VIP_SRAM_READ_BW_LIMITATION_FIX */ 0x0, /* gcFEATURE_BIT_USC_BOTTLENECK_FIX */ + 0x1, /* gcFEATURE_BIT_KERNEL_PER_CORE_LESS_THAN_THIRD_COEF_BUFF_DEPTH_FIX */ 0x0, /* gcFEATURE_BIT_KERNEL_SIZE_WASTE_IN_PARTIAL_MODE_FIX */ - 0x0, /* gcFEATURE_BIT_FULLCACHE_KERNEL_INTERLEAVE_FIX */ - 0x0, /* gcFEATURE_BIT_TP_REORDER_LAYER_SUSPEND_FIX */ - 0x1, /* gcFEATURE_BIT_KERNEL_VIP_SRAM_READ_BW_LIMITATION_FIX */ + 0x0, /* gcFEATURE_BIT_NN_COMMAND_KERNEL_REQUEST_CONFICT_FIX */ + 0x0, /* gcFEATURE_BIT_TP_REORDER_INTILE_X_SIZE_512_FIX */ 0x1, /* gcFEATURE_BIT_IMG_POP_PIPELINE_PAUSE_FIX */ + 0x0, /* gcFEATURE_BIT_FULLCACHE_KERNEL_INTERLEAVE_FIX */ + 0x0, /* gcFEATURE_BIT_V8_SINGLE_PORT_ACCUMULATION_BUFFER_RW_CONFICT_ZERO_SKIP_PERF_FIX */ + 0x0, /* gcFEATURE_BIT_V8_ACCUMLATION_READ_OUT_HAS_BUBBLES_PERF_FIX */ + 0x1, /* gcFEATURE_BIT_DEPTHWISE_NEIGHBOR_IMG_DATA_TRANSFER_NOT_EFFICIENT_FIX */ 0x1, /* gcFEATURE_BIT_DR_JD_DIFF_CONDITION_FOR_CACHELINE_MODE_PRE_FIX */ - 0x1, /* gcFEATURE_BIT_OUTIMAGE_X_BITWIDTH_LIMIT_FOR_NN_TRANSPOSE_FIX */ - 0x1, /* gcFEATURE_BIT_SMALL_BATCH_FLOPS_RESET_FIX */ - 0x0, /* gcFEATURE_BIT_SMALL_BATCH_DISBLE_FIX */ - 0x1, /* gcFEATURE_BIT_NEGATIVE_POST_SHIFT_FIX */ - 0x0, /* gcFEATURE_BIT_NN_COMMAND_KERNEL_REQUEST_CONFICT_FIX */ - 0x1, /* gcFEATURE_BIT_OCB_REMAP_PHYSICAL_ADDRESS */ - 0x0, /* gcFEATURE_BIT_NN_NO_Z_LOCATION_OFFSET */ - 0x0, /* gcFEATURE_BIT_NN_LEAKY_RELU */ - 0x0, /* gcFEATURE_BIT_NN_PRELU */ - 0x0, /* gcFEATURE_BIT_NN_PER_CHANNEL_QUANT */ - 0x0, /* gcFEATURE_BIT_NN_PER_CHANNEL_QUANT_ASYM */ - 0x0, /* gcFEATURE_BIT_NN_NATIVE_STRIDE_TWO */ - 0x0, /* gcFEATURE_BIT_NN_TENSOR_ADD */ - 0x0, /* gcFEATURE_BIT_NN_FLOAT_POST_MULT */ - 0x0, /* gcFEATURE_BIT_NN_SLICE_PADDING_TO_64BYTE_ALIGN */ - 0x0, /* gcFEATURE_BIT_NN_DW_1x1_CONV_MERGE */ - 0x0, /* gcFEATURE_BIT_NN_SLOW_OUTPUT */ - 0x1, /* gcFEATURE_BIT_NO_NARROW_POST_PROCESS_PIPE */ - 0x0, /* gcFEATURE_BIT_TP_NN_PROBE */ - 0x0, /* gcFEATURE_BIT_TP_23BITS_POST_MULTIPLIER */ - 0x0, /* gcFEATURE_BIT_NN_TRANSPOSE */ + 0x0, /* gcFEATURE_BIT_TP_ACCESS_VIPSRAM_OT_IS_ONE_FIX */ 0x0, /* gcFEATURE_BIT_EVIS2_FLOP_RESET_FIX */ + 0x1, /* gcFEATURE_BIT_OUTIMAGE_X_BITWIDTH_LIMIT_FOR_NN_TRANSPOSE_FIX */ 0x0, /* gcFEATURE_BIT_USC_ASYNC_CP_RTN_FLOP_RESET_FIX */ - 0x0, /* gcFEATURE_BIT_DDR_BURST_LEN_256B */ + 0x1, /* gcFEATURE_BIT_IMG_ADDR_NOT_WRAP_IF_OVER_OCB_ADDR_FIX */ + 0x1, /* gcFEATURE_BIT_NEGATIVE_POST_SHIFT_FIX */ + 0x0, /* gcFEATURE_BIT_INIMAGE_2DTILE_NOT_LESS_160PIXEL_FIX */ 0x0, /* gcFEATURE_BIT_IMG_CAHCE_MODE_MUST_0_IN_IMG_DIRECT_MODE_FIX */ - 0x0, /* gcFEATURE_BIT_USE_SINGLE_PORT_VIPSRAM */ - 0x0, /* gcFEATURE_BIT_NN_ASYMMETRIC_INT8 */ - 0x1, /* gcFEATURE_BIT_DEPTHWISE_NEIGHBOR_IMG_DATA_TRANSFER_NOT_EFFICIENT_FIX */ - 0x0, /* gcFEATURE_BIT_PRELU_LEAKLY_RELU_CLAMP */ - 0x0, /* gcFEATURE_BIT_TP_FLOAT32_IO */ - 0x0, /* gcFEATURE_BIT_NN_FLOAT32_IO */ - 0x0, /* gcFEATURE_BIT_NN_SMALL_BATCH_PHASE2 */ - 0x0, /* gcFEATURE_BIT_TILE_ACCESS_CAPABILITY */ - 0x0, /* gcFEATURE_BIT_FAST_DP3_PREPROCESSOR */ - 0x0, /* gcFEATURE_BIT_NN_COMPRESSION_BYPASSS */ - 0x0, /* gcFEATURE_BIT_BFLOAT_KERNEL_COMPRESSION_ZERO_SKIP_FIX */ - 0x0, /* gcFEATURE_BIT_TP_3_USC */ - 0x0, /* gcFEATURE_BIT_TP_KERNEL_1BYTE_ALGIN */ - 0x0, /* gcFEATURE_BIT_TPLITE_BFLOAT16 */ - 0x0, /* gcFEATURE_BIT_PREPROCESS_IMG_BUF_640BYTE_LIMIT */ - 0x0, /* gcFEATURE_BIT_V8_ACCUMLATION_READ_OUT_HAS_BUBBLES_PERF_FIX */ - 0x0, /* gcFEATURE_BIT_V8_SINGLE_PORT_ACCUMULATION_BUFFER_RW_CONFICT_ZERO_SKIP_PERF_FIX */ 0x0, /* gcFEATURE_BIT_BURST_COLLECT_DUMMY_DATA_WASTE_CYCLES_FIX */ 0x1, /* gcFEATURE_BIT_INIMG_NOT_64BYTE_ALIGN_CACHELINE_MODE_FIX */ - 0x0, /* gcFEATURE_BIT_TP_ACCESS_VIPSRAM_OT_IS_ONE_FIX */ - 0x1, /* gcFEATURE_BIT_VIP_HW_FINAL_RELEASE */ + 0x1, /* gcFEATURE_BIT_TP_FC_FLOAT_LAST_PIXEL_NEGATIVE_0_FIX */ + 0x1, /* gcFEATURE_BIT_NN_WASET_COEF_READ_WRITE_BANDWIDTH_128BYTE_VIPSRAM_IN_FULL_PATIAL_CACHE_MODE */ + 0x1, /* gcFEATURE_BIT_NN_IN_TILE_DATA_IS_ALL_PAD_FIX */ + 0x1, /* gcFEATURE_BIT_TP_FC_KERNEL_STREAM_MUST_LESS_THAN_OR_EQUAL_TO_64BYTE_WHEN_1BYTE_ALGINE_FIX */ + 0x0, /* gcFEATURE_BIT_NN_INTERLEVE8 */ + 0x0, /* gcFEATURE_BIT_NN_FP16_ALU */ + 0x1, /* gcFEATURE_BIT_NN_INT16_ALU */ + 0x1, /* gcFEATURE_BIT_NN_INT8_SCALE */ + 0x1, /* gcFEATURE_BIT_NN_POWER_ISOLATION */ + 0x0, /* gcFEATURE_BIT_ZRL_7BIT */ + 0x1, /* gcFEATURE_BIT_NN_SMALLBATCH_PHASE1 */ + 0x1, /* gcFEATURE_BIT_TP_SMALLBATCH_PHASE1 */ + 0x0, /* gcFEATURE_BIT_NN_SMALLBATCH */ + 0x0, /* gcFEATURE_BIT_TP_SMALLBATCH */ + 0x1, /* gcFEATURE_BIT_ZRL_8BIT */ + 0x0, /* gcFEATURE_BIT_DDR_BURST_LEN_256B */ + 0x0, /* gcFEATURE_BIT_XY_OFFSET_LIMITATION_FIX */ + 0x1, /* gcFEATURE_BIT_NN_NONZERO_MIRROR_BORDER */ + 0x0, /* gcFEATURE_BIT_IMAGE_PARTIAL_CACHE */ }, /* vippico_v3 */ { @@ -4293,13 +4692,23 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x140, /* gcFEATURE_VALUE_NumberOfConstants */ 0x1, /* gcFEATURE_VALUE_CoreCount */ 0x10, /* gcFEATURE_VALUE_LocalStorageSize */ + 0x0, /* gcFEATURE_VALUE_LocalStorageSize_1 */ + 0x0, /* gcFEATURE_VALUE_LocalStorageSize_2 */ 0x10, /* gcFEATURE_VALUE_L1CacheSize */ + 0x0, /* gcFEATURE_VALUE_L1CacheSize_1 */ + 0x0, /* gcFEATURE_VALUE_L1CacheSize_2 */ 0x200, /* gcFEATURE_VALUE_InstructionMemorySize */ 0x14, /* gcFEATURE_VALUE_ShaderPCLength */ 0x10, /* gcFEATURE_VALUE_USC_MAX_PAGES */ + 0x0, /* gcFEATURE_VALUE_USC_MAX_PAGES_1 */ + 0x0, /* gcFEATURE_VALUE_USC_MAX_PAGES_2 */ 0x1, /* gcFEATURE_VALUE_NumPixelPipes */ 0x2, /* gcFEATURE_VALUE_USC_CACHE_CONTROLLERS */ + 0x0, /* gcFEATURE_VALUE_USC_CACHE_CONTROLLERS_1 */ + 0x0, /* gcFEATURE_VALUE_USC_CACHE_CONTROLLERS_2 */ 0x2, /* gcFEATURE_VALUE_USC_BANKS */ + 0x0, /* gcFEATURE_VALUE_USC_BANKS_1 */ + 0x0, /* gcFEATURE_VALUE_USC_BANKS_2 */ 0x8, /* gcFEATURE_VALUE_Streams */ 0x10, /* gcFEATURE_VALUE_VaryingCount */ 0x400, /* gcFEATURE_VALUE_VertexOutputBufferSize */ @@ -4308,6 +4717,7 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_VALUE_NumResolvePipes */ 0x100, /* gcFEATURE_VALUE_RESULT_WINDOW_MAX_SIZE */ 0x0, /* gcFEATURE_VALUE_ClusterAliveMask */ + 0x0, /* gcFEATURE_VALUE_G2D_DEC400_MINOR */ 0x40, /* gcFEATURE_VALUE_NNMadPerCore */ 0x2, /* gcFEATURE_VALUE_NNCoreCount */ 0x2, /* gcFEATURE_VALUE_NNCoreCount_INT8 */ @@ -4332,14 +4742,26 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x40, /* gcFEATURE_VALUE_PHYSICAL_VIP_SRAM_WIDTH_IN_BYTE */ 0x20, /* gcFEATURE_VALUE_EQUIVALENT_VIP_SRAM_WIDTH_INBYTE */ 0x8, /* gcFEATURE_VALUE_TP_ZRL_BITS */ + 0x8, /* gcFEATURE_VALUE_NN_ZRL_BITS */ 0x80, /* gcFEATURE_VALUE_LATENCY_HIDING_AT_FULL_AXI_BW */ 0x10, /* gcFEATURE_VALUE_AXI_BUS_WIDTH */ 0xb, /* gcFEATURE_VALUE_NN_KERNEL_X_SIZE */ 0xb, /* gcFEATURE_VALUE_NN_KERNEL_Y_SIZE */ + 0xf, /* gcFEATURE_VALUE_NN_FC_KERNEL_Y_SIZE */ 0xfffff, /* gcFEATURE_VALUE_NN_KERNEL_Z_SIZE */ 0xf, /* gcFEATURE_VALUE_NN_X_OFFSET */ 0xf, /* gcFEATURE_VALUE_NN_Y_OFFSET */ 0x40, /* gcFEATURE_VALUE_DDR_KERNEL_BURST_SIZE */ + 0x10, /* gcFEATURE_VALUE_OUTIMAGE_X_STRIDE_BITS */ + 0x0, /* gcFEATURE_VALUE_OUTIMAGE_Y_STRIDE_BITS */ + 0x10, /* gcFEATURE_VALUE_INIMAGE_X_STRIDE_BITS */ + 0x10, /* gcFEATURE_VALUE_IMIMAGE_Y_STRIDE_BITS */ + 0xd, /* gcFEATURE_VALUE_OUTIMAGE_X_SIZE_BITS */ + 0xd, /* gcFEATURE_VALUE_OUTIMAGE_Y_SIZE_BITS */ + 0xe, /* gcFEATURE_VALUE_OUTIMAGE_SIZE_BITS */ + 0xd, /* gcFEATURE_VALUE_IMAGE_X_SIZE_BITS */ + 0xd, /* gcFEATURE_VALUE_INIMAGE_Y_SIZE_BITS */ + 0x40, /* gcFEATURE_VALUE_MAX_TILE_X_SIZE */ 0x0, /* gcFEATURE_BIT_REG_FastClear */ 0x0, /* gcFEATURE_BIT_REG_SpecialAntiAliasing */ 0x1, /* gcFEATURE_BIT_REG_Pipe3D */ @@ -4581,6 +5003,7 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x1, /* gcFEATURE_BIT_RA_HZEZ_CLOCK_CONTROL */ 0x1, /* gcFEATURE_BIT_CACHE128B256BPERLINE */ 0x1, /* gcFEATURE_BIT_V4Compression */ + 0x0, /* gcFEATURE_BIT_DE2D_MAJOR_SUPER_TILE */ 0x0, /* gcFEATURE_BIT_PE2D_MAJOR_SUPER_TILE */ 0x1, /* gcFEATURE_BIT_PE_32BPC_COLORMASK_FIX */ 0x1, /* gcFEATURE_BIT_ALPHA_BLENDING_OPT */ @@ -4713,6 +5136,7 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_BIT_TX_NO_FIXED_FILTER */ 0x0, /* gcFEATURE_BIT_SHARE_Z */ 0x0, /* gcFEATURE_BIT_DE_2D_FAST_CLEAR */ + 0x0, /* gcFEATURE_BIT_DE_TILESTATUS_ROTATION_FIX */ 0x0, /* gcFEATURE_BIT_TX_CLEAR_PENDING_FIX */ 0x0, /* gcFEATURE_BIT_NO_HI1_L2 */ 0x0, /* gcFEATURE_BIT_USC_EVICT_CTRL_FIFO_FLOP_RESET_FIX */ @@ -4723,6 +5147,13 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_BIT_SH_VX2_FLOATING_MAD_FIX */ 0x0, /* gcFEATURE_BIT_TS_FC_VULKAN_SUPPORT */ 0x0, /* gcFEATURE_BIT_MSAA_FLOAT_64BIT */ + 0x0, /* gcFEATURE_BIT_INDIRECT_COMPUTE_ZERODIM_FIX */ + 0x0, /* gcFEATURE_BIT_Q_CHANNEL_SUPPORT */ + 0x0, /* gcFEATURE_BIT_MMU_PAGE_DESCRIPTOR */ + 0x0, /* gcFEATURE_BIT_YUV_LINEAR_TO_TILE_ROTATE */ + 0x0, /* gcFEATURE_BIT_VEC2_IMULIMAD32_SUPPORT */ + 0x0, /* gcFEATURE_BIT_VEC4_IMULIMAD32_SUPPORT */ + 0x0, /* gcFEATURE_BIT_VEC2_IDIVIMOD16_SUPPORT */ 0x0, /* gcFEATURE_BIT_VG_TS_CULLING */ 0x0, /* gcFEATURE_BIT_VG_FP25 */ 0x0, /* gcFEATURE_BIT_VG_AYUV_INPUT_OUTPUT */ @@ -4749,6 +5180,20 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_BIT_DC_MMU */ 0x0, /* gcFEATURE_BIT_DC_COMPRESSION */ 0x0, /* gcFEATURE_BIT_DC_QOS */ + 0x1, /* gcFEATURE_BIT_VIP_HW_FINAL_RELEASE */ + 0x1, /* gcFEATURE_BIT_NN_SINGLEPORT_ACCUMBUFFER */ + 0x1, /* gcFEATURE_BIT_NN_STRIDE_SUPPORT */ + 0x1, /* gcFEATURE_BIT_SWTILING_PHASE1 */ + 0x1, /* gcFEATURE_BIT_SWTILING_PHASE2 */ + 0x0, /* gcFEATURE_BIT_TP_SIMPLE_INT16 */ + 0x1, /* gcFEATURE_BIT_TP_REAL_INT16 */ + 0x1, /* gcFEATURE_BIT_TP_ROI_POOLING */ + 0x1, /* gcFEATURE_BIT_TP_MAX_POOLING_STRIDE1 */ + 0x1, /* gcFEATURE_BIT_TP_LRN */ + 0x1, /* gcFEATURE_BIT_TP_REORDER */ + 0x1, /* gcFEATURE_BIT_TF_QUANTIZATION */ + 0x0, /* gcFEATURE_BIT_NN_NONZERO_BORDER */ + 0x0, /* gcFEATURE_BIT_NN_MIRROR_BORDER */ 0x0, /* gcFEATURE_BIT_AI_GPU */ 0x0, /* gcFEATURE_BIT_EVIS_NO_ABSDIFF */ 0x0, /* gcFEATURE_BIT_EVIS_NO_BITREPLACE */ @@ -4761,128 +5206,139 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_BIT_EVIS_LERP_7OUTPUT */ 0x0, /* gcFEATURE_BIT_EVIS_ACCSQ_8OUTPUT */ 0x1, /* gcFEATURE_BIT_EVIS_VX2 */ - 0x1, /* gcFEATURE_BIT_NN_FLOAT */ 0x1, /* gcFEATURE_BIT_TP_ENGINE */ 0x1, /* gcFEATURE_BIT_VIP_V7 */ - 0x0, /* gcFEATURE_BIT_MCFE */ - 0x0, /* gcFEATURE_BIT_NN_INTERLEVE8 */ - 0x1, /* gcFEATURE_BIT_TP_REORDER */ - 0x1, /* gcFEATURE_BIT_TP_LRN */ - 0x1, /* gcFEATURE_BIT_TP_MAX_POOLING_STRIDE1 */ - 0x0, /* gcFEATURE_BIT_NN_FP16_ALU */ - 0x0, /* gcFEATURE_BIT_NN_INT16_ALU */ - 0x1, /* gcFEATURE_BIT_TP_ROI_POOLING */ - 0x1, /* gcFEATURE_BIT_NN_ZDP3 */ + 0x0, /* gcFEATURE_BIT_TP_TENSOR_ADD_MUL */ + 0x0, /* gcFEATURE_BIT_NN_DEPTHWISE_INT16XINT8 */ + 0x0, /* gcFEATURE_BIT_TP_SOFTMAX */ + 0x0, /* gcFEATURE_BIT_NN_23BITS_POST_MULTIPLIER_VIP_V7 */ + 0x0, /* gcFEATURE_BIT_TP_23BITS_POST_MULTIPLIER_VIP_V7 */ + 0x0, /* gcFEATURE_BIT_HYBRID_MODE_VIP_V7 */ 0x0, /* gcFEATURE_BIT_NN_ZDP6 */ 0x0, /* gcFEATURE_BIT_NN_XYDP9 */ - 0x1, /* gcFEATURE_BIT_NN_INT8_SCALE */ - 0x1, /* gcFEATURE_BIT_NN_POWER_ISOLATION */ - 0x1, /* gcFEATURE_BIT_SWTILING_PHASE1 */ - 0x1, /* gcFEATURE_BIT_TF_QUANTIZATION */ - 0x0, /* gcFEATURE_BIT_TP_SIMPLE_INT16 */ - 0x1, /* gcFEATURE_BIT_TP_REAL_INT16 */ - 0x0, /* gcFEATURE_BIT_TP_BFLOAT16 */ 0x1, /* gcFEATURE_BIT_NN_FIRST_PIXEL_POOLING */ - 0x1, /* gcFEATURE_BIT_SWTILING_PHASE2 */ - 0x1, /* gcFEATURE_BIT_NN_STRIDE_SUPPORT */ + 0x1, /* gcFEATURE_BIT_NN_ZDP3 */ 0x1, /* gcFEATURE_BIT_NN_XYDP6 */ - 0x1, /* gcFEATURE_BIT_TP_REORDER_FIX */ - 0x1, /* gcFEATURE_BIT_NN_CONV1x1_PERF_FIX */ - 0x0, /* gcFEATURE_BIT_NN_CACHELINE_MODE_PERF_FIX */ - 0x0, /* gcFEATURE_BIT_NN_PER3DTILE_BUBBLE_FIX */ - 0x1, /* gcFEATURE_BIT_NN_CONVOUT_FIFO_DEPTH_FIX */ 0x1, /* gcFEATURE_BIT_SWTILING_PHASE3 */ + 0x0, /* gcFEATURE_BIT_MCFE */ 0x0, /* gcFEATURE_BIT_USC_STAY_LRU */ - 0x0, /* gcFEATURE_BIT_NN_NONZERO_MIRROR_BORDER */ + 0x1, /* gcFEATURE_BIT_COEF_COMPRESSION_ENHANCEMENT */ + 0x0, /* gcFEATURE_BIT_TP_COEF_COMPRESSION_ENHANCEMENT */ 0x0, /* gcFEATURE_BIT_NN_COEF_DECOMPRESS_PERF2X */ + 0x1, /* gcFEATURE_BIT_OCB_COUNTER */ + 0x0, /* gcFEATURE_BIT_SCALER */ + 0x0, /* gcFEATURE_BIT_SCALER_4K */ 0x0, /* gcFEATURE_BIT_INPUT_4BIT */ - 0x1, /* gcFEATURE_BIT_COEF_COMPRESSION_ENHANCEMENT */ + 0x0, /* gcFEATURE_BIT_NN_NO_Z_LOCATION_OFFSET */ + 0x1, /* gcFEATURE_BIT_OCB_REMAP_PHYSICAL_ADDRESS */ + 0x0, /* gcFEATURE_BIT_NN_SLOW_OUTPUT */ + 0x1, /* gcFEATURE_BIT_NO_NARROW_POST_PROCESS_PIPE */ + 0x0, /* gcFEATURE_BIT_TP_NN_PROBE */ + 0x0, /* gcFEATURE_BIT_NN_DEPTHWISE_SUPPORT */ + 0x0, /* gcFEATURE_BIT_NN_XYDP0 */ + 0x0, /* gcFEATURE_BIT_NN_WRITE_WITHOUT_USC */ + 0x0, /* gcFEATURE_BIT_NN_HW_LIMITATION_NATIVE_KER_1x2_2x1 */ + 0x0, /* gcFEATURE_BIT_NN_SLICE_PADDING_TO_64BYTE_ALIGN */ + 0x0, /* gcFEATURE_BIT_NN_DW_1x1_CONV_MERGE */ + 0x0, /* gcFEATURE_BIT_TP_BFLOAT16 */ + 0x0, /* gcFEATURE_BIT_TP_23BITS_POST_MULTIPLIER */ + 0x0, /* gcFEATURE_BIT_NN_TRANSPOSE */ + 0x0, /* gcFEATURE_BIT_USE_SINGLE_PORT_VIPSRAM */ + 0x0, /* gcFEATURE_BIT_NN_LEAKY_RELU */ + 0x0, /* gcFEATURE_BIT_NN_PRELU */ + 0x0, /* gcFEATURE_BIT_NN_PER_CHANNEL_QUANT */ + 0x0, /* gcFEATURE_BIT_NN_PER_CHANNEL_QUANT_ASYM */ + 0x0, /* gcFEATURE_BIT_NN_ASYMMETRIC_INT8 */ + 0x0, /* gcFEATURE_BIT_NN_FLOAT_POST_MULT */ + 0x0, /* gcFEATURE_BIT_PRELU_LEAKLY_RELU_CLAMP */ + 0x0, /* gcFEATURE_BIT_TPLITE_BFLOAT16 */ + 0x0, /* gcFEATURE_BIT_PREPROCESS_IMG_BUF_640BYTE_LIMIT */ + 0x0, /* gcFEATURE_BIT_TP_KERNEL_1BYTE_ALGIN */ + 0x0, /* gcFEATURE_BIT_BFLOAT_COEF_COMPRESSION_ZERO_COEFBIT14_INVERSE */ + 0x0, /* gcFEATURE_BIT_NN_COMPRESSION_BYPASSS */ + 0x0, /* gcFEATURE_BIT_TP_3_USC */ + 0x0, /* gcFEATURE_BIT_BFP_COEF_AUTO_PAD_INCOMPLETE_ZERO_IN_KZ_PLANE */ + 0x0, /* gcFEATURE_BIT_NN_NATIVE_STRIDE_TWO */ + 0x0, /* gcFEATURE_BIT_NN_TENSOR_ADD */ + 0x0, /* gcFEATURE_BIT_NN_FLOAT32_IO */ + 0x0, /* gcFEATURE_BIT_TP_FLOAT32_IO */ + 0x0, /* gcFEATURE_BIT_NN_SMALL_BATCH_PHASE2 */ + 0x0, /* gcFEATURE_BIT_TILE_ACCESS_CAPABILITY */ + 0x0, /* gcFEATURE_BIT_FAST_DP3_PREPROCESSOR */ + 0x0, /* gcFEATURE_BIT_DEPTHWISE_SUPPORT_16BIT_FORMAT */ + 0x0, /* gcFEATURE_BIT_NN_SUPPORT_ALU_LUT */ + 0x0, /* gcFEATURE_BIT_NN_ENHANCED_MAX_POOLING */ + 0x0, /* gcFEATURE_BIT_NN_TRANSPOSE_PHASE2 */ + 0x0, /* gcFEATURE_BIT_TPLITE_SUPPORT_TP_DATA_TRANSPOSE */ + 0x0, /* gcFEATURE_BIT_NN_SUPPORT_CONV_1D */ + 0x0, /* gcFEATURE_BIT_USE_VIPSRAM_FOR_KERNEL_STREAMING */ + 0x0, /* gcFEATURE_BIT_VIP_DEC400 */ + 0x0, /* gcFEATURE_BIT_NN_PER3DTILE_BUBBLE_FIX */ + 0x0, /* gcFEATURE_BIT_NN_CACHELINE_MODE_PERF_FIX */ + 0x1, /* gcFEATURE_BIT_NN_CONV1x1_PERF_FIX */ + 0x1, /* gcFEATURE_BIT_TP_REORDER_FIX */ + 0x1, /* gcFEATURE_BIT_NN_CONVOUT_FIFO_DEPTH_FIX */ 0x0, /* gcFEATURE_BIT_NN_ZXDP3_KERNEL_READ_CONFLICT_FIX */ 0x1, /* gcFEATURE_BIT_NN_ZDP3_NO_COMPRESS_FIX */ 0x1, /* gcFEATURE_BIT_NN_ASYNC_COPY_PERF_FIX */ - 0x1, /* gcFEATURE_BIT_OCB_COUNTER */ - 0x0, /* gcFEATURE_BIT_NN_XYDP0 */ - 0x1, /* gcFEATURE_BIT_ZRL_7BIT */ + 0x1, /* gcFEATURE_BIT_HI_REORDER_FIX */ + 0x1, /* gcFEATURE_BIT_INCORRECT_WR_REQ_TO_USC_BETWEEN_REORDER_AND_NORMAL_LAYER_FIX */ + 0x0, /* gcFEATURE_BIT_TP_REORDER_LAYER_SUSPEND_FIX */ 0x1, /* gcFEATURE_BIT_NN_ASYNC_COPY_MERGE_FIX */ - 0x1, /* gcFEATURE_BIT_NN_SMALLBATCH_PHASE1 */ - 0x1, /* gcFEATURE_BIT_TP_SMALLBATCH_PHASE1 */ - 0x0, /* gcFEATURE_BIT_SCALER */ - 0x0, /* gcFEATURE_BIT_SCALER_4K */ + 0x1, /* gcFEATURE_BIT_USC_INVALIDATE_CACHE_LINE_FIX */ 0x0, /* gcFEATURE_BIT_NN_REQ_SLOWARBITRATION_FIX */ - 0x0, /* gcFEATURE_BIT_IMAGE_PARTIAL_CACHE */ + 0x0, /* gcFEATURE_BIT_IMAGE_PARTIAL_CACHE_FIX */ 0x0, /* gcFEATURE_BIT_FULLCACHE_KERNELHEAD_FIX */ - 0x1, /* gcFEATURE_BIT_NN_SINGLEPORT_ACCUMBUFFER */ - 0x0, /* gcFEATURE_BIT_NN_SMALLBATCH */ - 0x0, /* gcFEATURE_BIT_TP_SMALLBATCH */ - 0x1, /* gcFEATURE_BIT_ZRL_8BIT */ - 0x0, /* gcFEATURE_BIT_NN_DEPTHWISE_SUPPORT */ - 0x0, /* gcFEATURE_BIT_NN_WRITE_WITHOUT_USC */ 0x0, /* gcFEATURE_BIT_NN_ZDP_INIMAGE_SIZE_FIX */ - 0x1, /* gcFEATURE_BIT_HI_REORDER_FIX */ - 0x1, /* gcFEATURE_BIT_INCORRECT_WR_REQ_TO_USC_BETWEEN_REORDER_AND_NORMAL_LAYER_FIX */ - 0x0, /* gcFEATURE_BIT_TP_COEF_COMPRESSION_ENHANCEMENT */ - 0x0, /* gcFEATURE_BIT_VIP_DEC400 */ - 0x0, /* gcFEATURE_BIT_IMAGE_NOT_PACKED_IN_SRAM_FIX */ 0x0, /* gcFEATURE_BIT_IDLE_BEFORE_FLUSH_COMPLETE_FIX */ 0x1, /* gcFEATURE_BIT_NO_FLUSH_USC_FIX */ + 0x1, /* gcFEATURE_BIT_SMALL_BATCH_FLOPS_RESET_FIX */ + 0x0, /* gcFEATURE_BIT_SMALL_BATCH_DISBLE_FIX */ + 0x1, /* gcFEATURE_BIT_OUTPUT_CONVERT_UINT8_INT8_TO_UINT16_INT16_FIX */ + 0x0, /* gcFEATURE_BIT_IMAGE_NOT_PACKED_IN_SRAM_FIX */ 0x0, /* gcFEATURE_BIT_COEF_DELTA_CORD_OVERFLOW_ZRL_8BIT_FIX */ - 0x0, /* gcFEATURE_BIT_XY_OFFSET_LIMITATION_FIX */ - 0x1, /* gcFEATURE_BIT_USC_INVALIDATE_CACHE_LINE_FIX */ 0x0, /* gcFEATURE_BIT_LOW_EFFICIENCY_OF_ID_WRITE_IMGBUF_FIX */ - 0x1, /* gcFEATURE_BIT_KERNEL_PER_CORE_LESS_THAN_THIRD_COEF_BUFF_DEPTH_FIX */ + 0x1, /* gcFEATURE_BIT_KERNEL_VIP_SRAM_READ_BW_LIMITATION_FIX */ 0x0, /* gcFEATURE_BIT_USC_BOTTLENECK_FIX */ + 0x1, /* gcFEATURE_BIT_KERNEL_PER_CORE_LESS_THAN_THIRD_COEF_BUFF_DEPTH_FIX */ 0x0, /* gcFEATURE_BIT_KERNEL_SIZE_WASTE_IN_PARTIAL_MODE_FIX */ - 0x0, /* gcFEATURE_BIT_FULLCACHE_KERNEL_INTERLEAVE_FIX */ - 0x0, /* gcFEATURE_BIT_TP_REORDER_LAYER_SUSPEND_FIX */ - 0x1, /* gcFEATURE_BIT_KERNEL_VIP_SRAM_READ_BW_LIMITATION_FIX */ + 0x0, /* gcFEATURE_BIT_NN_COMMAND_KERNEL_REQUEST_CONFICT_FIX */ + 0x0, /* gcFEATURE_BIT_TP_REORDER_INTILE_X_SIZE_512_FIX */ 0x1, /* gcFEATURE_BIT_IMG_POP_PIPELINE_PAUSE_FIX */ + 0x0, /* gcFEATURE_BIT_FULLCACHE_KERNEL_INTERLEAVE_FIX */ + 0x0, /* gcFEATURE_BIT_V8_SINGLE_PORT_ACCUMULATION_BUFFER_RW_CONFICT_ZERO_SKIP_PERF_FIX */ + 0x0, /* gcFEATURE_BIT_V8_ACCUMLATION_READ_OUT_HAS_BUBBLES_PERF_FIX */ + 0x1, /* gcFEATURE_BIT_DEPTHWISE_NEIGHBOR_IMG_DATA_TRANSFER_NOT_EFFICIENT_FIX */ 0x1, /* gcFEATURE_BIT_DR_JD_DIFF_CONDITION_FOR_CACHELINE_MODE_PRE_FIX */ - 0x1, /* gcFEATURE_BIT_OUTIMAGE_X_BITWIDTH_LIMIT_FOR_NN_TRANSPOSE_FIX */ - 0x1, /* gcFEATURE_BIT_SMALL_BATCH_FLOPS_RESET_FIX */ - 0x0, /* gcFEATURE_BIT_SMALL_BATCH_DISBLE_FIX */ - 0x1, /* gcFEATURE_BIT_NEGATIVE_POST_SHIFT_FIX */ - 0x0, /* gcFEATURE_BIT_NN_COMMAND_KERNEL_REQUEST_CONFICT_FIX */ - 0x1, /* gcFEATURE_BIT_OCB_REMAP_PHYSICAL_ADDRESS */ - 0x0, /* gcFEATURE_BIT_NN_NO_Z_LOCATION_OFFSET */ - 0x0, /* gcFEATURE_BIT_NN_LEAKY_RELU */ - 0x0, /* gcFEATURE_BIT_NN_PRELU */ - 0x0, /* gcFEATURE_BIT_NN_PER_CHANNEL_QUANT */ - 0x0, /* gcFEATURE_BIT_NN_PER_CHANNEL_QUANT_ASYM */ - 0x0, /* gcFEATURE_BIT_NN_NATIVE_STRIDE_TWO */ - 0x0, /* gcFEATURE_BIT_NN_TENSOR_ADD */ - 0x0, /* gcFEATURE_BIT_NN_FLOAT_POST_MULT */ - 0x0, /* gcFEATURE_BIT_NN_SLICE_PADDING_TO_64BYTE_ALIGN */ - 0x0, /* gcFEATURE_BIT_NN_DW_1x1_CONV_MERGE */ - 0x0, /* gcFEATURE_BIT_NN_SLOW_OUTPUT */ - 0x1, /* gcFEATURE_BIT_NO_NARROW_POST_PROCESS_PIPE */ - 0x0, /* gcFEATURE_BIT_TP_NN_PROBE */ - 0x0, /* gcFEATURE_BIT_TP_23BITS_POST_MULTIPLIER */ - 0x0, /* gcFEATURE_BIT_NN_TRANSPOSE */ + 0x0, /* gcFEATURE_BIT_TP_ACCESS_VIPSRAM_OT_IS_ONE_FIX */ 0x0, /* gcFEATURE_BIT_EVIS2_FLOP_RESET_FIX */ + 0x1, /* gcFEATURE_BIT_OUTIMAGE_X_BITWIDTH_LIMIT_FOR_NN_TRANSPOSE_FIX */ 0x0, /* gcFEATURE_BIT_USC_ASYNC_CP_RTN_FLOP_RESET_FIX */ - 0x0, /* gcFEATURE_BIT_DDR_BURST_LEN_256B */ + 0x1, /* gcFEATURE_BIT_IMG_ADDR_NOT_WRAP_IF_OVER_OCB_ADDR_FIX */ + 0x1, /* gcFEATURE_BIT_NEGATIVE_POST_SHIFT_FIX */ + 0x0, /* gcFEATURE_BIT_INIMAGE_2DTILE_NOT_LESS_160PIXEL_FIX */ 0x0, /* gcFEATURE_BIT_IMG_CAHCE_MODE_MUST_0_IN_IMG_DIRECT_MODE_FIX */ - 0x0, /* gcFEATURE_BIT_USE_SINGLE_PORT_VIPSRAM */ - 0x0, /* gcFEATURE_BIT_NN_ASYMMETRIC_INT8 */ - 0x1, /* gcFEATURE_BIT_DEPTHWISE_NEIGHBOR_IMG_DATA_TRANSFER_NOT_EFFICIENT_FIX */ - 0x0, /* gcFEATURE_BIT_PRELU_LEAKLY_RELU_CLAMP */ - 0x0, /* gcFEATURE_BIT_TP_FLOAT32_IO */ - 0x0, /* gcFEATURE_BIT_NN_FLOAT32_IO */ - 0x0, /* gcFEATURE_BIT_NN_SMALL_BATCH_PHASE2 */ - 0x0, /* gcFEATURE_BIT_TILE_ACCESS_CAPABILITY */ - 0x0, /* gcFEATURE_BIT_FAST_DP3_PREPROCESSOR */ - 0x0, /* gcFEATURE_BIT_NN_COMPRESSION_BYPASSS */ - 0x0, /* gcFEATURE_BIT_BFLOAT_KERNEL_COMPRESSION_ZERO_SKIP_FIX */ - 0x0, /* gcFEATURE_BIT_TP_3_USC */ - 0x0, /* gcFEATURE_BIT_TP_KERNEL_1BYTE_ALGIN */ - 0x0, /* gcFEATURE_BIT_TPLITE_BFLOAT16 */ - 0x0, /* gcFEATURE_BIT_PREPROCESS_IMG_BUF_640BYTE_LIMIT */ - 0x0, /* gcFEATURE_BIT_V8_ACCUMLATION_READ_OUT_HAS_BUBBLES_PERF_FIX */ - 0x0, /* gcFEATURE_BIT_V8_SINGLE_PORT_ACCUMULATION_BUFFER_RW_CONFICT_ZERO_SKIP_PERF_FIX */ 0x0, /* gcFEATURE_BIT_BURST_COLLECT_DUMMY_DATA_WASTE_CYCLES_FIX */ 0x1, /* gcFEATURE_BIT_INIMG_NOT_64BYTE_ALIGN_CACHELINE_MODE_FIX */ - 0x0, /* gcFEATURE_BIT_TP_ACCESS_VIPSRAM_OT_IS_ONE_FIX */ - 0x1, /* gcFEATURE_BIT_VIP_HW_FINAL_RELEASE */ + 0x1, /* gcFEATURE_BIT_TP_FC_FLOAT_LAST_PIXEL_NEGATIVE_0_FIX */ + 0x1, /* gcFEATURE_BIT_NN_WASET_COEF_READ_WRITE_BANDWIDTH_128BYTE_VIPSRAM_IN_FULL_PATIAL_CACHE_MODE */ + 0x1, /* gcFEATURE_BIT_NN_IN_TILE_DATA_IS_ALL_PAD_FIX */ + 0x1, /* gcFEATURE_BIT_TP_FC_KERNEL_STREAM_MUST_LESS_THAN_OR_EQUAL_TO_64BYTE_WHEN_1BYTE_ALGINE_FIX */ + 0x0, /* gcFEATURE_BIT_NN_INTERLEVE8 */ + 0x0, /* gcFEATURE_BIT_NN_FP16_ALU */ + 0x0, /* gcFEATURE_BIT_NN_INT16_ALU */ + 0x1, /* gcFEATURE_BIT_NN_INT8_SCALE */ + 0x1, /* gcFEATURE_BIT_NN_POWER_ISOLATION */ + 0x1, /* gcFEATURE_BIT_ZRL_7BIT */ + 0x1, /* gcFEATURE_BIT_NN_SMALLBATCH_PHASE1 */ + 0x1, /* gcFEATURE_BIT_TP_SMALLBATCH_PHASE1 */ + 0x0, /* gcFEATURE_BIT_NN_SMALLBATCH */ + 0x0, /* gcFEATURE_BIT_TP_SMALLBATCH */ + 0x1, /* gcFEATURE_BIT_ZRL_8BIT */ + 0x0, /* gcFEATURE_BIT_DDR_BURST_LEN_256B */ + 0x0, /* gcFEATURE_BIT_XY_OFFSET_LIMITATION_FIX */ + 0x0, /* gcFEATURE_BIT_NN_NONZERO_MIRROR_BORDER */ + 0x0, /* gcFEATURE_BIT_IMAGE_PARTIAL_CACHE */ }, }; @@ -4933,5 +5389,3 @@ gcQueryFeatureDB( return gcvNULL; } #endif /* _gc_feature_database_h_ */ - - diff --git a/drivers/amlogic/npu/inc/gc_hal.h b/drivers/amlogic/npu/inc/gc_hal.h index a510def..8fa2547 100644 --- a/drivers/amlogic/npu/inc/gc_hal.h +++ b/drivers/amlogic/npu/inc/gc_hal.h @@ -14,11 +14,11 @@ #ifndef __gc_hal_h_ #define __gc_hal_h_ -#include "shared/gc_hal_types.h" +#include "gc_hal_types.h" #include "gc_hal_enum.h" #include "gc_hal_base.h" #include "gc_hal_profiler.h" -#include "shared/gc_hal_driver.h" +#include "gc_hal_driver.h" #if gcdENABLE_3D #include "gc_hal_statistics.h" #endif @@ -371,6 +371,7 @@ gckOS_RequestReservedMemory( gctSIZE_T Size, const char * Name, gctBOOL Requested, + gctBOOL CpuAccessible, gctPOINTER * MemoryHandle ); @@ -380,6 +381,20 @@ gckOS_ReleaseReservedMemory( gctPOINTER MemoryHandle ); +/* Reserved memory sub area */ +gceSTATUS +gckOS_RequestReservedMemoryArea( + IN gctPOINTER MemoryHandle, + IN gctSIZE_T Offset, + IN gctSIZE_T Size, + OUT gctPOINTER * MemoryAreaHandle + ); + +void +gckOS_ReleaseReservedMemoryArea( + gctPOINTER MemoryAreaHandle + ); + /* Get the number fo bytes per page. */ gceSTATUS gckOS_GetPageSize( @@ -1373,6 +1388,15 @@ gckOS_ReleaseSemaphore( IN gctPOINTER Semaphore ); +#if gcdENABLE_SW_PREEMPTION +/* Release a semahore. */ +gceSTATUS +gckOS_ReleaseSemaphoreEx( + IN gckOS Os, + IN gctPOINTER Semaphore + ); +#endif + /******************************************************************************* ** Timer API. */ @@ -1459,6 +1483,8 @@ gckHEAP_ProfileEnd( typedef struct _gckVIDMEM * gckVIDMEM; typedef struct _gckKERNEL * gckKERNEL; +typedef struct _gckCOMMAND * gckCOMMAND; +typedef struct _gckEVENT * gckEVENT; typedef struct _gckDB * gckDB; typedef struct _gckDVFS * gckDVFS; typedef struct _gckMMU * gckMMU; @@ -1574,6 +1600,13 @@ gckKERNEL_Notify( IN gceNOTIFY Notifcation ); +gceSTATUS +gckKERNEL_SyncVideoMemory( + IN gckKERNEL Kernel, + IN gckVIDMEM_NODE Node, + IN gctUINT32 Reason + ); + /******************************************************************************* ** ** gckKERNEL_Recovery diff --git a/drivers/amlogic/npu/inc/gc_hal_base.h b/drivers/amlogic/npu/inc/gc_hal_base.h index 6e18e95..db7cf70 100644 --- a/drivers/amlogic/npu/inc/gc_hal_base.h +++ b/drivers/amlogic/npu/inc/gc_hal_base.h @@ -15,9 +15,9 @@ #define __gc_hal_base_h_ #include "gc_hal_enum.h" -#include "shared/gc_hal_types.h" +#include "gc_hal_types.h" #include "gc_hal_debug_zones.h" -#include "shared/gc_hal_base.h" +#include "shared/gc_hal_base_shared.h" #ifdef __cplusplus @@ -102,9 +102,6 @@ typedef struct _gcsNN_CUSTOMIZED_FEATURE { gctUINT vipSRAMSize; gctUINT axiSRAMSize; - gctUINT vipSRAMRemapStartAddr; - gctUINT axiSRAMRemapStartAddr; - gctUINT axiSRAMRemapEndAddr; gctFLOAT ddrReadBWLimit; gctFLOAT ddrWriteBWLimit; gctFLOAT ddrTotalBWLimit; @@ -294,6 +291,11 @@ typedef struct _gcsTLS /* Driver tls. */ gcsDRIVER_TLS_PTR driverTLS[gcvTLS_KEY_COUNT]; + +#if gcdENABLE_SW_PREEMPTION + /* PriorityID. */ + gctUINT priorityID; +#endif } gcsTLS; @@ -789,6 +791,14 @@ gcoHAL_GetCurrentCoreIndex( ); gceSTATUS +gcoHAL_InitCoreIndexByType( + IN gcoHAL Hal, + IN gceHARDWARE_TYPE Type, + IN gctBOOL Init, + OUT gctUINT32 *CoreIndex + ); + +gceSTATUS gcoHAL_ConvertCoreIndexGlobal( IN gcoHAL Hal, IN gceHARDWARE_TYPE Type, @@ -879,7 +889,7 @@ gcoHAL_AllocateVideoMemory( IN gctUINT Alignment, IN gceVIDMEM_TYPE Type, IN gctUINT32 Flag, - IN gcePOOL Pool, + IN OUT gcePOOL *Pool, IN OUT gctSIZE_T * Bytes, OUT gctUINT32_PTR Node ); @@ -926,6 +936,16 @@ gcoHAL_QueryTargetCaps( #endif gceSTATUS +gcoHAL_PrepareVideoMemory( + IN gctUINT32 Node + ); + +gceSTATUS +gcoHAL_FinishVideoMemory( + IN gctUINT32 Node + ); + +gceSTATUS gcoHAL_WrapUserMemory( IN gcsUSER_MEMORY_DESC_PTR UserMemoryDesc, IN gceVIDMEM_TYPE Type, @@ -2097,6 +2117,13 @@ typedef struct _gcsFORMAT_CLASS_TYPE_DEPTH } gcsFORMAT_CLASS_TYPE_DEPTH; +/* Intensity format class. */ +typedef struct _gcsFORMAT_CLASs_TYPE_INTENSITY +{ + gcsFORMAT_COMPONENT value; +} +gcsFORMAT_CLASs_TYPE_INTENSITY; + typedef union _gcuPIXEL_FORMAT_CLASS { gcsFORMAT_CLASS_TYPE_BUMP bump; @@ -2105,6 +2132,7 @@ typedef union _gcuPIXEL_FORMAT_CLASS gcsFORMAT_CLASS_TYPE_LUMINANCE lum; gcsFORMAT_CLASS_TYPE_INDEX index; gcsFORMAT_CLASS_TYPE_DEPTH depth; + gcsFORMAT_CLASs_TYPE_INTENSITY intensity; } gcuPIXEL_FORMAT_CLASS; @@ -5623,6 +5651,7 @@ gcoHAL_GetUserDebugOption( if (featureComputeOnly) \ { \ L1cacheSize = featureL1CacheSize; \ + attribCacheRatio = 0x7; \ } \ else \ { \ diff --git a/drivers/amlogic/npu/inc/gc_hal_cl.h b/drivers/amlogic/npu/inc/gc_hal_cl.h index 60de746..cda694b 100644 --- a/drivers/amlogic/npu/inc/gc_hal_cl.h +++ b/drivers/amlogic/npu/inc/gc_hal_cl.h @@ -89,6 +89,7 @@ typedef struct _gcoCL_DEVICE_INFO gctBOOL halti2; /* Halit2 support */ gctBOOL multiWGPack; gctBOOL asyncBLT; + gctBOOL multiCluster; gceCHIPMODEL chipModel; gctUINT32 chipRevision; @@ -117,6 +118,16 @@ gcoCL_SetHardwareType( IN gceHARDWARE_TYPE Type ); +gceSTATUS +gcoCL_ForceSetHardwareType( + IN gceHARDWARE_TYPE Type, + OUT gceHARDWARE_TYPE *savedType + ); + +gceSTATUS +gcoCL_ForceRestoreHardwareType( + IN gceHARDWARE_TYPE savedType + ); /******************************************************************************* ** ** gcoCL_InitializeHardware @@ -598,6 +609,23 @@ gcoCL_QueryDeviceCount( OUT gctUINT32 * GPUCountPerDevice ); +gceSTATUS +gcoCL_QueryDeviceCountWithGPUType( + OUT gctUINT32 * DeviceCount, + OUT gctUINT32 * GPUCountPerDevice + ); + +gceSTATUS +gcoCL_QueryDeviceCountWithVIPType( + OUT gctUINT32 * DeviceCount, + OUT gctUINT32 * GPUCountPerDevice + ); + +gceSTATUS +gcoCL_QueryDeviceCountWith3D2DType( + OUT gctUINT32 * DeviceCount, + OUT gctUINT32 * GPUCountPerDevice + ); gceSTATUS gcoCL_CreateHW( @@ -606,6 +634,13 @@ gcoCL_CreateHW( ); gceSTATUS +gcoCL_CreateHWWithType( + IN gceHARDWARE_TYPE hwType, + IN gctUINT32 DeviceId, + OUT gcoHARDWARE * Hardware + ); + +gceSTATUS gcoCL_DestroyHW( gcoHARDWARE Hardware ); diff --git a/drivers/amlogic/npu/inc/gc_hal_driver.h b/drivers/amlogic/npu/inc/gc_hal_driver.h index d39c80b7..a9c5f56 100644 --- a/drivers/amlogic/npu/inc/gc_hal_driver.h +++ b/drivers/amlogic/npu/inc/gc_hal_driver.h @@ -1,6 +1,6 @@ /**************************************************************************** * -* Copyright (c) 2005 - 2019 by Vivante Corp. All rights reserved. +* Copyright (c) 2005 - 2020 by Vivante Corp. All rights reserved. * * The material in this file is confidential and contains trade secrets * of Vivante Corporation. This is proprietary information owned by @@ -11,1341 +11,7 @@ *****************************************************************************/ -#ifndef __gc_hal_driver_h_ -#define __gc_hal_driver_h_ +#include "shared/gc_hal_driver_shared.h" -#include "gc_hal_enum.h" -#include "gc_hal_types.h" - - -#ifdef __cplusplus -extern "C" { -#endif - -/******************************************************************************\ -******************************* I/O Control Codes ****************************** -\******************************************************************************/ - -#define gcvHAL_CLASS "galcore" -#define IOCTL_GCHAL_INTERFACE 30000 -#define IOCTL_GCHAL_KERNEL_INTERFACE 30001 -#define IOCTL_GCHAL_TERMINATE 30002 - -/******************************************************************************\ -********************************* Command Codes ******************************** -\******************************************************************************/ - -typedef enum _gceHAL_COMMAND_CODES -{ - /*************** Common ***************/ - - /* Chip info: count, type and so on. */ - gcvHAL_CHIP_INFO, - - /* HAL driver version. */ - gcvHAL_VERSION, - - /* Query chip id and options. */ - gcvHAL_QUERY_CHIP_IDENTITY, - gcvHAL_QUERY_CHIP_OPTION, - - /* Query chip frequency, used by CL. */ - gcvHAL_QUERY_CHIP_FREQUENCY, - - /* Query system pool video memory, used by CL. */ - gcvHAL_QUERY_VIDEO_MEMORY, - - /* Memory management. */ - gcvHAL_ALLOCATE_LINEAR_VIDEO_MEMORY, - gcvHAL_WRAP_USER_MEMORY, - gcvHAL_RELEASE_VIDEO_MEMORY, - gcvHAL_LOCK_VIDEO_MEMORY, - gcvHAL_UNLOCK_VIDEO_MEMORY, - gcvHAL_BOTTOM_HALF_UNLOCK_VIDEO_MEMORY, - gcvHAL_MAP_MEMORY, - gcvHAL_UNMAP_MEMORY, - - /* Cache operations. */ - gcvHAL_CACHE, - - /* HAL user attach and detach. */ - gcvHAL_ATTACH, - gcvHAL_DETACH, - - /* Event commit. */ - gcvHAL_EVENT_COMMIT, - - /* User command commit. */ - gcvHAL_COMMIT, - - /* Set hardware timeout, used by CL. */ - gcvHAL_SET_TIMEOUT, - - /* User signal operations. */ - gcvHAL_USER_SIGNAL, - - /* Event signal, commit stall. */ - gcvHAL_SIGNAL, - - /* Profile related. */ - gcvHAL_SET_PROFILE_SETTING, - gcvHAL_READ_PROFILER_REGISTER_SETTING, - gcvHAL_READ_ALL_PROFILE_REGISTERS_PART1, - gcvHAL_READ_ALL_PROFILE_REGISTERS_PART2, - - /* Query process database info when debug trace and proflie. */ - gcvHAL_DATABASE, - - /* Power managment enable/disable. */ - gcvHAL_CONFIG_POWER_MANAGEMENT, - - /* Debug/dump feature. */ - gcvHAL_DEBUG_DUMP, - - /*************** Common end ***************/ - - /*************** GPU only ***************/ - /* Register operations, 2D only. */ - gcvHAL_READ_REGISTER, - gcvHAL_WRITE_REGISTER, - gcvHAL_PROFILE_REGISTERS_2D, - - /* Get base address for old mmu. */ - gcvHAL_GET_BASE_ADDRESS, - - /* Read frame database, 3D only. */ - gcvHAL_GET_FRAME_INFO, - - /* Set video memory meta data. */ - gcvHAL_SET_VIDEO_MEMORY_METADATA, - - /* Query command buffer, VG only. */ - gcvHAL_QUERY_COMMAND_BUFFER, - - /* Reset time stamp. */ - gcvHAL_QUERY_RESET_TIME_STAMP, - - /* Create native fence. */ - gcvHAL_CREATE_NATIVE_FENCE, - - /* Wait native fence. */ - gcvHAL_WAIT_NATIVE_FENCE, - - /* Wait until GPU finishes access to a resource. */ - gcvHAL_WAIT_FENCE, - - /* Video memory node operations. */ - gcvHAL_EXPORT_VIDEO_MEMORY, - gcvHAL_NAME_VIDEO_MEMORY, - gcvHAL_IMPORT_VIDEO_MEMORY, - - /* Mutex Operation. */ - gcvHAL_DEVICE_MUTEX, - /*************** GPU only end ***************/ - - /*************** DEC only ***************/ - /* DEC200 test. */ - gcvHAL_DEC200_TEST, - - /* DEC300 related operations. */ - gcvHAL_DEC300_READ, - gcvHAL_DEC300_WRITE, - gcvHAL_DEC300_FLUSH, - gcvHAL_DEC300_FLUSH_WAIT, - /*************** DEC only end ***************/ - - /*************** OS specific ***************/ - - /* Android gralloc: shared buffer operations. */ - gcvHAL_SHBUF, - - /* Android gralloc: get graphic buffer fd. */ - gcvHAL_GET_GRAPHIC_BUFFER_FD, - - /* Vsimulator only. */ - gcvHAL_UPDATE_DEBUG_CALLBACK, - gcvHAL_CONFIG_CTX_FRAMEWORK, - - /* Non paged memory management backup compatibility, windows, qnx. */ - gcvHAL_ALLOCATE_NON_PAGED_MEMORY, - gcvHAL_FREE_NON_PAGED_MEMORY, - - /* Write user data, windows only. */ - gcvHAL_WRITE_DATA, - - /*************** OS specific end ***************/ - - /*************** Reserved ***************/ - gcvHAL_SET_IDLE, - gcvHAL_RESET, - - /* Command commit done, kernel event only. */ - gcvHAL_COMMIT_DONE, - - /* Get video memory file description. */ - gcvHAL_GET_VIDEO_MEMORY_FD, - - /* Get profile setting. */ - gcvHAL_GET_PROFILE_SETTING, - - /* Read/Write register ex. */ - gcvHAL_READ_REGISTER_EX, - gcvHAL_WRITE_REGISTER_EX, - - /* Power managment state. */ - gcvHAL_SET_POWER_MANAGEMENT_STATE, - gcvHAL_QUERY_POWER_MANAGEMENT_STATE, - - /* Set debug level. */ - gcvHAL_SET_DEBUG_LEVEL_ZONE, - - /* Dump info. */ - gcvHAL_DUMP_GPU_STATE, - gcvHAL_DUMP_EVENT, - gcvHAL_DUMP_GPU_PROFILE, - - /* Timer. */ - gcvHAL_TIMESTAMP, - - /* FSCALE_VAL. */ - gcvHAL_SET_FSCALE_VALUE, - gcvHAL_GET_FSCALE_VALUE, - - /* Destory MMU. */ - gcvHAL_DESTROY_MMU, - /*************** Reserved end ***************/ -} -gceHAL_COMMAND_CODES; - -/******************************************************************************\ -****************************** Interface Structure ***************************** -\******************************************************************************/ - -#define gcdMAX_PROFILE_FILE_NAME 128 -#define gcdMAX_FLAT_MAPPING_COUNT 16 - -/* gcvHAL_CHIP_INFO */ -typedef struct _gcsHAL_CHIP_INFO -{ - /* Chip count. */ - OUT gctINT32 count; - - /* Chip types. */ - OUT gceHARDWARE_TYPE types[gcdCHIP_COUNT]; - - /* Chip IDs. */ - OUT gctUINT32 ids[gcvCORE_COUNT]; -} -gcsHAL_CHIP_INFO; - -/* gcvHAL_VERSION */ -typedef struct _gcsHAL_VERSION -{ - /* version: ... */ - OUT gctINT32 major; - OUT gctINT32 minor; - OUT gctINT32 patch; - - /* Build version. */ - OUT gctUINT32 build; -} -gcsHAL_VERSION; - -/* gcvHAL_SET_TIMEOUT. */ -typedef struct _gcsHAL_SET_TIMEOUT -{ - gctUINT32 timeOut; -} -gcsHAL_SET_TIMEOUT; - -/* gcvHAL_QUERY_VIDEO_MEMORY */ -typedef struct _gcsHAL_QUERY_VIDEO_MEMORY -{ - /* Physical memory address of internal memory. Just a name. */ - OUT gctUINT32 internalPhysName; - /* Size in bytes of internal memory. */ - OUT gctUINT64 internalSize; - - /* Physical memory address of external memory. Just a name. */ - OUT gctUINT32 externalPhysName; - /* Size in bytes of external memory.*/ - OUT gctUINT64 externalSize; - - /* Physical memory address of contiguous memory. Just a name. */ - OUT gctUINT32 contiguousPhysName; - /* Size in bytes of contiguous memory.*/ - OUT gctUINT64 contiguousSize; -} -gcsHAL_QUERY_VIDEO_MEMORY; - -enum -{ - /* GPU can't issue more that 32bit physical address */ - gcvPLATFORM_FLAG_LIMIT_4G_ADDRESS = 1 << 0, - - gcvPLATFORM_FLAG_IMX_MM = 1 << 1, -}; - -/* gcvHAL_QUERY_CHIP_IDENTITY */ -typedef struct _gcsHAL_QUERY_CHIP_IDENTITY * gcsHAL_QUERY_CHIP_IDENTITY_PTR; -typedef struct _gcsHAL_QUERY_CHIP_IDENTITY -{ - - /* Chip model. */ - gceCHIPMODEL chipModel; - - /* Revision value.*/ - gctUINT32 chipRevision; - - /* Chip date. */ - gctUINT32 chipDate; - - /* Supported feature fields. */ - gctUINT32 chipFeatures; - - /* Supported minor feature fields. */ - gctUINT32 chipMinorFeatures; - - /* Supported minor feature 1 fields. */ - gctUINT32 chipMinorFeatures1; - - /* Supported minor feature 2 fields. */ - gctUINT32 chipMinorFeatures2; - - /* Supported minor feature 3 fields. */ - gctUINT32 chipMinorFeatures3; - - /* Supported minor feature 4 fields. */ - gctUINT32 chipMinorFeatures4; - - /* Supported minor feature 5 fields. */ - gctUINT32 chipMinorFeatures5; - - /* Supported minor feature 6 fields. */ - gctUINT32 chipMinorFeatures6; - - /* Number of streams supported. */ - gctUINT32 streamCount; - - /* Number of pixel pipes. */ - gctUINT32 pixelPipes; - - /* Number of resolve pipes. */ - gctUINT32 resolvePipes; - - /* Number of instructions. */ - gctUINT32 instructionCount; - - /* Number of constants. */ - gctUINT32 numConstants; - - /* Number of varyings */ - gctUINT32 varyingsCount; - - /* Number of 3D GPUs */ - gctUINT32 gpuCoreCount; - - /* Physical mask of all AVAILABLE clusters in core.*/ - gctUINT32 clusterAvailMask; - - /* Product ID */ - gctUINT32 productID; - - /* Special chip flag bits */ - gceCHIP_FLAG chipFlags; - - /* ECO ID. */ - gctUINT32 ecoID; - - /* Customer ID. */ - gctUINT32 customerID; - - /* CPU view physical address and size of SRAMs. */ - gctUINT64 sRAMBases[gcvSRAM_INTER_COUNT]; - gctUINT32 sRAMSizes[gcvSRAM_INTER_COUNT]; - - gctUINT64 platformFlagBits; -} -gcsHAL_QUERY_CHIP_IDENTITY; - -/* gcvHAL_QUERY_CHIP_OPTION. */ -typedef struct _gcsHAL_QUERY_CHIP_OPTIONS * gcsHAL_QUERY_CHIP_OPTIONS_PTR; -typedef struct _gcsHAL_QUERY_CHIP_OPTIONS -{ - gctBOOL gpuProfiler; - gctBOOL allowFastClear; - gctBOOL powerManagement; - /* Whether use new MMU. It is meaningless - ** for old MMU since old MMU is always enabled. - */ - gctBOOL enableMMU; - gceCOMPRESSION_OPTION allowCompression; - gctBOOL smallBatch; - gctUINT32 uscL1CacheRatio; - gctUINT32 uscAttribCacheRatio; - gctUINT32 userClusterMask; - - /* Internal SRAM. */ - gctUINT32 sRAMGPUVirtAddrs[gcvSRAM_INTER_COUNT]; - gctUINT32 sRAMSizes[gcvSRAM_INTER_COUNT]; - gctUINT32 sRAMCount; - - /* External SRAM. */ - gctPHYS_ADDR_T extSRAMCPUPhysAddrs[gcvSRAM_EXT_COUNT]; - gctPHYS_ADDR_T extSRAMGPUPhysAddrs[gcvSRAM_EXT_COUNT]; - gctUINT32 extSRAMGPUVirtAddrs[gcvSRAM_EXT_COUNT]; - gctUINT32 extSRAMGPUPhysNames[gcvSRAM_EXT_COUNT]; - gctUINT32 extSRAMSizes[gcvSRAM_EXT_COUNT]; - gctUINT32 extSRAMCount; - - gceSECURE_MODE secureMode; - gctBOOL enableNNTPParallel; - gctUINT enableSwtilingPhase1; -} -gcsHAL_QUERY_CHIP_OPTIONS; - -/* gcvHAL_QUERY_CHIP_FREQUENCY. */ -typedef struct _gcsHAL_QUERY_CHIP_FREQUENCY * gcsHAL_QUERY_CHIP_FREQUENCY_PTR; -typedef struct _gcsHAL_QUERY_CHIP_FREQUENCY -{ - OUT gctUINT32 mcClk; - OUT gctUINT32 shClk; -} -gcsHAL_QUERY_CHIP_FREQUENCY; - -/* Obsolete for userpace. */ -/* gcvHAL_ALLOCATE_NON_PAGED_MEMORY */ -typedef struct _gcsHAL_ALLOCATE_NON_PAGED_MEMORY -{ - /* Allocation flags. */ - IN gctUINT32 flags; - - /* Number of bytes to allocate. */ - IN OUT gctUINT64 bytes; - - /* Physical address of allocation. Just a name. */ - OUT gctUINT32 physName; - - /* Logical address of allocation. */ - OUT gctUINT64 logical; -} -gcsHAL_ALLOCATE_NON_PAGED_MEMORY; - -/* Obsolete for userpace. */ -/* gcvHAL_FREE_NON_PAGED_MEMORY */ -typedef struct _gcsHAL_FREE_NON_PAGED_MEMORY -{ - /* Number of bytes allocated. */ - IN gctUINT64 bytes; - - /* Physical address of allocation. Just a name. */ - IN gctUINT32 physName; - - /* Logical address of allocation. */ - IN gctUINT64 logical; -} -gcsHAL_FREE_NON_PAGED_MEMORY; - -/* Video memory allocation. */ -/* gcvHAL_ALLOCATE_LINEAR_VIDEO_MEMORY */ -typedef struct _gcsHAL_ALLOCATE_LINEAR_VIDEO_MEMORY -{ - /* Number of bytes to allocate. */ - IN OUT gctUINT64 bytes; - - /* Buffer alignment. */ - IN gctUINT32 alignment; - - /* Type of allocation, see gceVIDMEM_TYPE. */ - IN gctUINT32 type; - - /* Flag of allocation. */ - IN gctUINT32 flag; - - /* Memory pool to allocate from. */ - IN OUT gctUINT32 pool; - - /* Internal SRAM index. */ - IN gctINT32 sRAMIndex; - /* External SRAM index. */ - IN gctINT32 extSRAMIndex; - - /* Allocated video memory. */ - OUT gctUINT32 node; -} -gcsHAL_ALLOCATE_LINEAR_VIDEO_MEMORY; - -typedef struct _gcsUSER_MEMORY_DESC -{ - /* Import flag. */ - gctUINT32 flag; - - /* gcvALLOC_FLAG_DMABUF */ - gctUINT32 handle; - gctUINT64 dmabuf; - - /* gcvALLOC_FLAG_USERMEMORY */ - gctUINT64 logical; - gctUINT64 physical; - gctUINT32 size; - - /* gcvALLOC_FLAG_EXTERNAL_MEMORY */ - gcsEXTERNAL_MEMORY_INFO externalMemoryInfo; -} -gcsUSER_MEMORY_DESC; - -/* gcvHAL_WRAP_USER_MEMORY. */ -typedef struct _gcsHAL_WRAP_USER_MEMORY -{ - /* Description of user memory. */ - IN gcsUSER_MEMORY_DESC desc; - - /* Video memory allocation type. */ - IN gctUINT32 type; - - /* Output video mmory node. */ - OUT gctUINT32 node; - - /* size of the node in bytes */ - OUT gctUINT64 bytes; -} -gcsHAL_WRAP_USER_MEMORY; - -/* gcvHAL_RELEASE_VIDEO_MEMORY */ -typedef struct _gcsHAL_RELEASE_VIDEO_MEMORY -{ - /* Allocated video memory. */ - IN gctUINT32 node; - -#ifdef __QNXNTO__ - /* Mapped logical address to unmap in user space. */ - OUT gctUINT64 memory; - - /* Number of bytes to allocated. */ - OUT gctUINT64 bytes; -#endif -} -gcsHAL_RELEASE_VIDEO_MEMORY; - -/* gcvHAL_LOCK_VIDEO_MEMORY */ -typedef struct _gcsHAL_LOCK_VIDEO_MEMORY -{ - /* Allocated video memory. */ - IN gctUINT32 node; - - /* Cache configuration. */ - /* Only gcvPOOL_VIRTUAL can be configured */ - IN gctBOOL cacheable; - - /* Hardware specific address. */ - OUT gctUINT32 address; - - /* Mapped logical address. */ - OUT gctUINT64 memory; - - /* Customer priviate handle*/ - OUT gctUINT32 gid; - - /* Bus address of a contiguous video node. */ - OUT gctUINT64 physicalAddress; -} -gcsHAL_LOCK_VIDEO_MEMORY; - -/* gcvHAL_UNLOCK_VIDEO_MEMORY */ -typedef struct _gcsHAL_UNLOCK_VIDEO_MEMORY -{ - /* Allocated video memory. */ - IN gctUINT64 node; - - /* Video memory allocation type. */ - IN gctUINT32 type; - - /* Pool of the unlock node */ - OUT gctUINT32 pool; - - /* Bytes of the unlock node */ - OUT gctUINT64 bytes; - - /* Flag to unlock surface asynchroneously. */ - IN OUT gctBOOL asynchroneous; -} -gcsHAL_UNLOCK_VIDEO_MEMORY; - -/* gcvHAL_BOTTOM_HALF_UNLOCK_VIDEO_MEMORY: */ -typedef struct _gcsHAL_BOTTOM_HALF_UNLOCK_VIDEO_MEMORY -{ - /* Allocated video memory. */ - IN gctUINT32 node; - - /* Video memory allocation type. */ - IN gctUINT32 type; -} -gcsHAL_BOTTOM_HALF_UNLOCK_VIDEO_MEMORY; - -/* gcvHAL_EXPORT_VIDEO_MEMORY. */ -typedef struct _gcsHAL_EXPORT_VIDEO_MEMORY -{ - /* Allocated video memory. */ - IN gctUINT32 node; - - /* Export flags */ - IN gctUINT32 flags; - - /* Exported dma_buf fd */ - OUT gctINT32 fd; -} -gcsHAL_EXPORT_VIDEO_MEMORY; - -/* gcvHAL_NAME_VIDEO_MEMORY. */ -typedef struct _gcsHAL_NAME_VIDEO_MEMORY -{ - IN gctUINT32 handle; - OUT gctUINT32 name; -} -gcsHAL_NAME_VIDEO_MEMORY; - -/* gcvHAL_IMPORT_VIDEO_MEMORY. */ -typedef struct _gcsHAL_IMPORT_VIDEO_MEMORY -{ - IN gctUINT32 name; - OUT gctUINT32 handle; -} -gcsHAL_IMPORT_VIDEO_MEMORY; - -/* gcvHAL_MAP_MEMORY */ -typedef struct _gcsHAL_MAP_MEMORY -{ - /* Physical memory address to map. Just a name on Linux/Qnx. */ - IN gctUINT32 physName; - - /* Number of bytes in physical memory to map. */ - IN gctUINT64 bytes; - - /* Address of mapped memory. */ - OUT gctUINT64 logical; -} -gcsHAL_MAP_MEMORY; - -/* gcvHAL_UNMAP_MEMORY */ -typedef struct _gcsHAL_UNMAP_MEMORY -{ - /* Physical memory address to unmap. Just a name on Linux/Qnx. */ - IN gctUINT32 physName; - - /* Number of bytes in physical memory to unmap. */ - IN gctUINT64 bytes; - - /* Address of mapped memory to unmap. */ - IN gctUINT64 logical; -} -gcsHAL_UNMAP_MEMORY; - -/* gcvHAL_CACHE */ -typedef struct _gcsHAL_CACHE -{ - IN gceCACHEOPERATION operation; - IN gctUINT64 process; - IN gctUINT64 logical; - IN gctUINT64 bytes; - IN gctUINT32 node; -} -gcsHAL_CACHE; - -/* gcvHAL_ATTACH */ -typedef struct _gcsHAL_ATTACH -{ - /* Handle of context buffer object. */ - OUT gctUINT32 context; - - /* Maximum state in the buffer. */ - OUT gctUINT64 maxState; - - /* Number of states in the buffer. */ - OUT gctUINT32 numStates; - - /* Map context buffer to user or not. */ - IN gctBOOL map; - - /* Physical of context buffer. */ - OUT gctUINT64 logicals[2]; - - /* Bytes of context buffer. */ - OUT gctUINT32 bytes; -} -gcsHAL_ATTACH; - -/* gcvHAL_DETACH */ -typedef struct _gcsHAL_DETACH -{ - /* Context buffer object gckCONTEXT. Just a name. */ - IN gctUINT32 context; -} -gcsHAL_DETACH; - - -/* gcvHAL_EVENT_COMMIT. */ -typedef struct _gcsHAL_EVENT_COMMIT -{ - /* Event queue in gcsQUEUE. */ - IN gctUINT64 queue; -} -gcsHAL_EVENT_COMMIT; - -typedef struct _gcsHAL_COMMAND_LOCATION -{ - gctUINT32 priority; - gctUINT32 channelId; - - gctUINT32 videoMemNode; - - gctUINT32 address; - gctUINT64 logical; - gctUINT32 startOffset; - /* size includes reservedHead and reservedTail. */ - gctUINT32 size; - - gctUINT32 reservedHead; - gctUINT32 reservedTail; - - /* Pointer to patch list. */ - gctUINT64 patchHead; - - /* - * Location index of exit commands, ie where to put the chipEnable/link back - * commands in the reservedTail area. - * It's used in fully shared command buffer for multiple cores. - */ - gctUINT32 exitIndex; - gctUINT32 entryPipe; - gctUINT32 exitPipe; - - /* struct _gcsHAL_COMMAND_LOCATION * next; */ - gctUINT64 next; -} -gcsHAL_COMMAND_LOCATION; - -typedef struct _gcsHAL_SUBCOMMIT -{ - gctUINT32 coreId; - - /* user gcsSTATE_DELTA_PTR. */ - gctUINT64 delta; - - /* Kernel gckCONTEXT. */ - gctUINT64 context; - - /* Event queue in user gcsQUEUE *. */ - gctUINT64 queue; - - /* Locate the commands. */ - gcsHAL_COMMAND_LOCATION commandBuffer; - - /* struct _gcsHAL_SUBCOMMIT * next; */ - gctUINT64 next; -} -gcsHAL_SUBCOMMIT; - -/* gcvHAL_COMMIT */ -typedef struct _gcsHAL_COMMIT -{ - gcsHAL_SUBCOMMIT subCommit; - - gctBOOL shared; - - gctBOOL contextSwitched; - - /* Commit stamp of this commit. */ - OUT gctUINT64 commitStamp; -} -gcsHAL_COMMIT; - - -typedef struct _gcsHAL_COMMIT_DONE -{ - IN gctUINT64 context; -} -gcsHAL_COMMIT_DONE; - -/* gcvHAL_USER_SIGNAL */ -typedef struct _gcsHAL_USER_SIGNAL -{ - /* Command. */ - gceUSER_SIGNAL_COMMAND_CODES command; - - /* Signal ID. */ - IN OUT gctINT32 id; - - /* Reset mode. */ - IN gctBOOL manualReset; - - /* Wait timedout. */ - IN gctUINT32 wait; - - /* State. */ - IN gctBOOL state; -} -gcsHAL_USER_SIGNAL; - -/* gcvHAL_SIGNAL. */ -typedef struct _gcsHAL_SIGNAL -{ - /* Signal handle to signal gctSIGNAL. */ - IN gctUINT64 signal; - - /* Reserved gctSIGNAL. */ - IN gctUINT64 auxSignal; - - /* Process owning the signal gctHANDLE. */ - IN gctUINT64 process; - -#if defined(__QNXNTO__) - /* Client pulse side-channel connection ID. Set by client in gcoOS_CreateSignal. */ - IN gctINT32 coid; - - /* Set by server. */ - IN gctINT32 rcvid; -#endif - /* Event generated from where of pipeline */ - IN gceKERNEL_WHERE fromWhere; -} -gcsHAL_SIGNAL; - -/* gcvHAL_WRITE_DATA. */ -typedef struct _gcsHAL_WRITE_DATA -{ - /* Address to write data to. */ - IN gctUINT32 address; - - /* Data to write. */ - IN gctUINT32 data; -} -gcsHAL_WRITE_DATA; - -/* gcvHAL_READ_REGISTER */ -typedef struct _gcsHAL_READ_REGISTER -{ - /* Logical address of memory to write data to. */ - IN gctUINT32 address; - - /* Data read. */ - OUT gctUINT32 data; -} -gcsHAL_READ_REGISTER; - -/* gcvHAL_WRITE_REGISTER */ -typedef struct _gcsHAL_WRITE_REGISTER -{ - /* Logical address of memory to write data to. */ - IN gctUINT32 address; - - /* Data read. */ - IN gctUINT32 data; -} -gcsHAL_WRITE_REGISTER; - -/* gcvHAL_READ_REGISTER_EX */ -typedef struct _gcsHAL_READ_REGISTER_EX -{ - /* Logical address of memory to write data to. */ - IN gctUINT32 address; - - IN gctUINT32 coreSelect; - - /* Data read. */ - OUT gctUINT32 data[4]; -} -gcsHAL_READ_REGISTER_EX; - -/* gcvHAL_WRITE_REGISTER_EX */ -typedef struct _gcsHAL_WRITE_REGISTER_EX -{ - /* Logical address of memory to write data to. */ - IN gctUINT32 address; - - IN gctUINT32 coreSelect; - - /* Data read. */ - IN gctUINT32 data[4]; -} -gcsHAL_WRITE_REGISTER_EX; - -#if VIVANTE_PROFILER -/* gcvHAL_GET_PROFILE_SETTING */ -typedef struct _gcsHAL_GET_PROFILE_SETTING -{ - /* Enable profiling */ - OUT gctBOOL enable; -} -gcsHAL_GET_PROFILE_SETTING; - -/* gcvHAL_SET_PROFILE_SETTING */ -typedef struct _gcsHAL_SET_PROFILE_SETTING -{ - /* Enable profiling */ - IN gctBOOL enable; -} -gcsHAL_SET_PROFILE_SETTING; - -/* gcvHAL_READ_PROFILER_REGISTER_SETTING */ -typedef struct _gcsHAL_READ_PROFILER_REGISTER_SETTING -{ - /*Should Clear Register*/ - IN gctBOOL bclear; -} -gcsHAL_READ_PROFILER_REGISTER_SETTING; - -typedef struct _gcsHAL_READ_ALL_PROFILE_REGISTERS_PART1 -{ - /* Context buffer object gckCONTEXT. Just a name. */ - IN gctUINT32 context; - - /* Data read. */ - OUT gcsPROFILER_COUNTERS_PART1 Counters; -} -gcsHAL_READ_ALL_PROFILE_REGISTERS_PART1; - -typedef struct _gcsHAL_READ_ALL_PROFILE_REGISTERS_PART2 -{ - /* Context buffer object gckCONTEXT. Just a name. */ - IN gctUINT32 context; - - /* Data read. */ - OUT gcsPROFILER_COUNTERS_PART2 Counters; -} -gcsHAL_READ_ALL_PROFILE_REGISTERS_PART2; - -/* gcvHAL_PROFILE_REGISTERS_2D */ -typedef struct _gcsHAL_PROFILE_REGISTERS_2D -{ - /* Data read in gcs2D_PROFILE. */ - OUT gctUINT64 hwProfile2D; -} -gcsHAL_PROFILE_REGISTERS_2D; -#endif - -/* gcvHAL_SET_POWER_MANAGEMENT_STATE */ -typedef struct _gcsHAL_SET_POWER_MANAGEMENT -{ - /* Data read. */ - IN gceCHIPPOWERSTATE state; -} -gcsHAL_SET_POWER_MANAGEMENT; - -/* gcvHAL_QUERY_POWER_MANAGEMENT_STATE */ -typedef struct _gcsHAL_QUERY_POWER_MANAGEMENT -{ - /* Data read. */ - OUT gceCHIPPOWERSTATE state; - - /* Idle query. */ - OUT gctBOOL isIdle; -} -gcsHAL_QUERY_POWER_MANAGEMENT; - -/* gcvHAL_CONFIG_POWER_MANAGEMENT. */ -typedef struct _gcsHAL_CONFIG_POWER_MANAGEMENT -{ - IN gctBOOL enable; -} -gcsHAL_CONFIG_POWER_MANAGEMENT; - -typedef struct _gcsFLAT_MAPPING_RANGE -{ - gctUINT64 start; - gctUINT64 end; - gctUINT32 size; - gceFLATMAP_FLAG flag; -} -gcsFLAT_MAPPING_RANGE; - -/* gcvHAL_GET_BASE_ADDRESS */ -typedef struct _gcsHAL_GET_BASE_ADDRESS -{ - /* Physical memory address of internal memory. */ - OUT gctUINT32 baseAddress; - - OUT gctUINT32 flatMappingRangeCount; - - OUT gcsFLAT_MAPPING_RANGE flatMappingRanges[gcdMAX_FLAT_MAPPING_COUNT]; -} -gcsHAL_GET_BASE_ADDRESS; - -typedef struct _gcsHAL_SET_DEBUG_LEVEL_ZONE -{ - IN gctUINT32 level; - IN gctUINT32 zones; - IN gctBOOL enable; -} -gcsHAL_SET_DEBUG_LEVEL_ZONE; - -/* gcvHAL_DEBUG_DUMP. */ -typedef struct _gcsHAL_DEBUG_DUMP -{ - /* gceDUMP_BUFFER_TYPE type. */ - IN gctUINT32 type; - - IN gctUINT64 ptr; - IN gctUINT32 address; - IN gctUINT32 size; -} -gcsHAL_DEBUG_DUMP; - - -/* gcvHAL_TIMESTAMP */ -typedef struct _gcsHAL_TIMESTAMP -{ - /* Timer select. */ - IN gctUINT32 timer; - - /* Timer request type (0-stop, 1-start, 2-send delta). */ - IN gctUINT32 request; - - /* Result of delta time in microseconds. */ - OUT gctINT32 timeDelta; -} -gcsHAL_TIMESTAMP; - -/* gcvHAL_DATABASE */ -typedef struct _gcsHAL_DATABASE -{ - /* Set to gcvTRUE if you want to query a particular process ID. - ** Set to gcvFALSE to query the last detached process. */ - IN gctBOOL validProcessID; - - /* Process ID to query. */ - IN gctUINT32 processID; - - /* Information. */ - OUT gcuDATABASE_INFO vidMem; - OUT gcuDATABASE_INFO nonPaged; - OUT gcuDATABASE_INFO gpuIdle; - - /* Detail information about video memory. */ - OUT gcuDATABASE_INFO vidMemPool[3]; -} -gcsHAL_DATABASE; - -/* gcvHAL_GET_FRAME_INFO. */ -typedef struct _gcsHAL_GET_FRAME_INFO -{ - /* gcsHAL_FRAME_INFO* */ - OUT gctUINT64 frameInfo; -} -gcsHAL_GET_FRAME_INFO; - - -typedef struct _gcsHAL_SET_FSCALE_VALUE -{ - IN gctUINT32 value; -} -gcsHAL_SET_FSCALE_VALUE; - -typedef struct _gcsHAL_GET_FSCALE_VALUE -{ - OUT gctUINT32 value; - OUT gctUINT32 minValue; - OUT gctUINT32 maxValue; -} -gcsHAL_GET_FSCALE_VALUE; - -/* gcvHAL_QUERY_RESET_TIME_STAMP. */ -typedef struct _gcsHAL_QUERY_RESET_TIME_STAMP -{ - OUT gctUINT64 timeStamp; - OUT gctUINT64 contextID; -} -gcsHAL_QUERY_RESET_TIME_STAMP; - -/* gcvHAL_CREATE_NATIVE_FENCE. */ -typedef struct _gcsHAL_CREATE_NATIVE_FENCE -{ - /* Signal id. */ - IN gctUINT64 signal; - - /* Native fence file descriptor. */ - OUT gctINT32 fenceFD; - -} -gcsHAL_CREATE_NATIVE_FENCE; - -/* gcvHAL_WAIT_NATIVE_FENCE. */ -typedef struct _gcsHAL_WAIT_NATIVE_FENCE -{ - /* Native fence file descriptor. */ - IN gctINT32 fenceFD; - - /* Wait timeout. */ - IN gctUINT32 timeout; -} -gcsHAL_WAIT_NATIVE_FENCE; - -/* gcvHAL_SHBUF. */ -typedef struct _gcsHAL_SHBUF -{ - gceSHBUF_COMMAND_CODES command; - - /* Shared buffer. */ - IN OUT gctUINT64 id; - - /* User data to be shared. */ - IN gctUINT64 data; - - /* Data size. */ - IN OUT gctUINT32 bytes; -} -gcsHAL_SHBUF; - -/* gcvHAL_GET_GRAPHIC_BUFFER_FD. */ -/* - * Fd representation of android graphic buffer contents. - * Currently, it is only to reference video nodes, signal, etc to avoid being - * destroyed when trasfering across processes. - */ -typedef struct _gcsHAL_GET_GRAPHIC_BUFFER_FD -{ - /* Max 3 video nodes, node handle here. */ - IN gctUINT32 node[3]; - - /* A shBuf. */ - IN gctUINT64 shBuf; - - /* A signal. */ - IN gctUINT64 signal; - - OUT gctINT32 fd; -} -gcsHAL_GET_GRAPHIC_BUFFER_FD; - -typedef struct _gcsHAL_VIDEO_MEMORY_METADATA -{ - /* Allocated video memory. */ - IN gctUINT32 node; - - IN gctUINT32 readback; - - INOUT gctINT32 ts_fd; - INOUT gctUINT32 fc_enabled; - INOUT gctUINT32 fc_value; - INOUT gctUINT32 fc_value_upper; - - INOUT gctUINT32 compressed; - INOUT gctUINT32 compress_format; -} -gcsHAL_VIDEO_MEMORY_METADATA; - -/* gcvHAL_GET_VIDEO_MEMORY_FD. */ -typedef struct _gcsHAL_GET_VIDEO_MEMORY_FD -{ - IN gctUINT32 handle; - OUT gctINT32 fd; -} -gcsHAL_GET_VIDEO_MEMORY_FD; - -/* gcvHAL_DESTROY_MMU. */ -typedef struct _gcsHAL_DESTROY_MMU -{ - /* Mmu object. */ - IN gctUINT64 mmu; -} -gcsHAL_DESTROY_MMU; - -/* gcvHAL_WAIT_FENCE. */ -typedef struct _gcsHAL_WAIT_FENCE -{ - IN gctUINT32 handle; - IN gctUINT32 timeOut; -} -gcsHAL_WAIT_FENCE; - -/* gcvHAL_DEVICE_MUTEX: */ -typedef struct _gcsHAL_DEVICE_MUTEX -{ - /* Lock or Release device mutex. */ - gctBOOL isMutexLocked; -} -gcsHAL_DEVICE_MUTEX; - - -#if gcdDEC_ENABLE_AHB -/* gcvHAL_DEC300_READ. */ -typedef struct _gcsHAL_DEC300_READ -{ - gctUINT32 enable; - gctUINT32 readId; - gctUINT32 format; - gctUINT32 strides[3]; - gctUINT32 is3D; - gctUINT32 isMSAA; - gctUINT32 clearValue; - gctUINT32 isTPC; - gctUINT32 isTPCCompressed; - gctUINT32 surfAddrs[3]; - gctUINT32 tileAddrs[3]; -} -DEC300Read; - -/* gcvHAL_DEC300_WRITE. */ -typedef struct _gcsHAL_DEC300_WRITE -{ - gctUINT32 enable; - gctUINT32 readId; - gctUINT32 writeId; - gctUINT32 format; - gctUINT32 surfAddr; - gctUINT32 tileAddr; -} -DEC300Write; - -/* gcvHAL_DEC300_FLUSH. */ -typedef struct _gcsHAL_DEC300_FLUSH -{ - IN gctUINT8 useless; -} -DEC300Flush; - -/* gcvHAL_DEC300_FLUSH_WAIT. */ -typedef struct _gcsHAL_DEC300_FLUSH_WAIT -{ - IN gctUINT32 done; -} -DEC300FlushWait; -#endif - - -typedef struct _gcsHAL_INTERFACE -{ - /* Command code. */ - gceHAL_COMMAND_CODES command; - - /* Hardware type. */ - gceHARDWARE_TYPE hardwareType; - - /* Core index for current hardware type. */ - gctUINT32 coreIndex; - - /* Status value. */ - gceSTATUS status; - - /* Engine */ - gceENGINE engine; - - /* Ignore information from TSL when doing IO control */ - gctBOOL ignoreTLS; - - /* The mutext already acquired */ - IN gctBOOL commitMutex; - - /* Union of command structures. */ - union _u - { - gcsHAL_CHIP_INFO ChipInfo; - gcsHAL_VERSION Version; - gcsHAL_SET_TIMEOUT SetTimeOut; - - gcsHAL_QUERY_VIDEO_MEMORY QueryVideoMemory; - gcsHAL_QUERY_CHIP_IDENTITY QueryChipIdentity; - gcsHAL_QUERY_CHIP_OPTIONS QueryChipOptions; - gcsHAL_QUERY_CHIP_FREQUENCY QueryChipFrequency; - - gcsHAL_ALLOCATE_NON_PAGED_MEMORY AllocateNonPagedMemory; - gcsHAL_FREE_NON_PAGED_MEMORY FreeNonPagedMemory; - - gcsHAL_ALLOCATE_LINEAR_VIDEO_MEMORY AllocateLinearVideoMemory; - gcsHAL_WRAP_USER_MEMORY WrapUserMemory; - gcsHAL_RELEASE_VIDEO_MEMORY ReleaseVideoMemory; - - gcsHAL_LOCK_VIDEO_MEMORY LockVideoMemory; - gcsHAL_UNLOCK_VIDEO_MEMORY UnlockVideoMemory; - gcsHAL_BOTTOM_HALF_UNLOCK_VIDEO_MEMORY BottomHalfUnlockVideoMemory; - - gcsHAL_EXPORT_VIDEO_MEMORY ExportVideoMemory; - gcsHAL_NAME_VIDEO_MEMORY NameVideoMemory; - gcsHAL_IMPORT_VIDEO_MEMORY ImportVideoMemory; - - gcsHAL_MAP_MEMORY MapMemory; - gcsHAL_UNMAP_MEMORY UnmapMemory; - - gcsHAL_CACHE Cache; - - gcsHAL_ATTACH Attach; - gcsHAL_DETACH Detach; - - gcsHAL_EVENT_COMMIT Event; - gcsHAL_COMMIT Commit; - gcsHAL_COMMIT_DONE CommitDone; - - gcsHAL_USER_SIGNAL UserSignal; - gcsHAL_SIGNAL Signal; - - gcsHAL_WRITE_DATA WriteData; - gcsHAL_READ_REGISTER ReadRegisterData; - gcsHAL_WRITE_REGISTER WriteRegisterData; - gcsHAL_READ_REGISTER_EX ReadRegisterDataEx; - gcsHAL_WRITE_REGISTER_EX WriteRegisterDataEx; - -#if VIVANTE_PROFILER - gcsHAL_GET_PROFILE_SETTING GetProfileSetting; - gcsHAL_SET_PROFILE_SETTING SetProfileSetting; - gcsHAL_READ_PROFILER_REGISTER_SETTING SetProfilerRegisterClear; - gcsHAL_READ_ALL_PROFILE_REGISTERS_PART1 RegisterProfileData_part1; - gcsHAL_READ_ALL_PROFILE_REGISTERS_PART2 RegisterProfileData_part2; - gcsHAL_PROFILE_REGISTERS_2D RegisterProfileData2D; -#endif - - gcsHAL_SET_POWER_MANAGEMENT SetPowerManagement; - gcsHAL_QUERY_POWER_MANAGEMENT QueryPowerManagement; - gcsHAL_CONFIG_POWER_MANAGEMENT ConfigPowerManagement; - - gcsHAL_GET_BASE_ADDRESS GetBaseAddress; - - gcsHAL_SET_DEBUG_LEVEL_ZONE DebugLevelZone; - gcsHAL_DEBUG_DUMP DebugDump; - - gcsHAL_TIMESTAMP TimeStamp; - gcsHAL_DATABASE Database; - - gcsHAL_GET_FRAME_INFO GetFrameInfo; - - - /* gcsHAL_DUMP_GPU_STATE */ - /* gcsHAL_DUMP_EVENT */ - - gcsHAL_SET_FSCALE_VALUE SetFscaleValue; - gcsHAL_GET_FSCALE_VALUE GetFscaleValue; - - gcsHAL_QUERY_RESET_TIME_STAMP QueryResetTimeStamp; - - gcsHAL_CREATE_NATIVE_FENCE CreateNativeFence; - gcsHAL_WAIT_NATIVE_FENCE WaitNativeFence; - gcsHAL_SHBUF ShBuf; - gcsHAL_GET_GRAPHIC_BUFFER_FD GetGraphicBufferFd; - gcsHAL_VIDEO_MEMORY_METADATA SetVidMemMetadata; - gcsHAL_GET_VIDEO_MEMORY_FD GetVideoMemoryFd; - - gcsHAL_DESTROY_MMU DestroyMmu; - - gcsHAL_WAIT_FENCE WaitFence; - - /* gcvHAL_DEVICE_MUTEX: */ - gcsHAL_DEVICE_MUTEX DeviceMutex; - - -#if gcdDEC_ENABLE_AHB - gcsHAL_DEC300_READ DEC300Read; - gcsHAL_DEC300_WRITE DEC300Write; - gcsHAL_DEC300_FLUSH DEC300Flush; - gcsHAL_DEC300_FLUSH_WAIT DEC300FlushWait; -#endif - } - u; -} -gcsHAL_INTERFACE; - - -#ifdef __cplusplus -} -#endif - -#endif /* __gc_hal_driver_h_ */ diff --git a/drivers/amlogic/npu/inc/gc_hal_driver_vg.h b/drivers/amlogic/npu/inc/gc_hal_driver_vg.h index 920ced3..a482ea7 100644 --- a/drivers/amlogic/npu/inc/gc_hal_driver_vg.h +++ b/drivers/amlogic/npu/inc/gc_hal_driver_vg.h @@ -1,6 +1,6 @@ /**************************************************************************** * -* Copyright (c) 2005 - 2019 by Vivante Corp. All rights reserved. +* Copyright (c) 2005 - 2020 by Vivante Corp. All rights reserved. * * The material in this file is confidential and contains trade secrets * of Vivante Corporation. This is proprietary information owned by @@ -11,228 +11,7 @@ *****************************************************************************/ -#ifndef __gc_hal_driver_vg_h_ -#define __gc_hal_driver_vg_h_ +#include "shared/gc_hal_driver_vg_shared.h" -#include "gc_hal_types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/******************************************************************************\ -******************************* I/O Control Codes ****************************** -\******************************************************************************/ - -#define gcvHAL_CLASS "galcore" -#define IOCTL_GCHAL_INTERFACE 30000 - -/******************************************************************************\ -********************* Command buffer information structure. ******************** -\******************************************************************************/ - -typedef struct _gcsCOMMAND_BUFFER_INFO * gcsCOMMAND_BUFFER_INFO_PTR; -typedef struct _gcsCOMMAND_BUFFER_INFO -{ - /* FE command buffer interrupt ID. */ - gctINT32 feBufferInt; - - /* TS overflow interrupt ID. */ - gctINT32 tsOverflowInt; - - /* Alignment and mask for the buffer address. */ - gctUINT addressMask; - gctUINT32 addressAlignment; - - /* Alignment for each command. */ - gctUINT32 commandAlignment; - - /* Number of bytes required by the STATE command. */ - gctUINT32 stateCommandSize; - - /* Number of bytes required by the RESTART command. */ - gctUINT32 restartCommandSize; - - /* Number of bytes required by the FETCH command. */ - gctUINT32 fetchCommandSize; - - /* Number of bytes required by the CALL command. */ - gctUINT32 callCommandSize; - - /* Number of bytes required by the RETURN command. */ - gctUINT32 returnCommandSize; - - /* Number of bytes required by the EVENT command. */ - gctUINT32 eventCommandSize; - - /* Number of bytes required by the END command. */ - gctUINT32 endCommandSize; - - /* Number of bytes reserved at the tail of a static command buffer. */ - gctUINT32 staticTailSize; - - /* Number of bytes reserved at the tail of a dynamic command buffer. */ - gctUINT32 dynamicTailSize; -} -gcsCOMMAND_BUFFER_INFO; - -/******************************************************************************\ -******************************** Task Structures ******************************* -\******************************************************************************/ - -typedef enum _gceTASK -{ - gcvTASK_LINK, - gcvTASK_CLUSTER, - gcvTASK_INCREMENT, - gcvTASK_DECREMENT, - gcvTASK_SIGNAL, - gcvTASK_LOCKDOWN, - gcvTASK_UNLOCK_VIDEO_MEMORY, - gcvTASK_FREE_VIDEO_MEMORY, - gcvTASK_FREE_CONTIGUOUS_MEMORY, -} -gceTASK; - -typedef struct _gcsTASK_HEADER * gcsTASK_HEADER_PTR; -typedef struct _gcsTASK_HEADER -{ - /* Task ID. */ - IN gceTASK id; -} -gcsTASK_HEADER; - -typedef struct _gcsTASK_LINK * gcsTASK_LINK_PTR; -typedef struct _gcsTASK_LINK -{ - /* Task ID (gcvTASK_LINK). */ - IN gceTASK id; - - /* Pointer to the next task container. */ - IN gctPOINTER cotainer; - - /* Pointer to the next task from the next task container. */ - IN gcsTASK_HEADER_PTR task; -} -gcsTASK_LINK; - -typedef struct _gcsTASK_CLUSTER * gcsTASK_CLUSTER_PTR; -typedef struct _gcsTASK_CLUSTER -{ - /* Task ID (gcvTASK_CLUSTER). */ - IN gceTASK id; - - /* Number of tasks in the cluster. */ - IN gctUINT taskCount; -} -gcsTASK_CLUSTER; - -typedef struct _gcsTASK_INCREMENT * gcsTASK_INCREMENT_PTR; -typedef struct _gcsTASK_INCREMENT -{ - /* Task ID (gcvTASK_INCREMENT). */ - IN gceTASK id; - - /* Address of the variable to increment. */ - IN gctUINT32 address; -} -gcsTASK_INCREMENT; - -typedef struct _gcsTASK_DECREMENT * gcsTASK_DECREMENT_PTR; -typedef struct _gcsTASK_DECREMENT -{ - /* Task ID (gcvTASK_DECREMENT). */ - IN gceTASK id; - - /* Address of the variable to decrement. */ - IN gctUINT32 address; -} -gcsTASK_DECREMENT; - -typedef struct _gcsTASK_SIGNAL * gcsTASK_SIGNAL_PTR; -typedef struct _gcsTASK_SIGNAL -{ - /* Task ID (gcvTASK_SIGNAL). */ - IN gceTASK id; - - /* Process owning the signal. */ - IN gctHANDLE process; - - /* Signal handle to signal. */ - IN gctSIGNAL signal; - -#if defined(__QNXNTO__) - IN gctINT32 coid; - IN gctINT32 rcvid; -#endif -} -gcsTASK_SIGNAL; - -typedef struct _gcsTASK_LOCKDOWN * gcsTASK_LOCKDOWN_PTR; -typedef struct _gcsTASK_LOCKDOWN -{ - /* Task ID (gcvTASK_LOCKDOWN). */ - IN gceTASK id; - - /* Address of the user space counter. */ - IN gctUINT32 userCounter; - - /* Address of the kernel space counter. */ - IN gctUINT32 kernelCounter; - - /* Process owning the signal. */ - IN gctHANDLE process; - - /* Signal handle to signal. */ - IN gctSIGNAL signal; -} -gcsTASK_LOCKDOWN; - -typedef struct _gcsTASK_UNLOCK_VIDEO_MEMORY * gcsTASK_UNLOCK_VIDEO_MEMORY_PTR; -typedef struct _gcsTASK_UNLOCK_VIDEO_MEMORY -{ - /* Task ID (gcvTASK_UNLOCK_VIDEO_MEMORY). */ - IN gceTASK id; - - /* Allocated video memory. */ - IN gctUINT64 node; -} -gcsTASK_UNLOCK_VIDEO_MEMORY; - -typedef struct _gcsTASK_FREE_VIDEO_MEMORY * gcsTASK_FREE_VIDEO_MEMORY_PTR; -typedef struct _gcsTASK_FREE_VIDEO_MEMORY -{ - /* Task ID (gcvTASK_FREE_VIDEO_MEMORY). */ - IN gceTASK id; - - /* Allocated video memory. */ - IN gctUINT32 node; -} -gcsTASK_FREE_VIDEO_MEMORY; - -typedef struct _gcsTASK_FREE_CONTIGUOUS_MEMORY * gcsTASK_FREE_CONTIGUOUS_MEMORY_PTR; -typedef struct _gcsTASK_FREE_CONTIGUOUS_MEMORY -{ - /* Task ID (gcvTASK_FREE_CONTIGUOUS_MEMORY). */ - IN gceTASK id; - - /* Number of bytes allocated. */ - IN gctSIZE_T bytes; - - /* Physical address of allocation. */ - IN gctPHYS_ADDR physical; - - /* Logical address of allocation. */ - IN gctPOINTER logical; -} -gcsTASK_FREE_CONTIGUOUS_MEMORY; - -#ifdef __cplusplus -} -#endif - -#endif /* __gc_hal_driver_h_ */ - - diff --git a/drivers/amlogic/npu/inc/gc_hal_eglplatform.h b/drivers/amlogic/npu/inc/gc_hal_eglplatform.h index 9f144c5..cf6ecc7 100644 --- a/drivers/amlogic/npu/inc/gc_hal_eglplatform.h +++ b/drivers/amlogic/npu/inc/gc_hal_eglplatform.h @@ -14,7 +14,7 @@ #ifndef __gc_hal_eglplatform_h_ #define __gc_hal_eglplatform_h_ -#include "shared/gc_hal_types.h" +#include "gc_hal_types.h" #include "gc_hal_base.h" #ifdef __cplusplus diff --git a/drivers/amlogic/npu/inc/gc_hal_engine.h b/drivers/amlogic/npu/inc/gc_hal_engine.h index a6a6afb..2aeb7b9 100644 --- a/drivers/amlogic/npu/inc/gc_hal_engine.h +++ b/drivers/amlogic/npu/inc/gc_hal_engine.h @@ -14,7 +14,7 @@ #ifndef __gc_hal_engine_h_ #define __gc_hal_engine_h_ -#include "shared/gc_hal_types.h" +#include "gc_hal_types.h" #include "gc_hal_enum.h" @@ -454,6 +454,13 @@ gcoSURF_DrawBlit( gscSURF_BLITDRAW_BLIT *Args ); +gceSTATUS +gcoSURF_DrawBlitDepth( + gcsSURF_VIEW *SrcView, + gcsSURF_VIEW *DstView, + gscSURF_BLITDRAW_BLIT *Args +); + /******************************************************************************\ ******************************** gcoINDEX Object ******************************* diff --git a/drivers/amlogic/npu/inc/gc_hal_engine_vg.h b/drivers/amlogic/npu/inc/gc_hal_engine_vg.h index fe1e412..6bff2ab 100644 --- a/drivers/amlogic/npu/inc/gc_hal_engine_vg.h +++ b/drivers/amlogic/npu/inc/gc_hal_engine_vg.h @@ -18,7 +18,7 @@ extern "C" { #endif -#include "shared/gc_hal_types.h" +#include "gc_hal_types.h" /******************************************************************************\ ******************************** VG Structures ******************************* diff --git a/drivers/amlogic/npu/inc/gc_hal_enum.h b/drivers/amlogic/npu/inc/gc_hal_enum.h index a8e182a..146348f 100644 --- a/drivers/amlogic/npu/inc/gc_hal_enum.h +++ b/drivers/amlogic/npu/inc/gc_hal_enum.h @@ -15,7 +15,7 @@ #define __gc_hal_enum_h_ #include "gc_hal_options.h" -#include "shared/gc_hal_enum.h" +#include "shared/gc_hal_enum_shared.h" #ifdef __cplusplus extern "C" { @@ -443,12 +443,22 @@ typedef enum _gce2D_TILE_STATUS_CONFIG } gce2D_TILE_STATUS_CONFIG; +typedef enum _gce2D_DEC400_MINOR_VERSION +{ + gcv2D_DEC400_MINOR_V1 = 1, + gcv2D_DEC400_MINOR_V2 = 2, + gcv2D_DEC400_MINOR_V3 = 3, +} +gce2D_DEC400_MINOR_VERSION; + + typedef enum _gce2D_QUERY { gcv2D_QUERY_RGB_ADDRESS_MIN_ALIGN = 0, gcv2D_QUERY_RGB_STRIDE_MIN_ALIGN, gcv2D_QUERY_YUV_ADDRESS_MIN_ALIGN, gcv2D_QUERY_YUV_STRIDE_MIN_ALIGN, + gcv2D_QUERY_DEC400_MINOR_VERSION, } gce2D_QUERY; @@ -1417,7 +1427,8 @@ typedef enum _gceFORMAT_CLASS gcvFORMAT_CLASS_DEPTH, gcvFORMAT_CLASS_ASTC, gcvFORMAT_CLASS_COMPRESSED, - gcvFORMAT_CLASS_OTHER + gcvFORMAT_CLASS_OTHER, + gcvFORMAT_CLASS_INTENSITY } gceFORMAT_CLASS; @@ -1538,8 +1549,9 @@ gceCLEAR; typedef enum _gceBLITDRAW_TYPE { - gcvBLITDRAW_CLEAR = 0, - gcvBLITDRAW_BLIT = 1, + gcvBLITDRAW_CLEAR = 0, + gcvBLITDRAW_BLIT = 1, + gcvBLITDRAW_BLIT_DEPTH = 2, /* last number, not a real type */ gcvBLITDRAW_NUM_TYPE @@ -2089,6 +2101,9 @@ enum /* Do not try slow pools (gcvPOOL_VIRTUAL) */ #define gcvALLOC_FLAG_FAST_POOLS 0x00000100 +/* Only accessed by GPU */ +#define gcvALLOC_FLAG_NON_CPU_ACCESS 0x00000200 + /* Import DMABUF. */ #define gcvALLOC_FLAG_DMABUF 0x00001000 /* Import USERMEMORY. */ @@ -2122,6 +2137,11 @@ enum /* Default chip ID means chip ID same as core index. */ #define gcvCHIP_ID_DEFAULT (~0U) +/* Tile status header size */ +#ifndef gcvTS_FC_HEADER_SIZE +#define gcvTS_FC_HEADER_SIZE 128 +#endif + /******************************************************************************\ ****************************** Object Declarations ***************************** \******************************************************************************/ @@ -2132,6 +2152,9 @@ typedef struct _gcsSTATE_DELTA * gcsSTATE_DELTA_PTR; typedef struct _gcsQUEUE * gcsQUEUE_PTR; typedef struct _gcoQUEUE * gcoQUEUE; typedef struct _gcsHAL_INTERFACE * gcsHAL_INTERFACE_PTR; +#if VIVANTE_PROFILER +typedef struct _gcsHAL_PROFILER_INTERFACE * gcsHAL_PROFILER_INTERFACE_PTR; +#endif typedef struct _gcs2D_PROFILE * gcs2D_PROFILE_PTR; diff --git a/drivers/amlogic/npu/inc/gc_hal_options.h b/drivers/amlogic/npu/inc/gc_hal_options.h index 45c8029..bddaa23 100644 --- a/drivers/amlogic/npu/inc/gc_hal_options.h +++ b/drivers/amlogic/npu/inc/gc_hal_options.h @@ -635,8 +635,12 @@ This define enables the use of VM for gckCommand and fence buffers. When non-zero, all video memory will be bufferable by default. */ #ifndef gcdENABLE_BUFFERABLE_VIDEO_MEMORY +#if gcdFPGA_BUILD +# define gcdENABLE_BUFFERABLE_VIDEO_MEMORY 0 +#else # define gcdENABLE_BUFFERABLE_VIDEO_MEMORY 1 #endif +#endif /* gcdENABLE_INFINITE_SPEED_HW @@ -717,7 +721,11 @@ This define enables the use of VM for gckCommand and fence buffers. */ #ifndef gcdENABLE_GPU_1M_PAGE #if !gcdSECURITY && defined(LINUX) +#ifdef EMULATOR +# define gcdENABLE_GPU_1M_PAGE 0 +#else # define gcdENABLE_GPU_1M_PAGE 1 +#endif #else # define gcdENABLE_GPU_1M_PAGE 0 #endif @@ -1004,11 +1012,7 @@ This define enables the use of VM for gckCommand and fence buffers. Expremental, under test only. Not ready for production. */ #ifndef gcdPARTIAL_FAST_CLEAR -#if defined(ANDROID) # define gcdPARTIAL_FAST_CLEAR 0 -#else -# define gcdPARTIAL_FAST_CLEAR 1 -#endif #endif /* @@ -1361,6 +1365,15 @@ This define enables the use of VM for gckCommand and fence buffers. # define gcdEXTERNAL_SRAM_DEFAULT_POOL 0 #endif +/* + gcdENABLE_SW_PREEMPTION + Enable software preemption if set to 1, disable by default. + Only support Linux OS currently. +*/ +#ifndef gcdENABLE_SW_PREEMPTION +# define gcdENABLE_SW_PREEMPTION 0 +#endif + #endif /* __gc_hal_options_h_ */ diff --git a/drivers/amlogic/npu/inc/gc_hal_priv.h b/drivers/amlogic/npu/inc/gc_hal_priv.h index 2c7c0d9..2632671 100644 --- a/drivers/amlogic/npu/inc/gc_hal_priv.h +++ b/drivers/amlogic/npu/inc/gc_hal_priv.h @@ -155,6 +155,9 @@ typedef enum _gcePATCH_ID gcvPATCH_KANZI, gcvPATCH_OPENCV_TEST_PHOTO, gcvPATCH_VKMARK, + gcvPATCH_VK_T3DSTRESSTEST, + gcvPATCH_VK_HDR02_FBBASICTONEMAPPING, + gcvPATCH_VK_BLOOM, gcvPATCH_COUNT } gcePATCH_ID; @@ -317,6 +320,18 @@ gcoHAL_GetPLS( OUT gcsPLS_PTR * PLS ); +gceSTATUS +gcoHAL_SetPriority( + IN gcoHAL Hal, + IN gctUINT32 PriorityID + ); + +gceSTATUS +gcoHAL_GetPriority( + IN gcoHAL Hal, + OUT gctUINT32 * PriorityID + ); + #ifdef __cplusplus } #endif diff --git a/drivers/amlogic/npu/inc/gc_hal_profiler.h b/drivers/amlogic/npu/inc/gc_hal_profiler.h index 465d7c0..2bcbfa7 100644 --- a/drivers/amlogic/npu/inc/gc_hal_profiler.h +++ b/drivers/amlogic/npu/inc/gc_hal_profiler.h @@ -14,7 +14,7 @@ #ifndef __gc_hal_profiler_h_ #define __gc_hal_profiler_h_ -#include "shared/gc_hal_profiler.h" +#include "shared/gc_hal_profiler_shared.h" #ifdef __cplusplus extern "C" { @@ -225,7 +225,9 @@ extern "C" { #define VPNG_MCZ 0x2e0000 #define VPNG_HI 0x2f0000 #define VPNG_L2 0x300000 -#define VPG_FINISH 0x310000 +#define VPNG_NN 0x310000 +#define VPNG_TP 0x320000 +#define VPG_FINISH 0x330000 #define VPG_END 0xff0000 /* Info. */ @@ -636,6 +638,134 @@ extern "C" { + MODULE_MEMORY_CONTROLLER_DEPTH_COUNTER_NUM + MODULE_HOST_INTERFACE0_COUNTER_NUM + MODULE_HOST_INTERFACE1_COUNTER_NUM \ + MODULE_GPUL2_CACHE_COUNTER_NUM) +#define VPNC_NN_LAYER_ID (VPNG_NN + 1) +#define VPNC_NN_LAYER_ID_OVFL (VPNG_NN + 2) +#define VPNC_NN_INSTR_INFO (VPNG_NN + 3) +#define VPNC_NN_TOTAL_BUSY_CYCLE (VPNG_NN + 4) +#define VPNC_NN_TOTAL_BUSY_CYCLE_OVFL (VPNG_NN + 5) +#define VPNC_NN_TOTAL_READ_CYCLE_DDR (VPNG_NN + 6) +#define VPNC_NN_TOTAL_READ_CYCLE_DDR_OVFL (VPNG_NN + 7) +#define VPNC_NN_TOTAL_READ_VALID_BW_DDR (VPNG_NN + 8) +#define VPNC_NN_TOTAL_READ_VALID_BW_DDR_OVFL (VPNG_NN + 9) +#define VPNC_NN_TOTAL_WRITE_CYCLE_DDR (VPNG_NN + 10) +#define VPNC_NN_TOTAL_WRITE_CYCLE_DDR_OVFL (VPNG_NN + 11) +#define VPNC_NN_TOTAL_WRITE_VALID_BW_DDR (VPNG_NN + 12) +#define VPNC_NN_TOTAL_WRITE_VALID_BW_DDR_OVFL (VPNG_NN + 13) +#define VPNC_NN_TOTAL_READ_CYCLE_SRAM (VPNG_NN + 14) +#define VPNC_NN_TOTAL_READ_CYCLE_SRAM_OVFL (VPNG_NN + 15) +#define VPNC_NN_TOTAL_WRITE_CYCLE_SRAM (VPNG_NN + 16) +#define VPNC_NN_TOTAL_WRITE_CYCLE_SRAM_OVFL (VPNG_NN + 17) +#define VPNC_NN_TOTAL_MAC_CYCLE (VPNG_NN + 18) +#define VPNC_NN_TOTAL_MAC_CYCLE_OVFL (VPNG_NN + 19) +#define VPNC_NN_TOTAL_MAC_COUNT (VPNG_NN + 20) +#define VPNC_NN_TOTAL_MAC_COUNT_OVFL (VPNG_NN + 21) +#define VPNC_NN_ZERO_COEF_SKIP_COUNT (VPNG_NN + 22) +#define VPNC_NN_ZERO_COEF_SKIP_COUNT_OVFL (VPNG_NN + 23) +#define VPNC_NN_NON_ZERO_COEF_COUNT (VPNG_NN + 24) +#define VPNC_NN_NON_ZERO_COEF_COUNT_OVFL (VPNG_NN + 25) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE_OVFL (VPNG_NN + 26) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE0 (VPNG_NN + 27) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE1 (VPNG_NN + 28) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE2 (VPNG_NN + 29) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE3 (VPNG_NN + 30) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE4 (VPNG_NN + 31) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE5 (VPNG_NN + 32) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE6 (VPNG_NN + 33) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE7 (VPNG_NN + 34) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE8 (VPNG_NN + 35) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE9 (VPNG_NN + 36) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE10 (VPNG_NN + 37) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE11 (VPNG_NN + 38) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE12 (VPNG_NN + 39) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE13 (VPNG_NN + 40) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE14 (VPNG_NN + 41) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE15 (VPNG_NN + 42) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE16 (VPNG_NN + 43) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE17 (VPNG_NN + 44) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE18 (VPNG_NN + 45) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE19 (VPNG_NN + 46) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE20 (VPNG_NN + 47) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE21 (VPNG_NN + 48) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE22 (VPNG_NN + 49) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE23 (VPNG_NN + 50) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE24 (VPNG_NN + 51) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE25 (VPNG_NN + 52) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE26 (VPNG_NN + 53) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE27 (VPNG_NN + 54) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE28 (VPNG_NN + 55) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE29 (VPNG_NN + 56) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE30 (VPNG_NN + 57) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE31 (VPNG_NN + 58) +#define VPNC_NN_COUNT (VPNC_NN_TOTAL_IDLE_CYCLE_CORE31 - VPNG_NN) + +/* HW: TP Probe Counters. */ +#define VPNC_TP_LAYER_ID (VPNG_TP + 1) +#define VPNC_TP_LAYER_ID_OVFL (VPNG_TP + 2) +#define VPNC_TP_TOTAL_BUSY_CYCLE (VPNG_TP + 3) +#define VPNC_TP_TOTAL_BUSY_CYCLE_OVFL (VPNG_TP + 4) +#define VPNC_TP_TOTAL_READ_BW_CACHE (VPNG_TP + 5) +#define VPNC_TP_TOTAL_READ_BW_CACHE_OVFL (VPNG_TP + 6) +#define VPNC_TP_TOTAL_WRITE_BW_CACHE (VPNG_TP + 7) +#define VPNC_TP_TOTAL_WRITE_BW_CACHE_OVFL (VPNG_TP + 8) +#define VPNC_TP_TOTAL_READ_BW_SRAM (VPNG_TP + 9) +#define VPNC_TP_TOTAL_READ_BW_SRAM_OVFL (VPNG_TP + 10) +#define VPNC_TP_TOTAL_WRITE_BW_SRAM (VPNG_TP + 11) +#define VPNC_TP_TOTAL_WRITE_BW_SRAM_OVFL (VPNG_TP + 12) +#define VPNC_TP_TOTAL_READ_BW_OCB (VPNG_TP + 13) +#define VPNC_TP_TOTAL_READ_BW_OCB_OVFL (VPNG_TP + 14) +#define VPNC_TP_TOTAL_WRITE_BW_OCB (VPNG_TP + 15) +#define VPNC_TP_TOTAL_WRITE_BW_OCB_OVFL (VPNG_TP + 16) +#define VPNC_TP_FC_PIX_CNT (VPNG_TP + 17) +#define VPNC_TP_FC_ZERO_SKIP_CNT (VPNG_TP + 18) +#define VPNC_TP_FC_PIX_CNT_OVFL (VPNG_TP + 19) +#define VPNC_TP_FC_ZERO_SKIP_CNT_OVFL (VPNG_TP + 20) +#define VPNC_TP_FC_COEF_CNT (VPNG_TP + 21) +#define VPNC_TP_FC_COEF_ZERO_CNT (VPNG_TP + 22) +#define VPNC_TP_FC_COEF_CNT_OVFL (VPNG_TP + 23) +#define VPNC_TP_FC_COEF_ZERO_CNT_OVFL (VPNG_TP + 24) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE0 (VPNG_TP + 25) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE0_OVFL (VPNG_TP + 26) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE1 (VPNG_TP + 27) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE1_OVFL (VPNG_TP + 28) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE2 (VPNG_TP + 29) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE2_OVFL (VPNG_TP + 30) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE3 (VPNG_TP + 31) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE3_OVFL (VPNG_TP + 32) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE4 (VPNG_TP + 33) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE4_OVFL (VPNG_TP + 34) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE5 (VPNG_TP + 35) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE5_OVFL (VPNG_TP + 36) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE6 (VPNG_TP + 37) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE6_OVFL (VPNG_TP + 38) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE7 (VPNG_TP + 39) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE7_OVFL (VPNG_TP + 40) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE8 (VPNG_TP + 41) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE8_OVFL (VPNG_TP + 42) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE9 (VPNG_TP + 43) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE9_OVFL (VPNG_TP + 44) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE10 (VPNG_TP + 45) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE10_OVFL (VPNG_TP + 46) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE11 (VPNG_TP + 47) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE11_OVFL (VPNG_TP + 48) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE12 (VPNG_TP + 49) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE12_OVFL (VPNG_TP + 50) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE13 (VPNG_TP + 51) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE13_OVFL (VPNG_TP + 52) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE14 (VPNG_TP + 53) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE14_OVFL (VPNG_TP + 54) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE15 (VPNG_TP + 55) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE15_OVFL (VPNG_TP + 56) +#define VPNC_TP_COUNT (VPNC_TP_TOTAL_IDLE_CYCLE_CORE15_OVFL - VPNG_TP) + +#define MODULE_NN_BASE_COUNTER_NUM 0x6 +/*#define MODULE_NN_RESERVED_COUNTER_NUM 0x9*/ +#define MODULE_NN_IDLE_COUNTER_NUM 0x9 +#define MODULE_NN_COUNTER_NUM (MODULE_NN_BASE_COUNTER_NUM + MODULE_NN_RESERVED_COUNTER_NUM + MODULE_NN_IDLE_COUNTER_NUM) + +#define TOTAL_VIP_COUNTER_NUMBER (VPNC_TP_COUNT + VPNC_NN_COUNT) +#define TOTAL_VIP_MODULE_NUMBER 2 +#define MODULE_TP_COUNTER_NUM 0xE +#define TOTAL_VIP_PROBE_NUMBER (MODULE_NN_COUNTER_NUM + MODULE_TP_COUNTER_NUM) #ifdef ANDROID #define DEFAULT_PROFILE_FILE_NAME "/sdcard/vprofiler.vpd" @@ -740,8 +870,30 @@ extern "C" { { \ gctUINT32 i; \ gctUINT32_PTR Memory = memory; \ + gctUINT32 total_probe_number = gcoPROFILER_GetProbeNumber(clusterCount, hostInterface1); \ counter = 0; \ - Memory = memory + TOTAL_PROBE_NUMBER * CoreId * (1 << clusterIDWidth); \ + Memory = memory + total_probe_number * CoreId * (1 << clusterIDWidth); \ + for (i = 0; i < (gctUINT32)(1 << clusterIDWidth); i++) \ + { \ + counter += *(Memory + (counterId + offset) * (1 << clusterIDWidth) + i); \ + } \ + } \ + } \ + while (gcvFALSE) + +#define gcmGET_VIPCOUNTER(counter, counterId) \ + do \ + { \ + if (*(memory + (counterId + offset) * (1 << clusterIDWidth)) == 0xdeaddead) \ + { \ + counter = 0xdeaddead; \ + } \ + else \ + { \ + gctUINT32 i; \ + gctUINT32_PTR Memory = memory; \ + counter = 0; \ + Memory = memory + TOTAL_VIP_PROBE_NUMBER * CoreId * (1 << clusterIDWidth); \ for (i = 0; i < (gctUINT32)(1 << clusterIDWidth); i++) \ { \ counter += *(Memory + (counterId + offset) * (1 << clusterIDWidth) + i); \ @@ -761,7 +913,8 @@ extern "C" { { \ gctUINT32 i; \ gctUINT32_PTR Memory = memory; \ - Memory = memory + TOTAL_PROBE_NUMBER * CoreId * (1 << clusterIDWidth); \ + gctUINT32 total_probe_number = gcoPROFILER_GetProbeNumber(clusterCount, hostInterface1); \ + Memory = memory + total_probe_number * CoreId * (1 << clusterIDWidth); \ for (i = 0; i < (gctUINT32)(1 << clusterIDWidth); i++) \ { \ maxLatency += ((*(Memory + (counterId + offset) * (1 << clusterIDWidth) + i) & 0xfff000) >> 12); \ @@ -781,6 +934,7 @@ typedef struct gcsCounterBuffer * gcsCounterBuffer_PTR; struct gcsCounterBuffer { gcsPROFILER_COUNTERS *counters; + gcsPROFILER_VIP_PROBE_COUNTERS *vipCounters; gctHANDLE couterBufobj; gctUINT32 probeAddress; gctPOINTER logicalAddress; @@ -803,6 +957,7 @@ struct _gcoPROFILER gctBOOL enablePrint; gctBOOL disableProbe; gctBOOL probeMode; + gctBOOL vipProbe; gctFILE file; gctCHAR* fileName; @@ -875,6 +1030,13 @@ gceSTATUS gcoPROFILER_Flush( IN gcoPROFILER Profiler ); + +gctUINT32 +gcoPROFILER_GetProbeNumber( + IN gctUINT32 clusterCount, + IN gctBOOL hostInterface1 + ); + #ifdef __cplusplus } #endif diff --git a/drivers/amlogic/npu/inc/gc_hal_raster.h b/drivers/amlogic/npu/inc/gc_hal_raster.h index 4b60ba5..5b7cab4 100644 --- a/drivers/amlogic/npu/inc/gc_hal_raster.h +++ b/drivers/amlogic/npu/inc/gc_hal_raster.h @@ -15,7 +15,7 @@ #define __gc_hal_raster_h_ #include "gc_hal_enum.h" -#include "shared/gc_hal_types.h" +#include "gc_hal_types.h" #ifdef __cplusplus extern "C" { diff --git a/drivers/amlogic/npu/inc/gc_hal_rename.h b/drivers/amlogic/npu/inc/gc_hal_rename.h deleted file mode 100644 index 5a12efc..0000000 --- a/drivers/amlogic/npu/inc/gc_hal_rename.h +++ /dev/null @@ -1,182 +0,0 @@ -/**************************************************************************** -* -* Copyright (c) 2005 - 2019 by Vivante Corp. All rights reserved. -* -* The material in this file is confidential and contains trade secrets -* of Vivante Corporation. This is proprietary information owned by -* Vivante Corporation. No part of this work may be disclosed, -* reproduced, copied, transmitted, or used in any way for any purpose, -* without the express written permission of Vivante Corporation. -* -*****************************************************************************/ - - -#ifndef __gc_hal_rename_h_ -#define __gc_hal_rename_h_ - - -#if defined(_HAL2D_APPENDIX) - -#define _HAL2D_RENAME_2(api, appendix) api ## appendix -#define _HAL2D_RENAME_1(api, appendix) _HAL2D_RENAME_2(api, appendix) -#define gcmHAL2D(api) _HAL2D_RENAME_1(api, _HAL2D_APPENDIX) - - -#define gckOS_Construct gcmHAL2D(gckOS_Construct) -#define gckOS_Destroy gcmHAL2D(gckOS_Destroy) -#define gckOS_QueryVideoMemory gcmHAL2D(gckOS_QueryVideoMemory) -#define gckOS_Allocate gcmHAL2D(gckOS_Allocate) -#define gckOS_Free gcmHAL2D(gckOS_Free) -#define gckOS_AllocateMemory gcmHAL2D(gckOS_AllocateMemory) -#define gckOS_FreeMemory gcmHAL2D(gckOS_FreeMemory) -#define gckOS_LockPages gcmHAL2D(gckOS_LockPages) -#define gckOS_UnlockPages gcmHAL2D(gckOS_UnlockPages) -#define gckOS_FreePagedMemory gcmHAL2D(gckOS_FreePagedMemory) -#define gckOS_AllocateNonPagedMemory gcmHAL2D(gckOS_AllocateNonPagedMemory) -#define gckOS_FreeNonPagedMemory gcmHAL2D(gckOS_FreeNonPagedMemory) -#define gckOS_GetPageSize gcmHAL2D(gckOS_GetPageSize) -#define gckOS_GetPhysicalAddress gcmHAL2D(gckOS_GetPhysicalAddress) -#define gckOS_UserLogicalToPhysical gcmHAL2D(gckOS_UserLogicalToPhysical) -#define gckOS_MapPhysical gcmHAL2D(gckOS_MapPhysical) -#define gckOS_UnmapPhysical gcmHAL2D(gckOS_UnmapPhysical) -#define gckOS_ReadRegister gcmHAL2D(gckOS_ReadRegister) -#define gckOS_WriteRegister gcmHAL2D(gckOS_WriteRegister) -#define gckOS_WriteMemory gcmHAL2D(gckOS_WriteMemory) -#define gckOS_MapMemory gcmHAL2D(gckOS_MapMemory) -#define gckOS_UnmapMemory gcmHAL2D(gckOS_UnmapMemory) -#define gckOS_UnmapMemoryEx gcmHAL2D(gckOS_UnmapMemoryEx) -#define gckOS_CreateMutex gcmHAL2D(gckOS_CreateMutex) -#define gckOS_DeleteMutex gcmHAL2D(gckOS_DeleteMutex) -#define gckOS_AcquireMutex gcmHAL2D(gckOS_AcquireMutex) -#define gckOS_ReleaseMutex gcmHAL2D(gckOS_ReleaseMutex) -#define gckOS_AtomicExchange gcmHAL2D(gckOS_AtomicExchange) -#define gckOS_AtomicExchangePtr gcmHAL2D(gckOS_AtomicExchangePtr) -#define gckOS_AtomConstruct gcmHAL2D(gckOS_AtomConstruct) -#define gckOS_AtomDestroy gcmHAL2D(gckOS_AtomDestroy) -#define gckOS_AtomGet gcmHAL2D(gckOS_AtomGet) -#define gckOS_AtomIncrement gcmHAL2D(gckOS_AtomIncrement) -#define gckOS_AtomDecrement gcmHAL2D(gckOS_AtomDecrement) -#define gckOS_Delay gcmHAL2D(gckOS_Delay) -#define gckOS_GetTime gcmHAL2D(gckOS_GetTime) -#define gckOS_MemoryBarrier gcmHAL2D(gckOS_MemoryBarrier) -#define gckOS_MapUserPointer gcmHAL2D(gckOS_MapUserPointer) -#define gckOS_UnmapUserPointer gcmHAL2D(gckOS_UnmapUserPointer) -#define gckOS_QueryNeedCopy gcmHAL2D(gckOS_QueryNeedCopy) -#define gckOS_CopyFromUserData gcmHAL2D(gckOS_CopyFromUserData) -#define gckOS_CopyToUserData gcmHAL2D(gckOS_CopyToUserData) -#define gckOS_SuspendInterrupt gcmHAL2D(gckOS_SuspendInterrupt) -#define gckOS_ResumeInterrupt gcmHAL2D(gckOS_ResumeInterrupt) -#define gckOS_GetBaseAddress gcmHAL2D(gckOS_GetBaseAddress) -#define gckOS_MemCopy gcmHAL2D(gckOS_MemCopy) -#define gckOS_ZeroMemory gcmHAL2D(gckOS_ZeroMemory) -#define gckOS_DeviceControl gcmHAL2D(gckOS_DeviceControl) -#define gckOS_GetProcessID gcmHAL2D(gckOS_GetProcessID) -#define gckOS_GetThreadID gcmHAL2D(gckOS_GetThreadID) -#define gckOS_CreateSignal gcmHAL2D(gckOS_CreateSignal) -#define gckOS_DestroySignal gcmHAL2D(gckOS_DestroySignal) -#define gckOS_Signal gcmHAL2D(gckOS_Signal) -#define gckOS_WaitSignal gcmHAL2D(gckOS_WaitSignal) -#define gckOS_MapSignal gcmHAL2D(gckOS_MapSignal) -#define gckOS_CreateUserSignal gcmHAL2D(gckOS_CreateUserSignal) -#define gckOS_DestroyUserSignal gcmHAL2D(gckOS_DestroyUserSignal) -#define gckOS_WaitUserSignal gcmHAL2D(gckOS_WaitUserSignal) -#define gckOS_SignalUserSignal gcmHAL2D(gckOS_SignalUserSignal) -#define gckOS_UserSignal gcmHAL2D(gckOS_UserSignal) -#define gckOS_UserSignal gcmHAL2D(gckOS_UserSignal) -#define gckOS_SetDebugLevel gcmHAL2D(gckOS_SetDebugLevel) -#define gckOS_SetDebugZone gcmHAL2D(gckOS_SetDebugZone) -#define gckOS_SetDebugLevelZone gcmHAL2D(gckOS_SetDebugLevelZone) -#define gckOS_SetDebugZones gcmHAL2D(gckOS_SetDebugZones) -#define gckOS_SetDebugFile gcmHAL2D(gckOS_SetDebugFile) -#define gckOS_Broadcast gcmHAL2D(gckOS_Broadcast) -#define gckOS_SetGPUPower gcmHAL2D(gckOS_SetGPUPower) -#define gckOS_CreateSemaphore gcmHAL2D(gckOS_CreateSemaphore) -#define gckOS_DestroySemaphore gcmHAL2D(gckOS_DestroySemaphore) -#define gckOS_AcquireSemaphore gcmHAL2D(gckOS_AcquireSemaphore) -#define gckOS_ReleaseSemaphore gcmHAL2D(gckOS_ReleaseSemaphore) -#define gckHEAP_Construct gcmHAL2D(gckHEAP_Construct) -#define gckHEAP_Destroy gcmHAL2D(gckHEAP_Destroy) -#define gckHEAP_Allocate gcmHAL2D(gckHEAP_Allocate) -#define gckHEAP_Free gcmHAL2D(gckHEAP_Free) -#define gckHEAP_ProfileStart gcmHAL2D(gckHEAP_ProfileStart) -#define gckHEAP_ProfileEnd gcmHAL2D(gckHEAP_ProfileEnd) -#define gckHEAP_Test gcmHAL2D(gckHEAP_Test) -#define gckVIDMEM_Construct gcmHAL2D(gckVIDMEM_Construct) -#define gckVIDMEM_Destroy gcmHAL2D(gckVIDMEM_Destroy) -#define gckKERNEL_Construct gcmHAL2D(gckKERNEL_Construct) -#define gckKERNEL_Destroy gcmHAL2D(gckKERNEL_Destroy) -#define gckKERNEL_Dispatch gcmHAL2D(gckKERNEL_Dispatch) -#define gckKERNEL_QueryVideoMemory gcmHAL2D(gckKERNEL_QueryVideoMemory) -#define gckKERNEL_GetVideoMemoryPool gcmHAL2D(gckKERNEL_GetVideoMemoryPool) -#define gckKERNEL_UnmapVideoMemory gcmHAL2D(gckKERNEL_UnmapVideoMemory) -#define gckKERNEL_MapMemory gcmHAL2D(gckKERNEL_MapMemory) -#define gckKERNEL_UnmapMemory gcmHAL2D(gckKERNEL_UnmapMemory) -#define gckKERNEL_Notify gcmHAL2D(gckKERNEL_Notify) -#define gckKERNEL_Recovery gcmHAL2D(gckKERNEL_Recovery) -#define gckKERNEL_OpenUserData gcmHAL2D(gckKERNEL_OpenUserData) -#define gckKERNEL_CloseUserData gcmHAL2D(gckKERNEL_CloseUserData) -#define gckHARDWARE_Construct gcmHAL2D(gckHARDWARE_Construct) -#define gckHARDWARE_Destroy gcmHAL2D(gckHARDWARE_Destroy) -#define gckHARDWARE_QuerySystemMemory gcmHAL2D(gckHARDWARE_QuerySystemMemory) -#define gckHARDWARE_BuildVirtualAddress gcmHAL2D(gckHARDWARE_BuildVirtualAddress) -#define gckHARDWARE_QueryCommandBuffer gcmHAL2D(gckHARDWARE_QueryCommandBuffer) -#define gckHARDWARE_PipeSelect gcmHAL2D(gckHARDWARE_PipeSelect) -#define gckHARDWARE_QueryMemory gcmHAL2D(gckHARDWARE_QueryMemory) -#define gckHARDWARE_QueryChipIdentity gcmHAL2D(gckHARDWARE_QueryChipIdentity) -#define gckHARDWARE_QueryChipSpecs gcmHAL2D(gckHARDWARE_QueryChipSpecs) -#define gckHARDWARE_ConvertFormat gcmHAL2D(gckHARDWARE_ConvertFormat) -#define gckHARDWARE_SplitMemory gcmHAL2D(gckHARDWARE_SplitMemory) -#define gckHARDWARE_AlignToTile gcmHAL2D(gckHARDWARE_AlignToTile) -#define gckHARDWARE_UpdateQueueTail gcmHAL2D(gckHARDWARE_UpdateQueueTail) -#define gckHARDWARE_ConvertLogical gcmHAL2D(gckHARDWARE_ConvertLogical) -#define gckHARDWARE_Interrupt gcmHAL2D(gckHARDWARE_Interrupt) -#define gckHARDWARE_Notify gcmHAL2D(gckHARDWARE_Notify) -#define gckHARDWARE_SetMMU gcmHAL2D(gckHARDWARE_SetMMU) -#define gckHARDWARE_FlushMMU gcmHAL2D(gckHARDWARE_FlushMMU) -#define gckHARDWARE_GetIdle gcmHAL2D(gckHARDWARE_GetIdle) -#define gckHARDWARE_Flush gcmHAL2D(gckHARDWARE_Flush) -#define gckHARDWARE_SetFastClear gcmHAL2D(gckHARDWARE_SetFastClear) -#define gckHARDWARE_ReadInterrupt gcmHAL2D(gckHARDWARE_ReadInterrupt) -#define gckHARDWARE_SetPowerManagementState gcmHAL2D(gckHARDWARE_SetPowerManagementState) -#define gckHARDWARE_QueryPowerManagementState gcmHAL2D(gckHARDWARE_QueryPowerManagementState) -#define gckHARDWARE_ProfileEngine2D gcmHAL2D(gckHARDWARE_ProfileEngine2D) -#define gckHARDWARE_InitializeHardware gcmHAL2D(gckHARDWARE_InitializeHardware) -#define gckHARDWARE_Reset gcmHAL2D(gckHARDWARE_Reset) -#define gckINTERRUPT_Construct gcmHAL2D(gckINTERRUPT_Construct) -#define gckINTERRUPT_Destroy gcmHAL2D(gckINTERRUPT_Destroy) -#define gckINTERRUPT_SetHandler gcmHAL2D(gckINTERRUPT_SetHandler) -#define gckINTERRUPT_Notify gcmHAL2D(gckINTERRUPT_Notify) -#define gckMMU_Construct gcmHAL2D(gckMMU_Construct) -#define gckMMU_Destroy gcmHAL2D(gckMMU_Destroy) -#define gckMMU_AllocatePages gcmHAL2D(gckMMU_AllocatePages) -#define gckMMU_FreePages gcmHAL2D(gckMMU_FreePages) -#define gckMMU_Test gcmHAL2D(gckMMU_Test) -#define gckHARDWARE_QueryProfileRegisters gcmHAL2D(gckHARDWARE_QueryProfileRegisters) - - -#define FindMdlMap gcmHAL2D(FindMdlMap) -#define OnProcessExit gcmHAL2D(OnProcessExit) - -#define gckGALDEVICE_Construct gcmHAL2D(gckGALDEVICE_Construct) -#define gckGALDEVICE_Start gcmHAL2D(gckGALDEVICE_Start) -#define gckGALDEVICE_Destroy gcmHAL2D(gckGALDEVICE_Destroy) -#define gckGALDEVICE_FreeMemory gcmHAL2D(gckGALDEVICE_FreeMemory) -#define gckGALDEVICE_AllocateMemory gcmHAL2D(gckGALDEVICE_AllocateMemory) -#define gckGALDEVICE_Stop gcmHAL2D(gckGALDEVICE_Stop) -#define gckOS_Print gcmHAL2D(gckOS_Print) -#define gckOS_DebugBreak gcmHAL2D(gckOS_DebugBreak) -#define gckOS_Verify gcmHAL2D(gckOS_Verify) -#define gckOS_DebugFatal gcmHAL2D(gckOS_DebugFatal) -#define gckOS_DebugTrace gcmHAL2D(gckOS_DebugTrace) -#define gckHARDWARE_GetBaseAddress gcmHAL2D(gckHARDWARE_GetBaseAddress) -#define gckKERNEL_AttachProcess gcmHAL2D(gckKERNEL_AttachProcess) -#define gckKERNEL_AttachProcessEx gcmHAL2D(gckKERNEL_AttachProcessEx) -#define gckHARDWARE_QueryIdle gcmHAL2D(gckHARDWARE_QueryIdle) -#define gckOS_DebugTraceZone gcmHAL2D(gckOS_DebugTraceZone) -#define gckHARDWARE_NeedBaseAddress gcmHAL2D(gckHARDWARE_NeedBaseAddress) - -#endif - -#endif /* __gc_hal_rename_h_ */ - - diff --git a/drivers/amlogic/npu/inc/gc_hal_resource.h b/drivers/amlogic/npu/inc/gc_hal_resource.h deleted file mode 100644 index 7816945..0000000 --- a/drivers/amlogic/npu/inc/gc_hal_resource.h +++ /dev/null @@ -1,27 +0,0 @@ -/**************************************************************************** -* -* Copyright (c) 2005 - 2019 by Vivante Corp. All rights reserved. -* -* The material in this file is confidential and contains trade secrets -* of Vivante Corporation. This is proprietary information owned by -* Vivante Corporation. No part of this work may be disclosed, -* reproduced, copied, transmitted, or used in any way for any purpose, -* without the express written permission of Vivante Corporation. -* -*****************************************************************************/ - - -#ifndef __gc_hal_resource_h_ -#define __gc_hal_resource_h_ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* __gc_hal_resource_h_ */ - - diff --git a/drivers/amlogic/npu/inc/gc_hal_types.h b/drivers/amlogic/npu/inc/gc_hal_types.h index e53c0ed..630d5cb 100644 --- a/drivers/amlogic/npu/inc/gc_hal_types.h +++ b/drivers/amlogic/npu/inc/gc_hal_types.h @@ -1,6 +1,6 @@ /**************************************************************************** * -* Copyright (c) 2005 - 2019 by Vivante Corp. All rights reserved. +* Copyright (c) 2005 - 2020 by Vivante Corp. All rights reserved. * * The material in this file is confidential and contains trade secrets * of Vivante Corporation. This is proprietary information owned by @@ -11,1101 +11,7 @@ *****************************************************************************/ -#ifndef __gc_hal_types_h_ -#define __gc_hal_types_h_ +#include "shared/gc_hal_types_shared.h" -#include "gc_hal_version.h" -#include "gc_hal_options.h" - -#if !defined(VIV_KMD) -#if defined(__KERNEL__) -#include "linux/version.h" -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) - typedef unsigned long uintptr_t; -# endif -# include "linux/types.h" -#elif defined(UNDER_CE) -#include -typedef signed char int8_t; -typedef short int16_t; -typedef int int32_t; -typedef long long int64_t; -typedef unsigned char uint8_t; -typedef unsigned short uint16_t; -typedef unsigned int uint32_t; -typedef unsigned long long uint64_t; -#elif defined(_MSC_VER) && (_MSC_VER <= 1500) -#include -#include "vadefs.h" -#elif defined(__QNXNTO__) -#define _QNX_SOURCE -#include -#include -#else -#include -#include -#include -#endif -#endif - -#ifdef _WIN32 -#pragma warning(disable:4127) /* Conditional expression is constant (do { } while(0)). */ -#pragma warning(disable:4100) /* Unreferenced formal parameter. */ -#pragma warning(disable:4204) /* Non-constant aggregate initializer (C99). */ -#pragma warning(disable:4131) /* Uses old-style declarator. */ -#pragma warning(disable:4206) /* Translation unit is empty. */ -#pragma warning(disable:4214) /* Nonstandard extension used : - ** bit field types other than int. */ -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/******************************************************************************\ -** Platform macros. -*/ - -#if defined(__GNUC__) -# define gcdHAS_ELLIPSIS 1 /* GCC always has it. */ -#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) -# define gcdHAS_ELLIPSIS 1 /* C99 has it. */ -#elif defined(_MSC_VER) && (_MSC_VER >= 1500) -# define gcdHAS_ELLIPSIS 1 /* MSVC 2007+ has it. */ -#elif defined(UNDER_CE) -#if UNDER_CE >= 600 -# define gcdHAS_ELLIPSIS 1 -# else -# define gcdHAS_ELLIPSIS 0 -# endif -#else -# error "gcdHAS_ELLIPSIS: Platform could not be determined" -#endif - -/******************************************************************************\ -************************************ Keyword *********************************** -\******************************************************************************/ - -#if defined(ANDROID) && defined(__BIONIC_FORTIFY) -#if defined(__clang__) -# define gcmINLINE __inline__ __attribute__ ((always_inline)) __attribute__ ((gnu_inline)) -# else -# define gcmINLINE __inline__ __attribute__ ((always_inline)) __attribute__ ((gnu_inline)) __attribute__ ((artificial)) -# endif -#elif ((defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || defined(__APPLE__)) -# define gcmINLINE inline /* C99 keyword. */ -#elif defined(__GNUC__) -# define gcmINLINE __inline__ /* GNU keyword. */ -#elif defined(_MSC_VER) || defined(UNDER_CE) -# define gcmINLINE __inline /* Internal keyword. */ -#else -# error "gcmINLINE: Platform could not be determined" -#endif - - -/* Possible debug flags. */ -#define gcdDEBUG_NONE 0 -#define gcdDEBUG_ALL (1 << 0) -#define gcdDEBUG_FATAL (1 << 1) -#define gcdDEBUG_TRACE (1 << 2) -#define gcdDEBUG_BREAK (1 << 3) -#define gcdDEBUG_ASSERT (1 << 4) -#define gcdDEBUG_CODE (1 << 5) -#define gcdDEBUG_STACK (1 << 6) - -#define gcmIS_DEBUG(flag) (gcdDEBUG & (flag | gcdDEBUG_ALL) ) - -#ifndef gcdDEBUG -#if (defined(DBG) && DBG) || defined(DEBUG) || defined(_DEBUG) -# define gcdDEBUG gcdDEBUG_ALL -# else -# define gcdDEBUG gcdDEBUG_NONE -# endif -#endif - -#ifdef _USRDLL -#ifdef _MSC_VER -#ifdef HAL_EXPORTS -# define HALAPI __declspec(dllexport) -# else -# define HALAPI __declspec(dllimport) -# endif -# define HALDECL __cdecl -# else -#ifdef HAL_EXPORTS -# define HALAPI -# else -# define HALAPI extern -# endif -# endif -#else -# define HALAPI -# define HALDECL -#endif - -/******************************************************************************\ -********************************** Common Types ******************************** -\******************************************************************************/ - -#define gcvFALSE 0 -#define gcvTRUE 1 - -#define gcvINFINITE ((gctUINT32) ~0U) - -#define gcvINVALID_HANDLE ((gctHANDLE) ~0U) - -typedef int gctBOOL; -typedef gctBOOL * gctBOOL_PTR; - -typedef int gctINT; -typedef signed char gctINT8; -typedef signed short gctINT16; -typedef signed int gctINT32; -typedef signed long long gctINT64; - -typedef gctINT * gctINT_PTR; -typedef gctINT8 * gctINT8_PTR; -typedef gctINT16 * gctINT16_PTR; -typedef gctINT32 * gctINT32_PTR; -typedef gctINT64 * gctINT64_PTR; - -typedef unsigned int gctUINT; -typedef unsigned char gctUINT8; -typedef unsigned short gctUINT16; -typedef unsigned int gctUINT32; -typedef unsigned long long gctUINT64; -typedef uintptr_t gctUINTPTR_T; -typedef ptrdiff_t gctPTRDIFF_T; - -typedef gctUINT * gctUINT_PTR; -typedef gctUINT8 * gctUINT8_PTR; -typedef gctUINT16 * gctUINT16_PTR; -typedef gctUINT32 * gctUINT32_PTR; -typedef gctUINT64 * gctUINT64_PTR; - -typedef size_t gctSIZE_T; -typedef gctSIZE_T * gctSIZE_T_PTR; -typedef gctUINT32 gctTRACE; - -#ifdef __cplusplus -# define gcvNULL 0 -#else -# define gcvNULL ((void *) 0) -#endif - -#define gcvMAXINT8 0x7f -#define gcvMININT8 0x80 -#define gcvMAXINT16 0x7fff -#define gcvMININT16 0x8000 -#define gcvMAXINT32 0x7fffffff -#define gcvMININT32 0x80000000 -#define gcvMAXINT64 0x7fffffffffffffff -#define gcvMININT64 0x8000000000000000 -#define gcvMAXUINT8 0xff -#define gcvMINUINT8 0x0 -#define gcvMAXUINT16 0xffff -#define gcvMINUINT16 0x0 -#define gcvMAXUINT32 0xffffffff -#define gcvMINUINT32 0x0 -#define gcvMAXUINT64 0xffffffffffffffff -#define gcvMINUINT64 0x0 -#define gcvMAXUINTPTR_T (~(gctUINTPTR_T)0) -#define gcvMAXSIZE_T ((gctSIZE_T)(-1)) - -typedef float gctFLOAT; -typedef signed int gctFIXED_POINT; -typedef float * gctFLOAT_PTR; - -typedef void * gctPHYS_ADDR; -typedef void * gctHANDLE; -typedef void * gctFILE; -typedef void * gctSIGNAL; -typedef void * gctWINDOW; -typedef void * gctIMAGE; -typedef void * gctSHBUF; - -typedef void * gctSEMAPHORE; - -typedef void * gctPOINTER; -typedef const void * gctCONST_POINTER; - -typedef char gctCHAR; -typedef signed char gctSIGNED_CHAR; -typedef unsigned char gctUNSIGNED_CHAR; -typedef char * gctSTRING; -typedef const char * gctCONST_STRING; - -typedef gctUINT64 gctPHYS_ADDR_T; - -typedef struct _gcsCOUNT_STRING -{ - gctSIZE_T Length; - gctCONST_STRING String; -} -gcsCOUNT_STRING; - -typedef union _gcuFLOAT_UINT32 -{ - gctFLOAT f; - gctUINT32 u; -} -gcuFLOAT_UINT32; - -/* Fixed point constants. */ -#define gcvZERO_X ((gctFIXED_POINT) 0x00000000) -#define gcvHALF_X ((gctFIXED_POINT) 0x00008000) -#define gcvONE_X ((gctFIXED_POINT) 0x00010000) -#define gcvNEGONE_X ((gctFIXED_POINT) 0xFFFF0000) -#define gcvTWO_X ((gctFIXED_POINT) 0x00020000) - - - -#define gcmFIXEDCLAMP_NEG1_TO_1(_x) \ - (((_x) < gcvNEGONE_X) \ - ? gcvNEGONE_X \ - : (((_x) > gcvONE_X) \ - ? gcvONE_X \ - : (_x))) - -#define gcmFLOATCLAMP_NEG1_TO_1(_f) \ - (((_f) < -1.0f) \ - ? -1.0f \ - : (((_f) > 1.0f) \ - ? 1.0f \ - : (_f))) - - -#define gcmFIXEDCLAMP_0_TO_1(_x) \ - (((_x) < 0) \ - ? 0 \ - : (((_x) > gcvONE_X) \ - ? gcvONE_X \ - : (_x))) - -#define gcmFLOATCLAMP_0_TO_1(_f) \ - (((_f) < 0.0f) \ - ? 0.0f \ - : (((_f) > 1.0f) \ - ? 1.0f \ - : (_f))) - - -/******************************************************************************\ -******************************* Multicast Values ******************************* -\******************************************************************************/ - -/* Value types. */ -typedef enum _gceVALUE_TYPE -{ - gcvVALUE_UINT = 0x0, - gcvVALUE_FIXED, - gcvVALUE_FLOAT, - gcvVALUE_INT, - - /* - ** The value need be unsigned denormalized. clamp (0.0-1.0) should be done first. - */ - gcvVALUE_FLAG_UNSIGNED_DENORM = 0x00010000, - - /* - ** The value need be signed denormalized. clamp (-1.0-1.0) should be done first. - */ - gcvVALUE_FLAG_SIGNED_DENORM = 0x00020000, - - /* - ** The value need to gammar - */ - gcvVALUE_FLAG_GAMMAR = 0x00040000, - - /* - ** The value need to convert from float to float16 - */ - gcvVALUE_FLAG_FLOAT_TO_FLOAT16 = 0x0080000, - - /* - ** Mask for flag field. - */ - gcvVALUE_FLAG_MASK = 0xFFFF0000, -} -gceVALUE_TYPE; - -/* Value unions. */ -typedef union _gcuVALUE -{ - gctUINT uintValue; - gctFIXED_POINT fixedValue; - gctFLOAT floatValue; - gctINT intValue; -} -gcuVALUE; - - - - -/* Stringizing macro. */ -#define gcmSTRING(Value) #Value - -/******************************************************************************\ -******************************* Fixed Point Math ******************************* -\******************************************************************************/ - -#define gcmXMultiply(x1, x2) gcoMATH_MultiplyFixed(x1, x2) -#define gcmXDivide(x1, x2) gcoMATH_DivideFixed(x1, x2) -#define gcmXMultiplyDivide(x1, x2, x3) gcoMATH_MultiplyDivideFixed(x1, x2, x3) - -/* 2D Engine profile. */ -typedef struct _gcs2D_PROFILE -{ - /* Cycle count. - 32bit counter incremented every 2D clock cycle. - Wraps back to 0 when the counter overflows. - */ - gctUINT32 cycleCount; - - /* Pixels rendered by the 2D engine. - Resets to 0 every time it is read. */ - gctUINT32 pixelsRendered; -} -gcs2D_PROFILE; - -/* Macro to combine four characters into a Charcater Code. */ -#define gcmCC(c1, c2, c3, c4) \ -(\ - (char) (c1) \ - | \ - ((char) (c2) << 8) \ - | \ - ((char) (c3) << 16) \ - | \ - ((char) (c4) << 24) \ -) - -#define gcmPRINTABLE(c) ((((c) >= ' ') && ((c) <= '}')) ? ((c) != '%' ? (c) : ' ') : ' ') - -#define gcmCC_PRINT(cc) \ - gcmPRINTABLE((char) ((cc) & 0xFF)), \ - gcmPRINTABLE((char) (((cc) >> 8) & 0xFF)), \ - gcmPRINTABLE((char) (((cc) >> 16) & 0xFF)), \ - gcmPRINTABLE((char) (((cc) >> 24) & 0xFF)) - -/******************************************************************************\ -****************************** Function Parameters ***************************** -\******************************************************************************/ - -#define IN -#define OUT -#define INOUT -#define OPTIONAL - -/******************************************************************************\ -********************************* Status Codes ********************************* -\******************************************************************************/ - -typedef enum _gceSTATUS -{ - gcvSTATUS_OK = 0, - gcvSTATUS_FALSE = 0, - gcvSTATUS_TRUE = 1, - gcvSTATUS_NO_MORE_DATA = 2, - gcvSTATUS_CACHED = 3, - gcvSTATUS_MIPMAP_TOO_LARGE = 4, - gcvSTATUS_NAME_NOT_FOUND = 5, - gcvSTATUS_NOT_OUR_INTERRUPT = 6, - gcvSTATUS_MISMATCH = 7, - gcvSTATUS_MIPMAP_TOO_SMALL = 8, - gcvSTATUS_LARGER = 9, - gcvSTATUS_SMALLER = 10, - gcvSTATUS_CHIP_NOT_READY = 11, - gcvSTATUS_NEED_CONVERSION = 12, - gcvSTATUS_SKIP = 13, - gcvSTATUS_DATA_TOO_LARGE = 14, - gcvSTATUS_INVALID_CONFIG = 15, - gcvSTATUS_CHANGED = 16, - gcvSTATUS_NOT_SUPPORT_DITHER = 17, - gcvSTATUS_EXECUTED = 18, - gcvSTATUS_TERMINATE = 19, - - gcvSTATUS_INVALID_ARGUMENT = -1, - gcvSTATUS_INVALID_OBJECT = -2, - gcvSTATUS_OUT_OF_MEMORY = -3, - gcvSTATUS_MEMORY_LOCKED = -4, - gcvSTATUS_MEMORY_UNLOCKED = -5, - gcvSTATUS_HEAP_CORRUPTED = -6, - gcvSTATUS_GENERIC_IO = -7, - gcvSTATUS_INVALID_ADDRESS = -8, - gcvSTATUS_CONTEXT_LOSSED = -9, - gcvSTATUS_TOO_COMPLEX = -10, - gcvSTATUS_BUFFER_TOO_SMALL = -11, - gcvSTATUS_INTERFACE_ERROR = -12, - gcvSTATUS_NOT_SUPPORTED = -13, - gcvSTATUS_MORE_DATA = -14, - gcvSTATUS_TIMEOUT = -15, - gcvSTATUS_OUT_OF_RESOURCES = -16, - gcvSTATUS_INVALID_DATA = -17, - gcvSTATUS_INVALID_MIPMAP = -18, - gcvSTATUS_NOT_FOUND = -19, - gcvSTATUS_NOT_ALIGNED = -20, - gcvSTATUS_INVALID_REQUEST = -21, - gcvSTATUS_GPU_NOT_RESPONDING = -22, - gcvSTATUS_TIMER_OVERFLOW = -23, - gcvSTATUS_VERSION_MISMATCH = -24, - gcvSTATUS_LOCKED = -25, - gcvSTATUS_INTERRUPTED = -26, - gcvSTATUS_DEVICE = -27, - gcvSTATUS_NOT_MULTI_PIPE_ALIGNED = -28, - gcvSTATUS_OUT_OF_SAMPLER = -29, - - /* Linker errors. */ - gcvSTATUS_GLOBAL_TYPE_MISMATCH = -1000, - gcvSTATUS_TOO_MANY_ATTRIBUTES = -1001, - gcvSTATUS_TOO_MANY_UNIFORMS = -1002, - gcvSTATUS_TOO_MANY_VARYINGS = -1003, - gcvSTATUS_UNDECLARED_VARYING = -1004, - gcvSTATUS_VARYING_TYPE_MISMATCH = -1005, - gcvSTATUS_MISSING_MAIN = -1006, - gcvSTATUS_NAME_MISMATCH = -1007, - gcvSTATUS_INVALID_INDEX = -1008, - gcvSTATUS_UNIFORM_MISMATCH = -1009, - gcvSTATUS_UNSAT_LIB_SYMBOL = -1010, - gcvSTATUS_TOO_MANY_SHADERS = -1011, - gcvSTATUS_LINK_INVALID_SHADERS = -1012, - gcvSTATUS_CS_NO_WORKGROUP_SIZE = -1013, - gcvSTATUS_LINK_LIB_ERROR = -1014, - - gcvSTATUS_SHADER_VERSION_MISMATCH = -1015, - gcvSTATUS_TOO_MANY_INSTRUCTION = -1016, - gcvSTATUS_SSBO_MISMATCH = -1017, - gcvSTATUS_TOO_MANY_OUTPUT = -1018, - gcvSTATUS_TOO_MANY_INPUT = -1019, - gcvSTATUS_NOT_SUPPORT_CL = -1020, - gcvSTATUS_NOT_SUPPORT_INTEGER = -1021, - gcvSTATUS_UNIFORM_TYPE_MISMATCH = -1022, - - gcvSTATUS_MISSING_PRIMITIVE_TYPE = -1023, - gcvSTATUS_MISSING_OUTPUT_VERTEX_COUNT = -1024, - gcvSTATUS_NON_INVOCATION_ID_AS_INDEX = -1025, - gcvSTATUS_INPUT_ARRAY_SIZE_MISMATCH = -1026, - gcvSTATUS_OUTPUT_ARRAY_SIZE_MISMATCH = -1027, - gcvSTATUS_LOCATION_ALIASED = -1028, - - /* Compiler errors. */ - gcvSTATUS_COMPILER_FE_PREPROCESSOR_ERROR = -2000, - gcvSTATUS_COMPILER_FE_PARSER_ERROR = -2001, - - /* Recompilation Errors */ - gcvSTATUS_RECOMPILER_CONVERT_UNIMPLEMENTED = -3000, -} -gceSTATUS; - -/******************************************************************************\ -********************************* Status Macros ******************************** -\******************************************************************************/ - -#define gcmIS_ERROR(status) (status < 0) -#define gcmNO_ERROR(status) (status >= 0) -#define gcmIS_SUCCESS(status) (status == gcvSTATUS_OK) - -/******************************************************************************\ -********************************* Field Macros ********************************* -\******************************************************************************/ - -#define __gcmSTART(reg_field) \ - (0 ? reg_field) - -#define __gcmEND(reg_field) \ - (1 ? reg_field) - -#define __gcmGETSIZE(reg_field) \ - (__gcmEND(reg_field) - __gcmSTART(reg_field) + 1) - -#define __gcmALIGN(data, reg_field) \ - (((gctUINT32) (data)) << __gcmSTART(reg_field)) - -#define __gcmMASK(reg_field) \ - ((gctUINT32) ((__gcmGETSIZE(reg_field) == 32) \ - ? ~0U \ - : (~(~0U << __gcmGETSIZE(reg_field))))) - -/******************************************************************************* -** -** gcmFIELDMASK -** -** Get aligned field mask. -** -** ARGUMENTS: -** -** reg Name of register. -** field Name of field within register. -*/ -#define gcmFIELDMASK(reg, field) \ -(\ - __gcmALIGN(__gcmMASK(reg##_##field), reg##_##field) \ -) - -/******************************************************************************* -** -** gcmGETFIELD -** -** Extract the value of a field from specified data. -** -** ARGUMENTS: -** -** data Data value. -** reg Name of register. -** field Name of field within register. -*/ -#define gcmGETFIELD(data, reg, field) \ -(\ - ((((gctUINT32) (data)) >> __gcmSTART(reg##_##field)) \ - & __gcmMASK(reg##_##field)) \ -) - -/******************************************************************************* -** -** gcmSETFIELD -** -** Set the value of a field within specified data. -** -** ARGUMENTS: -** -** data Data value. -** reg Name of register. -** field Name of field within register. -** value Value for field. -*/ -#define gcmSETFIELD(data, reg, field, value) \ -(\ - (((gctUINT32) (data)) \ - & ~__gcmALIGN(__gcmMASK(reg##_##field), reg##_##field)) \ - | __gcmALIGN((gctUINT32) (value) \ - & __gcmMASK(reg##_##field), reg##_##field) \ -) - -/******************************************************************************* -** -** gcmSETFIELDVALUE -** -** Set the value of a field within specified data with a -** predefined value. -** -** ARGUMENTS: -** -** data Data value. -** reg Name of register. -** field Name of field within register. -** value Name of the value within the field. -*/ -#define gcmSETFIELDVALUE(data, reg, field, value) \ -(\ - (((gctUINT32) (data)) \ - & ~__gcmALIGN(__gcmMASK(reg##_##field), reg##_##field)) \ - | __gcmALIGN(reg##_##field##_##value \ - & __gcmMASK(reg##_##field), reg##_##field) \ -) - -/******************************************************************************* -** -** gcmGETMASKEDFIELDMASK -** -** Determine field mask of a masked field. -** -** ARGUMENTS: -** -** reg Name of register. -** field Name of field within register. -*/ -#define gcmGETMASKEDFIELDMASK(reg, field) \ -(\ - gcmSETFIELD(0, reg, field, ~0U) | \ - gcmSETFIELD(0, reg, MASK_ ## field, ~0U) \ -) - -/******************************************************************************* -** -** gcmSETMASKEDFIELD -** -** Set the value of a masked field with specified data. -** -** ARGUMENTS: -** -** reg Name of register. -** field Name of field within register. -** value Value for field. -*/ -#define gcmSETMASKEDFIELD(reg, field, value) \ -(\ - gcmSETFIELD (~0U, reg, field, value) & \ - gcmSETFIELDVALUE(~0U, reg, MASK_ ## field, ENABLED) \ -) - -/******************************************************************************* -** -** gcmSETMASKEDFIELDVALUE -** -** Set the value of a masked field with specified data. -** -** ARGUMENTS: -** -** reg Name of register. -** field Name of field within register. -** value Value for field. -*/ -#define gcmSETMASKEDFIELDVALUE(reg, field, value) \ -(\ - gcmSETFIELDVALUE(~0U, reg, field, value) & \ - gcmSETFIELDVALUE(~0U, reg, MASK_ ## field, ENABLED) \ -) - -/******************************************************************************* -** -** gcmVERIFYFIELDVALUE -** -** Verify if the value of a field within specified data equals a -** predefined value. -** -** ARGUMENTS: -** -** data Data value. -** reg Name of register. -** field Name of field within register. -** value Name of the value within the field. -*/ -#define gcmVERIFYFIELDVALUE(data, reg, field, value) \ -(\ - (((gctUINT32) (data)) >> __gcmSTART(reg##_##field) & \ - __gcmMASK(reg##_##field)) \ - == \ - (reg##_##field##_##value & __gcmMASK(reg##_##field)) \ -) - -/******************************************************************************* -** Bit field macros. -*/ - -#define __gcmSTARTBIT(Field) \ - (1 ? Field ) - -#define __gcmBITSIZE(Field) \ - (0 ? Field ) - -#define __gcmBITMASK(Field) \ -(\ - (1 << __gcmBITSIZE(Field)) - 1 \ -) - -#define gcmGETBITS(Value, Type, Field) \ -(\ - (((Type) (Value)) >> __gcmSTARTBIT(Field) ) \ - & \ - __gcmBITMASK(Field) \ -) - -#define gcmSETBITS(Value, Type, Field, NewValue) \ -(\ - (((Type) (Value)) \ - & ~(__gcmBITMASK(Field) << __gcmSTARTBIT(Field)) \ - ) \ - | \ - ((((Type) (NewValue)) \ - & __gcmBITMASK(Field) \ - ) << __gcmSTARTBIT(Field) \ - ) \ -) - -/******************************************************************************* -** -** gcmISINREGRANGE -** -** Verify whether the specified address is in the register range. -** -** ARGUMENTS: -** -** Address Address to be verified. -** Name Name of a register. -*/ - -#define gcmISINREGRANGE(Address, Name) \ -(\ - ((Address & (~0U << Name ## _LSB)) == (Name ## _Address >> 2)) \ -) - -/******************************************************************************\ -******************************** Ceiling Macro ******************************** -\******************************************************************************/ -#define gcmCEIL(x) (((x) - (gctUINT32)(x)) == 0 ? (gctUINT32)(x) : (gctUINT32)(x) + 1) - -/******************************************************************************\ -******************************** Min/Max Macros ******************************** -\******************************************************************************/ - -#define gcmMIN(x, y) (((x) <= (y)) ? (x) : (y)) -#define gcmMAX(x, y) (((x) >= (y)) ? (x) : (y)) -#define gcmCLAMP(x, min, max) (((x) < (min)) ? (min) : \ - ((x) > (max)) ? (max) : (x)) -#define gcmABS(x) (((x) < 0) ? -(x) : (x)) -#define gcmNEG(x) (((x) < 0) ? (x) : -(x)) - -/******************************************************************************\ -******************************** Bit Macro ******************************** -\******************************************************************************/ -#define gcmBITSET(x, y) ((x) & (y)) -/******************************************************************************* -** -** gcmPTR2SIZE -** -** Convert a pointer to an integer value. -** -** ARGUMENTS: -** -** p Pointer value. -*/ -#define gcmPTR2SIZE(p) \ -(\ - (gctUINTPTR_T) (p) \ -) - -#define gcmPTR2INT32(p) \ -(\ - (gctUINT32)(gctUINTPTR_T) (p) \ -) - -/******************************************************************************* -** -** gcmINT2PTR -** -** Convert an integer value into a pointer. -** -** ARGUMENTS: -** -** v Integer value. -*/ - -#define gcmINT2PTR(i) \ -(\ - (gctPOINTER) (gctUINTPTR_T)(i) \ -) - -/******************************************************************************* -** -** gcmOFFSETOF -** -** Compute the byte offset of a field inside a structure. -** -** ARGUMENTS: -** -** s Structure name. -** field Field name. -*/ -#define gcmOFFSETOF(s, field) \ -(\ - gcmPTR2INT32(& (((struct s *) 0)->field)) \ -) - -#define __gcmOFFSETOF(type, field) \ -(\ - gcmPTR2INT32(& (((type *) 0)->field)) \ -) - -/******************************************************************************* -** -** gcmCONTAINEROF -** -** Get containing structure of a member. -** -** ARGUMENTS: -** -** Pointer Pointer of member. -** Type Structure name. -** Name Field name. -*/ -#define gcmCONTAINEROF(Pointer, Type, Member) \ -(\ - (Type *)((gctUINTPTR_T)Pointer - __gcmOFFSETOF(Type, Member)) \ -) - -/******************************************************************************* -** -** gcmBSWAP32 -** -** Return a value with all bytes in the 32 bit argument swapped. -*/ -#if !defined(__KERNEL__) && defined(__GNUC__) && (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__ >= 40300) \ - && !defined(__VXWORKS__) -# define gcmBSWAP32(x) __builtin_bswap32(x) -#else -# define gcmBSWAP32(x) ((gctUINT32)(\ - (((gctUINT32)(x) & (gctUINT32)0x000000FFUL) << 24) | \ - (((gctUINT32)(x) & (gctUINT32)0x0000FF00UL) << 8) | \ - (((gctUINT32)(x) & (gctUINT32)0x00FF0000UL) >> 8) | \ - (((gctUINT32)(x) & (gctUINT32)0xFF000000UL) >> 24))) -#endif - -/******************************************************************************* -***** Database ****************************************************************/ - -typedef struct _gcsDATABASE_COUNTERS -{ - /* Number of currently allocated bytes. */ - gctUINT64 bytes; - - /* Maximum number of bytes allocated (memory footprint). */ - gctUINT64 maxBytes; - - /* Total number of bytes allocated. */ - gctUINT64 totalBytes; - - /* The numbers of times video memory was allocated. */ - gctUINT32 allocCount; - - /* The numbers of times video memory was freed. */ - gctUINT32 freeCount; -} -gcsDATABASE_COUNTERS; - -typedef struct _gcuDATABASE_INFO -{ - /* Counters. */ - gcsDATABASE_COUNTERS counters; - - /* Time value. */ - gctUINT64 time; -} -gcuDATABASE_INFO; - -/******************************************************************************* -***** Frame database **********************************************************/ - -/* gcsHAL_FRAME_INFO */ -typedef struct _gcsHAL_FRAME_INFO -{ - /* Current timer tick. */ - OUT gctUINT64 ticks; - - /* Bandwidth counters. */ - OUT gctUINT readBytes8[8]; - OUT gctUINT writeBytes8[8]; - - /* Counters. */ - OUT gctUINT cycles[8]; - OUT gctUINT idleCycles[8]; - OUT gctUINT mcCycles[8]; - OUT gctUINT readRequests[8]; - OUT gctUINT writeRequests[8]; - - /* 3D counters. */ - OUT gctUINT vertexCount; - OUT gctUINT primitiveCount; - OUT gctUINT rejectedPrimitives; - OUT gctUINT culledPrimitives; - OUT gctUINT clippedPrimitives; - OUT gctUINT outPrimitives; - OUT gctUINT inPrimitives; - OUT gctUINT culledQuadCount; - OUT gctUINT totalQuadCount; - OUT gctUINT quadCount; - OUT gctUINT totalPixelCount; - - /* PE counters. */ - OUT gctUINT colorKilled[8]; - OUT gctUINT colorDrawn[8]; - OUT gctUINT depthKilled[8]; - OUT gctUINT depthDrawn[8]; - - /* Shader counters. */ - OUT gctUINT shaderCycles; - OUT gctUINT vsInstructionCount; - OUT gctUINT vsTextureCount; - OUT gctUINT psInstructionCount; - OUT gctUINT psTextureCount; - - /* Texture counters. */ - OUT gctUINT bilinearRequests; - OUT gctUINT trilinearRequests; - OUT gctUINT txBytes8; - OUT gctUINT txHitCount; - OUT gctUINT txMissCount; -} -gcsHAL_FRAME_INFO; - -typedef struct _gckLINKDATA * gckLINKDATA; -struct _gckLINKDATA -{ - gctUINT32 start; - gctUINT32 end; - gctUINT32 pid; - gctUINT32 linkLow; - gctUINT32 linkHigh; -}; - -typedef struct _gckADDRESSDATA * gckADDRESSDATA; -struct _gckADDRESSDATA -{ - gctUINT32 start; - gctUINT32 end; -}; - -typedef union _gcuQUEUEDATA -{ - struct _gckLINKDATA linkData; - - struct _gckADDRESSDATA addressData; -} -gcuQUEUEDATA; - -typedef struct _gckQUEUE * gckQUEUE; -struct _gckQUEUE -{ - gcuQUEUEDATA * datas; - gctUINT32 rear; - gctUINT32 front; - gctUINT32 count; - gctUINT32 size; -}; - -typedef enum _gceTRACEMODE -{ - gcvTRACEMODE_NONE = 0, - gcvTRACEMODE_FULL = 1, - gcvTRACEMODE_LOGGER = 2, - gcvTRACEMODE_ALLZONE = 3, - gcvTRACEMODE_PRE = 4, - gcvTRACEMODE_POST = 5, -} gceTRACEMODE; - -typedef struct _gcsLISTHEAD * gcsLISTHEAD_PTR; -typedef struct _gcsLISTHEAD -{ - gcsLISTHEAD_PTR prev; - gcsLISTHEAD_PTR next; -} -gcsLISTHEAD; - -/* - * 'Patch' here means a mechanism to let kernel side modify user space reserved - * command buffer location, or something the like, during the command buffer - * commit. - * - * Reasons of using 'patch': - * 1. Some resources/states are managed globally only in kernel side, such as - * MCFE semaphore, etc. - * 2. For the sake of security or optimization, like video memory address. - * - * Patches are arranged in arrays, each array has the same type. The 'patchArray' - * in 'gcsHAL_PATCH_LIST' pointers the concrete patch item array. - * - * NOTICE: - * Be aware of the order and values! Tables in gc_hal_user_buffer.c and - * gc_hal_kernel_command.c depend on this. - */ -/* The patch types. */ -enum _gceHAL_PATCH_TYPE -{ - gcvHAL_PATCH_VIDMEM_ADDRESS = 1, - gcvHAL_PATCH_MCFE_SEMAPHORE, - gcvHAL_PATCH_VIDMEM_TIMESTAMP, - - /* Must be the last one for counting. */ - gcvHAL_PATCH_TYPE_COUNT, -}; - -/* The patch array. */ -typedef struct _gcsHAL_PATCH_LIST -{ - /* Patch type. */ - gctUINT32 type; - - /* Patch item count. */ - gctUINT32 count; - - /* - * Pointer to the patch items. - * - * gcsHAL_PATCH_VIDMEM_ADDRESS * patchArray; - * gcsHAL_PATCH_MCFE_SEMAPHORE * patchArray; - * gcsHAL_PATCH_VIDMEM_TIMESTAMP * patchArray; - * ... - */ - gctUINT64 patchArray; - - /* struct _gcsHAL_PATCH_LIST * next; */ - gctUINT64 next; -} -gcsHAL_PATCH_LIST; - -/* - * Patch a GPU address in the place (gcvHAL_PATCH_VIDMEM_ADDRESS). - * Size of a GPU address is always 32 bits. - */ -typedef struct _gcsHAL_PATCH_VIDMEM_ADDRESS -{ - /* Patch location in the command buffer. */ - gctUINT32 location; - - /* Handle of the video memory node. */ - gctUINT32 node; - - /* Address offset in the video memory node. */ - gctUINT32 offset; -} -gcsHAL_PATCH_VIDMEM_ADDRESS; - -/* - * Patch a MCFE semaphore command in the place (gcvHAL_PATCH_MCFE_SEMAPHORE). - * Size of the semaphore command is fixed at _64_ bits! - */ -typedef struct _gcsHAL_PATCH_MCFE_SEMAPHORE -{ - /* Patch location in the command buffer. */ - gctUINT32 location; - - /* semaphore direction: 1 = Send, 0 = Wait. */ - gctUINT32 sendSema; - - /* Handle of the semaphore. */ - gctUINT32 semaHandle; -} -gcsHAL_PATCH_MCFE_SEMAPHORE; - -/* - * Patch timestamp of given video memory node (gcvHAL_PATCH_VIDMEM_TIMESTAMP). - * Pure software-wise, not command relevant. - */ -typedef struct _gcsHAL_PATCH_VIDMEM_TIMESTAMP -{ - /* Handle of a video memory node. */ - gctUINT32 handle; - - gctUINT32 flag; -} -gcsHAL_PATCH_VIDMEM_TIMESTAMP; - - -/* - gcvFEATURE_DATABASE_DATE_MASK - - Mask used to control which bits of chip date will be used to - query feature database, ignore release date for fpga and emulator. -*/ -#if (gcdFPGA_BUILD || defined(EMULATOR)) -# define gcvFEATURE_DATABASE_DATE_MASK (0U) -#else -# define gcvFEATURE_DATABASE_DATE_MASK (~0U) -#endif - -#if defined(__GNUC__) -#if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) -#define gcdENDIAN_BIG 1 -#else -#define gcdENDIAN_BIG 0 -#endif -#else -#define gcdENDIAN_BIG 0 -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* __gc_hal_types_h_ */ diff --git a/drivers/amlogic/npu/inc/gc_hal_version.h b/drivers/amlogic/npu/inc/gc_hal_version.h index 9a9d661..b32b596 100644 --- a/drivers/amlogic/npu/inc/gc_hal_version.h +++ b/drivers/amlogic/npu/inc/gc_hal_version.h @@ -18,11 +18,11 @@ #define gcvVERSION_MINOR 4 -#define gcvVERSION_PATCH 2 +#define gcvVERSION_PATCH 3 -#define gcvVERSION_BUILD 258160 +#define gcvVERSION_BUILD 279124 -#define gcvVERSION_STRING "6.4.2.1.258160" +#define gcvVERSION_STRING "6.4.3.279124CB" #endif /* __gc_hal_version_h_ */ diff --git a/drivers/amlogic/npu/inc/gc_hal_vg.h b/drivers/amlogic/npu/inc/gc_hal_vg.h index a5b327c..2f16746 100644 --- a/drivers/amlogic/npu/inc/gc_hal_vg.h +++ b/drivers/amlogic/npu/inc/gc_hal_vg.h @@ -19,10 +19,10 @@ extern "C" { #endif -#include "shared/gc_hal_types.h" +#include "gc_hal_types.h" #include "gc_hal_enum.h" #include "gc_hal_base.h" -#include "shared/gc_hal_vg.h" +#include "shared/gc_hal_vg_shared.h" #ifdef __cplusplus diff --git a/drivers/amlogic/npu/inc/gc_hal_vx.h b/drivers/amlogic/npu/inc/gc_hal_vx.h index 568c04d..fb1303a 100644 --- a/drivers/amlogic/npu/inc/gc_hal_vx.h +++ b/drivers/amlogic/npu/inc/gc_hal_vx.h @@ -141,7 +141,6 @@ gcoVX_InvokeKernel( IN gcsVX_KERNEL_PARAMETERS_PTR Parameters ); - gceSTATUS gcoVX_AllocateMemory( IN gctUINT32 Size, @@ -213,10 +212,7 @@ gcoVX_TriggerAccelerator( IN gctBOOL waitEvent, IN gctUINT32 gpuId, IN gctBOOL sync, - IN gctUINT32 syncEventID, - IN gctUINT32 vipSRAMRemapStartAddr, - IN gctUINT32 axiSRAMRemapStartAddr, - IN gctUINT32 axiSRAMRemapEndAddr + IN gctUINT32 syncEventID ); gceSTATUS @@ -340,14 +336,6 @@ gcoVX_CaptureState( ); gceSTATUS -gcoVX_CaptureInitState( - IN OUT gctPOINTER *CaptureBuffer, - IN gctUINT32 InputSizeInByte, - IN OUT gctUINT32_PTR OutputSizeInByte, - IN gctUINT32 deviceCount - ); - -gceSTATUS gcoVX_SetRemapAddress( IN gctUINT32 remapStart, IN gctUINT32 remapEnd, @@ -379,7 +367,9 @@ gceSTATUS gcoVX_GetEvisNoInstFeatureCap( OUT vx_evis_no_inst_s *EvisNoInst ); - +gceSTATUS gcoVX_MultiGPUSync( + OUT gctUINT32_PTR *Memory + ); #ifdef __cplusplus } diff --git a/drivers/amlogic/npu/inc/old_impl/gc_vsc_old_drvi_interface.h b/drivers/amlogic/npu/inc/old_impl/gc_vsc_old_drvi_interface.h index 8d8033d..083e2a8 100644 --- a/drivers/amlogic/npu/inc/old_impl/gc_vsc_old_drvi_interface.h +++ b/drivers/amlogic/npu/inc/old_impl/gc_vsc_old_drvi_interface.h @@ -53,12 +53,17 @@ BEGIN_EXTERN_C() #define __INIT_VALUE_FOR_WORK_GROUP_INDEX__ 0x1234 /* For OCL. */ +#define _sldLocalSizeName "#local_size" +#define _sldGlobalSizeName "#global_size" +#define _sldGlobalOffsetName "#global_offset" +#define _sldEnqueuedLocalSizeName "#enqueued_local_size" #define _sldLocalStorageAddressName "#sh_local_address" #define _sldWorkGroupCountName "#workGroupCount" #define _sldWorkGroupIdOffsetName "#workGroupIdOffset" #define _sldGlobalIdOffsetName "#globalIdOffset" /* Shared use. */ +#define _sldLocalInvocationIndexName "#local_invocation_index" #define _sldLocalMemoryAddressName "#sh_localMemoryAddress" #define _sldThreadIdMemoryAddressName "#sh_threadIdMemAddr" #define _sldWorkThreadCountName "#sh_workThreadCount" @@ -760,7 +765,8 @@ typedef struct _gcsHINT /* Third word. */ gctUINT fragColorUsage : 2; - gctUINT reserved : 30; + gctBOOL dependOnWorkGroupSize : 2; + gctUINT reserved : 28; /* flag if the shader uses gl_FragCoord, gl_FrontFacing, gl_PointCoord */ gctCHAR useFragCoord[4]; @@ -831,6 +837,7 @@ typedef struct _gcsHINT /* per-vertex attributeCount. */ gctUINT tcsPerVertexAttributeCount; + gctBOOL tcsHasNoPerVertexAttribute; gctUINT extraUscPages; @@ -846,8 +853,11 @@ typedef struct _gcsHINT /* Sampler Base offset. */ gctBOOL useGPRSpill[gcvPROGRAM_STAGE_LAST]; + /* Misc hints */ + gctINT32 GSmaxThreadsPerHwTG; + gctUINT tpgTopology; /* padding bytes to make the offset of shaderVidNodes field be consistent in 32bit and 64bit platforms */ - gctCHAR reservedByteForShaderVidNodeOffset[4]; + gctCHAR reservedByteForShaderVidNodeOffset[8]; /* shaderVidNodes should always be the LAST filed in hits. */ /* SURF Node for memory that is used in shader. */ @@ -911,13 +921,13 @@ typedef struct _gcSHADER_TYPEINFO extern const gcSHADER_TYPEINFO gcvShaderTypeInfo[]; -#define gcmType_Comonents(Type) (gcvShaderTypeInfo[Type].components) -#define gcmType_PackedComonents(Type) (gcvShaderTypeInfo[Type].packedComponents) -#define gcmType_Rows(Type) (gcvShaderTypeInfo[Type].rows) -#define gcmType_RowType(Type) (gcvShaderTypeInfo[Type].rowType) -#define gcmType_ComonentType(Type) (gcvShaderTypeInfo[Type].componentType) -#define gcmType_Kind(Type) (gcvShaderTypeInfo[Type].kind) -#define gcmType_Name(Type) (gcvShaderTypeInfo[Type].name) +#define gcmType_Comonents(Type) (Type < gcSHADER_TYPE_COUNT? gcvShaderTypeInfo[Type].components : gcvShaderTypeInfo[gcSHADER_UNKONWN_TYPE].components) +#define gcmType_PackedComonents(Type) (Type < gcSHADER_TYPE_COUNT? gcvShaderTypeInfo[Type].packedComponents : gcvShaderTypeInfo[gcSHADER_UNKONWN_TYPE].packedComponents) +#define gcmType_Rows(Type) (Type < gcSHADER_TYPE_COUNT? gcvShaderTypeInfo[Type].rows : gcvShaderTypeInfo[gcSHADER_UNKONWN_TYPE].rows) +#define gcmType_RowType(Type) (Type < gcSHADER_TYPE_COUNT? gcvShaderTypeInfo[Type].rowType : gcvShaderTypeInfo[gcSHADER_UNKONWN_TYPE].rowType) +#define gcmType_ComonentType(Type) (Type < gcSHADER_TYPE_COUNT? gcvShaderTypeInfo[Type].componentType : gcvShaderTypeInfo[gcSHADER_UNKONWN_TYPE].componentType) +#define gcmType_Kind(Type) (Type < gcSHADER_TYPE_COUNT? gcvShaderTypeInfo[Type].kind : gcvShaderTypeInfo[gcSHADER_UNKONWN_TYPE].kind) +#define gcmType_Name(Type) (Type < gcSHADER_TYPE_COUNT? gcvShaderTypeInfo[Type].name : gcvShaderTypeInfo[gcSHADER_UNKONWN_TYPE].name) #define gcmType_isSampler(Type) (gcmType_Kind(Type) == gceTK_SAMPLER || gcmType_Kind(Type) == gceTK_SAMPLER_T) @@ -1018,8 +1028,8 @@ typedef enum _gceSHADER_FLAGS /* Remove unused uniforms on shader, only enable for es20 shader. */ gcvSHADER_REMOVE_UNUSED_UNIFORMS = 0x2000, - /* Force linking when either vertex or fragment shader not present */ - gcvSHADER_FORCE_LINKING = 0x4000, + /* Force generate a floating MAD, no matter if HW can support it. */ + gcSHADER_FLAG_FORCE_GEN_FLOAT_MAD = 0x4000, /* Disable default UBO for vertex and fragment shader. */ gcvSHADER_DISABLE_DEFAULT_UBO = 0x8000, @@ -1867,7 +1877,9 @@ extern gctBOOL gcDoTriageForShaderId(gctINT shaderId, gctINT startId, gctINT end it can decrease the temp registers but increases the constant registers. */ #define FB_DISABLE_GL_LOOP_UNROLLING 0x40000 /* Disable loop unrolling for GL FE. */ -#define FE_GENERATED_OFFLINE_COMPILER 0x80000 /* Enable Offline Compile . */ +#define FB_GENERATED_OFFLINE_COMPILER 0x80000 /* Enable Offline Compile . */ + +#define FB_VSIMULATOR_RUNNING_MODE 0x100000 /* VSimulator running mode. */ #define gcmOPT_SetPatchTexld(m,n) (gcmGetOptimizerOption()->patchEveryTEXLDs = (m),\ gcmGetOptimizerOption()->patchDummyTEXLDs = (n)) @@ -2053,8 +2065,13 @@ typedef struct _gcsGLSLCaps gcePROVOKING_VERTEX_CONVENSION provokingVertex; gctUINT maxGsInvocationCount; - /* Desktop GL limits */ + /* Primitive Clipling limits */ gctUINT maxClipDistances; + gctUINT maxCullDistances; + gctUINT maxCombinedClipAndCullDistances; + + /* Desktop GL limits */ + gctUINT maxLights; gctUINT maxClipPlanes; gctUINT maxFragmentUniformComponents; gctUINT maxTextureCoords; @@ -2092,7 +2109,8 @@ extern gcsHWCaps * #define GetHWHasHalti1() (gcGetHWCaps()->hwFeatureFlags.hasHalti1) #define GetHWHasHalti2() (gcGetHWCaps()->hwFeatureFlags.hasHalti2) #define GetHWHasHalti5() (gcGetHWCaps()->hwFeatureFlags.hasHalti5) -#define GetHWHasFmaSupport() (gcGetHWCaps()->hwFeatureFlags.supportAdvancedInsts) +#define GetHWHasAdvancedInst() (gcGetHWCaps()->hwFeatureFlags.supportAdvancedInsts) +#define GetHWHasFmaSupport() (GetHWHasHalti5() && GetHWHasAdvancedInst()) #define GetHWHasTS() (gcGetHWCaps()->hwFeatureFlags.supportTS) #define GetHWHasGS() (gcGetHWCaps()->hwFeatureFlags.supportGS) #define GetHWHasSamplerBaseOffset() (gcGetHWCaps()->hwFeatureFlags.hasSamplerBaseOffset) @@ -2212,8 +2230,12 @@ extern gceSTATUS gcInitGLSLCaps( #define GetGLMaxGSUniformBufferBindings() (gcGetGLSLCaps()->maxGsUniformBlocks) #define GetGLMaxGSShaderStorageBufferBindings() (gcGetGLSLCaps()->maxGsShaderStorageBlocks) -/* Desktop GL constants */ #define GetGLMaxClipDistances() (gcGetGLSLCaps()->maxClipDistances) +#define GetGLMaxCullDistances() (gcGetGLSLCaps()->maxCullDistances) +#define GetGLMaxCombinedClipCullDistances() (gcGetGLSLCaps()->maxCombinedClipAndCullDistances) + +/* Desktop GL constants */ +#define GetGLMaxLights() (gcGetGLSLCaps()->maxLights) #define GetGLMaxClipPlanes() (gcGetGLSLCaps()->maxClipPlanes) #define GetGLMaxFragmentUniformComponents() (gcGetGLSLCaps()->maxFragmentUniformComponents) #define GetGLMaxTextureCoords() (gcGetGLSLCaps()->maxTextureCoords) @@ -8584,7 +8606,7 @@ gcSHADER_Has64BitOperation( IN gcSHADER Shader ); -void +gceSTATUS gcSHADER_SetBuildOptions( IN gcSHADER Shader, IN gctSTRING Options @@ -8614,6 +8636,12 @@ gcSHADER_SetAttrLocationByDriver( IN gctINT Location ); +gceSTATUS +gcSHADER_SetCLProgramBinaryType( + IN gcSHADER Shader, + IN gctUINT clProgramBinaryType + ); + gctBOOL gceLAYOUT_QUALIFIER_HasHWNotSupportingBlendMode( IN gceLAYOUT_QUALIFIER Qualifier diff --git a/drivers/amlogic/npu/inc/old_impl/gc_vsc_old_gcsl.h b/drivers/amlogic/npu/inc/old_impl/gc_vsc_old_gcsl.h index 99e0b70c..e735e1b 100644 --- a/drivers/amlogic/npu/inc/old_impl/gc_vsc_old_gcsl.h +++ b/drivers/amlogic/npu/inc/old_impl/gc_vsc_old_gcsl.h @@ -127,10 +127,25 @@ BEGIN_EXTERN_C() /* bump up version to 1.42 for saving adding intrinsic functions sin, cos, tan 11/8/2019 */ /* bump up version to 1.43 for supporting textureGather functions have texture2DrectShadow type 11/14/2019 */ -/* current version */ -#define gcdSL_SHADER_BINARY_FILE_VERSION gcmCC(SHADER_64BITMODE, 0, 1, 43) -#define gcdSL_PROGRAM_BINARY_FILE_VERSION gcmCC(SHADER_64BITMODE, 0, 1, 43) +/* bump up version to 1.44 for saving cl_program_binary_type for gcSHADER on 03/12/2020 */ +#define gcdSL_SHADER_BINARY_BEFORE_SAVING_CL_PROGRAM_BINARY_TYPE gcmCC(0, 0, 1, 44) + +/* bump up version to 1.45 for saving the return variable to a argument 03/27/2020 */ +#define gcdSL_SHADER_BINARY_BEFORE_SAVING_FUNCTION_RETURN_VARIABLE gcmCC(0, 0, 1, 45) + +/* bump up version to 1.46 for adding intrinsic functions vstore_half with rounding modes rtz, rtp and rtn 03/28/2020 */ + +/* bump up version to 1.47 for adding intrinsic functions noise1, noise2 ... for OGL4.0 05/02/2020 */ + +/* bump up version to 1.48 for adding intrinsic functions of double type for ldexp, frexp, fma, packDouble2x32 and unpackDouble2x32 for OGL4.0 05/04/2020 */ + +/* bump up version to 1.49 for supporting textureSize function for more sampler type 5/20/2020 */ +/* bump up version to 1.50 for adding a new variable tcsHasNoPerVertexAttribute in hints 06/03/2020 */ + +/* current version */ +#define gcdSL_SHADER_BINARY_FILE_VERSION gcmCC(SHADER_64BITMODE, 0, 1, 51) +#define gcdSL_PROGRAM_BINARY_FILE_VERSION gcmCC(SHADER_64BITMODE, 0, 1, 51) typedef union _gcsValue { @@ -394,6 +409,7 @@ typedef enum _gcSL_OPCODE gcSL_CLAMPCOORD, /* 0x9C clamp image 2d cooridate to its width and height */ gcSL_EMIT_STREAM_VERTEX, /* 0x9D For function "EmitStreamVertex" */ gcSL_END_STREAM_PRIMITIVE, /* 0x9E For function "EndStreamPrimitive" */ + gcSL_CTZ, /* 0x9F For function "ctz()" */ gcSL_MAXOPCODE } gcSL_OPCODE; @@ -1482,7 +1498,7 @@ typedef enum _gceBuiltinNameKind gcSL_POINT_COORD = -5, gcSL_POSITION_W = -6, gcSL_DEPTH = -7, - gcSL_FOG_COORD = -8, + gcSL_FOG_FRAG_COORD = -8, gcSL_VERTEX_ID = -9, gcSL_INSTANCE_ID = -10, gcSL_WORK_GROUP_ID = -11, @@ -1516,7 +1532,22 @@ typedef enum _gceBuiltinNameKind gcSL_LAST_FRAG_DATA = -39, /* gl_LastFragData */ gcSL_CLUSTER_ID = -40, /* cluster id */ gcSL_CLIP_DISTANCE = -41, /* gl_ClipDistance */ - gcSL_BUILTINNAME_COUNT = 42 + gcSL_LOCAL_INVOCATION_INDEX = -42, + gcSL_GLOBAL_INVOCATION_INDEX = -43, + gcSL_SECONDARY_COLOR = -44, /* gl_SecondaryColor */ + gcSL_NORMAL = -45, /* gl_Normal */ + gcSL_VERTEX = -46, /* gl_Vertex */ + gcSL_FOG_COORD = -47, /* gl_FogCoord */ + gcSL_MULTI_TEX_COORD_0 = -48, /* gl_MultiTexCoord0 */ + gcSL_MULTI_TEX_COORD_1 = -49, /* gl_MultiTexCoord1 */ + gcSL_MULTI_TEX_COORD_2 = -50, /* gl_MultiTexCoord2 */ + gcSL_MULTI_TEX_COORD_3 = -51, /* gl_MultiTexCoord3 */ + gcSL_MULTI_TEX_COORD_4 = -52, /* gl_MultiTexCoord4 */ + gcSL_MULTI_TEX_COORD_5 = -53, /* gl_MultiTexCoord5 */ + gcSL_MULTI_TEX_COORD_6 = -54, /* gl_MultiTexCoord6 */ + gcSL_MULTI_TEX_COORD_7 = -55, /* gl_MultiTexCoord7 */ + gcSL_CLIP_VERTEX = -56, /* gl_ClipVertex */ + gcSL_BUILTINNAME_COUNT = 57 } gceBuiltinNameKind; /* Special code generation indices. */ @@ -1725,14 +1756,8 @@ typedef struct _gcSL_INSTRUCTION typedef union _ConstantValueUnion { gctBOOL b; - gctUINT8 u8; - gctUINT16 u16; gctUINT32 u32; - gctUINT64 u64; - gctINT8 i8; - gctINT16 i16; gctINT32 i32; - gctINT64 i64; gctFLOAT f32; } ConstantValueUnion; @@ -3624,8 +3649,9 @@ typedef struct _gcBINARY_VARIABLE_EX typedef enum _gceFUNCTION_ARGUMENT_FLAG { - gceFUNCTION_ARGUMENT_FLAG_NONE = 0x00, - gceFUNCTION_ARGUMENT_FLAG_IS_PRECISE = 0x01, + gceFUNCTION_ARGUMENT_FLAG_NONE = 0x00, + gceFUNCTION_ARGUMENT_FLAG_IS_PRECISE = 0x01, + gceFUNCTION_ARGUMENT_FLAG_IS_RETURN_VARIABLE = 0x02, } gceFUNCTION_ARGUMENT_FLAG; typedef struct _gcsFUNCTION_ARGUMENT @@ -4254,6 +4280,8 @@ typedef enum _gcSHADER_FLAGS gcSHADER_FLAG_ENABLE_MULTI_GPU = 0x1000000, /* whether enable multi-GPU. */ gcSHADER_FLAG_HAS_VIV_GCSL_DRIVER_IMAGE = 0x2000000, /* the shader has OCL option `-cl-viv-gcsl-driver-image */ gcSHADER_FLAG_GENERATED_OFFLINE_COMPILER= 0x4000000, /* whether enable offline compile. */ + gcSHADER_FLAG_COMPATIBILITY_PROFILE = 0x8000000, /* the shader version is compatibility profile for OGL.*/ + gcSHADER_FLAG_USE_CONST_REG_FOR_UBO = 0x10000000, /* Use constant register to save the UBO.*/ } gcSHADER_FLAGS; #define gcShaderIsOldHeader(Shader) (((Shader)->flags & gcSHADER_FLAG_OLDHEADER) != 0) @@ -4283,6 +4311,8 @@ typedef enum _gcSHADER_FLAGS #define gcShaderHasDefineMainFunc(Shader) (((Shader)->flags & gcSHADER_FLAG_HAS_DEFINE_MAIN_FUNC) != 0) #define gcShaderEnableMultiGPU(Shader) (((Shader)->flags & gcSHADER_FLAG_ENABLE_MULTI_GPU) != 0) #define gcShaderEnableOfflineCompiler(Shader) (((Shader)->flags & gcSHADER_FLAG_GENERATED_OFFLINE_COMPILER) != 0) +#define gcShaderIsCompatibilityProfile(Shader) (((Shader)->flags & gcSHADER_FLAG_COMPATIBILITY_PROFILE) != 0) +#define gcShaderUseConstRegForUBO(Shader) (((Shader)->flags & gcSHADER_FLAG_USE_CONST_REG_FOR_UBO) != 0) #define gcShaderGetFlag(Shader) (Shader)->flags) @@ -4332,7 +4362,10 @@ typedef enum _gcSHADER_FLAGS #define gcShaderClrEnableMultiGPU(Shader) do { (Shader)->flags &= ~gcSHADER_FLAG_ENABLE_MULTI_GPU; } while (0) #define gcShaderSetEnableOfflineCompiler(Shader)do { (Shader)->flags |= gcSHADER_FLAG_GENERATED_OFFLINE_COMPILER; } while (0) #define gcShaderClrEnableOfflineCompiler(Shader)do { (Shader)->flags &= ~gcSHADER_FLAG_GENERATED_OFFLINE_COMPILER; } while (0) - +#define gcShaderSetIsCompatibilityProfile(Shader) do { (Shader)->flags |= gcSHADER_FLAG_COMPATIBILITY_PROFILE; } while (0) +#define gcShaderClrIsCompatibilityProfile(Shader) do { (Shader)->flags &= ~gcSHADER_FLAG_COMPATIBILITY_PROFILE; } while (0) +#define gcShaderSetUseConstRegForUBO(Shader) do { (Shader)->flags |= gcSHADER_FLAG_USE_CONST_REG_FOR_UBO; } while (0) +#define gcShaderClrUseConstRegForUBO(Shader) do { (Shader)->flags &= ~gcSHADER_FLAG_USE_CONST_REG_FOR_UBO; } while (0) #define gcShaderSetFlag(Shader, Flag) do { (Shader)->flags = (Flag); } while (0) typedef struct _gcLibraryList gcLibraryList; @@ -4451,6 +4484,15 @@ typedef struct _gcGEOLAYOUT gcGeoPrimitive geoOutPrimitive; } gcGEOLayout; +/* same value as cl_program_binary_type. */ +typedef enum _gcCL_PROGRAM_BINARY_TYPE +{ + gcCL_PROGRAM_BINARY_TYPE_NONE = 0x0, + gcCL_PROGRAM_BINARY_TYPE_COMPILED_OBJECT = 0x1, + gcCL_PROGRAM_BINARY_TYPE_LIBRARY = 0x2, + gcCL_PROGRAM_BINARY_TYPE_EXECUTABLE = 0x4, +} gcCL_PROGRAM_BINARY_TYPE; + /* The structure that defines the gcSHADER object to the outside world. */ struct _gcSHADER { @@ -4483,6 +4525,9 @@ struct _gcSHADER /* Type of shader. */ gcSHADER_KIND type; + /* Save the cl_program_binary_type which is set by OCL driver. */ + gcCL_PROGRAM_BINARY_TYPE clProgramBinaryType; + /* Flags */ gcSHADER_FLAGS flags; @@ -4923,6 +4968,7 @@ typedef enum _gcBuiltinConst gcBIConst_MaxGSAtomicCounterBuffers, /* Desktop GL */ + gcBIConst_MaxLights, gcBIConst_MaxClipDistances, gcBIConst_MaxClipPlanes, gcBIConst_MaxFragmentUniformComponents, diff --git a/drivers/amlogic/npu/inc/shared/gc_hal_base.h b/drivers/amlogic/npu/inc/shared/gc_hal_base_shared.h similarity index 100% rename from drivers/amlogic/npu/inc/shared/gc_hal_base.h rename to drivers/amlogic/npu/inc/shared/gc_hal_base_shared.h diff --git a/drivers/amlogic/npu/inc/shared/gc_hal_driver.h b/drivers/amlogic/npu/inc/shared/gc_hal_driver_shared.h similarity index 86% rename from drivers/amlogic/npu/inc/shared/gc_hal_driver.h rename to drivers/amlogic/npu/inc/shared/gc_hal_driver_shared.h index a4e2e3a..949b62f 100644 --- a/drivers/amlogic/npu/inc/shared/gc_hal_driver.h +++ b/drivers/amlogic/npu/inc/shared/gc_hal_driver_shared.h @@ -11,8 +11,8 @@ *****************************************************************************/ -#ifndef __gc_hal_driver_h_ -#define __gc_hal_driver_h_ +#ifndef __gc_hal_driver_shared_h_ +#define __gc_hal_driver_shared_h_ #include "gc_hal_enum.h" #include "gc_hal_types.h" @@ -23,7 +23,14 @@ extern "C" { #endif /* The number of context buffers per user. */ -#define gcdCONTEXT_BUFFER_NUM 2 +#if gcdCAPTURE_ONLY_MODE +#define gcdCONTEXT_BUFFER_COUNT 1 +#else +#define gcdCONTEXT_BUFFER_COUNT 2 +#endif + +#define gcdRENDER_FENCE_LENGTH (6 * gcmSIZEOF(gctUINT32)) +#define gcdBLT_FENCE_LENGTH (10 * gcmSIZEOF(gctUINT32)) /******************************************************************************\ ******************************* I/O Control Codes ****************************** @@ -31,7 +38,7 @@ extern "C" { #define gcvHAL_CLASS "galcore" #define IOCTL_GCHAL_INTERFACE 30000 -#define IOCTL_GCHAL_KERNEL_INTERFACE 30001 +#define IOCTL_GCHAL_PROFILER_INTERFACE 30001 #define IOCTL_GCHAL_TERMINATE 30002 /******************************************************************************\ @@ -94,6 +101,11 @@ typedef struct _gcsHAL_QUERY_VIDEO_MEMORY OUT gctUINT32 contiguousPhysName; /* Size in bytes of contiguous memory.*/ OUT gctUINT64 contiguousSize; + + /* Physical memory address of exclusive memory. Just a name. */ + OUT gctUINT32 exclusivePhysName; + /* Size in bytes of exclusive memory.*/ + OUT gctUINT64 exclusiveSize; } gcsHAL_QUERY_VIDEO_MEMORY; @@ -212,6 +224,8 @@ typedef struct _gcsHAL_QUERY_CHIP_OPTIONS gceSECURE_MODE secureMode; gctBOOL enableNNTPParallel; gctUINT enableSwtilingPhase1; + + gctBOOL hasShader; } gcsHAL_QUERY_CHIP_OPTIONS; @@ -495,7 +509,7 @@ typedef struct _gcsHAL_ATTACH #if gcdCAPTURE_ONLY_MODE IN gctBOOL queryCapSize; - IN gctPOINTER contextLogical[gcdCONTEXT_BUFFER_NUM]; + IN gctPOINTER contextLogical[gcdCONTEXT_BUFFER_COUNT]; OUT gctSIZE_T captureSize; #endif } @@ -515,6 +529,14 @@ typedef struct _gcsHAL_EVENT_COMMIT { /* Event queue in gcsQUEUE. */ IN gctUINT64 queue; + +#if gcdENABLE_SW_PREEMPTION + /* Priority ID. */ + IN gctUINT32 priorityID; + + /* Does it require top priority? */ + IN gctBOOL topPriority; +#endif } gcsHAL_EVENT_COMMIT; @@ -549,7 +571,7 @@ typedef struct _gcsHAL_COMMAND_LOCATION /* struct _gcsHAL_COMMAND_LOCATION * next; */ gctUINT64 next; #if gcdCAPTURE_ONLY_MODE - gctPOINTER contextLogical[gcdCONTEXT_BUFFER_NUM]; + gctPOINTER contextLogical[gcdCONTEXT_BUFFER_COUNT]; #endif } gcsHAL_COMMAND_LOCATION; @@ -572,8 +594,25 @@ typedef struct _gcsHAL_SUBCOMMIT /* struct _gcsHAL_SUBCOMMIT * next; */ gctUINT64 next; + +#if gcdENABLE_SW_PREEMPTION + /* Process ID. */ + gctUINT32 pid; + + /* Engine type. */ + gceENGINE engine; + + /* Is it multi-core and shared mode?. */ + gctBOOL shared; + + /* Priority ID. */ + gctUINT32 priorityID; + + /* Does it require top priority. */ + gctBOOL topPriority; +#endif } -gcsHAL_SUBCOMMIT; +gcsHAL_SUBCOMMIT, * gcsHAL_SUBCOMMIT_PTR; /* gcvHAL_COMMIT */ typedef struct _gcsHAL_COMMIT @@ -586,6 +625,11 @@ typedef struct _gcsHAL_COMMIT /* Commit stamp of this commit. */ OUT gctUINT64 commitStamp; + +#if gcdENABLE_SW_PREEMPTION + /* If user need to merge the delta. */ + gctBOOL needMerge; +#endif } gcsHAL_COMMIT; @@ -593,6 +637,11 @@ gcsHAL_COMMIT; typedef struct _gcsHAL_COMMIT_DONE { IN gctUINT64 context; + +#if gcdENABLE_SW_PREEMPTION + /* Priority ID. */ + IN gctUINT32 priorityID; +#endif } gcsHAL_COMMIT_DONE; @@ -1043,6 +1092,12 @@ typedef struct _gcsHAL_DEC300_FLUSH_WAIT DEC300FlushWait; #endif +typedef struct _gcsHAL_SYNC_VIDEO_MEMORY +{ + IN gctUINT64 node; + IN gceSYNC_VIDEO_MEMORY_REASON reason; +} +gcsHAL_SYNC_VIDEO_MEMORY; typedef struct _gcsHAL_INTERFACE { @@ -1115,15 +1170,6 @@ typedef struct _gcsHAL_INTERFACE gcsHAL_READ_REGISTER_EX ReadRegisterDataEx; gcsHAL_WRITE_REGISTER_EX WriteRegisterDataEx; -#if VIVANTE_PROFILER - gcsHAL_GET_PROFILE_SETTING GetProfileSetting; - gcsHAL_SET_PROFILE_SETTING SetProfileSetting; - gcsHAL_READ_PROFILER_REGISTER_SETTING SetProfilerRegisterClear; - gcsHAL_READ_ALL_PROFILE_REGISTERS_PART1 RegisterProfileData_part1; - gcsHAL_READ_ALL_PROFILE_REGISTERS_PART2 RegisterProfileData_part2; - gcsHAL_PROFILE_REGISTERS_2D RegisterProfileData2D; -#endif - gcsHAL_SET_POWER_MANAGEMENT SetPowerManagement; gcsHAL_QUERY_POWER_MANAGEMENT QueryPowerManagement; gcsHAL_CONFIG_POWER_MANAGEMENT ConfigPowerManagement; @@ -1168,16 +1214,129 @@ typedef struct _gcsHAL_INTERFACE gcsHAL_DEC300_FLUSH DEC300Flush; gcsHAL_DEC300_FLUSH_WAIT DEC300FlushWait; #endif + gcsHAL_SYNC_VIDEO_MEMORY SyncVideoMemory; } u; } gcsHAL_INTERFACE; +#if VIVANTE_PROFILER +typedef struct _gcsHAL_PROFILER_INTERFACE +{ + /* Command code. */ + gceHAL_COMMAND_CODES command; + + /* Hardware type. */ + gceHARDWARE_TYPE hardwareType; + + /* Core index for current hardware type. */ + gctUINT32 coreIndex; + + /* Status value. */ + gceSTATUS status; + + /* Engine */ + gceENGINE engine; + + /* Ignore information from TSL when doing IO control */ + gctBOOL ignoreTLS; + + /* The mutext already acquired */ + IN gctBOOL commitMutex; + + /* Union of command structures. */ + union profiler_u + { + gcsHAL_GET_PROFILE_SETTING GetProfileSetting; + gcsHAL_SET_PROFILE_SETTING SetProfileSetting; + gcsHAL_READ_PROFILER_REGISTER_SETTING SetProfilerRegisterClear; + gcsHAL_READ_ALL_PROFILE_REGISTERS_PART1 RegisterProfileData_part1; + gcsHAL_READ_ALL_PROFILE_REGISTERS_PART2 RegisterProfileData_part2; + gcsHAL_PROFILE_REGISTERS_2D RegisterProfileData2D; + } + u; +} +gcsHAL_PROFILER_INTERFACE; +#endif + +/* State delta record. */ +typedef struct _gcsSTATE_DELTA_RECORD * gcsSTATE_DELTA_RECORD_PTR; +typedef struct _gcsSTATE_DELTA_RECORD +{ + /* State address. */ + gctUINT address; + + /* State mask. */ + gctUINT32 mask; + + /* State data. */ + gctUINT32 data; +} +gcsSTATE_DELTA_RECORD; + +/* State delta. */ +typedef struct _gcsSTATE_DELTA +{ + /* For debugging: the number of delta in the order of creation. */ + gctUINT num; + + /* Main state delta ID. Every time state delta structure gets reinitialized, + main ID is incremented. If main state ID overflows, all map entry IDs get + reinitialized to make sure there is no potential erroneous match after + the overflow.*/ + gctUINT id; + + /* The number of contexts pending modification by the delta. */ + gctINT refCount; + + /* Vertex element count for the delta buffer. */ + gctUINT elementCount; + + /* Number of states currently stored in the record array. */ + gctUINT recordCount; + + /* Record array; holds all modified states in gcsSTATE_DELTA_RECORD. */ + gctUINT64 recordArray; + + /* Map entry ID is used for map entry validation. If map entry ID does not + match the main state delta ID, the entry and the corresponding state are + considered not in use. */ + gctUINT64 mapEntryID; + gctUINT mapEntryIDSize; + + /* If the map entry ID matches the main state delta ID, index points to + the state record in the record array. */ + gctUINT64 mapEntryIndex; + + /* Previous and next state deltas in gcsSTATE_DELTA. */ + gctUINT64 prev; + gctUINT64 next; +} +gcsSTATE_DELTA; + +typedef struct _gcsQUEUE +{ + /* Pointer to next gcsQUEUE structure in gcsQUEUE. */ + gctUINT64 next; + + /* Event information. */ + gcsHAL_INTERFACE iface; +} +gcsQUEUE; + +/* A record chunk include multiple records to save allocation. */ +typedef struct _gcsQUEUE_CHUNK +{ + struct _gcsQUEUE_CHUNK * next; + + gcsQUEUE record[16]; +} +gcsQUEUE_CHUNK; #ifdef __cplusplus } #endif -#endif /* __gc_hal_driver_h_ */ +#endif /* __gc_hal_driver_shared_h_ */ diff --git a/drivers/amlogic/npu/inc/shared/gc_hal_driver_vg.h b/drivers/amlogic/npu/inc/shared/gc_hal_driver_vg_shared.h similarity index 98% rename from drivers/amlogic/npu/inc/shared/gc_hal_driver_vg.h rename to drivers/amlogic/npu/inc/shared/gc_hal_driver_vg_shared.h index b054e16..e669b8d 100644 --- a/drivers/amlogic/npu/inc/shared/gc_hal_driver_vg.h +++ b/drivers/amlogic/npu/inc/shared/gc_hal_driver_vg_shared.h @@ -11,8 +11,8 @@ *****************************************************************************/ -#ifndef __gc_hal_driver_vg_h_ -#define __gc_hal_driver_vg_h_ +#ifndef __gc_hal_driver_vg_shared_h_ +#define __gc_hal_driver_vg_shared_h_ #include "gc_hal_types.h" @@ -217,6 +217,6 @@ gcsTASK_FREE_CONTIGUOUS_MEMORY; } #endif -#endif /* __gc_hal_driver_h_ */ +#endif /* __gc_hal_driver_shared_h_ */ diff --git a/drivers/amlogic/npu/inc/shared/gc_hal_enum.h b/drivers/amlogic/npu/inc/shared/gc_hal_enum_shared.h similarity index 96% rename from drivers/amlogic/npu/inc/shared/gc_hal_enum.h rename to drivers/amlogic/npu/inc/shared/gc_hal_enum_shared.h index bb3a7e9..9187fcb 100644 --- a/drivers/amlogic/npu/inc/shared/gc_hal_enum.h +++ b/drivers/amlogic/npu/inc/shared/gc_hal_enum_shared.h @@ -529,6 +529,7 @@ typedef enum _gceFEATURE gcvFEATURE_DR_JD_DIFF_CONDITION_FOR_CACHELINE_MODE_PRE_FIX, gcvFEATURE_USC_BOTTLENECK_FIX, gcvFEATURE_OCB_REMAP_PHYSICAL_ADDRESS, + gcFEATURE_BIT_NN_HW_LIMITATION_NATIVE_KER_1x2_2x1, gcvFEATURE_NN_SLICE_PADDING_TO_64BYTE_ALIGN, gcvFEATURE_NN_DW_1x1_CONV_MERGE, gcvFEATURE_TP_REORDER_LAYER_SUSPEND_FIX, @@ -609,15 +610,53 @@ typedef enum _gceFEATURE gcvFEATURE_AI_GPU, gcvFEATURE_NN_FAST_FIRST_PIXEL_POOLING, gcvFEATURE_NN_FLOAT_POST_MULT, + gcvFEATURE_NN_ASYMMETRIC_INT8, gcvFEATURE_FORMAT_YUV_I010, /*support YUVI010 & P010_LSB format*/ gcFEATURE_BIT_NN_COMPRESSION_BYPASSS, - gcFEATURE_BIT_BFLOAT_KERNEL_COMPRESSION_ZERO_SKIP_FIX, + gcFEATURE_BIT_BFLOAT_COEF_COMPRESSION_ZERO_COEFBIT14_INVERSE, gcFEATURE_BIT_TP_KERNEL_1BYTE_ALGIN, gcFEATURE_PREPROCESS_IMG_BUF_640BYTE_LIMIT, - + gcFEATURE_BIT_TPLITE_BFLOAT16, gcvFEATURE_VIP_HW_FINAL_RELEASE, + gcvFEATURE_OUTPUT_CONVERT_UINT8_INT8_TO_UINT16_INT16_FIX, + gcvFEATURE_IMG_ADDR_NOT_WRAP_IF_OVER_OCB_ADDR_FIX, /* 2089 */ + gcFEATURE_BIT_V8_SINGLE_PORT_ACCUMULATION_BUFFER_RW_CONFICT_ZERO_SKIP_PERF_FIX, /* 2043 */ + gcFEATURE_BIT_BURST_COLLECT_DUMMY_DATA_WASTE_CYCLES_FIX, /* 2111 */ + gcFEATURE_BIT_TP_ACCESS_VIPSRAM_OT_IS_ONE_FIX, /* 2050 */ + + + gcFEATURE_BIT_USE_SINGLE_PORT_VIPSRAM, + gcFEATURE_VALUE_DDR_KERNEL_BURST_SIZE, + gcFEATURE_BIT_TILE_ACCESS_CAPABILITY, + gcFEATURE_BIT_FAST_DP3_PREPROCESSOR, + + gcvFEATURE_BIT_INIMG_NOT_64BYTE_ALIGN_CACHELINE_MODE_FIX, /* 2112 */ + gcFEATURE_BIT_DEPTHWISE_16BIT_FORMAT, + + gcvFEATURE_2D_TILESTATUS_ROTATION,/*Fix fastclear feature with rotation*/ + gcFEATURE_BIT_TP_FC_FLOAT_LAST_PIXEL_NEGATIVE_0_FIX, + gcvFEATURE_TS_FC_VULKAN_SUPPORT, + gcFEATURE_BIT_V8_ACCUMLATION_READ_OUT_HAS_BUBBLES_PERF_FIX, /* 2044 */ + gcFEATURE_BIT_MAX_TILE_SIZE, + gcvFEATURE_2D_TARGET_MAJOR_SUPER_TILE, /*target support supertile Y major*/ + gcFEATURE_BIT_INIMAGE_2DTILE_NOT_LESS_160PIXEL_FIX, + gcFEATURE_BIT_NN_IN_TILE_DATA_IS_ALL_PAD_FIX, /* 2131 */ + + /* TP reorder the int tile x should be less than 512 */ + gcFEATURE_TP_REORDER_INTILE_X_SIZE_512_FIX, + gcFEATURE_NN_WASET_COEF_READ_WRITE_BANDWIDTH_128BYTE_VIPSRAM_IN_FULL_PATIAL_CACHE_MODE, + gcFEATURE_BIT_BFP_COEF_AUTO_PAD_INCOMPLETE_ZERO_IN_KZ_PLANE, + gcvFEATURE_NN_FLOAT32_IO, + gcvFEATURE_TP_FLOAT32_IO, + + /* Q channel support. */ + gcvFEATURE_Q_CHANNEL_SUPPORT, + + /* MMU descriptor new refinement. */ + gcvFEATURE_MMU_PAGE_DESCRIPTOR, + /* Insert features above this comment only. */ gcvFEATURE_COUNT /* Not a feature. */ } @@ -1174,6 +1213,12 @@ typedef enum _gceSURF_FORMAT gcvSURF_B8, gcvSURF_G32F, gcvSURF_B32F, + + /* Intensity formats */ + gcvSURF_I4 = 2000, + gcvSURF_I8, + gcvSURF_I12, + gcvSURF_I16, } gceSURF_FORMAT; @@ -1470,6 +1515,7 @@ typedef enum _gceSTATUS gcvSTATUS_DEVICE = -27, gcvSTATUS_NOT_MULTI_PIPE_ALIGNED = -28, gcvSTATUS_OUT_OF_SAMPLER = -29, + gcvSTATUS_PROBE_LATER = -30, /* Linker errors. */ gcvSTATUS_GLOBAL_TYPE_MISMATCH = -1000, @@ -1708,6 +1754,9 @@ typedef enum _gceHAL_COMMAND_CODES /* Destory MMU. */ gcvHAL_DESTROY_MMU, + + /* sync video memory for special memory pool */ + gcvHAL_SYNC_VIDEO_MEMORY, /*************** Reserved end ***************/ } gceHAL_COMMAND_CODES; @@ -1795,6 +1844,7 @@ typedef enum _gcePOOL gcvPOOL_USER, gcvPOOL_INTERNAL_SRAM, gcvPOOL_EXTERNAL_SRAM, + gcvPOOL_LOCAL_EXCLUSIVE, gcvPOOL_NUMBER_OF_POOLS } @@ -1827,6 +1877,14 @@ typedef enum _gceDUMP_BUFFER_TYPE } gceDUMP_BUFFER_TYPE; +typedef enum _gceSYNC_VIDEO_MEMORY_REASON +{ + gcvSYNC_REASON_NONE = 0, + gcvSYNC_REASON_BEFORE_READ, + gcvSYNC_REASON_AFTER_WRITE, +} +gceSYNC_VIDEO_MEMORY_REASON; + #ifdef __cplusplus } #endif diff --git a/drivers/amlogic/npu/inc/shared/gc_hal_profiler.h b/drivers/amlogic/npu/inc/shared/gc_hal_profiler_shared.h similarity index 65% rename from drivers/amlogic/npu/inc/shared/gc_hal_profiler.h rename to drivers/amlogic/npu/inc/shared/gc_hal_profiler_shared.h index 0664a7b..6293931 100644 --- a/drivers/amlogic/npu/inc/shared/gc_hal_profiler.h +++ b/drivers/amlogic/npu/inc/shared/gc_hal_profiler_shared.h @@ -229,6 +229,126 @@ typedef struct _gcsPROFILER_COUNTERS } gcsPROFILER_COUNTERS; +typedef enum _gceVIP_PROBE_COUNTER +{ + gcvVIP_PROBE_COUNTER_NEURAL_NET, + gcvVIP_PROBE_COUNTER_TENSOR_PROCESSOR, + gcvVIP_PROBE_COUNTER_COUNT +} +gceVIP_PROBE_COUNTER; + +/* Mask definations for overflow indicator of TP */ +typedef enum _gceTPCOUNTER_OVERFLOW +{ + gcvTPCOUNTER_LAYER_ID_OVERFLOW = (1 << 0), + gcvTPCOUNTER_TOTAL_BUSY_CYCLE_OVERFLOW = (1 << 1), + gcvTPCOUNTER_TOTAL_READ_BW_DDR_OVERFLOW = (1 << 2), + gcvTPCOUNTER_TOTAL_WRITE_BW_DDR_OVERFLOW = (1 << 3), + gcvTPCOUNTER_TOTAL_READ_BW_SRAM_OVERFLOW = (1 << 4), + gcvTPCOUNTER_TOTAL_WRITE_BW_SRAM_OVERFLOW = (1 << 5), + gcvTPCOUNTER_TOTAL_READ_BW_OCB_OVERFLOW = (1 << 6), + gcvTPCOUNTER_TOTAL_WRITE_BW_OCB_OVERFLOW = (1 << 7), + gcvTPCOUNTER_FC_PIX_CNT_OVERFLOW = (1 << 8), + gcvTPCOUNTER_FC_ZERO_SKIP_OVERFLOW = (1 << 9), + gcvTPCOUNTER_FC_COEF_CNT_OVERFLOW = (1 << 10), + gcvTPCOUNTER_FC_COEF_ZERO_CNT_OVERFLOW = (1 << 11), + gcvTPCOUNTER_TOTAL_IDLE_CYCLE_CORE0_OVERFLOW = (1 << 0), + gcvTPCOUNTER_TOTAL_IDLE_CYCLE_CORE1_OVERFLOW = (1 << 1), + gcvTPCOUNTER_TOTAL_IDLE_CYCLE_CORE2_OVERFLOW = (1 << 2), + gcvTPCOUNTER_TOTAL_IDLE_CYCLE_CORE3_OVERFLOW = (1 << 3), +} +_gceTPCOUNTER_OVERFLOW; + +/* Mask definations for overflow indicator of NN */ +typedef enum _gceNNCOUNTER_OVERFLOW +{ + gcvNNCOUNTER_TOTAL_BUSY_CYCLE_OVERFLOW = (1 << 0), + gcvNNCOUNTER_TOTAL_READ_CYCLE_DDR_OVERFLOW = (1 << 2), + gcvNNCOUNTER_TOTAL_READ_BW_DDR_OVERFLOW = (1 << 3), + gcvNNCOUNTER_TOTAL_WRITE_CYCLE_DDR_OVERFLOW = (1 << 4), + gcvNNCOUNTER_TOTAL_WRITE_BW_DDR_OVERFLOW = (1 << 5), + gcvNNCOUNTER_TOTAL_READ_SYCLE_SRAM_OVERFLOW = (1 << 6), + gcvNNCOUNTER_TOTAL_WRITE_CYCLE_SRAM_OVERFLOW = (1 << 7), + gcvNNCOUNTER_TOTAL_MAC_CYCLE_OVERFLOW = (1 << 8), + gcvNNCOUNTER_TOTAL_MAC_COUNT_OVERFLOW = (1 << 9), + gcvNNCOUNTER_ZERO_COEF_SKIP_COUNT_OVERFLOW = (1 << 10), + gcvNNCOUNTER_NON_ZERO_COEF_COUNT_OVERFLOW = (1 << 11), +} +_gceNNCOUNTER_OVERFLOW; + +#define MODULE_NN_RESERVED_COUNTER_NUM 0x9 +typedef struct _gcsPROFILER_VIP_PROBE_COUNTERS +{ + /* NN */ + gctUINT32 nn_layer_id; + gctUINT32 nn_layer_id_overflow; + gctUINT32 nn_instr_info; + gctUINT32 nn_total_busy_cycle; + gctUINT32 nn_total_busy_cycle_overflow; + gctUINT32 nn_total_read_cycle_ddr; + gctUINT32 nn_total_read_cycle_ddr_overflow; + gctUINT32 nn_total_read_valid_bandwidth_ddr; + gctUINT32 nn_total_read_valid_bandwidth_ddr_overflow; + gctUINT32 nn_total_write_cycle_ddr; + gctUINT32 nn_total_write_cycle_ddr_overflow; + gctUINT32 nn_total_write_valid_bandwidth_ddr; + gctUINT32 nn_total_write_valid_bandwidth_ddr_overflow; + gctUINT32 nn_total_read_cycle_sram; + gctUINT32 nn_total_read_cycle_sram_overflow; + gctUINT32 nn_total_write_cycle_sram; + gctUINT32 nn_total_write_cycle_sram_overflow; + gctUINT32 nn_total_mac_cycle; + gctUINT32 nn_total_mac_cycle_overflow; + gctUINT32 nn_total_mac_count; + gctUINT32 nn_total_mac_count_overflow; + gctUINT32 nn_zero_coef_skip_count; + gctUINT32 nn_zero_coef_skip_count_overflow; + gctUINT32 nn_non_zero_coef_count; + gctUINT32 nn_non_zero_coef_count_overflow; + + gctUINT32 nn_reserved_counter[4 * MODULE_NN_RESERVED_COUNTER_NUM]; + gctUINT32 nn_total_idle_cycle_core_overflow; + gctUINT32 nn_total_idle_cycle_core[32]; + + /* TP */ + gctUINT32 tp_layer_id; + gctUINT32 tp_layer_id_overflow; + gctUINT32 tp_total_busy_cycle; + gctUINT32 tp_total_busy_cycle_overflow; + + gctUINT32 tp_total_read_bandwidth_cache; + gctUINT32 tp_total_read_bandwidth_cache_overflow; + gctUINT32 tp_total_write_bandwidth_cache; + gctUINT32 tp_total_write_bandwidth_cache_overflow; + + gctUINT32 tp_total_read_bandwidth_sram; + gctUINT32 tp_total_read_bandwidth_sram_overflow; + gctUINT32 tp_total_write_bandwidth_sram; + gctUINT32 tp_total_write_bandwidth_sram_overflow; + + + gctUINT32 tp_total_read_bandwidth_ocb; + gctUINT32 tp_total_read_bandwidth_ocb_overflow; + gctUINT32 tp_total_write_bandwidth_ocb; + gctUINT32 tp_total_write_bandwidth_ocb_overflow; + + gctUINT32 tp_fc_pix_count; + gctUINT32 tp_fc_zero_skip_count; + gctUINT32 tp_fc_pix_count_overflow; + gctUINT32 tp_fc_zero_skip_count_overflow; + + gctUINT32 tp_fc_coef_count; + gctUINT32 tp_fc_coef_zero_count; + gctUINT32 tp_fc_coef_count_overflow; + gctUINT32 tp_fc_coef_zero_count_overflow; + + gctUINT32 tp_total_idle_cycle_core[16]; + gctUINT32 tp_total_idle_cycle_core_overflows[16]; + + /* VIP SH */ +} +gcsPROFILER_VIP_PROBE_COUNTERS; + #ifdef __cplusplus } #endif diff --git a/drivers/amlogic/npu/inc/shared/gc_hal_types.h b/drivers/amlogic/npu/inc/shared/gc_hal_types_shared.h similarity index 99% rename from drivers/amlogic/npu/inc/shared/gc_hal_types.h rename to drivers/amlogic/npu/inc/shared/gc_hal_types_shared.h index e096f76..412079c 100644 --- a/drivers/amlogic/npu/inc/shared/gc_hal_types.h +++ b/drivers/amlogic/npu/inc/shared/gc_hal_types_shared.h @@ -11,8 +11,8 @@ *****************************************************************************/ -#ifndef __gc_hal_types_h_ -#define __gc_hal_types_h_ +#ifndef __gc_hal_types_shared_h_ +#define __gc_hal_types_shared_h_ #include "gc_hal_version.h" #include "gc_hal_options.h" @@ -357,7 +357,8 @@ gcs2D_PROFILE; #define gcmIS_ERROR(status) (status < 0) #define gcmNO_ERROR(status) (status >= 0) #define gcmIS_SUCCESS(status) (status == gcvSTATUS_OK) - +#define gcmERROR2PTR(err) ((gctPOINTER)(err)) +#define gcmPTR2ERROR(ptr) ((gctINT64)(ptr)) /******************************************************************************\ ********************************* Field Macros ********************************* \******************************************************************************/ @@ -940,6 +941,6 @@ gcsHAL_PATCH_VIDMEM_TIMESTAMP; } #endif -#endif /* __gc_hal_types_h_ */ +#endif /* __gc_hal_types_shared_h_ */ diff --git a/drivers/amlogic/npu/inc/shared/gc_hal_vg.h b/drivers/amlogic/npu/inc/shared/gc_hal_vg_shared.h similarity index 100% rename from drivers/amlogic/npu/inc/shared/gc_hal_vg.h rename to drivers/amlogic/npu/inc/shared/gc_hal_vg_shared.h diff --git a/drivers/amlogic/npu/kernel/Android.mk b/drivers/amlogic/npu/kernel/Android.mk old mode 100644 new mode 100755 diff --git a/drivers/amlogic/npu/kernel/arch/cebuild/makefile b/drivers/amlogic/npu/kernel/arch/cebuild/makefile old mode 100644 new mode 100755 diff --git a/drivers/amlogic/npu/kernel/arch/cebuild/sources b/drivers/amlogic/npu/kernel/arch/cebuild/sources old mode 100644 new mode 100755 diff --git a/drivers/amlogic/npu/kernel/arch/gc_hal_kernel_context.c b/drivers/amlogic/npu/kernel/arch/gc_hal_kernel_context.c index a059ad9..5e767dd 100644 --- a/drivers/amlogic/npu/kernel/arch/gc_hal_kernel_context.c +++ b/drivers/amlogic/npu/kernel/arch/gc_hal_kernel_context.c @@ -56,7 +56,6 @@ #include "gc_hal.h" #include "gc_hal_kernel.h" #include "gc_hal_kernel_context.h" -#include "gc_hal_kernel_buffer.h" /******************************************************************************\ ******************************** Debugging Macro ******************************* @@ -236,6 +235,7 @@ _FlushPipe( gctBOOL blt; gctBOOL peTSFlush; gctBOOL multiCluster; + gctBOOL computeOnly; txCacheFix = gckHARDWARE_IsFeatureAvailable(Context->hardware, gcvFEATURE_TEX_CACHE_FLUSH_FIX); @@ -264,6 +264,8 @@ _FlushPipe( peTSFlush = gckHARDWARE_IsFeatureAvailable(Context->hardware, gcvFEATURE_PE_TILE_CACHE_FLUSH_FIX); + computeOnly = gckHARDWARE_IsFeatureAvailable(Context->hardware, gcvFEATURE_COMPUTE_ONLY); + flushSlots = blt ? 10 : 6; if (Pipe == gcvPIPE_3D) @@ -278,7 +280,7 @@ _FlushPipe( flushSlots += 2; } - if (fcFlushStall) + if (fcFlushStall && !computeOnly) { /* Flush tile status cache. */ flushSlots += blt ? ((!peTSFlush) ? 14 :10) : 6; @@ -1049,7 +1051,7 @@ _FlushPipe( ~0U : (~(~0U << ((1 ? 12:8) - (0 ? 12:8) + 1))))))) << (0 ? 12:8))); } - if (fcFlushStall) + if (fcFlushStall && !computeOnly) { if (!peTSFlush && blt) { @@ -2348,6 +2350,179 @@ _SemaphoreStall( #endif #if (gcdENABLE_3D) + +#if gcdENABLE_SW_PREEMPTION +typedef struct { + gctUINT inputBase; + gctUINT count; + gctUINT outputBase; +} +gcsSTATEMIRROR; + +const gcsSTATEMIRROR mirroredStates[] = +{ + {0x5800, 0x300, 0x5B00}, + {0x5600, 0x100, 0x5700}, + {0xD800, 0x140, 0xD000}, +}; + +gctUINT mirroredStatesCount = 0; + +static gceSTATUS +_ResetDelta( + IN gcsSTATE_DELTA_PTR StateDelta + ) +{ + /* Not attached yet, advance the ID. */ + StateDelta->id += 1; + + /* Did ID overflow? */ + if (StateDelta->id == 0) + { + /* Reset the map to avoid erroneous ID matches. */ + gckOS_ZeroMemory(gcmUINT64_TO_PTR(StateDelta->mapEntryID), StateDelta->mapEntryIDSize); + + /* Increment the main ID to avoid matches after reset. */ + StateDelta->id += 1; + } + + /* Reset the vertex element count. */ + StateDelta->elementCount = 0; + + /* Reset the record count. */ + StateDelta->recordCount = 0; + + /* Success. */ + return gcvSTATUS_OK; +} + +static gceSTATUS +_DestroyDelta( + IN gckCONTEXT Context, + IN gcsSTATE_DELTA_PTR delta +) +{ + gctUINT_PTR mapEntryIndex = gcmUINT64_TO_PTR(delta->mapEntryIndex); + gctUINT_PTR mapEntryID = gcmUINT64_TO_PTR(delta->mapEntryID); + gcsSTATE_DELTA_RECORD_PTR recordArray = gcmUINT64_TO_PTR(delta->recordArray); + gceSTATUS status = gcvSTATUS_OK; + + gcmkHEADER(); + + /* Free map index array. */ + if (mapEntryIndex != gcvNULL) + { + gcmkONERROR(gcmkOS_SAFE_FREE(Context->os, mapEntryIndex)); + } + + /* Allocate map ID array. */ + if (mapEntryID != gcvNULL) + { + gcmkONERROR(gcmkOS_SAFE_FREE(Context->os, mapEntryID)); + } + + /* Free state record array. */ + if (recordArray != gcvNULL) + { + gcmkONERROR(gcmkOS_SAFE_FREE(Context->os, recordArray)); + } + + gcmkONERROR(gcmkOS_SAFE_FREE(Context->os, delta)); + +OnError: + + /* Return the status. */ + gcmkFOOTER_NO(); + return gcvSTATUS_OK; +} + +static gceSTATUS +_AllocateDelta( + IN gckCONTEXT Context, + OUT gcsSTATE_DELTA_PTR * Delta + ) +{ + gckCONTEXT context = Context; + gckOS os = context->os; + gceSTATUS status; + gcsSTATE_DELTA_PTR delta = gcvNULL; + gctPOINTER pointer = gcvNULL; + + gcmkHEADER(); + + if (context->maxState == 0) + { + *Delta = NULL; + gcmkFOOTER_NO(); + return gcvSTATUS_OK; + } + + /* Allocate the state delta structure. */ + gcmkONERROR(gckOS_Allocate( + os, gcmSIZEOF(gcsSTATE_DELTA), (gctPOINTER *) &delta + )); + + /* Reset the context buffer structure. */ + gckOS_ZeroMemory(delta, gcmSIZEOF(gcsSTATE_DELTA)); + + if (context->maxState > 0) + { + /* Compute UINT array size. */ + gctUINT32 bytes = gcmSIZEOF(gctUINT) * context->maxState; + + /* Allocate map ID array. */ + gcmkONERROR(gckOS_Allocate( + os, bytes, &pointer + )); + + delta->mapEntryID = gcmPTR_TO_UINT64(pointer); + + /* Set the map ID size. */ + delta->mapEntryIDSize = bytes; + + /* Reset the record map. */ + gckOS_ZeroMemory(gcmUINT64_TO_PTR(delta->mapEntryID), bytes); + + /* Allocate map index array. */ + gcmkONERROR(gckOS_Allocate( + os, bytes, &pointer + )); + + delta->mapEntryIndex = gcmPTR_TO_UINT64(pointer); + + } + + if (context->numStates > 0) + { + /* Allocate state record array. */ + gcmkONERROR(gckOS_Allocate( + os, + gcmSIZEOF(gcsSTATE_DELTA_RECORD) * context->numStates, + &pointer + )); + + delta->recordArray = gcmPTR_TO_UINT64(pointer); + } + + /* Reset the new state delta. */ + _ResetDelta(delta); + + *Delta = delta; + + gcmkFOOTER(); + return status; + +OnError: + if (delta) + { + _DestroyDelta(Context, delta); + } + + gcmkFOOTER_NO(); + return status; +} +#endif + static gctUINT32 _SwitchPipe( IN gckCONTEXT Context, @@ -2846,8 +3021,9 @@ _UpdateUnifiedReg( #endif #if (gcdENABLE_3D) + static gceSTATUS -_InitializeContextBuffer( +_InitializeNoShaderAndPixelEngine( IN gckCONTEXT Context ) { @@ -2855,26 +3031,11 @@ _InitializeContextBuffer( gctUINT32 index; #if gcdENABLE_3D - gctBOOL halti0, halti1, halti2, halti3, halti4, halti5; - gctUINT i; - gctUINT vertexUniforms, fragmentUniforms; - gctBOOL unifiedUniform; - gctBOOL hasGS, hasTS; - gctBOOL genericAttrib; - gctBOOL hasICache; - gctBOOL hasICachePrefetch; - gctUINT numRT = 0; - gctUINT numSamplers = 32; - gctBOOL hasTXdesc; + gctBOOL halti5; gctBOOL hasSecurity; gctBOOL hasRobustness; gctBOOL multiCluster; - gctBOOL smallBatch; - gctBOOL multiCoreBlockSetCfg2; gctUINT clusterAliveMask; - gctBOOL hasPSCSThrottle; - gctBOOL hasMsaaFragOperation; - gctBOOL newGPipe; #endif gckHARDWARE hardware; @@ -2905,75 +3066,11 @@ _InitializeContextBuffer( /**************************************************************************/ /* Build 3D states. *******************************************************/ - halti0 = gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_HALTI0); - halti1 = gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_HALTI1); - halti2 = gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_HALTI2); - halti3 = gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_HALTI3); - halti4 = gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_HALTI4); halti5 = gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_HALTI5); - hasGS = gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_GEOMETRY_SHADER); - hasTS = gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_TESSELLATION); - genericAttrib = gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_GENERIC_ATTRIB); - hasICache = gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_SHADER_HAS_INSTRUCTION_CACHE); - hasTXdesc = gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_TX_DESCRIPTOR); hasSecurity = gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_SECURITY); hasRobustness = gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_ROBUSTNESS); - hasICachePrefetch = gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_SH_INSTRUCTION_PREFETCH); multiCluster = gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_MULTI_CLUSTER); - smallBatch = gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_SMALL_BATCH) && hardware->options.smallBatch; - multiCoreBlockSetCfg2 = gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_MULTI_CORE_BLOCK_SET_CONFIG2); clusterAliveMask = hardware->identity.clusterAvailMask & hardware->options.userClusterMask; - hasPSCSThrottle = gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_PSCS_THROTTLE); - hasMsaaFragOperation = gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_MSAA_FRAGMENT_OPERATION); - newGPipe = gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_NEW_GPIPE); - - /* Multi render target. */ - if (Context->hardware->identity.chipModel == gcv880 && - Context->hardware->identity.chipRevision == 0x5124 && - Context->hardware->identity.customerID == 0x103) - { - numRT = 16; - } - else if (halti2 || - ((Context->hardware->identity.chipModel == gcv900) && - (Context->hardware->identity.chipRevision == 0x5250))) - { - numRT = 8; - } - else if (halti0) - { - numRT = 4; - } - else - { - numRT = 1; - } - - if (hasGS && hasTS) - { - numSamplers = 80; - } - - /* Query how many uniforms can support. */ - gcmCONFIGUREUNIFORMS2(Context->hardware->identity.chipModel, - Context->hardware->identity.chipRevision, - halti5, - smallBatch, - Context->hardware->identity.numConstants, - unifiedUniform, - vertexUniforms, - fragmentUniforms); - -#if !gcdENABLE_UNIFIED_CONSTANT - if (Context->hardware->identity.numConstants > 256) - { - unifiedUniform = gcvTRUE; - } - else - { - unifiedUniform = gcvFALSE; - } -#endif /* Store the 3D entry index. */ Context->entryOffset3D = (gctUINT)index * gcmSIZEOF(gctUINT32); @@ -3022,11 +3119,6 @@ _InitializeContextBuffer( index += _State(Context, index, 0x03904 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); } - index += _State(Context, index, 0x03814 >> 2, 0x00000001, 1, gcvFALSE, gcvFALSE); - index += _CLOSE_RANGE(); - index += _State(Context, index, 0x03818 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x0381C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - if (halti5) { gctUINT32 uscControl = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? @@ -3077,1601 +3169,2864 @@ _InitializeContextBuffer( index += _State(Context, index, 0x03854 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); } - if (hasGS) - { - index += _State(Context, index, 0x0388C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - } - - index += _State(Context, index, 0x0384C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _CLOSE_RANGE(); - /* Front End states. */ - if (halti5) - { - index += _State(Context, index, 0x17800 >> 2, 0x00000000, 32, gcvFALSE, gcvFALSE); - index += _CLOSE_RANGE(); - index += _State(Context, index, 0x007C4 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x007D0 >> 2, 0x00000000, 2, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x007D8 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x17A80 >> 2, 0x00000000, 32, gcvFALSE, gcvFALSE); - if (genericAttrib || newGPipe) - { - index += _State(Context, index, 0x17880 >> 2, 0x00000000, 32, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x17900 >> 2, 0x00000000, 32, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x17980 >> 2, 0x00000000, 32, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x17A00 >> 2, 0x3F800000, 32, gcvFALSE, gcvFALSE); - } - } - else - { - index += _State(Context, index, 0x00600 >> 2, 0x00000000, (halti0 ? 16 : 12), gcvFALSE, gcvFALSE); - index += _CLOSE_RANGE(); - if (genericAttrib) - { - index += _State(Context, index, 0x006C0 >> 2, 0x00000000, 16, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x00700 >> 2, 0x00000000, 16, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x00740 >> 2, 0x00000000, 16, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x00780 >> 2, 0x3F800000, 16, gcvFALSE, gcvFALSE); - } - } + /* Memory Controller */ + index += _State(Context, index, 0x01654 >> 2, 0x00200000, 1, gcvFALSE, gcvFALSE); - if (halti2 || (Context->hardware->identity.streamCount > 8)) - { - index += _State(Context, index, 0x14600 >> 2, 0x00000000, 16, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x14640 >> 2, 0x00000000, 16, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x14680 >> 2, 0x00000000, 16, gcvFALSE, gcvFALSE); - } - else if (Context->hardware->identity.streamCount > 1) + if (hasSecurity || hasRobustness) { - index += _State(Context, index, 0x00680 >> 2, 0x00000000, 8, gcvFALSE, gcvTRUE); - index += _State(Context, index, 0x006A0 >> 2, 0x00000000, 8, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x001AC >> 2, ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 16:16) - (0 ? + 16:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 16:16) - (0 ? + 16:16) + 1))))))) << (0 ? + 16:16))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 16:16) - (0 ? + 16:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 16:16) - (0 ? 16:16) + 1))))))) << (0 ? 16:16))), 1, gcvFALSE, gcvFALSE); } - else - { - index += _State(Context, index, 0x0064C >> 2, 0x00000000, 1, gcvFALSE, gcvTRUE); - index += _State(Context, index, 0x00650 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - } - index += _State(Context, index, 0x00644 >> 2, 0x00000000, 1, gcvFALSE, gcvTRUE); - index += _State(Context, index, 0x00648 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x00674 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + /* Semaphore/stall. */ + index += _SemaphoreStall(Context, index); +#endif - if (halti1) - { - index += _State(Context, index, 0x00678 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x0067C >> 2, 0xFFFFFFFF, 1, gcvFALSE, gcvFALSE); - } - - index += _CLOSE_RANGE(); + /**************************************************************************/ + /* Link to another address. ***********************************************/ - if (hasRobustness) - { - index += _State(Context, index, 0x146C0 >> 2, 0x00000000, 16, gcvFALSE, gcvTRUE); - index += _CLOSE_RANGE(); - index += _State(Context, index, 0x007F8 >> 2, 0x00000000, 1, gcvFALSE, gcvTRUE); - index += _CLOSE_RANGE(); - } + Context->linkIndex3D = (gctUINT)index; - /* WD */ - if (multiCluster) + if (buffer != gcvNULL) { - index += _State(Context, index, 0x18404 >> 2, ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 1:0) - (0 ? - 1:0) + 1) == 32) ? + buffer[index + 0] + = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? ~0U : (~(~0U << ((1 ? - 1:0) - (0 ? - 1:0) + 1))))))) << (0 ? - 1:0))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? - 1:0) - (0 ? - 1:0) + 1) == 32) ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x08 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? - 1:0) - (0 ? 1:0) + 1))))))) << (0 ? 1:0))), 1, gcvFALSE, gcvFALSE); + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))); + + buffer[index + 1] + = 0; } - if (halti5) - { - index += _State(Context, index, 0x008B8 >> 2, ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 4:4) - (0 ? - 4:4) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 4:4) - (0 ? - 4:4) + 1))))))) << (0 ? - 4:4))) | (((gctUINT32) ((gctUINT32) (smallBatch ? - 0x0 : 0x1) & ((gctUINT32) ((((1 ? - 4:4) - (0 ? - 4:4) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 4:4) - (0 ? - 4:4) + 1))))))) << (0 ? - 4:4))) | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 5:5) - (0 ? - 5:5) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 5:5) - (0 ? - 5:5) + 1))))))) << (0 ? - 5:5))) | (((gctUINT32) ((gctUINT32) (smallBatch ? - 0x0 : 0x1) & ((gctUINT32) ((((1 ? - 5:5) - (0 ? - 5:5) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 5:5) - (0 ? - 5:5) + 1))))))) << (0 ? - 5:5))) | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 8:8) - (0 ? - 8:8) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 8:8) - (0 ? - 8:8) + 1))))))) << (0 ? - 8:8))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? - 8:8) - (0 ? - 8:8) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 8:8) - (0 ? - 8:8) + 1))))))) << (0 ? - 8:8))) | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 9:9) - (0 ? - 9:9) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 9:9) - (0 ? - 9:9) + 1))))))) << (0 ? - 9:9))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? - 9:9) - (0 ? - 9:9) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 9:9) - (0 ? 9:9) + 1))))))) << (0 ? 9:9))), 1, gcvFALSE, gcvFALSE); + index += 2; - index += _State(Context, index, 0x15600 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - } - else - { - /* This register is programed by all chips, which program all DECODE_SELECT as VS - ** except SAMPLER_DECODE_SELECT. - */ - index += _State(Context, index, 0x00860 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - } + /* Store the end of the context buffer. */ + Context->bufferSize = index * gcmSIZEOF(gctUINT32); - if (hasICache) - { - /* I-Cache states. */ - index += _State(Context, index, 0x00868 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x0086C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x0304C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x01028 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _CLOSE_RANGE(); - if (hasICachePrefetch) - { - if (halti5) - { - index += _State(Context, index, 0x15604 >> 2, 0x00000000, 1, gcvFALSE, gcvTRUE); - index += _State(Context, index, 0x01094 >> 2, 0x00000000, 1, gcvFALSE, gcvTRUE); - } - else - { - index += _State(Context, index, 0x00890 >> 2, 0x00000000, 1, gcvFALSE, gcvTRUE); - index += _State(Context, index, 0x0104C >> 2, 0x00000000, 1, gcvFALSE, gcvTRUE); - } - index += _CLOSE_RANGE(); - } - } + /**************************************************************************/ + /* Pipe switch for the case where neither 2D nor 3D are used. *************/ - if (multiCluster) - { - index += _State(Context, index, 0x010A8 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - } + /* Store the 3D entry index. */ + Context->entryOffsetXDFrom2D = (gctUINT)index * gcmSIZEOF(gctUINT32); - /* Vertex Shader states. */ - index += _State(Context, index, 0x00804 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x00808 >> 2, ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 5:0) - (0 ? - 5:0) + 1) == 32) ? + /* Switch to 3D pipe. */ + index += _SwitchPipe(Context, index, gcvPIPE_3D); + + /* Store the location of the link. */ + Context->linkIndexXD = (gctUINT)index; + + if (buffer != gcvNULL) + { + buffer[index + 0] + = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? ~0U : (~(~0U << ((1 ? - 5:0) - (0 ? - 5:0) + 1))))))) << (0 ? - 5:0))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? - 5:0) - (0 ? - 5:0) + 1) == 32) ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x08 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? - 5:0) - (0 ? 5:0) + 1))))))) << (0 ? 5:0))), 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x0080C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x00830 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))); - if (halti5) - { - index += _State(Context, index, 0x00898 >> 2, 0x00000000, 2, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x008A0 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x00870 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x008A8 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x008C0 >> 2, 0x00000000, 8, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x008E0 >> 2, 0x00000000, 8, gcvFALSE, gcvFALSE); - } - else - { - index += _State(Context, index, 0x00810 >> 2, 0x00000000, 4, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x00820 >> 2, 0x00000000, 4, gcvFALSE, gcvFALSE); + buffer[index + 1] + = 0; } - if (multiCluster) - { - index += _State(Context, index, 0x007FC >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x15608 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - } + index += 2; - index += _CLOSE_RANGE(); - /* GS */ - if (hasGS) - { - index += _State(Context, index, 0x01100 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x01104 >> 2, 0x00000001, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x01108 >> 2, 0x01000001, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x0110C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x01110 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x01114 >> 2, 0x00000000, 1, gcvFALSE, gcvTRUE); - index += _State(Context, index, 0x0111C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x01140 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x01144 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x01148 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x0114C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x01154 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x01120 >> 2, 0x00000000, 8, gcvFALSE, gcvFALSE); - index += _CLOSE_RANGE(); - } + /**************************************************************************/ + /* Save size for buffer. **************************************************/ - /* TCS & TES */ - if (hasTS) - { - index += _State(Context, index, 0x007C0 >> 2, 0x00000003, 1, gcvFALSE, gcvFALSE); + Context->totalSize = index * gcmSIZEOF(gctUINT32); - index += _State(Context, index, 0x14A14 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x14A18 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x14A1C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x14A40 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x14A00 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x14A04 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x14A08 >> 2, 0x00000000, 1, gcvFALSE, gcvTRUE); - index += _State(Context, index, 0x14A10 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x14A20 >> 2, 0x00000000, 8, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x14A44 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x14A4C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + /* Success. */ + gcmkFOOTER_NO(); + return gcvSTATUS_OK; - index += _CLOSE_RANGE(); +} - index += _State(Context, index, 0x14B18 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x14B1C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x14B20 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x14B04 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x14B08 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x14B0C >> 2, 0x00000000, 1, gcvFALSE, gcvTRUE); - index += _State(Context, index, 0x14B14 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x14B40 >> 2, 0x00000000, 8, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x14B24 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x14B2C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x14B34 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); +static gceSTATUS +_InitializeContextBuffer( + IN gckCONTEXT Context + ) +{ + gctUINT32_PTR buffer = gcvNULL; + gctUINT32 index; - index += _State(Context, index, 0x14B00 >> 2, 0x00040000, 1, gcvFALSE, gcvFALSE); +#if gcdENABLE_3D + gctBOOL halti0, halti1, halti2, halti3, halti4, halti5; + gctUINT i; + gctUINT vertexUniforms, fragmentUniforms; + gctBOOL unifiedUniform; + gctBOOL hasGS, hasTS; + gctBOOL genericAttrib; + gctBOOL hasICache; + gctBOOL hasICachePrefetch; + gctUINT numRT = 0; + gctUINT numSamplers = 32; + gctBOOL hasTXdesc; + gctBOOL hasSecurity; + gctBOOL hasRobustness; + gctBOOL multiCluster; + gctBOOL smallBatch; + gctBOOL multiCoreBlockSetCfg2; + gctUINT clusterAliveMask; + gctBOOL hasPSCSThrottle; + gctBOOL hasMsaaFragOperation; + gctBOOL newGPipe; +#endif - } + gckHARDWARE hardware; - index += _CLOSE_RANGE(); + gcmkHEADER(); - /* TFB */ - if (gckHARDWARE_IsFeatureAvailable(Context->hardware, gcvFEATURE_HW_TFB)) - { - index += _State(Context, index, 0x1C000 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x1C008 >> 2, 0x00000000, 1, gcvFALSE, gcvTRUE); - index += _State(Context, index, (0x1C040 >> 2) + (0 << 4), 0x00000000, 4, gcvFALSE, gcvTRUE); - index += _State(Context, index, 0x1C080 >> 2, 0x00000000, 4, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x1C0C0 >> 2, 0x00000000, 4, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x1C100 >> 2, 0x00000000, 4, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x1C800 >> 2, 0x00000000, 128*4, gcvFALSE, gcvFALSE); + hardware = Context->hardware; - index += _State(Context, index, 0x1C014 >> 2, 0x00000000, 1, gcvFALSE, gcvTRUE); - index += _CLOSE_RANGE(); + gcmkVERIFY_OBJECT(hardware, gcvOBJ_HARDWARE); + if (!hardware->options.hasShader) + { + return _InitializeNoShaderAndPixelEngine(Context); } - /* Primitive Assembly states. */ - index += _State(Context, index, 0x00A00 >> 2, 0x00000000, 1, gcvTRUE, gcvFALSE); - index += _State(Context, index, 0x00A04 >> 2, 0x00000000, 1, gcvTRUE, gcvFALSE); - index += _State(Context, index, 0x00A08 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x00A0C >> 2, 0x00000000, 1, gcvTRUE, gcvFALSE); - index += _State(Context, index, 0x00A10 >> 2, 0x00000000, 1, gcvTRUE, gcvFALSE); - index += _State(Context, index, 0x00A14 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x00A18 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x00A1C >> 2, 0x3F000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x00A28 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x00A2C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x00A30 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x00A34 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x00A38 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x00A3C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x00A80 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x00A84 >> 2, 0x00000000, 1, gcvTRUE, gcvFALSE); - index += _State(Context, index, 0x00A8C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x00A88 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + /* Reset the buffer index. */ + index = 0; - if (halti5) - { - index += _State(Context, index, 0x00AA8 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x00A90 >> 2, 0x00000000, 4, gcvFALSE, gcvFALSE); - } - else - { - index += _State(Context, index, 0x00A40 >> 2, 0x00000000, Context->hardware->identity.varyingsCount, gcvFALSE, gcvFALSE); - } + /* Reset the last state address. */ + Context->lastAddress = ~0U; - if (multiCluster) - { - index += _State(Context, index, 0x00AAC >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - } + /* Get the buffer pointer. */ + buffer = (Context->buffer == gcvNULL) + ? gcvNULL + : Context->buffer->logical; - index += _State(Context, index, 0x03A00 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x03A04 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x03A08 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - if (multiCoreBlockSetCfg2) - { - index += _State(Context, index, 0x03A0C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x03A10 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - } + /**************************************************************************/ + /* Build 2D states. *******************************************************/ - /* Setup states. */ - index += _State(Context, index, 0x00C00 >> 2, 0x00000000, 1, gcvTRUE, gcvFALSE); - index += _State(Context, index, 0x00C04 >> 2, 0x00000000, 1, gcvTRUE, gcvFALSE); - index += _State(Context, index, 0x00C08 >> 2, 0x45000000, 1, gcvTRUE, gcvFALSE); - index += _State(Context, index, 0x00C0C >> 2, 0x45000000, 1, gcvTRUE, gcvFALSE); - index += _State(Context, index, 0x00C10 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x00C14 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x00C18 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x00C1C >> 2, 0x42000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x00C20 >> 2, 0x00000000, 1, gcvTRUE, gcvFALSE); - index += _State(Context, index, 0x00C24 >> 2, 0x00000000, 1, gcvTRUE, gcvFALSE); - /* Raster states. */ - index += _State(Context, index, 0x00E00 >> 2, 0x000000F1, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x00E10 >> 2, 0x00000000, 4, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x00E04 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x00E40 >> 2, 0x00000000, 16, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x00E08 >> 2, ((((gctUINT32) (0x17000031)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 2:2) - (0 ? - 2:2) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 2:2) - (0 ? - 2:2) + 1))))))) << (0 ? - 2:2))) | (((gctUINT32) ((gctUINT32) (smallBatch ? - 0x0 : 0x1) & ((gctUINT32) ((((1 ? - 2:2) - (0 ? - 2:2) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 2:2) - (0 ? 2:2) + 1))))))) << (0 ? 2:2))), 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x00E24 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x00E20 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); +#if gcdENABLE_3D + /**************************************************************************/ + /* Build 3D states. *******************************************************/ - if (halti2) - { - index += _State(Context, index, 0x00E0C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - } + halti0 = gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_HALTI0); + halti1 = gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_HALTI1); + halti2 = gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_HALTI2); + halti3 = gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_HALTI3); + halti4 = gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_HALTI4); + halti5 = gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_HALTI5); + hasGS = gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_GEOMETRY_SHADER); + hasTS = gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_TESSELLATION); + genericAttrib = gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_GENERIC_ATTRIB); + hasICache = gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_SHADER_HAS_INSTRUCTION_CACHE); + hasTXdesc = gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_TX_DESCRIPTOR); + hasSecurity = gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_SECURITY); + hasRobustness = gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_ROBUSTNESS); + hasICachePrefetch = gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_SH_INSTRUCTION_PREFETCH); + multiCluster = gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_MULTI_CLUSTER); + smallBatch = gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_SMALL_BATCH) && hardware->options.smallBatch; + multiCoreBlockSetCfg2 = gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_MULTI_CORE_BLOCK_SET_CONFIG2); + clusterAliveMask = hardware->identity.clusterAvailMask & hardware->options.userClusterMask; + hasPSCSThrottle = gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_PSCS_THROTTLE); + hasMsaaFragOperation = gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_MSAA_FRAGMENT_OPERATION); + newGPipe = gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_NEW_GPIPE); - if (halti5) + /* Multi render target. */ + if (Context->hardware->identity.chipModel == gcv880 && + Context->hardware->identity.chipRevision == 0x5124 && + Context->hardware->identity.customerID == 0x103) { - index += _State(Context, index, 0x00E34 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + numRT = 16; } - - - /* Pixel Shader states. */ - index += _State(Context, index, 0x01004 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x01008 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x0100C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x01010 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x01030 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x01034 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - - if (halti2) + else if (halti2 || + ((Context->hardware->identity.chipModel == gcv900) && + (Context->hardware->identity.chipRevision == 0x5250))) { - index += _State(Context, index, 0x01040 >> 2, 0x00000000, 2, gcvFALSE, gcvFALSE); + numRT = 8; } - - if (numRT == 16) + else if (halti0) { - index += _State(Context, index, 0x0102C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x010C8 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x010CC >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + numRT = 4; } - else if (numRT == 8) + else { - index += _State(Context, index, 0x0102C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x01038 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + numRT = 1; } - if (hasMsaaFragOperation) + if (hasGS && hasTS) { - index += _State(Context, index, 0x01054 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x01060 >> 2, 0x00000000, 8, gcvFALSE, gcvFALSE); + numSamplers = 80; } - if (halti5) + /* Query how many uniforms can support. */ + gcmCONFIGUREUNIFORMS2(Context->hardware->identity.chipModel, + Context->hardware->identity.chipRevision, + halti5, + smallBatch, + Context->hardware->identity.numConstants, + unifiedUniform, + vertexUniforms, + fragmentUniforms); + +#if !gcdENABLE_UNIFIED_CONSTANT + if (Context->hardware->identity.numConstants > 256) { - index += _State(Context, index, 0x01080 >> 2, 0x00000000, 4, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x01058 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x01098 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + unifiedUniform = gcvTRUE; } - - if (hasPSCSThrottle) + else { - index += _State(Context, index, 0x0109C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + unifiedUniform = gcvFALSE; } +#endif - index += _CLOSE_RANGE(); + /* Store the 3D entry index. */ + Context->entryOffset3D = (gctUINT)index * gcmSIZEOF(gctUINT32); - /* Texture states. */ - if (hasTXdesc) + /* Switch to 3D pipe. */ + index += _SwitchPipe(Context, index, gcvPIPE_3D); + + if (multiCluster) { - /* Texture descriptor states */ - index += _State(Context, index, 0x14C40 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, (0x03910 >> 2) + (0 << 2), ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 7:0) - (0 ? + 7:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 7:0) - (0 ? + 7:0) + 1))))))) << (0 ? + 7:0))) | (((gctUINT32) ((gctUINT32) (clusterAliveMask) & ((gctUINT32) ((((1 ? + 7:0) - (0 ? + 7:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 7:0) - (0 ? 7:0) + 1))))))) << (0 ? 7:0))), 4, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x03908 >> 2, ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 2:0) - (0 ? + 2:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 2:0) - (0 ? + 2:0) + 1))))))) << (0 ? + 2:0))) | (((gctUINT32) (0x2 & ((gctUINT32) ((((1 ? + 2:0) - (0 ? + 2:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 2:0) - (0 ? 2:0) + 1))))))) << (0 ? 2:0))), 1, gcvFALSE, gcvFALSE); + } - if (smallBatch) - { - index += _State(Context, index, 0x010B0 >> 2, numSamplers, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x010B4 >> 2, numSamplers, 1, gcvFALSE, gcvFALSE); - - index += _State(Context, index, 0x16000 >> 2, 0x00000000, numSamplers, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x16200 >> 2, 0x00000000, numSamplers, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x16400 >> 2, 0x00000000, numSamplers, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x16600 >> 2, 0x00000000, numSamplers, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x16800 >> 2, 0x00000000, numSamplers, gcvFALSE, gcvFALSE); - - index += _State(Context, index, (0x15800 >> 2) + (0 << 0), 0x00000000, numSamplers, gcvFALSE, gcvTRUE); - index += _State(Context, index, 0x15A00 >> 2, 0x00000000, numSamplers, gcvFALSE, gcvFALSE); - - index += _CLOSE_RANGE(); - } - else - { - index += _State(Context, index, 0x16C00 >> 2, 0x00000000, numSamplers, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x16E00 >> 2, 0x00000000, numSamplers, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x17000 >> 2, 0x00000000, numSamplers, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x17200 >> 2, 0x00000000, numSamplers, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x17400 >> 2, 0x00000000, numSamplers, gcvFALSE, gcvFALSE); - - index += _State(Context, index, (0x15C00 >> 2) + (0 << 0), 0x00000000, numSamplers, gcvFALSE, gcvTRUE); - index += _State(Context, index, 0x15E00 >> 2, 0x00000000, numSamplers, gcvFALSE, gcvFALSE); + /* Current context pointer. */ +#if gcdDEBUG + index += _State(Context, index, 0x03850 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); +#endif - index += _CLOSE_RANGE(); + index += _FlushPipe(Context, index, gcvPIPE_3D); - _StateMirror(Context, 0x16000 >> 2, numSamplers , 0x16C00 >> 2); - _StateMirror(Context, 0x16200 >> 2, numSamplers , 0x16E00 >> 2); - _StateMirror(Context, 0x16400 >> 2, numSamplers , 0x17000 >> 2); - _StateMirror(Context, 0x16600 >> 2, numSamplers , 0x17200 >> 2); - _StateMirror(Context, 0x16800 >> 2, numSamplers , 0x17400 >> 2); - _StateMirror(Context, 0x15800 >> 2, numSamplers , 0x15C00 >> 2); - _StateMirror(Context, 0x15A00 >> 2, numSamplers , 0x15E00 >> 2); - } - } - else + /* Global states. */ + if (hasSecurity) { - index += _State(Context, index, 0x02000 >> 2, 0x00000000, 12, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x02040 >> 2, 0x00000000, 12, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x02080 >> 2, 0x00000000, 12, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x020C0 >> 2, 0x00000000, 12, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x02100 >> 2, 0x00000000, 12, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x02140 >> 2, 0x00000000, 12, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x02180 >> 2, 0x00000000, 12, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x021C0 >> 2, 0x00321000, 12, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x02200 >> 2, 0x00000000, 12, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x02240 >> 2, 0x00000000, 12, gcvFALSE, gcvFALSE); - index += _State(Context, index, (0x02400 >> 2) + (0 << 4), 0x00000000, 12, gcvFALSE, gcvTRUE); - index += _State(Context, index, (0x02440 >> 2) + (0 << 4), 0x00000000, 12, gcvFALSE, gcvTRUE); - index += _State(Context, index, (0x02480 >> 2) + (0 << 4), 0x00000000, 12, gcvFALSE, gcvTRUE); - index += _State(Context, index, (0x024C0 >> 2) + (0 << 4), 0x00000000, 12, gcvFALSE, gcvTRUE); - index += _State(Context, index, (0x02500 >> 2) + (0 << 4), 0x00000000, 12, gcvFALSE, gcvTRUE); - index += _State(Context, index, (0x02540 >> 2) + (0 << 4), 0x00000000, 12, gcvFALSE, gcvTRUE); - index += _State(Context, index, (0x02580 >> 2) + (0 << 4), 0x00000000, 12, gcvFALSE, gcvTRUE); - index += _State(Context, index, (0x025C0 >> 2) + (0 << 4), 0x00000000, 12, gcvFALSE, gcvTRUE); - index += _State(Context, index, (0x02600 >> 2) + (0 << 4), 0x00000000, 12, gcvFALSE, gcvTRUE); - index += _State(Context, index, (0x02640 >> 2) + (0 << 4), 0x00000000, 12, gcvFALSE, gcvTRUE); - index += _State(Context, index, (0x02680 >> 2) + (0 << 4), 0x00000000, 12, gcvFALSE, gcvTRUE); - index += _State(Context, index, (0x026C0 >> 2) + (0 << 4), 0x00000000, 12, gcvFALSE, gcvTRUE); - index += _State(Context, index, (0x02700 >> 2) + (0 << 4), 0x00000000, 12, gcvFALSE, gcvTRUE); - index += _State(Context, index, (0x02740 >> 2) + (0 << 4), 0x00000000, 12, gcvFALSE, gcvTRUE); + index += _State(Context, index, 0x03900 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); index += _CLOSE_RANGE(); + index += _State(Context, index, 0x03904 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + } - if (gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_TEXTURE_LINEAR)) - { - /* - * Linear stride LODn will overwrite LOD0 on GC880,GC2000. - * And only LOD0 is valid for this register. - */ - gctUINT count = halti1 ? 14 : 1; + index += _State(Context, index, 0x03814 >> 2, 0x00000001, 1, gcvFALSE, gcvFALSE); + index += _CLOSE_RANGE(); + index += _State(Context, index, 0x03818 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x0381C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - for (i = 0; i < 12; i += 1) - { - index += _State(Context, index, (0x02C00 >> 2) + i * 16, 0x00000000, count, gcvFALSE, gcvFALSE); - } - } + if (halti5) + { + gctUINT32 uscControl = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 20:16) - (0 ? + 20:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 20:16) - (0 ? + 20:16) + 1))))))) << (0 ? + 20:16))) | (((gctUINT32) ((gctUINT32) (2) & ((gctUINT32) ((((1 ? + 20:16) - (0 ? + 20:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 20:16) - (0 ? 20:16) + 1))))))) << (0 ? 20:16))); + index += _State(Context, index, 0x03888 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x038C0 >> 2, 0x00000000, 16, gcvFALSE, gcvFALSE); - if (gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_SUPPORT_GCREGTX)) + uscControl |= ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 2:0) - (0 ? + 2:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 2:0) - (0 ? + 2:0) + 1))))))) << (0 ? + 2:0))) | (((gctUINT32) ((gctUINT32) (hardware->options.uscL1CacheRatio) & ((gctUINT32) ((((1 ? + 2:0) - (0 ? + 2:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 2:0) - (0 ? 2:0) + 1))))))) << (0 ? 2:0))); + if (multiCluster) { - gctUINT texBlockCount; - gctUINT gcregTXLogSizeResetValue; - - /* Enable the integer filter pipe for all texture samplers - so that the floating point filter clock will shut off until - we start using the floating point filter. - */ - gcregTXLogSizeResetValue = ((((gctUINT32) (0x00000000)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 29:29) - (0 ? - 29:29) + 1) == 32) ? + uscControl |= ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 11:8) - (0 ? + 11:8) + 1) == 32) ? ~0U : (~(~0U << ((1 ? - 29:29) - (0 ? - 29:29) + 1))))))) << (0 ? - 29:29))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? - 29:29) - (0 ? - 29:29) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 29:29) - (0 ? 29:29) + 1))))))) << (0 ? 29:29))); - - /* New texture block. */ - index += _State(Context, index, 0x10000 >> 2, 0x00000000, 32, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x10080 >> 2, 0x00000000, 32, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x10100 >> 2, gcregTXLogSizeResetValue, 32, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x10180 >> 2, 0x00000000, 32, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x10200 >> 2, 0x00000000, 32, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x10280 >> 2, 0x00000000, 32, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x10300 >> 2, 0x00000000, 32, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x10380 >> 2, 0x00321000, 32, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x10400 >> 2, 0x00000000, 32, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x10480 >> 2, 0x00000000, 32, gcvFALSE, gcvFALSE); - - if (gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_TX_FILTER)) - { - index += _State(Context, index, 0x12000 >> 2, 0x00000000, 256, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x12400 >> 2, 0x00000000, 256, gcvFALSE, gcvFALSE); - } - - texBlockCount = ((512) >> (4)); - - for (i = 0; i < texBlockCount; i += 1) - { - index += _State(Context, index, (0x10800 >> 2) + (i << 4), 0x00000000, 14, gcvFALSE, gcvTRUE); - } + 11:8) - (0 ? + 11:8) + 1))))))) << (0 ? + 11:8))) | (((gctUINT32) ((gctUINT32) (hardware->options.uscAttribCacheRatio) & ((gctUINT32) ((((1 ? + 11:8) - (0 ? + 11:8) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 11:8) - (0 ? 11:8) + 1))))))) << (0 ? 11:8))); } + index += _State(Context, index, 0x03884 >> 2, uscControl, 1, gcvFALSE, gcvFALSE); + } + else + { + index += _State(Context, index, 0x03820 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x03828 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x0382C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x03834 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x03838 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x03854 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + } - if (gckHARDWARE_IsFeatureAvailable(Context->hardware, gcvFEATURE_TEX_BASELOD)) - { - index += _State(Context, index, 0x10700 >> 2, 0x00000F00, 32, gcvFALSE, gcvFALSE); - } + if (hasGS) + { + index += _State(Context, index, 0x0388C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + } - if (halti3 || - gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_TX_SUPPORT_DEC)) - { - index += _State(Context, index, 0x10780 >> 2, 0x00030000, 32, gcvFALSE, gcvFALSE); - } + index += _State(Context, index, 0x0384C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - if (halti4) + /* Front End states. */ + if (halti5) + { + index += _State(Context, index, 0x17800 >> 2, 0x00000000, 32, gcvFALSE, gcvFALSE); + index += _CLOSE_RANGE(); + index += _State(Context, index, 0x007C4 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x007D0 >> 2, 0x00000000, 2, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x007D8 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x17A80 >> 2, 0x00000000, 32, gcvFALSE, gcvFALSE); + if (genericAttrib || newGPipe) { - index += _State(Context, index, 0x11200 >> 2, 0x00000000, 32, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x11280 >> 2, 0x00000000, 32, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x17880 >> 2, 0x00000000, 32, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x17900 >> 2, 0x00000000, 32, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x17980 >> 2, 0x00000000, 32, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x17A00 >> 2, 0x3F800000, 32, gcvFALSE, gcvFALSE); } - - if (gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_TX_FRAC_PRECISION_6BIT)) + } + else + { + index += _State(Context, index, 0x00600 >> 2, 0x00000000, (halti0 ? 16 : 12), gcvFALSE, gcvFALSE); + index += _CLOSE_RANGE(); + if (genericAttrib) { - index += _State(Context, index, 0x11000 >> 2, 0x00000000, 32, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x11080 >> 2, 0x00000000, 32, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x11100 >> 2, 0x00000000, 32, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x11180 >> 2, 0x00000000, 32, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x11300 >> 2, 0x00000000, 32, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x006C0 >> 2, 0x00000000, 16, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x00700 >> 2, 0x00000000, 16, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x00740 >> 2, 0x00000000, 16, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x00780 >> 2, 0x3F800000, 16, gcvFALSE, gcvFALSE); } + } - /* ASTC */ - if (gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_TEXTURE_ASTC)) - { - index += _State(Context, index, 0x10500 >> 2, 0x00000000, 32, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x10580 >> 2, 0x00000000, 32, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x10600 >> 2, 0x00000000, 32, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x10680 >> 2, 0x00000000, 32, gcvFALSE, gcvFALSE); - } + if (halti2 || (Context->hardware->identity.streamCount > 8)) + { + index += _State(Context, index, 0x14600 >> 2, 0x00000000, 16, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x14640 >> 2, 0x00000000, 16, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x14680 >> 2, 0x00000000, 16, gcvFALSE, gcvFALSE); + } + else if (Context->hardware->identity.streamCount > 1) + { + index += _State(Context, index, 0x00680 >> 2, 0x00000000, 8, gcvFALSE, gcvTRUE); + index += _State(Context, index, 0x006A0 >> 2, 0x00000000, 8, gcvFALSE, gcvFALSE); } + else + { + index += _State(Context, index, 0x0064C >> 2, 0x00000000, 1, gcvFALSE, gcvTRUE); + index += _State(Context, index, 0x00650 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - if (halti3) + } + index += _State(Context, index, 0x00644 >> 2, 0x00000000, 1, gcvFALSE, gcvTRUE); + index += _State(Context, index, 0x00648 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x00674 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + + if (halti1) { - index += _State(Context, index, 0x14C00 >> 2, 0x00000000, 16, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x00678 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x0067C >> 2, 0xFFFFFFFF, 1, gcvFALSE, gcvFALSE); } - /* Thread walker states. */ - index += _State(Context, index, 0x00900 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x00904 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x00908 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x0090C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x00910 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x00914 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x00918 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x00924 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x0091C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _CLOSE_RANGE(); - if (gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_SHADER_ENHANCEMENTS2)) + if (hasRobustness) { - index += _State(Context, index, 0x00940 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x00944 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x00948 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x0094C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x00950 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x00954 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x146C0 >> 2, 0x00000000, 16, gcvFALSE, gcvTRUE); + index += _CLOSE_RANGE(); + index += _State(Context, index, 0x007F8 >> 2, 0x00000000, 1, gcvFALSE, gcvTRUE); + index += _CLOSE_RANGE(); } - if (halti5) + /* WD */ + if (multiCluster) { - index += _State(Context, index, 0x00958 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x0095C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x00960 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x18404 >> 2, ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 1:0) - (0 ? + 1:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 1:0) - (0 ? + 1:0) + 1))))))) << (0 ? + 1:0))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 1:0) - (0 ? + 1:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 1:0) - (0 ? 1:0) + 1))))))) << (0 ? 1:0))), 1, gcvFALSE, gcvFALSE); } - index += _CLOSE_RANGE(); - - /* VS/PS Start/End PC register */ if (halti5) { - index += _State(Context, index, 0x00874 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x008BC >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x0087C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x01090 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _CLOSE_RANGE(); - } - else if (hasICache) - { - /* New Shader instruction PC registers(20bit). */ - index += _State(Context, index, 0x00874 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x00878 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x0087C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x00880 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _CLOSE_RANGE(); - } - else - { - if (Context->hardware->identity.instructionCount <= 256) - { - /* old shader instruction PC registers (12bit)*/ - index += _State(Context, index, 0x00800 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x00838 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _CLOSE_RANGE(); + index += _State(Context, index, 0x008B8 >> 2, ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 4:4) - (0 ? + 4:4) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 4:4) - (0 ? + 4:4) + 1))))))) << (0 ? + 4:4))) | (((gctUINT32) ((gctUINT32) (smallBatch ? + 0x0 : 0x1) & ((gctUINT32) ((((1 ? + 4:4) - (0 ? + 4:4) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 4:4) - (0 ? + 4:4) + 1))))))) << (0 ? + 4:4))) | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 5:5) - (0 ? + 5:5) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 5:5) - (0 ? + 5:5) + 1))))))) << (0 ? + 5:5))) | (((gctUINT32) ((gctUINT32) (smallBatch ? + 0x0 : 0x1) & ((gctUINT32) ((((1 ? + 5:5) - (0 ? + 5:5) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 5:5) - (0 ? + 5:5) + 1))))))) << (0 ? + 5:5))) | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 8:8) - (0 ? + 8:8) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 8:8) - (0 ? + 8:8) + 1))))))) << (0 ? + 8:8))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 8:8) - (0 ? + 8:8) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 8:8) - (0 ? + 8:8) + 1))))))) << (0 ? + 8:8))) | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 9:9) - (0 ? + 9:9) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 9:9) - (0 ? + 9:9) + 1))))))) << (0 ? + 9:9))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 9:9) - (0 ? + 9:9) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 9:9) - (0 ? 9:9) + 1))))))) << (0 ? 9:9))), 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x01000 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x01018 >> 2, 0x01000000, 1, gcvFALSE, gcvFALSE); - index += _CLOSE_RANGE(); - } - else - { - /* New Shader instruction PC registers (16bit) */ - index += _State(Context, index, 0x0085C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x0101C >> 2, 0x00000100, 1, gcvFALSE, gcvFALSE); - index += _CLOSE_RANGE(); - } + index += _State(Context, index, 0x15600 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); } - - - if (!hasICachePrefetch) + else { - /* This unified one need SELECT bit to steer */ - if (Context->hardware->identity.instructionCount > 1024) - { - for (i = 0; - i < Context->hardware->identity.instructionCount << 2; - i += 256 << 2 - ) - { - index += _State(Context, index, (0x20000 >> 2) + i, 0x00000000, 256 << 2, gcvFALSE, gcvFALSE); - index += _CLOSE_RANGE(); - } - } - /* This unified one is steered by base adddress, it's automatical. */ - else if (Context->hardware->identity.instructionCount > 256) - { - /* VS instruction memory. */ - for (i = 0; - i < Context->hardware->identity.instructionCount << 2; - i += 256 << 2 - ) - { - index += _State(Context, index, (0x0C000 >> 2) + i, 0x00000000, 256 << 2, gcvFALSE, gcvFALSE); - index += _CLOSE_RANGE(); - } - - _StateMirror(Context, 0x08000 >> 2, Context->hardware->identity.instructionCount << 2 , 0x0C000 >> 2); - } - /* if (Context->hardware->identity.instructionCount <= 256). This is non-unified one. */ - else - { - index += _State(Context, index, 0x04000 >> 2, 0x00000000, 1024, gcvFALSE, gcvFALSE); - index += _CLOSE_RANGE(); - index += _State(Context, index, 0x06000 >> 2, 0x00000000, 1024, gcvFALSE, gcvFALSE); - index += _CLOSE_RANGE(); - } + /* This register is programed by all chips, which program all DECODE_SELECT as VS + ** except SAMPLER_DECODE_SELECT. + */ + index += _State(Context, index, 0x00860 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); } - if (unifiedUniform) + if (hasICache) { - gctINT numConstants = Context->hardware->identity.numConstants; - - /* Base Offset register */ - index += _State(Context, index, 0x01024 >> 2, 0x00000100, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x00864 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + /* I-Cache states. */ + index += _State(Context, index, 0x00868 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x0086C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x0304C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x01028 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); index += _CLOSE_RANGE(); - if (smallBatch) - { - index += _State(Context, index, 0x010AC >> 2, numConstants, 1, gcvFALSE, gcvFALSE); - } - - for (i = 0; - numConstants > 0; - i += 256 << 2, - numConstants -= 256 - ) + if (hasICachePrefetch) { if (halti5) { - if (numConstants >= 256) - { - if (smallBatch) - { - index += _State(Context, index, (0x34000 >> 2) + i, 0x00000000, 256 << 2, gcvFALSE, gcvFALSE); - } - else - { - index += _State(Context, index, (0x36000 >> 2) + i, 0x00000000, 256 << 2, gcvFALSE, gcvFALSE); - } - } - else - { - if (smallBatch) - { - index += _State(Context, index, (0x34000 >> 2) + i, 0x00000000, numConstants << 2, gcvFALSE, gcvFALSE); - } - else - { - index += _State(Context, index, (0x36000 >> 2) + i, 0x00000000, numConstants << 2, gcvFALSE, gcvFALSE); - } - } - index += _CLOSE_RANGE(); + index += _State(Context, index, 0x15604 >> 2, 0x00000000, 1, gcvFALSE, gcvTRUE); + index += _State(Context, index, 0x01094 >> 2, 0x00000000, 1, gcvFALSE, gcvTRUE); } else { - if (numConstants >= 256) - { - index += _State(Context, index, (0x30000 >> 2) + i, 0x00000000, 256 << 2, gcvFALSE, gcvFALSE); - } - else - { - index += _State(Context, index, (0x30000 >> 2) + i, 0x00000000, numConstants << 2, gcvFALSE, gcvFALSE); - } - - index += _CLOSE_RANGE(); + index += _State(Context, index, 0x00890 >> 2, 0x00000000, 1, gcvFALSE, gcvTRUE); + index += _State(Context, index, 0x0104C >> 2, 0x00000000, 1, gcvFALSE, gcvTRUE); } + index += _CLOSE_RANGE(); } - - if (halti5 && !smallBatch) - { - _StateMirror(Context, 0x34000 >> 2, Context->hardware->identity.numConstants << 2 , 0x36000 >> 2); - } - } -#if gcdENABLE_UNIFIED_CONSTANT - else -#endif - { - index += _State(Context, index, 0x05000 >> 2, 0x00000000, vertexUniforms * 4, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x07000 >> 2, 0x00000000, fragmentUniforms * 4, gcvFALSE, gcvFALSE); - } - - if (halti1) - { - index += _State(Context, index, 0x00884 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); } - if (halti5) + if (multiCluster) { - index += _State(Context, index, 0x008B0 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x010A8 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); } - /* Store the index of the "XD" entry. */ - Context->entryOffsetXDFrom3D = (gctUINT)index * gcmSIZEOF(gctUINT32); - - - /* Pixel Engine states. */ - index += _State(Context, index, 0x01400 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x01404 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x01408 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x0140C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x01414 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x01418 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x0141C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x01420 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x01424 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x01428 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x0142C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x01434 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x01454 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x01458 >> 2, 0x00000000, 1, gcvFALSE, gcvTRUE); - index += _State(Context, index, 0x014A0 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x014A8 >> 2, 0xFFFFFFFF, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x014AC >> 2, 0xFFFFFFFF, 1, gcvFALSE, gcvFALSE); + /* Vertex Shader states. */ + index += _State(Context, index, 0x00804 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x00808 >> 2, ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 5:0) - (0 ? + 5:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 5:0) - (0 ? + 5:0) + 1))))))) << (0 ? + 5:0))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 5:0) - (0 ? + 5:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 5:0) - (0 ? 5:0) + 1))))))) << (0 ? 5:0))), 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x0080C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x00830 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - if(gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_HALF_FLOAT_PIPE) ) + if (halti5) { - index += _State(Context, index, 0x014B0 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x014B4 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x00898 >> 2, 0x00000000, 2, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x008A0 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x00870 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x008A8 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x008C0 >> 2, 0x00000000, 8, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x008E0 >> 2, 0x00000000, 8, gcvFALSE, gcvFALSE); + } + else + { + index += _State(Context, index, 0x00810 >> 2, 0x00000000, 4, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x00820 >> 2, 0x00000000, 4, gcvFALSE, gcvFALSE); } - index += _State(Context, index, 0x014A4 >> 2, 0x000E400C, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x01580 >> 2, 0x00000000, 3, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x014B8 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - if (halti3) + if (multiCluster) { - index += _State(Context, index, 0x0103C >> 2, 0x76543210, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x007FC >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x15608 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); } - index += _State(Context, index, (0x01460 >> 2) + (0 << 3), 0x00000000, Context->hardware->identity.pixelPipes, gcvFALSE, gcvTRUE); + index += _CLOSE_RANGE(); - if (Context->hardware->identity.pixelPipes == 1) + /* GS */ + if (hasGS) { - index += _State(Context, index, 0x01430 >> 2, 0x00000000, 1, gcvFALSE, gcvTRUE); - index += _State(Context, index, 0x01410 >> 2, 0x00000000, 1, gcvFALSE, gcvTRUE); + index += _State(Context, index, 0x01100 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x01104 >> 2, 0x00000001, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x01108 >> 2, 0x01000001, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x0110C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x01110 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x01114 >> 2, 0x00000000, 1, gcvFALSE, gcvTRUE); + index += _State(Context, index, 0x0111C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x01140 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x0115C >> 2, 0x000000FF, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x01144 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x01148 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x0114C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x01154 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x01120 >> 2, 0x00000000, 8, gcvFALSE, gcvFALSE); + index += _CLOSE_RANGE(); } - if (Context->hardware->identity.pixelPipes > 1 || halti0) + /* TCS & TES */ + if (hasTS) { - index += _State(Context, index, (0x01480 >> 2) + (0 << 3), 0x00000000, Context->hardware->identity.pixelPipes, gcvFALSE, gcvTRUE); + index += _State(Context, index, 0x007C0 >> 2, 0x00000003, 1, gcvFALSE, gcvFALSE); + + index += _State(Context, index, 0x14A14 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x14A18 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x14A1C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x14A40 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x14A00 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x14A04 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x14A08 >> 2, 0x00000000, 1, gcvFALSE, gcvTRUE); + index += _State(Context, index, 0x14A10 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x14A20 >> 2, 0x00000000, 8, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x14A44 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x14A4C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + + index += _CLOSE_RANGE(); + + index += _State(Context, index, 0x14B18 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x14B1C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x14B20 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x14B04 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x14B08 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x14B0C >> 2, 0x00000000, 1, gcvFALSE, gcvTRUE); + index += _State(Context, index, 0x14B14 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x14B40 >> 2, 0x00000000, 8, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x14B24 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x14B2C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x14B34 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + + index += _State(Context, index, 0x14B00 >> 2, 0x00040000, 1, gcvFALSE, gcvFALSE); + } - for (i = 0; i < 3; i++) + index += _CLOSE_RANGE(); + + /* TFB */ + if (gckHARDWARE_IsFeatureAvailable(Context->hardware, gcvFEATURE_HW_TFB)) { - index += _State(Context, index, (0x01500 >> 2) + (i << 3), 0x00000000, Context->hardware->identity.pixelPipes, gcvFALSE, gcvTRUE); + index += _State(Context, index, 0x1C000 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x1C008 >> 2, 0x00000000, 1, gcvFALSE, gcvTRUE); + index += _State(Context, index, (0x1C040 >> 2) + (0 << 4), 0x00000000, 4, gcvFALSE, gcvTRUE); + index += _State(Context, index, 0x1C080 >> 2, 0x00000000, 4, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x1C0C0 >> 2, 0x00000000, 4, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x1C100 >> 2, 0x00000000, 4, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x1C800 >> 2, 0x00000000, 128*4, gcvFALSE, gcvFALSE); + + index += _State(Context, index, 0x1C014 >> 2, 0x00000000, 1, gcvFALSE, gcvTRUE); + index += _CLOSE_RANGE(); + } - if (numRT == 16) + /* Primitive Assembly states. */ + index += _State(Context, index, 0x00A00 >> 2, 0x00000000, 1, gcvTRUE, gcvFALSE); + index += _State(Context, index, 0x00A04 >> 2, 0x00000000, 1, gcvTRUE, gcvFALSE); + index += _State(Context, index, 0x00A08 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x00A0C >> 2, 0x00000000, 1, gcvTRUE, gcvFALSE); + index += _State(Context, index, 0x00A10 >> 2, 0x00000000, 1, gcvTRUE, gcvFALSE); + index += _State(Context, index, 0x00A14 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x00A18 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x00A1C >> 2, 0x3F000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x00A28 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x00A2C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x00A30 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x00A34 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x00A38 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x00A3C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x00A80 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x00A84 >> 2, 0x00000000, 1, gcvTRUE, gcvFALSE); + index += _State(Context, index, 0x00A8C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x00A88 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + + if (halti5) { - for (i = 0; i < 15; i++) - { - index += _State(Context, index, (0x17C00 >> 2) + (i << 0), 0x00000000, Context->hardware->identity.pixelPipes, gcvFALSE, gcvTRUE); - } - index += _State(Context, index, 0x17C40 >> 2, 0x00000000, 15, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x17C80 >> 2, 0x03012000, 15, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x00AA8 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x00A90 >> 2, 0x00000000, 4, gcvFALSE, gcvFALSE); } - else if (numRT == 8) + else { - for (i = 0; i < 7; i++) - { - index += _State(Context, index, (0x14800 >> 2) + (i << 3), 0x00000000, Context->hardware->identity.pixelPipes, gcvFALSE, gcvTRUE); - } - index += _State(Context, index, 0x14900 >> 2, 0x00000000, 7, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x00A40 >> 2, 0x00000000, Context->hardware->identity.varyingsCount, gcvFALSE, gcvFALSE); } - - if (halti3) + if (multiCluster) { - index += _State(Context, index, 0x014BC >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x00AAC >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); } - if (halti4) - { - index += _State(Context, index, 0x014C0 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - } + index += _State(Context, index, 0x03A00 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x03A04 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x03A08 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - if (hasGS) + if (multiCoreBlockSetCfg2) { - index += _State(Context, index, 0x038A0 >> 2, 0x00000000, 8, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x03A0C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x03A10 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); } - if (halti5) + /* Setup states. */ + index += _State(Context, index, 0x00C00 >> 2, 0x00000000, 1, gcvTRUE, gcvFALSE); + index += _State(Context, index, 0x00C04 >> 2, 0x00000000, 1, gcvTRUE, gcvFALSE); + index += _State(Context, index, 0x00C08 >> 2, 0x45000000, 1, gcvTRUE, gcvFALSE); + index += _State(Context, index, 0x00C0C >> 2, 0x45000000, 1, gcvTRUE, gcvFALSE); + index += _State(Context, index, 0x00C10 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x00C14 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x00C18 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x00C1C >> 2, 0x42000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x00C20 >> 2, 0x00000000, 1, gcvTRUE, gcvFALSE); + index += _State(Context, index, 0x00C24 >> 2, 0x00000000, 1, gcvTRUE, gcvFALSE); + + /* Raster states. */ + index += _State(Context, index, 0x00E00 >> 2, 0x000000F1, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x00E10 >> 2, 0x00000000, 4, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x00E04 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x00E40 >> 2, 0x00000000, 16, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x00E08 >> 2, ((((gctUINT32) (0x17000031)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 2:2) - (0 ? + 2:2) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 2:2) - (0 ? + 2:2) + 1))))))) << (0 ? + 2:2))) | (((gctUINT32) ((gctUINT32) (smallBatch ? + 0x0 : 0x1) & ((gctUINT32) ((((1 ? + 2:2) - (0 ? + 2:2) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 2:2) - (0 ? 2:2) + 1))))))) << (0 ? 2:2))), 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x00E24 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x00E20 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + + if (halti2) { - index += _State(Context, index, 0x14920 >> 2, 0x00000000, 7, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x14940 >> 2, 0x00000000, 7, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x14960 >> 2, 0x00000000, 7, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x14980 >> 2, 0x00000000, 7, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x149A0 >> 2, 0x00000000, 7, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x00E0C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); } - if (hasRobustness) + if (halti5) { - index += _State(Context, index, 0x149C0 >> 2, 0x00000000, 8, gcvFALSE, gcvTRUE); - index += _State(Context, index, 0x014C4 >> 2, 0x00000000, 1, gcvFALSE, gcvTRUE); + index += _State(Context, index, 0x00E34 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); } - /* Memory Controller */ - index += _State(Context, index, 0x01654 >> 2, 0x00200000, 1, gcvFALSE, gcvFALSE); - - index += _CLOSE_RANGE(); - index += _State(Context, index, 0x01658 >> 2, 0x00000000, 1, gcvFALSE, gcvTRUE); - index += _State(Context, index, 0x0165C >> 2, 0x00000000, 1, gcvFALSE, gcvTRUE); - index += _State(Context, index, 0x01660 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x01664 >> 2, 0x00000000, 1, gcvFALSE, gcvTRUE); - index += _State(Context, index, 0x01668 >> 2, 0x00000000, 1, gcvFALSE, gcvTRUE); - index += _State(Context, index, 0x0166C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x01670 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x01674 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x016A4 >> 2, 0x00000000, 1, gcvFALSE, gcvTRUE); - index += _State(Context, index, 0x016AC >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x016A8 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x01720 >> 2, 0x00000000, 8, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x01740 >> 2, 0x00000000, 8, gcvFALSE, gcvTRUE); - index += _State(Context, index, 0x01760 >> 2, 0x00000000, 8, gcvFALSE, gcvFALSE); + /* Pixel Shader states. */ + index += _State(Context, index, 0x01004 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x01008 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x0100C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x01010 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x01030 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x01034 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); if (halti2) { - index += _State(Context, index, 0x01780 >> 2, 0x00000000, 8, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x016BC >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, (0x017A0 >> 2) + 1, 0x00000000, 7, gcvFALSE, gcvFALSE); - index += _State(Context, index, (0x017C0 >> 2) + 1, 0x00000000, 7, gcvFALSE, gcvTRUE); - index += _State(Context, index, (0x017E0 >> 2) + 1, 0x00000000, 7, gcvFALSE, gcvTRUE); - index += _State(Context, index, (0x01A00 >> 2) + 1, 0x00000000, 7, gcvFALSE, gcvFALSE); - index += _State(Context, index, (0x01A20 >> 2) + 1, 0x00000000, 7, gcvFALSE, gcvFALSE); - index += _State(Context, index, (0x01A40 >> 2) + 1, 0x00000000, 7, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x01040 >> 2, 0x00000000, 2, gcvFALSE, gcvFALSE); } - index += _CLOSE_RANGE(); - - if (gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_BUG_FIXES18)) + if (numRT == 16) { - index += _State(Context, index, 0x03860 >> 2, 0x6, 1, gcvFALSE, gcvFALSE); - index += _CLOSE_RANGE(); + index += _State(Context, index, 0x0102C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x010C8 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x010CC >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); } - - if (halti3) + else if (numRT == 8) { - index += _State(Context, index, 0x01A80 >> 2, 0x00000000, 8, gcvFALSE, gcvTRUE); - index += _CLOSE_RANGE(); + index += _State(Context, index, 0x0102C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x01038 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); } - if (hasSecurity || hasRobustness) + if (hasMsaaFragOperation) { - index += _State(Context, index, 0x001AC >> 2, ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 16:16) - (0 ? - 16:16) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 16:16) - (0 ? - 16:16) + 1))))))) << (0 ? - 16:16))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? - 16:16) - (0 ? - 16:16) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 16:16) - (0 ? 16:16) + 1))))))) << (0 ? 16:16))), 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x01054 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x01060 >> 2, 0x00000000, 8, gcvFALSE, gcvFALSE); } - /* Semaphore/stall. */ - index += _SemaphoreStall(Context, index); -#endif - - /**************************************************************************/ - /* Link to another address. ***********************************************/ - - Context->linkIndex3D = (gctUINT)index; - - if (buffer != gcvNULL) + if (halti5) { - buffer[index + 0] - = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 31:27) - (0 ? - 31:27) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 31:27) - (0 ? - 31:27) + 1))))))) << (0 ? - 31:27))) | (((gctUINT32) (0x08 & ((gctUINT32) ((((1 ? - 31:27) - (0 ? - 31:27) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) - | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 15:0) - (0 ? - 15:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 15:0) - (0 ? - 15:0) + 1))))))) << (0 ? - 15:0))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? - 15:0) - (0 ? - 15:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))); + index += _State(Context, index, 0x01080 >> 2, 0x00000000, 4, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x01058 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x01098 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + } - buffer[index + 1] - = 0; + if (hasPSCSThrottle) + { + index += _State(Context, index, 0x0109C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); } - index += 2; + index += _CLOSE_RANGE(); - /* Store the end of the context buffer. */ - Context->bufferSize = index * gcmSIZEOF(gctUINT32); + /* Texture states. */ + if (hasTXdesc) + { + /* Texture descriptor states */ + index += _State(Context, index, 0x14C40 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + if (smallBatch) + { + index += _State(Context, index, 0x010B0 >> 2, numSamplers, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x010B4 >> 2, numSamplers, 1, gcvFALSE, gcvFALSE); - /**************************************************************************/ - /* Pipe switch for the case where neither 2D nor 3D are used. *************/ + index += _State(Context, index, 0x16000 >> 2, 0x00000000, numSamplers, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x16200 >> 2, 0x00000000, numSamplers, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x16400 >> 2, 0x00000000, numSamplers, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x16600 >> 2, 0x00000000, numSamplers, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x16800 >> 2, 0x00000000, numSamplers, gcvFALSE, gcvFALSE); - /* Store the 3D entry index. */ - Context->entryOffsetXDFrom2D = (gctUINT)index * gcmSIZEOF(gctUINT32); + index += _State(Context, index, (0x15800 >> 2) + (0 << 0), 0x00000000, numSamplers, gcvFALSE, gcvTRUE); + index += _State(Context, index, 0x15A00 >> 2, 0x00000000, numSamplers, gcvFALSE, gcvFALSE); - /* Switch to 3D pipe. */ - index += _SwitchPipe(Context, index, gcvPIPE_3D); + index += _CLOSE_RANGE(); + } + else + { + index += _State(Context, index, 0x16C00 >> 2, 0x00000000, numSamplers, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x16E00 >> 2, 0x00000000, numSamplers, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x17000 >> 2, 0x00000000, numSamplers, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x17200 >> 2, 0x00000000, numSamplers, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x17400 >> 2, 0x00000000, numSamplers, gcvFALSE, gcvFALSE); - /* Store the location of the link. */ - Context->linkIndexXD = (gctUINT)index; + index += _State(Context, index, (0x15C00 >> 2) + (0 << 0), 0x00000000, numSamplers, gcvFALSE, gcvTRUE); + index += _State(Context, index, 0x15E00 >> 2, 0x00000000, numSamplers, gcvFALSE, gcvFALSE); - if (buffer != gcvNULL) - { - buffer[index + 0] - = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 31:27) - (0 ? - 31:27) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 31:27) - (0 ? - 31:27) + 1))))))) << (0 ? - 31:27))) | (((gctUINT32) (0x08 & ((gctUINT32) ((((1 ? - 31:27) - (0 ? - 31:27) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) - | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 15:0) - (0 ? - 15:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 15:0) - (0 ? - 15:0) + 1))))))) << (0 ? - 15:0))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? - 15:0) - (0 ? - 15:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))); + index += _CLOSE_RANGE(); - buffer[index + 1] - = 0; + _StateMirror(Context, 0x16000 >> 2, numSamplers , 0x16C00 >> 2); + _StateMirror(Context, 0x16200 >> 2, numSamplers , 0x16E00 >> 2); + _StateMirror(Context, 0x16400 >> 2, numSamplers , 0x17000 >> 2); + _StateMirror(Context, 0x16600 >> 2, numSamplers , 0x17200 >> 2); + _StateMirror(Context, 0x16800 >> 2, numSamplers , 0x17400 >> 2); + _StateMirror(Context, 0x15800 >> 2, numSamplers , 0x15C00 >> 2); + _StateMirror(Context, 0x15A00 >> 2, numSamplers , 0x15E00 >> 2); + } } + else + { + index += _State(Context, index, 0x02000 >> 2, 0x00000000, 12, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x02040 >> 2, 0x00000000, 12, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x02080 >> 2, 0x00000000, 12, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x020C0 >> 2, 0x00000000, 12, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x02100 >> 2, 0x00000000, 12, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x02140 >> 2, 0x00000000, 12, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x02180 >> 2, 0x00000000, 12, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x021C0 >> 2, 0x00321000, 12, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x02200 >> 2, 0x00000000, 12, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x02240 >> 2, 0x00000000, 12, gcvFALSE, gcvFALSE); + index += _State(Context, index, (0x02400 >> 2) + (0 << 4), 0x00000000, 12, gcvFALSE, gcvTRUE); + index += _State(Context, index, (0x02440 >> 2) + (0 << 4), 0x00000000, 12, gcvFALSE, gcvTRUE); + index += _State(Context, index, (0x02480 >> 2) + (0 << 4), 0x00000000, 12, gcvFALSE, gcvTRUE); + index += _State(Context, index, (0x024C0 >> 2) + (0 << 4), 0x00000000, 12, gcvFALSE, gcvTRUE); + index += _State(Context, index, (0x02500 >> 2) + (0 << 4), 0x00000000, 12, gcvFALSE, gcvTRUE); + index += _State(Context, index, (0x02540 >> 2) + (0 << 4), 0x00000000, 12, gcvFALSE, gcvTRUE); + index += _State(Context, index, (0x02580 >> 2) + (0 << 4), 0x00000000, 12, gcvFALSE, gcvTRUE); + index += _State(Context, index, (0x025C0 >> 2) + (0 << 4), 0x00000000, 12, gcvFALSE, gcvTRUE); + index += _State(Context, index, (0x02600 >> 2) + (0 << 4), 0x00000000, 12, gcvFALSE, gcvTRUE); + index += _State(Context, index, (0x02640 >> 2) + (0 << 4), 0x00000000, 12, gcvFALSE, gcvTRUE); + index += _State(Context, index, (0x02680 >> 2) + (0 << 4), 0x00000000, 12, gcvFALSE, gcvTRUE); + index += _State(Context, index, (0x026C0 >> 2) + (0 << 4), 0x00000000, 12, gcvFALSE, gcvTRUE); + index += _State(Context, index, (0x02700 >> 2) + (0 << 4), 0x00000000, 12, gcvFALSE, gcvTRUE); + index += _State(Context, index, (0x02740 >> 2) + (0 << 4), 0x00000000, 12, gcvFALSE, gcvTRUE); + index += _CLOSE_RANGE(); - index += 2; - - - /**************************************************************************/ - /* Save size for buffer. **************************************************/ + if (gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_TEXTURE_LINEAR)) + { + /* + * Linear stride LODn will overwrite LOD0 on GC880,GC2000. + * And only LOD0 is valid for this register. + */ + gctUINT count = halti1 ? 14 : 1; - Context->totalSize = index * gcmSIZEOF(gctUINT32); + for (i = 0; i < 12; i += 1) + { + index += _State(Context, index, (0x02C00 >> 2) + i * 16, 0x00000000, count, gcvFALSE, gcvFALSE); + } + } - /* Success. */ - gcmkFOOTER_NO(); - return gcvSTATUS_OK; -} -#endif + if (gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_SUPPORT_GCREGTX)) + { + gctUINT texBlockCount; + gctUINT gcregTXLogSizeResetValue; -static gceSTATUS -_DestroyContext( - IN gckCONTEXT Context - ) -{ - gceSTATUS status = gcvSTATUS_OK; + /* Enable the integer filter pipe for all texture samplers + so that the floating point filter clock will shut off until + we start using the floating point filter. + */ + gcregTXLogSizeResetValue = ((((gctUINT32) (0x00000000)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 29:29) - (0 ? + 29:29) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 29:29) - (0 ? + 29:29) + 1))))))) << (0 ? + 29:29))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 29:29) - (0 ? + 29:29) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 29:29) - (0 ? 29:29) + 1))))))) << (0 ? 29:29))); - if (Context != gcvNULL) - { - gcsCONTEXT_PTR bufferHead; + /* New texture block. */ + index += _State(Context, index, 0x10000 >> 2, 0x00000000, 32, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x10080 >> 2, 0x00000000, 32, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x10100 >> 2, gcregTXLogSizeResetValue, 32, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x10180 >> 2, 0x00000000, 32, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x10200 >> 2, 0x00000000, 32, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x10280 >> 2, 0x00000000, 32, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x10300 >> 2, 0x00000000, 32, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x10380 >> 2, 0x00321000, 32, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x10400 >> 2, 0x00000000, 32, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x10480 >> 2, 0x00000000, 32, gcvFALSE, gcvFALSE); - /* Free context buffers. */ - for (bufferHead = Context->buffer; Context->buffer != gcvNULL;) - { - /* Get a shortcut to the current buffer. */ - gcsCONTEXT_PTR buffer = Context->buffer; + if (gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_TX_FILTER)) + { + index += _State(Context, index, 0x12000 >> 2, 0x00000000, 256, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x12400 >> 2, 0x00000000, 256, gcvFALSE, gcvFALSE); + } - /* Get the next buffer. */ - gcsCONTEXT_PTR next = buffer->next; + texBlockCount = ((512) >> (4)); - /* Last item? */ - if (next == bufferHead) + for (i = 0; i < texBlockCount; i += 1) { - next = gcvNULL; + index += _State(Context, index, (0x10800 >> 2) + (i << 4), 0x00000000, 14, gcvFALSE, gcvTRUE); } + } - /* Destroy the signal. */ - if (buffer->signal != gcvNULL) - { - gcmkONERROR(gckOS_DestroySignal( - Context->os, buffer->signal - )); - - buffer->signal = gcvNULL; - } + if (gckHARDWARE_IsFeatureAvailable(Context->hardware, gcvFEATURE_TEX_BASELOD)) + { + index += _State(Context, index, 0x10700 >> 2, 0x00000F00, 32, gcvFALSE, gcvFALSE); + } - /* Free state delta map. */ - if (buffer->logical != gcvNULL) - { - gckKERNEL kernel = Context->hardware->kernel; + if (halti3 || + gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_TX_SUPPORT_DEC)) + { + index += _State(Context, index, 0x10780 >> 2, 0x00030000, 32, gcvFALSE, gcvFALSE); + } -#if gcdCAPTURE_ONLY_MODE - gceDATABASE_TYPE dbType; - gctUINT32 processID; -#endif + if (halti4) + { + index += _State(Context, index, 0x11200 >> 2, 0x00000000, 32, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x11280 >> 2, 0x00000000, 32, gcvFALSE, gcvFALSE); + } - /* End cpu access. */ - gcmkVERIFY_OK(gckVIDMEM_NODE_UnlockCPU( - kernel, - buffer->videoMem, - 0, - gcvFALSE, - gcvFALSE - )); + if (gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_TX_FRAC_PRECISION_6BIT)) + { + index += _State(Context, index, 0x11000 >> 2, 0x00000000, 32, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x11080 >> 2, 0x00000000, 32, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x11100 >> 2, 0x00000000, 32, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x11180 >> 2, 0x00000000, 32, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x11300 >> 2, 0x00000000, 32, gcvFALSE, gcvFALSE); + } - /* Synchronized unlock. */ - gcmkVERIFY_OK(gckVIDMEM_NODE_Unlock( - kernel, - buffer->videoMem, - 0, - gcvNULL - )); + /* ASTC */ + if (gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_TEXTURE_ASTC)) + { + index += _State(Context, index, 0x10500 >> 2, 0x00000000, 32, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x10580 >> 2, 0x00000000, 32, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x10600 >> 2, 0x00000000, 32, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x10680 >> 2, 0x00000000, 32, gcvFALSE, gcvFALSE); + } + } -#if gcdCAPTURE_ONLY_MODE - /* Encode surface type and pool to database type. */ - dbType = gcvDB_VIDEO_MEMORY - | (gcvVIDMEM_TYPE_GENERIC << gcdDB_VIDEO_MEMORY_TYPE_SHIFT) - | (buffer->videoMem->pool << gcdDB_VIDEO_MEMORY_POOL_SHIFT); + if (halti3) + { + index += _State(Context, index, 0x14C00 >> 2, 0x00000000, 16, gcvFALSE, gcvFALSE); + } - gcmkONERROR(gckOS_GetProcessID(&processID)); + /* Thread walker states. */ + index += _State(Context, index, 0x00900 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x00904 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x00908 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x0090C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x00910 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x00914 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x00918 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x00924 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x0091C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - gcmkONERROR( - gckKERNEL_RemoveProcessDB(kernel, - processID, - dbType, - buffer->videoMem)); -#endif + if (gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_SHADER_ENHANCEMENTS2)) + { + index += _State(Context, index, 0x00940 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x00944 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x00948 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x0094C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x00950 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x00954 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + } - /* Free video memory. */ - gcmkVERIFY_OK(gckVIDMEM_NODE_Dereference( - kernel, - buffer->videoMem - )); + if (halti5) + { + index += _State(Context, index, 0x00958 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x0095C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x00960 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + } - buffer->logical = gcvNULL; - } + index += _CLOSE_RANGE(); - /* Free context buffer. */ - gcmkONERROR(gcmkOS_SAFE_FREE(Context->os, buffer)); + /* VS/PS Start/End PC register */ + if (halti5) + { + index += _State(Context, index, 0x00874 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x008BC >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x0087C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x01090 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _CLOSE_RANGE(); + } + else if (hasICache) + { + /* New Shader instruction PC registers(20bit). */ + index += _State(Context, index, 0x00874 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x00878 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x0087C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x00880 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _CLOSE_RANGE(); + } + else + { + if (Context->hardware->identity.instructionCount <= 256) + { + /* old shader instruction PC registers (12bit)*/ + index += _State(Context, index, 0x00800 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x00838 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _CLOSE_RANGE(); - /* Remove from the list. */ - Context->buffer = next; + index += _State(Context, index, 0x01000 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x01018 >> 2, 0x01000000, 1, gcvFALSE, gcvFALSE); + index += _CLOSE_RANGE(); + } + else + { + /* New Shader instruction PC registers (16bit) */ + index += _State(Context, index, 0x0085C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x0101C >> 2, 0x00000100, 1, gcvFALSE, gcvFALSE); + index += _CLOSE_RANGE(); } - - /* Mark the gckCONTEXT object as unknown. */ - Context->object.type = gcvOBJ_UNKNOWN; - - /* Free the gckCONTEXT object. */ - gcmkONERROR(gcmkOS_SAFE_FREE(Context->os, Context)); } -OnError: - return status; -} - -#if (gcdENABLE_3D) -static gceSTATUS -_AllocateContextBuffer( - IN gckCONTEXT Context, - IN gcsCONTEXT_PTR Buffer - ) -{ - gceSTATUS status; - gckKERNEL kernel = Context->hardware->kernel; - gcePOOL pool = gcvPOOL_DEFAULT; - gctSIZE_T totalSize = Context->totalSize; - gctUINT32 allocFlag = 0; - -#if gcdCAPTURE_ONLY_MODE - gceDATABASE_TYPE dbType; - gctUINT32 processID; -#endif -#if gcdENABLE_CACHEABLE_COMMAND_BUFFER - allocFlag = gcvALLOC_FLAG_CACHEABLE; -#endif + if (!hasICachePrefetch) + { + /* This unified one need SELECT bit to steer */ + if (Context->hardware->identity.instructionCount > 1024) + { + for (i = 0; + i < Context->hardware->identity.instructionCount << 2; + i += 256 << 2 + ) + { + index += _State(Context, index, (0x20000 >> 2) + i, 0x00000000, 256 << 2, gcvFALSE, gcvFALSE); + index += _CLOSE_RANGE(); + } + } + /* This unified one is steered by base adddress, it's automatical. */ + else if (Context->hardware->identity.instructionCount > 256) + { + /* VS instruction memory. */ + for (i = 0; + i < Context->hardware->identity.instructionCount << 2; + i += 256 << 2 + ) + { + index += _State(Context, index, (0x0C000 >> 2) + i, 0x00000000, 256 << 2, gcvFALSE, gcvFALSE); + index += _CLOSE_RANGE(); + } - /* Allocate video memory node for command buffers. */ - gcmkONERROR(gckKERNEL_AllocateVideoMemory( - kernel, - 64, - gcvVIDMEM_TYPE_COMMAND, - allocFlag, - &totalSize, - &pool, - &Buffer->videoMem - )); + _StateMirror(Context, 0x08000 >> 2, Context->hardware->identity.instructionCount << 2 , 0x0C000 >> 2); + } + /* if (Context->hardware->identity.instructionCount <= 256). This is non-unified one. */ + else + { + index += _State(Context, index, 0x04000 >> 2, 0x00000000, 1024, gcvFALSE, gcvFALSE); + index += _CLOSE_RANGE(); + index += _State(Context, index, 0x06000 >> 2, 0x00000000, 1024, gcvFALSE, gcvFALSE); + index += _CLOSE_RANGE(); + } + } -#if gcdCAPTURE_ONLY_MODE - gcmkONERROR(gckVIDMEM_HANDLE_Allocate(kernel, Buffer->videoMem, &Context->buffer->handle)); + if (unifiedUniform) + { + gctINT numConstants = Context->hardware->identity.numConstants; - /* Encode surface type and pool to database type. */ - dbType = gcvDB_VIDEO_MEMORY - | (gcvVIDMEM_TYPE_GENERIC << gcdDB_VIDEO_MEMORY_TYPE_SHIFT) - | (pool << gcdDB_VIDEO_MEMORY_POOL_SHIFT); + /* Base Offset register */ + index += _State(Context, index, 0x01024 >> 2, 0x00000100, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x00864 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _CLOSE_RANGE(); - gcmkONERROR(gckOS_GetProcessID(&processID)); + if (smallBatch) + { + index += _State(Context, index, 0x010AC >> 2, numConstants, 1, gcvFALSE, gcvFALSE); + } - /* Record in process db. */ - gcmkONERROR( - gckKERNEL_AddProcessDB(kernel, - processID, - dbType, - Buffer->videoMem, - gcvNULL, - totalSize)); + for (i = 0; + numConstants > 0; + i += 256 << 2, + numConstants -= 256 + ) + { + if (halti5) + { + if (numConstants >= 256) + { + if (smallBatch) + { + index += _State(Context, index, (0x34000 >> 2) + i, 0x00000000, 256 << 2, gcvFALSE, gcvFALSE); + } + else + { + index += _State(Context, index, (0x36000 >> 2) + i, 0x00000000, 256 << 2, gcvFALSE, gcvFALSE); + } + } + else + { + if (smallBatch) + { + index += _State(Context, index, (0x34000 >> 2) + i, 0x00000000, numConstants << 2, gcvFALSE, gcvFALSE); + } + else + { + index += _State(Context, index, (0x36000 >> 2) + i, 0x00000000, numConstants << 2, gcvFALSE, gcvFALSE); + } + } + index += _CLOSE_RANGE(); + } + else + { + if (numConstants >= 256) + { + index += _State(Context, index, (0x30000 >> 2) + i, 0x00000000, 256 << 2, gcvFALSE, gcvFALSE); + } + else + { + index += _State(Context, index, (0x30000 >> 2) + i, 0x00000000, numConstants << 2, gcvFALSE, gcvFALSE); + } + + index += _CLOSE_RANGE(); + } + } + + if (halti5 && !smallBatch) + { + _StateMirror(Context, 0x34000 >> 2, Context->hardware->identity.numConstants << 2 , 0x36000 >> 2); + } + } +#if gcdENABLE_UNIFIED_CONSTANT + else #endif + { + index += _State(Context, index, 0x05000 >> 2, 0x00000000, vertexUniforms * 4, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x07000 >> 2, 0x00000000, fragmentUniforms * 4, gcvFALSE, gcvFALSE); + } - /* Lock for GPU access. */ - gcmkONERROR(gckVIDMEM_NODE_Lock( - kernel, - Buffer->videoMem, - &Buffer->address - )); + if (halti1) + { + index += _State(Context, index, 0x00884 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + } - /* Lock for kernel side CPU access. */ - gcmkONERROR(gckVIDMEM_NODE_LockCPU( - kernel, - Buffer->videoMem, - gcvFALSE, - gcvFALSE, - (gctPOINTER *)&Buffer->logical - )); + if (halti5) + { + index += _State(Context, index, 0x008B0 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + } - return gcvSTATUS_OK; + /* Store the index of the "XD" entry. */ + Context->entryOffsetXDFrom3D = (gctUINT)index * gcmSIZEOF(gctUINT32); -OnError: - return status; -} + + /* Pixel Engine states. */ + index += _State(Context, index, 0x01400 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x01404 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x01408 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x0140C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x01414 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x01418 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x0141C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x01420 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x01424 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x01428 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x0142C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x01434 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x01454 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x01458 >> 2, 0x00000000, 1, gcvFALSE, gcvTRUE); + index += _State(Context, index, 0x014A0 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x014A8 >> 2, 0xFFFFFFFF, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x014AC >> 2, 0xFFFFFFFF, 1, gcvFALSE, gcvFALSE); + + if(gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_HALF_FLOAT_PIPE) ) + { + index += _State(Context, index, 0x014B0 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x014B4 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + } + index += _State(Context, index, 0x014A4 >> 2, 0x000E400C, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x01580 >> 2, 0x00000000, 3, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x014B8 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + + if (halti3) + { + index += _State(Context, index, 0x0103C >> 2, 0x76543210, 1, gcvFALSE, gcvFALSE); + } + + index += _State(Context, index, (0x01460 >> 2) + (0 << 3), 0x00000000, Context->hardware->identity.pixelPipes, gcvFALSE, gcvTRUE); + + if (Context->hardware->identity.pixelPipes == 1) + { + index += _State(Context, index, 0x01430 >> 2, 0x00000000, 1, gcvFALSE, gcvTRUE); + index += _State(Context, index, 0x01410 >> 2, 0x00000000, 1, gcvFALSE, gcvTRUE); + } + + if (Context->hardware->identity.pixelPipes > 1 || halti0) + { + index += _State(Context, index, (0x01480 >> 2) + (0 << 3), 0x00000000, Context->hardware->identity.pixelPipes, gcvFALSE, gcvTRUE); + } + + for (i = 0; i < 3; i++) + { + index += _State(Context, index, (0x01500 >> 2) + (i << 3), 0x00000000, Context->hardware->identity.pixelPipes, gcvFALSE, gcvTRUE); + } + + if (numRT == 16) + { + for (i = 0; i < 15; i++) + { + index += _State(Context, index, (0x17C00 >> 2) + (i << 0), 0x00000000, Context->hardware->identity.pixelPipes, gcvFALSE, gcvTRUE); + } + index += _State(Context, index, 0x17C40 >> 2, 0x00000000, 15, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x17C80 >> 2, 0x03012000, 15, gcvFALSE, gcvFALSE); + } + else if (numRT == 8) + { + for (i = 0; i < 7; i++) + { + index += _State(Context, index, (0x14800 >> 2) + (i << 3), 0x00000000, Context->hardware->identity.pixelPipes, gcvFALSE, gcvTRUE); + } + index += _State(Context, index, 0x14900 >> 2, 0x00000000, 7, gcvFALSE, gcvFALSE); + } + + + if (halti3) + { + index += _State(Context, index, 0x014BC >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + } + + if (halti4) + { + index += _State(Context, index, 0x014C0 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + } + + if (hasGS) + { + index += _State(Context, index, 0x038A0 >> 2, 0x00000000, 8, gcvFALSE, gcvFALSE); + } + + if (halti5) + { + index += _State(Context, index, 0x14920 >> 2, 0x00000000, 7, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x14940 >> 2, 0x00000000, 7, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x14960 >> 2, 0x00000000, 7, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x14980 >> 2, 0x00000000, 7, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x149A0 >> 2, 0x00000000, 7, gcvFALSE, gcvFALSE); + } + + if (hasRobustness) + { + index += _State(Context, index, 0x149C0 >> 2, 0x00000000, 8, gcvFALSE, gcvTRUE); + index += _State(Context, index, 0x014C4 >> 2, 0x00000000, 1, gcvFALSE, gcvTRUE); + } + + /* Memory Controller */ + index += _State(Context, index, 0x01654 >> 2, 0x00200000, 1, gcvFALSE, gcvFALSE); + + index += _CLOSE_RANGE(); + index += _State(Context, index, 0x01658 >> 2, 0x00000000, 1, gcvFALSE, gcvTRUE); + index += _State(Context, index, 0x0165C >> 2, 0x00000000, 1, gcvFALSE, gcvTRUE); + index += _State(Context, index, 0x01660 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x01664 >> 2, 0x00000000, 1, gcvFALSE, gcvTRUE); + index += _State(Context, index, 0x01668 >> 2, 0x00000000, 1, gcvFALSE, gcvTRUE); + index += _State(Context, index, 0x0166C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x01670 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x01674 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x016A4 >> 2, 0x00000000, 1, gcvFALSE, gcvTRUE); + index += _State(Context, index, 0x016AC >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x016A8 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x01720 >> 2, 0x00000000, 8, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x01740 >> 2, 0x00000000, 8, gcvFALSE, gcvTRUE); + index += _State(Context, index, 0x01760 >> 2, 0x00000000, 8, gcvFALSE, gcvFALSE); + + + if (halti2) + { + index += _State(Context, index, 0x01780 >> 2, 0x00000000, 8, gcvFALSE, gcvFALSE); + index += _State(Context, index, 0x016BC >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); + index += _State(Context, index, (0x017A0 >> 2) + 1, 0x00000000, 7, gcvFALSE, gcvFALSE); + index += _State(Context, index, (0x017C0 >> 2) + 1, 0x00000000, 7, gcvFALSE, gcvTRUE); + index += _State(Context, index, (0x017E0 >> 2) + 1, 0x00000000, 7, gcvFALSE, gcvTRUE); + index += _State(Context, index, (0x01A00 >> 2) + 1, 0x00000000, 7, gcvFALSE, gcvFALSE); + index += _State(Context, index, (0x01A20 >> 2) + 1, 0x00000000, 7, gcvFALSE, gcvFALSE); + index += _State(Context, index, (0x01A40 >> 2) + 1, 0x00000000, 7, gcvFALSE, gcvFALSE); + } + + index += _CLOSE_RANGE(); + + if (gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_BUG_FIXES18)) + { + index += _State(Context, index, 0x03860 >> 2, 0x6, 1, gcvFALSE, gcvFALSE); + index += _CLOSE_RANGE(); + } + + if (halti3) + { + index += _State(Context, index, 0x01A80 >> 2, 0x00000000, 8, gcvFALSE, gcvTRUE); + index += _CLOSE_RANGE(); + } + + if (hasSecurity || hasRobustness) + { + index += _State(Context, index, 0x001AC >> 2, ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 16:16) - (0 ? + 16:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 16:16) - (0 ? + 16:16) + 1))))))) << (0 ? + 16:16))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 16:16) - (0 ? + 16:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 16:16) - (0 ? 16:16) + 1))))))) << (0 ? 16:16))), 1, gcvFALSE, gcvFALSE); + } + + /* Semaphore/stall. */ + index += _SemaphoreStall(Context, index); #endif -/******************************************************************************\ -**************************** Context Management API **************************** -\******************************************************************************/ + /**************************************************************************/ + /* Link to another address. ***********************************************/ + + Context->linkIndex3D = (gctUINT)index; + + if (buffer != gcvNULL) + { + buffer[index + 0] + = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x08 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))); + + buffer[index + 1] + = 0; + } + + index += 2; + + /* Store the end of the context buffer. */ + Context->bufferSize = index * gcmSIZEOF(gctUINT32); + + + /**************************************************************************/ + /* Pipe switch for the case where neither 2D nor 3D are used. *************/ + + /* Store the 3D entry index. */ + Context->entryOffsetXDFrom2D = (gctUINT)index * gcmSIZEOF(gctUINT32); + + /* Switch to 3D pipe. */ + index += _SwitchPipe(Context, index, gcvPIPE_3D); + + /* Store the location of the link. */ + Context->linkIndexXD = (gctUINT)index; + + if (buffer != gcvNULL) + { + buffer[index + 0] + = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x08 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))); + + buffer[index + 1] + = 0; + } + + index += 2; + + + /**************************************************************************/ + /* Save size for buffer. **************************************************/ + + Context->totalSize = index * gcmSIZEOF(gctUINT32); + + /* Success. */ + gcmkFOOTER_NO(); + return gcvSTATUS_OK; +} +#endif + +static gceSTATUS +_DestroyContext( + IN gckCONTEXT Context + ) +{ + gceSTATUS status = gcvSTATUS_OK; + + if (Context != gcvNULL) + { + gcsCONTEXT_PTR bufferHead; + +#if gcdENABLE_SW_PREEMPTION + gcsSTATE_DELTA_PTR delta, next; + + /* Free state deltas. */ + for (Context->delta = Context->deltaHead; Context->delta != gcvNULL;) + { + delta = Context->delta; + + /* Get the next delta. */ + next = gcmUINT64_TO_PTR(delta->next); + + /* Last item? */ + if (next == Context->deltaHead) + { + next = gcvNULL; + } + + _DestroyDelta(Context, delta); + + /* Remove from the list. */ + Context->delta = next; + } + + gcmkVERIFY_OK(gckCONTEXT_DestroyPrevDelta(Context)); +#endif + + /* Free context buffers. */ + for (bufferHead = Context->buffer; Context->buffer != gcvNULL;) + { + /* Get a shortcut to the current buffer. */ + gcsCONTEXT_PTR buffer = Context->buffer; + + /* Get the next buffer. */ + gcsCONTEXT_PTR next = buffer->next; + + /* Last item? */ + if (next == bufferHead) + { + next = gcvNULL; + } + + /* Destroy the signal. */ + if (buffer->signal != gcvNULL) + { + gcmkONERROR(gckOS_DestroySignal( + Context->os, buffer->signal + )); + + buffer->signal = gcvNULL; + } + + /* Free state delta map. */ + if (buffer->logical != gcvNULL) + { + gckKERNEL kernel = Context->hardware->kernel; + +#if gcdCAPTURE_ONLY_MODE + gceDATABASE_TYPE dbType; + gctUINT32 processID; +#endif + + /* End cpu access. */ + gcmkVERIFY_OK(gckVIDMEM_NODE_UnlockCPU( + kernel, + buffer->videoMem, + 0, + gcvFALSE, + gcvFALSE + )); + + /* Synchronized unlock. */ + gcmkVERIFY_OK(gckVIDMEM_NODE_Unlock( + kernel, + buffer->videoMem, + 0, + gcvNULL + )); + +#if gcdCAPTURE_ONLY_MODE + /* Encode surface type and pool to database type. */ + dbType = gcvDB_VIDEO_MEMORY + | (gcvVIDMEM_TYPE_GENERIC << gcdDB_VIDEO_MEMORY_TYPE_SHIFT) + | (buffer->videoMem->pool << gcdDB_VIDEO_MEMORY_POOL_SHIFT); + + gcmkONERROR(gckOS_GetProcessID(&processID)); + + gcmkONERROR( + gckKERNEL_RemoveProcessDB(kernel, + processID, + dbType, + buffer->videoMem)); +#endif + + /* Free video memory. */ + gcmkVERIFY_OK(gckVIDMEM_NODE_Dereference( + kernel, + buffer->videoMem + )); + + buffer->logical = gcvNULL; + } + + /* Free context buffer. */ + gcmkONERROR(gcmkOS_SAFE_FREE(Context->os, buffer)); + + /* Remove from the list. */ + Context->buffer = next; + } + + /* Mark the gckCONTEXT object as unknown. */ + Context->object.type = gcvOBJ_UNKNOWN; + + /* Free the gckCONTEXT object. */ + gcmkONERROR(gcmkOS_SAFE_FREE(Context->os, Context)); + } + +OnError: + return status; +} -/******************************************************************************\ -** -** gckCONTEXT_Construct -** -** Construct a new gckCONTEXT object. -** -** INPUT: -** -** gckOS Os -** Pointer to gckOS object. -** -** gctUINT32 ProcessID -** Current process ID. -** -** gckHARDWARE Hardware -** Pointer to gckHARDWARE object. -** -** OUTPUT: -** -** gckCONTEXT * Context -** Pointer to a variable thet will receive the gckCONTEXT object -** pointer. -*/ #if (gcdENABLE_3D) -gceSTATUS -gckCONTEXT_Construct( - IN gckOS Os, - IN gckHARDWARE Hardware, - IN gctUINT32 ProcessID, - OUT gckCONTEXT * Context +static gceSTATUS +_AllocateContextBuffer( + IN gckCONTEXT Context, + IN gcsCONTEXT_PTR Buffer ) { gceSTATUS status; - gckCONTEXT context = gcvNULL; - gctUINT32 allocationSize; - gctUINT i; - gctPOINTER pointer = gcvNULL; + gckKERNEL kernel = Context->hardware->kernel; + gcePOOL pool = gcvPOOL_DEFAULT; + gctSIZE_T totalSize = Context->totalSize; + gctUINT32 allocFlag = 0; + +#if gcdCAPTURE_ONLY_MODE + gceDATABASE_TYPE dbType; + gctUINT32 processID; +#endif + +#if gcdENABLE_CACHEABLE_COMMAND_BUFFER + allocFlag = gcvALLOC_FLAG_CACHEABLE; +#endif + + /* Allocate video memory node for command buffers. */ + gcmkONERROR(gckKERNEL_AllocateVideoMemory( + kernel, + 64, + gcvVIDMEM_TYPE_COMMAND, + allocFlag, + &totalSize, + &pool, + &Buffer->videoMem + )); + +#if gcdCAPTURE_ONLY_MODE + gcmkONERROR(gckVIDMEM_HANDLE_Allocate(kernel, Buffer->videoMem, &Context->buffer->handle)); + + /* Encode surface type and pool to database type. */ + dbType = gcvDB_VIDEO_MEMORY + | (gcvVIDMEM_TYPE_GENERIC << gcdDB_VIDEO_MEMORY_TYPE_SHIFT) + | (pool << gcdDB_VIDEO_MEMORY_POOL_SHIFT); + + gcmkONERROR(gckOS_GetProcessID(&processID)); + + /* Record in process db. */ + gcmkONERROR( + gckKERNEL_AddProcessDB(kernel, + processID, + dbType, + Buffer->videoMem, + gcvNULL, + totalSize)); +#endif + + /* Lock for GPU access. */ + gcmkONERROR(gckVIDMEM_NODE_Lock( + kernel, + Buffer->videoMem, + &Buffer->address + )); + + /* Lock for kernel side CPU access. */ + gcmkONERROR(gckVIDMEM_NODE_LockCPU( + kernel, + Buffer->videoMem, + gcvFALSE, + gcvFALSE, + (gctPOINTER *)&Buffer->logical + )); + + return gcvSTATUS_OK; + +OnError: + return status; +} +#endif + +/******************************************************************************\ +**************************** Context Management API **************************** +\******************************************************************************/ + +/******************************************************************************\ +** +** gckCONTEXT_Construct +** +** Construct a new gckCONTEXT object. +** +** INPUT: +** +** gckOS Os +** Pointer to gckOS object. +** +** gctUINT32 ProcessID +** Current process ID. +** +** gckHARDWARE Hardware +** Pointer to gckHARDWARE object. +** +** OUTPUT: +** +** gckCONTEXT * Context +** Pointer to a variable thet will receive the gckCONTEXT object +** pointer. +*/ +#if (gcdENABLE_3D) +gceSTATUS +gckCONTEXT_Construct( + IN gckOS Os, + IN gckHARDWARE Hardware, + IN gctUINT32 ProcessID, + OUT gckCONTEXT * Context + ) +{ + gceSTATUS status; + gckCONTEXT context = gcvNULL; + gctUINT32 allocationSize; + gctUINT i; + gctPOINTER pointer = gcvNULL; + + gcmkHEADER_ARG("Os=%p Hardware=%p", Os, Hardware); + + /* Verify the arguments. */ + gcmkVERIFY_OBJECT(Os, gcvOBJ_OS); + gcmkVERIFY_ARGUMENT(Context != gcvNULL); + + + /**************************************************************************/ + /* Allocate and initialize basic fields of gckCONTEXT. ********************/ + + /* The context object size. */ + allocationSize = gcmSIZEOF(struct _gckCONTEXT); + + /* Allocate the object. */ + gcmkONERROR(gckOS_Allocate( + Os, allocationSize, &pointer + )); + + context = pointer; + + /* Reset the entire object. */ + gcmkONERROR(gckOS_ZeroMemory(context, allocationSize)); + + /* Initialize the gckCONTEXT object. */ + context->object.type = gcvOBJ_CONTEXT; + context->os = Os; + context->hardware = Hardware; + + +#if !gcdENABLE_3D + context->entryPipe = gcvPIPE_2D; + context->exitPipe = gcvPIPE_2D; +#elif gcdCMD_NO_2D_CONTEXT + context->entryPipe = gcvPIPE_3D; + context->exitPipe = gcvPIPE_3D; +#else + context->entryPipe + = (((((gctUINT32) (context->hardware->identity.chipFeatures)) >> (0 ? 9:9)) & ((gctUINT32) ((((1 ? 9:9) - (0 ? 9:9) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 9:9) - (0 ? 9:9) + 1)))))) ) + ? gcvPIPE_2D + : gcvPIPE_3D; + context->exitPipe = gcvPIPE_3D; +#endif + + /* Get the command buffer requirements. */ + gcmkONERROR(gckHARDWARE_QueryCommandBuffer( + Hardware, + gcvENGINE_RENDER, + &context->alignment, + &context->reservedHead, + gcvNULL + )); + + /**************************************************************************/ + /* Get the size of the context buffer. ************************************/ + + gcmkONERROR(_InitializeContextBuffer(context)); + + if (context->maxState > 0) + { + /**************************************************************************/ + /* Allocate and reset the state mapping table. ****************************/ + if (context->hardware->kernel->command->stateMap == gcvNULL) + { + /* Allocate the state mapping table. */ + gcmkONERROR(gckOS_Allocate( + Os, + gcmSIZEOF(gcsSTATE_MAP) * context->maxState, + &pointer + )); + + context->map = pointer; + + /* Zero the state mapping table. */ + gcmkONERROR(gckOS_ZeroMemory( + context->map, gcmSIZEOF(gcsSTATE_MAP) * context->maxState + )); + + context->hardware->kernel->command->stateMap = pointer; + } + else + { + context->map = context->hardware->kernel->command->stateMap; + } + } + + /**************************************************************************/ + /* Allocate the context and state delta buffers. **************************/ + + for (i = 0; i < gcdCONTEXT_BUFFER_COUNT; i += 1) + { + /* Allocate a context buffer. */ + gcsCONTEXT_PTR buffer; + + /* Allocate the context buffer structure. */ + gcmkONERROR(gckOS_Allocate( + Os, + gcmSIZEOF(gcsCONTEXT), + &pointer + )); + + buffer = pointer; + + /* Reset the context buffer structure. */ + gcmkVERIFY_OK(gckOS_ZeroMemory( + buffer, gcmSIZEOF(gcsCONTEXT) + )); + + /* Append to the list. */ + if (context->buffer == gcvNULL) + { + buffer->next = buffer; + context->buffer = buffer; + } + else + { + buffer->next = context->buffer->next; + context->buffer->next = buffer; + } + + /* Set the number of delta in the order of creation. */ +#if gcmIS_DEBUG(gcdDEBUG_CODE) + buffer->num = i; +#endif + + /* Create the busy signal. */ + gcmkONERROR(gckOS_CreateSignal( + Os, gcvFALSE, &buffer->signal + )); + + /* Set the signal, buffer is currently not busy. */ + gcmkONERROR(gckOS_Signal( + Os, buffer->signal, gcvTRUE + )); + + /* Create a new physical context buffer. */ + gcmkONERROR(_AllocateContextBuffer( + context, buffer + )); + + /* Set gckEVENT object pointer. */ + buffer->eventObj = Hardware->kernel->eventObj; + + /* Set the pointers to the LINK commands. */ + if (context->linkIndex2D != 0) + { + buffer->link2D = &buffer->logical[context->linkIndex2D]; + } + + if (context->linkIndex3D != 0) + { + buffer->link3D = &buffer->logical[context->linkIndex3D]; + } + + if (context->linkIndexXD != 0) + { + gctPOINTER xdLink; + gctUINT32 xdEntryAddress; + gctUINT32 xdEntrySize; + gctUINT32 linkBytes; + + /* Determine LINK parameters. */ + xdLink + = &buffer->logical[context->linkIndexXD]; + + xdEntryAddress + = buffer->address + + context->entryOffsetXDFrom3D; + + xdEntrySize + = context->bufferSize + - context->entryOffsetXDFrom3D; + + /* Query LINK size. */ + gcmkONERROR(gckWLFE_Link( + Hardware, gcvNULL, 0, 0, &linkBytes, gcvNULL, gcvNULL + )); + + /* Generate a LINK. */ + gcmkONERROR(gckWLFE_Link( + Hardware, + xdLink, + xdEntryAddress, + xdEntrySize, + &linkBytes, + gcvNULL, + gcvNULL + )); + } + } + + /**************************************************************************/ + /* Initialize the context buffers. ****************************************/ + + /* Initialize the current context buffer. */ + gcmkONERROR(_InitializeContextBuffer(context)); + +#if gcdENABLE_SW_PREEMPTION + if (context->maxState > 0 && context->numStates > 0) + { + for (i = 0; i < gcdCONTEXT_BUFFER_COUNT + 1; i += 1) + { + /* Allocate a state delta. */ + gcsSTATE_DELTA_PTR delta = gcvNULL; + gcsSTATE_DELTA_PTR prev; + + /* Allocate the state delta structure. */ + _AllocateDelta(context, &delta); + + /* Append to the list. */ + if (context->delta == gcvNULL) + { + delta->prev = gcmPTR_TO_UINT64(delta); + delta->next = gcmPTR_TO_UINT64(delta); + context->deltaHead = context->delta = delta; + } + else + { + delta->next = gcmPTR_TO_UINT64(context->delta); + delta->prev = context->delta->prev; + + prev = gcmUINT64_TO_PTR(context->delta->prev); + prev->next = gcmPTR_TO_UINT64(delta); + context->delta->prev = gcmPTR_TO_UINT64(delta); + } + } + } + + if (gckHARDWARE_IsFeatureAvailable(context->hardware, gcvFEATURE_HALTI5) && + !(gckHARDWARE_IsFeatureAvailable(context->hardware, gcvFEATURE_SMALL_BATCH) && context->hardware->options.smallBatch)) + { + mirroredStatesCount = sizeof(mirroredStates) / sizeof(mirroredStates[0]); + } + + context->prevRecordArray = gcvNULL; + context->prevMapEntryID = gcvNULL; + context->prevMapEntryIndex = gcvNULL; + context->prevDeltaPtr = gcvNULL; +#endif + + /* Make all created contexts equal. */ + { + gcsCONTEXT_PTR currContext, tempContext; + + /* Set the current context buffer. */ + currContext = context->buffer; + + /* Get the next context buffer. */ + tempContext = currContext->next; + + /* Loop through all buffers. */ + while (tempContext != currContext) + { + if (tempContext == gcvNULL) + { + gcmkONERROR(gcvSTATUS_NOT_FOUND); + } + + /* Copy the current context. */ + gckOS_MemCopy( + tempContext->logical, + currContext->logical, + context->totalSize + ); + + /* Get the next context buffer. */ + tempContext = tempContext->next; + } + } + + /* Return pointer to the gckCONTEXT object. */ + *Context = context; + + /* Success. */ + gcmkFOOTER_ARG("*Context=0x%08X", *Context); + return gcvSTATUS_OK; + +OnError: + /* Roll back on error. */ + gcmkVERIFY_OK(_DestroyContext(context)); + + /* Return the status. */ + gcmkFOOTER(); + return status; +} +#endif + +/******************************************************************************\ +** +** gckCONTEXT_Destroy +** +** Destroy a gckCONTEXT object. +** +** INPUT: +** +** gckCONTEXT Context +** Pointer to an gckCONTEXT object. +** +** OUTPUT: +** +** Nothing. +*/ +gceSTATUS +gckCONTEXT_Destroy( + IN gckCONTEXT Context + ) +{ + gceSTATUS status; + + gcmkHEADER_ARG("Context=%p", Context); + + /* Verify the arguments. */ + gcmkVERIFY_OBJECT(Context, gcvOBJ_CONTEXT); + + /* Destroy the context and all related objects. */ + status = _DestroyContext(Context); + + /* Success. */ + gcmkFOOTER_NO(); + return status; +} + +/******************************************************************************\ +** +** gckCONTEXT_Update +** +** Merge all pending state delta buffers into the current context buffer. +** +** INPUT: +** +** gckCONTEXT Context +** Pointer to an gckCONTEXT object. +** +** gctUINT32 ProcessID +** Current process ID. +** +** gcsSTATE_DELTA_PTR StateDelta +** Pointer to the state delta. +** +** OUTPUT: +** +** Nothing. +*/ +gceSTATUS +gckCONTEXT_Update( + IN gckCONTEXT Context, + IN gctUINT32 ProcessID, + IN gcsSTATE_DELTA_PTR StateDelta + ) +{ +#if gcdENABLE_3D + gceSTATUS status = gcvSTATUS_OK; + gcsSTATE_DELTA _stateDelta; + gckKERNEL kernel; + gcsCONTEXT_PTR buffer; + gcsSTATE_MAP_PTR map; + gctBOOL needCopy = gcvFALSE; + gcsSTATE_DELTA_PTR nDelta; + gcsSTATE_DELTA_PTR uDelta = gcvNULL; + gcsSTATE_DELTA_PTR kDelta = gcvNULL; + gcsSTATE_DELTA_RECORD_PTR record; + gcsSTATE_DELTA_RECORD_PTR recordArray = gcvNULL; + gctUINT elementCount; + gctUINT address; + gctUINT32 mask; + gctUINT32 data; + gctUINT index; + gctUINT i, j; + gctUINT32 dirtyRecordArraySize = 0; + + gcmkHEADER_ARG( + "Context=%p ProcessID=%d StateDelta=%p", + Context, ProcessID, StateDelta + ); + + /* Verify the arguments. */ + gcmkVERIFY_OBJECT(Context, gcvOBJ_CONTEXT); + + /* Get a shortcut to the kernel object. */ + kernel = Context->hardware->kernel; + + /* Check wehther we need to copy the structures or not. */ + gcmkONERROR(gckOS_QueryNeedCopy(Context->os, ProcessID, &needCopy)); + + /* Get the current context buffer. */ + buffer = Context->buffer; + + /* Wait until the context buffer becomes available; this will + also reset the signal and mark the buffer as busy. */ + gcmkONERROR(gckOS_WaitSignal( + Context->os, buffer->signal, gcvFALSE, gcvINFINITE + )); + +#if gcmIS_DEBUG(gcdDEBUG_CODE) && 1 && gcdENABLE_3D + /* Update current context token. */ + buffer->logical[Context->map[0x0E14].index] + = (gctUINT32)gcmPTR2INT32(Context); +#endif + + /* Are there any pending deltas? */ + if (buffer->deltaCount != 0) + { + /* Get the state map. */ + map = Context->map; + + /* Get the first delta item. */ + uDelta = buffer->delta; + + /* Reset the vertex stream count. */ + elementCount = 0; + + /* Merge all pending deltas. */ + for (i = 0; i < buffer->deltaCount; i += 1) + { + /* Get access to the state delta. */ + gcmkONERROR(gckKERNEL_OpenUserData( + kernel, needCopy, + &_stateDelta, + uDelta, gcmSIZEOF(gcsSTATE_DELTA), + (gctPOINTER *) &kDelta + )); + + dirtyRecordArraySize + = gcmSIZEOF(gcsSTATE_DELTA_RECORD) * kDelta->recordCount; + + if (dirtyRecordArraySize) + { + /* Get access to the state records. */ + gcmkONERROR(gckOS_MapUserPointer( + kernel->os, + gcmUINT64_TO_PTR(kDelta->recordArray), + dirtyRecordArraySize, + (gctPOINTER *) &recordArray + )); + + if (recordArray == gcvNULL) + { + gcmkONERROR(gcvSTATUS_INVALID_ARGUMENT); + } + + /* Merge all pending states. */ + for (j = 0; j < kDelta->recordCount; j += 1) + { + if (j >= Context->numStates) + { + break; + } + + /* Get the current state record. */ + record = &recordArray[j]; + + /* Get the state address. */ + gcmkONERROR(gckOS_ReadMappedPointer(kernel->os, &record->address, &address)); + + /* Make sure the state is a part of the mapping table. */ + if (address >= Context->maxState) + { + gcmkTRACE( + gcvLEVEL_ERROR, + "%s(%d): State 0x%04X (0x%04X) is not mapped.\n", + __FUNCTION__, __LINE__, + address, address << 2 + ); + + continue; + } + + /* Get the state index. */ + index = map[address].index; + + /* Skip the state if not mapped. */ + if (index == 0) + { + continue; + } + + /* Get the data mask. */ + gcmkONERROR(gckOS_ReadMappedPointer(kernel->os, &record->mask, &mask)); + + /* Get the new data value. */ + gcmkONERROR(gckOS_ReadMappedPointer(kernel->os, &record->data, &data)); + + /* Masked states that are being completly reset or regular states. */ + if ((mask == 0) || (mask == ~0U)) + { + /* Process special states. */ + if (address == 0x0595) + { + /* Force auto-disable to be disabled. */ + data = ((((gctUINT32) (data)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 5:5) - (0 ? + 5:5) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 5:5) - (0 ? + 5:5) + 1))))))) << (0 ? + 5:5))) | (((gctUINT32) (0x0 & ((gctUINT32) ((((1 ? + 5:5) - (0 ? + 5:5) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 5:5) - (0 ? 5:5) + 1))))))) << (0 ? 5:5))); + data = ((((gctUINT32) (data)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 4:4) - (0 ? + 4:4) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 4:4) - (0 ? + 4:4) + 1))))))) << (0 ? + 4:4))) | (((gctUINT32) (0x0 & ((gctUINT32) ((((1 ? + 4:4) - (0 ? + 4:4) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 4:4) - (0 ? 4:4) + 1))))))) << (0 ? 4:4))); + data = ((((gctUINT32) (data)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 13:13) - (0 ? + 13:13) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 13:13) - (0 ? + 13:13) + 1))))))) << (0 ? + 13:13))) | (((gctUINT32) (0x0 & ((gctUINT32) ((((1 ? + 13:13) - (0 ? + 13:13) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 13:13) - (0 ? 13:13) + 1))))))) << (0 ? 13:13))); + } + + /* Set new data. */ + buffer->logical[index] = data; + } + + /* Masked states that are being set partially. */ + else + { + buffer->logical[index] + = (~mask & buffer->logical[index]) + | (mask & data); + } + } + } + + /* Get the element count. */ + if (kDelta->elementCount != 0) + { + elementCount = kDelta->elementCount; + } + + /* Dereference delta. */ + kDelta->refCount -= 1; + + gcmkASSERT(kDelta->refCount >= 0); + + /* Get the next state delta. */ + nDelta = gcmUINT64_TO_PTR(kDelta->next); + + if (dirtyRecordArraySize) + { + /* Get access to the state records. */ + gcmkONERROR(gckOS_UnmapUserPointer( + kernel->os, + gcmUINT64_TO_PTR(kDelta->recordArray), + dirtyRecordArraySize, + recordArray + )); + + recordArray = gcvNULL; + } + + /* Close access to the current state delta. */ + gcmkONERROR(gckKERNEL_CloseUserData( + kernel, needCopy, + gcvTRUE, + uDelta, gcmSIZEOF(gcsSTATE_DELTA), + (gctPOINTER *) &kDelta + )); + + /* Update the user delta pointer. */ + uDelta = nDelta; + } + + /* Hardware disables all input attribute when the attribute 0 is programmed, + it then reenables those attributes that were explicitely programmed by + the software. Because of this we cannot program the entire array of + values, otherwise we'll get all attributes reenabled, but rather program + only those that are actully needed by the software. + elementCount = attribCount + 1 to make sure 0 is a flag to indicate if UMD + touches it. + */ + if (elementCount != 0) + { + gctUINT base; + gctUINT nopCount; + gctUINT32_PTR nop; + gctUINT fe2vsCount; + gctUINT attribCount = elementCount -1; + gctUINT32 feAttributeStatgeAddr = 0x0180; + if (gckHARDWARE_IsFeatureAvailable(Context->hardware, gcvFEATURE_HALTI5)) + { + fe2vsCount = 32; + base = map[0x5E00].index; + feAttributeStatgeAddr = 0x5E00; + } + else if (gckHARDWARE_IsFeatureAvailable(Context->hardware, gcvFEATURE_HALTI0)) + { + fe2vsCount = 16; + base = map[0x0180].index; + } + else + { + fe2vsCount = 12; + base = map[0x0180].index; + } + + /* Set the proper state count. */ + if (attribCount == 0) + { + gcmkASSERT(gckHARDWARE_IsFeatureAvailable(Context->hardware, gcvFEATURE_ZERO_ATTRIB_SUPPORT)); + + buffer->logical[base - 1] + = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 26:26) - (0 ? + 26:26) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 26:26) - (0 ? + 26:26) + 1))))))) << (0 ? + 26:26))) | (((gctUINT32) (0x0 & ((gctUINT32) ((((1 ? + 26:26) - (0 ? + 26:26) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 26:26) - (0 ? 26:26) + 1))))))) << (0 ? 26:26))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (feAttributeStatgeAddr) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))); + + /* Set the proper state count. */ + buffer->logical[base + 1] = + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 26:26) - (0 ? + 26:26) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 26:26) - (0 ? + 26:26) + 1))))))) << (0 ? + 26:26))) | (((gctUINT32) (0x0 & ((gctUINT32) ((((1 ? + 26:26) - (0 ? + 26:26) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 26:26) - (0 ? 26:26) + 1))))))) << (0 ? 26:26))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x01F2) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))); + buffer->logical[base + 2] = 0x1; + attribCount = 3; + } + else + { + buffer->logical[base - 1] + = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 26:26) - (0 ? + 26:26) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 26:26) - (0 ? + 26:26) + 1))))))) << (0 ? + 26:26))) | (((gctUINT32) (0x0 & ((gctUINT32) ((((1 ? + 26:26) - (0 ? + 26:26) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 26:26) - (0 ? 26:26) + 1))))))) << (0 ? 26:26))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (attribCount) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (feAttributeStatgeAddr) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))); + } - gcmkHEADER_ARG("Os=%p Hardware=%p", Os, Hardware); + /* Determine the number of NOP commands. */ + nopCount = (fe2vsCount / 2) - (attribCount / 2); + /* Determine the location of the first NOP. */ + nop = &buffer->logical[base + (attribCount | 1)]; - /* Verify the arguments. */ - gcmkVERIFY_OBJECT(Os, gcvOBJ_OS); - gcmkVERIFY_ARGUMENT(Context != gcvNULL); + /* Fill the unused space with NOPs. */ + for (i = 0; i < nopCount; i += 1) + { + if (nop >= buffer->logical + Context->totalSize) + { + break; + } + /* Generate a NOP command. */ + *nop = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x03 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))); - /**************************************************************************/ - /* Allocate and initialize basic fields of gckCONTEXT. ********************/ + /* Advance. */ + nop += 2; + } + } - /* The context object size. */ - allocationSize = gcmSIZEOF(struct _gckCONTEXT); + if (gckHARDWARE_IsFeatureAvailable(Context->hardware, gcvFEATURE_SMALL_BATCH) && + Context->hardware->options.smallBatch) + { + gctUINT numConstant = (gctUINT)Context->hardware->identity.numConstants; + gctUINT32 constCount = 0; - /* Allocate the object. */ - gcmkONERROR(gckOS_Allocate( - Os, allocationSize, &pointer - )); + /* Get the const number after merge. */ + index = map[0x042B].index; + data = buffer->logical[index]; + constCount = (((((gctUINT32) (data)) >> (0 ? 8:0)) & ((gctUINT32) ((((1 ? 8:0) - (0 ? 8:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 8:0) - (0 ? 8:0) + 1)))))) ); - context = pointer; + _UpdateUnifiedReg(Context, 0xD000, numConstant << 2, constCount << 2); + } - /* Reset the entire object. */ - gcmkONERROR(gckOS_ZeroMemory(context, allocationSize)); + if (gckHARDWARE_IsFeatureAvailable(Context->hardware, gcvFEATURE_SMALL_BATCH) && + Context->hardware->options.smallBatch) + { + gctUINT numSamplers = 80; + gctUINT32 samplerCount = 0; - /* Initialize the gckCONTEXT object. */ - context->object.type = gcvOBJ_CONTEXT; - context->os = Os; - context->hardware = Hardware; + /* Get the sampler number after merge. */ + index = map[0x042C].index; + data = buffer->logical[index]; + samplerCount = (((((gctUINT32) (data)) >> (0 ? 6:0)) & ((gctUINT32) ((((1 ? 6:0) - (0 ? 6:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 6:0) - (0 ? 6:0) + 1)))))) ); + _UpdateUnifiedReg(Context, 0x5800, numSamplers, samplerCount); + _UpdateUnifiedReg(Context, 0x5880, numSamplers, samplerCount); + _UpdateUnifiedReg(Context, 0x5900, numSamplers, samplerCount); + _UpdateUnifiedReg(Context, 0x5980, numSamplers, samplerCount); + _UpdateUnifiedReg(Context, 0x5A00, numSamplers, samplerCount); + _UpdateUnifiedReg(Context, 0x5600, numSamplers, samplerCount); + _UpdateUnifiedReg(Context, 0x5680, numSamplers, samplerCount); + } + /* Reset pending deltas. */ + buffer->deltaCount = 0; + buffer->delta = gcvNULL; + } -#if !gcdENABLE_3D - context->entryPipe = gcvPIPE_2D; - context->exitPipe = gcvPIPE_2D; -#elif gcdCMD_NO_2D_CONTEXT - context->entryPipe = gcvPIPE_3D; - context->exitPipe = gcvPIPE_3D; -#else - context->entryPipe - = (((((gctUINT32) (context->hardware->identity.chipFeatures)) >> (0 ? 9:9)) & ((gctUINT32) ((((1 ? 9:9) - (0 ? 9:9) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 9:9) - (0 ? 9:9) + 1)))))) ) - ? gcvPIPE_2D - : gcvPIPE_3D; - context->exitPipe = gcvPIPE_3D; -#endif + if (StateDelta) + { + /* Set state delta user pointer. */ + uDelta = StateDelta; - /* Get the command buffer requirements. */ - gcmkONERROR(gckHARDWARE_QueryCommandBuffer( - Hardware, - gcvENGINE_RENDER, - &context->alignment, - &context->reservedHead, - gcvNULL - )); + /* Get access to the state delta. */ + gcmkONERROR(gckKERNEL_OpenUserData( + kernel, needCopy, + &_stateDelta, + uDelta, gcmSIZEOF(gcsSTATE_DELTA), + (gctPOINTER *) &kDelta + )); - /**************************************************************************/ - /* Get the size of the context buffer. ************************************/ + /* State delta cannot be attached to anything yet. */ + if (kDelta->refCount != 0) + { + gcmkTRACE( + gcvLEVEL_ERROR, + "%s(%d): kDelta->refCount = %d (has to be 0).\n", + __FUNCTION__, __LINE__, + kDelta->refCount + ); + } - gcmkONERROR(_InitializeContextBuffer(context)); + /* Attach to all contexts. */ + buffer = Context->buffer; - if (context->maxState > 0) - { - /**************************************************************************/ - /* Allocate and reset the state mapping table. ****************************/ - if (context->hardware->kernel->command->stateMap == gcvNULL) + do { - /* Allocate the state mapping table. */ - gcmkONERROR(gckOS_Allocate( - Os, - gcmSIZEOF(gcsSTATE_MAP) * context->maxState, - &pointer - )); + /* Attach to the context if nothing is attached yet. If a delta + is allready attached, all we need to do is to increment + the number of deltas in the context. */ + if (buffer->delta == gcvNULL) + { + buffer->delta = uDelta; + } - context->map = pointer; + /* Update reference count. */ + kDelta->refCount += 1; - /* Zero the state mapping table. */ - gcmkONERROR(gckOS_ZeroMemory( - context->map, gcmSIZEOF(gcsSTATE_MAP) * context->maxState - )); + /* Update counters. */ + buffer->deltaCount += 1; - context->hardware->kernel->command->stateMap = pointer; - } - else - { - context->map = context->hardware->kernel->command->stateMap; + /* Get the next context buffer. */ + buffer = buffer->next; + + if (buffer == gcvNULL) + { + gcmkONERROR(gcvSTATUS_NOT_FOUND); + } } - } + while (Context->buffer != buffer); - /**************************************************************************/ - /* Allocate the context and state delta buffers. **************************/ + /* Close access to the current state delta. */ + gcmkONERROR(gckKERNEL_CloseUserData( + kernel, needCopy, + gcvTRUE, + uDelta, gcmSIZEOF(gcsSTATE_DELTA), + (gctPOINTER *) &kDelta + )); - for (i = 0; i < gcdCONTEXT_BUFFER_COUNT; i += 1) - { - /* Allocate a context buffer. */ - gcsCONTEXT_PTR buffer; + } + /* Schedule an event to mark the context buffer as available. */ + gcmkONERROR(gckEVENT_Signal( + buffer->eventObj, buffer->signal, gcvKERNEL_PIXEL + )); - /* Allocate the context buffer structure. */ - gcmkONERROR(gckOS_Allocate( - Os, - gcmSIZEOF(gcsCONTEXT), - &pointer - )); + /* Advance to the next context buffer. */ + Context->buffer = buffer->next; - buffer = pointer; + /* Return the status. */ + gcmkFOOTER(); + return gcvSTATUS_OK; - /* Reset the context buffer structure. */ - gcmkVERIFY_OK(gckOS_ZeroMemory( - buffer, gcmSIZEOF(gcsCONTEXT) +OnError: + /* Get access to the state records. */ + if (kDelta != gcvNULL && recordArray != gcvNULL) + { + gcmkVERIFY_OK(gckOS_UnmapUserPointer( + kernel->os, + gcmUINT64_TO_PTR(kDelta->recordArray), + dirtyRecordArraySize, + (gctPOINTER *) &recordArray )); + } - /* Append to the list. */ - if (context->buffer == gcvNULL) - { - buffer->next = buffer; - context->buffer = buffer; - } - else - { - buffer->next = context->buffer->next; - context->buffer->next = buffer; - } + /* Close access to the current state delta. */ + gcmkVERIFY_OK(gckKERNEL_CloseUserData( + kernel, needCopy, + gcvTRUE, + uDelta, gcmSIZEOF(gcsSTATE_DELTA), + (gctPOINTER *) &kDelta + )); - /* Set the number of delta in the order of creation. */ -#if gcmIS_DEBUG(gcdDEBUG_CODE) - buffer->num = i; + /* Return the status. */ + gcmkFOOTER(); + return status; +#else + return gcvSTATUS_OK; #endif +} - /* Create the busy signal. */ - gcmkONERROR(gckOS_CreateSignal( - Os, gcvFALSE, &buffer->signal - )); +gceSTATUS +gckCONTEXT_MapBuffer( + IN gckCONTEXT Context, + OUT gctUINT64 *Logicals, + OUT gctUINT32 *Bytes + ) +{ + gceSTATUS status; + int i = 0; + gckKERNEL kernel = Context->hardware->kernel; + gctPOINTER logical; + gcsCONTEXT_PTR buffer; + + gcmkHEADER_ARG("Context=%p", Context); + + buffer = Context->buffer; - /* Set the signal, buffer is currently not busy. */ - gcmkONERROR(gckOS_Signal( - Os, buffer->signal, gcvTRUE + for (i = 0; i < gcdCONTEXT_BUFFER_COUNT; i++) + { + /* Lock for userspace CPU access. */ + gcmkONERROR(gckVIDMEM_NODE_LockCPU( + kernel, + buffer->videoMem, + gcvFALSE, + gcvTRUE, + &logical )); - /* Create a new physical context buffer. */ - gcmkONERROR(_AllocateContextBuffer( - context, buffer - )); + Logicals[i] = gcmPTR_TO_UINT64(logical); + buffer = buffer->next; + } - /* Set gckEVENT object pointer. */ - buffer->eventObj = Hardware->kernel->eventObj; + *Bytes = (gctUINT)Context->totalSize; - /* Set the pointers to the LINK commands. */ - if (context->linkIndex2D != 0) - { - buffer->link2D = &buffer->logical[context->linkIndex2D]; - } + gcmkFOOTER_NO(); + return gcvSTATUS_OK; - if (context->linkIndex3D != 0) - { - buffer->link3D = &buffer->logical[context->linkIndex3D]; - } +OnError: + gcmkFOOTER(); + return status; +} - if (context->linkIndexXD != 0) - { - gctPOINTER xdLink; - gctUINT32 xdEntryAddress; - gctUINT32 xdEntrySize; - gctUINT32 linkBytes; +#if gcdENABLE_SW_PREEMPTION +static void +_CopyDelta( + IN gcsSTATE_DELTA_PTR DstDelta, + IN gcsSTATE_DELTA_PTR SrcDelta + ) +{ + DstDelta->recordCount = SrcDelta->recordCount; - /* Determine LINK parameters. */ - xdLink - = &buffer->logical[context->linkIndexXD]; + if (DstDelta->recordCount) + { + gckOS_MemCopy( + gcmUINT64_TO_PTR(DstDelta->recordArray), + gcmUINT64_TO_PTR(SrcDelta->recordArray), + gcmSIZEOF(gcsSTATE_DELTA_RECORD) * DstDelta->recordCount + ); + } - xdEntryAddress - = buffer->address - + context->entryOffsetXDFrom3D; + if (SrcDelta->mapEntryIDSize) + { + gckOS_MemCopy( + gcmUINT64_TO_PTR(DstDelta->mapEntryID), + gcmUINT64_TO_PTR(SrcDelta->mapEntryID), + SrcDelta->mapEntryIDSize + ); + + gckOS_MemCopy( + gcmUINT64_TO_PTR(DstDelta->mapEntryIndex), + gcmUINT64_TO_PTR(SrcDelta->mapEntryIndex), + SrcDelta->mapEntryIDSize + ); + } - xdEntrySize - = context->bufferSize - - context->entryOffsetXDFrom3D; + DstDelta->mapEntryIDSize = SrcDelta->mapEntryIDSize; + DstDelta->id = SrcDelta->id; + DstDelta->elementCount = SrcDelta->elementCount; +} - /* Query LINK size. */ - gcmkONERROR(gckWLFE_Link( - Hardware, gcvNULL, 0, 0, &linkBytes, gcvNULL, gcvNULL - )); +static void +_MergeDelta( + IN gcsSTATE_DELTA_PTR StateDelta, + IN gctUINT32 Address, + IN gctUINT32 Mask, + IN gctUINT32 Data + ) +{ + gcsSTATE_DELTA_RECORD_PTR recordArray; + gcsSTATE_DELTA_RECORD_PTR recordEntry; + gctUINT32_PTR mapEntryID; + gctUINT32_PTR mapEntryIndex; + gctUINT deltaID; + gctUINT32 i; - /* Generate a LINK. */ - gcmkONERROR(gckWLFE_Link( - Hardware, - xdLink, - xdEntryAddress, - xdEntrySize, - &linkBytes, - gcvNULL, - gcvNULL - )); - } + if (!StateDelta) + { + return; } + /* Get the current record array. */ + recordArray = (gcsSTATE_DELTA_RECORD_PTR)(gcmUINT64_TO_PTR(StateDelta->recordArray)); - /**************************************************************************/ - /* Initialize the context buffers. ****************************************/ + /* Get shortcuts to the fields. */ + deltaID = StateDelta->id; + mapEntryID = (gctUINT32_PTR)(gcmUINT64_TO_PTR(StateDelta->mapEntryID)); + mapEntryIndex = (gctUINT32_PTR)(gcmUINT64_TO_PTR(StateDelta->mapEntryIndex)); - /* Initialize the current context buffer. */ - gcmkONERROR(_InitializeContextBuffer(context)); + gcmkASSERT(Address < (StateDelta->mapEntryIDSize / gcmSIZEOF(gctUINT))); - /* Make all created contexts equal. */ + for (i = 0; i < mirroredStatesCount; i++) { - gcsCONTEXT_PTR currContext, tempContext; - - /* Set the current context buffer. */ - currContext = context->buffer; + if ((Address >= mirroredStates[i].inputBase) && + (Address < (mirroredStates[i].inputBase + mirroredStates[i].count))) + { + Address = mirroredStates[i].outputBase + (Address - mirroredStates[i].inputBase); + break; + } + } - /* Get the next context buffer. */ - tempContext = currContext->next; + /* Has the entry been initialized? */ + if (mapEntryID[Address] != deltaID) + { + /* No, initialize the map entry. */ + mapEntryID [Address] = deltaID; + mapEntryIndex [Address] = StateDelta->recordCount; - /* Loop through all buffers. */ - while (tempContext != currContext) - { - if (tempContext == gcvNULL) - { - gcmkONERROR(gcvSTATUS_NOT_FOUND); - } + /* Get the current record. */ + recordEntry = &recordArray[mapEntryIndex[Address]]; - /* Copy the current context. */ - gckOS_MemCopy( - tempContext->logical, - currContext->logical, - context->totalSize - ); + /* Add the state to the list. */ + recordEntry->address = Address; + recordEntry->mask = Mask; + recordEntry->data = Data; - /* Get the next context buffer. */ - tempContext = tempContext->next; - } + /* Update the number of valid records. */ + StateDelta->recordCount += 1; } - /* Return pointer to the gckCONTEXT object. */ - *Context = context; + /* Regular (not masked) states. */ + else if (Mask == 0) + { + /* Get the current record. */ + recordEntry = &recordArray[mapEntryIndex[Address]]; - /* Success. */ - gcmkFOOTER_ARG("*Context=0x%08X", *Context); - return gcvSTATUS_OK; + /* Update the state record. */ + recordEntry->mask = 0; + recordEntry->data = Data; + } -OnError: - /* Roll back on error. */ - gcmkVERIFY_OK(_DestroyContext(context)); + /* Masked states. */ + else + { + /* Get the current record. */ + recordEntry = &recordArray[mapEntryIndex[Address]]; - /* Return the status. */ - gcmkFOOTER(); - return status; + /* Update the state record. */ + recordEntry->mask |= Mask; + recordEntry->data &= ~Mask; + recordEntry->data |= (Data & Mask); + } } -#endif /******************************************************************************\ ** -** gckCONTEXT_Destroy +** gckCONTEXT_UpdateDelta ** -** Destroy a gckCONTEXT object. +** Update delta in kernel driver. ** ** INPUT: ** ** gckCONTEXT Context ** Pointer to an gckCONTEXT object. ** -** OUTPUT: -** -** Nothing. +** gcsSTATE_DELTA_PTR Delta +** Pointer to the state delta. */ gceSTATUS -gckCONTEXT_Destroy( - IN gckCONTEXT Context +gckCONTEXT_UpdateDelta( + IN gckCONTEXT Context, + IN gcsSTATE_DELTA_PTR Delta ) { - gceSTATUS status; + gceSTATUS status = gcvSTATUS_OK; + gcsSTATE_DELTA_PTR delta = gcvNULL; + gcsSTATE_DELTA_PTR prevDelta = gcvNULL; + gcsCONTEXT_PTR buffer = gcvNULL; + gcsSTATE_DELTA_RECORD_PTR record = gcvNULL; - gcmkHEADER_ARG("Context=%p", Context); + gcmkHEADER_ARG("Context=%p Delta=%p", Context, Delta); /* Verify the arguments. */ gcmkVERIFY_OBJECT(Context, gcvOBJ_CONTEXT); + gcmkVERIFY_ARGUMENT(Delta != gcvNULL); - /* Destroy the context and all related objects. */ - status = _DestroyContext(Context); + delta = Delta; - /* Success. */ - gcmkFOOTER_NO(); + if (delta && Context->delta) + { + _CopyDelta(Context->delta, delta); + + buffer = Context->buffer; + + do + { + if (buffer->kDelta == gcvNULL) + { + buffer->kDelta = Context->delta; + } + + buffer->kDeltaCount = 1; + + buffer = buffer->next; + + if (buffer == gcvNULL) + { + gcmkONERROR(gcvSTATUS_NOT_FOUND); + } + } + while (Context->buffer != buffer); + + if (Context->deltaHead != Context->delta) + { + gctUINT count = 0; + gctUINT i = 0; + + delta = Context->delta; + + count = delta->recordCount; + + record = gcmUINT64_TO_PTR(delta->recordArray); + + prevDelta = gcmUINT64_TO_PTR(delta->prev); + + /* Go through all records. */ + for (i = 0; i < count; i += 1) + { + _MergeDelta( + prevDelta, record->address, record->mask, record->data + ); + + /* Advance to the next state. */ + record += 1; + } + + /* Update the element count. */ + if (delta->elementCount != 0) + { + prevDelta->elementCount = delta->elementCount; + } + } + else + { + Context->delta = (gcsSTATE_DELTA_PTR)gcmUINT64_TO_PTR(Context->delta->next); + } + + _ResetDelta(Context->delta); + } + +OnError: + gcmkFOOTER(); return status; } /******************************************************************************\ ** -** gckCONTEXT_Update +** gckCONTEXT_PreemptUpdate ** -** Merge all pending state delta buffers into the current context buffer. +** Context update in preemption mode. ** ** INPUT: ** ** gckCONTEXT Context ** Pointer to an gckCONTEXT object. ** -** gctUINT32 ProcessID -** Current process ID. -** -** gcsSTATE_DELTA_PTR StateDelta -** Pointer to the state delta. -** -** OUTPUT: -** -** Nothing. +** gckPREEMPT_COMMIT PreemptCommit +** The preemptCommit. */ gceSTATUS -gckCONTEXT_Update( +gckCONTEXT_PreemptUpdate( IN gckCONTEXT Context, - IN gctUINT32 ProcessID, - IN gcsSTATE_DELTA_PTR StateDelta + IN gckPREEMPT_COMMIT PreemptCommit ) { -#if gcdENABLE_3D gceSTATUS status = gcvSTATUS_OK; - gcsSTATE_DELTA _stateDelta; - gckKERNEL kernel; gcsCONTEXT_PTR buffer; gcsSTATE_MAP_PTR map; - gctBOOL needCopy = gcvFALSE; - gcsSTATE_DELTA_PTR nDelta; - gcsSTATE_DELTA_PTR uDelta = gcvNULL; - gcsSTATE_DELTA_PTR kDelta = gcvNULL; gcsSTATE_DELTA_RECORD_PTR record; gcsSTATE_DELTA_RECORD_PTR recordArray = gcvNULL; gctUINT elementCount; @@ -4681,77 +6036,38 @@ gckCONTEXT_Update( gctUINT index; gctUINT i, j; gctUINT32 dirtyRecordArraySize = 0; + gcsSTATE_DELTA_PTR kDelta = gcvNULL; - gcmkHEADER_ARG( - "Context=%p ProcessID=%d StateDelta=%p", - Context, ProcessID, StateDelta - ); + gcmkHEADER_ARG("Context=%p PreemptCommit=%p", Context, PreemptCommit); /* Verify the arguments. */ gcmkVERIFY_OBJECT(Context, gcvOBJ_CONTEXT); - /* Get a shortcut to the kernel object. */ - kernel = Context->hardware->kernel; - - /* Check wehther we need to copy the structures or not. */ - gcmkONERROR(gckOS_QueryNeedCopy(Context->os, ProcessID, &needCopy)); - - /* Get the current context buffer. */ buffer = Context->buffer; - /* Wait until the context buffer becomes available; this will - also reset the signal and mark the buffer as busy. */ gcmkONERROR(gckOS_WaitSignal( Context->os, buffer->signal, gcvFALSE, gcvINFINITE )); -#if gcmIS_DEBUG(gcdDEBUG_CODE) && 1 && gcdENABLE_3D - /* Update current context token. */ - buffer->logical[Context->map[0x0E14].index] - = (gctUINT32)gcmPTR2INT32(Context); -#endif - /* Are there any pending deltas? */ - if (buffer->deltaCount != 0) + if (buffer->kDeltaCount != 0) { /* Get the state map. */ map = Context->map; - /* Get the first delta item. */ - uDelta = buffer->delta; - - /* Reset the vertex stream count. */ - elementCount = 0; - - /* Merge all pending deltas. */ - for (i = 0; i < buffer->deltaCount; i += 1) - { - /* Get access to the state delta. */ - gcmkONERROR(gckKERNEL_OpenUserData( - kernel, needCopy, - &_stateDelta, - uDelta, gcmSIZEOF(gcsSTATE_DELTA), - (gctPOINTER *) &kDelta - )); - - dirtyRecordArraySize - = gcmSIZEOF(gcsSTATE_DELTA_RECORD) * kDelta->recordCount; + kDelta = buffer->kDelta; - if (dirtyRecordArraySize) - { - /* Get access to the state records. */ - gcmkONERROR(gckOS_MapUserPointer( - kernel->os, - gcmUINT64_TO_PTR(kDelta->recordArray), - dirtyRecordArraySize, - (gctPOINTER *) &recordArray - )); + /* Reset the vertex stream count. */ + elementCount = 0; - if (recordArray == gcvNULL) - { - gcmkONERROR(gcvSTATUS_INVALID_ARGUMENT); - } + /* Merge all pending deltas. */ + for (i = 0; i < buffer->kDeltaCount; i += 1) + { + dirtyRecordArraySize + = gcmSIZEOF(gcsSTATE_DELTA_RECORD) * kDelta->recordCount; + if (dirtyRecordArraySize) + { /* Merge all pending states. */ for (j = 0; j < kDelta->recordCount; j += 1) { @@ -4760,11 +6076,13 @@ gckCONTEXT_Update( break; } + recordArray = gcmUINT64_TO_PTR(kDelta->recordArray); + /* Get the current state record. */ record = &recordArray[j]; /* Get the state address. */ - gcmkONERROR(gckOS_ReadMappedPointer(kernel->os, &record->address, &address)); + address = record->address; /* Make sure the state is a part of the mapping table. */ if (address >= Context->maxState) @@ -4789,10 +6107,10 @@ gckCONTEXT_Update( } /* Get the data mask. */ - gcmkONERROR(gckOS_ReadMappedPointer(kernel->os, &record->mask, &mask)); + mask = record->mask; /* Get the new data value. */ - gcmkONERROR(gckOS_ReadMappedPointer(kernel->os, &record->data, &data)); + data = record->data; /* Masked states that are being completly reset or regular states. */ if ((mask == 0) || (mask == ~0U)) @@ -4853,36 +6171,13 @@ gckCONTEXT_Update( elementCount = kDelta->elementCount; } - /* Dereference delta. */ - kDelta->refCount -= 1; - gcmkASSERT(kDelta->refCount >= 0); - - /* Get the next state delta. */ - nDelta = gcmUINT64_TO_PTR(kDelta->next); - if (dirtyRecordArraySize) { - /* Get access to the state records. */ - gcmkONERROR(gckOS_UnmapUserPointer( - kernel->os, - gcmUINT64_TO_PTR(kDelta->recordArray), - dirtyRecordArraySize, - recordArray - )); - recordArray = gcvNULL; } - /* Close access to the current state delta. */ - gcmkONERROR(gckKERNEL_CloseUserData( - kernel, needCopy, - gcvTRUE, - uDelta, gcmSIZEOF(gcsSTATE_DELTA), - (gctPOINTER *) &kDelta - )); - - /* Update the user delta pointer. */ - uDelta = nDelta; + /* Get the next state delta. */ + kDelta = gcmUINT64_TO_PTR(kDelta->next); } /* Hardware disables all input attribute when the attribute 0 is programmed, @@ -5118,152 +6413,237 @@ gckCONTEXT_Update( _UpdateUnifiedReg(Context, 0x5600, numSamplers, samplerCount); _UpdateUnifiedReg(Context, 0x5680, numSamplers, samplerCount); } + /* Reset pending deltas. */ - buffer->deltaCount = 0; - buffer->delta = gcvNULL; + buffer->kDeltaCount = 0; + } + + /* Schedule an event to mark the context buffer as available. */ + gcmkONERROR(gckEVENT_Signal( + buffer->eventObj, buffer->signal, gcvKERNEL_PIXEL + )); + + /* Advance to the next context buffer. */ + Context->buffer = buffer->next; + +OnError: + gcmkFOOTER(); + return status; +} + +/* Destroy previous context switch delta. */ +gceSTATUS +gckCONTEXT_DestroyPrevDelta( + IN gckCONTEXT Context + ) +{ + gceSTATUS status = gcvSTATUS_OK; + + gcmkHEADER_ARG("Context=%p", Context); + + if (Context->prevRecordArray) + { + gcmkVERIFY_OK(gcmkOS_SAFE_FREE(Context->os, Context->prevRecordArray)); + } + + if (Context->prevMapEntryID) + { + gcmkVERIFY_OK(gcmkOS_SAFE_FREE(Context->os, Context->prevMapEntryID)); } + if (Context->prevMapEntryIndex) + { + gcmkVERIFY_OK(gcmkOS_SAFE_FREE(Context->os, Context->prevMapEntryIndex)); + } + + Context->prevDeltaPtr = gcvNULL; + + gcmkFOOTER(); + + return status; +} + +/* Construct and store previous context switch delta. */ +gceSTATUS +gckCONTEXT_ConstructPrevDelta( + IN gckCONTEXT Context, + IN gctUINT32 ProcessID, + IN gcsSTATE_DELTA_PTR StateDelta + ) +{ + gceSTATUS status = gcvSTATUS_OK; + gcsSTATE_DELTA_PTR uDelta = gcvNULL; + gcsSTATE_DELTA_PTR kDelta = gcvNULL; + gcsSTATE_DELTA_RECORD_PTR kRecordArray = gcvNULL; + gctBOOL needCopy = gcvFALSE; + gctPOINTER pointer = gcvNULL; + gctUINT32 dirtyRecordArraySize = 0; + gckKERNEL kernel = gcvNULL; + gctBOOL allocated = gcvFALSE; + + gcmkHEADER_ARG( + "Context=%p ProcessID=%d StateDelta=%p", + Context, ProcessID, StateDelta + ); + + /* Verify the arguments. */ + gcmkVERIFY_OBJECT(Context, gcvOBJ_CONTEXT); + if (StateDelta) { - /* Set state delta user pointer. */ + kernel = Context->hardware->kernel; + + gcmkVERIFY_OK(gckCONTEXT_DestroyPrevDelta(Context)); + + gcmkVERIFY_OK(gckOS_QueryNeedCopy(kernel->os, ProcessID, &needCopy)); + uDelta = StateDelta; - /* Get access to the state delta. */ gcmkONERROR(gckKERNEL_OpenUserData( kernel, needCopy, - &_stateDelta, + &Context->prevDelta, uDelta, gcmSIZEOF(gcsSTATE_DELTA), - (gctPOINTER *) &kDelta + (gctPOINTER *)&kDelta )); - /* State delta cannot be attached to anything yet. */ - if (kDelta->refCount != 0) + allocated = gcvTRUE; + + dirtyRecordArraySize + = gcmSIZEOF(gcsSTATE_DELTA_RECORD) * kDelta->recordCount; + + if (dirtyRecordArraySize) { - gcmkTRACE( - gcvLEVEL_ERROR, - "%s(%d): kDelta->refCount = %d (has to be 0).\n", - __FUNCTION__, __LINE__, - kDelta->refCount - ); + gcmkONERROR(gckOS_Allocate( + kernel->os, + gcmSIZEOF(gcsSTATE_DELTA_RECORD) * dirtyRecordArraySize, + &pointer + )); + + Context->prevRecordArray = (gcsSTATE_DELTA_RECORD_PTR)pointer; + + gcmkONERROR(gckKERNEL_OpenUserData( + kernel, needCopy, + Context->prevRecordArray, + gcmUINT64_TO_PTR(kDelta->recordArray), + dirtyRecordArraySize, + (gctPOINTER *) &kRecordArray + )); + + if (kRecordArray == gcvNULL) + { + gcmkONERROR(gcvSTATUS_INVALID_ARGUMENT); + } + + gcmkONERROR(gckKERNEL_CloseUserData( + kernel, needCopy, + gcvFALSE, + gcmUINT64_TO_PTR(kDelta->recordArray), + dirtyRecordArraySize, + (gctPOINTER *) &kRecordArray + )); + + } + else + { + Context->prevRecordArray = gcvNULL; } - /* Attach to all contexts. */ - buffer = Context->buffer; + kDelta->recordArray = gcmPTR_TO_UINT64(Context->prevRecordArray); - do + if (Context && Context->maxState > 0) { - /* Attach to the context if nothing is attached yet. If a delta - is allready attached, all we need to do is to increment - the number of deltas in the context. */ - if (buffer->delta == gcvNULL) + /* Compute UINT array size. */ + gctUINT bytes = gcmSIZEOF(gctUINT) * Context->maxState; + gctUINT32 *kMapEntryID = gcvNULL; + gctUINT32 *kMapEntryIndex = gcvNULL; + + /* Allocate map ID array. */ + gcmkONERROR(gckOS_Allocate( + kernel->os, bytes, &pointer + )); + + Context->prevMapEntryID = (gctUINT32 *)pointer; + + /* Set the map ID size. */ + kDelta->mapEntryIDSize = bytes; + + gcmkONERROR(gckKERNEL_OpenUserData( + kernel, needCopy, + Context->prevMapEntryID, + gcmUINT64_TO_PTR(kDelta->mapEntryID), + bytes, + (gctPOINTER *) &kMapEntryID + )); + + if (kMapEntryID == gcvNULL) { - buffer->delta = uDelta; + gcmkONERROR(gcvSTATUS_INVALID_ARGUMENT); } - /* Update reference count. */ - kDelta->refCount += 1; + gcmkONERROR(gckKERNEL_CloseUserData( + kernel, needCopy, + gcvFALSE, + gcmUINT64_TO_PTR(kDelta->mapEntryID), + bytes, + (gctPOINTER *) &kMapEntryID + )); - /* Update counters. */ - buffer->deltaCount += 1; + kDelta->mapEntryID = gcmPTR_TO_UINT64(Context->prevMapEntryID); - /* Get the next context buffer. */ - buffer = buffer->next; + /* Allocate map index array. */ + gcmkONERROR(gckOS_Allocate( + kernel->os, bytes, &pointer + )); - if (buffer == gcvNULL) + Context->prevMapEntryIndex = (gctUINT32 *)pointer; + + gcmkONERROR(gckKERNEL_OpenUserData( + kernel, needCopy, + Context->prevMapEntryIndex, + gcmUINT64_TO_PTR(kDelta->mapEntryIndex), + bytes, + (gctPOINTER *) &kMapEntryIndex + )); + + if (kMapEntryIndex == gcvNULL) { - gcmkONERROR(gcvSTATUS_NOT_FOUND); + gcmkONERROR(gcvSTATUS_INVALID_ARGUMENT); } + + gcmkONERROR(gckKERNEL_CloseUserData( + kernel, needCopy, + gcvFALSE, + gcmUINT64_TO_PTR(kDelta->mapEntryIndex), + bytes, + (gctPOINTER *) &kMapEntryIndex + )); + + kDelta->mapEntryIndex = gcmPTR_TO_UINT64(Context->prevMapEntryIndex); } - while (Context->buffer != buffer); - /* Close access to the current state delta. */ + Context->prevDeltaPtr = kDelta; + gcmkONERROR(gckKERNEL_CloseUserData( kernel, needCopy, - gcvTRUE, + gcvFALSE, uDelta, gcmSIZEOF(gcsSTATE_DELTA), (gctPOINTER *) &kDelta )); - } - /* Schedule an event to mark the context buffer as available. */ - gcmkONERROR(gckEVENT_Signal( - buffer->eventObj, buffer->signal, gcvKERNEL_PIXEL - )); - - /* Advance to the next context buffer. */ - Context->buffer = buffer->next; - /* Return the status. */ - gcmkFOOTER(); + gcmkFOOTER_NO(); return gcvSTATUS_OK; OnError: - /* Get access to the state records. */ - if (kDelta != gcvNULL && recordArray != gcvNULL) + if (allocated) { - gcmkVERIFY_OK(gckOS_UnmapUserPointer( - kernel->os, - gcmUINT64_TO_PTR(kDelta->recordArray), - dirtyRecordArraySize, - (gctPOINTER *) &recordArray - )); + gcmkVERIFY_OK(gckCONTEXT_DestroyPrevDelta(Context)); } - /* Close access to the current state delta. */ - gcmkVERIFY_OK(gckKERNEL_CloseUserData( - kernel, needCopy, - gcvTRUE, - uDelta, gcmSIZEOF(gcsSTATE_DELTA), - (gctPOINTER *) &kDelta - )); - - /* Return the status. */ gcmkFOOTER(); return status; -#else - return gcvSTATUS_OK; -#endif } -gceSTATUS -gckCONTEXT_MapBuffer( - IN gckCONTEXT Context, - OUT gctUINT64 *Logicals, - OUT gctUINT32 *Bytes - ) -{ - gceSTATUS status; - int i = 0; - gckKERNEL kernel = Context->hardware->kernel; - gctPOINTER logical; - gcsCONTEXT_PTR buffer; - - gcmkHEADER_ARG("Context=%p", Context); - - buffer = Context->buffer; - - for (i = 0; i < gcdCONTEXT_BUFFER_COUNT; i++) - { - /* Lock for userspace CPU access. */ - gcmkONERROR(gckVIDMEM_NODE_LockCPU( - kernel, - buffer->videoMem, - gcvFALSE, - gcvTRUE, - &logical - )); - - Logicals[i] = gcmPTR_TO_UINT64(logical); - buffer = buffer->next; - } - - *Bytes = (gctUINT)Context->totalSize; - - gcmkFOOTER_NO(); - return gcvSTATUS_OK; -OnError: - gcmkFOOTER(); - return status; -} +#endif diff --git a/drivers/amlogic/npu/kernel/arch/gc_hal_kernel_context.h b/drivers/amlogic/npu/kernel/arch/gc_hal_kernel_context.h index 5f99ddf..0f44d95 100644 --- a/drivers/amlogic/npu/kernel/arch/gc_hal_kernel_context.h +++ b/drivers/amlogic/npu/kernel/arch/gc_hal_kernel_context.h @@ -56,8 +56,6 @@ #ifndef __gc_hal_kernel_context_h_ #define __gc_hal_kernel_context_h_ -#include "gc_hal_kernel_buffer.h" - #ifdef __cplusplus extern "C" { #endif @@ -110,6 +108,12 @@ typedef struct _gcsCONTEXT /* Pointer to the first delta to be applied. */ gcsSTATE_DELTA_PTR delta; +#if gcdENABLE_SW_PREEMPTION + /* Kernel delta. */ + gcsSTATE_DELTA_PTR kDelta; + gctUINT kDeltaCount; +#endif + /* Next context buffer. */ gcsCONTEXT_PTR next; } @@ -183,6 +187,18 @@ struct _gckCONTEXT gcsPROFILER_COUNTERS_PART2 latestProfiler_part2; gcsPROFILER_COUNTERS_PART2 histroyProfiler_part2; gcsPROFILER_COUNTERS_PART2 preProfiler_part2; + +#if gcdENABLE_SW_PREEMPTION + /* Kernel delta. */ + gcsSTATE_DELTA_PTR delta; + gcsSTATE_DELTA_PTR deltaHead; + + gcsSTATE_DELTA prevDelta; + gcsSTATE_DELTA_PTR prevDeltaPtr; + gcsSTATE_DELTA_RECORD_PTR prevRecordArray; + gctUINT32 * prevMapEntryID; + gctUINT32 * prevMapEntryIndex; +#endif }; #ifdef __cplusplus diff --git a/drivers/amlogic/npu/kernel/arch/gc_hal_kernel_hardware.c b/drivers/amlogic/npu/kernel/arch/gc_hal_kernel_hardware.c index b1bf686..0a2ae5c 100644 --- a/drivers/amlogic/npu/kernel/arch/gc_hal_kernel_hardware.c +++ b/drivers/amlogic/npu/kernel/arch/gc_hal_kernel_hardware.c @@ -347,6 +347,14 @@ _IdentifyHardwareByDatabase( sizeof(gctUINT32) * gcvSRAM_INTER_COUNT ); } + else + { + for (i = gcvSRAM_INTERNAL0; i < gcvSRAM_INTER_COUNT; i++) + { + Identity->sRAMSizes[i] = 0; + } + } + for (i = gcvSRAM_INTERNAL0; i < gcvSRAM_INTER_COUNT; i++) { @@ -1649,6 +1657,16 @@ _QueryFeatureDatabase( case gcvFEATURE_USC_EVICT_CTRL_FIFO_FLOP_RESET_FIX: available = database->USC_EVICT_CTRL_FIFO_FLOP_RESET_FIX; + break; + + case gcvFEATURE_Q_CHANNEL_SUPPORT: + available = database->Q_CHANNEL_SUPPORT; + break; + + case gcvFEATURE_MMU_PAGE_DESCRIPTOR: + available = database->MMU_PAGE_DESCRIPTOR; + break; + /*FALLTHRU*/ default: gcmkFATAL("Invalid feature has been requested."); @@ -1854,6 +1872,8 @@ _SetHardwareOptions( options->secureMode = gcvSECURE_IN_NORMAL; } + options->hasShader = database->NumShaderCores; + return; } @@ -2043,7 +2063,7 @@ _SetupSRAMVidMem( gctUINT64 data = 0; gctBOOL sRAMRequested; - gcmkSPRINTF(sRAMName, gcmSIZEOF(sRAMName) - 1, "Galcore core%d sram%d", Hardware->core, i); + gcmkSPRINTF(sRAMName, gcmSIZEOF(sRAMName) - 1, "gcCore%dSRAM%d", Hardware->core, i); status = gckOS_QueryOption(Hardware->os, "sRAMRequested", (gctUINT64 *)&data); sRAMRequested = (status == gcvSTATUS_OK) ? (data != 0) : gcvFALSE; @@ -2053,6 +2073,7 @@ _SetupSRAMVidMem( Hardware->identity.sRAMSizes[i], sRAMName, sRAMRequested, + gcvTRUE, &Hardware->sRAMPhysical[i] )); @@ -2068,6 +2089,82 @@ OnError: /******************************************************************************\ ****************************** gckHARDWARE API code ***************************** \******************************************************************************/ +gceSTATUS +gckHARDWARE_QchannelPowerOn( + IN gckHARDWARE Hardware + ) +{ + gceSTATUS status = gcvSTATUS_OK; + gctUINT32 reg = 0, delay = 1; + + gcmkHEADER_ARG("Hardware=%p", Hardware); + + gcmkVERIFY_ARGUMENT(Hardware != gcvNULL); + + gcmkONERROR( + gckOS_WriteRegisterEx(Hardware->os, + Hardware->core, + 0x005E8, + ((((gctUINT32) (0x00000000)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 0:0) - (0 ? + 0:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 0:0) - (0 ? + 0:0) + 1))))))) << (0 ? + 0:0))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 0:0) - (0 ? + 0:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 0:0) - (0 ? 0:0) + 1))))))) << (0 ? 0:0))))); + + do + { + gckOS_Delay(Hardware->os, delay); + + gcmkVERIFY_OK( + gckOS_ReadRegisterEx(Hardware->os, + Hardware->core, + 0x005E4, + ®)); + delay *= 2; + + } while(!(reg & 0x1)); + +OnError: + gcmkFOOTER(); + return status; +} + +gceSTATUS +gckHARDWARE_QchannelBypass( + IN gckHARDWARE Hardware, + IN gctBOOL Enable + ) +{ + gceSTATUS status = gcvSTATUS_OK; + + gcmkHEADER_ARG("Hardware=%p", Hardware); + + gcmkVERIFY_ARGUMENT(Hardware != gcvNULL); + + gcmkONERROR( + gckOS_WriteRegisterEx(Hardware->os, + Hardware->core, + 0x005E8, + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 1:1) - (0 ? + 1:1) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 1:1) - (0 ? + 1:1) + 1))))))) << (0 ? + 1:1))) | (((gctUINT32) ((gctUINT32) (Enable) & ((gctUINT32) ((((1 ? + 1:1) - (0 ? + 1:1) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 1:1) - (0 ? 1:1) + 1))))))) << (0 ? 1:1))))); + +OnError: + gcmkFOOTER(); + return status; +} /******************************************************************************* ** @@ -2140,6 +2237,14 @@ gckHARDWARE_Construct( _SetHardwareOptions(hardware); + hardware->hasQchannel = gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_Q_CHANNEL_SUPPORT); + + /* Bypass Qchannel power management. */ + if (!hardware->options.powerManagement && hardware->hasQchannel) + { + gcmkONERROR(gckHARDWARE_QchannelBypass(hardware, gcvTRUE)); + } + hardware->mmuVersion = gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_MMU); /* Get the system's physical base address for old MMU */ @@ -2796,7 +2901,7 @@ gckHARDWARE_InitializeHardware( gckOS_WriteRegisterEx(Hardware->os, Hardware->core, 0x0010C, - ((((gctUINT32) (0x01590880)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + ((((gctUINT32) (0x015B0880)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 23:23) - (0 ? 23:23) + 1) == 32) ? ~0U : (~(~0U << ((1 ? @@ -2818,7 +2923,7 @@ gckHARDWARE_InitializeHardware( { gctUINT32 pulseEater; - pulseEater = ((((gctUINT32) (0x01590880)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + pulseEater = ((((gctUINT32) (0x015B0880)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 16:16) - (0 ? 16:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? @@ -2956,6 +3061,29 @@ gckHARDWARE_InitializeHardware( data)); } + if (Hardware->identity.chipModel == 0x620 && + Hardware->identity.chipRevision == 0x5552 && + Hardware->identity.productID == 0x6200 && + Hardware->identity.customerID == 0x209) + { + gcmkPRINT("Initailize APB1 registers.\n "); + + + /* APB FE ctrl. */ + gcmkONERROR(gckOS_WriteRegisterEx( + Hardware->os, + Hardware->core, + 0x300028, + 0x2)); + + /* APB FE cfg. */ + gcmkONERROR(gckOS_WriteRegisterEx( + Hardware->os, + Hardware->core, + 0x30002C, + 0x2)); + } + #if !gcdCAPTURE_ONLY_MODE gcmkONERROR( gckHARDWARE_SetMMU(Hardware, @@ -3343,7 +3471,7 @@ gckHARDWARE_InitializeHardware( if (funcVaild) { gckFUNCTION_Execute(&Hardware->functions[i]); - gckFUNCTION_Release(&Hardware->functions[i]); + gckFUNCTION_Execute(&Hardware->functions[gcvFUNCTION_EXECUTION_FLUSH]); } } @@ -4870,11 +4998,11 @@ gckHARDWARE_SetMMU( /* Enable MMU. */ if (Hardware->options.secureMode == gcvSECURE_IN_NORMAL) { - gcmkONERROR(gckOS_WriteRegisterEx_NoDump( - Hardware->os, - Hardware->core, - 0x00388, - ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + gctUINT32 config; + + if (Mmu->initMode == gcvMMU_INIT_FROM_REG) + { + config = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 0:0) - (0 ? 0:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? @@ -4884,6 +5012,36 @@ gckHARDWARE_SetMMU( 0:0) - (0 ? 0:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 0:0) - (0 ? 0:0) + 1))))))) << (0 ? 0:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 5:5) - (0 ? + 5:5) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 5:5) - (0 ? + 5:5) + 1))))))) << (0 ? + 5:5))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 5:5) - (0 ? + 5:5) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 5:5) - (0 ? 5:5) + 1))))))) << (0 ? 5:5))); + } + else + { + config = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 0:0) - (0 ? + 0:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 0:0) - (0 ? + 0:0) + 1))))))) << (0 ? + 0:0))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 0:0) - (0 ? + 0:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 0:0) - (0 ? 0:0) + 1))))))) << (0 ? 0:0))); + } + + gcmkONERROR(gckOS_WriteRegisterEx_NoDump( + Hardware->os, + Hardware->core, + 0x00388, + config )); } else @@ -6174,6 +6332,7 @@ gckHARDWARE_Flush( gctBOOL blt; gctBOOL peTSFlush; gctBOOL multiCluster; + gctBOOL computeOnly; gcmkHEADER_ARG("Hardware=0x%x Flush=0x%x Logical=0x%x *Bytes=%lu", Hardware, Flush, Logical, gcmOPT_VALUE(Bytes)); @@ -6193,6 +6352,8 @@ gckHARDWARE_Flush( peTSFlush = gckHARDWARE_IsFeatureAvailable(Hardware, gcvFEATURE_PE_TILE_CACHE_FLUSH_FIX); + computeOnly = gckHARDWARE_IsFeatureAvailable(Hardware, gcvFEATURE_COMPUTE_ONLY); + /* Flush tile status cache. */ flushTileStatus = Flush & gcvFLUSH_TILE_STATUS; @@ -6422,7 +6583,7 @@ gckHARDWARE_Flush( reserveBytes += 2 * gcmSIZEOF(gctUINT32); } - if (flushTileStatus) + if (flushTileStatus && !computeOnly) { reserveBytes += (!peTSFlush && blt) ? 6 * gcmSIZEOF(gctUINT32) : 2 * gcmSIZEOF(gctUINT32); } @@ -6816,7 +6977,7 @@ gckHARDWARE_Flush( gcmkTRACE_ZONE(gcvLEVEL_INFO, gcvZONE_HARDWARE, "0x%x: FLUSH 0x%x", logical - 1, flush); } - if (flushTileStatus) + if (flushTileStatus && !computeOnly) { if (!peTSFlush && blt) { @@ -8225,7 +8386,7 @@ _PmSetPowerOffDirection( switch (Hardware->chipPowerState) { case gcvPOWER_ON: - if(Hardware->kernel->threadInitialized == gcvTRUE) + if (Hardware->kernel->threadInitialized == gcvTRUE) { /* Stall. */ status = _PmStallCommand(Hardware, command, Broadcast); @@ -8257,10 +8418,11 @@ _PmSetPowerOffDirection( gcmkONERROR(_PmClockOff(Hardware, gcvTRUE)); break; } + /* FALLTHRU */ case gcvPOWER_SUSPEND: - if(Hardware->kernel->threadInitialized == gcvTRUE) + if (Hardware->kernel->threadInitialized == gcvTRUE) { /* Flush. */ gcmkONERROR(_PmFlushCache(Hardware, command)); @@ -8284,6 +8446,158 @@ OnError: return status; } +static gceSTATUS +_QchannelForcePowerOff( + IN gckCOMMAND Command, + IN gckHARDWARE Hardware + ) +{ + gceSTATUS status = gcvSTATUS_OK; + gctUINT32 endBytes, bufferSize; + gctUINT32 address; + gctPOINTER logical = gcvNULL; + + gcmkONERROR(gckWLFE_End(Hardware, gcvNULL, ~0U, &endBytes)); + + /* Reserve space. */ + gcmkONERROR(gckCOMMAND_Reserve( + Command, + endBytes, + (gctPOINTER *)&logical, + &bufferSize + )); + + /* Pointer to reserved address. */ + address = Command->address + Command->offset; + + /* END command to trigger Qchannel power off. */ + gcmkONERROR(gckWLFE_End(Hardware, logical, address, &endBytes)); + + gcmkONERROR(gckVIDMEM_NODE_CleanCache( + Command->kernel, + Command->videoMem, + Command->offset, + logical, + endBytes + )); + + gcmkONERROR(gckWLFE_Execute(Hardware, address, endBytes)); + +OnError: + return status; +} + +static gceSTATUS +_QchannelPowerOnDirection( + IN gckHARDWARE Hardware, + IN gceCHIPPOWERSTATE State + ) +{ + gceSTATUS status; + gckCOMMAND command = Hardware->kernel->command; + gctBOOL clockOn = gcvFALSE; + + switch (Hardware->chipPowerState) + { + case gcvPOWER_OFF: + case gcvPOWER_SUSPEND: + + gcmkONERROR(gckHARDWARE_QchannelPowerOn(Hardware)); + + clockOn = gcvTRUE; + + /* Clock control, put to target state (On or idle). */ + gcmkONERROR(_PmClockControl(Hardware, State)); + + /* Delay. */ + gcmkONERROR(gckOS_Delay(Hardware->os, gcdPOWER_CONTROL_DELAY)); + + /* Initialize. */ + gcmkONERROR(_PmInitializeGPU(Hardware, command)); + + /* Start. */ + gcmkONERROR(gckCOMMAND_Start(command)); + break; + + case gcvPOWER_IDLE: + /* Clock control, put to ON state. */ + gcmkONERROR(_PmClockControl(Hardware, gcvPOWER_ON)); + + break; + + default: + break; + } + + return gcvSTATUS_OK; + +OnError: + if (clockOn) + { + _QchannelForcePowerOff(command, Hardware); + } + + return status; +} + + +static gceSTATUS +_QchannelPowerOffDirection( + IN gckHARDWARE Hardware, + IN gceCHIPPOWERSTATE State, + IN gctBOOL Broadcast + ) +{ + gceSTATUS status; + gckCOMMAND command = Hardware->kernel->command; + + switch (Hardware->chipPowerState) + { + case gcvPOWER_ON: + if (Hardware->kernel->threadInitialized == gcvTRUE) + { + /* Stall. */ + status = _PmStallCommand(Hardware, command, Broadcast); + + if (!gcmIS_SUCCESS(status)) + { + /* abort for error and NOT READY. */ + goto OnError; + } + } + + if (State == gcvPOWER_IDLE) + { + gcmkONERROR(_PmClockControl(Hardware, gcvPOWER_IDLE)); + break; + } + /* FALLTHRU */ + + case gcvPOWER_IDLE: + case gcvPOWER_SUSPEND: + if (Hardware->kernel->threadInitialized == gcvTRUE) + { + /* Flush. */ + gcmkONERROR(_FlushCache(Hardware, command)); + + /* Stop the command parser and trigger Qchannel power off. */ + gcmkONERROR(gckCOMMAND_Stop(command)); + } + + /* Clock control, put to off state. */ + gcmkONERROR(_PmClockControl(Hardware, gcvPOWER_OFF)); + + break; + + default: + break; + } + + return gcvSTATUS_OK; + +OnError: + return status; +} /******************************************************************************* ** ** gckHARDWARE_SetPowerState @@ -8550,12 +8864,26 @@ gckHARDWARE_SetPowerState( if (Hardware->chipPowerState < state) { /* On to off direction. */ - gcmkONERROR(_PmSetPowerOffDirection(Hardware, state, broadcast)); + if (Hardware->hasQchannel) + { + gcmkONERROR(_QchannelPowerOffDirection(Hardware, state, broadcast)); + } + else + { + gcmkONERROR(_PmSetPowerOffDirection(Hardware, state, broadcast)); + } } else { /* Off to on direction. */ - gcmkONERROR(_PmSetPowerOnDirection(Hardware, state)); + if (Hardware->hasQchannel) + { + gcmkONERROR(_QchannelPowerOnDirection(Hardware, state)); + } + else + { + gcmkONERROR(_PmSetPowerOnDirection(Hardware, state)); + } } if (status == gcvSTATUS_CHIP_NOT_READY) @@ -8618,8 +8946,14 @@ gckHARDWARE_SetPowerState( /* Delayed power off. */ Hardware->nextPowerState = gcvPOWER_OFF_TIMEOUT; + if (Hardware->powerTimeout > 0) + { + gcmkVERIFY_OK(gckOS_StartTimer(os, Hardware->powerStateTimer, Hardware->powerTimeout)); + } + else { /* Start a timer to power off GPU when GPU enters IDLE or SUSPEND. */ - gcmkVERIFY_OK(gckOS_StartTimer(os, Hardware->powerStateTimer, gcdPOWEROFF_TIMEOUT)); + gcmkVERIFY_OK(gckOS_StartTimer(os, Hardware->powerStateTimer, gcdPOWEROFF_TIMEOUT)); + } } #endif @@ -11507,7 +11841,7 @@ _ResetGPU( 0x00104, 0x00000000)); - control = ((((gctUINT32) (0x01590880)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + control = ((((gctUINT32) (0x015B0880)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 17:17) - (0 ? 17:17) + 1) == 32) ? ~0U : (~(~0U << ((1 ? @@ -11617,6 +11951,24 @@ _ResetGPU( ~0U : (~(~0U << ((1 ? 12:12) - (0 ? 12:12) + 1))))))) << (0 ? 12:12))))); } + if (Hardware->hasQchannel) + { + /* Reset Qchannel. */ + gcmkONERROR(gckOS_WriteRegisterEx(Os, + Core, + 0x005E8, + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 2:2) - (0 ? + 2:2) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 2:2) - (0 ? + 2:2) + 1))))))) << (0 ? + 2:2))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 2:2) - (0 ? + 2:2) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 2:2) - (0 ? 2:2) + 1))))))) << (0 ? 2:2))))); + } + #if gcdFPGA_BUILD /* Wait more time on FPGA for reset as lower frequency */ gcmkONERROR(gckOS_Delay(Os, 10)); @@ -11639,6 +11991,30 @@ _ResetGPU( 12:12) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 12:12) - (0 ? 12:12) + 1))))))) << (0 ? 12:12))))); + if (Hardware->hasQchannel) + { + /* Reset Qchannel reset. */ + gcmkONERROR(gckOS_WriteRegisterEx(Os, + Core, + 0x005E8, + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 2:2) - (0 ? + 2:2) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 2:2) - (0 ? + 2:2) + 1))))))) << (0 ? + 2:2))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 2:2) - (0 ? + 2:2) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 2:2) - (0 ? 2:2) + 1))))))) << (0 ? 2:2))))); + + /* Bypass Qchannel power management after reset. */ + if (!Hardware->options.powerManagement) + { + gcmkONERROR(gckHARDWARE_QchannelBypass(Hardware, gcvTRUE)); + } + } + /* Reset GPU isolation. */ control = ((((gctUINT32) (control)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 19:19) - (0 ? @@ -12444,6 +12820,7 @@ gckHARDWARE_DumpGPUState( DIR_INDEX = 17, PPA_INDEX = 18, NN_INDEX = 19, + QC_INDEX = 20, MODULE_MAX_INDEX, }; @@ -12470,6 +12847,7 @@ gckHARDWARE_DumpGPUState( { "DIR", 0xF0, 24, 0xF8, 256, 0x1, 0x00, gcvFALSE, gcvTRUE }, { "PPA", 0x474, 0, 0x598, 256, 0x1, 0x00, gcvFALSE, gcvTRUE }, { "NN", 0x474, 24, 0x44C, 256, 0x2, 0x00, gcvFALSE, gcvTRUE }, + { "QC", 0x5E8, 3, 0x590, 256, 0x1, 0x00, gcvFALSE, gcvFALSE }, }; @@ -12621,6 +12999,12 @@ gckHARDWARE_DumpGPUState( { _dbgRegs[TPG_INDEX].avail = gcvTRUE; } + + if (Hardware->hasQchannel) + { + _dbgRegs[QC_INDEX].avail = gcvTRUE; + } + if (multiCluster) { _dbgRegs[WD_INDEX].avail = gcvTRUE; @@ -13469,7 +13853,7 @@ gckHARDWARE_ExecuteFunctions( { gceSTATUS status; gctUINT32 idle; - gctUINT32 timer = 0, delay = 1; + gctUINT32 i, timer = 0, delay = 1; gctUINT32 address; gckHARDWARE hardware = (gckHARDWARE)Execution->hardware; @@ -13477,68 +13861,83 @@ gckHARDWARE_ExecuteFunctions( return gcvSTATUS_OK; #endif - address = Execution->address; +#if gcdDUMP_IN_KERNEL + gcmkDUMP(hardware->os, "#[function: %s]", Execution->funcName); +#endif - /* Execute prepared command sequence. */ - if (hardware->mcFE) - { - gcmkONERROR(gckMCFE_Execute(hardware, gcvFALSE, 0, address, Execution->bytes)); - } - else + for (i = 0; i < Execution->funcCmdCount; i++) { - gcmkONERROR(gckWLFE_Execute(hardware, address, Execution->bytes)); - } + address = Execution->funcCmd[i].address; + + /* Execute prepared command sequence. */ + if (hardware->mcFE) + { + gcmkONERROR(gckMCFE_Execute(hardware, gcvFALSE, 0, address, Execution->funcCmd[i].bytes)); + } + else + { + gcmkONERROR(gckWLFE_Execute(hardware, address, Execution->funcCmd[i].bytes)); + } #if gcdLINK_QUEUE_SIZE - { - gcuQUEUEDATA data; + { + gcuQUEUEDATA data; - gcmkVERIFY_OK(gckOS_GetProcessID(&data.linkData.pid)); + gcmkVERIFY_OK(gckOS_GetProcessID(&data.linkData.pid)); - data.linkData.start = address; - data.linkData.end = address + Execution->bytes; - data.linkData.linkLow = 0; - data.linkData.linkHigh = 0; + data.linkData.start = address; + data.linkData.end = address + Execution->funcCmd[i].bytes; + data.linkData.linkLow = 0; + data.linkData.linkHigh = 0; - gckQUEUE_Enqueue(&hardware->linkQueue, &data); - } + gckQUEUE_Enqueue(&hardware->linkQueue, &data); + } #endif - gckFUNCTION_Dump(Execution); +#if gcdDUMP_IN_KERNEL + gcmkDUMP_BUFFER( + hardware->os, + gcvDUMP_BUFFER_KERNEL_COMMAND, + Execution->funcCmd[i].logical, + Execution->funcCmd[i].address, + Execution->funcCmd[i].bytes + ); +#endif - /* Wait until GPU idle. */ - do - { - gckOS_Delay(hardware->os, delay); + /* Wait until GPU idle. */ + do + { + gckOS_Delay(hardware->os, delay); - gcmkONERROR(gckOS_ReadRegisterEx( - hardware->os, - hardware->core, - 0x00004, - &idle)); + gcmkONERROR(gckOS_ReadRegisterEx( + hardware->os, + hardware->core, + 0x00004, + &idle)); - timer += delay; - delay *= 2; + timer += delay; + delay *= 2; #if gcdGPU_TIMEOUT - if (timer >= hardware->kernel->timeOut) - { - gckHARDWARE_DumpGPUState(hardware); - - if (hardware->kernel->command) + if (timer >= hardware->kernel->timeOut) { - gckCOMMAND_DumpExecutingBuffer(hardware->kernel->command); - } + gckHARDWARE_DumpGPUState(hardware); - /* Even if hardware is not reset correctly, let software - ** continue to avoid software stuck. Software will timeout again - ** and try to recover GPU in next timeout. - */ - gcmkONERROR(gcvSTATUS_DEVICE); - } + if (hardware->kernel->command) + { + gckCOMMAND_DumpExecutingBuffer(hardware->kernel->command); + } + + /* Even if hardware is not reset correctly, let software + ** continue to avoid software stuck. Software will timeout again + ** and try to recover GPU in next timeout. + */ + gcmkONERROR(gcvSTATUS_DEVICE); + } #endif + } + while (!_IsGPUIdle(idle)); } - while (!_IsGPUIdle(idle)); return gcvSTATUS_OK; diff --git a/drivers/amlogic/npu/kernel/arch/gc_hal_kernel_hardware.h b/drivers/amlogic/npu/kernel/arch/gc_hal_kernel_hardware.h index 83dfd6d..3c3279a 100644 --- a/drivers/amlogic/npu/kernel/arch/gc_hal_kernel_hardware.h +++ b/drivers/amlogic/npu/kernel/arch/gc_hal_kernel_hardware.h @@ -232,6 +232,10 @@ struct _gckHARDWARE gcsHARDWARE_PAGETABLE_ARRAY pagetableArray; gctUINT64 contextID; + + gctUINT32 powerTimeout; + + gctBOOL hasQchannel; }; gceSTATUS diff --git a/drivers/amlogic/npu/kernel/arch/gc_hal_kernel_hardware_func.c b/drivers/amlogic/npu/kernel/arch/gc_hal_kernel_hardware_func.c index 54a7908..1c50958 100644 --- a/drivers/amlogic/npu/kernel/arch/gc_hal_kernel_hardware_func.c +++ b/drivers/amlogic/npu/kernel/arch/gc_hal_kernel_hardware_func.c @@ -57,4303 +57,1072 @@ #include "gc_hal_kernel.h" #include "gc_hal_kernel_hardware.h" - +#if gcdFLOP_RESET +#include "gc_hal_kernel_hardware_func_flop_reset.h" +#else #if gcdINITIALIZE_PPU +#if !gcdINITIALIZE_PPU_C static gctUINT32 ppuMem0[] = { - 0x00010000, + 0x00010000 }; static gctUINT32 ppuMem1[] = { - 0x00010000, + 0x00010000 }; static gctUINT32 ppuMem2[] = { - 0x38011039, - 0x39200804, - 0xC0A90050, - 0x74000008, - 0x38021039, - 0x39202804, - 0xC0A90050, - 0x74000008, - 0x38031039, - 0x39204804, - 0xC0A90050, - 0x74000008, - 0xB8017005, - 0x002018FC, - 0x01C900C0, - 0x40390098, - 0xB8027005, - 0x002028FC, - 0x01C90140, - 0x40390098, - 0xB8037005, - 0x002038FC, - 0x01C901C0, - 0x40390098, - 0x04041036, - 0x00000804, - 0x4000047A, - 0x00000002, - 0x0400100C, - 0x3FC04804, - 0x40AB0440, - 0x2000007A, - 0x38000835, - 0x39207804, - 0x41E80050, - 0x00390018, - 0x04041036, - 0x00001804, - 0x4000047A, - 0x00000002, - 0x0400100C, - 0x3FC04804, - 0x40AB0440, - 0x2000007A, - 0x38000835, - 0x39207804, - 0x41E80050, - 0x00390028, - 0x04041036, - 0x00002804, - 0x4000047A, - 0x00000002, - 0x0400100C, - 0x3FC04804, - 0x40AB0440, - 0x2000007A, - 0x38000835, - 0x39207804, - 0x41E80050, - 0x00390038, + 0x38011039, 0x39200804, 0xC0A90050, 0x74000008, 0x38021039, 0x39202804, 0xC0A90050, 0x74000008, + 0x38031039, 0x39204804, 0xC0A90050, 0x74000008, 0xB8017005, 0x002018FC, 0x01C900C0, 0x40390098, + 0xB8027005, 0x002028FC, 0x01C90140, 0x40390098, 0xB8037005, 0x002038FC, 0x01C901C0, 0x40390098, + 0x04041036, 0x00000804, 0x4000047A, 0x00000002, 0x0400100C, 0x3FC04804, 0x40AB0440, 0x2000007A, + 0x38000835, 0x39207804, 0x41E80050, 0x00390018, 0x04041036, 0x00001804, 0x4000047A, 0x00000002, + 0x0400100C, 0x3FC04804, 0x40AB0440, 0x2000007A, 0x38000835, 0x39207804, 0x41E80050, 0x00390028, + 0x04041036, 0x00002804, 0x4000047A, 0x00000002, 0x0400100C, 0x3FC04804, 0x40AB0440, 0x2000007A, + 0x38000835, 0x39207804, 0x41E80050, 0x00390038 }; static gctUINT32 ppuMem3[] = { - 0x07841009, - 0x00200004, - 0xC0000000, - 0x200000D8, - 0xB8019005, - 0x0020D81C, - 0xC00106D0, - 0x0039004A, - 0x38011039, - 0x39200804, - 0xC0A90050, - 0x74000008, - 0xB8029005, - 0x0020D81C, - 0xC00106D0, - 0x0039004A, - 0x38021039, - 0x39202804, - 0xC0A90050, - 0x74000008, - 0xB8039005, - 0x0020D81C, - 0xC00106D0, - 0x0039004A, - 0x38031039, - 0x39204804, - 0xC0A90050, - 0x74000008, - 0xB8017005, - 0x002018FC, - 0x01C900C0, - 0x40390098, - 0xB8027005, - 0x002028FC, - 0x01C90140, - 0x40390098, - 0xB8037005, - 0x002038FC, - 0x01C901C0, - 0x40390098, - 0x04041036, - 0x00000804, - 0x4000047A, + 0x7E7E7E7E, 0x797B7E7F, 0x79797879, 0x7D7C7B7A, 0x80818181, 0x7B7C7D7F, 0x83817C79, 0x7C7D8082, + 0x7C7C7D7D, 0x7D7D7C7C, 0x81818181, 0x7D7D7F80, 0x73777E83, 0x71717171, 0x7E7A7574, 0x8A888782, + 0x7475797B, 0x8D888078, 0x8F92918F, 0x787B8189, 0x908E8781, 0x787B838C, 0x7A767576, 0x85868581, + 0x817F8185, 0x87838181, 0x8182878D, 0x787C8181, 0x807A787A, 0x8B878483, 0x8D8A8787, 0x8885878D, + 0x817E7D7D, 0x81828483, 0x7C7D7D7E, 0x69686D76, 0x6E6D6C6C, 0x70727271, 0x74727172, 0x74757675, + 0x6F6E7072, 0x70717170, 0x6E6E7073, 0x78767471, 0x7A77726F, 0x84817F7C, 0x93949596, 0x8D8D9092, + 0x8F8F8D88, 0xB3A79991, 0xABB4BABD, 0x8D9199A2, 0x77737274, 0x676F787A, 0x78716862, 0x7577797A, + 0x74747474, 0x78777675, 0x78797A7A, 0x74747576, 0x817C7977, 0x82848685, 0x787A7D80, 0x8886807A, + 0x79858D91, 0x6D6A696E, 0x676D7471, 0x5659646A, 0x3E3B3F45, 0x44484A46, 0x675B504A, 0x82807A72, + 0x71777C80, 0x6868696C, 0x716E6D6B, 0x7F7B7773, 0x87909391, 0x908F8A85, 0x9596938F, 0x89898C91, + 0x89878584, 0x92908E8C, 0x99999693, 0x7B818993, 0x7A818582, 0x928B8078, 0x928A8D97, 0xA5968F93, + 0x939DA5AB, 0x8F8D8A8C, 0x8D8B8A8C, 0x85878B8D, 0x7C7D8082, 0x7F807F7E, 0x85858382, 0x787B7F83, + 0x72717475, 0x9B928378, 0x9EB4B6AB, 0x8C898589, 0x998F8A8E, 0x686D7E93, 0x6A6A6865, 0x65646568, + 0x64676868, 0x60616162, 0x7A7A7268, 0x72767878, 0x6C717577, 0x716A6466, 0x7D7E7B78, 0x7A777679, + 0x8484817F, 0x7A7E8183, 0x89807E84, 0x8080868D, 0x60505069, 0x7074857A, 0x968D7A69, 0x8E8C8D93, + 0x6D6D7A8D, 0x8A7E7470, 0x7C7D7F80, 0x7A7A7A7B, 0x7A7A7C7C, 0x74757678, 0x7C7A7775, 0x75777A7C, + 0x7A7A7978, 0x7A7A7A7A, 0x81817C7A, 0x7D7E7F81, 0x8D898581, 0x8185898D, 0x7374787B, 0x79797674, + 0x797A7A7B, 0x79797878, 0x807F7D7C, 0x7D7E7F80, 0x78797A7A, 0x79797878, 0x77787878, 0x76767677, + 0x77777778, 0x76767676, 0x78767574, 0x7F7E7C7A, 0x797B7D7F, 0x76767677, 0x807E7C7A, 0x82828181, + 0x7C7F8183, 0x7979797A, 0x84807B79, 0x8E8D8C88, 0x88888888, 0x86878788, 0x82818384, 0x85868684, + 0x87878787, 0x87878786, 0x767B8185, 0x72717173, 0x7F818282, 0x76787A7C, 0x76767676, 0x74747576, + 0x78736E6A, 0x77787A7A, 0x78757474, 0x85827F7B, 0x8D8E8D8D, 0x8184878C, 0x87837F7C, 0x82848788, + 0x80818182, 0x7E7E7F7F, 0x8985817E, 0x8C8C8D8C, 0x8B8A8A8B, 0x7A80878B, 0x86817D7B, 0x8D8D8C89, + 0x87888785, 0x82828386, 0x89848181, 0x9293938F, 0x8D8D8F92, 0x868A8E8F, 0x89837F7C, 0x8C8E8F8D, + 0x78808689, 0x63666A71, 0x5F5C5F63, 0x73726E67, 0x75727274, 0x68696E74, 0x6C6B6C6B, 0x83837D73, + 0x686B7074, 0x807A716A, 0x81828180, 0x676C747C, 0x68626060, 0x7D7C7A72, 0x7074787A, 0x7F79716E, + 0x6E6A7585, 0x686E7474, 0x5C646665, 0x4F4C4C52, 0x63615A53, 0x786F6763, 0x7A7F8385, 0x77757475, + 0x6B6E7171, 0x65646467, 0x6662605F, 0x736E6A68, 0x79797877, 0x74757779, 0x78747170, 0x7B7D7D7B, + 0x7F7B7B7E, 0x7C818483, 0x8B878585, 0x92939491, 0x99949190, 0x90959B9D, 0x6C717E8A, 0x7E7D7870, + 0x81828282, 0x84828080, 0x71727C87, 0x7D7A7774, 0x676F7E88, 0x837B7068, 0x84888A8B, 0x7A7A7C80, + 0x76747373, 0x76787979, 0x6E6E7072, 0x87817A73, 0x8385878A, 0x797B8082, 0x8989837D, 0x7E7C7D83, + 0x817B7A7B, 0x757F8788, 0x6F727476, 0x6D6D6D6E, 0x707A7A75, 0x62626368, 0x62636566, 0x67656362, + 0x6E6E6E6E, 0x7E78726E, 0x817F7E7D, 0x908D8A86, 0x82818488, 0x8A8C8B87, 0x8184878A, 0x807F7E7F, + 0x84858787, 0x767A7F82, 0x6C6C6C6C, 0x7674716E, 0x76787A7A, 0x70717274, 0x6E6D6E70, 0x7D7B7772, + 0x807B7A78, 0x878D8E87, 0x79828989, 0x74777774, 0x4E545E67, 0x6B645A50, 0x8A796C68, 0x63718490, + 0x7068615C, 0x74747675, 0x7C787471, 0x82828180, 0x7A7B7B7B, 0x74757779, 0x858B877E, 0x7B747077, + 0x6F717980, 0x74767572, 0x6E6F6F6F, 0x696A6B6D, 0x565C6060, 0x605F5A55, 0x5F5F5E5D, 0x66646160, + 0x736E6A68, 0x7C7F7E7A, 0x75757879, 0x79797877, 0x71717375, 0x6C6E7273, 0x6D6B6A69, 0x71706F6E, + 0x66686A6B, 0x61616263, 0x7F7F7365, 0x61697379, 0x6B67625D, 0x69696B6C, 0x7776716B, 0x75737274, + 0x6E788082, 0x6F696365, 0x6E6F7172, 0x6E6D6B6B, 0x74625E6F, 0x74767679, 0x77787979, 0x7F7B7876, + 0x7C7D7D7C, 0x6E71757A, 0x63626262, 0x6C6A6865, 0x7C827C72, 0x76747173, 0x74706F6F, 0x74777A78, + 0x6A6F7274, 0x56595E64, 0x615E775C, 0x61625E6E, 0x694F8559, 0x13285176, 0x1910261C, 0x16201313, + 0x29191017, 0x567B8219, 0x836E967A, 0x6B6C7087, 0x726C6862, 0x71827477, 0x10171091, 0x13252F10, + 0x1010171C, 0x17101923, 0x60847A58, 0x66735684, 0x6E6A6868, 0x79777471, 0x5C747B77, 0x5676866C, + 0x5C67616B, 0x102D1F14, 0x67251028, 0x955B7689, 0x8A8B8B8C, 0x8989898A, 0x936E9489, 0x79778177, + 0x102A6A6E, 0x10151310, 0x1E131214, 0x13131F1D, 0x817C8D8B, 0x71706368, 0x696E7479, 0x7A746E69, + 0x7D807E7C, 0x73737478, 0x79797572, 0x60646C74, 0x7870596B, 0x7B8D9A93, 0x777A7274, 0x105F6880, + 0x10181829, 0x78604720, 0x65696D6E, 0x56585C60, 0x8D685B55, 0x8E78A599, 0x21107F71, 0x1024102F, + 0x10101B2D, 0x13251618, 0x634F5C16, 0x44567A3C, 0x5B565350, 0x5D5D5D5C, 0x5E5C5C5C, 0x69686461, + 0x73716F6E, 0x7A797775, 0x56677099, 0x465D624C, 0x1F134859, 0x10191910, 0x10101010, 0x10101010, + 0x71939610, 0x8F574661, 0x7A7C7B7A, 0x7B797778, 0x6068886D, 0x705F7971, 0x18101925, 0x1F10101D, + 0x1B1A1F10, 0x6C4C1F13, 0x6866686A, 0x5D545A6B, 0x5A5A5959, 0x57585959, 0x6C625953, 0x6D6F7171, + 0x44586863, 0x4C4E3C58, 0x101F2613, 0x101D1110, 0x161F1019, 0x4F191310, 0x6056617B, 0x4A505F6C, + 0x855B3E60, 0x3F4A3E78, 0x107A3849, 0x1B101A27, 0x1910101A, 0x102B101F, 0x5E6F1112, 0x67626263, + 0x65625E5C, 0x5F626466, 0x7A808588, 0x4A556472, 0x66629274, 0x4E464873, 0x6E673E56, 0x102F6E57, + 0x1B101810, 0x13131C19, 0x101E1019, 0x35685021, 0x75676D6E, 0x5981667E, 0x463E4E4F, 0x105C6350, + 0x19111822, 0x21101E10, 0x21232323, 0x18191A1E, 0x1D101E12, 0x674E4810, 0x66747368, 0x7C6E5D59, + 0x6B6B6A6A, 0x6F6E6B6A, 0x7F80776E, 0x74707077, 0x51107274, 0x10171E18, 0x19191919, 0x19191919, + 0x191B1C1C, 0x17171819, 0x646A6268, 0x6A726C74, 0x73637362, 0x32485C51, 0x2E1A1017, 0x1F131023, + 0x2A103114, 0x564A121C, 0x4C45374F, 0x35425A64, 0x6D614E40, 0x4550606C, 0x3D454B50, 0x282A2F35, + 0x7B797979, 0x7D7F807E, 0x7B7B7B7B, 0x7F7E7D7C, 0x80808180, 0x7B7C7E7F, 0x83817C79, 0x7E7F8182, + 0x7A7A7A7B, 0x7B7A7A7A, 0x817F7D7C, 0x83838281, 0x777D7E7A, 0x7B746E6E, 0x807F7E7D, 0x83838281, + 0x7A7A7D7F, 0x918D857E, 0x9192918F, 0x7D81868D, 0x8D8D8883, 0x75798088, 0x837D7977, 0x8A8C8D89, + 0x84828285, 0x87838183, 0x7E81878D, 0x81838280, 0x8B878481, 0x9393928F, 0x8F939595, 0x8787898C, + 0x82808080, 0x83848684, 0x82828283, 0x6E6E737C, 0x6F6E6E6E, 0x72737371, 0x75737272, 0x7A7A7A79, + 0x72737476, 0x70727373, 0x6D6C6E71, 0x7877746F, 0x6F717475, 0x8C847A72, 0x8E8F9090, 0x87888A8C, + 0x8A87837F, 0xB1A5968D, 0xA4ABB1B4, 0x878C939B, 0x78757578, 0x6870787A, 0x837A6E66, 0x8B8B8B89, + 0x74747575, 0x79787675, 0x78797A7A, 0x76767777, 0x817D7B7A, 0x7E818383, 0x77747476, 0x8C89847D, + 0x74818C91, 0x6C68666A, 0x6D70726A, 0x5C5E666C, 0x564A494C, 0x6A707168, 0x746E6866, 0x81817D79, + 0x787B7E80, 0x6E6F7174, 0x7473706E, 0x7F7B7875, 0x878D8D8A, 0x8D8D8985, 0x99988F87, 0x797D8591, + 0x85817E7C, 0x93918D8A, 0x98999894, 0x7A7F8791, 0x70747472, 0x938B7D72, 0x8D888C96, 0x9C8F888D, + 0x979C9FA1, 0x8E8D8E91, 0x8D8C8C8D, 0x87898C8E, 0x7A7B7F82, 0x8482807C, 0x8181807E, 0x74767B80, + 0x72727374, 0x84817B75, 0x949F9988, 0x8D8B8687, 0x938D898C, 0x74717A8B, 0x6B6D7074, 0x65676869, + 0x68686765, 0x5B5C6064, 0x787A746A, 0x78787474, 0x787B7B7B, 0x7C777374, 0x84858381, 0x807E7E81, + 0x8483817E, 0x7C7F8283, 0x877E7B7D, 0x787E878B, 0x524F4B5A, 0x6661685E, 0x948D7A6B, 0x8D8B8C91, + 0x6E6A788C, 0x7F7C7A77, 0x7B7C7D7E, 0x7B7B7B7B, 0x7B7C7E7E, 0x7777787A, 0x74747576, 0x76757474, + 0x7A797878, 0x7A7A7A7A, 0x807E7A78, 0x7B7C7D7F, 0x87868381, 0x81838687, 0x7374797D, 0x7A7A7774, + 0x7B7C7D7D, 0x7A7A7A7B, 0x7F7E7D7D, 0x7C7C7E7F, 0x78797A7A, 0x78787878, 0x77787878, 0x76767677, + 0x74747575, 0x74747474, 0x77747473, 0x7D7C7A79, 0x787A7B7C, 0x77767677, 0x7D7D7D7C, 0x81807E7D, + 0x80818283, 0x7B7B7C7E, 0x8683817F, 0x8B8B8A88, 0x88888787, 0x85868787, 0x81818183, 0x85868684, + 0x86878787, 0x85858585, 0x787C8082, 0x75747475, 0x7F7F7F7F, 0x7C7D7E7F, 0x7F7F7E7E, 0x7C7C7E7F, + 0x7A797472, 0x7375797B, 0x7A787675, 0x8583817D, 0x8B8C8C8B, 0x7F818588, 0x87837E7B, 0x81848788, + 0x7E808181, 0x81807F7E, 0x8784817E, 0x8B8C8B8A, 0x8A8A8A8B, 0x7A7F8689, 0x85817E7C, 0x89898887, + 0x8184888B, 0x87868281, 0x88858281, 0x8D8D8D8B, 0x8B8B8C8D, 0x86888C8D, 0x87838180, 0x83868989, + 0x797E8285, 0x6C6E6F74, 0x5F5C6064, 0x73726E66, 0x76757475, 0x62636973, 0x6E696763, 0x8A8A8378, + 0x646E7A82, 0x79726862, 0x787A7978, 0x5E636B74, 0x615B5A5C, 0x7273726B, 0x7C7C7A78, 0x817E7B7B, + 0x6D6A7584, 0x686C7172, 0x61636668, 0x5053585D, 0x605B5047, 0x776F6662, 0x7F7F7C7A, 0x75777A7D, + 0x6B6E6F6E, 0x65646568, 0x68666564, 0x736F6B68, 0x7A797876, 0x7B7C7C7B, 0x70707375, 0x7A797673, + 0x7F7A7B7E, 0x7E838785, 0x8B878585, 0x9092928F, 0x99939190, 0x8E949A9C, 0x72757D85, 0x807F7C76, + 0x81807F7F, 0x86868482, 0x70717B87, 0x7A787573, 0x6C717B83, 0x8A83796F, 0x85898C8D, 0x7A7A7D81, + 0x74747677, 0x6F727474, 0x6E6C6E6F, 0x89847A73, 0x82848789, 0x787A7E81, 0x83817A73, 0x7A7A7A80, + 0x817A7979, 0x77808788, 0x70737475, 0x6D6D6E6E, 0x6E777773, 0x62626266, 0x5F606262, 0x63626160, + 0x6B6B6B6A, 0x817A726D, 0x797B8185, 0x8D88817B, 0x81818589, 0x8E8E8C87, 0x8286898C, 0x81818181, + 0x80818284, 0x73767B7F, 0x6C6B6C6C, 0x7574716E, 0x7678797A, 0x71727374, 0x6A6A6D6F, 0x7A78746E, + 0x7877797A, 0x8B8E8B81, 0x7A818685, 0x777A7A77, 0x4C505A62, 0x6F695D52, 0x87786D69, 0x6571838D, + 0x746F6761, 0x74747677, 0x7A777473, 0x7A7B7B7B, 0x77767575, 0x7A7A7A79, 0x868B8781, 0x7E79767C, + 0x6F71797F, 0x74757572, 0x6E6F7070, 0x696A6B6D, 0x545E6363, 0x53514F4E, 0x5E5D5C5A, 0x5D5D5D5E, + 0x6A64615F, 0x777B7B74, 0x6C6E7174, 0x696B6D6D, 0x6C6A6C6E, 0x6C6E6F6E, 0x6A686868, 0x6E6E6D6C, + 0x696C6E6E, 0x64646668, 0x7B7B7165, 0x61687076, 0x6A67625D, 0x62646769, 0x716C655F, 0x76747373, + 0x71797C7D, 0x6D69676A, 0x7072716F, 0x6F6E6C6E, 0x74625D6E, 0x76787779, 0x77767676, 0x79797877, + 0x7A7B7C7C, 0x6F727478, 0x71706F6F, 0x79787573, 0x7B7A7977, 0x6D6F7479, 0x6E6E7072, 0x7875726F, + 0x6D717475, 0x5B5D6268, 0x615C6759, 0x61685E6E, 0x7A7D5C44, 0xD6144E6D, 0xDDE5E2EB, 0xE4EBEBEB, + 0xEBDCE3EB, 0x8F6E73DD, 0x64518573, 0x6766626E, 0x6E676260, 0x74887C71, 0xE7DD3B61, 0xE7E9CCEB, + 0xDCE1EBEB, 0xEBDEDCE2, 0x606F8774, 0x6371687F, 0x6D6A6868, 0x7674726F, 0x80817C79, 0x61748786, + 0x78635A4E, 0xEBE5D014, 0x86C8E5E7, 0x6E748F7B, 0x77777778, 0x75757676, 0x7E647F74, 0x7470656D, + 0xE1444A68, 0xE9CED7EB, 0xE6DDDDDD, 0xE7EAE9E8, 0x874A7282, 0x9F7E876E, 0x696E7478, 0x79746E69, + 0x7C808180, 0x6E6E7076, 0x6B6E6E6F, 0x5E606267, 0x5F5C646D, 0x6E76716E, 0x73796A73, 0x17496762, + 0xDEEBDFE4, 0x899AC9D7, 0x6267696B, 0x56575A5E, 0x6B5C656F, 0x83687A6F, 0xD31A7483, 0xEAD3E5E7, + 0xEBEBDEE0, 0xEBE4EBDF, 0x692F63E8, 0x534A584E, 0x58565554, 0x5C5C5B5A, 0x5E5C5C5C, 0x65646260, + 0x6B696868, 0x70706E6D, 0x7A707474, 0x4E4A543B, 0xC41B564C, 0xE9E5EBC4, 0xE8E8E8E8, 0xE8E8E8E8, + 0x8F556FEB, 0x6E7A7593, 0x5B5F6E7B, 0x61646560, 0x4A727E51, 0x6B54585E, 0xE1EBD52E, 0xE4EBE7E8, + 0xE6E8EBEA, 0x6668E6EB, 0x4E5D5E4F, 0x6E6C5F4F, 0x53535252, 0x53535454, 0x635C5653, 0x67686867, + 0x375B6352, 0x44505A4F, 0xEBE2D820, 0xEAE6D6CC, 0xDCE8E5E8, 0x6FE8E2EB, 0x45556166, 0x43504E43, + 0x495A525A, 0x4E4D4276, 0x2B446056, 0xD0EBEBDC, 0xDCE4EBD1, 0xEBE2D2EB, 0x438CE3D5, 0x60626E6E, + 0x625E5956, 0x5D606264, 0x74736F6C, 0x5E626970, 0x6E6C8561, 0x4A4B496C, 0x7A63582A, 0xE929566C, + 0xDDD9EBE9, 0xE2EBE2EB, 0xE7DEDBEB, 0x785A54DC, 0x7B74715E, 0x687B5673, 0x443E5154, 0x1462654E, + 0xEBE3E3E4, 0xEBE3EBE7, 0xE2E3E3E3, 0xDFDFE0E1, 0xE8E0E9E2, 0x636C60C8, 0x727B786E, 0x7C746867, + 0x58575D62, 0x7D776C60, 0x7C7C746D, 0x6B6B6E75, 0xD0347668, 0xEBEBE4CA, 0xE9E9E9E9, 0xE9E9E9E9, + 0xE9E9E9E9, 0xE8E8E8E8, 0x5B5D5756, 0x61646062, 0x50485064, 0x104D4946, 0xDFE9EAE8, 0xEBEBEADB, + 0xD7EADEEB, 0x4876D4E3, 0x5B4E4958, 0x3F4B616D, 0x6960534A, 0x4E56626A, 0x3F474D50, 0x2C2E3238, + 0x79747372, 0x8483817E, 0x7F808181, 0x807F7F7F, 0x80818080, 0x7D7E7F80, 0x82817C79, 0x80808182, + 0x77777878, 0x78787777, 0x817C7A77, 0x8B8A8785, 0x7A817C74, 0x877A6D6F, 0x82858789, 0x7C7D7E81, + 0x81818284, 0x95918A84, 0x93928F8D, 0x87898E92, 0x8A8D8C89, 0x75787D84, 0x938A8380, 0x999B9C99, + 0x898A8A8B, 0x89848286, 0x7E81888F, 0x8C8A8681, 0x9699958F, 0x999E9E98, 0x8F9B9F9D, 0x84888A89, + 0x83828283, 0x87878786, 0x8A8A8989, 0x74747A84, 0x706E6F71, 0x74747472, 0x79747373, 0x8383817D, + 0x787A7C7F, 0x6F727476, 0x68686B6E, 0x7876726D, 0x686D747A, 0x9387776B, 0x898B8B8C, 0x82848687, + 0x84837F7A, 0xA59A8D85, 0x999FA3A5, 0x83868C92, 0x7A797A7D, 0x6E747A7C, 0x8A837A73, 0x8A8B8D8D, + 0x74757778, 0x79787674, 0x78787878, 0x78787878, 0x817E7C7B, 0x7F818383, 0x7A777778, 0x8081817F, + 0x6B788287, 0x68635F62, 0x73757066, 0x65686C6E, 0x75656062, 0x8B929389, 0x7D7E8081, 0x7D7D7C7C, + 0x81818180, 0x76787B7F, 0x79787674, 0x7D7B7A79, 0x84868581, 0x8B8B8884, 0x8E938C83, 0x6C6D7481, + 0x817D7A78, 0x8D8C8885, 0x93949391, 0x8183878E, 0x6E6F706F, 0x8D898074, 0x8C898D96, 0x8D838188, + 0x9D9C9894, 0x8C8F9399, 0x8A898887, 0x8286898A, 0x787C8389, 0x7C7A7977, 0x7E7E7B7A, 0x6F73777C, + 0x78726F6F, 0x8182827F, 0x8F958E81, 0x8E8D8887, 0x8B8B8989, 0x7F787882, 0x6B6E757B, 0x6A6C6E6C, + 0x686A6867, 0x56585D63, 0x777A736A, 0x7D7A7473, 0x8686827F, 0x87868484, 0x88898887, 0x83838487, + 0x85838180, 0x7D7E8184, 0x81818180, 0x5E6C7B81, 0x49514A4C, 0x6259574A, 0x938D7E71, 0x8C8A8B8F, + 0x736A788D, 0x747C8481, 0x7A7A7B7B, 0x7D7C7B7B, 0x7D7E7F80, 0x797A7A7B, 0x6B6E7477, 0x77746E6B, + 0x79787777, 0x7979797A, 0x7E7C7975, 0x7A7A7A7C, 0x81818282, 0x82828181, 0x74767B80, 0x7D7B7975, + 0x80818181, 0x7C7C7E7F, 0x7E7E7D7D, 0x7A7B7C7D, 0x78797A7B, 0x76767677, 0x77777777, 0x76767676, + 0x71727272, 0x70707171, 0x7472706F, 0x7A797875, 0x77797A7A, 0x76767676, 0x7A7A7B7B, 0x7F7C7A78, + 0x84838382, 0x80818283, 0x87878685, 0x87878787, 0x87878786, 0x85858687, 0x81808181, 0x86878684, + 0x85868787, 0x82828384, 0x797A7C7D, 0x76767778, 0x7F7D7A7A, 0x84838281, 0x87878786, 0x84858787, + 0x80817F7E, 0x6E72787D, 0x7F7C7A79, 0x86858381, 0x86878787, 0x7A7C8083, 0x86817C79, 0x81838787, + 0x7E818284, 0x7D7C7C7C, 0x8581807E, 0x8A8A8887, 0x88888989, 0x7B7F8487, 0x8381807F, 0x83848484, + 0x7E7F8488, 0x81828280, 0x8784817E, 0x87878687, 0x87878786, 0x87878788, 0x87878686, 0x7A7E8387, + 0x777A7D7F, 0x75757475, 0x5F5E6266, 0x72706C65, 0x78797675, 0x5D5E6470, 0x6C65605C, 0x89898376, + 0x6874818A, 0x6E6A6462, 0x71716E6D, 0x5F63696E, 0x5A55575C, 0x61656863, 0x867F756E, 0x84868788, + 0x6E6E7884, 0x686C7071, 0x6865676B, 0x5761696C, 0x5C564A3E, 0x7068605C, 0x837F7872, 0x73767B81, + 0x6B6E6F6F, 0x65646568, 0x6F6F6E6E, 0x7573706F, 0x7E7A7775, 0x86858381, 0x686E787F, 0x7C78706A, + 0x8078797C, 0x878D8F8A, 0x8B878686, 0x8D8F8F8E, 0x96928F8E, 0x8B909799, 0x7A7A7D81, 0x82817F7C, + 0x84807E7F, 0x8D8E8E8A, 0x6F717A86, 0x79777473, 0x7474787C, 0x928D847A, 0x85898D8E, 0x7A7B7E81, + 0x6E717477, 0x68696C6E, 0x69656464, 0x89837A71, 0x8386888A, 0x787A7F81, 0x7C79716B, 0x7676787A, + 0x837C7979, 0x79808788, 0x72747677, 0x6B6C6E6F, 0x6C73736E, 0x62626263, 0x5C5D5E5F, 0x5F5E5C5C, + 0x62606060, 0x7D766D65, 0x6E72797E, 0x83807972, 0x7F7F8489, 0x918F8A84, 0x81848788, 0x81818080, + 0x7D7F8181, 0x7274797C, 0x6C6C6C6C, 0x7473706E, 0x76777878, 0x73747475, 0x66686C6F, 0x76746E69, + 0x77747575, 0x8A8D8B81, 0x83878786, 0x80828381, 0x5457626B, 0x6E6A6259, 0x83766E6E, 0x67718189, + 0x7A786F68, 0x75747579, 0x76767474, 0x72737476, 0x74716F6E, 0x83817D78, 0x878A8886, 0x82818183, + 0x6F71787E, 0x73747573, 0x6E6E6F70, 0x69696B6C, 0x525C6261, 0x4D4D4B4B, 0x5D5C5B59, 0x56585B5C, + 0x615A5858, 0x71797A6E, 0x6262676B, 0x5E626564, 0x625F6061, 0x6B6A6865, 0x6B696868, 0x6F6E6E6D, + 0x6E707172, 0x68686A6C, 0x76756E65, 0x62676D72, 0x6867625D, 0x5B5D6266, 0x6F69625E, 0x70727373, + 0x77797774, 0x6A6A6D71, 0x7576726E, 0x6F6E6E71, 0x73625D6B, 0x76787777, 0x75727272, 0x787A7B7A, + 0x78797A7A, 0x72737476, 0x78767676, 0x7E7D7B7A, 0x80787B85, 0x626B7A83, 0x6A6A6968, 0x7974706C, + 0x71747778, 0x6264686C, 0x6A645A5F, 0x50625B72, 0x58896E95, 0xE9162710, 0xE8E1EBEB, 0xE4EBE2E6, + 0xE1DFEBE2, 0x101028E7, 0x68454A10, 0x72625669, 0x7C776C6A, 0x5174806E, 0xD8D12810, 0xE8EBCAEB, + 0xE4EAEBDE, 0xEBE5E2D8, 0x87645811, 0x7363697C, 0x6B6A6969, 0x706F6E6C, 0x6E768768, 0x7A78928C, + 0x94726577, 0xEBD2E015, 0x5CD4EBE0, 0x6F8D9355, 0x6C6C6C6C, 0x6B6B6B6B, 0x797A7D63, 0x1F1C1050, + 0xD0121326, 0xEBEBEBE7, 0xE8EBEBEB, 0xE5EBDAE3, 0x552E2519, 0x8770725F, 0x676A7074, 0x74706A66, + 0x777B7D7D, 0x696A6D72, 0x5E646B6F, 0x615F5C5B, 0x6C5C6A5E, 0x82857A7A, 0x605F5B68, 0x3972666E, + 0xEAEBE5EA, 0x7A92D6E6, 0x5E626365, 0x5456575B, 0x7058504F, 0x7C727179, 0xE21B2B10, 0xEBD2E8E5, + 0xE0E8E6E8, 0xE5E5D0D7, 0x633438DA, 0x63505362, 0x56545454, 0x5C5B5957, 0x5D5C5C5B, 0x5F5F5F5E, + 0x61605F5E, 0x63636262, 0x8B636352, 0x635A6349, 0xDE103B15, 0xEBE4E4EB, 0xEBEBEBEB, 0xEBEBEBEB, + 0x1A132DCC, 0x70552812, 0x4E5C6D77, 0x7D6E594C, 0x146E8866, 0x1A101030, 0xD6E7E33E, 0xE8E2DEEB, + 0xEBE6DDCC, 0x1728D6EB, 0x5B52341A, 0x56443841, 0x4D4D4C4C, 0x504F4F4E, 0x56555353, 0x5E5D5C59, + 0x363F3B44, 0x1013665B, 0xEBEAE531, 0xEBE0E4E8, 0xE5E2EBEB, 0x32DDD6EB, 0x6256392C, 0x4B413844, + 0x394E525A, 0x5A4A4D70, 0x25191F2A, 0xE0EBEBDF, 0xE3E7EBE4, 0xEBE2E4EB, 0x1434CDEB, 0x6F7B7D53, + 0x645E5853, 0x5F626567, 0x716D635C, 0x6C6C6D70, 0x66686C4E, 0x5860505B, 0x78637D76, 0xDE2C1E15, + 0xE8E3EBE8, 0xE5E5E5E9, 0xEBEBEBE2, 0x10112DEB, 0x6F4D3510, 0x7A856379, 0x3E435E67, 0x10555642, + 0xEBEAEBEB, 0xE3E4E8EA, 0xE2E2E2E2, 0xE3E3E3E3, 0xE4DEE6EB, 0x7D7926DD, 0x7E817A72, 0x77767577, + 0x50525D67, 0x7F77695A, 0x7A79746F, 0x65686E75, 0xE5295C55, 0xEBE7EBE8, 0xE6E6E6E6, 0xE6E6E6E6, + 0xE8E8E8E8, 0xEAEAE9E9, 0x5352534C, 0x5151544D, 0x26194F48, 0x1114294F, 0xEBDDD9EB, 0xE6E4E8EB, + 0xD6E9E1EB, 0x104ABBE9, 0x503A4345, 0x66676866, 0x65605B59, 0x565C6568, 0x40464B4F, 0x3133363A, + 0x78737070, 0x8887847F, 0x83868788, 0x7E7F8081, 0x81818181, 0x7F7F8081, 0x817F7B79, 0x80808081, + 0x75767777, 0x77777675, 0x827D7976, 0x8F8E8B87, 0x7A7E7A74, 0x8B817574, 0x85898D8E, 0x7A7B7D81, + 0x81818284, 0x93908A85, 0x938E8987, 0x91939696, 0x878C8E8F, 0x787A7D81, 0x988F8783, 0xA4A4A39F, + 0x8E939699, 0x8C868388, 0x83878D93, 0x8F8D8985, 0x90999A93, 0x8F98988F, 0x8F9D9C91, 0x82878786, + 0x85838485, 0x88898887, 0x8E8E8D8D, 0x78797F88, 0x72707273, 0x77787774, 0x7C777575, 0x8B8A8782, + 0x7E818689, 0x6D70757A, 0x62626568, 0x76736E68, 0x6E707477, 0x92887C72, 0x8B8C8D8D, 0x84858788, + 0x82868581, 0x9088807E, 0x8F929394, 0x8385888C, 0x7E7D8082, 0x757A7F80, 0x8A87817D, 0x80818588, + 0x7476797A, 0x77767474, 0x77777676, 0x79797878, 0x7E7B7A7A, 0x81828281, 0x81818182, 0x6E747A80, + 0x6871787A, 0x6B666262, 0x7879726C, 0x6E767674, 0x81797474, 0x878C8D8A, 0x7E82878A, 0x7C7B7A7B, + 0x87858280, 0x7A7E8286, 0x7B7C7A7A, 0x7A7A797A, 0x81807E7B, 0x8C8B8784, 0x7B898D8C, 0x6F68636B, + 0x80808181, 0x7F7F7F80, 0x8B898582, 0x92908D8D, 0x8F919598, 0x8E959993, 0x8C8A8C92, 0x807A7C87, + 0xA19B9189, 0x888E989F, 0x8B8A8782, 0x7D848A8C, 0x757A8186, 0x75757474, 0x81817F7D, 0x71747A7E, + 0x7A716D6B, 0x81868884, 0x767A7A77, 0x82817C76, 0x86898A8B, 0x817C7A7F, 0x6E707476, 0x7474726F, + 0x686D6F6F, 0x5F5D5E62, 0x7574726F, 0x7D7A7775, 0x8D8C8780, 0x888B8C8C, 0x8C8B8A89, 0x8386888B, + 0x85828182, 0x7D7D8084, 0x7A818481, 0x50627276, 0x55605A59, 0x726F6E5A, 0x8D8A7E74, 0x8786868A, + 0x786F7A8C, 0x737D8887, 0x7A7A7A7A, 0x7E7D7B7A, 0x7C7E7E7F, 0x797A7A7B, 0x686D7377, 0x77736D68, + 0x78787776, 0x78787979, 0x7C7B7874, 0x79797A7B, 0x7B7D8183, 0x83817D7B, 0x76797E82, 0x807E7A77, + 0x82838383, 0x7D7E8081, 0x7B7C7C7C, 0x7A7A7A7B, 0x77797A7B, 0x75757576, 0x76767676, 0x76767676, + 0x6F6F6F6F, 0x6E6E6E6E, 0x706E6D6C, 0x75747472, 0x76777979, 0x73737474, 0x76777574, 0x7A787574, + 0x87858280, 0x82848787, 0x85868687, 0x82838384, 0x86858584, 0x84848586, 0x81808181, 0x87878785, + 0x84858687, 0x7E7F8182, 0x79797979, 0x76777879, 0x7F7B7977, 0x86858481, 0x88878787, 0x85868787, + 0x85868583, 0x72757B81, 0x8481807E, 0x86868786, 0x7F818283, 0x7577797C, 0x85807A76, 0x80828587, + 0x7F828486, 0x7274777B, 0x81807E7D, 0x88878684, 0x87878787, 0x7D808285, 0x8181807F, 0x7D7E8081, + 0x837F7E80, 0x757C8487, 0x84817B76, 0x82828384, 0x83828180, 0x87868584, 0x84858686, 0x70757C81, + 0x72747577, 0x79777473, 0x61616468, 0x716E6A65, 0x7B7B7774, 0x5F5F6572, 0x6462615F, 0x7A7A756C, + 0x777A7B7C, 0x686A6E74, 0x746F6B68, 0x6E717475, 0x615D6269, 0x5E666C69, 0x81766961, 0x85878988, + 0x6F737B84, 0x6B6D6F6F, 0x6E69696D, 0x68707675, 0x63635B52, 0x6C645D5E, 0x7E7C7874, 0x7374787B, + 0x6A6F7476, 0x66646265, 0x7576736E, 0x73747474, 0x807B7875, 0x8E8D8985, 0x6972808A, 0x847D736A, + 0x7D787A80, 0x80878B87, 0x8C8A8887, 0x8C8D8D8D, 0x928D8C8B, 0x858B9294, 0x7B7B7B7C, 0x7F7E7D7B, + 0x837C7A7A, 0x8F92928D, 0x6F707983, 0x79777473, 0x7C777677, 0x94928C83, 0x82878B8D, 0x797A7C80, + 0x6D6F7477, 0x68686A6C, 0x6E67625F, 0x87847E76, 0x82838687, 0x7A7C7F81, 0x7474716F, 0x73737374, + 0x857F7A78, 0x7C818788, 0x74787A7B, 0x66686C70, 0x6A706F69, 0x64646264, 0x5C5D5E5F, 0x5A5A5A5B, + 0x54515152, 0x736C6259, 0x6B686B6E, 0x7C7A7771, 0x7A7B8084, 0x8A87837E, 0x7B7D7F80, 0x7C7B7A7A, + 0x77797A7C, 0x6E707476, 0x6D6C6C6B, 0x7473716E, 0x76767676, 0x75757676, 0x63666C71, 0x726F6A66, + 0x827B7774, 0x8990938C, 0x91918F8D, 0x8C8E9091, 0x6E737C85, 0x73747470, 0x81777476, 0x67707D85, + 0x7F7D746D, 0x7674747A, 0x74747575, 0x6E6E7173, 0x736F6D6C, 0x88857F79, 0x87878788, 0x86878989, + 0x7071777D, 0x70737473, 0x6B6D6E6E, 0x6868696A, 0x5A5D6162, 0x6264625C, 0x5C5C5C5C, 0x56585B5C, + 0x5C565657, 0x6C76796B, 0x5C595C5F, 0x61646662, 0x59565656, 0x6866625D, 0x6F6E6D6D, 0x74737271, + 0x70727374, 0x696A6C6E, 0x6E6E6A65, 0x6265686C, 0x6868625E, 0x585C6066, 0x6C645E5B, 0x6C6E7271, + 0x7A78726D, 0x6B6E7278, 0x7B7B746E, 0x6E6D6F75, 0x71625E6A, 0x73757474, 0x726D6C6E, 0x7C7F7F7A, + 0x74767779, 0x74747474, 0x74737372, 0x78777674, 0x897F8391, 0x636B7D8D, 0x6D66615E, 0x75767673, + 0x73767879, 0x696A6D70, 0x605E4C65, 0x51585367, 0x4F5C4E45, 0xE2E4D342, 0xEBEBE8DC, 0xE8E7E2EB, + 0xC8D7EBE2, 0xEBEBD0EB, 0x7B8CDFDE, 0x78706471, 0x80816A68, 0x28567456, 0xE2EBEAEB, 0xD7EBEBD8, + 0xEBE4E6E3, 0xE5E5EBDF, 0x6858CAE6, 0x6D657D65, 0x6868696A, 0x6A696968, 0x6E5C6D65, 0x96949381, + 0x70687C93, 0xE5EBDB32, 0x63C4D4CA, 0x6A767A63, 0x6B6B6B6B, 0x6B6B6B6B, 0x716E6E55, 0xEBB43E68, + 0xEBC6E7EB, 0xC7DFEBE5, 0xEBEBE8E4, 0xD6EBDEEB, 0x62EBE1D6, 0x767A536E, 0x62666C70, 0x6E6B6662, + 0x70717171, 0x6E6E6E6F, 0x5C636E74, 0x67635E5B, 0x5D596D67, 0x65636463, 0x68625B71, 0x15535C71, + 0xDBE4E1EA, 0x828FD7DA, 0x575A5B5C, 0x51525456, 0x695D5757, 0x686B4A69, 0xEBE0BB3A, 0xE8E9DEE6, + 0xE9E9E6EB, 0xE1EBEBEB, 0x69DCCFEB, 0x4B3E444A, 0x5451504F, 0x5C5A5856, 0x5C5C5B5B, 0x58595B5C, + 0x58585857, 0x5A595959, 0x5046546A, 0x4950363A, 0xE5EBE110, 0xC5EBD4E6, 0xE7E7E7E7, 0xE7E7E7E7, + 0xEBEBD3E7, 0x6475D6E0, 0x64635B53, 0x7C716562, 0x1E457A8E, 0xDFEBEBC5, 0xE3E3EBC7, 0xEBE6E5EB, + 0xEBE8E5DB, 0xEBE0EBDC, 0x40125DE0, 0x3E486060, 0x4B4B4B4B, 0x4E4D4C4C, 0x4D4F5154, 0x5654504E, + 0x4E6D4C4D, 0xDF392F31, 0xC3E4E0E3, 0xE0DEEBEB, 0xEBE1E2DC, 0xE1EBE7D2, 0x4A165EE8, 0x45536868, + 0x4D4E535C, 0x3631524E, 0xD7DC2E3E, 0xEBCBDCEB, 0xE6E7E5EB, 0xC3E4EBEB, 0xEBEBDAEB, 0x7557466E, + 0x6E68615C, 0x66696E70, 0x6F6E6863, 0x5F62666C, 0x585B5B55, 0x747C6756, 0x5B495256, 0xE1EBC329, + 0xEBEBD2C9, 0xEBE2EBEB, 0xD4DCEBE8, 0xEBEBC5EB, 0x5A6AC1E2, 0x8D96746E, 0x474D6B74, 0x145F5E4A, + 0xE8E4EBE9, 0xEBEBE0EB, 0xE7E7E8E8, 0xE7E8E8E8, 0xEBEBE0E7, 0x6E7742EB, 0x807C7671, 0x6C71797E, + 0x67696E70, 0x726E6A67, 0x71707071, 0x62676D70, 0xE7255C5E, 0xE6E1EBEB, 0xEBEBEBEB, 0xEBEBEBEB, + 0xEBEBEBEB, 0xEBEBEBEB, 0x4B4A5751, 0x3A404C3E, 0xCE453E49, 0xE6E3DDE5, 0xD9E4E9EB, 0xDCEBEBD9, + 0xE1EBEBCA, 0xD1DDEBEB, 0x5043574F, 0x6E6B6861, 0x63606162, 0x585E6466, 0x3D414548, 0x32333538, + 0x7B757372, 0x8A898781, 0x85888C8D, 0x7C7D7F81, 0x82828282, 0x7F808181, 0x7D7D7A79, 0x7F7D7C7D, + 0x77787979, 0x79797877, 0x85807C7A, 0x908F8D89, 0x78777A7F, 0x8786827D, 0x86898C8D, 0x7D7E8082, + 0x7A7A7B7D, 0x8886817B, 0x90888380, 0x96999997, 0x82878B8E, 0x7A7B7C7F, 0x8B85807D, 0x9D9A9691, + 0x8F969EA4, 0x8D878488, 0x8C8E9294, 0x8C8C8C8B, 0x818D918D, 0x878D8980, 0x8E99917F, 0x85888785, + 0x86848585, 0x88898A88, 0x8C8C8A8B, 0x76767C86, 0x74737374, 0x7A7B7A78, 0x7D7A7878, 0x8D8C8883, + 0x81868B8E, 0x696E747B, 0x5C5C6063, 0x736F6862, 0x7C797471, 0x8B888480, 0x8E909191, 0x88898B8D, + 0x858B8B88, 0x7F7A787C, 0x89888787, 0x87878888, 0x81818284, 0x7C7F8283, 0x8786817E, 0x84848687, + 0x76787A7C, 0x76757474, 0x76767676, 0x77777777, 0x78777778, 0x7A7A7B7A, 0x8684807D, 0x70757E84, + 0x71747574, 0x77736E6E, 0x7C7D7879, 0x76858279, 0x7A7A7673, 0x7A767475, 0x7A7D8182, 0x7E7C7A7A, + 0x8583817F, 0x7D7F8184, 0x7C7E7F7E, 0x7877777A, 0x817C7A7A, 0x8F8D8986, 0x7A8C9598, 0x8074686B, + 0x83888D8E, 0x7174787D, 0x837C7673, 0xA49E948B, 0xBABDC4C9, 0x96A6B6BA, 0x89868284, 0x7A787C86, + 0xA1998D83, 0x878D98A0, 0x9B99938C, 0x848E999B, 0x7474777A, 0x79787775, 0x7D7E7D7C, 0x6F72767A, + 0x706B696B, 0x6F747876, 0x706A6A6A, 0x8A8C877B, 0x84898D8E, 0x7C7F8181, 0x78787470, 0x7D7A7575, + 0x69717679, 0x7A736966, 0x6D6F7A84, 0x7C7B7872, 0x8C8D8881, 0x82878B8B, 0x8C888787, 0x80858B8D, + 0x817C7A7C, 0x807D7E82, 0x767C7F7B, 0x66717875, 0x6E747377, 0x818D967E, 0x88877F78, 0x83818084, + 0x7A757B86, 0x757C8482, 0x7979797A, 0x7C7B7A7A, 0x7A7B7B7C, 0x77787879, 0x6D6F7375, 0x75736F6D, + 0x78787776, 0x78787979, 0x7E7C7976, 0x7A7A7B7D, 0x7A7D8184, 0x84817D7A, 0x797B8084, 0x82817E7A, + 0x82838485, 0x7C7D7F81, 0x7A7A7A7B, 0x7979797A, 0x76787A7A, 0x74747475, 0x76767675, 0x76767676, + 0x6F6F6F6F, 0x6E6E6E6E, 0x6E6D6C6B, 0x7271706F, 0x72747575, 0x6C6D6E70, 0x75746F6B, 0x75737273, + 0x8985807C, 0x8285888A, 0x81818181, 0x80808080, 0x84838382, 0x83838484, 0x82818182, 0x88888785, + 0x82848686, 0x797A7D80, 0x7A7A7978, 0x797A7A7A, 0x7E7B7A79, 0x83828181, 0x81818181, 0x80808181, + 0x88868280, 0x80828688, 0x87868584, 0x85868787, 0x777A7D7E, 0x6F707274, 0x827D7672, 0x7E818385, + 0x7E818181, 0x686C7279, 0x7F7D7C7B, 0x86858381, 0x82838382, 0x7C7C7E80, 0x7D7D7C7C, 0x78797A7C, + 0x807A7979, 0x71798183, 0x817B7570, 0x80818283, 0x7E7C7B7B, 0x85848381, 0x7D7E7F80, 0x696E747A, + 0x6A6C6E70, 0x77746F6C, 0x6566686B, 0x706E6B68, 0x7F7D7773, 0x6A686E78, 0x62686D6E, 0x686A6862, + 0x8A807167, 0x6872808A, 0x736E6865, 0x74767776, 0x716C7077, 0x70777D7A, 0x756C625D, 0x7F80807D, + 0x6E757C81, 0x6C6D6D6D, 0x726E6D6E, 0x7A7A7A77, 0x70797873, 0x6A625E63, 0x74767879, 0x7A767372, + 0x68727A80, 0x66626062, 0x79787168, 0x6F747878, 0x817C7A78, 0x908E8A86, 0x727A8790, 0x8D867A73, + 0x7A7A8087, 0x6E757C7D, 0x8D8D8B8A, 0x898A8B8C, 0x8D898787, 0x7E848C8E, 0x76767677, 0x77777676, + 0x7C757374, 0x898C8C86, 0x6E6E7580, 0x77747371, 0x7F797574, 0x8E8E8B86, 0x7C808589, 0x7476797A, + 0x7173777A, 0x6D6E6F70, 0x7E766E6A, 0x85868683, 0x7B7A797A, 0x7C7E7F7E, 0x6E71767A, 0x6E6D6D6C, + 0x867E7772, 0x84878989, 0x777C7F80, 0x61646A71, 0x6C706E67, 0x6C6B6868, 0x60626465, 0x5C5C5C5E, + 0x4F4C4D4F, 0x6A655C55, 0x64616266, 0x7575736C, 0x7877797A, 0x7A7A7A79, 0x73747474, 0x77767474, + 0x6F707374, 0x67696C6E, 0x6D6B6A69, 0x7474716F, 0x76757474, 0x79787877, 0x65686F74, 0x6F6E6966, + 0x87817B77, 0x8B939690, 0x99959291, 0x92939699, 0x8C8C9094, 0x878B8D8D, 0x7E79797E, 0x666D7981, + 0x807E756E, 0x7775767A, 0x74747575, 0x6E6F7072, 0x74706E6E, 0x87847E79, 0x85828387, 0x868A8D8A, + 0x7071767B, 0x6E717473, 0x68696B6C, 0x68686868, 0x6B67686B, 0x81858377, 0x5C5C5E60, 0x5B5C5D5C, + 0x59565859, 0x65737668, 0x5A565657, 0x63666662, 0x57555453, 0x67635F5A, 0x6F6E6E6D, 0x74747371, + 0x6F717272, 0x68686B6E, 0x68676565, 0x66656567, 0x6C6B6762, 0x5D5F6469, 0x675C5550, 0x6E6F716E, + 0x7A756E69, 0x6F72767A, 0x81807972, 0x6B6D727A, 0x6F646069, 0x6E727070, 0x6C68696D, 0x7B7C7A74, + 0x72737475, 0x76747472, 0x77767676, 0x76767677, 0x8D83838D, 0x6F707C8C, 0x716A6768, 0x74787B79, + 0x73747677, 0x6E6E6F71, 0x62655878, 0x69565C6B, 0x1410164B, 0xE8E2C73D, 0xD0EBD5EB, 0xEAEAEBEB, + 0xEBEBD0D8, 0xD4DCEBD0, 0x6A7ADEEB, 0x5762636C, 0x52706977, 0x10274110, 0xE0CBE8EB, 0xEBE0E6EB, + 0xDBC3DAEB, 0xE8EBEBC3, 0x3835C1EB, 0x6E4E5031, 0x66686869, 0x64646465, 0x8C5C5A75, 0x8C907670, + 0x311D8B7B, 0xCBEBC525, 0x81DDE3EB, 0x605F687C, 0x67676767, 0x67676767, 0x21155B6F, 0xEBB0222B, + 0xC0EBE0E3, 0xEBEBE8E0, 0xDADBE0E4, 0xD5EBBFE2, 0x1DC5DEEB, 0x59431E25, 0x61646A6E, 0x6B686360, + 0x6B686564, 0x7776746F, 0x61666F75, 0x68666361, 0x5A5F6A75, 0x736E6E64, 0x63685363, 0x101C2D3F, + 0xE9EBE6E7, 0x6171D6E2, 0x51525252, 0x4F505050, 0x5754443D, 0x1D371047, 0xCAD7B939, 0xE4E6EBE7, + 0xEBEBE2E8, 0xE4D8EADB, 0x2EDEEAEB, 0x32293113, 0x53504D4B, 0x57575656, 0x5B5C5B5B, 0x54555759, + 0x55555555, 0x55555555, 0x51694B5F, 0x1B371054, 0xCCEBDC2B, 0xE3E6DCEB, 0xE9E9E9E9, 0xE9E9E9E9, + 0xE0E8EBE4, 0x6C63E8DC, 0x65676E75, 0x535A6265, 0x19152410, 0xDBE2EBCA, 0xE6E9D1EB, 0xD7E9E8D2, + 0xDAEBEBEB, 0xDEE2DEE7, 0x40104ED0, 0x3B44564F, 0x4A4B4C4C, 0x4C4C4B4A, 0x4A4D5155, 0x514F4B49, + 0x16412F3C, 0xE0341F19, 0xE3E7BEEB, 0xEBEBE4D0, 0xDBE2EBE5, 0xEBE9E0E7, 0x491356E2, 0x313F5050, + 0x44566257, 0x2E13483A, 0xEBE61910, 0xE7EBEBD1, 0xE2EBDFDD, 0xEBE8EBDC, 0xE7EBD6EB, 0x633C1035, + 0x7A746D68, 0x6F73787A, 0x6C6E6F70, 0x49515D67, 0x55505363, 0x70727463, 0x1A191051, 0xE8D2D03E, + 0xCAE0E4EB, 0xE2EADDEB, 0xEBEBDFEB, 0xD2EBDDD0, 0x5F7ADCEB, 0x7A786267, 0x535C7880, 0x105A5E50, + 0xEBE6EBE7, 0xCADBC7EB, 0xE8E8E8E9, 0xE3E6E8E9, 0xCBE8DBE3, 0x79817DC3, 0x77726E6E, 0x61687379, + 0x88837568, 0x72747A83, 0x65666B6F, 0x61646867, 0xD1104A50, 0xE8E3E8DE, 0xE2E2E2E2, 0xE2E2E2E2, + 0xE5E5E6E6, 0xE4E4E4E5, 0x484A5F5E, 0x293C5040, 0xD63A101C, 0xE8EBE3E4, 0xDEEBEBEA, 0xDFEBE7D7, + 0xE8EBEBE4, 0xEAD2EBD5, 0x40342A10, 0x6164695F, 0x62616264, 0x555B6264, 0x383D4043, 0x30303134, + 0x7F797574, 0x89898885, 0x85878B8C, 0x7D7E7F81, 0x81828282, 0x7C7D7F81, 0x7A7A7977, 0x7B7A7879, + 0x7C7C7D7D, 0x7D7D7C7C, 0x87848180, 0x8E8D8D8A, 0x77747E89, 0x81878A82, 0x8788898A, 0x7F808285, + 0x6E707476, 0x7C79746F, 0x8C837D7A, 0x94979994, 0x7C808589, 0x7F7F7D7C, 0x7F7D7B7A, 0x8E8B8581, + 0x8A8E979F, 0x8D878587, 0x91929191, 0x888A8D8F, 0x7D868B8A, 0x8E8F887E, 0x8B8F887B, 0x88898786, + 0x89878686, 0x888A8C8C, 0x81828284, 0x6E6E737B, 0x78747372, 0x7E7F7E7C, 0x7B79797A, 0x87878480, + 0x7F83888B, 0x666B7279, 0x58585C61, 0x716D655C, 0x837D756F, 0x88878787, 0x8E909191, 0x88898B8D, + 0x888D8A86, 0x7A797980, 0x8482807F, 0x89888787, 0x84838485, 0x7D808384, 0x81817F7D, 0x81817F80, + 0x797A7A7A, 0x7A7A7979, 0x77787878, 0x75767677, 0x70727577, 0x6C6E6F70, 0x8881746B, 0x81828689, + 0x76767472, 0x7E7A7675, 0x83857F85, 0x7A8E897C, 0x7579736C, 0x7E746C6E, 0x75757576, 0x7A797876, + 0x7C7C7C7C, 0x7F7F7E7D, 0x7C808282, 0x78767678, 0x857D797A, 0x93908E8C, 0x929B9E9C, 0x8F888387, + 0x878E9396, 0x72747A81, 0x7D777370, 0xAAA19387, 0xC1C6CACA, 0x8E9EB0BA, 0x857E7977, 0x7E7C7F84, + 0x9C958A81, 0x888D959C, 0xABABA49A, 0x8F9DA8AB, 0x74777A7D, 0x71737474, 0x6A6C6D6E, 0x5F616468, + 0x62606062, 0x62656665, 0x81746E6C, 0x9699988E, 0x858C8F8D, 0x767F8483, 0x81817A73, 0x817D7A7C, + 0x6F757B7E, 0x978A796E, 0x686F869A, 0x817D776E, 0x858A8983, 0x7B828583, 0x857F7C7B, 0x757D8789, + 0x7A716E70, 0x827D7B7E, 0x777B7C7B, 0x7F7F7C78, 0x7E818189, 0x808E9F8D, 0x88898581, 0x84818183, + 0x7A7A7B7F, 0x797B7E7D, 0x797A7A7A, 0x7A7A7979, 0x77787979, 0x75757676, 0x74747474, 0x74747474, + 0x79787777, 0x7979797A, 0x81817C7A, 0x7D7E7F81, 0x7F818284, 0x8482817F, 0x7C7E8185, 0x8382817E, + 0x7F818385, 0x7A7A7B7D, 0x78787979, 0x7A797878, 0x76777879, 0x74747474, 0x75757575, 0x76767676, + 0x71727272, 0x70707171, 0x6F6E6E6E, 0x7070706F, 0x70717272, 0x696A6C6E, 0x75746E68, 0x716F6E72, + 0x88837B76, 0x7F83878A, 0x7B7B7B7B, 0x7F7E7D7B, 0x82818181, 0x82828283, 0x82818182, 0x87878785, + 0x81848585, 0x74777A7E, 0x7B797776, 0x7F7F7E7D, 0x7F7E7D7C, 0x7F7F807F, 0x7A7B7D7E, 0x7C7B7A7A, + 0x8B86807B, 0x8D8E8F8E, 0x86878787, 0x81818385, 0x7074787A, 0x6A6A6B6E, 0x807A736E, 0x7B7E8182, + 0x787A7978, 0x63676E74, 0x7E7B7A79, 0x81818180, 0x7C7F8080, 0x74747578, 0x77767574, 0x74747576, + 0x6D6B6E70, 0x74747470, 0x7A777474, 0x7F81817F, 0x77747578, 0x8081817D, 0x7A7B7B7C, 0x696E7479, + 0x6465686A, 0x746F6A66, 0x6D6E6F70, 0x72716F6E, 0x837E7874, 0x7A797B81, 0x68737C81, 0x68696866, + 0x8F816F62, 0x6D788792, 0x6966625F, 0x67686A6B, 0x77707074, 0x7F858781, 0x6E6C6C6C, 0x78787673, + 0x6E767C7D, 0x6E6D6A69, 0x72716F6E, 0x7E7B7774, 0x6D7A7B78, 0x5E56525B, 0x6E727577, 0x807A736E, + 0x68737D83, 0x63605D60, 0x7F7C7368, 0x777F8280, 0x807D7C7B, 0x8C8A8783, 0x7C81898F, 0x8C88827D, + 0x7A7A7E81, 0x777B7E7E, 0x8D8D8D8B, 0x8787878A, 0x8A878585, 0x7980878B, 0x74737373, 0x70737576, + 0x7D777575, 0x898A8884, 0x6E6E7681, 0x73717170, 0x7C777473, 0x84858581, 0x74767C81, 0x6E717373, + 0x71717374, 0x71737373, 0x88837C78, 0x7D818789, 0x78747271, 0x8081807C, 0x686F7981, 0x6A6A6968, + 0x857C736C, 0x88888988, 0x7A7F8182, 0x5D626A72, 0x70726E67, 0x7674706E, 0x6A6C6D6E, 0x66666868, + 0x59585A5C, 0x6A68635D, 0x57596168, 0x6867635C, 0x78746F6C, 0x6A6E7478, 0x6B696868, 0x72706E6D, + 0x6C6E7072, 0x6567696B, 0x6B686765, 0x7473716E, 0x76747372, 0x7B7A7978, 0x6A6E747A, 0x6F6E6C69, + 0x7A767574, 0x83888981, 0x918B8786, 0x8C8C8E92, 0x908C8988, 0x92939493, 0x7A777A81, 0x636A747B, + 0x7F7B736C, 0x7A797A7D, 0x74757677, 0x71717273, 0x74737171, 0x817F7B78, 0x807C7E81, 0x83878A87, + 0x7171757A, 0x6C707474, 0x67686869, 0x6B696868, 0x736E6E71, 0x888E8D81, 0x5F606367, 0x5F616261, + 0x56565B5A, 0x606E7263, 0x59565555, 0x5E5E5E5C, 0x5A5A5857, 0x62605C5B, 0x68676665, 0x6D6C6B69, + 0x6E6E6E6E, 0x6466686B, 0x62606164, 0x6A666362, 0x73726F6C, 0x66686B6F, 0x6E68625E, 0x6D6E7070, + 0x74716D6A, 0x79797977, 0x82817A75, 0x696E777F, 0x6F666269, 0x6C706F6E, 0x68686A6E, 0x7373716D, + 0x70707171, 0x76757472, 0x80818181, 0x7A7B7D7F, 0x84807A79, 0x7B75757F, 0x74757A7F, 0x70747675, + 0x6F707172, 0x6F6F6E6E, 0x74766F80, 0x54285C79, 0xE6C81A56, 0xE5CBEBE0, 0x212CBBE8, 0x101E1010, + 0x1D191F30, 0xEBEBDE10, 0x6B78D4DC, 0x7D7E7472, 0x646F5C6F, 0xEAE8C937, 0xE4EBE4E4, 0x25101FD6, + 0x23172710, 0xCFEBBF26, 0xE0D2EBD6, 0x936E7AB5, 0x63656868, 0x5F5F6062, 0x60567A55, 0x7A68625B, + 0xC6117F6A, 0xEBE4EBB5, 0x66DDE0DE, 0x626A5F67, 0x61616060, 0x62626261, 0xBF386560, 0xE2EBD5E9, + 0x1CDEEBEB, 0x101A2419, 0x161C1914, 0xEBC92225, 0xEBE9EBE6, 0x7560D7E4, 0x6064696D, 0x69676260, + 0x68626060, 0x7A78746E, 0x62646A70, 0x60626262, 0x6E6C5F60, 0x4B645C72, 0x62716E62, 0xE8DE3A6D, + 0xE6E8DCDB, 0x646FE1E5, 0x4D4C4C4C, 0x4F4E4E4D, 0x55544D4F, 0xDCD63E5F, 0xEBCCEBDB, 0x152DC6EB, + 0x101D2512, 0xDEC52731, 0xD0EBD7E9, 0x5772D6E1, 0x504F4D4B, 0x55555452, 0x595B5C5C, 0x51535557, + 0x53535353, 0x53535353, 0x5B724E56, 0xE3C5316D, 0xE6C5EBE4, 0x1927C2EB, 0x10101010, 0x10101010, + 0xEBEAD11B, 0x6A56EBEB, 0x565C666D, 0x4A4D5154, 0xD0E3CA44, 0xEBC7E8EB, 0x312525C1, 0x17212613, + 0x221A1016, 0xEBE9EBCA, 0xE8EBDBD0, 0x5A585674, 0x494A4A4B, 0x4D4C4A4A, 0x4B4E5254, 0x4F4D4B4A, + 0x2D3B455E, 0xD6C9EBC6, 0xEBEBDFC7, 0x1010111B, 0x12101010, 0xB7EBEBEB, 0xDDE7CCC8, 0x48474062, + 0x3A495653, 0x99134062, 0xE6E5EBE5, 0x24D9EBDA, 0x20211816, 0xCA31171F, 0xEADCEBDF, 0x7DC7E2E5, + 0x7A756F6B, 0x72757A7B, 0x6C6E7275, 0x444E5C66, 0x5245455E, 0x553B5F6C, 0xDECA106B, 0xEBD4EBCB, + 0x1E1FB0D1, 0x102A1913, 0x1013101B, 0xE4EBC410, 0x6070CED2, 0x6060616D, 0x66697D7E, 0x105D6962, + 0xCDDAEBEB, 0x103741B3, 0x15121111, 0x10131818, 0x101B1714, 0x756D561F, 0x6E6A6D73, 0x60656D70, + 0x998B6F58, 0x80828A96, 0x62656C72, 0x64666764, 0xDF236268, 0xEAE8EBE8, 0x1F1F1F1F, 0x1F1F1F1F, + 0x14151515, 0x13131314, 0x5257696C, 0x27496457, 0xEBE2E3E0, 0xEBD7D1EB, 0x25191013, 0x17101018, + 0xBC151014, 0xEBE0EBEB, 0x58B7E5EB, 0x675D5B54, 0x615F5F5F, 0x52585E62, 0x393F4447, 0x2C2D3034, + 0x817A7674, 0x87898A87, 0x82848687, 0x80808081, 0x7F818181, 0x797A7B7D, 0x76777776, 0x77757474, + 0x81818283, 0x83828181, 0x89878584, 0x8D8D8D8B, 0x7A7A838D, 0x81878983, 0x88898988, 0x7D7F8387, + 0x696D7275, 0x76736E69, 0x877F7A7A, 0x8D919390, 0x7B7D8186, 0x8786837F, 0x7A7E7F7F, 0x7F7C7978, + 0x807E848C, 0x89878583, 0x918F8C89, 0x898B8D90, 0x83868A8D, 0x97928B86, 0x81828689, 0x88888783, + 0x8D898786, 0x898C8F8F, 0x7577787A, 0x6664686F, 0x7A757270, 0x81818280, 0x7776787A, 0x7E7D7C79, + 0x797B7F81, 0x65696F74, 0x56575C61, 0x706B635B, 0x7C7A7876, 0x8D89837F, 0x888A8A8B, 0x81838587, + 0x8C8D867E, 0x7E7C7E84, 0x817E7C7A, 0x87868583, 0x84858586, 0x797B8083, 0x74767778, 0x77747272, + 0x7D7A7877, 0x81818180, 0x7A7B7C7D, 0x74757678, 0x6C6E7376, 0x6667686A, 0x8C867669, 0x81808288, + 0x77797877, 0x7F7A7675, 0x8C8E858A, 0x7A91897D, 0x797B756E, 0x82797172, 0x7A7A7978, 0x78797A7A, + 0x73747679, 0x83807A75, 0x7C818587, 0x7A777677, 0x8D817A79, 0x93939595, 0xA9A79E95, 0x99999EA5, + 0x8A8D8F90, 0x81838587, 0x7C7A7B7C, 0x9F988C81, 0xAEB7B1A8, 0x8287929F, 0x827E7A7A, 0x83818182, + 0x958F8781, 0x8E909396, 0xA8AAA59B, 0x8D9AA5A6, 0x71798187, 0x6365686C, 0x595C5F61, 0x52525456, + 0x59575656, 0x605F5D5B, 0x78706862, 0x82817E7C, 0x858E8F89, 0x757E8181, 0x82817C77, 0x82807E80, + 0x757A7E80, 0x9F928176, 0x7275879A, 0x85827E78, 0x7B848783, 0x747B7D7A, 0x827A7473, 0x6E798588, + 0x72686468, 0x7D767476, 0x7677787A, 0x867C7474, 0x878D878B, 0x7E828F89, 0x83878582, 0x807D7C7F, + 0x7E7E7D7B, 0x7C7E7F7E, 0x797A7C7D, 0x76777778, 0x76767777, 0x74747475, 0x79787675, 0x75767879, + 0x7A797878, 0x7A7A7A7A, 0x8685817E, 0x81828385, 0x86858584, 0x84858586, 0x80818385, 0x83838381, + 0x7A7E8184, 0x78787778, 0x76767677, 0x7A7A7876, 0x75767777, 0x75747474, 0x75747474, 0x76767675, + 0x74747575, 0x74747474, 0x73747474, 0x72727273, 0x74747473, 0x70717374, 0x7476716C, 0x706D6C6F, + 0x87807772, 0x7A7F8588, 0x78777878, 0x7D7C7A79, 0x8181807F, 0x81818182, 0x81808181, 0x84858482, + 0x81838485, 0x7174787D, 0x77747270, 0x83817F7B, 0x81818181, 0x7D7E7F80, 0x787A7E81, 0x7F7C7A78, + 0x8F8B8682, 0x8D8F9191, 0x82858789, 0x7B7B7D80, 0x6B6F7476, 0x66666768, 0x7D776F6A, 0x797B8081, + 0x70737475, 0x5F62676B, 0x7D7A7875, 0x7E7F807F, 0x757B7E7F, 0x6868696E, 0x6F6E6C6A, 0x6F6F7070, + 0x62626669, 0x7D776E66, 0x73747A81, 0x7E7F7D78, 0x706D7074, 0x797C7E79, 0x78787878, 0x686C7276, + 0x61626568, 0x736E6862, 0x76777676, 0x75747475, 0x88817A79, 0x8987898B, 0x757D8587, 0x75777673, + 0x83807A76, 0x74787E83, 0x6B6A6866, 0x6365686A, 0x766E6C6C, 0x83868781, 0x73757C81, 0x7C7A7874, + 0x6F7A7E7C, 0x72706C69, 0x6F707070, 0x75747270, 0x6771706B, 0x5B534E56, 0x74747474, 0x7C797674, + 0x68737B80, 0x5F5D5C60, 0x817F7468, 0x838A8A84, 0x7F7E7F7F, 0x84838180, 0x83848688, 0x81828383, + 0x7D7A7878, 0x88878681, 0x8B8D8C8A, 0x82828387, 0x89878585, 0x777D8689, 0x7D777474, 0x72798081, + 0x82807E7D, 0x8D8B8986, 0x73747E89, 0x72717274, 0x77737170, 0x7A7B7C7A, 0x6B6D7378, 0x686B6D6C, + 0x736E6B6A, 0x7F7F7D79, 0x8B87827F, 0x7C81868A, 0x81807F7F, 0x83858584, 0x6A707B84, 0x6C6D6D6A, + 0x837D746D, 0x81818284, 0x7A7F8181, 0x5E626B74, 0x74757068, 0x817E7974, 0x76767675, 0x75757676, + 0x6D6D7073, 0x7272716E, 0x585C666E, 0x595C5C5B, 0x7C74685E, 0x6068737B, 0x615E5C5C, 0x6B696764, + 0x68696C6E, 0x62636667, 0x68646260, 0x72706E6B, 0x75747271, 0x7D7C7A78, 0x70747A80, 0x71706F6E, + 0x6F6D6C6B, 0x747A7C76, 0x81787372, 0x817F8083, 0x8382807C, 0x82818182, 0x7573767D, 0x62687177, + 0x7E786F69, 0x7D7D7F80, 0x74767879, 0x71727274, 0x74737271, 0x7A797876, 0x7A76777A, 0x7F838581, + 0x7171757A, 0x6A6E7374, 0x68686868, 0x6E6D6A68, 0x74747473, 0x7F83827B, 0x696A6E71, 0x62676A6B, + 0x565A5D5B, 0x5F6D7062, 0x59595755, 0x56565657, 0x5B5C5C5A, 0x5A595758, 0x5E5C5C5B, 0x6262615F, + 0x6B6C6C6C, 0x61636669, 0x5D5B5D63, 0x6E686260, 0x7A7A7A78, 0x6E6F7276, 0x7B7D7A77, 0x6C6D7076, + 0x6E6C6D6E, 0x827F7A73, 0x837F7A76, 0x6B737C83, 0x6F686268, 0x6E73706F, 0x6B6B6C6D, 0x6E6E6D6C, + 0x706E6E6E, 0x76757472, 0x7D7F7F80, 0x7475787A, 0x76787168, 0x7E746C6E, 0x7A828788, 0x65666870, + 0x6B6B6C6C, 0x6E6E6D6B, 0x6C6C7470, 0x56105A76, 0xE2EB211E, 0xDCE4DCDC, 0x6653E3EB, 0x62745042, + 0x57597F52, 0xE9DBDB2E, 0x1E3FC7EB, 0x7E755332, 0x667D7290, 0xE8E8CE29, 0xD0DAEBE1, 0x876E67EB, + 0x6B6C7E62, 0xC7EBCC43, 0xE6DAEAEB, 0x60688BEB, 0x62636668, 0x5C5C5D5F, 0x15196231, 0x13101E23, + 0xEB101C19, 0xEBC5EBE7, 0x5FEBEBE9, 0x5766565E, 0x5D5D5D5C, 0x5F5F5E5E, 0xCF13635C, 0xD1E5E9E7, + 0x41E2EBE5, 0x44716E39, 0x565C5044, 0xEBD72C54, 0xEBC1E2E8, 0x8656EBE2, 0x5D616669, 0x65625F5C, + 0x62606162, 0x6D6E6C68, 0x5D5E6368, 0x55595C5D, 0x5756574C, 0x1F4C1047, 0x10101710, 0xE1DA103E, + 0xE3E8E7EB, 0x676FE9E7, 0x4B4A4949, 0x50504F4D, 0x535A5150, 0xDEDD2556, 0xE7E1EBEB, 0x657EE2E8, + 0x2B4A6350, 0xE8E12852, 0xE7E6EBE2, 0x4B40D1EB, 0x4A494949, 0x5C59534E, 0x575A5C5C, 0x51525355, + 0x51515151, 0x52525251, 0x1E104060, 0xEBBD261A, 0xE1EBE6E8, 0x2E74EBD6, 0x53535353, 0x53535353, + 0xEBE0D51D, 0x1F2FC0DC, 0x55514A42, 0x4B4C4F53, 0xDCDED424, 0xD9ABEBE3, 0x453755EB, 0x382F3B38, + 0x404F3943, 0xE8E2D0CF, 0xCAE8EAEB, 0x48595153, 0x4949494A, 0x52504D4A, 0x4F505152, 0x4D4D4E4E, + 0x19475D5C, 0xE9EBE4CA, 0xEBEAE4EB, 0x5E5F6867, 0x1D33344C, 0xEBDCE9E9, 0xD1EBE8EB, 0x545F4B4E, + 0x4A42464A, 0xE920436E, 0xEBC3EBE9, 0x4FE9EBE2, 0x4444424E, 0xDC423C45, 0xD7EBEBD7, 0xA2EBEBDA, + 0x706B6662, 0x6C6E7172, 0x696D6E6E, 0x444C5762, 0x51424258, 0x6A1A4971, 0xEBEB141C, 0xD0EBDDD0, + 0x756EE4EB, 0x565E6354, 0x4C5F5C39, 0xE9DCE148, 0x203CCFEB, 0x746A5F49, 0x83777A70, 0x30849287, + 0xEBE7EBEB, 0x3D6866E5, 0x625B5655, 0x61666A68, 0x5E646D50, 0x4E736666, 0x6A69737F, 0x69696C6D, + 0x92866F5C, 0x81828790, 0x62656C72, 0x61626362, 0xD4104953, 0xE9E0E6E1, 0x61616161, 0x61616161, + 0x72727171, 0x73737372, 0x60696F71, 0x25557271, 0xE9EBD8DF, 0xEBEBE9DE, 0x4A605E50, 0x6A6D563F, + 0xCC305161, 0xDEE9CAE3, 0x5CDAEBEA, 0x5C596762, 0x5F5C5A58, 0x55585C5F, 0x424A5156, 0x2B2D3139, + 0x827A7572, 0x87898A88, 0x81818181, 0x82828181, 0x7D7E7F80, 0x7576787A, 0x74757676, 0x74737172, + 0x85868687, 0x87868685, 0x8A888786, 0x8D8D8D8C, 0x7F81888E, 0x83848481, 0x8A8B8A89, 0x7A7D8287, + 0x6A6E7479, 0x77736E69, 0x857E7A7A, 0x868B8E8C, 0x7E7D8185, 0x8E8D8983, 0x7A7F8181, 0x72707074, + 0x7871737A, 0x86868581, 0x8E8B8682, 0x8C8D8D8F, 0x8583878D, 0x938D8787, 0x77778799, 0x8585847F, + 0x908C8887, 0x8A8D9193, 0x6D6F7174, 0x5F5D6067, 0x7C76716E, 0x81838482, 0x73747679, 0x76767574, + 0x74757778, 0x64686E71, 0x56575C62, 0x706B635B, 0x72757A7F, 0x938A7E74, 0x81838484, 0x7A7C7E80, + 0x8D8C8279, 0x807F8187, 0x7E7C7A79, 0x82828181, 0x84868686, 0x74777C81, 0x6A6C6E6E, 0x78746E6B, + 0x817B7774, 0x88878784, 0x7C7E8081, 0x7476777A, 0x6A6E7275, 0x67686969, 0x90908376, 0x72717784, + 0x7A7F8181, 0x817D7878, 0x92968889, 0x7990877D, 0x7A7C7973, 0x7A747073, 0x88888786, 0x7D7F8387, + 0x6D6E7375, 0x87817870, 0x7C828789, 0x7B797677, 0x94847A78, 0x93959A9D, 0xB2A9998E, 0x9BA0AAB1, + 0x8C898887, 0x92918F8D, 0x7C818689, 0x938D837D, 0xA5B0A594, 0x837F808E, 0x83838485, 0x87838182, + 0x908B8580, 0x93939392, 0x989D9992, 0x818D9797, 0x6A747E85, 0x60616265, 0x575C5F62, 0x52525354, + 0x55555453, 0x58565554, 0x6868615A, 0x786E6464, 0x85918F84, 0x787E7E7C, 0x7F7C7A78, 0x83828180, + 0x7A7E807F, 0x998D7F78, 0x817B818C, 0x87878787, 0x737E8381, 0x70767771, 0x877D7775, 0x727E8B8E, + 0x6E646266, 0x746E6C70, 0x706D6B6E, 0x87776C6E, 0x919B8E8A, 0x867D8386, 0x777B7B7A, 0x74727073, + 0x83827F7B, 0x7F818383, 0x797B7D7E, 0x74747577, 0x75767676, 0x74747474, 0x7B7A7776, 0x76777A7B, + 0x7A7A7978, 0x7A7A7A7A, 0x89878481, 0x85858687, 0x8A888684, 0x8486888A, 0x82828385, 0x83848483, + 0x777B8083, 0x76757474, 0x75747575, 0x7A7A7876, 0x74757676, 0x75757474, 0x75747474, 0x76767675, + 0x77777778, 0x76767676, 0x76777878, 0x74747475, 0x7A797776, 0x7A7A7A7A, 0x74787572, 0x706C6A6E, + 0x867E746E, 0x777C8387, 0x76767677, 0x7C7B7A77, 0x81807F7F, 0x81818181, 0x7F7E8081, 0x81828281, + 0x81838484, 0x6F73777C, 0x736E6B69, 0x85827D78, 0x82828383, 0x7D7E7F81, 0x7A7D8184, 0x82807B7A, + 0x93928F8D, 0x86898D92, 0x7F838789, 0x7777797B, 0x686D7274, 0x64636365, 0x7C756D68, 0x787A7E7F, + 0x6A707578, 0x5C5C6064, 0x7D7A7674, 0x7C7D7F7F, 0x71797D7F, 0x5F5F6168, 0x6A686563, 0x6C6C6C6C, + 0x68676868, 0x8A82766D, 0x6E73818D, 0x7C7C7A73, 0x6C686C73, 0x747A7C76, 0x6F6F6F6F, 0x60646A6E, + 0x60616467, 0x746F6862, 0x7D7D7B7A, 0x78787A7B, 0x8B827D7D, 0x92919291, 0x7E828687, 0x8285837F, + 0x757D878D, 0x78757271, 0x7A7A7978, 0x7174767A, 0x79716E6E, 0x84868681, 0x797F8890, 0x84827E7A, + 0x747F827F, 0x78756F6D, 0x6E6E7073, 0x6A6C6E6E, 0x6E757068, 0x69615B62, 0x7C7A7571, 0x7374787B, + 0x6971787A, 0x5C5C5C62, 0x7A797064, 0x878C897F, 0x7D7F8181, 0x7E7E7D7D, 0x86848281, 0x777B8185, + 0x7B797775, 0x8683807D, 0x898C8B89, 0x7F7F8184, 0x89878686, 0x767D868A, 0x877F7A79, 0x78828D8E, + 0x83828181, 0x8D898684, 0x7A7D8793, 0x74747679, 0x726F6E6E, 0x74767675, 0x65676D73, 0x65686868, + 0x7A6F6866, 0x92918D84, 0x8D898582, 0x86888B8D, 0x90929395, 0x86888C8E, 0x6E727C85, 0x70737370, + 0x83817972, 0x78787A80, 0x7B7F8080, 0x60646C74, 0x78787169, 0x87847E79, 0x7F7D7B7A, 0x81818181, + 0x7A7C8083, 0x787A7B7B, 0x68696F75, 0x565D6568, 0x80746256, 0x5B657480, 0x59565351, 0x6563615C, + 0x5E606366, 0x5A5B5D5E, 0x65615D5C, 0x706E6C69, 0x75737170, 0x7E7D7B79, 0x74797F83, 0x72727373, + 0x746E6A66, 0x6B747C7A, 0x746A6464, 0x78757578, 0x7B828381, 0x6D6C6D73, 0x726E7279, 0x62676F74, + 0x7D756E68, 0x80818281, 0x7577797A, 0x71717273, 0x74737170, 0x74757574, 0x77737476, 0x7B80817E, + 0x71717579, 0x696E7374, 0x68686869, 0x716F6D6A, 0x787B7A75, 0x7A7A7976, 0x7474777A, 0x666C7375, + 0x595D605C, 0x626F7162, 0x595C5855, 0x54515155, 0x595C5B59, 0x52515155, 0x57565554, 0x5C5B5A58, + 0x6A6B6B6A, 0x60626568, 0x5B575C63, 0x7168625F, 0x7F818181, 0x7374767A, 0x8184817D, 0x70707279, + 0x69696D71, 0x8882796F, 0x827C7876, 0x6E768185, 0x71696268, 0x70757370, 0x6F6E6D6A, 0x706F6E6F, + 0x706E6D6C, 0x76757472, 0x71737474, 0x65686A6E, 0x6D746F63, 0x7A706562, 0x808A8781, 0x59585E6E, + 0x68686868, 0x6E6C6A68, 0x62627E76, 0xB0377E7F, 0xE8EBD6E6, 0x201E19E8, 0x3F661012, 0x59484F5C, + 0x81639143, 0xBB31151E, 0xD2CAEBD6, 0x6280A2CA, 0x747D6177, 0xE3EBE53A, 0x1035E2DB, 0x58605839, + 0x744E617C, 0x17101C10, 0xE5EBE2E3, 0x61616EEB, 0x60626566, 0x5A5B5C5D, 0xBE43496E, 0xE7EBDED3, + 0xEBE5DBE4, 0xE2EBE9D2, 0x68E8E0DF, 0x535B4C69, 0x5C5B5B5B, 0x5C5C5C5C, 0xEB196A46, 0xE0E0EBE2, + 0x4D301014, 0x555F6659, 0x8D765950, 0x10421086, 0xDFE4EBE5, 0x8563EAE1, 0x595C6265, 0x615E5B58, + 0x5E5E6265, 0x5E606160, 0x595A5E62, 0x4E53585A, 0x423C5C4F, 0xC3D82844, 0xEBE5CBEB, 0xEBDFE2DF, + 0xE9E7E0E3, 0x3D52E5EB, 0x4C4A4948, 0x5251504E, 0x56625754, 0xE8E91F56, 0x28EAE5D6, 0x3D572110, + 0x626E5253, 0x10103336, 0xE2E9D821, 0x6D39DCE9, 0x44424344, 0x6660564B, 0x56595C5D, 0x52525254, + 0x50505050, 0x51515150, 0xDA354533, 0xCFEAEBDD, 0x1C241FD9, 0x7D381020, 0x56565656, 0x56565656, + 0xDB391912, 0xEBE7EBE8, 0x4C6891B0, 0x44474644, 0xEBE6E61A, 0x192BD6DB, 0x49614831, 0x3D515B41, + 0x103C473A, 0xEBBF1E2D, 0xE8E7DCEB, 0x555C5A6F, 0x4A4A4949, 0x5756514E, 0x52525150, 0x4C4E5051, + 0x25384446, 0xE5EBD5EB, 0x101528D2, 0x62566E5E, 0x11565371, 0xEB101716, 0xDFE8DAEA, 0x39372B4C, + 0x5856523D, 0xCA21473C, 0xDBE7DCEB, 0x4124102E, 0x3E645B5B, 0x13145431, 0xEBC31029, 0x52D6EBE4, + 0x645F5A56, 0x65666868, 0x62676562, 0x3E434B57, 0x594C4F62, 0xA6254A7B, 0xE5E7E7D2, 0x351932EB, + 0x52681610, 0x625C607A, 0x58687246, 0xC2181716, 0xD6D2EBBB, 0xA08FA1CB, 0x8D818275, 0x1E798F8D, + 0xE9DCE4E8, 0x5A7E69E9, 0x6358524F, 0x686D706D, 0x67628C6D, 0x648E4A75, 0x6B6D7A8A, 0x74706E6D, + 0x8481786F, 0x74757980, 0x5C60666A, 0x57595B5C, 0xE8206074, 0xEBDDE7EB, 0x5C5C5C5C, 0x5C5C5C5C, + 0x6E6D6C6C, 0x7171706E, 0x64726E6D, 0x1B52727A, 0xE6E4EBE2, 0x182BC8EB, 0x554C4245, 0x6E5D4A4C, + 0x21324644, 0xE3D37515, 0x4CE5EBEB, 0x55516056, 0x5D5B5653, 0x595A5B5C, 0x49545D62, 0x2B2E353E, + 0x877B7574, 0x828A9290, 0x81818181, 0x84838281, 0x7A7C7D7E, 0x77777879, 0x74747576, 0x78777574, + 0x87888989, 0x81808183, 0x8C87817B, 0x8A8B8C8D, 0x84858787, 0x89878684, 0x878B8D8D, 0x7C7E8184, + 0x6B717A82, 0x756E6868, 0x817C7774, 0x82838584, 0x82818284, 0x8D8D8A87, 0x6F757D83, 0x6E6E6E6D, + 0x7F7C7B7A, 0x88878481, 0x8E8B8784, 0x898C8E90, 0x85868788, 0x918E8A87, 0x767A848C, 0x87847F79, + 0x8F87878A, 0x969B9E99, 0x6D737A7F, 0x68676768, 0x7978746E, 0x74797B7A, 0x6C6B6E6F, 0x7A79746F, + 0x686E767C, 0x68686666, 0x6D6C6660, 0x7A746D6B, 0x6E7B7F79, 0x817B7068, 0x7A7B8185, 0x7A7B7C7B, + 0x817D7A7A, 0x7A7F8485, 0x7C787575, 0x757A7E7F, 0x7D7D7F80, 0x797A7D7E, 0x6A6C6F72, 0x7B776F6B, + 0x7E7A7776, 0x87878783, 0x7B7F8386, 0x7A7A7979, 0x6F747576, 0x6766676A, 0x8F908A7F, 0x71697387, + 0x85838180, 0x81828485, 0x88898B8D, 0x81848788, 0x747A7A77, 0x79716B6C, 0x99999894, 0x8F969A9A, + 0x746C6D7D, 0x8F877A74, 0x7C848889, 0x7B767374, 0x93908880, 0x81889193, 0x91878382, 0xA5A6A59C, + 0x96959493, 0x90929395, 0x7E818890, 0x8F87817E, 0x989F9F9B, 0x8886868D, 0x87888D91, 0x85878887, + 0x83848687, 0x908D8985, 0x8785878A, 0x7E858B8B, 0x63697176, 0x5C5D5F61, 0x595C5D5E, 0x53545657, + 0x52535353, 0x52525252, 0x50515353, 0x6B625750, 0x817F756D, 0x7D7A797C, 0x817B7A7F, 0x85818184, + 0x807D7C7E, 0x89848181, 0x86878681, 0x81888B88, 0x73747A80, 0x8387877C, 0x8E817A7D, 0x8C8F9598, + 0x827E7D88, 0x7174747A, 0x6B615C62, 0x7E6F686E, 0x8B8D8A83, 0x767F8687, 0x7B777271, 0x66646A75, + 0x9A8E7A74, 0x8F918F94, 0x75797E83, 0x6F727474, 0x76767474, 0x7B7A7776, 0x74787B7D, 0x7A767372, + 0x7A797776, 0x7A7A7B7B, 0x88878481, 0x86868687, 0x88878584, 0x84858788, 0x84838383, 0x85858584, + 0x747A8083, 0x71707071, 0x716F7174, 0x77797975, 0x73737577, 0x79797875, 0x72747678, 0x78767472, + 0x77777778, 0x7A797878, 0x7E7E7A78, 0x78787A7C, 0x7A787675, 0x7A7A7A7A, 0x787A7674, 0x6B6B6E73, + 0x867C7471, 0x747C878B, 0x7173777A, 0x7C797471, 0x7F7C7A79, 0x81818181, 0x7A7C7F81, 0x817F7C7A, + 0x81808080, 0x71767D81, 0x736E6967, 0x81807C78, 0x81828383, 0x82828181, 0x747B8184, 0x80797270, + 0x93908B88, 0x888C9093, 0x8286898C, 0x72757A7F, 0x686B6E71, 0x60616264, 0x706B6865, 0x7C7A7874, + 0x5F6E797F, 0x57535054, 0x807B7169, 0x7C7B7C7F, 0x737A7B81, 0x5F5D585F, 0x68676360, 0x6C6B6969, + 0x81756F70, 0x83818386, 0x6A6E7A84, 0x7D7B776F, 0x6C686D72, 0x69707573, 0x68746D61, 0x64564B54, + 0x60616262, 0x75706862, 0x7C7A7878, 0x74787B7E, 0x87838589, 0x878D908D, 0x81818283, 0x87868482, + 0x72798185, 0x7D78726F, 0x8787847D, 0x77808787, 0x79727072, 0x80838581, 0x777D8386, 0x87807774, + 0x7C818587, 0x7F7B7979, 0x68686F79, 0x706E6D6B, 0x8A937E64, 0x8E776671, 0x80838586, 0x7475787C, + 0x6970767A, 0x5C5D5F63, 0x747A7263, 0x787F7D74, 0x7F81807A, 0x81848480, 0x87848281, 0x7E818587, + 0x80848381, 0x85797075, 0x8C8D8C8C, 0x87888A8B, 0x87878787, 0x87878787, 0x8D808085, 0x74899D9E, + 0x7E776C62, 0x85828181, 0x818A8C8A, 0x6E6E7076, 0x73716E6C, 0x7A787574, 0x68696F77, 0x62626468, + 0x746C6662, 0x9591887F, 0x8E8C867F, 0x8A88888B, 0x93939494, 0x85878C8F, 0x74757E89, 0x7C7A7978, + 0x8A827B7A, 0x73757E89, 0x7D7F8080, 0x676B7178, 0x6E747471, 0x7676736D, 0x827C7875, 0x898A8A87 +}; + +static gctUINT32 ppuMem4[] = +{ + 0x7E83898D, 0x807E7B7B, 0x84817F7F, 0x5C687A83, 0x7E766C66, 0x616A777F, 0x5C5B5856, 0x625F5C5C, + 0x52515A62, 0x52585C58, 0x60585554, 0x70716F69, 0x71696A6E, 0x787F827D, 0x72747D87, 0x6D6D6E71, + 0x877F736A, 0x6A737F87, 0x6B686868, 0x7A78746E, 0x767A7B7C, 0x67696E72, 0x716E6E6E, 0x686E7274, + 0x7A75706C, 0x7D7D7D7C, 0x7477797A, 0x6E6E6E70, 0x72716F6E, 0x74747473, 0x75747474, 0x75757575, + 0x72747475, 0x70707071, 0x6E6A6868, 0x76767572, 0x78757678, 0x7D7F7F7C, 0x81807D7A, 0x686E787F, + 0x625E6062, 0x67696B68, 0x62625C55, 0x5352555C, 0x5C5C5B59, 0x5052565A, 0x56504F50, 0x68625E5C, + 0x7B7E7468, 0x6260626E, 0x59565B62, 0x726B645E, 0x7D818283, 0x76757679, 0x72747472, 0x726F6E6E, + 0x73727170, 0x87817A75, 0x7C74757A, 0x747F8786, 0x706A686E, 0x747B7872, 0x78747475, 0x6F747A7B, + 0x706D6C6C, 0x72737473, 0x74797874, 0x66626269, 0x6A6A6B6B, 0x6D6C6A6A, 0x807B7168, 0x5C636F7A, + 0x62636566, 0x65646362, 0x61516277, 0xE0226E5C, 0xE5EAE6E2, 0x48627ACA, 0x4C514837, 0x4E4E4A46, + 0x78575350, 0xE610687C, 0xDFE2DBE0, 0x504E58EB, 0x1026109F, 0xEBE6BD38, 0x7483AEEB, 0x5E5A5561, + 0x716D645C, 0x1834566C, 0xE8EBE2E6, 0x181531D3, 0x5B5D6162, 0x605D5C5A, 0xD1154469, 0xEBE8E8EB, + 0xCDEBDCEB, 0xEBDDEBDC, 0x5DE6E8EB, 0x47594A56, 0x5C5C5550, 0x5D71564A, 0xEB10616A, 0xE3EBD5EB, + 0x3E524456, 0x64645C56, 0x8C716370, 0x2E5C4E55, 0xE7E8E9EB, 0x6788B7D9, 0x50535B60, 0x605C5651, + 0x5C5D5E5F, 0x52545659, 0x57565554, 0x4B4E5256, 0x4A705252, 0xEBD8173F, 0xCDDFEBD4, 0xE5EBDCEB, + 0xE8EBE2EB, 0x4A57E5EB, 0x4E4C4B4B, 0x5251504F, 0x3B105F60, 0xEBC93914, 0x5DDFCBEB, 0x4B58522C, + 0x6259504A, 0x314A6369, 0xEBCECA29, 0x1043E4D6, 0x4F483E5C, 0x685E5D3A, 0x565B5C5C, 0x4E4D4D50, + 0x50504E4E, 0x4D4E5050, 0xDC193F49, 0xEBE3EAE2, 0x6F7457C9, 0x50465B4B, 0x5860686E, 0x53535254, + 0xE715402F, 0xE0EBEBE9, 0x385662DF, 0x29403755, 0xDDEBEB16, 0x5F3FE7EB, 0x553D4245, 0x2A4D4853, + 0x446F233E, 0xD9C93E3B, 0xC5EBE5E8, 0x434F4C71, 0x4547494A, 0x5D564E47, 0x504F5256, 0x4E515554, + 0x56105012, 0xC4EBE8DB, 0x314B87BB, 0x565A523D, 0x524A5648, 0x8725235A, 0xCBEBE6EB, 0x23331A53, + 0x5B51394C, 0xE8103F5C, 0xD9E2EBE5, 0x504C293C, 0x4A544B40, 0x513E3D40, 0xE9E11948, 0x5CE9DEEB, + 0x615D5957, 0x67676664, 0x4D84534D, 0x38584348, 0x5E3E595A, 0xDE16627A, 0xE1EBD4E9, 0x52607CD6, + 0x5D63686C, 0x5A585758, 0x6D5F6552, 0xE619767C, 0xEBEBE6E3, 0x7E626FDE, 0x8E938083, 0x31315410, + 0xE8EAEBE8, 0x84875FD3, 0x686C7174, 0x6F6D6967, 0x5C5A5E5E, 0x60636A68, 0x76666462, 0x74876868, + 0x857A627F, 0x836B5C93, 0x695F6462, 0x124D515B, 0xDB28121D, 0xE4E3E9E6, 0x4A4A4A4A, 0x4A4A4A4A, + 0x8B626B68, 0x5458807A, 0x7878736F, 0x145D526A, 0xD8EBEAB7, 0x648DCADE, 0x4A544A61, 0x5D56474F, + 0x3B476A43, 0xE8EB123C, 0x4DE2EBE6, 0x55536059, 0x55555454, 0x59585756, 0x45555C5C, 0x3B322D34, + 0x8078726F, 0x81858786, 0x7F808080, 0x8181807F, 0x7C7D7E7E, 0x7C7C7C7C, 0x7A7A7A7B, 0x7D7C7A7A, + 0x83878787, 0x7A7A7B7F, 0x8B867E79, 0x8C8C8D8D, 0x84868789, 0x87868484, 0x86878989, 0x7A7B7F82, + 0x696D767F, 0x756E6968, 0x7A777574, 0x80807E7C, 0x817F8081, 0x8B8A8884, 0x7A7E8286, 0x71737578, + 0x807D7B7A, 0x88878582, 0x8F8D8887, 0x888B8D8F, 0x87878889, 0x8E8C8987, 0x74777E85, 0x89878179, + 0x938D8B8B, 0x9A9B9B99, 0x787E858A, 0x74747474, 0x6F737472, 0x6D6F706E, 0x67656668, 0x74736F6A, + 0x686A6E72, 0x65666767, 0x74736D66, 0x817A7474, 0x707A7E7C, 0x7B746C69, 0x73737475, 0x74747474, + 0x7B787676, 0x74797E7F, 0x75727171, 0x73757878, 0x76747474, 0x78797A79, 0x6F747574, 0x7C756E6C, + 0x7B787675, 0x8181817F, 0x7A7C7E80, 0x79787879, 0x73777A7A, 0x69696A6E, 0x93948D80, 0x776E778B, + 0x85878582, 0x86838182, 0x85858687, 0x80828485, 0x70777A7A, 0x756F696A, 0xA3A29F9B, 0x989EA4A4, + 0x77717382, 0x90897D77, 0x7E858B8D, 0x817E7A79, 0x94948F88, 0x747E8890, 0x7A737274, 0x9C999387, + 0x90929496, 0x95939290, 0x81848C93, 0x8B857F7F, 0x8D91918E, 0x89858285, 0x8B8D9093, 0x8B8C8D8C, + 0x81828384, 0x86858382, 0x85818184, 0x79808788, 0x60646B6F, 0x5A5B5C5D, 0x585A5B5B, 0x55555657, + 0x51525253, 0x50505051, 0x484C5051, 0x5B544B47, 0x78756A5F, 0x8D827876, 0x817C8188, 0x787A8083, + 0x7B787A80, 0x8D878280, 0x8E93938F, 0x82878B8C, 0x77777D81, 0x8A8E8C81, 0x978A8688, 0x96999F9F, + 0x9593939D, 0x7A7C7E88, 0x6D646269, 0x7D6F686D, 0x858A8781, 0x6F757B80, 0x76736D6B, 0x61606671, + 0x98887571, 0x92949395, 0x75797E81, 0x70727474, 0x77777675, 0x817E7A78, 0x7A7E8182, 0x79777576, + 0x807E7D7C, 0x80818181, 0x85858280, 0x81818284, 0x85848382, 0x82838485, 0x83828181, 0x87868584, + 0x777A7F81, 0x76757474, 0x74737374, 0x76777775, 0x74747576, 0x77787876, 0x71727474, 0x74747271, + 0x74747474, 0x76767574, 0x7F7F7B79, 0x78797A7D, 0x76757474, 0x77777777, 0x7A7B7B7A, 0x7B7A7A7A, + 0x79706E71, 0x78808683, 0x6F727579, 0x7975726F, 0x7C7A7877, 0x80807F7E, 0x76787A7C, 0x7C7A7876, + 0x83817F7F, 0x7D818485, 0x7A777574, 0x7F7E7D7B, 0x81828383, 0x81818181, 0x777B8082, 0x837F7976, + 0x8F8E8D8C, 0x8B8C8D8F, 0x82868A8D, 0x73767A7F, 0x65696E71, 0x5F5F6062, 0x6863615F, 0x73716E6B, + 0x69717474, 0x5C5A5A60, 0x7E7A716A, 0x7B7A7B7D, 0x7277767C, 0x63625C62, 0x6E6A6662, 0x7372706F, + 0x887F7979, 0x8686898D, 0x6467737E, 0x7979746B, 0x67666C74, 0x666C706E, 0x75796857, 0x5B545462, + 0x5F5C5C5D, 0x74716B64, 0x7C7A7877, 0x777A7D7E, 0x807A7A7E, 0x868A8D87, 0x83818386, 0x8B8B8986, + 0x76777C81, 0x7C7D7C79, 0x7A7F817F, 0x777B7C7A, 0x7A747172, 0x7B808481, 0x71747577, 0x7C787471, + 0x7A7B7D7F, 0x7F7E7B7A, 0x696B7178, 0x69666568, 0x898B7C6C, 0x93867A7E, 0x84888B8C, 0x76787B80, + 0x6E737679, 0x61626568, 0x73796F5E, 0x787B7770, 0x7E7F7D79, 0x85878680, 0x8C888789, 0x898D908F, + 0x8B8F8D8C, 0x827A7780, 0x8F8E8E8E, 0x9090908F, 0x84848687, 0x84858585, 0x81797E87, 0x7585928F, + 0x7F786C63, 0x7F7F7F81, 0x71747675, 0x71737371, 0x7474716E, 0x7B797775, 0x6868717A, 0x66666868, + 0x69666362, 0x7E7B756F, 0x8C8B8580, 0x86858689, 0x8B898887, 0x8C8C8C8C, 0x7A7A818A, 0x7F7E7E7D, + 0x91877D7A, 0x6E758391, 0x78797877, 0x6E707476, 0x6E747673, 0x696C6C6B, 0x8178706C, 0x8D8D8D88, + 0x7D82878B, 0x7F7C7A7A, 0x918D8887, 0x747D8990, 0x817F7A78, 0x686F7980, 0x65626263, 0x6C6E6E6A, + 0x5B5B6065, 0x575C5E5D, 0x635C5653, 0x7474716B, 0x76757473, 0x88837C78, 0x6C6E747E, 0x6A696B6D, + 0x817B746E, 0x6B717A80, 0x6F6F6F70, 0x74737170, 0x74747575, 0x6F707173, 0x79726F70, 0x71798080, + 0x76746F6D, 0x7A7A7A79, 0x72747778, 0x6D6C6D6E, 0x6E6D6C6B, 0x6E6E6E6E, 0x6E6E6E6E, 0x6F6F6E6E, + 0x73747475, 0x6E6F7072, 0x6D6A6A6A, 0x73747370, 0x7A757271, 0x8383827F, 0x77787A7D, 0x686D7275, + 0x5F5E6164, 0x5B5E6262, 0x66635D57, 0x5C5C5E62, 0x5B595858, 0x5155595C, 0x56504E50, 0x67625D5B, + 0x747A746D, 0x68626168, 0x5B575B62, 0x746E6862, 0x75797C7E, 0x7F7A7674, 0x75797A7C, 0x74737272, + 0x827E7874, 0x82828383, 0x7E78787A, 0x7A818785, 0x73727075, 0x767A746F, 0x7A787675, 0x70747A7C, + 0x73706E6E, 0x70727475, 0x7074706B, 0x6C686669, 0x696A6C6E, 0x6467696A, 0x74706C69, 0x62666E73, + 0x5F606162, 0x6261605F, 0x695D6671, 0xC7216E61, 0xEAEBE6DF, 0x35567ACD, 0x50565147, 0x4D51514D, + 0x7367574A, 0xE912505B, 0xE8EBE8EB, 0x755850EB, 0xE0D12B6C, 0xE4EBEBD6, 0x5637252C, 0x52535860, + 0x68676462, 0x4C5A666A, 0xD6A81F1C, 0xEAE2C5EB, 0x595B5E61, 0x605D5B58, 0xD7356073, 0xE8E5EBEB, + 0x2BCAEBE1, 0xCEEBCF1F, 0x5CE5E8EB, 0x45584854, 0x5759534F, 0x4A624D44, 0xE52D6867, 0xE0DCDCEB, + 0x5559505C, 0x775D4F56, 0x6351767D, 0x235E5679, 0x23201310, 0x6E553726, 0x484D5256, 0x55504A47, + 0x57595A5A, 0x51525456, 0x54545352, 0x4A4C5052, 0x556B4A47, 0xE6DC3356, 0xEBEBE5EA, 0x1922EBCA, + 0xE8EBE2EB, 0x4A57E5EB, 0x504F4E4D, 0x52525150, 0xD03C5F54, 0xE1EBCAD2, 0x443116E0, 0x3946403B, + 0x4D4C4E4E, 0x5D625F56, 0xDF251610, 0xE1D5EBE5, 0x4B505CB5, 0x4F4D4B41, 0x53555554, 0x504F4E50, + 0x504F4E4D, 0x4E4F5050, 0xEB254868, 0xEAD1DFEB, 0x5A444DEB, 0x472F4B4E, 0x54585958, 0x514F4D4F, + 0xEB1E5555, 0xE0E3D0DE, 0x444F5CEB, 0x2E513B5D, 0xC9D0E627, 0x5442E3E7, 0x5151543D, 0x4A5E4442, + 0x2B50453D, 0x1E16102A, 0x351E1018, 0x48565444, 0x44454849, 0x4E4A4543, 0x51505357, 0x50545656, + 0xE0E8EA18, 0x2EC8E8EB, 0x69614A36, 0x53525662, 0x4D565B54, 0x2B3D4E50, 0xEBE4BC42, 0x5EC3C1D7, + 0x605D4338, 0xEB153D5D, 0xE8E8EBE2, 0x4B4C2F38, 0x5650444D, 0x525B5750, 0xE0E83052, 0x55E4EBE5, + 0x5A565250, 0x5E5E5E5C, 0x4B6B415C, 0x5852434A, 0x52395056, 0xEB326068, 0xEBEADCE8, 0x683A6CEB, + 0x585A5C5C, 0x56565657, 0x6A5C524C, 0xCF216E62, 0xEBEBE9EA, 0x816E7EE8, 0x7C69637A, 0xEBD7C72D, + 0xEBE3E0E9, 0x7C8768E9, 0x6E747A80, 0x76736E6C, 0x314F7280, 0x937B5B3A, 0x7C616168, 0x54736673, + 0x8C766E6B, 0x545D7887, 0x665D625F, 0x10484A55, 0xE9C6EBEB, 0xD6EBE7D5, 0x69696969, 0x69696969, + 0x6B6E686A, 0x725A4D5D, 0x67656568, 0x2C695661, 0x19181110, 0x7F644125, 0x63626367, 0x50564C59, + 0x5348624B, 0xEBDD1348, 0x6DDED8E2, 0x4E444F64, 0x4E505152, 0x4A4A4B4C, 0x434E514F, 0x38312E35, + 0x7D7A7571, 0x8482807F, 0x7C7E7F80, 0x7B7B7B7C, 0x807F7E7D, 0x83828181, 0x81818182, 0x81818181, + 0x7F838585, 0x7474767A, 0x89837B76, 0x8C8C8C8C, 0x8386888A, 0x81818181, 0x81828282, 0x75787B7F, + 0x66676E78, 0x76716C68, 0x74747475, 0x7F7C7A77, 0x7E7C7C7D, 0x88878682, 0x8D8D8D8D, 0x8083888B, + 0x817D7A7A, 0x87878683, 0x8F8D8A87, 0x878A8D8F, 0x88898A8B, 0x8A898988, 0x79797E83, 0x8E8C877F, + 0x93918E8C, 0x98979594, 0x7D82898E, 0x7D7D7C7B, 0x69717778, 0x65676765, 0x62626264, 0x69696865, + 0x6F6D6B6A, 0x686B6F70, 0x7D7A736B, 0x85807A7A, 0x73797C80, 0x746D686C, 0x6D6C6A69, 0x706E6E6D, + 0x7A777474, 0x71767C7D, 0x6D6C6D6E, 0x6F70706E, 0x706C6A69, 0x79797874, 0x767B7A76, 0x7B746E6F, + 0x76747474, 0x7A7A7A7A, 0x76767676, 0x76767676, 0x767D8182, 0x6667696E, 0x91938B7B, 0x7A707687, + 0x84878582, 0x827F7D7F, 0x7E7C7B7C, 0x7E808180, 0x6D73797C, 0x736E6968, 0xA7A6A39F, 0x9BA2A8A9, + 0x7C767987, 0x938E827C, 0x81878D93, 0x87868381, 0x9093928D, 0x7079838B, 0x746E6D6E, 0x928F897F, + 0x888D9398, 0x9D978F89, 0x878C939A, 0x88838184, 0x80818180, 0x8B86817F, 0x8A8C8E91, 0x8B8B8C8B, + 0x81818181, 0x7D7E7F81, 0x7E7A7A7B, 0x6F767E81, 0x5B5E6367, 0x58595959, 0x56575758, 0x55555656, + 0x50515152, 0x4D4E4F50, 0x42474B4C, 0x4E48413E, 0x6D6A5F54, 0x9787756D, 0x7E7A818C, 0x84878986, + 0x7A75777C, 0x9C948A82, 0x969E9F9E, 0x81858A8F, 0x79787C80, 0x91938F83, 0x9A908C8D, 0x999DA1A2, + 0x9B999399, 0x8483828D, 0x6E696A71, 0x7D6F686D, 0x80878781, 0x696C6F76, 0x74706A66, 0x5F60666F, + 0x8C7C6965, 0x8588878A, 0x76797D80, 0x70727474, 0x75757574, 0x86817B77, 0x81848585, 0x7E7C7C7E, + 0x8281807F, 0x82828382, 0x83838180, 0x7F7F7F81, 0x81818181, 0x81818181, 0x83818181, 0x87878584, + 0x7A7C7E80, 0x7D7C7A7A, 0x76777877, 0x75747474, 0x77757575, 0x74767879, 0x6F6F6F6F, 0x6F6F6F6F, + 0x72717070, 0x74747473, 0x80807C7A, 0x78797A7D, 0x75757575, 0x78777675, 0x837F7B7A, 0x87888987, + 0x6962676E, 0x7B818178, 0x6C6E7274, 0x74726E6C, 0x7A777574, 0x7E7D7D7B, 0x7476797A, 0x7A797674, + 0x83807E7E, 0x85878787, 0x81818282, 0x7C7D7F80, 0x81828282, 0x81818181, 0x7C7B7D7F, 0x89878480, + 0x8C8D8E8F, 0x8D8C8C8B, 0x8185898D, 0x74767A7E, 0x61676D70, 0x5E5D5C5D, 0x625E5C5B, 0x6E6C6865, + 0x7577726B, 0x6463666E, 0x7D7A746E, 0x79797A7C, 0x7576747A, 0x6A696468, 0x78746E6A, 0x7B7A7A7A, + 0x8C837E7C, 0x84868B8E, 0x5F616E7A, 0x78787468, 0x63646E76, 0x64696C68, 0x7C7A6855, 0x5A585E6E, + 0x645D5C5C, 0x7675736C, 0x7C7A7877, 0x7A7D7F7F, 0x7B747477, 0x83878A85, 0x807E8287, 0x8F8F8D87, + 0x7F7E8388, 0x81858784, 0x68727A7E, 0x73716B66, 0x7C747170, 0x767C8382, 0x676A6F73, 0x6B6A6867, + 0x76727273, 0x8181817C, 0x7176797A, 0x625E5F68, 0x7D77706C, 0x8D8A8681, 0x84888B8D, 0x77797C80, + 0x6E707273, 0x6466686B, 0x747A705F, 0x7778746E, 0x79787774, 0x8686827C, 0x8C88898C, 0x92949592, + 0x8E949697, 0x817B7A83, 0x8A888787, 0x8F8E8D8C, 0x80818487, 0x7F818181, 0x72727F8D, 0x7A81837C, + 0x8480766F, 0x787A7D82, 0x69696B6B, 0x7276766F, 0x7A787574, 0x807E7B7A, 0x6666707C, 0x68696B6A, + 0x63656869, 0x6C696764, 0x89898681, 0x81818186, 0x8481807F, 0x8E8D8A87, 0x7F7B8188, 0x80808182, + 0x93887E7A, 0x67748794, 0x72716F6E, 0x73747473, 0x6F757674, 0x6164676A, 0x7C716761, 0x8F8E8C86, + 0x7B818689, 0x7D7B7A79, 0x88878481, 0x8B8A8988, 0x8386888B, 0x767A7E81, 0x6E686C71, 0x767C7F79, + 0x666B6E6F, 0x5E5D5F62, 0x6F68615C, 0x7D7B7874, 0x80827D76, 0x8F857B7A, 0x6A6A6F77, 0x6A69696B, + 0x7975716E, 0x7174777A, 0x7477797A, 0x6A6B6E71, 0x6F6D6C6C, 0x7A787572, 0x8177767A, 0x7A858E8D, + 0x72717070, 0x78777574, 0x6F727577, 0x6A6A6B6D, 0x68696A6B, 0x62636466, 0x63636262, 0x64646463, + 0x73747373, 0x6E6E7072, 0x6C6B6C6D, 0x6E6E6F6E, 0x78716A65, 0x8B88847F, 0x6C727C85, 0x66686A6A, + 0x5D5E6164, 0x55585C5E, 0x67625C59, 0x65666868, 0x57555658, 0x54585C5C, 0x56504E50, 0x645F5C59, + 0x6C747470, 0x6E665E61, 0x5C565C64, 0x706E6A65, 0x6D6F7476, 0x8881766E, 0x8D8D8F90, 0x8184888B, + 0x8B867E77, 0x7D81868A, 0x7F7B7A7A, 0x7F818281, 0x7A7F7D81, 0x76756D6D, 0x82817C79, 0x74767B80 +}; + +static gctUINT32 ppuMem5[] = +{ + 0x7573706F, 0x6C707476, 0x6E6E6A64, 0x706B6869, 0x67666768, 0x61646868, 0x6868696A, 0x65666868, + 0x5D5E5F5F, 0x5F5F5E5D, 0x5C65635C, 0xBF245040, 0xD5DEE0E1, 0x415C7BBA, 0x54575652, 0x4E565A56, + 0x5A47464E, 0xE3246557, 0xE4E6E9EA, 0x715A58E7, 0xEBE71F6A, 0xEBE9DFDE, 0x625D5954, 0x5C535662, + 0x5D626869, 0x6264625E, 0xEBDE254E, 0xD6E8D9E3, 0x56595C5F, 0x5D5C5856, 0xAB355D5A, 0xDED5D3C6, + 0x46BBEBDA, 0xD4EBE019, 0x5AE5E8EA, 0x44574752, 0x5155514F, 0x3150433D, 0xB7191D10, 0xE8E1EBEA, + 0x74655437, 0x5F575C5D, 0x694F6365, 0x43627A7C, 0x504D5054, 0x61626059, 0x4C505456, 0x56514B49, + 0x54555656, 0x51515253, 0x50515151, 0x4A4C4D4F, 0x435C5665, 0xC0B72E45, 0xEBE4E7EB, 0x1F46EBD9, + 0xE8EBE2EB, 0x4A57E5EB, 0x51515050, 0x53525252, 0xD0104F5F, 0xEBEBEBEB, 0x25565FBB, 0x524A6E59, + 0x4A4C4B49, 0x625E564D, 0xDD102568, 0xEBE5E1D2, 0x45445EEB, 0x464C454B, 0x52535352, 0x54525050, + 0x504F4D4D, 0x50505050, 0xC526445B, 0xEBD6D6D6, 0x5B594FB7, 0x3D364A44, 0x51514A44, 0x4E4B4A4D, + 0xE7206347, 0xEAE8D9E5, 0x3E3D41E8, 0x25421036, 0xEBE9EA1D, 0x6C4CCAE0, 0x5F4E5344, 0x505B4D5C, + 0x6E705548, 0x38434762, 0x45414848, 0x4A424A51, 0x44464747, 0x4A484444, 0x52505458, 0x50545756, + 0xD9EBE910, 0x47E6E8DC, 0x3A273956, 0x4D687863, 0x4A46474B, 0x34495652, 0xEBE7E317, 0x43E5EBEB, + 0x68605944, 0xD0125D82, 0xEBE0E2E9, 0x3C5C5B4C, 0x3833444C, 0x3842504D, 0xEBE81024, 0x61C9DAE5, + 0x5758595B, 0x5E5C5A58, 0x122A104B, 0x45251010, 0x4D455D6A, 0xB5305453, 0xE4EBE1EB, 0x484565C2, + 0x56514E4D, 0x565A5C5B, 0x62504E63, 0xDF45825C, 0xDEDCE8EB, 0x807179DD, 0x5E546893, 0xEBE6D121, + 0xEBE8E9EB, 0x988F6DDD, 0x6F767F84, 0x77746E6D, 0x55576081, 0x626D5646, 0x805C6172, 0x2C5D667B, + 0x29102012, 0x64676E2E, 0x62595E5A, 0x10444550, 0xEBD2E0E2, 0xD6E2D0EB, 0x57575757, 0x57575757, + 0x5A746F61, 0x7E70554F, 0x5C56585D, 0x4977615D, 0x68594F5B, 0x6374726A, 0x615E665C, 0x4D594B51, + 0x5554672B, 0xEBDA317A, 0x4EDFEBEB, 0x4459553E, 0x44484B4D, 0x3A3B3D40, 0x3F45433E, 0x38323036, + 0x7777726D, 0x827B7574, 0x7A7D8081, 0x75767779, 0x817F7D7B, 0x87878583, 0x85868787, 0x82828384, + 0x7D818282, 0x73737478, 0x88827B75, 0x88898A8A, 0x81848788, 0x7A7B7C7E, 0x7C7C7C7B, 0x7274777A, + 0x6462676E, 0x79746F6A, 0x79797A7A, 0x817F7C7A, 0x7F7D7D7E, 0x88888783, 0x93918F8E, 0x8C8F9394, + 0x817E7B7A, 0x87878684, 0x8D8C8887, 0x888A8D8E, 0x8B8C8C8C, 0x8787888A, 0x7F7D8184, 0x92908C85, + 0x8D8D8D8E, 0x8D8D8E8D, 0x7A7D848A, 0x80807D7A, 0x6E777B7B, 0x6468696A, 0x62626466, 0x61626362, + 0x77726C68, 0x6E72787A, 0x817F766E, 0x817D7A7D, 0x74757980, 0x6F68666E, 0x66676563, 0x6C686564, + 0x847E7A77, 0x767D8487, 0x686B6E71, 0x6E6C6A68, 0x706C6969, 0x797A7975, 0x797B7A77, 0x7A767374, + 0x716F6E6F, 0x75767674, 0x71706F6F, 0x78767473, 0x747B7F81, 0x6566686E, 0x82878171, 0x766A6D7A, + 0x8283817F, 0x7374797E, 0x76727070, 0x7E7E7D7A, 0x6B70777C, 0x73706D6A, 0xA2A19D99, 0x969DA3A4, + 0x7F7A7A86, 0x98948780, 0x86878D92, 0x87898A88, 0x878A8986, 0x7F848787, 0x938D8987, 0x999B9B98, + 0x82889198, 0xA2998D84, 0x898D939A, 0x83808085, 0x827F7E7D, 0x918E8A86, 0x81838486, 0x7E7F8081, + 0x82817E7C, 0x7A7C8081, 0x74747477, 0x656B7274, 0x57595D60, 0x57575757, 0x54555656, 0x52525354, + 0x4E505050, 0x4A4A4B4D, 0x41454848, 0x4E48413F, 0x64625B54, 0x8D806F67, 0x7C798087, 0x93928F87, + 0x83818081, 0xA2978C87, 0x93999FA3, 0x7C82898E, 0x7876797A, 0x92938F82, 0x9C938D8C, 0x969BA2A3, + 0x97938B8E, 0x807D7B87, 0x6F6D6F75, 0x7E726B6E, 0x7C858682, 0x6564676F, 0x736F6761, 0x6062686F, + 0x8A7D6860, 0x797B7B83, 0x76797B7E, 0x71727374, 0x73737374, 0x87817A74, 0x87878583, 0x86858586, + 0x86858584, 0x87878787, 0x85868584, 0x80808182, 0x80818181, 0x81818180, 0x83828282, 0x85858484, + 0x7E7D7E7E, 0x8382817F, 0x767C7E7F, 0x74716F71, 0x7A777574, 0x7074797A, 0x6E6E6D6B, 0x6B6D6E6E, + 0x74737271, 0x77777675, 0x7F7F7C7A, 0x7576797C, 0x73747475, 0x76757474, 0x857E7976, 0x747A8387, + 0x615D626A, 0x7A7B776D, 0x68696C6E, 0x726F6B68, 0x77747372, 0x7C7B7A79, 0x73747678, 0x78767473, + 0x807E7D7C, 0x84848381, 0x84868787, 0x7C7D8081, 0x81818181, 0x7E7F8081, 0x807B7A7B, 0x8D8D8C87, + 0x8A8C8D8E, 0x8B8B8989, 0x7F82878A, 0x7274797B, 0x5D646B6F, 0x5D5C5A5A, 0x65625F5E, 0x74716E68, + 0x7C7C756D, 0x6E6C6E74, 0x7B7A7774, 0x74757679, 0x7B77737A, 0x73716E72, 0x81807B78, 0x7E7F8081, + 0x8B847E7B, 0x83878C8E, 0x60616E7B, 0x797A756A, 0x62636E79, 0x686B6C67, 0x76766C60, 0x6865656D, + 0x70686565, 0x7C7F807A, 0x7D7A7A7A, 0x7B7D7F7F, 0x7C767578, 0x81878985, 0x76757D85, 0x8E8D8980, + 0x85878D92, 0x85878786, 0x5F6A767D, 0x6E685F5B, 0x7C746E6D, 0x737A8283, 0x5F636B72, 0x65656360, + 0x746B6767, 0x8386857F, 0x81868481, 0x635F6371, 0x70686769, 0x8083847C, 0x7C7F8182, 0x7575777A, + 0x72727170, 0x6B6D6F71, 0x767B766A, 0x74787673, 0x706F6E6E, 0x807E7A74, 0x85838383, 0x8D8D8B87, + 0x81878D93, 0x7A747279, 0x82828181, 0x7C7D8081, 0x7C7C8185, 0x7D7F817F, 0x686F8292, 0x7F7E786E, + 0x87888581, 0x72757A82, 0x74787773, 0x70767975, 0x7E7B7976, 0x87858180, 0x6B687380, 0x6B6E7271, + 0x68676768, 0x7E7A746D, 0x87888784, 0x7D7D7F83, 0x7A7A7B7B, 0x83817F7C, 0x807B7D83, 0x7C7E8183, + 0x8B817B7A, 0x6371838D, 0x6E6D6C6C, 0x7271706E, 0x6E737372, 0x62636669, 0x756C625D, 0x8D89847D, + 0x7B808487, 0x7C7A7979, 0x75797A7A, 0x93887B74, 0x81858D92, 0x8482817F, 0x7A75787C, 0x81878984, + 0x6F797D7D, 0x63605E63, 0x817C746E, 0x8A878583, 0x8785807B, 0x86858687, 0x7271757B, 0x706F7072, + 0x75726F6D, 0x7A7A7978, 0x767A7C7D, 0x62656B71, 0x69666463, 0x807B756F, 0x847A7D84, 0x7E8A9491, + 0x70717475, 0x77767472, 0x6D707477, 0x68696A6B, 0x63686C6E, 0x56575A5E, 0x59585858, 0x5B5B5A5A, + 0x72706E6D, 0x6E6F7172, 0x6C6C6E6F, 0x696B6D6D, 0x716B645F, 0x8A847C76, 0x666F7F8B, 0x5F626263, + 0x605E5F61, 0x5C5E6161, 0x645E5B59, 0x67696B69, 0x5251575D, 0x55595B58, 0x55504F50, 0x625D5A58, + 0x676F7270, 0x71675D5D, 0x5B565C66, 0x69696863, 0x686A6E70, 0x8B82756C, 0xA09E9B9A, 0x8A929BA0, + 0x81817D7A, 0x7C7C7D80, 0x7E7F7C7A, 0x82807C7C, 0x828C8A8B, 0x716E676D, 0x85847D76, 0x74757A80, + 0x76736F6E, 0x6A6E7477, 0x6E706C67, 0x6B676468, 0x65646362, 0x68676665, 0x67696A69, 0x64626263, + 0x62626262, 0x63636262, 0x644F5468, 0x2A10827B, 0x2D211F20, 0x5350443E, 0x5A58544F, 0x50585E5C, + 0x6B615447, 0xEA104450, 0xEBE9EBE1, 0x575F79EB, 0xE5D9106C, 0xE2EBE5E4, 0x5063746E, 0x66534D4F, + 0x5B626666, 0x56585756, 0xEBEB1A69, 0xE3EBEBD8, 0x54585D61, 0x59565453, 0x30165A5A, 0x10101B21, + 0x492D1F1C, 0xE2E0DB26, 0x59E6E9EA, 0x43584850, 0x4E51504E, 0x1C443F3B, 0xEBD9E9E8, 0x1531C7E7, + 0x6758683B, 0x4C5E694B, 0x62595C64, 0x626C4C45, 0x56494A50, 0x46576865, 0x4F525659, 0x5755504E, + 0x52535354, 0x52525252, 0x50505151, 0x4E4E4E4F, 0x5C5C3F39, 0x10301252, 0x12101E10, 0x15392A30, + 0xE8EBE2EB, 0x4A57E5EB, 0x53535353, 0x53535353, 0xE010544E, 0xEAE3EBEA, 0x5A533CEB, 0x3E464447, + 0x4E4F4B47, 0x4D4C4B4C, 0xD6184E4F, 0xE8E5E6DC, 0x47304AE4, 0x4D524C4A, 0x50515252, 0x51505050, + 0x4F4E4D4D, 0x50505050, 0x35114B4F, 0x1019251F, 0x637F4C48, 0x434E513C, 0x544F463F, 0x4D4E5053, + 0xDD256E3D, 0xDEEBEBEB, 0x584F47EA, 0xE6D02543, 0xE2EBEBB9, 0x323C3126, 0x4C284458, 0x30333C5F, + 0x4949243C, 0x3A573E4A, 0x464F6056, 0x58373D4F, 0x49484645, 0x5955504B, 0x51515559, 0x4C505554, + 0xDEE0E842, 0x51E8E6E7, 0x5A514842, 0x4B515A5D, 0x3C34494F, 0x623E4453, 0xD3D9EB1C, 0x3EDFD1DC, + 0x50555F38, 0xEB2F6071, 0xE9E3DAE6, 0x31433F2D, 0x59585647, 0x3A3D4253, 0xEAE71666, 0x87E7E5E8, + 0x5A5F666A, 0x615E5A58, 0xEBD1335E, 0xB2DCE6EB, 0x515E7380, 0x491C4B4A, 0x2A2C1310, 0x3654442C, + 0x50494648, 0x4F565B59, 0x7E989D95, 0xE8103F47, 0xEBE9EBE2, 0x78717AE8, 0x615A6E94, 0xE4E3D624, + 0x2A29ABEB, 0x84784C2C, 0x757B8186, 0x7A787474, 0x5A535B70, 0x896F5C5B, 0x775E6978, 0x15576876, + 0xE1E2EBEB, 0x4F6BA3BB, 0x695C6260, 0x1250565E, 0xEBE8E8EB, 0x102A4DDE, 0x5B5B5B5B, 0x5B5B5B5B, + 0x66595D4F, 0x4E56695B, 0x4E48494B, 0x3D5C4D4A, 0x666C583E, 0x61767564, 0x2F4C5B68, 0x5A553528, + 0x30445953, 0xDFEB183F, 0x59D3E3DE, 0x3E3D4147, 0x3E424547, 0x3334373A, 0x3B3E3833, 0x3E383436, + 0x6E6D6761, 0x8078706E, 0x7A7E8182, 0x73747477, 0x817F7C7A, 0x87878684, 0x86878787, 0x81818284, + 0x7D818181, 0x75747679, 0x87827C77, 0x83848687, 0x7D808284, 0x7475777A, 0x77777675, 0x70727476, + 0x68626268, 0x7D79746E, 0x83828180, 0x86868584, 0x86838383, 0x8D8D8C89, 0x8B89898A, 0x888A8C8C, + 0x82807E7D, 0x87878684, 0x8D8B8886, 0x8A8B8D8D, 0x8C8D8D8C, 0x8787898B, 0x827F8081, 0x9493918A, + 0x86878C92, 0x81868988, 0x74767D83, 0x82817E79, 0x7B81817E, 0x686E7477, 0x63636567, 0x64656665, + 0x7A746E6A, 0x6E747A7D, 0x82817A73, 0x7D7A7A7D, 0x7473767D, 0x6E686971, 0x61626362, 0x68645F5E, + 0x8D867E7A, 0x7C858D91, 0x686E7477, 0x6E6B6867, 0x726F6E6E, 0x77787875, 0x75757677, 0x75767776, + 0x6C696869, 0x7374736F, 0x6E6C6C6C, 0x7B797471, 0x7075797A, 0x6565676B, 0x747C7A6C, 0x7367656D, + 0x81807D7B, 0x656D777F, 0x716C6868, 0x7E7E7B77, 0x6F72777C, 0x77767470, 0x99999590, 0x8F969B9B, + 0x7F79767F, 0x96958A81, 0x8987878B, 0x81878D8D, 0x7E7F7F7D, 0x93928B82, 0xA8A5A2A1, 0xA6A8ABAB, + 0x80858D94, 0xA2998D82, 0x85898F95, 0x7C7A7A81, 0x88828181, 0x93949490, 0x7A7B7A7A, 0x71727478, + 0x807C7976, 0x7A7B7F81, 0x6C6F7478, 0x6063686A, 0x5556595C, 0x56565656, 0x51535454, 0x4D4E4F50, + 0x4B4D4E4E, 0x4848494A, 0x44474847, 0x504A4442, 0x5E5B5857, 0x78736B63, 0x83807E7D, 0x86898A87, + 0x8C8E8B88, 0x968B8185, 0x898C949D, 0x787F878A, 0x7A777878, 0x90938E83, 0xA098908A, 0x949BA3A5, + 0x999A9396, 0x71717385, 0x72707175, 0x7E746E70, 0x767E807F, 0x605D5F69, 0x746F655C, 0x62666C71, + 0x93897166, 0x7C7C7C87, 0x77797A7B, 0x72727374, 0x72737475, 0x85807874, 0x8A888683, 0x87878889, + 0x8C8C8C8C, 0x8D8D8D8C, 0x898A8A89, 0x84848486, 0x82828384, 0x84838282, 0x85858686, 0x82838384, + 0x807F7D7D, 0x85848381, 0x767E8385, 0x74706E6F, 0x7C797574, 0x6D72797C, 0x716E6C69, 0x696C6E71, + 0x7A787574, 0x7C7C7C7B, 0x7D7D7B79, 0x7374767A, 0x70717273, 0x7271706F, 0x78777676, 0x5C656F76, + 0x62616367, 0x74716C66, 0x64636566, 0x716E6A66, 0x74727070, 0x7B7A7876, 0x70727476, 0x76747270, + 0x7B7A7A79, 0x81807E7C, 0x81818181, 0x7D7E8081, 0x7F807F7F, 0x7A7B7D7F, 0x817A7877, 0x8D8E8E89, + 0x898A8A8A, 0x87888889, 0x7B7F8487, 0x70737578, 0x5C62696E, 0x5E5C5958, 0x6D686664, 0x7C7A7671, + 0x7C7F7B76, 0x74717175, 0x76777675, 0x6F6F7174, 0x7E746E76, 0x7C7B777A, 0x86878583, 0x7A7A7D81, + 0x8A857E7A, 0x868B8E8E, 0x6365727E, 0x7778746C, 0x5F616B75, 0x696C6C65, 0x71736E6A, 0x78736E6E, + 0x7E777474, 0x82878986, 0x7E7C7B7B, 0x797B7F80, 0x7A737274, 0x81868884, 0x6D6E7781, 0x89878175, + 0x8D908E8C, 0x82828489, 0x676F797E, 0x6A656060, 0x7A706A68, 0x727A8181, 0x6666686B, 0x68696B69, + 0x74686261, 0x85878781, 0x8C8F8C88, 0x69676D7D, 0x716C6C6E, 0x7A7D7E79, 0x73737474, 0x76757474, + 0x7B7A7776, 0x78797A7B, 0x777A7B78, 0x6F767A77, 0x6C6A6A6B, 0x7674706E, 0x7E7E7A77, 0x86827E7D, + 0x7B7E8287, 0x68686D75, 0x7A7A7A79, 0x6E717478, 0x7A77797A, 0x8182817E, 0x68728391, 0x807A7168, + 0x81858787, 0x6F71757A, 0x838B8476, 0x7276787A, 0x7D7A7674, 0x89878380, 0x736F7884, 0x6E737979, + 0x72696462, 0x9F988C7E, 0x84878787, 0x7B7C7E81, 0x7475787A, 0x76757473, 0x817B7B80, 0x797C8185, + 0x7A777778, 0x67717B7E, 0x6C6B6B6C, 0x71706E6D, 0x6A6E6F71, 0x63626266, 0x6E696461, 0x84807973, + 0x7A7E8285, 0x7A7A7979, 0x7A80817E, 0x90857A76, 0x7A81898F, 0x83817D7A, 0x84818182, 0x8A8B8A87, + 0x717D8384, 0x6C656165, 0x8B867E78, 0x94928E8D, 0x8680848B, 0x7C879290, 0x7D7D8085, 0x7877787C, + 0x7473706E, 0x7A797877, 0x74777979, 0x5E62686E, 0x63605E5E, 0x7B787169, 0x7E777B83, 0x818B918B, + 0x7072777B, 0x78777472, 0x6B6E7477, 0x68696A6A, 0x60666A6D, 0x5052565A, 0x53525151, 0x56555554, + 0x706D6A68, 0x70717271, 0x6D6E6F71, 0x686A6C6D, 0x69686664, 0x7A746E6A, 0x646C7982, 0x5C5E6061, + 0x64626060, 0x63656666, 0x625D5C5C, 0x66696B68, 0x50525C64, 0x55575754, 0x55505051, 0x605C5857, + 0x676D6D6A, 0x6E675F5F, 0x5A545B64, 0x68696863, 0x69696C6D, 0x857E746C, 0x928F8F8F, 0x848A9093, + 0x71757A7E, 0x7F7A736F, 0x8082807B, 0x847F7A7A, 0x86918E8E, 0x6868636E, 0x7F7B726A, 0x7776777B, + 0x78746F6D, 0x6C71777A, 0x6E74736F, 0x625F5E65, 0x62656461, 0x66615C5D, 0x6D6E6862, 0x63606065, + 0x68686867, 0x69696968, 0x585F5652, 0x76466A54, 0x565A6671, 0x7372715F, 0x645F5449, 0x52585F63, + 0x64444043, 0xEB115C68, 0xE2DCEBE2, 0x665766D8, 0xEBEB1369, 0xE5EBE9E8, 0x50545543, 0x5350585A, + 0x5E605D58, 0x5C5D5D5C, 0xE0E8106E, 0xEBE2EBDD, 0x53596064, 0x53515050, 0x4A3E604D, 0x6C66624F, + 0x594D4F4B, 0xE6EBEA1D, 0x58E7EBEB, 0x43594950, 0x4E4F4F4E, 0x1344443F, 0xE6EBEAEB, 0x6A68E8E3, + 0x2C105058, 0x12182512, 0x15101918, 0x52581C1A, 0x4D565550, 0x6B594744, 0x484A5157, 0x4D4D4C4A, + 0x50505152, 0x50504F4F, 0x50505151, 0x53525150, 0x56565660, 0x64694B5B, 0x5F656E5D, 0x374B484A, + 0xE8EBE2EB, 0x4A57E5EB, 0x54545454, 0x53535353, 0xEB2D6C44, 0xEBE5EBE2, 0x304547DA, 0x48394743 +}; +#endif + +#define PATCH_OFFSET_0 29 +#define PATCH_OFFSET_1 31 +#define PATCH_OFFSET_2 83 +#define PATCH_OFFSET_3 11 +#define PATCH_OFFSET_4 17 +#define PATCH_OFFSET_5 23 +#define PATCH_OFFSET_6 33 + +static gctUINT32 ppuCmd0_0xA0[] = { + 0x0801028A, + 0x00000011, + 0x08010E13, 0x00000002, - 0x0400100C, - 0x3FC04804, - 0x40AB0440, - 0x2000007A, - 0x38000835, - 0x39207804, - 0x41E80050, - 0x00390018, - 0x04041036, - 0x00001804, - 0x4000047A, + 0x08010E4E, + 0x00400000, + 0x08010E4F, + 0x00000000, + 0x08010E50, + 0x00000000, + 0x10000000, + 0x00000000 +}; + +static gctUINT32 ppuCmd1_0xA0[] = { + 0x08010E03, + 0x00000C23, + 0x08010E03, + 0x00000C23, + 0x08010594, + 0x00000001, + 0x10000000, + 0x00000000 +}; + +static gctUINT32 ppuCmd2_0xA0[] = { + 0x08015580, 0x00000002, - 0x0400100C, - 0x3FC04804, - 0x40AB0440, - 0x2000007A, - 0x38000835, - 0x39207804, - 0x41E80050, - 0x00390028, - 0x04041036, - 0x00002804, - 0x4000047A, + 0x08010E02, + 0x00000701, + 0x48000000, + 0x00000701, + 0x0804D800, + 0x7388C280, + 0x00000080, + 0x00800080, + 0x444051F0, + 0x18000000, + 0x0804D804, + 0x00004000, + 0x00000000, + 0x10DA10B0, + 0x00000000, + 0x18000000, + 0x0804D808, + 0x738902C0, + 0x00000040, + 0x00400040, + 0x444051F0, + 0x18000000, + 0x0804D80C, + 0x00001000, + 0x00000000, + 0x10DA10B0, + 0x00000000, + 0x18000000, + 0x0804D810, + 0x73891300, + 0x00000040, + 0x00400040, + 0x444051F0, + 0x18000000, + 0x0804D814, + 0x00001000, + 0x00000000, + 0x10DA10B0, + 0x00000000, + 0x18000000, + 0x0801D818, + 0x7388BF40, + 0x0801D819, + 0x7388BF80, + 0x0804D81C, + 0x73892340, + 0x00000080, + 0x00400040, + 0x44405071, + 0x18000000, + 0x0804D820, + 0x00002000, + 0x00000003, + 0x10DD10B0, + 0x00000000, + 0x18000000, + 0x0804D824, + 0x11111111, + 0x00000000, + 0x03020100, + 0x07060504, + 0x18000000, + 0x0804D828, + 0x22222222, + 0x00000000, + 0x00000000, + 0x00000400, + 0x18000000, + 0x0804D82C, + 0x00000001, + 0x00000001, + 0x00000001, + 0x00000001, + 0x18000000, + 0x0804D830, + 0x00000001, + 0x00000001, + 0x00000001, + 0x00000001, + 0x18000000, + 0x080102A4, + 0x00000000, + 0x08010420, + 0x00000000, + 0x08010427, + 0x00000000, + 0x08010416, + 0x00000000, + 0x08010409, + 0x00000000, + 0x0801021F, + 0x00000000, + 0x08010424, + 0x00000010, + 0x0801040A, + 0x7388C000, + 0x08015580, 0x00000002, - 0x0400100C, - 0x3FC04804, - 0x40AB0440, - 0x2000007A, - 0x38000835, - 0x39207804, - 0x41E80050, - 0x00390038, + 0x0801021A, + 0x00000001, + 0x08010425, + 0x0000000F, + 0x08030402, + 0x00001F01, + 0x00000005, + 0x00000F00, + 0x08010228, + 0x00000000, + 0x0801028C, + 0x00000100, + 0x08010E07, + 0x00000000, + 0x0801040C, + 0x00000000, + 0x0801020C, + 0x0F3F0000, + 0x08010201, + 0x00000001, + 0x080102AA, + 0x00000000, + 0x08010E22, + 0x007F0000, + 0x08010412, + 0x00000000, + 0x08010E27, + 0xFFFFFFFF, + 0x08010240, + 0x03000002, + 0x08010249, + 0x00000000, + 0x08010247, + 0x00000002, + 0x0801024B, + 0x00000000, + 0x0801024D, + 0x00000000, + 0x0801024F, + 0x00000000, + 0x08010256, + 0x00000008, + 0x08010257, + 0x00000001, + 0x08010258, + 0x00000000, + 0x08060250, + 0x00000000, + 0x0000003F, + 0xFFFFFFFF, + 0x00000007, + 0x00000000, + 0x000003FF, + 0x18000000, + 0x08010248, + 0xBADABEEB, + 0x08010E03, + 0x00000024, + 0x08010E02, + 0x00000701, + 0x48000000, + 0x00000701, + 0x08010E03, + 0x00000C23, + 0x08010E03, + 0x00000C23, + 0x08010594, + 0x00000001, + 0x10000000, + 0x00000000 }; -static gctUINT32 ppuMem4[] = -{ - 0x7E7E7E7E, - 0x797B7E7F, - 0x79797879, - 0x7D7C7B7A, - 0x80818181, - 0x7B7C7D7F, - 0x83817C79, - 0x7C7D8082, - 0x7C7C7D7D, - 0x7D7D7C7C, - 0x81818181, - 0x7D7D7F80, - 0x73777E83, - 0x71717171, - 0x7E7A7574, - 0x8A888782, - 0x7475797B, - 0x8D888078, - 0x8F92918F, - 0x787B8189, - 0x908E8781, - 0x787B838C, - 0x7A767576, - 0x85868581, - 0x817F8185, - 0x87838181, - 0x8182878D, - 0x787C8181, - 0x807A787A, - 0x8B878483, - 0x8D8A8787, - 0x8885878D, - 0x817E7D7D, - 0x81828483, - 0x7C7D7D7E, - 0x69686D76, - 0x6E6D6C6C, - 0x70727271, - 0x74727172, - 0x74757675, - 0x6F6E7072, - 0x70717170, - 0x6E6E7073, - 0x78767471, - 0x7A77726F, - 0x84817F7C, - 0x93949596, - 0x8D8D9092, - 0x8F8F8D88, - 0xB3A79991, - 0xABB4BABD, - 0x8D9199A2, - 0x77737274, - 0x676F787A, - 0x78716862, - 0x7577797A, - 0x74747474, - 0x78777675, - 0x78797A7A, - 0x74747576, - 0x817C7977, - 0x82848685, - 0x787A7D80, - 0x8886807A, - 0x79858D91, - 0x6D6A696E, - 0x676D7471, - 0x5659646A, - 0x3E3B3F45, - 0x44484A46, - 0x675B504A, - 0x82807A72, - 0x71777C80, - 0x6868696C, - 0x716E6D6B, - 0x7F7B7773, - 0x87909391, - 0x908F8A85, - 0x9596938F, - 0x89898C91, - 0x89878584, - 0x92908E8C, - 0x99999693, - 0x7B818993, - 0x7A818582, - 0x928B8078, - 0x928A8D97, - 0xA5968F93, - 0x939DA5AB, - 0x8F8D8A8C, - 0x8D8B8A8C, - 0x85878B8D, - 0x7C7D8082, - 0x7F807F7E, - 0x85858382, - 0x787B7F83, - 0x72717475, - 0x9B928378, - 0x9EB4B6AB, - 0x8C898589, - 0x998F8A8E, - 0x686D7E93, - 0x6A6A6865, - 0x65646568, - 0x64676868, - 0x60616162, - 0x7A7A7268, - 0x72767878, - 0x6C717577, - 0x716A6466, - 0x7D7E7B78, - 0x7A777679, - 0x8484817F, - 0x7A7E8183, - 0x89807E84, - 0x8080868D, - 0x60505069, - 0x7074857A, - 0x968D7A69, - 0x8E8C8D93, - 0x6D6D7A8D, - 0x8A7E7470, - 0x7C7D7F80, - 0x7A7A7A7B, - 0x7A7A7C7C, - 0x74757678, - 0x7C7A7775, - 0x75777A7C, - 0x7A7A7978, - 0x7A7A7A7A, - 0x81817C7A, - 0x7D7E7F81, - 0x8D898581, - 0x8185898D, - 0x7374787B, - 0x79797674, - 0x797A7A7B, - 0x79797878, - 0x807F7D7C, - 0x7D7E7F80, - 0x78797A7A, - 0x79797878, - 0x77787878, - 0x76767677, - 0x77777778, - 0x76767676, - 0x78767574, - 0x7F7E7C7A, - 0x797B7D7F, - 0x76767677, - 0x807E7C7A, - 0x82828181, - 0x7C7F8183, - 0x7979797A, - 0x84807B79, - 0x8E8D8C88, - 0x88888888, - 0x86878788, - 0x82818384, - 0x85868684, - 0x87878787, - 0x87878786, - 0x767B8185, - 0x72717173, - 0x7F818282, - 0x76787A7C, - 0x76767676, - 0x74747576, - 0x78736E6A, - 0x77787A7A, - 0x78757474, - 0x85827F7B, - 0x8D8E8D8D, - 0x8184878C, - 0x87837F7C, - 0x82848788, - 0x80818182, - 0x7E7E7F7F, - 0x8985817E, - 0x8C8C8D8C, - 0x8B8A8A8B, - 0x7A80878B, - 0x86817D7B, - 0x8D8D8C89, - 0x87888785, - 0x82828386, - 0x89848181, - 0x9293938F, - 0x8D8D8F92, - 0x868A8E8F, - 0x89837F7C, - 0x8C8E8F8D, - 0x78808689, - 0x63666A71, - 0x5F5C5F63, - 0x73726E67, - 0x75727274, - 0x68696E74, - 0x6C6B6C6B, - 0x83837D73, - 0x686B7074, - 0x807A716A, - 0x81828180, - 0x676C747C, - 0x68626060, - 0x7D7C7A72, - 0x7074787A, - 0x7F79716E, - 0x6E6A7585, - 0x686E7474, - 0x5C646665, - 0x4F4C4C52, - 0x63615A53, - 0x786F6763, - 0x7A7F8385, - 0x77757475, - 0x6B6E7171, - 0x65646467, - 0x6662605F, - 0x736E6A68, - 0x79797877, - 0x74757779, - 0x78747170, - 0x7B7D7D7B, - 0x7F7B7B7E, - 0x7C818483, - 0x8B878585, - 0x92939491, - 0x99949190, - 0x90959B9D, - 0x6C717E8A, - 0x7E7D7870, - 0x81828282, - 0x84828080, - 0x71727C87, - 0x7D7A7774, - 0x676F7E88, - 0x837B7068, - 0x84888A8B, - 0x7A7A7C80, - 0x76747373, - 0x76787979, - 0x6E6E7072, - 0x87817A73, - 0x8385878A, - 0x797B8082, - 0x8989837D, - 0x7E7C7D83, - 0x817B7A7B, - 0x757F8788, - 0x6F727476, - 0x6D6D6D6E, - 0x707A7A75, - 0x62626368, - 0x62636566, - 0x67656362, - 0x6E6E6E6E, - 0x7E78726E, - 0x817F7E7D, - 0x908D8A86, - 0x82818488, - 0x8A8C8B87, - 0x8184878A, - 0x807F7E7F, - 0x84858787, - 0x767A7F82, - 0x6C6C6C6C, - 0x7674716E, - 0x76787A7A, - 0x70717274, - 0x6E6D6E70, - 0x7D7B7772, - 0x807B7A78, - 0x878D8E87, - 0x79828989, - 0x74777774, - 0x4E545E67, - 0x6B645A50, - 0x8A796C68, - 0x63718490, - 0x7068615C, - 0x74747675, - 0x7C787471, - 0x82828180, - 0x7A7B7B7B, - 0x74757779, - 0x858B877E, - 0x7B747077, - 0x6F717980, - 0x74767572, - 0x6E6F6F6F, - 0x696A6B6D, - 0x565C6060, - 0x605F5A55, - 0x5F5F5E5D, - 0x66646160, - 0x736E6A68, - 0x7C7F7E7A, - 0x75757879, - 0x79797877, - 0x71717375, - 0x6C6E7273, - 0x6D6B6A69, - 0x71706F6E, - 0x66686A6B, - 0x61616263, - 0x7F7F7365, - 0x61697379, - 0x6B67625D, - 0x69696B6C, - 0x7776716B, - 0x75737274, - 0x6E788082, - 0x6F696365, - 0x6E6F7172, - 0x6E6D6B6B, - 0x74625E6F, - 0x74767679, - 0x77787979, - 0x7F7B7876, - 0x7C7D7D7C, - 0x6E71757A, - 0x63626262, - 0x6C6A6865, - 0x7C827C72, - 0x76747173, - 0x74706F6F, - 0x74777A78, - 0x6A6F7274, - 0x56595E64, - 0x615E775C, - 0x61625E6E, - 0x694F8559, - 0x13285176, - 0x1910261C, - 0x16201313, - 0x29191017, - 0x567B8219, - 0x836E967A, - 0x6B6C7087, - 0x726C6862, - 0x71827477, - 0x10171091, - 0x13252F10, - 0x1010171C, - 0x17101923, - 0x60847A58, - 0x66735684, - 0x6E6A6868, - 0x79777471, - 0x5C747B77, - 0x5676866C, - 0x5C67616B, - 0x102D1F14, - 0x67251028, - 0x955B7689, - 0x8A8B8B8C, - 0x8989898A, - 0x936E9489, - 0x79778177, - 0x102A6A6E, - 0x10151310, - 0x1E131214, - 0x13131F1D, - 0x817C8D8B, - 0x71706368, - 0x696E7479, - 0x7A746E69, - 0x7D807E7C, - 0x73737478, - 0x79797572, - 0x60646C74, - 0x7870596B, - 0x7B8D9A93, - 0x777A7274, - 0x105F6880, - 0x10181829, - 0x78604720, - 0x65696D6E, - 0x56585C60, - 0x8D685B55, - 0x8E78A599, - 0x21107F71, - 0x1024102F, - 0x10101B2D, - 0x13251618, - 0x634F5C16, - 0x44567A3C, - 0x5B565350, - 0x5D5D5D5C, - 0x5E5C5C5C, - 0x69686461, - 0x73716F6E, - 0x7A797775, - 0x56677099, - 0x465D624C, - 0x1F134859, - 0x10191910, - 0x10101010, - 0x10101010, - 0x71939610, - 0x8F574661, - 0x7A7C7B7A, - 0x7B797778, - 0x6068886D, - 0x705F7971, - 0x18101925, - 0x1F10101D, - 0x1B1A1F10, - 0x6C4C1F13, - 0x6866686A, - 0x5D545A6B, - 0x5A5A5959, - 0x57585959, - 0x6C625953, - 0x6D6F7171, - 0x44586863, - 0x4C4E3C58, - 0x101F2613, - 0x101D1110, - 0x161F1019, - 0x4F191310, - 0x6056617B, - 0x4A505F6C, - 0x855B3E60, - 0x3F4A3E78, - 0x107A3849, - 0x1B101A27, - 0x1910101A, - 0x102B101F, - 0x5E6F1112, - 0x67626263, - 0x65625E5C, - 0x5F626466, - 0x7A808588, - 0x4A556472, - 0x66629274, - 0x4E464873, - 0x6E673E56, - 0x102F6E57, - 0x1B101810, - 0x13131C19, - 0x101E1019, - 0x35685021, - 0x75676D6E, - 0x5981667E, - 0x463E4E4F, - 0x105C6350, - 0x19111822, - 0x21101E10, - 0x21232323, - 0x18191A1E, - 0x1D101E12, - 0x674E4810, - 0x66747368, - 0x7C6E5D59, - 0x6B6B6A6A, - 0x6F6E6B6A, - 0x7F80776E, - 0x74707077, - 0x51107274, - 0x10171E18, - 0x19191919, - 0x19191919, - 0x191B1C1C, - 0x17171819, - 0x646A6268, - 0x6A726C74, - 0x73637362, - 0x32485C51, - 0x2E1A1017, - 0x1F131023, - 0x2A103114, - 0x564A121C, - 0x4C45374F, - 0x35425A64, - 0x6D614E40, - 0x4550606C, - 0x3D454B50, - 0x282A2F35, - 0x7B797979, - 0x7D7F807E, - 0x7B7B7B7B, - 0x7F7E7D7C, - 0x80808180, - 0x7B7C7E7F, - 0x83817C79, - 0x7E7F8182, - 0x7A7A7A7B, - 0x7B7A7A7A, - 0x817F7D7C, - 0x83838281, - 0x777D7E7A, - 0x7B746E6E, - 0x807F7E7D, - 0x83838281, - 0x7A7A7D7F, - 0x918D857E, - 0x9192918F, - 0x7D81868D, - 0x8D8D8883, - 0x75798088, - 0x837D7977, - 0x8A8C8D89, - 0x84828285, - 0x87838183, - 0x7E81878D, - 0x81838280, - 0x8B878481, - 0x9393928F, - 0x8F939595, - 0x8787898C, - 0x82808080, - 0x83848684, - 0x82828283, - 0x6E6E737C, - 0x6F6E6E6E, - 0x72737371, - 0x75737272, - 0x7A7A7A79, - 0x72737476, - 0x70727373, - 0x6D6C6E71, - 0x7877746F, - 0x6F717475, - 0x8C847A72, - 0x8E8F9090, - 0x87888A8C, - 0x8A87837F, - 0xB1A5968D, - 0xA4ABB1B4, - 0x878C939B, - 0x78757578, - 0x6870787A, - 0x837A6E66, - 0x8B8B8B89, - 0x74747575, - 0x79787675, - 0x78797A7A, - 0x76767777, - 0x817D7B7A, - 0x7E818383, - 0x77747476, - 0x8C89847D, - 0x74818C91, - 0x6C68666A, - 0x6D70726A, - 0x5C5E666C, - 0x564A494C, - 0x6A707168, - 0x746E6866, - 0x81817D79, - 0x787B7E80, - 0x6E6F7174, - 0x7473706E, - 0x7F7B7875, - 0x878D8D8A, - 0x8D8D8985, - 0x99988F87, - 0x797D8591, - 0x85817E7C, - 0x93918D8A, - 0x98999894, - 0x7A7F8791, - 0x70747472, - 0x938B7D72, - 0x8D888C96, - 0x9C8F888D, - 0x979C9FA1, - 0x8E8D8E91, - 0x8D8C8C8D, - 0x87898C8E, - 0x7A7B7F82, - 0x8482807C, - 0x8181807E, - 0x74767B80, - 0x72727374, - 0x84817B75, - 0x949F9988, - 0x8D8B8687, - 0x938D898C, - 0x74717A8B, - 0x6B6D7074, - 0x65676869, - 0x68686765, - 0x5B5C6064, - 0x787A746A, - 0x78787474, - 0x787B7B7B, - 0x7C777374, - 0x84858381, - 0x807E7E81, - 0x8483817E, - 0x7C7F8283, - 0x877E7B7D, - 0x787E878B, - 0x524F4B5A, - 0x6661685E, - 0x948D7A6B, - 0x8D8B8C91, - 0x6E6A788C, - 0x7F7C7A77, - 0x7B7C7D7E, - 0x7B7B7B7B, - 0x7B7C7E7E, - 0x7777787A, - 0x74747576, - 0x76757474, - 0x7A797878, - 0x7A7A7A7A, - 0x807E7A78, - 0x7B7C7D7F, - 0x87868381, - 0x81838687, - 0x7374797D, - 0x7A7A7774, - 0x7B7C7D7D, - 0x7A7A7A7B, - 0x7F7E7D7D, - 0x7C7C7E7F, - 0x78797A7A, - 0x78787878, - 0x77787878, - 0x76767677, - 0x74747575, - 0x74747474, - 0x77747473, - 0x7D7C7A79, - 0x787A7B7C, - 0x77767677, - 0x7D7D7D7C, - 0x81807E7D, - 0x80818283, - 0x7B7B7C7E, - 0x8683817F, - 0x8B8B8A88, - 0x88888787, - 0x85868787, - 0x81818183, - 0x85868684, - 0x86878787, - 0x85858585, - 0x787C8082, - 0x75747475, - 0x7F7F7F7F, - 0x7C7D7E7F, - 0x7F7F7E7E, - 0x7C7C7E7F, - 0x7A797472, - 0x7375797B, - 0x7A787675, - 0x8583817D, - 0x8B8C8C8B, - 0x7F818588, - 0x87837E7B, - 0x81848788, - 0x7E808181, - 0x81807F7E, - 0x8784817E, - 0x8B8C8B8A, - 0x8A8A8A8B, - 0x7A7F8689, - 0x85817E7C, - 0x89898887, - 0x8184888B, - 0x87868281, - 0x88858281, - 0x8D8D8D8B, - 0x8B8B8C8D, - 0x86888C8D, - 0x87838180, - 0x83868989, - 0x797E8285, - 0x6C6E6F74, - 0x5F5C6064, - 0x73726E66, - 0x76757475, - 0x62636973, - 0x6E696763, - 0x8A8A8378, - 0x646E7A82, - 0x79726862, - 0x787A7978, - 0x5E636B74, - 0x615B5A5C, - 0x7273726B, - 0x7C7C7A78, - 0x817E7B7B, - 0x6D6A7584, - 0x686C7172, - 0x61636668, - 0x5053585D, - 0x605B5047, - 0x776F6662, - 0x7F7F7C7A, - 0x75777A7D, - 0x6B6E6F6E, - 0x65646568, - 0x68666564, - 0x736F6B68, - 0x7A797876, - 0x7B7C7C7B, - 0x70707375, - 0x7A797673, - 0x7F7A7B7E, - 0x7E838785, - 0x8B878585, - 0x9092928F, - 0x99939190, - 0x8E949A9C, - 0x72757D85, - 0x807F7C76, - 0x81807F7F, - 0x86868482, - 0x70717B87, - 0x7A787573, - 0x6C717B83, - 0x8A83796F, - 0x85898C8D, - 0x7A7A7D81, - 0x74747677, - 0x6F727474, - 0x6E6C6E6F, - 0x89847A73, - 0x82848789, - 0x787A7E81, - 0x83817A73, - 0x7A7A7A80, - 0x817A7979, - 0x77808788, - 0x70737475, - 0x6D6D6E6E, - 0x6E777773, - 0x62626266, - 0x5F606262, - 0x63626160, - 0x6B6B6B6A, - 0x817A726D, - 0x797B8185, - 0x8D88817B, - 0x81818589, - 0x8E8E8C87, - 0x8286898C, - 0x81818181, - 0x80818284, - 0x73767B7F, - 0x6C6B6C6C, - 0x7574716E, - 0x7678797A, - 0x71727374, - 0x6A6A6D6F, +static gctUINT32 ppuCmd3_0xA0[] = { + 0x08010E03, + 0x00000C23, + 0x08010E03, + 0x00000C23, + 0x08010594, + 0x00000001, + 0x10000000, + 0x00000000 +}; + +static gctUINT32 ppuMem0_0xA0[] = { + 0x7E83898D, + 0x807E7B7B, + 0x84817F7F, + 0x5C687A83, + 0x7E766C66, + 0x616A777F, + 0x5C5B5856, + 0x625F5C5C, + 0x52515A62, + 0x52585C58, + 0x60585554, + 0x70716F69, + 0x71696A6E, + 0x787F827D, + 0x72747D87, + 0x6D6D6E71, + 0x877F736A, + 0x6A737F87, + 0x6B686868, 0x7A78746E, - 0x7877797A, - 0x8B8E8B81, - 0x7A818685, - 0x777A7A77, - 0x4C505A62, - 0x6F695D52, - 0x87786D69, - 0x6571838D, - 0x746F6761, - 0x74747677, - 0x7A777473, - 0x7A7B7B7B, - 0x77767575, - 0x7A7A7A79, - 0x868B8781, - 0x7E79767C, - 0x6F71797F, - 0x74757572, - 0x6E6F7070, - 0x696A6B6D, - 0x545E6363, - 0x53514F4E, - 0x5E5D5C5A, - 0x5D5D5D5E, - 0x6A64615F, - 0x777B7B74, - 0x6C6E7174, - 0x696B6D6D, - 0x6C6A6C6E, - 0x6C6E6F6E, - 0x6A686868, - 0x6E6E6D6C, - 0x696C6E6E, - 0x64646668, - 0x7B7B7165, - 0x61687076, - 0x6A67625D, - 0x62646769, - 0x716C655F, - 0x76747373, - 0x71797C7D, - 0x6D69676A, - 0x7072716F, - 0x6F6E6C6E, - 0x74625D6E, - 0x76787779, - 0x77767676, - 0x79797877, - 0x7A7B7C7C, - 0x6F727478, - 0x71706F6F, - 0x79787573, - 0x7B7A7977, - 0x6D6F7479, - 0x6E6E7072, - 0x7875726F, - 0x6D717475, - 0x5B5D6268, - 0x615C6759, - 0x61685E6E, - 0x7A7D5C44, - 0xD6144E6D, - 0xDDE5E2EB, - 0xE4EBEBEB, - 0xEBDCE3EB, - 0x8F6E73DD, - 0x64518573, - 0x6766626E, - 0x6E676260, - 0x74887C71, - 0xE7DD3B61, - 0xE7E9CCEB, - 0xDCE1EBEB, - 0xEBDEDCE2, - 0x606F8774, - 0x6371687F, - 0x6D6A6868, - 0x7674726F, - 0x80817C79, - 0x61748786, - 0x78635A4E, - 0xEBE5D014, - 0x86C8E5E7, - 0x6E748F7B, - 0x77777778, - 0x75757676, - 0x7E647F74, - 0x7470656D, - 0xE1444A68, - 0xE9CED7EB, - 0xE6DDDDDD, - 0xE7EAE9E8, - 0x874A7282, - 0x9F7E876E, - 0x696E7478, - 0x79746E69, - 0x7C808180, - 0x6E6E7076, - 0x6B6E6E6F, - 0x5E606267, - 0x5F5C646D, - 0x6E76716E, - 0x73796A73, - 0x17496762, - 0xDEEBDFE4, - 0x899AC9D7, - 0x6267696B, - 0x56575A5E, - 0x6B5C656F, - 0x83687A6F, - 0xD31A7483, - 0xEAD3E5E7, - 0xEBEBDEE0, - 0xEBE4EBDF, - 0x692F63E8, - 0x534A584E, - 0x58565554, - 0x5C5C5B5A, - 0x5E5C5C5C, - 0x65646260, - 0x6B696868, - 0x70706E6D, - 0x7A707474, - 0x4E4A543B, - 0xC41B564C, - 0xE9E5EBC4, - 0xE8E8E8E8, - 0xE8E8E8E8, - 0x8F556FEB, - 0x6E7A7593, - 0x5B5F6E7B, - 0x61646560, - 0x4A727E51, - 0x6B54585E, - 0xE1EBD52E, - 0xE4EBE7E8, - 0xE6E8EBEA, - 0x6668E6EB, - 0x4E5D5E4F, - 0x6E6C5F4F, - 0x53535252, - 0x53535454, - 0x635C5653, - 0x67686867, - 0x375B6352, - 0x44505A4F, - 0xEBE2D820, - 0xEAE6D6CC, - 0xDCE8E5E8, - 0x6FE8E2EB, - 0x45556166, - 0x43504E43, - 0x495A525A, - 0x4E4D4276, - 0x2B446056, - 0xD0EBEBDC, - 0xDCE4EBD1, - 0xEBE2D2EB, - 0x438CE3D5, - 0x60626E6E, - 0x625E5956, - 0x5D606264, - 0x74736F6C, - 0x5E626970, - 0x6E6C8561, - 0x4A4B496C, - 0x7A63582A, - 0xE929566C, - 0xDDD9EBE9, - 0xE2EBE2EB, - 0xE7DEDBEB, - 0x785A54DC, - 0x7B74715E, - 0x687B5673, - 0x443E5154, - 0x1462654E, - 0xEBE3E3E4, - 0xEBE3EBE7, - 0xE2E3E3E3, - 0xDFDFE0E1, - 0xE8E0E9E2, - 0x636C60C8, - 0x727B786E, - 0x7C746867, - 0x58575D62, - 0x7D776C60, - 0x7C7C746D, - 0x6B6B6E75, - 0xD0347668, - 0xEBEBE4CA, - 0xE9E9E9E9, - 0xE9E9E9E9, - 0xE9E9E9E9, - 0xE8E8E8E8, - 0x5B5D5756, - 0x61646062, - 0x50485064, - 0x104D4946, - 0xDFE9EAE8, - 0xEBEBEADB, - 0xD7EADEEB, - 0x4876D4E3, - 0x5B4E4958, - 0x3F4B616D, - 0x6960534A, - 0x4E56626A, - 0x3F474D50, - 0x2C2E3238, - 0x79747372, - 0x8483817E, - 0x7F808181, - 0x807F7F7F, - 0x80818080, - 0x7D7E7F80, - 0x82817C79, - 0x80808182, - 0x77777878, - 0x78787777, - 0x817C7A77, - 0x8B8A8785, - 0x7A817C74, - 0x877A6D6F, - 0x82858789, - 0x7C7D7E81, - 0x81818284, - 0x95918A84, - 0x93928F8D, - 0x87898E92, - 0x8A8D8C89, - 0x75787D84, - 0x938A8380, - 0x999B9C99, - 0x898A8A8B, - 0x89848286, - 0x7E81888F, - 0x8C8A8681, - 0x9699958F, - 0x999E9E98, - 0x8F9B9F9D, - 0x84888A89, - 0x83828283, - 0x87878786, - 0x8A8A8989, - 0x74747A84, - 0x706E6F71, - 0x74747472, - 0x79747373, - 0x8383817D, - 0x787A7C7F, - 0x6F727476, - 0x68686B6E, - 0x7876726D, - 0x686D747A, - 0x9387776B, - 0x898B8B8C, - 0x82848687, - 0x84837F7A, - 0xA59A8D85, - 0x999FA3A5, - 0x83868C92, - 0x7A797A7D, - 0x6E747A7C, - 0x8A837A73, - 0x8A8B8D8D, - 0x74757778, - 0x79787674, - 0x78787878, - 0x78787878, - 0x817E7C7B, - 0x7F818383, - 0x7A777778, - 0x8081817F, - 0x6B788287, - 0x68635F62, - 0x73757066, - 0x65686C6E, - 0x75656062, - 0x8B929389, - 0x7D7E8081, - 0x7D7D7C7C, - 0x81818180, - 0x76787B7F, - 0x79787674, - 0x7D7B7A79, - 0x84868581, - 0x8B8B8884, - 0x8E938C83, - 0x6C6D7481, - 0x817D7A78, - 0x8D8C8885, - 0x93949391, - 0x8183878E, - 0x6E6F706F, - 0x8D898074, - 0x8C898D96, - 0x8D838188, - 0x9D9C9894, - 0x8C8F9399, - 0x8A898887, - 0x8286898A, - 0x787C8389, - 0x7C7A7977, - 0x7E7E7B7A, - 0x6F73777C, - 0x78726F6F, - 0x8182827F, - 0x8F958E81, - 0x8E8D8887, - 0x8B8B8989, - 0x7F787882, - 0x6B6E757B, - 0x6A6C6E6C, - 0x686A6867, - 0x56585D63, - 0x777A736A, - 0x7D7A7473, - 0x8686827F, - 0x87868484, - 0x88898887, - 0x83838487, - 0x85838180, - 0x7D7E8184, - 0x81818180, - 0x5E6C7B81, - 0x49514A4C, - 0x6259574A, - 0x938D7E71, - 0x8C8A8B8F, - 0x736A788D, - 0x747C8481, - 0x7A7A7B7B, - 0x7D7C7B7B, - 0x7D7E7F80, - 0x797A7A7B, - 0x6B6E7477, - 0x77746E6B, - 0x79787777, - 0x7979797A, - 0x7E7C7975, - 0x7A7A7A7C, - 0x81818282, - 0x82828181, - 0x74767B80, - 0x7D7B7975, - 0x80818181, - 0x7C7C7E7F, - 0x7E7E7D7D, - 0x7A7B7C7D, - 0x78797A7B, - 0x76767677, - 0x77777777, - 0x76767676, - 0x71727272, - 0x70707171, - 0x7472706F, - 0x7A797875, - 0x77797A7A, - 0x76767676, - 0x7A7A7B7B, - 0x7F7C7A78, - 0x84838382, - 0x80818283, - 0x87878685, - 0x87878787, - 0x87878786, - 0x85858687, - 0x81808181, - 0x86878684, - 0x85868787, - 0x82828384, - 0x797A7C7D, - 0x76767778, - 0x7F7D7A7A, - 0x84838281, - 0x87878786, - 0x84858787, - 0x80817F7E, - 0x6E72787D, - 0x7F7C7A79, - 0x86858381, - 0x86878787, - 0x7A7C8083, - 0x86817C79, - 0x81838787, - 0x7E818284, - 0x7D7C7C7C, - 0x8581807E, - 0x8A8A8887, - 0x88888989, - 0x7B7F8487, - 0x8381807F, - 0x83848484, - 0x7E7F8488, - 0x81828280, - 0x8784817E, - 0x87878687, - 0x87878786, - 0x87878788, - 0x87878686, - 0x7A7E8387, - 0x777A7D7F, - 0x75757475, - 0x5F5E6266, - 0x72706C65, - 0x78797675, - 0x5D5E6470, - 0x6C65605C, - 0x89898376, - 0x6874818A, - 0x6E6A6462, - 0x71716E6D, - 0x5F63696E, - 0x5A55575C, - 0x61656863, - 0x867F756E, - 0x84868788, - 0x6E6E7884, - 0x686C7071, - 0x6865676B, - 0x5761696C, - 0x5C564A3E, - 0x7068605C, - 0x837F7872, - 0x73767B81, - 0x6B6E6F6F, - 0x65646568, - 0x6F6F6E6E, - 0x7573706F, - 0x7E7A7775, - 0x86858381, - 0x686E787F, - 0x7C78706A, - 0x8078797C, - 0x878D8F8A, - 0x8B878686, - 0x8D8F8F8E, - 0x96928F8E, - 0x8B909799, - 0x7A7A7D81, - 0x82817F7C, - 0x84807E7F, - 0x8D8E8E8A, - 0x6F717A86, - 0x79777473, - 0x7474787C, - 0x928D847A, - 0x85898D8E, - 0x7A7B7E81, - 0x6E717477, - 0x68696C6E, - 0x69656464, - 0x89837A71, - 0x8386888A, - 0x787A7F81, - 0x7C79716B, - 0x7676787A, - 0x837C7979, - 0x79808788, - 0x72747677, - 0x6B6C6E6F, - 0x6C73736E, - 0x62626263, - 0x5C5D5E5F, - 0x5F5E5C5C, - 0x62606060, - 0x7D766D65, - 0x6E72797E, - 0x83807972, - 0x7F7F8489, - 0x918F8A84, - 0x81848788, - 0x81818080, - 0x7D7F8181, - 0x7274797C, - 0x6C6C6C6C, - 0x7473706E, - 0x76777878, - 0x73747475, - 0x66686C6F, - 0x76746E69, - 0x77747575, - 0x8A8D8B81, - 0x83878786, - 0x80828381, - 0x5457626B, - 0x6E6A6259, - 0x83766E6E, - 0x67718189, - 0x7A786F68, - 0x75747579, - 0x76767474, - 0x72737476, - 0x74716F6E, - 0x83817D78, - 0x878A8886, - 0x82818183, - 0x6F71787E, - 0x73747573, - 0x6E6E6F70, - 0x69696B6C, - 0x525C6261, - 0x4D4D4B4B, - 0x5D5C5B59, - 0x56585B5C, - 0x615A5858, - 0x71797A6E, - 0x6262676B, - 0x5E626564, - 0x625F6061, - 0x6B6A6865, - 0x6B696868, - 0x6F6E6E6D, - 0x6E707172, - 0x68686A6C, - 0x76756E65, - 0x62676D72, - 0x6867625D, - 0x5B5D6266, - 0x6F69625E, - 0x70727373, - 0x77797774, - 0x6A6A6D71, - 0x7576726E, - 0x6F6E6E71, - 0x73625D6B, - 0x76787777, - 0x75727272, - 0x787A7B7A, - 0x78797A7A, - 0x72737476, - 0x78767676, - 0x7E7D7B7A, - 0x80787B85, - 0x626B7A83, - 0x6A6A6968, - 0x7974706C, - 0x71747778, - 0x6264686C, - 0x6A645A5F, - 0x50625B72, - 0x58896E95, - 0xE9162710, - 0xE8E1EBEB, - 0xE4EBE2E6, - 0xE1DFEBE2, - 0x101028E7, - 0x68454A10, - 0x72625669, - 0x7C776C6A, - 0x5174806E, - 0xD8D12810, - 0xE8EBCAEB, - 0xE4EAEBDE, - 0xEBE5E2D8, - 0x87645811, - 0x7363697C, - 0x6B6A6969, - 0x706F6E6C, - 0x6E768768, - 0x7A78928C, - 0x94726577, - 0xEBD2E015, - 0x5CD4EBE0, - 0x6F8D9355, - 0x6C6C6C6C, - 0x6B6B6B6B, - 0x797A7D63, - 0x1F1C1050, - 0xD0121326, - 0xEBEBEBE7, - 0xE8EBEBEB, - 0xE5EBDAE3, - 0x552E2519, - 0x8770725F, - 0x676A7074, - 0x74706A66, - 0x777B7D7D, - 0x696A6D72, - 0x5E646B6F, - 0x615F5C5B, - 0x6C5C6A5E, - 0x82857A7A, - 0x605F5B68, - 0x3972666E, - 0xEAEBE5EA, - 0x7A92D6E6, - 0x5E626365, - 0x5456575B, - 0x7058504F, - 0x7C727179, - 0xE21B2B10, - 0xEBD2E8E5, - 0xE0E8E6E8, - 0xE5E5D0D7, - 0x633438DA, - 0x63505362, - 0x56545454, - 0x5C5B5957, - 0x5D5C5C5B, - 0x5F5F5F5E, - 0x61605F5E, - 0x63636262, - 0x8B636352, - 0x635A6349, - 0xDE103B15, - 0xEBE4E4EB, - 0xEBEBEBEB, - 0xEBEBEBEB, - 0x1A132DCC, - 0x70552812, - 0x4E5C6D77, - 0x7D6E594C, - 0x146E8866, - 0x1A101030, - 0xD6E7E33E, - 0xE8E2DEEB, - 0xEBE6DDCC, - 0x1728D6EB, - 0x5B52341A, - 0x56443841, - 0x4D4D4C4C, - 0x504F4F4E, - 0x56555353, - 0x5E5D5C59, - 0x363F3B44, - 0x1013665B, - 0xEBEAE531, - 0xEBE0E4E8, - 0xE5E2EBEB, - 0x32DDD6EB, - 0x6256392C, - 0x4B413844, - 0x394E525A, - 0x5A4A4D70, - 0x25191F2A, - 0xE0EBEBDF, - 0xE3E7EBE4, - 0xEBE2E4EB, - 0x1434CDEB, - 0x6F7B7D53, - 0x645E5853, - 0x5F626567, - 0x716D635C, - 0x6C6C6D70, - 0x66686C4E, - 0x5860505B, - 0x78637D76, - 0xDE2C1E15, - 0xE8E3EBE8, - 0xE5E5E5E9, - 0xEBEBEBE2, - 0x10112DEB, - 0x6F4D3510, - 0x7A856379, - 0x3E435E67, - 0x10555642, - 0xEBEAEBEB, - 0xE3E4E8EA, - 0xE2E2E2E2, - 0xE3E3E3E3, - 0xE4DEE6EB, - 0x7D7926DD, - 0x7E817A72, - 0x77767577, - 0x50525D67, - 0x7F77695A, - 0x7A79746F, - 0x65686E75, - 0xE5295C55, - 0xEBE7EBE8, - 0xE6E6E6E6, - 0xE6E6E6E6, - 0xE8E8E8E8, - 0xEAEAE9E9, - 0x5352534C, - 0x5151544D, - 0x26194F48, - 0x1114294F, - 0xEBDDD9EB, - 0xE6E4E8EB, - 0xD6E9E1EB, - 0x104ABBE9, - 0x503A4345, - 0x66676866, - 0x65605B59, - 0x565C6568, - 0x40464B4F, - 0x3133363A, - 0x78737070, - 0x8887847F, - 0x83868788, - 0x7E7F8081, - 0x81818181, - 0x7F7F8081, - 0x817F7B79, - 0x80808081, - 0x75767777, - 0x77777675, - 0x827D7976, - 0x8F8E8B87, - 0x7A7E7A74, - 0x8B817574, - 0x85898D8E, - 0x7A7B7D81, - 0x81818284, - 0x93908A85, - 0x938E8987, - 0x91939696, - 0x878C8E8F, - 0x787A7D81, - 0x988F8783, - 0xA4A4A39F, - 0x8E939699, - 0x8C868388, - 0x83878D93, - 0x8F8D8985, - 0x90999A93, - 0x8F98988F, - 0x8F9D9C91, - 0x82878786, - 0x85838485, - 0x88898887, - 0x8E8E8D8D, - 0x78797F88, - 0x72707273, - 0x77787774, - 0x7C777575, - 0x8B8A8782, - 0x7E818689, - 0x6D70757A, - 0x62626568, - 0x76736E68, - 0x6E707477, - 0x92887C72, - 0x8B8C8D8D, - 0x84858788, - 0x82868581, - 0x9088807E, - 0x8F929394, - 0x8385888C, - 0x7E7D8082, - 0x757A7F80, - 0x8A87817D, - 0x80818588, - 0x7476797A, - 0x77767474, - 0x77777676, - 0x79797878, - 0x7E7B7A7A, - 0x81828281, - 0x81818182, - 0x6E747A80, - 0x6871787A, - 0x6B666262, - 0x7879726C, - 0x6E767674, - 0x81797474, - 0x878C8D8A, - 0x7E82878A, - 0x7C7B7A7B, - 0x87858280, - 0x7A7E8286, - 0x7B7C7A7A, - 0x7A7A797A, - 0x81807E7B, - 0x8C8B8784, - 0x7B898D8C, - 0x6F68636B, - 0x80808181, - 0x7F7F7F80, - 0x8B898582, - 0x92908D8D, - 0x8F919598, - 0x8E959993, - 0x8C8A8C92, - 0x807A7C87, - 0xA19B9189, - 0x888E989F, - 0x8B8A8782, - 0x7D848A8C, - 0x757A8186, - 0x75757474, - 0x81817F7D, - 0x71747A7E, - 0x7A716D6B, - 0x81868884, - 0x767A7A77, - 0x82817C76, - 0x86898A8B, - 0x817C7A7F, - 0x6E707476, - 0x7474726F, - 0x686D6F6F, - 0x5F5D5E62, - 0x7574726F, - 0x7D7A7775, - 0x8D8C8780, - 0x888B8C8C, - 0x8C8B8A89, - 0x8386888B, - 0x85828182, - 0x7D7D8084, - 0x7A818481, - 0x50627276, - 0x55605A59, - 0x726F6E5A, - 0x8D8A7E74, - 0x8786868A, - 0x786F7A8C, - 0x737D8887, - 0x7A7A7A7A, - 0x7E7D7B7A, - 0x7C7E7E7F, - 0x797A7A7B, - 0x686D7377, - 0x77736D68, - 0x78787776, - 0x78787979, - 0x7C7B7874, - 0x79797A7B, - 0x7B7D8183, - 0x83817D7B, - 0x76797E82, - 0x807E7A77, - 0x82838383, - 0x7D7E8081, - 0x7B7C7C7C, - 0x7A7A7A7B, - 0x77797A7B, - 0x75757576, - 0x76767676, - 0x76767676, - 0x6F6F6F6F, - 0x6E6E6E6E, - 0x706E6D6C, - 0x75747472, - 0x76777979, - 0x73737474, - 0x76777574, - 0x7A787574, - 0x87858280, - 0x82848787, - 0x85868687, - 0x82838384, - 0x86858584, - 0x84848586, - 0x81808181, - 0x87878785, - 0x84858687, - 0x7E7F8182, - 0x79797979, - 0x76777879, - 0x7F7B7977, - 0x86858481, - 0x88878787, - 0x85868787, - 0x85868583, - 0x72757B81, - 0x8481807E, - 0x86868786, - 0x7F818283, - 0x7577797C, - 0x85807A76, - 0x80828587, - 0x7F828486, - 0x7274777B, - 0x81807E7D, - 0x88878684, - 0x87878787, - 0x7D808285, - 0x8181807F, - 0x7D7E8081, - 0x837F7E80, - 0x757C8487, - 0x84817B76, - 0x82828384, - 0x83828180, - 0x87868584, - 0x84858686, - 0x70757C81, - 0x72747577, - 0x79777473, - 0x61616468, - 0x716E6A65, - 0x7B7B7774, - 0x5F5F6572, - 0x6462615F, - 0x7A7A756C, - 0x777A7B7C, - 0x686A6E74, - 0x746F6B68, - 0x6E717475, - 0x615D6269, - 0x5E666C69, - 0x81766961, - 0x85878988, - 0x6F737B84, - 0x6B6D6F6F, - 0x6E69696D, - 0x68707675, - 0x63635B52, - 0x6C645D5E, - 0x7E7C7874, - 0x7374787B, - 0x6A6F7476, - 0x66646265, - 0x7576736E, - 0x73747474, - 0x807B7875, - 0x8E8D8985, - 0x6972808A, - 0x847D736A, - 0x7D787A80, - 0x80878B87, - 0x8C8A8887, - 0x8C8D8D8D, - 0x928D8C8B, - 0x858B9294, - 0x7B7B7B7C, - 0x7F7E7D7B, - 0x837C7A7A, - 0x8F92928D, - 0x6F707983, - 0x79777473, - 0x7C777677, - 0x94928C83, - 0x82878B8D, - 0x797A7C80, - 0x6D6F7477, - 0x68686A6C, - 0x6E67625F, - 0x87847E76, - 0x82838687, - 0x7A7C7F81, - 0x7474716F, - 0x73737374, - 0x857F7A78, - 0x7C818788, - 0x74787A7B, - 0x66686C70, - 0x6A706F69, - 0x64646264, - 0x5C5D5E5F, - 0x5A5A5A5B, - 0x54515152, - 0x736C6259, - 0x6B686B6E, - 0x7C7A7771, - 0x7A7B8084, - 0x8A87837E, - 0x7B7D7F80, - 0x7C7B7A7A, - 0x77797A7C, - 0x6E707476, - 0x6D6C6C6B, - 0x7473716E, - 0x76767676, - 0x75757676, - 0x63666C71, - 0x726F6A66, - 0x827B7774, - 0x8990938C, - 0x91918F8D, - 0x8C8E9091, - 0x6E737C85, - 0x73747470, - 0x81777476, - 0x67707D85, - 0x7F7D746D, - 0x7674747A, - 0x74747575, - 0x6E6E7173, - 0x736F6D6C, - 0x88857F79, - 0x87878788, - 0x86878989, - 0x7071777D, - 0x70737473, - 0x6B6D6E6E, - 0x6868696A, - 0x5A5D6162, - 0x6264625C, - 0x5C5C5C5C, - 0x56585B5C, - 0x5C565657, - 0x6C76796B, - 0x5C595C5F, - 0x61646662, - 0x59565656, - 0x6866625D, - 0x6F6E6D6D, - 0x74737271, - 0x70727374, - 0x696A6C6E, - 0x6E6E6A65, - 0x6265686C, - 0x6868625E, - 0x585C6066, - 0x6C645E5B, - 0x6C6E7271, - 0x7A78726D, - 0x6B6E7278, - 0x7B7B746E, - 0x6E6D6F75, - 0x71625E6A, - 0x73757474, - 0x726D6C6E, - 0x7C7F7F7A, - 0x74767779, - 0x74747474, - 0x74737372, - 0x78777674, - 0x897F8391, - 0x636B7D8D, - 0x6D66615E, - 0x75767673, - 0x73767879, - 0x696A6D70, - 0x605E4C65, - 0x51585367, - 0x4F5C4E45, - 0xE2E4D342, - 0xEBEBE8DC, - 0xE8E7E2EB, - 0xC8D7EBE2, - 0xEBEBD0EB, - 0x7B8CDFDE, - 0x78706471, - 0x80816A68, - 0x28567456, - 0xE2EBEAEB, - 0xD7EBEBD8, - 0xEBE4E6E3, - 0xE5E5EBDF, - 0x6858CAE6, - 0x6D657D65, - 0x6868696A, - 0x6A696968, - 0x6E5C6D65, - 0x96949381, - 0x70687C93, - 0xE5EBDB32, - 0x63C4D4CA, - 0x6A767A63, - 0x6B6B6B6B, - 0x6B6B6B6B, - 0x716E6E55, - 0xEBB43E68, - 0xEBC6E7EB, - 0xC7DFEBE5, - 0xEBEBE8E4, - 0xD6EBDEEB, - 0x62EBE1D6, - 0x767A536E, - 0x62666C70, - 0x6E6B6662, - 0x70717171, - 0x6E6E6E6F, - 0x5C636E74, - 0x67635E5B, - 0x5D596D67, - 0x65636463, - 0x68625B71, - 0x15535C71, - 0xDBE4E1EA, - 0x828FD7DA, - 0x575A5B5C, - 0x51525456, - 0x695D5757, - 0x686B4A69, - 0xEBE0BB3A, - 0xE8E9DEE6, - 0xE9E9E6EB, - 0xE1EBEBEB, - 0x69DCCFEB, - 0x4B3E444A, - 0x5451504F, - 0x5C5A5856, - 0x5C5C5B5B, - 0x58595B5C, - 0x58585857, - 0x5A595959, - 0x5046546A, - 0x4950363A, - 0xE5EBE110, - 0xC5EBD4E6, - 0xE7E7E7E7, - 0xE7E7E7E7, - 0xEBEBD3E7, - 0x6475D6E0, - 0x64635B53, - 0x7C716562, - 0x1E457A8E, - 0xDFEBEBC5, - 0xE3E3EBC7, - 0xEBE6E5EB, - 0xEBE8E5DB, - 0xEBE0EBDC, - 0x40125DE0, - 0x3E486060, - 0x4B4B4B4B, - 0x4E4D4C4C, - 0x4D4F5154, - 0x5654504E, - 0x4E6D4C4D, - 0xDF392F31, - 0xC3E4E0E3, - 0xE0DEEBEB, - 0xEBE1E2DC, - 0xE1EBE7D2, - 0x4A165EE8, - 0x45536868, - 0x4D4E535C, - 0x3631524E, - 0xD7DC2E3E, - 0xEBCBDCEB, - 0xE6E7E5EB, - 0xC3E4EBEB, - 0xEBEBDAEB, - 0x7557466E, - 0x6E68615C, - 0x66696E70, - 0x6F6E6863, - 0x5F62666C, - 0x585B5B55, - 0x747C6756, - 0x5B495256, - 0xE1EBC329, - 0xEBEBD2C9, - 0xEBE2EBEB, - 0xD4DCEBE8, - 0xEBEBC5EB, - 0x5A6AC1E2, - 0x8D96746E, - 0x474D6B74, - 0x145F5E4A, - 0xE8E4EBE9, - 0xEBEBE0EB, - 0xE7E7E8E8, - 0xE7E8E8E8, - 0xEBEBE0E7, - 0x6E7742EB, - 0x807C7671, - 0x6C71797E, - 0x67696E70, - 0x726E6A67, - 0x71707071, - 0x62676D70, - 0xE7255C5E, - 0xE6E1EBEB, - 0xEBEBEBEB, - 0xEBEBEBEB, - 0xEBEBEBEB, - 0xEBEBEBEB, - 0x4B4A5751, - 0x3A404C3E, - 0xCE453E49, - 0xE6E3DDE5, - 0xD9E4E9EB, - 0xDCEBEBD9, - 0xE1EBEBCA, - 0xD1DDEBEB, - 0x5043574F, - 0x6E6B6861, - 0x63606162, - 0x585E6466, - 0x3D414548, - 0x32333538, - 0x7B757372, - 0x8A898781, - 0x85888C8D, - 0x7C7D7F81, - 0x82828282, - 0x7F808181, - 0x7D7D7A79, - 0x7F7D7C7D, - 0x77787979, - 0x79797877, - 0x85807C7A, - 0x908F8D89, - 0x78777A7F, - 0x8786827D, - 0x86898C8D, - 0x7D7E8082, - 0x7A7A7B7D, - 0x8886817B, - 0x90888380, - 0x96999997, - 0x82878B8E, - 0x7A7B7C7F, - 0x8B85807D, - 0x9D9A9691, - 0x8F969EA4, - 0x8D878488, - 0x8C8E9294, - 0x8C8C8C8B, - 0x818D918D, - 0x878D8980, - 0x8E99917F, - 0x85888785, - 0x86848585, - 0x88898A88, - 0x8C8C8A8B, - 0x76767C86, - 0x74737374, - 0x7A7B7A78, - 0x7D7A7878, - 0x8D8C8883, - 0x81868B8E, - 0x696E747B, - 0x5C5C6063, - 0x736F6862, - 0x7C797471, - 0x8B888480, - 0x8E909191, - 0x88898B8D, - 0x858B8B88, - 0x7F7A787C, - 0x89888787, - 0x87878888, - 0x81818284, - 0x7C7F8283, - 0x8786817E, - 0x84848687, - 0x76787A7C, - 0x76757474, - 0x76767676, - 0x77777777, - 0x78777778, - 0x7A7A7B7A, - 0x8684807D, - 0x70757E84, - 0x71747574, - 0x77736E6E, - 0x7C7D7879, - 0x76858279, - 0x7A7A7673, - 0x7A767475, - 0x7A7D8182, - 0x7E7C7A7A, - 0x8583817F, - 0x7D7F8184, - 0x7C7E7F7E, - 0x7877777A, - 0x817C7A7A, - 0x8F8D8986, - 0x7A8C9598, - 0x8074686B, - 0x83888D8E, - 0x7174787D, - 0x837C7673, - 0xA49E948B, - 0xBABDC4C9, - 0x96A6B6BA, - 0x89868284, - 0x7A787C86, - 0xA1998D83, - 0x878D98A0, - 0x9B99938C, - 0x848E999B, - 0x7474777A, - 0x79787775, - 0x7D7E7D7C, - 0x6F72767A, - 0x706B696B, - 0x6F747876, - 0x706A6A6A, - 0x8A8C877B, - 0x84898D8E, - 0x7C7F8181, - 0x78787470, - 0x7D7A7575, - 0x69717679, - 0x7A736966, - 0x6D6F7A84, - 0x7C7B7872, - 0x8C8D8881, - 0x82878B8B, - 0x8C888787, - 0x80858B8D, - 0x817C7A7C, - 0x807D7E82, - 0x767C7F7B, - 0x66717875, - 0x6E747377, - 0x818D967E, - 0x88877F78, - 0x83818084, - 0x7A757B86, - 0x757C8482, - 0x7979797A, - 0x7C7B7A7A, - 0x7A7B7B7C, - 0x77787879, - 0x6D6F7375, - 0x75736F6D, - 0x78787776, - 0x78787979, - 0x7E7C7976, - 0x7A7A7B7D, - 0x7A7D8184, - 0x84817D7A, - 0x797B8084, - 0x82817E7A, - 0x82838485, - 0x7C7D7F81, - 0x7A7A7A7B, - 0x7979797A, - 0x76787A7A, - 0x74747475, - 0x76767675, - 0x76767676, - 0x6F6F6F6F, - 0x6E6E6E6E, - 0x6E6D6C6B, - 0x7271706F, - 0x72747575, - 0x6C6D6E70, - 0x75746F6B, - 0x75737273, - 0x8985807C, - 0x8285888A, - 0x81818181, - 0x80808080, - 0x84838382, - 0x83838484, - 0x82818182, - 0x88888785, - 0x82848686, - 0x797A7D80, - 0x7A7A7978, - 0x797A7A7A, - 0x7E7B7A79, - 0x83828181, - 0x81818181, - 0x80808181, - 0x88868280, - 0x80828688, - 0x87868584, - 0x85868787, - 0x777A7D7E, - 0x6F707274, - 0x827D7672, - 0x7E818385, - 0x7E818181, - 0x686C7279, - 0x7F7D7C7B, - 0x86858381, - 0x82838382, - 0x7C7C7E80, - 0x7D7D7C7C, - 0x78797A7C, - 0x807A7979, - 0x71798183, - 0x817B7570, - 0x80818283, - 0x7E7C7B7B, - 0x85848381, - 0x7D7E7F80, - 0x696E747A, - 0x6A6C6E70, - 0x77746F6C, - 0x6566686B, - 0x706E6B68, - 0x7F7D7773, - 0x6A686E78, - 0x62686D6E, - 0x686A6862, - 0x8A807167, - 0x6872808A, - 0x736E6865, - 0x74767776, - 0x716C7077, - 0x70777D7A, - 0x756C625D, - 0x7F80807D, - 0x6E757C81, - 0x6C6D6D6D, - 0x726E6D6E, - 0x7A7A7A77, - 0x70797873, - 0x6A625E63, - 0x74767879, - 0x7A767372, - 0x68727A80, - 0x66626062, - 0x79787168, - 0x6F747878, - 0x817C7A78, - 0x908E8A86, - 0x727A8790, - 0x8D867A73, - 0x7A7A8087, - 0x6E757C7D, - 0x8D8D8B8A, - 0x898A8B8C, - 0x8D898787, - 0x7E848C8E, - 0x76767677, - 0x77777676, - 0x7C757374, - 0x898C8C86, - 0x6E6E7580, - 0x77747371, - 0x7F797574, - 0x8E8E8B86, - 0x7C808589, - 0x7476797A, - 0x7173777A, - 0x6D6E6F70, - 0x7E766E6A, - 0x85868683, - 0x7B7A797A, - 0x7C7E7F7E, - 0x6E71767A, - 0x6E6D6D6C, - 0x867E7772, - 0x84878989, - 0x777C7F80, - 0x61646A71, - 0x6C706E67, - 0x6C6B6868, - 0x60626465, - 0x5C5C5C5E, - 0x4F4C4D4F, - 0x6A655C55, - 0x64616266, - 0x7575736C, - 0x7877797A, - 0x7A7A7A79, - 0x73747474, - 0x77767474, - 0x6F707374, - 0x67696C6E, - 0x6D6B6A69, - 0x7474716F, - 0x76757474, - 0x79787877, - 0x65686F74, - 0x6F6E6966, - 0x87817B77, - 0x8B939690, - 0x99959291, - 0x92939699, - 0x8C8C9094, - 0x878B8D8D, - 0x7E79797E, - 0x666D7981, - 0x807E756E, - 0x7775767A, - 0x74747575, - 0x6E6F7072, - 0x74706E6E, - 0x87847E79, - 0x85828387, - 0x868A8D8A, - 0x7071767B, - 0x6E717473, - 0x68696B6C, - 0x68686868, - 0x6B67686B, - 0x81858377, - 0x5C5C5E60, - 0x5B5C5D5C, - 0x59565859, - 0x65737668, - 0x5A565657, - 0x63666662, - 0x57555453, - 0x67635F5A, - 0x6F6E6E6D, - 0x74747371, - 0x6F717272, - 0x68686B6E, - 0x68676565, - 0x66656567, - 0x6C6B6762, - 0x5D5F6469, - 0x675C5550, - 0x6E6F716E, - 0x7A756E69, - 0x6F72767A, - 0x81807972, - 0x6B6D727A, - 0x6F646069, - 0x6E727070, - 0x6C68696D, - 0x7B7C7A74, - 0x72737475, - 0x76747472, - 0x77767676, - 0x76767677, - 0x8D83838D, - 0x6F707C8C, - 0x716A6768, - 0x74787B79, - 0x73747677, - 0x6E6E6F71, - 0x62655878, - 0x69565C6B, - 0x1410164B, - 0xE8E2C73D, - 0xD0EBD5EB, - 0xEAEAEBEB, - 0xEBEBD0D8, - 0xD4DCEBD0, - 0x6A7ADEEB, - 0x5762636C, - 0x52706977, - 0x10274110, - 0xE0CBE8EB, - 0xEBE0E6EB, - 0xDBC3DAEB, - 0xE8EBEBC3, - 0x3835C1EB, - 0x6E4E5031, - 0x66686869, - 0x64646465, - 0x8C5C5A75, - 0x8C907670, - 0x311D8B7B, - 0xCBEBC525, - 0x81DDE3EB, - 0x605F687C, - 0x67676767, - 0x67676767, - 0x21155B6F, - 0xEBB0222B, - 0xC0EBE0E3, - 0xEBEBE8E0, - 0xDADBE0E4, - 0xD5EBBFE2, - 0x1DC5DEEB, - 0x59431E25, - 0x61646A6E, - 0x6B686360, - 0x6B686564, - 0x7776746F, - 0x61666F75, - 0x68666361, - 0x5A5F6A75, - 0x736E6E64, - 0x63685363, - 0x101C2D3F, - 0xE9EBE6E7, - 0x6171D6E2, - 0x51525252, - 0x4F505050, - 0x5754443D, - 0x1D371047, - 0xCAD7B939, - 0xE4E6EBE7, - 0xEBEBE2E8, - 0xE4D8EADB, - 0x2EDEEAEB, - 0x32293113, - 0x53504D4B, - 0x57575656, - 0x5B5C5B5B, - 0x54555759, - 0x55555555, - 0x55555555, - 0x51694B5F, - 0x1B371054, - 0xCCEBDC2B, - 0xE3E6DCEB, - 0xE9E9E9E9, - 0xE9E9E9E9, - 0xE0E8EBE4, - 0x6C63E8DC, - 0x65676E75, - 0x535A6265, - 0x19152410, - 0xDBE2EBCA, - 0xE6E9D1EB, - 0xD7E9E8D2, - 0xDAEBEBEB, - 0xDEE2DEE7, - 0x40104ED0, - 0x3B44564F, - 0x4A4B4C4C, - 0x4C4C4B4A, - 0x4A4D5155, - 0x514F4B49, - 0x16412F3C, - 0xE0341F19, - 0xE3E7BEEB, - 0xEBEBE4D0, - 0xDBE2EBE5, - 0xEBE9E0E7, - 0x491356E2, - 0x313F5050, - 0x44566257, - 0x2E13483A, - 0xEBE61910, - 0xE7EBEBD1, - 0xE2EBDFDD, - 0xEBE8EBDC, - 0xE7EBD6EB, - 0x633C1035, - 0x7A746D68, - 0x6F73787A, - 0x6C6E6F70, - 0x49515D67, - 0x55505363, - 0x70727463, - 0x1A191051, - 0xE8D2D03E, - 0xCAE0E4EB, - 0xE2EADDEB, - 0xEBEBDFEB, - 0xD2EBDDD0, - 0x5F7ADCEB, - 0x7A786267, - 0x535C7880, - 0x105A5E50, - 0xEBE6EBE7, - 0xCADBC7EB, - 0xE8E8E8E9, - 0xE3E6E8E9, - 0xCBE8DBE3, - 0x79817DC3, - 0x77726E6E, - 0x61687379, - 0x88837568, - 0x72747A83, - 0x65666B6F, - 0x61646867, - 0xD1104A50, - 0xE8E3E8DE, - 0xE2E2E2E2, - 0xE2E2E2E2, - 0xE5E5E6E6, - 0xE4E4E4E5, - 0x484A5F5E, - 0x293C5040, - 0xD63A101C, - 0xE8EBE3E4, - 0xDEEBEBEA, - 0xDFEBE7D7, - 0xE8EBEBE4, - 0xEAD2EBD5, - 0x40342A10, - 0x6164695F, - 0x62616264, - 0x555B6264, - 0x383D4043, - 0x30303134, - 0x7F797574, - 0x89898885, - 0x85878B8C, - 0x7D7E7F81, - 0x81828282, - 0x7C7D7F81, - 0x7A7A7977, - 0x7B7A7879, - 0x7C7C7D7D, - 0x7D7D7C7C, - 0x87848180, - 0x8E8D8D8A, - 0x77747E89, - 0x81878A82, - 0x8788898A, - 0x7F808285, - 0x6E707476, - 0x7C79746F, - 0x8C837D7A, - 0x94979994, - 0x7C808589, - 0x7F7F7D7C, - 0x7F7D7B7A, - 0x8E8B8581, - 0x8A8E979F, - 0x8D878587, - 0x91929191, - 0x888A8D8F, - 0x7D868B8A, - 0x8E8F887E, - 0x8B8F887B, - 0x88898786, - 0x89878686, - 0x888A8C8C, - 0x81828284, - 0x6E6E737B, - 0x78747372, - 0x7E7F7E7C, - 0x7B79797A, - 0x87878480, - 0x7F83888B, - 0x666B7279, - 0x58585C61, - 0x716D655C, - 0x837D756F, - 0x88878787, - 0x8E909191, - 0x88898B8D, - 0x888D8A86, - 0x7A797980, - 0x8482807F, - 0x89888787, - 0x84838485, - 0x7D808384, - 0x81817F7D, - 0x81817F80, - 0x797A7A7A, - 0x7A7A7979, - 0x77787878, - 0x75767677, - 0x70727577, - 0x6C6E6F70, - 0x8881746B, - 0x81828689, - 0x76767472, - 0x7E7A7675, - 0x83857F85, - 0x7A8E897C, - 0x7579736C, - 0x7E746C6E, - 0x75757576, - 0x7A797876, - 0x7C7C7C7C, - 0x7F7F7E7D, - 0x7C808282, - 0x78767678, - 0x857D797A, - 0x93908E8C, - 0x929B9E9C, - 0x8F888387, - 0x878E9396, - 0x72747A81, - 0x7D777370, - 0xAAA19387, - 0xC1C6CACA, - 0x8E9EB0BA, - 0x857E7977, - 0x7E7C7F84, - 0x9C958A81, - 0x888D959C, - 0xABABA49A, - 0x8F9DA8AB, - 0x74777A7D, - 0x71737474, - 0x6A6C6D6E, - 0x5F616468, - 0x62606062, - 0x62656665, - 0x81746E6C, - 0x9699988E, - 0x858C8F8D, - 0x767F8483, - 0x81817A73, - 0x817D7A7C, - 0x6F757B7E, - 0x978A796E, - 0x686F869A, - 0x817D776E, - 0x858A8983, - 0x7B828583, - 0x857F7C7B, - 0x757D8789, - 0x7A716E70, - 0x827D7B7E, - 0x777B7C7B, - 0x7F7F7C78, - 0x7E818189, - 0x808E9F8D, - 0x88898581, - 0x84818183, - 0x7A7A7B7F, - 0x797B7E7D, - 0x797A7A7A, - 0x7A7A7979, - 0x77787979, - 0x75757676, - 0x74747474, - 0x74747474, - 0x79787777, - 0x7979797A, - 0x81817C7A, - 0x7D7E7F81, - 0x7F818284, - 0x8482817F, - 0x7C7E8185, - 0x8382817E, - 0x7F818385, - 0x7A7A7B7D, - 0x78787979, - 0x7A797878, - 0x76777879, - 0x74747474, - 0x75757575, - 0x76767676, - 0x71727272, - 0x70707171, - 0x6F6E6E6E, - 0x7070706F, - 0x70717272, - 0x696A6C6E, - 0x75746E68, - 0x716F6E72, - 0x88837B76, - 0x7F83878A, - 0x7B7B7B7B, - 0x7F7E7D7B, - 0x82818181, - 0x82828283, - 0x82818182, - 0x87878785, - 0x81848585, - 0x74777A7E, - 0x7B797776, - 0x7F7F7E7D, - 0x7F7E7D7C, - 0x7F7F807F, - 0x7A7B7D7E, - 0x7C7B7A7A, - 0x8B86807B, - 0x8D8E8F8E, - 0x86878787, - 0x81818385, - 0x7074787A, - 0x6A6A6B6E, - 0x807A736E, - 0x7B7E8182, - 0x787A7978, - 0x63676E74, - 0x7E7B7A79, - 0x81818180, - 0x7C7F8080, - 0x74747578, - 0x77767574, - 0x74747576, - 0x6D6B6E70, - 0x74747470, - 0x7A777474, - 0x7F81817F, - 0x77747578, - 0x8081817D, - 0x7A7B7B7C, - 0x696E7479, - 0x6465686A, - 0x746F6A66, - 0x6D6E6F70, - 0x72716F6E, - 0x837E7874, - 0x7A797B81, - 0x68737C81, - 0x68696866, - 0x8F816F62, - 0x6D788792, - 0x6966625F, - 0x67686A6B, - 0x77707074, - 0x7F858781, - 0x6E6C6C6C, - 0x78787673, - 0x6E767C7D, - 0x6E6D6A69, - 0x72716F6E, - 0x7E7B7774, - 0x6D7A7B78, - 0x5E56525B, - 0x6E727577, - 0x807A736E, - 0x68737D83, - 0x63605D60, - 0x7F7C7368, - 0x777F8280, - 0x807D7C7B, - 0x8C8A8783, - 0x7C81898F, - 0x8C88827D, - 0x7A7A7E81, - 0x777B7E7E, - 0x8D8D8D8B, - 0x8787878A, - 0x8A878585, - 0x7980878B, - 0x74737373, - 0x70737576, - 0x7D777575, - 0x898A8884, - 0x6E6E7681, - 0x73717170, - 0x7C777473, - 0x84858581, - 0x74767C81, - 0x6E717373, - 0x71717374, - 0x71737373, - 0x88837C78, - 0x7D818789, - 0x78747271, - 0x8081807C, - 0x686F7981, - 0x6A6A6968, - 0x857C736C, - 0x88888988, - 0x7A7F8182, - 0x5D626A72, - 0x70726E67, - 0x7674706E, - 0x6A6C6D6E, - 0x66666868, - 0x59585A5C, - 0x6A68635D, - 0x57596168, - 0x6867635C, - 0x78746F6C, - 0x6A6E7478, - 0x6B696868, - 0x72706E6D, - 0x6C6E7072, - 0x6567696B, - 0x6B686765, - 0x7473716E, - 0x76747372, - 0x7B7A7978, - 0x6A6E747A, - 0x6F6E6C69, - 0x7A767574, - 0x83888981, - 0x918B8786, - 0x8C8C8E92, - 0x908C8988, - 0x92939493, - 0x7A777A81, - 0x636A747B, - 0x7F7B736C, - 0x7A797A7D, - 0x74757677, - 0x71717273, - 0x74737171, - 0x817F7B78, - 0x807C7E81, - 0x83878A87, - 0x7171757A, - 0x6C707474, - 0x67686869, - 0x6B696868, - 0x736E6E71, - 0x888E8D81, - 0x5F606367, - 0x5F616261, - 0x56565B5A, - 0x606E7263, - 0x59565555, - 0x5E5E5E5C, - 0x5A5A5857, - 0x62605C5B, - 0x68676665, - 0x6D6C6B69, - 0x6E6E6E6E, - 0x6466686B, - 0x62606164, - 0x6A666362, - 0x73726F6C, - 0x66686B6F, - 0x6E68625E, - 0x6D6E7070, - 0x74716D6A, - 0x79797977, - 0x82817A75, - 0x696E777F, - 0x6F666269, - 0x6C706F6E, - 0x68686A6E, - 0x7373716D, - 0x70707171, - 0x76757472, - 0x80818181, - 0x7A7B7D7F, - 0x84807A79, - 0x7B75757F, - 0x74757A7F, - 0x70747675, - 0x6F707172, - 0x6F6F6E6E, - 0x74766F80, - 0x54285C79, - 0xE6C81A56, - 0xE5CBEBE0, - 0x212CBBE8, - 0x101E1010, - 0x1D191F30, - 0xEBEBDE10, - 0x6B78D4DC, - 0x7D7E7472, - 0x646F5C6F, - 0xEAE8C937, - 0xE4EBE4E4, - 0x25101FD6, - 0x23172710, - 0xCFEBBF26, - 0xE0D2EBD6, - 0x936E7AB5, - 0x63656868, - 0x5F5F6062, - 0x60567A55, - 0x7A68625B, - 0xC6117F6A, - 0xEBE4EBB5, - 0x66DDE0DE, - 0x626A5F67, - 0x61616060, - 0x62626261, - 0xBF386560, - 0xE2EBD5E9, - 0x1CDEEBEB, - 0x101A2419, - 0x161C1914, - 0xEBC92225, - 0xEBE9EBE6, - 0x7560D7E4, - 0x6064696D, - 0x69676260, - 0x68626060, - 0x7A78746E, - 0x62646A70, - 0x60626262, - 0x6E6C5F60, - 0x4B645C72, - 0x62716E62, - 0xE8DE3A6D, - 0xE6E8DCDB, - 0x646FE1E5, - 0x4D4C4C4C, - 0x4F4E4E4D, - 0x55544D4F, - 0xDCD63E5F, - 0xEBCCEBDB, - 0x152DC6EB, - 0x101D2512, - 0xDEC52731, - 0xD0EBD7E9, - 0x5772D6E1, - 0x504F4D4B, - 0x55555452, - 0x595B5C5C, - 0x51535557, - 0x53535353, - 0x53535353, - 0x5B724E56, - 0xE3C5316D, - 0xE6C5EBE4, - 0x1927C2EB, - 0x10101010, - 0x10101010, - 0xEBEAD11B, - 0x6A56EBEB, - 0x565C666D, - 0x4A4D5154, - 0xD0E3CA44, - 0xEBC7E8EB, - 0x312525C1, - 0x17212613, - 0x221A1016, - 0xEBE9EBCA, - 0xE8EBDBD0, - 0x5A585674, - 0x494A4A4B, - 0x4D4C4A4A, - 0x4B4E5254, - 0x4F4D4B4A, - 0x2D3B455E, - 0xD6C9EBC6, - 0xEBEBDFC7, - 0x1010111B, - 0x12101010, - 0xB7EBEBEB, - 0xDDE7CCC8, - 0x48474062, - 0x3A495653, - 0x99134062, - 0xE6E5EBE5, - 0x24D9EBDA, - 0x20211816, - 0xCA31171F, - 0xEADCEBDF, - 0x7DC7E2E5, - 0x7A756F6B, - 0x72757A7B, - 0x6C6E7275, - 0x444E5C66, - 0x5245455E, - 0x553B5F6C, - 0xDECA106B, - 0xEBD4EBCB, - 0x1E1FB0D1, - 0x102A1913, - 0x1013101B, - 0xE4EBC410, - 0x6070CED2, - 0x6060616D, - 0x66697D7E, - 0x105D6962, - 0xCDDAEBEB, - 0x103741B3, - 0x15121111, - 0x10131818, - 0x101B1714, - 0x756D561F, - 0x6E6A6D73, - 0x60656D70, - 0x998B6F58, - 0x80828A96, - 0x62656C72, - 0x64666764, - 0xDF236268, - 0xEAE8EBE8, - 0x1F1F1F1F, - 0x1F1F1F1F, - 0x14151515, - 0x13131314, - 0x5257696C, - 0x27496457, - 0xEBE2E3E0, - 0xEBD7D1EB, - 0x25191013, - 0x17101018, - 0xBC151014, - 0xEBE0EBEB, - 0x58B7E5EB, - 0x675D5B54, - 0x615F5F5F, - 0x52585E62, - 0x393F4447, - 0x2C2D3034, - 0x817A7674, - 0x87898A87, - 0x82848687, - 0x80808081, - 0x7F818181, - 0x797A7B7D, - 0x76777776, - 0x77757474, - 0x81818283, - 0x83828181, - 0x89878584, - 0x8D8D8D8B, - 0x7A7A838D, - 0x81878983, - 0x88898988, - 0x7D7F8387, - 0x696D7275, - 0x76736E69, - 0x877F7A7A, - 0x8D919390, - 0x7B7D8186, - 0x8786837F, - 0x7A7E7F7F, - 0x7F7C7978, - 0x807E848C, - 0x89878583, - 0x918F8C89, - 0x898B8D90, - 0x83868A8D, - 0x97928B86, - 0x81828689, - 0x88888783, - 0x8D898786, - 0x898C8F8F, - 0x7577787A, - 0x6664686F, - 0x7A757270, - 0x81818280, - 0x7776787A, - 0x7E7D7C79, - 0x797B7F81, - 0x65696F74, - 0x56575C61, - 0x706B635B, - 0x7C7A7876, - 0x8D89837F, - 0x888A8A8B, - 0x81838587, - 0x8C8D867E, - 0x7E7C7E84, - 0x817E7C7A, - 0x87868583, - 0x84858586, - 0x797B8083, - 0x74767778, - 0x77747272, - 0x7D7A7877, - 0x81818180, - 0x7A7B7C7D, - 0x74757678, - 0x6C6E7376, - 0x6667686A, - 0x8C867669, - 0x81808288, - 0x77797877, - 0x7F7A7675, - 0x8C8E858A, - 0x7A91897D, - 0x797B756E, - 0x82797172, - 0x7A7A7978, - 0x78797A7A, - 0x73747679, - 0x83807A75, - 0x7C818587, - 0x7A777677, - 0x8D817A79, - 0x93939595, - 0xA9A79E95, - 0x99999EA5, - 0x8A8D8F90, - 0x81838587, - 0x7C7A7B7C, - 0x9F988C81, - 0xAEB7B1A8, - 0x8287929F, - 0x827E7A7A, - 0x83818182, - 0x958F8781, - 0x8E909396, - 0xA8AAA59B, - 0x8D9AA5A6, - 0x71798187, - 0x6365686C, - 0x595C5F61, - 0x52525456, - 0x59575656, - 0x605F5D5B, - 0x78706862, - 0x82817E7C, - 0x858E8F89, - 0x757E8181, - 0x82817C77, - 0x82807E80, - 0x757A7E80, - 0x9F928176, - 0x7275879A, - 0x85827E78, - 0x7B848783, - 0x747B7D7A, - 0x827A7473, - 0x6E798588, - 0x72686468, - 0x7D767476, - 0x7677787A, - 0x867C7474, - 0x878D878B, - 0x7E828F89, - 0x83878582, - 0x807D7C7F, - 0x7E7E7D7B, - 0x7C7E7F7E, - 0x797A7C7D, - 0x76777778, - 0x76767777, - 0x74747475, - 0x79787675, - 0x75767879, - 0x7A797878, - 0x7A7A7A7A, - 0x8685817E, - 0x81828385, - 0x86858584, - 0x84858586, - 0x80818385, - 0x83838381, - 0x7A7E8184, - 0x78787778, - 0x76767677, - 0x7A7A7876, - 0x75767777, - 0x75747474, - 0x75747474, - 0x76767675, - 0x74747575, - 0x74747474, - 0x73747474, - 0x72727273, - 0x74747473, - 0x70717374, - 0x7476716C, - 0x706D6C6F, - 0x87807772, - 0x7A7F8588, - 0x78777878, - 0x7D7C7A79, - 0x8181807F, - 0x81818182, - 0x81808181, - 0x84858482, - 0x81838485, - 0x7174787D, - 0x77747270, - 0x83817F7B, - 0x81818181, - 0x7D7E7F80, - 0x787A7E81, - 0x7F7C7A78, - 0x8F8B8682, - 0x8D8F9191, - 0x82858789, - 0x7B7B7D80, - 0x6B6F7476, - 0x66666768, - 0x7D776F6A, - 0x797B8081, - 0x70737475, - 0x5F62676B, - 0x7D7A7875, - 0x7E7F807F, - 0x757B7E7F, - 0x6868696E, - 0x6F6E6C6A, - 0x6F6F7070, - 0x62626669, - 0x7D776E66, - 0x73747A81, - 0x7E7F7D78, - 0x706D7074, - 0x797C7E79, - 0x78787878, - 0x686C7276, - 0x61626568, - 0x736E6862, - 0x76777676, - 0x75747475, - 0x88817A79, - 0x8987898B, - 0x757D8587, - 0x75777673, - 0x83807A76, - 0x74787E83, - 0x6B6A6866, - 0x6365686A, - 0x766E6C6C, - 0x83868781, - 0x73757C81, - 0x7C7A7874, - 0x6F7A7E7C, - 0x72706C69, - 0x6F707070, - 0x75747270, - 0x6771706B, - 0x5B534E56, - 0x74747474, - 0x7C797674, - 0x68737B80, - 0x5F5D5C60, - 0x817F7468, - 0x838A8A84, - 0x7F7E7F7F, - 0x84838180, - 0x83848688, - 0x81828383, - 0x7D7A7878, - 0x88878681, - 0x8B8D8C8A, - 0x82828387, - 0x89878585, - 0x777D8689, - 0x7D777474, - 0x72798081, - 0x82807E7D, - 0x8D8B8986, - 0x73747E89, - 0x72717274, - 0x77737170, - 0x7A7B7C7A, - 0x6B6D7378, - 0x686B6D6C, - 0x736E6B6A, - 0x7F7F7D79, - 0x8B87827F, - 0x7C81868A, - 0x81807F7F, - 0x83858584, - 0x6A707B84, - 0x6C6D6D6A, - 0x837D746D, - 0x81818284, - 0x7A7F8181, - 0x5E626B74, - 0x74757068, - 0x817E7974, - 0x76767675, - 0x75757676, - 0x6D6D7073, - 0x7272716E, - 0x585C666E, - 0x595C5C5B, - 0x7C74685E, - 0x6068737B, - 0x615E5C5C, - 0x6B696764, - 0x68696C6E, - 0x62636667, - 0x68646260, - 0x72706E6B, - 0x75747271, - 0x7D7C7A78, - 0x70747A80, - 0x71706F6E, - 0x6F6D6C6B, - 0x747A7C76, - 0x81787372, - 0x817F8083, - 0x8382807C, - 0x82818182, - 0x7573767D, - 0x62687177, - 0x7E786F69, - 0x7D7D7F80, - 0x74767879, - 0x71727274, - 0x74737271, - 0x7A797876, - 0x7A76777A, - 0x7F838581, - 0x7171757A, - 0x6A6E7374, - 0x68686868, - 0x6E6D6A68, - 0x74747473, - 0x7F83827B, - 0x696A6E71, - 0x62676A6B, - 0x565A5D5B, - 0x5F6D7062, - 0x59595755, - 0x56565657, - 0x5B5C5C5A, - 0x5A595758, - 0x5E5C5C5B, - 0x6262615F, - 0x6B6C6C6C, - 0x61636669, - 0x5D5B5D63, - 0x6E686260, - 0x7A7A7A78, - 0x6E6F7276, - 0x7B7D7A77, - 0x6C6D7076, - 0x6E6C6D6E, - 0x827F7A73, - 0x837F7A76, - 0x6B737C83, - 0x6F686268, - 0x6E73706F, - 0x6B6B6C6D, - 0x6E6E6D6C, - 0x706E6E6E, - 0x76757472, - 0x7D7F7F80, - 0x7475787A, - 0x76787168, - 0x7E746C6E, - 0x7A828788, - 0x65666870, - 0x6B6B6C6C, - 0x6E6E6D6B, - 0x6C6C7470, - 0x56105A76, - 0xE2EB211E, - 0xDCE4DCDC, - 0x6653E3EB, - 0x62745042, - 0x57597F52, - 0xE9DBDB2E, - 0x1E3FC7EB, - 0x7E755332, - 0x667D7290, - 0xE8E8CE29, - 0xD0DAEBE1, - 0x876E67EB, - 0x6B6C7E62, - 0xC7EBCC43, - 0xE6DAEAEB, - 0x60688BEB, - 0x62636668, - 0x5C5C5D5F, - 0x15196231, - 0x13101E23, - 0xEB101C19, - 0xEBC5EBE7, - 0x5FEBEBE9, - 0x5766565E, - 0x5D5D5D5C, - 0x5F5F5E5E, - 0xCF13635C, - 0xD1E5E9E7, - 0x41E2EBE5, - 0x44716E39, - 0x565C5044, - 0xEBD72C54, - 0xEBC1E2E8, - 0x8656EBE2, - 0x5D616669, - 0x65625F5C, - 0x62606162, - 0x6D6E6C68, - 0x5D5E6368, - 0x55595C5D, - 0x5756574C, - 0x1F4C1047, - 0x10101710, - 0xE1DA103E, - 0xE3E8E7EB, - 0x676FE9E7, - 0x4B4A4949, - 0x50504F4D, - 0x535A5150, - 0xDEDD2556, - 0xE7E1EBEB, - 0x657EE2E8, - 0x2B4A6350, - 0xE8E12852, - 0xE7E6EBE2, - 0x4B40D1EB, - 0x4A494949, - 0x5C59534E, - 0x575A5C5C, - 0x51525355, - 0x51515151, - 0x52525251, - 0x1E104060, - 0xEBBD261A, - 0xE1EBE6E8, - 0x2E74EBD6, - 0x53535353, - 0x53535353, - 0xEBE0D51D, - 0x1F2FC0DC, - 0x55514A42, - 0x4B4C4F53, - 0xDCDED424, - 0xD9ABEBE3, - 0x453755EB, - 0x382F3B38, - 0x404F3943, - 0xE8E2D0CF, - 0xCAE8EAEB, - 0x48595153, - 0x4949494A, - 0x52504D4A, - 0x4F505152, - 0x4D4D4E4E, - 0x19475D5C, - 0xE9EBE4CA, - 0xEBEAE4EB, - 0x5E5F6867, - 0x1D33344C, - 0xEBDCE9E9, - 0xD1EBE8EB, - 0x545F4B4E, - 0x4A42464A, - 0xE920436E, - 0xEBC3EBE9, - 0x4FE9EBE2, - 0x4444424E, - 0xDC423C45, - 0xD7EBEBD7, - 0xA2EBEBDA, - 0x706B6662, - 0x6C6E7172, - 0x696D6E6E, - 0x444C5762, - 0x51424258, - 0x6A1A4971, - 0xEBEB141C, - 0xD0EBDDD0, - 0x756EE4EB, - 0x565E6354, - 0x4C5F5C39, - 0xE9DCE148, - 0x203CCFEB, - 0x746A5F49, - 0x83777A70, - 0x30849287, - 0xEBE7EBEB, - 0x3D6866E5, - 0x625B5655, - 0x61666A68, - 0x5E646D50, - 0x4E736666, - 0x6A69737F, - 0x69696C6D, - 0x92866F5C, - 0x81828790, - 0x62656C72, - 0x61626362, - 0xD4104953, - 0xE9E0E6E1, - 0x61616161, - 0x61616161, - 0x72727171, - 0x73737372, - 0x60696F71, - 0x25557271, - 0xE9EBD8DF, - 0xEBEBE9DE, - 0x4A605E50, - 0x6A6D563F, - 0xCC305161, - 0xDEE9CAE3, - 0x5CDAEBEA, - 0x5C596762, - 0x5F5C5A58, - 0x55585C5F, - 0x424A5156, - 0x2B2D3139, - 0x827A7572, - 0x87898A88, - 0x81818181, - 0x82828181, - 0x7D7E7F80, - 0x7576787A, - 0x74757676, - 0x74737172, - 0x85868687, - 0x87868685, - 0x8A888786, - 0x8D8D8D8C, - 0x7F81888E, - 0x83848481, - 0x8A8B8A89, - 0x7A7D8287, - 0x6A6E7479, - 0x77736E69, - 0x857E7A7A, - 0x868B8E8C, - 0x7E7D8185, - 0x8E8D8983, - 0x7A7F8181, - 0x72707074, - 0x7871737A, - 0x86868581, - 0x8E8B8682, - 0x8C8D8D8F, - 0x8583878D, - 0x938D8787, - 0x77778799, - 0x8585847F, - 0x908C8887, - 0x8A8D9193, - 0x6D6F7174, - 0x5F5D6067, - 0x7C76716E, - 0x81838482, - 0x73747679, - 0x76767574, - 0x74757778, - 0x64686E71, - 0x56575C62, - 0x706B635B, - 0x72757A7F, - 0x938A7E74, - 0x81838484, - 0x7A7C7E80, - 0x8D8C8279, - 0x807F8187, - 0x7E7C7A79, - 0x82828181, - 0x84868686, - 0x74777C81, - 0x6A6C6E6E, - 0x78746E6B, - 0x817B7774, - 0x88878784, - 0x7C7E8081, - 0x7476777A, - 0x6A6E7275, - 0x67686969, - 0x90908376, - 0x72717784, - 0x7A7F8181, - 0x817D7878, - 0x92968889, - 0x7990877D, - 0x7A7C7973, - 0x7A747073, - 0x88888786, - 0x7D7F8387, - 0x6D6E7375, - 0x87817870, - 0x7C828789, - 0x7B797677, - 0x94847A78, - 0x93959A9D, - 0xB2A9998E, - 0x9BA0AAB1, - 0x8C898887, - 0x92918F8D, - 0x7C818689, - 0x938D837D, - 0xA5B0A594, - 0x837F808E, - 0x83838485, - 0x87838182, - 0x908B8580, - 0x93939392, - 0x989D9992, - 0x818D9797, - 0x6A747E85, - 0x60616265, - 0x575C5F62, - 0x52525354, - 0x55555453, - 0x58565554, - 0x6868615A, - 0x786E6464, - 0x85918F84, - 0x787E7E7C, - 0x7F7C7A78, - 0x83828180, - 0x7A7E807F, - 0x998D7F78, - 0x817B818C, - 0x87878787, - 0x737E8381, - 0x70767771, - 0x877D7775, - 0x727E8B8E, - 0x6E646266, - 0x746E6C70, - 0x706D6B6E, - 0x87776C6E, - 0x919B8E8A, - 0x867D8386, - 0x777B7B7A, - 0x74727073, - 0x83827F7B, - 0x7F818383, - 0x797B7D7E, - 0x74747577, - 0x75767676, - 0x74747474, - 0x7B7A7776, - 0x76777A7B, - 0x7A7A7978, - 0x7A7A7A7A, - 0x89878481, - 0x85858687, - 0x8A888684, - 0x8486888A, - 0x82828385, - 0x83848483, - 0x777B8083, - 0x76757474, - 0x75747575, - 0x7A7A7876, - 0x74757676, - 0x75757474, - 0x75747474, - 0x76767675, - 0x77777778, - 0x76767676, - 0x76777878, - 0x74747475, - 0x7A797776, - 0x7A7A7A7A, - 0x74787572, - 0x706C6A6E, - 0x867E746E, - 0x777C8387, - 0x76767677, - 0x7C7B7A77, - 0x81807F7F, - 0x81818181, - 0x7F7E8081, - 0x81828281, - 0x81838484, - 0x6F73777C, - 0x736E6B69, - 0x85827D78, - 0x82828383, - 0x7D7E7F81, - 0x7A7D8184, - 0x82807B7A, - 0x93928F8D, - 0x86898D92, - 0x7F838789, - 0x7777797B, - 0x686D7274, - 0x64636365, - 0x7C756D68, - 0x787A7E7F, - 0x6A707578, - 0x5C5C6064, - 0x7D7A7674, - 0x7C7D7F7F, - 0x71797D7F, - 0x5F5F6168, - 0x6A686563, - 0x6C6C6C6C, - 0x68676868, - 0x8A82766D, - 0x6E73818D, - 0x7C7C7A73, - 0x6C686C73, - 0x747A7C76, - 0x6F6F6F6F, - 0x60646A6E, - 0x60616467, - 0x746F6862, - 0x7D7D7B7A, - 0x78787A7B, - 0x8B827D7D, - 0x92919291, - 0x7E828687, - 0x8285837F, - 0x757D878D, - 0x78757271, - 0x7A7A7978, - 0x7174767A, - 0x79716E6E, - 0x84868681, - 0x797F8890, - 0x84827E7A, - 0x747F827F, - 0x78756F6D, - 0x6E6E7073, - 0x6A6C6E6E, - 0x6E757068, - 0x69615B62, - 0x7C7A7571, - 0x7374787B, - 0x6971787A, - 0x5C5C5C62, - 0x7A797064, - 0x878C897F, - 0x7D7F8181, - 0x7E7E7D7D, - 0x86848281, - 0x777B8185, - 0x7B797775, - 0x8683807D, - 0x898C8B89, - 0x7F7F8184, - 0x89878686, - 0x767D868A, - 0x877F7A79, - 0x78828D8E, - 0x83828181, - 0x8D898684, - 0x7A7D8793, - 0x74747679, - 0x726F6E6E, - 0x74767675, - 0x65676D73, - 0x65686868, - 0x7A6F6866, - 0x92918D84, - 0x8D898582, - 0x86888B8D, - 0x90929395, - 0x86888C8E, - 0x6E727C85, - 0x70737370, - 0x83817972, - 0x78787A80, - 0x7B7F8080, - 0x60646C74, - 0x78787169, - 0x87847E79, - 0x7F7D7B7A, - 0x81818181, - 0x7A7C8083, - 0x787A7B7B, - 0x68696F75, - 0x565D6568, - 0x80746256, - 0x5B657480, - 0x59565351, - 0x6563615C, - 0x5E606366, - 0x5A5B5D5E, - 0x65615D5C, - 0x706E6C69, - 0x75737170, - 0x7E7D7B79, - 0x74797F83, - 0x72727373, - 0x746E6A66, - 0x6B747C7A, - 0x746A6464, - 0x78757578, - 0x7B828381, - 0x6D6C6D73, - 0x726E7279, - 0x62676F74, - 0x7D756E68, - 0x80818281, - 0x7577797A, - 0x71717273, - 0x74737170, - 0x74757574, - 0x77737476, - 0x7B80817E, - 0x71717579, - 0x696E7374, - 0x68686869, - 0x716F6D6A, - 0x787B7A75, - 0x7A7A7976, - 0x7474777A, - 0x666C7375, - 0x595D605C, - 0x626F7162, - 0x595C5855, - 0x54515155, - 0x595C5B59, - 0x52515155, - 0x57565554, - 0x5C5B5A58, - 0x6A6B6B6A, - 0x60626568, - 0x5B575C63, - 0x7168625F, - 0x7F818181, - 0x7374767A, - 0x8184817D, - 0x70707279, - 0x69696D71, - 0x8882796F, - 0x827C7876, - 0x6E768185, - 0x71696268, - 0x70757370, - 0x6F6E6D6A, - 0x706F6E6F, - 0x706E6D6C, - 0x76757472, - 0x71737474, - 0x65686A6E, - 0x6D746F63, - 0x7A706562, - 0x808A8781, - 0x59585E6E, - 0x68686868, - 0x6E6C6A68, - 0x62627E76, - 0xB0377E7F, - 0xE8EBD6E6, - 0x201E19E8, - 0x3F661012, - 0x59484F5C, - 0x81639143, - 0xBB31151E, - 0xD2CAEBD6, - 0x6280A2CA, - 0x747D6177, - 0xE3EBE53A, - 0x1035E2DB, - 0x58605839, - 0x744E617C, - 0x17101C10, - 0xE5EBE2E3, - 0x61616EEB, - 0x60626566, - 0x5A5B5C5D, - 0xBE43496E, - 0xE7EBDED3, - 0xEBE5DBE4, - 0xE2EBE9D2, - 0x68E8E0DF, - 0x535B4C69, - 0x5C5B5B5B, - 0x5C5C5C5C, - 0xEB196A46, - 0xE0E0EBE2, - 0x4D301014, - 0x555F6659, - 0x8D765950, - 0x10421086, - 0xDFE4EBE5, - 0x8563EAE1, - 0x595C6265, - 0x615E5B58, - 0x5E5E6265, - 0x5E606160, - 0x595A5E62, - 0x4E53585A, - 0x423C5C4F, - 0xC3D82844, - 0xEBE5CBEB, - 0xEBDFE2DF, - 0xE9E7E0E3, - 0x3D52E5EB, - 0x4C4A4948, - 0x5251504E, - 0x56625754, - 0xE8E91F56, - 0x28EAE5D6, - 0x3D572110, - 0x626E5253, - 0x10103336, - 0xE2E9D821, - 0x6D39DCE9, - 0x44424344, - 0x6660564B, - 0x56595C5D, - 0x52525254, - 0x50505050, - 0x51515150, - 0xDA354533, - 0xCFEAEBDD, - 0x1C241FD9, - 0x7D381020, - 0x56565656, - 0x56565656, - 0xDB391912, - 0xEBE7EBE8, - 0x4C6891B0, - 0x44474644, - 0xEBE6E61A, - 0x192BD6DB, - 0x49614831, - 0x3D515B41, - 0x103C473A, - 0xEBBF1E2D, - 0xE8E7DCEB, - 0x555C5A6F, - 0x4A4A4949, - 0x5756514E, - 0x52525150, - 0x4C4E5051, - 0x25384446, - 0xE5EBD5EB, - 0x101528D2, - 0x62566E5E, - 0x11565371, - 0xEB101716, - 0xDFE8DAEA, - 0x39372B4C, - 0x5856523D, - 0xCA21473C, - 0xDBE7DCEB, - 0x4124102E, - 0x3E645B5B, - 0x13145431, - 0xEBC31029, - 0x52D6EBE4, - 0x645F5A56, - 0x65666868, - 0x62676562, - 0x3E434B57, - 0x594C4F62, - 0xA6254A7B, - 0xE5E7E7D2, - 0x351932EB, - 0x52681610, - 0x625C607A, - 0x58687246, - 0xC2181716, - 0xD6D2EBBB, - 0xA08FA1CB, - 0x8D818275, - 0x1E798F8D, - 0xE9DCE4E8, - 0x5A7E69E9, - 0x6358524F, - 0x686D706D, - 0x67628C6D, - 0x648E4A75, - 0x6B6D7A8A, - 0x74706E6D, - 0x8481786F, - 0x74757980, - 0x5C60666A, - 0x57595B5C, - 0xE8206074, - 0xEBDDE7EB, - 0x5C5C5C5C, - 0x5C5C5C5C, - 0x6E6D6C6C, - 0x7171706E, - 0x64726E6D, - 0x1B52727A, - 0xE6E4EBE2, - 0x182BC8EB, - 0x554C4245, - 0x6E5D4A4C, - 0x21324644, - 0xE3D37515, - 0x4CE5EBEB, - 0x55516056, - 0x5D5B5653, - 0x595A5B5C, - 0x49545D62, - 0x2B2E353E, - 0x877B7574, - 0x828A9290, - 0x81818181, - 0x84838281, - 0x7A7C7D7E, - 0x77777879, - 0x74747576, - 0x78777574, - 0x87888989, - 0x81808183, - 0x8C87817B, - 0x8A8B8C8D, - 0x84858787, - 0x89878684, - 0x878B8D8D, - 0x7C7E8184, - 0x6B717A82, - 0x756E6868, - 0x817C7774, - 0x82838584, - 0x82818284, - 0x8D8D8A87, - 0x6F757D83, - 0x6E6E6E6D, - 0x7F7C7B7A, - 0x88878481, - 0x8E8B8784, - 0x898C8E90, - 0x85868788, - 0x918E8A87, - 0x767A848C, - 0x87847F79, - 0x8F87878A, - 0x969B9E99, - 0x6D737A7F, - 0x68676768, - 0x7978746E, - 0x74797B7A, - 0x6C6B6E6F, - 0x7A79746F, - 0x686E767C, - 0x68686666, - 0x6D6C6660, - 0x7A746D6B, - 0x6E7B7F79, - 0x817B7068, - 0x7A7B8185, - 0x7A7B7C7B, - 0x817D7A7A, - 0x7A7F8485, - 0x7C787575, - 0x757A7E7F, - 0x7D7D7F80, - 0x797A7D7E, - 0x6A6C6F72, - 0x7B776F6B, - 0x7E7A7776, - 0x87878783, - 0x7B7F8386, - 0x7A7A7979, - 0x6F747576, - 0x6766676A, - 0x8F908A7F, - 0x71697387, - 0x85838180, - 0x81828485, - 0x88898B8D, - 0x81848788, - 0x747A7A77, - 0x79716B6C, - 0x99999894, - 0x8F969A9A, - 0x746C6D7D, - 0x8F877A74, - 0x7C848889, - 0x7B767374, - 0x93908880, - 0x81889193, - 0x91878382, - 0xA5A6A59C, - 0x96959493, - 0x90929395, - 0x7E818890, - 0x8F87817E, - 0x989F9F9B, - 0x8886868D, - 0x87888D91, - 0x85878887, - 0x83848687, - 0x908D8985, - 0x8785878A, - 0x7E858B8B, - 0x63697176, - 0x5C5D5F61, - 0x595C5D5E, - 0x53545657, - 0x52535353, - 0x52525252, - 0x50515353, - 0x6B625750, - 0x817F756D, - 0x7D7A797C, - 0x817B7A7F, - 0x85818184, - 0x807D7C7E, - 0x89848181, - 0x86878681, - 0x81888B88, - 0x73747A80, - 0x8387877C, - 0x8E817A7D, - 0x8C8F9598, - 0x827E7D88, - 0x7174747A, - 0x6B615C62, - 0x7E6F686E, - 0x8B8D8A83, - 0x767F8687, - 0x7B777271, - 0x66646A75, - 0x9A8E7A74, - 0x8F918F94, - 0x75797E83, - 0x6F727474, - 0x76767474, - 0x7B7A7776, - 0x74787B7D, - 0x7A767372, - 0x7A797776, - 0x7A7A7B7B, - 0x88878481, - 0x86868687, - 0x88878584, - 0x84858788, - 0x84838383, - 0x85858584, - 0x747A8083, - 0x71707071, - 0x716F7174, - 0x77797975, - 0x73737577, - 0x79797875, - 0x72747678, - 0x78767472, - 0x77777778, - 0x7A797878, - 0x7E7E7A78, - 0x78787A7C, - 0x7A787675, - 0x7A7A7A7A, - 0x787A7674, - 0x6B6B6E73, - 0x867C7471, - 0x747C878B, - 0x7173777A, - 0x7C797471, - 0x7F7C7A79, - 0x81818181, - 0x7A7C7F81, - 0x817F7C7A, - 0x81808080, - 0x71767D81, - 0x736E6967, - 0x81807C78, - 0x81828383, - 0x82828181, - 0x747B8184, - 0x80797270, - 0x93908B88, - 0x888C9093, - 0x8286898C, - 0x72757A7F, - 0x686B6E71, - 0x60616264, - 0x706B6865, - 0x7C7A7874, - 0x5F6E797F, - 0x57535054, - 0x807B7169, - 0x7C7B7C7F, - 0x737A7B81, - 0x5F5D585F, - 0x68676360, - 0x6C6B6969, - 0x81756F70, - 0x83818386, - 0x6A6E7A84, - 0x7D7B776F, - 0x6C686D72, - 0x69707573, - 0x68746D61, - 0x64564B54, - 0x60616262, - 0x75706862, - 0x7C7A7878, - 0x74787B7E, - 0x87838589, - 0x878D908D, - 0x81818283, - 0x87868482, - 0x72798185, - 0x7D78726F, - 0x8787847D, - 0x77808787, - 0x79727072, - 0x80838581, - 0x777D8386, - 0x87807774, - 0x7C818587, - 0x7F7B7979, - 0x68686F79, - 0x706E6D6B, - 0x8A937E64, - 0x8E776671, - 0x80838586, - 0x7475787C, - 0x6970767A, - 0x5C5D5F63, - 0x747A7263, - 0x787F7D74, - 0x7F81807A, - 0x81848480, - 0x87848281, - 0x7E818587, - 0x80848381, - 0x85797075, - 0x8C8D8C8C, - 0x87888A8B, - 0x87878787, - 0x87878787, - 0x8D808085, - 0x74899D9E, - 0x7E776C62, - 0x85828181, - 0x818A8C8A, - 0x6E6E7076, - 0x73716E6C, - 0x7A787574, - 0x68696F77, - 0x62626468, - 0x746C6662, - 0x9591887F, - 0x8E8C867F, - 0x8A88888B, - 0x93939494, - 0x85878C8F, - 0x74757E89, - 0x7C7A7978, - 0x8A827B7A, - 0x73757E89, - 0x7D7F8080, - 0x676B7178, - 0x6E747471, - 0x7676736D, - 0x827C7875, - 0x898A8A87, -}; - -static gctUINT32 ppuMem5[] = -{ - 0x7E83898D, - 0x807E7B7B, - 0x84817F7F, - 0x5C687A83, - 0x7E766C66, - 0x616A777F, - 0x5C5B5856, - 0x625F5C5C, - 0x52515A62, - 0x52585C58, - 0x60585554, - 0x70716F69, - 0x71696A6E, - 0x787F827D, - 0x72747D87, - 0x6D6D6E71, - 0x877F736A, - 0x6A737F87, - 0x6B686868, - 0x7A78746E, - 0x767A7B7C, - 0x67696E72, - 0x716E6E6E, - 0x686E7274, - 0x7A75706C, - 0x7D7D7D7C, - 0x7477797A, - 0x6E6E6E70, - 0x72716F6E, - 0x74747473, - 0x75747474, - 0x75757575, - 0x72747475, - 0x70707071, - 0x6E6A6868, - 0x76767572, - 0x78757678, - 0x7D7F7F7C, - 0x81807D7A, + 0x767A7B7C, + 0x67696E72, + 0x716E6E6E, + 0x686E7274, + 0x7A75706C, + 0x7D7D7D7C, + 0x7477797A, + 0x6E6E6E70, + 0x72716F6E, + 0x74747473, + 0x75747474, + 0x75757575, + 0x72747475, + 0x70707071, + 0x6E6A6868, + 0x76767572, + 0x78757678, + 0x7D7F7F7C, + 0x81807D7A, 0x686E787F, 0x625E6062, 0x67696B68, @@ -5306,3284 +2075,198 @@ static gctUINT32 ppuMem5[] = 0x68696A6B, 0x62636466, 0x63636262, - 0x64646463, - 0x73747373, - 0x6E6E7072, - 0x6C6B6C6D, - 0x6E6E6F6E, - 0x78716A65, - 0x8B88847F, - 0x6C727C85, - 0x66686A6A, - 0x5D5E6164, - 0x55585C5E, - 0x67625C59, - 0x65666868, - 0x57555658, - 0x54585C5C, - 0x56504E50, - 0x645F5C59, - 0x6C747470, - 0x6E665E61, - 0x5C565C64, - 0x706E6A65, - 0x6D6F7476, - 0x8881766E, - 0x8D8D8F90, - 0x8184888B, - 0x8B867E77, - 0x7D81868A, - 0x7F7B7A7A, - 0x7F818281, - 0x7A7F7D81, - 0x76756D6D, - 0x82817C79, - 0x74767B80, -}; - -static gctUINT32 ppuMem6[] = -{ - 0x7573706F, - 0x6C707476, - 0x6E6E6A64, - 0x706B6869, - 0x67666768, - 0x61646868, - 0x6868696A, - 0x65666868, - 0x5D5E5F5F, - 0x5F5F5E5D, - 0x5C65635C, - 0xBF245040, - 0xD5DEE0E1, - 0x415C7BBA, - 0x54575652, - 0x4E565A56, - 0x5A47464E, - 0xE3246557, - 0xE4E6E9EA, - 0x715A58E7, - 0xEBE71F6A, - 0xEBE9DFDE, - 0x625D5954, - 0x5C535662, - 0x5D626869, - 0x6264625E, - 0xEBDE254E, - 0xD6E8D9E3, - 0x56595C5F, - 0x5D5C5856, - 0xAB355D5A, - 0xDED5D3C6, - 0x46BBEBDA, - 0xD4EBE019, - 0x5AE5E8EA, - 0x44574752, - 0x5155514F, - 0x3150433D, - 0xB7191D10, - 0xE8E1EBEA, - 0x74655437, - 0x5F575C5D, - 0x694F6365, - 0x43627A7C, - 0x504D5054, - 0x61626059, - 0x4C505456, - 0x56514B49, - 0x54555656, - 0x51515253, - 0x50515151, - 0x4A4C4D4F, - 0x435C5665, - 0xC0B72E45, - 0xEBE4E7EB, - 0x1F46EBD9, - 0xE8EBE2EB, - 0x4A57E5EB, - 0x51515050, - 0x53525252, - 0xD0104F5F, - 0xEBEBEBEB, - 0x25565FBB, - 0x524A6E59, - 0x4A4C4B49, - 0x625E564D, - 0xDD102568, - 0xEBE5E1D2, - 0x45445EEB, - 0x464C454B, - 0x52535352, - 0x54525050, - 0x504F4D4D, - 0x50505050, - 0xC526445B, - 0xEBD6D6D6, - 0x5B594FB7, - 0x3D364A44, - 0x51514A44, - 0x4E4B4A4D, - 0xE7206347, - 0xEAE8D9E5, - 0x3E3D41E8, - 0x25421036, - 0xEBE9EA1D, - 0x6C4CCAE0, - 0x5F4E5344, - 0x505B4D5C, - 0x6E705548, - 0x38434762, - 0x45414848, - 0x4A424A51, - 0x44464747, - 0x4A484444, - 0x52505458, - 0x50545756, - 0xD9EBE910, - 0x47E6E8DC, - 0x3A273956, - 0x4D687863, - 0x4A46474B, - 0x34495652, - 0xEBE7E317, - 0x43E5EBEB, - 0x68605944, - 0xD0125D82, - 0xEBE0E2E9, - 0x3C5C5B4C, - 0x3833444C, - 0x3842504D, - 0xEBE81024, - 0x61C9DAE5, - 0x5758595B, - 0x5E5C5A58, - 0x122A104B, - 0x45251010, - 0x4D455D6A, - 0xB5305453, - 0xE4EBE1EB, - 0x484565C2, - 0x56514E4D, - 0x565A5C5B, - 0x62504E63, - 0xDF45825C, - 0xDEDCE8EB, - 0x807179DD, - 0x5E546893, - 0xEBE6D121, - 0xEBE8E9EB, - 0x988F6DDD, - 0x6F767F84, - 0x77746E6D, - 0x55576081, - 0x626D5646, - 0x805C6172, - 0x2C5D667B, - 0x29102012, - 0x64676E2E, - 0x62595E5A, - 0x10444550, - 0xEBD2E0E2, - 0xD6E2D0EB, - 0x57575757, - 0x57575757, - 0x5A746F61, - 0x7E70554F, - 0x5C56585D, - 0x4977615D, - 0x68594F5B, - 0x6374726A, - 0x615E665C, - 0x4D594B51, - 0x5554672B, - 0xEBDA317A, - 0x4EDFEBEB, - 0x4459553E, - 0x44484B4D, - 0x3A3B3D40, - 0x3F45433E, - 0x38323036, - 0x7777726D, - 0x827B7574, - 0x7A7D8081, - 0x75767779, - 0x817F7D7B, - 0x87878583, - 0x85868787, - 0x82828384, - 0x7D818282, - 0x73737478, - 0x88827B75, - 0x88898A8A, - 0x81848788, - 0x7A7B7C7E, - 0x7C7C7C7B, - 0x7274777A, - 0x6462676E, - 0x79746F6A, - 0x79797A7A, - 0x817F7C7A, - 0x7F7D7D7E, - 0x88888783, - 0x93918F8E, - 0x8C8F9394, - 0x817E7B7A, - 0x87878684, - 0x8D8C8887, - 0x888A8D8E, - 0x8B8C8C8C, - 0x8787888A, - 0x7F7D8184, - 0x92908C85, - 0x8D8D8D8E, - 0x8D8D8E8D, - 0x7A7D848A, - 0x80807D7A, - 0x6E777B7B, - 0x6468696A, - 0x62626466, - 0x61626362, - 0x77726C68, - 0x6E72787A, - 0x817F766E, - 0x817D7A7D, - 0x74757980, - 0x6F68666E, - 0x66676563, - 0x6C686564, - 0x847E7A77, - 0x767D8487, - 0x686B6E71, - 0x6E6C6A68, - 0x706C6969, - 0x797A7975, - 0x797B7A77, - 0x7A767374, - 0x716F6E6F, - 0x75767674, - 0x71706F6F, - 0x78767473, - 0x747B7F81, - 0x6566686E, - 0x82878171, - 0x766A6D7A, - 0x8283817F, - 0x7374797E, - 0x76727070, - 0x7E7E7D7A, - 0x6B70777C, - 0x73706D6A, - 0xA2A19D99, - 0x969DA3A4, - 0x7F7A7A86, - 0x98948780, - 0x86878D92, - 0x87898A88, - 0x878A8986, - 0x7F848787, - 0x938D8987, - 0x999B9B98, - 0x82889198, - 0xA2998D84, - 0x898D939A, - 0x83808085, - 0x827F7E7D, - 0x918E8A86, - 0x81838486, - 0x7E7F8081, - 0x82817E7C, - 0x7A7C8081, - 0x74747477, - 0x656B7274, - 0x57595D60, - 0x57575757, - 0x54555656, - 0x52525354, - 0x4E505050, - 0x4A4A4B4D, - 0x41454848, - 0x4E48413F, - 0x64625B54, - 0x8D806F67, - 0x7C798087, - 0x93928F87, - 0x83818081, - 0xA2978C87, - 0x93999FA3, - 0x7C82898E, - 0x7876797A, - 0x92938F82, - 0x9C938D8C, - 0x969BA2A3, - 0x97938B8E, - 0x807D7B87, - 0x6F6D6F75, - 0x7E726B6E, - 0x7C858682, - 0x6564676F, - 0x736F6761, - 0x6062686F, - 0x8A7D6860, - 0x797B7B83, - 0x76797B7E, - 0x71727374, - 0x73737374, - 0x87817A74, - 0x87878583, - 0x86858586, - 0x86858584, - 0x87878787, - 0x85868584, - 0x80808182, - 0x80818181, - 0x81818180, - 0x83828282, - 0x85858484, - 0x7E7D7E7E, - 0x8382817F, - 0x767C7E7F, - 0x74716F71, - 0x7A777574, - 0x7074797A, - 0x6E6E6D6B, - 0x6B6D6E6E, - 0x74737271, - 0x77777675, - 0x7F7F7C7A, - 0x7576797C, - 0x73747475, - 0x76757474, - 0x857E7976, - 0x747A8387, - 0x615D626A, - 0x7A7B776D, - 0x68696C6E, - 0x726F6B68, - 0x77747372, - 0x7C7B7A79, - 0x73747678, - 0x78767473, - 0x807E7D7C, - 0x84848381, - 0x84868787, - 0x7C7D8081, - 0x81818181, - 0x7E7F8081, - 0x807B7A7B, - 0x8D8D8C87, - 0x8A8C8D8E, - 0x8B8B8989, - 0x7F82878A, - 0x7274797B, - 0x5D646B6F, - 0x5D5C5A5A, - 0x65625F5E, - 0x74716E68, - 0x7C7C756D, - 0x6E6C6E74, - 0x7B7A7774, - 0x74757679, - 0x7B77737A, - 0x73716E72, - 0x81807B78, - 0x7E7F8081, - 0x8B847E7B, - 0x83878C8E, - 0x60616E7B, - 0x797A756A, - 0x62636E79, - 0x686B6C67, - 0x76766C60, - 0x6865656D, - 0x70686565, - 0x7C7F807A, - 0x7D7A7A7A, - 0x7B7D7F7F, - 0x7C767578, - 0x81878985, - 0x76757D85, - 0x8E8D8980, - 0x85878D92, - 0x85878786, - 0x5F6A767D, - 0x6E685F5B, - 0x7C746E6D, - 0x737A8283, - 0x5F636B72, - 0x65656360, - 0x746B6767, - 0x8386857F, - 0x81868481, - 0x635F6371, - 0x70686769, - 0x8083847C, - 0x7C7F8182, - 0x7575777A, - 0x72727170, - 0x6B6D6F71, - 0x767B766A, - 0x74787673, - 0x706F6E6E, - 0x807E7A74, - 0x85838383, - 0x8D8D8B87, - 0x81878D93, - 0x7A747279, - 0x82828181, - 0x7C7D8081, - 0x7C7C8185, - 0x7D7F817F, - 0x686F8292, - 0x7F7E786E, - 0x87888581, - 0x72757A82, - 0x74787773, - 0x70767975, - 0x7E7B7976, - 0x87858180, - 0x6B687380, - 0x6B6E7271, - 0x68676768, - 0x7E7A746D, - 0x87888784, - 0x7D7D7F83, - 0x7A7A7B7B, - 0x83817F7C, - 0x807B7D83, - 0x7C7E8183, - 0x8B817B7A, - 0x6371838D, - 0x6E6D6C6C, - 0x7271706E, - 0x6E737372, - 0x62636669, - 0x756C625D, - 0x8D89847D, - 0x7B808487, - 0x7C7A7979, - 0x75797A7A, - 0x93887B74, - 0x81858D92, - 0x8482817F, - 0x7A75787C, - 0x81878984, - 0x6F797D7D, - 0x63605E63, - 0x817C746E, - 0x8A878583, - 0x8785807B, - 0x86858687, - 0x7271757B, - 0x706F7072, - 0x75726F6D, - 0x7A7A7978, - 0x767A7C7D, - 0x62656B71, - 0x69666463, - 0x807B756F, - 0x847A7D84, - 0x7E8A9491, - 0x70717475, - 0x77767472, - 0x6D707477, - 0x68696A6B, - 0x63686C6E, - 0x56575A5E, - 0x59585858, - 0x5B5B5A5A, - 0x72706E6D, - 0x6E6F7172, - 0x6C6C6E6F, - 0x696B6D6D, - 0x716B645F, - 0x8A847C76, - 0x666F7F8B, - 0x5F626263, - 0x605E5F61, - 0x5C5E6161, - 0x645E5B59, - 0x67696B69, - 0x5251575D, - 0x55595B58, - 0x55504F50, - 0x625D5A58, - 0x676F7270, - 0x71675D5D, - 0x5B565C66, - 0x69696863, - 0x686A6E70, - 0x8B82756C, - 0xA09E9B9A, - 0x8A929BA0, - 0x81817D7A, - 0x7C7C7D80, - 0x7E7F7C7A, - 0x82807C7C, - 0x828C8A8B, - 0x716E676D, - 0x85847D76, - 0x74757A80, - 0x76736F6E, - 0x6A6E7477, - 0x6E706C67, - 0x6B676468, - 0x65646362, - 0x68676665, - 0x67696A69, - 0x64626263, - 0x62626262, - 0x63636262, - 0x644F5468, - 0x2A10827B, - 0x2D211F20, - 0x5350443E, - 0x5A58544F, - 0x50585E5C, - 0x6B615447, - 0xEA104450, - 0xEBE9EBE1, - 0x575F79EB, - 0xE5D9106C, - 0xE2EBE5E4, - 0x5063746E, - 0x66534D4F, - 0x5B626666, - 0x56585756, - 0xEBEB1A69, - 0xE3EBEBD8, - 0x54585D61, - 0x59565453, - 0x30165A5A, - 0x10101B21, - 0x492D1F1C, - 0xE2E0DB26, - 0x59E6E9EA, - 0x43584850, - 0x4E51504E, - 0x1C443F3B, - 0xEBD9E9E8, - 0x1531C7E7, - 0x6758683B, - 0x4C5E694B, - 0x62595C64, - 0x626C4C45, - 0x56494A50, - 0x46576865, - 0x4F525659, - 0x5755504E, - 0x52535354, - 0x52525252, - 0x50505151, - 0x4E4E4E4F, - 0x5C5C3F39, - 0x10301252, - 0x12101E10, - 0x15392A30, - 0xE8EBE2EB, - 0x4A57E5EB, - 0x53535353, - 0x53535353, - 0xE010544E, - 0xEAE3EBEA, - 0x5A533CEB, - 0x3E464447, - 0x4E4F4B47, - 0x4D4C4B4C, - 0xD6184E4F, - 0xE8E5E6DC, - 0x47304AE4, - 0x4D524C4A, - 0x50515252, - 0x51505050, - 0x4F4E4D4D, - 0x50505050, - 0x35114B4F, - 0x1019251F, - 0x637F4C48, - 0x434E513C, - 0x544F463F, - 0x4D4E5053, - 0xDD256E3D, - 0xDEEBEBEB, - 0x584F47EA, - 0xE6D02543, - 0xE2EBEBB9, - 0x323C3126, - 0x4C284458, - 0x30333C5F, - 0x4949243C, - 0x3A573E4A, - 0x464F6056, - 0x58373D4F, - 0x49484645, - 0x5955504B, - 0x51515559, - 0x4C505554, - 0xDEE0E842, - 0x51E8E6E7, - 0x5A514842, - 0x4B515A5D, - 0x3C34494F, - 0x623E4453, - 0xD3D9EB1C, - 0x3EDFD1DC, - 0x50555F38, - 0xEB2F6071, - 0xE9E3DAE6, - 0x31433F2D, - 0x59585647, - 0x3A3D4253, - 0xEAE71666, - 0x87E7E5E8, - 0x5A5F666A, - 0x615E5A58, - 0xEBD1335E, - 0xB2DCE6EB, - 0x515E7380, - 0x491C4B4A, - 0x2A2C1310, - 0x3654442C, - 0x50494648, - 0x4F565B59, - 0x7E989D95, - 0xE8103F47, - 0xEBE9EBE2, - 0x78717AE8, - 0x615A6E94, - 0xE4E3D624, - 0x2A29ABEB, - 0x84784C2C, - 0x757B8186, - 0x7A787474, - 0x5A535B70, - 0x896F5C5B, - 0x775E6978, - 0x15576876, - 0xE1E2EBEB, - 0x4F6BA3BB, - 0x695C6260, - 0x1250565E, - 0xEBE8E8EB, - 0x102A4DDE, - 0x5B5B5B5B, - 0x5B5B5B5B, - 0x66595D4F, - 0x4E56695B, - 0x4E48494B, - 0x3D5C4D4A, - 0x666C583E, - 0x61767564, - 0x2F4C5B68, - 0x5A553528, - 0x30445953, - 0xDFEB183F, - 0x59D3E3DE, - 0x3E3D4147, - 0x3E424547, - 0x3334373A, - 0x3B3E3833, - 0x3E383436, - 0x6E6D6761, - 0x8078706E, - 0x7A7E8182, - 0x73747477, - 0x817F7C7A, - 0x87878684, - 0x86878787, - 0x81818284, - 0x7D818181, - 0x75747679, - 0x87827C77, - 0x83848687, - 0x7D808284, - 0x7475777A, - 0x77777675, - 0x70727476, - 0x68626268, - 0x7D79746E, - 0x83828180, - 0x86868584, - 0x86838383, - 0x8D8D8C89, - 0x8B89898A, - 0x888A8C8C, - 0x82807E7D, - 0x87878684, - 0x8D8B8886, - 0x8A8B8D8D, - 0x8C8D8D8C, - 0x8787898B, - 0x827F8081, - 0x9493918A, - 0x86878C92, - 0x81868988, - 0x74767D83, - 0x82817E79, - 0x7B81817E, - 0x686E7477, - 0x63636567, - 0x64656665, - 0x7A746E6A, - 0x6E747A7D, - 0x82817A73, - 0x7D7A7A7D, - 0x7473767D, - 0x6E686971, - 0x61626362, - 0x68645F5E, - 0x8D867E7A, - 0x7C858D91, - 0x686E7477, - 0x6E6B6867, - 0x726F6E6E, - 0x77787875, - 0x75757677, - 0x75767776, - 0x6C696869, - 0x7374736F, - 0x6E6C6C6C, - 0x7B797471, - 0x7075797A, - 0x6565676B, - 0x747C7A6C, - 0x7367656D, - 0x81807D7B, - 0x656D777F, - 0x716C6868, - 0x7E7E7B77, - 0x6F72777C, - 0x77767470, - 0x99999590, - 0x8F969B9B, - 0x7F79767F, - 0x96958A81, - 0x8987878B, - 0x81878D8D, - 0x7E7F7F7D, - 0x93928B82, - 0xA8A5A2A1, - 0xA6A8ABAB, - 0x80858D94, - 0xA2998D82, - 0x85898F95, - 0x7C7A7A81, - 0x88828181, - 0x93949490, - 0x7A7B7A7A, - 0x71727478, - 0x807C7976, - 0x7A7B7F81, - 0x6C6F7478, - 0x6063686A, - 0x5556595C, - 0x56565656, - 0x51535454, - 0x4D4E4F50, - 0x4B4D4E4E, - 0x4848494A, - 0x44474847, - 0x504A4442, - 0x5E5B5857, - 0x78736B63, - 0x83807E7D, - 0x86898A87, - 0x8C8E8B88, - 0x968B8185, - 0x898C949D, - 0x787F878A, - 0x7A777878, - 0x90938E83, - 0xA098908A, - 0x949BA3A5, - 0x999A9396, - 0x71717385, - 0x72707175, - 0x7E746E70, - 0x767E807F, - 0x605D5F69, - 0x746F655C, - 0x62666C71, - 0x93897166, - 0x7C7C7C87, - 0x77797A7B, - 0x72727374, - 0x72737475, - 0x85807874, - 0x8A888683, - 0x87878889, - 0x8C8C8C8C, - 0x8D8D8D8C, - 0x898A8A89, - 0x84848486, - 0x82828384, - 0x84838282, - 0x85858686, - 0x82838384, - 0x807F7D7D, - 0x85848381, - 0x767E8385, - 0x74706E6F, - 0x7C797574, - 0x6D72797C, - 0x716E6C69, - 0x696C6E71, - 0x7A787574, - 0x7C7C7C7B, - 0x7D7D7B79, - 0x7374767A, - 0x70717273, - 0x7271706F, - 0x78777676, - 0x5C656F76, - 0x62616367, - 0x74716C66, - 0x64636566, - 0x716E6A66, - 0x74727070, - 0x7B7A7876, - 0x70727476, - 0x76747270, - 0x7B7A7A79, - 0x81807E7C, - 0x81818181, - 0x7D7E8081, - 0x7F807F7F, - 0x7A7B7D7F, - 0x817A7877, - 0x8D8E8E89, - 0x898A8A8A, - 0x87888889, - 0x7B7F8487, - 0x70737578, - 0x5C62696E, - 0x5E5C5958, - 0x6D686664, - 0x7C7A7671, - 0x7C7F7B76, - 0x74717175, - 0x76777675, - 0x6F6F7174, - 0x7E746E76, - 0x7C7B777A, - 0x86878583, - 0x7A7A7D81, - 0x8A857E7A, - 0x868B8E8E, - 0x6365727E, - 0x7778746C, - 0x5F616B75, - 0x696C6C65, - 0x71736E6A, - 0x78736E6E, - 0x7E777474, - 0x82878986, - 0x7E7C7B7B, - 0x797B7F80, - 0x7A737274, - 0x81868884, - 0x6D6E7781, - 0x89878175, - 0x8D908E8C, - 0x82828489, - 0x676F797E, - 0x6A656060, - 0x7A706A68, - 0x727A8181, - 0x6666686B, - 0x68696B69, - 0x74686261, - 0x85878781, - 0x8C8F8C88, - 0x69676D7D, - 0x716C6C6E, - 0x7A7D7E79, - 0x73737474, - 0x76757474, - 0x7B7A7776, - 0x78797A7B, - 0x777A7B78, - 0x6F767A77, - 0x6C6A6A6B, - 0x7674706E, - 0x7E7E7A77, - 0x86827E7D, - 0x7B7E8287, - 0x68686D75, - 0x7A7A7A79, - 0x6E717478, - 0x7A77797A, - 0x8182817E, - 0x68728391, - 0x807A7168, - 0x81858787, - 0x6F71757A, - 0x838B8476, - 0x7276787A, - 0x7D7A7674, - 0x89878380, - 0x736F7884, - 0x6E737979, - 0x72696462, - 0x9F988C7E, - 0x84878787, - 0x7B7C7E81, - 0x7475787A, - 0x76757473, - 0x817B7B80, - 0x797C8185, - 0x7A777778, - 0x67717B7E, - 0x6C6B6B6C, - 0x71706E6D, - 0x6A6E6F71, - 0x63626266, - 0x6E696461, - 0x84807973, - 0x7A7E8285, - 0x7A7A7979, - 0x7A80817E, - 0x90857A76, - 0x7A81898F, - 0x83817D7A, - 0x84818182, - 0x8A8B8A87, - 0x717D8384, - 0x6C656165, - 0x8B867E78, - 0x94928E8D, - 0x8680848B, - 0x7C879290, - 0x7D7D8085, - 0x7877787C, - 0x7473706E, - 0x7A797877, - 0x74777979, - 0x5E62686E, - 0x63605E5E, - 0x7B787169, - 0x7E777B83, - 0x818B918B, - 0x7072777B, - 0x78777472, - 0x6B6E7477, - 0x68696A6A, - 0x60666A6D, - 0x5052565A, - 0x53525151, - 0x56555554, - 0x706D6A68, - 0x70717271, - 0x6D6E6F71, - 0x686A6C6D, - 0x69686664, - 0x7A746E6A, - 0x646C7982, - 0x5C5E6061, - 0x64626060, - 0x63656666, - 0x625D5C5C, - 0x66696B68, - 0x50525C64, - 0x55575754, - 0x55505051, - 0x605C5857, - 0x676D6D6A, - 0x6E675F5F, - 0x5A545B64, - 0x68696863, - 0x69696C6D, - 0x857E746C, - 0x928F8F8F, - 0x848A9093, - 0x71757A7E, - 0x7F7A736F, - 0x8082807B, - 0x847F7A7A, - 0x86918E8E, - 0x6868636E, - 0x7F7B726A, - 0x7776777B, - 0x78746F6D, - 0x6C71777A, - 0x6E74736F, - 0x625F5E65, - 0x62656461, - 0x66615C5D, - 0x6D6E6862, - 0x63606065, - 0x68686867, - 0x69696968, - 0x585F5652, - 0x76466A54, - 0x565A6671, - 0x7372715F, - 0x645F5449, - 0x52585F63, - 0x64444043, - 0xEB115C68, - 0xE2DCEBE2, - 0x665766D8, - 0xEBEB1369, - 0xE5EBE9E8, - 0x50545543, - 0x5350585A, - 0x5E605D58, - 0x5C5D5D5C, - 0xE0E8106E, - 0xEBE2EBDD, - 0x53596064, - 0x53515050, - 0x4A3E604D, - 0x6C66624F, - 0x594D4F4B, - 0xE6EBEA1D, - 0x58E7EBEB, - 0x43594950, - 0x4E4F4F4E, - 0x1344443F, - 0xE6EBEAEB, - 0x6A68E8E3, - 0x2C105058, - 0x12182512, - 0x15101918, - 0x52581C1A, - 0x4D565550, - 0x6B594744, - 0x484A5157, - 0x4D4D4C4A, - 0x50505152, - 0x50504F4F, - 0x50505151, - 0x53525150, - 0x56565660, - 0x64694B5B, - 0x5F656E5D, - 0x374B484A, - 0xE8EBE2EB, - 0x4A57E5EB, - 0x54545454, - 0x53535353, - 0xEB2D6C44, - 0xEBE5EBE2, - 0x304547DA, - 0x48394743, -}; - -static gctUINT32 ppuMem7[] = -{ - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, + 0x64646463, + 0x73747373, + 0x6E6E7072, + 0x6C6B6C6D, + 0x6E6E6F6E, + 0x78716A65, + 0x8B88847F, + 0x6C727C85, + 0x66686A6A, + 0x5D5E6164, + 0x55585C5E, + 0x67625C59, + 0x65666868, + 0x57555658, + 0x54585C5C, + 0x56504E50, + 0x645F5C59, + 0x6C747470, + 0x6E665E61, + 0x5C565C64, + 0x706E6A65, + 0x6D6F7476, + 0x8881766E, + 0x8D8D8F90, + 0x8184888B, + 0x8B867E77, + 0x7D81868A, + 0x7F7B7A7A, + 0x7F818281, + 0x7A7F7D81, + 0x76756D6D, + 0x82817C79, + 0x74767B80 +}; + +static gctUINT32 ppuMem1_0xA0[] = { + 0x00010000 +}; + +static gctUINT32 ppuMem2_0xA0[] = { + 0x00010000 +}; + +static gctUINT32 ppuMem3_0xA0[] = { + 0x38011039, + 0x39200804, + 0xC0A90050, + 0x74000008, + 0x38021039, + 0x39202804, + 0xC0A90050, + 0x74000008, + 0x38031039, + 0x39204804, + 0xC0A90050, + 0x74000008, + 0xB8017005, + 0x002018FC, + 0x01C900C0, + 0x40390098, + 0xB8027005, + 0x002028FC, + 0x01C90140, + 0x40390098, + 0xB8037005, + 0x002038FC, + 0x01C901C0, + 0x40390098, + 0x02001001, + 0x15408804, + 0x40000010, + 0x76FFDFF8, + 0x04041036, + 0x00000804, + 0x4154007A, 0x00000000, + 0x0400100C, + 0x3FC04804, + 0x40010440, + 0x2000007A, + 0x38000835, + 0x39207804, + 0x41E80050, + 0x00390018, + 0x04041036, + 0x00001804, + 0x4154007A, 0x00000000, + 0x0400100C, + 0x3FC04804, + 0x40010440, + 0x2000007A, + 0x38000835, + 0x39207804, + 0x41E80050, + 0x00390028, + 0x04041036, + 0x00002804, + 0x4154007A, 0x00000000, + 0x0400100C, + 0x3FC04804, + 0x40010440, + 0x2000007A, + 0x38000835, + 0x39207804, + 0x41E80050, + 0x00390038 }; -#define PATCH_OFFSET_0 29 -#define PATCH_OFFSET_1 31 -#define PATCH_OFFSET_2 83 -/* Buffer[3] is not used. */ -#define PATCH_OFFSET_3 -#define PATCH_OFFSET_4 11 -#define PATCH_OFFSET_5 17 -#define PATCH_OFFSET_6 23 -#define PATCH_OFFSET_7 33 #endif -#if gcdRESET_USC +#if gcdRESET_USC1 + +#if gcdRESET_USC_C + +#include "gc_hal_kernel_hardware_func_usc.h" +#endif + +#if !gcdRESET_USC_C static gctUINT32 nnBuffer0[] = { - 0x8010010c, - 0x07383fc2, - 0xc1000000, - 0x00a01000, - 0x08e00008, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000800, - 0x40000000, - 0x00e700ff, - 0x00000040, - 0x00000000, - 0x03ffffff, - 0x00000000, - 0x03ffffff, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000 + 0x8010010c, 0x07383fc2, 0xc1000000, 0x00a01000, + 0x08e00008, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000800, 0x40000000, + 0x00e700ff, 0x00000040, 0x00000000, 0x03ffffff, + 0x00000000, 0x03ffffff, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000 }; static gctUINT32 nnBuffer1[] = { - 0x8040010c, - 0x07383fd5, - 0x01000000, - 0x00a00e00, - 0x08700008, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000800, - 0x00000000, - 0x00e701fe, - 0x00000070, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000 + 0x8040010c, 0x07383fd5, 0x01000000, 0x00a00e00, + 0x08700008, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000800, 0x00000000, + 0x00e701fe, 0x00000070, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000 }; static gctUINT32 nnBuffer2[] = { - 0x8080010c, - 0x07383fd5, - 0x01000000, - 0x00a01000, - 0x09000008, - 0x00000000, - 0x00000000, - 0x00000000 + 0x8080010c, 0x07383fd5, 0x01000000, 0x00a01000, + 0x09000008, 0x00000000, 0x00000000, 0x00000000 }; +static gctUINT32 nnBuffer3[] = { + 0x8010010e, 0x07383fc2, 0xc1000000, 0x00a01000, + 0x08e00008, 0x00000000, 0x00000000, 0x00000000, + 0x00143000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000800, 0x00000000, + 0x00e700ff, 0x00000040, 0x00000000, 0x03ffffff, + 0x00000000, 0x03ffffff, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000 +}; +#endif + #define NN_BUFFER_IDX 0 #define KERNEL_BUFFER_IDX 1 #define INPUT_BUFFER_IDX 2 #define RESULT_BUFFER_IDX 3 +#define SRAM_BUFFER_IDX_C 4 #define PATCH_KERNEL_OFFSET 5 #define PATCH_INPUT_OFFSET 6 #define PATCH_RESULT_OFFSET 7 +#endif +#if gcdRESET_USC2 static gctUINT32 instBuffer[] = { - 0x04021009, - 0x00200000, - 0x80000000, - 0x20000048, - 0x02021009, - 0x00200000, - 0x80000000, - 0x20154048, - 0x07801009, - 0x00200000, - 0x80000000, - 0x20390008, - 0x07801033, - 0x3fe02800, - 0x81540140, - 0x00390008, - 0x02021001, - 0x2aa02800, - 0x80000000, - 0x202a8048, - 0x07801033, - 0x3fe02800, - 0x81540140, - 0x00390008, - 0x02021001, - 0x2aa02800, - 0x80000000, - 0x202a8048, - 0x07801033, - 0x3fe02800, - 0x81540140, - 0x00390008, - 0x02021001, - 0x2aa02800, - 0x80000000, - 0x202a8048, - 0x07801033, - 0x3fe02800, - 0x81540140, - 0x00390008, - 0x02021001, - 0x2aa02800, - 0x80000000, - 0x202a8048, - 0x07801033, - 0x3fe02800, - 0x81540140, - 0x00390008, - 0x02021001, - 0x2aa02800, - 0x80000000, - 0x202a8048, - 0x07801033, - 0x3fe02800, - 0x81540140, - 0x00390008 + 0x04021009, 0x00200000, 0x80000000, 0x20000048, + 0x02021009, 0x00200000, 0x80000000, 0x20154048, + 0x07801009, 0x00200000, 0x80000000, 0x20390008, + 0x07801033, 0x3fe02800, 0x81540140, 0x00390008, + 0x02021001, 0x2aa02800, 0x80000000, 0x202a8048, + 0x07801033, 0x3fe02800, 0x81540140, 0x00390008, + 0x02021001, 0x2aa02800, 0x80000000, 0x202a8048, + 0x07801033, 0x3fe02800, 0x81540140, 0x00390008, + 0x02021001, 0x2aa02800, 0x80000000, 0x202a8048, + 0x07801033, 0x3fe02800, 0x81540140, 0x00390008, + 0x02021001, 0x2aa02800, 0x80000000, 0x202a8048, + 0x07801033, 0x3fe02800, 0x81540140, 0x00390008, + 0x02021001, 0x2aa02800, 0x80000000, 0x202a8048, + 0x07801033, 0x3fe02800, 0x81540140, 0x00390008 }; #define INST_BUFFER_IDX 0 #define OUTPUT_BUFFER_IDX 1 +#define SRAM_BUFFER_IDX 2 +#endif #endif #define _GC_OBJ_ZONE gcvZONE_HARDWARE @@ -8610,6 +2293,117 @@ static gctUINT32 instBuffer[] = { | gcmSETFIELDVALUE(0, STALL_STALL, DESTINATION, PIXEL_ENGINE); \ } while(0) +#if gcdFLOP_RESET +static gceSTATUS +_FuncRelease( + IN OUT gcsFUNCTION_EXECUTION_PTR Execution + ) +{ + gckHARDWARE hardware = gcvNULL; + gcsFUNCTION_COMMAND_PTR command = gcvNULL; + gcsFUNCTION_EXECUTION_DATA_PTR data = gcvNULL; + gctUINT8 i, j; + + if (!Execution || !Execution->funcCmd) + { + return gcvSTATUS_OK; + } + + hardware = (gckHARDWARE)Execution->hardware; + + for (i = 0; i < Execution->funcCmdCount; i++) + { + command = &Execution->funcCmd[i]; + + /* Free data buffers. */ + if (command->data) + { + for (j = 0; j < command->dataCount; j++) + { + data = &command->data[j]; + + if (data->bufVidMem) + { + if (data->address) + { + /* Synchroneous unlock. */ + gcmkVERIFY_OK(gckVIDMEM_NODE_Unlock( + hardware->kernel, + data->bufVidMem, + 0, + gcvNULL + )); + data->address = 0; + } + + if (data->logical) + { + gcmkVERIFY_OK(gckVIDMEM_NODE_UnlockCPU( + hardware->kernel, + data->bufVidMem, + 0, + gcvFALSE, + gcvFALSE + )); + data->logical = gcvNULL; + } + + gcmkVERIFY_OK(gckVIDMEM_NODE_Dereference( + hardware->kernel, + data->bufVidMem + )); + data->bufVidMem = gcvNULL; + } + } + + gcmkVERIFY_OK(gckOS_Free(hardware->os, (gctPOINTER)command->data)); + command->data = gcvNULL; + command->dataCount = 0; + } + + /* Free command. */ + if (command->funcVidMem) + { + if (command->address) + { + /* Synchroneous unlock. */ + gcmkVERIFY_OK(gckVIDMEM_NODE_Unlock( + hardware->kernel, + command->funcVidMem, + 0, + gcvNULL + )); + command->address = 0; + } + + if (command->logical) + { + gcmkVERIFY_OK(gckVIDMEM_NODE_UnlockCPU( + hardware->kernel, + command->funcVidMem, + 0, + gcvFALSE, + gcvFALSE + )); + command->logical = gcvNULL; + } + + gcmkVERIFY_OK(gckVIDMEM_NODE_Dereference( + hardware->kernel, + command->funcVidMem + )); + command->funcVidMem = gcvNULL; + } + } + + gcmkVERIFY_OK(gckOS_Free(hardware->os, (gctPOINTER)Execution->funcCmd)); + Execution->funcCmd = gcvNULL; + Execution->funcCmdCount = 0; + + return gcvSTATUS_OK; +} +#endif + static gceSTATUS _FuncExecute(IN gcsFUNCTION_EXECUTION_PTR Execution) { @@ -8638,27 +2432,36 @@ _FuncValidate_MMU(IN gcsFUNCTION_EXECUTION_PTR Execution) static gceSTATUS _FuncRelease_MMU(IN gcsFUNCTION_EXECUTION_PTR Execution) { + gctUINT8 i; gckHARDWARE hardware = (gckHARDWARE)Execution->hardware; - if (Execution->funcVidMem) + if (Execution->funcCmd) { - if (Execution->logical) + for (i = 0; i < Execution->funcCmdCount; i++) { - gcmkVERIFY_OK(gckVIDMEM_NODE_UnlockCPU( - hardware->kernel, - Execution->funcVidMem, - 0, - gcvFALSE, - gcvFALSE - )); - Execution->logical = gcvNULL; + if (Execution->funcCmd[i].funcVidMem) + { + if (Execution->funcCmd[i].logical) + { + gcmkVERIFY_OK(gckVIDMEM_NODE_UnlockCPU( + hardware->kernel, + Execution->funcCmd[i].funcVidMem, + 0, + gcvFALSE, + gcvFALSE + )); + Execution->funcCmd[0].logical = gcvNULL; + } + + gcmkVERIFY_OK(gckVIDMEM_NODE_Dereference( + hardware->kernel, + Execution->funcCmd[i].funcVidMem + )); + Execution->funcCmd[i].funcVidMem = gcvNULL; + } } - gcmkVERIFY_OK(gckVIDMEM_NODE_Dereference( - hardware->kernel, - Execution->funcVidMem - )); - Execution->funcVidMem = gcvNULL; + gcmkVERIFY_OK(gckOS_Free(hardware->os, (gctPOINTER)Execution->funcCmd)); } return gcvSTATUS_OK; @@ -9678,7 +3481,7 @@ _ProgramMMUStatesMCFE( if (Logical != gcvNULL) { - buffer = Logical; + buffer = (gctUINT32_PTR)Logical; if (Hardware->options.secureMode == gcvSECURE_IN_NORMAL) { @@ -9949,6 +3752,13 @@ _FuncInit_MMU(IN gcsFUNCTION_EXECUTION_PTR Execution) gcePOOL pool; gctPHYS_ADDR_T physical; gckHARDWARE hardware = (gckHARDWARE)Execution->hardware; + gckMMU mmu = hardware->kernel->mmu; + gctPOINTER pointer = gcvNULL; + + if (mmu->initMode == gcvMMU_INIT_FROM_REG) + { + return gcvSTATUS_OK; + } #if gcdENABLE_MMU_1KMODE mode = gcvMMU_MODE_1K; @@ -9956,7 +3766,10 @@ _FuncInit_MMU(IN gcsFUNCTION_EXECUTION_PTR Execution) mode = gcvMMU_MODE_4K; #endif - flags |= gcvALLOC_FLAG_4GB_ADDR; + if (!gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_MMU_PAGE_DESCRIPTOR)) + { + flags |= gcvALLOC_FLAG_4GB_ADDR; + } #if gcdENABLE_CACHEABLE_COMMAND_BUFFER flags |= gcvALLOC_FLAG_CACHEABLE; @@ -9967,32 +3780,42 @@ _FuncInit_MMU(IN gcsFUNCTION_EXECUTION_PTR Execution) #else pool = gcvPOOL_VIRTUAL; #endif + Execution->funcCmdCount = 1; + + /* Allocate the gcsFUNCTION_COMMAND buffer */ + gcmkONERROR(gckOS_Allocate(hardware->os, + gcmSIZEOF(gcsFUNCTION_COMMAND) * Execution->funcCmdCount, + (gctPOINTER *)&pointer)); + + gckOS_ZeroMemory((gctPOINTER)pointer, gcmSIZEOF(gcsFUNCTION_COMMAND) * Execution->funcCmdCount); - Execution->funcVidMemBytes = 1024; + Execution->funcCmd = (gcsFUNCTION_COMMAND_PTR)pointer; + + Execution->funcCmd[0].funcVidMemBytes = 1024; /* Allocate mmu command buffer within 32bit space */ gcmkONERROR(gckKERNEL_AllocateVideoMemory( hardware->kernel, 64, gcvVIDMEM_TYPE_COMMAND, flags, - &Execution->funcVidMemBytes, + &Execution->funcCmd[0].funcVidMemBytes, &pool, - &Execution->funcVidMem + &Execution->funcCmd[0].funcVidMem )); /* Lock for kernel side CPU access. */ gcmkONERROR(gckVIDMEM_NODE_LockCPU( hardware->kernel, - Execution->funcVidMem, + Execution->funcCmd[0].funcVidMem, gcvFALSE, gcvFALSE, - &Execution->logical + &Execution->funcCmd[0].logical )); /* Get CPU physical address. */ gcmkONERROR(gckVIDMEM_NODE_GetPhysical( hardware->kernel, - Execution->funcVidMem, + Execution->funcCmd[0].funcVidMem, 0, &physical )); @@ -10004,7 +3827,8 @@ _FuncInit_MMU(IN gcsFUNCTION_EXECUTION_PTR Execution) &physical )); - if (physical & 0xFFFFFFFF00000000ULL) + if (!gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_MMU_PAGE_DESCRIPTOR) + && (physical & 0xFFFFFFFF00000000ULL)) { gcmkFATAL("%s(%d): Command buffer physical address (0x%llx) for MMU setup exceeds 32bits, " "please rebuild kernel with CONFIG_ZONE_DMA32=y or CONFIG_ZONE_DMA=y or both.", @@ -10020,7 +3844,7 @@ _FuncInit_MMU(IN gcsFUNCTION_EXECUTION_PTR Execution) gcmkONERROR(gcvSTATUS_OUT_OF_MEMORY); } - gcmkSAFECASTPHYSADDRT(Execution->address, physical); + Execution->funcCmd[0].physical = physical; if (hardware->mcFE) { @@ -10028,54 +3852,195 @@ _FuncInit_MMU(IN gcsFUNCTION_EXECUTION_PTR Execution) hardware, hardware->kernel->mmu, mode, - Execution->logical, + Execution->funcCmd[0].logical, + &mmuBytes + )); + } + else + { + gcmkONERROR(_ProgramMMUStates( + hardware, + hardware->kernel->mmu, + mode, + Execution->funcCmd[0].logical, &mmuBytes )); } + + Execution->funcCmd[0].endPhysical = Execution->funcCmd[0].physical + mmuBytes; + Execution->funcCmd[0].endLogical = (gctUINT8_PTR)Execution->funcCmd[0].logical + mmuBytes; + + gcmkSAFECASTPHYSADDRT(Execution->funcCmd[0].address, Execution->funcCmd[0].physical); + + /* + * It is OK to cast the end physical to 32bit end address, even though the end physical is above 32bit. + * As the debug register which is checked with lastEnd, also will cast above 32bit address to 32bit address. + */ + gcmkSAFECASTPHYSADDRT(Execution->funcCmd[0].endAddress, Execution->funcCmd[0].endPhysical); + + if (hardware->wlFE) + { + tailBytes = (gctUINT32)(Execution->funcCmd[0].funcVidMemBytes - mmuBytes); + gcmkONERROR(gckWLFE_End( + hardware, Execution->funcCmd[0].endLogical, + Execution->funcCmd[0].endAddress, + &tailBytes)); + } else { - gcmkONERROR(_ProgramMMUStates( - hardware, - hardware->kernel->mmu, - mode, - Execution->logical, - &mmuBytes - )); + tailBytes = 0; + } + + Execution->funcCmd[0].bytes = mmuBytes + tailBytes; + + gcmkONERROR(gckVIDMEM_NODE_CleanCache( + hardware->kernel, + Execution->funcCmd[0].funcVidMem, + 0, + Execution->funcCmd[0].logical, + Execution->funcCmd[0].bytes + )); + + return gcvSTATUS_OK; + +OnError: + _FuncRelease_MMU(Execution); + + return status; +} + +static gceSTATUS +_FuncExecute_MMU_REG(IN gcsFUNCTION_EXECUTION_PTR Execution) +{ + gceSTATUS status = gcvSTATUS_OK; + gckHARDWARE hardware = (gckHARDWARE)Execution->hardware; + gckMMU mmu = hardware->kernel->mmu; + gctUINT32 address = 0; + gctUINT32 extSafeAddress = 0; + gctUINT32 mtlb, extMtlb; + + mtlb = (gctUINT32)(mmu->mtlbPhysical & 0xFFFFFFFF); + extMtlb = (gctUINT32)(mmu->mtlbPhysical >> 32); + + /* more than 40bit physical address */ + if (extMtlb & 0xFFFFFF00) + { + gcmkONERROR(gcvSTATUS_NOT_SUPPORTED); } - Execution->endAddress = Execution->address + mmuBytes; - Execution->endLogical = (gctUINT8_PTR)Execution->logical + mmuBytes; + gcmkONERROR(gckOS_WriteRegisterEx( + hardware->os, + hardware->core, + 0x003B4, + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 1:0) - (0 ? + 1:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 1:0) - (0 ? + 1:0) + 1))))))) << (0 ? + 1:0))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 1:0) - (0 ? + 1:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 1:0) - (0 ? 1:0) + 1))))))) << (0 ? 1:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:4) - (0 ? + 31:4) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:4) - (0 ? + 31:4) + 1))))))) << (0 ? + 31:4))) | (((gctUINT32) ((gctUINT32) ((extMtlb << 20) | (mtlb >> 4)) & ((gctUINT32) ((((1 ? + 31:4) - (0 ? + 31:4) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:4) - (0 ? 31:4) + 1))))))) << (0 ? 31:4))) + )); + + address = (gctUINT32)(mmu->safePagePhysical & 0xFFFFFFFF); + extSafeAddress = (gctUINT32)(mmu->safePagePhysical >> 32); - if (hardware->wlFE) + if (address & 0x3F) { - tailBytes = (gctUINT32)(Execution->funcVidMemBytes - mmuBytes); - gcmkONERROR(gckWLFE_End(hardware, Execution->endLogical, Execution->endAddress, &tailBytes)); + gcmkONERROR(gcvSTATUS_NOT_ALIGNED); } - else + + /* more than 40bit physical address */ + if (extSafeAddress & 0xFFFFFF00) { - tailBytes = 0; + gcmkONERROR(gcvSTATUS_NOT_SUPPORTED); } - Execution->bytes = mmuBytes + tailBytes; + gcmkONERROR(gckOS_WriteRegisterEx( + hardware->os, + hardware->core, + 0x00394, + 1 + )); - gcmkONERROR(gckVIDMEM_NODE_CleanCache( - hardware->kernel, - Execution->funcVidMem, - 0, - Execution->logical, - Execution->bytes + gcmkONERROR(gckOS_WriteRegisterEx( + hardware->os, + hardware->core, + 0x0039C, + address )); - return gcvSTATUS_OK; + gcmkONERROR(gckOS_WriteRegisterEx( + hardware->os, + hardware->core, + 0x00398, + address + )); -OnError: - _FuncRelease_MMU(Execution); + gcmkONERROR(gckOS_WriteRegisterEx( + hardware->os, + hardware->core, + 0x003A0, + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 23:16) - (0 ? + 23:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 23:16) - (0 ? + 23:16) + 1))))))) << (0 ? + 23:16))) | (((gctUINT32) ((gctUINT32) ((gctUINT32)extSafeAddress) & ((gctUINT32) ((((1 ? + 23:16) - (0 ? + 23:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 23:16) - (0 ? 23:16) + 1))))))) << (0 ? 23:16))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:31) - (0 ? + 31:31) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:31) - (0 ? + 31:31) + 1))))))) << (0 ? + 31:31))) | (((gctUINT32) (0x0 & ((gctUINT32) ((((1 ? + 31:31) - (0 ? + 31:31) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:31) - (0 ? 31:31) + 1))))))) << (0 ? 31:31))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 7:0) - (0 ? + 7:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 7:0) - (0 ? + 7:0) + 1))))))) << (0 ? + 7:0))) | (((gctUINT32) ((gctUINT32) ((gctUINT32)extSafeAddress) & ((gctUINT32) ((((1 ? + 7:0) - (0 ? + 7:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 7:0) - (0 ? 7:0) + 1))))))) << (0 ? 7:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:15) - (0 ? + 15:15) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:15) - (0 ? + 15:15) + 1))))))) << (0 ? + 15:15))) | (((gctUINT32) (0x0 & ((gctUINT32) ((((1 ? + 15:15) - (0 ? + 15:15) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:15) - (0 ? 15:15) + 1))))))) << (0 ? 15:15))) + )); +OnError: return status; } static gceSTATUS -_FuncExecute_MMU(IN gcsFUNCTION_EXECUTION_PTR Execution) +_FuncExecute_MMU_CMD(IN gcsFUNCTION_EXECUTION_PTR Execution) { gceSTATUS status = gcvSTATUS_OK; gctUINT32 address = 0; @@ -10083,13 +4048,13 @@ _FuncExecute_MMU(IN gcsFUNCTION_EXECUTION_PTR Execution) gctUINT32 timer = 0, delay = 1; gckHARDWARE hardware = (gckHARDWARE)Execution->hardware; gckMMU mmu = hardware->kernel->mmu; + gctUINT32_PTR endLogical = (gctUINT32_PTR)Execution->funcCmd[0].endLogical; /* Prepared command sequence contains an END, ** so update lastEnd and store executeCount to END command. */ - gctUINT32_PTR endLogical = (gctUINT32_PTR)Execution->endLogical; - hardware->lastEnd = Execution->endAddress; + hardware->lastEnd = Execution->funcCmd[0].endAddress; if (hardware->wlFE) { @@ -10100,6 +4065,38 @@ _FuncExecute_MMU(IN gcsFUNCTION_EXECUTION_PTR Execution) if (hardware->options.secureMode == gcvSECURE_IN_NORMAL) { gctUINT32 extSafeAddress; + + if (gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_MMU_PAGE_DESCRIPTOR)) + { + gctUINT32 extAddress = (gctUINT32)(Execution->funcCmd[0].physical >> 32); + + gcmkONERROR(gckOS_WriteRegisterEx( + hardware->os, + hardware->core, + 0x003B4, + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 1:0) - (0 ? + 1:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 1:0) - (0 ? + 1:0) + 1))))))) << (0 ? + 1:0))) | (((gctUINT32) (0x2 & ((gctUINT32) ((((1 ? + 1:0) - (0 ? + 1:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 1:0) - (0 ? 1:0) + 1))))))) << (0 ? 1:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:4) - (0 ? + 31:4) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:4) - (0 ? + 31:4) + 1))))))) << (0 ? + 31:4))) | (((gctUINT32) ((gctUINT32) ((extAddress << 20)) & ((gctUINT32) ((((1 ? + 31:4) - (0 ? + 31:4) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:4) - (0 ? 31:4) + 1))))))) << (0 ? 31:4))) + )); + } + /* Set up base address of page table array. */ gcmkONERROR(gckOS_WriteRegisterEx( hardware->os, @@ -10206,16 +4203,16 @@ _FuncExecute_MMU(IN gcsFUNCTION_EXECUTION_PTR Execution) hardware, gcvFALSE, 0, - Execution->address, - Execution->bytes + Execution->funcCmd[0].address, + Execution->funcCmd[0].bytes )); } else { gcmkONERROR(gckWLFE_Execute( hardware, - Execution->address, - Execution->bytes + Execution->funcCmd[0].address, + Execution->funcCmd[0].bytes )); } @@ -10225,8 +4222,8 @@ _FuncExecute_MMU(IN gcsFUNCTION_EXECUTION_PTR Execution) gcmkVERIFY_OK(gckOS_GetProcessID(&data.linkData.pid)); - data.linkData.start = Execution->address; - data.linkData.end = Execution->address + Execution->bytes; + data.linkData.start = Execution->funcCmd[0].address; + data.linkData.end = Execution->funcCmd[0].address + Execution->funcCmd[0].bytes; data.linkData.linkLow = 0; data.linkData.linkHigh = 0; @@ -10268,6 +4265,35 @@ _FuncExecute_MMU(IN gcsFUNCTION_EXECUTION_PTR Execution) } while (!(((((gctUINT32) (idle)) >> (0 ? 0:0)) & ((gctUINT32) ((((1 ? 0:0) - (0 ? 0:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 0:0) - (0 ? 0:0) + 1)))))) )); + if (gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_MMU_PAGE_DESCRIPTOR)) + { + gcmkONERROR(gckOS_WriteRegisterEx( + hardware->os, + hardware->core, + 0x003B4, + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 1:0) - (0 ? + 1:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 1:0) - (0 ? + 1:0) + 1))))))) << (0 ? + 1:0))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 1:0) - (0 ? + 1:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 1:0) - (0 ? 1:0) + 1))))))) << (0 ? 1:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:4) - (0 ? + 31:4) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:4) - (0 ? + 31:4) + 1))))))) << (0 ? + 31:4))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 31:4) - (0 ? + 31:4) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:4) - (0 ? 31:4) + 1))))))) << (0 ? 31:4))) + )); + } + gcmkDUMP(hardware->os, "@[register.wait 0x%05X 0x%08X 0x%08X]", 0x00004, ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? @@ -10287,6 +4313,26 @@ OnError: } static gceSTATUS +_FuncExecute_MMU(IN gcsFUNCTION_EXECUTION_PTR Execution) +{ + gckHARDWARE hardware = (gckHARDWARE)Execution->hardware; + gckMMU mmu = hardware->kernel->mmu; + gceSTATUS status = gcvSTATUS_OK; + + if (mmu->initMode == gcvMMU_INIT_FROM_REG) + { + gcmkONERROR(_FuncExecute_MMU_REG(Execution)); + } + else + { + gcmkONERROR(_FuncExecute_MMU_CMD(Execution)); + } + +OnError: + return status; +} + +static gceSTATUS _FuncValidate_Flush(IN gcsFUNCTION_EXECUTION_PTR Execution) { Execution->valid = gcvTRUE; @@ -10297,40 +4343,49 @@ _FuncValidate_Flush(IN gcsFUNCTION_EXECUTION_PTR Execution) static gceSTATUS _FuncRelease_Flush(IN gcsFUNCTION_EXECUTION_PTR Execution) { + gctUINT8 i; gckHARDWARE hardware = (gckHARDWARE)Execution->hardware; - if (Execution->funcVidMem) + if (Execution->funcCmd) { - if (Execution->address) + for (i = 0; i < Execution->funcCmdCount; i++) { - /* Synchroneous unlock. */ - gcmkVERIFY_OK(gckVIDMEM_NODE_Unlock( - hardware->kernel, - Execution->funcVidMem, - 0, - gcvNULL - )); - Execution->address = 0; - } + if (Execution->funcCmd[i].funcVidMem) + { + if (Execution->funcCmd[i].address) + { + /* Synchroneous unlock. */ + gcmkVERIFY_OK(gckVIDMEM_NODE_Unlock( + hardware->kernel, + Execution->funcCmd[i].funcVidMem, + 0, + gcvNULL + )); + Execution->funcCmd[i].address = 0; + } - if (Execution->logical) - { - gcmkVERIFY_OK(gckVIDMEM_NODE_UnlockCPU( - hardware->kernel, - Execution->funcVidMem, - 0, - gcvFALSE, - gcvFALSE - )); - Execution->logical = gcvNULL; - } + if (Execution->funcCmd[i].logical) + { + gcmkVERIFY_OK(gckVIDMEM_NODE_UnlockCPU( + hardware->kernel, + Execution->funcCmd[i].funcVidMem, + 0, + gcvFALSE, + gcvFALSE + )); + Execution->funcCmd[i].logical = gcvNULL; + } - gcmkVERIFY_OK(gckVIDMEM_NODE_Dereference( - hardware->kernel, - Execution->funcVidMem - )); + gcmkVERIFY_OK(gckVIDMEM_NODE_Dereference( + hardware->kernel, + Execution->funcCmd[i].funcVidMem + )); + + Execution->funcCmd[i].funcVidMem = gcvNULL; + } + } - Execution->funcVidMem = gcvNULL; + gcmkVERIFY_OK(gckOS_Free(hardware->os, (gctPOINTER)Execution->funcCmd)); } return gcvSTATUS_OK; @@ -10348,6 +4403,7 @@ _FuncInit_Flush(IN gcsFUNCTION_EXECUTION_PTR Execution) gcePOOL pool; gctUINT8_PTR logical; gckHARDWARE hardware = (gckHARDWARE)Execution->hardware; + gctPOINTER pointer = gcvNULL; #if !gcdCAPTURE_ONLY_MODE pool = gcvPOOL_DEFAULT; @@ -10358,39 +4414,49 @@ _FuncInit_Flush(IN gcsFUNCTION_EXECUTION_PTR Execution) #if gcdENABLE_CACHEABLE_COMMAND_BUFFER allocFlag = gcvALLOC_FLAG_CACHEABLE; #endif + Execution->funcCmdCount = 1; + + /* Allocate the gcsFUNCTION_COMMAND buffer */ + gcmkONERROR(gckOS_Allocate(hardware->os, + gcmSIZEOF(gcsFUNCTION_COMMAND) * Execution->funcCmdCount, + (gctPOINTER *)&pointer)); - Execution->funcVidMemBytes = 1024; + gckOS_ZeroMemory((gctPOINTER)pointer, gcmSIZEOF(gcsFUNCTION_COMMAND) * Execution->funcCmdCount); + + Execution->funcCmd = (gcsFUNCTION_COMMAND_PTR)pointer; + + Execution->funcCmd[0].funcVidMemBytes = 1024; /* Allocate video memory node for aux functions. */ gcmkONERROR(gckKERNEL_AllocateVideoMemory( hardware->kernel, 64, gcvVIDMEM_TYPE_COMMAND, allocFlag, - &Execution->funcVidMemBytes, + &Execution->funcCmd[0].funcVidMemBytes, &pool, - &Execution->funcVidMem + &Execution->funcCmd[0].funcVidMem )); /* Lock for GPU access. */ gcmkONERROR(gckVIDMEM_NODE_Lock( hardware->kernel, - Execution->funcVidMem, - &Execution->address + Execution->funcCmd[0].funcVidMem, + &Execution->funcCmd[0].address )); /* Lock for kernel side CPU access. */ gcmkONERROR(gckVIDMEM_NODE_LockCPU( hardware->kernel, - Execution->funcVidMem, + Execution->funcCmd[0].funcVidMem, gcvFALSE, gcvFALSE, - &Execution->logical + &Execution->funcCmd[0].logical )); /* ** All cache flush command sequence. */ - logical = (gctUINT8_PTR)Execution->logical; - address = Execution->address; + logical = (gctUINT8_PTR)Execution->funcCmd[0].logical; + address = Execution->funcCmd[0].address; /* Get the size of the flush command. */ gcmkONERROR(gckHARDWARE_Flush(hardware, gcvFLUSH_ALL, gcvNULL, &flushBytes)); @@ -10408,9 +4474,9 @@ _FuncInit_Flush(IN gcsFUNCTION_EXECUTION_PTR Execution) gcmkONERROR(gckWLFE_End(hardware, logical, address, &endBytes)); } - Execution->bytes = flushBytes + endBytes; - Execution->endAddress = Execution->address + flushBytes; - Execution->endLogical = (gctUINT8_PTR)Execution->logical + flushBytes; + Execution->funcCmd[0].bytes = flushBytes + endBytes; + Execution->funcCmd[0].endAddress = Execution->funcCmd[0].address + flushBytes; + Execution->funcCmd[0].endLogical = (gctUINT8_PTR)Execution->funcCmd[0].logical + flushBytes; return gcvSTATUS_OK; OnError: @@ -10419,25 +4485,175 @@ OnError: return status; } +#if gcdFLOP_RESET +static gceSTATUS +_FuncValidate_FlopReset( + IN gcsFUNCTION_EXECUTION_PTR Execution + ) +{ + gceSTATUS status = gcvSTATUS_OK; + +#ifndef EMULATOR + gckHARDWARE hardware = (gckHARDWARE)Execution->hardware; +#endif + +#ifdef EMULATOR + Execution->valid = gcvFALSE; +#else + Execution->valid = gcvFALSE; + + if (hardware->type == gcvHARDWARE_VIP && + (!gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_EVIS2_FLOP_RESET_FIX) || + !gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_USC_EVICT_CTRL_FIFO_FLOP_RESET_FIX) || + !gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_USC_ASYNC_CP_RTN_FLOP_RESET_FIX))) + { + Execution->valid = gcvTRUE; + } +#endif + + return status; +} + +static gceSTATUS +_FuncInit_FlopReset( + IN gcsFUNCTION_EXECUTION_PTR Execution + ) +{ + gceSTATUS status = gcvSTATUS_OK; + + gckHARDWARE hardware = (gckHARDWARE)Execution->hardware; + gctPOINTER pointer = gcvNULL; + gctUINT32 index = 0; + gctBOOL doPPU = gcvFALSE; + gctBOOL doNN = gcvFALSE; + gctBOOL doTP = gcvFALSE; + gctUINT32 allocFlag = gcvALLOC_FLAG_NONE; + gcePOOL pool = gcvPOOL_DEFAULT; + + Execution->funcCmdCount = 0; + +#if gcdFLOP_RESET_PPU + /* PPU is always there. */ + doPPU = gcvTRUE; + Execution->funcCmdCount++; +#endif + +#if gcdFLOP_RESET_NN + if (gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_NN_ENGINE) && (hardware->identity.customerID == 0x9f)) + { + doNN = gcvTRUE; + Execution->funcCmdCount++; + } +#endif + +#if gcdFLOP_RESET_TP + if (gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_TP_ENGINE) && (hardware->identity.customerID == 0x9f)) + { + doTP = gcvTRUE; + Execution->funcCmdCount++; + } +#endif + + if (!Execution->funcCmdCount) + { + /* Nothing to do. */ + return gcvSTATUS_OK; + } + + /* Allocate the gcsFUNCTION_COMMAND buffer */ + gcmkONERROR(gckOS_Allocate( + hardware->os, + gcmSIZEOF(gcsFUNCTION_COMMAND) * Execution->funcCmdCount, + (gctPOINTER *)&pointer + )); + + Execution->funcCmd = (gcsFUNCTION_COMMAND_PTR)pointer; + + gcmkONERROR(gckOS_ZeroMemory( + (gctPOINTER)pointer, + gcmSIZEOF(gcsFUNCTION_COMMAND) * Execution->funcCmdCount + )); + +#if !gcdCAPTURE_ONLY_MODE + pool = gcvPOOL_DEFAULT; +#else + pool = gcvPOOL_VIRTUAL; +#endif + +#if gcdENABLE_CACHEABLE_COMMAND_BUFFER + allocFlag = gcvALLOC_FLAG_CACHEABLE; +#endif + + if (doPPU) + { + gcmkONERROR(gckHARDWARE_ResetFlopWithPPU( + hardware, + allocFlag, + &pool, + &Execution->funcCmd[index++] + )); + } + + if (doNN) + { + gcmkONERROR(gckHARDWARE_ResetFlopWithNN( + hardware, + allocFlag, + &pool, + &Execution->funcCmd[index++] + )); + } + + if (doTP) + { + gcmkONERROR(gckHARDWARE_ResetFlopWithTP( + hardware, + allocFlag, + &pool, + &Execution->funcCmd[index++] + )); + } + + gcmkASSERT(index <= Execution->funcCmdCount); + + return gcvSTATUS_OK; + +OnError: + _FuncRelease(Execution); + + return status; +} +#else #if gcdINITIALIZE_PPU + +#if gcdINITIALIZE_PPU_C +#include "gc_hal_kernel_hardware_func_ppu.h" +#endif + static gceSTATUS _FuncValidate_PPU(IN gcsFUNCTION_EXECUTION_PTR Execution) { +#ifdef EMULATOR + Execution->valid = gcvFALSE; +#else gckHARDWARE hardware = (gckHARDWARE)Execution->hardware; Execution->valid = gcvFALSE; if (!gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_EVIS2_FLOP_RESET_FIX)) { +#if gcdINITIALIZE_PPU_C + Execution->valid = gcvTRUE; +#else if (hardware->identity.customerID == 0x21 || hardware->identity.customerID == 0x25 || - hardware->identity.customerID == 0x86 || - hardware->identity.customerID == 0xA0 + hardware->identity.customerID == 0x86 ) { Execution->valid = gcvTRUE; } +#endif } - +#endif return gcvSTATUS_OK; } @@ -10445,79 +4661,103 @@ static gceSTATUS _FuncRelease_PPU(IN gcsFUNCTION_EXECUTION_PTR Execution) { gckHARDWARE hardware = (gckHARDWARE)Execution->hardware; - gctUINT32 i; + gctUINT32 i, j; - if (Execution->data) + if (Execution->funcCmd) { - for (i = 0; i < 8; i++) +#if gcdINITIALIZE_PPU_C + + gctUINT32 pass = gcvTRUE; + + for (i = 0; i < (64 * 6 / 4); i ++) { - if (Execution->data[i].bufVidMem) + if (((gctUINT32_PTR)(Execution->funcCmd[0].data[OUTPUT_PPU_IDX].logical))[i] != 0x02020202) { - if (Execution->data[i].logical) - { - gckVIDMEM_NODE_UnlockCPU( - hardware->kernel, - Execution->data[i].bufVidMem, - 0, - gcvFALSE, - gcvFALSE - ); - Execution->data[i].logical = gcvNULL; - } - if (Execution->data[i].address) - { - gckVIDMEM_NODE_Unlock( - hardware->kernel, - Execution->data[i].bufVidMem, - 0, - gcvNULL - ); - Execution->data[i].address = 0; + pass = gcvFALSE; + gcmkPRINT("Incorrect Result:[%d] 0x%08x\n", i, ((gctUINT32_PTR)(Execution->funcCmd[0].data[OUTPUT_PPU_IDX].logical))[i]); + } + } + gcmkPRINT("PPU %s!\n", pass?"PASS":"FAIL"); + +#endif + + for (j = 0; j < Execution->funcCmdCount; j++) + { + if (Execution->funcCmd[j].data) + { + for (i = 0; i < 7; i++) + { + if (Execution->funcCmd[j].data[i].bufVidMem) + { + if (Execution->funcCmd[j].data[i].logical) + { + gckVIDMEM_NODE_UnlockCPU( + hardware->kernel, + Execution->funcCmd[j].data[i].bufVidMem, + 0, + gcvFALSE, + gcvFALSE + ); + Execution->funcCmd[j].data[i].logical = gcvNULL; + } + if (Execution->funcCmd[j].data[i].address) + { + gckVIDMEM_NODE_Unlock( + hardware->kernel, + Execution->funcCmd[j].data[i].bufVidMem, + 0, + gcvNULL + ); + Execution->funcCmd[j].data[i].address = 0; + } + + gckVIDMEM_NODE_Dereference( + hardware->kernel, + Execution->funcCmd[j].data[i].bufVidMem + ); + } } - gckVIDMEM_NODE_Dereference( - hardware->kernel, - Execution->data[i].bufVidMem - ); + gcmkVERIFY_OK(gckOS_Free(hardware->os, Execution->funcCmd[j].data)); + Execution->funcCmd[j].data = gcvNULL; } - } - gcmkVERIFY_OK(gckOS_Free(hardware->os, Execution->data)); - Execution->data = gcvNULL; - } + if (Execution->funcCmd[j].funcVidMem) + { + if (Execution->funcCmd[j].address) + { + /* Synchroneous unlock. */ + gcmkVERIFY_OK(gckVIDMEM_NODE_Unlock( + hardware->kernel, + Execution->funcCmd[j].funcVidMem, + 0, + gcvNULL + )); + Execution->funcCmd[j].address = 0; + } - if (Execution->funcVidMem) - { - if (Execution->address) - { - /* Synchroneous unlock. */ - gcmkVERIFY_OK(gckVIDMEM_NODE_Unlock( - hardware->kernel, - Execution->funcVidMem, - 0, - gcvNULL - )); - Execution->address = 0; - } + if (Execution->funcCmd[j].logical) + { + gcmkVERIFY_OK(gckVIDMEM_NODE_UnlockCPU( + hardware->kernel, + Execution->funcCmd[j].funcVidMem, + 0, + gcvFALSE, + gcvFALSE + )); + Execution->funcCmd[j].logical = gcvNULL; + } - if (Execution->logical) - { - gcmkVERIFY_OK(gckVIDMEM_NODE_UnlockCPU( - hardware->kernel, - Execution->funcVidMem, - 0, - gcvFALSE, - gcvFALSE - )); - Execution->logical = gcvNULL; - } + gcmkVERIFY_OK(gckVIDMEM_NODE_Dereference( + hardware->kernel, + Execution->funcCmd[j].funcVidMem + )); - gcmkVERIFY_OK(gckVIDMEM_NODE_Dereference( - hardware->kernel, - Execution->funcVidMem - )); + Execution->funcCmd[j].funcVidMem = gcvNULL; + } + } - Execution->funcVidMem = gcvNULL; + gcmkVERIFY_OK(gckOS_Free(hardware->os, (gctPOINTER)Execution->funcCmd)); } return gcvSTATUS_OK; @@ -10526,31 +4766,51 @@ _FuncRelease_PPU(IN gcsFUNCTION_EXECUTION_PTR Execution) gceSTATUS _PatchPPUBuffer( IN gcsFUNCTION_EXECUTION_PTR Execution +#if gcdINITIALIZE_PPU_C +, + IN gctUINT32 Width, + IN gctUINT32 Height, + OUT gctUINT32_PTR Bytes, + OUT gctUINT32_PTR RegCount +#endif ) { gceSTATUS status = gcvSTATUS_OK; gcePOOL pool = gcvPOOL_DEFAULT; - gctUINT32_PTR command = (gctUINT32_PTR)Execution->logical; - gctUINT32 commandPatchOffsets[8]; - gctUINT32_PTR patchBuffers[8]; - gctSIZE_T patchBufferSizes[8]; +#if !gcdINITIALIZE_PPU_C + gctUINT32_PTR command = (gctUINT32_PTR)Execution->funcCmd[0].logical; + gctUINT32 commandPatchOffsets[7] = {0}; +#endif + gctUINT32_PTR patchBuffers[7] = {NULL}; + gctSIZE_T patchBufferSizes[7] = {0}; gctUINT32 i; gctUINT32 allocFlag = 0; gckHARDWARE hardware = (gckHARDWARE)Execution->hardware; gctPOINTER pointer = gcvNULL; + gctUINT32 patchSize = 7; #if gcdENABLE_CACHEABLE_COMMAND_BUFFER allocFlag = gcvALLOC_FLAG_CACHEABLE; #endif +#if gcdINITIALIZE_PPU_C + gctUINT32 j = 0; + gctUINT32 data_type = 0x7, item_size = 1; + patchBuffers[INPUT_PPU_IDX] = NULL; + patchBuffers[OUTPUT_PPU_IDX] = NULL; + patchBuffers[INST_PPU_IDX] = NULL; + patchBufferSizes[INPUT_PPU_IDX] = Width * Height * item_size; + patchBufferSizes[OUTPUT_PPU_IDX] = Width * Height * item_size; + patchBufferSizes[INST_PPU_IDX] = 4 * 4 * gcmSIZEOF(gctUINT32); + +#else patchBuffers[0] = ppuMem0; patchBuffers[1] = ppuMem1; patchBuffers[2] = ppuMem2; patchBuffers[3] = ppuMem3; patchBuffers[4] = ppuMem4; patchBuffers[5] = ppuMem5; - patchBuffers[6] = ppuMem6; - patchBuffers[7] = ppuMem7; + patchBuffers[6] = gcvNULL; patchBufferSizes[0] = gcmSIZEOF(ppuMem0); patchBufferSizes[1] = gcmSIZEOF(ppuMem1); @@ -10558,100 +4818,117 @@ _PatchPPUBuffer( patchBufferSizes[3] = gcmSIZEOF(ppuMem3); patchBufferSizes[4] = gcmSIZEOF(ppuMem4); patchBufferSizes[5] = gcmSIZEOF(ppuMem5); - patchBufferSizes[6] = gcmSIZEOF(ppuMem6); - patchBufferSizes[7] = gcmSIZEOF(ppuMem7); + patchBufferSizes[6] = 1024 * 6; commandPatchOffsets[0] = PATCH_OFFSET_0; commandPatchOffsets[1] = PATCH_OFFSET_1; commandPatchOffsets[2] = PATCH_OFFSET_2; + commandPatchOffsets[3] = PATCH_OFFSET_3; commandPatchOffsets[4] = PATCH_OFFSET_4; commandPatchOffsets[5] = PATCH_OFFSET_5; commandPatchOffsets[6] = PATCH_OFFSET_6; - commandPatchOffsets[7] = PATCH_OFFSET_7; +#endif gcmkONERROR(gckOS_Allocate(hardware->os, - gcmSIZEOF(gcsFUNCTION_EXECUTION_DATA) * 8, + gcmSIZEOF(gcsFUNCTION_EXECUTION_DATA) * patchSize, &pointer)); - gckOS_ZeroMemory(pointer, gcmSIZEOF(gcsFUNCTION_EXECUTION_DATA) * 8); + gckOS_ZeroMemory(pointer, gcmSIZEOF(gcsFUNCTION_EXECUTION_DATA) * patchSize); - Execution->data = (gcsFUNCTION_EXECUTION_DATA_PTR)pointer; + Execution->funcCmd[0].data = (gcsFUNCTION_EXECUTION_DATA_PTR)pointer; - for (i = 0; i < 8; i++) + for (i = 0; i < patchSize; i++) { - if (i != 3) - { - /* Allocate memory for buffers. */ - gcmkONERROR(gckKERNEL_AllocateVideoMemory( - hardware->kernel, - 64, - gcvVIDMEM_TYPE_BITMAP, - allocFlag, - &patchBufferSizes[i], - &pool, - &Execution->data[i].bufVidMem - )); +#if gcdINITIALIZE_PPU_C + if (patchBufferSizes[i] <= 0) + continue; +#endif + /* Allocate memory for buffers. */ + gcmkONERROR(gckKERNEL_AllocateVideoMemory( + hardware->kernel, + 64, + gcvVIDMEM_TYPE_BITMAP, + allocFlag, + &patchBufferSizes[i], + &pool, + &Execution->funcCmd[0].data[i].bufVidMem + )); - gcmkONERROR(gckVIDMEM_NODE_LockCPU( - hardware->kernel, - Execution->data[i].bufVidMem, - gcvFALSE, - gcvFALSE, - &Execution->data[i].logical - )); + gcmkONERROR(gckVIDMEM_NODE_LockCPU( + hardware->kernel, + Execution->funcCmd[0].data[i].bufVidMem, + gcvFALSE, + gcvFALSE, + &Execution->funcCmd[0].data[i].logical + )); - gckOS_MemCopy(Execution->data[i].logical, patchBuffers[i], patchBufferSizes[i]); + gcmkONERROR(gckVIDMEM_NODE_Lock( + hardware->kernel, + Execution->funcCmd[0].data[i].bufVidMem, + &Execution->funcCmd[0].data[i].address + )); - gcmkONERROR(gckVIDMEM_NODE_Lock( - hardware->kernel, - Execution->data[i].bufVidMem, - &Execution->data[i].address - )); +#if gcdINITIALIZE_PPU_C + gckOS_ZeroMemory(Execution->funcCmd[0].data[i].logical, patchBufferSizes[i]); - /* patch the buffer */ - command[commandPatchOffsets[i]] = Execution->data[i].address; + if (patchBuffers[i]) + { + gckOS_MemCopy(Execution->funcCmd[0].data[i].logical, patchBuffers[i], patchBufferSizes[i]); + } + else if (i == INST_PPU_IDX) + { + gcoHwFunc_SH_CMD(hardware, data_type, (gctUINT32_PTR)Execution->funcCmd[0].data[i].logical, Bytes, RegCount); + } + else + { + for (j = 0; j < patchBufferSizes[i]/4; j++) + ((gctUINT32_PTR)(Execution->funcCmd[0].data[i].logical))[j] = 0x01010101; } +#else + /* patch the buffer */ + command[commandPatchOffsets[i]] = Execution->funcCmd[0].data[i].address; +#endif } return status; OnError: - if (Execution->data) + if (Execution->funcCmd[0].data) { - for (i = 0; i < 8; i++) + for (i = 0; i < patchSize; i++) { - if (Execution->data[i].bufVidMem) + if (Execution->funcCmd[0].data[i].bufVidMem) { - if (Execution->data[i].logical) + if (Execution->funcCmd[0].data[i].logical) { gckVIDMEM_NODE_UnlockCPU( hardware->kernel, - Execution->data[i].bufVidMem, + Execution->funcCmd[0].data[i].bufVidMem, 0, gcvFALSE, gcvFALSE ); - Execution->data[i].logical = gcvNULL; + Execution->funcCmd[0].data[i].logical = gcvNULL; } - if (Execution->data[i].address) + if (Execution->funcCmd[0].data[i].address) { gckVIDMEM_NODE_Unlock( hardware->kernel, - Execution->data[i].bufVidMem, + Execution->funcCmd[0].data[i].bufVidMem, 0, gcvNULL ); - Execution->data[i].address = 0; + Execution->funcCmd[0].data[i].address = 0; } gckVIDMEM_NODE_Dereference( hardware->kernel, - Execution->data[i].bufVidMem + Execution->funcCmd[0].data[i].bufVidMem ); } } - gcmkVERIFY_OK(gckOS_Free(hardware->os, Execution->data)); - Execution->data = gcvNULL; + gcmkVERIFY_OK(gckOS_Free(hardware->os, Execution->funcCmd[0].data)); + Execution->funcCmd[0].data = gcvNULL; } return status; @@ -10664,9 +4941,242 @@ _InitializePPU( ) { gceSTATUS status = gcvSTATUS_OK; - gctPOINTER logical = Execution->logical; + gctPOINTER logical = Execution->funcCmd[0].logical; +#if gcdINITIALIZE_PPU_C + gctUINT32 width = 64, height = 6, stride = 64; + gctUINT32 count = 0, regCount = 0; + gcsFEATURE_DATABASE * db = (gcsFEATURE_DATABASE *)((gckHARDWARE)Execution->hardware)->featureDatabase; + + gctINT32 workDim = 0x2, valueOrder = 0x2; + gctUINT32 groupsizeX = 1, groupsizeY = 1, groupsizeZ = 0; + gctUINT32 globalscaleX = 4, globalscaleY = 1, globalscaleZ = 0; + gctUINT32 groupcountX = gcmALIGN_NP2(width, globalscaleX)/globalscaleX, groupcountY = gcmALIGN_NP2(height, globalscaleY)/globalscaleY, groupcountZ = 0; + gctUINT32 globaloffsetX = 0, globaloffsetY = 0, globaloffsetZ = 0; + gctUINT32 threadAllocation = gcmALIGN_NP2(groupsizeX * groupsizeY, db->NumShaderCores * 4)/db->NumShaderCores * 4; + + /* Patch the command. */ + if (logical) + { + status = _PatchPPUBuffer(Execution, width, height, &count, ®Count); + } + + if (count > 0 && regCount > 0) + { +#endif +#if gcdINITIALIZE_PPU_C + gctUINT32 flushCommands[] = { +#else + static gctUINT32 flushCommands[] = { + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x028A) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))), + 0x00000011, +#endif + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0E13) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))), +#if gcdINITIALIZE_PPU_C + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 1:0) - (0 ? + 1:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 1:0) - (0 ? + 1:0) + 1))))))) << (0 ? + 1:0))) | (((gctUINT32) (0x2 & ((gctUINT32) ((((1 ? + 1:0) - (0 ? + 1:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 1:0) - (0 ? 1:0) + 1))))))) << (0 ? 1:0))), +#else + 0x00000002, +#endif + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x5580) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))), +#if gcdINITIALIZE_PPU_C + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 1:1) - (0 ? + 1:1) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 1:1) - (0 ? + 1:1) + 1))))))) << (0 ? + 1:1))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 1:1) - (0 ? + 1:1) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 1:1) - (0 ? 1:1) + 1))))))) << (0 ? 1:1))), +#else + 0x00000002, +#endif + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0E02) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))), +#if gcdINITIALIZE_PPU_C + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 4:0) - (0 ? + 4:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 4:0) - (0 ? + 4:0) + 1))))))) << (0 ? + 4:0))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 4:0) - (0 ? + 4:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 4:0) - (0 ? 4:0) + 1))))))) << (0 ? 4:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 12:8) - (0 ? + 12:8) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 12:8) - (0 ? + 12:8) + 1))))))) << (0 ? + 12:8))) | (((gctUINT32) (0x07 & ((gctUINT32) ((((1 ? + 12:8) - (0 ? + 12:8) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 12:8) - (0 ? 12:8) + 1))))))) << (0 ? 12:8))), +#else + 0x00000701, +#endif + + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x09 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))), +#if gcdINITIALIZE_PPU_C + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 4:0) - (0 ? + 4:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 4:0) - (0 ? + 4:0) + 1))))))) << (0 ? + 4:0))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 4:0) - (0 ? + 4:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 4:0) - (0 ? 4:0) + 1))))))) << (0 ? 4:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 12:8) - (0 ? + 12:8) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 12:8) - (0 ? + 12:8) + 1))))))) << (0 ? + 12:8))) | (((gctUINT32) (0x07 & ((gctUINT32) ((((1 ? + 12:8) - (0 ? + 12:8) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 12:8) - (0 ? 12:8) + 1))))))) << (0 ? 12:8))), +#else + 0x00000701, +#endif - gctUINT32 flushCommands[] = { ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 31:27) - (0 ? 31:27) + 1) == 32) ? @@ -10683,7 +5193,7 @@ _InitializePPU( ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? - 15:0))) | (((gctUINT32) ((gctUINT32) (0x028A) & ((gctUINT32) ((((1 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0xD800) & ((gctUINT32) ((((1 ? 15:0) - (0 ? 15:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) @@ -10693,11 +5203,126 @@ _InitializePPU( ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? - 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (4) & ((gctUINT32) ((((1 ? 25:16) - (0 ? 25:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))), - 0x00000011, +#if gcdINITIALIZE_PPU_C + Execution->funcCmd[0].data[0].address, stride, (height << 16 | width), + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 2:0) - (0 ? + 2:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 2:0) - (0 ? + 2:0) + 1))))))) << (0 ? + 2:0))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 2:0) - (0 ? + 2:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 2:0) - (0 ? 2:0) + 1))))))) << (0 ? 2:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 3:3) - (0 ? + 3:3) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 3:3) - (0 ? + 3:3) + 1))))))) << (0 ? + 3:3))) | (((gctUINT32) ((gctUINT32) (0x0) & ((gctUINT32) ((((1 ? + 3:3) - (0 ? + 3:3) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 3:3) - (0 ? 3:3) + 1))))))) << (0 ? 3:3))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 5:4) - (0 ? + 5:4) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 5:4) - (0 ? + 5:4) + 1))))))) << (0 ? + 5:4))) | (((gctUINT32) ((gctUINT32) (0x3) & ((gctUINT32) ((((1 ? + 5:4) - (0 ? + 5:4) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 5:4) - (0 ? 5:4) + 1))))))) << (0 ? 5:4))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 9:6) - (0 ? + 9:6) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 9:6) - (0 ? + 9:6) + 1))))))) << (0 ? + 9:6))) | (((gctUINT32) ((gctUINT32) (0x7) & ((gctUINT32) ((((1 ? + 9:6) - (0 ? + 9:6) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 9:6) - (0 ? 9:6) + 1))))))) << (0 ? 9:6))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 11:10) - (0 ? + 11:10) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 11:10) - (0 ? + 11:10) + 1))))))) << (0 ? + 11:10))) | (((gctUINT32) (0x0 & ((gctUINT32) ((((1 ? + 11:10) - (0 ? + 11:10) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 11:10) - (0 ? 11:10) + 1))))))) << (0 ? 11:10))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 12:12) - (0 ? + 12:12) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 12:12) - (0 ? + 12:12) + 1))))))) << (0 ? + 12:12))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 12:12) - (0 ? + 12:12) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 12:12) - (0 ? 12:12) + 1))))))) << (0 ? 12:12))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:14) - (0 ? + 15:14) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:14) - (0 ? + 15:14) + 1))))))) << (0 ? + 15:14))) | (((gctUINT32) ((gctUINT32) (0x1) & ((gctUINT32) ((((1 ? + 15:14) - (0 ? + 15:14) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:14) - (0 ? 15:14) + 1))))))) << (0 ? 15:14))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 18:16) - (0 ? + 18:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 18:16) - (0 ? + 18:16) + 1))))))) << (0 ? + 18:16))) | (((gctUINT32) ((gctUINT32) (0x0) & ((gctUINT32) ((((1 ? + 18:16) - (0 ? + 18:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 18:16) - (0 ? 18:16) + 1))))))) << (0 ? 18:16))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 22:20) - (0 ? + 22:20) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 22:20) - (0 ? + 22:20) + 1))))))) << (0 ? + 22:20))) | (((gctUINT32) ((gctUINT32) (0x4) & ((gctUINT32) ((((1 ? + 22:20) - (0 ? + 22:20) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 22:20) - (0 ? 22:20) + 1))))))) << (0 ? 22:20))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 26:24) - (0 ? + 26:24) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 26:24) - (0 ? + 26:24) + 1))))))) << (0 ? + 26:24))) | (((gctUINT32) ((gctUINT32) (0x4) & ((gctUINT32) ((((1 ? + 26:24) - (0 ? + 26:24) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 26:24) - (0 ? 26:24) + 1))))))) << (0 ? 26:24))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 30:28) - (0 ? + 30:28) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 30:28) - (0 ? + 30:28) + 1))))))) << (0 ? + 30:28))) | (((gctUINT32) ((gctUINT32) (0x4) & ((gctUINT32) ((((1 ? + 30:28) - (0 ? + 30:28) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 30:28) - (0 ? 30:28) + 1))))))) << (0 ? 30:28))), +#else + 0xD8000340, 0x00000080, 0x00800080, 0x444051F0, +#endif + 0xFFFFFFFF, ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 31:27) - (0 ? @@ -10709,13 +5334,15 @@ _InitializePPU( 31:27) - (0 ? 31:27) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) +#if gcdINITIALIZE_PPU_C + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 15:0) - (0 ? 15:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? - 15:0))) | (((gctUINT32) ((gctUINT32) (0x0E13) & ((gctUINT32) ((((1 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0xD800 + 0x04) & ((gctUINT32) ((((1 ? 15:0) - (0 ? 15:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) @@ -10725,29 +5352,129 @@ _InitializePPU( ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? - 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (4) & ((gctUINT32) ((((1 ? 25:16) - (0 ? 25:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))), - 0x00000002, - - ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 31:27) - (0 ? - 31:27) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 31:27) - (0 ? - 31:27) + 1))))))) << (0 ? - 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? - 31:27) - (0 ? - 31:27) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + Execution->funcCmd[0].data[1].address, stride, (height << 16 | width), + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 2:0) - (0 ? + 2:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 2:0) - (0 ? + 2:0) + 1))))))) << (0 ? + 2:0))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 2:0) - (0 ? + 2:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 2:0) - (0 ? 2:0) + 1))))))) << (0 ? 2:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 3:3) - (0 ? + 3:3) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 3:3) - (0 ? + 3:3) + 1))))))) << (0 ? + 3:3))) | (((gctUINT32) ((gctUINT32) (0x0) & ((gctUINT32) ((((1 ? + 3:3) - (0 ? + 3:3) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 3:3) - (0 ? 3:3) + 1))))))) << (0 ? 3:3))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 5:4) - (0 ? + 5:4) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 5:4) - (0 ? + 5:4) + 1))))))) << (0 ? + 5:4))) | (((gctUINT32) ((gctUINT32) (0x3) & ((gctUINT32) ((((1 ? + 5:4) - (0 ? + 5:4) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 5:4) - (0 ? 5:4) + 1))))))) << (0 ? 5:4))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 9:6) - (0 ? + 9:6) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 9:6) - (0 ? + 9:6) + 1))))))) << (0 ? + 9:6))) | (((gctUINT32) ((gctUINT32) (0x7) & ((gctUINT32) ((((1 ? + 9:6) - (0 ? + 9:6) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 9:6) - (0 ? 9:6) + 1))))))) << (0 ? 9:6))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 11:10) - (0 ? + 11:10) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 11:10) - (0 ? + 11:10) + 1))))))) << (0 ? + 11:10))) | (((gctUINT32) (0x0 & ((gctUINT32) ((((1 ? + 11:10) - (0 ? + 11:10) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 11:10) - (0 ? 11:10) + 1))))))) << (0 ? 11:10))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 12:12) - (0 ? + 12:12) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 12:12) - (0 ? + 12:12) + 1))))))) << (0 ? + 12:12))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 12:12) - (0 ? + 12:12) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 12:12) - (0 ? 12:12) + 1))))))) << (0 ? 12:12))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:14) - (0 ? + 15:14) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:14) - (0 ? + 15:14) + 1))))))) << (0 ? + 15:14))) | (((gctUINT32) ((gctUINT32) (0x1) & ((gctUINT32) ((((1 ? + 15:14) - (0 ? + 15:14) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:14) - (0 ? 15:14) + 1))))))) << (0 ? 15:14))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 18:16) - (0 ? + 18:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 18:16) - (0 ? + 18:16) + 1))))))) << (0 ? + 18:16))) | (((gctUINT32) ((gctUINT32) (0x0) & ((gctUINT32) ((((1 ? + 18:16) - (0 ? + 18:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 18:16) - (0 ? 18:16) + 1))))))) << (0 ? 18:16))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 22:20) - (0 ? + 22:20) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 22:20) - (0 ? + 22:20) + 1))))))) << (0 ? + 22:20))) | (((gctUINT32) ((gctUINT32) (0x4) & ((gctUINT32) ((((1 ? + 22:20) - (0 ? + 22:20) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 22:20) - (0 ? 22:20) + 1))))))) << (0 ? 22:20))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 26:24) - (0 ? + 26:24) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 26:24) - (0 ? + 26:24) + 1))))))) << (0 ? + 26:24))) | (((gctUINT32) ((gctUINT32) (0x4) & ((gctUINT32) ((((1 ? + 26:24) - (0 ? + 26:24) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 26:24) - (0 ? 26:24) + 1))))))) << (0 ? 26:24))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 30:28) - (0 ? + 30:28) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 30:28) - (0 ? + 30:28) + 1))))))) << (0 ? + 30:28))) | (((gctUINT32) ((gctUINT32) (0x4) & ((gctUINT32) ((((1 ? + 30:28) - (0 ? + 30:28) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 30:28) - (0 ? 30:28) + 1))))))) << (0 ? 30:28))), +#else | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 15:0) - (0 ? 15:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? - 15:0))) | (((gctUINT32) ((gctUINT32) (0x5580) & ((gctUINT32) ((((1 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0xD800 + 0x08) & ((gctUINT32) ((((1 ? 15:0) - (0 ? 15:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) @@ -10757,11 +5484,15 @@ _InitializePPU( ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? - 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (4) & ((gctUINT32) ((((1 ? 25:16) - (0 ? 25:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))), - 0x00000002, + 0xD8004380, 0x00000040, 0x00400040, 0x444051F0, +#endif + 0xFFFFFFFF, + +#if gcdINITIALIZE_PPU_C ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 31:27) - (0 ? @@ -10779,7 +5510,7 @@ _InitializePPU( ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? - 15:0))) | (((gctUINT32) ((gctUINT32) (0x0E02) & ((gctUINT32) ((((1 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0xD800 + 0x08) & ((gctUINT32) ((((1 ? 15:0) - (0 ? 15:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) @@ -10789,23 +5520,15 @@ _InitializePPU( ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? - 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (16) & ((gctUINT32) ((((1 ? 25:16) - (0 ? 25:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))), - 0x00000701, - - ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 31:27) - (0 ? - 31:27) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 31:27) - (0 ? - 31:27) + 1))))))) << (0 ? - 31:27))) | (((gctUINT32) (0x09 & ((gctUINT32) ((((1 ? - 31:27) - (0 ? - 31:27) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))), - 0x00000701, + 0x55555555, 0x00000000, // TCfg + 0x01234567, 0x89abcdef, 0x55555555, 0x01234567, 0x89abcdef, // BinSelect + 0x00000000, // AccumType, ConstantType, and PostShift + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // Constant + 0xFFFFFFFF, ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 31:27) - (0 ? @@ -10823,7 +5546,7 @@ _InitializePPU( ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? - 15:0))) | (((gctUINT32) ((gctUINT32) (0xD800) & ((gctUINT32) ((((1 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0240) & ((gctUINT32) ((((1 ? 15:0) - (0 ? 15:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) @@ -10833,12 +5556,41 @@ _InitializePPU( ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? - 25:16))) | (((gctUINT32) ((gctUINT32) (4) & ((gctUINT32) ((((1 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? 25:16) - (0 ? 25:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))), - 0xD8000340, 0x00000080, 0x00800080, 0x444051F0, 0xFFFFFFFF, - + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 1:0) - (0 ? + 1:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 1:0) - (0 ? + 1:0) + 1))))))) << (0 ? + 1:0))) | (((gctUINT32) ((gctUINT32) (workDim) & ((gctUINT32) ((((1 ? + 1:0) - (0 ? + 1:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 1:0) - (0 ? 1:0) + 1))))))) << (0 ? 1:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 6:4) - (0 ? + 6:4) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 6:4) - (0 ? + 6:4) + 1))))))) << (0 ? + 6:4))) | (((gctUINT32) (0x0 & ((gctUINT32) ((((1 ? + 6:4) - (0 ? + 6:4) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 6:4) - (0 ? 6:4) + 1))))))) << (0 ? 6:4))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 26:24) - (0 ? + 26:24) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 26:24) - (0 ? + 26:24) + 1))))))) << (0 ? + 26:24))) | (((gctUINT32) ((gctUINT32) (valueOrder) & ((gctUINT32) ((((1 ? + 26:24) - (0 ? + 26:24) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 26:24) - (0 ? 26:24) + 1))))))) << (0 ? 26:24))), +#else ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 31:27) - (0 ? 31:27) + 1) == 32) ? @@ -10855,7 +5607,7 @@ _InitializePPU( ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? - 15:0))) | (((gctUINT32) ((gctUINT32) (0xD800 + 0x08) & ((gctUINT32) ((((1 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0xD800 + 0x10) & ((gctUINT32) ((((1 ? 15:0) - (0 ? 15:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) @@ -10869,7 +5621,7 @@ _InitializePPU( 25:16) - (0 ? 25:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))), - 0xD8004380, 0x00000040, 0x00400040, 0x444051F0, 0xFFFFFFFF, + 0xD80053C0, 0x00000040, 0x00400040, 0x444051F0, 0xFFFFFFFF, ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 31:27) - (0 ? @@ -10887,7 +5639,7 @@ _InitializePPU( ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? - 15:0))) | (((gctUINT32) ((gctUINT32) (0xD800 + 0x10) & ((gctUINT32) ((((1 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0xD800 + 0x18) & ((gctUINT32) ((((1 ? 15:0) - (0 ? 15:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) @@ -10897,11 +5649,11 @@ _InitializePPU( ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? - 25:16))) | (((gctUINT32) ((gctUINT32) (4) & ((gctUINT32) ((((1 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? 25:16) - (0 ? 25:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))), - 0xD80053C0, 0x00000040, 0x00400040, 0x444051F0, 0xFFFFFFFF, + 0xD8000000, ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 31:27) - (0 ? @@ -10919,7 +5671,7 @@ _InitializePPU( ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? - 15:0))) | (((gctUINT32) ((gctUINT32) (0xD800 + 0x18) & ((gctUINT32) ((((1 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0xD800 + 0x19) & ((gctUINT32) ((((1 ? 15:0) - (0 ? 15:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) @@ -10933,7 +5685,7 @@ _InitializePPU( 25:16) - (0 ? 25:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))), - 0xD8000000, + 0xD8000040, ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 31:27) - (0 ? @@ -10951,7 +5703,7 @@ _InitializePPU( ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? - 15:0))) | (((gctUINT32) ((gctUINT32) (0xD800 + 0x19) & ((gctUINT32) ((((1 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0xD800 + 0x1C) & ((gctUINT32) ((((1 ? 15:0) - (0 ? 15:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) @@ -10961,11 +5713,11 @@ _InitializePPU( ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? - 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (8) & ((gctUINT32) ((((1 ? 25:16) - (0 ? 25:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))), - 0xD8000040, + 0xD8006400, 0x00000080, 0x00400040, 0x44405071, 0x00000003, 0x00002000, 0x00000000, 0x00000000, 0xFFFFFFFF, ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 31:27) - (0 ? @@ -10983,7 +5735,7 @@ _InitializePPU( ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? - 15:0))) | (((gctUINT32) ((gctUINT32) (0xD800 + 0x1C) & ((gctUINT32) ((((1 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0xD800 + 0x24) & ((gctUINT32) ((((1 ? 15:0) - (0 ? 15:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) @@ -10993,11 +5745,11 @@ _InitializePPU( ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? - 25:16))) | (((gctUINT32) ((gctUINT32) (8) & ((gctUINT32) ((((1 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (4) & ((gctUINT32) ((((1 ? 25:16) - (0 ? 25:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))), - 0xD8006400, 0x00000080, 0x00400040, 0x44405071, 0x00000003, 0x00002000, 0x00000000, 0x00000000, 0xFFFFFFFF, + 0x11111111, 0x00000000, 0x03020100, 0x07060504, 0xFFFFFFFF, ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 31:27) - (0 ? @@ -11015,7 +5767,7 @@ _InitializePPU( ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? - 15:0))) | (((gctUINT32) ((gctUINT32) (0xD800 + 0x24) & ((gctUINT32) ((((1 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0xD800 + 0x28) & ((gctUINT32) ((((1 ? 15:0) - (0 ? 15:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) @@ -11029,7 +5781,7 @@ _InitializePPU( 25:16) - (0 ? 25:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))), - 0x11111111, 0x00000000, 0x03020100, 0x07060504, 0xFFFFFFFF, + 0x22222222, 0x00000000, 0x00000000, 0x00000400, 0xFFFFFFFF, ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 31:27) - (0 ? @@ -11047,7 +5799,7 @@ _InitializePPU( ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? - 15:0))) | (((gctUINT32) ((gctUINT32) (0xD800 + 0x28) & ((gctUINT32) ((((1 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0xD800 + 0x2C) & ((gctUINT32) ((((1 ? 15:0) - (0 ? 15:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) @@ -11061,7 +5813,7 @@ _InitializePPU( 25:16) - (0 ? 25:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))), - 0x22222222, 0x00000000, 0x00000000, 0x00000400, 0xFFFFFFFF, + 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0xFFFFFFFF, ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 31:27) - (0 ? @@ -11079,7 +5831,7 @@ _InitializePPU( ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? - 15:0))) | (((gctUINT32) ((gctUINT32) (0xD800 + 0x2C) & ((gctUINT32) ((((1 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0xD800 + 0x30) & ((gctUINT32) ((((1 ? 15:0) - (0 ? 15:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) @@ -11094,7 +5846,7 @@ _InitializePPU( 25:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))), 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0xFFFFFFFF, - +#endif ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 31:27) - (0 ? 31:27) + 1) == 32) ? @@ -11111,7 +5863,7 @@ _InitializePPU( ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? - 15:0))) | (((gctUINT32) ((gctUINT32) (0xD800 + 0x30) & ((gctUINT32) ((((1 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x022C) & ((gctUINT32) ((((1 ? 15:0) - (0 ? 15:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) @@ -11121,12 +5873,66 @@ _InitializePPU( ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? - 25:16))) | (((gctUINT32) ((gctUINT32) (4) & ((gctUINT32) ((((1 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? 25:16) - (0 ? 25:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))), - 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0xFFFFFFFF, +#if gcdINITIALIZE_PPU_C + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 0:0) - (0 ? + 0:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 0:0) - (0 ? + 0:0) + 1))))))) << (0 ? + 0:0))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 0:0) - (0 ? + 0:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 0:0) - (0 ? 0:0) + 1))))))) << (0 ? 0:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 1:1) - (0 ? + 1:1) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 1:1) - (0 ? + 1:1) + 1))))))) << (0 ? + 1:1))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 1:1) - (0 ? + 1:1) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 1:1) - (0 ? 1:1) + 1))))))) << (0 ? 1:1))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 2:2) - (0 ? + 2:2) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 2:2) - (0 ? + 2:2) + 1))))))) << (0 ? + 2:2))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 2:2) - (0 ? + 2:2) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 2:2) - (0 ? 2:2) + 1))))))) << (0 ? 2:2))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 3:3) - (0 ? + 3:3) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 3:3) - (0 ? + 3:3) + 1))))))) << (0 ? + 3:3))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 3:3) - (0 ? + 3:3) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 3:3) - (0 ? 3:3) + 1))))))) << (0 ? 3:3))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 4:4) - (0 ? + 4:4) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 4:4) - (0 ? + 4:4) + 1))))))) << (0 ? + 4:4))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 4:4) - (0 ? + 4:4) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 4:4) - (0 ? 4:4) + 1))))))) << (0 ? 4:4))), +#else + 0x0000001F, +#endif +#if !gcdINITIALIZE_PPU_C ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 31:27) - (0 ? 31:27) + 1) == 32) ? @@ -11143,7 +5949,7 @@ _InitializePPU( ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? - 15:0))) | (((gctUINT32) ((gctUINT32) (0x022C) & ((gctUINT32) ((((1 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x02A4) & ((gctUINT32) ((((1 ? 15:0) - (0 ? 15:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) @@ -11157,8 +5963,9 @@ _InitializePPU( 25:16) - (0 ? 25:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))), - 0x0000001F, - + 0x00000000, +#endif +#if gcdINITIALIZE_PPU_C ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 31:27) - (0 ? 31:27) + 1) == 32) ? @@ -11175,7 +5982,7 @@ _InitializePPU( ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? - 15:0))) | (((gctUINT32) ((gctUINT32) (0x02A4) & ((gctUINT32) ((((1 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0420) & ((gctUINT32) ((((1 ? 15:0) - (0 ? 15:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) @@ -11189,8 +5996,17 @@ _InitializePPU( 25:16) - (0 ? 25:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))), - 0x00000000, - + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 2:0) - (0 ? + 2:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 2:0) - (0 ? + 2:0) + 1))))))) << (0 ? + 2:0))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 2:0) - (0 ? + 2:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 2:0) - (0 ? 2:0) + 1))))))) << (0 ? 2:0))), +#else ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 31:27) - (0 ? 31:27) + 1) == 32) ? @@ -11222,6 +6038,7 @@ _InitializePPU( 25:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))), 0x00000000, +#endif ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 31:27) - (0 ? @@ -11253,8 +6070,11 @@ _InitializePPU( 25:16) - (0 ? 25:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))), +#if gcdINITIALIZE_PPU_C + regCount, +#else 0x00000005, - +#endif ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 31:27) - (0 ? 31:27) + 1) == 32) ? @@ -11381,8 +6201,11 @@ _InitializePPU( 25:16) - (0 ? 25:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))), +#if gcdINITIALIZE_PPU_C + count/4, +#else 0x0000000F, - +#endif ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 31:27) - (0 ? 31:27) + 1) == 32) ? @@ -11413,7 +6236,11 @@ _InitializePPU( 25:16) - (0 ? 25:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))), +#if gcdINITIALIZE_PPU_C + Execution->funcCmd[0].data[2].address, +#else 0xD8000100, +#endif ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 31:27) - (0 ? @@ -11445,8 +6272,20 @@ _InitializePPU( 25:16) - (0 ? 25:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))), +#if gcdINITIALIZE_PPU_C + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 1:1) - (0 ? + 1:1) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 1:1) - (0 ? + 1:1) + 1))))))) << (0 ? + 1:1))) | (((gctUINT32) ((gctUINT32) (0x1) & ((gctUINT32) ((((1 ? + 1:1) - (0 ? + 1:1) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 1:1) - (0 ? 1:1) + 1))))))) << (0 ? 1:1))), +#else 0x00000002, - +#endif ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 31:27) - (0 ? 31:27) + 1) == 32) ? @@ -11477,8 +6316,20 @@ _InitializePPU( 25:16) - (0 ? 25:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))), +#if gcdINITIALIZE_PPU_C + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 0:0) - (0 ? + 0:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 0:0) - (0 ? + 0:0) + 1))))))) << (0 ? + 0:0))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 0:0) - (0 ? + 0:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 0:0) - (0 ? 0:0) + 1))))))) << (0 ? 0:0))), +#else 0x00000001, - +#endif ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 31:27) - (0 ? 31:27) + 1) == 32) ? @@ -11509,7 +6360,11 @@ _InitializePPU( 25:16) - (0 ? 25:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))), +#if gcdINITIALIZE_PPU_C + count/4 - 1, +#else 0x0000000E, +#endif ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 31:27) - (0 ? @@ -11531,6 +6386,38 @@ _InitializePPU( 15:0) - (0 ? 15:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) +#if gcdINITIALIZE_PPU_C + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))), + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 5:0) - (0 ? + 5:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 5:0) - (0 ? + 5:0) + 1))))))) << (0 ? + 5:0))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 5:0) - (0 ? + 5:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 5:0) - (0 ? 5:0) + 1))))))) << (0 ? 5:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 12:8) - (0 ? + 12:8) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 12:8) - (0 ? + 12:8) + 1))))))) << (0 ? + 12:8))) | (((gctUINT32) ((gctUINT32) (~0) & ((gctUINT32) ((((1 ? + 12:8) - (0 ? + 12:8) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 12:8) - (0 ? 12:8) + 1))))))) << (0 ? 12:8))), +#else | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 25:16) - (0 ? 25:16) + 1) == 32) ? @@ -11542,7 +6429,7 @@ _InitializePPU( 25:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))), 0x00001F01, 0x00000005, 0x00000F00, - +#endif ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 31:27) - (0 ? 31:27) + 1) == 32) ? @@ -11607,6 +6494,7 @@ _InitializePPU( ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))), 0x00000000, +#if !gcdINITIALIZE_PPU_C ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 31:27) - (0 ? 31:27) + 1) == 32) ? @@ -11638,7 +6526,7 @@ _InitializePPU( 25:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))), 0x00000100, - +#endif ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 31:27) - (0 ? 31:27) + 1) == 32) ? @@ -11702,7 +6590,7 @@ _InitializePPU( 25:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))), 0x00000000, - +#if !gcdINITIALIZE_PPU_C ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 31:27) - (0 ? 31:27) + 1) == 32) ? @@ -11734,7 +6622,7 @@ _InitializePPU( 25:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))), 0x0F3F0000, - +#endif ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 31:27) - (0 ? 31:27) + 1) == 32) ? @@ -11765,8 +6653,20 @@ _InitializePPU( 25:16) - (0 ? 25:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))), +#if gcdINITIALIZE_PPU_C + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 5:0) - (0 ? + 5:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 5:0) - (0 ? + 5:0) + 1))))))) << (0 ? + 5:0))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 5:0) - (0 ? + 5:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 5:0) - (0 ? 5:0) + 1))))))) << (0 ? 5:0))), +#else 0x00000001, - +#endif ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 31:27) - (0 ? 31:27) + 1) == 32) ? @@ -11861,7 +6761,40 @@ _InitializePPU( 25:16) - (0 ? 25:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))), +#if gcdINITIALIZE_PPU_C + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 1:0) - (0 ? + 1:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 1:0) - (0 ? + 1:0) + 1))))))) << (0 ? + 1:0))) | (((gctUINT32) ((gctUINT32) (0x2) & ((gctUINT32) ((((1 ? + 1:0) - (0 ? + 1:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 1:0) - (0 ? 1:0) + 1))))))) << (0 ? 1:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 6:4) - (0 ? + 6:4) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 6:4) - (0 ? + 6:4) + 1))))))) << (0 ? + 6:4))) | (((gctUINT32) (0x0 & ((gctUINT32) ((((1 ? + 6:4) - (0 ? + 6:4) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 6:4) - (0 ? 6:4) + 1))))))) << (0 ? 6:4))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 26:24) - (0 ? + 26:24) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 26:24) - (0 ? + 26:24) + 1))))))) << (0 ? + 26:24))) | (((gctUINT32) ((gctUINT32) (0x3) & ((gctUINT32) ((((1 ? + 26:24) - (0 ? + 26:24) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 26:24) - (0 ? 26:24) + 1))))))) << (0 ? 26:24))), +#else 0x03000002, +#endif ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 31:27) - (0 ? @@ -11925,7 +6858,11 @@ _InitializePPU( 25:16) - (0 ? 25:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))), +#if gcdINITIALIZE_PPU_C + threadAllocation, +#else 0x00000001, +#endif ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 31:27) - (0 ? @@ -11957,7 +6894,11 @@ _InitializePPU( 25:16) - (0 ? 25:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))), +#if gcdINITIALIZE_PPU_C + globaloffsetX, +#else 0x00000000, +#endif ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 31:27) - (0 ? @@ -11989,7 +6930,11 @@ _InitializePPU( 25:16) - (0 ? 25:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))), +#if gcdINITIALIZE_PPU_C + globaloffsetY, +#else 0x00000000, +#endif ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 31:27) - (0 ? @@ -12021,7 +6966,11 @@ _InitializePPU( 25:16) - (0 ? 25:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))), +#if gcdINITIALIZE_PPU_C + globaloffsetZ, +#else 0x00000000, +#endif ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 31:27) - (0 ? @@ -12053,8 +7002,11 @@ _InitializePPU( 25:16) - (0 ? 25:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))), +#if gcdINITIALIZE_PPU_C + globalscaleX, +#else 0x00000008, - +#endif ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 31:27) - (0 ? 31:27) + 1) == 32) ? @@ -12085,7 +7037,11 @@ _InitializePPU( 25:16) - (0 ? 25:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))), +#if gcdINITIALIZE_PPU_C + globalscaleY, +#else 0x00000001, +#endif ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 31:27) - (0 ? @@ -12117,7 +7073,11 @@ _InitializePPU( 25:16) - (0 ? 25:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))), +#if gcdINITIALIZE_PPU_C + globalscaleZ, +#else 0x00000000, +#endif ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 31:27) - (0 ? @@ -12149,7 +7109,42 @@ _InitializePPU( 25:16) - (0 ? 25:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))), - 0x00000000, 0x0000003F, 0xFFFFFFFF, 0x00000007, 0x00000000, 0x000003FF, 0x00000000, +#if gcdINITIALIZE_PPU_C + groupcountX - 1, groupcountY - 1, groupcountZ - 1, + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 9:0) - (0 ? + 9:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 9:0) - (0 ? + 9:0) + 1))))))) << (0 ? + 9:0))) | (((gctUINT32) ((gctUINT32) (groupsizeX - 1) & ((gctUINT32) ((((1 ? + 9:0) - (0 ? + 9:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 9:0) - (0 ? 9:0) + 1))))))) << (0 ? 9:0))), + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 9:0) - (0 ? + 9:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 9:0) - (0 ? + 9:0) + 1))))))) << (0 ? + 9:0))) | (((gctUINT32) ((gctUINT32) (groupsizeY - 1) & ((gctUINT32) ((((1 ? + 9:0) - (0 ? + 9:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 9:0) - (0 ? 9:0) + 1))))))) << (0 ? 9:0))), + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 9:0) - (0 ? + 9:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 9:0) - (0 ? + 9:0) + 1))))))) << (0 ? + 9:0))) | (((gctUINT32) ((gctUINT32) (groupsizeZ - 1) & ((gctUINT32) ((((1 ? + 9:0) - (0 ? + 9:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 9:0) - (0 ? 9:0) + 1))))))) << (0 ? 9:0))), +#else + 0x00000000, 0x0000003F, 0xFFFFFFFF, 0x00000007, 0x00000000, 0x000003FF, +#endif + 0x00000000, ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 31:27) - (0 ? @@ -12213,7 +7208,40 @@ _InitializePPU( 25:16) - (0 ? 25:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))), +#if gcdINITIALIZE_PPU_C + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 5:5) - (0 ? + 5:5) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 5:5) - (0 ? + 5:5) + 1))))))) << (0 ? + 5:5))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 5:5) - (0 ? + 5:5) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 5:5) - (0 ? 5:5) + 1))))))) << (0 ? 5:5))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 10:10) - (0 ? + 10:10) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 10:10) - (0 ? + 10:10) + 1))))))) << (0 ? + 10:10))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 10:10) - (0 ? + 10:10) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 10:10) - (0 ? 10:10) + 1))))))) << (0 ? 10:10))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 11:11) - (0 ? + 11:11) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 11:11) - (0 ? + 11:11) + 1))))))) << (0 ? + 11:11))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 11:11) - (0 ? + 11:11) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 11:11) - (0 ? 11:11) + 1))))))) << (0 ? 11:11))), +#else 0x00000C20, +#endif ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 31:27) - (0 ? @@ -12245,7 +7273,30 @@ _InitializePPU( 25:16) - (0 ? 25:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))), +#if gcdINITIALIZE_PPU_C + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 4:0) - (0 ? + 4:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 4:0) - (0 ? + 4:0) + 1))))))) << (0 ? + 4:0))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 4:0) - (0 ? + 4:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 4:0) - (0 ? 4:0) + 1))))))) << (0 ? 4:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 12:8) - (0 ? + 12:8) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 12:8) - (0 ? + 12:8) + 1))))))) << (0 ? + 12:8))) | (((gctUINT32) (0x07 & ((gctUINT32) ((((1 ? + 12:8) - (0 ? + 12:8) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 12:8) - (0 ? 12:8) + 1))))))) << (0 ? 12:8))), +#else 0x00000701, +#endif ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 31:27) - (0 ? @@ -12257,7 +7308,30 @@ _InitializePPU( 31:27) - (0 ? 31:27) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))), +#if gcdINITIALIZE_PPU_C + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 4:0) - (0 ? + 4:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 4:0) - (0 ? + 4:0) + 1))))))) << (0 ? + 4:0))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 4:0) - (0 ? + 4:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 4:0) - (0 ? 4:0) + 1))))))) << (0 ? 4:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 12:8) - (0 ? + 12:8) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 12:8) - (0 ? + 12:8) + 1))))))) << (0 ? + 12:8))) | (((gctUINT32) (0x07 & ((gctUINT32) ((((1 ? + 12:8) - (0 ? + 12:8) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 12:8) - (0 ? 12:8) + 1))))))) << (0 ? 12:8))), +#else 0x00000701, +#endif ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 31:27) - (0 ? @@ -12289,8 +7363,60 @@ _InitializePPU( 25:16) - (0 ? 25:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))), +#if gcdINITIALIZE_PPU_C + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 0:0) - (0 ? + 0:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 0:0) - (0 ? + 0:0) + 1))))))) << (0 ? + 0:0))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 0:0) - (0 ? + 0:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 0:0) - (0 ? 0:0) + 1))))))) << (0 ? 0:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 1:1) - (0 ? + 1:1) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 1:1) - (0 ? + 1:1) + 1))))))) << (0 ? + 1:1))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 1:1) - (0 ? + 1:1) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 1:1) - (0 ? 1:1) + 1))))))) << (0 ? 1:1))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 5:5) - (0 ? + 5:5) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 5:5) - (0 ? + 5:5) + 1))))))) << (0 ? + 5:5))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 5:5) - (0 ? + 5:5) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 5:5) - (0 ? 5:5) + 1))))))) << (0 ? 5:5))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 10:10) - (0 ? + 10:10) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 10:10) - (0 ? + 10:10) + 1))))))) << (0 ? + 10:10))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 10:10) - (0 ? + 10:10) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 10:10) - (0 ? 10:10) + 1))))))) << (0 ? 10:10))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 11:11) - (0 ? + 11:11) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 11:11) - (0 ? + 11:11) + 1))))))) << (0 ? + 11:11))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 11:11) - (0 ? + 11:11) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 11:11) - (0 ? 11:11) + 1))))))) << (0 ? 11:11))), +#else 0x00000C23, - +#endif ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 31:27) - (0 ? 31:27) + 1) == 32) ? @@ -12321,7 +7447,60 @@ _InitializePPU( 25:16) - (0 ? 25:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))), +#if gcdINITIALIZE_PPU_C + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 0:0) - (0 ? + 0:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 0:0) - (0 ? + 0:0) + 1))))))) << (0 ? + 0:0))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 0:0) - (0 ? + 0:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 0:0) - (0 ? 0:0) + 1))))))) << (0 ? 0:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 1:1) - (0 ? + 1:1) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 1:1) - (0 ? + 1:1) + 1))))))) << (0 ? + 1:1))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 1:1) - (0 ? + 1:1) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 1:1) - (0 ? 1:1) + 1))))))) << (0 ? 1:1))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 5:5) - (0 ? + 5:5) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 5:5) - (0 ? + 5:5) + 1))))))) << (0 ? + 5:5))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 5:5) - (0 ? + 5:5) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 5:5) - (0 ? 5:5) + 1))))))) << (0 ? 5:5))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 10:10) - (0 ? + 10:10) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 10:10) - (0 ? + 10:10) + 1))))))) << (0 ? + 10:10))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 10:10) - (0 ? + 10:10) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 10:10) - (0 ? 10:10) + 1))))))) << (0 ? 10:10))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 11:11) - (0 ? + 11:11) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 11:11) - (0 ? + 11:11) + 1))))))) << (0 ? + 11:11))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 11:11) - (0 ? + 11:11) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 11:11) - (0 ? 11:11) + 1))))))) << (0 ? 11:11))), +#else 0x00000C23, +#endif ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 31:27) - (0 ? @@ -12353,7 +7532,20 @@ _InitializePPU( 25:16) - (0 ? 25:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))), +#if gcdINITIALIZE_PPU_C + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 0:0) - (0 ? + 0:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 0:0) - (0 ? + 0:0) + 1))))))) << (0 ? + 0:0))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 0:0) - (0 ? + 0:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 0:0) - (0 ? 0:0) + 1))))))) << (0 ? 0:0))), +#else 0x00000001, +#endif ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 31:27) - (0 ? @@ -12385,8 +7577,62 @@ _InitializePPU( 25:16) - (0 ? 25:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))), +#if gcdINITIALIZE_PPU_C + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 0:0) - (0 ? + 0:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 0:0) - (0 ? + 0:0) + 1))))))) << (0 ? + 0:0))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 0:0) - (0 ? + 0:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 0:0) - (0 ? 0:0) + 1))))))) << (0 ? 0:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 1:1) - (0 ? + 1:1) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 1:1) - (0 ? + 1:1) + 1))))))) << (0 ? + 1:1))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 1:1) - (0 ? + 1:1) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 1:1) - (0 ? 1:1) + 1))))))) << (0 ? 1:1))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 5:5) - (0 ? + 5:5) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 5:5) - (0 ? + 5:5) + 1))))))) << (0 ? + 5:5))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 5:5) - (0 ? + 5:5) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 5:5) - (0 ? 5:5) + 1))))))) << (0 ? 5:5))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 10:10) - (0 ? + 10:10) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 10:10) - (0 ? + 10:10) + 1))))))) << (0 ? + 10:10))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 10:10) - (0 ? + 10:10) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 10:10) - (0 ? 10:10) + 1))))))) << (0 ? 10:10))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 11:11) - (0 ? + 11:11) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 11:11) - (0 ? + 11:11) + 1))))))) << (0 ? + 11:11))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 11:11) - (0 ? + 11:11) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 11:11) - (0 ? 11:11) + 1))))))) << (0 ? 11:11))), +#else 0x00000C23, +#endif +#if !gcdINITIALIZE_PPU_C ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 31:27) - (0 ? 31:27) + 1) == 32) ? @@ -12417,7 +7663,20 @@ _InitializePPU( 25:16) - (0 ? 25:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))), +#if gcdINITIALIZE_PPU_C + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 1:0) - (0 ? + 1:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 1:0) - (0 ? + 1:0) + 1))))))) << (0 ? + 1:0))) | (((gctUINT32) (0x0 & ((gctUINT32) ((((1 ? + 1:0) - (0 ? + 1:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 1:0) - (0 ? 1:0) + 1))))))) << (0 ? 1:0))), +#else 0x00000000, +#endif ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 31:27) - (0 ? @@ -12430,8 +7689,16 @@ _InitializePPU( 31:27) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))), 0x00000000, +#endif }; +#if gcdINITIALIZE_PPU_C + + + *Bytes = gcmSIZEOF(flushCommands); + gckOS_MemCopy(logical, flushCommands, *Bytes); + } +#else *Bytes = gcmSIZEOF(flushCommands) - 8; /* Patch the command. */ if (logical) @@ -12439,7 +7706,7 @@ _InitializePPU( gckOS_MemCopy(logical, flushCommands, *Bytes); status = _PatchPPUBuffer(Execution); } - +#endif return status; } @@ -12455,86 +7722,514 @@ _FuncInit_PPU(IN gcsFUNCTION_EXECUTION_PTR Execution) gcePOOL pool; gctUINT8_PTR logical; gckHARDWARE hardware = (gckHARDWARE)Execution->hardware; + gctPOINTER pointer = gcvNULL; pool = gcvPOOL_DEFAULT; #if gcdENABLE_CACHEABLE_COMMAND_BUFFER allocFlag = gcvALLOC_FLAG_CACHEABLE; #endif - Execution->funcVidMemBytes = 1024; + Execution->funcCmdCount = 1; + + /* Allocate the gcsFUNCTION_COMMAND buffer */ + gcmkONERROR(gckOS_Allocate(hardware->os, + gcmSIZEOF(gcsFUNCTION_COMMAND) * Execution->funcCmdCount, + (gctPOINTER *)&pointer)); + + gckOS_ZeroMemory((gctPOINTER)pointer, gcmSIZEOF(gcsFUNCTION_COMMAND) * Execution->funcCmdCount); + + Execution->funcCmd = (gcsFUNCTION_COMMAND_PTR)pointer; + + Execution->funcCmd[0].funcVidMemBytes = 1024; /* Allocate video memory node for aux functions. */ gcmkONERROR(gckKERNEL_AllocateVideoMemory( hardware->kernel, 64, gcvVIDMEM_TYPE_COMMAND, allocFlag, - &Execution->funcVidMemBytes, + &Execution->funcCmd[0].funcVidMemBytes, &pool, - &Execution->funcVidMem + &Execution->funcCmd[0].funcVidMem )); /* Lock for GPU access. */ gcmkONERROR(gckVIDMEM_NODE_Lock( hardware->kernel, - Execution->funcVidMem, - &Execution->address + Execution->funcCmd[0].funcVidMem, + &Execution->funcCmd[0].address )); /* Lock for kernel side CPU access. */ gcmkONERROR(gckVIDMEM_NODE_LockCPU( hardware->kernel, - Execution->funcVidMem, + Execution->funcCmd[0].funcVidMem, gcvFALSE, gcvFALSE, - &Execution->logical + &Execution->funcCmd[0].logical )); /* ** All cache flush command sequence. */ - logical = (gctUINT8_PTR)Execution->logical; - address = Execution->address; + logical = (gctUINT8_PTR)Execution->funcCmd[0].logical; + address = Execution->funcCmd[0].address; /* Append a flush. */ gcmkONERROR(_InitializePPU(Execution, &ppuBytes)); - offset += ppuBytes; - logical += offset; - address += offset; + offset += ppuBytes; + logical += offset; + address += offset; + + if (hardware->wlFE) + { + gcmkONERROR(gckWLFE_End(hardware, gcvNULL, ~0U, &endBytes)); + gcmkONERROR(gckWLFE_End(hardware, logical, address, &endBytes)); + } + + Execution->funcCmd[0].bytes = ppuBytes + endBytes; + Execution->funcCmd[0].endAddress = Execution->funcCmd[0].address + ppuBytes; + Execution->funcCmd[0].endLogical = (gctUINT8_PTR)Execution->funcCmd[0].logical + ppuBytes; + + return gcvSTATUS_OK; +OnError: + _FuncRelease_PPU(Execution); + + return status; +} + +static gceSTATUS +_FuncValidate_PPU_0xA0(IN gcsFUNCTION_EXECUTION_PTR Execution) +{ +#ifdef EMULATOR + Execution->valid = gcvFALSE; +#else + gckHARDWARE hardware = (gckHARDWARE)Execution->hardware; + + Execution->valid = gcvFALSE; + if (!gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_EVIS2_FLOP_RESET_FIX)) + { + if (hardware->identity.customerID == 0xA0) + { + Execution->valid = gcvTRUE; + } + } +#endif + + return gcvSTATUS_OK; +} + +static gceSTATUS +_FuncRelease_PPU_0xA0(IN gcsFUNCTION_EXECUTION_PTR Execution) +{ + gckHARDWARE hardware = (gckHARDWARE)Execution->hardware; + gctUINT32 i, j; + + if (Execution->funcCmd) + { + for (j = 0; j < Execution->funcCmdCount; j++) + { + if (Execution->funcCmd[j].data) + { + for (i = 0; i < 7; i++) + { + if (Execution->funcCmd[j].data[i].bufVidMem) + { + if (Execution->funcCmd[j].data[i].logical) + { + gckVIDMEM_NODE_UnlockCPU( + hardware->kernel, + Execution->funcCmd[j].data[i].bufVidMem, + 0, + gcvFALSE, + gcvFALSE + ); + Execution->funcCmd[j].data[i].logical = gcvNULL; + } + if (Execution->funcCmd[j].data[i].address) + { + gckVIDMEM_NODE_Unlock( + hardware->kernel, + Execution->funcCmd[j].data[i].bufVidMem, + 0, + gcvNULL + ); + Execution->funcCmd[j].data[i].address = 0; + } + + gckVIDMEM_NODE_Dereference( + hardware->kernel, + Execution->funcCmd[j].data[i].bufVidMem + ); + } + } + + gcmkVERIFY_OK(gckOS_Free(hardware->os, Execution->funcCmd[j].data)); + Execution->funcCmd[j].data = gcvNULL; + } + + if (Execution->funcCmd[j].funcVidMem) + { + if (Execution->funcCmd[j].address) + { + /* Synchroneous unlock. */ + gcmkVERIFY_OK(gckVIDMEM_NODE_Unlock( + hardware->kernel, + Execution->funcCmd[j].funcVidMem, + 0, + gcvNULL + )); + Execution->funcCmd[j].address = 0; + } + + if (Execution->funcCmd[j].logical) + { + gcmkVERIFY_OK(gckVIDMEM_NODE_UnlockCPU( + hardware->kernel, + Execution->funcCmd[j].funcVidMem, + 0, + gcvFALSE, + gcvFALSE + )); + Execution->funcCmd[j].logical = gcvNULL; + } + + gcmkVERIFY_OK(gckVIDMEM_NODE_Dereference( + hardware->kernel, + Execution->funcCmd[j].funcVidMem + )); + + Execution->funcCmd[j].funcVidMem = gcvNULL; + } + } + gcmkVERIFY_OK(gckOS_Free(hardware->os, (gctPOINTER)Execution->funcCmd)); + } + + return gcvSTATUS_OK; +} + +gceSTATUS +_PatchPPUBuffer_0xA0( + IN gctPOINTER Hardware, + IN gcsFUNCTION_COMMAND *funcCmd + ) +{ + gceSTATUS status = gcvSTATUS_OK; + gcePOOL pool = gcvPOOL_DEFAULT; + gctUINT32_PTR command = (gctUINT32_PTR)funcCmd->logical; + gctUINT32 commandPatchOffsets[7]; + gctUINT32_PTR patchBuffers[7]; + gctSIZE_T patchBufferSizes[7]; + gctUINT32 i; + gctUINT32 allocFlag = 0; + gckHARDWARE hardware = (gckHARDWARE)Hardware; + gctPOINTER pointer = gcvNULL; + +#if gcdENABLE_CACHEABLE_COMMAND_BUFFER + allocFlag = gcvALLOC_FLAG_CACHEABLE; +#endif + + patchBuffers[0] = gcvNULL; + patchBuffers[1] = ppuMem0_0xA0; + patchBuffers[2] = gcvNULL; + patchBuffers[3] = ppuMem1_0xA0; + patchBuffers[4] = ppuMem2_0xA0; + patchBuffers[5] = gcvNULL; + patchBuffers[6] = ppuMem3_0xA0; + + patchBufferSizes[0] = 32*1024; + patchBufferSizes[1] = gcmSIZEOF(ppuMem0_0xA0);; + patchBufferSizes[2] = 32*1024; + patchBufferSizes[3] = gcmSIZEOF(ppuMem1_0xA0); + patchBufferSizes[4] = gcmSIZEOF(ppuMem2_0xA0); + patchBufferSizes[5] = 32*1024; + patchBufferSizes[6] = gcmSIZEOF(ppuMem3_0xA0); + + commandPatchOffsets[0] = 7; + commandPatchOffsets[1] = 19; + commandPatchOffsets[2] = 31; + commandPatchOffsets[3] = 43; + commandPatchOffsets[4] = 45; + commandPatchOffsets[5] = 47; + commandPatchOffsets[6] = 97; + + gcmkONERROR(gckOS_Allocate(hardware->os, + gcmSIZEOF(gcsFUNCTION_EXECUTION_DATA) * 7, + &pointer)); + + gckOS_ZeroMemory(pointer, gcmSIZEOF(gcsFUNCTION_EXECUTION_DATA) * 7); + + funcCmd->data = (gcsFUNCTION_EXECUTION_DATA_PTR)pointer; + + for (i = 0; i < 7; i++) + { + /* Allocate memory for buffers. */ + gcmkONERROR(gckKERNEL_AllocateVideoMemory( + hardware->kernel, + 64, + gcvVIDMEM_TYPE_BITMAP, + allocFlag, + &patchBufferSizes[i], + &pool, + &funcCmd->data[i].bufVidMem + )); + + gcmkONERROR(gckVIDMEM_NODE_LockCPU( + hardware->kernel, + funcCmd->data[i].bufVidMem, + gcvFALSE, + gcvFALSE, + &funcCmd->data[i].logical + )); + + gcmkONERROR(gckVIDMEM_NODE_Lock( + hardware->kernel, + funcCmd->data[i].bufVidMem, + &funcCmd->data[i].address + )); + + gckOS_ZeroMemory(funcCmd->data[i].logical, patchBufferSizes[i]); + + if (patchBuffers[i]) + { + gckOS_MemCopy(funcCmd->data[i].logical, patchBuffers[i], patchBufferSizes[i]); + } + /* patch the buffer */ + command[commandPatchOffsets[i]] = funcCmd->data[i].address; + } + + return status; +OnError: + if (funcCmd->data) + { + for (i = 0; i < 7; i++) + { + if (funcCmd->data[i].bufVidMem) + { + if (funcCmd->data[i].logical) + { + gckVIDMEM_NODE_UnlockCPU( + hardware->kernel, + funcCmd->data[i].bufVidMem, + 0, + gcvFALSE, + gcvFALSE + ); + funcCmd->data[i].logical = gcvNULL; + } + if (funcCmd->data[i].address) + { + gckVIDMEM_NODE_Unlock( + hardware->kernel, + funcCmd->data[i].bufVidMem, + 0, + gcvNULL + ); + funcCmd->data[i].address = 0; + } + + gckVIDMEM_NODE_Dereference( + hardware->kernel, + funcCmd->data[i].bufVidMem + ); + } + } + + gcmkVERIFY_OK(gckOS_Free(hardware->os, funcCmd->data)); + funcCmd->data = gcvNULL; + } + + return status; +} + +gceSTATUS +_InitializePPU_0xA0( + IN gcsFUNCTION_EXECUTION_PTR Execution, + IN gctUINT32 Index, + IN OUT gctUINT32 * Bytes + ) +{ + gceSTATUS status = gcvSTATUS_OK; + gctPOINTER logical = Execution->funcCmd[Index].logical; + + switch(Index) + { + case 0: + *Bytes = gcmSIZEOF(ppuCmd0_0xA0); + if (logical) + { + gckOS_MemCopy(logical, ppuCmd0_0xA0, *Bytes); + } + break; + case 1: + *Bytes = gcmSIZEOF(ppuCmd1_0xA0); + if (logical) + { + gckOS_MemCopy(logical, ppuCmd1_0xA0, *Bytes); + } + break; + case 2: + *Bytes = gcmSIZEOF(ppuCmd2_0xA0); + if (logical) + { + gckOS_MemCopy(logical, ppuCmd2_0xA0, *Bytes); + status = _PatchPPUBuffer_0xA0(Execution->hardware, &Execution->funcCmd[2]); + } + break; + case 3: + *Bytes = gcmSIZEOF(ppuCmd3_0xA0); + if (logical) + { + gckOS_MemCopy(logical, ppuCmd3_0xA0, *Bytes); + } + break; + default: + return gcvSTATUS_INVALID_ARGUMENT; + break; + } + + *Bytes = *Bytes - 8; + return status; +} + +static gceSTATUS +_FuncInit_PPU_0xA0(IN gcsFUNCTION_EXECUTION_PTR Execution) +{ + gceSTATUS status = gcvSTATUS_OK; + gctUINT32 ppuBytes = 0; + gctUINT32 endBytes = 0; + gctUINT32 address; + gctUINT32 i, allocFlag = 0; + gcePOOL pool; + gctUINT8_PTR logical; + gckHARDWARE hardware = (gckHARDWARE)Execution->hardware; + gctPOINTER pointer = gcvNULL; + + pool = gcvPOOL_DEFAULT; + +#if gcdENABLE_CACHEABLE_COMMAND_BUFFER + allocFlag = gcvALLOC_FLAG_CACHEABLE; +#endif + Execution->funcCmdCount = 4; + + /* Allocate the gcsFUNCTION_COMMAND buffer */ + gcmkONERROR(gckOS_Allocate(hardware->os, + gcmSIZEOF(gcsFUNCTION_COMMAND) * Execution->funcCmdCount, + (gctPOINTER *)&pointer)); + + gckOS_ZeroMemory((gctPOINTER)pointer, gcmSIZEOF(gcsFUNCTION_COMMAND) * Execution->funcCmdCount); + + Execution->funcCmd = (gcsFUNCTION_COMMAND_PTR)pointer; + + for (i = 0; i < Execution->funcCmdCount; i++) + { + Execution->funcCmd[i].funcVidMemBytes = 1024; + /* Allocate video memory node for aux functions. */ + gcmkONERROR(gckKERNEL_AllocateVideoMemory( + hardware->kernel, + 64, + gcvVIDMEM_TYPE_COMMAND, + allocFlag, + &Execution->funcCmd[i].funcVidMemBytes, + &pool, + &Execution->funcCmd[i].funcVidMem + )); + + /* Lock for GPU access. */ + gcmkONERROR(gckVIDMEM_NODE_Lock( + hardware->kernel, + Execution->funcCmd[i].funcVidMem, + &Execution->funcCmd[i].address + )); - if (hardware->wlFE) - { - gcmkONERROR(gckWLFE_End(hardware, gcvNULL, ~0U, &endBytes)); - gcmkONERROR(gckWLFE_End(hardware, logical, address, &endBytes)); - } + /* Lock for kernel side CPU access. */ + gcmkONERROR(gckVIDMEM_NODE_LockCPU( + hardware->kernel, + Execution->funcCmd[i].funcVidMem, + gcvFALSE, + gcvFALSE, + &Execution->funcCmd[i].logical + )); + /* + ** All cache flush command sequence. + */ + logical = (gctUINT8_PTR)Execution->funcCmd[i].logical; + address = Execution->funcCmd[i].address; + + /* Append a flush. */ + gcmkONERROR(_InitializePPU_0xA0(Execution, i, &ppuBytes)); + + logical += ppuBytes; + address += ppuBytes; - Execution->bytes = ppuBytes + endBytes; - Execution->endAddress = Execution->address + ppuBytes; - Execution->endLogical = (gctUINT8_PTR)Execution->logical + ppuBytes; + if (hardware->wlFE) + { + gcmkONERROR(gckWLFE_End(hardware, gcvNULL, ~0U, &endBytes)); + gcmkONERROR(gckWLFE_End(hardware, logical, address, &endBytes)); + } + + Execution->funcCmd[i].bytes = ppuBytes + endBytes; + Execution->funcCmd[i].endAddress = Execution->funcCmd[i].address + ppuBytes; + Execution->funcCmd[i].endLogical = (gctUINT8_PTR)Execution->funcCmd[i].logical + ppuBytes; + } return gcvSTATUS_OK; OnError: - _FuncRelease_PPU(Execution); + _FuncRelease_PPU_0xA0(Execution); return status; } + #endif -#if gcdRESET_USC +#if gcdRESET_USC1 gceSTATUS _InitializeUSC( IN gcsFUNCTION_EXECUTION_PTR Execution, IN OUT gctUINT32 * Bytes ) { - gctUINT32 i, idx = 0; + gctUINT32 i; gcePOOL pool = gcvPOOL_DEFAULT; - gctUINT32 flushCommands[128] = {0}; + gctUINT32_PTR flushCommands = gcvNULL; gctUINT32_PTR nnCommands = gcvNULL; - gctSIZE_T patchBufferSizes[4]; + gctSIZE_T patchBufferSizes[5]; gceSTATUS status = gcvSTATUS_OK; gckHARDWARE hardware = (gckHARDWARE)Execution->hardware; - gctUINT8_PTR logical = (gctUINT8_PTR)Execution->logical; + gctUINT8_PTR logical = (gctUINT8_PTR)Execution->funcCmd[0].logical; gctPOINTER pointer = gcvNULL; +#if gcdRESET_USC_C + gcsFEATURE_DATABASE * db = (gcsFEATURE_DATABASE *)(hardware->featureDatabase); + gctUINT32 sram_size = db->AXI_SRAM_SIZE + db->VIP_SRAM_SIZE; + USC_NN_TYPE hw_type = (db->NN_XYDP0) ? USC_NN_TYPE_V8 : + ( + (db->VIP_V7)?USC_NN_TYPE_V7:USC_NN_TYPE_V6 + ); + + gctUINT32 item_size = 2, core_count = 0; + gctUINT8 data_type = 0; + gctUINT32 filterSize = 0, biasSize = 4, filterTotalCount = 1, zdp = (db->NN_ZDP3)?3:1, size = 64; + + gcmkONERROR(_InitializeUSC_NNCommands(hardware, hw_type, 0, 0, 0, &data_type, &item_size, &core_count, &patchBufferSizes[NN_BUFFER_IDX], &nnCommands)); + + filterSize = 2 * 2 * 1 * item_size; + size = gcmALIGN_NP2(((filterSize + biasSize + 3) * filterTotalCount + 3), 64); + + patchBufferSizes[INPUT_BUFFER_IDX] = gcmALIGN_NP2(3 * 2 * item_size, 64); + patchBufferSizes[RESULT_BUFFER_IDX] = gcmALIGN_NP2(2 * 1 * item_size, 64); + + /*v8*/ + if (hw_type == USC_NN_TYPE_V8) + /*head(align to 64) + body(align to 64) + tail(align to 64)*/ + patchBufferSizes[KERNEL_BUFFER_IDX] = 64 + gcmALIGN_NP2((gcmALIGN_NP2(filterSize, zdp * 3) * (zdp * 3) * filterTotalCount) + (1 * (16 / item_size)), 64) + 64; + else + /*head(align to 64) + body(align to 64)*/ + patchBufferSizes[KERNEL_BUFFER_IDX] = size + 64; + + patchBufferSizes[SRAM_BUFFER_IDX_C] = (sram_size > 0) ? sram_size : (128 * 1024); + +#else + gctUINT32 idx = 0; + if (hardware->identity.customerID == 0x86) { patchBufferSizes[NN_BUFFER_IDX] = gcmSIZEOF(nnBuffer0); @@ -12550,6 +8245,11 @@ _InitializeUSC( patchBufferSizes[NN_BUFFER_IDX] = gcmSIZEOF(nnBuffer2); nnCommands = nnBuffer2; } + else if (hardware->identity.customerID == 0xA0) + { + patchBufferSizes[NN_BUFFER_IDX] = gcmSIZEOF(nnBuffer3); + nnCommands = nnBuffer3; + } else { gcmkONERROR(gcvSTATUS_NOT_SUPPORTED); @@ -12557,52 +8257,126 @@ _InitializeUSC( patchBufferSizes[INPUT_BUFFER_IDX] = patchBufferSizes[KERNEL_BUFFER_IDX] = - patchBufferSizes[RESULT_BUFFER_IDX] = 1024 * 1024; + patchBufferSizes[RESULT_BUFFER_IDX] = 512 * 1024; + patchBufferSizes[SRAM_BUFFER_IDX_C] = 0; +#endif + gcmkONERROR(gckOS_Allocate(hardware->os, + 160 * gcmSIZEOF(gctUINT32), + (gctPOINTER *)&flushCommands)); + + gckOS_ZeroMemory((gctPOINTER)flushCommands, 160 * gcmSIZEOF(gctUINT32)); gcmkONERROR(gckOS_Allocate(hardware->os, - gcmSIZEOF(gcsFUNCTION_EXECUTION_DATA) * 4, + gcmSIZEOF(gcsFUNCTION_EXECUTION_DATA) * 5, &pointer)); - gckOS_ZeroMemory(pointer, gcmSIZEOF(gcsFUNCTION_EXECUTION_DATA) * 4); + gckOS_ZeroMemory(pointer, gcmSIZEOF(gcsFUNCTION_EXECUTION_DATA) * 5); - Execution->data = (gcsFUNCTION_EXECUTION_DATA_PTR)pointer; + Execution->funcCmd[0].data = (gcsFUNCTION_EXECUTION_DATA_PTR)pointer; - for (i = 0; i < 4; i++) + for (i = 0; i < 5; i++) { + if (patchBufferSizes[i] == 0) + { + continue; + } /* Allocate memory for buffers. */ gcmkONERROR(gckKERNEL_AllocateVideoMemory( hardware->kernel, 64, - gcvVIDMEM_TYPE_BITMAP, + gcvVIDMEM_TYPE_COMMAND, gcvALLOC_FLAG_NONE, &patchBufferSizes[i], &pool, - &Execution->data[i].bufVidMem + &Execution->funcCmd[0].data[i].bufVidMem )); gcmkONERROR(gckVIDMEM_NODE_LockCPU( hardware->kernel, - Execution->data[i].bufVidMem, + Execution->funcCmd[0].data[i].bufVidMem, gcvFALSE, gcvFALSE, - &Execution->data[i].logical + &Execution->funcCmd[0].data[i].logical )); gcmkONERROR(gckVIDMEM_NODE_Lock( hardware->kernel, - Execution->data[i].bufVidMem, - &Execution->data[i].address + Execution->funcCmd[0].data[i].bufVidMem, + &Execution->funcCmd[0].data[i].address )); - gcmkONERROR(gckOS_ZeroMemory(Execution->data[i].logical, patchBufferSizes[i])); + gcmkONERROR(gckOS_ZeroMemory(Execution->funcCmd[0].data[i].logical, patchBufferSizes[i])); + } +#if gcdRESET_USC_C + if(Execution->funcCmd[0].data[KERNEL_BUFFER_IDX].logical) + { + _InitializeUSC_NNKernel(hardware, hw_type, data_type, item_size, core_count, (gctUINT32_PTR)Execution->funcCmd[0].data[KERNEL_BUFFER_IDX].logical); + +#if gcdDUMP_IN_KERNEL + gcmkDUMP(hardware->os, "#[reset usc: nn kernel]"); + gcmkDUMP_BUFFER( + hardware->os, + gcvDUMP_BUFFER_KERNEL_COMMAND, + Execution->funcCmd[0].data[KERNEL_BUFFER_IDX].logical, + Execution->funcCmd[0].data[KERNEL_BUFFER_IDX].address, + patchBufferSizes[KERNEL_BUFFER_IDX] + ); +#endif + } + + if (Execution->funcCmd[0].data[INPUT_BUFFER_IDX].logical) + { + gctUINT32 i = 0, offset = 0; + /*uint8, fp16, int8, uint16, int16, uint4, int4, bf16*/ + gctUINT32 value[] = {1, 0x3c00, 1, 1, 1, 1, 1, 0x3f80}; + + if (hw_type == USC_NN_TYPE_V8) + value[0x4] = 0x81; + + for (i = 0; i < (3 * 2); i ++) + _BitValue((gctUINT8_PTR*)&(Execution->funcCmd[0].data[INPUT_BUFFER_IDX].logical), value[data_type], &offset, item_size * 8); + +#if gcdDUMP_IN_KERNEL + gcmkDUMP(hardware->os, "#[reset usc: nn input]"); + gcmkDUMP_BUFFER( + hardware->os, + gcvDUMP_BUFFER_KERNEL_COMMAND, + Execution->funcCmd[0].data[INPUT_BUFFER_IDX].logical, + Execution->funcCmd[0].data[INPUT_BUFFER_IDX].address, + patchBufferSizes[INPUT_BUFFER_IDX] + ); +#endif } +#endif + /* Patch NN command */ - nnCommands[PATCH_KERNEL_OFFSET] = Execution->data[KERNEL_BUFFER_IDX].address >> 6; - nnCommands[PATCH_INPUT_OFFSET] = Execution->data[INPUT_BUFFER_IDX].address; - nnCommands[PATCH_RESULT_OFFSET] = Execution->data[RESULT_BUFFER_IDX].address; - gckOS_MemCopy(Execution->data[NN_BUFFER_IDX].logical, nnCommands, patchBufferSizes[NN_BUFFER_IDX]); + nnCommands[PATCH_KERNEL_OFFSET] = Execution->funcCmd[0].data[KERNEL_BUFFER_IDX].address >> 6; + nnCommands[PATCH_INPUT_OFFSET] = Execution->funcCmd[0].data[INPUT_BUFFER_IDX].address; + nnCommands[PATCH_RESULT_OFFSET] = Execution->funcCmd[0].data[RESULT_BUFFER_IDX].address; + + gckOS_MemCopy(Execution->funcCmd[0].data[NN_BUFFER_IDX].logical, nnCommands, patchBufferSizes[NN_BUFFER_IDX]); + +#if gcdDUMP_IN_KERNEL + gcmkDUMP(hardware->os, "#[reset usc: nn instruction]"); + gcmkDUMP_BUFFER( + hardware->os, + gcvDUMP_BUFFER_KERNEL_COMMAND, + Execution->funcCmd[0].data[NN_BUFFER_IDX].logical, + Execution->funcCmd[0].data[NN_BUFFER_IDX].address, + patchBufferSizes[NN_BUFFER_IDX] + ); +#endif +#if gcdRESET_USC_C + _InitializeUSC_NNCmdBuffer( + hardware, + hw_type, + flushCommands, + Execution->funcCmd[0].data[NN_BUFFER_IDX].address, + Execution->funcCmd[0].data[SRAM_BUFFER_IDX_C].address, + Bytes); +#else /* construct command */ if (hardware->identity.customerID == 0x21) { @@ -12670,6 +8444,136 @@ _InitializeUSC( ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); flushCommands[idx++] = 0x00000040; } + else if (hardware->identity.customerID == 0xA0) + { + flushCommands[idx++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0E4E) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + flushCommands[idx++] = 0xf0800000; + + flushCommands[idx++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0E4F) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + flushCommands[idx++] = 0x00000000; + + flushCommands[idx++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0E50) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + flushCommands[idx++] = 0x00000000; + + flushCommands[idx++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0E03) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + flushCommands[idx++] = 0x00000040; + } flushCommands[idx++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 31:27) - (0 ? @@ -13389,7 +9293,71 @@ _InitializeUSC( 25:16) - (0 ? 25:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); - flushCommands[idx++] = 0x00000004; + flushCommands[idx++] = 0x00000004; + + flushCommands[idx++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0515) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + flushCommands[idx++] = 0x00000000; + + flushCommands[idx++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0516) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + flushCommands[idx++] = 0x00000000; flushCommands[idx++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 31:27) - (0 ? @@ -13407,7 +9375,7 @@ _InitializeUSC( ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? - 15:0))) | (((gctUINT32) ((gctUINT32) (0x0515) & ((gctUINT32) ((((1 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0518) & ((gctUINT32) ((((1 ? 15:0) - (0 ? 15:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) @@ -13439,7 +9407,7 @@ _InitializeUSC( ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? - 15:0))) | (((gctUINT32) ((gctUINT32) (0x0516) & ((gctUINT32) ((((1 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0520) & ((gctUINT32) ((((1 ? 15:0) - (0 ? 15:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) @@ -13453,9 +9421,19 @@ _InitializeUSC( 25:16) - (0 ? 25:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); - flushCommands[idx++] = 0x00000000; - flushCommands[idx++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + if (hardware->identity.customerID == 0x21) + { + flushCommands[idx++] = 0x000a0000; + } + else + { + flushCommands[idx++] = 0x00000000; + } + + if (hardware->identity.customerID == 0x86) + { + flushCommands[idx++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 31:27) - (0 ? 31:27) + 1) == 32) ? ~0U : (~(~0U << ((1 ? @@ -13465,17 +9443,17 @@ _InitializeUSC( 31:27) - (0 ? 31:27) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) - | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 15:0) - (0 ? 15:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? - 15:0))) | (((gctUINT32) ((gctUINT32) (0x0518) & ((gctUINT32) ((((1 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0E4C) & ((gctUINT32) ((((1 ? 15:0) - (0 ? 15:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) - | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 25:16) - (0 ? 25:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? @@ -13485,9 +9463,11 @@ _InitializeUSC( 25:16) - (0 ? 25:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); - flushCommands[idx++] = 0x00000000; - - flushCommands[idx++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + flushCommands[idx++] = 0x0000008c; + } + else if (hardware->identity.customerID == 0xA0) + { + flushCommands[idx++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 31:27) - (0 ? 31:27) + 1) == 32) ? ~0U : (~(~0U << ((1 ? @@ -13497,17 +9477,17 @@ _InitializeUSC( 31:27) - (0 ? 31:27) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) - | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 15:0) - (0 ? 15:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? - 15:0))) | (((gctUINT32) ((gctUINT32) (0x0520) & ((gctUINT32) ((((1 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0E4C) & ((gctUINT32) ((((1 ? 15:0) - (0 ? 15:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) - | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 25:16) - (0 ? 25:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? @@ -13517,18 +9497,8 @@ _InitializeUSC( 25:16) - (0 ? 25:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + flushCommands[idx++] = 0x00000008; - if (hardware->identity.customerID == 0x21) - { - flushCommands[idx++] = 0x000a0000; - } - else - { - flushCommands[idx++] = 0x00000000; - } - - if (hardware->identity.customerID == 0x86) - { flushCommands[idx++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 31:27) - (0 ? 31:27) + 1) == 32) ? @@ -13545,7 +9515,7 @@ _InitializeUSC( ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? - 15:0))) | (((gctUINT32) ((gctUINT32) (0x0E4C) & ((gctUINT32) ((((1 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0E4E) & ((gctUINT32) ((((1 ? 15:0) - (0 ? 15:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) @@ -13559,7 +9529,7 @@ _InitializeUSC( 25:16) - (0 ? 25:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); - flushCommands[idx++] = 0x0000008c; + flushCommands[idx++] = 0xf0800000; } flushCommands[idx++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? @@ -13592,7 +9562,7 @@ _InitializeUSC( 25:16) - (0 ? 25:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); - flushCommands[idx++] = Execution->data[NN_BUFFER_IDX].address; + flushCommands[idx++] = Execution->funcCmd[0].data[NN_BUFFER_IDX].address; flushCommands[idx++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 31:27) - (0 ? @@ -13639,49 +9609,61 @@ _InitializeUSC( flushCommands[idx++] = 0x00000000; *Bytes = idx * 4 - 8; +#endif /* Copy command to command buffer */ gckOS_MemCopy(logical, flushCommands, *Bytes); + if (flushCommands) + { + gckOS_Free(hardware->os, flushCommands); + flushCommands = gcvNULL; + } return status; OnError: - if (Execution->data) + if (flushCommands) + { + gckOS_Free(hardware->os, flushCommands); + flushCommands = gcvNULL; + } + + if (Execution->funcCmd[0].data) { - for (i = 0; i < 4; i++) + for (i = 0; i < 5; i++) { - if (Execution->data[i].bufVidMem) + if (Execution->funcCmd[0].data[i].bufVidMem) { - if (Execution->data[i].logical) + if (Execution->funcCmd[0].data[i].logical) { gckVIDMEM_NODE_UnlockCPU( hardware->kernel, - Execution->data[i].bufVidMem, + Execution->funcCmd[0].data[i].bufVidMem, 0, gcvFALSE, gcvFALSE ); - Execution->data[i].logical = gcvNULL; + Execution->funcCmd[0].data[i].logical = gcvNULL; } - if (Execution->data[i].address) + if (Execution->funcCmd[0].data[i].address) { gckVIDMEM_NODE_Unlock( hardware->kernel, - Execution->data[i].bufVidMem, + Execution->funcCmd[0].data[i].bufVidMem, 0, gcvNULL ); - Execution->data[i].address = 0; + Execution->funcCmd[0].data[i].address = 0; } gckVIDMEM_NODE_Dereference( hardware->kernel, - Execution->data[i].bufVidMem + Execution->funcCmd[0].data[i].bufVidMem ); } } - gcmkVERIFY_OK(gckOS_Free(hardware->os, Execution->data)); - Execution->data = gcvNULL; + gcmkVERIFY_OK(gckOS_Free(hardware->os, Execution->funcCmd[0].data)); + Execution->funcCmd[0].data = gcvNULL; } return status; @@ -13690,11 +9672,17 @@ OnError: static gceSTATUS _FuncValidate_USC(IN gcsFUNCTION_EXECUTION_PTR Execution) { +#ifdef EMULATOR + Execution->valid = gcvFALSE; +#else gckHARDWARE hardware = (gckHARDWARE)Execution->hardware; Execution->valid = gcvFALSE; if (!gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_USC_ASYNC_CP_RTN_FLOP_RESET_FIX)) { +#if gcdRESET_USC_C + Execution->valid = gcvTRUE; +#else if (hardware->identity.customerID == 0x21 || hardware->identity.customerID == 0x25 || hardware->identity.customerID == 0x86 || @@ -13703,8 +9691,9 @@ _FuncValidate_USC(IN gcsFUNCTION_EXECUTION_PTR Execution) { Execution->valid = gcvTRUE; } +#endif } - +#endif return gcvSTATUS_OK; } @@ -13712,79 +9701,99 @@ static gceSTATUS _FuncRelease_USC(IN gcsFUNCTION_EXECUTION_PTR Execution) { gckHARDWARE hardware = (gckHARDWARE)Execution->hardware; - gctUINT32 i; + gctUINT32 i = 0, j = 0; - if (Execution->data) + if (Execution->funcCmd) { - for (i = 0; i < 4; i++) +#if gcdRESET_USC_C + if (Execution->funcCmd[0].data) { - if (Execution->data[i].bufVidMem) + if (*((gctUINT32_PTR)(Execution->funcCmd[0].data[3].logical)) == 0x00000404 /*INT8*/ + || *((gctUINT32_PTR)(Execution->funcCmd[0].data[3].logical)) == 0x00040004 /*INT16*/ + || *((gctUINT32_PTR)(Execution->funcCmd[0].data[3].logical)) == 0x44004400 /*FP16*/ + ) { - if (Execution->data[i].logical) - { - gckVIDMEM_NODE_UnlockCPU( - hardware->kernel, - Execution->data[i].bufVidMem, - 0, - gcvFALSE, - gcvFALSE - ); - Execution->data[i].logical = gcvNULL; - } - if (Execution->data[i].address) + gcmkPRINT("USC PASS! "); + } + } +#endif + + for (j = 0; j < Execution->funcCmdCount; j++) + { + if (Execution->funcCmd[j].data) + { + for (i = 0; i < 5; i++) { - gckVIDMEM_NODE_Unlock( - hardware->kernel, - Execution->data[i].bufVidMem, - 0, - gcvNULL - ); - Execution->data[i].address = 0; + if (Execution->funcCmd[j].data[i].bufVidMem) + { + if (Execution->funcCmd[j].data[i].logical) + { + gckVIDMEM_NODE_UnlockCPU( + hardware->kernel, + Execution->funcCmd[j].data[i].bufVidMem, + 0, + gcvFALSE, + gcvFALSE + ); + Execution->funcCmd[j].data[i].logical = gcvNULL; + } + if (Execution->funcCmd[j].data[i].address) + { + gckVIDMEM_NODE_Unlock( + hardware->kernel, + Execution->funcCmd[j].data[i].bufVidMem, + 0, + gcvNULL + ); + Execution->funcCmd[j].data[i].address = 0; + } + + gckVIDMEM_NODE_Dereference( + hardware->kernel, + Execution->funcCmd[j].data[i].bufVidMem + ); + } } - gckVIDMEM_NODE_Dereference( - hardware->kernel, - Execution->data[i].bufVidMem - ); + gcmkVERIFY_OK(gckOS_Free(hardware->os, Execution->funcCmd[j].data)); + Execution->funcCmd[j].data = gcvNULL; } - } - - gcmkVERIFY_OK(gckOS_Free(hardware->os, Execution->data)); - Execution->data = gcvNULL; - } - if (Execution->funcVidMem) - { - if (Execution->address) - { - /* Synchroneous unlock. */ - gcmkVERIFY_OK(gckVIDMEM_NODE_Unlock( - hardware->kernel, - Execution->funcVidMem, - 0, - gcvNULL - )); - Execution->address = 0; - } + if (Execution->funcCmd[j].funcVidMem) + { + if (Execution->funcCmd[j].address) + { + /* Synchroneous unlock. */ + gcmkVERIFY_OK(gckVIDMEM_NODE_Unlock( + hardware->kernel, + Execution->funcCmd[j].funcVidMem, + 0, + gcvNULL + )); + Execution->funcCmd[j].address = 0; + } - if (Execution->logical) - { - gcmkVERIFY_OK(gckVIDMEM_NODE_UnlockCPU( - hardware->kernel, - Execution->funcVidMem, - 0, - gcvFALSE, - gcvFALSE - )); - Execution->logical = gcvNULL; - } + if (Execution->funcCmd[j].logical) + { + gcmkVERIFY_OK(gckVIDMEM_NODE_UnlockCPU( + hardware->kernel, + Execution->funcCmd[j].funcVidMem, + 0, + gcvFALSE, + gcvFALSE + )); + Execution->funcCmd[j].logical = gcvNULL; + } - gcmkVERIFY_OK(gckVIDMEM_NODE_Dereference( - hardware->kernel, - Execution->funcVidMem - )); + gcmkVERIFY_OK(gckVIDMEM_NODE_Dereference( + hardware->kernel, + Execution->funcCmd[j].funcVidMem + )); - Execution->funcVidMem = gcvNULL; + Execution->funcCmd[j].funcVidMem = gcvNULL; + } + } + gcmkVERIFY_OK(gckOS_Free(hardware->os, (gctPOINTER)Execution->funcCmd)); } return gcvSTATUS_OK; @@ -13802,45 +9811,56 @@ _FuncInit_USC(IN gcsFUNCTION_EXECUTION_PTR Execution) gcePOOL pool; gctPOINTER logical; gckHARDWARE hardware = (gckHARDWARE)Execution->hardware; + gctPOINTER pointer = gcvNULL; pool = gcvPOOL_DEFAULT; #if gcdENABLE_CACHEABLE_COMMAND_BUFFER allocFlag = gcvALLOC_FLAG_CACHEABLE; #endif + Execution->funcCmdCount = 1; + + /* Allocate the gcsFUNCTION_COMMAND buffer */ + gcmkONERROR(gckOS_Allocate(hardware->os, + gcmSIZEOF(gcsFUNCTION_COMMAND) * Execution->funcCmdCount, + (gctPOINTER *)&pointer)); + + gckOS_ZeroMemory((gctPOINTER)pointer, gcmSIZEOF(gcsFUNCTION_COMMAND) * Execution->funcCmdCount); - Execution->funcVidMemBytes = 1024; + Execution->funcCmd = (gcsFUNCTION_COMMAND_PTR)pointer; + + Execution->funcCmd[0].funcVidMemBytes = 1024; /* Allocate video memory node for aux functions. */ gcmkONERROR(gckKERNEL_AllocateVideoMemory( hardware->kernel, 64, gcvVIDMEM_TYPE_COMMAND, allocFlag, - &Execution->funcVidMemBytes, + &Execution->funcCmd[0].funcVidMemBytes, &pool, - &Execution->funcVidMem + &Execution->funcCmd[0].funcVidMem )); /* Lock for GPU access. */ gcmkONERROR(gckVIDMEM_NODE_Lock( hardware->kernel, - Execution->funcVidMem, - &Execution->address + Execution->funcCmd[0].funcVidMem, + &Execution->funcCmd[0].address )); /* Lock for kernel side CPU access. */ gcmkONERROR(gckVIDMEM_NODE_LockCPU( hardware->kernel, - Execution->funcVidMem, + Execution->funcCmd[0].funcVidMem, gcvFALSE, gcvFALSE, - &Execution->logical + &Execution->funcCmd[0].logical )); /* ** All cache flush command sequence. */ - logical = Execution->logical; - address = Execution->address; + logical = Execution->funcCmd[0].logical; + address = Execution->funcCmd[0].address; /* Append a flush. */ gcmkONERROR(_InitializeUSC(Execution, &uscBytes)); @@ -13854,9 +9874,9 @@ _FuncInit_USC(IN gcsFUNCTION_EXECUTION_PTR Execution) gcmkONERROR(gckWLFE_End(hardware, logical, address, &endBytes)); } - Execution->bytes = uscBytes + endBytes; - Execution->endAddress = Execution->address + uscBytes; - Execution->endLogical = (gctUINT8_PTR)Execution->logical + uscBytes; + Execution->funcCmd[0].bytes = uscBytes + endBytes; + Execution->funcCmd[0].endAddress = Execution->funcCmd[0].address + uscBytes; + Execution->funcCmd[0].endLogical = (gctUINT8_PTR)Execution->funcCmd[0].logical + uscBytes; return gcvSTATUS_OK; OnError: @@ -13864,7 +9884,8 @@ OnError: return status; } - +#endif +#if gcdRESET_USC2 gceSTATUS _InitializeUSC2( IN gcsFUNCTION_EXECUTION_PTR Execution, @@ -13873,25 +9894,32 @@ _InitializeUSC2( { gctUINT32 i, idx = 0; gcePOOL pool = gcvPOOL_DEFAULT; - gctUINT32 flushCommands[80] = {0}; - gctSIZE_T patchBufferSizes[2]; + gctUINT32_PTR flushCommands = gcvNULL; + gctSIZE_T patchBufferSizes[3]; gceSTATUS status = gcvSTATUS_OK; gckHARDWARE hardware = (gckHARDWARE)Execution->hardware; - gctUINT8_PTR logical = (gctUINT8_PTR)Execution->logical; + gctUINT8_PTR logical = (gctUINT8_PTR)Execution->funcCmd[0].logical; gctPOINTER pointer = gcvNULL; patchBufferSizes[INST_BUFFER_IDX] = gcmSIZEOF(instBuffer); patchBufferSizes[OUTPUT_BUFFER_IDX] = 1024; + patchBufferSizes[SRAM_BUFFER_IDX] = 128 * 1024; + + gcmkONERROR(gckOS_Allocate(hardware->os, + 128 * gcmSIZEOF(gctUINT32), + (gctPOINTER *)&flushCommands)); + + gckOS_ZeroMemory((gctPOINTER)flushCommands, 128 * gcmSIZEOF(gctUINT32)); gcmkONERROR(gckOS_Allocate(hardware->os, - gcmSIZEOF(gcsFUNCTION_EXECUTION_DATA) * 2, + gcmSIZEOF(gcsFUNCTION_EXECUTION_DATA) * 3, &pointer)); - gckOS_ZeroMemory(pointer, gcmSIZEOF(gcsFUNCTION_EXECUTION_DATA) * 2); + gckOS_ZeroMemory(pointer, gcmSIZEOF(gcsFUNCTION_EXECUTION_DATA) * 3); - Execution->data = (gcsFUNCTION_EXECUTION_DATA_PTR)pointer; + Execution->funcCmd[0].data = (gcsFUNCTION_EXECUTION_DATA_PTR)pointer; - for (i = 0; i < 2; i++) + for (i = 0; i < 3; i++) { /* Allocate memory for buffers. */ gcmkONERROR(gckKERNEL_AllocateVideoMemory( @@ -13901,27 +9929,27 @@ _InitializeUSC2( gcvALLOC_FLAG_NONE, &patchBufferSizes[i], &pool, - &Execution->data[i].bufVidMem + &Execution->funcCmd[0].data[i].bufVidMem )); gcmkONERROR(gckVIDMEM_NODE_LockCPU( hardware->kernel, - Execution->data[i].bufVidMem, + Execution->funcCmd[0].data[i].bufVidMem, gcvFALSE, gcvFALSE, - &Execution->data[i].logical + &Execution->funcCmd[0].data[i].logical )); gcmkONERROR(gckVIDMEM_NODE_Lock( hardware->kernel, - Execution->data[i].bufVidMem, - &Execution->data[i].address + Execution->funcCmd[0].data[i].bufVidMem, + &Execution->funcCmd[0].data[i].address )); - gcmkONERROR(gckOS_ZeroMemory(Execution->data[i].logical, patchBufferSizes[i])); + gcmkONERROR(gckOS_ZeroMemory(Execution->funcCmd[0].data[i].logical, patchBufferSizes[i])); } - gckOS_MemCopy(Execution->data[INST_BUFFER_IDX].logical, instBuffer, patchBufferSizes[INST_BUFFER_IDX]); + gckOS_MemCopy(Execution->funcCmd[0].data[INST_BUFFER_IDX].logical, instBuffer, patchBufferSizes[INST_BUFFER_IDX]); /* construct command */ flushCommands[idx++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? @@ -13983,7 +10011,7 @@ _InitializeUSC2( flushCommands[idx++] = 0x00000003; flushCommands[idx++] = 0x00000003; flushCommands[idx++] = 0x0000000f; - flushCommands[idx++] = Execution->data[OUTPUT_BUFFER_IDX].address; + flushCommands[idx++] = Execution->funcCmd[0].data[OUTPUT_BUFFER_IDX].address; flushCommands[idx++] = 0x00000000; flushCommands[idx++] = 0x00000080; flushCommands[idx++] = 0x00000001; @@ -14130,7 +10158,7 @@ _InitializeUSC2( 25:16) - (0 ? 25:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); - flushCommands[idx++] = Execution->data[INST_BUFFER_IDX].address; + flushCommands[idx++] = Execution->funcCmd[0].data[INST_BUFFER_IDX].address; flushCommands[idx++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 31:27) - (0 ? @@ -14228,7 +10256,43 @@ _InitializeUSC2( ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); flushCommands[idx++] = 0x00000001; - flushCommands[idx++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + if (hardware->identity.customerID == 0xA0) + { + flushCommands[idx++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x040E) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + flushCommands[idx++] = Execution->funcCmd[0].data[SRAM_BUFFER_IDX].address; + } + else + { + flushCommands[idx++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 31:27) - (0 ? 31:27) + 1) == 32) ? ~0U : (~(~0U << ((1 ? @@ -14238,8 +10302,9 @@ _InitializeUSC2( 31:27) - (0 ? 31:27) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) - | gcvCORE_3D_ALL_MASK; - flushCommands[idx++] = 0x00000000; + | gcvCORE_3D_ALL_MASK; + flushCommands[idx++] = 0x00000000; + } flushCommands[idx++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 31:27) - (0 ? @@ -14710,46 +10775,57 @@ _InitializeUSC2( *Bytes = idx * 4 - 8; /* Copy command to command buffer */ gckOS_MemCopy(logical, flushCommands, *Bytes); + if (flushCommands) + { + gckOS_Free(hardware->os, flushCommands); + flushCommands = gcvNULL; + } return status; OnError: - if (Execution->data) + if (flushCommands) + { + gckOS_Free(hardware->os, flushCommands); + flushCommands = gcvNULL; + } + + if (Execution->funcCmd[0].data) { - for (i = 0; i < 2; i++) + for (i = 0; i < 3; i++) { - if (Execution->data[i].bufVidMem) + if (Execution->funcCmd[0].data[i].bufVidMem) { - if (Execution->data[i].logical) + if (Execution->funcCmd[0].data[i].logical) { gckVIDMEM_NODE_UnlockCPU( hardware->kernel, - Execution->data[i].bufVidMem, + Execution->funcCmd[0].data[i].bufVidMem, 0, gcvFALSE, gcvFALSE ); - Execution->data[i].logical = gcvNULL; + Execution->funcCmd[0].data[i].logical = gcvNULL; } - if (Execution->data[i].address) + if (Execution->funcCmd[0].data[i].address) { gckVIDMEM_NODE_Unlock( hardware->kernel, - Execution->data[i].bufVidMem, + Execution->funcCmd[0].data[i].bufVidMem, 0, gcvNULL ); - Execution->data[i].address = 0; + Execution->funcCmd[0].data[i].address = 0; } gckVIDMEM_NODE_Dereference( hardware->kernel, - Execution->data[i].bufVidMem + Execution->funcCmd[0].data[i].bufVidMem ); } } - gcmkVERIFY_OK(gckOS_Free(hardware->os, Execution->data)); - Execution->data = gcvNULL; + gcmkVERIFY_OK(gckOS_Free(hardware->os, Execution->funcCmd[0].data)); + Execution->funcCmd[0].data = gcvNULL; } return status; @@ -14758,6 +10834,9 @@ OnError: static gceSTATUS _FuncValidate_USC2(IN gcsFUNCTION_EXECUTION_PTR Execution) { +#ifdef EMULATOR + Execution->valid = gcvFALSE; +#else gckHARDWARE hardware = (gckHARDWARE)Execution->hardware; Execution->valid = gcvFALSE; @@ -14772,7 +10851,7 @@ _FuncValidate_USC2(IN gcsFUNCTION_EXECUTION_PTR Execution) Execution->valid = gcvTRUE; } } - +#endif return gcvSTATUS_OK; } @@ -14780,79 +10859,86 @@ static gceSTATUS _FuncRelease_USC2(IN gcsFUNCTION_EXECUTION_PTR Execution) { gckHARDWARE hardware = (gckHARDWARE)Execution->hardware; - gctUINT32 i; + gctUINT32 i, j; - if (Execution->data) + if (Execution->funcCmd) { - for (i = 0; i < 2; i++) + for (j = 0; j < Execution->funcCmdCount; j++) { - if (Execution->data[i].bufVidMem) + if (Execution->funcCmd[j].data) { - if (Execution->data[i].logical) - { - gckVIDMEM_NODE_UnlockCPU( - hardware->kernel, - Execution->data[i].bufVidMem, - 0, - gcvFALSE, - gcvFALSE - ); - Execution->data[i].logical = gcvNULL; - } - if (Execution->data[i].address) + for (i = 0; i < 3; i++) { - gckVIDMEM_NODE_Unlock( - hardware->kernel, - Execution->data[i].bufVidMem, - 0, - gcvNULL - ); - Execution->data[i].address = 0; + if (Execution->funcCmd[j].data[i].bufVidMem) + { + if (Execution->funcCmd[j].data[i].logical) + { + gckVIDMEM_NODE_UnlockCPU( + hardware->kernel, + Execution->funcCmd[j].data[i].bufVidMem, + 0, + gcvFALSE, + gcvFALSE + ); + Execution->funcCmd[j].data[i].logical = gcvNULL; + } + if (Execution->funcCmd[j].data[i].address) + { + gckVIDMEM_NODE_Unlock( + hardware->kernel, + Execution->funcCmd[j].data[i].bufVidMem, + 0, + gcvNULL + ); + Execution->funcCmd[j].data[i].address = 0; + } + + gckVIDMEM_NODE_Dereference( + hardware->kernel, + Execution->funcCmd[j].data[i].bufVidMem + ); + } } - gckVIDMEM_NODE_Dereference( - hardware->kernel, - Execution->data[i].bufVidMem - ); + gcmkVERIFY_OK(gckOS_Free(hardware->os, Execution->funcCmd[j].data)); + Execution->funcCmd[j].data = gcvNULL; } - } - - gcmkVERIFY_OK(gckOS_Free(hardware->os, Execution->data)); - Execution->data = gcvNULL; - } - if (Execution->funcVidMem) - { - if (Execution->address) - { - /* Synchroneous unlock. */ - gcmkVERIFY_OK(gckVIDMEM_NODE_Unlock( - hardware->kernel, - Execution->funcVidMem, - 0, - gcvNULL - )); - Execution->address = 0; - } + if (Execution->funcCmd[j].funcVidMem) + { + if (Execution->funcCmd[j].address) + { + /* Synchroneous unlock. */ + gcmkVERIFY_OK(gckVIDMEM_NODE_Unlock( + hardware->kernel, + Execution->funcCmd[j].funcVidMem, + 0, + gcvNULL + )); + Execution->funcCmd[j].address = 0; + } - if (Execution->logical) - { - gcmkVERIFY_OK(gckVIDMEM_NODE_UnlockCPU( - hardware->kernel, - Execution->funcVidMem, - 0, - gcvFALSE, - gcvFALSE - )); - Execution->logical = gcvNULL; - } + if (Execution->funcCmd[j].logical) + { + gcmkVERIFY_OK(gckVIDMEM_NODE_UnlockCPU( + hardware->kernel, + Execution->funcCmd[j].funcVidMem, + 0, + gcvFALSE, + gcvFALSE + )); + Execution->funcCmd[j].logical = gcvNULL; + } - gcmkVERIFY_OK(gckVIDMEM_NODE_Dereference( - hardware->kernel, - Execution->funcVidMem - )); + gcmkVERIFY_OK(gckVIDMEM_NODE_Dereference( + hardware->kernel, + Execution->funcCmd[j].funcVidMem + )); - Execution->funcVidMem = gcvNULL; + Execution->funcCmd[j].funcVidMem = gcvNULL; + } + } + gcmkVERIFY_OK(gckOS_Free(hardware->os, (gctPOINTER)Execution->funcCmd)); } return gcvSTATUS_OK; @@ -14870,45 +10956,56 @@ _FuncInit_USC2(IN gcsFUNCTION_EXECUTION_PTR Execution) gcePOOL pool; gctPOINTER logical; gckHARDWARE hardware = (gckHARDWARE)Execution->hardware; + gctPOINTER pointer = gcvNULL; pool = gcvPOOL_DEFAULT; #if gcdENABLE_CACHEABLE_COMMAND_BUFFER allocFlag = gcvALLOC_FLAG_CACHEABLE; #endif + Execution->funcCmdCount = 1; - Execution->funcVidMemBytes = 1024; + /* Allocate the gcsFUNCTION_COMMAND buffer */ + gcmkONERROR(gckOS_Allocate(hardware->os, + gcmSIZEOF(gcsFUNCTION_COMMAND) * Execution->funcCmdCount, + (gctPOINTER *)&pointer)); + + gckOS_ZeroMemory((gctPOINTER)pointer, gcmSIZEOF(gcsFUNCTION_COMMAND) * Execution->funcCmdCount); + + Execution->funcCmd = (gcsFUNCTION_COMMAND_PTR)pointer; + + Execution->funcCmd[0].funcVidMemBytes = 1024; /* Allocate video memory node for aux functions. */ gcmkONERROR(gckKERNEL_AllocateVideoMemory( hardware->kernel, 64, gcvVIDMEM_TYPE_COMMAND, allocFlag, - &Execution->funcVidMemBytes, + &Execution->funcCmd[0].funcVidMemBytes, &pool, - &Execution->funcVidMem + &Execution->funcCmd[0].funcVidMem )); /* Lock for GPU access. */ gcmkONERROR(gckVIDMEM_NODE_Lock( hardware->kernel, - Execution->funcVidMem, - &Execution->address + Execution->funcCmd[0].funcVidMem, + &Execution->funcCmd[0].address )); /* Lock for kernel side CPU access. */ gcmkONERROR(gckVIDMEM_NODE_LockCPU( hardware->kernel, - Execution->funcVidMem, + Execution->funcCmd[0].funcVidMem, gcvFALSE, gcvFALSE, - &Execution->logical + &Execution->funcCmd[0].logical )); /* ** All cache flush command sequence. */ - logical = Execution->logical; - address = Execution->address; + logical = Execution->funcCmd[0].logical; + address = Execution->funcCmd[0].address; /* Append a flush. */ gcmkONERROR(_InitializeUSC2(Execution, &uscBytes)); @@ -14922,9 +11019,9 @@ _FuncInit_USC2(IN gcsFUNCTION_EXECUTION_PTR Execution) gcmkONERROR(gckWLFE_End(hardware, logical, address, &endBytes)); } - Execution->bytes = uscBytes + endBytes; - Execution->endAddress = Execution->address + uscBytes; - Execution->endLogical = (gctUINT8_PTR)Execution->logical + uscBytes; + Execution->funcCmd[0].bytes = uscBytes + endBytes; + Execution->funcCmd[0].endAddress = Execution->funcCmd[0].address + uscBytes; + Execution->funcCmd[0].endLogical = (gctUINT8_PTR)Execution->funcCmd[0].logical + uscBytes; return gcvSTATUS_OK; @@ -14935,6 +11032,7 @@ OnError: } #endif +#endif /******************************************************************************* ** @@ -14981,6 +11079,7 @@ gceSTATUS gckFUNCTION_Construct(IN gctPOINTER Hardware) func->hardware = hardware; func->funcId = (gceFUNCTION_EXECUTION)i; + func->funcCmd = gcvNULL; /* Init functions API pointer */ switch (i) @@ -15001,16 +11100,36 @@ gceSTATUS gckFUNCTION_Construct(IN gctPOINTER Hardware) func->funcExecution.release = _FuncRelease_Flush; break; +#if gcdFLOP_RESET + case gcvFUNCTION_EXECUTION_FLOP_RESET: + gckOS_MemCopy(func->funcName, "flop reset", 11); + func->funcExecution.init = _FuncInit_FlopReset; + func->funcExecution.validate = _FuncValidate_FlopReset; + func->funcExecution.execute = _FuncExecute; + func->funcExecution.release = _FuncRelease; + break; +#else #if gcdINITIALIZE_PPU case gcvFUNCTION_EXECUTION_INITIALIZE_PPU: gckOS_MemCopy(func->funcName, "init ppu", 9); - func->funcExecution.init = _FuncInit_PPU; - func->funcExecution.validate = _FuncValidate_PPU; - func->funcExecution.execute = _FuncExecute; - func->funcExecution.release = _FuncRelease_PPU; + switch(hardware->identity.customerID) + { + case 0xA0: + func->funcExecution.init = _FuncInit_PPU_0xA0; + func->funcExecution.validate = _FuncValidate_PPU_0xA0; + func->funcExecution.execute = _FuncExecute; + func->funcExecution.release = _FuncRelease_PPU_0xA0; + break; + default: + func->funcExecution.init = _FuncInit_PPU; + func->funcExecution.validate = _FuncValidate_PPU; + func->funcExecution.execute = _FuncExecute; + func->funcExecution.release = _FuncRelease_PPU; + break; + } break; #endif -#if gcdRESET_USC +#if gcdRESET_USC1 case gcvFUNCTION_EXECUTION_RESET_USC: gckOS_MemCopy(func->funcName, "reset usc", 10); func->funcExecution.init = _FuncInit_USC; @@ -15018,6 +11137,9 @@ gceSTATUS gckFUNCTION_Construct(IN gctPOINTER Hardware) func->funcExecution.execute = _FuncExecute; func->funcExecution.release = _FuncRelease_USC; break; +#endif +#if gcdRESET_USC2 + case gcvFUNCTION_EXECUTION_RESET_USC2: gckOS_MemCopy(func->funcName, "reset usc2", 11); func->funcExecution.init = _FuncInit_USC2; @@ -15026,6 +11148,7 @@ gceSTATUS gckFUNCTION_Construct(IN gctPOINTER Hardware) func->funcExecution.release = _FuncRelease_USC2; break; #endif +#endif default: gcmkONERROR(gcvSTATUS_INVALID_ARGUMENT); @@ -15034,15 +11157,16 @@ gceSTATUS gckFUNCTION_Construct(IN gctPOINTER Hardware) return gcvSTATUS_OK; OnError: - if (pointer) + if (hardware->functions) { - gcmkVERIFY_OK(gckOS_Free(hardware->os, pointer)); + gcmkVERIFY_OK(gckOS_Free(hardware->os, hardware->functions)); } /* Return the status. */ gcmkFOOTER(); return status; } + gceSTATUS gckFUNCTION_Destory(IN gctPOINTER Hardware) { gceSTATUS status = gcvSTATUS_OK; @@ -15111,17 +11235,35 @@ gceSTATUS gckFUNCTION_Init(IN gcsFUNCTION_EXECUTION_PTR Execution) gceSTATUS gckFUNCTION_Execute(IN gcsFUNCTION_EXECUTION_PTR Execution) { - gceSTATUS status = gcvSTATUS_NOT_SUPPORTED; + gceSTATUS status = gcvSTATUS_OK; gcmkHEADER_ARG("Execution=0x%x", Execution); + /* Verify the arguments. */ gcmkVERIFY_ARGUMENT(Execution != gcvNULL); if (Execution->inited && Execution->funcExecution.execute) { - status = Execution->funcExecution.execute(Execution); + gckHARDWARE hardware = (gckHARDWARE)Execution->hardware; + + if (hardware->options.powerManagement && hardware->hasQchannel) + { + gcmkONERROR(gckHARDWARE_QchannelBypass(hardware, gcvTRUE)); + } + + gcmkONERROR(Execution->funcExecution.execute(Execution)); + + if (hardware->options.powerManagement && hardware->hasQchannel) + { + gcmkONERROR(gckHARDWARE_QchannelBypass(hardware, gcvFALSE)); + } + } + else + { + status = gcvSTATUS_NOT_SUPPORTED; } +OnError: gcmkFOOTER(); return status; } @@ -15131,6 +11273,7 @@ gceSTATUS gckFUNCTION_Release(IN gcsFUNCTION_EXECUTION_PTR Execution) gceSTATUS status = gcvSTATUS_NOT_SUPPORTED; gcmkHEADER_ARG("Execution=0x%x", Execution); + /* Verify the arguments. */ gcmkVERIFY_ARGUMENT(Execution != gcvNULL); @@ -15149,15 +11292,25 @@ void gckFUNCTION_Dump(IN gcsFUNCTION_EXECUTION_PTR Execution) { #if gcdDUMP_IN_KERNEL + gctUINT32 i; gckHARDWARE hardware = (gckHARDWARE)Execution->hardware; + if (!Execution || !Execution->funcCmd) + { + return; + } + gcmkDUMP(hardware->os, "#[function: %s]", Execution->funcName); - gcmkDUMP_BUFFER( - hardware->os, - gcvDUMP_BUFFER_KERNEL_COMMAND, - Execution->logical, - Execution->address, - Execution->bytes); + for (i = 0; i < Execution->funcCmdCount; i++) + { + gcmkDUMP_BUFFER( + hardware->os, + gcvDUMP_BUFFER_KERNEL_COMMAND, + Execution->funcCmd[i].logical, + Execution->funcCmd[i].address, + Execution->funcCmd[i].bytes + ); + } #endif } diff --git a/drivers/amlogic/npu/kernel/arch/gc_hal_kernel_hardware_func.h b/drivers/amlogic/npu/kernel/arch/gc_hal_kernel_hardware_func.h index 043a679..9b7add21 100644 --- a/drivers/amlogic/npu/kernel/arch/gc_hal_kernel_hardware_func.h +++ b/drivers/amlogic/npu/kernel/arch/gc_hal_kernel_hardware_func.h @@ -60,31 +60,62 @@ extern "C" { #endif -#define gcdINITIALIZE_PPU 0 -#define gcdRESET_USC 0 +#define gcdFLOP_RESET 1 +#define gcdFLOP_RESET_PPU 1 +#define gcdFLOP_RESET_NN 1 +#define gcdFLOP_RESET_TP 1 + +/* + * The following macros are for old FLOP + * reset path. + * Use gcdFLOP_RESET=1 for the new path. + * The related code will be removed as long + * as the new path is stable. + */ +#define gcdINITIALIZE_PPU 1 +#define gcdINITIALIZE_PPU_C 0 +#define gcdRESET_USC1 0 +#define gcdRESET_USC_C 0 +#define gcdRESET_USC2 1 typedef struct _gcsFUNCTION_EXECUTION * gcsFUNCTION_EXECUTION_PTR; typedef enum { gcvFUNCTION_EXECUTION_MMU, gcvFUNCTION_EXECUTION_FLUSH, -#if gcdRESET_USC +#if gcdFLOP_RESET + gcvFUNCTION_EXECUTION_FLOP_RESET, +#else +#if gcdRESET_USC1 gcvFUNCTION_EXECUTION_RESET_USC, +#endif +#if gcdRESET_USC2 gcvFUNCTION_EXECUTION_RESET_USC2, #endif #if gcdINITIALIZE_PPU gcvFUNCTION_EXECUTION_INITIALIZE_PPU, #endif +#endif gcvFUNCTION_EXECUTION_NUM } gceFUNCTION_EXECUTION; typedef struct { + /* Data Vidmem object */ gckVIDMEM_NODE bufVidMem; + + /* Total bytes of the data. */ + gctSIZE_T bufVidMemBytes; + + /* Entry of the data. */ gctUINT32 address; - /* CPU address of the function. */ + + /* CPU address of the data. */ gctPOINTER logical; + + /* Actually bytes of the data. */ + gctSIZE_T bytes; } gcsFUNCTION_EXECUTION_DATA, *gcsFUNCTION_EXECUTION_DATA_PTR; @@ -96,17 +127,8 @@ typedef struct { } gcsFUNCTION_API, *gcsFUNCTION_API_PTR; - -typedef struct _gcsFUNCTION_EXECUTION +typedef struct _gcsFUNCTION_COMMAND { - gctPOINTER hardware; - - /* Function name */ - gctCHAR funcName[16]; - - /* Function ID */ - gceFUNCTION_EXECUTION funcId; - /* Function Vidmem object */ gckVIDMEM_NODE funcVidMem; @@ -119,6 +141,9 @@ typedef struct _gcsFUNCTION_EXECUTION /* CPU address of the function. */ gctPOINTER logical; + /* Physical address of this command. */ + gctPHYS_ADDR_T physical; + /* Actually bytes of the function. */ gctUINT32 bytes; @@ -128,8 +153,30 @@ typedef struct _gcsFUNCTION_EXECUTION /* Logical of END in this function. */ gctUINT8_PTR endLogical; + /* Physical of End in this function. */ + gctPHYS_ADDR_T endPhysical; + /* Function private data */ + gctUINT32 dataCount; gcsFUNCTION_EXECUTION_DATA_PTR data; +} +gcsFUNCTION_COMMAND, *gcsFUNCTION_COMMAND_PTR; + +typedef struct _gcsFUNCTION_EXECUTION +{ + gctPOINTER hardware; + + /* Function name */ + gctCHAR funcName[16]; + + /* Function ID */ + gceFUNCTION_EXECUTION funcId; + + /* Function count */ + gctUINT8 funcCmdCount; + + /* Function array */ + gcsFUNCTION_COMMAND_PTR funcCmd; /* API of functions */ gcsFUNCTION_API funcExecution; diff --git a/drivers/amlogic/npu/kernel/arch/gc_hal_kernel_hardware_func_flop_reset.c b/drivers/amlogic/npu/kernel/arch/gc_hal_kernel_hardware_func_flop_reset.c new file mode 100644 index 0000000..ba295f7 --- /dev/null +++ b/drivers/amlogic/npu/kernel/arch/gc_hal_kernel_hardware_func_flop_reset.c @@ -0,0 +1,7025 @@ +/**************************************************************************** +* +* The MIT License (MIT) +* +* Copyright (c) 2014 - 2020 Vivante Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +* +***************************************************************************** +* +* The GPL License (GPL) +* +* Copyright (C) 2014 - 2020 Vivante Corporation +* +* 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 +* of the License, or (at your option) any later version. +* +* 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, write to the Free Software Foundation, +* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +***************************************************************************** +* +* Note: This software is released under dual MIT and GPL licenses. A +* recipient may use this file under the terms of either the MIT license or +* GPL License. If you wish to use only one license not the other, you can +* indicate your decision by deleting one of the above license notices in your +* version of this file. +* +*****************************************************************************/ + + +#include +#include + +#include "gc_hal_kernel_hardware_func_flop_reset.h" + +/* + * Flop reset. + * + * The flops can be reset with PPU, NN and TP programs. + * PPU: + * Requirements: + * 1. DP inst with all bins enabled. + * 2. Load inst which has at least two shader group, + * and every thread should load from different 64-byte address. + * 3. Stroe inst which has at least 6 threads, whose addresses are + * from different 64-byte address and flush. + * Case: + * * InImage: 64x6 = {1}, unsigned int8 + * * OutImage: 64x6, unsigned int8 + * * OutImage = InImage + InImage + * NN: + * Requirements: + * 1. A XYDP6 case. + * 2. NN cmd that uses only 1 core and make othere core's kernel size + * to be 0. + * Case: + * * Input: 3x2x1 = {1} + * * Kernel: 2x2x1 = {1} + * * Output: 2x1x1 + * TP: + * Requirements: + * 1. Run TP fc on all TP cores. + * Case: + * * Input: 1x1x2 = {1} + * * Kernel: 1x1x2x64 = {1} + * * Output: 1x64 + */ + +/* + * PPU. + */ +#define PPU_IMAGE_XSIZE 64 +#define PPU_IMAGE_YSIZE 6 +#define PPU_IMAGE_DATA 0x01010101 +#define MAX_PPU_INSTRUCTION_COUNT 16 +#define MAX_PPU_COMMAND_NUM 128 + +#define GCREG_SH_INSTRUCTION_TYPE_INVALID (~0U) + +typedef enum _gceFLOP_RESET_PPU_DATA { + gcvFLOP_RESET_PPU_INSTRUCTION = 0, + gcvFLOP_RESET_PPU_INPUT = 1, + gcvFLOP_RESET_PPU_OUTPUT = 2, + gcvFLOP_RESET_PPU_DATA_NUM +} +gceFLOP_RESET_PPU_DATA; + +/* + * NN convolution. + */ +#define MAX_NN_COMMAND_NUM 64 + +#define NN_KERNEL_XSIZE 2 +#define NN_KERNEL_YSIZE 2 +#define NN_KERNEL_ZSIZE 1 + +#define NN_INPUT_XSIZE 3 +#define NN_INPUT_YSIZE 2 +#define NN_INPUT_ZSIZE 1 + +#define NN_OUTPUT_XSIZE 2 +#define NN_OUTPUT_YSIZE 1 +#define NN_OUTPUT_ZSIZE 1 + +typedef enum _gceVIP_ARCH_TYPE { + gcvVIP_ARCH_TYPE_V6, + gcvVIP_ARCH_TYPE_V7, + gcvVIP_ARCH_TYPE_V8 +} +gceVIP_ARCH_TYPE; + +typedef enum _gceFLOP_RESET_NN_DATA { + gcvFLOP_RESET_NN_INSTRUCTION = 0, + gcvFLOP_RESET_NN_INPUT = 1, + gcvFLOP_RESET_NN_OUTPUT = 2, + gcvFLOP_RESET_NN_KERNEL = 3, + gcvFLOP_RESET_NN_DATA_NUM +} +gceFLOP_RESET_NN_DATA; + +#define TP_KERNEL_XSIZE 1 +#define TP_KERNEL_YSIZE 1 +#define TP_KERNEL_ZSIZE 2 +#define TP_KENREL_UNITS 64 + +#define TP_INPUT_XSIZE 1 +#define TP_INPUT_YSIZE 1 +#define TP_INPUT_ZSIZE 2 + +#define TP_OUTPUT_XSIZE 1 +#define TP_OUTPUT_YSIZE 64 +#define TP_OUTPUT_ZSIZE 1 + +typedef enum _gceFLOP_RESET_TP_DATA { + gcvFLOP_RESET_TP_INSTRUCTION = 0, + gcvFLOP_RESET_TP_INPUT = 1, + gcvFLOP_RESET_TP_OUTPUT = 2, + gcvFLOP_RESET_TP_KERNEL = 3, + gcvFLOP_RESET_TP_DATA_NUM +} +gceFLOP_RESET_TP_DATA; + +static gceSTATUS +_AllocateVideoMemory( + IN gckKERNEL Kernel, + IN gceVIDMEM_TYPE Type, + IN gctUINT32 AllocFlag, + IN OUT gcePOOL *Pool, + IN OUT gctSIZE_T *Bytes, + OUT gckVIDMEM_NODE *Node, + OUT gctPOINTER *Logical, + OUT gctUINT32 *Address + ) +{ + gceSTATUS status = gcvSTATUS_OK; + + gckVIDMEM_NODE bufferNode = gcvNULL; + gctPOINTER bufferLogical = gcvNULL; + gctUINT32 bufferAddress = 0; + gctSIZE_T bufferBytes = 0; + gcePOOL pool = gcvPOOL_DEFAULT; + + if (!Bytes || *Bytes == 0) + { + gcmkONERROR(gcvSTATUS_INVALID_ARGUMENT); + } + + if (Pool) + { + pool = *Pool; + } + + bufferBytes = *Bytes; + + gcmkONERROR(gckKERNEL_AllocateVideoMemory( + Kernel, + 64, + Type, + AllocFlag, + &bufferBytes, + &pool, + &bufferNode + )); + + gcmkONERROR(gckVIDMEM_NODE_LockCPU( + Kernel, + bufferNode, + gcvFALSE, + gcvFALSE, + &bufferLogical + )); + + gcmkONERROR(gckVIDMEM_NODE_Lock( + Kernel, + bufferNode, + &bufferAddress + )); + + gcmkONERROR(gckOS_ZeroMemory(bufferLogical, bufferBytes)); + + *Bytes = bufferBytes; + + if (Pool) + { + *Pool = pool; + } + + if (Node) + { + *Node = bufferNode; + } + + if (Logical) + { + *Logical = bufferLogical; + } + + if (Address) + { + *Address = bufferAddress; + } + + return gcvSTATUS_OK; + +OnError: + if (bufferNode) + { + if (bufferAddress) + { + gcmkVERIFY_OK(gckVIDMEM_NODE_Unlock( + Kernel, + bufferNode, + 0, + gcvNULL + )); + } + + if (bufferLogical) + { + gcmkVERIFY_OK(gckVIDMEM_NODE_UnlockCPU( + Kernel, + bufferNode, + 0, + gcvFALSE, + gcvFALSE + )); + } + + gcmkVERIFY_OK(gckVIDMEM_NODE_Dereference( + Kernel, + bufferNode + )); + } + + return status; +} + +static gceSTATUS +_FreeVideoMemory( + IN gckKERNEL Kernel, + IN gckVIDMEM_NODE Node + ) +{ + gceSTATUS status = gcvSTATUS_OK; + + if (!Node) + { + gcmkONERROR(gcvSTATUS_INVALID_ARGUMENT); + } + + gcmkVERIFY_OK(gckVIDMEM_NODE_Unlock( + Kernel, + Node, + 0, + gcvNULL + )); + + gcmkVERIFY_OK(gckVIDMEM_NODE_UnlockCPU( + Kernel, + Node, + 0, + gcvFALSE, + gcvFALSE + )); + + gcmkVERIFY_OK(gckVIDMEM_NODE_Dereference( + Kernel, + Node + )); + + return gcvSTATUS_OK; + +OnError: + return status; +} + +static gceSTATUS +_BitValue( + IN gctUINT8_PTR *Base, + IN gctUINT32 Value, + IN gctUINT32_PTR Offset, + IN gctUINT Length + ) +{ + gceSTATUS status = gcvSTATUS_OK; + + gctUINT32_PTR msb = (gctUINT32_PTR)(*Base) + 1, lsb = (gctUINT32_PTR)(*Base); + + gcmkASSERT(*Offset <= 32 && Length <= 32); + + if ((*Offset) < 32) + { + gctUINT32 end = (*Offset) + Length, data = *lsb; + + if (end < 32) + { + /************************************************************************ + * offset 32 64 * + * _________________________ * + * |_____|////|_|____________| * + * end * + ************************************************************************/ + data = (*lsb & ((1 << *Offset) - 1)); + data |= (*lsb & ~((1 << end) - 1)); + data |= (Value << *Offset); + + *lsb = data; + *Offset = end; + } + else if (end < 64) + { + /************************************************************************ + * offset 32 64 * + * _________________________ * + * |_____|//////|//|_________| * + * end * + ************************************************************************/ + gctUINT32 length_m = end - 32; + gctUINT32 data_l = (*lsb & ((1 << *Offset) - 1)); + gctUINT32 data_m = (*msb & ~((1 << length_m) - 1)); + + data_l |= (Value << *Offset); + data_m |= (Value >> (32 - *Offset)); + + *lsb = data_l; + + if (end > 32) + *msb = data_m; + + *Offset = length_m; + + *Base = (gctUINT8_PTR)msb; + } + + } + + return status; +} + +static gceSTATUS +_GetVIPCoreInfo( + IN gckHARDWARE Hardware, + OUT gceVIP_ARCH_TYPE *ArchType, + OUT gctUINT8 *DataType, + OUT gctUINT32 *CoreCount, + OUT gctUINT32 *Zdp, + OUT gctUINT32 *KernelBurstSize + ) +{ + gceSTATUS status = gcvSTATUS_OK; + + gcsFEATURE_DATABASE *database = (gcsFEATURE_DATABASE *)(Hardware->featureDatabase); + gceVIP_ARCH_TYPE archType; + gctUINT8 dataType = 0x0; + gctUINT32 coreCount = 0; + gctUINT32 zdp = 1; + gctUINT32 kernelBurstSize; + + gcmkASSERT(database); + + /* Make compiler happy. */ + gcQueryFeatureDB(0, 0, 0, 0, 0); + + /* Choose one supported format. */ + if (database->NNCoreCount_INT8 > 0) + { + dataType = 0x0; + coreCount = database->NNCoreCount_INT8; + } + else if (database->NNCoreCount_INT16 > 0) + { + dataType = 0x4; + coreCount = database->NNCoreCount_INT16; + } + else if (database->NNCoreCount_FLOAT16 > 0) + { + dataType = 0x1; + coreCount = database->NNCoreCount_FLOAT16; + } + else if (database->NNCoreCount_BFLOAT > 0) + { + dataType = 0x7; + coreCount = database->NNCoreCount_BFLOAT; + } + else + { + gcmkONERROR(gcvSTATUS_NOT_SUPPORTED); + } + + if (database->NN_XYDP0) + { + archType = gcvVIP_ARCH_TYPE_V8; + } + else if (database->VIP_V7) + { + archType = gcvVIP_ARCH_TYPE_V7; + } + else + { + archType = gcvVIP_ARCH_TYPE_V6; + } + + zdp = database->NN_ZDP3 ? 3 : 1; + + kernelBurstSize = database->DDR_KERNEL_BURST_SIZE; + + if (ArchType) + { + *ArchType = archType; + } + + if (DataType) + { + *DataType = dataType; + } + + if (CoreCount) + { + *CoreCount = coreCount; + } + + if (Zdp) + { + *Zdp = zdp; + } + + if (KernelBurstSize) + { + *KernelBurstSize = kernelBurstSize; + } + + return gcvSTATUS_OK; + +OnError: + return status; +} + +static gceSTATUS +_GetMapIndex( + gctUINT8 DataType, + gctUINT32_PTR Index + ) +{ + gceSTATUS status = gcvSTATUS_OK; + + if (!Index) + { + gcmkONERROR(gcvSTATUS_INVALID_ARGUMENT); + } + + switch (DataType) + { + case 0x1: + *Index = 1; + break; + + case 0x7: + *Index = 2; + break; + + default: + *Index = 0; + break; + } + + return gcvSTATUS_OK; + +OnError: + return status; +} + +static gceSTATUS +_GetNNDataSize( + IN gctUINT8 DataType, + OUT gctUINT32_PTR DataSize + ) +{ + gceSTATUS status = gcvSTATUS_OK; + + if (!DataSize) + { + gcmkONERROR(gcvSTATUS_INVALID_ARGUMENT); + } + + switch (DataType) + { + case 0x2: + case 0x0: + *DataSize = 1; + break; + + case 0x4: + case 0x1: + case 0x7: + *DataSize = 2; + break; + + default: + gcmkONERROR(gcvSTATUS_INVALID_ARGUMENT); + break; + } + + return gcvSTATUS_OK; + +OnError: + return status; +} + +/* + * PPU. + */ +static gceSTATUS +_ProgramPPUInput( + IN gckHARDWARE Hardware, + IN gctUINT32 InImageXSize, + IN gctUINT32 InImageYSize, + IN gctUINT32 AllocFlag, + IN OUT gcePOOL *Pool, + OUT gcsFUNCTION_EXECUTION_DATA *Data + ) +{ + gceSTATUS status = gcvSTATUS_OK; + + gctUINT32 itemBytes = 1; /* U8 format. */ + gckVIDMEM_NODE bufferNode = gcvNULL; + gctPOINTER bufferLogical = gcvNULL; + gctUINT32 bufferAddress = 0; + gctSIZE_T bufferBytes, bytes; + gctUINT32 *buffer = gcvNULL; + gctUINT32 i; + + bufferBytes = bytes = InImageXSize * InImageYSize * itemBytes; + + gcmkONERROR(_AllocateVideoMemory( + Hardware->kernel, + gcvVIDMEM_TYPE_BITMAP, + AllocFlag, + Pool, + &bufferBytes, + &bufferNode, + &bufferLogical, + &bufferAddress + )); + + buffer = (gctUINT32_PTR)bufferLogical; + + /* Fill the data. */ + for (i = 0; i < bytes / 4; i++) + { + buffer[i] = PPU_IMAGE_DATA; + } + + gcmkONERROR(gckVIDMEM_NODE_CleanCache( + Hardware->kernel, + bufferNode, + 0, + bufferLogical, + bytes + )); + +#if gcdDUMP_IN_KERNEL + gcmkDUMP(Hardware->os, "#[flop reset: ppu input]"); + gcmkDUMP_BUFFER( + Hardware->os, + gcvDUMP_BUFFER_KERNEL_COMMAND, + bufferLogical, + bufferAddress, + bytes + ); +#endif + + Data->bufVidMem = bufferNode; + Data->bufVidMemBytes = bufferBytes; + Data->address = bufferAddress; + Data->logical = bufferLogical; + Data->bytes = bytes; + + return gcvSTATUS_OK; + +OnError: + if (bufferNode) + { + gcmkVERIFY_OK(_FreeVideoMemory( + Hardware->kernel, + bufferNode + )); + } + + return status; +} + +static gceSTATUS +_ProgramPPUOutput( + IN gckHARDWARE Hardware, + IN gctUINT32 Width, + IN gctUINT32 Height, + IN gctUINT32 AllocFlag, + IN OUT gcePOOL *Pool, + OUT gcsFUNCTION_EXECUTION_DATA *Data + ) +{ + gceSTATUS status = gcvSTATUS_OK; + + gctUINT32 itemBytes = 1; + gckVIDMEM_NODE bufferNode = gcvNULL; + gctPOINTER bufferLogical = gcvNULL; + gctUINT32 bufferAddress = 0; + gctSIZE_T bufferBytes, bytes; + + bufferBytes = bytes = Width * Height * itemBytes; + + gcmkONERROR(_AllocateVideoMemory( + Hardware->kernel, + gcvVIDMEM_TYPE_BITMAP, + AllocFlag, + Pool, + &bufferBytes, + &bufferNode, + &bufferLogical, + &bufferAddress + )); + + gcmkONERROR(gckVIDMEM_NODE_CleanCache( + Hardware->kernel, + bufferNode, + 0, + bufferLogical, + bufferBytes + )); + + Data->bufVidMem = bufferNode; + Data->bufVidMemBytes = bufferBytes; + Data->address = bufferAddress; + Data->logical = bufferLogical; + Data->bytes = bytes; + + return gcvSTATUS_OK; + +OnError: + if (bufferNode) + { + gcmkVERIFY_OK(_FreeVideoMemory( + Hardware->kernel, + bufferNode + )); + } + + return status; +} + +static gctUINT32 +_SETBITS( + IN gctUINT32 Data, + IN gctUINT32 Start, + IN gctUINT32 End, + IN gctUINT32 Value + ) +{ + gctUINT32 data = Data; + gctUINT32 mask; + + if (End >= Start) + { + mask = ((~0ULL >> (63 - End + Start)) << Start); + data &= ~mask; + data |= ((Value) << Start) & mask; + return data; + } + else + { + mask = ((~0ULL >> (63 - Start + End)) << End); + data &= ~mask; + data |= ((Value) << End) & mask; + return data; + } +} + +static gctUINT32 +_SETBIT( + IN gctUINT32 Data, + IN gctUINT32 Position, + IN gctUINT32 Value + ) +{ + gctUINT32 data; + + data = _SETBITS(Data, Position, Position, Value); + + return data; +} + +static gctUINT32 +_GETBITS( + IN gctUINT32 Data, + IN gctUINT32 Start, + IN gctUINT32 End + ) +{ + gctUINT32 data = Data; + gctUINT32 mask; + + if (End >= Start) + { + mask = (~0ULL >> (63 - (End - Start))); + return (data >> Start) & mask; + } + else + { + mask = (~0ULL >> (63 - (Start - End))); + return (data >> End) & mask;; + } +} + +static gctUINT32 +_GETBIT( + IN gctUINT32 Data, + IN gctUINT32 Position + ) +{ + gctUINT32 data; + + data = _GETBITS(Data, Position, Position); + + return data; +} + +static gceSTATUS +gckPPU_SetImmediate( + IN gctUINT32 Where, + IN gctUINT32 Value, + IN gctUINT32 Type, + IN OUT gctUINT32_PTR Inst + ) +{ + gceSTATUS status = gcvSTATUS_OK; + + if (!Inst) + { + gcmkONERROR(gcvSTATUS_INVALID_ARGUMENT); + } + + switch (Where) + { + case 0: + Inst[1] = ((((gctUINT32) (Inst[1])) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 20:12) - (0 ? + 20:12) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 20:12) - (0 ? + 20:12) + 1))))))) << (0 ? + 20:12))) | (((gctUINT32) ((gctUINT32) (_GETBITS(Value, 8, 0)) & ((gctUINT32) ((((1 ? + 20:12) - (0 ? + 20:12) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 20:12) - (0 ? 20:12) + 1))))))) << (0 ? 20:12))); + Inst[1] = ((((gctUINT32) (Inst[1])) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 29:22) - (0 ? + 29:22) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 29:22) - (0 ? + 29:22) + 1))))))) << (0 ? + 29:22))) | (((gctUINT32) ((gctUINT32) (_GETBITS(Value, 16, 9)) & ((gctUINT32) ((((1 ? + 29:22) - (0 ? + 29:22) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 29:22) - (0 ? 29:22) + 1))))))) << (0 ? 29:22))); + Inst[1] = ((((gctUINT32) (Inst[1])) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 30:30) - (0 ? + 30:30) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 30:30) - (0 ? + 30:30) + 1))))))) << (0 ? + 30:30))) | (((gctUINT32) ((gctUINT32) (_GETBIT(Value, 17)) & ((gctUINT32) ((((1 ? + 30:30) - (0 ? + 30:30) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 30:30) - (0 ? 30:30) + 1))))))) << (0 ? 30:30))); + Inst[1] = ((((gctUINT32) (Inst[1])) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:31) - (0 ? + 31:31) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:31) - (0 ? + 31:31) + 1))))))) << (0 ? + 31:31))) | (((gctUINT32) ((gctUINT32) (_GETBIT(Value, 18)) & ((gctUINT32) ((((1 ? + 31:31) - (0 ? + 31:31) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:31) - (0 ? 31:31) + 1))))))) << (0 ? 31:31))); + Inst[2] = ((((gctUINT32) (Inst[2])) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 2:0) - (0 ? + 2:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 2:0) - (0 ? + 2:0) + 1))))))) << (0 ? + 2:0))) | (((gctUINT32) ((gctUINT32) (_GETBIT(Value, 19) | (Type << 1)) & ((gctUINT32) ((((1 ? + 2:0) - (0 ? + 2:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 2:0) - (0 ? 2:0) + 1))))))) << (0 ? 2:0))); + Inst[2] = ((((gctUINT32) (Inst[2])) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 5:3) - (0 ? + 5:3) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 5:3) - (0 ? + 5:3) + 1))))))) << (0 ? + 5:3))) | (((gctUINT32) ((gctUINT32) (0x7) & ((gctUINT32) ((((1 ? + 5:3) - (0 ? + 5:3) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 5:3) - (0 ? 5:3) + 1))))))) << (0 ? 5:3))); + break; + + case 1: + Inst[2] = ((((gctUINT32) (Inst[2])) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:7) - (0 ? + 15:7) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:7) - (0 ? + 15:7) + 1))))))) << (0 ? + 15:7))) | (((gctUINT32) ((gctUINT32) (_GETBITS(Value, 8, 0)) & ((gctUINT32) ((((1 ? + 15:7) - (0 ? + 15:7) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:7) - (0 ? 15:7) + 1))))))) << (0 ? 15:7))); + Inst[2] = ((((gctUINT32) (Inst[2])) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 24:17) - (0 ? + 24:17) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 24:17) - (0 ? + 24:17) + 1))))))) << (0 ? + 24:17))) | (((gctUINT32) ((gctUINT32) (_GETBITS(Value, 16, 9)) & ((gctUINT32) ((((1 ? + 24:17) - (0 ? + 24:17) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 24:17) - (0 ? 24:17) + 1))))))) << (0 ? 24:17))); + Inst[2] = ((((gctUINT32) (Inst[2])) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:25) - (0 ? + 25:25) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:25) - (0 ? + 25:25) + 1))))))) << (0 ? + 25:25))) | (((gctUINT32) ((gctUINT32) (_GETBIT(Value, 17)) & ((gctUINT32) ((((1 ? + 25:25) - (0 ? + 25:25) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:25) - (0 ? 25:25) + 1))))))) << (0 ? 25:25))); + Inst[2] = ((((gctUINT32) (Inst[2])) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 26:26) - (0 ? + 26:26) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 26:26) - (0 ? + 26:26) + 1))))))) << (0 ? + 26:26))) | (((gctUINT32) ((gctUINT32) (_GETBIT(Value, 18)) & ((gctUINT32) ((((1 ? + 26:26) - (0 ? + 26:26) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 26:26) - (0 ? 26:26) + 1))))))) << (0 ? 26:26))); + Inst[2] = ((((gctUINT32) (Inst[2])) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 29:27) - (0 ? + 29:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 29:27) - (0 ? + 29:27) + 1))))))) << (0 ? + 29:27))) | (((gctUINT32) ((gctUINT32) (_GETBIT(Value, 19) | (Type << 1)) & ((gctUINT32) ((((1 ? + 29:27) - (0 ? + 29:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 29:27) - (0 ? 29:27) + 1))))))) << (0 ? 29:27))); + Inst[3] = ((((gctUINT32) (Inst[3])) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 2:0) - (0 ? + 2:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 2:0) - (0 ? + 2:0) + 1))))))) << (0 ? + 2:0))) | (((gctUINT32) ((gctUINT32) (0x7) & ((gctUINT32) ((((1 ? + 2:0) - (0 ? + 2:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 2:0) - (0 ? 2:0) + 1))))))) << (0 ? 2:0))); + break; + + case 2: + Inst[3] = ((((gctUINT32) (Inst[3])) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 12:4) - (0 ? + 12:4) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 12:4) - (0 ? + 12:4) + 1))))))) << (0 ? + 12:4))) | (((gctUINT32) ((gctUINT32) (_GETBITS(Value, 8, 0)) & ((gctUINT32) ((((1 ? + 12:4) - (0 ? + 12:4) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 12:4) - (0 ? 12:4) + 1))))))) << (0 ? 12:4))); + Inst[3] = ((((gctUINT32) (Inst[3])) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 21:14) - (0 ? + 21:14) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 21:14) - (0 ? + 21:14) + 1))))))) << (0 ? + 21:14))) | (((gctUINT32) ((gctUINT32) (_GETBITS(Value, 16, 9)) & ((gctUINT32) ((((1 ? + 21:14) - (0 ? + 21:14) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 21:14) - (0 ? 21:14) + 1))))))) << (0 ? 21:14))); + Inst[3] = ((((gctUINT32) (Inst[3])) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 22:22) - (0 ? + 22:22) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 22:22) - (0 ? + 22:22) + 1))))))) << (0 ? + 22:22))) | (((gctUINT32) ((gctUINT32) (_GETBIT(Value, 17)) & ((gctUINT32) ((((1 ? + 22:22) - (0 ? + 22:22) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 22:22) - (0 ? 22:22) + 1))))))) << (0 ? 22:22))); + Inst[3] = ((((gctUINT32) (Inst[3])) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 23:23) - (0 ? + 23:23) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 23:23) - (0 ? + 23:23) + 1))))))) << (0 ? + 23:23))) | (((gctUINT32) ((gctUINT32) (_GETBIT(Value, 18)) & ((gctUINT32) ((((1 ? + 23:23) - (0 ? + 23:23) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 23:23) - (0 ? 23:23) + 1))))))) << (0 ? 23:23))); + Inst[3] = ((((gctUINT32) (Inst[3])) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 27:25) - (0 ? + 27:25) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 27:25) - (0 ? + 27:25) + 1))))))) << (0 ? + 27:25))) | (((gctUINT32) ((gctUINT32) (_GETBIT(Value, 19) | (Type << 1)) & ((gctUINT32) ((((1 ? + 27:25) - (0 ? + 27:25) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 27:25) - (0 ? 27:25) + 1))))))) << (0 ? 27:25))); + Inst[3] = ((((gctUINT32) (Inst[3])) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 30:28) - (0 ? + 30:28) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 30:28) - (0 ? + 30:28) + 1))))))) << (0 ? + 30:28))) | (((gctUINT32) ((gctUINT32) (0x7) & ((gctUINT32) ((((1 ? + 30:28) - (0 ? + 30:28) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 30:28) - (0 ? 30:28) + 1))))))) << (0 ? 30:28))); + break; + } + + return gcvSTATUS_OK; + +OnError: + return status; +} + +static gceSTATUS +gckPPU_SetInstructionType( + IN gctUINT32 Type, + OUT gctUINT32_PTR Inst + ) +{ + gceSTATUS status = gcvSTATUS_OK; + + if (!Inst) + { + gcmkONERROR(gcvSTATUS_INVALID_ARGUMENT); + } + + Inst[1] = ((((gctUINT32) (Inst[1])) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 21:21) - (0 ? + 21:21) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 21:21) - (0 ? + 21:21) + 1))))))) << (0 ? + 21:21))) | (((gctUINT32) ((gctUINT32) (_GETBIT(Type, 0)) & ((gctUINT32) ((((1 ? + 21:21) - (0 ? + 21:21) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 21:21) - (0 ? 21:21) + 1))))))) << (0 ? 21:21))); + Inst[2] = ((((gctUINT32) (Inst[2])) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:30) - (0 ? + 31:30) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:30) - (0 ? + 31:30) + 1))))))) << (0 ? + 31:30))) | (((gctUINT32) ((gctUINT32) (_GETBITS(Type, 2, 1)) & ((gctUINT32) ((((1 ? + 31:30) - (0 ? + 31:30) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:30) - (0 ? 31:30) + 1))))))) << (0 ? 31:30))); + + return gcvSTATUS_OK; + +OnError: + return status; +} + +static gceSTATUS +gckPPU_IsEndOfBB( + IN gckHARDWARE Hardware, + IN gctUINT32 OpCode, + OUT gctUINT32_PTR Inst +) +{ + gceSTATUS status = gcvSTATUS_OK; + + gcsFEATURE_DATABASE *database = (gcsFEATURE_DATABASE *)Hardware->featureDatabase; + gctUINT32 bits = 0; + + if (!Inst) + { + gcmkONERROR(gcvSTATUS_INVALID_ARGUMENT); + } + + if (!database->SH_END_OF_BB) + { + return gcvSTATUS_OK; + } + + switch (OpCode) + { + case 0x09: + case 0x56: + case 0x0A: + case 0x0B: + case 0x0F: + case 0x31: + case 0x10: + bits = _SETBITS(Inst[1], 3, 3, 1); + Inst[1] = ((((gctUINT32) (Inst[1])) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 10:3) - (0 ? + 10:3) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 10:3) - (0 ? + 10:3) + 1))))))) << (0 ? + 10:3))) | (((gctUINT32) ((gctUINT32) (bits) & ((gctUINT32) ((((1 ? + 10:3) - (0 ? + 10:3) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 10:3) - (0 ? 10:3) + 1))))))) << (0 ? 10:3))); + break; + + case 0x65: + case 0x66: + case 0x67: + case 0x68: + case 0x69: + case 0x6A: + case 0x6B: + case 0x6C: + case 0x46: + bits = _SETBITS(Inst[0], 2, 2, 1); + Inst[0] = ((((gctUINT32) (Inst[0])) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 10:6) - (0 ? + 10:6) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 10:6) - (0 ? + 10:6) + 1))))))) << (0 ? + 10:6))) | (((gctUINT32) ((gctUINT32) (bits) & ((gctUINT32) ((((1 ? + 10:6) - (0 ? + 10:6) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 10:6) - (0 ? 10:6) + 1))))))) << (0 ? 10:6))); + break; + + case 0x32: + case 0x39: + case 0x33: + case 0x3A: + case 0x79: + case 0x34: + case 0x7A: + case 0x35: + bits = _SETBITS(Inst[0], 2, 2, 1); + Inst[0] = ((((gctUINT32) (Inst[0])) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 10:6) - (0 ? + 10:6) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 10:6) - (0 ? + 10:6) + 1))))))) << (0 ? + 10:6))) | (((gctUINT32) ((gctUINT32) (bits) & ((gctUINT32) ((((1 ? + 10:6) - (0 ? + 10:6) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 10:6) - (0 ? 10:6) + 1))))))) << (0 ? 10:6))); + break; + + default: + if (OpCode != 0x16 && + OpCode != 0x24 && + OpCode != 0x14 && + OpCode != 0x15 && + OpCode != 0x17) + { + bits = _SETBITS(Inst[0], 2, 2, 1); + Inst[0] = ((((gctUINT32) (Inst[0])) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 10:6) - (0 ? + 10:6) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 10:6) - (0 ? + 10:6) + 1))))))) << (0 ? + 10:6))) | (((gctUINT32) ((gctUINT32) (bits) & ((gctUINT32) ((((1 ? + 10:6) - (0 ? + 10:6) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 10:6) - (0 ? 10:6) + 1))))))) << (0 ? 10:6))); + } + break; + } + + return gcvSTATUS_OK; + +OnError: + return status; +} + +static gceSTATUS +gckPPU_AddOpCode( + IN gckHARDWARE Hardware, + IN gctUINT32 OpCode, + IN gctUINT32 Extended, + IN gctUINT32 Type, + IN OUT gctUINT32_PTR Inst + ) +{ + gceSTATUS status = gcvSTATUS_OK; + + + Inst[0] = ((((gctUINT32) (Inst[0])) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 5:0) - (0 ? + 5:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 5:0) - (0 ? + 5:0) + 1))))))) << (0 ? + 5:0))) | (((gctUINT32) ((gctUINT32) (_GETBITS(OpCode, 5, 0)) & ((gctUINT32) ((((1 ? + 5:0) - (0 ? + 5:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 5:0) - (0 ? 5:0) + 1))))))) << (0 ? 5:0))); + Inst[2] = ((((gctUINT32) (Inst[2])) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 16:16) - (0 ? + 16:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 16:16) - (0 ? + 16:16) + 1))))))) << (0 ? + 16:16))) | (((gctUINT32) ((gctUINT32) (_GETBIT(OpCode, 6)) & ((gctUINT32) ((((1 ? + 16:16) - (0 ? + 16:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 16:16) - (0 ? 16:16) + 1))))))) << (0 ? 16:16))); + + if (!Inst) + { + gcmkONERROR(gcvSTATUS_INVALID_ARGUMENT); + } + + switch (OpCode) + { + case 0x7F: + gcmkONERROR(gckPPU_SetImmediate(2, Extended, 0x2, Inst)); + break; + + case 0x45: + Inst[0] = ((((gctUINT32) (Inst[0])) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:13) - (0 ? + 15:13) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:13) - (0 ? + 15:13) + 1))))))) << (0 ? + 15:13))) | (((gctUINT32) ((gctUINT32) (_GETBITS(Extended, 2, 0)) & ((gctUINT32) ((((1 ? + 15:13) - (0 ? + 15:13) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:13) - (0 ? 15:13) + 1))))))) << (0 ? 15:13))); + Inst[0] = _SETBIT(Inst[0], 31, _GETBIT(Extended, 3)); + Inst[1] = _SETBITS(Inst[1], 1, 0, _GETBITS(Extended, 5, 4)); + break; + + case 0x31: + case 0x09: + case 0x0F: + Inst[0] = ((((gctUINT32) (Inst[0])) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 10:6) - (0 ? + 10:6) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 10:6) - (0 ? + 10:6) + 1))))))) << (0 ? + 10:6))) | (((gctUINT32) ((gctUINT32) (_GETBITS(Extended, 4, 0)) & ((gctUINT32) ((((1 ? + 10:6) - (0 ? + 10:6) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 10:6) - (0 ? 10:6) + 1))))))) << (0 ? 10:6))); + break; + + default: + break; + } + + if (Type != GCREG_SH_INSTRUCTION_TYPE_INVALID) + { + gcmkONERROR(gckPPU_SetInstructionType(Type, Inst)); + } + + gcmkONERROR(gckPPU_IsEndOfBB(Hardware, OpCode, Inst)); + + return gcvSTATUS_OK; + +OnError: + return status; +} + +static gceSTATUS +gckPPU_SetDestination( + IN gctUINT32 Address, + IN gctUINT32 WriteEnable, + IN gctUINT32 Saturate, + IN OUT gctUINT32_PTR Inst + ) +{ + gceSTATUS status = gcvSTATUS_OK; + + if (!Inst) + { + gcmkONERROR(gcvSTATUS_INVALID_ARGUMENT); + } + + Inst[0] = ((((gctUINT32) (Inst[0])) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 12:12) - (0 ? + 12:12) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 12:12) - (0 ? + 12:12) + 1))))))) << (0 ? + 12:12))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 12:12) - (0 ? + 12:12) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 12:12) - (0 ? 12:12) + 1))))))) << (0 ? 12:12))); + Inst[0] = ((((gctUINT32) (Inst[0])) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 22:16) - (0 ? + 22:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 22:16) - (0 ? + 22:16) + 1))))))) << (0 ? + 22:16))) | (((gctUINT32) ((gctUINT32) (Address) & ((gctUINT32) ((((1 ? + 22:16) - (0 ? + 22:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 22:16) - (0 ? 22:16) + 1))))))) << (0 ? 22:16))); + Inst[0] = ((((gctUINT32) (Inst[0])) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 26:23) - (0 ? + 26:23) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 26:23) - (0 ? + 26:23) + 1))))))) << (0 ? + 26:23))) | (((gctUINT32) ((gctUINT32) (WriteEnable) & ((gctUINT32) ((((1 ? + 26:23) - (0 ? + 26:23) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 26:23) - (0 ? 26:23) + 1))))))) << (0 ? 26:23))); + Inst[0] = ((((gctUINT32) (Inst[0])) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 11:11) - (0 ? + 11:11) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 11:11) - (0 ? + 11:11) + 1))))))) << (0 ? + 11:11))) | (((gctUINT32) ((gctUINT32) (Saturate) & ((gctUINT32) ((((1 ? + 11:11) - (0 ? + 11:11) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 11:11) - (0 ? 11:11) + 1))))))) << (0 ? 11:11))); + + return gcvSTATUS_OK; + +OnError: + return status; +} + +#define gcdVX_ENABLE ((1 << 0) | (1 << 1) | (1 << 2) | (1 << 3)) +#define gcdVX_ENABLE4(X, Y, Z, W) ((1 << (X)) | (1 << (Y)) | (1 << (Z)) | (1 << (W))) +#define gcdVX_ENABLE1(X) (1 << (X)) +#define gcdVX_ENABLE2(X, Y) ((1 << (X)) | (1 << (Y))) +#define gcdVX_ENABLE3(X, Y, Z) ((1 << (X)) | (1 << (Y)) | (1 << (Z))) +#define gcdVX_SWIZZLE (0 | (1 << 2) | (2 << 4) | (3 << 6)) +#define gcdVX_SWIZZLE1(X) ((X) | ((X) << 2) | ((X) << 4) | ((X) << 6)) +#define gcdVX_SWIZZLE2(X, Y) ((X) | ((Y) << 2) | ((Y) << 4) | ((Y) << 6)) +#define gcdVX_SWIZZLE4(X, Y, Z, W) ((X) | ((Y) << 2) | ((Z) << 4) | ((W) << 6)) + +static gctUINT32 +gckPPU_GetPixel( + IN gctUINT32 Format + ) +{ + gctUINT32 pixel = 0; + + switch(Format) + { + case 0x7: + pixel = 15; + break; + + case 0x3: + case 0x6: + pixel = 7; + break; + + default: + pixel = 15; + break; + } + + return pixel; +} + +gceSTATUS +gckPPU_SetEVIS( + IN gctUINT32 Start, + IN gctUINT32 End, + IN gctUINT32 Evis, + IN OUT gctUINT32_PTR Inst + ) +{ + gceSTATUS status = gcvSTATUS_OK; + + if (!Inst) + { + gcmkONERROR(gcvSTATUS_INVALID_ARGUMENT); + } + + Inst[0] = ((((gctUINT32) (Inst[0])) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 26:23) - (0 ? + 26:23) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 26:23) - (0 ? + 26:23) + 1))))))) << (0 ? + 26:23))) | (((gctUINT32) ((gctUINT32) (Start) & ((gctUINT32) ((((1 ? + 26:23) - (0 ? + 26:23) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 26:23) - (0 ? 26:23) + 1))))))) << (0 ? 26:23))); + Inst[0] = _SETBITS(Inst[0], 30, 27, End); + Inst[1] = _SETBITS(Inst[1], 10, 2, Evis); + + return gcvSTATUS_OK; + +OnError: + return status; +} + +static gceSTATUS +gckPPU_SetSource( + IN gctUINT32 Where, + IN gctUINT32 Address, + IN gctUINT32 Swizzle, + IN gctUINT32 Type, + IN gctBOOL Negate, + IN gctBOOL Absolute, + IN gctUINT32 Relative, + IN OUT gctUINT32_PTR Inst + ) +{ + gceSTATUS status = gcvSTATUS_OK; + + if (!Inst) + { + gcmkONERROR(gcvSTATUS_INVALID_ARGUMENT); + } + + switch (Where) + { + case 0: + Inst[1] = ((((gctUINT32) (Inst[1])) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 11:11) - (0 ? + 11:11) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 11:11) - (0 ? + 11:11) + 1))))))) << (0 ? + 11:11))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 11:11) - (0 ? + 11:11) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 11:11) - (0 ? 11:11) + 1))))))) << (0 ? 11:11))); + Inst[1] = ((((gctUINT32) (Inst[1])) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 20:12) - (0 ? + 20:12) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 20:12) - (0 ? + 20:12) + 1))))))) << (0 ? + 20:12))) | (((gctUINT32) ((gctUINT32) (Address) & ((gctUINT32) ((((1 ? + 20:12) - (0 ? + 20:12) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 20:12) - (0 ? 20:12) + 1))))))) << (0 ? 20:12))); + Inst[1] = ((((gctUINT32) (Inst[1])) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 29:22) - (0 ? + 29:22) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 29:22) - (0 ? + 29:22) + 1))))))) << (0 ? + 29:22))) | (((gctUINT32) ((gctUINT32) (Swizzle) & ((gctUINT32) ((((1 ? + 29:22) - (0 ? + 29:22) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 29:22) - (0 ? 29:22) + 1))))))) << (0 ? 29:22))); + Inst[1] = ((((gctUINT32) (Inst[1])) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 30:30) - (0 ? + 30:30) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 30:30) - (0 ? + 30:30) + 1))))))) << (0 ? + 30:30))) | (((gctUINT32) ((gctUINT32) (Negate) & ((gctUINT32) ((((1 ? + 30:30) - (0 ? + 30:30) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 30:30) - (0 ? 30:30) + 1))))))) << (0 ? 30:30))); + Inst[1] = ((((gctUINT32) (Inst[1])) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:31) - (0 ? + 31:31) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:31) - (0 ? + 31:31) + 1))))))) << (0 ? + 31:31))) | (((gctUINT32) ((gctUINT32) (Absolute) & ((gctUINT32) ((((1 ? + 31:31) - (0 ? + 31:31) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:31) - (0 ? 31:31) + 1))))))) << (0 ? 31:31))); + Inst[2] = ((((gctUINT32) (Inst[2])) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 2:0) - (0 ? + 2:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 2:0) - (0 ? + 2:0) + 1))))))) << (0 ? + 2:0))) | (((gctUINT32) ((gctUINT32) (Relative) & ((gctUINT32) ((((1 ? + 2:0) - (0 ? + 2:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 2:0) - (0 ? 2:0) + 1))))))) << (0 ? 2:0))); + Inst[2] = ((((gctUINT32) (Inst[2])) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 5:3) - (0 ? + 5:3) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 5:3) - (0 ? + 5:3) + 1))))))) << (0 ? + 5:3))) | (((gctUINT32) ((gctUINT32) (Type) & ((gctUINT32) ((((1 ? + 5:3) - (0 ? + 5:3) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 5:3) - (0 ? 5:3) + 1))))))) << (0 ? 5:3))); + break; + + case 1: + Inst[2] = ((((gctUINT32) (Inst[2])) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 6:6) - (0 ? + 6:6) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 6:6) - (0 ? + 6:6) + 1))))))) << (0 ? + 6:6))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 6:6) - (0 ? + 6:6) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 6:6) - (0 ? 6:6) + 1))))))) << (0 ? 6:6))); + Inst[2] = ((((gctUINT32) (Inst[2])) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:7) - (0 ? + 15:7) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:7) - (0 ? + 15:7) + 1))))))) << (0 ? + 15:7))) | (((gctUINT32) ((gctUINT32) (Address) & ((gctUINT32) ((((1 ? + 15:7) - (0 ? + 15:7) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:7) - (0 ? 15:7) + 1))))))) << (0 ? 15:7))); + Inst[2] = ((((gctUINT32) (Inst[2])) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 24:17) - (0 ? + 24:17) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 24:17) - (0 ? + 24:17) + 1))))))) << (0 ? + 24:17))) | (((gctUINT32) ((gctUINT32) (Swizzle) & ((gctUINT32) ((((1 ? + 24:17) - (0 ? + 24:17) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 24:17) - (0 ? 24:17) + 1))))))) << (0 ? 24:17))); + Inst[2] = ((((gctUINT32) (Inst[2])) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:25) - (0 ? + 25:25) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:25) - (0 ? + 25:25) + 1))))))) << (0 ? + 25:25))) | (((gctUINT32) ((gctUINT32) (Negate) & ((gctUINT32) ((((1 ? + 25:25) - (0 ? + 25:25) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:25) - (0 ? 25:25) + 1))))))) << (0 ? 25:25))); + Inst[2] = ((((gctUINT32) (Inst[2])) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 26:26) - (0 ? + 26:26) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 26:26) - (0 ? + 26:26) + 1))))))) << (0 ? + 26:26))) | (((gctUINT32) ((gctUINT32) (Absolute) & ((gctUINT32) ((((1 ? + 26:26) - (0 ? + 26:26) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 26:26) - (0 ? 26:26) + 1))))))) << (0 ? 26:26))); + Inst[2] = ((((gctUINT32) (Inst[2])) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 29:27) - (0 ? + 29:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 29:27) - (0 ? + 29:27) + 1))))))) << (0 ? + 29:27))) | (((gctUINT32) ((gctUINT32) (Relative) & ((gctUINT32) ((((1 ? + 29:27) - (0 ? + 29:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 29:27) - (0 ? 29:27) + 1))))))) << (0 ? 29:27))); + Inst[3] = ((((gctUINT32) (Inst[3])) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 2:0) - (0 ? + 2:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 2:0) - (0 ? + 2:0) + 1))))))) << (0 ? + 2:0))) | (((gctUINT32) ((gctUINT32) (Type) & ((gctUINT32) ((((1 ? + 2:0) - (0 ? + 2:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 2:0) - (0 ? 2:0) + 1))))))) << (0 ? 2:0))); + break; + + case 2: + Inst[3] = ((((gctUINT32) (Inst[3])) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 3:3) - (0 ? + 3:3) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 3:3) - (0 ? + 3:3) + 1))))))) << (0 ? + 3:3))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 3:3) - (0 ? + 3:3) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 3:3) - (0 ? 3:3) + 1))))))) << (0 ? 3:3))); + Inst[3] = ((((gctUINT32) (Inst[3])) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 12:4) - (0 ? + 12:4) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 12:4) - (0 ? + 12:4) + 1))))))) << (0 ? + 12:4))) | (((gctUINT32) ((gctUINT32) (Address) & ((gctUINT32) ((((1 ? + 12:4) - (0 ? + 12:4) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 12:4) - (0 ? 12:4) + 1))))))) << (0 ? 12:4))); + Inst[3] = ((((gctUINT32) (Inst[3])) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 21:14) - (0 ? + 21:14) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 21:14) - (0 ? + 21:14) + 1))))))) << (0 ? + 21:14))) | (((gctUINT32) ((gctUINT32) (Swizzle) & ((gctUINT32) ((((1 ? + 21:14) - (0 ? + 21:14) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 21:14) - (0 ? 21:14) + 1))))))) << (0 ? 21:14))); + Inst[3] = ((((gctUINT32) (Inst[3])) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 22:22) - (0 ? + 22:22) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 22:22) - (0 ? + 22:22) + 1))))))) << (0 ? + 22:22))) | (((gctUINT32) ((gctUINT32) (Negate) & ((gctUINT32) ((((1 ? + 22:22) - (0 ? + 22:22) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 22:22) - (0 ? 22:22) + 1))))))) << (0 ? 22:22))); + Inst[3] = ((((gctUINT32) (Inst[3])) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 23:23) - (0 ? + 23:23) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 23:23) - (0 ? + 23:23) + 1))))))) << (0 ? + 23:23))) | (((gctUINT32) ((gctUINT32) (Absolute) & ((gctUINT32) ((((1 ? + 23:23) - (0 ? + 23:23) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 23:23) - (0 ? 23:23) + 1))))))) << (0 ? 23:23))); + Inst[3] = ((((gctUINT32) (Inst[3])) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 27:25) - (0 ? + 27:25) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 27:25) - (0 ? + 27:25) + 1))))))) << (0 ? + 27:25))) | (((gctUINT32) ((gctUINT32) (Relative) & ((gctUINT32) ((((1 ? + 27:25) - (0 ? + 27:25) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 27:25) - (0 ? 27:25) + 1))))))) << (0 ? 27:25))); + Inst[3] = ((((gctUINT32) (Inst[3])) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 30:28) - (0 ? + 30:28) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 30:28) - (0 ? + 30:28) + 1))))))) << (0 ? + 30:28))) | (((gctUINT32) ((gctUINT32) (Type) & ((gctUINT32) ((((1 ? + 30:28) - (0 ? + 30:28) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 30:28) - (0 ? 30:28) + 1))))))) << (0 ? 30:28))); + break; + + default: + gcmkONERROR(gcvSTATUS_INVALID_ARGUMENT); + break; + } + + return gcvSTATUS_OK; + +OnError: + return status; +} + +static const gctUINT32 NEGATE_FLAG = 1 << 0; +static const gctUINT32 ABSOLUTE_FLAG = 1 << 1; + +static gceSTATUS +gckPPU_SetUniform( + IN gctUINT32 Where, + IN gctUINT32 Address, + IN gctUINT32 Swizzle, + IN gctUINT32 Modifiers, + OUT gctUINT32_PTR Inst + ) +{ + gceSTATUS status = gcvSTATUS_OK; + + gctBOOL negate = (Modifiers & NEGATE_FLAG) ? gcvTRUE : gcvFALSE; + gctBOOL absolute = (Modifiers & ABSOLUTE_FLAG) ? gcvTRUE : gcvFALSE; + + if (!Inst) + { + gcmkONERROR(gcvSTATUS_INVALID_ARGUMENT); + } + + gcmkONERROR(gckPPU_SetSource( + Where, + Address, + Swizzle, + 0x2, + negate, + absolute, + 0, + Inst + )); + + return gcvSTATUS_OK; + +OnError: + return status; +} + +gceSTATUS +gckPPU_SetTempReg( + IN gctUINT32 Where, + IN gctUINT32 Address, + IN gctUINT32 Swizzle, + IN gctUINT32 Modifiers, + OUT gctUINT32_PTR Inst + ) +{ + gceSTATUS status = gcvSTATUS_OK; + + gctBOOL negate = (Modifiers & NEGATE_FLAG) ? gcvTRUE : gcvFALSE; + gctBOOL absolute = (Modifiers & ABSOLUTE_FLAG) ? gcvTRUE : gcvFALSE; + + if (!Inst) + { + gcmkONERROR(gcvSTATUS_INVALID_ARGUMENT); + } + + gcmkONERROR(gckPPU_SetSource( + Where, + Address, + Swizzle, + 0x0, + negate, + absolute, + 0, + Inst + )); + + return gcvSTATUS_OK; + +OnError: + return status; +} + + +static gceSTATUS +_ProgramPPUInstruction( + IN gckHARDWARE Hardware, + IN gctUINT32 DataType, + IN gctUINT32 AllocFlag, + IN OUT gcePOOL *Pool, + OUT gctUINT32 *InstCount, + OUT gctUINT32 *RegCount, + OUT gcsFUNCTION_EXECUTION_DATA *Data + ) +{ + gceSTATUS status = gcvSTATUS_OK; + + gckVIDMEM_NODE bufferNode = gcvNULL; + gctPOINTER bufferLogical = gcvNULL; + gctUINT32 bufferAddress = 0; + gctSIZE_T bufferBytes, bytes; + + gctUINT32 instCount = 0; + gctUINT32_PTR inst = gcvNULL; + + gctUINT32 inImage1DataType = DataType; + gctUINT32 inImage2DataType = DataType; + gctUINT32 outImageDataType = DataType; + + if (!Data || !InstCount || !RegCount) + { + gcmkONERROR(gcvSTATUS_INVALID_ARGUMENT); + } + + bufferBytes = bytes = gcmSIZEOF(gctUINT32) * MAX_PPU_INSTRUCTION_COUNT; + + gcmkONERROR(_AllocateVideoMemory( + Hardware->kernel, + gcvVIDMEM_TYPE_COMMAND, + AllocFlag, + Pool, + &bufferBytes, + &bufferNode, + &bufferLogical, + &bufferAddress + )); + + inst = (gctUINT32_PTR)bufferLogical; + + /* img_load.u8 r1, c0, r0.xy */ + gcmkONERROR(gckPPU_AddOpCode(Hardware, 0x79, 0, inImage1DataType, &inst[instCount])); + gcmkONERROR(gckPPU_SetDestination(1, gcdVX_ENABLE, gcvFALSE, &inst[instCount])); + gcmkONERROR(gckPPU_SetEVIS(0, gckPPU_GetPixel(inImage1DataType), 1, &inst[instCount])); + gcmkONERROR(gckPPU_SetUniform(0, 0, gcdVX_SWIZZLE, 0, &inst[instCount])); + gcmkONERROR(gckPPU_SetTempReg(1, 0, gcdVX_SWIZZLE2(0, 1), 0, &inst[instCount])); + instCount += 4; + + /*img_load.u8 r2, c0, r0.xy */ + gcmkONERROR(gckPPU_AddOpCode(Hardware, 0x79, 0, inImage2DataType, &inst[instCount])); + gcmkONERROR(gckPPU_SetDestination(2, gcdVX_ENABLE, gcvFALSE, &inst[instCount])); + gcmkONERROR(gckPPU_SetEVIS(0, gckPPU_GetPixel(inImage2DataType), 1, &inst[instCount])); + gcmkONERROR(gckPPU_SetUniform(0, 0, gcdVX_SWIZZLE, 0, &inst[instCount])); + gcmkONERROR(gckPPU_SetTempReg(1, 0, gcdVX_SWIZZLE2(0, 1), 0, &inst[instCount])); + instCount += 4; + + /* dp2x8 r1, r1, r2, c3_512 */ + gcmkONERROR(gckPPU_AddOpCode(Hardware, 0x45, 0x0B, outImageDataType, &inst[instCount])); + gcmkONERROR(gckPPU_SetDestination(1, gcdVX_ENABLE, gcvFALSE, &inst[instCount])); + gcmkONERROR(gckPPU_SetEVIS(0, 7, (inImage1DataType | (inImage2DataType << 3)), &inst[instCount])); + gcmkONERROR(gckPPU_SetTempReg(0, 1, gcdVX_SWIZZLE, 0, &inst[instCount])); + gcmkONERROR(gckPPU_SetTempReg(1, 2, gcdVX_SWIZZLE, 0, &inst[instCount])); + gcmkONERROR(gckPPU_SetSource (2, 2, gcdVX_SWIZZLE, 0x4, gcvFALSE, gcvFALSE, 0, &inst[instCount])); + instCount += 4; + + /* img_store.u8 r1, c2, r0.xy, r1 */ + gcmkONERROR(gckPPU_AddOpCode(Hardware, 0x7A, 0, outImageDataType, &inst[instCount])); + gcmkONERROR(gckPPU_SetEVIS(0, gckPPU_GetPixel(outImageDataType), 1, &inst[instCount])); + gcmkONERROR(gckPPU_SetUniform(0, 1, gcdVX_SWIZZLE, 0, &inst[instCount])); + gcmkONERROR(gckPPU_SetTempReg(1, 0, gcdVX_SWIZZLE2(0, 1), 0, &inst[instCount])); + gcmkONERROR(gckPPU_SetTempReg(2, 1, gcdVX_SWIZZLE, 0, &inst[instCount])); + instCount += 4; + + bytes = gcmSIZEOF(gctUINT32) * instCount; + + gcmkONERROR(gckVIDMEM_NODE_CleanCache( + Hardware->kernel, + bufferNode, + 0, + bufferLogical, + bytes + )); + +#if gcdDUMP_IN_KERNEL + gcmkDUMP(Hardware->os, "#[flop reset: ppu instruction]"); + gcmkDUMP_BUFFER( + Hardware->os, + gcvDUMP_BUFFER_KERNEL_COMMAND, + bufferLogical, + bufferAddress, + bytes + ); +#endif + + *InstCount = instCount; + *RegCount = 0x3; + + Data->bufVidMem = bufferNode; + Data->bufVidMemBytes = bufferBytes; + Data->address = bufferAddress; + Data->logical = bufferLogical; + Data->bytes = bytes; + + return gcvSTATUS_OK; + +OnError: + if (bufferNode) + { + gcmkVERIFY_OK(_FreeVideoMemory( + Hardware->kernel, + bufferNode + )); + } + + return status; +} + +static gceSTATUS +_ProgramPPUCommand( + IN gckHARDWARE Hardware, + IN gctUINT32 Stride, + IN gctUINT32 Width, + IN gctUINT32 Height, + IN gctUINT32 WorkDim, + IN gctUINT32 ValueOrder, + IN gctUINT32 GroupSizeX, + IN gctUINT32 GroupSizeY, + IN gctUINT32 GroupSizeZ, + IN gctUINT32 GlobalScaleX, + IN gctUINT32 GlobalScaleY, + IN gctUINT32 GlobalScaleZ, + IN gctUINT32 GlobalOffsetX, + IN gctUINT32 GlobalOffsetY, + IN gctUINT32 GlobalOffsetZ, + IN gctUINT32 ThreadAllocation, + IN gctUINT32 InImageAddress, + IN gctUINT32 OutImageAddress, + IN gctUINT32 InstAddress, + IN gctUINT32 InstCount, + IN gctUINT32 RegCount, + IN gctUINT32 AllocFlag, + IN OUT gcePOOL *Pool, + OUT gcsFUNCTION_COMMAND_PTR Command + ) +{ + gceSTATUS status = gcvSTATUS_OK; + + gckVIDMEM_NODE bufferNode = gcvNULL; + gctPOINTER bufferLogical = gcvNULL; + gctUINT32 bufferAddress = 0; + gctSIZE_T bufferBytes = 0; + gctUINT32 bytes = 0; + gctUINT8_PTR endLogical; + gctUINT32 endAddress; + gctUINT32 endBytes = 0; + gctUINT32_PTR commands = gcvNULL; + gctUINT32 index = 0; + gctUINT32 groupCountX = (Width + GlobalScaleX - 1) / GlobalScaleX; + gctUINT32 groupCountY = (Height + GlobalScaleY - 1) / GlobalScaleY; + gctUINT32 groupCountZ = 0; + + if (!Command) + { + gcmkONERROR(gcvSTATUS_INVALID_ARGUMENT); + } + + bufferBytes = gcmSIZEOF(gctUINT32) * MAX_PPU_COMMAND_NUM; + + gcmkONERROR(_AllocateVideoMemory( + Hardware->kernel, + gcvVIDMEM_TYPE_COMMAND, + AllocFlag, + Pool, + &bufferBytes, + &bufferNode, + &bufferLogical, + &bufferAddress + )); + + commands = (gctUINT32_PTR)bufferLogical; + + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0E13) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 1:0) - (0 ? + 1:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 1:0) - (0 ? + 1:0) + 1))))))) << (0 ? + 1:0))) | (((gctUINT32) (0x2 & ((gctUINT32) ((((1 ? + 1:0) - (0 ? + 1:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 1:0) - (0 ? 1:0) + 1))))))) << (0 ? 1:0))); + + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0E02) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 4:0) - (0 ? + 4:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 4:0) - (0 ? + 4:0) + 1))))))) << (0 ? + 4:0))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 4:0) - (0 ? + 4:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 4:0) - (0 ? 4:0) + 1))))))) << (0 ? 4:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 12:8) - (0 ? + 12:8) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 12:8) - (0 ? + 12:8) + 1))))))) << (0 ? + 12:8))) | (((gctUINT32) (0x07 & ((gctUINT32) ((((1 ? + 12:8) - (0 ? + 12:8) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 12:8) - (0 ? 12:8) + 1))))))) << (0 ? 12:8))); + + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x09 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))); + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 4:0) - (0 ? + 4:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 4:0) - (0 ? + 4:0) + 1))))))) << (0 ? + 4:0))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 4:0) - (0 ? + 4:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 4:0) - (0 ? 4:0) + 1))))))) << (0 ? 4:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 12:8) - (0 ? + 12:8) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 12:8) - (0 ? + 12:8) + 1))))))) << (0 ? + 12:8))) | (((gctUINT32) (0x07 & ((gctUINT32) ((((1 ? + 12:8) - (0 ? + 12:8) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 12:8) - (0 ? 12:8) + 1))))))) << (0 ? 12:8))); + + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0xD800) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (4) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + commands[index++] = InImageAddress; + commands[index++] = Stride; + commands[index++] = Height << 16 | Width; + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 2:0) - (0 ? + 2:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 2:0) - (0 ? + 2:0) + 1))))))) << (0 ? + 2:0))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 2:0) - (0 ? + 2:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 2:0) - (0 ? 2:0) + 1))))))) << (0 ? 2:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 3:3) - (0 ? + 3:3) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 3:3) - (0 ? + 3:3) + 1))))))) << (0 ? + 3:3))) | (((gctUINT32) ((gctUINT32) (0x0) & ((gctUINT32) ((((1 ? + 3:3) - (0 ? + 3:3) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 3:3) - (0 ? 3:3) + 1))))))) << (0 ? 3:3))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 5:4) - (0 ? + 5:4) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 5:4) - (0 ? + 5:4) + 1))))))) << (0 ? + 5:4))) | (((gctUINT32) ((gctUINT32) (0x3) & ((gctUINT32) ((((1 ? + 5:4) - (0 ? + 5:4) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 5:4) - (0 ? 5:4) + 1))))))) << (0 ? 5:4))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 9:6) - (0 ? + 9:6) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 9:6) - (0 ? + 9:6) + 1))))))) << (0 ? + 9:6))) | (((gctUINT32) ((gctUINT32) (0x7) & ((gctUINT32) ((((1 ? + 9:6) - (0 ? + 9:6) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 9:6) - (0 ? 9:6) + 1))))))) << (0 ? 9:6))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 11:10) - (0 ? + 11:10) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 11:10) - (0 ? + 11:10) + 1))))))) << (0 ? + 11:10))) | (((gctUINT32) (0x0 & ((gctUINT32) ((((1 ? + 11:10) - (0 ? + 11:10) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 11:10) - (0 ? 11:10) + 1))))))) << (0 ? 11:10))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 12:12) - (0 ? + 12:12) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 12:12) - (0 ? + 12:12) + 1))))))) << (0 ? + 12:12))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 12:12) - (0 ? + 12:12) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 12:12) - (0 ? 12:12) + 1))))))) << (0 ? 12:12))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:14) - (0 ? + 15:14) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:14) - (0 ? + 15:14) + 1))))))) << (0 ? + 15:14))) | (((gctUINT32) ((gctUINT32) (0x1) & ((gctUINT32) ((((1 ? + 15:14) - (0 ? + 15:14) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:14) - (0 ? 15:14) + 1))))))) << (0 ? 15:14))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 18:16) - (0 ? + 18:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 18:16) - (0 ? + 18:16) + 1))))))) << (0 ? + 18:16))) | (((gctUINT32) ((gctUINT32) (0x0) & ((gctUINT32) ((((1 ? + 18:16) - (0 ? + 18:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 18:16) - (0 ? 18:16) + 1))))))) << (0 ? 18:16))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 22:20) - (0 ? + 22:20) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 22:20) - (0 ? + 22:20) + 1))))))) << (0 ? + 22:20))) | (((gctUINT32) ((gctUINT32) (0x4) & ((gctUINT32) ((((1 ? + 22:20) - (0 ? + 22:20) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 22:20) - (0 ? 22:20) + 1))))))) << (0 ? 22:20))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 26:24) - (0 ? + 26:24) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 26:24) - (0 ? + 26:24) + 1))))))) << (0 ? + 26:24))) | (((gctUINT32) ((gctUINT32) (0x4) & ((gctUINT32) ((((1 ? + 26:24) - (0 ? + 26:24) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 26:24) - (0 ? 26:24) + 1))))))) << (0 ? 26:24))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 30:28) - (0 ? + 30:28) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 30:28) - (0 ? + 30:28) + 1))))))) << (0 ? + 30:28))) | (((gctUINT32) ((gctUINT32) (0x4) & ((gctUINT32) ((((1 ? + 30:28) - (0 ? + 30:28) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 30:28) - (0 ? 30:28) + 1))))))) << (0 ? 30:28))); + + commands[index++] = 0xFFFFFFFF; + + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0xD800 + 0x04) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (4) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + commands[index++] = OutImageAddress; + commands[index++] = Stride; + commands[index++] = Height << 16 | Width; + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 2:0) - (0 ? + 2:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 2:0) - (0 ? + 2:0) + 1))))))) << (0 ? + 2:0))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 2:0) - (0 ? + 2:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 2:0) - (0 ? 2:0) + 1))))))) << (0 ? 2:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 3:3) - (0 ? + 3:3) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 3:3) - (0 ? + 3:3) + 1))))))) << (0 ? + 3:3))) | (((gctUINT32) ((gctUINT32) (0x0) & ((gctUINT32) ((((1 ? + 3:3) - (0 ? + 3:3) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 3:3) - (0 ? 3:3) + 1))))))) << (0 ? 3:3))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 5:4) - (0 ? + 5:4) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 5:4) - (0 ? + 5:4) + 1))))))) << (0 ? + 5:4))) | (((gctUINT32) ((gctUINT32) (0x3) & ((gctUINT32) ((((1 ? + 5:4) - (0 ? + 5:4) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 5:4) - (0 ? 5:4) + 1))))))) << (0 ? 5:4))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 9:6) - (0 ? + 9:6) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 9:6) - (0 ? + 9:6) + 1))))))) << (0 ? + 9:6))) | (((gctUINT32) ((gctUINT32) (0x7) & ((gctUINT32) ((((1 ? + 9:6) - (0 ? + 9:6) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 9:6) - (0 ? 9:6) + 1))))))) << (0 ? 9:6))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 11:10) - (0 ? + 11:10) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 11:10) - (0 ? + 11:10) + 1))))))) << (0 ? + 11:10))) | (((gctUINT32) (0x0 & ((gctUINT32) ((((1 ? + 11:10) - (0 ? + 11:10) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 11:10) - (0 ? 11:10) + 1))))))) << (0 ? 11:10))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 12:12) - (0 ? + 12:12) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 12:12) - (0 ? + 12:12) + 1))))))) << (0 ? + 12:12))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 12:12) - (0 ? + 12:12) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 12:12) - (0 ? 12:12) + 1))))))) << (0 ? 12:12))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:14) - (0 ? + 15:14) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:14) - (0 ? + 15:14) + 1))))))) << (0 ? + 15:14))) | (((gctUINT32) ((gctUINT32) (0x1) & ((gctUINT32) ((((1 ? + 15:14) - (0 ? + 15:14) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:14) - (0 ? 15:14) + 1))))))) << (0 ? 15:14))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 18:16) - (0 ? + 18:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 18:16) - (0 ? + 18:16) + 1))))))) << (0 ? + 18:16))) | (((gctUINT32) ((gctUINT32) (0x0) & ((gctUINT32) ((((1 ? + 18:16) - (0 ? + 18:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 18:16) - (0 ? 18:16) + 1))))))) << (0 ? 18:16))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 22:20) - (0 ? + 22:20) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 22:20) - (0 ? + 22:20) + 1))))))) << (0 ? + 22:20))) | (((gctUINT32) ((gctUINT32) (0x4) & ((gctUINT32) ((((1 ? + 22:20) - (0 ? + 22:20) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 22:20) - (0 ? 22:20) + 1))))))) << (0 ? 22:20))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 26:24) - (0 ? + 26:24) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 26:24) - (0 ? + 26:24) + 1))))))) << (0 ? + 26:24))) | (((gctUINT32) ((gctUINT32) (0x4) & ((gctUINT32) ((((1 ? + 26:24) - (0 ? + 26:24) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 26:24) - (0 ? 26:24) + 1))))))) << (0 ? 26:24))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 30:28) - (0 ? + 30:28) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 30:28) - (0 ? + 30:28) + 1))))))) << (0 ? + 30:28))) | (((gctUINT32) ((gctUINT32) (0x4) & ((gctUINT32) ((((1 ? + 30:28) - (0 ? + 30:28) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 30:28) - (0 ? 30:28) + 1))))))) << (0 ? 30:28))); + + commands[index++] = 0xFFFFFFFF; + + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0xD800 + 0x08) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (16) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + commands[index++] = 0x55555555; + commands[index++] = 0x00000000; /* TCfg. */ + commands[index++] = 0x01234567; + commands[index++] = 0x89abcdef; + commands[index++] = 0x55555555; + commands[index++] = 0x01234567; + commands[index++] = 0x89abcdef; /* BinSelect. */ + commands[index++] = 0x00000000; /* AccumType, ConstantType, and PostShift. */ + commands[index++] = 0x00000000; + commands[index++] = 0x00000000; + commands[index++] = 0x00000000; + commands[index++] = 0x00000000; + commands[index++] = 0x00000000; + commands[index++] = 0x00000000; + commands[index++] = 0x00000000; + commands[index++] = 0x00000000; /* Constant. */ + + commands[index++] = 0xFFFFFFFF; + + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0240) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 1:0) - (0 ? + 1:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 1:0) - (0 ? + 1:0) + 1))))))) << (0 ? + 1:0))) | (((gctUINT32) ((gctUINT32) (0x2) & ((gctUINT32) ((((1 ? + 1:0) - (0 ? + 1:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 1:0) - (0 ? 1:0) + 1))))))) << (0 ? 1:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 6:4) - (0 ? + 6:4) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 6:4) - (0 ? + 6:4) + 1))))))) << (0 ? + 6:4))) | (((gctUINT32) (0x0 & ((gctUINT32) ((((1 ? + 6:4) - (0 ? + 6:4) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 6:4) - (0 ? 6:4) + 1))))))) << (0 ? 6:4))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 26:24) - (0 ? + 26:24) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 26:24) - (0 ? + 26:24) + 1))))))) << (0 ? + 26:24))) | (((gctUINT32) ((gctUINT32) (0x2) & ((gctUINT32) ((((1 ? + 26:24) - (0 ? + 26:24) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 26:24) - (0 ? 26:24) + 1))))))) << (0 ? 26:24))); + + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x022C) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 0:0) - (0 ? + 0:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 0:0) - (0 ? + 0:0) + 1))))))) << (0 ? + 0:0))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 0:0) - (0 ? + 0:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 0:0) - (0 ? 0:0) + 1))))))) << (0 ? 0:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 1:1) - (0 ? + 1:1) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 1:1) - (0 ? + 1:1) + 1))))))) << (0 ? + 1:1))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 1:1) - (0 ? + 1:1) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 1:1) - (0 ? 1:1) + 1))))))) << (0 ? 1:1))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 2:2) - (0 ? + 2:2) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 2:2) - (0 ? + 2:2) + 1))))))) << (0 ? + 2:2))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 2:2) - (0 ? + 2:2) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 2:2) - (0 ? 2:2) + 1))))))) << (0 ? 2:2))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 3:3) - (0 ? + 3:3) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 3:3) - (0 ? + 3:3) + 1))))))) << (0 ? + 3:3))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 3:3) - (0 ? + 3:3) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 3:3) - (0 ? 3:3) + 1))))))) << (0 ? 3:3))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 4:4) - (0 ? + 4:4) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 4:4) - (0 ? + 4:4) + 1))))))) << (0 ? + 4:4))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 4:4) - (0 ? + 4:4) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 4:4) - (0 ? 4:4) + 1))))))) << (0 ? 4:4))); + + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0420) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 2:0) - (0 ? + 2:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 2:0) - (0 ? + 2:0) + 1))))))) << (0 ? + 2:0))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 2:0) - (0 ? + 2:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 2:0) - (0 ? 2:0) + 1))))))) << (0 ? 2:0))); + + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0403) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + commands[index++] = RegCount; + + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0416) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + commands[index++] = 0x00000000; + + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0409) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + commands[index++] = 0x00000000; + + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x021F) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + commands[index++] = 0x00000000; + + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0424) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + commands[index++] = InstCount / 4; + + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x040A) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + commands[index++] = InstAddress; + + if (gckHARDWARE_IsFeatureAvailable(Hardware, gcvFEATURE_HALTI5)) + { + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x5580) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 1:1) - (0 ? + 1:1) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 1:1) - (0 ? + 1:1) + 1))))))) << (0 ? + 1:1))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 1:1) - (0 ? + 1:1) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 1:1) - (0 ? 1:1) + 1))))))) << (0 ? 1:1))); + } + else + { + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0218) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 12:12) - (0 ? + 12:12) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 12:12) - (0 ? + 12:12) + 1))))))) << (0 ? + 12:12))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 12:12) - (0 ? + 12:12) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 12:12) - (0 ? 12:12) + 1))))))) << (0 ? 12:12))); + } + + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x021A) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 0:0) - (0 ? + 0:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 0:0) - (0 ? + 0:0) + 1))))))) << (0 ? + 0:0))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 0:0) - (0 ? + 0:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 0:0) - (0 ? 0:0) + 1))))))) << (0 ? 0:0))); + + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0425) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + commands[index++] = InstCount / 4 - 1; + + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0402) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 5:0) - (0 ? + 5:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 5:0) - (0 ? + 5:0) + 1))))))) << (0 ? + 5:0))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 5:0) - (0 ? + 5:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 5:0) - (0 ? 5:0) + 1))))))) << (0 ? 5:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 12:8) - (0 ? + 12:8) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 12:8) - (0 ? + 12:8) + 1))))))) << (0 ? + 12:8))) | (((gctUINT32) ((gctUINT32) (~0) & ((gctUINT32) ((((1 ? + 12:8) - (0 ? + 12:8) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 12:8) - (0 ? 12:8) + 1))))))) << (0 ? 12:8))); + + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0228) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + commands[index++] = 0x00000000; + + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x02AA) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + commands[index++] = 0x00000000; + + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0E07) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + commands[index++] = 0x00000000; + + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x040C) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + commands[index++] = 0x00000000; + + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0201) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 5:0) - (0 ? + 5:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 5:0) - (0 ? + 5:0) + 1))))))) << (0 ? + 5:0))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 5:0) - (0 ? + 5:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 5:0) - (0 ? 5:0) + 1))))))) << (0 ? 5:0))); + + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0E22) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + commands[index++] = 0x00000000; + + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0412) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + commands[index++] = 0x00000000; + + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0240) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 1:0) - (0 ? + 1:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 1:0) - (0 ? + 1:0) + 1))))))) << (0 ? + 1:0))) | (((gctUINT32) ((gctUINT32) (0x2) & ((gctUINT32) ((((1 ? + 1:0) - (0 ? + 1:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 1:0) - (0 ? 1:0) + 1))))))) << (0 ? 1:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 6:4) - (0 ? + 6:4) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 6:4) - (0 ? + 6:4) + 1))))))) << (0 ? + 6:4))) | (((gctUINT32) (0x0 & ((gctUINT32) ((((1 ? + 6:4) - (0 ? + 6:4) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 6:4) - (0 ? 6:4) + 1))))))) << (0 ? 6:4))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 26:24) - (0 ? + 26:24) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 26:24) - (0 ? + 26:24) + 1))))))) << (0 ? + 26:24))) | (((gctUINT32) ((gctUINT32) (0x3) & ((gctUINT32) ((((1 ? + 26:24) - (0 ? + 26:24) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 26:24) - (0 ? 26:24) + 1))))))) << (0 ? 26:24))); + + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0249) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + commands[index++] = 0x00000000; + + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0247) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + commands[index++] = ThreadAllocation; + + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x024B) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + commands[index++] = GlobalOffsetX; + + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x024D) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + commands[index++] = GlobalOffsetY; + + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x024F) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + commands[index++] = GlobalOffsetZ; + + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0256) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + commands[index++] = GlobalScaleX; + + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0257) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + commands[index++] = GlobalScaleY; + + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0258) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + commands[index++] = GlobalScaleZ; + + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0250) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (6) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + commands[index++] = groupCountX - 1; + commands[index++] = groupCountY - 1; + commands[index++] = groupCountZ - 1; + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 9:0) - (0 ? + 9:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 9:0) - (0 ? + 9:0) + 1))))))) << (0 ? + 9:0))) | (((gctUINT32) ((gctUINT32) (GroupSizeX - 1) & ((gctUINT32) ((((1 ? + 9:0) - (0 ? + 9:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 9:0) - (0 ? 9:0) + 1))))))) << (0 ? 9:0))); + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 9:0) - (0 ? + 9:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 9:0) - (0 ? + 9:0) + 1))))))) << (0 ? + 9:0))) | (((gctUINT32) ((gctUINT32) (GroupSizeY - 1) & ((gctUINT32) ((((1 ? + 9:0) - (0 ? + 9:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 9:0) - (0 ? 9:0) + 1))))))) << (0 ? 9:0))); + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 9:0) - (0 ? + 9:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 9:0) - (0 ? + 9:0) + 1))))))) << (0 ? + 9:0))) | (((gctUINT32) ((gctUINT32) (GroupSizeZ - 1) & ((gctUINT32) ((((1 ? + 9:0) - (0 ? + 9:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 9:0) - (0 ? 9:0) + 1))))))) << (0 ? 9:0))); + commands[index++] = 0x00000000; + + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0248) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + commands[index++] = 0xBADABEEB; + + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0E03) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 5:5) - (0 ? + 5:5) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 5:5) - (0 ? + 5:5) + 1))))))) << (0 ? + 5:5))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 5:5) - (0 ? + 5:5) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 5:5) - (0 ? 5:5) + 1))))))) << (0 ? 5:5))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 10:10) - (0 ? + 10:10) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 10:10) - (0 ? + 10:10) + 1))))))) << (0 ? + 10:10))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 10:10) - (0 ? + 10:10) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 10:10) - (0 ? 10:10) + 1))))))) << (0 ? 10:10))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 11:11) - (0 ? + 11:11) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 11:11) - (0 ? + 11:11) + 1))))))) << (0 ? + 11:11))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 11:11) - (0 ? + 11:11) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 11:11) - (0 ? 11:11) + 1))))))) << (0 ? 11:11))); + + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0E02) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 4:0) - (0 ? + 4:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 4:0) - (0 ? + 4:0) + 1))))))) << (0 ? + 4:0))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 4:0) - (0 ? + 4:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 4:0) - (0 ? 4:0) + 1))))))) << (0 ? 4:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 12:8) - (0 ? + 12:8) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 12:8) - (0 ? + 12:8) + 1))))))) << (0 ? + 12:8))) | (((gctUINT32) (0x07 & ((gctUINT32) ((((1 ? + 12:8) - (0 ? + 12:8) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 12:8) - (0 ? 12:8) + 1))))))) << (0 ? 12:8))); + + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x09 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))); + + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 4:0) - (0 ? + 4:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 4:0) - (0 ? + 4:0) + 1))))))) << (0 ? + 4:0))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 4:0) - (0 ? + 4:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 4:0) - (0 ? 4:0) + 1))))))) << (0 ? 4:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 12:8) - (0 ? + 12:8) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 12:8) - (0 ? + 12:8) + 1))))))) << (0 ? + 12:8))) | (((gctUINT32) (0x07 & ((gctUINT32) ((((1 ? + 12:8) - (0 ? + 12:8) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 12:8) - (0 ? 12:8) + 1))))))) << (0 ? 12:8))); + + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0E03) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 0:0) - (0 ? + 0:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 0:0) - (0 ? + 0:0) + 1))))))) << (0 ? + 0:0))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 0:0) - (0 ? + 0:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 0:0) - (0 ? 0:0) + 1))))))) << (0 ? 0:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 1:1) - (0 ? + 1:1) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 1:1) - (0 ? + 1:1) + 1))))))) << (0 ? + 1:1))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 1:1) - (0 ? + 1:1) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 1:1) - (0 ? 1:1) + 1))))))) << (0 ? 1:1))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 5:5) - (0 ? + 5:5) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 5:5) - (0 ? + 5:5) + 1))))))) << (0 ? + 5:5))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 5:5) - (0 ? + 5:5) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 5:5) - (0 ? 5:5) + 1))))))) << (0 ? 5:5))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 10:10) - (0 ? + 10:10) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 10:10) - (0 ? + 10:10) + 1))))))) << (0 ? + 10:10))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 10:10) - (0 ? + 10:10) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 10:10) - (0 ? 10:10) + 1))))))) << (0 ? 10:10))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 11:11) - (0 ? + 11:11) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 11:11) - (0 ? + 11:11) + 1))))))) << (0 ? + 11:11))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 11:11) - (0 ? + 11:11) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 11:11) - (0 ? 11:11) + 1))))))) << (0 ? 11:11))); + + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0E03) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 0:0) - (0 ? + 0:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 0:0) - (0 ? + 0:0) + 1))))))) << (0 ? + 0:0))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 0:0) - (0 ? + 0:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 0:0) - (0 ? 0:0) + 1))))))) << (0 ? 0:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 1:1) - (0 ? + 1:1) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 1:1) - (0 ? + 1:1) + 1))))))) << (0 ? + 1:1))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 1:1) - (0 ? + 1:1) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 1:1) - (0 ? 1:1) + 1))))))) << (0 ? 1:1))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 5:5) - (0 ? + 5:5) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 5:5) - (0 ? + 5:5) + 1))))))) << (0 ? + 5:5))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 5:5) - (0 ? + 5:5) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 5:5) - (0 ? 5:5) + 1))))))) << (0 ? 5:5))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 10:10) - (0 ? + 10:10) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 10:10) - (0 ? + 10:10) + 1))))))) << (0 ? + 10:10))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 10:10) - (0 ? + 10:10) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 10:10) - (0 ? 10:10) + 1))))))) << (0 ? 10:10))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 11:11) - (0 ? + 11:11) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 11:11) - (0 ? + 11:11) + 1))))))) << (0 ? + 11:11))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 11:11) - (0 ? + 11:11) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 11:11) - (0 ? 11:11) + 1))))))) << (0 ? 11:11))); + + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0594) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 0:0) - (0 ? + 0:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 0:0) - (0 ? + 0:0) + 1))))))) << (0 ? + 0:0))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 0:0) - (0 ? + 0:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 0:0) - (0 ? 0:0) + 1))))))) << (0 ? 0:0))); + + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0E03) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 0:0) - (0 ? + 0:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 0:0) - (0 ? + 0:0) + 1))))))) << (0 ? + 0:0))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 0:0) - (0 ? + 0:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 0:0) - (0 ? 0:0) + 1))))))) << (0 ? 0:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 1:1) - (0 ? + 1:1) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 1:1) - (0 ? + 1:1) + 1))))))) << (0 ? + 1:1))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 1:1) - (0 ? + 1:1) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 1:1) - (0 ? 1:1) + 1))))))) << (0 ? 1:1))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 5:5) - (0 ? + 5:5) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 5:5) - (0 ? + 5:5) + 1))))))) << (0 ? + 5:5))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 5:5) - (0 ? + 5:5) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 5:5) - (0 ? 5:5) + 1))))))) << (0 ? 5:5))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 10:10) - (0 ? + 10:10) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 10:10) - (0 ? + 10:10) + 1))))))) << (0 ? + 10:10))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 10:10) - (0 ? + 10:10) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 10:10) - (0 ? 10:10) + 1))))))) << (0 ? 10:10))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 11:11) - (0 ? + 11:11) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 11:11) - (0 ? + 11:11) + 1))))))) << (0 ? + 11:11))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 11:11) - (0 ? + 11:11) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 11:11) - (0 ? 11:11) + 1))))))) << (0 ? 11:11))); + + bytes = gcmSIZEOF(gctUINT32) * index; + + endLogical = (gctUINT8_PTR)bufferLogical + bytes; + endAddress = bufferAddress + bytes; + + if (Hardware->wlFE) + { + gcmkONERROR(gckWLFE_End(Hardware, gcvNULL, ~0U, &endBytes)); + gcmkONERROR(gckWLFE_End(Hardware, endLogical, endAddress, &endBytes)); + } + + bytes += endBytes; + + gcmkASSERT(bytes <= bufferBytes); + + gcmkONERROR(gckVIDMEM_NODE_CleanCache( + Hardware->kernel, + bufferNode, + 0, + bufferLogical, + bytes + )); + + Command->funcVidMem = bufferNode; + Command->funcVidMemBytes = bufferBytes; + Command->logical = bufferLogical; + Command->address = bufferAddress; + Command->bytes = bytes; + Command->endAddress = endAddress; + Command->endLogical = endLogical; + + return gcvSTATUS_OK; + +OnError: + if (bufferNode) + { + gcmkVERIFY_OK(_FreeVideoMemory( + Hardware->kernel, + bufferNode + )); + } + + return status; +} + +/* +** gckHARDWARE_ResetFlopWithPPU +** +** Generate the command to do PPU program as follows. +** InImage: 64x6 = {1}, unsigned int8 +** OutImage: 64x6, unsigned int8 +** OutImage = InImage + InImage +** +** INPUT: +** +** gckHARDWARE Hardware +** +** gctUINT32 AllocFlag +** +** gcePOOL *Pool +** +** OUTPUT: +** +** gcePOOL *Pool +** +** gcsFUNCTION_COMMAND *Command +*/ +gceSTATUS +gckHARDWARE_ResetFlopWithPPU( + IN gckHARDWARE Hardware, + IN gctUINT32 AllocFlag, + IN OUT gcePOOL *Pool, + OUT gcsFUNCTION_COMMAND *Command + ) +{ + gceSTATUS status = gcvSTATUS_OK; + + gctUINT32 dataType = 0x7; + gcsFEATURE_DATABASE *database = gcvNULL; + gctUINT32 numShaderCores; + gctUINT32 stride, width, height; + gctUINT32 workDim; + gctUINT32 valueOrder; + gctUINT32 groupSizeX, groupSizeY, groupSizeZ; + gctUINT32 globalScaleX, globalScaleY, globalScaleZ; + gctUINT32 globalOffsetX, globalOffsetY, globalOffsetZ; + gctUINT32 threadAllocation; + gctUINT32 inImageAddress = 0, outImageAddress = 0, instAddress = 0; + gctUINT32 instCount = 0, regCount = 0; + gctUINT32 dataCount; + gctPOINTER pointer = gcvNULL; + gcsFUNCTION_EXECUTION_DATA *data = gcvNULL; + gctUINT32 i; + + /* Exectution data. */ + dataCount = gcvFLOP_RESET_PPU_DATA_NUM; + gcmkASSERT(dataCount > 0); + + gcmkONERROR(gckOS_Allocate( + Hardware->os, + gcmSIZEOF(gcsFUNCTION_EXECUTION_DATA) * dataCount, + &pointer + )); + gckOS_ZeroMemory(pointer, gcmSIZEOF(gcsFUNCTION_EXECUTION_DATA) * dataCount); + data = (gcsFUNCTION_EXECUTION_DATA_PTR)pointer; + + database = (gcsFEATURE_DATABASE *)Hardware->featureDatabase; + + numShaderCores = database->NumShaderCores; + + stride = PPU_IMAGE_XSIZE * 1; + width = PPU_IMAGE_XSIZE; + height = PPU_IMAGE_YSIZE; + + gcmkONERROR(_ProgramPPUInput( + Hardware, + width, + height, + AllocFlag, + Pool, + &data[gcvFLOP_RESET_PPU_INPUT] + )); + + gcmkONERROR(_ProgramPPUOutput( + Hardware, + width, + height, + AllocFlag, + Pool, + &data[gcvFLOP_RESET_PPU_OUTPUT] + )); + + gcmkONERROR(_ProgramPPUInstruction( + Hardware, + dataType, + AllocFlag, + Pool, + &instCount, + ®Count, + &data[gcvFLOP_RESET_PPU_INSTRUCTION] + )); + + workDim = 0x2; + valueOrder = 0x2; + groupSizeX = 1; + groupSizeY = 1; + groupSizeZ = 0; + globalScaleX = 4; + globalScaleY = 1; + globalScaleZ = 0; + globalOffsetX = 0; + globalOffsetY = 0; + globalOffsetZ = 0; + threadAllocation = (groupSizeX * groupSizeY + numShaderCores * 4 - 1) / (numShaderCores * 4); + inImageAddress = data[gcvFLOP_RESET_PPU_INPUT].address; + outImageAddress = data[gcvFLOP_RESET_PPU_OUTPUT].address; + instAddress = data[gcvFLOP_RESET_PPU_INSTRUCTION].address; + + gcmkONERROR(_ProgramPPUCommand( + Hardware, + stride, + width, + height, + workDim, + valueOrder, + groupSizeX, + groupSizeY, + groupSizeZ, + globalScaleX, + globalScaleY, + globalScaleZ, + globalOffsetX, + globalOffsetY, + globalOffsetZ, + threadAllocation, + inImageAddress, + outImageAddress, + instAddress, + instCount, + regCount, + AllocFlag, + Pool, + Command + )); + + Command->data = data; + Command->dataCount = dataCount; + + return gcvSTATUS_OK; + +OnError: + if (Command->funcVidMem) + { + gcmkVERIFY_OK(_FreeVideoMemory( + Hardware->kernel, + Command->funcVidMem + )); + Command->funcVidMem = gcvNULL; + } + + if (data) + { + for (i = 0; i < dataCount; i++) + { + if (data[i].bufVidMem) + { + gcmkVERIFY_OK(_FreeVideoMemory( + Hardware->kernel, + data[i].bufVidMem + )); + } + } + + gcmkVERIFY_OK(gckOS_Free(Hardware->os, data)); + } + + return status; +} + +/* + * NN + */ +static gceSTATUS +_ProgramNNKernel( + IN gckHARDWARE Hardware, + IN gceVIP_ARCH_TYPE ArchType, + IN gctUINT32 CoreCount, + IN gctUINT32 Zdp, + IN gctUINT8 DataType, + IN gctUINT32 KernelXSize, + IN gctUINT32 KernelYSize, + IN gctUINT32 KernelZSize, + IN gctUINT32 AllocFlag, + IN OUT gcePOOL *Pool, + OUT gcsFUNCTION_EXECUTION_DATA *Data + ) +{ + gceSTATUS status = gcvSTATUS_OK; + + gctUINT32 filterBytes = 0; + gctUINT8_PTR kernels = gcvNULL; + gctUINT32 offset = 0; + gctUINT8_PTR kernelStreamSizePtr = gcvNULL; + gctUINT32 filterTotalCount = 1; + gctUINT32 itemBytes = 1; + gctUINT32 biasBytes = 4; + gckVIDMEM_NODE bufferNode = gcvNULL; + gctPOINTER bufferLogical = gcvNULL; + gctUINT32 bufferAddress = 0; + gctSIZE_T bufferBytes, bytes; + + gcmkONERROR(_GetNNDataSize(DataType, &itemBytes)); + + filterBytes = KernelXSize * KernelYSize * KernelZSize * itemBytes; + + /* Kernel buffer. */ + if (gcvVIP_ARCH_TYPE_V8 == ArchType) + { + /* Head (align to 64) + body (align to 64) + tail (align to 64). */ + gcmkASSERT(Zdp == 1 || Zdp == 3); + bufferBytes = 64 + gcmALIGN_NP2((gcmALIGN_NP2(filterBytes, Zdp * 3) * (Zdp * 3) * filterTotalCount) + (1 * (16 / itemBytes)), 64) + 64; + } + else + { + /* Head (align to 64) + body (align to 64). */ + bufferBytes = 64 + gcmALIGN_NP2(((filterBytes + biasBytes + 3) * filterTotalCount + 3), 64); + } + + gcmkONERROR(_AllocateVideoMemory( + Hardware->kernel, + gcvVIDMEM_TYPE_BITMAP, + AllocFlag, + Pool, + &bufferBytes, + &bufferNode, + &bufferLogical, + &bufferAddress + )); + + kernels = (gctUINT8_PTR)bufferLogical; + + /* V8 huffman encoder. */ + if (gcvVIP_ARCH_TYPE_V8 == ArchType) + { + gctUINT32 i = 0; + gctUINT8 rlt[][18] = { + {0}, /* uint8 */ + {1, 1, 0, 1}, /* fp16 */ + {7, 1}, /* int8 */ + {0}, /* uint16 */ + {3, 1, 0, 1}, /* int16 */ + {0}, /* uint4 */ + {0}, /* int4 */ + {1, 1, 0, 1} /* bf16 */ + }; + gctUINT8 map[][9] = { + {1, 8, 7, 0, 4, 5, 6, 2, 3}, + {1, 5, 0, 7, 8, 2, 6, 3, 4}, + {1, 0, 7, 8, 4, 5, 6, 2, 3}, + }; + gctBOOL bit16 = DataType == 0x4 || + DataType == 0x1 || + DataType == 0x7; + gctBOOL fp16 = DataType == 0x1; + gctUINT32 index = 0; + + if (Hardware->identity.customerID == 0x9f) + { + rlt[0][0] = 3; + rlt[0][1] = 1; + rlt[0][3] = 1; + } + + gcmkONERROR(_GetMapIndex(DataType, &index)); + + gcmkONERROR(_BitValue(&kernels, 0, &offset, 1)); /* precode */ + gcmkONERROR(_BitValue(&kernels, bit16, &offset, 1)); /* bit16 */ + gcmkONERROR(_BitValue(&kernels, fp16, &offset, 1)); /* fp16 */ + gcmkONERROR(_BitValue(&kernels, 0, &offset, 1)); /* reserved */ + gcmkONERROR(_BitValue(&kernels, 1, &offset, 4)); /* version, 1 */ + gcmkONERROR(_BitValue(&kernels, 4, &offset, 8)); /* zero run length size */ + + for (i = 0; i < 18; i++) + { + /* Zero run length x 18. */ + gcmkONERROR(_BitValue(&kernels, rlt[DataType][i], &offset, 8)); + } + + for (i = 0; i < 4; i++) + { + /* Map x 4. */ + gcmkONERROR(_BitValue(&kernels, (map[index][2 * i + 1] << 4) + map[index][2 * i], &offset, 8)); + } + + /* Avg bias */ + gcmkONERROR(_BitValue(&kernels, 0, &offset, 16)); + + /* Reserved, must zero. */ + gcmkONERROR(_BitValue(&kernels, 0, &offset, 16)); + + kernelStreamSizePtr = kernels; + + for (i = 0; i < CoreCount; i ++) + { + /* Stream size. */ + gcmkONERROR(_BitValue(&kernels, 0, &offset, 32)); + } + + kernels = (gctUINT8_PTR)bufferLogical + gcmALIGN_NP2((gctUINT32)((gctUINT8_PTR)kernels - (gctUINT8_PTR)bufferLogical), 64); + + switch (DataType) + { + case 0x4: + /* Huffman data: 00000018 00924600 */ + gcmkONERROR(_BitValue(&kernels, 0x04058000, &offset, 32)); + /* Huffman data. */ + gcmkONERROR(_BitValue(&kernels, 0x640101fc, &offset, 32)); + /* Huffman data. */ + gcmkONERROR(_BitValue(&kernels, 0x00001200, &offset, 32)); + + /* Only on core, stream size. */ + gcmkONERROR(_BitValue(&kernelStreamSizePtr, 0x0000006d, &offset, 32)); + + break; + + case 0x0: + case 0x2: + /* Huffman data. */ + gcmkONERROR(_BitValue(&kernels, 0xec000038, &offset, 32)); + + /* Only on core, stream size. */ + gcmkONERROR(_BitValue(&kernelStreamSizePtr, 0x35, &offset, 32)); + + break; + + case 0x1: + /* Huffman data: 0009db68 000006c0 000001f0 00000900 00024000. */ + gcmkONERROR(_BitValue(&kernels, 0x0009db68, &offset, 32)); + /* Huffman data. */ + gcmkONERROR(_BitValue(&kernels, 0x000006c0, &offset, 32)); + /* Huffman data. */ + gcmkONERROR(_BitValue(&kernels, 0x000001f0, &offset, 32)); + /* Huffman data. */ + gcmkONERROR(_BitValue(&kernels, 0x00000900, &offset, 32)); + /* Huffman data. */ + gcmkONERROR(_BitValue(&kernels, 0x00024000, &offset, 32)); + + /* Only on core, stream size. */ + gcmkONERROR(_BitValue(&kernelStreamSizePtr, 0x000000a3, &offset, 32)); + + break; + + case 0x7: + /* Huffman data: 0007fff8 7f00fdfc c0397f00 0900001f 40000000 00000002. */ + gcmkONERROR(_BitValue(&kernels, 0x0007fff8, &offset, 32)); + /* Huffman data. */ + gcmkONERROR(_BitValue(&kernels, 0x7f00fdfc, &offset, 32)); + /* Huffman data. */ + gcmkONERROR(_BitValue(&kernels, 0xc0397f00, &offset, 32)); + /* Huffman data. */ + gcmkONERROR(_BitValue(&kernels, 0x0900001f, &offset, 32)); + /* Huffman data. */ + gcmkONERROR(_BitValue(&kernels, 0x40000000, &offset, 32)); + /* Huffman data. */ + gcmkONERROR(_BitValue(&kernels, 0x00000002, &offset, 32)); + + /* Only on core, stream size. */ + gcmkONERROR(_BitValue(&kernelStreamSizePtr, 0x000000b2, &offset, 32)); + + break; + + default: + gcmkFATAL("Huffman encode not support this format! Please check!"); + break; + } + } + else + { + gctBOOL zeroAll = gcvFALSE; + gctUINT8 zrl = 0; + gctUINT16 vzNum = 1; + gctUINT32 bias = 0; + gctUINT32 totalSize = gcmALIGN_NP2((filterTotalCount * (filterBytes + biasBytes + 3) + 3), 64); + + gckOS_ZeroMemory(kernels, totalSize + 64); + + *((gctUINT32_PTR)kernels) = totalSize; + kernels += totalSize; + if (zeroAll) + { + /* + * Zrl & coreFilterCount, both compressed weight and bias are zero, + * the size (1 * 1 * 2 * 2 + 4 ) < 64, aligned to 64. + */ + *((gctUINT32_PTR)kernels) = (vzNum << (8 * itemBytes)); + } + else + { + gctINT16 value = (DataType == 0x1) ? 0x3c00 /*1.0f*/ : 1; + gctUINT32 i = 0; + + _BitValue(&kernels, zrl, &offset, 8); + _BitValue(&kernels, vzNum, &offset, 16); + _BitValue(&kernels, value, &offset, 8 * itemBytes); + _BitValue(&kernels, bias, &offset, 32); + + if (DataType == 0x3 || + DataType == 0x4) + { + _BitValue(&kernels, 0, &offset, 16); + } + + for (i = 1; i < filterBytes / itemBytes; i++) + { + _BitValue(&kernels, value, &offset, 8 * itemBytes); + } + } + } + + bytes = kernels + (offset + 7) / 8 - (gctUINT8_PTR)bufferLogical; + + gcmkONERROR(gckVIDMEM_NODE_CleanCache( + Hardware->kernel, + bufferNode, + 0, + bufferLogical, + bytes + )); + +#if gcdDUMP_IN_KERNEL + gcmkDUMP(Hardware->os, "#[flop reset: nn kernel]"); + gcmkDUMP_BUFFER( + Hardware->os, + gcvDUMP_BUFFER_KERNEL_COMMAND, + bufferLogical, + bufferAddress, + bytes + ); +#endif + + Data->bufVidMem = bufferNode; + Data->bufVidMemBytes = bufferBytes; + Data->address = bufferAddress; + Data->logical = bufferLogical; + Data->bytes = bytes; + + return gcvSTATUS_OK; + +OnError: + if (bufferNode) + { + gcmkVERIFY_OK(_FreeVideoMemory( + Hardware->kernel, + bufferNode + )); + } + + return status; +} + +static gceSTATUS +_ProgramNNInput( + IN gckHARDWARE Hardware, + IN gceVIP_ARCH_TYPE ArchType, + IN gctUINT8 DataType, + IN gctUINT32 InImageXSize, + IN gctUINT32 InImageYSize, + IN gctUINT32 InImageZSize, + IN gctUINT32 AllocFlag, + IN OUT gcePOOL *Pool, + OUT gcsFUNCTION_EXECUTION_DATA_PTR Data + ) +{ + gceSTATUS status = gcvSTATUS_OK; + + gctUINT32 inputSize = InImageXSize * InImageYSize * InImageZSize; + gctUINT32 itemBytes = 0; + gckVIDMEM_NODE bufferNode = gcvNULL; + gctPOINTER bufferLogical = gcvNULL; + gctUINT32 bufferAddress = 0; + gctSIZE_T bufferBytes, bytes; + gctUINT8_PTR buffer = gcvNULL; + + gctUINT32 i = 0; + gctUINT32 offset = 0; + gctUINT32 value[] = { + 1, /* uint8 */ + 0x3c00, /* fp16 */ + 1, /* int8 */ + 1, /* uint16 */ + 1, /* int16 */ + 1, /* uint4 */ + 1, /* int4 */ + 0x3f80 /* bf16 */ + }; + + gcmkONERROR(_GetNNDataSize(DataType, &itemBytes)); + + bufferBytes = inputSize * itemBytes; + + gcmkONERROR(_AllocateVideoMemory( + Hardware->kernel, + gcvVIDMEM_TYPE_BITMAP, + AllocFlag, + Pool, + &bufferBytes, + &bufferNode, + &bufferLogical, + &bufferAddress + )); + + if (gcvVIP_ARCH_TYPE_V8 == ArchType) + { + value[0x4] = 0x81; + } + + buffer = (gctUINT8_PTR)bufferLogical; + + for (i = 0; i < inputSize; i++) + { + _BitValue(&buffer, value[DataType], &offset, itemBytes * 8); + } + + bytes = buffer + (offset + 7) / 8 - (gctUINT8_PTR)bufferLogical; + + gcmkONERROR(gckVIDMEM_NODE_CleanCache( + Hardware->kernel, + bufferNode, + 0, + bufferLogical, + bytes + )); + +#if gcdDUMP_IN_KERNEL + gcmkDUMP(Hardware->os, "#[flop reset: nn input]"); + gcmkDUMP_BUFFER( + Hardware->os, + gcvDUMP_BUFFER_KERNEL_COMMAND, + bufferLogical, + bufferAddress, + bytes + ); +#endif + + Data->bufVidMem = bufferNode; + Data->bufVidMemBytes = bufferBytes; + Data->address = bufferAddress; + Data->logical = bufferLogical; + Data->bytes = bytes; + + return gcvSTATUS_OK; + +OnError: + gcmkVERIFY_OK(_FreeVideoMemory( + Hardware->kernel, + bufferNode + )); + + return status; +} + +static gceSTATUS +_ProgramNNOutput( + IN gckHARDWARE Hardware, + IN gctUINT8 DataType, + IN gctUINT32 OutputXSize, + IN gctUINT32 OutputYSize, + IN gctUINT32 OutputZSize, + IN gctUINT32 AllocFlag, + IN OUT gcePOOL *Pool, + OUT gcsFUNCTION_EXECUTION_DATA *Data + ) +{ + gceSTATUS status = gcvSTATUS_OK; + + gctUINT32 itemBytes = 0; + gckVIDMEM_NODE bufferNode = gcvNULL; + gctPOINTER bufferLogical = gcvNULL; + gctUINT32 bufferAddress = 0; + gctSIZE_T bufferBytes, bytes; + + if (!Data) + { + gcmkONERROR(gcvSTATUS_INVALID_ARGUMENT); + } + + gcmkONERROR(_GetNNDataSize(DataType, &itemBytes)); + + bufferBytes = bytes = OutputXSize * OutputYSize * OutputZSize * itemBytes; + + gcmkONERROR(_AllocateVideoMemory( + Hardware->kernel, + gcvVIDMEM_TYPE_BITMAP, + AllocFlag, + Pool, + &bufferBytes, + &bufferNode, + &bufferLogical, + &bufferAddress + )); + + gcmkONERROR(gckVIDMEM_NODE_CleanCache( + Hardware->kernel, + bufferNode, + 0, + bufferLogical, + bytes + )); + + Data->bufVidMem = bufferNode; + Data->bufVidMemBytes = bufferBytes; + Data->address = bufferAddress; + Data->logical = bufferLogical; + Data->bytes = bytes; + + return gcvSTATUS_OK; + +OnError: + gcmkVERIFY_OK(_FreeVideoMemory( + Hardware->kernel, + bufferNode + )); + + return status; +} + +static gceSTATUS +_ProgramNNInstruction( + IN gckHARDWARE Hardware, + IN gceVIP_ARCH_TYPE ArchType, + IN gctUINT8 DataType, + IN gctUINT32 InImageXSize, + IN gctUINT32 InImageYSize, + IN gctUINT32 OutImageXSize, + IN gctUINT32 OutImageYSize, + IN gctUINT32 OutImageZSize, + IN gctUINT32 KernelXSize, + IN gctUINT32 KernelYSize, + IN gctUINT32 KernelZSize, + IN gctUINT32 InImageAddress, + IN gctUINT32 OutImageAddress, + IN gctUINT32 KernelAddress, + IN gctUINT32 AllocFlag, + IN gcePOOL *Pool, + OUT gcsFUNCTION_EXECUTION_DATA_PTR Data + ) +{ + gceSTATUS status = gcvSTATUS_OK; + + gckOS os = Hardware->os; + + gctUINT32 itemBytes; + gckVIDMEM_NODE bufferNode = gcvNULL; + gctPOINTER bufferLogical = gcvNULL; + gctUINT32 bufferAddress = 0; + gctSIZE_T bufferBytes, bytes; + gctUINT32 *command = gcvNULL; + + gctUINT8 kernelDataType; + gctUINT8 inImageDataType; + gctUINT8 outImageDataType; + + gctUINT32 kernelsPerCore = 1; + + gctUINT32 nnLayerFlush = 1; + gctUINT32 noZOffset = 0; + gctUINT32 imageEndAddress = 2048; + gctUINT32 postShift = 0; + gctUINT32 postShiftBit56 = 0; + gctUINT8 coefZP = 0; + gctUINT8 outputZP = 0; + + bufferBytes = bytes = gcmSIZEOF(gctUINT32) * ((ArchType == gcvVIP_ARCH_TYPE_V6) ? 16 : 32); + + /* Allocate buffer. */ + gcmkONERROR(_AllocateVideoMemory( + Hardware->kernel, + gcvVIDMEM_TYPE_COMMAND, + AllocFlag, + Pool, + &bufferBytes, + &bufferNode, + &bufferLogical, + &bufferAddress + )); + + command = (gctUINT32_PTR)bufferLogical; + + gcmkONERROR(_GetNNDataSize(DataType, &itemBytes)); + + kernelDataType = + inImageDataType = + outImageDataType = DataType; + + switch (ArchType) + { + case gcvVIP_ARCH_TYPE_V8: + noZOffset = 1; + outputZP = 0; + postShift = (gckHARDWARE_IsFeatureAvailable(Hardware, gcvFEATURE_NN_FLOAT_POST_MULT)) ? 0x1f : 0; + postShiftBit56 = (gckHARDWARE_IsFeatureAvailable(Hardware, gcvFEATURE_NN_FLOAT_POST_MULT)) ? 3 : 0; + break; + + case gcvVIP_ARCH_TYPE_V7: + case gcvVIP_ARCH_TYPE_V6: + postShift = (DataType == 0x2) ? 15 : 0; + break; + + default: + gcmkONERROR(gcvSTATUS_NOT_SUPPORTED); + break; + } + + /* gcregNNInstWord0 */ + gcmkWRITE_MEMORY( + command, + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 0:0) - (0 ? + 0:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 0:0) - (0 ? + 0:0) + 1))))))) << (0 ? + 0:0))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 0:0) - (0 ? + 0:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 0:0) - (0 ? 0:0) + 1))))))) << (0 ? 0:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 1:1) - (0 ? + 1:1) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 1:1) - (0 ? + 1:1) + 1))))))) << (0 ? + 1:1))) | (((gctUINT32) ((gctUINT32) (noZOffset) & ((gctUINT32) ((((1 ? + 1:1) - (0 ? + 1:1) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 1:1) - (0 ? 1:1) + 1))))))) << (0 ? 1:1))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 5:2) - (0 ? + 5:2) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 5:2) - (0 ? + 5:2) + 1))))))) << (0 ? + 5:2))) | (((gctUINT32) ((gctUINT32) (KernelXSize) & ((gctUINT32) ((((1 ? + 5:2) - (0 ? + 5:2) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 5:2) - (0 ? 5:2) + 1))))))) << (0 ? 5:2))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 19:6) - (0 ? + 19:6) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 19:6) - (0 ? + 19:6) + 1))))))) << (0 ? + 19:6))) | (((gctUINT32) ((gctUINT32) ((KernelZSize & 0x3FFF)) & ((gctUINT32) ((((1 ? + 19:6) - (0 ? + 19:6) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 19:6) - (0 ? 19:6) + 1))))))) << (0 ? 19:6))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 26:20) - (0 ? + 26:20) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 26:20) - (0 ? + 26:20) + 1))))))) << (0 ? + 26:20))) | (((gctUINT32) ((gctUINT32) (kernelsPerCore) & ((gctUINT32) ((((1 ? + 26:20) - (0 ? + 26:20) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 26:20) - (0 ? 26:20) + 1))))))) << (0 ? 26:20))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 28:27) - (0 ? + 28:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 28:27) - (0 ? + 28:27) + 1))))))) << (0 ? + 28:27))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 28:27) - (0 ? + 28:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 28:27) - (0 ? 28:27) + 1))))))) << (0 ? 28:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 29:29) - (0 ? + 29:29) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 29:29) - (0 ? + 29:29) + 1))))))) << (0 ? + 29:29))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 29:29) - (0 ? + 29:29) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 29:29) - (0 ? 29:29) + 1))))))) << (0 ? 29:29))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 30:30) - (0 ? + 30:30) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 30:30) - (0 ? + 30:30) + 1))))))) << (0 ? + 30:30))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 30:30) - (0 ? + 30:30) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 30:30) - (0 ? 30:30) + 1))))))) << (0 ? 30:30))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:31) - (0 ? + 31:31) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:31) - (0 ? + 31:31) + 1))))))) << (0 ? + 31:31))) | (((gctUINT32) ((gctUINT32) (nnLayerFlush) & ((gctUINT32) ((((1 ? + 31:31) - (0 ? + 31:31) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:31) - (0 ? 31:31) + 1))))))) << (0 ? 31:31))) + ); + + /* gcregNNInstWord1 */ + gcmkWRITE_MEMORY( + command, + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 18:6) - (0 ? + 18:6) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 18:6) - (0 ? + 18:6) + 1))))))) << (0 ? + 18:6))) | (((gctUINT32) ((gctUINT32) (InImageXSize) & ((gctUINT32) ((((1 ? + 18:6) - (0 ? + 18:6) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 18:6) - (0 ? 18:6) + 1))))))) << (0 ? 18:6))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:19) - (0 ? + 31:19) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:19) - (0 ? + 31:19) + 1))))))) << (0 ? + 31:19))) | (((gctUINT32) ((gctUINT32) (InImageYSize) & ((gctUINT32) ((((1 ? + 31:19) - (0 ? + 31:19) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:19) - (0 ? 31:19) + 1))))))) << (0 ? 31:19))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 1:1) - (0 ? + 1:1) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 1:1) - (0 ? + 1:1) + 1))))))) << (0 ? + 1:1))) | (((gctUINT32) ((gctUINT32) (kernelDataType >> 1) & ((gctUINT32) ((((1 ? + 1:1) - (0 ? + 1:1) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 1:1) - (0 ? 1:1) + 1))))))) << (0 ? 1:1))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 3:3) - (0 ? + 3:3) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 3:3) - (0 ? + 3:3) + 1))))))) << (0 ? + 3:3))) | (((gctUINT32) ((gctUINT32) (inImageDataType >> 1) & ((gctUINT32) ((((1 ? + 3:3) - (0 ? + 3:3) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 3:3) - (0 ? 3:3) + 1))))))) << (0 ? 3:3))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 5:5) - (0 ? + 5:5) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 5:5) - (0 ? + 5:5) + 1))))))) << (0 ? + 5:5))) | (((gctUINT32) ((gctUINT32) (outImageDataType >> 1) & ((gctUINT32) ((((1 ? + 5:5) - (0 ? + 5:5) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 5:5) - (0 ? 5:5) + 1))))))) << (0 ? 5:5))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 0:0) - (0 ? + 0:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 0:0) - (0 ? + 0:0) + 1))))))) << (0 ? + 0:0))) | (((gctUINT32) ((gctUINT32) (kernelDataType & 0x1) & ((gctUINT32) ((((1 ? + 0:0) - (0 ? + 0:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 0:0) - (0 ? 0:0) + 1))))))) << (0 ? 0:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 2:2) - (0 ? + 2:2) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 2:2) - (0 ? + 2:2) + 1))))))) << (0 ? + 2:2))) | (((gctUINT32) ((gctUINT32) (inImageDataType & 0x1) & ((gctUINT32) ((((1 ? + 2:2) - (0 ? + 2:2) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 2:2) - (0 ? 2:2) + 1))))))) << (0 ? 2:2))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 4:4) - (0 ? + 4:4) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 4:4) - (0 ? + 4:4) + 1))))))) << (0 ? + 4:4))) | (((gctUINT32) ((gctUINT32) (outImageDataType & 0x1) & ((gctUINT32) ((((1 ? + 4:4) - (0 ? + 4:4) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 4:4) - (0 ? 4:4) + 1))))))) << (0 ? 4:4))) + ); + + /* gcregNNInstWord2 */ + gcmkWRITE_MEMORY( + command, + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 24:24) - (0 ? + 24:24) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 24:24) - (0 ? + 24:24) + 1))))))) << (0 ? + 24:24))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 24:24) - (0 ? + 24:24) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 24:24) - (0 ? 24:24) + 1))))))) << (0 ? 24:24))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:25) - (0 ? + 25:25) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:25) - (0 ? + 25:25) + 1))))))) << (0 ? + 25:25))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 25:25) - (0 ? + 25:25) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:25) - (0 ? 25:25) + 1))))))) << (0 ? 25:25))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 2:0) - (0 ? + 2:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 2:0) - (0 ? + 2:0) + 1))))))) << (0 ? + 2:0))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 2:0) - (0 ? + 2:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 2:0) - (0 ? 2:0) + 1))))))) << (0 ? 2:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 5:3) - (0 ? + 5:3) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 5:3) - (0 ? + 5:3) + 1))))))) << (0 ? + 5:3))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 5:3) - (0 ? + 5:3) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 5:3) - (0 ? 5:3) + 1))))))) << (0 ? 5:3))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 26:26) - (0 ? + 26:26) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 26:26) - (0 ? + 26:26) + 1))))))) << (0 ? + 26:26))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 26:26) - (0 ? + 26:26) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 26:26) - (0 ? 26:26) + 1))))))) << (0 ? 26:26))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 7:7) - (0 ? + 7:7) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 7:7) - (0 ? + 7:7) + 1))))))) << (0 ? + 7:7))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 7:7) - (0 ? + 7:7) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 7:7) - (0 ? 7:7) + 1))))))) << (0 ? 7:7))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 23:8) - (0 ? + 23:8) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 23:8) - (0 ? + 23:8) + 1))))))) << (0 ? + 23:8))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 23:8) - (0 ? + 23:8) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 23:8) - (0 ? 23:8) + 1))))))) << (0 ? 23:8))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) ((gctUINT32) (postShift) & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + ); + + /* gcregNNInstWord3 */ + gcmkWRITE_MEMORY( + command, + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 18:6) - (0 ? + 18:6) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 18:6) - (0 ? + 18:6) + 1))))))) << (0 ? + 18:6))) | (((gctUINT32) ((gctUINT32) (OutImageXSize) & ((gctUINT32) ((((1 ? + 18:6) - (0 ? + 18:6) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 18:6) - (0 ? 18:6) + 1))))))) << (0 ? 18:6))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:19) - (0 ? + 31:19) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:19) - (0 ? + 31:19) + 1))))))) << (0 ? + 31:19))) | (((gctUINT32) ((gctUINT32) (OutImageYSize) & ((gctUINT32) ((((1 ? + 31:19) - (0 ? + 31:19) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:19) - (0 ? 31:19) + 1))))))) << (0 ? 31:19))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 2:2) - (0 ? + 2:2) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 2:2) - (0 ? + 2:2) + 1))))))) << (0 ? + 2:2))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 2:2) - (0 ? + 2:2) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 2:2) - (0 ? 2:2) + 1))))))) << (0 ? 2:2))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 3:3) - (0 ? + 3:3) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 3:3) - (0 ? + 3:3) + 1))))))) << (0 ? + 3:3))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 3:3) - (0 ? + 3:3) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 3:3) - (0 ? 3:3) + 1))))))) << (0 ? 3:3))) + ); + + /* gcregNNInstWord4 */ + gcmkWRITE_MEMORY( + command, + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 13:0) - (0 ? + 13:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 13:0) - (0 ? + 13:0) + 1))))))) << (0 ? + 13:0))) | (((gctUINT32) ((gctUINT32) (OutImageZSize) & ((gctUINT32) ((((1 ? + 13:0) - (0 ? + 13:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 13:0) - (0 ? 13:0) + 1))))))) << (0 ? 13:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:14) - (0 ? + 15:14) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:14) - (0 ? + 15:14) + 1))))))) << (0 ? + 15:14))) | (((gctUINT32) ((gctUINT32) (0x0) & ((gctUINT32) ((((1 ? + 15:14) - (0 ? + 15:14) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:14) - (0 ? 15:14) + 1))))))) << (0 ? 15:14))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 24:18) - (0 ? + 24:18) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 24:18) - (0 ? + 24:18) + 1))))))) << (0 ? + 24:18))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 24:18) - (0 ? + 24:18) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 24:18) - (0 ? 24:18) + 1))))))) << (0 ? 24:18))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:25) - (0 ? + 31:25) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:25) - (0 ? + 31:25) + 1))))))) << (0 ? + 31:25))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 31:25) - (0 ? + 31:25) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:25) - (0 ? 31:25) + 1))))))) << (0 ? 31:25))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 16:16) - (0 ? + 16:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 16:16) - (0 ? + 16:16) + 1))))))) << (0 ? + 16:16))) | (((gctUINT32) ((gctUINT32) ((0 >> 3) & 0x1) & ((gctUINT32) ((((1 ? + 16:16) - (0 ? + 16:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 16:16) - (0 ? 16:16) + 1))))))) << (0 ? 16:16))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 17:17) - (0 ? + 17:17) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 17:17) - (0 ? + 17:17) + 1))))))) << (0 ? + 17:17))) | (((gctUINT32) ((gctUINT32) ((0 >> 3) & 0x1) & ((gctUINT32) ((((1 ? + 17:17) - (0 ? + 17:17) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 17:17) - (0 ? 17:17) + 1))))))) << (0 ? 17:17))) + ); + + /* gcregNNInstWord5 */ + gcmkWRITE_MEMORY( + command, + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:26) - (0 ? + 31:26) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:26) - (0 ? + 31:26) + 1))))))) << (0 ? + 31:26))) | (((gctUINT32) ((gctUINT32) (((KernelZSize >> 14) & 0x3F)) & ((gctUINT32) ((((1 ? + 31:26) - (0 ? + 31:26) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:26) - (0 ? 31:26) + 1))))))) << (0 ? 31:26))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:0) - (0 ? + 25:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:0) - (0 ? + 25:0) + 1))))))) << (0 ? + 25:0))) | (((gctUINT32) ((gctUINT32) ((KernelAddress >> 6)) & ((gctUINT32) ((((1 ? + 25:0) - (0 ? + 25:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:0) - (0 ? 25:0) + 1))))))) << (0 ? 25:0))) + ); + + /* gcregNNInstWord6 */ + gcmkWRITE_MEMORY(command, InImageAddress); + + /* gcregNNInstWord7 */ + gcmkWRITE_MEMORY(command, OutImageAddress); + + /* gcregNNInstWord8 */ + gcmkWRITE_MEMORY( + command, + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:12) - (0 ? + 15:12) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:12) - (0 ? + 15:12) + 1))))))) << (0 ? + 15:12))) | (((gctUINT32) ((gctUINT32) (KernelYSize) & ((gctUINT32) ((((1 ? + 15:12) - (0 ? + 15:12) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:12) - (0 ? 15:12) + 1))))))) << (0 ? 15:12))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:16) - (0 ? + 31:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:16) - (0 ? + 31:16) + 1))))))) << (0 ? + 31:16))) | (((gctUINT32) ((gctUINT32) (OutImageYSize) & ((gctUINT32) ((((1 ? + 31:16) - (0 ? + 31:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:16) - (0 ? 31:16) + 1))))))) << (0 ? 31:16))) + ); + + /* gcregNNInstWord9 */ + gcmkWRITE_MEMORY(command, 0); + + /* gcregNNInstWord10 */ + gcmkWRITE_MEMORY(command, 0); + + /* gcregNNInstWord11 */ + gcmkWRITE_MEMORY(command, 0); + + /* gcregNNInstWord12 */ + gcmkWRITE_MEMORY(command, 0); + + /* gcregNNInstWord13 */ + gcmkWRITE_MEMORY(command, 0); + + /* gcregNNInstWord14 */ + gcmkWRITE_MEMORY(command, imageEndAddress); + + /* gcregNNInstWord15 */ + gcmkWRITE_MEMORY( + command, + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 1:0) - (0 ? + 1:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 1:0) - (0 ? + 1:0) + 1))))))) << (0 ? + 1:0))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 1:0) - (0 ? + 1:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 1:0) - (0 ? 1:0) + 1))))))) << (0 ? 1:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 17:2) - (0 ? + 17:2) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 17:2) - (0 ? + 17:2) + 1))))))) << (0 ? + 17:2))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 17:2) - (0 ? + 17:2) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 17:2) - (0 ? 17:2) + 1))))))) << (0 ? 17:2))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 19:19) - (0 ? + 19:19) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 19:19) - (0 ? + 19:19) + 1))))))) << (0 ? + 19:19))) | (((gctUINT32) ((gctUINT32) (kernelDataType >> 2) & ((gctUINT32) ((((1 ? + 19:19) - (0 ? + 19:19) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 19:19) - (0 ? 19:19) + 1))))))) << (0 ? 19:19))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 20:20) - (0 ? + 20:20) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 20:20) - (0 ? + 20:20) + 1))))))) << (0 ? + 20:20))) | (((gctUINT32) ((gctUINT32) (inImageDataType >> 2) & ((gctUINT32) ((((1 ? + 20:20) - (0 ? + 20:20) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 20:20) - (0 ? 20:20) + 1))))))) << (0 ? 20:20))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 21:21) - (0 ? + 21:21) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 21:21) - (0 ? + 21:21) + 1))))))) << (0 ? + 21:21))) | (((gctUINT32) ((gctUINT32) (outImageDataType >> 2) & ((gctUINT32) ((((1 ? + 21:21) - (0 ? + 21:21) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 21:21) - (0 ? 21:21) + 1))))))) << (0 ? 21:21))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 27:22) - (0 ? + 27:22) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 27:22) - (0 ? + 27:22) + 1))))))) << (0 ? + 27:22))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 27:22) - (0 ? + 27:22) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 27:22) - (0 ? 27:22) + 1))))))) << (0 ? 27:22))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 29:28) - (0 ? + 29:28) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 29:28) - (0 ? + 29:28) + 1))))))) << (0 ? + 29:28))) | (((gctUINT32) ((gctUINT32) (postShiftBit56) & ((gctUINT32) ((((1 ? + 29:28) - (0 ? + 29:28) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 29:28) - (0 ? 29:28) + 1))))))) << (0 ? 29:28))) + ); + + /* V7 or V8 */ + if (ArchType == gcvVIP_ARCH_TYPE_V7 || + ArchType == gcvVIP_ARCH_TYPE_V8) + { + /* gcregNNInstWord16 */ + gcmkWRITE_MEMORY( + command, + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (InImageXSize * itemBytes) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:16) - (0 ? + 31:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:16) - (0 ? + 31:16) + 1))))))) << (0 ? + 31:16))) | (((gctUINT32) ((gctUINT32) (InImageYSize) & ((gctUINT32) ((((1 ? + 31:16) - (0 ? + 31:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:16) - (0 ? 31:16) + 1))))))) << (0 ? 31:16))) + ); + + /* gcregNNInstWord17 */ + gcmkWRITE_MEMORY( + command, + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (OutImageXSize * itemBytes) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:24) - (0 ? + 31:24) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:24) - (0 ? + 31:24) + 1))))))) << (0 ? + 31:24))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 31:24) - (0 ? + 31:24) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:24) - (0 ? 31:24) + 1))))))) << (0 ? 31:24))) + ); + + /* gcregNNInstWord18 */ + gcmkWRITE_MEMORY( + command, + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:0) - (0 ? + 25:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:0) - (0 ? + 25:0) + 1))))))) << (0 ? + 25:0))) | (((gctUINT32) ((gctUINT32) (0 >> 6) & ((gctUINT32) ((((1 ? + 25:0) - (0 ? + 25:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:0) - (0 ? 25:0) + 1))))))) << (0 ? 25:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 26:26) - (0 ? + 26:26) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 26:26) - (0 ? + 26:26) + 1))))))) << (0 ? + 26:26))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 26:26) - (0 ? + 26:26) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 26:26) - (0 ? 26:26) + 1))))))) << (0 ? 26:26))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 29:29) - (0 ? + 29:29) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 29:29) - (0 ? + 29:29) + 1))))))) << (0 ? + 29:29))) | (((gctUINT32) ((gctUINT32) ((0 >> 4) & 0x1) & ((gctUINT32) ((((1 ? + 29:29) - (0 ? + 29:29) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 29:29) - (0 ? 29:29) + 1))))))) << (0 ? 29:29))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 30:30) - (0 ? + 30:30) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 30:30) - (0 ? + 30:30) + 1))))))) << (0 ? + 30:30))) | (((gctUINT32) ((gctUINT32) ((0 >> 4) & 0x1) & ((gctUINT32) ((((1 ? + 30:30) - (0 ? + 30:30) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 30:30) - (0 ? 30:30) + 1))))))) << (0 ? 30:30))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 28:28) - (0 ? + 28:28) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 28:28) - (0 ? + 28:28) + 1))))))) << (0 ? + 28:28))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 28:28) - (0 ? + 28:28) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 28:28) - (0 ? 28:28) + 1))))))) << (0 ? 28:28))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:31) - (0 ? + 31:31) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:31) - (0 ? + 31:31) + 1))))))) << (0 ? + 31:31))) | (((gctUINT32) ((gctUINT32) (kernelDataType >> 3) & ((gctUINT32) ((((1 ? + 31:31) - (0 ? + 31:31) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:31) - (0 ? 31:31) + 1))))))) << (0 ? 31:31))) + ); + + /* 25:0 */ + gcmkWRITE_MEMORY( + command, + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:0) - (0 ? + 25:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:0) - (0 ? + 25:0) + 1))))))) << (0 ? + 25:0))) | (((gctUINT32) ((gctUINT32) (0xFFFFFFFF >> 6) & ((gctUINT32) ((((1 ? + 25:0) - (0 ? + 25:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:0) - (0 ? 25:0) + 1))))))) << (0 ? 25:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 30:30) - (0 ? + 30:30) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 30:30) - (0 ? + 30:30) + 1))))))) << (0 ? + 30:30))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 30:30) - (0 ? + 30:30) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 30:30) - (0 ? 30:30) + 1))))))) << (0 ? 30:30))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:31) - (0 ? + 31:31) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:31) - (0 ? + 31:31) + 1))))))) << (0 ? + 31:31))) | (((gctUINT32) ((gctUINT32) (inImageDataType >> 3) & ((gctUINT32) ((((1 ? + 31:31) - (0 ? + 31:31) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:31) - (0 ? 31:31) + 1))))))) << (0 ? 31:31))) + ); + + /* GCREG_NN_INST_WORD20 */ + gcmkWRITE_MEMORY( + command, + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:0) - (0 ? + 25:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:0) - (0 ? + 25:0) + 1))))))) << (0 ? + 25:0))) | (((gctUINT32) ((gctUINT32) (0 >> 6) & ((gctUINT32) ((((1 ? + 25:0) - (0 ? + 25:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:0) - (0 ? 25:0) + 1))))))) << (0 ? 25:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 26:26) - (0 ? + 26:26) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 26:26) - (0 ? + 26:26) + 1))))))) << (0 ? + 26:26))) | (((gctUINT32) ((gctUINT32) (outImageDataType >> 3) & ((gctUINT32) ((((1 ? + 26:26) - (0 ? + 26:26) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 26:26) - (0 ? 26:26) + 1))))))) << (0 ? 26:26))) + ); + + /* 25:0 */ + gcmkWRITE_MEMORY( + command, + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:0) - (0 ? + 25:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:0) - (0 ? + 25:0) + 1))))))) << (0 ? + 25:0))) | (((gctUINT32) ((gctUINT32) (0xFFFFFFFF >> 6) & ((gctUINT32) ((((1 ? + 25:0) - (0 ? + 25:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:0) - (0 ? 25:0) + 1))))))) << (0 ? 25:0))) + ); + + /*GCREG_NN_INST_WORD22*/ + gcmkWRITE_MEMORY( + command, + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 7:0) - (0 ? + 7:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 7:0) - (0 ? + 7:0) + 1))))))) << (0 ? + 7:0))) | (((gctUINT32) ((gctUINT32) (coefZP) & ((gctUINT32) ((((1 ? + 7:0) - (0 ? + 7:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 7:0) - (0 ? 7:0) + 1))))))) << (0 ? 7:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:8) - (0 ? + 15:8) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:8) - (0 ? + 15:8) + 1))))))) << (0 ? + 15:8))) | (((gctUINT32) ((gctUINT32) (outputZP) & ((gctUINT32) ((((1 ? + 15:8) - (0 ? + 15:8) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:8) - (0 ? 15:8) + 1))))))) << (0 ? 15:8))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 16:16) - (0 ? + 16:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 16:16) - (0 ? + 16:16) + 1))))))) << (0 ? + 16:16))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 16:16) - (0 ? + 16:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 16:16) - (0 ? 16:16) + 1))))))) << (0 ? 16:16))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 17:17) - (0 ? + 17:17) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 17:17) - (0 ? + 17:17) + 1))))))) << (0 ? + 17:17))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 17:17) - (0 ? + 17:17) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 17:17) - (0 ? 17:17) + 1))))))) << (0 ? 17:17))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:18) - (0 ? + 25:18) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:18) - (0 ? + 25:18) + 1))))))) << (0 ? + 25:18))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 25:18) - (0 ? + 25:18) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:18) - (0 ? 25:18) + 1))))))) << (0 ? 25:18))) + ); + + /*GCREG_NN_INST_WORD23*/ + gcmkWRITE_MEMORY(command, 0); + + /*GCREG_NN_INST_WORD24*/ + gcmkWRITE_MEMORY( + command, + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 3:0) - (0 ? + 3:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 3:0) - (0 ? + 3:0) + 1))))))) << (0 ? + 3:0))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 3:0) - (0 ? + 3:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 3:0) - (0 ? 3:0) + 1))))))) << (0 ? 3:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:4) - (0 ? + 31:4) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:4) - (0 ? + 31:4) + 1))))))) << (0 ? + 31:4))) | (((gctUINT32) ((gctUINT32) (0 >> 4) & ((gctUINT32) ((((1 ? + 31:4) - (0 ? + 31:4) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:4) - (0 ? 31:4) + 1))))))) << (0 ? 31:4))) + ); + + /*GCREG_NN_INST_WORD25*/ + gcmkWRITE_MEMORY( + command, + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 3:0) - (0 ? + 3:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 3:0) - (0 ? + 3:0) + 1))))))) << (0 ? + 3:0))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 3:0) - (0 ? + 3:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 3:0) - (0 ? 3:0) + 1))))))) << (0 ? 3:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:4) - (0 ? + 31:4) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:4) - (0 ? + 31:4) + 1))))))) << (0 ? + 31:4))) | (((gctUINT32) ((gctUINT32) (0 >> 4) & ((gctUINT32) ((((1 ? + 31:4) - (0 ? + 31:4) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:4) - (0 ? 31:4) + 1))))))) << (0 ? 31:4))) + ); + } + + gcmkONERROR(gckVIDMEM_NODE_CleanCache( + Hardware->kernel, + bufferNode, + 0, + bufferLogical, + bytes + )); + +#if gcdDUMP_IN_KERNEL + gcmkDUMP(Hardware->os, "#[flop reset: nn instruction]"); + gcmkDUMP_BUFFER( + Hardware->os, + gcvDUMP_BUFFER_KERNEL_COMMAND, + bufferLogical, + bufferAddress, + bytes + ); +#endif + + Data->bufVidMem = bufferNode; + Data->bufVidMemBytes = bufferBytes; + Data->address = bufferAddress; + Data->logical = bufferLogical; + Data->bytes = bytes; + + return gcvSTATUS_OK; + +OnError: + if (bufferNode) + { + gcmkVERIFY_OK(_FreeVideoMemory( + Hardware->kernel, + bufferNode + )); + } + + return status; +} + +static gceSTATUS +_ProgramNNCommand( + IN gckHARDWARE Hardware, + IN gceVIP_ARCH_TYPE ArchType, + IN gctUINT32 KernelBurstSize, + IN gctUINT32 InstAddress, + IN gctUINT32 AllocFlag, + IN gcePOOL *Pool, + OUT gcsFUNCTION_COMMAND_PTR Command + ) +{ + gceSTATUS status = gcvSTATUS_OK; + + gckVIDMEM_NODE bufferNode = gcvNULL; + gctPOINTER bufferLogical = gcvNULL; + gctUINT32 bufferAddress = 0; + gctSIZE_T bufferBytes; + gctUINT32 bytes; + gctUINT8_PTR endLogical; + gctUINT32 endAddress; + gctUINT32 endBytes = 0; + gcsFEATURE_DATABASE *database = (gcsFEATURE_DATABASE *)(Hardware->featureDatabase); + gctUINT32 index = 0; + gctINT32 disableZDPN = 1, disableSWTiling = 1; + gctBOOL enableNNStride = gcvFALSE; + gctUINT32 smallBatch; + gctUINT32 ddrBurstSize; + gctUINT32 *commands = gcvNULL; + + bufferBytes = gcmSIZEOF(gctUINT32) * MAX_NN_COMMAND_NUM; + + gcmkONERROR(_AllocateVideoMemory( + Hardware->kernel, + gcvVIDMEM_TYPE_COMMAND, + AllocFlag, + Pool, + &bufferBytes, + &bufferNode, + &bufferLogical, + &bufferAddress + )); + + commands = (gctUINT32 *)bufferLogical; + + disableZDPN = (database->NN_ZDP3 || database->NN_ZDP6) ? 0 : 1; + + enableNNStride = database->NN_STRIDE_SUPPORT; + disableSWTiling = enableNNStride ? 0 : 1; + + if (Hardware->identity.chipModel == 0x8000 && + Hardware->identity.chipRevision == 0x7120 && + (Hardware->identity.customerID == 0x80 || + Hardware->identity.customerID == 0x92)) + { + smallBatch = 0x0; + } + else + { + smallBatch = (database->NN_SMALLBATCH_PHASE1 && database->NN_COMMAND_KERNEL_REQUEST_CONFICT_FIX) + ? 0x0 : 0x1; + } + + switch(KernelBurstSize) + { + case 256: + ddrBurstSize = 0x2; + break; + + case 64: + default: + ddrBurstSize = 0x0; + break; + } + + commands = (gctUINT32_PTR)bufferLogical; + + if (gcvVIP_ARCH_TYPE_V6 == ArchType) + { + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x006B) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + commands[index++] = 0; + + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0E03) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 6:6) - (0 ? + 6:6) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 6:6) - (0 ? + 6:6) + 1))))))) << (0 ? + 6:6))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 6:6) - (0 ? + 6:6) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 6:6) - (0 ? 6:6) + 1))))))) << (0 ? 6:6))); + } + + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0E4E) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + commands[index++] = Hardware->options.sRAMGPUVirtAddrs[0]; + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0E4F) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + commands[index++] = 0x00000000; + + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0E50) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + commands[index++] = 0x00000000; + + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0E03) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 6:6) - (0 ? + 6:6) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 6:6) - (0 ? + 6:6) + 1))))))) << (0 ? + 6:6))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 6:6) - (0 ? + 6:6) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 6:6) - (0 ? 6:6) + 1))))))) << (0 ? 6:6))); + + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0E4C) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 2:2) - (0 ? + 2:2) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 2:2) - (0 ? + 2:2) + 1))))))) << (0 ? + 2:2))) | (((gctUINT32) ((gctUINT32) (disableZDPN) & ((gctUINT32) ((((1 ? + 2:2) - (0 ? + 2:2) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 2:2) - (0 ? 2:2) + 1))))))) << (0 ? 2:2))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 3:3) - (0 ? + 3:3) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 3:3) - (0 ? + 3:3) + 1))))))) << (0 ? + 3:3))) | (((gctUINT32) ((gctUINT32) (disableSWTiling) & ((gctUINT32) ((((1 ? + 3:3) - (0 ? + 3:3) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 3:3) - (0 ? 3:3) + 1))))))) << (0 ? 3:3))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 4:4) - (0 ? + 4:4) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 4:4) - (0 ? + 4:4) + 1))))))) << (0 ? + 4:4))) | (((gctUINT32) ((gctUINT32) (smallBatch) & ((gctUINT32) ((((1 ? + 4:4) - (0 ? + 4:4) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 4:4) - (0 ? 4:4) + 1))))))) << (0 ? 4:4))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 6:5) - (0 ? + 6:5) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 6:5) - (0 ? + 6:5) + 1))))))) << (0 ? + 6:5))) | (((gctUINT32) ((gctUINT32) (ddrBurstSize) & ((gctUINT32) ((((1 ? + 6:5) - (0 ? + 6:5) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 6:5) - (0 ? 6:5) + 1))))))) << (0 ? 6:5))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 12:12) - (0 ? + 12:12) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 12:12) - (0 ? + 12:12) + 1))))))) << (0 ? + 12:12))) | (((gctUINT32) ((gctUINT32) (0x0) & ((gctUINT32) ((((1 ? + 12:12) - (0 ? + 12:12) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 12:12) - (0 ? 12:12) + 1))))))) << (0 ? 12:12))); + + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0E54) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 0:0) - (0 ? + 0:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 0:0) - (0 ? + 0:0) + 1))))))) << (0 ? + 0:0))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 0:0) - (0 ? + 0:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 0:0) - (0 ? 0:0) + 1))))))) << (0 ? 0:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 1:1) - (0 ? + 1:1) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 1:1) - (0 ? + 1:1) + 1))))))) << (0 ? + 1:1))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 1:1) - (0 ? + 1:1) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 1:1) - (0 ? 1:1) + 1))))))) << (0 ? 1:1))); + + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0428) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:6) - (0 ? + 31:6) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:6) - (0 ? + 31:6) + 1))))))) << (0 ? + 31:6))) | (((gctUINT32) ((gctUINT32) ((InstAddress >> 6)) & ((gctUINT32) ((((1 ? + 31:6) - (0 ? + 31:6) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:6) - (0 ? 31:6) + 1))))))) << (0 ? 31:6))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 4:0) - (0 ? + 4:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 4:0) - (0 ? + 4:0) + 1))))))) << (0 ? + 4:0))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 4:0) - (0 ? + 4:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 4:0) - (0 ? 4:0) + 1))))))) << (0 ? 4:0))); + + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0429) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + commands[index++] = 0; + + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0E03) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + commands[index++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 5:5) - (0 ? + 5:5) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 5:5) - (0 ? + 5:5) + 1))))))) << (0 ? + 5:5))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 5:5) - (0 ? + 5:5) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 5:5) - (0 ? 5:5) + 1))))))) << (0 ? 5:5))); + + bytes = gcmSIZEOF(gctUINT32) * index; + + endLogical = (gctUINT8_PTR)bufferLogical + bytes; + endAddress = bufferAddress + bytes; + + if (Hardware->wlFE) + { + gcmkONERROR(gckWLFE_End(Hardware, gcvNULL, ~0U, &endBytes)); + gcmkONERROR(gckWLFE_End(Hardware, endLogical, endAddress, &endBytes)); + } + + bytes += endBytes; + + gcmkASSERT(bytes <= bufferBytes); + + gcmkONERROR(gckVIDMEM_NODE_CleanCache( + Hardware->kernel, + bufferNode, + 0, + bufferLogical, + bytes + )); + + Command->funcVidMem = bufferNode; + Command->funcVidMemBytes = bufferBytes; + Command->logical = bufferLogical; + Command->address = bufferAddress; + Command->bytes = bytes; + Command->endAddress = endAddress; + Command->endLogical = endLogical; + + return gcvSTATUS_OK; + +OnError: + if (bufferNode) + { + gcmkONERROR(_FreeVideoMemory( + Hardware->kernel, + bufferNode + )); + } + + return status; +} + +gceSTATUS +gckHARDWARE_ResetFlopWithNN( + IN gckHARDWARE Hardware, + IN gctUINT32 AllocFlag, + IN OUT gcePOOL *Pool, + OUT gcsFUNCTION_COMMAND *Command + ) +{ + gceSTATUS status = gcvSTATUS_OK; + + gctUINT32 kernelXSize = NN_KERNEL_XSIZE; + gctUINT32 kernelYSize = NN_KERNEL_YSIZE; + gctUINT32 kernelZSize = NN_KERNEL_ZSIZE; + + gctUINT32 inImageXSize = NN_INPUT_XSIZE; + gctUINT32 inImageYSize = NN_INPUT_YSIZE; + gctUINT32 inImageZSize = NN_INPUT_ZSIZE; + + gctUINT32 outImageXSize = NN_OUTPUT_XSIZE; + gctUINT32 outImageYSize = NN_OUTPUT_YSIZE; + gctUINT32 outImageZSize = NN_OUTPUT_ZSIZE; + + gctUINT32 i; + gctPOINTER pointer = gcvNULL; + + gceVIP_ARCH_TYPE archType; + gctUINT8 dataType; + gctUINT32 coreCount = 0; + gctUINT32 itemBytes = 0; + gctUINT32 zdp = 1; + gctUINT32 kernelBurstSize; + gcsFUNCTION_EXECUTION_DATA_PTR data = gcvNULL; + gctUINT32 dataCount = 0; + + if (!Command) + { + gcmkONERROR(gcvSTATUS_INVALID_ARGUMENT); + } + + gcmkONERROR(_GetVIPCoreInfo( + Hardware, + &archType, + &dataType, + &coreCount, + &zdp, + &kernelBurstSize + )); + + gcmkONERROR(_GetNNDataSize(dataType, &itemBytes)); + + /* Exectution data. */ + dataCount = gcvFLOP_RESET_NN_DATA_NUM; + gcmkASSERT(dataCount > 0); + + gcmkONERROR(gckOS_Allocate( + Hardware->os, + gcmSIZEOF(gcsFUNCTION_EXECUTION_DATA) * dataCount, + &pointer + )); + gckOS_ZeroMemory(pointer, gcmSIZEOF(gcsFUNCTION_EXECUTION_DATA) * dataCount); + data = (gcsFUNCTION_EXECUTION_DATA *)pointer; + + /* Kernel. */ + gcmkONERROR(_ProgramNNKernel( + Hardware, + archType, + coreCount, + zdp, + dataType, + kernelXSize, + kernelYSize, + kernelZSize, + AllocFlag, + Pool, + &data[gcvFLOP_RESET_NN_KERNEL] + )); + + /* Input. */ + gcmkONERROR(_ProgramNNInput( + Hardware, + archType, + dataType, + inImageXSize, + inImageYSize, + inImageZSize, + AllocFlag, + Pool, + &data[gcvFLOP_RESET_NN_INPUT] + )); + + /* Output. */ + gcmkONERROR(_ProgramNNOutput( + Hardware, + dataType, + outImageXSize, + outImageYSize, + outImageZSize, + AllocFlag, + Pool, + &data[gcvFLOP_RESET_NN_OUTPUT] + )); + + /* Commands. */ + gcmkONERROR(_ProgramNNInstruction( + Hardware, + archType, + dataType, + inImageXSize, + inImageYSize, + outImageXSize, + outImageYSize, + outImageZSize, + kernelXSize, + kernelYSize, + kernelZSize, + data[gcvFLOP_RESET_NN_INPUT].address, + data[gcvFLOP_RESET_NN_OUTPUT].address, + data[gcvFLOP_RESET_NN_KERNEL].address, + AllocFlag, + Pool, + &data[gcvFLOP_RESET_NN_INSTRUCTION] + )); + + gcmkONERROR(_ProgramNNCommand( + Hardware, + archType, + kernelBurstSize, + data[gcvFLOP_RESET_NN_INSTRUCTION].address, + AllocFlag, + Pool, + Command + )); + + Command->data = data; + Command->dataCount = dataCount; + + return gcvSTATUS_OK; + +OnError: + if (Command->funcVidMem) + { + gcmkVERIFY_OK(_FreeVideoMemory( + Hardware->kernel, + Command->funcVidMem + )); + Command->funcVidMem = gcvNULL; + } + + if (data) + { + for (i = 0; i < dataCount; i++) + { + if (data[i].bufVidMem) + { + gcmkVERIFY_OK(_FreeVideoMemory( + Hardware->kernel, + data[i].bufVidMem + )); + } + } + + gcmkVERIFY_OK(gckOS_Free(Hardware->os, data)); + } + + return status; +} + +static gceSTATUS +_ProgramTPKernel( + IN gckHARDWARE Hardware, + IN gceVIP_ARCH_TYPE ArchType, + IN gctUINT32 CoreCount, + IN gctUINT32 Zdp, + IN gctUINT8 DataType, + IN gctUINT32 KernelXSize, + IN gctUINT32 KernelYSize, + IN gctUINT32 KernelZSize, + IN gctUINT32 AllocFlag, + IN OUT gcePOOL *Pool, + OUT gcsFUNCTION_EXECUTION_DATA *Data + ) +{ + gceSTATUS status = gcvSTATUS_OK; + gckVIDMEM_NODE bufferNode = gcvNULL; + gctPOINTER bufferLogical = gcvNULL; + gctUINT32 bufferAddress =0; + gctSIZE_T bufferBytes = 0x3C0; + gctUINT32 *buffer = gcvNULL; + gctUINT32 i; + + + /* hardcode */ + gcmkONERROR(_AllocateVideoMemory( + Hardware->kernel, + gcvVIDMEM_TYPE_BITMAP, + AllocFlag, + Pool, + &bufferBytes, + &bufferNode, + &bufferLogical, + &bufferAddress + )); + + buffer = (gctUINT32_PTR)bufferLogical; + + /* Fill the data. */ + for (i = 0; i < bufferBytes / 4; i++) + { + buffer[i] = 0; + } + + buffer[0] = 0x01150410; + buffer[1] = buffer[81] = buffer[161] = 0x00000100; + buffer[5] = buffer[85] = buffer[165] = 0x26543780; + buffer[6] = buffer[86] = buffer[166] = 0x000000ff; + buffer[7] = buffer[87] = buffer[167] = 0x0006801a; + buffer[48] = buffer[128] = buffer[208] = 0x00024938; + buffer[64] = buffer[144] = buffer[224] = 0x00024938; + buffer[80] = buffer[160] = 0x01140410; + + + gcmkONERROR(gckVIDMEM_NODE_CleanCache( + Hardware->kernel, + bufferNode, + 0, + bufferLogical, + bufferBytes + )); + +#if gcdDUMP_IN_KERNEL + gcmkDUMP(Hardware->os, "#[flop reset: TP kernel]"); + gcmkDUMP_BUFFER( + Hardware->os, + gcvDUMP_BUFFER_KERNEL_COMMAND, + bufferLogical, + bufferAddress, + bufferBytes + ); +#endif + + Data->bufVidMem = bufferNode; + Data->bufVidMemBytes = bufferBytes; + Data->address = bufferAddress; + Data->logical = bufferLogical; + Data->bytes = bufferBytes; + + return gcvSTATUS_OK; + +OnError: + if (bufferNode) + { + gcmkVERIFY_OK(_FreeVideoMemory( + Hardware->kernel, + bufferNode + )); + } + + return status; +} + +static gceSTATUS +_ProgramTPInput( + IN gckHARDWARE Hardware, + IN gceVIP_ARCH_TYPE ArchType, + IN gctUINT8 DataType, + IN gctUINT32 InImageXSize, + IN gctUINT32 InImageYSize, + IN gctUINT32 InImageZSize, + IN gctUINT32 AllocFlag, + IN OUT gcePOOL *Pool, + OUT gcsFUNCTION_EXECUTION_DATA_PTR Data + ) +{ + gceSTATUS status = gcvSTATUS_OK; + + gctUINT32 inputSize = InImageXSize * InImageYSize * InImageZSize; + gctUINT32 itemBytes = 0; + gckVIDMEM_NODE bufferNode = gcvNULL; + gctPOINTER bufferLogical = gcvNULL; + gctUINT32 bufferAddress = 0; + gctSIZE_T bufferBytes, bytes; + gctUINT8_PTR buffer = gcvNULL; + + gctUINT32 i = 0; + gctUINT32 offset = 0; + gctUINT32 value[] = { + 0xff, /* uint8, the case set scale = 0.003921569*/ + 0x3c00, /* fp16 */ + 1, /* int8 */ + 1, /* uint16 */ + 1, /* int16 */ + 1, /* uint4 */ + 1, /* int4 */ + 0x3f80 /* bf16 */ + }; + gcmkONERROR(_GetNNDataSize(DataType, &itemBytes)); + + bufferBytes = inputSize * itemBytes; + + gcmkONERROR(_AllocateVideoMemory( + Hardware->kernel, + gcvVIDMEM_TYPE_BITMAP, + AllocFlag, + Pool, + &bufferBytes, + &bufferNode, + &bufferLogical, + &bufferAddress + )); + + if (gcvVIP_ARCH_TYPE_V8 == ArchType) + { + value[0x4] = 0x81; + } + + buffer = (gctUINT8_PTR)bufferLogical; + + for (i = 0; i < inputSize; i++) + { + _BitValue(&buffer, value[DataType], &offset, itemBytes * 8); + } + + bytes = buffer + (offset + 7) / 8 - (gctUINT8_PTR)bufferLogical; + + gcmkONERROR(gckVIDMEM_NODE_CleanCache( + Hardware->kernel, + bufferNode, + 0, + bufferLogical, + bytes + )); + +#if gcdDUMP_IN_KERNEL + gcmkDUMP(Hardware->os, "#[flop reset: TP input]"); + gcmkDUMP_BUFFER( + Hardware->os, + gcvDUMP_BUFFER_KERNEL_COMMAND, + bufferLogical, + bufferAddress, + bytes + ); +#endif + + Data->bufVidMem = bufferNode; + Data->bufVidMemBytes = bufferBytes; + Data->address = bufferAddress; + Data->logical = bufferLogical; + Data->bytes = bytes; + + return gcvSTATUS_OK; + +OnError: + gcmkVERIFY_OK(_FreeVideoMemory( + Hardware->kernel, + bufferNode + )); + + return status; +} + +static gceSTATUS +_ProgramTPOutput( + IN gckHARDWARE Hardware, + IN gctUINT8 DataType, + IN gctUINT32 OutputXSize, + IN gctUINT32 OutputYSize, + IN gctUINT32 OutputZSize, + IN gctUINT32 AllocFlag, + IN OUT gcePOOL *Pool, + OUT gcsFUNCTION_EXECUTION_DATA *Data + ) +{ + gceSTATUS status = gcvSTATUS_OK; + + gctUINT32 itemBytes = 0; + gckVIDMEM_NODE bufferNode = gcvNULL; + gctPOINTER bufferLogical = gcvNULL; + gctUINT32 bufferAddress = 0; + gctSIZE_T bufferBytes, bytes; + + if (!Data) + { + gcmkONERROR(gcvSTATUS_INVALID_ARGUMENT); + } + + gcmkONERROR(_GetNNDataSize(DataType, &itemBytes)); + + bufferBytes = bytes = OutputXSize * OutputYSize * OutputZSize * itemBytes; + + gcmkONERROR(_AllocateVideoMemory( + Hardware->kernel, + gcvVIDMEM_TYPE_BITMAP, + AllocFlag, + Pool, + &bufferBytes, + &bufferNode, + &bufferLogical, + &bufferAddress + )); + + gcmkONERROR(gckVIDMEM_NODE_CleanCache( + Hardware->kernel, + bufferNode, + 0, + bufferLogical, + bytes + )); + + Data->bufVidMem = bufferNode; + Data->bufVidMemBytes = bufferBytes; + Data->address = bufferAddress; + Data->logical = bufferLogical; + Data->bytes = bytes; + + return gcvSTATUS_OK; + +OnError: + gcmkVERIFY_OK(_FreeVideoMemory( + Hardware->kernel, + bufferNode + )); + + return status; +} + +static gceSTATUS +_ProgramTPInstruction( + IN gckHARDWARE Hardware, + IN gceVIP_ARCH_TYPE ArchType, + IN gctUINT8 DataType, + IN gctUINT32 InImageXSize, + IN gctUINT32 InImageYSize, + IN gctUINT32 OutImageXSize, + IN gctUINT32 OutImageYSize, + IN gctUINT32 OutImageZSize, + IN gctUINT32 KernelXSize, + IN gctUINT32 KernelYSize, + IN gctUINT32 KernelZSize, + IN gctUINT32 InImageAddress, + IN gctUINT32 OutImageAddress, + IN gctUINT32 KernelAddress, + IN gctUINT32 AllocFlag, + IN gcePOOL *Pool, + OUT gcsFUNCTION_EXECUTION_DATA_PTR Data + ) +{ + gceSTATUS status = gcvSTATUS_OK; + + gckVIDMEM_NODE bufferNode = gcvNULL; + gctPOINTER bufferLogical = gcvNULL; + gctUINT32 bufferAddress = 0; + gctSIZE_T bufferBytes, bytes; + gctUINT32 *command = gcvNULL; + gctUINT32 i; + + bufferBytes = bytes = 0x180; + + /* Allocate buffer. */ + gcmkONERROR(_AllocateVideoMemory( + Hardware->kernel, + gcvVIDMEM_TYPE_COMMAND, + AllocFlag, + Pool, + &bufferBytes, + &bufferNode, + &bufferLogical, + &bufferAddress + )); + + command = (gctUINT32_PTR)bufferLogical; + + /* Fill the data. */ + for (i = 0; i < bufferBytes / 4; i++) + { + command[i] = 0; + } + + for (i = 0; i < 3; i++) + { + command[0] = command[2] = command[3] = command[20] = 0x00000001; + command[1] = 0x00020001; + command[8] = command[9] = command[16] = command[19] = 0x00010001; + command[10] = InImageAddress; + command[24] = 0x0000240a; + command[26] = command[28] = 0x03ffffff; + command[30] = 0x00008100; + command = command + 32; + } + + command = (gctUINT32_PTR)bufferLogical; + + command[6] = 0xa0002a1b; + command[38] = command[70] = 0xa000281b; + command[12] = command[44] = 0xc0000002; + command[76] = 0x80000002; + command[22] = 0x00010016; + command[54] = command[86] = 0x00010015; + command[11] = KernelAddress; + command[43] = KernelAddress + 0x140; + command[75] = KernelAddress + 0x280; + command[13] = OutImageAddress; + command[45] = OutImageAddress + 0x16; + command[77] = OutImageAddress + 0x2b; + + gcmkONERROR(gckVIDMEM_NODE_CleanCache( + Hardware->kernel, + bufferNode, + 0, + bufferLogical, + bytes + )); + +#if gcdDUMP_IN_KERNEL + gcmkDUMP(Hardware->os, "#[flop reset: TP instruction]"); + gcmkDUMP_BUFFER( + Hardware->os, + gcvDUMP_BUFFER_KERNEL_COMMAND, + bufferLogical, + bufferAddress, + bytes + ); +#endif + + Data->bufVidMem = bufferNode; + Data->bufVidMemBytes = bufferBytes; + Data->address = bufferAddress; + Data->logical = bufferLogical; + Data->bytes = bytes; + + return gcvSTATUS_OK; + +OnError: + if (bufferNode) + { + gcmkVERIFY_OK(_FreeVideoMemory( + Hardware->kernel, + bufferNode + )); + } + + return status; +} + +static gceSTATUS +_ProgramTPCommand( + IN gckHARDWARE Hardware, + IN gceVIP_ARCH_TYPE ArchType, + IN gctUINT32 InstAddress, + IN gctUINT32 AllocFlag, + IN gcePOOL *Pool, + OUT gcsFUNCTION_COMMAND_PTR Command + ) +{ + gceSTATUS status = gcvSTATUS_OK; + + gckVIDMEM_NODE bufferNode = gcvNULL; + gctPOINTER bufferLogical = gcvNULL; + gctUINT32 bufferAddress = 0; + gctSIZE_T bufferBytes; + gctUINT32 bytes; + gctUINT32 *commands; + + gctUINT8_PTR endLogical; + gctUINT32 endAddress; + gctUINT32 endBytes = 0; + gctUINT32 i = 0; + gctUINT32 k; + + bufferBytes = gcmSIZEOF(gctUINT32) * 64; + + gcmkONERROR(_AllocateVideoMemory( + Hardware->kernel, + gcvVIDMEM_TYPE_COMMAND, + AllocFlag, + Pool, + &bufferBytes, + &bufferNode, + &bufferLogical, + &bufferAddress + )); + + commands = (gctUINT32_PTR)bufferLogical; + for (i = 0; i < 3; i++) + { + k = 14 * i; + commands[0 + k] = 0x08010e4e; + commands[1 + k] = 0x00400000; + commands[2 + k] = 0x08010e4f; + commands[3 + k] = 0x00000000; + commands[4 + k] = 0x08010e50; + commands[5 + k] = 0x00000000; + commands[6 + k] = 0x08010e53; + commands[7 + k] = 0x00000000; + commands[8 + k] = 0x08010e54; + commands[9 + k] = 0x00000008; + commands[10 + k] = 0x08010e27; + commands[11 + k] = 0x00000000; + commands[12 + k] = 0x0801042e; + } + + commands[13] = (InstAddress & 0xffffffC0) | (0x1); + commands[27] = ((InstAddress + 0x80) & 0xffffffC0) | (0x1); + commands[37] = 0x00000000; + commands[41] = ((InstAddress + 0x100) & 0xffffffC0); + commands[42] = 0x08010429; + commands[43] = 0; + commands[44] = 0x08010E03; + commands[45] = 0x20; + + bytes = 46 * 4; + + endLogical = (gctUINT8_PTR)bufferLogical + bytes; + endAddress = bufferAddress + bytes; + + if (Hardware->wlFE) + { + gcmkONERROR(gckWLFE_End(Hardware, gcvNULL, ~0U, &endBytes)); + gcmkONERROR(gckWLFE_End(Hardware, endLogical, endAddress, &endBytes)); + } + + bytes += endBytes; + + gcmkASSERT(bytes <= bufferBytes); + + + gcmkONERROR(gckVIDMEM_NODE_CleanCache( + Hardware->kernel, + bufferNode, + 0, + bufferLogical, + bytes + )); + + Command->funcVidMem = bufferNode; + Command->funcVidMemBytes = bufferBytes; + Command->logical = bufferLogical; + Command->address = bufferAddress; + Command->bytes = bytes; + Command->endAddress = endAddress; + Command->endLogical = endLogical; + + return gcvSTATUS_OK; + +OnError: + if (bufferNode) + { + gcmkONERROR(_FreeVideoMemory( + Hardware->kernel, + bufferNode + )); + } + + return status; +} + +/* + * TP. + */ +gceSTATUS +gckHARDWARE_ResetFlopWithTP( + IN gckHARDWARE Hardware, + IN gctUINT32 AllocFlag, + IN gcePOOL *Pool, + OUT gcsFUNCTION_COMMAND_PTR Command + ) +{ + gceSTATUS status = gcvSTATUS_OK; + + gctUINT32 kernelXSize = TP_KERNEL_XSIZE; + gctUINT32 kernelYSize = TP_KERNEL_YSIZE; + gctUINT32 kernelZSize = TP_KERNEL_ZSIZE; + + gctUINT32 inImageXSize = TP_INPUT_XSIZE; + gctUINT32 inImageYSize = TP_INPUT_YSIZE; + gctUINT32 inImageZSize = TP_INPUT_ZSIZE; + + gctUINT32 outImageXSize = TP_OUTPUT_XSIZE; + gctUINT32 outImageYSize = TP_OUTPUT_YSIZE; + gctUINT32 outImageZSize = TP_OUTPUT_ZSIZE; + + gctUINT32 i; + gctPOINTER pointer = gcvNULL; + + gceVIP_ARCH_TYPE archType = gcvVIP_ARCH_TYPE_V8; + gctUINT8 dataType; + gctUINT32 coreCount = 0; + gctUINT32 zdp = 1; + gctUINT32 itemBytes = 0; + gcsFUNCTION_EXECUTION_DATA_PTR data = gcvNULL; + gctUINT32 dataCount = 0; + + if (!Command) + { + gcmkONERROR(gcvSTATUS_INVALID_ARGUMENT); + } + + + dataType = 0x0; + + gcmkONERROR(_GetNNDataSize(dataType, &itemBytes)); + + /* Exectution data. */ + dataCount = gcvFLOP_RESET_TP_DATA_NUM; + gcmkASSERT(dataCount > 0); + + gcmkONERROR(gckOS_Allocate( + Hardware->os, + gcmSIZEOF(gcsFUNCTION_EXECUTION_DATA) * dataCount, + &pointer + )); + gckOS_ZeroMemory(pointer, gcmSIZEOF(gcsFUNCTION_EXECUTION_DATA) * dataCount); + data = (gcsFUNCTION_EXECUTION_DATA *)pointer; + + /* Kernel. */ + gcmkONERROR(_ProgramTPKernel( + Hardware, + archType, + coreCount, + zdp, + dataType, + kernelXSize, + kernelYSize, + kernelZSize, + AllocFlag, + Pool, + &data[gcvFLOP_RESET_TP_KERNEL] + )); + + /* Input. */ + gcmkONERROR(_ProgramTPInput( + Hardware, + archType, + dataType, + inImageXSize, + inImageYSize, + inImageZSize, + AllocFlag, + Pool, + &data[gcvFLOP_RESET_TP_INPUT] + )); + + /* Output. */ + gcmkONERROR(_ProgramTPOutput( + Hardware, + dataType, + outImageXSize, + outImageYSize, + outImageZSize, + AllocFlag, + Pool, + &data[gcvFLOP_RESET_TP_OUTPUT] + )); + + /* Commands. */ + gcmkONERROR(_ProgramTPInstruction( + Hardware, + archType, + dataType, + inImageXSize, + inImageYSize, + outImageXSize, + outImageYSize, + outImageZSize, + kernelXSize, + kernelYSize, + kernelZSize, + data[gcvFLOP_RESET_TP_INPUT].address, + data[gcvFLOP_RESET_TP_OUTPUT].address, + data[gcvFLOP_RESET_TP_KERNEL].address, + AllocFlag, + Pool, + &data[gcvFLOP_RESET_TP_INSTRUCTION] + )); + + gcmkONERROR(_ProgramTPCommand( + Hardware, + archType, + data[gcvFLOP_RESET_TP_INSTRUCTION].address, + AllocFlag, + Pool, + Command + )); + + Command->data = data; + Command->dataCount = dataCount; + + return gcvSTATUS_OK; + +OnError: + if (Command->funcVidMem) + { + gcmkVERIFY_OK(_FreeVideoMemory( + Hardware->kernel, + Command->funcVidMem + )); + Command->funcVidMem = gcvNULL; + } + + if (data) + { + for (i = 0; i < dataCount; i++) + { + if (data[i].bufVidMem) + { + gcmkVERIFY_OK(_FreeVideoMemory( + Hardware->kernel, + data[i].bufVidMem + )); + } + } + + gcmkVERIFY_OK(gckOS_Free(Hardware->os, data)); + } + + return status; +} + diff --git a/drivers/amlogic/npu/kernel/inc/gc_hal_resource.h b/drivers/amlogic/npu/kernel/arch/gc_hal_kernel_hardware_func_flop_reset.h similarity index 76% rename from drivers/amlogic/npu/kernel/inc/gc_hal_resource.h rename to drivers/amlogic/npu/kernel/arch/gc_hal_kernel_hardware_func_flop_reset.h index c8431bf..39d0955 100644 --- a/drivers/amlogic/npu/kernel/inc/gc_hal_resource.h +++ b/drivers/amlogic/npu/kernel/arch/gc_hal_kernel_hardware_func_flop_reset.h @@ -2,7 +2,7 @@ * * The MIT License (MIT) * -* Copyright (c) 2014 - 2019 Vivante Corporation +* Copyright (c) 2014 - 2020 Vivante Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -26,7 +26,7 @@ * * The GPL License (GPL) * -* Copyright (C) 2014 - 2019 Vivante Corporation +* Copyright (C) 2014 - 2020 Vivante Corporation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -53,17 +53,40 @@ *****************************************************************************/ -#ifndef __gc_hal_resource_h_ -#define __gc_hal_resource_h_ - +#ifndef __gc_hal_kernel_hardware_func_flop_reset_h_ +#define __gc_hal_kernel_hardware_func_flop_reset_h_ #ifdef __cplusplus extern "C" { #endif +#include "gc_hal.h" +#include "gc_hal_kernel.h" +#include "gc_hal_kernel_hardware.h" + +gceSTATUS +gckHARDWARE_ResetFlopWithPPU( + IN gckHARDWARE Hardware, + IN gctUINT32 AllocFlag, + IN gcePOOL *Pool, + OUT gcsFUNCTION_COMMAND_PTR Command + ); + +gceSTATUS +gckHARDWARE_ResetFlopWithNN( + IN gckHARDWARE Hardware, + IN gctUINT32 AllocFlag, + IN gcePOOL *Pool, + OUT gcsFUNCTION_COMMAND_PTR Command + ); +gceSTATUS +gckHARDWARE_ResetFlopWithTP( + IN gckHARDWARE Hardware, + IN gctUINT32 AllocFlag, + IN gcePOOL *Pool, + OUT gcsFUNCTION_COMMAND_PTR Command + ); #ifdef __cplusplus } #endif - -#endif /* __gc_hal_resource_h_ */ - +#endif diff --git a/drivers/amlogic/npu/kernel/arch/gc_hal_kernel_hardware_func_ppu.h b/drivers/amlogic/npu/kernel/arch/gc_hal_kernel_hardware_func_ppu.h new file mode 100644 index 0000000..7e7cf08 --- /dev/null +++ b/drivers/amlogic/npu/kernel/arch/gc_hal_kernel_hardware_func_ppu.h @@ -0,0 +1,1157 @@ +/**************************************************************************** +* +* The MIT License (MIT) +* +* Copyright (c) 2014 - 2020 Vivante Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +* +***************************************************************************** +* +* The GPL License (GPL) +* +* Copyright (C) 2014 - 2020 Vivante Corporation +* +* 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 +* of the License, or (at your option) any later version. +* +* 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, write to the Free Software Foundation, +* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +***************************************************************************** +* +* Note: This software is released under dual MIT and GPL licenses. A +* recipient may use this file under the terms of either the MIT license or +* GPL License. If you wish to use only one license not the other, you can +* indicate your decision by deleting one of the above license notices in your +* version of this file. +* +*****************************************************************************/ + + +//#include "gc_hal_user_hardware_precomp.h" +//#include "gc_hal_user.h" +/* +** +*/ +#if gcdINITIALIZE_PPU + +#define gcdRESET_PPU_SH 1 + + +#define INPUT_PPU_IDX 0 +#define OUTPUT_PPU_IDX 1 +#define INST_PPU_IDX 2 + +#include "gc_feature_database.h" + +#define GCREG_SH_INSTRUCTION_TYPE_INVALID ~0U + +#define gcdVX_ENABLE ((1 << 0) | (1 << 1) | (1 << 2) | (1 << 3)) +#define gcdVX_ENABLE4(X, Y, Z, W) ((1 << (X)) | (1 << (Y)) | (1 << (Z)) | (1 << (W))) +#define gcdVX_ENABLE1(X) (1 << (X)) +#define gcdVX_ENABLE2(X, Y) ((1 << (X)) | (1 << (Y))) +#define gcdVX_ENABLE3(X, Y, Z) ((1 << (X)) | (1 << (Y)) | (1 << (Z))) +#define gcdVX_SWIZZLE (0 | (1 << 2) | (2 << 4) | (3 << 6)) +#define gcdVX_SWIZZLE1(X) ((X) | ((X) << 2) | ((X) << 4) | ((X) << 6)) +#define gcdVX_SWIZZLE2(X, Y) ((X) | ((Y) << 2) | ((Y) << 4) | ((Y) << 6)) +#define gcdVX_SWIZZLE4(X, Y, Z, W) ((X) | ((Y) << 2) | ((Z) << 4) | ((W) << 6)) + + +#define GETBIT(data, position) (((data) >> (position)) & 0x1) + +#define SETBIT(data, position, value) (\ + ((data) & (~((1ULL) << position))) \ + | \ + (((value) << position) & ((1ULL) << position)) \ + ) + +#define _START(reg_field) (0 ? reg_field) +#define _END(reg_field) (1 ? reg_field) +#define _GETSIZE(reg_field) (_END(reg_field) - _START(reg_field) + 1) +#define _ALIGN(data, reg_field) ((gctUINT32)(data) << _START(reg_field)) +#define _MASK(reg_field) ((_GETSIZE(reg_field) == 32) \ + ? ~0 \ + : (gctUINT32)(~((gctUINT64)(~0) << _GETSIZE(reg_field)))) + +#define AQSETFIELD(data, reg, field, value) \ +(\ + ((gctUINT32)(data) & ~_ALIGN(_MASK(reg##_##field), reg##_##field)) \ + | \ + _ALIGN((gctUINT32)(value) & _MASK(reg##_##field), reg##_##field) \ +) + +#define AQSETFIELDVALUE(data, reg, field, value) \ +(\ + ((gctUINT32)(data) & ~_ALIGN(_MASK(reg##_##field), reg##_##field)) \ + | \ + _ALIGN(reg##_##field##_##value & _MASK(reg##_##field), reg##_##field) \ +) + +gctUINT32 HwFunc_SETBITS( + IN gctUINT32 Data, + IN const unsigned int Start, + IN const unsigned int End, + IN const gctUINT32 Value + ) +{ + gctUINT32 data = Data; + if (End >= Start) + { + gctUINT32 _Mask = ((~0ULL >> (63 - End + Start)) << Start); + data &= ~_Mask; + data |= ((Value) << Start) & _Mask; + return data; + } + else + { + gctUINT32 _Mask = ((~0ULL >> (63 - Start + End)) << End); + data &= ~_Mask; + data |= ((Value) << End) & _Mask; + return data; + } +} + +gctUINT32 HwFunc_GETBITS( + IN gctUINT32 Data, + IN const unsigned int Start, + IN const unsigned int End + ) +{ + gctUINT32 data = Data; + if (End >= Start) + { + gctUINT32 _Mask = (~0ULL >> (63 - (End - Start))); + return (data >> Start) & _Mask; + } + else + { + gctUINT32 _Mask = (~0ULL >> (63 - (Start - End))); + return (data >> End) & _Mask;; + } +} + +gceSTATUS +_InitializePPU_SetImmediate( + IN gctUINT32 Where, + IN gctUINT32 Value, + IN gctUINT32 Type, + IN OUT gctUINT32_PTR binary + ) +{ + gceSTATUS status = gcvSTATUS_OK; + + gcmkHEADER_ARG("Where=0x%x", Where); + + switch (Where) + { + case 0: + binary[1] = (((gctUINT32)(binary[1]) & ~((gctUINT32)(((((1 ? + 20:12) - (0 ? + 20:12) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 20:12) - (0 ? + 20:12) + 1))))) << (0 ? + 20:12))) | ((gctUINT32)((gctUINT32)(HwFunc_GETBITS(Value, 8, 0)) & ((((1 ? + 20:12) - (0 ? + 20:12) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 20:12) - (0 ? 20:12) + 1))))) << (0 ? 20:12))); + binary[1] = (((gctUINT32)(binary[1]) & ~((gctUINT32)(((((1 ? + 29:22) - (0 ? + 29:22) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 29:22) - (0 ? + 29:22) + 1))))) << (0 ? + 29:22))) | ((gctUINT32)((gctUINT32)(HwFunc_GETBITS(Value, 16, 9)) & ((((1 ? + 29:22) - (0 ? + 29:22) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 29:22) - (0 ? 29:22) + 1))))) << (0 ? 29:22))); + binary[1] = (((gctUINT32)(binary[1]) & ~((gctUINT32)(((((1 ? + 30:30) - (0 ? + 30:30) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 30:30) - (0 ? + 30:30) + 1))))) << (0 ? + 30:30))) | ((gctUINT32)((gctUINT32)(GETBIT(Value, 17)) & ((((1 ? + 30:30) - (0 ? + 30:30) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 30:30) - (0 ? 30:30) + 1))))) << (0 ? 30:30))); + binary[1] = (((gctUINT32)(binary[1]) & ~((gctUINT32)(((((1 ? + 31:31) - (0 ? + 31:31) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 31:31) - (0 ? + 31:31) + 1))))) << (0 ? + 31:31))) | ((gctUINT32)((gctUINT32)(GETBIT(Value, 18)) & ((((1 ? + 31:31) - (0 ? + 31:31) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 31:31) - (0 ? 31:31) + 1))))) << (0 ? 31:31))); + binary[2] = (((gctUINT32)(binary[2]) & ~((gctUINT32)(((((1 ? + 2:0) - (0 ? + 2:0) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 2:0) - (0 ? + 2:0) + 1))))) << (0 ? + 2:0))) | ((gctUINT32)((gctUINT32)(GETBIT(Value, 19) | (Type << 1)) & ((((1 ? + 2:0) - (0 ? + 2:0) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 2:0) - (0 ? 2:0) + 1))))) << (0 ? 2:0))); + binary[2] = (((gctUINT32)(binary[2]) & ~((gctUINT32)(((((1 ? + 5:3) - (0 ? + 5:3) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 5:3) - (0 ? + 5:3) + 1))))) << (0 ? + 5:3))) | ((gctUINT32)((gctUINT32)(0x7) & ((((1 ? + 5:3) - (0 ? + 5:3) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 5:3) - (0 ? 5:3) + 1))))) << (0 ? 5:3))); + break; + + case 1: + binary[2] = (((gctUINT32)(binary[2]) & ~((gctUINT32)(((((1 ? + 15:7) - (0 ? + 15:7) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 15:7) - (0 ? + 15:7) + 1))))) << (0 ? + 15:7))) | ((gctUINT32)((gctUINT32)(HwFunc_GETBITS(Value, 8, 0)) & ((((1 ? + 15:7) - (0 ? + 15:7) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 15:7) - (0 ? 15:7) + 1))))) << (0 ? 15:7))); + binary[2] = (((gctUINT32)(binary[2]) & ~((gctUINT32)(((((1 ? + 24:17) - (0 ? + 24:17) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 24:17) - (0 ? + 24:17) + 1))))) << (0 ? + 24:17))) | ((gctUINT32)((gctUINT32)(HwFunc_GETBITS(Value, 16, 9)) & ((((1 ? + 24:17) - (0 ? + 24:17) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 24:17) - (0 ? 24:17) + 1))))) << (0 ? 24:17))); + binary[2] = (((gctUINT32)(binary[2]) & ~((gctUINT32)(((((1 ? + 25:25) - (0 ? + 25:25) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 25:25) - (0 ? + 25:25) + 1))))) << (0 ? + 25:25))) | ((gctUINT32)((gctUINT32)(GETBIT(Value, 17)) & ((((1 ? + 25:25) - (0 ? + 25:25) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 25:25) - (0 ? 25:25) + 1))))) << (0 ? 25:25))); + binary[2] = (((gctUINT32)(binary[2]) & ~((gctUINT32)(((((1 ? + 26:26) - (0 ? + 26:26) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 26:26) - (0 ? + 26:26) + 1))))) << (0 ? + 26:26))) | ((gctUINT32)((gctUINT32)(GETBIT(Value, 18)) & ((((1 ? + 26:26) - (0 ? + 26:26) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 26:26) - (0 ? 26:26) + 1))))) << (0 ? 26:26))); + binary[2] = (((gctUINT32)(binary[2]) & ~((gctUINT32)(((((1 ? + 29:27) - (0 ? + 29:27) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 29:27) - (0 ? + 29:27) + 1))))) << (0 ? + 29:27))) | ((gctUINT32)((gctUINT32)(GETBIT(Value, 19) | (Type << 1)) & ((((1 ? + 29:27) - (0 ? + 29:27) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 29:27) - (0 ? 29:27) + 1))))) << (0 ? 29:27))); + binary[3] = (((gctUINT32)(binary[3]) & ~((gctUINT32)(((((1 ? + 2:0) - (0 ? + 2:0) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 2:0) - (0 ? + 2:0) + 1))))) << (0 ? + 2:0))) | ((gctUINT32)((gctUINT32)(0x7) & ((((1 ? + 2:0) - (0 ? + 2:0) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 2:0) - (0 ? 2:0) + 1))))) << (0 ? 2:0))); + break; + + case 2: + binary[3] = (((gctUINT32)(binary[3]) & ~((gctUINT32)(((((1 ? + 12:4) - (0 ? + 12:4) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 12:4) - (0 ? + 12:4) + 1))))) << (0 ? + 12:4))) | ((gctUINT32)((gctUINT32)(HwFunc_GETBITS(Value, 8, 0)) & ((((1 ? + 12:4) - (0 ? + 12:4) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 12:4) - (0 ? 12:4) + 1))))) << (0 ? 12:4))); + binary[3] = (((gctUINT32)(binary[3]) & ~((gctUINT32)(((((1 ? + 21:14) - (0 ? + 21:14) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 21:14) - (0 ? + 21:14) + 1))))) << (0 ? + 21:14))) | ((gctUINT32)((gctUINT32)(HwFunc_GETBITS(Value, 16, 9)) & ((((1 ? + 21:14) - (0 ? + 21:14) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 21:14) - (0 ? 21:14) + 1))))) << (0 ? 21:14))); + binary[3] = (((gctUINT32)(binary[3]) & ~((gctUINT32)(((((1 ? + 22:22) - (0 ? + 22:22) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 22:22) - (0 ? + 22:22) + 1))))) << (0 ? + 22:22))) | ((gctUINT32)((gctUINT32)(GETBIT(Value, 17)) & ((((1 ? + 22:22) - (0 ? + 22:22) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 22:22) - (0 ? 22:22) + 1))))) << (0 ? 22:22))); + binary[3] = (((gctUINT32)(binary[3]) & ~((gctUINT32)(((((1 ? + 23:23) - (0 ? + 23:23) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 23:23) - (0 ? + 23:23) + 1))))) << (0 ? + 23:23))) | ((gctUINT32)((gctUINT32)(GETBIT(Value, 18)) & ((((1 ? + 23:23) - (0 ? + 23:23) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 23:23) - (0 ? 23:23) + 1))))) << (0 ? 23:23))); + binary[3] = (((gctUINT32)(binary[3]) & ~((gctUINT32)(((((1 ? + 27:25) - (0 ? + 27:25) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 27:25) - (0 ? + 27:25) + 1))))) << (0 ? + 27:25))) | ((gctUINT32)((gctUINT32)(GETBIT(Value, 19) | (Type << 1)) & ((((1 ? + 27:25) - (0 ? + 27:25) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 27:25) - (0 ? 27:25) + 1))))) << (0 ? 27:25))); + binary[3] = (((gctUINT32)(binary[3]) & ~((gctUINT32)(((((1 ? + 30:28) - (0 ? + 30:28) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 30:28) - (0 ? + 30:28) + 1))))) << (0 ? + 30:28))) | ((gctUINT32)((gctUINT32)(0x7) & ((((1 ? + 30:28) - (0 ? + 30:28) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 30:28) - (0 ? 30:28) + 1))))) << (0 ? 30:28))); + break; + } + + gcmkFOOTER(); + return status; +} + +gceSTATUS +_InitializePPU_SetInstructionType( + IN gctUINT32 Type, + OUT gctUINT32_PTR binary + ) +{ + gceSTATUS status = gcvSTATUS_OK; + + gcmkHEADER_ARG("Type=0x%x", Type); + + binary[1] = (((gctUINT32)(binary[1]) & ~((gctUINT32)(((((1 ? + 21:21) - (0 ? + 21:21) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 21:21) - (0 ? + 21:21) + 1))))) << (0 ? + 21:21))) | ((gctUINT32)((gctUINT32)(GETBIT(Type, 0)) & ((((1 ? + 21:21) - (0 ? + 21:21) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 21:21) - (0 ? 21:21) + 1))))) << (0 ? 21:21))); + binary[2] = (((gctUINT32)(binary[2]) & ~((gctUINT32)(((((1 ? + 31:30) - (0 ? + 31:30) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 31:30) - (0 ? + 31:30) + 1))))) << (0 ? + 31:30))) | ((gctUINT32)((gctUINT32)(HwFunc_GETBITS(Type, 2, 1)) & ((((1 ? + 31:30) - (0 ? + 31:30) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 31:30) - (0 ? 31:30) + 1))))) << (0 ? 31:30))); + + gcmkFOOTER(); + return status; +} + + +gceSTATUS +_InitializePPU_IsEndOfBB( + IN gckHARDWARE Hardware, + IN gctUINT32 Opcode, + OUT gctUINT32_PTR binary +) +{ + gceSTATUS status = gcvSTATUS_OK; + gcmkHEADER_ARG("Opcode=0x%x", Opcode); + + if (binary != NULL) + { + if (((gcsFEATURE_DATABASE *)Hardware->featureDatabase)->SH_END_OF_BB) + { + switch (Opcode) + { + case 0x09: + case 0x56: + case 0x0A: + case 0x0B: + case 0x0F: + case 0x31: + case 0x10: + binary[1] = (((gctUINT32)(binary[1]) & ~((gctUINT32)(((((1 ? + 10:3) - (0 ? + 10:3) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 10:3) - (0 ? + 10:3) + 1))))) << (0 ? + 10:3))) | ((gctUINT32)((gctUINT32)(HwFunc_SETBITS(binary[1], 3, 3, 1)) & ((((1 ? + 10:3) - (0 ? + 10:3) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 10:3) - (0 ? 10:3) + 1))))) << (0 ? 10:3))); + break; + case 0x65: + case 0x66: + case 0x67: + case 0x68: + case 0x69: + case 0x6A: + case 0x6B: + case 0x6C: + case 0x46: + binary[0] = (((gctUINT32)(binary[0]) & ~((gctUINT32)(((((1 ? + 10:6) - (0 ? + 10:6) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 10:6) - (0 ? + 10:6) + 1))))) << (0 ? + 10:6))) | ((gctUINT32)((gctUINT32)(HwFunc_SETBITS(binary[0], 2, 2, 1)) & ((((1 ? + 10:6) - (0 ? + 10:6) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 10:6) - (0 ? 10:6) + 1))))) << (0 ? 10:6))); + break; + case 0x32: + case 0x39: + case 0x33: + case 0x3A: + case 0x79: + case 0x34: + case 0x7A: + case 0x35: + binary[0] = (((gctUINT32)(binary[0]) & ~((gctUINT32)(((((1 ? + 10:6) - (0 ? + 10:6) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 10:6) - (0 ? + 10:6) + 1))))) << (0 ? + 10:6))) | ((gctUINT32)((gctUINT32)(HwFunc_SETBITS(binary[0], 2, 2, 1)) & ((((1 ? + 10:6) - (0 ? + 10:6) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 10:6) - (0 ? 10:6) + 1))))) << (0 ? 10:6))); + break; + default: + if (Opcode != 0x16 && + Opcode != 0x24 && + Opcode != 0x14 && + Opcode != 0x15 && + Opcode != 0x17) + binary[0] = (((gctUINT32)(binary[0]) & ~((gctUINT32)(((((1 ? + 10:6) - (0 ? + 10:6) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 10:6) - (0 ? + 10:6) + 1))))) << (0 ? + 10:6))) | ((gctUINT32)((gctUINT32)(HwFunc_SETBITS(binary[0], 2, 2, 1)) & ((((1 ? + 10:6) - (0 ? + 10:6) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 10:6) - (0 ? 10:6) + 1))))) << (0 ? 10:6))); + break; + } + } + } + +//OnError: + /* Return the status. */ + gcmkFOOTER(); + return status; +} +gceSTATUS +_InitializePPU_AddOpcode( + IN gckHARDWARE Hardware, + IN gctUINT32 Opcode, + IN gctUINT32 Extended, + IN gctINT32 Type, + OUT gctUINT32_PTR binary + ) +{ + gceSTATUS status = gcvSTATUS_OK; + + gcmkHEADER_ARG("Opcode=0x%x", Opcode); + + binary[0] = (((gctUINT32)(binary[0]) & ~((gctUINT32)(((((1 ? + 5:0) - (0 ? + 5:0) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 5:0) - (0 ? + 5:0) + 1))))) << (0 ? + 5:0))) | ((gctUINT32)((gctUINT32)(HwFunc_GETBITS(Opcode, 5, 0)) & ((((1 ? + 5:0) - (0 ? + 5:0) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 5:0) - (0 ? 5:0) + 1))))) << (0 ? 5:0))); + binary[2] = (((gctUINT32)(binary[2]) & ~((gctUINT32)(((((1 ? + 16:16) - (0 ? + 16:16) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 16:16) - (0 ? + 16:16) + 1))))) << (0 ? + 16:16))) | ((gctUINT32)((gctUINT32)(GETBIT(Opcode, 6)) & ((((1 ? + 16:16) - (0 ? + 16:16) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 16:16) - (0 ? 16:16) + 1))))) << (0 ? 16:16))); + if (Opcode == 0x7F) + { + gcmkONERROR(_InitializePPU_SetImmediate(2, Extended, 0x2, binary)); + } + else if (Opcode == 0x45) + { + binary[0] = (((gctUINT32)(binary[0]) & ~((gctUINT32)(((((1 ? + 15:13) - (0 ? + 15:13) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 15:13) - (0 ? + 15:13) + 1))))) << (0 ? + 15:13))) | ((gctUINT32)((gctUINT32)(HwFunc_GETBITS(Extended, 2, 0)) & ((((1 ? + 15:13) - (0 ? + 15:13) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 15:13) - (0 ? 15:13) + 1))))) << (0 ? 15:13))); + binary[0] = SETBIT(binary[0], 31, GETBIT(Extended, 3)); + binary[1] = HwFunc_SETBITS(binary[1], 1, 0, HwFunc_GETBITS(Extended, 5, 4)); + } + else if (Opcode == 0x31 || Opcode == 0x09 || Opcode == 0x0F) + { + binary[0] = (((gctUINT32)(binary[0]) & ~((gctUINT32)(((((1 ? + 10:6) - (0 ? + 10:6) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 10:6) - (0 ? + 10:6) + 1))))) << (0 ? + 10:6))) | ((gctUINT32)((gctUINT32)(HwFunc_GETBITS(Extended, 4, 0)) & ((((1 ? + 10:6) - (0 ? + 10:6) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 10:6) - (0 ? 10:6) + 1))))) << (0 ? 10:6))); + } + + if((gctUINT32)Type != GCREG_SH_INSTRUCTION_TYPE_INVALID) + gcmkONERROR(_InitializePPU_SetInstructionType(Type, binary)); + + gcmkONERROR(_InitializePPU_IsEndOfBB(Hardware, Opcode, binary)); + +OnError: + /* Return the status. */ + gcmkFOOTER(); + return status; +} + +gceSTATUS +_InitializePPU_SetDestination( + IN gctUINT32 Address, + IN gctUINT32 Enable, + IN gctBOOL Saturate, + IN OUT gctUINT32_PTR binary + ) +{ + gceSTATUS status = gcvSTATUS_OK; + + gcmkHEADER_ARG("Address=0x%x", Address); + + binary[0] = (((gctUINT32)(binary[0]) & ~((gctUINT32)(((((1 ? + 12:12) - (0 ? + 12:12) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 12:12) - (0 ? + 12:12) + 1))))) << (0 ? + 12:12))) | ((gctUINT32)((gctUINT32)(1) & ((((1 ? + 12:12) - (0 ? + 12:12) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 12:12) - (0 ? 12:12) + 1))))) << (0 ? 12:12))); + binary[0] = (((gctUINT32)(binary[0]) & ~((gctUINT32)(((((1 ? + 22:16) - (0 ? + 22:16) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 22:16) - (0 ? + 22:16) + 1))))) << (0 ? + 22:16))) | ((gctUINT32)((gctUINT32)(Address) & ((((1 ? + 22:16) - (0 ? + 22:16) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 22:16) - (0 ? 22:16) + 1))))) << (0 ? 22:16))); + binary[0] = (((gctUINT32)(binary[0]) & ~((gctUINT32)(((((1 ? + 26:23) - (0 ? + 26:23) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 26:23) - (0 ? + 26:23) + 1))))) << (0 ? + 26:23))) | ((gctUINT32)((gctUINT32)(Enable) & ((((1 ? + 26:23) - (0 ? + 26:23) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 26:23) - (0 ? 26:23) + 1))))) << (0 ? 26:23))); + binary[0] = (((gctUINT32)(binary[0]) & ~((gctUINT32)(((((1 ? + 11:11) - (0 ? + 11:11) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 11:11) - (0 ? + 11:11) + 1))))) << (0 ? + 11:11))) | ((gctUINT32)((gctUINT32)(Saturate) & ((((1 ? + 11:11) - (0 ? + 11:11) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 11:11) - (0 ? 11:11) + 1))))) << (0 ? 11:11))); + + gcmkFOOTER(); + return status; +} + +#define gcdVX_ENABLE ((1 << 0) | (1 << 1) | (1 << 2) | (1 << 3)) + +static gctUINT32 _InitializePPU_GetPixel(gctUINT32 format) +{ + gctUINT32 pixel = 0; + switch(format) + { + case 0x7: + pixel = 15; + break; + case 0x3: + case 0x6: + pixel = 7; + break; + default: + pixel = 15; + break; + } + + return pixel; +} + +gceSTATUS +_InitializePPU_SetEVIS( + IN gctUINT32 Start, + IN gctUINT32 End, + IN gctUINT32 Evis, + IN OUT gctUINT32_PTR binary + ) +{ + gceSTATUS status = gcvSTATUS_OK; + + gcmkHEADER_ARG("Evis=0x%x", Evis); + + binary[0] = (((gctUINT32)(binary[0]) & ~((gctUINT32)(((((1 ? + 26:23) - (0 ? + 26:23) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 26:23) - (0 ? + 26:23) + 1))))) << (0 ? + 26:23))) | ((gctUINT32)((gctUINT32)(Start) & ((((1 ? + 26:23) - (0 ? + 26:23) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 26:23) - (0 ? 26:23) + 1))))) << (0 ? 26:23))); + binary[0] = HwFunc_SETBITS(binary[0], 30, 27, End); + binary[1] = HwFunc_SETBITS(binary[1], 10, 2, Evis); + + gcmkFOOTER(); + return status; +} + +#define HwFunc_SETSOURCE(Where, Common_I, REL_ADR_I, TYPE_I, Address, Swizzle, Type, Negate, Absolute, Relative, Binary) \ + binary[Common_I] = AQSETFIELD(binary[Common_I], AQ_INST, SRCWhere_VALID, 1); \ + binary[Common_I] = AQSETFIELD(binary[Common_I], AQ_INST, SRC0_ADR, Address); \ + binary[Common_I] = AQSETFIELD(binary[Common_I], AQ_INST, SRC0_SWIZZLE, Swizzle); \ + binary[Common_I] = AQSETFIELD(binary[Common_I], AQ_INST, SRC0_MODIFIER_NEG, Negate); \ + binary[Common_I] = AQSETFIELD(binary[Common_I], AQ_INST, SRC0_MODIFIER_ABS, Absolute); \ + binary[REL_ADR_I] = AQSETFIELD(binary[REL_ADR_I], AQ_INST, SRC0_REL_ADR, Relative); \ + binary[TYPE_I] = AQSETFIELD(binary[TYPE_I], AQ_INST, SRC0_TYPE, Type); + +gceSTATUS +_InitializePPU_SetSource( + IN gctUINT32 Where, + IN gctUINT32 Address, + IN gctUINT32 Swizzle, + IN gctUINT32 Type, + IN gctBOOL Negate, + IN gctBOOL Absolute, + IN gctUINT32 Relative, + OUT gctUINT32_PTR binary + ) +{ + gceSTATUS status = gcvSTATUS_OK; + + gcmkHEADER_ARG("Where=0x%x", Where); + switch (Where) + { + case 0: + binary[1] = (((gctUINT32)(binary[1]) & ~((gctUINT32)(((((1 ? + 11:11) - (0 ? + 11:11) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 11:11) - (0 ? + 11:11) + 1))))) << (0 ? + 11:11))) | ((gctUINT32)((gctUINT32)(1) & ((((1 ? + 11:11) - (0 ? + 11:11) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 11:11) - (0 ? 11:11) + 1))))) << (0 ? 11:11))); + binary[1] = (((gctUINT32)(binary[1]) & ~((gctUINT32)(((((1 ? + 20:12) - (0 ? + 20:12) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 20:12) - (0 ? + 20:12) + 1))))) << (0 ? + 20:12))) | ((gctUINT32)((gctUINT32)(Address) & ((((1 ? + 20:12) - (0 ? + 20:12) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 20:12) - (0 ? 20:12) + 1))))) << (0 ? 20:12))); + binary[1] = (((gctUINT32)(binary[1]) & ~((gctUINT32)(((((1 ? + 29:22) - (0 ? + 29:22) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 29:22) - (0 ? + 29:22) + 1))))) << (0 ? + 29:22))) | ((gctUINT32)((gctUINT32)(Swizzle) & ((((1 ? + 29:22) - (0 ? + 29:22) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 29:22) - (0 ? 29:22) + 1))))) << (0 ? 29:22))); + binary[1] = (((gctUINT32)(binary[1]) & ~((gctUINT32)(((((1 ? + 30:30) - (0 ? + 30:30) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 30:30) - (0 ? + 30:30) + 1))))) << (0 ? + 30:30))) | ((gctUINT32)((gctUINT32)(Negate) & ((((1 ? + 30:30) - (0 ? + 30:30) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 30:30) - (0 ? 30:30) + 1))))) << (0 ? 30:30))); + binary[1] = (((gctUINT32)(binary[1]) & ~((gctUINT32)(((((1 ? + 31:31) - (0 ? + 31:31) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 31:31) - (0 ? + 31:31) + 1))))) << (0 ? + 31:31))) | ((gctUINT32)((gctUINT32)(Absolute) & ((((1 ? + 31:31) - (0 ? + 31:31) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 31:31) - (0 ? 31:31) + 1))))) << (0 ? 31:31))); + binary[2] = (((gctUINT32)(binary[2]) & ~((gctUINT32)(((((1 ? + 2:0) - (0 ? + 2:0) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 2:0) - (0 ? + 2:0) + 1))))) << (0 ? + 2:0))) | ((gctUINT32)((gctUINT32)(Relative) & ((((1 ? + 2:0) - (0 ? + 2:0) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 2:0) - (0 ? 2:0) + 1))))) << (0 ? 2:0))); + binary[2] = (((gctUINT32)(binary[2]) & ~((gctUINT32)(((((1 ? + 5:3) - (0 ? + 5:3) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 5:3) - (0 ? + 5:3) + 1))))) << (0 ? + 5:3))) | ((gctUINT32)((gctUINT32)(Type) & ((((1 ? + 5:3) - (0 ? + 5:3) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 5:3) - (0 ? 5:3) + 1))))) << (0 ? 5:3))); + break; + + case 1: + binary[2] = (((gctUINT32)(binary[2]) & ~((gctUINT32)(((((1 ? + 6:6) - (0 ? + 6:6) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 6:6) - (0 ? + 6:6) + 1))))) << (0 ? + 6:6))) | ((gctUINT32)((gctUINT32)(1) & ((((1 ? + 6:6) - (0 ? + 6:6) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 6:6) - (0 ? 6:6) + 1))))) << (0 ? 6:6))); + binary[2] = (((gctUINT32)(binary[2]) & ~((gctUINT32)(((((1 ? + 15:7) - (0 ? + 15:7) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 15:7) - (0 ? + 15:7) + 1))))) << (0 ? + 15:7))) | ((gctUINT32)((gctUINT32)(Address) & ((((1 ? + 15:7) - (0 ? + 15:7) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 15:7) - (0 ? 15:7) + 1))))) << (0 ? 15:7))); + binary[2] = (((gctUINT32)(binary[2]) & ~((gctUINT32)(((((1 ? + 24:17) - (0 ? + 24:17) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 24:17) - (0 ? + 24:17) + 1))))) << (0 ? + 24:17))) | ((gctUINT32)((gctUINT32)(Swizzle) & ((((1 ? + 24:17) - (0 ? + 24:17) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 24:17) - (0 ? 24:17) + 1))))) << (0 ? 24:17))); + binary[2] = (((gctUINT32)(binary[2]) & ~((gctUINT32)(((((1 ? + 25:25) - (0 ? + 25:25) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 25:25) - (0 ? + 25:25) + 1))))) << (0 ? + 25:25))) | ((gctUINT32)((gctUINT32)(Negate) & ((((1 ? + 25:25) - (0 ? + 25:25) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 25:25) - (0 ? 25:25) + 1))))) << (0 ? 25:25))); + binary[2] = (((gctUINT32)(binary[2]) & ~((gctUINT32)(((((1 ? + 26:26) - (0 ? + 26:26) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 26:26) - (0 ? + 26:26) + 1))))) << (0 ? + 26:26))) | ((gctUINT32)((gctUINT32)(Absolute) & ((((1 ? + 26:26) - (0 ? + 26:26) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 26:26) - (0 ? 26:26) + 1))))) << (0 ? 26:26))); + binary[2] = (((gctUINT32)(binary[2]) & ~((gctUINT32)(((((1 ? + 29:27) - (0 ? + 29:27) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 29:27) - (0 ? + 29:27) + 1))))) << (0 ? + 29:27))) | ((gctUINT32)((gctUINT32)(Relative) & ((((1 ? + 29:27) - (0 ? + 29:27) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 29:27) - (0 ? 29:27) + 1))))) << (0 ? 29:27))); + binary[3] = (((gctUINT32)(binary[3]) & ~((gctUINT32)(((((1 ? + 2:0) - (0 ? + 2:0) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 2:0) - (0 ? + 2:0) + 1))))) << (0 ? + 2:0))) | ((gctUINT32)((gctUINT32)(Type) & ((((1 ? + 2:0) - (0 ? + 2:0) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 2:0) - (0 ? 2:0) + 1))))) << (0 ? 2:0))); + break; + + case 2: + binary[3] = (((gctUINT32)(binary[3]) & ~((gctUINT32)(((((1 ? + 3:3) - (0 ? + 3:3) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 3:3) - (0 ? + 3:3) + 1))))) << (0 ? + 3:3))) | ((gctUINT32)((gctUINT32)(1) & ((((1 ? + 3:3) - (0 ? + 3:3) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 3:3) - (0 ? 3:3) + 1))))) << (0 ? 3:3))); + binary[3] = (((gctUINT32)(binary[3]) & ~((gctUINT32)(((((1 ? + 12:4) - (0 ? + 12:4) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 12:4) - (0 ? + 12:4) + 1))))) << (0 ? + 12:4))) | ((gctUINT32)((gctUINT32)(Address) & ((((1 ? + 12:4) - (0 ? + 12:4) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 12:4) - (0 ? 12:4) + 1))))) << (0 ? 12:4))); + binary[3] = (((gctUINT32)(binary[3]) & ~((gctUINT32)(((((1 ? + 21:14) - (0 ? + 21:14) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 21:14) - (0 ? + 21:14) + 1))))) << (0 ? + 21:14))) | ((gctUINT32)((gctUINT32)(Swizzle) & ((((1 ? + 21:14) - (0 ? + 21:14) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 21:14) - (0 ? 21:14) + 1))))) << (0 ? 21:14))); + binary[3] = (((gctUINT32)(binary[3]) & ~((gctUINT32)(((((1 ? + 22:22) - (0 ? + 22:22) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 22:22) - (0 ? + 22:22) + 1))))) << (0 ? + 22:22))) | ((gctUINT32)((gctUINT32)(Negate) & ((((1 ? + 22:22) - (0 ? + 22:22) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 22:22) - (0 ? 22:22) + 1))))) << (0 ? 22:22))); + binary[3] = (((gctUINT32)(binary[3]) & ~((gctUINT32)(((((1 ? + 23:23) - (0 ? + 23:23) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 23:23) - (0 ? + 23:23) + 1))))) << (0 ? + 23:23))) | ((gctUINT32)((gctUINT32)(Absolute) & ((((1 ? + 23:23) - (0 ? + 23:23) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 23:23) - (0 ? 23:23) + 1))))) << (0 ? 23:23))); + binary[3] = (((gctUINT32)(binary[3]) & ~((gctUINT32)(((((1 ? + 27:25) - (0 ? + 27:25) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 27:25) - (0 ? + 27:25) + 1))))) << (0 ? + 27:25))) | ((gctUINT32)((gctUINT32)(Relative) & ((((1 ? + 27:25) - (0 ? + 27:25) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 27:25) - (0 ? 27:25) + 1))))) << (0 ? 27:25))); + binary[3] = (((gctUINT32)(binary[3]) & ~((gctUINT32)(((((1 ? + 30:28) - (0 ? + 30:28) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 30:28) - (0 ? + 30:28) + 1))))) << (0 ? + 30:28))) | ((gctUINT32)((gctUINT32)(Type) & ((((1 ? + 30:28) - (0 ? + 30:28) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 30:28) - (0 ? 30:28) + 1))))) << (0 ? 30:28))); + break; + } + gcmkFOOTER(); + return status; +} + +static const gctUINT32 NEGATE_FLAG = 1 << 0; +static const gctUINT32 ABSOLUTE_FLAG = 1 << 1; + +gceSTATUS +_InitializePPU_SetUniform( + IN gctUINT32 Where, + IN gctUINT32 Address, + IN gctUINT32 Swizzle, + IN gctUINT32 Modifiers, + OUT gctUINT32_PTR binary + ) +{ + gceSTATUS status = gcvSTATUS_OK; + + gctBOOL negate = (Modifiers & NEGATE_FLAG ) ? gcvTRUE : gcvFALSE; + gctBOOL absolute = (Modifiers & ABSOLUTE_FLAG) ? gcvTRUE : gcvFALSE; + gcmkHEADER_ARG("Where=0x%x", Where); + + gcmkONERROR(_InitializePPU_SetSource(Where, Address, Swizzle, 0x2, negate, absolute, 0, binary)); + +OnError: + gcmkFOOTER(); + return status; +} + +gceSTATUS +_InitializePPU_SetTempReg( + IN gctUINT32 Where, + IN gctUINT32 Address, + IN gctUINT32 Swizzle, + IN gctUINT32 Modifiers, + OUT gctUINT32_PTR binary + ) +{ + gceSTATUS status = gcvSTATUS_OK; + + gctBOOL negate = (Modifiers & NEGATE_FLAG ) ? gcvTRUE : gcvFALSE; + gctBOOL absolute = (Modifiers & ABSOLUTE_FLAG) ? gcvTRUE : gcvFALSE; + gcmkHEADER_ARG("Where=0x%x", Where); + + gcmkONERROR(_InitializePPU_SetSource(Where, Address, Swizzle, 0x0, negate, absolute, 0, binary)); + +OnError: + gcmkFOOTER(); + return status; +} + + +gceSTATUS +_InitializePPU_SetSourceBin( + IN gctUINT32 SourceBin, + OUT gctUINT32_PTR binary + ) +{ + gceSTATUS status = gcvSTATUS_OK; + + gcmkHEADER_ARG("SourceBin=0x%x", SourceBin); + + binary[1] = HwFunc_SETBITS(binary[1], 25, 22, SourceBin); + + gcmkFOOTER(); + return status; +} + + +gceSTATUS +_InitializePPU_SetImmediateValue( + IN gctUINT32 Where, + IN gctUINT32 Value, + OUT gctUINT32_PTR binary + ) +{ + gceSTATUS status = gcvSTATUS_OK; + gctINT32 raw = (((gctUINT32)(0) & ~((gctUINT32)(((((1 ? + 19:0) - (0 ? + 19:0) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 19:0) - (0 ? + 19:0) + 1))))) << (0 ? + 19:0))) | ((gctUINT32)((gctUINT32)(Value) & ((((1 ? + 19:0) - (0 ? + 19:0) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 19:0) - (0 ? + 19:0) + 1))))) << (0 ? + 19:0))) | (((gctUINT32)(0) & ~((gctUINT32)(((((1 ? + 21:20) - (0 ? + 21:20) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 21:20) - (0 ? + 21:20) + 1))))) << (0 ? + 21:20))) | ((gctUINT32)(0x2 & ((((1 ? + 21:20) - (0 ? + 21:20) + 1) == 32) ? + ~0 : (gctUINT32)(~((gctUINT64)(~0) << ((1 ? + 21:20) - (0 ? 21:20) + 1))))) << (0 ? 21:20))); + + gcmkHEADER_ARG("Where=0x%x", Where); + + gcmkONERROR(_InitializePPU_SetSource(Where, HwFunc_GETBITS(raw, 8, 0), HwFunc_GETBITS(raw, 16, 9), 0x7, GETBIT(raw, 17), GETBIT(raw, 18), HwFunc_GETBITS(raw, 21, 19), binary)); + +OnError: + gcmkFOOTER(); + return status; +} + +gceSTATUS gcoHwFunc_SH_CMD( + IN gckHARDWARE Hardware, + IN gctUINT32 Data_type, + IN OUT gctUINT32_PTR binarys, + OUT gctUINT32_PTR command_count, + OUT gctUINT32_PTR reg_count + ) +{ + gceSTATUS status = gcvSTATUS_OK; + gctUINT32 count = 0; + gctUINT32 Input1 = Data_type; + gctUINT32 Input2 = Data_type; + gctUINT32 Output = Data_type; + + gcmkHEADER_ARG("binarys=0x%x", binarys); + + /* a. DP instruction with all bin */ + /* b. Store to 6 line which size are 64 bytes and flush out */ + + /*img_load.u8 r1, c0, r0.xy*/ + gcmkONERROR(_InitializePPU_AddOpcode(Hardware, 0x79, 0, Input1, &binarys[count])); + gcmkONERROR(_InitializePPU_SetDestination(1, gcdVX_ENABLE, gcvFALSE, &binarys[count])); + gcmkONERROR(_InitializePPU_SetEVIS(0, _InitializePPU_GetPixel(Input1), 1, &binarys[count])); + gcmkONERROR(_InitializePPU_SetUniform(0, 0, gcdVX_SWIZZLE, 0, &binarys[count])); + gcmkONERROR(_InitializePPU_SetTempReg(1, 0, gcdVX_SWIZZLE2(0, 1), 0, &binarys[count])); + count += 4; + + /*img_load.u8 r2, c0, r0.xy */ + gcmkONERROR(_InitializePPU_AddOpcode(Hardware, 0x79, 0, Input2, &binarys[count])); + gcmkONERROR(_InitializePPU_SetDestination(2, gcdVX_ENABLE, gcvFALSE, &binarys[count])); + gcmkONERROR(_InitializePPU_SetEVIS(0, _InitializePPU_GetPixel(Input2), 1, &binarys[count])); + gcmkONERROR(_InitializePPU_SetUniform(0, 0, gcdVX_SWIZZLE, 0, &binarys[count])); + gcmkONERROR(_InitializePPU_SetTempReg(1, 0, gcdVX_SWIZZLE2(0, 1), 0, &binarys[count])); + count += 4; + + /* dp2x8 r1, r1, r2, c3_512 */ + gcmkONERROR(_InitializePPU_AddOpcode(Hardware, 0x45, 0x0B, Output, &binarys[count])); + gcmkONERROR(_InitializePPU_SetDestination(1, gcdVX_ENABLE, gcvFALSE, &binarys[count])); + gcmkONERROR(_InitializePPU_SetEVIS(0, 7, (Input1 | (Input2 << 3)), &binarys[count])); + gcmkONERROR(_InitializePPU_SetTempReg(0, 1, gcdVX_SWIZZLE, 0, &binarys[count])); + gcmkONERROR(_InitializePPU_SetTempReg(1, 2, gcdVX_SWIZZLE, 0, &binarys[count])); + gcmkONERROR(_InitializePPU_SetSource (2, 2, gcdVX_SWIZZLE, 0x4, gcvFALSE, gcvFALSE, 0, &binarys[count])); + count += 4; + + + /*img_store.u8 r1, c2, r0.xy, r1*/ + gcmkONERROR(_InitializePPU_AddOpcode(Hardware, 0x7A, 0, Output, &binarys[count])); + gcmkONERROR(_InitializePPU_SetEVIS(0, _InitializePPU_GetPixel(Output), 1, &binarys[count])); + gcmkONERROR(_InitializePPU_SetUniform(0, 1, gcdVX_SWIZZLE, 0, &binarys[count])); + gcmkONERROR(_InitializePPU_SetTempReg(1, 0, gcdVX_SWIZZLE2(0, 1), 0, &binarys[count])); + gcmkONERROR(_InitializePPU_SetTempReg(2, 1, gcdVX_SWIZZLE, 0, &binarys[count])); + count += 4; + + *command_count = count; + *reg_count = 0x3; +OnError: + gcmkFOOTER(); + return status; +} + +#endif /*gcdINITIALIZE_PPU*/ + + diff --git a/drivers/amlogic/npu/kernel/arch/gc_hal_kernel_hardware_func_usc.h b/drivers/amlogic/npu/kernel/arch/gc_hal_kernel_hardware_func_usc.h new file mode 100644 index 0000000..c6f6297 --- /dev/null +++ b/drivers/amlogic/npu/kernel/arch/gc_hal_kernel_hardware_func_usc.h @@ -0,0 +1,1724 @@ +/**************************************************************************** +* +* The MIT License (MIT) +* +* Copyright (c) 2014 - 2020 Vivante Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +* +***************************************************************************** +* +* The GPL License (GPL) +* +* Copyright (C) 2014 - 2020 Vivante Corporation +* +* 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 +* of the License, or (at your option) any later version. +* +* 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, write to the Free Software Foundation, +* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +***************************************************************************** +* +* Note: This software is released under dual MIT and GPL licenses. A +* recipient may use this file under the terms of either the MIT license or +* GPL License. If you wish to use only one license not the other, you can +* indicate your decision by deleting one of the above license notices in your +* version of this file. +* +*****************************************************************************/ + + +//#include "gc_hal_user_hardware_precomp.h" +//#include "gc_hal_user.h" +/* +** +*/ +#if gcdRESET_USC1 + +#if gcdRESET_USC_C + +#include "gc_feature_database.h" + +#define USC_DEBUG 0 + +typedef enum _USC_NN_TYPE +{ + USC_NN_TYPE_V6, + USC_NN_TYPE_V7, + USC_NN_TYPE_V8, +} +USC_NN_TYPE; +gceSTATUS +_InitializeUSC_NNCommands( + IN gckHARDWARE Hardware, + IN USC_NN_TYPE hw_type, + IN gctUINT32 kernelAddress, + IN gctUINT32 inImageAddress, + IN gctUINT32 outImageAddress, + IN OUT gctUINT8_PTR data_type, + IN OUT gctUINT32_PTR item_size, + IN OUT gctUINT32_PTR core_count, + IN OUT gctSIZE_T_PTR patchBufferSizes, + IN OUT gctUINT32_PTR* nnCommands + ) +{ + gceSTATUS status = gcvSTATUS_OK; + gckOS os = Hardware->os; + + gctUINT32_PTR command = *nnCommands; + + gctUINT8 kernelDataType = *data_type; + gctUINT8 inImageDataType = *data_type; + gctUINT8 outImageDataType = *data_type; + + gctUINT32 kernelsPerCore = 1; + + gctUINT32 inImageXSize = 3; + gctUINT32 inImageYSize = 2; + + gctUINT32 outImageXSize = 2; + gctUINT32 outImageYSize = 1; + gctUINT32 outImageZSize = 1; + + gctUINT32 kernelXYSize = 2; + gctUINT32 kernelZSize = 1; + + gctUINT32 nn_layer_flush = 1, noZOffset = 0, size = gcmSIZEOF(gctUINT32) * ((hw_type == USC_NN_TYPE_V6)?16:32); + gctUINT32 imageEndAddress = 2048, post_shift = 0, post_shift_bit56 = 0; + gctUINT8 coefZP = 0, outputZP = 0; + gcsFEATURE_DATABASE * db = (gcsFEATURE_DATABASE *)Hardware->featureDatabase; + gctUINT32 config = 0, index = 0; + gctUINT32 configuration[][3] = { + /*item size, data type, core count*/ + {1, 0x2, db->NNCoreCount_INT8}, + {2, 0x4, db->NNCoreCount_INT16}, + {2, 0x1, db->NNCoreCount_FLOAT16}, + {2, 0x7, db->NNCoreCount_BFLOAT}, + }; + + *patchBufferSizes = size; + + if (command == NULL) + { + gcmkONERROR(gckOS_Allocate(os, size, (gctPOINTER*)(&command))); + gcmkONERROR(gckOS_ZeroMemory(command, size)); + + *nnCommands = command; + } + + gcmkASSERT(command != NULL); + gcQueryFeatureDB(0, 0, 0, 0, 0); + + for (index = 0; index < gcmCOUNTOF(configuration); index ++) + { + if(configuration[index][2] > 0) + break; + } + + if (index == gcmCOUNTOF(configuration)) + gcmkASSERT("Hardware not support NN!"); +#if USC_DEBUG + gcmkPRINT("The hardware(0x%0x) support %d\n", db->customerID, index); + gcmkPRINT("\tcore int8 %d\n\tcore int16 %d\n\tcore fp16 %d\n\tcore bfp16 %d\n", + db->NNCoreCount_INT8, db->NNCoreCount_INT16, db->NNCoreCount_FLOAT16, db->NNCoreCount_BFLOAT); + +#endif + *item_size = configuration [index][0]; + *data_type = (gctUINT8)configuration[index][1]; + *core_count = configuration[index][2]; + + kernelDataType = *data_type; + inImageDataType = *data_type; + outImageDataType = *data_type; + + switch (hw_type) + { + case USC_NN_TYPE_V8: + noZOffset = 1; + outputZP = 0; + post_shift = (gckHARDWARE_IsFeatureAvailable(Hardware, gcvFEATURE_NN_FLOAT_POST_MULT))?0x1f:0; + post_shift_bit56 = (gckHARDWARE_IsFeatureAvailable(Hardware, gcvFEATURE_NN_FLOAT_POST_MULT))?3:0; + + break; + case USC_NN_TYPE_V7: + case USC_NN_TYPE_V6: + post_shift = (*data_type == 0x2)?15:0; + break; + default: + break; + } + + /* gcregNNInstWord0 */ + gcmkWRITE_MEMORY(command, + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 0:0) - (0 ? + 0:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 0:0) - (0 ? + 0:0) + 1))))))) << (0 ? + 0:0))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 0:0) - (0 ? + 0:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 0:0) - (0 ? 0:0) + 1))))))) << (0 ? 0:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 1:1) - (0 ? + 1:1) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 1:1) - (0 ? + 1:1) + 1))))))) << (0 ? + 1:1))) | (((gctUINT32) ((gctUINT32) (noZOffset) & ((gctUINT32) ((((1 ? + 1:1) - (0 ? + 1:1) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 1:1) - (0 ? 1:1) + 1))))))) << (0 ? 1:1))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 5:2) - (0 ? + 5:2) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 5:2) - (0 ? + 5:2) + 1))))))) << (0 ? + 5:2))) | (((gctUINT32) ((gctUINT32) (kernelXYSize) & ((gctUINT32) ((((1 ? + 5:2) - (0 ? + 5:2) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 5:2) - (0 ? 5:2) + 1))))))) << (0 ? 5:2))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 19:6) - (0 ? + 19:6) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 19:6) - (0 ? + 19:6) + 1))))))) << (0 ? + 19:6))) | (((gctUINT32) ((gctUINT32) ((kernelZSize & 0x3FFF)) & ((gctUINT32) ((((1 ? + 19:6) - (0 ? + 19:6) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 19:6) - (0 ? 19:6) + 1))))))) << (0 ? 19:6))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 26:20) - (0 ? + 26:20) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 26:20) - (0 ? + 26:20) + 1))))))) << (0 ? + 26:20))) | (((gctUINT32) ((gctUINT32) (kernelsPerCore) & ((gctUINT32) ((((1 ? + 26:20) - (0 ? + 26:20) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 26:20) - (0 ? 26:20) + 1))))))) << (0 ? 26:20))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 28:27) - (0 ? + 28:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 28:27) - (0 ? + 28:27) + 1))))))) << (0 ? + 28:27))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 28:27) - (0 ? + 28:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 28:27) - (0 ? 28:27) + 1))))))) << (0 ? 28:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 29:29) - (0 ? + 29:29) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 29:29) - (0 ? + 29:29) + 1))))))) << (0 ? + 29:29))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 29:29) - (0 ? + 29:29) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 29:29) - (0 ? 29:29) + 1))))))) << (0 ? 29:29))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 30:30) - (0 ? + 30:30) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 30:30) - (0 ? + 30:30) + 1))))))) << (0 ? + 30:30))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 30:30) - (0 ? + 30:30) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 30:30) - (0 ? 30:30) + 1))))))) << (0 ? 30:30))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:31) - (0 ? + 31:31) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:31) - (0 ? + 31:31) + 1))))))) << (0 ? + 31:31))) | (((gctUINT32) ((gctUINT32) (nn_layer_flush) & ((gctUINT32) ((((1 ? + 31:31) - (0 ? + 31:31) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:31) - (0 ? 31:31) + 1))))))) << (0 ? 31:31)))); + + + config = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 18:6) - (0 ? + 18:6) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 18:6) - (0 ? + 18:6) + 1))))))) << (0 ? + 18:6))) | (((gctUINT32) ((gctUINT32) (inImageXSize) & ((gctUINT32) ((((1 ? + 18:6) - (0 ? + 18:6) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 18:6) - (0 ? 18:6) + 1))))))) << (0 ? 18:6))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:19) - (0 ? + 31:19) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:19) - (0 ? + 31:19) + 1))))))) << (0 ? + 31:19))) | (((gctUINT32) ((gctUINT32) (inImageYSize) & ((gctUINT32) ((((1 ? + 31:19) - (0 ? + 31:19) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:19) - (0 ? 31:19) + 1))))))) << (0 ? 31:19))) + + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 1:1) - (0 ? + 1:1) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 1:1) - (0 ? + 1:1) + 1))))))) << (0 ? + 1:1))) | (((gctUINT32) ((gctUINT32) (kernelDataType >> 1) & ((gctUINT32) ((((1 ? + 1:1) - (0 ? + 1:1) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 1:1) - (0 ? 1:1) + 1))))))) << (0 ? 1:1))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 3:3) - (0 ? + 3:3) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 3:3) - (0 ? + 3:3) + 1))))))) << (0 ? + 3:3))) | (((gctUINT32) ((gctUINT32) (inImageDataType >> 1) & ((gctUINT32) ((((1 ? + 3:3) - (0 ? + 3:3) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 3:3) - (0 ? 3:3) + 1))))))) << (0 ? 3:3))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 5:5) - (0 ? + 5:5) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 5:5) - (0 ? + 5:5) + 1))))))) << (0 ? + 5:5))) | (((gctUINT32) ((gctUINT32) (outImageDataType >> 1) & ((gctUINT32) ((((1 ? + 5:5) - (0 ? + 5:5) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 5:5) - (0 ? 5:5) + 1))))))) << (0 ? 5:5))) + + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 0:0) - (0 ? + 0:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 0:0) - (0 ? + 0:0) + 1))))))) << (0 ? + 0:0))) | (((gctUINT32) ((gctUINT32) (kernelDataType & 0x1) & ((gctUINT32) ((((1 ? + 0:0) - (0 ? + 0:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 0:0) - (0 ? 0:0) + 1))))))) << (0 ? 0:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 2:2) - (0 ? + 2:2) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 2:2) - (0 ? + 2:2) + 1))))))) << (0 ? + 2:2))) | (((gctUINT32) ((gctUINT32) (inImageDataType & 0x1) & ((gctUINT32) ((((1 ? + 2:2) - (0 ? + 2:2) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 2:2) - (0 ? 2:2) + 1))))))) << (0 ? 2:2))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 4:4) - (0 ? + 4:4) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 4:4) - (0 ? + 4:4) + 1))))))) << (0 ? + 4:4))) | (((gctUINT32) ((gctUINT32) (outImageDataType & 0x1) & ((gctUINT32) ((((1 ? + 4:4) - (0 ? + 4:4) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 4:4) - (0 ? 4:4) + 1))))))) << (0 ? 4:4))); + + /* gcregNNInstWord1 */ + gcmkWRITE_MEMORY(command, config); + + /* gcregNNInstWord2 */ + gcmkWRITE_MEMORY(command, + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 24:24) - (0 ? + 24:24) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 24:24) - (0 ? + 24:24) + 1))))))) << (0 ? + 24:24))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 24:24) - (0 ? + 24:24) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 24:24) - (0 ? 24:24) + 1))))))) << (0 ? 24:24))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:25) - (0 ? + 25:25) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:25) - (0 ? + 25:25) + 1))))))) << (0 ? + 25:25))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 25:25) - (0 ? + 25:25) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:25) - (0 ? 25:25) + 1))))))) << (0 ? 25:25))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 2:0) - (0 ? + 2:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 2:0) - (0 ? + 2:0) + 1))))))) << (0 ? + 2:0))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 2:0) - (0 ? + 2:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 2:0) - (0 ? 2:0) + 1))))))) << (0 ? 2:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 5:3) - (0 ? + 5:3) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 5:3) - (0 ? + 5:3) + 1))))))) << (0 ? + 5:3))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 5:3) - (0 ? + 5:3) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 5:3) - (0 ? 5:3) + 1))))))) << (0 ? 5:3))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 26:26) - (0 ? + 26:26) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 26:26) - (0 ? + 26:26) + 1))))))) << (0 ? + 26:26))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 26:26) - (0 ? + 26:26) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 26:26) - (0 ? 26:26) + 1))))))) << (0 ? 26:26))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 7:7) - (0 ? + 7:7) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 7:7) - (0 ? + 7:7) + 1))))))) << (0 ? + 7:7))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 7:7) - (0 ? + 7:7) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 7:7) - (0 ? 7:7) + 1))))))) << (0 ? 7:7))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 23:8) - (0 ? + 23:8) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 23:8) - (0 ? + 23:8) + 1))))))) << (0 ? + 23:8))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 23:8) - (0 ? + 23:8) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 23:8) - (0 ? 23:8) + 1))))))) << (0 ? 23:8))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) ((gctUINT32) (post_shift) & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27)))); + + /* gcregNNInstWord3 */ + gcmkWRITE_MEMORY(command, + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 18:6) - (0 ? + 18:6) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 18:6) - (0 ? + 18:6) + 1))))))) << (0 ? + 18:6))) | (((gctUINT32) ((gctUINT32) (outImageXSize) & ((gctUINT32) ((((1 ? + 18:6) - (0 ? + 18:6) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 18:6) - (0 ? 18:6) + 1))))))) << (0 ? 18:6))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:19) - (0 ? + 31:19) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:19) - (0 ? + 31:19) + 1))))))) << (0 ? + 31:19))) | (((gctUINT32) ((gctUINT32) (outImageYSize) & ((gctUINT32) ((((1 ? + 31:19) - (0 ? + 31:19) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:19) - (0 ? 31:19) + 1))))))) << (0 ? 31:19))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 2:2) - (0 ? + 2:2) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 2:2) - (0 ? + 2:2) + 1))))))) << (0 ? + 2:2))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 2:2) - (0 ? + 2:2) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 2:2) - (0 ? 2:2) + 1))))))) << (0 ? 2:2))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 3:3) - (0 ? + 3:3) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 3:3) - (0 ? + 3:3) + 1))))))) << (0 ? + 3:3))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 3:3) - (0 ? + 3:3) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 3:3) - (0 ? 3:3) + 1))))))) << (0 ? 3:3)))); + + /* gcregNNInstWord4 */ + gcmkWRITE_MEMORY(command, + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 13:0) - (0 ? + 13:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 13:0) - (0 ? + 13:0) + 1))))))) << (0 ? + 13:0))) | (((gctUINT32) ((gctUINT32) (outImageZSize) & ((gctUINT32) ((((1 ? + 13:0) - (0 ? + 13:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 13:0) - (0 ? 13:0) + 1))))))) << (0 ? 13:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:14) - (0 ? + 15:14) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:14) - (0 ? + 15:14) + 1))))))) << (0 ? + 15:14))) | (((gctUINT32) ((gctUINT32) (0x0) & ((gctUINT32) ((((1 ? + 15:14) - (0 ? + 15:14) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:14) - (0 ? 15:14) + 1))))))) << (0 ? 15:14))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 24:18) - (0 ? + 24:18) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 24:18) - (0 ? + 24:18) + 1))))))) << (0 ? + 24:18))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 24:18) - (0 ? + 24:18) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 24:18) - (0 ? 24:18) + 1))))))) << (0 ? 24:18))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:25) - (0 ? + 31:25) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:25) - (0 ? + 31:25) + 1))))))) << (0 ? + 31:25))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 31:25) - (0 ? + 31:25) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:25) - (0 ? 31:25) + 1))))))) << (0 ? 31:25))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 16:16) - (0 ? + 16:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 16:16) - (0 ? + 16:16) + 1))))))) << (0 ? + 16:16))) | (((gctUINT32) ((gctUINT32) ((0 >> 3) & 0x1) & ((gctUINT32) ((((1 ? + 16:16) - (0 ? + 16:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 16:16) - (0 ? 16:16) + 1))))))) << (0 ? 16:16))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 17:17) - (0 ? + 17:17) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 17:17) - (0 ? + 17:17) + 1))))))) << (0 ? + 17:17))) | (((gctUINT32) ((gctUINT32) ((0 >> 3) & 0x1) & ((gctUINT32) ((((1 ? + 17:17) - (0 ? + 17:17) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 17:17) - (0 ? 17:17) + 1))))))) << (0 ? 17:17)))); + + + /* gcregNNInstWord5 */ + gcmkWRITE_MEMORY(command, + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:26) - (0 ? + 31:26) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:26) - (0 ? + 31:26) + 1))))))) << (0 ? + 31:26))) | (((gctUINT32) ((gctUINT32) (((kernelZSize >> 14) & 0x3F)) & ((gctUINT32) ((((1 ? + 31:26) - (0 ? + 31:26) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:26) - (0 ? 31:26) + 1))))))) << (0 ? 31:26))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:0) - (0 ? + 25:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:0) - (0 ? + 25:0) + 1))))))) << (0 ? + 25:0))) | (((gctUINT32) ((gctUINT32) ((kernelAddress >> 6)) & ((gctUINT32) ((((1 ? + 25:0) - (0 ? + 25:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:0) - (0 ? 25:0) + 1))))))) << (0 ? 25:0)))); + + /* gcregNNInstWord6 */ + gcmkWRITE_MEMORY(command, inImageAddress); + /* gcregNNInstWord7 */ + gcmkWRITE_MEMORY(command, outImageAddress); + + gcmkWRITE_MEMORY(command, + /* gcmSETFIELD (0, GCREG_NN_INST_WORD8, IMAGE_CACHING_MODE, imageCachingMode) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 3:2) - (0 ? + 3:2) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 3:2) - (0 ? + 3:2) + 1))))))) << (0 ? + 3:2))) | (((gctUINT32) ((gctUINT32) (kernelCachingMode) & ((gctUINT32) ((((1 ? + 3:2) - (0 ? + 3:2) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 3:2) - (0 ? 3:2) + 1))))))) << (0 ? 3:2))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 5:4) - (0 ? + 5:4) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 5:4) - (0 ? + 5:4) + 1))))))) << (0 ? + 5:4))) | (((gctUINT32) ((gctUINT32) (partialCacheDataUnit) & ((gctUINT32) ((((1 ? + 5:4) - (0 ? + 5:4) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 5:4) - (0 ? 5:4) + 1))))))) << (0 ? 5:4))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 11:6) - (0 ? + 11:6) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 11:6) - (0 ? + 11:6) + 1))))))) << (0 ? + 11:6))) | (((gctUINT32) ((gctUINT32) (kernelPatternMsb) & ((gctUINT32) ((((1 ? + 11:6) - (0 ? + 11:6) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 11:6) - (0 ? 11:6) + 1))))))) << (0 ? 11:6))) + | */((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:12) - (0 ? + 15:12) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:12) - (0 ? + 15:12) + 1))))))) << (0 ? + 15:12))) | (((gctUINT32) ((gctUINT32) (kernelXYSize) & ((gctUINT32) ((((1 ? + 15:12) - (0 ? + 15:12) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:12) - (0 ? 15:12) + 1))))))) << (0 ? 15:12))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:16) - (0 ? + 31:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:16) - (0 ? + 31:16) + 1))))))) << (0 ? + 31:16))) | (((gctUINT32) ((gctUINT32) (outImageYSize) & ((gctUINT32) ((((1 ? + 31:16) - (0 ? + 31:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:16) - (0 ? 31:16) + 1))))))) << (0 ? 31:16)))); + + /* 31:0 */ + gcmkWRITE_MEMORY(command, 0); + + /* 31:0 */ + gcmkWRITE_MEMORY(command, 0); + + /* 31:0 */ + gcmkWRITE_MEMORY(command, 0); + + /* CREG_NN_INST_WORD12_KERNEL_CACHE_END_ADDRESS */ + gcmkWRITE_MEMORY(command, 0); + + /* 31:0 */ + gcmkWRITE_MEMORY(command, 0); + + /* GCREG_NN_INST_WORD14, IMAGE_END_ADDRESS */ + gcmkWRITE_MEMORY(command, imageEndAddress); + + + /*1:0*/ + gcmkWRITE_MEMORY(command, + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 1:0) - (0 ? + 1:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 1:0) - (0 ? + 1:0) + 1))))))) << (0 ? + 1:0))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 1:0) - (0 ? + 1:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 1:0) - (0 ? 1:0) + 1))))))) << (0 ? 1:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 17:2) - (0 ? + 17:2) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 17:2) - (0 ? + 17:2) + 1))))))) << (0 ? + 17:2))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 17:2) - (0 ? + 17:2) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 17:2) - (0 ? 17:2) + 1))))))) << (0 ? 17:2))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 19:19) - (0 ? + 19:19) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 19:19) - (0 ? + 19:19) + 1))))))) << (0 ? + 19:19))) | (((gctUINT32) ((gctUINT32) (kernelDataType >> 2) & ((gctUINT32) ((((1 ? + 19:19) - (0 ? + 19:19) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 19:19) - (0 ? 19:19) + 1))))))) << (0 ? 19:19))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 20:20) - (0 ? + 20:20) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 20:20) - (0 ? + 20:20) + 1))))))) << (0 ? + 20:20))) | (((gctUINT32) ((gctUINT32) (inImageDataType >> 2) & ((gctUINT32) ((((1 ? + 20:20) - (0 ? + 20:20) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 20:20) - (0 ? 20:20) + 1))))))) << (0 ? 20:20))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 21:21) - (0 ? + 21:21) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 21:21) - (0 ? + 21:21) + 1))))))) << (0 ? + 21:21))) | (((gctUINT32) ((gctUINT32) (outImageDataType >> 2) & ((gctUINT32) ((((1 ? + 21:21) - (0 ? + 21:21) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 21:21) - (0 ? 21:21) + 1))))))) << (0 ? 21:21))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 27:22) - (0 ? + 27:22) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 27:22) - (0 ? + 27:22) + 1))))))) << (0 ? + 27:22))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 27:22) - (0 ? + 27:22) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 27:22) - (0 ? 27:22) + 1))))))) << (0 ? 27:22))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 29:28) - (0 ? + 29:28) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 29:28) - (0 ? + 29:28) + 1))))))) << (0 ? + 29:28))) | (((gctUINT32) ((gctUINT32) (post_shift_bit56) & ((gctUINT32) ((((1 ? + 29:28) - (0 ? + 29:28) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 29:28) - (0 ? 29:28) + 1))))))) << (0 ? 29:28)))); + + /* V7 or V8 */ + if (hw_type == USC_NN_TYPE_V7 || hw_type == USC_NN_TYPE_V8) + { + /*GCREG_NN_INST_WORD16*/ + gcmkWRITE_MEMORY(command, + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (inImageXSize * (*item_size)) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:16) - (0 ? + 31:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:16) - (0 ? + 31:16) + 1))))))) << (0 ? + 31:16))) | (((gctUINT32) ((gctUINT32) (inImageYSize) & ((gctUINT32) ((((1 ? + 31:16) - (0 ? + 31:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:16) - (0 ? 31:16) + 1))))))) << (0 ? 31:16)))); + + /*GCREG_NN_INST_WORD17*/ + gcmkWRITE_MEMORY(command, ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (outImageXSize * (*item_size)) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:24) - (0 ? + 31:24) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:24) - (0 ? + 31:24) + 1))))))) << (0 ? + 31:24))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 31:24) - (0 ? + 31:24) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:24) - (0 ? 31:24) + 1))))))) << (0 ? 31:24)))); + + + /*GCREG_NN_INST_WORD18*/ + gcmkWRITE_MEMORY(command, + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:0) - (0 ? + 25:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:0) - (0 ? + 25:0) + 1))))))) << (0 ? + 25:0))) | (((gctUINT32) ((gctUINT32) (0 >> 6) & ((gctUINT32) ((((1 ? + 25:0) - (0 ? + 25:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:0) - (0 ? 25:0) + 1))))))) << (0 ? 25:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 26:26) - (0 ? + 26:26) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 26:26) - (0 ? + 26:26) + 1))))))) << (0 ? + 26:26))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 26:26) - (0 ? + 26:26) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 26:26) - (0 ? 26:26) + 1))))))) << (0 ? 26:26))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 29:29) - (0 ? + 29:29) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 29:29) - (0 ? + 29:29) + 1))))))) << (0 ? + 29:29))) | (((gctUINT32) ((gctUINT32) ((0 >> 4) & 0x1) & ((gctUINT32) ((((1 ? + 29:29) - (0 ? + 29:29) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 29:29) - (0 ? 29:29) + 1))))))) << (0 ? 29:29))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 30:30) - (0 ? + 30:30) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 30:30) - (0 ? + 30:30) + 1))))))) << (0 ? + 30:30))) | (((gctUINT32) ((gctUINT32) ((0 >> 4) & 0x1) & ((gctUINT32) ((((1 ? + 30:30) - (0 ? + 30:30) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 30:30) - (0 ? 30:30) + 1))))))) << (0 ? 30:30))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 28:28) - (0 ? + 28:28) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 28:28) - (0 ? + 28:28) + 1))))))) << (0 ? + 28:28))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 28:28) - (0 ? + 28:28) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 28:28) - (0 ? 28:28) + 1))))))) << (0 ? 28:28))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:31) - (0 ? + 31:31) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:31) - (0 ? + 31:31) + 1))))))) << (0 ? + 31:31))) | (((gctUINT32) ((gctUINT32) (kernelDataType >> 3) & ((gctUINT32) ((((1 ? + 31:31) - (0 ? + 31:31) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:31) - (0 ? 31:31) + 1))))))) << (0 ? 31:31)))); + + /*25:0*/ + gcmkWRITE_MEMORY(command, + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:0) - (0 ? + 25:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:0) - (0 ? + 25:0) + 1))))))) << (0 ? + 25:0))) | (((gctUINT32) ((gctUINT32) (0xFFFFFFFF >> 6) & ((gctUINT32) ((((1 ? + 25:0) - (0 ? + 25:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:0) - (0 ? 25:0) + 1))))))) << (0 ? 25:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 30:30) - (0 ? + 30:30) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 30:30) - (0 ? + 30:30) + 1))))))) << (0 ? + 30:30))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 30:30) - (0 ? + 30:30) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 30:30) - (0 ? 30:30) + 1))))))) << (0 ? 30:30))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:31) - (0 ? + 31:31) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:31) - (0 ? + 31:31) + 1))))))) << (0 ? + 31:31))) | (((gctUINT32) ((gctUINT32) (inImageDataType >> 3) & ((gctUINT32) ((((1 ? + 31:31) - (0 ? + 31:31) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:31) - (0 ? 31:31) + 1))))))) << (0 ? 31:31)))); + + /*GCREG_NN_INST_WORD20*/ + gcmkWRITE_MEMORY(command, ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:0) - (0 ? + 25:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:0) - (0 ? + 25:0) + 1))))))) << (0 ? + 25:0))) | (((gctUINT32) ((gctUINT32) (0 >> 6) & ((gctUINT32) ((((1 ? + 25:0) - (0 ? + 25:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:0) - (0 ? 25:0) + 1))))))) << (0 ? 25:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 26:26) - (0 ? + 26:26) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 26:26) - (0 ? + 26:26) + 1))))))) << (0 ? + 26:26))) | (((gctUINT32) ((gctUINT32) (outImageDataType >> 3) & ((gctUINT32) ((((1 ? + 26:26) - (0 ? + 26:26) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 26:26) - (0 ? 26:26) + 1))))))) << (0 ? 26:26)))); + + /*25:0*/ + gcmkWRITE_MEMORY(command, ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:0) - (0 ? + 25:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:0) - (0 ? + 25:0) + 1))))))) << (0 ? + 25:0))) | (((gctUINT32) ((gctUINT32) (0xFFFFFFFF >> 6) & ((gctUINT32) ((((1 ? + 25:0) - (0 ? + 25:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:0) - (0 ? 25:0) + 1))))))) << (0 ? 25:0)))); + + /*GCREG_NN_INST_WORD22*/ + gcmkWRITE_MEMORY(command, + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 7:0) - (0 ? + 7:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 7:0) - (0 ? + 7:0) + 1))))))) << (0 ? + 7:0))) | (((gctUINT32) ((gctUINT32) (coefZP) & ((gctUINT32) ((((1 ? + 7:0) - (0 ? + 7:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 7:0) - (0 ? 7:0) + 1))))))) << (0 ? 7:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:8) - (0 ? + 15:8) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:8) - (0 ? + 15:8) + 1))))))) << (0 ? + 15:8))) | (((gctUINT32) ((gctUINT32) (outputZP) & ((gctUINT32) ((((1 ? + 15:8) - (0 ? + 15:8) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:8) - (0 ? 15:8) + 1))))))) << (0 ? 15:8))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 16:16) - (0 ? + 16:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 16:16) - (0 ? + 16:16) + 1))))))) << (0 ? + 16:16))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 16:16) - (0 ? + 16:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 16:16) - (0 ? 16:16) + 1))))))) << (0 ? 16:16))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 17:17) - (0 ? + 17:17) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 17:17) - (0 ? + 17:17) + 1))))))) << (0 ? + 17:17))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 17:17) - (0 ? + 17:17) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 17:17) - (0 ? 17:17) + 1))))))) << (0 ? 17:17))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:18) - (0 ? + 25:18) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:18) - (0 ? + 25:18) + 1))))))) << (0 ? + 25:18))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 25:18) - (0 ? + 25:18) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:18) - (0 ? 25:18) + 1))))))) << (0 ? 25:18)))); + + /*GCREG_NN_INST_WORD23*/ + gcmkWRITE_MEMORY(command, 0); + + /*GCREG_NN_INST_WORD24*/ + gcmkWRITE_MEMORY(command, + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 3:0) - (0 ? + 3:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 3:0) - (0 ? + 3:0) + 1))))))) << (0 ? + 3:0))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 3:0) - (0 ? + 3:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 3:0) - (0 ? 3:0) + 1))))))) << (0 ? 3:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:4) - (0 ? + 31:4) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:4) - (0 ? + 31:4) + 1))))))) << (0 ? + 31:4))) | (((gctUINT32) ((gctUINT32) (0 >> 4) & ((gctUINT32) ((((1 ? + 31:4) - (0 ? + 31:4) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:4) - (0 ? 31:4) + 1))))))) << (0 ? 31:4)))); + + /*GCREG_NN_INST_WORD25*/ + gcmkWRITE_MEMORY(command, + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 3:0) - (0 ? + 3:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 3:0) - (0 ? + 3:0) + 1))))))) << (0 ? + 3:0))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 3:0) - (0 ? + 3:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 3:0) - (0 ? 3:0) + 1))))))) << (0 ? 3:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:4) - (0 ? + 31:4) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:4) - (0 ? + 31:4) + 1))))))) << (0 ? + 31:4))) | (((gctUINT32) ((gctUINT32) (0 >> 4) & ((gctUINT32) ((((1 ? + 31:4) - (0 ? + 31:4) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:4) - (0 ? 31:4) + 1))))))) << (0 ? 31:4)))); + } + +OnError: + return status; +} + +gceSTATUS +_BitValue( + IN gctUINT8_PTR* base, + IN gctUINT32 value, + IN gctUINT32_PTR offset, + IN gctUINT length) +{ + gceSTATUS status = gcvSTATUS_OK; + gctUINT32_PTR msb = (gctUINT32_PTR)(*base) + 1, lsb = (gctUINT32_PTR)(*base); + + gcmkASSERT(*offset <= 32 && length <= 32); + + if ((*offset) < 32) + { + gctUINT32 end = (*offset) + length, data = *lsb; + + if (end < 32) + { + /************************************************************************ + * offset 32 64 * + * _________________________ * + * |_____|////|_|____________| * + * end * + ************************************************************************/ + data = (*lsb & ((1 << *offset) - 1)); + data |= (*lsb & ~((1 << end) - 1)); + data |= (value << *offset); + + *lsb = data; + *offset = end; + } + else if (end < 64) + { + /************************************************************************ + * offset 32 64 * + * _________________________ * + * |_____|//////|//|_________| * + * end * + ************************************************************************/ + gctUINT32 length_m = end - 32; + gctUINT32 data_l = (*lsb & ((1 << *offset) - 1)); + gctUINT32 data_m = (*msb & ~((1 << length_m) - 1)); + + data_l |= (value << *offset); + data_m |= (value >> length_m); + + *lsb = data_l; + + if (end > 32) + *msb = data_m; + + *offset = length_m; + + *base = (gctUINT8_PTR)msb; + } + + } + + return status; +} + +gceSTATUS +_InitializeUSC_NNKernel( + IN gckHARDWARE Hardware, + IN USC_NN_TYPE hw_type, + IN gctUINT8 data_type, + IN gctUINT32 item_size, + IN gctUINT32 core_count, + IN OUT gctUINT32_PTR nnKernels + ) +{ + gceSTATUS status = gcvSTATUS_OK; + + gctUINT8_PTR kernels = (gctUINT8_PTR)nnKernels; + gctUINT8_PTR kernel_stream_size_ptr = 0; + gctUINT32 filterTotalCount = 1, filterSize = 2 * 2 * 1 * item_size, biasSize = 4; + + /* v8 huffman encoder */ + if (USC_NN_TYPE_V8 == hw_type) + { + gctUINT32 i = 0, offset = 0; + /*uint8, fp16, int8, uint16, int16, uint4, int4, bf16*/ + gctUINT8 rlt[][18] = {{0}, {1, 1, 0, 1}, {7, 1}, {0}, {3, 1, 0, 1}, {0}, {0}, {1, 1, 0, 1} }; + gctUINT8 map[][9] = { + {1, 8, 7, 0, 4, 5, 6, 2, 3}, + {1, 5, 0, 7, 8, 2, 6, 3, 4}, + {1, 0, 7, 8, 4, 5, 6, 2, 3}, + }; + gctBOOL bit16 = (data_type == 0x4) || data_type == (0x1) || data_type == (0x7); + gctBOOL fp16 = (data_type == 0x1); + gctUINT32 index = (data_type == 0x1)?1:((data_type == 0x7)?2:0); + + gcmkONERROR(_BitValue(&kernels, 0, &offset, 1));/*precode*/ + gcmkONERROR(_BitValue(&kernels, bit16, &offset, 1));/*bit16*/ + gcmkONERROR(_BitValue(&kernels, fp16, &offset, 1));/*fp16*/ + gcmkONERROR(_BitValue(&kernels, 0, &offset, 1));/*reserve*/ + gcmkONERROR(_BitValue(&kernels, 1, &offset, 4));/*version, 1*/ + gcmkONERROR(_BitValue(&kernels, 4, &offset, 8));/*zero run length size*/ + + for(i = 0; i < 18; i++) + gcmkONERROR(_BitValue(&kernels, rlt[data_type][i], &offset, 8));/*zero run length x 18*/ + + for(i = 0; i < 4; i++) + { + gcmkONERROR(_BitValue(&kernels, (map[index][2 * i + 1] << 4) + map[index][2 * i], &offset, 8));/*map x 4*/ + } + + gcmkONERROR(_BitValue(&kernels, 0, &offset, 16));/*avg bias*/ + + gcmkONERROR(_BitValue(&kernels, 0, &offset, 16));/*reserved, must zero*/ + + kernel_stream_size_ptr = kernels; + for (i = 0; i < core_count; i ++) + gcmkONERROR(_BitValue(&kernels, 0, &offset, 32));/*stream size*/ + + kernels = (gctUINT8_PTR)nnKernels + gcmALIGN_NP2((gctUINT32)((gctUINT32_PTR)kernels - nnKernels), 64); + + switch (data_type) + { + case 0x4: + gcmkONERROR(_BitValue(&kernels, 0x04058000, &offset, 32));/*huffman data*/ /*00000018 00924600*/ + gcmkONERROR(_BitValue(&kernels, 0x640101fc, &offset, 32));/*huffman data*/ + gcmkONERROR(_BitValue(&kernels, 0x00001200, &offset, 32));/*huffman data*/ + + gcmkONERROR(_BitValue(&kernel_stream_size_ptr, 0x0000006d, &offset, 32));/*only on core, stream size*/ + + + break; + case 0x0: + case 0x2: + gcmkONERROR(_BitValue(&kernels, 0xec000038, &offset, 32));/*huffman data*/ + + gcmkONERROR(_BitValue(&kernel_stream_size_ptr, 0x35, &offset, 32));/*only on core, stream size*/ + + break; + case 0x1: + gcmkONERROR(_BitValue(&kernels, 0x0009db68, &offset, 32));/*huffman data*/ /*0009db68 000006c0 000001f0 00000900 00024000*/ + gcmkONERROR(_BitValue(&kernels, 0x000006c0, &offset, 32));/*huffman data*/ + gcmkONERROR(_BitValue(&kernels, 0x000001f0, &offset, 32));/*huffman data*/ + gcmkONERROR(_BitValue(&kernels, 0x00000900, &offset, 32));/*huffman data*/ + gcmkONERROR(_BitValue(&kernels, 0x00024000, &offset, 32));/*huffman data*/ + + gcmkONERROR(_BitValue(&kernel_stream_size_ptr, 0x000000a3, &offset, 32));/*only on core, stream size*/ + + break; + case 0x7: + gcmkONERROR(_BitValue(&kernels, 0x0007fff8, &offset, 32));/*huffman data*/ /*0007fff8 7f00fdfc c0397f00 0900001f 40000000 00000002*/ + gcmkONERROR(_BitValue(&kernels, 0x7f00fdfc, &offset, 32));/*huffman data*/ + gcmkONERROR(_BitValue(&kernels, 0xc0397f00, &offset, 32));/*huffman data*/ + gcmkONERROR(_BitValue(&kernels, 0x0900001f, &offset, 32));/*huffman data*/ + gcmkONERROR(_BitValue(&kernels, 0x40000000, &offset, 32));/*huffman data*/ + gcmkONERROR(_BitValue(&kernels, 0x00000002, &offset, 32));/*huffman data*/ + + gcmkONERROR(_BitValue(&kernel_stream_size_ptr, 0x000000b2, &offset, 32));/*only on core, stream size*/ + + break; + default: + gcmkASSERT("Huffman encode not support this format! Please check!"); + break; + } + + + } + else + { + gctBOOL zero_all = gcvFALSE; + gctUINT8 zrl = 0; + gctUINT16 vznum = 1; + gctUINT32 bias = 0; + gctUINT32 total_size = gcmALIGN_NP2((filterTotalCount * (filterSize + biasSize + 3) + 3), 64);//1 + 2 + *item_size;; + + gckOS_ZeroMemory(kernels, total_size + 64); + + *((gctUINT32_PTR)kernels) = total_size; + kernels += total_size; + if (zero_all) + *((gctUINT32_PTR)kernels) = (vznum << (8 * item_size));/*zrl & coreFilterCount, both compressed weight and bias are zero, the size(1 * 1 * 2 * 2 + 4 ) < 64, align to 64*/ + else + { + gctINT16 value = (data_type == 0x1)?0x3c00/*1.0f*/:1; + gctUINT32 i = 0, offset = 0; + + _BitValue(&kernels, zrl, &offset, 8); + _BitValue(&kernels, vznum, &offset, 16); + _BitValue(&kernels, value, &offset, 8 * item_size); + _BitValue(&kernels, bias, &offset, 32); + if (data_type == 0x3 || data_type == 0x4) + _BitValue(&kernels, 0, &offset, 16); + + for (i = 1; i < filterSize/item_size; i ++) + _BitValue(&kernels, value, &offset, 8 * item_size); + } + + } +OnError: + return status; +} +static gceSTATUS _InitializeUSC_NNCmdBuffer(IN gckHARDWARE Hardware, + IN USC_NN_TYPE hw_type, + IN gctUINT32_PTR flushCommands, + IN gctUINT32 CmdAddress, + IN gctUINT32 SramRemapAddress, + OUT gctUINT32_PTR Bytes) +{ + gceSTATUS status = gcvSTATUS_OK; + gcsFEATURE_DATABASE *db = (gcsFEATURE_DATABASE *)(Hardware->featureDatabase); + gctUINT32 idx = 0, kernel_brust_size = db->DDR_KERNEL_BURST_SIZE; + gctINT32 disableZDPN = 1, disableSWTiling = 1, smallBatch = 1, ddrBurstSize = 0; + gctBOOL enableNNStride = gcvFALSE; + + disableZDPN = (db->NN_ZDP3 || db->NN_ZDP6) ? 0 : 1; + + enableNNStride = db->NN_STRIDE_SUPPORT; + disableSWTiling = enableNNStride ? 0 : 1; + + switch(kernel_brust_size) + { + case 256: + ddrBurstSize = 0x2; + break; + case 64: + ddrBurstSize = 0x0; + break; + default: + break; + } + + if (Hardware->identity.chipModel == 0x8000 && Hardware->identity.chipRevision == 0x7120 && + (Hardware->identity.customerID == 0x80 || Hardware->identity.customerID == 0x92)) + smallBatch = 0x0; + else + smallBatch = (db->NN_SMALLBATCH_PHASE1 && db->NN_COMMAND_KERNEL_REQUEST_CONFICT_FIX) + ? 0x0 : 0x1; + + if (hw_type == USC_NN_TYPE_V6) + { + flushCommands[idx++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x006B) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + flushCommands[idx++] = 0; + + flushCommands[idx++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0E03) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + flushCommands[idx++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 6:6) - (0 ? + 6:6) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 6:6) - (0 ? + 6:6) + 1))))))) << (0 ? + 6:6))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 6:6) - (0 ? + 6:6) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 6:6) - (0 ? 6:6) + 1))))))) << (0 ? 6:6))); + } + + flushCommands[idx++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0E4E) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + flushCommands[idx++] = SramRemapAddress; + + flushCommands[idx++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0E4F) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + flushCommands[idx++] = 0x00000000; + + flushCommands[idx++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0E50) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + flushCommands[idx++] = 0x00000000; + + flushCommands[idx++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0E03) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + flushCommands[idx++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 6:6) - (0 ? + 6:6) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 6:6) - (0 ? + 6:6) + 1))))))) << (0 ? + 6:6))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 6:6) - (0 ? + 6:6) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 6:6) - (0 ? 6:6) + 1))))))) << (0 ? 6:6))); + + flushCommands[idx++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0E4C) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + + flushCommands[idx++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 2:2) - (0 ? + 2:2) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 2:2) - (0 ? + 2:2) + 1))))))) << (0 ? + 2:2))) | (((gctUINT32) ((gctUINT32) (disableZDPN) & ((gctUINT32) ((((1 ? + 2:2) - (0 ? + 2:2) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 2:2) - (0 ? 2:2) + 1))))))) << (0 ? 2:2))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 3:3) - (0 ? + 3:3) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 3:3) - (0 ? + 3:3) + 1))))))) << (0 ? + 3:3))) | (((gctUINT32) ((gctUINT32) (disableSWTiling) & ((gctUINT32) ((((1 ? + 3:3) - (0 ? + 3:3) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 3:3) - (0 ? 3:3) + 1))))))) << (0 ? 3:3))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 4:4) - (0 ? + 4:4) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 4:4) - (0 ? + 4:4) + 1))))))) << (0 ? + 4:4))) | (((gctUINT32) ((gctUINT32) (smallBatch) & ((gctUINT32) ((((1 ? + 4:4) - (0 ? + 4:4) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 4:4) - (0 ? 4:4) + 1))))))) << (0 ? 4:4))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 6:5) - (0 ? + 6:5) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 6:5) - (0 ? + 6:5) + 1))))))) << (0 ? + 6:5))) | (((gctUINT32) ((gctUINT32) (ddrBurstSize) & ((gctUINT32) ((((1 ? + 6:5) - (0 ? + 6:5) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 6:5) - (0 ? 6:5) + 1))))))) << (0 ? 6:5))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 12:12) - (0 ? + 12:12) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 12:12) - (0 ? + 12:12) + 1))))))) << (0 ? + 12:12))) | (((gctUINT32) ((gctUINT32) (0x0) & ((gctUINT32) ((((1 ? + 12:12) - (0 ? + 12:12) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 12:12) - (0 ? 12:12) + 1))))))) << (0 ? 12:12))); + + + flushCommands[idx++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0E54) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + + flushCommands[idx++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 0:0) - (0 ? + 0:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 0:0) - (0 ? + 0:0) + 1))))))) << (0 ? + 0:0))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 0:0) - (0 ? + 0:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 0:0) - (0 ? 0:0) + 1))))))) << (0 ? 0:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 1:1) - (0 ? + 1:1) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 1:1) - (0 ? + 1:1) + 1))))))) << (0 ? + 1:1))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 1:1) - (0 ? + 1:1) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 1:1) - (0 ? 1:1) + 1))))))) << (0 ? 1:1))); + + + flushCommands[idx++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0428) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + + flushCommands[idx++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:6) - (0 ? + 31:6) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:6) - (0 ? + 31:6) + 1))))))) << (0 ? + 31:6))) | (((gctUINT32) ((gctUINT32) ((CmdAddress >> 6)) & ((gctUINT32) ((((1 ? + 31:6) - (0 ? + 31:6) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:6) - (0 ? 31:6) + 1))))))) << (0 ? 31:6))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 4:0) - (0 ? + 4:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 4:0) - (0 ? + 4:0) + 1))))))) << (0 ? + 4:0))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? + 4:0) - (0 ? + 4:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 4:0) - (0 ? 4:0) + 1))))))) << (0 ? 4:0))); + + flushCommands[idx++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0429) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + + flushCommands[idx++] = 0; + + flushCommands[idx++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 31:27) - (0 ? + 31:27) + 1))))))) << (0 ? + 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? + 31:27) - (0 ? + 31:27) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 15:0) - (0 ? + 15:0) + 1))))))) << (0 ? + 15:0))) | (((gctUINT32) ((gctUINT32) (0x0E03) & ((gctUINT32) ((((1 ? + 15:0) - (0 ? + 15:0) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) + | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 25:16) - (0 ? + 25:16) + 1))))))) << (0 ? + 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? + 25:16) - (0 ? + 25:16) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); + + flushCommands[idx++] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? + 5:5) - (0 ? + 5:5) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? + 5:5) - (0 ? + 5:5) + 1))))))) << (0 ? + 5:5))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? + 5:5) - (0 ? + 5:5) + 1) == 32) ? + ~0U : (~(~0U << ((1 ? 5:5) - (0 ? 5:5) + 1))))))) << (0 ? 5:5))); + + *Bytes = idx * 4; + + /* Return the status. */ + return status; +} +#endif /*gcdRESET_USC_C*/ + +#endif /*gcdRESET_USC1*/ + + diff --git a/drivers/amlogic/npu/kernel/arch/makefile.linux b/drivers/amlogic/npu/kernel/arch/makefile.linux index de550f3..15b252f 100644 --- a/drivers/amlogic/npu/kernel/arch/makefile.linux +++ b/drivers/amlogic/npu/kernel/arch/makefile.linux @@ -85,6 +85,7 @@ CFLAGS += $(INCLUDE) -Werror -ansi OBJECTS = $(OBJ_DIR)/gc_hal_kernel_context.o \ $(OBJ_DIR)/gc_hal_kernel_hardware.o \ $(OBJ_DIR)/gc_hal_kernel_hardware_func.o \ + $(OBJ_DIR)/gc_hal_kernel_hardware_func_flop_reset.o \ $(OBJ_DIR)/gc_hal_kernel_hardware_async_fe.o \ $(OBJ_DIR)/gc_hal_kernel_hardware_mc_fe.o \ $(OBJ_DIR)/gc_hal_kernel_hardware_waitlink_fe.o diff --git a/drivers/amlogic/npu/kernel/cebuild/makefile b/drivers/amlogic/npu/kernel/cebuild/makefile old mode 100644 new mode 100755 diff --git a/drivers/amlogic/npu/kernel/cebuild/sources b/drivers/amlogic/npu/kernel/cebuild/sources old mode 100644 new mode 100755 index d6ce135..c98e650 --- a/drivers/amlogic/npu/kernel/cebuild/sources +++ b/drivers/amlogic/npu/kernel/cebuild/sources @@ -73,6 +73,6 @@ SOURCES = \ INCLUDES = \ $(INCLUDES); \ - $(AQROOT)\hal\kernel\inc; \ + $(AQROOT)\hal\user; \ $(AQROOT)\hal\os\ce\kernel; \ $(AQROOT)\hal\kernel\arch; \ diff --git a/drivers/amlogic/npu/kernel/gc_hal_kernel.c b/drivers/amlogic/npu/kernel/gc_hal_kernel.c index 93634cf..94fab59 100644 --- a/drivers/amlogic/npu/kernel/gc_hal_kernel.c +++ b/drivers/amlogic/npu/kernel/gc_hal_kernel.c @@ -593,6 +593,7 @@ gckKERNEL_Construct( kernel->contiguousBaseAddress = kernel->mmu->contiguousBaseAddress; kernel->externalBaseAddress = kernel->mmu->externalBaseAddress; + kernel->exclusiveBaseAddress = kernel->mmu->exclusiveBaseAddress; /* Construct the gckCOMMAND object, either MCFE or wait-link FE can exist. */ if (gckHARDWARE_IsFeatureAvailable(kernel->hardware, gcvFEATURE_MCFE)) @@ -691,6 +692,20 @@ gckKERNEL_Construct( } #endif +#if gcdENABLE_SW_PREEMPTION + gcmkONERROR(gckOS_CreateSemaphore(Os, &kernel->preemptSema)); + + /* Init the priority queue. */ + for (i = 0; i < gcdMAX_PRIORITY_QUEUE_NUM; i++) + { + kernel->priorityQueues[i] = gcvNULL; + kernel->priorityDBCreated[i] = gcvFALSE; + gcmkONERROR(gckOS_CreateMutex(Os, &kernel->priorityQueueMutex[i])); + } + + kernel->preemptionMode = gcvFULLY_PREEMPTIBLE_MODE; +#endif + /* Return pointer to the gckKERNEL object. */ *Kernel = kernel; @@ -744,6 +759,24 @@ gckKERNEL_Destroy( gcmkVERIFY_OK(gckOS_DeleteMutex(Kernel->os, Kernel->debugMutex)); #endif +#if gcdENABLE_SW_PREEMPTION + gcmkVERIFY_OK(gckOS_DestroySemaphore(Kernel->os, Kernel->preemptSema)); + + for (i = 0; i < gcdMAX_PRIORITY_QUEUE_NUM; i++) + { + gcsPRIORITY_QUEUE_PTR queue = gcvNULL; + + gcmkVERIFY_OK(gckOS_DeleteMutex(Kernel->os, Kernel->priorityQueueMutex[i])); + queue = Kernel->priorityQueues[i]; + + if (queue && !queue->head) + { + gcmkVERIFY_OK(gckKERNEL_PriorityQueueDestroy(Kernel, queue)); + Kernel->priorityQueues[i] = gcvNULL; + } + } +#endif + if (Kernel->monitorTimer) { /* Stop and destroy monitor timer. */ @@ -1044,7 +1077,11 @@ AllocateMemory: break; case gcvPOOL_UNIFIED: +#if USE_LINUX_PCIE + pool = gcvPOOL_LOCAL; +#else pool = gcvPOOL_SYSTEM; +#endif loopCount = (gctINT) gcvPOOL_NUMBER_OF_POOLS; break; @@ -1156,7 +1193,6 @@ AllocateMemory: if ((Flag & videoMemory->capability) != Flag) { status = gcvSTATUS_NOT_SUPPORTED; - } #if defined(gcdLINEAR_SIZE_LIMIT) /* 512 KB */ @@ -1196,14 +1232,39 @@ AllocateMemory: } } - if (pool == gcvPOOL_LOCAL_INTERNAL) + if (pool == gcvPOOL_LOCAL) { - /* Advance to external memory. */ - pool = gcvPOOL_LOCAL_EXTERNAL; + pool = gcvPOOL_LOCAL_INTERNAL; } - - else - if (pool == gcvPOOL_LOCAL_EXTERNAL) + else if (pool == gcvPOOL_LOCAL_INTERNAL) + { + /* Get pointer to gckVIDMEM object for pool. */ + status = gckKERNEL_GetVideoMemoryPool(Kernel, gcvPOOL_LOCAL_EXCLUSIVE, &videoMemory); + if (gcmIS_ERROR(status)) + { + /* Advance to external memory. */ + pool = gcvPOOL_LOCAL_EXTERNAL; + } + else + { + status = gckKERNEL_GetVideoMemoryPool(Kernel, gcvPOOL_LOCAL_EXTERNAL, &videoMemory); + if (gcmIS_SUCCESS(status) && + (videoMemory->freeBytes < videoMemory->bytes / 3) && + Type != gcvVIDMEM_TYPE_BITMAP) + { + pool = gcvPOOL_LOCAL_EXCLUSIVE; + } + else + { + pool = gcvPOOL_LOCAL_EXTERNAL; + } + } + } + else if (pool == gcvPOOL_LOCAL_EXTERNAL) + { + pool = gcvPOOL_LOCAL_EXCLUSIVE; + } + else if (pool == gcvPOOL_LOCAL_EXCLUSIVE) { if (Kernel->sRAMLoopMode) { @@ -1216,9 +1277,7 @@ AllocateMemory: pool = gcvPOOL_SYSTEM; } } - - else - if (pool == gcvPOOL_INTERNAL_SRAM) + else if (pool == gcvPOOL_INTERNAL_SRAM) { if (Kernel->sRAMIndex < gcvSRAM_INTER_COUNT - 1 && !Kernel->sRAMPhysFaked[Kernel->sRAMIndex]) { @@ -1231,9 +1290,7 @@ AllocateMemory: pool = gcvPOOL_SYSTEM; } } - - else - if (pool == gcvPOOL_SYSTEM) + else if (pool == gcvPOOL_SYSTEM) { /* Do not go ahead to try relative slow pools */ if (fastPools && hasFastPools) @@ -1245,7 +1302,6 @@ AllocateMemory: /* Advance to virtual memory. */ pool = gcvPOOL_VIRTUAL; } - else { /* Out of pools. */ @@ -2077,7 +2133,6 @@ OnError: return status; } - gceSTATUS gckKERNEL_QueryDatabase( IN gckKERNEL Kernel, @@ -2193,6 +2248,7 @@ gckKERNEL_CacheOperation( gckVIDMEM_BLOCK vidMemBlock = gcvNULL; gctSIZE_T offset = 0; void *memHandle; + gceSYNC_VIDEO_MEMORY_REASON reason = gcvSYNC_REASON_NONE; gcmkHEADER_ARG("Kernel=%p pid=%u Node=%u op=%d Logical=%p Bytes=0x%lx", Kernel, ProcessID, Node, Operation, Logical, Bytes); @@ -2201,8 +2257,14 @@ gckKERNEL_CacheOperation( ProcessID, Node, &nodeObject)); - - node = nodeObject->node; + if (nodeObject->pool == gcvPOOL_LOCAL_EXCLUSIVE) + { + node = nodeObject->transitNode; + } + else + { + node = nodeObject->node; + } vidMemBlock = node->VirtualChunk.parent; @@ -2239,6 +2301,7 @@ gckKERNEL_CacheOperation( offset, Logical, Bytes); + reason = gcvSYNC_REASON_AFTER_WRITE; break; case gcvCACHE_CLEAN: /* Clean the cache. */ @@ -2248,6 +2311,7 @@ gckKERNEL_CacheOperation( offset, Logical, Bytes); + reason = gcvSYNC_REASON_AFTER_WRITE; break; case gcvCACHE_INVALIDATE: /* Invalidate the cache. */ @@ -2257,10 +2321,12 @@ gckKERNEL_CacheOperation( offset, Logical, Bytes); + reason = gcvSYNC_REASON_BEFORE_READ; break; case gcvCACHE_MEMORY_BARRIER: status = gckOS_MemoryBarrier(Kernel->os, Logical); + reason = gcvSYNC_REASON_AFTER_WRITE; break; default: @@ -2268,6 +2334,10 @@ gckKERNEL_CacheOperation( break; } + if (nodeObject->pool == gcvPOOL_LOCAL_EXCLUSIVE && reason != gcvSYNC_REASON_NONE) + { + status = gckKERNEL_SyncVideoMemory(Kernel, nodeObject, reason); + } OnError: gcmkFOOTER(); return status; @@ -2447,6 +2517,17 @@ _Commit( } { +#if gcdENABLE_SW_PREEMPTION + /* Commit command with preemption. */ + gcmkONERROR( + gckKERNEL_CommandCommitPreemption(kernel, + Engine, + ProcessId, + command, + eventObj, + subCommit, + Commit)); +#else /* Commit command buffers. */ status = gckCOMMAND_Commit(command, subCommit, @@ -2471,6 +2552,7 @@ _Commit( { gcmkONERROR(status); } +#endif } next = subCommit->next; @@ -2764,7 +2846,6 @@ gckKERNEL_Dispatch( #if !USE_NEW_LINUX_SIGNAL gctSIGNAL signal; #endif - gctBOOL powerMutexAcquired = gcvFALSE; gctBOOL commitMutexAcquired = gcvFALSE; gctBOOL idle = gcvFALSE; @@ -2871,7 +2952,7 @@ gckKERNEL_Dispatch( gckOS_AllocateNonPagedMemory( Kernel->os, gcvTRUE, - gcvALLOC_FLAG_CONTIGUOUS, + Interface->u.AllocateNonPagedMemory.flags | gcvALLOC_FLAG_CONTIGUOUS, &bytes, &physical, &logical)); @@ -2945,6 +3026,17 @@ gckKERNEL_Dispatch( commitMutexAcquired = gcvTRUE; } + +#if gcdENABLE_SW_PREEMPTION + /* Commit event with preemption. */ + gcmkONERROR( + gckKERNEL_EventCommitPreemption(Kernel, + Interface->engine, + processID, + gcmUINT64_TO_PTR(Interface->u.Event.queue), + Interface->u.Event.priorityID, + Interface->u.Event.topPriority)); +#else /* Commit an event queue. */ if (Interface->engine == gcvENGINE_BLT) { @@ -2961,12 +3053,14 @@ gckKERNEL_Dispatch( gcmkONERROR(gckEVENT_Commit( Kernel->eventObj, gcmUINT64_TO_PTR(Interface->u.Event.queue), gcvFALSE)); } +#endif if (!Interface->commitMutex) { gcmkONERROR(gckOS_ReleaseMutex(Kernel->os, Kernel->device->commitMutex)); commitMutexAcquired = gcvFALSE; } + break; case gcvHAL_COMMIT: @@ -2992,6 +3086,35 @@ gckKERNEL_Dispatch( } break; + case gcvHAL_COMMIT_DONE: +#if gcdENABLE_SW_PREEMPTION + /* Commit done and trigger the lower priority queue. */ + { + gctUINT32 id; + + gcmkVERIFY_OK(gckOS_AtomGet(Kernel->os, Device->atomPriorityID, &id)); + if (id > 0 && Interface->u.CommitDone.priorityID == id) + { + gcmkONERROR(gckOS_AtomDecrement(Kernel->os, Device->atomPriorityID, &id)); + + while (--id) + { + gcmkONERROR(gckOS_AcquireMutex(Kernel->os, Kernel->priorityQueueMutex[id], gcvINFINITE)); + if (!Kernel->priorityQueues[id] || !Kernel->priorityQueues[id]->head) + { + gcmkONERROR(gckOS_AtomDecrement(Kernel->os, Device->atomPriorityID, &id)); + } + + gcmkONERROR(gckOS_ReleaseMutex(Kernel->os, Kernel->priorityQueueMutex[id])); + } + } + + gcmkONERROR(gckOS_ReleaseSemaphoreEx(Kernel->os, Kernel->preemptSema)); + } +#endif + + break; + #if !USE_NEW_LINUX_SIGNAL case gcvHAL_USER_SIGNAL: /* Dispatch depends on the user signal subcommands. */ @@ -3162,64 +3285,6 @@ gckKERNEL_Dispatch( #endif break; - case gcvHAL_READ_ALL_PROFILE_REGISTERS_PART1: - /* Read profile data according to the context. */ - gcmkONERROR( - gckHARDWARE_QueryContextProfile( - Kernel->hardware, - Kernel->profileCleanRegister, - gcmNAME_TO_PTR(Interface->u.RegisterProfileData_part1.context), - &Interface->u.RegisterProfileData_part1.Counters, - gcvNULL)); - break; - case gcvHAL_READ_ALL_PROFILE_REGISTERS_PART2: - /* Read profile data according to the context. */ - gcmkONERROR( - gckHARDWARE_QueryContextProfile( - Kernel->hardware, - Kernel->profileCleanRegister, - gcmNAME_TO_PTR(Interface->u.RegisterProfileData_part2.context), - gcvNULL, - &Interface->u.RegisterProfileData_part2.Counters)); - break; - - case gcvHAL_GET_PROFILE_SETTING: -#if VIVANTE_PROFILER - /* Get profile setting */ - Interface->u.GetProfileSetting.enable = Kernel->profileEnable; -#endif - - status = gcvSTATUS_OK; - break; - - case gcvHAL_SET_PROFILE_SETTING: -#if VIVANTE_PROFILER - /* Set profile setting */ - if(Kernel->hardware->options.gpuProfiler) - { - Kernel->profileEnable = Interface->u.SetProfileSetting.enable; - - if (Kernel->profileEnable) - { - gcmkONERROR(gckHARDWARE_InitProfiler(Kernel->hardware)); - } - - } - else - { - status = gcvSTATUS_NOT_SUPPORTED; - break; - } -#endif - - status = gcvSTATUS_OK; - break; - - case gcvHAL_READ_PROFILER_REGISTER_SETTING: - Kernel->profileCleanRegister = Interface->u.SetProfilerRegisterClear.bclear; - status = gcvSTATUS_OK; - break; - case gcvHAL_RESET: /* Reset the hardware. */ gcmkONERROR( @@ -3371,7 +3436,7 @@ gckKERNEL_Dispatch( gctUINT i = 0; context = gcmNAME_TO_PTR(Interface->u.Attach.context); - for (i = 0; i < gcdCONTEXT_BUFFER_NUM; ++i) + for (i = 0; i < gcdCONTEXT_BUFFER_COUNT; ++i) { gcsCONTEXT_PTR buffer = context->buffer; @@ -3401,17 +3466,20 @@ gckKERNEL_Dispatch( #if gcdCAPTURE_ONLY_MODE gctUINT i = 0; - for (i = 0; i < gcdCONTEXT_BUFFER_NUM; ++i) + for (i = 0; i < gcdCONTEXT_BUFFER_COUNT; ++i) { Interface->u.Attach.logicals[i] = gcmPTR_TO_UINT64(Interface->u.Attach.contextLogical[i]); } Interface->u.Attach.bytes = (gctUINT)context->totalSize; #else - gcmkVERIFY_OK( - gckCONTEXT_MapBuffer(context, - Interface->u.Attach.logicals, - &Interface->u.Attach.bytes)); + if (Kernel->command->feType == gcvHW_FE_WAIT_LINK) + { + gcmkVERIFY_OK( + gckCONTEXT_MapBuffer(context, + Interface->u.Attach.logicals, + &Interface->u.Attach.bytes)); + } #endif } else @@ -3732,6 +3800,30 @@ gckKERNEL_Dispatch( &Interface->u.QueryChipOptions)); break; + case gcvHAL_SYNC_VIDEO_MEMORY: + { + gckVIDMEM_NODE nodeObject; + + gcmkONERROR(gckVIDMEM_HANDLE_Lookup( + Kernel, + processID, + (gctUINT32)Interface->u.SyncVideoMemory.node, + &nodeObject + )); + + if (nodeObject->pool == gcvPOOL_LOCAL_EXCLUSIVE + && nodeObject->transitNode != gcvNULL + && nodeObject->transitNode->Virtual.logical != gcvNULL) + { + gcmkONERROR(gckKERNEL_SyncVideoMemory( + Kernel, + nodeObject, + Interface->u.SyncVideoMemory.reason + )); + } + } + break; + default: /* Invalid command. */ gcmkONERROR(gcvSTATUS_INVALID_ARGUMENT); @@ -4594,7 +4686,6 @@ OnError: return status; } - gctUINT32 gckKERNEL_AllocateNameFromPointer( IN gckKERNEL Kernel, @@ -5337,6 +5428,12 @@ gckDEVICE_Construct( gcmkONERROR(gckOS_CreateMutex(Os, &device->stuckDumpMutex)); gcmkONERROR(gckOS_CreateMutex(Os, &device->commitMutex)); +#if gcdENABLE_SW_PREEMPTION + gcmkONERROR(gckOS_AtomConstruct(Os, &device->atomPriorityID)); + + gcmkVERIFY_OK(gckOS_AtomSet(Os, device->atomPriorityID, 0)); +#endif + device->os = Os; device->showSRAMMapInfo = 0; @@ -5532,6 +5629,13 @@ gckDEVICE_Destroy( gcmkVERIFY_OK(gckOS_DeleteMutex(Os, Device->stuckDumpMutex)); } +#if gcdENABLE_SW_PREEMPTION + if (Device->atomPriorityID) + { + gcmkVERIFY_OK(gckOS_AtomDestroy(Os, Device->atomPriorityID)); + } +#endif + gcmkOS_SAFE_FREE(Os, Device); return gcvSTATUS_OK; @@ -5576,7 +5680,6 @@ gckDEVICE_SetTimeOut( return gcvSTATUS_OK; } - gceSTATUS gckDEVICE_Dispatch( IN gckDEVICE Device, @@ -5634,6 +5737,94 @@ gckDEVICE_Dispatch( return status; } +#if VIVANTE_PROFILER +gceSTATUS +gckDEVICE_Profiler_Dispatch( + IN gckDEVICE Device, + IN gcsHAL_PROFILER_INTERFACE_PTR Interface + ) +{ + gceSTATUS status = gcvSTATUS_NOT_SUPPORTED; + gckKERNEL kernel; + gctUINT32 coreIndex = Interface->coreIndex; + + kernel = Device->coreInfoArray[coreIndex].kernel; + + /* Dispatch on profiler command. */ + switch (Interface->command) + { + case gcvHAL_READ_ALL_PROFILE_REGISTERS_PART1: + /* Read profile data according to the context. */ + gcmkONERROR( + gckHARDWARE_QueryContextProfile( + kernel->hardware, + kernel->profileCleanRegister, + gcmNAME_TO_PTR(Interface->u.RegisterProfileData_part1.context), + &Interface->u.RegisterProfileData_part1.Counters, + gcvNULL)); + + status = gcvSTATUS_OK; + break; + + case gcvHAL_READ_ALL_PROFILE_REGISTERS_PART2: + /* Read profile data according to the context. */ + gcmkONERROR( + gckHARDWARE_QueryContextProfile( + kernel->hardware, + kernel->profileCleanRegister, + gcmNAME_TO_PTR(Interface->u.RegisterProfileData_part2.context), + gcvNULL, + &Interface->u.RegisterProfileData_part2.Counters)); + + status = gcvSTATUS_OK; + break; + + case gcvHAL_GET_PROFILE_SETTING: + /* Get profile setting */ + Interface->u.GetProfileSetting.enable = kernel->profileEnable; + + status = gcvSTATUS_OK; + break; + + case gcvHAL_SET_PROFILE_SETTING: + /* Set profile setting */ + if(kernel->hardware->options.gpuProfiler) + { + kernel->profileEnable = Interface->u.SetProfileSetting.enable; + + if (kernel->profileEnable) + { + gcmkONERROR(gckHARDWARE_InitProfiler(kernel->hardware)); + } + } + else + { + status = gcvSTATUS_NOT_SUPPORTED; + break; + } + + status = gcvSTATUS_OK; + break; + + case gcvHAL_READ_PROFILER_REGISTER_SETTING: + kernel->profileCleanRegister = Interface->u.SetProfilerRegisterClear.bclear; + status = gcvSTATUS_OK; + break; + + default: + /* Invalid command. */ + gcmkONERROR(gcvSTATUS_INVALID_ARGUMENT); + } + +OnError: + /* Save status. */ + Interface->status = status; + + /* Return the status. */ + return status; +} +#endif + gceSTATUS gckDEVICE_GetMMU( IN gckDEVICE Device, diff --git a/drivers/amlogic/npu/kernel/gc_hal_kernel.h b/drivers/amlogic/npu/kernel/gc_hal_kernel.h index 7f25279..d81f49b 100644 --- a/drivers/amlogic/npu/kernel/gc_hal_kernel.h +++ b/drivers/amlogic/npu/kernel/gc_hal_kernel.h @@ -59,10 +59,14 @@ #include "gc_hal.h" #include "gc_hal_kernel_hardware.h" #include "gc_hal_kernel_hardware_fe.h" -#include "shared/gc_hal_driver.h" +#include "gc_hal_driver.h" #include "gc_hal_kernel_mutex.h" #include "gc_hal_metadata.h" +#if gcdENABLE_SW_PREEMPTION +#include "gc_hal_kernel_preemption.h" +#endif + #if gcdSECURITY || gcdENABLE_TRUST_APPLICATION #include "gc_hal_security_interface.h" @@ -238,6 +242,9 @@ typedef enum _gceDATABASE_TYPE gcvDB_MAP_MEMORY, /* Map memory */ gcvDB_MAP_USER_MEMORY, /* Map user memory */ gcvDB_SHBUF, /* Shared buffer. */ +#if gcdENABLE_SW_PREEMPTION + gcvDB_PRIORITY, +#endif gcvDB_NUM_TYPES, } @@ -318,6 +325,12 @@ gcsFDPRIVATE; typedef struct _gcsRECORDER * gckRECORDER; +typedef enum _gceMMU_INIT_MODE +{ + gcvMMU_INIT_FROM_REG, + gcvMMU_INIT_FROM_CMD, +} +gceMMU_INIT_MODE; /* Create a process database that will contain all its allocations. */ gceSTATUS @@ -519,10 +532,6 @@ struct _gckDB gctPOINTER videoMemListMutex; }; -typedef struct _gckCOMMAND * gckCOMMAND; - -typedef struct _gckEVENT * gckEVENT; - /* gckKERNEL object. */ struct _gckKERNEL { @@ -616,6 +625,7 @@ struct _gckKERNEL gctUINT32 contiguousBaseAddress; gctUINT32 externalBaseAddress; gctUINT32 internalBaseAddress; + gctUINT32 exclusiveBaseAddress; /* External shared SRAM. */ gctUINT32 extSRAMBaseAddresses[gcvSRAM_EXT_COUNT]; @@ -632,6 +642,14 @@ struct _gckKERNEL gctUINT32 timeoutPID; gctBOOL threadInitialized; + +#if gcdENABLE_SW_PREEMPTION + gctPOINTER priorityQueueMutex[gcdMAX_PRIORITY_QUEUE_NUM]; + gcsPRIORITY_QUEUE_PTR priorityQueues[gcdMAX_PRIORITY_QUEUE_NUM]; + gctBOOL priorityDBCreated[gcdMAX_PRIORITY_QUEUE_NUM]; + gctSEMAPHORE preemptSema; + gcePREEMPTION_MODE preemptionMode; +#endif }; struct _FrequencyHistory @@ -992,6 +1010,17 @@ gckEVENT_GetEvent( /* Add a new event to the list of events. */ gceSTATUS +gckEVENT_AddListEx( + IN gckEVENT Event, + IN gcsHAL_INTERFACE_PTR Interface, + IN gceKERNEL_WHERE FromWhere, + IN gctBOOL AllocateAllowed, + IN gctBOOL FromKernel, + IN gctUINT32 ProcessID + ); + +/* Add a new event to the list of events. */ +gceSTATUS gckEVENT_AddList( IN gckEVENT Event, IN gcsHAL_INTERFACE_PTR Interface, @@ -1284,6 +1313,9 @@ typedef struct _gcsVIDMEM_NODE /* Pointer to gcuVIDMEM_NODE. */ gcuVIDMEM_NODE_PTR node; + /* Pointer to gcuVIDMEM_NODE. */ + gcuVIDMEM_NODE_PTR transitNode; + /* Pointer to gckKERNEL object. */ gckKERNEL kernel; @@ -1416,6 +1448,10 @@ typedef struct _gcsDEVICE /* Mutex for multi-core combine mode command submission */ gctPOINTER commitMutex; + +#if gcdENABLE_SW_PREEMPTION + gctPOINTER atomPriorityID; +#endif } gcsDEVICE; @@ -1770,6 +1806,10 @@ struct _gckMMU gctUINT32 contiguousBaseAddress; gctUINT32 externalBaseAddress; gctUINT32 internalBaseAddress; + gctUINT32 exclusiveBaseAddress; + + gceMMU_INIT_MODE initMode; + gctBOOL pageTableOver4G; }; @@ -1849,6 +1889,17 @@ gckKERNEL_AllocateVideoMemory( ); gceSTATUS +gckHARDWARE_QchannelPowerOn( + IN gckHARDWARE Hardware + ); + +gceSTATUS +gckHARDWARE_QchannelBypass( + IN gckHARDWARE Hardware, + IN gctBOOL Enable + ); + +gceSTATUS gckHARDWARE_QueryIdle( IN gckHARDWARE Hardware, OUT gctBOOL_PTR IsIdle @@ -2353,6 +2404,14 @@ gckDEVICE_Dispatch( IN gcsHAL_INTERFACE_PTR Interface ); +#if VIVANTE_PROFILER +gceSTATUS +gckDEVICE_Profiler_Dispatch( + IN gckDEVICE Device, + IN gcsHAL_PROFILER_INTERFACE_PTR Interface + ); +#endif + gceSTATUS gckDEVICE_GetMMU( IN gckDEVICE Device, diff --git a/drivers/amlogic/npu/kernel/gc_hal_kernel_command.c b/drivers/amlogic/npu/kernel/gc_hal_kernel_command.c index 684e397..36f6e4a 100644 --- a/drivers/amlogic/npu/kernel/gc_hal_kernel_command.c +++ b/drivers/amlogic/npu/kernel/gc_hal_kernel_command.c @@ -2185,7 +2185,9 @@ _CommitWaitLinkOnce( IN gcsSTATE_DELTA_PTR StateDelta, IN gctUINT32 ProcessID, IN gctBOOL Shared, - INOUT gctBOOL *contextSwitched + INOUT gctBOOL *contextSwitched, + IN gctPOINTER PreemptCommit, + IN gctBOOL InPreemptThread ) { gceSTATUS status; @@ -2391,7 +2393,21 @@ _CommitWaitLinkOnce( contextBuffer = Context->buffer; /* Yes, merge in the deltas. */ +#if gcdENABLE_SW_PREEMPTION + if (InPreemptThread || Command->kernel->preemptionMode == gcvNON_FULLY_PREEMPTIBLE_MODE) + { + gckPREEMPT_COMMIT preemptCommit = (gckPREEMPT_COMMIT)PreemptCommit; + gcmkONERROR(gckCONTEXT_PreemptUpdate(Context, preemptCommit)); + } + else + { + gcmkONERROR(gckCONTEXT_Update(Context, ProcessID, StateDelta)); + + gcmkONERROR(gckCONTEXT_ConstructPrevDelta(Context, ProcessID, StateDelta)); + } +#else gcmkONERROR(gckCONTEXT_Update(Context, ProcessID, StateDelta)); +#endif /*************************************************************** ** SWITCHING CONTEXT. @@ -2451,7 +2467,7 @@ _CommitWaitLinkOnce( )); #if gcdCAPTURE_ONLY_MODE - for (i = 0; i < gcdCONTEXT_BUFFER_NUM; ++i) + for (i = 0; i < gcdCONTEXT_BUFFER_COUNT; ++i) { gcsCONTEXT_PTR buffer = contextBuffer; @@ -2631,11 +2647,13 @@ _CommitWaitLinkOnce( { gctUINT8_PTR link = commandBufferTail + CommandBuffer->exitIndex * 16; gctSIZE_T bytes = 8; + gceCORE_3D_MASK mask = gckHARDWARE_IsFeatureAvailable(hardware, gcvFEATURE_MULTI_CLUSTER) ? + gcvCORE_3D_ALL_MASK : ((gceCORE_3D_MASK)(1 << hardware->kernel->chipID)); gcmkONERROR(gckWLFE_ChipEnable( hardware, link, - (gceCORE_3D_MASK)(1 << hardware->kernel->chipID), + mask, &bytes )); @@ -2723,7 +2741,6 @@ _CommitWaitLinkOnce( #endif #if gcdLINK_QUEUE_SIZE - /* TODO: What's it? */ if (Command->kernel->stuckDump >= gcvSTUCK_DUMP_USER_COMMAND) { gcuQUEUEDATA data; @@ -3211,7 +3228,37 @@ OnError: return status; } +gceSTATUS +_ValidCommandBuffer( + IN gckCOMMAND Command, + IN gctUINT32 ProcessId, + IN gcsHAL_COMMAND_LOCATION *cmdLoc + ) +{ + gceSTATUS status; + gcsDATABASE_RECORD Record; + + gcmkHEADER_ARG("Command=%p CommandLocation=%p Pid=%u", + Command, cmdLoc, ProcessId); + + gcmkONERROR(gckKERNEL_FindProcessDB( + Command->kernel, + ProcessId, + 0, + gcvDB_VIDEO_MEMORY_LOCKED, + gcmINT2PTR(cmdLoc->videoMemNode), + &Record + )); + + if (gcmPTR_TO_UINT64(Record.physical) != cmdLoc->logical) + { + gcmkONERROR(gcvSTATUS_INVALID_ADDRESS); + } +OnError: + gcmkFOOTER(); + return status; +} /******************************************************************************* ** ** gckCOMMAND_Commit @@ -3302,6 +3349,8 @@ gckCOMMAND_Commit( } } + gcmkONERROR(_ValidCommandBuffer(Command, ProcessId, cmdLoc)); + if (Command->feType == gcvHW_FE_WAIT_LINK) { /* Commit command buffers. */ @@ -3311,7 +3360,9 @@ gckCOMMAND_Commit( delta, ProcessId, Shared, - contextSwitched); + contextSwitched, + gcvNULL, + gcvFALSE); } else if (Command->feType == gcvHW_FE_MULTI_CHANNEL) { @@ -4507,3 +4558,75 @@ OnError: return status; } +#if gcdENABLE_SW_PREEMPTION +/******************************************************************************* +** +** gckCOMMAND_PreemptCommit +** +** Commit command in preemption mode. +** +** INPUT: +** +** gckCOMMAND Command +** Pointer to a gckCOMMAND object. +** +** gckPREEMPT_COMMIT PreemptCommit +** The preempt commit. +** +** OUTPUT: +** +** Nothing. +*/ +gceSTATUS +gckCOMMAND_PreemptCommit( + IN gckCOMMAND Command, + IN gckPREEMPT_COMMIT PreemptCommit + ) +{ + gceSTATUS status = gcvSTATUS_OK; + gctBOOL contextSwitched = gcvFALSE; + gcsHAL_COMMAND_LOCATION *cmdLoc = PreemptCommit->cmdLoc; + gckCONTEXT context = PreemptCommit->context; + gcsSTATE_DELTA_PTR delta = PreemptCommit->delta; + + gcmkHEADER(); + + do + { + if (Command->feType == gcvHW_FE_WAIT_LINK) + { + status = _CommitWaitLinkOnce(Command, + context, + cmdLoc, + delta, + PreemptCommit->pid, + PreemptCommit->shared, + &contextSwitched, + PreemptCommit, + gcvTRUE); + + if (status != gcvSTATUS_INTERRUPTED) + { + gcmkONERROR(status); + } + } + else + { + gcmkPRINT("Don't enable SW preemption for non-WLFE.\n"); + + gcmkONERROR(gcvSTATUS_NOT_SUPPORTED); + } + + context = gcvNULL; + delta = gcvNULL; + + cmdLoc = (gcsHAL_COMMAND_LOCATION *)gcmUINT64_TO_PTR(cmdLoc->next); + } + while(cmdLoc); + +OnError: + /* Return the status. */ + gcmkFOOTER(); + return status; +} +#endif diff --git a/drivers/amlogic/npu/kernel/gc_hal_kernel_db.c b/drivers/amlogic/npu/kernel/gc_hal_kernel_db.c index a0a68bd..594b127 100644 --- a/drivers/amlogic/npu/kernel/gc_hal_kernel_db.c +++ b/drivers/amlogic/npu/kernel/gc_hal_kernel_db.c @@ -807,8 +807,16 @@ gckKERNEL_AddProcessDB( return gcvSTATUS_OK; } +#if gcdENABLE_SW_PREEMPTION + if (Type == gcvDB_PRIORITY) + { + gctUINT32 id = gcmPTR2INT32(Pointer); + Kernel->priorityDBCreated[id] = gcvTRUE; + } +#else /* Verify the arguments. */ gcmkVERIFY_ARGUMENT(Pointer != gcvNULL); +#endif /* Find the database. */ gcmkONERROR(gckKERNEL_FindDatabase(Kernel, ProcessID, gcvFALSE, &database)); @@ -1326,6 +1334,56 @@ gckKERNEL_DestroyProcessDB( (gctUINT32)(gctUINTPTR_T) record->data, status); break; +#if gcdENABLE_SW_PREEMPTION + case gcvDB_PRIORITY: + /* Commit done and trigger the lower priority queue. */ + { + gctUINT32 priorityID = gcmPTR2INT32(record->data); + gceHARDWARE_TYPE type = Kernel->hardware->type; + gctUINT32 id = 0; + + if (priorityID >= gcdMAX_PRIORITY_QUEUE_NUM) + { + gcmkPRINT("Galcore Info: get an error priority."); + break; + } + + Kernel->priorityDBCreated[priorityID] = gcvFALSE; + + gcmkVERIFY_OK(gckOS_AtomGet(Kernel->os, Kernel->device->atomPriorityID, &id)); + + if (id > 0 && priorityID == id) + { + gcmkVERIFY_OK(gckOS_AtomDecrement(Kernel->os, Kernel->device->atomPriorityID, &id)); + while (--id) + { + gcmkVERIFY_OK(gckOS_AcquireMutex(Kernel->os, Kernel->priorityQueueMutex[id], gcvINFINITE)); + if (!Kernel->priorityQueues[id] || !Kernel->priorityQueues[id]->head) + { + gcmkVERIFY_OK(gckOS_AtomDecrement(Kernel->os, kernel->device->atomPriorityID, &id)); + } + + gcmkVERIFY_OK(gckOS_ReleaseMutex(Kernel->os, Kernel->priorityQueueMutex[id])); + } + } + + if (type == gcvHARDWARE_3D || type == gcvHARDWARE_3D2D || type == gcvHARDWARE_VIP) + { + gckKERNEL kernel = gcvNULL; + gctINT i; + + for (i = 0; i < Kernel->device->coreNum; i++) + { + kernel = Kernel->device->coreInfoArray[i].kernel; + + gcmkVERIFY_OK(gckOS_ReleaseSemaphoreEx(kernel->os, kernel->preemptSema)); + } + } + } + + break; +#endif + default: gcmkTRACE_ZONE(gcvLEVEL_ERROR, gcvZONE_DATABASE, "DB: Correcupted record=0x%08x type=%d", diff --git a/drivers/amlogic/npu/kernel/gc_hal_kernel_event.c b/drivers/amlogic/npu/kernel/gc_hal_kernel_event.c index 9f12fea..9763bfd 100644 --- a/drivers/amlogic/npu/kernel/gc_hal_kernel_event.c +++ b/drivers/amlogic/npu/kernel/gc_hal_kernel_event.c @@ -54,7 +54,6 @@ #include "gc_hal_kernel_precomp.h" -#include "gc_hal_kernel_buffer.h" #ifdef __QNXNTO__ #include "gc_hal_kernel_qnx.h" @@ -940,12 +939,13 @@ OnError: ** Nothing. */ gceSTATUS -gckEVENT_AddList( +gckEVENT_AddListEx( IN gckEVENT Event, IN gcsHAL_INTERFACE_PTR Interface, IN gceKERNEL_WHERE FromWhere, IN gctBOOL AllocateAllowed, - IN gctBOOL FromKernel + IN gctBOOL FromKernel, + IN gctUINT32 ProcessID ) { gceSTATUS status; @@ -994,7 +994,14 @@ gckEVENT_AddList( gckOS_MemCopy(&record->info, Interface, gcmSIZEOF(record->info)); /* Get process ID. */ - gcmkONERROR(gckOS_GetProcessID(&record->processID)); + if (ProcessID) + { + record->processID = ProcessID; + } + else + { + gcmkONERROR(gckOS_GetProcessID(&record->processID)); + } if (FromKernel == gcvFALSE) { @@ -1083,6 +1090,18 @@ OnError: return status; } +gceSTATUS +gckEVENT_AddList( + IN gckEVENT Event, + IN gcsHAL_INTERFACE_PTR Interface, + IN gceKERNEL_WHERE FromWhere, + IN gctBOOL AllocateAllowed, + IN gctBOOL FromKernel + ) +{ + return gckEVENT_AddListEx(Event, Interface, FromWhere, AllocateAllowed, FromKernel, 0); +} + /******************************************************************************* ** ** gckEVENT_Unlock @@ -1520,6 +1539,79 @@ OnError: ** gckEVENT Event ** Pointer to an gckEVENT object. ** +** gckPREEMPT_COMMIT PreemptCommit +** The preempt commit. +** +** gctBOOL Forced +** Force fire a event. There won't be interrupt if there's no events +** queued. Force a event by append a dummy one if this parameter is on. +** +** OUTPUT: +** +** Nothing. +*/ +#if gcdENABLE_SW_PREEMPTION +gceSTATUS +gckEVENT_PreemptCommit( + IN gckEVENT Event, + IN gckPREEMPT_COMMIT PreemptCommit, + IN gctBOOL Forced + ) +{ + gceSTATUS status; + gcsQUEUE_PTR record = gcvNULL; + + gcmkHEADER_ARG("Event=0x%x PreemptCommit=0x%x", Event, PreemptCommit); + + /* Verify the arguments. */ + gcmkVERIFY_OBJECT(Event, gcvOBJ_EVENT); + gcmkVERIFY_ARGUMENT(PreemptCommit != gcvNULL); + + record = PreemptCommit->eventQueue; + + /* Loop while there are records in the queue. */ + while (record != gcvNULL) + { + /* Append event record to event queue. */ + gcmkONERROR(gckEVENT_AddListEx( + Event, + &record->iface, + gcvKERNEL_PIXEL, + gcvTRUE, + gcvFALSE, + PreemptCommit->pid + )); + + /* Next record in the queue. */ + record = gcmUINT64_TO_PTR(record->next); + } + + + /* Submit the event list. */ + gcmkONERROR(gckEVENT_Submit(Event, gcvTRUE, gcvFALSE)); + + /* Success */ + gcmkFOOTER_NO(); + return gcvSTATUS_OK; + +OnError: + /* Return the status. */ + gcmkFOOTER(); + return status; +} +#endif + +/******************************************************************************* +** +** gckEVENT_Commit +** +** Commit an event queue from the user. +** +** INPUT: +** +** gckEVENT Event +** Pointer to an gckEVENT object. +** ** gcsQUEUE_PTR Queue ** User event queue. ** @@ -1633,7 +1725,6 @@ OnError: gcmkFOOTER(); return status; } - /******************************************************************************* ** ** gckEVENT_Interrupt @@ -1975,15 +2066,15 @@ gckEVENT_Notify( nodeObject = gcmUINT64_TO_PTR(record->info.u.UnlockVideoMemory.node); /* Unlock, sync'ed. */ - status = gckVIDMEM_NODE_Unlock( - Event->kernel, - nodeObject, - record->processID, - gcvNULL - ); + gcmkERR_BREAK( + gckVIDMEM_NODE_Unlock(Event->kernel, + nodeObject, + record->processID, + gcvNULL)); /* Deref node. */ - status = gckVIDMEM_NODE_Dereference(Event->kernel, nodeObject); + gcmkERR_BREAK(gckVIDMEM_NODE_Dereference(Event->kernel, nodeObject)); + break; case gcvHAL_SIGNAL: diff --git a/drivers/amlogic/npu/kernel/gc_hal_kernel_mmu.c b/drivers/amlogic/npu/kernel/gc_hal_kernel_mmu.c index 714ff28..ae994b5 100644 --- a/drivers/amlogic/npu/kernel/gc_hal_kernel_mmu.c +++ b/drivers/amlogic/npu/kernel/gc_hal_kernel_mmu.c @@ -973,7 +973,10 @@ _FillFlatMapping( allocFlag |= gcvALLOC_FLAG_CACHEABLE; #endif - allocFlag |= gcvALLOC_FLAG_4GB_ADDR; + if (!Mmu->pageTableOver4G) + { + allocFlag |= gcvALLOC_FLAG_4GB_ADDR; + } gcmkONERROR(gckKERNEL_AllocateVideoMemory( kernel, @@ -1275,7 +1278,10 @@ _ConstructDynamicStlb( allocFlag |= gcvALLOC_FLAG_CACHEABLE; #endif - allocFlag |= gcvALLOC_FLAG_4GB_ADDR; + if (!Mmu->pageTableOver4G) + { + allocFlag |= gcvALLOC_FLAG_4GB_ADDR; + } /* Construct Slave TLB. */ gcmkONERROR(gckKERNEL_AllocateVideoMemory( @@ -1596,8 +1602,10 @@ _Construct( gctSIZE_T physSize; gctPHYS_ADDR_T contiguousBase; gctSIZE_T contiguousSize = 0; - gctPHYS_ADDR_T externalBase; + gctPHYS_ADDR_T externalBase = 0; + gctPHYS_ADDR_T exclusiveBase = 0; gctSIZE_T externalSize = 0; + gctSIZE_T exclusiveSize = 0; gctUINT32 gpuAddress; gctPHYS_ADDR_T gpuPhysical; gcsADDRESS_AREA_PTR area = gcvNULL; @@ -1636,6 +1644,8 @@ _Construct( mmu->mtlbLogical = gcvNULL; mmu->staticSTLB = gcvNULL; mmu->enabled = gcvFALSE; + mmu->initMode = gcvMMU_INIT_FROM_CMD; + mmu->pageTableOver4G = gcvFALSE; mmu->dynamicAreaSetuped = gcvFALSE; mmu->pool = _GetPageTablePool(mmu->os); @@ -1737,15 +1747,39 @@ _Construct( } else { + gctUINT64 gpuContiguousBase = ~0ULL; + mmu->mtlbSize = gcdMMU_MTLB_SIZE; + status = gckOS_QueryOption(mmu->os, "contiguousBase", &contiguousBase); + + if (gcmIS_SUCCESS(status)) + { + status = gckOS_QueryOption(mmu->os, "contiguousSize", &data); + contiguousSize = (gctSIZE_T)data; + } + + if (gcmIS_SUCCESS(status) && contiguousSize) + { + gcmkONERROR(gckOS_CPUPhysicalToGPUPhysical(mmu->os, contiguousBase, &gpuContiguousBase)); + + if (gpuContiguousBase >= gcvMAXUINT32) + { + mmu->pageTableOver4G = gcvTRUE; + mmu->pool = gcvPOOL_DEFAULT; + } + } + pool = mmu->pool; #if gcdENABLE_CACHEABLE_COMMAND_BUFFER allocFlag |= gcvALLOC_FLAG_CACHEABLE; #endif - allocFlag |= gcvALLOC_FLAG_4GB_ADDR; + if (!mmu->pageTableOver4G) + { + allocFlag |= gcvALLOC_FLAG_4GB_ADDR; + } /* 1K mode is 1024 byte aligned. */ gcmkONERROR(gckKERNEL_AllocateVideoMemory( @@ -1833,21 +1867,10 @@ _Construct( } #endif - status = gckOS_QueryOption(mmu->os, "contiguousBase", &contiguousBase); - - if (gcmIS_SUCCESS(status)) - { - status = gckOS_QueryOption(mmu->os, "contiguousSize", &data); - contiguousSize = (gctSIZE_T)data; - } - - if (gcmIS_SUCCESS(status) && contiguousSize) + if (contiguousSize && gpuContiguousBase != ~0ULL) { - gctUINT64 gpuContiguousBase; gctUINT32 contiguousBaseAddress = 0; - gcmkONERROR(gckOS_CPUPhysicalToGPUPhysical(mmu->os, contiguousBase, &gpuContiguousBase)); - /* Setup flat mapping for reserved memory (VIDMEM). */ gcmkONERROR(_FillFlatMapping(mmu, gpuContiguousBase, contiguousSize, gcvFALSE, gcvTRUE, &contiguousBaseAddress)); @@ -1881,6 +1904,24 @@ _Construct( mmu->externalBaseAddress = externalBaseAddress; } + + status = gckOS_QueryOption(mmu->os, "exclusiveBase", &exclusiveBase); + + if (gcmIS_SUCCESS(status)) + { + status = gckOS_QueryOption(mmu->os, "exclusiveSize", &data); + exclusiveSize = (gctSIZE_T)data; + } + + if (gcmIS_SUCCESS(status) && exclusiveSize) + { + gctUINT32 exclusiveBaseAddress = 0; + + /* Setup flat mapping for external memory. */ + gcmkONERROR(_FillFlatMapping(mmu, exclusiveBase, exclusiveSize, gcvFALSE, gcvTRUE, &exclusiveBaseAddress)); + + mmu->exclusiveBaseAddress = exclusiveBaseAddress; + } } /* A 64 byte for safe address, we use 256 here. */ @@ -1888,12 +1929,19 @@ _Construct( pool = mmu->pool; + allocFlag = gcvALLOC_FLAG_CONTIGUOUS | gcvALLOC_FLAG_4K_PAGES; + + if (!mmu->pageTableOver4G) + { + allocFlag |= gcvALLOC_FLAG_4GB_ADDR; + } + /* Allocate safe page from video memory. */ gcmkONERROR(gckKERNEL_AllocateVideoMemory( Kernel, 256, gcvVIDMEM_TYPE_COMMAND, - gcvALLOC_FLAG_CONTIGUOUS | gcvALLOC_FLAG_4K_PAGES | gcvALLOC_FLAG_4GB_ADDR, + allocFlag, &mmu->safePageSize, &pool, &mmu->safePageVideoMem @@ -3281,7 +3329,8 @@ gckMMU_SetupSRAM( Mmu->os, (gctPHYS_ADDR_T)kernel->sRAMBaseAddresses[i], kernel->sRAMSizes[i], - "Per core SRAM reserve usage region", + "gcPerCoreSRAM", + gcvTRUE, gcvTRUE, &kernel->sRAMPhysical[i] )); diff --git a/drivers/amlogic/npu/kernel/gc_hal_kernel_precomp.h b/drivers/amlogic/npu/kernel/gc_hal_kernel_precomp.h index 0ce3495..5282291 100644 --- a/drivers/amlogic/npu/kernel/gc_hal_kernel_precomp.h +++ b/drivers/amlogic/npu/kernel/gc_hal_kernel_precomp.h @@ -57,7 +57,7 @@ #define __gc_hal_kernel_precomp_h_ #include "gc_hal.h" -#include "shared/gc_hal_driver.h" +#include "gc_hal_driver.h" #include "gc_hal_kernel.h" #endif /* __gc_hal_kernel_precomp_h_ */ diff --git a/drivers/amlogic/npu/kernel/gc_hal_kernel_preemption.c b/drivers/amlogic/npu/kernel/gc_hal_kernel_preemption.c new file mode 100644 index 0000000..747923b --- /dev/null +++ b/drivers/amlogic/npu/kernel/gc_hal_kernel_preemption.c @@ -0,0 +1,1495 @@ +/**************************************************************************** +* +* The MIT License (MIT) +* +* Copyright (c) 2014 - 2020 Vivante Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +* +***************************************************************************** +* +* The GPL License (GPL) +* +* Copyright (C) 2014 - 2020 Vivante Corporation +* +* 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 +* of the License, or (at your option) any later version. +* +* 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, write to the Free Software Foundation, +* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +***************************************************************************** +* +* Note: This software is released under dual MIT and GPL licenses. A +* recipient may use this file under the terms of either the MIT license or +* GPL License. If you wish to use only one license not the other, you can +* indicate your decision by deleting one of the above license notices in your +* version of this file. +* +*****************************************************************************/ + + +#include "gc_hal_kernel_precomp.h" +#include "gc_hal_kernel_context.h" +#include "gc_hal_kernel_preemption.h" + +#if gcdENABLE_SW_PREEMPTION +#define _GC_OBJ_ZONE gcvZONE_KERNEL + +/******************************************************************************* +** +** gckKERNEL_DestroyPreemptCommit +** +** Destroy the preempt commit. +** +** INPUT: +** +** gckKERNEL Kernel +** Pointer to an gckKERNEL. +** +** gckPREEMPT_COMMIT PreemptCommit +** Pointer to an gckPREEMPT_COMMIT object to destroy. +** +** OUTPUT: +** +** Nothing. +*/ +gceSTATUS +gckKERNEL_DestroyPreemptCommit( + IN gckKERNEL Kernel, + IN gckPREEMPT_COMMIT PreemptCommit + ) +{ + gcsHAL_COMMAND_LOCATION *cmdLoc = gcvNULL; + gcsHAL_COMMAND_LOCATION *nextCmdLoc = gcvNULL; + gckVIDMEM_NODE nodeObject = gcvNULL; + gcsQUEUE_PTR eventQueue = gcvNULL; + gcsQUEUE_PTR nextEventQueue = gcvNULL; + gceSTATUS status = gcvSTATUS_OK; + + gcmkHEADER_ARG("Kernel=%p PreemptComimt=%p", Kernel, PreemptCommit); + + gcmkVERIFY_ARGUMENT(Kernel != gcvNULL); + gcmkVERIFY_ARGUMENT(PreemptCommit != gcvNULL); + + cmdLoc = PreemptCommit->cmdLoc; + + while (cmdLoc) + { + gcmkVERIFY_OK(gckVIDMEM_HANDLE_Lookup( + Kernel, + PreemptCommit->pid, + cmdLoc->videoMemNode, + &nodeObject + )); + + gcmkVERIFY_OK(gckVIDMEM_NODE_UnlockCPU( + Kernel, + nodeObject, + PreemptCommit->pid, + gcvFALSE, + gcvFALSE + )); + + nextCmdLoc = (gcsHAL_COMMAND_LOCATION *)gcmUINT64_TO_PTR(cmdLoc->next); + + gcmkVERIFY_OK(gcmkOS_SAFE_FREE(Kernel->os, cmdLoc)); + + cmdLoc = nextCmdLoc; + } + + PreemptCommit->cmdLoc = gcvNULL; + + eventQueue = PreemptCommit->eventQueue; + + while (eventQueue) + { + nextEventQueue = (gcsQUEUE_PTR)gcmUINT64_TO_PTR(eventQueue->next); + + gcmkVERIFY_OK(gcmkOS_SAFE_FREE(Kernel->os, eventQueue)); + + eventQueue = nextEventQueue; + } + + PreemptCommit->eventQueue = gcvNULL; + + if (PreemptCommit->recordArray) + { + gcmkVERIFY_OK(gcmkOS_SAFE_FREE(Kernel->os, PreemptCommit->recordArray)); + } + + if (PreemptCommit->mapEntryID) + { + gcmkVERIFY_OK(gcmkOS_SAFE_FREE(Kernel->os, PreemptCommit->mapEntryID)); + } + + if (PreemptCommit->mapEntryIndex) + { + gcmkVERIFY_OK(gcmkOS_SAFE_FREE(Kernel->os, PreemptCommit->mapEntryIndex)); + } + + gcmkVERIFY_OK(gcmkOS_SAFE_FREE(Kernel->os, PreemptCommit)); + + gcmkFOOTER(); + + return status; +} + +/******************************************************************************* +** +** gckKERNEL_ConstructPreemptCommit +** +** Construct the preempt commit. +** +** INPUT: +** +** gckKERNEL Kernel +** Pointer to an gckKERNEL. +** +** gcsHAL_SUBCOMMIT_PTR SubCommit +** SubCommit pointer from user driver. +** +** gceENGINE Engine +** Engine type of the user commit. +** +** gctUINT32 ProcessID +** Proccess ID of this commit. +** +** gctBOOL Shared +** If it is multi-core and shared commit. +** +** OUTPUT: +** gckPREEMPT_COMMIT * PreemptCommit +** The gckPREEMPT_COMMIT object to construct. +** +*/ +gceSTATUS +gckKERNEL_ConstructPreemptCommit( + IN gckKERNEL Kernel, + IN gcsHAL_SUBCOMMIT_PTR SubCommit, + IN gceENGINE Engine, + IN gctUINT32 ProcessID, + IN gctBOOL Shared, + OUT gckPREEMPT_COMMIT *PreemptCommit + ) +{ + gceSTATUS status = gcvSTATUS_OK; + gctPOINTER pointer = gcvNULL; + gckCONTEXT context = gcvNULL; + gctPOINTER userPtr = gcvNULL; + gctBOOL needCopy = gcvFALSE; + gctUINT64 next = 0; + gcsHAL_COMMAND_LOCATION *cmdLoc = gcvNULL; + gcsHAL_COMMAND_LOCATION *cursor = gcvNULL; + gcsHAL_COMMAND_LOCATION *cmdLocHead = gcvNULL; + gcsSTATE_DELTA_PTR uDelta = gcvNULL; + gcsSTATE_DELTA_PTR kDelta = gcvNULL; + gcsSTATE_DELTA_RECORD_PTR kRecordArray = gcvNULL; + gcsQUEUE_PTR uQueue = gcvNULL; + gcsQUEUE_PTR kQueue = gcvNULL; + gcsQUEUE_PTR kQueueHead = gcvNULL; + gcsQUEUE_PTR kQueueTail = gcvNULL; + gckPREEMPT_COMMIT preemptCommit = gcvNULL; + gckVIDMEM_NODE commandBufferVideoMem = gcvNULL; + gctPOINTER commandBufferLogical= gcvNULL; + gctUINT32 dirtyRecordArraySize = 0; + + gcmkHEADER_ARG("Kernel=%p SubCommit=%p Engine=%x ProcessID=%x Shared=%x", + Kernel, SubCommit, Engine, ProcessID, Shared); + + /* Verify the arguments. */ + gcmkVERIFY_ARGUMENT(Kernel != gcvNULL); + gcmkVERIFY_ARGUMENT(SubCommit != gcvNULL); + + gcmkONERROR(gckOS_Allocate( + Kernel->os, + gcmSIZEOF(gcsPREEMPT_COMMIT), + &pointer)); + + preemptCommit = (gckPREEMPT_COMMIT)pointer; + + if (SubCommit->context) + { + context = gckKERNEL_QueryPointerFromName( + Kernel, + (gctUINT32)(SubCommit->context) + ); + } + + gcmkVERIFY_OK(gckOS_QueryNeedCopy(Kernel->os, ProcessID, &needCopy)); + + gcmkONERROR(gckOS_Allocate( + Kernel->os, + gcmSIZEOF(gcsHAL_COMMAND_LOCATION), + &pointer)); + + cmdLocHead = (gcsHAL_COMMAND_LOCATION *)pointer; + + cmdLoc = &SubCommit->commandBuffer; + + gcmkONERROR(gckVIDMEM_HANDLE_Lookup( + Kernel, + ProcessID, + cmdLoc->videoMemNode, + &commandBufferVideoMem + )); + + gcmkONERROR(gckVIDMEM_NODE_LockCPU( + Kernel, + commandBufferVideoMem, + gcvFALSE, + gcvFALSE, + &commandBufferLogical + )); + + gcmkONERROR(gckOS_MemCopy(cmdLocHead, cmdLoc, gcmSIZEOF(gcsHAL_COMMAND_LOCATION))); + + cmdLocHead->logical = gcmPTR_TO_UINT64(commandBufferLogical); + + cursor = cmdLocHead; + + do + { + gcsHAL_COMMAND_LOCATION * user; + if (userPtr) + { + gcmkONERROR( + gckOS_Allocate(Kernel->os, + gcmSIZEOF(gcsHAL_COMMAND_LOCATION), + &pointer)); + + cmdLoc = (gcsHAL_COMMAND_LOCATION *)pointer; + + if (needCopy) + { + status = gckOS_CopyFromUserData( + Kernel->os, + cmdLoc, + userPtr, + gcmSIZEOF(gcsHAL_COMMAND_LOCATION) + ); + } + else + { + status = gckOS_MapUserPointer( + Kernel->os, + userPtr, + gcmSIZEOF(gcsHAL_COMMAND_LOCATION), + (gctPOINTER *)&cmdLoc + ); + } + + if (gcmIS_ERROR(status)) + { + userPtr = gcvNULL; + gcmkONERROR(status); + } + + gcmkONERROR(gckVIDMEM_HANDLE_Lookup( + Kernel, + ProcessID, + cmdLoc->videoMemNode, + &commandBufferVideoMem + )); + + gcmkONERROR(gckVIDMEM_NODE_LockCPU( + Kernel, + commandBufferVideoMem, + gcvFALSE, + gcvFALSE, + &commandBufferLogical + )); + + cursor->next = gcmPTR_TO_UINT64(cmdLoc); + cursor = (gcsHAL_COMMAND_LOCATION *)gcmUINT64_TO_PTR(cursor->next); + cursor->logical = gcmPTR_TO_UINT64(commandBufferLogical); + } + + next = cmdLoc->next; + + if (!needCopy && userPtr) + { + gcmkVERIFY_OK(gckOS_UnmapUserPointer( + Kernel->os, + userPtr, + gcmSIZEOF(gcsHAL_COMMAND_LOCATION), + cmdLoc + )); + } + + userPtr = gcmUINT64_TO_PTR(next); + user = (gcsHAL_COMMAND_LOCATION *)userPtr; + } + while (userPtr); + + if (SubCommit->delta) + { + uDelta = gcmUINT64_TO_PTR(SubCommit->delta); + + gcmkONERROR(gckKERNEL_OpenUserData( + Kernel, needCopy, + &preemptCommit->sDelta, + uDelta, gcmSIZEOF(gcsSTATE_DELTA), + (gctPOINTER *)&kDelta + )); + + dirtyRecordArraySize + = gcmSIZEOF(gcsSTATE_DELTA_RECORD) * kDelta->recordCount; + + if (dirtyRecordArraySize) + { + gcmkONERROR(gckOS_Allocate( + Kernel->os, + gcmSIZEOF(gcsSTATE_DELTA_RECORD) * dirtyRecordArraySize, + &pointer + )); + + preemptCommit->recordArray = (gcsSTATE_DELTA_RECORD_PTR)pointer; + + gcmkONERROR(gckKERNEL_OpenUserData( + Kernel, needCopy, + preemptCommit->recordArray, + gcmUINT64_TO_PTR(kDelta->recordArray), + dirtyRecordArraySize, + (gctPOINTER *) &kRecordArray + )); + + if (kRecordArray == gcvNULL) + { + gcmkONERROR(gcvSTATUS_INVALID_ARGUMENT); + } + + gcmkONERROR(gckKERNEL_CloseUserData( + Kernel, needCopy, + gcvFALSE, + gcmUINT64_TO_PTR(kDelta->recordArray), + dirtyRecordArraySize, + (gctPOINTER *) &kRecordArray + )); + + } + else + { + preemptCommit->recordArray = gcvNULL; + } + + kDelta->recordArray = gcmPTR_TO_UINT64(preemptCommit->recordArray); + + if (context && context->maxState > 0) + { + gctUINT bytes = gcmSIZEOF(gctUINT) * context->maxState; + gctUINT32 *kMapEntryID = gcvNULL; + gctUINT32 *kMapEntryIndex = gcvNULL; + + gcmkONERROR(gckOS_Allocate( + Kernel->os, bytes, &pointer + )); + + preemptCommit->mapEntryID = (gctUINT32 *)pointer; + + kDelta->mapEntryIDSize = bytes; + + gcmkONERROR(gckKERNEL_OpenUserData( + Kernel, needCopy, + preemptCommit->mapEntryID, + gcmUINT64_TO_PTR(kDelta->mapEntryID), + bytes, + (gctPOINTER *) &kMapEntryID + )); + + if (kMapEntryID == gcvNULL) + { + gcmkONERROR(gcvSTATUS_INVALID_ARGUMENT); + } + + gcmkONERROR(gckKERNEL_CloseUserData( + Kernel, needCopy, + gcvFALSE, + gcmUINT64_TO_PTR(kDelta->mapEntryID), + bytes, + (gctPOINTER *) &kMapEntryID + )); + + kDelta->mapEntryID = gcmPTR_TO_UINT64(preemptCommit->mapEntryID); + + gcmkONERROR(gckOS_Allocate( + Kernel->os, bytes, &pointer + )); + + preemptCommit->mapEntryIndex = (gctUINT32 *)pointer; + + gcmkONERROR(gckKERNEL_OpenUserData( + Kernel, needCopy, + preemptCommit->mapEntryIndex, + gcmUINT64_TO_PTR(kDelta->mapEntryIndex), + bytes, + (gctPOINTER *) &kMapEntryIndex + )); + + if (kMapEntryIndex == gcvNULL) + { + gcmkONERROR(gcvSTATUS_INVALID_ARGUMENT); + } + + gcmkONERROR(gckKERNEL_CloseUserData( + Kernel, needCopy, + gcvFALSE, + gcmUINT64_TO_PTR(kDelta->mapEntryIndex), + bytes, + (gctPOINTER *) &kMapEntryIndex + )); + + kDelta->mapEntryIndex = gcmPTR_TO_UINT64(preemptCommit->mapEntryIndex); + } + + preemptCommit->delta = kDelta; + + gcmkONERROR(gckKERNEL_CloseUserData( + Kernel, needCopy, + gcvFALSE, + uDelta, gcmSIZEOF(gcsSTATE_DELTA), + (gctPOINTER *) &kDelta + )); + } + + uQueue = gcmUINT64_TO_PTR(SubCommit->queue); + if (uQueue != gcvNULL) + { + gcsQUEUE_PTR sEventQueue = gcvNULL; + gcsQUEUE_PTR next = gcvNULL; + + gcmkONERROR( + gckOS_Allocate(Kernel->os, + gcmSIZEOF(gcsQUEUE), + &pointer)); + + sEventQueue = (gcsQUEUE_PTR)pointer; + + gcmkONERROR(gckKERNEL_OpenUserData( + Kernel, needCopy, + sEventQueue, + uQueue, gcmSIZEOF(gcsQUEUE), + (gctPOINTER *)&kQueue + )); + + next = (gcsQUEUE_PTR)gcmUINT64_TO_PTR(kQueue->next); + + if (!needCopy && uQueue) + { + gcmkVERIFY_OK(gckOS_UnmapUserPointer( + Kernel->os, + uQueue, + gcmSIZEOF(gcsQUEUE), + (gctPOINTER *)&kQueue + )); + } + + uQueue = next; + kQueueHead = kQueueTail = kQueue; + + while (uQueue != gcvNULL) + { + gcmkONERROR( + gckOS_Allocate(Kernel->os, + gcmSIZEOF(gcsQUEUE), + &pointer)); + + sEventQueue = (gcsQUEUE_PTR)pointer; + + gcmkONERROR(gckKERNEL_OpenUserData( + Kernel, needCopy, + sEventQueue, + uQueue, gcmSIZEOF(gcsQUEUE), + (gctPOINTER *)&kQueue + )); + + next = (gcsQUEUE_PTR)gcmUINT64_TO_PTR(kQueue->next); + + if (!needCopy && uQueue) + { + gcmkVERIFY_OK(gckOS_UnmapUserPointer( + Kernel->os, + uQueue, + gcmSIZEOF(gcsQUEUE), + (gctPOINTER *)&kQueue + )); + } + + uQueue = next; + kQueueTail->next = gcmPTR_TO_UINT64(kQueue); + kQueueTail = kQueue; + } + } + + preemptCommit->engine = Engine; + preemptCommit->pid = ProcessID; + preemptCommit->shared = Shared; + preemptCommit->cmdLoc = cmdLocHead; + + preemptCommit->dirtyRecordArraySize = dirtyRecordArraySize; + + preemptCommit->context = context; + preemptCommit->eventQueue = kQueueHead; + preemptCommit->eventOnly = gcvFALSE; + preemptCommit->priorityID = SubCommit->priorityID; + preemptCommit->next = gcvNULL; + preemptCommit->isEnd = gcvFALSE; + preemptCommit->isNop = gcvFALSE; + + *PreemptCommit = preemptCommit; + + gcmkFOOTER_NO(); + return gcvSTATUS_OK; + +OnError: + if (preemptCommit != gcvNULL) + { + gcmkVERIFY_OK(gckKERNEL_DestroyPreemptCommit(Kernel, preemptCommit)); + } + + gcmkFOOTER(); + return status; +} + +/******************************************************************************* +** +** gckKERNEL_PreparePreemptEvent +** +** Prepare the preempt event. +** +** INPUT: +** +** gckKERNEL Kernel +** Pointer to an gckKERNEL. +** +** gcsQUEUE_PTR Queue +** Pointer to the user commit event queue. +** +** gctUINT32 PriorityID +** Priority ID of this event. +** +** gctUINT32 ProcessID +** Proccess ID of this event. +** +** OUTPUT: +** gckPREEMPT_COMMIT * PreemptCommit +** The gckPREEMPT_COMMIT object to construct. +** +*/ +gceSTATUS +gckKERNEL_PreparePreemptEvent( + IN gckKERNEL Kernel, + IN gcsQUEUE_PTR Queue, + IN gctUINT32 PriorityID, + IN gctUINT32 ProcessID, + OUT gckPREEMPT_COMMIT *PreemptCommit + ) +{ + gceSTATUS status = gcvSTATUS_OK; + gctPOINTER pointer = gcvNULL; + gctBOOL needCopy = gcvFALSE; + gcsQUEUE_PTR uQueue = Queue; + gcsQUEUE_PTR kQueue = gcvNULL; + gcsQUEUE_PTR kQueueHead = gcvNULL; + gcsQUEUE_PTR kQueueTail = gcvNULL; + gckPREEMPT_COMMIT preemptCommit = gcvNULL; + + gcmkHEADER_ARG("Kernel=%p Queue=%p PriorityID=%x ProcessID=%x", + Kernel, Queue, ProcessID); + + gcmkONERROR(gckOS_Allocate( + Kernel->os, + gcmSIZEOF(gcsPREEMPT_COMMIT), + &pointer)); + + preemptCommit = (gckPREEMPT_COMMIT)pointer; + + gcmkVERIFY_OK(gckOS_QueryNeedCopy(Kernel->os, ProcessID, &needCopy)); + + if (uQueue) + { + gcsQUEUE_PTR sEventQueue = gcvNULL; + gcsQUEUE_PTR next = gcvNULL; + + gcmkONERROR( + gckOS_Allocate(Kernel->os, + gcmSIZEOF(gcsQUEUE), + &pointer)); + + sEventQueue = (gcsQUEUE_PTR)pointer; + + gcmkONERROR(gckKERNEL_OpenUserData( + Kernel, needCopy, + sEventQueue, + uQueue, gcmSIZEOF(gcsQUEUE), + (gctPOINTER *)&kQueue + )); + + next = (gcsQUEUE_PTR)gcmUINT64_TO_PTR(kQueue->next); + + if (!needCopy && uQueue) + { + gcmkVERIFY_OK(gckOS_UnmapUserPointer( + Kernel->os, + uQueue, + gcmSIZEOF(gcsQUEUE), + (gctPOINTER *)&kQueue + )); + } + + uQueue = next; + kQueueHead = kQueueTail = kQueue; + + while (uQueue != gcvNULL) + { + gcmkONERROR( + gckOS_Allocate(Kernel->os, + gcmSIZEOF(gcsQUEUE), + &pointer)); + + sEventQueue = (gcsQUEUE_PTR)pointer; + + gcmkONERROR(gckKERNEL_OpenUserData( + Kernel, needCopy, + sEventQueue, + uQueue, gcmSIZEOF(gcsQUEUE), + (gctPOINTER *)&kQueue + )); + + next = (gcsQUEUE_PTR)gcmUINT64_TO_PTR(kQueue->next); + + if (!needCopy && uQueue) + { + gcmkVERIFY_OK(gckOS_UnmapUserPointer( + Kernel->os, + uQueue, + gcmSIZEOF(gcsQUEUE), + (gctPOINTER *)&kQueue + )); + } + + uQueue = next; + kQueueTail->next = gcmPTR_TO_UINT64(kQueue); + kQueueTail = kQueue; + } + } + + preemptCommit->eventQueue = kQueueHead; + preemptCommit->priorityID = PriorityID; + preemptCommit->eventOnly = gcvTRUE; + preemptCommit->pid = ProcessID; + preemptCommit->next = gcvNULL; + preemptCommit->isEnd = gcvFALSE; + preemptCommit->isNop = gcvFALSE; + + preemptCommit->cmdLoc = gcvNULL; + preemptCommit->mapEntryID = gcvNULL; + preemptCommit->mapEntryIndex = gcvNULL; + preemptCommit->recordArray = gcvNULL; + preemptCommit->delta = gcvNULL; + preemptCommit->context = gcvNULL; + + *PreemptCommit = preemptCommit; + + gcmkFOOTER_NO(); + return gcvSTATUS_OK; + +OnError: + if (preemptCommit != gcvNULL) + { + gcmkVERIFY_OK(gckKERNEL_DestroyPreemptCommit(Kernel, preemptCommit)); + } + + gcmkFOOTER(); + return status; +} + +/* Construct a NOP preemptCommit which means it is the end commit. */ +gceSTATUS +gckKERNEL_PreemptCommitDone( + IN gckKERNEL Kernel, + IN gctUINT32 PriorityID, + OUT gckPREEMPT_COMMIT *PreemptCommit + ) +{ + gceSTATUS status = gcvSTATUS_OK; + gckPREEMPT_COMMIT preemptCommit = gcvNULL; + + gcmkHEADER_ARG("Kernel=%p", Kernel); + + gcmkONERROR(gckOS_Allocate( + Kernel->os, + gcmSIZEOF(gcsPREEMPT_COMMIT), + (gctPOINTER *)&preemptCommit)); + + gckOS_ZeroMemory(preemptCommit, sizeof(gcsPREEMPT_COMMIT)); + + preemptCommit->priorityID = PriorityID; + + preemptCommit->isEnd = gcvTRUE; + + *PreemptCommit = preemptCommit; + +OnError: + gcmkFOOTER(); + return status; +} + +/* Construct a NOP preemptCommit to block all the lower priority queues. */ +gceSTATUS +gckKERNEL_PreemptCommitNop( + IN gckKERNEL Kernel, + IN gctUINT32 PriorityID, + OUT gckPREEMPT_COMMIT *PreemptCommit + ) +{ + gceSTATUS status = gcvSTATUS_OK; + gckPREEMPT_COMMIT preemptCommit = gcvNULL; + + gcmkHEADER_ARG("Kernel=%p", Kernel); + + gcmkONERROR(gckOS_Allocate( + Kernel->os, + gcmSIZEOF(gcsPREEMPT_COMMIT), + (gctPOINTER *)&preemptCommit)); + + gckOS_ZeroMemory(preemptCommit, sizeof(gcsPREEMPT_COMMIT)); + + preemptCommit->priorityID = PriorityID; + + preemptCommit->isNop = gcvTRUE; + + *PreemptCommit = preemptCommit; + +OnError: + gcmkFOOTER(); + return status; +} + +/******************************************************************************* +** +** gckKERNEL_PriorityQueueConstruct +** +** Construct the priority queue. +** +** INPUT: +** +** gckKERNEL Kernel +** Pointer to an gckKERNEL. +** +** gctUINT32 PriorityID +** Priority ID of this queue. +** +** OUTPUT: +** gcsPRIORITY_QUEUE_PTR +** The priority queue to construct. +** +*/ +gceSTATUS +gckKERNEL_PriorityQueueConstruct( + gckKERNEL Kernel, + gctUINT PriorityID, + gcsPRIORITY_QUEUE_PTR * Queue + ) +{ + gceSTATUS status = gcvSTATUS_OK; + gctPOINTER pointer = gcvNULL; + gcsPRIORITY_QUEUE_PTR queue; + + gcmkHEADER_ARG("Kernel=%p PriorityID=%d", Kernel, PriorityID); + + gcmkVERIFY_OBJECT(Kernel, gcvOBJ_KERNEL); + gcmkVERIFY_ARGUMENT(Kernel != gcvNULL); + gcmkVERIFY_ARGUMENT(Queue != gcvNULL); + + gcmkONERROR( + gckOS_Allocate(Kernel->os, + gcmSIZEOF(gcsPRIORITY_QUEUE), + &pointer)); + + queue = pointer; + + queue->id = PriorityID; + queue->head = gcvNULL; + queue->tail = gcvNULL; + + *Queue = queue; + +OnError: + gcmkFOOTER(); + return status; +} + +/******************************************************************************* +** +** gckKERNEL_PriorityQueueDestroy +** +** Destroy the priority queue. +** +** INPUT: +** +** gckKERNEL Kernel +** Pointer to an gckKERNEL. +** +** gcsPRIORITY_QUEUE_PTR +** The priority queue to destroy. +** +*/ +gceSTATUS +gckKERNEL_PriorityQueueDestroy( + gckKERNEL Kernel, + gcsPRIORITY_QUEUE_PTR Queue + ) +{ + gceSTATUS status = gcvSTATUS_OK; + + gcmkHEADER_ARG("Kernel=%p", Kernel); + + gcmkVERIFY_OBJECT(Kernel, gcvOBJ_KERNEL); + gcmkVERIFY_ARGUMENT(Kernel != gcvNULL); + gcmkVERIFY_ARGUMENT(Queue != gcvNULL); + + Kernel->priorityQueues[Queue->id] = gcvNULL; + + gcmkVERIFY_OK(gcmkOS_SAFE_FREE(Kernel->os, Queue)); + + gcmkFOOTER(); + return status; +} + +/******************************************************************************* +** +** gckKERNEL_PriorityQueueAppend +** +** Append preempt commit to the priority queue. +** +** INPUT: +** +** gckKERNEL Kernel +** Pointer to an gckKERNEL. +** +** gctUINT32 PriorityID +** Priority ID of this queue. +** +** gckPREEMPT_COMMIT +** The preempt commit. +** +*/ +gceSTATUS +gckKERNEL_PriorityQueueAppend( + IN gckKERNEL Kernel, + IN gctUINT PriorityID, + IN gckPREEMPT_COMMIT PreemptCommit + ) +{ + gceSTATUS status = gcvSTATUS_OK; + gctBOOL acquired = gcvFALSE; + gctBOOL constructed = gcvFALSE; + gcsPRIORITY_QUEUE_PTR queue = gcvNULL; + + gcmkHEADER_ARG("Kernel=%p PriorityID=%d PreemptCommit=%p", Kernel, PriorityID, PreemptCommit); + + gcmkVERIFY_OBJECT(Kernel, gcvOBJ_KERNEL); + gcmkVERIFY_ARGUMENT(Kernel != gcvNULL); + gcmkVERIFY_ARGUMENT(PreemptCommit != gcvNULL); + gcmkVERIFY_ARGUMENT(PriorityID < gcdMAX_PRIORITY_QUEUE_NUM); + + gcmkONERROR( + gckOS_AcquireMutex(Kernel->os, + Kernel->priorityQueueMutex[PriorityID], + gcvINFINITE)); + acquired = gcvTRUE; + + queue = Kernel->priorityQueues[PriorityID]; + + if (!queue) + { + gcmkONERROR(gckKERNEL_PriorityQueueConstruct(Kernel, PriorityID, &queue)); + + Kernel->priorityQueues[PriorityID] = queue; + + constructed = gcvTRUE; + } + + if (queue->head == gcvNULL) + { + queue->head = PreemptCommit; + queue->tail = PreemptCommit; + } + else + { + queue->tail->next = PreemptCommit; + queue->tail = PreemptCommit; + } + + gcmkONERROR(gckOS_ReleaseMutex(Kernel->os, Kernel->priorityQueueMutex[PriorityID])); + + + gcmkFOOTER_NO(); + + return gcvSTATUS_OK; + +OnError: + if (acquired) + { + gcmkVERIFY_OK(gckOS_ReleaseMutex(Kernel->os, Kernel->priorityQueueMutex[PriorityID])); + } + + if (constructed && queue) + { + gcmkVERIFY_OK(gckKERNEL_PriorityQueueDestroy(Kernel, queue)); + } + + gcmkFOOTER(); + return status; +} + +/******************************************************************************* +** +** gckKERNEL_PriorityQueueRemove +** +** Remove preempt commit from the priority queue. +** +** INPUT: +** +** gckKERNEL Kernel +** Pointer to an gckKERNEL. +** +** gcsPRIORITY_QUEUE_PTR +** The priority queue to append. +** +** OUTPUT: +** gckPREEMPT_COMMIT * +** The preempt commit. +** +*/ +gceSTATUS +gckKERNEL_PriorityQueueRemove( + IN gckKERNEL Kernel, + IN gcsPRIORITY_QUEUE_PTR Queue, + OUT gckPREEMPT_COMMIT * PreemptCommit + ) +{ + gckPREEMPT_COMMIT preemptCommit = gcvNULL; + + gcmkHEADER_ARG("Kernel=%p Queue=%p PreemptCommit=%p", Kernel, Queue, PreemptCommit); + + /* Verify the arguments. */ + gcmkVERIFY_OBJECT(Kernel, gcvOBJ_KERNEL); + gcmkVERIFY_ARGUMENT(Kernel != gcvNULL); + gcmkVERIFY_ARGUMENT(PreemptCommit != gcvNULL); + + if (Queue->head != gcvNULL) + { + preemptCommit = Queue->head; + Queue->head = preemptCommit->next; + } + + *PreemptCommit = preemptCommit; + + gcmkFOOTER_NO(); + + return gcvSTATUS_OK; +} + +gceSTATUS +gckKERNEL_NormalPreemption( + gckKERNEL Kernel + ) +{ + gcsPRIORITY_QUEUE_PTR queue = gcvNULL; + gckPREEMPT_COMMIT preemptCommit = gcvNULL; + gceSTATUS status = gcvSTATUS_OK; + gctBOOL queueAvailable; + gctINT id; + + for (id = gcdMAX_PRIORITY_QUEUE_NUM - 1; id >= 0; id--) + { + gcmkONERROR(gckOS_AcquireMutex(Kernel->os, Kernel->priorityQueueMutex[id], gcvINFINITE)); + + queueAvailable = gcvFALSE; + + queue = Kernel->priorityQueues[id]; + if (!queue || !queue->head) + { + gcmkONERROR(gckOS_ReleaseMutex(Kernel->os, Kernel->priorityQueueMutex[id])); + continue; + } + else + { + gcmkONERROR(gckKERNEL_PriorityQueueRemove(Kernel, queue, &preemptCommit)); + + if (preemptCommit) + { + gctBOOL forced; + + if (!preemptCommit->eventOnly) + { + if (preemptCommit->context) + { + gcmkONERROR(gckCONTEXT_UpdateDelta(preemptCommit->context, preemptCommit->delta)); + } + + status = gckCOMMAND_PreemptCommit(Kernel->command, preemptCommit); + + if (status != gcvSTATUS_INTERRUPTED) + { + gcmkONERROR(status); + } + + forced = Kernel->hardware->options.powerManagement; + } + else + { + forced = gcvFALSE; + } + + status = gckEVENT_PreemptCommit(Kernel->eventObj, + preemptCommit, + forced); + + if (status != gcvSTATUS_INTERRUPTED) + { + gcmkONERROR(status); + } + + gcmkONERROR(gckKERNEL_DestroyPreemptCommit(Kernel, preemptCommit)); + } + + } + + gcmkONERROR(gckOS_ReleaseMutex(Kernel->os, Kernel->priorityQueueMutex[id])); + } + +OnError: + return status; +} + +gceSTATUS +gckKERNEL_FullPreemption( + gckKERNEL Kernel + ) +{ + gcsPRIORITY_QUEUE_PTR queue = gcvNULL; + gckPREEMPT_COMMIT preemptCommit = gcvNULL; + gceSTATUS status = gcvSTATUS_OK; + gctUINT32 curHighestPriorityID = 0; + gctINT id; + + for (id = gcdMAX_PRIORITY_QUEUE_NUM - 1; id >= 0; id--) + { + gcmkONERROR(gckOS_AcquireMutex(Kernel->os, Kernel->priorityQueueMutex[id], gcvINFINITE)); + + queue = Kernel->priorityQueues[id]; + if (!queue || !queue->head) + { + gcmkONERROR(gckOS_ReleaseMutex(Kernel->os, Kernel->priorityQueueMutex[id])); + continue; + } + + do + { + gcmkVERIFY_OK(gckOS_AtomGet(Kernel->os, Kernel->device->atomPriorityID, &curHighestPriorityID)); + if (id < curHighestPriorityID) + { + gcmkONERROR(gckOS_ReleaseMutex(Kernel->os, Kernel->priorityQueueMutex[id])); + return gcvSTATUS_OK; + } + + gcmkONERROR(gckKERNEL_PriorityQueueRemove(Kernel, queue, &preemptCommit)); + + if (preemptCommit && !preemptCommit->isNop) + { + gctBOOL forced; + + if (!preemptCommit->eventOnly) + { + if (preemptCommit->context) + { + if (preemptCommit->context->prevDeltaPtr) + { + gcmkONERROR(gckCONTEXT_UpdateDelta(preemptCommit->context, preemptCommit->context->prevDeltaPtr)); + gcmkONERROR(gckCONTEXT_DestroyPrevDelta(preemptCommit->context)); + } + + gcmkONERROR(gckCONTEXT_UpdateDelta(preemptCommit->context, preemptCommit->delta)); + } + + status = gckCOMMAND_PreemptCommit(Kernel->command, preemptCommit); + + if (status != gcvSTATUS_INTERRUPTED) + { + gcmkONERROR(status); + } + + forced = Kernel->hardware->options.powerManagement; + } + else + { + forced = gcvFALSE; + } + + status = gckEVENT_PreemptCommit(Kernel->eventObj, + preemptCommit, + forced); + + if (status != gcvSTATUS_INTERRUPTED) + { + gcmkONERROR(status); + } + + gcmkONERROR(gckKERNEL_DestroyPreemptCommit(Kernel, preemptCommit)); + } + + } while (queue->head != gcvNULL); + + gcmkONERROR(gckOS_ReleaseMutex(Kernel->os, Kernel->priorityQueueMutex[id])); + } + +OnError: + return status; +} + +gceSTATUS +gckKERNEL_PreemptionThread( + gckKERNEL Kernel + ) +{ + gceSTATUS status; + + if (Kernel->preemptionMode == gcvFULLY_PREEMPTIBLE_MODE) + { + gcmkONERROR(gckKERNEL_FullPreemption(Kernel)); + } + else + { + gcmkONERROR(gckKERNEL_NormalPreemption(Kernel)); + } + +OnError: + return status; +} + +/******************************************************************************* +** +** gckKERNEL_CommandCommitPreemption +** +** Commit the command with preemption. +** +** INPUT: +** +** gckKERNEL Kernel +** Pointer to an gckKERNEL. +** +** gceENGINE Engine +** Engine type of the user commit. +** +** gctUINT32 ProcessID +** Proccess ID of this commit. +** +** gckCOMMAND Command +** Kernel command queue. +** +** gckEVENT EventObj +** Event object. +** +** gcsHAL_SUBCOMMIT * SubCommit +** SubCommit pointer from user driver. +** +** gcsHAL_COMMIT * Commit +** Commit pointer from user driver. +** +*/ +gceSTATUS +gckKERNEL_CommandCommitPreemption( + IN gckKERNEL Kernel, + IN gceENGINE Engine, + IN gctUINT32 ProcessID, + IN gckCOMMAND Command, + IN gckEVENT EventObj, + IN gcsHAL_SUBCOMMIT * SubCommit, + IN OUT gcsHAL_COMMIT * Commit + ) +{ + gctUINT32 priorityID = 0; + gctUINT32 curHighestPriorityID = 0; + gckPREEMPT_COMMIT preemptCommit = gcvNULL; + gceSTATUS status = gcvSTATUS_OK; + + gcmkHEADER_ARG("Kernel=%p Engine=%x ProcessID=%x Command=%p, EventObj=%p SubCommit=%p Commit=%p", + Kernel, Engine, ProcessID, Command, EventObj, SubCommit, Commit); + + gcmkVERIFY_ARGUMENT(Kernel != gcvNULL); + gcmkVERIFY_ARGUMENT(Command != gcvNULL); + gcmkVERIFY_ARGUMENT(SubCommit != gcvNULL); + gcmkVERIFY_ARGUMENT(Commit != gcvNULL); + + priorityID = SubCommit->priorityID; + + if (Kernel->preemptionMode == gcvFULLY_PREEMPTIBLE_MODE) + { + Commit->needMerge = gcvTRUE; + + gcmkVERIFY_OK(gckOS_AtomGet(Kernel->os, Kernel->device->atomPriorityID, &curHighestPriorityID)); + + if (SubCommit->topPriority && priorityID != curHighestPriorityID) + { + priorityID = curHighestPriorityID; + } + + if (!Kernel->priorityDBCreated[priorityID]) + { + gcmkONERROR( + gckKERNEL_AddProcessDB(Kernel, + ProcessID, + gcvDB_PRIORITY, + gcmINT2PTR(priorityID), + gcvNULL, + 0)); + } + + if (priorityID < curHighestPriorityID || + (priorityID == curHighestPriorityID && Kernel->priorityQueues[priorityID] + && Kernel->priorityQueues[priorityID]->head)) + { + + gcmkONERROR( + gckKERNEL_ConstructPreemptCommit(Kernel, + SubCommit, + Engine, + ProcessID, + Commit->shared, + &preemptCommit)); + + gcmkONERROR( + gckKERNEL_PriorityQueueAppend(Kernel, + priorityID, + preemptCommit)); + + Commit->commitStamp = Command->commitStamp++; + Commit->needMerge = gcvFALSE; + + if (priorityID == curHighestPriorityID) + { + gcmkONERROR(gckOS_ReleaseSemaphoreEx(Kernel->os, Kernel->preemptSema)); + } + } + else + { + gcmkVERIFY_OK(gckOS_AtomSet(Kernel->os, Kernel->device->atomPriorityID, priorityID)); + + status = gckCOMMAND_Commit(Command, + SubCommit, + ProcessID, + Commit->shared, + &Commit->commitStamp, + &Commit->contextSwitched); + + if (status != gcvSTATUS_INTERRUPTED) + { + gcmkONERROR(status); + } + + status = gckEVENT_Commit( + EventObj, + gcmUINT64_TO_PTR(SubCommit->queue), + Kernel->hardware->options.powerManagement + ); + + if (status != gcvSTATUS_INTERRUPTED) + { + gcmkONERROR(status); + } + } + } + else + { + gcmkONERROR( + gckKERNEL_ConstructPreemptCommit(Kernel, + SubCommit, + Engine, + ProcessID, + Commit->shared, + &preemptCommit)); + + gcmkONERROR( + gckKERNEL_PriorityQueueAppend(Kernel, + priorityID, + preemptCommit)); + + Commit->commitStamp = Command->commitStamp++; + Commit->needMerge = gcvFALSE; + + gcmkONERROR(gckOS_ReleaseSemaphore(Kernel->os, Kernel->preemptSema)); + } + +OnError: + gcmkFOOTER(); + + return status; +} + +/******************************************************************************* +** +** gckKERNEL_CommandCommitPreemption +** +** Commit the command with preemption. +** +** INPUT: +** +** gckKERNEL Kernel +** Pointer to an gckKERNEL. +** +** gceENGINE Engine +** Engine type of the user commit. +** +** gctUINT32 ProcessID +** Proccess ID of this commit. +** +** gcsQUEUE_PTR Queue +** Event queue of the user commit. +** +** gctUINT32 PriorityID +** Priority ID of this commit. +** +** gctBOOL TopPriority +** If this commit requires top priority. +** +*/ +gceSTATUS +gckKERNEL_EventCommitPreemption( + IN gckKERNEL Kernel, + IN gceENGINE Engine, + IN gctUINT32 ProcessID, + IN gcsQUEUE_PTR Queue, + IN gctUINT32 PriorityID, + IN gctBOOL TopPriority + ) +{ + gctUINT32 priorityID = PriorityID; + gctUINT32 curHighestPriorityID = 0; + gceSTATUS status = gcvSTATUS_OK; + gckPREEMPT_COMMIT preemptCommit = gcvNULL; + + gcmkHEADER_ARG("Kernel=%p Engine=%x ProcessID=%x Queue=%p, PriorityID=%x", + Kernel, Engine, ProcessID, Queue, PriorityID); + + gcmkVERIFY_ARGUMENT(Kernel != gcvNULL); + gcmkVERIFY_ARGUMENT(Queue != gcvNULL); + + if (Kernel->preemptionMode == gcvFULLY_PREEMPTIBLE_MODE) + { + gcmkVERIFY_OK(gckOS_AtomGet(Kernel->os, Kernel->device->atomPriorityID, &curHighestPriorityID)); + + if (TopPriority && priorityID != curHighestPriorityID) + { + priorityID = curHighestPriorityID; + } + + if (!Kernel->priorityDBCreated[priorityID]) + { + gcmkONERROR( + gckKERNEL_AddProcessDB(Kernel, + ProcessID, + gcvDB_PRIORITY, + gcmINT2PTR(priorityID), + gcvNULL, + 0)); + } + + if (priorityID < curHighestPriorityID || + (priorityID == curHighestPriorityID && Kernel->priorityQueues[priorityID] + && Kernel->priorityQueues[priorityID]->head)) + { + gcmkONERROR( + gckKERNEL_PreparePreemptEvent(Kernel, + Queue, + priorityID, + ProcessID, + &preemptCommit)); + + gcmkONERROR( + gckKERNEL_PriorityQueueAppend(Kernel, + priorityID, + preemptCommit)); + + if (priorityID == curHighestPriorityID) + { + gcmkONERROR(gckOS_ReleaseSemaphoreEx(Kernel->os, Kernel->preemptSema)); + } + } + else + { + gckEVENT eventObj = gcvNULL; + + gcmkVERIFY_OK(gckOS_AtomSet(Kernel->os, Kernel->device->atomPriorityID, priorityID)); + + if (Engine == gcvENGINE_BLT) + { + if (!gckHARDWARE_IsFeatureAvailable(Kernel->hardware, gcvFEATURE_ASYNC_BLIT)) + { + gcmkONERROR(gcvSTATUS_NOT_SUPPORTED); + } + + eventObj = Kernel->asyncEvent; + } + else + { + eventObj = Kernel->eventObj; + } + + gcmkONERROR( + gckEVENT_Commit(eventObj, + Queue, + gcvFALSE)); + + } + } + else + { + gcmkONERROR( + gckKERNEL_PreparePreemptEvent(Kernel, + Queue, + priorityID, + ProcessID, + &preemptCommit)); + + gcmkONERROR( + gckKERNEL_PriorityQueueAppend(Kernel, + priorityID, + preemptCommit)); + + gcmkONERROR(gckOS_ReleaseSemaphore(Kernel->os, Kernel->preemptSema)); + } + +OnError: + gcmkFOOTER(); + + return status; +} +#endif + diff --git a/drivers/amlogic/npu/kernel/gc_hal_kernel_preemption.h b/drivers/amlogic/npu/kernel/gc_hal_kernel_preemption.h new file mode 100644 index 0000000..792ae90 --- /dev/null +++ b/drivers/amlogic/npu/kernel/gc_hal_kernel_preemption.h @@ -0,0 +1,274 @@ +/**************************************************************************** +* +* The MIT License (MIT) +* +* Copyright (c) 2014 - 2020 Vivante Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +* +***************************************************************************** +* +* The GPL License (GPL) +* +* Copyright (C) 2014 - 2020 Vivante Corporation +* +* 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 +* of the License, or (at your option) any later version. +* +* 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, write to the Free Software Foundation, +* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +***************************************************************************** +* +* Note: This software is released under dual MIT and GPL licenses. A +* recipient may use this file under the terms of either the MIT license or +* GPL License. If you wish to use only one license not the other, you can +* indicate your decision by deleting one of the above license notices in your +* version of this file. +* +*****************************************************************************/ + + +#ifndef __gc_hal_kernel_preemption_h_ +#define __gc_hal_kernel_preemption_h_ + +#if gcdENABLE_SW_PREEMPTION +#define gcdMAX_PRIORITY_QUEUE_NUM 3 +#define gcdMAX_EVENT_QUEUE_NUM 29 + +/* +** Fully preemptible mode: +** Once high priority render thread commits, the low priority thread will be blocked, +** until the high priority render thread finish and exit, the low priority can continue to commit to hardware. +** +** Non-fully preemptible mode: +** The low priority render thread can commit, as long as there is no pending commit in any higher priority queue. +** +*/ +typedef enum _gcePREEMPTION_MODE +{ + gcvFULLY_PREEMPTIBLE_MODE, + gcvNON_FULLY_PREEMPTIBLE_MODE, +} +gcePREEMPTION_MODE; + +/* Preempt commit. */ +typedef struct _gcsPREEMPT_COMMIT * gckPREEMPT_COMMIT; +typedef struct _gcsPREEMPT_COMMIT +{ + /* Priority ID. */ + gctUINT32 priorityID; + + /* Engine type. */ + gceENGINE engine; + + /* Process ID. */ + gctUINT32 pid; + + /* If it is multi-core and shared commit. */ + gctBOOL shared; + + /* Command location from user commit. */ + gcsHAL_COMMAND_LOCATION *cmdLoc; + + /* Static data to store the state delta. */ + gcsSTATE_DELTA sDelta; + + /* State delta from user commit. */ + gcsSTATE_DELTA_PTR delta; + + /* Record array. */ + gcsSTATE_DELTA_RECORD_PTR recordArray; + + /* Event queue. */ + gcsQUEUE_PTR eventQueue; + + /* If it is an event only commit. */ + gctBOOL eventOnly; + + /* Context object. */ + gckCONTEXT context; + + /* Record array; holds all modified states in gcsSTATE_DELTA_RECORD. */ + gctUINT32 dirtyRecordArraySize; + + /* Map entry ID is used for map entry validation. If map entry ID does not + match the main state delta ID, the entry and the corresponding state are + considered not in use. */ + gctUINT32 *mapEntryID; + + /* If the map entry ID matches the main state delta ID, index points to + the state record in the record array. */ + gctUINT32 *mapEntryIndex; + + /* If Commit done. */ + gctBOOL isEnd; + + /* If it is a NOP commit. */ + gctBOOL isNop; + + gckPREEMPT_COMMIT next; +} +gcsPREEMPT_COMMIT; + +/* Priority queue. */ +typedef struct _gcsPRIORITY_QUEUE * gcsPRIORITY_QUEUE_PTR; +typedef struct _gcsPRIORITY_QUEUE +{ + /* Queue id. */ + gctUINT32 id; + + /* Priority queue head. */ + gckPREEMPT_COMMIT head; + + /* Priority queue tail. */ + gckPREEMPT_COMMIT tail; + + gcsPRIORITY_QUEUE_PTR next; +} +gcsPRIORITY_QUEUE; + + +/* Construct the preempt commit.*/ +gceSTATUS +gckKERNEL_ConstructPreemptCommit( + IN gckKERNEL Kernel, + IN gcsHAL_SUBCOMMIT_PTR SubCommit, + IN gceENGINE Engine, + IN gctUINT32 ProcessID, + IN gctBOOL Shared, + OUT gckPREEMPT_COMMIT *PreemptCommit + ); + +/* Prepare the preempt event.*/ +gceSTATUS +gckKERNEL_PreparePreemptEvent( + IN gckKERNEL Kernel, + IN gcsQUEUE_PTR Queue, + IN gctUINT32 PriorityID, + IN gctUINT32 ProcessID, + OUT gckPREEMPT_COMMIT *PreemptCommit + ); + +/* Destroy the priority queue. */ +gceSTATUS +gckKERNEL_PriorityQueueDestroy( + gckKERNEL Kernel, + gcsPRIORITY_QUEUE_PTR Queue + ); + + +/* Append preemptCommit to priority queue. */ +gceSTATUS +gckKERNEL_PriorityQueueAppend( + IN gckKERNEL Kernel, + IN gctUINT PriorityID, + IN gckPREEMPT_COMMIT PreemptCommit + ); + +/* Preemption thread. */ +gceSTATUS +gckKERNEL_PreemptionThread( + gckKERNEL Kernel + ); + +/* Commit command with preemption. */ +gceSTATUS +gckKERNEL_CommandCommitPreemption( + IN gckKERNEL Kernel, + IN gceENGINE Engine, + IN gctUINT32 ProcessId, + IN gckCOMMAND Command, + IN gckEVENT EventObj, + IN gcsHAL_SUBCOMMIT * SubCommit, + IN OUT gcsHAL_COMMIT * Commit + ); + +/* Commit event with preemption. */ +gceSTATUS +gckKERNEL_EventCommitPreemption( + IN gckKERNEL Kernel, + IN gceENGINE Engine, + IN gctUINT32 ProcessID, + IN gcsQUEUE_PTR Queue, + IN gctUINT32 PriorityID, + IN gctBOOL TopPriority + ); + +/* Commit command in preemption mode. */ +gceSTATUS +gckCOMMAND_PreemptCommit( + IN gckCOMMAND Command, + IN gckPREEMPT_COMMIT PreemptCommit + ); + +/* Update delta in kernel driver. */ +gceSTATUS +gckCONTEXT_UpdateDelta( + IN gckCONTEXT Context, + IN gcsSTATE_DELTA_PTR Delta + ); + +/* Destroy previous context switch delta. */ +gceSTATUS +gckCONTEXT_DestroyPrevDelta( + IN gckCONTEXT Context + ); + +/* Construct and store previous context switch delta. */ +gceSTATUS +gckCONTEXT_ConstructPrevDelta( + IN gckCONTEXT Context, + IN gctUINT32 ProcessID, + IN gcsSTATE_DELTA_PTR StateDelta + ); + +/* Context update in preemption mode.*/ +gceSTATUS +gckCONTEXT_PreemptUpdate( + IN gckCONTEXT Context, + IN gckPREEMPT_COMMIT PreemptCommit + ); + +/* Event commit in preemption mode. */ +gceSTATUS +gckEVENT_PreemptCommit( + IN gckEVENT Event, + IN gckPREEMPT_COMMIT PreemptCommit, + IN gctBOOL Forced + ); + +/* Construct a NOP preemptCommit which means it is the end commit. */ +gceSTATUS +gckKERNEL_PreemptCommitDone( + IN gckKERNEL Kernel, + IN gctUINT32 PriorityID, + OUT gckPREEMPT_COMMIT *PreemptCommit + ); +#endif + +#endif /* __gc_hal_kernel_preemption_h_ */ diff --git a/drivers/amlogic/npu/kernel/gc_hal_kernel_video_memory.c b/drivers/amlogic/npu/kernel/gc_hal_kernel_video_memory.c index d7dd92b..346a3e3 100644 --- a/drivers/amlogic/npu/kernel/gc_hal_kernel_video_memory.c +++ b/drivers/amlogic/npu/kernel/gc_hal_kernel_video_memory.c @@ -878,22 +878,20 @@ gckVIDMEM_AllocateLinear( Memory->minFreeBytes = Memory->freeBytes; } + + /* Release the mutex. */ + gcmkVERIFY_OK(gckOS_ReleaseMutex(Memory->os, Memory->mutex)); + gckOS_QueryOption(Memory->os, "allMapInOne", &mappingInOne); if (!mappingInOne) { - gcmkONERROR(gckOS_RequestReservedMemory( - Memory->os, - Memory->physicalBase + node->VidMem.offset, + gcmkONERROR(gckOS_RequestReservedMemoryArea( + Memory->physical, + node->VidMem.offset, node->VidMem.bytes, - "gal reserved memory", - gcvTRUE, - &node->VidMem.physical - )); + &node->VidMem.physical)); } - /* Release the mutex. */ - gcmkVERIFY_OK(gckOS_ReleaseMutex(Memory->os, Memory->mutex)); - /* Return the pointer to the node. */ *Node = node; @@ -1839,7 +1837,6 @@ gckVIDMEM_Free( #if gcdCAPTURE_ONLY_MODE gcmkVERIFY_OK(gcmkOS_SAFE_FREE(Kernel->os, Node->VidMem.kvaddr)); #else - gcmkONERROR( gckOS_DestroyKernelMapping(Kernel->os, Node->VidMem.parent->physical, @@ -1925,10 +1922,10 @@ gckVIDMEM_Free( } } - gckOS_QueryOption(memory->os, "allMapInOne", &mappingInOne); + gckOS_QueryOption(Kernel->os, "allMapInOne", &mappingInOne); if (!mappingInOne) { - gckOS_ReleaseReservedMemory(memory->os, Node->VidMem.physical); + gckOS_ReleaseReservedMemoryArea(Node->VidMem.physical); Node->VidMem.physical = gcvNULL; } @@ -2113,9 +2110,6 @@ OnError: ** gctUINT32 * Address ** Pointer to a variable that will hold the hardware specific address. ** -** gctUINT32 * PhysicalAddress -** Pointer to a variable that will hold the bus address of a contiguous -** video node. */ static gceSTATUS gckVIDMEM_Lock( @@ -2139,6 +2133,9 @@ gckVIDMEM_Lock( switch (Node->VidMem.pool) { + case gcvPOOL_LOCAL_EXCLUSIVE: + address = Kernel->exclusiveBaseAddress + offset; + break; case gcvPOOL_LOCAL_EXTERNAL: address = Kernel->externalBaseAddress + offset; break; @@ -2902,6 +2899,7 @@ gckVIDMEM_NODE_Construct( #endif node->node = VideoNode; + node->transitNode = gcvNULL; node->kernel = Kernel; node->type = Type; node->pool = Pool; @@ -2976,11 +2974,21 @@ gckVIDMEM_NODE_AllocateLinear( gceSTATUS status; gctSIZE_T bytes = *Bytes; gcuVIDMEM_NODE_PTR node = gcvNULL; + gcuVIDMEM_NODE_PTR transitNode = gcvNULL; gckVIDMEM_NODE nodeObject = gcvNULL; gcmkHEADER_ARG("Kernel=%p VideoMemory=%p Pool=%d Alignment=%d Type=%d *Bytes=%u", Kernel, VideoMemory, Pool, Alignment, Type, bytes); + /* if it is exclusive pool, update Flag */ + if (Pool == gcvPOOL_LOCAL_EXCLUSIVE) + { + Flag &= ~gcvALLOC_FLAG_CPU_ACCESS; + Flag |= gcvALLOC_FLAG_NON_CPU_ACCESS; + /* insure that is contiguous memory */ + Flag |= gcvALLOC_FLAG_CONTIGUOUS; + } + gcmkONERROR( gckVIDMEM_AllocateLinear(Kernel, VideoMemory, @@ -2999,6 +3007,23 @@ gckVIDMEM_NODE_AllocateLinear( gcmkONERROR( gckVIDMEM_NODE_Construct(Kernel, node, Type, Pool, &nodeObject)); + /* allocate virtual mem for dma */ + if (Pool == gcvPOOL_LOCAL_EXCLUSIVE) + { + status = gckVIDMEM_AllocateVirtual(Kernel, + gcvALLOC_FLAG_CONTIGUOUS, + bytes, + &transitNode); + if (gcmIS_ERROR(status)) + { + gcmkONERROR(gckVIDMEM_AllocateVirtual(Kernel, + gcvALLOC_FLAG_NON_CONTIGUOUS, + bytes, + &transitNode)); + } + nodeObject->transitNode = transitNode; + } + *Bytes = bytes; *NodeObject = nodeObject; @@ -3011,6 +3036,10 @@ OnError: gcmkVERIFY_OK(gckVIDMEM_Free(Kernel, node)); } + if (nodeObject) + { + gckVIDMEM_NODE_Dereference(Kernel, nodeObject); + } gcmkFOOTER(); return status; } @@ -3160,8 +3189,15 @@ gckVIDMEM_NODE_Dereference( gckOS_ReleaseMutex(Kernel->os, Kernel->db->videoMemListMutex)); /* Free gcuVIDMEM_NODE. */ - gcmkVERIFY_OK(gckVIDMEM_Free(Kernel, NodeObject->node)); + if (NodeObject->node) + { + gcmkVERIFY_OK(gckVIDMEM_Free(Kernel, NodeObject->node)); + } + if (NodeObject->transitNode) + { + gcmkVERIFY_OK(gckVIDMEM_Free(Kernel, NodeObject->transitNode)); + } gcmkVERIFY_OK(gckOS_AtomDestroy(Kernel->os, NodeObject->reference)); gcmkVERIFY_OK(gckOS_DeleteMutex(Kernel->os, NodeObject->mutex)); @@ -3451,12 +3487,24 @@ gckVIDMEM_NODE_LockCPU( gceSTATUS status; gckOS os = Kernel->os; gctBOOL acquired = gcvFALSE; - gcuVIDMEM_NODE_PTR node = NodeObject->node; - gckVIDMEM_BLOCK vidMemBlock = node->VirtualChunk.parent; + gcuVIDMEM_NODE_PTR node; + gckVIDMEM_BLOCK vidMemBlock; gctPOINTER logical = gcvNULL; gcmkHEADER_ARG("NodeObject=%p", NodeObject); + if (NodeObject->pool == gcvPOOL_LOCAL_EXCLUSIVE) + { + node = NodeObject->transitNode; + + } + else + { + node = NodeObject->node; + } + + vidMemBlock = node->VirtualChunk.parent; + /* Grab the mutex. */ gcmkONERROR(gckOS_AcquireMutex(os, NodeObject->mutex, gcvINFINITE)); acquired = gcvTRUE; @@ -3601,11 +3649,23 @@ gckVIDMEM_NODE_UnlockCPU( gceSTATUS status; gckOS os = Kernel->os; gctBOOL acquired = gcvFALSE; - gcuVIDMEM_NODE_PTR node = NodeObject->node; - gckVIDMEM_BLOCK vidMemBlock = node->VirtualChunk.parent; + gcuVIDMEM_NODE_PTR node; + gckVIDMEM_BLOCK vidMemBlock; gcmkHEADER_ARG("NodeObject=%p", NodeObject); + if (NodeObject->pool == gcvPOOL_LOCAL_EXCLUSIVE) + { + node = NodeObject->transitNode; + + } + else + { + node = NodeObject->node; + } + + vidMemBlock = node->VirtualChunk.parent; + /* Grab the mutex. */ gcmkONERROR(gckOS_AcquireMutex(os, NodeObject->mutex, gcvINFINITE)); acquired = gcvTRUE; @@ -4638,11 +4698,22 @@ gckVIDMEM_NODE_IsContiguous( gceSTATUS status; gckOS os = Kernel->os; gctBOOL acquired = gcvFALSE; - gcuVIDMEM_NODE_PTR node = NodeObject->node; - gckVIDMEM_BLOCK vidMemBlock = node->VirtualChunk.parent; + gcuVIDMEM_NODE_PTR node; + gckVIDMEM_BLOCK vidMemBlock; gcmkHEADER(); + if (NodeObject->pool == gcvPOOL_LOCAL_EXCLUSIVE) + { + node = NodeObject->transitNode; + } + else + { + node = NodeObject->node; + } + + vidMemBlock = node->VirtualChunk.parent; + /* Grab the mutex. */ gcmkONERROR(gckOS_AcquireMutex(os, NodeObject->mutex, gcvINFINITE)); acquired = gcvTRUE; diff --git a/drivers/amlogic/npu/kernel/inc/gc_feature_database.h b/drivers/amlogic/npu/kernel/inc/gc_feature_database.h index ebd2585..7f7da37 100644 --- a/drivers/amlogic/npu/kernel/inc/gc_feature_database.h +++ b/drivers/amlogic/npu/kernel/inc/gc_feature_database.h @@ -53,7 +53,7 @@ *****************************************************************************/ -/*Auto created on 2020-03-26 14:34*/ +/*Auto created on 2020-06-23 16:44*/ #ifndef _gc_feature_database_h_ #define _gc_feature_database_h_ @@ -75,13 +75,23 @@ typedef struct gctUINT32 NumberOfConstants; gctUINT32 CoreCount; gctUINT32 LocalStorageSize; + gctUINT32 LocalStorageSize_1; + gctUINT32 LocalStorageSize_2; gctUINT32 L1CacheSize; + gctUINT32 L1CacheSize_1; + gctUINT32 L1CacheSize_2; gctUINT32 InstructionMemorySize; gctUINT32 ShaderPCLength; gctUINT32 USC_MAX_PAGES; + gctUINT32 USC_MAX_PAGES_1; + gctUINT32 USC_MAX_PAGES_2; gctUINT32 NumPixelPipes; gctUINT32 USC_CACHE_CONTROLLERS; + gctUINT32 USC_CACHE_CONTROLLERS_1; + gctUINT32 USC_CACHE_CONTROLLERS_2; gctUINT32 USC_BANKS; + gctUINT32 USC_BANKS_1; + gctUINT32 USC_BANKS_2; gctUINT32 Streams; gctUINT32 VaryingCount; gctUINT32 VertexOutputBufferSize; @@ -90,6 +100,7 @@ typedef struct gctUINT32 NumResolvePipes; gctUINT32 RESULT_WINDOW_MAX_SIZE; gctUINT32 ClusterAliveMask; + gctUINT32 G2D_DEC400_MINOR; gctUINT32 NNMadPerCore; gctUINT32 NNCoreCount; gctUINT32 NNCoreCount_INT8; @@ -114,14 +125,26 @@ typedef struct gctUINT32 PHYSICAL_VIP_SRAM_WIDTH_IN_BYTE; gctUINT32 EQUIVALENT_VIP_SRAM_WIDTH_INBYTE; gctUINT32 TP_ZRL_BITS; + gctUINT32 NN_ZRL_BITS; gctUINT32 LATENCY_HIDING_AT_FULL_AXI_BW; gctUINT32 AXI_BUS_WIDTH; gctUINT32 NN_KERNEL_X_SIZE; gctUINT32 NN_KERNEL_Y_SIZE; + gctUINT32 NN_FC_KERNEL_Y_SIZE; gctUINT32 NN_KERNEL_Z_SIZE; gctUINT32 NN_X_OFFSET; gctUINT32 NN_Y_OFFSET; gctUINT32 DDR_KERNEL_BURST_SIZE; + gctUINT32 OUTIMAGE_X_STRIDE_BITS; + gctUINT32 OUTIMAGE_Y_STRIDE_BITS; + gctUINT32 INIMAGE_X_STRIDE_BITS; + gctUINT32 IMIMAGE_Y_STRIDE_BITS; + gctUINT32 OUTIMAGE_X_SIZE_BITS; + gctUINT32 OUTIMAGE_Y_SIZE_BITS; + gctUINT32 OUTIMAGE_SIZE_BITS; + gctUINT32 IMAGE_X_SIZE_BITS; + gctUINT32 INIMAGE_Y_SIZE_BITS; + gctUINT32 MAX_TILE_X_SIZE; gctUINT32 REG_FastClear:1; gctUINT32 REG_SpecialAntiAliasing:1; gctUINT32 REG_Pipe3D:1; @@ -363,6 +386,7 @@ typedef struct gctUINT32 RA_HZEZ_CLOCK_CONTROL:1; gctUINT32 CACHE128B256BPERLINE:1; gctUINT32 V4Compression:1; + gctUINT32 DE2D_MAJOR_SUPER_TILE:1; gctUINT32 PE2D_MAJOR_SUPER_TILE:1; gctUINT32 PE_32BPC_COLORMASK_FIX:1; gctUINT32 ALPHA_BLENDING_OPT:1; @@ -495,6 +519,7 @@ typedef struct gctUINT32 TX_NO_FIXED_FILTER:1; gctUINT32 SHARE_Z:1; gctUINT32 DE_2D_FAST_CLEAR:1; + gctUINT32 DE_TILESTATUS_ROTATION_FIX:1; gctUINT32 TX_CLEAR_PENDING_FIX:1; gctUINT32 NO_HI1_L2:1; gctUINT32 USC_EVICT_CTRL_FIFO_FLOP_RESET_FIX:1; @@ -505,6 +530,13 @@ typedef struct gctUINT32 SH_VX2_FLOATING_MAD_FIX:1; gctUINT32 TS_FC_VULKAN_SUPPORT:1; gctUINT32 MSAA_FLOAT_64BIT:1; + gctUINT32 INDIRECT_COMPUTE_ZERODIM_FIX:1; + gctUINT32 Q_CHANNEL_SUPPORT:1; + gctUINT32 MMU_PAGE_DESCRIPTOR:1; + gctUINT32 YUV_LINEAR_TO_TILE_ROTATE:1; + gctUINT32 VEC2_IMULIMAD32_SUPPORT:1; + gctUINT32 VEC4_IMULIMAD32_SUPPORT:1; + gctUINT32 VEC2_IDIVIMOD16_SUPPORT:1; gctUINT32 VG_TS_CULLING:1; gctUINT32 VG_FP25:1; gctUINT32 VG_AYUV_INPUT_OUTPUT:1; @@ -531,6 +563,20 @@ typedef struct gctUINT32 DC_MMU:1; gctUINT32 DC_COMPRESSION:1; gctUINT32 DC_QOS:1; + gctUINT32 VIP_HW_FINAL_RELEASE:1; + gctUINT32 NN_SINGLEPORT_ACCUMBUFFER:1; + gctUINT32 NN_STRIDE_SUPPORT:1; + gctUINT32 SWTILING_PHASE1:1; + gctUINT32 SWTILING_PHASE2:1; + gctUINT32 TP_SIMPLE_INT16:1; + gctUINT32 TP_REAL_INT16:1; + gctUINT32 TP_ROI_POOLING:1; + gctUINT32 TP_MAX_POOLING_STRIDE1:1; + gctUINT32 TP_LRN:1; + gctUINT32 TP_REORDER:1; + gctUINT32 TF_QUANTIZATION:1; + gctUINT32 NN_NONZERO_BORDER:1; + gctUINT32 NN_MIRROR_BORDER:1; gctUINT32 AI_GPU:1; gctUINT32 EVIS_NO_ABSDIFF:1; gctUINT32 EVIS_NO_BITREPLACE:1; @@ -543,132 +589,143 @@ typedef struct gctUINT32 EVIS_LERP_7OUTPUT:1; gctUINT32 EVIS_ACCSQ_8OUTPUT:1; gctUINT32 EVIS_VX2:1; - gctUINT32 NN_FLOAT:1; gctUINT32 TP_ENGINE:1; gctUINT32 VIP_V7:1; - gctUINT32 MCFE:1; - gctUINT32 NN_INTERLEVE8:1; - gctUINT32 TP_REORDER:1; - gctUINT32 TP_LRN:1; - gctUINT32 TP_MAX_POOLING_STRIDE1:1; - gctUINT32 NN_FP16_ALU:1; - gctUINT32 NN_INT16_ALU:1; - gctUINT32 TP_ROI_POOLING:1; - gctUINT32 NN_ZDP3:1; + gctUINT32 TP_TENSOR_ADD_MUL:1; + gctUINT32 NN_DEPTHWISE_INT16XINT8:1; + gctUINT32 TP_SOFTMAX:1; + gctUINT32 NN_23BITS_POST_MULTIPLIER_VIP_V7:1; + gctUINT32 TP_23BITS_POST_MULTIPLIER_VIP_V7:1; + gctUINT32 HYBRID_MODE_VIP_V7:1; gctUINT32 NN_ZDP6:1; gctUINT32 NN_XYDP9:1; - gctUINT32 NN_INT8_SCALE:1; - gctUINT32 NN_POWER_ISOLATION:1; - gctUINT32 SWTILING_PHASE1:1; - gctUINT32 TF_QUANTIZATION:1; - gctUINT32 TP_SIMPLE_INT16:1; - gctUINT32 TP_REAL_INT16:1; - gctUINT32 TP_BFLOAT16:1; gctUINT32 NN_FIRST_PIXEL_POOLING:1; - gctUINT32 SWTILING_PHASE2:1; - gctUINT32 NN_STRIDE_SUPPORT:1; + gctUINT32 NN_ZDP3:1; gctUINT32 NN_XYDP6:1; - gctUINT32 TP_REORDER_FIX:1; - gctUINT32 NN_CONV1x1_PERF_FIX:1; - gctUINT32 NN_CACHELINE_MODE_PERF_FIX:1; - gctUINT32 NN_PER3DTILE_BUBBLE_FIX:1; - gctUINT32 NN_CONVOUT_FIFO_DEPTH_FIX:1; gctUINT32 SWTILING_PHASE3:1; + gctUINT32 MCFE:1; gctUINT32 USC_STAY_LRU:1; - gctUINT32 NN_NONZERO_MIRROR_BORDER:1; + gctUINT32 COEF_COMPRESSION_ENHANCEMENT:1; + gctUINT32 TP_COEF_COMPRESSION_ENHANCEMENT:1; gctUINT32 NN_COEF_DECOMPRESS_PERF2X:1; + gctUINT32 OCB_COUNTER:1; + gctUINT32 SCALER:1; + gctUINT32 SCALER_4K:1; gctUINT32 INPUT_4BIT:1; - gctUINT32 COEF_COMPRESSION_ENHANCEMENT:1; + gctUINT32 NN_NO_Z_LOCATION_OFFSET:1; + gctUINT32 OCB_REMAP_PHYSICAL_ADDRESS:1; + gctUINT32 NN_SLOW_OUTPUT:1; + gctUINT32 NO_NARROW_POST_PROCESS_PIPE:1; + gctUINT32 TP_NN_PROBE:1; + gctUINT32 NN_DEPTHWISE_SUPPORT:1; + gctUINT32 NN_XYDP0:1; + gctUINT32 NN_WRITE_WITHOUT_USC:1; + gctUINT32 NN_HW_LIMITATION_NATIVE_KER_1x2_2x1:1; + gctUINT32 NN_SLICE_PADDING_TO_64BYTE_ALIGN:1; + gctUINT32 NN_DW_1x1_CONV_MERGE:1; + gctUINT32 TP_BFLOAT16:1; + gctUINT32 TP_23BITS_POST_MULTIPLIER:1; + gctUINT32 NN_TRANSPOSE:1; + gctUINT32 USE_SINGLE_PORT_VIPSRAM:1; + gctUINT32 NN_LEAKY_RELU:1; + gctUINT32 NN_PRELU:1; + gctUINT32 NN_PER_CHANNEL_QUANT:1; + gctUINT32 NN_PER_CHANNEL_QUANT_ASYM:1; + gctUINT32 NN_ASYMMETRIC_INT8:1; + gctUINT32 NN_FLOAT_POST_MULT:1; + gctUINT32 PRELU_LEAKLY_RELU_CLAMP:1; + gctUINT32 TPLITE_BFLOAT16:1; + gctUINT32 PREPROCESS_IMG_BUF_640BYTE_LIMIT:1; + gctUINT32 TP_KERNEL_1BYTE_ALGIN:1; + gctUINT32 BFLOAT_COEF_COMPRESSION_ZERO_COEFBIT14_INVERSE:1; + gctUINT32 NN_COMPRESSION_BYPASSS:1; + gctUINT32 TP_3_USC:1; + gctUINT32 BFP_COEF_AUTO_PAD_INCOMPLETE_ZERO_IN_KZ_PLANE:1; + gctUINT32 NN_NATIVE_STRIDE_TWO:1; + gctUINT32 NN_TENSOR_ADD:1; + gctUINT32 NN_FLOAT32_IO:1; + gctUINT32 TP_FLOAT32_IO:1; + gctUINT32 NN_SMALL_BATCH_PHASE2:1; + gctUINT32 TILE_ACCESS_CAPABILITY:1; + gctUINT32 FAST_DP3_PREPROCESSOR:1; + gctUINT32 DEPTHWISE_SUPPORT_16BIT_FORMAT:1; + gctUINT32 NN_SUPPORT_ALU_LUT:1; + gctUINT32 NN_ENHANCED_MAX_POOLING:1; + gctUINT32 NN_TRANSPOSE_PHASE2:1; + gctUINT32 TPLITE_SUPPORT_TP_DATA_TRANSPOSE:1; + gctUINT32 NN_SUPPORT_CONV_1D:1; + gctUINT32 USE_VIPSRAM_FOR_KERNEL_STREAMING:1; + gctUINT32 VIP_DEC400:1; + gctUINT32 NN_PER3DTILE_BUBBLE_FIX:1; + gctUINT32 NN_CACHELINE_MODE_PERF_FIX:1; + gctUINT32 NN_CONV1x1_PERF_FIX:1; + gctUINT32 TP_REORDER_FIX:1; + gctUINT32 NN_CONVOUT_FIFO_DEPTH_FIX:1; gctUINT32 NN_ZXDP3_KERNEL_READ_CONFLICT_FIX:1; gctUINT32 NN_ZDP3_NO_COMPRESS_FIX:1; gctUINT32 NN_ASYNC_COPY_PERF_FIX:1; - gctUINT32 OCB_COUNTER:1; - gctUINT32 NN_XYDP0:1; - gctUINT32 ZRL_7BIT:1; + gctUINT32 HI_REORDER_FIX:1; + gctUINT32 INCORRECT_WR_REQ_TO_USC_BETWEEN_REORDER_AND_NORMAL_LAYER_FIX:1; + gctUINT32 TP_REORDER_LAYER_SUSPEND_FIX:1; gctUINT32 NN_ASYNC_COPY_MERGE_FIX:1; - gctUINT32 NN_SMALLBATCH_PHASE1:1; - gctUINT32 TP_SMALLBATCH_PHASE1:1; - gctUINT32 SCALER:1; - gctUINT32 SCALER_4K:1; + gctUINT32 USC_INVALIDATE_CACHE_LINE_FIX:1; gctUINT32 NN_REQ_SLOWARBITRATION_FIX:1; - gctUINT32 IMAGE_PARTIAL_CACHE:1; + gctUINT32 IMAGE_PARTIAL_CACHE_FIX:1; gctUINT32 FULLCACHE_KERNELHEAD_FIX:1; - gctUINT32 NN_SINGLEPORT_ACCUMBUFFER:1; - gctUINT32 NN_SMALLBATCH:1; - gctUINT32 TP_SMALLBATCH:1; - gctUINT32 ZRL_8BIT:1; - gctUINT32 NN_DEPTHWISE_SUPPORT:1; - gctUINT32 NN_WRITE_WITHOUT_USC:1; gctUINT32 NN_ZDP_INIMAGE_SIZE_FIX:1; - gctUINT32 HI_REORDER_FIX:1; - gctUINT32 INCORRECT_WR_REQ_TO_USC_BETWEEN_REORDER_AND_NORMAL_LAYER_FIX:1; - gctUINT32 TP_COEF_COMPRESSION_ENHANCEMENT:1; - gctUINT32 VIP_DEC400:1; - gctUINT32 IMAGE_NOT_PACKED_IN_SRAM_FIX:1; gctUINT32 IDLE_BEFORE_FLUSH_COMPLETE_FIX:1; gctUINT32 NO_FLUSH_USC_FIX:1; + gctUINT32 SMALL_BATCH_FLOPS_RESET_FIX:1; + gctUINT32 SMALL_BATCH_DISBLE_FIX:1; + gctUINT32 OUTPUT_CONVERT_UINT8_INT8_TO_UINT16_INT16_FIX:1; + gctUINT32 IMAGE_NOT_PACKED_IN_SRAM_FIX:1; gctUINT32 COEF_DELTA_CORD_OVERFLOW_ZRL_8BIT_FIX:1; - gctUINT32 XY_OFFSET_LIMITATION_FIX:1; - gctUINT32 USC_INVALIDATE_CACHE_LINE_FIX:1; gctUINT32 LOW_EFFICIENCY_OF_ID_WRITE_IMGBUF_FIX:1; - gctUINT32 KERNEL_PER_CORE_LESS_THAN_THIRD_COEF_BUFF_DEPTH_FIX:1; + gctUINT32 KERNEL_VIP_SRAM_READ_BW_LIMITATION_FIX:1; gctUINT32 USC_BOTTLENECK_FIX:1; + gctUINT32 KERNEL_PER_CORE_LESS_THAN_THIRD_COEF_BUFF_DEPTH_FIX:1; gctUINT32 KERNEL_SIZE_WASTE_IN_PARTIAL_MODE_FIX:1; - gctUINT32 FULLCACHE_KERNEL_INTERLEAVE_FIX:1; - gctUINT32 TP_REORDER_LAYER_SUSPEND_FIX:1; - gctUINT32 KERNEL_VIP_SRAM_READ_BW_LIMITATION_FIX:1; + gctUINT32 NN_COMMAND_KERNEL_REQUEST_CONFICT_FIX:1; + gctUINT32 TP_REORDER_INTILE_X_SIZE_512_FIX:1; gctUINT32 IMG_POP_PIPELINE_PAUSE_FIX:1; + gctUINT32 FULLCACHE_KERNEL_INTERLEAVE_FIX:1; + gctUINT32 V8_SINGLE_PORT_ACCUMULATION_BUFFER_RW_CONFICT_ZERO_SKIP_PERF_FIX:1; + gctUINT32 V8_ACCUMLATION_READ_OUT_HAS_BUBBLES_PERF_FIX:1; + gctUINT32 DEPTHWISE_NEIGHBOR_IMG_DATA_TRANSFER_NOT_EFFICIENT_FIX:1; gctUINT32 DR_JD_DIFF_CONDITION_FOR_CACHELINE_MODE_PRE_FIX:1; - gctUINT32 OUTIMAGE_X_BITWIDTH_LIMIT_FOR_NN_TRANSPOSE_FIX:1; - gctUINT32 SMALL_BATCH_FLOPS_RESET_FIX:1; - gctUINT32 SMALL_BATCH_DISBLE_FIX:1; - gctUINT32 NEGATIVE_POST_SHIFT_FIX:1; - gctUINT32 NN_COMMAND_KERNEL_REQUEST_CONFICT_FIX:1; - gctUINT32 OCB_REMAP_PHYSICAL_ADDRESS:1; - gctUINT32 NN_NO_Z_LOCATION_OFFSET:1; - gctUINT32 NN_LEAKY_RELU:1; - gctUINT32 NN_PRELU:1; - gctUINT32 NN_PER_CHANNEL_QUANT:1; - gctUINT32 NN_PER_CHANNEL_QUANT_ASYM:1; - gctUINT32 NN_NATIVE_STRIDE_TWO:1; - gctUINT32 NN_TENSOR_ADD:1; - gctUINT32 NN_FLOAT_POST_MULT:1; - gctUINT32 NN_SLICE_PADDING_TO_64BYTE_ALIGN:1; - gctUINT32 NN_DW_1x1_CONV_MERGE:1; - gctUINT32 NN_SLOW_OUTPUT:1; - gctUINT32 NO_NARROW_POST_PROCESS_PIPE:1; - gctUINT32 TP_NN_PROBE:1; - gctUINT32 TP_23BITS_POST_MULTIPLIER:1; - gctUINT32 NN_TRANSPOSE:1; + gctUINT32 TP_ACCESS_VIPSRAM_OT_IS_ONE_FIX:1; gctUINT32 EVIS2_FLOP_RESET_FIX:1; + gctUINT32 OUTIMAGE_X_BITWIDTH_LIMIT_FOR_NN_TRANSPOSE_FIX:1; gctUINT32 USC_ASYNC_CP_RTN_FLOP_RESET_FIX:1; - gctUINT32 DDR_BURST_LEN_256B:1; + gctUINT32 IMG_ADDR_NOT_WRAP_IF_OVER_OCB_ADDR_FIX:1; + gctUINT32 NEGATIVE_POST_SHIFT_FIX:1; + gctUINT32 INIMAGE_2DTILE_NOT_LESS_160PIXEL_FIX:1; gctUINT32 IMG_CAHCE_MODE_MUST_0_IN_IMG_DIRECT_MODE_FIX:1; - gctUINT32 USE_SINGLE_PORT_VIPSRAM:1; - gctUINT32 NN_ASYMMETRIC_INT8:1; - gctUINT32 DEPTHWISE_NEIGHBOR_IMG_DATA_TRANSFER_NOT_EFFICIENT_FIX:1; - gctUINT32 PRELU_LEAKLY_RELU_CLAMP:1; - gctUINT32 TP_FLOAT32_IO:1; - gctUINT32 NN_FLOAT32_IO:1; - gctUINT32 NN_SMALL_BATCH_PHASE2:1; - gctUINT32 TILE_ACCESS_CAPABILITY:1; - gctUINT32 FAST_DP3_PREPROCESSOR:1; - gctUINT32 NN_COMPRESSION_BYPASSS:1; - gctUINT32 BFLOAT_KERNEL_COMPRESSION_ZERO_SKIP_FIX:1; - gctUINT32 TP_3_USC:1; - gctUINT32 TP_KERNEL_1BYTE_ALGIN:1; - gctUINT32 TPLITE_BFLOAT16:1; - gctUINT32 PREPROCESS_IMG_BUF_640BYTE_LIMIT:1; - gctUINT32 V8_ACCUMLATION_READ_OUT_HAS_BUBBLES_PERF_FIX:1; - gctUINT32 V8_SINGLE_PORT_ACCUMULATION_BUFFER_RW_CONFICT_ZERO_SKIP_PERF_FIX:1; gctUINT32 BURST_COLLECT_DUMMY_DATA_WASTE_CYCLES_FIX:1; gctUINT32 INIMG_NOT_64BYTE_ALIGN_CACHELINE_MODE_FIX:1; - gctUINT32 TP_ACCESS_VIPSRAM_OT_IS_ONE_FIX:1; - gctUINT32 VIP_HW_FINAL_RELEASE:1; + gctUINT32 TP_FC_FLOAT_LAST_PIXEL_NEGATIVE_0_FIX:1; + gctUINT32 NN_WASET_COEF_READ_WRITE_BANDWIDTH_128BYTE_VIPSRAM_IN_FULL_PATIAL_CACHE_MODE:1; + gctUINT32 NN_IN_TILE_DATA_IS_ALL_PAD_FIX:1; + gctUINT32 TP_FC_KERNEL_STREAM_MUST_LESS_THAN_OR_EQUAL_TO_64BYTE_WHEN_1BYTE_ALGINE_FIX:1; + gctUINT32 NN_INTERLEVE8:1; + gctUINT32 NN_FP16_ALU:1; + gctUINT32 NN_INT16_ALU:1; + gctUINT32 NN_INT8_SCALE:1; + gctUINT32 NN_POWER_ISOLATION:1; + gctUINT32 ZRL_7BIT:1; + gctUINT32 NN_SMALLBATCH_PHASE1:1; + gctUINT32 TP_SMALLBATCH_PHASE1:1; + gctUINT32 NN_SMALLBATCH:1; + gctUINT32 TP_SMALLBATCH:1; + gctUINT32 ZRL_8BIT:1; + gctUINT32 DDR_BURST_LEN_256B:1; + gctUINT32 XY_OFFSET_LIMITATION_FIX:1; + gctUINT32 NN_NONZERO_MIRROR_BORDER:1; + gctUINT32 IMAGE_PARTIAL_CACHE:1; } gcsFEATURE_DATABASE; -#define FEATURE_BIT_START 63 -#define FEATURE_BIT_END 605 +#define FEATURE_BIT_START 86 +#define FEATURE_BIT_END 662 static gcsFEATURE_DATABASE gChipInfo[] = { /* vipnano-qi */ { @@ -687,13 +744,23 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x140, /* gcFEATURE_VALUE_NumberOfConstants */ 0x1, /* gcFEATURE_VALUE_CoreCount */ 0x10, /* gcFEATURE_VALUE_LocalStorageSize */ + 0x0, /* gcFEATURE_VALUE_LocalStorageSize_1 */ + 0x0, /* gcFEATURE_VALUE_LocalStorageSize_2 */ 0x10, /* gcFEATURE_VALUE_L1CacheSize */ + 0x0, /* gcFEATURE_VALUE_L1CacheSize_1 */ + 0x0, /* gcFEATURE_VALUE_L1CacheSize_2 */ 0x200, /* gcFEATURE_VALUE_InstructionMemorySize */ 0x14, /* gcFEATURE_VALUE_ShaderPCLength */ 0x10, /* gcFEATURE_VALUE_USC_MAX_PAGES */ + 0x0, /* gcFEATURE_VALUE_USC_MAX_PAGES_1 */ + 0x0, /* gcFEATURE_VALUE_USC_MAX_PAGES_2 */ 0x1, /* gcFEATURE_VALUE_NumPixelPipes */ 0x2, /* gcFEATURE_VALUE_USC_CACHE_CONTROLLERS */ + 0x0, /* gcFEATURE_VALUE_USC_CACHE_CONTROLLERS_1 */ + 0x0, /* gcFEATURE_VALUE_USC_CACHE_CONTROLLERS_2 */ 0x2, /* gcFEATURE_VALUE_USC_BANKS */ + 0x0, /* gcFEATURE_VALUE_USC_BANKS_1 */ + 0x0, /* gcFEATURE_VALUE_USC_BANKS_2 */ 0x8, /* gcFEATURE_VALUE_Streams */ 0x10, /* gcFEATURE_VALUE_VaryingCount */ 0x400, /* gcFEATURE_VALUE_VertexOutputBufferSize */ @@ -702,6 +769,7 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_VALUE_NumResolvePipes */ 0x100, /* gcFEATURE_VALUE_RESULT_WINDOW_MAX_SIZE */ 0x0, /* gcFEATURE_VALUE_ClusterAliveMask */ + 0x0, /* gcFEATURE_VALUE_G2D_DEC400_MINOR */ 0x40, /* gcFEATURE_VALUE_NNMadPerCore */ 0x8, /* gcFEATURE_VALUE_NNCoreCount */ 0x8, /* gcFEATURE_VALUE_NNCoreCount_INT8 */ @@ -726,14 +794,26 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x20, /* gcFEATURE_VALUE_PHYSICAL_VIP_SRAM_WIDTH_IN_BYTE */ 0x10, /* gcFEATURE_VALUE_EQUIVALENT_VIP_SRAM_WIDTH_INBYTE */ 0x8, /* gcFEATURE_VALUE_TP_ZRL_BITS */ + 0x5, /* gcFEATURE_VALUE_NN_ZRL_BITS */ 0x80, /* gcFEATURE_VALUE_LATENCY_HIDING_AT_FULL_AXI_BW */ 0x10, /* gcFEATURE_VALUE_AXI_BUS_WIDTH */ 0xf, /* gcFEATURE_VALUE_NN_KERNEL_X_SIZE */ 0xf, /* gcFEATURE_VALUE_NN_KERNEL_Y_SIZE */ + 0xf, /* gcFEATURE_VALUE_NN_FC_KERNEL_Y_SIZE */ 0xfffff, /* gcFEATURE_VALUE_NN_KERNEL_Z_SIZE */ 0x7, /* gcFEATURE_VALUE_NN_X_OFFSET */ 0x7, /* gcFEATURE_VALUE_NN_Y_OFFSET */ 0x40, /* gcFEATURE_VALUE_DDR_KERNEL_BURST_SIZE */ + 0x10, /* gcFEATURE_VALUE_OUTIMAGE_X_STRIDE_BITS */ + 0x0, /* gcFEATURE_VALUE_OUTIMAGE_Y_STRIDE_BITS */ + 0x10, /* gcFEATURE_VALUE_INIMAGE_X_STRIDE_BITS */ + 0x10, /* gcFEATURE_VALUE_IMIMAGE_Y_STRIDE_BITS */ + 0xd, /* gcFEATURE_VALUE_OUTIMAGE_X_SIZE_BITS */ + 0xd, /* gcFEATURE_VALUE_OUTIMAGE_Y_SIZE_BITS */ + 0xe, /* gcFEATURE_VALUE_OUTIMAGE_SIZE_BITS */ + 0xd, /* gcFEATURE_VALUE_IMAGE_X_SIZE_BITS */ + 0xd, /* gcFEATURE_VALUE_INIMAGE_Y_SIZE_BITS */ + 0x40, /* gcFEATURE_VALUE_MAX_TILE_X_SIZE */ 0x0, /* gcFEATURE_BIT_REG_FastClear */ 0x0, /* gcFEATURE_BIT_REG_SpecialAntiAliasing */ 0x1, /* gcFEATURE_BIT_REG_Pipe3D */ @@ -975,6 +1055,7 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x1, /* gcFEATURE_BIT_RA_HZEZ_CLOCK_CONTROL */ 0x1, /* gcFEATURE_BIT_CACHE128B256BPERLINE */ 0x1, /* gcFEATURE_BIT_V4Compression */ + 0x0, /* gcFEATURE_BIT_DE2D_MAJOR_SUPER_TILE */ 0x0, /* gcFEATURE_BIT_PE2D_MAJOR_SUPER_TILE */ 0x1, /* gcFEATURE_BIT_PE_32BPC_COLORMASK_FIX */ 0x1, /* gcFEATURE_BIT_ALPHA_BLENDING_OPT */ @@ -1107,6 +1188,7 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_BIT_TX_NO_FIXED_FILTER */ 0x0, /* gcFEATURE_BIT_SHARE_Z */ 0x0, /* gcFEATURE_BIT_DE_2D_FAST_CLEAR */ + 0x0, /* gcFEATURE_BIT_DE_TILESTATUS_ROTATION_FIX */ 0x0, /* gcFEATURE_BIT_TX_CLEAR_PENDING_FIX */ 0x0, /* gcFEATURE_BIT_NO_HI1_L2 */ 0x0, /* gcFEATURE_BIT_USC_EVICT_CTRL_FIFO_FLOP_RESET_FIX */ @@ -1117,6 +1199,13 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_BIT_SH_VX2_FLOATING_MAD_FIX */ 0x0, /* gcFEATURE_BIT_TS_FC_VULKAN_SUPPORT */ 0x0, /* gcFEATURE_BIT_MSAA_FLOAT_64BIT */ + 0x0, /* gcFEATURE_BIT_INDIRECT_COMPUTE_ZERODIM_FIX */ + 0x0, /* gcFEATURE_BIT_Q_CHANNEL_SUPPORT */ + 0x0, /* gcFEATURE_BIT_MMU_PAGE_DESCRIPTOR */ + 0x0, /* gcFEATURE_BIT_YUV_LINEAR_TO_TILE_ROTATE */ + 0x0, /* gcFEATURE_BIT_VEC2_IMULIMAD32_SUPPORT */ + 0x0, /* gcFEATURE_BIT_VEC4_IMULIMAD32_SUPPORT */ + 0x0, /* gcFEATURE_BIT_VEC2_IDIVIMOD16_SUPPORT */ 0x0, /* gcFEATURE_BIT_VG_TS_CULLING */ 0x0, /* gcFEATURE_BIT_VG_FP25 */ 0x0, /* gcFEATURE_BIT_VG_AYUV_INPUT_OUTPUT */ @@ -1143,6 +1232,20 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_BIT_DC_MMU */ 0x0, /* gcFEATURE_BIT_DC_COMPRESSION */ 0x0, /* gcFEATURE_BIT_DC_QOS */ + 0x1, /* gcFEATURE_BIT_VIP_HW_FINAL_RELEASE */ + 0x1, /* gcFEATURE_BIT_NN_SINGLEPORT_ACCUMBUFFER */ + 0x1, /* gcFEATURE_BIT_NN_STRIDE_SUPPORT */ + 0x1, /* gcFEATURE_BIT_SWTILING_PHASE1 */ + 0x0, /* gcFEATURE_BIT_SWTILING_PHASE2 */ + 0x1, /* gcFEATURE_BIT_TP_SIMPLE_INT16 */ + 0x0, /* gcFEATURE_BIT_TP_REAL_INT16 */ + 0x1, /* gcFEATURE_BIT_TP_ROI_POOLING */ + 0x1, /* gcFEATURE_BIT_TP_MAX_POOLING_STRIDE1 */ + 0x1, /* gcFEATURE_BIT_TP_LRN */ + 0x1, /* gcFEATURE_BIT_TP_REORDER */ + 0x1, /* gcFEATURE_BIT_TF_QUANTIZATION */ + 0x0, /* gcFEATURE_BIT_NN_NONZERO_BORDER */ + 0x0, /* gcFEATURE_BIT_NN_MIRROR_BORDER */ 0x0, /* gcFEATURE_BIT_AI_GPU */ 0x0, /* gcFEATURE_BIT_EVIS_NO_ABSDIFF */ 0x0, /* gcFEATURE_BIT_EVIS_NO_BITREPLACE */ @@ -1155,128 +1258,139 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_BIT_EVIS_LERP_7OUTPUT */ 0x0, /* gcFEATURE_BIT_EVIS_ACCSQ_8OUTPUT */ 0x1, /* gcFEATURE_BIT_EVIS_VX2 */ - 0x1, /* gcFEATURE_BIT_NN_FLOAT */ 0x1, /* gcFEATURE_BIT_TP_ENGINE */ 0x1, /* gcFEATURE_BIT_VIP_V7 */ - 0x0, /* gcFEATURE_BIT_MCFE */ - 0x0, /* gcFEATURE_BIT_NN_INTERLEVE8 */ - 0x1, /* gcFEATURE_BIT_TP_REORDER */ - 0x1, /* gcFEATURE_BIT_TP_LRN */ - 0x1, /* gcFEATURE_BIT_TP_MAX_POOLING_STRIDE1 */ - 0x0, /* gcFEATURE_BIT_NN_FP16_ALU */ - 0x1, /* gcFEATURE_BIT_NN_INT16_ALU */ - 0x1, /* gcFEATURE_BIT_TP_ROI_POOLING */ - 0x0, /* gcFEATURE_BIT_NN_ZDP3 */ + 0x0, /* gcFEATURE_BIT_TP_TENSOR_ADD_MUL */ + 0x0, /* gcFEATURE_BIT_NN_DEPTHWISE_INT16XINT8 */ + 0x0, /* gcFEATURE_BIT_TP_SOFTMAX */ + 0x0, /* gcFEATURE_BIT_NN_23BITS_POST_MULTIPLIER_VIP_V7 */ + 0x0, /* gcFEATURE_BIT_TP_23BITS_POST_MULTIPLIER_VIP_V7 */ + 0x0, /* gcFEATURE_BIT_HYBRID_MODE_VIP_V7 */ 0x0, /* gcFEATURE_BIT_NN_ZDP6 */ 0x0, /* gcFEATURE_BIT_NN_XYDP9 */ - 0x1, /* gcFEATURE_BIT_NN_INT8_SCALE */ - 0x1, /* gcFEATURE_BIT_NN_POWER_ISOLATION */ - 0x1, /* gcFEATURE_BIT_SWTILING_PHASE1 */ - 0x1, /* gcFEATURE_BIT_TF_QUANTIZATION */ - 0x1, /* gcFEATURE_BIT_TP_SIMPLE_INT16 */ - 0x0, /* gcFEATURE_BIT_TP_REAL_INT16 */ - 0x0, /* gcFEATURE_BIT_TP_BFLOAT16 */ 0x0, /* gcFEATURE_BIT_NN_FIRST_PIXEL_POOLING */ - 0x0, /* gcFEATURE_BIT_SWTILING_PHASE2 */ - 0x1, /* gcFEATURE_BIT_NN_STRIDE_SUPPORT */ + 0x0, /* gcFEATURE_BIT_NN_ZDP3 */ 0x0, /* gcFEATURE_BIT_NN_XYDP6 */ - 0x1, /* gcFEATURE_BIT_TP_REORDER_FIX */ - 0x0, /* gcFEATURE_BIT_NN_CONV1x1_PERF_FIX */ - 0x0, /* gcFEATURE_BIT_NN_CACHELINE_MODE_PERF_FIX */ - 0x0, /* gcFEATURE_BIT_NN_PER3DTILE_BUBBLE_FIX */ - 0x0, /* gcFEATURE_BIT_NN_CONVOUT_FIFO_DEPTH_FIX */ 0x0, /* gcFEATURE_BIT_SWTILING_PHASE3 */ + 0x0, /* gcFEATURE_BIT_MCFE */ 0x0, /* gcFEATURE_BIT_USC_STAY_LRU */ - 0x0, /* gcFEATURE_BIT_NN_NONZERO_MIRROR_BORDER */ - 0x0, /* gcFEATURE_BIT_NN_COEF_DECOMPRESS_PERF2X */ - 0x0, /* gcFEATURE_BIT_INPUT_4BIT */ 0x0, /* gcFEATURE_BIT_COEF_COMPRESSION_ENHANCEMENT */ - 0x1, /* gcFEATURE_BIT_NN_ZXDP3_KERNEL_READ_CONFLICT_FIX */ - 0x0, /* gcFEATURE_BIT_NN_ZDP3_NO_COMPRESS_FIX */ - 0x0, /* gcFEATURE_BIT_NN_ASYNC_COPY_PERF_FIX */ + 0x0, /* gcFEATURE_BIT_TP_COEF_COMPRESSION_ENHANCEMENT */ + 0x0, /* gcFEATURE_BIT_NN_COEF_DECOMPRESS_PERF2X */ 0x1, /* gcFEATURE_BIT_OCB_COUNTER */ - 0x0, /* gcFEATURE_BIT_NN_XYDP0 */ - 0x0, /* gcFEATURE_BIT_ZRL_7BIT */ - 0x0, /* gcFEATURE_BIT_NN_ASYNC_COPY_MERGE_FIX */ - 0x0, /* gcFEATURE_BIT_NN_SMALLBATCH_PHASE1 */ - 0x0, /* gcFEATURE_BIT_TP_SMALLBATCH_PHASE1 */ 0x0, /* gcFEATURE_BIT_SCALER */ 0x0, /* gcFEATURE_BIT_SCALER_4K */ - 0x0, /* gcFEATURE_BIT_NN_REQ_SLOWARBITRATION_FIX */ - 0x0, /* gcFEATURE_BIT_IMAGE_PARTIAL_CACHE */ - 0x0, /* gcFEATURE_BIT_FULLCACHE_KERNELHEAD_FIX */ - 0x1, /* gcFEATURE_BIT_NN_SINGLEPORT_ACCUMBUFFER */ - 0x0, /* gcFEATURE_BIT_NN_SMALLBATCH */ - 0x0, /* gcFEATURE_BIT_TP_SMALLBATCH */ - 0x0, /* gcFEATURE_BIT_ZRL_8BIT */ + 0x0, /* gcFEATURE_BIT_INPUT_4BIT */ + 0x0, /* gcFEATURE_BIT_NN_NO_Z_LOCATION_OFFSET */ + 0x1, /* gcFEATURE_BIT_OCB_REMAP_PHYSICAL_ADDRESS */ + 0x0, /* gcFEATURE_BIT_NN_SLOW_OUTPUT */ + 0x1, /* gcFEATURE_BIT_NO_NARROW_POST_PROCESS_PIPE */ + 0x0, /* gcFEATURE_BIT_TP_NN_PROBE */ 0x0, /* gcFEATURE_BIT_NN_DEPTHWISE_SUPPORT */ + 0x0, /* gcFEATURE_BIT_NN_XYDP0 */ 0x0, /* gcFEATURE_BIT_NN_WRITE_WITHOUT_USC */ - 0x0, /* gcFEATURE_BIT_NN_ZDP_INIMAGE_SIZE_FIX */ - 0x0, /* gcFEATURE_BIT_HI_REORDER_FIX */ - 0x0, /* gcFEATURE_BIT_INCORRECT_WR_REQ_TO_USC_BETWEEN_REORDER_AND_NORMAL_LAYER_FIX */ - 0x0, /* gcFEATURE_BIT_TP_COEF_COMPRESSION_ENHANCEMENT */ - 0x0, /* gcFEATURE_BIT_VIP_DEC400 */ - 0x0, /* gcFEATURE_BIT_IMAGE_NOT_PACKED_IN_SRAM_FIX */ - 0x0, /* gcFEATURE_BIT_IDLE_BEFORE_FLUSH_COMPLETE_FIX */ - 0x1, /* gcFEATURE_BIT_NO_FLUSH_USC_FIX */ - 0x1, /* gcFEATURE_BIT_COEF_DELTA_CORD_OVERFLOW_ZRL_8BIT_FIX */ - 0x0, /* gcFEATURE_BIT_XY_OFFSET_LIMITATION_FIX */ - 0x0, /* gcFEATURE_BIT_USC_INVALIDATE_CACHE_LINE_FIX */ - 0x0, /* gcFEATURE_BIT_LOW_EFFICIENCY_OF_ID_WRITE_IMGBUF_FIX */ - 0x1, /* gcFEATURE_BIT_KERNEL_PER_CORE_LESS_THAN_THIRD_COEF_BUFF_DEPTH_FIX */ - 0x0, /* gcFEATURE_BIT_USC_BOTTLENECK_FIX */ - 0x0, /* gcFEATURE_BIT_KERNEL_SIZE_WASTE_IN_PARTIAL_MODE_FIX */ - 0x0, /* gcFEATURE_BIT_FULLCACHE_KERNEL_INTERLEAVE_FIX */ - 0x0, /* gcFEATURE_BIT_TP_REORDER_LAYER_SUSPEND_FIX */ - 0x1, /* gcFEATURE_BIT_KERNEL_VIP_SRAM_READ_BW_LIMITATION_FIX */ - 0x1, /* gcFEATURE_BIT_IMG_POP_PIPELINE_PAUSE_FIX */ - 0x0, /* gcFEATURE_BIT_DR_JD_DIFF_CONDITION_FOR_CACHELINE_MODE_PRE_FIX */ - 0x1, /* gcFEATURE_BIT_OUTIMAGE_X_BITWIDTH_LIMIT_FOR_NN_TRANSPOSE_FIX */ - 0x1, /* gcFEATURE_BIT_SMALL_BATCH_FLOPS_RESET_FIX */ - 0x0, /* gcFEATURE_BIT_SMALL_BATCH_DISBLE_FIX */ - 0x1, /* gcFEATURE_BIT_NEGATIVE_POST_SHIFT_FIX */ - 0x0, /* gcFEATURE_BIT_NN_COMMAND_KERNEL_REQUEST_CONFICT_FIX */ - 0x1, /* gcFEATURE_BIT_OCB_REMAP_PHYSICAL_ADDRESS */ - 0x0, /* gcFEATURE_BIT_NN_NO_Z_LOCATION_OFFSET */ - 0x0, /* gcFEATURE_BIT_NN_LEAKY_RELU */ - 0x0, /* gcFEATURE_BIT_NN_PRELU */ - 0x0, /* gcFEATURE_BIT_NN_PER_CHANNEL_QUANT */ - 0x0, /* gcFEATURE_BIT_NN_PER_CHANNEL_QUANT_ASYM */ - 0x0, /* gcFEATURE_BIT_NN_NATIVE_STRIDE_TWO */ - 0x0, /* gcFEATURE_BIT_NN_TENSOR_ADD */ - 0x0, /* gcFEATURE_BIT_NN_FLOAT_POST_MULT */ + 0x0, /* gcFEATURE_BIT_NN_HW_LIMITATION_NATIVE_KER_1x2_2x1 */ 0x0, /* gcFEATURE_BIT_NN_SLICE_PADDING_TO_64BYTE_ALIGN */ 0x0, /* gcFEATURE_BIT_NN_DW_1x1_CONV_MERGE */ - 0x0, /* gcFEATURE_BIT_NN_SLOW_OUTPUT */ - 0x1, /* gcFEATURE_BIT_NO_NARROW_POST_PROCESS_PIPE */ - 0x0, /* gcFEATURE_BIT_TP_NN_PROBE */ + 0x0, /* gcFEATURE_BIT_TP_BFLOAT16 */ 0x0, /* gcFEATURE_BIT_TP_23BITS_POST_MULTIPLIER */ 0x0, /* gcFEATURE_BIT_NN_TRANSPOSE */ - 0x0, /* gcFEATURE_BIT_EVIS2_FLOP_RESET_FIX */ - 0x0, /* gcFEATURE_BIT_USC_ASYNC_CP_RTN_FLOP_RESET_FIX */ - 0x0, /* gcFEATURE_BIT_DDR_BURST_LEN_256B */ - 0x1, /* gcFEATURE_BIT_IMG_CAHCE_MODE_MUST_0_IN_IMG_DIRECT_MODE_FIX */ 0x0, /* gcFEATURE_BIT_USE_SINGLE_PORT_VIPSRAM */ + 0x0, /* gcFEATURE_BIT_NN_LEAKY_RELU */ + 0x0, /* gcFEATURE_BIT_NN_PRELU */ + 0x0, /* gcFEATURE_BIT_NN_PER_CHANNEL_QUANT */ + 0x0, /* gcFEATURE_BIT_NN_PER_CHANNEL_QUANT_ASYM */ 0x0, /* gcFEATURE_BIT_NN_ASYMMETRIC_INT8 */ - 0x1, /* gcFEATURE_BIT_DEPTHWISE_NEIGHBOR_IMG_DATA_TRANSFER_NOT_EFFICIENT_FIX */ + 0x0, /* gcFEATURE_BIT_NN_FLOAT_POST_MULT */ 0x0, /* gcFEATURE_BIT_PRELU_LEAKLY_RELU_CLAMP */ - 0x0, /* gcFEATURE_BIT_TP_FLOAT32_IO */ + 0x0, /* gcFEATURE_BIT_TPLITE_BFLOAT16 */ + 0x0, /* gcFEATURE_BIT_PREPROCESS_IMG_BUF_640BYTE_LIMIT */ + 0x0, /* gcFEATURE_BIT_TP_KERNEL_1BYTE_ALGIN */ + 0x0, /* gcFEATURE_BIT_BFLOAT_COEF_COMPRESSION_ZERO_COEFBIT14_INVERSE */ + 0x0, /* gcFEATURE_BIT_NN_COMPRESSION_BYPASSS */ + 0x0, /* gcFEATURE_BIT_TP_3_USC */ + 0x0, /* gcFEATURE_BIT_BFP_COEF_AUTO_PAD_INCOMPLETE_ZERO_IN_KZ_PLANE */ + 0x0, /* gcFEATURE_BIT_NN_NATIVE_STRIDE_TWO */ + 0x0, /* gcFEATURE_BIT_NN_TENSOR_ADD */ 0x0, /* gcFEATURE_BIT_NN_FLOAT32_IO */ + 0x0, /* gcFEATURE_BIT_TP_FLOAT32_IO */ 0x0, /* gcFEATURE_BIT_NN_SMALL_BATCH_PHASE2 */ 0x0, /* gcFEATURE_BIT_TILE_ACCESS_CAPABILITY */ 0x0, /* gcFEATURE_BIT_FAST_DP3_PREPROCESSOR */ - 0x0, /* gcFEATURE_BIT_NN_COMPRESSION_BYPASSS */ - 0x0, /* gcFEATURE_BIT_BFLOAT_KERNEL_COMPRESSION_ZERO_SKIP_FIX */ - 0x0, /* gcFEATURE_BIT_TP_3_USC */ - 0x0, /* gcFEATURE_BIT_TP_KERNEL_1BYTE_ALGIN */ - 0x0, /* gcFEATURE_BIT_TPLITE_BFLOAT16 */ - 0x0, /* gcFEATURE_BIT_PREPROCESS_IMG_BUF_640BYTE_LIMIT */ - 0x0, /* gcFEATURE_BIT_V8_ACCUMLATION_READ_OUT_HAS_BUBBLES_PERF_FIX */ + 0x0, /* gcFEATURE_BIT_DEPTHWISE_SUPPORT_16BIT_FORMAT */ + 0x0, /* gcFEATURE_BIT_NN_SUPPORT_ALU_LUT */ + 0x0, /* gcFEATURE_BIT_NN_ENHANCED_MAX_POOLING */ + 0x0, /* gcFEATURE_BIT_NN_TRANSPOSE_PHASE2 */ + 0x0, /* gcFEATURE_BIT_TPLITE_SUPPORT_TP_DATA_TRANSPOSE */ + 0x0, /* gcFEATURE_BIT_NN_SUPPORT_CONV_1D */ + 0x0, /* gcFEATURE_BIT_USE_VIPSRAM_FOR_KERNEL_STREAMING */ + 0x0, /* gcFEATURE_BIT_VIP_DEC400 */ + 0x0, /* gcFEATURE_BIT_NN_PER3DTILE_BUBBLE_FIX */ + 0x0, /* gcFEATURE_BIT_NN_CACHELINE_MODE_PERF_FIX */ + 0x0, /* gcFEATURE_BIT_NN_CONV1x1_PERF_FIX */ + 0x1, /* gcFEATURE_BIT_TP_REORDER_FIX */ + 0x0, /* gcFEATURE_BIT_NN_CONVOUT_FIFO_DEPTH_FIX */ + 0x1, /* gcFEATURE_BIT_NN_ZXDP3_KERNEL_READ_CONFLICT_FIX */ + 0x0, /* gcFEATURE_BIT_NN_ZDP3_NO_COMPRESS_FIX */ + 0x0, /* gcFEATURE_BIT_NN_ASYNC_COPY_PERF_FIX */ + 0x0, /* gcFEATURE_BIT_HI_REORDER_FIX */ + 0x0, /* gcFEATURE_BIT_INCORRECT_WR_REQ_TO_USC_BETWEEN_REORDER_AND_NORMAL_LAYER_FIX */ + 0x0, /* gcFEATURE_BIT_TP_REORDER_LAYER_SUSPEND_FIX */ + 0x0, /* gcFEATURE_BIT_NN_ASYNC_COPY_MERGE_FIX */ + 0x0, /* gcFEATURE_BIT_USC_INVALIDATE_CACHE_LINE_FIX */ + 0x0, /* gcFEATURE_BIT_NN_REQ_SLOWARBITRATION_FIX */ + 0x0, /* gcFEATURE_BIT_IMAGE_PARTIAL_CACHE_FIX */ + 0x0, /* gcFEATURE_BIT_FULLCACHE_KERNELHEAD_FIX */ + 0x0, /* gcFEATURE_BIT_NN_ZDP_INIMAGE_SIZE_FIX */ + 0x0, /* gcFEATURE_BIT_IDLE_BEFORE_FLUSH_COMPLETE_FIX */ + 0x1, /* gcFEATURE_BIT_NO_FLUSH_USC_FIX */ + 0x1, /* gcFEATURE_BIT_SMALL_BATCH_FLOPS_RESET_FIX */ + 0x0, /* gcFEATURE_BIT_SMALL_BATCH_DISBLE_FIX */ + 0x1, /* gcFEATURE_BIT_OUTPUT_CONVERT_UINT8_INT8_TO_UINT16_INT16_FIX */ + 0x0, /* gcFEATURE_BIT_IMAGE_NOT_PACKED_IN_SRAM_FIX */ + 0x1, /* gcFEATURE_BIT_COEF_DELTA_CORD_OVERFLOW_ZRL_8BIT_FIX */ + 0x0, /* gcFEATURE_BIT_LOW_EFFICIENCY_OF_ID_WRITE_IMGBUF_FIX */ + 0x1, /* gcFEATURE_BIT_KERNEL_VIP_SRAM_READ_BW_LIMITATION_FIX */ + 0x0, /* gcFEATURE_BIT_USC_BOTTLENECK_FIX */ + 0x1, /* gcFEATURE_BIT_KERNEL_PER_CORE_LESS_THAN_THIRD_COEF_BUFF_DEPTH_FIX */ + 0x0, /* gcFEATURE_BIT_KERNEL_SIZE_WASTE_IN_PARTIAL_MODE_FIX */ + 0x0, /* gcFEATURE_BIT_NN_COMMAND_KERNEL_REQUEST_CONFICT_FIX */ + 0x0, /* gcFEATURE_BIT_TP_REORDER_INTILE_X_SIZE_512_FIX */ + 0x1, /* gcFEATURE_BIT_IMG_POP_PIPELINE_PAUSE_FIX */ + 0x0, /* gcFEATURE_BIT_FULLCACHE_KERNEL_INTERLEAVE_FIX */ 0x0, /* gcFEATURE_BIT_V8_SINGLE_PORT_ACCUMULATION_BUFFER_RW_CONFICT_ZERO_SKIP_PERF_FIX */ + 0x0, /* gcFEATURE_BIT_V8_ACCUMLATION_READ_OUT_HAS_BUBBLES_PERF_FIX */ + 0x1, /* gcFEATURE_BIT_DEPTHWISE_NEIGHBOR_IMG_DATA_TRANSFER_NOT_EFFICIENT_FIX */ + 0x0, /* gcFEATURE_BIT_DR_JD_DIFF_CONDITION_FOR_CACHELINE_MODE_PRE_FIX */ + 0x0, /* gcFEATURE_BIT_TP_ACCESS_VIPSRAM_OT_IS_ONE_FIX */ + 0x0, /* gcFEATURE_BIT_EVIS2_FLOP_RESET_FIX */ + 0x1, /* gcFEATURE_BIT_OUTIMAGE_X_BITWIDTH_LIMIT_FOR_NN_TRANSPOSE_FIX */ + 0x0, /* gcFEATURE_BIT_USC_ASYNC_CP_RTN_FLOP_RESET_FIX */ + 0x1, /* gcFEATURE_BIT_IMG_ADDR_NOT_WRAP_IF_OVER_OCB_ADDR_FIX */ + 0x1, /* gcFEATURE_BIT_NEGATIVE_POST_SHIFT_FIX */ + 0x0, /* gcFEATURE_BIT_INIMAGE_2DTILE_NOT_LESS_160PIXEL_FIX */ + 0x1, /* gcFEATURE_BIT_IMG_CAHCE_MODE_MUST_0_IN_IMG_DIRECT_MODE_FIX */ 0x0, /* gcFEATURE_BIT_BURST_COLLECT_DUMMY_DATA_WASTE_CYCLES_FIX */ 0x0, /* gcFEATURE_BIT_INIMG_NOT_64BYTE_ALIGN_CACHELINE_MODE_FIX */ - 0x0, /* gcFEATURE_BIT_TP_ACCESS_VIPSRAM_OT_IS_ONE_FIX */ - 0x1, /* gcFEATURE_BIT_VIP_HW_FINAL_RELEASE */ + 0x1, /* gcFEATURE_BIT_TP_FC_FLOAT_LAST_PIXEL_NEGATIVE_0_FIX */ + 0x1, /* gcFEATURE_BIT_NN_WASET_COEF_READ_WRITE_BANDWIDTH_128BYTE_VIPSRAM_IN_FULL_PATIAL_CACHE_MODE */ + 0x1, /* gcFEATURE_BIT_NN_IN_TILE_DATA_IS_ALL_PAD_FIX */ + 0x1, /* gcFEATURE_BIT_TP_FC_KERNEL_STREAM_MUST_LESS_THAN_OR_EQUAL_TO_64BYTE_WHEN_1BYTE_ALGINE_FIX */ + 0x0, /* gcFEATURE_BIT_NN_INTERLEVE8 */ + 0x0, /* gcFEATURE_BIT_NN_FP16_ALU */ + 0x1, /* gcFEATURE_BIT_NN_INT16_ALU */ + 0x1, /* gcFEATURE_BIT_NN_INT8_SCALE */ + 0x1, /* gcFEATURE_BIT_NN_POWER_ISOLATION */ + 0x0, /* gcFEATURE_BIT_ZRL_7BIT */ + 0x0, /* gcFEATURE_BIT_NN_SMALLBATCH_PHASE1 */ + 0x0, /* gcFEATURE_BIT_TP_SMALLBATCH_PHASE1 */ + 0x0, /* gcFEATURE_BIT_NN_SMALLBATCH */ + 0x0, /* gcFEATURE_BIT_TP_SMALLBATCH */ + 0x0, /* gcFEATURE_BIT_ZRL_8BIT */ + 0x0, /* gcFEATURE_BIT_DDR_BURST_LEN_256B */ + 0x0, /* gcFEATURE_BIT_XY_OFFSET_LIMITATION_FIX */ + 0x0, /* gcFEATURE_BIT_NN_NONZERO_MIRROR_BORDER */ + 0x0, /* gcFEATURE_BIT_IMAGE_PARTIAL_CACHE */ }, /* vipnano-qi */ { @@ -1295,13 +1409,23 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x140, /* gcFEATURE_VALUE_NumberOfConstants */ 0x1, /* gcFEATURE_VALUE_CoreCount */ 0x10, /* gcFEATURE_VALUE_LocalStorageSize */ + 0x0, /* gcFEATURE_VALUE_LocalStorageSize_1 */ + 0x0, /* gcFEATURE_VALUE_LocalStorageSize_2 */ 0x10, /* gcFEATURE_VALUE_L1CacheSize */ + 0x0, /* gcFEATURE_VALUE_L1CacheSize_1 */ + 0x0, /* gcFEATURE_VALUE_L1CacheSize_2 */ 0x200, /* gcFEATURE_VALUE_InstructionMemorySize */ 0x14, /* gcFEATURE_VALUE_ShaderPCLength */ 0x10, /* gcFEATURE_VALUE_USC_MAX_PAGES */ + 0x0, /* gcFEATURE_VALUE_USC_MAX_PAGES_1 */ + 0x0, /* gcFEATURE_VALUE_USC_MAX_PAGES_2 */ 0x1, /* gcFEATURE_VALUE_NumPixelPipes */ 0x2, /* gcFEATURE_VALUE_USC_CACHE_CONTROLLERS */ + 0x0, /* gcFEATURE_VALUE_USC_CACHE_CONTROLLERS_1 */ + 0x0, /* gcFEATURE_VALUE_USC_CACHE_CONTROLLERS_2 */ 0x2, /* gcFEATURE_VALUE_USC_BANKS */ + 0x0, /* gcFEATURE_VALUE_USC_BANKS_1 */ + 0x0, /* gcFEATURE_VALUE_USC_BANKS_2 */ 0x8, /* gcFEATURE_VALUE_Streams */ 0x10, /* gcFEATURE_VALUE_VaryingCount */ 0x400, /* gcFEATURE_VALUE_VertexOutputBufferSize */ @@ -1310,6 +1434,7 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_VALUE_NumResolvePipes */ 0x100, /* gcFEATURE_VALUE_RESULT_WINDOW_MAX_SIZE */ 0x0, /* gcFEATURE_VALUE_ClusterAliveMask */ + 0x0, /* gcFEATURE_VALUE_G2D_DEC400_MINOR */ 0x40, /* gcFEATURE_VALUE_NNMadPerCore */ 0x8, /* gcFEATURE_VALUE_NNCoreCount */ 0x8, /* gcFEATURE_VALUE_NNCoreCount_INT8 */ @@ -1334,14 +1459,26 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x20, /* gcFEATURE_VALUE_PHYSICAL_VIP_SRAM_WIDTH_IN_BYTE */ 0x10, /* gcFEATURE_VALUE_EQUIVALENT_VIP_SRAM_WIDTH_INBYTE */ 0x8, /* gcFEATURE_VALUE_TP_ZRL_BITS */ + 0x5, /* gcFEATURE_VALUE_NN_ZRL_BITS */ 0x80, /* gcFEATURE_VALUE_LATENCY_HIDING_AT_FULL_AXI_BW */ 0x10, /* gcFEATURE_VALUE_AXI_BUS_WIDTH */ 0xb, /* gcFEATURE_VALUE_NN_KERNEL_X_SIZE */ 0xb, /* gcFEATURE_VALUE_NN_KERNEL_Y_SIZE */ + 0xf, /* gcFEATURE_VALUE_NN_FC_KERNEL_Y_SIZE */ 0xfffff, /* gcFEATURE_VALUE_NN_KERNEL_Z_SIZE */ 0x7, /* gcFEATURE_VALUE_NN_X_OFFSET */ 0x7, /* gcFEATURE_VALUE_NN_Y_OFFSET */ 0x40, /* gcFEATURE_VALUE_DDR_KERNEL_BURST_SIZE */ + 0x10, /* gcFEATURE_VALUE_OUTIMAGE_X_STRIDE_BITS */ + 0x0, /* gcFEATURE_VALUE_OUTIMAGE_Y_STRIDE_BITS */ + 0x10, /* gcFEATURE_VALUE_INIMAGE_X_STRIDE_BITS */ + 0x10, /* gcFEATURE_VALUE_IMIMAGE_Y_STRIDE_BITS */ + 0xd, /* gcFEATURE_VALUE_OUTIMAGE_X_SIZE_BITS */ + 0xd, /* gcFEATURE_VALUE_OUTIMAGE_Y_SIZE_BITS */ + 0xe, /* gcFEATURE_VALUE_OUTIMAGE_SIZE_BITS */ + 0xd, /* gcFEATURE_VALUE_IMAGE_X_SIZE_BITS */ + 0xd, /* gcFEATURE_VALUE_INIMAGE_Y_SIZE_BITS */ + 0x40, /* gcFEATURE_VALUE_MAX_TILE_X_SIZE */ 0x0, /* gcFEATURE_BIT_REG_FastClear */ 0x0, /* gcFEATURE_BIT_REG_SpecialAntiAliasing */ 0x1, /* gcFEATURE_BIT_REG_Pipe3D */ @@ -1583,6 +1720,7 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x1, /* gcFEATURE_BIT_RA_HZEZ_CLOCK_CONTROL */ 0x1, /* gcFEATURE_BIT_CACHE128B256BPERLINE */ 0x1, /* gcFEATURE_BIT_V4Compression */ + 0x0, /* gcFEATURE_BIT_DE2D_MAJOR_SUPER_TILE */ 0x0, /* gcFEATURE_BIT_PE2D_MAJOR_SUPER_TILE */ 0x1, /* gcFEATURE_BIT_PE_32BPC_COLORMASK_FIX */ 0x1, /* gcFEATURE_BIT_ALPHA_BLENDING_OPT */ @@ -1715,6 +1853,7 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_BIT_TX_NO_FIXED_FILTER */ 0x0, /* gcFEATURE_BIT_SHARE_Z */ 0x0, /* gcFEATURE_BIT_DE_2D_FAST_CLEAR */ + 0x0, /* gcFEATURE_BIT_DE_TILESTATUS_ROTATION_FIX */ 0x0, /* gcFEATURE_BIT_TX_CLEAR_PENDING_FIX */ 0x0, /* gcFEATURE_BIT_NO_HI1_L2 */ 0x0, /* gcFEATURE_BIT_USC_EVICT_CTRL_FIFO_FLOP_RESET_FIX */ @@ -1725,6 +1864,13 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_BIT_SH_VX2_FLOATING_MAD_FIX */ 0x0, /* gcFEATURE_BIT_TS_FC_VULKAN_SUPPORT */ 0x0, /* gcFEATURE_BIT_MSAA_FLOAT_64BIT */ + 0x0, /* gcFEATURE_BIT_INDIRECT_COMPUTE_ZERODIM_FIX */ + 0x0, /* gcFEATURE_BIT_Q_CHANNEL_SUPPORT */ + 0x0, /* gcFEATURE_BIT_MMU_PAGE_DESCRIPTOR */ + 0x0, /* gcFEATURE_BIT_YUV_LINEAR_TO_TILE_ROTATE */ + 0x0, /* gcFEATURE_BIT_VEC2_IMULIMAD32_SUPPORT */ + 0x0, /* gcFEATURE_BIT_VEC4_IMULIMAD32_SUPPORT */ + 0x0, /* gcFEATURE_BIT_VEC2_IDIVIMOD16_SUPPORT */ 0x0, /* gcFEATURE_BIT_VG_TS_CULLING */ 0x0, /* gcFEATURE_BIT_VG_FP25 */ 0x0, /* gcFEATURE_BIT_VG_AYUV_INPUT_OUTPUT */ @@ -1751,6 +1897,20 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_BIT_DC_MMU */ 0x0, /* gcFEATURE_BIT_DC_COMPRESSION */ 0x0, /* gcFEATURE_BIT_DC_QOS */ + 0x1, /* gcFEATURE_BIT_VIP_HW_FINAL_RELEASE */ + 0x1, /* gcFEATURE_BIT_NN_SINGLEPORT_ACCUMBUFFER */ + 0x1, /* gcFEATURE_BIT_NN_STRIDE_SUPPORT */ + 0x1, /* gcFEATURE_BIT_SWTILING_PHASE1 */ + 0x0, /* gcFEATURE_BIT_SWTILING_PHASE2 */ + 0x1, /* gcFEATURE_BIT_TP_SIMPLE_INT16 */ + 0x0, /* gcFEATURE_BIT_TP_REAL_INT16 */ + 0x1, /* gcFEATURE_BIT_TP_ROI_POOLING */ + 0x1, /* gcFEATURE_BIT_TP_MAX_POOLING_STRIDE1 */ + 0x1, /* gcFEATURE_BIT_TP_LRN */ + 0x0, /* gcFEATURE_BIT_TP_REORDER */ + 0x1, /* gcFEATURE_BIT_TF_QUANTIZATION */ + 0x0, /* gcFEATURE_BIT_NN_NONZERO_BORDER */ + 0x0, /* gcFEATURE_BIT_NN_MIRROR_BORDER */ 0x0, /* gcFEATURE_BIT_AI_GPU */ 0x0, /* gcFEATURE_BIT_EVIS_NO_ABSDIFF */ 0x0, /* gcFEATURE_BIT_EVIS_NO_BITREPLACE */ @@ -1763,128 +1923,139 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_BIT_EVIS_LERP_7OUTPUT */ 0x0, /* gcFEATURE_BIT_EVIS_ACCSQ_8OUTPUT */ 0x1, /* gcFEATURE_BIT_EVIS_VX2 */ - 0x1, /* gcFEATURE_BIT_NN_FLOAT */ 0x1, /* gcFEATURE_BIT_TP_ENGINE */ 0x1, /* gcFEATURE_BIT_VIP_V7 */ - 0x0, /* gcFEATURE_BIT_MCFE */ - 0x0, /* gcFEATURE_BIT_NN_INTERLEVE8 */ - 0x0, /* gcFEATURE_BIT_TP_REORDER */ - 0x1, /* gcFEATURE_BIT_TP_LRN */ - 0x1, /* gcFEATURE_BIT_TP_MAX_POOLING_STRIDE1 */ - 0x0, /* gcFEATURE_BIT_NN_FP16_ALU */ - 0x1, /* gcFEATURE_BIT_NN_INT16_ALU */ - 0x1, /* gcFEATURE_BIT_TP_ROI_POOLING */ - 0x0, /* gcFEATURE_BIT_NN_ZDP3 */ + 0x0, /* gcFEATURE_BIT_TP_TENSOR_ADD_MUL */ + 0x0, /* gcFEATURE_BIT_NN_DEPTHWISE_INT16XINT8 */ + 0x0, /* gcFEATURE_BIT_TP_SOFTMAX */ + 0x0, /* gcFEATURE_BIT_NN_23BITS_POST_MULTIPLIER_VIP_V7 */ + 0x0, /* gcFEATURE_BIT_TP_23BITS_POST_MULTIPLIER_VIP_V7 */ + 0x0, /* gcFEATURE_BIT_HYBRID_MODE_VIP_V7 */ 0x0, /* gcFEATURE_BIT_NN_ZDP6 */ 0x0, /* gcFEATURE_BIT_NN_XYDP9 */ - 0x1, /* gcFEATURE_BIT_NN_INT8_SCALE */ - 0x1, /* gcFEATURE_BIT_NN_POWER_ISOLATION */ - 0x1, /* gcFEATURE_BIT_SWTILING_PHASE1 */ - 0x1, /* gcFEATURE_BIT_TF_QUANTIZATION */ - 0x1, /* gcFEATURE_BIT_TP_SIMPLE_INT16 */ - 0x0, /* gcFEATURE_BIT_TP_REAL_INT16 */ - 0x0, /* gcFEATURE_BIT_TP_BFLOAT16 */ 0x0, /* gcFEATURE_BIT_NN_FIRST_PIXEL_POOLING */ - 0x0, /* gcFEATURE_BIT_SWTILING_PHASE2 */ - 0x1, /* gcFEATURE_BIT_NN_STRIDE_SUPPORT */ + 0x0, /* gcFEATURE_BIT_NN_ZDP3 */ 0x0, /* gcFEATURE_BIT_NN_XYDP6 */ - 0x0, /* gcFEATURE_BIT_TP_REORDER_FIX */ - 0x0, /* gcFEATURE_BIT_NN_CONV1x1_PERF_FIX */ - 0x0, /* gcFEATURE_BIT_NN_CACHELINE_MODE_PERF_FIX */ - 0x0, /* gcFEATURE_BIT_NN_PER3DTILE_BUBBLE_FIX */ - 0x0, /* gcFEATURE_BIT_NN_CONVOUT_FIFO_DEPTH_FIX */ 0x0, /* gcFEATURE_BIT_SWTILING_PHASE3 */ + 0x0, /* gcFEATURE_BIT_MCFE */ 0x0, /* gcFEATURE_BIT_USC_STAY_LRU */ - 0x0, /* gcFEATURE_BIT_NN_NONZERO_MIRROR_BORDER */ + 0x0, /* gcFEATURE_BIT_COEF_COMPRESSION_ENHANCEMENT */ + 0x0, /* gcFEATURE_BIT_TP_COEF_COMPRESSION_ENHANCEMENT */ 0x0, /* gcFEATURE_BIT_NN_COEF_DECOMPRESS_PERF2X */ + 0x1, /* gcFEATURE_BIT_OCB_COUNTER */ + 0x0, /* gcFEATURE_BIT_SCALER */ + 0x0, /* gcFEATURE_BIT_SCALER_4K */ 0x0, /* gcFEATURE_BIT_INPUT_4BIT */ - 0x0, /* gcFEATURE_BIT_COEF_COMPRESSION_ENHANCEMENT */ + 0x0, /* gcFEATURE_BIT_NN_NO_Z_LOCATION_OFFSET */ + 0x1, /* gcFEATURE_BIT_OCB_REMAP_PHYSICAL_ADDRESS */ + 0x0, /* gcFEATURE_BIT_NN_SLOW_OUTPUT */ + 0x1, /* gcFEATURE_BIT_NO_NARROW_POST_PROCESS_PIPE */ + 0x0, /* gcFEATURE_BIT_TP_NN_PROBE */ + 0x0, /* gcFEATURE_BIT_NN_DEPTHWISE_SUPPORT */ + 0x0, /* gcFEATURE_BIT_NN_XYDP0 */ + 0x0, /* gcFEATURE_BIT_NN_WRITE_WITHOUT_USC */ + 0x0, /* gcFEATURE_BIT_NN_HW_LIMITATION_NATIVE_KER_1x2_2x1 */ + 0x0, /* gcFEATURE_BIT_NN_SLICE_PADDING_TO_64BYTE_ALIGN */ + 0x0, /* gcFEATURE_BIT_NN_DW_1x1_CONV_MERGE */ + 0x0, /* gcFEATURE_BIT_TP_BFLOAT16 */ + 0x0, /* gcFEATURE_BIT_TP_23BITS_POST_MULTIPLIER */ + 0x0, /* gcFEATURE_BIT_NN_TRANSPOSE */ + 0x0, /* gcFEATURE_BIT_USE_SINGLE_PORT_VIPSRAM */ + 0x0, /* gcFEATURE_BIT_NN_LEAKY_RELU */ + 0x0, /* gcFEATURE_BIT_NN_PRELU */ + 0x0, /* gcFEATURE_BIT_NN_PER_CHANNEL_QUANT */ + 0x0, /* gcFEATURE_BIT_NN_PER_CHANNEL_QUANT_ASYM */ + 0x0, /* gcFEATURE_BIT_NN_ASYMMETRIC_INT8 */ + 0x0, /* gcFEATURE_BIT_NN_FLOAT_POST_MULT */ + 0x0, /* gcFEATURE_BIT_PRELU_LEAKLY_RELU_CLAMP */ + 0x0, /* gcFEATURE_BIT_TPLITE_BFLOAT16 */ + 0x0, /* gcFEATURE_BIT_PREPROCESS_IMG_BUF_640BYTE_LIMIT */ + 0x0, /* gcFEATURE_BIT_TP_KERNEL_1BYTE_ALGIN */ + 0x0, /* gcFEATURE_BIT_BFLOAT_COEF_COMPRESSION_ZERO_COEFBIT14_INVERSE */ + 0x0, /* gcFEATURE_BIT_NN_COMPRESSION_BYPASSS */ + 0x0, /* gcFEATURE_BIT_TP_3_USC */ + 0x0, /* gcFEATURE_BIT_BFP_COEF_AUTO_PAD_INCOMPLETE_ZERO_IN_KZ_PLANE */ + 0x0, /* gcFEATURE_BIT_NN_NATIVE_STRIDE_TWO */ + 0x0, /* gcFEATURE_BIT_NN_TENSOR_ADD */ + 0x0, /* gcFEATURE_BIT_NN_FLOAT32_IO */ + 0x0, /* gcFEATURE_BIT_TP_FLOAT32_IO */ + 0x0, /* gcFEATURE_BIT_NN_SMALL_BATCH_PHASE2 */ + 0x0, /* gcFEATURE_BIT_TILE_ACCESS_CAPABILITY */ + 0x0, /* gcFEATURE_BIT_FAST_DP3_PREPROCESSOR */ + 0x0, /* gcFEATURE_BIT_DEPTHWISE_SUPPORT_16BIT_FORMAT */ + 0x0, /* gcFEATURE_BIT_NN_SUPPORT_ALU_LUT */ + 0x0, /* gcFEATURE_BIT_NN_ENHANCED_MAX_POOLING */ + 0x0, /* gcFEATURE_BIT_NN_TRANSPOSE_PHASE2 */ + 0x0, /* gcFEATURE_BIT_TPLITE_SUPPORT_TP_DATA_TRANSPOSE */ + 0x0, /* gcFEATURE_BIT_NN_SUPPORT_CONV_1D */ + 0x0, /* gcFEATURE_BIT_USE_VIPSRAM_FOR_KERNEL_STREAMING */ + 0x0, /* gcFEATURE_BIT_VIP_DEC400 */ + 0x0, /* gcFEATURE_BIT_NN_PER3DTILE_BUBBLE_FIX */ + 0x0, /* gcFEATURE_BIT_NN_CACHELINE_MODE_PERF_FIX */ + 0x0, /* gcFEATURE_BIT_NN_CONV1x1_PERF_FIX */ + 0x0, /* gcFEATURE_BIT_TP_REORDER_FIX */ + 0x0, /* gcFEATURE_BIT_NN_CONVOUT_FIFO_DEPTH_FIX */ 0x1, /* gcFEATURE_BIT_NN_ZXDP3_KERNEL_READ_CONFLICT_FIX */ 0x0, /* gcFEATURE_BIT_NN_ZDP3_NO_COMPRESS_FIX */ 0x0, /* gcFEATURE_BIT_NN_ASYNC_COPY_PERF_FIX */ - 0x1, /* gcFEATURE_BIT_OCB_COUNTER */ - 0x0, /* gcFEATURE_BIT_NN_XYDP0 */ - 0x0, /* gcFEATURE_BIT_ZRL_7BIT */ + 0x1, /* gcFEATURE_BIT_HI_REORDER_FIX */ + 0x1, /* gcFEATURE_BIT_INCORRECT_WR_REQ_TO_USC_BETWEEN_REORDER_AND_NORMAL_LAYER_FIX */ + 0x0, /* gcFEATURE_BIT_TP_REORDER_LAYER_SUSPEND_FIX */ 0x0, /* gcFEATURE_BIT_NN_ASYNC_COPY_MERGE_FIX */ - 0x0, /* gcFEATURE_BIT_NN_SMALLBATCH_PHASE1 */ - 0x0, /* gcFEATURE_BIT_TP_SMALLBATCH_PHASE1 */ - 0x0, /* gcFEATURE_BIT_SCALER */ - 0x0, /* gcFEATURE_BIT_SCALER_4K */ + 0x0, /* gcFEATURE_BIT_USC_INVALIDATE_CACHE_LINE_FIX */ 0x0, /* gcFEATURE_BIT_NN_REQ_SLOWARBITRATION_FIX */ - 0x0, /* gcFEATURE_BIT_IMAGE_PARTIAL_CACHE */ + 0x0, /* gcFEATURE_BIT_IMAGE_PARTIAL_CACHE_FIX */ 0x0, /* gcFEATURE_BIT_FULLCACHE_KERNELHEAD_FIX */ - 0x1, /* gcFEATURE_BIT_NN_SINGLEPORT_ACCUMBUFFER */ - 0x0, /* gcFEATURE_BIT_NN_SMALLBATCH */ - 0x0, /* gcFEATURE_BIT_TP_SMALLBATCH */ - 0x0, /* gcFEATURE_BIT_ZRL_8BIT */ - 0x0, /* gcFEATURE_BIT_NN_DEPTHWISE_SUPPORT */ - 0x0, /* gcFEATURE_BIT_NN_WRITE_WITHOUT_USC */ 0x0, /* gcFEATURE_BIT_NN_ZDP_INIMAGE_SIZE_FIX */ - 0x1, /* gcFEATURE_BIT_HI_REORDER_FIX */ - 0x1, /* gcFEATURE_BIT_INCORRECT_WR_REQ_TO_USC_BETWEEN_REORDER_AND_NORMAL_LAYER_FIX */ - 0x0, /* gcFEATURE_BIT_TP_COEF_COMPRESSION_ENHANCEMENT */ - 0x0, /* gcFEATURE_BIT_VIP_DEC400 */ - 0x0, /* gcFEATURE_BIT_IMAGE_NOT_PACKED_IN_SRAM_FIX */ 0x0, /* gcFEATURE_BIT_IDLE_BEFORE_FLUSH_COMPLETE_FIX */ 0x1, /* gcFEATURE_BIT_NO_FLUSH_USC_FIX */ + 0x0, /* gcFEATURE_BIT_SMALL_BATCH_FLOPS_RESET_FIX */ + 0x0, /* gcFEATURE_BIT_SMALL_BATCH_DISBLE_FIX */ + 0x1, /* gcFEATURE_BIT_OUTPUT_CONVERT_UINT8_INT8_TO_UINT16_INT16_FIX */ + 0x0, /* gcFEATURE_BIT_IMAGE_NOT_PACKED_IN_SRAM_FIX */ 0x1, /* gcFEATURE_BIT_COEF_DELTA_CORD_OVERFLOW_ZRL_8BIT_FIX */ - 0x0, /* gcFEATURE_BIT_XY_OFFSET_LIMITATION_FIX */ - 0x0, /* gcFEATURE_BIT_USC_INVALIDATE_CACHE_LINE_FIX */ 0x0, /* gcFEATURE_BIT_LOW_EFFICIENCY_OF_ID_WRITE_IMGBUF_FIX */ - 0x1, /* gcFEATURE_BIT_KERNEL_PER_CORE_LESS_THAN_THIRD_COEF_BUFF_DEPTH_FIX */ + 0x1, /* gcFEATURE_BIT_KERNEL_VIP_SRAM_READ_BW_LIMITATION_FIX */ 0x0, /* gcFEATURE_BIT_USC_BOTTLENECK_FIX */ + 0x1, /* gcFEATURE_BIT_KERNEL_PER_CORE_LESS_THAN_THIRD_COEF_BUFF_DEPTH_FIX */ 0x0, /* gcFEATURE_BIT_KERNEL_SIZE_WASTE_IN_PARTIAL_MODE_FIX */ - 0x0, /* gcFEATURE_BIT_FULLCACHE_KERNEL_INTERLEAVE_FIX */ - 0x0, /* gcFEATURE_BIT_TP_REORDER_LAYER_SUSPEND_FIX */ - 0x1, /* gcFEATURE_BIT_KERNEL_VIP_SRAM_READ_BW_LIMITATION_FIX */ + 0x0, /* gcFEATURE_BIT_NN_COMMAND_KERNEL_REQUEST_CONFICT_FIX */ + 0x0, /* gcFEATURE_BIT_TP_REORDER_INTILE_X_SIZE_512_FIX */ 0x1, /* gcFEATURE_BIT_IMG_POP_PIPELINE_PAUSE_FIX */ + 0x0, /* gcFEATURE_BIT_FULLCACHE_KERNEL_INTERLEAVE_FIX */ + 0x0, /* gcFEATURE_BIT_V8_SINGLE_PORT_ACCUMULATION_BUFFER_RW_CONFICT_ZERO_SKIP_PERF_FIX */ + 0x0, /* gcFEATURE_BIT_V8_ACCUMLATION_READ_OUT_HAS_BUBBLES_PERF_FIX */ + 0x1, /* gcFEATURE_BIT_DEPTHWISE_NEIGHBOR_IMG_DATA_TRANSFER_NOT_EFFICIENT_FIX */ 0x0, /* gcFEATURE_BIT_DR_JD_DIFF_CONDITION_FOR_CACHELINE_MODE_PRE_FIX */ - 0x1, /* gcFEATURE_BIT_OUTIMAGE_X_BITWIDTH_LIMIT_FOR_NN_TRANSPOSE_FIX */ - 0x0, /* gcFEATURE_BIT_SMALL_BATCH_FLOPS_RESET_FIX */ - 0x0, /* gcFEATURE_BIT_SMALL_BATCH_DISBLE_FIX */ - 0x1, /* gcFEATURE_BIT_NEGATIVE_POST_SHIFT_FIX */ - 0x0, /* gcFEATURE_BIT_NN_COMMAND_KERNEL_REQUEST_CONFICT_FIX */ - 0x1, /* gcFEATURE_BIT_OCB_REMAP_PHYSICAL_ADDRESS */ - 0x0, /* gcFEATURE_BIT_NN_NO_Z_LOCATION_OFFSET */ - 0x0, /* gcFEATURE_BIT_NN_LEAKY_RELU */ - 0x0, /* gcFEATURE_BIT_NN_PRELU */ - 0x0, /* gcFEATURE_BIT_NN_PER_CHANNEL_QUANT */ - 0x0, /* gcFEATURE_BIT_NN_PER_CHANNEL_QUANT_ASYM */ - 0x0, /* gcFEATURE_BIT_NN_NATIVE_STRIDE_TWO */ - 0x0, /* gcFEATURE_BIT_NN_TENSOR_ADD */ - 0x0, /* gcFEATURE_BIT_NN_FLOAT_POST_MULT */ - 0x0, /* gcFEATURE_BIT_NN_SLICE_PADDING_TO_64BYTE_ALIGN */ - 0x0, /* gcFEATURE_BIT_NN_DW_1x1_CONV_MERGE */ - 0x0, /* gcFEATURE_BIT_NN_SLOW_OUTPUT */ - 0x1, /* gcFEATURE_BIT_NO_NARROW_POST_PROCESS_PIPE */ - 0x0, /* gcFEATURE_BIT_TP_NN_PROBE */ - 0x0, /* gcFEATURE_BIT_TP_23BITS_POST_MULTIPLIER */ - 0x0, /* gcFEATURE_BIT_NN_TRANSPOSE */ + 0x0, /* gcFEATURE_BIT_TP_ACCESS_VIPSRAM_OT_IS_ONE_FIX */ 0x0, /* gcFEATURE_BIT_EVIS2_FLOP_RESET_FIX */ + 0x1, /* gcFEATURE_BIT_OUTIMAGE_X_BITWIDTH_LIMIT_FOR_NN_TRANSPOSE_FIX */ 0x0, /* gcFEATURE_BIT_USC_ASYNC_CP_RTN_FLOP_RESET_FIX */ - 0x0, /* gcFEATURE_BIT_DDR_BURST_LEN_256B */ + 0x1, /* gcFEATURE_BIT_IMG_ADDR_NOT_WRAP_IF_OVER_OCB_ADDR_FIX */ + 0x1, /* gcFEATURE_BIT_NEGATIVE_POST_SHIFT_FIX */ + 0x0, /* gcFEATURE_BIT_INIMAGE_2DTILE_NOT_LESS_160PIXEL_FIX */ 0x1, /* gcFEATURE_BIT_IMG_CAHCE_MODE_MUST_0_IN_IMG_DIRECT_MODE_FIX */ - 0x0, /* gcFEATURE_BIT_USE_SINGLE_PORT_VIPSRAM */ - 0x0, /* gcFEATURE_BIT_NN_ASYMMETRIC_INT8 */ - 0x1, /* gcFEATURE_BIT_DEPTHWISE_NEIGHBOR_IMG_DATA_TRANSFER_NOT_EFFICIENT_FIX */ - 0x0, /* gcFEATURE_BIT_PRELU_LEAKLY_RELU_CLAMP */ - 0x0, /* gcFEATURE_BIT_TP_FLOAT32_IO */ - 0x0, /* gcFEATURE_BIT_NN_FLOAT32_IO */ - 0x0, /* gcFEATURE_BIT_NN_SMALL_BATCH_PHASE2 */ - 0x0, /* gcFEATURE_BIT_TILE_ACCESS_CAPABILITY */ - 0x0, /* gcFEATURE_BIT_FAST_DP3_PREPROCESSOR */ - 0x0, /* gcFEATURE_BIT_NN_COMPRESSION_BYPASSS */ - 0x0, /* gcFEATURE_BIT_BFLOAT_KERNEL_COMPRESSION_ZERO_SKIP_FIX */ - 0x0, /* gcFEATURE_BIT_TP_3_USC */ - 0x0, /* gcFEATURE_BIT_TP_KERNEL_1BYTE_ALGIN */ - 0x0, /* gcFEATURE_BIT_TPLITE_BFLOAT16 */ - 0x0, /* gcFEATURE_BIT_PREPROCESS_IMG_BUF_640BYTE_LIMIT */ - 0x0, /* gcFEATURE_BIT_V8_ACCUMLATION_READ_OUT_HAS_BUBBLES_PERF_FIX */ - 0x0, /* gcFEATURE_BIT_V8_SINGLE_PORT_ACCUMULATION_BUFFER_RW_CONFICT_ZERO_SKIP_PERF_FIX */ 0x0, /* gcFEATURE_BIT_BURST_COLLECT_DUMMY_DATA_WASTE_CYCLES_FIX */ 0x0, /* gcFEATURE_BIT_INIMG_NOT_64BYTE_ALIGN_CACHELINE_MODE_FIX */ - 0x0, /* gcFEATURE_BIT_TP_ACCESS_VIPSRAM_OT_IS_ONE_FIX */ - 0x1, /* gcFEATURE_BIT_VIP_HW_FINAL_RELEASE */ + 0x1, /* gcFEATURE_BIT_TP_FC_FLOAT_LAST_PIXEL_NEGATIVE_0_FIX */ + 0x1, /* gcFEATURE_BIT_NN_WASET_COEF_READ_WRITE_BANDWIDTH_128BYTE_VIPSRAM_IN_FULL_PATIAL_CACHE_MODE */ + 0x1, /* gcFEATURE_BIT_NN_IN_TILE_DATA_IS_ALL_PAD_FIX */ + 0x1, /* gcFEATURE_BIT_TP_FC_KERNEL_STREAM_MUST_LESS_THAN_OR_EQUAL_TO_64BYTE_WHEN_1BYTE_ALGINE_FIX */ + 0x0, /* gcFEATURE_BIT_NN_INTERLEVE8 */ + 0x0, /* gcFEATURE_BIT_NN_FP16_ALU */ + 0x1, /* gcFEATURE_BIT_NN_INT16_ALU */ + 0x1, /* gcFEATURE_BIT_NN_INT8_SCALE */ + 0x1, /* gcFEATURE_BIT_NN_POWER_ISOLATION */ + 0x0, /* gcFEATURE_BIT_ZRL_7BIT */ + 0x0, /* gcFEATURE_BIT_NN_SMALLBATCH_PHASE1 */ + 0x0, /* gcFEATURE_BIT_TP_SMALLBATCH_PHASE1 */ + 0x0, /* gcFEATURE_BIT_NN_SMALLBATCH */ + 0x0, /* gcFEATURE_BIT_TP_SMALLBATCH */ + 0x0, /* gcFEATURE_BIT_ZRL_8BIT */ + 0x0, /* gcFEATURE_BIT_DDR_BURST_LEN_256B */ + 0x0, /* gcFEATURE_BIT_XY_OFFSET_LIMITATION_FIX */ + 0x0, /* gcFEATURE_BIT_NN_NONZERO_MIRROR_BORDER */ + 0x0, /* gcFEATURE_BIT_IMAGE_PARTIAL_CACHE */ }, /* vipnano-qi */ { @@ -1903,13 +2074,23 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x140, /* gcFEATURE_VALUE_NumberOfConstants */ 0x1, /* gcFEATURE_VALUE_CoreCount */ 0x10, /* gcFEATURE_VALUE_LocalStorageSize */ + 0x0, /* gcFEATURE_VALUE_LocalStorageSize_1 */ + 0x0, /* gcFEATURE_VALUE_LocalStorageSize_2 */ 0x10, /* gcFEATURE_VALUE_L1CacheSize */ + 0x0, /* gcFEATURE_VALUE_L1CacheSize_1 */ + 0x0, /* gcFEATURE_VALUE_L1CacheSize_2 */ 0x200, /* gcFEATURE_VALUE_InstructionMemorySize */ 0x14, /* gcFEATURE_VALUE_ShaderPCLength */ 0x10, /* gcFEATURE_VALUE_USC_MAX_PAGES */ + 0x0, /* gcFEATURE_VALUE_USC_MAX_PAGES_1 */ + 0x0, /* gcFEATURE_VALUE_USC_MAX_PAGES_2 */ 0x1, /* gcFEATURE_VALUE_NumPixelPipes */ 0x2, /* gcFEATURE_VALUE_USC_CACHE_CONTROLLERS */ + 0x0, /* gcFEATURE_VALUE_USC_CACHE_CONTROLLERS_1 */ + 0x0, /* gcFEATURE_VALUE_USC_CACHE_CONTROLLERS_2 */ 0x2, /* gcFEATURE_VALUE_USC_BANKS */ + 0x0, /* gcFEATURE_VALUE_USC_BANKS_1 */ + 0x0, /* gcFEATURE_VALUE_USC_BANKS_2 */ 0x8, /* gcFEATURE_VALUE_Streams */ 0x10, /* gcFEATURE_VALUE_VaryingCount */ 0x400, /* gcFEATURE_VALUE_VertexOutputBufferSize */ @@ -1918,6 +2099,7 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_VALUE_NumResolvePipes */ 0x100, /* gcFEATURE_VALUE_RESULT_WINDOW_MAX_SIZE */ 0x0, /* gcFEATURE_VALUE_ClusterAliveMask */ + 0x0, /* gcFEATURE_VALUE_G2D_DEC400_MINOR */ 0x40, /* gcFEATURE_VALUE_NNMadPerCore */ 0x8, /* gcFEATURE_VALUE_NNCoreCount */ 0x8, /* gcFEATURE_VALUE_NNCoreCount_INT8 */ @@ -1942,14 +2124,26 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x20, /* gcFEATURE_VALUE_PHYSICAL_VIP_SRAM_WIDTH_IN_BYTE */ 0x10, /* gcFEATURE_VALUE_EQUIVALENT_VIP_SRAM_WIDTH_INBYTE */ 0x8, /* gcFEATURE_VALUE_TP_ZRL_BITS */ + 0x5, /* gcFEATURE_VALUE_NN_ZRL_BITS */ 0x80, /* gcFEATURE_VALUE_LATENCY_HIDING_AT_FULL_AXI_BW */ 0x10, /* gcFEATURE_VALUE_AXI_BUS_WIDTH */ 0xf, /* gcFEATURE_VALUE_NN_KERNEL_X_SIZE */ 0xf, /* gcFEATURE_VALUE_NN_KERNEL_Y_SIZE */ + 0xf, /* gcFEATURE_VALUE_NN_FC_KERNEL_Y_SIZE */ 0xfffff, /* gcFEATURE_VALUE_NN_KERNEL_Z_SIZE */ 0xf, /* gcFEATURE_VALUE_NN_X_OFFSET */ 0xf, /* gcFEATURE_VALUE_NN_Y_OFFSET */ 0x40, /* gcFEATURE_VALUE_DDR_KERNEL_BURST_SIZE */ + 0x10, /* gcFEATURE_VALUE_OUTIMAGE_X_STRIDE_BITS */ + 0x0, /* gcFEATURE_VALUE_OUTIMAGE_Y_STRIDE_BITS */ + 0x10, /* gcFEATURE_VALUE_INIMAGE_X_STRIDE_BITS */ + 0x10, /* gcFEATURE_VALUE_IMIMAGE_Y_STRIDE_BITS */ + 0xd, /* gcFEATURE_VALUE_OUTIMAGE_X_SIZE_BITS */ + 0xd, /* gcFEATURE_VALUE_OUTIMAGE_Y_SIZE_BITS */ + 0xe, /* gcFEATURE_VALUE_OUTIMAGE_SIZE_BITS */ + 0xd, /* gcFEATURE_VALUE_IMAGE_X_SIZE_BITS */ + 0xd, /* gcFEATURE_VALUE_INIMAGE_Y_SIZE_BITS */ + 0x40, /* gcFEATURE_VALUE_MAX_TILE_X_SIZE */ 0x0, /* gcFEATURE_BIT_REG_FastClear */ 0x0, /* gcFEATURE_BIT_REG_SpecialAntiAliasing */ 0x1, /* gcFEATURE_BIT_REG_Pipe3D */ @@ -2191,6 +2385,7 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x1, /* gcFEATURE_BIT_RA_HZEZ_CLOCK_CONTROL */ 0x1, /* gcFEATURE_BIT_CACHE128B256BPERLINE */ 0x1, /* gcFEATURE_BIT_V4Compression */ + 0x0, /* gcFEATURE_BIT_DE2D_MAJOR_SUPER_TILE */ 0x0, /* gcFEATURE_BIT_PE2D_MAJOR_SUPER_TILE */ 0x1, /* gcFEATURE_BIT_PE_32BPC_COLORMASK_FIX */ 0x1, /* gcFEATURE_BIT_ALPHA_BLENDING_OPT */ @@ -2323,6 +2518,7 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_BIT_TX_NO_FIXED_FILTER */ 0x0, /* gcFEATURE_BIT_SHARE_Z */ 0x0, /* gcFEATURE_BIT_DE_2D_FAST_CLEAR */ + 0x0, /* gcFEATURE_BIT_DE_TILESTATUS_ROTATION_FIX */ 0x0, /* gcFEATURE_BIT_TX_CLEAR_PENDING_FIX */ 0x0, /* gcFEATURE_BIT_NO_HI1_L2 */ 0x0, /* gcFEATURE_BIT_USC_EVICT_CTRL_FIFO_FLOP_RESET_FIX */ @@ -2333,6 +2529,13 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_BIT_SH_VX2_FLOATING_MAD_FIX */ 0x0, /* gcFEATURE_BIT_TS_FC_VULKAN_SUPPORT */ 0x0, /* gcFEATURE_BIT_MSAA_FLOAT_64BIT */ + 0x0, /* gcFEATURE_BIT_INDIRECT_COMPUTE_ZERODIM_FIX */ + 0x0, /* gcFEATURE_BIT_Q_CHANNEL_SUPPORT */ + 0x0, /* gcFEATURE_BIT_MMU_PAGE_DESCRIPTOR */ + 0x0, /* gcFEATURE_BIT_YUV_LINEAR_TO_TILE_ROTATE */ + 0x0, /* gcFEATURE_BIT_VEC2_IMULIMAD32_SUPPORT */ + 0x0, /* gcFEATURE_BIT_VEC4_IMULIMAD32_SUPPORT */ + 0x0, /* gcFEATURE_BIT_VEC2_IDIVIMOD16_SUPPORT */ 0x0, /* gcFEATURE_BIT_VG_TS_CULLING */ 0x0, /* gcFEATURE_BIT_VG_FP25 */ 0x0, /* gcFEATURE_BIT_VG_AYUV_INPUT_OUTPUT */ @@ -2359,6 +2562,20 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_BIT_DC_MMU */ 0x0, /* gcFEATURE_BIT_DC_COMPRESSION */ 0x0, /* gcFEATURE_BIT_DC_QOS */ + 0x1, /* gcFEATURE_BIT_VIP_HW_FINAL_RELEASE */ + 0x1, /* gcFEATURE_BIT_NN_SINGLEPORT_ACCUMBUFFER */ + 0x1, /* gcFEATURE_BIT_NN_STRIDE_SUPPORT */ + 0x1, /* gcFEATURE_BIT_SWTILING_PHASE1 */ + 0x1, /* gcFEATURE_BIT_SWTILING_PHASE2 */ + 0x0, /* gcFEATURE_BIT_TP_SIMPLE_INT16 */ + 0x1, /* gcFEATURE_BIT_TP_REAL_INT16 */ + 0x1, /* gcFEATURE_BIT_TP_ROI_POOLING */ + 0x1, /* gcFEATURE_BIT_TP_MAX_POOLING_STRIDE1 */ + 0x1, /* gcFEATURE_BIT_TP_LRN */ + 0x1, /* gcFEATURE_BIT_TP_REORDER */ + 0x1, /* gcFEATURE_BIT_TF_QUANTIZATION */ + 0x0, /* gcFEATURE_BIT_NN_NONZERO_BORDER */ + 0x0, /* gcFEATURE_BIT_NN_MIRROR_BORDER */ 0x0, /* gcFEATURE_BIT_AI_GPU */ 0x0, /* gcFEATURE_BIT_EVIS_NO_ABSDIFF */ 0x0, /* gcFEATURE_BIT_EVIS_NO_BITREPLACE */ @@ -2371,128 +2588,139 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_BIT_EVIS_LERP_7OUTPUT */ 0x0, /* gcFEATURE_BIT_EVIS_ACCSQ_8OUTPUT */ 0x1, /* gcFEATURE_BIT_EVIS_VX2 */ - 0x1, /* gcFEATURE_BIT_NN_FLOAT */ 0x1, /* gcFEATURE_BIT_TP_ENGINE */ 0x1, /* gcFEATURE_BIT_VIP_V7 */ - 0x0, /* gcFEATURE_BIT_MCFE */ - 0x0, /* gcFEATURE_BIT_NN_INTERLEVE8 */ - 0x1, /* gcFEATURE_BIT_TP_REORDER */ - 0x1, /* gcFEATURE_BIT_TP_LRN */ - 0x1, /* gcFEATURE_BIT_TP_MAX_POOLING_STRIDE1 */ - 0x0, /* gcFEATURE_BIT_NN_FP16_ALU */ - 0x1, /* gcFEATURE_BIT_NN_INT16_ALU */ - 0x1, /* gcFEATURE_BIT_TP_ROI_POOLING */ - 0x1, /* gcFEATURE_BIT_NN_ZDP3 */ + 0x0, /* gcFEATURE_BIT_TP_TENSOR_ADD_MUL */ + 0x0, /* gcFEATURE_BIT_NN_DEPTHWISE_INT16XINT8 */ + 0x0, /* gcFEATURE_BIT_TP_SOFTMAX */ + 0x0, /* gcFEATURE_BIT_NN_23BITS_POST_MULTIPLIER_VIP_V7 */ + 0x0, /* gcFEATURE_BIT_TP_23BITS_POST_MULTIPLIER_VIP_V7 */ + 0x0, /* gcFEATURE_BIT_HYBRID_MODE_VIP_V7 */ 0x0, /* gcFEATURE_BIT_NN_ZDP6 */ 0x0, /* gcFEATURE_BIT_NN_XYDP9 */ - 0x1, /* gcFEATURE_BIT_NN_INT8_SCALE */ - 0x1, /* gcFEATURE_BIT_NN_POWER_ISOLATION */ - 0x1, /* gcFEATURE_BIT_SWTILING_PHASE1 */ - 0x1, /* gcFEATURE_BIT_TF_QUANTIZATION */ - 0x0, /* gcFEATURE_BIT_TP_SIMPLE_INT16 */ - 0x1, /* gcFEATURE_BIT_TP_REAL_INT16 */ - 0x0, /* gcFEATURE_BIT_TP_BFLOAT16 */ 0x1, /* gcFEATURE_BIT_NN_FIRST_PIXEL_POOLING */ - 0x1, /* gcFEATURE_BIT_SWTILING_PHASE2 */ - 0x1, /* gcFEATURE_BIT_NN_STRIDE_SUPPORT */ + 0x1, /* gcFEATURE_BIT_NN_ZDP3 */ 0x1, /* gcFEATURE_BIT_NN_XYDP6 */ - 0x1, /* gcFEATURE_BIT_TP_REORDER_FIX */ - 0x1, /* gcFEATURE_BIT_NN_CONV1x1_PERF_FIX */ - 0x0, /* gcFEATURE_BIT_NN_CACHELINE_MODE_PERF_FIX */ - 0x0, /* gcFEATURE_BIT_NN_PER3DTILE_BUBBLE_FIX */ - 0x1, /* gcFEATURE_BIT_NN_CONVOUT_FIFO_DEPTH_FIX */ 0x0, /* gcFEATURE_BIT_SWTILING_PHASE3 */ + 0x0, /* gcFEATURE_BIT_MCFE */ 0x0, /* gcFEATURE_BIT_USC_STAY_LRU */ - 0x0, /* gcFEATURE_BIT_NN_NONZERO_MIRROR_BORDER */ + 0x0, /* gcFEATURE_BIT_COEF_COMPRESSION_ENHANCEMENT */ + 0x0, /* gcFEATURE_BIT_TP_COEF_COMPRESSION_ENHANCEMENT */ 0x0, /* gcFEATURE_BIT_NN_COEF_DECOMPRESS_PERF2X */ + 0x1, /* gcFEATURE_BIT_OCB_COUNTER */ + 0x0, /* gcFEATURE_BIT_SCALER */ + 0x0, /* gcFEATURE_BIT_SCALER_4K */ 0x0, /* gcFEATURE_BIT_INPUT_4BIT */ - 0x0, /* gcFEATURE_BIT_COEF_COMPRESSION_ENHANCEMENT */ + 0x0, /* gcFEATURE_BIT_NN_NO_Z_LOCATION_OFFSET */ + 0x1, /* gcFEATURE_BIT_OCB_REMAP_PHYSICAL_ADDRESS */ + 0x0, /* gcFEATURE_BIT_NN_SLOW_OUTPUT */ + 0x1, /* gcFEATURE_BIT_NO_NARROW_POST_PROCESS_PIPE */ + 0x0, /* gcFEATURE_BIT_TP_NN_PROBE */ + 0x0, /* gcFEATURE_BIT_NN_DEPTHWISE_SUPPORT */ + 0x0, /* gcFEATURE_BIT_NN_XYDP0 */ + 0x0, /* gcFEATURE_BIT_NN_WRITE_WITHOUT_USC */ + 0x0, /* gcFEATURE_BIT_NN_HW_LIMITATION_NATIVE_KER_1x2_2x1 */ + 0x0, /* gcFEATURE_BIT_NN_SLICE_PADDING_TO_64BYTE_ALIGN */ + 0x0, /* gcFEATURE_BIT_NN_DW_1x1_CONV_MERGE */ + 0x0, /* gcFEATURE_BIT_TP_BFLOAT16 */ + 0x0, /* gcFEATURE_BIT_TP_23BITS_POST_MULTIPLIER */ + 0x0, /* gcFEATURE_BIT_NN_TRANSPOSE */ + 0x0, /* gcFEATURE_BIT_USE_SINGLE_PORT_VIPSRAM */ + 0x0, /* gcFEATURE_BIT_NN_LEAKY_RELU */ + 0x0, /* gcFEATURE_BIT_NN_PRELU */ + 0x0, /* gcFEATURE_BIT_NN_PER_CHANNEL_QUANT */ + 0x0, /* gcFEATURE_BIT_NN_PER_CHANNEL_QUANT_ASYM */ + 0x0, /* gcFEATURE_BIT_NN_ASYMMETRIC_INT8 */ + 0x0, /* gcFEATURE_BIT_NN_FLOAT_POST_MULT */ + 0x0, /* gcFEATURE_BIT_PRELU_LEAKLY_RELU_CLAMP */ + 0x0, /* gcFEATURE_BIT_TPLITE_BFLOAT16 */ + 0x0, /* gcFEATURE_BIT_PREPROCESS_IMG_BUF_640BYTE_LIMIT */ + 0x0, /* gcFEATURE_BIT_TP_KERNEL_1BYTE_ALGIN */ + 0x0, /* gcFEATURE_BIT_BFLOAT_COEF_COMPRESSION_ZERO_COEFBIT14_INVERSE */ + 0x0, /* gcFEATURE_BIT_NN_COMPRESSION_BYPASSS */ + 0x0, /* gcFEATURE_BIT_TP_3_USC */ + 0x0, /* gcFEATURE_BIT_BFP_COEF_AUTO_PAD_INCOMPLETE_ZERO_IN_KZ_PLANE */ + 0x0, /* gcFEATURE_BIT_NN_NATIVE_STRIDE_TWO */ + 0x0, /* gcFEATURE_BIT_NN_TENSOR_ADD */ + 0x0, /* gcFEATURE_BIT_NN_FLOAT32_IO */ + 0x0, /* gcFEATURE_BIT_TP_FLOAT32_IO */ + 0x0, /* gcFEATURE_BIT_NN_SMALL_BATCH_PHASE2 */ + 0x0, /* gcFEATURE_BIT_TILE_ACCESS_CAPABILITY */ + 0x0, /* gcFEATURE_BIT_FAST_DP3_PREPROCESSOR */ + 0x0, /* gcFEATURE_BIT_DEPTHWISE_SUPPORT_16BIT_FORMAT */ + 0x0, /* gcFEATURE_BIT_NN_SUPPORT_ALU_LUT */ + 0x0, /* gcFEATURE_BIT_NN_ENHANCED_MAX_POOLING */ + 0x0, /* gcFEATURE_BIT_NN_TRANSPOSE_PHASE2 */ + 0x0, /* gcFEATURE_BIT_TPLITE_SUPPORT_TP_DATA_TRANSPOSE */ + 0x0, /* gcFEATURE_BIT_NN_SUPPORT_CONV_1D */ + 0x0, /* gcFEATURE_BIT_USE_VIPSRAM_FOR_KERNEL_STREAMING */ + 0x0, /* gcFEATURE_BIT_VIP_DEC400 */ + 0x0, /* gcFEATURE_BIT_NN_PER3DTILE_BUBBLE_FIX */ + 0x0, /* gcFEATURE_BIT_NN_CACHELINE_MODE_PERF_FIX */ + 0x1, /* gcFEATURE_BIT_NN_CONV1x1_PERF_FIX */ + 0x1, /* gcFEATURE_BIT_TP_REORDER_FIX */ + 0x1, /* gcFEATURE_BIT_NN_CONVOUT_FIFO_DEPTH_FIX */ 0x1, /* gcFEATURE_BIT_NN_ZXDP3_KERNEL_READ_CONFLICT_FIX */ 0x0, /* gcFEATURE_BIT_NN_ZDP3_NO_COMPRESS_FIX */ 0x1, /* gcFEATURE_BIT_NN_ASYNC_COPY_PERF_FIX */ - 0x1, /* gcFEATURE_BIT_OCB_COUNTER */ - 0x0, /* gcFEATURE_BIT_NN_XYDP0 */ - 0x0, /* gcFEATURE_BIT_ZRL_7BIT */ + 0x1, /* gcFEATURE_BIT_HI_REORDER_FIX */ + 0x1, /* gcFEATURE_BIT_INCORRECT_WR_REQ_TO_USC_BETWEEN_REORDER_AND_NORMAL_LAYER_FIX */ + 0x0, /* gcFEATURE_BIT_TP_REORDER_LAYER_SUSPEND_FIX */ 0x1, /* gcFEATURE_BIT_NN_ASYNC_COPY_MERGE_FIX */ - 0x0, /* gcFEATURE_BIT_NN_SMALLBATCH_PHASE1 */ - 0x0, /* gcFEATURE_BIT_TP_SMALLBATCH_PHASE1 */ - 0x0, /* gcFEATURE_BIT_SCALER */ - 0x0, /* gcFEATURE_BIT_SCALER_4K */ + 0x0, /* gcFEATURE_BIT_USC_INVALIDATE_CACHE_LINE_FIX */ 0x0, /* gcFEATURE_BIT_NN_REQ_SLOWARBITRATION_FIX */ - 0x0, /* gcFEATURE_BIT_IMAGE_PARTIAL_CACHE */ + 0x0, /* gcFEATURE_BIT_IMAGE_PARTIAL_CACHE_FIX */ 0x0, /* gcFEATURE_BIT_FULLCACHE_KERNELHEAD_FIX */ - 0x1, /* gcFEATURE_BIT_NN_SINGLEPORT_ACCUMBUFFER */ - 0x0, /* gcFEATURE_BIT_NN_SMALLBATCH */ - 0x0, /* gcFEATURE_BIT_TP_SMALLBATCH */ - 0x0, /* gcFEATURE_BIT_ZRL_8BIT */ - 0x0, /* gcFEATURE_BIT_NN_DEPTHWISE_SUPPORT */ - 0x0, /* gcFEATURE_BIT_NN_WRITE_WITHOUT_USC */ 0x0, /* gcFEATURE_BIT_NN_ZDP_INIMAGE_SIZE_FIX */ - 0x1, /* gcFEATURE_BIT_HI_REORDER_FIX */ - 0x1, /* gcFEATURE_BIT_INCORRECT_WR_REQ_TO_USC_BETWEEN_REORDER_AND_NORMAL_LAYER_FIX */ - 0x0, /* gcFEATURE_BIT_TP_COEF_COMPRESSION_ENHANCEMENT */ - 0x0, /* gcFEATURE_BIT_VIP_DEC400 */ - 0x0, /* gcFEATURE_BIT_IMAGE_NOT_PACKED_IN_SRAM_FIX */ 0x0, /* gcFEATURE_BIT_IDLE_BEFORE_FLUSH_COMPLETE_FIX */ 0x1, /* gcFEATURE_BIT_NO_FLUSH_USC_FIX */ + 0x1, /* gcFEATURE_BIT_SMALL_BATCH_FLOPS_RESET_FIX */ + 0x0, /* gcFEATURE_BIT_SMALL_BATCH_DISBLE_FIX */ + 0x0, /* gcFEATURE_BIT_OUTPUT_CONVERT_UINT8_INT8_TO_UINT16_INT16_FIX */ + 0x0, /* gcFEATURE_BIT_IMAGE_NOT_PACKED_IN_SRAM_FIX */ 0x1, /* gcFEATURE_BIT_COEF_DELTA_CORD_OVERFLOW_ZRL_8BIT_FIX */ - 0x0, /* gcFEATURE_BIT_XY_OFFSET_LIMITATION_FIX */ - 0x0, /* gcFEATURE_BIT_USC_INVALIDATE_CACHE_LINE_FIX */ 0x0, /* gcFEATURE_BIT_LOW_EFFICIENCY_OF_ID_WRITE_IMGBUF_FIX */ - 0x1, /* gcFEATURE_BIT_KERNEL_PER_CORE_LESS_THAN_THIRD_COEF_BUFF_DEPTH_FIX */ + 0x1, /* gcFEATURE_BIT_KERNEL_VIP_SRAM_READ_BW_LIMITATION_FIX */ 0x0, /* gcFEATURE_BIT_USC_BOTTLENECK_FIX */ + 0x1, /* gcFEATURE_BIT_KERNEL_PER_CORE_LESS_THAN_THIRD_COEF_BUFF_DEPTH_FIX */ 0x0, /* gcFEATURE_BIT_KERNEL_SIZE_WASTE_IN_PARTIAL_MODE_FIX */ - 0x0, /* gcFEATURE_BIT_FULLCACHE_KERNEL_INTERLEAVE_FIX */ - 0x0, /* gcFEATURE_BIT_TP_REORDER_LAYER_SUSPEND_FIX */ - 0x1, /* gcFEATURE_BIT_KERNEL_VIP_SRAM_READ_BW_LIMITATION_FIX */ - 0x1, /* gcFEATURE_BIT_IMG_POP_PIPELINE_PAUSE_FIX */ - 0x0, /* gcFEATURE_BIT_DR_JD_DIFF_CONDITION_FOR_CACHELINE_MODE_PRE_FIX */ - 0x1, /* gcFEATURE_BIT_OUTIMAGE_X_BITWIDTH_LIMIT_FOR_NN_TRANSPOSE_FIX */ - 0x1, /* gcFEATURE_BIT_SMALL_BATCH_FLOPS_RESET_FIX */ - 0x0, /* gcFEATURE_BIT_SMALL_BATCH_DISBLE_FIX */ - 0x1, /* gcFEATURE_BIT_NEGATIVE_POST_SHIFT_FIX */ - 0x0, /* gcFEATURE_BIT_NN_COMMAND_KERNEL_REQUEST_CONFICT_FIX */ - 0x1, /* gcFEATURE_BIT_OCB_REMAP_PHYSICAL_ADDRESS */ - 0x0, /* gcFEATURE_BIT_NN_NO_Z_LOCATION_OFFSET */ - 0x0, /* gcFEATURE_BIT_NN_LEAKY_RELU */ - 0x0, /* gcFEATURE_BIT_NN_PRELU */ - 0x0, /* gcFEATURE_BIT_NN_PER_CHANNEL_QUANT */ - 0x0, /* gcFEATURE_BIT_NN_PER_CHANNEL_QUANT_ASYM */ - 0x0, /* gcFEATURE_BIT_NN_NATIVE_STRIDE_TWO */ - 0x0, /* gcFEATURE_BIT_NN_TENSOR_ADD */ - 0x0, /* gcFEATURE_BIT_NN_FLOAT_POST_MULT */ - 0x0, /* gcFEATURE_BIT_NN_SLICE_PADDING_TO_64BYTE_ALIGN */ - 0x0, /* gcFEATURE_BIT_NN_DW_1x1_CONV_MERGE */ - 0x0, /* gcFEATURE_BIT_NN_SLOW_OUTPUT */ - 0x1, /* gcFEATURE_BIT_NO_NARROW_POST_PROCESS_PIPE */ - 0x0, /* gcFEATURE_BIT_TP_NN_PROBE */ - 0x0, /* gcFEATURE_BIT_TP_23BITS_POST_MULTIPLIER */ - 0x0, /* gcFEATURE_BIT_NN_TRANSPOSE */ + 0x0, /* gcFEATURE_BIT_NN_COMMAND_KERNEL_REQUEST_CONFICT_FIX */ + 0x0, /* gcFEATURE_BIT_TP_REORDER_INTILE_X_SIZE_512_FIX */ + 0x1, /* gcFEATURE_BIT_IMG_POP_PIPELINE_PAUSE_FIX */ + 0x0, /* gcFEATURE_BIT_FULLCACHE_KERNEL_INTERLEAVE_FIX */ + 0x0, /* gcFEATURE_BIT_V8_SINGLE_PORT_ACCUMULATION_BUFFER_RW_CONFICT_ZERO_SKIP_PERF_FIX */ + 0x0, /* gcFEATURE_BIT_V8_ACCUMLATION_READ_OUT_HAS_BUBBLES_PERF_FIX */ + 0x1, /* gcFEATURE_BIT_DEPTHWISE_NEIGHBOR_IMG_DATA_TRANSFER_NOT_EFFICIENT_FIX */ + 0x0, /* gcFEATURE_BIT_DR_JD_DIFF_CONDITION_FOR_CACHELINE_MODE_PRE_FIX */ + 0x0, /* gcFEATURE_BIT_TP_ACCESS_VIPSRAM_OT_IS_ONE_FIX */ 0x0, /* gcFEATURE_BIT_EVIS2_FLOP_RESET_FIX */ + 0x1, /* gcFEATURE_BIT_OUTIMAGE_X_BITWIDTH_LIMIT_FOR_NN_TRANSPOSE_FIX */ 0x0, /* gcFEATURE_BIT_USC_ASYNC_CP_RTN_FLOP_RESET_FIX */ - 0x0, /* gcFEATURE_BIT_DDR_BURST_LEN_256B */ + 0x1, /* gcFEATURE_BIT_IMG_ADDR_NOT_WRAP_IF_OVER_OCB_ADDR_FIX */ + 0x1, /* gcFEATURE_BIT_NEGATIVE_POST_SHIFT_FIX */ + 0x0, /* gcFEATURE_BIT_INIMAGE_2DTILE_NOT_LESS_160PIXEL_FIX */ 0x1, /* gcFEATURE_BIT_IMG_CAHCE_MODE_MUST_0_IN_IMG_DIRECT_MODE_FIX */ - 0x0, /* gcFEATURE_BIT_USE_SINGLE_PORT_VIPSRAM */ - 0x0, /* gcFEATURE_BIT_NN_ASYMMETRIC_INT8 */ - 0x1, /* gcFEATURE_BIT_DEPTHWISE_NEIGHBOR_IMG_DATA_TRANSFER_NOT_EFFICIENT_FIX */ - 0x0, /* gcFEATURE_BIT_PRELU_LEAKLY_RELU_CLAMP */ - 0x0, /* gcFEATURE_BIT_TP_FLOAT32_IO */ - 0x0, /* gcFEATURE_BIT_NN_FLOAT32_IO */ - 0x0, /* gcFEATURE_BIT_NN_SMALL_BATCH_PHASE2 */ - 0x0, /* gcFEATURE_BIT_TILE_ACCESS_CAPABILITY */ - 0x0, /* gcFEATURE_BIT_FAST_DP3_PREPROCESSOR */ - 0x0, /* gcFEATURE_BIT_NN_COMPRESSION_BYPASSS */ - 0x0, /* gcFEATURE_BIT_BFLOAT_KERNEL_COMPRESSION_ZERO_SKIP_FIX */ - 0x0, /* gcFEATURE_BIT_TP_3_USC */ - 0x0, /* gcFEATURE_BIT_TP_KERNEL_1BYTE_ALGIN */ - 0x0, /* gcFEATURE_BIT_TPLITE_BFLOAT16 */ - 0x0, /* gcFEATURE_BIT_PREPROCESS_IMG_BUF_640BYTE_LIMIT */ - 0x0, /* gcFEATURE_BIT_V8_ACCUMLATION_READ_OUT_HAS_BUBBLES_PERF_FIX */ - 0x0, /* gcFEATURE_BIT_V8_SINGLE_PORT_ACCUMULATION_BUFFER_RW_CONFICT_ZERO_SKIP_PERF_FIX */ 0x0, /* gcFEATURE_BIT_BURST_COLLECT_DUMMY_DATA_WASTE_CYCLES_FIX */ 0x0, /* gcFEATURE_BIT_INIMG_NOT_64BYTE_ALIGN_CACHELINE_MODE_FIX */ - 0x0, /* gcFEATURE_BIT_TP_ACCESS_VIPSRAM_OT_IS_ONE_FIX */ - 0x1, /* gcFEATURE_BIT_VIP_HW_FINAL_RELEASE */ + 0x1, /* gcFEATURE_BIT_TP_FC_FLOAT_LAST_PIXEL_NEGATIVE_0_FIX */ + 0x1, /* gcFEATURE_BIT_NN_WASET_COEF_READ_WRITE_BANDWIDTH_128BYTE_VIPSRAM_IN_FULL_PATIAL_CACHE_MODE */ + 0x1, /* gcFEATURE_BIT_NN_IN_TILE_DATA_IS_ALL_PAD_FIX */ + 0x1, /* gcFEATURE_BIT_TP_FC_KERNEL_STREAM_MUST_LESS_THAN_OR_EQUAL_TO_64BYTE_WHEN_1BYTE_ALGINE_FIX */ + 0x0, /* gcFEATURE_BIT_NN_INTERLEVE8 */ + 0x0, /* gcFEATURE_BIT_NN_FP16_ALU */ + 0x1, /* gcFEATURE_BIT_NN_INT16_ALU */ + 0x1, /* gcFEATURE_BIT_NN_INT8_SCALE */ + 0x1, /* gcFEATURE_BIT_NN_POWER_ISOLATION */ + 0x0, /* gcFEATURE_BIT_ZRL_7BIT */ + 0x0, /* gcFEATURE_BIT_NN_SMALLBATCH_PHASE1 */ + 0x0, /* gcFEATURE_BIT_TP_SMALLBATCH_PHASE1 */ + 0x0, /* gcFEATURE_BIT_NN_SMALLBATCH */ + 0x0, /* gcFEATURE_BIT_TP_SMALLBATCH */ + 0x0, /* gcFEATURE_BIT_ZRL_8BIT */ + 0x0, /* gcFEATURE_BIT_DDR_BURST_LEN_256B */ + 0x0, /* gcFEATURE_BIT_XY_OFFSET_LIMITATION_FIX */ + 0x0, /* gcFEATURE_BIT_NN_NONZERO_MIRROR_BORDER */ + 0x0, /* gcFEATURE_BIT_IMAGE_PARTIAL_CACHE */ }, /* vip9000nano-si */ { @@ -2511,13 +2739,23 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x140, /* gcFEATURE_VALUE_NumberOfConstants */ 0x1, /* gcFEATURE_VALUE_CoreCount */ 0x10, /* gcFEATURE_VALUE_LocalStorageSize */ + 0x0, /* gcFEATURE_VALUE_LocalStorageSize_1 */ + 0x0, /* gcFEATURE_VALUE_LocalStorageSize_2 */ 0x10, /* gcFEATURE_VALUE_L1CacheSize */ + 0x0, /* gcFEATURE_VALUE_L1CacheSize_1 */ + 0x0, /* gcFEATURE_VALUE_L1CacheSize_2 */ 0x200, /* gcFEATURE_VALUE_InstructionMemorySize */ 0x14, /* gcFEATURE_VALUE_ShaderPCLength */ 0x10, /* gcFEATURE_VALUE_USC_MAX_PAGES */ + 0x0, /* gcFEATURE_VALUE_USC_MAX_PAGES_1 */ + 0x0, /* gcFEATURE_VALUE_USC_MAX_PAGES_2 */ 0x1, /* gcFEATURE_VALUE_NumPixelPipes */ 0x1, /* gcFEATURE_VALUE_USC_CACHE_CONTROLLERS */ + 0x0, /* gcFEATURE_VALUE_USC_CACHE_CONTROLLERS_1 */ + 0x0, /* gcFEATURE_VALUE_USC_CACHE_CONTROLLERS_2 */ 0x2, /* gcFEATURE_VALUE_USC_BANKS */ + 0x0, /* gcFEATURE_VALUE_USC_BANKS_1 */ + 0x0, /* gcFEATURE_VALUE_USC_BANKS_2 */ 0x8, /* gcFEATURE_VALUE_Streams */ 0x10, /* gcFEATURE_VALUE_VaryingCount */ 0x400, /* gcFEATURE_VALUE_VertexOutputBufferSize */ @@ -2526,6 +2764,7 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_VALUE_NumResolvePipes */ 0x100, /* gcFEATURE_VALUE_RESULT_WINDOW_MAX_SIZE */ 0x0, /* gcFEATURE_VALUE_ClusterAliveMask */ + 0x0, /* gcFEATURE_VALUE_G2D_DEC400_MINOR */ 0x40, /* gcFEATURE_VALUE_NNMadPerCore */ 0x4, /* gcFEATURE_VALUE_NNCoreCount */ 0x4, /* gcFEATURE_VALUE_NNCoreCount_INT8 */ @@ -2550,14 +2789,26 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x40, /* gcFEATURE_VALUE_PHYSICAL_VIP_SRAM_WIDTH_IN_BYTE */ 0x10, /* gcFEATURE_VALUE_EQUIVALENT_VIP_SRAM_WIDTH_INBYTE */ 0x8, /* gcFEATURE_VALUE_TP_ZRL_BITS */ + 0x8, /* gcFEATURE_VALUE_NN_ZRL_BITS */ 0x80, /* gcFEATURE_VALUE_LATENCY_HIDING_AT_FULL_AXI_BW */ 0x10, /* gcFEATURE_VALUE_AXI_BUS_WIDTH */ 0xf, /* gcFEATURE_VALUE_NN_KERNEL_X_SIZE */ 0xf, /* gcFEATURE_VALUE_NN_KERNEL_Y_SIZE */ + 0xf, /* gcFEATURE_VALUE_NN_FC_KERNEL_Y_SIZE */ 0xfffff, /* gcFEATURE_VALUE_NN_KERNEL_Z_SIZE */ 0x1f, /* gcFEATURE_VALUE_NN_X_OFFSET */ 0x1f, /* gcFEATURE_VALUE_NN_Y_OFFSET */ 0x100, /* gcFEATURE_VALUE_DDR_KERNEL_BURST_SIZE */ + 0x10, /* gcFEATURE_VALUE_OUTIMAGE_X_STRIDE_BITS */ + 0x10, /* gcFEATURE_VALUE_OUTIMAGE_Y_STRIDE_BITS */ + 0x10, /* gcFEATURE_VALUE_INIMAGE_X_STRIDE_BITS */ + 0x10, /* gcFEATURE_VALUE_IMIMAGE_Y_STRIDE_BITS */ + 0xd, /* gcFEATURE_VALUE_OUTIMAGE_X_SIZE_BITS */ + 0xd, /* gcFEATURE_VALUE_OUTIMAGE_Y_SIZE_BITS */ + 0xe, /* gcFEATURE_VALUE_OUTIMAGE_SIZE_BITS */ + 0xd, /* gcFEATURE_VALUE_IMAGE_X_SIZE_BITS */ + 0xd, /* gcFEATURE_VALUE_INIMAGE_Y_SIZE_BITS */ + 0x40, /* gcFEATURE_VALUE_MAX_TILE_X_SIZE */ 0x0, /* gcFEATURE_BIT_REG_FastClear */ 0x0, /* gcFEATURE_BIT_REG_SpecialAntiAliasing */ 0x1, /* gcFEATURE_BIT_REG_Pipe3D */ @@ -2799,6 +3050,7 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x1, /* gcFEATURE_BIT_RA_HZEZ_CLOCK_CONTROL */ 0x1, /* gcFEATURE_BIT_CACHE128B256BPERLINE */ 0x1, /* gcFEATURE_BIT_V4Compression */ + 0x0, /* gcFEATURE_BIT_DE2D_MAJOR_SUPER_TILE */ 0x0, /* gcFEATURE_BIT_PE2D_MAJOR_SUPER_TILE */ 0x1, /* gcFEATURE_BIT_PE_32BPC_COLORMASK_FIX */ 0x1, /* gcFEATURE_BIT_ALPHA_BLENDING_OPT */ @@ -2931,6 +3183,7 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_BIT_TX_NO_FIXED_FILTER */ 0x0, /* gcFEATURE_BIT_SHARE_Z */ 0x0, /* gcFEATURE_BIT_DE_2D_FAST_CLEAR */ + 0x0, /* gcFEATURE_BIT_DE_TILESTATUS_ROTATION_FIX */ 0x0, /* gcFEATURE_BIT_TX_CLEAR_PENDING_FIX */ 0x0, /* gcFEATURE_BIT_NO_HI1_L2 */ 0x0, /* gcFEATURE_BIT_USC_EVICT_CTRL_FIFO_FLOP_RESET_FIX */ @@ -2941,6 +3194,13 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_BIT_SH_VX2_FLOATING_MAD_FIX */ 0x0, /* gcFEATURE_BIT_TS_FC_VULKAN_SUPPORT */ 0x0, /* gcFEATURE_BIT_MSAA_FLOAT_64BIT */ + 0x0, /* gcFEATURE_BIT_INDIRECT_COMPUTE_ZERODIM_FIX */ + 0x0, /* gcFEATURE_BIT_Q_CHANNEL_SUPPORT */ + 0x0, /* gcFEATURE_BIT_MMU_PAGE_DESCRIPTOR */ + 0x0, /* gcFEATURE_BIT_YUV_LINEAR_TO_TILE_ROTATE */ + 0x0, /* gcFEATURE_BIT_VEC2_IMULIMAD32_SUPPORT */ + 0x0, /* gcFEATURE_BIT_VEC4_IMULIMAD32_SUPPORT */ + 0x0, /* gcFEATURE_BIT_VEC2_IDIVIMOD16_SUPPORT */ 0x0, /* gcFEATURE_BIT_VG_TS_CULLING */ 0x0, /* gcFEATURE_BIT_VG_FP25 */ 0x0, /* gcFEATURE_BIT_VG_AYUV_INPUT_OUTPUT */ @@ -2967,6 +3227,20 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_BIT_DC_MMU */ 0x0, /* gcFEATURE_BIT_DC_COMPRESSION */ 0x0, /* gcFEATURE_BIT_DC_QOS */ + 0x1, /* gcFEATURE_BIT_VIP_HW_FINAL_RELEASE */ + 0x1, /* gcFEATURE_BIT_NN_SINGLEPORT_ACCUMBUFFER */ + 0x1, /* gcFEATURE_BIT_NN_STRIDE_SUPPORT */ + 0x1, /* gcFEATURE_BIT_SWTILING_PHASE1 */ + 0x1, /* gcFEATURE_BIT_SWTILING_PHASE2 */ + 0x0, /* gcFEATURE_BIT_TP_SIMPLE_INT16 */ + 0x1, /* gcFEATURE_BIT_TP_REAL_INT16 */ + 0x1, /* gcFEATURE_BIT_TP_ROI_POOLING */ + 0x1, /* gcFEATURE_BIT_TP_MAX_POOLING_STRIDE1 */ + 0x1, /* gcFEATURE_BIT_TP_LRN */ + 0x1, /* gcFEATURE_BIT_TP_REORDER */ + 0x1, /* gcFEATURE_BIT_TF_QUANTIZATION */ + 0x0, /* gcFEATURE_BIT_NN_NONZERO_BORDER */ + 0x1, /* gcFEATURE_BIT_NN_MIRROR_BORDER */ 0x0, /* gcFEATURE_BIT_AI_GPU */ 0x0, /* gcFEATURE_BIT_EVIS_NO_ABSDIFF */ 0x0, /* gcFEATURE_BIT_EVIS_NO_BITREPLACE */ @@ -2979,128 +3253,139 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_BIT_EVIS_LERP_7OUTPUT */ 0x0, /* gcFEATURE_BIT_EVIS_ACCSQ_8OUTPUT */ 0x1, /* gcFEATURE_BIT_EVIS_VX2 */ - 0x1, /* gcFEATURE_BIT_NN_FLOAT */ 0x1, /* gcFEATURE_BIT_TP_ENGINE */ 0x1, /* gcFEATURE_BIT_VIP_V7 */ - 0x0, /* gcFEATURE_BIT_MCFE */ - 0x0, /* gcFEATURE_BIT_NN_INTERLEVE8 */ - 0x1, /* gcFEATURE_BIT_TP_REORDER */ - 0x1, /* gcFEATURE_BIT_TP_LRN */ - 0x1, /* gcFEATURE_BIT_TP_MAX_POOLING_STRIDE1 */ - 0x0, /* gcFEATURE_BIT_NN_FP16_ALU */ - 0x1, /* gcFEATURE_BIT_NN_INT16_ALU */ - 0x1, /* gcFEATURE_BIT_TP_ROI_POOLING */ - 0x1, /* gcFEATURE_BIT_NN_ZDP3 */ + 0x0, /* gcFEATURE_BIT_TP_TENSOR_ADD_MUL */ + 0x0, /* gcFEATURE_BIT_NN_DEPTHWISE_INT16XINT8 */ + 0x0, /* gcFEATURE_BIT_TP_SOFTMAX */ + 0x0, /* gcFEATURE_BIT_NN_23BITS_POST_MULTIPLIER_VIP_V7 */ + 0x0, /* gcFEATURE_BIT_TP_23BITS_POST_MULTIPLIER_VIP_V7 */ + 0x0, /* gcFEATURE_BIT_HYBRID_MODE_VIP_V7 */ 0x0, /* gcFEATURE_BIT_NN_ZDP6 */ 0x0, /* gcFEATURE_BIT_NN_XYDP9 */ - 0x1, /* gcFEATURE_BIT_NN_INT8_SCALE */ - 0x1, /* gcFEATURE_BIT_NN_POWER_ISOLATION */ - 0x1, /* gcFEATURE_BIT_SWTILING_PHASE1 */ - 0x1, /* gcFEATURE_BIT_TF_QUANTIZATION */ - 0x0, /* gcFEATURE_BIT_TP_SIMPLE_INT16 */ - 0x1, /* gcFEATURE_BIT_TP_REAL_INT16 */ - 0x0, /* gcFEATURE_BIT_TP_BFLOAT16 */ 0x1, /* gcFEATURE_BIT_NN_FIRST_PIXEL_POOLING */ - 0x1, /* gcFEATURE_BIT_SWTILING_PHASE2 */ - 0x1, /* gcFEATURE_BIT_NN_STRIDE_SUPPORT */ + 0x1, /* gcFEATURE_BIT_NN_ZDP3 */ 0x0, /* gcFEATURE_BIT_NN_XYDP6 */ - 0x1, /* gcFEATURE_BIT_TP_REORDER_FIX */ - 0x1, /* gcFEATURE_BIT_NN_CONV1x1_PERF_FIX */ - 0x1, /* gcFEATURE_BIT_NN_CACHELINE_MODE_PERF_FIX */ - 0x1, /* gcFEATURE_BIT_NN_PER3DTILE_BUBBLE_FIX */ - 0x1, /* gcFEATURE_BIT_NN_CONVOUT_FIFO_DEPTH_FIX */ 0x1, /* gcFEATURE_BIT_SWTILING_PHASE3 */ + 0x0, /* gcFEATURE_BIT_MCFE */ 0x0, /* gcFEATURE_BIT_USC_STAY_LRU */ - 0x1, /* gcFEATURE_BIT_NN_NONZERO_MIRROR_BORDER */ + 0x1, /* gcFEATURE_BIT_COEF_COMPRESSION_ENHANCEMENT */ + 0x1, /* gcFEATURE_BIT_TP_COEF_COMPRESSION_ENHANCEMENT */ 0x1, /* gcFEATURE_BIT_NN_COEF_DECOMPRESS_PERF2X */ + 0x1, /* gcFEATURE_BIT_OCB_COUNTER */ + 0x0, /* gcFEATURE_BIT_SCALER */ + 0x0, /* gcFEATURE_BIT_SCALER_4K */ 0x0, /* gcFEATURE_BIT_INPUT_4BIT */ - 0x1, /* gcFEATURE_BIT_COEF_COMPRESSION_ENHANCEMENT */ + 0x1, /* gcFEATURE_BIT_NN_NO_Z_LOCATION_OFFSET */ + 0x1, /* gcFEATURE_BIT_OCB_REMAP_PHYSICAL_ADDRESS */ + 0x1, /* gcFEATURE_BIT_NN_SLOW_OUTPUT */ + 0x1, /* gcFEATURE_BIT_NO_NARROW_POST_PROCESS_PIPE */ + 0x1, /* gcFEATURE_BIT_TP_NN_PROBE */ + 0x1, /* gcFEATURE_BIT_NN_DEPTHWISE_SUPPORT */ + 0x1, /* gcFEATURE_BIT_NN_XYDP0 */ + 0x1, /* gcFEATURE_BIT_NN_WRITE_WITHOUT_USC */ + 0x1, /* gcFEATURE_BIT_NN_HW_LIMITATION_NATIVE_KER_1x2_2x1 */ + 0x1, /* gcFEATURE_BIT_NN_SLICE_PADDING_TO_64BYTE_ALIGN */ + 0x0, /* gcFEATURE_BIT_NN_DW_1x1_CONV_MERGE */ + 0x0, /* gcFEATURE_BIT_TP_BFLOAT16 */ + 0x0, /* gcFEATURE_BIT_TP_23BITS_POST_MULTIPLIER */ + 0x1, /* gcFEATURE_BIT_NN_TRANSPOSE */ + 0x1, /* gcFEATURE_BIT_USE_SINGLE_PORT_VIPSRAM */ + 0x0, /* gcFEATURE_BIT_NN_LEAKY_RELU */ + 0x0, /* gcFEATURE_BIT_NN_PRELU */ + 0x0, /* gcFEATURE_BIT_NN_PER_CHANNEL_QUANT */ + 0x0, /* gcFEATURE_BIT_NN_PER_CHANNEL_QUANT_ASYM */ + 0x0, /* gcFEATURE_BIT_NN_ASYMMETRIC_INT8 */ + 0x0, /* gcFEATURE_BIT_NN_FLOAT_POST_MULT */ + 0x0, /* gcFEATURE_BIT_PRELU_LEAKLY_RELU_CLAMP */ + 0x0, /* gcFEATURE_BIT_TPLITE_BFLOAT16 */ + 0x0, /* gcFEATURE_BIT_PREPROCESS_IMG_BUF_640BYTE_LIMIT */ + 0x0, /* gcFEATURE_BIT_TP_KERNEL_1BYTE_ALGIN */ + 0x0, /* gcFEATURE_BIT_BFLOAT_COEF_COMPRESSION_ZERO_COEFBIT14_INVERSE */ + 0x0, /* gcFEATURE_BIT_NN_COMPRESSION_BYPASSS */ + 0x0, /* gcFEATURE_BIT_TP_3_USC */ + 0x0, /* gcFEATURE_BIT_BFP_COEF_AUTO_PAD_INCOMPLETE_ZERO_IN_KZ_PLANE */ + 0x0, /* gcFEATURE_BIT_NN_NATIVE_STRIDE_TWO */ + 0x0, /* gcFEATURE_BIT_NN_TENSOR_ADD */ + 0x0, /* gcFEATURE_BIT_NN_FLOAT32_IO */ + 0x0, /* gcFEATURE_BIT_TP_FLOAT32_IO */ + 0x0, /* gcFEATURE_BIT_NN_SMALL_BATCH_PHASE2 */ + 0x0, /* gcFEATURE_BIT_TILE_ACCESS_CAPABILITY */ + 0x0, /* gcFEATURE_BIT_FAST_DP3_PREPROCESSOR */ + 0x0, /* gcFEATURE_BIT_DEPTHWISE_SUPPORT_16BIT_FORMAT */ + 0x0, /* gcFEATURE_BIT_NN_SUPPORT_ALU_LUT */ + 0x0, /* gcFEATURE_BIT_NN_ENHANCED_MAX_POOLING */ + 0x0, /* gcFEATURE_BIT_NN_TRANSPOSE_PHASE2 */ + 0x0, /* gcFEATURE_BIT_TPLITE_SUPPORT_TP_DATA_TRANSPOSE */ + 0x0, /* gcFEATURE_BIT_NN_SUPPORT_CONV_1D */ + 0x0, /* gcFEATURE_BIT_USE_VIPSRAM_FOR_KERNEL_STREAMING */ + 0x0, /* gcFEATURE_BIT_VIP_DEC400 */ + 0x1, /* gcFEATURE_BIT_NN_PER3DTILE_BUBBLE_FIX */ + 0x1, /* gcFEATURE_BIT_NN_CACHELINE_MODE_PERF_FIX */ + 0x1, /* gcFEATURE_BIT_NN_CONV1x1_PERF_FIX */ + 0x1, /* gcFEATURE_BIT_TP_REORDER_FIX */ + 0x1, /* gcFEATURE_BIT_NN_CONVOUT_FIFO_DEPTH_FIX */ 0x1, /* gcFEATURE_BIT_NN_ZXDP3_KERNEL_READ_CONFLICT_FIX */ 0x1, /* gcFEATURE_BIT_NN_ZDP3_NO_COMPRESS_FIX */ 0x1, /* gcFEATURE_BIT_NN_ASYNC_COPY_PERF_FIX */ - 0x1, /* gcFEATURE_BIT_OCB_COUNTER */ - 0x1, /* gcFEATURE_BIT_NN_XYDP0 */ - 0x0, /* gcFEATURE_BIT_ZRL_7BIT */ + 0x1, /* gcFEATURE_BIT_HI_REORDER_FIX */ + 0x1, /* gcFEATURE_BIT_INCORRECT_WR_REQ_TO_USC_BETWEEN_REORDER_AND_NORMAL_LAYER_FIX */ + 0x1, /* gcFEATURE_BIT_TP_REORDER_LAYER_SUSPEND_FIX */ 0x1, /* gcFEATURE_BIT_NN_ASYNC_COPY_MERGE_FIX */ - 0x1, /* gcFEATURE_BIT_NN_SMALLBATCH_PHASE1 */ - 0x1, /* gcFEATURE_BIT_TP_SMALLBATCH_PHASE1 */ - 0x0, /* gcFEATURE_BIT_SCALER */ - 0x0, /* gcFEATURE_BIT_SCALER_4K */ + 0x1, /* gcFEATURE_BIT_USC_INVALIDATE_CACHE_LINE_FIX */ 0x0, /* gcFEATURE_BIT_NN_REQ_SLOWARBITRATION_FIX */ - 0x0, /* gcFEATURE_BIT_IMAGE_PARTIAL_CACHE */ + 0x0, /* gcFEATURE_BIT_IMAGE_PARTIAL_CACHE_FIX */ 0x0, /* gcFEATURE_BIT_FULLCACHE_KERNELHEAD_FIX */ - 0x1, /* gcFEATURE_BIT_NN_SINGLEPORT_ACCUMBUFFER */ - 0x0, /* gcFEATURE_BIT_NN_SMALLBATCH */ - 0x0, /* gcFEATURE_BIT_TP_SMALLBATCH */ - 0x1, /* gcFEATURE_BIT_ZRL_8BIT */ - 0x1, /* gcFEATURE_BIT_NN_DEPTHWISE_SUPPORT */ - 0x1, /* gcFEATURE_BIT_NN_WRITE_WITHOUT_USC */ 0x1, /* gcFEATURE_BIT_NN_ZDP_INIMAGE_SIZE_FIX */ - 0x1, /* gcFEATURE_BIT_HI_REORDER_FIX */ - 0x1, /* gcFEATURE_BIT_INCORRECT_WR_REQ_TO_USC_BETWEEN_REORDER_AND_NORMAL_LAYER_FIX */ - 0x1, /* gcFEATURE_BIT_TP_COEF_COMPRESSION_ENHANCEMENT */ - 0x0, /* gcFEATURE_BIT_VIP_DEC400 */ - 0x1, /* gcFEATURE_BIT_IMAGE_NOT_PACKED_IN_SRAM_FIX */ 0x1, /* gcFEATURE_BIT_IDLE_BEFORE_FLUSH_COMPLETE_FIX */ 0x1, /* gcFEATURE_BIT_NO_FLUSH_USC_FIX */ + 0x1, /* gcFEATURE_BIT_SMALL_BATCH_FLOPS_RESET_FIX */ + 0x0, /* gcFEATURE_BIT_SMALL_BATCH_DISBLE_FIX */ + 0x1, /* gcFEATURE_BIT_OUTPUT_CONVERT_UINT8_INT8_TO_UINT16_INT16_FIX */ + 0x1, /* gcFEATURE_BIT_IMAGE_NOT_PACKED_IN_SRAM_FIX */ 0x1, /* gcFEATURE_BIT_COEF_DELTA_CORD_OVERFLOW_ZRL_8BIT_FIX */ - 0x1, /* gcFEATURE_BIT_XY_OFFSET_LIMITATION_FIX */ - 0x1, /* gcFEATURE_BIT_USC_INVALIDATE_CACHE_LINE_FIX */ 0x0, /* gcFEATURE_BIT_LOW_EFFICIENCY_OF_ID_WRITE_IMGBUF_FIX */ - 0x0, /* gcFEATURE_BIT_KERNEL_PER_CORE_LESS_THAN_THIRD_COEF_BUFF_DEPTH_FIX */ + 0x1, /* gcFEATURE_BIT_KERNEL_VIP_SRAM_READ_BW_LIMITATION_FIX */ 0x0, /* gcFEATURE_BIT_USC_BOTTLENECK_FIX */ + 0x0, /* gcFEATURE_BIT_KERNEL_PER_CORE_LESS_THAN_THIRD_COEF_BUFF_DEPTH_FIX */ 0x0, /* gcFEATURE_BIT_KERNEL_SIZE_WASTE_IN_PARTIAL_MODE_FIX */ - 0x1, /* gcFEATURE_BIT_FULLCACHE_KERNEL_INTERLEAVE_FIX */ - 0x1, /* gcFEATURE_BIT_TP_REORDER_LAYER_SUSPEND_FIX */ - 0x1, /* gcFEATURE_BIT_KERNEL_VIP_SRAM_READ_BW_LIMITATION_FIX */ + 0x1, /* gcFEATURE_BIT_NN_COMMAND_KERNEL_REQUEST_CONFICT_FIX */ + 0x1, /* gcFEATURE_BIT_TP_REORDER_INTILE_X_SIZE_512_FIX */ 0x1, /* gcFEATURE_BIT_IMG_POP_PIPELINE_PAUSE_FIX */ + 0x1, /* gcFEATURE_BIT_FULLCACHE_KERNEL_INTERLEAVE_FIX */ + 0x0, /* gcFEATURE_BIT_V8_SINGLE_PORT_ACCUMULATION_BUFFER_RW_CONFICT_ZERO_SKIP_PERF_FIX */ + 0x0, /* gcFEATURE_BIT_V8_ACCUMLATION_READ_OUT_HAS_BUBBLES_PERF_FIX */ + 0x1, /* gcFEATURE_BIT_DEPTHWISE_NEIGHBOR_IMG_DATA_TRANSFER_NOT_EFFICIENT_FIX */ 0x1, /* gcFEATURE_BIT_DR_JD_DIFF_CONDITION_FOR_CACHELINE_MODE_PRE_FIX */ - 0x1, /* gcFEATURE_BIT_OUTIMAGE_X_BITWIDTH_LIMIT_FOR_NN_TRANSPOSE_FIX */ - 0x1, /* gcFEATURE_BIT_SMALL_BATCH_FLOPS_RESET_FIX */ - 0x0, /* gcFEATURE_BIT_SMALL_BATCH_DISBLE_FIX */ - 0x1, /* gcFEATURE_BIT_NEGATIVE_POST_SHIFT_FIX */ - 0x1, /* gcFEATURE_BIT_NN_COMMAND_KERNEL_REQUEST_CONFICT_FIX */ - 0x1, /* gcFEATURE_BIT_OCB_REMAP_PHYSICAL_ADDRESS */ - 0x1, /* gcFEATURE_BIT_NN_NO_Z_LOCATION_OFFSET */ - 0x0, /* gcFEATURE_BIT_NN_LEAKY_RELU */ - 0x0, /* gcFEATURE_BIT_NN_PRELU */ - 0x0, /* gcFEATURE_BIT_NN_PER_CHANNEL_QUANT */ - 0x0, /* gcFEATURE_BIT_NN_PER_CHANNEL_QUANT_ASYM */ - 0x0, /* gcFEATURE_BIT_NN_NATIVE_STRIDE_TWO */ - 0x0, /* gcFEATURE_BIT_NN_TENSOR_ADD */ - 0x0, /* gcFEATURE_BIT_NN_FLOAT_POST_MULT */ - 0x1, /* gcFEATURE_BIT_NN_SLICE_PADDING_TO_64BYTE_ALIGN */ - 0x0, /* gcFEATURE_BIT_NN_DW_1x1_CONV_MERGE */ - 0x1, /* gcFEATURE_BIT_NN_SLOW_OUTPUT */ - 0x1, /* gcFEATURE_BIT_NO_NARROW_POST_PROCESS_PIPE */ - 0x1, /* gcFEATURE_BIT_TP_NN_PROBE */ - 0x0, /* gcFEATURE_BIT_TP_23BITS_POST_MULTIPLIER */ - 0x1, /* gcFEATURE_BIT_NN_TRANSPOSE */ + 0x0, /* gcFEATURE_BIT_TP_ACCESS_VIPSRAM_OT_IS_ONE_FIX */ 0x0, /* gcFEATURE_BIT_EVIS2_FLOP_RESET_FIX */ + 0x1, /* gcFEATURE_BIT_OUTIMAGE_X_BITWIDTH_LIMIT_FOR_NN_TRANSPOSE_FIX */ 0x0, /* gcFEATURE_BIT_USC_ASYNC_CP_RTN_FLOP_RESET_FIX */ - 0x1, /* gcFEATURE_BIT_DDR_BURST_LEN_256B */ + 0x1, /* gcFEATURE_BIT_IMG_ADDR_NOT_WRAP_IF_OVER_OCB_ADDR_FIX */ + 0x1, /* gcFEATURE_BIT_NEGATIVE_POST_SHIFT_FIX */ + 0x1, /* gcFEATURE_BIT_INIMAGE_2DTILE_NOT_LESS_160PIXEL_FIX */ 0x0, /* gcFEATURE_BIT_IMG_CAHCE_MODE_MUST_0_IN_IMG_DIRECT_MODE_FIX */ - 0x1, /* gcFEATURE_BIT_USE_SINGLE_PORT_VIPSRAM */ - 0x0, /* gcFEATURE_BIT_NN_ASYMMETRIC_INT8 */ - 0x1, /* gcFEATURE_BIT_DEPTHWISE_NEIGHBOR_IMG_DATA_TRANSFER_NOT_EFFICIENT_FIX */ - 0x0, /* gcFEATURE_BIT_PRELU_LEAKLY_RELU_CLAMP */ - 0x0, /* gcFEATURE_BIT_TP_FLOAT32_IO */ - 0x0, /* gcFEATURE_BIT_NN_FLOAT32_IO */ - 0x0, /* gcFEATURE_BIT_NN_SMALL_BATCH_PHASE2 */ - 0x0, /* gcFEATURE_BIT_TILE_ACCESS_CAPABILITY */ - 0x0, /* gcFEATURE_BIT_FAST_DP3_PREPROCESSOR */ - 0x0, /* gcFEATURE_BIT_NN_COMPRESSION_BYPASSS */ - 0x0, /* gcFEATURE_BIT_BFLOAT_KERNEL_COMPRESSION_ZERO_SKIP_FIX */ - 0x0, /* gcFEATURE_BIT_TP_3_USC */ - 0x0, /* gcFEATURE_BIT_TP_KERNEL_1BYTE_ALGIN */ - 0x0, /* gcFEATURE_BIT_TPLITE_BFLOAT16 */ - 0x0, /* gcFEATURE_BIT_PREPROCESS_IMG_BUF_640BYTE_LIMIT */ - 0x0, /* gcFEATURE_BIT_V8_ACCUMLATION_READ_OUT_HAS_BUBBLES_PERF_FIX */ - 0x0, /* gcFEATURE_BIT_V8_SINGLE_PORT_ACCUMULATION_BUFFER_RW_CONFICT_ZERO_SKIP_PERF_FIX */ 0x0, /* gcFEATURE_BIT_BURST_COLLECT_DUMMY_DATA_WASTE_CYCLES_FIX */ 0x1, /* gcFEATURE_BIT_INIMG_NOT_64BYTE_ALIGN_CACHELINE_MODE_FIX */ - 0x0, /* gcFEATURE_BIT_TP_ACCESS_VIPSRAM_OT_IS_ONE_FIX */ - 0x1, /* gcFEATURE_BIT_VIP_HW_FINAL_RELEASE */ + 0x0, /* gcFEATURE_BIT_TP_FC_FLOAT_LAST_PIXEL_NEGATIVE_0_FIX */ + 0x1, /* gcFEATURE_BIT_NN_WASET_COEF_READ_WRITE_BANDWIDTH_128BYTE_VIPSRAM_IN_FULL_PATIAL_CACHE_MODE */ + 0x1, /* gcFEATURE_BIT_NN_IN_TILE_DATA_IS_ALL_PAD_FIX */ + 0x1, /* gcFEATURE_BIT_TP_FC_KERNEL_STREAM_MUST_LESS_THAN_OR_EQUAL_TO_64BYTE_WHEN_1BYTE_ALGINE_FIX */ + 0x0, /* gcFEATURE_BIT_NN_INTERLEVE8 */ + 0x0, /* gcFEATURE_BIT_NN_FP16_ALU */ + 0x1, /* gcFEATURE_BIT_NN_INT16_ALU */ + 0x1, /* gcFEATURE_BIT_NN_INT8_SCALE */ + 0x1, /* gcFEATURE_BIT_NN_POWER_ISOLATION */ + 0x0, /* gcFEATURE_BIT_ZRL_7BIT */ + 0x1, /* gcFEATURE_BIT_NN_SMALLBATCH_PHASE1 */ + 0x1, /* gcFEATURE_BIT_TP_SMALLBATCH_PHASE1 */ + 0x0, /* gcFEATURE_BIT_NN_SMALLBATCH */ + 0x0, /* gcFEATURE_BIT_TP_SMALLBATCH */ + 0x1, /* gcFEATURE_BIT_ZRL_8BIT */ + 0x1, /* gcFEATURE_BIT_DDR_BURST_LEN_256B */ + 0x1, /* gcFEATURE_BIT_XY_OFFSET_LIMITATION_FIX */ + 0x1, /* gcFEATURE_BIT_NN_NONZERO_MIRROR_BORDER */ + 0x0, /* gcFEATURE_BIT_IMAGE_PARTIAL_CACHE */ }, /* vip9000nano-di */ { @@ -3119,13 +3404,23 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x140, /* gcFEATURE_VALUE_NumberOfConstants */ 0x1, /* gcFEATURE_VALUE_CoreCount */ 0x10, /* gcFEATURE_VALUE_LocalStorageSize */ + 0x0, /* gcFEATURE_VALUE_LocalStorageSize_1 */ + 0x0, /* gcFEATURE_VALUE_LocalStorageSize_2 */ 0x10, /* gcFEATURE_VALUE_L1CacheSize */ + 0x0, /* gcFEATURE_VALUE_L1CacheSize_1 */ + 0x0, /* gcFEATURE_VALUE_L1CacheSize_2 */ 0x200, /* gcFEATURE_VALUE_InstructionMemorySize */ 0x14, /* gcFEATURE_VALUE_ShaderPCLength */ 0x10, /* gcFEATURE_VALUE_USC_MAX_PAGES */ + 0x0, /* gcFEATURE_VALUE_USC_MAX_PAGES_1 */ + 0x0, /* gcFEATURE_VALUE_USC_MAX_PAGES_2 */ 0x1, /* gcFEATURE_VALUE_NumPixelPipes */ 0x1, /* gcFEATURE_VALUE_USC_CACHE_CONTROLLERS */ + 0x0, /* gcFEATURE_VALUE_USC_CACHE_CONTROLLERS_1 */ + 0x0, /* gcFEATURE_VALUE_USC_CACHE_CONTROLLERS_2 */ 0x2, /* gcFEATURE_VALUE_USC_BANKS */ + 0x0, /* gcFEATURE_VALUE_USC_BANKS_1 */ + 0x0, /* gcFEATURE_VALUE_USC_BANKS_2 */ 0x8, /* gcFEATURE_VALUE_Streams */ 0x10, /* gcFEATURE_VALUE_VaryingCount */ 0x400, /* gcFEATURE_VALUE_VertexOutputBufferSize */ @@ -3134,6 +3429,7 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_VALUE_NumResolvePipes */ 0x100, /* gcFEATURE_VALUE_RESULT_WINDOW_MAX_SIZE */ 0x0, /* gcFEATURE_VALUE_ClusterAliveMask */ + 0x0, /* gcFEATURE_VALUE_G2D_DEC400_MINOR */ 0x40, /* gcFEATURE_VALUE_NNMadPerCore */ 0x8, /* gcFEATURE_VALUE_NNCoreCount */ 0x8, /* gcFEATURE_VALUE_NNCoreCount_INT8 */ @@ -3146,7 +3442,7 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x10, /* gcFEATURE_VALUE_TPEngine_PwlLUTSize */ 0x100000, /* gcFEATURE_VALUE_VIP_SRAM_SIZE */ 0x3, /* gcFEATURE_VALUE_TPEngine_CoreCount */ - 0x0, /* gcFEATURE_VALUE_AXI_SRAM_SIZE */ + 0x40000, /* gcFEATURE_VALUE_AXI_SRAM_SIZE */ 0x5, /* gcFEATURE_VALUE_NN_INIMAGE_OFFSET_BITS */ 0x200, /* gcFEATURE_VALUE_TP_REORDER_INIMAGE_SIZE */ 0x0, /* gcFEATURE_VALUE_TPLite_CoreCount */ @@ -3158,14 +3454,26 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x40, /* gcFEATURE_VALUE_PHYSICAL_VIP_SRAM_WIDTH_IN_BYTE */ 0x10, /* gcFEATURE_VALUE_EQUIVALENT_VIP_SRAM_WIDTH_INBYTE */ 0x8, /* gcFEATURE_VALUE_TP_ZRL_BITS */ + 0x8, /* gcFEATURE_VALUE_NN_ZRL_BITS */ 0x80, /* gcFEATURE_VALUE_LATENCY_HIDING_AT_FULL_AXI_BW */ 0x10, /* gcFEATURE_VALUE_AXI_BUS_WIDTH */ 0xf, /* gcFEATURE_VALUE_NN_KERNEL_X_SIZE */ 0xf, /* gcFEATURE_VALUE_NN_KERNEL_Y_SIZE */ + 0xf, /* gcFEATURE_VALUE_NN_FC_KERNEL_Y_SIZE */ 0xfffff, /* gcFEATURE_VALUE_NN_KERNEL_Z_SIZE */ 0x1f, /* gcFEATURE_VALUE_NN_X_OFFSET */ 0x1f, /* gcFEATURE_VALUE_NN_Y_OFFSET */ 0x100, /* gcFEATURE_VALUE_DDR_KERNEL_BURST_SIZE */ + 0x10, /* gcFEATURE_VALUE_OUTIMAGE_X_STRIDE_BITS */ + 0x10, /* gcFEATURE_VALUE_OUTIMAGE_Y_STRIDE_BITS */ + 0x10, /* gcFEATURE_VALUE_INIMAGE_X_STRIDE_BITS */ + 0x10, /* gcFEATURE_VALUE_IMIMAGE_Y_STRIDE_BITS */ + 0xd, /* gcFEATURE_VALUE_OUTIMAGE_X_SIZE_BITS */ + 0xd, /* gcFEATURE_VALUE_OUTIMAGE_Y_SIZE_BITS */ + 0xe, /* gcFEATURE_VALUE_OUTIMAGE_SIZE_BITS */ + 0xd, /* gcFEATURE_VALUE_IMAGE_X_SIZE_BITS */ + 0xd, /* gcFEATURE_VALUE_INIMAGE_Y_SIZE_BITS */ + 0x40, /* gcFEATURE_VALUE_MAX_TILE_X_SIZE */ 0x0, /* gcFEATURE_BIT_REG_FastClear */ 0x0, /* gcFEATURE_BIT_REG_SpecialAntiAliasing */ 0x1, /* gcFEATURE_BIT_REG_Pipe3D */ @@ -3407,6 +3715,7 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x1, /* gcFEATURE_BIT_RA_HZEZ_CLOCK_CONTROL */ 0x1, /* gcFEATURE_BIT_CACHE128B256BPERLINE */ 0x1, /* gcFEATURE_BIT_V4Compression */ + 0x0, /* gcFEATURE_BIT_DE2D_MAJOR_SUPER_TILE */ 0x0, /* gcFEATURE_BIT_PE2D_MAJOR_SUPER_TILE */ 0x1, /* gcFEATURE_BIT_PE_32BPC_COLORMASK_FIX */ 0x1, /* gcFEATURE_BIT_ALPHA_BLENDING_OPT */ @@ -3539,6 +3848,7 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_BIT_TX_NO_FIXED_FILTER */ 0x0, /* gcFEATURE_BIT_SHARE_Z */ 0x0, /* gcFEATURE_BIT_DE_2D_FAST_CLEAR */ + 0x0, /* gcFEATURE_BIT_DE_TILESTATUS_ROTATION_FIX */ 0x0, /* gcFEATURE_BIT_TX_CLEAR_PENDING_FIX */ 0x0, /* gcFEATURE_BIT_NO_HI1_L2 */ 0x0, /* gcFEATURE_BIT_USC_EVICT_CTRL_FIFO_FLOP_RESET_FIX */ @@ -3549,6 +3859,13 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_BIT_SH_VX2_FLOATING_MAD_FIX */ 0x0, /* gcFEATURE_BIT_TS_FC_VULKAN_SUPPORT */ 0x0, /* gcFEATURE_BIT_MSAA_FLOAT_64BIT */ + 0x0, /* gcFEATURE_BIT_INDIRECT_COMPUTE_ZERODIM_FIX */ + 0x0, /* gcFEATURE_BIT_Q_CHANNEL_SUPPORT */ + 0x0, /* gcFEATURE_BIT_MMU_PAGE_DESCRIPTOR */ + 0x0, /* gcFEATURE_BIT_YUV_LINEAR_TO_TILE_ROTATE */ + 0x0, /* gcFEATURE_BIT_VEC2_IMULIMAD32_SUPPORT */ + 0x0, /* gcFEATURE_BIT_VEC4_IMULIMAD32_SUPPORT */ + 0x0, /* gcFEATURE_BIT_VEC2_IDIVIMOD16_SUPPORT */ 0x0, /* gcFEATURE_BIT_VG_TS_CULLING */ 0x0, /* gcFEATURE_BIT_VG_FP25 */ 0x0, /* gcFEATURE_BIT_VG_AYUV_INPUT_OUTPUT */ @@ -3575,6 +3892,20 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_BIT_DC_MMU */ 0x0, /* gcFEATURE_BIT_DC_COMPRESSION */ 0x0, /* gcFEATURE_BIT_DC_QOS */ + 0x1, /* gcFEATURE_BIT_VIP_HW_FINAL_RELEASE */ + 0x1, /* gcFEATURE_BIT_NN_SINGLEPORT_ACCUMBUFFER */ + 0x1, /* gcFEATURE_BIT_NN_STRIDE_SUPPORT */ + 0x1, /* gcFEATURE_BIT_SWTILING_PHASE1 */ + 0x1, /* gcFEATURE_BIT_SWTILING_PHASE2 */ + 0x0, /* gcFEATURE_BIT_TP_SIMPLE_INT16 */ + 0x1, /* gcFEATURE_BIT_TP_REAL_INT16 */ + 0x1, /* gcFEATURE_BIT_TP_ROI_POOLING */ + 0x1, /* gcFEATURE_BIT_TP_MAX_POOLING_STRIDE1 */ + 0x1, /* gcFEATURE_BIT_TP_LRN */ + 0x1, /* gcFEATURE_BIT_TP_REORDER */ + 0x1, /* gcFEATURE_BIT_TF_QUANTIZATION */ + 0x0, /* gcFEATURE_BIT_NN_NONZERO_BORDER */ + 0x1, /* gcFEATURE_BIT_NN_MIRROR_BORDER */ 0x0, /* gcFEATURE_BIT_AI_GPU */ 0x0, /* gcFEATURE_BIT_EVIS_NO_ABSDIFF */ 0x0, /* gcFEATURE_BIT_EVIS_NO_BITREPLACE */ @@ -3587,128 +3918,139 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_BIT_EVIS_LERP_7OUTPUT */ 0x0, /* gcFEATURE_BIT_EVIS_ACCSQ_8OUTPUT */ 0x1, /* gcFEATURE_BIT_EVIS_VX2 */ - 0x1, /* gcFEATURE_BIT_NN_FLOAT */ 0x1, /* gcFEATURE_BIT_TP_ENGINE */ 0x1, /* gcFEATURE_BIT_VIP_V7 */ - 0x0, /* gcFEATURE_BIT_MCFE */ - 0x0, /* gcFEATURE_BIT_NN_INTERLEVE8 */ - 0x1, /* gcFEATURE_BIT_TP_REORDER */ - 0x1, /* gcFEATURE_BIT_TP_LRN */ - 0x1, /* gcFEATURE_BIT_TP_MAX_POOLING_STRIDE1 */ - 0x0, /* gcFEATURE_BIT_NN_FP16_ALU */ - 0x1, /* gcFEATURE_BIT_NN_INT16_ALU */ - 0x1, /* gcFEATURE_BIT_TP_ROI_POOLING */ - 0x1, /* gcFEATURE_BIT_NN_ZDP3 */ + 0x0, /* gcFEATURE_BIT_TP_TENSOR_ADD_MUL */ + 0x0, /* gcFEATURE_BIT_NN_DEPTHWISE_INT16XINT8 */ + 0x0, /* gcFEATURE_BIT_TP_SOFTMAX */ + 0x0, /* gcFEATURE_BIT_NN_23BITS_POST_MULTIPLIER_VIP_V7 */ + 0x0, /* gcFEATURE_BIT_TP_23BITS_POST_MULTIPLIER_VIP_V7 */ + 0x0, /* gcFEATURE_BIT_HYBRID_MODE_VIP_V7 */ 0x0, /* gcFEATURE_BIT_NN_ZDP6 */ 0x0, /* gcFEATURE_BIT_NN_XYDP9 */ - 0x1, /* gcFEATURE_BIT_NN_INT8_SCALE */ - 0x1, /* gcFEATURE_BIT_NN_POWER_ISOLATION */ - 0x1, /* gcFEATURE_BIT_SWTILING_PHASE1 */ - 0x1, /* gcFEATURE_BIT_TF_QUANTIZATION */ - 0x0, /* gcFEATURE_BIT_TP_SIMPLE_INT16 */ - 0x1, /* gcFEATURE_BIT_TP_REAL_INT16 */ - 0x0, /* gcFEATURE_BIT_TP_BFLOAT16 */ - 0x1, /* gcFEATURE_BIT_NN_FIRST_PIXEL_POOLING */ - 0x1, /* gcFEATURE_BIT_SWTILING_PHASE2 */ - 0x1, /* gcFEATURE_BIT_NN_STRIDE_SUPPORT */ + 0x1, /* gcFEATURE_BIT_NN_FIRST_PIXEL_POOLING */ + 0x1, /* gcFEATURE_BIT_NN_ZDP3 */ 0x0, /* gcFEATURE_BIT_NN_XYDP6 */ - 0x1, /* gcFEATURE_BIT_TP_REORDER_FIX */ - 0x1, /* gcFEATURE_BIT_NN_CONV1x1_PERF_FIX */ - 0x1, /* gcFEATURE_BIT_NN_CACHELINE_MODE_PERF_FIX */ - 0x1, /* gcFEATURE_BIT_NN_PER3DTILE_BUBBLE_FIX */ - 0x1, /* gcFEATURE_BIT_NN_CONVOUT_FIFO_DEPTH_FIX */ 0x1, /* gcFEATURE_BIT_SWTILING_PHASE3 */ + 0x0, /* gcFEATURE_BIT_MCFE */ 0x0, /* gcFEATURE_BIT_USC_STAY_LRU */ - 0x1, /* gcFEATURE_BIT_NN_NONZERO_MIRROR_BORDER */ + 0x1, /* gcFEATURE_BIT_COEF_COMPRESSION_ENHANCEMENT */ + 0x1, /* gcFEATURE_BIT_TP_COEF_COMPRESSION_ENHANCEMENT */ 0x1, /* gcFEATURE_BIT_NN_COEF_DECOMPRESS_PERF2X */ + 0x1, /* gcFEATURE_BIT_OCB_COUNTER */ + 0x0, /* gcFEATURE_BIT_SCALER */ + 0x0, /* gcFEATURE_BIT_SCALER_4K */ 0x0, /* gcFEATURE_BIT_INPUT_4BIT */ - 0x1, /* gcFEATURE_BIT_COEF_COMPRESSION_ENHANCEMENT */ + 0x1, /* gcFEATURE_BIT_NN_NO_Z_LOCATION_OFFSET */ + 0x1, /* gcFEATURE_BIT_OCB_REMAP_PHYSICAL_ADDRESS */ + 0x1, /* gcFEATURE_BIT_NN_SLOW_OUTPUT */ + 0x1, /* gcFEATURE_BIT_NO_NARROW_POST_PROCESS_PIPE */ + 0x1, /* gcFEATURE_BIT_TP_NN_PROBE */ + 0x1, /* gcFEATURE_BIT_NN_DEPTHWISE_SUPPORT */ + 0x1, /* gcFEATURE_BIT_NN_XYDP0 */ + 0x1, /* gcFEATURE_BIT_NN_WRITE_WITHOUT_USC */ + 0x1, /* gcFEATURE_BIT_NN_HW_LIMITATION_NATIVE_KER_1x2_2x1 */ + 0x1, /* gcFEATURE_BIT_NN_SLICE_PADDING_TO_64BYTE_ALIGN */ + 0x0, /* gcFEATURE_BIT_NN_DW_1x1_CONV_MERGE */ + 0x0, /* gcFEATURE_BIT_TP_BFLOAT16 */ + 0x0, /* gcFEATURE_BIT_TP_23BITS_POST_MULTIPLIER */ + 0x1, /* gcFEATURE_BIT_NN_TRANSPOSE */ + 0x1, /* gcFEATURE_BIT_USE_SINGLE_PORT_VIPSRAM */ + 0x0, /* gcFEATURE_BIT_NN_LEAKY_RELU */ + 0x0, /* gcFEATURE_BIT_NN_PRELU */ + 0x0, /* gcFEATURE_BIT_NN_PER_CHANNEL_QUANT */ + 0x0, /* gcFEATURE_BIT_NN_PER_CHANNEL_QUANT_ASYM */ + 0x0, /* gcFEATURE_BIT_NN_ASYMMETRIC_INT8 */ + 0x0, /* gcFEATURE_BIT_NN_FLOAT_POST_MULT */ + 0x0, /* gcFEATURE_BIT_PRELU_LEAKLY_RELU_CLAMP */ + 0x0, /* gcFEATURE_BIT_TPLITE_BFLOAT16 */ + 0x0, /* gcFEATURE_BIT_PREPROCESS_IMG_BUF_640BYTE_LIMIT */ + 0x0, /* gcFEATURE_BIT_TP_KERNEL_1BYTE_ALGIN */ + 0x0, /* gcFEATURE_BIT_BFLOAT_COEF_COMPRESSION_ZERO_COEFBIT14_INVERSE */ + 0x0, /* gcFEATURE_BIT_NN_COMPRESSION_BYPASSS */ + 0x0, /* gcFEATURE_BIT_TP_3_USC */ + 0x0, /* gcFEATURE_BIT_BFP_COEF_AUTO_PAD_INCOMPLETE_ZERO_IN_KZ_PLANE */ + 0x0, /* gcFEATURE_BIT_NN_NATIVE_STRIDE_TWO */ + 0x0, /* gcFEATURE_BIT_NN_TENSOR_ADD */ + 0x0, /* gcFEATURE_BIT_NN_FLOAT32_IO */ + 0x0, /* gcFEATURE_BIT_TP_FLOAT32_IO */ + 0x0, /* gcFEATURE_BIT_NN_SMALL_BATCH_PHASE2 */ + 0x0, /* gcFEATURE_BIT_TILE_ACCESS_CAPABILITY */ + 0x0, /* gcFEATURE_BIT_FAST_DP3_PREPROCESSOR */ + 0x0, /* gcFEATURE_BIT_DEPTHWISE_SUPPORT_16BIT_FORMAT */ + 0x0, /* gcFEATURE_BIT_NN_SUPPORT_ALU_LUT */ + 0x0, /* gcFEATURE_BIT_NN_ENHANCED_MAX_POOLING */ + 0x0, /* gcFEATURE_BIT_NN_TRANSPOSE_PHASE2 */ + 0x0, /* gcFEATURE_BIT_TPLITE_SUPPORT_TP_DATA_TRANSPOSE */ + 0x0, /* gcFEATURE_BIT_NN_SUPPORT_CONV_1D */ + 0x0, /* gcFEATURE_BIT_USE_VIPSRAM_FOR_KERNEL_STREAMING */ + 0x0, /* gcFEATURE_BIT_VIP_DEC400 */ + 0x1, /* gcFEATURE_BIT_NN_PER3DTILE_BUBBLE_FIX */ + 0x1, /* gcFEATURE_BIT_NN_CACHELINE_MODE_PERF_FIX */ + 0x1, /* gcFEATURE_BIT_NN_CONV1x1_PERF_FIX */ + 0x1, /* gcFEATURE_BIT_TP_REORDER_FIX */ + 0x1, /* gcFEATURE_BIT_NN_CONVOUT_FIFO_DEPTH_FIX */ 0x1, /* gcFEATURE_BIT_NN_ZXDP3_KERNEL_READ_CONFLICT_FIX */ 0x1, /* gcFEATURE_BIT_NN_ZDP3_NO_COMPRESS_FIX */ 0x1, /* gcFEATURE_BIT_NN_ASYNC_COPY_PERF_FIX */ - 0x1, /* gcFEATURE_BIT_OCB_COUNTER */ - 0x1, /* gcFEATURE_BIT_NN_XYDP0 */ - 0x0, /* gcFEATURE_BIT_ZRL_7BIT */ + 0x1, /* gcFEATURE_BIT_HI_REORDER_FIX */ + 0x1, /* gcFEATURE_BIT_INCORRECT_WR_REQ_TO_USC_BETWEEN_REORDER_AND_NORMAL_LAYER_FIX */ + 0x1, /* gcFEATURE_BIT_TP_REORDER_LAYER_SUSPEND_FIX */ 0x1, /* gcFEATURE_BIT_NN_ASYNC_COPY_MERGE_FIX */ - 0x1, /* gcFEATURE_BIT_NN_SMALLBATCH_PHASE1 */ - 0x1, /* gcFEATURE_BIT_TP_SMALLBATCH_PHASE1 */ - 0x0, /* gcFEATURE_BIT_SCALER */ - 0x0, /* gcFEATURE_BIT_SCALER_4K */ + 0x1, /* gcFEATURE_BIT_USC_INVALIDATE_CACHE_LINE_FIX */ 0x0, /* gcFEATURE_BIT_NN_REQ_SLOWARBITRATION_FIX */ - 0x0, /* gcFEATURE_BIT_IMAGE_PARTIAL_CACHE */ + 0x0, /* gcFEATURE_BIT_IMAGE_PARTIAL_CACHE_FIX */ 0x0, /* gcFEATURE_BIT_FULLCACHE_KERNELHEAD_FIX */ - 0x1, /* gcFEATURE_BIT_NN_SINGLEPORT_ACCUMBUFFER */ - 0x0, /* gcFEATURE_BIT_NN_SMALLBATCH */ - 0x0, /* gcFEATURE_BIT_TP_SMALLBATCH */ - 0x1, /* gcFEATURE_BIT_ZRL_8BIT */ - 0x1, /* gcFEATURE_BIT_NN_DEPTHWISE_SUPPORT */ - 0x1, /* gcFEATURE_BIT_NN_WRITE_WITHOUT_USC */ 0x1, /* gcFEATURE_BIT_NN_ZDP_INIMAGE_SIZE_FIX */ - 0x1, /* gcFEATURE_BIT_HI_REORDER_FIX */ - 0x1, /* gcFEATURE_BIT_INCORRECT_WR_REQ_TO_USC_BETWEEN_REORDER_AND_NORMAL_LAYER_FIX */ - 0x1, /* gcFEATURE_BIT_TP_COEF_COMPRESSION_ENHANCEMENT */ - 0x0, /* gcFEATURE_BIT_VIP_DEC400 */ - 0x1, /* gcFEATURE_BIT_IMAGE_NOT_PACKED_IN_SRAM_FIX */ 0x1, /* gcFEATURE_BIT_IDLE_BEFORE_FLUSH_COMPLETE_FIX */ 0x1, /* gcFEATURE_BIT_NO_FLUSH_USC_FIX */ + 0x1, /* gcFEATURE_BIT_SMALL_BATCH_FLOPS_RESET_FIX */ + 0x0, /* gcFEATURE_BIT_SMALL_BATCH_DISBLE_FIX */ + 0x1, /* gcFEATURE_BIT_OUTPUT_CONVERT_UINT8_INT8_TO_UINT16_INT16_FIX */ + 0x1, /* gcFEATURE_BIT_IMAGE_NOT_PACKED_IN_SRAM_FIX */ 0x1, /* gcFEATURE_BIT_COEF_DELTA_CORD_OVERFLOW_ZRL_8BIT_FIX */ - 0x1, /* gcFEATURE_BIT_XY_OFFSET_LIMITATION_FIX */ - 0x1, /* gcFEATURE_BIT_USC_INVALIDATE_CACHE_LINE_FIX */ 0x0, /* gcFEATURE_BIT_LOW_EFFICIENCY_OF_ID_WRITE_IMGBUF_FIX */ - 0x0, /* gcFEATURE_BIT_KERNEL_PER_CORE_LESS_THAN_THIRD_COEF_BUFF_DEPTH_FIX */ + 0x1, /* gcFEATURE_BIT_KERNEL_VIP_SRAM_READ_BW_LIMITATION_FIX */ 0x0, /* gcFEATURE_BIT_USC_BOTTLENECK_FIX */ + 0x0, /* gcFEATURE_BIT_KERNEL_PER_CORE_LESS_THAN_THIRD_COEF_BUFF_DEPTH_FIX */ 0x0, /* gcFEATURE_BIT_KERNEL_SIZE_WASTE_IN_PARTIAL_MODE_FIX */ - 0x1, /* gcFEATURE_BIT_FULLCACHE_KERNEL_INTERLEAVE_FIX */ - 0x1, /* gcFEATURE_BIT_TP_REORDER_LAYER_SUSPEND_FIX */ - 0x1, /* gcFEATURE_BIT_KERNEL_VIP_SRAM_READ_BW_LIMITATION_FIX */ + 0x1, /* gcFEATURE_BIT_NN_COMMAND_KERNEL_REQUEST_CONFICT_FIX */ + 0x1, /* gcFEATURE_BIT_TP_REORDER_INTILE_X_SIZE_512_FIX */ 0x1, /* gcFEATURE_BIT_IMG_POP_PIPELINE_PAUSE_FIX */ + 0x1, /* gcFEATURE_BIT_FULLCACHE_KERNEL_INTERLEAVE_FIX */ + 0x0, /* gcFEATURE_BIT_V8_SINGLE_PORT_ACCUMULATION_BUFFER_RW_CONFICT_ZERO_SKIP_PERF_FIX */ + 0x0, /* gcFEATURE_BIT_V8_ACCUMLATION_READ_OUT_HAS_BUBBLES_PERF_FIX */ + 0x1, /* gcFEATURE_BIT_DEPTHWISE_NEIGHBOR_IMG_DATA_TRANSFER_NOT_EFFICIENT_FIX */ 0x1, /* gcFEATURE_BIT_DR_JD_DIFF_CONDITION_FOR_CACHELINE_MODE_PRE_FIX */ - 0x1, /* gcFEATURE_BIT_OUTIMAGE_X_BITWIDTH_LIMIT_FOR_NN_TRANSPOSE_FIX */ - 0x1, /* gcFEATURE_BIT_SMALL_BATCH_FLOPS_RESET_FIX */ - 0x0, /* gcFEATURE_BIT_SMALL_BATCH_DISBLE_FIX */ - 0x1, /* gcFEATURE_BIT_NEGATIVE_POST_SHIFT_FIX */ - 0x1, /* gcFEATURE_BIT_NN_COMMAND_KERNEL_REQUEST_CONFICT_FIX */ - 0x1, /* gcFEATURE_BIT_OCB_REMAP_PHYSICAL_ADDRESS */ - 0x1, /* gcFEATURE_BIT_NN_NO_Z_LOCATION_OFFSET */ - 0x0, /* gcFEATURE_BIT_NN_LEAKY_RELU */ - 0x0, /* gcFEATURE_BIT_NN_PRELU */ - 0x0, /* gcFEATURE_BIT_NN_PER_CHANNEL_QUANT */ - 0x0, /* gcFEATURE_BIT_NN_PER_CHANNEL_QUANT_ASYM */ - 0x0, /* gcFEATURE_BIT_NN_NATIVE_STRIDE_TWO */ - 0x0, /* gcFEATURE_BIT_NN_TENSOR_ADD */ - 0x0, /* gcFEATURE_BIT_NN_FLOAT_POST_MULT */ - 0x1, /* gcFEATURE_BIT_NN_SLICE_PADDING_TO_64BYTE_ALIGN */ - 0x0, /* gcFEATURE_BIT_NN_DW_1x1_CONV_MERGE */ - 0x1, /* gcFEATURE_BIT_NN_SLOW_OUTPUT */ - 0x1, /* gcFEATURE_BIT_NO_NARROW_POST_PROCESS_PIPE */ - 0x1, /* gcFEATURE_BIT_TP_NN_PROBE */ - 0x0, /* gcFEATURE_BIT_TP_23BITS_POST_MULTIPLIER */ - 0x1, /* gcFEATURE_BIT_NN_TRANSPOSE */ + 0x0, /* gcFEATURE_BIT_TP_ACCESS_VIPSRAM_OT_IS_ONE_FIX */ 0x0, /* gcFEATURE_BIT_EVIS2_FLOP_RESET_FIX */ + 0x1, /* gcFEATURE_BIT_OUTIMAGE_X_BITWIDTH_LIMIT_FOR_NN_TRANSPOSE_FIX */ 0x0, /* gcFEATURE_BIT_USC_ASYNC_CP_RTN_FLOP_RESET_FIX */ - 0x1, /* gcFEATURE_BIT_DDR_BURST_LEN_256B */ + 0x1, /* gcFEATURE_BIT_IMG_ADDR_NOT_WRAP_IF_OVER_OCB_ADDR_FIX */ + 0x1, /* gcFEATURE_BIT_NEGATIVE_POST_SHIFT_FIX */ + 0x1, /* gcFEATURE_BIT_INIMAGE_2DTILE_NOT_LESS_160PIXEL_FIX */ 0x0, /* gcFEATURE_BIT_IMG_CAHCE_MODE_MUST_0_IN_IMG_DIRECT_MODE_FIX */ - 0x1, /* gcFEATURE_BIT_USE_SINGLE_PORT_VIPSRAM */ - 0x0, /* gcFEATURE_BIT_NN_ASYMMETRIC_INT8 */ - 0x1, /* gcFEATURE_BIT_DEPTHWISE_NEIGHBOR_IMG_DATA_TRANSFER_NOT_EFFICIENT_FIX */ - 0x0, /* gcFEATURE_BIT_PRELU_LEAKLY_RELU_CLAMP */ - 0x0, /* gcFEATURE_BIT_TP_FLOAT32_IO */ - 0x0, /* gcFEATURE_BIT_NN_FLOAT32_IO */ - 0x0, /* gcFEATURE_BIT_NN_SMALL_BATCH_PHASE2 */ - 0x0, /* gcFEATURE_BIT_TILE_ACCESS_CAPABILITY */ - 0x0, /* gcFEATURE_BIT_FAST_DP3_PREPROCESSOR */ - 0x0, /* gcFEATURE_BIT_NN_COMPRESSION_BYPASSS */ - 0x0, /* gcFEATURE_BIT_BFLOAT_KERNEL_COMPRESSION_ZERO_SKIP_FIX */ - 0x0, /* gcFEATURE_BIT_TP_3_USC */ - 0x0, /* gcFEATURE_BIT_TP_KERNEL_1BYTE_ALGIN */ - 0x0, /* gcFEATURE_BIT_TPLITE_BFLOAT16 */ - 0x0, /* gcFEATURE_BIT_PREPROCESS_IMG_BUF_640BYTE_LIMIT */ - 0x0, /* gcFEATURE_BIT_V8_ACCUMLATION_READ_OUT_HAS_BUBBLES_PERF_FIX */ - 0x0, /* gcFEATURE_BIT_V8_SINGLE_PORT_ACCUMULATION_BUFFER_RW_CONFICT_ZERO_SKIP_PERF_FIX */ 0x0, /* gcFEATURE_BIT_BURST_COLLECT_DUMMY_DATA_WASTE_CYCLES_FIX */ 0x1, /* gcFEATURE_BIT_INIMG_NOT_64BYTE_ALIGN_CACHELINE_MODE_FIX */ - 0x0, /* gcFEATURE_BIT_TP_ACCESS_VIPSRAM_OT_IS_ONE_FIX */ - 0x0, /* gcFEATURE_BIT_VIP_HW_FINAL_RELEASE */ + 0x0, /* gcFEATURE_BIT_TP_FC_FLOAT_LAST_PIXEL_NEGATIVE_0_FIX */ + 0x1, /* gcFEATURE_BIT_NN_WASET_COEF_READ_WRITE_BANDWIDTH_128BYTE_VIPSRAM_IN_FULL_PATIAL_CACHE_MODE */ + 0x1, /* gcFEATURE_BIT_NN_IN_TILE_DATA_IS_ALL_PAD_FIX */ + 0x1, /* gcFEATURE_BIT_TP_FC_KERNEL_STREAM_MUST_LESS_THAN_OR_EQUAL_TO_64BYTE_WHEN_1BYTE_ALGINE_FIX */ + 0x0, /* gcFEATURE_BIT_NN_INTERLEVE8 */ + 0x0, /* gcFEATURE_BIT_NN_FP16_ALU */ + 0x1, /* gcFEATURE_BIT_NN_INT16_ALU */ + 0x1, /* gcFEATURE_BIT_NN_INT8_SCALE */ + 0x1, /* gcFEATURE_BIT_NN_POWER_ISOLATION */ + 0x0, /* gcFEATURE_BIT_ZRL_7BIT */ + 0x1, /* gcFEATURE_BIT_NN_SMALLBATCH_PHASE1 */ + 0x1, /* gcFEATURE_BIT_TP_SMALLBATCH_PHASE1 */ + 0x0, /* gcFEATURE_BIT_NN_SMALLBATCH */ + 0x0, /* gcFEATURE_BIT_TP_SMALLBATCH */ + 0x1, /* gcFEATURE_BIT_ZRL_8BIT */ + 0x1, /* gcFEATURE_BIT_DDR_BURST_LEN_256B */ + 0x1, /* gcFEATURE_BIT_XY_OFFSET_LIMITATION_FIX */ + 0x1, /* gcFEATURE_BIT_NN_NONZERO_MIRROR_BORDER */ + 0x0, /* gcFEATURE_BIT_IMAGE_PARTIAL_CACHE */ }, /* vipnano-qi */ { @@ -3727,13 +4069,23 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x140, /* gcFEATURE_VALUE_NumberOfConstants */ 0x1, /* gcFEATURE_VALUE_CoreCount */ 0x10, /* gcFEATURE_VALUE_LocalStorageSize */ + 0x0, /* gcFEATURE_VALUE_LocalStorageSize_1 */ + 0x0, /* gcFEATURE_VALUE_LocalStorageSize_2 */ 0x10, /* gcFEATURE_VALUE_L1CacheSize */ + 0x0, /* gcFEATURE_VALUE_L1CacheSize_1 */ + 0x0, /* gcFEATURE_VALUE_L1CacheSize_2 */ 0x200, /* gcFEATURE_VALUE_InstructionMemorySize */ 0x14, /* gcFEATURE_VALUE_ShaderPCLength */ 0x10, /* gcFEATURE_VALUE_USC_MAX_PAGES */ + 0x0, /* gcFEATURE_VALUE_USC_MAX_PAGES_1 */ + 0x0, /* gcFEATURE_VALUE_USC_MAX_PAGES_2 */ 0x1, /* gcFEATURE_VALUE_NumPixelPipes */ 0x2, /* gcFEATURE_VALUE_USC_CACHE_CONTROLLERS */ + 0x0, /* gcFEATURE_VALUE_USC_CACHE_CONTROLLERS_1 */ + 0x0, /* gcFEATURE_VALUE_USC_CACHE_CONTROLLERS_2 */ 0x2, /* gcFEATURE_VALUE_USC_BANKS */ + 0x0, /* gcFEATURE_VALUE_USC_BANKS_1 */ + 0x0, /* gcFEATURE_VALUE_USC_BANKS_2 */ 0x8, /* gcFEATURE_VALUE_Streams */ 0x10, /* gcFEATURE_VALUE_VaryingCount */ 0x400, /* gcFEATURE_VALUE_VertexOutputBufferSize */ @@ -3742,6 +4094,7 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_VALUE_NumResolvePipes */ 0x100, /* gcFEATURE_VALUE_RESULT_WINDOW_MAX_SIZE */ 0x0, /* gcFEATURE_VALUE_ClusterAliveMask */ + 0x0, /* gcFEATURE_VALUE_G2D_DEC400_MINOR */ 0x40, /* gcFEATURE_VALUE_NNMadPerCore */ 0x8, /* gcFEATURE_VALUE_NNCoreCount */ 0x8, /* gcFEATURE_VALUE_NNCoreCount_INT8 */ @@ -3766,14 +4119,26 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x40, /* gcFEATURE_VALUE_PHYSICAL_VIP_SRAM_WIDTH_IN_BYTE */ 0x20, /* gcFEATURE_VALUE_EQUIVALENT_VIP_SRAM_WIDTH_INBYTE */ 0x8, /* gcFEATURE_VALUE_TP_ZRL_BITS */ + 0x8, /* gcFEATURE_VALUE_NN_ZRL_BITS */ 0x80, /* gcFEATURE_VALUE_LATENCY_HIDING_AT_FULL_AXI_BW */ 0x10, /* gcFEATURE_VALUE_AXI_BUS_WIDTH */ 0xb, /* gcFEATURE_VALUE_NN_KERNEL_X_SIZE */ 0xb, /* gcFEATURE_VALUE_NN_KERNEL_Y_SIZE */ + 0xf, /* gcFEATURE_VALUE_NN_FC_KERNEL_Y_SIZE */ 0xfffff, /* gcFEATURE_VALUE_NN_KERNEL_Z_SIZE */ 0xf, /* gcFEATURE_VALUE_NN_X_OFFSET */ 0xf, /* gcFEATURE_VALUE_NN_Y_OFFSET */ 0x40, /* gcFEATURE_VALUE_DDR_KERNEL_BURST_SIZE */ + 0x10, /* gcFEATURE_VALUE_OUTIMAGE_X_STRIDE_BITS */ + 0x0, /* gcFEATURE_VALUE_OUTIMAGE_Y_STRIDE_BITS */ + 0x10, /* gcFEATURE_VALUE_INIMAGE_X_STRIDE_BITS */ + 0x10, /* gcFEATURE_VALUE_IMIMAGE_Y_STRIDE_BITS */ + 0xd, /* gcFEATURE_VALUE_OUTIMAGE_X_SIZE_BITS */ + 0xd, /* gcFEATURE_VALUE_OUTIMAGE_Y_SIZE_BITS */ + 0xe, /* gcFEATURE_VALUE_OUTIMAGE_SIZE_BITS */ + 0xd, /* gcFEATURE_VALUE_IMAGE_X_SIZE_BITS */ + 0xd, /* gcFEATURE_VALUE_INIMAGE_Y_SIZE_BITS */ + 0x40, /* gcFEATURE_VALUE_MAX_TILE_X_SIZE */ 0x0, /* gcFEATURE_BIT_REG_FastClear */ 0x0, /* gcFEATURE_BIT_REG_SpecialAntiAliasing */ 0x1, /* gcFEATURE_BIT_REG_Pipe3D */ @@ -4015,6 +4380,7 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x1, /* gcFEATURE_BIT_RA_HZEZ_CLOCK_CONTROL */ 0x1, /* gcFEATURE_BIT_CACHE128B256BPERLINE */ 0x1, /* gcFEATURE_BIT_V4Compression */ + 0x0, /* gcFEATURE_BIT_DE2D_MAJOR_SUPER_TILE */ 0x0, /* gcFEATURE_BIT_PE2D_MAJOR_SUPER_TILE */ 0x1, /* gcFEATURE_BIT_PE_32BPC_COLORMASK_FIX */ 0x1, /* gcFEATURE_BIT_ALPHA_BLENDING_OPT */ @@ -4147,6 +4513,7 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_BIT_TX_NO_FIXED_FILTER */ 0x0, /* gcFEATURE_BIT_SHARE_Z */ 0x0, /* gcFEATURE_BIT_DE_2D_FAST_CLEAR */ + 0x0, /* gcFEATURE_BIT_DE_TILESTATUS_ROTATION_FIX */ 0x0, /* gcFEATURE_BIT_TX_CLEAR_PENDING_FIX */ 0x0, /* gcFEATURE_BIT_NO_HI1_L2 */ 0x0, /* gcFEATURE_BIT_USC_EVICT_CTRL_FIFO_FLOP_RESET_FIX */ @@ -4157,6 +4524,13 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_BIT_SH_VX2_FLOATING_MAD_FIX */ 0x0, /* gcFEATURE_BIT_TS_FC_VULKAN_SUPPORT */ 0x0, /* gcFEATURE_BIT_MSAA_FLOAT_64BIT */ + 0x0, /* gcFEATURE_BIT_INDIRECT_COMPUTE_ZERODIM_FIX */ + 0x0, /* gcFEATURE_BIT_Q_CHANNEL_SUPPORT */ + 0x0, /* gcFEATURE_BIT_MMU_PAGE_DESCRIPTOR */ + 0x0, /* gcFEATURE_BIT_YUV_LINEAR_TO_TILE_ROTATE */ + 0x0, /* gcFEATURE_BIT_VEC2_IMULIMAD32_SUPPORT */ + 0x0, /* gcFEATURE_BIT_VEC4_IMULIMAD32_SUPPORT */ + 0x0, /* gcFEATURE_BIT_VEC2_IDIVIMOD16_SUPPORT */ 0x0, /* gcFEATURE_BIT_VG_TS_CULLING */ 0x0, /* gcFEATURE_BIT_VG_FP25 */ 0x0, /* gcFEATURE_BIT_VG_AYUV_INPUT_OUTPUT */ @@ -4183,6 +4557,20 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_BIT_DC_MMU */ 0x0, /* gcFEATURE_BIT_DC_COMPRESSION */ 0x0, /* gcFEATURE_BIT_DC_QOS */ + 0x1, /* gcFEATURE_BIT_VIP_HW_FINAL_RELEASE */ + 0x1, /* gcFEATURE_BIT_NN_SINGLEPORT_ACCUMBUFFER */ + 0x1, /* gcFEATURE_BIT_NN_STRIDE_SUPPORT */ + 0x1, /* gcFEATURE_BIT_SWTILING_PHASE1 */ + 0x1, /* gcFEATURE_BIT_SWTILING_PHASE2 */ + 0x0, /* gcFEATURE_BIT_TP_SIMPLE_INT16 */ + 0x1, /* gcFEATURE_BIT_TP_REAL_INT16 */ + 0x1, /* gcFEATURE_BIT_TP_ROI_POOLING */ + 0x1, /* gcFEATURE_BIT_TP_MAX_POOLING_STRIDE1 */ + 0x1, /* gcFEATURE_BIT_TP_LRN */ + 0x1, /* gcFEATURE_BIT_TP_REORDER */ + 0x1, /* gcFEATURE_BIT_TF_QUANTIZATION */ + 0x0, /* gcFEATURE_BIT_NN_NONZERO_BORDER */ + 0x1, /* gcFEATURE_BIT_NN_MIRROR_BORDER */ 0x0, /* gcFEATURE_BIT_AI_GPU */ 0x0, /* gcFEATURE_BIT_EVIS_NO_ABSDIFF */ 0x0, /* gcFEATURE_BIT_EVIS_NO_BITREPLACE */ @@ -4195,128 +4583,139 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_BIT_EVIS_LERP_7OUTPUT */ 0x0, /* gcFEATURE_BIT_EVIS_ACCSQ_8OUTPUT */ 0x1, /* gcFEATURE_BIT_EVIS_VX2 */ - 0x1, /* gcFEATURE_BIT_NN_FLOAT */ 0x1, /* gcFEATURE_BIT_TP_ENGINE */ 0x1, /* gcFEATURE_BIT_VIP_V7 */ - 0x0, /* gcFEATURE_BIT_MCFE */ - 0x0, /* gcFEATURE_BIT_NN_INTERLEVE8 */ - 0x1, /* gcFEATURE_BIT_TP_REORDER */ - 0x1, /* gcFEATURE_BIT_TP_LRN */ - 0x1, /* gcFEATURE_BIT_TP_MAX_POOLING_STRIDE1 */ - 0x0, /* gcFEATURE_BIT_NN_FP16_ALU */ - 0x1, /* gcFEATURE_BIT_NN_INT16_ALU */ - 0x1, /* gcFEATURE_BIT_TP_ROI_POOLING */ - 0x1, /* gcFEATURE_BIT_NN_ZDP3 */ + 0x0, /* gcFEATURE_BIT_TP_TENSOR_ADD_MUL */ + 0x0, /* gcFEATURE_BIT_NN_DEPTHWISE_INT16XINT8 */ + 0x0, /* gcFEATURE_BIT_TP_SOFTMAX */ + 0x0, /* gcFEATURE_BIT_NN_23BITS_POST_MULTIPLIER_VIP_V7 */ + 0x0, /* gcFEATURE_BIT_TP_23BITS_POST_MULTIPLIER_VIP_V7 */ + 0x0, /* gcFEATURE_BIT_HYBRID_MODE_VIP_V7 */ 0x0, /* gcFEATURE_BIT_NN_ZDP6 */ 0x0, /* gcFEATURE_BIT_NN_XYDP9 */ - 0x1, /* gcFEATURE_BIT_NN_INT8_SCALE */ - 0x1, /* gcFEATURE_BIT_NN_POWER_ISOLATION */ - 0x1, /* gcFEATURE_BIT_SWTILING_PHASE1 */ - 0x1, /* gcFEATURE_BIT_TF_QUANTIZATION */ - 0x0, /* gcFEATURE_BIT_TP_SIMPLE_INT16 */ - 0x1, /* gcFEATURE_BIT_TP_REAL_INT16 */ - 0x0, /* gcFEATURE_BIT_TP_BFLOAT16 */ 0x1, /* gcFEATURE_BIT_NN_FIRST_PIXEL_POOLING */ - 0x1, /* gcFEATURE_BIT_SWTILING_PHASE2 */ - 0x1, /* gcFEATURE_BIT_NN_STRIDE_SUPPORT */ + 0x1, /* gcFEATURE_BIT_NN_ZDP3 */ 0x1, /* gcFEATURE_BIT_NN_XYDP6 */ - 0x1, /* gcFEATURE_BIT_TP_REORDER_FIX */ - 0x1, /* gcFEATURE_BIT_NN_CONV1x1_PERF_FIX */ - 0x1, /* gcFEATURE_BIT_NN_CACHELINE_MODE_PERF_FIX */ - 0x0, /* gcFEATURE_BIT_NN_PER3DTILE_BUBBLE_FIX */ - 0x1, /* gcFEATURE_BIT_NN_CONVOUT_FIFO_DEPTH_FIX */ 0x1, /* gcFEATURE_BIT_SWTILING_PHASE3 */ + 0x0, /* gcFEATURE_BIT_MCFE */ 0x0, /* gcFEATURE_BIT_USC_STAY_LRU */ - 0x1, /* gcFEATURE_BIT_NN_NONZERO_MIRROR_BORDER */ + 0x1, /* gcFEATURE_BIT_COEF_COMPRESSION_ENHANCEMENT */ + 0x0, /* gcFEATURE_BIT_TP_COEF_COMPRESSION_ENHANCEMENT */ 0x1, /* gcFEATURE_BIT_NN_COEF_DECOMPRESS_PERF2X */ + 0x1, /* gcFEATURE_BIT_OCB_COUNTER */ + 0x0, /* gcFEATURE_BIT_SCALER */ + 0x0, /* gcFEATURE_BIT_SCALER_4K */ 0x0, /* gcFEATURE_BIT_INPUT_4BIT */ - 0x1, /* gcFEATURE_BIT_COEF_COMPRESSION_ENHANCEMENT */ + 0x0, /* gcFEATURE_BIT_NN_NO_Z_LOCATION_OFFSET */ + 0x1, /* gcFEATURE_BIT_OCB_REMAP_PHYSICAL_ADDRESS */ + 0x0, /* gcFEATURE_BIT_NN_SLOW_OUTPUT */ + 0x1, /* gcFEATURE_BIT_NO_NARROW_POST_PROCESS_PIPE */ + 0x0, /* gcFEATURE_BIT_TP_NN_PROBE */ + 0x0, /* gcFEATURE_BIT_NN_DEPTHWISE_SUPPORT */ + 0x0, /* gcFEATURE_BIT_NN_XYDP0 */ + 0x0, /* gcFEATURE_BIT_NN_WRITE_WITHOUT_USC */ + 0x0, /* gcFEATURE_BIT_NN_HW_LIMITATION_NATIVE_KER_1x2_2x1 */ + 0x0, /* gcFEATURE_BIT_NN_SLICE_PADDING_TO_64BYTE_ALIGN */ + 0x0, /* gcFEATURE_BIT_NN_DW_1x1_CONV_MERGE */ + 0x0, /* gcFEATURE_BIT_TP_BFLOAT16 */ + 0x0, /* gcFEATURE_BIT_TP_23BITS_POST_MULTIPLIER */ + 0x0, /* gcFEATURE_BIT_NN_TRANSPOSE */ + 0x0, /* gcFEATURE_BIT_USE_SINGLE_PORT_VIPSRAM */ + 0x0, /* gcFEATURE_BIT_NN_LEAKY_RELU */ + 0x0, /* gcFEATURE_BIT_NN_PRELU */ + 0x0, /* gcFEATURE_BIT_NN_PER_CHANNEL_QUANT */ + 0x0, /* gcFEATURE_BIT_NN_PER_CHANNEL_QUANT_ASYM */ + 0x0, /* gcFEATURE_BIT_NN_ASYMMETRIC_INT8 */ + 0x0, /* gcFEATURE_BIT_NN_FLOAT_POST_MULT */ + 0x0, /* gcFEATURE_BIT_PRELU_LEAKLY_RELU_CLAMP */ + 0x0, /* gcFEATURE_BIT_TPLITE_BFLOAT16 */ + 0x0, /* gcFEATURE_BIT_PREPROCESS_IMG_BUF_640BYTE_LIMIT */ + 0x0, /* gcFEATURE_BIT_TP_KERNEL_1BYTE_ALGIN */ + 0x0, /* gcFEATURE_BIT_BFLOAT_COEF_COMPRESSION_ZERO_COEFBIT14_INVERSE */ + 0x0, /* gcFEATURE_BIT_NN_COMPRESSION_BYPASSS */ + 0x0, /* gcFEATURE_BIT_TP_3_USC */ + 0x0, /* gcFEATURE_BIT_BFP_COEF_AUTO_PAD_INCOMPLETE_ZERO_IN_KZ_PLANE */ + 0x0, /* gcFEATURE_BIT_NN_NATIVE_STRIDE_TWO */ + 0x0, /* gcFEATURE_BIT_NN_TENSOR_ADD */ + 0x0, /* gcFEATURE_BIT_NN_FLOAT32_IO */ + 0x0, /* gcFEATURE_BIT_TP_FLOAT32_IO */ + 0x0, /* gcFEATURE_BIT_NN_SMALL_BATCH_PHASE2 */ + 0x0, /* gcFEATURE_BIT_TILE_ACCESS_CAPABILITY */ + 0x0, /* gcFEATURE_BIT_FAST_DP3_PREPROCESSOR */ + 0x0, /* gcFEATURE_BIT_DEPTHWISE_SUPPORT_16BIT_FORMAT */ + 0x0, /* gcFEATURE_BIT_NN_SUPPORT_ALU_LUT */ + 0x0, /* gcFEATURE_BIT_NN_ENHANCED_MAX_POOLING */ + 0x0, /* gcFEATURE_BIT_NN_TRANSPOSE_PHASE2 */ + 0x0, /* gcFEATURE_BIT_TPLITE_SUPPORT_TP_DATA_TRANSPOSE */ + 0x0, /* gcFEATURE_BIT_NN_SUPPORT_CONV_1D */ + 0x0, /* gcFEATURE_BIT_USE_VIPSRAM_FOR_KERNEL_STREAMING */ + 0x0, /* gcFEATURE_BIT_VIP_DEC400 */ + 0x0, /* gcFEATURE_BIT_NN_PER3DTILE_BUBBLE_FIX */ + 0x1, /* gcFEATURE_BIT_NN_CACHELINE_MODE_PERF_FIX */ + 0x1, /* gcFEATURE_BIT_NN_CONV1x1_PERF_FIX */ + 0x1, /* gcFEATURE_BIT_TP_REORDER_FIX */ + 0x1, /* gcFEATURE_BIT_NN_CONVOUT_FIFO_DEPTH_FIX */ 0x1, /* gcFEATURE_BIT_NN_ZXDP3_KERNEL_READ_CONFLICT_FIX */ 0x1, /* gcFEATURE_BIT_NN_ZDP3_NO_COMPRESS_FIX */ 0x1, /* gcFEATURE_BIT_NN_ASYNC_COPY_PERF_FIX */ - 0x1, /* gcFEATURE_BIT_OCB_COUNTER */ - 0x0, /* gcFEATURE_BIT_NN_XYDP0 */ - 0x0, /* gcFEATURE_BIT_ZRL_7BIT */ + 0x1, /* gcFEATURE_BIT_HI_REORDER_FIX */ + 0x1, /* gcFEATURE_BIT_INCORRECT_WR_REQ_TO_USC_BETWEEN_REORDER_AND_NORMAL_LAYER_FIX */ + 0x0, /* gcFEATURE_BIT_TP_REORDER_LAYER_SUSPEND_FIX */ 0x1, /* gcFEATURE_BIT_NN_ASYNC_COPY_MERGE_FIX */ - 0x1, /* gcFEATURE_BIT_NN_SMALLBATCH_PHASE1 */ - 0x1, /* gcFEATURE_BIT_TP_SMALLBATCH_PHASE1 */ - 0x0, /* gcFEATURE_BIT_SCALER */ - 0x0, /* gcFEATURE_BIT_SCALER_4K */ + 0x1, /* gcFEATURE_BIT_USC_INVALIDATE_CACHE_LINE_FIX */ 0x0, /* gcFEATURE_BIT_NN_REQ_SLOWARBITRATION_FIX */ - 0x0, /* gcFEATURE_BIT_IMAGE_PARTIAL_CACHE */ + 0x0, /* gcFEATURE_BIT_IMAGE_PARTIAL_CACHE_FIX */ 0x0, /* gcFEATURE_BIT_FULLCACHE_KERNELHEAD_FIX */ - 0x1, /* gcFEATURE_BIT_NN_SINGLEPORT_ACCUMBUFFER */ - 0x0, /* gcFEATURE_BIT_NN_SMALLBATCH */ - 0x0, /* gcFEATURE_BIT_TP_SMALLBATCH */ - 0x1, /* gcFEATURE_BIT_ZRL_8BIT */ - 0x0, /* gcFEATURE_BIT_NN_DEPTHWISE_SUPPORT */ - 0x0, /* gcFEATURE_BIT_NN_WRITE_WITHOUT_USC */ 0x0, /* gcFEATURE_BIT_NN_ZDP_INIMAGE_SIZE_FIX */ - 0x1, /* gcFEATURE_BIT_HI_REORDER_FIX */ - 0x1, /* gcFEATURE_BIT_INCORRECT_WR_REQ_TO_USC_BETWEEN_REORDER_AND_NORMAL_LAYER_FIX */ - 0x0, /* gcFEATURE_BIT_TP_COEF_COMPRESSION_ENHANCEMENT */ - 0x0, /* gcFEATURE_BIT_VIP_DEC400 */ - 0x0, /* gcFEATURE_BIT_IMAGE_NOT_PACKED_IN_SRAM_FIX */ 0x0, /* gcFEATURE_BIT_IDLE_BEFORE_FLUSH_COMPLETE_FIX */ 0x1, /* gcFEATURE_BIT_NO_FLUSH_USC_FIX */ + 0x1, /* gcFEATURE_BIT_SMALL_BATCH_FLOPS_RESET_FIX */ + 0x0, /* gcFEATURE_BIT_SMALL_BATCH_DISBLE_FIX */ + 0x1, /* gcFEATURE_BIT_OUTPUT_CONVERT_UINT8_INT8_TO_UINT16_INT16_FIX */ + 0x0, /* gcFEATURE_BIT_IMAGE_NOT_PACKED_IN_SRAM_FIX */ 0x1, /* gcFEATURE_BIT_COEF_DELTA_CORD_OVERFLOW_ZRL_8BIT_FIX */ - 0x0, /* gcFEATURE_BIT_XY_OFFSET_LIMITATION_FIX */ - 0x1, /* gcFEATURE_BIT_USC_INVALIDATE_CACHE_LINE_FIX */ 0x0, /* gcFEATURE_BIT_LOW_EFFICIENCY_OF_ID_WRITE_IMGBUF_FIX */ - 0x1, /* gcFEATURE_BIT_KERNEL_PER_CORE_LESS_THAN_THIRD_COEF_BUFF_DEPTH_FIX */ + 0x1, /* gcFEATURE_BIT_KERNEL_VIP_SRAM_READ_BW_LIMITATION_FIX */ 0x0, /* gcFEATURE_BIT_USC_BOTTLENECK_FIX */ + 0x1, /* gcFEATURE_BIT_KERNEL_PER_CORE_LESS_THAN_THIRD_COEF_BUFF_DEPTH_FIX */ 0x0, /* gcFEATURE_BIT_KERNEL_SIZE_WASTE_IN_PARTIAL_MODE_FIX */ - 0x0, /* gcFEATURE_BIT_FULLCACHE_KERNEL_INTERLEAVE_FIX */ - 0x0, /* gcFEATURE_BIT_TP_REORDER_LAYER_SUSPEND_FIX */ - 0x1, /* gcFEATURE_BIT_KERNEL_VIP_SRAM_READ_BW_LIMITATION_FIX */ + 0x0, /* gcFEATURE_BIT_NN_COMMAND_KERNEL_REQUEST_CONFICT_FIX */ + 0x0, /* gcFEATURE_BIT_TP_REORDER_INTILE_X_SIZE_512_FIX */ 0x1, /* gcFEATURE_BIT_IMG_POP_PIPELINE_PAUSE_FIX */ + 0x0, /* gcFEATURE_BIT_FULLCACHE_KERNEL_INTERLEAVE_FIX */ + 0x0, /* gcFEATURE_BIT_V8_SINGLE_PORT_ACCUMULATION_BUFFER_RW_CONFICT_ZERO_SKIP_PERF_FIX */ + 0x0, /* gcFEATURE_BIT_V8_ACCUMLATION_READ_OUT_HAS_BUBBLES_PERF_FIX */ + 0x1, /* gcFEATURE_BIT_DEPTHWISE_NEIGHBOR_IMG_DATA_TRANSFER_NOT_EFFICIENT_FIX */ 0x1, /* gcFEATURE_BIT_DR_JD_DIFF_CONDITION_FOR_CACHELINE_MODE_PRE_FIX */ - 0x1, /* gcFEATURE_BIT_OUTIMAGE_X_BITWIDTH_LIMIT_FOR_NN_TRANSPOSE_FIX */ - 0x1, /* gcFEATURE_BIT_SMALL_BATCH_FLOPS_RESET_FIX */ - 0x0, /* gcFEATURE_BIT_SMALL_BATCH_DISBLE_FIX */ - 0x1, /* gcFEATURE_BIT_NEGATIVE_POST_SHIFT_FIX */ - 0x0, /* gcFEATURE_BIT_NN_COMMAND_KERNEL_REQUEST_CONFICT_FIX */ - 0x1, /* gcFEATURE_BIT_OCB_REMAP_PHYSICAL_ADDRESS */ - 0x0, /* gcFEATURE_BIT_NN_NO_Z_LOCATION_OFFSET */ - 0x0, /* gcFEATURE_BIT_NN_LEAKY_RELU */ - 0x0, /* gcFEATURE_BIT_NN_PRELU */ - 0x0, /* gcFEATURE_BIT_NN_PER_CHANNEL_QUANT */ - 0x0, /* gcFEATURE_BIT_NN_PER_CHANNEL_QUANT_ASYM */ - 0x0, /* gcFEATURE_BIT_NN_NATIVE_STRIDE_TWO */ - 0x0, /* gcFEATURE_BIT_NN_TENSOR_ADD */ - 0x0, /* gcFEATURE_BIT_NN_FLOAT_POST_MULT */ - 0x0, /* gcFEATURE_BIT_NN_SLICE_PADDING_TO_64BYTE_ALIGN */ - 0x0, /* gcFEATURE_BIT_NN_DW_1x1_CONV_MERGE */ - 0x0, /* gcFEATURE_BIT_NN_SLOW_OUTPUT */ - 0x1, /* gcFEATURE_BIT_NO_NARROW_POST_PROCESS_PIPE */ - 0x0, /* gcFEATURE_BIT_TP_NN_PROBE */ - 0x0, /* gcFEATURE_BIT_TP_23BITS_POST_MULTIPLIER */ - 0x0, /* gcFEATURE_BIT_NN_TRANSPOSE */ + 0x0, /* gcFEATURE_BIT_TP_ACCESS_VIPSRAM_OT_IS_ONE_FIX */ 0x0, /* gcFEATURE_BIT_EVIS2_FLOP_RESET_FIX */ + 0x1, /* gcFEATURE_BIT_OUTIMAGE_X_BITWIDTH_LIMIT_FOR_NN_TRANSPOSE_FIX */ 0x0, /* gcFEATURE_BIT_USC_ASYNC_CP_RTN_FLOP_RESET_FIX */ - 0x0, /* gcFEATURE_BIT_DDR_BURST_LEN_256B */ + 0x1, /* gcFEATURE_BIT_IMG_ADDR_NOT_WRAP_IF_OVER_OCB_ADDR_FIX */ + 0x1, /* gcFEATURE_BIT_NEGATIVE_POST_SHIFT_FIX */ + 0x0, /* gcFEATURE_BIT_INIMAGE_2DTILE_NOT_LESS_160PIXEL_FIX */ 0x0, /* gcFEATURE_BIT_IMG_CAHCE_MODE_MUST_0_IN_IMG_DIRECT_MODE_FIX */ - 0x0, /* gcFEATURE_BIT_USE_SINGLE_PORT_VIPSRAM */ - 0x0, /* gcFEATURE_BIT_NN_ASYMMETRIC_INT8 */ - 0x1, /* gcFEATURE_BIT_DEPTHWISE_NEIGHBOR_IMG_DATA_TRANSFER_NOT_EFFICIENT_FIX */ - 0x0, /* gcFEATURE_BIT_PRELU_LEAKLY_RELU_CLAMP */ - 0x0, /* gcFEATURE_BIT_TP_FLOAT32_IO */ - 0x0, /* gcFEATURE_BIT_NN_FLOAT32_IO */ - 0x0, /* gcFEATURE_BIT_NN_SMALL_BATCH_PHASE2 */ - 0x0, /* gcFEATURE_BIT_TILE_ACCESS_CAPABILITY */ - 0x0, /* gcFEATURE_BIT_FAST_DP3_PREPROCESSOR */ - 0x0, /* gcFEATURE_BIT_NN_COMPRESSION_BYPASSS */ - 0x0, /* gcFEATURE_BIT_BFLOAT_KERNEL_COMPRESSION_ZERO_SKIP_FIX */ - 0x0, /* gcFEATURE_BIT_TP_3_USC */ - 0x0, /* gcFEATURE_BIT_TP_KERNEL_1BYTE_ALGIN */ - 0x0, /* gcFEATURE_BIT_TPLITE_BFLOAT16 */ - 0x0, /* gcFEATURE_BIT_PREPROCESS_IMG_BUF_640BYTE_LIMIT */ - 0x0, /* gcFEATURE_BIT_V8_ACCUMLATION_READ_OUT_HAS_BUBBLES_PERF_FIX */ - 0x0, /* gcFEATURE_BIT_V8_SINGLE_PORT_ACCUMULATION_BUFFER_RW_CONFICT_ZERO_SKIP_PERF_FIX */ 0x0, /* gcFEATURE_BIT_BURST_COLLECT_DUMMY_DATA_WASTE_CYCLES_FIX */ 0x1, /* gcFEATURE_BIT_INIMG_NOT_64BYTE_ALIGN_CACHELINE_MODE_FIX */ - 0x0, /* gcFEATURE_BIT_TP_ACCESS_VIPSRAM_OT_IS_ONE_FIX */ - 0x1, /* gcFEATURE_BIT_VIP_HW_FINAL_RELEASE */ + 0x1, /* gcFEATURE_BIT_TP_FC_FLOAT_LAST_PIXEL_NEGATIVE_0_FIX */ + 0x1, /* gcFEATURE_BIT_NN_WASET_COEF_READ_WRITE_BANDWIDTH_128BYTE_VIPSRAM_IN_FULL_PATIAL_CACHE_MODE */ + 0x1, /* gcFEATURE_BIT_NN_IN_TILE_DATA_IS_ALL_PAD_FIX */ + 0x1, /* gcFEATURE_BIT_TP_FC_KERNEL_STREAM_MUST_LESS_THAN_OR_EQUAL_TO_64BYTE_WHEN_1BYTE_ALGINE_FIX */ + 0x0, /* gcFEATURE_BIT_NN_INTERLEVE8 */ + 0x0, /* gcFEATURE_BIT_NN_FP16_ALU */ + 0x1, /* gcFEATURE_BIT_NN_INT16_ALU */ + 0x1, /* gcFEATURE_BIT_NN_INT8_SCALE */ + 0x1, /* gcFEATURE_BIT_NN_POWER_ISOLATION */ + 0x0, /* gcFEATURE_BIT_ZRL_7BIT */ + 0x1, /* gcFEATURE_BIT_NN_SMALLBATCH_PHASE1 */ + 0x1, /* gcFEATURE_BIT_TP_SMALLBATCH_PHASE1 */ + 0x0, /* gcFEATURE_BIT_NN_SMALLBATCH */ + 0x0, /* gcFEATURE_BIT_TP_SMALLBATCH */ + 0x1, /* gcFEATURE_BIT_ZRL_8BIT */ + 0x0, /* gcFEATURE_BIT_DDR_BURST_LEN_256B */ + 0x0, /* gcFEATURE_BIT_XY_OFFSET_LIMITATION_FIX */ + 0x1, /* gcFEATURE_BIT_NN_NONZERO_MIRROR_BORDER */ + 0x0, /* gcFEATURE_BIT_IMAGE_PARTIAL_CACHE */ }, /* vippico_v3 */ { @@ -4335,13 +4734,23 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x140, /* gcFEATURE_VALUE_NumberOfConstants */ 0x1, /* gcFEATURE_VALUE_CoreCount */ 0x10, /* gcFEATURE_VALUE_LocalStorageSize */ + 0x0, /* gcFEATURE_VALUE_LocalStorageSize_1 */ + 0x0, /* gcFEATURE_VALUE_LocalStorageSize_2 */ 0x10, /* gcFEATURE_VALUE_L1CacheSize */ + 0x0, /* gcFEATURE_VALUE_L1CacheSize_1 */ + 0x0, /* gcFEATURE_VALUE_L1CacheSize_2 */ 0x200, /* gcFEATURE_VALUE_InstructionMemorySize */ 0x14, /* gcFEATURE_VALUE_ShaderPCLength */ 0x10, /* gcFEATURE_VALUE_USC_MAX_PAGES */ + 0x0, /* gcFEATURE_VALUE_USC_MAX_PAGES_1 */ + 0x0, /* gcFEATURE_VALUE_USC_MAX_PAGES_2 */ 0x1, /* gcFEATURE_VALUE_NumPixelPipes */ 0x2, /* gcFEATURE_VALUE_USC_CACHE_CONTROLLERS */ + 0x0, /* gcFEATURE_VALUE_USC_CACHE_CONTROLLERS_1 */ + 0x0, /* gcFEATURE_VALUE_USC_CACHE_CONTROLLERS_2 */ 0x2, /* gcFEATURE_VALUE_USC_BANKS */ + 0x0, /* gcFEATURE_VALUE_USC_BANKS_1 */ + 0x0, /* gcFEATURE_VALUE_USC_BANKS_2 */ 0x8, /* gcFEATURE_VALUE_Streams */ 0x10, /* gcFEATURE_VALUE_VaryingCount */ 0x400, /* gcFEATURE_VALUE_VertexOutputBufferSize */ @@ -4350,6 +4759,7 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_VALUE_NumResolvePipes */ 0x100, /* gcFEATURE_VALUE_RESULT_WINDOW_MAX_SIZE */ 0x0, /* gcFEATURE_VALUE_ClusterAliveMask */ + 0x0, /* gcFEATURE_VALUE_G2D_DEC400_MINOR */ 0x40, /* gcFEATURE_VALUE_NNMadPerCore */ 0x2, /* gcFEATURE_VALUE_NNCoreCount */ 0x2, /* gcFEATURE_VALUE_NNCoreCount_INT8 */ @@ -4374,14 +4784,26 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x40, /* gcFEATURE_VALUE_PHYSICAL_VIP_SRAM_WIDTH_IN_BYTE */ 0x20, /* gcFEATURE_VALUE_EQUIVALENT_VIP_SRAM_WIDTH_INBYTE */ 0x8, /* gcFEATURE_VALUE_TP_ZRL_BITS */ + 0x8, /* gcFEATURE_VALUE_NN_ZRL_BITS */ 0x80, /* gcFEATURE_VALUE_LATENCY_HIDING_AT_FULL_AXI_BW */ 0x10, /* gcFEATURE_VALUE_AXI_BUS_WIDTH */ 0xb, /* gcFEATURE_VALUE_NN_KERNEL_X_SIZE */ 0xb, /* gcFEATURE_VALUE_NN_KERNEL_Y_SIZE */ + 0xf, /* gcFEATURE_VALUE_NN_FC_KERNEL_Y_SIZE */ 0xfffff, /* gcFEATURE_VALUE_NN_KERNEL_Z_SIZE */ 0xf, /* gcFEATURE_VALUE_NN_X_OFFSET */ 0xf, /* gcFEATURE_VALUE_NN_Y_OFFSET */ 0x40, /* gcFEATURE_VALUE_DDR_KERNEL_BURST_SIZE */ + 0x10, /* gcFEATURE_VALUE_OUTIMAGE_X_STRIDE_BITS */ + 0x0, /* gcFEATURE_VALUE_OUTIMAGE_Y_STRIDE_BITS */ + 0x10, /* gcFEATURE_VALUE_INIMAGE_X_STRIDE_BITS */ + 0x10, /* gcFEATURE_VALUE_IMIMAGE_Y_STRIDE_BITS */ + 0xd, /* gcFEATURE_VALUE_OUTIMAGE_X_SIZE_BITS */ + 0xd, /* gcFEATURE_VALUE_OUTIMAGE_Y_SIZE_BITS */ + 0xe, /* gcFEATURE_VALUE_OUTIMAGE_SIZE_BITS */ + 0xd, /* gcFEATURE_VALUE_IMAGE_X_SIZE_BITS */ + 0xd, /* gcFEATURE_VALUE_INIMAGE_Y_SIZE_BITS */ + 0x40, /* gcFEATURE_VALUE_MAX_TILE_X_SIZE */ 0x0, /* gcFEATURE_BIT_REG_FastClear */ 0x0, /* gcFEATURE_BIT_REG_SpecialAntiAliasing */ 0x1, /* gcFEATURE_BIT_REG_Pipe3D */ @@ -4623,6 +5045,7 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x1, /* gcFEATURE_BIT_RA_HZEZ_CLOCK_CONTROL */ 0x1, /* gcFEATURE_BIT_CACHE128B256BPERLINE */ 0x1, /* gcFEATURE_BIT_V4Compression */ + 0x0, /* gcFEATURE_BIT_DE2D_MAJOR_SUPER_TILE */ 0x0, /* gcFEATURE_BIT_PE2D_MAJOR_SUPER_TILE */ 0x1, /* gcFEATURE_BIT_PE_32BPC_COLORMASK_FIX */ 0x1, /* gcFEATURE_BIT_ALPHA_BLENDING_OPT */ @@ -4755,6 +5178,7 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_BIT_TX_NO_FIXED_FILTER */ 0x0, /* gcFEATURE_BIT_SHARE_Z */ 0x0, /* gcFEATURE_BIT_DE_2D_FAST_CLEAR */ + 0x0, /* gcFEATURE_BIT_DE_TILESTATUS_ROTATION_FIX */ 0x0, /* gcFEATURE_BIT_TX_CLEAR_PENDING_FIX */ 0x0, /* gcFEATURE_BIT_NO_HI1_L2 */ 0x0, /* gcFEATURE_BIT_USC_EVICT_CTRL_FIFO_FLOP_RESET_FIX */ @@ -4765,6 +5189,13 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_BIT_SH_VX2_FLOATING_MAD_FIX */ 0x0, /* gcFEATURE_BIT_TS_FC_VULKAN_SUPPORT */ 0x0, /* gcFEATURE_BIT_MSAA_FLOAT_64BIT */ + 0x0, /* gcFEATURE_BIT_INDIRECT_COMPUTE_ZERODIM_FIX */ + 0x0, /* gcFEATURE_BIT_Q_CHANNEL_SUPPORT */ + 0x0, /* gcFEATURE_BIT_MMU_PAGE_DESCRIPTOR */ + 0x0, /* gcFEATURE_BIT_YUV_LINEAR_TO_TILE_ROTATE */ + 0x0, /* gcFEATURE_BIT_VEC2_IMULIMAD32_SUPPORT */ + 0x0, /* gcFEATURE_BIT_VEC4_IMULIMAD32_SUPPORT */ + 0x0, /* gcFEATURE_BIT_VEC2_IDIVIMOD16_SUPPORT */ 0x0, /* gcFEATURE_BIT_VG_TS_CULLING */ 0x0, /* gcFEATURE_BIT_VG_FP25 */ 0x0, /* gcFEATURE_BIT_VG_AYUV_INPUT_OUTPUT */ @@ -4791,6 +5222,20 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_BIT_DC_MMU */ 0x0, /* gcFEATURE_BIT_DC_COMPRESSION */ 0x0, /* gcFEATURE_BIT_DC_QOS */ + 0x1, /* gcFEATURE_BIT_VIP_HW_FINAL_RELEASE */ + 0x1, /* gcFEATURE_BIT_NN_SINGLEPORT_ACCUMBUFFER */ + 0x1, /* gcFEATURE_BIT_NN_STRIDE_SUPPORT */ + 0x1, /* gcFEATURE_BIT_SWTILING_PHASE1 */ + 0x1, /* gcFEATURE_BIT_SWTILING_PHASE2 */ + 0x0, /* gcFEATURE_BIT_TP_SIMPLE_INT16 */ + 0x1, /* gcFEATURE_BIT_TP_REAL_INT16 */ + 0x1, /* gcFEATURE_BIT_TP_ROI_POOLING */ + 0x1, /* gcFEATURE_BIT_TP_MAX_POOLING_STRIDE1 */ + 0x1, /* gcFEATURE_BIT_TP_LRN */ + 0x1, /* gcFEATURE_BIT_TP_REORDER */ + 0x1, /* gcFEATURE_BIT_TF_QUANTIZATION */ + 0x0, /* gcFEATURE_BIT_NN_NONZERO_BORDER */ + 0x0, /* gcFEATURE_BIT_NN_MIRROR_BORDER */ 0x0, /* gcFEATURE_BIT_AI_GPU */ 0x0, /* gcFEATURE_BIT_EVIS_NO_ABSDIFF */ 0x0, /* gcFEATURE_BIT_EVIS_NO_BITREPLACE */ @@ -4803,128 +5248,139 @@ static gcsFEATURE_DATABASE gChipInfo[] = { 0x0, /* gcFEATURE_BIT_EVIS_LERP_7OUTPUT */ 0x0, /* gcFEATURE_BIT_EVIS_ACCSQ_8OUTPUT */ 0x1, /* gcFEATURE_BIT_EVIS_VX2 */ - 0x1, /* gcFEATURE_BIT_NN_FLOAT */ 0x1, /* gcFEATURE_BIT_TP_ENGINE */ 0x1, /* gcFEATURE_BIT_VIP_V7 */ - 0x0, /* gcFEATURE_BIT_MCFE */ - 0x0, /* gcFEATURE_BIT_NN_INTERLEVE8 */ - 0x1, /* gcFEATURE_BIT_TP_REORDER */ - 0x1, /* gcFEATURE_BIT_TP_LRN */ - 0x1, /* gcFEATURE_BIT_TP_MAX_POOLING_STRIDE1 */ - 0x0, /* gcFEATURE_BIT_NN_FP16_ALU */ - 0x0, /* gcFEATURE_BIT_NN_INT16_ALU */ - 0x1, /* gcFEATURE_BIT_TP_ROI_POOLING */ - 0x1, /* gcFEATURE_BIT_NN_ZDP3 */ + 0x0, /* gcFEATURE_BIT_TP_TENSOR_ADD_MUL */ + 0x0, /* gcFEATURE_BIT_NN_DEPTHWISE_INT16XINT8 */ + 0x0, /* gcFEATURE_BIT_TP_SOFTMAX */ + 0x0, /* gcFEATURE_BIT_NN_23BITS_POST_MULTIPLIER_VIP_V7 */ + 0x0, /* gcFEATURE_BIT_TP_23BITS_POST_MULTIPLIER_VIP_V7 */ + 0x0, /* gcFEATURE_BIT_HYBRID_MODE_VIP_V7 */ 0x0, /* gcFEATURE_BIT_NN_ZDP6 */ 0x0, /* gcFEATURE_BIT_NN_XYDP9 */ - 0x1, /* gcFEATURE_BIT_NN_INT8_SCALE */ - 0x1, /* gcFEATURE_BIT_NN_POWER_ISOLATION */ - 0x1, /* gcFEATURE_BIT_SWTILING_PHASE1 */ - 0x1, /* gcFEATURE_BIT_TF_QUANTIZATION */ - 0x0, /* gcFEATURE_BIT_TP_SIMPLE_INT16 */ - 0x1, /* gcFEATURE_BIT_TP_REAL_INT16 */ - 0x0, /* gcFEATURE_BIT_TP_BFLOAT16 */ 0x1, /* gcFEATURE_BIT_NN_FIRST_PIXEL_POOLING */ - 0x1, /* gcFEATURE_BIT_SWTILING_PHASE2 */ - 0x1, /* gcFEATURE_BIT_NN_STRIDE_SUPPORT */ + 0x1, /* gcFEATURE_BIT_NN_ZDP3 */ 0x1, /* gcFEATURE_BIT_NN_XYDP6 */ - 0x1, /* gcFEATURE_BIT_TP_REORDER_FIX */ - 0x1, /* gcFEATURE_BIT_NN_CONV1x1_PERF_FIX */ - 0x0, /* gcFEATURE_BIT_NN_CACHELINE_MODE_PERF_FIX */ - 0x0, /* gcFEATURE_BIT_NN_PER3DTILE_BUBBLE_FIX */ - 0x1, /* gcFEATURE_BIT_NN_CONVOUT_FIFO_DEPTH_FIX */ 0x1, /* gcFEATURE_BIT_SWTILING_PHASE3 */ + 0x0, /* gcFEATURE_BIT_MCFE */ 0x0, /* gcFEATURE_BIT_USC_STAY_LRU */ - 0x0, /* gcFEATURE_BIT_NN_NONZERO_MIRROR_BORDER */ + 0x1, /* gcFEATURE_BIT_COEF_COMPRESSION_ENHANCEMENT */ + 0x0, /* gcFEATURE_BIT_TP_COEF_COMPRESSION_ENHANCEMENT */ 0x0, /* gcFEATURE_BIT_NN_COEF_DECOMPRESS_PERF2X */ + 0x1, /* gcFEATURE_BIT_OCB_COUNTER */ + 0x0, /* gcFEATURE_BIT_SCALER */ + 0x0, /* gcFEATURE_BIT_SCALER_4K */ 0x0, /* gcFEATURE_BIT_INPUT_4BIT */ - 0x1, /* gcFEATURE_BIT_COEF_COMPRESSION_ENHANCEMENT */ + 0x0, /* gcFEATURE_BIT_NN_NO_Z_LOCATION_OFFSET */ + 0x1, /* gcFEATURE_BIT_OCB_REMAP_PHYSICAL_ADDRESS */ + 0x0, /* gcFEATURE_BIT_NN_SLOW_OUTPUT */ + 0x1, /* gcFEATURE_BIT_NO_NARROW_POST_PROCESS_PIPE */ + 0x0, /* gcFEATURE_BIT_TP_NN_PROBE */ + 0x0, /* gcFEATURE_BIT_NN_DEPTHWISE_SUPPORT */ + 0x0, /* gcFEATURE_BIT_NN_XYDP0 */ + 0x0, /* gcFEATURE_BIT_NN_WRITE_WITHOUT_USC */ + 0x0, /* gcFEATURE_BIT_NN_HW_LIMITATION_NATIVE_KER_1x2_2x1 */ + 0x0, /* gcFEATURE_BIT_NN_SLICE_PADDING_TO_64BYTE_ALIGN */ + 0x0, /* gcFEATURE_BIT_NN_DW_1x1_CONV_MERGE */ + 0x0, /* gcFEATURE_BIT_TP_BFLOAT16 */ + 0x0, /* gcFEATURE_BIT_TP_23BITS_POST_MULTIPLIER */ + 0x0, /* gcFEATURE_BIT_NN_TRANSPOSE */ + 0x0, /* gcFEATURE_BIT_USE_SINGLE_PORT_VIPSRAM */ + 0x0, /* gcFEATURE_BIT_NN_LEAKY_RELU */ + 0x0, /* gcFEATURE_BIT_NN_PRELU */ + 0x0, /* gcFEATURE_BIT_NN_PER_CHANNEL_QUANT */ + 0x0, /* gcFEATURE_BIT_NN_PER_CHANNEL_QUANT_ASYM */ + 0x0, /* gcFEATURE_BIT_NN_ASYMMETRIC_INT8 */ + 0x0, /* gcFEATURE_BIT_NN_FLOAT_POST_MULT */ + 0x0, /* gcFEATURE_BIT_PRELU_LEAKLY_RELU_CLAMP */ + 0x0, /* gcFEATURE_BIT_TPLITE_BFLOAT16 */ + 0x0, /* gcFEATURE_BIT_PREPROCESS_IMG_BUF_640BYTE_LIMIT */ + 0x0, /* gcFEATURE_BIT_TP_KERNEL_1BYTE_ALGIN */ + 0x0, /* gcFEATURE_BIT_BFLOAT_COEF_COMPRESSION_ZERO_COEFBIT14_INVERSE */ + 0x0, /* gcFEATURE_BIT_NN_COMPRESSION_BYPASSS */ + 0x0, /* gcFEATURE_BIT_TP_3_USC */ + 0x0, /* gcFEATURE_BIT_BFP_COEF_AUTO_PAD_INCOMPLETE_ZERO_IN_KZ_PLANE */ + 0x0, /* gcFEATURE_BIT_NN_NATIVE_STRIDE_TWO */ + 0x0, /* gcFEATURE_BIT_NN_TENSOR_ADD */ + 0x0, /* gcFEATURE_BIT_NN_FLOAT32_IO */ + 0x0, /* gcFEATURE_BIT_TP_FLOAT32_IO */ + 0x0, /* gcFEATURE_BIT_NN_SMALL_BATCH_PHASE2 */ + 0x0, /* gcFEATURE_BIT_TILE_ACCESS_CAPABILITY */ + 0x0, /* gcFEATURE_BIT_FAST_DP3_PREPROCESSOR */ + 0x0, /* gcFEATURE_BIT_DEPTHWISE_SUPPORT_16BIT_FORMAT */ + 0x0, /* gcFEATURE_BIT_NN_SUPPORT_ALU_LUT */ + 0x0, /* gcFEATURE_BIT_NN_ENHANCED_MAX_POOLING */ + 0x0, /* gcFEATURE_BIT_NN_TRANSPOSE_PHASE2 */ + 0x0, /* gcFEATURE_BIT_TPLITE_SUPPORT_TP_DATA_TRANSPOSE */ + 0x0, /* gcFEATURE_BIT_NN_SUPPORT_CONV_1D */ + 0x0, /* gcFEATURE_BIT_USE_VIPSRAM_FOR_KERNEL_STREAMING */ + 0x0, /* gcFEATURE_BIT_VIP_DEC400 */ + 0x0, /* gcFEATURE_BIT_NN_PER3DTILE_BUBBLE_FIX */ + 0x0, /* gcFEATURE_BIT_NN_CACHELINE_MODE_PERF_FIX */ + 0x1, /* gcFEATURE_BIT_NN_CONV1x1_PERF_FIX */ + 0x1, /* gcFEATURE_BIT_TP_REORDER_FIX */ + 0x1, /* gcFEATURE_BIT_NN_CONVOUT_FIFO_DEPTH_FIX */ 0x0, /* gcFEATURE_BIT_NN_ZXDP3_KERNEL_READ_CONFLICT_FIX */ 0x1, /* gcFEATURE_BIT_NN_ZDP3_NO_COMPRESS_FIX */ 0x1, /* gcFEATURE_BIT_NN_ASYNC_COPY_PERF_FIX */ - 0x1, /* gcFEATURE_BIT_OCB_COUNTER */ - 0x0, /* gcFEATURE_BIT_NN_XYDP0 */ - 0x1, /* gcFEATURE_BIT_ZRL_7BIT */ + 0x1, /* gcFEATURE_BIT_HI_REORDER_FIX */ + 0x1, /* gcFEATURE_BIT_INCORRECT_WR_REQ_TO_USC_BETWEEN_REORDER_AND_NORMAL_LAYER_FIX */ + 0x0, /* gcFEATURE_BIT_TP_REORDER_LAYER_SUSPEND_FIX */ 0x1, /* gcFEATURE_BIT_NN_ASYNC_COPY_MERGE_FIX */ - 0x1, /* gcFEATURE_BIT_NN_SMALLBATCH_PHASE1 */ - 0x1, /* gcFEATURE_BIT_TP_SMALLBATCH_PHASE1 */ - 0x0, /* gcFEATURE_BIT_SCALER */ - 0x0, /* gcFEATURE_BIT_SCALER_4K */ + 0x1, /* gcFEATURE_BIT_USC_INVALIDATE_CACHE_LINE_FIX */ 0x0, /* gcFEATURE_BIT_NN_REQ_SLOWARBITRATION_FIX */ - 0x0, /* gcFEATURE_BIT_IMAGE_PARTIAL_CACHE */ + 0x0, /* gcFEATURE_BIT_IMAGE_PARTIAL_CACHE_FIX */ 0x0, /* gcFEATURE_BIT_FULLCACHE_KERNELHEAD_FIX */ - 0x1, /* gcFEATURE_BIT_NN_SINGLEPORT_ACCUMBUFFER */ - 0x0, /* gcFEATURE_BIT_NN_SMALLBATCH */ - 0x0, /* gcFEATURE_BIT_TP_SMALLBATCH */ - 0x1, /* gcFEATURE_BIT_ZRL_8BIT */ - 0x0, /* gcFEATURE_BIT_NN_DEPTHWISE_SUPPORT */ - 0x0, /* gcFEATURE_BIT_NN_WRITE_WITHOUT_USC */ 0x0, /* gcFEATURE_BIT_NN_ZDP_INIMAGE_SIZE_FIX */ - 0x1, /* gcFEATURE_BIT_HI_REORDER_FIX */ - 0x1, /* gcFEATURE_BIT_INCORRECT_WR_REQ_TO_USC_BETWEEN_REORDER_AND_NORMAL_LAYER_FIX */ - 0x0, /* gcFEATURE_BIT_TP_COEF_COMPRESSION_ENHANCEMENT */ - 0x0, /* gcFEATURE_BIT_VIP_DEC400 */ - 0x0, /* gcFEATURE_BIT_IMAGE_NOT_PACKED_IN_SRAM_FIX */ 0x0, /* gcFEATURE_BIT_IDLE_BEFORE_FLUSH_COMPLETE_FIX */ 0x1, /* gcFEATURE_BIT_NO_FLUSH_USC_FIX */ + 0x1, /* gcFEATURE_BIT_SMALL_BATCH_FLOPS_RESET_FIX */ + 0x0, /* gcFEATURE_BIT_SMALL_BATCH_DISBLE_FIX */ + 0x1, /* gcFEATURE_BIT_OUTPUT_CONVERT_UINT8_INT8_TO_UINT16_INT16_FIX */ + 0x0, /* gcFEATURE_BIT_IMAGE_NOT_PACKED_IN_SRAM_FIX */ 0x0, /* gcFEATURE_BIT_COEF_DELTA_CORD_OVERFLOW_ZRL_8BIT_FIX */ - 0x0, /* gcFEATURE_BIT_XY_OFFSET_LIMITATION_FIX */ - 0x1, /* gcFEATURE_BIT_USC_INVALIDATE_CACHE_LINE_FIX */ 0x0, /* gcFEATURE_BIT_LOW_EFFICIENCY_OF_ID_WRITE_IMGBUF_FIX */ - 0x1, /* gcFEATURE_BIT_KERNEL_PER_CORE_LESS_THAN_THIRD_COEF_BUFF_DEPTH_FIX */ + 0x1, /* gcFEATURE_BIT_KERNEL_VIP_SRAM_READ_BW_LIMITATION_FIX */ 0x0, /* gcFEATURE_BIT_USC_BOTTLENECK_FIX */ + 0x1, /* gcFEATURE_BIT_KERNEL_PER_CORE_LESS_THAN_THIRD_COEF_BUFF_DEPTH_FIX */ 0x0, /* gcFEATURE_BIT_KERNEL_SIZE_WASTE_IN_PARTIAL_MODE_FIX */ - 0x0, /* gcFEATURE_BIT_FULLCACHE_KERNEL_INTERLEAVE_FIX */ - 0x0, /* gcFEATURE_BIT_TP_REORDER_LAYER_SUSPEND_FIX */ - 0x1, /* gcFEATURE_BIT_KERNEL_VIP_SRAM_READ_BW_LIMITATION_FIX */ + 0x0, /* gcFEATURE_BIT_NN_COMMAND_KERNEL_REQUEST_CONFICT_FIX */ + 0x0, /* gcFEATURE_BIT_TP_REORDER_INTILE_X_SIZE_512_FIX */ 0x1, /* gcFEATURE_BIT_IMG_POP_PIPELINE_PAUSE_FIX */ + 0x0, /* gcFEATURE_BIT_FULLCACHE_KERNEL_INTERLEAVE_FIX */ + 0x0, /* gcFEATURE_BIT_V8_SINGLE_PORT_ACCUMULATION_BUFFER_RW_CONFICT_ZERO_SKIP_PERF_FIX */ + 0x0, /* gcFEATURE_BIT_V8_ACCUMLATION_READ_OUT_HAS_BUBBLES_PERF_FIX */ + 0x1, /* gcFEATURE_BIT_DEPTHWISE_NEIGHBOR_IMG_DATA_TRANSFER_NOT_EFFICIENT_FIX */ 0x1, /* gcFEATURE_BIT_DR_JD_DIFF_CONDITION_FOR_CACHELINE_MODE_PRE_FIX */ - 0x1, /* gcFEATURE_BIT_OUTIMAGE_X_BITWIDTH_LIMIT_FOR_NN_TRANSPOSE_FIX */ - 0x1, /* gcFEATURE_BIT_SMALL_BATCH_FLOPS_RESET_FIX */ - 0x0, /* gcFEATURE_BIT_SMALL_BATCH_DISBLE_FIX */ - 0x1, /* gcFEATURE_BIT_NEGATIVE_POST_SHIFT_FIX */ - 0x0, /* gcFEATURE_BIT_NN_COMMAND_KERNEL_REQUEST_CONFICT_FIX */ - 0x1, /* gcFEATURE_BIT_OCB_REMAP_PHYSICAL_ADDRESS */ - 0x0, /* gcFEATURE_BIT_NN_NO_Z_LOCATION_OFFSET */ - 0x0, /* gcFEATURE_BIT_NN_LEAKY_RELU */ - 0x0, /* gcFEATURE_BIT_NN_PRELU */ - 0x0, /* gcFEATURE_BIT_NN_PER_CHANNEL_QUANT */ - 0x0, /* gcFEATURE_BIT_NN_PER_CHANNEL_QUANT_ASYM */ - 0x0, /* gcFEATURE_BIT_NN_NATIVE_STRIDE_TWO */ - 0x0, /* gcFEATURE_BIT_NN_TENSOR_ADD */ - 0x0, /* gcFEATURE_BIT_NN_FLOAT_POST_MULT */ - 0x0, /* gcFEATURE_BIT_NN_SLICE_PADDING_TO_64BYTE_ALIGN */ - 0x0, /* gcFEATURE_BIT_NN_DW_1x1_CONV_MERGE */ - 0x0, /* gcFEATURE_BIT_NN_SLOW_OUTPUT */ - 0x1, /* gcFEATURE_BIT_NO_NARROW_POST_PROCESS_PIPE */ - 0x0, /* gcFEATURE_BIT_TP_NN_PROBE */ - 0x0, /* gcFEATURE_BIT_TP_23BITS_POST_MULTIPLIER */ - 0x0, /* gcFEATURE_BIT_NN_TRANSPOSE */ + 0x0, /* gcFEATURE_BIT_TP_ACCESS_VIPSRAM_OT_IS_ONE_FIX */ 0x0, /* gcFEATURE_BIT_EVIS2_FLOP_RESET_FIX */ + 0x1, /* gcFEATURE_BIT_OUTIMAGE_X_BITWIDTH_LIMIT_FOR_NN_TRANSPOSE_FIX */ 0x0, /* gcFEATURE_BIT_USC_ASYNC_CP_RTN_FLOP_RESET_FIX */ - 0x0, /* gcFEATURE_BIT_DDR_BURST_LEN_256B */ + 0x1, /* gcFEATURE_BIT_IMG_ADDR_NOT_WRAP_IF_OVER_OCB_ADDR_FIX */ + 0x1, /* gcFEATURE_BIT_NEGATIVE_POST_SHIFT_FIX */ + 0x0, /* gcFEATURE_BIT_INIMAGE_2DTILE_NOT_LESS_160PIXEL_FIX */ 0x0, /* gcFEATURE_BIT_IMG_CAHCE_MODE_MUST_0_IN_IMG_DIRECT_MODE_FIX */ - 0x0, /* gcFEATURE_BIT_USE_SINGLE_PORT_VIPSRAM */ - 0x0, /* gcFEATURE_BIT_NN_ASYMMETRIC_INT8 */ - 0x1, /* gcFEATURE_BIT_DEPTHWISE_NEIGHBOR_IMG_DATA_TRANSFER_NOT_EFFICIENT_FIX */ - 0x0, /* gcFEATURE_BIT_PRELU_LEAKLY_RELU_CLAMP */ - 0x0, /* gcFEATURE_BIT_TP_FLOAT32_IO */ - 0x0, /* gcFEATURE_BIT_NN_FLOAT32_IO */ - 0x0, /* gcFEATURE_BIT_NN_SMALL_BATCH_PHASE2 */ - 0x0, /* gcFEATURE_BIT_TILE_ACCESS_CAPABILITY */ - 0x0, /* gcFEATURE_BIT_FAST_DP3_PREPROCESSOR */ - 0x0, /* gcFEATURE_BIT_NN_COMPRESSION_BYPASSS */ - 0x0, /* gcFEATURE_BIT_BFLOAT_KERNEL_COMPRESSION_ZERO_SKIP_FIX */ - 0x0, /* gcFEATURE_BIT_TP_3_USC */ - 0x0, /* gcFEATURE_BIT_TP_KERNEL_1BYTE_ALGIN */ - 0x0, /* gcFEATURE_BIT_TPLITE_BFLOAT16 */ - 0x0, /* gcFEATURE_BIT_PREPROCESS_IMG_BUF_640BYTE_LIMIT */ - 0x0, /* gcFEATURE_BIT_V8_ACCUMLATION_READ_OUT_HAS_BUBBLES_PERF_FIX */ - 0x0, /* gcFEATURE_BIT_V8_SINGLE_PORT_ACCUMULATION_BUFFER_RW_CONFICT_ZERO_SKIP_PERF_FIX */ 0x0, /* gcFEATURE_BIT_BURST_COLLECT_DUMMY_DATA_WASTE_CYCLES_FIX */ 0x1, /* gcFEATURE_BIT_INIMG_NOT_64BYTE_ALIGN_CACHELINE_MODE_FIX */ - 0x0, /* gcFEATURE_BIT_TP_ACCESS_VIPSRAM_OT_IS_ONE_FIX */ - 0x1, /* gcFEATURE_BIT_VIP_HW_FINAL_RELEASE */ + 0x1, /* gcFEATURE_BIT_TP_FC_FLOAT_LAST_PIXEL_NEGATIVE_0_FIX */ + 0x1, /* gcFEATURE_BIT_NN_WASET_COEF_READ_WRITE_BANDWIDTH_128BYTE_VIPSRAM_IN_FULL_PATIAL_CACHE_MODE */ + 0x1, /* gcFEATURE_BIT_NN_IN_TILE_DATA_IS_ALL_PAD_FIX */ + 0x1, /* gcFEATURE_BIT_TP_FC_KERNEL_STREAM_MUST_LESS_THAN_OR_EQUAL_TO_64BYTE_WHEN_1BYTE_ALGINE_FIX */ + 0x0, /* gcFEATURE_BIT_NN_INTERLEVE8 */ + 0x0, /* gcFEATURE_BIT_NN_FP16_ALU */ + 0x0, /* gcFEATURE_BIT_NN_INT16_ALU */ + 0x1, /* gcFEATURE_BIT_NN_INT8_SCALE */ + 0x1, /* gcFEATURE_BIT_NN_POWER_ISOLATION */ + 0x1, /* gcFEATURE_BIT_ZRL_7BIT */ + 0x1, /* gcFEATURE_BIT_NN_SMALLBATCH_PHASE1 */ + 0x1, /* gcFEATURE_BIT_TP_SMALLBATCH_PHASE1 */ + 0x0, /* gcFEATURE_BIT_NN_SMALLBATCH */ + 0x0, /* gcFEATURE_BIT_TP_SMALLBATCH */ + 0x1, /* gcFEATURE_BIT_ZRL_8BIT */ + 0x0, /* gcFEATURE_BIT_DDR_BURST_LEN_256B */ + 0x0, /* gcFEATURE_BIT_XY_OFFSET_LIMITATION_FIX */ + 0x0, /* gcFEATURE_BIT_NN_NONZERO_MIRROR_BORDER */ + 0x0, /* gcFEATURE_BIT_IMAGE_PARTIAL_CACHE */ }, }; @@ -4975,5 +5431,3 @@ gcQueryFeatureDB( return gcvNULL; } #endif /* _gc_feature_database_h_ */ - - diff --git a/drivers/amlogic/npu/kernel/inc/gc_hal.h b/drivers/amlogic/npu/kernel/inc/gc_hal.h index 231a80d..8da8740 100644 --- a/drivers/amlogic/npu/kernel/inc/gc_hal.h +++ b/drivers/amlogic/npu/kernel/inc/gc_hal.h @@ -56,11 +56,11 @@ #ifndef __gc_hal_h_ #define __gc_hal_h_ -#include "shared/gc_hal_types.h" +#include "gc_hal_types.h" #include "gc_hal_enum.h" #include "gc_hal_base.h" #include "gc_hal_profiler.h" -#include "shared/gc_hal_driver.h" +#include "gc_hal_driver.h" #if gcdENABLE_3D #include "gc_hal_statistics.h" #endif @@ -413,6 +413,7 @@ gckOS_RequestReservedMemory( gctSIZE_T Size, const char * Name, gctBOOL Requested, + gctBOOL CpuAccessible, gctPOINTER * MemoryHandle ); @@ -422,6 +423,20 @@ gckOS_ReleaseReservedMemory( gctPOINTER MemoryHandle ); +/* Reserved memory sub area */ +gceSTATUS +gckOS_RequestReservedMemoryArea( + IN gctPOINTER MemoryHandle, + IN gctSIZE_T Offset, + IN gctSIZE_T Size, + OUT gctPOINTER * MemoryAreaHandle + ); + +void +gckOS_ReleaseReservedMemoryArea( + gctPOINTER MemoryAreaHandle + ); + /* Get the number fo bytes per page. */ gceSTATUS gckOS_GetPageSize( @@ -1415,6 +1430,15 @@ gckOS_ReleaseSemaphore( IN gctPOINTER Semaphore ); +#if gcdENABLE_SW_PREEMPTION +/* Release a semahore. */ +gceSTATUS +gckOS_ReleaseSemaphoreEx( + IN gckOS Os, + IN gctPOINTER Semaphore + ); +#endif + /******************************************************************************* ** Timer API. */ @@ -1501,6 +1525,8 @@ gckHEAP_ProfileEnd( typedef struct _gckVIDMEM * gckVIDMEM; typedef struct _gckKERNEL * gckKERNEL; +typedef struct _gckCOMMAND * gckCOMMAND; +typedef struct _gckEVENT * gckEVENT; typedef struct _gckDB * gckDB; typedef struct _gckDVFS * gckDVFS; typedef struct _gckMMU * gckMMU; @@ -1616,6 +1642,13 @@ gckKERNEL_Notify( IN gceNOTIFY Notifcation ); +gceSTATUS +gckKERNEL_SyncVideoMemory( + IN gckKERNEL Kernel, + IN gckVIDMEM_NODE Node, + IN gctUINT32 Reason + ); + /******************************************************************************* ** ** gckKERNEL_Recovery diff --git a/drivers/amlogic/npu/kernel/inc/gc_hal_base.h b/drivers/amlogic/npu/kernel/inc/gc_hal_base.h index 863adb6..09337a2 100644 --- a/drivers/amlogic/npu/kernel/inc/gc_hal_base.h +++ b/drivers/amlogic/npu/kernel/inc/gc_hal_base.h @@ -57,9 +57,9 @@ #define __gc_hal_base_h_ #include "gc_hal_enum.h" -#include "shared/gc_hal_types.h" +#include "gc_hal_types.h" #include "gc_hal_debug_zones.h" -#include "shared/gc_hal_base.h" +#include "shared/gc_hal_base_shared.h" #ifdef __cplusplus @@ -144,9 +144,6 @@ typedef struct _gcsNN_CUSTOMIZED_FEATURE { gctUINT vipSRAMSize; gctUINT axiSRAMSize; - gctUINT vipSRAMRemapStartAddr; - gctUINT axiSRAMRemapStartAddr; - gctUINT axiSRAMRemapEndAddr; gctFLOAT ddrReadBWLimit; gctFLOAT ddrWriteBWLimit; gctFLOAT ddrTotalBWLimit; @@ -336,6 +333,11 @@ typedef struct _gcsTLS /* Driver tls. */ gcsDRIVER_TLS_PTR driverTLS[gcvTLS_KEY_COUNT]; + +#if gcdENABLE_SW_PREEMPTION + /* PriorityID. */ + gctUINT priorityID; +#endif } gcsTLS; @@ -831,6 +833,14 @@ gcoHAL_GetCurrentCoreIndex( ); gceSTATUS +gcoHAL_InitCoreIndexByType( + IN gcoHAL Hal, + IN gceHARDWARE_TYPE Type, + IN gctBOOL Init, + OUT gctUINT32 *CoreIndex + ); + +gceSTATUS gcoHAL_ConvertCoreIndexGlobal( IN gcoHAL Hal, IN gceHARDWARE_TYPE Type, @@ -921,7 +931,7 @@ gcoHAL_AllocateVideoMemory( IN gctUINT Alignment, IN gceVIDMEM_TYPE Type, IN gctUINT32 Flag, - IN gcePOOL Pool, + IN OUT gcePOOL *Pool, IN OUT gctSIZE_T * Bytes, OUT gctUINT32_PTR Node ); @@ -968,6 +978,16 @@ gcoHAL_QueryTargetCaps( #endif gceSTATUS +gcoHAL_PrepareVideoMemory( + IN gctUINT32 Node + ); + +gceSTATUS +gcoHAL_FinishVideoMemory( + IN gctUINT32 Node + ); + +gceSTATUS gcoHAL_WrapUserMemory( IN gcsUSER_MEMORY_DESC_PTR UserMemoryDesc, IN gceVIDMEM_TYPE Type, @@ -2139,6 +2159,13 @@ typedef struct _gcsFORMAT_CLASS_TYPE_DEPTH } gcsFORMAT_CLASS_TYPE_DEPTH; +/* Intensity format class. */ +typedef struct _gcsFORMAT_CLASs_TYPE_INTENSITY +{ + gcsFORMAT_COMPONENT value; +} +gcsFORMAT_CLASs_TYPE_INTENSITY; + typedef union _gcuPIXEL_FORMAT_CLASS { gcsFORMAT_CLASS_TYPE_BUMP bump; @@ -2147,6 +2174,7 @@ typedef union _gcuPIXEL_FORMAT_CLASS gcsFORMAT_CLASS_TYPE_LUMINANCE lum; gcsFORMAT_CLASS_TYPE_INDEX index; gcsFORMAT_CLASS_TYPE_DEPTH depth; + gcsFORMAT_CLASs_TYPE_INTENSITY intensity; } gcuPIXEL_FORMAT_CLASS; @@ -5665,6 +5693,7 @@ gcoHAL_GetUserDebugOption( if (featureComputeOnly) \ { \ L1cacheSize = featureL1CacheSize; \ + attribCacheRatio = 0x7; \ } \ else \ { \ diff --git a/drivers/amlogic/npu/kernel/inc/gc_hal_driver.h b/drivers/amlogic/npu/kernel/inc/gc_hal_driver.h index ba15817..1ae5d0f 100644 --- a/drivers/amlogic/npu/kernel/inc/gc_hal_driver.h +++ b/drivers/amlogic/npu/kernel/inc/gc_hal_driver.h @@ -2,7 +2,7 @@ * * The MIT License (MIT) * -* Copyright (c) 2014 - 2019 Vivante Corporation +* Copyright (c) 2014 - 2020 Vivante Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -26,7 +26,7 @@ * * The GPL License (GPL) * -* Copyright (C) 2014 - 2019 Vivante Corporation +* Copyright (C) 2014 - 2020 Vivante Corporation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -53,1341 +53,7 @@ *****************************************************************************/ -#ifndef __gc_hal_driver_h_ -#define __gc_hal_driver_h_ +#include "shared/gc_hal_driver_shared.h" -#include "gc_hal_enum.h" -#include "gc_hal_types.h" - - -#ifdef __cplusplus -extern "C" { -#endif - -/******************************************************************************\ -******************************* I/O Control Codes ****************************** -\******************************************************************************/ - -#define gcvHAL_CLASS "galcore" -#define IOCTL_GCHAL_INTERFACE 30000 -#define IOCTL_GCHAL_KERNEL_INTERFACE 30001 -#define IOCTL_GCHAL_TERMINATE 30002 - -/******************************************************************************\ -********************************* Command Codes ******************************** -\******************************************************************************/ - -typedef enum _gceHAL_COMMAND_CODES -{ - /*************** Common ***************/ - - /* Chip info: count, type and so on. */ - gcvHAL_CHIP_INFO, - - /* HAL driver version. */ - gcvHAL_VERSION, - - /* Query chip id and options. */ - gcvHAL_QUERY_CHIP_IDENTITY, - gcvHAL_QUERY_CHIP_OPTION, - - /* Query chip frequency, used by CL. */ - gcvHAL_QUERY_CHIP_FREQUENCY, - - /* Query system pool video memory, used by CL. */ - gcvHAL_QUERY_VIDEO_MEMORY, - - /* Memory management. */ - gcvHAL_ALLOCATE_LINEAR_VIDEO_MEMORY, - gcvHAL_WRAP_USER_MEMORY, - gcvHAL_RELEASE_VIDEO_MEMORY, - gcvHAL_LOCK_VIDEO_MEMORY, - gcvHAL_UNLOCK_VIDEO_MEMORY, - gcvHAL_BOTTOM_HALF_UNLOCK_VIDEO_MEMORY, - gcvHAL_MAP_MEMORY, - gcvHAL_UNMAP_MEMORY, - - /* Cache operations. */ - gcvHAL_CACHE, - - /* HAL user attach and detach. */ - gcvHAL_ATTACH, - gcvHAL_DETACH, - - /* Event commit. */ - gcvHAL_EVENT_COMMIT, - - /* User command commit. */ - gcvHAL_COMMIT, - - /* Set hardware timeout, used by CL. */ - gcvHAL_SET_TIMEOUT, - - /* User signal operations. */ - gcvHAL_USER_SIGNAL, - - /* Event signal, commit stall. */ - gcvHAL_SIGNAL, - - /* Profile related. */ - gcvHAL_SET_PROFILE_SETTING, - gcvHAL_READ_PROFILER_REGISTER_SETTING, - gcvHAL_READ_ALL_PROFILE_REGISTERS_PART1, - gcvHAL_READ_ALL_PROFILE_REGISTERS_PART2, - - /* Query process database info when debug trace and proflie. */ - gcvHAL_DATABASE, - - /* Power managment enable/disable. */ - gcvHAL_CONFIG_POWER_MANAGEMENT, - - /* Debug/dump feature. */ - gcvHAL_DEBUG_DUMP, - - /*************** Common end ***************/ - - /*************** GPU only ***************/ - /* Register operations, 2D only. */ - gcvHAL_READ_REGISTER, - gcvHAL_WRITE_REGISTER, - gcvHAL_PROFILE_REGISTERS_2D, - - /* Get base address for old mmu. */ - gcvHAL_GET_BASE_ADDRESS, - - /* Read frame database, 3D only. */ - gcvHAL_GET_FRAME_INFO, - - /* Set video memory meta data. */ - gcvHAL_SET_VIDEO_MEMORY_METADATA, - - /* Query command buffer, VG only. */ - gcvHAL_QUERY_COMMAND_BUFFER, - - /* Reset time stamp. */ - gcvHAL_QUERY_RESET_TIME_STAMP, - - /* Create native fence. */ - gcvHAL_CREATE_NATIVE_FENCE, - - /* Wait native fence. */ - gcvHAL_WAIT_NATIVE_FENCE, - - /* Wait until GPU finishes access to a resource. */ - gcvHAL_WAIT_FENCE, - - /* Video memory node operations. */ - gcvHAL_EXPORT_VIDEO_MEMORY, - gcvHAL_NAME_VIDEO_MEMORY, - gcvHAL_IMPORT_VIDEO_MEMORY, - - /* Mutex Operation. */ - gcvHAL_DEVICE_MUTEX, - /*************** GPU only end ***************/ - - /*************** DEC only ***************/ - /* DEC200 test. */ - gcvHAL_DEC200_TEST, - - /* DEC300 related operations. */ - gcvHAL_DEC300_READ, - gcvHAL_DEC300_WRITE, - gcvHAL_DEC300_FLUSH, - gcvHAL_DEC300_FLUSH_WAIT, - /*************** DEC only end ***************/ - - /*************** OS specific ***************/ - - /* Android gralloc: shared buffer operations. */ - gcvHAL_SHBUF, - - /* Android gralloc: get graphic buffer fd. */ - gcvHAL_GET_GRAPHIC_BUFFER_FD, - - /* Vsimulator only. */ - gcvHAL_UPDATE_DEBUG_CALLBACK, - gcvHAL_CONFIG_CTX_FRAMEWORK, - - /* Non paged memory management backup compatibility, windows, qnx. */ - gcvHAL_ALLOCATE_NON_PAGED_MEMORY, - gcvHAL_FREE_NON_PAGED_MEMORY, - - /* Write user data, windows only. */ - gcvHAL_WRITE_DATA, - - /*************** OS specific end ***************/ - - /*************** Reserved ***************/ - gcvHAL_SET_IDLE, - gcvHAL_RESET, - - /* Command commit done, kernel event only. */ - gcvHAL_COMMIT_DONE, - - /* Get video memory file description. */ - gcvHAL_GET_VIDEO_MEMORY_FD, - - /* Get profile setting. */ - gcvHAL_GET_PROFILE_SETTING, - - /* Read/Write register ex. */ - gcvHAL_READ_REGISTER_EX, - gcvHAL_WRITE_REGISTER_EX, - - /* Power managment state. */ - gcvHAL_SET_POWER_MANAGEMENT_STATE, - gcvHAL_QUERY_POWER_MANAGEMENT_STATE, - - /* Set debug level. */ - gcvHAL_SET_DEBUG_LEVEL_ZONE, - - /* Dump info. */ - gcvHAL_DUMP_GPU_STATE, - gcvHAL_DUMP_EVENT, - gcvHAL_DUMP_GPU_PROFILE, - - /* Timer. */ - gcvHAL_TIMESTAMP, - - /* FSCALE_VAL. */ - gcvHAL_SET_FSCALE_VALUE, - gcvHAL_GET_FSCALE_VALUE, - - /* Destory MMU. */ - gcvHAL_DESTROY_MMU, - /*************** Reserved end ***************/ -} -gceHAL_COMMAND_CODES; - -/******************************************************************************\ -****************************** Interface Structure ***************************** -\******************************************************************************/ - -#define gcdMAX_PROFILE_FILE_NAME 128 -#define gcdMAX_FLAT_MAPPING_COUNT 16 - -/* gcvHAL_CHIP_INFO */ -typedef struct _gcsHAL_CHIP_INFO -{ - /* Chip count. */ - OUT gctINT32 count; - - /* Chip types. */ - OUT gceHARDWARE_TYPE types[gcdCHIP_COUNT]; - - /* Chip IDs. */ - OUT gctUINT32 ids[gcvCORE_COUNT]; -} -gcsHAL_CHIP_INFO; - -/* gcvHAL_VERSION */ -typedef struct _gcsHAL_VERSION -{ - /* version: ... */ - OUT gctINT32 major; - OUT gctINT32 minor; - OUT gctINT32 patch; - - /* Build version. */ - OUT gctUINT32 build; -} -gcsHAL_VERSION; - -/* gcvHAL_SET_TIMEOUT. */ -typedef struct _gcsHAL_SET_TIMEOUT -{ - gctUINT32 timeOut; -} -gcsHAL_SET_TIMEOUT; - -/* gcvHAL_QUERY_VIDEO_MEMORY */ -typedef struct _gcsHAL_QUERY_VIDEO_MEMORY -{ - /* Physical memory address of internal memory. Just a name. */ - OUT gctUINT32 internalPhysName; - /* Size in bytes of internal memory. */ - OUT gctUINT64 internalSize; - - /* Physical memory address of external memory. Just a name. */ - OUT gctUINT32 externalPhysName; - /* Size in bytes of external memory.*/ - OUT gctUINT64 externalSize; - - /* Physical memory address of contiguous memory. Just a name. */ - OUT gctUINT32 contiguousPhysName; - /* Size in bytes of contiguous memory.*/ - OUT gctUINT64 contiguousSize; -} -gcsHAL_QUERY_VIDEO_MEMORY; - -enum -{ - /* GPU can't issue more that 32bit physical address */ - gcvPLATFORM_FLAG_LIMIT_4G_ADDRESS = 1 << 0, - - gcvPLATFORM_FLAG_IMX_MM = 1 << 1, -}; - -/* gcvHAL_QUERY_CHIP_IDENTITY */ -typedef struct _gcsHAL_QUERY_CHIP_IDENTITY * gcsHAL_QUERY_CHIP_IDENTITY_PTR; -typedef struct _gcsHAL_QUERY_CHIP_IDENTITY -{ - - /* Chip model. */ - gceCHIPMODEL chipModel; - - /* Revision value.*/ - gctUINT32 chipRevision; - - /* Chip date. */ - gctUINT32 chipDate; - - /* Supported feature fields. */ - gctUINT32 chipFeatures; - - /* Supported minor feature fields. */ - gctUINT32 chipMinorFeatures; - - /* Supported minor feature 1 fields. */ - gctUINT32 chipMinorFeatures1; - - /* Supported minor feature 2 fields. */ - gctUINT32 chipMinorFeatures2; - - /* Supported minor feature 3 fields. */ - gctUINT32 chipMinorFeatures3; - - /* Supported minor feature 4 fields. */ - gctUINT32 chipMinorFeatures4; - - /* Supported minor feature 5 fields. */ - gctUINT32 chipMinorFeatures5; - - /* Supported minor feature 6 fields. */ - gctUINT32 chipMinorFeatures6; - - /* Number of streams supported. */ - gctUINT32 streamCount; - - /* Number of pixel pipes. */ - gctUINT32 pixelPipes; - - /* Number of resolve pipes. */ - gctUINT32 resolvePipes; - - /* Number of instructions. */ - gctUINT32 instructionCount; - - /* Number of constants. */ - gctUINT32 numConstants; - - /* Number of varyings */ - gctUINT32 varyingsCount; - - /* Number of 3D GPUs */ - gctUINT32 gpuCoreCount; - - /* Physical mask of all AVAILABLE clusters in core.*/ - gctUINT32 clusterAvailMask; - - /* Product ID */ - gctUINT32 productID; - - /* Special chip flag bits */ - gceCHIP_FLAG chipFlags; - - /* ECO ID. */ - gctUINT32 ecoID; - - /* Customer ID. */ - gctUINT32 customerID; - - /* CPU view physical address and size of SRAMs. */ - gctUINT64 sRAMBases[gcvSRAM_INTER_COUNT]; - gctUINT32 sRAMSizes[gcvSRAM_INTER_COUNT]; - - gctUINT64 platformFlagBits; -} -gcsHAL_QUERY_CHIP_IDENTITY; - -/* gcvHAL_QUERY_CHIP_OPTION. */ -typedef struct _gcsHAL_QUERY_CHIP_OPTIONS * gcsHAL_QUERY_CHIP_OPTIONS_PTR; -typedef struct _gcsHAL_QUERY_CHIP_OPTIONS -{ - gctBOOL gpuProfiler; - gctBOOL allowFastClear; - gctBOOL powerManagement; - /* Whether use new MMU. It is meaningless - ** for old MMU since old MMU is always enabled. - */ - gctBOOL enableMMU; - gceCOMPRESSION_OPTION allowCompression; - gctBOOL smallBatch; - gctUINT32 uscL1CacheRatio; - gctUINT32 uscAttribCacheRatio; - gctUINT32 userClusterMask; - - /* Internal SRAM. */ - gctUINT32 sRAMGPUVirtAddrs[gcvSRAM_INTER_COUNT]; - gctUINT32 sRAMSizes[gcvSRAM_INTER_COUNT]; - gctUINT32 sRAMCount; - - /* External SRAM. */ - gctPHYS_ADDR_T extSRAMCPUPhysAddrs[gcvSRAM_EXT_COUNT]; - gctPHYS_ADDR_T extSRAMGPUPhysAddrs[gcvSRAM_EXT_COUNT]; - gctUINT32 extSRAMGPUVirtAddrs[gcvSRAM_EXT_COUNT]; - gctUINT32 extSRAMGPUPhysNames[gcvSRAM_EXT_COUNT]; - gctUINT32 extSRAMSizes[gcvSRAM_EXT_COUNT]; - gctUINT32 extSRAMCount; - - gceSECURE_MODE secureMode; - gctBOOL enableNNTPParallel; - gctUINT enableSwtilingPhase1; -} -gcsHAL_QUERY_CHIP_OPTIONS; - -/* gcvHAL_QUERY_CHIP_FREQUENCY. */ -typedef struct _gcsHAL_QUERY_CHIP_FREQUENCY * gcsHAL_QUERY_CHIP_FREQUENCY_PTR; -typedef struct _gcsHAL_QUERY_CHIP_FREQUENCY -{ - OUT gctUINT32 mcClk; - OUT gctUINT32 shClk; -} -gcsHAL_QUERY_CHIP_FREQUENCY; - -/* Obsolete for userpace. */ -/* gcvHAL_ALLOCATE_NON_PAGED_MEMORY */ -typedef struct _gcsHAL_ALLOCATE_NON_PAGED_MEMORY -{ - /* Allocation flags. */ - IN gctUINT32 flags; - - /* Number of bytes to allocate. */ - IN OUT gctUINT64 bytes; - - /* Physical address of allocation. Just a name. */ - OUT gctUINT32 physName; - - /* Logical address of allocation. */ - OUT gctUINT64 logical; -} -gcsHAL_ALLOCATE_NON_PAGED_MEMORY; - -/* Obsolete for userpace. */ -/* gcvHAL_FREE_NON_PAGED_MEMORY */ -typedef struct _gcsHAL_FREE_NON_PAGED_MEMORY -{ - /* Number of bytes allocated. */ - IN gctUINT64 bytes; - - /* Physical address of allocation. Just a name. */ - IN gctUINT32 physName; - - /* Logical address of allocation. */ - IN gctUINT64 logical; -} -gcsHAL_FREE_NON_PAGED_MEMORY; - -/* Video memory allocation. */ -/* gcvHAL_ALLOCATE_LINEAR_VIDEO_MEMORY */ -typedef struct _gcsHAL_ALLOCATE_LINEAR_VIDEO_MEMORY -{ - /* Number of bytes to allocate. */ - IN OUT gctUINT64 bytes; - - /* Buffer alignment. */ - IN gctUINT32 alignment; - - /* Type of allocation, see gceVIDMEM_TYPE. */ - IN gctUINT32 type; - - /* Flag of allocation. */ - IN gctUINT32 flag; - - /* Memory pool to allocate from. */ - IN OUT gctUINT32 pool; - - /* Internal SRAM index. */ - IN gctINT32 sRAMIndex; - /* External SRAM index. */ - IN gctINT32 extSRAMIndex; - - /* Allocated video memory. */ - OUT gctUINT32 node; -} -gcsHAL_ALLOCATE_LINEAR_VIDEO_MEMORY; - -typedef struct _gcsUSER_MEMORY_DESC -{ - /* Import flag. */ - gctUINT32 flag; - - /* gcvALLOC_FLAG_DMABUF */ - gctUINT32 handle; - gctUINT64 dmabuf; - - /* gcvALLOC_FLAG_USERMEMORY */ - gctUINT64 logical; - gctUINT64 physical; - gctUINT32 size; - - /* gcvALLOC_FLAG_EXTERNAL_MEMORY */ - gcsEXTERNAL_MEMORY_INFO externalMemoryInfo; -} -gcsUSER_MEMORY_DESC; - -/* gcvHAL_WRAP_USER_MEMORY. */ -typedef struct _gcsHAL_WRAP_USER_MEMORY -{ - /* Description of user memory. */ - IN gcsUSER_MEMORY_DESC desc; - - /* Video memory allocation type. */ - IN gctUINT32 type; - - /* Output video mmory node. */ - OUT gctUINT32 node; - - /* size of the node in bytes */ - OUT gctUINT64 bytes; -} -gcsHAL_WRAP_USER_MEMORY; - -/* gcvHAL_RELEASE_VIDEO_MEMORY */ -typedef struct _gcsHAL_RELEASE_VIDEO_MEMORY -{ - /* Allocated video memory. */ - IN gctUINT32 node; - -#ifdef __QNXNTO__ - /* Mapped logical address to unmap in user space. */ - OUT gctUINT64 memory; - - /* Number of bytes to allocated. */ - OUT gctUINT64 bytes; -#endif -} -gcsHAL_RELEASE_VIDEO_MEMORY; - -/* gcvHAL_LOCK_VIDEO_MEMORY */ -typedef struct _gcsHAL_LOCK_VIDEO_MEMORY -{ - /* Allocated video memory. */ - IN gctUINT32 node; - - /* Cache configuration. */ - /* Only gcvPOOL_VIRTUAL can be configured */ - IN gctBOOL cacheable; - - /* Hardware specific address. */ - OUT gctUINT32 address; - - /* Mapped logical address. */ - OUT gctUINT64 memory; - - /* Customer priviate handle*/ - OUT gctUINT32 gid; - - /* Bus address of a contiguous video node. */ - OUT gctUINT64 physicalAddress; -} -gcsHAL_LOCK_VIDEO_MEMORY; - -/* gcvHAL_UNLOCK_VIDEO_MEMORY */ -typedef struct _gcsHAL_UNLOCK_VIDEO_MEMORY -{ - /* Allocated video memory. */ - IN gctUINT64 node; - - /* Video memory allocation type. */ - IN gctUINT32 type; - - /* Pool of the unlock node */ - OUT gctUINT32 pool; - - /* Bytes of the unlock node */ - OUT gctUINT64 bytes; - - /* Flag to unlock surface asynchroneously. */ - IN OUT gctBOOL asynchroneous; -} -gcsHAL_UNLOCK_VIDEO_MEMORY; - -/* gcvHAL_BOTTOM_HALF_UNLOCK_VIDEO_MEMORY: */ -typedef struct _gcsHAL_BOTTOM_HALF_UNLOCK_VIDEO_MEMORY -{ - /* Allocated video memory. */ - IN gctUINT32 node; - - /* Video memory allocation type. */ - IN gctUINT32 type; -} -gcsHAL_BOTTOM_HALF_UNLOCK_VIDEO_MEMORY; - -/* gcvHAL_EXPORT_VIDEO_MEMORY. */ -typedef struct _gcsHAL_EXPORT_VIDEO_MEMORY -{ - /* Allocated video memory. */ - IN gctUINT32 node; - - /* Export flags */ - IN gctUINT32 flags; - - /* Exported dma_buf fd */ - OUT gctINT32 fd; -} -gcsHAL_EXPORT_VIDEO_MEMORY; - -/* gcvHAL_NAME_VIDEO_MEMORY. */ -typedef struct _gcsHAL_NAME_VIDEO_MEMORY -{ - IN gctUINT32 handle; - OUT gctUINT32 name; -} -gcsHAL_NAME_VIDEO_MEMORY; - -/* gcvHAL_IMPORT_VIDEO_MEMORY. */ -typedef struct _gcsHAL_IMPORT_VIDEO_MEMORY -{ - IN gctUINT32 name; - OUT gctUINT32 handle; -} -gcsHAL_IMPORT_VIDEO_MEMORY; - -/* gcvHAL_MAP_MEMORY */ -typedef struct _gcsHAL_MAP_MEMORY -{ - /* Physical memory address to map. Just a name on Linux/Qnx. */ - IN gctUINT32 physName; - - /* Number of bytes in physical memory to map. */ - IN gctUINT64 bytes; - - /* Address of mapped memory. */ - OUT gctUINT64 logical; -} -gcsHAL_MAP_MEMORY; - -/* gcvHAL_UNMAP_MEMORY */ -typedef struct _gcsHAL_UNMAP_MEMORY -{ - /* Physical memory address to unmap. Just a name on Linux/Qnx. */ - IN gctUINT32 physName; - - /* Number of bytes in physical memory to unmap. */ - IN gctUINT64 bytes; - - /* Address of mapped memory to unmap. */ - IN gctUINT64 logical; -} -gcsHAL_UNMAP_MEMORY; - -/* gcvHAL_CACHE */ -typedef struct _gcsHAL_CACHE -{ - IN gceCACHEOPERATION operation; - IN gctUINT64 process; - IN gctUINT64 logical; - IN gctUINT64 bytes; - IN gctUINT32 node; -} -gcsHAL_CACHE; - -/* gcvHAL_ATTACH */ -typedef struct _gcsHAL_ATTACH -{ - /* Handle of context buffer object. */ - OUT gctUINT32 context; - - /* Maximum state in the buffer. */ - OUT gctUINT64 maxState; - - /* Number of states in the buffer. */ - OUT gctUINT32 numStates; - - /* Map context buffer to user or not. */ - IN gctBOOL map; - - /* Physical of context buffer. */ - OUT gctUINT64 logicals[2]; - - /* Bytes of context buffer. */ - OUT gctUINT32 bytes; -} -gcsHAL_ATTACH; - -/* gcvHAL_DETACH */ -typedef struct _gcsHAL_DETACH -{ - /* Context buffer object gckCONTEXT. Just a name. */ - IN gctUINT32 context; -} -gcsHAL_DETACH; - - -/* gcvHAL_EVENT_COMMIT. */ -typedef struct _gcsHAL_EVENT_COMMIT -{ - /* Event queue in gcsQUEUE. */ - IN gctUINT64 queue; -} -gcsHAL_EVENT_COMMIT; - -typedef struct _gcsHAL_COMMAND_LOCATION -{ - gctUINT32 priority; - gctUINT32 channelId; - - gctUINT32 videoMemNode; - - gctUINT32 address; - gctUINT64 logical; - gctUINT32 startOffset; - /* size includes reservedHead and reservedTail. */ - gctUINT32 size; - - gctUINT32 reservedHead; - gctUINT32 reservedTail; - - /* Pointer to patch list. */ - gctUINT64 patchHead; - - /* - * Location index of exit commands, ie where to put the chipEnable/link back - * commands in the reservedTail area. - * It's used in fully shared command buffer for multiple cores. - */ - gctUINT32 exitIndex; - gctUINT32 entryPipe; - gctUINT32 exitPipe; - - /* struct _gcsHAL_COMMAND_LOCATION * next; */ - gctUINT64 next; -} -gcsHAL_COMMAND_LOCATION; - -typedef struct _gcsHAL_SUBCOMMIT -{ - gctUINT32 coreId; - - /* user gcsSTATE_DELTA_PTR. */ - gctUINT64 delta; - - /* Kernel gckCONTEXT. */ - gctUINT64 context; - - /* Event queue in user gcsQUEUE *. */ - gctUINT64 queue; - - /* Locate the commands. */ - gcsHAL_COMMAND_LOCATION commandBuffer; - - /* struct _gcsHAL_SUBCOMMIT * next; */ - gctUINT64 next; -} -gcsHAL_SUBCOMMIT; - -/* gcvHAL_COMMIT */ -typedef struct _gcsHAL_COMMIT -{ - gcsHAL_SUBCOMMIT subCommit; - - gctBOOL shared; - - gctBOOL contextSwitched; - - /* Commit stamp of this commit. */ - OUT gctUINT64 commitStamp; -} -gcsHAL_COMMIT; - - -typedef struct _gcsHAL_COMMIT_DONE -{ - IN gctUINT64 context; -} -gcsHAL_COMMIT_DONE; - -/* gcvHAL_USER_SIGNAL */ -typedef struct _gcsHAL_USER_SIGNAL -{ - /* Command. */ - gceUSER_SIGNAL_COMMAND_CODES command; - - /* Signal ID. */ - IN OUT gctINT32 id; - - /* Reset mode. */ - IN gctBOOL manualReset; - - /* Wait timedout. */ - IN gctUINT32 wait; - - /* State. */ - IN gctBOOL state; -} -gcsHAL_USER_SIGNAL; - -/* gcvHAL_SIGNAL. */ -typedef struct _gcsHAL_SIGNAL -{ - /* Signal handle to signal gctSIGNAL. */ - IN gctUINT64 signal; - - /* Reserved gctSIGNAL. */ - IN gctUINT64 auxSignal; - - /* Process owning the signal gctHANDLE. */ - IN gctUINT64 process; - -#if defined(__QNXNTO__) - /* Client pulse side-channel connection ID. Set by client in gcoOS_CreateSignal. */ - IN gctINT32 coid; - - /* Set by server. */ - IN gctINT32 rcvid; -#endif - /* Event generated from where of pipeline */ - IN gceKERNEL_WHERE fromWhere; -} -gcsHAL_SIGNAL; - -/* gcvHAL_WRITE_DATA. */ -typedef struct _gcsHAL_WRITE_DATA -{ - /* Address to write data to. */ - IN gctUINT32 address; - - /* Data to write. */ - IN gctUINT32 data; -} -gcsHAL_WRITE_DATA; - -/* gcvHAL_READ_REGISTER */ -typedef struct _gcsHAL_READ_REGISTER -{ - /* Logical address of memory to write data to. */ - IN gctUINT32 address; - - /* Data read. */ - OUT gctUINT32 data; -} -gcsHAL_READ_REGISTER; - -/* gcvHAL_WRITE_REGISTER */ -typedef struct _gcsHAL_WRITE_REGISTER -{ - /* Logical address of memory to write data to. */ - IN gctUINT32 address; - - /* Data read. */ - IN gctUINT32 data; -} -gcsHAL_WRITE_REGISTER; - -/* gcvHAL_READ_REGISTER_EX */ -typedef struct _gcsHAL_READ_REGISTER_EX -{ - /* Logical address of memory to write data to. */ - IN gctUINT32 address; - - IN gctUINT32 coreSelect; - - /* Data read. */ - OUT gctUINT32 data[4]; -} -gcsHAL_READ_REGISTER_EX; - -/* gcvHAL_WRITE_REGISTER_EX */ -typedef struct _gcsHAL_WRITE_REGISTER_EX -{ - /* Logical address of memory to write data to. */ - IN gctUINT32 address; - - IN gctUINT32 coreSelect; - - /* Data read. */ - IN gctUINT32 data[4]; -} -gcsHAL_WRITE_REGISTER_EX; - -#if VIVANTE_PROFILER -/* gcvHAL_GET_PROFILE_SETTING */ -typedef struct _gcsHAL_GET_PROFILE_SETTING -{ - /* Enable profiling */ - OUT gctBOOL enable; -} -gcsHAL_GET_PROFILE_SETTING; - -/* gcvHAL_SET_PROFILE_SETTING */ -typedef struct _gcsHAL_SET_PROFILE_SETTING -{ - /* Enable profiling */ - IN gctBOOL enable; -} -gcsHAL_SET_PROFILE_SETTING; - -/* gcvHAL_READ_PROFILER_REGISTER_SETTING */ -typedef struct _gcsHAL_READ_PROFILER_REGISTER_SETTING -{ - /*Should Clear Register*/ - IN gctBOOL bclear; -} -gcsHAL_READ_PROFILER_REGISTER_SETTING; - -typedef struct _gcsHAL_READ_ALL_PROFILE_REGISTERS_PART1 -{ - /* Context buffer object gckCONTEXT. Just a name. */ - IN gctUINT32 context; - - /* Data read. */ - OUT gcsPROFILER_COUNTERS_PART1 Counters; -} -gcsHAL_READ_ALL_PROFILE_REGISTERS_PART1; - -typedef struct _gcsHAL_READ_ALL_PROFILE_REGISTERS_PART2 -{ - /* Context buffer object gckCONTEXT. Just a name. */ - IN gctUINT32 context; - - /* Data read. */ - OUT gcsPROFILER_COUNTERS_PART2 Counters; -} -gcsHAL_READ_ALL_PROFILE_REGISTERS_PART2; - -/* gcvHAL_PROFILE_REGISTERS_2D */ -typedef struct _gcsHAL_PROFILE_REGISTERS_2D -{ - /* Data read in gcs2D_PROFILE. */ - OUT gctUINT64 hwProfile2D; -} -gcsHAL_PROFILE_REGISTERS_2D; -#endif - -/* gcvHAL_SET_POWER_MANAGEMENT_STATE */ -typedef struct _gcsHAL_SET_POWER_MANAGEMENT -{ - /* Data read. */ - IN gceCHIPPOWERSTATE state; -} -gcsHAL_SET_POWER_MANAGEMENT; - -/* gcvHAL_QUERY_POWER_MANAGEMENT_STATE */ -typedef struct _gcsHAL_QUERY_POWER_MANAGEMENT -{ - /* Data read. */ - OUT gceCHIPPOWERSTATE state; - - /* Idle query. */ - OUT gctBOOL isIdle; -} -gcsHAL_QUERY_POWER_MANAGEMENT; - -/* gcvHAL_CONFIG_POWER_MANAGEMENT. */ -typedef struct _gcsHAL_CONFIG_POWER_MANAGEMENT -{ - IN gctBOOL enable; -} -gcsHAL_CONFIG_POWER_MANAGEMENT; - -typedef struct _gcsFLAT_MAPPING_RANGE -{ - gctUINT64 start; - gctUINT64 end; - gctUINT32 size; - gceFLATMAP_FLAG flag; -} -gcsFLAT_MAPPING_RANGE; - -/* gcvHAL_GET_BASE_ADDRESS */ -typedef struct _gcsHAL_GET_BASE_ADDRESS -{ - /* Physical memory address of internal memory. */ - OUT gctUINT32 baseAddress; - - OUT gctUINT32 flatMappingRangeCount; - - OUT gcsFLAT_MAPPING_RANGE flatMappingRanges[gcdMAX_FLAT_MAPPING_COUNT]; -} -gcsHAL_GET_BASE_ADDRESS; - -typedef struct _gcsHAL_SET_DEBUG_LEVEL_ZONE -{ - IN gctUINT32 level; - IN gctUINT32 zones; - IN gctBOOL enable; -} -gcsHAL_SET_DEBUG_LEVEL_ZONE; - -/* gcvHAL_DEBUG_DUMP. */ -typedef struct _gcsHAL_DEBUG_DUMP -{ - /* gceDUMP_BUFFER_TYPE type. */ - IN gctUINT32 type; - - IN gctUINT64 ptr; - IN gctUINT32 address; - IN gctUINT32 size; -} -gcsHAL_DEBUG_DUMP; - - -/* gcvHAL_TIMESTAMP */ -typedef struct _gcsHAL_TIMESTAMP -{ - /* Timer select. */ - IN gctUINT32 timer; - - /* Timer request type (0-stop, 1-start, 2-send delta). */ - IN gctUINT32 request; - - /* Result of delta time in microseconds. */ - OUT gctINT32 timeDelta; -} -gcsHAL_TIMESTAMP; - -/* gcvHAL_DATABASE */ -typedef struct _gcsHAL_DATABASE -{ - /* Set to gcvTRUE if you want to query a particular process ID. - ** Set to gcvFALSE to query the last detached process. */ - IN gctBOOL validProcessID; - - /* Process ID to query. */ - IN gctUINT32 processID; - - /* Information. */ - OUT gcuDATABASE_INFO vidMem; - OUT gcuDATABASE_INFO nonPaged; - OUT gcuDATABASE_INFO gpuIdle; - - /* Detail information about video memory. */ - OUT gcuDATABASE_INFO vidMemPool[3]; -} -gcsHAL_DATABASE; - -/* gcvHAL_GET_FRAME_INFO. */ -typedef struct _gcsHAL_GET_FRAME_INFO -{ - /* gcsHAL_FRAME_INFO* */ - OUT gctUINT64 frameInfo; -} -gcsHAL_GET_FRAME_INFO; - - -typedef struct _gcsHAL_SET_FSCALE_VALUE -{ - IN gctUINT32 value; -} -gcsHAL_SET_FSCALE_VALUE; - -typedef struct _gcsHAL_GET_FSCALE_VALUE -{ - OUT gctUINT32 value; - OUT gctUINT32 minValue; - OUT gctUINT32 maxValue; -} -gcsHAL_GET_FSCALE_VALUE; - -/* gcvHAL_QUERY_RESET_TIME_STAMP. */ -typedef struct _gcsHAL_QUERY_RESET_TIME_STAMP -{ - OUT gctUINT64 timeStamp; - OUT gctUINT64 contextID; -} -gcsHAL_QUERY_RESET_TIME_STAMP; - -/* gcvHAL_CREATE_NATIVE_FENCE. */ -typedef struct _gcsHAL_CREATE_NATIVE_FENCE -{ - /* Signal id. */ - IN gctUINT64 signal; - - /* Native fence file descriptor. */ - OUT gctINT32 fenceFD; - -} -gcsHAL_CREATE_NATIVE_FENCE; - -/* gcvHAL_WAIT_NATIVE_FENCE. */ -typedef struct _gcsHAL_WAIT_NATIVE_FENCE -{ - /* Native fence file descriptor. */ - IN gctINT32 fenceFD; - - /* Wait timeout. */ - IN gctUINT32 timeout; -} -gcsHAL_WAIT_NATIVE_FENCE; - -/* gcvHAL_SHBUF. */ -typedef struct _gcsHAL_SHBUF -{ - gceSHBUF_COMMAND_CODES command; - - /* Shared buffer. */ - IN OUT gctUINT64 id; - - /* User data to be shared. */ - IN gctUINT64 data; - - /* Data size. */ - IN OUT gctUINT32 bytes; -} -gcsHAL_SHBUF; - -/* gcvHAL_GET_GRAPHIC_BUFFER_FD. */ -/* - * Fd representation of android graphic buffer contents. - * Currently, it is only to reference video nodes, signal, etc to avoid being - * destroyed when trasfering across processes. - */ -typedef struct _gcsHAL_GET_GRAPHIC_BUFFER_FD -{ - /* Max 3 video nodes, node handle here. */ - IN gctUINT32 node[3]; - - /* A shBuf. */ - IN gctUINT64 shBuf; - - /* A signal. */ - IN gctUINT64 signal; - - OUT gctINT32 fd; -} -gcsHAL_GET_GRAPHIC_BUFFER_FD; - -typedef struct _gcsHAL_VIDEO_MEMORY_METADATA -{ - /* Allocated video memory. */ - IN gctUINT32 node; - - IN gctUINT32 readback; - - INOUT gctINT32 ts_fd; - INOUT gctUINT32 fc_enabled; - INOUT gctUINT32 fc_value; - INOUT gctUINT32 fc_value_upper; - - INOUT gctUINT32 compressed; - INOUT gctUINT32 compress_format; -} -gcsHAL_VIDEO_MEMORY_METADATA; - -/* gcvHAL_GET_VIDEO_MEMORY_FD. */ -typedef struct _gcsHAL_GET_VIDEO_MEMORY_FD -{ - IN gctUINT32 handle; - OUT gctINT32 fd; -} -gcsHAL_GET_VIDEO_MEMORY_FD; - -/* gcvHAL_DESTROY_MMU. */ -typedef struct _gcsHAL_DESTROY_MMU -{ - /* Mmu object. */ - IN gctUINT64 mmu; -} -gcsHAL_DESTROY_MMU; - -/* gcvHAL_WAIT_FENCE. */ -typedef struct _gcsHAL_WAIT_FENCE -{ - IN gctUINT32 handle; - IN gctUINT32 timeOut; -} -gcsHAL_WAIT_FENCE; - -/* gcvHAL_DEVICE_MUTEX: */ -typedef struct _gcsHAL_DEVICE_MUTEX -{ - /* Lock or Release device mutex. */ - gctBOOL isMutexLocked; -} -gcsHAL_DEVICE_MUTEX; - - -#if gcdDEC_ENABLE_AHB -/* gcvHAL_DEC300_READ. */ -typedef struct _gcsHAL_DEC300_READ -{ - gctUINT32 enable; - gctUINT32 readId; - gctUINT32 format; - gctUINT32 strides[3]; - gctUINT32 is3D; - gctUINT32 isMSAA; - gctUINT32 clearValue; - gctUINT32 isTPC; - gctUINT32 isTPCCompressed; - gctUINT32 surfAddrs[3]; - gctUINT32 tileAddrs[3]; -} -DEC300Read; - -/* gcvHAL_DEC300_WRITE. */ -typedef struct _gcsHAL_DEC300_WRITE -{ - gctUINT32 enable; - gctUINT32 readId; - gctUINT32 writeId; - gctUINT32 format; - gctUINT32 surfAddr; - gctUINT32 tileAddr; -} -DEC300Write; - -/* gcvHAL_DEC300_FLUSH. */ -typedef struct _gcsHAL_DEC300_FLUSH -{ - IN gctUINT8 useless; -} -DEC300Flush; - -/* gcvHAL_DEC300_FLUSH_WAIT. */ -typedef struct _gcsHAL_DEC300_FLUSH_WAIT -{ - IN gctUINT32 done; -} -DEC300FlushWait; -#endif - - -typedef struct _gcsHAL_INTERFACE -{ - /* Command code. */ - gceHAL_COMMAND_CODES command; - - /* Hardware type. */ - gceHARDWARE_TYPE hardwareType; - - /* Core index for current hardware type. */ - gctUINT32 coreIndex; - - /* Status value. */ - gceSTATUS status; - - /* Engine */ - gceENGINE engine; - - /* Ignore information from TSL when doing IO control */ - gctBOOL ignoreTLS; - - /* The mutext already acquired */ - IN gctBOOL commitMutex; - - /* Union of command structures. */ - union _u - { - gcsHAL_CHIP_INFO ChipInfo; - gcsHAL_VERSION Version; - gcsHAL_SET_TIMEOUT SetTimeOut; - - gcsHAL_QUERY_VIDEO_MEMORY QueryVideoMemory; - gcsHAL_QUERY_CHIP_IDENTITY QueryChipIdentity; - gcsHAL_QUERY_CHIP_OPTIONS QueryChipOptions; - gcsHAL_QUERY_CHIP_FREQUENCY QueryChipFrequency; - - gcsHAL_ALLOCATE_NON_PAGED_MEMORY AllocateNonPagedMemory; - gcsHAL_FREE_NON_PAGED_MEMORY FreeNonPagedMemory; - - gcsHAL_ALLOCATE_LINEAR_VIDEO_MEMORY AllocateLinearVideoMemory; - gcsHAL_WRAP_USER_MEMORY WrapUserMemory; - gcsHAL_RELEASE_VIDEO_MEMORY ReleaseVideoMemory; - - gcsHAL_LOCK_VIDEO_MEMORY LockVideoMemory; - gcsHAL_UNLOCK_VIDEO_MEMORY UnlockVideoMemory; - gcsHAL_BOTTOM_HALF_UNLOCK_VIDEO_MEMORY BottomHalfUnlockVideoMemory; - - gcsHAL_EXPORT_VIDEO_MEMORY ExportVideoMemory; - gcsHAL_NAME_VIDEO_MEMORY NameVideoMemory; - gcsHAL_IMPORT_VIDEO_MEMORY ImportVideoMemory; - - gcsHAL_MAP_MEMORY MapMemory; - gcsHAL_UNMAP_MEMORY UnmapMemory; - - gcsHAL_CACHE Cache; - - gcsHAL_ATTACH Attach; - gcsHAL_DETACH Detach; - - gcsHAL_EVENT_COMMIT Event; - gcsHAL_COMMIT Commit; - gcsHAL_COMMIT_DONE CommitDone; - - gcsHAL_USER_SIGNAL UserSignal; - gcsHAL_SIGNAL Signal; - - gcsHAL_WRITE_DATA WriteData; - gcsHAL_READ_REGISTER ReadRegisterData; - gcsHAL_WRITE_REGISTER WriteRegisterData; - gcsHAL_READ_REGISTER_EX ReadRegisterDataEx; - gcsHAL_WRITE_REGISTER_EX WriteRegisterDataEx; - -#if VIVANTE_PROFILER - gcsHAL_GET_PROFILE_SETTING GetProfileSetting; - gcsHAL_SET_PROFILE_SETTING SetProfileSetting; - gcsHAL_READ_PROFILER_REGISTER_SETTING SetProfilerRegisterClear; - gcsHAL_READ_ALL_PROFILE_REGISTERS_PART1 RegisterProfileData_part1; - gcsHAL_READ_ALL_PROFILE_REGISTERS_PART2 RegisterProfileData_part2; - gcsHAL_PROFILE_REGISTERS_2D RegisterProfileData2D; -#endif - - gcsHAL_SET_POWER_MANAGEMENT SetPowerManagement; - gcsHAL_QUERY_POWER_MANAGEMENT QueryPowerManagement; - gcsHAL_CONFIG_POWER_MANAGEMENT ConfigPowerManagement; - - gcsHAL_GET_BASE_ADDRESS GetBaseAddress; - - gcsHAL_SET_DEBUG_LEVEL_ZONE DebugLevelZone; - gcsHAL_DEBUG_DUMP DebugDump; - - gcsHAL_TIMESTAMP TimeStamp; - gcsHAL_DATABASE Database; - - gcsHAL_GET_FRAME_INFO GetFrameInfo; - - - /* gcsHAL_DUMP_GPU_STATE */ - /* gcsHAL_DUMP_EVENT */ - - gcsHAL_SET_FSCALE_VALUE SetFscaleValue; - gcsHAL_GET_FSCALE_VALUE GetFscaleValue; - - gcsHAL_QUERY_RESET_TIME_STAMP QueryResetTimeStamp; - - gcsHAL_CREATE_NATIVE_FENCE CreateNativeFence; - gcsHAL_WAIT_NATIVE_FENCE WaitNativeFence; - gcsHAL_SHBUF ShBuf; - gcsHAL_GET_GRAPHIC_BUFFER_FD GetGraphicBufferFd; - gcsHAL_VIDEO_MEMORY_METADATA SetVidMemMetadata; - gcsHAL_GET_VIDEO_MEMORY_FD GetVideoMemoryFd; - - gcsHAL_DESTROY_MMU DestroyMmu; - - gcsHAL_WAIT_FENCE WaitFence; - - /* gcvHAL_DEVICE_MUTEX: */ - gcsHAL_DEVICE_MUTEX DeviceMutex; - - -#if gcdDEC_ENABLE_AHB - gcsHAL_DEC300_READ DEC300Read; - gcsHAL_DEC300_WRITE DEC300Write; - gcsHAL_DEC300_FLUSH DEC300Flush; - gcsHAL_DEC300_FLUSH_WAIT DEC300FlushWait; -#endif - } - u; -} -gcsHAL_INTERFACE; - - -#ifdef __cplusplus -} -#endif - -#endif /* __gc_hal_driver_h_ */ diff --git a/drivers/amlogic/npu/kernel/inc/gc_hal_driver_vg.h b/drivers/amlogic/npu/kernel/inc/gc_hal_driver_vg.h index 68c9786..090b1a2 100644 --- a/drivers/amlogic/npu/kernel/inc/gc_hal_driver_vg.h +++ b/drivers/amlogic/npu/kernel/inc/gc_hal_driver_vg.h @@ -2,7 +2,7 @@ * * The MIT License (MIT) * -* Copyright (c) 2014 - 2019 Vivante Corporation +* Copyright (c) 2014 - 2020 Vivante Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -26,7 +26,7 @@ * * The GPL License (GPL) * -* Copyright (C) 2014 - 2019 Vivante Corporation +* Copyright (C) 2014 - 2020 Vivante Corporation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -53,228 +53,7 @@ *****************************************************************************/ -#ifndef __gc_hal_driver_vg_h_ -#define __gc_hal_driver_vg_h_ +#include "shared/gc_hal_driver_vg_shared.h" -#include "gc_hal_types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/******************************************************************************\ -******************************* I/O Control Codes ****************************** -\******************************************************************************/ - -#define gcvHAL_CLASS "galcore" -#define IOCTL_GCHAL_INTERFACE 30000 - -/******************************************************************************\ -********************* Command buffer information structure. ******************** -\******************************************************************************/ - -typedef struct _gcsCOMMAND_BUFFER_INFO * gcsCOMMAND_BUFFER_INFO_PTR; -typedef struct _gcsCOMMAND_BUFFER_INFO -{ - /* FE command buffer interrupt ID. */ - gctINT32 feBufferInt; - - /* TS overflow interrupt ID. */ - gctINT32 tsOverflowInt; - - /* Alignment and mask for the buffer address. */ - gctUINT addressMask; - gctUINT32 addressAlignment; - - /* Alignment for each command. */ - gctUINT32 commandAlignment; - - /* Number of bytes required by the STATE command. */ - gctUINT32 stateCommandSize; - - /* Number of bytes required by the RESTART command. */ - gctUINT32 restartCommandSize; - - /* Number of bytes required by the FETCH command. */ - gctUINT32 fetchCommandSize; - - /* Number of bytes required by the CALL command. */ - gctUINT32 callCommandSize; - - /* Number of bytes required by the RETURN command. */ - gctUINT32 returnCommandSize; - - /* Number of bytes required by the EVENT command. */ - gctUINT32 eventCommandSize; - - /* Number of bytes required by the END command. */ - gctUINT32 endCommandSize; - - /* Number of bytes reserved at the tail of a static command buffer. */ - gctUINT32 staticTailSize; - - /* Number of bytes reserved at the tail of a dynamic command buffer. */ - gctUINT32 dynamicTailSize; -} -gcsCOMMAND_BUFFER_INFO; - -/******************************************************************************\ -******************************** Task Structures ******************************* -\******************************************************************************/ - -typedef enum _gceTASK -{ - gcvTASK_LINK, - gcvTASK_CLUSTER, - gcvTASK_INCREMENT, - gcvTASK_DECREMENT, - gcvTASK_SIGNAL, - gcvTASK_LOCKDOWN, - gcvTASK_UNLOCK_VIDEO_MEMORY, - gcvTASK_FREE_VIDEO_MEMORY, - gcvTASK_FREE_CONTIGUOUS_MEMORY, -} -gceTASK; - -typedef struct _gcsTASK_HEADER * gcsTASK_HEADER_PTR; -typedef struct _gcsTASK_HEADER -{ - /* Task ID. */ - IN gceTASK id; -} -gcsTASK_HEADER; - -typedef struct _gcsTASK_LINK * gcsTASK_LINK_PTR; -typedef struct _gcsTASK_LINK -{ - /* Task ID (gcvTASK_LINK). */ - IN gceTASK id; - - /* Pointer to the next task container. */ - IN gctPOINTER cotainer; - - /* Pointer to the next task from the next task container. */ - IN gcsTASK_HEADER_PTR task; -} -gcsTASK_LINK; - -typedef struct _gcsTASK_CLUSTER * gcsTASK_CLUSTER_PTR; -typedef struct _gcsTASK_CLUSTER -{ - /* Task ID (gcvTASK_CLUSTER). */ - IN gceTASK id; - - /* Number of tasks in the cluster. */ - IN gctUINT taskCount; -} -gcsTASK_CLUSTER; - -typedef struct _gcsTASK_INCREMENT * gcsTASK_INCREMENT_PTR; -typedef struct _gcsTASK_INCREMENT -{ - /* Task ID (gcvTASK_INCREMENT). */ - IN gceTASK id; - - /* Address of the variable to increment. */ - IN gctUINT32 address; -} -gcsTASK_INCREMENT; - -typedef struct _gcsTASK_DECREMENT * gcsTASK_DECREMENT_PTR; -typedef struct _gcsTASK_DECREMENT -{ - /* Task ID (gcvTASK_DECREMENT). */ - IN gceTASK id; - - /* Address of the variable to decrement. */ - IN gctUINT32 address; -} -gcsTASK_DECREMENT; - -typedef struct _gcsTASK_SIGNAL * gcsTASK_SIGNAL_PTR; -typedef struct _gcsTASK_SIGNAL -{ - /* Task ID (gcvTASK_SIGNAL). */ - IN gceTASK id; - - /* Process owning the signal. */ - IN gctHANDLE process; - - /* Signal handle to signal. */ - IN gctSIGNAL signal; - -#if defined(__QNXNTO__) - IN gctINT32 coid; - IN gctINT32 rcvid; -#endif -} -gcsTASK_SIGNAL; - -typedef struct _gcsTASK_LOCKDOWN * gcsTASK_LOCKDOWN_PTR; -typedef struct _gcsTASK_LOCKDOWN -{ - /* Task ID (gcvTASK_LOCKDOWN). */ - IN gceTASK id; - - /* Address of the user space counter. */ - IN gctUINT32 userCounter; - - /* Address of the kernel space counter. */ - IN gctUINT32 kernelCounter; - - /* Process owning the signal. */ - IN gctHANDLE process; - - /* Signal handle to signal. */ - IN gctSIGNAL signal; -} -gcsTASK_LOCKDOWN; - -typedef struct _gcsTASK_UNLOCK_VIDEO_MEMORY * gcsTASK_UNLOCK_VIDEO_MEMORY_PTR; -typedef struct _gcsTASK_UNLOCK_VIDEO_MEMORY -{ - /* Task ID (gcvTASK_UNLOCK_VIDEO_MEMORY). */ - IN gceTASK id; - - /* Allocated video memory. */ - IN gctUINT64 node; -} -gcsTASK_UNLOCK_VIDEO_MEMORY; - -typedef struct _gcsTASK_FREE_VIDEO_MEMORY * gcsTASK_FREE_VIDEO_MEMORY_PTR; -typedef struct _gcsTASK_FREE_VIDEO_MEMORY -{ - /* Task ID (gcvTASK_FREE_VIDEO_MEMORY). */ - IN gceTASK id; - - /* Allocated video memory. */ - IN gctUINT32 node; -} -gcsTASK_FREE_VIDEO_MEMORY; - -typedef struct _gcsTASK_FREE_CONTIGUOUS_MEMORY * gcsTASK_FREE_CONTIGUOUS_MEMORY_PTR; -typedef struct _gcsTASK_FREE_CONTIGUOUS_MEMORY -{ - /* Task ID (gcvTASK_FREE_CONTIGUOUS_MEMORY). */ - IN gceTASK id; - - /* Number of bytes allocated. */ - IN gctSIZE_T bytes; - - /* Physical address of allocation. */ - IN gctPHYS_ADDR physical; - - /* Logical address of allocation. */ - IN gctPOINTER logical; -} -gcsTASK_FREE_CONTIGUOUS_MEMORY; - -#ifdef __cplusplus -} -#endif - -#endif /* __gc_hal_driver_h_ */ - - diff --git a/drivers/amlogic/npu/kernel/inc/gc_hal_drm.h b/drivers/amlogic/npu/kernel/inc/gc_hal_drm.h index 1300c13..e7d5a29 100644 --- a/drivers/amlogic/npu/kernel/inc/gc_hal_drm.h +++ b/drivers/amlogic/npu/kernel/inc/gc_hal_drm.h @@ -190,10 +190,12 @@ struct drm_viv_gem_ref_node { #define DRM_IOCTL_VIV_GEM_ATTACH_AUX DRM_IOWR(DRM_COMMAND_BASE + DRM_VIV_GEM_ATTACH_AUX, struct drm_viv_gem_attach_aux) #define DRM_IOCTL_VIV_GEM_REF_NODE DRM_IOWR(DRM_COMMAND_BASE + DRM_VIV_GEM_REF_NODE, struct drm_viv_gem_ref_node) +#ifdef __KERNEL__ #if LINUX_VERSION_CODE >= KERNEL_VERSION(5,4,0) #define drm_gem_object_unreference_unlocked drm_gem_object_put_unlocked #define drm_dev_unref drm_dev_put #endif +#endif #if defined(__cplusplus) } diff --git a/drivers/amlogic/npu/kernel/inc/gc_hal_eglplatform.h b/drivers/amlogic/npu/kernel/inc/gc_hal_eglplatform.h index 7655871..76b2328 100644 --- a/drivers/amlogic/npu/kernel/inc/gc_hal_eglplatform.h +++ b/drivers/amlogic/npu/kernel/inc/gc_hal_eglplatform.h @@ -56,7 +56,7 @@ #ifndef __gc_hal_eglplatform_h_ #define __gc_hal_eglplatform_h_ -#include "shared/gc_hal_types.h" +#include "gc_hal_types.h" #include "gc_hal_base.h" #ifdef __cplusplus diff --git a/drivers/amlogic/npu/kernel/inc/gc_hal_engine.h b/drivers/amlogic/npu/kernel/inc/gc_hal_engine.h index e859bd7..6b86458 100644 --- a/drivers/amlogic/npu/kernel/inc/gc_hal_engine.h +++ b/drivers/amlogic/npu/kernel/inc/gc_hal_engine.h @@ -56,7 +56,7 @@ #ifndef __gc_hal_engine_h_ #define __gc_hal_engine_h_ -#include "shared/gc_hal_types.h" +#include "gc_hal_types.h" #include "gc_hal_enum.h" @@ -496,6 +496,13 @@ gcoSURF_DrawBlit( gscSURF_BLITDRAW_BLIT *Args ); +gceSTATUS +gcoSURF_DrawBlitDepth( + gcsSURF_VIEW *SrcView, + gcsSURF_VIEW *DstView, + gscSURF_BLITDRAW_BLIT *Args +); + /******************************************************************************\ ******************************** gcoINDEX Object ******************************* diff --git a/drivers/amlogic/npu/kernel/inc/gc_hal_engine_vg.h b/drivers/amlogic/npu/kernel/inc/gc_hal_engine_vg.h index 2558725..122fade 100644 --- a/drivers/amlogic/npu/kernel/inc/gc_hal_engine_vg.h +++ b/drivers/amlogic/npu/kernel/inc/gc_hal_engine_vg.h @@ -60,7 +60,7 @@ extern "C" { #endif -#include "shared/gc_hal_types.h" +#include "gc_hal_types.h" /******************************************************************************\ ******************************** VG Structures ******************************* diff --git a/drivers/amlogic/npu/kernel/inc/gc_hal_enum.h b/drivers/amlogic/npu/kernel/inc/gc_hal_enum.h index e24750b..b70c2531 100644 --- a/drivers/amlogic/npu/kernel/inc/gc_hal_enum.h +++ b/drivers/amlogic/npu/kernel/inc/gc_hal_enum.h @@ -57,7 +57,7 @@ #define __gc_hal_enum_h_ #include "gc_hal_options.h" -#include "shared/gc_hal_enum.h" +#include "shared/gc_hal_enum_shared.h" #ifdef __cplusplus extern "C" { @@ -485,12 +485,22 @@ typedef enum _gce2D_TILE_STATUS_CONFIG } gce2D_TILE_STATUS_CONFIG; +typedef enum _gce2D_DEC400_MINOR_VERSION +{ + gcv2D_DEC400_MINOR_V1 = 1, + gcv2D_DEC400_MINOR_V2 = 2, + gcv2D_DEC400_MINOR_V3 = 3, +} +gce2D_DEC400_MINOR_VERSION; + + typedef enum _gce2D_QUERY { gcv2D_QUERY_RGB_ADDRESS_MIN_ALIGN = 0, gcv2D_QUERY_RGB_STRIDE_MIN_ALIGN, gcv2D_QUERY_YUV_ADDRESS_MIN_ALIGN, gcv2D_QUERY_YUV_STRIDE_MIN_ALIGN, + gcv2D_QUERY_DEC400_MINOR_VERSION, } gce2D_QUERY; @@ -1459,7 +1469,8 @@ typedef enum _gceFORMAT_CLASS gcvFORMAT_CLASS_DEPTH, gcvFORMAT_CLASS_ASTC, gcvFORMAT_CLASS_COMPRESSED, - gcvFORMAT_CLASS_OTHER + gcvFORMAT_CLASS_OTHER, + gcvFORMAT_CLASS_INTENSITY } gceFORMAT_CLASS; @@ -1580,8 +1591,9 @@ gceCLEAR; typedef enum _gceBLITDRAW_TYPE { - gcvBLITDRAW_CLEAR = 0, - gcvBLITDRAW_BLIT = 1, + gcvBLITDRAW_CLEAR = 0, + gcvBLITDRAW_BLIT = 1, + gcvBLITDRAW_BLIT_DEPTH = 2, /* last number, not a real type */ gcvBLITDRAW_NUM_TYPE @@ -2131,6 +2143,9 @@ enum /* Do not try slow pools (gcvPOOL_VIRTUAL) */ #define gcvALLOC_FLAG_FAST_POOLS 0x00000100 +/* Only accessed by GPU */ +#define gcvALLOC_FLAG_NON_CPU_ACCESS 0x00000200 + /* Import DMABUF. */ #define gcvALLOC_FLAG_DMABUF 0x00001000 /* Import USERMEMORY. */ @@ -2164,6 +2179,11 @@ enum /* Default chip ID means chip ID same as core index. */ #define gcvCHIP_ID_DEFAULT (~0U) +/* Tile status header size */ +#ifndef gcvTS_FC_HEADER_SIZE +#define gcvTS_FC_HEADER_SIZE 128 +#endif + /******************************************************************************\ ****************************** Object Declarations ***************************** \******************************************************************************/ @@ -2174,6 +2194,9 @@ typedef struct _gcsSTATE_DELTA * gcsSTATE_DELTA_PTR; typedef struct _gcsQUEUE * gcsQUEUE_PTR; typedef struct _gcoQUEUE * gcoQUEUE; typedef struct _gcsHAL_INTERFACE * gcsHAL_INTERFACE_PTR; +#if VIVANTE_PROFILER +typedef struct _gcsHAL_PROFILER_INTERFACE * gcsHAL_PROFILER_INTERFACE_PTR; +#endif typedef struct _gcs2D_PROFILE * gcs2D_PROFILE_PTR; diff --git a/drivers/amlogic/npu/kernel/inc/gc_hal_kernel_buffer.h b/drivers/amlogic/npu/kernel/inc/gc_hal_kernel_buffer.h index f6c517a..f5aae99 100644 --- a/drivers/amlogic/npu/kernel/inc/gc_hal_kernel_buffer.h +++ b/drivers/amlogic/npu/kernel/inc/gc_hal_kernel_buffer.h @@ -64,15 +64,6 @@ extern "C" { ************************ Command Buffer and Event Objects ********************** \******************************************************************************/ -/* The number of context buffers per user. */ -#if gcdCAPTURE_ONLY_MODE -#define gcdCONTEXT_BUFFER_COUNT 1 -#else -#define gcdCONTEXT_BUFFER_COUNT 2 -#endif - -#define gcdRENDER_FENCE_LENGTH (6 * gcmSIZEOF(gctUINT32)) -#define gcdBLT_FENCE_LENGTH (10 * gcmSIZEOF(gctUINT32)) #define gcdRESERVED_FLUSHCACHE_LENGTH (2 * gcmSIZEOF(gctUINT32)) #define gcdRESERVED_PAUSE_OQ_LENGTH (2 * gcmSIZEOF(gctUINT32)) #define gcdRESERVED_PAUSE_XFBWRITTEN_QUERY_LENGTH (4 * gcmSIZEOF(gctUINT32)) @@ -80,69 +71,11 @@ extern "C" { #define gcdRESERVED_PAUSE_XFB_LENGTH (2 * gcmSIZEOF(gctUINT32)) #define gcdRESERVED_HW_FENCE_32BIT (4 * gcmSIZEOF(gctUINT32)) #define gcdRESERVED_HW_FENCE_64BIT (6 * gcmSIZEOF(gctUINT32)) -#define gcdRESERVED_PAUSE_PROBE_LENGTH (TOTAL_PROBE_NUMBER * 2 * gcmSIZEOF(gctUINT32)) #define gcdRESUME_OQ_LENGTH (2 * gcmSIZEOF(gctUINT32)) #define gcdRESUME_XFBWRITTEN_QUERY_LENGTH (4 * gcmSIZEOF(gctUINT32)) #define gcdRESUME_PRIMGEN_QUERY_LENGTH (4 * gcmSIZEOF(gctUINT32)) #define gcdRESUME_XFB_LENGH (2 * gcmSIZEOF(gctUINT32)) -#define gcdRESUME_PROBE_LENGH (TOTAL_PROBE_NUMBER * 2 * gcmSIZEOF(gctUINT32)) - - -/* State delta record. */ -typedef struct _gcsSTATE_DELTA_RECORD * gcsSTATE_DELTA_RECORD_PTR; -typedef struct _gcsSTATE_DELTA_RECORD -{ - /* State address. */ - gctUINT address; - - /* State mask. */ - gctUINT32 mask; - - /* State data. */ - gctUINT32 data; -} -gcsSTATE_DELTA_RECORD; - -/* State delta. */ -typedef struct _gcsSTATE_DELTA -{ - /* For debugging: the number of delta in the order of creation. */ - gctUINT num; - - /* Main state delta ID. Every time state delta structure gets reinitialized, - main ID is incremented. If main state ID overflows, all map entry IDs get - reinitialized to make sure there is no potential erroneous match after - the overflow.*/ - gctUINT id; - - /* The number of contexts pending modification by the delta. */ - gctINT refCount; - - /* Vertex element count for the delta buffer. */ - gctUINT elementCount; - - /* Number of states currently stored in the record array. */ - gctUINT recordCount; - - /* Record array; holds all modified states in gcsSTATE_DELTA_RECORD. */ - gctUINT64 recordArray; - - /* Map entry ID is used for map entry validation. If map entry ID does not - match the main state delta ID, the entry and the corresponding state are - considered not in use. */ - gctUINT64 mapEntryID; - gctUINT mapEntryIDSize; - - /* If the map entry ID matches the main state delta ID, index points to - the state record in the record array. */ - gctUINT64 mapEntryIndex; - - /* Previous and next state deltas in gcsSTATE_DELTA. */ - gctUINT64 prev; - gctUINT64 next; -} -gcsSTATE_DELTA; #define FENCE_NODE_LIST_INIT_COUNT 100 @@ -275,25 +208,6 @@ struct _gcoCMDBUF gctUINT32 mirrorCount; }; -typedef struct _gcsQUEUE -{ - /* Pointer to next gcsQUEUE structure in gcsQUEUE. */ - gctUINT64 next; - - /* Event information. */ - gcsHAL_INTERFACE iface; -} -gcsQUEUE; - -/* A record chunk include multiple records to save allocation. */ -typedef struct _gcsQUEUE_CHUNK -{ - struct _gcsQUEUE_CHUNK * next; - - gcsQUEUE record[16]; -} -gcsQUEUE_CHUNK; - /* Event queue. */ struct _gcoQUEUE { @@ -320,6 +234,14 @@ struct _gcoQUEUE gctUINT maxUnlockBytes; gceENGINE engine; + + /* Pointer to gcoHARDWARE object. */ + gcoHARDWARE hardware; + +#if gcdENABLE_SW_PREEMPTION + gctUINT priorityID; + gctBOOL topPriority; +#endif }; struct _gcsTEMPCMDBUF diff --git a/drivers/amlogic/npu/kernel/inc/gc_hal_options.h b/drivers/amlogic/npu/kernel/inc/gc_hal_options.h index 32d694d..d3e36a2 100644 --- a/drivers/amlogic/npu/kernel/inc/gc_hal_options.h +++ b/drivers/amlogic/npu/kernel/inc/gc_hal_options.h @@ -677,8 +677,12 @@ This define enables the use of VM for gckCommand and fence buffers. When non-zero, all video memory will be bufferable by default. */ #ifndef gcdENABLE_BUFFERABLE_VIDEO_MEMORY +#if gcdFPGA_BUILD +# define gcdENABLE_BUFFERABLE_VIDEO_MEMORY 0 +#else # define gcdENABLE_BUFFERABLE_VIDEO_MEMORY 1 #endif +#endif /* gcdENABLE_INFINITE_SPEED_HW @@ -759,7 +763,11 @@ This define enables the use of VM for gckCommand and fence buffers. */ #ifndef gcdENABLE_GPU_1M_PAGE #if !gcdSECURITY && defined(LINUX) +#ifdef EMULATOR +# define gcdENABLE_GPU_1M_PAGE 0 +#else # define gcdENABLE_GPU_1M_PAGE 1 +#endif #else # define gcdENABLE_GPU_1M_PAGE 0 #endif @@ -1046,11 +1054,7 @@ This define enables the use of VM for gckCommand and fence buffers. Expremental, under test only. Not ready for production. */ #ifndef gcdPARTIAL_FAST_CLEAR -#if defined(ANDROID) # define gcdPARTIAL_FAST_CLEAR 0 -#else -# define gcdPARTIAL_FAST_CLEAR 1 -#endif #endif /* @@ -1403,6 +1407,15 @@ This define enables the use of VM for gckCommand and fence buffers. # define gcdEXTERNAL_SRAM_DEFAULT_POOL 0 #endif +/* + gcdENABLE_SW_PREEMPTION + Enable software preemption if set to 1, disable by default. + Only support Linux OS currently. +*/ +#ifndef gcdENABLE_SW_PREEMPTION +# define gcdENABLE_SW_PREEMPTION 0 +#endif + #endif /* __gc_hal_options_h_ */ diff --git a/drivers/amlogic/npu/kernel/inc/gc_hal_profiler.h b/drivers/amlogic/npu/kernel/inc/gc_hal_profiler.h index 4db920e..f6c3fd0 100644 --- a/drivers/amlogic/npu/kernel/inc/gc_hal_profiler.h +++ b/drivers/amlogic/npu/kernel/inc/gc_hal_profiler.h @@ -56,7 +56,7 @@ #ifndef __gc_hal_profiler_h_ #define __gc_hal_profiler_h_ -#include "shared/gc_hal_profiler.h" +#include "shared/gc_hal_profiler_shared.h" #ifdef __cplusplus extern "C" { @@ -267,7 +267,9 @@ extern "C" { #define VPNG_MCZ 0x2e0000 #define VPNG_HI 0x2f0000 #define VPNG_L2 0x300000 -#define VPG_FINISH 0x310000 +#define VPNG_NN 0x310000 +#define VPNG_TP 0x320000 +#define VPG_FINISH 0x330000 #define VPG_END 0xff0000 /* Info. */ @@ -678,6 +680,134 @@ extern "C" { + MODULE_MEMORY_CONTROLLER_DEPTH_COUNTER_NUM + MODULE_HOST_INTERFACE0_COUNTER_NUM + MODULE_HOST_INTERFACE1_COUNTER_NUM \ + MODULE_GPUL2_CACHE_COUNTER_NUM) +#define VPNC_NN_LAYER_ID (VPNG_NN + 1) +#define VPNC_NN_LAYER_ID_OVFL (VPNG_NN + 2) +#define VPNC_NN_INSTR_INFO (VPNG_NN + 3) +#define VPNC_NN_TOTAL_BUSY_CYCLE (VPNG_NN + 4) +#define VPNC_NN_TOTAL_BUSY_CYCLE_OVFL (VPNG_NN + 5) +#define VPNC_NN_TOTAL_READ_CYCLE_DDR (VPNG_NN + 6) +#define VPNC_NN_TOTAL_READ_CYCLE_DDR_OVFL (VPNG_NN + 7) +#define VPNC_NN_TOTAL_READ_VALID_BW_DDR (VPNG_NN + 8) +#define VPNC_NN_TOTAL_READ_VALID_BW_DDR_OVFL (VPNG_NN + 9) +#define VPNC_NN_TOTAL_WRITE_CYCLE_DDR (VPNG_NN + 10) +#define VPNC_NN_TOTAL_WRITE_CYCLE_DDR_OVFL (VPNG_NN + 11) +#define VPNC_NN_TOTAL_WRITE_VALID_BW_DDR (VPNG_NN + 12) +#define VPNC_NN_TOTAL_WRITE_VALID_BW_DDR_OVFL (VPNG_NN + 13) +#define VPNC_NN_TOTAL_READ_CYCLE_SRAM (VPNG_NN + 14) +#define VPNC_NN_TOTAL_READ_CYCLE_SRAM_OVFL (VPNG_NN + 15) +#define VPNC_NN_TOTAL_WRITE_CYCLE_SRAM (VPNG_NN + 16) +#define VPNC_NN_TOTAL_WRITE_CYCLE_SRAM_OVFL (VPNG_NN + 17) +#define VPNC_NN_TOTAL_MAC_CYCLE (VPNG_NN + 18) +#define VPNC_NN_TOTAL_MAC_CYCLE_OVFL (VPNG_NN + 19) +#define VPNC_NN_TOTAL_MAC_COUNT (VPNG_NN + 20) +#define VPNC_NN_TOTAL_MAC_COUNT_OVFL (VPNG_NN + 21) +#define VPNC_NN_ZERO_COEF_SKIP_COUNT (VPNG_NN + 22) +#define VPNC_NN_ZERO_COEF_SKIP_COUNT_OVFL (VPNG_NN + 23) +#define VPNC_NN_NON_ZERO_COEF_COUNT (VPNG_NN + 24) +#define VPNC_NN_NON_ZERO_COEF_COUNT_OVFL (VPNG_NN + 25) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE_OVFL (VPNG_NN + 26) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE0 (VPNG_NN + 27) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE1 (VPNG_NN + 28) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE2 (VPNG_NN + 29) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE3 (VPNG_NN + 30) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE4 (VPNG_NN + 31) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE5 (VPNG_NN + 32) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE6 (VPNG_NN + 33) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE7 (VPNG_NN + 34) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE8 (VPNG_NN + 35) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE9 (VPNG_NN + 36) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE10 (VPNG_NN + 37) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE11 (VPNG_NN + 38) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE12 (VPNG_NN + 39) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE13 (VPNG_NN + 40) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE14 (VPNG_NN + 41) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE15 (VPNG_NN + 42) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE16 (VPNG_NN + 43) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE17 (VPNG_NN + 44) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE18 (VPNG_NN + 45) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE19 (VPNG_NN + 46) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE20 (VPNG_NN + 47) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE21 (VPNG_NN + 48) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE22 (VPNG_NN + 49) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE23 (VPNG_NN + 50) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE24 (VPNG_NN + 51) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE25 (VPNG_NN + 52) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE26 (VPNG_NN + 53) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE27 (VPNG_NN + 54) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE28 (VPNG_NN + 55) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE29 (VPNG_NN + 56) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE30 (VPNG_NN + 57) +#define VPNC_NN_TOTAL_IDLE_CYCLE_CORE31 (VPNG_NN + 58) +#define VPNC_NN_COUNT (VPNC_NN_TOTAL_IDLE_CYCLE_CORE31 - VPNG_NN) + +/* HW: TP Probe Counters. */ +#define VPNC_TP_LAYER_ID (VPNG_TP + 1) +#define VPNC_TP_LAYER_ID_OVFL (VPNG_TP + 2) +#define VPNC_TP_TOTAL_BUSY_CYCLE (VPNG_TP + 3) +#define VPNC_TP_TOTAL_BUSY_CYCLE_OVFL (VPNG_TP + 4) +#define VPNC_TP_TOTAL_READ_BW_CACHE (VPNG_TP + 5) +#define VPNC_TP_TOTAL_READ_BW_CACHE_OVFL (VPNG_TP + 6) +#define VPNC_TP_TOTAL_WRITE_BW_CACHE (VPNG_TP + 7) +#define VPNC_TP_TOTAL_WRITE_BW_CACHE_OVFL (VPNG_TP + 8) +#define VPNC_TP_TOTAL_READ_BW_SRAM (VPNG_TP + 9) +#define VPNC_TP_TOTAL_READ_BW_SRAM_OVFL (VPNG_TP + 10) +#define VPNC_TP_TOTAL_WRITE_BW_SRAM (VPNG_TP + 11) +#define VPNC_TP_TOTAL_WRITE_BW_SRAM_OVFL (VPNG_TP + 12) +#define VPNC_TP_TOTAL_READ_BW_OCB (VPNG_TP + 13) +#define VPNC_TP_TOTAL_READ_BW_OCB_OVFL (VPNG_TP + 14) +#define VPNC_TP_TOTAL_WRITE_BW_OCB (VPNG_TP + 15) +#define VPNC_TP_TOTAL_WRITE_BW_OCB_OVFL (VPNG_TP + 16) +#define VPNC_TP_FC_PIX_CNT (VPNG_TP + 17) +#define VPNC_TP_FC_ZERO_SKIP_CNT (VPNG_TP + 18) +#define VPNC_TP_FC_PIX_CNT_OVFL (VPNG_TP + 19) +#define VPNC_TP_FC_ZERO_SKIP_CNT_OVFL (VPNG_TP + 20) +#define VPNC_TP_FC_COEF_CNT (VPNG_TP + 21) +#define VPNC_TP_FC_COEF_ZERO_CNT (VPNG_TP + 22) +#define VPNC_TP_FC_COEF_CNT_OVFL (VPNG_TP + 23) +#define VPNC_TP_FC_COEF_ZERO_CNT_OVFL (VPNG_TP + 24) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE0 (VPNG_TP + 25) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE0_OVFL (VPNG_TP + 26) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE1 (VPNG_TP + 27) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE1_OVFL (VPNG_TP + 28) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE2 (VPNG_TP + 29) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE2_OVFL (VPNG_TP + 30) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE3 (VPNG_TP + 31) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE3_OVFL (VPNG_TP + 32) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE4 (VPNG_TP + 33) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE4_OVFL (VPNG_TP + 34) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE5 (VPNG_TP + 35) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE5_OVFL (VPNG_TP + 36) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE6 (VPNG_TP + 37) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE6_OVFL (VPNG_TP + 38) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE7 (VPNG_TP + 39) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE7_OVFL (VPNG_TP + 40) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE8 (VPNG_TP + 41) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE8_OVFL (VPNG_TP + 42) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE9 (VPNG_TP + 43) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE9_OVFL (VPNG_TP + 44) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE10 (VPNG_TP + 45) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE10_OVFL (VPNG_TP + 46) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE11 (VPNG_TP + 47) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE11_OVFL (VPNG_TP + 48) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE12 (VPNG_TP + 49) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE12_OVFL (VPNG_TP + 50) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE13 (VPNG_TP + 51) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE13_OVFL (VPNG_TP + 52) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE14 (VPNG_TP + 53) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE14_OVFL (VPNG_TP + 54) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE15 (VPNG_TP + 55) +#define VPNC_TP_TOTAL_IDLE_CYCLE_CORE15_OVFL (VPNG_TP + 56) +#define VPNC_TP_COUNT (VPNC_TP_TOTAL_IDLE_CYCLE_CORE15_OVFL - VPNG_TP) + +#define MODULE_NN_BASE_COUNTER_NUM 0x6 +/*#define MODULE_NN_RESERVED_COUNTER_NUM 0x9*/ +#define MODULE_NN_IDLE_COUNTER_NUM 0x9 +#define MODULE_NN_COUNTER_NUM (MODULE_NN_BASE_COUNTER_NUM + MODULE_NN_RESERVED_COUNTER_NUM + MODULE_NN_IDLE_COUNTER_NUM) + +#define TOTAL_VIP_COUNTER_NUMBER (VPNC_TP_COUNT + VPNC_NN_COUNT) +#define TOTAL_VIP_MODULE_NUMBER 2 +#define MODULE_TP_COUNTER_NUM 0xE +#define TOTAL_VIP_PROBE_NUMBER (MODULE_NN_COUNTER_NUM + MODULE_TP_COUNTER_NUM) #ifdef ANDROID #define DEFAULT_PROFILE_FILE_NAME "/sdcard/vprofiler.vpd" @@ -782,8 +912,30 @@ extern "C" { { \ gctUINT32 i; \ gctUINT32_PTR Memory = memory; \ + gctUINT32 total_probe_number = gcoPROFILER_GetProbeNumber(clusterCount, hostInterface1); \ counter = 0; \ - Memory = memory + TOTAL_PROBE_NUMBER * CoreId * (1 << clusterIDWidth); \ + Memory = memory + total_probe_number * CoreId * (1 << clusterIDWidth); \ + for (i = 0; i < (gctUINT32)(1 << clusterIDWidth); i++) \ + { \ + counter += *(Memory + (counterId + offset) * (1 << clusterIDWidth) + i); \ + } \ + } \ + } \ + while (gcvFALSE) + +#define gcmGET_VIPCOUNTER(counter, counterId) \ + do \ + { \ + if (*(memory + (counterId + offset) * (1 << clusterIDWidth)) == 0xdeaddead) \ + { \ + counter = 0xdeaddead; \ + } \ + else \ + { \ + gctUINT32 i; \ + gctUINT32_PTR Memory = memory; \ + counter = 0; \ + Memory = memory + TOTAL_VIP_PROBE_NUMBER * CoreId * (1 << clusterIDWidth); \ for (i = 0; i < (gctUINT32)(1 << clusterIDWidth); i++) \ { \ counter += *(Memory + (counterId + offset) * (1 << clusterIDWidth) + i); \ @@ -803,7 +955,8 @@ extern "C" { { \ gctUINT32 i; \ gctUINT32_PTR Memory = memory; \ - Memory = memory + TOTAL_PROBE_NUMBER * CoreId * (1 << clusterIDWidth); \ + gctUINT32 total_probe_number = gcoPROFILER_GetProbeNumber(clusterCount, hostInterface1); \ + Memory = memory + total_probe_number * CoreId * (1 << clusterIDWidth); \ for (i = 0; i < (gctUINT32)(1 << clusterIDWidth); i++) \ { \ maxLatency += ((*(Memory + (counterId + offset) * (1 << clusterIDWidth) + i) & 0xfff000) >> 12); \ @@ -823,6 +976,7 @@ typedef struct gcsCounterBuffer * gcsCounterBuffer_PTR; struct gcsCounterBuffer { gcsPROFILER_COUNTERS *counters; + gcsPROFILER_VIP_PROBE_COUNTERS *vipCounters; gctHANDLE couterBufobj; gctUINT32 probeAddress; gctPOINTER logicalAddress; @@ -845,6 +999,7 @@ struct _gcoPROFILER gctBOOL enablePrint; gctBOOL disableProbe; gctBOOL probeMode; + gctBOOL vipProbe; gctFILE file; gctCHAR* fileName; @@ -917,6 +1072,13 @@ gceSTATUS gcoPROFILER_Flush( IN gcoPROFILER Profiler ); + +gctUINT32 +gcoPROFILER_GetProbeNumber( + IN gctUINT32 clusterCount, + IN gctBOOL hostInterface1 + ); + #ifdef __cplusplus } #endif diff --git a/drivers/amlogic/npu/kernel/inc/gc_hal_raster.h b/drivers/amlogic/npu/kernel/inc/gc_hal_raster.h index 277a037..1daf4a6 100644 --- a/drivers/amlogic/npu/kernel/inc/gc_hal_raster.h +++ b/drivers/amlogic/npu/kernel/inc/gc_hal_raster.h @@ -57,7 +57,7 @@ #define __gc_hal_raster_h_ #include "gc_hal_enum.h" -#include "shared/gc_hal_types.h" +#include "gc_hal_types.h" #ifdef __cplusplus extern "C" { diff --git a/drivers/amlogic/npu/kernel/inc/gc_hal_rename.h b/drivers/amlogic/npu/kernel/inc/gc_hal_rename.h deleted file mode 100644 index 5370373..0000000 --- a/drivers/amlogic/npu/kernel/inc/gc_hal_rename.h +++ /dev/null @@ -1,224 +0,0 @@ -/**************************************************************************** -* -* The MIT License (MIT) -* -* Copyright (c) 2014 - 2019 Vivante Corporation -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in -* all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -* -***************************************************************************** -* -* The GPL License (GPL) -* -* Copyright (C) 2014 - 2019 Vivante Corporation -* -* 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 -* of the License, or (at your option) any later version. -* -* 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, write to the Free Software Foundation, -* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -* -***************************************************************************** -* -* Note: This software is released under dual MIT and GPL licenses. A -* recipient may use this file under the terms of either the MIT license or -* GPL License. If you wish to use only one license not the other, you can -* indicate your decision by deleting one of the above license notices in your -* version of this file. -* -*****************************************************************************/ - - -#ifndef __gc_hal_rename_h_ -#define __gc_hal_rename_h_ - - -#if defined(_HAL2D_APPENDIX) - -#define _HAL2D_RENAME_2(api, appendix) api ## appendix -#define _HAL2D_RENAME_1(api, appendix) _HAL2D_RENAME_2(api, appendix) -#define gcmHAL2D(api) _HAL2D_RENAME_1(api, _HAL2D_APPENDIX) - - -#define gckOS_Construct gcmHAL2D(gckOS_Construct) -#define gckOS_Destroy gcmHAL2D(gckOS_Destroy) -#define gckOS_QueryVideoMemory gcmHAL2D(gckOS_QueryVideoMemory) -#define gckOS_Allocate gcmHAL2D(gckOS_Allocate) -#define gckOS_Free gcmHAL2D(gckOS_Free) -#define gckOS_AllocateMemory gcmHAL2D(gckOS_AllocateMemory) -#define gckOS_FreeMemory gcmHAL2D(gckOS_FreeMemory) -#define gckOS_LockPages gcmHAL2D(gckOS_LockPages) -#define gckOS_UnlockPages gcmHAL2D(gckOS_UnlockPages) -#define gckOS_FreePagedMemory gcmHAL2D(gckOS_FreePagedMemory) -#define gckOS_AllocateNonPagedMemory gcmHAL2D(gckOS_AllocateNonPagedMemory) -#define gckOS_FreeNonPagedMemory gcmHAL2D(gckOS_FreeNonPagedMemory) -#define gckOS_GetPageSize gcmHAL2D(gckOS_GetPageSize) -#define gckOS_GetPhysicalAddress gcmHAL2D(gckOS_GetPhysicalAddress) -#define gckOS_UserLogicalToPhysical gcmHAL2D(gckOS_UserLogicalToPhysical) -#define gckOS_MapPhysical gcmHAL2D(gckOS_MapPhysical) -#define gckOS_UnmapPhysical gcmHAL2D(gckOS_UnmapPhysical) -#define gckOS_ReadRegister gcmHAL2D(gckOS_ReadRegister) -#define gckOS_WriteRegister gcmHAL2D(gckOS_WriteRegister) -#define gckOS_WriteMemory gcmHAL2D(gckOS_WriteMemory) -#define gckOS_MapMemory gcmHAL2D(gckOS_MapMemory) -#define gckOS_UnmapMemory gcmHAL2D(gckOS_UnmapMemory) -#define gckOS_UnmapMemoryEx gcmHAL2D(gckOS_UnmapMemoryEx) -#define gckOS_CreateMutex gcmHAL2D(gckOS_CreateMutex) -#define gckOS_DeleteMutex gcmHAL2D(gckOS_DeleteMutex) -#define gckOS_AcquireMutex gcmHAL2D(gckOS_AcquireMutex) -#define gckOS_ReleaseMutex gcmHAL2D(gckOS_ReleaseMutex) -#define gckOS_AtomicExchange gcmHAL2D(gckOS_AtomicExchange) -#define gckOS_AtomicExchangePtr gcmHAL2D(gckOS_AtomicExchangePtr) -#define gckOS_AtomConstruct gcmHAL2D(gckOS_AtomConstruct) -#define gckOS_AtomDestroy gcmHAL2D(gckOS_AtomDestroy) -#define gckOS_AtomGet gcmHAL2D(gckOS_AtomGet) -#define gckOS_AtomIncrement gcmHAL2D(gckOS_AtomIncrement) -#define gckOS_AtomDecrement gcmHAL2D(gckOS_AtomDecrement) -#define gckOS_Delay gcmHAL2D(gckOS_Delay) -#define gckOS_GetTime gcmHAL2D(gckOS_GetTime) -#define gckOS_MemoryBarrier gcmHAL2D(gckOS_MemoryBarrier) -#define gckOS_MapUserPointer gcmHAL2D(gckOS_MapUserPointer) -#define gckOS_UnmapUserPointer gcmHAL2D(gckOS_UnmapUserPointer) -#define gckOS_QueryNeedCopy gcmHAL2D(gckOS_QueryNeedCopy) -#define gckOS_CopyFromUserData gcmHAL2D(gckOS_CopyFromUserData) -#define gckOS_CopyToUserData gcmHAL2D(gckOS_CopyToUserData) -#define gckOS_SuspendInterrupt gcmHAL2D(gckOS_SuspendInterrupt) -#define gckOS_ResumeInterrupt gcmHAL2D(gckOS_ResumeInterrupt) -#define gckOS_GetBaseAddress gcmHAL2D(gckOS_GetBaseAddress) -#define gckOS_MemCopy gcmHAL2D(gckOS_MemCopy) -#define gckOS_ZeroMemory gcmHAL2D(gckOS_ZeroMemory) -#define gckOS_DeviceControl gcmHAL2D(gckOS_DeviceControl) -#define gckOS_GetProcessID gcmHAL2D(gckOS_GetProcessID) -#define gckOS_GetThreadID gcmHAL2D(gckOS_GetThreadID) -#define gckOS_CreateSignal gcmHAL2D(gckOS_CreateSignal) -#define gckOS_DestroySignal gcmHAL2D(gckOS_DestroySignal) -#define gckOS_Signal gcmHAL2D(gckOS_Signal) -#define gckOS_WaitSignal gcmHAL2D(gckOS_WaitSignal) -#define gckOS_MapSignal gcmHAL2D(gckOS_MapSignal) -#define gckOS_CreateUserSignal gcmHAL2D(gckOS_CreateUserSignal) -#define gckOS_DestroyUserSignal gcmHAL2D(gckOS_DestroyUserSignal) -#define gckOS_WaitUserSignal gcmHAL2D(gckOS_WaitUserSignal) -#define gckOS_SignalUserSignal gcmHAL2D(gckOS_SignalUserSignal) -#define gckOS_UserSignal gcmHAL2D(gckOS_UserSignal) -#define gckOS_UserSignal gcmHAL2D(gckOS_UserSignal) -#define gckOS_SetDebugLevel gcmHAL2D(gckOS_SetDebugLevel) -#define gckOS_SetDebugZone gcmHAL2D(gckOS_SetDebugZone) -#define gckOS_SetDebugLevelZone gcmHAL2D(gckOS_SetDebugLevelZone) -#define gckOS_SetDebugZones gcmHAL2D(gckOS_SetDebugZones) -#define gckOS_SetDebugFile gcmHAL2D(gckOS_SetDebugFile) -#define gckOS_Broadcast gcmHAL2D(gckOS_Broadcast) -#define gckOS_SetGPUPower gcmHAL2D(gckOS_SetGPUPower) -#define gckOS_CreateSemaphore gcmHAL2D(gckOS_CreateSemaphore) -#define gckOS_DestroySemaphore gcmHAL2D(gckOS_DestroySemaphore) -#define gckOS_AcquireSemaphore gcmHAL2D(gckOS_AcquireSemaphore) -#define gckOS_ReleaseSemaphore gcmHAL2D(gckOS_ReleaseSemaphore) -#define gckHEAP_Construct gcmHAL2D(gckHEAP_Construct) -#define gckHEAP_Destroy gcmHAL2D(gckHEAP_Destroy) -#define gckHEAP_Allocate gcmHAL2D(gckHEAP_Allocate) -#define gckHEAP_Free gcmHAL2D(gckHEAP_Free) -#define gckHEAP_ProfileStart gcmHAL2D(gckHEAP_ProfileStart) -#define gckHEAP_ProfileEnd gcmHAL2D(gckHEAP_ProfileEnd) -#define gckHEAP_Test gcmHAL2D(gckHEAP_Test) -#define gckVIDMEM_Construct gcmHAL2D(gckVIDMEM_Construct) -#define gckVIDMEM_Destroy gcmHAL2D(gckVIDMEM_Destroy) -#define gckKERNEL_Construct gcmHAL2D(gckKERNEL_Construct) -#define gckKERNEL_Destroy gcmHAL2D(gckKERNEL_Destroy) -#define gckKERNEL_Dispatch gcmHAL2D(gckKERNEL_Dispatch) -#define gckKERNEL_QueryVideoMemory gcmHAL2D(gckKERNEL_QueryVideoMemory) -#define gckKERNEL_GetVideoMemoryPool gcmHAL2D(gckKERNEL_GetVideoMemoryPool) -#define gckKERNEL_UnmapVideoMemory gcmHAL2D(gckKERNEL_UnmapVideoMemory) -#define gckKERNEL_MapMemory gcmHAL2D(gckKERNEL_MapMemory) -#define gckKERNEL_UnmapMemory gcmHAL2D(gckKERNEL_UnmapMemory) -#define gckKERNEL_Notify gcmHAL2D(gckKERNEL_Notify) -#define gckKERNEL_Recovery gcmHAL2D(gckKERNEL_Recovery) -#define gckKERNEL_OpenUserData gcmHAL2D(gckKERNEL_OpenUserData) -#define gckKERNEL_CloseUserData gcmHAL2D(gckKERNEL_CloseUserData) -#define gckHARDWARE_Construct gcmHAL2D(gckHARDWARE_Construct) -#define gckHARDWARE_Destroy gcmHAL2D(gckHARDWARE_Destroy) -#define gckHARDWARE_QuerySystemMemory gcmHAL2D(gckHARDWARE_QuerySystemMemory) -#define gckHARDWARE_BuildVirtualAddress gcmHAL2D(gckHARDWARE_BuildVirtualAddress) -#define gckHARDWARE_QueryCommandBuffer gcmHAL2D(gckHARDWARE_QueryCommandBuffer) -#define gckHARDWARE_PipeSelect gcmHAL2D(gckHARDWARE_PipeSelect) -#define gckHARDWARE_QueryMemory gcmHAL2D(gckHARDWARE_QueryMemory) -#define gckHARDWARE_QueryChipIdentity gcmHAL2D(gckHARDWARE_QueryChipIdentity) -#define gckHARDWARE_QueryChipSpecs gcmHAL2D(gckHARDWARE_QueryChipSpecs) -#define gckHARDWARE_ConvertFormat gcmHAL2D(gckHARDWARE_ConvertFormat) -#define gckHARDWARE_SplitMemory gcmHAL2D(gckHARDWARE_SplitMemory) -#define gckHARDWARE_AlignToTile gcmHAL2D(gckHARDWARE_AlignToTile) -#define gckHARDWARE_UpdateQueueTail gcmHAL2D(gckHARDWARE_UpdateQueueTail) -#define gckHARDWARE_ConvertLogical gcmHAL2D(gckHARDWARE_ConvertLogical) -#define gckHARDWARE_Interrupt gcmHAL2D(gckHARDWARE_Interrupt) -#define gckHARDWARE_Notify gcmHAL2D(gckHARDWARE_Notify) -#define gckHARDWARE_SetMMU gcmHAL2D(gckHARDWARE_SetMMU) -#define gckHARDWARE_FlushMMU gcmHAL2D(gckHARDWARE_FlushMMU) -#define gckHARDWARE_GetIdle gcmHAL2D(gckHARDWARE_GetIdle) -#define gckHARDWARE_Flush gcmHAL2D(gckHARDWARE_Flush) -#define gckHARDWARE_SetFastClear gcmHAL2D(gckHARDWARE_SetFastClear) -#define gckHARDWARE_ReadInterrupt gcmHAL2D(gckHARDWARE_ReadInterrupt) -#define gckHARDWARE_SetPowerManagementState gcmHAL2D(gckHARDWARE_SetPowerManagementState) -#define gckHARDWARE_QueryPowerManagementState gcmHAL2D(gckHARDWARE_QueryPowerManagementState) -#define gckHARDWARE_ProfileEngine2D gcmHAL2D(gckHARDWARE_ProfileEngine2D) -#define gckHARDWARE_InitializeHardware gcmHAL2D(gckHARDWARE_InitializeHardware) -#define gckHARDWARE_Reset gcmHAL2D(gckHARDWARE_Reset) -#define gckINTERRUPT_Construct gcmHAL2D(gckINTERRUPT_Construct) -#define gckINTERRUPT_Destroy gcmHAL2D(gckINTERRUPT_Destroy) -#define gckINTERRUPT_SetHandler gcmHAL2D(gckINTERRUPT_SetHandler) -#define gckINTERRUPT_Notify gcmHAL2D(gckINTERRUPT_Notify) -#define gckMMU_Construct gcmHAL2D(gckMMU_Construct) -#define gckMMU_Destroy gcmHAL2D(gckMMU_Destroy) -#define gckMMU_AllocatePages gcmHAL2D(gckMMU_AllocatePages) -#define gckMMU_FreePages gcmHAL2D(gckMMU_FreePages) -#define gckMMU_Test gcmHAL2D(gckMMU_Test) -#define gckHARDWARE_QueryProfileRegisters gcmHAL2D(gckHARDWARE_QueryProfileRegisters) - - -#define FindMdlMap gcmHAL2D(FindMdlMap) -#define OnProcessExit gcmHAL2D(OnProcessExit) - -#define gckGALDEVICE_Construct gcmHAL2D(gckGALDEVICE_Construct) -#define gckGALDEVICE_Start gcmHAL2D(gckGALDEVICE_Start) -#define gckGALDEVICE_Destroy gcmHAL2D(gckGALDEVICE_Destroy) -#define gckGALDEVICE_FreeMemory gcmHAL2D(gckGALDEVICE_FreeMemory) -#define gckGALDEVICE_AllocateMemory gcmHAL2D(gckGALDEVICE_AllocateMemory) -#define gckGALDEVICE_Stop gcmHAL2D(gckGALDEVICE_Stop) -#define gckOS_Print gcmHAL2D(gckOS_Print) -#define gckOS_DebugBreak gcmHAL2D(gckOS_DebugBreak) -#define gckOS_Verify gcmHAL2D(gckOS_Verify) -#define gckOS_DebugFatal gcmHAL2D(gckOS_DebugFatal) -#define gckOS_DebugTrace gcmHAL2D(gckOS_DebugTrace) -#define gckHARDWARE_GetBaseAddress gcmHAL2D(gckHARDWARE_GetBaseAddress) -#define gckKERNEL_AttachProcess gcmHAL2D(gckKERNEL_AttachProcess) -#define gckKERNEL_AttachProcessEx gcmHAL2D(gckKERNEL_AttachProcessEx) -#define gckHARDWARE_QueryIdle gcmHAL2D(gckHARDWARE_QueryIdle) -#define gckOS_DebugTraceZone gcmHAL2D(gckOS_DebugTraceZone) -#define gckHARDWARE_NeedBaseAddress gcmHAL2D(gckHARDWARE_NeedBaseAddress) - -#endif - -#endif /* __gc_hal_rename_h_ */ - - diff --git a/drivers/amlogic/npu/kernel/inc/gc_hal_types.h b/drivers/amlogic/npu/kernel/inc/gc_hal_types.h index 7ded9c8..aece5f4 100644 --- a/drivers/amlogic/npu/kernel/inc/gc_hal_types.h +++ b/drivers/amlogic/npu/kernel/inc/gc_hal_types.h @@ -2,7 +2,7 @@ * * The MIT License (MIT) * -* Copyright (c) 2014 - 2019 Vivante Corporation +* Copyright (c) 2014 - 2020 Vivante Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -26,7 +26,7 @@ * * The GPL License (GPL) * -* Copyright (C) 2014 - 2019 Vivante Corporation +* Copyright (C) 2014 - 2020 Vivante Corporation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -53,1101 +53,7 @@ *****************************************************************************/ -#ifndef __gc_hal_types_h_ -#define __gc_hal_types_h_ +#include "shared/gc_hal_types_shared.h" -#include "gc_hal_version.h" -#include "gc_hal_options.h" - -#if !defined(VIV_KMD) -#if defined(__KERNEL__) -#include "linux/version.h" -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) - typedef unsigned long uintptr_t; -# endif -# include "linux/types.h" -#elif defined(UNDER_CE) -#include -typedef signed char int8_t; -typedef short int16_t; -typedef int int32_t; -typedef long long int64_t; -typedef unsigned char uint8_t; -typedef unsigned short uint16_t; -typedef unsigned int uint32_t; -typedef unsigned long long uint64_t; -#elif defined(_MSC_VER) && (_MSC_VER <= 1500) -#include -#include "vadefs.h" -#elif defined(__QNXNTO__) -#define _QNX_SOURCE -#include -#include -#else -#include -#include -#include -#endif -#endif - -#ifdef _WIN32 -#pragma warning(disable:4127) /* Conditional expression is constant (do { } while(0)). */ -#pragma warning(disable:4100) /* Unreferenced formal parameter. */ -#pragma warning(disable:4204) /* Non-constant aggregate initializer (C99). */ -#pragma warning(disable:4131) /* Uses old-style declarator. */ -#pragma warning(disable:4206) /* Translation unit is empty. */ -#pragma warning(disable:4214) /* Nonstandard extension used : - ** bit field types other than int. */ -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/******************************************************************************\ -** Platform macros. -*/ - -#if defined(__GNUC__) -# define gcdHAS_ELLIPSIS 1 /* GCC always has it. */ -#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) -# define gcdHAS_ELLIPSIS 1 /* C99 has it. */ -#elif defined(_MSC_VER) && (_MSC_VER >= 1500) -# define gcdHAS_ELLIPSIS 1 /* MSVC 2007+ has it. */ -#elif defined(UNDER_CE) -#if UNDER_CE >= 600 -# define gcdHAS_ELLIPSIS 1 -# else -# define gcdHAS_ELLIPSIS 0 -# endif -#else -# error "gcdHAS_ELLIPSIS: Platform could not be determined" -#endif - -/******************************************************************************\ -************************************ Keyword *********************************** -\******************************************************************************/ - -#if defined(ANDROID) && defined(__BIONIC_FORTIFY) -#if defined(__clang__) -# define gcmINLINE __inline__ __attribute__ ((always_inline)) __attribute__ ((gnu_inline)) -# else -# define gcmINLINE __inline__ __attribute__ ((always_inline)) __attribute__ ((gnu_inline)) __attribute__ ((artificial)) -# endif -#elif ((defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || defined(__APPLE__)) -# define gcmINLINE inline /* C99 keyword. */ -#elif defined(__GNUC__) -# define gcmINLINE __inline__ /* GNU keyword. */ -#elif defined(_MSC_VER) || defined(UNDER_CE) -# define gcmINLINE __inline /* Internal keyword. */ -#else -# error "gcmINLINE: Platform could not be determined" -#endif - - -/* Possible debug flags. */ -#define gcdDEBUG_NONE 0 -#define gcdDEBUG_ALL (1 << 0) -#define gcdDEBUG_FATAL (1 << 1) -#define gcdDEBUG_TRACE (1 << 2) -#define gcdDEBUG_BREAK (1 << 3) -#define gcdDEBUG_ASSERT (1 << 4) -#define gcdDEBUG_CODE (1 << 5) -#define gcdDEBUG_STACK (1 << 6) - -#define gcmIS_DEBUG(flag) (gcdDEBUG & (flag | gcdDEBUG_ALL) ) - -#ifndef gcdDEBUG -#if (defined(DBG) && DBG) || defined(DEBUG) || defined(_DEBUG) -# define gcdDEBUG gcdDEBUG_ALL -# else -# define gcdDEBUG gcdDEBUG_NONE -# endif -#endif - -#ifdef _USRDLL -#ifdef _MSC_VER -#ifdef HAL_EXPORTS -# define HALAPI __declspec(dllexport) -# else -# define HALAPI __declspec(dllimport) -# endif -# define HALDECL __cdecl -# else -#ifdef HAL_EXPORTS -# define HALAPI -# else -# define HALAPI extern -# endif -# endif -#else -# define HALAPI -# define HALDECL -#endif - -/******************************************************************************\ -********************************** Common Types ******************************** -\******************************************************************************/ - -#define gcvFALSE 0 -#define gcvTRUE 1 - -#define gcvINFINITE ((gctUINT32) ~0U) - -#define gcvINVALID_HANDLE ((gctHANDLE) ~0U) - -typedef int gctBOOL; -typedef gctBOOL * gctBOOL_PTR; - -typedef int gctINT; -typedef signed char gctINT8; -typedef signed short gctINT16; -typedef signed int gctINT32; -typedef signed long long gctINT64; - -typedef gctINT * gctINT_PTR; -typedef gctINT8 * gctINT8_PTR; -typedef gctINT16 * gctINT16_PTR; -typedef gctINT32 * gctINT32_PTR; -typedef gctINT64 * gctINT64_PTR; - -typedef unsigned int gctUINT; -typedef unsigned char gctUINT8; -typedef unsigned short gctUINT16; -typedef unsigned int gctUINT32; -typedef unsigned long long gctUINT64; -typedef uintptr_t gctUINTPTR_T; -typedef ptrdiff_t gctPTRDIFF_T; - -typedef gctUINT * gctUINT_PTR; -typedef gctUINT8 * gctUINT8_PTR; -typedef gctUINT16 * gctUINT16_PTR; -typedef gctUINT32 * gctUINT32_PTR; -typedef gctUINT64 * gctUINT64_PTR; - -typedef size_t gctSIZE_T; -typedef gctSIZE_T * gctSIZE_T_PTR; -typedef gctUINT32 gctTRACE; - -#ifdef __cplusplus -# define gcvNULL 0 -#else -# define gcvNULL ((void *) 0) -#endif - -#define gcvMAXINT8 0x7f -#define gcvMININT8 0x80 -#define gcvMAXINT16 0x7fff -#define gcvMININT16 0x8000 -#define gcvMAXINT32 0x7fffffff -#define gcvMININT32 0x80000000 -#define gcvMAXINT64 0x7fffffffffffffff -#define gcvMININT64 0x8000000000000000 -#define gcvMAXUINT8 0xff -#define gcvMINUINT8 0x0 -#define gcvMAXUINT16 0xffff -#define gcvMINUINT16 0x0 -#define gcvMAXUINT32 0xffffffff -#define gcvMINUINT32 0x0 -#define gcvMAXUINT64 0xffffffffffffffff -#define gcvMINUINT64 0x0 -#define gcvMAXUINTPTR_T (~(gctUINTPTR_T)0) -#define gcvMAXSIZE_T ((gctSIZE_T)(-1)) - -typedef float gctFLOAT; -typedef signed int gctFIXED_POINT; -typedef float * gctFLOAT_PTR; - -typedef void * gctPHYS_ADDR; -typedef void * gctHANDLE; -typedef void * gctFILE; -typedef void * gctSIGNAL; -typedef void * gctWINDOW; -typedef void * gctIMAGE; -typedef void * gctSHBUF; - -typedef void * gctSEMAPHORE; - -typedef void * gctPOINTER; -typedef const void * gctCONST_POINTER; - -typedef char gctCHAR; -typedef signed char gctSIGNED_CHAR; -typedef unsigned char gctUNSIGNED_CHAR; -typedef char * gctSTRING; -typedef const char * gctCONST_STRING; - -typedef gctUINT64 gctPHYS_ADDR_T; - -typedef struct _gcsCOUNT_STRING -{ - gctSIZE_T Length; - gctCONST_STRING String; -} -gcsCOUNT_STRING; - -typedef union _gcuFLOAT_UINT32 -{ - gctFLOAT f; - gctUINT32 u; -} -gcuFLOAT_UINT32; - -/* Fixed point constants. */ -#define gcvZERO_X ((gctFIXED_POINT) 0x00000000) -#define gcvHALF_X ((gctFIXED_POINT) 0x00008000) -#define gcvONE_X ((gctFIXED_POINT) 0x00010000) -#define gcvNEGONE_X ((gctFIXED_POINT) 0xFFFF0000) -#define gcvTWO_X ((gctFIXED_POINT) 0x00020000) - - - -#define gcmFIXEDCLAMP_NEG1_TO_1(_x) \ - (((_x) < gcvNEGONE_X) \ - ? gcvNEGONE_X \ - : (((_x) > gcvONE_X) \ - ? gcvONE_X \ - : (_x))) - -#define gcmFLOATCLAMP_NEG1_TO_1(_f) \ - (((_f) < -1.0f) \ - ? -1.0f \ - : (((_f) > 1.0f) \ - ? 1.0f \ - : (_f))) - - -#define gcmFIXEDCLAMP_0_TO_1(_x) \ - (((_x) < 0) \ - ? 0 \ - : (((_x) > gcvONE_X) \ - ? gcvONE_X \ - : (_x))) - -#define gcmFLOATCLAMP_0_TO_1(_f) \ - (((_f) < 0.0f) \ - ? 0.0f \ - : (((_f) > 1.0f) \ - ? 1.0f \ - : (_f))) - - -/******************************************************************************\ -******************************* Multicast Values ******************************* -\******************************************************************************/ - -/* Value types. */ -typedef enum _gceVALUE_TYPE -{ - gcvVALUE_UINT = 0x0, - gcvVALUE_FIXED, - gcvVALUE_FLOAT, - gcvVALUE_INT, - - /* - ** The value need be unsigned denormalized. clamp (0.0-1.0) should be done first. - */ - gcvVALUE_FLAG_UNSIGNED_DENORM = 0x00010000, - - /* - ** The value need be signed denormalized. clamp (-1.0-1.0) should be done first. - */ - gcvVALUE_FLAG_SIGNED_DENORM = 0x00020000, - - /* - ** The value need to gammar - */ - gcvVALUE_FLAG_GAMMAR = 0x00040000, - - /* - ** The value need to convert from float to float16 - */ - gcvVALUE_FLAG_FLOAT_TO_FLOAT16 = 0x0080000, - - /* - ** Mask for flag field. - */ - gcvVALUE_FLAG_MASK = 0xFFFF0000, -} -gceVALUE_TYPE; - -/* Value unions. */ -typedef union _gcuVALUE -{ - gctUINT uintValue; - gctFIXED_POINT fixedValue; - gctFLOAT floatValue; - gctINT intValue; -} -gcuVALUE; - - - - -/* Stringizing macro. */ -#define gcmSTRING(Value) #Value - -/******************************************************************************\ -******************************* Fixed Point Math ******************************* -\******************************************************************************/ - -#define gcmXMultiply(x1, x2) gcoMATH_MultiplyFixed(x1, x2) -#define gcmXDivide(x1, x2) gcoMATH_DivideFixed(x1, x2) -#define gcmXMultiplyDivide(x1, x2, x3) gcoMATH_MultiplyDivideFixed(x1, x2, x3) - -/* 2D Engine profile. */ -typedef struct _gcs2D_PROFILE -{ - /* Cycle count. - 32bit counter incremented every 2D clock cycle. - Wraps back to 0 when the counter overflows. - */ - gctUINT32 cycleCount; - - /* Pixels rendered by the 2D engine. - Resets to 0 every time it is read. */ - gctUINT32 pixelsRendered; -} -gcs2D_PROFILE; - -/* Macro to combine four characters into a Charcater Code. */ -#define gcmCC(c1, c2, c3, c4) \ -(\ - (char) (c1) \ - | \ - ((char) (c2) << 8) \ - | \ - ((char) (c3) << 16) \ - | \ - ((char) (c4) << 24) \ -) - -#define gcmPRINTABLE(c) ((((c) >= ' ') && ((c) <= '}')) ? ((c) != '%' ? (c) : ' ') : ' ') - -#define gcmCC_PRINT(cc) \ - gcmPRINTABLE((char) ((cc) & 0xFF)), \ - gcmPRINTABLE((char) (((cc) >> 8) & 0xFF)), \ - gcmPRINTABLE((char) (((cc) >> 16) & 0xFF)), \ - gcmPRINTABLE((char) (((cc) >> 24) & 0xFF)) - -/******************************************************************************\ -****************************** Function Parameters ***************************** -\******************************************************************************/ - -#define IN -#define OUT -#define INOUT -#define OPTIONAL - -/******************************************************************************\ -********************************* Status Codes ********************************* -\******************************************************************************/ - -typedef enum _gceSTATUS -{ - gcvSTATUS_OK = 0, - gcvSTATUS_FALSE = 0, - gcvSTATUS_TRUE = 1, - gcvSTATUS_NO_MORE_DATA = 2, - gcvSTATUS_CACHED = 3, - gcvSTATUS_MIPMAP_TOO_LARGE = 4, - gcvSTATUS_NAME_NOT_FOUND = 5, - gcvSTATUS_NOT_OUR_INTERRUPT = 6, - gcvSTATUS_MISMATCH = 7, - gcvSTATUS_MIPMAP_TOO_SMALL = 8, - gcvSTATUS_LARGER = 9, - gcvSTATUS_SMALLER = 10, - gcvSTATUS_CHIP_NOT_READY = 11, - gcvSTATUS_NEED_CONVERSION = 12, - gcvSTATUS_SKIP = 13, - gcvSTATUS_DATA_TOO_LARGE = 14, - gcvSTATUS_INVALID_CONFIG = 15, - gcvSTATUS_CHANGED = 16, - gcvSTATUS_NOT_SUPPORT_DITHER = 17, - gcvSTATUS_EXECUTED = 18, - gcvSTATUS_TERMINATE = 19, - - gcvSTATUS_INVALID_ARGUMENT = -1, - gcvSTATUS_INVALID_OBJECT = -2, - gcvSTATUS_OUT_OF_MEMORY = -3, - gcvSTATUS_MEMORY_LOCKED = -4, - gcvSTATUS_MEMORY_UNLOCKED = -5, - gcvSTATUS_HEAP_CORRUPTED = -6, - gcvSTATUS_GENERIC_IO = -7, - gcvSTATUS_INVALID_ADDRESS = -8, - gcvSTATUS_CONTEXT_LOSSED = -9, - gcvSTATUS_TOO_COMPLEX = -10, - gcvSTATUS_BUFFER_TOO_SMALL = -11, - gcvSTATUS_INTERFACE_ERROR = -12, - gcvSTATUS_NOT_SUPPORTED = -13, - gcvSTATUS_MORE_DATA = -14, - gcvSTATUS_TIMEOUT = -15, - gcvSTATUS_OUT_OF_RESOURCES = -16, - gcvSTATUS_INVALID_DATA = -17, - gcvSTATUS_INVALID_MIPMAP = -18, - gcvSTATUS_NOT_FOUND = -19, - gcvSTATUS_NOT_ALIGNED = -20, - gcvSTATUS_INVALID_REQUEST = -21, - gcvSTATUS_GPU_NOT_RESPONDING = -22, - gcvSTATUS_TIMER_OVERFLOW = -23, - gcvSTATUS_VERSION_MISMATCH = -24, - gcvSTATUS_LOCKED = -25, - gcvSTATUS_INTERRUPTED = -26, - gcvSTATUS_DEVICE = -27, - gcvSTATUS_NOT_MULTI_PIPE_ALIGNED = -28, - gcvSTATUS_OUT_OF_SAMPLER = -29, - - /* Linker errors. */ - gcvSTATUS_GLOBAL_TYPE_MISMATCH = -1000, - gcvSTATUS_TOO_MANY_ATTRIBUTES = -1001, - gcvSTATUS_TOO_MANY_UNIFORMS = -1002, - gcvSTATUS_TOO_MANY_VARYINGS = -1003, - gcvSTATUS_UNDECLARED_VARYING = -1004, - gcvSTATUS_VARYING_TYPE_MISMATCH = -1005, - gcvSTATUS_MISSING_MAIN = -1006, - gcvSTATUS_NAME_MISMATCH = -1007, - gcvSTATUS_INVALID_INDEX = -1008, - gcvSTATUS_UNIFORM_MISMATCH = -1009, - gcvSTATUS_UNSAT_LIB_SYMBOL = -1010, - gcvSTATUS_TOO_MANY_SHADERS = -1011, - gcvSTATUS_LINK_INVALID_SHADERS = -1012, - gcvSTATUS_CS_NO_WORKGROUP_SIZE = -1013, - gcvSTATUS_LINK_LIB_ERROR = -1014, - - gcvSTATUS_SHADER_VERSION_MISMATCH = -1015, - gcvSTATUS_TOO_MANY_INSTRUCTION = -1016, - gcvSTATUS_SSBO_MISMATCH = -1017, - gcvSTATUS_TOO_MANY_OUTPUT = -1018, - gcvSTATUS_TOO_MANY_INPUT = -1019, - gcvSTATUS_NOT_SUPPORT_CL = -1020, - gcvSTATUS_NOT_SUPPORT_INTEGER = -1021, - gcvSTATUS_UNIFORM_TYPE_MISMATCH = -1022, - - gcvSTATUS_MISSING_PRIMITIVE_TYPE = -1023, - gcvSTATUS_MISSING_OUTPUT_VERTEX_COUNT = -1024, - gcvSTATUS_NON_INVOCATION_ID_AS_INDEX = -1025, - gcvSTATUS_INPUT_ARRAY_SIZE_MISMATCH = -1026, - gcvSTATUS_OUTPUT_ARRAY_SIZE_MISMATCH = -1027, - gcvSTATUS_LOCATION_ALIASED = -1028, - - /* Compiler errors. */ - gcvSTATUS_COMPILER_FE_PREPROCESSOR_ERROR = -2000, - gcvSTATUS_COMPILER_FE_PARSER_ERROR = -2001, - - /* Recompilation Errors */ - gcvSTATUS_RECOMPILER_CONVERT_UNIMPLEMENTED = -3000, -} -gceSTATUS; - -/******************************************************************************\ -********************************* Status Macros ******************************** -\******************************************************************************/ - -#define gcmIS_ERROR(status) (status < 0) -#define gcmNO_ERROR(status) (status >= 0) -#define gcmIS_SUCCESS(status) (status == gcvSTATUS_OK) - -/******************************************************************************\ -********************************* Field Macros ********************************* -\******************************************************************************/ - -#define __gcmSTART(reg_field) \ - (0 ? reg_field) - -#define __gcmEND(reg_field) \ - (1 ? reg_field) - -#define __gcmGETSIZE(reg_field) \ - (__gcmEND(reg_field) - __gcmSTART(reg_field) + 1) - -#define __gcmALIGN(data, reg_field) \ - (((gctUINT32) (data)) << __gcmSTART(reg_field)) - -#define __gcmMASK(reg_field) \ - ((gctUINT32) ((__gcmGETSIZE(reg_field) == 32) \ - ? ~0U \ - : (~(~0U << __gcmGETSIZE(reg_field))))) - -/******************************************************************************* -** -** gcmFIELDMASK -** -** Get aligned field mask. -** -** ARGUMENTS: -** -** reg Name of register. -** field Name of field within register. -*/ -#define gcmFIELDMASK(reg, field) \ -(\ - __gcmALIGN(__gcmMASK(reg##_##field), reg##_##field) \ -) - -/******************************************************************************* -** -** gcmGETFIELD -** -** Extract the value of a field from specified data. -** -** ARGUMENTS: -** -** data Data value. -** reg Name of register. -** field Name of field within register. -*/ -#define gcmGETFIELD(data, reg, field) \ -(\ - ((((gctUINT32) (data)) >> __gcmSTART(reg##_##field)) \ - & __gcmMASK(reg##_##field)) \ -) - -/******************************************************************************* -** -** gcmSETFIELD -** -** Set the value of a field within specified data. -** -** ARGUMENTS: -** -** data Data value. -** reg Name of register. -** field Name of field within register. -** value Value for field. -*/ -#define gcmSETFIELD(data, reg, field, value) \ -(\ - (((gctUINT32) (data)) \ - & ~__gcmALIGN(__gcmMASK(reg##_##field), reg##_##field)) \ - | __gcmALIGN((gctUINT32) (value) \ - & __gcmMASK(reg##_##field), reg##_##field) \ -) - -/******************************************************************************* -** -** gcmSETFIELDVALUE -** -** Set the value of a field within specified data with a -** predefined value. -** -** ARGUMENTS: -** -** data Data value. -** reg Name of register. -** field Name of field within register. -** value Name of the value within the field. -*/ -#define gcmSETFIELDVALUE(data, reg, field, value) \ -(\ - (((gctUINT32) (data)) \ - & ~__gcmALIGN(__gcmMASK(reg##_##field), reg##_##field)) \ - | __gcmALIGN(reg##_##field##_##value \ - & __gcmMASK(reg##_##field), reg##_##field) \ -) - -/******************************************************************************* -** -** gcmGETMASKEDFIELDMASK -** -** Determine field mask of a masked field. -** -** ARGUMENTS: -** -** reg Name of register. -** field Name of field within register. -*/ -#define gcmGETMASKEDFIELDMASK(reg, field) \ -(\ - gcmSETFIELD(0, reg, field, ~0U) | \ - gcmSETFIELD(0, reg, MASK_ ## field, ~0U) \ -) - -/******************************************************************************* -** -** gcmSETMASKEDFIELD -** -** Set the value of a masked field with specified data. -** -** ARGUMENTS: -** -** reg Name of register. -** field Name of field within register. -** value Value for field. -*/ -#define gcmSETMASKEDFIELD(reg, field, value) \ -(\ - gcmSETFIELD (~0U, reg, field, value) & \ - gcmSETFIELDVALUE(~0U, reg, MASK_ ## field, ENABLED) \ -) - -/******************************************************************************* -** -** gcmSETMASKEDFIELDVALUE -** -** Set the value of a masked field with specified data. -** -** ARGUMENTS: -** -** reg Name of register. -** field Name of field within register. -** value Value for field. -*/ -#define gcmSETMASKEDFIELDVALUE(reg, field, value) \ -(\ - gcmSETFIELDVALUE(~0U, reg, field, value) & \ - gcmSETFIELDVALUE(~0U, reg, MASK_ ## field, ENABLED) \ -) - -/******************************************************************************* -** -** gcmVERIFYFIELDVALUE -** -** Verify if the value of a field within specified data equals a -** predefined value. -** -** ARGUMENTS: -** -** data Data value. -** reg Name of register. -** field Name of field within register. -** value Name of the value within the field. -*/ -#define gcmVERIFYFIELDVALUE(data, reg, field, value) \ -(\ - (((gctUINT32) (data)) >> __gcmSTART(reg##_##field) & \ - __gcmMASK(reg##_##field)) \ - == \ - (reg##_##field##_##value & __gcmMASK(reg##_##field)) \ -) - -/******************************************************************************* -** Bit field macros. -*/ - -#define __gcmSTARTBIT(Field) \ - (1 ? Field ) - -#define __gcmBITSIZE(Field) \ - (0 ? Field ) - -#define __gcmBITMASK(Field) \ -(\ - (1 << __gcmBITSIZE(Field)) - 1 \ -) - -#define gcmGETBITS(Value, Type, Field) \ -(\ - (((Type) (Value)) >> __gcmSTARTBIT(Field) ) \ - & \ - __gcmBITMASK(Field) \ -) - -#define gcmSETBITS(Value, Type, Field, NewValue) \ -(\ - (((Type) (Value)) \ - & ~(__gcmBITMASK(Field) << __gcmSTARTBIT(Field)) \ - ) \ - | \ - ((((Type) (NewValue)) \ - & __gcmBITMASK(Field) \ - ) << __gcmSTARTBIT(Field) \ - ) \ -) - -/******************************************************************************* -** -** gcmISINREGRANGE -** -** Verify whether the specified address is in the register range. -** -** ARGUMENTS: -** -** Address Address to be verified. -** Name Name of a register. -*/ - -#define gcmISINREGRANGE(Address, Name) \ -(\ - ((Address & (~0U << Name ## _LSB)) == (Name ## _Address >> 2)) \ -) - -/******************************************************************************\ -******************************** Ceiling Macro ******************************** -\******************************************************************************/ -#define gcmCEIL(x) (((x) - (gctUINT32)(x)) == 0 ? (gctUINT32)(x) : (gctUINT32)(x) + 1) - -/******************************************************************************\ -******************************** Min/Max Macros ******************************** -\******************************************************************************/ - -#define gcmMIN(x, y) (((x) <= (y)) ? (x) : (y)) -#define gcmMAX(x, y) (((x) >= (y)) ? (x) : (y)) -#define gcmCLAMP(x, min, max) (((x) < (min)) ? (min) : \ - ((x) > (max)) ? (max) : (x)) -#define gcmABS(x) (((x) < 0) ? -(x) : (x)) -#define gcmNEG(x) (((x) < 0) ? (x) : -(x)) - -/******************************************************************************\ -******************************** Bit Macro ******************************** -\******************************************************************************/ -#define gcmBITSET(x, y) ((x) & (y)) -/******************************************************************************* -** -** gcmPTR2SIZE -** -** Convert a pointer to an integer value. -** -** ARGUMENTS: -** -** p Pointer value. -*/ -#define gcmPTR2SIZE(p) \ -(\ - (gctUINTPTR_T) (p) \ -) - -#define gcmPTR2INT32(p) \ -(\ - (gctUINT32)(gctUINTPTR_T) (p) \ -) - -/******************************************************************************* -** -** gcmINT2PTR -** -** Convert an integer value into a pointer. -** -** ARGUMENTS: -** -** v Integer value. -*/ - -#define gcmINT2PTR(i) \ -(\ - (gctPOINTER) (gctUINTPTR_T)(i) \ -) - -/******************************************************************************* -** -** gcmOFFSETOF -** -** Compute the byte offset of a field inside a structure. -** -** ARGUMENTS: -** -** s Structure name. -** field Field name. -*/ -#define gcmOFFSETOF(s, field) \ -(\ - gcmPTR2INT32(& (((struct s *) 0)->field)) \ -) - -#define __gcmOFFSETOF(type, field) \ -(\ - gcmPTR2INT32(& (((type *) 0)->field)) \ -) - -/******************************************************************************* -** -** gcmCONTAINEROF -** -** Get containing structure of a member. -** -** ARGUMENTS: -** -** Pointer Pointer of member. -** Type Structure name. -** Name Field name. -*/ -#define gcmCONTAINEROF(Pointer, Type, Member) \ -(\ - (Type *)((gctUINTPTR_T)Pointer - __gcmOFFSETOF(Type, Member)) \ -) - -/******************************************************************************* -** -** gcmBSWAP32 -** -** Return a value with all bytes in the 32 bit argument swapped. -*/ -#if !defined(__KERNEL__) && defined(__GNUC__) && (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__ >= 40300) \ - && !defined(__VXWORKS__) -# define gcmBSWAP32(x) __builtin_bswap32(x) -#else -# define gcmBSWAP32(x) ((gctUINT32)(\ - (((gctUINT32)(x) & (gctUINT32)0x000000FFUL) << 24) | \ - (((gctUINT32)(x) & (gctUINT32)0x0000FF00UL) << 8) | \ - (((gctUINT32)(x) & (gctUINT32)0x00FF0000UL) >> 8) | \ - (((gctUINT32)(x) & (gctUINT32)0xFF000000UL) >> 24))) -#endif - -/******************************************************************************* -***** Database ****************************************************************/ - -typedef struct _gcsDATABASE_COUNTERS -{ - /* Number of currently allocated bytes. */ - gctUINT64 bytes; - - /* Maximum number of bytes allocated (memory footprint). */ - gctUINT64 maxBytes; - - /* Total number of bytes allocated. */ - gctUINT64 totalBytes; - - /* The numbers of times video memory was allocated. */ - gctUINT32 allocCount; - - /* The numbers of times video memory was freed. */ - gctUINT32 freeCount; -} -gcsDATABASE_COUNTERS; - -typedef struct _gcuDATABASE_INFO -{ - /* Counters. */ - gcsDATABASE_COUNTERS counters; - - /* Time value. */ - gctUINT64 time; -} -gcuDATABASE_INFO; - -/******************************************************************************* -***** Frame database **********************************************************/ - -/* gcsHAL_FRAME_INFO */ -typedef struct _gcsHAL_FRAME_INFO -{ - /* Current timer tick. */ - OUT gctUINT64 ticks; - - /* Bandwidth counters. */ - OUT gctUINT readBytes8[8]; - OUT gctUINT writeBytes8[8]; - - /* Counters. */ - OUT gctUINT cycles[8]; - OUT gctUINT idleCycles[8]; - OUT gctUINT mcCycles[8]; - OUT gctUINT readRequests[8]; - OUT gctUINT writeRequests[8]; - - /* 3D counters. */ - OUT gctUINT vertexCount; - OUT gctUINT primitiveCount; - OUT gctUINT rejectedPrimitives; - OUT gctUINT culledPrimitives; - OUT gctUINT clippedPrimitives; - OUT gctUINT outPrimitives; - OUT gctUINT inPrimitives; - OUT gctUINT culledQuadCount; - OUT gctUINT totalQuadCount; - OUT gctUINT quadCount; - OUT gctUINT totalPixelCount; - - /* PE counters. */ - OUT gctUINT colorKilled[8]; - OUT gctUINT colorDrawn[8]; - OUT gctUINT depthKilled[8]; - OUT gctUINT depthDrawn[8]; - - /* Shader counters. */ - OUT gctUINT shaderCycles; - OUT gctUINT vsInstructionCount; - OUT gctUINT vsTextureCount; - OUT gctUINT psInstructionCount; - OUT gctUINT psTextureCount; - - /* Texture counters. */ - OUT gctUINT bilinearRequests; - OUT gctUINT trilinearRequests; - OUT gctUINT txBytes8; - OUT gctUINT txHitCount; - OUT gctUINT txMissCount; -} -gcsHAL_FRAME_INFO; - -typedef struct _gckLINKDATA * gckLINKDATA; -struct _gckLINKDATA -{ - gctUINT32 start; - gctUINT32 end; - gctUINT32 pid; - gctUINT32 linkLow; - gctUINT32 linkHigh; -}; - -typedef struct _gckADDRESSDATA * gckADDRESSDATA; -struct _gckADDRESSDATA -{ - gctUINT32 start; - gctUINT32 end; -}; - -typedef union _gcuQUEUEDATA -{ - struct _gckLINKDATA linkData; - - struct _gckADDRESSDATA addressData; -} -gcuQUEUEDATA; - -typedef struct _gckQUEUE * gckQUEUE; -struct _gckQUEUE -{ - gcuQUEUEDATA * datas; - gctUINT32 rear; - gctUINT32 front; - gctUINT32 count; - gctUINT32 size; -}; - -typedef enum _gceTRACEMODE -{ - gcvTRACEMODE_NONE = 0, - gcvTRACEMODE_FULL = 1, - gcvTRACEMODE_LOGGER = 2, - gcvTRACEMODE_ALLZONE = 3, - gcvTRACEMODE_PRE = 4, - gcvTRACEMODE_POST = 5, -} gceTRACEMODE; - -typedef struct _gcsLISTHEAD * gcsLISTHEAD_PTR; -typedef struct _gcsLISTHEAD -{ - gcsLISTHEAD_PTR prev; - gcsLISTHEAD_PTR next; -} -gcsLISTHEAD; - -/* - * 'Patch' here means a mechanism to let kernel side modify user space reserved - * command buffer location, or something the like, during the command buffer - * commit. - * - * Reasons of using 'patch': - * 1. Some resources/states are managed globally only in kernel side, such as - * MCFE semaphore, etc. - * 2. For the sake of security or optimization, like video memory address. - * - * Patches are arranged in arrays, each array has the same type. The 'patchArray' - * in 'gcsHAL_PATCH_LIST' pointers the concrete patch item array. - * - * NOTICE: - * Be aware of the order and values! Tables in gc_hal_user_buffer.c and - * gc_hal_kernel_command.c depend on this. - */ -/* The patch types. */ -enum _gceHAL_PATCH_TYPE -{ - gcvHAL_PATCH_VIDMEM_ADDRESS = 1, - gcvHAL_PATCH_MCFE_SEMAPHORE, - gcvHAL_PATCH_VIDMEM_TIMESTAMP, - - /* Must be the last one for counting. */ - gcvHAL_PATCH_TYPE_COUNT, -}; - -/* The patch array. */ -typedef struct _gcsHAL_PATCH_LIST -{ - /* Patch type. */ - gctUINT32 type; - - /* Patch item count. */ - gctUINT32 count; - - /* - * Pointer to the patch items. - * - * gcsHAL_PATCH_VIDMEM_ADDRESS * patchArray; - * gcsHAL_PATCH_MCFE_SEMAPHORE * patchArray; - * gcsHAL_PATCH_VIDMEM_TIMESTAMP * patchArray; - * ... - */ - gctUINT64 patchArray; - - /* struct _gcsHAL_PATCH_LIST * next; */ - gctUINT64 next; -} -gcsHAL_PATCH_LIST; - -/* - * Patch a GPU address in the place (gcvHAL_PATCH_VIDMEM_ADDRESS). - * Size of a GPU address is always 32 bits. - */ -typedef struct _gcsHAL_PATCH_VIDMEM_ADDRESS -{ - /* Patch location in the command buffer. */ - gctUINT32 location; - - /* Handle of the video memory node. */ - gctUINT32 node; - - /* Address offset in the video memory node. */ - gctUINT32 offset; -} -gcsHAL_PATCH_VIDMEM_ADDRESS; - -/* - * Patch a MCFE semaphore command in the place (gcvHAL_PATCH_MCFE_SEMAPHORE). - * Size of the semaphore command is fixed at _64_ bits! - */ -typedef struct _gcsHAL_PATCH_MCFE_SEMAPHORE -{ - /* Patch location in the command buffer. */ - gctUINT32 location; - - /* semaphore direction: 1 = Send, 0 = Wait. */ - gctUINT32 sendSema; - - /* Handle of the semaphore. */ - gctUINT32 semaHandle; -} -gcsHAL_PATCH_MCFE_SEMAPHORE; - -/* - * Patch timestamp of given video memory node (gcvHAL_PATCH_VIDMEM_TIMESTAMP). - * Pure software-wise, not command relevant. - */ -typedef struct _gcsHAL_PATCH_VIDMEM_TIMESTAMP -{ - /* Handle of a video memory node. */ - gctUINT32 handle; - - gctUINT32 flag; -} -gcsHAL_PATCH_VIDMEM_TIMESTAMP; - - -/* - gcvFEATURE_DATABASE_DATE_MASK - - Mask used to control which bits of chip date will be used to - query feature database, ignore release date for fpga and emulator. -*/ -#if (gcdFPGA_BUILD || defined(EMULATOR)) -# define gcvFEATURE_DATABASE_DATE_MASK (0U) -#else -# define gcvFEATURE_DATABASE_DATE_MASK (~0U) -#endif - -#if defined(__GNUC__) -#if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) -#define gcdENDIAN_BIG 1 -#else -#define gcdENDIAN_BIG 0 -#endif -#else -#define gcdENDIAN_BIG 0 -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* __gc_hal_types_h_ */ diff --git a/drivers/amlogic/npu/kernel/inc/gc_hal_version.h b/drivers/amlogic/npu/kernel/inc/gc_hal_version.h index 3635cd9..869fb97 100644 --- a/drivers/amlogic/npu/kernel/inc/gc_hal_version.h +++ b/drivers/amlogic/npu/kernel/inc/gc_hal_version.h @@ -60,11 +60,11 @@ #define gcvVERSION_MINOR 4 -#define gcvVERSION_PATCH 2 +#define gcvVERSION_PATCH 3 -#define gcvVERSION_BUILD 258160 +#define gcvVERSION_BUILD 279124 -#define gcvVERSION_STRING "6.4.2.1.258160" +#define gcvVERSION_STRING "6.4.3.279124CB" #endif /* __gc_hal_version_h_ */ diff --git a/drivers/amlogic/npu/kernel/inc/gc_hal_vg.h b/drivers/amlogic/npu/kernel/inc/gc_hal_vg.h index dcc10a5..667759d 100644 --- a/drivers/amlogic/npu/kernel/inc/gc_hal_vg.h +++ b/drivers/amlogic/npu/kernel/inc/gc_hal_vg.h @@ -61,10 +61,10 @@ extern "C" { #endif -#include "shared/gc_hal_types.h" +#include "gc_hal_types.h" #include "gc_hal_enum.h" #include "gc_hal_base.h" -#include "shared/gc_hal_vg.h" +#include "shared/gc_hal_vg_shared.h" #ifdef __cplusplus diff --git a/drivers/amlogic/npu/kernel/inc/shared/gc_hal_base.h b/drivers/amlogic/npu/kernel/inc/shared/gc_hal_base_shared.h similarity index 100% rename from drivers/amlogic/npu/kernel/inc/shared/gc_hal_base.h rename to drivers/amlogic/npu/kernel/inc/shared/gc_hal_base_shared.h diff --git a/drivers/amlogic/npu/kernel/inc/shared/gc_hal_driver.h b/drivers/amlogic/npu/kernel/inc/shared/gc_hal_driver_shared.h similarity index 87% rename from drivers/amlogic/npu/kernel/inc/shared/gc_hal_driver.h rename to drivers/amlogic/npu/kernel/inc/shared/gc_hal_driver_shared.h index d539507..462895f 100644 --- a/drivers/amlogic/npu/kernel/inc/shared/gc_hal_driver.h +++ b/drivers/amlogic/npu/kernel/inc/shared/gc_hal_driver_shared.h @@ -53,8 +53,8 @@ *****************************************************************************/ -#ifndef __gc_hal_driver_h_ -#define __gc_hal_driver_h_ +#ifndef __gc_hal_driver_shared_h_ +#define __gc_hal_driver_shared_h_ #include "gc_hal_enum.h" #include "gc_hal_types.h" @@ -65,7 +65,14 @@ extern "C" { #endif /* The number of context buffers per user. */ -#define gcdCONTEXT_BUFFER_NUM 2 +#if gcdCAPTURE_ONLY_MODE +#define gcdCONTEXT_BUFFER_COUNT 1 +#else +#define gcdCONTEXT_BUFFER_COUNT 2 +#endif + +#define gcdRENDER_FENCE_LENGTH (6 * gcmSIZEOF(gctUINT32)) +#define gcdBLT_FENCE_LENGTH (10 * gcmSIZEOF(gctUINT32)) /******************************************************************************\ ******************************* I/O Control Codes ****************************** @@ -73,7 +80,7 @@ extern "C" { #define gcvHAL_CLASS "galcore" #define IOCTL_GCHAL_INTERFACE 30000 -#define IOCTL_GCHAL_KERNEL_INTERFACE 30001 +#define IOCTL_GCHAL_PROFILER_INTERFACE 30001 #define IOCTL_GCHAL_TERMINATE 30002 /******************************************************************************\ @@ -136,6 +143,11 @@ typedef struct _gcsHAL_QUERY_VIDEO_MEMORY OUT gctUINT32 contiguousPhysName; /* Size in bytes of contiguous memory.*/ OUT gctUINT64 contiguousSize; + + /* Physical memory address of exclusive memory. Just a name. */ + OUT gctUINT32 exclusivePhysName; + /* Size in bytes of exclusive memory.*/ + OUT gctUINT64 exclusiveSize; } gcsHAL_QUERY_VIDEO_MEMORY; @@ -254,6 +266,8 @@ typedef struct _gcsHAL_QUERY_CHIP_OPTIONS gceSECURE_MODE secureMode; gctBOOL enableNNTPParallel; gctUINT enableSwtilingPhase1; + + gctBOOL hasShader; } gcsHAL_QUERY_CHIP_OPTIONS; @@ -537,7 +551,7 @@ typedef struct _gcsHAL_ATTACH #if gcdCAPTURE_ONLY_MODE IN gctBOOL queryCapSize; - IN gctPOINTER contextLogical[gcdCONTEXT_BUFFER_NUM]; + IN gctPOINTER contextLogical[gcdCONTEXT_BUFFER_COUNT]; OUT gctSIZE_T captureSize; #endif } @@ -557,6 +571,14 @@ typedef struct _gcsHAL_EVENT_COMMIT { /* Event queue in gcsQUEUE. */ IN gctUINT64 queue; + +#if gcdENABLE_SW_PREEMPTION + /* Priority ID. */ + IN gctUINT32 priorityID; + + /* Does it require top priority? */ + IN gctBOOL topPriority; +#endif } gcsHAL_EVENT_COMMIT; @@ -591,7 +613,7 @@ typedef struct _gcsHAL_COMMAND_LOCATION /* struct _gcsHAL_COMMAND_LOCATION * next; */ gctUINT64 next; #if gcdCAPTURE_ONLY_MODE - gctPOINTER contextLogical[gcdCONTEXT_BUFFER_NUM]; + gctPOINTER contextLogical[gcdCONTEXT_BUFFER_COUNT]; #endif } gcsHAL_COMMAND_LOCATION; @@ -614,8 +636,25 @@ typedef struct _gcsHAL_SUBCOMMIT /* struct _gcsHAL_SUBCOMMIT * next; */ gctUINT64 next; + +#if gcdENABLE_SW_PREEMPTION + /* Process ID. */ + gctUINT32 pid; + + /* Engine type. */ + gceENGINE engine; + + /* Is it multi-core and shared mode?. */ + gctBOOL shared; + + /* Priority ID. */ + gctUINT32 priorityID; + + /* Does it require top priority. */ + gctBOOL topPriority; +#endif } -gcsHAL_SUBCOMMIT; +gcsHAL_SUBCOMMIT, * gcsHAL_SUBCOMMIT_PTR; /* gcvHAL_COMMIT */ typedef struct _gcsHAL_COMMIT @@ -628,6 +667,11 @@ typedef struct _gcsHAL_COMMIT /* Commit stamp of this commit. */ OUT gctUINT64 commitStamp; + +#if gcdENABLE_SW_PREEMPTION + /* If user need to merge the delta. */ + gctBOOL needMerge; +#endif } gcsHAL_COMMIT; @@ -635,6 +679,11 @@ gcsHAL_COMMIT; typedef struct _gcsHAL_COMMIT_DONE { IN gctUINT64 context; + +#if gcdENABLE_SW_PREEMPTION + /* Priority ID. */ + IN gctUINT32 priorityID; +#endif } gcsHAL_COMMIT_DONE; @@ -1085,6 +1134,12 @@ typedef struct _gcsHAL_DEC300_FLUSH_WAIT DEC300FlushWait; #endif +typedef struct _gcsHAL_SYNC_VIDEO_MEMORY +{ + IN gctUINT64 node; + IN gceSYNC_VIDEO_MEMORY_REASON reason; +} +gcsHAL_SYNC_VIDEO_MEMORY; typedef struct _gcsHAL_INTERFACE { @@ -1157,15 +1212,6 @@ typedef struct _gcsHAL_INTERFACE gcsHAL_READ_REGISTER_EX ReadRegisterDataEx; gcsHAL_WRITE_REGISTER_EX WriteRegisterDataEx; -#if VIVANTE_PROFILER - gcsHAL_GET_PROFILE_SETTING GetProfileSetting; - gcsHAL_SET_PROFILE_SETTING SetProfileSetting; - gcsHAL_READ_PROFILER_REGISTER_SETTING SetProfilerRegisterClear; - gcsHAL_READ_ALL_PROFILE_REGISTERS_PART1 RegisterProfileData_part1; - gcsHAL_READ_ALL_PROFILE_REGISTERS_PART2 RegisterProfileData_part2; - gcsHAL_PROFILE_REGISTERS_2D RegisterProfileData2D; -#endif - gcsHAL_SET_POWER_MANAGEMENT SetPowerManagement; gcsHAL_QUERY_POWER_MANAGEMENT QueryPowerManagement; gcsHAL_CONFIG_POWER_MANAGEMENT ConfigPowerManagement; @@ -1210,16 +1256,129 @@ typedef struct _gcsHAL_INTERFACE gcsHAL_DEC300_FLUSH DEC300Flush; gcsHAL_DEC300_FLUSH_WAIT DEC300FlushWait; #endif + gcsHAL_SYNC_VIDEO_MEMORY SyncVideoMemory; } u; } gcsHAL_INTERFACE; +#if VIVANTE_PROFILER +typedef struct _gcsHAL_PROFILER_INTERFACE +{ + /* Command code. */ + gceHAL_COMMAND_CODES command; + + /* Hardware type. */ + gceHARDWARE_TYPE hardwareType; + + /* Core index for current hardware type. */ + gctUINT32 coreIndex; + + /* Status value. */ + gceSTATUS status; + + /* Engine */ + gceENGINE engine; + + /* Ignore information from TSL when doing IO control */ + gctBOOL ignoreTLS; + + /* The mutext already acquired */ + IN gctBOOL commitMutex; + + /* Union of command structures. */ + union profiler_u + { + gcsHAL_GET_PROFILE_SETTING GetProfileSetting; + gcsHAL_SET_PROFILE_SETTING SetProfileSetting; + gcsHAL_READ_PROFILER_REGISTER_SETTING SetProfilerRegisterClear; + gcsHAL_READ_ALL_PROFILE_REGISTERS_PART1 RegisterProfileData_part1; + gcsHAL_READ_ALL_PROFILE_REGISTERS_PART2 RegisterProfileData_part2; + gcsHAL_PROFILE_REGISTERS_2D RegisterProfileData2D; + } + u; +} +gcsHAL_PROFILER_INTERFACE; +#endif + +/* State delta record. */ +typedef struct _gcsSTATE_DELTA_RECORD * gcsSTATE_DELTA_RECORD_PTR; +typedef struct _gcsSTATE_DELTA_RECORD +{ + /* State address. */ + gctUINT address; + + /* State mask. */ + gctUINT32 mask; + + /* State data. */ + gctUINT32 data; +} +gcsSTATE_DELTA_RECORD; + +/* State delta. */ +typedef struct _gcsSTATE_DELTA +{ + /* For debugging: the number of delta in the order of creation. */ + gctUINT num; + + /* Main state delta ID. Every time state delta structure gets reinitialized, + main ID is incremented. If main state ID overflows, all map entry IDs get + reinitialized to make sure there is no potential erroneous match after + the overflow.*/ + gctUINT id; + + /* The number of contexts pending modification by the delta. */ + gctINT refCount; + + /* Vertex element count for the delta buffer. */ + gctUINT elementCount; + + /* Number of states currently stored in the record array. */ + gctUINT recordCount; + + /* Record array; holds all modified states in gcsSTATE_DELTA_RECORD. */ + gctUINT64 recordArray; + + /* Map entry ID is used for map entry validation. If map entry ID does not + match the main state delta ID, the entry and the corresponding state are + considered not in use. */ + gctUINT64 mapEntryID; + gctUINT mapEntryIDSize; + + /* If the map entry ID matches the main state delta ID, index points to + the state record in the record array. */ + gctUINT64 mapEntryIndex; + + /* Previous and next state deltas in gcsSTATE_DELTA. */ + gctUINT64 prev; + gctUINT64 next; +} +gcsSTATE_DELTA; + +typedef struct _gcsQUEUE +{ + /* Pointer to next gcsQUEUE structure in gcsQUEUE. */ + gctUINT64 next; + + /* Event information. */ + gcsHAL_INTERFACE iface; +} +gcsQUEUE; + +/* A record chunk include multiple records to save allocation. */ +typedef struct _gcsQUEUE_CHUNK +{ + struct _gcsQUEUE_CHUNK * next; + + gcsQUEUE record[16]; +} +gcsQUEUE_CHUNK; #ifdef __cplusplus } #endif -#endif /* __gc_hal_driver_h_ */ +#endif /* __gc_hal_driver_shared_h_ */ diff --git a/drivers/amlogic/npu/kernel/inc/shared/gc_hal_driver_vg.h b/drivers/amlogic/npu/kernel/inc/shared/gc_hal_driver_vg_shared.h similarity index 98% rename from drivers/amlogic/npu/kernel/inc/shared/gc_hal_driver_vg.h rename to drivers/amlogic/npu/kernel/inc/shared/gc_hal_driver_vg_shared.h index b4e0bda..3c7472c 100644 --- a/drivers/amlogic/npu/kernel/inc/shared/gc_hal_driver_vg.h +++ b/drivers/amlogic/npu/kernel/inc/shared/gc_hal_driver_vg_shared.h @@ -53,8 +53,8 @@ *****************************************************************************/ -#ifndef __gc_hal_driver_vg_h_ -#define __gc_hal_driver_vg_h_ +#ifndef __gc_hal_driver_vg_shared_h_ +#define __gc_hal_driver_vg_shared_h_ #include "gc_hal_types.h" @@ -259,6 +259,6 @@ gcsTASK_FREE_CONTIGUOUS_MEMORY; } #endif -#endif /* __gc_hal_driver_h_ */ +#endif /* __gc_hal_driver_shared_h_ */ diff --git a/drivers/amlogic/npu/kernel/inc/shared/gc_hal_enum.h b/drivers/amlogic/npu/kernel/inc/shared/gc_hal_enum_shared.h similarity index 96% rename from drivers/amlogic/npu/kernel/inc/shared/gc_hal_enum.h rename to drivers/amlogic/npu/kernel/inc/shared/gc_hal_enum_shared.h index ab244e8..3d3fd16 100644 --- a/drivers/amlogic/npu/kernel/inc/shared/gc_hal_enum.h +++ b/drivers/amlogic/npu/kernel/inc/shared/gc_hal_enum_shared.h @@ -571,6 +571,7 @@ typedef enum _gceFEATURE gcvFEATURE_DR_JD_DIFF_CONDITION_FOR_CACHELINE_MODE_PRE_FIX, gcvFEATURE_USC_BOTTLENECK_FIX, gcvFEATURE_OCB_REMAP_PHYSICAL_ADDRESS, + gcFEATURE_BIT_NN_HW_LIMITATION_NATIVE_KER_1x2_2x1, gcvFEATURE_NN_SLICE_PADDING_TO_64BYTE_ALIGN, gcvFEATURE_NN_DW_1x1_CONV_MERGE, gcvFEATURE_TP_REORDER_LAYER_SUSPEND_FIX, @@ -651,15 +652,53 @@ typedef enum _gceFEATURE gcvFEATURE_AI_GPU, gcvFEATURE_NN_FAST_FIRST_PIXEL_POOLING, gcvFEATURE_NN_FLOAT_POST_MULT, + gcvFEATURE_NN_ASYMMETRIC_INT8, gcvFEATURE_FORMAT_YUV_I010, /*support YUVI010 & P010_LSB format*/ gcFEATURE_BIT_NN_COMPRESSION_BYPASSS, - gcFEATURE_BIT_BFLOAT_KERNEL_COMPRESSION_ZERO_SKIP_FIX, + gcFEATURE_BIT_BFLOAT_COEF_COMPRESSION_ZERO_COEFBIT14_INVERSE, gcFEATURE_BIT_TP_KERNEL_1BYTE_ALGIN, gcFEATURE_PREPROCESS_IMG_BUF_640BYTE_LIMIT, - + gcFEATURE_BIT_TPLITE_BFLOAT16, gcvFEATURE_VIP_HW_FINAL_RELEASE, + gcvFEATURE_OUTPUT_CONVERT_UINT8_INT8_TO_UINT16_INT16_FIX, + gcvFEATURE_IMG_ADDR_NOT_WRAP_IF_OVER_OCB_ADDR_FIX, /* 2089 */ + gcFEATURE_BIT_V8_SINGLE_PORT_ACCUMULATION_BUFFER_RW_CONFICT_ZERO_SKIP_PERF_FIX, /* 2043 */ + gcFEATURE_BIT_BURST_COLLECT_DUMMY_DATA_WASTE_CYCLES_FIX, /* 2111 */ + gcFEATURE_BIT_TP_ACCESS_VIPSRAM_OT_IS_ONE_FIX, /* 2050 */ + + + gcFEATURE_BIT_USE_SINGLE_PORT_VIPSRAM, + gcFEATURE_VALUE_DDR_KERNEL_BURST_SIZE, + gcFEATURE_BIT_TILE_ACCESS_CAPABILITY, + gcFEATURE_BIT_FAST_DP3_PREPROCESSOR, + + gcvFEATURE_BIT_INIMG_NOT_64BYTE_ALIGN_CACHELINE_MODE_FIX, /* 2112 */ + gcFEATURE_BIT_DEPTHWISE_16BIT_FORMAT, + + gcvFEATURE_2D_TILESTATUS_ROTATION,/*Fix fastclear feature with rotation*/ + gcFEATURE_BIT_TP_FC_FLOAT_LAST_PIXEL_NEGATIVE_0_FIX, + gcvFEATURE_TS_FC_VULKAN_SUPPORT, + gcFEATURE_BIT_V8_ACCUMLATION_READ_OUT_HAS_BUBBLES_PERF_FIX, /* 2044 */ + gcFEATURE_BIT_MAX_TILE_SIZE, + gcvFEATURE_2D_TARGET_MAJOR_SUPER_TILE, /*target support supertile Y major*/ + gcFEATURE_BIT_INIMAGE_2DTILE_NOT_LESS_160PIXEL_FIX, + gcFEATURE_BIT_NN_IN_TILE_DATA_IS_ALL_PAD_FIX, /* 2131 */ + + /* TP reorder the int tile x should be less than 512 */ + gcFEATURE_TP_REORDER_INTILE_X_SIZE_512_FIX, + gcFEATURE_NN_WASET_COEF_READ_WRITE_BANDWIDTH_128BYTE_VIPSRAM_IN_FULL_PATIAL_CACHE_MODE, + gcFEATURE_BIT_BFP_COEF_AUTO_PAD_INCOMPLETE_ZERO_IN_KZ_PLANE, + gcvFEATURE_NN_FLOAT32_IO, + gcvFEATURE_TP_FLOAT32_IO, + + /* Q channel support. */ + gcvFEATURE_Q_CHANNEL_SUPPORT, + + /* MMU descriptor new refinement. */ + gcvFEATURE_MMU_PAGE_DESCRIPTOR, + /* Insert features above this comment only. */ gcvFEATURE_COUNT /* Not a feature. */ } @@ -1216,6 +1255,12 @@ typedef enum _gceSURF_FORMAT gcvSURF_B8, gcvSURF_G32F, gcvSURF_B32F, + + /* Intensity formats */ + gcvSURF_I4 = 2000, + gcvSURF_I8, + gcvSURF_I12, + gcvSURF_I16, } gceSURF_FORMAT; @@ -1512,6 +1557,7 @@ typedef enum _gceSTATUS gcvSTATUS_DEVICE = -27, gcvSTATUS_NOT_MULTI_PIPE_ALIGNED = -28, gcvSTATUS_OUT_OF_SAMPLER = -29, + gcvSTATUS_PROBE_LATER = -30, /* Linker errors. */ gcvSTATUS_GLOBAL_TYPE_MISMATCH = -1000, @@ -1750,6 +1796,9 @@ typedef enum _gceHAL_COMMAND_CODES /* Destory MMU. */ gcvHAL_DESTROY_MMU, + + /* sync video memory for special memory pool */ + gcvHAL_SYNC_VIDEO_MEMORY, /*************** Reserved end ***************/ } gceHAL_COMMAND_CODES; @@ -1837,6 +1886,7 @@ typedef enum _gcePOOL gcvPOOL_USER, gcvPOOL_INTERNAL_SRAM, gcvPOOL_EXTERNAL_SRAM, + gcvPOOL_LOCAL_EXCLUSIVE, gcvPOOL_NUMBER_OF_POOLS } @@ -1869,6 +1919,14 @@ typedef enum _gceDUMP_BUFFER_TYPE } gceDUMP_BUFFER_TYPE; +typedef enum _gceSYNC_VIDEO_MEMORY_REASON +{ + gcvSYNC_REASON_NONE = 0, + gcvSYNC_REASON_BEFORE_READ, + gcvSYNC_REASON_AFTER_WRITE, +} +gceSYNC_VIDEO_MEMORY_REASON; + #ifdef __cplusplus } #endif diff --git a/drivers/amlogic/npu/kernel/inc/shared/gc_hal_profiler.h b/drivers/amlogic/npu/kernel/inc/shared/gc_hal_profiler_shared.h similarity index 69% rename from drivers/amlogic/npu/kernel/inc/shared/gc_hal_profiler.h rename to drivers/amlogic/npu/kernel/inc/shared/gc_hal_profiler_shared.h index 9db4c39..3531685 100644 --- a/drivers/amlogic/npu/kernel/inc/shared/gc_hal_profiler.h +++ b/drivers/amlogic/npu/kernel/inc/shared/gc_hal_profiler_shared.h @@ -271,6 +271,126 @@ typedef struct _gcsPROFILER_COUNTERS } gcsPROFILER_COUNTERS; +typedef enum _gceVIP_PROBE_COUNTER +{ + gcvVIP_PROBE_COUNTER_NEURAL_NET, + gcvVIP_PROBE_COUNTER_TENSOR_PROCESSOR, + gcvVIP_PROBE_COUNTER_COUNT +} +gceVIP_PROBE_COUNTER; + +/* Mask definations for overflow indicator of TP */ +typedef enum _gceTPCOUNTER_OVERFLOW +{ + gcvTPCOUNTER_LAYER_ID_OVERFLOW = (1 << 0), + gcvTPCOUNTER_TOTAL_BUSY_CYCLE_OVERFLOW = (1 << 1), + gcvTPCOUNTER_TOTAL_READ_BW_DDR_OVERFLOW = (1 << 2), + gcvTPCOUNTER_TOTAL_WRITE_BW_DDR_OVERFLOW = (1 << 3), + gcvTPCOUNTER_TOTAL_READ_BW_SRAM_OVERFLOW = (1 << 4), + gcvTPCOUNTER_TOTAL_WRITE_BW_SRAM_OVERFLOW = (1 << 5), + gcvTPCOUNTER_TOTAL_READ_BW_OCB_OVERFLOW = (1 << 6), + gcvTPCOUNTER_TOTAL_WRITE_BW_OCB_OVERFLOW = (1 << 7), + gcvTPCOUNTER_FC_PIX_CNT_OVERFLOW = (1 << 8), + gcvTPCOUNTER_FC_ZERO_SKIP_OVERFLOW = (1 << 9), + gcvTPCOUNTER_FC_COEF_CNT_OVERFLOW = (1 << 10), + gcvTPCOUNTER_FC_COEF_ZERO_CNT_OVERFLOW = (1 << 11), + gcvTPCOUNTER_TOTAL_IDLE_CYCLE_CORE0_OVERFLOW = (1 << 0), + gcvTPCOUNTER_TOTAL_IDLE_CYCLE_CORE1_OVERFLOW = (1 << 1), + gcvTPCOUNTER_TOTAL_IDLE_CYCLE_CORE2_OVERFLOW = (1 << 2), + gcvTPCOUNTER_TOTAL_IDLE_CYCLE_CORE3_OVERFLOW = (1 << 3), +} +_gceTPCOUNTER_OVERFLOW; + +/* Mask definations for overflow indicator of NN */ +typedef enum _gceNNCOUNTER_OVERFLOW +{ + gcvNNCOUNTER_TOTAL_BUSY_CYCLE_OVERFLOW = (1 << 0), + gcvNNCOUNTER_TOTAL_READ_CYCLE_DDR_OVERFLOW = (1 << 2), + gcvNNCOUNTER_TOTAL_READ_BW_DDR_OVERFLOW = (1 << 3), + gcvNNCOUNTER_TOTAL_WRITE_CYCLE_DDR_OVERFLOW = (1 << 4), + gcvNNCOUNTER_TOTAL_WRITE_BW_DDR_OVERFLOW = (1 << 5), + gcvNNCOUNTER_TOTAL_READ_SYCLE_SRAM_OVERFLOW = (1 << 6), + gcvNNCOUNTER_TOTAL_WRITE_CYCLE_SRAM_OVERFLOW = (1 << 7), + gcvNNCOUNTER_TOTAL_MAC_CYCLE_OVERFLOW = (1 << 8), + gcvNNCOUNTER_TOTAL_MAC_COUNT_OVERFLOW = (1 << 9), + gcvNNCOUNTER_ZERO_COEF_SKIP_COUNT_OVERFLOW = (1 << 10), + gcvNNCOUNTER_NON_ZERO_COEF_COUNT_OVERFLOW = (1 << 11), +} +_gceNNCOUNTER_OVERFLOW; + +#define MODULE_NN_RESERVED_COUNTER_NUM 0x9 +typedef struct _gcsPROFILER_VIP_PROBE_COUNTERS +{ + /* NN */ + gctUINT32 nn_layer_id; + gctUINT32 nn_layer_id_overflow; + gctUINT32 nn_instr_info; + gctUINT32 nn_total_busy_cycle; + gctUINT32 nn_total_busy_cycle_overflow; + gctUINT32 nn_total_read_cycle_ddr; + gctUINT32 nn_total_read_cycle_ddr_overflow; + gctUINT32 nn_total_read_valid_bandwidth_ddr; + gctUINT32 nn_total_read_valid_bandwidth_ddr_overflow; + gctUINT32 nn_total_write_cycle_ddr; + gctUINT32 nn_total_write_cycle_ddr_overflow; + gctUINT32 nn_total_write_valid_bandwidth_ddr; + gctUINT32 nn_total_write_valid_bandwidth_ddr_overflow; + gctUINT32 nn_total_read_cycle_sram; + gctUINT32 nn_total_read_cycle_sram_overflow; + gctUINT32 nn_total_write_cycle_sram; + gctUINT32 nn_total_write_cycle_sram_overflow; + gctUINT32 nn_total_mac_cycle; + gctUINT32 nn_total_mac_cycle_overflow; + gctUINT32 nn_total_mac_count; + gctUINT32 nn_total_mac_count_overflow; + gctUINT32 nn_zero_coef_skip_count; + gctUINT32 nn_zero_coef_skip_count_overflow; + gctUINT32 nn_non_zero_coef_count; + gctUINT32 nn_non_zero_coef_count_overflow; + + gctUINT32 nn_reserved_counter[4 * MODULE_NN_RESERVED_COUNTER_NUM]; + gctUINT32 nn_total_idle_cycle_core_overflow; + gctUINT32 nn_total_idle_cycle_core[32]; + + /* TP */ + gctUINT32 tp_layer_id; + gctUINT32 tp_layer_id_overflow; + gctUINT32 tp_total_busy_cycle; + gctUINT32 tp_total_busy_cycle_overflow; + + gctUINT32 tp_total_read_bandwidth_cache; + gctUINT32 tp_total_read_bandwidth_cache_overflow; + gctUINT32 tp_total_write_bandwidth_cache; + gctUINT32 tp_total_write_bandwidth_cache_overflow; + + gctUINT32 tp_total_read_bandwidth_sram; + gctUINT32 tp_total_read_bandwidth_sram_overflow; + gctUINT32 tp_total_write_bandwidth_sram; + gctUINT32 tp_total_write_bandwidth_sram_overflow; + + + gctUINT32 tp_total_read_bandwidth_ocb; + gctUINT32 tp_total_read_bandwidth_ocb_overflow; + gctUINT32 tp_total_write_bandwidth_ocb; + gctUINT32 tp_total_write_bandwidth_ocb_overflow; + + gctUINT32 tp_fc_pix_count; + gctUINT32 tp_fc_zero_skip_count; + gctUINT32 tp_fc_pix_count_overflow; + gctUINT32 tp_fc_zero_skip_count_overflow; + + gctUINT32 tp_fc_coef_count; + gctUINT32 tp_fc_coef_zero_count; + gctUINT32 tp_fc_coef_count_overflow; + gctUINT32 tp_fc_coef_zero_count_overflow; + + gctUINT32 tp_total_idle_cycle_core[16]; + gctUINT32 tp_total_idle_cycle_core_overflows[16]; + + /* VIP SH */ +} +gcsPROFILER_VIP_PROBE_COUNTERS; + #ifdef __cplusplus } #endif diff --git a/drivers/amlogic/npu/kernel/inc/shared/gc_hal_types.h b/drivers/amlogic/npu/kernel/inc/shared/gc_hal_types_shared.h similarity index 99% rename from drivers/amlogic/npu/kernel/inc/shared/gc_hal_types.h rename to drivers/amlogic/npu/kernel/inc/shared/gc_hal_types_shared.h index c8038ad..bc4a457 100644 --- a/drivers/amlogic/npu/kernel/inc/shared/gc_hal_types.h +++ b/drivers/amlogic/npu/kernel/inc/shared/gc_hal_types_shared.h @@ -53,8 +53,8 @@ *****************************************************************************/ -#ifndef __gc_hal_types_h_ -#define __gc_hal_types_h_ +#ifndef __gc_hal_types_shared_h_ +#define __gc_hal_types_shared_h_ #include "gc_hal_version.h" #include "gc_hal_options.h" @@ -399,7 +399,8 @@ gcs2D_PROFILE; #define gcmIS_ERROR(status) (status < 0) #define gcmNO_ERROR(status) (status >= 0) #define gcmIS_SUCCESS(status) (status == gcvSTATUS_OK) - +#define gcmERROR2PTR(err) ((gctPOINTER)(err)) +#define gcmPTR2ERROR(ptr) ((gctINT64)(ptr)) /******************************************************************************\ ********************************* Field Macros ********************************* \******************************************************************************/ @@ -982,6 +983,6 @@ gcsHAL_PATCH_VIDMEM_TIMESTAMP; } #endif -#endif /* __gc_hal_types_h_ */ +#endif /* __gc_hal_types_shared_h_ */ diff --git a/drivers/amlogic/npu/kernel/inc/shared/gc_hal_vg.h b/drivers/amlogic/npu/kernel/inc/shared/gc_hal_vg_shared.h similarity index 100% rename from drivers/amlogic/npu/kernel/inc/shared/gc_hal_vg.h rename to drivers/amlogic/npu/kernel/inc/shared/gc_hal_vg_shared.h diff --git a/drivers/amlogic/npu/os/libGAL.def.mak b/drivers/amlogic/npu/os/libGAL.def.mak old mode 100644 new mode 100755 index 24f1ba1..a776c94 --- a/drivers/amlogic/npu/os/libGAL.def.mak +++ b/drivers/amlogic/npu/os/libGAL.def.mak @@ -227,6 +227,7 @@ EXPORTS gcoHAL_DumpFrameDB gcoHAL_InitGPUProfile gcoHAL_DumpGPUProfile + gcoHAL_InitCoreIndexByType !IF "$(VIVANTE_ENABLE_3D)" == "1" @@ -271,6 +272,8 @@ EXPORTS gcoHAL_ReleaseVideoMemory gcoHAL_ScheduleSignal gcoHAL_GetPLS + gcoHAL_SetPriority + gcoHAL_GetPriority !IF "$(VIVANTE_ENABLE_3D)" == "1" gcoHAL_QueryShaderCaps @@ -383,6 +386,7 @@ EXPORTS gcoSURF_WaitFence gcoSURF_AlignResolveRect gcoSURF_DrawBlit + gcoSURF_DrawBlitDepth gcsSURF_NODE_Construct gcsSURF_NODE_Destroy gcsSURF_NODE_Lock @@ -787,8 +791,8 @@ EXPORTS gcoVX_QueryDeviceCount gcoVX_QueryCoreCount gcoVX_QueryMultiCore - gcoVX_CaptureInitState gcoVX_SetHardwareType + gcoVX_MultiGPUSync !IF "$(VSIMULATOR_DEBUG)" == "1" gcoOS_UpdateSimulatorCallback diff --git a/drivers/amlogic/npu/os/linux/kernel/allocator/default/gc_hal_kernel_allocator_dma.c b/drivers/amlogic/npu/os/linux/kernel/allocator/default/gc_hal_kernel_allocator_dma.c index 5fcf102..ea2c4bd 100644 --- a/drivers/amlogic/npu/os/linux/kernel/allocator/default/gc_hal_kernel_allocator_dma.c +++ b/drivers/amlogic/npu/os/linux/kernel/allocator/default/gc_hal_kernel_allocator_dma.c @@ -165,7 +165,7 @@ _DmaAlloc( #endif mdlPriv->kvaddr -#if defined CONFIG_MIPS || defined CONFIG_CPU_CSKYV2 || defined CONFIG_PPC || defined CONFIG_ARM64 +#if defined CONFIG_MIPS || defined CONFIG_CPU_CSKYV2 || defined CONFIG_PPC || defined CONFIG_ARM64 || !gcdENABLE_BUFFERABLE_VIDEO_MEMORY = dma_alloc_coherent(galcore_device, NumPages * PAGE_SIZE, &mdlPriv->dmaHandle, gfp); #else #if LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0) @@ -290,7 +290,7 @@ _DmaFree( struct mdl_dma_priv *mdlPriv=(struct mdl_dma_priv *)Mdl->priv; gcsDMA_PRIV_PTR allocatorPriv = (gcsDMA_PRIV_PTR)Allocator->privateData; -#if defined CONFIG_MIPS || defined CONFIG_CPU_CSKYV2 || defined CONFIG_PPC || defined CONFIG_ARM64 +#if defined CONFIG_MIPS || defined CONFIG_CPU_CSKYV2 || defined CONFIG_PPC || defined CONFIG_ARM64 || !gcdENABLE_BUFFERABLE_VIDEO_MEMORY dma_free_coherent(galcore_device, Mdl->numPages * PAGE_SIZE, mdlPriv->kvaddr, mdlPriv->dmaHandle); #else #if LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0) @@ -322,7 +322,7 @@ _DmaMmap( gcmkHEADER_ARG("Allocator=%p Mdl=%p vma=%p", Allocator, Mdl, vma); gcmkASSERT(skipPages + numPages <= Mdl->numPages); - +#if gcdENABLE_BUFFERABLE_VIDEO_MEMORY /* map kernel memory to user space.. */ #if defined CONFIG_MIPS || defined CONFIG_CPU_CSKYV2 || defined CONFIG_PPC if (remap_pfn_range( @@ -348,6 +348,14 @@ _DmaMmap( numPages << PAGE_SHIFT) < 0) #endif #endif +#else + /* map kernel memory to user space.. */ + if (dma_mmap_coherent(galcore_device, + vma, + (gctINT8_PTR)mdlPriv->kvaddr + (skipPages << PAGE_SHIFT), + mdlPriv->dmaHandle + (skipPages << PAGE_SHIFT), + numPages << PAGE_SHIFT) < 0) +#endif { gcmkTRACE_ZONE( gcvLEVEL_WARNING, gcvZONE_OS, diff --git a/drivers/amlogic/npu/os/linux/kernel/allocator/default/gc_hal_kernel_allocator_gfp.c b/drivers/amlogic/npu/os/linux/kernel/allocator/default/gc_hal_kernel_allocator_gfp.c index beb7cd3..c441b22 100644 --- a/drivers/amlogic/npu/os/linux/kernel/allocator/default/gc_hal_kernel_allocator_gfp.c +++ b/drivers/amlogic/npu/os/linux/kernel/allocator/default/gc_hal_kernel_allocator_gfp.c @@ -276,7 +276,7 @@ _NonContiguousAlloc( pages[i] = p; } - MdlPriv->contiguousPages = (struct page *)pages; + MdlPriv->nonContiguousPages = pages; gcmkFOOTER_ARG("pages=0x%X", pages); return gcvSTATUS_OK; @@ -413,7 +413,7 @@ _NonContiguous1MPagesAlloc( gcmkONERROR(gcvSTATUS_OUT_OF_MEMORY); } } - MdlPriv->contiguousPages = (struct page *)pages; + MdlPriv->nonContiguousPages = pages; for (i = 0; i < numPages1M; i++) { @@ -567,7 +567,7 @@ _GFPAlloc( mdlPriv->dma_addr = dma_map_page(galcore_device, mdlPriv->contiguousPages, 0, NumPages * PAGE_SIZE, - DMA_FROM_DEVICE); + DMA_BIDIRECTIONAL); if (dma_mapping_error(galcore_device, mdlPriv->dma_addr)) { @@ -634,7 +634,7 @@ _GFPAlloc( } result = dma_map_sg(galcore_device, - mdlPriv->sgt.sgl, mdlPriv->sgt.nents, DMA_FROM_DEVICE); + mdlPriv->sgt.sgl, mdlPriv->sgt.nents, DMA_BIDIRECTIONAL); if (result != mdlPriv->sgt.nents) { @@ -739,7 +739,7 @@ _GFPGetSGT( gcmkASSERT(Offset + Bytes <= Mdl->numPages << PAGE_SHIFT); - if (Mdl->contiguous) + if (mdlPriv->contiguous) { pages = tmpPages = kmalloc(sizeof(struct page*) * numPages, GFP_KERNEL | gcdNOWARN); if (!pages) @@ -800,7 +800,7 @@ _GFPFree( int low = 0; int high = 0; - if (Mdl->contiguous) + if (mdlPriv->contiguous) { dma_unmap_page(galcore_device, mdlPriv->dma_addr, Mdl->numPages << PAGE_SHIFT, DMA_FROM_DEVICE); @@ -820,7 +820,7 @@ _GFPFree( for (i = 0; i < Mdl->numPages; i++) { - if (Mdl->contiguous) + if (mdlPriv->contiguous) { page = nth_page(mdlPriv->contiguousPages, i); } @@ -844,7 +844,7 @@ _GFPFree( atomic_sub(low, &priv->low); atomic_sub(high, &priv->high); - if (Mdl->contiguous) + if (mdlPriv->contiguous) { #if defined(CONFIG_X86) if (!PageHighMem(mdlPriv->contiguousPages)) @@ -1124,7 +1124,7 @@ _GFPMapKernel( numPages = ((Offset & ~PAGE_MASK) + Bytes + (PAGE_SIZE - 1)) >> PAGE_SHIFT; - if (Mdl->contiguous) + if (mdlPriv->contiguous) { gctSIZE_T i; @@ -1287,7 +1287,7 @@ _GFPPhysical( gctUINT32 offsetInPage = Offset & ~PAGE_MASK; gctUINT32 index = Offset / PAGE_SIZE; - if (Mdl->contiguous) + if (mdlPriv->contiguous) { *Physical = page_to_phys(nth_page(mdlPriv->contiguousPages, index)); } diff --git a/drivers/amlogic/npu/os/linux/kernel/allocator/default/gc_hal_kernel_allocator_reserved_mem.c b/drivers/amlogic/npu/os/linux/kernel/allocator/default/gc_hal_kernel_allocator_reserved_mem.c index a2d9558..14386f4 100644 --- a/drivers/amlogic/npu/os/linux/kernel/allocator/default/gc_hal_kernel_allocator_reserved_mem.c +++ b/drivers/amlogic/npu/os/linux/kernel/allocator/default/gc_hal_kernel_allocator_reserved_mem.c @@ -81,6 +81,8 @@ struct reserved_mem /* Link together. */ struct list_head link; + /* the mdl is root or not */ + gctBOOL root; }; /* allocator info. */ @@ -182,34 +184,34 @@ reserved_mem_attach( res->offset_in_page = Desc->reservedMem.start & (PAGE_SIZE - 1); strncpy(res->name, Desc->reservedMem.name, sizeof(res->name)-1); res->release = 0; + res->root = Desc->reservedMem.root; - if (!Desc->reservedMem.requested) + /* the region requierd is handed by root MDL */ + if (Desc->reservedMem.root) { - region = request_mem_region(res->start, res->size, res->name); - - if (!region) + if (!Desc->reservedMem.requested) { - printk("request mem %s(0x%lx - 0x%lx) failed\n", - res->name, res->start, res->start + res->size - 1); + region = request_mem_region(res->start, res->size, res->name); + + if (!region) + { + printk("request mem %s(0x%lx - 0x%lx) failed\n", + res->name, res->start, res->start + res->size - 1); + + kfree(res); + return gcvSTATUS_OUT_OF_RESOURCES; + } - kfree(res); - return gcvSTATUS_OUT_OF_RESOURCES; + res->release = 1; } - res->release = 1; + mutex_lock(&alloc->lock); + list_add(&res->link, &alloc->region); + mutex_unlock(&alloc->lock); } - mutex_lock(&alloc->lock); - list_add(&res->link, &alloc->region); - mutex_unlock(&alloc->lock); - Mdl->priv = res; - if ((res->start + res->size) < 0xFFFFFFFF) - { - Allocator->capability |= gcvALLOC_FLAG_4GB_ADDR; - } - return gcvSTATUS_OK; } @@ -222,14 +224,17 @@ reserved_mem_detach( struct reserved_mem_alloc *alloc = Allocator->privateData; struct reserved_mem *res = Mdl->priv; - /* unlink from region list. */ - mutex_lock(&alloc->lock); - list_del_init(&res->link); - mutex_unlock(&alloc->lock); - - if (res->release) + if (res->root) { - release_mem_region(res->start, res->size); + /* unlink from region list. */ + mutex_lock(&alloc->lock); + list_del_init(&res->link); + mutex_unlock(&alloc->lock); + + if (res->release) + { + release_mem_region(res->start, res->size); + } } kfree(res); @@ -251,26 +256,39 @@ reserved_mem_mmap( gcmkHEADER_ARG("Allocator=%p Mdl=%p vma=%p", Allocator, Mdl, vma); - gcmkASSERT(skipPages + numPages <= Mdl->numPages); + if (Mdl->cpuAccessible) + { + gcmkASSERT(skipPages + numPages <= Mdl->numPages); - pfn = (res->start >> PAGE_SHIFT) + skipPages; + pfn = (res->start >> PAGE_SHIFT) + skipPages; - /* Make this mapping non-cached. */ - vma->vm_flags |= gcdVM_FLAGS; - vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot); + /* Make this mapping non-cached. */ + vma->vm_flags |= gcdVM_FLAGS; - if (remap_pfn_range(vma, vma->vm_start, - pfn, numPages << PAGE_SHIFT, vma->vm_page_prot) < 0) - { - gcmkTRACE( - gcvLEVEL_ERROR, - "%s(%d): remap_pfn_range error.", - __FUNCTION__, __LINE__ - ); +#if gcdENABLE_BUFFERABLE_VIDEO_MEMORY + vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot); +#else + vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); +#endif - status = gcvSTATUS_OUT_OF_MEMORY; + if (remap_pfn_range(vma, vma->vm_start, + pfn, numPages << PAGE_SHIFT, vma->vm_page_prot) < 0) + { + gcmkTRACE( + gcvLEVEL_ERROR, + "%s(%d): remap_pfn_range error.", + __FUNCTION__, __LINE__ + ); + + status = gcvSTATUS_OUT_OF_MEMORY; + } + } + else + { + status = gcvSTATUS_NOT_SUPPORTED; } + gcmkFOOTER(); return status; } @@ -317,6 +335,12 @@ reserved_mem_map_user( gcmkHEADER_ARG("Allocator=%p Mdl=%p Cacheable=%d", Allocator, Mdl, Cacheable); + if (!Mdl->cpuAccessible) + { + status = gcvSTATUS_NOT_SUPPORTED; + goto Out; + } + #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 4, 0) userLogical = (gctPOINTER)vm_mmap(NULL, 0L, res->size, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_NORESERVE, 0); @@ -373,6 +397,7 @@ OnError: { reserved_mem_unmap_user(Allocator, Mdl, userLogical, res->size); } +Out: gcmkFOOTER(); return status; } @@ -389,13 +414,22 @@ reserved_mem_map_kernel( struct reserved_mem *res = Mdl->priv; void *vaddr; + if (!Mdl->cpuAccessible) + { + return gcvSTATUS_NOT_SUPPORTED; + } + if (Offset + Bytes > res->size) { return gcvSTATUS_INVALID_ARGUMENT; } #if LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0) +#if gcdENABLE_BUFFERABLE_VIDEO_MEMORY vaddr = memremap(res->start + Offset, Bytes, MEMREMAP_WC); +#else + vaddr = memremap(res->start + Offset, Bytes, MEMREMAP_WT); +#endif #elif LINUX_VERSION_CODE >= KERNEL_VERSION(4,3,0) vaddr = memremap(res->start + Offset, Bytes, MEMREMAP_WT); #else @@ -418,6 +452,11 @@ reserved_mem_unmap_kernel( IN gctPOINTER Logical ) { + if (!Mdl->cpuAccessible) + { + return gcvSTATUS_NOT_SUPPORTED; + } + #if LINUX_VERSION_CODE >= KERNEL_VERSION(4,3,0) memunmap((void *)Logical); #else @@ -528,7 +567,9 @@ _ReservedMemoryAllocatorInit( allocator->capability = gcvALLOC_FLAG_LINUX_RESERVED_MEM | gcvALLOC_FLAG_CONTIGUOUS - | gcvALLOC_FLAG_CPU_ACCESS; + | gcvALLOC_FLAG_CPU_ACCESS + | gcvALLOC_FLAG_NON_CPU_ACCESS + | gcvALLOC_FLAG_4GB_ADDR; *Allocator = allocator; diff --git a/drivers/amlogic/npu/os/linux/kernel/gc_hal_kernel_allocator.h b/drivers/amlogic/npu/os/linux/kernel/gc_hal_kernel_allocator.h index e6f1d24..ff058f5 100644 --- a/drivers/amlogic/npu/os/linux/kernel/gc_hal_kernel_allocator.h +++ b/drivers/amlogic/npu/os/linux/kernel/gc_hal_kernel_allocator.h @@ -501,6 +501,7 @@ typedef union _gcsATTACH_DESC unsigned long size; const char * name; int requested; + gctBOOL root; } reservedMem; } diff --git a/drivers/amlogic/npu/os/linux/kernel/gc_hal_kernel_device.c b/drivers/amlogic/npu/os/linux/kernel/gc_hal_kernel_device.c index 44cb18e5..41f62d8 100644 --- a/drivers/amlogic/npu/os/linux/kernel/gc_hal_kernel_device.c +++ b/drivers/amlogic/npu/os/linux/kernel/gc_hal_kernel_device.c @@ -55,10 +55,14 @@ #include "gc_hal_kernel_linux.h" #include "gc_hal_kernel_allocator.h" +#include "gc_feature_database.h" +#include "gc_hal.h" #include #include #include #include +#include +#include #define _GC_OBJ_ZONE gcvZONE_DEVICE @@ -71,6 +75,67 @@ static gckGALDEVICE galDevice; extern gcTA globalTA[16]; +#ifdef CONFIG_DEBUG_FS +#if defined(CONFIG_CPU_CSKYV2) && LINUX_VERSION_CODE <= KERNEL_VERSION(3,0,8) +static void +seq_vprintf( + struct seq_file *m, + const char *f, + va_list args + ) +{ + int len; + if (m->count < m->size) + { + len = vsnprintf(m->buf + m->count, m->size - m->count, f, args); + if (m->count + len < m->size) + { + m->count += len; + return; + } + } + m->count = m->size; +} +#endif + +static int +debugfs_printf( + IN void* obj, + IN const char* fmt, + ... + ) +{ + va_list args; + va_start(args, fmt); + seq_vprintf((struct seq_file*)obj, fmt, args); + va_end(args); + + return 0; +} +#else +static int +sys_printf( + IN void* obj, + IN const char* fmt, + ... + ) +{ + int len = 0; + va_list args; + va_start(args, fmt); + len = vsprintf((char*)obj, fmt, args); + va_end(args); + + return len; +} +#endif + +#ifdef CONFIG_DEBUG_FS +#define fs_printf debugfs_printf +#else +#define fs_printf sys_printf +#endif + /******************************************************************************\ ******************************** Debugfs Support ******************************* \******************************************************************************/ @@ -79,11 +144,16 @@ extern gcTA globalTA[16]; ***************************** DEBUG SHOW FUNCTIONS ***************************** \******************************************************************************/ -int gc_info_show(struct seq_file* m, void* data) +int gc_info_show(void* m, void* data) { - gcsINFO_NODE *node = m->private; - gckGALDEVICE device = node->device; + gckGALDEVICE device = galDevice; int i = 0; + int len = 0; +#ifdef CONFIG_DEBUG_FS + void* ptr = m; +#else + char* ptr = (char*)m; +#endif gceCHIPMODEL chipModel = 0; gctUINT32 chipRevision = 0; gctUINT32 productID = 0; @@ -107,34 +177,38 @@ int gc_info_show(struct seq_file* m, void* data) ecoID = device->kernels[i]->hardware->identity.ecoID; } - seq_printf(m, "gpu : %d\n", i); - seq_printf(m, "model : %4x\n", chipModel); - seq_printf(m, "revision : %4x\n", chipRevision); - seq_printf(m, "product : %4x\n", productID); - seq_printf(m, "eco : %4x\n", ecoID); - seq_printf(m, "\n"); + len = fs_printf(ptr, "gpu : %d\n", i); + len += fs_printf(ptr + len, "model : %4x\n", chipModel); + len += fs_printf(ptr + len, "revision : %4x\n", chipRevision); + len += fs_printf(ptr + len, "product : %4x\n", productID); + len += fs_printf(ptr + len, "eco : %4x\n", ecoID); + len += fs_printf(ptr + len, "\n"); } } - - return 0; + return len; } -int gc_clients_show(struct seq_file* m, void* data) +int gc_clients_show(void* m, void* data) { - gcsINFO_NODE *node = m->private; - gckGALDEVICE device = node->device; + gckGALDEVICE device = galDevice; gckKERNEL kernel = _GetValidKernel(device); gcsDATABASE_PTR database; gctINT i, pid; char name[24]; + int len = 0; +#ifdef CONFIG_DEBUG_FS + void* ptr = m; +#else + char* ptr = (char*)m; +#endif if (!kernel) return -ENXIO; - seq_printf(m, "%-8s%s\n", "PID", "NAME"); - seq_printf(m, "------------------------\n"); + len = fs_printf(ptr, "%-8s%s\n", "PID", "NAME"); + len += fs_printf(ptr + len, "------------------------\n"); /* Acquire the database mutex. */ gcmkVERIFY_OK( @@ -151,7 +225,7 @@ int gc_clients_show(struct seq_file* m, void* data) gcmkVERIFY_OK(gckOS_GetProcessNameByPid(pid, gcmSIZEOF(name), name)); - seq_printf(m, "%-8d%s\n", pid, name); + len += fs_printf(ptr + len, "%-8d%s\n", pid, name); } } @@ -159,18 +233,23 @@ int gc_clients_show(struct seq_file* m, void* data) gcmkVERIFY_OK(gckOS_ReleaseMutex(kernel->os, kernel->db->dbMutex)); /* Success. */ - return 0; + return len; } -int gc_meminfo_show(struct seq_file* m, void* data) +int gc_meminfo_show(void* m, void* data) { - gcsINFO_NODE *node = m->private; - gckGALDEVICE device = node->device; + gckGALDEVICE device = galDevice; gckKERNEL kernel = _GetValidKernel(device); gckVIDMEM memory; gceSTATUS status; gcsDATABASE_PTR database; gctUINT32 i; + int len = 0; +#ifdef CONFIG_DEBUG_FS + void* ptr = m; +#else + char* ptr = (char*)m; +#endif gctUINT32 free = 0, used = 0, total = 0, minFree = 0, maxUsed = 0; @@ -196,13 +275,13 @@ int gc_meminfo_show(struct seq_file* m, void* data) gcmkVERIFY_OK(gckOS_ReleaseMutex(memory->os, memory->mutex)); } - seq_printf(m, "VIDEO MEMORY:\n"); - seq_printf(m, " POOL SYSTEM:\n"); - seq_printf(m, " Free : %10u B\n", free); - seq_printf(m, " Used : %10u B\n", used); - seq_printf(m, " MinFree : %10u B\n", minFree); - seq_printf(m, " MaxUsed : %10u B\n", maxUsed); - seq_printf(m, " Total : %10u B\n", total); + len = fs_printf(ptr, "VIDEO MEMORY:\n"); + len += fs_printf(ptr + len, " POOL SYSTEM:\n"); + len += fs_printf(ptr + len, " Free : %10u B\n", free); + len += fs_printf(ptr + len, " Used : %10u B\n", used); + len += fs_printf(ptr + len, " MinFree : %10u B\n", minFree); + len += fs_printf(ptr + len, " MaxUsed : %10u B\n", maxUsed); + len += fs_printf(ptr + len, " Total : %10u B\n", total); /* Acquire the database mutex. */ gcmkVERIFY_OK( @@ -229,11 +308,11 @@ int gc_meminfo_show(struct seq_file* m, void* data) /* Release the database mutex. */ gcmkVERIFY_OK(gckOS_ReleaseMutex(kernel->os, kernel->db->dbMutex)); - seq_printf(m, " POOL VIRTUAL:\n"); - seq_printf(m, " Used : %10llu B\n", virtualCounter.bytes); - seq_printf(m, " MaxUsed : %10llu B\n", virtualCounter.bytes); + len += fs_printf(ptr + len, " POOL VIRTUAL:\n"); + len += fs_printf(ptr + len, " Used : %10llu B\n", virtualCounter.bytes); + len += fs_printf(ptr + len, " MaxUsed : %10llu B\n", virtualCounter.bytes); - return 0; + return len; } static const char * vidmemTypeStr[gcvVIDMEM_TYPE_COUNT] = @@ -271,19 +350,21 @@ static const char * poolStr[gcvPOOL_NUMBER_OF_POOLS] = "User", "Insram", "Exsram", + "Exclusive", }; -static void +static int _ShowDummyRecord( - IN struct seq_file *File, + IN void *File, IN gcsDATABASE_PTR Database ) { + return 0; } -static void +static int _ShowVideoMemoryRecord( - IN struct seq_file *m, + IN void *m, IN gcsDATABASE_PTR Database ) { @@ -294,9 +375,15 @@ _ShowVideoMemoryRecord( gctINT32 refCount = 0; gctINT32 lockCount = 0; gceSTATUS status; + int len = 0; +#ifdef CONFIG_DEBUG_FS + void* ptr = m; +#else + char* ptr = (char*)m; +#endif - seq_printf(m, "Video Memory Node:\n"); - seq_printf(m, " handle nodeObject size type pool physical ref lock\n"); + len = fs_printf(ptr, "Video Memory Node:\n"); + len += fs_printf(ptr + len, " handle nodeObject size type pool physical ref lock\n"); for (i = 0; i < gcmCOUNTOF(Database->list); i++) { @@ -323,7 +410,7 @@ _ShowVideoMemoryRecord( if (gcmIS_ERROR(status)) { - seq_printf(m, "%6u Invalid Node\n", handle); + len += fs_printf(ptr + len, "%6u Invalid Node\n", handle); continue; } @@ -331,7 +418,7 @@ _ShowVideoMemoryRecord( gcmkONERROR(gckVIDMEM_NODE_GetReference(record->kernel, nodeObject, &refCount)); gcmkONERROR(gckVIDMEM_NODE_GetLockCount(record->kernel, nodeObject, &lockCount)); - seq_printf(m, "%#8x %#18lx %10lu %12s %8s %#12llx %4d %4d\n", + len += fs_printf(ptr + len, "%#8x %#18lx %10lu %12s %8s %#12llx %4d %4d\n", handle, (unsigned long)nodeObject, (unsigned long)record->bytes, @@ -345,28 +432,34 @@ _ShowVideoMemoryRecord( } OnError: - return; + return len; } -static void +static int _ShowCommandBufferRecord( - IN struct seq_file *m, + IN void *m, IN gcsDATABASE_PTR Database ) { - return; + return 0; } -static void +static int _ShowNonPagedRecord( - IN struct seq_file *m, + IN void *m, IN gcsDATABASE_PTR Database ) { gctUINT i; + int len = 0; +#ifdef CONFIG_DEBUG_FS + void* ptr = m; +#else + char* ptr = (char*)m; +#endif - seq_printf(m, "NonPaged Memory:\n"); - seq_printf(m, " name vaddr size\n"); + len = fs_printf(ptr, "NonPaged Memory:\n"); + len += fs_printf(ptr + len, " name vaddr size\n"); for (i = 0; i < gcmCOUNTOF(Database->list); i++) { @@ -382,33 +475,40 @@ _ShowNonPagedRecord( continue; } - seq_printf(m, "%6u %#18lx %10lu\n", + len += fs_printf(ptr + len, "%6u %#18lx %10lu\n", gcmPTR2INT32(record->physical), (unsigned long)record->data, (unsigned long)record->bytes ); } } + return len; } -static void +static int _ShowContiguousRecord( - IN struct seq_file *m, + IN void *m, IN gcsDATABASE_PTR Database ) { - return; + return 0; } -static void +static int _ShowSignalRecord( - IN struct seq_file *m, + IN void *m, IN gcsDATABASE_PTR Database ) { gctUINT i; + int len = 0; +#ifdef CONFIG_DEBUG_FS + void* ptr = m; +#else + char* ptr = (char*)m; +#endif - seq_printf(m, "User signal:\n"); + len = fs_printf(ptr, "User signal:\n"); for (i = 0; i < gcmCOUNTOF(Database->list); i++) { @@ -424,14 +524,15 @@ _ShowSignalRecord( continue; } - seq_printf(m, "%#10x\n", gcmPTR2INT32(record->data)); + len += fs_printf(ptr + len, "%#10x\n", gcmPTR2INT32(record->data)); } } + return len; } -static void +static int _ShowLockRecord( - IN struct seq_file *m, + IN void *m, IN gcsDATABASE_PTR Database ) { @@ -439,9 +540,15 @@ _ShowLockRecord( gceSTATUS status; gctUINT32 handle; gckVIDMEM_NODE nodeObject; + int len = 0; +#ifdef CONFIG_DEBUG_FS + void* ptr = m; +#else + char* ptr = (char*)m; +#endif - seq_printf(m, "Video Memory Lock:\n"); - seq_printf(m, " handle nodeObject vaddr\n"); + len = fs_printf(ptr, "Video Memory Lock:\n"); + len += fs_printf(ptr + len, " handle nodeObject vaddr\n"); for (i = 0; i < gcmCOUNTOF(Database->list); i++) { @@ -471,24 +578,31 @@ _ShowLockRecord( nodeObject = gcvNULL; } - seq_printf(m, "%#8x %#18lx %#18lx\n", + len += fs_printf(ptr + len, "%#8x %#18lx %#18lx\n", handle, (unsigned long)nodeObject, (unsigned long)record->physical ); } } + return len; } -static void +static int _ShowContextRecord( - IN struct seq_file *m, + IN void *m, IN gcsDATABASE_PTR Database ) { gctUINT i; + int len = 0; +#ifdef CONFIG_DEBUG_FS + void* ptr = m; +#else + char* ptr = (char*)m; +#endif - seq_printf(m, "Context:\n"); + len = fs_printf(ptr, "Context:\n"); for (i = 0; i < gcmCOUNTOF(Database->list); i++) { @@ -504,21 +618,28 @@ _ShowContextRecord( continue; } - seq_printf(m, "%6u\n", gcmPTR2INT32(record->data)); + len += fs_printf(ptr + len, "%6u\n", gcmPTR2INT32(record->data)); } } + return len; } -static void +static int _ShowMapMemoryRecord( - IN struct seq_file *m, + IN void *m, IN gcsDATABASE_PTR Database ) { gctUINT i; + int len = 0; +#ifdef CONFIG_DEBUG_FS + void* ptr = m; +#else + char* ptr = (char*)m; +#endif - seq_printf(m, "Map Memory:\n"); - seq_printf(m, " name vaddr size\n"); + len = fs_printf(ptr, "Map Memory:\n"); + len += fs_printf(ptr + len, " name vaddr size\n"); for (i = 0; i < gcmCOUNTOF(Database->list); i++) { @@ -534,33 +655,40 @@ _ShowMapMemoryRecord( continue; } - seq_printf(m, "%#6lx %#18lx %10lu\n", + len += fs_printf(ptr + len, "%#6lx %#18lx %10lu\n", (unsigned long)record->physical, (unsigned long)record->data, (unsigned long)record->bytes ); } } + return len; } -static void +static int _ShowMapUserMemoryRecord( - IN struct seq_file *m, + IN void *m, IN gcsDATABASE_PTR Database ) { - return; + return 0; } -static void +static int _ShowShbufRecord( - IN struct seq_file *m, + IN void *m, IN gcsDATABASE_PTR Database ) { gctUINT i; + int len = 0; +#ifdef CONFIG_DEBUG_FS + void* ptr = m; +#else + char* ptr = (char*)m; +#endif - seq_printf(m, "ShBuf:\n"); + len = fs_printf(ptr, "ShBuf:\n"); for (i = 0; i < gcmCOUNTOF(Database->list); i++) { @@ -576,18 +704,36 @@ _ShowShbufRecord( continue; } - seq_printf(m, "%#8x\n", gcmPTR2INT32(record->data)); + len += fs_printf(ptr + len, "%#8x\n", gcmPTR2INT32(record->data)); } } + return len; } -static void +#if gcdENABLE_SW_PREEMPTION +static int +_ShowPriorityRecord( + IN void *m, + IN gcsDATABASE_PTR Database + ) +{ + return 0; +} +#endif + +static int _ShowCounters( - struct seq_file *File, + void *File, gcsDATABASE_PTR Database ) { gctUINT i = 0; + int len = 0; +#ifdef CONFIG_DEBUG_FS + void* ptr = File; +#else + char* ptr = (char*)File; +#endif static const char * otherCounterNames[] = { "AllocNonPaged", @@ -603,10 +749,10 @@ _ShowCounters( &Database->mapMemory, }; - seq_printf(File, "%-16s %16s %16s %16s\n", "", "Current", "Maximum", "Total"); + len = fs_printf(ptr, "%-16s %16s %16s %16s\n", "", "Current", "Maximum", "Total"); /* Print surface type counters. */ - seq_printf(File, "%-16s %16lld %16lld %16lld\n", + len += fs_printf(ptr + len, "%-16s %16lld %16lld %16lld\n", "All-Types", Database->vidMem.bytes, Database->vidMem.maxBytes, @@ -614,16 +760,17 @@ _ShowCounters( for (i = 1; i < gcvVIDMEM_TYPE_COUNT; i++) { - seq_printf(File, "%-16s %16lld %16lld %16lld\n", + len += fs_printf(ptr + len, "%-16s %16lld %16lld %16lld\n", vidmemTypeStr[i], Database->vidMemType[i].bytes, Database->vidMemType[i].maxBytes, Database->vidMemType[i].totalBytes); } - seq_puts(File, "\n"); + /*seq_puts(File, "\n");*/ + len += fs_printf(ptr + len, "\n"); /* Print surface pool counters. */ - seq_printf(File, "%-16s %16lld %16lld %16lld\n", + len += fs_printf(ptr + len, "%-16s %16lld %16lld %16lld\n", "All-Pools", Database->vidMem.bytes, Database->vidMem.maxBytes, @@ -631,29 +778,32 @@ _ShowCounters( for (i = 1; i < gcvPOOL_NUMBER_OF_POOLS; i++) { - seq_printf(File, "%-16s %16lld %16lld %16lld\n", + len += fs_printf(ptr + len, "%-16s %16lld %16lld %16lld\n", poolStr[i], Database->vidMemPool[i].bytes, Database->vidMemPool[i].maxBytes, Database->vidMemPool[i].totalBytes); } - seq_puts(File, "\n"); + /*seq_puts(File, "\n");*/ + len += fs_printf(ptr + len, "\n"); /* Print other counters. */ for (i = 0; i < gcmCOUNTOF(otherCounterNames); i++) { - seq_printf(File, "%-16s %16lld %16lld %16lld\n", + len += fs_printf(ptr + len, "%-16s %16lld %16lld %16lld\n", otherCounterNames[i], otherCounters[i]->bytes, otherCounters[i]->maxBytes, otherCounters[i]->totalBytes); } - seq_puts(File, "\n"); + /*seq_puts(File, "\n");*/ + len += fs_printf(ptr + len, "\n"); + return len; } static int _ShowRecord( - IN struct seq_file *File, + IN void *File, IN gcsDATABASE_PTR Database, IN gcsDATABASE_RECORD_PTR Record ) @@ -662,6 +812,12 @@ _ShowRecord( gckVIDMEM_NODE nodeObject; gctPHYS_ADDR_T physical; gceSTATUS status = gcvSTATUS_OK; + int len = 0; +#ifdef CONFIG_DEBUG_FS + void* ptr = File; +#else + char* ptr = (char*)File; +#endif static const char * recordTypes[gcvDB_NUM_TYPES] = { "Unknown", @@ -691,7 +847,7 @@ _ShowRecord( if (gcmIS_ERROR(status)) { - seq_printf(File, "%6u Invalid Node\n", handle); + len += fs_printf(ptr + len, "%6u Invalid Node\n", handle); gcmkONERROR(gcvSTATUS_INVALID_ARGUMENT); } gcmkONERROR(gckVIDMEM_NODE_GetPhysical(Record->kernel, nodeObject, 0, &physical)); @@ -701,7 +857,7 @@ _ShowRecord( physical = (gctUINT64)(gctUINTPTR_T)Record->physical; } - seq_printf(File, "%-14s %3d %16x %16zx %16zu\n", + len += fs_printf(ptr + len, "%-14s %3d %16x %16zx %16zu\n", recordTypes[Record->type], Record->kernel->core, gcmPTR2INT32(Record->data), @@ -710,29 +866,35 @@ _ShowRecord( ); OnError: - return status; + return len; } -static void +static int _ShowDataBaseOldFormat( - IN struct seq_file *File, + IN void *File, IN gcsDATABASE_PTR Database ) { gctINT pid; gctUINT i; char name[24]; + int len = 0; +#ifdef CONFIG_DEBUG_FS + void* ptr = File; +#else + char* ptr = (char*)File; +#endif /* Process ID and name */ pid = Database->processID; gcmkVERIFY_OK(gckOS_GetProcessNameByPid(pid, gcmSIZEOF(name), name)); - seq_printf(File, "--------------------------------------------------------------------------------\n"); - seq_printf(File, "Process: %-8d %s\n", pid, name); + len = fs_printf(ptr, "--------------------------------------------------------------------------------\n"); + len += fs_printf(ptr + len, "Process: %-8d %s\n", pid, name); - seq_printf(File, "Records:\n"); + len += fs_printf(ptr + len, "Records:\n"); - seq_printf(File, "%14s %3s %16s %16s %16s\n", + len += fs_printf(ptr + len, "%14s %3s %16s %16s %16s\n", "Type", "GPU", "Data/Node", "Physical/Node", "Bytes"); for (i = 0; i < gcmCOUNTOF(Database->list); i++) @@ -741,27 +903,34 @@ _ShowDataBaseOldFormat( while (record != NULL) { - _ShowRecord(File, Database, record); + len += _ShowRecord(ptr + len, Database, record); record = record->next; } } - seq_printf(File, "Counters:\n"); + len += fs_printf(ptr + len, "Counters:\n"); - _ShowCounters(File, Database); + len += _ShowCounters(ptr + len, Database); + return len; } -static void +static int _ShowDatabase( - IN struct seq_file *File, + IN void *File, IN gcsDATABASE_PTR Database ) { gctINT pid; gctUINT i; char name[24]; + int len = 0; +#ifdef CONFIG_DEBUG_FS + void* ptr = File; +#else + char* ptr = (char*)File; +#endif gctBOOL hasType[gcvDB_NUM_TYPES] = {0,}; - void (* showFuncs[])(struct seq_file *, gcsDATABASE_PTR) = + int (* showFuncs[])(void *, gcsDATABASE_PTR) = { _ShowDummyRecord, _ShowVideoMemoryRecord, @@ -775,6 +944,9 @@ _ShowDatabase( _ShowMapMemoryRecord, _ShowMapUserMemoryRecord, _ShowShbufRecord, +#if gcdENABLE_SW_PREEMPTION + _ShowPriorityRecord, +#endif }; gcmSTATIC_ASSERT(gcmCOUNTOF(showFuncs) == gcvDB_NUM_TYPES, @@ -784,8 +956,8 @@ _ShowDatabase( pid = Database->processID; gcmkVERIFY_OK(gckOS_GetProcessNameByPid(pid, gcmSIZEOF(name), name)); - seq_printf(File, "--------------------------------------------------------------------------------\n"); - seq_printf(File, "Process: %-8d %s\n", pid, name); + len = fs_printf(ptr, "--------------------------------------------------------------------------------\n"); + len += fs_printf(ptr + len, "Process: %-8d %s\n", pid, name); for (i = 0; i < gcmCOUNTOF(Database->list); i++) { @@ -802,20 +974,26 @@ _ShowDatabase( { if (hasType[i]) { - showFuncs[i](File, Database); + len += showFuncs[i](ptr + len, Database); } } + return len; } static int -gc_db_show_old(struct seq_file *m, void *data) +gc_db_old_show(void *m, void *data) { gcsDATABASE_PTR database; gctINT i; static gctUINT64 idleTime = 0; - gcsINFO_NODE *node = m->private; - gckGALDEVICE device = node->device; + gckGALDEVICE device = galDevice; gckKERNEL kernel = _GetValidKernel(device); + int len = 0; +#ifdef CONFIG_DEBUG_FS + void* ptr = m; +#else + char* ptr = (char*)m; +#endif if (!kernel) return -ENXIO; @@ -832,7 +1010,7 @@ gc_db_show_old(struct seq_file *m, void *data) } /* Idle time since last call */ - seq_printf(m, "GPU Idle: %llu ns\n", idleTime); + len = fs_printf(ptr, "GPU Idle: %llu ns\n", idleTime); /* Walk the databases. */ for (i = 0; i < gcmCOUNTOF(kernel->db->db); ++i) @@ -841,25 +1019,30 @@ gc_db_show_old(struct seq_file *m, void *data) database != gcvNULL; database = database->next) { - _ShowDataBaseOldFormat(m, database); + len += _ShowDataBaseOldFormat(ptr + len, database); } } /* Release the database mutex. */ gcmkVERIFY_OK(gckOS_ReleaseMutex(kernel->os, kernel->db->dbMutex)); - return 0 ; + return len; } static int -gc_db_show(struct seq_file *m, void *data) +gc_db_show(void *m, void *data) { gcsDATABASE_PTR database; gctINT i; static gctUINT64 idleTime = 0; - gcsINFO_NODE *node = m->private; - gckGALDEVICE device = node->device; + gckGALDEVICE device = galDevice; gckKERNEL kernel = _GetValidKernel(device); + int len = 0; +#ifdef CONFIG_DEBUG_FS + void* ptr = m; +#else + char* ptr = (char*)m; +#endif if (!kernel) return -ENXIO; @@ -876,7 +1059,7 @@ gc_db_show(struct seq_file *m, void *data) } /* Idle time since last call */ - seq_printf(m, "GPU Idle: %llu ns\n", idleTime); + len = fs_printf(ptr, "GPU Idle: %llu ns\n", idleTime); /* Walk the databases. */ for (i = 0; i < gcmCOUNTOF(kernel->db->db); ++i) @@ -885,22 +1068,27 @@ gc_db_show(struct seq_file *m, void *data) database != gcvNULL; database = database->next) { - _ShowDatabase(m, database); + len += _ShowDatabase(ptr + len, database); } } /* Release the database mutex. */ gcmkVERIFY_OK(gckOS_ReleaseMutex(kernel->os, kernel->db->dbMutex)); - return 0 ; + return len; } static int -gc_version_show(struct seq_file *m, void *data) +gc_version_show(void *m, void *data) { - gcsINFO_NODE *node = m->private; - gckGALDEVICE device = node->device; + gckGALDEVICE device = galDevice; gcsPLATFORM * platform = gcvNULL; + int len = 0; +#ifdef CONFIG_DEBUG_FS + void* ptr = m; +#else + char* ptr = (char*)m; +#endif if (!device) return -ENXIO; @@ -909,18 +1097,18 @@ gc_version_show(struct seq_file *m, void *data) if (!platform) return -ENXIO; - seq_printf(m, "%s built at %s\n", gcvVERSION_STRING, HOST); + len = fs_printf(ptr, "%s built at %s\n", gcvVERSION_STRING, HOST); if (platform->name) { - seq_printf(m, "Platform path: %s\n", platform->name); + len += fs_printf(ptr + len, "Platform path: %s\n", platform->name); } else { - seq_printf(m, "Code path: %s\n", __FILE__); + len += fs_printf(ptr + len, "Code path: %s\n", __FILE__); } - return 0 ; + return len; } static void print_ull(char dest[32], unsigned long long u) @@ -963,10 +1151,9 @@ static void print_ull(char dest[32], unsigned long long u) ** Suspend: Time GPU stays in gcvPOWER_SUSPEND. */ static int -gc_idle_show(struct seq_file *m, void *data) +gc_idle_show(void *m, void *data) { - gcsINFO_NODE *node = m->private; - gckGALDEVICE device = node->device; + gckGALDEVICE device = galDevice; gckKERNEL kernel = _GetValidKernel(device); char str[32]; @@ -974,6 +1161,12 @@ gc_idle_show(struct seq_file *m, void *data) gctUINT64 off; gctUINT64 idle; gctUINT64 suspend; + int len = 0; +#ifdef CONFIG_DEBUG_FS + void* ptr = m; +#else + char* ptr = (char*)m; +#endif if (!kernel) return -ENXIO; @@ -982,15 +1175,15 @@ gc_idle_show(struct seq_file *m, void *data) /* Idle time since last call */ print_ull(str, on); - seq_printf(m, "On: %s ns\n", str); + len = fs_printf(ptr, "On: %s ns\n", str); print_ull(str, off); - seq_printf(m, "Off: %s ns\n", str); + len += fs_printf(ptr + len, "Off: %s ns\n", str); print_ull(str, idle); - seq_printf(m, "Idle: %s ns\n", str); + len += fs_printf(ptr + len, "Idle: %s ns\n", str); print_ull(str, suspend); - seq_printf(m, "Suspend: %s ns\n", str); + len += fs_printf(ptr + len, "Suspend: %s ns\n", str); - return 0 ; + return len; } extern void @@ -1016,11 +1209,17 @@ _DumpState( static int dumpCore = 0; static int -gc_dump_trigger_show(struct seq_file *m, void *data) +gc_dump_trigger_show(void *m, void *data) { + int len = 0; +#ifdef CONFIG_DEBUG_FS + void* ptr = m; +#else + char* ptr = (char*)m; +#endif + #if gcdENABLE_3D - gcsINFO_NODE *node = m->private; - gckGALDEVICE device = node->device; + gckGALDEVICE device = galDevice; gckKERNEL kernel = gcvNULL; if (dumpCore >= gcvCORE_MAJOR && dumpCore < gcvCORE_COUNT) @@ -1033,29 +1232,35 @@ gc_dump_trigger_show(struct seq_file *m, void *data) #endif - seq_printf(m, gcdDEBUG_FS_WARN); + len = fs_printf(ptr, gcdDEBUG_FS_WARN); #if gcdENABLE_3D - seq_printf(m, "Get dump from /proc/kmsg or /sys/kernel/debug/gc/galcore_trace\n"); + //len += fs_printf(ptr + len, "Get dump from /proc/kmsg or /sys/kernel/debug/gc/galcore_trace\n"); - if (kernel && kernel->hardware->options.powerManagement == gcvFALSE) + if (kernel) { _DumpState(kernel); } #endif - return 0; + return len; } static int dumpProcess = 0; -static void +static int _ShowVideoMemoryOldFormat( - struct seq_file *File, + void *File, gcsDATABASE_PTR Database ) { gctUINT i = 0; + int len = 0; +#ifdef CONFIG_DEBUG_FS + void* ptr = File; +#else + char* ptr = (char*)File; +#endif static const char * otherCounterNames[] = { "AllocNonPaged", @@ -1071,10 +1276,10 @@ _ShowVideoMemoryOldFormat( &Database->mapMemory, }; - seq_printf(File, "%-16s %16s %16s %16s\n", "", "Current", "Maximum", "Total"); + len = fs_printf(ptr, "%-16s %16s %16s %16s\n", "", "Current", "Maximum", "Total"); /* Print surface type counters. */ - seq_printf(File, "%-16s %16llu %16llu %16llu\n", + len += fs_printf(ptr + len, "%-16s %16llu %16llu %16llu\n", "All-Types", Database->vidMem.bytes, Database->vidMem.maxBytes, @@ -1082,16 +1287,17 @@ _ShowVideoMemoryOldFormat( for (i = 1; i < gcvVIDMEM_TYPE_COUNT; i++) { - seq_printf(File, "%-16s %16llu %16llu %16llu\n", + len += fs_printf(ptr + len, "%-16s %16llu %16llu %16llu\n", vidmemTypeStr[i], Database->vidMemType[i].bytes, Database->vidMemType[i].maxBytes, Database->vidMemType[i].totalBytes); } - seq_puts(File, "\n"); + /*seq_puts(File, "\n");*/ + len += fs_printf(ptr + len, "\n"); /* Print surface pool counters. */ - seq_printf(File, "%-16s %16llu %16llu %16llu\n", + len += fs_printf(ptr + len, "%-16s %16llu %16llu %16llu\n", "All-Pools", Database->vidMem.bytes, Database->vidMem.maxBytes, @@ -1099,33 +1305,42 @@ _ShowVideoMemoryOldFormat( for (i = 1; i < gcvPOOL_NUMBER_OF_POOLS; i++) { - seq_printf(File, "%-16s %16llu %16llu %16llu\n", + len += fs_printf(ptr + len, "%-16s %16llu %16llu %16llu\n", poolStr[i], Database->vidMemPool[i].bytes, Database->vidMemPool[i].maxBytes, Database->vidMemPool[i].totalBytes); } - seq_puts(File, "\n"); + /*seq_puts(File, "\n");*/ + len += fs_printf(ptr + len, "\n"); /* Print other counters. */ for (i = 0; i < gcmCOUNTOF(otherCounterNames); i++) { - seq_printf(File, "%-16s %16llu %16llu %16llu\n", + len += fs_printf(ptr + len, "%-16s %16llu %16llu %16llu\n", otherCounterNames[i], otherCounters[i]->bytes, otherCounters[i]->maxBytes, otherCounters[i]->totalBytes); } - seq_puts(File, "\n"); + /*seq_puts(File, "\n");*/ + len += fs_printf(ptr + len, "\n"); + return len; } -static void +static int _ShowVideoMemory( - struct seq_file *File, + void *File, gcsDATABASE_PTR Database ) { gctUINT i = 0; + int len = 0; +#ifdef CONFIG_DEBUG_FS + void* ptr = File; +#else + char* ptr = (char*)File; +#endif static const char * otherCounterNames[] = { "AllocNonPaged", @@ -1137,10 +1352,10 @@ _ShowVideoMemory( &Database->mapMemory, }; - seq_printf(File, "%-16s %16s %16s %16s\n", "", "Current", "Maximum", "Total"); + len = fs_printf(ptr, "%-16s %16s %16s %16s\n", "", "Current", "Maximum", "Total"); /* Print surface type counters. */ - seq_printf(File, "%-16s %16llu %16llu %16llu\n", + len += fs_printf(ptr + len, "%-16s %16llu %16llu %16llu\n", "All-Types", Database->vidMem.bytes, Database->vidMem.maxBytes, @@ -1148,16 +1363,17 @@ _ShowVideoMemory( for (i = 1; i < gcvVIDMEM_TYPE_COUNT; i++) { - seq_printf(File, "%-16s %16llu %16llu %16llu\n", + len += fs_printf(ptr + len, "%-16s %16llu %16llu %16llu\n", vidmemTypeStr[i], Database->vidMemType[i].bytes, Database->vidMemType[i].maxBytes, Database->vidMemType[i].totalBytes); } - seq_puts(File, "\n"); + /*seq_puts(File, "\n");*/ + len += fs_printf(ptr + len, "\n"); /* Print surface pool counters. */ - seq_printf(File, "%-16s %16llu %16llu %16llu\n", + len += fs_printf(ptr + len, "%-16s %16llu %16llu %16llu\n", "All-Pools", Database->vidMem.bytes, Database->vidMem.maxBytes, @@ -1165,34 +1381,42 @@ _ShowVideoMemory( for (i = 1; i < gcvPOOL_NUMBER_OF_POOLS; i++) { - seq_printf(File, "%-16s %16llu %16llu %16llu\n", + len += fs_printf(ptr + len, "%-16s %16llu %16llu %16llu\n", poolStr[i], Database->vidMemPool[i].bytes, Database->vidMemPool[i].maxBytes, Database->vidMemPool[i].totalBytes); } - seq_puts(File, "\n"); + /*seq_puts(File, "\n");*/ + len += fs_printf(ptr + len, "\n"); /* Print other counters. */ for (i = 0; i < gcmCOUNTOF(otherCounterNames); i++) { - seq_printf(File, "%-16s %16llu %16llu %16llu\n", + len += fs_printf(ptr + len, "%-16s %16llu %16llu %16llu\n", otherCounterNames[i], otherCounters[i]->bytes, otherCounters[i]->maxBytes, otherCounters[i]->totalBytes); } - seq_puts(File, "\n"); + /*seq_puts(File, "\n");*/ + len += fs_printf(ptr + len, "\n"); + return len; } -static int gc_vidmem_show_old(struct seq_file *m, void *unused) +static int gc_vidmem_old_show(void *m, void *unused) { gceSTATUS status; gcsDATABASE_PTR database; - gcsINFO_NODE *node = m->private; - gckGALDEVICE device = node->device; + gckGALDEVICE device = galDevice; char name[64]; int i; + int len = 0; +#ifdef CONFIG_DEBUG_FS + void* ptr = m; +#else + char* ptr = (char*)m; +#endif gckKERNEL kernel = _GetValidKernel(device); @@ -1212,9 +1436,10 @@ static int gc_vidmem_show_old(struct seq_file *m, void *unused) database = database->next) { gckOS_GetProcessNameByPid(database->processID, gcmSIZEOF(name), name); - seq_printf(m, "VidMem Usage (Process %u: %s):\n", database->processID, name); - _ShowVideoMemoryOldFormat(m, database); - seq_puts(m, "\n"); + len += fs_printf(ptr + len, "VidMem Usage (Process %u: %s):\n", database->processID, name); + len += _ShowVideoMemoryOldFormat(ptr + len, database); + /*seq_puts(m, "\n");*/ + len += fs_printf(ptr + len, "\n"); } } @@ -1228,26 +1453,31 @@ static int gc_vidmem_show_old(struct seq_file *m, void *unused) if (gcmIS_ERROR(status)) { - seq_printf(m, "ERROR: process %d not found\n", dumpProcess); - return 0; + len += fs_printf(ptr + len, "ERROR: process %d not found\n", dumpProcess); + return len; } gckOS_GetProcessNameByPid(dumpProcess, gcmSIZEOF(name), name); - seq_printf(m, "VidMem Usage (Process %d: %s):\n", dumpProcess, name); - _ShowVideoMemoryOldFormat(m, database); + len += fs_printf(ptr + len, "VidMem Usage (Process %d: %s):\n", dumpProcess, name); + len += _ShowVideoMemoryOldFormat(ptr + len, database); } - return 0; + return len; } -static int gc_vidmem_show(struct seq_file *m, void *unused) +static int gc_vidmem_show(void *m, void *unused) { gceSTATUS status; gcsDATABASE_PTR database; - gcsINFO_NODE *node = m->private; - gckGALDEVICE device = node->device; + gckGALDEVICE device = galDevice; char name[64]; int i; + int len = 0; +#ifdef CONFIG_DEBUG_FS + void* ptr = m; +#else + char* ptr = (char*)m; +#endif gckKERNEL kernel = _GetValidKernel(device); @@ -1267,9 +1497,10 @@ static int gc_vidmem_show(struct seq_file *m, void *unused) database = database->next) { gckOS_GetProcessNameByPid(database->processID, gcmSIZEOF(name), name); - seq_printf(m, "VidMem Usage (Process %u: %s):\n", database->processID, name); - _ShowVideoMemory(m, database); - seq_puts(m, "\n"); + len += fs_printf(ptr + len, "VidMem Usage (Process %u: %s):\n", database->processID, name); + len += _ShowVideoMemory(ptr + len, database); + /*seq_puts(m, "\n");*/ + len += fs_printf(ptr + len, "\n"); } } @@ -1283,18 +1514,19 @@ static int gc_vidmem_show(struct seq_file *m, void *unused) if (gcmIS_ERROR(status)) { - seq_printf(m, "ERROR: process %d not found\n", dumpProcess); - return 0; + len += fs_printf(ptr + len, "ERROR: process %d not found\n", dumpProcess); + return len; } gckOS_GetProcessNameByPid(dumpProcess, gcmSIZEOF(name), name); - seq_printf(m, "VidMem Usage (Process %d: %s):\n", dumpProcess, name); - _ShowVideoMemory(m, database); + len += fs_printf(ptr + len, "VidMem Usage (Process %d: %s):\n", dumpProcess, name); + len += _ShowVideoMemory(ptr + len, database); } - return 0; + return len; } +#ifdef CONFIG_DEBUG_FS static inline int strtoint_from_user(const char __user *s, size_t count, int *res) { @@ -1327,13 +1559,19 @@ static int gc_dump_trigger_write(const char __user *buf, size_t count, void* dat { return strtoint_from_user(buf, count, &dumpCore); } +#endif -static int gc_clk_show(struct seq_file* m, void* data) +static int gc_clk_show(void* m, void* data) { - gcsINFO_NODE *node = m->private; - gckGALDEVICE device = node->device; + gckGALDEVICE device = galDevice; gctUINT i; gceSTATUS status; + int len = 0; +#ifdef CONFIG_DEBUG_FS + void* ptr = m; +#else + char* ptr = (char*)m; +#endif if (!device) return -ENXIO; @@ -1352,39 +1590,298 @@ static int gc_clk_show(struct seq_file* m, void* data) status = gckHARDWARE_QueryFrequency(hardware); if (gcmIS_ERROR(status)) { - seq_printf(m, "query gpu%d clock fail.\n", i); + len += fs_printf(ptr + len, "query gpu%d clock fail.\n", i); continue; } if (hardware->mcClk) { - seq_printf(m, "gpu%d mc clock: %d HZ.\n", i, hardware->mcClk); + len += fs_printf(ptr + len, "gpu%d mc clock: %d HZ.\n", i, hardware->mcClk); } if (hardware->shClk) { - seq_printf(m, "gpu%d sh clock: %d HZ.\n", i, hardware->shClk); + len += fs_printf(ptr + len, "gpu%d sh clock: %d HZ.\n", i, hardware->shClk); } } } - return 0; + return len; +} + +static int gc_dump_param_show(void *m, void *unused) +{ + fs_printf(m, "galcore module param will dumped by printk\n"); + gckOS_DumpParam(); + return 0; +} + +static int customID = 0; +static int gc_chipinfo_show(void *m, void *unused) +{ + int entryNum = sizeof(gChipInfo) / sizeof(gChipInfo[0]); + int i; + if(customID == 0) + { + gcQueryFeatureDB(0,0,0,0,0); + fs_printf(m, "chip id should setting by chipinfo>\n"); + } + /* check formal release entries first */ + for (i = 0; i < entryNum; ++i) + { + + if(gChipInfo[i].customerID == customID) + { + fs_printf(m, "chipID:0x%x\n",gChipInfo[i].chipID); + fs_printf(m, "customID:0x%x\n",customID); + fs_printf(m, "shaderCore number:%d\n",gChipInfo[i].NumShaderCores); + fs_printf(m, "NNcore number:%d\n",gChipInfo[i].NNCoreCount/2); + fs_printf(m, "NNInputDepth:%d\n",gChipInfo[i].NNInputBufferDepth); + fs_printf(m, "TPcore number:%d\n",gChipInfo[i].TPEngine_CoreCount); + fs_printf(m, "AXI-SRAM size:0x%x\n",gChipInfo[i].AXI_SRAM_SIZE); + fs_printf(m, "VIP-SRAM size:0x%x\n",gChipInfo[i].VIP_SRAM_SIZE); + fs_printf(m, "NN-KERNEL-X size:%d\n",gChipInfo[i].NN_KERNEL_X_SIZE); + fs_printf(m, "NN-KERNEL-Y size:%d\n",gChipInfo[i].NN_KERNEL_Y_SIZE); + fs_printf(m, "MMU ENABLE:%d\n",gChipInfo[i].REG_MMU); + fs_printf(m, "TP reorder:%d\n",gChipInfo[i].TP_REORDER); + fs_printf(m, "NN-FP16-ALU:%d\n",gChipInfo[i].NN_FP16_ALU); + fs_printf(m, "NN-INT16-ALU:%d\n",gChipInfo[i].NN_INT16_ALU); + fs_printf(m, "TP-ROI-POOLING:%d\n",gChipInfo[i].TP_ROI_POOLING); + fs_printf(m, "NN-DEPTHWISE-SUPPORT:%d\n",gChipInfo[i].NN_DEPTHWISE_SUPPORT); + break; + } + } + return 0; +} + +static int gc_chipinfo_write(const char __user *ubuf, size_t count, void* data) +{ + int dval[2]; + int i; + int j; + + char buf[10]; + size_t len = min(count, sizeof(buf) - 1); + + printk("chipinfo write enter,customID-[0x00,0xff]\n"); + if(copy_from_user(buf, ubuf, len)) + { + return -EFAULT; + } + + if((buf[0]=='0') && (buf[1]=='x')) + { + customID = 0; + for(i=2,j=0;i= '0') && (buf[i] <= '9')) + { + dval[j] = buf[i] - '0'; + } + else if((buf[i] >= 'a') && (buf[i] <= 'f')) + { + dval[j] = buf[i] - 'a' + 10; + } + else if((buf[i] >= 'A') && (buf[i] <= 'F')) + { + dval[j] = buf[i] - 'A' + 10; + } + } + + if(count == 5) + { + customID = 16*dval[0]+dval[1]; + } + else if(count == 4) + { + customID = dval[0]; + } + else + { + printk("count number not support:%ld\n",count); + } + } + else + { + strtoint_from_user(buf, count, &customID); + } + printk("customid:0x%x\n",customID); + return 0; } +#ifdef CONFIG_DEBUG_FS +int gc_info_show_debugfs(struct seq_file* m, void* data) +{ + return gc_info_show((void*)m , data); +} +int gc_clients_show_debugfs(struct seq_file* m, void* data) +{ + return gc_clients_show((void*)m , data); +} +int gc_meminfo_show_debugfs(struct seq_file* m, void* data) +{ + return gc_meminfo_show((void*)m , data); +} +int gc_idle_show_debugfs(struct seq_file* m, void* data) +{ + return gc_idle_show((void*)m , data); +} +int gc_db_old_show_debugfs(struct seq_file* m, void* data) +{ + return gc_db_old_show((void*)m , data); +} +int gc_db_show_debugfs(struct seq_file* m, void* data) +{ + return gc_db_show((void*)m , data); +} +int gc_version_show_debugfs(struct seq_file* m, void* data) +{ + return gc_version_show((void*)m , data); +} +int gc_vidmem_old_show_debugfs(struct seq_file* m, void* data) +{ + return gc_vidmem_old_show((void*)m , data); +} +int gc_vidmem_show_debugfs(struct seq_file* m, void* data) +{ + return gc_vidmem_show((void*)m , data); +} +int gc_dump_trigger_show_debugfs(struct seq_file* m, void* data) +{ + return gc_dump_trigger_show((void*)m , data); +} +int gc_clk_show_debugfs(struct seq_file* m, void* data) +{ + return gc_clk_show((void*)m , data); +} +int gc_dump_param_show_debugfs(struct seq_file* m, void* data) +{ + return gc_dump_param_show((void*)m , data); +} +int gc_chipinfo_show_debugfs(struct seq_file*m, void *unused) +{ + return gc_chipinfo_show((void *)m, unused); +} +int gc_chipinfo_write_debugfs(const char __user *ubuf, size_t count, void* data) +{ + return gc_chipinfo_write(ubuf, count, data ); +} + + static gcsINFO InfoList[] = { - {"info", gc_info_show}, - {"clients", gc_clients_show}, - {"meminfo", gc_meminfo_show}, - {"idle", gc_idle_show}, - {"database", gc_db_show_old}, - {"database64x", gc_db_show}, - {"version", gc_version_show}, - {"vidmem", gc_vidmem_show_old, gc_vidmem_write}, - {"vidmem64x", gc_vidmem_show, gc_vidmem_write}, - {"dump_trigger", gc_dump_trigger_show, gc_dump_trigger_write}, - {"clk", gc_clk_show}, + {"info", gc_info_show_debugfs}, + {"clients", gc_clients_show_debugfs}, + {"meminfo", gc_meminfo_show_debugfs}, + {"idle", gc_idle_show_debugfs}, + {"database", gc_db_old_show_debugfs}, + {"database64x", gc_db_show_debugfs}, + {"version", gc_version_show_debugfs}, + {"vidmem", gc_vidmem_old_show_debugfs, gc_vidmem_write}, + {"vidmem64x", gc_vidmem_show_debugfs, gc_vidmem_write}, + {"dump_trigger", gc_dump_trigger_show_debugfs, gc_dump_trigger_write}, + {"clk", gc_clk_show_debugfs}, + {"dump_param",gc_dump_param_show_debugfs}, + {"chipinfo",gc_chipinfo_show_debugfs, gc_chipinfo_write_debugfs}, }; +#else +static ssize_t info_show(struct device *dev, struct device_attribute* attr, char *buf) +{ + return gc_info_show((void*)buf, NULL); +} +DEVICE_ATTR_RO(info); + +static ssize_t clients_show(struct device *dev, struct device_attribute* attr, char *buf) +{ + return gc_clients_show((void*)buf, NULL); +} +DEVICE_ATTR_RO(clients); + +static ssize_t meminfo_show(struct device *dev, struct device_attribute* attr, char *buf) +{ + return gc_meminfo_show((void*)buf, NULL); +} +DEVICE_ATTR_RO(meminfo); + +static ssize_t idle_show(struct device *dev, struct device_attribute* attr, char *buf) +{ + return gc_idle_show((void*)buf, NULL); +} +DEVICE_ATTR_RO(idle); + +static ssize_t database_show(struct device *dev, struct device_attribute* attr, char *buf) +{ + return gc_db_old_show((void*)buf, NULL); +} +DEVICE_ATTR_RO(database); + +static ssize_t database64x_show(struct device *dev, struct device_attribute* attr, char *buf) +{ + return gc_db_show((void*)buf, NULL); +} +DEVICE_ATTR_RO(database64x); + +static ssize_t version_show(struct device *dev, struct device_attribute* attr, char *buf) +{ + return gc_version_show((void*)buf, NULL); +} +DEVICE_ATTR_RO(version); + +static ssize_t vidmem_show(struct device *dev, struct device_attribute* attr, char *buf) +{ + return gc_vidmem_old_show((void*)buf, NULL); +} +static ssize_t vidmem_store(struct device *dev, struct device_attribute* attr, const char *buf, size_t count) +{ + sscanf(buf, "%d", &dumpProcess); + return count; +} +DEVICE_ATTR_RW(vidmem); + +static ssize_t vidmem64x_show(struct device *dev, struct device_attribute* attr, char *buf) +{ + return gc_vidmem_show((void*)buf, NULL); +} +static ssize_t vidmem64x_store(struct device *dev, struct device_attribute* attr, const char *buf, size_t count) +{ + sscanf(buf, "%d", &dumpProcess); + return count; +} +DEVICE_ATTR_RW(vidmem64x); + +static ssize_t dump_trigger_show(struct device *dev, struct device_attribute* attr, char *buf) +{ + return gc_dump_trigger_show((void*)buf, NULL); +} +static ssize_t dump_trigger_store(struct device *dev, struct device_attribute* attr, const char *buf, size_t count) +{ + sscanf(buf, "%d", &dumpCore); + return count; +} +DEVICE_ATTR_RW(dump_trigger); + +static ssize_t clk_show(struct device *dev, struct device_attribute* attr, char *buf) +{ + return gc_clk_show((void*)buf, NULL); +} +DEVICE_ATTR_RO(clk); + +static struct attribute *Info_attrs[] = { + &dev_attr_info.attr, + &dev_attr_clients.attr, + &dev_attr_meminfo.attr, + &dev_attr_idle.attr, + &dev_attr_database.attr, + &dev_attr_database64x.attr, + &dev_attr_version.attr, + &dev_attr_vidmem.attr, + &dev_attr_vidmem64x.attr, + &dev_attr_dump_trigger.attr, + &dev_attr_clk.attr, + NULL, +}; +ATTRIBUTE_GROUPS(Info); +#endif static gceSTATUS _DebugfsInit( @@ -1392,10 +1889,21 @@ _DebugfsInit( ) { gceSTATUS status = gcvSTATUS_OK; + +#ifdef CONFIG_DEBUG_FS gckDEBUGFS_DIR dir = &Device->debugfsDir; - gcmkONERROR(gckDEBUGFS_DIR_Init(dir, gcvNULL, "gc")); + gcmkONERROR(gckDEBUGFS_DIR_Init(dir, gcvNULL, "galcore")); gcmkONERROR(gckDEBUGFS_DIR_CreateFiles(dir, InfoList, gcmCOUNTOF(InfoList), Device)); +#else + int ret; + ret = sysfs_create_groups(&galcore_device->kobj, Info_groups); + if (ret < 0) + { + gcmkONERROR(gcvSTATUS_NOT_SUPPORTED); + } +#endif + galDevice = Device; OnError: return status; @@ -1406,6 +1914,7 @@ _DebugfsCleanup( IN gckGALDEVICE Device ) { +#ifdef CONFIG_DEBUG_FS gckDEBUGFS_DIR dir = &Device->debugfsDir; if (Device->debugfsDir.root) @@ -1414,6 +1923,9 @@ _DebugfsCleanup( gckDEBUGFS_DIR_Deinit(dir); } +#else + sysfs_remove_groups(&galcore_device->kobj, Info_groups); +#endif } @@ -1590,8 +2102,9 @@ _SetupContiguousVidMem( gcmkONERROR(gckOS_RequestReservedMemory( device->os, Args->contiguousBase, Args->contiguousSize, - "galcore contiguous memory", + "gcContMem", contiguousRequested, + gcvTRUE, &device->contiguousPhysical )); @@ -1668,6 +2181,7 @@ _SetupExternalSRAMVidMem( device->extSRAMBases[i], device->extSRAMSizes[i], sRAMName, device->args.sRAMRequested, + gcvTRUE, &device->extSRAMPhysical[i] )); @@ -1960,6 +2474,8 @@ _StartThread( device->threadCtxts[Core] = task; device->threadInitializeds[Core] = device->kernels[Core]->threadInitialized = gcvTRUE; + + set_user_nice(task, -20); } else { @@ -1987,6 +2503,99 @@ _StopThread( } } +#if gcdENABLE_SW_PREEMPTION + +static int +_ThreadPreempt( + void *ctxt + ) +{ + gckGALDEVICE device = galDevice; + gceCORE core = (gceCORE) gcmPTR2INT32(ctxt); + + sema_init((struct semaphore *)(device->kernels[core]->preemptSema), 0); + + for (;;) + { + int down; + + down = down_interruptible(device->kernels[core]->preemptSema); + if (down && down != -EINTR) + { + return down; + } + + if (unlikely(device->killPreemptThread)) + { + while (!kthread_should_stop()) + { + gckOS_Delay(device->os, 1); + } + + return 0; + } + + gckKERNEL_PreemptionThread(device->kernels[core]); + } +} + +static gceSTATUS +_StartPreemptThread( + IN gckGALDEVICE Device, + IN gceCORE Core + ) +{ + gceSTATUS status = gcvSTATUS_OK; + gckGALDEVICE device = galDevice; + struct task_struct * task; + + if (device->kernels[Core] != gcvNULL) + { + /* Start the kernel thread. */ + task = kthread_run(_ThreadPreempt, (void *)Core, + "galcore_preempt/%d", Core); + + if (IS_ERR(task)) + { + gcmkTRACE_ZONE( + gcvLEVEL_ERROR, gcvZONE_DRIVER, + "%s(%d): Could not start the kernel preempt thread.\n", + __FUNCTION__, __LINE__ + ); + + gcmkONERROR(gcvSTATUS_GENERIC_IO); + } + + device->preemptThread[Core] = task; + device->preemptThreadInits[Core] = gcvTRUE; + } + else + { + device->preemptThreadInits[Core] = gcvFALSE; + } + +OnError: + return status; +} + +static void +_StopPreemptThread( + gckGALDEVICE Device, + gceCORE Core + ) +{ + if (Device->preemptThreadInits[Core]) + { + Device->killPreemptThread = gcvTRUE; + up(Device->kernels[Core]->preemptSema); + + kthread_stop(Device->preemptThread[Core]); + Device->preemptThread[Core] = gcvNULL; + Device->preemptThreadInits[Core] = gcvFALSE; + } +} +#endif + /******************************************************************************* ** ** gckGALDEVICE_Construct @@ -2092,12 +2701,12 @@ gckGALDEVICE_Construct( gcmkONERROR(gcvSTATUS_OUT_OF_RESOURCES); } -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,5,0) && (defined(CONFIG_ARM) || defined(CONFIG_ARM64)) - device->registerBases[i] = (gctPOINTER)ioremap( + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,5,0) + device->registerBases[i] = (gctPOINTER)memremap(physical, device->requestedRegisterMemSizes[i], MEMREMAP_WT); #else - device->registerBases[i] = (gctPOINTER)ioremap_nocache( + device->registerBases[i] = (gctPOINTER)ioremap_nocache(physical, device->requestedRegisterMemSizes[i]); #endif - physical, device->requestedRegisterMemSizes[i]); if (device->registerBases[i] == gcvNULL) { @@ -2122,6 +2731,9 @@ gckGALDEVICE_Construct( device->externalBase = Args->externalBase; device->externalSize = Args->externalSize; + /* Set the extern base address and none cpu access */ + device->exclusiveBase = Args->exclusiveBase; + device->exclusiveSize = Args->exclusiveSize; for (i = 0; i < gcvSRAM_EXT_COUNT; i++) { device->extSRAMBases[i] = Args->extSRAMBases[i]; @@ -2155,7 +2767,8 @@ gckGALDEVICE_Construct( gcmkONERROR(gckOS_RequestReservedMemory( device->os, device->externalBase, device->externalSize, - "galcore external memory", + "gcExtMem", + gcvTRUE, gcvTRUE, &device->externalPhysical )); @@ -2164,6 +2777,41 @@ gckGALDEVICE_Construct( } } + if (device->exclusiveSize > 0) + { + /* create the exclusive memory heap */ + status = gckVIDMEM_Construct( + device->os, + device->exclusiveBase, + device->exclusiveSize, + 64, + 0, + &device->exclusiveVidMem + ); + + if (gcmIS_ERROR(status)) + { + /* Error, disable exclusive heap. */ + device->exclusiveSize = 0; + } + else + { + gckALLOCATOR allocator; + /* Map exclusive memory. */ + gcmkONERROR(gckOS_RequestReservedMemory( + device->os, + device->exclusiveBase, device->exclusiveSize, + "gcExclMem", + gcvTRUE, + gcvFALSE, + &device->exclusivePhysical + )); + allocator = ((PLINUX_MDL)device->exclusivePhysical)->allocator; + device->exclusiveVidMem->physical = device->exclusivePhysical; + device->exclusiveVidMem->capability |= allocator->capability; + } + } + /* Construct the gckDEVICE object for os independent core management. */ gcmkONERROR(gckDEVICE_Construct(device->os, &device->device)); @@ -2332,6 +2980,11 @@ gckGALDEVICE_Construct( device->externalPhysName = gcmPTR_TO_NAME(device->externalPhysical); } + if (device->exclusivePhysical) + { + device->exclusivePhysName = gcmPTR_TO_NAME(device->exclusivePhysical); + } + if (device->contiguousPhysical) { device->contiguousPhysName = gcmPTR_TO_NAME(device->contiguousPhysical); @@ -2409,6 +3062,11 @@ gckGALDEVICE_Destroy( gcmRELEASE_NAME(Device->contiguousPhysName); Device->contiguousPhysName = 0; } + if (Device->exclusivePhysName != 0) + { + gcmRELEASE_NAME(Device->exclusivePhysName); + Device->exclusivePhysName = 0; + } } /* Destroy per-core SRAM heap. */ @@ -2518,6 +3176,27 @@ gckGALDEVICE_Destroy( Device->externalVidMem = gcvNULL; } + if (Device->exclusivePhysical != gcvNULL) + { + gckOS_ReleaseReservedMemory( + Device->os, + Device->exclusivePhysical + ); + Device->exclusivePhysical = gcvNULL; + } + + if (Device->exclusiveLogical != gcvNULL) + { + Device->exclusiveLogical = gcvNULL; + } + + if (Device->exclusiveVidMem != gcvNULL) + { + /* destroy the external heap */ + gcmkVERIFY_OK(gckVIDMEM_Destroy(Device->exclusiveVidMem)); + Device->exclusiveVidMem = gcvNULL; + } + /* * Destroy contiguous memory pool after gckDEVICE destroyed. gckDEVICE * may allocates GPU memory types from SYSTEM pool. @@ -2561,7 +3240,11 @@ gckGALDEVICE_Destroy( /* Unmap register memory. */ if (Device->requestedRegisterMemBases[i] != 0) { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,5,0) + memunmap(Device->registerBases[i]); +#else iounmap(Device->registerBases[i]); +#endif release_mem_region(Device->requestedRegisterMemBases[i], Device->requestedRegisterMemSizes[i]); } @@ -2636,6 +3319,10 @@ gckGALDEVICE_Start( } gcmkONERROR(_StartThread(Device, i)); + +#if gcdENABLE_SW_PREEMPTION + gcmkONERROR(_StartPreemptThread(Device, i)); +#endif } for (i = 0; i < gcvCORE_COUNT; i++) @@ -2732,6 +3419,9 @@ gckGALDEVICE_Stop( for (i = 0; i < gcvCORE_COUNT; i++) { _StopThread(Device, i); +#if gcdENABLE_SW_PREEMPTION + _StopPreemptThread(Device, i); +#endif } OnError: diff --git a/drivers/amlogic/npu/os/linux/kernel/gc_hal_kernel_device.h b/drivers/amlogic/npu/os/linux/kernel/gc_hal_kernel_device.h index d5ebe81..19edef7 100644 --- a/drivers/amlogic/npu/os/linux/kernel/gc_hal_kernel_device.h +++ b/drivers/amlogic/npu/os/linux/kernel/gc_hal_kernel_device.h @@ -99,6 +99,13 @@ typedef struct _gckGALDEVICE gctPOINTER contiguousLogical; gckVIDMEM contiguousVidMem; + gctPHYS_ADDR_T exclusiveBase; + gctSIZE_T exclusiveSize; + gctPHYS_ADDR exclusivePhysical; + gctUINT32 exclusivePhysName; + gctPOINTER exclusiveLogical; + gckVIDMEM exclusiveVidMem; + /* By request_mem_region. */ gctUINT64 requestedContiguousBase; gctSIZE_T requestedContiguousSize; @@ -146,6 +153,13 @@ typedef struct _gckGALDEVICE #if gcdENABLE_DRM void * drm; #endif + +#if gcdENABLE_SW_PREEMPTION + struct task_struct *preemptThread[gcdMAX_GPU_COUNT]; + struct semaphore preemptSemas[gcdMAX_GPU_COUNT]; + gctBOOL preemptThreadInits[gcdMAX_GPU_COUNT]; + gctBOOL killPreemptThread; +#endif } * gckGALDEVICE; diff --git a/drivers/amlogic/npu/os/linux/kernel/gc_hal_kernel_driver.c b/drivers/amlogic/npu/os/linux/kernel/gc_hal_kernel_driver.c index bcb2cf0..6b098d5 100644 --- a/drivers/amlogic/npu/os/linux/kernel/gc_hal_kernel_driver.c +++ b/drivers/amlogic/npu/os/linux/kernel/gc_hal_kernel_driver.c @@ -57,11 +57,13 @@ #include #include #include - -#include "gc_hal_kernel_linux.h" -#include "shared/gc_hal_driver.h" - +#include +#include #include +#include +#include +#include "gc_hal_kernel_linux.h" +#include "gc_hal_driver.h" /* Zone used for header/footer. */ #define _GC_OBJ_ZONE gcvZONE_DRIVER @@ -157,8 +159,13 @@ static ulong exclusiveSize = 0; module_param(exclusiveSize, ulong, 0644); MODULE_PARM_DESC(exclusiveSize, "Size of exclusiveSize memory, if it is 0, means there is no exclusive pool"); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0) +static gctPHYS_ADDR_T exclusiveBase = 0; +module_param(exclusiveBase, ullong, 0644); +#else static ulong exclusiveBase = 0; module_param(exclusiveBase, ulong, 0644); +#endif MODULE_PARM_DESC(exclusiveBase, "Base address of exclusive memory(GPU access only)"); static int fastClear = -1; @@ -311,6 +318,151 @@ static ulong bankSize = 0; static gcsMODULE_PARAMETERS moduleParam; +/*==========================some sysfs functions,class begin===================================*/ +static ssize_t show_class_control(struct class *class,struct class_attribute *attr, char *buf) +{ + gctUINT32 status = 0; + if (platform->ops->getPowerStatus) + { + platform->ops->getPowerStatus(platform,&status); + } + return snprintf(buf, PAGE_SIZE, "customid:%d,status:%d\n",galDevice->kernels[0]->hardware->identity.customerID,status); +} +/*============the control format should as: (control-domain:control-value)==========*/ +static int kcmp(const char *buff,const char *token,int lenth) +{ + int i = 0; + int flag = 0; + for (i=0;iops->getPowerStatus) + { + platform->ops->getPowerStatus(platform,&status); + } + if (status != POWER_ON) + { + gckOS_SetGPUPower(galDevice->os, 0, 1, 1); + } + if (buf[pos+1] == '1') + { + galDevice->args.gpuProfiler = 1; + gckHARDWARE_SetGpuProfiler(galDevice->kernels[0]->hardware, 1); + } + else + { + galDevice->args.gpuProfiler = 0; + gckHARDWARE_SetGpuProfiler(galDevice->kernels[0]->hardware, 0); + } + } + else if (kcmp(buf,"policy",strlen("policy")) == 0) + { + printk("the control domain is policy\n"); + if (platform->ops->setPolicy) + { + platform->ops->setPolicy(platform,(gctUINT32)(buf[pos+1]-'0')); + } + } + else if (kcmp(buf,"suspend",strlen("suspend")) == 0) + { + if (kstrtoint(&buf[pos+1], 0, &val) != 0) + { + printk("kstrtoint return error\n"); + val = 300; + } + printk("the control domain is suspend,value is %d\n",val); + galDevice->kernels[0]->hardware->powerTimeout = val; + } + return count; +} + +static ssize_t show_class_policy(struct class *class,struct class_attribute *attr, char *buf) +{ + return snprintf(buf, PAGE_SIZE, "policy read,just for test\n"); +} + +static ssize_t store_class_policy(struct class *class,struct class_attribute *attr, const char *buf, size_t count) +{ + ssize_t ret = 0; + printk("store_policy,%s\n",buf); + return ret; +} + +static ssize_t show_class_status(struct class *class,struct class_attribute *attr, char *buf) +{ + gctUINT32 status = 0; + if (platform->ops->getPowerStatus) + { + platform->ops->getPowerStatus(platform,&status); + } + return snprintf(buf, PAGE_SIZE, "status:%d",status); +} + +static ssize_t store_class_status(struct class *class,struct class_attribute *attr, const char *buf, size_t count) +{ + ssize_t ret = 0; + printk("store_status,%s\n",buf); + return ret; +} + +static ssize_t show_class_info(struct class *class,struct class_attribute *attr, char *buf) +{ + return snprintf(buf, PAGE_SIZE, "info read,just for test\n"); +} + +static ssize_t store_class_info(struct class *class,struct class_attribute *attr, const char *buf, size_t count) +{ + ssize_t ret = 0; + printk("store_info,%s\n",buf); + return ret; +} + +static struct class_attribute gal_class_attrs[] = { + __ATTR(control, 0664, + show_class_control, store_class_control), + __ATTR(policy, 0664, + show_class_policy, store_class_policy), + __ATTR(status, 0664, + show_class_status, store_class_status), + __ATTR(info, 0664, + show_class_info, store_class_info), +}; +/*=========================some sysfs functions,class end=======================================*/ static void _InitModuleParam( gcsMODULE_PARAMETERS * ModuleParam @@ -338,7 +490,10 @@ _InitModuleParam( #if USE_LINUX_PCIE if (bar != -1) { - p->bars[gcvCORE_MAJOR] = bar; + if (p->bars[gcvCORE_MAJOR] == -1) + { + p->bars[gcvCORE_MAJOR] = bar; + } } #endif @@ -389,6 +544,9 @@ _InitModuleParam( p->externalBase = externalBase; p->externalSize = externalSize; + p->exclusiveBase = exclusiveBase; + p->exclusiveSize = exclusiveSize; + for (i = 0; i < gcvCORE_COUNT; i++) { for (j = 0; j < gcvSRAM_INTER_COUNT; j++) @@ -508,6 +666,9 @@ _SyncModuleParam( externalBase = p->externalBase; externalSize = p->externalSize; + exclusiveBase = p->exclusiveBase; + exclusiveSize = p->exclusiveSize; + for (i = 0; i < gcvCORE_COUNT; i++) { for (j = 0; j < gcvSRAM_INTER_COUNT; j++) @@ -608,6 +769,12 @@ gckOS_DumpParam( #else printk(" externalBase = 0x%lX\n", externalBase); #endif + printk(" exclusiveSize = 0x%08lX\n", exclusiveSize); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0) + printk(" exclusiveBase = 0x%llX\n", exclusiveBase); +#else + printk(" exclusiveBase = 0x%lX\n", exclusiveBase); +#endif printk(" bankSize = 0x%08lX\n", bankSize); printk(" fastClear = %d\n", fastClear); printk(" compression = %d\n", compression); @@ -834,6 +1001,11 @@ static long drv_ioctl( long ret = -ENOTTY; gceSTATUS status = gcvSTATUS_OK; gcsHAL_INTERFACE iface; + +#if VIVANTE_PROFILER + static gcsHAL_PROFILER_INTERFACE iface_profiler; +#endif + gctUINT32 copyLen; DRIVER_ARGS drvArgs; gckGALDEVICE device; @@ -867,97 +1039,172 @@ static long drv_ioctl( gcmkONERROR(gcvSTATUS_INVALID_ARGUMENT); } - if ((ioctlCode != IOCTL_GCHAL_INTERFACE) - && (ioctlCode != IOCTL_GCHAL_KERNEL_INTERFACE) - ) + switch (ioctlCode) { - gcmkTRACE_ZONE( - gcvLEVEL_ERROR, gcvZONE_DRIVER, - "%s(%d): unknown command %d\n", - __FUNCTION__, __LINE__, - ioctlCode + case IOCTL_GCHAL_INTERFACE: + /* Get the drvArgs. */ + copyLen = copy_from_user( + &drvArgs, (void *) arg, sizeof(DRIVER_ARGS) ); - gcmkONERROR(gcvSTATUS_INVALID_ARGUMENT); - } + if (copyLen != 0) + { + gcmkTRACE_ZONE( + gcvLEVEL_ERROR, gcvZONE_DRIVER, + "%s(%d): error copying of the input arguments.\n", + __FUNCTION__, __LINE__ + ); - /* Get the drvArgs. */ - copyLen = copy_from_user( - &drvArgs, (void *) arg, sizeof(DRIVER_ARGS) - ); + gcmkONERROR(gcvSTATUS_INVALID_ARGUMENT); + } - if (copyLen != 0) - { - gcmkTRACE_ZONE( - gcvLEVEL_ERROR, gcvZONE_DRIVER, - "%s(%d): error copying of the input arguments.\n", - __FUNCTION__, __LINE__ + /* Now bring in the gcsHAL_INTERFACE structure. */ + if ((drvArgs.InputBufferSize != sizeof(gcsHAL_INTERFACE)) + || (drvArgs.OutputBufferSize != sizeof(gcsHAL_INTERFACE)) + ) + { + gcmkTRACE_ZONE( + gcvLEVEL_ERROR, gcvZONE_DRIVER, + "%s(%d): input or/and output structures are invalid.\n", + __FUNCTION__, __LINE__ + ); + + gcmkONERROR(gcvSTATUS_INVALID_ARGUMENT); + } + + copyLen = copy_from_user( + &iface, gcmUINT64_TO_PTR(drvArgs.InputBuffer), sizeof(gcsHAL_INTERFACE) ); - gcmkONERROR(gcvSTATUS_INVALID_ARGUMENT); - } + if (copyLen != 0) + { + gcmkTRACE_ZONE( + gcvLEVEL_ERROR, gcvZONE_DRIVER, + "%s(%d): error copying of input HAL interface.\n", + __FUNCTION__, __LINE__ + ); - /* Now bring in the gcsHAL_INTERFACE structure. */ - if ((drvArgs.InputBufferSize != sizeof(gcsHAL_INTERFACE)) - || (drvArgs.OutputBufferSize != sizeof(gcsHAL_INTERFACE)) - ) - { - gcmkTRACE_ZONE( - gcvLEVEL_ERROR, gcvZONE_DRIVER, - "%s(%d): input or/and output structures are invalid.\n", - __FUNCTION__, __LINE__ + gcmkONERROR(gcvSTATUS_INVALID_ARGUMENT); + } + + if (iface.command == gcvHAL_DEVICE_MUTEX) + { + if (iface.u.DeviceMutex.isMutexLocked == gcvTRUE) + { + data->isLocked = gcvTRUE; + } + else + { + data->isLocked = gcvFALSE; + } + } + + status = gckDEVICE_Dispatch(device->device, &iface); + + /* Redo system call after pending signal is handled. */ + if (status == gcvSTATUS_INTERRUPTED) + { + ret = -ERESTARTSYS; + gcmkONERROR(status); + } + + /* Copy data back to the user. */ + copyLen = copy_to_user( + gcmUINT64_TO_PTR(drvArgs.OutputBuffer), &iface, sizeof(gcsHAL_INTERFACE) ); - gcmkONERROR(gcvSTATUS_INVALID_ARGUMENT); - } + if (copyLen != 0) + { + gcmkTRACE_ZONE( + gcvLEVEL_ERROR, gcvZONE_DRIVER, + "%s(%d): error copying of output HAL interface.\n", + __FUNCTION__, __LINE__ + ); - copyLen = copy_from_user( - &iface, gcmUINT64_TO_PTR(drvArgs.InputBuffer), sizeof(gcsHAL_INTERFACE) - ); + gcmkONERROR(gcvSTATUS_INVALID_ARGUMENT); + } + break; - if (copyLen != 0) - { - gcmkTRACE_ZONE( - gcvLEVEL_ERROR, gcvZONE_DRIVER, - "%s(%d): error copying of input HAL interface.\n", - __FUNCTION__, __LINE__ + case IOCTL_GCHAL_PROFILER_INTERFACE: +#if VIVANTE_PROFILER + /* Get the drvArgs. */ + copyLen = copy_from_user( + &drvArgs, (void *) arg, sizeof(DRIVER_ARGS) ); - gcmkONERROR(gcvSTATUS_INVALID_ARGUMENT); - } + if (copyLen != 0) + { + gcmkTRACE_ZONE( + gcvLEVEL_ERROR, gcvZONE_DRIVER, + "%s(%d): error copying of the input arguments.\n", + __FUNCTION__, __LINE__ + ); - if (iface.command == gcvHAL_DEVICE_MUTEX) - { - if (iface.u.DeviceMutex.isMutexLocked == gcvTRUE) + gcmkONERROR(gcvSTATUS_INVALID_ARGUMENT); + } + + /* Now bring in the gcsHAL_INTERFACE structure. */ + if ((drvArgs.InputBufferSize != sizeof(gcsHAL_PROFILER_INTERFACE)) + || (drvArgs.OutputBufferSize != sizeof(gcsHAL_PROFILER_INTERFACE)) + ) { - data->isLocked = gcvTRUE; + gcmkTRACE_ZONE( + gcvLEVEL_ERROR, gcvZONE_DRIVER, + "%s(%d): input or/and output structures are invalid.\n", + __FUNCTION__, __LINE__ + ); + + gcmkONERROR(gcvSTATUS_INVALID_ARGUMENT); } - else + + copyLen = copy_from_user( + &iface_profiler, gcmUINT64_TO_PTR(drvArgs.InputBuffer), sizeof(gcsHAL_PROFILER_INTERFACE) + ); + + if (copyLen != 0) { - data->isLocked = gcvFALSE; + gcmkTRACE_ZONE( + gcvLEVEL_ERROR, gcvZONE_DRIVER, + "%s(%d): error copying of input HAL interface.\n", + __FUNCTION__, __LINE__ + ); + + gcmkONERROR(gcvSTATUS_INVALID_ARGUMENT); } - } - status = gckDEVICE_Dispatch(device->device, &iface); + status = gckDEVICE_Profiler_Dispatch(device->device, &iface_profiler); - /* Redo system call after pending signal is handled. */ - if (status == gcvSTATUS_INTERRUPTED) - { - ret = -ERESTARTSYS; - gcmkONERROR(status); - } + /* Redo system call after pending signal is handled. */ + if (status == gcvSTATUS_INTERRUPTED) + { + ret = -ERESTARTSYS; + gcmkONERROR(status); + } - /* Copy data back to the user. */ - copyLen = copy_to_user( - gcmUINT64_TO_PTR(drvArgs.OutputBuffer), &iface, sizeof(gcsHAL_INTERFACE) - ); + /* Copy data back to the user. */ + copyLen = copy_to_user( + gcmUINT64_TO_PTR(drvArgs.OutputBuffer), &iface_profiler, sizeof(gcsHAL_PROFILER_INTERFACE) + ); - if (copyLen != 0) - { + if (copyLen != 0) + { + gcmkTRACE_ZONE( + gcvLEVEL_ERROR, gcvZONE_DRIVER, + "%s(%d): error copying of output HAL interface.\n", + __FUNCTION__, __LINE__ + ); + + gcmkONERROR(gcvSTATUS_INVALID_ARGUMENT); + } +#endif + break; + + default: gcmkTRACE_ZONE( gcvLEVEL_ERROR, gcvZONE_DRIVER, - "%s(%d): error copying of output HAL interface.\n", - __FUNCTION__, __LINE__ + "%s(%d): unknown command %d\n", + __FUNCTION__, __LINE__, + ioctlCode ); gcmkONERROR(gcvSTATUS_INVALID_ARGUMENT); @@ -1068,7 +1315,7 @@ static int drv_init(void) } /* Create the device class. */ - device_class = class_create(THIS_MODULE, CLASS_NAME); + device_class = class_create(THIS_MODULE, "npu"); if (IS_ERR(device_class)) { @@ -1171,6 +1418,7 @@ static int __devinit gpu_probe(struct platform_device *pdev) { int ret = -ENODEV; bool getPowerFlag = gcvFALSE; + int i = 0; #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24) static u64 dma_mask = DMA_BIT_MASK(40); #else @@ -1188,13 +1436,13 @@ static int __devinit gpu_probe(struct platform_device *pdev) #endif gcmkHEADER(); - if (get_nna_status(pdev) == gcvSTATUS_MISMATCH) { printk("nn is disable,should not do probe continue\n"); return ret; } + platform->device = pdev; galcore_device = &pdev->dev; @@ -1272,6 +1520,11 @@ static int __devinit gpu_probe(struct platform_device *pdev) /* Update module param because drv_init() uses them directly. */ _SyncModuleParam(&moduleParam); + if (powerManagement == 0) + { + gcmkPRINT("[galcore warning]: power saveing is disabled."); + } + ret = drv_init(); if (!ret) @@ -1283,6 +1536,12 @@ static int __devinit gpu_probe(struct platform_device *pdev) #endif } + for (i = 0; i < ARRAY_SIZE(gal_class_attrs); i++) + { + //device_create_file(&pdev->dev, &gal_attrs[i]); + ret = class_create_file(gpuClass, &gal_class_attrs[i]); + } + if (ret < 0) { if(platform->ops->putPower) diff --git a/drivers/amlogic/npu/os/linux/kernel/gc_hal_kernel_linux.c b/drivers/amlogic/npu/os/linux/kernel/gc_hal_kernel_linux.c index 2c51664..fac6ca0 100644 --- a/drivers/amlogic/npu/os/linux/kernel/gc_hal_kernel_linux.c +++ b/drivers/amlogic/npu/os/linux/kernel/gc_hal_kernel_linux.c @@ -107,6 +107,10 @@ gckKERNEL_QueryVideoMemory( Interface->u.QueryVideoMemory.contiguousSize = device->contiguousSize; Interface->u.QueryVideoMemory.contiguousPhysName = device->contiguousPhysName; + /* Get exclusive memory size and physical address. */ + Interface->u.QueryVideoMemory.exclusiveSize = device->exclusiveSize; + Interface->u.QueryVideoMemory.exclusivePhysName = device->exclusivePhysName; + /* Success. */ gcmkFOOTER_NO(); return gcvSTATUS_OK; @@ -169,6 +173,11 @@ gckKERNEL_GetVideoMemoryPool( videoMemory = device->contiguousVidMem; break; + case gcvPOOL_LOCAL_EXCLUSIVE: + /* gpu exclusive memory. */ + videoMemory = device->exclusiveVidMem; + break; + case gcvPOOL_INTERNAL_SRAM: /* Internal SRAM memory. */ videoMemory = Kernel->sRAMVidMem[Kernel->sRAMIndex]; @@ -295,6 +304,9 @@ gckKERNEL_DestroyProcessReservedUserMap( /* when unmap reserved memory, we don't need real logical*/ gctPOINTER Logical = (gctPOINTER)0xFFFFFFFF; gctINT i; + PLINUX_MDL mdl; + PLINUX_MDL_MAP mdlMap = gcvNULL; + gcmkHEADER_ARG("Logical=0x%08x pid=%u", Logical, Pid); /* Verify the arguments. */ @@ -306,14 +318,24 @@ gckKERNEL_DestroyProcessReservedUserMap( bytes = device->internalSize; if (bytes) { - gckOS_UnmapMemoryEx(Kernel->os, physHandle, bytes, Logical, Pid); + mdl = physHandle; + mdlMap = FindMdlMap(mdl, Pid); + if (mdlMap) + { + gckOS_UnmapMemoryEx(Kernel->os, physHandle, bytes, Logical, Pid); + } } physHandle = (PLINUX_MDL)device->externalPhysical; bytes = device->externalSize; if (bytes) { - gckOS_UnmapMemoryEx(Kernel->os, physHandle, bytes, Logical, Pid); + mdl = physHandle; + mdlMap = FindMdlMap(mdl, Pid); + if (mdlMap) + { + gckOS_UnmapMemoryEx(Kernel->os, physHandle, bytes, Logical, Pid); + } } /* System memory. */ @@ -321,7 +343,12 @@ gckKERNEL_DestroyProcessReservedUserMap( bytes = device->contiguousSize; if (bytes) { - gckOS_UnmapMemoryEx(Kernel->os, physHandle, bytes, Logical, Pid); + mdl = physHandle; + mdlMap = FindMdlMap(mdl, Pid); + if (mdlMap) + { + gckOS_UnmapMemoryEx(Kernel->os, physHandle, bytes, Logical, Pid); + } } /* External shared SRAM memory. */ @@ -331,7 +358,12 @@ gckKERNEL_DestroyProcessReservedUserMap( bytes = device->extSRAMSizes[i]; if (bytes) { - gckOS_UnmapMemoryEx(Kernel->os, physHandle, bytes, Logical, Pid); + mdl = physHandle; + mdlMap = FindMdlMap(mdl, Pid); + if (mdlMap) + { + gckOS_UnmapMemoryEx(Kernel->os, physHandle, bytes, Logical, Pid); + } } } @@ -344,7 +376,12 @@ gckKERNEL_DestroyProcessReservedUserMap( bytes = Kernel->sRAMSizes[i]; if (bytes) { - gckOS_UnmapMemoryEx(Kernel->os, physHandle, bytes, Logical, Pid); + mdl = physHandle; + mdlMap = FindMdlMap(mdl, Pid); + if (mdlMap) + { + gckOS_UnmapMemoryEx(Kernel->os, physHandle, bytes, Logical, Pid); + } } } } @@ -659,3 +696,30 @@ gckKERNEL_Notify( gcmkFOOTER(); return status; } + +gceSTATUS +gckKERNEL_SyncVideoMemory( + IN gckKERNEL Kernel, + IN gckVIDMEM_NODE Node, + IN gctUINT32 Reason + ) +{ + gceSTATUS status = gcvSTATUS_NOT_SUPPORTED; + gcsPLATFORM * platform; + + gcmkHEADER(); + + /* Verify the arguments. */ + gcmkVERIFY_OBJECT(Kernel, gcvOBJ_KERNEL); + + platform = Kernel->os->device->platform; + + if (platform && platform->ops->syncMemory) + { + status = platform->ops->syncMemory(Kernel, (gctPOINTER)Node, Reason); + } + + gcmkFOOTER(); + return status; +} + diff --git a/drivers/amlogic/npu/os/linux/kernel/gc_hal_kernel_linux.h b/drivers/amlogic/npu/os/linux/kernel/gc_hal_kernel_linux.h index 1e3ca19..54976b7 100644 --- a/drivers/amlogic/npu/os/linux/kernel/gc_hal_kernel_linux.h +++ b/drivers/amlogic/npu/os/linux/kernel/gc_hal_kernel_linux.h @@ -86,7 +86,7 @@ #define NTSTRSAFE_NO_CCH_FUNCTIONS #include "gc_hal.h" -#include "shared/gc_hal_driver.h" +#include "gc_hal_driver.h" #include "gc_hal_kernel.h" #include "gc_hal_kernel_platform.h" #include "gc_hal_kernel_device.h" diff --git a/drivers/amlogic/npu/os/linux/kernel/gc_hal_kernel_os.c b/drivers/amlogic/npu/os/linux/kernel/gc_hal_kernel_os.c index 16a932f..3f5526d 100644 --- a/drivers/amlogic/npu/os/linux/kernel/gc_hal_kernel_os.c +++ b/drivers/amlogic/npu/os/linux/kernel/gc_hal_kernel_os.c @@ -205,6 +205,7 @@ _CreateMdl( atomic_set(&mdl->refs, 1); mutex_init(&mdl->mapsMutex); INIT_LIST_HEAD(&mdl->mapsHead); + INIT_LIST_HEAD(&mdl->rmaHead); } gcmkFOOTER_ARG("%p", mdl); @@ -233,6 +234,7 @@ _DestroyMdl( if (Mdl->addr) { gcmALLOCATOR_UnmapKernel(allocator, Mdl, Mdl->addr); + Mdl->addr = gcvNULL; } gcmALLOCATOR_Free(allocator, Mdl); } @@ -251,6 +253,13 @@ _DestroyMdl( list_del(&Mdl->link); mutex_unlock(&os->mdlMutex); } + else if (Mdl->rmaLink.next) + { + /* Remove the sub node from root mdl */ + mutex_lock(&os->mdlMutex); + list_del(&Mdl->rmaLink); + mutex_unlock(&os->mdlMutex); + } kfree(Mdl); } @@ -872,6 +881,11 @@ gckOS_CreateKernelMapping( else { gcmkONERROR(gcmALLOCATOR_MapKernel(allocator, mdl, Offset, Bytes, Logical)); + if (Offset == 0 && Bytes == mdl->bytes) + { + /* the whole mdl has mapped */ + mdl->addr = *Logical; + } } OnError: @@ -893,7 +907,9 @@ gckOS_DestroyKernelMapping( if (mdl->addr) { - /* Nothing to do. */ + /* Nothing to do. + * it will be unmpped in vidmem free + */ } else { @@ -1416,6 +1432,7 @@ gckOS_AllocateNonPagedMemory( mdl->numPages = numPages; mdl->contiguous = gcvTRUE; + mdl->cpuAccessible = gcvTRUE; gcmkONERROR(gcmALLOCATOR_MapKernel(allocator, mdl, 0, bytes, &addr)); @@ -1558,6 +1575,7 @@ gckOS_RequestReservedMemory( gctSIZE_T Size, const char * Name, gctBOOL Requested, + gctBOOL CpuAccessible, gctPOINTER * MemoryHandle ) { @@ -1581,6 +1599,7 @@ gckOS_RequestReservedMemory( desc.reservedMem.size = Size; desc.reservedMem.name = Name; desc.reservedMem.requested = Requested; + desc.reservedMem.root = gcvTRUE; allocator = _FindAllocator(Os, gcvALLOC_FLAG_LINUX_RESERVED_MEM); if (!allocator) @@ -1593,13 +1612,14 @@ gckOS_RequestReservedMemory( gcmkONERROR(gcmALLOCATOR_Attach(allocator, &desc, mdl)); /* Assign alloator. */ - mdl->allocator = allocator; - mdl->bytes = Size; - mdl->numPages = Size >> PAGE_SHIFT; - mdl->contiguous = gcvTRUE; - mdl->addr = gcvNULL; - mdl->dmaHandle = Start; - mdl->gid = 0; + mdl->allocator = allocator; + mdl->bytes = Size; + mdl->numPages = Size >> PAGE_SHIFT; + mdl->cpuAccessible = CpuAccessible; + mdl->contiguous = gcvTRUE; + mdl->addr = gcvNULL; + mdl->dmaHandle = Start; + mdl->gid = 0; /* * Add this to a global list. @@ -1641,6 +1661,106 @@ gckOS_ReleaseReservedMemory( /******************************************************************************* ** +** gckOS_RequestReservedMemoryArea +** +** request a reserved memory area. it is used for dynamic mapping for usr +** +** INPUT: +** +** gctPOINTER MemoryHandle +** Pointer to the root MDL. +** +** gctSIZE_T Offset +** Offset from the root reserved memory. +** +** gctSIZE_T Size +** Area size. +** +** gctPOINTER * MemoryAreaHandle +** Sub MDL address to save +** OUTPUT: +** +** gctPOINTER * MemoryAreaHandle +** Pointer to sub MDL. +*/ +gceSTATUS +gckOS_RequestReservedMemoryArea( + IN gctPOINTER MemoryHandle, + IN gctSIZE_T Offset, + IN gctSIZE_T Size, + OUT gctPOINTER * MemoryAreaHandle + ) +{ + PLINUX_MDL rootMdl = (PLINUX_MDL)MemoryHandle; + PLINUX_MDL subMdl = gcvNULL; + gceSTATUS status; + gcsATTACH_DESC desc; + + gcmkHEADER_ARG("MemoryHandle=%p Offset=0x%lx size=0x%lx", MemoryHandle, Offset, Size); + + /* Round up to page size. */ + Size = (Size + ~PAGE_MASK) & PAGE_MASK; + + subMdl = _CreateMdl(rootMdl->os); + if (!subMdl) + { + gcmkONERROR(gcvSTATUS_OUT_OF_MEMORY); + } + + desc.reservedMem.start = rootMdl->dmaHandle + Offset; + desc.reservedMem.size = Size; + desc.reservedMem.name = "subRMA"; + /* consider that the memory region has requested by the root mdl */ + desc.reservedMem.requested = gcvTRUE; + desc.reservedMem.root = gcvFALSE; + + /* Call attach. */ + gcmkONERROR(gcmALLOCATOR_Attach((gckALLOCATOR)rootMdl->allocator, &desc, subMdl)); + + /* Assign alloator. */ + subMdl->allocator = rootMdl->allocator; + subMdl->bytes = Size; + subMdl->numPages = Size >> PAGE_SHIFT; + subMdl->cpuAccessible = rootMdl->cpuAccessible; + subMdl->contiguous = gcvTRUE; + subMdl->addr = gcvNULL; + subMdl->dmaHandle = rootMdl->dmaHandle + Offset; + subMdl->gid = 0; + + mutex_lock(&rootMdl->os->mdlMutex); + list_add_tail(&subMdl->rmaLink, &rootMdl->rmaHead); + mutex_unlock(&rootMdl->os->mdlMutex); + + *MemoryAreaHandle = (void *)subMdl; + + gcmkFOOTER_NO(); + return gcvSTATUS_OK; + +OnError: + if (subMdl) + { + gcmkVERIFY_OK(_DestroyMdl(subMdl)); + } + + gcmkFOOTER(); + return status; +} + +void +gckOS_ReleaseReservedMemoryArea( + gctPOINTER MemoryAreaHandle + ) +{ + PLINUX_MDL subMdl = (PLINUX_MDL)MemoryAreaHandle; + + if (subMdl) + { + gcmkVERIFY_OK(_DestroyMdl(subMdl)); + } +} + +/******************************************************************************* +** ** gckOS_ReadRegister ** ** Read data from a register. @@ -1970,7 +2090,23 @@ _GetPhysicalAddressProcess( { mutex_lock(&mdl->mapsMutex); - status = _ConvertLogical2Physical(Os, Logical, ProcessID, mdl, Address); + if (mdl->addr != gcvNULL) + { + status = _ConvertLogical2Physical(Os, Logical, ProcessID, mdl, Address); + } + else if (!list_empty(&mdl->rmaHead)) + { + PLINUX_MDL subMdl; + + list_for_each_entry(subMdl, &mdl->rmaHead, rmaLink) + { + status = _ConvertLogical2Physical(Os, Logical, ProcessID, subMdl, Address); + if (gcmIS_SUCCESS(status)) + { + break; + } + } + } mutex_unlock(&mdl->mapsMutex); @@ -2192,13 +2328,38 @@ gckOS_MapPhysical( if (mdl->dmaHandle != 0) { if ((physical >= mdl->dmaHandle) - && (physical < mdl->dmaHandle + mdl->bytes) - && (mdl->addr != 0) - ) + && (physical < mdl->dmaHandle + mdl->bytes)) { - *Logical = mdl->addr + (physical - mdl->dmaHandle); - found = gcvTRUE; - break; + + if (mdl->addr != gcvNULL) + { + *Logical = mdl->addr + (physical - mdl->dmaHandle); + found = gcvTRUE; + } + else if (!list_empty(&mdl->rmaHead)) + { + PLINUX_MDL subMdl; + + /* when enable dynamic mapping, MDL from the mdlHead is the root. + * the sub MDL should be looped from root MDL + */ + list_for_each_entry(subMdl, &mdl->rmaHead, rmaLink) + { + if ((physical >= subMdl->dmaHandle) + && (physical < subMdl->dmaHandle + subMdl->bytes) + && (subMdl->addr != 0)) + { + *Logical = subMdl->addr + (physical - subMdl->dmaHandle); + found = gcvTRUE; + break; + } + } + } + + if (found) + { + break; + } } } } @@ -2262,7 +2423,7 @@ gckOS_MapPhysical( /* Map memory as cached memory. */ request_mem_region(physical, Bytes, "MapRegion"); #if LINUX_VERSION_CODE >= KERNEL_VERSION(5,5,0) - logical = (gctPOINTER) ioremap(physical, Bytes); + logical = (gctPOINTER) memremap(physical, Bytes, MEMREMAP_WT); #else logical = (gctPOINTER) ioremap_nocache(physical, Bytes); #endif @@ -2337,9 +2498,28 @@ gckOS_UnmapPhysical( (Logical < (gctPOINTER)((gctSTRING)mdl->addr + mdl->bytes))) { found = gcvTRUE; - break; } } + else if (!list_empty(&mdl->rmaHead)) + { + PLINUX_MDL subMdl; + /* Find the subMDL */ + list_for_each_entry(subMdl, &mdl->rmaHead, rmaLink) + { + if ((subMdl->addr != gcvNULL) && + (Logical >= (gctPOINTER)subMdl->addr) && + (Logical < (gctPOINTER)((gctSTRING)subMdl->addr + subMdl->bytes))) + { + found = gcvTRUE; + break; + } + } + } + + if (found) + { + break; + } } mutex_unlock(&Os->mdlMutex); @@ -3005,6 +3185,41 @@ gckOS_GetTime( /******************************************************************************* ** +** _ExternalCacheOperation +** +** External device cache operation, if support. If the core has any additional caches +** they must be invalidated after this function returns. If the core does not +** have any addional caches the externalCacheOperation in the platform->ops should +** remain NULL. +** +** INPUT: +** +** gckOS Os +** Pointer to an gckOS object. +** +** gceCACHEOPERATION Operation +** Cache Operation: gcvCACHE_FLUSH, gcvCACHE_CLEAN or gcvCACHE_INVALIDATE. +** +** OUTPUT: +** +** Nothing. +*/ +static void +_ExternalCacheOperation( + IN gckOS Os, + IN gceCACHEOPERATION Operation + ) +{ + gcsPLATFORM *platform = Os->device->platform; + + if (platform && platform->ops->externalCacheOperation) + { + platform->ops->externalCacheOperation(platform, Operation); + } +} + +/******************************************************************************* +** ** gckOS_MemoryBarrier ** ** Make sure the CPU has executed everything up to this point and the data got @@ -3030,6 +3245,8 @@ gckOS_MemoryBarrier( { _MemoryBarrier(); + _ExternalCacheOperation(Os, gcvCACHE_INVALIDATE); + return gcvSTATUS_OK; } @@ -3136,6 +3353,7 @@ gckOS_AllocatePagedMemory( mdl->numPages = numPages; mdl->contiguous = Flag & gcvALLOC_FLAG_CONTIGUOUS; mdl->cacheable = Flag & gcvALLOC_FLAG_CACHEABLE; + mdl->cpuAccessible = gcvTRUE; /* * Add this to a global list. @@ -3649,7 +3867,6 @@ gckOS_UnlockPages( /* Verify the arguments. */ gcmkVERIFY_OBJECT(Os, gcvOBJ_OS); gcmkVERIFY_ARGUMENT(Physical != gcvNULL); - gcmkVERIFY_ARGUMENT(Logical != gcvNULL); mutex_lock(&mdl->mapsMutex); @@ -4189,12 +4406,22 @@ _CacheOperation( gcmALLOCATOR_Cache(allocator, mdl, Offset, Logical, Bytes, Operation); + if (Operation == gcvCACHE_CLEAN || Operation == gcvCACHE_FLUSH) + { + _ExternalCacheOperation(Os, gcvCACHE_INVALIDATE); + } + return gcvSTATUS_OK; } } _MemoryBarrier(); + if (Operation == gcvCACHE_CLEAN || Operation == gcvCACHE_FLUSH) + { + _ExternalCacheOperation(Os, gcvCACHE_INVALIDATE); + } + return gcvSTATUS_OK; } @@ -4761,6 +4988,43 @@ gckOS_ReleaseSemaphore( return gcvSTATUS_OK; } +#if gcdENABLE_SW_PREEMPTION +gceSTATUS +gckOS_ReleaseSemaphoreEx( + IN gckOS Os, + IN gctPOINTER Semaphore + ) +{ + struct semaphore *sem; + unsigned long flags; + + gcmkHEADER_ARG("Os=%p Semaphore=%p", Os, Semaphore); + + /* Verify the arguments. */ + gcmkVERIFY_OBJECT(Os, gcvOBJ_OS); + gcmkVERIFY_ARGUMENT(Semaphore != gcvNULL); + + sem = Semaphore; + + raw_spin_lock_irqsave(&sem->lock, flags); + + if (!sem->count) + { + raw_spin_unlock_irqrestore(&sem->lock, flags); + up((struct semaphore *) Semaphore); + } + else + { + raw_spin_unlock_irqrestore(&sem->lock, flags); + } + + + /* Success. */ + gcmkFOOTER_NO(); + return gcvSTATUS_OK; +} +#endif + /******************************************************************************* ** ** gckOS_DestroySemaphore @@ -6932,6 +7196,16 @@ gckOS_QueryOption( *Value = device->externalSize; return gcvSTATUS_OK; } + else if (!strcmp(Option, "exclusiveBase")) + { + *Value = device->exclusiveBase; + return gcvSTATUS_OK; + } + else if (!strcmp(Option, "exclusiveSize")) + { + *Value = device->exclusiveSize; + return gcvSTATUS_OK; + } else if (!strcmp(Option, "externalBase")) { *Value = device->externalBase; @@ -7266,4 +7540,3 @@ gckOS_GetPolicyID( return status; } - diff --git a/drivers/amlogic/npu/os/linux/kernel/gc_hal_kernel_os.h b/drivers/amlogic/npu/os/linux/kernel/gc_hal_kernel_os.h index b4bd951..8e80825 100644 --- a/drivers/amlogic/npu/os/linux/kernel/gc_hal_kernel_os.h +++ b/drivers/amlogic/npu/os/linux/kernel/gc_hal_kernel_os.h @@ -89,6 +89,7 @@ struct _LINUX_MDL gctBOOL contiguous; dma_addr_t dmaHandle; gctBOOL cacheable; + gctBOOL cpuAccessible; struct mutex mapsMutex; struct list_head mapsHead; @@ -104,6 +105,12 @@ struct _LINUX_MDL struct list_head link; gctBOOL pageUnit1M; + + /* list header for sub mdl for dynamic mapping */ + struct list_head rmaHead; + + /* sub mdl list */ + struct list_head rmaLink; }; extern PLINUX_MDL_MAP diff --git a/drivers/amlogic/npu/os/linux/kernel/gc_hal_kernel_platform.h b/drivers/amlogic/npu/os/linux/kernel/gc_hal_kernel_platform.h index 8d4e1020..ad46f8f 100644 --- a/drivers/amlogic/npu/os/linux/kernel/gc_hal_kernel_platform.h +++ b/drivers/amlogic/npu/os/linux/kernel/gc_hal_kernel_platform.h @@ -61,6 +61,12 @@ #include #endif +#define POWER_IDLE 0 +#define POWER_ON 1 +#define POWER_SUSPEND 2 +#define POWER_OFF 3 +#define POWER_RESET 4 + typedef struct _gcsMODULE_PARAMETERS { gctINT irqs[gcvCORE_COUNT]; @@ -81,6 +87,10 @@ typedef struct _gcsMODULE_PARAMETERS gctPHYS_ADDR_T externalBase; gctSIZE_T externalSize; + /* External memory pool. */ + gctPHYS_ADDR_T exclusiveBase; + gctSIZE_T exclusiveSize; + /* Per-core SRAM. */ gctPHYS_ADDR_T sRAMBases[gcvCORE_COUNT][gcvSRAM_INTER_COUNT]; gctUINT32 sRAMSizes[gcvCORE_COUNT][gcvSRAM_INTER_COUNT]; @@ -291,6 +301,69 @@ typedef struct _gcsPLATFORM_OPERATIONS OUT gctUINT32_PTR PolicyID, OUT gctUINT32_PTR AXIConfig ); + + /******************************************************************************* + ** + ** syncMemory + ** + ** sync invisible memory by dma if support. + */ + gceSTATUS + (*syncMemory)( + IN gctPOINTER Object, + IN gctPOINTER Node, + IN gctUINT32 Reason + ); + + /******************************************************************************* + ** + ** getPowerStatus + ** + ** Get power status by user + */ + gceSTATUS + (*getPowerStatus)( + IN gcsPLATFORM *Platform, + OUT gctUINT32_PTR pstat + ); + + /******************************************************************************* + ** + ** setPolicy + ** + ** Set power policy by user + */ + gceSTATUS + (*setPolicy)( + IN gcsPLATFORM *Platform, + IN gctUINT32 powerLevel + ); +/******************************************************************************* +** +** _ExternalCacheOperation +** +** External device cache operation, if support. If the core has any additional caches +** they must be invalidated after this function returns. If the core does not +** have any addional caches the externalCacheOperation in the platform->ops should +** remain NULL. +** +** INPUT: +** +** gckOS Os +** Pointer to an gckOS object. +** +** gceCACHEOPERATION Operation +** Cache Operation: gcvCACHE_FLUSH, gcvCACHE_CLEAN or gcvCACHE_INVALIDATE. +** +** OUTPUT: +** +** Nothing. +*/ + void + (*externalCacheOperation)( + IN gcsPLATFORM *Platform, + IN gceCACHEOPERATION Operation + ); } gcsPLATFORM_OPERATIONS; diff --git a/drivers/amlogic/npu/os/linux/kernel/platform/amlogic/gc_hal_kernel_platform_amlogic.c b/drivers/amlogic/npu/os/linux/kernel/platform/amlogic/gc_hal_kernel_platform_amlogic.c index fefbd18..7f8acb8 100644 --- a/drivers/amlogic/npu/os/linux/kernel/platform/amlogic/gc_hal_kernel_platform_amlogic.c +++ b/drivers/amlogic/npu/os/linux/kernel/platform/amlogic/gc_hal_kernel_platform_amlogic.c @@ -69,6 +69,7 @@ #include #endif +#define NN_PD_0X99 16 /*======== power version 0 hardware reg begin ===========*/ #define AO_RTI_BASE 0xff800000 #define AO_RTI_GEN_PWR_SLEEP0 (AO_RTI_BASE + (0x3a<<2)) @@ -92,6 +93,8 @@ module_param(hardwareResetNum, int, 0644); static int nanoqFreq = 800000000; module_param(nanoqFreq, int, 0644); +static gctUINT32 powerStatus = 0; + gceSTATUS _InitDtsRegValue(IN gcsPLATFORM *Platform) { int ret = 0; @@ -103,28 +106,28 @@ gceSTATUS _InitDtsRegValue(IN gcsPLATFORM *Platform) if (res) { HHI_NANOQ_MEM_PD_REG0 = (unsigned long)res->start; - printk("reg resource 2, start: %lx,end: %lx\n",(unsigned long)res->start,(unsigned long)res->end); +/* printk("reg resource 2, start: %lx,end: %lx\n",(unsigned long)res->start,(unsigned long)res->end);*/ } res = platform_get_resource(pdev, IORESOURCE_MEM, 3); if (res) { HHI_NANOQ_MEM_PD_REG1 = (unsigned long)res->start; - printk("reg resource 3, start: %lx,end: %lx\n",(unsigned long)res->start,(unsigned long)res->end); +/* printk("reg resource 3, start: %lx,end: %lx\n",(unsigned long)res->start,(unsigned long)res->end);*/ } res = platform_get_resource(pdev, IORESOURCE_MEM, 4); if (res) { RESET_LEVEL2 = (unsigned long)res->start; - printk("reg resource 4, start: %lx,end: %lx\n",(unsigned long)res->start,(unsigned long)res->end); +/* printk("reg resource 4, start: %lx,end: %lx\n",(unsigned long)res->start,(unsigned long)res->end);*/ } res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "NN_CLK"); if (res) { NN_clk = (unsigned long)res->start; - printk("reg resource NN_CLK, start: %lx,end: %lx\n",(unsigned long)res->start,(unsigned long)res->end); +/* printk("reg resource NN_CLK, start: %lx,end: %lx\n",(unsigned long)res->start,(unsigned long)res->end);*/ } ret = of_property_read_u32(pdev->dev.of_node,"nn_power_version",&nn_power_version); @@ -138,8 +141,6 @@ gceSTATUS _AdjustParam(IN gcsPLATFORM *Platform,OUT gcsMODULE_PARAMETERS *Args) struct platform_device *pdev = Platform->device; int irqLine = platform_get_irq_byname(pdev, "galcore"); - if (irqLine >= 0) - printk("galcore irq number is %d.\n", irqLine); if (irqLine < 0) { printk("get galcore irq resource error\n"); irqLine = platform_get_irq(pdev, 0); @@ -154,7 +155,7 @@ gceSTATUS _AdjustParam(IN gcsPLATFORM *Platform,OUT gcsMODULE_PARAMETERS *Args) if (res) { Args->registerBases[0] = (gctPHYS_ADDR_T)res->start; - Args->registerSizes[0] = (gctSIZE_T)(res->end - res->start+1); + Args->registerSizes[0] = 0x20000; } else { @@ -291,27 +292,27 @@ void Getpower_88(struct platform_device *pdev) } void Getpower_99(struct platform_device *pdev) { - uint32_t readReg = 0; - _RegRead(AO_RTI_GEN_PWR_SLEEP0,&readReg); - readReg = (readReg & 0xfffeffff); - _RegWrite(AO_RTI_GEN_PWR_SLEEP0, readReg); + uint32_t readReg = 0; + _RegRead(AO_RTI_GEN_PWR_SLEEP0,&readReg); + readReg = (readReg & 0xfffeffff); + _RegWrite(AO_RTI_GEN_PWR_SLEEP0, readReg); - _RegWrite(HHI_NANOQ_MEM_PD_REG0, 0x0); - _RegWrite(HHI_NANOQ_MEM_PD_REG1, 0x0); + _RegWrite(HHI_NANOQ_MEM_PD_REG0, 0x0); + _RegWrite(HHI_NANOQ_MEM_PD_REG1, 0x0); - _RegRead(RESET_LEVEL2,&readReg); - readReg = (readReg & 0xffffefff); - _RegWrite(RESET_LEVEL2, readReg); + _RegRead(RESET_LEVEL2,&readReg); + readReg = (readReg & 0xffffefff); + _RegWrite(RESET_LEVEL2, readReg); - _RegRead(AO_RTI_GEN_PWR_ISO0,&readReg); - readReg = (readReg & 0xfffeffff); - _RegWrite(AO_RTI_GEN_PWR_ISO0, readReg); + _RegRead(AO_RTI_GEN_PWR_ISO0,&readReg); + readReg = (readReg & 0xfffeffff); + _RegWrite(AO_RTI_GEN_PWR_ISO0, readReg); - _RegRead(RESET_LEVEL2,&readReg); - readReg = (readReg | (0x1<<12)); - _RegWrite(RESET_LEVEL2, readReg); + _RegRead(RESET_LEVEL2,&readReg); + readReg = (readReg | (0x1<<12)); + _RegWrite(RESET_LEVEL2, readReg); - set_clock(pdev); + set_clock(pdev); } void Getpower_a1(struct platform_device *pdev) { @@ -319,6 +320,12 @@ void Getpower_a1(struct platform_device *pdev) set_clock(pdev); return; } +void Getpower_be(struct platform_device *pdev) +{ + /*C2 added power domain, it will get domain power when prob*/ + set_clock(pdev); + return; +} /* Downpower: disable nna power for platform */ @@ -338,28 +345,33 @@ void Downpower_88(void) } void Downpower_99(void) { - unsigned int readReg=0; + unsigned int readReg=0; - _RegRead(RESET_LEVEL2,&readReg); - readReg = (readReg & (~(0x1<<12))); - _RegWrite(RESET_LEVEL2, readReg); + _RegRead(RESET_LEVEL2,&readReg); + readReg = (readReg & (~(0x1<<12))); + _RegWrite(RESET_LEVEL2, readReg); - _RegRead(AO_RTI_GEN_PWR_ISO0,&readReg); - readReg = (readReg | 0x10000); - _RegWrite(AO_RTI_GEN_PWR_ISO0, readReg); + _RegRead(AO_RTI_GEN_PWR_ISO0,&readReg); + readReg = (readReg | 0x10000); + _RegWrite(AO_RTI_GEN_PWR_ISO0, readReg); - _RegWrite(HHI_NANOQ_MEM_PD_REG0, 0xffffffff); - _RegWrite(HHI_NANOQ_MEM_PD_REG1, 0xffffffff); + _RegWrite(HHI_NANOQ_MEM_PD_REG0, 0xffffffff); + _RegWrite(HHI_NANOQ_MEM_PD_REG1, 0xffffffff); - _RegRead(AO_RTI_GEN_PWR_SLEEP0,&readReg); - readReg = (readReg | 0x10000); - _RegWrite(AO_RTI_GEN_PWR_SLEEP0, readReg); + _RegRead(AO_RTI_GEN_PWR_SLEEP0,&readReg); + readReg = (readReg | 0x10000); + _RegWrite(AO_RTI_GEN_PWR_SLEEP0, readReg); } void Downpower_a1(void) { /*C1 added power domain, it will down domain power when rmmod */ return; } +void Downpower_be(void) +{ + /*C2 added power domain, it will down domain power when rmmod */ + return; +} /* Runtime power manage */ void Runtime_getpower_88(struct platform_device *pdev) @@ -392,9 +404,24 @@ void Runtime_downpower_a1(struct platform_device *pdev) pm_runtime_disable(&pdev->dev); } +void Runtime_getpower_be(struct platform_device *pdev) +{ + int ret; + + pm_runtime_enable(&pdev->dev); + ret = pm_runtime_get_sync(&pdev->dev); + if (ret < 0) printk("===runtime getpower error===\n"); + set_clock(pdev); +} +void Runtime_downpower_be(struct platform_device *pdev) +{ + pm_runtime_put_sync(&pdev->dev); + pm_runtime_disable(&pdev->dev); +} gceSTATUS _GetPower(IN gcsPLATFORM *Platform) { struct platform_device *pdev = Platform->device; + powerStatus = POWER_IDLE; _InitDtsRegValue(Platform); switch (nn_power_version) { @@ -408,9 +435,14 @@ gceSTATUS _GetPower(IN gcsPLATFORM *Platform) case 3: Getpower_99(pdev); break; + case 4: + nanoqFreq=666*1024*1024; + Getpower_be(pdev); + break; default: printk("not find power_version\n"); } + powerStatus = POWER_ON; return gcvSTATUS_OK; } @@ -430,9 +462,14 @@ gceSTATUS _SetPower(IN gcsPLATFORM * Platform,IN gceCORE GPU,IN gctBOOL Enable) case 3: Runtime_downpower_99(); break; + case 4: + Runtime_downpower_be(pdev); + break; default: printk("not find power_version\n"); + break; } + powerStatus = POWER_OFF; } else { @@ -447,9 +484,14 @@ gceSTATUS _SetPower(IN gcsPLATFORM * Platform,IN gceCORE GPU,IN gctBOOL Enable) case 3: Runtime_getpower_99(pdev); break; + case 4: + Runtime_getpower_be(pdev); + break; default: printk("not find power_version\n"); + break; } + powerStatus = POWER_ON; } return gcvSTATUS_OK; } @@ -457,6 +499,7 @@ gceSTATUS _SetPower(IN gcsPLATFORM * Platform,IN gceCORE GPU,IN gctBOOL Enable) gceSTATUS _Reset(IN gcsPLATFORM * Platform, IN gceCORE GPU) { struct platform_device *pdev = Platform->device; + powerStatus = POWER_RESET; switch (nn_power_version) { case 1: @@ -474,8 +517,14 @@ gceSTATUS _Reset(IN gcsPLATFORM * Platform, IN gceCORE GPU) mdelay(10); Getpower_99(pdev); break; + case 4: + Runtime_downpower_be(pdev); + mdelay(10); + Runtime_getpower_be(pdev); + break; default: printk("not find power_version\n"); + break; } mdelay(2); printk("====>>>>npu hardware reset end!\n"); @@ -485,6 +534,7 @@ gceSTATUS _Reset(IN gcsPLATFORM * Platform, IN gceCORE GPU) printk("hardwareResetNum is too large over 10000,just set zero\n"); hardwareResetNum = 0; } + powerStatus = POWER_ON; return gcvSTATUS_OK; } @@ -501,9 +551,54 @@ gceSTATUS _DownPower(IN gcsPLATFORM *Platform) case 3: Downpower_99(); break; + case 4: + Downpower_be(); + break; default: printk("not find power_version\n"); + break; + } + powerStatus = POWER_OFF; + return gcvSTATUS_OK; +} + +gceSTATUS +_GetPowerStatus(IN gcsPLATFORM *Platform,OUT gctUINT32_PTR pstat) +{ + *pstat = powerStatus; + return gcvSTATUS_OK; +} + +gceSTATUS _SetPolicy(IN gcsPLATFORM *Platform,IN gctUINT32 powerLevel) +{ + switch (nn_power_version) + { + case 1: + nanoqFreq=666*1024*1024; + break; + case 2: + nanoqFreq=800000000; + break; + case 3: + nanoqFreq=800000000; + break; + case 4: + nanoqFreq=666*1024*1024; + break; + default: + nanoqFreq=800000000; + break; + } + + if (powerLevel == 2) + { + nanoqFreq = nanoqFreq/2; + } + else if (powerLevel == 3) + { + nanoqFreq = nanoqFreq/4; } + printk("nanoqFreq:%d\n",nanoqFreq); return gcvSTATUS_OK; } @@ -514,6 +609,8 @@ static gcsPLATFORM_OPERATIONS default_ops = .reset = _Reset, .putPower = _DownPower, .setPower = _SetPower, + .getPowerStatus = _GetPowerStatus, + .setPolicy = _SetPolicy, }; static gcsPLATFORM default_platform = diff --git a/drivers/amlogic/npu/os/linux/kernel/platform/amlogic/gc_hal_kernel_platform_amlogic.config b/drivers/amlogic/npu/os/linux/kernel/platform/amlogic/gc_hal_kernel_platform_amlogic.config old mode 100644 new mode 100755 diff --git a/drivers/amlogic/npu/os/linux/kernel/platform/amlogic/gc_hal_kernel_platform_c308x.c b/drivers/amlogic/npu/os/linux/kernel/platform/amlogic/gc_hal_kernel_platform_c308x.c index cbc6047..62de702 100644 --- a/drivers/amlogic/npu/os/linux/kernel/platform/amlogic/gc_hal_kernel_platform_c308x.c +++ b/drivers/amlogic/npu/os/linux/kernel/platform/amlogic/gc_hal_kernel_platform_c308x.c @@ -15,10 +15,9 @@ #include #include #include -#include -#include -#include #include +#include +#include #include "gc_hal_kernel_linux.h" #include "gc_hal_kernel_platform.h" @@ -31,93 +30,90 @@ /*======== power version 0 hardware reg begin ===========*/ #define AO_RTI_BASE 0xff800000 -#define AO_RTI_GEN_PWR_SLEEP0 (AO_RTI_BASE + (0x3a<<2)) //0xff8000e8 -#define AO_RTI_GEN_PWR_ISO0 (AO_RTI_BASE + (0x3b<<2)) //0xff8000ec +#define AO_RTI_GEN_PWR_SLEEP0 (AO_RTI_BASE + (0x3a<<2)) +#define AO_RTI_GEN_PWR_ISO0 (AO_RTI_BASE + (0x3b<<2)) /*======== power version 1 hardware reg begin ===========*/ #define P_PWRCTRL_ISO_EN1 0xfe007818 #define P_PWRCTRL_PWR_OFF1 0xfe00781c -static unsigned int HHI_NANOQ_MEM_PD_REG0 = 0xff63c10c; -static unsigned int HHI_NANOQ_MEM_PD_REG1 = 0xff63c110; -static unsigned int RESET_LEVEL2 = 0xffd01088;//RESET_LEVEL2 = P_PWRCTRL_FOCRSTN1 +static uint32_t HHI_NANOQ_MEM_PD_REG0 = 0xff63c10c; +static uint32_t HHI_NANOQ_MEM_PD_REG1 = 0xff63c110; +static uint32_t RESET_LEVEL2 = 0xffd01088; -static unsigned int NN_clk = 0xff63c1c8; -static unsigned int nn_power_version = 0; +static uint32_t NN_clk = 0xff63c1c8; +static uint32_t nn_power_version = 0; -//static unsigned int P_PWRCTRL_FOCRSTN1 = 0xfe007824 -//#define HHI_NANOQ_MEM_PD_REG0 0xfe0078a0 -//#define HHI_NANOQ_MEM_PD_REG1 0xfe0078a4 - - - - -//#define PWR_OFF 0 -//#define MAX_NANOQ_FREQ 800000000 static int hardwareResetNum = 0; module_param(hardwareResetNum, int, 0644); -//static int nanoqFreq = 800000000; -//module_param(nanoqFreq, int, 0644); +static int nanoqFreq = 800000000; +module_param(nanoqFreq, int, 0644); -static void _InitDtsRegValue(IN gcsPLATFORM *Platform) +gceSTATUS _InitDtsRegValue(IN gcsPLATFORM *Platform) { + int ret = 0; + struct resource *res = NULL; struct platform_device *pdev = Platform->device; - struct resource *res; - int ret; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 2); if (res) { - printk("reg resource 2, start: %ld,end: %lx\n",(unsigned long)res->start,(unsigned long)res->end); HHI_NANOQ_MEM_PD_REG0 = (unsigned long)res->start; + printk("reg resource 2, start: %lx,end: %lx\n",(unsigned long)res->start,(unsigned long)res->end); } res = platform_get_resource(pdev, IORESOURCE_MEM, 3); if (res) { - printk("reg resource 3, start: %ld,end: %lx\n",(unsigned long)res->start,(unsigned long)res->end); HHI_NANOQ_MEM_PD_REG1 = (unsigned long)res->start; + printk("reg resource 3, start: %lx,end: %lx\n",(unsigned long)res->start,(unsigned long)res->end); } res = platform_get_resource(pdev, IORESOURCE_MEM, 4); if (res) { - printk("reg resource 4, start: %ld,end: %lx\n",(unsigned long)res->start,(unsigned long)res->end); RESET_LEVEL2 = (unsigned long)res->start; + printk("reg resource 4, start: %lx,end: %lx\n",(unsigned long)res->start,(unsigned long)res->end); } + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "NN_CLK"); if (res) { - printk("reg resource NN_CLK, start: %ld,end: %lx\n",(unsigned long)res->start,(unsigned long)res->end); NN_clk = (unsigned long)res->start; + printk("reg resource NN_CLK, start: %lx,end: %lx\n",(unsigned long)res->start,(unsigned long)res->end); } + ret = of_property_read_u32(pdev->dev.of_node,"nn_power_version",&nn_power_version); - return; + printk("npu_version: %d\n",nn_power_version); + return gcvSTATUS_OK; } gceSTATUS _AdjustParam(IN gcsPLATFORM *Platform,OUT gcsMODULE_PARAMETERS *Args) { + struct resource *res = NULL; struct platform_device *pdev = Platform->device; - struct resource *res; int irqLine = platform_get_irq_byname(pdev, "galcore"); - printk("galcore irq number is %d.\n", irqLine); + if (irqLine >= 0) + printk("galcore irq number is %d.\n", irqLine); if (irqLine < 0) { printk("get galcore irq resource error\n"); irqLine = platform_get_irq(pdev, 0); printk("galcore irq number is %d\n", irqLine); + if (irqLine < 0) + return gcvSTATUS_OUT_OF_RESOURCES; } - if (irqLine < 0) return gcvSTATUS_OUT_OF_RESOURCES; Args->irqs[gcvCORE_MAJOR] = irqLine; + /*================read reg value from dts===============*/ res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (res) { - //printk("reg resource 0,start:%ld,end:%ld",(unsigned long)res->start,(unsigned long)res->end); Args->registerBases[0] = (gctPHYS_ADDR_T)res->start; Args->registerSizes[0] = (gctSIZE_T)(res->end - res->start+1); - //printk("read from dts,regbase:0x%llx,size:0x%lx\n",Args->registerBases[0],Args->registerSizes[0]); } else { @@ -129,62 +125,81 @@ gceSTATUS _AdjustParam(IN gcsPLATFORM *Platform,OUT gcsMODULE_PARAMETERS *Args) res = platform_get_resource(pdev, IORESOURCE_MEM, 1); if (res) { - //printk("reg resource 1,start:%ld,end:%ld",(unsigned long)res->start,(unsigned long)res->end); Args->extSRAMBases[0] = (gctPHYS_ADDR_T)res->start; -// Args->sRAMSizes[0][1] = 0x480000; + Args->contiguousBase = 0; - Args->contiguousSize = 0x400000; -// Args->contiguousSize = (gctSIZE_T)(res->end - res->start+1); + Args->contiguousSize = (gctSIZE_T)(res->end - res->start+1); } else { printk("no memory resource 1\n"); Args->contiguousBase = 0; Args->contiguousSize = 0x400000; - Args->extSRAMBases[0] = 0xFF000000; } - Args->registerSizes[0] = 0x20000; return gcvSTATUS_OK; } -int _RegWrite(unsigned int reg, unsigned int writeval) +gceSTATUS _RegWrite(uint32_t reg, uint32_t writeval) { - void __iomem *vaddr; + void __iomem *vaddr = NULL; reg = round_down(reg, 0x3); vaddr = ioremap(reg, 0x4); writel(writeval, vaddr); iounmap(vaddr); - return 0; + return gcvSTATUS_OK; } -int _RegRead(unsigned int reg,unsigned int *readval) +gceSTATUS _RegRead(uint32_t reg,uint32_t *readval) { - void __iomem *vaddr; + void __iomem *vaddr = NULL; reg = round_down(reg, 0x3); vaddr = ioremap(reg, 0x4); *readval = readl(vaddr); iounmap(vaddr); - return 0; + return gcvSTATUS_OK; +} +gceSTATUS get_nna_status(struct platform_device *dev) +{ + int ret = 0; + uint32_t readReg = 0; + uint32_t nn_ef[2]; + struct platform_device *pdev = dev; + + ret = of_property_read_u32_array(pdev->dev.of_node,"nn_efuse", &nn_ef[0], 2); + if (ret == 0) + { + _RegRead(nn_ef[0],&readReg); + readReg = (readReg & nn_ef[1]); + if (readReg == 0) + return gcvSTATUS_OK; + else + return gcvSTATUS_MISMATCH; + } + else + { + return gcvSTATUS_OK; + } } //us -void delay(unsigned int time) +void delay(uint32_t time) { - int i,j; - for(j=0;j<1000;j++) + int i = 0,j = 0; + for (j=0;j<1000;j++) { - for(i = 0;idev, "cts_vipnanoq_axi_clk_composite"); if (IS_ERR(npu_axi_clk)) - { + { printk("%s: get npu_axi_clk error!!!\n", __func__); return; } @@ -206,227 +221,256 @@ static void set_clock(struct platform_device *pdev) } clk_set_rate(npu_core_clk, nanoqFreq); return; -}*/ -gceSTATUS _GetPower(IN gcsPLATFORM *Platform) +} + +/* Getpower: enable the nna power for platform */ +void Getpower_88(struct platform_device *pdev) { - unsigned int readReg=0; - _InitDtsRegValue(Platform); - if (nn_power_version == 1) - { - _RegRead(RESET_LEVEL2,&readReg); - readReg = (readReg & (~(1<<3))); - _RegWrite(RESET_LEVEL2, readReg); + uint32_t readReg = 0; + _RegRead(AO_RTI_GEN_PWR_SLEEP0,&readReg); + readReg = (readReg & 0xfffcffff); + _RegWrite(AO_RTI_GEN_PWR_SLEEP0, readReg); - _RegRead(P_PWRCTRL_PWR_OFF1,&readReg); - readReg = (readReg & (~(1<<3))); - _RegWrite(P_PWRCTRL_PWR_OFF1, readReg); + _RegWrite(HHI_NANOQ_MEM_PD_REG0, 0x0); + _RegWrite(HHI_NANOQ_MEM_PD_REG1, 0x0); - _RegWrite(HHI_NANOQ_MEM_PD_REG0, 0x0); - _RegWrite(HHI_NANOQ_MEM_PD_REG1, 0x0); + _RegRead(RESET_LEVEL2,&readReg); + readReg = (readReg & 0xffffefff); + _RegWrite(RESET_LEVEL2, readReg); - _RegRead(P_PWRCTRL_ISO_EN1,&readReg); - readReg = (readReg & (~(1<<3))); - _RegWrite(P_PWRCTRL_ISO_EN1, readReg); + _RegRead(AO_RTI_GEN_PWR_ISO0,&readReg); + readReg = (readReg & 0xfffcffff); + _RegWrite(AO_RTI_GEN_PWR_ISO0, readReg); - _RegRead(RESET_LEVEL2,&readReg); - readReg = (readReg | (1<<3)); - _RegWrite(RESET_LEVEL2, readReg); + _RegRead(RESET_LEVEL2,&readReg); + readReg = (readReg | (0x1<<12)); + _RegWrite(RESET_LEVEL2, readReg); - _RegWrite(NN_clk, 0x3000300); - } - else - { - _RegRead(AO_RTI_GEN_PWR_SLEEP0,&readReg); - readReg = (readReg & 0xfffcffff); - _RegWrite(AO_RTI_GEN_PWR_SLEEP0, readReg); + set_clock(pdev); +} +void Getpower_99(struct platform_device *pdev) +{ + uint32_t readReg = 0; + _RegRead(AO_RTI_GEN_PWR_SLEEP0,&readReg); + readReg = (readReg & 0xfffeffff); + _RegWrite(AO_RTI_GEN_PWR_SLEEP0, readReg); - _RegWrite(HHI_NANOQ_MEM_PD_REG0, 0x0); - _RegWrite(HHI_NANOQ_MEM_PD_REG1, 0x0); + _RegWrite(HHI_NANOQ_MEM_PD_REG0, 0x0); + _RegWrite(HHI_NANOQ_MEM_PD_REG1, 0x0); - _RegRead(RESET_LEVEL2,&readReg); - readReg = (readReg & 0xffffefff); - _RegWrite(RESET_LEVEL2, readReg); + _RegRead(RESET_LEVEL2,&readReg); + readReg = (readReg & 0xffffefff); + _RegWrite(RESET_LEVEL2, readReg); - _RegRead(AO_RTI_GEN_PWR_ISO0,&readReg); - readReg = (readReg & 0xfffcffff); - _RegWrite(AO_RTI_GEN_PWR_ISO0, readReg); + _RegRead(AO_RTI_GEN_PWR_ISO0,&readReg); + readReg = (readReg & 0xfffeffff); + _RegWrite(AO_RTI_GEN_PWR_ISO0, readReg); - _RegRead(RESET_LEVEL2,&readReg); - readReg = (readReg | (0x1<<12)); - _RegWrite(RESET_LEVEL2, readReg); + _RegRead(RESET_LEVEL2,&readReg); + readReg = (readReg | (0x1<<12)); + _RegWrite(RESET_LEVEL2, readReg); -// set_clock(Platform->device); - _RegWrite(NN_clk, 0x7000700); - } - return gcvSTATUS_OK; + set_clock(pdev); } - -gceSTATUS _DownPower(IN gcsPLATFORM *Platform) +void Getpower_a1(struct platform_device *pdev) { + /*C1 added power domain, it will get domain power when prob*/ + set_clock(pdev); + return; +} - unsigned int readReg=0; - printk("====>>>>downpower for putpower\n"); - if (nn_power_version == 1) - { - _RegRead(P_PWRCTRL_ISO_EN1,&readReg); - readReg = (readReg | (1<<3)); - _RegWrite(P_PWRCTRL_ISO_EN1, readReg); - - _RegWrite(HHI_NANOQ_MEM_PD_REG0, 0xffffffff); - _RegWrite(HHI_NANOQ_MEM_PD_REG1, 0xffffffff); +/* Downpower: disable nna power for platform */ - _RegRead(P_PWRCTRL_PWR_OFF1,&readReg); - readReg = (readReg | (1<<3)); - _RegWrite(P_PWRCTRL_PWR_OFF1, readReg); - } - else - { - _RegRead(AO_RTI_GEN_PWR_ISO0,&readReg); - readReg = (readReg | 0x30000); - _RegWrite(AO_RTI_GEN_PWR_ISO0, readReg); +void Downpower_88(void) +{ + uint32_t readReg = 0; + _RegRead(AO_RTI_GEN_PWR_ISO0,&readReg); + readReg = (readReg | 0x30000); + _RegWrite(AO_RTI_GEN_PWR_ISO0, readReg); - _RegWrite(HHI_NANOQ_MEM_PD_REG0, 0xffffffff); - _RegWrite(HHI_NANOQ_MEM_PD_REG1, 0xffffffff); + _RegWrite(HHI_NANOQ_MEM_PD_REG0, 0xffffffff); + _RegWrite(HHI_NANOQ_MEM_PD_REG1, 0xffffffff); - _RegRead(AO_RTI_GEN_PWR_SLEEP0,&readReg); - readReg = (readReg | 0x30000); - _RegWrite(AO_RTI_GEN_PWR_SLEEP0, readReg); - } - return gcvSTATUS_OK; + _RegRead(AO_RTI_GEN_PWR_SLEEP0,&readReg); + readReg = (readReg | 0x30000); + _RegWrite(AO_RTI_GEN_PWR_SLEEP0, readReg); } - -gceSTATUS _Reset(IN gcsPLATFORM * Platform, IN gceCORE GPU) +void Downpower_99(void) { unsigned int readReg=0; - printk("====>>>>begin npu hardware reset!\n"); - _RegWrite(RESET_LEVEL2, 0xffffefff); - /*==========power off=============*/ - _RegWrite(HHI_NANOQ_MEM_PD_REG0, 0xffffffff); - _RegWrite(HHI_NANOQ_MEM_PD_REG1, 0xffffffff); + _RegRead(RESET_LEVEL2,&readReg); + readReg = (readReg & (~(0x1<<12))); + _RegWrite(RESET_LEVEL2, readReg); + _RegRead(AO_RTI_GEN_PWR_ISO0,&readReg); - readReg = (readReg | 0x30000); + readReg = (readReg | 0x10000); _RegWrite(AO_RTI_GEN_PWR_ISO0, readReg); - _RegRead(AO_RTI_GEN_PWR_SLEEP0,&readReg); - readReg = (readReg | 0x30000); - _RegWrite(AO_RTI_GEN_PWR_SLEEP0, readReg); + _RegWrite(HHI_NANOQ_MEM_PD_REG0, 0xffffffff); + _RegWrite(HHI_NANOQ_MEM_PD_REG1, 0xffffffff); - mdelay(10); - /*==========power on===============*/ _RegRead(AO_RTI_GEN_PWR_SLEEP0,&readReg); - readReg = (readReg & 0xfffcffff); + readReg = (readReg | 0x10000); _RegWrite(AO_RTI_GEN_PWR_SLEEP0, readReg); - _RegRead(AO_RTI_GEN_PWR_ISO0,&readReg); - readReg = (readReg & 0xfffcffff); - _RegWrite(AO_RTI_GEN_PWR_ISO0, readReg); - _RegWrite(HHI_NANOQ_MEM_PD_REG0, 0x0); - _RegWrite(HHI_NANOQ_MEM_PD_REG1, 0x0); - _RegWrite(NN_clk, 0x3000300); -// set_clock(Platform->device); - mdelay(1); - _RegWrite(RESET_LEVEL2, 0xffffffff); - mdelay(2); - printk("====>>>>npu hardware reset end!\n"); - hardwareResetNum++; - if(hardwareResetNum > 10000) +} +void Downpower_a1(void) +{ + /*C1 added power domain, it will down domain power when rmmod */ + return; +} + +/* Runtime power manage */ +void Runtime_getpower_88(struct platform_device *pdev) +{ + Getpower_88(pdev); +} +void Runtime_downpower_88(void) +{ + Downpower_88(); +} +void Runtime_getpower_99(struct platform_device *pdev) +{ + Getpower_99(pdev); +} +void Runtime_downpower_99(void) +{ + Downpower_99(); +} +void Runtime_getpower_a1(struct platform_device *pdev) +{ + int ret; + pm_runtime_enable(&pdev->dev); + ret = pm_runtime_get_sync(&pdev->dev); + if (ret < 0) printk("===runtime getpower error===\n"); + set_clock(pdev); +} +void Runtime_downpower_a1(struct platform_device *pdev) +{ + pm_runtime_put_sync(&pdev->dev); + pm_runtime_disable(&pdev->dev); +} + +gceSTATUS _GetPower(IN gcsPLATFORM *Platform) +{ + struct platform_device *pdev = Platform->device; + _InitDtsRegValue(Platform); + switch (nn_power_version) { - printk("hardwareResetNum is too large over 10000,just set zero\n"); - hardwareResetNum = 0; + case 1: + nanoqFreq=666*1024*1024; + Getpower_a1(pdev); + break; + case 2: + Getpower_88(pdev); + break; + case 3: + Getpower_99(pdev); + break; + default: + printk("not find power_version\n"); } - - return gcvSTATUS_OK; //gcvSTATUS_NOT_SUPPORTED; + return gcvSTATUS_OK; } gceSTATUS _SetPower(IN gcsPLATFORM * Platform,IN gceCORE GPU,IN gctBOOL Enable) { - unsigned int readReg=0; - printk("_setpower,control status:%d\n",Enable); - if (nn_power_version == 1) + struct platform_device *pdev = Platform->device; + if (Enable == 0) { - if(Enable == 0) - { - printk("====>>>>poweroff in _SetPower\n"); - _RegRead(P_PWRCTRL_ISO_EN1,&readReg); - readReg = (readReg | (1<<3)); - _RegWrite(P_PWRCTRL_ISO_EN1, readReg); - - _RegWrite(HHI_NANOQ_MEM_PD_REG0, 0xffffffff); - _RegWrite(HHI_NANOQ_MEM_PD_REG1, 0xffffffff); - - _RegRead(P_PWRCTRL_PWR_OFF1,&readReg); - readReg = (readReg | (1<<3)); - _RegWrite(P_PWRCTRL_PWR_OFF1, readReg); - } - else + switch (nn_power_version) { - printk("====>>>>poweron in _SetPower\n"); - _RegRead(RESET_LEVEL2,&readReg); - readReg = (readReg & (~(1<<3))); - _RegWrite(RESET_LEVEL2, readReg); - - _RegRead(P_PWRCTRL_PWR_OFF1,&readReg); - readReg = (readReg & (~(1<<3))); - _RegWrite(P_PWRCTRL_PWR_OFF1, readReg); - - _RegWrite(HHI_NANOQ_MEM_PD_REG0, 0x0); - _RegWrite(HHI_NANOQ_MEM_PD_REG1, 0x0); - - _RegRead(P_PWRCTRL_ISO_EN1,&readReg); - readReg = (readReg & (~(1<<3))); - _RegWrite(P_PWRCTRL_ISO_EN1, readReg); - - _RegRead(RESET_LEVEL2,&readReg); - readReg = (readReg | (1<<3)); - _RegWrite(RESET_LEVEL2, readReg); - - _RegWrite(NN_clk, 0x3000300); + case 1: + Runtime_downpower_a1(pdev); + break; + case 2: + Runtime_downpower_88(); + break; + case 3: + Runtime_downpower_99(); + break; + default: + printk("not find power_version\n"); } } else { - if(Enable == 0) + switch (nn_power_version) { - printk("====>>>>poweroff in _SetPower\n"); - _RegRead(AO_RTI_GEN_PWR_ISO0,&readReg); - readReg = (readReg | 0x30000); - _RegWrite(AO_RTI_GEN_PWR_ISO0, readReg); - _RegWrite(HHI_NANOQ_MEM_PD_REG0, 0xffffffff); - _RegWrite(HHI_NANOQ_MEM_PD_REG1, 0xffffffff); - _RegRead(AO_RTI_GEN_PWR_SLEEP0,&readReg); - readReg = (readReg | 0x30000); - _RegWrite(AO_RTI_GEN_PWR_SLEEP0, readReg); - } - else - { - printk("====>>>>poweron in _SetPower\n"); - _RegRead(AO_RTI_GEN_PWR_SLEEP0,&readReg); - readReg = (readReg & 0xfffcffff); - _RegWrite(AO_RTI_GEN_PWR_SLEEP0, readReg); - _RegWrite(HHI_NANOQ_MEM_PD_REG0, 0x0); - _RegWrite(HHI_NANOQ_MEM_PD_REG1, 0x0); - _RegRead(RESET_LEVEL2,&readReg); - readReg = (readReg & 0xffffefff); - _RegWrite(RESET_LEVEL2, readReg); - _RegRead(AO_RTI_GEN_PWR_ISO0,&readReg); - readReg = (readReg & 0xfffcffff); - _RegWrite(AO_RTI_GEN_PWR_ISO0, readReg); - _RegRead(RESET_LEVEL2,&readReg); - readReg = (readReg | (0x1<<12)); - _RegWrite(RESET_LEVEL2, readReg); - _RegWrite(NN_clk, 0x7000700); + case 1: + Runtime_getpower_a1(pdev); + break; + case 2: + Runtime_getpower_88(pdev); + break; + case 3: + Runtime_getpower_99(pdev); + break; + default: + printk("not find power_version\n"); } } + return gcvSTATUS_OK; +} +gceSTATUS _Reset(IN gcsPLATFORM * Platform, IN gceCORE GPU) +{ + struct platform_device *pdev = Platform->device; + switch (nn_power_version) + { + case 1: + Runtime_downpower_a1(pdev); + mdelay(10); + Runtime_getpower_a1(pdev); + break; + case 2: + Downpower_88(); + mdelay(10); + Getpower_88(pdev); + break; + case 3: + Downpower_99(); + mdelay(10); + Getpower_99(pdev); + break; + default: + printk("not find power_version\n"); + } + mdelay(2); + printk("====>>>>npu hardware reset end!\n"); + hardwareResetNum++; + if (hardwareResetNum > 10000) + { + printk("hardwareResetNum is too large over 10000,just set zero\n"); + hardwareResetNum = 0; + } return gcvSTATUS_OK; } +gceSTATUS _DownPower(IN gcsPLATFORM *Platform) +{ + switch (nn_power_version) + { + case 1: + Downpower_a1(); + break; + case 2: + Downpower_88(); + break; + case 3: + Downpower_99(); + break; + default: + printk("not find power_version\n"); + } + return gcvSTATUS_OK; +} static gcsPLATFORM_OPERATIONS default_ops = { .adjustParam = _AdjustParam, .getPower = _GetPower, -// .reset = _Reset, + .reset = _Reset, .putPower = _DownPower, .setPower = _SetPower, }; @@ -465,4 +509,3 @@ int gckPLATFORM_Terminate(gcsPLATFORM *platform) return 0; } - diff --git a/drivers/amlogic/npu/os/linux/kernel/platform/amlogic/gc_hal_kernel_platform_c308x.config b/drivers/amlogic/npu/os/linux/kernel/platform/amlogic/gc_hal_kernel_platform_c308x.config old mode 100644 new mode 100755 diff --git a/drivers/amlogic/npu/os/linux/kernel/platform/amlogic/gc_hal_kernel_platform_pico.config b/drivers/amlogic/npu/os/linux/kernel/platform/amlogic/gc_hal_kernel_platform_pico.config old mode 100644 new mode 100755 diff --git a/drivers/amlogic/npu/os/linux/kernel/platform/amlogic/gc_hal_kernel_platform_vim3.c b/drivers/amlogic/npu/os/linux/kernel/platform/amlogic/gc_hal_kernel_platform_vim3.c new file mode 100644 index 0000000..b173d09 --- /dev/null +++ b/drivers/amlogic/npu/os/linux/kernel/platform/amlogic/gc_hal_kernel_platform_vim3.c @@ -0,0 +1,179 @@ +/**************************************************************************** +* +* Copyright (c) 2005 - 2020 by Vivante Corp. All rights reserved. +* +* The material in this file is confidential and contains trade secrets +* of Vivante Corporation. This is proprietary information owned by +* Vivante Corporation. No part of this work may be disclosed, +* reproduced, copied, transmitted, or used in any way for any purpose, +* without the express written permission of Vivante Corporation. +* +*****************************************************************************/ + + +#include +#include +#include +#include +#include +#include "gc_hal_kernel_linux.h" +#include "gc_hal_kernel_platform.h" + +/*========add by zxw for g12b hardware reg define========*/ +#define AO_RTI_BASE 0xff800000 +#define AO_RTI_GEN_PWR_SLEEP0 (AO_RTI_BASE + (0x3a<<2)) //0xff8000e8 +#define AO_RTI_GEN_PWR_ISO0 (AO_RTI_BASE + (0x3b<<2)) //0xff8000ec + +#define HHI_BASE_ADDR 0xff63c000 +#define HHI_NANOQ_MEM_PD_REG0 (HHI_BASE_ADDR+(0x43<<2)) +#define HHI_NANOQ_MEM_PD_REG1 (HHI_BASE_ADDR+(0x44<<2)) + +#define MAX_NANOQ_FREQ 800000000 + +gceSTATUS +_AdjustParam( + IN gcsPLATFORM *Platform, + OUT gcsMODULE_PARAMETERS *Args + ) +{ + struct platform_device *pdev = Platform->device; + int irqLine = platform_get_irq_byname(pdev, "galcore"); + + printk("galcore irq number is %d.\n", irqLine); + if (irqLine< 0) { + printk("get galcore irq resource error\n"); + irqLine = platform_get_irq(pdev, 0); + printk("galcore irq number is %d\n", irqLine); + } + if (irqLine < 0) return gcvSTATUS_OUT_OF_RESOURCES; + + Args->irqs[gcvCORE_MAJOR] = irqLine; + + Args->contiguousBase = 0; + Args->contiguousSize = 0x01000000; + + Args->extSRAMBases[0] = 0xFF000000; + + Args->registerBases[0] = 0xFF100000; + Args->registerSizes[0] = 0x20000; + + return gcvSTATUS_OK; +} + +int _RegWrite(unsigned int reg, unsigned int writeval) +{ + void __iomem *vaddr; + reg = round_down(reg, 0x3); + + vaddr = ioremap(reg, 0x4); + writel(writeval, vaddr); + iounmap(vaddr); + + return 0; +} + +int _RegRead(unsigned int reg,unsigned int *readval) +{ + void __iomem *vaddr; + reg = round_down(reg, 0x3); + vaddr = ioremap(reg, 0x4); + *readval = readl(vaddr); + iounmap(vaddr); + return 0; +} +//us +void delay(unsigned int time) +{ + int i,j; + for(j=0;j<1000;j++) + { + for(i = 0;idev, "cts_vipnanoq_axi_clk_composite"); + if (IS_ERR(npu_axi_clk)) + { + printk("%s: get npu_axi_clk error!!!\n", __func__); + return; + } + else + { + clk_prepare_enable(npu_axi_clk); + } + clk_set_rate(npu_axi_clk, MAX_NANOQ_FREQ); + + npu_core_clk = clk_get(&pdev->dev, "cts_vipnanoq_core_clk_composite"); + if (IS_ERR(npu_core_clk)) + { + printk("%s: get npu_core_clk error!!!\n", __func__); + return; + } + else + { + clk_prepare_enable(npu_core_clk); + } + clk_set_rate(npu_core_clk, MAX_NANOQ_FREQ); + return; +} +gceSTATUS +_GetPower(IN gcsPLATFORM *Platform) +{ + unsigned int readReg=0; + _RegRead(AO_RTI_GEN_PWR_SLEEP0,&readReg); + readReg = (readReg & 0xfffcffff); + _RegWrite(AO_RTI_GEN_PWR_SLEEP0, readReg); + _RegRead(AO_RTI_GEN_PWR_ISO0,&readReg); + readReg = (readReg & 0xfffcffff); + _RegWrite(AO_RTI_GEN_PWR_ISO0, readReg); + _RegWrite(HHI_NANOQ_MEM_PD_REG0, 0x0); + _RegWrite(HHI_NANOQ_MEM_PD_REG1, 0x0); + set_clock(Platform->device); + delay(500); + return gcvSTATUS_OK; +} + +static struct _gcsPLATFORM_OPERATIONS default_ops = +{ + .adjustParam = _AdjustParam, + .getPower = _GetPower, +}; + +static struct _gcsPLATFORM default_platform = +{ + .name = __FILE__, + .ops = &default_ops, +}; + +static struct platform_device *default_dev; + +static const +struct of_device_id galcore_dev_match[] = { + { + .compatible = "amlogic, galcore" + }, + { }, +}; + +int gckPLATFORM_Init(struct platform_driver *pdrv, + struct _gcsPLATFORM **platform) +{ + pdrv->driver.of_match_table = galcore_dev_match; + + *platform = &default_platform; + return 0; +} + +int gckPLATFORM_Terminate(struct _gcsPLATFORM *platform) +{ + if (default_dev) { + platform_device_unregister(default_dev); + default_dev = NULL; + } + + return 0; +} diff --git a/drivers/amlogic/npu/os/linux/kernel/platform/amlogic/gc_hal_kernel_platform_vim3.config b/drivers/amlogic/npu/os/linux/kernel/platform/amlogic/gc_hal_kernel_platform_vim3.config new file mode 100755 index 0000000..a01a43fc --- /dev/null +++ b/drivers/amlogic/npu/os/linux/kernel/platform/amlogic/gc_hal_kernel_platform_vim3.config @@ -0,0 +1,4 @@ +ifeq ($(USE_LINUX_PCIE), 1) +EXTRA_CFLAGS +=-DgcdIRQ_SHARED +endif +EXTRA_CFLAGS += -DNO_DMA_COHERENT=1 diff --git a/drivers/amlogic/npu/os/linux/kernel/platform/default/gc_hal_kernel_platform_default.config b/drivers/amlogic/npu/os/linux/kernel/platform/default/gc_hal_kernel_platform_default.config old mode 100644 new mode 100755 diff --git a/drivers/amlogic/npu/os/linux/user/Android.mk b/drivers/amlogic/npu/os/linux/user/Android.mk deleted file mode 100644 index f75e93f..0000000 --- a/drivers/amlogic/npu/os/linux/user/Android.mk +++ /dev/null @@ -1,62 +0,0 @@ -############################################################################## -# -# Copyright (c) 2005 - 2019 by Vivante Corp. All rights reserved. -# -# The material in this file is confidential and contains trade secrets -# of Vivante Corporation. This is proprietary information owned by -# Vivante Corporation. No part of this work may be disclosed, -# reproduced, copied, transmitted, or used in any way for any purpose, -# without the express written permission of Vivante Corporation. -# -############################################################################## - - -LOCAL_PATH := $(call my-dir) -include $(LOCAL_PATH)/../../../../Android.mk.def - -include $(CLEAR_VARS) - -platform_option := \ - platform/$(soc_vendor)/gc_hal_user_platform_$(soc_board).c - -ifeq ($(wildcard $(LOCAL_PATH)/$(platform_option)),) - platform_option := platform/default/gc_hal_user_platform_default.c -endif - -LOCAL_SRC_FILES := \ - gc_hal_user_debug.c \ - gc_hal_user_os.c \ - gc_hal_user_math.c \ - $(platform_option) - -LOCAL_CFLAGS := \ - $(CFLAGS) \ - -Werror - -LOCAL_C_INCLUDES := \ - $(AQROOT)/hal/inc \ - $(AQROOT)/hal/user \ - $(AQROOT)/hal/os/linux/user - -ifeq ($(VIVANTE_ENABLE_3D),1) -LOCAL_C_INCLUDES += \ - $(AQROOT)/compiler/libVSC/include -endif - -ifeq ($(shell expr $(PLATFORM_SDK_VERSION) ">=" 20),1) -LOCAL_C_INCLUDES += \ - system/core/libsync/include -endif - -ifeq ($(shell expr $(PLATFORM_SDK_VERSION) ">=" 28),1) -LOCAL_C_INCLUDES += \ - system/core/include -endif - -LOCAL_MODULE := libhalosuser -LOCAL_MODULE_TAGS := optional -ifeq ($(PLATFORM_VENDOR),1) -LOCAL_VENDOR_MODULE := true -endif -include $(BUILD_STATIC_LIBRARY) - diff --git a/drivers/amlogic/npu/os/linux/user/bin_r/gc_hal_user_debug.d b/drivers/amlogic/npu/os/linux/user/bin_r/gc_hal_user_debug.d deleted file mode 100644 index 2a2df99..0000000 --- a/drivers/amlogic/npu/os/linux/user/bin_r/gc_hal_user_debug.d +++ /dev/null @@ -1,33 +0,0 @@ -bin_r/gc_hal_user_debug.o: gc_hal_user_debug.c gc_hal_user_linux.h \ - /home/nick/code/fenix/nanoq/hal/user/gc_hal_user.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_types.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_version.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_options.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_enum.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_base.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_debug_zones.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_profiler.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_driver.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_statistics.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_driver.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_enum.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_dump.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_base.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_priv.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_raster.h \ - /home/nick/code/fenix/nanoq/hal/os/linux/user/gc_hal_user_math.h \ - /home/nick/code/fenix/nanoq/hal/os/linux/user/gc_hal_user_os_memory.h \ - /home/nick/code/fenix/nanoq/hal/os/linux/user/gc_hal_user_os_atomic.h \ - /home/nick/code/fenix/nanoq/hal/os/linux/user/gc_hal_user_debug.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_engine.h \ - /home/nick/code/fenix/nanoq/hal/inc/drvi/gc_vsc_drvi_interface.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_vsc_precomp.h \ - /home/nick/code/fenix/nanoq/hal/inc/old_impl/gc_vsc_old_drvi_interface.h \ - /home/nick/code/fenix/nanoq/hal/inc/old_impl/gc_vsc_old_gcsl.h \ - /home/nick/code/fenix/nanoq/hal/inc/drvi/gc_vsc_drvi_lib_link.h \ - /home/nick/code/fenix/nanoq/hal/inc/drvi/gc_vsc_drvi_shader_priv_mapping.h \ - /home/nick/code/fenix/nanoq/hal/inc/drvi/gc_vsc_drvi_shader_profile.h \ - /home/nick/code/fenix/nanoq/hal/inc/drvi/gc_vsc_drvi_program_profile.h \ - /home/nick/code/fenix/nanoq/hal/inc/drvi/gc_vsc_drvi_kernel_profile.h \ - /home/nick/code/fenix/nanoq/hal/user/gc_hal_user_shader.h diff --git a/drivers/amlogic/npu/os/linux/user/bin_r/gc_hal_user_math.d b/drivers/amlogic/npu/os/linux/user/bin_r/gc_hal_user_math.d deleted file mode 100644 index bbb9772..0000000 --- a/drivers/amlogic/npu/os/linux/user/bin_r/gc_hal_user_math.d +++ /dev/null @@ -1,34 +0,0 @@ -bin_r/gc_hal_user_math.o: gc_hal_user_math.c \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_types.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_version.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_options.h gc_hal_user_math.h \ - gc_hal_user_linux.h /home/nick/code/fenix/nanoq/hal/user/gc_hal_user.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_types.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_enum.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_base.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_debug_zones.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_profiler.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_driver.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_statistics.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_driver.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_enum.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_dump.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_base.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_priv.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_raster.h \ - /home/nick/code/fenix/nanoq/hal/os/linux/user/gc_hal_user_math.h \ - /home/nick/code/fenix/nanoq/hal/os/linux/user/gc_hal_user_os_memory.h \ - /home/nick/code/fenix/nanoq/hal/os/linux/user/gc_hal_user_os_atomic.h \ - /home/nick/code/fenix/nanoq/hal/os/linux/user/gc_hal_user_debug.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_engine.h \ - /home/nick/code/fenix/nanoq/hal/inc/drvi/gc_vsc_drvi_interface.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_vsc_precomp.h \ - /home/nick/code/fenix/nanoq/hal/inc/old_impl/gc_vsc_old_drvi_interface.h \ - /home/nick/code/fenix/nanoq/hal/inc/old_impl/gc_vsc_old_gcsl.h \ - /home/nick/code/fenix/nanoq/hal/inc/drvi/gc_vsc_drvi_lib_link.h \ - /home/nick/code/fenix/nanoq/hal/inc/drvi/gc_vsc_drvi_shader_priv_mapping.h \ - /home/nick/code/fenix/nanoq/hal/inc/drvi/gc_vsc_drvi_shader_profile.h \ - /home/nick/code/fenix/nanoq/hal/inc/drvi/gc_vsc_drvi_program_profile.h \ - /home/nick/code/fenix/nanoq/hal/inc/drvi/gc_vsc_drvi_kernel_profile.h \ - /home/nick/code/fenix/nanoq/hal/user/gc_hal_user_shader.h diff --git a/drivers/amlogic/npu/os/linux/user/bin_r/gc_hal_user_os.d b/drivers/amlogic/npu/os/linux/user/bin_r/gc_hal_user_os.d deleted file mode 100644 index 1506ffe..0000000 --- a/drivers/amlogic/npu/os/linux/user/bin_r/gc_hal_user_os.d +++ /dev/null @@ -1,34 +0,0 @@ -bin_r/gc_hal_user_os.o: gc_hal_user_os.c gc_hal_user_linux.h \ - /home/nick/code/fenix/nanoq/hal/user/gc_hal_user.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_types.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_version.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_options.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_enum.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_base.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_debug_zones.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_profiler.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_driver.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_statistics.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_driver.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_enum.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_dump.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_base.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_priv.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_raster.h \ - /home/nick/code/fenix/nanoq/hal/os/linux/user/gc_hal_user_math.h \ - /home/nick/code/fenix/nanoq/hal/os/linux/user/gc_hal_user_os_memory.h \ - /home/nick/code/fenix/nanoq/hal/os/linux/user/gc_hal_user_os_atomic.h \ - /home/nick/code/fenix/nanoq/hal/os/linux/user/gc_hal_user_debug.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_engine.h \ - /home/nick/code/fenix/nanoq/hal/inc/drvi/gc_vsc_drvi_interface.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_vsc_precomp.h \ - /home/nick/code/fenix/nanoq/hal/inc/old_impl/gc_vsc_old_drvi_interface.h \ - /home/nick/code/fenix/nanoq/hal/inc/old_impl/gc_vsc_old_gcsl.h \ - /home/nick/code/fenix/nanoq/hal/inc/drvi/gc_vsc_drvi_lib_link.h \ - /home/nick/code/fenix/nanoq/hal/inc/drvi/gc_vsc_drvi_shader_priv_mapping.h \ - /home/nick/code/fenix/nanoq/hal/inc/drvi/gc_vsc_drvi_shader_profile.h \ - /home/nick/code/fenix/nanoq/hal/inc/drvi/gc_vsc_drvi_program_profile.h \ - /home/nick/code/fenix/nanoq/hal/inc/drvi/gc_vsc_drvi_kernel_profile.h \ - /home/nick/code/fenix/nanoq/hal/user/gc_hal_user_shader.h \ - gc_hal_user_os_atomic.h gc_hal_user_platform.h diff --git a/drivers/amlogic/npu/os/linux/user/bin_r/gc_hal_user_platform_default.d b/drivers/amlogic/npu/os/linux/user/bin_r/gc_hal_user_platform_default.d deleted file mode 100644 index f0d8afb..0000000 --- a/drivers/amlogic/npu/os/linux/user/bin_r/gc_hal_user_platform_default.d +++ /dev/null @@ -1,36 +0,0 @@ -bin_r/gc_hal_user_platform_default.o: \ - platform/default/gc_hal_user_platform_default.c \ - /home/nick/code/fenix/nanoq/hal/os/linux/user/gc_hal_user_linux.h \ - /home/nick/code/fenix/nanoq/hal/user/gc_hal_user.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_types.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_version.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_options.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_enum.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_base.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_debug_zones.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_profiler.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_driver.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_statistics.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_driver.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_enum.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_dump.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_base.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_priv.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_raster.h \ - /home/nick/code/fenix/nanoq/hal/os/linux/user/gc_hal_user_math.h \ - /home/nick/code/fenix/nanoq/hal/os/linux/user/gc_hal_user_os_memory.h \ - /home/nick/code/fenix/nanoq/hal/os/linux/user/gc_hal_user_os_atomic.h \ - /home/nick/code/fenix/nanoq/hal/os/linux/user/gc_hal_user_debug.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_hal_engine.h \ - /home/nick/code/fenix/nanoq/hal/inc/drvi/gc_vsc_drvi_interface.h \ - /home/nick/code/fenix/nanoq/hal/inc/gc_vsc_precomp.h \ - /home/nick/code/fenix/nanoq/hal/inc/old_impl/gc_vsc_old_drvi_interface.h \ - /home/nick/code/fenix/nanoq/hal/inc/old_impl/gc_vsc_old_gcsl.h \ - /home/nick/code/fenix/nanoq/hal/inc/drvi/gc_vsc_drvi_lib_link.h \ - /home/nick/code/fenix/nanoq/hal/inc/drvi/gc_vsc_drvi_shader_priv_mapping.h \ - /home/nick/code/fenix/nanoq/hal/inc/drvi/gc_vsc_drvi_shader_profile.h \ - /home/nick/code/fenix/nanoq/hal/inc/drvi/gc_vsc_drvi_program_profile.h \ - /home/nick/code/fenix/nanoq/hal/inc/drvi/gc_vsc_drvi_kernel_profile.h \ - /home/nick/code/fenix/nanoq/hal/user/gc_hal_user_shader.h \ - /home/nick/code/fenix/nanoq/hal/os/linux/user/gc_hal_user_platform.h diff --git a/drivers/amlogic/npu/os/linux/user/gc_hal_user_debug.c b/drivers/amlogic/npu/os/linux/user/gc_hal_user_debug.c deleted file mode 100644 index afdb34f..0000000 --- a/drivers/amlogic/npu/os/linux/user/gc_hal_user_debug.c +++ /dev/null @@ -1,2103 +0,0 @@ -/**************************************************************************** -* -* Copyright (c) 2005 - 2019 by Vivante Corp. All rights reserved. -* -* The material in this file is confidential and contains trade secrets -* of Vivante Corporation. This is proprietary information owned by -* Vivante Corporation. No part of this work may be disclosed, -* reproduced, copied, transmitted, or used in any way for any purpose, -* without the express written permission of Vivante Corporation. -* -*****************************************************************************/ - - -/** -** @file -** Debug code for hal user layers. -** -*/ - -#include "gc_hal_user_linux.h" -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef ANDROID -#include -#include - -#if (ANDROID_SDK_VERSION >= 18) -#define ATRACE_TAG ATRACE_TAG_GRAPHICS -#include -#endif - -#endif - - -/* - gcdDEBUG_IN_KERNEL - - If enabled, the debug output is sent to the kernel. -*/ -#define gcdDEBUG_IN_KERNEL 0 - -/* - gcdBUFFERED_OUTPUT - - When set to non-zero, all output is collected into a buffer with the - specified size. Once the buffer gets full, or the token "$$FLUSH$$" has - been received, the debug buffer will be printed to the console. - gcdBUFFERED_SIZE determines the size of the buffer. -*/ -#define gcdBUFFERED_OUTPUT 0 - -/* - gcdBUFFERED_SIZE - - When set to non-zero, all output is collected into a buffer with the - specified size. Once the buffer gets full, or the token "$$FLUSH$$" has - been received, the debug buffer will be printed to the console. -*/ -#define gcdBUFFERED_SIZE 1024 * 1024 * 10 - -/* - gcdTHREAD_BUFFERS - - When greater then one, will accumulate messages from the specified number - of threads in separate output buffers. -*/ -#if defined(ANDROID) -#define gcdTHREAD_BUFFERS 4 -#else -#define gcdTHREAD_BUFFERS 1 -#endif - - -/* - gcdENABLE_OVERFLOW - - When set to non-zero, and the output buffer gets full, instead of being - printed, it will be allowed to overflow removing the oldest messages. - Meaningful only if gcdBUFFERED_OUTPUT is 1. -*/ -#define gcdENABLE_OVERFLOW 1 - -/* - gcdSHOW_LINE_NUMBER - - When enabledm each print statement will be preceeded with the current - line number. -*/ -#if defined(ANDROID) -#define gcdSHOW_LINE_NUMBER 0 -#else -#define gcdSHOW_LINE_NUMBER 1 -#endif - -/* - gcdSHOW_PROCESS_ID - - When enabled each print statement will be preceeded with the current - process ID. -*/ -#define gcdSHOW_PROCESS_ID 0 - -/* - gcdSHOW_THREAD_ID - - When enabledm each print statement will be preceeded with the current - thread ID. -*/ -#define gcdSHOW_THREAD_ID 0 - -/* - gcdSEPARATE_THREADS - - When enabled, an empty line is printed between messages from different - threads. -*/ -#define gcdSEPARATE_THREADS 0 - -/* - gcdSHOW_TIME - - When enabled each print statement will be preceeded with the current - high-resolution time. -*/ -#define gcdSHOW_TIME 0 - - -/* - gcdFLUSH_FILE - - When enabled each print statement will be succeeded with a fflush - operation. This should be turned on to capture applications that hang - the GPU. As otherwise the file contents are not fully synced. -*/ -#if gcdDUMP || gcdDUMP_API -#define gcdFLUSH_FILE 1 -#else -#define gcdFLUSH_FILE 0 -#endif - - -/******************************************************************************\ -******************************** Debug Variables ******************************* -\******************************************************************************/ - -static gceSTATUS _lastError = gcvSTATUS_OK; -static gctUINT32 _debugLevel = gcvLEVEL_ERROR; - -#define gcdZONE_ARRAY_SIZE 16 - -static gctUINT32 _debugZones[gcdZONE_ARRAY_SIZE] = -{ - /* Subzones of HAL User */ gcdZONE_NONE, - /* Subzones of EGL API */ gcdZONE_NONE, - /* Subzones of ES11 API */ gcdZONE_NONE, - /* Subzones of ES30 API */ gcdZONE_NONE, - /* Subzones of GL40 API */ gcdZONE_NONE, - /* Subzones of VG3D API */ gcdZONE_NONE, - /* Subzones of CL API */ gcdZONE_NONE, - /* Subzones of VX API */ gcdZONE_NONE, - /* Subzones of VG API */ gcdZONE_NONE, - /* -------------------- */ gcdZONE_NONE, - /* -------------------- */ gcdZONE_NONE, - /* -------------------- */ gcdZONE_NONE, - /* -------------------- */ gcdZONE_NONE, - /* -------------------- */ gcdZONE_NONE, - /* -------------------- */ gcdZONE_NONE, - /* -------------------- */ gcdZONE_NONE -}; - - -/* systrace for API. */ -#if (gcdSYSTRACE & 1) -# define SYSTRACE_API_ZONE_EN gcvTRUE -#else -# define SYSTRACE_API_ZONE_EN gcvFALSE -#endif - -/* systrace for HAL. */ -#if (gcdSYSTRACE & 2) - /* All HAL zone but compiler. */ -# define SYSTRACE_HAL_ZONES_EN (gcvZONE_ALL & ~gcvZONE_COMPILER) -#else -# define SYSTRACE_HAL_ZONES_EN 0 -#endif - -/* systrace for compiler. */ -#if (gcdSYSTRACE & 4) -# define SYSTRACE_COMPILER_ZONE_EN (gcvZONE_COMPILER) -#else -# define SYSTRACE_COMPILER_ZONE_EN 0 -#endif - -/* Specify enabled HAL zones for systrace. */ -static gctUINT32 _systraceZones[16] = -{ - /*Others*/ SYSTRACE_HAL_ZONES_EN | SYSTRACE_COMPILER_ZONE_EN, - /* HAL */ gcdZONE_NONE, - /* EGL */ gcdZONE_NONE, - /* ES11 */ gcdZONE_NONE, - /* ES20 */ gcdZONE_NONE, - /* VG11 */ gcdZONE_NONE, - /* GL */ gcdZONE_NONE, - /* DFB */ gcdZONE_NONE, - /* GDI */ gcdZONE_NONE, - /* D3D */ gcdZONE_NONE, - /* CL */ gcdZONE_NONE, - /* VX */ gcdZONE_NONE, - /* ---- */ gcdZONE_NONE, - /* ---- */ gcdZONE_NONE, - /* ---- */ gcdZONE_NONE, - /* ---- */ gcdZONE_NONE -}; - -/* Specify enabled API zones for systrace. */ -static gctUINT32 _systraceAPIZones[16] = -{ - /*Others*/ gcvFALSE, - /* HAL */ gcvFALSE, - /* EGL */ SYSTRACE_API_ZONE_EN, - /* ES11 */ SYSTRACE_API_ZONE_EN, - /* ES20 */ SYSTRACE_API_ZONE_EN, - /* VG11 */ SYSTRACE_API_ZONE_EN, - /* GL */ SYSTRACE_API_ZONE_EN, - /* DFB */ SYSTRACE_API_ZONE_EN, - /* GDI */ SYSTRACE_API_ZONE_EN, - /* D3D */ SYSTRACE_API_ZONE_EN, - /* CL */ SYSTRACE_API_ZONE_EN, - /* VX */ SYSTRACE_API_ZONE_EN, - /* ---- */ gcvFALSE, - /* ---- */ gcvFALSE, - /* ---- */ gcvFALSE, - /* ---- */ gcvFALSE -}; - - -/*************************************************************/ -#define STACK_THREAD_NUMBER 16 - -typedef struct _gcsDUMP_FILE_INFO -{ - gctFILE _debugFile; - gctUINT32 _threadID; -} -gcsDUMP_FILE_INFO; - -static gcsDUMP_FILE_INFO _FileArray[STACK_THREAD_NUMBER]; -static gctUINT32 _usedFileSlot = 0; -static gctUINT32 _currentPos = 0; -/*************************************************************/ - -static FILE * _debugFileVS; -static FILE * _debugFileFS; -static gctUINT32 _shaderFileType; - -#if gcdBUFFERED_OUTPUT - static gctBOOL _debugBuffering = gcvTRUE; -#else - static gctBOOL _debugBuffering = gcvFALSE; -#endif - -/*************************************************************/ -static pthread_mutex_t _printMutex = PTHREAD_MUTEX_INITIALIZER; -static pthread_mutex_t _dumpFileMutex = PTHREAD_MUTEX_INITIALIZER; - - -/******************************************************************************\ -****************************** OS-dependent Macros ***************************** -\******************************************************************************/ - -#if gcdFLUSH_FILE -#define FFLUSH fflush -#else -#define FFLUSH(...) -#endif - -#define gcmGETPROCESSID() \ - getpid() - -#ifdef ANDROID -# define gcmGETTHREADID() (gctUINT32)gettid() - -# define gcmOUTPUT_STRING(File, String) \ - do \ - { \ - if (File == gcvNULL) \ - { \ - __android_log_write(ANDROID_LOG_DEBUG, "v_gal", String); \ - } \ - else \ - { \ - fprintf(File, "%s", String); \ - FFLUSH(File); \ - } \ - } \ - while (0) -#else -# define gcmGETTHREADID() (gctUINT32)pthread_self() - -# define gcmOUTPUT_STRING(File, String) \ - fprintf((File == gcvNULL) ? stderr : File, "%s", String); \ - FFLUSH((File == gcvNULL) ? stderr : File) -#endif - -#ifdef __STRICT_ANSI__ -# define gcmSPRINTF(Destination, Size, Message, Value) \ - sprintf(Destination, Message, Value) - -# define gcmVSPRINTF(Destination, Size, Message, Arguments) \ - vsprintf(Destination, Message, Arguments) -#else -# define gcmSPRINTF(Destination, Size, Message, Value) \ - snprintf(Destination, Size, Message, Value) - -# define gcmVSPRINTF(Destination, Size, Message, Arguments) \ - vsnprintf(Destination, Size, Message, Arguments) -#endif - -#define gcmSTRCAT(Destination, Size, String) \ - strncat(Destination, String, Size) - - -/******************************************************************************\ -******************************* Private Functions ****************************** -\******************************************************************************/ - -typedef struct _gcsBUFFERED_OUTPUT * gcsBUFFERED_OUTPUT_PTR; -typedef struct _gcsBUFFERED_OUTPUT -{ -#if gcdTHREAD_BUFFERS > 1 - gctUINT32 threadID; -#endif - -#if gcdSHOW_LINE_NUMBER - gctUINT64 lineNumber; -#endif - - gctINT indent; - -#if gcdBUFFERED_OUTPUT - gctINT start; - gctINT index; - gctINT count; - gctCHAR buffer[gcdBUFFERED_SIZE]; -#endif - - gcsBUFFERED_OUTPUT_PTR prev; - gcsBUFFERED_OUTPUT_PTR next; -} -gcsBUFFERED_OUTPUT; - -#if !gcdDEBUG_IN_KERNEL -static gcsBUFFERED_OUTPUT _outputBuffer[gcdTHREAD_BUFFERS]; -static gcsBUFFERED_OUTPUT_PTR _outputBufferHead = gcvNULL; -static gcsBUFFERED_OUTPUT_PTR _outputBufferTail = gcvNULL; -#endif - -static void _Flush( - IN gctFILE File - ) -{ -#if gcdBUFFERED_OUTPUT - gctINT i, j; - - gcsBUFFERED_OUTPUT_PTR outputBuffer = _outputBufferHead; - - while (outputBuffer != gcvNULL) - { - if (outputBuffer->count != 0) - { - i = outputBuffer->start; - -#if gcdTHREAD_BUFFERS > 1 - gcmOUTPUT_STRING(File, "********************************************************************************\n"); - gcmOUTPUT_STRING(File, "FLUSHING DEBUG OUTPUT BUFFER\n"); - gcmOUTPUT_STRING(File, "********************************************************************************\n"); -#endif - - for (j = 0; j < outputBuffer->count; j += 1) - { - gcmOUTPUT_STRING(File, outputBuffer->buffer + i); - - i += strlen(outputBuffer->buffer + i) + 1; - - if ((i >= gcdBUFFERED_SIZE) || (outputBuffer->buffer[i] == 0)) - { - i = 0; - } - } - - outputBuffer->start = 0; - outputBuffer->index = 0; - outputBuffer->count = 0; - } - - outputBuffer = outputBuffer->next; - } -#endif -} - -#if !gcdDEBUG_IN_KERNEL -static void -OutputString( - IN gctFILE File, - IN gcsBUFFERED_OUTPUT_PTR OutputBuffer, - IN gctCONST_STRING String - ) -{ - if (String == gcvNULL) - { - _Flush(File); - } - else - -#if gcdBUFFERED_OUTPUT - if ((OutputBuffer == gcvNULL) || !_debugBuffering) -#endif - - { - gcmOUTPUT_STRING(File, String); - } - -#if gcdBUFFERED_OUTPUT - else - { - gctINT n = strlen(String) + 1; - -#if gcdENABLE_OVERFLOW - if ( - (OutputBuffer->index + n >= gcdBUFFERED_SIZE - 1) - || - ( - (OutputBuffer->index < OutputBuffer->start) && - (OutputBuffer->index + n >= OutputBuffer->start) - ) - ) - { - if (OutputBuffer->index + n >= gcdBUFFERED_SIZE - 1) - { - if (OutputBuffer->index < OutputBuffer->start) - { - while (OutputBuffer->buffer[OutputBuffer->start] != 0) - { - int length = strlen(OutputBuffer->buffer + OutputBuffer->start) + 1; - - OutputBuffer->buffer[OutputBuffer->start] = 0; - OutputBuffer->start += length; - OutputBuffer->count -= 1; - } - - OutputBuffer->start = 0; - } - - OutputBuffer->index = 0; - } - - while (OutputBuffer->start - OutputBuffer->index <= n) - { - int length = strlen(OutputBuffer->buffer + OutputBuffer->start) + 1; - - OutputBuffer->buffer[OutputBuffer->start] = 0; - OutputBuffer->start += length; - OutputBuffer->count -= 1; - - if (OutputBuffer->buffer[OutputBuffer->start] == 0) - { - OutputBuffer->start = 0; - break; - } - } - } -#else - if (OutputBuffer->index + n > gcdBUFFERED_SIZE) - { - _Flush(File); - return; - } -#endif - - memcpy(OutputBuffer->buffer + OutputBuffer->index, String, n); - OutputBuffer->index += n; - OutputBuffer->count += 1; - OutputBuffer->buffer[OutputBuffer->index] = 0; - } -#endif -} -#endif - -static void -_Print( - IN gctFILE File, - IN gctCONST_STRING Message, - IN va_list Arguments - ) -{ - /* Output to file or debugger. */ -#if gcdDEBUG_IN_KERNEL - char buffer[256]; - gctUINT n; - gcsHAL_INTERFACE iface; - - n = gcmVSPRINTF(buffer, sizeof(buffer) - 1, Message, Arguments); - - iface.ignoreTLS = gcvFALSE; - iface.command = gcvHAL_DEBUG_DUMP; - iface.u.DebugDump.type = gcvDUMP_BUFFER_USER_STRING; - iface.u.DebugDump.ptr = gcmPTR_TO_UINT64(buffer); - iface.u.DebugDump.address = ~0U; /* ignored. */ - iface.u.DebugDump.size = n + 1; /* include tailing \0'. */ - - gcoOS_DeviceControl( - gcvNULL, IOCTL_GCHAL_INTERFACE, - &iface, gcmSIZEOF(iface), - &iface, gcmSIZEOF(iface) - ); -#else - int i, j, n, indent; - char buffer[4096]; - gcsBUFFERED_OUTPUT_PTR outputBuffer = gcvNULL; -#if gcdSEPARATE_THREADS - static gctUINT32 prevThreadID; -#endif - -#if gcdTHREAD_BUFFERS > 1 - gctUINT32 threadID; -#endif - - pthread_mutex_lock(&_printMutex); - -#if gcdTHREAD_BUFFERS > 1 - /* Get the current thread ID. */ - threadID = gcmGETTHREADID(); -#endif - - /* Initialize output buffer list. */ - if (_outputBufferHead == gcvNULL) - { - for (i = 0; i < gcdTHREAD_BUFFERS; i += 1) - { - if (_outputBufferTail == gcvNULL) - { - _outputBufferHead = &_outputBuffer[i]; - } - else - { - _outputBufferTail->next = &_outputBuffer[i]; - } - -#if gcdTHREAD_BUFFERS > 1 - _outputBuffer[i].threadID = ~0U; -#endif - - _outputBuffer[i].prev = _outputBufferTail; - _outputBuffer[i].next = gcvNULL; - - _outputBufferTail = &_outputBuffer[i]; - } - } - -#if gcdTHREAD_BUFFERS > 1 - /* Locate the output buffer for the thread. */ - outputBuffer = _outputBufferHead; - - while (outputBuffer != gcvNULL) - { - if (outputBuffer->threadID == threadID) - { - break; - } - - outputBuffer = outputBuffer->next; - } - - /* No matching buffer found? */ - if (outputBuffer == gcvNULL) - { - /* Get the tail for the buffer. */ - outputBuffer = _outputBufferTail; - - /* Move it to the head. */ - _outputBufferTail = _outputBufferTail->prev; - _outputBufferTail->next = gcvNULL; - - outputBuffer->prev = gcvNULL; - outputBuffer->next = _outputBufferHead; - - _outputBufferHead->prev = outputBuffer; - _outputBufferHead = outputBuffer; - - /* Reset the buffer. */ - outputBuffer->threadID = threadID; -#if gcdBUFFERED_OUTPUT - outputBuffer->start = 0; - outputBuffer->index = 0; - outputBuffer->count = 0; -#endif -#if gcdSHOW_LINE_NUMBER - outputBuffer->lineNumber = 0; -#endif - } -#else - outputBuffer = _outputBufferHead; -#endif - -#if gcdSEPARATE_THREADS && (gcdTHREAD_BUFFERS > 1) - if ((prevThreadID != 0) && (prevThreadID != threadID)) - { - OutputString( - File, outputBuffer, "********************************************************************************\n" - ); - } - - /* Update the previous thread value. */ - prevThreadID = threadID; -#endif - - if (strcmp(Message, "$$FLUSH$$") == 0) - { - OutputString(File, gcvNULL, gcvNULL); - pthread_mutex_unlock(&_printMutex); - return; - } - - i = 0; - -#if gcdSHOW_LINE_NUMBER || gcdSHOW_PROCESS_ID || gcdSHOW_THREAD_ID || gcdSHOW_TIME - buffer[i++] = '['; - -#if gcdSHOW_TIME - { - gctUINT64 time; - gcoOS_GetProfileTick(&time); - i += gcmSPRINTF( - buffer + i, sizeof(buffer) - i, "%12llu", time - ); - buffer[sizeof(buffer) - 1] = '\0'; - } -#endif - -#if gcdSHOW_LINE_NUMBER - -#if gcdSHOW_TIME - buffer[i++] = ','; -#endif - - { - i += gcmSPRINTF( - buffer + i, sizeof(buffer) - i, "%6llu", ++outputBuffer->lineNumber - ); - buffer[sizeof(buffer) - 1] = '\0'; - } -#endif - -#if gcdSHOW_PROCESS_ID - -#if gcdSHOW_TIME || gcdSHOW_LINE_NUMBER - buffer[i++] = ','; -#endif - - { - gctUINT32 processID = gcmGETPROCESSID(); - i += gcmSPRINTF( - buffer + i, sizeof(buffer) - i, "pid=%5u", processID - ); - buffer[sizeof(buffer) - 1] = '\0'; - } -#endif - -#if gcdSHOW_THREAD_ID - -#if gcdTHREAD_BUFFERS > 1 -#if gcdSHOW_TIME || gcdSHOW_LINE_NUMBER || gcdSHOW_PROCESS_ID - buffer[i++] = ','; -#endif - - { - i += gcmSPRINTF( - buffer + i, sizeof(buffer) - i, "tid=%5u", threadID - ); - buffer[sizeof(buffer) - 1] = '\0'; - } -#endif -#endif - buffer[i++] = ']'; - buffer[i++] = ' '; -#endif - - if (strncmp(Message, "--", 2) == 0) - { - if (outputBuffer->indent == 0) - { - OutputString(File, outputBuffer, "ERROR: indent=0\n"); - } - - outputBuffer->indent -= 2; - } - - indent = outputBuffer->indent % 40; - - for (j = 0; j < indent; ++j) - { - buffer[i++] = ' '; - } - - if (indent != outputBuffer->indent) - { - i += gcmSPRINTF( - buffer + i, sizeof(buffer) - i, " <%d> ", outputBuffer->indent - ); - buffer[sizeof(buffer) - 1] = '\0'; - } - - /* Print message to buffer. */ - n = gcmVSPRINTF(buffer + i, sizeof(buffer) - i, Message, Arguments); - if (n > (int)sizeof(buffer) - i) - { - n = (int)sizeof(buffer) - i; - } - buffer[sizeof(buffer) - 1] = '\0'; - - if ((n <= 0) || (buffer[i + n - 1] != '\n')) - { - /* Append new-line. */ - gcmSTRCAT(buffer, strlen("\n"), "\n\n"); - buffer[sizeof(buffer) - 1] = '\0'; - } - - /* Output to debugger. */ - OutputString(File, outputBuffer, buffer); - - if (strncmp(Message, "++", 2) == 0) - { - outputBuffer->indent += 2; - } - - pthread_mutex_unlock(&_printMutex); -#endif -} - -static gctFILE -_SetDumpFile( - IN gctFILE File, - IN gctBOOL CloseOldFile - ) -{ - gctFILE oldFile = gcvNULL; - gctUINT32 selfThreadID = gcmGETTHREADID(); - gctUINT32 pos; - gctUINT32 tmpCurPos; - - pthread_mutex_lock(&_dumpFileMutex); - tmpCurPos = _currentPos; - - /* Find if this thread has already been recorded */ - for (pos = 0; pos < _usedFileSlot; pos++) - { - if (selfThreadID == _FileArray[pos]._threadID) - { - _Flush(_FileArray[pos]._debugFile); - if (_FileArray[pos]._debugFile != gcvNULL && - _FileArray[pos]._debugFile != File && - CloseOldFile) - { - /* Close the earliest existing file handle. */ - fclose(_FileArray[pos]._debugFile); - _FileArray[pos]._debugFile = gcvNULL; - } - - oldFile = _FileArray[pos]._debugFile; - /* Replace old file by new file */ - _FileArray[pos]._debugFile = File; - goto exit; - } - } - - /* Test if we have exhausted our thread buffers. One thread one buffer. */ - if (tmpCurPos == STACK_THREAD_NUMBER) - { - goto error; - } - - /* Record this new thread */ - _FileArray[tmpCurPos]._debugFile = File; - _FileArray[tmpCurPos]._threadID = selfThreadID; - _currentPos = ++tmpCurPos; - - if (_usedFileSlot < STACK_THREAD_NUMBER) - { - _usedFileSlot++; - } - -exit: - pthread_mutex_unlock(&_dumpFileMutex); - return oldFile; - -error: - pthread_mutex_unlock(&_dumpFileMutex); - gcmPRINT("ERROR: Not enough dump file buffers. Buffer num = %d", STACK_THREAD_NUMBER); - return oldFile; -} - -static gctFILE -_GetDumpFile() -{ - gctUINT32 selfThreadID; - gctUINT32 pos = 0; - gctFILE retFile = gcvNULL; - - pthread_mutex_lock(&_dumpFileMutex); - - if (_usedFileSlot == 0) - { - goto exit; - } - - selfThreadID = gcmGETTHREADID(); - for (; pos < _usedFileSlot; pos++) - { - if (selfThreadID == _FileArray[pos]._threadID) - { - retFile = _FileArray[pos]._debugFile; - goto exit; - } - } - -exit: - pthread_mutex_unlock(&_dumpFileMutex); - return retFile; -} - -/******************************************************************************\ -********************************* Debug Macros ********************************* -\******************************************************************************/ - -#define gcmDEBUGPRINT(FileHandle, Message) \ -{ \ - va_list arguments; \ - \ - va_start(arguments, Message); \ - _Print(FileHandle, Message, arguments); \ - va_end(arguments); \ - FFLUSH(FileHandle); \ -} - - -/******************************************************************************\ -********************************** Debug Code ********************************** -\******************************************************************************/ - -/******************************************************************************* -** -** gcoOS_Print -** -** Send a message to the debugger. -** -** INPUT: -** -** gctCONST_STRING Message -** Pointer to message. -** -** ... -** Optional arguments. -** -** OUTPUT: -** -** Nothing. -*/ - -void -gcoOS_Print( - IN gctCONST_STRING Message, - ... - ) -{ - gcmDEBUGPRINT(_GetDumpFile(), Message); -} - -/******************************************************************************* -** -** gcoOS_DebugTrace -** -** Send a leveled message to the debugger. -** -** INPUT: -** -** gctUINT32 Level -** Debug level of message. -** -** gctCONST_STRING Message -** Pointer to message. -** -** ... -** Optional arguments. -** -** OUTPUT: -** -** Nothing. -*/ - -void -gcoOS_DebugTrace( - IN gctUINT32 Level, - IN gctCONST_STRING Message, - ... - ) -{ - if (Level > _debugLevel) - { - return; - } - - gcmDEBUGPRINT(_GetDumpFile(), Message); -} - -/******************************************************************************* -** -** gcoOS_DebugTraceZone -** -** Send a leveled and zoned message to the debugger. -** -** INPUT: -** -** gctUINT32 Level -** Debug level for message. -** -** gctUINT32 Zone -** Debug zone for message. -** -** gctCONST_STRING Message -** Pointer to message. -** -** ... -** Optional arguments. -** -** OUTPUT: -** -** Nothing. -*/ -void -gcoOS_DebugTraceZone( - IN gctUINT32 Level, - IN gctUINT32 Zone, - IN gctCONST_STRING Message, - ... - ) -{ - /* Verify that the debug level and zone are valid. */ - if ((Level > _debugLevel) - || !(_debugZones[gcmZONE_GET_API(Zone)] & Zone & gcdZONE_ALL) - ) - { - return; - } - - if(Message != gcvNULL) - gcmDEBUGPRINT(_GetDumpFile(), Message); -} - -/******************************************************************************* -** -** gcoOS_DebugBreak -** -** Break into the debugger. -** -** INPUT: -** -** Nothing. -** -** OUTPUT: -** -** Nothing. -*/ -void -gcoOS_DebugBreak( - void - ) -{ - gcoOS_DebugTrace(gcvLEVEL_ERROR, "%s(%d)", __FUNCTION__, __LINE__); -} - -/******************************************************************************* -** -** gcoOS_DebugFatal -** -** Send a message to the debugger and break into the debugger. -** -** INPUT: -** -** gctCONST_STRING Message -** Pointer to message. -** -** ... -** Optional arguments. -** -** OUTPUT: -** -** Nothing. -*/ - -void -gcoOS_DebugFatal( - IN gctCONST_STRING Message, - ... - ) -{ - gcmPRINT_VERSION(); - gcmDEBUGPRINT(_GetDumpFile(), Message); - - /* Break into the debugger. */ - gcoOS_DebugBreak(); -} - -/******************************************************************************* -** -** gcoOS_SetDebugLevel -** -** Set the debug level. -** -** INPUT: -** -** gctUINT32 Level -** New debug level. -** -** OUTPUT: -** -** Nothing. -*/ - -void -gcoOS_SetDebugLevel( - IN gctUINT32 Level - ) -{ - _debugLevel = Level; -} - -/******************************************************************************* -** -** gcoOS_GetDebugLevel -** -** Get the current debug level. -** -** INPUT: -** -** Nothing. -** -** OUTPUT: -** -** gctUINT32_PTR DebugLevel -** Handle to store the debug level. -*/ -void -gcoOS_GetDebugLevel( - OUT gctUINT32_PTR DebugLevel - ) -{ - *DebugLevel = _debugLevel; -} - -/******************************************************************************* -** -** gcoOS_GetDebugZone -** -** Get current subzones of a debug API. -** -** INPUT: -** -** gctUINT32 Zone -** Debug API zone. -** -** OUTPUT: -** -** gctUINT32_PTR DebugZone -** Handle to store the debug zone. -*/ -void -gcoOS_GetDebugZone( - IN gctUINT32 Zone, - OUT gctUINT32_PTR DebugZone - ) -{ - *DebugZone = _debugZones[gcmZONE_GET_API(Zone)]; -} - -/******************************************************************************* -** -** gcoOS_SetDebugZone -** -** Set a debug zone. -** -** INPUT: -** -** gctUINT32 Zone -** A debug zone listed in gc_hal_debug_zones.h -** -** OUTPUT: -** -** Nothing. -*/ - -void -gcoOS_SetDebugZone( - IN gctUINT32 Zone - ) -{ - gctUINT32 _api = gcmZONE_GET_API(Zone); - gctUINT32 i; - - /* Zone is gcdZONE_NONE or gcdZONE_ALL */ - if (Zone == gcdZONE_NONE || Zone == gcdZONE_ALL) - { - for(i = 0; i < gcdZONE_ARRAY_SIZE; i++) - _debugZones[i] = Zone; - } - /* Zone is API Zone */ - else if (gcmZONE_GET_SUBZONES(Zone) == 0) - { - _debugZones[_api] = gcdZONE_ALL; - } - /* Zone is Subzone */ - else - { - _debugZones[_api] |= Zone; - } -} - -/******************************************************************************* -** -** gcoOS_Verify -** -** Called to verify the result of a function call. -** -** INPUT: -** -** gceSTATUS Status -** Function call result. -** -** OUTPUT: -** -** Nothing. -*/ - -void -gcoOS_Verify( - IN gceSTATUS status - ) -{ - _lastError = status; -} - -/******************************************************************************* -** -** gcoOS_SetDebugFile -** -** Open or close the debug file. -** -** INPUT: -** -** gctCONST_STRING FileName -** Name of debug file to open or gcvNULL to close the current debug -** file. -** -** OUTPUT: -** -** Nothing. -*/ - -void -gcoOS_SetDebugFile( - IN gctCONST_STRING FileName - ) -{ - gctFILE debugFile; - - if (FileName != gcvNULL) - { - /* Don't change it to 'w' !!!*/ - debugFile = fopen(FileName, "a"); - if (debugFile) - { - _SetDumpFile(debugFile, gcvTRUE); - } - } -} - -/******************************************************************************* -** -** gcoOS_ReplaceDebugFile -** -** Replace the debug file to new FILE pointer. -** -** INPUT: -** -** -** gctFILE fp -** The new debug file pointer (already opened). -** -** OUTPUT: -** -** The old debug file pointer. -*/ -gctFILE -gcoOS_ReplaceDebugFile( - IN gctFILE fp - ) -{ - gctFILE old_fp = _SetDumpFile(fp, gcvFALSE); - - return old_fp; -} - -/******************************************************************************* -** -** gcoOS_SetDebugShaderFiles -** -** Called to redirect shader debug output to file(s). -** Passing gcvNULL argument closes previously open file handles. -** -** INPUT: -** -** gctCONST_STRING VSFileName -** Vertex Shader Filename. -** -** gctCONST_STRING FSFileName -** Fragment Shader Filename. -** -** OUTPUT: -** -** Nothing. -*/ - -void -gcoOS_SetDebugShaderFiles( - IN gctCONST_STRING VSFileName, - IN gctCONST_STRING FSFileName - ) -{ - if (_debugFileVS != gcvNULL) - { - fclose(_debugFileVS); - _debugFileVS = gcvNULL; - } - - if (_debugFileFS != gcvNULL) - { - fclose(_debugFileFS); - _debugFileFS = gcvNULL; - } - - if (VSFileName != gcvNULL) - { - _debugFileVS = fopen(VSFileName, "w"); - } - - if (FSFileName != gcvNULL) - { - _debugFileFS = fopen(FSFileName, "w"); - } -} - -/******************************************************************************* -** -** gcoOS_SetDebugShaderFileType -** -** Called to set debugging output to vertex/fragment shader file. -** -** INPUT: -** -** gctUINT32 ShaderType -** 0 for Vertex Shader, 1 for Fragment Shader. -** -** OUTPUT: -** -** Nothing. -*/ - -void -gcoOS_SetDebugShaderFileType( - IN gctUINT32 ShaderType - ) -{ - if (ShaderType <= 1) - { - _shaderFileType = ShaderType; - } -} - -/******************************************************************************* -** -** gcoOS_DebugShaderTrace -** -** Dump a message to a shader file. -** -** INPUT: -** -** gctCONST_STRING Message -** Pointer to message. -** -** ... -** Optional arguments. -** -** OUTPUT: -** -** Nothing. -*/ - -void -gcoOS_DebugShaderTrace( - IN gctCONST_STRING Message, - ... - ) -{ - FILE * file; - - /* Verify that the shader file handle is valid. */ - if (_shaderFileType && (_debugFileFS != gcvNULL)) - { - file = _debugFileFS; - } - else if (!_shaderFileType && (_debugFileVS != gcvNULL)) - { - file = _debugFileVS; - } - else - { - return; - } - - gcmDEBUGPRINT(file, Message); -} - -/******************************************************************************* -** -** gcoOS_EnableDebugBuffer -** -** Enable internal buffering of debug output. -** -** INPUT: -** -** gctBOOL Enable -** Set debug buffering. -** -** OUTPUT: -** -** Nothing. -*/ - -void -gcoOS_EnableDebugBuffer( - IN gctBOOL Enable - ) -{ - _debugBuffering = Enable; -} - -/******************************************************************************* -** -** gcoOS_DebugStatus2Name -** -** transform status enum to status name. -** -** INPUT: -** -** gceSTATUS status Message -** -** OUTPUT: -** -** gctCONST_STRING status name. -*/ - -gctCONST_STRING -gcoOS_DebugStatus2Name( - gceSTATUS status - ) -{ - switch (status) - { - case gcvSTATUS_OK: - return "gcvSTATUS_OK"; - case gcvSTATUS_TRUE: - return "gcvSTATUS_TRUE"; - case gcvSTATUS_NO_MORE_DATA: - return "gcvSTATUS_NO_MORE_DATA"; - case gcvSTATUS_CACHED: - return "gcvSTATUS_CACHED"; - case gcvSTATUS_MIPMAP_TOO_LARGE: - return "gcvSTATUS_MIPMAP_TOO_LARGE"; - case gcvSTATUS_NAME_NOT_FOUND: - return "gcvSTATUS_NAME_NOT_FOUND"; - case gcvSTATUS_NOT_OUR_INTERRUPT: - return "gcvSTATUS_NOT_OUR_INTERRUPT"; - case gcvSTATUS_MISMATCH: - return "gcvSTATUS_MISMATCH"; - case gcvSTATUS_MIPMAP_TOO_SMALL: - return "gcvSTATUS_MIPMAP_TOO_SMALL"; - case gcvSTATUS_LARGER: - return "gcvSTATUS_LARGER"; - case gcvSTATUS_SMALLER: - return "gcvSTATUS_SMALLER"; - case gcvSTATUS_CHIP_NOT_READY: - return "gcvSTATUS_CHIP_NOT_READY"; - case gcvSTATUS_NEED_CONVERSION: - return "gcvSTATUS_NEED_CONVERSION"; - case gcvSTATUS_SKIP: - return "gcvSTATUS_SKIP"; - case gcvSTATUS_DATA_TOO_LARGE: - return "gcvSTATUS_DATA_TOO_LARGE"; - case gcvSTATUS_INVALID_CONFIG: - return "gcvSTATUS_INVALID_CONFIG"; - case gcvSTATUS_CHANGED: - return "gcvSTATUS_CHANGED"; - case gcvSTATUS_NOT_SUPPORT_DITHER: - return "gcvSTATUS_NOT_SUPPORT_DITHER"; - case gcvSTATUS_EXECUTED: - return "gcvSTATUS_EXECUTED"; - case gcvSTATUS_TERMINATE: - return "gcvSTATUS_TERMINATE"; - - case gcvSTATUS_INVALID_ARGUMENT: - return "gcvSTATUS_INVALID_ARGUMENT"; - case gcvSTATUS_INVALID_OBJECT: - return "gcvSTATUS_INVALID_OBJECT"; - case gcvSTATUS_OUT_OF_MEMORY: - return "gcvSTATUS_OUT_OF_MEMORY"; - case gcvSTATUS_MEMORY_LOCKED: - return "gcvSTATUS_MEMORY_LOCKED"; - case gcvSTATUS_MEMORY_UNLOCKED: - return "gcvSTATUS_MEMORY_UNLOCKED"; - case gcvSTATUS_HEAP_CORRUPTED: - return "gcvSTATUS_HEAP_CORRUPTED"; - case gcvSTATUS_GENERIC_IO: - return "gcvSTATUS_GENERIC_IO"; - case gcvSTATUS_INVALID_ADDRESS: - return "gcvSTATUS_INVALID_ADDRESS"; - case gcvSTATUS_CONTEXT_LOSSED: - return "gcvSTATUS_CONTEXT_LOSSED"; - case gcvSTATUS_TOO_COMPLEX: - return "gcvSTATUS_TOO_COMPLEX"; - case gcvSTATUS_BUFFER_TOO_SMALL: - return "gcvSTATUS_BUFFER_TOO_SMALL"; - case gcvSTATUS_INTERFACE_ERROR: - return "gcvSTATUS_INTERFACE_ERROR"; - case gcvSTATUS_NOT_SUPPORTED: - return "gcvSTATUS_NOT_SUPPORTED"; - case gcvSTATUS_MORE_DATA: - return "gcvSTATUS_MORE_DATA"; - case gcvSTATUS_TIMEOUT: - return "gcvSTATUS_TIMEOUT"; - case gcvSTATUS_OUT_OF_RESOURCES: - return "gcvSTATUS_OUT_OF_RESOURCES"; - case gcvSTATUS_INVALID_DATA: - return "gcvSTATUS_INVALID_DATA"; - case gcvSTATUS_INVALID_MIPMAP: - return "gcvSTATUS_INVALID_MIPMAP"; - case gcvSTATUS_NOT_FOUND: - return "gcvSTATUS_NOT_FOUND"; - case gcvSTATUS_NOT_ALIGNED: - return "gcvSTATUS_NOT_ALIGNED"; - case gcvSTATUS_INVALID_REQUEST: - return "gcvSTATUS_INVALID_REQUEST"; - case gcvSTATUS_GPU_NOT_RESPONDING: - return "gcvSTATUS_GPU_NOT_RESPONDING"; - case gcvSTATUS_TIMER_OVERFLOW: - return "gcvSTATUS_TIMER_OVERFLOW"; - case gcvSTATUS_VERSION_MISMATCH: - return "gcvSTATUS_VERSION_MISMATCH"; - case gcvSTATUS_LOCKED: - return "gcvSTATUS_LOCKED"; - case gcvSTATUS_INTERRUPTED: - return "gcvSTATUS_INTERRUPTED"; - case gcvSTATUS_DEVICE: - return "gcvSTATUS_DEVICE"; - case gcvSTATUS_NOT_MULTI_PIPE_ALIGNED: - return "gcvSTATUS_NOT_MULTI_PIPE_ALIGNED"; - - /* Linker errors. */ - case gcvSTATUS_GLOBAL_TYPE_MISMATCH: - return "gcvSTATUS_GLOBAL_TYPE_MISMATCH"; - case gcvSTATUS_TOO_MANY_ATTRIBUTES: - return "gcvSTATUS_TOO_MANY_ATTRIBUTES"; - case gcvSTATUS_TOO_MANY_UNIFORMS: - return "gcvSTATUS_TOO_MANY_UNIFORMS"; - case gcvSTATUS_TOO_MANY_VARYINGS: - return "gcvSTATUS_TOO_MANY_VARYINGS"; - case gcvSTATUS_UNDECLARED_VARYING: - return "gcvSTATUS_UNDECLARED_VARYING"; - case gcvSTATUS_VARYING_TYPE_MISMATCH: - return "gcvSTATUS_VARYING_TYPE_MISMATCH"; - case gcvSTATUS_MISSING_MAIN: - return "gcvSTATUS_MISSING_MAIN"; - case gcvSTATUS_NAME_MISMATCH: - return "gcvSTATUS_NAME_MISMATCH"; - case gcvSTATUS_INVALID_INDEX: - return "gcvSTATUS_INVALID_INDEX"; - case gcvSTATUS_UNIFORM_MISMATCH: - return "gcvSTATUS_UNIFORM_MISMATCH"; - case gcvSTATUS_UNSAT_LIB_SYMBOL: - return "gcvSTATUS_UNSAT_LIB_SYMBOL"; - case gcvSTATUS_TOO_MANY_SHADERS: - return "gcvSTATUS_TOO_MANY_SHADERS"; - case gcvSTATUS_LINK_INVALID_SHADERS: - return "gcvSTATUS_LINK_INVALID_SHADERS"; - case gcvSTATUS_CS_NO_WORKGROUP_SIZE: - return "gcvSTATUS_CS_NO_WORKGROUP_SIZE"; - case gcvSTATUS_LINK_LIB_ERROR: - return "gcvSTATUS_LINK_LIB_ERROR"; - case gcvSTATUS_SHADER_VERSION_MISMATCH: - return "gcvSTATUS_SHADER_VERSION_MISMATCH"; - case gcvSTATUS_TOO_MANY_INSTRUCTION: - return "gcvSTATUS_TOO_MANY_INSTRUCTION"; - case gcvSTATUS_SSBO_MISMATCH: - return "gcvSTATUS_SSBO_MISMATCH"; - case gcvSTATUS_TOO_MANY_OUTPUT: - return "gcvSTATUS_TOO_MANY_OUTPUT"; - case gcvSTATUS_TOO_MANY_INPUT: - return "gcvSTATUS_TOO_MANY_INPUT"; - case gcvSTATUS_NOT_SUPPORT_CL: - return "gcvSTATUS_NOT_SUPPORT_CL"; - case gcvSTATUS_NOT_SUPPORT_INTEGER: - return "gcvSTATUS_NOT_SUPPORT_INTEGER"; - case gcvSTATUS_UNIFORM_TYPE_MISMATCH: - return "gcvSTATUS_UNIFORM_TYPE_MISMATCH"; - case gcvSTATUS_MISSING_PRIMITIVE_TYPE: - return "gcvSTATUS_MISSING_PRIMITIVE_TYPE"; - case gcvSTATUS_MISSING_OUTPUT_VERTEX_COUNT: - return "gcvSTATUS_MISSING_OUTPUT_VERTEX_COUNT"; - case gcvSTATUS_NON_INVOCATION_ID_AS_INDEX: - return "gcvSTATUS_NON_INVOCATION_ID_AS_INDEX"; - case gcvSTATUS_INPUT_ARRAY_SIZE_MISMATCH: - return "gcvSTATUS_INPUT_ARRAY_SIZE_MISMATCH"; - case gcvSTATUS_OUTPUT_ARRAY_SIZE_MISMATCH: - return "gcvSTATUS_OUTPUT_ARRAY_SIZE_MISMATCH"; - - /* Compiler errors. */ - case gcvSTATUS_COMPILER_FE_PREPROCESSOR_ERROR: - return "gcvSTATUS_COMPILER_FE_PREPROCESSOR_ERROR"; - case gcvSTATUS_COMPILER_FE_PARSER_ERROR: - return "gcvSTATUS_COMPILER_FE_PARSER_ERROR"; - - default: - return "nil"; - } -} - -/******************************************************************************* -***** Trace Stack Management *************************************************** -*******************************************************************************/ - -typedef struct _gcsSTACK_FRAME -{ - gctINT8_PTR identity; - gctCONST_STRING function; - gctINT line; - gctCONST_STRING text; - gctPOINTER arguments[12]; -} -gcsSTACK_FRAME; - -typedef struct _gcsTRACE_STACK -{ - gcsSTACK_FRAME frames[128]; - gctINT level; -} -gcsTRACE_STACK; - - -static pthread_key_t _stackTLSKey; - -static void -_DestroyStack( - void * Stack - ) -{ - free(Stack); -} - -static void -_AllocStackTLSKey( - void - ) -{ - pthread_key_create(&_stackTLSKey, _DestroyStack); -} - -/******************************************************************************* -** _FindStack -** -** Find the trace stack belonging to the current thread. -** -** ARGUMENTS: -** -** -** -** RETURNS: -** -** gcsTRACE_STACK * -** Pointer to the trace stack for the current thread or gcvNULL if -** there are not enough trace stacks. -*/ -static gcsTRACE_STACK * _FindStack(void) -{ - static pthread_once_t onceControl = {PTHREAD_ONCE_INIT}; - gcsTRACE_STACK * traceStack; - - /* Allocate stack trace tls key. */ - pthread_once(&onceControl, _AllocStackTLSKey); - - traceStack = (gcsTRACE_STACK *) pthread_getspecific(_stackTLSKey); - - if (traceStack == gcvNULL) - { - traceStack = (gcsTRACE_STACK *) malloc(sizeof (gcsTRACE_STACK)); - - if (!traceStack) - { - /* Out of memory. */ - return gcvNULL; - } - - traceStack->level = 0; - pthread_setspecific(_stackTLSKey, traceStack); - } - - return traceStack; -} - -/******************************************************************************* -** gcoOS_StackPush -** -** Push a function onto the trace stack. -** -** ARGUMENTS: -** -** gctCONST_STRING Function -** Pointer to function name. -** -** gctINT Line -** Line number. -** -** gctCONST_STRING Text OPTIONAL -** Optional pointer to a descriptive text. -** -** ... -** Optional arguments to the descriptive text. -*/ -void -gcoOS_StackPush( - IN gctINT8_PTR Identity, - IN gctCONST_STRING Function, - IN gctINT Line, - IN gctCONST_STRING Text OPTIONAL, - ... - ) -{ - /* Find our stack. */ - gcsTRACE_STACK * traceStack = _FindStack(); - - if (traceStack == gcvNULL) - { - return; - } - - /* Test for stack overflow. */ - if (traceStack->level >= (gctINT)gcmCOUNTOF(traceStack->frames)) - { - gcmPRINT("ERROR(%s): Trace stack overflow.", Function); - } - else - { - /* Push arguments onto the stack. */ - gcsSTACK_FRAME* frame = &traceStack->frames[traceStack->level++]; - frame->identity = Identity; - frame->function = Function; - frame->line = Line; - frame->text = Text; - - if (Text != gcvNULL) - { - /* Copy the arguments. */ - gctSIZE_T i; - gctPOINTER * arguments = ((gctPOINTER *) &Text) + 1; - for (i = 0; i < gcmCOUNTOF(frame->arguments); ++i) - { - frame->arguments[i] = arguments[i]; - } - } - } -} - -/******************************************************************************* -** gcoOS_StackPop -** -** Pop a function from the trace stack. -** -** ARGUMENTS: -** -** gctCONST_STRING Function -** Pointer to function name. -*/ -void -gcoOS_StackPop( - IN gctINT8_PTR Identity, - IN gctCONST_STRING Function - ) -{ - /* Find our stack. */ - gcsTRACE_STACK * traceStack = _FindStack(); - if (traceStack == gcvNULL) - { - return; - } - - if (traceStack->level > 0) - { - /* Pop arguments from the stack. */ - gcsSTACK_FRAME* frame = &traceStack->frames[--traceStack->level]; - - - /* Check for function mismatch. */ - if (frame->identity != Identity) - { - gctINT32 levelCheck; - gcsSTACK_FRAME* backFrame; - - for (levelCheck = traceStack->level; levelCheck >= 0; levelCheck--) - { - backFrame = &traceStack->frames[levelCheck]; - if (backFrame->identity == Identity) - { - /* Skip all miss-footer funcions in stack */ - traceStack->level = levelCheck; - break; - } - else - { - gcmPRINT("ERROR(%s): Trace stack mismatch in (%s : %d).", - Function, backFrame->function, backFrame->line); - } - } - } - } - /* Test for stack underflow. */ - else if (traceStack->level <= 0) - { - gcmPRINT("ERROR(%s): Trace stack underflow.", Function); - } -} - -/******************************************************************************* -** gcoOS_StackDump -** -** Dump the current trace stack. -** -** ARGUMENTS: -** -** -*/ -void -gcoOS_StackDump( - void - ) -{ - /* Find our stack. */ - gcsTRACE_STACK * traceStack = _FindStack(); - - if (traceStack == gcvNULL) - { - return; - } - - if (traceStack->level > 0) - { - gctINT l; - - gcmPRINT("Trace Stack Backtrace:"); - - for (l = traceStack->level - 1; l >= 0; --l) - { - gcsSTACK_FRAME* frame = &traceStack->frames[l]; - - gcmPRINT(" [%d] %s(%d)", l, frame->function, frame->line); - - if (frame->text != gcvNULL) - { - char buffer[192] = ""; - gctUINT offset = 0; - gctPOINTER pointer = (gctPOINTER) frame->arguments; - - gcoOS_PrintStrVSafe(buffer, gcmSIZEOF(buffer), - &offset, frame->text, *(gctARGUMENTS *) &pointer); - - gcmPRINT(" (%s)", buffer); - } - } - } -} - -/******************************************************************************* -***** Binary Trace ************************************************************* -*******************************************************************************/ - -/******************************************************************************* -** _VerifyMessage -** -** Verify a binary trace message, decode it to human readable string and print -** it. -** -** ARGUMENTS: -** -** gctCONST_STRING Buffer -** Pointer to buffer to store. -** -** gctSIZE_T Bytes -** Buffer length. -*/ -void -_VerifyMessage( - IN gctCONST_STRING Buffer, - IN gctSIZE_T Bytes - ) -{ - char arguments[150] = {0}; - char format[100] = {0}; - - gctSTRING function; - gctPOINTER args; - gctUINT32 numArguments; - int i = 0; - gctUINT32 functionBytes; - - gcsBINARY_TRACE_MESSAGE_PTR message = (gcsBINARY_TRACE_MESSAGE_PTR)Buffer; - - /* Check signature. */ - if (message->signature != 0x7FFFFFFF) - { - gcmPRINT("Signature error"); - return; - } - - /* Get function name. */ - function = (gctSTRING)&message->payload; - functionBytes = strlen(function) + 1; - - /* Get arguments number. */ - numArguments = message->numArguments; - - /* Get arguments . */ - args = function + functionBytes; - - /* Prepare format string. */ - while (numArguments--) - { - format[i++] = '%'; - format[i++] = 'x'; - format[i++] = ' '; - } - - format[i] = '\0'; - - if (numArguments) - { - gcmVSPRINTF(arguments, 150, format, *(gctARGUMENTS *) &args); - } - - gcmPRINT("[%d](%d): %s(%d) %s", - message->pid, - message->tid, - function, - message->line, - arguments); -} - -#if gcdBINARY_TRACE_FILE_SIZE -static FILE * _binaryTraceFile; -#endif -/******************************************************************************* -** gcoOS_WriteToStorage -** -** Store a buffer, as a example, raw buffer is written to a file. -** -** ARGUMENTS: -** -** gctCONST_STRING Buffer -** Pointer to buffer to store. -** -** gctSIZE_T Bytes -** Buffer length. -*/ -void -gcoOS_WriteToStorage( - IN gctCONST_STRING Buffer, - IN gctSIZE_T Bytes - ) -{ - /* Implement a buffer storage mechanisam to record binary trace buffer. */ -#if gcdBINARY_TRACE_FILE_SIZE - char binaryTraceFileName[64]; - static gctUINT32 fileBytes = 0; - - if (_binaryTraceFile == gcvNULL) - { - sprintf(binaryTraceFileName, "%x.trace", getpid()); - _binaryTraceFile = fopen(binaryTraceFileName, "w"); - } - - fwrite(Buffer, 1, Bytes, _binaryTraceFile); - - fileBytes += Bytes; - - if (fileBytes >= gcdBINARY_TRACE_FILE_SIZE) - { - rewind(_binaryTraceFile); - fileBytes = 0; - } -#endif -} - -/******************************************************************************* -** gcoOS_BinaryTrace -** -** Output a binary trace message. -** -** ARGUMENTS: -** -** gctCONST_STRING Function -** Pointer to function name. -** -** gctINT Line -** Line number. -** -** gctCONST_STRING Text OPTIONAL -** Optional pointer to a descriptive text. -** -** ... -** Optional arguments to the descriptive text. -*/ -void -gcoOS_BinaryTrace( - IN gctCONST_STRING Function, - IN gctINT Line, - IN gctCONST_STRING Text OPTIONAL, - ... - ) -{ - static gctUINT32 messageSignature = 0x7FFFFFFF; - char buffer[gcdBINARY_TRACE_MESSAGE_SIZE]; - gctUINT32 numArguments = 0; - gctUINT32 functionBytes; - gctUINT32 i = 0; - gctSTRING payload; - gcsBINARY_TRACE_MESSAGE_PTR message = (gcsBINARY_TRACE_MESSAGE_PTR)buffer; - - /* Calculate arguments number. */ - if (Text) - { - while (Text[i] != '\0') - { - if (Text[i] == '%') - { - numArguments++; - } - i++; - } - } - - message->signature = messageSignature; - message->pid = gcmGETPROCESSID(); - message->tid = gcmGETTHREADID(); - message->line = Line; - message->numArguments = numArguments; - - payload = (gctSTRING)&message->payload; - - /* Function name. */ - functionBytes = strlen(Function) + 1; - memcpy(payload, Function, functionBytes); - - /* Advance to next payload. */ - payload += functionBytes; - - /* Arguments value. */ - if (numArguments) - { - va_list p; - va_start(p, Text); - - for (i = 0; i < numArguments; ++i) - { - gctPOINTER value = va_arg(p, gctPOINTER); - memcpy(payload, &value, gcmSIZEOF(gctPOINTER)); - payload += gcmSIZEOF(gctPOINTER); - } - - va_end(p); - } - - gcmASSERT(payload - buffer <= gcdBINARY_TRACE_MESSAGE_SIZE); - - - /* Send buffer to ring buffer. */ - gcoOS_WriteToStorage(buffer, payload - buffer); -} - -#if !defined(ANDROID) || (ANDROID_SDK_VERSION < 18) -static pthread_mutex_t _atraceMutex = PTHREAD_MUTEX_INITIALIZER; -static int _atraceFD = -1; - -static gctBOOL _ATraceInit() -{ - static gctBOOL once = gcvFALSE; - - pthread_mutex_lock(&_atraceMutex); - - if ((_atraceFD == -1) && (!once)) - { - const char* const traceFileName = - "/sys/kernel/debug/tracing/trace_marker"; - - _atraceFD = open(traceFileName, O_WRONLY); - - if (_atraceFD == -1) - { - gcmPRINT("error opening trace file: %s (%d)", strerror(errno), errno); - } - once = gcvTRUE; - } - - pthread_mutex_unlock(&_atraceMutex); - - return (_atraceFD != -1); -} - -static void _ATraceBegin(const char* name) -{ - if (_ATraceInit()) { - char buf[1024]; - size_t len = snprintf(buf, 1024, "B|%d|%s", getpid(), name); - - if (len > 0) - { - if (write(_atraceFD, buf, len)) {}; - } - } -} - -static void _ATraceEnd() -{ - if (_ATraceInit()) { - char buf = 'E'; - if (write(_atraceFD, &buf, 1)) {}; - } -} -#endif - -void -gcoOS_SysTraceBegin( - IN gctUINT32 Zone, - IN gctCONST_STRING FuncName - ) -{ - gctUINT32 api = gcmZONE_GET_API(Zone); - - if (!_systraceAPIZones[api] && - !(_systraceZones[api] & Zone)) - { - /* No API or HAL zone enabled. */ - return; - } - -#if defined(ANDROID) && (ANDROID_SDK_VERSION >= 18) - ATRACE_BEGIN(FuncName); -#else - _ATraceBegin(FuncName); -#endif -} - -void -gcoOS_SysTraceEnd( - IN gctUINT32 Zone - ) -{ - gctUINT32 api = gcmZONE_GET_API(Zone); - - if (!_systraceAPIZones[api] && - !(_systraceZones[api] & Zone)) - { - /* No API or HAL zone enabled. */ - return; - } - -#if defined(ANDROID) && (ANDROID_SDK_VERSION >= 18) - ATRACE_END(); -#else - _ATraceEnd(); -#endif -} - diff --git a/drivers/amlogic/npu/os/linux/user/gc_hal_user_debug.h b/drivers/amlogic/npu/os/linux/user/gc_hal_user_debug.h deleted file mode 100644 index 5110fcb..0000000 --- a/drivers/amlogic/npu/os/linux/user/gc_hal_user_debug.h +++ /dev/null @@ -1,23 +0,0 @@ -/**************************************************************************** -* -* Copyright (c) 2005 - 2019 by Vivante Corp. All rights reserved. -* -* The material in this file is confidential and contains trade secrets -* of Vivante Corporation. This is proprietary information owned by -* Vivante Corporation. No part of this work may be disclosed, -* reproduced, copied, transmitted, or used in any way for any purpose, -* without the express written permission of Vivante Corporation. -* -*****************************************************************************/ - - -#ifndef __gc_hal_user_debug_h_ -#define __gc_hal_user_debug_h_ - -#include - -typedef va_list gctARGUMENTS; -#define gcmARGUMENTS_START(argument, pointer) va_start(argument, pointer) -#define gcmARGUMENTS_END(argument) va_end(argument) - -#endif /* __gc_hal_user_debug_h_ */ diff --git a/drivers/amlogic/npu/os/linux/user/gc_hal_user_linux.h b/drivers/amlogic/npu/os/linux/user/gc_hal_user_linux.h deleted file mode 100644 index 7081d8d..0000000 --- a/drivers/amlogic/npu/os/linux/user/gc_hal_user_linux.h +++ /dev/null @@ -1,32 +0,0 @@ -/**************************************************************************** -* -* Copyright (c) 2005 - 2019 by Vivante Corp. All rights reserved. -* -* The material in this file is confidential and contains trade secrets -* of Vivante Corporation. This is proprietary information owned by -* Vivante Corporation. No part of this work may be disclosed, -* reproduced, copied, transmitted, or used in any way for any purpose, -* without the express written permission of Vivante Corporation. -* -*****************************************************************************/ - - -#ifndef __gc_hal_user_linux_h_ -#define __gc_hal_user_linux_h_ - -#ifndef _ISOC99_SOURCE -# define _ISOC99_SOURCE -#endif - -#ifndef _XOPEN_SOURCE -# define _XOPEN_SOURCE 501 -#endif -#include -#include -#include -#include -#include -#include "gc_hal_user.h" - - -#endif /* __gc_hal_user_linux_h_ */ diff --git a/drivers/amlogic/npu/os/linux/user/gc_hal_user_math.c b/drivers/amlogic/npu/os/linux/user/gc_hal_user_math.c deleted file mode 100644 index 8c97139..0000000 --- a/drivers/amlogic/npu/os/linux/user/gc_hal_user_math.c +++ /dev/null @@ -1,587 +0,0 @@ -/**************************************************************************** -* -* Copyright (c) 2005 - 2019 by Vivante Corp. All rights reserved. -* -* The material in this file is confidential and contains trade secrets -* of Vivante Corporation. This is proprietary information owned by -* Vivante Corporation. No part of this work may be disclosed, -* reproduced, copied, transmitted, or used in any way for any purpose, -* without the express written permission of Vivante Corporation. -* -*****************************************************************************/ - - -#include "gc_hal_types.h" -#include "gc_hal_user_math.h" -#include "gc_hal_user_linux.h" - -gctUINT32 -gcoMATH_Log2in5dot5( - IN gctINT X - ) -{ - gctUINT32 res = 0; - - if ( X <= 1 ) - { - return 0; - } - - if (!(X & 0xFF)) - { - X >>= 8; - res += 8 * 32; - } - if (!(X & 0xF)) - { - X >>= 4; - res += 4 * 32; - } - if (!(X & 0x3)) - { - X >>= 2; - res += 2 * 32; - } - if (!(X & 0x1)) - { - X >>= 1; - res += 32; - } - - switch(X) - { - case 1: - break; - case 3: - /* Return res + log_2(3)*32.f = res + (gctUIN32)50.7188f */ - res += 50; - break; - case 5: - /* Return res + log_2(5)*32.f = res + (gctUIN32)74.301699f */ - res += 74; - break; - default: - /* Return res + log_2(x)*32.f = res + log_e(x) / log_e(2) * 32.f - = res + (gctUIN32)46.166241f - */ - res += (gctUINT32)(gcoMATH_Log(X) * 46.166241f); - } - - return res; -} - - -gctUINT32 -gcoMATH_FloatAsUInt( - IN gctFLOAT X - ) -{ - union __anon_1 - { - gctFLOAT f; - gctUINT32 u; - } - var; - - var.f = X; - return var.u; -} - -gctFLOAT -gcoMATH_UIntAsFloat( - IN gctUINT32 X - ) -{ - union __anon_1 - { - gctFLOAT f; - gctUINT32 u; - } - var; - - var.u = X; - return var.f; -} - -gctBOOL -gcoMATH_CompareEqualF( - IN gctFLOAT X, - IN gctFLOAT Y - ) -{ - union __anon_1 - { - gctFLOAT f; - gctUINT32 u; - } - var1, var2; - - var1.f = X; - var2.f = Y; - - return (var1.u == var2.u); -} - -/* Return result in 16bit UINT format. - * Don't round up the UINT input. - */ -gctUINT16 -gcoMATH_UInt8AsFloat16( - IN gctUINT8 X - ) -{ - gctUINT16 exp, x16, mask; - - if (X == 0x0) - return (gctUINT16)0x0; - - x16 = X; - exp = 15; - mask = 0x1 << 8; - - while((x16 & mask) == 0) - { - exp--; - x16 <<= 1; - } - - x16 = (x16 & 0xFF) << 2; - - return (exp << 10) | x16; -} - - -/* Defines and constants for 32-bit floating point. */ -#define gcdSINGLEFLOATEXP 8 -#define gcdSINGLEFLOATEXPMASK 0xFF -#define gcdSINGLEFLOATEXPBIAS (gcdSINGLEFLOATEXPMASK >> 1) -#define gcdGETSINGLEFLOATEXP(x) ((x >> (32 - 1 - 8)) & gcdSINGLEFLOATEXPMASK) -#define gcdSINGLEFLOATMAN 23 -#define gcdFORMSINGLEFLOAT(s,e,m) (((s)<<(32 - 1))|((e)<<(32 - 9))|(m)) -#define gcdSINGLEFLOATEXPINFINITY 0xFF - -/* Defines and constants for 16-bit floating point. */ -#define gcdFLOAT16_EXPONENTSIZE 5 -#define gcdFLOAT16_EXPONENTMASK ((1 << gcdFLOAT16_EXPONENTSIZE) - 1) -#define gcdFLOAT16_MANTISSASIZE 10 -#define gcdFLOAT16_MANTISSAMASK ((1 << gcdFLOAT16_MANTISSASIZE) - 1) -#define gcdFLOAT16_BIAS (gcdFLOAT16_EXPONENTMASK >> 1) -#define gcdFLOAT16_INFINITY gcdFLOAT16_EXPONENTMASK - -/* -** Convert float16 to single float -*/ -gctUINT32 -gcoMATH_Float16ToFloat( - IN gctUINT16 In - ) -{ - gctUINT16 signIn = In >> (gcdFLOAT16_MANTISSASIZE + gcdFLOAT16_EXPONENTSIZE); - gctUINT16 expIn = (In >> gcdFLOAT16_MANTISSASIZE) & gcdFLOAT16_EXPONENTMASK; - gctUINT16 expOut; - gctUINT32 manIn, manOut; - - if (expIn == 0) - { - return gcdFORMSINGLEFLOAT(signIn, 0, 0); - } - - if (expIn == gcdFLOAT16_INFINITY) - { - return gcdFORMSINGLEFLOAT(signIn, gcdSINGLEFLOATEXPINFINITY, 0); - } - - manIn = In & gcdFLOAT16_MANTISSAMASK; - - expOut = expIn - gcdFLOAT16_BIAS + gcdSINGLEFLOATEXPBIAS; - manOut = manIn << (gcdSINGLEFLOATMAN - gcdFLOAT16_MANTISSASIZE); - - return gcdFORMSINGLEFLOAT(signIn, expOut, manOut); -} - - -#define gcdFLOAT16_SIGNBIT 15 -#define gcdFLOAT16_EXPONENTBIAS ((1U << (gcdFLOAT16_EXPONENTSIZE - 1)) - 1) /* Exponent bias */ -#define gcdFLOAT16_EXPONENTMAX gcdFLOAT16_EXPONENTBIAS /* Max exponent */ -#define gcdFLOAT16_EXPONENTMIN (-gcdFLOAT16_EXPONENTBIAS + 1) /* MIn exponent */ -#define gcdFLOAT16_MAXNORMAL (((gcdFLOAT16_EXPONENTMAX + 127) << 23) | 0x7FE000) -#define gcdFLOAT16_MINNORMAL ((gcdFLOAT16_EXPONENTMIN + 127) << 23) -#define gcdFLOAT16_BIASDIFF ((gcdFLOAT16_EXPONENTBIAS - 127) << 23) -#define gcdFLOAT16_MANTISSASIZEDIFF (23 - gcdFLOAT16_MANTISSASIZE) - -/* pass value is not as good as pass pointer, for SNaN may be changed to QNaN, - but I thInk it's ok for current usage. */ -gctUINT16 -gcoMATH_FloatToFloat16( - IN gctUINT32 In - ) -{ - gctUINT16 ret; - gctUINT32 u = In; - gctUINT32 sign = (u & 0x80000000) >> 16; - gctUINT32 mag = u & 0x7FFFFFFF; - - if((u & (0xff<<23)) == (0xff<<23)) - { - /* INF or NaN */ - ret = (gctUINT16)(sign | (((1 << gcdFLOAT16_EXPONENTSIZE) - 1))<float->float16 - ** conversion Invertible down to the bit level, even with NaN). - */ - ret = (gctUINT16)(ret| (((u>>13)|(u>>3)|(u))&0x000003ff)); - } - } - else if (mag > gcdFLOAT16_MAXNORMAL) - { - /* Not representable by 16 bit float -> use flt16_max (due to round to zero) */ - ret = (gctUINT16)(sign | ((((1 << gcdFLOAT16_EXPONENTSIZE) - 2))<> 23)); - - if (nshift < 24) - { - mag = Frac >> nshift; - } - else - { - mag = 0; - } - - /* Round to zero */ - ret = (gctUINT16)(sign | (mag>>gcdFLOAT16_MANTISSASIZEDIFF)); - } - else - { - /* Normalize value with Round to zero */ - ret = (gctUINT16)(sign | ((mag + gcdFLOAT16_BIASDIFF)>>gcdFLOAT16_MANTISSASIZEDIFF)); - } - - return ret; -} - - -/* Defines and constants for 11-bit floatIng poInt. */ -#define gcdFLOAT11_EXPONENTSIZE 5 -#define gcdFLOAT11_EXPONENTMASK ((1 << gcdFLOAT11_EXPONENTSIZE) - 1) -#define gcdFLOAT11_MANTISSASIZE 6 -#define gcdFLOAT11_MANTISSAMASK ((1 << gcdFLOAT11_MANTISSASIZE) - 1) -#define gcdFLOAT11_BIAS (gcdFLOAT11_EXPONENTMASK >> 1) -#define gcdFLOAT11_INFINITY gcdFLOAT11_EXPONENTMASK - -/* -** Convert float11 to single float -*/ -gctUINT32 -gcoMATH_Float11ToFloat( - IN gctUINT32 In - ) -{ - gctUINT16 expIn = (In >> gcdFLOAT11_MANTISSASIZE) & gcdFLOAT11_EXPONENTMASK; - gctUINT16 expOut; - gctUINT32 manIn, manOut; - - if (expIn == 0) - { - return gcdFORMSINGLEFLOAT(0, 0, 0); - } - - if (expIn == gcdFLOAT11_INFINITY) - { - return gcdFORMSINGLEFLOAT(0, gcdSINGLEFLOATEXPINFINITY, 0); - } - - manIn = In & gcdFLOAT11_MANTISSAMASK; - - expOut = expIn - gcdFLOAT11_BIAS + gcdSINGLEFLOATEXPBIAS; - manOut = manIn << (gcdSINGLEFLOATMAN - gcdFLOAT11_MANTISSASIZE); - - return gcdFORMSINGLEFLOAT(0, expOut, manOut); -} - - -#define gcdFLOAT11_EXPONENTBIAS ((1U << (gcdFLOAT11_EXPONENTSIZE - 1)) - 1) /* Exponent bias */ -#define gcdFLOAT11_EXPONENTMAX gcdFLOAT11_EXPONENTBIAS /* Max exponent */ -#define gcdFLOAT11_EXPONENTMIN (-gcdFLOAT11_EXPONENTBIAS + 1) /* MIn exponent */ -#define gcdFLOAT11_MAXNORMAL (((gcdFLOAT11_EXPONENTMAX + 127) << 23) | 0x7FE000) -#define gcdFLOAT11_MINNORMAL ((gcdFLOAT11_EXPONENTMIN + 127) << 23) -#define gcdFLOAT11_BIASDIFF ((gcdFLOAT11_EXPONENTBIAS - 127) << 23) -#define gcdFLOAT11_MANTISSASIZEDIFF (23 - gcdFLOAT11_MANTISSASIZE) - -/* pass value is not as good as pass pointer, for SNaN may be changed to QNaN, - but I thInk it's ok for current usage. */ -gctUINT16 -gcoMATH_FloatToFloat11( - IN gctUINT32 In - ) -{ - gctUINT16 ret; - gctUINT32 u = In; - gctUINT32 sign = (u & 0x80000000); - gctUINT32 mag = u & 0x7FFFFFFF; - - if((u & (0xff<<23)) == (0xff<<23)) - { - /* INF or NaN */ - if( (u & (~0xff800000)) != 0 ) - { - /* - ** NaN - smash together the fraction bits to - ** keep the random 1's (In a way that keeps float16->float->float16 - ** conversion Invertible down to the bit level, even with NaN). - */ - ret = (gctUINT16)(gcdFLOAT11_EXPONENTMASK << gcdFLOAT11_MANTISSASIZE) |1; - } - else - { - if (sign) /*-INF */ - { - ret = (gctUINT16)0; - } - else /*+INF */ - { - ret = (gctUINT16)(gcdFLOAT11_EXPONENTMASK << gcdFLOAT11_MANTISSASIZE); - } - } - } - else if (mag > gcdFLOAT11_MAXNORMAL) - { - if (sign) - { - ret = 0; - } - else - { - /* Not representable by 16 bit float -> use flt16_max (due to round to zero) */ - ret = (gctUINT16)(((((1 << gcdFLOAT11_EXPONENTSIZE) - 2))<> 23)); - - if (nshift < 24) - { - mag = Frac >> nshift; - } - else - { - mag = 0; - } - - if (sign) - { - ret = 0; - } - else - { - /* Round to zero */ - ret = (gctUINT16)(mag>>gcdFLOAT11_MANTISSASIZEDIFF); - } - } - else - { - if (sign) - { - ret = 0; - } - else - { - /* Normalize value with Round to zero */ - ret = (gctUINT16)((mag + gcdFLOAT11_BIASDIFF)>>gcdFLOAT11_MANTISSASIZEDIFF); - } - } - - return ret; -} - - -/* Defines and constants for 10-bit floatIng poInt. */ -#define gcdFLOAT10_EXPONENTSIZE 5 -#define gcdFLOAT10_EXPONENTMASK ((1 << gcdFLOAT10_EXPONENTSIZE) - 1) -#define gcdFLOAT10_MANTISSASIZE 5 -#define gcdFLOAT10_MANTISSAMASK ((1 << gcdFLOAT10_MANTISSASIZE) - 1) -#define gcdFLOAT10_BIAS (gcdFLOAT10_EXPONENTMASK >> 1) -#define gcdFLOAT10_INFINITY gcdFLOAT10_EXPONENTMASK - -/* -** Convert float10 to single float -*/ -gctUINT32 -gcoMATH_Float10ToFloat( - IN gctUINT32 In - ) -{ - gctUINT16 expIn = (In >> gcdFLOAT10_MANTISSASIZE) & gcdFLOAT10_EXPONENTMASK; - gctUINT16 expOut; - gctUINT32 manIn, manOut; - - if (expIn == 0) - { - return gcdFORMSINGLEFLOAT(0, 0, 0); - } - - if (expIn == gcdFLOAT10_INFINITY) - { - return gcdFORMSINGLEFLOAT(0, gcdSINGLEFLOATEXPINFINITY, 0); - } - - manIn = In & gcdFLOAT10_MANTISSAMASK; - - expOut = expIn - gcdFLOAT10_BIAS + gcdSINGLEFLOATEXPBIAS; - manOut = manIn << (gcdSINGLEFLOATMAN - gcdFLOAT10_MANTISSASIZE); - - return gcdFORMSINGLEFLOAT(0, expOut, manOut); -} - - -#define gcdFLOAT10_EXPONENTBIAS ((1U << (gcdFLOAT10_EXPONENTSIZE - 1)) - 1) /* Exponent bias */ -#define gcdFLOAT10_EXPONENTMAX gcdFLOAT10_EXPONENTBIAS /* Max exponent */ -#define gcdFLOAT10_EXPONENTMIN (-gcdFLOAT10_EXPONENTBIAS + 1) /* MIn exponent */ -#define gcdFLOAT10_MAXNORMAL (((gcdFLOAT10_EXPONENTMAX + 127) << 23) | 0x7FE000) -#define gcdFLOAT10_MINNORMAL ((gcdFLOAT10_EXPONENTMIN + 127) << 23) -#define gcdFLOAT10_BIASDIFF ((gcdFLOAT10_EXPONENTBIAS - 127) << 23) -#define gcdFLOAT10_MANTISSASIZEDIFF (23 - gcdFLOAT10_MANTISSASIZE) - -/* Pass value is not as good as pass pointer, for SNaN may be changed to QNaN, - but I thInk it's ok for current usage. */ -gctUINT16 -gcoMATH_FloatToFloat10( - IN gctUINT32 In - ) -{ - gctUINT16 ret; - gctUINT32 u = In; - gctUINT32 sign = (u & 0x80000000); - gctUINT32 mag = u & 0x7FFFFFFF; - - if((u & (0xff<<23)) == (0xff<<23)) - { - /* INF or NaN */ - if( (u & (~0xff800000)) != 0 ) - { - /* - ** NaN - smash together the fraction bits to - ** keep the random 1's (In a way that keeps float16->float->float16 - ** conversion Invertible down to the bit level, even with NaN). - */ - ret = (gctUINT16)(gcdFLOAT10_EXPONENTMASK << gcdFLOAT10_MANTISSASIZE)|1; - } - else - { - if (sign) /*-INF */ - { - ret = (gctUINT16)0; - } - else /*+INF */ - { - ret = (gctUINT16)(gcdFLOAT10_EXPONENTMASK << gcdFLOAT10_MANTISSASIZE); - } - } - } - else if (mag > gcdFLOAT10_MAXNORMAL) - { - if (sign) - { - ret = 0; - } - else - { - /* Not representable by 16 bit float -> use flt16_max (due to round to zero) */ - ret = (gctUINT16)(((((1 << gcdFLOAT10_EXPONENTSIZE) - 2))<> 23)); - - if (nshift < 24) - { - mag = Frac >> nshift; - } - else - { - mag = 0; - } - - if (sign) - { - ret = 0; - } - else - { - /* Round to zero */ - ret = (gctUINT16)(mag>>gcdFLOAT10_MANTISSASIZEDIFF); - } - } - else - { - if (sign) - { - ret = 0; - } - else - { - /* Normalize value with Round to zero */ - ret = (gctUINT16)((mag + gcdFLOAT10_BIASDIFF)>>gcdFLOAT10_MANTISSASIZEDIFF); - } - } - - return ret; -} - - -/* Defines and constants for 14-bit floatIng poInt. */ -#define gcdFLOAT14_EXPONENTSIZE 5 -#define gcdFLOAT14_EXPONENTMASK ((1 << gcdFLOAT14_EXPONENTSIZE) - 1) -#define gcdFLOAT14_MANTISSASIZE 9 -#define gcdFLOAT14_MANTISSAMASK ((1 << gcdFLOAT14_MANTISSASIZE) - 1) -#define gcdFLOAT14_BIAS (gcdFLOAT14_EXPONENTMASK >> 1) -#define gcdFLOAT14_INFINITY gcdFLOAT14_EXPONENTMASK - -/* -** Convert float10 to single float -*/ -gctUINT32 -gcoMATH_Float14ToFloat( - IN gctUINT16 In - ) -{ - gctUINT16 expIn = (In >> gcdFLOAT14_MANTISSASIZE) & gcdFLOAT14_EXPONENTMASK; - gctUINT16 expOut; - gctUINT32 manIn, manOut; - - if (expIn == 0) - { - return gcdFORMSINGLEFLOAT(0, 0, 0); - } - - if (expIn == gcdFLOAT14_INFINITY) - { - return gcdFORMSINGLEFLOAT(0, gcdSINGLEFLOATEXPINFINITY, 0); - } - - manIn = In & gcdFLOAT14_MANTISSAMASK; - - expOut = expIn - gcdFLOAT14_BIAS + gcdSINGLEFLOATEXPBIAS; - manOut = manIn << (gcdSINGLEFLOATMAN - gcdFLOAT14_MANTISSASIZE); - - return gcdFORMSINGLEFLOAT(0, expOut, manOut); -} diff --git a/drivers/amlogic/npu/os/linux/user/gc_hal_user_math.h b/drivers/amlogic/npu/os/linux/user/gc_hal_user_math.h deleted file mode 100644 index d1ae066..0000000 --- a/drivers/amlogic/npu/os/linux/user/gc_hal_user_math.h +++ /dev/null @@ -1,120 +0,0 @@ -/**************************************************************************** -* -* Copyright (c) 2005 - 2019 by Vivante Corp. All rights reserved. -* -* The material in this file is confidential and contains trade secrets -* of Vivante Corporation. This is proprietary information owned by -* Vivante Corporation. No part of this work may be disclosed, -* reproduced, copied, transmitted, or used in any way for any purpose, -* without the express written permission of Vivante Corporation. -* -*****************************************************************************/ - - -#ifndef __gc_hal_user_math_h_ -#define __gc_hal_user_math_h_ - -#ifndef _ISOC99_SOURCE -# define _ISOC99_SOURCE -#endif - -#if (defined _ISOC99_SOURCE || defined _ISOC9X_SOURCE\ -|| (defined __STDC_VERSION__&&__STDC_VERSION__ >= 199901L)) -#define __USE_ISOC99 1 -#endif - -#include - -#ifdef __STRICT_ANSI__ -#define gcoMATH_Sine(X) (gctFLOAT)(sin((X))) -#define gcoMATH_Cosine(X) (gctFLOAT)(cos((X))) -#define gcoMATH_Floor(X) (gctFLOAT)(floor((X))) -#define gcoMATH_Ceiling(X) (gctFLOAT)(ceil((X))) -#define gcoMATH_Exp(X) (gctFLOAT)(exp((X))) -#define gcoMATH_Exp2(X) (gctFLOAT)(pow(2.0f, (X))) -#define gcoMATH_Absolute(X) (gctFLOAT)(fabs((X))) -#define gcoMATH_ArcCosine(X) (gctFLOAT)(acos((X))) -#define gcoMATH_Tangent(X) (gctFLOAT)(tan((X))) -#define gcoMATH_TangentH(X) (gctFLOAT)(tanh((X))) -#define gcoMATH_ArcSine(X) (gctFLOAT)(asin((X))) -#define gcoMATH_ArcTangent(X) (gctFLOAT)(atan((X))) -#define gcoMATH_Modulo(X, Y) (gctFLOAT)(fmod((X),(Y))) -#define gcoMATH_Power(X, Y) (gctFLOAT)(pow((X),(Y))) -#define gcoMATH_SquareRoot(X) (gctFLOAT)(sqrt((X))) -#define gcoMATH_ReciprocalSquareRoot(X) (gctFLOAT)(1.0f / sqrt((X))) -#define gcoMATH_Log(X) (gctFLOAT)(log((X))) -#define gcoMATH_Log2(X) (gctFLOAT)(log((X)) / log(2.0f)) -#else -#define gcoMATH_Sine(X) (gctFLOAT)(sinf((X))) -#define gcoMATH_Cosine(X) (gctFLOAT)(cosf((X))) -#define gcoMATH_Floor(X) (gctFLOAT)(floorf((X))) -#define gcoMATH_Ceiling(X) (gctFLOAT)(ceilf((X))) -#define gcoMATH_Exp(X) (gctFLOAT)(expf((X))) -#define gcoMATH_Exp2(X) (gctFLOAT)(powf(2.0f, (X))) -#define gcoMATH_Absolute(X) (gctFLOAT)(fabsf((X))) -#define gcoMATH_ArcCosine(X) (gctFLOAT)(acosf((X))) -#define gcoMATH_Tangent(X) (gctFLOAT)(tanf((X))) -#define gcoMATH_TangentH(X) (gctFLOAT)(tanhf((X))) -#define gcoMATH_ArcSine(X) (gctFLOAT)(asinf((X))) -#define gcoMATH_ArcTangent(X) (gctFLOAT)(atanf((X))) -#define gcoMATH_Modulo(X, Y) (gctFLOAT)(fmodf((X),(Y))) -#define gcoMATH_Power(X, Y) (gctFLOAT)(powf((X),(Y))) -#define gcoMATH_SquareRoot(X) (gctFLOAT)(sqrtf((X))) -#define gcoMATH_ReciprocalSquareRoot(X) (gctFLOAT)(1.0f / sqrtf((X))) -#define gcoMATH_Log(X) (gctFLOAT)(logf((X))) -#define gcoMATH_Log2(X) (gctFLOAT)(logf((X)) / logf(2.0f)) -#endif - -#define gcoMATH_ModuloInt(X, Y) (gctINT)((X) % (Y)) -#define gcoMATH_ModuloUInt(X, Y) (gctUINT)((X) % (Y)) -#define gcoMATH_DivideInt(X, Y) (gctINT)((X) / (Y)) -#define gcoMATH_DivideUInt(X, Y) (gctUINT)((X) / (Y)) -#define gcoMATH_DivideUInt64(X, Y) (gctUINT64)((X) / (Y)) -#define gcoMATH_Add(X, Y) (gctFLOAT)((X) + (Y)) -#define gcoMATH_Multiply(X, Y) (gctFLOAT)((X) * (Y)) -#define gcoMATH_Divide(X, Y) (gctFLOAT)((X) / (Y)) -#define gcoMATH_DivideFromUInteger(X, Y) (gctFLOAT)(X) / (gctFLOAT)(Y) - -#define gcoMATH_UInt2Float(X) (gctFLOAT)(X) -#define gcoMATH_Int2Float(X) (gctFLOAT)(X) -#define gcoMATH_Float2UInt(X) (gctUINT) (X + 0.5f) -#define gcoMATH_Float2Int(X) (gctINT) ((X > 0.0f)? (X + 0.5f) : (X - 0.5f)) -#define gcoMATH_Float2Int64(X) (gctINT64) ((X > 0.0f)? (X + 0.5f) : (X - 0.5f)) -#define gcoMATH_Fixed2Float(X) (gctFLOAT)((X) / 65536.0f) -#define gcoMATH_Float2NormalizedUInt8(X) (gctUINT8)((X) * 255.0f + 0.5f) - -#define gcoMATH_MultiplyFixed(X, Y) \ - (gctFIXED_POINT)( ((gctINT64) (X) * (Y)) >> 16 ) - -#define gcoMATH_DivideFixed(X, Y) \ - (gctFIXED_POINT)( (((gctINT64) (X)) << 16) / (Y) ) - -#define gcoMATH_MultiplyDivideFixed(X, Y, Z) \ - (gctFIXED_POINT)( (gctINT64) (X) * (Y) / (Z) ) - -#define gcoMATH_MIN(X, Y) (((X) < (Y))?(X):(Y)) -#define gcoMATH_MAX(X, Y) (((X) > (Y))?(X):(Y)) - -static gcmINLINE gctUINT gcoMath_Float2UINT_STICKROUNDING(IN gctFLOAT Value) -{ - gctUINT ret = 0; - gctFLOAT dp = 0.0f; - - if (Value < 0.0f) - { - return 0; - } - - ret = (gctUINT)(Value); - dp = Value - (gctFLOAT)ret; - - if ((dp == 0.5f && (ret & 0x1u)) || dp > 0.5f) - { - ret++; - } - - return ret; -} - -#endif - diff --git a/drivers/amlogic/npu/os/linux/user/gc_hal_user_os.c b/drivers/amlogic/npu/os/linux/user/gc_hal_user_os.c deleted file mode 100644 index fd0582c..0000000 --- a/drivers/amlogic/npu/os/linux/user/gc_hal_user_os.c +++ /dev/null @@ -1,7375 +0,0 @@ -/**************************************************************************** -* -* Copyright (c) 2005 - 2019 by Vivante Corp. All rights reserved. -* -* The material in this file is confidential and contains trade secrets -* of Vivante Corporation. This is proprietary information owned by -* Vivante Corporation. No part of this work may be disclosed, -* reproduced, copied, transmitted, or used in any way for any purpose, -* without the express written permission of Vivante Corporation. -* -*****************************************************************************/ - - -/** -** @file -** OS object for hal user layers. -** -*/ - -#if defined(SOLARIS) -# define __EXTENSIONS__ -#endif - -#include "gc_hal_user_linux.h" -#include "gc_hal_user_os_atomic.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#ifdef ANDROID -#include -#include -#endif - -#include "gc_hal_user_platform.h" -#include "gc_hal_dump.h" - -#define _GC_OBJ_ZONE gcvZONE_OS - -char const * const GALDeviceName[] = -{ - "/dev/galcore", - "/dev/graphics/galcore" -}; - -#define MAX_RETRY_IOCTL_TIMES 10000 - -#ifndef gcdBUILT_FOR_VALGRIND -#define gcdBUILT_FOR_VALGRIND 0 -#endif - -#define gcmGETPROCESSID() \ - getpid() - -#ifdef ANDROID -#define gcmGETTHREADID() \ - (gctUINT32) gettid() -#else -# define gcmGETTHREADID() \ - (gctUINT32) pthread_self() -#endif - -/******************************************************************************* -***** Version Signature *******************************************************/ - -#ifdef ANDROID -const char * _GAL_PLATFORM = "\n\0$PLATFORM$Android$\n"; -#else -const char * _GAL_PLATFORM = "\n\0$PLATFORM$Linux$\n"; -#endif - -/******************************************************************************\ -***************************** gcoOS Object Structure *************************** -\******************************************************************************/ - -typedef struct _gcsDRIVER_ARGS -{ - gctUINT64 InputBuffer; - gctUINT64 InputBufferSize; - gctUINT64 OutputBuffer; - gctUINT64 OutputBufferSize; -} -gcsDRIVER_ARGS; - -struct _gcoOS -{ - /* Object. */ - gcsOBJECT object; - - /* Context. */ - gctPOINTER context; - - /* Heap. */ - gcoHEAP heap; - -#if gcdENABLE_PROFILING - gctUINT64 startTick; -#endif - -#if VIVANTE_PROFILER_SYSTEM_MEMORY -#if gcdGC355_MEM_PRINT - /* For a single collection. */ - gctINT32 oneSize; - gctBOOL oneRecording; -#endif -#endif - - gcsPLATFORM platform; - - /* Handle to the device. */ - int device; -}; - -/******************************************************************************\ -*********************************** Globals ************************************ -\******************************************************************************/ - -static pthread_key_t gcProcessKey; - -gcsPLS gcPLS = gcPLS_INITIALIZER; -static pthread_mutex_t plsMutex = PTHREAD_MUTEX_INITIALIZER; - -/******************************************************************************\ -****************************** Internal Functions ****************************** -\******************************************************************************/ -#if (gcmIS_DEBUG(gcdDEBUG_TRACE) || gcdGC355_MEM_PRINT) -static void _ReportDB( - void - ) -{ - gceSTATUS status; - gcsHAL_INTERFACE iface; - - gcoOS_ZeroMemory(&iface, sizeof(iface)); - - iface.command = gcvHAL_DATABASE; - iface.u.Database.processID = (gctUINT32)(gctUINTPTR_T)gcoOS_GetCurrentProcessID(); - iface.u.Database.validProcessID = gcvTRUE; - - /* Call kernel service. */ - gcmONERROR(gcoOS_DeviceControl( - gcvNULL, - IOCTL_GCHAL_INTERFACE, - &iface, gcmSIZEOF(iface), - &iface, gcmSIZEOF(iface) - )); - - if ((iface.u.Database.vidMem.counters.bytes != 0) || - (iface.u.Database.nonPaged.counters.bytes != 0)) - { - gcmTRACE(gcvLEVEL_ERROR, "\n"); - gcmTRACE(gcvLEVEL_ERROR, "******* MEMORY LEAKS DETECTED *******\n"); - } - - if (iface.u.Database.vidMem.counters.bytes != 0) - { - gcmTRACE(gcvLEVEL_ERROR, "\n"); - gcmTRACE(gcvLEVEL_ERROR, "vidMem.bytes = %d\n", iface.u.Database.vidMem.counters.bytes); - gcmTRACE(gcvLEVEL_ERROR, "vidMem.maxBytes = %d\n", iface.u.Database.vidMem.counters.maxBytes); - gcmTRACE(gcvLEVEL_ERROR, "vidMem.totalBytes = %d\n", iface.u.Database.vidMem.counters.totalBytes); - } - - if (iface.u.Database.nonPaged.counters.bytes != 0) - { - gcmTRACE(gcvLEVEL_ERROR, "\n"); - gcmTRACE(gcvLEVEL_ERROR, "nonPaged.bytes = %d\n", iface.u.Database.nonPaged.counters.bytes); - gcmTRACE(gcvLEVEL_ERROR, "nonPaged.maxBytes = %d\n", iface.u.Database.nonPaged.counters.maxBytes); - gcmTRACE(gcvLEVEL_ERROR, "nonPaged.totalBytes = %d\n", iface.u.Database.nonPaged.counters.totalBytes); - } - - gcmPRINT("05) Video memory - current : %lld \n", iface.u.Database.vidMem.counters.bytes); - gcmPRINT("06) Video memory - maximum : %lld \n", iface.u.Database.vidMem.counters.maxBytes); - gcmPRINT("07) Video memory - total : %lld \n", iface.u.Database.vidMem.counters.totalBytes); - gcmPRINT("08) Video memory - allocation Count: %u \n", iface.u.Database.vidMem.counters.allocCount); - gcmPRINT("09) Video memory - deallocation Count : %u \n", iface.u.Database.vidMem.counters.freeCount); - -OnError:; -} -#endif - -#if gcdDUMP || gcdDUMP_API || gcdDUMP_2D -static void -_SetDumpFileInfo( - ) -{ - gceSTATUS status = gcvSTATUS_TRUE; - gctBOOL dumpNew2D = gcvFALSE; -#if gcdDUMP_2D - gcsTLS_PTR tls; -#endif - -#if gcdDUMP || gcdDUMP_2D - #define DUMP_FILE_PREFIX "hal" -#else - #define DUMP_FILE_PREFIX "api" -#endif - -#if defined(ANDROID) - /* The default key of dump key for match use. Only useful in android. Do not change it! */ - #define DEFAULT_DUMP_KEY "allprocesses" - - if (gcmIS_SUCCESS(gcoOS_StrCmp(gcdDUMP_KEY, DEFAULT_DUMP_KEY))) - status = gcvSTATUS_TRUE; - else - status = gcoOS_DetectProcessByName(gcdDUMP_KEY); -#endif - -#if gcdDUMP_2D - tls = (gcsTLS_PTR) pthread_getspecific(gcProcessKey); - - /* Enable new dump 2D by env variable "2D_DUMP_LEVEL". Level=2 dump all. Level=1 dump cmd only. */ - if (status != gcvSTATUS_TRUE) - { - gctSTRING dump = gcvNULL; - gctINT level = 0; - - if (gcmIS_SUCCESS(gcoOS_GetEnv(gcvNULL, "2D_DUMP_LEVEL", &dump)) && dump) - { - gcoOS_StrToInt(dump, &level); - - if (level != 0 && level < 4) - { - tls->newDump2DFlag = level; - dumpNew2D = gcvTRUE; - } - } - } - else - { - tls->newDump2DFlag = 3; - } -#endif - - if (status == gcvSTATUS_TRUE || dumpNew2D) - { -#if !gcdDUMP_IN_KERNEL - char dump_file[128]; - gctUINT offset = 0; - - /* Customize filename as needed. */ - gcmVERIFY_OK(gcoOS_PrintStrSafe(dump_file, - gcmSIZEOF(dump_file), - &offset, - "%s%s_dump_pid-%d_tid-%d_%s.log", - gcdDUMP_PATH, - DUMP_FILE_PREFIX, - (int) getpid(), - gcmGETTHREADID(), - dumpNew2D ? "dump2D" : gcdDUMP_KEY)); - - gcoOS_SetDebugFile(dump_file); -#endif - - gcoOS_SetDumpFlag(gcvTRUE); - } -} -#endif - -/******************************************************************************\ -**************************** OS Construct/Destroy ****************************** -\******************************************************************************/ -static gceSTATUS -_DestroyOs( - IN gcoOS Os - ) -{ - gceSTATUS status; - - gcmPROFILE_DECLARE_ONLY(gctUINT64 ticks); - - gcmHEADER(); - - if (gcPLS.os != gcvNULL) - { - - gcmPROFILE_QUERY(gcPLS.os->startTick, ticks); - gcmPROFILE_ONLY(gcmTRACE_ZONE(gcvLEVEL_INFO, gcvZONE_OS, - "Total ticks during gcoOS life: %llu", - ticks)); - - if (gcPLS.os->heap != gcvNULL) - { - gcoHEAP heap = gcPLS.os->heap; - -#if VIVANTE_PROFILER_SYSTEM_MEMORY - /* End profiler. */ - gcoHEAP_ProfileEnd(heap, "gcoOS_HEAP"); -#endif - - /* Mark the heap as gone. */ - gcPLS.os->heap = gcvNULL; - - /* Destroy the heap. */ - gcmONERROR(gcoHEAP_Destroy(heap)); - } - -#if VIVANTE_PROFILER_SYSTEM_MEMORY - /* End profiler. */ - gcoOS_ProfileEnd(gcPLS.os, "system memory"); -#endif - - /* Close the handle to the kernel service. */ - if (gcPLS.os->device != -1) - { -#if gcmIS_DEBUG(gcdDEBUG_TRACE) || gcdGC355_MEM_PRINT - _ReportDB(); -#endif - - close(gcPLS.os->device); - gcPLS.os->device = -1; - } - - /* Mark the gcoOS object as unknown. */ - gcPLS.os->object.type = gcvOBJ_UNKNOWN; - - /* Free the gcoOS structure. */ - free(gcPLS.os); - - /* Reset PLS object. */ - gcPLS.os = gcvNULL; - } - - /* Success. */ - gcmFOOTER_KILL(); - return gcvSTATUS_OK; - -OnError: - /* Return the status. */ - gcmFOOTER(); - return status; -} - -#if gcmIS_DEBUG(gcdDEBUG_STACK) && !defined(ANDROID) - -static __sighandler_t handleSEGV; -static __sighandler_t handleINT; - -static void -_DumpCallStackOnCrash( - int signo - ) -{ - printf("libGAL: catch signal %d\n", signo); - fflush(stdout); - - gcmSTACK_DUMP(); - - /* Restore old signal handler. */ - switch (signo) - { - case SIGSEGV: - signal(SIGSEGV, handleSEGV); - break; - case SIGINT: - signal(SIGINT, handleINT); - break; - default: - break; - } - - raise(signo); -} - -static void -_InstallSignalHandler( - void - ) -{ - handleSEGV = signal(SIGSEGV, _DumpCallStackOnCrash); - handleINT = signal(SIGINT, _DumpCallStackOnCrash); -} - -static void -_RestoreSignalHandler( - void - ) -{ - signal(SIGSEGV, handleSEGV); - signal(SIGINT, handleINT); -} -#endif - -static gceSTATUS -_ConstructOs( - IN gctPOINTER Context, - OUT gcoOS * Os - ) -{ - gcoOS os = gcPLS.os; - gceSTATUS status; - - gcmPROFILE_DECLARE_ONLY(gctUINT64 freq); - - gcmHEADER_ARG("Context=0x%x", Context); - - if (os == gcvNULL) - { - /* Allocate the gcoOS structure. */ - os = malloc(gcmSIZEOF(struct _gcoOS)); - if (os == gcvNULL) - { - gcmONERROR(gcvSTATUS_OUT_OF_MEMORY); - } - - /* Initialize the gcoOS object. */ - os->object.type = gcvOBJ_OS; - os->context = Context; - os->heap = gcvNULL; - os->device = -1; - - /* Set the object pointer to PLS. */ - gcmASSERT(gcPLS.os == gcvNULL); - gcPLS.os = os; - - - /* Construct heap. */ - status = gcoHEAP_Construct(gcvNULL, gcdHEAP_SIZE, &os->heap); - - if (gcmIS_ERROR(status)) - { - gcmTRACE_ZONE( - gcvLEVEL_WARNING, gcvZONE_OS, - "%s(%d): Could not construct gcoHEAP (%d).", - __FUNCTION__, __LINE__, status - ); - - os->heap = gcvNULL; - } -#if VIVANTE_PROFILER_SYSTEM_MEMORY - else - { - /* Start profiler. */ - gcoHEAP_ProfileStart(os->heap); - } -#endif -#if VIVANTE_PROFILER_SYSTEM_MEMORY - /* Start profiler. */ - gcoOS_ProfileStart(os); -#endif - /* Get profiler start tick. */ - gcmPROFILE_INIT(freq, os->startTick); - - /* Get platform callback functions. */ - gcoPLATFORM_QueryOperations(&os->platform.ops); - } - - /* Return pointer to the gcoOS object. */ - if (Os != gcvNULL) - { - *Os = os; - } - - /* Success. */ - gcmFOOTER_ARG("*Os=0x%x", os); - return gcvSTATUS_OK; - -OnError: - /* Roll back. */ - gcmVERIFY_OK(_DestroyOs(gcvNULL)); - gcmFOOTER(); - return status; -} - -/******************************************************************************\ -************************* Process/Thread Local Storage ************************* -\******************************************************************************/ - -static gceSTATUS __attribute__((constructor)) _ModuleConstructor(void); -static void __attribute__((destructor)) _ModuleDestructor(void); - -static gceSTATUS -_QueryVideoMemory( - OUT gctUINT32 * InternalPhysName, - OUT gctSIZE_T * InternalSize, - OUT gctUINT32 * ExternalPhysName, - OUT gctSIZE_T * ExternalSize, - OUT gctUINT32 * ContiguousPhysName, - OUT gctSIZE_T * ContiguousSize - ) -{ - gceSTATUS status; - gcsHAL_INTERFACE iface; - - gcmHEADER(); - - /* Call kernel HAL to query video memory. */ - iface.ignoreTLS = gcvTRUE; - iface.hardwareType = gcPLS.hal->defaultHwType, - iface.coreIndex = 0; - - iface.command = gcvHAL_QUERY_VIDEO_MEMORY; - - /* Call kernel service. */ - gcmONERROR(gcoOS_DeviceControl(gcvNULL, - IOCTL_GCHAL_INTERFACE, - &iface, gcmSIZEOF(iface), - &iface, gcmSIZEOF(iface))); - - if (InternalPhysName != gcvNULL) - { - /* Verify arguments. */ - gcmDEBUG_VERIFY_ARGUMENT(InternalSize != gcvNULL); - - /* Save internal memory size. */ - *InternalPhysName = iface.u.QueryVideoMemory.internalPhysName; - *InternalSize = (gctSIZE_T)iface.u.QueryVideoMemory.internalSize; - } - - if (ExternalPhysName != gcvNULL) - { - /* Verify arguments. */ - gcmDEBUG_VERIFY_ARGUMENT(ExternalSize != gcvNULL); - - /* Save external memory size. */ - *ExternalPhysName = iface.u.QueryVideoMemory.externalPhysName; - *ExternalSize = (gctSIZE_T)iface.u.QueryVideoMemory.externalSize; - } - - if (ContiguousPhysName != gcvNULL) - { - /* Verify arguments. */ - gcmDEBUG_VERIFY_ARGUMENT(ContiguousSize != gcvNULL); - - /* Save contiguous memory size. */ - *ContiguousPhysName = iface.u.QueryVideoMemory.contiguousPhysName; - *ContiguousSize = (gctSIZE_T)iface.u.QueryVideoMemory.contiguousSize; - } - - /* Success. */ - gcmFOOTER_ARG("*InternalPhysName=0x%08x *InternalSize=%lu " - "*ExternalPhysName=0x%08x *ExternalSize=%lu " - "*ContiguousPhysName=0x%08x *ContiguousSize=%lu", - gcmOPT_VALUE(InternalPhysName), gcmOPT_VALUE(InternalSize), - gcmOPT_VALUE(ExternalPhysName), gcmOPT_VALUE(ExternalSize), - gcmOPT_VALUE(ContiguousPhysName), - gcmOPT_VALUE(ContiguousSize)); - return gcvSTATUS_OK; - -OnError: - /* Return the status. */ - gcmFOOTER(); - return status; -} - -static void -_OpenGalLib( - gcsTLS_PTR TLS - ) -{ -#if !gcdSTATIC_LINK -#if defined(ANDROID) - gctHANDLE handle; - - gcmHEADER_ARG("TLS=0x%x", TLS); - - gcmASSERT(TLS != gcvNULL); - - /* Only two possibilities on android. */ -#if defined(__LP64__) - handle = dlopen("/system/vendor/lib64/libGAL.so", RTLD_NOW); -# else - handle = dlopen("/system/vendor/lib/libGAL.so", RTLD_NOW); -# endif - - if (handle == gcvNULL) - { -#if defined(__LP64__) - handle = dlopen("/system/lib64/libGAL.so", RTLD_NOW); -# else - handle = dlopen("/system/lib/libGAL.so", RTLD_NOW); -# endif - } - - if (handle != gcvNULL) - { - TLS->handle = handle; - } - - gcmFOOTER_NO(); -# else - gctSTRING path; - gctSTRING envPath = gcvNULL; - gctSTRING oneEnvPath; - gctSTRING fullPath = gcvNULL; - gctINT32 len; - gctHANDLE handle = gcvNULL; - gctSTRING saveptr = gcvNULL; - - gcmHEADER_ARG("TLS=0x%x", TLS); - - gcmASSERT(TLS != gcvNULL); - - do - { - path = getenv("LD_LIBRARY_PATH"); - - if (path != gcvNULL) - { - len = strlen(path) + 1; - - envPath = malloc(len); - fullPath = malloc(len + 10); - - if (envPath == NULL || fullPath == NULL) - { - break; - } - - memset(envPath, 0, len); - memcpy(envPath, path, len); - oneEnvPath = strtok_r(envPath, ":", &saveptr); - - while (oneEnvPath != NULL) - { - sprintf(fullPath, "%s/libGAL.so", oneEnvPath); - - handle = dlopen(fullPath, RTLD_NOW | RTLD_NODELETE); - - if (handle != gcvNULL) - { - break; - } - - oneEnvPath = strtok_r(NULL, ":", &saveptr); - } - } - - if (handle == gcvNULL) - { - handle = dlopen("/usr/lib/libGAL.so", RTLD_NOW | RTLD_NODELETE); - } - - if (handle == gcvNULL) - { - handle = dlopen("/lib/libGAL.so", RTLD_NOW | RTLD_NODELETE); - } - } - while (gcvFALSE); - - if (envPath != gcvNULL) - { - free(envPath); - } - - if (fullPath != gcvNULL) - { - free(fullPath); - } - - if (handle != gcvNULL) - { - TLS->handle = handle; - } - - gcmFOOTER_NO(); -# endif -#endif -} - -static void -_CloseGalLib( - gcsTLS_PTR TLS - ) -{ - gcmHEADER_ARG("TLS=0x%x", TLS); - - gcmASSERT(TLS != gcvNULL); - - if (TLS->handle != gcvNULL) - { - gcoOS_FreeLibrary(gcvNULL, TLS->handle); - TLS->handle = gcvNULL; - } - - gcmFOOTER_NO(); -} - -static void -_PLSDestructor( - void - ) -{ - gcmHEADER(); - -#if gcdENABLE_3D -#if gcdSYNC - if(gcPLS.globalFenceID) gcoOS_AtomDestroy(gcvNULL, gcPLS.globalFenceID); -#endif -#endif - - if (gcPLS.destructor != gcvNULL) - { - gcPLS.destructor(&gcPLS); - gcPLS.destructor = gcvNULL; - } - -#if gcdDUMP_2D - gcmVERIFY_OK(gcoOS_DeleteMutex(gcPLS.os, dumpMemInfoListMutex)); - dumpMemInfoListMutex = gcvNULL; -#endif - - gcmVERIFY_OK(gcoOS_DeleteMutex(gcPLS.os, gcPLS.accessLock)); - gcPLS.accessLock = gcvNULL; - - gcmVERIFY_OK(gcoOS_DeleteMutex(gcPLS.os, gcPLS.glFECompilerAccessLock)); - gcPLS.glFECompilerAccessLock = gcvNULL; - - gcmVERIFY_OK(gcoOS_DeleteMutex(gcPLS.os, gcPLS.clFECompilerAccessLock)); - gcPLS.clFECompilerAccessLock = gcvNULL; - - gcmVERIFY_OK(gcoOS_DeleteMutex(gcPLS.os, gcPLS.vxContextGlobalLock)); - gcPLS.vxContextGlobalLock = gcvNULL; - - gcmVERIFY_OK(gcoOS_AtomDestroy(gcPLS.os, gcPLS.reference)); - gcPLS.reference = gcvNULL; - - if (gcPLS.hal != gcvNULL) - { - gcmVERIFY_OK(gcoHAL_DestroyEx(gcPLS.hal)); - gcPLS.hal = gcvNULL; - } - - gcmVERIFY_OK(_DestroyOs(gcPLS.os)); - - pthread_key_delete(gcProcessKey); - - gcmFOOTER_NO(); -} - -static void -_TLSDestructor( - gctPOINTER TLS - ) -{ - gcsTLS_PTR tls; - gctINT reference = 0; - gctINT i; - - gcmHEADER_ARG("TLS=0x%x", TLS); - - tls = (gcsTLS_PTR) TLS; - gcmASSERT(tls != gcvNULL); - - pthread_setspecific(gcProcessKey, tls); - - if (tls->copied) - { - /* Zero out all information if this TLS was copied. */ - gcoOS_ZeroMemory(tls, gcmSIZEOF(gcsTLS)); - } - - for (i = 0; i < gcvTLS_KEY_COUNT; i++) - { - gcsDRIVER_TLS_PTR drvTLS = tls->driverTLS[i]; - - if (drvTLS && drvTLS->destructor != gcvNULL) - { - drvTLS->destructor(drvTLS); - } - - tls->driverTLS[i] = gcvNULL; - } - -#if gcdENABLE_3D - /* DON'T destroy tls->engine3D, which belongs to app context - */ -#endif - - -#if gcdUSE_VX - if(tls->engineVX) - { - gcmVERIFY_OK(gcoVX_Destroy(tls->engineVX)); - } -#endif - - if (tls->defaultHardware != gcvNULL) - { - gceHARDWARE_TYPE type = tls->currentType; - - tls->currentType = gcvHARDWARE_3D; - - gcmTRACE_ZONE( - gcvLEVEL_VERBOSE, gcvZONE_HARDWARE, - "%s(%d): destroying default hardware object 0x%08X.", - __FUNCTION__, __LINE__, tls->defaultHardware - ); - - gcmVERIFY_OK(gcoHARDWARE_Destroy(tls->defaultHardware, gcvTRUE)); - - tls->defaultHardware = gcvNULL; - tls->currentHardware = gcvNULL; - tls->currentType = type; - } - - if (tls->hardware2D != gcvNULL) - { - gceHARDWARE_TYPE type = tls->currentType; - tls->currentType = gcvHARDWARE_2D; - - gcmTRACE_ZONE( - gcvLEVEL_VERBOSE, gcvZONE_HARDWARE, - "%s(%d): destroying hardware object 0x%08X.", - __FUNCTION__, __LINE__, tls->hardware2D - ); - - tls->hardware2D = gcvNULL; - tls->currentType = type; - } - - - if (gcPLS.threadID && gcPLS.threadID != gcmGETTHREADID() && !gcPLS.exiting) - { - _CloseGalLib(tls); - } - - if (gcPLS.reference != gcvNULL) - { - /* Decrement the reference. */ - gcmVERIFY_OK(gcoOS_AtomDecrement(gcPLS.os, - gcPLS.reference, - &reference)); - - /* Check if there are still more references. */ - if (reference == 1) - { - /* If all threads exit, destruct PLS */ - _PLSDestructor(); - } - } - - free(tls); - - pthread_setspecific(gcProcessKey, gcvNULL); - - gcmFOOTER_NO(); -} - -static void -_AtForkChild( - void - ) -{ - gcPLS.os = gcvNULL; - gcPLS.hal = gcvNULL; - gcPLS.contiguousSize = 0; - gcPLS.processID = 0; - gcPLS.reference = 0; - gcPLS.patchID = gcvPATCH_NOTINIT; - - pthread_key_delete(gcProcessKey); -} - -static void -_OnceInit( - void - ) -{ -#if (defined(ANDROID) && (ANDROID_SDK_VERSION > 16)) || !defined(ANDROID) - /* Use once control to avoid registering the handler multiple times. */ - pthread_atfork(gcvNULL, gcvNULL, _AtForkChild); -#endif - - /* - * On Android, crash stack is in logcat log, so don't try to catch - * these signals. - */ -#if gcmIS_DEBUG(gcdDEBUG_STACK) && !defined(ANDROID) - _InstallSignalHandler(); -#endif -} - -static gceSTATUS -_ModuleConstructor( - void - ) -{ - gceSTATUS status = gcvSTATUS_OK; - int result; - static pthread_once_t onceControl = {PTHREAD_ONCE_INIT}; - -#if VIVANTE_PROFILER_SYSTEM_MEMORY - gcoOS_InitMemoryProfile(); -#endif - - gcmHEADER(); - - if (gcPLS.processID) - { - gcmFOOTER_NO(); - return gcvSTATUS_OK; - } - - /* Each process gets its own objects. */ - gcmASSERT(gcPLS.os == gcvNULL); - gcmASSERT(gcPLS.hal == gcvNULL); - - gcmASSERT(gcPLS.internalLogical == gcvNULL); - gcmASSERT(gcPLS.externalLogical == gcvNULL); - gcmASSERT(gcPLS.contiguousLogical == gcvNULL); - - pthread_once(&onceControl, _OnceInit); - - /* Create tls key. */ - result = pthread_key_create(&gcProcessKey, _TLSDestructor); - - if (result != 0) - { - gcmTRACE( - gcvLEVEL_ERROR, - "%s(%d): pthread_key_create returned %d", - __FUNCTION__, __LINE__, result - ); - - gcmONERROR(gcvSTATUS_OUT_OF_MEMORY); - } - - /* Construct OS object. */ - gcmONERROR(_ConstructOs(gcvNULL, gcvNULL)); - - /* Construct PLS reference atom. */ - gcmONERROR(gcoOS_AtomConstruct(gcPLS.os, &gcPLS.reference)); - - /* Increment PLS reference for main thread. */ - gcmONERROR(gcoOS_AtomIncrement(gcPLS.os, gcPLS.reference, gcvNULL)); - - /* Record the process and thread that calling this constructor function */ - gcPLS.processID = gcmGETPROCESSID(); - gcPLS.threadID = gcmGETTHREADID(); - - /* Construct access lock */ - gcmONERROR(gcoOS_CreateMutex(gcPLS.os, &gcPLS.accessLock)); - - /* Construct gl FE compiler access lock */ - gcmONERROR(gcoOS_CreateMutex(gcPLS.os, &gcPLS.glFECompilerAccessLock)); - - /* Construct cl FE compiler access lock */ - gcmONERROR(gcoOS_CreateMutex(gcPLS.os, &gcPLS.clFECompilerAccessLock)); - - /* Construct vx context access lock */ - gcmONERROR(gcoOS_CreateMutex(gcPLS.os, &gcPLS.vxContextGlobalLock)); - -#if gcdDUMP_2D - gcmONERROR(gcoOS_CreateMutex(gcPLS.os, &dumpMemInfoListMutex)); -#endif - - gcmFOOTER_ARG( - "gcPLS.os=0x%08X, gcPLS.hal=0x%08X", - gcPLS.os, gcPLS.hal - ); - - return status; - -OnError: - if (gcPLS.accessLock != gcvNULL) - { - /* Destroy access lock */ - gcmVERIFY_OK(gcoOS_DeleteMutex(gcPLS.os, gcPLS.accessLock)); - gcPLS.accessLock = gcvNULL; - } - - if (gcPLS.glFECompilerAccessLock != gcvNULL) - { - /* Destroy access lock */ - gcmVERIFY_OK(gcoOS_DeleteMutex(gcPLS.os, gcPLS.glFECompilerAccessLock)); - gcPLS.glFECompilerAccessLock = gcvNULL; - } - - if (gcPLS.clFECompilerAccessLock != gcvNULL) - { - /* Destroy access lock */ - gcmVERIFY_OK(gcoOS_DeleteMutex(gcPLS.os, gcPLS.clFECompilerAccessLock)); - gcPLS.clFECompilerAccessLock = gcvNULL; - } - - if (gcPLS.vxContextGlobalLock != gcvNULL) - { - /* Destroy vx context access lock */ - gcmVERIFY_OK(gcoOS_DeleteMutex(gcPLS.os, gcPLS.vxContextGlobalLock)); - gcPLS.vxContextGlobalLock = gcvNULL; - } - - if (gcPLS.reference != gcvNULL) - { - /* Destroy the reference. */ - gcmVERIFY_OK(gcoOS_AtomDestroy(gcPLS.os, gcPLS.reference)); - gcPLS.reference = gcvNULL; - } - - gcmFOOTER(); - return status; -} - -static gceSTATUS -_OpenDevice( - IN gcoOS Os - ) -{ - gceSTATUS status = gcvSTATUS_OK; - - gcmHEADER(); - - pthread_mutex_lock(&plsMutex); - - if (gcPLS.bDeviceOpen) - { - pthread_mutex_unlock(&plsMutex); - gcmFOOTER_NO(); - return gcvSTATUS_OK; - } - - { - gctUINT tryCount; - for (tryCount = 0; tryCount < 5; tryCount++) - { - gctUINT i; - - if (tryCount > 0) - { - /* Sleep for a while when second and later tries. */ - usleep(1000000); - gcmPRINT("Failed to open device: %s, Try again...", strerror(errno)); - } - - /* Attempt to open the device. */ - for (i = 0; i < gcmCOUNTOF(GALDeviceName); i += 1) - { - gcmTRACE_ZONE( - gcvLEVEL_VERBOSE, gcvZONE_OS, - "%s(%d): Attempting to open device %s.", - __FUNCTION__, __LINE__, GALDeviceName[i] - ); - - Os->device = open(GALDeviceName[i], O_RDWR); - - if (Os->device >= 0) - { - gcmTRACE_ZONE( - gcvLEVEL_VERBOSE, gcvZONE_OS, - "%s(%d): Opened device %s.", - __FUNCTION__, __LINE__, GALDeviceName[i] - ); - - break; - } - } - - if (Os->device >= 0) - { - /* Device opened. */ - break; - } - } - } - if (Os->device < 0) - { - pthread_mutex_unlock(&plsMutex); - - gcmPRINT( - "%s(%d): FATAL: Failed to open device, errno=%s.", - __FUNCTION__, __LINE__, strerror(errno) - ); - - exit(1); - - /* Should not run here. */ - gcmFOOTER(); - return gcvSTATUS_GENERIC_IO; - } - - /* Construct gcoHAL object. */ - gcmONERROR(gcoHAL_ConstructEx(gcvNULL, gcvNULL, &gcPLS.hal)); - - /* Query the video memory sizes. */ - gcmONERROR(_QueryVideoMemory( - &gcPLS.internalPhysName, - &gcPLS.internalSize, - &gcPLS.externalPhysName, - &gcPLS.externalSize, - &gcPLS.contiguousPhysName, - &gcPLS.contiguousSize - )); - - /* make sure this instruction is at last */ - gcPLS.bDeviceOpen = gcvTRUE; - -OnError: - pthread_mutex_unlock(&plsMutex); - - gcmFOOTER(); - return status; -} - -static void -_ModuleDestructor( - void - ) -{ - gctINT reference = 0; - gcmHEADER(); - - if (gcPLS.reference != gcvNULL) - { - gcPLS.exiting = gcvTRUE; - - /* Decrement the reference for main thread. */ - gcmVERIFY_OK(gcoOS_AtomDecrement(gcPLS.os, - gcPLS.reference, - &reference)); - - if (reference == 1) - { - /* If all threads exit, destruct PLS. */ - _PLSDestructor(); - } - else - { - gcoOS_FreeThreadData(); - } - } - -#if gcmIS_DEBUG(gcdDEBUG_STACK) && !defined(ANDROID) - _RestoreSignalHandler(); -#endif - -#if VIVANTE_PROFILER_SYSTEM_MEMORY - gcoOS_DeInitMemoryProfile(); -#endif - - gcmFOOTER_NO(); -} - -/******************************************************************************\ -********************************* gcoOS API Code ******************************* -\******************************************************************************/ - -/******************************************************************************* - ** - ** gcoOS_GetPLSValue - ** - ** Get value associated with the given key. - ** - ** INPUT: - ** - ** gcePLS_VALUE key - ** key to look up. - ** - ** OUTPUT: - ** - ** None - ** - ** RETURN: - ** - ** gctPOINTER - ** Pointer to object associated with key. - */ -gctPOINTER -gcoOS_GetPLSValue( - IN gcePLS_VALUE key - ) -{ - switch (key) - { - case gcePLS_VALUE_EGL_DISPLAY_INFO : - return gcPLS.eglDisplayInfo; - - case gcePLS_VALUE_EGL_CONFIG_FORMAT_INFO : - return (gctPOINTER) gcPLS.eglConfigFormat; - - case gcePLS_VALUE_EGL_DESTRUCTOR_INFO : - return (gctPOINTER) gcPLS.destructor; - } - - return gcvNULL; -} - -/******************************************************************************* - ** - ** gcoOS_SetPLSValue - ** - ** Associated object represented by 'value' with the given key. - ** - ** INPUT: - ** - ** gcePLS_VALUE key - ** key to associate. - ** - ** gctPOINTER value - ** value to associate with key. - ** - ** OUTPUT: - ** - ** None - ** - */ -void -gcoOS_SetPLSValue( - IN gcePLS_VALUE key, - IN gctPOINTER value - ) -{ - switch (key) - { - case gcePLS_VALUE_EGL_DISPLAY_INFO : - gcPLS.eglDisplayInfo = value; - return; - - case gcePLS_VALUE_EGL_CONFIG_FORMAT_INFO : - gcPLS.eglConfigFormat = (gceSURF_FORMAT)(gctUINTPTR_T)value; - return; - - case gcePLS_VALUE_EGL_DESTRUCTOR_INFO : - gcPLS.destructor = (gctPLS_DESTRUCTOR) value; - return; - } -} - -static gcmINLINE gceSTATUS -_GetTLS( - OUT gcsTLS_PTR * TLS - ) -{ - gceSTATUS status = gcvSTATUS_OK; - gcsTLS_PTR tls = gcvNULL; - int res; - - gcmHEADER_ARG("TLS=%p", TLS); - - if (!gcPLS.processID) - { - pthread_mutex_lock(&plsMutex); - status = _ModuleConstructor(); - pthread_mutex_unlock(&plsMutex); - - gcmONERROR(status); - } - - tls = (gcsTLS_PTR) pthread_getspecific(gcProcessKey); - - if (tls == NULL) - { - tls = (gcsTLS_PTR) malloc(sizeof(gcsTLS)); - - if (!tls) - { - gcmONERROR(gcvSTATUS_OUT_OF_MEMORY); - } - - memset(tls, 0, sizeof(gcsTLS)); - - /* Determine default hardware type later. */ - tls->currentType = gcvHARDWARE_INVALID; - - res = pthread_setspecific(gcProcessKey, tls); - - if (res != 0) - { - gcmTRACE( - gcvLEVEL_ERROR, - "%s(%d): pthread_setspecific returned %d", - __FUNCTION__, __LINE__, res - ); - - gcmONERROR(gcvSTATUS_GENERIC_IO); - } - - if (gcPLS.threadID && gcPLS.threadID != gcmGETTHREADID()) - _OpenGalLib(tls); - - if (gcPLS.reference != gcvNULL) - { - /* Increment PLS reference. */ - gcmONERROR(gcoOS_AtomIncrement(gcPLS.os, gcPLS.reference, gcvNULL)); - } - -#if gcdDUMP || gcdDUMP_API || gcdDUMP_2D - _SetDumpFileInfo(); -#endif - } - - *TLS = tls; - - gcmFOOTER_NO(); - return gcvSTATUS_OK; - -OnError: - if (tls != gcvNULL) - { - free(tls); - } - - * TLS = gcvNULL; - - gcmFOOTER(); - return status; -} - -/******************************************************************************* - ** - ** gcoOS_GetTLS - ** - ** Get access to the thread local storage. - ** - ** INPUT: - ** - ** Nothing. - ** - ** OUTPUT: - ** - ** gcsTLS_PTR * TLS - ** Pointer to a variable that will hold the pointer to the TLS. - */ -gceSTATUS -gcoOS_GetTLS( - OUT gcsTLS_PTR * TLS - ) -{ - gceSTATUS status; - gcsTLS_PTR tls = gcvNULL; - - gcmONERROR(_GetTLS(&tls)); - - if (!gcPLS.bDeviceOpen) - { - status = _OpenDevice(gcPLS.os); - gcmONERROR(status); - } - - if ((tls->currentType == gcvHARDWARE_INVALID) && gcPLS.hal) - { - tls->currentType = gcPLS.hal->defaultHwType; - } - - *TLS = tls; - return gcvSTATUS_OK; - -OnError: - *TLS = gcvNULL; - return status; -} - -/* - * gcoOS_CopyTLS - * - * Copy the TLS from a source thread and mark this thread as a copied thread, so the destructor won't free the resources. - * - * NOTE: Make sure the "source thread" doesn't get kiiled while this thread is running, since the objects will be taken away. This - * will be fixed in a future version of the HAL when reference counters will be used to keep track of object usage (automatic - * destruction). - */ -gceSTATUS gcoOS_CopyTLS(IN gcsTLS_PTR Source) -{ - gceSTATUS status; - gcsTLS_PTR tls; - - gcmHEADER(); - - /* Verify the arguyments. */ - gcmDEBUG_VERIFY_ARGUMENT(Source != gcvNULL); - - /* Get the thread specific data. */ - tls = pthread_getspecific(gcProcessKey); - - if (tls != gcvNULL) - { - /* We cannot copy if the TLS has already been initialized. */ - gcmONERROR(gcvSTATUS_INVALID_REQUEST); - } - - /* Allocate memory for the TLS. */ - tls = malloc(gcmSIZEOF(gcsTLS)); - - if (!tls) - { - gcmONERROR(gcvSTATUS_OUT_OF_MEMORY); - } - - /* Set the thread specific data. */ - pthread_setspecific(gcProcessKey, tls); - - if (gcPLS.threadID && gcPLS.threadID != gcmGETTHREADID()) - _OpenGalLib(tls); - - if (gcPLS.reference != gcvNULL) - { - /* Increment PLS reference. */ - gcmONERROR(gcoOS_AtomIncrement(gcPLS.os, gcPLS.reference, gcvNULL)); - } - - /* Copy the TLS information. */ - gcoOS_MemCopy(tls, Source, sizeof(gcsTLS)); - - /* Mark this TLS as copied. */ - tls->copied = gcvTRUE; - - tls->currentHardware = gcvNULL; - -#if gcdDUMP || gcdDUMP_API || gcdDUMP_2D - _SetDumpFileInfo(); -#endif - - /* Success. */ - gcmFOOTER_NO(); - return gcvSTATUS_OK; - -OnError: - /* Return the status. */ - gcmFOOTER(); - return status; -} - - -gceSTATUS -gcoOS_QueryTLS( - OUT gcsTLS_PTR * TLS - ) -{ - gceSTATUS status = gcvSTATUS_OK; - gcsTLS_PTR tls; - - gcmHEADER(); - - /* Verify the arguyments. */ - gcmVERIFY_ARGUMENT(TLS != gcvNULL); - - /* Get the thread specific data. */ - tls = pthread_getspecific(gcProcessKey); - - /* Return pointer to user. */ - *TLS = tls; - - /* Return the status. */ - gcmFOOTER(); - return status; -} - -/* Get access to driver tls. */ -gceSTATUS -gcoOS_GetDriverTLS( - IN gceTLS_KEY Key, - OUT gcsDRIVER_TLS_PTR * TLS - ) -{ - gceSTATUS status; - gcsTLS_PTR tls; - - gcmHEADER_ARG("Key=%d", Key); - - if (Key >= gcvTLS_KEY_COUNT) - { - gcmONERROR(gcvSTATUS_INVALID_ARGUMENT); - } - - /* Get generic tls. */ - gcmONERROR(_GetTLS(&tls)); - - *TLS = tls->driverTLS[Key]; - gcmFOOTER_NO(); - return gcvSTATUS_OK; - -OnError: - /* Return the status. */ - gcmFOOTER(); - return status; -} - -/* Set driver tls. */ -gceSTATUS -gcoOS_SetDriverTLS( - IN gceTLS_KEY Key, - IN gcsDRIVER_TLS * TLS - ) -{ - gceSTATUS status; - gcsTLS_PTR tls; - - gcmHEADER_ARG("Key=%d", Key); - - if (Key >= gcvTLS_KEY_COUNT) - { - gcmONERROR(gcvSTATUS_INVALID_ARGUMENT); - } - - /* Get generic tls. */ - gcmONERROR(_GetTLS(&tls)); - - tls->driverTLS[Key] = TLS; - gcmFOOTER_NO(); - return gcvSTATUS_OK; - -OnError: - /* Return the status. */ - gcmFOOTER(); - return status; -} - - -/******************************************************************************* -** -** gcoOS_LockPLS -** -** Lock mutext before access PLS if needed -** -** INPUT: -** -** Nothing. -** -** OUTPUT: -** -** Nothing. -*/ -gceSTATUS -gcoOS_LockPLS( - void - ) -{ - gceSTATUS status = gcvSTATUS_OK; - gcmHEADER(); - if (gcPLS.accessLock) - { - status = gcoOS_AcquireMutex(gcPLS.os, gcPLS.accessLock, gcvINFINITE); - - } - gcmFOOTER_ARG("Lock PLS ret=%d", status); - - return status; -} - -/******************************************************************************* -** -** gcoOS_UnLockPLS -** -** Release mutext after access PLS if needed -** -** INPUT: -** -** Nothing. -** -** OUTPUT: -** -** Nothing. -*/ -gceSTATUS -gcoOS_UnLockPLS( - void - ) -{ - gceSTATUS status = gcvSTATUS_OK; - gcmHEADER(); - if (gcPLS.accessLock) - { - status = gcoOS_ReleaseMutex(gcPLS.os, gcPLS.accessLock); - - } - gcmFOOTER_ARG("Release PLS ret=%d", status); - - return status; -} - -/******************************************************************************* -** -** gcoOS_LockGLFECompiler -** -** Lock mutext before access GL FE compiler if needed -** -** INPUT: -** -** Nothing. -** -** OUTPUT: -** -** Nothing. -*/ -gceSTATUS -gcoOS_LockGLFECompiler( - void - ) -{ - gceSTATUS status = gcvSTATUS_OK; - gcmHEADER(); - if (gcPLS.glFECompilerAccessLock) - { - status = gcoOS_AcquireMutex(gcPLS.os, gcPLS.glFECompilerAccessLock, gcvINFINITE); - } - gcmFOOTER_ARG("Lock GL FE compiler ret=%d", status); - - return status; -} - -/******************************************************************************* -** -** gcoOS_UnLockGLFECompiler -** -** Release mutext after access GL FE compiler if needed -** -** INPUT: -** -** Nothing. -** -** OUTPUT: -** -** Nothing. -*/ -gceSTATUS -gcoOS_UnLockGLFECompiler( - void - ) -{ - gceSTATUS status = gcvSTATUS_OK; - gcmHEADER(); - if (gcPLS.glFECompilerAccessLock) - { - status = gcoOS_ReleaseMutex(gcPLS.os, gcPLS.glFECompilerAccessLock); - } - gcmFOOTER_ARG("Release GL FE compiler ret=%d", status); - - return status; -} - -/******************************************************************************* -** -** gcoOS_LockCLFECompiler -** -** Lock mutext before access CL FE compiler if needed -** -** INPUT: -** -** Nothing. -** -** OUTPUT: -** -** Nothing. -*/ -gceSTATUS -gcoOS_LockCLFECompiler( - void - ) -{ - gceSTATUS status = gcvSTATUS_OK; - gcmHEADER(); - if (gcPLS.clFECompilerAccessLock) - { - status = gcoOS_AcquireMutex(gcPLS.os, gcPLS.clFECompilerAccessLock, gcvINFINITE); - } - gcmFOOTER_ARG("Lock CL FE compiler ret=%d", status); - - return status; -} - -/******************************************************************************* -** -** gcoOS_UnLockCLFECompiler -** -** Release mutext after access CL FE compiler if needed -** -** INPUT: -** -** Nothing. -** -** OUTPUT: -** -** Nothing. -*/ -gceSTATUS -gcoOS_UnLockCLFECompiler( - void - ) -{ - gceSTATUS status = gcvSTATUS_OK; - gcmHEADER(); - if (gcPLS.clFECompilerAccessLock) - { - status = gcoOS_ReleaseMutex(gcPLS.os, gcPLS.clFECompilerAccessLock); - } - gcmFOOTER_ARG("Release CL FE compiler ret=%d", status); - - return status; -} - -/******************************************************************************* -** -** gcoOS_FreeThreadData -** -** Destroy the objects associated with the current thread. -** -** INPUT: -** -** Nothing. -** -** OUTPUT: -** -** Nothing. -*/ -void -gcoOS_FreeThreadData( - void - ) -{ - gcsTLS_PTR tls; - - tls = (gcsTLS_PTR) pthread_getspecific(gcProcessKey); - - if (tls != NULL) - { - if (gcPLS.processID != (gctUINT32)(gctUINTPTR_T)gcmGETPROCESSID()) - { - /* This process is not the one called construct function. - * It maybe created by fork or clone, just return in this case . */ - return; - } - - _TLSDestructor((gctPOINTER) tls); - } -} - -/******************************************************************************* - ** - ** gcoOS_Construct - ** - ** Construct a new gcoOS object. Empty function only for compatibility. - ** - ** INPUT: - ** - ** gctPOINTER Context - ** Pointer to an OS specific context. - ** - ** OUTPUT: - ** - ** Nothing. - ** - */ -gceSTATUS -gcoOS_Construct( - IN gctPOINTER Context, - OUT gcoOS * Os - ) -{ - gceSTATUS status; - gcsTLS_PTR tls; - - gcmONERROR(gcoOS_GetTLS(&tls)); - - /* Return gcoOS object for compatibility to prevent any failure in applications. */ - *Os = gcPLS.os; - - return gcvSTATUS_OK; - -OnError: - return status; -} - -/******************************************************************************* - ** - ** gcoOS_Destroy - ** - ** Destroys an gcoOS object. Empty function only for compatibility. - ** - ** ARGUMENTS: - ** - ** gcoOS Os - ** Pointer to the gcoOS object that needs to be destroyed. - ** - ** OUTPUT: - ** - ** Nothing. - ** - */ -gceSTATUS -gcoOS_Destroy( - IN gcoOS Os - ) -{ - return gcvSTATUS_OK; -} - -/******************************************************************************* -** -** gcoOS_GetPhysicalSystemMemorySize -** -** Get the amount of system memory. -** -** OUTPUT: -** -** gctSIZE_T * PhysicalSystemMemorySize -** Pointer to a variable that will hold the size of the physical system -** memory. -*/ -gceSTATUS -gcoOS_GetPhysicalSystemMemorySize( - OUT gctSIZE_T * PhysicalSystemMemorySize - ) -{ -#if defined(SOLARIS) - if (PhysicalSystemMemorySize != gcvNULL) - { - *PhysicalSystemMemorySize = sysconf(_SC_PHYS_PAGES) * sysconf(_SC_PAGESIZE); - } -#else - struct sysinfo info; - sysinfo( &info ); - if (PhysicalSystemMemorySize != gcvNULL) - { - *PhysicalSystemMemorySize = (size_t)info.totalram * (size_t)info.mem_unit; - } -#endif - return gcvSTATUS_OK; -} - -/******************************************************************************* -** -** gcoOS_QueryVideoMemory -** -** Query the amount of video memory. -** -** INPUT: -** -** gcoOS Os -** Pointer to a gcoOS object. -** -** OUTPUT: -** -** gctUINT32 * InternalPhysName -** Pointer to a variable that will hold the physical memory name of the -** internal memory. If 'InternalPhysName' is gcvNULL, no information -** about the internal memory will be returned. -** -** gctSIZE_T * InternalSize -** Pointer to a variable that will hold the size of the internal -** memory. 'InternalSize' cannot be gcvNULL if 'InternalPhysName' is -** not gcvNULL. -** -** gctUINT32 * ExternalPhysName -** Pointer to a variable that will hold the physical memory name of the -** external memory. If 'ExternalPhysName' is gcvNULL, no information -** about the external memory will be returned. -** -** gctSIZE_T * ExternalSize -** Pointer to a variable that will hold the size of the external -** memory. 'ExternalSize' cannot be gcvNULL if 'ExternalPhysName' is -** not gcvNULL. -** -** gctUINT32 * ContiguousPhysName -** Pointer to a variable that will hold the physical memory name of the -** contiguous memory. If 'ContiguousPhysName' is gcvNULL, no -** information about the contiguous memory will be returned. -** -** gctSIZE_T * ContiguousSize -** Pointer to a variable that will hold the size of the contiguous -** memory. 'ContiguousSize' cannot be gcvNULL if 'ContiguousPhysName' -** is not gcvNULL. -*/ -gceSTATUS -gcoOS_QueryVideoMemory( - IN gcoOS Os, - OUT gctUINT32 * InternalPhysName, - OUT gctSIZE_T * InternalSize, - OUT gctUINT32 * ExternalPhysName, - OUT gctSIZE_T * ExternalSize, - OUT gctUINT32 * ContiguousPhysName, - OUT gctSIZE_T * ContiguousSize - ) -{ - gceSTATUS status; - gcsHAL_INTERFACE iface; - - gcmHEADER(); - - /* Call kernel HAL to query video memory. */ - iface.ignoreTLS = gcvFALSE; - iface.command = gcvHAL_QUERY_VIDEO_MEMORY; - - /* Call kernel service. */ - gcmONERROR(gcoOS_DeviceControl(gcvNULL, - IOCTL_GCHAL_INTERFACE, - &iface, gcmSIZEOF(iface), - &iface, gcmSIZEOF(iface))); - - if (InternalPhysName != gcvNULL) - { - /* Verify arguments. */ - gcmDEBUG_VERIFY_ARGUMENT(InternalSize != gcvNULL); - - /* Save internal memory size. */ - *InternalPhysName = iface.u.QueryVideoMemory.internalPhysName; - *InternalSize = (gctSIZE_T)iface.u.QueryVideoMemory.internalSize; - } - - if (ExternalPhysName != gcvNULL) - { - /* Verify arguments. */ - gcmDEBUG_VERIFY_ARGUMENT(ExternalSize != gcvNULL); - - /* Save external memory size. */ - *ExternalPhysName = iface.u.QueryVideoMemory.externalPhysName; - *ExternalSize = (gctSIZE_T)iface.u.QueryVideoMemory.externalSize; - } - - if (ContiguousPhysName != gcvNULL) - { - /* Verify arguments. */ - gcmDEBUG_VERIFY_ARGUMENT(ContiguousSize != gcvNULL); - - /* Save contiguous memory size. */ - *ContiguousPhysName = iface.u.QueryVideoMemory.contiguousPhysName; - *ContiguousSize = (gctSIZE_T)iface.u.QueryVideoMemory.contiguousSize; - } - - /* Success. */ - gcmFOOTER_ARG("*InternalPhysName=0x%08x *InternalSize=%lu " - "*ExternalPhysName=0x%08x *ExternalSize=%lu " - "*ContiguousPhysName=0x%08x *ContiguousSize=%lu", - gcmOPT_VALUE(InternalPhysName), gcmOPT_VALUE(InternalSize), - gcmOPT_VALUE(ExternalPhysName), gcmOPT_VALUE(ExternalSize), - gcmOPT_VALUE(ContiguousPhysName), - gcmOPT_VALUE(ContiguousSize)); - return gcvSTATUS_OK; - -OnError: - /* Return the status. */ - gcmFOOTER(); - return status; -} - -/******************************************************************************* -** -** Deprecated API: please use gcoHAL_GetBaseAddr() instead. -** This API was kept only for legacy BSP usage. -** -** gcoOS_GetBaseAddress -** -** Get the base address for the physical memory. -** -** INPUT: -** -** gcoOS Os -** Pointer to the gcoOS object. -** -** OUTPUT: -** -** gctUINT32_PTR BaseAddress -** Pointer to a variable that will receive the base address. -*/ -gceSTATUS -gcoOS_GetBaseAddress( - IN gcoOS Os, - OUT gctUINT32_PTR BaseAddress - ) -{ - gceSTATUS status = gcvSTATUS_OK; - gceHARDWARE_TYPE type = gcvHARDWARE_INVALID; - - gcmHEADER(); - - /* Verify the arguments. */ - gcmDEBUG_VERIFY_ARGUMENT(BaseAddress); - - gcmONERROR(gcoHAL_GetHardwareType(gcvNULL, &type)); - - /* Return base address. */ - if (type == gcvHARDWARE_VG) - { - *BaseAddress = 0; - } - else - { - gcsHAL_INTERFACE iface; - - /* Query base address. */ - iface.ignoreTLS = gcvFALSE; - iface.command = gcvHAL_GET_BASE_ADDRESS; - - /* Call kernel driver. */ - gcmONERROR(gcoOS_DeviceControl( - gcvNULL, - IOCTL_GCHAL_INTERFACE, - &iface, gcmSIZEOF(iface), - &iface, gcmSIZEOF(iface) - )); - - *BaseAddress = iface.u.GetBaseAddress.baseAddress; - } - -OnError: - /* Success. */ - gcmFOOTER_ARG("*BaseAddress=0x%08x", *BaseAddress); - return status; -} - -/******************************************************************************* -** -** gcoOS_Allocate -** -** Allocate memory from the user heap. -** -** INPUT: -** -** gcoOS Os -** Pointer to an gcoOS object. -** -** gctSIZE_T Bytes -** Number of bytes to allocate. -** -** OUTPUT: -** -** gctPOINTER * Memory -** Pointer to a variable that will hold the pointer to the memory -** allocation. -*/ -gceSTATUS -gcoOS_Allocate( - IN gcoOS Os, - IN gctSIZE_T Bytes, - OUT gctPOINTER * Memory - ) -{ - gceSTATUS status; - - /* - * The max of all additions to Bytes in following functions, - * which is gcmSIZEOF(gcsHEAP) (16 bytes) + gcmSIZEOF(gcsNODE) (16 bytes) - */ - gctSIZE_T bytesToAdd = 32; - - gcmHEADER_ARG("Bytes=%lu", Bytes); - - /* Verify the arguments. */ - gcmDEBUG_VERIFY_ARGUMENT(Bytes > 0); - gcmDEBUG_VERIFY_ARGUMENT(Memory != gcvNULL); - - /* Make sure Bytes doesn't exceed MAX_SIZET after additions */ - if (Bytes > gcvMAXSIZE_T - bytesToAdd) - { - gcmFOOTER_ARG("%d", gcvSTATUS_DATA_TOO_LARGE); - return gcvSTATUS_DATA_TOO_LARGE; - } - - if ((gcPLS.os != gcvNULL) && (gcPLS.os->heap != gcvNULL)) - { - gcmONERROR(gcoHEAP_Allocate(gcPLS.os->heap, Bytes, Memory)); - } - else - { - gcmONERROR(gcoOS_AllocateMemory(gcPLS.os, Bytes, Memory)); - } - - /* Success. */ - gcmFOOTER_ARG("*Memory=0x%x", *Memory); - return gcvSTATUS_OK; - -OnError: - /* Return the status. */ - gcmFOOTER(); - return status; -} - -/******************************************************************************* -** -** gcoOS_GetMemorySize -** -** Get allocated memory from the user heap. -** -** INPUT: -** -** gcoOS Os -** Pointer to an gcoOS object. -** -** gctPOINTER Memory -** Pointer to the memory -** allocation. -** -** OUTPUT: -** -** gctPOINTER MemorySize -** Pointer to a variable that will hold the pointer to the memory -** size. -*/ -gceSTATUS -gcoOS_GetMemorySize( - IN gcoOS Os, - IN gctPOINTER Memory, - OUT gctSIZE_T_PTR MemorySize - ) -{ - gceSTATUS status; - - gcmHEADER_ARG("Memory=0x%x", Memory); - - /* Verify the arguments. */ - gcmDEBUG_VERIFY_ARGUMENT(Memory != gcvNULL); - gcmDEBUG_VERIFY_ARGUMENT(MemorySize != gcvNULL); - - /* Free the memory. */ - if ((gcPLS.os != gcvNULL) && (gcPLS.os->heap != gcvNULL)) - { - gcmONERROR(gcoHEAP_GetMemorySize(gcPLS.os->heap, Memory, MemorySize)); - } - else - { - *MemorySize = 0; - } - - /* Success. */ - gcmFOOTER_NO(); - return gcvSTATUS_OK; - -OnError: - /* Return the status. */ - gcmFOOTER(); - return status; -} - -/******************************************************************************* - ** - ** gcoOS_Free - ** - ** Free allocated memory from the user heap. - ** - ** INPUT: - ** - ** gcoOS Os - ** Pointer to an gcoOS object. - ** - ** gctPOINTER Memory - ** Pointer to the memory allocation that needs to be freed. - ** - ** OUTPUT: - ** - ** Nothing. - */ -gceSTATUS -gcoOS_Free( - IN gcoOS Os, - IN gctPOINTER Memory - ) -{ - gceSTATUS status; - - gcmHEADER_ARG("Memory=0x%x", Memory); - - /* Verify the arguments. */ - gcmDEBUG_VERIFY_ARGUMENT(Memory != gcvNULL); - - /* Free the memory. */ - if ((gcPLS.os != gcvNULL) && (gcPLS.os->heap != gcvNULL)) - { - gcmONERROR(gcoHEAP_Free(gcPLS.os->heap, Memory)); - } - else - { - gcmONERROR(gcoOS_FreeMemory(gcPLS.os, Memory)); - } - - /* Success. */ - gcmFOOTER_NO(); - return gcvSTATUS_OK; - -OnError: - /* Return the status. */ - gcmFOOTER(); - return status; -} - -/******************************************************************************* -** -** gcoOS_AllocateSharedMemory -** -** Allocate memory that can be used in both user and kernel. -** -** INPUT: -** -** gcoOS Os -** Pointer to an gcoOS object. -** -** gctSIZE_T Bytes -** Number of bytes to allocate. -** -** OUTPUT: -** -** gctPOINTER * Memory -** Pointer to a variable that will hold the pointer to the memory -** allocation. -*/ -gceSTATUS -gcoOS_AllocateSharedMemory( - IN gcoOS Os, - IN gctSIZE_T Bytes, - OUT gctPOINTER * Memory - ) -{ - return gcoOS_Allocate(Os, Bytes, Memory); -} - -/******************************************************************************* - ** - ** gcoOS_FreeSharedMemory - ** - ** Free allocated memory. - ** - ** INPUT: - ** - ** gcoOS Os - ** Pointer to an gcoOS object. - ** - ** gctPOINTER Memory - ** Pointer to the memory allocation that needs to be freed. - ** - ** OUTPUT: - ** - ** Nothing. - */ -gceSTATUS -gcoOS_FreeSharedMemory( - IN gcoOS Os, - IN gctPOINTER Memory - ) -{ - return gcoOS_Free(Os, Memory); -} - -/******************************************************************************* - ** - ** gcoOS_AllocateMemory - ** - ** Allocate memory from the user heap. - ** - ** INPUT: - ** - ** gcoOS Os - ** Pointer to an gcoOS object. - ** - ** gctSIZE_T Bytes - ** Number of bytes to allocate. - ** - ** OUTPUT: - ** - ** gctPOINTER * Memory - ** Pointer to a variable that will hold the pointer to the memory - ** allocation. - */ -gceSTATUS -gcoOS_AllocateMemory( - IN gcoOS Os, - IN gctSIZE_T Bytes, - OUT gctPOINTER * Memory - ) -{ - gceSTATUS status; - gctPOINTER memory = gcvNULL; - - gcmHEADER_ARG("Bytes=%lu", Bytes); - - /* Verify the arguments. */ - gcmDEBUG_VERIFY_ARGUMENT(Bytes > 0); - gcmDEBUG_VERIFY_ARGUMENT(Memory != gcvNULL); - - /* Allocate the memory. */ -#if VIVANTE_PROFILER_SYSTEM_MEMORY - if (gcPLS.bMemoryProfile) - { - memory = malloc(Bytes + VP_MALLOC_OFFSET); - } - else -#endif - { - memory = malloc(Bytes); - } - - if (memory == gcvNULL) - { - /* Out of memory. */ - gcmONERROR(gcvSTATUS_OUT_OF_MEMORY); - } - -#if VIVANTE_PROFILER_SYSTEM_MEMORY - if (gcPLS.bMemoryProfile) - { - gcoOS os = (gcPLS.os != gcvNULL) ? gcPLS.os : Os; - - if (os != gcvNULL) - { -#if gcdGC355_MEM_PRINT - if (os->oneRecording == 1) - { - os->oneSize += (gctINT32)Bytes; - } -#endif - } - - if (gcPLS.profileLock) - { - gcmONERROR(gcoOS_AcquireMutex(os, gcPLS.profileLock, gcvINFINITE)); - ++ (gcPLS.allocCount); - gcPLS.allocSize += Bytes; - gcPLS.currentSize += Bytes; - - if (gcPLS.currentSize > gcPLS.maxAllocSize) - { - gcPLS.maxAllocSize = gcPLS.currentSize; - } - gcmONERROR(gcoOS_ReleaseMutex(os, gcPLS.profileLock)); - } - - /* Return pointer to the memory allocation. */ - *(gctSIZE_T *) memory = Bytes; - *Memory = (gctPOINTER) ((gctUINT8 *) memory + VP_MALLOC_OFFSET); - } - else -#endif - { - /* Return pointer to the memory allocation. */ - *Memory = memory; - } - - /* Success. */ - gcmFOOTER_ARG("*Memory=0x%x", *Memory); - return gcvSTATUS_OK; - -OnError: -#if VIVANTE_PROFILER_SYSTEM_MEMORY - if (memory) - { - free(memory); - } -#endif - - /* Return the status. */ - gcmFOOTER(); - return status; -} - -/******************************************************************************* - ** - ** gcoOS_FreeMemory - ** - ** Free allocated memory from the user heap. - ** - ** INPUT: - ** - ** gcoOS Os - ** Pointer to an gcoOS object. - ** - ** gctPOINTER Memory - ** Pointer to the memory allocation that needs to be freed. - ** - ** OUTPUT: - ** - ** Nothing. - */ -gceSTATUS -gcoOS_FreeMemory( - IN gcoOS Os, - IN gctPOINTER Memory - ) -{ - gcmHEADER_ARG("Memory=0x%x", Memory); - - /* Verify the arguments. */ - gcmDEBUG_VERIFY_ARGUMENT(Memory != gcvNULL); - - /* Free the memory allocation. */ -#if VIVANTE_PROFILER_SYSTEM_MEMORY - if (gcPLS.bMemoryProfile) - { - gcoOS os = (gcPLS.os != gcvNULL) ? gcPLS.os : Os; - gctPOINTER p = (gctPOINTER) ((gctUINT8 *) Memory - VP_MALLOC_OFFSET); - gctSIZE_T size = *((gctSIZE_T *)p); - free(p); - - if (os != gcvNULL) - { -#if gcdGC355_MEM_PRINT - if (os->oneRecording == 1) - { - os->oneSize -= (gctINT32)size; - } -#endif - } - - if (gcPLS.profileLock) - { - gcmVERIFY_OK(gcoOS_AcquireMutex(os, gcPLS.profileLock, gcvINFINITE)); - - gcPLS.freeSize += size; - ++ (gcPLS.freeCount); - gcPLS.currentSize -= size; - gcmVERIFY_OK(gcoOS_ReleaseMutex(os, gcPLS.profileLock)); - } - } - else -#endif - { - free(Memory); - } - - /* Success. */ - gcmFOOTER_NO(); - return gcvSTATUS_OK; -} - -/******************************************************************************* - ** - ** gcoOS_DeviceControl - ** - ** Perform a device I/O control call to the kernel API. - ** - ** INPUT: - ** - ** gcoOS Os - ** Pointer to an gcoOS object. - ** - ** gctUINT32 IoControlCode - ** I/O control code to execute. - ** - ** gctPOINTER InputBuffer - ** Pointer to the input buffer. - ** - ** gctSIZE_T InputBufferSize - ** Size of the input buffer in bytes. - ** - ** gctSIZE_T outputBufferSize - ** Size of the output buffer in bytes. - ** - ** OUTPUT: - ** - ** gctPOINTER OutputBuffer - ** Output buffer is filled with the data returned from the kernel HAL - ** layer. - */ -gceSTATUS -gcoOS_DeviceControl( - IN gcoOS Os, - IN gctUINT32 IoControlCode, - IN gctPOINTER InputBuffer, - IN gctSIZE_T InputBufferSize, - OUT gctPOINTER OutputBuffer, - IN gctSIZE_T OutputBufferSize - ) -{ - gceSTATUS status; - gcsHAL_INTERFACE_PTR inputBuffer; - gcsHAL_INTERFACE_PTR outputBuffer; - gcsDRIVER_ARGS args; - gcsTLS_PTR tls; - gctPOINTER logical = gcvNULL; - gctUINT32 interrupt_count = 0; - - gcmHEADER_ARG("IoControlCode=%u InputBuffer=0x%x " - "InputBufferSize=%lu OutputBuffer=0x%x OutputBufferSize=%lu", - IoControlCode, InputBuffer, InputBufferSize, - OutputBuffer, OutputBufferSize); - - if (gcPLS.os == gcvNULL) - { - gcmONERROR(gcvSTATUS_DEVICE); - } - - /* Cast the interface. */ - inputBuffer = (gcsHAL_INTERFACE_PTR) InputBuffer; - outputBuffer = (gcsHAL_INTERFACE_PTR) OutputBuffer; - - if (!inputBuffer->ignoreTLS) - { - /* Set current hardware type */ - if (gcPLS.processID) - { - gcmONERROR(gcoOS_GetTLS(&tls)); - inputBuffer->hardwareType = tls->currentType; - inputBuffer->coreIndex = tls->currentType == gcvHARDWARE_2D ? 0: tls->currentCoreIndex; - } - else - { - inputBuffer->hardwareType = gcvHARDWARE_2D; - inputBuffer->coreIndex = 0; - } - } - - switch (inputBuffer->command) - { - case gcvHAL_MAP_MEMORY: - logical = mmap( - gcvNULL, inputBuffer->u.MapMemory.bytes, - PROT_READ | PROT_WRITE, MAP_SHARED, - gcPLS.os->device, (off_t) 0 - ); - - if (logical != MAP_FAILED) - { - inputBuffer->u.MapMemory.logical = gcmPTR_TO_UINT64(logical); - inputBuffer->status = gcvSTATUS_OK; - gcmFOOTER_NO(); - return gcvSTATUS_OK; - } - break; - - case gcvHAL_UNMAP_MEMORY: - munmap(gcmUINT64_TO_PTR(inputBuffer->u.UnmapMemory.logical), inputBuffer->u.UnmapMemory.bytes); - - inputBuffer->status = gcvSTATUS_OK; - gcmFOOTER_NO(); - return gcvSTATUS_OK; - - default: - /* This has to be here so that GCC does not complain. */ - break; - } - - /* Call kernel. */ - args.InputBuffer = gcmPTR_TO_UINT64(InputBuffer); - args.InputBufferSize = InputBufferSize; - args.OutputBuffer = gcmPTR_TO_UINT64(OutputBuffer); - args.OutputBufferSize = OutputBufferSize; - - while (ioctl(gcPLS.os->device, IoControlCode, &args) < 0) - { - if (errno != EINTR) - { - gcmTRACE(gcvLEVEL_ERROR, "ioctl failed; errno=%s\n", strerror(errno)); - gcmONERROR(gcvSTATUS_GENERIC_IO); - } - /* Retry MAX_RETRY_IOCTL_TIMES times at most when receiving interrupt */ - else if (++interrupt_count == MAX_RETRY_IOCTL_TIMES) - { - gcmTRACE(gcvLEVEL_ERROR, "ioctl failed; too many interrupt\n"); - gcmONERROR(gcvSTATUS_GENERIC_IO); - } - } - - /* Get the status. */ - status = outputBuffer->status; - - /* Eliminate gcmONERROR on gcoOS_WaitSignal timeout errors. */ -#if gcmIS_DEBUG(gcdDEBUG_CODE) - if ((inputBuffer->command == gcvHAL_USER_SIGNAL) && - (inputBuffer->u.UserSignal.command == gcvUSER_SIGNAL_WAIT)) - { - if (status == gcvSTATUS_TIMEOUT) - { - goto OnError; - } - } -#endif - - /* Test for API error. */ - gcmONERROR(status); - -OnError: - /* Return the status. */ - gcmFOOTER(); - return status; -} - -/******************************************************************************* -** -** gcoOS_AllocateVideoMemory (OBSOLETE, do NOT use it) -** -** Allocate contiguous video memory from the kernel. -** -** -** INPUT: -** -** gcoOS Os -** Pointer to an gcoOS object. -** -** gctBOOL InUserSpace -** gcvTRUE to map the memory into the user space. -** -** gctBOOL InCacheable -** gcvTRUE to allocate the cacheable memory. -** -** -** gctSIZE_T * Bytes -** Pointer to the number of bytes to allocate. -** -** OUTPUT: -** -** gctSIZE_T * Bytes -** Pointer to a variable that will receive the aligned number of bytes -** allocated. -** -** gctUINT32 * Physical -** Pointer to a variable that will receive the physical addresses of -** the allocated memory. -** -** gctPOINTER * Logical -** Pointer to a variable that will receive the logical address of the -** allocation. -** -** gctPOINTER * Handle -** Pointer to a variable that will receive the node handle of the -** allocation. -*/ -gceSTATUS -gcoOS_AllocateVideoMemory( - IN gcoOS Os, - IN gctBOOL InUserSpace, - IN gctBOOL InCacheable, - IN OUT gctSIZE_T * Bytes, - OUT gctUINT32 * Physical, - OUT gctPOINTER * Logical, - OUT gctPOINTER * Handle - ) -{ - gceSTATUS status; - gcsHAL_INTERFACE iface; - gceHARDWARE_TYPE type; - gctUINT32 flag = 0; - gcoHAL hal = gcvNULL; - - gcmHEADER_ARG("InUserSpace=%d *Bytes=%lu", - InUserSpace, gcmOPT_VALUE(Bytes)); - - /* Verify the arguments. */ - gcmVERIFY_ARGUMENT(Bytes != gcvNULL); - gcmVERIFY_ARGUMENT(Physical != gcvNULL); - gcmVERIFY_ARGUMENT(Logical != gcvNULL); - - gcmVERIFY_OK(gcoHAL_GetHardwareType(gcvNULL, &type)); - hal = gcPLS.hal; - gcoHAL_SetHardwareType(gcvNULL, hal->is3DAvailable ? gcvHARDWARE_3D : gcvHARDWARE_2D); - - flag |= gcvALLOC_FLAG_CONTIGUOUS; - - if (InCacheable) - { - flag |= gcvALLOC_FLAG_CACHEABLE; - } - - iface.ignoreTLS = gcvFALSE; - iface.command = gcvHAL_ALLOCATE_LINEAR_VIDEO_MEMORY; - iface.u.AllocateLinearVideoMemory.bytes = *Bytes; - - iface.u.AllocateLinearVideoMemory.alignment = 64; - iface.u.AllocateLinearVideoMemory.pool = gcvPOOL_DEFAULT; - iface.u.AllocateLinearVideoMemory.type = gcvVIDMEM_TYPE_BITMAP; - iface.u.AllocateLinearVideoMemory.flag = flag; - - /* Call kernel driver. */ - gcmONERROR(gcoOS_DeviceControl( - gcvNULL, - IOCTL_GCHAL_INTERFACE, - &iface, gcmSIZEOF(iface), - &iface, gcmSIZEOF(iface) - )); - - /* Return allocated number of bytes. */ - *Bytes = (gctSIZE_T)iface.u.AllocateLinearVideoMemory.bytes; - - /* Return the handle of allocated Node. */ - *Handle = gcmUINT64_TO_PTR(iface.u.AllocateLinearVideoMemory.node); - - /* Fill in the kernel call structure. */ - iface.ignoreTLS = gcvFALSE; - iface.engine = gcvENGINE_RENDER; - iface.command = gcvHAL_LOCK_VIDEO_MEMORY; - iface.u.LockVideoMemory.node = iface.u.AllocateLinearVideoMemory.node; - iface.u.LockVideoMemory.cacheable = InCacheable; - - /* Call the kernel. */ - gcmONERROR(gcoOS_DeviceControl( - gcvNULL, - IOCTL_GCHAL_INTERFACE, - &iface, sizeof(iface), - &iface, sizeof(iface) - )); - - /* Success? */ - gcmONERROR(iface.status); - - /* Return physical address. */ - *Physical = iface.u.LockVideoMemory.physicalAddress; - - /* Return logical address. */ - *Logical = gcmUINT64_TO_PTR(iface.u.LockVideoMemory.memory); - - gcoHAL_SetHardwareType(gcvNULL, type); - - /* Success. */ - gcmFOOTER_ARG("*Bytes=%lu *Physical=0x%x *Logical=0x%x", - *Bytes, *Physical, *Logical); - return gcvSTATUS_OK; - -OnError: - gcmTRACE( - gcvLEVEL_ERROR, - "%s(%d): failed to allocate %lu bytes", - __FUNCTION__, __LINE__, *Bytes - ); - - gcoHAL_SetHardwareType(gcvNULL, type); - - /* Return the status. */ - gcmFOOTER(); - return status; -} - -/******************************************************************************* -** -** gcoOS_FreeVideoMemory (OBSOLETE, do NOT use it) -** -** Free contiguous video memory from the kernel. -** -** INPUT: -** -** gcoOS Os -** Pointer to an gcoOS object. -** -** gctPOINTER Handle -** Pointer to a variable that indicate the node of the -** allocation. -** -** OUTPUT: -** -** Nothing. -*/ -gceSTATUS -gcoOS_FreeVideoMemory( - IN gcoOS Os, - IN gctPOINTER Handle - ) -{ - gcsHAL_INTERFACE iface; - gceHARDWARE_TYPE type; - gcoHAL hal = gcPLS.hal; - gceSTATUS status; - - gcmHEADER_ARG("Os=0x%x Handle=0x%x", - Os, Handle); - gcmVERIFY_OK(gcoHAL_GetHardwareType(gcvNULL, &type)); - gcoHAL_SetHardwareType(gcvNULL, hal->is3DAvailable ? gcvHARDWARE_3D : gcvHARDWARE_2D); - - do - { - gcuVIDMEM_NODE_PTR Node = (gcuVIDMEM_NODE_PTR)Handle; - - /* Free first to set freed flag since asynchroneous unlock is needed for the contiguous memory. */ - iface.ignoreTLS = gcvFALSE; - iface.command = gcvHAL_RELEASE_VIDEO_MEMORY; - iface.u.ReleaseVideoMemory.node = gcmPTR_TO_UINT64(Node); - - /* Call kernel driver. */ - gcmONERROR(gcoOS_DeviceControl( - gcvNULL, - IOCTL_GCHAL_INTERFACE, - &iface, gcmSIZEOF(iface), - &iface, gcmSIZEOF(iface) - )); - - /* Unlock the video memory node in asynchronous mode. */ - iface.engine = gcvENGINE_RENDER; - iface.command = gcvHAL_UNLOCK_VIDEO_MEMORY; - iface.u.UnlockVideoMemory.node = gcmPTR_TO_UINT64(Node); - iface.u.UnlockVideoMemory.type = gcvVIDMEM_TYPE_BITMAP; - iface.u.UnlockVideoMemory.asynchroneous = gcvTRUE; - - /* Call kernel driver. */ - gcmONERROR(gcoOS_DeviceControl( - gcvNULL, - IOCTL_GCHAL_INTERFACE, - &iface, gcmSIZEOF(iface), - &iface, gcmSIZEOF(iface) - )); - - /* Success? */ - gcmONERROR(iface.status); - - /* Do we need to schedule an event for the unlock? */ - if (iface.u.UnlockVideoMemory.asynchroneous) - { - iface.u.UnlockVideoMemory.asynchroneous = gcvFALSE; - gcmONERROR(gcoHAL_ScheduleEvent(gcvNULL, &iface)); - gcmONERROR(gcoHAL_Commit(gcvNULL, gcvFALSE)); - } - - gcoHAL_SetHardwareType(gcvNULL, type); - - /* Success. */ - gcmFOOTER_NO(); - - return gcvSTATUS_OK; - } - while (gcvFALSE); - -OnError: - gcmTRACE( - gcvLEVEL_ERROR, - "%s(%d): failed to free handle %lu", - __FUNCTION__, __LINE__, Handle - ); - - gcoHAL_SetHardwareType(gcvNULL, type); - - /* Return the status. */ - gcmFOOTER(); - return status; -} - -/******************************************************************************* -** -** gcoOS_LockVideoMemory (OBSOLETE, do NOT use it) -** -** Lock contiguous video memory for access. -** -** INPUT: -** -** gcoOS Os -** Pointer to an gcoOS object. -** -** gctPOINTER Handle -** Pointer to a variable that indicate the node of the -** allocation. -** -** gctBOOL InUserSpace -** gcvTRUE to map the memory into the user space. -** -** gctBOOL InCacheable -** gcvTRUE to allocate the cacheable memory. -** -** OUTPUT: -** -** gctUINT32 * Physical -** Pointer to a variable that will receive the physical addresses of -** the allocated memory. -** -** gctPOINTER * Logical -** Pointer to a variable that will receive the logical address of the -** allocation. -*/ -gceSTATUS -gcoOS_LockVideoMemory( - IN gcoOS Os, - IN gctPOINTER Handle, - IN gctBOOL InUserSpace, - IN gctBOOL InCacheable, - OUT gctUINT32 * Physical, - OUT gctPOINTER * Logical - ) -{ - gceSTATUS status; - gcsHAL_INTERFACE iface; - gceHARDWARE_TYPE type; - gcuVIDMEM_NODE_PTR Node; - - gcmHEADER_ARG("Handle=%d,InUserSpace=%d InCacheable=%d", - Handle, InUserSpace, InCacheable); - - /* Verify the arguments. */ - gcmVERIFY_ARGUMENT(Handle != gcvNULL); - gcmVERIFY_ARGUMENT(Physical != gcvNULL); - gcmVERIFY_ARGUMENT(Logical != gcvNULL); - - Node = (gcuVIDMEM_NODE_PTR)Handle; - - gcmVERIFY_OK(gcoHAL_GetHardwareType(gcvNULL, &type)); - gcoHAL_SetHardwareType(gcvNULL, gcvHARDWARE_3D); - - /* Fill in the kernel call structure. */ - iface.ignoreTLS = gcvFALSE; - iface.engine = gcvENGINE_RENDER; - iface.command = gcvHAL_LOCK_VIDEO_MEMORY; - iface.u.LockVideoMemory.node = gcmPTR_TO_UINT64(Node); - iface.u.LockVideoMemory.cacheable = InCacheable; - - /* Call the kernel. */ - gcmONERROR(gcoOS_DeviceControl( - gcvNULL, - IOCTL_GCHAL_INTERFACE, - &iface, sizeof(iface), - &iface, sizeof(iface) - )); - - /* Success? */ - gcmONERROR(iface.status); - - /* Return physical address. */ - *Physical = iface.u.LockVideoMemory.physicalAddress; - - /* Return logical address. */ - *Logical = gcmUINT64_TO_PTR(iface.u.LockVideoMemory.memory); - - gcoHAL_SetHardwareType(gcvNULL, type); - - /* Success. */ - gcmFOOTER_ARG("*Physical=0x%x *Logical=0x%x", *Physical, *Logical); - return gcvSTATUS_OK; - -OnError: - gcmTRACE( - gcvLEVEL_ERROR, - "%s(%d): failed to lock handle %x", - __FUNCTION__, __LINE__, Handle - ); - - gcoHAL_SetHardwareType(gcvNULL, type); - - /* Return the status. */ - gcmFOOTER(); - return status; - -} - - -/******************************************************************************* -** -** gcoOS_Open -** -** Open or create a file. -** -** INPUT: -** -** gcoOS Os -** Pointer to an gcoOS object. -** -** gctCONST_STRING FileName -** File name of file to open or create. -** -** gceFILE_MODE Mode -** Mode to open file with: -** -** gcvFILE_CREATE - Overwite any existing file. -** gcvFILE_APPEND - Append to an exisiting file or create a -** new file if there is no exisiting file. -** gcvFILE_READ - Open an existing file for read only. -** gcvFILE_CREATETEXT - Overwite any existing text file. -** gcvFILE_APPENDTEXT - Append to an exisiting text file or create -** a new text file if there is no exisiting -** file. -** gcvFILE_READTEXT - Open an existing text file fir read only. -** -** OUTPUT: -** -** gctFILE * File -** Pointer to a variable receivig the handle to the opened file. -*/ -gceSTATUS -gcoOS_Open( - IN gcoOS Os, - IN gctCONST_STRING FileName, - IN gceFILE_MODE Mode, - OUT gctFILE * File - ) -{ - static gctCONST_STRING modes[] = - { - "wb", - "ab", - "rb", - "w", - "a", - "r", - }; - FILE * file; - - gcmHEADER_ARG("FileName=%s Mode=%d", - gcmOPT_STRING(FileName), Mode); - - /* Verify the arguments. */ - gcmDEBUG_VERIFY_ARGUMENT(File != gcvNULL); - - /* Open the file. */ - file = fopen(FileName, modes[Mode]); - - if (file == gcvNULL) - { - /* Error. */ - gcmFOOTER_ARG("status=%d", gcvSTATUS_GENERIC_IO); - return gcvSTATUS_GENERIC_IO; - } - - /* Return handle to file. */ - *File = (gctFILE) file; - - /* Success. */ - gcmFOOTER_ARG("*File=0x%x", *File); - return gcvSTATUS_OK; -} - -/******************************************************************************* -** -** gcoOS_Close -** -** Close a file. -** -** INPUT: -** -** gcoOS Os -** Pointer to an gcoOS object. -** -** gctFILE File -** Pointer to an open file object. -** -** OUTPUT: -** -** Nothing. -*/ -gceSTATUS -gcoOS_Close( - IN gcoOS Os, - IN gctFILE File - ) -{ - gcmHEADER_ARG("File=0x%x", File); - - /* Verify the arguments. */ - gcmDEBUG_VERIFY_ARGUMENT(File != gcvNULL); - - /* Close the file. */ - fclose((FILE *) File); - - /* Success. */ - gcmFOOTER_NO(); - return gcvSTATUS_OK; -} - -gceSTATUS -gcoOS_Remove( - IN gcoOS Os, - IN gctCONST_STRING FileName - ) -{ - int ret; - gceSTATUS status = gcvSTATUS_OK; - gcmHEADER_ARG("FileName=%s", FileName); - - /* Verify the arguments. */ - gcmDEBUG_VERIFY_ARGUMENT(FileName != gcvNULL); - - ret = remove((const char *)FileName); - - if (ret != 0) - { - status = gcvSTATUS_GENERIC_IO; - } - - /* Success. */ - gcmFOOTER(); - return status; -} - -/******************************************************************************* -** -** gcoOS_Read -** -** Read data from an open file. -** -** INPUT: -** -** gcoOS Os -** Pointer to an gcoOS object. -** -** gctFILE File -** Pointer to an open file object. -** -** gctSIZE_T ByteCount -** Number of bytes to read from the file. -** -** gctCONST_POINTER Data -** Pointer to the data to read from the file. -** -** OUTPUT: -** -** gctSIZE_T * ByteRead -** Pointer to a variable receiving the number of bytes read from the -** file. -*/ -gceSTATUS -gcoOS_Read( - IN gcoOS Os, - IN gctFILE File, - IN gctSIZE_T ByteCount, - IN gctPOINTER Data, - OUT gctSIZE_T * ByteRead - ) -{ - size_t byteRead; - - gcmHEADER_ARG("File=0x%x ByteCount=%lu Data=0x%x", - File, ByteCount, Data); - - /* Verify the arguments. */ - gcmDEBUG_VERIFY_ARGUMENT(File != gcvNULL); - gcmDEBUG_VERIFY_ARGUMENT(ByteCount > 0); - gcmDEBUG_VERIFY_ARGUMENT(Data != gcvNULL); - - /* Read the data from the file. */ - byteRead = fread(Data, 1, ByteCount, (FILE *) File); - - if (ByteRead != gcvNULL) - { - *ByteRead = (gctSIZE_T) byteRead; - } - - if (byteRead == ByteCount || ((byteRead < ByteCount) && fseek((FILE *)File, 0, SEEK_END) == 0)) - { - /* Success. */ - gcmFOOTER_NO(); - return gcvSTATUS_OK; - } - else - { - /* Error */ - gcmFOOTER_NO(); - return gcvSTATUS_GENERIC_IO; - } -} - -/******************************************************************************* -** -** gcoOS_Write -** -** Write data to an open file. -** -** INPUT: -** -** gcoOS Os -** Pointer to an gcoOS object. -** -** gctFILE File -** Pointer to an open file object. -** -** gctSIZE_T ByteCount -** Number of bytes to write to the file. -** -** gctCONST_POINTER Data -** Pointer to the data to write to the file. -** -** OUTPUT: -** -** Nothing. -*/ -gceSTATUS -gcoOS_Write( - IN gcoOS Os, - IN gctFILE File, - IN gctSIZE_T ByteCount, - IN gctCONST_POINTER Data - ) -{ - size_t byteWritten; - - gcmHEADER_ARG("File=0x%x ByteCount=%lu Data=0x%x", - File, ByteCount, Data); - - /* Verify the arguments. */ - gcmDEBUG_VERIFY_ARGUMENT(File != gcvNULL); - gcmDEBUG_VERIFY_ARGUMENT(ByteCount > 0); - gcmDEBUG_VERIFY_ARGUMENT(Data != gcvNULL); - - /* Write the data to the file. */ - byteWritten = fwrite(Data, 1, ByteCount, (FILE *) File); - - if (byteWritten == ByteCount) - { - /* Success. */ - gcmFOOTER_NO(); - return gcvSTATUS_OK; - } - else - { - /* Error */ - gcmFOOTER_ARG("status=%d", gcvSTATUS_GENERIC_IO); - return gcvSTATUS_GENERIC_IO; - } -} - -/* Flush data to a file. */ -gceSTATUS -gcoOS_Flush( - IN gcoOS Os, - IN gctFILE File - ) -{ - gcmHEADER_ARG("File=0x%x", File); - - fflush((FILE *) File); - - /* Success. */ - gcmFOOTER_NO(); - return gcvSTATUS_OK; -} - -gceSTATUS -gcoOS_FscanfI( - IN gcoOS Os, - IN gctFILE File, - IN gctCONST_STRING Format, - OUT gctUINT *result - ) -{ - gctINT ret; - gcmHEADER_ARG("File=0x%x Format=0x%x", File, Format); - - /* Verify the arguments. */ - gcmVERIFY_ARGUMENT(File != gcvNULL); - gcmVERIFY_ARGUMENT(Format != gcvNULL); - - /* Format the string. */ - ret = fscanf(File, Format, result); - - if (!ret) - { - gcmFOOTER_NO(); - return gcvSTATUS_GENERIC_IO; - } - - /* Success. */ - gcmFOOTER_NO(); - return gcvSTATUS_OK; -} - -gceSTATUS -gcoOS_DupFD( - IN gcoOS Os, - IN gctINT FD, - OUT gctINT * FD2 - ) -{ - int fd; - gceSTATUS status; - - gcmHEADER_ARG("FD=%d", FD); - fd = dup(FD); - - if (fd < 0) - { - status = gcvSTATUS_OUT_OF_RESOURCES; - gcmFOOTER(); - return status; - } - - *FD2 = fd; - gcmFOOTER_ARG("FD2=%d", FD2); - return gcvSTATUS_OK; -} - -gceSTATUS -gcoOS_CloseFD( - IN gcoOS Os, - IN gctINT FD - ) -{ - int err; - gceSTATUS status; - gcmHEADER_ARG("FD=%d", FD); - - err = close(FD); - - if (err < 0) - { - status = gcvSTATUS_GENERIC_IO; - gcmFOOTER(); - return status; - } - - gcmFOOTER_NO(); - return gcvSTATUS_OK; -} - -/******************************************************************************* -** -** gcoOS_LockFile -** -** Apply an advisory lock on an open file -** -** INPUT: -** -** gcoOS Os -** Pointer to an gcoOS object. -** -** gctFILE File -** Pointer to an open file object. -** -** gctBOOL Shared -** Place a shared lock if true. More than one process may hold a -** shared lock for a given file at a given time. -** Place an exclusive lock. Only one process may hold an exclusive -** lock for a given file at a given time. -** -** gctBOOL Block -** Block if an incompatible lock is held by another process. -** Otherwise return immediately with gcvSTATUS_LOCKED error. -** -** OUTPUT: -** -** Nothing. -*/ -gceSTATUS -gcoOS_LockFile( - IN gcoOS Os, - IN gctFILE File, - IN gctBOOL Shared, - IN gctBOOL Block - ) -{ - int flags; - int err; - gceSTATUS status = gcvSTATUS_OK; - - gcmHEADER_ARG("File=%p Shared=%d Block=%d", File, Shared, Block); - - flags = Shared ? LOCK_SH : LOCK_EX; - flags |= Block ? 0 : LOCK_NB; - - err = flock(fileno((FILE *)File), flags); - - if (err) - { - if (errno == EWOULDBLOCK) - { - gcmONERROR(gcvSTATUS_LOCKED); - } - else if (errno == EINTR) - { - gcmONERROR(gcvSTATUS_INTERRUPTED); - } - else - { - gcmONERROR(gcvSTATUS_INVALID_ARGUMENT); - } - } - - gcmFOOTER_NO(); - return gcvSTATUS_OK; - -OnError: - gcmFOOTER_ARG("status=%d", status); - return status; -} - -/******************************************************************************* -** -** gcoOS_UnlockFile -** -** Remove an advisory lock on an open file. -** -** INPUT: -** -** gcoOS Os -** Pointer to an gcoOS object. -** -** gctFILE File -** Pointer to an open file object. -** -** OUTPUT: -** -** Nothing. -*/ -gceSTATUS -gcoOS_UnlockFile( - IN gcoOS Os, - IN gctFILE File - ) -{ - int err; - gceSTATUS status; - - gcmHEADER_ARG("File=%p", File); - - err = flock(fileno((FILE *)File), LOCK_UN); - - if (err) - { - gcmONERROR(gcvSTATUS_INVALID_ARGUMENT); - } - - gcmFOOTER_NO(); - return gcvSTATUS_OK; - -OnError: - gcmFOOTER_ARG("status=%d", status); - return status; -} - -/* Create an endpoint for communication. */ -gceSTATUS -gcoOS_Socket( - IN gcoOS Os, - IN gctINT Domain, - IN gctINT Type, - IN gctINT Protocol, - OUT gctINT * SockFd - ) -{ - gctINT fd; - - gcmHEADER_ARG("Domain=%d Type=%d Protocol=%d", - Domain, Type, Protocol); - - /* Create a socket. */ - fd = socket(Domain, Type, Protocol); - - if (fd >= 0) - { - /* Return socket descriptor. */ - *SockFd = fd; - - /* Success. */ - gcmFOOTER_ARG("*SockFd=%d", *SockFd); - return gcvSTATUS_OK; - } - else - { - /* Error. */ - gcmFOOTER_ARG("status=%d", gcvSTATUS_GENERIC_IO); - return gcvSTATUS_GENERIC_IO; - } -} - -/* Close a socket. */ -gceSTATUS -gcoOS_WaitForSend( - IN gcoOS Os, - IN gctINT SockFd, - IN gctINT Seconds, - IN gctINT MicroSeconds - ) -{ - gcmHEADER_ARG("SockFd=%d Seconds=%d MicroSeconds=%d", - SockFd, Seconds, MicroSeconds); - - struct timeval tv; - fd_set writefds; - int ret; - - /* Linux select() will overwrite the struct on return */ - tv.tv_sec = Seconds; - tv.tv_usec = MicroSeconds; - - FD_ZERO(&writefds); - FD_SET(SockFd, &writefds); - - ret = select(SockFd + 1, NULL, &writefds, NULL, &tv); - - if (ret == 0) - { - /* Timeout. */ - gcmFOOTER_ARG("status=%d", gcvSTATUS_TIMEOUT); - return gcvSTATUS_TIMEOUT; - } - else if (ret == -1) - { - /* Error. */ - gcmFOOTER_ARG("status=%d", gcvSTATUS_GENERIC_IO); - return gcvSTATUS_GENERIC_IO; - } - else - { - int error = 0; - socklen_t len = sizeof(error); - - /* Get error code. */ - getsockopt(SockFd, SOL_SOCKET, SO_ERROR, (char*) &error, &len); - - if (! error) - { - /* Success. */ - gcmFOOTER_NO(); - return gcvSTATUS_OK; - } - } - - /* Error */ - gcmFOOTER_ARG("status=%d", gcvSTATUS_GENERIC_IO); - return gcvSTATUS_GENERIC_IO; -} - -/* Close a socket. */ -gceSTATUS -gcoOS_CloseSocket( - IN gcoOS Os, - IN gctINT SockFd - ) -{ - gcmHEADER_ARG("SockFd=%d", SockFd); - - /* Close the socket file descriptor. */ - gcoOS_WaitForSend(gcvNULL, SockFd, 600, 0); - close(SockFd); - - /* Success. */ - gcmFOOTER_NO(); - return gcvSTATUS_OK; -} - -/* Initiate a connection on a socket. */ -gceSTATUS -gcoOS_Connect( - IN gcoOS Os, - IN gctINT SockFd, - IN gctCONST_POINTER HostName, - IN gctUINT Port - ) -{ - gctINT rc; - gctINT addrLen; - struct sockaddr sockAddr; - struct sockaddr_in *sockAddrIn; - struct in_addr *inAddr; - - gcmHEADER_ARG("SockFd=0x%x HostName=0x%x Port=%d", - SockFd, HostName, Port); - - /* Get server address. */ - sockAddrIn = (struct sockaddr_in *) &sockAddr; - sockAddrIn->sin_family = AF_INET; - inAddr = &sockAddrIn->sin_addr; - inAddr->s_addr = inet_addr(HostName); - - /* If it is a numeric host name, convert it now */ - if (inAddr->s_addr == INADDR_NONE) - { -#if !gcdSTATIC_LINK - struct hostent *hostEnt; - struct in_addr *arrayAddr; - - /* It is a real name, we solve it */ - if ((hostEnt = gethostbyname(HostName)) == NULL) - { - /* Error */ - gcmFOOTER_ARG("status=%d", gcvSTATUS_GENERIC_IO); - return gcvSTATUS_GENERIC_IO; - } - arrayAddr = (struct in_addr *) *(hostEnt->h_addr_list); - inAddr->s_addr = arrayAddr[0].s_addr; -#endif /*gcdSTATIC_LINK*/ - } - - sockAddrIn->sin_port = htons((gctUINT16) Port); - - /* Currently, for INET only. */ - addrLen = sizeof(struct sockaddr); - - /*{ - gctINT arg = 1; - ioctl(SockFd, FIONBIO, &arg); - }*/ - - /* Close the file descriptor. */ - rc = connect(SockFd, &sockAddr, addrLen); - - if (rc) - { - int err = errno; - - if (err == EINPROGRESS) - { - gceSTATUS status; - - /* Connect is not complete. Wait for it. */ - status = gcoOS_WaitForSend(gcvNULL, SockFd, 600, 0); - - gcmFOOTER(); - return status; - } - - /* Error */ - gcmFOOTER_ARG("status=%d", gcvSTATUS_GENERIC_IO); - return gcvSTATUS_GENERIC_IO; - } - - /* Success. */ - gcmFOOTER_NO(); - return gcvSTATUS_OK; -} - -/* Shut down part of connection on a socket. */ -gceSTATUS -gcoOS_Shutdown( - IN gcoOS Os, - IN gctINT SockFd, - IN gctINT How - ) -{ - gcmHEADER_ARG("SockFd=%d How=%d", SockFd, How); - - /* Shut down connection. */ - shutdown(SockFd, How); - - /* Success. */ - gcmFOOTER_NO(); - return gcvSTATUS_OK; -} - -/* Send a message on a socket. */ -gceSTATUS -gcoOS_Send( - IN gcoOS Os, - IN gctINT SockFd, - IN gctSIZE_T ByteCount, - IN gctCONST_POINTER Data, - IN gctINT Flags - ) -{ - gctINT byteSent; - - gcmHEADER_ARG("SockFd=0x%x ByteCount=%lu Data=0x%x Flags=%d", - SockFd, ByteCount, Data, Flags); - - /* Verify the arguments. */ - gcmDEBUG_VERIFY_ARGUMENT(ByteCount > 0); - gcmDEBUG_VERIFY_ARGUMENT(Data != gcvNULL); - - /* Write the data to the file. */ - /*gcoOS_WaitForSend(gcvNULL, SockFd, 0, 50000);*/ - byteSent = send(SockFd, Data, ByteCount, Flags); - - if (byteSent == (gctINT) ByteCount) - { - /* Success. */ - gcmFOOTER_NO(); - return gcvSTATUS_OK; - } - else - { - /* Error */ - gcmFOOTER_ARG("status=%d", gcvSTATUS_GENERIC_IO); - return gcvSTATUS_GENERIC_IO; - } -} - -/* Get environment variable value. */ -gceSTATUS -gcoOS_GetEnv( - IN gcoOS Os, - IN gctCONST_STRING VarName, - OUT gctSTRING * Value - ) -{ -#ifdef ANDROID - static char properties[512]; - static int currentIndex; - static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; - - gctSTRING value = gcvNULL; - - gcmHEADER_ARG("VarName=%s", gcmOPT_STRING(VarName)); - - pthread_mutex_lock(&mutex); - - /* Get property value. */ - if (property_get(VarName, &properties[currentIndex], NULL) != 0) - { - /* Property exists. */ - value = &properties[currentIndex]; - - /* Pointer to space for next property. */ - currentIndex += strlen(value) + 1; - - if (currentIndex + PROPERTY_VALUE_MAX >= 512) - { - /* Rewind, will overrite old values. */ - currentIndex = 0; - } - } - - pthread_mutex_unlock(&mutex); - - *Value = value; - - /* Success. */ - gcmFOOTER_ARG("*Value=%s", gcmOPT_STRING(*Value)); - return gcvSTATUS_OK; -#else - gcmHEADER_ARG("VarName=%s", gcmOPT_STRING(VarName)); - - *Value = getenv(VarName); - - /* Success. */ - gcmFOOTER_ARG("*Value=%s", gcmOPT_STRING(*Value)); - return gcvSTATUS_OK; -#endif -} - -/* Set environment variable value. */ -gceSTATUS gcoOS_SetEnv( - IN gcoOS Os, - IN gctCONST_STRING VarName, - IN gctSTRING Value - ) -{ -#ifdef ANDROID - return gcvSTATUS_OK; -#endif - gcmHEADER_ARG("VarName=%s", gcmOPT_STRING(VarName)); - - - /* Success. */ - gcmFOOTER_NO(); - return gcvSTATUS_OK; -} - -/* Get current working directory. */ -gceSTATUS -gcoOS_GetCwd( - IN gcoOS Os, - IN gctINT SizeInBytes, - OUT gctSTRING Buffer - ) -{ - gcmHEADER_ARG("SizeInBytes=%d", SizeInBytes); - - if (getcwd(Buffer, SizeInBytes)) - { - gcmFOOTER_ARG("Buffer=%s", Buffer); - return gcvSTATUS_NOT_SUPPORTED; - } - else - { - gcmFOOTER_ARG("status=%d", gcvSTATUS_NOT_SUPPORTED); - return gcvSTATUS_NOT_SUPPORTED; - } -} - -/* Get file status info. */ -gceSTATUS -gcoOS_Stat( - IN gcoOS Os, - IN gctCONST_STRING FileName, - OUT gctPOINTER Buffer - ) -{ - gcmHEADER_ARG("FileName=%s", gcmOPT_STRING(FileName)); - - if (stat(FileName, Buffer) == 0) - { - gcmFOOTER_NO(); - return gcvSTATUS_OK; - } - else - { - gcmFOOTER_ARG("status=%d", gcvSTATUS_NOT_SUPPORTED); - return gcvSTATUS_NOT_SUPPORTED; - } -} - -/******************************************************************************* -** -** gcoOS_GetPos -** -** Get the current position of a file. -** -** INPUT: -** -** gcoOS Os -** Pointer to an gcoOS object. -** -** gctFILE File -** Pointer to an open file object. -** -** OUTPUT: -** -** gctUINT32 * Position -** Pointer to a variable receiving the current position of the file. -*/ -gceSTATUS -gcoOS_GetPos( - IN gcoOS Os, - IN gctFILE File, - OUT gctUINT32 * Position - ) -{ - gctINT64 ret; - gcmHEADER_ARG("File=0x%x", File); - - /* Verify the arguments. */ - gcmDEBUG_VERIFY_ARGUMENT(File != gcvNULL); - gcmDEBUG_VERIFY_ARGUMENT(Position != gcvNULL); - - /* Get the current file position. */ - ret = ftell((FILE *) File); - - /* Check if ftell encounters error. */ - if (ret == -1) - { - gcmFOOTER_ARG("%d", gcvSTATUS_TRUE); - return gcvSTATUS_TRUE; - } - /* If no error, ret contains a file size of a positive number. - Check if this file size is supported. - Since file size will be stored in UINT32, up to 2^32 = 4Gb is supported. - */ - else if (ret >= gcvMAXUINT32) - { - gcmFOOTER_ARG("%d", gcvSTATUS_DATA_TOO_LARGE); - return gcvSTATUS_DATA_TOO_LARGE; - } - else - { - /* Now we're sure file size takes <= 32 bit and cast it to UINT32 safely. */ - *Position = (gctUINT32) ret; - - gcmFOOTER_ARG("*Position=%u", *Position); - return gcvSTATUS_OK; - } -} - -/******************************************************************************* -** -** gcoOS_SetPos -** -** Set position for a file. -** -** INPUT: -** -** gcoOS Os -** Pointer to an gcoOS object. -** -** gctFILE File -** Pointer to an open file object. -** -** gctUINT32 Position -** Absolute position of the file to set. -** -** OUTPUT: -** -** Nothing. -*/ -gceSTATUS -gcoOS_SetPos( - IN gcoOS Os, - IN gctFILE File, - IN gctUINT32 Position - ) -{ - gceSTATUS status; - - gcmHEADER_ARG("File=0x%x Position=%u", File, Position); - - /* Verify the arguments. */ - gcmDEBUG_VERIFY_ARGUMENT(File != gcvNULL); - - /* Set file position. */ - gcmONERROR(fseek((FILE *) File, Position, SEEK_SET)); - -OnError: - /* Success. */ - gcmFOOTER_NO(); - return status; -} - -/******************************************************************************* -** -** gcoOS_Seek -** -** Set position for a file. -** -** INPUT: -** -** gcoOS Os -** Pointer to an gcoOS object. -** -** gctFILE File -** Pointer to an open file object. -** -** gctUINT32 Offset -** Offset added to the position specified by Whence. -** -** gceFILE_WHENCE Whence -** Mode that specify how to add the offset to the position: -** -** gcvFILE_SEEK_SET - Relative to the start of the file. -** gcvFILE_SEEK_CUR - Relative to the current position. -** gcvFILE_SEEK_END - Relative to the end of the file. -** -** OUTPUT: -** -** Nothing. -*/ -gceSTATUS -gcoOS_Seek( - IN gcoOS Os, - IN gctFILE File, - IN gctUINT32 Offset, - IN gceFILE_WHENCE Whence - ) -{ - gctINT result = 0; - - gcmHEADER_ARG("File=0x%x Offset=%u Whence=%d", - File, Offset, Whence); - - /* Verify the arguments. */ - gcmDEBUG_VERIFY_ARGUMENT(File != gcvNULL); - - /* Set file position. */ - switch (Whence) - { - case gcvFILE_SEEK_SET: - result = fseek((FILE *) File, Offset, SEEK_SET); - break; - - case gcvFILE_SEEK_CUR: - result = fseek((FILE *) File, Offset, SEEK_CUR); - break; - - case gcvFILE_SEEK_END: - result = fseek((FILE *) File, Offset, SEEK_END); - break; - } - - if (result == 0) - { - /* Success. */ - gcmFOOTER_NO(); - return gcvSTATUS_OK; - } - else - { - /* Error */ - gcmFOOTER_ARG("status=%d", gcvSTATUS_GENERIC_IO); - return gcvSTATUS_GENERIC_IO; - } -} - -/******************************************************************************* -** -** gcoOS_CreateThread -** -** Create a new thread. -** -** INPUT: -** -** gcoOS Os -** Pointer to an gcoOS object. -** -** OUTPUT: -** -** gctPOINTER * Thread -** Pointer to a variable that will hold a pointer to the thread. -*/ -gceSTATUS -gcoOS_CreateThread( - IN gcoOS Os, - IN gcTHREAD_ROUTINE Worker, - IN gctPOINTER Argument, - OUT gctPOINTER * Thread - ) -{ - pthread_t thread; - - gcmHEADER_ARG("Worker=0x%x Argument=0x%x", Worker, Argument); - - /* Validate the arguments. */ - gcmDEBUG_VERIFY_ARGUMENT(Thread != gcvNULL); - - if (pthread_create(&thread, gcvNULL, Worker, Argument) != 0) - { - gcmFOOTER_ARG("status=%d", gcvSTATUS_OUT_OF_RESOURCES); - return gcvSTATUS_OUT_OF_RESOURCES; - } - - *Thread = (gctPOINTER)(uintptr_t)thread; - - /* Success. */ - gcmFOOTER_ARG("*Thread=0x%x", *Thread); - return gcvSTATUS_OK; -} - -/******************************************************************************* -** -** gcoOS_CloseThread -** -** Close a thread. -** -** INPUT: -** -** gcoOS Os -** Pointer to an gcoOS object. -** -** gctPOINTER Thread -** Pointer to the thread to be deleted. -** -** OUTPUT: -** -** Nothing. -*/ -gceSTATUS -gcoOS_CloseThread( - IN gcoOS Os, - IN gctPOINTER Thread - ) -{ - gcmHEADER_ARG("Thread=0x%x", Thread); - - /* Validate the arguments. */ - gcmDEBUG_VERIFY_ARGUMENT(Thread != gcvNULL); - - pthread_join((pthread_t)(uintptr_t)Thread, gcvNULL); - - /* Success. */ - gcmFOOTER_NO(); - return gcvSTATUS_OK; -} - -/******************************************************************************* -** -** gcoOS_CreateMutex -** -** Create a new mutex. -** -** INPUT: -** -** gcoOS Os -** Pointer to an gcoOS object. -** -** OUTPUT: -** -** gctPOINTER * Mutex -** Pointer to a variable that will hold a pointer to the mutex. -*/ -gceSTATUS -gcoOS_CreateMutex( - IN gcoOS Os, - OUT gctPOINTER * Mutex - ) -{ - gceSTATUS status; - pthread_mutex_t* mutex; - pthread_mutexattr_t mta; - - gcmHEADER(); - - /* Validate the arguments. */ - gcmDEBUG_VERIFY_ARGUMENT(Mutex != gcvNULL); - - /* Allocate memory for the mutex. */ - gcmONERROR(gcoOS_Allocate( - gcvNULL, gcmSIZEOF(pthread_mutex_t), (gctPOINTER *) &mutex - )); - - pthread_mutexattr_init(&mta); - - pthread_mutexattr_settype(&mta, PTHREAD_MUTEX_RECURSIVE); - - /* Initialize the mutex. */ - pthread_mutex_init(mutex, &mta); - - /* Destroy mta.*/ - pthread_mutexattr_destroy(&mta); - - /* Return mutex to caller. */ - *Mutex = (gctPOINTER) mutex; - - /* Success. */ - gcmFOOTER_ARG("*Mutex = 0x%x", *Mutex); - return gcvSTATUS_OK; - -OnError: - /* Return the status. */ - gcmFOOTER(); - return status; -} - -/******************************************************************************* -** -** gcoOS_DeleteMutex -** -** Delete a mutex. -** -** INPUT: -** -** gcoOS Os -** Pointer to an gcoOS object. -** -** gctPOINTER Mutex -** Pointer to the mutex to be deleted. -** -** OUTPUT: -** -** Nothing. -*/ -gceSTATUS -gcoOS_DeleteMutex( - IN gcoOS Os, - IN gctPOINTER Mutex - ) -{ - pthread_mutex_t *mutex; - - gcmHEADER_ARG("Mutex=0x%x", Mutex); - - /* Validate the arguments. */ - gcmDEBUG_VERIFY_ARGUMENT(Mutex != gcvNULL); - - /* Cast the pointer. */ - mutex = (pthread_mutex_t *) Mutex; - - /* Destroy the mutex. */ - pthread_mutex_destroy(mutex); - - /* Free the memory. */ - gcmVERIFY_OK(gcmOS_SAFE_FREE(gcvNULL, mutex)); - - /* Success. */ - gcmFOOTER_NO(); - return gcvSTATUS_OK; -} - -/******************************************************************************* -** -** gcoOS_AcquireMutex -** -** Acquire a mutex. -** -** INPUT: -** -** gcoOS Os -** Pointer to an gcoOS object. -** -** gctPOINTER Mutex -** Pointer to the mutex to be acquired. -** -** gctUINT32 Timeout -** Timeout value specified in milliseconds. -** Specify the value of gcvINFINITE to keep the thread suspended -** until the mutex has been acquired. -** -** OUTPUT: -** -** Nothing. -*/ -gceSTATUS -gcoOS_AcquireMutex( - IN gcoOS Os, - IN gctPOINTER Mutex, - IN gctUINT32 Timeout - ) -{ - gceSTATUS status; - pthread_mutex_t *mutex; - - gcmHEADER_ARG("Mutex=0x%x Timeout=%u", Mutex, Timeout); - - /* Validate the arguments. */ - gcmDEBUG_VERIFY_ARGUMENT(Mutex != gcvNULL); - - /* Cast the pointer. */ - mutex = (pthread_mutex_t *) Mutex; - - /* Test for infinite. */ - if (Timeout == gcvINFINITE) - { - /* Lock the mutex. */ - if (pthread_mutex_lock(mutex)) - { - /* Some error. */ - status = gcvSTATUS_GENERIC_IO; - } - else - { - /* Success. */ - status = gcvSTATUS_OK; - } - } - else - { - /* Try locking the mutex. */ - if (pthread_mutex_trylock(mutex)) - { - /* Assume timeout. */ - status = gcvSTATUS_TIMEOUT; - - /* Loop while not timeout. */ - while (Timeout-- > 0) - { - /* Try locking the mutex. */ - if (pthread_mutex_trylock(mutex) == 0) - { - /* Success. */ - status = gcvSTATUS_OK; - break; - } - - /* Sleep 1 millisecond. */ - usleep(1000); - } - } - else - { - /* Success. */ - status = gcvSTATUS_OK; - } - } - - /* Return the status. */ - gcmFOOTER(); - return status; -} - -/******************************************************************************* -** -** gcoOS_ReleaseMutex -** -** Release an acquired mutex. -** -** INPUT: -** -** gcoOS Os -** Pointer to an gcoOS object. -** -** gctPOINTER Mutex -** Pointer to the mutex to be released. -** -** OUTPUT: -** -** Nothing. -*/ -gceSTATUS -gcoOS_ReleaseMutex( - IN gcoOS Os, - IN gctPOINTER Mutex - ) -{ - pthread_mutex_t *mutex; - - gcmHEADER_ARG("Mutex=0x%x", Mutex); - - /* Validate the arguments. */ - gcmDEBUG_VERIFY_ARGUMENT(Mutex != gcvNULL); - - /* Cast the pointer. */ - mutex = (pthread_mutex_t *) Mutex; - - /* Release the mutex. */ - pthread_mutex_unlock(mutex); - - /* Success. */ - gcmFOOTER_NO(); - return gcvSTATUS_OK; -} - -/******************************************************************************* -** -** gcoOS_Delay -** -** Delay execution of the current thread for a number of milliseconds. -** -** INPUT: -** -** gcoOS Os -** Pointer to an gcoOS object. -** -** gctUINT32 Delay -** Delay to sleep, specified in milliseconds. -** -** OUTPUT: -** -** Nothing. -*/ -gceSTATUS -gcoOS_Delay( - IN gcoOS Os, - IN gctUINT32 Delay - ) -{ - gcmHEADER_ARG("Delay=%u", Delay); - - /* Sleep for a while. */ - usleep((Delay == 0) ? 1 : (1000 * Delay)); - - /* Success. */ - gcmFOOTER_NO(); - return gcvSTATUS_OK; -} - -gceSTATUS -gcoOS_StrStr( - IN gctCONST_STRING String, - IN gctCONST_STRING SubString, - OUT gctSTRING * Output - ) -{ - gctCHAR* pos; - gceSTATUS status; - - gcmHEADER_ARG("String=0x%x SubString=0x%x", String, SubString); - - /* Verify the arguments. */ - gcmVERIFY_ARGUMENT(String != gcvNULL); - gcmVERIFY_ARGUMENT(SubString != gcvNULL); - - /* Call C. */ - pos = strstr(String, SubString); - if (Output) - { - *Output = pos; - } - status = pos ? gcvSTATUS_TRUE : gcvSTATUS_FALSE; - - /* Success. */ - gcmFOOTER(); - return status; -} - -gceSTATUS -gcoOS_StrFindReverse( - IN gctCONST_STRING String, - IN gctINT8 Character, - OUT gctSTRING * Output - ) -{ - gcmHEADER_ARG("String=0x%x Character=%d", String, Character); - - /* Verify the arguments. */ - gcmDEBUG_VERIFY_ARGUMENT(String != gcvNULL); - gcmDEBUG_VERIFY_ARGUMENT(Output != gcvNULL); - - /* Call C. */ - *Output = strrchr(String, Character); - - /* Success. */ - gcmFOOTER_ARG("*Output=0x%x", *Output); - return gcvSTATUS_OK; -} - -/******************************************************************************* -** -** gcoOS_StrCopy -** -** Copy a string. -** -** INPUT: -** -** gctSTRING Destination -** Pointer to the destination string. -** -** gctCONST_STRING Source -** Pointer to the source string. -** -** OUTPUT: -** -** Nothing. -*/ -gceSTATUS -gcoOS_StrCopySafe( - IN gctSTRING Destination, - IN gctSIZE_T DestinationSize, - IN gctCONST_STRING Source - ) -{ - gcmHEADER_ARG("Destination=0x%x DestinationSize=%lu Source=0x%x", - Destination, DestinationSize, Source); - - /* Verify the arguments. */ - gcmDEBUG_VERIFY_ARGUMENT(Destination != gcvNULL); - gcmDEBUG_VERIFY_ARGUMENT(Source != gcvNULL); - - /* Don't overflow the destination buffer. */ - strncpy(Destination, Source, DestinationSize - 1); - - /* Put this there in case the strncpy overflows. */ - Destination[DestinationSize - 1] = '\0'; - - /* Success. */ - gcmFOOTER_NO(); - return gcvSTATUS_OK; -} - -/******************************************************************************* -** -** gcoOS_StrCat -** -** Append a string. -** -** INPUT: -** -** gctSTRING Destination -** Pointer to the destination string. -** -** gctCONST_STRING Source -** Pointer to the source string. -** -** OUTPUT: -** -** Nothing. -*/ -gceSTATUS -gcoOS_StrCatSafe( - IN gctSTRING Destination, - IN gctSIZE_T DestinationSize, - IN gctCONST_STRING Source - ) -{ - gctSIZE_T n; - - gcmHEADER_ARG("Destination=0x%x DestinationSize=%lu Source=0x%x", - Destination, DestinationSize, Source); - - /* Verify the arguments. */ - gcmDEBUG_VERIFY_ARGUMENT(Destination != gcvNULL); - gcmDEBUG_VERIFY_ARGUMENT(Source != gcvNULL); - - /* Find the end of the destination. */ -#ifdef __USE_XOPEN2K8 - n = (gctSIZE_T)strnlen(Destination, DestinationSize); -#else - n = (gctSIZE_T)strlen(Destination); -#endif - if (n + 1 < DestinationSize) - { - /* Append the string but don't overflow the destination buffer. */ - strncpy(Destination + n, Source, DestinationSize - n - 1); - - /* Put this there in case the strncpy overflows. */ - Destination[DestinationSize - 1] = '\0'; - - /* Success. */ - gcmFOOTER_NO(); - return gcvSTATUS_OK; - } - else - { - /* Failure */ - gcmFOOTER_NO(); - return gcvSTATUS_DATA_TOO_LARGE; - } -} - -/******************************************************************************* -** -** gcoOS_StrCmp -** -** Compare two strings and return whether they match or not. -** -** INPUT: -** -** gctCONST_STRING String1 -** Pointer to the first string to compare. -** -** gctCONST_STRING String2 -** Pointer to the second string to compare. -** -** OUTPUT: -** -** Nothing. -** -** RETURNS: -** -** gcvSTATUS_OK if the strings match -** gcvSTATUS_LARGER if String1 > String2 -** gcvSTATUS_SMALLER if String1 < String2 -*/ -gceSTATUS -gcoOS_StrCmp( - IN gctCONST_STRING String1, - IN gctCONST_STRING String2 - ) -{ - int result; - gceSTATUS status; - - gcmHEADER_ARG("String1=0x%x String2=0x%x", String1, String2); - - /* Verify the arguments. */ - gcmDEBUG_VERIFY_ARGUMENT(String1 != gcvNULL); - gcmDEBUG_VERIFY_ARGUMENT(String2 != gcvNULL); - - /* Compare the strings and return proper status. */ - result = strcmp(String1, String2); - - status = (result == 0) ? gcvSTATUS_OK - : (result > 0) ? gcvSTATUS_LARGER - : gcvSTATUS_SMALLER; - - gcmFOOTER(); - return status; -} - -/******************************************************************************* -** -** gcoOS_StrNCmp -** -** Compare characters of two strings and return whether they match or not. -** -** INPUT: -** -** gctCONST_STRING String1 -** Pointer to the first string to compare. -** -** gctCONST_STRING String2 -** Pointer to the second string to compare. -** -** gctSIZE_T Count -** Number of characters to compare. -** -** OUTPUT: -** -** Nothing. -** -** RETURNS: -** -** gcvSTATUS_OK if the strings match -** gcvSTATUS_LARGER if String1 > String2 -** gcvSTATUS_SMALLER if String1 < String2 -*/ -gceSTATUS -gcoOS_StrNCmp( - IN gctCONST_STRING String1, - IN gctCONST_STRING String2, - IN gctSIZE_T Count - ) -{ - int result; - gceSTATUS status; - - gcmHEADER_ARG("String1=0x%x String2=0x%x Count=%lu", - String1, String2, Count); - - /* Verify the arguments. */ - gcmDEBUG_VERIFY_ARGUMENT(String1 != gcvNULL); - gcmDEBUG_VERIFY_ARGUMENT(String2 != gcvNULL); - - /* Compare the strings and return proper status. */ - result = strncmp(String1, String2, Count); - - status = (result == 0) - ? gcvSTATUS_OK - : ((result > 0) ? gcvSTATUS_LARGER : gcvSTATUS_SMALLER); - gcmFOOTER(); - return status; -} - -/******************************************************************************* -** -** gcoOS_StrToFloat -** -** Convert string to float. -** -** INPUT: -** -** gctCONST_STRING String -** Pointer to the string to be converted. -** -** -** OUTPUT: -** -** gctFLOAT * Float -** Pointer to a variable that will receive the float. -** -*/ -gceSTATUS -gcoOS_StrToFloat( - IN gctCONST_STRING String, - OUT gctFLOAT * Float - ) -{ - gcmHEADER_ARG("String=%s", gcmOPT_STRING(String)); - - /* Verify the arguments. */ - gcmDEBUG_VERIFY_ARGUMENT(String != gcvNULL); - - *Float = (gctFLOAT) atof(String); - - gcmFOOTER_ARG("*Float=%f", *Float); - return gcvSTATUS_OK; -} - -/* Converts a hex string to 32-bit integer. */ -gceSTATUS gcoOS_HexStrToInt(IN gctCONST_STRING String, - OUT gctINT * Int) -{ - gcmHEADER_ARG("String=%s", gcmOPT_STRING(String)); - gcmDEBUG_VERIFY_ARGUMENT(String != gcvNULL); - gcmDEBUG_VERIFY_ARGUMENT(Int != gcvNULL); - - sscanf(String, "%x", ((gctUINT*)Int)); - - gcmFOOTER_ARG("*Int=%d", *Int); - return gcvSTATUS_OK; -} - -/* Converts a hex string to float. */ -gceSTATUS gcoOS_HexStrToFloat(IN gctCONST_STRING String, - OUT gctFLOAT * Float) -{ - gctSTRING pch = gcvNULL; - gctCONST_STRING delim = "x.p"; - gctFLOAT b=0.0, exp=0.0; - gctINT s=0; - gctSTRING saveptr; - - gcmHEADER_ARG("String=%s", gcmOPT_STRING(String)); - gcmDEBUG_VERIFY_ARGUMENT(String != gcvNULL); - gcmDEBUG_VERIFY_ARGUMENT(Float != gcvNULL); - - pch = strtok_r((gctSTRING)String, delim, &saveptr); - if (pch == NULL) goto onError; - - pch = strtok_r(NULL, delim, &saveptr); - if (pch == NULL) goto onError; - gcmVERIFY_OK(gcoOS_StrToFloat(pch, &b)); - - pch = strtok_r(NULL, delim, &saveptr); - if (pch == NULL) goto onError; - gcmVERIFY_OK(gcoOS_HexStrToInt(pch, &s)); - - pch = strtok_r(NULL, delim, &saveptr); - if (pch == NULL) goto onError; - gcmVERIFY_OK(gcoOS_StrToFloat(pch, &exp)); - - *Float = (float)(b + s / (float)(1 << 24)) * (float)pow(2.0, exp); - - gcmFOOTER_ARG("*Float=%d", *Float); - return gcvSTATUS_OK; - -onError: - gcmFOOTER_NO(); - return gcvSTATUS_INVALID_ARGUMENT; -} - -/******************************************************************************* -** -** gcoOS_StrToInt -** -** Convert string to integer. -** -** INPUT: -** -** gctCONST_STRING String -** Pointer to the string to be converted. -** -** -** OUTPUT: -** -** gctINT * Int -** Pointer to a variable that will receive the integer. -** -*/ -gceSTATUS -gcoOS_StrToInt( - IN gctCONST_STRING String, - OUT gctINT * Int - ) -{ - gcmHEADER_ARG("String=%s", gcmOPT_STRING(String)); - - /* Verify the arguments. */ - gcmDEBUG_VERIFY_ARGUMENT(String != gcvNULL); - - *Int = (gctINT) atoi(String); - - gcmFOOTER_ARG("*Int=%d", *Int); - return gcvSTATUS_OK; -} - -/******************************************************************************* -** -** gcoOS_MemCmp -** -** Compare two memory regions and return whether they match or not. -** -** INPUT: -** -** gctCONST_POINTER Memory1 -** Pointer to the first memory region to compare. -** -** gctCONST_POINTER Memory2 -** Pointer to the second memory region to compare. -** -** gctSIZE_T Bytes -** Number of bytes to compare. -** -** OUTPUT: -** -** Nothing. -** -** RETURNS: -** -** gcvSTATUS_OK if the memory regions match or gcvSTATUS_MISMATCH if the -** memory regions don't match. -*/ -gceSTATUS -gcoOS_MemCmp( - IN gctCONST_POINTER Memory1, - IN gctCONST_POINTER Memory2, - IN gctSIZE_T Bytes - ) -{ - gceSTATUS status; - - gcmHEADER_ARG("Memory1=0x%x Memory2=0x%x Bytes=%lu", - Memory1, Memory2, Bytes); - - /* Verify the arguments. */ - gcmDEBUG_VERIFY_ARGUMENT(Memory1 != gcvNULL); - gcmDEBUG_VERIFY_ARGUMENT(Memory2 != gcvNULL); - gcmDEBUG_VERIFY_ARGUMENT(Bytes > 0); - - /* Compare the memory rregions and return proper status. */ - status = (memcmp(Memory1, Memory2, Bytes) == 0) - ? gcvSTATUS_OK - : gcvSTATUS_MISMATCH; - gcmFOOTER(); - return status; -} - -/******************************************************************************* -** -** gcoOS_PrintStr -** -** Append a "printf" formatted string to a string buffer and adjust the offset -** into the string buffer. There is no checking for a buffer overflow, so make -** sure the string buffer is large enough. -** -** INPUT: -** -** gctSTRING String -** Pointer to the string buffer. -** -** gctUINT_PTR Offset -** Pointer to a variable that holds the current offset into the string -** buffer. -** -** gctCONST_STRING Format -** Pointer to a "printf" style format to append to the string buffer -** pointet to by at the offset specified by <*Offset>. -** -** ... -** Variable number of arguments that will be used by . -** -** OUTPUT: -** -** gctUINT_PTR Offset -** Pointer to a variable that receives the new offset into the string -** buffer pointed to by after the formatted string pointed to -** by has been appended to it. -*/ -gceSTATUS -gcoOS_PrintStrSafe( - IN gctSTRING String, - IN gctSIZE_T StringSize, - IN OUT gctUINT_PTR Offset, - IN gctCONST_STRING Format, - ... - ) -{ - gctARGUMENTS arguments; - gceSTATUS status = gcvSTATUS_OK; - - gcmHEADER_ARG("String=0x%x StringSize=%lu *Offset=%u Format=0x%x", - String, StringSize, gcmOPT_VALUE(Offset), Format); - - /* Verify the arguments. */ - gcmVERIFY_ARGUMENT(String != gcvNULL); - gcmVERIFY_ARGUMENT(StringSize > 0); - gcmVERIFY_ARGUMENT(Format != gcvNULL); - - /* Route through gcoOS_PrintStrVSafe. */ - gcmARGUMENTS_START(arguments, Format); - gcmONERROR(gcoOS_PrintStrVSafe(String, StringSize, - Offset, - Format, arguments)); - -OnError: - gcmARGUMENTS_END(arguments); - - gcmFOOTER_ARG("*Offset=%u", gcmOPT_VALUE(Offset)); - return status; -} - -/******************************************************************************* -** -** gcoOS_PrintStrV -** -** Append a "vprintf" formatted string to a string buffer and adjust the offset -** into the string buffer. There is no checking for a buffer overflow, so make -** sure the string buffer is large enough. -** -** INPUT: -** -** gctSTRING String -** Pointer to the string buffer. -** -** gctUINT_PTR Offset -** Pointer to a variable that holds the current offset into the string -** buffer. -** -** gctCONST_STRING Format -** Pointer to a "printf" style format to append to the string buffer -** pointet to by at the offset specified by <*Offset>. -** -** gctPOINTER ArgPtr -** Pointer to list of arguments. -** -** OUTPUT: -** -** gctUINT_PTR Offset -** Pointer to a variable that receives the new offset into the string -** buffer pointed to by after the formatted string pointed to -** by has been appended to it. -*/ -gceSTATUS -gcoOS_PrintStrVSafe( - OUT gctSTRING String, - IN gctSIZE_T StringSize, - IN OUT gctUINT_PTR Offset, - IN gctCONST_STRING Format, - IN gctARGUMENTS Arguments - ) -{ - gctUINT offset = gcmOPT_VALUE(Offset); - gceSTATUS status = gcvSTATUS_OK; - - gcmHEADER_ARG("String=0x%x StringSize=%lu *Offset=%u Format=0x%x Arguments=0x%x", - String, StringSize, offset, Format, Arguments); - - /* Verify the arguments. */ - gcmVERIFY_ARGUMENT(String != gcvNULL); - gcmVERIFY_ARGUMENT(StringSize > 0); - gcmVERIFY_ARGUMENT(Format != gcvNULL); - - if (offset < StringSize - 1) - { - /* Print into the string. */ - gctINT n = vsnprintf(String + offset, - StringSize - offset, - Format, - Arguments); - - if (n < 0 || n >= (gctINT)(StringSize - offset)) - { - status = gcvSTATUS_GENERIC_IO; - } - else if (Offset) - { - *Offset = offset + n; - } - } - else - { - status = gcvSTATUS_BUFFER_TOO_SMALL; - } - - /* Success. */ - gcmFOOTER_ARG("*Offset=%u", offset); - return status; -} - -/******************************************************************************* -** -** gcoOS_StrDup -** -** Duplicate the given string by copying it into newly allocated memory. -** -** INPUT: -** -** gcoOS Os -** Pointer to gcoOS object. -** -** gctCONST_STRING String -** Pointer to string to duplicate. -** -** OUTPUT: -** -** gctSTRING * Target -** Pointer to variable holding the duplicated string address. -*/ -gceSTATUS -gcoOS_StrDup( - IN gcoOS Os, - IN gctCONST_STRING String, - OUT gctSTRING * Target - ) -{ - gctSIZE_T bytes; - gctSTRING string; - gceSTATUS status; - - gcmHEADER_ARG("String=0x%x", String); - - gcmDEBUG_VERIFY_ARGUMENT(String != gcvNULL); - gcmDEBUG_VERIFY_ARGUMENT(Target != gcvNULL); - - bytes = gcoOS_StrLen(String, gcvNULL); - - gcmONERROR(gcoOS_Allocate(gcvNULL, bytes + 1, (gctPOINTER *) &string)); - - memcpy(string, String, bytes + 1); - - *Target = string; - - /* Success. */ - gcmFOOTER_ARG("*Target=0x%x", gcmOPT_VALUE(Target)); - return gcvSTATUS_OK; - -OnError: - /* Return the status. */ - gcmFOOTER(); - return status; -} - -/******************************************************************************* -** -** gcoOS_LoadLibrary -** -** Load a library. -** -** INPUT: -** -** gcoOS Os -** Pointer to gcoOS object. -** -** gctCONST_STRING Library -** Name of library to load. -** -** OUTPUT: -** -** gctHANDLE * Handle -** Pointer to variable receiving the library handle. -*/ -gceSTATUS -gcoOS_LoadLibrary( - IN gcoOS Os, - IN gctCONST_STRING Library, - OUT gctHANDLE * Handle - ) -{ -#if gcdSTATIC_LINK - return gcvSTATUS_NOT_SUPPORTED; -#else - gctSIZE_T length; - gctSTRING library = gcvNULL; - gceSTATUS status = gcvSTATUS_OK; - - gcmHEADER_ARG("Library=%s", gcmOPT_STRING(Library)); - - /* Verify the arguments. */ - gcmDEBUG_VERIFY_ARGUMENT(Handle != gcvNULL); - - /* Reset the handle. */ - *Handle = gcvNULL; - - if (Library != gcvNULL) - { - /* Get the length of the library name. */ - length = strlen(Library); - - /* Test if the libray has ".so" at the end. */ - if (strcmp(Library + length - 3, ".so") != 0) - { - /* Allocate temporay string buffer. */ - gcmONERROR(gcoOS_Allocate( - gcvNULL, length + 3 + 1, (gctPOINTER *) &library - )); - - /* Copy the library name to the temporary string buffer. */ - strncpy(library, Library, length + 1); - - /* Append the ".so" to the temporary string buffer. */ - strncat(library, ".so", 3 + 1); - - /* Replace the library name. */ - Library = library; - } - - *Handle = dlopen(Library, RTLD_NOW); - - /* Failed? */ - if (*Handle == gcvNULL) - { - gcmTRACE( - gcvLEVEL_VERBOSE, "%s(%d): %s", __FUNCTION__, __LINE__, Library - ); - - gcmTRACE( - gcvLEVEL_VERBOSE, "%s(%d): %s", __FUNCTION__, __LINE__, dlerror() - ); - - /* Library could not be loaded. */ - status = gcvSTATUS_NOT_FOUND; - } - } - -OnError: - /* Free the temporary string buffer. */ - if (library != gcvNULL) - { - gcmVERIFY_OK(gcmOS_SAFE_FREE(gcvNULL, library)); - } - - gcmFOOTER_ARG("*Handle=0x%x status=%d", *Handle, status); - return status; -#endif -} - -/******************************************************************************* -** -** gcoOS_FreeLibrary -** -** Unload a loaded library. -** -** INPUT: -** -** gcoOS Os -** Pointer to gcoOS object. -** -** gctHANDLE Handle -** Handle of a loaded libarry. -** -** OUTPUT: -** -** Nothing. -*/ -gceSTATUS -gcoOS_FreeLibrary( - IN gcoOS Os, - IN gctHANDLE Handle - ) -{ -#if gcdSTATIC_LINK - return gcvSTATUS_NOT_SUPPORTED; -#else - gcmHEADER_ARG("Handle=0x%x", Handle); - -#if !gcdBUILT_FOR_VALGRIND - /* Free the library. */ - dlclose(Handle); -#endif - - /* Success. */ - gcmFOOTER_NO(); - return gcvSTATUS_OK; -#endif -} - -/******************************************************************************* -** -** gcoOS_GetProcAddress -** -** Get the address of a function inside a loaded library. -** -** INPUT: -** -** gcoOS Os -** Pointer to gcoOS object. -** -** gctHANDLE Handle -** Handle of a loaded libarry. -** -** gctCONST_STRING Name -** Name of function to get the address of. -** -** OUTPUT: -** -** gctPOINTER * Function -** Pointer to variable receiving the function pointer. -*/ -gceSTATUS -gcoOS_GetProcAddress( - IN gcoOS Os, - IN gctHANDLE Handle, - IN gctCONST_STRING Name, - OUT gctPOINTER * Function - ) -{ -#if gcdSTATIC_LINK - return gcvSTATUS_NOT_SUPPORTED; -#else - gceSTATUS status = gcvSTATUS_OK; - - gcmHEADER_ARG("Handle=0x%x Name=%s", Handle, gcmOPT_STRING(Name)); - - /* Verify the arguments. */ - gcmDEBUG_VERIFY_ARGUMENT(Name != gcvNULL); - gcmDEBUG_VERIFY_ARGUMENT(Function != gcvNULL); - - /* Get the address of the function. */ - *Function = dlsym(Handle, Name); - - if (*Function == gcvNULL) - { - gcmTRACE( - gcvLEVEL_WARNING, - "%s(%d): Function %s not found.", - __FUNCTION__, __LINE__, Name - ); - - /* Function could not be found. */ - status = gcvSTATUS_NOT_FOUND; - } - - /* Success. */ - gcmFOOTER_ARG("*Function=0x%x status=%d", *Function, status); - return status; -#endif -} - -#if VIVANTE_PROFILER_SYSTEM_MEMORY -gceSTATUS -gcoOS_ProfileStart( - IN gcoOS Os - ) -{ -#if gcdGC355_MEM_PRINT - gcPLS.os->oneRecording = 0; - gcPLS.os->oneSize = 0; -#endif - - return gcvSTATUS_OK; -} - -gceSTATUS -gcoOS_ProfileEnd( - IN gcoOS Os, - IN gctCONST_STRING Title - ) -{ - gceSTATUS status = gcvSTATUS_OK; - if (gcPLS.bMemoryProfile && gcPLS.os) - { - /* cache video memory infomation to PLS when Destroy OS */ - gcsHAL_INTERFACE iface; - - gcoOS_ZeroMemory(&iface, sizeof(iface)); - - iface.command = gcvHAL_DATABASE; - iface.u.Database.processID = gcmPTR2INT32(gcoOS_GetCurrentProcessID()); - iface.u.Database.validProcessID = gcvTRUE; - - /* Call kernel service. */ - gcmONERROR(gcoOS_DeviceControl( - gcvNULL, - IOCTL_GCHAL_INTERFACE, - &iface, gcmSIZEOF(iface), - &iface, gcmSIZEOF(iface) - )); - - gcPLS.video_currentSize = iface.u.Database.vidMem.counters.bytes + iface.u.Database.nonPaged.counters.bytes; - gcPLS.video_maxAllocSize = iface.u.Database.vidMem.counters.maxBytes + iface.u.Database.nonPaged.counters.maxBytes; - gcPLS.video_allocSize = iface.u.Database.vidMem.counters.totalBytes + iface.u.Database.nonPaged.counters.totalBytes; - gcPLS.video_allocCount = iface.u.Database.vidMem.counters.allocCount + iface.u.Database.nonPaged.counters.allocCount; - gcPLS.video_freeCount = iface.u.Database.vidMem.counters.freeCount + iface.u.Database.nonPaged.counters.freeCount; - } - -OnError: - return status; -} - -/******************************************************************************* -** -** gcoOS_SetProfileSetting -** -** Set Vivante profiler settings. -** -** INPUT: -** -** gcoOS Os -** Pointer to an gcoOS object. -** -** gctBOOL Enable -** Enable or Disable Vivante profiler. -** -** gctCONST_STRING FileName -** Specify FileName for storing profile data into. -** -** OUTPUT: -** -** Nothing. -*/ -gceSTATUS -gcoOS_SetProfileSetting( - IN gcoOS Os, - IN gctBOOL Enable, - IN gctCONST_STRING FileName - ) -{ - gcsHAL_INTERFACE iface; - - if (strlen(FileName) >= gcdMAX_PROFILE_FILE_NAME) - { - return gcvSTATUS_INVALID_ARGUMENT; - } - - /* Initialize the gcsHAL_INTERFACE structure. */ - iface.ignoreTLS = gcvFALSE; - iface.command = gcvHAL_SET_PROFILE_SETTING; - iface.u.SetProfileSetting.enable = Enable; - - /* Call the kernel. */ - return gcoOS_DeviceControl(gcvNULL, - IOCTL_GCHAL_INTERFACE, - &iface, gcmSIZEOF(iface), - &iface, gcmSIZEOF(iface)); -} -#endif - -gceSTATUS -gcoOS_Compact( - IN gcoOS Os - ) -{ - return gcvSTATUS_OK; -} - -/*----------------------------------------------------------------------------*/ -/*----------------------------------- Atoms ----------------------------------*/ -/* Create an atom. */ -gceSTATUS -gcoOS_AtomConstruct( - IN gcoOS Os, - OUT gcsATOM_PTR * Atom - ) -{ - gceSTATUS status; - gcsATOM_PTR atom = gcvNULL; - - gcmHEADER(); - - /* Verify the arguments. */ - gcmDEBUG_VERIFY_ARGUMENT(Atom != gcvNULL); - - do - { - /* Allocate memory for the atom. */ - gcmERR_BREAK(gcoOS_Allocate(gcvNULL, - gcmSIZEOF(struct gcsATOM), - (gctPOINTER *) &atom)); - - /* Initialize the atom to 0. */ - atom->counter = 0; - -#if !gcdBUILTIN_ATOMIC_FUNCTIONS - if (pthread_mutex_init(&atom->mutex, gcvNULL) != 0) - { - status = gcvSTATUS_OUT_OF_RESOURCES; - break; - } -#endif - - /* Return pointer to atom. */ - *Atom = atom; - - /* Success. */ - gcmFOOTER_ARG("*Atom=%p", *Atom); - return gcvSTATUS_OK; - } - while (gcvFALSE); - - /* Free the atom. */ - if (atom != gcvNULL) - { - gcmOS_SAFE_FREE(gcvNULL, atom); - } - - /* Return error status. */ - gcmFOOTER(); - return status; -} - -/* Destroy an atom. */ -gceSTATUS -gcoOS_AtomDestroy( - IN gcoOS Os, - IN gcsATOM_PTR Atom - ) -{ - gceSTATUS status; - - gcmHEADER_ARG("Atom=0x%x", Atom); - - /* Verify the arguments. */ - gcmDEBUG_VERIFY_ARGUMENT(Atom != gcvNULL); - - /* Free the atom. */ - status = gcmOS_SAFE_FREE(gcvNULL, Atom); - - /* Return the status. */ - gcmFOOTER(); - return status; -} - -gceSTATUS -gcoOS_AtomGet( - IN gcoOS Os, - IN gcsATOM_PTR Atom, - OUT gctINT32_PTR Value - ) -{ - gcmHEADER_ARG("Atom=0x%0x", Atom); - - /* Verify the arguments. */ - gcmVERIFY_ARGUMENT(Atom != gcvNULL); - - /* Get the atom value. */ - *Value = Atom->counter; - - /* Success. */ - gcmFOOTER_ARG("*Value=%d", *Value); - return gcvSTATUS_OK; -} - -gceSTATUS -gcoOS_AtomSet( - IN gcoOS Os, - IN gcsATOM_PTR Atom, - IN gctINT32 Value - ) -{ - gcmHEADER_ARG("Atom=0x%0x Value=%d", Atom, Value); - - /* Verify the arguments. */ - gcmVERIFY_ARGUMENT(Atom != gcvNULL); - - /* Set the atom value. */ - Atom->counter = Value; - - /* Success. */ - gcmFOOTER_NO(); - return gcvSTATUS_OK; -} - -/* Increment an atom. */ -gceSTATUS -gcoOS_AtomIncrement( - IN gcoOS Os, - IN gcsATOM_PTR Atom, - OUT gctINT32_PTR OldValue OPTIONAL - ) -{ - gctINT32 value; - - gcmHEADER_ARG("Atom=0x%x", Atom); - - /* Verify the arguments. */ - gcmDEBUG_VERIFY_ARGUMENT(Atom != gcvNULL); - - /* Increment the atom's counter. */ -#if gcdBUILTIN_ATOMIC_FUNCTIONS - value = __sync_fetch_and_add(&Atom->counter, 1); -#else - /* Lock the mutex. */ - pthread_mutex_lock(&Atom->mutex); - - /* Get original value. */ - value = Atom->counter; - - /* Add given value. */ - Atom->counter += 1; - - /* Unlock the mutex. */ - pthread_mutex_unlock(&Atom->mutex); -#endif - - if (OldValue != gcvNULL) - { - /* Return the original value to the caller. */ - *OldValue = value; - } - - /* Success. */ - gcmFOOTER_ARG("*OldValue=%d", gcmOPT_VALUE(OldValue)); - return gcvSTATUS_OK; -} - -/* Decrement an atom. */ -gceSTATUS -gcoOS_AtomDecrement( - IN gcoOS Os, - IN gcsATOM_PTR Atom, - OUT gctINT32_PTR OldValue OPTIONAL - ) -{ - gctINT32 value; - - gcmHEADER_ARG("Atom=0x%x", Atom); - - /* Verify the arguments. */ - gcmDEBUG_VERIFY_ARGUMENT(Atom != gcvNULL); - - /* Decrement the atom's counter. */ -#if gcdBUILTIN_ATOMIC_FUNCTIONS - value = __sync_fetch_and_sub(&Atom->counter, 1); -#else - /* Lock the mutex. */ - pthread_mutex_lock(&Atom->mutex); - - /* Get original value. */ - value = Atom->counter; - - /* Subtract given value. */ - Atom->counter -= 1; - - /* Unlock the mutex. */ - pthread_mutex_unlock(&Atom->mutex); -#endif - - if (OldValue != gcvNULL) - { - /* Return the original value to the caller. */ - *OldValue = value; - } - - /* Success. */ - gcmFOOTER_ARG("*OldValue=%d", gcmOPT_VALUE(OldValue)); - return gcvSTATUS_OK; -} - -gctHANDLE -gcoOS_GetCurrentProcessID( - void - ) -{ - return (gctHANDLE)(gctUINTPTR_T) getpid(); -} - -gctHANDLE -gcoOS_GetCurrentThreadID( - void - ) -{ - return (gctHANDLE)gcmINT2PTR(gcmGETTHREADID()); -} - -/*----------------------------------------------------------------------------*/ -/*----------------------------------- Time -----------------------------------*/ - -/******************************************************************************* -** -** gcoOS_GetTicks -** -** Get the number of milliseconds since the system started. -** -** INPUT: -** -** OUTPUT: -** -*/ -gctUINT32 -gcoOS_GetTicks( - void - ) -{ - struct timeval tv; - - /* Return the time of day in milliseconds. */ - gettimeofday(&tv, 0); - return (tv.tv_sec * 1000) + (tv.tv_usec / 1000); -} - -/******************************************************************************* -** -** gcoOS_GetTime -** -** Get the number of microseconds since 1970/1/1. -** -** INPUT: -** -** OUTPUT: -** -** gctUINT64_PTR Time -** Pointer to a variable to get time. -** -*/ -gceSTATUS -gcoOS_GetTime( - OUT gctUINT64_PTR Time - ) -{ - struct timeval tv; - - /* Return the time of day in microseconds. */ - gettimeofday(&tv, 0); - *Time = (tv.tv_sec * (gctUINT64)1000000) + tv.tv_usec; - return gcvSTATUS_OK; -} - -/******************************************************************************* -** -** gcoOS_GetCPUTime -** -** Get CPU time usage in microseconds. -** -** INPUT: -** -** OUTPUT: -** -** gctUINT64_PTR CPUTime -** Pointer to a variable to get CPU time usage. -** -*/ -gceSTATUS -gcoOS_GetCPUTime( - OUT gctUINT64_PTR CPUTime - ) -{ - struct rusage usage; - - /* Return CPU time in microseconds. */ - if (getrusage(RUSAGE_SELF, &usage) == 0) - { - *CPUTime = usage.ru_utime.tv_sec * (gctUINT64)1000000 + usage.ru_utime.tv_usec; - *CPUTime += usage.ru_stime.tv_sec * (gctUINT64)1000000 + usage.ru_stime.tv_usec; - return gcvSTATUS_OK; - } - else - { - *CPUTime = 0; - return gcvSTATUS_INVALID_ARGUMENT; - } -} - -/******************************************************************************* -** -** gcoOS_GetMemoryUsage -** -** Get current processes resource usage. -** -** INPUT: -** -** OUTPUT: -** -** gctUINT32_PTR MaxRSS -** Total amount of resident set memory used. -** The value will be in terms of memory pages used. -** -** gctUINT32_PTR IxRSS -** Total amount of memory used by the text segment -** in kilobytes multiplied by the execution-ticks. -** -** gctUINT32_PTR IdRSS -** Total amount of private memory used by a process -** in kilobytes multiplied by execution-ticks. -** -** gctUINT32_PTR IsRSS -** Total amount of memory used by the stack in -** kilobytes multiplied by execution-ticks. -** -*/ -gceSTATUS -gcoOS_GetMemoryUsage( - OUT gctUINT32_PTR MaxRSS, - OUT gctUINT32_PTR IxRSS, - OUT gctUINT32_PTR IdRSS, - OUT gctUINT32_PTR IsRSS - ) -{ - struct rusage usage; - - /* Return memory usage. */ - if (getrusage(RUSAGE_SELF, &usage) == 0) - { - *MaxRSS = usage.ru_maxrss; - *IxRSS = usage.ru_ixrss; - *IdRSS = usage.ru_idrss; - *IsRSS = usage.ru_isrss; - return gcvSTATUS_OK; - } - else - { - *MaxRSS = 0; - *IxRSS = 0; - *IdRSS = 0; - *IsRSS = 0; - return gcvSTATUS_INVALID_ARGUMENT; - } -} - -/******************************************************************************* -** -** gcoOS_ReadRegister -** -** Read data from a register. -** -** INPUT: -** -** gcoOS Os -** Pointer to an gcoOS object. -** -** gctUINT32 Address -** Address of register. -** -** OUTPUT: -** -** gctUINT32 * Data -** Pointer to a variable that receives the data read from the register. -*/ -gceSTATUS -gcoOS_ReadRegister( - IN gcoOS Os, - IN gctUINT32 Address, - OUT gctUINT32 * Data - ) -{ - gcsHAL_INTERFACE iface; - gceSTATUS status; - - gcmHEADER_ARG("Address=0x%x", Address); - - /* Verify the arguments. */ - gcmDEBUG_VERIFY_ARGUMENT(Data != gcvNULL); - - /* Initialize the gcsHAL_INTERFACE structure. */ - iface.ignoreTLS = gcvFALSE; - iface.command = gcvHAL_READ_REGISTER; - iface.u.ReadRegisterData.address = Address; - iface.u.ReadRegisterData.data = 0xDEADDEAD; - - /* Call kernel driver. */ - gcmONERROR(gcoOS_DeviceControl(gcvNULL, - IOCTL_GCHAL_INTERFACE, - &iface, gcmSIZEOF(iface), - &iface, gcmSIZEOF(iface))); - - /* Return the Data on success. */ - *Data = iface.u.ReadRegisterData.data; - - /* Success. */ - gcmFOOTER_ARG("*Data=0x%08x", *Data); - return gcvSTATUS_OK; - -OnError: - /* Return the status. */ - gcmFOOTER(); - return status; -} - -/******************************************************************************* -** -** gcoOS_WriteRegister -** -** Write data to a register. -** -** INPUT: -** -** gcoOS Os -** Pointer to an gcoOS object. -** -** gctUINT32 Address -** Address of register. -** -** gctUINT32 Data -** Data for register. -** -** OUTPUT: -** -** Nothing. -*/ -gceSTATUS -gcoOS_WriteRegister( - IN gcoOS Os, - IN gctUINT32 Address, - IN gctUINT32 Data - ) -{ - gcsHAL_INTERFACE iface; - gceSTATUS status; - - gcmHEADER_ARG("Address=0x%x Data=0x%08x", Address, Data); - - /* Initialize the gcsHAL_INTERFACE structure. */ - iface.ignoreTLS = gcvFALSE; - iface.command = gcvHAL_WRITE_REGISTER; - iface.u.WriteRegisterData.address = Address; - iface.u.WriteRegisterData.data = Data; - - /* Call kernel driver. */ - gcmONERROR(gcoOS_DeviceControl(gcvNULL, - IOCTL_GCHAL_INTERFACE, - &iface, gcmSIZEOF(iface), - &iface, gcmSIZEOF(iface))); - - /* Success. */ - gcmFOOTER_NO(); - return gcvSTATUS_OK; - -OnError: - /* Return the status. */ - gcmFOOTER(); - return status; -} - -static gceSTATUS -gcoOS_Cache( - IN gctUINT32 Node, - IN gctPOINTER Logical, - IN gctSIZE_T Bytes, - IN gceCACHEOPERATION Operation - ) -{ - gcsHAL_INTERFACE ioctl; - gceSTATUS status; - - gcmHEADER_ARG("Node=0x%x Logical=0x%x Bytes=%u Operation=%d", - Node, Logical, Bytes, Operation); - - /* Verify the arguments. */ - gcmDEBUG_VERIFY_ARGUMENT(Logical != gcvNULL); - gcmDEBUG_VERIFY_ARGUMENT(Bytes > 0); - - /* Set up the cache. */ - ioctl.ignoreTLS = gcvFALSE; - ioctl.command = gcvHAL_CACHE; - ioctl.u.Cache.operation = Operation; - ioctl.u.Cache.node = Node; - ioctl.u.Cache.logical = gcmPTR_TO_UINT64(Logical); - ioctl.u.Cache.bytes = Bytes; - - /* Call the kernel. */ - gcmONERROR(gcoOS_DeviceControl(gcvNULL, - IOCTL_GCHAL_INTERFACE, - &ioctl, gcmSIZEOF(ioctl), - &ioctl, gcmSIZEOF(ioctl))); - - /* Success. */ - gcmFOOTER_NO(); - return gcvSTATUS_OK; - -OnError: - /* Return the status. */ - gcmFOOTER(); - return status; -} - -/******************************************************************************* -** gcoOS_CacheClean -** -** Clean the cache for the specified addresses. The GPU is going to need the -** data. If the system is allocating memory as non-cachable, this function can -** be ignored. -** -** ARGUMENTS: -** -** gcoOS Os -** Pointer to gcoOS object. -** -** gctUINT32 Node -** Pointer to the video memory node that needs to be flushed. -** -** gctPOINTER Logical -** Logical address to flush. -** -** gctSIZE_T Bytes -** Size of the address range in bytes to flush. -*/ -gceSTATUS -gcoOS_CacheClean( - IN gcoOS Os, - IN gctUINT32 Node, - IN gctPOINTER Logical, - IN gctSIZE_T Bytes - ) -{ - gceSTATUS status; - - gcmHEADER_ARG("Node=0x%x Logical=0x%x Bytes=%u", - Node, Logical, Bytes); - - /* Call common code. */ - gcmONERROR(gcoOS_Cache(Node, Logical, Bytes, gcvCACHE_CLEAN)); - - /* Success. */ - gcmFOOTER_NO(); - return gcvSTATUS_OK; - -OnError: - /* Return the status. */ - gcmFOOTER(); - return status; -} - -/******************************************************************************* -** gcoOS_CacheFlush -** -** Flush the cache for the specified addresses and invalidate the lines as -** well. The GPU is going to need and modify the data. If the system is -** allocating memory as non-cachable, this function can be ignored. -** -** ARGUMENTS: -** -** gcoOS Os -** Pointer to gcoOS object. -** -** gctUINT32 Node -** Pointer to the video memory node that needs to be flushed. -** -** gctPOINTER Logical -** Logical address to flush. -** -** gctSIZE_T Bytes -** Size of the address range in bytes to flush. -*/ -gceSTATUS -gcoOS_CacheFlush( - IN gcoOS Os, - IN gctUINT32 Node, - IN gctPOINTER Logical, - IN gctSIZE_T Bytes - ) -{ - gceSTATUS status; - - gcmHEADER_ARG("Node=0x%x Logical=0x%x Bytes=%u", - Node, Logical, Bytes); - - /* Call common code. */ - gcmONERROR(gcoOS_Cache(Node, Logical, Bytes, gcvCACHE_FLUSH)); - - /* Success. */ - gcmFOOTER_NO(); - return gcvSTATUS_OK; - -OnError: - /* Return the status. */ - gcmFOOTER(); - return status; -} - -/******************************************************************************* -** gcoOS_CacheInvalidate -** -** Invalidate the lines. The GPU is going modify the data. If the system is -** allocating memory as non-cachable, this function can be ignored. -** -** ARGUMENTS: -** -** gcoOS Os -** Pointer to gcoOS object. -** -** gctUINT32 Node -** Pointer to the video memory node that needs to be invalidated. -** -** gctPOINTER Logical -** Logical address to flush. -** -** gctSIZE_T Bytes -** Size of the address range in bytes to invalidated. -*/ -gceSTATUS -gcoOS_CacheInvalidate( - IN gcoOS Os, - IN gctUINT32 Node, - IN gctPOINTER Logical, - IN gctSIZE_T Bytes - ) -{ - gceSTATUS status; - - gcmHEADER_ARG("Node=0x%x Logical=0x%x Bytes=%u", - Node, Logical, Bytes); - - /* Call common code. */ - gcmONERROR(gcoOS_Cache(Node, Logical, Bytes, gcvCACHE_INVALIDATE)); - - /* Success. */ - gcmFOOTER_NO(); - return gcvSTATUS_OK; - -OnError: - /* Return the status. */ - gcmFOOTER(); - return status; -} - -/******************************************************************************* -** gcoOS_MemoryBarrier -** Make sure the CPU has executed everything up to this point and the data got -** written to the specified pointer. -** ARGUMENTS: -** -** gcoOS Os -** Pointer to gcoOS object. -** -** gctPOINTER Logical -** Logical address to flush. -** -*/ -gceSTATUS -gcoOS_MemoryBarrier( - IN gcoOS Os, - IN gctPOINTER Logical - ) -{ - gceSTATUS status; - - gcmHEADER_ARG("Logical=0x%x", Logical); - - /* Call common code. */ - gcmONERROR(gcoOS_Cache(0, Logical, 1, gcvCACHE_MEMORY_BARRIER)); - - /* Success. */ - gcmFOOTER_NO(); - return gcvSTATUS_OK; - -OnError: - /* Return the status. */ - gcmFOOTER(); - return status; -} - - -/*----------------------------------------------------------------------------*/ -/*----- Profiling ------------------------------------------------------------*/ -/*----------------------------------------------------------------------------*/ - -#if gcdENABLE_PROFILING -gceSTATUS -gcoOS_GetProfileTick( - OUT gctUINT64_PTR Tick - ) -{ -#ifdef CLOCK_MONOTONIC - struct timespec time; - - clock_gettime(CLOCK_MONOTONIC, &time); - - *Tick = time.tv_nsec + time.tv_sec * 1000000000ULL; - - return gcvSTATUS_OK; -#else - return gcvSTATUS_NOT_SUPPORTED; -#endif -} - -gceSTATUS -gcoOS_QueryProfileTickRate( - OUT gctUINT64_PTR TickRate - ) -{ -#ifdef CLOCK_MONOTONIC - struct timespec res; - - clock_getres(CLOCK_MONOTONIC, &res); - - *TickRate = res.tv_nsec + res.tv_sec * 1000000000ULL; - - return gcvSTATUS_OK; -#else - return gcvSTATUS_NOT_SUPPORTED; -#endif -} - -/******************************************************************************* -** gcoOS_ProfileDB -** -** Manage the profile database. -** -** The database layout is very simple: -** -** (1 byte) -** -** The can be one of the following values: -** -** 1 Initialize a new function to be profiled. Followed by the NULL- -** terminated name of the function, 4 bytes of the function ID and -** 8 bytes of the profile tick. -** 2 Enter a function to be profiled. Followed by 4 bytes of function -** ID and 8 bytes of the profile tick. -** 3 Exit a function to be profiled. Followed by 8 bytes of the -** profile tick. -** -** There are three options to manage the profile database. One would be to -** enter a function that needs to be profiled. This is specified with both -** and pointers initialized to some value. Here -** is pointing to a string with the function name and -** is pointing to a boolean value that tells the profiler whether this function -** has been initialized or not. -** -** The second option would be to exit a function that was being profiled. This -** is specified by pointing to a string with the function name and -** set to gcvNULL. -** -** The third and last option is to flush the profile database. This is -** specified with set to gcvNULL. -** -***** PARAMETERS -** -** Function -** -** Pointer to a string with the function name being profiled or gcvNULL to -** flush the profile database. -** -** Initialized -** -** Pointer to a boolean variable that informs the profiler if the entry of -** a function has been initialized or not, or gcvNULL to mark the exit of a -** function being profiled. -*/ -void -gcoOS_ProfileDB( - IN gctCONST_STRING Function, - IN OUT gctBOOL_PTR Initialized - ) -{ - gctUINT64 nanos; - static gctUINT8_PTR profileBuffer = gcvNULL; - static gctSIZE_T profileSize, profileThreshold, totalBytes; - static gctUINT32 profileIndex; - static gctINT profileLevel; - static FILE * profileDB = gcvNULL; - int len, bytes; - - /* Check if we need to flush the profile database. */ - if (Function == gcvNULL) - { - if (profileBuffer != gcvNULL) - { - /* Check of the profile database exists. */ - if (profileIndex > 0) - { - if (profileDB == gcvNULL) - { - /* Open the profile database file. */ - profileDB = fopen("profile.database", "wb"); - } - - if (profileDB != gcvNULL) - { - /* Write the profile database to the file. */ - totalBytes += fwrite(profileBuffer, - 1, profileIndex, - profileDB); - } - } - - if (profileDB != gcvNULL) - { - /* Convert the size of the profile database into a nice human - ** readable format. */ - char buf[] = "#,###,###,###"; - int i; - - i = strlen(buf); - while ((totalBytes != 0) && (i > 0)) - { - if (buf[--i] == ',') --i; - - buf[i] = '0' + (totalBytes % 10); - totalBytes /= 10; - } - - /* Print the size of the profile database. */ - gcmPRINT("Closing the profile database: %s bytes.", &buf[i]); - - /* Close the profile database file. */ - fclose(profileDB); - profileDB = gcvNULL; - } - - /* Destroy the profile database. */ - free(profileBuffer); - profileBuffer = gcvNULL; - } - } - - /* Check if we have to enter a function. */ - else if (Initialized != gcvNULL) - { - /* Check if the profile database exists or not. */ - if (profileBuffer == gcvNULL) - { - /* Allocate the profile database. */ - for (profileSize = 32 << 20; - profileSize > 0; - profileSize -= 1 << 20 - ) - { - profileBuffer = malloc(profileSize); - - if (profileBuffer != gcvNULL) - { - break; - } - } - - if (profileBuffer == gcvNULL) - { - /* Sorry - no memory. */ - gcmPRINT("Cannot create the profile buffer!"); - return; - } - - /* Reset the profile database. */ - profileThreshold = gcmMIN(profileSize / 2, 4 << 20); - totalBytes = 0; - profileIndex = 0; - profileLevel = 0; - } - - /* Increment the profile level. */ - ++profileLevel; - - /* Determine number of bytes to copy. */ - len = strlen(Function) + 1; - bytes = 1 + (*Initialized ? 0 : len) + 4 + 8; - - /* Check if the profile database has enough space. */ - if (profileIndex + bytes > profileSize) - { - gcmPRINT("PROFILE ENTRY: index=%u size=%u bytes=%d level=%d", - profileIndex, profileSize, bytes, profileLevel); - - if (profileDB == gcvNULL) - { - /* Open the profile database file. */ - profileDB = fopen("profile.database", "wb"); - } - - if (profileDB != gcvNULL) - { - /* Write the profile database to the file. */ - totalBytes += fwrite(profileBuffer, 1, profileIndex, profileDB); - } - - /* Empty the profile databse. */ - profileIndex = 0; - } - - /* Check whether this function is initialized or not. */ - if (*Initialized) - { - /* Already initialized - don't need to save name. */ - profileBuffer[profileIndex] = 2; - } - else - { - /* Not yet initialized, save name as well. */ - profileBuffer[profileIndex] = 1; - memcpy(profileBuffer + profileIndex + 1, Function, len); - profileIndex += len; - - /* Mark function as initialized. */ - *Initialized = gcvTRUE; - } - - /* Copy the function ID into the profile database. */ - memcpy(profileBuffer + profileIndex + 1, &Initialized, 4); - - /* Get the profile tick. */ - gcoOS_GetProfileTick(&nanos); - - /* Copy the profile tick into the profile database. */ - memcpy(profileBuffer + profileIndex + 5, &nanos, 8); - profileIndex += 1 + 4 + 8; - } - - /* Exit a function, check whether the profile database is around. */ - else if (profileBuffer != gcvNULL) - { - /* Get the profile tick. */ - gcoOS_GetProfileTick(&nanos); - - /* Check if the profile database has enough space. */ - if (profileIndex + 1 + 8 > profileSize) - { - gcmPRINT("PROFILE EXIT: index=%u size=%u bytes=%d level=%d", - profileIndex, profileSize, 1 + 8, profileLevel); - - if (profileDB == gcvNULL) - { - /* Open the profile database file. */ - profileDB = fopen("profile.database", "wb"); - } - - if (profileDB != gcvNULL) - { - /* Write the profile database to the file. */ - totalBytes += fwrite(profileBuffer, 1, profileIndex, profileDB); - } - - /* Empty the profile databse. */ - profileIndex = 0; - } - - /* Copy the profile tick into the profile database. */ - profileBuffer[profileIndex] = 3; - memcpy(profileBuffer + profileIndex + 1, &nanos, 8); - profileIndex += 1 + 8; - - /* Decrease the profile level and check whether the profile database is - ** getting too big if we exit a top-level function. */ - if ((--profileLevel == 0) - && (profileSize - profileIndex < profileThreshold) - ) - { - if (profileDB == gcvNULL) - { - /* Open the profile database file. */ - profileDB = fopen("profile.database", "wb"); - } - - if (profileDB != gcvNULL) - { - /* Write the profile database to the file. */ - totalBytes += fwrite(profileBuffer, 1, profileIndex, profileDB); - - /* Flush the file now. */ - fflush(profileDB); - } - - /* Empty the profile databse. */ - profileIndex = 0; - } - } -} -#endif - -/******************************************************************************\ -******************************* Signal Management ****************************** -\******************************************************************************/ - -#undef _GC_OBJ_ZONE -#define _GC_OBJ_ZONE gcvZONE_SIGNAL - -/******************************************************************************* -** -** gcoOS_CreateSignal -** -** Create a new signal. -** -** INPUT: -** -** gcoOS Os -** Pointer to an gcoOS object. -** -** gctBOOL ManualReset -** If set to gcvTRUE, gcoOS_Signal with gcvFALSE must be called in -** order to set the signal to nonsignaled state. -** If set to gcvFALSE, the signal will automatically be set to -** nonsignaled state by gcoOS_WaitSignal function. -** -** OUTPUT: -** -** gctSIGNAL * Signal -** Pointer to a variable receiving the created gctSIGNAL. -*/ -gceSTATUS -gcoOS_CreateSignal( - IN gcoOS Os, - IN gctBOOL ManualReset, - OUT gctSIGNAL * Signal - ) -{ - gceSTATUS status; - gcsHAL_INTERFACE iface; - - gcmHEADER_ARG("ManualReset=%d", ManualReset); - - /* Verify the arguments. */ - gcmDEBUG_VERIFY_ARGUMENT(Signal != gcvNULL); - - /* Initialize the gcsHAL_INTERFACE structure. */ - iface.ignoreTLS = gcvFALSE; - iface.command = gcvHAL_USER_SIGNAL; - iface.u.UserSignal.command = gcvUSER_SIGNAL_CREATE; - iface.u.UserSignal.manualReset = ManualReset; - - /* Call kernel driver. */ - gcmONERROR(gcoOS_DeviceControl(gcvNULL, - IOCTL_GCHAL_INTERFACE, - &iface, gcmSIZEOF(iface), - &iface, gcmSIZEOF(iface))); - - *Signal = (gctSIGNAL)(gctUINTPTR_T) iface.u.UserSignal.id; - - gcmFOOTER_ARG("*Signal=0x%x", *Signal); - return gcvSTATUS_OK; - -OnError: - gcmFOOTER(); - return status; -} - -/******************************************************************************* -** -** gcoOS_DestroySignal -** -** Destroy a signal. -** -** INPUT: -** -** gcoOS Os -** Pointer to an gcoOS object. -** -** gctSIGNAL Signal -** Pointer to the gctSIGNAL. -** -** OUTPUT: -** -** Nothing. -*/ -gceSTATUS -gcoOS_DestroySignal( - IN gcoOS Os, - IN gctSIGNAL Signal - ) -{ - gceSTATUS status; - gcsHAL_INTERFACE iface; - - gcmHEADER_ARG("Signal=0x%x", Signal); - - gcmTRACE_ZONE( - gcvLEVEL_VERBOSE, gcvZONE_OS, - "gcoOS_DestroySignal: signal->%d.", - (gctINT)(gctUINTPTR_T)Signal - ); - - /* Initialize the gcsHAL_INTERFACE structure. */ - iface.ignoreTLS = gcvFALSE; - iface.command = gcvHAL_USER_SIGNAL; - iface.u.UserSignal.command = gcvUSER_SIGNAL_DESTROY; - iface.u.UserSignal.id = (gctINT)(gctUINTPTR_T) Signal; - - /* Call kernel driver. */ - status = gcoOS_DeviceControl(gcvNULL, - IOCTL_GCHAL_INTERFACE, - &iface, gcmSIZEOF(iface), - &iface, gcmSIZEOF(iface)); - - /* Success. */ - gcmFOOTER(); - return status; -} - -/******************************************************************************* -** -** gcoOS_Signal -** -** Set a state of the specified signal. -** -** INPUT: -** -** gcoOS Os -** Pointer to an gcoOS object. -** -** gctSIGNAL Signal -** Pointer to the gctSIGNAL. -** -** gctBOOL State -** If gcvTRUE, the signal will be set to signaled state. -** If gcvFALSE, the signal will be set to nonsignaled state. -** -** OUTPUT: -** -** Nothing. -*/ -gceSTATUS -gcoOS_Signal( - IN gcoOS Os, - IN gctSIGNAL Signal, - IN gctBOOL State - ) -{ - gceSTATUS status; - gcsHAL_INTERFACE iface; - - gcmHEADER_ARG("Signal=0x%x State=%d", Signal, State); - - /* Initialize the gcsHAL_INTERFACE structure. */ - iface.ignoreTLS = gcvFALSE; - iface.command = gcvHAL_USER_SIGNAL; - iface.u.UserSignal.command = gcvUSER_SIGNAL_SIGNAL; - iface.u.UserSignal.id = (gctINT)(gctUINTPTR_T) Signal; - iface.u.UserSignal.state = State; - - /* Call kernel driver. */ - status = gcoOS_DeviceControl(gcvNULL, - IOCTL_GCHAL_INTERFACE, - &iface, gcmSIZEOF(iface), - &iface, gcmSIZEOF(iface)); - - gcmFOOTER(); - return status; -} - -/******************************************************************************* -** -** gcoOS_WaitSignal -** -** Wait for a signal to become signaled. -** -** INPUT: -** -** gcoOS Os -** Pointer to an gcoOS object. -** -** gctSIGNAL Signal -** Pointer to the gctSIGNAL. -** -** gctUINT32 Wait -** Number of milliseconds to wait. -** Pass the value of gcvINFINITE for an infinite wait. -** -** OUTPUT: -** -** Nothing. -*/ -gceSTATUS -gcoOS_WaitSignal( - IN gcoOS Os, - IN gctSIGNAL Signal, - IN gctUINT32 Wait - ) -{ - gceSTATUS status; - gcsHAL_INTERFACE iface; - - gcmHEADER_ARG("Signal=0x%x Wait=%u", Signal, Wait); - - /* Initialize the gcsHAL_INTERFACE structure. */ - iface.ignoreTLS = gcvFALSE; - iface.command = gcvHAL_USER_SIGNAL; - iface.u.UserSignal.command = gcvUSER_SIGNAL_WAIT; - iface.u.UserSignal.id = (gctINT)(gctUINTPTR_T) Signal; - iface.u.UserSignal.wait = Wait; - - /* Call kernel driver. */ - status = gcoOS_DeviceControl(gcvNULL, - IOCTL_GCHAL_INTERFACE, - &iface, gcmSIZEOF(iface), - &iface, gcmSIZEOF(iface)); - - gcmFOOTER_ARG("Signal=0x%x status=%d", Signal, status); - return status; -} - -/******************************************************************************* -** -** gcoOS_MapSignal -** -** Map a signal from another process. -** -** INPUT: -** -** gctSIGNAL RemoteSignal -** -** OUTPUT: -** -** gctSIGNAL * LocalSignal -** Pointer to a variable receiving the created gctSIGNAL. -*/ -gceSTATUS -gcoOS_MapSignal( - IN gctSIGNAL RemoteSignal, - OUT gctSIGNAL * LocalSignal - ) -{ - gceSTATUS status; - gcsHAL_INTERFACE iface; - - gcmHEADER_ARG("RemoteSignal=%d", RemoteSignal); - - gcmDEBUG_VERIFY_ARGUMENT(RemoteSignal != gcvNULL); - gcmDEBUG_VERIFY_ARGUMENT(LocalSignal != gcvNULL); - iface.ignoreTLS = gcvFALSE; - iface.command = gcvHAL_USER_SIGNAL; - iface.u.UserSignal.command = gcvUSER_SIGNAL_MAP; - iface.u.UserSignal.id = (gctINT)(gctUINTPTR_T) RemoteSignal; - - gcmONERROR(gcoOS_DeviceControl(gcvNULL, - IOCTL_GCHAL_INTERFACE, - &iface, gcmSIZEOF(iface), - &iface, gcmSIZEOF(iface))); - - *LocalSignal = (gctSIGNAL)(gctUINTPTR_T) iface.u.UserSignal.id; - - gcmFOOTER_ARG("*LocalSignal=0x%x", *LocalSignal); - return gcvSTATUS_OK; - -OnError: - gcmFOOTER(); - return status; -} - -/******************************************************************************* -** -** gcoOS_UnmapSignal -** -** Unmap a signal mapped from another process. -** -** INPUT: -** -** gctSIGNAL Signal -** Pointer to the gctSIGNAL. -** -** OUTPUT: -** -** Nothing. -*/ -gceSTATUS -gcoOS_UnmapSignal( - IN gctSIGNAL Signal - ) -{ - gceSTATUS status; - gcsHAL_INTERFACE iface; - - gcmHEADER_ARG("Signal=0x%x", Signal); - - gcmDEBUG_VERIFY_ARGUMENT(Signal != gcvNULL); - - gcmTRACE_ZONE( - gcvLEVEL_VERBOSE, gcvZONE_OS, - "gcoOS_UnmapSignal: signal->%d.", - (gctINT)(gctUINTPTR_T)Signal - ); - iface.ignoreTLS = gcvFALSE; - iface.command = gcvHAL_USER_SIGNAL; - iface.u.UserSignal.command = gcvUSER_SIGNAL_UNMAP; - iface.u.UserSignal.id = (gctINT)(gctUINTPTR_T) Signal; - - status = gcoOS_DeviceControl(gcvNULL, - IOCTL_GCHAL_INTERFACE, - &iface, gcmSIZEOF(iface), - &iface, gcmSIZEOF(iface)); - - gcmFOOTER(); - return status; -} - - -void _SignalHandlerForSIGFPEWhenSignalCodeIs0( - int sig_num, - siginfo_t * info, - void * ucontext - ) -{ - gctINT signalCode; - - signalCode = ((info->si_code) & 0xffff); - if (signalCode == 0) - { - /* simply ignore the signal, this is a temporary fix for bug 4203 */ - return; - } - - /* Let OS handle the signal */ - gcoOS_Print("Process got signal (%d). To further debug the issue, you should run in debug mode", sig_num); - signal (sig_num, SIG_DFL); - raise (sig_num); - return; -} - -/******************************************************************************* -** -** gcoOS_AddSignalHandler -** -** Adds Signal handler depending on Signal Handler Type -** -** INPUT: -** -** gceSignalHandlerType SignalHandlerType -** Type of handler to be added -** -** OUTPUT: -** -** Nothing. -*/ -gceSTATUS -gcoOS_AddSignalHandler ( - IN gceSignalHandlerType SignalHandlerType - ) -{ - gceSTATUS status = gcvSTATUS_OK; - - gcmHEADER_ARG("SignalHandlerType=0x%x", SignalHandlerType); - - switch(SignalHandlerType) - { - case gcvHANDLE_SIGFPE_WHEN_SIGNAL_CODE_IS_0: - { -#if gcdDEBUG - /* Handler will not be registered in debug mode*/ - gcmTRACE( - gcvLEVEL_INFO, - "%s(%d): Will not register signal handler for type gcvHANDLE_SIGFPE_WHEN_SIGNAL_CODE_IS_0 in debug mode", - __FUNCTION__, __LINE__ - ); -#else - struct sigaction temp; - struct sigaction sigact; - sigaction (SIGFPE, NULL, &temp); - if (temp.sa_handler != (void *)_SignalHandlerForSIGFPEWhenSignalCodeIs0) - { - sigact.sa_handler = (void *)_SignalHandlerForSIGFPEWhenSignalCodeIs0; - sigact.sa_flags = SA_RESTART | SA_SIGINFO; - sigemptyset(&sigact.sa_mask); - sigaction(SIGFPE, &sigact, (struct sigaction *)NULL); - } -#endif - break; - } - - default: - { - /* Unknown handler type */ - gcmTRACE( - gcvLEVEL_ERROR, - "%s(%d): Cannot register a signal handler for type 0x%0x", - __FUNCTION__, __LINE__, SignalHandlerType - ); - break; - } - - } - gcmFOOTER(); - return status; -} - -gceSTATUS -gcoOS_QueryCurrentProcessName( - OUT gctSTRING Name, - IN gctSIZE_T Size - ) -{ - gctFILE fHandle = 0; - gctUINT offset = 0; - gctSIZE_T bytesRead = 0; - char procEntryName[gcdMAX_PATH]; - gceSTATUS status = gcvSTATUS_OK; - - gctHANDLE Pid = gcoOS_GetCurrentProcessID(); - - gcmHEADER_ARG("Name=%s Pid=%d", Name, Pid); - - if (!Name || Size <= 0) - { - gcmONERROR(gcvSTATUS_INVALID_ARGUMENT); - } - - /* Construct the proc cmdline entry */ - gcmONERROR(gcoOS_PrintStrSafe(procEntryName, - gcdMAX_PATH, - &offset, - "/proc/%d/cmdline", - (int) (gctUINTPTR_T) Pid)); - - /* Open the procfs entry */ - gcmONERROR(gcoOS_Open(gcvNULL, - procEntryName, - gcvFILE_READ, - &fHandle)); - - - gcmONERROR(gcoOS_Read(gcvNULL, - fHandle, - Size - 1, - Name, - &bytesRead)); - - Name[bytesRead] = '\0'; - -OnError: - if (fHandle) - { - gcoOS_Close(gcvNULL, fHandle); - } - - /* Return the status. */ - gcmFOOTER(); - return status; -} - -/******************************************************************************* -** -** gcoOS_DetectProcessByName -** -** Detect if the current process is the executable specified. -** -** INPUT: -** -** gctCONST_STRING Name -** Name (full or partial) of executable. -** -** OUTPUT: -** -** Nothing. -** -** -** RETURN: -** -** gcvSTATUS_TRUE -** if process is as specified by Name parameter. -** gcvSTATUS_FALSE -** Otherwise. -** -*/ -gceSTATUS -gcoOS_DetectProcessByName( - IN gctCONST_STRING Name - ) -{ - gctCHAR curProcessName[gcdMAX_PATH]; - gceSTATUS status = gcvSTATUS_FALSE; - - gcmHEADER_ARG("Name=%s", Name); - - if (gcmIS_SUCCESS(gcoOS_QueryCurrentProcessName(curProcessName, gcdMAX_PATH)) && - (gcoOS_StrStr(curProcessName, Name, gcvNULL) == gcvSTATUS_TRUE) - ) - { - status = gcvSTATUS_TRUE; - } - - gcmFOOTER(); - return status; -} - -gceSTATUS -gcoOS_DetectProcessByEncryptedName( - IN gctCONST_STRING Name - ) -{ - gceSTATUS status = gcvSTATUS_FALSE; - gctCHAR *p, buff[gcdMAX_PATH]; - p = buff; - - gcmONERROR(gcoOS_StrCopySafe(buff, gcdMAX_PATH, Name)); - - while (*p) - { - *p = ~(*p); - p++; - } - - status = gcoOS_DetectProcessByName(buff); - -OnError: - return status; -} - -#if defined(ANDROID) -static gceSTATUS -ParseSymbol( - IN gctCONST_STRING Library, - IN gcsSYMBOLSLIST_PTR Symbols - ) -{ - gceSTATUS status = gcvSTATUS_FALSE; - int fp; - Elf32_Ehdr ehdr; - Elf32_Shdr shdr; - Elf32_Sym sym; - char secNameTab[2048]; - char *symNameTab = gcvNULL; - int i = 0, j = 0, size_dynsym = 0, match = 0; - unsigned int offset_dynsym = 0, offset_dynstr = 0, size_dynstr = 0; - - fp = open(Library, O_RDONLY); - if (fp == -1) - return gcvSTATUS_FALSE; - - if (read(fp, &ehdr, sizeof(Elf32_Ehdr)) == 0) - { - close(fp); - return gcvSTATUS_FALSE; - } - - if (ehdr.e_type != ET_DYN) - { - close(fp); - return gcvSTATUS_FALSE; - } - - if (lseek(fp, 0, SEEK_END) > 1024 * 1024 * 10) - { - close(fp); - return gcvSTATUS_SKIP; - } - - lseek(fp, ehdr.e_shoff + ehdr.e_shstrndx * 40, SEEK_SET); - if (read(fp, &shdr, ehdr.e_shentsize) == 0) - { - close(fp); - return gcvSTATUS_FALSE; - } - - lseek(fp, (unsigned int)shdr.sh_offset, SEEK_SET); - if (read(fp, secNameTab, shdr.sh_size) == 0) - { - close(fp); - return gcvSTATUS_FALSE; - } - - lseek(fp, ehdr.e_shoff, SEEK_SET); - for (i = 0; i < ehdr.e_shnum; i++) - { - if (read(fp, &shdr, (ssize_t)ehdr.e_shentsize) == 0) - { - close(fp); - return gcvSTATUS_FALSE; - } - - if (strcmp(secNameTab + shdr.sh_name, ".dynsym") == 0) - { - offset_dynsym = (unsigned int)shdr.sh_offset; - size_dynsym = (int)(shdr.sh_size / shdr.sh_entsize); - } - else if(strcmp(secNameTab + shdr.sh_name, ".dynstr") == 0) - { - offset_dynstr = (unsigned int)shdr.sh_offset; - size_dynstr = (unsigned int)shdr.sh_size; - } - } - - if (size_dynstr == 0) - { - close(fp); - return gcvSTATUS_FALSE; - } - else - symNameTab = (char *)malloc(size_dynstr); - - if ((lseek(fp, (off_t)offset_dynstr, SEEK_SET) != (off_t)offset_dynstr) || (offset_dynstr == 0)) - { - free(symNameTab); - symNameTab = gcvNULL; - close(fp); - return gcvSTATUS_FALSE; - } - if (read(fp, symNameTab, (size_t)(size_dynstr)) == 0) - { - free(symNameTab); - symNameTab = gcvNULL; - close(fp); - return gcvSTATUS_FALSE; - } - - if (size_dynsym > 8 * 1000) - { - free(symNameTab); - symNameTab = gcvNULL; - close(fp); - return gcvSTATUS_MISMATCH; - } - - lseek(fp, (off_t)offset_dynsym, SEEK_SET); - for (i = 0; i < size_dynsym; i ++) - { - if (read(fp, &sym, (size_t)16) > 0) - { - for (j = 0; j < 10 && Symbols->symList[j]; j ++ ) - { - gctCHAR *p, buffers[1024]; - p = buffers; - buffers[0]='\0'; - strcat(buffers, Symbols->symList[j]); - - while (*p) - { - *p = ~(*p); - p++; - } - - if (strcmp(symNameTab + sym.st_name, buffers) == 0) - match++; - } - - if (match >= j) - { - free(symNameTab); - symNameTab = gcvNULL; - close(fp); - return gcvSTATUS_TRUE; - } - } - else - { - status = gcvSTATUS_FALSE; - break; - } - } - - if (symNameTab != gcvNULL) - { - free(symNameTab); - symNameTab = gcvNULL; - } - - close(fp); - - if (gcmIS_ERROR(status)) - { - status = gcvSTATUS_FALSE; - } - return status; -} - -gceSTATUS -gcoOS_DetectProgrameByEncryptedSymbols( - IN gcsSYMBOLSLIST_PTR Symbols - ) -{ - gceSTATUS status = gcvSTATUS_FALSE; - - /* Detect shared library path. */ - char path[256] = "/data/data/"; - char * s = NULL, * f = NULL; - ssize_t size; - - s = path + strlen(path); - - /* Open cmdline file. */ - int fd = open("/proc/self/cmdline", O_RDONLY); - - if (fd < 0) - { - gcmPRINT("open /proc/self/cmdline failed"); - return gcvSTATUS_FALSE; - } - - /* Connect cmdline string to path. */ - size = read(fd, s, 64); - close(fd); - - if (size < 0) - { - gcmPRINT("read /proc/self/cmdline failed"); - return gcvSTATUS_FALSE; - } - - s[size] = '\0'; - - f = strstr(s, ":"); - size = (f != NULL) ? (f - s) : size; - - s[size] = '\0'; - - /* Connect /lib. */ - strcat(path, "/lib"); - - /* Open shared library path. */ - DIR * dir = opendir(path); - - if (!dir) - { - return gcvSTATUS_FALSE; - } - - //const char * found = NULL; - struct dirent * dp; - int count = 0; - - while ((dp = readdir(dir)) != NULL) - { - if (dp->d_type == DT_REG && ++count > 8) - { - status = gcvSTATUS_SKIP; - goto OnError; - } - } - rewinddir(dir); - - while ((dp = readdir(dir)) != NULL) - { - /* Only test regular file. */ - if (dp->d_type == DT_REG) - { - char buf[256]; - - snprintf(buf, 256, "%s/%s", path, dp->d_name); - - gcmONERROR(ParseSymbol(buf, Symbols)); - - if (status == gcvSTATUS_MISMATCH) - continue; - else if (status) - break; - } - } - -OnError: - - closedir(dir); - - if (gcmIS_ERROR(status)) - { - status = gcvSTATUS_FALSE; - } - - return status; -} -#endif - -#if defined(ANDROID) -#include -#else -int sync_wait(int fd, int timeout) -{ - struct pollfd fds; - int ret; - - if (fd < 0) { - errno = EINVAL; - return -1; - } - - fds.fd = fd; - fds.events = POLLIN; - - do { - ret = poll(&fds, 1, timeout); - if (ret > 0) { - if (fds.revents & (POLLERR | POLLNVAL)) { - errno = EINVAL; - return -1; - } - return 0; - } else if (ret == 0) { - errno = ETIME; - return -1; - } - } while (ret == -1 && (errno == EINTR || errno == EAGAIN)); - - return ret; -} -#endif - -gceSTATUS -gcoOS_CreateNativeFence( - IN gcoOS Os, - IN gctSIGNAL Signal, - OUT gctINT * FenceFD - ) -{ - gceSTATUS status; - gcsHAL_INTERFACE iface; - - gcmHEADER_ARG("Os=0x%x Signal=%d", - Os, (gctUINT) (gctUINTPTR_T) Signal); - - /* Call kernel API to dup signal to native fence fd. */ - iface.ignoreTLS = gcvFALSE; - iface.command = gcvHAL_CREATE_NATIVE_FENCE; - iface.u.CreateNativeFence.signal = gcmPTR_TO_UINT64(Signal); - iface.u.CreateNativeFence.fenceFD = -1; - - gcmONERROR(gcoOS_DeviceControl( - gcvNULL, - IOCTL_GCHAL_INTERFACE, - &iface, gcmSIZEOF(iface), - &iface, gcmSIZEOF(iface) - )); - - /* Return fence fd. */ - *FenceFD = iface.u.CreateNativeFence.fenceFD; - - /* Success. */ - gcmFOOTER_ARG("*FenceFD=%d", iface.u.CreateNativeFence.fenceFD); - return gcvSTATUS_OK; - -OnError: - *FenceFD = -1; - - /* Return the status. */ - gcmFOOTER(); - return status; -} - -gceSTATUS -gcoOS_ClientWaitNativeFence( - IN gcoOS Os, - IN gctINT FenceFD, - IN gctUINT32 Timeout - ) -{ - int err; - int wait; - gceSTATUS status; - - gcmASSERT(FenceFD != -1); - gcmHEADER_ARG("Os=0x%x FenceFD=%d Timeout=%d", Os, FenceFD, Timeout); - - wait = (Timeout == gcvINFINITE) ? -1 - : (int) Timeout; - - /* err = ioctl(FenceFD, SYNC_IOC_WAIT, &wait); */ - err = sync_wait(FenceFD, wait); - - switch (err) - { - case 0: - status = gcvSTATUS_OK; - break; - - case -1: - /* - * libc ioctl: - * On error, -1 is returned, and errno is set appropriately. - * 'errno' is positive. - */ - if (errno == ETIME) - { - status = gcvSTATUS_TIMEOUT; - break; - } - - default: - status = gcvSTATUS_GENERIC_IO; - break; - } - - gcmFOOTER_ARG("status=%d", status); - return status; -} - -gceSTATUS -gcoOS_WaitNativeFence( - IN gcoOS Os, - IN gctINT FenceFD, - IN gctUINT32 Timeout - ) -{ - gceSTATUS status; - gcsHAL_INTERFACE iface; - - gcmASSERT(FenceFD != -1); - gcmHEADER_ARG("Os=0x%x FenceFD=%d Timeout=%d", Os, FenceFD, Timeout); - - /* Call kernel API to dup signal to native fence fd. */ - iface.ignoreTLS = gcvFALSE; - iface.command = gcvHAL_WAIT_NATIVE_FENCE; - iface.u.WaitNativeFence.fenceFD = FenceFD; - iface.u.WaitNativeFence.timeout = Timeout; - - gcmONERROR(gcoOS_DeviceControl( - gcvNULL, - IOCTL_GCHAL_INTERFACE, - &iface, gcmSIZEOF(iface), - &iface, gcmSIZEOF(iface) - )); - -OnError: - gcmFOOTER_ARG("status=%d", status); - return status; -} - -gceSTATUS -gcoOS_CPUPhysicalToGPUPhysical( - IN gctPHYS_ADDR_T CPUPhysical, - OUT gctPHYS_ADDR_T * GPUPhysical - ) -{ - gcoOS os = gcPLS.os; - gcoPLATFORM platform; - - gcmHEADER(); - gcmVERIFY_ARGUMENT(os); - - platform = &os->platform; - - if (platform->ops->getGPUPhysical) - { - platform->ops->getGPUPhysical(platform, CPUPhysical, GPUPhysical); - } - else - { - *GPUPhysical = CPUPhysical; - } - - gcmFOOTER_NO(); - return gcvSTATUS_OK; -} - -void -gcoOS_RecordAllocation(void) -{ -#if VIVANTE_PROFILER_SYSTEM_MEMORY - -#if gcdGC355_MEM_PRINT - gcoOS os; - if (gcPLS.os != gcvNULL) - { - os = gcPLS.os; - - os->oneSize = 0; - os->oneRecording = 1; - } -#endif - -#endif -} - -gctINT32 -gcoOS_EndRecordAllocation(void) -{ - gctINT32 result = 0; -#if VIVANTE_PROFILER_SYSTEM_MEMORY - -#if gcdGC355_MEM_PRINT - gcoOS os; - - if (gcPLS.os != gcvNULL) - { - os = gcPLS.os; - - if (os->oneRecording == 1) - { - result = os->oneSize; - - os->oneSize = 0; - os->oneRecording = 0; - } - } - -#endif - -#endif - return result; -} - -void -gcoOS_AddRecordAllocation(gctSIZE_T Size) -{ -#if VIVANTE_PROFILER_SYSTEM_MEMORY - -#if gcdGC355_MEM_PRINT - gcoOS os; - - if (gcPLS.os != gcvNULL) - { - os = gcPLS.os; - - if (os->oneRecording == 1) - { - os->oneSize += (gctINT32)Size; - } - } -#endif - -#endif -} - -gceSTATUS -gcoOS_QuerySystemInfo( - IN gcoOS Os, - OUT gcsSystemInfo *Info - ) -{ - /* SH cycles = MC cycles * (SH clock/MC clock). - ** Default value is 128 * 3 (cycles). - */ - Info->memoryLatencySH = 128 * 3; - - return gcvSTATUS_OK; -} - -/*** memory profile ***/ -#if VIVANTE_PROFILER_SYSTEM_MEMORY - -gceSTATUS gcoOS_GetMemoryProfileInfo(size_t size, - struct _memory_profile_info *info) -{ - gceSTATUS status = gcvSTATUS_OK; - if (size != gcmSIZEOF(struct _memory_profile_info)) - { - gcmONERROR(gcvSTATUS_INVALID_ARGUMENT); - } - if (gcPLS.bMemoryProfile && gcPLS.profileLock) - { - struct _memory_profile_info mem_info = { {0}, {0} }; - - if (gcPLS.os) { /* video memory */ - gcsHAL_INTERFACE iface; - - gcoOS_ZeroMemory(&iface, gcmSIZEOF(iface)); - - iface.command = gcvHAL_DATABASE; - iface.u.Database.processID = gcmPTR2INT32(gcoOS_GetCurrentProcessID()); - iface.u.Database.validProcessID = gcvTRUE; - - /* Call kernel service. */ - gcmONERROR(gcoOS_DeviceControl( - gcvNULL, - IOCTL_GCHAL_INTERFACE, - &iface, gcmSIZEOF(iface), - &iface, gcmSIZEOF(iface) - )); - - mem_info.gpu_memory.currentSize = iface.u.Database.vidMem.counters.bytes + iface.u.Database.nonPaged.counters.bytes; - mem_info.gpu_memory.peakSize = iface.u.Database.vidMem.counters.maxBytes + iface.u.Database.nonPaged.counters.maxBytes; - mem_info.gpu_memory.total_allocate = iface.u.Database.vidMem.counters.totalBytes + iface.u.Database.nonPaged.counters.totalBytes; - mem_info.gpu_memory.total_free = 0; - mem_info.gpu_memory.total_allocateCount = iface.u.Database.vidMem.counters.allocCount + iface.u.Database.nonPaged.counters.allocCount; - mem_info.gpu_memory.total_freeCount = iface.u.Database.vidMem.counters.freeCount + iface.u.Database.nonPaged.counters.freeCount; - } - else - { - mem_info.gpu_memory.currentSize = gcPLS.video_currentSize; - mem_info.gpu_memory.peakSize = gcPLS.video_maxAllocSize; - mem_info.gpu_memory.total_allocate = gcPLS.video_allocSize; - mem_info.gpu_memory.total_allocateCount = gcPLS.video_allocCount; - mem_info.gpu_memory.total_free = gcPLS.video_freeSize; - mem_info.gpu_memory.total_freeCount = gcPLS.video_freeCount; - } - - /* os memory */ - gcmONERROR(gcoOS_AcquireMutex(gcPLS.os, gcPLS.profileLock, gcvINFINITE)); - - mem_info.system_memory.peakSize = gcPLS.maxAllocSize; - mem_info.system_memory.total_allocate = gcPLS.allocSize; - mem_info.system_memory.total_free = gcPLS.freeSize; - mem_info.system_memory.currentSize = gcPLS.currentSize; - mem_info.system_memory.total_allocateCount = gcPLS.allocCount; - mem_info.system_memory.total_freeCount = gcPLS.freeCount; - - gcmONERROR(gcoOS_ReleaseMutex(gcPLS.os, gcPLS.profileLock)); - - gcoOS_MemCopy(info, &mem_info, gcmSIZEOF(mem_info)); - return gcvSTATUS_OK; - } -OnError: - return status; -} - -gceSTATUS gcoOS_DumpMemoryProfile(void) -{ - if (gcPLS.bMemoryProfile) - { - struct _memory_profile_info info; - gcmVERIFY_OK(gcoOS_GetMemoryProfileInfo(gcmSIZEOF(info), &info)); - - gcmPRINT("*************** Memory Profile Info Dump ****************\n"); - gcmPRINT("system memory:\n"); - gcmPRINT(" current allocation : %lld\n", (long long)info.system_memory.currentSize); - gcmPRINT(" maximum allocation : %lld\n", (long long)info.system_memory.peakSize); - gcmPRINT(" total allocation : %lld\n", (long long)info.system_memory.total_allocate); - gcmPRINT(" total free : %lld\n", (long long)info.system_memory.total_free); - gcmPRINT(" allocation count : %u\n", info.system_memory.total_allocateCount); - gcmPRINT(" free count : %u\n", info.system_memory.total_freeCount); - gcmPRINT("\n"); - gcmPRINT("gpu memory:\n"); - gcmPRINT(" current allocation : %lld\n", (long long)info.gpu_memory.currentSize); - gcmPRINT(" maximum allocation : %lld\n", (long long)info.gpu_memory.peakSize); - gcmPRINT(" total allocation : %lld\n", (long long)info.gpu_memory.total_allocate); - gcmPRINT(" allocation count : %u\n", info.gpu_memory.total_allocateCount); - gcmPRINT(" free count : %u\n", info.gpu_memory.total_freeCount); - gcmPRINT("************ end of Memory Profile Info Dump ************\n"); - } - return gcvSTATUS_OK; -} - -gceSTATUS gcoOS_InitMemoryProfile(void) -{ - gctSTRING str = gcvNULL; - gcoOS_GetEnv(gcPLS.os, "VIV_MEMORY_PROFILE", &str); - gcmVERIFY_OK(gcoOS_CreateMutex(gcPLS.os, &gcPLS.profileLock)); - if (str != gcvNULL && 0 != atoi(str)) - { - gcPLS.bMemoryProfile = gcvTRUE; - } - - return gcvSTATUS_OK; -} - -gceSTATUS gcoOS_DeInitMemoryProfile(void) -{ - gcmVERIFY_OK(gcoOS_DumpMemoryProfile()); - gcPLS.bMemoryProfile = gcvFALSE; - gcmVERIFY_OK(gcoOS_DeleteMutex(gcPLS.os, gcPLS.profileLock)); - gcPLS.profileLock = gcvNULL; - - return gcvSTATUS_OK; -} - -#endif diff --git a/drivers/amlogic/npu/os/linux/user/gc_hal_user_os_atomic.h b/drivers/amlogic/npu/os/linux/user/gc_hal_user_os_atomic.h deleted file mode 100644 index d0f077f..0000000 --- a/drivers/amlogic/npu/os/linux/user/gc_hal_user_os_atomic.h +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -* -* Copyright (c) 2005 - 2019 by Vivante Corp. All rights reserved. -* -* The material in this file is confidential and contains trade secrets -* of Vivante Corporation. This is proprietary information owned by -* Vivante Corporation. No part of this work may be disclosed, -* reproduced, copied, transmitted, or used in any way for any purpose, -* without the express written permission of Vivante Corporation. -* -*****************************************************************************/ - - -#ifndef __gc_hal_user_os_atomic_h_ -#define __gc_hal_user_os_atomic_h_ - -/* -** GCC supports sync_* built-in functions since 4.1.2 -** For those gcc variation whose verion is newer than 4.1.2 but -** still doesn't support sync_*, build driver with -** gcdBUILTIN_ATOMIC_FUNCTIONS = 0 to override version check. -*/ -#ifndef gcdBUILTIN_ATOMIC_FUNCTIONS -#if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__ >= 40102) -#define gcdBUILTIN_ATOMIC_FUNCTIONS 1 -#else -#define gcdBUILTIN_ATOMIC_FUNCTIONS 0 -#endif -#endif - -#if !gcdBUILTIN_ATOMIC_FUNCTIONS -#include -#endif - -struct gcsATOM -{ - /* Counter. */ - gctINT32 counter; - -#if !gcdBUILTIN_ATOMIC_FUNCTIONS - /* Mutex. */ - pthread_mutex_t mutex; -#endif -}; - -#if !gcdBUILTIN_ATOMIC_FUNCTIONS -#define gcmATOM_INITIALIZER \ - { \ - 0, \ - PTHREAD_MUTEX_INITIALIZER \ - }; -#else -#define gcmATOM_INITIALIZER \ - { \ - 0 \ - }; -#endif - -#endif diff --git a/drivers/amlogic/npu/os/linux/user/gc_hal_user_os_memory.h b/drivers/amlogic/npu/os/linux/user/gc_hal_user_os_memory.h deleted file mode 100644 index 7f9f073..0000000 --- a/drivers/amlogic/npu/os/linux/user/gc_hal_user_os_memory.h +++ /dev/null @@ -1,146 +0,0 @@ -/**************************************************************************** -* -* Copyright (c) 2005 - 2019 by Vivante Corp. All rights reserved. -* -* The material in this file is confidential and contains trade secrets -* of Vivante Corporation. This is proprietary information owned by -* Vivante Corporation. No part of this work may be disclosed, -* reproduced, copied, transmitted, or used in any way for any purpose, -* without the express written permission of Vivante Corporation. -* -*****************************************************************************/ - - -#ifndef __gc_hal_user_os_memory_h_ -#define __gc_hal_user_os_memory_h_ - -#ifndef _ISOC99_SOURCE -#define _ISOC99_SOURCE -#endif - -#include - -/* Fill the specified memory with 0's. */ -static gcmINLINE void -gcoOS_ZeroMemory( - IN gctPOINTER Memory, - IN gctSIZE_T Bytes - ) -{ - /* Verify the arguments. */ - gcmASSERT(Memory != gcvNULL); - gcmASSERT(Bytes > 0); - - /* Zero the memory. */ - memset(Memory, 0, Bytes); -} - -static gcmINLINE void -gcoOS_MemCopyFast( - IN gctPOINTER Destination, - IN gctCONST_POINTER Source, - IN gctSIZE_T Bytes - ) -{ - /* Verify the arguments. */ - gcmASSERT(Destination != gcvNULL); - gcmASSERT(Source != gcvNULL); - gcmASSERT(Bytes > 0); - - if ((Bytes > 4096) - && ((gctSIZE_T)Destination & 0xf) - && ((gctSIZE_T)Source & 0xf)) - { - gctUINT8 *srcAddr = (gctUINT8*)Destination; - gctUINT8 *dstAddr = (gctUINT8*)Source; - gctSIZE_T origDst = (gctSIZE_T)Destination; - gctSIZE_T size = 0; - - size = (gctSIZE_T)(((origDst + 0xf) & ~0xf) - origDst); - srcAddr += size; - dstAddr += size; - - memcpy(Destination, Source, size); - memcpy(dstAddr, srcAddr, Bytes-size); - } - else - { - memcpy(Destination, Source, Bytes); - } -} - -/* Perform a memory copy. */ -static gcmINLINE void -gcoOS_MemCopy( - IN gctPOINTER Destination, - IN gctCONST_POINTER Source, - IN gctSIZE_T Bytes - ) -{ - /* Verify the arguments. */ - gcmASSERT(Destination != gcvNULL); - gcmASSERT(Source != gcvNULL); - gcmASSERT(Bytes > 0); - gcmASSERT((Destination >= Source && (gctCHAR*)Source + Bytes <= (gctCHAR*)Destination) || - (Source > Destination && (gctCHAR*)Destination + Bytes <= (gctCHAR*)Source)); - - /* Copy the memory. */ - memcpy(Destination, Source, Bytes); -} - -/* Perform a memory move. */ -static gcmINLINE void -gcoOS_MemMove( - IN gctPOINTER Destination, - IN gctCONST_POINTER Source, - IN gctSIZE_T Bytes - ) -{ - /* Verify the arguments. */ - gcmASSERT(Destination != gcvNULL); - gcmASSERT(Source != gcvNULL); - gcmASSERT(Bytes > 0); - - /* Move the memory. */ - memmove(Destination, Source, Bytes); -} - -/* Perform a memory fill. */ -static gcmINLINE void -gcoOS_MemFill( - IN gctPOINTER Memory, - IN gctUINT8 Filler, - IN gctSIZE_T Bytes - ) -{ - /* Verify the arguments. */ - gcmASSERT(Memory != gcvNULL); - gcmASSERT(Bytes > 0); - - /* Fill the memory. */ - memset(Memory, Filler, Bytes); -} - -static gcmINLINE gctSIZE_T -gcoOS_StrLen( - IN gctCONST_STRING String, - OUT gctSIZE_T * Length - ) -{ - gctSIZE_T len; - - /* Verify the arguments. */ - gcmASSERT(String != gcvNULL); - - /* Get the length of the string. */ - len = (gctSIZE_T) strlen(String); - if (Length) - { - *Length = len; - } - - return len; -} - -#endif - diff --git a/drivers/amlogic/npu/os/linux/user/gc_hal_user_platform.h b/drivers/amlogic/npu/os/linux/user/gc_hal_user_platform.h deleted file mode 100644 index 802f742..0000000 --- a/drivers/amlogic/npu/os/linux/user/gc_hal_user_platform.h +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -* -* Copyright (c) 2005 - 2019 by Vivante Corp. All rights reserved. -* -* The material in this file is confidential and contains trade secrets -* of Vivante Corporation. This is proprietary information owned by -* Vivante Corporation. No part of this work may be disclosed, -* reproduced, copied, transmitted, or used in any way for any purpose, -* without the express written permission of Vivante Corporation. -* -*****************************************************************************/ - - -#ifndef _gc_hal_user_platform_h_ -#define _gc_hal_user_platform_h_ - -typedef struct _gcsPLATFORM * gcoPLATFORM; - -typedef struct _gcsPLATFORM_OPERATIONS -{ - /******************************************************************************* - ** - ** getGPUPhysical - ** - ** Convert CPU physical address to GPU physical address if they are - ** different. - */ - gceSTATUS - (*getGPUPhysical)( - IN gcoPLATFORM Platform, - IN gctPHYS_ADDR_T CPUPhysical, - OUT gctPHYS_ADDR_T * GPUPhysical - ); - - /******************************************************************************* - ** - ** getGPUPhysical - ** - ** Convert GPU physical address to CPU physical address if they are - ** different. - */ - gceSTATUS - (*getCPUPhysical)( - IN gcoPLATFORM Platform, - IN gctPHYS_ADDR_T GPUPhysical, - OUT gctPHYS_ADDR_T * CPUPhysical - ); -} -gcsPLATFORM_OPERATIONS; - -typedef struct _gcsPLATFORM -{ - gcsPLATFORM_OPERATIONS* ops; -} -gcsPLATFORM; - -void -gcoPLATFORM_QueryOperations( - IN gcsPLATFORM_OPERATIONS ** Operations - ); -#endif diff --git a/drivers/amlogic/npu/os/linux/user/makefile.linux b/drivers/amlogic/npu/os/linux/user/makefile.linux deleted file mode 100644 index 86e20b5..0000000 --- a/drivers/amlogic/npu/os/linux/user/makefile.linux +++ /dev/null @@ -1,109 +0,0 @@ -############################################################################## -# -# Copyright (c) 2005 - 2019 by Vivante Corp. All rights reserved. -# -# The material in this file is confidential and contains trade secrets -# of Vivante Corporation. This is proprietary information owned by -# Vivante Corporation. No part of this work may be disclosed, -# reproduced, copied, transmitted, or used in any way for any purpose, -# without the express written permission of Vivante Corporation. -# -############################################################################## - - -# -# Linux build file for user HAL layer. -# - -################################################################################ -# Include common definitions. - -include $(AQROOT)/makefile.linux.def - -################################################################################ -# Define target module name. - -STATIC := 1 -TARGET_NAME := libhalosuser.a -TARGET_MODULE := $(OBJ_DIR)/$(TARGET_NAME) - -################################################################################ -# Installation directory. - -INSTALL_DIR := $(SDK_DIR)/drivers - -################################################################################ -# Supply additional include directories. - -INCLUDE := -I$(AQROOT)/hal/inc \ - -I$(AQROOT)/hal/user \ - -I$(AQROOT)/hal/optimizer \ - -I$(AQROOT)/hal/os/linux/user \ - -I$(AQROOT)/compiler/libVSC/include - -CFLAGS += $(INCLUDE) - -################################################################################ -# Add extra flags for object files. - -ifneq ($(USE_ARMCC),1) - CFLAGS += -fPIC -Werror -ansi -endif - -################################################################################ -# Describe object files. - -platform_option := \ - $(firstword $(wildcard \ - platform/$(soc_vendor)/gc_hal_user_platform_$(soc_board).c \ - platform/default/gc_hal_user_platform_default.c)) - -platform_option_obj := $(patsubst %.c,%.o,$(notdir $(platform_option))) - -OBJECTS := $(OBJ_DIR)/gc_hal_user_debug.o \ - $(OBJ_DIR)/gc_hal_user_os.o \ - $(OBJ_DIR)/gc_hal_user_math.o \ - $(OBJ_DIR)/$(platform_option_obj) \ - -################################################################################ -# Define targets. - -.PHONY: all clean install - -all: $(TARGET_MODULE) - -clean: - @rm -rf $(OBJ_DIR) - -install: all - -ifeq ($(gcdSTATIC_LINK), 1) -install: - @mkdir -p $(INSTALL_DIR) - @-cp $(TARGET_MODULE) $(INSTALL_DIR) -endif - -################################################################################ -# Module rules. - -$(TARGET_MODULE): $(OBJECTS) - @echo " ARCHIVE \033[1m$(notdir $@)\033[0m" - @$(AR) -r -c $@ $(OBJECTS) -ifneq ($(USE_ARMCC), 1) - @$(RANLIB) $@ -endif - -################################################################################ -# Object rules. - -$(OBJ_DIR)/%.o: %.c - @echo " COMPILE $(abspath $<)" - @mkdir -p $(OBJ_DIR) - @$(CC) -c $(CFLAGS) -MMD -o $@ $< - -vpath %.c platform/default -vpath %.c platform/$(soc_vendor) - -# object dependencies. --include $(OBJECTS:.o=.d) - diff --git a/drivers/amlogic/npu/os/linux/user/platform/default/gc_hal_user_platform_default.c b/drivers/amlogic/npu/os/linux/user/platform/default/gc_hal_user_platform_default.c deleted file mode 100644 index 09fcb75..0000000 --- a/drivers/amlogic/npu/os/linux/user/platform/default/gc_hal_user_platform_default.c +++ /dev/null @@ -1,28 +0,0 @@ -/**************************************************************************** -* -* Copyright (c) 2005 - 2019 by Vivante Corp. All rights reserved. -* -* The material in this file is confidential and contains trade secrets -* of Vivante Corporation. This is proprietary information owned by -* Vivante Corporation. No part of this work may be disclosed, -* reproduced, copied, transmitted, or used in any way for any purpose, -* without the express written permission of Vivante Corporation. -* -*****************************************************************************/ - - -#include "gc_hal_user_linux.h" -#include "gc_hal_user_platform.h" - -gcsPLATFORM_OPERATIONS platformOperations = -{ -}; - -void -gcoPLATFORM_QueryOperations( - IN gcsPLATFORM_OPERATIONS ** Operations - ) -{ - *Operations = &platformOperations; -} - diff --git a/drivers/amlogic/npu/security/Android.mk b/drivers/amlogic/npu/security/Android.mk deleted file mode 100644 index 6348d4e..0000000 --- a/drivers/amlogic/npu/security/Android.mk +++ /dev/null @@ -1,47 +0,0 @@ -############################################################################## -# -# Copyright (c) 2005 - 2019 by Vivante Corp. All rights reserved. -# -# The material in this file is confidential and contains trade secrets -# of Vivante Corporation. This is proprietary information owned by -# Vivante Corporation. No part of this work may be disclosed, -# reproduced, copied, transmitted, or used in any way for any purpose, -# without the express written permission of Vivante Corporation. -# -############################################################################## - - -LOCAL_PATH := $(call my-dir) -include $(LOCAL_PATH)/../../Android.mk.def - -# -# galcore.ta -# -include $(CLEAR_VARS) -.PHONY: TABUILD - -GALCORE := \ - $(LOCAL_PATH)/../../driver/galcore.ta - -$(GALCORE): $(AQREG) TABUILD - @cd $(AQROOT)/hal/security/ - @$(MAKE) -C $(AQROOT)/hal/security/ \ - AQROOT=$(abspath $(AQROOT)) \ - AQARCH=$(abspath $(AQARCH)) \ - DEBUG=$(DEBUG) - -LOCAL_SRC_FILES := \ - ../../driver/galcore.ta - -LOCAL_GENERATED_SOURCES := \ - $(GALCORE) - -LOCAL_MODULE := galcore.ta -LOCAL_MODULE_TAGS := optional -LOCAL_MODULE_CLASS := SHARED_LIBRARIES -LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/modules -ifeq ($(PLATFORM_VENDOR),1) -LOCAL_VENDOR_MODULE:= true -endif -include $(BUILD_PREBUILT) - diff --git a/drivers/amlogic/npu/security/Makefile b/drivers/amlogic/npu/security/Makefile deleted file mode 100644 index 8232bfd..0000000 --- a/drivers/amlogic/npu/security/Makefile +++ /dev/null @@ -1,64 +0,0 @@ -############################################################################## -# -# Copyright (c) 2005 - 2019 by Vivante Corp. All rights reserved. -# -# The material in this file is confidential and contains trade secrets -# of Vivante Corporation. This is proprietary information owned by -# Vivante Corporation. No part of this work may be disclosed, -# reproduced, copied, transmitted, or used in any way for any purpose, -# without the express written permission of Vivante Corporation. -# -############################################################################## - - -TARGET = ../../driver/galcore.ta - -TEE_PATH := $(AQROOT)/../../vendor/marvell-sdk/tee - -INCLUDES := \ - $(AQROOT)/hal/inc \ - $(AQROOT)/hal/user \ - $(AQROOT)/compiler/libVSC/include \ - $(AQROOT)/hal/os/linux/user \ - $(AQARCH)/cmodel/inc \ - - -CFLAGS = -Wa, -O2 -nostdlib -fno-builtin -march=armv7-a -fno-short-enums -CFLAGS += $(addprefix -I, $(sort $(dir $(objs)))) -CFLAGS += -I. -I$(TEE_PATH)/include/ -I$(TEE_PATH)/tee/common/ -CFLAGS += -I$(TEE_PATH)/tee/internal_api/ -I$(TEE_PATH)/tee/mgr/ -CFLAGS += -fPIC -DCONFIG_SO -CFLAGS += -I$(AQROOT)/hal/inc -CFLAGS += -I$(AQROOT)/hal/user -CFLAGS += -I$(AQROOT)/compiler/libVSC/include -CFLAGS += -I$(AQROOT)/hal/os/linux/user -CFLAGS += -I$(AQARCH)/cmodel/inc - -PLATFORM_LIBS = -L $(shell dirname `$(CC) $(CFLAGS) -print-libgcc-file-name`) -lgcc - -CROSS_COMPILE = arm-marvell-eabi- -CC = $(CROSS_COMPILE)gcc -OBJDUMP = $(CROSS_COMPILE)objdump -OBJCOPY = $(CROSS_COMPILE)objcopy -LD = $(CROSS_COMPILE)ld -AR = $(CROSS_COMPILE)ar - -objs := gc_hal_ta.o \ - gc_hal_ta_command.o \ - gc_hal_ta_mmu.o \ - gc_hal_ta_hardware.o \ - os/linux/gc_hal_ta_linux.o \ - os/linux/gc_hal_ta_driver.o - -headers := os/linux/gc_hal_ta_linux.h - -all: $(TARGET) $(objs) - -%.o: %.c $(headers) - $(CC) -c $(CFLAGS) $< -o $@ - -$(TARGET): $(objs) - $(CC) $(CFLAGS) $(LDFLAGS) -shared -Wl,-soname,galcore.ta -o $@ $^ $(PLATFORM_LIBS) - -clean: - @rm -f $(TARGET) *.o diff --git a/drivers/amlogic/npu/security/gc_hal_ta.c b/drivers/amlogic/npu/security/gc_hal_ta.c deleted file mode 100644 index d54d96f..0000000 --- a/drivers/amlogic/npu/security/gc_hal_ta.c +++ /dev/null @@ -1,368 +0,0 @@ -/**************************************************************************** -* -* Copyright (c) 2005 - 2019 by Vivante Corp. All rights reserved. -* -* The material in this file is confidential and contains trade secrets -* of Vivante Corporation. This is proprietary information owned by -* Vivante Corporation. No part of this work may be disclosed, -* reproduced, copied, transmitted, or used in any way for any purpose, -* without the express written permission of Vivante Corporation. -* -*****************************************************************************/ - - -#include "gc_hal_types.h" -#include "gc_hal_base.h" -#include "gc_hal_security_interface.h" -#include "gc_hal_ta.h" -#include "gc_hal.h" - -void -_DumpCommand( - gctUINT32 * Buffer - ) -{ - gctUINT32 * buffer = Buffer; - int i = 0; - - for (i = 0; i < 10; i++) - { - printf("%08x %08x %08x %08x %08x %08x %08x %08x \n", - buffer[0], - buffer[1], - buffer[2], - buffer[3], - buffer[4], - buffer[5], - buffer[6], - buffer[7]); - buffer += 8; - } - - printf("====================================\n"); -} - -void -_DumpCommandRaw( - gctUINT32 * Buffer, - gctUINT32 Bytes - ) -{ - gctUINT32 * buffer = Buffer; - gctUINT32 row, left; - - row = Bytes / 8; - left = Bytes % 8; - int i = 0; - - for (i = 0; i < row; i++) - { - printf("%08x %08x %08x %08x %08x %08x %08x %08x\n ", - buffer[0], - buffer[1], - buffer[2], - buffer[3], - buffer[4], - buffer[5], - buffer[6], - buffer[7]); - buffer += 8; - } - - for (i = 0; i < left; i++) - { - printf("%08X "); - } - - if (left) - { - printf("\n"); - } - - gcmkPRINT("====================================\n"); -} - - - - -gctUINT8_PTR -_Handle2Logical( - gctUINT32 Handle - ) -{ - gcTA_NODE node = (gcTA_NODE) Handle; - - return node->logical; -} - -gctUINT32 -_Logical2Handle( - gctPOINTER Logical - ) -{ - return (gctUINT32)Logical; -} - -/******************************************************************************* -** -** gcTA_Construct -** -** Construct a new gcTA object. -*/ -int -gcTA_Construct( - IN gctaOS Os, - OUT gcTA *TA - ) -{ - gceSTATUS status; - gctPOINTER pointer; - gcTA ta; - - /* Construct a gcTA object. */ - gcmkONERROR(gctaOS_Allocate(sizeof(struct _gcTA), &pointer)); - - ta = (gcTA)pointer; - - ta->os = Os; - - /* Hardware. */ - gcmkONERROR(gctaHARDWARE_Construct(ta, &ta->hardware)); - - /* MMU. */ - /* Maybe passed with a global mmu later. */ - gcmkONERROR(gctaMMU_Construct(ta, &ta->mmu)); - - /* Command. */ - gcmkONERROR(gctaCOMMAND_Construct(ta, &ta->command)); - - /* Parser. */ - gcmkONERROR(gctaPARSER_Construct(ta, &ta->parser)); - - status = gctaMMU_FlatMapping2G(ta->mmu); - - *TA = ta; - - return 0; - -OnError: - return status; -} - -/******************************************************************************* -** -** gcTA_Construct -** -** Destroy a gcTA object. -*/ -int -gcTA_Destroy( - IN gcTA TA - ) -{ - - /* Destroy. */ - return 0; -} - -gceSTATUS -gcTA_AllocateSecurityMemory( - IN gcTA TA, - IN gctUINT32 Bytes, - OUT gctUINT32 * Handle - ) -{ - gceSTATUS status; - gctPOINTER logical; - gctUINT32 physical; - gcTA_NODE node = gcvNULL; - - gcmkONERROR( - gctaOS_Allocate(gcmSIZEOF(*node), (gctPOINTER *)&node)); - - node->bytes = Bytes; - node->type = gcvTA_USER_COMMAND; - - gcmkONERROR( - gctaOS_AllocateSecurityMemory(TA->os, &node->bytes, &logical, &physical)); - - node->logical = logical; - node->physical = physical; - - *Handle = _Logical2Handle(node); - - return gcvSTATUS_OK; - -OnError: - return status; -} - -/* -* Map a scatter gather list into gpu address space. -* -*/ -gceSTATUS -gcTA_MapMemory ( - IN gcTA TA, - IN gctUINT32 *PhysicalArray, - IN gctUINT32 PageCount, - OUT gctUINT32 *GPUAddress - ) -{ - gceSTATUS status; - gcTA_MMU mmu; - gctUINT32 pageCount = PageCount; - gctUINT32 i; - gctUINT32 gpuAddress; - gctBOOL allocated = gcvFALSE; - gctBOOL secure = gcvFALSE; - - mmu = TA->mmu; - - for (i = 0; i < pageCount; i++) - { - gctUINT32 physical = PhysicalArray[i]; - - gcmkVERIFY_OK(gctaOS_IsPhysicalSecure(TA->os, physical, &secure)); - - if (secure) - { - break; - } - } - - - /* Reserve space. */ - gcmkONERROR(gctaMMU_AllocatePages( - mmu, - pageCount, - &gpuAddress - )); - - *GPUAddress = gpuAddress; - - allocated = gcvTRUE; - - /* Fill in page table. */ - for (i = 0; i < pageCount; i++) - { - gctUINT32 physical = PhysicalArray[i]; - gctUINT32_PTR entry; - - gcmkONERROR(gctaMMU_GetPageEntry(mmu, gpuAddress, &entry)); - - gctaMMU_SetPage(mmu, physical, secure, entry); - - gpuAddress += 4096; - } - - return gcvSTATUS_OK; - -OnError: - if (allocated == gcvTRUE) - { - gctaMMU_FreePages(mmu, gpuAddress, pageCount); - } - - return status; -} - -gceSTATUS -gcTA_UnmapMemory ( - IN gcTA TA, - IN gctUINT32 GPUAddress, - IN gctUINT32 PageCount - ) -{ - gctaMMU_FreePages(TA->mmu, GPUAddress, PageCount); - return gcvSTATUS_OK; -} - -int -gcTA_Dispatch( - IN gcTA TA, - IN gcsTA_INTERFACE * Interface - ) -{ - int command = Interface->command; - - gceSTATUS status = gcvSTATUS_OK; - - switch (command) - { - case KERNEL_START_COMMAND: - status = gctaCOMMAND_Start(TA->command); - - if (status == gcvSTATUS_OK && !TA->mmuEnabled) - { - status = gctaMMU_Enable(TA->mmu, TA); - TA->mmuEnabled = gcvTRUE; - } - - break; - - case KERNEL_ALLOCATE_SECRUE_MEMORY: - status = gcTA_AllocateSecurityMemory( - TA, - Interface->u.AllocateSecurityMemory.bytes, - &Interface->u.AllocateSecurityMemory.memory_handle - ); - break; - - case KERNEL_EXECUTE: - if (TA->mmu->pageTableChanged || 1) - { - gctUINT32 flushMmu[10 * 4]; - gctUINT32 bytes = 10 * 4; - - gctaHARDWARE_FlushMMU(gcvNULL, flushMmu, &bytes); - - status = gctaCOMMAND_Commit( - TA->command, - (gctUINT8_PTR)flushMmu, - bytes - ); - - TA->mmu->pageTableChanged = gcvFALSE; - } - - status = gctaCOMMAND_Commit( - TA->command, - (gctUINT8_PTR)Interface->u.Execute.command_buffer, - Interface->u.Execute.command_buffer_length - ); - - break; - - case KERNEL_MAP_MEMORY: - status = gcTA_MapMemory( - TA, - Interface->u.MapMemory.physicals, - Interface->u.MapMemory.pageCount, - &Interface->u.MapMemory.gpuAddress - ); - - break; - - case KERNEL_UNMAP_MEMORY: - status = gcTA_UnmapMemory( - TA, - Interface->u.UnmapMemory.gpuAddress, - Interface->u.UnmapMemory.pageCount - ); - break; - - default: - gcmkASSERT(0); - - status = gcvSTATUS_INVALID_ARGUMENT; - break; - } - - Interface->result = status; - - return 0; -} - - - diff --git a/drivers/amlogic/npu/security/gc_hal_ta.h b/drivers/amlogic/npu/security/gc_hal_ta.h deleted file mode 100644 index 2d0fb5e..0000000 --- a/drivers/amlogic/npu/security/gc_hal_ta.h +++ /dev/null @@ -1,472 +0,0 @@ -/**************************************************************************** -* -* Copyright (c) 2005 - 2019 by Vivante Corp. All rights reserved. -* -* The material in this file is confidential and contains trade secrets -* of Vivante Corporation. This is proprietary information owned by -* Vivante Corporation. No part of this work may be disclosed, -* reproduced, copied, transmitted, or used in any way for any purpose, -* without the express written permission of Vivante Corporation. -* -*****************************************************************************/ - - -#ifndef _GC_HAL_TA_H_ -#define _GC_HAL_TA_H_ -#include "gc_hal_types.h" -#include "gc_hal_security_interface.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -typedef struct _gctaOS * gctaOS; - -typedef struct _gcTA_COMMAND * gcTA_COMMAND; -typedef struct _gcTA_PARSER * gcTA_PARSER; -typedef struct _gcTA_HARDWARE * gcTA_HARDWARE; -typedef struct _gcTA_MMU * gcTA_MMU; -typedef struct _gcTA * gcTA; - -typedef struct _gcsMMU_STLB *gcsMMU_STLB_PTR; - -typedef struct _gcsMMU_STLB -{ - gctPHYS_ADDR physical; - gctUINT32_PTR logical; - gctSIZE_T size; - gctUINT32 physBase; - gctSIZE_T pageCount; - gctUINT32 mtlbIndex; - gctUINT32 mtlbEntryNum; - gcsMMU_STLB_PTR next; -} gcsMMU_STLB; - -typedef struct _gcTA_MMU { - gctaOS os; - - gctPOINTER mtlbLogical; - gctUINT32 mtlbBytes; - gctUINT32 mtlbPhysical; - - gctUINT32 dynamicMappingStart; - gctPOINTER stlbs; - - - gctUINT32 pageTableEntries; - gctUINT32 heapList; - - gctUINT32_PTR mapLogical; - gctBOOL freeNodes; - gctUINT32 pageTableSize; - - gctPOINTER safePageLogical; - gctUINT32 safePagePhysical; - - gctBOOL pageTableChanged; - gctPOINTER mutex; -} -gcsTA_MMU; - - -/* - Trust Application is a object needed to be created as a context in trust zone. - One client for a core. -*/ -typedef struct _gcTA { - /* gctaOS object */ - gctaOS os; - - /* Command manager. */ - gcTA_COMMAND command; - - /* Parser. */ - gcTA_PARSER parser; - - /* Hardware. */ - gcTA_HARDWARE hardware; - - /* Page table. */ - gcTA_MMU mmu; - - gctBOOL mmuEnabled; -} gcsTA; - - -typedef struct _gcTA_HARDWARE { - gcTA ta; - gctUINT32 chipFeatures; - - /* Supported minor feature fields. */ - gctUINT32 chipMinorFeatures; - - /* Supported minor feature 1 fields. */ - gctUINT32 chipMinorFeatures1; - - /* Supported minor feature 2 fields. */ - gctUINT32 chipMinorFeatures2; - - /* Supported minor feature 3 fields. */ - gctUINT32 chipMinorFeatures3; - - /*specs.*/ - gctUINT8 pixelPipes; - - gctUINT8 resolvePipes; -} gcsTA_HARDWARE; - -/* Maps state locations within the context buffer. */ -typedef struct _gcsSTATE_MAP * gcsSTATE_MAP_PTR; -typedef struct _gcsSTATE_MAP -{ - /* Index of the state in the context buffer. */ - gctUINT index; - - /* State mask. */ - gctUINT32 mask; -} -gcsSTATE_MAP; - -typedef struct _gcTA_PARSER { - gcTA ta; - - gctUINT8_PTR currentCmdBufferAddr; - - /* Current command. */ - gctUINT32 lo; - gctUINT32 hi; - - gctUINT8 cmdOpcode; - gctUINT16 cmdAddr; - gctUINT32 cmdSize; - gctUINT32 cmdRectCount; - gctUINT8 skip; - gctUINT32 skipCount; - - gctBOOL allow; - gctBOOL isFilterBlit; - - /* Borrow from kernel context buffer. */ - gctUINT32_PTR buffer; - gctUINT32 stateCount; - gctUINT32 lastAddress; - gctUINT32 lastFixed; - gctUINT32 lastIndex; - gctUINT32 lastSize; - gctUINT32 totalSize; - gcsSTATE_MAP_PTR map; -} -gcsTA_PARSER; - -typedef enum { - gcvTA_COMMAND, - gcvTA_USER_COMMAND, - gcvTA_CONTEXT -} gceTA_NODE_TYPE; - -typedef struct _gcTA_NODE * gcTA_NODE; -typedef struct _gcTA_NODE { - /* Type. */ - gceTA_NODE_TYPE type; - - /* Storage. */ - gctPOINTER logical; - gctUINT32 physical; - gctSIZE_T bytes; -} gcsTA_NODE; - -gceSTATUS HALDECL -TAEmulator( - void - ); - -int -gcTA_Construct( - IN gctaOS Os, - OUT gcTA *TA -); - -int -gcTA_Destroy( - -); - -int -gcTA_Dispatch( - IN gcTA TA, - IN OUT gcsTA_INTERFACE * Interface -); - -/************************************* -* Porting layer -*/ - -gceSTATUS -gctaOS_ConstructOS( - IN gckOS Os, - OUT gctaOS *TAos - ); - -gceSTATUS -gctaOS_Allocate( - IN gctUINT32 Bytes, - OUT gctPOINTER *Pointer - ); - -gceSTATUS -gctaOS_Free( - IN gctPOINTER Pointer - ); - -gceSTATUS -gctaOS_AllocateSecurityMemory( - IN gctaOS Os, - IN gctSIZE_T *Bytes, - OUT gctPOINTER *Logical, - OUT gctUINT32 *Physical - ); - -gceSTATUS -gctaOS_GetPhysicalAddress( - IN gctaOS Os, - IN gctPOINTER Logical, - OUT gctUINT32 * Physical - ); - -gceSTATUS -gctaOS_WriteRegister( - IN gctaOS Os, - IN gctUINT32 Address, - IN gctUINT32 Data - ); - -gceSTATUS -gctaOS_ReadRegister( - IN gctaOS Os, - IN gctUINT32 Address, - IN gctUINT32 *Data - ); - -gceSTATUS -gctaOS_MemCopy( - IN gctUINT8_PTR Dest, - IN gctUINT8_PTR Src, - IN gctUINT32 Bytes - ); - -gceSTATUS -gctaOS_ZeroMemory( - IN gctUINT8_PTR Dest, - IN gctUINT32 Bytes - ); - -void -gctaOS_CacheFlush( - IN gctUINT8_PTR Dest, - IN gctUINT32 Bytes - ); - -void -gctaOS_CacheClean( - IN gctUINT8_PTR Dest, - IN gctUINT32 Bytes - ); - -void -gctaOS_CacheInvalidate( - IN gctUINT8_PTR Dest, - IN gctUINT32 Bytes - ); - -gceSTATUS -gctaOS_IsPhysicalSecure( - IN gctaOS Os, - IN gctUINT32 Physical, - OUT gctBOOL *Secure - ); - -/** -** Hardware layer -**/ -gceSTATUS -gctaHARDWARE_IsFeatureAvailable( - IN gcTA_HARDWARE Hardware, - IN gceFEATURE Feature - ); - -gceSTATUS -gctaHARDWARE_Link( - IN gcTA TA, - IN gctPOINTER Logical, - IN gctPOINTER FetchAddress, - IN gctSIZE_T FetchSize, - IN OUT gctSIZE_T * Bytes - ); - -gceSTATUS -gctaHARDWARE_WaitLink( - IN gcTA TA, - IN gctPOINTER Logical, - IN gctUINT32 Offset, - IN OUT gctSIZE_T * Bytes, - OUT gctUINT32 * WaitOffset - ); - -gceSTATUS -gctaHARDWARE_Execute( - IN gcTA TA, - IN gctPOINTER Logical, - IN gctSIZE_T Bytes - ); - -gceSTATUS -gctaHARDWARE_Fence( - gcTA TA, - gctPOINTER Logical, - gctPOINTER FenceAddress, - gctUINT32 * FenceBytes - ); - -gceSTATUS -gctaHARDWARE_VerifyCommand( - IN gcTA TA, - IN gctUINT32 *CommandBuffer, - IN gctUINT32 Length, - OUT gctBOOL *Allow - ); - -gceSTATUS -gctaHARDWARE_Construct( - IN gcTA TA, - OUT gcTA_HARDWARE * Hardware - ); - -gceSTATUS -gctaHARDWARE_MMU( - IN gcTA_HARDWARE Hardware, - IN gctPOINTER Logical, - IN gctUINT32 MtlbAddress, - IN gctUINT32 SafeAddress, - OUT gctUINT32 *Bytes - ); - -gceSTATUS -gctaHARDWARE_MmuEnable( - IN gcTA_HARDWARE Hardware - ); - -gceSTATUS -gctaHARDWARE_End( - IN gcTA_HARDWARE Hardware, - IN gctPOINTER Logical, - IN OUT gctUINT32 * Bytes - ); - -gceSTATUS -gctaHARDWARE_Nop( - IN gcTA_HARDWARE Hardware, - IN gctPOINTER Logical, - IN OUT gctSIZE_T * Bytes - ); - -/* -*Command. -*/ - -gceSTATUS -gctaCOMMAND_Construct( - IN gcTA TA, - OUT gcTA_COMMAND *Command - ); - -gceSTATUS -gctaCOMMAND_Destory( - IN gcTA TA, - OUT gcTA_COMMAND Command - ); - -gceSTATUS -gctaCOMMAND_Start( - IN gcTA_COMMAND Command - ); - -gceSTATUS -gctaCOMMAND_Commit( - IN gcTA_COMMAND Command, - IN gctUINT8_PTR Buffer, - IN gctUINT32 Bytes - ); - - -/* -* Parser -*/ -gceSTATUS -gctaPARSER_Construct( - IN gcTA TA, - OUT gcTA_PARSER *Parser - ); - -/* -* MMU. -*/ -gceSTATUS -gctaMMU_Construct( - IN gcTA TA, - OUT gcTA_MMU *Mmu - ); - -gceSTATUS -gctaMMU_FlatMapping( - IN gcTA_MMU Mmu, - IN gctUINT32 Physical - ); - -gceSTATUS -gctaMMU_AllocatePages( - IN gcTA_MMU Mmu, - IN gctSIZE_T PageCount, - OUT gctUINT32 * Address - ); - -gceSTATUS -gctaMMU_SetPage( - IN gcTA_MMU Mmu, - IN gctUINT32 PageAddress, - IN gctBOOL Secure, - IN gctUINT32 *PageEntry - ); - -gceSTATUS -gctaMMU_GetPageEntry( - IN gcTA_MMU Mmu, - IN gctUINT32 Address, - IN gctUINT32_PTR *PageTable - ); - -gceSTATUS -gctaMMU_FreePages( - IN gcTA_MMU Mmu, - IN gctUINT32 Address, - IN gctSIZE_T PageCount - ); - -gceSTATUS -gctaMMU_Enable( - IN gcTA_MMU Mmu, - IN gcTA TA - ); - -gceSTATUS -gctaMMU_CheckHardwareAddressSecure( - IN gcTA_MMU Mmu, - IN gctUINT32 Address, - IN gctBOOL *Secure - ); - -#ifdef __cplusplus -} -#endif -#endif - diff --git a/drivers/amlogic/npu/security/gc_hal_ta_command.c b/drivers/amlogic/npu/security/gc_hal_ta_command.c deleted file mode 100644 index eaf7673..0000000 --- a/drivers/amlogic/npu/security/gc_hal_ta_command.c +++ /dev/null @@ -1,522 +0,0 @@ -/**************************************************************************** -* -* Copyright (c) 2005 - 2019 by Vivante Corp. All rights reserved. -* -* The material in this file is confidential and contains trade secrets -* of Vivante Corporation. This is proprietary information owned by -* Vivante Corporation. No part of this work may be disclosed, -* reproduced, copied, transmitted, or used in any way for any purpose, -* without the express written permission of Vivante Corporation. -* -*****************************************************************************/ - - -#include "gc_hal_types.h" -#include "gc_hal_base.h" -#include "gc_hal_security_interface.h" -#include "gc_hal_ta.h" -#include "gc_hal.h" - -#define gcvTA_COMMAND_BUSY (~0U) -#define gcvTA_COMMAND_IDLE (0) - -#define gcvTA_COMMAND_QUEUE_NUMBER 4 - -typedef struct _gcTA_COMMAND { - gcTA ta; - - /* gctUINT32 bytes; */ - gctSIZE_T bytes; - - gctPOINTER logical; - gctUINT32 offset; - gctPOINTER lastWaitLink; - - gctSIZE_T waitLinkBytes; - gctUINT32 fenceBytes; - - struct _gcsTA_COMMAND_QUEUE { - gctPOINTER logical; - gctUINT32 physical; - - /* Fence address. */ - gctPOINTER fenceLogical; - gctUINT32 fencePhysical; - } - queues[gcvTA_COMMAND_QUEUE_NUMBER]; - - gctUINT32 index; - gctPOINTER syncFenceLogical; - gctUINT32 syncFencePhysical; -} gcsTA_COMMAND; - -#define gcdCOMMAND_BUFFER_SIZE (4096 * 80) - -extern void -_DumpCommand( - gctUINT32 * Buffer - ); - -#define gcmkPTR_OFFSET(ptr, offset) \ -(\ - (gctUINT8_PTR)(ptr) + (offset) \ -) - -gctPOINTER -_CurrentLogical( - gcTA_COMMAND Command - ) -{ - return gcmkPTR_OFFSET(Command->logical, Command->offset); -} - -void -_WaitLink( - IN gcTA_COMMAND Command, - IN gctUINT32 Offset - ) -{ - gcTA ta = Command->ta; - - gctUINT8_PTR waitLinkLogical; - - waitLinkLogical = gcmkPTR_OFFSET(Command->logical, Offset); - - gctaHARDWARE_WaitLink( - ta, - waitLinkLogical, - 0, - &Command->waitLinkBytes, - gcvNULL - ); - - gctaOS_CacheClean(waitLinkLogical, Command->waitLinkBytes); - - Command->lastWaitLink = waitLinkLogical; -} - -static gctBOOL -_QueueIdle( - IN gcTA_COMMAND Command, - IN gctUINT32 Index - ) -{ - gctUINT32_PTR fenceLogical = (gctUINT32_PTR)Command->queues[Index].fenceLogical; - - gctaOS_CacheInvalidate(fenceLogical, sizeof(gctUINT32)); - - return (*fenceLogical == gcvTA_COMMAND_IDLE); -} - -static void -_SetQueueBusy( - IN gcTA_COMMAND Command, - IN gctUINT32 Index - ) -{ - gctUINT32_PTR fenceLogical = (gctUINT32_PTR)Command->queues[Index].fenceLogical; - - *fenceLogical = gcvTA_COMMAND_BUSY; - - gctaOS_CacheClean(fenceLogical, gcmSIZEOF(gctUINT32)); -} - -static gceSTATUS -_NewQueue( - IN gcTA_COMMAND Command, - OUT gctINT32 * PreviousIndex - ) -{ - gctUINT32 currentIndex = Command->index; - gctUINT32 newIndex = (currentIndex + 1) % gcvTA_COMMAND_QUEUE_NUMBER; - gctUINT32 fenceBytes; - gctUINT32 waitLinkOffset = 0; - - while (!_QueueIdle(Command, newIndex)) - { - printf("XQ %s(%d) \n", __FUNCTION__, __LINE__); - gctaOS_Delay(1000); - /* We don't wait in trust zone but go back to kernel and ask kernel to call again. */ - } - - /* Set current. */ - Command->logical = Command->queues[newIndex].logical; - Command->offset = 0; - Command->index = newIndex; - - _SetQueueBusy(Command, newIndex); - - *PreviousIndex = currentIndex; - - return gcvSTATUS_OK; -} - -gceSTATUS -_FlatMapCommandBuffer( - IN gcTA TA, - IN gctPOINTER Logical, - IN gctUINT32 PageCount -) -{ - gceSTATUS status; - gcTA_MMU mmu = TA->mmu; - gctINT i; - gctUINT32 physical; - - gctaOS_GetPhysicalAddress(TA->os, Logical, &physical); - - for (i = 0; i < PageCount; i++) - { - gcmkONERROR(gctaMMU_FlatMapping(mmu, physical + i * 4096)); - } - - return gcvSTATUS_OK; -OnError: - return status; -} - -gceSTATUS -gctaCOMMAND_Construct( - IN gcTA TA, - OUT gcTA_COMMAND *Command - ) -{ - gceSTATUS status; - gcTA_COMMAND command; - gctPOINTER pointer; - - gctSIZE_T bytes = 4096; - gctaOS os = TA->os; - gctINT i; - - gcmkONERROR(gctaOS_Allocate(gcmSIZEOF(gcsTA_COMMAND), &pointer)); - - command = (gcTA_COMMAND)pointer; - - command->bytes = gcdCOMMAND_BUFFER_SIZE; - command->offset = 0; - command->ta = TA; - command->logical = gcvNULL; - command->index = 0; - - for (i = 0; i < gcvTA_COMMAND_QUEUE_NUMBER; i++) - { - /* Allocate command buffer. */ - gcmkONERROR(gctaOS_AllocateSecurityMemory( - os, - &command->bytes, - &command->queues[i].logical, - &command->queues[i].physical - )); - - /* Allocate fence buffer */ - gcmkONERROR(gctaOS_AllocateSecurityMemory( - os, - &bytes, - &command->queues[i].fenceLogical, - &command->queues[i].fencePhysical - )); - - /* Mark this queue a IDLE queue. */ - *(gctUINT32 *)command->queues[i].fenceLogical = gcvTA_COMMAND_IDLE; - - gctaOS_CacheFlush(command->queues[i].fenceLogical, sizeof(gctUINT32)); - - /* Set up page table for this command buffer. */ - gcmkONERROR(_FlatMapCommandBuffer( - TA, - command->queues[i].logical, - command->bytes/4096 - )); - } - - /* Allocate sync fence buffer. */ - gcmkONERROR(gctaOS_AllocateSecurityMemory( - os, - &bytes, - &command->syncFenceLogical, - &command->syncFencePhysical - )); - - /* Query fence bytes. */ - gcmkONERROR(gctaHARDWARE_Fence( - TA, - gcvNULL, - gcvNULL, - &command->fenceBytes - )); - - /* Query WAIT/LINK bytes. */ - gcmkONERROR(gctaHARDWARE_WaitLink( - TA, - gcvNULL, - 0, - &command->waitLinkBytes, - gcvNULL - )); - - *Command = command; - - return gcvSTATUS_OK; - -OnError: - return status; -} - -gceSTATUS -gctaCOMMAND_Destory( - IN gcTA TA, - OUT gcTA_COMMAND Command - ) -{ - gctINT i; - - for (i = 0; i < gcvTA_COMMAND_QUEUE_NUMBER; i++) - { - - } - - gcmkVERIFY_OK(gctaOS_Free(Command)); - - return gcvSTATUS_OK; -} - -gceSTATUS -gctaCOMMAND_Start( - IN gcTA_COMMAND Command - ) -{ - gceSTATUS status; - gcTA ta = Command->ta; - gctPOINTER waitLinkLogical = 0; - gctINT32 previousIndex = -1; - - if (Command->logical == gcvNULL) - { - gcmkONERROR(_NewQueue(Command, &previousIndex)); - } - - /* Start at beginning of page. */ - Command->offset = 0; - - waitLinkLogical = gcmkPTR_OFFSET(Command->logical, Command->offset); - - /* Append a WAIT/LINK. */ - gcmkONERROR(gctaHARDWARE_WaitLink( - ta, - waitLinkLogical, - 0, - &Command->waitLinkBytes, - gcvNULL - )); - - gctaOS_CacheClean(waitLinkLogical, Command->waitLinkBytes); - - /* Advance current position. */ - Command->offset += Command->waitLinkBytes; - - /* Store wait location. */ - Command->lastWaitLink = waitLinkLogical; - - /* Start FE. */ - gcmkONERROR(gctaHARDWARE_Execute( - ta, - waitLinkLogical, - Command->waitLinkBytes - )); - - /* Enable MMU if needed. */ - - - return gcvSTATUS_OK; - -OnError: - return status; -} - -gceSTATUS -gctaCOMMAND_Stop( - IN gcTA_COMMAND Command - ) -{ - gceSTATUS status; - gctUINT32 bytes = 8; - gcmkONERROR(gctaHARDWARE_End(Command->ta->hardware, Command->lastWaitLink, &bytes)); - return gcvSTATUS_OK; - -OnError: - return status; -} - -gceSTATUS -gctaCOMMAND_Commit( - IN gcTA_COMMAND Command, - IN gctUINT8_PTR Buffer, - IN gctUINT32 Bytes - ) -{ - gceSTATUS status; - gctPOINTER commandLogical; - gctUINT32 commandBytes; - gctUINT32 reservedBytes; - gctUINT32 waitLinkOffset; - gctPOINTER lastWaitLink; - gctSIZE_T bytes = 8; - gctINT previousIndex = -1; - gctPOINTER fenceLogical; - gcTA ta; - gctPOINTER entryLogical; - gctUINT32 fenceBytes = 0; - gctBOOL allow; - - /* Shortcut to ta. */ - ta = Command->ta; - - /* Aligned input buffer to 8 bytes. */ - commandBytes = gcmALIGN(Bytes, 8); - - /* Bytes needed by WAIT/LINK and command buffer from non-secure world. */ - reservedBytes = commandBytes + Command->waitLinkBytes; - - /* Enough space ? */ - if (gcdCOMMAND_BUFFER_SIZE - Command->offset < reservedBytes) - { - gcmkONERROR(_NewQueue(Command, &previousIndex)); - gcmkPRINT("wrap\n"); - } - - /* Location of LINK. */ - lastWaitLink = Command->lastWaitLink; - - entryLogical = commandLogical = _CurrentLogical(Command); - - if (previousIndex >= 0) - { - fenceBytes = Command->fenceBytes; - - /* Need add a fence for previous command. */ - gcmkONERROR(gctaHARDWARE_Fence( - Command->ta, - entryLogical, - Command->queues[previousIndex].fenceLogical, - &Command->fenceBytes - )); - - gctaOS_CacheClean(entryLogical, Command->fenceBytes); - - commandLogical = gcmkPTR_OFFSET(entryLogical, fenceBytes); - reservedBytes += fenceBytes; - } - - /* After commit buffer executed, FE will stop here (offset). */ - waitLinkOffset = Command->offset + commandBytes + fenceBytes; - - _WaitLink(Command, waitLinkOffset); - - /* Do we need add padding nop???. */ - gctaOS_MemCopy((gctUINT8_PTR)commandLogical, Buffer, commandBytes); - - gcmkONERROR(gctaHARDWARE_VerifyCommand( - ta, - (gctUINT32_PTR)commandLogical, - commandBytes, - &allow - )); - - if (allow == gcvFALSE) - { - gctUINT32_PTR secureBuffer = (gctUINT32_PTR)commandLogical; - gctINT i; - gctUINT32 bytes = 8; - - /* memset command buffer to NOP. */ - for (i = 0; i < commandBytes; i += 4) - { - gcmkVERIFY_OK(gctaHARDWARE_Nop( - ta->hardware, - secureBuffer, - &bytes - )); - - secureBuffer++; - } - } - - gctaOS_CacheClean(commandLogical, commandBytes); - - /* Link to copied command buffer. */ - gcmkONERROR(gctaHARDWARE_Link( - ta, - lastWaitLink, - entryLogical, - reservedBytes, - &bytes - )); - - Command->offset += reservedBytes; - - - /* _DumpCommand(Command->logical); */ - - return gcvSTATUS_OK; - -OnError: - return status; -} - -gceSTATUS -gctaCOMMAND_Stall( - IN gcTA_COMMAND Command - ) -{ - gceSTATUS status; - gctUINT8 buffer[32 * sizeof(gctUINT32)]; - gctUINT32 bytes = 32 * sizeof(gctUINT32); - gctUINT32 data; - gctUINT32 delay = 1; - gctUINT32 timer = 0; - - gctUINT32_PTR logical = Command->syncFenceLogical; - - gctaOS_WriteSecurityMemory(logical, 4, gcvTA_COMMAND_BUSY); - - gcmkONERROR(gctaHARDWARE_Fence( - Command->ta, - buffer, - Command->syncFenceLogical, - &bytes - )); - - gcmkONERROR(gctaCOMMAND_Commit( - Command, - buffer, - bytes - )); - - do { - gctaOS_ReadSecurityMemory(logical, 4, &data); - - if (data == gcvTA_COMMAND_IDLE) - { - break; - } - else - { - gctaOS_Delay(delay); - timer += delay; - delay *= 2; - - if (timer > gcdGPU_TIMEOUT) - { - gcmkONERROR(gcvSTATUS_TIMEOUT); - } - } - } - while (gcvTRUE); - - return gcvSTATUS_OK; - -OnError: - return status; -} - diff --git a/drivers/amlogic/npu/security/gc_hal_ta_hardware.c b/drivers/amlogic/npu/security/gc_hal_ta_hardware.c deleted file mode 100644 index ace230d..0000000 --- a/drivers/amlogic/npu/security/gc_hal_ta_hardware.c +++ /dev/null @@ -1,2769 +0,0 @@ -/**************************************************************************** -* -* Copyright (c) 2005 - 2019 by Vivante Corp. All rights reserved. -* -* The material in this file is confidential and contains trade secrets -* of Vivante Corporation. This is proprietary information owned by -* Vivante Corporation. No part of this work may be disclosed, -* reproduced, copied, transmitted, or used in any way for any purpose, -* without the express written permission of Vivante Corporation. -* -*****************************************************************************/ - - -#include "gc_hal_types.h" -#include "gc_hal_base.h" -#include "gc_hal_security_interface.h" -#include "gc_hal_ta.h" -#include "gc_hal.h" - - -#define _GC_OBJ_ZONE 1 -#define SRC_MAX 8 -#define RECT_ADDR_OFFSET 3 - -#define INVALID_ADDRESS ~0U - -/* TA Debug macro. */ -#define gcmTA_PRINT(...) - -/* -* Parser functions. -*/ - -#define _STATE(reg) \ - _State(\ - Context, index, \ - reg ## _Address >> 2, \ - reg ## _ResetValue, \ - reg ## _Count, \ - gcvFALSE, gcvFALSE \ - ) - -#define _STATE_X(reg) \ - _State(\ - Context, index, \ - reg ## _Address >> 2, \ - reg ## _ResetValue, \ - reg ## _Count, \ - gcvTRUE, gcvFALSE \ - ) - -#define _STATE_HINT_BLOCK(reg, block, count) \ - _State(\ - Context, index, \ - (reg ## _Address >> 2) + (block << reg ## _BLK), \ - reg ## _ResetValue, \ - count, \ - gcvFALSE, gcvTRUE \ - ) - -#define _BLOCK_COUNT(reg) \ - ((reg ## _Count) >> (reg ## _BLK)) - -static gctSIZE_T -_State( - IN gcTA_PARSER Context, - IN gctSIZE_T Index, - IN gctUINT32 Address, - IN gctUINT32 Value, - IN gctSIZE_T Size, - IN gctBOOL FixedPoint, - IN gctBOOL Hinted - ) -{ - gctUINT32_PTR buffer; - gctSIZE_T align, i; - - /* Determine if we need alignment. */ - align = (Index & 1) ? 1 : 0; - - /* Address correct index. */ - buffer = (Context->buffer == gcvNULL) - ? gcvNULL - : Context->buffer; - - if ((buffer == gcvNULL) && (Address + Size > Context->stateCount)) - { - /* Determine maximum state. */ - Context->stateCount = Address + Size; - } - - /* Do we need a new entry? */ - if ((Address != Context->lastAddress) || (FixedPoint != Context->lastFixed)) - { - if (buffer != gcvNULL) - { - if (align) - { - /* Add filler. */ - buffer[Index++] = 0xDEADDEAD; - } - - /* LoadState(Address, Count). */ - gcmkASSERT((Index & 1) == 0); - - if (FixedPoint) - { - buffer[Index] - = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 31:27) - (0 ? - 31:27) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 31:27) - (0 ? - 31:27) + 1))))))) << (0 ? - 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? - 31:27) - (0 ? - 31:27) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) - | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 26:26) - (0 ? - 26:26) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 26:26) - (0 ? - 26:26) + 1))))))) << (0 ? - 26:26))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? - 26:26) - (0 ? - 26:26) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 26:26) - (0 ? 26:26) + 1))))))) << (0 ? 26:26))) - | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 25:16) - (0 ? - 25:16) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 25:16) - (0 ? - 25:16) + 1))))))) << (0 ? - 25:16))) | (((gctUINT32) ((gctUINT32) (Size) & ((gctUINT32) ((((1 ? - 25:16) - (0 ? - 25:16) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))) - | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 15:0) - (0 ? - 15:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 15:0) - (0 ? - 15:0) + 1))))))) << (0 ? - 15:0))) | (((gctUINT32) ((gctUINT32) (Address) & ((gctUINT32) ((((1 ? - 15:0) - (0 ? - 15:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))); - } - else - { - buffer[Index] - = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 31:27) - (0 ? - 31:27) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 31:27) - (0 ? - 31:27) + 1))))))) << (0 ? - 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? - 31:27) - (0 ? - 31:27) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) - | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 26:26) - (0 ? - 26:26) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 26:26) - (0 ? - 26:26) + 1))))))) << (0 ? - 26:26))) | (((gctUINT32) (0x0 & ((gctUINT32) ((((1 ? - 26:26) - (0 ? - 26:26) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 26:26) - (0 ? 26:26) + 1))))))) << (0 ? 26:26))) - | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 25:16) - (0 ? - 25:16) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 25:16) - (0 ? - 25:16) + 1))))))) << (0 ? - 25:16))) | (((gctUINT32) ((gctUINT32) (Size) & ((gctUINT32) ((((1 ? - 25:16) - (0 ? - 25:16) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))) - | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 15:0) - (0 ? - 15:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 15:0) - (0 ? - 15:0) + 1))))))) << (0 ? - 15:0))) | (((gctUINT32) ((gctUINT32) (Address) & ((gctUINT32) ((((1 ? - 15:0) - (0 ? - 15:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))); - } - - /* Walk all the states. */ - for (i = 0; i < Size; i += 1) - { - /* Set state to uninitialized value. */ - buffer[Index + 1 + i] = Value; - - /* Set index in state mapping table. */ - Context->map[Address + i].index = Index + 1 + i; - } - } - - /* Save information for this LoadState. */ - Context->lastIndex = Index; - Context->lastAddress = Address + Size; - Context->lastSize = Size; - Context->lastFixed = FixedPoint; - - /* Return size for load state. */ - return align + 1 + Size; - } - - /* Append this state to the previous one. */ - if (buffer != gcvNULL) - { - /* Update last load state. */ - buffer[Context->lastIndex] = - ((((gctUINT32) (buffer[Context->lastIndex])) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 25:16) - (0 ? - 25:16) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 25:16) - (0 ? - 25:16) + 1))))))) << (0 ? - 25:16))) | (((gctUINT32) ((gctUINT32) (Context->lastSize + Size) & ((gctUINT32) ((((1 ? - 25:16) - (0 ? - 25:16) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); - - /* Walk all the states. */ - for (i = 0; i < Size; i += 1) - { - /* Set state to uninitialized value. */ - buffer[Index + i] = Value; - - /* Set index in state mapping table. */ - Context->map[Address + i].index = Index + i; - } - } - - /* Update last address and size. */ - Context->lastAddress += Size; - Context->lastSize += Size; - - /* Return number of slots required. */ - return Size; -} - -gceSTATUS -_GetValue( - IN gcTA_PARSER Parser, - IN gctUINT32 State, - OUT gctUINT32 *Data - ) -{ - gctUINT32 index; - - /* Is it recorded? */ - if (State >= Parser->stateCount) - { - return gcvSTATUS_NOT_FOUND; - } - - index = Parser->map[State].index; - - if (index == 0) - { - return gcvSTATUS_NOT_FOUND; - } - - /* Get current value. */ - *Data = Parser->buffer[index]; - return gcvSTATUS_OK; -} - -gctBOOL -_SecureBuffer( - IN gcTA_PARSER Parser, - IN gctUINT32 Address - ) -{ - gceSTATUS status; - gcTA_MMU mmu = Parser->ta->mmu; - gctBOOL secure = gcvFALSE; - - status = - gctaMMU_CheckHardwareAddressSecure(mmu, Address, &secure); - - if (gcmIS_SUCCESS(status) && secure) - { - /* Address is marked as security buffer. */ - return gcvTRUE; - } - else - { - return gcvFALSE; - } -} - -void -_CheckResolve( - IN OUT gcTA_PARSER Parser - ) -{ - gctUINT32 source, source1; - gctUINT32 target, target1; - gctUINT32 windowSize, width, height, srcStride, dstStride; - gctUINT32 config; - gctUINT32 resolvePipes = Parser->ta->hardware->resolvePipes; - gctUINT32 clearControl; - gctUINT32 sourceEnd, targetEnd; - - _GetValue(Parser, 0x058F, &clearControl); - - if ((((((gctUINT32) (clearControl)) >> (0 ? 17:16)) & ((gctUINT32) ((((1 ? 17:16) - (0 ? 17:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 17:16) - (0 ? 17:16) + 1)))))) )) - { - /* Clear doesn't leak data, ignore state check. */ - return; - } - - if (resolvePipes > 1) - { - _GetValue(Parser, 0x05B0, &source); - _GetValue(Parser, 0x05B8, &target); - - _GetValue(Parser, 0x05B0 + 1, &source1); - _GetValue(Parser, 0x05B8 + 1, &target1); - } - else - { - _GetValue(Parser, 0x0582, &source); - _GetValue(Parser, 0x0584, &target); - } - - _GetValue(Parser, 0x0588, &windowSize); - _GetValue(Parser, 0x0583, &srcStride); - _GetValue(Parser, 0x0585, &dstStride); - _GetValue(Parser, 0x0581, &config); - - width = (((((gctUINT32) (windowSize)) >> (0 ? 15:0)) & ((gctUINT32) ((((1 ? 15:0) - (0 ? 15:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1)))))) ); - height = (((((gctUINT32) (windowSize)) >> (0 ? 31:16)) & ((gctUINT32) ((((1 ? 31:16) - (0 ? 31:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 31:16) - (0 ? 31:16) + 1)))))) ); - - /* Get Stride. */ - srcStride = (((((gctUINT32) (srcStride)) >> (0 ? 19:0)) & ((gctUINT32) ((((1 ? 19:0) - (0 ? 19:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 19:0) - (0 ? 19:0) + 1)))))) ); - dstStride = (((((gctUINT32) (dstStride)) >> (0 ? 19:0)) & ((gctUINT32) ((((1 ? 19:0) - (0 ? 19:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 19:0) - (0 ? 19:0) + 1)))))) ); - - /* Fixup Stride. */ - if ((((((gctUINT32) (config)) >> (0 ? 7:7)) & ((gctUINT32) ((((1 ? 7:7) - (0 ? 7:7) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 7:7) - (0 ? 7:7) + 1)))))) )) - { - srcStride /= 4; - } - - if ((((((gctUINT32) (config)) >> (0 ? 14:14)) & ((gctUINT32) ((((1 ? 14:14) - (0 ? 14:14) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 14:14) - (0 ? 14:14) + 1)))))) )) - { - dstStride /= 4; - } - - - gcmTA_PRINT("Resolving: 0x%08x 0x%08x => 0x%08x 0x%08x (%d x %d) srcStride=%d destStride=%d", - source, source1, target, target1, width, height, srcStride, dstStride); - - sourceEnd = source + srcStride * height; - targetEnd = target + dstStride * height; - - gcmkPRINT("RESOLVE: [%08x,%08x) => [%08x,%08x)", source, sourceEnd, target, targetEnd); - - /* If any part of source is secure memory. */ - if (_SecureBuffer(Parser, source) || _SecureBuffer(Parser, sourceEnd)) - { - /* None of target can be non-secure. */ - if (!_SecureBuffer(Parser, target) || !_SecureBuffer(Parser, targetEnd)) - { - Parser->allow = gcvFALSE; - } - } -} - -void -_CheckDraw( - IN OUT gcTA_PARSER Parser - ) -{ - gctUINT32 target, targetEnd, stride; - gctUINT32 xscale, yscale, xoffset, yoffset; - gctUINT32 left, top, right, bottom; - gctUINT32 width, height; - gctINT i, j; - gctUINT32 sample; - gctUINT32 textureSampleArray[] = { - 0x0900, - 0x0910, - 0x0920, - 0x0930, - 0x0940, - 0x0950, - 0x0960, - 0x0970, - 0x0980, - 0x0990, - 0x09A0, - 0x09B0, - 0x09C0, - 0x09D0 - }; - - gctUINT32 textureAddress = 0x4200; - - gctUINT32 texBlockCount = ((512) >> (4)); - - _GetValue(Parser, 0x0280, &xscale); - _GetValue(Parser, 0x0281, &yscale); - _GetValue(Parser, 0x0283, &xoffset); - _GetValue(Parser, 0x0284, &yoffset); - - _GetValue(Parser, 0x0518, &target); - _GetValue(Parser, 0x050D, &stride); - - /* Viewport. */ - left = (xoffset - xscale) >> 16; - right = left + (xscale >> 15); - - if (yscale & 0x80000000) - { - top = (yoffset + yscale) >> 16; - bottom = top + (((~yscale) + 1) >> 15); - } - else - { - top = (yoffset - yscale) >> 16; - bottom = top + (yscale >> 15); - } - - width = right - left; - height = bottom - top; - - /* Memory range. */ - targetEnd = target + height * stride; - - gcmTA_PRINT("draw... %x %d %d %d %d", target, left, top, width, height); - - gcmkPRINT("DRAW : [%08x,%08x)", target, target + height * stride); - - for (i = 0 ; i < texBlockCount; i++) - { - for (j = 0; j < 14; j++) - { - textureAddress = 0x4200 + (i << 4) + j; - - _GetValue(Parser, textureAddress, &sample); - - if ((sample != INVALID_ADDRESS) &&_SecureBuffer(Parser, sample)) - { - /* There is a secure source, check target. */ - if (!_SecureBuffer(Parser, target) || !_SecureBuffer(Parser, targetEnd)) - { - printf("Offending DRAW %x => [%08x,%08x) \n", sample, target, target + height * stride); - Parser->allow = gcvFALSE; - } - } - } - } -} - -void -_ConvertHwFormat( - IN gctUINT32 HwFormat, - OUT gctUINT32 *bytesPerPixel - ) -{ - switch(HwFormat) - { - case 0x05: - case 0x06: - *bytesPerPixel = 4; - break; - - case 0x00: - case 0x01: - case 0x02: - case 0x03: - case 0x04: - case 0x07: - case 0x08: - *bytesPerPixel = 2; - break; - - case 0x10: - *bytesPerPixel = 1; - break; - - default: - printf("HwFormat not supported!\n"); - break; - } -} - -gctBOOL -_IsYUVFormat( - IN gctUINT32 HwFormat - ) -{ - /*YV12, NV12, NV16 calculate Yaddress, Uaddress, Vaddress or UVaddress separately*/ - return ((HwFormat == 0x0F) || - (HwFormat == 0x11) || - (HwFormat == 0x12)) ? 1 : 0; -} - -void -_Get2DEndAddr( - IN gctUINT32 baseAddr, - IN gctUINT32 hwFormat, - IN gctUINT32 stride, - IN gctUINT32 bottom, - IN gctUINT32 right, - OUT gctUINT32 *endAddr - ) -{ - gctUINT32 bytesPerPixel; - - _ConvertHwFormat(hwFormat, &bytesPerPixel); - *endAddr = baseAddr + ((bottom - 1) * stride + right * bytesPerPixel); -} - -void -_GetYUVSrcAddr( - IN gcTA_PARSER Parser, - IN gctUINT32 Yaddr, - IN gctUINT32 YaddrEnd, - IN gctUINT32 srcFormat, - IN gctUINT32 src_bottom, - IN gctUINT32 src_right, - OUT gctUINT32 sourceYUV[], - OUT gctUINT32 sourceYUVEnd[] - ) -{ - gctUINT32 uStride, vStride; - - /* Y address */ - sourceYUV[0] = Yaddr; - sourceYUVEnd[0] = YaddrEnd; - - _GetValue(Parser, 0x04A1, &sourceYUV[1]); - _GetValue(Parser, 0x04A2, &uStride); - uStride = (((((gctUINT32) (uStride)) >> (0 ? 17:0)) & ((gctUINT32) ((((1 ? 17:0) - (0 ? 17:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 17:0) - (0 ? 17:0) + 1)))))) ); - - /* NV12 */ - if (srcFormat == 0x11) - { - /* UV address */ - sourceYUVEnd[1] = sourceYUV[1] + uStride * (src_bottom - 1) / 2 + src_right; - } - /* NV16 */ - else if (srcFormat == 0x12) - { - /* UV address */ - sourceYUVEnd[1] = sourceYUV[1] + uStride * (src_bottom - 1) + src_right * 2; - } - /* YV12 */ - else if (srcFormat == 0x0F) - { - _GetValue(Parser, 0x04A3, &sourceYUV[2]); - _GetValue(Parser, 0x04A4, &vStride); - vStride = (((((gctUINT32) (vStride)) >> (0 ? 17:0)) & ((gctUINT32) ((((1 ? 17:0) - (0 ? 17:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 17:0) - (0 ? 17:0) + 1)))))) ); - - /* U address */ - sourceYUVEnd[1] = sourceYUV[1] + uStride * (src_bottom - 1) / 2 + src_right / 2; - - /* V address */ - sourceYUVEnd[2] = sourceYUV[2] + vStride * (src_bottom - 1) / 2 + src_right / 2; - } -} - -void -_Check2D( - IN OUT gcTA_PARSER Parser - ) -{ - gctUINT32 source[SRC_MAX], sourceEnd[SRC_MAX]; - gctUINT32 target, targetEnd; - gctUINT32 srcConfig, srcStride, srcOrigin, srcSize, srcFormat; - gctUINT32 dstConfig, dstStride, bottomRight, dstFormat; - gcsPOINT src_orign, src_size; - gcsPOINT dst_orign, dst_size; - gctUINT32 src_bottom, src_right, dst_bottom, dst_right; - gctUINT32 srcType, vrConfigType; - gctUINT32 i, j, maxSrc, multiSrc0; - gctUINT32 srcLow, srcHigh, windowLow, windowHigh, imageLow, imageHigh; - gctUINT32 sourceYUV[3], sourceYUVEnd[3], destYUV[3], destYUVEnd[3]; - gctBOOL isYUV, srcHasSecure = gcvFALSE; - - memset(source, 0, sizeof(source)); - memset(sourceEnd, 0, sizeof(sourceEnd)); - memset(sourceYUV, 0, sizeof(sourceYUV)); - memset(sourceYUVEnd, 0, sizeof(sourceYUVEnd)); - memset(destYUV, 0, sizeof(destYUV)); - memset(destYUVEnd, 0, sizeof(destYUVEnd)); - - _GetValue(Parser, 0x048D, &dstConfig); - srcType = (((((gctUINT32) (dstConfig)) >> (0 ? 15:12)) & ((gctUINT32) ((((1 ? 15:12) - (0 ? 15:12) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 15:12) - (0 ? 15:12) + 1)))))) ); - - /* Bitblt. */ - if ((srcType == 0x2) || - (srcType == 0x4) ) - { - /* SRC */ - _GetValue(Parser, 0x0480, &source[0]); - _GetValue(Parser, 0x0483, &srcConfig); - _GetValue(Parser, 0x0481, &srcStride); - _GetValue(Parser, 0x0484, &srcOrigin); - _GetValue(Parser, 0x0485, &srcSize); - - src_orign.x = (((((gctUINT32) (srcOrigin)) >> (0 ? 15:0)) & ((gctUINT32) ((((1 ? 15:0) - (0 ? 15:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1)))))) ); - src_orign.y = (((((gctUINT32) (srcOrigin)) >> (0 ? 31:16)) & ((gctUINT32) ((((1 ? 31:16) - (0 ? 31:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 31:16) - (0 ? 31:16) + 1)))))) ); - - src_size.x = (((((gctUINT32) (srcSize)) >> (0 ? 15:0)) & ((gctUINT32) ((((1 ? 15:0) - (0 ? 15:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1)))))) ); - src_size.y = (((((gctUINT32) (srcSize)) >> (0 ? 31:16)) & ((gctUINT32) ((((1 ? 31:16) - (0 ? 31:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 31:16) - (0 ? 31:16) + 1)))))) ); - - src_bottom = src_orign.y + src_size.y; - src_right = src_orign.x + src_size.x; - - srcStride = (((((gctUINT32) (srcStride)) >> (0 ? 17:0)) & ((gctUINT32) ((((1 ? 17:0) - (0 ? 17:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 17:0) - (0 ? 17:0) + 1)))))) ); - - srcFormat = (((((gctUINT32) (srcConfig)) >> (0 ? 3:0)) & ((gctUINT32) ((((1 ? 3:0) - (0 ? 3:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 3:0) - (0 ? 3:0) + 1)))))) ); - - _Get2DEndAddr(source[0], srcFormat, srcStride, src_bottom, src_right, &sourceEnd[0]); - - isYUV = _IsYUVFormat(srcFormat); - if (isYUV) - { - _GetYUVSrcAddr(Parser, source[0], sourceEnd[0], srcFormat, - src_bottom, src_right, sourceYUV, sourceYUVEnd); - - /* if any of source is security */ - for (i = 0; i < 3; i++) - { - if ((sourceYUV[i] && _SecureBuffer(Parser, sourceYUV[i])) || - (sourceYUVEnd[i] && _SecureBuffer(Parser, sourceYUVEnd[i]))) - { - srcHasSecure = gcvTRUE; - break; - } - } - } - else - { - /* if any of source is security */ - if (_SecureBuffer(Parser, source[0]) || _SecureBuffer(Parser, sourceEnd[0])) - { - srcHasSecure = gcvTRUE; - } - } - - /* DST (StartDE)*/ - _GetValue(Parser, 0x048A, &target); - _GetValue(Parser, 0x048B, &dstStride); - _GetValue(Parser, 0x048D, &dstConfig); - - dstStride = (((((gctUINT32) (dstStride)) >> (0 ? 17:0)) & ((gctUINT32) ((((1 ? 17:0) - (0 ? 17:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 17:0) - (0 ? 17:0) + 1)))))) ); - - dstFormat = (((((gctUINT32) (dstConfig)) >> (0 ? 4:0)) & ((gctUINT32) ((((1 ? 4:0) - (0 ? 4:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 4:0) - (0 ? 4:0) + 1)))))) ); - - if (srcHasSecure) - { - gctUINT32 * buffer = (gctUINT32 *)Parser->currentCmdBufferAddr; - - for (i = 0; i < Parser->cmdRectCount; i++) - { - dst_bottom = (((((gctUINT32) (*(buffer + RECT_ADDR_OFFSET + i * 2))) >> (0 ? 31:16)) & ((gctUINT32) ((((1 ? 31:16) - (0 ? 31:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 31:16) - (0 ? 31:16) + 1)))))) ); - dst_right = (((((gctUINT32) (*(buffer + RECT_ADDR_OFFSET + i * 2))) >> (0 ? 15:0)) & ((gctUINT32) ((((1 ? 15:0) - (0 ? 15:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1)))))) ); - - _Get2DEndAddr(target, dstFormat, dstStride, dst_bottom, dst_right, &targetEnd); - - /* None of target can be non-secure. */ - if (!_SecureBuffer(Parser, target) || !_SecureBuffer(Parser, targetEnd)) - { - Parser->allow = gcvFALSE; - break; - } - } - } - } - - /* Multi source blt. */ - if (srcType == 0x8) - { - /* SRC */ - _GetValue(Parser, 0x04C2, &maxSrc); - maxSrc = (((((gctUINT32) (maxSrc)) >> (0 ? 2:0)) & ((gctUINT32) ((((1 ? 2:0) - (0 ? 2:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 2:0) - (0 ? 2:0) + 1)))))) ); - - for (i = 0; i < maxSrc; i++) - { - /* First source */ - if (i == 0) - { - _GetValue(Parser, 0x0480, &source[0]); - _GetValue(Parser, 0x0483, &srcConfig); - _GetValue(Parser, 0x0481, &srcStride); - _GetValue(Parser, 0x0484, &srcOrigin); - _GetValue(Parser, 0x0485, &srcSize); - - src_orign.x = (((((gctUINT32) (srcOrigin)) >> (0 ? 15:0)) & ((gctUINT32) ((((1 ? 15:0) - (0 ? 15:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1)))))) ); - src_orign.y = (((((gctUINT32) (srcOrigin)) >> (0 ? 31:16)) & ((gctUINT32) ((((1 ? 31:16) - (0 ? 31:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 31:16) - (0 ? 31:16) + 1)))))) ); - - src_size.x = (((((gctUINT32) (srcSize)) >> (0 ? 15:0)) & ((gctUINT32) ((((1 ? 15:0) - (0 ? 15:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1)))))) ); - src_size.y = (((((gctUINT32) (srcSize)) >> (0 ? 31:16)) & ((gctUINT32) ((((1 ? 31:16) - (0 ? 31:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 31:16) - (0 ? 31:16) + 1)))))) ); - - src_bottom = src_orign.y + src_size.y; - src_right = src_orign.x + src_size.x; - - srcStride = (((((gctUINT32) (srcStride)) >> (0 ? 17:0)) & ((gctUINT32) ((((1 ? 17:0) - (0 ? 17:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 17:0) - (0 ? 17:0) + 1)))))) ); - - srcFormat = (((((gctUINT32) (srcConfig)) >> (0 ? 3:0)) & ((gctUINT32) ((((1 ? 3:0) - (0 ? 3:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 3:0) - (0 ? 3:0) + 1)))))) ); - - _Get2DEndAddr(source[0], srcFormat, srcStride, src_bottom, src_right, &sourceEnd[0]); - - isYUV = _IsYUVFormat(srcFormat); - if (isYUV) - { - _GetYUVSrcAddr(Parser, source[0], sourceEnd[0], srcFormat, - src_bottom, src_right, sourceYUV, sourceYUVEnd); - - /* if any of source is security */ - for (i = 0; i < 3; i++) - { - if ((sourceYUV[i] && _SecureBuffer(Parser, sourceYUV[i])) || - (sourceYUVEnd[i] && _SecureBuffer(Parser, sourceYUVEnd[i]))) - { - srcHasSecure = gcvTRUE; - break; - } - } - } - else - { - /* if any of source is security */ - if (_SecureBuffer(Parser, source[0]) || _SecureBuffer(Parser, sourceEnd[0])) - { - srcHasSecure = gcvTRUE; - } - } - - if (srcHasSecure) - { - break; - } - - continue; - } - - /* Other sources */ - _GetValue(Parser, 0x4A80 + i, &source[i]); - _GetValue(Parser, 0x4AA0 + i, &srcOrigin); - _GetValue(Parser, 0x4A98 + i, &srcConfig); - _GetValue(Parser, 0x4A88 + i, &srcStride); - _GetValue(Parser, 0x4AA8 + i, &srcSize); - - src_orign.x = (((((gctUINT32) (srcOrigin)) >> (0 ? 15:0)) & ((gctUINT32) ((((1 ? 15:0) - (0 ? 15:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1)))))) ); - src_orign.y = (((((gctUINT32) (srcOrigin)) >> (0 ? 31:16)) & ((gctUINT32) ((((1 ? 31:16) - (0 ? 31:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 31:16) - (0 ? 31:16) + 1)))))) ); - - src_size.x = (((((gctUINT32) (srcSize)) >> (0 ? 15:0)) & ((gctUINT32) ((((1 ? 15:0) - (0 ? 15:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1)))))) ); - src_size.y = (((((gctUINT32) (srcSize)) >> (0 ? 31:16)) & ((gctUINT32) ((((1 ? 31:16) - (0 ? 31:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 31:16) - (0 ? 31:16) + 1)))))) ); - - src_bottom = src_orign.y + src_size.y; - src_right = src_orign.x + src_size.x; - - srcStride = (((((gctUINT32) (srcStride)) >> (0 ? 17:0)) & ((gctUINT32) ((((1 ? 17:0) - (0 ? 17:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 17:0) - (0 ? 17:0) + 1)))))) ); - - /* Bpp */ - srcFormat = (((((gctUINT32) (srcConfig)) >> (0 ? 28:24)) & ((gctUINT32) ((((1 ? 28:24) - (0 ? 28:24) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 28:24) - (0 ? 28:24) + 1)))))) ); - - _Get2DEndAddr(source[i], srcFormat, srcStride, src_bottom, src_right, &sourceEnd[i]); - - isYUV = _IsYUVFormat(srcFormat); - if (isYUV) - { - _GetYUVSrcAddr(Parser, source[i], sourceEnd[i], srcFormat, - src_bottom, src_right, sourceYUV, sourceYUVEnd); - - /* if any of source is security */ - for (j = 0; j < 3; j++) - { - if ((sourceYUV[j] && _SecureBuffer(Parser, sourceYUV[j])) || - (sourceYUVEnd[j] && _SecureBuffer(Parser, sourceYUVEnd[j]))) - { - srcHasSecure = gcvTRUE; - break; - } - } - } - else - { - /* if any of source is security */ - if (_SecureBuffer(Parser, source[i]) || _SecureBuffer(Parser, sourceEnd[i])) - { - srcHasSecure = gcvTRUE; - } - } - - if (srcHasSecure) - break; - } - - /* DST */ - _GetValue(Parser, 0x048A, &target); - _GetValue(Parser, 0x048B, &dstStride); - _GetValue(Parser, 0x048D, &dstConfig); - _GetValue(Parser, 0x4B58, &bottomRight); - - dst_right = (((((gctUINT32) (bottomRight)) >> (0 ? 14:0)) & ((gctUINT32) ((((1 ? 14:0) - (0 ? 14:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 14:0) - (0 ? 14:0) + 1)))))) ); - dst_bottom = (((((gctUINT32) (bottomRight)) >> (0 ? 30:16)) & ((gctUINT32) ((((1 ? 30:16) - (0 ? 30:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 30:16) - (0 ? 30:16) + 1)))))) ); - - dstStride = (((((gctUINT32) (dstStride)) >> (0 ? 17:0)) & ((gctUINT32) ((((1 ? 17:0) - (0 ? 17:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 17:0) - (0 ? 17:0) + 1)))))) ); - - dstFormat = (((((gctUINT32) (dstConfig)) >> (0 ? 4:0)) & ((gctUINT32) ((((1 ? 4:0) - (0 ? 4:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 4:0) - (0 ? 4:0) + 1)))))) ); - - _Get2DEndAddr(target, dstFormat, dstStride, dst_bottom, dst_right, &targetEnd); - - /* If any part of source is secure memory. */ - if (srcHasSecure) - { - isYUV = _IsYUVFormat(dstFormat); - if (isYUV) - { - _GetYUVSrcAddr(Parser, target, targetEnd, dstFormat, - dst_bottom, dst_right, destYUV, destYUVEnd); - - for (j = 0; j < 2; j++) - { - /* None of target can be non-secure. */ - if (!_SecureBuffer(Parser, destYUV[j]) || !_SecureBuffer(Parser, destYUVEnd[j])) - { - Parser->allow = gcvFALSE; - } - } - - if (Parser->allow) - { - if (destYUV[2] && destYUVEnd[2]) - { - if (!_SecureBuffer(Parser, destYUV[2]) || !_SecureBuffer(Parser, destYUVEnd[2])) - { - Parser->allow = gcvFALSE; - } - } - } - } - /* None of target can be non-secure. */ - else if (!_SecureBuffer(Parser, target) || !_SecureBuffer(Parser, targetEnd)) - { - Parser->allow = gcvFALSE; - } - } - } - - /* FilterBlit */ - if (Parser->isFilterBlit) - { - _GetValue(Parser, 0x04A5, &vrConfigType); - vrConfigType = (((((gctUINT32) (vrConfigType)) >> (0 ? 1:0)) & ((gctUINT32) ((((1 ? 1:0) - (0 ? 1:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 1:0) - (0 ? 1:0) + 1)))))) ); - - if ((vrConfigType == 0x0) || - (vrConfigType == 0x1) || - (vrConfigType == 0x2)) - { - /* DST */ - _GetValue(Parser, 0x048A, &target); - _GetValue(Parser, 0x048B, &dstStride); - _GetValue(Parser, 0x048D, &dstConfig); - _GetValue(Parser, 0x04AA, &windowLow); - _GetValue(Parser, 0x04AB, &windowHigh); - - dst_orign.y = (((((gctUINT32) (windowLow)) >> (0 ? 31:16)) & ((gctUINT32) ((((1 ? 31:16) - (0 ? 31:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 31:16) - (0 ? 31:16) + 1)))))) ); - dst_orign.x = (((((gctUINT32) (windowLow)) >> (0 ? 15:0)) & ((gctUINT32) ((((1 ? 15:0) - (0 ? 15:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1)))))) ); - dst_bottom = (((((gctUINT32) (windowHigh)) >> (0 ? 31:16)) & ((gctUINT32) ((((1 ? 31:16) - (0 ? 31:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 31:16) - (0 ? 31:16) + 1)))))) ); - dst_right = (((((gctUINT32) (windowHigh)) >> (0 ? 15:0)) & ((gctUINT32) ((((1 ? 15:0) - (0 ? 15:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1)))))) ); - - dstStride = (((((gctUINT32) (dstStride)) >> (0 ? 17:0)) & ((gctUINT32) ((((1 ? 17:0) - (0 ? 17:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 17:0) - (0 ? 17:0) + 1)))))) ); - - dstFormat = (((((gctUINT32) (dstConfig)) >> (0 ? 4:0)) & ((gctUINT32) ((((1 ? 4:0) - (0 ? 4:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 4:0) - (0 ? 4:0) + 1)))))) ); - - _Get2DEndAddr(target, dstFormat, dstStride, dst_bottom, dst_right, &targetEnd); - - /* SRC */ - _GetValue(Parser, 0x0480, &source[0]); - _GetValue(Parser, 0x0483, &srcConfig); - _GetValue(Parser, 0x0481, &srcStride); - _GetValue(Parser, 0x04A6, &imageLow); - _GetValue(Parser, 0x04A7, &imageHigh); - - src_orign.y = (((((gctUINT32) (imageLow)) >> (0 ? 31:16)) & ((gctUINT32) ((((1 ? 31:16) - (0 ? 31:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 31:16) - (0 ? 31:16) + 1)))))) ); - src_orign.x = (((((gctUINT32) (imageLow)) >> (0 ? 15:0)) & ((gctUINT32) ((((1 ? 15:0) - (0 ? 15:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1)))))) ); - src_bottom = (((((gctUINT32) (imageHigh)) >> (0 ? 31:16)) & ((gctUINT32) ((((1 ? 31:16) - (0 ? 31:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 31:16) - (0 ? 31:16) + 1)))))) ); - src_right = (((((gctUINT32) (imageHigh)) >> (0 ? 15:0)) & ((gctUINT32) ((((1 ? 15:0) - (0 ? 15:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1)))))) ); - - srcStride = (((((gctUINT32) (srcStride)) >> (0 ? 17:0)) & ((gctUINT32) ((((1 ? 17:0) - (0 ? 17:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 17:0) - (0 ? 17:0) + 1)))))) ); - - srcFormat = (((((gctUINT32) (srcConfig)) >> (0 ? 3:0)) & ((gctUINT32) ((((1 ? 3:0) - (0 ? 3:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 3:0) - (0 ? 3:0) + 1)))))) ); - - _Get2DEndAddr(source[0], srcFormat, srcStride, src_bottom, src_right, &sourceEnd[0]); - - isYUV = _IsYUVFormat(srcFormat); - if (isYUV) - { - _GetYUVSrcAddr(Parser, source[0], sourceEnd[0], srcFormat, - src_bottom, src_right, sourceYUV, sourceYUVEnd); - /* if any of source is security */ - for (i = 0; i < 3; i++) - { - if ((sourceYUV[i] && _SecureBuffer(Parser, sourceYUV[i])) || - (sourceYUVEnd[i] && _SecureBuffer(Parser, sourceYUVEnd[i]))) - { - srcHasSecure = gcvTRUE; - break; - } - } - } - else - { - /* if any of source is security */ - if (_SecureBuffer(Parser, source[0]) || _SecureBuffer(Parser, sourceEnd[0])) - { - srcHasSecure = gcvTRUE; - } - } - - if (srcHasSecure) - { - /* None of target can be non-secure. */ - if (!_SecureBuffer(Parser, target) || !_SecureBuffer(Parser, targetEnd)) - { - Parser->allow = gcvFALSE; - } - } - } - } -} - -void -_FillState( - IN OUT gcTA_PARSER Parser -) -{ - gctINT i; - gctUINT32_PTR data = (gctUINT32_PTR)Parser->currentCmdBufferAddr; - gctUINT32 cmdAddr = Parser->cmdAddr; - gctUINT32 index; - gcsSTATE_MAP_PTR map = Parser->map; - gctUINT32_PTR buffer = Parser->buffer; - - for (i = 0; i < Parser->cmdSize; i++) - { - if (cmdAddr == 0x0580) - { - _CheckResolve(Parser); - continue; - } - - if (cmdAddr >= Parser->stateCount) - { - continue; - } - - index = map[cmdAddr].index; - - if (index) - { - buffer[index] = *data; - } - - /* Advance to next state. */ - cmdAddr++; - data++; - } -} - -static void -_GetCommand( - IN OUT gcTA_PARSER Parser - ) -{ - gctUINT32 low, high; - gctUINT32 * buffer = (gctUINT32 *)Parser->currentCmdBufferAddr; - gctUINT32 skipCount; - gctUINT32 vrConfig; - - gctUINT16 cmdRectCount; - gctUINT16 cmdDataCount; - - Parser->hi = buffer[0]; - Parser->lo = buffer[1]; - - Parser->cmdOpcode = (((((gctUINT32) (Parser->hi)) >> (0 ? 31:27)) & ((gctUINT32) ((((1 ? 31:27) - (0 ? 31:27) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1)))))) ); - Parser->cmdRectCount = 1; - - switch (Parser->cmdOpcode) - { - case 0x01: - // Extract count. - Parser->cmdSize = (((((gctUINT32) (Parser->hi)) >> (0 ? 25:16)) & ((gctUINT32) ((((1 ? 25:16) - (0 ? 25:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1)))))) ); - if (Parser->cmdSize == 0) - { - // 0 means 1024. - Parser->cmdSize = 1024; - } - Parser->skip = (Parser->cmdSize & 0x1) ? 0 : 1; - - // Extract address. - Parser->cmdAddr = (((((gctUINT32) (Parser->hi)) >> (0 ? 15:0)) & ((gctUINT32) ((((1 ? 15:0) - (0 ? 15:0) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1)))))) ); - - if (Parser->cmdAddr == 0x04A5) - { - _GetValue(Parser, 0x04A5, &vrConfig); - if (!(((((gctUINT32) (vrConfig)) >> (0 ? 3:3)) & ((gctUINT32) ((((1 ? 3:3) - (0 ? 3:3) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 3:3) - (0 ? 3:3) + 1)))))) )) - { - // FilterBlit - Parser->isFilterBlit = gcvTRUE; - } - } - - - Parser->currentCmdBufferAddr = Parser->currentCmdBufferAddr + 4; - Parser->skipCount = Parser->cmdSize + Parser->skip; - break; - - case 0x05: - Parser->cmdSize = 4; - Parser->skipCount = gcmALIGN(Parser->cmdSize, 2); - break; - - case 0x06: - Parser->cmdSize = 5; - Parser->skipCount = gcmALIGN(Parser->cmdSize, 2); - break; - - case 0x0C: - Parser->cmdSize = 3; - Parser->skipCount = gcmALIGN(Parser->cmdSize, 2); - break; - - case 0x09: - Parser->cmdSize = 2; - Parser->cmdAddr = 0x0F16; - Parser->skipCount = gcmALIGN(Parser->cmdSize, 2); - break; - - case 0x04: - Parser->cmdSize = 1; - Parser->cmdAddr = 0x0F06; - - cmdRectCount = (((((gctUINT32) (Parser->hi)) >> (0 ? 15:8)) & ((gctUINT32) ((((1 ? 15:8) - (0 ? 15:8) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 15:8) - (0 ? 15:8) + 1)))))) ); - cmdDataCount = (((((gctUINT32) (Parser->hi)) >> (0 ? 26:16)) & ((gctUINT32) ((((1 ? 26:16) - (0 ? 26:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 26:16) - (0 ? 26:16) + 1)))))) ); - - gcmTA_PRINT("FE: @ 0x%08x StartDE(%u, %u)\n", - currentCmdBufferAddr, - cmdRectCount, - cmdDataCount); - - Parser->skipCount = gcmALIGN(Parser->cmdSize, 2) - + cmdRectCount * 2 - + gcmALIGN(cmdDataCount, 2); - - Parser->cmdRectCount = cmdRectCount; - break; - - case 0x03: - gcmTA_PRINT("FE: @ 0x%08x Nop\n", - currentCmdBufferAddr); - - Parser->currentCmdBufferAddr = Parser->currentCmdBufferAddr + 8; - Parser->skipCount = 0; - break; - - case 0x02: - Parser->currentCmdBufferAddr = Parser->currentCmdBufferAddr + 8; - Parser->skipCount = 0; - break; - - default: - /* Unknown command is a risk. */ - Parser->allow = gcvFALSE; - break; - } -} - -void -_ParseCommand( - IN OUT gcTA_PARSER Parser - ) -{ - switch(Parser->cmdOpcode) - { - case 0x01: - _FillState(Parser); - if (Parser->isFilterBlit) - { - _Check2D(Parser); - } - break; - case 0x05: - case 0x06: - case 0x0C: - _CheckDraw(Parser); - break; - case 0x04: - _Check2D(Parser); - break; - default: - break; - } - - /* Advance to next command. */ - Parser->currentCmdBufferAddr = Parser->currentCmdBufferAddr - + (Parser->skipCount << 2); -} - -gceSTATUS -_InitializeContextBuffer( - IN gcTA_PARSER Context -) -{ - gctUINT32 index; - gcTA_HARDWARE hardware = Context->ta->hardware; - gctUINT32 pixelPipes = hardware->pixelPipes; - - gctUINT32 resolvePipes = hardware->resolvePipes; - gctINT i; - gctBOOL halti1; - - halti1 = (((((gctUINT32) (hardware->chipMinorFeatures2)) >> (0 ? 11:11)) & ((gctUINT32) ((((1 ? 11:11) - (0 ? 11:11) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 11:11) - (0 ? 11:11) + 1)))))) ); - - index = 0; - - /* 2D states. */ - index += _State(Context, index, 0x01200 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x0120C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x01204 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x01210 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x01214 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - - index += _State(Context, index, 0x01228 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x01234 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x0122C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - - index += _State(Context, index, 0x01294 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x012A8 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x012AC >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x01298 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x0129C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - - index += _State(Context, index, 0x12A00 >> 2, 0x00000000, 8, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x12A60 >> 2, 0x00000000, 8, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x12A20 >> 2, 0x00000000, 8, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x12A80 >> 2, 0x00000000, 8, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x12AA0 >> 2, 0x00000000, 8, gcvFALSE, gcvFALSE); - - index += _State(Context, index, 0x01308 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - - index += _State(Context, index, 0x12D60 >> 2, 0x00000000, 8, gcvFALSE, gcvFALSE); - - index += _State(Context, index, 0x01288 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x01290 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - - /* Resolve states. */ - index += _State(Context, index, 0x01608 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x01610 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - - if (resolvePipes > 1) - { - index += _State(Context, index, (0x016C0 >> 2) + (0 << 3), 0x00000000, resolvePipes, gcvFALSE, gcvTRUE); - index += _State(Context, index, (0x016E0 >> 2) + (0 << 3), 0x00000000, resolvePipes, gcvFALSE, gcvTRUE); - } - - index += _State(Context, index, 0x01620 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x0160C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x01614 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x0163C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x01604 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - - /* Draw states. */ - index += _State(Context, index, 0x0165C >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x00A00 >> 2, 0x00000000, 1, gcvTRUE, gcvFALSE); - index += _State(Context, index, 0x00A04 >> 2, 0x00000000, 1, gcvTRUE, gcvFALSE); - index += _State(Context, index, 0x00A0C >> 2, 0x00000000, 1, gcvTRUE, gcvFALSE); - index += _State(Context, index, 0x00A10 >> 2, 0x00000000, 1, gcvTRUE, gcvFALSE); - index += _State(Context, index, 0x01434 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - - if (pixelPipes == 1) - { - index += _State(Context, index, 0x01460 >> 2, 0x00000000, 8, gcvFALSE, gcvFALSE); - - index += _State(Context, index, 0x01430 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - index += _State(Context, index, 0x01410 >> 2, 0x00000000, 1, gcvFALSE, gcvFALSE); - } - else - { - index += _State(Context, index, (0x01460 >> 2) + (0 << 3), 0x00000000, pixelPipes, gcvFALSE, gcvTRUE); - index += _State(Context, index, (0x01480 >> 2) + (0 << 3), 0x00000000, pixelPipes, gcvFALSE, gcvTRUE); - - for (i = 0; i < 3; i++) - { - index += _State(Context, index, (0x01500 >> 2) + (i << 3), 0x00000000, pixelPipes, gcvFALSE, gcvTRUE); - } - } - - if (halti1) - { - gctUINT texBlockCount; - - texBlockCount = ((512) >> (4)); - - for (i = 0; i < texBlockCount; i += 1) - { - index += _State(Context, index, (0x10800 >> 2) + (i << 4), 0x00000000, 14, gcvFALSE, gcvTRUE); - } - } - else - { - index += _State(Context, index, (0x02400 >> 2) + (0 << 4), 0x00000000, 12, gcvFALSE, gcvTRUE); - index += _State(Context, index, (0x02440 >> 2) + (0 << 4), 0x00000000, 12, gcvFALSE, gcvTRUE); - index += _State(Context, index, (0x02480 >> 2) + (0 << 4), 0x00000000, 12, gcvFALSE, gcvTRUE); - index += _State(Context, index, (0x024C0 >> 2) + (0 << 4), 0x00000000, 12, gcvFALSE, gcvTRUE); - index += _State(Context, index, (0x02500 >> 2) + (0 << 4), 0x00000000, 12, gcvFALSE, gcvTRUE); - index += _State(Context, index, (0x02540 >> 2) + (0 << 4), 0x00000000, 12, gcvFALSE, gcvTRUE); - index += _State(Context, index, (0x02580 >> 2) + (0 << 4), 0x00000000, 12, gcvFALSE, gcvTRUE); - index += _State(Context, index, (0x025C0 >> 2) + (0 << 4), 0x00000000, 12, gcvFALSE, gcvTRUE); - index += _State(Context, index, (0x02600 >> 2) + (0 << 4), 0x00000000, 12, gcvFALSE, gcvTRUE); - index += _State(Context, index, (0x02640 >> 2) + (0 << 4), 0x00000000, 12, gcvFALSE, gcvTRUE); - index += _State(Context, index, (0x02680 >> 2) + (0 << 4), 0x00000000, 12, gcvFALSE, gcvTRUE); - index += _State(Context, index, (0x026C0 >> 2) + (0 << 4), 0x00000000, 12, gcvFALSE, gcvTRUE); - index += _State(Context, index, (0x02700 >> 2) + (0 << 4), 0x00000000, 12, gcvFALSE, gcvTRUE); - index += _State(Context, index, (0x02740 >> 2) + (0 << 4), 0x00000000, 12, gcvFALSE, gcvTRUE); - } - - - - Context->totalSize = index * gcmSIZEOF(gctUINT32); - - return gcvSTATUS_OK; -} - -gceSTATUS -gctaPARSER_Construct( - IN gcTA TA, - OUT gcTA_PARSER *Parser - ) -{ - gceSTATUS status; - gctPOINTER pointer; - gcTA_PARSER parser; - - gcmkONERROR(gctaOS_Allocate(gcmSIZEOF(gcsTA_PARSER), &pointer)); - - parser = (gcTA_PARSER)pointer; - - gctaOS_ZeroMemory(pointer, gcmSIZEOF(gcsTA_PARSER)); - - parser->ta = TA; - - gcmkONERROR(_InitializeContextBuffer(parser)); - - gcmkONERROR(gctaOS_Allocate( - parser->totalSize, - (gctPOINTER *)&parser->buffer - )); - - gcmkONERROR(gctaOS_Allocate( - parser->stateCount * gcmSIZEOF(gcsSTATE_MAP), - (gctPOINTER *)&parser->map)); - - gcmkONERROR(gctaOS_ZeroMemory( - (gctPOINTER)parser->map, - parser->stateCount * gcmSIZEOF(gcsSTATE_MAP) - )); - - gcmkONERROR(_InitializeContextBuffer(parser)); - - *Parser = parser; - - return gcvSTATUS_OK; - -OnError: - return status; -} - -/* -* Hardare layer. -*/ - -gceSTATUS -gctaHARDWARE_Link( - IN gcTA TA, - IN gctPOINTER Logical, - IN gctPOINTER FetchAddress, - IN gctSIZE_T FetchSize, - IN OUT gctSIZE_T * Bytes - ) -{ - gceSTATUS status; - gctSIZE_T bytes; - gctUINT32 address; - gctUINT32 link; - gctUINT32_PTR logical = (gctUINT32_PTR) Logical; - - gcmkHEADER_ARG("Logical=0x%x FetchAddress=0x%x FetchSize=%lu " - "*Bytes=%lu", - Logical, FetchAddress, FetchSize, - gcmOPT_VALUE(Bytes)); - - /* Verify the arguments. */ - - gcmkVERIFY_ARGUMENT((Logical == gcvNULL) || (Bytes != gcvNULL)); - - if (Logical != gcvNULL) - { - if (*Bytes < 8) - { - printf("XQ %s(%d) \n", __FUNCTION__, __LINE__); - /* Command queue too small. */ - gcmkONERROR(gcvSTATUS_BUFFER_TOO_SMALL); - } - - /* Convert logical address to hardware address. */ - gcmkONERROR( - gctaOS_GetPhysicalAddress(TA->os, FetchAddress, &address)); - - if (address == 0) - { - printf("XQ %s(%d) \n", __FUNCTION__, __LINE__); - } - - *(logical + 1) = address; - - gctaOS_CacheClean(logical + 1, 4); - - /* Compute number of 64-byte aligned bytes to fetch. */ - bytes = gcmALIGN(address + FetchSize, 64) - address; - - /* Append LINK(bytes / 8), FetchAddress. */ - link = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 31:27) - (0 ? - 31:27) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 31:27) - (0 ? - 31:27) + 1))))))) << (0 ? - 31:27))) | (((gctUINT32) (0x08 & ((gctUINT32) ((((1 ? - 31:27) - (0 ? - 31:27) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) - | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 15:0) - (0 ? - 15:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 15:0) - (0 ? - 15:0) + 1))))))) << (0 ? - 15:0))) | (((gctUINT32) ((gctUINT32) (bytes >> 3) & ((gctUINT32) ((((1 ? - 15:0) - (0 ? - 15:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))); - - *logical = link; - - gctaOS_CacheClean(logical, 4); - } - - if (Bytes != gcvNULL) - { - /* Return number of bytes required by the LINK command. */ - *Bytes = 8; - } - - /* Success. */ - gcmkFOOTER_ARG("*Bytes=%lu", gcmOPT_VALUE(Bytes)); - return gcvSTATUS_OK; - -OnError: - /* Return the status. */ - gcmkFOOTER(); - return status; -} - -gceSTATUS -gctaHARDWARE_WaitLink( - IN gcTA TA, - IN gctPOINTER Logical, - IN gctUINT32 Offset, - IN OUT gctSIZE_T * Bytes, - OUT gctUINT32 * WaitOffset - ) -{ - static const gctUINT waitCount = 200; - - gceSTATUS status; - gctUINT32 address; - gctUINT32_PTR logical; - gctSIZE_T bytes; - - gcmkHEADER_ARG("Logical=0x%x Offset=0x%08x *Bytes=%lu", - Logical, Offset, gcmOPT_VALUE(Bytes)); - - /* Verify the arguments. */ - gcmkVERIFY_ARGUMENT((Logical != gcvNULL) || (Bytes != gcvNULL)); - - /* Compute number of bytes required. */ - bytes = gcmALIGN(Offset + 16, 8) - Offset; - - /* Cast the input pointer. */ - logical = (gctUINT32_PTR) Logical; - - if (logical != gcvNULL) - { - /* Not enough space? */ - if (*Bytes < bytes) - { - /* Command queue too small. */ - gcmkONERROR(gcvSTATUS_BUFFER_TOO_SMALL); - } - - /* Convert logical into hardware specific address. */ - gcmkONERROR(gctaOS_GetPhysicalAddress(TA->os, logical, &address)); - - /* Append WAIT(count). */ - logical[0] - = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 31:27) - (0 ? - 31:27) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 31:27) - (0 ? - 31:27) + 1))))))) << (0 ? - 31:27))) | (((gctUINT32) (0x07 & ((gctUINT32) ((((1 ? - 31:27) - (0 ? - 31:27) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) - | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 15:0) - (0 ? - 15:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 15:0) - (0 ? - 15:0) + 1))))))) << (0 ? - 15:0))) | (((gctUINT32) ((gctUINT32) (waitCount) & ((gctUINT32) ((((1 ? - 15:0) - (0 ? - 15:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))); - - /* Append LINK(2, address). */ - logical[2] - = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 31:27) - (0 ? - 31:27) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 31:27) - (0 ? - 31:27) + 1))))))) << (0 ? - 31:27))) | (((gctUINT32) (0x08 & ((gctUINT32) ((((1 ? - 31:27) - (0 ? - 31:27) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) - | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 15:0) - (0 ? - 15:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 15:0) - (0 ? - 15:0) + 1))))))) << (0 ? - 15:0))) | (((gctUINT32) ((gctUINT32) (bytes >> 3) & ((gctUINT32) ((((1 ? - 15:0) - (0 ? - 15:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))); - - logical[3] = address; - - gcmkTRACE_ZONE( - gcvLEVEL_INFO, gcvZONE_HARDWARE, - "0x%08x: WAIT %u", address, waitCount - ); - - gcmkTRACE_ZONE( - gcvLEVEL_INFO, gcvZONE_HARDWARE, - "0x%08x: LINK 0x%08x, #%lu", - address + 8, address, bytes - ); - - if (WaitOffset != gcvNULL) - { - /* Return the offset pointer to WAIT command. */ - *WaitOffset = 0; - } - - } - - if (Bytes != gcvNULL) - { - /* Return number of bytes required by the WAIT/LINK command - ** sequence. */ - *Bytes = bytes; - } - - /* Success. */ - gcmkFOOTER_ARG("*Bytes=%lu *WaitOffset=0x%x", - gcmOPT_VALUE(Bytes), gcmOPT_VALUE(WaitOffset)); - return gcvSTATUS_OK; - -OnError: - /* Return the status. */ - gcmkFOOTER(); - return status; -} - -gceSTATUS -gctaHARDWARE_VerifyCommand( - IN gcTA TA, - IN gctUINT32 * CommandBuffer, - IN gctUINT32 Length, - OUT gctBOOL *Allow - ) -{ - gcTA_PARSER parser = TA->parser; - gctUINT8_PTR end = (gctUINT8_PTR)CommandBuffer + Length; - - /* Initialize parser. */ - parser->currentCmdBufferAddr = (gctUINT8_PTR)CommandBuffer; - parser->allow = gcvTRUE; - parser->isFilterBlit = gcvFALSE; - parser->skip = 0; - - /* Go through command buffer until reaching the end - ** or meeting illegal behavior. */ - do - { - _GetCommand(parser); - - _ParseCommand(parser); - } - while ((parser->currentCmdBufferAddr < end) && (parser->allow == gcvTRUE)); - - *Allow = parser->allow; - - return gcvSTATUS_OK; -} - -gceSTATUS -gctaHARDWARE_Execute( - IN gcTA TA, - IN gctPOINTER Logical, - IN gctSIZE_T Bytes - ) -{ - gceSTATUS status; - gctUINT32 address = 0, control; - - gcmkHEADER_ARG("Logical=0x%x Bytes=%lu", - Logical, Bytes); - - /* Verify the arguments. */ - gcmkVERIFY_ARGUMENT(Logical != gcvNULL); - - - /* Convert logical into hardware specific address. */ - gcmkONERROR( - gctaOS_GetPhysicalAddress(TA->os, Logical, &address)); - - - /* Enable all events. */ - gcmkONERROR( - gctaOS_WriteRegister(TA->os, 0x00014, ~0U)); - - /* Write address register. */ - gcmkONERROR( - gctaOS_WriteRegister(TA->os, 0x00654, address)); - - /* Build control register. */ - control = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 16:16) - (0 ? - 16:16) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 16:16) - (0 ? - 16:16) + 1))))))) << (0 ? - 16:16))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? - 16:16) - (0 ? - 16:16) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 16:16) - (0 ? 16:16) + 1))))))) << (0 ? 16:16))) - | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 15:0) - (0 ? - 15:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 15:0) - (0 ? - 15:0) + 1))))))) << (0 ? - 15:0))) | (((gctUINT32) ((gctUINT32) ((Bytes + 7) >> 3) & ((gctUINT32) ((((1 ? - 15:0) - (0 ? - 15:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))); - - - /* Write control register. */ - gcmkONERROR( - gctaOS_WriteRegister(TA->os, 0x00658, control)); - - gcmkTRACE_ZONE(gcvLEVEL_INFO, gcvZONE_HARDWARE, - "Started command buffer @ 0x%08x", - address); - - /* Success. */ - gcmkFOOTER_NO(); - return gcvSTATUS_OK; - -OnError: - /* Return the status. */ - gcmkFOOTER(); - return status; -} - -gceSTATUS -gctaHARDWARE_Fence( - gcTA TA, - gctPOINTER Logical, - gctPOINTER FenceAddress, - gctUINT32 * FenceBytes - ) -{ - gctUINT32_PTR logical = (gctUINT32_PTR) Logical; - gctUINT32 fencePhysical; - gctUINT32 bytes; - - gctBOOL only2D; - - only2D = gctaHARDWARE_IsFeatureAvailable(TA->hardware, gcvFEATURE_PIPE_2D) - && !gctaHARDWARE_IsFeatureAvailable(TA->hardware, gcvFEATURE_PIPE_3D); - - bytes = only2D - ? 20 * gcmSIZEOF(gctUINT32) - : 4 * gcmSIZEOF(gctUINT32); - - if (logical) - { - if (*FenceBytes < bytes) - { - return gcvSTATUS_BUFFER_TOO_SMALL; - } - - gctaOS_GetPhysicalAddress(TA->os, FenceAddress, &fencePhysical); - - if (only2D) - { - *logical++ - = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 31:27) - (0 ? - 31:27) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 31:27) - (0 ? - 31:27) + 1))))))) << (0 ? - 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? - 31:27) - (0 ? - 31:27) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) - | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 25:16) - (0 ? - 25:16) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 25:16) - (0 ? - 25:16) + 1))))))) << (0 ? - 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? - 25:16) - (0 ? - 25:16) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))) - | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 15:0) - (0 ? - 15:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 15:0) - (0 ? - 15:0) + 1))))))) << (0 ? - 15:0))) | (((gctUINT32) ((gctUINT32) (0x048A) & ((gctUINT32) ((((1 ? - 15:0) - (0 ? - 15:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))); - - *logical++ - = fencePhysical; - - *logical++ - = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 31:27) - (0 ? - 31:27) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 31:27) - (0 ? - 31:27) + 1))))))) << (0 ? - 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? - 31:27) - (0 ? - 31:27) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) - | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 25:16) - (0 ? - 25:16) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 25:16) - (0 ? - 25:16) + 1))))))) << (0 ? - 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? - 25:16) - (0 ? - 25:16) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))) - | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 15:0) - (0 ? - 15:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 15:0) - (0 ? - 15:0) + 1))))))) << (0 ? - 15:0))) | (((gctUINT32) ((gctUINT32) (0x04B0) & ((gctUINT32) ((((1 ? - 15:0) - (0 ? - 15:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))); - - *logical++ - = 0; - - *logical++ - = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 31:27) - (0 ? - 31:27) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 31:27) - (0 ? - 31:27) + 1))))))) << (0 ? - 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? - 31:27) - (0 ? - 31:27) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) - | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 25:16) - (0 ? - 25:16) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 25:16) - (0 ? - 25:16) + 1))))))) << (0 ? - 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? - 25:16) - (0 ? - 25:16) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))) - | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 15:0) - (0 ? - 15:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 15:0) - (0 ? - 15:0) + 1))))))) << (0 ? - 15:0))) | (((gctUINT32) ((gctUINT32) (0x048D) & ((gctUINT32) ((((1 ? - 15:0) - (0 ? - 15:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))); - - *logical++ - = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 29:29) - (0 ? - 29:29) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 29:29) - (0 ? - 29:29) + 1))))))) << (0 ? - 29:29))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? - 29:29) - (0 ? - 29:29) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 29:29) - (0 ? 29:29) + 1))))))) << (0 ? 29:29))) - | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 15:12) - (0 ? - 15:12) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 15:12) - (0 ? - 15:12) + 1))))))) << (0 ? - 15:12))) | (((gctUINT32) (0x0 & ((gctUINT32) ((((1 ? - 15:12) - (0 ? - 15:12) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 15:12) - (0 ? 15:12) + 1))))))) << (0 ? 15:12))); - - *logical++ - = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 31:27) - (0 ? - 31:27) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 31:27) - (0 ? - 31:27) + 1))))))) << (0 ? - 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? - 31:27) - (0 ? - 31:27) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) - | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 25:16) - (0 ? - 25:16) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 25:16) - (0 ? - 25:16) + 1))))))) << (0 ? - 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? - 25:16) - (0 ? - 25:16) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))) - | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 15:0) - (0 ? - 15:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 15:0) - (0 ? - 15:0) + 1))))))) << (0 ? - 15:0))) | (((gctUINT32) ((gctUINT32) (0x0497) & ((gctUINT32) ((((1 ? - 15:0) - (0 ? - 15:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))); - - *logical++ - = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 21:20) - (0 ? - 21:20) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 21:20) - (0 ? - 21:20) + 1))))))) << (0 ? - 21:20))) | (((gctUINT32) (0x3 & ((gctUINT32) ((((1 ? - 21:20) - (0 ? - 21:20) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 21:20) - (0 ? 21:20) + 1))))))) << (0 ? 21:20))) - | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 15:8) - (0 ? - 15:8) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 15:8) - (0 ? - 15:8) + 1))))))) << (0 ? - 15:8))) | (((gctUINT32) ((gctUINT32) (0xCC) & ((gctUINT32) ((((1 ? - 15:8) - (0 ? - 15:8) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 15:8) - (0 ? 15:8) + 1))))))) << (0 ? 15:8))) - | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 7:0) - (0 ? - 7:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 7:0) - (0 ? - 7:0) + 1))))))) << (0 ? - 7:0))) | (((gctUINT32) ((gctUINT32) (0xCC) & ((gctUINT32) ((((1 ? - 7:0) - (0 ? - 7:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 7:0) - (0 ? 7:0) + 1))))))) << (0 ? 7:0))); - - *logical++ - = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 31:27) - (0 ? - 31:27) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 31:27) - (0 ? - 31:27) + 1))))))) << (0 ? - 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? - 31:27) - (0 ? - 31:27) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) - | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 25:16) - (0 ? - 25:16) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 25:16) - (0 ? - 25:16) + 1))))))) << (0 ? - 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? - 25:16) - (0 ? - 25:16) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))) - | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 15:0) - (0 ? - 15:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 15:0) - (0 ? - 15:0) + 1))))))) << (0 ? - 15:0))) | (((gctUINT32) ((gctUINT32) (0x049F) & ((gctUINT32) ((((1 ? - 15:0) - (0 ? - 15:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))); - - *logical++ - = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 0:0) - (0 ? - 0:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 0:0) - (0 ? - 0:0) + 1))))))) << (0 ? - 0:0))) | (((gctUINT32) (0x0 & ((gctUINT32) ((((1 ? - 0:0) - (0 ? - 0:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 0:0) - (0 ? 0:0) + 1))))))) << (0 ? 0:0))); - - *logical++ - = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 31:27) - (0 ? - 31:27) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 31:27) - (0 ? - 31:27) + 1))))))) << (0 ? - 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? - 31:27) - (0 ? - 31:27) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) - | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 25:16) - (0 ? - 25:16) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 25:16) - (0 ? - 25:16) + 1))))))) << (0 ? - 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? - 25:16) - (0 ? - 25:16) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))) - | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 15:0) - (0 ? - 15:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 15:0) - (0 ? - 15:0) + 1))))))) << (0 ? - 15:0))) | (((gctUINT32) ((gctUINT32) (0x4B40) & ((gctUINT32) ((((1 ? - 15:0) - (0 ? - 15:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))); - - *logical++ - = 0; - - *logical++ - = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 31:27) - (0 ? - 31:27) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 31:27) - (0 ? - 31:27) + 1))))))) << (0 ? - 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? - 31:27) - (0 ? - 31:27) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) - | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 25:16) - (0 ? - 25:16) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 25:16) - (0 ? - 25:16) + 1))))))) << (0 ? - 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? - 25:16) - (0 ? - 25:16) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))) - | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 15:0) - (0 ? - 15:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 15:0) - (0 ? - 15:0) + 1))))))) << (0 ? - 15:0))) | (((gctUINT32) ((gctUINT32) (0x0499) & ((gctUINT32) ((((1 ? - 15:0) - (0 ? - 15:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))); - - *logical++ - = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 14:0) - (0 ? - 14:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 14:0) - (0 ? - 14:0) + 1))))))) << (0 ? - 14:0))) | (((gctUINT32) ((gctUINT32) (16) & ((gctUINT32) ((((1 ? - 14:0) - (0 ? - 14:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 14:0) - (0 ? 14:0) + 1))))))) << (0 ? 14:0))) - | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 30:16) - (0 ? - 30:16) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 30:16) - (0 ? - 30:16) + 1))))))) << (0 ? - 30:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? - 30:16) - (0 ? - 30:16) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 30:16) - (0 ? 30:16) + 1))))))) << (0 ? 30:16))); - - *logical++ - = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 31:27) - (0 ? - 31:27) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 31:27) - (0 ? - 31:27) + 1))))))) << (0 ? - 31:27))) | (((gctUINT32) (0x04 & ((gctUINT32) ((((1 ? - 31:27) - (0 ? - 31:27) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) - | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 15:8) - (0 ? - 15:8) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 15:8) - (0 ? - 15:8) + 1))))))) << (0 ? - 15:8))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? - 15:8) - (0 ? - 15:8) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 15:8) - (0 ? 15:8) + 1))))))) << (0 ? 15:8))); - - *logical++ - = 0; - - *logical++ - = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 15:0) - (0 ? - 15:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 15:0) - (0 ? - 15:0) + 1))))))) << (0 ? - 15:0))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? - 15:0) - (0 ? - 15:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) - | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 31:16) - (0 ? - 31:16) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 31:16) - (0 ? - 31:16) + 1))))))) << (0 ? - 31:16))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? - 31:16) - (0 ? - 31:16) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 31:16) - (0 ? 31:16) + 1))))))) << (0 ? 31:16))); - - *logical++ - = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 15:0) - (0 ? - 15:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 15:0) - (0 ? - 15:0) + 1))))))) << (0 ? - 15:0))) | (((gctUINT32) ((gctUINT32) (16) & ((gctUINT32) ((((1 ? - 15:0) - (0 ? - 15:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) - | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 31:16) - (0 ? - 31:16) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 31:16) - (0 ? - 31:16) + 1))))))) << (0 ? - 31:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? - 31:16) - (0 ? - 31:16) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 31:16) - (0 ? 31:16) + 1))))))) << (0 ? 31:16))); - - *logical++ - = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 31:27) - (0 ? - 31:27) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 31:27) - (0 ? - 31:27) + 1))))))) << (0 ? - 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? - 31:27) - (0 ? - 31:27) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) - | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 15:0) - (0 ? - 15:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 15:0) - (0 ? - 15:0) + 1))))))) << (0 ? - 15:0))) | (((gctUINT32) ((gctUINT32) (0x0E03) & ((gctUINT32) ((((1 ? - 15:0) - (0 ? - 15:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) - | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 25:16) - (0 ? - 25:16) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 25:16) - (0 ? - 25:16) + 1))))))) << (0 ? - 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? - 25:16) - (0 ? - 25:16) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); - - *logical++ - = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 3:3) - (0 ? - 3:3) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 3:3) - (0 ? - 3:3) + 1))))))) << (0 ? - 3:3))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? - 3:3) - (0 ? - 3:3) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 3:3) - (0 ? 3:3) + 1))))))) << (0 ? 3:3))); - } - else - { - *logical++ - = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 31:27) - (0 ? - 31:27) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 31:27) - (0 ? - 31:27) + 1))))))) << (0 ? - 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? - 31:27) - (0 ? - 31:27) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) - | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 25:16) - (0 ? - 25:16) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 25:16) - (0 ? - 25:16) + 1))))))) << (0 ? - 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? - 25:16) - (0 ? - 25:16) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))) - | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 15:0) - (0 ? - 15:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 15:0) - (0 ? - 15:0) + 1))))))) << (0 ? - 15:0))) | (((gctUINT32) ((gctUINT32) (0x0E09) & ((gctUINT32) ((((1 ? - 15:0) - (0 ? - 15:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))); - - *logical++ - = fencePhysical; - - *logical++ - = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 31:27) - (0 ? - 31:27) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 31:27) - (0 ? - 31:27) + 1))))))) << (0 ? - 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? - 31:27) - (0 ? - 31:27) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) - | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 25:16) - (0 ? - 25:16) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 25:16) - (0 ? - 25:16) + 1))))))) << (0 ? - 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? - 25:16) - (0 ? - 25:16) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))) - | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 15:0) - (0 ? - 15:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 15:0) - (0 ? - 15:0) + 1))))))) << (0 ? - 15:0))) | (((gctUINT32) ((gctUINT32) (0x0E0C) & ((gctUINT32) ((((1 ? - 15:0) - (0 ? - 15:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))); - - *logical++ - = 0; - } - } - - if (FenceBytes) - { - *FenceBytes = bytes; - } - - return gcvSTATUS_OK; -} - -gceSTATUS -gctaHARDWARE_Construct( - IN gcTA TA, - OUT gcTA_HARDWARE * Hardware - ) -{ - gceSTATUS status; - - gcTA_HARDWARE hardware; - - gctaOS os = TA->os; - gctUINT32 specs; - - gcmkONERROR(gctaOS_Allocate( - gcmSIZEOF(gcsTA_HARDWARE), - (gctPOINTER *)&hardware - )); - - hardware->ta = TA; - - /*************************************/ - /******** Get chip information ******/ - /*************************************/ - - /* Read chip feature register. */ - gcmkONERROR(gctaOS_ReadRegister(os, 0x0001C, &hardware->chipFeatures)); - - /* Read chip minor featuress register #1. */ - gcmkONERROR( - gctaOS_ReadRegister(os, - 0x00074, - &hardware->chipMinorFeatures1)); - - /* Read chip minor featuress register #2. */ - gcmkONERROR( - gctaOS_ReadRegister(os, - 0x00084, - &hardware->chipMinorFeatures2)); - - /* Read chip minor featuress register #3. */ - gcmkONERROR( - gctaOS_ReadRegister(os, - 0x00088, - &hardware->chipMinorFeatures3)); - - /* Read gcChipSpecs register. */ - gcmkONERROR(gctaOS_ReadRegister(os, 0x00048, &specs)); - - hardware->pixelPipes = gcmMAX((((((gctUINT32) (specs)) >> (0 ? 27:25)) & ((gctUINT32) ((((1 ? 27:25) - (0 ? 27:25) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 27:25) - (0 ? 27:25) + 1)))))) ), 1); - - hardware->resolvePipes = hardware->pixelPipes; - - *Hardware = hardware; - - return gcvSTATUS_OK; -OnError: - return status; -} - -gceSTATUS -gctaHARDWARE_IsFeatureAvailable( - IN gcTA_HARDWARE Hardware, - IN gceFEATURE Feature - ) -{ - gctBOOL available; - - gcmkHEADER_ARG("Hardware=0x%x Feature=%d", Hardware, Feature); - - /* Only features needed by common kernel logic added here. */ - switch (Feature) - { - case gcvFEATURE_PIPE_2D: - available = ((((gctUINT32) (Hardware->chipFeatures)) >> (0 ? - 9:9) & ((gctUINT32) ((((1 ? - 9:9) - (0 ? - 9:9) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 9:9) - (0 ? - 9:9) + 1)))))) == (0x1 & ((gctUINT32) ((((1 ? - 9:9) - (0 ? - 9:9) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 9:9) - (0 ? 9:9) + 1))))))); - break; - - case gcvFEATURE_PIPE_3D: - available = ((((gctUINT32) (Hardware->chipFeatures)) >> (0 ? - 2:2) & ((gctUINT32) ((((1 ? - 2:2) - (0 ? - 2:2) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 2:2) - (0 ? - 2:2) + 1)))))) == (0x1 & ((gctUINT32) ((((1 ? - 2:2) - (0 ? - 2:2) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 2:2) - (0 ? 2:2) + 1))))))); - break; - - default: - gcmkFATAL("Invalid feature has been requested."); - available = gcvFALSE; - } - - /* Return result. */ - gcmkFOOTER_ARG("%d", available ? gcvSTATUS_TRUE : gcvSTATUS_OK); - return available ? gcvSTATUS_TRUE : gcvSTATUS_OK; -} - -gceSTATUS -gctaHARDWARE_MMU( - IN gcTA_HARDWARE Hardware, - IN gctPOINTER Logical, - IN gctUINT32 MtlbAddress, - IN gctUINT32 SafeAddress, - OUT gctUINT32 *Bytes - ) -{ - gctUINT32_PTR logical = (gctUINT32_PTR)Logical; - gctUINT32 config; - - gctUINT32 bytes; - - bytes = 4 * gcmSIZEOF(gctUINT32); - - if (logical) - { - config = MtlbAddress - | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 0:0) - (0 ? - 0:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 0:0) - (0 ? - 0:0) + 1))))))) << (0 ? - 0:0))) | (((gctUINT32) (0x0 & ((gctUINT32) ((((1 ? - 0:0) - (0 ? - 0:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 0:0) - (0 ? 0:0) + 1))))))) << (0 ? 0:0))); - - *logical++ - = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 31:27) - (0 ? - 31:27) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 31:27) - (0 ? - 31:27) + 1))))))) << (0 ? - 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? - 31:27) - (0 ? - 31:27) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) - | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 15:0) - (0 ? - 15:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 15:0) - (0 ? - 15:0) + 1))))))) << (0 ? - 15:0))) | (((gctUINT32) ((gctUINT32) (0x0061) & ((gctUINT32) ((((1 ? - 15:0) - (0 ? - 15:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) - | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 25:16) - (0 ? - 25:16) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 25:16) - (0 ? - 25:16) + 1))))))) << (0 ? - 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? - 25:16) - (0 ? - 25:16) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); - - *logical++ - = config; - - *logical++ - = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 31:27) - (0 ? - 31:27) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 31:27) - (0 ? - 31:27) + 1))))))) << (0 ? - 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? - 31:27) - (0 ? - 31:27) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) - | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 15:0) - (0 ? - 15:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 15:0) - (0 ? - 15:0) + 1))))))) << (0 ? - 15:0))) | (((gctUINT32) ((gctUINT32) (0x0060) & ((gctUINT32) ((((1 ? - 15:0) - (0 ? - 15:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) - | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 25:16) - (0 ? - 25:16) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 25:16) - (0 ? - 25:16) + 1))))))) << (0 ? - 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? - 25:16) - (0 ? - 25:16) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); - - *logical++ - = SafeAddress; - } - - if (Bytes) - { - *Bytes = bytes; - } - - return gcvSTATUS_OK; -} - -gceSTATUS -gctaHARDWARE_MmuEnable( - IN gcTA_HARDWARE Hardware - ) -{ - gctaOS_WriteRegister( - Hardware->ta->os, - 0x0018C, - ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 0:0) - (0 ? - 0:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 0:0) - (0 ? - 0:0) + 1))))))) << (0 ? - 0:0))) | (((gctUINT32) ((gctUINT32) (1 ) & ((gctUINT32) ((((1 ? - 0:0) - (0 ? - 0:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 0:0) - (0 ? 0:0) + 1))))))) << (0 ? 0:0)))); - - return gcvSTATUS_OK; -} - -gceSTATUS -gctaHARDWARE_FlushMMU( - IN gcTA_HARDWARE Hardware, - IN gctPOINTER Logical, - OUT gctUINT32 *Bytes - ) -{ - gctUINT32_PTR logical = (gctUINT32_PTR) Logical; - - gctUINT32 bytes = 10 * gcmSIZEOF(gctUINT32); - - if (logical) - { - /* Arm the PE-FE Semaphore. */ - *logical++ - = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 31:27) - (0 ? - 31:27) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 31:27) - (0 ? - 31:27) + 1))))))) << (0 ? - 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? - 31:27) - (0 ? - 31:27) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) - | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 25:16) - (0 ? - 25:16) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 25:16) - (0 ? - 25:16) + 1))))))) << (0 ? - 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? - 25:16) - (0 ? - 25:16) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))) - | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 15:0) - (0 ? - 15:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 15:0) - (0 ? - 15:0) + 1))))))) << (0 ? - 15:0))) | (((gctUINT32) ((gctUINT32) (0x0E02) & ((gctUINT32) ((((1 ? - 15:0) - (0 ? - 15:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))); - - *logical++ - = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 4:0) - (0 ? - 4:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 4:0) - (0 ? - 4:0) + 1))))))) << (0 ? - 4:0))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? - 4:0) - (0 ? - 4:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 4:0) - (0 ? 4:0) + 1))))))) << (0 ? 4:0))) - | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 12:8) - (0 ? - 12:8) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 12:8) - (0 ? - 12:8) + 1))))))) << (0 ? - 12:8))) | (((gctUINT32) (0x07 & ((gctUINT32) ((((1 ? - 12:8) - (0 ? - 12:8) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 12:8) - (0 ? 12:8) + 1))))))) << (0 ? 12:8))); - - /* STALL FE until PE is done flushing. */ - *logical++ - = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 31:27) - (0 ? - 31:27) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 31:27) - (0 ? - 31:27) + 1))))))) << (0 ? - 31:27))) | (((gctUINT32) (0x09 & ((gctUINT32) ((((1 ? - 31:27) - (0 ? - 31:27) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))); - - *logical++ - = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 4:0) - (0 ? - 4:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 4:0) - (0 ? - 4:0) + 1))))))) << (0 ? - 4:0))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? - 4:0) - (0 ? - 4:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 4:0) - (0 ? 4:0) + 1))))))) << (0 ? 4:0))) - | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 12:8) - (0 ? - 12:8) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 12:8) - (0 ? - 12:8) + 1))))))) << (0 ? - 12:8))) | (((gctUINT32) (0x07 & ((gctUINT32) ((((1 ? - 12:8) - (0 ? - 12:8) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 12:8) - (0 ? 12:8) + 1))))))) << (0 ? 12:8))); - - - /* Flush MMU cache. */ - *logical++ - = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 31:27) - (0 ? - 31:27) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 31:27) - (0 ? - 31:27) + 1))))))) << (0 ? - 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? - 31:27) - (0 ? - 31:27) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) - | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 15:0) - (0 ? - 15:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 15:0) - (0 ? - 15:0) + 1))))))) << (0 ? - 15:0))) | (((gctUINT32) ((gctUINT32) (0x0061) & ((gctUINT32) ((((1 ? - 15:0) - (0 ? - 15:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) - | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 25:16) - (0 ? - 25:16) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 25:16) - (0 ? - 25:16) + 1))))))) << (0 ? - 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? - 25:16) - (0 ? - 25:16) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))); - - *logical++ - = (((((gctUINT32) (~0U)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 4:4) - (0 ? - 4:4) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 4:4) - (0 ? - 4:4) + 1))))))) << (0 ? - 4:4))) | (((gctUINT32) (0x1 & ((gctUINT32) ((((1 ? - 4:4) - (0 ? - 4:4) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 4:4) - (0 ? - 4:4) + 1))))))) << (0 ? - 4:4))) & ((((gctUINT32) (~0U)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 7:7) - (0 ? - 7:7) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 7:7) - (0 ? - 7:7) + 1))))))) << (0 ? - 7:7))) | (((gctUINT32) (0x0 & ((gctUINT32) ((((1 ? - 7:7) - (0 ? - 7:7) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 7:7) - (0 ? 7:7) + 1))))))) << (0 ? 7:7)))); - - *logical++ - = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 31:27) - (0 ? - 31:27) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 31:27) - (0 ? - 31:27) + 1))))))) << (0 ? - 31:27))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? - 31:27) - (0 ? - 31:27) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) - | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 25:16) - (0 ? - 25:16) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 25:16) - (0 ? - 25:16) + 1))))))) << (0 ? - 25:16))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? - 25:16) - (0 ? - 25:16) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))) - | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 15:0) - (0 ? - 15:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 15:0) - (0 ? - 15:0) + 1))))))) << (0 ? - 15:0))) | (((gctUINT32) ((gctUINT32) (0x0E02) & ((gctUINT32) ((((1 ? - 15:0) - (0 ? - 15:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))); - - *logical++ - = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 4:0) - (0 ? - 4:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 4:0) - (0 ? - 4:0) + 1))))))) << (0 ? - 4:0))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? - 4:0) - (0 ? - 4:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 4:0) - (0 ? 4:0) + 1))))))) << (0 ? 4:0))) - | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 12:8) - (0 ? - 12:8) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 12:8) - (0 ? - 12:8) + 1))))))) << (0 ? - 12:8))) | (((gctUINT32) (0x07 & ((gctUINT32) ((((1 ? - 12:8) - (0 ? - 12:8) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 12:8) - (0 ? 12:8) + 1))))))) << (0 ? 12:8))); - - /* STALL FE until PE is done flushing. */ - *logical++ - = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 31:27) - (0 ? - 31:27) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 31:27) - (0 ? - 31:27) + 1))))))) << (0 ? - 31:27))) | (((gctUINT32) (0x09 & ((gctUINT32) ((((1 ? - 31:27) - (0 ? - 31:27) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))); - - *logical++ - = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 4:0) - (0 ? - 4:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 4:0) - (0 ? - 4:0) + 1))))))) << (0 ? - 4:0))) | (((gctUINT32) (0x01 & ((gctUINT32) ((((1 ? - 4:0) - (0 ? - 4:0) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 4:0) - (0 ? 4:0) + 1))))))) << (0 ? 4:0))) - | ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 12:8) - (0 ? - 12:8) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 12:8) - (0 ? - 12:8) + 1))))))) << (0 ? - 12:8))) | (((gctUINT32) (0x07 & ((gctUINT32) ((((1 ? - 12:8) - (0 ? - 12:8) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 12:8) - (0 ? 12:8) + 1))))))) << (0 ? 12:8))); - } - - if (Bytes) - { - *Bytes = bytes; - } - - return gcvSTATUS_OK; -} - -gceSTATUS -gctaHARDWARE_End( - IN gcTA_HARDWARE Hardware, - IN gctPOINTER Logical, - IN OUT gctUINT32 * Bytes - ) -{ - gctUINT32_PTR logical = (gctUINT32_PTR) Logical; - gceSTATUS status; - - gcmkHEADER_ARG("Hardware=0x%x Logical=0x%x *Bytes=%lu", - Hardware, Logical, gcmOPT_VALUE(Bytes)); - - /* Verify the arguments. */ - /* gcmkVERIFY_OBJECT(Hardware, gcvOBJ_HARDWARE); */ - gcmkVERIFY_ARGUMENT((Logical == gcvNULL) || (Bytes != gcvNULL)); - - if (Logical != gcvNULL) - { - if (*Bytes < 8) - { - /* Command queue too small. */ - gcmkONERROR(gcvSTATUS_BUFFER_TOO_SMALL); - } - - /* Append END. */ - logical[0] = - ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 31:27) - (0 ? - 31:27) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 31:27) - (0 ? - 31:27) + 1))))))) << (0 ? - 31:27))) | (((gctUINT32) (0x02 & ((gctUINT32) ((((1 ? - 31:27) - (0 ? - 31:27) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))); - - gcmkTRACE_ZONE(gcvLEVEL_INFO, gcvZONE_HARDWARE, "0x%x: END", Logical); - - } - - if (Bytes != gcvNULL) - { - /* Return number of bytes required by the END command. */ - *Bytes = 8; - } - - /* Success. */ - gcmkFOOTER_ARG("*Bytes=%lu", gcmOPT_VALUE(Bytes)); - return gcvSTATUS_OK; - -OnError: - /* Return the status. */ - gcmkFOOTER(); - return status; -} - -gceSTATUS -gctaHARDWARE_Nop( - IN gcTA_HARDWARE Hardware, - IN gctPOINTER Logical, - IN OUT gctSIZE_T * Bytes - ) -{ - gctUINT32_PTR logical = (gctUINT32_PTR) Logical; - gceSTATUS status; - - gcmkHEADER_ARG("Hardware=0x%x Logical=0x%x *Bytes=%lu", - Hardware, Logical, gcmOPT_VALUE(Bytes)); - - /* Verify the arguments. */ - /* gcmkVERIFY_OBJECT(Hardware, gcvOBJ_HARDWARE); */ - gcmkVERIFY_ARGUMENT((Logical == gcvNULL) || (Bytes != gcvNULL)); - - if (Logical != gcvNULL) - { - if (*Bytes < 8) - { - /* Command queue too small. */ - gcmkONERROR(gcvSTATUS_BUFFER_TOO_SMALL); - } - - /* Append NOP. */ - logical[0] = ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? - 31:27) - (0 ? - 31:27) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? - 31:27) - (0 ? - 31:27) + 1))))))) << (0 ? - 31:27))) | (((gctUINT32) (0x03 & ((gctUINT32) ((((1 ? - 31:27) - (0 ? - 31:27) + 1) == 32) ? - ~0U : (~(~0U << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))); - - gcmkTRACE_ZONE(gcvLEVEL_INFO, gcvZONE_HARDWARE, "0x%x: NOP", Logical); - } - - if (Bytes != gcvNULL) - { - /* Return number of bytes required by the NOP command. */ - *Bytes = 8; - } - - /* Success. */ - gcmkFOOTER_ARG("*Bytes=%lu", gcmOPT_VALUE(Bytes)); - return gcvSTATUS_OK; - -OnError: - /* Return the status. */ - gcmkFOOTER(); - return status; -} - - diff --git a/drivers/amlogic/npu/security/gc_hal_ta_mmu.c b/drivers/amlogic/npu/security/gc_hal_ta_mmu.c deleted file mode 100644 index ec9f2e3..0000000 --- a/drivers/amlogic/npu/security/gc_hal_ta_mmu.c +++ /dev/null @@ -1,1018 +0,0 @@ -/**************************************************************************** -* -* Copyright (c) 2005 - 2019 by Vivante Corp. All rights reserved. -* -* The material in this file is confidential and contains trade secrets -* of Vivante Corporation. This is proprietary information owned by -* Vivante Corporation. No part of this work may be disclosed, -* reproduced, copied, transmitted, or used in any way for any purpose, -* without the express written permission of Vivante Corporation. -* -*****************************************************************************/ - - -#include "gc_hal_types.h" -#include "gc_hal_base.h" -#include "gc_hal_security_interface.h" -#include "gc_hal_ta.h" -#include "gc_hal.h" - -#define _GC_OBJ_ZONE 2 -/******************************************************************************* -************************************ Define ************************************ -********************************************************************************/ - -#define gcdMMU_MTLB_SHIFT 22 -#define gcdMMU_STLB_4K_SHIFT 12 -#define gcdMMU_STLB_64K_SHIFT 16 - -#define gcdMMU_MTLB_BITS (32 - gcdMMU_MTLB_SHIFT) -#define gcdMMU_PAGE_4K_BITS gcdMMU_STLB_4K_SHIFT -#define gcdMMU_STLB_4K_BITS (32 - gcdMMU_MTLB_BITS - gcdMMU_PAGE_4K_BITS) -#define gcdMMU_PAGE_64K_BITS gcdMMU_STLB_64K_SHIFT -#define gcdMMU_STLB_64K_BITS (32 - gcdMMU_MTLB_BITS - gcdMMU_PAGE_64K_BITS) - -#define gcdMMU_MTLB_ENTRY_NUM (1 << gcdMMU_MTLB_BITS) -#define gcdMMU_MTLB_SIZE (gcdMMU_MTLB_ENTRY_NUM << 2) -#define gcdMMU_STLB_4K_ENTRY_NUM (1 << gcdMMU_STLB_4K_BITS) -#define gcdMMU_STLB_4K_SIZE (gcdMMU_STLB_4K_ENTRY_NUM << 2) -#define gcdMMU_PAGE_4K_SIZE (1 << gcdMMU_STLB_4K_SHIFT) -#define gcdMMU_STLB_64K_ENTRY_NUM (1 << gcdMMU_STLB_64K_BITS) -#define gcdMMU_STLB_64K_SIZE (gcdMMU_STLB_64K_ENTRY_NUM << 2) -#define gcdMMU_PAGE_64K_SIZE (1 << gcdMMU_STLB_64K_SHIFT) - -#define gcdMMU_MTLB_MASK (~((1U << gcdMMU_MTLB_SHIFT)-1)) -#define gcdMMU_STLB_4K_MASK ((~0U << gcdMMU_STLB_4K_SHIFT) ^ gcdMMU_MTLB_MASK) -#define gcdMMU_PAGE_4K_MASK (gcdMMU_PAGE_4K_SIZE - 1) -#define gcdMMU_STLB_64K_MASK ((~((1U << gcdMMU_STLB_64K_SHIFT)-1)) ^ gcdMMU_MTLB_MASK) -#define gcdMMU_PAGE_64K_MASK (gcdMMU_PAGE_64K_SIZE - 1) - -/* Page offset definitions. */ -#define gcdMMU_OFFSET_4K_BITS (32 - gcdMMU_MTLB_BITS - gcdMMU_STLB_4K_BITS) -#define gcdMMU_OFFSET_4K_MASK ((1U << gcdMMU_OFFSET_4K_BITS) - 1) -#define gcdMMU_OFFSET_64K_BITS (32 - gcdMMU_MTLB_BITS - gcdMMU_STLB_64K_BITS) -#define gcdMMU_OFFSET_64K_MASK ((1U << gcdMMU_OFFSET_64K_BITS) - 1) - -#define gcdMMU_MTLB_PRESENT 0x00000001 -#define gcdMMU_MTLB_EXCEPTION 0x00000002 -#define gcdMMU_MTLB_4K_PAGE (0 << 2) - -#define gcdMMU_STLB_PRESENT 0x00000001 -#define gcdMMU_STLB_EXCEPTION 0x00000002 -#define gcdMMU_STLB_SECURITY (1 << 4) - -#define gcdUSE_MMU_EXCEPTION 1 - -typedef enum _gceMMU_TYPE -{ - gcvMMU_USED = (0 << 4), - gcvMMU_SINGLE = (1 << 4), - gcvMMU_FREE = (2 << 4), -} -gceMMU_TYPE; - -#define gcmENTRY_TYPE(x) (x & 0xF0) -/* -* We need flat mapping ta command buffer. - -*/ - -/* -* Helper -*/ -gctUINT32 -_AddressToIndex( - IN gcTA_MMU Mmu, - IN gctUINT32 Address - ) -{ - gctUINT32 mtlbOffset = (Address & gcdMMU_MTLB_MASK) >> gcdMMU_MTLB_SHIFT; - gctUINT32 stlbOffset = (Address & gcdMMU_STLB_4K_MASK) >> gcdMMU_STLB_4K_SHIFT; - - return (mtlbOffset - Mmu->dynamicMappingStart) * gcdMMU_STLB_4K_ENTRY_NUM + stlbOffset; -} - -gctUINT32 -_MtlbOffset( - gctUINT32 Address - ) -{ - return (Address & gcdMMU_MTLB_MASK) >> gcdMMU_MTLB_SHIFT; -} - -gctUINT32 -_StlbOffset( - gctUINT32 Address - ) -{ - return (Address & gcdMMU_STLB_4K_MASK) >> gcdMMU_STLB_4K_SHIFT; -} - -static gctUINT32 -_SetPage(gctUINT32 PageAddress) -{ - return PageAddress - /* writable */ - | (1 << 2) - /* Ignore exception */ - | (0 << 1) - /* Present */ - | (1 << 0); -} - -static void -_WritePageEntry( - IN gctUINT32_PTR PageEntry, - IN gctUINT32 EntryValue - ) -{ - *PageEntry = EntryValue; - - gctaOS_CacheClean(PageEntry, gcmSIZEOF(gctUINT32)); -} - -static gctUINT32 -_ReadPageEntry( - IN gctUINT32_PTR PageEntry - ) -{ - return *PageEntry; -} - -static gceSTATUS -_FillPageTable( - IN gctUINT32_PTR PageTable, - IN gctUINT32 PageCount, - IN gctUINT32 EntryValue -) -{ - gctUINT i; - - for (i = 0; i < PageCount; i++) - { - _WritePageEntry(PageTable + i, EntryValue); - } - - return gcvSTATUS_OK; -} - - -static gceSTATUS -_AllocateStlb( - IN gctaOS Os, - OUT gcsMMU_STLB_PTR *Stlb - ) -{ - gceSTATUS status; - gcsMMU_STLB_PTR stlb; - gctPOINTER pointer; - - /* Allocate slave TLB record. */ - gcmkONERROR(gctaOS_Allocate(gcmSIZEOF(gcsMMU_STLB), &pointer)); - stlb = pointer; - - stlb->size = gcdMMU_STLB_4K_SIZE; - - /* Allocate slave TLB entries. */ - gcmkONERROR(gctaOS_AllocateSecurityMemory( - Os, - &stlb->size, - &stlb->logical, - &stlb->physical - )); - - gcmkONERROR(gctaOS_GetPhysicalAddress(Os, stlb->logical, &stlb->physBase)); - -#if gcdUSE_MMU_EXCEPTION - _FillPageTable(stlb->logical, stlb->size / 4, gcdMMU_STLB_EXCEPTION); -#else - gctaOS_ZeroMemory(stlb->logical, stlb->size); -#endif - - *Stlb = stlb; - - return gcvSTATUS_OK; - -OnError: - return status; -} - - -gceSTATUS -_SetupProcessAddressSpace( - IN gcTA_MMU Mmu - ) -{ - gceSTATUS status; - gctINT numEntries = 0; - gctUINT32_PTR map; - gctUINT32 flatmappingEntries; - gctUINT32 free; - gctUINT32 i = 0; - - numEntries = 1024; - - Mmu->dynamicMappingStart = 0; - - Mmu->pageTableSize = numEntries * 4096; - - Mmu->pageTableEntries = Mmu->pageTableSize / gcmSIZEOF(gctUINT32); - - gcmkONERROR(gctaOS_Allocate( - Mmu->pageTableSize, - (void **)&Mmu->mapLogical - )); - - /* Initilization. */ - map = Mmu->mapLogical; - - flatmappingEntries = Mmu->pageTableEntries / 2; - - map += flatmappingEntries; - free = Mmu->pageTableEntries - flatmappingEntries; - - _WritePageEntry(map, (free << 8) | gcvMMU_FREE); - _WritePageEntry(map + 1, ~0U); - - gctaOS_ZeroMemory(Mmu->mtlbLogical, flatmappingEntries * 4); - - Mmu->heapList = flatmappingEntries; - Mmu->freeNodes = gcvFALSE; - - for (i = 0; i < numEntries; i++) - { - gctUINT32 mtlbEntry; - struct _gcsMMU_STLB *stlb; - struct _gcsMMU_STLB **stlbs = (struct _gcsMMU_STLB **)Mmu->stlbs; - - gcmkONERROR(_AllocateStlb(Mmu->os, &stlb)); - - mtlbEntry = stlb->physBase - | gcdMMU_MTLB_4K_PAGE - | gcdMMU_MTLB_PRESENT - ; - - /* Insert Slave TLB address to Master TLB entry.*/ - _WritePageEntry((gctUINT32_PTR)Mmu->mtlbLogical + i, mtlbEntry); - - /* Record stlb. */ - stlbs[i] = stlb; - } - - return gcvSTATUS_OK; - -OnError: - return status; -} - - -/* -* Address space management -*/ - -static gceSTATUS -_Link( - IN gcTA_MMU Mmu, - IN gctUINT32 Index, - IN gctUINT32 Next - ) -{ - if (Index >= Mmu->pageTableEntries) - { - printf("XQ %s(%d) \n", __FUNCTION__, __LINE__); - /* Just move heap pointer. */ - Mmu->heapList = Next; - } - else - { - /* Address page table. */ - gctUINT32_PTR map = Mmu->mapLogical; - - /* Dispatch on node type. */ - switch (gcmENTRY_TYPE(_ReadPageEntry(&map[Index]))) - { - case gcvMMU_SINGLE: - /* Set single index. */ - _WritePageEntry(&map[Index], (Next << 8) | gcvMMU_SINGLE); - break; - - case gcvMMU_FREE: - /* Set index. */ - _WritePageEntry(&map[Index + 1], Next); - break; - - default: - gcmkFATAL("MMU table correcupted at index %u!", Index); - return gcvSTATUS_HEAP_CORRUPTED; - } - } - - /* Success. */ - return gcvSTATUS_OK; -} - -static gceSTATUS -_AddFree( - IN gcTA_MMU Mmu, - IN gctUINT32 Index, - IN gctUINT32 Node, - IN gctUINT32 Count - ) -{ - gctUINT32_PTR map = Mmu->mapLogical; - - if (Count == 1) - { - /* Initialize a single page node. */ - _WritePageEntry(map + Node, (~((1U<<8)-1)) | gcvMMU_SINGLE); - } - else - { - /* Initialize the node. */ - _WritePageEntry(map + Node + 0, (Count << 8) | gcvMMU_FREE); - _WritePageEntry(map + Node + 1, ~0U); - } - - /* Append the node. */ - return _Link(Mmu, Index, Node); -} - -static gceSTATUS -_Collect( - IN gcTA_MMU Mmu - ) -{ - gctUINT32_PTR map = Mmu->mapLogical; - gceSTATUS status; - gctUINT32 i, previous, start = 0, count = 0; - - previous = Mmu->heapList = ~0U; - Mmu->freeNodes = gcvFALSE; - - /* Walk the entire page table. */ - for (i = 0; i < Mmu->pageTableEntries; ++i) - { - /* Dispatch based on type of page. */ - switch (gcmENTRY_TYPE(_ReadPageEntry(&map[i]))) - { - case gcvMMU_USED: - /* Used page, so close any open node. */ - if (count > 0) - { - /* Add the node. */ - gcmkONERROR(_AddFree(Mmu, previous, start, count)); - - /* Reset the node. */ - previous = start; - count = 0; - } - break; - - case gcvMMU_SINGLE: - /* Single free node. */ - if (count++ == 0) - { - /* Start a new node. */ - start = i; - } - break; - - case gcvMMU_FREE: - /* A free node. */ - if (count == 0) - { - /* Start a new node. */ - start = i; - } - - /* Advance the count. */ - count += _ReadPageEntry(&map[i]) >> 8; - - /* Advance the index into the page table. */ - i += (_ReadPageEntry(&map[i]) >> 8) - 1; - break; - - default: - gcmkFATAL("MMU page table correcupted at index %u!", i); - return gcvSTATUS_HEAP_CORRUPTED; - } - } - - /* See if we have an open node left. */ - if (count > 0) - { - /* Add the node to the list. */ - gcmkONERROR(_AddFree(Mmu, previous, start, count)); - } - - gcmkTRACE_ZONE(gcvLEVEL_INFO, gcvZONE_MMU, - "Performed a garbage collection of the MMU heap."); - - /* Success. */ - return gcvSTATUS_OK; - -OnError: - /* Return the staus. */ - return status; -} - -gcTA_MMU sharedMMU = gcvNULL; - -gceSTATUS -gctaMMU_Construct( - IN gcTA TA, - OUT gcTA_MMU *Mmu - ) -{ - gceSTATUS status; - gctUINT32 bytes = 4096; - - gcTA_MMU mmu; - - if (sharedMMU) - { - *Mmu = sharedMMU; - return gcvSTATUS_OK; - } - - gcmkONERROR(gctaOS_Allocate( - gcmSIZEOF(gcsTA_MMU), - (gctPOINTER *)&mmu - )); - - mmu->os = TA->os; - - /* MTLB bytes. */ - mmu->mtlbBytes = gcdMMU_MTLB_SIZE; - - /* Allocate MTLB. */ - gcmkONERROR(gctaOS_AllocateSecurityMemory( - TA->os, - &mmu->mtlbBytes, - &mmu->mtlbLogical, - &mmu->mtlbPhysical - )); - - /* Allocate a array to store stlbs. */ - gcmkONERROR(gctaOS_Allocate(mmu->mtlbBytes, &mmu->stlbs)); - - gctaOS_ZeroMemory((gctUINT8_PTR)mmu->stlbs, mmu->mtlbBytes); - - _SetupProcessAddressSpace(mmu); - - /* Allocate MTLB. */ - gcmkONERROR(gctaOS_AllocateSecurityMemory( - TA->os, - &bytes, - &mmu->safePageLogical, - &mmu->safePagePhysical - )); - - gcmkONERROR(gctaOS_CreateMutex(TA->os, &mmu->mutex)); - - mmu->pageTableChanged = gcvTRUE; - - *Mmu = mmu; - - sharedMMU = mmu; - - return gcvSTATUS_OK; - -OnError: - return status; -} - -gceSTATUS -gctaMMU_GetPageEntry( - IN gcTA_MMU Mmu, - IN gctUINT32 Address, - IN gctUINT32_PTR *PageTable - ) -{ - gceSTATUS status; - struct _gcsMMU_STLB *stlb; - struct _gcsMMU_STLB **stlbs = (struct _gcsMMU_STLB **)Mmu->stlbs; - gctUINT32 offset = _MtlbOffset(Address); - gctUINT32 mtlbEntry; - - gcmkHEADER_ARG("Mmu=0x%x", Mmu); - - /* Verify the arguments. */ - gcmkVERIFY_ARGUMENT((Address & 0xFFF) == 0); - - stlb = stlbs[offset]; - - - if (stlb == gcvNULL) - { - gcmkONERROR(_AllocateStlb(Mmu->os, &stlb)); - - mtlbEntry = stlb->physBase - | gcdMMU_MTLB_4K_PAGE - | gcdMMU_MTLB_PRESENT - ; - - - /* Insert Slave TLB address to Master TLB entry.*/ - _WritePageEntry((gctUINT32_PTR)Mmu->mtlbLogical + offset, mtlbEntry); - - /* Record stlb. */ - stlbs[offset] = stlb; - } - - *PageTable = &stlb->logical[_StlbOffset(Address)]; - - /* Success. */ - gcmkFOOTER_NO(); - return gcvSTATUS_OK; - -OnError: - gcmkFOOTER(); - return status; -} - -/* Flat mapping physical address to GPU virtual address. */ -gceSTATUS -gctaMMU_FlatMapping( - IN gcTA_MMU Mmu, - IN gctUINT32 Physical - ) -{ - gceSTATUS status; - gctUINT32 index = _AddressToIndex(Mmu, Physical); - gctUINT32 i; - gctBOOL gotIt = gcvFALSE; - /* gctUINT32_PTR map = Mmu->mapLogical; */ - gctUINT32_PTR map = gcvNULL; - gctUINT32 previous = ~0U; - gctUINT32_PTR pageTable; - gctBOOL secure = gcvFALSE; - - gctaMMU_GetPageEntry(Mmu, Physical, &pageTable); - - gcmkVERIFY_OK(gctaOS_IsPhysicalSecure(Mmu->os, Physical, &secure)); - - if (secure) - { - _WritePageEntry(pageTable, _SetPage(Physical | gcdMMU_STLB_SECURITY)); - } - else - { - _WritePageEntry(pageTable, _SetPage(Physical)); - } - - if (map) - { - /* Find node which contains index. */ - for (i = 0; !gotIt && (i < Mmu->pageTableEntries);) - { - gctUINT32 numPages; - - switch (gcmENTRY_TYPE(_ReadPageEntry(&map[i]))) - { - case gcvMMU_SINGLE: - if (i == index) - { - gotIt = gcvTRUE; - } - else - { - previous = i; - i = _ReadPageEntry(&map[i]) >> 8; - } - break; - - case gcvMMU_FREE: - numPages = _ReadPageEntry(&map[i]) >> 8; - if (index >= i && index < i + numPages) - { - gotIt = gcvTRUE; - } - else - { - previous = i; - i = _ReadPageEntry(&map[i + 1]); - } - break; - - default: - gcmkFATAL("MMU table correcupted at index %u!", index); - printf("XQ %s(%d) %x = \n", __FUNCTION__, __LINE__, index); - gcmkONERROR(gcvSTATUS_OUT_OF_RESOURCES); - } - } - - - switch (gcmENTRY_TYPE(_ReadPageEntry(&map[i]))) - { - case gcvMMU_SINGLE: - /* Unlink single node from free list. */ - gcmkONERROR( - _Link(Mmu, previous, _ReadPageEntry(&map[i]) >> 8)); - break; - - case gcvMMU_FREE: - /* Split the node. */ - { - gctUINT32 start; - gctUINT32 next = _ReadPageEntry(&map[i+1]); - gctUINT32 total = _ReadPageEntry(&map[i]) >> 8; - gctUINT32 countLeft = index - i; - gctUINT32 countRight = total - countLeft - 1; - - - if (countLeft) - { - start = i; - _AddFree(Mmu, previous, start, countLeft); - previous = start; - } - - if (countRight) - { - start = index + 1; - _AddFree(Mmu, previous, start, countRight); - previous = start; - } - - _Link(Mmu, previous, next); - - } - break; - } - - map[index] = gcvMMU_USED; - - - - - } - - return gcvSTATUS_OK; - -OnError: - - /* Roll back. */ - return status; -} - -gceSTATUS -gctaMMU_AllocatePages( - IN gcTA_MMU Mmu, - IN gctSIZE_T PageCount, - OUT gctUINT32 * Address - ) -{ - gceSTATUS status; - gctUINT32 index = 0, previous = ~0U, left; - gctUINT32_PTR map; - gctBOOL gotIt; - gctUINT32 address; - gctBOOL acquired = gcvFALSE; - - gcmkHEADER_ARG("Mmu=0x%x PageCount=%lu", Mmu, PageCount); - - /* Verify the arguments. */ - gcmkVERIFY_ARGUMENT(PageCount > 0); - - if (PageCount > Mmu->pageTableEntries) - { - /* Not enough pages avaiable. */ - gcmkONERROR(gcvSTATUS_OUT_OF_RESOURCES); - } - - gctaOS_AcquireMutex(Mmu->os, Mmu->mutex); - acquired = gcvTRUE; - - /* Cast pointer to page table. */ - for (map = Mmu->mapLogical, gotIt = gcvFALSE; !gotIt;) - { - /* printf("XQ %s(%d) heapList=%d\n", __FUNCTION__, __LINE__, Mmu->heapList); */ - /* Walk the heap list. */ - for (index = Mmu->heapList; !gotIt && (index < Mmu->pageTableEntries);) - { - /* Check the node type. */ - switch (gcmENTRY_TYPE(_ReadPageEntry(&map[index]))) - { - case gcvMMU_SINGLE: - /* Single odes are valid if we only need 1 page. */ - if (PageCount == 1) - { - gotIt = gcvTRUE; - } - else - { - /* Move to next node. */ - previous = index; - index = _ReadPageEntry(&map[index]) >> 8; - } - break; - - case gcvMMU_FREE: - /* Test if the node has enough space. */ - if (PageCount <= (_ReadPageEntry(&map[index]) >> 8)) - { - gotIt = gcvTRUE; - } - else - { - /* Move to next node. */ - previous = index; - index = _ReadPageEntry(&map[index + 1]); - } - break; - - default: - gcmkFATAL("MMU table correcupted at index %u!", index); - printf("XQ %s(%d) \n", __FUNCTION__, __LINE__); - gcmkONERROR(gcvSTATUS_OUT_OF_RESOURCES); - } - } - - /* Test if we are out of memory. */ - if (index >= Mmu->pageTableEntries) - { - if (Mmu->freeNodes) - { - /* Time to move out the trash! */ - gcmkONERROR(_Collect(Mmu)); - } - else - { - /* Out of resources. */ - gcmkONERROR(gcvSTATUS_OUT_OF_RESOURCES); - } - } - } - - switch (gcmENTRY_TYPE(_ReadPageEntry(&map[index]))) - { - case gcvMMU_SINGLE: - /* Unlink single node from free list. */ - gcmkONERROR( - _Link(Mmu, previous, _ReadPageEntry(&map[index]) >> 8)); - break; - - case gcvMMU_FREE: - /* Check how many pages will be left. */ - left = (_ReadPageEntry(&map[index]) >> 8) - PageCount; - switch (left) - { - case 0: - /* The entire node is consumed, just unlink it. */ - gcmkONERROR( - _Link(Mmu, previous, _ReadPageEntry(&map[index + 1]))); - break; - - case 1: - /* One page will remain. Convert the node to a single node and - ** advance the index. */ - _WritePageEntry(&map[index], (_ReadPageEntry(&map[index + 1]) << 8) | gcvMMU_SINGLE); - index ++; - break; - - default: - /* Enough pages remain for a new node. However, we will just adjust - ** the size of the current node and advance the index. */ - _WritePageEntry(&map[index], (left << 8) | gcvMMU_FREE); - index += left; - break; - } - break; - } - - /* Mark node as used. */ - gcmkONERROR(_FillPageTable(&map[index], PageCount, gcvMMU_USED)); - - gctaOS_ReleaseMutex(Mmu->os, Mmu->mutex); - - /* Build virtual address. */ - { - gctUINT32 masterOffset = index / gcdMMU_STLB_4K_ENTRY_NUM - + Mmu->dynamicMappingStart; - gctUINT32 slaveOffset = index % gcdMMU_STLB_4K_ENTRY_NUM; - - address = (masterOffset << gcdMMU_MTLB_SHIFT) - | (slaveOffset << gcdMMU_STLB_4K_SHIFT); - } - - if (Address != gcvNULL) - { - *Address = address; - } - - Mmu->pageTableChanged = gcvTRUE; - - /* Success. */ - gcmkFOOTER_ARG("*Address=%08x", - gcmOPT_VALUE(Address)); - return gcvSTATUS_OK; - -OnError: - if (acquired) - { - gctaOS_ReleaseMutex(Mmu->os, Mmu->mutex); - } - - /* Return the status. */ - gcmkFOOTER(); - return status; -} - -gceSTATUS -gctaMMU_FreePages( - IN gcTA_MMU Mmu, - IN gctUINT32 Address, - IN gctSIZE_T PageCount - ) -{ - gctUINT32_PTR node; - gceSTATUS status; - -#if gcdUSE_MMU_EXCEPTION - gctUINT32 i; - struct _gcsMMU_STLB *stlb; - struct _gcsMMU_STLB **stlbs = Mmu->stlbs; -#endif - - gcmkHEADER_ARG("Mmu=0x%x Address=0x%x PageCount=%lu", - Mmu, Address, PageCount); - - /* Verify the arguments. */ - gcmkVERIFY_ARGUMENT(PageCount > 0); - - /* Get the node by index. */ - node = Mmu->mapLogical + _AddressToIndex(Mmu, Address); - - gctaOS_AcquireMutex(Mmu->os, Mmu->mutex); - - if (PageCount == 1) - { - /* Single page node. */ - _WritePageEntry(node, (~((1U<<8)-1)) | gcvMMU_SINGLE); - } - else - { - /* Mark the node as free. */ - _WritePageEntry(node, (PageCount << 8) | gcvMMU_FREE); - _WritePageEntry(node + 1, ~0U); - } - - /* We have free nodes. */ - Mmu->freeNodes = gcvTRUE; - - gctaOS_ReleaseMutex(Mmu->os, Mmu->mutex); - -#if gcdUSE_MMU_EXCEPTION - for (i = 0; i < PageCount; i++) - { - /* Get */ - stlb = stlbs[_MtlbOffset(Address)]; - - /* Enable exception */ - stlb->logical[_StlbOffset(Address)] = gcdMMU_STLB_EXCEPTION; - } -#endif - - /* Success. */ - gcmkFOOTER_NO(); - return gcvSTATUS_OK; - -OnError: - gcmkFOOTER(); - return status; -} - - -gceSTATUS -gctaMMU_SetPage( - IN gcTA_MMU Mmu, - IN gctUINT32 PageAddress, - IN gctBOOL Secure, - IN gctUINT32 *PageEntry - ) -{ - gctBOOL secure; - - gcmkHEADER_ARG("Mmu=0x%x", Mmu); - - /* Verify the arguments. */ - gcmkVERIFY_ARGUMENT(PageEntry != gcvNULL); - gcmkVERIFY_ARGUMENT(!(PageAddress & 0xFFF)); - - if (Secure) - { - PageAddress |= gcdMMU_STLB_SECURITY; - } - - _WritePageEntry(PageEntry, _SetPage(PageAddress)); - - /* Success. */ - gcmkFOOTER_NO(); - return gcvSTATUS_OK; -} - -gceSTATUS -gctaMMU_Enable( - IN gcTA_MMU Mmu, - IN gcTA TA - ) -{ - gceSTATUS status; - gctUINT8 buffer[4 * 4]; - gctUINT32 address; - gctUINT32 safeAddress; - gctUINT32 bytes = 4 * 4; - - gcTA_HARDWARE hardware = TA->hardware; - gcTA_COMMAND command = TA->command; - - gctaOS_GetPhysicalAddress(Mmu->os, Mmu->mtlbLogical, &address); - - gctaOS_GetPhysicalAddress(Mmu->os, Mmu->safePageLogical, &safeAddress); - - gcmkONERROR(gctaHARDWARE_MMU(hardware, buffer, address, safeAddress, &bytes)); - - gcmkONERROR(gctaCOMMAND_Commit(command, buffer, bytes)); - - gcmkONERROR(gctaCOMMAND_Stall(command)); - - gcmkONERROR(gctaHARDWARE_MmuEnable(hardware)); - - return gcvSTATUS_OK; - -OnError: - return status; -} - -gceSTATUS -gctaMMU_FlatMapping2G( - IN gcTA_MMU Mmu - ) -{ - gceSTATUS status; - gctUINT32 physical = 0; - - for (physical = 0; physical < 0x80000000; physical += 4096) - { - gcmkVERIFY_OK(gctaMMU_FlatMapping(Mmu, physical)); - } - - /* gctaMMU_CheckFlatMapping2G(Mmu); */ - - return gcvSTATUS_OK; -OnError: - - return status; -} - -gceSTATUS -gctaMMU_CheckFlatMapping2G( - IN gcTA_MMU Mmu - ) -{ - gceSTATUS status; - gctUINT32 physical = 0; - gctUINT32 *entry; - - for (physical = 0; physical < 0x80000000; physical += 4096) - { - gctaMMU_GetPageEntry(Mmu, physical, &entry); - - if ((*entry & 0xfffffff0) != physical) - { - printf("XQ %s(%d) \n", __FUNCTION__, __LINE__); - } - } - - return gcvSTATUS_OK; -OnError: - - return status; -} - -gceSTATUS -gctaMMU_CheckHardwareAddressSecure( - IN gcTA_MMU Mmu, - IN gctUINT32 Address, - IN gctBOOL *Secure - ) -{ - gceSTATUS status; - gctUINT32_PTR entry; - - if (Address & 0xFFF) - { - Address = Address & (~0xFFF); - } - - gcmkONERROR(gctaMMU_GetPageEntry(Mmu, Address, &entry)); - - *Secure = *entry & gcdMMU_STLB_SECURITY; - - return gcvSTATUS_OK; - -OnError: - return status; -} - diff --git a/drivers/amlogic/npu/security/os/linux/gc_hal_ta_driver.c b/drivers/amlogic/npu/security/os/linux/gc_hal_ta_driver.c deleted file mode 100644 index 6479b5e..0000000 --- a/drivers/amlogic/npu/security/os/linux/gc_hal_ta_driver.c +++ /dev/null @@ -1,187 +0,0 @@ -/**************************************************************************** -* -* Copyright (c) 2005 - 2019 by Vivante Corp. All rights reserved. -* -* The material in this file is confidential and contains trade secrets -* of Vivante Corporation. This is proprietary information owned by -* Vivante Corporation. No part of this work may be disclosed, -* reproduced, copied, transmitted, or used in any way for any purpose, -* without the express written permission of Vivante Corporation. -* -*****************************************************************************/ - - -#include "gc_hal_types.h" -#include "gc_hal_base.h" -#include "gc_hal_security_interface.h" -#include "gc_hal_ta.h" -#include "tee_internal_api.h" - -#include "gc_hal_ta_linux.h" - -#define TA_EXPORT - -#define gcmCOUNTOF(a) \ -(\ - sizeof(a) / sizeof(a[0]) \ -) - -static TEE_Result TA_EXPORT TA_CreateEntryPoint(void) -{ - printf("TA_CreateEntryPoint\n"); - return TEE_SUCCESS; -} - -static void TA_EXPORT TA_DestroyEntryPoint(void) -{ - printf("TA_DestroyEntryPoint\n"); -} - -static TEE_Result TA_EXPORT TA_OpenSessionEntryPoint( - uint32_t paramTypes, - TEE_Param params[4], - void** sessionContext) -{ - gceSTATUS status; - TAContext *context; - gctUINT32 core; - uint32_t i = 0; - uint32_t nRegions = 0; - TEE_MemRegion *regions = NULL; - - gcmkONERROR( - gctaOS_Allocate(sizeof(TAContext), (gctPOINTER *)&context)); - - gctaOS_ZeroMemory(context, sizeof(TAContext)); - - if (params[0].value.a == 0) - { - context->registerBase = gcv3D_REGISTER_BASE; - } - else - { - context->registerBase = gcv2D_REGISTER_BASE; - } - - /* Query secure memory regions. */ - nRegions = TEE_GetMemRegionCount(TZ_M_NRW, TZ_M_NRW); - gcmkONERROR( - gctaOS_Allocate(nRegions * sizeof(TEE_MemRegion), (gctPOINTER *)®ions)); - TEE_GetMemRegionList(regions, nRegions, TZ_M_NRW, TZ_M_NRW); - - if (nRegions >= gcmCOUNTOF(context->secureRegions)) - { - printf("Too many secure pools.\n"); - } - - for (i = 0; i < nRegions; i++) - { - printf("===region %d, name %s, attrib 0x%x, (0x%8x, 0x%8x)===\n", - i, regions[i].name, regions[i].attr, regions[i].base, regions[i].base + regions[i].size); - context->secureRegions[i].base = regions[i].base; - context->secureRegions[i].size = regions[i].size; - } - - /* Construct gctaOS object. */ - gcmkONERROR(gctaOS_ConstructOS((gckOS)context, &context->os)); - - /* Store context. */ - *sessionContext = context; - - return TEE_SUCCESS; - -OnError: - if (context) - { - } - - return TEE_ERROR_STORAGE_NO_SPACE; -} - -static void TA_EXPORT TA_CloseSessionEntryPoint(void* sessionContext) -{ - return; -} - -static TEE_Result TA_EXPORT TA_InvokeCommandEntryPoint( - void* sessionContext, - uint32_t commandID, - uint32_t paramTypes, - TEE_Param params[4]) -{ - gceSTATUS status; - TAContext *context = sessionContext; - void *buffer; - gctUINT32 len; - gcsTA_INTERFACE interface; - - switch (commandID) - { - case gcvTA_COMMAND_INIT: - /* Construct gcTA object. */ - gcmkONERROR(gcTA_Construct(context->os, &context->ta)); - - break; - - case gcvTA_COMMAND_DISPATCH: - buffer = params[0].memref.buffer; - len = params[0].memref.size; - - if (buffer == gcvNULL) - { - gcmkONERROR(gcvSTATUS_INVALID_ARGUMENT); - } - - if (len != sizeof(gcsTA_INTERFACE)) - { - gcmkONERROR(gcvSTATUS_INVALID_ARGUMENT); - } - - TEE_MemMove(&interface, buffer, len); - - gcmkONERROR(gcTA_Dispatch(context->ta, &interface)); - - TEE_MemMove(buffer, &interface, len); - - break; - - default: - break; - } - - return TEE_SUCCESS; - -OnError: - return TEE_ERROR_GENERIC; -} - -/******************************************************************************\ -**************************************** Entry ******************************** -\******************************************************************************/ - -#define GPU3D_UUID { 0xcc9f80ea, 0xa836, 0x11e3, { 0x9b, 0x07, 0x78, 0x2b, 0xcb, 0x5c, 0xf3, 0xe3 } } - -const TEE_TA galcoreTA = { - .uuid = GPU3D_UUID, - .name = "galcore", - .singleInstance = false, - .multiSession = false, - .instanceKeepAlive = false, - - .Create = TA_CreateEntryPoint, - .Destroy = TA_DestroyEntryPoint, - .OpenSession = TA_OpenSessionEntryPoint, - .CloseSession = TA_CloseSessionEntryPoint, - .InvokeCommand = TA_InvokeCommandEntryPoint, -}; - -uint32_t __init(void) -{ - return (uint32_t)&galcoreTA; -} - -uint32_t __fini(void) -{ - return 0; -} - diff --git a/drivers/amlogic/npu/security/os/linux/gc_hal_ta_linux.c b/drivers/amlogic/npu/security/os/linux/gc_hal_ta_linux.c deleted file mode 100644 index 408d1b8..0000000 --- a/drivers/amlogic/npu/security/os/linux/gc_hal_ta_linux.c +++ /dev/null @@ -1,313 +0,0 @@ -/**************************************************************************** -* -* Copyright (c) 2005 - 2019 by Vivante Corp. All rights reserved. -* -* The material in this file is confidential and contains trade secrets -* of Vivante Corporation. This is proprietary information owned by -* Vivante Corporation. No part of this work may be disclosed, -* reproduced, copied, transmitted, or used in any way for any purpose, -* without the express written permission of Vivante Corporation. -* -*****************************************************************************/ - - -#include "tee_internal_api.h" -#include "gc_hal_base.h" -#include "gc_hal.h" -#include "gc_hal_ta.h" -#include "gc_hal_ta_linux.h" - -gceSTATUS -gctaOS_ConstructOS( - IN gckOS Os, - OUT gctaOS *TAos - ) -{ - *TAos = (gctaOS)Os; - return gcvSTATUS_OK; -} - -gceSTATUS -gctaOS_AllocateSecurityMemory( - IN gctaOS Os, - IN gctSIZE_T *Bytes, - OUT gctPOINTER *Logical, - OUT gctUINT32 *Physical - ) -{ - gceSTATUS status; - uint32_t cb_paramTypes = TEE_PARAM_TYPES(TEE_PARAM_TYPE_VALUE_INOUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE); - - TEE_Param cb_params[4]; - TEE_Result result; - - cb_params[0].value.a = *Bytes; - - /* Call allocation callback. */ - result = TEE_Callback(gcvTA_CALLBACK_ALLOC_SECURE_MEM, cb_paramTypes, cb_params, 0, NULL); - - if (result != TEE_SUCCESS) { - gcmkONERROR(gcvSTATUS_OUT_OF_MEMORY); - } - - *Physical = cb_params[0].value.b; - *Logical = TEE_PhysToVirt(*Physical); - - return gcvSTATUS_OK; - -OnError: - return status; -} - -gceSTATUS -gctaOS_FreeSecurityMemory( - IN gctaOS Os, - IN gctPOINTER Logical - ) -{ - return gcvSTATUS_OK; -} - -gceSTATUS -gctaOS_Allocate( - IN gctUINT32 Bytes, - OUT gctPOINTER *Pointer - ) -{ - gceSTATUS status; - gctPOINTER memory; - - memory = TEE_Malloc(Bytes, 0); - - if (memory == gcvNULL) - { - gcmkONERROR(gcvSTATUS_OUT_OF_MEMORY); - } - - *Pointer = memory; - - return gcvSTATUS_OK; - -OnError: - return status; -} - -gceSTATUS -gctaOS_Free( - IN gctPOINTER Pointer - ) -{ - TEE_Free(Pointer); - return gcvSTATUS_OK; -} - -gceSTATUS -gctaOS_GetPhysicalAddress( - IN gctaOS Os, - IN gctPOINTER Logical, - OUT gctUINT32 * Physical - ) -{ - *Physical = Logical; - - return gcvSTATUS_OK; -} - -gceSTATUS -gctaOS_WriteRegister( - IN gctaOS Os, - IN gctUINT32 Address, - IN gctUINT32 Data - ) -{ - TAContext *context = (TAContext *)Os; - - *((gctUINT32 *)(context->registerBase + Address)) = Data; - return gcvSTATUS_OK; -} - -gceSTATUS -gctaOS_ReadRegister( - IN gctaOS Os, - IN gctUINT32 Address, - IN gctUINT32 *Data - ) -{ - TAContext *context = (TAContext *)Os; - - *Data = *((gctUINT32 *)(context->registerBase + Address)); - - return gcvSTATUS_OK; -} - - -gceSTATUS -gctaOS_MemCopy( - IN gctUINT8_PTR Dest, - IN gctUINT8_PTR Src, - IN gctUINT32 Bytes - ) -{ - memcpy(Dest, Src, Bytes); - return gcvSTATUS_OK; -} - -gceSTATUS -gctaOS_ZeroMemory( - IN gctUINT8_PTR Dest, - IN gctUINT32 Bytes - ) -{ - memset(Dest, 0, Bytes); - return gcvSTATUS_OK; -} - -void -gctaOS_CacheFlush( - IN gctUINT8_PTR Dest, - IN gctUINT32 Bytes - ) -{ - TEE_FlushCache(Dest, Bytes); -} - -void -gctaOS_CacheClean( - IN gctUINT8_PTR Dest, - IN gctUINT32 Bytes - ) -{ - TEE_CleanCache(Dest, Bytes); -} - -void -gctaOS_CacheInvalidate( - IN gctUINT8_PTR Dest, - IN gctUINT32 Bytes - ) -{ - TEE_InvalidateCache(Dest, Bytes); -} - -void -gctaOS_Delay( - IN gctUINT32 Milliseconds - ) -{ - TEE_Wait(Milliseconds); -} - -void -gckOS_Print( - IN gctCONST_STRING Message, - ... - ) -{ - -} - -void -gctaOS_WriteSecurityMemory( - IN gctPOINTER Pointer, - IN gctUINT8 Width, - IN gctUINT32 Data - ) -{ - gctUINT32_PTR pointer = (gctUINT32_PTR)Pointer; - - *pointer = Data; - - gctaOS_CacheFlush(pointer, Width); -} - -void -gctaOS_ReadSecurityMemory( - IN gctPOINTER Pointer, - IN gctUINT8 Width, - IN gctUINT32 *Data - ) -{ - gctUINT32_PTR pointer = (gctUINT32_PTR)Pointer; - - gctaOS_CacheInvalidate(pointer, Width); - - *Data = *pointer; -} - -gceSTATUS -gctaOS_CreateMutex( - IN gctaOS Os, - OUT gctPOINTER * Mutex - ) -{ - TEE_Result result; - - result = TEE_MutexCreate(Mutex, "MMU"); - - if (result != TEE_SUCCESS) - { - return gcvSTATUS_OUT_OF_RESOURCES; - } - - return gcvSTATUS_OK; -} - -gceSTATUS -gctaOS_DeleteMutex( - IN gctaOS Os, - OUT gctPOINTER Mutex - ) -{ - TEE_MutexDestroy(Mutex); - return gcvSTATUS_OK; -} - -gceSTATUS -gctaOS_AcquireMutex( - IN gctaOS Os, - IN gctPOINTER Mutex - ) -{ - TEE_MutexLock(Mutex); - return gcvSTATUS_OK; -} - -gceSTATUS -gctaOS_ReleaseMutex( - IN gctaOS Os, - IN gctPOINTER Mutex - ) -{ - TEE_MutexUnlock(Mutex); - return gcvSTATUS_OK; -} - -gceSTATUS -gctaOS_IsPhysicalSecure( - IN gctaOS Os, - IN gctUINT32 Physical, - OUT gctBOOL *Secure - ) -{ - gctUINT32 index = 0; - TAContext *context = (TAContext *)Os; - TAMemoryRegion *sr = context->secureRegions; - gctUINT32 nSr = gcmSIZEOF(context->secureRegions) / gcmSIZEOF(TAMemoryRegion); - - for (index = 0; index < nSr; index++) - { - if (Physical >= sr[index].base && Physical < sr[index].base + sr[index].size) - { - *Secure = gcvTRUE; - return gcvSTATUS_OK; - } - } - - *Secure = gcvFALSE; - - return gcvSTATUS_OK; -} - diff --git a/drivers/amlogic/npu/security/os/linux/gc_hal_ta_linux.h b/drivers/amlogic/npu/security/os/linux/gc_hal_ta_linux.h deleted file mode 100644 index 9a5746a..0000000 --- a/drivers/amlogic/npu/security/os/linux/gc_hal_ta_linux.h +++ /dev/null @@ -1,31 +0,0 @@ -/**************************************************************************** -* -* Copyright (c) 2005 - 2019 by Vivante Corp. All rights reserved. -* -* The material in this file is confidential and contains trade secrets -* of Vivante Corporation. This is proprietary information owned by -* Vivante Corporation. No part of this work may be disclosed, -* reproduced, copied, transmitted, or used in any way for any purpose, -* without the express written permission of Vivante Corporation. -* -*****************************************************************************/ - - -#define MAX_SECURE_POOL 16 - -typedef struct _TAMemoryRegion{ - gctUINT32 base; - gctUINT32 size; -} TAMemoryRegion; - -typedef struct _TAContext{ - gctaOS os; - gcTA ta; - gctUINT32 registerBase; - TAMemoryRegion secureRegions[MAX_SECURE_POOL]; -} TAContext; - -#define gcv3D_REGISTER_BASE 0xF7BC0000 -#define gcv2D_REGISTER_BASE 0xF7EF0000 - - diff --git a/drivers/amlogic/npu/security_v1/gc_hal_ta.c b/drivers/amlogic/npu/security_v1/gc_hal_ta.c index 485dc91..b175518 100644 --- a/drivers/amlogic/npu/security_v1/gc_hal_ta.c +++ b/drivers/amlogic/npu/security_v1/gc_hal_ta.c @@ -53,7 +53,7 @@ *****************************************************************************/ -#include "shared/gc_hal_types.h" +#include "gc_hal_types.h" #include "gc_hal_base.h" #include "gc_hal_security_interface.h" #include "gc_hal_ta.h" diff --git a/drivers/amlogic/npu/security_v1/gc_hal_ta.h b/drivers/amlogic/npu/security_v1/gc_hal_ta.h index 549a03e..c6b64a9 100644 --- a/drivers/amlogic/npu/security_v1/gc_hal_ta.h +++ b/drivers/amlogic/npu/security_v1/gc_hal_ta.h @@ -55,7 +55,7 @@ #ifndef _GC_HAL_TA_H_ #define _GC_HAL_TA_H_ -#include "shared/gc_hal_types.h" +#include "gc_hal_types.h" #include "gc_hal_security_interface.h" #ifdef __cplusplus diff --git a/drivers/amlogic/npu/security_v1/gc_hal_ta_hardware.c b/drivers/amlogic/npu/security_v1/gc_hal_ta_hardware.c index 27e9f2f..c9a2905 100644 --- a/drivers/amlogic/npu/security_v1/gc_hal_ta_hardware.c +++ b/drivers/amlogic/npu/security_v1/gc_hal_ta_hardware.c @@ -53,7 +53,7 @@ *****************************************************************************/ -#include "shared/gc_hal_types.h" +#include "gc_hal_types.h" #include "gc_hal_base.h" #include "gc_hal_security_interface.h" #include "gc_hal_ta.h" diff --git a/drivers/amlogic/npu/security_v1/gc_hal_ta_hardware.h b/drivers/amlogic/npu/security_v1/gc_hal_ta_hardware.h index 815d1a1..dd85d08 100644 --- a/drivers/amlogic/npu/security_v1/gc_hal_ta_hardware.h +++ b/drivers/amlogic/npu/security_v1/gc_hal_ta_hardware.h @@ -55,7 +55,7 @@ #ifndef _GC_HAL_TA_HARDWARE_H_ #define _GC_HAL_TA_HARDWARE_H_ -#include "shared/gc_hal_types.h" +#include "gc_hal_types.h" #include "gc_hal_security_interface.h" #ifdef __cplusplus diff --git a/drivers/amlogic/npu/security_v1/gc_hal_ta_mmu.c b/drivers/amlogic/npu/security_v1/gc_hal_ta_mmu.c index 3d11053..5797211 100644 --- a/drivers/amlogic/npu/security_v1/gc_hal_ta_mmu.c +++ b/drivers/amlogic/npu/security_v1/gc_hal_ta_mmu.c @@ -53,7 +53,7 @@ *****************************************************************************/ -#include "shared/gc_hal_types.h" +#include "gc_hal_types.h" #include "gc_hal_base.h" #include "gc_hal_security_interface.h" #include "gc_hal_ta.h" -- 2.7.4 From 6d76f09e685b1f6e29f668ea1a64d1f441cba4d2 Mon Sep 17 00:00:00 2001 From: Tao Zeng Date: Wed, 28 Aug 2019 15:25:40 +0800 Subject: [PATCH 03/16] mm: fix wrong kasan report [1/1] PD#SWPL-13281 Problem: There are 2 types of wrong kasan report after merge change of save wasted slab. 1, slab-out-of-bounds, which is caused by krealloc set shadow memory out-of-range, since tail of page was freed. 2, use-after-free, which is caused by kasan_free_pages called after a page freed. Because this function already called in free_page, so it marked shadow memory twice. Solution: 1, make shadow do not out of range if a tail page was freed and been realloc again. 2, remove call of kasan_free_pages. Verify: X301 Signed-off-by: Tao Zeng [sw0312.kim: fully apply amlogic vendor commit becb83999e19 missed from merge] Ref: https://github.com/hardkernel/linux/commit/becb83999e19d2055458f08a2b7a44bd1170853e Signed-off-by: Seung-Woo Kim Change-Id: I71daa41038e156a9bacf26e27fc51792d558f819 --- mm/slub.c | 1 - 1 file changed, 1 deletion(-) diff --git a/mm/slub.c b/mm/slub.c index d1f5fd0..80f291c 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -3808,7 +3808,6 @@ static void aml_slub_free_large(struct page *page, const void *obj) __func__, page_address(page), nr_pages, obj); for (i = 0; i < nr_pages; i++) { __free_pages(page, 0); - kasan_free_pages(page, 0); page++; } } -- 2.7.4 From 52ddac0afb8337c550ce5068c1c9c5ff785f4ebc Mon Sep 17 00:00:00 2001 From: Seung-Woo Kim Date: Tue, 12 Jan 2021 18:19:36 +0900 Subject: [PATCH 04/16] net: rtl88xx: fix to check null adapter UBSAN warns about null pointer accessin rtl88xx. Fix to check null pointer for adapter to remove below warning: UBSAN: Undefined behaviour in drivers/net/wireless/rtl8812au/os_dep/osdep_service.c:1187:2 member access within null pointer of type 'struct _adapter' [...] [] __ubsan_handle_type_mismatch+0x28/0x30 [] rtw_init_timer+0xbc/0xf0 [88XXau] [] devobj_init+0x90/0x100 [88XXau] [] rtw_usb_primary_adapter_init+0x64c/0x1558 [88XXau] [] usb_probe_interface+0x16c/0x4c8 [...] Change-Id: I258df3b790d7b1be49a89706dca46a895c4461b8 Signed-off-by: Seung-Woo Kim --- drivers/net/wireless/rtl8812au/os_dep/osdep_service.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/wireless/rtl8812au/os_dep/osdep_service.c b/drivers/net/wireless/rtl8812au/os_dep/osdep_service.c index 7c6d120..36d793d 100644 --- a/drivers/net/wireless/rtl8812au/os_dep/osdep_service.c +++ b/drivers/net/wireless/rtl8812au/os_dep/osdep_service.c @@ -1183,6 +1183,9 @@ void rtw_init_timer(_timer *ptimer, void *padapter, void *pfunc, void *ctx) { _adapter *adapter = (_adapter *)padapter; + if (!adapter) + return; + #ifdef PLATFORM_LINUX _init_timer(ptimer, adapter->pnetdev, pfunc, ctx); #endif -- 2.7.4 From ed433ca707269cd22fa1137c33818af6c254eea4 Mon Sep 17 00:00:00 2001 From: Seung-Woo Kim Date: Wed, 13 Jan 2021 14:50:51 +0900 Subject: [PATCH 05/16] clk: amlogic: g12a: fix divide by zero for default pll register On reset register value 0x20000000 for some plls of g12, there are divide by zero operations warned by UBSAN. For the case, calculate pll rate as zero. This removes below UBSAN warnings: UBSAN: Undefined behaviour in drivers/amlogic/clk/g12a/g12a_clk-pll.c:155:74 ... UBSAN: Undefined behaviour in drivers/amlogic/clk/g12a/g12a_clk-pll.c:140:74 ... UBSAN: Undefined behaviour in drivers/amlogic/clk/g12a/g12a_clk-pll.c:145:25 division by zero ... [] __ubsan_handle_divrem_overflow+0x8c/0xc8 [] meson_g12a_pll_recalc_rate+0x8d0/0x930 [] clk_register+0x724/0xe10 [] g12a_clkc_init+0x640/0x7fc ... Change-Id: I4f0c771502e2ae0291a9eaffbea7a03e617009af Signed-off-by: Seung-Woo Kim --- drivers/amlogic/clk/g12a/g12a_clk-pll.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/amlogic/clk/g12a/g12a_clk-pll.c b/drivers/amlogic/clk/g12a/g12a_clk-pll.c index e466bfc..b32609c 100644 --- a/drivers/amlogic/clk/g12a/g12a_clk-pll.c +++ b/drivers/amlogic/clk/g12a/g12a_clk-pll.c @@ -123,7 +123,9 @@ static unsigned long meson_g12a_pll_recalc_rate(struct clk_hw *hw, p = &pll->frac; - if (p->width >= 2) { + if (!n) { + rate_mhz = 0; + } else if (p->width >= 2) { reg = readl(pll->base + p->reg_off); frac = PARM_GET(p->width - 1, p->shift, reg); -- 2.7.4 From cffdfea367bc56ca47ebeb24eeed5ef505632677 Mon Sep 17 00:00:00 2001 From: Seung-Woo Kim Date: Wed, 13 Jan 2021 16:52:58 +0900 Subject: [PATCH 06/16] Staging: android: ion: fix to set cached element of pool always The allocated memory with kmalloc() can have invalid value. To avoid using the invalid value, always set cached element. This removes below UBSAN warning: UBSAN: Undefined behaviour in drivers/staging/android/ion/ion_page_pool.c:33:11 load of value 152 is not a valid value for type '_Bool' ... [] __ubsan_handle_load_invalid_value+0x80/0x90 [] ion_page_pool_alloc+0x154/0x180 [] ion_system_heap_allocate+0x2b8/0xa68 [] ion_alloc+0x238/0x9c8 ... Change-Id: I86e0ee70404bb074dad3b73dccec31ebcf2c7c72 Signed-off-by: Seung-Woo Kim --- drivers/staging/android/ion/ion_page_pool.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/android/ion/ion_page_pool.c b/drivers/staging/android/ion/ion_page_pool.c index aea89c1ec..c34d921 100644 --- a/drivers/staging/android/ion/ion_page_pool.c +++ b/drivers/staging/android/ion/ion_page_pool.c @@ -163,8 +163,7 @@ struct ion_page_pool *ion_page_pool_create(gfp_t gfp_mask, unsigned int order, pool->order = order; mutex_init(&pool->mutex); plist_node_init(&pool->list, order); - if (cached) - pool->cached = true; + pool->cached = cached; return pool; } -- 2.7.4 From 019788d0573129ecfc7ecaa0de6a09e348b3e24d Mon Sep 17 00:00:00 2001 From: Seung-Woo Kim Date: Fri, 15 Jan 2021 13:41:36 +0900 Subject: [PATCH 07/16] amlogic: drm/meson: Fix plane state out-of-bounds access For drm_plane_funcs callbacks, it was fixed to use meson specific functions except reset callback. Not like other meson specific callbacks, reset callback allocates drm_plane_state, so accessing meson_plane_state from drm_plane state in other callbacks causes out-of-bounds access. Fix plane state out-of-bounds access by using meson specific reset callback using meson_plane_state based on drm_atomic_helper_plane_reset(). This removes below kasan warning: BUG: KASAN: slab-out-of-bounds in kmemdup+0x4c/0xb0 Read of size 128 at addr ffffffc005a710c0 by task enlightenment/4376 ... [] kmemdup+0x4c/0xb0 [] meson_plane_duplicate_state+0x40/0x90 [] drm_atomic_get_plane_state+0xc4/0x230 [] __drm_atomic_helper_set_config+0xdc/0x788 [] drm_atomic_helper_set_config+0xdc/0x178 [] meson_crtc_set_mode+0x40/0x68 [] drm_mode_set_config_internal+0xf4/0x348 [] drm_mode_setcrtc+0x1d4/0x910 ... Allocated by task 1: ... kmem_cache_alloc_trace+0x20c/0x6c8 drm_atomic_helper_plane_reset+0x6c/0xc8 drm_mode_config_reset+0x7c/0x310 am_meson_drm_bind+0x1fc/0x2f8 try_to_bring_up_master.part.1+0x70/0x128 component_master_add_with_match+0x1b8/0x230 am_meson_drv_probe+0x3c8/0x410 ... Change-Id: Ie7bfd41d797a0782cffa45801629981c25b01561 Fixes commit 1f1efcfdd85d ("drm: add multi-layer support [1/1]") Signed-off-by: Seung-Woo Kim --- drivers/amlogic/drm/meson_plane.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/drivers/amlogic/drm/meson_plane.c b/drivers/amlogic/drm/meson_plane.c index c7a2d07..08270f1 100644 --- a/drivers/amlogic/drm/meson_plane.c +++ b/drivers/amlogic/drm/meson_plane.c @@ -292,6 +292,27 @@ meson_plane_duplicate_state(struct drm_plane *plane) return &meson_plane_state->base; } +static void meson_plane_reset(struct drm_plane *plane) +{ + struct am_meson_plane_state *meson_plane_state; + + if (plane->state) { + __drm_atomic_helper_plane_destroy_state(plane->state); + + meson_plane_state = to_am_meson_plane_state(plane->state); + kfree(meson_plane_state); + plane->state = NULL; + } + + meson_plane_state = kzalloc(sizeof(*meson_plane_state), GFP_KERNEL); + + if (meson_plane_state) { + plane->state = &meson_plane_state->base; + plane->state->plane = plane; + plane->state->rotation = DRM_ROTATE_0; + } +} + static void meson_plane_destroy_state(struct drm_plane *plane, struct drm_plane_state *state) { @@ -336,7 +357,7 @@ static const struct drm_plane_funcs am_osd_plane_funs = { .update_plane = drm_atomic_helper_update_plane, .disable_plane = drm_atomic_helper_disable_plane, .destroy = drm_plane_cleanup, - .reset = drm_atomic_helper_plane_reset, + .reset = meson_plane_reset, .atomic_duplicate_state = meson_plane_duplicate_state, .atomic_destroy_state = meson_plane_destroy_state, .atomic_set_property = meson_plane_atomic_set_property, -- 2.7.4 From 37a9041f85094da32a0069a13392d8bb4c4dfdbb Mon Sep 17 00:00:00 2001 From: Seung-Woo Kim Date: Mon, 18 Jan 2021 16:16:24 +0900 Subject: [PATCH 08/16] amlogic: drm/meson: Fix to use address type for 64bit In arm64, physical address type is accessed as 64bit, but there is 32bit variable for it, so there is out-of-bounds access. Fix to use address type for 64bit. This fixes following kasan wanring: BUG: KASAN: stack-out-of-bounds in ion_phys+0xb4/0x180 Write of size 8 at addr ffffffc0a152f700 by task enlightenment/4189 ... [] ion_phys+0xb4/0x180 [] am_meson_gem_object_get_phyaddr+0x114/0x148 [] meson_plane_atomic_check+0x570/0xea8 ... Change-Id: I185601b2dd8f0bb9c700f87c2baaa9f6ebb183d8 Signed-off-by: Seung-Woo Kim --- drivers/amlogic/drm/meson_gem.c | 4 ++-- drivers/amlogic/drm/meson_gem.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/amlogic/drm/meson_gem.c b/drivers/amlogic/drm/meson_gem.c index 4c6ef32..fba2bb7 100644 --- a/drivers/amlogic/drm/meson_gem.c +++ b/drivers/amlogic/drm/meson_gem.c @@ -212,11 +212,11 @@ int am_meson_gem_mmap( return ret; } -int am_meson_gem_object_get_phyaddr( +phys_addr_t am_meson_gem_object_get_phyaddr( struct meson_drm *drm, struct am_meson_gem_object *meson_gem) { - int addr; + phys_addr_t addr; size_t len; if (meson_gem->sg) { diff --git a/drivers/amlogic/drm/meson_gem.h b/drivers/amlogic/drm/meson_gem.h index c644112..cab22a5 100644 --- a/drivers/amlogic/drm/meson_gem.h +++ b/drivers/amlogic/drm/meson_gem.h @@ -78,7 +78,7 @@ int am_meson_gem_object_mmap( struct am_meson_gem_object *obj, struct vm_area_struct *vma); -extern int am_meson_gem_object_get_phyaddr( +extern phys_addr_t am_meson_gem_object_get_phyaddr( struct meson_drm *drm, struct am_meson_gem_object *meson_gem); -- 2.7.4 From 5dd3ffecd46fe44a93ee072c649ea10c058f7fb8 Mon Sep 17 00:00:00 2001 From: Seung-Woo Kim Date: Tue, 19 Jan 2021 14:47:25 +0900 Subject: [PATCH 09/16] usb: gadget: f_fs: Fix use-after-free for unbind with remaining io If usb has stall, then there can be remaining submitted io and unbinding f_fs with the remaining io, there is use-after-free. Fix the use-after-free by checking endpoint after wait. This fixes following kasan warning: BUG: KASAN: use-after-free in ffs_epfile_io+0x654/0xb58 Read of size 4 at addr ffffffc0a44e65dc by task mtp-responder/5117 ... [] ffs_epfile_io+0x654/0xb58 [] ffs_epfile_read_iter+0x1ac/0x3e0 ... Allocated by task 3869: ... __kmalloc+0x234/0x760 _ffs_func_bind+0x264/0x7c8 ffs_func_bind+0xe8/0x650 usb_add_function+0x13c/0x378 ... Freed by task 3869: ... kfree+0xa4/0x750 ffs_func_unbind+0x150/0x248 purge_configs_funcs+0x1a0/0x310 ... Change-Id: I2bb9b07d93b1ac42432caaa2c2176d987b36b140 Signed-off-by: Seung-Woo Kim --- drivers/usb/gadget/function/f_fs.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c index 620e509..df74bfa 100644 --- a/drivers/usb/gadget/function/f_fs.c +++ b/drivers/usb/gadget/function/f_fs.c @@ -1181,7 +1181,8 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data) spin_unlock_irq(&epfile->ffs->eps_lock); - if (unlikely(wait_for_completion_interruptible(&done))) { + if (unlikely(wait_for_completion_interruptible(&done)) && + epfile->ep) { /* * To avoid race condition with ffs_epfile_io_complete, * dequeue the request first then check @@ -1193,6 +1194,12 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data) interrupted = ep->status < 0; } + if (epfile->ep != ep) { + /* In the meantime, endpoint got disabled or changed. */ + ret = -ESHUTDOWN; + goto error_mutex; + } + if (interrupted) ret = -EINTR; -- 2.7.4 From 5f1acde8c82eb3099af328a6e4f5155051ed809d Mon Sep 17 00:00:00 2001 From: Seung-Woo Kim Date: Wed, 20 Jan 2021 11:00:11 +0900 Subject: [PATCH 10/16] char: aml-gpiomem: Use allocated pointer for class registration The class name for class_create() requires memory pointer not freed until the class is destroy, but local array is used, so it causes memory bad access. Use allocated pointer for class registration. This fixes below kasan warning: BUG: KASAN: out-of-bounds in strlcpy+0x48/0x88 Read of size 11 at addr ffffffc00029f9c0 by task udevadm/2912 ... [] check_memory_region+0x12c/0x1a0 [] memcpy+0x34/0x68 [] strlcpy+0x48/0x88 [] kobject_uevent_env+0x55c/0x948 [] kobject_uevent+0x10/0x18 [] uevent_store+0xf0/0xf8 ... Change-Id: I0e265a8b1b52e732de262a0058bd821419ca4fe8 Signed-off-by: Seung-Woo Kim --- drivers/char/aml-gpiomem.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/char/aml-gpiomem.c b/drivers/char/aml-gpiomem.c index 5c71560..1d2d2dc 100644 --- a/drivers/char/aml-gpiomem.c +++ b/drivers/char/aml-gpiomem.c @@ -62,6 +62,7 @@ struct aml_gpiomem_instance { unsigned long gpio_regs_phys; struct device *dev; char dev_name[32]; + char class_name[64]; int major; }; @@ -166,7 +167,6 @@ static int aml_gpiomem_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct resource *ioresource; const char *str; - char tmp[64]; struct aml_gpiomem_instance *inst = NULL; /* Allocate buffers and instance data */ @@ -200,9 +200,9 @@ static int aml_gpiomem_probe(struct platform_device *pdev) inst->dev_name[31] = '\0'; /* Create character device entries */ - sprintf(tmp, "aml-%s", inst->dev_name); + sprintf(inst->class_name, "aml-%s", inst->dev_name); err = alloc_chrdev_region(&aml_gpiomem_devid, - DEVICE_MINOR, 1, tmp); + DEVICE_MINOR, 1, inst->class_name); if (err != 0) { dev_err(inst->dev, "unable to allocate device number"); goto failed_alloc_chrdev; @@ -216,7 +216,7 @@ static int aml_gpiomem_probe(struct platform_device *pdev) } /* Create sysfs entries */ - aml_gpiomem_class = class_create(THIS_MODULE, tmp); + aml_gpiomem_class = class_create(THIS_MODULE, inst->class_name); ptr_err = aml_gpiomem_class; if (IS_ERR(ptr_err)) goto failed_class_create; -- 2.7.4 From 03aa4bdcdf1825497cfbaf6dae4cdf28284e5e37 Mon Sep 17 00:00:00 2001 From: Seung-Woo Kim Date: Wed, 20 Jan 2021 14:25:45 +0900 Subject: [PATCH 11/16] amlogic/media: lcd: Fix division by zero If no lcd is set by bootargs, it can not choose lcd type from device tree and it causes division by zero. Fix the it by checking division value. This fixes below ubsan warnings: UBSAN: Undefined behaviour in drivers/amlogic/media/vout/lcd/lcd_common.c:777:59 UBSAN: Undefined behaviour in drivers/amlogic/media/vout/lcd/lcd_common.c:778:43 UBSAN: Undefined behaviour in drivers/amlogic/media/vout/lcd/lcd_common.c:784:53 UBSAN: Undefined behaviour in drivers/amlogic/media/vout/lcd/lcd_common.c:786:59 UBSAN: Undefined behaviour in drivers/amlogic/media/vout/lcd/lcd_common.c:787:43 division by zero ... [ffffff9200003610+ 96][] __ubsan_handle_divrem_overflow+0x8c/0xc8 [ffffff9200003670+ 144][] lcd_timing_init_config+0x254/0x390 [ffffff9200003700+ 544][] lcd_tablet_probe+0xfa0/0x3f50 [ffffff9200003920+ 64][] lcd_mode_probe+0x54/0x6c0 [ffffff9200003960+ 272][] lcd_probe+0x984/0x1070 ... Change-Id: I6ad73fcd554715c1d7ac3cadf82ead251b596e1c Signed-off-by: Seung-Woo Kim --- drivers/amlogic/media/vout/lcd/lcd_common.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/drivers/amlogic/media/vout/lcd/lcd_common.c b/drivers/amlogic/media/vout/lcd/lcd_common.c index 0f7f90b..237a465 100644 --- a/drivers/amlogic/media/vout/lcd/lcd_common.c +++ b/drivers/amlogic/media/vout/lcd/lcd_common.c @@ -774,17 +774,28 @@ void lcd_timing_init_config(struct lcd_config_s *pconf) pconf->lcd_timing.de_vs_addr = de_vstart; pconf->lcd_timing.de_ve_addr = de_vstart + v_active - 1; - hstart = (de_hstart + h_period - hsync_bp - hsync_width) % h_period; - hend = (de_hstart + h_period - hsync_bp) % h_period; + if (h_period) { + hstart = (de_hstart + h_period - hsync_bp - hsync_width) % h_period; + hend = (de_hstart + h_period - hsync_bp) % h_period; + } else { + hstart = 0; + hend = 0; + } pconf->lcd_timing.hs_hs_addr = hstart; pconf->lcd_timing.hs_he_addr = hend; pconf->lcd_timing.hs_vs_addr = 0; pconf->lcd_timing.hs_ve_addr = v_period - 1; - pconf->lcd_timing.vs_hs_addr = (hstart + h_period) % h_period; + if (h_period) { + pconf->lcd_timing.vs_hs_addr = (hstart + h_period) % h_period; + vstart = (de_vstart + v_period - vsync_bp - vsync_width) % v_period; + vend = (de_vstart + v_period - vsync_bp) % v_period; + } else { + pconf->lcd_timing.vs_hs_addr = 0; + vstart = 0; + vend = 0; + } pconf->lcd_timing.vs_he_addr = pconf->lcd_timing.vs_hs_addr; - vstart = (de_vstart + v_period - vsync_bp - vsync_width) % v_period; - vend = (de_vstart + v_period - vsync_bp) % v_period; pconf->lcd_timing.vs_vs_addr = vstart; pconf->lcd_timing.vs_ve_addr = vend; -- 2.7.4 From 4b77b6ea1ab55e299b3fcd1b35044030b3ee7d77 Mon Sep 17 00:00:00 2001 From: Seung-Woo Kim Date: Thu, 21 Jan 2021 15:22:52 +0900 Subject: [PATCH 12/16] of: Fix wrong kmemleak ignore in reserved_mem If size is 0, then kmemleak object found for ignore object is not properly working and ignore should work for create kmemleak object. Fix the wrong kmemleak ignore usages in of_reserved_mem. This removes below kmemleak warnings: kmemleak: Not scanning unknown object at 0xffffffc0f4807000 kmemleak: Not scanning unknown object at 0xffffffc0f4800000 kmemleak: Not scanning unknown object at 0xffffffc007400000 ... [] kmemleak_no_scan+0xd8/0xe8 [] kmemleak_init+0x260/0x504 .. kmemleak: Early log backtrace: log_early+0x1d8/0x268 kmemleak_no_scan+0xbc/0xe8 fdt_init_reserved_mem+0x8b4/0x928 early_init_fdt_scan_reserved_mem+0x100/0x13c arm64_memblock_init+0x310/0x388 ... Change-Id: Idac1f672b06373f6eb7485d63b60747f2cf9f5b5 Fixes: commit 47a87b6930cd ("kmemleak: shouldn't scan reserved memory") Signed-off-by: Seung-Woo Kim --- drivers/of/of_reserved_mem.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c index 0d706be..c4a7b04 100644 --- a/drivers/of/of_reserved_mem.c +++ b/drivers/of/of_reserved_mem.c @@ -315,13 +315,15 @@ void __init fdt_init_reserved_mem(void) if (prop) rmem->phandle = of_read_number(prop, len/4); - if (rmem->size == 0) + if (rmem->size == 0) { err = __reserved_mem_alloc_size(node, rmem->name, &rmem->base, &rmem->size); #ifdef CONFIG_AMLOGIC_MODIFY - kmemleak_no_scan(phys_to_virt(rmem->base)); + if (!err && rmem->size) + kmemleak_no_scan(phys_to_virt(rmem->base)); #endif + } if (err == 0) __reserved_mem_init_node(rmem); -- 2.7.4 From c8cda0b6868bd5b0335e91cd0274a59fe359e207 Mon Sep 17 00:00:00 2001 From: Seung-Woo Kim Date: Fri, 22 Jan 2021 14:52:15 +0900 Subject: [PATCH 13/16] arm64: dts: amlogic: g12 boards: Remove size 0 cma areas The cma area with size 0 has no meaning and it adds unnecessary reserve information. Remove size 0 cma areas. Change-Id: I02f6091d7628e19aec3be928612e778c57648c9e Signed-off-by: Seung-Woo Kim --- arch/arm64/boot/dts/amlogic/kvim3_linux.dts | 2 ++ arch/arm64/boot/dts/amlogic/kvim3l_linux.dts | 2 ++ arch/arm64/boot/dts/amlogic/meson64_odroidc4.dts | 2 ++ arch/arm64/boot/dts/amlogic/meson64_odroidn2.dtsi | 2 ++ 4 files changed, 8 insertions(+) diff --git a/arch/arm64/boot/dts/amlogic/kvim3_linux.dts b/arch/arm64/boot/dts/amlogic/kvim3_linux.dts index 2e9dd48..6583f3a 100644 --- a/arch/arm64/boot/dts/amlogic/kvim3_linux.dts +++ b/arch/arm64/boot/dts/amlogic/kvim3_linux.dts @@ -120,6 +120,7 @@ }; /* POST PROCESS MANAGER */ ppmgr_reserved:linux,ppmgr { + status = "disable"; compatible = "shared-dma-pool"; size = <0x0 0x0>; }; @@ -133,6 +134,7 @@ }; /* codec shared reserved */ codec_mm_reserved:linux,codec_mm_reserved { + status = "disable"; compatible = "amlogic, codec-mm-reserved"; size = <0x0 0x0>; alignment = <0x0 0x100000>; diff --git a/arch/arm64/boot/dts/amlogic/kvim3l_linux.dts b/arch/arm64/boot/dts/amlogic/kvim3l_linux.dts index 5ed3c76..1c38e44 100644 --- a/arch/arm64/boot/dts/amlogic/kvim3l_linux.dts +++ b/arch/arm64/boot/dts/amlogic/kvim3l_linux.dts @@ -117,6 +117,7 @@ }; /* POST PROCESS MANAGER */ ppmgr_reserved:linux,ppmgr { + status = "disable"; compatible = "shared-dma-pool"; size = <0x0 0x0>; }; @@ -131,6 +132,7 @@ }; /* codec shared reserved */ codec_mm_reserved:linux,codec_mm_reserved { + status = "disable"; compatible = "amlogic, codec-mm-reserved"; size = <0x0 0x0>; alignment = <0x0 0x100000>; diff --git a/arch/arm64/boot/dts/amlogic/meson64_odroidc4.dts b/arch/arm64/boot/dts/amlogic/meson64_odroidc4.dts index b7fcced..a8aeb3a 100644 --- a/arch/arm64/boot/dts/amlogic/meson64_odroidc4.dts +++ b/arch/arm64/boot/dts/amlogic/meson64_odroidc4.dts @@ -74,6 +74,7 @@ /* POST PROCESS MANAGER */ ppmgr_reserved:linux,ppmgr { + status = "disable"; compatible = "shared-dma-pool"; size = <0x0 0x0>; }; @@ -127,6 +128,7 @@ }; /* codec shared reserved */ codec_mm_reserved:linux,codec_mm_reserved { + status = "disable"; compatible = "amlogic, codec-mm-reserved"; size = <0x0 0x0>; alignment = <0x0 0x100000>; diff --git a/arch/arm64/boot/dts/amlogic/meson64_odroidn2.dtsi b/arch/arm64/boot/dts/amlogic/meson64_odroidn2.dtsi index 4564b01..a07676e 100644 --- a/arch/arm64/boot/dts/amlogic/meson64_odroidn2.dtsi +++ b/arch/arm64/boot/dts/amlogic/meson64_odroidn2.dtsi @@ -85,6 +85,7 @@ }; /* POST PROCESS MANAGER */ ppmgr_reserved:linux,ppmgr { + status = "disable"; compatible = "shared-dma-pool"; size = <0x0 0x0>; }; @@ -99,6 +100,7 @@ }; /* codec shared reserved */ codec_mm_reserved:linux,codec_mm_reserved { + status = "disable"; compatible = "amlogic, codec-mm-reserved"; size = <0x0 0x0>; alignment = <0x0 0x100000>; -- 2.7.4 From e4fd24aeabed64cd82033a53f0ef130a07f2932d Mon Sep 17 00:00:00 2001 From: Seung-Woo Kim Date: Mon, 25 Jan 2021 15:40:42 +0900 Subject: [PATCH 14/16] amlogic: mm: Add aml_task_stack() in amlogic vmap In kerne, there are several places to get stack page address of task and when using AMLOGIC_VMAP, task_stack_page() does not return page address. Add aml_task_stack() to get task stack page for amlogic vmap. Change-Id: I64cd827f98bec74357227dcc3ed546807b5406e3 Signed-off-by: Seung-Woo Kim --- drivers/amlogic/memory_ext/vmap_stack.c | 16 ++++++++++++++++ include/linux/amlogic/vmap_stack.h | 1 + 2 files changed, 17 insertions(+) diff --git a/drivers/amlogic/memory_ext/vmap_stack.c b/drivers/amlogic/memory_ext/vmap_stack.c index 387fb80..7a98983 100644 --- a/drivers/amlogic/memory_ext/vmap_stack.c +++ b/drivers/amlogic/memory_ext/vmap_stack.c @@ -753,6 +753,22 @@ static void check_and_map_stack_shadow(unsigned long addr) } #endif +void *aml_task_stack(struct task_struct *tsk) +{ + unsigned long stack = (unsigned long)tsk->stack; + unsigned long addr; + struct page *page; + + if (unlikely(!is_vmap_addr(stack))) { + /* stack get from kmalloc, currently no method to get page */ + return NULL; + } + + addr = stack + STACK_TOP_PAGE_OFF; + page = vmalloc_to_page((const void *)addr); + return page ? page_address(page) : NULL; +} + void *aml_stack_alloc(int node, struct task_struct *tsk) { unsigned long bitmap_no, raw_start; diff --git a/include/linux/amlogic/vmap_stack.h b/include/linux/amlogic/vmap_stack.h index 9b1f868..419e908 100644 --- a/include/linux/amlogic/vmap_stack.h +++ b/include/linux/amlogic/vmap_stack.h @@ -76,6 +76,7 @@ extern void __setup_vmap_stack(unsigned long off); extern void update_vmap_stack(int diff); extern int get_vmap_stack_size(void); extern int is_vmap_addr(unsigned long addr); +extern void *aml_task_stack(struct task_struct *tsk); extern void aml_stack_free(struct task_struct *tsk); extern void *aml_stack_alloc(int node, struct task_struct *tsk); extern void aml_account_task_stack(struct task_struct *tsk, int account); -- 2.7.4 From 60021b40cb179630c2c7aae90a2a9882a7b18192 Mon Sep 17 00:00:00 2001 From: Seung-Woo Kim Date: Mon, 25 Jan 2021 15:44:20 +0900 Subject: [PATCH 15/16] kmemleak: Fix bad memory access with scan stack for amlogic vmap When AMLOGIC_VMAP is enabled, try_get_task_stack() returns address of stasck instead of page address. This causes bad memory access during kmemleak scan stack. Fix the bad memory access by using aml_task_stack(). Note: Maybe, get_task_stack() needs to call aml_task_stack() is required, but aml_task_stack() has no consideration for kmalloced task stack, so just fix from kmemleak. Change-Id: I58a2e324cb92cd692d2260c675e81d7d0715e96c Fixes: commit 4d6ae4359385 ("mm: optimize thread stack usage on arm64 [1/1]") Signed-off-by: Seung-Woo Kim --- mm/kmemleak.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mm/kmemleak.c b/mm/kmemleak.c index d05133b..7eeb84a 100644 --- a/mm/kmemleak.c +++ b/mm/kmemleak.c @@ -112,6 +112,10 @@ #include #include +#ifdef CONFIG_AMLOGIC_VMAP +#include +#endif + /* * Kmemleak configuration and common defines. */ @@ -1456,11 +1460,17 @@ static void kmemleak_scan(void) read_lock(&tasklist_lock); do_each_thread(g, p) { +#ifdef CONFIG_AMLOGIC_VMAP + void *stack = aml_task_stack(p); + if (stack) + scan_block(stack, stack + THREAD_SIZE, NULL); +#else void *stack = try_get_task_stack(p); if (stack) { scan_block(stack, stack + THREAD_SIZE, NULL); put_task_stack(p); } +#endif } while_each_thread(g, p); read_unlock(&tasklist_lock); } -- 2.7.4 From 326ee33b0b1d2d64ce7f7820c6bd0b96a49f3603 Mon Sep 17 00:00:00 2001 From: Seung-Woo Kim Date: Mon, 25 Jan 2021 15:48:02 +0900 Subject: [PATCH 16/16] amlogic: bt: Remove memory leak The prdata is covered by pdata from bt_probe, so there is memory leak for prdata. Remove the memory leak store prdata, and get pdata from prdata. This fixes following kmemleak issue: unreferenced object 0xffffffc00c39e300 (size 64): ... backtrace: [] create_object+0x278/0x580 [] kmemleak_alloc+0x74/0xa0 [] kmem_cache_alloc_trace+0x328/0x5e8 [] bt_probe+0x20c/0x870 ... Change-Id: Ic3f2091d16806dba0855927d048747b40cb96f80 Signed-off-by: Seung-Woo Kim --- drivers/amlogic/bluetooth/bt_device.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/drivers/amlogic/bluetooth/bt_device.c b/drivers/amlogic/bluetooth/bt_device.c index 19f3bc9..b3bc97d 100644 --- a/drivers/amlogic/bluetooth/bt_device.c +++ b/drivers/amlogic/bluetooth/bt_device.c @@ -242,20 +242,34 @@ static void bt_lateresume(struct early_suspend *h) static int bt_suspend(struct platform_device *pdev, pm_message_t state) { - struct bt_dev_data *pdata = platform_get_drvdata(pdev); + struct bt_dev_runtime_data *prdata = + platform_get_drvdata(pdev); + struct bt_dev_data *pdata; pr_info("bt suspend\n"); - enable_irq(pdata->irqno_wakeup); + + if (prdata) { + pdata = prdata->pdata; + if (pdata) + enable_irq(pdata->irqno_wakeup); + } return 0; } static int bt_resume(struct platform_device *pdev) { - struct bt_dev_data *pdata = platform_get_drvdata(pdev); + struct bt_dev_runtime_data *prdata = + platform_get_drvdata(pdev); + struct bt_dev_data *pdata; pr_info("bt resume\n"); - disable_irq(pdata->irqno_wakeup); + + if (prdata) { + pdata = prdata->pdata; + if (pdata) + disable_irq(pdata->irqno_wakeup); + } return 0; } @@ -401,8 +415,6 @@ static int bt_probe(struct platform_device *pdev) register_early_suspend(&bt_early_suspend); #endif - platform_set_drvdata(pdev, pdata); - /*1.Set BT_WAKE_HOST to the input state;*/ /*2.Get interrupt number(irqno_wakeup).*/ pdata->irqno_wakeup = gpio_to_irq(pdata->gpio_btwakeup); -- 2.7.4