📄 jvm_runtime.c
字号:
{
length++;
} */
if (length <= 0)
{
return dst;
}
invalidPtrEnd = invalidPtr + (length << 5);
interruptMask = SaveAndSetIRQMask();
do
{
InvalidCodeCacheByAlignedAddr((kal_int32) invalidPtr);
invalidPtr += 32;
/*
* enable the interrupt a while to prevent precision problem for CTIRQ
* * (Every 256 cache-invaliations)
*/
if (((unsigned int)invalidPtr << 19) == 0)
{
#if defined(MT6228) || defined(MT6229)
*CACHE_OP = 9 | 0x10000; /* need to be modified */
*CACHE_OP = 9 | 0x20000;
*CACHE_OP = 9 | 0x40000;
*CACHE_OP = 9 | 0x80000;
#endif /* defined(MT6228) || defined(MT6229) */ /* #if defined(MT6228) || defined(MT6229) */
RestoreIRQMask(interruptMask);
interruptMask = SaveAndSetIRQMask();
}
} while ((kal_int32) invalidPtr < (kal_int32) invalidPtrEnd);
/*
* important for invalidation by address
* * this is a software work-around for solving L1 invalidation by address bug
*/
#if defined(MT6228) || defined(MT6229)
*CACHE_OP = 9 | 0x10000; /* need to be modified */
*CACHE_OP = 9 | 0x20000;
*CACHE_OP = 9 | 0x40000;
*CACHE_OP = 9 | 0x80000;
#endif /* defined(MT6228) || defined(MT6229) */ /* #if defined(MT6228) || defined(MT6229) */
RestoreIRQMask(interruptMask);
/* the bit 26 setting to on means bypassing the cache.
This will ensure the L2 will not cache the L1 cacheable area */
dst = (unsigned short*)((kal_int32) dst | 0x4000000);
#endif /* DATACACHE_FBBR_ON */
return dst;
}
/*****************************************************************************
* FUNCTION
* FBBR_invalid_l1_cache_img
* DESCRIPTION
*
* PARAMETERS
* dst [?]
* x_pos [IN]
* y_pos [IN]
* width [IN]
* height [IN]
* dst_width [IN]
* RETURNS
* void
*****************************************************************************/
void *FBBR_invalid_l1_cache_img(void *dst, int x_pos, int y_pos, int width, int height, int dst_width)
{
#if DATACACHE_FBBR_ON
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/* invalidating l1 cache entry starts here */
U8 *startPtr = (U8*) dst + ((y_pos * dst_width + x_pos) << 1);
kal_int32 lineWidth = width;
U8 *invalidPtr = (U8*) ((kal_int32) startPtr & (~0x1f));
kal_int32 width_count;
kal_int32 i, j;
kal_int32 interruptMask;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
/* make sure not use the function when FBBR not initilized */
/* if(!FBBR_initialized || (int)dst < (int)javaheap_space ||
(int)dst > (int)((char*)javaheap_space + javaheap_size)){
return dst;
} */
width_count = lineWidth >> 4;
if (startPtr != invalidPtr)
{
width_count++;
}
if ((startPtr + (width << 1)) > (invalidPtr + (width_count << 5)))
{
width_count++;
}
if (width_count <= 0)
{
return dst;
}
interruptMask = SaveAndSetIRQMask();
if ((width_count << 4) >= dst_width)
{
/* memset(invalidPtr - 5, 0x66, (dst_->width * height) << 1); */
U8 *invalidPtrEnd = invalidPtr + ((dst_width * height) << 1);
do
{
InvalidCodeCacheByAlignedAddr((kal_int32) invalidPtr);
invalidPtr += 32;
if (((unsigned int)invalidPtr << 19) == 0)
{
#if defined(MT6228) || defined(MT6229)
*CACHE_OP = 9 | 0x10000; /* need to be modified */
*CACHE_OP = 9 | 0x20000;
*CACHE_OP = 9 | 0x40000;
*CACHE_OP = 9 | 0x80000;
#endif /* defined(MT6228) || defined(MT6229) */ /* #if defined(MT6228) || defined(MT6229) */
RestoreIRQMask(interruptMask);
interruptMask = SaveAndSetIRQMask();
}
} while ((kal_int32) invalidPtr < (kal_int32) invalidPtrEnd);
}
else
{
if (width_count > 64)
{
int counter = 256;
for (i = 0; i < height; i++)
{
/* memset(invalidPtr - 5, 0x66, width_count << 5); */
for (j = 0; j < width_count; j++)
{
/* invalid l1 cache line */
// *CACHE_OP = ((((unsigned int)invalidPtr) << 19) >> 19) | 9 | 0x10000;
// *CACHE_OP = ((((unsigned int)invalidPtr) << 19) >> 19) | 9 | 0x20000;
// *CACHE_OP = ((((unsigned int)invalidPtr) << 19) >> 19) | 9 | 0x40000;
// *CACHE_OP = ((((unsigned int)invalidPtr) << 19) >> 19) | 9 | 0x80000;
InvalidCodeCacheByAlignedAddr((kal_int32) invalidPtr);
/* *CACHE_OP = (int)invalidPtr; */
invalidPtr += 32;
/*
* enable the interrupt a while to prevent precision problem for CTIRQ
* * (Every 256 cache-invaliations)
*/
if ((counter--) == 0)
{
counter = 256;
#if defined(MT6228) || defined(MT6229)
*CACHE_OP = 9 | 0x10000; /* need to be modified */
*CACHE_OP = 9 | 0x20000;
*CACHE_OP = 9 | 0x40000;
*CACHE_OP = 9 | 0x80000;
#endif /* defined(MT6228) || defined(MT6229) */ /* #if defined(MT6228) || defined(MT6229) */
RestoreIRQMask(interruptMask);
interruptMask = SaveAndSetIRQMask();
}
}
startPtr += (dst_width << 1);
invalidPtr = (U8*) ((kal_int32) startPtr & (~0x1F)) + 5;
}
}
else
{
int counter = 128;
for (i = 0; i < height; i++)
{
/* memset(invalidPtr - 5, 0x66, width_count << 5); */
for (j = 0; j < width_count; j++)
{
/* invalid l1 cache line */
// *CACHE_OP = ((((unsigned int)invalidPtr) << 19) >> 19) | 9 | 0x10000;
// *CACHE_OP = ((((unsigned int)invalidPtr) << 19) >> 19) | 9 | 0x20000;
// *CACHE_OP = ((((unsigned int)invalidPtr) << 19) >> 19) | 9 | 0x40000;
// *CACHE_OP = ((((unsigned int)invalidPtr) << 19) >> 19) | 9 | 0x80000;
InvalidCodeCacheByAlignedAddr((kal_int32) invalidPtr);
/* *CACHE_OP = (int)invalidPtr; */
invalidPtr += 32;
/*
* enable the interrupt a while to prevent precision problem for CTIRQ
* * (Every 64 cache-invaliations)
*/
counter--;
}
if ((counter--) <= 0)
{
counter = 128;
#if defined(MT6228) || defined(MT6229)
*CACHE_OP = 9 | 0x10000; /* need to be modified */
*CACHE_OP = 9 | 0x20000;
*CACHE_OP = 9 | 0x40000;
*CACHE_OP = 9 | 0x80000;
#endif /* defined(MT6228) || defined(MT6229) */ /* #if defined(MT6228) || defined(MT6229) */
RestoreIRQMask(interruptMask);
interruptMask = SaveAndSetIRQMask();
}
startPtr += (dst_width << 1);
invalidPtr = (U8*) ((kal_int32) startPtr & (~0x1F)) + 5;
}
}
}
/*
* important for invalidation by address
* * this is a software work-around for solving L1 invalidation by address bug
*/
#if defined(MT6228) || defined(MT6229)
*CACHE_OP = 9 | 0x10000; /* need to be modified */
*CACHE_OP = 9 | 0x20000;
*CACHE_OP = 9 | 0x40000;
*CACHE_OP = 9 | 0x80000;
#endif /* defined(MT6228) || defined(MT6229) */ /* #if defined(MT6228) || defined(MT6229) */
RestoreIRQMask(interruptMask);
/* the bit 26 setting to on means bypassing the cache.
This will ensure the L2 will not cache the L1 cacheable area */
dst = (unsigned short*)((kal_int32) dst | 0x4000000);
/* *CACHE_OP = 0x3; */
/* end of cache manipulation */
#endif /* DATACACHE_FBBR_ON */
return dst;
}
#if DATACACHE_FBBR_ON
#pragma arm section code
#endif
/*****************************************************************************
* FUNCTION
* jvm_recv_get_imsi_res
* DESCRIPTION
*
* PARAMETERS
* MsgStruct [?]
* RETURNS
* void
*****************************************************************************/
void jvm_recv_get_imsi_res(void *MsgStruct)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
mmi_java_get_imsi_res_struct *msg;
S32 i;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
msg = (mmi_java_get_imsi_res_struct*) MsgStruct;
jvm_imsi_error = msg->error;
for (i = 0; i < 17; i++)
{
jvm_imsi[i] = msg->imsi[i];
}
kal_set_eg_events(J2ME_general_event_group, J2ME_EG_GET_IMSI, KAL_OR);
}
/*****************************************************************************
* FUNCTION
* jvm_send_get_imsi_ind
* DESCRIPTION
* Send MSG_ID_MMI_JAVA_GET_IMSI_IND to MMI
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
void jvm_send_get_imsi_ind(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
ilm_struct *ilm_ptr;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
ilm_ptr = allocate_ilm(MOD_J2ME);
ilm_ptr->src_mod_id = MOD_J2ME;
ilm_ptr->dest_mod_id = MOD_MMI;
ilm_ptr->msg_id = MSG_ID_MMI_JAVA_GET_IMSI_IND;
ilm_ptr->local_para_ptr = NULL;
ilm_ptr->peer_buff_ptr = NULL;
msg_send_ext_queue(ilm_ptr);
}
/*****************************************************************************
* FUNCTION
* jvm_get_imsi_crc32
* DESCRIPTION
* get crc32 of IMSI
* PARAMETERS
* void
* RETURNS
* return the a integer which is crc32 of IMSI
* If there is no sim, we return 0xFFFFFFFF
*****************************************************************************/
kal_int32 jvm_get_imsi_crc32(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
kal_int32 imsi_crc32 = 0;
kal_uint32 event_group;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
jvm_send_get_imsi_ind();
kal_retrieve_eg_events(J2ME_general_event_group, J2ME_EG_GET_IMSI, KAL_OR_CONSUME, &event_group, KAL_SUSPEND);
if (jvm_imsi_error != J2ME_NO_ERROR)
{
imsi_crc32 = 0xFFFFFFFF;
}
else
{
imsi_crc32 = applib_crc_update(0, jvm_imsi, 17);
}
return imsi_crc32;
}
/*****************************************************************************
* FUNCTION
* jvm_get_imsi_mcc
* DESCRIPTION
* get mcc of SIM card
* (Mobile Country Code, the first 3 bytes of IMSI)
* PARAMETERS
* void
* RETURNS
* return NULL if fail
* return a uint8 array with size 3 back, caller should release
* this array by jvm_free
*****************************************************************************/
kal_uint8 *jvm_get_imsi_mcc(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
kal_uint8 *imsi_mcc = NULL;
kal_uint32 event_group;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
jvm_send_get_imsi_ind();
kal_retrieve_eg_events(J2ME_general_event_group, J2ME_EG_GET_IMSI, KAL_OR_CONSUME, &event_group, KAL_SUSPEND);
if (jvm_imsi_error != J2ME_NO_ERROR)
{
imsi_mcc = NULL;
}
else
{
imsi_mcc = jvm_malloc(4);
if (jvm_imsi[1] == '0')
{
if (jvm_imsi[2] == '0')
{
imsi_mcc[0] = jvm_imsi[3];
imsi_mcc[1] = 0;
}
else
{
imsi_mcc[0] = jvm_imsi[2];
imsi_mcc[1] = jvm_imsi[3];
imsi_mcc[2] = 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -