#include <linux/slab.h>
#include <linux/errno.h>
#include <linux/module.h>
+#include <linux/interrupt.h>
#include <asm/uaccess.h>
#include <bcm_map_part.h>
{
void *pBuf;
int tryCount = 0;
+ int allocType = GFP_KERNEL;
+
+ if( in_interrupt() )
+ {
+ allocType = GFP_ATOMIC;
+ tryCount = 999;
+ }
// try 1000 times before quit
- while (((pBuf = kmalloc(size, GFP_KERNEL)) == NULL) && (tryCount++ < 1000))
+ while (((pBuf = kmalloc(size, allocType)) == NULL) && (++tryCount < 1000))
{
current->state = TASK_INTERRUPTIBLE;
schedule_timeout(HZ/10);
if(memcmp(((PSP_HEADER)pBuf)->SPMagicNum, MAGIC_NUMBER, MAGIC_NUM_LEN) != 0)
{
printk("Scratch pad is not initialized.\n");
+ retriedKfree(pShareBuf);
return sts;
}
if (strncmp(pToken->tokenName, tokenId, TOKEN_NAME_LEN) == 0)
{
- sts = pToken->tokenLen;
+ if ( pToken->tokenLen > bufLen )
+ {
+ printk("The length %d of token %s is greater than buffer len %d.\n", pToken->tokenLen, pToken->tokenName, bufLen);
+ break;
+ } else
+ sts = pToken->tokenLen;
memcpy(tokBuf, startPtr + sizeof(SP_TOKEN), sts);
break;
}
}
+// wipe out the scratchPad
+// return:
+// 0 - ok
+// -1 - fail
+int kerSysScratchPadClearAll(void)
+{
+ int sts = -1;
+ char *pShareBuf = NULL;
+ char *pBuf = NULL;
+
+
+ if (fInfo.flash_scratch_pad_length == 0)
+ return sts;
+ if( (pShareBuf = getSharedBlks( fInfo.flash_scratch_pad_start_blk,
+ (fInfo.flash_scratch_pad_start_blk + fInfo.flash_scratch_pad_number_blk) )) == NULL )
+ return sts;
+ pBuf = pShareBuf + fInfo.flash_scratch_pad_blk_offset;
+ memset(pBuf, 0x00, fInfo.flash_scratch_pad_length);
+ sts = setSharedBlks(fInfo.flash_scratch_pad_start_blk,
+ (fInfo.flash_scratch_pad_number_blk + fInfo.flash_scratch_pad_start_blk), pShareBuf);
+
+ retriedKfree(pShareBuf);
+
+ return sts;
+}
+
int kerSysFlashSizeGet(void)
{
return flash_get_total_size();