util.c
来自「davinci的NANDFLASH烧写程序」· C语言 代码 · 共 63 行
C
63 行
/* --------------------------------------------------------------------------
FILE : util.c
PURPOSE : Utility and misc. file
PROJECT : DaVinci CCS NOR Flashing Utility
AUTHOR : Daniel Allred
DATE : 04-Jun-2007
HISTORY
v1.00 - DJA - 04-Jun-2007
Completion (with support for DM6441 and DM6441_LV)
----------------------------------------------------------------------------- */
#include "norwriter.h"
#include "dm644x.h"
#include "util.h"
// Memory allocation stuff
static VUint32 current_mem_loc;
extern VUint32 DDRStart;
// DDR Memory allocation routines (for storing large data)
Uint32 get_current_mem_loc()
{
return current_mem_loc;
}
void set_current_mem_loc(Uint32 value)
{
current_mem_loc = value;
}
void *ubl_alloc_mem (Uint32 size)
{
void *cPtr;
VUint8 *DDRMem;
Uint32 size_temp;
DDRMem = (void*) &DDRStart;
// Ensure word boundaries
size_temp = ((size + 4) >> 2 ) << 2;
if((current_mem_loc + size_temp) > (MAX_IMAGE_SIZE))
{
return 0;
}
cPtr = (void *) (DDRMem + current_mem_loc);
current_mem_loc += size_temp;
return cPtr;
}
// Simple wait loop - comes in handy.
void waitloop(Uint32 loopcnt)
{
Uint32 i;
for (i = 0; i<loopcnt; i++)
{
asm(" NOP");
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?