mirror of
https://github.com/marqs85/ossc
synced 2026-10-31 20:27:17 +03:00
move bitswap inside epcq_controller driver
This commit is contained in:
1 parent
9777fe8e66
commit
055a794b5e
11 files changed
+7437
-7315
No files matched your search
File diff suppressed because it is too large.
Load diff
@@ -49,9 +49,6 @@ int read_flash(alt_u32 offset, alt_u32 length, alt_u8 *dstbuf)
|
||||
if (retval != 0)
|
||||
return -FLASH_READ_ERROR;
|
||||
|
||||
for (i=0; i<length; i++)
|
||||
dstbuf[i] = bitswap8(dstbuf[i]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -69,10 +66,6 @@ int write_flash_page(alt_u8 *pagedata, alt_u32 length, alt_u32 pagenum)
|
||||
}
|
||||
}
|
||||
|
||||
// Bit-reverse bytes for flash
|
||||
for (i=0; i<length; i++)
|
||||
pagedata[i] = bitswap8(pagedata[i]);
|
||||
|
||||
retval = alt_epcq_controller_write_block(&epcq_controller_dev->dev, (pagenum/PAGES_PER_SECTOR)*PAGES_PER_SECTOR*PAGESIZE, pagenum*PAGESIZE, pagedata, length);
|
||||
|
||||
if (retval != 0) {
|
||||
@@ -83,7 +76,7 @@ int write_flash_page(alt_u8 *pagedata, alt_u32 length, alt_u32 pagenum)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int write_flash(alt_u8 *buf, alt_u32 length, alt_u32 pagenum, alt_u8 *tmpbuf)
|
||||
int write_flash(alt_u8 *buf, alt_u32 length, alt_u32 pagenum)
|
||||
{
|
||||
int retval;
|
||||
alt_u32 bytes_to_w;
|
||||
@@ -91,13 +84,7 @@ int write_flash(alt_u8 *buf, alt_u32 length, alt_u32 pagenum, alt_u8 *tmpbuf)
|
||||
while (length > 0) {
|
||||
bytes_to_w = (length > PAGESIZE) ? PAGESIZE : length;
|
||||
|
||||
// Use a temporary buffer if one was given.
|
||||
// This is to avoid the original buffer from
|
||||
// being overwritten by write_flash_page().
|
||||
if (tmpbuf)
|
||||
memcpy(tmpbuf, buf, bytes_to_w);
|
||||
|
||||
retval = write_flash_page(tmpbuf ? tmpbuf : buf, bytes_to_w, pagenum);
|
||||
retval = write_flash_page(buf, bytes_to_w, pagenum);
|
||||
if (retval != 0)
|
||||
return retval;
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ int read_flash(alt_u32 offset, alt_u32 length, alt_u8 *dstbuf);
|
||||
|
||||
int write_flash_page(alt_u8 *pagedata, alt_u32 length, alt_u32 pagenum);
|
||||
|
||||
int write_flash(alt_u8 *buf, alt_u32 length, alt_u32 pagenum, alt_u8 *tmpbuf);
|
||||
int write_flash(alt_u8 *buf, alt_u32 length, alt_u32 pagenum);
|
||||
|
||||
int verify_flash(alt_u32 offset, alt_u32 length, alt_u32 golden_crc, alt_u8 *tmpbuf);
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ int copy_sd_to_flash(alt_u32 sd_blknum, alt_u32 flash_pagenum, alt_u32 length, a
|
||||
return -retval;
|
||||
}
|
||||
|
||||
retval = write_flash(tmpbuf, bytes_to_rw, flash_pagenum, NULL);
|
||||
retval = write_flash(tmpbuf, bytes_to_rw, flash_pagenum);
|
||||
if (retval != 0)
|
||||
return retval;
|
||||
|
||||
|
||||
@@ -25,6 +25,6 @@
|
||||
#include "sd_io.h"
|
||||
|
||||
int check_sdcard(alt_u8 *databuf);
|
||||
int copy_sd_to_flash(alt_u32 sd_offset, alt_u32 flash_offset, alt_u32 length, alt_u8 *tmpbuf);
|
||||
int copy_sd_to_flash(alt_u32 sd_blknum, alt_u32 flash_pagenum, alt_u32 length, alt_u8 *tmpbuf);
|
||||
|
||||
#endif /* SDCARD_H_ */
|
||||
@@ -94,7 +94,7 @@ int write_userdata(alt_u8 entry)
|
||||
|
||||
// then write the rest
|
||||
if (vm_to_write > 0)
|
||||
write_flash((alt_u8*)video_modes+srcoffset, vm_to_write, ((USERDATA_OFFSET+entry*SECTORSIZE)/PAGESIZE) + 1, databuf);
|
||||
write_flash((alt_u8*)video_modes+srcoffset, vm_to_write, ((USERDATA_OFFSET+entry*SECTORSIZE)/PAGESIZE) + 1);
|
||||
|
||||
printf("Profile %u data written (%u bytes)\n", entry, sizeof(avconfig_t)+VIDEO_MODES_SIZE);
|
||||
break;
|
||||
@@ -236,17 +236,17 @@ int import_userdata()
|
||||
}
|
||||
|
||||
if (strncmp(header.userdata_key, "USRDATA", 8)) {
|
||||
printf("Not an userdata entry at %u\n", profile);
|
||||
printf("Not an userdata entry at 0x%x\n", 512+n*SECTORSIZE);
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((header.version_major != FW_VER_MAJOR) || (header.version_minor != FW_VER_MINOR)) {
|
||||
printf("Data version %u.%u does not match fw\n", header->version_major, header->version_minor);
|
||||
printf("Data version %u.%u does not match fw\n", header.version_major, header.version_minor);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (header.type > UDE_PROFILE) {
|
||||
printf("Unknown userdata entry\n", header->type);
|
||||
printf("Unknown userdata entry type %u\n", header.type);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,12 +21,6 @@
|
||||
#include "system.h"
|
||||
#include "io.h"
|
||||
|
||||
unsigned char bitswap8(unsigned char v)
|
||||
{
|
||||
return ((v * 0x0802LU & 0x22110LU) |
|
||||
(v * 0x8020LU & 0x88440LU)) * 0x10101LU >> 16;
|
||||
}
|
||||
|
||||
alt_u32 bswap32(alt_u32 w)
|
||||
{
|
||||
return (((w << 24) & 0xff000000) |
|
||||
|
||||
Reference in new issue
Block a user