mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-13 09:20:17 +00:00
staging: ft1000: Fix indentation in scram_dnldr() function.
Signed-off-by: Marek Belisko <marek.belisko@open-nandra.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
parent
857af455c8
commit
6f953fbbf6
@ -694,455 +694,542 @@ static u32 write_blk_fifo(struct ft1000_device *ft1000dev, u16 **pUsFile,
|
|||||||
// Returns: status - return code
|
// Returns: status - return code
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
u16 scram_dnldr(struct ft1000_device *ft1000dev, void *pFileStart, u32 FileLength)
|
u16 scram_dnldr(struct ft1000_device *ft1000dev, void *pFileStart,
|
||||||
|
u32 FileLength)
|
||||||
{
|
{
|
||||||
u16 status = STATUS_SUCCESS;
|
u16 status = STATUS_SUCCESS;
|
||||||
u32 state;
|
u32 state;
|
||||||
u16 handshake;
|
u16 handshake;
|
||||||
struct pseudo_hdr *pseudo_header;
|
struct pseudo_hdr *pseudo_header;
|
||||||
u16 pseudo_header_len;
|
u16 pseudo_header_len;
|
||||||
long word_length;
|
long word_length;
|
||||||
u16 request;
|
u16 request;
|
||||||
u16 temp;
|
u16 temp;
|
||||||
u16 tempword;
|
u16 tempword;
|
||||||
|
|
||||||
struct dsp_file_hdr *file_hdr;
|
struct dsp_file_hdr *file_hdr;
|
||||||
struct dsp_image_info *dsp_img_info = NULL;
|
struct dsp_image_info *dsp_img_info = NULL;
|
||||||
long requested_version;
|
long requested_version;
|
||||||
bool correct_version;
|
bool correct_version;
|
||||||
struct drv_msg *mailbox_data;
|
struct drv_msg *mailbox_data;
|
||||||
u16 *data = NULL;
|
u16 *data = NULL;
|
||||||
u16 *s_file = NULL;
|
u16 *s_file = NULL;
|
||||||
u8 *c_file = NULL;
|
u8 *c_file = NULL;
|
||||||
u8 *boot_end = NULL, *code_end= NULL;
|
u8 *boot_end = NULL, *code_end = NULL;
|
||||||
int image;
|
int image;
|
||||||
long loader_code_address, loader_code_size = 0;
|
long loader_code_address, loader_code_size = 0;
|
||||||
long run_address = 0, run_size = 0;
|
long run_address = 0, run_size = 0;
|
||||||
|
|
||||||
u32 templong;
|
u32 templong;
|
||||||
u32 image_chksum = 0;
|
u32 image_chksum = 0;
|
||||||
|
|
||||||
u16 dpram = 0;
|
u16 dpram = 0;
|
||||||
u8 *pbuffer;
|
u8 *pbuffer;
|
||||||
struct prov_record *pprov_record;
|
struct prov_record *pprov_record;
|
||||||
struct ft1000_info *pft1000info = netdev_priv(ft1000dev->net);
|
struct ft1000_info *pft1000info = netdev_priv(ft1000dev->net);
|
||||||
|
|
||||||
DEBUG("Entered scram_dnldr...\n");
|
DEBUG("Entered scram_dnldr...\n");
|
||||||
|
|
||||||
pft1000info->fcodeldr = 0;
|
pft1000info->fcodeldr = 0;
|
||||||
pft1000info->usbboot = 0;
|
pft1000info->usbboot = 0;
|
||||||
pft1000info->dspalive = 0xffff;
|
pft1000info->dspalive = 0xffff;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Get version id of file, at first 4 bytes of file, for newer files.
|
||||||
|
//
|
||||||
|
|
||||||
//
|
state = STATE_START_DWNLD;
|
||||||
// Get version id of file, at first 4 bytes of file, for newer files.
|
|
||||||
//
|
|
||||||
|
|
||||||
state = STATE_START_DWNLD;
|
file_hdr = (struct dsp_file_hdr *)pFileStart;
|
||||||
|
|
||||||
file_hdr = (struct dsp_file_hdr *)pFileStart;
|
ft1000_write_register(ft1000dev, 0x800, FT1000_REG_MAG_WATERMARK);
|
||||||
|
|
||||||
ft1000_write_register (ft1000dev, 0x800, FT1000_REG_MAG_WATERMARK);
|
s_file = (u16 *) (pFileStart + file_hdr->loader_offset);
|
||||||
|
c_file = (u8 *) (pFileStart + file_hdr->loader_offset);
|
||||||
|
|
||||||
s_file = (u16 *)(pFileStart + file_hdr->loader_offset);
|
boot_end = (u8 *) (pFileStart + file_hdr->loader_code_end);
|
||||||
c_file = (u8 *)(pFileStart + file_hdr->loader_offset);
|
|
||||||
|
|
||||||
boot_end = (u8 *)(pFileStart + file_hdr->loader_code_end);
|
loader_code_address = file_hdr->loader_code_address;
|
||||||
|
loader_code_size = file_hdr->loader_code_size;
|
||||||
|
correct_version = FALSE;
|
||||||
|
|
||||||
loader_code_address = file_hdr->loader_code_address;
|
while ((status == STATUS_SUCCESS) && (state != STATE_DONE_FILE)) {
|
||||||
loader_code_size = file_hdr->loader_code_size;
|
switch (state) {
|
||||||
correct_version = FALSE;
|
case STATE_START_DWNLD:
|
||||||
|
DEBUG("FT1000:STATE_START_DWNLD\n");
|
||||||
|
if (pft1000info->usbboot)
|
||||||
|
handshake =
|
||||||
|
get_handshake_usb(ft1000dev,
|
||||||
|
HANDSHAKE_DSP_BL_READY);
|
||||||
|
else
|
||||||
|
handshake =
|
||||||
|
get_handshake(ft1000dev,
|
||||||
|
HANDSHAKE_DSP_BL_READY);
|
||||||
|
|
||||||
while ((status == STATUS_SUCCESS) && (state != STATE_DONE_FILE))
|
if (handshake == HANDSHAKE_DSP_BL_READY) {
|
||||||
{
|
DEBUG
|
||||||
switch (state)
|
("scram_dnldr: handshake is HANDSHAKE_DSP_BL_READY, call put_handshake(HANDSHAKE_DRIVER_READY)\n");
|
||||||
{
|
put_handshake(ft1000dev,
|
||||||
case STATE_START_DWNLD:
|
HANDSHAKE_DRIVER_READY);
|
||||||
DEBUG("FT1000:STATE_START_DWNLD\n");
|
} else {
|
||||||
if (pft1000info->usbboot)
|
DEBUG
|
||||||
handshake = get_handshake_usb(ft1000dev, HANDSHAKE_DSP_BL_READY);
|
("FT1000:download:Download error: Handshake failed\n");
|
||||||
else
|
status = STATUS_FAILURE;
|
||||||
handshake = get_handshake(ft1000dev, HANDSHAKE_DSP_BL_READY);
|
}
|
||||||
|
|
||||||
if (handshake == HANDSHAKE_DSP_BL_READY)
|
state = STATE_BOOT_DWNLD;
|
||||||
{
|
|
||||||
DEBUG("scram_dnldr: handshake is HANDSHAKE_DSP_BL_READY, call put_handshake(HANDSHAKE_DRIVER_READY)\n");
|
|
||||||
put_handshake(ft1000dev, HANDSHAKE_DRIVER_READY);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
DEBUG("FT1000:download:Download error: Handshake failed\n");
|
|
||||||
status = STATUS_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
state = STATE_BOOT_DWNLD;
|
break;
|
||||||
|
|
||||||
break;
|
case STATE_BOOT_DWNLD:
|
||||||
|
DEBUG("FT1000:STATE_BOOT_DWNLD\n");
|
||||||
case STATE_BOOT_DWNLD:
|
pft1000info->bootmode = 1;
|
||||||
DEBUG("FT1000:STATE_BOOT_DWNLD\n");
|
handshake = get_handshake(ft1000dev, HANDSHAKE_REQUEST);
|
||||||
pft1000info->bootmode = 1;
|
if (handshake == HANDSHAKE_REQUEST) {
|
||||||
handshake = get_handshake(ft1000dev, HANDSHAKE_REQUEST);
|
/*
|
||||||
if (handshake == HANDSHAKE_REQUEST)
|
* Get type associated with the request.
|
||||||
{
|
*/
|
||||||
/*
|
request = get_request_type(ft1000dev);
|
||||||
* Get type associated with the request.
|
switch (request) {
|
||||||
*/
|
case REQUEST_RUN_ADDRESS:
|
||||||
request = get_request_type(ft1000dev);
|
DEBUG("FT1000:REQUEST_RUN_ADDRESS\n");
|
||||||
switch (request)
|
put_request_value(ft1000dev,
|
||||||
{
|
loader_code_address);
|
||||||
case REQUEST_RUN_ADDRESS:
|
break;
|
||||||
DEBUG("FT1000:REQUEST_RUN_ADDRESS\n");
|
case REQUEST_CODE_LENGTH:
|
||||||
put_request_value(ft1000dev, loader_code_address);
|
DEBUG("FT1000:REQUEST_CODE_LENGTH\n");
|
||||||
break;
|
put_request_value(ft1000dev,
|
||||||
case REQUEST_CODE_LENGTH:
|
loader_code_size);
|
||||||
DEBUG("FT1000:REQUEST_CODE_LENGTH\n");
|
break;
|
||||||
put_request_value(ft1000dev, loader_code_size);
|
case REQUEST_DONE_BL:
|
||||||
break;
|
DEBUG("FT1000:REQUEST_DONE_BL\n");
|
||||||
case REQUEST_DONE_BL:
|
/* Reposition ptrs to beginning of code section */
|
||||||
DEBUG("FT1000:REQUEST_DONE_BL\n");
|
s_file = (u16 *) (boot_end);
|
||||||
/* Reposition ptrs to beginning of code section */
|
c_file = (u8 *) (boot_end);
|
||||||
s_file = (u16 *)(boot_end);
|
//DEBUG("FT1000:download:s_file = 0x%8x\n", (int)s_file);
|
||||||
c_file = (u8 *)(boot_end);
|
//DEBUG("FT1000:download:c_file = 0x%8x\n", (int)c_file);
|
||||||
//DEBUG("FT1000:download:s_file = 0x%8x\n", (int)s_file);
|
state = STATE_CODE_DWNLD;
|
||||||
//DEBUG("FT1000:download:c_file = 0x%8x\n", (int)c_file);
|
pft1000info->fcodeldr = 1;
|
||||||
state = STATE_CODE_DWNLD;
|
break;
|
||||||
pft1000info->fcodeldr = 1;
|
case REQUEST_CODE_SEGMENT:
|
||||||
break;
|
//DEBUG("FT1000:REQUEST_CODE_SEGMENT\n");
|
||||||
case REQUEST_CODE_SEGMENT:
|
word_length =
|
||||||
//DEBUG("FT1000:REQUEST_CODE_SEGMENT\n");
|
get_request_value(ft1000dev);
|
||||||
word_length = get_request_value(ft1000dev);
|
//DEBUG("FT1000:word_length = 0x%x\n", (int)word_length);
|
||||||
//DEBUG("FT1000:word_length = 0x%x\n", (int)word_length);
|
//NdisMSleep (100);
|
||||||
//NdisMSleep (100);
|
if (word_length > MAX_LENGTH) {
|
||||||
if (word_length > MAX_LENGTH)
|
DEBUG
|
||||||
{
|
("FT1000:download:Download error: Max length exceeded\n");
|
||||||
DEBUG("FT1000:download:Download error: Max length exceeded\n");
|
status = STATUS_FAILURE;
|
||||||
status = STATUS_FAILURE;
|
break;
|
||||||
break;
|
}
|
||||||
}
|
if ((word_length * 2 + c_file) >
|
||||||
if ( (word_length*2 + c_file) > boot_end)
|
boot_end) {
|
||||||
{
|
/*
|
||||||
/*
|
* Error, beyond boot code range.
|
||||||
* Error, beyond boot code range.
|
*/
|
||||||
*/
|
DEBUG
|
||||||
DEBUG("FT1000:download:Download error: Requested len=%d exceeds BOOT code boundry.\n",
|
("FT1000:download:Download error: Requested len=%d exceeds BOOT code boundry.\n",
|
||||||
(int)word_length);
|
(int)word_length);
|
||||||
status = STATUS_FAILURE;
|
status = STATUS_FAILURE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Position ASIC DPRAM auto-increment pointer.
|
* Position ASIC DPRAM auto-increment pointer.
|
||||||
*/
|
*/
|
||||||
dpram = (u16)DWNLD_MAG1_PS_HDR_LOC;
|
dpram = (u16) DWNLD_MAG1_PS_HDR_LOC;
|
||||||
if (word_length & 0x1)
|
if (word_length & 0x1)
|
||||||
word_length++;
|
word_length++;
|
||||||
word_length = word_length / 2;
|
word_length = word_length / 2;
|
||||||
|
|
||||||
status = write_blk(ft1000dev, &s_file, &c_file, word_length);
|
status =
|
||||||
//DEBUG("write_blk returned %d\n", status);
|
write_blk(ft1000dev, &s_file,
|
||||||
break;
|
&c_file, word_length);
|
||||||
default:
|
//DEBUG("write_blk returned %d\n", status);
|
||||||
DEBUG("FT1000:download:Download error: Bad request type=%d in BOOT download state.\n",request);
|
break;
|
||||||
status = STATUS_FAILURE;
|
default:
|
||||||
break;
|
DEBUG
|
||||||
}
|
("FT1000:download:Download error: Bad request type=%d in BOOT download state.\n",
|
||||||
if (pft1000info->usbboot)
|
request);
|
||||||
put_handshake_usb(ft1000dev, HANDSHAKE_RESPONSE);
|
status = STATUS_FAILURE;
|
||||||
else
|
break;
|
||||||
put_handshake(ft1000dev, HANDSHAKE_RESPONSE);
|
}
|
||||||
}
|
if (pft1000info->usbboot)
|
||||||
else
|
put_handshake_usb(ft1000dev,
|
||||||
{
|
HANDSHAKE_RESPONSE);
|
||||||
DEBUG("FT1000:download:Download error: Handshake failed\n");
|
else
|
||||||
status = STATUS_FAILURE;
|
put_handshake(ft1000dev,
|
||||||
}
|
HANDSHAKE_RESPONSE);
|
||||||
|
} else {
|
||||||
|
DEBUG
|
||||||
|
("FT1000:download:Download error: Handshake failed\n");
|
||||||
|
status = STATUS_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case STATE_CODE_DWNLD:
|
case STATE_CODE_DWNLD:
|
||||||
//DEBUG("FT1000:STATE_CODE_DWNLD\n");
|
//DEBUG("FT1000:STATE_CODE_DWNLD\n");
|
||||||
pft1000info->bootmode = 0;
|
pft1000info->bootmode = 0;
|
||||||
if (pft1000info->usbboot)
|
if (pft1000info->usbboot)
|
||||||
handshake = get_handshake_usb(ft1000dev, HANDSHAKE_REQUEST);
|
handshake =
|
||||||
else
|
get_handshake_usb(ft1000dev,
|
||||||
handshake = get_handshake(ft1000dev, HANDSHAKE_REQUEST);
|
HANDSHAKE_REQUEST);
|
||||||
if (handshake == HANDSHAKE_REQUEST)
|
else
|
||||||
{
|
handshake =
|
||||||
/*
|
get_handshake(ft1000dev, HANDSHAKE_REQUEST);
|
||||||
* Get type associated with the request.
|
if (handshake == HANDSHAKE_REQUEST) {
|
||||||
*/
|
/*
|
||||||
if (pft1000info->usbboot)
|
* Get type associated with the request.
|
||||||
request = get_request_type_usb(ft1000dev);
|
*/
|
||||||
else
|
if (pft1000info->usbboot)
|
||||||
request = get_request_type(ft1000dev);
|
request =
|
||||||
switch (request)
|
get_request_type_usb(ft1000dev);
|
||||||
{
|
else
|
||||||
case REQUEST_FILE_CHECKSUM:
|
request = get_request_type(ft1000dev);
|
||||||
DEBUG("FT1000:download:image_chksum = 0x%8x\n", image_chksum);
|
switch (request) {
|
||||||
put_request_value(ft1000dev, image_chksum);
|
case REQUEST_FILE_CHECKSUM:
|
||||||
break;
|
DEBUG
|
||||||
case REQUEST_RUN_ADDRESS:
|
("FT1000:download:image_chksum = 0x%8x\n",
|
||||||
DEBUG("FT1000:download: REQUEST_RUN_ADDRESS\n");
|
image_chksum);
|
||||||
if (correct_version)
|
put_request_value(ft1000dev,
|
||||||
{
|
image_chksum);
|
||||||
DEBUG("FT1000:download:run_address = 0x%8x\n", (int)run_address);
|
break;
|
||||||
put_request_value(ft1000dev, run_address);
|
case REQUEST_RUN_ADDRESS:
|
||||||
}
|
DEBUG
|
||||||
else
|
("FT1000:download: REQUEST_RUN_ADDRESS\n");
|
||||||
{
|
if (correct_version) {
|
||||||
DEBUG("FT1000:download:Download error: Got Run address request before image offset request.\n");
|
DEBUG
|
||||||
status = STATUS_FAILURE;
|
("FT1000:download:run_address = 0x%8x\n",
|
||||||
break;
|
(int)run_address);
|
||||||
}
|
put_request_value(ft1000dev,
|
||||||
break;
|
run_address);
|
||||||
case REQUEST_CODE_LENGTH:
|
} else {
|
||||||
DEBUG("FT1000:download:REQUEST_CODE_LENGTH\n");
|
DEBUG
|
||||||
if (correct_version)
|
("FT1000:download:Download error: Got Run address request before image offset request.\n");
|
||||||
{
|
status = STATUS_FAILURE;
|
||||||
DEBUG("FT1000:download:run_size = 0x%8x\n", (int)run_size);
|
break;
|
||||||
put_request_value(ft1000dev, run_size);
|
}
|
||||||
}
|
break;
|
||||||
else
|
case REQUEST_CODE_LENGTH:
|
||||||
{
|
DEBUG
|
||||||
DEBUG("FT1000:download:Download error: Got Size request before image offset request.\n");
|
("FT1000:download:REQUEST_CODE_LENGTH\n");
|
||||||
status = STATUS_FAILURE;
|
if (correct_version) {
|
||||||
break;
|
DEBUG
|
||||||
}
|
("FT1000:download:run_size = 0x%8x\n",
|
||||||
break;
|
(int)run_size);
|
||||||
case REQUEST_DONE_CL:
|
put_request_value(ft1000dev,
|
||||||
pft1000info->usbboot = 3;
|
run_size);
|
||||||
/* Reposition ptrs to beginning of provisioning section */
|
} else {
|
||||||
s_file = (u16 *)(pFileStart + file_hdr->commands_offset);
|
DEBUG
|
||||||
c_file = (u8 *)(pFileStart + file_hdr->commands_offset);
|
("FT1000:download:Download error: Got Size request before image offset request.\n");
|
||||||
state = STATE_DONE_DWNLD;
|
status = STATUS_FAILURE;
|
||||||
break;
|
break;
|
||||||
case REQUEST_CODE_SEGMENT:
|
}
|
||||||
//DEBUG("FT1000:download: REQUEST_CODE_SEGMENT - CODELOADER\n");
|
break;
|
||||||
if (!correct_version)
|
case REQUEST_DONE_CL:
|
||||||
{
|
pft1000info->usbboot = 3;
|
||||||
DEBUG("FT1000:download:Download error: Got Code Segment request before image offset request.\n");
|
/* Reposition ptrs to beginning of provisioning section */
|
||||||
status = STATUS_FAILURE;
|
s_file =
|
||||||
break;
|
(u16 *) (pFileStart +
|
||||||
}
|
file_hdr->commands_offset);
|
||||||
|
c_file =
|
||||||
|
(u8 *) (pFileStart +
|
||||||
|
file_hdr->commands_offset);
|
||||||
|
state = STATE_DONE_DWNLD;
|
||||||
|
break;
|
||||||
|
case REQUEST_CODE_SEGMENT:
|
||||||
|
//DEBUG("FT1000:download: REQUEST_CODE_SEGMENT - CODELOADER\n");
|
||||||
|
if (!correct_version) {
|
||||||
|
DEBUG
|
||||||
|
("FT1000:download:Download error: Got Code Segment request before image offset request.\n");
|
||||||
|
status = STATUS_FAILURE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
word_length = get_request_value(ft1000dev);
|
word_length =
|
||||||
//DEBUG("FT1000:download:word_length = %d\n", (int)word_length);
|
get_request_value(ft1000dev);
|
||||||
if (word_length > MAX_LENGTH)
|
//DEBUG("FT1000:download:word_length = %d\n", (int)word_length);
|
||||||
{
|
if (word_length > MAX_LENGTH) {
|
||||||
DEBUG("FT1000:download:Download error: Max length exceeded\n");
|
DEBUG
|
||||||
status = STATUS_FAILURE;
|
("FT1000:download:Download error: Max length exceeded\n");
|
||||||
break;
|
status = STATUS_FAILURE;
|
||||||
}
|
break;
|
||||||
if ( (word_length*2 + c_file) > code_end)
|
}
|
||||||
{
|
if ((word_length * 2 + c_file) >
|
||||||
/*
|
code_end) {
|
||||||
* Error, beyond boot code range.
|
/*
|
||||||
*/
|
* Error, beyond boot code range.
|
||||||
DEBUG("FT1000:download:Download error: Requested len=%d exceeds DSP code boundry.\n",
|
*/
|
||||||
(int)word_length);
|
DEBUG
|
||||||
status = STATUS_FAILURE;
|
("FT1000:download:Download error: Requested len=%d exceeds DSP code boundry.\n",
|
||||||
break;
|
(int)word_length);
|
||||||
}
|
status = STATUS_FAILURE;
|
||||||
/*
|
break;
|
||||||
* Position ASIC DPRAM auto-increment pointer.
|
}
|
||||||
*/
|
/*
|
||||||
dpram = (u16)DWNLD_MAG1_PS_HDR_LOC;
|
* Position ASIC DPRAM auto-increment pointer.
|
||||||
if (word_length & 0x1)
|
*/
|
||||||
word_length++;
|
dpram = (u16) DWNLD_MAG1_PS_HDR_LOC;
|
||||||
word_length = word_length / 2;
|
if (word_length & 0x1)
|
||||||
|
word_length++;
|
||||||
|
word_length = word_length / 2;
|
||||||
|
|
||||||
write_blk_fifo (ft1000dev, &s_file, &c_file, word_length);
|
write_blk_fifo(ft1000dev, &s_file,
|
||||||
if (pft1000info->usbboot == 0)
|
&c_file, word_length);
|
||||||
pft1000info->usbboot++;
|
if (pft1000info->usbboot == 0)
|
||||||
if (pft1000info->usbboot == 1) {
|
pft1000info->usbboot++;
|
||||||
tempword = 0;
|
if (pft1000info->usbboot == 1) {
|
||||||
ft1000_write_dpram16 (ft1000dev, DWNLD_MAG1_PS_HDR_LOC, tempword, 0);
|
tempword = 0;
|
||||||
}
|
ft1000_write_dpram16(ft1000dev,
|
||||||
|
DWNLD_MAG1_PS_HDR_LOC,
|
||||||
|
tempword,
|
||||||
|
0);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case REQUEST_MAILBOX_DATA:
|
case REQUEST_MAILBOX_DATA:
|
||||||
DEBUG("FT1000:download: REQUEST_MAILBOX_DATA\n");
|
DEBUG
|
||||||
// Convert length from byte count to word count. Make sure we round up.
|
("FT1000:download: REQUEST_MAILBOX_DATA\n");
|
||||||
word_length = (long)(pft1000info->DSPInfoBlklen + 1)/2;
|
// Convert length from byte count to word count. Make sure we round up.
|
||||||
put_request_value(ft1000dev, word_length);
|
word_length =
|
||||||
mailbox_data = (struct drv_msg *)&(pft1000info->DSPInfoBlk[0]);
|
(long)(pft1000info->DSPInfoBlklen +
|
||||||
/*
|
1) / 2;
|
||||||
* Position ASIC DPRAM auto-increment pointer.
|
put_request_value(ft1000dev,
|
||||||
*/
|
word_length);
|
||||||
|
mailbox_data =
|
||||||
|
(struct drv_msg *)&(pft1000info->
|
||||||
|
DSPInfoBlk[0]);
|
||||||
|
/*
|
||||||
|
* Position ASIC DPRAM auto-increment pointer.
|
||||||
|
*/
|
||||||
|
|
||||||
|
data = (u16 *) & mailbox_data->data[0];
|
||||||
|
dpram = (u16) DWNLD_MAG1_PS_HDR_LOC;
|
||||||
|
if (word_length & 0x1)
|
||||||
|
word_length++;
|
||||||
|
|
||||||
data = (u16 *)&mailbox_data->data[0];
|
word_length = (word_length / 2);
|
||||||
dpram = (u16)DWNLD_MAG1_PS_HDR_LOC;
|
|
||||||
if (word_length & 0x1)
|
|
||||||
word_length++;
|
|
||||||
|
|
||||||
word_length = (word_length / 2);
|
for (; word_length > 0; word_length--) { /* In words */
|
||||||
|
|
||||||
|
templong = *data++;
|
||||||
|
templong |= (*data++ << 16);
|
||||||
|
status =
|
||||||
|
fix_ft1000_write_dpram32
|
||||||
|
(ft1000dev, dpram++,
|
||||||
|
(u8 *) & templong);
|
||||||
|
|
||||||
for (; word_length > 0; word_length--) /* In words */
|
}
|
||||||
{
|
break;
|
||||||
|
|
||||||
templong = *data++;
|
case REQUEST_VERSION_INFO:
|
||||||
templong |= (*data++ << 16);
|
DEBUG
|
||||||
status = fix_ft1000_write_dpram32 (ft1000dev, dpram++, (u8 *)&templong);
|
("FT1000:download:REQUEST_VERSION_INFO\n");
|
||||||
|
word_length =
|
||||||
|
file_hdr->version_data_size;
|
||||||
|
put_request_value(ft1000dev,
|
||||||
|
word_length);
|
||||||
|
/*
|
||||||
|
* Position ASIC DPRAM auto-increment pointer.
|
||||||
|
*/
|
||||||
|
|
||||||
}
|
s_file =
|
||||||
break;
|
(u16 *) (pFileStart +
|
||||||
|
file_hdr->
|
||||||
|
version_data_offset);
|
||||||
|
|
||||||
case REQUEST_VERSION_INFO:
|
dpram = (u16) DWNLD_MAG1_PS_HDR_LOC;
|
||||||
DEBUG("FT1000:download:REQUEST_VERSION_INFO\n");
|
if (word_length & 0x1)
|
||||||
word_length = file_hdr->version_data_size;
|
word_length++;
|
||||||
put_request_value(ft1000dev, word_length);
|
|
||||||
/*
|
|
||||||
* Position ASIC DPRAM auto-increment pointer.
|
|
||||||
*/
|
|
||||||
|
|
||||||
s_file = (u16 *)(pFileStart + file_hdr->version_data_offset);
|
word_length = (word_length / 2);
|
||||||
|
|
||||||
|
for (; word_length > 0; word_length--) { /* In words */
|
||||||
|
|
||||||
dpram = (u16)DWNLD_MAG1_PS_HDR_LOC;
|
templong = ntohs(*s_file++);
|
||||||
if (word_length & 0x1)
|
temp = ntohs(*s_file++);
|
||||||
word_length++;
|
templong |= (temp << 16);
|
||||||
|
status =
|
||||||
|
fix_ft1000_write_dpram32
|
||||||
|
(ft1000dev, dpram++,
|
||||||
|
(u8 *) & templong);
|
||||||
|
|
||||||
word_length = (word_length / 2);
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case REQUEST_CODE_BY_VERSION:
|
||||||
|
DEBUG
|
||||||
|
("FT1000:download:REQUEST_CODE_BY_VERSION\n");
|
||||||
|
correct_version = FALSE;
|
||||||
|
requested_version =
|
||||||
|
get_request_value(ft1000dev);
|
||||||
|
|
||||||
for (; word_length > 0; word_length--) /* In words */
|
dsp_img_info =
|
||||||
{
|
(struct dsp_image_info *)(pFileStart
|
||||||
|
+
|
||||||
|
sizeof
|
||||||
|
(struct
|
||||||
|
dsp_file_hdr));
|
||||||
|
|
||||||
templong = ntohs(*s_file++);
|
for (image = 0;
|
||||||
temp = ntohs(*s_file++);
|
image < file_hdr->nDspImages;
|
||||||
templong |= (temp << 16);
|
image++) {
|
||||||
status = fix_ft1000_write_dpram32 (ft1000dev, dpram++, (u8 *)&templong);
|
|
||||||
|
|
||||||
}
|
temp =
|
||||||
break;
|
(u16) (dsp_img_info->
|
||||||
|
version);
|
||||||
|
templong = temp;
|
||||||
|
temp =
|
||||||
|
(u16) (dsp_img_info->
|
||||||
|
version >> 16);
|
||||||
|
templong |= (temp << 16);
|
||||||
|
if (templong ==
|
||||||
|
(u32) requested_version) {
|
||||||
|
correct_version = TRUE;
|
||||||
|
DEBUG
|
||||||
|
("FT1000:download: correct_version is TRUE\n");
|
||||||
|
s_file =
|
||||||
|
(u16 *) (pFileStart
|
||||||
|
+
|
||||||
|
dsp_img_info->
|
||||||
|
begin_offset);
|
||||||
|
c_file =
|
||||||
|
(u8 *) (pFileStart +
|
||||||
|
dsp_img_info->
|
||||||
|
begin_offset);
|
||||||
|
code_end =
|
||||||
|
(u8 *) (pFileStart +
|
||||||
|
dsp_img_info->
|
||||||
|
end_offset);
|
||||||
|
run_address =
|
||||||
|
dsp_img_info->
|
||||||
|
run_address;
|
||||||
|
run_size =
|
||||||
|
dsp_img_info->
|
||||||
|
image_size;
|
||||||
|
image_chksum =
|
||||||
|
(u32) dsp_img_info->
|
||||||
|
checksum;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
dsp_img_info++;
|
||||||
|
|
||||||
case REQUEST_CODE_BY_VERSION:
|
} //end of for
|
||||||
DEBUG("FT1000:download:REQUEST_CODE_BY_VERSION\n");
|
|
||||||
correct_version = FALSE;
|
|
||||||
requested_version = get_request_value(ft1000dev);
|
|
||||||
|
|
||||||
dsp_img_info = (struct dsp_image_info *)(pFileStart + sizeof(struct dsp_file_hdr ));
|
if (!correct_version) {
|
||||||
|
/*
|
||||||
|
* Error, beyond boot code range.
|
||||||
|
*/
|
||||||
|
DEBUG
|
||||||
|
("FT1000:download:Download error: Bad Version Request = 0x%x.\n",
|
||||||
|
(int)requested_version);
|
||||||
|
status = STATUS_FAILURE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
for (image = 0; image < file_hdr->nDspImages; image++)
|
default:
|
||||||
{
|
DEBUG
|
||||||
|
("FT1000:download:Download error: Bad request type=%d in CODE download state.\n",
|
||||||
|
request);
|
||||||
|
status = STATUS_FAILURE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (pft1000info->usbboot)
|
||||||
|
put_handshake_usb(ft1000dev,
|
||||||
|
HANDSHAKE_RESPONSE);
|
||||||
|
else
|
||||||
|
put_handshake(ft1000dev,
|
||||||
|
HANDSHAKE_RESPONSE);
|
||||||
|
} else {
|
||||||
|
DEBUG
|
||||||
|
("FT1000:download:Download error: Handshake failed\n");
|
||||||
|
status = STATUS_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
temp = (u16)(dsp_img_info->version);
|
break;
|
||||||
templong = temp;
|
|
||||||
temp = (u16)(dsp_img_info->version >> 16);
|
|
||||||
templong |= (temp << 16);
|
|
||||||
if (templong == (u32)requested_version)
|
|
||||||
{
|
|
||||||
correct_version = TRUE;
|
|
||||||
DEBUG("FT1000:download: correct_version is TRUE\n");
|
|
||||||
s_file = (u16 *)(pFileStart + dsp_img_info->begin_offset);
|
|
||||||
c_file = (u8 *)(pFileStart + dsp_img_info->begin_offset);
|
|
||||||
code_end = (u8 *)(pFileStart + dsp_img_info->end_offset);
|
|
||||||
run_address = dsp_img_info->run_address;
|
|
||||||
run_size = dsp_img_info->image_size;
|
|
||||||
image_chksum = (u32)dsp_img_info->checksum;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
dsp_img_info++;
|
|
||||||
|
|
||||||
|
case STATE_DONE_DWNLD:
|
||||||
|
DEBUG("FT1000:download:Code loader is done...\n");
|
||||||
|
state = STATE_SECTION_PROV;
|
||||||
|
break;
|
||||||
|
|
||||||
} //end of for
|
case STATE_SECTION_PROV:
|
||||||
|
DEBUG("FT1000:download:STATE_SECTION_PROV\n");
|
||||||
|
pseudo_header = (struct pseudo_hdr *)c_file;
|
||||||
|
|
||||||
if (!correct_version)
|
if (pseudo_header->checksum ==
|
||||||
{
|
hdr_checksum(pseudo_header)) {
|
||||||
/*
|
if (pseudo_header->portdest !=
|
||||||
* Error, beyond boot code range.
|
0x80 /* Dsp OAM */ ) {
|
||||||
*/
|
state = STATE_DONE_PROV;
|
||||||
DEBUG("FT1000:download:Download error: Bad Version Request = 0x%x.\n",(int)requested_version);
|
break;
|
||||||
status = STATUS_FAILURE;
|
}
|
||||||
break;
|
pseudo_header_len = ntohs(pseudo_header->length); /* Byte length for PROV records */
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
// Get buffer for provisioning data
|
||||||
DEBUG("FT1000:download:Download error: Bad request type=%d in CODE download state.\n",request);
|
pbuffer =
|
||||||
status = STATUS_FAILURE;
|
kmalloc((pseudo_header_len +
|
||||||
break;
|
sizeof(struct pseudo_hdr)),
|
||||||
}
|
GFP_ATOMIC);
|
||||||
if (pft1000info->usbboot)
|
if (pbuffer) {
|
||||||
put_handshake_usb(ft1000dev, HANDSHAKE_RESPONSE);
|
memcpy(pbuffer, (void *)c_file,
|
||||||
else
|
(u32) (pseudo_header_len +
|
||||||
put_handshake(ft1000dev, HANDSHAKE_RESPONSE);
|
sizeof(struct
|
||||||
}
|
pseudo_hdr)));
|
||||||
else
|
// link provisioning data
|
||||||
{
|
pprov_record =
|
||||||
DEBUG("FT1000:download:Download error: Handshake failed\n");
|
kmalloc(sizeof(struct prov_record),
|
||||||
status = STATUS_FAILURE;
|
GFP_ATOMIC);
|
||||||
}
|
if (pprov_record) {
|
||||||
|
pprov_record->pprov_data =
|
||||||
|
pbuffer;
|
||||||
|
list_add_tail(&pprov_record->
|
||||||
|
list,
|
||||||
|
&pft1000info->
|
||||||
|
prov_list);
|
||||||
|
// Move to next entry if available
|
||||||
|
c_file =
|
||||||
|
(u8 *) ((unsigned long)
|
||||||
|
c_file +
|
||||||
|
(u32) ((pseudo_header_len + 1) & 0xFFFFFFFE) + sizeof(struct pseudo_hdr));
|
||||||
|
if ((unsigned long)(c_file) -
|
||||||
|
(unsigned long)(pFileStart)
|
||||||
|
>=
|
||||||
|
(unsigned long)FileLength) {
|
||||||
|
state = STATE_DONE_FILE;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
kfree(pbuffer);
|
||||||
|
status = STATUS_FAILURE;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
status = STATUS_FAILURE;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/* Checksum did not compute */
|
||||||
|
status = STATUS_FAILURE;
|
||||||
|
}
|
||||||
|
DEBUG
|
||||||
|
("ft1000:download: after STATE_SECTION_PROV, state = %d, status= %d\n",
|
||||||
|
state, status);
|
||||||
|
break;
|
||||||
|
|
||||||
break;
|
case STATE_DONE_PROV:
|
||||||
|
DEBUG("FT1000:download:STATE_DONE_PROV\n");
|
||||||
|
state = STATE_DONE_FILE;
|
||||||
|
break;
|
||||||
|
|
||||||
case STATE_DONE_DWNLD:
|
default:
|
||||||
DEBUG("FT1000:download:Code loader is done...\n");
|
status = STATUS_FAILURE;
|
||||||
state = STATE_SECTION_PROV;
|
break;
|
||||||
break;
|
} /* End Switch */
|
||||||
|
|
||||||
case STATE_SECTION_PROV:
|
if (status != STATUS_SUCCESS) {
|
||||||
DEBUG("FT1000:download:STATE_SECTION_PROV\n");
|
break;
|
||||||
pseudo_header = (struct pseudo_hdr *)c_file;
|
}
|
||||||
|
|
||||||
if (pseudo_header->checksum == hdr_checksum(pseudo_header))
|
|
||||||
{
|
|
||||||
if (pseudo_header->portdest != 0x80 /* Dsp OAM */)
|
|
||||||
{
|
|
||||||
state = STATE_DONE_PROV;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
pseudo_header_len = ntohs(pseudo_header->length); /* Byte length for PROV records */
|
|
||||||
|
|
||||||
// Get buffer for provisioning data
|
|
||||||
pbuffer = kmalloc((pseudo_header_len + sizeof(struct pseudo_hdr)), GFP_ATOMIC);
|
|
||||||
if (pbuffer) {
|
|
||||||
memcpy(pbuffer, (void *)c_file, (u32)(pseudo_header_len + sizeof(struct pseudo_hdr)));
|
|
||||||
// link provisioning data
|
|
||||||
pprov_record = kmalloc(sizeof(struct prov_record), GFP_ATOMIC);
|
|
||||||
if (pprov_record) {
|
|
||||||
pprov_record->pprov_data = pbuffer;
|
|
||||||
list_add_tail (&pprov_record->list, &pft1000info->prov_list);
|
|
||||||
// Move to next entry if available
|
|
||||||
c_file = (u8 *)((unsigned long)c_file + (u32)((pseudo_header_len + 1) & 0xFFFFFFFE) + sizeof(struct pseudo_hdr));
|
|
||||||
if ( (unsigned long)(c_file) - (unsigned long)(pFileStart) >= (unsigned long)FileLength) {
|
|
||||||
state = STATE_DONE_FILE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
kfree(pbuffer);
|
|
||||||
status = STATUS_FAILURE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
status = STATUS_FAILURE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Checksum did not compute */
|
|
||||||
status = STATUS_FAILURE;
|
|
||||||
}
|
|
||||||
DEBUG("ft1000:download: after STATE_SECTION_PROV, state = %d, status= %d\n", state, status);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case STATE_DONE_PROV:
|
|
||||||
DEBUG("FT1000:download:STATE_DONE_PROV\n");
|
|
||||||
state = STATE_DONE_FILE;
|
|
||||||
break;
|
|
||||||
|
|
||||||
|
|
||||||
default:
|
|
||||||
status = STATUS_FAILURE;
|
|
||||||
break;
|
|
||||||
} /* End Switch */
|
|
||||||
|
|
||||||
if (status != STATUS_SUCCESS) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/****
|
/****
|
||||||
// Check if Card is present
|
// Check if Card is present
|
||||||
@ -1157,11 +1244,12 @@ u16 scram_dnldr(struct ft1000_device *ft1000dev, void *pFileStart, u32 FileLeng
|
|||||||
}
|
}
|
||||||
****/
|
****/
|
||||||
|
|
||||||
} /* End while */
|
} /* End while */
|
||||||
|
|
||||||
DEBUG("Download exiting with status = 0x%8x\n", status);
|
DEBUG("Download exiting with status = 0x%8x\n", status);
|
||||||
ft1000_write_register(ft1000dev, FT1000_DB_DNLD_TX, FT1000_REG_DOORBELL);
|
ft1000_write_register(ft1000dev, FT1000_DB_DNLD_TX,
|
||||||
|
FT1000_REG_DOORBELL);
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user