- flashgen: new bigendian target
Committed on the Free edition of March Hare Software CVSNT Server. Upgrade to CVS Suite for more features and support: http://march-hare.com/cvsnt/ git-svn-id: http://moon:8086/svn/vhdl/trunk@285 cc03376c-175c-47c8-b038-4cd826a8556b
This commit is contained in:
@@ -17,6 +17,36 @@
|
||||
#define SDRAM_BASE 0x40000000
|
||||
#define FLASH_OFFSET 0x00000000
|
||||
|
||||
UINT32 conv_endian32(UINT32 src)
|
||||
{
|
||||
UINT32 dst;
|
||||
|
||||
dst = (0xFF000000 & (src << 24))
|
||||
| (0x00FF0000 & (src << 8))
|
||||
| (0x0000FF00 & (src >> 8))
|
||||
| (0x000000FF & (src >> 24));
|
||||
|
||||
return dst;
|
||||
};
|
||||
|
||||
UINT32 to_big_endian32(UINT32 src)
|
||||
{
|
||||
#ifndef NATIVE_IS_BIG_ENDIAN
|
||||
return conv_endian32(src);
|
||||
#else
|
||||
return src;
|
||||
#endif
|
||||
}
|
||||
|
||||
UINT32 from_big_endian32(UINT32 src)
|
||||
{
|
||||
#ifndef NATIVE_IS_BIG_ENDIAN
|
||||
return conv_endian32(src);
|
||||
#else
|
||||
return src;
|
||||
#endif
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------
|
||||
typedef struct _sflash_img_hdr_t
|
||||
{
|
||||
@@ -102,11 +132,17 @@ int main(int argc, char *argv[])
|
||||
img_hdr.magic[1] = 'F';
|
||||
img_hdr.magic[2] = 'I';
|
||||
img_hdr.magic[3] = '1';
|
||||
#ifdef TARGET_IS_BIG_ENDIAN
|
||||
img_hdr.target_addr = to_big_endian32(SDRAM_BASE);
|
||||
img_hdr.img_size = to_big_endian32(filesize);
|
||||
img_hdr.img_offset = to_big_endian32(FLASH_OFFSET + sizeof(flash_img_hdr_t));
|
||||
img_hdr.hdr_next = to_big_endian32(FLASH_OFFSET);
|
||||
#else
|
||||
img_hdr.target_addr = SDRAM_BASE;
|
||||
img_hdr.img_size = filesize;
|
||||
img_hdr.img_offset = FLASH_OFFSET + sizeof(flash_img_hdr_t);
|
||||
img_hdr.hdr_next = FLASH_OFFSET;
|
||||
|
||||
#endif
|
||||
fwrite(&img_hdr, sizeof(flash_img_hdr_t), 1, pFile);
|
||||
fwrite(pBuf, 1, filesize, pFile);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user