Commit 6f953fbb authored by Marek Belisko's avatar Marek Belisko Committed by Greg Kroah-Hartman

staging: ft1000: Fix indentation in scram_dnldr() function.

Signed-off-by: default avatarMarek Belisko <marek.belisko@open-nandra.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 857af455
...@@ -694,7 +694,8 @@ static u32 write_blk_fifo(struct ft1000_device *ft1000dev, u16 **pUsFile, ...@@ -694,7 +694,8 @@ 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;
...@@ -714,7 +715,7 @@ u16 scram_dnldr(struct ft1000_device *ft1000dev, void *pFileStart, u32 FileLeng ...@@ -714,7 +715,7 @@ u16 scram_dnldr(struct ft1000_device *ft1000dev, void *pFileStart, u32 FileLeng
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;
...@@ -733,7 +734,6 @@ u16 scram_dnldr(struct ft1000_device *ft1000dev, void *pFileStart, u32 FileLeng ...@@ -733,7 +734,6 @@ u16 scram_dnldr(struct ft1000_device *ft1000dev, void *pFileStart, u32 FileLeng
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. // Get version id of file, at first 4 bytes of file, for newer files.
// //
...@@ -742,36 +742,38 @@ u16 scram_dnldr(struct ft1000_device *ft1000dev, void *pFileStart, u32 FileLeng ...@@ -742,36 +742,38 @@ u16 scram_dnldr(struct ft1000_device *ft1000dev, void *pFileStart, u32 FileLeng
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); s_file = (u16 *) (pFileStart + file_hdr->loader_offset);
c_file = (u8 *)(pFileStart + file_hdr->loader_offset); c_file = (u8 *) (pFileStart + file_hdr->loader_offset);
boot_end = (u8 *)(pFileStart + file_hdr->loader_code_end); boot_end = (u8 *) (pFileStart + file_hdr->loader_code_end);
loader_code_address = file_hdr->loader_code_address; loader_code_address = file_hdr->loader_code_address;
loader_code_size = file_hdr->loader_code_size; loader_code_size = file_hdr->loader_code_size;
correct_version = FALSE; correct_version = FALSE;
while ((status == STATUS_SUCCESS) && (state != STATE_DONE_FILE)) while ((status == STATUS_SUCCESS) && (state != STATE_DONE_FILE)) {
{ switch (state) {
switch (state)
{
case STATE_START_DWNLD: case STATE_START_DWNLD:
DEBUG("FT1000:STATE_START_DWNLD\n"); DEBUG("FT1000:STATE_START_DWNLD\n");
if (pft1000info->usbboot) if (pft1000info->usbboot)
handshake = get_handshake_usb(ft1000dev, HANDSHAKE_DSP_BL_READY); handshake =
get_handshake_usb(ft1000dev,
HANDSHAKE_DSP_BL_READY);
else else
handshake = get_handshake(ft1000dev, HANDSHAKE_DSP_BL_READY); handshake =
get_handshake(ft1000dev,
if (handshake == HANDSHAKE_DSP_BL_READY) HANDSHAKE_DSP_BL_READY);
{
DEBUG("scram_dnldr: handshake is HANDSHAKE_DSP_BL_READY, call put_handshake(HANDSHAKE_DRIVER_READY)\n"); if (handshake == HANDSHAKE_DSP_BL_READY) {
put_handshake(ft1000dev, HANDSHAKE_DRIVER_READY); DEBUG
} ("scram_dnldr: handshake is HANDSHAKE_DSP_BL_READY, call put_handshake(HANDSHAKE_DRIVER_READY)\n");
else put_handshake(ft1000dev,
{ HANDSHAKE_DRIVER_READY);
DEBUG("FT1000:download:Download error: Handshake failed\n"); } else {
DEBUG
("FT1000:download:Download error: Handshake failed\n");
status = STATUS_FAILURE; status = STATUS_FAILURE;
} }
...@@ -783,27 +785,27 @@ u16 scram_dnldr(struct ft1000_device *ft1000dev, void *pFileStart, u32 FileLeng ...@@ -783,27 +785,27 @@ u16 scram_dnldr(struct ft1000_device *ft1000dev, void *pFileStart, u32 FileLeng
DEBUG("FT1000:STATE_BOOT_DWNLD\n"); DEBUG("FT1000:STATE_BOOT_DWNLD\n");
pft1000info->bootmode = 1; pft1000info->bootmode = 1;
handshake = get_handshake(ft1000dev, HANDSHAKE_REQUEST); handshake = get_handshake(ft1000dev, HANDSHAKE_REQUEST);
if (handshake == HANDSHAKE_REQUEST) if (handshake == HANDSHAKE_REQUEST) {
{
/* /*
* Get type associated with the request. * Get type associated with the request.
*/ */
request = get_request_type(ft1000dev); request = get_request_type(ft1000dev);
switch (request) switch (request) {
{
case REQUEST_RUN_ADDRESS: case REQUEST_RUN_ADDRESS:
DEBUG("FT1000:REQUEST_RUN_ADDRESS\n"); DEBUG("FT1000:REQUEST_RUN_ADDRESS\n");
put_request_value(ft1000dev, loader_code_address); put_request_value(ft1000dev,
loader_code_address);
break; break;
case REQUEST_CODE_LENGTH: case REQUEST_CODE_LENGTH:
DEBUG("FT1000:REQUEST_CODE_LENGTH\n"); DEBUG("FT1000:REQUEST_CODE_LENGTH\n");
put_request_value(ft1000dev, loader_code_size); put_request_value(ft1000dev,
loader_code_size);
break; break;
case REQUEST_DONE_BL: case REQUEST_DONE_BL:
DEBUG("FT1000:REQUEST_DONE_BL\n"); DEBUG("FT1000:REQUEST_DONE_BL\n");
/* Reposition ptrs to beginning of code section */ /* Reposition ptrs to beginning of code section */
s_file = (u16 *)(boot_end); s_file = (u16 *) (boot_end);
c_file = (u8 *)(boot_end); c_file = (u8 *) (boot_end);
//DEBUG("FT1000:download:s_file = 0x%8x\n", (int)s_file); //DEBUG("FT1000:download:s_file = 0x%8x\n", (int)s_file);
//DEBUG("FT1000:download:c_file = 0x%8x\n", (int)c_file); //DEBUG("FT1000:download:c_file = 0x%8x\n", (int)c_file);
state = STATE_CODE_DWNLD; state = STATE_CODE_DWNLD;
...@@ -811,21 +813,23 @@ u16 scram_dnldr(struct ft1000_device *ft1000dev, void *pFileStart, u32 FileLeng ...@@ -811,21 +813,23 @@ u16 scram_dnldr(struct ft1000_device *ft1000dev, void *pFileStart, u32 FileLeng
break; break;
case REQUEST_CODE_SEGMENT: case REQUEST_CODE_SEGMENT:
//DEBUG("FT1000:REQUEST_CODE_SEGMENT\n"); //DEBUG("FT1000:REQUEST_CODE_SEGMENT\n");
word_length = 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
DEBUG("FT1000:download:Download error: Max length exceeded\n"); ("FT1000:download:Download error: Max length exceeded\n");
status = STATUS_FAILURE; status = STATUS_FAILURE;
break; break;
} }
if ( (word_length*2 + c_file) > boot_end) if ((word_length * 2 + c_file) >
{ boot_end) {
/* /*
* Error, beyond boot code range. * Error, beyond boot code range.
*/ */
DEBUG("FT1000:download:Download error: Requested len=%d exceeds BOOT code boundry.\n", DEBUG
("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;
...@@ -833,27 +837,32 @@ u16 scram_dnldr(struct ft1000_device *ft1000dev, void *pFileStart, u32 FileLeng ...@@ -833,27 +837,32 @@ u16 scram_dnldr(struct ft1000_device *ft1000dev, void *pFileStart, u32 FileLeng
/* /*
* 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 =
write_blk(ft1000dev, &s_file,
&c_file, word_length);
//DEBUG("write_blk returned %d\n", status); //DEBUG("write_blk returned %d\n", status);
break; break;
default: default:
DEBUG("FT1000:download:Download error: Bad request type=%d in BOOT download state.\n",request); DEBUG
("FT1000:download:Download error: Bad request type=%d in BOOT download state.\n",
request);
status = STATUS_FAILURE; status = STATUS_FAILURE;
break; break;
} }
if (pft1000info->usbboot) if (pft1000info->usbboot)
put_handshake_usb(ft1000dev, HANDSHAKE_RESPONSE); put_handshake_usb(ft1000dev,
else HANDSHAKE_RESPONSE);
put_handshake(ft1000dev, HANDSHAKE_RESPONSE);
}
else else
{ put_handshake(ft1000dev,
DEBUG("FT1000:download:Download error: Handshake failed\n"); HANDSHAKE_RESPONSE);
} else {
DEBUG
("FT1000:download:Download error: Handshake failed\n");
status = STATUS_FAILURE; status = STATUS_FAILURE;
} }
...@@ -863,48 +872,57 @@ u16 scram_dnldr(struct ft1000_device *ft1000dev, void *pFileStart, u32 FileLeng ...@@ -863,48 +872,57 @@ u16 scram_dnldr(struct ft1000_device *ft1000dev, void *pFileStart, u32 FileLeng
//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 =
get_handshake_usb(ft1000dev,
HANDSHAKE_REQUEST);
else else
handshake = get_handshake(ft1000dev, HANDSHAKE_REQUEST); handshake =
if (handshake == HANDSHAKE_REQUEST) get_handshake(ft1000dev, HANDSHAKE_REQUEST);
{ if (handshake == HANDSHAKE_REQUEST) {
/* /*
* Get type associated with the request. * Get type associated with the request.
*/ */
if (pft1000info->usbboot) if (pft1000info->usbboot)
request = get_request_type_usb(ft1000dev); request =
get_request_type_usb(ft1000dev);
else else
request = get_request_type(ft1000dev); request = get_request_type(ft1000dev);
switch (request) switch (request) {
{
case REQUEST_FILE_CHECKSUM: case REQUEST_FILE_CHECKSUM:
DEBUG("FT1000:download:image_chksum = 0x%8x\n", image_chksum); DEBUG
put_request_value(ft1000dev, image_chksum); ("FT1000:download:image_chksum = 0x%8x\n",
image_chksum);
put_request_value(ft1000dev,
image_chksum);
break; break;
case REQUEST_RUN_ADDRESS: case REQUEST_RUN_ADDRESS:
DEBUG("FT1000:download: REQUEST_RUN_ADDRESS\n"); DEBUG
if (correct_version) ("FT1000:download: REQUEST_RUN_ADDRESS\n");
{ if (correct_version) {
DEBUG("FT1000:download:run_address = 0x%8x\n", (int)run_address); DEBUG
put_request_value(ft1000dev, run_address); ("FT1000:download:run_address = 0x%8x\n",
} (int)run_address);
else put_request_value(ft1000dev,
{ run_address);
DEBUG("FT1000:download:Download error: Got Run address request before image offset request.\n"); } else {
DEBUG
("FT1000:download:Download error: Got Run address request before image offset request.\n");
status = STATUS_FAILURE; status = STATUS_FAILURE;
break; break;
} }
break; break;
case REQUEST_CODE_LENGTH: case REQUEST_CODE_LENGTH:
DEBUG("FT1000:download:REQUEST_CODE_LENGTH\n"); DEBUG
if (correct_version) ("FT1000:download:REQUEST_CODE_LENGTH\n");
{ if (correct_version) {
DEBUG("FT1000:download:run_size = 0x%8x\n", (int)run_size); DEBUG
put_request_value(ft1000dev, run_size); ("FT1000:download:run_size = 0x%8x\n",
} (int)run_size);
else put_request_value(ft1000dev,
{ run_size);
DEBUG("FT1000:download:Download error: Got Size request before image offset request.\n"); } else {
DEBUG
("FT1000:download:Download error: Got Size request before image offset request.\n");
status = STATUS_FAILURE; status = STATUS_FAILURE;
break; break;
} }
...@@ -912,33 +930,39 @@ u16 scram_dnldr(struct ft1000_device *ft1000dev, void *pFileStart, u32 FileLeng ...@@ -912,33 +930,39 @@ u16 scram_dnldr(struct ft1000_device *ft1000dev, void *pFileStart, u32 FileLeng
case REQUEST_DONE_CL: case REQUEST_DONE_CL:
pft1000info->usbboot = 3; pft1000info->usbboot = 3;
/* Reposition ptrs to beginning of provisioning section */ /* Reposition ptrs to beginning of provisioning section */
s_file = (u16 *)(pFileStart + file_hdr->commands_offset); s_file =
c_file = (u8 *)(pFileStart + file_hdr->commands_offset); (u16 *) (pFileStart +
file_hdr->commands_offset);
c_file =
(u8 *) (pFileStart +
file_hdr->commands_offset);
state = STATE_DONE_DWNLD; state = STATE_DONE_DWNLD;
break; break;
case REQUEST_CODE_SEGMENT: case REQUEST_CODE_SEGMENT:
//DEBUG("FT1000:download: REQUEST_CODE_SEGMENT - CODELOADER\n"); //DEBUG("FT1000:download: REQUEST_CODE_SEGMENT - CODELOADER\n");
if (!correct_version) if (!correct_version) {
{ DEBUG
DEBUG("FT1000:download:Download error: Got Code Segment request before image offset request.\n"); ("FT1000:download:Download error: Got Code Segment request before image offset request.\n");
status = STATUS_FAILURE; status = STATUS_FAILURE;
break; break;
} }
word_length = get_request_value(ft1000dev); word_length =
get_request_value(ft1000dev);
//DEBUG("FT1000:download:word_length = %d\n", (int)word_length); //DEBUG("FT1000:download:word_length = %d\n", (int)word_length);
if (word_length > MAX_LENGTH) if (word_length > MAX_LENGTH) {
{ DEBUG
DEBUG("FT1000:download:Download error: Max length exceeded\n"); ("FT1000:download:Download error: Max length exceeded\n");
status = STATUS_FAILURE; status = STATUS_FAILURE;
break; 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", DEBUG
("FT1000:download:Download error: Requested len=%d exceeds DSP code boundry.\n",
(int)word_length); (int)word_length);
status = STATUS_FAILURE; status = STATUS_FAILURE;
break; break;
...@@ -946,134 +970,182 @@ u16 scram_dnldr(struct ft1000_device *ft1000dev, void *pFileStart, u32 FileLeng ...@@ -946,134 +970,182 @@ u16 scram_dnldr(struct ft1000_device *ft1000dev, void *pFileStart, u32 FileLeng
/* /*
* 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;
write_blk_fifo (ft1000dev, &s_file, &c_file, word_length); write_blk_fifo(ft1000dev, &s_file,
&c_file, word_length);
if (pft1000info->usbboot == 0) if (pft1000info->usbboot == 0)
pft1000info->usbboot++; pft1000info->usbboot++;
if (pft1000info->usbboot == 1) { if (pft1000info->usbboot == 1) {
tempword = 0; tempword = 0;
ft1000_write_dpram16 (ft1000dev, DWNLD_MAG1_PS_HDR_LOC, 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
("FT1000:download: REQUEST_MAILBOX_DATA\n");
// Convert length from byte count to word count. Make sure we round up. // Convert length from byte count to word count. Make sure we round up.
word_length = (long)(pft1000info->DSPInfoBlklen + 1)/2; word_length =
put_request_value(ft1000dev, word_length); (long)(pft1000info->DSPInfoBlklen +
mailbox_data = (struct drv_msg *)&(pft1000info->DSPInfoBlk[0]); 1) / 2;
put_request_value(ft1000dev,
word_length);
mailbox_data =
(struct drv_msg *)&(pft1000info->
DSPInfoBlk[0]);
/* /*
* Position ASIC DPRAM auto-increment pointer. * Position ASIC DPRAM auto-increment pointer.
*/ */
data = (u16 *) & mailbox_data->data[0];
data = (u16 *)&mailbox_data->data[0]; 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);
for (; word_length > 0; word_length--) { /* In words */
for (; word_length > 0; word_length--) /* In words */
{
templong = *data++; templong = *data++;
templong |= (*data++ << 16); templong |= (*data++ << 16);
status = fix_ft1000_write_dpram32 (ft1000dev, dpram++, (u8 *)&templong); status =
fix_ft1000_write_dpram32
(ft1000dev, dpram++,
(u8 *) & templong);
} }
break; break;
case REQUEST_VERSION_INFO: case REQUEST_VERSION_INFO:
DEBUG("FT1000:download:REQUEST_VERSION_INFO\n"); DEBUG
word_length = file_hdr->version_data_size; ("FT1000:download:REQUEST_VERSION_INFO\n");
put_request_value(ft1000dev, word_length); word_length =
file_hdr->version_data_size;
put_request_value(ft1000dev,
word_length);
/* /*
* Position ASIC DPRAM auto-increment pointer. * Position ASIC DPRAM auto-increment pointer.
*/ */
s_file = (u16 *)(pFileStart + file_hdr->version_data_offset); s_file =
(u16 *) (pFileStart +
file_hdr->
version_data_offset);
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);
for (; word_length > 0; word_length--) { /* In words */
for (; word_length > 0; word_length--) /* In words */
{
templong = ntohs(*s_file++); templong = ntohs(*s_file++);
temp = ntohs(*s_file++); temp = ntohs(*s_file++);
templong |= (temp << 16); templong |= (temp << 16);
status = fix_ft1000_write_dpram32 (ft1000dev, dpram++, (u8 *)&templong); status =
fix_ft1000_write_dpram32
(ft1000dev, dpram++,
(u8 *) & templong);
} }
break; break;
case REQUEST_CODE_BY_VERSION: case REQUEST_CODE_BY_VERSION:
DEBUG("FT1000:download:REQUEST_CODE_BY_VERSION\n"); DEBUG
("FT1000:download:REQUEST_CODE_BY_VERSION\n");
correct_version = FALSE; correct_version = FALSE;
requested_version = get_request_value(ft1000dev); requested_version =
get_request_value(ft1000dev);
dsp_img_info = (struct dsp_image_info *)(pFileStart + sizeof(struct dsp_file_hdr ));
dsp_img_info =
for (image = 0; image < file_hdr->nDspImages; image++) (struct dsp_image_info *)(pFileStart
{ +
sizeof
temp = (u16)(dsp_img_info->version); (struct
dsp_file_hdr));
for (image = 0;
image < file_hdr->nDspImages;
image++) {
temp =
(u16) (dsp_img_info->
version);
templong = temp; templong = temp;
temp = (u16)(dsp_img_info->version >> 16); temp =
(u16) (dsp_img_info->
version >> 16);
templong |= (temp << 16); templong |= (temp << 16);
if (templong == (u32)requested_version) if (templong ==
{ (u32) requested_version) {
correct_version = TRUE; correct_version = TRUE;
DEBUG("FT1000:download: correct_version is TRUE\n"); DEBUG
s_file = (u16 *)(pFileStart + dsp_img_info->begin_offset); ("FT1000:download: correct_version is TRUE\n");
c_file = (u8 *)(pFileStart + dsp_img_info->begin_offset); s_file =
code_end = (u8 *)(pFileStart + dsp_img_info->end_offset); (u16 *) (pFileStart
run_address = dsp_img_info->run_address; +
run_size = dsp_img_info->image_size; dsp_img_info->
image_chksum = (u32)dsp_img_info->checksum; 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; break;
} }
dsp_img_info++; dsp_img_info++;
} //end of for } //end of for
if (!correct_version) if (!correct_version) {
{
/* /*
* Error, beyond boot code range. * Error, beyond boot code range.
*/ */
DEBUG("FT1000:download:Download error: Bad Version Request = 0x%x.\n",(int)requested_version); DEBUG
("FT1000:download:Download error: Bad Version Request = 0x%x.\n",
(int)requested_version);
status = STATUS_FAILURE; status = STATUS_FAILURE;
break; break;
} }
break; break;
default: default:
DEBUG("FT1000:download:Download error: Bad request type=%d in CODE download state.\n",request); DEBUG
("FT1000:download:Download error: Bad request type=%d in CODE download state.\n",
request);
status = STATUS_FAILURE; status = STATUS_FAILURE;
break; break;
} }
if (pft1000info->usbboot) if (pft1000info->usbboot)
put_handshake_usb(ft1000dev, HANDSHAKE_RESPONSE); put_handshake_usb(ft1000dev,
else HANDSHAKE_RESPONSE);
put_handshake(ft1000dev, HANDSHAKE_RESPONSE);
}
else else
{ put_handshake(ft1000dev,
DEBUG("FT1000:download:Download error: Handshake failed\n"); HANDSHAKE_RESPONSE);
} else {
DEBUG
("FT1000:download:Download error: Handshake failed\n");
status = STATUS_FAILURE; status = STATUS_FAILURE;
} }
...@@ -1088,45 +1160,61 @@ u16 scram_dnldr(struct ft1000_device *ft1000dev, void *pFileStart, u32 FileLeng ...@@ -1088,45 +1160,61 @@ u16 scram_dnldr(struct ft1000_device *ft1000dev, void *pFileStart, u32 FileLeng
DEBUG("FT1000:download:STATE_SECTION_PROV\n"); DEBUG("FT1000:download:STATE_SECTION_PROV\n");
pseudo_header = (struct pseudo_hdr *)c_file; pseudo_header = (struct pseudo_hdr *)c_file;
if (pseudo_header->checksum == hdr_checksum(pseudo_header)) if (pseudo_header->checksum ==
{ hdr_checksum(pseudo_header)) {
if (pseudo_header->portdest != 0x80 /* Dsp OAM */) if (pseudo_header->portdest !=
{ 0x80 /* Dsp OAM */ ) {
state = STATE_DONE_PROV; state = STATE_DONE_PROV;
break; break;
} }
pseudo_header_len = ntohs(pseudo_header->length); /* Byte length for PROV records */ pseudo_header_len = ntohs(pseudo_header->length); /* Byte length for PROV records */
// Get buffer for provisioning data // Get buffer for provisioning data
pbuffer = kmalloc((pseudo_header_len + sizeof(struct pseudo_hdr)), GFP_ATOMIC); pbuffer =
kmalloc((pseudo_header_len +
sizeof(struct pseudo_hdr)),
GFP_ATOMIC);
if (pbuffer) { if (pbuffer) {
memcpy(pbuffer, (void *)c_file, (u32)(pseudo_header_len + sizeof(struct pseudo_hdr))); memcpy(pbuffer, (void *)c_file,
(u32) (pseudo_header_len +
sizeof(struct
pseudo_hdr)));
// link provisioning data // link provisioning data
pprov_record = kmalloc(sizeof(struct prov_record), GFP_ATOMIC); pprov_record =
kmalloc(sizeof(struct prov_record),
GFP_ATOMIC);
if (pprov_record) { if (pprov_record) {
pprov_record->pprov_data = pbuffer; pprov_record->pprov_data =
list_add_tail (&pprov_record->list, &pft1000info->prov_list); pbuffer;
list_add_tail(&pprov_record->
list,
&pft1000info->
prov_list);
// Move to next entry if available // Move to next entry if available
c_file = (u8 *)((unsigned long)c_file + (u32)((pseudo_header_len + 1) & 0xFFFFFFFE) + sizeof(struct pseudo_hdr)); c_file =
if ( (unsigned long)(c_file) - (unsigned long)(pFileStart) >= (unsigned long)FileLength) { (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; state = STATE_DONE_FILE;
} }
} } else {
else {
kfree(pbuffer); kfree(pbuffer);
status = STATUS_FAILURE; status = STATUS_FAILURE;
} }
} } else {
else {
status = STATUS_FAILURE; status = STATUS_FAILURE;
} }
} } else {
else
{
/* Checksum did not compute */ /* Checksum did not compute */
status = STATUS_FAILURE; status = STATUS_FAILURE;
} }
DEBUG("ft1000:download: after STATE_SECTION_PROV, state = %d, status= %d\n", state, status); DEBUG
("ft1000:download: after STATE_SECTION_PROV, state = %d, status= %d\n",
state, status);
break; break;
case STATE_DONE_PROV: case STATE_DONE_PROV:
...@@ -1134,7 +1222,6 @@ u16 scram_dnldr(struct ft1000_device *ft1000dev, void *pFileStart, u32 FileLeng ...@@ -1134,7 +1222,6 @@ u16 scram_dnldr(struct ft1000_device *ft1000dev, void *pFileStart, u32 FileLeng
state = STATE_DONE_FILE; state = STATE_DONE_FILE;
break; break;
default: default:
status = STATUS_FAILURE; status = STATUS_FAILURE;
break; break;
...@@ -1160,7 +1247,8 @@ u16 scram_dnldr(struct ft1000_device *ft1000dev, void *pFileStart, u32 FileLeng ...@@ -1160,7 +1247,8 @@ 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;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment