From: 杜坤明 Date: Sat, 4 Jun 2011 06:36:15 +0000 (+0800) Subject: gpu: update to 2.5.3.2.2; add auto freq switch; fix some game crash. X-Git-Tag: firefly_0821_release~10235 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=e3c3a35d9882c54087e56f1b36feaa4fff0be057;p=firefly-linux-kernel-4.4.55.git gpu: update to 2.5.3.2.2; add auto freq switch; fix some game crash. --- diff --git a/drivers/staging/rk29/vivante/arch/XAQ2/hal/kernel/gc_hal_kernel_hardware.c b/drivers/staging/rk29/vivante/arch/XAQ2/hal/kernel/gc_hal_kernel_hardware.c old mode 100755 new mode 100644 index e518bd6cdd06..9bfaa9aa3c3c --- a/drivers/staging/rk29/vivante/arch/XAQ2/hal/kernel/gc_hal_kernel_hardware.c +++ b/drivers/staging/rk29/vivante/arch/XAQ2/hal/kernel/gc_hal_kernel_hardware.c @@ -26,7 +26,8 @@ #define _GC_OBJ_ZONE gcvZONE_HARDWARE -#if gcdENABLE_AUTO_FREQ +// dkm: gcdENABLE_AUTO_FREQ +#if (1==gcdENABLE_AUTO_FREQ) #include #include u32 usec_run = 0; @@ -90,9 +91,33 @@ inline void cal_run_idle(gceCHIPPOWERSTATE State) lastState = State; } - +#elif (2==gcdENABLE_AUTO_FREQ) +#include +gceCHIPPOWERSTATE lastState = gcvPOWER_IDLE; +int lasthighfreq = 0; +extern int needhighfreq; +struct clk *clk_gpu = NULL; +inline void get_idle_change(gceCHIPPOWERSTATE State) +{ + if(gcvPOWER_ON!=lastState && gcvPOWER_ON==State) //gcvPOWER_IDLE->gcvPOWER_ON + { + if(lasthighfreq != needhighfreq) { + int gpufreq = needhighfreq ? 552 : 360; + clk_gpu = clk_get(NULL, "gpu"); + clk_set_parent(clk_gpu, clk_get(NULL, "general_pll")); + clk_set_rate(clk_get(NULL, "codec_pll"), gpufreq*1000000); + clk_set_rate(clk_gpu, gpufreq*1000000); + clk_set_parent(clk_gpu, clk_get(NULL, "codec_pll")); + lasthighfreq = needhighfreq; + + printk("gpu: change freq to %d \n", gpufreq); + } + } + lastState = State; +} #endif +// dkm: gcdENABLE_LONG_IDLE_POWEROFF #if gcdENABLE_LONG_IDLE_POWEROFF #include struct delayed_work poweroff_work; @@ -122,7 +147,8 @@ _IdentifyHardware( OUT gctUINT32_PTR ChipRevision, OUT gctUINT32_PTR ChipFeatures, OUT gctUINT32_PTR ChipMinorFeatures0, - OUT gctUINT32_PTR ChipMinorFeatures1 + OUT gctUINT32_PTR ChipMinorFeatures1, + OUT gctUINT32_PTR ChipMinorFeatures2 ) { gceSTATUS status; @@ -200,6 +226,7 @@ _IdentifyHardware( /* GC500 rev 1.x and GC300 rev < 2.0 doesn't have these registers. */ *ChipMinorFeatures0 = 0; *ChipMinorFeatures1 = 0; + *ChipMinorFeatures2 = 0; } else { @@ -209,6 +236,8 @@ _IdentifyHardware( 0x00034, ChipMinorFeatures0)); + *ChipMinorFeatures0 = ((((gctUINT32) (*ChipMinorFeatures0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 27:27) - (0 ? 27:27) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 27:27) - (0 ? 27:27) + 1))))))) << (0 ? 27:27))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? 27:27) - (0 ? 27:27) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 27:27) - (0 ? 27:27) + 1))))))) << (0 ? 27:27))); + if (((((gctUINT32) (*ChipMinorFeatures0)) >> (0 ? 21:21) & ((gctUINT32) ((((1 ? 21:21) - (0 ? 21:21) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 21:21) - (0 ? 21:21) + 1)))))) == (0x1 & ((gctUINT32) ((((1 ? 21:21) - (0 ? 21:21) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 21:21) - (0 ? 21:21) + 1))))))) ) { @@ -217,19 +246,35 @@ _IdentifyHardware( gckOS_ReadRegister(Os, 0x00074, ChipMinorFeatures1)); + + /* Read chip minor featuress register #1. */ +#if defined GC_MINOR_FEATURES2_Address + gcmkONERROR( + gckOS_ReadRegister(Os, + GC_MINOR_FEATURES2_Address, + ChipMinorFeatures2)); +#else + /* Chip doesn't has minor features register 2. */ + *ChipMinorFeatures2 = 0; +#endif } else { - /* Chip doesn't has minor features register #1. */ + /* Chip doesn't has minor features register #1 or 2. */ *ChipMinorFeatures1 = 0; + *ChipMinorFeatures2 = 0; } } + *ChipMinorFeatures0 = ((((gctUINT32) (*ChipMinorFeatures0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 27:27) - (0 ? 27:27) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 27:27) - (0 ? 27:27) + 1))))))) << (0 ? 27:27))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? 27:27) - (0 ? 27:27) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 27:27) - (0 ? 27:27) + 1))))))) << (0 ? 27:27))); + /* Success. */ - gcmkFOOTER_ARG("*ChipModel=%x *ChipRevision=%x *ChipFeatures=%08x " - "*ChipMinorFeatures0=%08X *ChipMinorFeatures1=%08x", + gcmkFOOTER_ARG("*ChipModel=%x *ChipRevision=%x *ChipFeatures=0x%08x " + "*ChipMinorFeatures0=0x%08X *ChipMinorFeatures1=0x%08x " + "*ChipMinorFeatures2=0x%08x", *ChipModel, *ChipRevision, *ChipFeatures, - *ChipMinorFeatures0, *ChipMinorFeatures1); + *ChipMinorFeatures0, *ChipMinorFeatures1, + *ChipMinorFeatures2); return gcvSTATUS_OK; OnError: @@ -387,6 +432,7 @@ gckHARDWARE_Construct( gctUINT32 chipFeatures; gctUINT32 chipMinorFeatures0; gctUINT32 chipMinorFeatures1; + gctUINT32 chipMinorFeatures2; gctUINT16 data = 0xff00; gcmkHEADER_ARG("Os=0x%x", Os); @@ -405,7 +451,8 @@ gckHARDWARE_Construct( &chipRevision, &chipFeatures, &chipMinorFeatures0, - &chipMinorFeatures1)); + &chipMinorFeatures1, + &chipMinorFeatures2)); /* Allocate the gckHARDWARE object. */ gcmkONERROR(gckOS_Allocate(Os, @@ -422,6 +469,7 @@ gckHARDWARE_Construct( hardware->chipFeatures = chipFeatures; hardware->chipMinorFeatures0 = chipMinorFeatures0; hardware->chipMinorFeatures1 = chipMinorFeatures1; + hardware->chipMinorFeatures2 = chipMinorFeatures2; hardware->powerBaseAddress = ( (chipModel == gcv300) && (chipRevision < 0x2000) ) ? 0x100 : 0x00; @@ -451,6 +499,7 @@ gckHARDWARE_Construct( /* Return pointer to the gckHARDWARE object. */ *Hardware = hardware; +// dkm: gcdENABLE_LONG_IDLE_POWEROFF #if gcdENABLE_LONG_IDLE_POWEROFF INIT_DELAYED_WORK(&poweroff_work, time_to_poweroff); gHardware = hardware; @@ -814,6 +863,10 @@ gckHARDWARE_QueryMemory( ** If 'ChipMinorFeatures1' is not gcvNULL, the variable it points to ** will receive the minor feature set 1 of the chip. ** +** gctUINT32 * ChipMinorFeatures2 +** If 'ChipMinorFeatures2' is not gcvNULL, the variable it points to +** will receive the minor feature set 2 of the chip. +** */ gceSTATUS gckHARDWARE_QueryChipIdentity( @@ -822,7 +875,8 @@ gckHARDWARE_QueryChipIdentity( OUT gctUINT32 * ChipRevision, OUT gctUINT32* ChipFeatures, OUT gctUINT32* ChipMinorFeatures, - OUT gctUINT32* ChipMinorFeatures1 + OUT gctUINT32* ChipMinorFeatures1, + OUT gctUINT32* ChipMinorFeatures2 ) { gcmkHEADER_ARG("Hardware=0x%x", Hardware); @@ -885,12 +939,21 @@ gckHARDWARE_QueryChipIdentity( *ChipMinorFeatures1 = Hardware->chipMinorFeatures1; } + /* Return minor feature set 2. */ + if (ChipMinorFeatures2 != gcvNULL) + { + *ChipMinorFeatures2 = Hardware->chipMinorFeatures2; + } + /* Success. */ gcmkFOOTER_ARG("*ChipModel=0x%x *ChipRevision=0x%x *ChipFeatures=0x%08x " - "*ChipMinorFeatures=0x%08x *ChipMinorFeatures1=0x%08x", + "*ChipMinorFeatures=0x%08x *ChipMinorFeatures1=0x%08x " + "*ChipMinorFeatures2=0x%08x", gcmOPT_VALUE(ChipModel), gcmOPT_VALUE(ChipRevision), gcmOPT_VALUE(ChipFeatures), gcmOPT_VALUE(ChipMinorFeatures), - gcmOPT_VALUE(ChipMinorFeatures1)); + gcmOPT_VALUE(ChipMinorFeatures1), + gcmOPT_VALUE(ChipMinorFeatures2)); + return gcvSTATUS_OK; } @@ -2641,6 +2704,7 @@ gckHARDWARE_GetIdle( pollCount = Wait ? 100 : 1; /* At most, try for 1 second. */ + // dkm: 1000³¬Ê±Ì«³¤ÁË£¬¸ÄΪ200 for (retry = 0; retry < 200; ++retry) { /* If we have to wait, try 100 polls per millisecond. */ @@ -2896,6 +2960,7 @@ gckHARDWARE_SetPowerManagementState( gctBOOL stall = gcvTRUE; gctBOOL broadcast = gcvFALSE; gctUINT32 process, thread; +// dkm: gcdENABLE_LONG_IDLE_POWEROFF #if gcdENABLE_LONG_IDLE_POWEROFF gceCHIPPOWERSTATE curState = State; #endif @@ -2942,6 +3007,7 @@ gckHARDWARE_SetPowerManagementState( }, /* gcvPOWER_SUSPEND */ + // dkm: Õâ±ß©ÁËgcvPOWER_FLAG_INITIALIZE { /* ON */ gcvPOWER_FLAG_INITIALIZE | gcvPOWER_FLAG_START | gcvPOWER_FLAG_RELEASE | @@ -2949,6 +3015,7 @@ gckHARDWARE_SetPowerManagementState( /* OFF */ gcvPOWER_FLAG_SAVE | gcvPOWER_FLAG_OFF | gcvPOWER_FLAG_CLOCK_OFF, + // dkm: Õâ±ß©ÁËgcvPOWER_FLAG_INITIALIZE /* IDLE */ gcvPOWER_FLAG_INITIALIZE | gcvPOWER_FLAG_START | gcvPOWER_FLAG_DELAY, @@ -2963,22 +3030,26 @@ gckHARDWARE_SetPowerManagementState( ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 0:0) - (0 ? 0:0) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 0:0) - (0 ? 0:0) + 1))))))) << (0 ? 0:0))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? 0:0) - (0 ? 0:0) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 0:0) - (0 ? 0:0) + 1))))))) << (0 ? 0:0)))| ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 1:1) - (0 ? 1:1) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 1:1) - (0 ? 1:1) + 1))))))) << (0 ? 1:1))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? 1:1) - (0 ? 1:1) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 1:1) - (0 ? 1:1) + 1))))))) << (0 ? 1:1)))| ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 8:2) - (0 ? 8:2) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 8:2) - (0 ? 8:2) + 1))))))) << (0 ? 8:2))) | (((gctUINT32) ((gctUINT32) (64) & ((gctUINT32) ((((1 ? 8:2) - (0 ? 8:2) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 8:2) - (0 ? 8:2) + 1))))))) << (0 ? 8:2)))| - ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 9:9) - (0 ? 9:9) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 9:9) - (0 ? 9:9) + 1))))))) << (0 ? 9:9))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? 9:9) - (0 ? 9:9) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 9:9) - (0 ? 9:9) + 1))))))) << (0 ? 9:9))) , + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 9:9) - (0 ? 9:9) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 9:9) - (0 ? 9:9) + 1))))))) << (0 ? 9:9))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? 9:9) - (0 ? 9:9) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 9:9) - (0 ? 9:9) + 1))))))) << (0 ? 9:9))), + /* gcvPOWER_OFF */ ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 0:0) - (0 ? 0:0) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 0:0) - (0 ? 0:0) + 1))))))) << (0 ? 0:0))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? 0:0) - (0 ? 0:0) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 0:0) - (0 ? 0:0) + 1))))))) << (0 ? 0:0)))| ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 1:1) - (0 ? 1:1) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 1:1) - (0 ? 1:1) + 1))))))) << (0 ? 1:1))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? 1:1) - (0 ? 1:1) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 1:1) - (0 ? 1:1) + 1))))))) << (0 ? 1:1)))| ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 8:2) - (0 ? 8:2) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 8:2) - (0 ? 8:2) + 1))))))) << (0 ? 8:2))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? 8:2) - (0 ? 8:2) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 8:2) - (0 ? 8:2) + 1))))))) << (0 ? 8:2)))| - ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 9:9) - (0 ? 9:9) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 9:9) - (0 ? 9:9) + 1))))))) << (0 ? 9:9))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? 9:9) - (0 ? 9:9) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 9:9) - (0 ? 9:9) + 1))))))) << (0 ? 9:9))) , + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 9:9) - (0 ? 9:9) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 9:9) - (0 ? 9:9) + 1))))))) << (0 ? 9:9))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? 9:9) - (0 ? 9:9) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 9:9) - (0 ? 9:9) + 1))))))) << (0 ? 9:9))), + /* gcvPOWER_IDLE */ ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 0:0) - (0 ? 0:0) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 0:0) - (0 ? 0:0) + 1))))))) << (0 ? 0:0))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? 0:0) - (0 ? 0:0) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 0:0) - (0 ? 0:0) + 1))))))) << (0 ? 0:0)))| ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 1:1) - (0 ? 1:1) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 1:1) - (0 ? 1:1) + 1))))))) << (0 ? 1:1))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ? 1:1) - (0 ? 1:1) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 1:1) - (0 ? 1:1) + 1))))))) << (0 ? 1:1)))| ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 8:2) - (0 ? 8:2) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 8:2) - (0 ? 8:2) + 1))))))) << (0 ? 8:2))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? 8:2) - (0 ? 8:2) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 8:2) - (0 ? 8:2) + 1))))))) << (0 ? 8:2)))| - ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 9:9) - (0 ? 9:9) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 9:9) - (0 ? 9:9) + 1))))))) << (0 ? 9:9))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? 9:9) - (0 ? 9:9) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 9:9) - (0 ? 9:9) + 1))))))) << (0 ? 9:9))) , + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 9:9) - (0 ? 9:9) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 9:9) - (0 ? 9:9) + 1))))))) << (0 ? 9:9))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? 9:9) - (0 ? 9:9) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 9:9) - (0 ? 9:9) + 1))))))) << (0 ? 9:9))), + /* gcvPOWER_SUSPEND */ ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 0:0) - (0 ? 0:0) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 0:0) - (0 ? 0:0) + 1))))))) << (0 ? 0:0))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? 0:0) - (0 ? 0:0) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 0:0) - (0 ? 0:0) + 1))))))) << (0 ? 0:0)))| ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 1:1) - (0 ? 1:1) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 1:1) - (0 ? 1:1) + 1))))))) << (0 ? 1:1))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? 1:1) - (0 ? 1:1) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 1:1) - (0 ? 1:1) + 1))))))) << (0 ? 1:1)))| ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 8:2) - (0 ? 8:2) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 8:2) - (0 ? 8:2) + 1))))))) << (0 ? 8:2))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? 8:2) - (0 ? 8:2) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 8:2) - (0 ? 8:2) + 1))))))) << (0 ? 8:2)))| - ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 9:9) - (0 ? 9:9) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 9:9) - (0 ? 9:9) + 1))))))) << (0 ? 9:9))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? 9:9) - (0 ? 9:9) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 9:9) - (0 ? 9:9) + 1))))))) << (0 ? 9:9))), }; + ((((gctUINT32) (0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? 9:9) - (0 ? 9:9) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 9:9) - (0 ? 9:9) + 1))))))) << (0 ? 9:9))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ? 9:9) - (0 ? 9:9) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 9:9) - (0 ? 9:9) + 1))))))) << (0 ? 9:9))), + }; gcmkHEADER_ARG("Hardware=0x%x State=%d", Hardware, State); @@ -3039,11 +3110,7 @@ gckHARDWARE_SetPowerManagementState( default: break; } - -#if gcdENABLE_AUTO_FREQ - cal_run_idle(State); -#endif - + /* Get current process and thread IDs. */ gcmkONERROR(gckOS_GetProcessID(&process)); gcmkONERROR(gckOS_GetThreadID(&thread)); @@ -3064,7 +3131,8 @@ gckHARDWARE_SetPowerManagementState( gcmkFOOTER_NO(); return gcvSTATUS_OK; } - else if(gcvPOWER_IDLE==State) // dkm add 110330 + // dkm: add 110330 + else if(gcvPOWER_IDLE==State) { /* Bail out on idle broadcast with other process is setting power. */ gcmkFOOTER_NO(); @@ -3087,11 +3155,19 @@ gckHARDWARE_SetPowerManagementState( Hardware->powerProcess = process; Hardware->powerThread = thread; mutexAcquired = gcvTRUE; + +// dkm: gcdENABLE_AUTO_FREQ +#if (1==gcdENABLE_AUTO_FREQ) + cal_run_idle(State); +#elif (2==gcdENABLE_AUTO_FREQ) + get_idle_change(State); +#endif /* Grab control flags and clock. */ flag = flags[Hardware->chipPowerState][State]; clock = clocks[State]; +// dkm: gcdENABLE_LONG_IDLE_POWEROFF #if gcdENABLE_LONG_IDLE_POWEROFF if(gcvPOWER_IDLE_BROADCAST==curState) { cancel_delayed_work_sync(&poweroff_work); @@ -3105,15 +3181,16 @@ gckHARDWARE_SetPowerManagementState( if ((flag == 0) || (Hardware->settingPowerState)) { +// dkm: gcdENABLE_LONG_IDLE_POWEROFF #if gcdENABLE_LONG_IDLE_POWEROFF if( (gcvPOWER_OFF==Hardware->chipPowerState) && (gcvPOWER_OFF==State) && (gcvFALSE==broadcast) ) { Hardware->broadcast = gcvFALSE; } #endif + Hardware->powerProcess = Hardware->powerThread = 0x0; + /* Release the power mutex. */ - Hardware->powerProcess = 0; - Hardware->powerThread = 0; gcmkONERROR(gckOS_ReleaseMutex(os, Hardware->powerMutex)); /* No need to do anything. */ @@ -3125,9 +3202,9 @@ gckHARDWARE_SetPowerManagementState( && (Hardware->chipPowerState == gcvPOWER_OFF) ) { + Hardware->powerProcess = Hardware->powerThread = 0x0; + /* Release the power mutex. */ - Hardware->powerProcess = 0; - Hardware->powerThread = 0; gcmkONERROR(gckOS_ReleaseMutex(os, Hardware->powerMutex)); /* No broadcast while GPU is forced power off. */ @@ -3217,6 +3294,9 @@ gckHARDWARE_SetPowerManagementState( { /* Stop the command parser. */ gcmkONERROR(gckCOMMAND_Stop(command)); + + /* Stop the Isr. */ + gcmkONERROR(Hardware->stopIsr(Hardware->isrContext)); } /* Write the clock control register. */ @@ -3265,6 +3345,9 @@ gckHARDWARE_SetPowerManagementState( { /* Start the command processor. */ gcmkONERROR(gckCOMMAND_Start(command)); + + /* Start the Isr. */ + gcmkONERROR(Hardware->startIsr(Hardware->isrContext)); } if (flag & gcvPOWER_FLAG_RELEASE) @@ -3277,10 +3360,9 @@ gckHARDWARE_SetPowerManagementState( Hardware->chipPowerState = State; Hardware->broadcast = broadcast; Hardware->settingPowerState = gcvFALSE; + Hardware->powerProcess = Hardware->powerThread = 0x0; /* Release the power mutex. */ - Hardware->powerProcess = 0; - Hardware->powerThread = 0; gcmkONERROR(gckOS_ReleaseMutex(os, Hardware->powerMutex)); /* Success. */ @@ -3304,9 +3386,8 @@ OnError: if (mutexAcquired) { Hardware->settingPowerState = gcvFALSE; + Hardware->powerProcess = Hardware->powerThread = 0x0; - Hardware->powerProcess = 0; - Hardware->powerThread = 0; gcmkVERIFY_OK(gckOS_ReleaseMutex(Hardware->os, Hardware->powerMutex)); } @@ -3904,3 +3985,39 @@ gckHARDWARE_NeedBaseAddress( return gcvSTATUS_OK; } +gceSTATUS +gckHARDWARE_SetIsrManager( + IN gckHARDWARE Hardware, + IN gctISRMANAGERFUNC StartIsr, + IN gctISRMANAGERFUNC StopIsr, + IN gctPOINTER Context + ) +{ + gceSTATUS status = gcvSTATUS_OK; + + gcmkHEADER_ARG("Hardware=0x%x, StartIsr=0x%x, StopIsr=0x%x, Context=0x%x", + Hardware, StartIsr, StopIsr, Context); + + /* Verify the arguments. */ + gcmkVERIFY_OBJECT(Hardware, gcvOBJ_HARDWARE); + + if (StartIsr == gcvNULL || + StopIsr == gcvNULL || + Context == gcvNULL) + { + status = gcvSTATUS_INVALID_ARGUMENT; + + gcmkFOOTER(); + return status; + } + + Hardware->startIsr = StartIsr; + Hardware->stopIsr = StopIsr; + Hardware->isrContext = Context; + + /* Success. */ + gcmkFOOTER(); + + return status; +} + diff --git a/drivers/staging/rk29/vivante/arch/XAQ2/hal/kernel/gc_hal_kernel_hardware.h b/drivers/staging/rk29/vivante/arch/XAQ2/hal/kernel/gc_hal_kernel_hardware.h old mode 100755 new mode 100644 index 2b8592a1ea81..67b7d53543f6 --- a/drivers/staging/rk29/vivante/arch/XAQ2/hal/kernel/gc_hal_kernel_hardware.h +++ b/drivers/staging/rk29/vivante/arch/XAQ2/hal/kernel/gc_hal_kernel_hardware.h @@ -46,6 +46,7 @@ struct _gckHARDWARE gctUINT32 chipFeatures; gctUINT32 chipMinorFeatures0; gctUINT32 chipMinorFeatures1; + gctUINT32 chipMinorFeatures2; gctBOOL allowFastClear; gctBOOL allowCompression; gctUINT32 powerBaseAddress; @@ -69,6 +70,10 @@ struct _gckHARDWARE gctBOOL broadcast; gctBOOL settingPowerState; gctUINT32 lastWaitLink; + + gctISRMANAGERFUNC startIsr; + gctISRMANAGERFUNC stopIsr; + gctPOINTER isrContext; }; gceSTATUS diff --git a/drivers/staging/rk29/vivante/arch/XAQ2/hal/kernel/makefile.linux b/drivers/staging/rk29/vivante/arch/XAQ2/hal/kernel/makefile.linux index ca9f433c7297..fc674ca4813d 100644 --- a/drivers/staging/rk29/vivante/arch/XAQ2/hal/kernel/makefile.linux +++ b/drivers/staging/rk29/vivante/arch/XAQ2/hal/kernel/makefile.linux @@ -1,6 +1,6 @@ ############################################################################## # -# Copyright (C) 2005 - 2010 by Vivante Corp. +# Copyright (C) 2005 - 2011 by Vivante Corp. # # 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 diff --git a/drivers/staging/rk29/vivante/config b/drivers/staging/rk29/vivante/config index 779ac82311b4..f57be0d2750a 100644 --- a/drivers/staging/rk29/vivante/config +++ b/drivers/staging/rk29/vivante/config @@ -1,6 +1,6 @@ ############################################################################## # -# Copyright (C) 2005 - 2010 by Vivante Corp. +# Copyright (C) 2005 - 2011 by Vivante Corp. # # 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 diff --git a/drivers/staging/rk29/vivante/hal/inc/gc_hal.h b/drivers/staging/rk29/vivante/hal/inc/gc_hal.h old mode 100755 new mode 100644 index cbfa92cc0b3e..f1a37bda0ff9 --- a/drivers/staging/rk29/vivante/hal/inc/gc_hal.h +++ b/drivers/staging/rk29/vivante/hal/inc/gc_hal.h @@ -1,6 +1,6 @@ /**************************************************************************** * -* Copyright (C) 2005 - 2010 by Vivante Corp. +* Copyright (C) 2005 - 2011 by Vivante Corp. * * 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 @@ -24,6 +24,7 @@ #ifndef __gc_hal_h_ #define __gc_hal_h_ +// dkm: ·½±ãµ÷ÓÃϵͳµÄº¯Êý #include #include "gc_hal_types.h" #include "gc_hal_enum.h" @@ -775,6 +776,14 @@ gckOS_WaitSignal( IN gctUINT32 Wait ); +/* Wait for a signal uninterruptibly. */ +gceSTATUS +gckOS_WaitSignalUninterruptible( + IN gckOS Os, + IN gctSIGNAL Signal, + IN gctUINT32 Wait + ); + /* Map a user signal to the kernel space. */ gceSTATUS gckOS_MapSignal( @@ -1053,14 +1062,6 @@ gckHEAP_ProfileEnd( IN gctCONST_STRING Title ); -#if defined gcdHAL_TEST -gceSTATUS -gckHEAP_Test( - IN gckHEAP Heap, - IN gctSIZE_T Vectors, - IN gctSIZE_T MaxSize - ); -#endif /******************************************************************************\ ******************************** gckVIDMEM Object ****************************** @@ -1457,7 +1458,8 @@ gckHARDWARE_QueryChipIdentity( OUT gctUINT32* ChipRevision, OUT gctUINT32* ChipFeatures, OUT gctUINT32* ChipMinorFeatures, - OUT gctUINT32* ChipMinorFeatures1 + OUT gctUINT32* ChipMinorFeatures1, + OUT gctUINT32* ChipMinorFeatures2 ); /* Query the specifications sof the hardware. */ @@ -1607,6 +1609,16 @@ gckHARDWARE_Reset( IN gckHARDWARE Hardware ); +typedef gceSTATUS (*gctISRMANAGERFUNC)(gctPOINTER Context); + +gceSTATUS +gckHARDWARE_SetIsrManager( + IN gckHARDWARE Hardware, + IN gctISRMANAGERFUNC StartIsr, + IN gctISRMANAGERFUNC StopIsr, + IN gctPOINTER Context + ); + /******************************************************************************\ ***************************** gckINTERRUPT Object ****************************** \******************************************************************************/ @@ -1859,14 +1871,6 @@ gckMMU_FreeHandleMemory( ); #endif -#if defined gcdHAL_TEST -gceSTATUS -gckMMU_Test( - IN gckMMU Mmu, - IN gctSIZE_T Vectors, - IN gctINT MaxSize - ); -#endif gceSTATUS gckHARDWARE_QueryProfileRegisters( diff --git a/drivers/staging/rk29/vivante/hal/inc/gc_hal_base.h b/drivers/staging/rk29/vivante/hal/inc/gc_hal_base.h index 7d6714f64cb6..3e7b65ae029c 100644 --- a/drivers/staging/rk29/vivante/hal/inc/gc_hal_base.h +++ b/drivers/staging/rk29/vivante/hal/inc/gc_hal_base.h @@ -1,6 +1,6 @@ /**************************************************************************** * -* Copyright (C) 2005 - 2010 by Vivante Corp. +* Copyright (C) 2005 - 2011 by Vivante Corp. * * 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 @@ -193,6 +193,13 @@ gcoHAL_QueryChipIdentity( OUT gctUINT32* ChipMinorFeatures ); +/* Query the minor features of the hardware. */ +gceSTATUS gcoHAL_QueryChipMinorFeatures( + IN gcoHAL Hal, + OUT gctUINT32* NumFeatures, + OUT gctUINT32* ChipMinorFeatures + ); + /* Query the amount of video memory. */ gceSTATUS gcoHAL_QueryVideoMemory( @@ -1406,6 +1413,13 @@ gcoSURF_QueryOrientation( OUT gceORIENTATION * Orientation ); +/*Reset the hal member of a surface*/ +gceSTATUS +gcoSURF_ResetHal( + IN gcoSURF Surface, + IN gcoHAL Hal + ); + /******************************************************************************\ ********************************* gcoDUMP Object ******************************** \******************************************************************************/ @@ -1588,14 +1602,6 @@ gcoHEAP_ProfileEnd( IN gctCONST_STRING Title ); -#if defined gcdHAL_TEST -gceSTATUS -gcoHEAP_Test( - IN gcoHEAP Heap, - IN gctSIZE_T Vectors, - IN gctSIZE_T MaxSize - ); -#endif /******************************************************************************\ ******************************* Debugging Macros ******************************* diff --git a/drivers/staging/rk29/vivante/hal/inc/gc_hal_compiler.h b/drivers/staging/rk29/vivante/hal/inc/gc_hal_compiler.h index 1f6cf3ff8296..a85a54a2bd68 100644 --- a/drivers/staging/rk29/vivante/hal/inc/gc_hal_compiler.h +++ b/drivers/staging/rk29/vivante/hal/inc/gc_hal_compiler.h @@ -1,6 +1,6 @@ /**************************************************************************** * -* Copyright (C) 2005 - 2010 by Vivante Corp. +* Copyright (C) 2005 - 2011 by Vivante Corp. * * 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 diff --git a/drivers/staging/rk29/vivante/hal/inc/gc_hal_driver.h b/drivers/staging/rk29/vivante/hal/inc/gc_hal_driver.h index c1a983514b87..7a44306d5e13 100644 --- a/drivers/staging/rk29/vivante/hal/inc/gc_hal_driver.h +++ b/drivers/staging/rk29/vivante/hal/inc/gc_hal_driver.h @@ -1,6 +1,6 @@ /**************************************************************************** * -* Copyright (C) 2005 - 2010 by Vivante Corp. +* Copyright (C) 2005 - 2011 by Vivante Corp. * * 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 @@ -194,6 +194,9 @@ typedef struct _gcsHAL_INTERFACE /* Supported minor feature 1 fields. */ OUT gctUINT32 chipMinorFeatures1; + /* Supported minor feature 2 fields. */ + OUT gctUINT32 chipMinorFeatures2; + /* Number of streams supported. */ OUT gctUINT32 streamCount; diff --git a/drivers/staging/rk29/vivante/hal/inc/gc_hal_dump.h b/drivers/staging/rk29/vivante/hal/inc/gc_hal_dump.h index 2264b60cf612..b3e80c91685b 100644 --- a/drivers/staging/rk29/vivante/hal/inc/gc_hal_dump.h +++ b/drivers/staging/rk29/vivante/hal/inc/gc_hal_dump.h @@ -1,6 +1,6 @@ /**************************************************************************** * -* Copyright (C) 2005 - 2010 by Vivante Corp. +* Copyright (C) 2005 - 2011 by Vivante Corp. * * 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 diff --git a/drivers/staging/rk29/vivante/hal/inc/gc_hal_engine.h b/drivers/staging/rk29/vivante/hal/inc/gc_hal_engine.h index 3cca85fd1a56..6ceac6ec1893 100644 --- a/drivers/staging/rk29/vivante/hal/inc/gc_hal_engine.h +++ b/drivers/staging/rk29/vivante/hal/inc/gc_hal_engine.h @@ -1,6 +1,6 @@ /**************************************************************************** * -* Copyright (C) 2005 - 2010 by Vivante Corp. +* Copyright (C) 2005 - 2011 by Vivante Corp. * * 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 @@ -265,7 +265,6 @@ gcoSURF_ClearRect( ); /* TO BE REMOVED */ -#if 1 gceSTATUS depr_gcoSURF_Resolve( IN gcoSURF SrcSurface, @@ -294,7 +293,6 @@ gcoSURF_ClearRect( IN gcsPOINT_PTR DestOrigin, IN gcsPOINT_PTR RectSize ); -#endif /* Resample surface. */ gceSTATUS @@ -833,7 +831,8 @@ gco3D_SetStencilWriteMask( gceSTATUS gco3D_SetStencilReference( IN gco3D Engine, - IN gctUINT8 Reference + IN gctUINT8 Reference, + IN gctBOOL Front ); /* Set stencil compare. */ @@ -996,6 +995,27 @@ gco3D_SetCentroids( /*----------------------------------------------------------------------------*/ /*-------------------------- gco3D Fragment Processor ------------------------*/ +/* Set the fragment processor configuration. */ +gceSTATUS +gco3D_SetWClipEnable( + IN gco3D Engine, + IN gctBOOL Enable + ); + +gceSTATUS +gco3D_SetWPlaneLimitF( + IN gco3D Engine, + IN gctFLOAT Value + ); + +gceSTATUS +gco3D_SetWPlaneLimitX( + IN gco3D Engine, + IN gctFIXED_POINT Value + ); +/*----------------------------------------------------------------------------*/ +/*-------------------------- gco3D Fragment Processor ------------------------*/ + /* Set the fragment processor configuration. */ gceSTATUS gco3D_SetFragmentConfiguration( diff --git a/drivers/staging/rk29/vivante/hal/inc/gc_hal_enum.h b/drivers/staging/rk29/vivante/hal/inc/gc_hal_enum.h old mode 100755 new mode 100644 index d1cba5cbbf77..88787b19995f --- a/drivers/staging/rk29/vivante/hal/inc/gc_hal_enum.h +++ b/drivers/staging/rk29/vivante/hal/inc/gc_hal_enum.h @@ -94,8 +94,21 @@ typedef enum _gceFEATURE gcvFEATURE_VG_DOUBLE_BUFFER, gcvFEATURE_MC20, gcvFEATURE_SUPER_TILED, + + gcvFEATURE_2D_FILTERBLIT_PLUS_ALPHABLEND, gcvFEATURE_2D_DITHER, + gcvFEATURE_2D_A8_TARGET, + gcvFEATURE_2D_FILTERBLIT_FULLROTATION, + gcvFEATURE_2D_BITBLIT_FULLROTATION, + gcvFEATURE_WIDE_LINE, + gcvFEATURE_FC_FLUSH_STALL, + + gcvFEATURE_FULL_DIRECTFB, + gcvFEATURE_HALF_FLOAT_PIPE, + gcvFEATURE_LINE_LOOP, + gcvFEATURE_2D_YUV_BLIT, + gcvFEATURE_2D_TILING, } gceFEATURE; @@ -155,7 +168,9 @@ typedef enum _gceSURF_ROTATION gcvSURF_0_DEGREE, gcvSURF_90_DEGREE, gcvSURF_180_DEGREE, - gcvSURF_270_DEGREE + gcvSURF_270_DEGREE, + gcvSURF_FLIP_X, + gcvSURF_FLIP_Y, } gceSURF_ROTATION; @@ -284,14 +299,6 @@ typedef enum _gceSURF_FORMAT gcvSURF_G32R32F, gcvSURF_A32B32G32R32F, -#if 0 - /* FIXME: remove HDR support for now. */ - /* HDR formats. */ - gcvSURF_HDR7E3 = 1200, - gcvSURF_HDR6E4, - gcvSURF_HDR5E5, - gcvSURF_HDR6E5, -#endif } gceSURF_FORMAT; @@ -412,7 +419,12 @@ typedef enum _gceSURF_BLEND_FACTOR_MODE gcvSURF_BLEND_INVERSED, gcvSURF_BLEND_COLOR, gcvSURF_BLEND_COLOR_INVERSED, - gcvSURF_BLEND_SRC_ALPHA_SATURATED + gcvSURF_BLEND_SRC_ALPHA_SATURATED, + gcvSURF_BLEND_STRAIGHT_NO_CROSS, + gcvSURF_BLEND_INVERSED_NO_CROSS, + gcvSURF_BLEND_COLOR_NO_CROSS, + gcvSURF_BLEND_COLOR_INVERSED_NO_CROSS, + gcvSURF_BLEND_SRC_ALPHA_SATURATED_CROSS } gceSURF_BLEND_FACTOR_MODE; @@ -463,9 +475,11 @@ typedef enum _gce2D_COMMAND gcv2D_STRETCH, gcv2D_HOR_FILTER, gcv2D_VER_FILTER, + gcv2D_MULTI_SOURCE_BLEND, } gce2D_COMMAND; +#ifndef VIVANTE_NO_3D /* Texture functions. */ typedef enum _gceTEXTURE_FUNCTION { @@ -499,6 +513,7 @@ typedef enum _gceTEXTURE_CHANNEL gcvFROM_ONE_MINUS_ALPHA } gceTEXTURE_CHANNEL; +#endif /* VIVANTE_NO_3D */ /* Filter types. */ typedef enum _gceFILTER_TYPE @@ -526,15 +541,46 @@ typedef enum _gceENDIAN_HINT } gceENDIAN_HINT; -/* Endian hints. */ +/* Tiling modes. */ typedef enum _gceTILING { gcvLINEAR, gcvTILED, - gcvSUPERTILED + gcvSUPERTILED, + gcvMULTI_TILED, + gcvMULTI_SUPERTILED, } gceTILING; +/* 2D pattern type. */ +typedef enum _gce2D_PATTERN +{ + gcv2D_PATTERN_SOLID = 0, + gcv2D_PATTERN_MONO, + gcv2D_PATTERN_COLOR, + gcv2D_PATTERN_INVALID +} +gce2D_PATTERN; + +/* 2D source type. */ +typedef enum _gce2D_SOURCE +{ + gcv2D_SOURCE_MASKED = 0, + gcv2D_SOURCE_MONO, + gcv2D_SOURCE_COLOR, + gcv2D_SOURCE_INVALID +} +gce2D_SOURCE; + +/* Pipes. */ +typedef enum _gcePIPE_SELECT +{ + gcvPIPE_INVALID = ~0, + gcvPIPE_3D = 0, + gcvPIPE_2D +} +gcePIPE_SELECT; + /******************************************************************************\ ****************************** Object Declarations ***************************** \******************************************************************************/ @@ -551,3 +597,4 @@ typedef struct gcs2D_PROFILE * gcs2D_PROFILE_PTR; #endif /* __gc_hal_enum_h_ */ + diff --git a/drivers/staging/rk29/vivante/hal/inc/gc_hal_mem.h b/drivers/staging/rk29/vivante/hal/inc/gc_hal_mem.h index 9b7d28ccb1a5..8653f34c2d32 100644 --- a/drivers/staging/rk29/vivante/hal/inc/gc_hal_mem.h +++ b/drivers/staging/rk29/vivante/hal/inc/gc_hal_mem.h @@ -1,6 +1,6 @@ /**************************************************************************** * -* Copyright (C) 2005 - 2010 by Vivante Corp. +* Copyright (C) 2005 - 2011 by Vivante Corp. * * 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 diff --git a/drivers/staging/rk29/vivante/hal/inc/gc_hal_options.h b/drivers/staging/rk29/vivante/hal/inc/gc_hal_options.h old mode 100755 new mode 100644 index eb3debc75133..9260467964a0 --- a/drivers/staging/rk29/vivante/hal/inc/gc_hal_options.h +++ b/drivers/staging/rk29/vivante/hal/inc/gc_hal_options.h @@ -1,6 +1,6 @@ /**************************************************************************** * -* Copyright (C) 2005 - 2010 by Vivante Corp. +* Copyright (C) 2005 - 2011 by Vivante Corp. * * 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 @@ -83,28 +83,32 @@ */ #define USE_SUPER_SAMPLING 0 +/* PROFILE_HAL_COUNTERS, PROFILE_HW_COUNTERS, PROFILE_SHADER_COUNTERS are not runtime configurable. */ /* PROFILE_HAL_COUNTERS This define enables HAL counter profiling support. HW and SHADER Counter profiling depends on this. */ +/* #define PROFILE_HAL_COUNTERS 1 - +*/ /* PROFILE_HW_COUNTERS This define enables HW counter profiling support. */ +/* #define PROFILE_HW_COUNTERS 1 - +*/ /* PROFILE_SHADER_COUNTERS This define enables SHADER counter profiling support. */ +/* #define PROFILE_SHADER_COUNTERS 1 - +*/ /* COMMAND_PROCESSOR_VERSION @@ -182,6 +186,7 @@ Size of the MMU page table in bytes. Each 4 bytes can hold 4kB worth of virtual data. */ +// dkm£º ÐèÒª¸ÄΪ256,·ñÔòÓеÄÓÎÏ·²»¹» #define gcdMMU_SIZE (256 << 10) /* @@ -257,15 +262,16 @@ /* - gcdENABLE_AUTO_FREQ - - ¸ù¾ÝGPU¸ººÉ×Ô¶¯µ÷½ÚGPUµÄCOREƵÂÊ + dkm: gcdENABLE_AUTO_FREQ + 0: ¹Ø±Õ×Ô¶¯µ÷Ƶ + 1: ¸ù¾ÝGPU¸ººÉ×Ô¶¯µ÷½ÚGPUµÄCOREƵÂÊ + 2: ¸ù¾ÝÊÇ·ñÓÐ3DÓ¦ÓÃ×Ô¶¯µ÷Ƶ(ÓÐ3DÓ¦ÓÃÔÚÅÜʱ¸ßƵ£¬·ñÔòµÍƵ) */ -#define gcdENABLE_AUTO_FREQ 0 +#define gcdENABLE_AUTO_FREQ 2 /* - gcdENABLE_MEM_CACHE + dkm: gcdENABLE_MEM_CACHE ÅäÖÃGPUËùʹÓõÄmemoryÊÇ·ñ±»ARM Cache»òWriteCombineס 1: Cached @@ -276,7 +282,7 @@ /* - gcdENABLE_DELAY_EARLY_SUSPEND + dkm: gcdENABLE_DELAY_EARLY_SUSPEND ÔÚgpu_early_suspendÖÐʹÓÃÑÓʱ¹¤×÷¶ÓÁÐÀ´Ö´ÐÐsuspend, ±ÜÃâgpu_early_suspend¹ýÔçÖ´Ðе¼ÖÂÓû§Ï̵߳ÄÊÂÇ黹´¦Àí¸É¾» @@ -288,7 +294,7 @@ /* - gcdENABLE_LONG_IDLE_POWEROFF + dkm: gcdENABLE_LONG_IDLE_POWEROFF ³¤Ê±¼äIDLEºó½øÈëPowerOff, ¸Ã¹¦ÄÜ¿ªÆôºóÐèÒª°ÑEarlySuspend¹¦Äܹصô ÕâÑù¿ÉÒÔʹijЩ²»Ê¹ÓÃGPUµÄ³¡¾°µÄ¹¦ºÄ½øÒ»²½½µµÍ£¬ÈçÊÓƵ²¥·Åʱ£¬Ò»¼¶´ý»úʱ£¬ diff --git a/drivers/staging/rk29/vivante/hal/inc/gc_hal_profiler.h b/drivers/staging/rk29/vivante/hal/inc/gc_hal_profiler.h index 4e283bfa8802..bd9b30981971 100644 --- a/drivers/staging/rk29/vivante/hal/inc/gc_hal_profiler.h +++ b/drivers/staging/rk29/vivante/hal/inc/gc_hal_profiler.h @@ -1,6 +1,6 @@ /**************************************************************************** * -* Copyright (C) 2005 - 2010 by Vivante Corp. +* Copyright (C) 2005 - 2011 by Vivante Corp. * * 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 @@ -41,6 +41,569 @@ extern "C" { #define gcmPROFILE_GC(Hal, Enum, Value) do { } while (gcvFALSE) #endif +#ifndef gcdNEW_PROFILER_FILE +#define gcdNEW_PROFILER_FILE 1 +#endif + +#ifdef gcdNEW_PROFILER_FILE + +/* Category Constants. */ +#define VPHEADER 0x010000 +#define VPG_INFO 0x020000 +#define VPG_TIME 0x030000 +#define VPG_MEM 0x040000 +#define VPG_ES11 0x050000 +#define VPG_ES20 0x060000 +#define VPG_VG11 0x070000 +#define VPG_HAL 0x080000 +#define VPG_HW 0x090000 +#define VPG_GPU 0x0a0000 +#define VPG_VS 0x0b0000 +#define VPG_PS 0x0c0000 +#define VPG_PA 0x0d0000 +#define VPG_SETUP 0x0e0000 +#define VPG_RA 0x0f0000 +#define VPG_TX 0x100000 +#define VPG_PE 0x110000 +#define VPG_MC 0x120000 +#define VPG_AXI 0x130000 +#define VPG_PROG 0x140000 +#define VPG_PVS 0x150000 +#define VPG_PPS 0x160000 +#define VPG_FRAME 0x170000 +#define VPG_END 0xff0000 + +/* Info. */ +#define VPC_INFOCOMPANY (VPG_INFO + 1) +#define VPC_INFOVERSION (VPG_INFO + 2) +#define VPC_INFORENDERER (VPG_INFO + 3) +#define VPC_INFOREVISION (VPG_INFO + 4) +#define VPC_INFODRIVER (VPG_INFO + 5) + +/* Counter Constants. */ +#define VPC_ELAPSETIME 0x030001 +#define VPC_CPUTIME 0x030002 + +#define VPC_MEMMAXRES 0x040001 +#define VPC_MEMSHARED 0x040002 +#define VPC_MEMUNSHAREDDATA 0x040003 +#define VPC_MEMUNSHAREDSTACK 0x040004 + +/* OpenGL ES11 Counters. */ +#define VPC_ES11ACTIVETEXTURE (VPG_ES11 + 1) +#define VPC_ES11ALPHAFUNC (VPG_ES11 + 2) +#define VPC_ES11ALPHAFUNCX (VPG_ES11 + 3) +#define VPC_ES11BINDBUFFER (VPG_ES11 + 4) +#define VPC_ES11BINDTEXTURE (VPG_ES11 + 5) +#define VPC_ES11BLENDFUNC (VPG_ES11 + 6) +#define VPC_ES11BUFFERDATA (VPG_ES11 + 7) +#define VPC_ES11BUFFERSUBDATA (VPG_ES11 + 8) +#define VPC_ES11CLEAR (VPG_ES11 + 9) +#define VPC_ES11CLEARCOLOR (VPG_ES11 + 10) +#define VPC_ES11CLEARCOLORX (VPG_ES11 + 11) +#define VPC_ES11CLEARDEPTHF (VPG_ES11 + 12) +#define VPC_ES11CLEARDEPTHX (VPG_ES11 + 13) +#define VPC_ES11CLEARSTENCIL (VPG_ES11 + 14) +#define VPC_ES11CLIENTACTIVETEXTURE (VPG_ES11 + 15) +#define VPC_ES11CLIPPLANEF (VPG_ES11 + 16) +#define VPC_ES11CLIPPLANEX (VPG_ES11 + 17) +#define VPC_ES11COLOR4F (VPG_ES11 + 18) +#define VPC_ES11COLOR4UB (VPG_ES11 + 19) +#define VPC_ES11COLOR4X (VPG_ES11 + 20) +#define VPC_ES11COLORMASK (VPG_ES11 + 21) +#define VPC_ES11COLORPOINTER (VPG_ES11 + 22) +#define VPC_ES11COMPRESSEDTEXIMAGE2D (VPG_ES11 + 23) +#define VPC_ES11COMPRESSEDTEXSUBIMAGE2D (VPG_ES11 + 24) +#define VPC_ES11COPYTEXIMAGE2D (VPG_ES11 + 25) +#define VPC_ES11COPYTEXSUBIMAGE2D (VPG_ES11 + 26) +#define VPC_ES11CULLFACE (VPG_ES11 + 27) +#define VPC_ES11DELETEBUFFERS (VPG_ES11 + 28) +#define VPC_ES11DELETETEXTURES (VPG_ES11 + 29) +#define VPC_ES11DEPTHFUNC (VPG_ES11 + 30) +#define VPC_ES11DEPTHMASK (VPG_ES11 + 31) +#define VPC_ES11DEPTHRANGEF (VPG_ES11 + 32) +#define VPC_ES11DEPTHRANGEX (VPG_ES11 + 33) +#define VPC_ES11DISABLE (VPG_ES11 + 34) +#define VPC_ES11DISABLECLIENTSTATE (VPG_ES11 + 35) +#define VPC_ES11DRAWARRAYS (VPG_ES11 + 36) +#define VPC_ES11DRAWELEMENTS (VPG_ES11 + 37) +#define VPC_ES11ENABLE (VPG_ES11 + 38) +#define VPC_ES11ENABLECLIENTSTATE (VPG_ES11 + 39) +#define VPC_ES11FINISH (VPG_ES11 + 40) +#define VPC_ES11FLUSH (VPG_ES11 + 41) +#define VPC_ES11FOGF (VPG_ES11 + 42) +#define VPC_ES11FOGFV (VPG_ES11 + 43) +#define VPC_ES11FOGX (VPG_ES11 + 44) +#define VPC_ES11FOGXV (VPG_ES11 + 45) +#define VPC_ES11FRONTFACE (VPG_ES11 + 46) +#define VPC_ES11FRUSTUMF (VPG_ES11 + 47) +#define VPC_ES11FRUSTUMX (VPG_ES11 + 48) +#define VPC_ES11GENBUFFERS (VPG_ES11 + 49) +#define VPC_ES11GENTEXTURES (VPG_ES11 + 50) +#define VPC_ES11GETBOOLEANV (VPG_ES11 + 51) +#define VPC_ES11GETBUFFERPARAMETERIV (VPG_ES11 + 52) +#define VPC_ES11GETCLIPPLANEF (VPG_ES11 + 53) +#define VPC_ES11GETCLIPPLANEX (VPG_ES11 + 54) +#define VPC_ES11GETERROR (VPG_ES11 + 55) +#define VPC_ES11GETFIXEDV (VPG_ES11 + 56) +#define VPC_ES11GETFLOATV (VPG_ES11 + 57) +#define VPC_ES11GETINTEGERV (VPG_ES11 + 58) +#define VPC_ES11GETLIGHTFV (VPG_ES11 + 59) +#define VPC_ES11GETLIGHTXV (VPG_ES11 + 60) +#define VPC_ES11GETMATERIALFV (VPG_ES11 + 61) +#define VPC_ES11GETMATERIALXV (VPG_ES11 + 62) +#define VPC_ES11GETPOINTERV (VPG_ES11 + 63) +#define VPC_ES11GETSTRING (VPG_ES11 + 64) +#define VPC_ES11GETTEXENVFV (VPG_ES11 + 65) +#define VPC_ES11GETTEXENVIV (VPG_ES11 + 66) +#define VPC_ES11GETTEXENVXV (VPG_ES11 + 67) +#define VPC_ES11GETTEXPARAMETERFV (VPG_ES11 + 68) +#define VPC_ES11GETTEXPARAMETERIV (VPG_ES11 + 69) +#define VPC_ES11GETTEXPARAMETERXV (VPG_ES11 + 70) +#define VPC_ES11HINT (VPG_ES11 + 71) +#define VPC_ES11ISBUFFER (VPG_ES11 + 72) +#define VPC_ES11ISENABLED (VPG_ES11 + 73) +#define VPC_ES11ISTEXTURE (VPG_ES11 + 74) +#define VPC_ES11LIGHTF (VPG_ES11 + 75) +#define VPC_ES11LIGHTFV (VPG_ES11 + 76) +#define VPC_ES11LIGHTMODELF (VPG_ES11 + 77) +#define VPC_ES11LIGHTMODELFV (VPG_ES11 + 78) +#define VPC_ES11LIGHTMODELX (VPG_ES11 + 79) +#define VPC_ES11LIGHTMODELXV (VPG_ES11 + 80) +#define VPC_ES11LIGHTX (VPG_ES11 + 81) +#define VPC_ES11LIGHTXV (VPG_ES11 + 82) +#define VPC_ES11LINEWIDTH (VPG_ES11 + 83) +#define VPC_ES11LINEWIDTHX (VPG_ES11 + 84) +#define VPC_ES11LOADIDENTITY (VPG_ES11 + 85) +#define VPC_ES11LOADMATRIXF (VPG_ES11 + 86) +#define VPC_ES11LOADMATRIXX (VPG_ES11 + 87) +#define VPC_ES11LOGICOP (VPG_ES11 + 88) +#define VPC_ES11MATERIALF (VPG_ES11 + 89) +#define VPC_ES11MATERIALFV (VPG_ES11 + 90) +#define VPC_ES11MATERIALX (VPG_ES11 + 91) +#define VPC_ES11MATERIALXV (VPG_ES11 + 92) +#define VPC_ES11MATRIXMODE (VPG_ES11 + 93) +#define VPC_ES11MULTITEXCOORD4F (VPG_ES11 + 94) +#define VPC_ES11MULTITEXCOORD4X (VPG_ES11 + 95) +#define VPC_ES11MULTMATRIXF (VPG_ES11 + 96) +#define VPC_ES11MULTMATRIXX (VPG_ES11 + 97) +#define VPC_ES11NORMAL3F (VPG_ES11 + 98) +#define VPC_ES11NORMAL3X (VPG_ES11 + 99) +#define VPC_ES11NORMALPOINTER (VPG_ES11 + 100) +#define VPC_ES11ORTHOF (VPG_ES11 + 101) +#define VPC_ES11ORTHOX (VPG_ES11 + 102) +#define VPC_ES11PIXELSTOREI (VPG_ES11 + 103) +#define VPC_ES11POINTPARAMETERF (VPG_ES11 + 104) +#define VPC_ES11POINTPARAMETERFV (VPG_ES11 + 105) +#define VPC_ES11POINTPARAMETERX (VPG_ES11 + 106) +#define VPC_ES11POINTPARAMETERXV (VPG_ES11 + 107) +#define VPC_ES11POINTSIZE (VPG_ES11 + 108) +#define VPC_ES11POINTSIZEX (VPG_ES11 + 109) +#define VPC_ES11POLYGONOFFSET (VPG_ES11 + 110) +#define VPC_ES11POLYGONOFFSETX (VPG_ES11 + 111) +#define VPC_ES11POPMATRIX (VPG_ES11 + 112) +#define VPC_ES11PUSHMATRIX (VPG_ES11 + 113) +#define VPC_ES11READPIXELS (VPG_ES11 + 114) +#define VPC_ES11ROTATEF (VPG_ES11 + 115) +#define VPC_ES11ROTATEX (VPG_ES11 + 116) +#define VPC_ES11SAMPLECOVERAGE (VPG_ES11 + 117) +#define VPC_ES11SAMPLECOVERAGEX (VPG_ES11 + 118) +#define VPC_ES11SCALEF (VPG_ES11 + 119) +#define VPC_ES11SCALEX (VPG_ES11 + 120) +#define VPC_ES11SCISSOR (VPG_ES11 + 121) +#define VPC_ES11SHADEMODEL (VPG_ES11 + 122) +#define VPC_ES11STENCILFUNC (VPG_ES11 + 123) +#define VPC_ES11STENCILMASK (VPG_ES11 + 124) +#define VPC_ES11STENCILOP (VPG_ES11 + 125) +#define VPC_ES11TEXCOORDPOINTER (VPG_ES11 + 126) +#define VPC_ES11TEXENVF (VPG_ES11 + 127) +#define VPC_ES11TEXENVFV (VPG_ES11 + 128) +#define VPC_ES11TEXENVI (VPG_ES11 + 129) +#define VPC_ES11TEXENVIV (VPG_ES11 + 130) +#define VPC_ES11TEXENVX (VPG_ES11 + 131) +#define VPC_ES11TEXENVXV (VPG_ES11 + 132) +#define VPC_ES11TEXIMAGE2D (VPG_ES11 + 133) +#define VPC_ES11TEXPARAMETERF (VPG_ES11 + 134) +#define VPC_ES11TEXPARAMETERFV (VPG_ES11 + 135) +#define VPC_ES11TEXPARAMETERI (VPG_ES11 + 136) +#define VPC_ES11TEXPARAMETERIV (VPG_ES11 + 137) +#define VPC_ES11TEXPARAMETERX (VPG_ES11 + 138) +#define VPC_ES11TEXPARAMETERXV (VPG_ES11 + 139) +#define VPC_ES11TEXSUBIMAGE2D (VPG_ES11 + 140) +#define VPC_ES11TRANSLATEF (VPG_ES11 + 141) +#define VPC_ES11TRANSLATEX (VPG_ES11 + 142) +#define VPC_ES11VERTEXPOINTER (VPG_ES11 + 143) +#define VPC_ES11VIEWPORT (VPG_ES11 + 144) +#define VPC_ES11CALLS (VPG_ES11 + 145) +#define VPC_ES11DRAWCALLS (VPG_ES11 + 146) +#define VPC_ES11STATECHANGECALLS (VPG_ES11 + 147) +#define VPC_ES11POINTCOUNT (VPG_ES11 + 148) +#define VPC_ES11LINECOUNT (VPG_ES11 + 149) +#define VPC_ES11TRIANGLECOUNT (VPG_ES11 + 150) + +/* OpenGLES 2.x */ +#define VPC_ES20ACTIVETEXTURE (VPG_ES20 + 1) +#define VPC_ES20ATTACHSHADER (VPG_ES20 + 2) +#define VPC_ES20BINDATTRIBLOCATION (VPG_ES20 + 3) +#define VPC_ES20BINDBUFFER (VPG_ES20 + 4) +#define VPC_ES20BINDFRAMEBUFFER (VPG_ES20 + 5) +#define VPC_ES20BINDRENDERBUFFER (VPG_ES20 + 6) +#define VPC_ES20BINDTEXTURE (VPG_ES20 + 7) +#define VPC_ES20BLENDCOLOR (VPG_ES20 + 8) +#define VPC_ES20BLENDEQUATION (VPG_ES20 + 9) +#define VPC_ES20BLENDEQUATIONSEPARATE (VPG_ES20 + 10) +#define VPC_ES20BLENDFUNC (VPG_ES20 + 11) +#define VPC_ES20BLENDFUNCSEPARATE (VPG_ES20 + 12) +#define VPC_ES20BUFFERDATA (VPG_ES20 + 13) +#define VPC_ES20BUFFERSUBDATA (VPG_ES20 + 14) +#define VPC_ES20CHECKFRAMEBUFFERSTATUS (VPG_ES20 + 15) +#define VPC_ES20CLEAR (VPG_ES20 + 16) +#define VPC_ES20CLEARCOLOR (VPG_ES20 + 17) +#define VPC_ES20CLEARDEPTHF (VPG_ES20 + 18) +#define VPC_ES20CLEARSTENCIL (VPG_ES20 + 19) +#define VPC_ES20COLORMASK (VPG_ES20 + 20) +#define VPC_ES20COMPILESHADER (VPG_ES20 + 21) +#define VPC_ES20COMPRESSEDTEXIMAGE2D (VPG_ES20 + 22) +#define VPC_ES20COMPRESSEDTEXSUBIMAGE2D (VPG_ES20 + 23) +#define VPC_ES20COPYTEXIMAGE2D (VPG_ES20 + 24) +#define VPC_ES20COPYTEXSUBIMAGE2D (VPG_ES20 + 25) +#define VPC_ES20CREATEPROGRAM (VPG_ES20 + 26) +#define VPC_ES20CREATESHADER (VPG_ES20 + 27) +#define VPC_ES20CULLFACE (VPG_ES20 + 28) +#define VPC_ES20DELETEBUFFERS (VPG_ES20 + 29) +#define VPC_ES20DELETEFRAMEBUFFERS (VPG_ES20 + 30) +#define VPC_ES20DELETEPROGRAM (VPG_ES20 + 31) +#define VPC_ES20DELETERENDERBUFFERS (VPG_ES20 + 32) +#define VPC_ES20DELETESHADER (VPG_ES20 + 33) +#define VPC_ES20DELETETEXTURES (VPG_ES20 + 34) +#define VPC_ES20DEPTHFUNC (VPG_ES20 + 35) +#define VPC_ES20DEPTHMASK (VPG_ES20 + 36) +#define VPC_ES20DEPTHRANGEF (VPG_ES20 + 37) +#define VPC_ES20DETACHSHADER (VPG_ES20 + 38) +#define VPC_ES20DISABLE (VPG_ES20 + 39) +#define VPC_ES20DISABLEVERTEXATTRIBARRAY (VPG_ES20 + 40) +#define VPC_ES20DRAWARRAYS (VPG_ES20 + 41) +#define VPC_ES20DRAWELEMENTS (VPG_ES20 + 42) +#define VPC_ES20ENABLE (VPG_ES20 + 43) +#define VPC_ES20ENABLEVERTEXATTRIBARRAY (VPG_ES20 + 44) +#define VPC_ES20FINISH (VPG_ES20 + 45) +#define VPC_ES20FLUSH (VPG_ES20 + 46) +#define VPC_ES20FRAMEBUFFERRENDERBUFFER (VPG_ES20 + 47) +#define VPC_ES20FRAMEBUFFERTEXTURE2D (VPG_ES20 + 48) +#define VPC_ES20FRONTFACE (VPG_ES20 + 49) +#define VPC_ES20GENBUFFERS (VPG_ES20 + 50) +#define VPC_ES20GENERATEMIPMAP (VPG_ES20 + 51) +#define VPC_ES20GENFRAMEBUFFERS (VPG_ES20 + 52) +#define VPC_ES20GENRENDERBUFFERS (VPG_ES20 + 53) +#define VPC_ES20GENTEXTURES (VPG_ES20 + 54) +#define VPC_ES20GETACTIVEATTRIB (VPG_ES20 + 55) +#define VPC_ES20GETACTIVEUNIFORM (VPG_ES20 + 56) +#define VPC_ES20GETATTACHEDSHADERS (VPG_ES20 + 57) +#define VPC_ES20GETATTRIBLOCATION (VPG_ES20 + 58) +#define VPC_ES20GETBOOLEANV (VPG_ES20 + 59) +#define VPC_ES20GETBUFFERPARAMETERIV (VPG_ES20 + 60) +#define VPC_ES20GETERROR (VPG_ES20 + 61) +#define VPC_ES20GETFLOATV (VPG_ES20 + 62) +#define VPC_ES20GETFRAMEBUFFERATTACHMENTPARAMETERIV (VPG_ES20 + 63) +#define VPC_ES20GETINTEGERV (VPG_ES20 + 64) +#define VPC_ES20GETPROGRAMIV (VPG_ES20 + 65) +#define VPC_ES20GETPROGRAMINFOLOG (VPG_ES20 + 66) +#define VPC_ES20GETRENDERBUFFERPARAMETERIV (VPG_ES20 + 67) +#define VPC_ES20GETSHADERIV (VPG_ES20 + 68) +#define VPC_ES20GETSHADERINFOLOG (VPG_ES20 + 69) +#define VPC_ES20GETSHADERPRECISIONFORMAT (VPG_ES20 + 70) +#define VPC_ES20GETSHADERSOURCE (VPG_ES20 + 71) +#define VPC_ES20GETSTRING (VPG_ES20 + 72) +#define VPC_ES20GETTEXPARAMETERFV (VPG_ES20 + 73) +#define VPC_ES20GETTEXPARAMETERIV (VPG_ES20 + 74) +#define VPC_ES20GETUNIFORMFV (VPG_ES20 + 75) +#define VPC_ES20GETUNIFORMIV (VPG_ES20 + 76) +#define VPC_ES20GETUNIFORMLOCATION (VPG_ES20 + 77) +#define VPC_ES20GETVERTEXATTRIBFV (VPG_ES20 + 78) +#define VPC_ES20GETVERTEXATTRIBIV (VPG_ES20 + 79) +#define VPC_ES20GETVERTEXATTRIBPOINTERV (VPG_ES20 + 80) +#define VPC_ES20HINT (VPG_ES20 + 81) +#define VPC_ES20ISBUFFER (VPG_ES20 + 82) +#define VPC_ES20ISENABLED (VPG_ES20 + 83) +#define VPC_ES20ISFRAMEBUFFER (VPG_ES20 + 84) +#define VPC_ES20ISPROGRAM (VPG_ES20 + 85) +#define VPC_ES20ISRENDERBUFFER (VPG_ES20 + 86) +#define VPC_ES20ISSHADER (VPG_ES20 + 87) +#define VPC_ES20ISTEXTURE (VPG_ES20 + 88) +#define VPC_ES20LINEWIDTH (VPG_ES20 + 89) +#define VPC_ES20LINKPROGRAM (VPG_ES20 + 90) +#define VPC_ES20PIXELSTOREI (VPG_ES20 + 91) +#define VPC_ES20POLYGONOFFSET (VPG_ES20 + 92) +#define VPC_ES20READPIXELS (VPG_ES20 + 93) +#define VPC_ES20RELEASESHADERCOMPILER (VPG_ES20 + 94) +#define VPC_ES20RENDERBUFFERSTORAGE (VPG_ES20 + 95) +#define VPC_ES20SAMPLECOVERAGE (VPG_ES20 + 96) +#define VPC_ES20SCISSOR (VPG_ES20 + 97) +#define VPC_ES20SHADERBINARY (VPG_ES20 + 98) +#define VPC_ES20SHADERSOURCE (VPG_ES20 + 99) +#define VPC_ES20STENCILFUNC (VPG_ES20 + 100) +#define VPC_ES20STENCILFUNCSEPARATE (VPG_ES20 + 101) +#define VPC_ES20STENCILMASK (VPG_ES20 + 102) +#define VPC_ES20STENCILMASKSEPARATE (VPG_ES20 + 103) +#define VPC_ES20STENCILOP (VPG_ES20 + 104) +#define VPC_ES20STENCILOPSEPARATE (VPG_ES20 + 105) +#define VPC_ES20TEXIMAGE2D (VPG_ES20 + 106) +#define VPC_ES20TEXPARAMETERF (VPG_ES20 + 107) +#define VPC_ES20TEXPARAMETERFV (VPG_ES20 + 108) +#define VPC_ES20TEXPARAMETERI (VPG_ES20 + 109) +#define VPC_ES20TEXPARAMETERIV (VPG_ES20 + 110) +#define VPC_ES20TEXSUBIMAGE2D (VPG_ES20 + 111) +#define VPC_ES20UNIFORM1F (VPG_ES20 + 112) +#define VPC_ES20UNIFORM1FV (VPG_ES20 + 113) +#define VPC_ES20UNIFORM1I (VPG_ES20 + 114) +#define VPC_ES20UNIFORM1IV (VPG_ES20 + 115) +#define VPC_ES20UNIFORM2F (VPG_ES20 + 116) +#define VPC_ES20UNIFORM2FV (VPG_ES20 + 117) +#define VPC_ES20UNIFORM2I (VPG_ES20 + 118) +#define VPC_ES20UNIFORM2IV (VPG_ES20 + 119) +#define VPC_ES20UNIFORM3F (VPG_ES20 + 120) +#define VPC_ES20UNIFORM3FV (VPG_ES20 + 121) +#define VPC_ES20UNIFORM3I (VPG_ES20 + 122) +#define VPC_ES20UNIFORM3IV (VPG_ES20 + 123) +#define VPC_ES20UNIFORM4F (VPG_ES20 + 124) +#define VPC_ES20UNIFORM4FV (VPG_ES20 + 125) +#define VPC_ES20UNIFORM4I (VPG_ES20 + 126) +#define VPC_ES20UNIFORM4IV (VPG_ES20 + 127) +#define VPC_ES20UNIFORMMATRIX2FV (VPG_ES20 + 128) +#define VPC_ES20UNIFORMMATRIX3FV (VPG_ES20 + 129) +#define VPC_ES20UNIFORMMATRIX4FV (VPG_ES20 + 130) +#define VPC_ES20USEPROGRAM (VPG_ES20 + 131) +#define VPC_ES20VALIDATEPROGRAM (VPG_ES20 + 132) +#define VPC_ES20VERTEXATTRIB1F (VPG_ES20 + 133) +#define VPC_ES20VERTEXATTRIB1FV (VPG_ES20 + 134) +#define VPC_ES20VERTEXATTRIB2F (VPG_ES20 + 135) +#define VPC_ES20VERTEXATTRIB2FV (VPG_ES20 + 136) +#define VPC_ES20VERTEXATTRIB3F (VPG_ES20 + 137) +#define VPC_ES20VERTEXATTRIB3FV (VPG_ES20 + 138) +#define VPC_ES20VERTEXATTRIB4F (VPG_ES20 + 139) +#define VPC_ES20VERTEXATTRIB4FV (VPG_ES20 + 140) +#define VPC_ES20VERTEXATTRIBPOINTER (VPG_ES20 + 141) +#define VPC_ES20VIEWPORT (VPG_ES20 + 142) +#define VPC_ES20CALLS (VPG_ES20 + 143) +#define VPC_ES20DRAWCALLS (VPG_ES20 + 144) +#define VPC_ES20STATECHANGECALLS (VPG_ES20 + 145) +#define VPC_ES20POINTCOUNT (VPG_ES20 + 146) +#define VPC_ES20LINECOUNT (VPG_ES20 + 147) +#define VPC_ES20TRIANGLECOUNT (VPG_ES20 + 148) + +/* VG11 Counters. */ +#define VPC_VG11APPENDPATH (VPG_VG11 + 1) +#define VPC_VG11APPENDPATHDATA (VPG_VG11 + 2) +#define VPC_VG11CHILDIMAGE (VPG_VG11 + 3) +#define VPC_VG11CLEAR (VPG_VG11 + 4) +#define VPC_VG11CLEARGLYPH (VPG_VG11 + 5) +#define VPC_VG11CLEARIMAGE (VPG_VG11 + 6) +#define VPC_VG11CLEARPATH (VPG_VG11 + 7) +#define VPC_VG11COLORMATRIX (VPG_VG11 + 8) +#define VPC_VG11CONVOLVE (VPG_VG11 + 9) +#define VPC_VG11COPYIMAGE (VPG_VG11 + 10) +#define VPC_VG11COPYMASK (VPG_VG11 + 11) +#define VPC_VG11COPYPIXELS (VPG_VG11 + 12) +#define VPC_VG11CREATEFONT (VPG_VG11 + 13) +#define VPC_VG11CREATEIMAGE (VPG_VG11 + 14) +#define VPC_VG11CREATEMASKLAYER (VPG_VG11 + 15) +#define VPC_VG11CREATEPAINT (VPG_VG11 + 16) +#define VPC_VG11CREATEPATH (VPG_VG11 + 17) +#define VPC_VG11DESTROYFONT (VPG_VG11 + 18) +#define VPC_VG11DESTROYIMAGE (VPG_VG11 + 19) +#define VPC_VG11DESTROYMASKLAYER (VPG_VG11 + 20) +#define VPC_VG11DESTROYPAINT (VPG_VG11 + 21) +#define VPC_VG11DESTROYPATH (VPG_VG11 + 22) +#define VPC_VG11DRAWGLYPH (VPG_VG11 + 23) +#define VPC_VG11DRAWGLYPHS (VPG_VG11 + 24) +#define VPC_VG11DRAWIMAGE (VPG_VG11 + 25) +#define VPC_VG11DRAWPATH (VPG_VG11 + 26) +#define VPC_VG11FILLMASKLAYER (VPG_VG11 + 27) +#define VPC_VG11FINISH (VPG_VG11 + 28) +#define VPC_VG11FLUSH (VPG_VG11 + 29) +#define VPC_VG11GAUSSIANBLUR (VPG_VG11 + 30) +#define VPC_VG11GETCOLOR (VPG_VG11 + 31) +#define VPC_VG11GETERROR (VPG_VG11 + 32) +#define VPC_VG11GETF (VPG_VG11 + 33) +#define VPC_VG11GETFV (VPG_VG11 + 34) +#define VPC_VG11GETI (VPG_VG11 + 35) +#define VPC_VG11GETIMAGESUBDATA (VPG_VG11 + 36) +#define VPC_VG11GETIV (VPG_VG11 + 37) +#define VPC_VG11GETMATRIX (VPG_VG11 + 38) +#define VPC_VG11GETPAINT (VPG_VG11 + 39) +#define VPC_VG11GETPARAMETERF (VPG_VG11 + 40) +#define VPC_VG11GETPARAMETERFV (VPG_VG11 + 41) +#define VPC_VG11GETPARAMETERI (VPG_VG11 + 42) +#define VPC_VG11GETPARAMETERIV (VPG_VG11 + 43) +#define VPC_VG11GETPARAMETERVECTORSIZE (VPG_VG11 + 44) +#define VPC_VG11GETPARENT (VPG_VG11 + 45) +#define VPC_VG11GETPATHCAPABILITIES (VPG_VG11 + 46) +#define VPC_VG11GETPIXELS (VPG_VG11 + 47) +#define VPC_VG11GETSTRING (VPG_VG11 + 48) +#define VPC_VG11GETVECTORSIZE (VPG_VG11 + 49) +#define VPC_VG11HARDWAREQUERY (VPG_VG11 + 50) +#define VPC_VG11IMAGESUBDATA (VPG_VG11 + 51) +#define VPC_VG11INTERPOLATEPATH (VPG_VG11 + 52) +#define VPC_VG11LOADIDENTITY (VPG_VG11 + 53) +#define VPC_VG11LOADMATRIX (VPG_VG11 + 54) +#define VPC_VG11LOOKUP (VPG_VG11 + 55) +#define VPC_VG11LOOKUPSINGLE (VPG_VG11 + 56) +#define VPC_VG11MASK (VPG_VG11 + 57) +#define VPC_VG11MODIFYPATHCOORDS (VPG_VG11 + 58) +#define VPC_VG11MULTMATRIX (VPG_VG11 + 59) +#define VPC_VG11PAINTPATTERN (VPG_VG11 + 60) +#define VPC_VG11PATHBOUNDS (VPG_VG11 + 61) +#define VPC_VG11PATHLENGTH (VPG_VG11 + 62) +#define VPC_VG11PATHTRANSFORMEDBOUNDS (VPG_VG11 + 63) +#define VPC_VG11POINTALONGPATH (VPG_VG11 + 64) +#define VPC_VG11READPIXELS (VPG_VG11 + 65) +#define VPC_VG11REMOVEPATHCAPABILITIES (VPG_VG11 + 66) +#define VPC_VG11RENDERTOMASK (VPG_VG11 + 67) +#define VPC_VG11ROTATE (VPG_VG11 + 68) +#define VPC_VG11SCALE (VPG_VG11 + 69) +#define VPC_VG11SEPARABLECONVOLVE (VPG_VG11 + 70) +#define VPC_VG11SETCOLOR (VPG_VG11 + 71) +#define VPC_VG11SETF (VPG_VG11 + 72) +#define VPC_VG11SETFV (VPG_VG11 + 73) +#define VPC_VG11SETGLYPHTOIMAGE (VPG_VG11 + 74) +#define VPC_VG11SETGLYPHTOPATH (VPG_VG11 + 75) +#define VPC_VG11SETI (VPG_VG11 + 76) +#define VPC_VG11SETIV (VPG_VG11 + 77) +#define VPC_VG11SETPAINT (VPG_VG11 + 78) +#define VPC_VG11SETPARAMETERF (VPG_VG11 + 79) +#define VPC_VG11SETPARAMETERFV (VPG_VG11 + 80) +#define VPC_VG11SETPARAMETERI (VPG_VG11 + 81) +#define VPC_VG11SETPARAMETERIV (VPG_VG11 + 82) +#define VPC_VG11SETPIXELS (VPG_VG11 + 83) +#define VPC_VG11SHEAR (VPG_VG11 + 84) +#define VPC_VG11TRANSFORMPATH (VPG_VG11 + 85) +#define VPC_VG11TRANSLATE (VPG_VG11 + 86) +#define VPC_VG11WRITEPIXELS (VPG_VG11 + 87) +#define VPC_VG11CALLS (VPG_VG11 + 88) +#define VPC_VG11DRAWCALLS (VPG_VG11 + 89) +#define VPC_VG11STATECHANGECALLS (VPG_VG11 + 90) +#define VPC_VG11FILLCOUNT (VPG_VG11 + 91) +#define VPC_VG11STROKECOUNT (VPG_VG11 + 92) + +/* HAL Counters. */ +#define VPC_HALVERTBUFNEWBYTEALLOC (VPG_HAL + 1) +#define VPC_HALVERTBUFTOTALBYTEALLOC (VPG_HAL + 2) +#define VPC_HALVERTBUFNEWOBJALLOC (VPG_HAL + 3) +#define VPC_HALVERTBUFTOTALOBJALLOC (VPG_HAL + 4) +#define VPC_HALINDBUFNEWBYTEALLOC (VPG_HAL + 5) +#define VPC_HALINDBUFTOTALBYTEALLOC (VPG_HAL + 6) +#define VPC_HALINDBUFNEWOBJALLOC (VPG_HAL + 7) +#define VPC_HALINDBUFTOTALOBJALLOC (VPG_HAL + 8) +#define VPC_HALTEXBUFNEWBYTEALLOC (VPG_HAL + 9) +#define VPC_HALTEXBUFTOTALBYTEALLOC (VPG_HAL + 10) +#define VPC_HALTEXBUFNEWOBJALLOC (VPG_HAL + 11) +#define VPC_HALTEXBUFTOTALOBJALLOC (VPG_HAL + 12) + +#define VPC_VG11TRANSLATE (VPG_VG11 + 86) +#define VPC_VG11WRITEPIXELS (VPG_VG11 + 87) +#define VPC_VG11CALLS (VPG_VG11 + 88) +#define VPC_VG11DRAWCALLS (VPG_VG11 + 89) +#define VPC_VG11STATECHANGECALLS (VPG_VG11 + 90) +#define VPC_VG11FILLCOUNT (VPG_VG11 + 91) +#define VPC_VG11STROKECOUNT (VPG_VG11 + 92) + +/* HAL Counters. */ +#define VPC_HALVERTBUFNEWBYTEALLOC (VPG_HAL + 1) +#define VPC_HALVERTBUFTOTALBYTEALLOC (VPG_HAL + 2) +#define VPC_HALVERTBUFNEWOBJALLOC (VPG_HAL + 3) +#define VPC_HALVERTBUFTOTALOBJALLOC (VPG_HAL + 4) +#define VPC_HALINDBUFNEWBYTEALLOC (VPG_HAL + 5) +#define VPC_HALINDBUFTOTALBYTEALLOC (VPG_HAL + 6) +#define VPC_HALINDBUFNEWOBJALLOC (VPG_HAL + 7) +#define VPC_HALINDBUFTOTALOBJALLOC (VPG_HAL + 8) +#define VPC_HALTEXBUFNEWBYTEALLOC (VPG_HAL + 9) +#define VPC_HALTEXBUFTOTALBYTEALLOC (VPG_HAL + 10) +#define VPC_HALTEXBUFNEWOBJALLOC (VPG_HAL + 11) +#define VPC_HALTEXBUFTOTALOBJALLOC (VPG_HAL + 12) + +/* HW: GPU Counters. */ +#define VPC_GPUCYCLES (VPG_GPU + 1) +#define VPC_GPUREAD64BYTE (VPG_GPU + 2) +#define VPC_GPUWRITE64BYTE (VPG_GPU + 3) + +/* HW: Shader Counters. */ +#define VPC_VSINSTCOUNT (VPG_VS + 1) +#define VPC_VSBRANCHINSTCOUNT (VPG_VS + 2) +#define VPC_VSTEXLDINSTCOUNT (VPG_VS + 3) +#define VPC_VSRENDEREDVERTCOUNT (VPG_VS + 4) +/* HW: PS Count. */ +#define VPC_PSINSTCOUNT (VPG_PS + 1) +#define VPC_PSBRANCHINSTCOUNT (VPG_PS + 2) +#define VPC_PSTEXLDINSTCOUNT (VPG_PS + 3) +#define VPC_PSRENDEREDPIXCOUNT (VPG_PS + 4) + + +/* HW: PA Counters. */ +#define VPC_PAINVERTCOUNT (VPG_PA + 1) +#define VPC_PAINPRIMCOUNT (VPG_PA + 2) +#define VPC_PAOUTPRIMCOUNT (VPG_PA + 3) +#define VPC_PADEPTHCLIPCOUNT (VPG_PA + 4) +#define VPC_PATRIVIALREJCOUNT (VPG_PA + 5) +#define VPC_PACULLCOUNT (VPG_PA + 6) + +/* HW: Setup Counters. */ +#define VPC_SETRIANGLECOUNT (VPG_SETUP + 1) +#define VPC_SELINECOUNT (VPG_SETUP + 2) + +/* HW: RA Counters. */ +#define VPC_RAVALIDPIXCOUNT (VPG_RA + 1) +#define VPC_RATOTALQUADCOUNT (VPG_RA + 2) +#define VPC_RAVALIDQUADCOUNTEZ (VPG_RA + 3) +#define VPC_RATOTALPRIMCOUNT (VPG_RA + 4) +#define VPC_RAPIPECACHEMISSCOUNT (VPG_RA + 5) +#define VPC_RAPREFCACHEMISSCOUNT (VPG_RA + 6) +#define VPC_RAEEZCULLCOUNT (VPG_RA + 7) + +/* HW: TEX Counters. */ +#define VPC_TXTOTBILINEARREQ (VPG_TX + 1) +#define VPC_TXTOTTRILINEARREQ (VPG_TX + 2) +#define VPC_TXTOTDISCARDTEXREQ (VPG_TX + 3) +#define VPC_TXTOTTEXREQ (VPG_TX + 4) +#define VPC_TXMEMREADCOUNT (VPG_TX + 5) +#define VPC_TXMEMREADIN8BCOUNT (VPG_TX + 6) +#define VPC_TXCACHEMISSCOUNT (VPG_TX + 7) +#define VPC_TXCACHEHITTEXELCOUNT (VPG_TX + 8) +#define VPC_TXCACHEMISSTEXELCOUNT (VPG_TX + 9) + +/* HW: PE Counters. */ +#define VPC_PEKILLEDBYCOLOR (VPG_PE + 1) +#define VPC_PEKILLEDBYDEPTH (VPG_PE + 2) +#define VPC_PEDRAWNBYCOLOR (VPG_PE + 3) +#define VPC_PEDRAWNBYDEPTH (VPG_PE + 4) + +/* HW: MC Counters. */ +#define VPC_MCREADREQ8BPIPE (VPG_MC + 1) +#define VPC_MCREADREQ8BIP (VPG_MC + 2) +#define VPC_MCWRITEREQ8BPIPE (VPG_MC + 3) + +/* HW: AXI Counters. */ +#define VPC_AXIREADREQSTALLED (VPG_AXI + 1) +#define VPC_AXIWRITEREQSTALLED (VPG_AXI + 2) +#define VPC_AXIWRITEDATASTALLED (VPG_AXI + 3) + +/* PROGRAM: Shader program counters. */ +#define VPC_PVSINSTRCOUNT (VPG_PVS + 1) +#define VPC_PVSALUINSTRCOUNT (VPG_PVS + 2) +#define VPC_PVSTEXINSTRCOUNT (VPG_PVS + 3) +#define VPC_PVSATTRIBCOUNT (VPG_PVS + 4) +#define VPC_PVSUNIFORMCOUNT (VPG_PVS + 5) +#define VPC_PVSFUNCTIONCOUNT (VPG_PVS + 6) + +#define VPC_PPSINSTRCOUNT (VPG_PPS + 1) +#define VPC_PPSALUINSTRCOUNT (VPG_PPS + 2) +#define VPC_PPSTEXINSTRCOUNT (VPG_PPS + 3) +#define VPC_PPSATTRIBCOUNT (VPG_PPS + 4) +#define VPC_PPSUNIFORMCOUNT (VPG_PPS + 5) +#define VPC_PPSFUNCTIONCOUNT (VPG_PPS + 6) + +#endif + + /* HW profile information. */ typedef struct _gcsPROFILER_COUNTERS { @@ -122,6 +685,9 @@ gcsPROFILER_COUNTERS; typedef struct _gcsPROFILER { gctUINT32 enable; + gctBOOL enableHal; + gctBOOL enableHW; + gctBOOL enableSH; gctBOOL useSocket; gctINT sockFd; @@ -141,7 +707,7 @@ typedef struct _gcsPROFILER gctUINT64 frameStartCPUTimeusec; gctUINT64 frameEndCPUTimeusec; -#if PROFILE_HAL_COUNTERS +/* #if PROFILE_HAL_COUNTERS */ gctUINT32 vertexBufferTotalBytesAlloc; gctUINT32 vertexBufferNewBytesAlloc; int vertexBufferTotalObjectsAlloc; @@ -163,7 +729,7 @@ typedef struct _gcsPROFILER gctUINT32 drawTriangleCount; gctUINT32 drawVertexCount; gctUINT32 redundantStateChangeCalls; -#endif +/* #endif */ } gcsPROFILER; diff --git a/drivers/staging/rk29/vivante/hal/inc/gc_hal_raster.h b/drivers/staging/rk29/vivante/hal/inc/gc_hal_raster.h old mode 100755 new mode 100644 index 4ff9c22f12db..8d4c46e97bd4 --- a/drivers/staging/rk29/vivante/hal/inc/gc_hal_raster.h +++ b/drivers/staging/rk29/vivante/hal/inc/gc_hal_raster.h @@ -597,6 +597,32 @@ gco2D_FilterBlitEx( IN gcsRECT_PTR DestSubRect ); +gceSTATUS +gco2D_FilterBlitEx2( + IN gco2D Engine, + IN gctUINT32_PTR SrcAddresses, + IN gctUINT32 SrcAddressNum, + IN gctUINT32_PTR SrcStrides, + IN gctUINT32 SrcStrideNum, + IN gceTILING SrcTiling, + IN gceSURF_FORMAT SrcFormat, + IN gceSURF_ROTATION SrcRotation, + IN gctUINT32 SrcSurfaceWidth, + IN gctUINT32 SrcSurfaceHeight, + IN gcsRECT_PTR SrcRect, + IN gctUINT32_PTR DestAddresses, + IN gctUINT32 DestAddressNum, + IN gctUINT32_PTR DestStrides, + IN gctUINT32 DestStrideNum, + IN gceTILING DestTiling, + IN gceSURF_FORMAT DestFormat, + IN gceSURF_ROTATION DestRotation, + IN gctUINT32 DestSurfaceWidth, + IN gctUINT32 DestSurfaceHeight, + IN gcsRECT_PTR DestRect, + IN gcsRECT_PTR DestSubRect + ); + /* Enable alpha blending engine in the hardware and disengage the ROP engine. */ gceSTATUS gco2D_EnableAlphaBlend( @@ -780,6 +806,34 @@ gco2D_EnableDither( IN gctBOOL Enable ); +gceSTATUS +gco2D_SetGenericSource( + IN gco2D Engine, + IN gctUINT32_PTR Addresses, + IN gctUINT32 AddressNum, + IN gctUINT32_PTR Strides, + IN gctUINT32 StrideNum, + IN gceTILING Tiling, + IN gceSURF_FORMAT Format, + IN gceSURF_ROTATION Rotation, + IN gctUINT32 SurfaceWidth, + IN gctUINT32 SurfaceHeight +); + +gceSTATUS +gco2D_SetGenericTarget( + IN gco2D Engine, + IN gctUINT32_PTR Addresses, + IN gctUINT32 AddressNum, + IN gctUINT32_PTR Strides, + IN gctUINT32 StrideNum, + IN gceTILING Tiling, + IN gceSURF_FORMAT Format, + IN gceSURF_ROTATION Rotation, + IN gctUINT32 SurfaceWidth, + IN gctUINT32 SurfaceHeight +); + #ifdef __cplusplus } #endif diff --git a/drivers/staging/rk29/vivante/hal/inc/gc_hal_types.h b/drivers/staging/rk29/vivante/hal/inc/gc_hal_types.h index d572d5fbb67e..eeea9aca4a7a 100644 --- a/drivers/staging/rk29/vivante/hal/inc/gc_hal_types.h +++ b/drivers/staging/rk29/vivante/hal/inc/gc_hal_types.h @@ -1,6 +1,6 @@ /**************************************************************************** * -* Copyright (C) 2005 - 2010 by Vivante Corp. +* Copyright (C) 2005 - 2011 by Vivante Corp. * * 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 @@ -71,7 +71,7 @@ extern "C" { #endif #ifndef gcdDEBUG -# if (defined(DBG) && DBG) || defined(DEBUG) || defined(_DEBUG) +#if (defined(DBG) && DBG) || defined(DEBUG) || defined(_DEBUG) # define gcdDEBUG 1 # else # define gcdDEBUG 0 @@ -79,15 +79,15 @@ extern "C" { #endif #ifdef _USRDLL -# ifdef _MSC_VER -# ifdef HAL_EXPORTS +#ifdef _MSC_VER +#ifdef HAL_EXPORTS # define HALAPI __declspec(dllexport) # else # define HALAPI __declspec(dllimport) # endif # define HALDECL __cdecl # else -# ifdef HAL_EXPORTS +#ifdef HAL_EXPORTS # define HALAPI # else # define HALAPI extern @@ -255,6 +255,7 @@ typedef enum _gceSTATUS gcvSTATUS_DATA_TOO_LARGE = 14, gcvSTATUS_INVALID_CONFIG = 15, gcvSTATUS_CHANGED = 16, + gcvSTATUS_NOT_SUPPORT_DITHER = 17, gcvSTATUS_INVALID_ARGUMENT = -1, gcvSTATUS_INVALID_OBJECT = -2, @@ -278,6 +279,9 @@ typedef enum _gceSTATUS gcvSTATUS_NOT_ALIGNED = -20, gcvSTATUS_INVALID_REQUEST = -21, gcvSTATUS_GPU_NOT_RESPONDING = -22, + gcvSTATUS_TIMER_OVERFLOW = -23, + gcvSTATUS_VERSION_MISMATCH = -24, + gcvSTATUS_LOCKED = -25, /* Linker errors. */ gcvSTATUS_GLOBAL_TYPE_MISMATCH = -1000, @@ -412,8 +416,8 @@ gceSTATUS; */ #define gcmSETMASKEDFIELD(reg, field, value) \ ( \ - gcmSETFIELD(~0, reg, field, value) & \ - gcmSETFIELDVALUE(~0, reg, MASK_ ## field, ENABLED) \ + ((((gctUINT32) (~0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? reg_field) - (0 ? reg_field) + 1) == 32) ? ~0 : (~(~0 << ((1 ? reg_field) - (0 ? reg_field) + 1))))))) << (0 ? reg_field))) | (((gctUINT32) ((gctUINT32) (value) & ((gctUINT32) ((((1 ? reg_field) - (0 ? reg_field) + 1) == 32) ? ~0 : (~(~0 << ((1 ? reg_field) - (0 ? reg_field) + 1))))))) << (0 ? reg_field)))&\ + ((((gctUINT32) (~0)) & ~(((gctUINT32) (((gctUINT32) ((((1 ? reg_MASK_##field) - (0 ? reg_MASK_##field) + 1) == 32) ? ~0 : (~(~0 << ((1 ? reg_MASK_##field) - (0 ? reg_MASK_##field) + 1))))))) << (0 ? reg_MASK_##field))) | (((gctUINT32) (reg_MASK_##field_ENABLED&((gctUINT32)((((1?reg_MASK_##field)-(0?reg_MASK_##field)+1)==32)?~0:(~(~0<<((1?reg_MASK_##field)-(0?reg_MASK_##field)+1)))))))<<(0?reg_MASK_##field)))\ ) /******************************************************************************* diff --git a/drivers/staging/rk29/vivante/hal/kernel/gc_hal_kernel.c b/drivers/staging/rk29/vivante/hal/kernel/gc_hal_kernel.c index e795ecdc1ced..d850810c6eca 100644 --- a/drivers/staging/rk29/vivante/hal/kernel/gc_hal_kernel.c +++ b/drivers/staging/rk29/vivante/hal/kernel/gc_hal_kernel.c @@ -1,21 +1,21 @@ /**************************************************************************** -* -* Copyright (C) 2005 - 2010 by Vivante Corp. -* +* +* Copyright (C) 2005 - 2011 by Vivante Corp. +* * 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., 675 Mass Ave, Cambridge, MA 02139, USA. -* +* *****************************************************************************/ @@ -51,10 +51,18 @@ */ #ifdef ANDROID +#if gcdNEW_PROFILER_FILE +#define DEFAULT_PROFILE_FILE_NAME "/sdcard/vprofiler.vpd" +#else #define DEFAULT_PROFILE_FILE_NAME "/sdcard/vprofiler.xml" +#endif +#else +#if gcdNEW_PROFILER_FILE +#define DEFAULT_PROFILE_FILE_NAME "vprofiler.vpd" /* "vpd" means "vprofile data" */ #else #define DEFAULT_PROFILE_FILE_NAME "vprofiler.xml" #endif +#endif gceSTATUS gckKERNEL_Construct( @@ -465,7 +473,8 @@ gckKERNEL_Dispatch( &Interface->u.QueryChipIdentity.chipRevision, &Interface->u.QueryChipIdentity.chipFeatures, &Interface->u.QueryChipIdentity.chipMinorFeatures, - &Interface->u.QueryChipIdentity.chipMinorFeatures1)); + &Interface->u.QueryChipIdentity.chipMinorFeatures1, + &Interface->u.QueryChipIdentity.chipMinorFeatures2)); /* Query chip specifications. */ gcmkONERROR( @@ -1243,4 +1252,3 @@ OnError: gcmkFOOTER(); return status; } - diff --git a/drivers/staging/rk29/vivante/hal/kernel/gc_hal_kernel.h b/drivers/staging/rk29/vivante/hal/kernel/gc_hal_kernel.h index 35adeb725f8b..8fe566bb1263 100644 --- a/drivers/staging/rk29/vivante/hal/kernel/gc_hal_kernel.h +++ b/drivers/staging/rk29/vivante/hal/kernel/gc_hal_kernel.h @@ -1,21 +1,21 @@ /**************************************************************************** -* -* Copyright (C) 2005 - 2010 by Vivante Corp. -* +* +* Copyright (C) 2005 - 2011 by Vivante Corp. +* * 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., 675 Mass Ave, Cambridge, MA 02139, USA. -* +* *****************************************************************************/ @@ -403,4 +403,3 @@ gckHARDWARE_QueryIdle( #endif #endif /* __gc_hal_kernel_h_ */ - diff --git a/drivers/staging/rk29/vivante/hal/kernel/gc_hal_kernel_command.c b/drivers/staging/rk29/vivante/hal/kernel/gc_hal_kernel_command.c old mode 100755 new mode 100644 index 0d0bb37a0518..5cd08fdf2099 --- a/drivers/staging/rk29/vivante/hal/kernel/gc_hal_kernel_command.c +++ b/drivers/staging/rk29/vivante/hal/kernel/gc_hal_kernel_command.c @@ -1,21 +1,21 @@ /**************************************************************************** -* +* * Copyright (C) 2005 - 2011 by Vivante Corp. -* +* * 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., 675 Mass Ave, Cambridge, MA 02139, USA. -* +* *****************************************************************************/ @@ -30,6 +30,7 @@ #define _GC_OBJ_ZONE gcvZONE_COMMAND + /******************************************************************************\ ********************************* Support Code ********************************* \******************************************************************************/ @@ -758,8 +759,8 @@ gckCOMMAND_Commit( gctBOOL semaAcquired = gcvFALSE; gctINT32 atomValue; gctBOOL atomIncremented = gcvFALSE; - gctUINT32 process, thread; gctBOOL powerAcquired = gcvFALSE; + gctUINT32 process, thread; gcmkHEADER_ARG("Command=0x%x CommandBuffer=0x%x Context=0x%x", Command, CommandBuffer, Context); @@ -773,6 +774,22 @@ gckCOMMAND_Commit( return gcvSTATUS_OK; #endif +// dkm: gcdENABLE_AUTO_FREQ +#if (2==gcdENABLE_AUTO_FREQ) + { + static int cnt = 0; + extern void mod_gpu_timer(void); + extern int needhighfreq; + + if( (++cnt>20) && (0==Command->pipeSelect) ) { + cnt = 0; + mod_gpu_timer(); + needhighfreq = 1; + //printk("needhighfreq = 1! \n"); + } + } +#endif + gcmkONERROR( _AddMap(Command->os, CommandBuffer, @@ -833,11 +850,12 @@ gckCOMMAND_Commit( &atomValue)); atomIncremented = gcvTRUE; + /* Release the power mutex. */ if (powerAcquired) { + hardware->powerProcess = hardware->powerThread = 0x0; + /* Release the power mutex. */ - hardware->powerProcess = 0; - hardware->powerThread = 0; gcmkONERROR(gckOS_ReleaseMutex(Command->os, hardware->powerMutex)); powerAcquired = gcvFALSE; } @@ -1362,9 +1380,9 @@ OnError: if (powerAcquired) { + hardware->powerProcess = hardware->powerThread = 0x0; + /* Release the power mutex. */ - hardware->powerProcess = 0; - hardware->powerThread = 0; gcmkONERROR(gckOS_ReleaseMutex(Command->os, hardware->powerMutex)); } @@ -1408,12 +1426,13 @@ gckCOMMAND_Reserve( gceSTATUS status; gctSIZE_T requiredBytes, bytes; gctBOOL acquired = gcvFALSE; - gctBOOL semaAcquired = gcvFALSE; // This value must be gcvFALSE - gckHARDWARE hardware = gcvNULL; + // dkm: This value must be gcvFALSE + gctBOOL semaAcquired = gcvFALSE; gctINT32 atomValue; gctBOOL atomIncremented = gcvFALSE; - gctUINT32 process, thread; gctBOOL powerAcquired = gcvFALSE; + gckHARDWARE hardware = gcvNULL; + gctUINT32 process, thread; gcmkHEADER_ARG("Command=0x%x RequestedBytes=%lu", Command, RequestedBytes); @@ -1450,7 +1469,7 @@ gckCOMMAND_Reserve( hardware->powerMutex, gcvINFINITE)); hardware->powerProcess = process; - hardware->powerThread = thread; + hardware->powerThread = thread; powerAcquired = gcvTRUE; } } @@ -1466,9 +1485,9 @@ gckCOMMAND_Reserve( if (powerAcquired) { + hardware->powerProcess = hardware->powerThread = 0x0; + /* Release the power mutex. */ - hardware->powerProcess = 0; - hardware->powerThread = 0; gcmkONERROR(gckOS_ReleaseMutex(Command->os, Command->kernel->hardware->powerMutex)); powerAcquired = gcvFALSE; @@ -1555,9 +1574,9 @@ OnError: if (powerAcquired) { + hardware->powerProcess = hardware->powerThread = 0x0; + /* Release the power mutex. */ - hardware->powerProcess = 0; - hardware->powerThread = 0; gcmkONERROR(gckOS_ReleaseMutex(Command->os, Command->kernel->hardware->powerMutex)); } @@ -1846,7 +1865,7 @@ gckCOMMAND_Stall( do { /* Wait for the signal. */ - status = gckOS_WaitSignal(os, signal, 250); + status = gckOS_WaitSignalUninterruptible(os, signal, 250); if (status == gcvSTATUS_TIMEOUT) { @@ -1940,4 +1959,3 @@ OnError: gcmkFOOTER(); return status; } - diff --git a/drivers/staging/rk29/vivante/hal/kernel/gc_hal_kernel_event.c b/drivers/staging/rk29/vivante/hal/kernel/gc_hal_kernel_event.c old mode 100755 new mode 100644 index 122bca943301..213f4f527cf1 --- a/drivers/staging/rk29/vivante/hal/kernel/gc_hal_kernel_event.c +++ b/drivers/staging/rk29/vivante/hal/kernel/gc_hal_kernel_event.c @@ -1,21 +1,21 @@ /**************************************************************************** -* -* Copyright (C) 2005 - 2010 by Vivante Corp. -* +* +* Copyright (C) 2005 - 2011 by Vivante Corp. +* * 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., 675 Mass Ave, Cambridge, MA 02139, USA. -* +* *****************************************************************************/ @@ -979,8 +979,6 @@ gckEVENT_Interrupt( /* Combine current interrupt status with pending flags. */ Event->pending |= Data; - //printk("& "); - /* Success. */ gcmkFOOTER_NO(); return gcvSTATUS_OK; @@ -1473,4 +1471,3 @@ OnError: gcmkFOOTER(); return status; } - diff --git a/drivers/staging/rk29/vivante/hal/kernel/gc_hal_kernel_heap.c b/drivers/staging/rk29/vivante/hal/kernel/gc_hal_kernel_heap.c index ee65306352d8..cb5fb91851c0 100644 --- a/drivers/staging/rk29/vivante/hal/kernel/gc_hal_kernel_heap.c +++ b/drivers/staging/rk29/vivante/hal/kernel/gc_hal_kernel_heap.c @@ -1,21 +1,21 @@ /**************************************************************************** -* -* Copyright (C) 2005 - 2010 by Vivante Corp. -* +* +* Copyright (C) 2005 - 2011 by Vivante Corp. +* * 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., 675 Mass Ave, Cambridge, MA 02139, USA. -* +* *****************************************************************************/ @@ -43,7 +43,7 @@ typedef struct _gcskNODE { /* Number of byets in node. */ gctSIZE_T bytes; - + /* Pointer to next free node, or gcvNULL to mark the node as freed, or ** gcdIN_USE to mark the node as used. */ gcskNODE_PTR next; @@ -166,7 +166,7 @@ _CompactKernelHeap( gcskHEAP_PTR heap, next; gctPOINTER p; gcskHEAP_PTR freeList = gcvNULL; - + gcmkHEADER_ARG("Heap=0x%x", Heap); /* Walk all the heaps. */ @@ -537,7 +537,7 @@ gckHEAP_Allocate( { /* Compact the heap. */ gcmkVERIFY_OK(_CompactKernelHeap(Heap)); - + #if gcdDEBUG gcmkTRACE_ZONE(gcvLEVEL_VERBOSE, gcvZONE_HEAP, "===== KERNEL HEAP ====="); @@ -578,8 +578,8 @@ gckHEAP_Allocate( /* Allocate a new heap. */ gcmkONERROR( - gckOS_AllocateVirtualMemory(Heap->os, - Heap->allocationSize, + gckOS_AllocateVirtualMemory(Heap->os, + Heap->allocationSize, &memory)); gcmkTRACE_ZONE(gcvLEVEL_INFO, gcvZONE_HEAP, @@ -654,7 +654,7 @@ UseNode: { heap->next->prev = heap->prev; } - + /* Move the heap to the front of the list. */ heap->next = Heap->heap; heap->prev = gcvNULL; @@ -777,7 +777,7 @@ gckHEAP_Free( /* Mark the node as freed. */ node->next = gcvNULL; - + #if VIVANTE_PROFILER || gcdDEBUG /* Update profile counters. */ Heap->allocBytes -= node->bytes; @@ -857,200 +857,3 @@ gckHEAP_ProfileEnd( ***** Test Code **************************************************************** *******************************************************************************/ -#if defined gcdHAL_TEST - -#include -#define gcmRANDOM(n) (rand() % n) - -typedef struct -{ - gctSIZE_T bytes; - gctPOINTER memory; -} -gcskHEAP_TEST; - -gceSTATUS -gckHEAP_Test( - IN gckHEAP Heap, - IN gctSIZE_T Vectors, - IN gctSIZE_T MaxSize - ) -{ - gctSIZE_T nodeCount = MaxSize / 4; - gcskHEAP_TEST * nodes = gcvNULL; - gctSIZE_T bytes, index, i; - gceSTATUS status, failure = gcvSTATUS_OK; - gctUINT8_PTR memory; - gcskHEAP_PTR heap, current; - - /* Allocate the node array. */ - gcmkONERROR( - gckOS_AllocateMemory(Heap->os, - nodeCount * gcmSIZEOF(gcskHEAP_TEST), - (gctPOINTER *) &nodes)); - - /* Mark all nodes as free. */ - gcmkONERROR( - gckOS_ZeroMemory(nodes, nodeCount * gcmSIZEOF(gcskHEAP_TEST))); - - gcmkONERROR(gckHEAP_ProfileStart(Heap)); - - /* Loop through all vectors. */ - while (Vectors-- > 0) - { - /* Get a random index. */ - index = gcmRANDOM(nodeCount); - - /* Test if we need to allocate pages. */ - if (nodes[index].bytes == 0) - { - /* Generate a random byte size. */ - do - { - bytes = gcmALIGN(gcmRANDOM(MaxSize), gcmSIZEOF(gctSIZE_T)); - } - while (bytes == 0); - - /* Allocate pages. */ - status = gckHEAP_Allocate(Heap, bytes, (gctPOINTER *) &memory); - - if (gcmIS_SUCCESS(status)) - { - /* Mark node as allocated. */ - nodes[index].bytes = bytes; - nodes[index].memory = memory; - - /* Put signature in the memory. */ - for (i = 0; i < bytes; i += gcmSIZEOF(gctSIZE_T)) - { - *(gctSIZE_T_PTR) (memory + i) = index; - } - } - else - { - gcmkTRACE(gcvLEVEL_WARNING, - "%s(%d): Failed to allocate %lu bytes", - __FUNCTION__, __LINE__, bytes); - } - } - else - { - /* Verify the memory. */ - memory = nodes[index].memory; - for (i = 0; i < nodes[index].bytes; i += gcmSIZEOF(gctSIZE_T)) - { - if (*(gctSIZE_T_PTR) (memory + i) != index) - { - gcmkFATAL("%s(%d): Corruption detected at index %lu", - __FUNCTION__, __LINE__, index); - - failure = gcvSTATUS_HEAP_CORRUPTED; - } - } - - /* Free the memory. */ - status = gckHEAP_Free(Heap, memory); - - if (gcmIS_ERROR(status)) - { - gcmkFATAL("%s(%d): Cannot free %lu bytes at 0x%x (index=%lu)", - __FUNCTION__, __LINE__, - nodes[index].bytes, memory, index); - - failure = status; - } - - /* Mark the node as free. */ - nodes[index].bytes = 0; - } - - /* Verify the heap chain. */ - i = 0; - for (current = Heap->heap; current != gcvNULL; current = current->next) - { - gctSIZE_T j; - for (heap = Heap->heap, j = 0; j < i; heap = heap->next, ++j) - { - if (heap == current) - { - gcmkFATAL("%s(%d): Linked list corrupted for heap 0x%x", - __FUNCTION__, __LINE__, current); - - failure = gcvSTATUS_HEAP_CORRUPTED; - } - } - - if (heap != current) - { - gcmkFATAL("%s(%d): Linked list corrupted for heap 0x%x", - __FUNCTION__, __LINE__, current); - - failure = gcvSTATUS_HEAP_CORRUPTED; - } - - ++i; - } - } - - /* Walk the entire array of nodes. */ - for (index = 0; index < nodeCount; ++index) - { - /* Test if we need to free pages. */ - if (nodes[index].bytes != 0) - { - /* Verify the memory. */ - memory = nodes[index].memory; - for (i = 0; i < nodes[index].bytes; i += gcmSIZEOF(gctSIZE_T)) - { - if (*(gctSIZE_T_PTR) (memory + i) != index) - { - gcmkFATAL("%s(%d): Corruption detected at page %lu", - __FUNCTION__, __LINE__, index); - - failure = gcvSTATUS_HEAP_CORRUPTED; - } - } - - /* Free the memory. */ - status = gckHEAP_Free(Heap, memory); - - if (gcmIS_ERROR(status)) - { - gcmkFATAL("%s(%d): Cannot free %u bytes at 0x%x (index=%lu)", - __FUNCTION__, __LINE__, - nodes[index].bytes, memory, index); - - failure = status; - } - } - } - - /* Perform garbage collection. */ - gcmkONERROR(_CompactKernelHeap(Heap)); - - /* Show profiling. */ - gcmkONERROR(gckHEAP_ProfileEnd(Heap, "Profile")); - - /* Verify we did not loose any nodes. */ - if (Heap->heap != gcvNULL) - { - gcmkFATAL("%s(%d): Detected leaking in the heap.", - __FUNCTION__, __LINE__); - - failure = gcvSTATUS_HEAP_CORRUPTED; - } - -OnError: - /* Roll back. */ - if (nodes != gcvNULL) - { - gcmkVERIFY_OK( - gckOS_FreeMemory(Heap->os, nodes)); - } - - /* Return the status. */ - gcmkFOOTER(); - return status; -} -#endif - diff --git a/drivers/staging/rk29/vivante/hal/kernel/gc_hal_kernel_mmu.c b/drivers/staging/rk29/vivante/hal/kernel/gc_hal_kernel_mmu.c index ed77149566d7..b23dcf6b3a32 100644 --- a/drivers/staging/rk29/vivante/hal/kernel/gc_hal_kernel_mmu.c +++ b/drivers/staging/rk29/vivante/hal/kernel/gc_hal_kernel_mmu.c @@ -1,21 +1,21 @@ /**************************************************************************** -* -* Copyright (C) 2005 - 2010 by Vivante Corp. -* +* +* Copyright (C) 2005 - 2011 by Vivante Corp. +* * 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., 675 Mass Ave, Cambridge, MA 02139, USA. -* +* *****************************************************************************/ @@ -75,9 +75,9 @@ _Link( static gceSTATUS _AddFree( - IN gckMMU Mmu, - IN gctUINT32 Index, - IN gctUINT32 Node, + IN gckMMU Mmu, + IN gctUINT32 Index, + IN gctUINT32 Node, IN gctUINT32 Count ) { @@ -201,7 +201,7 @@ OnError: ** gckMMU * Mmu ** Pointer to a variable that receives the gckMMU object pointer. */ -gceSTATUS +gceSTATUS gckMMU_Construct( IN gckKERNEL Kernel, IN gctSIZE_T MmuSize, @@ -213,7 +213,7 @@ gckMMU_Construct( gceSTATUS status; gckMMU mmu = gcvNULL; gctUINT32_PTR pageTable; - + gcmkHEADER_ARG("Kernel=0x%x MmuSize=%lu", Kernel, MmuSize); /* Verify the arguments. */ @@ -290,7 +290,7 @@ OnError: { /* Free the page table. */ gcmkVERIFY_OK( - gckOS_FreeContiguous(os, + gckOS_FreeContiguous(os, mmu->pageTablePhysical, (gctPOINTER) mmu->pageTableLogical, mmu->pageTableSize)); @@ -303,7 +303,7 @@ OnError: gckOS_DeleteMutex(os, mmu->pageTableMutex)); } -#ifdef __QNXNTO__ +#ifdef __QNXNTO__ if (mmu->nodeMutex != gcvNULL) { /* Delete the mutex. */ @@ -339,7 +339,7 @@ OnError: ** ** Nothing. */ -gceSTATUS +gceSTATUS gckMMU_Destroy( IN gckMMU Mmu ) @@ -349,7 +349,7 @@ gckMMU_Destroy( #endif gcmkHEADER_ARG("Mmu=0x%x", Mmu); - + /* Verify the arguments. */ gcmkVERIFY_OBJECT(Mmu, gcvOBJ_MMU); @@ -425,7 +425,7 @@ gckMMU_AllocatePages( gctUINT32_PTR pageTable; gctBOOL gotIt; gctUINT32 address; - + gcmkHEADER_ARG("Mmu=0x%x PageCount=%lu", Mmu, PageCount); /* Verify the arguments. */ @@ -594,7 +594,7 @@ OnError: ** ** Nothing. */ -gceSTATUS +gceSTATUS gckMMU_FreePages( IN gckMMU Mmu, IN gctPOINTER PageTable, @@ -602,7 +602,7 @@ gckMMU_FreePages( ) { gctUINT32_PTR pageTable; - + gcmkHEADER_ARG("Mmu=0x%x PageTable=0x%x PageCount=%lu", Mmu, PageTable, PageCount); @@ -628,7 +628,7 @@ gckMMU_FreePages( /* We have free nodes. */ Mmu->freeNodes = gcvTRUE; - + /* Success. */ gcmkFOOTER_NO(); return gcvSTATUS_OK; @@ -760,169 +760,3 @@ OnError: ****************************** T E S T C O D E ****************************** ******************************************************************************/ -#if defined gcdHAL_TEST - -#include -#define gcmRANDOM(n) (rand() % n) - -typedef struct -{ - gctSIZE_T pageCount; - gctUINT32_PTR pageTable; -} -gcsMMU_TEST; - -gceSTATUS -gckMMU_Test( - IN gckMMU Mmu, - IN gctSIZE_T Vectors, - IN gctINT MaxSize - ) -{ - const gctINT nodeCount = MaxSize / 4; - gcsMMU_TEST * nodes = gcvNULL; - gceSTATUS status, failure = gcvSTATUS_OK; - gctSIZE_T i, count; - gctUINT32_PTR pageTable; - gctINT index; - - /* Allocate the node array. */ - gcmkONERROR( - gckOS_Allocate(Mmu->os, - nodeCount * gcmSIZEOF(gcsMMU_TEST), - (gctPOINTER *) &nodes)); - - /* Mark all nodes as free. */ - gcmkONERROR( - gckOS_ZeroMemory(nodes, nodeCount * gcmSIZEOF(gcsMMU_TEST))); - - /* Loop through all vectors. */ - while (Vectors-- > 0) - { - /* Get a random index. */ - index = gcmRANDOM(nodeCount); - - /* Test if we need to allocate pages. */ - if (nodes[index].pageCount == 0) - { - /* Generate a random page count. */ - do - { - count = gcmRANDOM(MaxSize); - } - while (count == 0); - - /* Allocate pages. */ - status = gckMMU_AllocatePages(Mmu, - count, - (gctPOINTER *) &pageTable, - gcvNULL); - - if (gcmIS_SUCCESS(status)) - { - /* Mark node as allocated. */ - nodes[index].pageCount = count; - nodes[index].pageTable = pageTable; - - /* Put signature in the page table. */ - for (i = 0; i < count; ++i) - { - pageTable[i] = (index << 8) | gcvMMU_USED; - } - } - else - { - gcmkTRACE(gcvLEVEL_WARNING, - "gckMMU_Test: Failed to allocate %u pages", - count); - } - } - else - { - /* Verify the page table. */ - pageTable = nodes[index].pageTable; - for (i = 0; i < nodes[index].pageCount; ++i) - { - if (pageTable[i] != ((index << 8) | gcvMMU_USED)) - { - gcmkFATAL("gckMMU_Test: Corruption detected at page %u", - index); - - failure = gcvSTATUS_HEAP_CORRUPTED; - } - } - - /* Free the pages. */ - status = gckMMU_FreePages(Mmu, pageTable, nodes[index].pageCount); - - if (gcmIS_ERROR(status)) - { - gcmkFATAL("gckMMU_Test: Cannot free %u pages at 0x%x (index=%u)", - nodes[index].pageCount, pageTable, index); - - failure = status; - } - - /* Mark the node as free. */ - nodes[index].pageCount = 0; - } - } - - /* Walk the entire array of nodes. */ - for (index = 0; index < nodeCount; ++index) - { - /* Test if we need to free pages. */ - if (nodes[index].pageCount != 0) - { - /* Verify the page table. */ - pageTable = nodes[index].pageTable; - for (i = 0; i < nodes[index].pageCount; ++i) - { - if (pageTable[i] != ((index << 8) | gcvMMU_USED)) - { - gcmkFATAL("gckMMU_Test: Corruption detected at page %u", - index); - - failure = gcvSTATUS_HEAP_CORRUPTED; - } - } - - /* Free the pages. */ - status = gckMMU_FreePages(Mmu, pageTable, nodes[index].pageCount); - - if (gcmIS_ERROR(status)) - { - gcmkFATAL("gckMMU_Test: Cannot free %u pages at 0x%x (index=%u)", - nodes[index].pageCount, pageTable, index); - - failure = status; - } - } - } - - /* Perform garbage collection. */ - gcmkONERROR(_Collect(Mmu)); - - /* Verify we did not loose any nodes. */ - if ((Mmu->heapList != 0) - || ((Mmu->pageTableLogical[0] & 0xFF) != gcvMMU_FREE) - || (Mmu->pageTableEntries != (Mmu->pageTableLogical[0] >> 8)) - ) - { - gcmkFATAL("gckMMU_Test: Detected leaking in the page table."); - - failure = gcvSTATUS_HEAP_CORRUPTED; - } - -OnError: - /* Free the array of nodes. */ - if (nodes != gcvNULL) - { - gcmkVERIFY_OK(gckOS_Free(Mmu->os, nodes)); - } - - /* Return test status. */ - return failure; -} -#endif - diff --git a/drivers/staging/rk29/vivante/hal/kernel/gc_hal_kernel_precomp.h b/drivers/staging/rk29/vivante/hal/kernel/gc_hal_kernel_precomp.h index 0379a7528416..58ebb140c3e4 100644 --- a/drivers/staging/rk29/vivante/hal/kernel/gc_hal_kernel_precomp.h +++ b/drivers/staging/rk29/vivante/hal/kernel/gc_hal_kernel_precomp.h @@ -1,21 +1,21 @@ /**************************************************************************** -* -* Copyright (C) 2005 - 2010 by Vivante Corp. -* +* +* Copyright (C) 2005 - 2011 by Vivante Corp. +* * 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., 675 Mass Ave, Cambridge, MA 02139, USA. -* +* *****************************************************************************/ @@ -29,4 +29,3 @@ #include "gc_hal_kernel.h" #endif /* __gc_hal_kernel_precomp_h_ */ - diff --git a/drivers/staging/rk29/vivante/hal/kernel/gc_hal_kernel_video_memory.c b/drivers/staging/rk29/vivante/hal/kernel/gc_hal_kernel_video_memory.c index 3adb5c6779ad..c82a51adf55d 100644 --- a/drivers/staging/rk29/vivante/hal/kernel/gc_hal_kernel_video_memory.c +++ b/drivers/staging/rk29/vivante/hal/kernel/gc_hal_kernel_video_memory.c @@ -1,21 +1,21 @@ /**************************************************************************** -* -* Copyright (C) 2005 - 2010 by Vivante Corp. -* +* +* Copyright (C) 2005 - 2011 by Vivante Corp. +* * 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., 675 Mass Ave, Cambridge, MA 02139, USA. -* +* *****************************************************************************/ @@ -822,6 +822,15 @@ gckVIDMEM_AllocateLinear( acquired = gcvTRUE; + // dkm: ¶ÔÓÚ»¨ÆÁËÀ»úµÄÎÊÌ⣬¸Ð¾õVVÕâô×öÖ»Êǹæ±Ü£¬»¹ÊÇûÓÐÕÒµ½ÎÊÌâµÄÔ­Òò + if (Type == gcvSURF_TILE_STATUS + && (Bytes + (1 << 20) > Memory->freeBytes) + ) + { + /* Not enough memory. */ + gcmkONERROR(gcvSTATUS_OUT_OF_MEMORY); + } + if (Bytes > Memory->freeBytes) { /* Not enough memory. */ @@ -987,8 +996,8 @@ gckVIDMEM_Free( "Node 0x%x is locked (%d)", Node, Node->VidMem.locked); - /* Node is locked. */ - gcmkONERROR(gcvSTATUS_MEMORY_LOCKED); + /* Force unlock. */ + Node->VidMem.locked = 0; } /* Extract pointer to gckVIDMEM object owning the node. */ @@ -1072,8 +1081,8 @@ gckVIDMEM_Free( "gckVIDMEM_Free: Virtual node 0x%x is locked (%d)", Node, Node->Virtual.locked); - /* Node is locked. */ - gcmkONERROR(gcvSTATUS_MEMORY_LOCKED); + /* Force unlock. */ + Node->Virtual.locked = 0; } #ifdef __QNXNTO__ @@ -1751,4 +1760,3 @@ gckVIDMEM_SetPID( return gcvSTATUS_OK; } #endif - diff --git a/drivers/staging/rk29/vivante/hal/kernel/makefile.linux b/drivers/staging/rk29/vivante/hal/kernel/makefile.linux index d4dc5bbaa338..2abd9946f02b 100644 --- a/drivers/staging/rk29/vivante/hal/kernel/makefile.linux +++ b/drivers/staging/rk29/vivante/hal/kernel/makefile.linux @@ -1,6 +1,6 @@ ############################################################################## # -# Copyright (C) 2005 - 2010 by Vivante Corp. +# Copyright (C) 2005 - 2011 by Vivante Corp. # # 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 diff --git a/drivers/staging/rk29/vivante/hal/makefile.linux b/drivers/staging/rk29/vivante/hal/makefile.linux index 5d4112255130..3051c63712cf 100644 --- a/drivers/staging/rk29/vivante/hal/makefile.linux +++ b/drivers/staging/rk29/vivante/hal/makefile.linux @@ -1,6 +1,6 @@ ############################################################################## # -# Copyright (c) 2005 - 2010 by Vivante Corp. All rights reserved. +# Copyright (c) 2005 - 2011 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 @@ -10,7 +10,7 @@ # ############################################################################## # -# Auto-generated file on 12/17/2010. Do not edit!!! +# Auto-generated file on 5/20/2011. Do not edit!!! # ############################################################################## diff --git a/drivers/staging/rk29/vivante/hal/os/libGAL.def.mak b/drivers/staging/rk29/vivante/hal/os/libGAL.def.mak old mode 100755 new mode 100644 index eb56599b6277..20e8e81c7429 --- a/drivers/staging/rk29/vivante/hal/os/libGAL.def.mak +++ b/drivers/staging/rk29/vivante/hal/os/libGAL.def.mak @@ -4,13 +4,13 @@ # # 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, +# 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. # ############################################################################## # -# Auto-generated file on 1/7/2011. Do not edit!!! +# Auto-generated file on 5/20/2011. Do not edit!!! # ############################################################################## @@ -111,9 +111,11 @@ EXPORTS ; gcoHAL gcoHAL_Construct + gcoHAL_ConstructGlobal gcoHAL_Destroy gcoHAL_IsFeatureAvailable gcoHAL_QueryChipIdentity + gcoHAL_QueryChipMinorFeatures gcoHAL_Call gcoHAL_QueryVideoMemory gcoHAL_MapMemory @@ -152,6 +154,10 @@ EXPORTS gcoDUMP_DumpData gcoDUMP_Delete gcfDump + gcfDumpApi + gcfDumpArray + gcfDumpArrayToken + gcfDumpApiData ; gcoSURF gcoSURF_Construct @@ -187,6 +193,7 @@ EXPORTS gcoSURF_SetOrientation gcoSURF_QueryOrientation gcoSURF_QueryReferenceCount + gcoSURF_ResetHal !IFNDEF VIVANTE_NO_3D gcoSURF_IsTileStatusSupported @@ -280,7 +287,9 @@ EXPORTS gco2D_ProfileEngine gco2D_GetMaximumDataCount gco2D_EnableDither - + gco2D_SetGenericSource; + gco2D_SetGenericTarget; + gco2D_FilterBlitEx2; !IFNDEF VIVANTE_NO_3D gco3D_Construct @@ -359,6 +368,9 @@ EXPORTS gco3D_SetAlphaTextureFunction gco3D_Semaphore gco3D_SetCentroids + gco3D_SetWClipEnable + gco3D_SetWPlaneLimitF + gco3D_SetWPlaneLimitX !ENDIF !IFNDEF VIVANTE_NO_3D diff --git a/drivers/staging/rk29/vivante/hal/os/linux/kernel/gc_hal_kernel_debug.c b/drivers/staging/rk29/vivante/hal/os/linux/kernel/gc_hal_kernel_debug.c index 078a1c7d9ddd..34c4be3c44cd 100644 --- a/drivers/staging/rk29/vivante/hal/os/linux/kernel/gc_hal_kernel_debug.c +++ b/drivers/staging/rk29/vivante/hal/os/linux/kernel/gc_hal_kernel_debug.c @@ -1,21 +1,21 @@ /**************************************************************************** -* -* Copyright (C) 2005 - 2010 by Vivante Corp. -* +* +* Copyright (C) 2005 - 2011 by Vivante Corp. +* * 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., 675 Mass Ave, Cambridge, MA 02139, USA. -* +* *****************************************************************************/ @@ -27,7 +27,7 @@ /* 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. @@ -55,17 +55,17 @@ OutputDebugString( gctINT n, i; n = (String != gcvNULL) ? strlen(String) + 1 : 0; - + if ((n == 0) || (outputBufferIndex + n > gcmSIZEOF(outputBuffer))) { for (i = 0; i < outputBufferIndex; i += strlen(outputBuffer + i) + 1) { printk(outputBuffer + i); } - + outputBufferIndex = 0; } - + if (n > 0) { memcpy(outputBuffer + outputBufferIndex, String, n); @@ -87,7 +87,7 @@ _Print( { char buffer[1024]; int i, n; - + if (strcmp(Message, "$$FLUSH$$") == 0) { spin_lock(&_lock); @@ -97,22 +97,22 @@ _Print( spin_unlock(&_lock); return; } - + if (strncmp(Message, "--", 2) == 0) { if (_indent == 0) { printk("ERROR: _indent=0\n"); } - + _indent -= 2; } - + for (i = 0; i < _indent; ++i) { buffer[i] = ' '; } - + /* Print message to buffer. */ n = vsnprintf(buffer + i, sizeof(buffer) - i, Message, Arguments); if ((n <= 0) || (buffer[i + n - 1] != '\n')) @@ -127,7 +127,7 @@ _Print( OutputDebugString(buffer); } spin_unlock(&_lock); - + if (strncmp(Message, "++", 2) == 0) { _indent += 2; @@ -325,7 +325,7 @@ gckOS_DebugFatal( ** Nothing. */ -void +void gckOS_SetDebugLevel( IN gctUINT32 Level ) @@ -348,7 +348,7 @@ gckOS_SetDebugLevel( ** ** Nothing. */ -void +void gckOS_SetDebugZone( IN gctUINT32 Zone ) @@ -375,7 +375,7 @@ gckOS_SetDebugZone( ** Nothing. */ -void +void gckOS_SetDebugLevelZone( IN gctUINT32 Level, IN gctUINT32 Zone @@ -405,7 +405,7 @@ gckOS_SetDebugLevelZone( ** Nothing. */ -void +void gckOS_SetDebugZones( IN gctUINT32 Zones, IN gctBOOL Enable @@ -446,4 +446,3 @@ gckOS_Verify( { _lastError = Status; } - diff --git a/drivers/staging/rk29/vivante/hal/os/linux/kernel/gc_hal_kernel_device.c b/drivers/staging/rk29/vivante/hal/os/linux/kernel/gc_hal_kernel_device.c index 8fd9af9f7790..9440eed8271e 100644 --- a/drivers/staging/rk29/vivante/hal/os/linux/kernel/gc_hal_kernel_device.c +++ b/drivers/staging/rk29/vivante/hal/os/linux/kernel/gc_hal_kernel_device.c @@ -1,21 +1,21 @@ /**************************************************************************** -* -* Copyright (C) 2005 - 2010 by Vivante Corp. -* +* +* Copyright (C) 2005 - 2011 by Vivante Corp. +* * 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., 675 Mass Ave, Cambridge, MA 02139, USA. -* +* *****************************************************************************/ @@ -488,7 +488,7 @@ gckGALDEVICE_Construct( device->registerBase = (gctPOINTER) ioremap_nocache(RegisterMemBase, RegisterMemSize); if (!device->registerBase) - { + { gcmkTRACE_ZONE(gcvLEVEL_INFO, gcvZONE_DRIVER, "[galcore] gckGALDEVICE_Construct: Unable to map location->0x%lX for size->%ld", RegisterMemBase, @@ -496,6 +496,7 @@ gckGALDEVICE_Construct( return gcvSTATUS_OUT_OF_RESOURCES; } + // dkm: print te regbase printk("---- gpu regbase: 0x%08x ---- \n", (unsigned int)device->registerBase); physical += RegisterMemSize; @@ -515,6 +516,12 @@ gckGALDEVICE_Construct( /* construct the gckKERNEL object. */ gcmkVERIFY_OK(gckKERNEL_Construct(device->os, device, &device->kernel)); + /* Setup the Isr manager. */ + gcmkVERIFY_OK(gckHARDWARE_SetIsrManager(device->kernel->hardware, + (gctISRMANAGERFUNC)gckGALDEVICE_Setup_ISR, + (gctISRMANAGERFUNC)gckGALDEVICE_Release_ISR, + device)); + gcmkVERIFY_OK(gckHARDWARE_SetFastClear(device->kernel->hardware, FastClear, Compression)); @@ -612,7 +619,7 @@ gckGALDEVICE_Construct( { /* map internal memory */ device->externalPhysical = (gctPHYS_ADDR)physical; -// dkm: gcdENABLE_MEM_CACHE +// dkm: gcdENABLE_MEM_CACHE #if (1==gcdENABLE_MEM_CACHE) device->externalLogical = (gctPOINTER)ioremap_cached( physical, device->externalSize); @@ -731,7 +738,7 @@ gckGALDEVICE_Construct( device->contiguousPhysical = (gctPHYS_ADDR) ContiguousBase; device->contiguousSize = ContiguousSize; -// dkm: gcdENABLE_MEM_CACHE +// dkm: gcdENABLE_MEM_CACHE #if (1==gcdENABLE_MEM_CACHE) device->contiguousBase = (gctPOINTER) ioremap_cached(ContiguousBase, ContiguousSize); #else @@ -851,4 +858,3 @@ gckGALDEVICE_Destroy( return gcvSTATUS_OK; } - diff --git a/drivers/staging/rk29/vivante/hal/os/linux/kernel/gc_hal_kernel_device.h b/drivers/staging/rk29/vivante/hal/os/linux/kernel/gc_hal_kernel_device.h index 01629d99b85a..57122e8ab14d 100644 --- a/drivers/staging/rk29/vivante/hal/os/linux/kernel/gc_hal_kernel_device.h +++ b/drivers/staging/rk29/vivante/hal/os/linux/kernel/gc_hal_kernel_device.h @@ -1,21 +1,21 @@ /**************************************************************************** -* +* * Copyright (C) 2005 - 2011 by Vivante Corp. -* +* * 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., 675 Mass Ave, Cambridge, MA 02139, USA. -* +* *****************************************************************************/ @@ -91,9 +91,10 @@ typedef enum _gceMEMORY_TYPE gcvVIDEO_MEMORY } gceMEMORY_TYPE; + typedef struct MEMORY_RECORD { - gceMEMORY_TYPE type; + gceMEMORY_TYPE type; union { @@ -129,6 +130,7 @@ typedef struct _gcsHAL_PRIVATE_DATA #if gcdkUSE_MEMORY_RECORD MEMORY_RECORD memoryRecordList; + #if gcdkREPORT_VIDMEM_USAGE gctUINT64 allocatedMem[gcvSURF_NUM_TYPES]; gctUINT64 maxAllocatedMem[gcvSURF_NUM_TYPES]; @@ -182,4 +184,3 @@ gceSTATUS gckGALDEVICE_Destroy( ); #endif /* __gc_hal_kernel_device_h_ */ - diff --git a/drivers/staging/rk29/vivante/hal/os/linux/kernel/gc_hal_kernel_driver.c b/drivers/staging/rk29/vivante/hal/os/linux/kernel/gc_hal_kernel_driver.c index 84014a611417..0e0fd06dbee6 100644 --- a/drivers/staging/rk29/vivante/hal/os/linux/kernel/gc_hal_kernel_driver.c +++ b/drivers/staging/rk29/vivante/hal/os/linux/kernel/gc_hal_kernel_driver.c @@ -1,29 +1,30 @@ /**************************************************************************** -* +* * Copyright (C) 2005 - 2011 by Vivante Corp. -* +* * 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., 675 Mass Ave, Cambridge, MA 02139, USA. -* +* *****************************************************************************/ #include -#include #include +// dkm: add +#include #include #include #include @@ -35,6 +36,7 @@ #if USE_PLATFORM_DRIVER #include #endif +// dkm: add #include #include #include @@ -64,6 +66,7 @@ module_param(contiguousSize, long, 0644); ulong contiguousBase = 0; module_param(contiguousBase, ulong, 0644); +// dkm: change to 16 from 32 long bankSize = 16 << 20; module_param(bankSize, long, 0644); @@ -83,10 +86,12 @@ int showArgs = 0; module_param(showArgs, int, 0644); #if ENABLE_GPU_CLOCK_BY_DRIVER +// dkm: change unsigned long coreClock = 552*1000000; module_param(coreClock, ulong, 0644); #endif +// gcdkREPORT_VIDMEM_USAGE add by vv #if gcdkREPORT_VIDMEM_USAGE #include @@ -171,6 +176,7 @@ static void gckDeviceProc_UnRegister(void) } #endif +// dkm: add int shutdown = 0; static int drv_open(struct inode *inode, struct file *filp); @@ -187,7 +193,8 @@ struct file_operations driver_fops = .mmap = drv_mmap, }; -#if gcdENABLE_AUTO_FREQ +// dkm: gcdENABLE_AUTO_FREQ +#if (1==gcdENABLE_AUTO_FREQ) #include struct timer_list gpu_timer; extern void get_run_idle(u32 *run, u32 *idle); @@ -233,8 +240,22 @@ void gputimer_callback(unsigned long arg) printk("%8d /%8d = %3d %%, needfreq = %dM (%d)\n", (int)run, (int)(run+idle), precent, freq, power_cnt); } +#elif(2==gcdENABLE_AUTO_FREQ) +#include +struct timer_list gpu_timer; +int needhighfreq = 0; +void mod_gpu_timer(void) +{ + mod_timer(&gpu_timer, jiffies + 3*HZ); +} +void gputimer_callback(unsigned long arg) +{ + needhighfreq = 0; + //printk("needhighfreq = 0! \n"); +} #endif +// dkm: gcdENABLE_DELAY_EARLY_SUSPEND #if (1==gcdENABLE_DELAY_EARLY_SUSPEND) struct delayed_work suspend_work; void real_suspend(struct work_struct *work) @@ -264,9 +285,9 @@ int drv_open(struct inode *inode, struct file* filp) { return -ENOTTY; } - /* Zero the memory. */ + + /* Zero the memory. */ gckOS_ZeroMemory(private, gcmSIZEOF(gcsHAL_PRIVATE_DATA)); - private->device = galDevice; private->mappedMemory = gcvNULL; @@ -281,15 +302,17 @@ int drv_open(struct inode *inode, struct file* filp) gcmkVERIFY_OK( gckKERNEL_AttachProcess(galDevice->kernel, gcvTRUE)); - if (!galDevice->contiguousMapped) + if (galDevice->contiguousSize != 0 + && !galDevice->contiguousMapped) { gcmkVERIFY_OK(gckOS_MapMemory(galDevice->os, galDevice->contiguousPhysical, galDevice->contiguousSize, &private->contiguousLogical)); } - + filp->private_data = private; +// gcdkREPORT_VIDMEM_USAGE add by vv #if gcdkREPORT_VIDMEM_USAGE s_gckHalPrivate = private; #endif @@ -311,18 +334,23 @@ int drv_release(struct inode* inode, struct file* filp) gcmkTRACE_ZONE(gcvLEVEL_INFO, gcvZONE_DRIVER, "Entering drv_close\n"); - gcmkVERIFY_OK( - gckOS_DestroyAllUserSignals(galDevice->os)); - private = filp->private_data; gcmkASSERT(private != gcvNULL); device = private->device; +#ifndef ANDROID + gcmkVERIFY_OK(gckCOMMAND_Stall(device->kernel->command)); +#endif + + gcmkVERIFY_OK( + gckOS_DestroyAllUserSignals(galDevice->os)); + #if gcdkUSE_MEMORY_RECORD FreeAllMemoryRecord(galDevice->os, private, &private->memoryRecordList); #ifdef ANDROID +// dkm: ±£ÁôdelayµÄ×ö·¨ gcmkVERIFY_OK(gckOS_Delay(galDevice->os, 1000)); #else gcmkVERIFY_OK(gckCOMMAND_Stall(device->kernel->command)); @@ -343,6 +371,7 @@ int drv_release(struct inode* inode, struct file* filp) /* A process gets detached. */ gcmkVERIFY_OK( gckKERNEL_AttachProcess(galDevice->kernel, gcvFALSE)); +// gcdkREPORT_VIDMEM_USAGE add by vv #if gcdkREPORT_VIDMEM_USAGE s_gckHalPrivate = NULL; #endif @@ -354,7 +383,7 @@ int drv_release(struct inode* inode, struct file* filp) } int drv_ioctl(struct inode *inode, - struct file *filp, + struct file *filp, unsigned int ioctlCode, unsigned long arg) { @@ -364,9 +393,10 @@ int drv_ioctl(struct inode *inode, gckGALDEVICE device; gceSTATUS status; gcsHAL_PRIVATE_DATA_PTR private; - + private = filp->private_data; + // dkm: add if(shutdown) { return -ENOTTY; @@ -379,9 +409,9 @@ int drv_ioctl(struct inode *inode, return -ENOTTY; } - + device = private->device; - + if (device == gcvNULL) { gcmkTRACE_ZONE(gcvLEVEL_ERROR, gcvZONE_DRIVER, @@ -389,7 +419,7 @@ int drv_ioctl(struct inode *inode, return -ENOTTY; } - + if (ioctlCode != IOCTL_GCHAL_INTERFACE && ioctlCode != IOCTL_GCHAL_KERNEL_INTERFACE) { @@ -401,7 +431,7 @@ int drv_ioctl(struct inode *inode, copyLen = copy_from_user(&drvArgs, (void *) arg, sizeof(DRIVER_ARGS)); - + if (copyLen != 0) { /* The input buffer is not big enough. So fail the I/O. */ @@ -411,7 +441,7 @@ int drv_ioctl(struct inode *inode, /* Now bring in the gcsHAL_INTERFACE structure. */ if ((drvArgs.InputBufferSize != sizeof(gcsHAL_INTERFACE)) || (drvArgs.OutputBufferSize != sizeof(gcsHAL_INTERFACE)) - ) + ) { return -ENOTTY; } @@ -419,19 +449,19 @@ int drv_ioctl(struct inode *inode, copyLen = copy_from_user(&iface, drvArgs.InputBuffer, sizeof(gcsHAL_INTERFACE)); - + if (copyLen != 0) { /* The input buffer is not big enough. So fail the I/O. */ return -ENOTTY; } - + #if gcdkUSE_MEMORY_RECORD if (iface.command == gcvHAL_EVENT_COMMIT) { MEMORY_RECORD_PTR mr; gcsQUEUE_PTR queue = iface.u.Event.queue; - + while (queue != gcvNULL) { gcsQUEUE_PTR record, next; @@ -444,7 +474,7 @@ int drv_ioctl(struct inode *inode, switch (record->iface.command) { - case gcvHAL_FREE_NON_PAGED_MEMORY: + case gcvHAL_FREE_NON_PAGED_MEMORY: mr = FindMemoryRecord(device->os, private, &private->memoryRecordList, @@ -481,22 +511,23 @@ int drv_ioctl(struct inode *inode, gcmkPRINT("*ERROR* Invalid contiguous memory for free"); } break; + case gcvHAL_FREE_VIDEO_MEMORY: - mr = FindVideoMemoryRecord(device->os, + mr = FindVideoMemoryRecord(device->os, private, &private->memoryRecordList, record->iface.u.FreeVideoMemory.node); - - if (mr != gcvNULL) - { - DestroyVideoMemoryRecord(device->os, private, mr); - } - else - { - gcmkPRINT("*ERROR* Invalid video memory for free"); - } + + if (mr != gcvNULL) + { + DestroyVideoMemoryRecord(device->os, private, mr); + } + else + { + gcmkPRINT("*ERROR* Invalid video memory for free"); + } break; - + default: break; } @@ -516,7 +547,7 @@ int drv_ioctl(struct inode *inode, status = gckKERNEL_Dispatch(device->kernel, (ioctlCode == IOCTL_GCHAL_INTERFACE) , &iface); - + if (gcmIS_ERROR(status)) { gcmkTRACE_ZONE(gcvLEVEL_WARNING, gcvZONE_DRIVER, @@ -531,7 +562,7 @@ int drv_ioctl(struct inode *inode, iface.command, iface.status); } - + /* See if this was a LOCK_VIDEO_MEMORY command. */ else if (iface.command == gcvHAL_LOCK_VIDEO_MEMORY) { @@ -543,7 +574,7 @@ int drv_ioctl(struct inode *inode, /* Compute offset into mapped memory. */ gctUINT32 offset = (gctUINT8 *) iface.u.LockVideoMemory.memory - (gctUINT8 *) device->contiguousBase; - + /* Compute offset into user-mapped region. */ iface.u.LockVideoMemory.memory = (gctUINT8 *) private->mappedMemory + offset; @@ -614,37 +645,39 @@ int drv_ioctl(struct inode *inode, } else if (iface.command == gcvHAL_ALLOCATE_VIDEO_MEMORY) { - gctSIZE_T bytes = (iface.u.AllocateVideoMemory.node->VidMem.memory->object.type == gcvOBJ_VIDMEM) - ? iface.u.AllocateVideoMemory.node->VidMem.bytes + gctSIZE_T bytes = (iface.u.AllocateVideoMemory.node->VidMem.memory->object.type == gcvOBJ_VIDMEM) + ? iface.u.AllocateVideoMemory.node->VidMem.bytes : iface.u.AllocateVideoMemory.node->Virtual.bytes; + CreateVideoMemoryRecord(device->os, - private, - &private->memoryRecordList, - iface.u.AllocateVideoMemory.node, - iface.u.AllocateVideoMemory.type & 0xFF, - bytes); + private, + &private->memoryRecordList, + iface.u.AllocateVideoMemory.node, + iface.u.AllocateVideoMemory.type & 0xFF, + bytes); } else if (iface.command == gcvHAL_ALLOCATE_LINEAR_VIDEO_MEMORY) { gctSIZE_T bytes = (iface.u.AllocateLinearVideoMemory.node->VidMem.memory->object.type == gcvOBJ_VIDMEM) - ? iface.u.AllocateLinearVideoMemory.node->VidMem.bytes + ? iface.u.AllocateLinearVideoMemory.node->VidMem.bytes : iface.u.AllocateLinearVideoMemory.node->Virtual.bytes; + CreateVideoMemoryRecord(device->os, - private, - &private->memoryRecordList, - iface.u.AllocateLinearVideoMemory.node, - iface.u.AllocateLinearVideoMemory.type & 0xFF, - bytes); + private, + &private->memoryRecordList, + iface.u.AllocateLinearVideoMemory.node, + iface.u.AllocateLinearVideoMemory.type & 0xFF, + bytes); } else if (iface.command == gcvHAL_FREE_VIDEO_MEMORY) { MEMORY_RECORD_PTR mr; - + mr = FindVideoMemoryRecord(device->os, - private, - &private->memoryRecordList, - iface.u.FreeVideoMemory.node); - + private, + &private->memoryRecordList, + iface.u.FreeVideoMemory.node); + if (mr != gcvNULL) { DestroyVideoMemoryRecord(device->os, private, mr); @@ -706,9 +739,9 @@ static int drv_mmap(struct file * filp, struct vm_area_struct * vma) (gctUINT32) device->contiguousPhysical >> PAGE_SHIFT, size, vma->vm_page_prot); - + private->mappedMemory = (ret == 0) ? (gctPOINTER) vma->vm_start : gcvNULL; - + return ret; } else @@ -717,16 +750,14 @@ static int drv_mmap(struct file * filp, struct vm_area_struct * vma) } } - +// dkm: add static struct miscdevice miscdev = { .name = "galcore", .fops = &driver_fops, .minor = MISC_DYNAMIC_MINOR, }; - - - +// dkm: ÐÞ¸Ädrv_init #if !USE_PLATFORM_DRIVER static int __init drv_init(void) #else @@ -795,6 +826,9 @@ static int drv_init(void) printk(" compression = %d\n", compression); printk(" signal = %d\n", signal); printk(" baseAddress = 0x%08lX\n", baseAddress); +#if ENABLE_GPU_CLOCK_BY_DRIVER + printk(" coreClock = %lu\n", coreClock); +#endif } /* Create the GAL device. */ @@ -809,7 +843,7 @@ static int drv_init(void) baseAddress, signal, &device)); - + /* Start the GAL device. */ if (gcmIS_ERROR(gckGALDEVICE_Start(device))) { @@ -874,21 +908,23 @@ static int drv_init(void) device_create(gpuClass, NULL, MKDEV(major, 0), NULL, "galcore"); #else device_create(gpuClass, NULL, MKDEV(major, 0), "galcore"); -#endif #endif +#endif + gcmkTRACE_ZONE(gcvLEVEL_INFO, gcvZONE_DRIVER, "[galcore] irqLine->%ld, contiguousSize->%lu, memBase->0x%lX\n", irqLine, contiguousSize, registerMemBase); - + gcmkTRACE_ZONE(gcvLEVEL_VERBOSE, gcvZONE_DRIVER, "[galcore] driver registered successfully.\n"); return 0; } +// dkm: ÐÞ¸Ädrv_exit #if !USE_PLATFORM_DRIVER static void __exit drv_exit(void) #else @@ -961,7 +997,7 @@ module_exit(drv_exit); #endif - +// dkm: CONFIG_HAS_EARLYSUSPEND #if CONFIG_HAS_EARLYSUSPEND static void gpu_early_suspend(struct early_suspend *h) { @@ -1019,6 +1055,7 @@ static int __devinit gpu_probe(struct platform_device *pdev) goto gpu_probe_fail; } registerMemBase = res->start; + // dkm: ²»ÄÜ+1 registerMemSize = res->end - res->start; res = platform_get_resource_byname(pdev, IORESOURCE_MEM,"gpu_mem"); @@ -1027,21 +1064,30 @@ static int __devinit gpu_probe(struct platform_device *pdev) goto gpu_probe_fail; } contiguousBase = res->start; - contiguousSize = res->end-res->start; + // dkm: ²»ÄÜ+1 + contiguousSize = res->end - res->start; -#if gcdENABLE_AUTO_FREQ +// dkm: gcdENABLE_AUTO_FREQ +#if (1==gcdENABLE_AUTO_FREQ) init_timer(&gpu_timer); gpu_timer.function = gputimer_callback; gpu_timer.expires = jiffies + 15*HZ; add_timer(&gpu_timer); +#elif(2==gcdENABLE_AUTO_FREQ) + init_timer(&gpu_timer); + gpu_timer.function = gputimer_callback; + gpu_timer.expires = jiffies + 3*HZ; + add_timer(&gpu_timer); #endif +// dkm: CONFIG_HAS_EARLYSUSPEND #if CONFIG_HAS_EARLYSUSPEND #if (2!=gcdENABLE_DELAY_EARLY_SUSPEND) register_early_suspend(&gpu_early_suspend_info); #endif #endif +// dkm: gcdENABLE_DELAY_EARLY_SUSPEND #if (1==gcdENABLE_DELAY_EARLY_SUSPEND) INIT_DELAYED_WORK(&suspend_work, real_suspend); #endif @@ -1052,17 +1098,19 @@ static int __devinit gpu_probe(struct platform_device *pdev) return ret; } -gpu_probe_fail: +gpu_probe_fail: printk(KERN_INFO "Failed to register gpu driver.\n"); return ret; } static int __devinit gpu_remove(struct platform_device *pdev) { +// dkm: gcdENABLE_DELAY_EARLY_SUSPEND #if (1==gcdENABLE_DELAY_EARLY_SUSPEND) cancel_delayed_work_sync(&suspend_work); #endif drv_exit(); + return 0; } @@ -1071,16 +1119,16 @@ static int __devinit gpu_suspend(struct platform_device *dev, pm_message_t state gceSTATUS status; gckGALDEVICE device; +// dkm: gcdENABLE_DELAY_EARLY_SUSPEND #if (1==gcdENABLE_DELAY_EARLY_SUSPEND) cancel_delayed_work_sync(&suspend_work); #endif device = platform_get_drvdata(dev); - + status = gckHARDWARE_SetPowerManagementState(device->kernel->hardware, gcvPOWER_OFF); if (gcmIS_ERROR(status)) { - printk("%s fail!\n", __func__); return -1; } @@ -1093,18 +1141,25 @@ static int __devinit gpu_resume(struct platform_device *dev) gckGALDEVICE device; device = platform_get_drvdata(dev); - + status = gckHARDWARE_SetPowerManagementState(device->kernel->hardware, gcvPOWER_ON); if (gcmIS_ERROR(status)) { - printk("%s fail!\n", __func__); return -1; } - + + status = gckHARDWARE_SetPowerManagementState(device->kernel->hardware, gcvPOWER_IDLE_BROADCAST); + + if (gcmIS_ERROR(status)) + { + return -1; + } + return 0; } +// dkm: add static void __devinit gpu_shutdown(struct platform_device *dev) { #if (1==gcdENABLE_DELAY_EARLY_SUSPEND) @@ -1117,6 +1172,7 @@ static void __devinit gpu_shutdown(struct platform_device *dev) static struct platform_driver gpu_driver = { .probe = gpu_probe, .remove = gpu_remove, + // dkm add .shutdown = gpu_shutdown, .suspend = gpu_suspend, .resume = gpu_resume, @@ -1126,7 +1182,7 @@ static struct platform_driver gpu_driver = { } }; -#if 0 +#if 0 // by dkm #ifndef CONFIG_DOVE_GPU static struct resource gpu_resources[] = { { @@ -1190,6 +1246,7 @@ static int __init gpu_init(void) ret = platform_driver_register(&gpu_driver); if (!ret) { +// add by vv #if gcdkREPORT_VIDMEM_USAGE gckDeviceProc_Register(); #endif @@ -1220,6 +1277,7 @@ static void __exit gpu_exit(void) #endif #endif +// add by vv #if gcdkREPORT_VIDMEM_USAGE gckDeviceProc_UnRegister(); #endif diff --git a/drivers/staging/rk29/vivante/hal/os/linux/kernel/gc_hal_kernel_linux.c b/drivers/staging/rk29/vivante/hal/os/linux/kernel/gc_hal_kernel_linux.c index 36546c9ae899..d497ceee7d97 100644 --- a/drivers/staging/rk29/vivante/hal/os/linux/kernel/gc_hal_kernel_linux.c +++ b/drivers/staging/rk29/vivante/hal/os/linux/kernel/gc_hal_kernel_linux.c @@ -1,21 +1,21 @@ /**************************************************************************** -* -* Copyright (C) 2005 - 2010 by Vivante Corp. -* +* +* Copyright (C) 2005 - 2011 by Vivante Corp. +* * 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., 675 Mass Ave, Cambridge, MA 02139, USA. -* +* *****************************************************************************/ @@ -53,7 +53,7 @@ gckKERNEL_QueryVideoMemory( ) { gckGALDEVICE device; - + gcmkHEADER_ARG("Kernel=%p", Kernel); /* Verify the arguments. */ @@ -100,7 +100,7 @@ gckKERNEL_QueryVideoMemory( ** Pointer to a variable that will hold the pointer to the gckVIDMEM ** object belonging to the requested pool. */ -gceSTATUS +gceSTATUS gckKERNEL_GetVideoMemoryPool( IN gckKERNEL Kernel, IN gcePOOL Pool, @@ -109,7 +109,7 @@ gckKERNEL_GetVideoMemoryPool( { gckGALDEVICE device; gckVIDMEM videoMemory; - + gcmkHEADER_ARG("Kernel=%p Pool=%d", Kernel, Pool); /* Verify the arguments. */ @@ -173,7 +173,7 @@ gckKERNEL_GetVideoMemoryPool( ** Pointer to a variable that will hold the base address of the mapped ** memory region. */ -gceSTATUS +gceSTATUS gckKERNEL_MapMemory( IN gckKERNEL Kernel, IN gctPHYS_ADDR Physical, @@ -208,7 +208,7 @@ gckKERNEL_MapMemory( ** ** Nothing. */ -gceSTATUS +gceSTATUS gckKERNEL_UnmapMemory( IN gckKERNEL Kernel, IN gctPHYS_ADDR Physical, @@ -243,7 +243,7 @@ gckKERNEL_UnmapMemory( ** Pointer to a variable that will hold the logical address of the ** specified memory address. */ -gceSTATUS +gceSTATUS gckKERNEL_MapVideoMemory( IN gckKERNEL Kernel, IN gctBOOL InUserSpace, @@ -258,7 +258,7 @@ gckKERNEL_MapVideoMemory( gctUINT32 offset, base; gceSTATUS status; gctPOINTER logical; - + gcmkHEADER_ARG("Kernel=%p InUserSpace=%d Address=%08x", Kernel, InUserSpace, Address); @@ -305,7 +305,7 @@ gckKERNEL_MapVideoMemory( gcmkVERIFY_OK( gckHARDWARE_SplitMemory(Kernel->hardware, device->contiguousVidMem->baseAddress, - &pool, + &pool, &base)); offset -= base; @@ -322,7 +322,7 @@ gckKERNEL_MapVideoMemory( /* Success. */ gcmkFOOTER_ARG("*Logical=%p", *Logical); return gcvSTATUS_OK; - + OnError: /* Retunn the status. */ gcmkFOOTER(); @@ -347,7 +347,7 @@ OnError: ** ** Nothing. */ -gceSTATUS +gceSTATUS gckKERNEL_Notify( IN gckKERNEL Kernel, IN gceNOTIFY Notification, @@ -355,7 +355,7 @@ gckKERNEL_Notify( ) { gceSTATUS status; - + gcmkHEADER_ARG("Kernel=%p Notification=%d Data=%d", Kernel, Notification, Data); @@ -391,21 +391,20 @@ gckKERNEL_QuerySettings( ) { gckGALDEVICE device; - + gcmkHEADER_ARG("Kernel=%p", Kernel); - + /* Verify the arguments. */ gcmkVERIFY_OBJECT(Kernel, gcvOBJ_KERNEL); gcmkVERIFY_ARGUMENT(Settings != gcvNULL); - + /* Extract the pointer to the gckGALDEVICE class. */ device = (gckGALDEVICE) Kernel->context; - + /* Fill in signal. */ Settings->signal = device->signal; - + /* Success. */ gcmkFOOTER_ARG("Settings->signal=%d", Settings->signal); return gcvSTATUS_OK; } - diff --git a/drivers/staging/rk29/vivante/hal/os/linux/kernel/gc_hal_kernel_linux.h b/drivers/staging/rk29/vivante/hal/os/linux/kernel/gc_hal_kernel_linux.h old mode 100755 new mode 100644 index 3cc30d7728ee..5166b0a8edf3 --- a/drivers/staging/rk29/vivante/hal/os/linux/kernel/gc_hal_kernel_linux.h +++ b/drivers/staging/rk29/vivante/hal/os/linux/kernel/gc_hal_kernel_linux.h @@ -1,21 +1,21 @@ /**************************************************************************** -* -* Copyright (C) 2005 - 2010 by Vivante Corp. -* +* +* Copyright (C) 2005 - 2011 by Vivante Corp. +* * 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., 675 Mass Ave, Cambridge, MA 02139, USA. -* +* *****************************************************************************/ @@ -47,7 +47,7 @@ #if ENABLE_GPU_CLOCK_BY_DRIVER && LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28) #include -#endif +#endif #define NTSTRSAFE_NO_CCH_FUNCTIONS #include "gc_hal.h" @@ -57,6 +57,7 @@ #include "gc_hal_kernel_os.h" #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31) +// dkm: pid_task²»ÐУ¬µÃ¸ÄΪget_pid_task #define FIND_TASK_BY_PID(x) get_pid_task(find_vpid(x), PIDTYPE_PID) #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27) #define FIND_TASK_BY_PID(x) find_task_by_vpid(x) @@ -79,11 +80,10 @@ GetOrder( ) { gctINT order = 0; - + while ((1 << order) < numPages) order++; - + return order; } #endif /* __gc_hal_kernel_linux_h_ */ - diff --git a/drivers/staging/rk29/vivante/hal/os/linux/kernel/gc_hal_kernel_os.c b/drivers/staging/rk29/vivante/hal/os/linux/kernel/gc_hal_kernel_os.c index 7356af9dd642..1f0d9a40995e 100644 --- a/drivers/staging/rk29/vivante/hal/os/linux/kernel/gc_hal_kernel_os.c +++ b/drivers/staging/rk29/vivante/hal/os/linux/kernel/gc_hal_kernel_os.c @@ -1,21 +1,21 @@ /**************************************************************************** -* +* * Copyright (C) 2005 - 2011 by Vivante Corp. -* +* * 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., 675 Mass Ave, Cambridge, MA 02139, USA. -* +* *****************************************************************************/ @@ -34,7 +34,7 @@ #include #endif /* NO_DMA_COHERENT */ - +// dkm: add #include #include #include @@ -45,9 +45,11 @@ #define _GC_OBJ_ZONE gcvZONE_OS +// dkm: add #define PAGE_ALLOC_LIMIT 1 // ÏÞÖÆPageÉêÇë #define PAGE_ALLOC_LIMIT_SIZE 0 // ÏÞÖÆPageÉêÇëµÄ´óС,µ¥Î»ÎªM +// dkm: PAGE_ALLOC_LIMIT #if PAGE_ALLOC_LIMIT int g_pages_alloced = 0; #endif @@ -70,9 +72,11 @@ int g_pages_alloced = 0; #define MEMORY_MAP_UNLOCK(os) \ gcmkVERIFY_OK(gckOS_ReleaseMutex((os), (os)->memoryMapLock)) +// add by vv // 512MÄÚ´æµÄÇé¿öÏÂ,²âÊÔ¼¸¸öÓÎÏ·°ÑÄÚ´æºÄ¹â£¬ÆäÖµ¾Íµ½40£¬Òò´Ë100Ó¦¸ÃÊǹ»ÓÃµÄ #define gcdkUSE_NON_PAGED_MEMORY_CACHE 100 +// add by vv #if gcdkUSE_NON_PAGED_MEMORY_CACHE typedef struct _gcsNonPagedMemoryCache { @@ -144,6 +148,8 @@ struct _gckOS gctPOINTER lock; } signal; #endif + +// add by vv #if gcdkUSE_NON_PAGED_MEMORY_CACHE gctUINT cacheSize; gcsNonPagedMemoryCache * cacheHead; @@ -427,7 +433,7 @@ OnProcessExit( #endif } - +// dkm: add #if gcdkUSE_NON_PAGED_MEMORY_CACHE gceSTATUS gckOS_AllocateNonPagedMemoryFromSystem( @@ -447,7 +453,8 @@ gckOS_AllocateNonPagedMemoryFromSystem( #ifdef NO_DMA_COHERENT struct page * page; long size, order; - gctPOINTER vaddr; + gctPOINTER vaddr, reserved_vaddr; + gctUINT32 reserved_size; #endif /* Verify the arguments. */ @@ -496,7 +503,26 @@ gckOS_AllocateNonPagedMemoryFromSystem( return gcvSTATUS_OUT_OF_MEMORY; } - vaddr = (gctPOINTER)page_address(page); + /* + * On some system ioremap_nocache fails when + * given a size of more than 1 page if all + * of the pages haven't been marked as reserved + * first. Allocating a single page works without + * any changes though. + */ + vaddr = (gctPOINTER)page_address(page); + + reserved_vaddr = vaddr; + reserved_size = size; + + while (reserved_size > 0) + { + SetPageReserved(virt_to_page(reserved_vaddr)); + + reserved_vaddr += PAGE_SIZE; + reserved_size -= PAGE_SIZE; + } + // dkm: gcdENABLE_MEM_CACHE #if (1==gcdENABLE_MEM_CACHE) addr = ioremap_cached(virt_to_phys(vaddr), size); @@ -510,13 +536,6 @@ gckOS_AllocateNonPagedMemoryFromSystem( dma_cache_maint(vaddr, size, DMA_FROM_DEVICE); #endif - while (size > 0) - { - SetPageReserved(virt_to_page(vaddr)); - - vaddr += PAGE_SIZE; - size -= PAGE_SIZE; - } #endif if (addr == gcvNULL) @@ -634,8 +653,7 @@ gckOS_AllocateNonPagedMemoryFromSystem( // dkm: gcdENABLE_MEM_CACHE #if (2==gcdENABLE_MEM_CACHE) - //mdlMap->vma->vm_page_prot = pgprot_writecombine(mdlMap->vma->vm_page_prot); - mdlMap->vma->vm_page_prot = pgprot_noncached(mdlMap->vma->vm_page_prot); + mdlMap->vma->vm_page_prot = pgprot_writecombine(mdlMap->vma->vm_page_prot); #elif (1==gcdENABLE_MEM_CACHE) // NULL #else @@ -716,7 +734,6 @@ gckOS_AllocateNonPagedMemoryFromSystem( /* Success. */ return gcvSTATUS_OK; } - #endif /******************************************************************************* @@ -823,10 +840,12 @@ gckOS_Construct( os->signal.currentID = 0; #endif +// add by vv #if gcdkUSE_NON_PAGED_MEMORY_CACHE os->cacheSize = 0; os->cacheHead = gcvNULL; os->cacheTail = gcvNULL; + // dkm: add { int i = 0; gctPHYS_ADDR Physical; @@ -911,6 +930,7 @@ gckOS_Destroy( /* Verify the arguments. */ gcmkVERIFY_OBJECT(Os, gcvOBJ_OS); +// add by vv #if gcdkUSE_NON_PAGED_MEMORY_CACHE _FreeAllNonPagedMemoryCache(Os); #endif @@ -950,6 +970,14 @@ gckOS_Destroy( gcmkVERIFY_OK( gckHEAP_Destroy(heap)); } + else + { + gcmkTRACE_ZONE(gcvLEVEL_ERROR, + gcvZONE_OS, + "Failed to destroy signal, it was not unmampped \n" + ); + return gcvSTATUS_INVALID_ARGUMENT; + } /* Destroy the memory lock. */ gcmkVERIFY_OK( @@ -1022,7 +1050,7 @@ gckOS_Allocate( OnError: /* Return the status. */ - /* gcmkFOOTER(); */ + /*gcmkFOOTER();*/ return status; } @@ -1075,7 +1103,7 @@ gckOS_Free( OnError: /* Return the status. */ - /* gcmkFOOTER(); */ + /* gcmkFOOTER();*/ return status; } @@ -1379,6 +1407,7 @@ gckOS_MapMemory( } #else +// dkm: gcdENABLE_MEM_CACHE #if (2==gcdENABLE_MEM_CACHE) mdlMap->vma->vm_page_prot = pgprot_writecombine(mdlMap->vma->vm_page_prot); #elif (1==gcdENABLE_MEM_CACHE) @@ -1460,6 +1489,7 @@ gckOS_UnmapMemory( PLINUX_MDL_MAP mdlMap; PLINUX_MDL mdl = (PLINUX_MDL)Physical; struct task_struct * task; + // dkm: add struct mm_struct * mm; /* Verify the arguments. */ @@ -1499,6 +1529,7 @@ gckOS_UnmapMemory( /* Get the current pointer for the task with stored pid. */ task = FIND_TASK_BY_PID(mdlMap->pid); + // dkm: add if(task) { mm = get_task_mm(task); put_task_struct(task); @@ -1506,6 +1537,7 @@ gckOS_UnmapMemory( mm = gcvNULL; } + // dkm: modify if (mm) { down_write(&mm->mmap_sem); @@ -1530,6 +1562,7 @@ gckOS_UnmapMemory( return gcvSTATUS_OK; } +// add by vv #if gcdkUSE_NON_PAGED_MEMORY_CACHE static gctBOOL @@ -1788,7 +1821,8 @@ gckOS_AllocateNonPagedMemory( #ifdef NO_DMA_COHERENT struct page * page; long size, order; - gctPOINTER vaddr; + gctPOINTER vaddr, reserved_vaddr; + gctUINT32 reserved_size; #endif /* Verify the arguments. */ @@ -1821,6 +1855,7 @@ gckOS_AllocateNonPagedMemory( MEMORY_LOCK(Os); #ifndef NO_DMA_COHERENT +// add by vv #if gcdkUSE_NON_PAGED_MEMORY_CACHE addr = _GetNonPagedMemoryCache(Os, mdl->numPages * PAGE_SIZE, @@ -1842,6 +1877,7 @@ gckOS_AllocateNonPagedMemory( #else size = mdl->numPages * PAGE_SIZE; order = get_order(size); +// add by vv #if gcdkUSE_NON_PAGED_MEMORY_CACHE page = _GetNonPagedMemoryCache(Os, order); @@ -1860,7 +1896,26 @@ gckOS_AllocateNonPagedMemory( return gcvSTATUS_OUT_OF_MEMORY; } - vaddr = (gctPOINTER)page_address(page); + /* + * On some system ioremap_nocache fails when + * given a size of more than 1 page if all + * of the pages haven't been marked as reserved + * first. Allocating a single page works without + * any changes though. + */ + vaddr = (gctPOINTER)page_address(page); + + reserved_vaddr = vaddr; + reserved_size = size; + + while (reserved_size > 0) + { + SetPageReserved(virt_to_page(reserved_vaddr)); + + reserved_vaddr += PAGE_SIZE; + reserved_size -= PAGE_SIZE; + } + // dkm: gcdENABLE_MEM_CACHE #if (1==gcdENABLE_MEM_CACHE) addr = ioremap_cached(virt_to_phys(vaddr), size); @@ -1874,13 +1929,6 @@ gckOS_AllocateNonPagedMemory( dma_cache_maint(vaddr, size, DMA_FROM_DEVICE); #endif - while (size > 0) - { - SetPageReserved(virt_to_page(vaddr)); - - vaddr += PAGE_SIZE; - size -= PAGE_SIZE; - } #endif if (addr == gcvNULL) @@ -1998,8 +2046,7 @@ gckOS_AllocateNonPagedMemory( // dkm: gcdENABLE_MEM_CACHE #if (2==gcdENABLE_MEM_CACHE) - //mdlMap->vma->vm_page_prot = pgprot_writecombine(mdlMap->vma->vm_page_prot); - mdlMap->vma->vm_page_prot = pgprot_noncached(mdlMap->vma->vm_page_prot); + mdlMap->vma->vm_page_prot = pgprot_writecombine(mdlMap->vma->vm_page_prot); #elif (1==gcdENABLE_MEM_CACHE) // NULL #else @@ -2115,6 +2162,7 @@ gceSTATUS gckOS_FreeNonPagedMemory( PLINUX_MDL mdl; PLINUX_MDL_MAP mdlMap; struct task_struct * task; + // dkm: add struct mm_struct * mm; #ifdef NO_DMA_COHERENT @@ -2138,6 +2186,7 @@ gceSTATUS gckOS_FreeNonPagedMemory( MEMORY_LOCK(Os); #ifndef NO_DMA_COHERENT +// add by vv #if gcdkUSE_NON_PAGED_MEMORY_CACHE if (!_AddNonPagedMemoryCache(Os, mdl->numPages * PAGE_SIZE, @@ -2167,6 +2216,7 @@ gceSTATUS gckOS_FreeNonPagedMemory( size -= PAGE_SIZE; } +// add by vv #if gcdkUSE_NON_PAGED_MEMORY_CACHE if (!_AddNonPagedMemoryCache(Os, get_order(mdl->numPages * PAGE_SIZE), @@ -2189,6 +2239,7 @@ gceSTATUS gckOS_FreeNonPagedMemory( { /* Get the current pointer for the task with stored pid. */ task = FIND_TASK_BY_PID(mdlMap->pid); + // dkm: add if(task) { mm = get_task_mm(task); put_task_struct(task); @@ -2196,6 +2247,7 @@ gceSTATUS gckOS_FreeNonPagedMemory( mm = gcvNULL; } + // dkm: modify if (mm) { down_write(&mm->mmap_sem); @@ -2822,7 +2874,7 @@ gckOS_AcquireMutex( return gcvSTATUS_OK; } - if (Timeout-- == 0) break; + if (Timeout-- == 0) break; /* Wait for 1 millisecond. */ gcmkVERIFY_OK(gckOS_Delay(Os, 1)); @@ -3197,7 +3249,7 @@ gckOS_Delay( /* Convert timeval to jiffies. */ jiffies = timeval_to_jiffies(&now); - /* Schedule timeout. */ + /* Schedule timeout. */ schedule_timeout_interruptible(jiffies); } @@ -3232,7 +3284,7 @@ gceSTATUS gckOS_MemoryBarrier( /* Verify thearguments. */ gcmkVERIFY_OBJECT(Os, gcvOBJ_OS); - //mb(); + // dkm: change to dsb from mb dsb(); /* Success. */ @@ -3320,6 +3372,7 @@ gceSTATUS gckOS_AllocatePagedMemoryEx( if (Contiguous) { +// dkm: PAGE_ALLOC_LIMIT #if PAGE_ALLOC_LIMIT if( (g_pages_alloced + numPages) > (256*PAGE_ALLOC_LIMIT_SIZE) ) { //printk("full %d! \n", g_pages_alloced); @@ -3488,6 +3541,7 @@ gceSTATUS gckOS_FreePagedMemory( if (mdl->contiguous) { free_pages((unsigned long)mdl->addr, GetOrder(mdl->numPages)); +// dkm: PAGE_ALLOC_LIMIT #if PAGE_ALLOC_LIMIT g_pages_alloced -= mdl->numPages; //printk("free %d / %d \n", mdl->numPages, g_pages_alloced); @@ -3654,6 +3708,8 @@ gceSTATUS gckOS_LockPages( mdlMap->vma->vm_flags |= VM_RESERVED; /* Make this mapping non-cached. */ + +// dkm: gcdENABLE_MEM_CACHE #if (2==gcdENABLE_MEM_CACHE) mdlMap->vma->vm_page_prot = pgprot_writecombine(mdlMap->vma->vm_page_prot); #elif (1==gcdENABLE_MEM_CACHE) @@ -3890,6 +3946,7 @@ gceSTATUS gckOS_UnlockPages( PLINUX_MDL_MAP mdlMap; PLINUX_MDL mdl = (PLINUX_MDL)Physical; struct task_struct * task; + // dkm: add struct mm_struct * mm; /* Verify the arguments. */ @@ -3914,6 +3971,7 @@ gceSTATUS gckOS_UnlockPages( { /* Get the current pointer for the task with stored pid. */ task = FIND_TASK_BY_PID(mdlMap->pid); + // dkm: add if(task) { mm = get_task_mm(task); put_task_struct(task); @@ -3921,6 +3979,7 @@ gceSTATUS gckOS_UnlockPages( mm = gcvNULL; } + // dkm: modify if (mm) { down_write(&mm->mmap_sem); @@ -4521,6 +4580,7 @@ gckOS_UserSignal( /* Success. */ status = gcvSTATUS_OK; } + // dkm: add put_task_struct(task); } else @@ -4743,6 +4803,63 @@ gckOS_WaitSignal( return status; } +/******************************************************************************* +** +** gckOS_WaitSignalUninterruptible +** +** Wait for a signal to become signaled uninterruptibly. +** +** INPUT: +** +** gckOS Os +** Pointer to an gckOS 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 +gckOS_WaitSignalUninterruptible( + IN gckOS Os, + IN gctSIGNAL Signal, + IN gctUINT32 Wait + ) +{ + gceSTATUS status; + gcsSIGNAL_PTR signal; + gctUINT timeout; + gctUINT rc; + + gcmkHEADER_ARG("Os=0x%x Signal=0x%x Wait=%u", Os, Signal, Wait); + + /* Verify the arguments. */ + gcmkVERIFY_OBJECT(Os, gcvOBJ_OS); + gcmkVERIFY_ARGUMENT(Signal != gcvNULL); + + signal = (gcsSIGNAL_PTR) Signal; + + /* Convert wait to milliseconds. */ + timeout = (Wait == gcvINFINITE) ? MAX_SCHEDULE_TIMEOUT : Wait*HZ/1000; + + /* Linux bug ? */ + if (!signal->manualReset && timeout == 0) timeout = 1; + + rc = wait_for_completion_timeout(&signal->event, timeout); + status = ((rc == 0) && !signal->event.done) ? gcvSTATUS_TIMEOUT + : gcvSTATUS_OK; + + /* Return status. */ + gcmkFOOTER(); + return status; +} + /******************************************************************************* ** ** gckOS_MapSignal @@ -5370,7 +5487,7 @@ gckOS_DestroyAllUserSignals( if (Os->signal.table[signal] != gcvNULL && ((gcsSIGNAL_PTR)Os->signal.table[signal])->process == (gctHANDLE) current->tgid) { - gckOS_Signal(Os, Os->signal.table[signal], gcvTRUE); + gckOS_Signal(Os, Os->signal.table[signal], gcvTRUE); gckOS_DestroySignal(Os, Os->signal.table[signal]); @@ -5987,7 +6104,7 @@ gckOS_ZeroMemory( MEMORY_RECORD_PTR CreateMemoryRecord( gckOS Os, - gcsHAL_PRIVATE_DATA_PTR private, + gcsHAL_PRIVATE_DATA_PTR private, MEMORY_RECORD_PTR List, gceMEMORY_TYPE Type, gctSIZE_T Bytes, @@ -6124,11 +6241,12 @@ CreateVideoMemoryRecord( void DestroyVideoMemoryRecord( gckOS Os, - gcsHAL_PRIVATE_DATA_PTR private, + gcsHAL_PRIVATE_DATA_PTR private, MEMORY_RECORD_PTR Mr ) { - gcmkASSERT(Mr->type == gcvVIDEO_MEMORY); + gcmkASSERT(Mr->type == gcvVIDEO_MEMORY); + MEMORY_LOCK(Os); #if gcdkREPORT_VIDMEM_USAGE @@ -6178,15 +6296,33 @@ FindVideoMemoryRecord( void FreeAllMemoryRecord( gckOS Os, - gcsHAL_PRIVATE_DATA_PTR private, + gcsHAL_PRIVATE_DATA_PTR private, MEMORY_RECORD_PTR List ) { MEMORY_RECORD_PTR mr; gctUINT i = 0; - MEMORY_LOCK(Os); +#if gcdkREPORT_VIDMEM_USAGE + gctUINT type; + printk("------------------------------------\n"); + printk(" Type Current Max\n"); + + for (type = 0; type < gcvSURF_NUM_TYPES; type++) + { + printk("[%8s] %8llu KB %8llu KB\n", + _MemTypes[type], + private->allocatedMem[type] / 1024, + private->maxAllocatedMem[type] / 1024); + } + + printk("[ TOTAL] %8llu KB %8llu KB\n", + private->totalAllocatedMem / 1024, + private->maxTotalAllocatedMem / 1024); +#endif + + MEMORY_LOCK(Os); while (List->next != List) { @@ -6256,7 +6392,6 @@ FreeAllMemoryRecord( break; } - kfree(mr); MEMORY_LOCK(Os); @@ -6303,6 +6438,7 @@ gckOS_CacheFlush( IN gctSIZE_T Bytes ) { +// dkm: gcdENABLE_MEM_CACHE #if (1==gcdENABLE_MEM_CACHE) dmac_clean_range(Logical, Logical+Bytes); #elif (2==gcdENABLE_MEM_CACHE) @@ -6341,6 +6477,7 @@ gckOS_CacheInvalidate( IN gctSIZE_T Bytes ) { +// dkm: gcdENABLE_MEM_CACHE #if (1==gcdENABLE_MEM_CACHE) dmac_flush_range(Logical, Logical+Bytes); #elif (2==gcdENABLE_MEM_CACHE) @@ -6445,9 +6582,9 @@ gckOS_Broadcast( break; case gcvBROADCAST_GPU_STUCK: - gcmkONERROR(gckHARDWARE_GetIdle(Hardware, gcvFALSE, &idle)); + gcmkONERROR(gckHARDWARE_GetIdle(Hardware, gcvFALSE, &idle)); gcmkONERROR(gckOS_ReadRegister(Os, 0x00C, &axi)); - gcmkONERROR(gckOS_ReadRegister(Os, 0x664, &dma)); + gcmkONERROR(gckOS_ReadRegister(Os, 0x664, &dma)); gcmkPRINT("!!FATAL!! GPU Stuck"); gcmkPRINT(" idle=0x%08X axi=0x%08X cmd=0x%08X", idle, axi, dma); @@ -6474,7 +6611,7 @@ gckOS_Broadcast( { gcmkONERROR(gckOS_WriteRegister(Os, 0x470, i << 16)); gcmkPRINT("%d: Write 0x%08X to DebugControl0(0x470)", i, i << 16); - + gcmkONERROR(gckOS_ReadRegister(Os, 0x454, &debugSignalsPe)); gcmkPRINT("%d: debugSignalsPe(0x454)=0x%08X", i, debugSignalsPe); @@ -6485,7 +6622,7 @@ gckOS_Broadcast( { gcmkONERROR(gckOS_WriteRegister(Os, 0x478, i)); gcmkPRINT("%d: Write 0x%08X to DebugControl2(0x478)", i, i); - + gcmkONERROR(gckOS_ReadRegister(Os, 0x468, &debugSignalsMc)); gcmkPRINT("%d: debugSignalsMc(0x468)=0x%08X", i, debugSignalsMc); @@ -6807,6 +6944,7 @@ gckOS_GetThreadID( ** ** Nothing. */ +// dkm: modify gceSTATUS gckOS_SetGPUPower( IN gckOS Os, diff --git a/drivers/staging/rk29/vivante/hal/os/linux/kernel/gc_hal_kernel_os.h b/drivers/staging/rk29/vivante/hal/os/linux/kernel/gc_hal_kernel_os.h index 5428259de8d1..aef1b69600f2 100644 --- a/drivers/staging/rk29/vivante/hal/os/linux/kernel/gc_hal_kernel_os.h +++ b/drivers/staging/rk29/vivante/hal/os/linux/kernel/gc_hal_kernel_os.h @@ -1,21 +1,21 @@ /**************************************************************************** -* +* * Copyright (C) 2005 - 2011 by Vivante Corp. -* +* * 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., 675 Mass Ave, Cambridge, MA 02139, USA. -* +* *****************************************************************************/ @@ -72,11 +72,11 @@ gceSTATUS gckOS_DestroyAllUserSignals( IN gckOS Os ); - + #ifdef gcdkUSE_MEMORY_RECORD MEMORY_RECORD_PTR CreateMemoryRecord( -gckOS Os, + gckOS Os, gcsHAL_PRIVATE_DATA_PTR private, MEMORY_RECORD_PTR List, gceMEMORY_TYPE Type, @@ -106,7 +106,7 @@ FindMemoryRecord( MEMORY_RECORD_PTR CreateVideoMemoryRecord( gckOS Os, - gcsHAL_PRIVATE_DATA_PTR private, + gcsHAL_PRIVATE_DATA_PTR private, MEMORY_RECORD_PTR List, gcuVIDMEM_NODE_PTR Node, gceSURF_TYPE Type, @@ -116,25 +116,24 @@ CreateVideoMemoryRecord( void DestroyVideoMemoryRecord( gckOS Os, - gcsHAL_PRIVATE_DATA_PTR private, + gcsHAL_PRIVATE_DATA_PTR private, MEMORY_RECORD_PTR Mr ); - + MEMORY_RECORD_PTR FindVideoMemoryRecord( gckOS Os, - gcsHAL_PRIVATE_DATA_PTR private, + gcsHAL_PRIVATE_DATA_PTR private, MEMORY_RECORD_PTR List, gcuVIDMEM_NODE_PTR Node ); - -void + +void FreeAllMemoryRecord( gckOS Os, - gcsHAL_PRIVATE_DATA_PTR private, + gcsHAL_PRIVATE_DATA_PTR private, MEMORY_RECORD_PTR List ); #endif - + #endif /* __gc_hal_kernel_os_h_ */ - diff --git a/drivers/staging/rk29/vivante/hal/os/qnx/inc/gc_hal_common_qnx.h b/drivers/staging/rk29/vivante/hal/os/qnx/inc/gc_hal_common_qnx.h deleted file mode 100644 index 0f514b2f0de4..000000000000 --- a/drivers/staging/rk29/vivante/hal/os/qnx/inc/gc_hal_common_qnx.h +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -* -* Copyright (c) 2005 - 2010 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. -* -***************************************************************************** -* -* Auto-generated file on 12/8/2010. Do not edit!!! -* -*****************************************************************************/ - - -/* - * gc_hal_common_qnx.h - * - * Created on: Jul 7, 2010 - * Author: tarang - */ - -#ifndef GC_HAL_COMMON_QNX_H_ -#define GC_HAL_COMMON_QNX_H_ - -/******************************************************************************\ -******************************* QNX Control Codes ****************************** -\******************************************************************************/ -#ifndef _IOMGR_VIVANTE -#define _IOMGR_VIVANTE (_IOMGR_PRIVATE_BASE + 0x301) -#endif - -/******************************************************************************* -** Signal management. -** -** Is much simpler in Neutrino versus Linux :-) -** -** Neutrino pulses are equivalent to RT signals (queued, small payload) except -** they are explicitly received on a channel. We therefore dedicate a thread -** to handle them. -** -** We don't use RT signals because: -** 1. They can be delivered on any thread. -** 2. We don't support SA_RESTART so blocking kernel calls can fail. It would be -** impossible to robustly handle this condition in all libraries. -** -** Only downside is that more information needs to be passed between client/server -** (signals require only PID, pulses require connection ID and receive ID). -*/ - -typedef struct _gcsSIGNAL -{ - /* Pointer to gcoOS object. */ - gcoOS os; - - /* Signaled state. */ - gctBOOL state; - - /* Manual reset flag. */ - gctBOOL manual; - - /* Mutex. */ - pthread_mutex_t mutex; - - /* Condition. */ - pthread_cond_t condition; - - /* Number of signals pending in the command queue. */ - gctINT pending; - - /* Number of signals received. */ - gctINT received; -} -gcsSIGNAL; - -#endif /* GC_HAL_COMMON_QNX_H_ */ - diff --git a/drivers/staging/rk29/vivante/hal/os/qnx/kernel/gc_hal_kernel_debug.c b/drivers/staging/rk29/vivante/hal/os/qnx/kernel/gc_hal_kernel_debug.c deleted file mode 100644 index c382c1299341..000000000000 --- a/drivers/staging/rk29/vivante/hal/os/qnx/kernel/gc_hal_kernel_debug.c +++ /dev/null @@ -1,435 +0,0 @@ -/**************************************************************************** -* -* Copyright (c) 2005 - 2010 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. -* -***************************************************************************** -* -* Auto-generated file on 12/8/2010. Do not edit!!! -* -*****************************************************************************/ - - - - -#include "gc_hal_kernel_qnx.h" -#include - -/* - 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. -*/ -#define gcdBUFFERED_OUTPUT 0 - -/******************************************************************************\ -******************************** Debug Variables ******************************* -\******************************************************************************/ - -static gceSTATUS _lastError = gcvSTATUS_OK; -static gctUINT32 _debugLevel = gcvLEVEL_ERROR; -static gctUINT32 _debugZones = gcvZONE_NONE; -static gctINT _indent = 0; - -static void -OutputDebugString( - IN gctCONST_STRING String - ) -{ -#if gcdBUFFERED_OUTPUT - static gctCHAR outputBuffer[gcdBUFFERED_OUTPUT]; - static gctINT outputBufferIndex = 0; - gctINT n, i; - - n = (String != gcvNULL) ? strlen(String) + 1 : 0; - - if ((n == 0) || (outputBufferIndex + n > gcmSIZEOF(outputBuffer))) - { - for (i = 0; i < outputBufferIndex; i += strlen(outputBuffer + i) + 1) - { - printf(outputBuffer + i); - } - - outputBufferIndex = 0; - } - - if (n > 0) - { - memcpy(outputBuffer + outputBufferIndex, String, n); - outputBufferIndex += n; - } -#else - if (String != gcvNULL) - { - printf(String); - } -#endif -} - -static void -_Print( - IN gctCONST_STRING Message, - IN va_list Arguments - ) -{ - char buffer[1024]; - int i, n; - - if (strcmp(Message, "$$FLUSH$$") == 0) - { - OutputDebugString(gcvNULL); - return; - } - - if (strncmp(Message, "--", 2) == 0) - { - if (_indent == 0) - { - printf("ERROR: _indent=0\n"); - } - - _indent -= 2; - } - - for (i = 0; i < _indent; ++i) - { - buffer[i] = ' '; - } - - /* Print message to buffer. */ - n = vsnprintf(buffer + i, sizeof(buffer) - i, Message, Arguments); - if ((n <= 0) || (buffer[i + n - 1] != '\n')) - { - /* Append new-line. */ - strncat(buffer, "\n", sizeof(buffer)); - } - - /* Output to debugger. */ - OutputDebugString(buffer); - - if (strncmp(Message, "++", 2) == 0) - { - _indent += 2; - } -} - -/******************************************************************************\ -********************************* Debug Macros ********************************* -\******************************************************************************/ - -#define _DEBUGPRINT(Message) \ -{ \ - va_list arguments; \ - \ - va_start(arguments, Message); \ - _Print(Message, arguments); \ - va_end(arguments); \ -} - -/******************************************************************************\ -********************************** Debug Code ********************************** -\******************************************************************************/ - -/******************************************************************************* -** -** gckOS_Print -** -** Send a message to the debugger. -** -** INPUT: -** -** gctCONST_STRING Message -** Pointer to message. -** -** ... -** Optional arguments. -** -** OUTPUT: -** -** Nothing. -*/ - -void -gckOS_Print( - IN gctCONST_STRING Message, - ... - ) -{ - _DEBUGPRINT(Message); -} - -/******************************************************************************* -** -** gckOS_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 -gckOS_DebugTrace( - IN gctUINT32 Level, - IN gctCONST_STRING Message, - ... - ) -{ - if (Level > _debugLevel) - { - return; - } - - _DEBUGPRINT(Message); -} - -/******************************************************************************* -** -** gckOS_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 -gckOS_DebugTraceZone( - IN gctUINT32 Level, - IN gctUINT32 Zone, - IN gctCONST_STRING Message, - ... - ) -{ - if ((Level > _debugLevel) || !(Zone & _debugZones)) - { - return; - } - - _DEBUGPRINT(Message); -} - -/******************************************************************************* -** -** gckOS_DebugBreak -** -** Break into the debugger. -** -** INPUT: -** -** Nothing. -** -** OUTPUT: -** -** Nothing. -*/ -void -gckOS_DebugBreak( - void - ) -{ - gckOS_DebugTrace(gcvLEVEL_ERROR, "gckOS_DebugBreak"); -} - -/******************************************************************************* -** -** gckOS_DebugFatal -** -** Send a message to the debugger and break into the debugger. -** -** INPUT: -** -** gctCONST_STRING Message -** Pointer to message. -** -** ... -** Optional arguments. -** -** OUTPUT: -** -** Nothing. -*/ -void -gckOS_DebugFatal( - IN gctCONST_STRING Message, - ... - ) -{ - _DEBUGPRINT(Message); - - /* Break into the debugger. */ - gckOS_DebugBreak(); -} - -/******************************************************************************* -** -** gckOS_SetDebugLevel -** -** Set the debug level. -** -** INPUT: -** -** gctUINT32 Level -** New debug level. -** -** OUTPUT: -** -** Nothing. -*/ - -void -gckOS_SetDebugLevel( - IN gctUINT32 Level - ) -{ - _debugLevel = Level; -} - -/******************************************************************************* -** -** gckOS_SetDebugZone -** -** Set the debug zone. -** -** INPUT: -** -** gctUINT32 Zone -** New debug zone. -** -** OUTPUT: -** -** Nothing. -*/ -void -gckOS_SetDebugZone( - IN gctUINT32 Zone - ) -{ - _debugZones = Zone; -} - -/******************************************************************************* -** -** gckOS_SetDebugLevelZone -** -** Set the debug level and zone. -** -** INPUT: -** -** gctUINT32 Level -** New debug level. -** -** gctUINT32 Zone -** New debug zone. -** -** OUTPUT: -** -** Nothing. -*/ - -void -gckOS_SetDebugLevelZone( - IN gctUINT32 Level, - IN gctUINT32 Zone - ) -{ - _debugLevel = Level; - _debugZones = Zone; -} - -/******************************************************************************* -** -** gckOS_SetDebugZones -** -** Enable or disable debug zones. -** -** INPUT: -** -** gctUINT32 Zones -** Debug zones to enable or disable. -** -** gctBOOL Enable -** Set to gcvTRUE to enable the zones (or the Zones with the current -** zones) or gcvFALSE to disable the specified Zones. -** -** OUTPUT: -** -** Nothing. -*/ - -void -gckOS_SetDebugZones( - IN gctUINT32 Zones, - IN gctBOOL Enable - ) -{ - if (Enable) - { - /* Enable the zones. */ - _debugZones |= Zones; - } - else - { - /* Disable the zones. */ - _debugZones &= ~Zones; - } -} - -/******************************************************************************* -** -** gckOS_Verify -** -** Called to verify the result of a function call. -** -** INPUT: -** -** gceSTATUS Status -** Function call result. -** -** OUTPUT: -** -** Nothing. -*/ - -void -gckOS_Verify( - IN gceSTATUS Status - ) -{ - _lastError = Status; -} - diff --git a/drivers/staging/rk29/vivante/hal/os/qnx/kernel/gc_hal_kernel_device.c b/drivers/staging/rk29/vivante/hal/os/qnx/kernel/gc_hal_kernel_device.c deleted file mode 100644 index 80f0818cf56a..000000000000 --- a/drivers/staging/rk29/vivante/hal/os/qnx/kernel/gc_hal_kernel_device.c +++ /dev/null @@ -1,812 +0,0 @@ -/**************************************************************************** -* -* Copyright (c) 2005 - 2010 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. -* -***************************************************************************** -* -* Auto-generated file on 12/8/2010. Do not edit!!! -* -*****************************************************************************/ - - - - - -#include "gc_hal_kernel_qnx.h" -#include -#include - -#define _GC_OBJ_ZONE gcvZONE_DEVICE - -/******************************************************************************\ -******************************** gckGALDEVICE Code ******************************* -\******************************************************************************/ - -gceSTATUS -gckGALDEVICE_AllocateMemory( - IN gckGALDEVICE Device, - IN gctSIZE_T Bytes, - OUT gctPOINTER *Logical, - OUT gctPHYS_ADDR *Physical, - OUT gctUINT32 *PhysAddr - ) -{ - gceSTATUS status; - - gcmkVERIFY_ARGUMENT(Device != NULL); - gcmkVERIFY_ARGUMENT(Logical != NULL); - gcmkVERIFY_ARGUMENT(Physical != NULL); - gcmkVERIFY_ARGUMENT(PhysAddr != NULL); - - status = gckOS_AllocateContiguous(Device->os, - gcvFALSE, - &Bytes, - Physical, - Logical); - - if (gcmIS_ERROR(status)) - { - gcmkTRACE_ZONE(gcvLEVEL_ERROR, gcvZONE_DRIVER, - "gckGALDEVICE_AllocateMemory: error status->0x%x", - status); - - return status; - } - - *PhysAddr = (gctUINT32)(*(off_t*) Physical) - Device->baseAddress; - gcmkTRACE_ZONE(gcvLEVEL_INFO, gcvZONE_DRIVER, - "gckGALDEVICE_AllocateMemory: phys_addr->0x%x phsical->0x%x Logical->0x%x", - (gctUINT32)*Physical, - (gctUINT32)*PhysAddr, - (gctUINT32)*Logical); - - /* Success. */ - return gcvSTATUS_OK; -} - -gceSTATUS -gckGALDEVICE_FreeMemory( - IN gckGALDEVICE Device, - IN gctPOINTER Logical, - IN gctPHYS_ADDR Physical) -{ - gcmkVERIFY_ARGUMENT(Device != NULL); - - return gckOS_FreeContiguous(Device->os, - Physical, - Logical, - 0); -} - -/* TODO. fix global sigevent to be part of device. */ -struct sigevent irqEvent; - -const struct sigevent* isrRoutine(void* arg, int id) -{ - gckGALDEVICE device = (gckGALDEVICE)arg; - - /* Call kernel interrupt notification. */ - if (gckKERNEL_Notify(device->kernel, - gcvNOTIFY_INTERRUPT, - gcvTRUE) == gcvSTATUS_OK) - { - InterruptUnmask(device->irqLine, device->irqId); - - return &irqEvent; - } - - return gcvNULL; -} - -static void* threadRoutine(void *ctxt) -{ - gckGALDEVICE device = (gckGALDEVICE) ctxt; - - gcmkTRACE_ZONE(gcvLEVEL_INFO, gcvZONE_DRIVER, - "Starting ISR Thread with irq:%d\n", - device->irqLine); - - SIGEV_INTR_INIT(&irqEvent); - - /* Obtain I/O privileges */ - ThreadCtl( _NTO_TCTL_IO, 0 ); - - device->irqId = InterruptAttach(device->irqLine, - isrRoutine, - (void*)device, - gcmSIZEOF(struct _gckGALDEVICE), - 0); - - gcmkTRACE_ZONE(gcvLEVEL_INFO, - gcvZONE_DRIVER, - "irqId:%d\n", - device->irqId); - - if (device->irqId < 0) { - gcmkTRACE_ZONE(gcvLEVEL_INFO, - gcvZONE_DRIVER, - "[galcore] gckGALDEVICE_Setup_ISR: " - "Could not register irq line->%d\n", - device->irqLine); - - device->isrInitialized = gcvFALSE; - - return (void *)1; - } - - printf("[Interrupt] Attached irqLine %d with id %d.\n", - device->irqLine, device->irqId); - - device->isrInitialized = gcvTRUE; - - while (1) - { - if (InterruptWait(0, NULL) == -1) - { - printf("[Interrupt] IST exiting\n"); - /* Either something is wrong or the thread got canceled */ - InterruptUnmask(device->irqLine, device->irqId); - pthread_exit(NULL); - } - - gckKERNEL_Notify(device->kernel, gcvNOTIFY_INTERRUPT, gcvFALSE); - } - - return (void *)0; -} - -/******************************************************************************* -** -** gckGALDEVICE_Setup_ISR -** -** Start the ISR routine. -** -** INPUT: -** -** gckGALDEVICE Device -** Pointer to an gckGALDEVICE object. -** -** OUTPUT: -** -** Nothing. -** -** RETURNS: -** -** gcvSTATUS_OK -** Setup successfully. -** gcvSTATUS_GENERIC_IO -** Setup failed. -*/ -gceSTATUS -gckGALDEVICE_Setup_ISR( - IN gckGALDEVICE Device - ) -{ - return gcvSTATUS_OK; -} - -/******************************************************************************* -** -** gckGALDEVICE_Release_ISR -** -** Release the irq line. -** -** INPUT: -** -** gckGALDEVICE Device -** Pointer to an gckGALDEVICE object. -** -** OUTPUT: -** -** Nothing. -** -** RETURNS: -** -** Nothing. -*/ -gceSTATUS -gckGALDEVICE_Release_ISR( - IN gckGALDEVICE Device - ) -{ - gcmkVERIFY_ARGUMENT(Device != NULL); - - return gcvSTATUS_OK; -} - - -int -gsl_free_interrupts() -{ - - return 0; -} -/******************************************************************************* -** -** gckGALDEVICE_Start_Thread -** -** Start the daemon thread. -** -** INPUT: -** -** gckGALDEVICE Device -** Pointer to an gckGALDEVICE object. -** -** OUTPUT: -** -** Nothing. -** -** RETURNS: -** -** gcvSTATUS_OK -** Start successfully. -** gcvSTATUS_GENERIC_IO -** Start failed. -*/ -gceSTATUS -gckGALDEVICE_Start_Thread( - IN gckGALDEVICE Device - ) -{ - pthread_attr_t attr; - struct sched_param sched; - gctINT ret; - gcmkVERIFY_ARGUMENT(Device != NULL); - - gcmkTRACE_ZONE(gcvLEVEL_INFO, - gcvZONE_DRIVER, - "[galcore] gckGALDEVICE_Start_Thread: Creating threadRoutine\n"); - - pthread_attr_init(&attr); - pthread_attr_getschedparam(&attr, &sched); - sched.sched_priority += 10; - pthread_attr_setschedparam(&attr, &sched); - pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED); - - /* Start the interrupt service thread */ - if ((ret = pthread_create(&Device->threadCtxt, &attr, threadRoutine, Device)) != 0) - { - gcmkTRACE_ZONE(gcvLEVEL_ERROR, - gcvZONE_DRIVER, - "[galcore] gckGALDEVICE_Start_Thread: Failed with code %d\n", - ret); - - return gcvSTATUS_OUT_OF_RESOURCES; - } - - pthread_setname_np(Device->threadCtxt, "galcore-IST"); - - Device->threadInitialized = gcvTRUE; - gcmkTRACE_ZONE(gcvLEVEL_INFO, - gcvZONE_DRIVER, - "[galcore] gckGALDEVICE_Start_Thread: " - "Start the daemon thread.\n"); - - return gcvSTATUS_OK; -} - - -/******************************************************************************* -** -** gckGALDEVICE_Stop_Thread -** -** Stop the gal device, including the following actions: stop the daemon -** thread, release the irq. -** -** INPUT: -** -** gckGALDEVICE Device -** Pointer to an gckGALDEVICE object. -** -** OUTPUT: -** -** Nothing. -** -** RETURNS: -** -** Nothing. -*/ -gceSTATUS -gckGALDEVICE_Stop_Thread( - gckGALDEVICE Device - ) -{ - gcmkVERIFY_ARGUMENT(Device != NULL); - - /* stop the thread */ - if (Device->threadInitialized) - { - InterruptDetach(Device->irqId); - Device->irqId = 0; - ConnectDetach(Device->coid); - Device->coid = 0; - ChannelDestroy(Device->chid); - Device->chid = 0; - - pthread_cancel(Device->threadCtxt); - pthread_join(Device->threadCtxt, NULL); - Device->threadCtxt = 0; - - Device->threadInitialized = gcvFALSE; - Device->isrInitialized = gcvFALSE; - } - - return gcvSTATUS_OK; -} - -/******************************************************************************* -** -** gckGALDEVICE_Start -** -** Start the gal device, including the following actions: setup the isr routine -** and start the daemon thread. -** -** INPUT: -** -** gckGALDEVICE Device -** Pointer to an gckGALDEVICE object. -** -** OUTPUT: -** -** Nothing. -** -** RETURNS: -** -** gcvSTATUS_OK -** Start successfully. -*/ -gceSTATUS -gckGALDEVICE_Start( - IN gckGALDEVICE Device - ) -{ - gceSTATUS ret; - /* Start the daemon thread. */ - gcmkVERIFY_OK((ret = gckGALDEVICE_Start_Thread(Device))); - - return ret; -} - -/******************************************************************************* -** -** gckGALDEVICE_Stop -** -** Stop the gal device, including the following actions: stop the daemon -** thread, release the irq. -** -** INPUT: -** -** gckGALDEVICE Device -** Pointer to an gckGALDEVICE object. -** -** OUTPUT: -** -** Nothing. -** -** RETURNS: -** -** Nothing. -*/ -gceSTATUS -gckGALDEVICE_Stop( - gckGALDEVICE Device - ) -{ - gcmkVERIFY_ARGUMENT(Device != NULL); - - if (Device->threadInitialized) - { - gckGALDEVICE_Stop_Thread(Device); - } - - return gcvSTATUS_OK; -} - -/******************************************************************************* -** -** gckGALDEVICE_Construct -** -** Constructor. -** -** INPUT: -** -** OUTPUT: -** -** gckGALDEVICE * Device -** Pointer to a variable receiving the gckGALDEVICE object pointer on -** success. -*/ -gceSTATUS -gckGALDEVICE_Construct( - IN gctINT IrqLine, - IN gctUINT32 RegisterMemBase, - IN gctSIZE_T RegisterMemSize, - IN gctUINT32 ContiguousBase, - IN gctSIZE_T ContiguousSize, - IN gctSIZE_T BankSize, - IN gctINT FastClear, - IN gctINT Compression, - IN gctUINT32 BaseAddress, - OUT gckGALDEVICE *Device - ) -{ - gctUINT32 internalBaseAddress, internalAlignment; - gctUINT32 externalBaseAddress, externalAlignment; - gctUINT32 horizontalTileSize, verticalTileSize; - gctUINT32 physAddr; - gctUINT32 physical; - gckGALDEVICE device; - gceSTATUS status; - - gcmkTRACE(gcvLEVEL_VERBOSE, "[galcore] Enter gckGALDEVICE_Construct\n"); - - /* Allocate device structure. */ - device = calloc(1, sizeof(struct _gckGALDEVICE)); - if (!device) - { - gcmkTRACE_ZONE(gcvLEVEL_ERROR, gcvZONE_DRIVER, - "[galcore] gckGALDEVICE_Construct: Can't allocate memory.\n"); - - return gcvSTATUS_OUT_OF_MEMORY; - } - - physical = RegisterMemBase; - - /* Set up register memory region */ - if (physical != 0) - { - /* Request a region. */ - device->registerBase = (gctPOINTER)mmap_device_io(RegisterMemSize, RegisterMemBase); - - if ((uintptr_t)device->registerBase == MAP_DEVICE_FAILED) - { - gcmkTRACE_ZONE(gcvLEVEL_INFO, gcvZONE_DRIVER, - "[galcore] gckGALDEVICE_Construct: Unable to map location->0x%lX for size->%ld\n", - RegisterMemBase, - RegisterMemSize); - - return gcvSTATUS_OUT_OF_RESOURCES; - } - - physical += RegisterMemSize; - - gcmkTRACE_ZONE(gcvLEVEL_INFO, - gcvZONE_DRIVER, - "[galcore] gckGALDEVICE_Construct: " - "RegisterBase after mapping Address->0x%x is 0x%x\n", - (gctUINT32)RegisterMemBase, - (gctUINT32)device->registerBase); - } - - /* construct the gckOS object */ - device->baseAddress = BaseAddress; - gcmkONERROR( - gckOS_Construct(device, &device->os)); - - /* construct the gckKERNEL object. */ - gcmkONERROR( - gckKERNEL_Construct(device->os, device, &device->kernel)); - - gcmkONERROR( - gckHARDWARE_SetFastClear(device->kernel->hardware, - FastClear, - Compression)); - - /* query the ceiling of the system memory */ - gcmkONERROR( - gckHARDWARE_QuerySystemMemory(device->kernel->hardware, - &device->systemMemorySize, - &device->systemMemoryBaseAddress)); - - gcmkTRACE_ZONE(gcvLEVEL_INFO, - gcvZONE_DRIVER, - "[galcore] gckGALDEVICE_Construct: " - "Will be trying to allocate contiguous memory of 0x%x bytes\n", - (gctUINT32)device->systemMemoryBaseAddress); - -#if COMMAND_PROCESSOR_VERSION == 1 - /* start the command queue */ - gcmkVERIFY_OK(gckCOMMAND_Start(device->kernel->command)); -#endif - - /* initialize the thread daemon */ - memset(&device->isrLock, 0, sizeof(device->isrLock)); - - device->threadInitialized = gcvFALSE; - device->killThread = gcvFALSE; - - /* initialize the isr */ - device->isrInitialized = gcvFALSE; - device->dataReady = gcvFALSE; - device->irqLine = IrqLine; - - /* query the amount of video memory */ - gcmkVERIFY_OK(gckHARDWARE_QueryMemory(device->kernel->hardware, - &device->internalSize, - &internalBaseAddress, - &internalAlignment, - &device->externalSize, - &externalBaseAddress, - &externalAlignment, - &horizontalTileSize, - &verticalTileSize)); - - /* set up the internal memory region */ - if (device->internalSize > 0) - { - gceSTATUS status = gckVIDMEM_Construct(device->os, - internalBaseAddress, - device->internalSize, - internalAlignment, - 0, - &device->internalVidMem); - - if (gcmIS_ERROR(status)) - { - /* error, remove internal heap */ - device->internalSize = 0; - } - else - { - /* map internal memory */ - device->internalPhysical = (gctPHYS_ADDR)physical; - device->internalLogical = (gctPOINTER)mmap_device_io(device->internalSize, physical); - - gcmkASSERT(device->internalLogical != NULL); - - physical += device->internalSize; - } - } - - if (device->externalSize > 0) - { - /* create the external memory heap */ - gceSTATUS status = gckVIDMEM_Construct(device->os, - externalBaseAddress, - device->externalSize, - externalAlignment, - 0, - &device->externalVidMem); - - if (gcmIS_ERROR(status)) - { - /* error, remove internal heap */ - device->externalSize = 0; - } - else - { - /* map internal memory */ - device->externalPhysical = (gctPHYS_ADDR)physical; - device->externalLogical = (gctPOINTER)mmap_device_io(device->externalSize, physical); - - gcmkASSERT(device->externalLogical != NULL); - - physical += device->externalSize; - } - } - - /* set up the contiguous memory */ - device->contiguousSize = ContiguousSize; - - if (ContiguousBase == 0) - { - status = gcvSTATUS_OUT_OF_MEMORY; - - while (device->contiguousSize > 0) - { - gcmkTRACE_ZONE( - gcvLEVEL_INFO, gcvZONE_DRIVER, - "[galcore] gckGALDEVICE_Construct: Will be trying to allocate contiguous memory of %ld bytes\n", - device->contiguousSize - ); - - /* allocate contiguous memory */ - status = gckGALDEVICE_AllocateMemory( - device, - device->contiguousSize, - &device->contiguousBase, - &device->contiguousPhysical, - &physAddr - ); - - if (gcmIS_SUCCESS(status)) - { - gcmkTRACE_ZONE( - gcvLEVEL_INFO, gcvZONE_DRIVER, - "[galcore] gckGALDEVICE_Construct: Contiguous allocated size->0x%08X Virt->0x%08lX physAddr->0x%08X\n", - device->contiguousSize, - device->contiguousBase, - physAddr - ); - - status = gckVIDMEM_Construct( - device->os, - physAddr | device->systemMemoryBaseAddress, - device->contiguousSize, - 64, - BankSize, - &device->contiguousVidMem - ); - - if (gcmIS_SUCCESS(status)) - { - device->contiguousMapped = gcvFALSE; - - /* success, abort loop */ - gcmkTRACE_ZONE( - gcvLEVEL_INFO, gcvZONE_DRIVER, - "Using %u bytes of contiguous memory.\n", - device->contiguousSize - ); - - break; - } - - gcmkVERIFY_OK(gckGALDEVICE_FreeMemory( - device, - device->contiguousBase, - device->contiguousPhysical - )); - - device->contiguousBase = NULL; - } - - device->contiguousSize -= (4 << 20); - } - } - else - { - /* Create the contiguous memory heap. */ - status = gckVIDMEM_Construct( - device->os, - (ContiguousBase - device->baseAddress) | device->systemMemoryBaseAddress, - ContiguousSize, - 64, - BankSize, - &device->contiguousVidMem - ); - - if (gcmIS_ERROR(status)) - { - /* Error, roll back. */ - device->contiguousVidMem = gcvNULL; - device->contiguousSize = 0; - } - else - { - /* Map the contiguous memory. */ - device->contiguousPhysical = (gctPHYS_ADDR) ContiguousBase; - device->contiguousSize = ContiguousSize; - device->contiguousBase = (gctPOINTER) mmap_device_io(ContiguousSize, ContiguousBase); - device->contiguousMapped = gcvTRUE; - - if (device->contiguousBase == gcvNULL) - { - /* Error, roll back. */ - gcmkVERIFY_OK(gckVIDMEM_Destroy(device->contiguousVidMem)); - device->contiguousVidMem = gcvNULL; - device->contiguousSize = 0; - - status = gcvSTATUS_OUT_OF_RESOURCES; - } - } - } - - *Device = device; - - gcmkTRACE_ZONE(gcvLEVEL_INFO, gcvZONE_DRIVER, - "[galcore] gckGALDEVICE_Construct: Initialized device->0x%x contiguous->%lu @ 0x%x (0x%08X)\n", - device, - device->contiguousSize, - device->contiguousBase, - device->contiguousPhysical); - - return gcvSTATUS_OK; -OnError: - /* Roll back. */ - - /* Destroy the gckKERNEL object. */ - if ( Device != gcvNULL) - { - gcmkVERIFY_OK(gckGALDEVICE_Destroy(*Device)); - } - - /* Return the status. */ - return status; -} - -/******************************************************************************* -** -** gckGALDEVICE_Destroy -** -** Class destructor. -** -** INPUT: -** -** Nothing. -** -** OUTPUT: -** -** Nothing. -** -** RETURNS: -** -** Nothing. -*/ -gceSTATUS -gckGALDEVICE_Destroy( - gckGALDEVICE Device) -{ - gcmkVERIFY_ARGUMENT(Device != NULL); - - gcmkTRACE(gcvLEVEL_VERBOSE, "[ENTER] gckGALDEVICE_Destroy\n"); - - /* Destroy the gckKERNEL object. */ - gcmkVERIFY_OK(gckKERNEL_Destroy(Device->kernel)); - - if (Device->internalVidMem != gcvNULL) - { - /* destroy the internal heap */ - gcmkVERIFY_OK(gckVIDMEM_Destroy(Device->internalVidMem)); - - /* unmap the internal memory */ - munmap_device_io((uintptr_t)Device->internalLogical, Device->internalSize); - } - - if (Device->externalVidMem != gcvNULL) - { - /* destroy the internal heap */ - gcmkVERIFY_OK(gckVIDMEM_Destroy(Device->externalVidMem)); - - /* unmap the external memory */ - munmap_device_io((uintptr_t)Device->externalLogical, Device->externalSize); - } - - if (Device->contiguousVidMem != gcvNULL) - { - /* Destroy the contiguous heap */ - gcmkVERIFY_OK(gckVIDMEM_Destroy(Device->contiguousVidMem)); - - if (Device->contiguousMapped) - { - gcmkTRACE_ZONE(gcvLEVEL_INFO, gcvZONE_DRIVER, - "[galcore] gckGALDEVICE_Destroy: " - "Unmapping contiguous memory->0x%08lX\n", - Device->contiguousBase); - - munmap_device_io((uintptr_t)Device->contiguousBase, Device->contiguousSize); - } - else - { - gcmkTRACE_ZONE(gcvLEVEL_INFO, gcvZONE_DRIVER, - "[galcore] gckGALDEVICE_Destroy: " - "Freeing contiguous memory->0x%08lX\n", - Device->contiguousBase); - - gcmkVERIFY_OK(gckGALDEVICE_FreeMemory(Device, - Device->contiguousBase, - Device->contiguousPhysical)); - } - } - - if (Device->registerBase) - { - munmap_device_io((uintptr_t)Device->registerBase, Device->registerSize); - } - - /* Destroy the gckOS object. */ - gcmkVERIFY_OK(gckOS_Destroy(Device->os)); - - free(Device); - - gcmkTRACE(gcvLEVEL_VERBOSE, "[galcore] Leave gckGALDEVICE_Destroy\n"); - - return gcvSTATUS_OK; -} - diff --git a/drivers/staging/rk29/vivante/hal/os/qnx/kernel/gc_hal_kernel_device.h b/drivers/staging/rk29/vivante/hal/os/qnx/kernel/gc_hal_kernel_device.h deleted file mode 100644 index bb5835f0dfea..000000000000 --- a/drivers/staging/rk29/vivante/hal/os/qnx/kernel/gc_hal_kernel_device.h +++ /dev/null @@ -1,123 +0,0 @@ -/**************************************************************************** -* -* Copyright (c) 2005 - 2010 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. -* -***************************************************************************** -* -* Auto-generated file on 12/8/2010. Do not edit!!! -* -*****************************************************************************/ - - - - -#ifndef __gc_hal_kernel_device_h_ -#define __gc_hal_kernel_device_h_ - -/******************************************************************************\ -******************************* gckGALDEVICE Structure ******************************* -\******************************************************************************/ - -#define GALCORE_INTERRUPT_PULSE 0x5D - -typedef struct _gckGALDEVICE -{ - /* Objects. */ - gckOS os; - gckKERNEL kernel; - - /* Attributes. */ - gctSIZE_T internalSize; - gctPHYS_ADDR internalPhysical; - gctPOINTER internalLogical; - gckVIDMEM internalVidMem; - gctSIZE_T externalSize; - gctPHYS_ADDR externalPhysical; - gctPOINTER externalLogical; - gckVIDMEM externalVidMem; - gckVIDMEM contiguousVidMem; - gctPOINTER contiguousBase; - gctPHYS_ADDR contiguousPhysical; - gctSIZE_T contiguousSize; - gctBOOL contiguousMapped; - gctPOINTER contiguousMappedUser; - gctSIZE_T systemMemorySize; - gctUINT32 systemMemoryBaseAddress; - gctPOINTER registerBase; - gctSIZE_T registerSize; - gctUINT32 baseAddress; - - /* IRQ management. */ - gctINT irqLine; - gctINT irqId; - gctBOOL isrInitialized; - gctBOOL dataReady; - intrspin_t isrLock; - struct sigevent event; - int chid; - int coid; - - /* Thread management. */ - pthread_t threadCtxt; - gctBOOL threadInitialized; - gctBOOL killThread; -} -* gckGALDEVICE; - -typedef struct _gcsHAL_PRIVATE_DATA -{ - gckGALDEVICE device; - gctPOINTER mappedMemory; - gctPOINTER contiguousLogical; -} -gcsHAL_PRIVATE_DATA, * gcsHAL_PRIVATE_DATA_PTR; - -gceSTATUS gckGALDEVICE_Setup_ISR( - IN gckGALDEVICE Device - ); - -gceSTATUS gckGALDEVICE_Release_ISR( - IN gckGALDEVICE Device - ); - -gceSTATUS gckGALDEVICE_Start_Thread( - IN gckGALDEVICE Device - ); - -gceSTATUS gckGALDEVICE_Stop_Thread( - gckGALDEVICE Device - ); - -gceSTATUS gckGALDEVICE_Start( - IN gckGALDEVICE Device - ); - -gceSTATUS gckGALDEVICE_Stop( - gckGALDEVICE Device - ); - -gceSTATUS gckGALDEVICE_Construct( - IN gctINT IrqLine, - IN gctUINT32 RegisterMemBase, - IN gctSIZE_T RegisterMemSize, - IN gctUINT32 ContiguousBase, - IN gctSIZE_T ContiguousSize, - IN gctSIZE_T BankSize, - IN gctINT FastClear, - IN gctINT Compression, - IN gctUINT32 BaseAddress, - OUT gckGALDEVICE *Device - ); - -gceSTATUS gckGALDEVICE_Destroy( - IN gckGALDEVICE Device - ); - -#endif /* __gc_hal_kernel_device_h_ */ - diff --git a/drivers/staging/rk29/vivante/hal/os/qnx/kernel/gc_hal_kernel_driver.c b/drivers/staging/rk29/vivante/hal/os/qnx/kernel/gc_hal_kernel_driver.c deleted file mode 100644 index f3bb021eb528..000000000000 --- a/drivers/staging/rk29/vivante/hal/os/qnx/kernel/gc_hal_kernel_driver.c +++ /dev/null @@ -1,1367 +0,0 @@ -/**************************************************************************** -* -* Copyright (c) 2005 - 2010 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. -* -***************************************************************************** -* -* Auto-generated file on 12/8/2010. Do not edit!!! -* -*****************************************************************************/ - - - - -#include "gc_hal_kernel_qnx.h" -#include "gc_hal_driver.h" -#include "gc_hal_user_context.h" - -# include - -static gckGALDEVICE galDevice; - -/* GN TODO take these from the graphics.conf file. */ -#ifdef MMP2 -int irqLine = 8; -long registerMemBase = 0xd420d000; -#else -int irqLine = 48; -long registerMemBase = 0xf1840000; -#endif - -/* Configurable Memory sizes. */ -unsigned long contiguousSize = ( 64 << 20); /* Video memory pool. */ -unsigned int internalPoolSize = ( 16 << 20); /* Kernel local memory pool. */ -unsigned int sharedPoolSize = ( 8 << 20); /* Shared per-client memory pool initial size. */ -unsigned long registerMemSize = (256 << 10); /* GPU register memory size. */ - -/* ContiguousBase should be 0, - * for video memory to be allocated from the memory pool. */ -unsigned long contiguousBase = 0; -long bankSize = 0; -int fastClear = -1; -int compression = -1; -unsigned long baseAddress = 0; - -/* Global video memory pool. */ -typedef struct _gcsMEM_POOL -{ - gctINT32 freePage; - gctSIZE_T pageCount; - gctUINT32 pageSize; - gctUINT32 poolSize; - pthread_mutex_t mutex; - gctUINT32 addr; - gctUINT32 paddr; - gckPAGE_USAGE pageUsage; - gctCHAR fdName[64]; - gctINT fd; -} gcsMEM_POOL; - -gcsMEM_POOL memPool; - -/* Pointer to list of shared memory pools. */ -gckSHM_POOL shmPoolList; -pthread_mutex_t shmPoolListMutex; - -/* Resource Manager Globals. */ -struct _gcsRESMGR_GLOBALS -{ - dispatch_t *dpp; - dispatch_context_t *ctp; - int id; - thread_pool_attr_t pool_attr; - thread_pool_t *tpp; - pthread_t root; -} resmgr_globals; - -win_gpu_2_cm_iface_t *g_qnx_gpu_2_cm_iface = 0; -static resmgr_connect_funcs_t connect_funcs; -static resmgr_io_funcs_t io_funcs; -static iofunc_attr_t attr; - -gceSTATUS gckVIDMEM_FreeHandleMemory(IN gckVIDMEM Memory, IN gctHANDLE Handle); - -gceSTATUS -drv_mempool_init() -{ - off64_t paddr; - void* addr; - size_t pcontig; - - /* Default 4KB page size. */ - memPool.pageSize = __PAGESIZE; - - /* Compute number of pages. */ - memPool.pageCount = (contiguousSize + internalPoolSize) / memPool.pageSize; - gcmkASSERT(memPool.pageCount <= 65536); - - /* Align memPoolSize to page size. */ - memPool.poolSize = memPool.pageCount * memPool.pageSize; - - /* Allocate a single chunk of physical memory. - * Zero memory with MAP_ANON so we don't leak any sensitive information by chance. */ - snprintf(memPool.fdName, sizeof(memPool.fdName), "galcore:vidmem:%d", getpid()); - memPool.fd = shm_open(memPool.fdName, O_RDWR|O_CREAT, 0777); - if (memPool.fd == -1) { - fprintf(stderr, "galcore:%s[%d]: shm_open failed\n", __FUNCTION__, __LINE__); - return gcvSTATUS_GENERIC_IO; - } - - shm_unlink(memPool.fdName); - - if (shm_ctl_special(memPool.fd, SHMCTL_ANON|SHMCTL_PHYS, 0, memPool.poolSize, 0x9) == -1) { - fprintf(stderr, "galcore:%s[%d]: shm_ctl_special failed\n", __FUNCTION__, __LINE__); - close(memPool.fd); - memPool.fd = -1; - return gcvSTATUS_GENERIC_IO; - } - - addr = mmap64(0, memPool.poolSize, PROT_READ|PROT_WRITE, MAP_SHARED, memPool.fd, 0); - if (addr == MAP_FAILED) { - fprintf(stderr, "galcore:%s[%d]: mmap64 failed\n", __FUNCTION__, __LINE__); - close(memPool.fd); - memPool.fd = -1; - return gcvSTATUS_GENERIC_IO; - } - memPool.addr = (gctUINT32)addr; - - if (mem_offset64(addr, NOFD, memPool.poolSize, &paddr, &pcontig) == -1) - { - fprintf(stderr, "galcore:%s[%d]: mem_offset64 failed\n", __FUNCTION__, __LINE__); - munmap(addr, memPool.poolSize); - close(memPool.fd); - memPool.fd = -1; - memPool.addr = NULL; - return gcvSTATUS_GENERIC_IO; - } - - /* TODO. Truncating 64bit value. */ - memPool.paddr = (gctUINT32)paddr; - - printf( "Mempool Map addr range[%x-%x]\n", memPool.addr, memPool.addr + memPool.poolSize); - printf( "Mempool Map paddr range[%x-%x]\n", memPool.paddr, memPool.paddr + memPool.poolSize ); - - /* Allocate the page usage array and Initialize all pages to free. */ - memPool.pageUsage = (gckPAGE_USAGE)calloc( - memPool.pageCount, - sizeof(struct _gckPAGE_USAGE)); - - if (memPool.pageUsage == gcvNULL) - { - fprintf( stderr, "malloc failed: %s\n", strerror( errno ) ); - munmap(addr, memPool.poolSize); - close(memPool.fd); - memPool.fd = -1; - memPool.addr = NULL; - memPool.paddr = 0; - return gcvSTATUS_GENERIC_IO; - } - - /* The first page is free.*/ - memPool.freePage = 0; - - /* Initialize the semaphore. */ - if (pthread_mutex_init(&memPool.mutex, NULL) != EOK) - { - free(memPool.pageUsage); - munmap(addr, memPool.poolSize); - close(memPool.fd); - memPool.fd = -1; - memPool.addr = NULL; - memPool.paddr = 0; - return gcvSTATUS_GENERIC_IO; - } - - return gcvSTATUS_OK; -} - -void -drv_mempool_destroy() -{ - pthread_mutex_destroy(&memPool.mutex); - free(memPool.pageUsage); - memPool.pageUsage = NULL; - munmap((void*)memPool.addr, memPool.poolSize); - close(memPool.fd); - memPool.fd = -1; - memPool.addr = NULL; - memPool.paddr = 0; -} - -gctINT -drv_mempool_get_fileDescriptor() -{ - return memPool.fd; -} - -gctUINT32 -drv_mempool_get_basePAddress() -{ - return memPool.paddr; -} - -gctUINT32 -drv_mempool_get_baseAddress() -{ - return memPool.addr; -} - -gctUINT32 -drv_mempool_get_page_size() -{ - return memPool.pageSize; -} - -gceSTATUS -drv_mempool_mem_offset( - IN gctPOINTER Logical, - OUT gctUINT32 * Address) -{ - gctUINT32 logical = (gctUINT32)Logical; - - if ( Address == gcvNULL ) - return gcvSTATUS_INVALID_ARGUMENT; - - if ( logical < memPool.addr - || logical > (memPool.addr + memPool.poolSize)) - return gcvSTATUS_INVALID_ARGUMENT; - - *Address = (logical - memPool.addr) + memPool.paddr; - - return gcvSTATUS_OK; -} - -/* Allocate pages from mapped shared memory. - Return Physical and Logical addresses. -*/ -void -drv_mempool_alloc_contiguous( - IN gctUINT32 Bytes, - OUT gctPHYS_ADDR * Physical, - OUT gctPOINTER * Logical - ) -{ - gctSIZE_T i, j; - gctSIZE_T pageCount; - - pthread_mutex_lock(&memPool.mutex); - - /* Compute the number of required pages. */ - pageCount = gcmALIGN(Bytes, drv_mempool_get_page_size()) / drv_mempool_get_page_size(); - - if ( (pageCount <= 0) || (memPool.freePage < 0) ) - { - *Physical = gcvNULL; - *Logical = gcvNULL; - pthread_mutex_unlock(&memPool.mutex); - /* No free pages left. */ - return; - } - - /* Try finding enough contiguous free pages. */ - for (i = memPool.freePage; i < memPool.pageCount;) - { - /* All pages behind this free page should be free. */ - gctSIZE_T j; - for (j = 1; j < pageCount; ++j) - { - if (memPool.pageUsage[i + j].pageCount != 0) - { - /* Bail out if page is allocated. */ - break; - } - } - - if (j == pageCount) - { - /* We found a spot that has enough free pages. */ - break; - } - - /* Move to the page after the allocated page. */ - i += j + 1; - - /* Find the next free page. */ - while ((i < memPool.pageCount) && (memPool.pageUsage[i].pageCount != 0)) - { - ++i; - } - } - - if (i >= memPool.pageCount) - { - *Physical = gcvNULL; - *Logical = gcvNULL; - pthread_mutex_unlock(&memPool.mutex); - /* Not enough contiguous pages. */ - return; - } - - /* Check if we allocate from the first free page. */ - if (i == memPool.freePage) - { - /* Move first free page to beyond the contiguous request. */ - memPool.freePage = i + pageCount; - - /* Find first free page. */ - while ( (memPool.freePage < memPool.pageCount) && - (memPool.pageUsage[memPool.freePage].pageCount != 0) ) - { - ++memPool.freePage; - } - - if (memPool.freePage >= memPool.pageCount) - { - /* No more free pages. */ - memPool.freePage = -1; - } - } - - /* Walk all pages. */ - for (j = 0; j < pageCount; ++j) - { - /* Store page count in each pageUsage to mark page is allocated. */ - memPool.pageUsage[i+j].pageCount = pageCount; - } - - gcmkTRACE(gcvLEVEL_INFO, "Allocated %u contiguous pages from 0x%X\n", - pageCount, i); - - /* Success. */ - *Physical = (gctPHYS_ADDR)(i * memPool.pageSize + (gctUINT32)memPool.paddr); - *Logical = (gctPOINTER)(i * memPool.pageSize + (gctUINT32)memPool.addr); - - pthread_mutex_unlock(&memPool.mutex); -} - -int drv_mempool_free(gctPOINTER Logical) -{ - gctUINT16 pageCount; - gctSIZE_T i; - gctINT32 pageIndex; - - gcmkTRACE(gcvLEVEL_INFO, "Freeing pages @ %x\n", Logical); - - pthread_mutex_lock(&memPool.mutex); - - pageIndex = ((gctUINT32)Logical - (gctUINT32)memPool.addr) / memPool.pageSize; - - /* Verify the memory is valid and unlocked. */ - if ( (pageIndex < 0) || (pageIndex >= memPool.pageCount) ) - { - pthread_mutex_unlock(&memPool.mutex); - gcmkTRACE(gcvLEVEL_ERROR, "Invalid page index @ %d\n", pageIndex); - return -1; - } - - pageCount = memPool.pageUsage[pageIndex].pageCount; - - /* Mark all used pages as free. */ - for (i = 0; i < pageCount; ++i) - { - gcmkASSERT(memPool.pageUsage[i + pageIndex].pageCount == pageCount); - - memPool.pageUsage[i + pageIndex].pageCount = 0; - } - - /* Update first free page. */ - if ( (memPool.freePage < 0) || (pageIndex < memPool.freePage) ) - { - memPool.freePage = pageIndex; - } - - pthread_mutex_unlock(&memPool.mutex); - - gcmkTRACE(gcvLEVEL_INFO, "Free'd %u contiguos pages from 0x%X @ 0x%x\n", - pageCount, pageIndex); - - return 1; -} - -/* - * Initialize shm pool list and mutex. - */ -gceSTATUS -drv_shm_init() -{ - shmPoolList = gcvNULL; - pthread_mutex_init(&shmPoolListMutex, 0); - return gcvSTATUS_OK; -/* resmgr_globals.shmpool = gcvNULL; - return pthread_mutex_init(&resmgr_globals.shmMutex, 0);*/ -} - -gceSTATUS -drv_shm_destroy() -{ - gckSHM_POOL shmPool; - gctUINT32 count = 0; - - pthread_mutex_destroy(&shmPoolListMutex); - - shmPool = shmPoolList; - while (shmPool != gcvNULL) - { - /* Remove this pool from the list. */ - drv_shmpool_destroy(shmPool); - - shmPool = shmPool->nextPool; - count++; - } - - return gcvSTATUS_OK; -/* resmgr_globals.shmpool = gcvNULL; - return pthread_mutex_destroy(&resmgr_globals.shmMutex);*/ -} - -/* - * Get the shm pool associated with this Handle and PID and lock it. - * Create one, if not present. - */ -gckSHM_POOL -drv_shm_acquire_pool( - IN gctUINT32 Pid, - IN gctHANDLE Handle - ) -{ - gckSHM_POOL shmPool, tail = gcvNULL; - - pthread_mutex_lock(&shmPoolListMutex); - - shmPool = shmPoolList; - while (shmPool != gcvNULL) - { - if (shmPool->Handle == Handle && shmPool->pid == Pid) - { - pthread_mutex_unlock(&shmPoolListMutex); - return shmPool; - } - - tail = shmPool; - shmPool = shmPool->nextPool; - } - - /* TODO: Start with smaller shmMemory pool size and increase on demand. */ - /* Default 4KB page size. */ - shmPool = drv_shmpool_create(Pid, Handle, sharedPoolSize, __PAGESIZE); - - /* Add this pool to tail. */ - if ( shmPool != gcvNULL ) - { - if (tail != gcvNULL ) - { - tail->nextPool = shmPool; - } - else - { - /* Set this pool as head. */ - shmPoolList = shmPool; - } - - shmPool->nextPool = gcvNULL; - } - else - { - /* Failed to create new shmPool. */ - } - - pthread_mutex_unlock(&shmPoolListMutex); - return shmPool; -} - -/* - * Get the shm pool associated with this Logical pointer. - */ -gckSHM_POOL -drv_shm_acquire_pool2( - IN gctPOINTER Logical - ) -{ - gckSHM_POOL shmPool, tail = gcvNULL; - - pthread_mutex_lock(&shmPoolListMutex); - - shmPool = shmPoolList; - while (shmPool != gcvNULL) - { - /* Check if this address is in range of this shmPool. */ - if (shmPool->Logical <= (gctUINT32)Logical && - (shmPool->Logical + shmPool->pageCount * shmPool->pageSize) > (gctUINT32)Logical) - { - pthread_mutex_unlock(&shmPoolListMutex); - return shmPool; - } - - tail = shmPool; - shmPool = shmPool->nextPool; - } - - /* Failed to find associated shmPool. */ - pthread_mutex_unlock(&shmPoolListMutex); - return shmPool; -} - -/* - * Remove the shm pool associated with this ocb. - */ -gceSTATUS -drv_shm_remove_pool( - IN gctHANDLE Handle - ) -{ - gckSHM_POOL shmPool, prev = gcvNULL; - - pthread_mutex_lock(&shmPoolListMutex); - - shmPool = shmPoolList; - - while (shmPool != gcvNULL) - { - /* Remove this pool from the list. */ - if (shmPool->Handle == Handle) - { - if (prev == gcvNULL) - { - shmPoolList = shmPool->nextPool; - } - else - { - prev->nextPool = shmPool->nextPool; - } - - drv_shmpool_destroy(shmPool); - - pthread_mutex_unlock(&shmPoolListMutex); - return gcvSTATUS_OK; - } - - prev = shmPool; - shmPool = shmPool->nextPool; - } - - pthread_mutex_unlock(&shmPoolListMutex); - - return gcvSTATUS_INVALID_ARGUMENT; -} - -gceSTATUS -drv_shmpool_mem_offset( - IN gctPOINTER Logical, - OUT gctUINT32 * Address) -{ - gctUINT32 logical = (gctUINT32)Logical; - gckSHM_POOL shmPool; - - if ( Address == gcvNULL ) - return gcvSTATUS_INVALID_ARGUMENT; - - pthread_mutex_lock(&shmPoolListMutex); - - shmPool = shmPoolList; - while (shmPool != gcvNULL) - { - if ( (logical >= shmPool->Logical) - && (logical < (shmPool->Logical + shmPool->pageCount * shmPool->pageSize))) - { - *Address = (logical - shmPool->Logical ) + shmPool->Physical; - pthread_mutex_unlock(&shmPoolListMutex); - return gcvSTATUS_OK; - } - - shmPool = shmPool->nextPool; - } - - pthread_mutex_unlock(&shmPoolListMutex); - - return gcvSTATUS_INVALID_ARGUMENT; -} - -/* Initialize a shm pool with this ocb. */ -gckSHM_POOL drv_shmpool_create( - IN gctUINT32 Pid, - IN gctHANDLE Handle, - IN gctUINT32 PoolSize, - IN gctUINT32 PageSize) -{ - int rc, poolSize; - void* addr; - char shm_file_name[20] = "shm_galcore"; - gctUINT32 i, pid; - gckSHM_POOL shm = (gckSHM_POOL) calloc(1, sizeof(struct _gckSHM_POOL)); - - /* Compute number of pages. */ - shm->pageSize = PageSize; - shm->pageCount = PoolSize / shm->pageSize; - gcmkASSERT(shm->pageCount <= 65536); - - /* Align poolSize to pageSize. */ - poolSize = shm->pageCount * shm->pageSize; - - shm->pid = Pid; - shm->Handle = Handle; - - /* Initialize the semaphore. */ - if (pthread_mutex_init(&shm->mutex, NULL) != EOK) - { - fprintf( stderr, "pthread_mutex_init failed: %s\n", strerror( errno ) ); - free(shm); - return gcvNULL; - } - - /* Create a pseudo unique name, so as to not open - * the same file twice from different threads at the same time. */ - pid = Pid; - i = strlen(shm_file_name); - while(pid) - { - shm_file_name[i++] = (char)(pid % 10 + '0'); - pid /= 10; - } - shm_file_name[i] = '\0'; - - shm->fd = shm_open(shm_file_name, O_RDWR | O_CREAT, 0777); - if (shm->fd == -1) { - free(shm); - return gcvNULL; - } - - shm_unlink(shm_file_name); - - /* Special flags for this shm, to make it write buffered. */ - rc = shm_ctl_special(shm->fd, - SHMCTL_ANON | SHMCTL_PHYS /*| SHMCTL_LAZYWRITE*/, - 0, - poolSize, - 0x9); - if (rc == -1) { - close(shm->fd); - free(shm); - return gcvNULL; - } - - /* Map this memory inside user and galcore. */ - addr = mmap64_join(Pid, - 0, - poolSize, - PROT_READ | PROT_WRITE, - MAP_SHARED, - shm->fd, - 0); - if (addr == MAP_FAILED) - { - free(shm); - return gcvNULL; - } - - /* TODO: Dont close fd if need to truncate shm later. */ - rc = close(shm->fd); - if (rc == -1) { - free(shm); - return gcvNULL; - } - - shm->Logical = (gctUINT32) addr; - - /* fd should be NOFD here, to get physical address. */ - rc = mem_offset( addr, NOFD, 1, (off_t *)&shm->Physical, NULL); - if (rc == -1) { - free(shm); - return gcvNULL; - } - - /* TODO: MLOCK may or may not be needed!. */ - mlock((void*)shm->Logical, poolSize); - - /* Allocate the page usage array and Initialize all pages to free. */ - shm->pageUsage = (gckPAGE_USAGE)calloc(shm->pageCount, sizeof(struct _gckPAGE_USAGE)); - if (shm->pageUsage == gcvNULL) - { - munmap((void*)shm->Logical, poolSize); - munmap_peer(Pid, (void*)shm->Logical, poolSize); - free(shm); - return gcvNULL; - } - - /* The first page is free. */ - shm->freePage = 0; - - return shm; -} - -void -drv_shmpool_destroy( - IN gckSHM_POOL ShmPool) -{ - if (ShmPool) - { - int poolSize = ShmPool->pageCount * ShmPool->pageSize; - if (ShmPool->pageUsage) - free(ShmPool->pageUsage); - if (ShmPool->Logical) - { - munmap((void*)ShmPool->Logical, poolSize); - munmap_peer(ShmPool->pid, (void*)ShmPool->Logical, poolSize); - } - } -} - -gctUINT32 -drv_shmpool_get_BaseAddress( - IN gckSHM_POOL ShmPool - ) -{ - gcmkASSERT(ShmPool != 0); - - if (!ShmPool) - return 0; - - return ShmPool->Logical; -} - -gctUINT32 -drv_shmpool_get_page_size( - IN gckSHM_POOL ShmPool - ) -{ - gcmkASSERT(ShmPool != 0); - - if (!ShmPool) - return 0; - - return ShmPool->pageSize; -} - -/* Allocate pages from mapped shared memory. - Return Logical user address. -*/ -gctPOINTER -drv_shmpool_alloc_contiguous( - IN gctUINT32 Pid, - IN gctHANDLE Handle, - IN gctUINT32 Bytes - ) -{ - gctSIZE_T i, j; - int pageSize; - gctSIZE_T pageCount; - gckSHM_POOL shmPool = drv_shm_acquire_pool(Pid, Handle); - - if (shmPool == gcvNULL) - { - return gcvNULL; - } - /* Compute the number of required pages. */ - pageSize = drv_shmpool_get_page_size(shmPool); - if ( pageSize == 0 ) - { - /* Invalid pageSize. */ - return gcvNULL; - } - - pageCount = gcmALIGN(Bytes, pageSize) / pageSize; - - if ( (pageCount <= 0) || (shmPool->freePage < 0) ) - { - /* No free pages left. */ - return gcvNULL; - } - - if ( (pageCount <= 0) || (shmPool->freePage < 0) ) - { - /* No free pages left. */ - return gcvNULL; - } - - /* Try finding enough contiguous free pages. */ - for (i = shmPool->freePage; i < shmPool->pageCount;) - { - /* All pages behind this free page should be free. */ - gctSIZE_T j; - for (j = 1; j < pageCount; ++j) - { - if (shmPool->pageUsage[i + j].pageCount != 0) - { - /* Bail out if page is allocated. */ - break; - } - } - - if (j == pageCount) - { - /* We found a spot that has enough free pages. */ - break; - } - - /* Move to the page after the allocated page. */ - i += j + 1; - - /* Find the next free page. */ - while ((i < shmPool->pageCount) && (shmPool->pageUsage[i].pageCount != 0)) - { - ++i; - } - } - - if (i >= shmPool->pageCount) - { - /* Not enough contiguous pages. */ - return gcvNULL; - } - - /* Check if we allocate from the first free page. */ - if (i == shmPool->freePage) - { - /* Move first free page to beyond the contiguous request. */ - shmPool->freePage = i + pageCount; - - /* Find first free page. */ - while ( (shmPool->freePage < shmPool->pageCount) && - (shmPool->pageUsage[shmPool->freePage].pageCount != 0) ) - { - ++shmPool->freePage; - } - - if (shmPool->freePage >= shmPool->pageCount) - { - /* No more free pages. */ - shmPool->freePage = -1; - } - } - - /* Walk all pages. */ - for (j = 0; j < pageCount; ++j) - { - /* Store page count in each pageUsage to mark page is allocated. */ - shmPool->pageUsage[i+j].pageCount = pageCount; - } - - gcmkTRACE(gcvLEVEL_INFO, "Allocated %u contiguos pages from 0x%X\n", - pageCount, i); - - /* Success. */ - return (gctPOINTER)(i * shmPool->pageSize + shmPool->Logical); -} - -gctUINT32 -drv_shmpool_free( - IN gctPOINTER Logical - ) -{ - gctUINT16 pageCount; - gctSIZE_T i; - gctINT32 pageIndex; - gckSHM_POOL shmPool = drv_shm_acquire_pool2(Logical); - - if (shmPool == gcvNULL) - { - gcmkTRACE(gcvLEVEL_ERROR, "Invalid Logical addr: %x.\n", Logical); - return 0; - } - - pageIndex = ((gctUINT32)Logical - shmPool->Logical)/shmPool->pageSize; - - gcmkTRACE(gcvLEVEL_INFO, "Freeing pages @ %d\n", pageIndex); - - /* Verify the memory is valid and unlocked. */ - if ( (pageIndex < 0) || (pageIndex >= shmPool->pageCount) ) - { - gcmkTRACE(gcvLEVEL_ERROR, "Invalid page index @ %d\n", pageIndex); - - return 0; - } - - pageCount = shmPool->pageUsage[pageIndex].pageCount; - - /* Mark all used pages as free. */ - for (i = 0; i < pageCount; ++i) - { - gcmkASSERT(shmPool->pageUsage[i + pageIndex].pageCount == pageCount); - - shmPool->pageUsage[i + pageIndex].pageCount = 0; - } - - /* Update first free page. */ - if ( (shmPool->freePage < 0) || (pageIndex < shmPool->freePage) ) - { - shmPool->freePage = pageIndex; - } - - gcmkTRACE(gcvLEVEL_INFO, "Free'd %u contiguos pages from 0x%X @ 0x%x\n", - pageCount, pageIndex); - - return 1; -} - -int drv_msg(resmgr_context_t *ctp, - io_msg_t *msg, - RESMGR_OCB_T *ocb) -{ - gcsDRIVER_ARGS *drvArgs = (gcsDRIVER_ARGS *)msg; - int rc; - gceSTATUS status; - gcsQUEUE_PTR queue; - -#define UNLOCK_RESMGR -#ifdef UNLOCK_RESMGR - iofunc_attr_unlock(&attr); -#endif - - if ((drvArgs->iomsg.i.type != _IO_MSG) - || (drvArgs->iomsg.i.mgrid != _IOMGR_VIVANTE) - || (drvArgs->iomsg.i.subtype != IOCTL_GCHAL_INTERFACE - && drvArgs->iomsg.i.subtype != IOCTL_GCHAL_KERNEL_INTERFACE - && drvArgs->iomsg.i.subtype != IOCTL_GCHAL_TERMINATE)) - { - /* Unknown command. Fail the I/O. */ -#ifdef UNLOCK_RESMGR - iofunc_attr_lock(&attr); -#endif - rc = ENOSYS; - if (ctp->info.scoid != -1) - return _RESMGR_STATUS(ctp, rc); - return _RESMGR_NOREPLY; - } - - if (drvArgs->iomsg.i.subtype == IOCTL_GCHAL_TERMINATE) - { - /* terminate the resource manager */ - pthread_kill(resmgr_globals.root, SIGTERM); -#ifdef UNLOCK_RESMGR - iofunc_attr_lock(&attr); -#endif - return _RESMGR_NOREPLY; - } - - /* Save channel handle and pid for later functions. */ - drvArgs->iface.handle = (gctHANDLE)ocb; - drvArgs->iface.pid = (gctUINT32)ctp->info.pid; - - /* Store receive ID with signal event so that we can later respond via pulse. */ - switch (drvArgs->iface.command) - { - case gcvHAL_SIGNAL: - printf("Setup rcvid as:%d\n", ctp->rcvid); - drvArgs->iface.u.Signal.rcvid = ctp->rcvid; - break; - - case gcvHAL_EVENT_COMMIT: - for (queue = drvArgs->iface.u.Event.queue; queue != gcvNULL; queue = queue->next) - { - if (queue->iface.command == gcvHAL_SIGNAL) - { - queue->iface.u.Signal.rcvid = ctp->rcvid; - } - } - break; - - default: - break; - } - - status = gckKERNEL_Dispatch(galDevice->kernel, - (drvArgs->iomsg.i.subtype == IOCTL_GCHAL_INTERFACE), - &drvArgs->iface); - - if (gcmIS_ERROR(status)) - { - gcmkTRACE_ZONE(gcvLEVEL_WARNING, gcvZONE_DRIVER, - "[galcore] gckKERNEL_Dispatch returned %d.\n", - status); - } - else if (gcmIS_ERROR(drvArgs->iface.status)) - { - gcmkTRACE_ZONE(gcvLEVEL_WARNING, gcvZONE_DRIVER, - "[galcore] IOCTL %d returned %d.\n", - drvArgs->iface.command, - drvArgs->iface.status); - } - - /* Reply data back to the user. */ - MsgReply(ctp->rcvid, EOK, (gctPOINTER) &drvArgs->iface, sizeof(gcsHAL_INTERFACE)); - -#ifdef UNLOCK_RESMGR - iofunc_attr_lock(&attr); -#endif - - gcmkTRACE(gcvLEVEL_INFO, "Replied message with command %d, status %d\n", - drvArgs->iface.command, - drvArgs->iface.status); - - return (_RESMGR_NOREPLY); -} - -static int drv_init(void) -{ - /* TODO: Enable clock by driver support? */ - gcmkTRACE_ZONE(gcvLEVEL_VERBOSE, gcvZONE_DRIVER, - "Entering drv_init\n"); - - /* Create the GAL device. */ - gcmkVERIFY_OK(gckGALDEVICE_Construct(irqLine, - registerMemBase, - registerMemSize, - contiguousBase, - contiguousSize, - bankSize, - fastClear, - compression, - baseAddress, - &galDevice)); - - gcmkTRACE_ZONE(gcvLEVEL_VERBOSE, gcvZONE_DRIVER, - "galcore device constructed.\n"); - - /* Start the GAL device. */ - if (gcmIS_ERROR(gckGALDEVICE_Start(galDevice))) - { - gcmkTRACE_ZONE(gcvLEVEL_ERROR, gcvZONE_DRIVER, - "[galcore] Can't start the gal device.\n"); - - /* Roll back. */ - gckGALDEVICE_Stop(galDevice); - gckGALDEVICE_Destroy(galDevice); - - return -1; - } - - gcmkTRACE_ZONE(gcvLEVEL_INFO, gcvZONE_DRIVER, - "[galcore] irqLine->%ld, contiguousSize->%lu, memBase->0x%lX\n", - irqLine, - contiguousSize, - registerMemBase); - - gcmkTRACE_ZONE(gcvLEVEL_VERBOSE, gcvZONE_DRIVER, - "[galcore] driver registered successfully.\n"); - - return 0; -} - -static void drv_exit(void) -{ - gcmkTRACE_ZONE(gcvLEVEL_VERBOSE, gcvZONE_DRIVER, - "[galcore] Entering drv_exit\n"); - - gckGALDEVICE_Stop(galDevice); - gckGALDEVICE_Destroy(galDevice); - -} - -/* Invoked by OS, when a connection is closed or dies. */ -int -drv_close_ocb(resmgr_context_t *ctp, void *reserved, RESMGR_OCB_T *ocb) -{ - gckVIDMEM videoMemory; - gceSTATUS status; - - /* Free virtual memory owned by this client. */ - gckMMU_FreeHandleMemory(galDevice->kernel->mmu, (gctHANDLE)ocb); - - /* Free system memory owned by the client. */ - status = gckKERNEL_GetVideoMemoryPool(galDevice->kernel, gcvPOOL_SYSTEM, &videoMemory); - - if (status == gcvSTATUS_OK) - { - gckVIDMEM_FreeHandleMemory(videoMemory, - (gctHANDLE)ocb); - } - - /* Free shared memory and its mapping. */ - drv_shm_remove_pool(ocb); - - return iofunc_close_ocb_default(ctp, reserved, ocb); -} - -int gpu_init() -{ - /* Declare variables we'll be using. */ - resmgr_attr_t resmgr_attr; - sigset_t sigset; - int rc; - - if (drv_mempool_init() != gcvSTATUS_OK) - { - fprintf(stderr, "drv_mempool_init failed."); - goto fail_001; - } - - if (drv_shm_init() != gcvSTATUS_OK) - { - fprintf(stderr, "drv_mempool_init failed."); - goto fail_002; - } - - if (drv_init() != 0) - { - fprintf(stderr, "drv_init failed."); - goto fail_003; - } - - /* initialize dispatch interface */ - if((resmgr_globals.dpp = dispatch_create()) == NULL) - { - fprintf(stderr, "Unable to allocate dispatch handle.\n"); - goto fail_004; - } - - /* initialize resource manager attributes */ - memset(&resmgr_attr, 0, sizeof resmgr_attr); - resmgr_attr.nparts_max = 1; - resmgr_attr.msg_max_size = 2048; - - /* initialize functions for handling messages */ - iofunc_func_init(_RESMGR_CONNECT_NFUNCS, &connect_funcs, - _RESMGR_IO_NFUNCS, &io_funcs); - - /* Register io handling functions. */ - io_funcs.msg = drv_msg; - io_funcs.close_ocb = drv_close_ocb; - - - /* initialize attribute structure used by the device */ - iofunc_attr_init(&attr, S_IFNAM | 0666, 0, 0); - - /* attach our device name */ - resmgr_globals.id = resmgr_attach( - resmgr_globals.dpp,/* dispatch handle */ - &resmgr_attr, /* resource manager attrs */ - GAL_DEV, /* device name */ - _FTYPE_ANY, /* open type */ - _RESMGR_FLAG_SELF, /* flags */ - &connect_funcs, /* connect routines */ - &io_funcs, /* I/O routines */ - &attr); /* handle */ - if (resmgr_globals.id == -1) { - fprintf(stderr, "Unable to attach name.\n"); - goto fail_005; - } - - /* Prevent signals from affecting resmgr threads. */ - sigfillset(&sigset); - sigdelset(&sigset, SIGTERM); - pthread_sigmask(SIG_BLOCK, &sigset, NULL); - - /* initialize thread pool attributes */ - memset(&resmgr_globals.pool_attr, 0, sizeof(resmgr_globals.pool_attr)); - resmgr_globals.pool_attr.handle = resmgr_globals.dpp; - resmgr_globals.pool_attr.context_alloc = resmgr_context_alloc; - resmgr_globals.pool_attr.block_func = resmgr_block; - resmgr_globals.pool_attr.unblock_func = resmgr_unblock; - resmgr_globals.pool_attr.handler_func = resmgr_handler; - resmgr_globals.pool_attr.context_free = resmgr_context_free; - resmgr_globals.pool_attr.lo_water = 2; - resmgr_globals.pool_attr.hi_water = 4; - resmgr_globals.pool_attr.increment = 1; - resmgr_globals.pool_attr.maximum = 50; -#if (defined(_NTO_VERSION) && (_NTO_VERSION >= 650)) - resmgr_globals.pool_attr.tid_name = "galcore-message-handler"; -#endif - - /* allocate a thread pool handle */ - resmgr_globals.tpp = thread_pool_create(&resmgr_globals.pool_attr, POOL_FLAG_EXIT_SELF); - if (resmgr_globals.tpp == NULL) - { - goto fail_006; - } - - rc = pthread_create(NULL, resmgr_globals.pool_attr.attr, (void * (*)(void *))thread_pool_start, resmgr_globals.tpp); - if (rc != 0) - { - goto fail_007; - } - - /* TODO: gpu_suspend, gpu_resume */ - - return EXIT_SUCCESS; - -fail_007: - thread_pool_destroy(resmgr_globals.tpp); -fail_006: - resmgr_detach(resmgr_globals.dpp, resmgr_globals.id, 0); -fail_005: - dispatch_destroy(resmgr_globals.dpp); -fail_004: - drv_exit(); -fail_003: - drv_shm_destroy(); -fail_002: - drv_mempool_destroy(); -fail_001: - return EXIT_FAILURE; -} - -int gpu_fini() -{ - thread_pool_destroy(resmgr_globals.tpp); - resmgr_detach(resmgr_globals.dpp, resmgr_globals.id, 0); - dispatch_destroy(resmgr_globals.dpp); - drv_exit(); - drv_shm_destroy(); - drv_mempool_destroy(); - return EXIT_SUCCESS; -} - -#ifndef QNX_USE_OLD_FRAMEWORK - -int GPU_Startup(win_gpu_2_cm_iface_t *iface) -{ - g_qnx_gpu_2_cm_iface = iface; - return gpu_init(); -} - -int GPU_Shutdown() -{ - g_qnx_gpu_2_cm_iface = NULL; - return gpu_fini(); -} - -void win_gpu_module_getfuncs(win_cm_2_gpu_iface_t *iface) -{ - iface->init = GPU_Startup; - iface->fini = GPU_Shutdown; -} - -#else /* QNX_USE_OLD_FRAMEWORK */ - -int drv_resmgr_loop() -{ - sigset_t sigset; - siginfo_t info; - - resmgr_globals.root = pthread_self(); - - /* Background ourselves */ - procmgr_daemon(EXIT_SUCCESS, PROCMGR_DAEMON_NODEVNULL | - PROCMGR_DAEMON_NOCHDIR | - PROCMGR_DAEMON_NOCLOSE); - - /* - * This thread ignores all signals except SIGTERM. On receipt of - * a SIGTERM, we shut everything down and exit. - */ - sigemptyset(&sigset); - sigaddset(&sigset, SIGTERM); - - while (1) - { - if (SignalWaitinfo(&sigset, &info) == -1) - continue; - if (info.si_signo == SIGTERM) - { - break; - } - } - - return EXIT_SUCCESS; -} - -int drv_start_cmd() -{ - int rc; - - printf("Starting up...\n"); - fflush(stdout); - - pthread_setname_np(pthread_self(), "vivante-monitor"); - - if ((rc = gpu_init()) != EXIT_SUCCESS) - { - fprintf(stderr, "Initialization failed!, Exiting."); - exit(EXIT_FAILURE); - } - - printf("Running galcore...\n"); - fflush(stdout); - rc = drv_resmgr_loop(); - printf("Shutting down galcore...\n"); - fflush(stdout); - - gpu_fini(); - - return EXIT_SUCCESS; -} - -int drv_stop_cmd() -{ - gcsDRIVER_ARGS args; - int fd, rc; - - /* Open the gpu device. */ - fd = open(DRV_NAME, O_RDONLY); - if (fd == -1) - { - fprintf(stderr, "Could not connect to " DRV_NAME); - return EXIT_FAILURE; - } - - /* Send the term message. */ - args.iomsg.i.type = _IO_MSG; - args.iomsg.i.subtype = IOCTL_GCHAL_TERMINATE; - args.iomsg.i.mgrid = _IOMGR_VIVANTE; - args.iomsg.i.combine_len = sizeof(io_msg_t); - - do { - rc = MsgSend_r(fd, &args, args.iomsg.i.combine_len, NULL, 0); - } while ((rc * -1) == EINTR); - - return EXIT_SUCCESS; -} - -int main(int argc, char **argv) -{ - enum { start, stop } cmd = start; - int i; - int rc = EXIT_FAILURE; - - /* Process command lines -start, -stop, -c (file), -d [file]. */ - for (i = 1; i < argc; i++) - { - if (stricmp(argv[i], "-start") == 0) - { - cmd = start; - } - else if (strcmp(argv[i], "-stop") == 0) - { - cmd = stop; - } - else if (strncmp(argv[i], "-poolsize=", strlen("-poolsize=")) == 0) - { - /* The syntax of the poolsize option is -poolsize=(number). - * All we need is to convert the number that starts after the '='.*/ - contiguousSize = atoi(argv[i] + strlen("-poolsize=")); - if (contiguousSize <= 0) - { - fprintf(stderr, "%s: poolsize needs to be a positive number\n", strerror(errno)); - return rc; - } - } - else - { - fprintf(stderr, "%s: bad command line\n", argv[0]); - return rc; - } - } - - switch (cmd) - { - case start: - /* Elevate thread priority to do IO. */ - ThreadCtl(_NTO_TCTL_IO, 0); - rc = drv_start_cmd(); - break; - - case stop: - rc = drv_stop_cmd(); - break; - } - - return rc; -} - -#endif /* QNX_USE_OLD_FRAMEWORK */ - diff --git a/drivers/staging/rk29/vivante/hal/os/qnx/kernel/gc_hal_kernel_os.c b/drivers/staging/rk29/vivante/hal/os/qnx/kernel/gc_hal_kernel_os.c deleted file mode 100644 index bf7e5c923e05..000000000000 --- a/drivers/staging/rk29/vivante/hal/os/qnx/kernel/gc_hal_kernel_os.c +++ /dev/null @@ -1,3008 +0,0 @@ -/**************************************************************************** -* -* Copyright (c) 2005 - 2010 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. -* -***************************************************************************** -* -* Auto-generated file on 12/8/2010. Do not edit!!! -* -*****************************************************************************/ - - - - -#include "gc_hal_kernel_qnx.h" - - - -# include - -#define USE_VMALLOC 0 - -#define _GC_OBJ_ZONE gcvZONE_OS - -#define MEMORY_LOCK(os) \ - gcmkVERIFY_OK(gckOS_AcquireMutex( \ - (os), \ - (os)->memoryLock, \ - gcvINFINITE)) - -#define MEMORY_UNLOCK(os) \ - gcmkVERIFY_OK(gckOS_ReleaseMutex((os), (os)->memoryLock)) - -#define MEMORY_MAP_LOCK(os) \ - gcmkVERIFY_OK(gckOS_AcquireMutex( \ - (os), \ - (os)->memoryMapLock, \ - gcvINFINITE)) - -#define MEMORY_MAP_UNLOCK(os) \ - gcmkVERIFY_OK(gckOS_ReleaseMutex((os), (os)->memoryMapLock)) - -/******************************************************************************\ -********************************** Structures ********************************** -\******************************************************************************/ - -struct _gckOS -{ - /* Object. */ - gcsOBJECT object; - - /* Heap. */ - gckHEAP heap; - - /* Pointer to device */ - gckGALDEVICE device; - - /* Memory management */ - gctPOINTER memoryLock; - gctPOINTER memoryMapLock; - gctPOINTER mempoolBaseAddress; - gctPOINTER mempoolBasePAddress; - gctUINT32 mempoolPageSize; - - gctUINT32 baseAddress; - - /* Atomic operation lock. */ - gctPOINTER atomicOperationLock; -}; - - -typedef struct _gcskSIGNAL -{ - pthread_mutex_t *mutex; - - /* Manual reset flag. */ - gctBOOL manualReset; -} -gcskSIGNAL; - -typedef struct _gcskSIGNAL * gcskSIGNAL_PTR; - - -/******************************************************************************* -** -** gckOS_Construct -** -** Construct a new gckOS object. -** -** INPUT: -** -** gctPOINTER Context -** Pointer to the gckGALDEVICE class. -** -** OUTPUT: -** -** gckOS * Os -** Pointer to a variable that will hold the pointer to the gckOS object. -*/ -gceSTATUS gckOS_Construct( - IN gctPOINTER Context, - OUT gckOS * Os - ) -{ - gckOS os; - gceSTATUS status; - - /* Verify the arguments. */ - gcmkVERIFY_ARGUMENT(Os != gcvNULL); - - /* Allocate the gckOS object. */ - os = (gckOS) malloc(gcmSIZEOF(struct _gckOS)); - - if (os == gcvNULL) - { - /* Out of memory. */ - return gcvSTATUS_OUT_OF_MEMORY; - } - - /* Zero the memory. */ - memset(os, 0, gcmSIZEOF(struct _gckOS)); - - /* Initialize the gckOS object. */ - os->object.type = gcvOBJ_OS; - - /* Set device device. */ - os->device = Context; - - /* IMPORTANT! No heap yet. */ - os->heap = gcvNULL; - - /* Initialize the memory lock. */ - gcmkONERROR( - gckOS_CreateMutex(os, &os->memoryLock)); - - gcmkONERROR( - gckOS_CreateMutex(os, &os->memoryMapLock)); - - /* Create the gckHEAP object. */ - gcmkONERROR( - gckHEAP_Construct(os, gcdHEAP_SIZE, &os->heap)); - - /* Find the base address of the physical memory. */ - os->baseAddress = os->device->baseAddress; - - gcmkTRACE_ZONE(gcvLEVEL_INFO, gcvZONE_OS, - "Physical base address set to 0x%08X.\n", - os->baseAddress); - - os->mempoolBaseAddress = (gctPOINTER) drv_mempool_get_baseAddress(); - os->mempoolBasePAddress = (gctPOINTER) drv_mempool_get_basePAddress(); - os->mempoolPageSize = drv_mempool_get_page_size(); - - - /* Initialize the atomic operations lock. */ - gcmkONERROR( - gckOS_CreateMutex(os, &os->atomicOperationLock)); - - /* Return pointer to the gckOS object. */ - *Os = os; - - /* Success. */ - return gcvSTATUS_OK; - -OnError: - if (os->heap != gcvNULL) - { - gcmkVERIFY_OK( - gckHEAP_Destroy(os->heap)); - } - - if (os->memoryMapLock != gcvNULL) - { - gcmkVERIFY_OK( - gckOS_DeleteMutex(os, os->memoryMapLock)); - } - - if (os->memoryLock != gcvNULL) - { - gcmkVERIFY_OK( - gckOS_DeleteMutex(os, os->memoryLock)); - } - - if (os->atomicOperationLock != gcvNULL) - { - gcmkVERIFY_OK( - gckOS_DeleteMutex(os, os->atomicOperationLock)); - } - - free(os); - - /* Return the error. */ - return status; -} - -/******************************************************************************* -** -** gckOS_Destroy -** -** Destroy an gckOS object. -** -** INPUT: -** -** gckOS Os -** Pointer to an gckOS object that needs to be destroyed. -** -** OUTPUT: -** -** Nothing. -*/ -gceSTATUS -gckOS_Destroy( - IN gckOS Os - ) -{ - gckHEAP heap; - - /* Verify the arguments. */ - gcmkVERIFY_OBJECT(Os, gcvOBJ_OS); - - if (Os->heap != NULL) - { - /* Mark gckHEAP as gone. */ - heap = Os->heap; - Os->heap = NULL; - - /* Destroy the gckHEAP object. */ - gcmkVERIFY_OK( - gckHEAP_Destroy(heap)); - } - - /* Destroy the memory lock. */ - gcmkVERIFY_OK( - gckOS_DeleteMutex(Os, Os->memoryMapLock)); - - gcmkVERIFY_OK( - gckOS_DeleteMutex(Os, Os->memoryLock)); - - /* Destroy the atomic operation lock. */ - gcmkVERIFY_OK( - gckOS_DeleteMutex(Os, Os->atomicOperationLock)); - - /* Mark the gckOS object as unknown. */ - Os->object.type = gcvOBJ_UNKNOWN; - - /* Free the gckOS object. */ - free(Os); - - /* Success. */ - return gcvSTATUS_OK; -} - -/******************************************************************************* -** -** gckOS_Allocate -** -** Allocate memory. -** -** INPUT: -** -** gckOS Os -** Pointer to an gckOS object. -** -** gctSIZE_T Bytes -** Number of bytes to allocate. -** -** OUTPUT: -** -** gctPOINTER * Memory -** Pointer to a variable that will hold the allocated memory location. -*/ -gceSTATUS -gckOS_Allocate( - IN gckOS Os, - IN gctSIZE_T Bytes, - OUT gctPOINTER * Memory - ) -{ - gceSTATUS status; - - /*gcmkHEADER_ARG("Os=0x%x Bytes=%lu", Os, Bytes);*/ - - /* Verify the arguments. */ - gcmkVERIFY_OBJECT(Os, gcvOBJ_OS); - gcmkVERIFY_ARGUMENT(Bytes > 0); - gcmkVERIFY_ARGUMENT(Memory != NULL); - - /* Do we have a heap? */ - if (Os->heap != NULL) - { - /* Allocate from the heap. */ - gcmkONERROR(gckHEAP_Allocate(Os->heap, Bytes, Memory)); - } - else - { - gcmkONERROR(gckOS_AllocateMemory(Os, Bytes, Memory)); - } - - /* Success. */ - /*gcmkFOOTER_ARG("*memory=0x%x", *Memory);*/ - return gcvSTATUS_OK; - -OnError: - /* Return the status. */ - gcmkFOOTER(); - return status; -} - -/******************************************************************************* -** -** gckOS_Free -** -** Free allocated memory. -** -** INPUT: -** -** gckOS Os -** Pointer to an gckOS object. -** -** gctPOINTER Memory -** Pointer to memory allocation to free. -** -** OUTPUT: -** -** Nothing. -*/ -gceSTATUS -gckOS_Free( - IN gckOS Os, - IN gctPOINTER Memory - ) -{ - gceSTATUS status; - - /* Verify the arguments. */ - gcmkVERIFY_OBJECT(Os, gcvOBJ_OS); - gcmkVERIFY_ARGUMENT(Memory != NULL); - - /* Do we have a heap? */ - if (Os->heap != NULL) - { - /* Free from the heap. */ - gcmkONERROR(gckHEAP_Free(Os->heap, Memory)); - } - else - { - gcmkONERROR(gckOS_FreeMemory(Os, Memory)); - } - - /* Success. */ - return gcvSTATUS_OK; - -OnError: - /* Return the status. */ - gcmkFOOTER(); - return status; -} -/******************************************************************************* -** -** gckOS_AllocateMemory -** -** Allocate memory wrapper. -** -** INPUT: -** -** gctSIZE_T Bytes -** Number of bytes to allocate. -** -** OUTPUT: -** -** gctPOINTER * Memory -** Pointer to a variable that will hold the allocated memory location. -*/ -gceSTATUS -gckOS_AllocateMemory( - IN gckOS Os, - IN gctSIZE_T Bytes, - OUT gctPOINTER * Memory - ) -{ - gctPOINTER memory; - gceSTATUS status; - - gcmkHEADER_ARG("Os=0x%x Bytes=%lu", Os, Bytes); - - /* Verify the arguments. */ - gcmkVERIFY_ARGUMENT(Bytes > 0); - gcmkVERIFY_ARGUMENT(Memory != NULL); - - memory = (gctPOINTER) calloc(1, Bytes); - - if (memory == NULL) - { - /* Out of memory. */ - gcmkONERROR(gcvSTATUS_OUT_OF_MEMORY); - } - - /* Return pointer to the memory allocation. */ - *Memory = memory; - - /* Success. */ - gcmkFOOTER_ARG("*Memory=0x%x", *Memory); - return gcvSTATUS_OK; - -OnError: - /* Return the status. */ - gcmkFOOTER(); - return status; -} - -/******************************************************************************* -** -** gckOS_FreeMemory -** -** Free allocated memory wrapper. -** -** INPUT: -** -** gctPOINTER Memory -** Pointer to memory allocation to free. -** -** OUTPUT: -** -** Nothing. -*/ -gceSTATUS -gckOS_FreeMemory( - IN gckOS Os, - IN gctPOINTER Memory - ) -{ - gcmkHEADER_ARG("Memory=0x%x", Memory); - - /* Verify the arguments. */ - gcmkVERIFY_ARGUMENT(Memory != NULL); - - /* Free the memory from the OS pool. */ - free(Memory); - - /* Success. */ - gcmkFOOTER_NO(); - return gcvSTATUS_OK; -} - -/******************************************************************************* -** -** gckOS_MapMemory -** -** Map physical memory into the current process. -** -** INPUT: -** -** gckOS Os -** Pointer to an gckOS object. -** -** gctPHYS_ADDR Physical -** Start of physical address memory. -** -** gctSIZE_T Bytes -** Number of bytes to map. -** -** OUTPUT: -** -** gctPOINTER * Memory -** Pointer to a variable that will hold the logical address of the -** mapped memory. -*/ -gceSTATUS gckOS_MapMemory( - IN gckOS Os, - IN gctPHYS_ADDR Physical, - IN gctSIZE_T Bytes, - OUT gctPOINTER * Logical - ) -{ - /* Verify the arguments. */ - gcmkVERIFY_OBJECT(Os, gcvOBJ_OS); - gcmkVERIFY_ARGUMENT(Physical != 0); - gcmkVERIFY_ARGUMENT(Bytes > 0); - gcmkVERIFY_ARGUMENT(Logical != NULL); - - gcmkTRACE_ZONE(gcvLEVEL_INFO, - gcvZONE_OS, - "Enter gckOS_MapMemory\n"); - - MEMORY_LOCK(Os); - - /* Map physical address. */ - *Logical = mmap64(0, - Bytes, - PROT_READ | PROT_WRITE, - MAP_PHYS | MAP_SHARED, - NOFD, - (off_t)Physical); - - MEMORY_UNLOCK(Os); - - if (*Logical == MAP_FAILED) - { - gcmkTRACE_ZONE(gcvLEVEL_ERROR, - gcvZONE_OS, - "gckOS_MapMemory: mmap error: %s\n", - strerror(errno)); - - return gcvSTATUS_OUT_OF_MEMORY; - } - - gcmkTRACE_ZONE(gcvLEVEL_ERROR, gcvZONE_OS, - "gckOS_MapMemory: User Mapped address for 0x%x is 0x%x\n", - (gctUINT32)Physical, - (gctUINT32)*Logical); - - return gcvSTATUS_OK; -} - -/******************************************************************************* -** -** gckOS_UnmapMemory -** -** Unmap physical memory out of the current process. -** -** INPUT: -** -** gckOS Os -** Pointer to an gckOS object. -** -** gctPHYS_ADDR Physical -** Start of physical address memory. -** -** gctSIZE_T Bytes -** Number of bytes to unmap. -** -** gctPOINTER Memory -** Pointer to a previously mapped memory region. -** -** OUTPUT: -** -** Nothing. -*/ -gceSTATUS gckOS_UnmapMemory( - IN gckOS Os, - IN gctPHYS_ADDR Physical, - IN gctSIZE_T Bytes, - IN gctPOINTER Logical - ) -{ - /* Verify the arguments. */ - gcmkVERIFY_OBJECT(Os, gcvOBJ_OS); - gcmkVERIFY_ARGUMENT(Physical != 0); - gcmkVERIFY_ARGUMENT(Bytes > 0); - gcmkVERIFY_ARGUMENT(Logical != NULL); - - gcmkTRACE_ZONE(gcvLEVEL_INFO, - gcvZONE_OS, - "in gckOS_UnmapMemory\n"); - - if (Logical) - { - gctUINT32 res; - gcmkTRACE_ZONE(gcvLEVEL_VERBOSE, - gcvZONE_OS, - "[gckOS_UnmapMemory] Logical: 0x%x\n", - Logical - ); - - MEMORY_LOCK(Os); - - res = munmap(Logical, Bytes); - - MEMORY_UNLOCK(Os); - - if (res == -1) - { - gcmkTRACE_ZONE(gcvLEVEL_ERROR, - gcvZONE_OS, - "gckOS_UnmapMemory: munmap error: %s\n", - strerror(errno)); - - return gcvSTATUS_INVALID_ARGUMENT; - } - } - - /* Success. */ - return gcvSTATUS_OK; -} - -/******************************************************************************* -** -** gckOS_AllocateNonPagedMemory -** -** Allocate a number of pages from non-paged memory. -** -** INPUT: -** -** gckOS Os -** Pointer to an gckOS object. -** -** gctBOOL InUserSpace -** gcvTRUE if the pages need to be mapped into user space. -** -** gctSIZE_T * Bytes -** Pointer to a variable that holds the number of bytes to allocate. -** -** OUTPUT: -** -** gctSIZE_T * Bytes -** Pointer to a variable that hold the number of bytes allocated. -** -** gctPHYS_ADDR * Physical -** Pointer to a variable that will hold the physical address of the -** allocation. -** -** gctPOINTER * Logical -** Pointer to a variable that will hold the logical address of the -** allocation. -*/ -gceSTATUS gckOS_AllocateNonPagedMemory( - IN gckOS Os, - IN gctBOOL InUserSpace, - IN OUT gctSIZE_T * Bytes, - OUT gctPHYS_ADDR * Physical, - OUT gctPOINTER * Logical - ) -{ - - if (InUserSpace) - { - /* TODO: Make a separate OS call for allocating from shared memory pool. */ - *Logical = drv_shmpool_alloc_contiguous((gctUINT32)Physical, (gctHANDLE)Logical, *Bytes); - - if (*Logical == gcvNULL) - { - gcmkTRACE_ZONE(gcvLEVEL_INFO, - gcvZONE_OS, - "gckOS_AllocateNonPagedMemory: Out of memory."); - - *Bytes = 0; - return gcvSTATUS_OUT_OF_RESOURCES; - } - - /* Used to distinguish from memory allocated in kernel space. */ - *((gctUINT32*)Physical) = 0; - } - else - { - drv_mempool_alloc_contiguous(*Bytes, Physical, Logical); - - if (*Physical == gcvNULL || *Logical == gcvNULL) - { - gcmkTRACE_ZONE(gcvLEVEL_INFO, - gcvZONE_OS, - "gckOS_AllocateNonPagedMemory: Out of memory."); - - *Bytes = 0; - return gcvSTATUS_OUT_OF_RESOURCES; - } - } - - gcmkTRACE_ZONE(gcvLEVEL_INFO, - gcvZONE_OS, - "gckOS_AllocateNonPagedMemory: " - "Bytes->0x%x, Logical->0x%x Physical->0x%x\n", - (gctUINT32)*Bytes, - *Logical, - *Physical); - - /* Success. */ - return gcvSTATUS_OK; -} - -/******************************************************************************* -** -** gckOS_FreeNonPagedMemory -** -** Free previously allocated and mapped pages from non-paged memory. -** -** INPUT: -** -** gckOS Os -** Pointer to an gckOS object. -** -** gctSIZE_T Bytes -** Number of bytes allocated. -** -** gctPHYS_ADDR Physical -** Physical address of the allocated memory. -** -** gctPOINTER Logical -** Logical address of the allocated memory. -** -** OUTPUT: -** -** Nothing. -*/ -gceSTATUS gckOS_FreeNonPagedMemory( - IN gckOS Os, - IN gctSIZE_T Bytes, - IN gctPHYS_ADDR Physical, - IN gctPOINTER Logical - ) -{ - int rc; - - if (Physical) - { - rc = drv_mempool_free(Logical); - } - else - { - rc = drv_shmpool_free(Logical); - } - - if (rc == -1) - { - gcmkTRACE_ZONE(gcvLEVEL_INFO, - gcvZONE_OS, - "gckOS_FreeNonPagedMemory: " - "Unmap Failed Logical->0x%x, Bytes->%d, Physical->0x%x\n", - (gctUINT32)Logical, - Bytes, - (gctUINT32)Physical); - return gcvSTATUS_INVALID_ARGUMENT; - } - - gcmkTRACE_ZONE(gcvLEVEL_INFO, - gcvZONE_OS, - "gckOS_FreeNonPagedMemory: " - "Logical->0x%x Physical->0x%x\n", - (gctUINT32)Logical, - (gctUINT32)Physical); - - /* Success. */ - return gcvSTATUS_OK; -} - -/******************************************************************************* -** -** gckOS_ReadRegister -** -** Read data from a register. -** -** INPUT: -** -** gckOS Os -** Pointer to an gckOS object. -** -** gctUINT32 Address -** Address of register. -** -** OUTPUT: -** -** gctUINT32 * Data -** Pointer to a variable that receives the data read from the register. -*/ -gceSTATUS gckOS_ReadRegister( - IN gckOS Os, - IN gctUINT32 Address, - OUT gctUINT32 * Data - ) -{ - /* Verify the arguments. */ - gcmkVERIFY_OBJECT(Os, gcvOBJ_OS); - gcmkVERIFY_ARGUMENT(Data != NULL); - - *Data = (gctUINT32)in32((uintptr_t) ((gctUINT8 *)Os->device->registerBase + Address)); - - /* Success. */ - return gcvSTATUS_OK; -} - -/******************************************************************************* -** -** gckOS_WriteRegister -** -** Write data to a register. -** -** INPUT: -** -** gckOS Os -** Pointer to an gckOS object. -** -** gctUINT32 Address -** Address of register. -** -** gctUINT32 Data -** Data for register. -** -** OUTPUT: -** -** Nothing. -*/ -gceSTATUS gckOS_WriteRegister( - IN gckOS Os, - IN gctUINT32 Address, - IN gctUINT32 Data - ) -{ - gcmkTRACE_ZONE(gcvLEVEL_INFO, - gcvZONE_OS, - "gckOS_WriteRegister: " - "Writing to physical address [%x] = %x\n", - (gctUINT8 *)Os->device->registerBase, - Data); - - out32((uintptr_t) ((gctUINT8 *)Os->device->registerBase + Address), (uint32_t)Data); - - /* Success. */ - return gcvSTATUS_OK; -} - -/******************************************************************************* -** -** gckOS_GetPageSize -** -** Get the system's page size. -** -** INPUT: -** -** gckOS Os -** Pointer to an gckOS object. -** -** OUTPUT: -** -** gctSIZE_T * PageSize -** Pointer to a variable that will receive the system's page size. -*/ -gceSTATUS gckOS_GetPageSize( - IN gckOS Os, - OUT gctSIZE_T * PageSize - ) -{ - /* Verify the arguments. */ - gcmkVERIFY_OBJECT(Os, gcvOBJ_OS); - gcmkVERIFY_ARGUMENT(PageSize != NULL); - - /* Return the page size. */ - *PageSize = (gctSIZE_T) __PAGESIZE; - - /* Success. */ - return gcvSTATUS_OK; -} - -/******************************************************************************* -** -** gckOS_GetPhysicalAddressProcess -** -** Get the physical system address of a corresponding virtual address for a -** given process. -** -** INPUT: -** -** gckOS Os -** Pointer to an gckOS object. -** -** gctPOINTER Logical -** Logical address. -** -** gctUINT ProcessID -** Procedd ID. -** -** OUTPUT: -** -** gctUINT32 * Address -** Poinetr to a variable that receives the 32-bit physical adress. -*/ -gceSTATUS -gckOS_GetPhysicalAddressProcess( - IN gckOS Os, - IN gctPOINTER Logical, - IN gctUINT ProcessID, - OUT gctUINT32 * Address - ) -{ - return gckOS_GetPhysicalAddress(Os, Logical, Address); -} - -/******************************************************************************* -** -** gckOS_GetPhysicalAddress -** -** Get the physical system address of a corresponding virtual address. -** -** INPUT: -** -** gckOS Os -** Pointer to an gckOS object. -** -** gctPOINTER Logical -** Logical address. -** -** OUTPUT: -** -** gctUINT32 * Address -** Pointer to a variable that receives the 32-bit physical adress. -*/ -gceSTATUS gckOS_GetPhysicalAddress( - IN gckOS Os, - IN gctPOINTER Logical, - OUT gctUINT32 * Address - ) -{ - - gctUINT32 res; - - /* Verify the arguments. */ - gcmkVERIFY_OBJECT(Os, gcvOBJ_OS); - gcmkVERIFY_ARGUMENT(Address != gcvNULL); - - if ( drv_mempool_mem_offset(Logical, Address) != gcvSTATUS_OK) - { - if ( drv_shmpool_mem_offset(Logical, Address) != gcvSTATUS_OK) - { - printf("Warning, using mem_offset for Logical:%x!\n", (gctUINT32) Logical); - - MEMORY_LOCK(Os); - - /* TODO: mem_offset in QNX works only for memory that is allocated - contiguosly using gckOS_AllocateContiguous(). */ - res = mem_offset( Logical, NOFD, 1, (off_t *)Address, NULL); - - if (res == -1) - { - MEMORY_UNLOCK(Os); - - gcmkTRACE_ZONE(gcvLEVEL_INFO, - gcvZONE_OS, - "gckOS_GetPhysicalAddress: " - "Unable to get physical address for 0x%x\n", - (gctUINT32)Logical); - - return gcvSTATUS_INVALID_ARGUMENT; - } - - MEMORY_UNLOCK(Os); - } - } - - /* Subtract base address to get a GPU physical address. */ - gcmASSERT(*Address >= Os->baseAddress); - *Address -= Os->baseAddress; - - gcmkTRACE_ZONE(gcvLEVEL_INFO, - gcvZONE_OS, - "gckOS_GetPhysicalAddress: Logical->0x%x Physical->0x%x\n", - (gctUINT32)Logical, - (gctUINT32)*Address); - - /* Success. */ - return gcvSTATUS_OK; -} - -/******************************************************************************* -** -** gckOS_MapPhysical -** -** Map a physical address into kernel space. -** -** INPUT: -** -** gckOS Os -** Pointer to an gckOS object. -** -** gctUINT32 Physical -** Physical address of the memory to map. -** -** gctSIZE_T Bytes -** Number of bytes to map. -** -** OUTPUT: -** -** gctPOINTER * Logical -** Pointer to a variable that receives the base address of the mapped -** memory. -*/ -gceSTATUS gckOS_MapPhysical( - IN gckOS Os, - IN gctUINT32 Physical, - IN gctSIZE_T Bytes, - OUT gctPOINTER * Logical - ) -{ - gctUINT32 physical; - - /* Verify the arguments. */ - gcmkVERIFY_OBJECT(Os, gcvOBJ_OS); - gcmkVERIFY_ARGUMENT(Bytes > 0); - gcmkVERIFY_ARGUMENT(Logical != gcvNULL); - - MEMORY_LOCK(Os); - - /* Compute true physical address (before subtraction of the baseAddress). */ - physical = Physical + Os->baseAddress; - - /* Map physical address. */ - *Logical = mmap64(0, - Bytes, - PROT_READ | PROT_WRITE, - MAP_PHYS | MAP_SHARED | MAP_NOINIT, - NOFD, - (off_t)physical); - - MEMORY_UNLOCK(Os); - - if (*Logical == MAP_FAILED) - { - gcmkTRACE_ZONE(gcvLEVEL_ERROR, - gcvZONE_OS, - "gckOS_MapMemory: mmap error: %s\n", - strerror(errno)); - - return gcvSTATUS_OUT_OF_MEMORY; - } - - gcmkTRACE_ZONE(gcvLEVEL_INFO, gcvZONE_OS, - "gckOS_MapPhysical: " - "Physical->0x%X Bytes->0x%X Logical->0x%X\n", - (gctUINT32) Physical, - (gctUINT32) Bytes, - (gctUINT32) *Logical); - - /* Success. */ - return gcvSTATUS_OK; -} - -/******************************************************************************* -** -** gckOS_UnmapPhysical -** -** Unmap a previously mapped memory region from kernel memory. -** -** INPUT: -** -** gckOS Os -** Pointer to an gckOS object. -** -** gctPOINTER Logical -** Pointer to the base address of the memory to unmap. -** -** gctSIZE_T Bytes -** Number of bytes to unmap. -** -** OUTPUT: -** -** Nothing. -*/ -gceSTATUS gckOS_UnmapPhysical( - IN gckOS Os, - IN gctPOINTER Logical, - IN gctSIZE_T Bytes - ) -{ - gctUINT32 res; - - /* Verify the arguments. */ - gcmkVERIFY_OBJECT(Os, gcvOBJ_OS); - gcmkVERIFY_ARGUMENT(Logical != NULL); - gcmkVERIFY_ARGUMENT(Bytes > 0); - - MEMORY_LOCK(Os); - - res = munmap(Logical, Bytes); - - MEMORY_UNLOCK(Os); - - if (res == -1) - { - gcmkTRACE_ZONE(gcvLEVEL_ERROR, - gcvZONE_OS, - "gckOS_UnmapMemory: munmap error: %s\n", - strerror(errno)); - - return gcvSTATUS_INVALID_ARGUMENT; - } - - gcmkTRACE_ZONE(gcvLEVEL_INFO, - gcvZONE_OS, - "gckOS_UnmapPhysical: " - "Logical->0x%x Bytes->0x%x\n", - (gctUINT32)Logical, - (gctUINT32)Bytes); - - /* Success. */ - return gcvSTATUS_OK; -} - -/******************************************************************************* -** -** gckOS_CreateMutex -** -** Create a new mutex. -** -** INPUT: -** -** gckOS Os -** Pointer to an gckOS object. -** -** OUTPUT: -** -** gctPOINTER * Mutex -** Pointer to a variable that will hold a pointer to the mutex. -*/ -gceSTATUS gckOS_CreateMutex( - IN gckOS Os, - OUT gctPOINTER * Mutex - ) -{ - gctUINT32 res; - - /* Validate the arguments. */ - gcmkVERIFY_OBJECT(Os, gcvOBJ_OS); - gcmkVERIFY_ARGUMENT(Mutex != NULL); - - /* Allocate a FAST_MUTEX structure. */ - *Mutex = (gctPOINTER) malloc(sizeof(pthread_mutex_t)); - - if (*Mutex == gcvNULL) - { - return gcvSTATUS_OUT_OF_MEMORY; - } - - /* Initialize the semaphore.. Come up in unlocked state. */ - res = pthread_mutex_init((pthread_mutex_t *)(*Mutex), NULL); - if (res != EOK) - { - return gcvSTATUS_OUT_OF_RESOURCES; - } - - /* Return status. */ - return gcvSTATUS_OK; -} - -/******************************************************************************* -** -** gckOS_DeleteMutex -** -** Delete a mutex. -** -** INPUT: -** -** gckOS Os -** Pointer to an gckOS object. -** -** gctPOINTER Mutex -** Pointer to the mute to be deleted. -** -** OUTPUT: -** -** Nothing. -*/ -gceSTATUS gckOS_DeleteMutex( - IN gckOS Os, - IN gctPOINTER Mutex - ) -{ - gctUINT32 res; - - /* Validate the arguments. */ - gcmkVERIFY_OBJECT(Os, gcvOBJ_OS); - gcmkVERIFY_ARGUMENT(Mutex != NULL); - - res = pthread_mutex_destroy((pthread_mutex_t *)(Mutex)); - - if (res != EOK) - { - return gcvSTATUS_INVALID_ARGUMENT; - } - - /* Delete the fast mutex. */ - free(Mutex); - - return gcvSTATUS_OK; -} - -/******************************************************************************* -** -** gckOS_AcquireMutex -** -** Acquire a mutex. -** -** INPUT: -** -** gckOS Os -** Pointer to an gckOS 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 -gckOS_AcquireMutex( - IN gckOS Os, - IN gctPOINTER Mutex, - IN gctUINT32 Timeout - ) -{ - /* Validate the arguments. */ - gcmkVERIFY_OBJECT(Os, gcvOBJ_OS); - gcmkVERIFY_ARGUMENT(Mutex != gcvNULL); - - if (Timeout == gcvINFINITE) - { - pthread_mutex_lock((pthread_mutex_t *) Mutex); - - /* Success. */ - return gcvSTATUS_OK; - } - - while (Timeout-- > 0) - { - /* Try to acquire the fast mutex. */ - if (!pthread_mutex_trylock((pthread_mutex_t *) Mutex)) - { - /* Success. */ - return gcvSTATUS_OK; - } - - /* Wait for 1 millisecond. */ - gcmkVERIFY_OK(gckOS_Delay(Os, 1)); - } - - /* Timeout. */ - return gcvSTATUS_TIMEOUT; -} - -/******************************************************************************* -** -** gckOS_ReleaseMutex -** -** Release an acquired mutex. -** -** INPUT: -** -** gckOS Os -** Pointer to an gckOS object. -** -** gctPOINTER Mutex -** Pointer to the mutex to be released. -** -** OUTPUT: -** -** Nothing. -*/ -gceSTATUS gckOS_ReleaseMutex( - IN gckOS Os, - IN gctPOINTER Mutex - ) -{ - /* Validate the arguments. */ - gcmkVERIFY_OBJECT(Os, gcvOBJ_OS); - gcmkVERIFY_ARGUMENT(Mutex != NULL); - - /* Release the fast mutex. */ - pthread_mutex_unlock((pthread_mutex_t *) Mutex); - - /* Success. */ - return gcvSTATUS_OK; -} - -/******************************************************************************* -** -** gckOS_AtomicExchange -** -** Atomically exchange a pair of 32-bit values. -** -** INPUT: -** -** gckOS Os -** Pointer to an gckOS object. -** -** IN OUT gctINT32_PTR Target -** Pointer to the 32-bit value to exchange. -** -** IN gctINT32 NewValue -** Specifies a new value for the 32-bit value pointed to by Target. -** -** OUT gctINT32_PTR OldValue -** The old value of the 32-bit value pointed to by Target. -** -** OUTPUT: -** -** Nothing. -*/ -gceSTATUS -gckOS_AtomicExchange( - IN gckOS Os, - IN OUT gctUINT32_PTR Target, - IN gctUINT32 NewValue, - OUT gctUINT32_PTR OldValue - ) -{ - /* Verify the arguments. */ - gcmkVERIFY_OBJECT(Os, gcvOBJ_OS); - - /* Acquire atomic operation lock. */ - gcmkVERIFY_OK(gckOS_AcquireMutex(Os, - Os->atomicOperationLock, - gcvINFINITE)); - - /* Exchange the pair of 32-bit values. */ - *OldValue = *Target; - *Target = NewValue; - - gcmkVERIFY_OK(gckOS_ReleaseMutex(Os, Os->atomicOperationLock)); - - /* Success. */ - return gcvSTATUS_OK; -} - - -/******************************************************************************* -** -** gckOS_AtomicExchangePtr -** -** Atomically exchange a pair of pointers. -** -** INPUT: -** -** gckOS Os -** Pointer to an gckOS object. -** -** IN OUT gctPOINTER * Target -** Pointer to the 32-bit value to exchange. -** -** IN gctPOINTER NewValue -** Specifies a new value for the pointer pointed to by Target. -** -** OUT gctPOINTER * OldValue -** The old value of the pointer pointed to by Target. -** -** OUTPUT: -** -** Nothing. -*/ -gceSTATUS -gckOS_AtomicExchangePtr( - IN gckOS Os, - IN OUT gctPOINTER * Target, - IN gctPOINTER NewValue, - OUT gctPOINTER * OldValue - ) -{ - /* Verify the arguments. */ - gcmkVERIFY_OBJECT(Os, gcvOBJ_OS); - - /* Acquire atomic operation lock. */ - gcmkVERIFY_OK(gckOS_AcquireMutex(Os, - Os->atomicOperationLock, - gcvINFINITE)); - - /* Exchange the pair of pointers. */ - *OldValue = *Target; - *Target = NewValue; - - gcmkVERIFY_OK(gckOS_ReleaseMutex(Os, Os->atomicOperationLock)); - - /* Success. */ - return gcvSTATUS_OK; -} - - -/******************************************************************************* -** -** gckOS_Delay -** -** Delay execution of the current thread for a number of milliseconds. -** -** INPUT: -** -** gckOS Os -** Pointer to an gckOS object. -** -** gctUINT32 Delay -** Delay to sleep, specified in milliseconds. -** -** OUTPUT: -** -** Nothing. -*/ -gceSTATUS gckOS_Delay( - IN gckOS Os, - IN gctUINT32 Delay - ) -{ - /* Schedule delay. */ - delay(Delay); - - /* Success. */ - return gcvSTATUS_OK; -} - -/******************************************************************************* -** -** gckOS_MemoryBarrier -** -** Make sure the CPU has executed everything up to this point and the data got -** written to the specified pointer. -** -** INPUT: -** -** gckOS Os -** Pointer to an gckOS object. -** -** gctPOINTER Address -** Address of memory that needs to be barriered. -** -** OUTPUT: -** -** Nothing. -*/ -gceSTATUS gckOS_MemoryBarrier( - IN gckOS Os, - IN gctPOINTER Address - ) -{ - /* Verify thearguments. */ - gcmkVERIFY_OBJECT(Os, gcvOBJ_OS); - - __cpu_membarrier(); - - /* Success. */ - return gcvSTATUS_OK; -} - -/******************************************************************************* -** -** gckOS_AllocatePagedMemory -** -** Allocate memory from the paged pool. -** -** INPUT: -** -** gckOS Os -** Pointer to an gckOS object. -** -** gctSIZE_T Bytes -** Number of bytes to allocate. -** -** OUTPUT: -** -** gctPHYS_ADDR * Physical -** Pointer to a variable that receives the physical address of the -** memory allocation. -*/ -gceSTATUS -gckOS_AllocatePagedMemory( - IN gckOS Os, - IN gctSIZE_T Bytes, - OUT gctPHYS_ADDR * Physical - ) -{ - return gckOS_AllocatePagedMemoryEx(Os, gcvFALSE, Bytes, Physical); -} - -/******************************************************************************* -** -** gckOS_AllocatePagedMemoryEx -** -** Allocate memory from the paged pool. -** -** INPUT: -** -** gckOS Os -** Pointer to an gckOS object. -** -** gctBOOL Contiguous -** Need contiguous memory or not. -** -** gctSIZE_T Bytes -** Number of bytes to allocate. -** -** OUTPUT: -** -** gctPHYS_ADDR * Physical -** Pointer to a variable that receives the physical address of the -** memory allocation. -*/ -gceSTATUS gckOS_AllocatePagedMemoryEx( - IN gckOS Os, - IN gctBOOL Contiguous, - IN gctSIZE_T Bytes, - OUT gctPHYS_ADDR * Physical - ) -{ - int rc, fd, shm_ctl_flags = SHMCTL_ANON | SHMCTL_LAZYWRITE; - - /* Verify the arguments. */ - gcmkVERIFY_OBJECT(Os, gcvOBJ_OS); - gcmkVERIFY_ARGUMENT(Bytes > 0); - gcmkVERIFY_ARGUMENT(Physical != NULL); - - gcmkTRACE_ZONE(gcvLEVEL_INFO, - gcvZONE_OS, - "in gckOS_AllocatePagedMemory\n"); - - if (Contiguous) - { - shm_ctl_flags |= SHMCTL_PHYS; - } - - /* Lock down, to avoid opening same shm file twice. */ - MEMORY_LOCK(Os); - - fd = shm_open("shm_gal", O_RDWR | O_CREAT, 0777); - if (fd == -1) { - printf("shm_open failed. error %s\n", strerror( errno ) ); - return gcvSTATUS_GENERIC_IO; - } - - /* Free to use the same name for next create shm object after shm_unlink. */ - shm_unlink("shm_gal"); - - MEMORY_UNLOCK(Os); - - /* Special flags for this shm, to make it write buffered. */ - /* Virtual memory doesn't need to be physically contiguous. */ - /* Allocations would be page aligned. */ - rc = shm_ctl_special(fd, - SHMCTL_ANON /*| SHMCTL_PHYS*/ | SHMCTL_LAZYWRITE, - 0, - Bytes, - 0x9); - if (rc == -1) { - printf("shm_ctl_special failed. error %s\n", strerror( errno ) ); - close(fd); - return gcvSTATUS_OUT_OF_MEMORY; - } - - /* Use the fd as the handle for the physical memory just allocated. */ - *Physical = (gctPHYS_ADDR) fd; - - gcmkTRACE_ZONE(gcvLEVEL_INFO, - gcvZONE_OS, - "gckOS_AllocatePagedMemory: " - "Bytes->0x%x, Physical->0x%x\n", - (gctUINT32)Bytes, - (gctUINT32)*Physical); - - /* Success. */ - return gcvSTATUS_OK; -} - -/******************************************************************************* -** -** gckOS_FreePagedMemory -** -** Free memory allocated from the paged pool. -** -** INPUT: -** -** gckOS Os -** Pointer to an gckOS object. -** -** gctPHYS_ADDR Physical -** Physical address of the allocation. -** -** gctSIZE_T Bytes -** Number of bytes of the allocation. -** -** OUTPUT: -** -** Nothing. -*/ -gceSTATUS gckOS_FreePagedMemory( - IN gckOS Os, - IN gctPHYS_ADDR Physical, - IN gctSIZE_T Bytes - ) -{ - int rc; - - /* Verify the arguments. */ - gcmkVERIFY_OBJECT(Os, gcvOBJ_OS); - gcmkVERIFY_ARGUMENT(Physical != NULL); - - gcmkTRACE_ZONE(gcvLEVEL_INFO, - gcvZONE_OS, - "in gckOS_FreePagedMemory\n"); - - rc = close((gctINT)Physical); - if ( rc == -1 ) - { - printf("gckOS_FreePagedMemory failed. error: %s\n", strerror( errno ) ); - return gcvSTATUS_GENERIC_IO; - } - - /* Success. */ - return gcvSTATUS_OK; -} - -/******************************************************************************* -** -** gckOS_LockPages -** -** Lock memory allocated from the paged pool. -** -** INPUT: -** -** gckOS Os -** Pointer to an gckOS object. -** -** gctPHYS_ADDR Physical -** Physical address of the allocation. -** -** gctSIZE_T Bytes -** Number of bytes of the allocation. -** -** OUTPUT: -** -** gctPOINTER * Logical -** Pointer to a variable that receives the address of the mapped -** memory. -** -** gctSIZE_T * PageCount -** Pointer to a variable that receives the number of pages required for -** the page table. -*/ -gceSTATUS gckOS_LockPages( - IN gckOS Os, - IN gctPHYS_ADDR Physical, - IN gctSIZE_T Bytes, - IN gctUINT32 Pid, - OUT gctPOINTER * Logical, - OUT gctSIZE_T * PageCount - ) -{ - void* addr; - - /* Verify the arguments. */ - gcmkVERIFY_OBJECT(Os, gcvOBJ_OS); - gcmkVERIFY_ARGUMENT(Physical != NULL); - gcmkVERIFY_ARGUMENT(Logical != NULL); - gcmkVERIFY_ARGUMENT(PageCount != NULL); - gcmkVERIFY_ARGUMENT(Bytes > 0); - - gcmkTRACE_ZONE(gcvLEVEL_INFO, - gcvZONE_OS, - "in gckOS_LockPages\n"); - - /* Map this memory inside user and galcore. */ - addr = mmap64_join(Pid, - 0, - Bytes, - PROT_READ | PROT_WRITE, - MAP_SHARED, - (int)Physical, - 0); - - if (addr == MAP_FAILED) - { - printf("gckOS_LockPages: couldn't map memory of size %d, Pid: %x [errno %s]", - (gctUINT32)Bytes, Pid, strerror( errno ) ); - return gcvSTATUS_GENERIC_IO; - } - - /* TODO: MLOCK may or may not be needed!. */ - mlock((void*)addr, Bytes); - - *Logical = (gctPOINTER)addr; - *PageCount = (gcmALIGN(Bytes, __PAGESIZE)) / __PAGESIZE; - - gcmkTRACE_ZONE(gcvLEVEL_INFO, - gcvZONE_OS, - "gckOS_LockPages: " - "gctPHYS_ADDR->0x%x Bytes->0x%x Logical->0x%x pid->%d\n", - (gctUINT32)Physical, - (gctUINT32)Bytes, - (gctUINT32)*Logical, - Pid); - - /* Success. */ - return gcvSTATUS_OK; -} - -/******************************************************************************* -** -** gckOS_MapPages -** -** Map paged memory into a page table. -** -** INPUT: -** -** gckOS Os -** Pointer to an gckOS object. -** -** gctPHYS_ADDR Physical -** Physical address of the allocation. -** -** gctSIZE_T PageCount -** Number of pages required for the physical address. -** -** gctPOINTER PageTable -** Pointer to the page table to fill in. -** -** OUTPUT: -** -** Nothing. -*/ -gceSTATUS -gckOS_MapPages( - IN gckOS Os, - IN gctPHYS_ADDR Physical, - IN gctPOINTER Logical, - IN gctSIZE_T PageCount, - IN gctPOINTER PageTable - ) -{ - gctUINT32* table; - gctPOINTER addr; - size_t contigLen = 0; - off_t offset; - gctUINT32 bytes; - int rc; - - /* Verify the arguments. */ - gcmkVERIFY_OBJECT(Os, gcvOBJ_OS); - gcmkVERIFY_ARGUMENT(Physical != NULL); - gcmkVERIFY_ARGUMENT(PageCount > 0); - gcmkVERIFY_ARGUMENT(PageTable != NULL); - - gcmkTRACE_ZONE(gcvLEVEL_INFO, - gcvZONE_OS, - "in gckOS_MapPages\n"); - - gcmkTRACE_ZONE(gcvLEVEL_INFO, - gcvZONE_OS, - "gckOS_MapPages: " - "Physical->0x%x PageCount->0x%x Logical->0x%x\n", - (gctUINT32)Physical, - (gctUINT32)PageCount, - (gctUINT32)Logical); - - addr = Logical; - table = (gctUINT32 *)PageTable; - bytes = PageCount * __PAGESIZE; - - /* Try to get the user pages so DMA can happen. */ - while (PageCount > 0) - { - /* fd should be NOFD here, to get physical address. */ - rc = mem_offset( addr, NOFD, bytes, &offset, &contigLen); - if (rc == -1) { - printf("gckOS_MapPages: mem_offset failed: %s\n", strerror( errno ) ); - return gcvSTATUS_GENERIC_IO; - } - - gcmASSERT(contigLen > 0); - - while(contigLen > 0) - { - *table++ = (gctUINT32) offset; - offset += 4096; - addr += 4096; - contigLen -= 4096; - bytes -= 4096; - PageCount--; - } - } - - /* Success. */ - return gcvSTATUS_OK; -} - -/******************************************************************************* -** -** gckOS_UnlockPages -** -** Unlock memory allocated from the paged pool. -** -** INPUT: -** -** gckOS Os -** Pointer to an gckOS object. -** -** gctPHYS_ADDR Physical -** Physical address of the allocation. -** -** gctSIZE_T Bytes -** Number of bytes of the allocation. -** -** gctPOINTER Logical -** Address of the mapped memory. -** -** OUTPUT: -** -** Nothing. -*/ -gceSTATUS gckOS_UnlockPages( - IN gckOS Os, - IN gctPHYS_ADDR Physical, - IN gctUINT32 Pid, - IN gctSIZE_T Bytes, - IN gctPOINTER Logical - ) -{ - int rc = 0; - - /* Verify the arguments. */ - gcmkVERIFY_OBJECT(Os, gcvOBJ_OS); - gcmkVERIFY_ARGUMENT(Physical != NULL); - gcmkVERIFY_ARGUMENT(Logical != NULL); - - gcmkTRACE_ZONE(gcvLEVEL_INFO, - gcvZONE_OS, - "in gckOS_UnlockPages\n"); - - gcmkTRACE_ZONE(gcvLEVEL_INFO, - gcvZONE_OS, - "gckOS_MapPages: " - "Physical->0x%x Bytes->0x%x Logical->0x%x Pid->0x%x\n", - (gctUINT32)Physical, - (gctUINT32)Bytes, - (gctUINT32)Logical, - (gctUINT32)Pid); - - rc = munmap((void*)Logical, Bytes); - if (rc == -1) { - printf("munmap failed: %s\n", strerror( errno ) ); - return gcvSTATUS_GENERIC_IO; - } - - rc = munmap_peer(Pid, (void*)Logical, Bytes); - if (rc == -1) { - printf("munmap_peer failed: %s\n", strerror( errno ) ); - return gcvSTATUS_GENERIC_IO; - } - - /* Success. */ - return gcvSTATUS_OK; -} - - -/******************************************************************************* -** -** gckOS_AllocateContiguous -** -** Allocate memory from the contiguous pool. -** -** INPUT: -** -** gckOS Os -** Pointer to an gckOS object. -** -** gctBOOL InUserSpace -** gcvTRUE if the pages need to be mapped into user space. -** -** gctSIZE_T * Bytes -** Pointer to the number of bytes to allocate. -** -** OUTPUT: -** -** gctSIZE_T * Bytes -** Pointer to a variable that receives the number of bytes allocated. -** -** gctPHYS_ADDR * Physical -** Pointer to a variable that receives the physical address of the -** memory allocation. -** -** gctPOINTER * Logical -** Pointer to a variable that receives the logical address of the -** memory allocation. -*/ -gceSTATUS gckOS_AllocateContiguous( - IN gckOS Os, - IN gctBOOL InUserSpace, - IN OUT gctSIZE_T * Bytes, - OUT gctPHYS_ADDR * Physical, - OUT gctPOINTER * Logical - ) -{ - /* Same as non-paged memory for now. */ - return gckOS_AllocateNonPagedMemory(Os, - InUserSpace, - Bytes, - Physical, - Logical - ); -} - -/******************************************************************************* -** -** gckOS_FreeContiguous -** -** Free memory allocated from the contiguous pool. -** -** INPUT: -** -** gckOS Os -** Pointer to an gckOS object. -** -** gctPHYS_ADDR Physical -** Physical address of the allocation. -** -** gctPOINTER Logical -** Logicval address of the allocation. -** -** gctSIZE_T Bytes -** Number of bytes of the allocation. -** -** OUTPUT: -** -** Nothing. -*/ -gceSTATUS gckOS_FreeContiguous( - IN gckOS Os, - IN gctPHYS_ADDR Physical, - IN gctPOINTER Logical, - IN gctSIZE_T Bytes - ) -{ - /* Same of non-paged memory for now. */ - return gckOS_FreeNonPagedMemory(Os, Bytes, Physical, Logical); -} - -/****************************************************************************** -** -** gckOS_GetKernelLogical -** -** Return the kernel logical pointer that corresponds to the specified -** hardware address. -** -** INPUT: -** -** gckOS Os -** Pointer to an gckOS object. -** -** gctUINT32 Address -** Hardware physical address. -** -** OUTPUT: -** -** gctPOINTER * KernelPointer -** Pointer to a variable receiving the pointer in kernel address space. -*/ -gceSTATUS -gckOS_GetKernelLogical( - IN gckOS Os, - IN gctUINT32 Address, - OUT gctPOINTER * KernelPointer - ) -{ - gceSTATUS status; - - do - { - gckGALDEVICE device; - gckKERNEL kernel; - gcePOOL pool; - gctUINT32 offset; - gctPOINTER logical; - - /* Extract the pointer to the gckGALDEVICE class. */ - device = (gckGALDEVICE) Os->device; - - /* Kernel shortcut. */ - kernel = device->kernel; - - /* Split the memory address into a pool type and offset. */ - gcmkERR_BREAK(gckHARDWARE_SplitMemory( - kernel->hardware, Address, &pool, &offset - )); - - /* Dispatch on pool. */ - switch (pool) - { - case gcvPOOL_LOCAL_INTERNAL: - /* Internal memory. */ - logical = device->internalLogical; - break; - - case gcvPOOL_LOCAL_EXTERNAL: - /* External memory. */ - logical = device->externalLogical; - break; - - case gcvPOOL_SYSTEM: - /* System memory. */ - logical = device->contiguousBase; - break; - - default: - /* Invalid memory pool. */ - return gcvSTATUS_INVALID_ARGUMENT; - } - - /* Build logical address of specified address. */ - * KernelPointer = ((gctUINT8_PTR) logical) + offset; - - /* Success. */ - return gcvSTATUS_OK; - } - while (gcvFALSE); - - /* Return status. */ - return status; -} - -/******************************************************************************* -** -** gckOS_MapUserPointer -** -** Map a pointer from the user process into the kernel address space. -** -** INPUT: -** -** gckOS Os -** Pointer to an gckOS object. -** -** gctPOINTER Pointer -** Pointer in user process space that needs to be mapped. -** -** gctSIZE_T Size -** Number of bytes that need to be mapped. -** -** OUTPUT: -** -** gctPOINTER * KernelPointer -** Pointer to a variable receiving the mapped pointer in kernel address -** space. -*/ -gceSTATUS -gckOS_MapUserPointer( - IN gckOS Os, - IN gctPOINTER Pointer, - IN gctSIZE_T Size, - OUT gctPOINTER * KernelPointer - ) -{ - /* A pointer is assumed to be allocated from its shared memory object. - Which is mapped by both user and kernel at the same vitual address. */ - /* TODO: Check if Pointer is a valid pointer? */ - *KernelPointer = Pointer; - - return gcvSTATUS_OK; -} - -/******************************************************************************* -** -** gckOS_UnmapUserPointer -** -** Unmap a user process pointer from the kernel address space. -** -** INPUT: -** -** gckOS Os -** Pointer to an gckOS object. -** -** gctPOINTER Pointer -** Pointer in user process space that needs to be unmapped. -** -** gctSIZE_T Size -** Number of bytes that need to be unmapped. -** -** gctPOINTER KernelPointer -** Pointer in kernel address space that needs to be unmapped. -** -** OUTPUT: -** -** Nothing. -*/ -gceSTATUS -gckOS_UnmapUserPointer( - IN gckOS Os, - IN gctPOINTER Pointer, - IN gctSIZE_T Size, - IN gctPOINTER KernelPointer - ) -{ - /* Nothing to unmap. */ - return gcvSTATUS_OK; -} - -/******************************************************************************* -** -** gckOS_MapUserPhysical -** -** Map a physical address from the user process into the kernel address space. -** The physical address should be obtained by user from gckOS_AllocateNonPagedMemory. -** -** INPUT: -** -** gckOS Os -** Pointer to an gckOS object. -** -** IN gctPHYS_ADDR Phys, -** Physical address of memory that needs to be mapped. -** -** OUTPUT: -** -** gctPHYS_ADDR * KernelPointer -** Pointer to a variable receiving the mapped pointer in kernel address -** space. -*/ -gceSTATUS -gckOS_MapUserPhysical( - IN gckOS Os, - IN gctPHYS_ADDR Phys, - OUT gctPHYS_ADDR * KernelPointer - ) -{ - /* A gctPHYS_ADDR is assumed to be allocated from physical memory pool. */ - /* Dont call this function for pointers already in kernel space. */ - printf("ERROR: %s Not supported.\n", __FUNCTION__); - *KernelPointer = (gctPHYS_ADDR)0xDEADBEEF; - - return gcvSTATUS_NOT_SUPPORTED; -} - - -/******************************************************************************* -** -** gckOS_WriteMemory -** -** Write data to a memory. -** -** INPUT: -** -** gckOS Os -** Pointer to an gckOS object. -** -** gctPOINTER Address -** Address of the memory to write to. -** -** gctUINT32 Data -** Data for register. -** -** OUTPUT: -** -** Nothing. -*/ -gceSTATUS -gckOS_WriteMemory( - IN gckOS Os, - IN gctPOINTER Address, - IN gctUINT32 Data - ) -{ - /* Verify the arguments. */ - gcmkVERIFY_ARGUMENT(Address != NULL); - - /* Write memory. */ - *(gctUINT32 *)Address = Data; - - /* Success. */ - return gcvSTATUS_OK; -} - -/******************************************************************************* -** -** gckOS_CreateSignal -** -** Create a new signal. -** -** INPUT: -** -** gckOS Os -** Pointer to an gckOS object. -** -** gctBOOL ManualReset -** If set to gcvTRUE, gckOS_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 gckOS_WaitSignal function. -** Nonsignaled state in QNX is mutex acquired (not free). -** -** OUTPUT: -** -** gctSIGNAL * Signal -** Pointer to a variable receiving the created gctSIGNAL. -*/ -gceSTATUS -gckOS_CreateSignal( - IN gckOS Os, - IN gctBOOL ManualReset, - OUT gctSIGNAL * Signal - ) -{ - gcskSIGNAL_PTR signal; - gceSTATUS status; - - gcmkHEADER_ARG("Os=0x%x ManualReset=0x%x", Os, ManualReset); - - /* Verify the arguments. */ - gcmkVERIFY_OBJECT(Os, gcvOBJ_OS); - gcmkVERIFY_ARGUMENT(Signal != NULL); - - /* Create an event structure. */ - signal = (gcskSIGNAL_PTR) malloc(sizeof(gcskSIGNAL)); - - if (signal == gcvNULL) - { - gcmFOOTER_NO(); - return gcvSTATUS_OUT_OF_MEMORY; - } - - signal->manualReset = ManualReset; - - status = gckOS_CreateMutex(Os, (gctPOINTER *)(&signal->mutex)); - - if (gcmIS_ERROR(status)) - { - /* Error. */ - free(signal); - gcmFOOTER(); - return status; - } - - *Signal = (gctSIGNAL) signal; - - /* Success. */ - gcmkFOOTER_ARG("Os=0x%x Signal=0x%x", Os, Signal); - return gcvSTATUS_OK; - -} - -/******************************************************************************* -** -** gckOS_DestroySignal -** -** Destroy a signal. -** -** INPUT: -** -** gckOS Os -** Pointer to an gckOS object. -** -** gctSIGNAL Signal -** Pointer to the gctSIGNAL. -** -** OUTPUT: -** -** Nothing. -*/ -gceSTATUS -gckOS_DestroySignal( - IN gckOS Os, - IN gctSIGNAL Signal - ) -{ - - gceSTATUS status = gcvSTATUS_OK; - gcskSIGNAL_PTR signal; - - gcmkHEADER_ARG("Os=0x%x Signal=0x%x", Os, Signal); - - /* Verify the arguments. */ - gcmkVERIFY_OBJECT(Os, gcvOBJ_OS); - gcmkVERIFY_ARGUMENT(Signal != NULL); - - signal = (gcskSIGNAL_PTR) Signal; - - /* Verify the arguments. */ - gcmkVERIFY_OBJECT(Os, gcvOBJ_OS); - gcmkVERIFY_ARGUMENT(Signal != NULL); - - if (signal != gcvNULL ) - { - status = gckOS_DeleteMutex(Os, (gctPOINTER)(signal->mutex)); - - free(signal); - } - - /* Success. */ - gcmkFOOTER_NO(); - return status; -} - -/******************************************************************************* -** -** gckOS_Signal -** -** Set a state of the specified signal. -** -** INPUT: -** -** gckOS Os -** Pointer to an gckOS 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 -gckOS_Signal( - IN gckOS Os, - IN gctSIGNAL Signal, - IN gctBOOL State - ) -{ - gcskSIGNAL_PTR signal; - gceSTATUS status = gcvSTATUS_OK; - - gcmkHEADER_ARG("Os=0x%x Signal=0x%x State=%d", Os, Signal, State); - - /* Verify the arguments. */ - gcmkVERIFY_OBJECT(Os, gcvOBJ_OS); - gcmkVERIFY_ARGUMENT(Signal != gcvNULL); - - signal = (gcskSIGNAL_PTR) Signal; - - /* Set the new state of the event. */ - if (signal->manualReset && State) - { - /* Set the event to a signaled state. */ - gckOS_ReleaseMutex(Os,(gctPOINTER *)(&signal->mutex)); - } - else - { - gckOS_AcquireMutex(Os, (gctPOINTER *)(&signal->mutex), gcvINFINITE); - } - - /* Success. */ - gcmkFOOTER_NO(); - return status; -} - -/******************************************************************************* -** -** gckOS_UserSignal -** -** Set the specified signal which is owned by a process to signaled state. -** -** INPUT: -** -** gckOS Os -** Pointer to an gckOS object. -** -** gctSIGNAL Signal -** Pointer to the gctSIGNAL. -** -** gctHANDLE Process -** Handle of process owning the signal. -** -** OUTPUT: -** -** Nothing. -*/ -gceSTATUS -gckOS_UserSignal( - IN gckOS Os, - IN gctSIGNAL Signal, - IN gctINT Rcvid, - IN gctINT Coid - ) -{ - gctINT rc; - struct sigevent event; - - SIGEV_PULSE_INIT( &event, Coid, SIGEV_PULSE_PRIO_INHERIT, _PULSE_CODE_MINAVAIL, Signal); - - rc = MsgDeliverEvent_r(Rcvid, &event); - if (rc != EOK) - { - gcmkTRACE(gcvLEVEL_INFO, - "%s(%d): Sent signal to (receive ID = %d, connect ID = %d).", - __FUNCTION__, __LINE__, Rcvid, Coid); - - gcmkTRACE(gcvLEVEL_ERROR, - "%s(%d): MsgDeliverEvent failed (%d).", - __FUNCTION__, __LINE__, rc); - -; - - return gcvSTATUS_GENERIC_IO; - } - - /* Return status. */ - return gcvSTATUS_OK; -} - -/******************************************************************************* -** -** gckOS_WaitSignal -** -** Wait for a signal to become signaled. -** -** INPUT: -** -** gckOS Os -** Pointer to an gckOS 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 -gckOS_WaitSignal( - IN gckOS Os, - IN gctSIGNAL Signal, - IN gctUINT32 Wait - ) -{ - gceSTATUS status = gcvSTATUS_OK; - - gcskSIGNAL_PTR signal; - - /* Verify the arguments. */ - gcmkVERIFY_OBJECT(Os, gcvOBJ_OS); - gcmkVERIFY_ARGUMENT(Signal != gcvNULL); - - signal = (gcskSIGNAL_PTR) Signal; - - status = gckOS_AcquireMutex(Os, (gctPOINTER *)(&signal->mutex), Wait); - - /* If manualReset is true, use gckOS_Signal to acquire mutex again. */ - if (signal->manualReset) - { - status = gckOS_ReleaseMutex(Os, (gctPOINTER *)(&signal->mutex)); - } - - /* Return status. */ - return status; -} - -/******************************************************************************* -** -** gckOS_MapSignal -** -** Map a signal in to the current process space. -** -** INPUT: -** -** gckOS Os -** Pointer to an gckOS object. -** -** gctSIGNAL Signal -** Pointer to tha gctSIGNAL to map. -** -** gctHANDLE Process -** Handle of process owning the signal. -** -** OUTPUT: -** -** gctSIGNAL * MappedSignal -** Pointer to a variable receiving the mapped gctSIGNAL. -*/ -gceSTATUS -gckOS_MapSignal( - IN gckOS Os, - IN gctSIGNAL Signal, - IN gctHANDLE Process, - OUT gctSIGNAL * MappedSignal - ) -{ - printf("ERROR: %s Not supported.\n", __FUNCTION__); - return gcvSTATUS_NOT_SUPPORTED; -} - -/******************************************************************************* -** -** gckOS_MapUserMemory -** -** Lock down a user buffer and return an DMA'able address to be used by the -** hardware to access it. -** -** INPUT: -** -** gctPOINTER Memory -** Pointer to memory to lock down. -** -** gctSIZE_T Size -** Size in bytes of the memory to lock down. -** -** OUTPUT: -** -** gctPOINTER * Info -** Pointer to variable receiving the information record required by -** gckOS_UnmapUserMemory. -** -** gctUINT32_PTR Address -** Pointer to a variable that will receive the address DMA'able by the -** hardware. -*/ -gceSTATUS -gckOS_MapUserMemory( - IN gckOS Os, - IN gctPOINTER Memory, - IN gctSIZE_T Size, - OUT gctPOINTER * Info, - OUT gctUINT32_PTR Address - ) -{ - /* Verify the arguments. */ - gcmkVERIFY_OBJECT(Os, gcvOBJ_OS); - gcmkVERIFY_ARGUMENT(Memory != gcvNULL); - gcmkVERIFY_ARGUMENT(Size > 0); - gcmkVERIFY_ARGUMENT(Info != gcvNULL); - gcmkVERIFY_ARGUMENT(Address != gcvNULL); - - gcmkTRACE_ZONE(gcvLEVEL_VERBOSE, - gcvZONE_OS, - "[gckOS_MapUserMemory] enter.\n" - ); - - printf("ERROR: %s Not supported.\n", __FUNCTION__); - - gcmkTRACE_ZONE(gcvLEVEL_VERBOSE, - gcvZONE_OS, - "[gckOS_MapUserMemory] leave.\n" - ); - - /* Return the status. */ - return gcvSTATUS_NOT_SUPPORTED; -} - -/******************************************************************************* -** -** gckOS_UnmapUserMemory -** -** Unlock a user buffer and that was previously locked down by -** gckOS_MapUserMemory. -** -** INPUT: -** -** gctPOINTER Memory -** Pointer to memory to unlock. -** -** gctSIZE_T Size -** Size in bytes of the memory to unlock. -** -** gctPOINTER Info -** Information record returned by gckOS_MapUserMemory. -** -** gctUINT32_PTR Address -** The address returned by gckOS_MapUserMemory. -** -** OUTPUT: -** -** Nothing. -*/ -gceSTATUS -gckOS_UnmapUserMemory( - IN gckOS Os, - IN gctPOINTER Memory, - IN gctSIZE_T Size, - IN gctPOINTER Info, - IN gctUINT32 Address - ) -{ - /* Verify the arguments. */ - gcmkVERIFY_OBJECT(Os, gcvOBJ_OS); - gcmkVERIFY_ARGUMENT(Memory != gcvNULL); - gcmkVERIFY_ARGUMENT(Size > 0); - gcmkVERIFY_ARGUMENT(Info != gcvNULL); - - gcmkTRACE_ZONE(gcvLEVEL_VERBOSE, - gcvZONE_OS, - "[gckOS_UnmapUserMemory] enter.\n" - ); - - printf("ERROR: %s Not supported.\n", __FUNCTION__); - - /* Return the status. */ - return gcvSTATUS_NOT_SUPPORTED; -} - -/******************************************************************************* -** -** gckOS_GetBaseAddress -** -** Get the base address for the physical memory. -** -** INPUT: -** -** gckOS Os -** Pointer to the gckOS object. -** -** OUTPUT: -** -** gctUINT32_PTR BaseAddress -** Pointer to a variable that will receive the base address. -*/ -gceSTATUS -gckOS_GetBaseAddress( - IN gckOS Os, - OUT gctUINT32_PTR BaseAddress - ) -{ - /* Verify the arguments. */ - gcmkVERIFY_OBJECT(Os, gcvOBJ_OS); - gcmkVERIFY_ARGUMENT(BaseAddress != gcvNULL); - - /* Return base address. */ - *BaseAddress = Os->baseAddress; - - /* Success. */ - return gcvSTATUS_OK; -} - -gceSTATUS -gckOS_SuspendInterrupt( - IN gckOS Os - ) -{ - /* Verify the arguments. */ - gcmkVERIFY_OBJECT(Os, gcvOBJ_OS); - - InterruptLock(&Os->device->isrLock); - - return gcvSTATUS_OK; -} - -gceSTATUS -gckOS_ResumeInterrupt( - IN gckOS Os - ) -{ - /* Verify the arguments. */ - gcmkVERIFY_OBJECT(Os, gcvOBJ_OS); - - InterruptUnlock(&Os->device->isrLock); - - return gcvSTATUS_OK; -} - -gceSTATUS -gckOS_NotifyIdle( - IN gckOS Os, - IN gctBOOL Idle - ) -{ - /* TODO */ - return gcvSTATUS_OK; -} - -/* Perform a memory copy. */ -gceSTATUS -gckOS_MemCopy( - IN gctPOINTER Destination, - IN gctCONST_POINTER Source, - IN gctSIZE_T Bytes - ) -{ - gcmkVERIFY_ARGUMENT(Destination != NULL); - gcmkVERIFY_ARGUMENT(Source != NULL); - gcmkVERIFY_ARGUMENT(Bytes > 0); - - memcpy(Destination, Source, Bytes); - - return gcvSTATUS_OK; -} - -/******************************************************************************* -** -** gckOS_AllocateNonPagedMemory -** -** Allocate a number of pages from non-paged memory. -** -** INPUT: -** -** gckOS Os -** Pointer to an gckOS object. -** -** gctBOOL InUserSpace -** gcvTRUE if the pages need to be mapped into user space. -** -** gctSIZE_T * Bytes -** Pointer to a variable that holds the number of bytes to allocate. -** -** OUTPUT: -** -** gctSIZE_T * Bytes -** Pointer to a variable that hold the number of bytes allocated. -** -** gctPHYS_ADDR * Physical -** Pointer to a variable that will hold the physical address of the -** allocation. -** -** gctPOINTER * Logical -** Pointer to a variable that will hold the logical address of the -** allocation. -*/ -gceSTATUS -gckOS_AllocateNonPagedMemoryShmPool( - IN gckOS Os, - IN gctBOOL InUserSpace, - IN gctUINT32 Pid, - IN gctHANDLE Handle, - IN OUT gctSIZE_T * Bytes, - OUT gctPHYS_ADDR * Physical, - OUT gctPOINTER * Logical - ) -{ - - if (InUserSpace) - { - *Logical = drv_shmpool_alloc_contiguous(Pid, Handle, *Bytes); - - if (*Logical == gcvNULL) - { - gcmkTRACE_ZONE(gcvLEVEL_INFO, - gcvZONE_OS, - "gckOS_AllocateNonPagedMemory: Out of memory."); - - *Bytes = 0; - return gcvSTATUS_OUT_OF_RESOURCES; - } - - /* Used to distinguish from memory allocated in kernel space. */ - *((gctUINT32*)Physical) = 0; - } - else - { - return gcvSTATUS_INVALID_ARGUMENT; - } - - gcmkTRACE_ZONE(gcvLEVEL_INFO, - gcvZONE_OS, - "gckOS_AllocateNonPagedMemoryShmPool: " - "Bytes->0x%x, Logical->0x%x Physical->0x%x\n", - (gctUINT32)*Bytes, - *Logical, - *Physical); - - /* Success. */ - return gcvSTATUS_OK; -} - -int -memmgr_peer_sendnc(pid_t pid, int coid, void *smsg, size_t sbytes, void *rmsg, size_t rbytes ) -{ - mem_peer_t peer; - iov_t siov[2]; - int rc; - - peer.i.type = _MEM_PEER; - peer.i.peer_msg_len = sizeof(peer); - peer.i.pid = pid; - - SETIOV(siov + 0, &peer, sizeof peer); - SETIOV(siov + 1, smsg, sbytes); - - do { - rc = MsgSendvsnc(coid, siov, 2, rmsg, rbytes); - } while (rc == -1 && errno == EINTR); - - return rc; -} - -void * -_mmap2_peer(pid_t pid, void *addr, size_t len, int prot, int flags, int fd, off64_t off, - unsigned align, unsigned pre_load, void **base, size_t *size) { - mem_map_t msg; - - msg.i.type = _MEM_MAP; - msg.i.zero = 0; - msg.i.addr = (uintptr_t)addr; - msg.i.len = len; - msg.i.prot = prot; - msg.i.flags = flags; - msg.i.fd = fd; - msg.i.offset = off; - msg.i.align = align; - msg.i.preload = pre_load; - msg.i.reserved1 = 0; - if (memmgr_peer_sendnc(pid, MEMMGR_COID, &msg.i, sizeof msg.i, &msg.o, sizeof msg.o) == -1) { - return MAP_FAILED; - } - if (base) { - *base = (void *)(uintptr_t)msg.o.real_addr; - } - if (size) { - *size = msg.o.real_size; - } - return (void *)(uintptr_t)msg.o.addr; -} - -void * -mmap64_peer(pid_t pid, void *addr, size_t len, int prot, int flags, int fd, off64_t off) { - return _mmap2_peer(pid, addr, len, prot, flags, fd, off, 0, 0, 0, 0); -} - -int -munmap_flags_peer(pid_t pid, void *addr, size_t len, unsigned flags) { - mem_ctrl_t msg; - - msg.i.type = _MEM_CTRL; - msg.i.subtype = _MEM_CTRL_UNMAP; - msg.i.addr = (uintptr_t)addr; - msg.i.len = len; - msg.i.flags = flags; - return memmgr_peer_sendnc(pid, MEMMGR_COID, &msg.i, sizeof msg.i, 0, 0); -} - -int -munmap_peer(pid_t pid, void *addr, size_t len) { - return munmap_flags_peer(pid, addr, len, 0); -} - -int -mem_offset64_peer(pid_t pid, const uintptr_t addr, size_t len, - off64_t *offset, size_t *contig_len) { - int rc; - - struct _peer_mem_off { - struct _mem_peer peer; - struct _mem_offset msg; - }; - typedef union { - struct _peer_mem_off i; - struct _mem_offset_reply o; - } memoffset_peer_t; - memoffset_peer_t msg; - - msg.i.peer.type = _MEM_PEER; - msg.i.peer.peer_msg_len = sizeof(msg.i.peer); - msg.i.peer.pid = pid; - msg.i.peer.reserved1 = 0; - - msg.i.msg.type = _MEM_OFFSET; - msg.i.msg.subtype = _MEM_OFFSET_PHYS; - msg.i.msg.addr = addr; - msg.i.msg.reserved = -1; - msg.i.msg.len = len; - - do { - rc = MsgSendnc(MEMMGR_COID, &msg.i, sizeof msg.i, &msg.o, sizeof msg.o); - } while (rc == -1 && errno == EINTR); - - if (rc == -1) { - return -1; - } - - *offset = msg.o.offset; - *contig_len = msg.o.size; - - return 0; -} - -#if defined(__X86__) -#define CPU_VADDR_SERVER_HINT 0x30000000u -#elif defined(__ARM__) -#define CPU_VADDR_SERVER_HINT 0x20000000u -#else -#error NO CPU SOUP FOR YOU! -#endif - -/* - * map the object into both client and server at the same virtual address - */ -void * -mmap64_join(pid_t pid, void *addr, size_t len, int prot, int flags, int fd, off64_t off) { - void *svaddr, *cvaddr = MAP_FAILED; - uintptr_t hint = (uintptr_t)addr; - uintptr_t start_hint = hint; - - if ( hint == (uintptr_t)0 ) - { - hint = (uintptr_t)CPU_VADDR_SERVER_HINT; - } - - do { - svaddr = mmap64( (void *)hint, len, prot, flags, fd, off ); - if ( svaddr == MAP_FAILED ) { - break; - } - if ( svaddr == cvaddr ) { - return svaddr; - } - - cvaddr = mmap64_peer( pid, svaddr, len, prot, MAP_FIXED | flags, fd, off ); - if ( cvaddr == MAP_FAILED ) { - break; - } - if ( svaddr == cvaddr ) { - return svaddr; - } - - if ( munmap( svaddr, len ) == -1 ) { - svaddr = MAP_FAILED; - break; - } - - svaddr = mmap64( cvaddr, len, prot, flags, fd, off ); - if ( svaddr == MAP_FAILED ) { - break; - } - if ( svaddr == cvaddr ) { - return svaddr; - } - - if ( munmap( svaddr, len ) == -1 ) { - svaddr = MAP_FAILED; - break; - } - if ( munmap_peer( pid, cvaddr, len ) == -1 ) { - cvaddr = MAP_FAILED; - break; - } - hint += __PAGESIZE; - - } while(hint != start_hint); /* do we really want to wrap all the way */ - - if ( svaddr != MAP_FAILED ) { - munmap( svaddr, len ); - } - if ( cvaddr != MAP_FAILED ) { - munmap_peer( pid, cvaddr, len ); - } - - return MAP_FAILED; -} - -/******************************************************************************* -** gckOS_CacheFlush -** -** Flush 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: -** -** gckOS Os -** Pointer to gckOS object. -** -** gctHANDLE Process -** Process handle Logical belongs to or gcvNULL if Logical belongs to -** the kernel. -** -** gctPOINTER Logical -** Logical address to flush. -** -** gctSIZE_T Bytes -** Size of the address range in bytes to flush. -*/ -gceSTATUS -gckOS_CacheFlush( - IN gckOS Os, - IN gctHANDLE Process, - IN gctPOINTER Logical, - IN gctSIZE_T Bytes - ) -{ - return gcvSTATUS_OK; -} - -/******************************************************************************* -** gckOS_CacheInvalidate -** -** 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: -** -** gckOS Os -** Pointer to gckOS object. -** -** gctHANDLE Process -** Process handle Logical belongs to or gcvNULL if Logical belongs to -** the kernel. -** -** gctPOINTER Logical -** Logical address to flush. -** -** gctSIZE_T Bytes -** Size of the address range in bytes to flush. -*/ -gceSTATUS -gckOS_CacheInvalidate( - IN gckOS Os, - IN gctHANDLE Process, - IN gctPOINTER Logical, - IN gctSIZE_T Bytes - ) -{ - return gcvSTATUS_OK; -} - -/******************************************************************************* -** Broadcast interface. -*/ - -gceSTATUS -gckOS_Broadcast( - IN gckOS Os, - IN gckHARDWARE Hardware, - IN gceBROADCAST Reason - ) -{ - return gcvSTATUS_OK; -} - diff --git a/drivers/staging/rk29/vivante/hal/os/qnx/kernel/gc_hal_kernel_os.h b/drivers/staging/rk29/vivante/hal/os/qnx/kernel/gc_hal_kernel_os.h deleted file mode 100644 index 3f112ecc0af0..000000000000 --- a/drivers/staging/rk29/vivante/hal/os/qnx/kernel/gc_hal_kernel_os.h +++ /dev/null @@ -1,163 +0,0 @@ -/**************************************************************************** -* -* Copyright (c) 2005 - 2010 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. -* -***************************************************************************** -* -* Auto-generated file on 12/8/2010. Do not edit!!! -* -*****************************************************************************/ - - - - - -/* - * Os.h - * - * Created on: Feb 2, 2010 - * Author: Tarang Vaish - */ - -#ifndef __gc_hal_kernel_os_h_ -#define __gc_hal_kernel_os_h_ - -typedef struct -{ - io_msg_t iomsg; - gcsHAL_INTERFACE iface; -} gcsDRIVER_ARGS; - -struct _gckPAGE_USAGE -{ - gctUINT16 pageCount; -}; - -struct _gckSHM_POOL -{ - gctHANDLE Handle; - gctINT32 fd; - gctUINT32 pid; - gctUINT32 freePage; - gctUINT32 pageCount; - gctUINT32 pageSize; - pthread_mutex_t mutex; - gctUINT32 Logical; - gctUINT32 Physical; - struct _gckPAGE_USAGE* pageUsage; - struct _gckSHM_POOL* nextPool; -}; - -typedef struct _gckSHM_POOL* gckSHM_POOL; -typedef struct _gckPAGE_USAGE* gckPAGE_USAGE; - -gceSTATUS -drv_mempool_init(); - -void -drv_mempool_destroy(); - -void -drv_mempool_alloc_contiguous( - IN gctUINT32 Bytes, - OUT gctPHYS_ADDR * Physical, - OUT gctPOINTER * Logical - ); - -int -drv_mempool_free( - IN gctPOINTER Logical - ); - -gctUINT32 -drv_mempool_get_baseAddress(); - -gctUINT32 -drv_mempool_get_basePAddress(); - -gctUINT32 -drv_mempool_get_page_size(); - -gctINT -drv_mempool_get_fileDescriptor(); - -gceSTATUS -drv_mempool_mem_offset( - IN gctPOINTER Logical, - OUT gctUINT32 * Address); - -/* Shared memory pool functions. */ -gckSHM_POOL drv_shmpool_create( - IN gctUINT32 Pid, - IN gctHANDLE Handle, - IN gctUINT32 PoolSize, - IN gctUINT32 PageSize); -void -drv_shmpool_destroy( - IN gckSHM_POOL ShmPool); - -gckSHM_POOL -drv_shm_acquire_pool( - IN gctUINT32 Pid, - IN gctHANDLE Handle - ); - -gckSHM_POOL -drv_shm_acquire_pool2( - IN gctPOINTER Logical - ); - -gceSTATUS -drv_shm_remove_pool( - IN gctHANDLE Handle - ); - -gctUINT32 -drv_shmpool_get_BaseAddress( - IN gckSHM_POOL ShmPool - ); - -gctUINT32 -drv_shmpool_get_page_size( - IN gckSHM_POOL ShmPool - ); - -gceSTATUS -drv_shmpool_mem_offset( - IN gctPOINTER Logical, - OUT gctUINT32 * Address); - -gctPOINTER -drv_shmpool_alloc_contiguous( - IN gctUINT32 Pid, - IN gctHANDLE Handle, - IN gctUINT32 Bytes - ); - -gctUINT32 -drv_shmpool_free( - IN gctPOINTER Logical - ); - -void * -mmap64_join(pid_t pid, void *addr, size_t len, int prot, int flags, int fd, off64_t off); - -int -mem_offset64_peer(pid_t pid, const uintptr_t addr, size_t len, - off64_t *offset, size_t *contig_len); - -int -munmap_peer(pid_t pid, void *addr, size_t len); - -void * -mmap64_peer(pid_t pid, void *addr, size_t len, int prot, int flags, int fd, off64_t off); - -#endif /* __gc_hal_kernel_os_h_ */ - - diff --git a/drivers/staging/rk29/vivante/hal/os/qnx/kernel/gc_hal_kernel_qnx.c b/drivers/staging/rk29/vivante/hal/os/qnx/kernel/gc_hal_kernel_qnx.c deleted file mode 100644 index 837500429d63..000000000000 --- a/drivers/staging/rk29/vivante/hal/os/qnx/kernel/gc_hal_kernel_qnx.c +++ /dev/null @@ -1,401 +0,0 @@ -/**************************************************************************** -* -* Copyright (c) 2005 - 2010 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. -* -***************************************************************************** -* -* Auto-generated file on 12/8/2010. Do not edit!!! -* -*****************************************************************************/ - - - - -#include "gc_hal_kernel_qnx.h" - -#define _GC_OBJ_ZONE gcvZONE_KERNEL - -/******************************************************************************\ -******************************* gckKERNEL API Code ****************************** -\******************************************************************************/ - -/******************************************************************************* -** -** gckKERNEL_QueryVideoMemory -** -** Query the amount of video memory. -** -** INPUT: -** -** gckKERNEL Kernel -** Pointer to an gckKERNEL object. -** -** OUTPUT: -** -** gcsHAL_INTERFACE * Interface -** Pointer to an gcsHAL_INTERFACE structure that will be filled in with -** the memory information. -*/ -gceSTATUS -gckKERNEL_QueryVideoMemory( - IN gckKERNEL Kernel, - OUT gcsHAL_INTERFACE * Interface - ) -{ - gckGALDEVICE device; - - gcmkHEADER_ARG("Kernel=0x%x", Kernel); - - /* Verify the arguments. */ - gcmkVERIFY_OBJECT(Kernel, gcvOBJ_KERNEL); - gcmkVERIFY_ARGUMENT(Interface != NULL); - - /* Extract the pointer to the gckGALDEVICE class. */ - device = (gckGALDEVICE) Kernel->context; - - /* Get internal memory size and physical address. */ - Interface->u.QueryVideoMemory.internalSize = device->internalSize; - Interface->u.QueryVideoMemory.internalPhysical = device->internalPhysical; - - /* Get external memory size and physical address. */ - Interface->u.QueryVideoMemory.externalSize = device->externalSize; - Interface->u.QueryVideoMemory.externalPhysical = device->externalPhysical; - - /* Get contiguous memory size and physical address. */ - Interface->u.QueryVideoMemory.contiguousSize = device->contiguousSize; - Interface->u.QueryVideoMemory.contiguousPhysical = device->contiguousPhysical; - - /* Success. */ - gcmkFOOTER_NO(); - return gcvSTATUS_OK; -} - -/******************************************************************************* -** -** gckKERNEL_GetVideoMemoryPool -** -** Get the gckVIDMEM object belonging to the specified pool. -** -** INPUT: -** -** gckKERNEL Kernel -** Pointer to an gckKERNEL object. -** -** gcePOOL Pool -** Pool to query gckVIDMEM object for. -** -** OUTPUT: -** -** gckVIDMEM * VideoMemory -** Pointer to a variable that will hold the pointer to the gckVIDMEM -** object belonging to the requested pool. -*/ -gceSTATUS -gckKERNEL_GetVideoMemoryPool( - IN gckKERNEL Kernel, - IN gcePOOL Pool, - OUT gckVIDMEM * VideoMemory - ) -{ - gckGALDEVICE device; - gckVIDMEM videoMemory; - - gcmkHEADER_ARG("Kernel=0x%x Pool=0x%x", Kernel, Pool); - - /* Verify the arguments. */ - gcmkVERIFY_OBJECT(Kernel, gcvOBJ_KERNEL); - gcmkVERIFY_ARGUMENT(VideoMemory != NULL); - - /* Extract the pointer to the gckGALDEVICE class. */ - device = (gckGALDEVICE) Kernel->context; - - /* Dispatch on pool. */ - switch (Pool) - { - case gcvPOOL_LOCAL_INTERNAL: - /* Internal memory. */ - videoMemory = device->internalVidMem; - break; - - case gcvPOOL_LOCAL_EXTERNAL: - /* External memory. */ - videoMemory = device->externalVidMem; - break; - - case gcvPOOL_SYSTEM: - /* System memory. */ - videoMemory = device->contiguousVidMem; - break; - - default: - /* Unknown pool. */ - videoMemory = NULL; - } - - /* Return pointer to the gckVIDMEM object. */ - *VideoMemory = videoMemory; - - /* Return status. */ - gcmkFOOTER_ARG("*VideoMemory=0x%x", *VideoMemory); - return (videoMemory == NULL) ? gcvSTATUS_OUT_OF_MEMORY : gcvSTATUS_OK; -} - -/******************************************************************************* -** -** gckKERNEL_MapMemory -** -** Map video memory into the current process space. -** -** INPUT: -** -** gckKERNEL Kernel -** Pointer to an gckKERNEL object. -** -** gctPHYS_ADDR Physical -** Physical address of video memory to map. -** -** gctSIZE_T Bytes -** Number of bytes to map. -** -** OUTPUT: -** -** gctPOINTER * Logical -** Pointer to a variable that will hold the base address of the mapped -** memory region. -*/ -gceSTATUS -gckKERNEL_MapMemory( - IN gckKERNEL Kernel, - IN gctPHYS_ADDR Physical, - IN gctSIZE_T Bytes, - OUT gctPOINTER * Logical - ) -{ - return gckOS_MapMemory(Kernel->os, Physical, Bytes, Logical); -} - -/******************************************************************************* -** -** gckKERNEL_UnmapMemory -** -** Unmap video memory from the current process space. -** -** INPUT: -** -** gckKERNEL Kernel -** Pointer to an gckKERNEL object. -** -** gctPHYS_ADDR Physical -** Physical address of video memory to map. -** -** gctSIZE_T Bytes -** Number of bytes to map. -** -** gctPOINTER Logical -** Base address of the mapped memory region. -** -** OUTPUT: -** -** Nothing. -*/ -gceSTATUS -gckKERNEL_UnmapMemory( - IN gckKERNEL Kernel, - IN gctPHYS_ADDR Physical, - IN gctSIZE_T Bytes, - IN gctPOINTER Logical - ) -{ - return gckOS_UnmapMemory(Kernel->os, Physical, Bytes, Logical); -} - -/******************************************************************************* -** -** gckKERNEL_MapVideoMemory -** -** Map video memory for the current process. -** -** INPUT: -** -** gckKERNEL Kernel -** Pointer to an gckKERNEL object. -** -** gctBOOL InUserSpace -** gcvTRUE to map the memory into the user space. -** -** gctUINT32 Address -** Hardware specific memory address. -** -** gctUINT32 Pid -** Process ID of the current process. -** -** gctUINT32 Bytes -** Number of bytes to map. -** -** OUTPUT: -** -** gctPOINTER * Logical -** Pointer to a variable that will hold the logical address of the -** specified memory address. -*/ -gceSTATUS -gckKERNEL_MapVideoMemory( - IN gckKERNEL Kernel, - IN gctBOOL InUserSpace, - IN gctUINT32 Address, - IN gctUINT32 Pid, - IN gctUINT32 Bytes, - OUT gctPOINTER * Logical - ) -{ - off64_t offset = (off64_t)Address - (off64_t)drv_mempool_get_basePAddress(); - - gcmkHEADER_ARG("Kernel=0x%x InUserSpace=%d Address=%08x", - Kernel, InUserSpace, Address); - - /* Verify the arguments. */ - gcmkVERIFY_OBJECT(Kernel, gcvOBJ_KERNEL); - - *Logical = (gctPOINTER)mmap64_peer(Pid, gcvNULL, Bytes, - PROT_READ | PROT_WRITE, MAP_SHARED | MAP_NOINIT, - drv_mempool_get_fileDescriptor(), offset); - if (*Logical == MAP_FAILED) { - *Logical = NULL; - return gcvSTATUS_INVALID_ADDRESS; - } - - /* Success. */ - return gcvSTATUS_OK; -} - -/******************************************************************************* -** -** gckKERNEL_UnmapVideoMemory -** -** Unmap video memory for the current process. -** -** INPUT: -** -** gckKERNEL Kernel -** Pointer to an gckKERNEL object. -** -** gctUINT32 Address -** Hardware specific memory address. -** -** gctUINT32 Pid -** Process ID of the current process. -** -** gctUINT32 Bytes -** Number of bytes to map. -** -** OUTPUT: -** -** Nothing. -*/ -gceSTATUS -gckKERNEL_UnmapVideoMemory( - IN gckKERNEL Kernel, - IN gctPOINTER Logical, - IN gctUINT32 Pid, - IN gctUINT32 Bytes - ) -{ - /* Verify the arguments. */ - gcmkVERIFY_OBJECT(Kernel, gcvOBJ_KERNEL); - - if (munmap_peer(Pid, Logical, Bytes) == -1) - { - return gcvSTATUS_INVALID_ADDRESS; - } - - /* Success. */ - return gcvSTATUS_OK; -} - -/******************************************************************************* -** -** gckKERNEL_Notify -** -** This function is called by clients to notify the gckKERNEL object of an event. -** -** INPUT: -** -** gckKERNEL Kernel -** Pointer to an gckKERNEL object. -** -** gceNOTIFY Notification -** Notification event. -** -** OUTPUT: -** -** Nothing. -*/ -gceSTATUS -gckKERNEL_Notify( - IN gckKERNEL Kernel, - IN gceNOTIFY Notification, - IN gctBOOL Data - ) -{ - gceSTATUS status; - - gcmkHEADER_ARG("Kernel=0x%x Notification=%d Data=%d", - Kernel, Notification, Data); - - /* Verify the arguments. */ - gcmkVERIFY_OBJECT(Kernel, gcvOBJ_KERNEL); - - /* Dispatch on notifcation. */ - switch (Notification) - { - case gcvNOTIFY_INTERRUPT: - /* Process the interrupt. */ -#if COMMAND_PROCESSOR_VERSION > 1 - status = gckINTERRUPT_Notify(Kernel->interrupt, Data); -#else - status = gckHARDWARE_Interrupt(Kernel->hardware, Data); -#endif - break; - - default: - status = gcvSTATUS_OK; - break; - } - - /* Success. */ - gcmkFOOTER(); - return status; -} - -gceSTATUS -gckKERNEL_QuerySettings( - IN gckKERNEL Kernel, - OUT gcsKERNEL_SETTINGS * Settings - ) -{ - gckGALDEVICE device; - - gcmkHEADER_ARG("Kernel=0x%x", Kernel); - - /* Verify the arguments. */ - gcmkVERIFY_OBJECT(Kernel, gcvOBJ_KERNEL); - gcmkVERIFY_ARGUMENT(Settings != gcvNULL); - - /* Extract the pointer to the gckGALDEVICE class. */ - device = (gckGALDEVICE) Kernel->context; - - /* Fill in signal. */ - Settings->signal = -1; - - /* Success. */ - gcmkFOOTER_ARG("Settings->signal=%d", Settings->signal); - return gcvSTATUS_OK; -} - - diff --git a/drivers/staging/rk29/vivante/hal/os/qnx/kernel/gc_hal_kernel_qnx.h b/drivers/staging/rk29/vivante/hal/os/qnx/kernel/gc_hal_kernel_qnx.h deleted file mode 100644 index ef541d493b71..000000000000 --- a/drivers/staging/rk29/vivante/hal/os/qnx/kernel/gc_hal_kernel_qnx.h +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -* -* Copyright (c) 2005 - 2010 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. -* -***************************************************************************** -* -* Auto-generated file on 12/8/2010. Do not edit!!! -* -*****************************************************************************/ - - - - -#ifndef __gc_hal_kernel_qnx_h_ -#define __gc_hal_kernel_qnx_h_ - -#define _QNX_SOURCE - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define NTSTRSAFE_NO_CCH_FUNCTIONS -#include "gc_hal.h" -#include "gc_hal_driver.h" -#include "gc_hal_kernel.h" -#include "gc_hal_kernel_device.h" -#include "gc_hal_kernel_os.h" -#include "../inc/gc_hal_common_qnx.h" - -#define _WIDE(string) L##string -#define WIDE(string) _WIDE(string) - -#define countof(a) (sizeof(a) / sizeof(a[0])) - -#ifndef GAL_DEV -#define GAL_DEV "/dev/galcore" -#endif - -#endif /* __gc_hal_kernel_qnx_h_ */ - diff --git a/drivers/staging/rk29/vivante/hal/os/qnx/kernel/makefile.linux b/drivers/staging/rk29/vivante/hal/os/qnx/kernel/makefile.linux deleted file mode 100644 index 64ac37551804..000000000000 --- a/drivers/staging/rk29/vivante/hal/os/qnx/kernel/makefile.linux +++ /dev/null @@ -1,78 +0,0 @@ -############################################################################## -# -# Copyright (c) 2005 - 2010 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. -# -############################################################################## -# -# Auto-generated file on 12/17/2010. Do not edit!!! -# -############################################################################## - - -# -# Qnx build file for kernel HAL layer. -# - -################################################################################ -# Include common definitions. - -include $(AQROOT)/makefile.linux.def - -################################################################################ -# Define a shortcut for the main target. - -#ifeq ($(STATIC_LINK),1) - STATIC = 1 -#else - DYNAMIC = 1 -#endif -PROGRAM := 1 - -#ifeq ($(STATIC), 1) - TARGET_NAME = galcore.a -#else - TARGET_NAME = galcore -#endif - -################################################################################ -# Installation directory -INSTALL_DIR := $(SDK_DIR)/drivers - -################################################################################ -# Supply additional include directories. - -INCLUDE += -I$(AQROOT)/hal/inc -INCLUDE += -I$(AQROOT)/hal/user -INCLUDE += -I$(AQROOT)/hal/kernel -INCLUDE += -I$(AQARCH)/hal/kernel -INCLUDE += -I$(AQARCH)/hal/kernel -CFLAGS += $(INCLUDE) -CFLAGS += -fPIC - -################################################################################ -# Supply necessary libraries. - -# Specify Vivante library paths. -LIBS += -L $(AQARCH)/hal/kernel/$(OBJ_DIR) -LIBS += -L $(AQROOT)/hal/kernel/$(OBJ_DIR) -LIBS += -l halarchkernel -l halkernel - -################################################################################ -# Describe object files. - -OBJECTS = \ - $(OBJ_DIR)/gc_hal_kernel_driver.o \ - $(OBJ_DIR)/gc_hal_kernel_os.o \ - $(OBJ_DIR)/gc_hal_kernel_qnx.o \ - $(OBJ_DIR)/gc_hal_kernel_device.o \ - $(OBJ_DIR)/gc_hal_kernel_debug.o \ - -include $(AQROOT)/common.target - - diff --git a/drivers/staging/rk29/vivante/hal/os/qnx/makefile.linux b/drivers/staging/rk29/vivante/hal/os/qnx/makefile.linux deleted file mode 100644 index 75a7a4e4fab3..000000000000 --- a/drivers/staging/rk29/vivante/hal/os/qnx/makefile.linux +++ /dev/null @@ -1,40 +0,0 @@ -############################################################################## -# -# Copyright (c) 2005 - 2010 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. -# -############################################################################## -# -# Auto-generated file on 12/17/2010. Do not edit!!! -# -############################################################################## - - -# -# QNX build file for the kernel level HAL libraries. -# - -################################################################################ -# Define make command. -MAKE = make --makefile=makefile.linux - - -################################################################################ -# Define build directories. - -HAL_KERNEL_DRV_ARCH := $(AQARCH)/hal/kernel -HAL_KERNEL_DRV_OS := $(AQROOT)/hal/os/qnx/kernel -HAL_KERNEL_DRV_MAIN := $(AQROOT)/hal/kernel - -$(HAL_KERNEL_DRV_OS): $(HAL_KERNEL_DRV_ARCH) $(HAL_KERNEL_DRV_MAIN) - -MODULES := $(HAL_KERNEL_DRV_ARCH) $(HAL_KERNEL_DRV_OS) $(HAL_KERNEL_DRV_MAIN) -MAIN_MODULE = $(HAL_KERNEL_DRV_OS) - -include $(AQROOT)/common.node - diff --git a/drivers/staging/rk29/vivante/hal/user/gc_hal_user_context.h b/drivers/staging/rk29/vivante/hal/user/gc_hal_user_context.h index d2c805e2c47f..430603554a14 100644 --- a/drivers/staging/rk29/vivante/hal/user/gc_hal_user_context.h +++ b/drivers/staging/rk29/vivante/hal/user/gc_hal_user_context.h @@ -1,21 +1,21 @@ /**************************************************************************** -* -* Copyright (C) 2005 - 2010 by Vivante Corp. -* +* +* Copyright (C) 2005 - 2011 by Vivante Corp. +* * 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., 675 Mass Ave, Cambridge, MA 02139, USA. -* +* *****************************************************************************/ @@ -167,4 +167,3 @@ struct _gcoQUEUE #endif #endif /* __gc_hal_user_context_h_ */ -