Lines Matching +full:ch +full:- +full:func
6 * Copyright (c) 2001-2013 ATTO Technology, Inc.
22 * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
41 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
108 len--; in esas2r_calc_byte_xor_cksum()
113 len -= 4; in esas2r_calc_byte_xor_cksum()
115 while (len--) { in esas2r_calc_byte_xor_cksum()
127 while (len--) in esas2r_calc_byte_cksum()
136 struct atto_vda_flash_req *vrq = &rq->vrq->flash; in esas2r_fmapi_callback()
138 (struct esas2r_flash_context *)rq->interrupt_cx; in esas2r_fmapi_callback()
140 if (rq->req_stat == RS_SUCCESS) { in esas2r_fmapi_callback()
142 switch (vrq->sub_func) { in esas2r_fmapi_callback()
144 if (fc->sgc.cur_offset == NULL) in esas2r_fmapi_callback()
147 vrq->sub_func = VDA_FLASH_WRITE; in esas2r_fmapi_callback()
148 rq->req_stat = RS_PENDING; in esas2r_fmapi_callback()
153 vrq->sub_func = VDA_FLASH_COMMIT; in esas2r_fmapi_callback()
154 rq->req_stat = RS_PENDING; in esas2r_fmapi_callback()
155 rq->interrupt_cb = fc->interrupt_cb; in esas2r_fmapi_callback()
163 if (rq->req_stat != RS_PENDING) in esas2r_fmapi_callback()
169 (*fc->interrupt_cb)(a, rq); in esas2r_fmapi_callback()
180 (struct esas2r_flash_context *)rq->interrupt_cx; in build_flash_msg()
181 struct esas2r_sg_context *sgc = &fc->sgc; in build_flash_msg()
185 if (fc->func == VDA_FLASH_BEGINW) { in build_flash_msg()
186 if (sgc->cur_offset) in build_flash_msg()
187 cksum = esas2r_calc_byte_xor_cksum(sgc->cur_offset, in build_flash_msg()
188 sgc->length, in build_flash_msg()
190 rq->interrupt_cb = esas2r_fmapi_callback; in build_flash_msg()
192 rq->interrupt_cb = fc->interrupt_cb; in build_flash_msg()
196 fc->func, in build_flash_msg()
198 fc->flsh_addr, in build_flash_msg()
199 sgc->length); in build_flash_msg()
208 fc->curr_len = fc->sgc.length; in build_flash_msg()
210 if (sgc->cur_offset) { in build_flash_msg()
212 esas2r_sgc_init(sgc, a, rq, &rq->vrq->flash.data.sge[0]); in build_flash_msg()
215 rq->req_stat = RS_BUSY; in build_flash_msg()
219 fc->sgc.length = 0; in build_flash_msg()
223 fc->flsh_addr += fc->curr_len; in build_flash_msg()
233 rq->req_stat = RS_PENDING; in load_image()
234 if (test_bit(AF_DEGRADED_MODE, &a->flags)) in load_image()
239 return rq->req_stat == RS_PENDING; in load_image()
245 struct esas2r_component_header *ch = &fi->cmp_hdr[CH_IT_BIOS]; in fix_bios() local
249 pi = (struct esas2r_pc_image *)((u8 *)fi + ch->image_offset); in fix_bios()
252 le16_to_cpu(pi->header_offset)); in fix_bios()
253 bh->device_id = cpu_to_le16(a->pcid->device); in fix_bios()
256 if (pi->pnp_offset) { in fix_bios()
258 ((u8 *)pi + le16_to_cpu(pi->pnp_offset)); in fix_bios()
260 /* Identifier - dword that starts at byte 10 */ in fix_bios()
262 cpu_to_le32(MAKEDWORD(a->pcid->subsystem_vendor, in fix_bios()
263 a->pcid->subsystem_device)); in fix_bios()
265 /* Checksum - byte 9 */ in fix_bios()
266 pnp_header_bytes[9] -= esas2r_calc_byte_cksum(pnp_header_bytes, in fix_bios()
271 pi->checksum = pi->checksum - in fix_bios()
272 esas2r_calc_byte_cksum((u8 *)pi, ch->length, 0); in fix_bios()
277 struct esas2r_component_header *ch = &fi->cmp_hdr[CH_IT_EFI]; in fix_efi() local
278 u32 len = ch->length; in fix_efi()
279 u32 offset = ch->image_offset; in fix_efi()
289 ei->header_offset)); in fix_efi()
290 bh->device_id = cpu_to_le16(a->pcid->device); in fix_efi()
291 thislen = (u32)le16_to_cpu(bh->image_length) * 512; in fix_efi()
296 len -= thislen; in fix_efi()
306 (struct esas2r_flash_context *)rq->interrupt_cx; in complete_fmapi_req()
307 struct esas2r_flash_img *fi = fc->fi; in complete_fmapi_req()
309 fi->status = fi_stat; in complete_fmapi_req()
310 fi->driver_error = rq->req_stat; in complete_fmapi_req()
311 rq->interrupt_cb = NULL; in complete_fmapi_req()
312 rq->req_stat = RS_SUCCESS; in complete_fmapi_req()
315 memset(fc->scratch, 0, FM_BUF_SZ); in complete_fmapi_req()
318 clear_bit(AF_FLASH_LOCK, &a->flags); in complete_fmapi_req()
327 (struct esas2r_flash_context *)rq->interrupt_cx; in fw_download_proc()
328 struct esas2r_flash_img *fi = fc->fi; in fw_download_proc()
329 struct esas2r_component_header *ch; in fw_download_proc() local
334 if (rq->req_stat != RS_SUCCESS) in fw_download_proc()
338 * If an upload just completed and the compare length is non-zero, in fw_download_proc()
342 if (fc->func == VDA_FLASH_READ in fw_download_proc()
343 && fc->cmp_len) { in fw_download_proc()
344 ch = &fi->cmp_hdr[fc->comp_typ]; in fw_download_proc()
346 p = fc->scratch; in fw_download_proc()
348 + ch->image_offset /* start of the current image */ in fw_download_proc()
349 + ch->length /* end of the current image */ in fw_download_proc()
350 - fc->cmp_len; /* where we are now */ in fw_download_proc()
353 * NOTE - curr_len is the exact count of bytes for the read in fw_download_proc()
356 for (len = fc->curr_len; len; len--) in fw_download_proc()
360 fc->cmp_len -= fc->curr_len; /* # left to compare */ in fw_download_proc()
363 if (fc->cmp_len > FM_BUF_SZ) in fw_download_proc()
364 fc->sgc.length = FM_BUF_SZ; in fw_download_proc()
366 fc->sgc.length = fc->cmp_len; in fw_download_proc()
368 fc->sgc.cur_offset = fc->sgc_offset + in fw_download_proc()
369 ((u8 *)fc->scratch - (u8 *)fi); in fw_download_proc()
378 while (fc->sgc.length == 0) { in fw_download_proc()
379 ch = &fi->cmp_hdr[fc->comp_typ]; in fw_download_proc()
381 switch (fc->task) { in fw_download_proc()
384 ch = &fi->cmp_hdr[CH_IT_BIOS]; in fw_download_proc()
385 if (ch->length == 0) in fw_download_proc()
388 fc->task = FMTSK_WRTBIOS; in fw_download_proc()
389 fc->func = VDA_FLASH_BEGINW; in fw_download_proc()
390 fc->comp_typ = CH_IT_BIOS; in fw_download_proc()
391 fc->flsh_addr = FLS_OFFSET_BOOT; in fw_download_proc()
392 fc->sgc.length = ch->length; in fw_download_proc()
393 fc->sgc.cur_offset = fc->sgc_offset + in fw_download_proc()
394 ch->image_offset; in fw_download_proc()
399 * The BIOS image has been written - read it and in fw_download_proc()
402 fc->task = FMTSK_READBIOS; in fw_download_proc()
403 fc->func = VDA_FLASH_READ; in fw_download_proc()
404 fc->flsh_addr = FLS_OFFSET_BOOT; in fw_download_proc()
405 fc->cmp_len = ch->length; in fw_download_proc()
406 fc->sgc.length = FM_BUF_SZ; in fw_download_proc()
407 fc->sgc.cur_offset = fc->sgc_offset in fw_download_proc()
408 + ((u8 *)fc->scratch - in fw_download_proc()
418 ch->status = CH_STAT_SUCCESS; in fw_download_proc()
421 ch = &fi->cmp_hdr[CH_IT_MAC]; in fw_download_proc()
422 if (ch->length == 0) in fw_download_proc()
425 fc->task = FMTSK_WRTMAC; in fw_download_proc()
426 fc->func = VDA_FLASH_BEGINW; in fw_download_proc()
427 fc->comp_typ = CH_IT_MAC; in fw_download_proc()
428 fc->flsh_addr = FLS_OFFSET_BOOT in fw_download_proc()
429 + fi->cmp_hdr[CH_IT_BIOS].length; in fw_download_proc()
430 fc->sgc.length = ch->length; in fw_download_proc()
431 fc->sgc.cur_offset = fc->sgc_offset + in fw_download_proc()
432 ch->image_offset; in fw_download_proc()
436 /* The MAC image has been written - read and verify */ in fw_download_proc()
437 fc->task = FMTSK_READMAC; in fw_download_proc()
438 fc->func = VDA_FLASH_READ; in fw_download_proc()
439 fc->flsh_addr -= ch->length; in fw_download_proc()
440 fc->cmp_len = ch->length; in fw_download_proc()
441 fc->sgc.length = FM_BUF_SZ; in fw_download_proc()
442 fc->sgc.cur_offset = fc->sgc_offset in fw_download_proc()
443 + ((u8 *)fc->scratch - in fw_download_proc()
453 ch->status = CH_STAT_SUCCESS; in fw_download_proc()
456 ch = &fi->cmp_hdr[CH_IT_EFI]; in fw_download_proc()
457 if (ch->length == 0) in fw_download_proc()
460 fc->task = FMTSK_WRTEFI; in fw_download_proc()
461 fc->func = VDA_FLASH_BEGINW; in fw_download_proc()
462 fc->comp_typ = CH_IT_EFI; in fw_download_proc()
463 fc->flsh_addr = FLS_OFFSET_BOOT in fw_download_proc()
464 + fi->cmp_hdr[CH_IT_BIOS].length in fw_download_proc()
465 + fi->cmp_hdr[CH_IT_MAC].length; in fw_download_proc()
466 fc->sgc.length = ch->length; in fw_download_proc()
467 fc->sgc.cur_offset = fc->sgc_offset + in fw_download_proc()
468 ch->image_offset; in fw_download_proc()
472 /* The EFI image has been written - read and verify */ in fw_download_proc()
473 fc->task = FMTSK_READEFI; in fw_download_proc()
474 fc->func = VDA_FLASH_READ; in fw_download_proc()
475 fc->flsh_addr -= ch->length; in fw_download_proc()
476 fc->cmp_len = ch->length; in fw_download_proc()
477 fc->sgc.length = FM_BUF_SZ; in fw_download_proc()
478 fc->sgc.cur_offset = fc->sgc_offset in fw_download_proc()
479 + ((u8 *)fc->scratch - in fw_download_proc()
489 ch->status = CH_STAT_SUCCESS; in fw_download_proc()
492 ch = &fi->cmp_hdr[CH_IT_CFG]; in fw_download_proc()
494 if (ch->length == 0) in fw_download_proc()
496 fc->task = FMTSK_WRTCFG; in fw_download_proc()
497 fc->func = VDA_FLASH_BEGINW; in fw_download_proc()
498 fc->comp_typ = CH_IT_CFG; in fw_download_proc()
499 fc->flsh_addr = FLS_OFFSET_CPYR - ch->length; in fw_download_proc()
500 fc->sgc.length = ch->length; in fw_download_proc()
501 fc->sgc.cur_offset = fc->sgc_offset + in fw_download_proc()
502 ch->image_offset; in fw_download_proc()
506 /* The CFG image has been written - read and verify */ in fw_download_proc()
507 fc->task = FMTSK_READCFG; in fw_download_proc()
508 fc->func = VDA_FLASH_READ; in fw_download_proc()
509 fc->flsh_addr = FLS_OFFSET_CPYR - ch->length; in fw_download_proc()
510 fc->cmp_len = ch->length; in fw_download_proc()
511 fc->sgc.length = FM_BUF_SZ; in fw_download_proc()
512 fc->sgc.cur_offset = fc->sgc_offset in fw_download_proc()
513 + ((u8 *)fc->scratch - in fw_download_proc()
523 ch->status = CH_STAT_SUCCESS; in fw_download_proc()
529 if (test_bit(AF_DEGRADED_MODE, &a->flags)) in fw_download_proc()
532 a->flash_ver = fi->cmp_hdr[CH_IT_BIOS].version; in fw_download_proc()
536 memcpy(a->image_type, fi->rel_version, in fw_download_proc()
537 sizeof(fi->rel_version)); in fw_download_proc()
543 if (fc->func == VDA_FLASH_READ in fw_download_proc()
544 && fc->sgc.length > fc->cmp_len) in fw_download_proc()
545 fc->sgc.length = fc->cmp_len; in fw_download_proc()
551 if (fc->comp_typ < fi->num_comps) { in fw_download_proc()
552 ch = &fi->cmp_hdr[fc->comp_typ]; in fw_download_proc()
553 ch->status = CH_STAT_FAILED; in fw_download_proc()
566 switch (a->pcid->device) { in get_fi_adap_type()
589 u16 *pw = (u16 *)cfg - 1; in chk_cfg()
603 type = le16_to_cpu(*pw--); in chk_cfg()
604 size = le16_to_cpu(*pw--); in chk_cfg()
613 *flash_ver = le32_to_cpu(*(u32 *)(pw - 1)); in chk_cfg()
616 pw -= size / sizeof(u16); in chk_cfg()
618 if (sz > len - (2 * sizeof(u16))) in chk_cfg()
633 u16 hdroffset = le16_to_cpu(bi->header_offset); in chk_boot()
636 if (bi->signature != le16_to_cpu(0xaa55) in chk_boot()
638 (long)(65536L - sizeof(struct esas2r_boot_header)) in chk_boot()
646 if (bh->signature[0] != 'P' in chk_boot()
647 || bh->signature[1] != 'C' in chk_boot()
648 || bh->signature[2] != 'I' in chk_boot()
649 || bh->signature[3] != 'R' in chk_boot()
650 || le16_to_cpu(bh->struct_length) < in chk_boot()
652 || bh->class_code[2] != 0x01 in chk_boot()
653 || bh->class_code[1] != 0x04 in chk_boot()
654 || bh->class_code[0] != 0x00 in chk_boot()
655 || (bh->code_type != CODE_TYPE_PC in chk_boot()
656 && bh->code_type != CODE_TYPE_OPEN in chk_boot()
657 && bh->code_type != CODE_TYPE_EFI)) in chk_boot()
660 return bh->code_type; in chk_boot()
666 struct esas2r_flash_img *fi = fc->fi; in calc_fi_checksum()
671 for (len = (fi->length - fc->fi_hdr_len) / 2, in calc_fi_checksum()
672 pw = (u16 *)((u8 *)fi + fc->fi_hdr_len), in calc_fi_checksum()
675 len--, pw++) in calc_fi_checksum()
695 struct esas2r_flash_img *fi = fc->fi; in verify_fi()
700 struct esas2r_component_header *ch; in verify_fi() local
702 /* Verify the length - length must even since we do a word checksum */ in verify_fi()
703 len = fi->length; in verify_fi()
706 || len < fc->fi_hdr_len) { in verify_fi()
707 fi->status = FI_STAT_LENGTH; in verify_fi()
713 if ((type == FI_AT_UNKNWN) || (fi->adap_typ != type)) { in verify_fi()
714 fi->status = FI_STAT_ADAPTYP; in verify_fi()
725 for (i = 0, len = 0, ch = fi->cmp_hdr; in verify_fi()
726 i < fi->num_comps; in verify_fi()
727 i++, ch++) { in verify_fi()
734 if (i != ch->img_type) { in verify_fi()
736 ch->status = CH_STAT_INVALID; in verify_fi()
740 switch (ch->img_type) { in verify_fi()
754 switch (ch->img_type) { in verify_fi()
762 if (ch->length & 0x1ff) in verify_fi()
766 if (ch->length == 0) in verify_fi()
769 /* Image is present - verify the image */ in verify_fi()
770 if (chk_boot((u8 *)fi + ch->image_offset, ch->length) in verify_fi()
779 if (ch->length == 0) { in verify_fi()
784 /* Image is present - verify the image */ in verify_fi()
785 if (!chk_cfg((u8 *)fi + ch->image_offset + ch->length, in verify_fi()
786 ch->length, NULL)) in verify_fi()
793 fi->status = FI_STAT_UNKNOWN; in verify_fi()
799 ch->status = CH_STAT_INVALID; in verify_fi()
801 ch->status = CH_STAT_PENDING; in verify_fi()
802 len += ch->length; in verify_fi()
807 fi->status = FI_STAT_MISSING; in verify_fi()
811 /* Compare fi->length to the sum of ch->length fields */ in verify_fi()
812 if (len != fi->length - fc->fi_hdr_len) { in verify_fi()
813 fi->status = FI_STAT_LENGTH; in verify_fi()
817 /* Compute the checksum - it should come out zero */ in verify_fi()
818 if (fi->checksum != calc_fi_checksum(fc)) { in verify_fi()
819 fi->status = FI_STAT_CHKSUM; in verify_fi()
831 (struct esas2r_ioctl_fs *)rq->interrupt_cx; in esas2r_complete_fs_ioctl()
833 if (rq->vrq->flash.sub_func == VDA_FLASH_COMMIT) in esas2r_complete_fs_ioctl()
836 fs->driver_error = rq->req_stat; in esas2r_complete_fs_ioctl()
838 if (fs->driver_error == RS_SUCCESS) in esas2r_complete_fs_ioctl()
839 fs->status = ATTO_STS_SUCCESS; in esas2r_complete_fs_ioctl()
841 fs->status = ATTO_STS_FAILED; in esas2r_complete_fs_ioctl()
851 struct esas2r_ioctlfs_command *fsc = &fs->command; in esas2r_process_fs_ioctl()
852 u8 func = 0; in esas2r_process_fs_ioctl() local
855 fs->status = ATTO_STS_FAILED; in esas2r_process_fs_ioctl()
856 fs->driver_error = RS_PENDING; in esas2r_process_fs_ioctl()
858 if (fs->version > ESAS2R_FS_VER) { in esas2r_process_fs_ioctl()
859 fs->status = ATTO_STS_INV_VERSION; in esas2r_process_fs_ioctl()
863 if (fsc->command >= cmdcnt) { in esas2r_process_fs_ioctl()
864 fs->status = ATTO_STS_INV_FUNC; in esas2r_process_fs_ioctl()
868 func = cmd_to_fls_func[fsc->command]; in esas2r_process_fs_ioctl()
869 if (func == 0xFF) { in esas2r_process_fs_ioctl()
870 fs->status = ATTO_STS_INV_FUNC; in esas2r_process_fs_ioctl()
874 if (fsc->command != ESAS2R_FS_CMD_CANCEL) { in esas2r_process_fs_ioctl()
875 if ((a->pcid->device != ATTO_DID_MV_88RC9580 in esas2r_process_fs_ioctl()
876 || fs->adap_type != ESAS2R_FS_AT_ESASRAID2) in esas2r_process_fs_ioctl()
877 && (a->pcid->device != ATTO_DID_MV_88RC9580TS in esas2r_process_fs_ioctl()
878 || fs->adap_type != ESAS2R_FS_AT_TSSASRAID2) in esas2r_process_fs_ioctl()
879 && (a->pcid->device != ATTO_DID_MV_88RC9580TSE in esas2r_process_fs_ioctl()
880 || fs->adap_type != ESAS2R_FS_AT_TSSASRAID2E) in esas2r_process_fs_ioctl()
881 && (a->pcid->device != ATTO_DID_MV_88RC9580TL in esas2r_process_fs_ioctl()
882 || fs->adap_type != ESAS2R_FS_AT_TLSASHBA)) { in esas2r_process_fs_ioctl()
883 fs->status = ATTO_STS_INV_ADAPTER; in esas2r_process_fs_ioctl()
887 if (fs->driver_ver > ESAS2R_FS_DRVR_VER) { in esas2r_process_fs_ioctl()
888 fs->status = ATTO_STS_INV_DRVR_VER; in esas2r_process_fs_ioctl()
893 if (test_bit(AF_DEGRADED_MODE, &a->flags)) { in esas2r_process_fs_ioctl()
894 fs->status = ATTO_STS_DEGRADED; in esas2r_process_fs_ioctl()
898 rq->interrupt_cb = esas2r_complete_fs_ioctl; in esas2r_process_fs_ioctl()
899 rq->interrupt_cx = fs; in esas2r_process_fs_ioctl()
900 datalen = le32_to_cpu(fsc->length); in esas2r_process_fs_ioctl()
903 func, in esas2r_process_fs_ioctl()
904 fsc->checksum, in esas2r_process_fs_ioctl()
905 le32_to_cpu(fsc->flash_addr), in esas2r_process_fs_ioctl()
908 if (func == VDA_FLASH_WRITE in esas2r_process_fs_ioctl()
909 || func == VDA_FLASH_READ) { in esas2r_process_fs_ioctl()
911 fs->status = ATTO_STS_INV_FUNC; in esas2r_process_fs_ioctl()
915 esas2r_sgc_init(sgc, a, rq, rq->vrq->flash.data.sge); in esas2r_process_fs_ioctl()
916 sgc->length = datalen; in esas2r_process_fs_ioctl()
919 fs->status = ATTO_STS_OUT_OF_RSRC; in esas2r_process_fs_ioctl()
924 if (func == VDA_FLASH_COMMIT) in esas2r_process_fs_ioctl()
949 if (test_bit(AF_CHPRST_PENDING, &a->flags) || in esas2r_flash_access()
950 test_bit(AF_DISC_PENDING, &a->flags)) in esas2r_flash_access()
970 if ((jiffies_to_msecs(jiffies) - starttime) > timeout) { in esas2r_flash_access()
974 * up. If this was a REQ, we also need to re-enable in esas2r_flash_access()
990 /* if we're done, re-enable chip interrupts */ in esas2r_flash_access()
1015 if (test_bit(AF2_SERIAL_FLASH, &a->flags2)) in esas2r_read_flash_block()
1016 iatvr = MW_DATA_ADDR_SER_FLASH + (from & -WINDOW_SIZE); in esas2r_read_flash_block()
1018 iatvr = MW_DATA_ADDR_PAR_FLASH + (from & -WINDOW_SIZE); in esas2r_read_flash_block()
1021 offset = from & (WINDOW_SIZE - 1); in esas2r_read_flash_block()
1024 if (len > WINDOW_SIZE - offset) in esas2r_read_flash_block()
1025 len = WINDOW_SIZE - offset; in esas2r_read_flash_block()
1028 size -= len; in esas2r_read_flash_block()
1030 while (len--) { in esas2r_read_flash_block()
1054 if (!esas2r_read_flash_block(a, bytes, FLS_OFFSET_CPYR - sz, sz)) in esas2r_read_flash_rev()
1058 pw--; in esas2r_read_flash_rev()
1060 pw--; in esas2r_read_flash_rev()
1062 pw -= size / 2; in esas2r_read_flash_rev()
1070 a->flash_ver = le32_to_cpu(*(u32 *)pw); in esas2r_read_flash_rev()
1081 u16 year = LOWORD(a->flash_ver); in esas2r_print_flash_rev()
1082 u8 day = LOBYTE(HIWORD(a->flash_ver)); in esas2r_print_flash_rev()
1083 u8 month = HIBYTE(HIWORD(a->flash_ver)); in esas2r_print_flash_rev()
1091 strcpy(a->flash_rev, "not found"); in esas2r_print_flash_rev()
1092 a->flash_ver = 0; in esas2r_print_flash_rev()
1096 sprintf(a->flash_rev, "%02d/%02d/%04d", month, day, year); in esas2r_print_flash_rev()
1097 esas2r_hdebug("flash version: %s", a->flash_rev); in esas2r_print_flash_rev()
1103 * The chip only has a 64 KB PCI-e expansion ROM
1129 bi->header_offset)); in esas2r_read_image_type()
1130 if (bi->signature != cpu_to_le16(0xAA55)) in esas2r_read_image_type()
1133 if (bh->code_type == CODE_TYPE_PC) { in esas2r_read_image_type()
1134 strcpy(a->image_type, "BIOS"); in esas2r_read_image_type()
1137 } else if (bh->code_type == CODE_TYPE_EFI) { in esas2r_read_image_type()
1146 switch (le16_to_cpu(ei->machine_type)) { in esas2r_read_image_type()
1148 strcpy(a->image_type, "EFI 32-bit"); in esas2r_read_image_type()
1152 strcpy(a->image_type, "EFI itanium"); in esas2r_read_image_type()
1156 strcpy(a->image_type, "EFI 64-bit"); in esas2r_read_image_type()
1160 strcpy(a->image_type, "EFI EBC"); in esas2r_read_image_type()
1170 thislen = (u32)le16_to_cpu(bh->image_length) * 512; in esas2r_read_image_type()
1173 || bh->indicator == INDICATOR_LAST) in esas2r_read_image_type()
1181 strcpy(a->image_type, "no boot images"); in esas2r_read_image_type()
1194 if (down_interruptible(&a->nvram_semaphore)) in esas2r_nvram_read_direct()
1197 if (!esas2r_read_flash_block(a, a->nvram, FLS_OFFSET_NVR, in esas2r_nvram_read_direct()
1200 up(&a->nvram_semaphore); in esas2r_nvram_read_direct()
1206 up(&a->nvram_semaphore); in esas2r_nvram_read_direct()
1215 struct atto_vda_flash_req *vrq = &rq->vrq->flash; in esas2r_nvram_callback()
1217 if (rq->req_stat == RS_SUCCESS) { in esas2r_nvram_callback()
1220 switch (vrq->sub_func) { in esas2r_nvram_callback()
1222 vrq->sub_func = VDA_FLASH_WRITE; in esas2r_nvram_callback()
1223 rq->req_stat = RS_PENDING; in esas2r_nvram_callback()
1227 vrq->sub_func = VDA_FLASH_COMMIT; in esas2r_nvram_callback()
1228 rq->req_stat = RS_PENDING; in esas2r_nvram_callback()
1241 if (rq->req_stat != RS_PENDING) { in esas2r_nvram_callback()
1243 if (rq->req_stat == RS_SUCCESS) in esas2r_nvram_callback()
1244 set_bit(AF_NVR_VALID, &a->flags); in esas2r_nvram_callback()
1246 clear_bit(AF_NVR_VALID, &a->flags); in esas2r_nvram_callback()
1250 up(&a->nvram_semaphore); in esas2r_nvram_callback()
1264 struct atto_vda_flash_req *vrq = &rq->vrq->flash; in esas2r_nvram_write()
1266 if (test_bit(AF_DEGRADED_MODE, &a->flags)) in esas2r_nvram_write()
1269 if (down_interruptible(&a->nvram_semaphore)) in esas2r_nvram_write()
1273 n = a->nvram; in esas2r_nvram_write()
1276 if (n->version > SASNVR_VERSION) { in esas2r_nvram_write()
1277 up(&a->nvram_semaphore); in esas2r_nvram_write()
1281 memcpy(&sas_address_bytes[0], n->sas_addr, 8); in esas2r_nvram_write()
1288 up(&a->nvram_semaphore); in esas2r_nvram_write()
1292 if (n->spin_up_delay > SASNVR_SPINUP_MAX) in esas2r_nvram_write()
1293 n->spin_up_delay = SASNVR_SPINUP_MAX; in esas2r_nvram_write()
1295 n->version = SASNVR_VERSION; in esas2r_nvram_write()
1296 n->checksum = n->checksum - esas2r_nvramcalc_cksum(n); in esas2r_nvram_write()
1297 memcpy(a->nvram, n, sizeof(struct esas2r_sas_nvram)); in esas2r_nvram_write()
1300 n = a->nvram; in esas2r_nvram_write()
1310 if (test_bit(AF_LEGACY_SGE_MODE, &a->flags)) { in esas2r_nvram_write()
1312 vrq->data.sge[0].length = in esas2r_nvram_write()
1315 vrq->data.sge[0].address = cpu_to_le64( in esas2r_nvram_write()
1316 a->uncached_phys + (u64)((u8 *)n - a->uncached)); in esas2r_nvram_write()
1318 vrq->data.prde[0].ctl_len = in esas2r_nvram_write()
1320 vrq->data.prde[0].address = cpu_to_le64( in esas2r_nvram_write()
1321 a->uncached_phys in esas2r_nvram_write()
1322 + (u64)((u8 *)n - a->uncached)); in esas2r_nvram_write()
1324 rq->interrupt_cb = esas2r_nvram_callback; in esas2r_nvram_write()
1332 struct esas2r_sas_nvram *n = a->nvram; in esas2r_nvram_validate()
1335 if (n->signature[0] != 'E' in esas2r_nvram_validate()
1336 || n->signature[1] != 'S' in esas2r_nvram_validate()
1337 || n->signature[2] != 'A' in esas2r_nvram_validate()
1338 || n->signature[3] != 'S') { in esas2r_nvram_validate()
1342 } else if (n->version > SASNVR_VERSION) { in esas2r_nvram_validate()
1345 set_bit(AF_NVR_VALID, &a->flags); in esas2r_nvram_validate()
1364 struct esas2r_sas_nvram *n = a->nvram; in esas2r_nvram_set_defaults()
1367 clear_bit(AF_NVR_VALID, &a->flags); in esas2r_nvram_set_defaults()
1369 n->sas_addr[3] |= 0x0F; in esas2r_nvram_set_defaults()
1370 n->sas_addr[4] = HIBYTE(LOWORD(time)); in esas2r_nvram_set_defaults()
1371 n->sas_addr[5] = LOBYTE(LOWORD(time)); in esas2r_nvram_set_defaults()
1372 n->sas_addr[6] = a->pcid->bus->number; in esas2r_nvram_set_defaults()
1373 n->sas_addr[7] = a->pcid->devfn; in esas2r_nvram_set_defaults()
1385 memcpy(&sas_addr[0], a->nvram->sas_addr, 8); in esas2r_nvram_get_defaults()
1387 memcpy(&nvram->sas_addr[0], &sas_addr[0], 8); in esas2r_nvram_get_defaults()
1393 struct esas2r_flash_context *fc = &a->flash_context; in esas2r_fm_api()
1395 struct esas2r_component_header *ch; in esas2r_fm_api() local
1397 if (test_and_set_bit(AF_FLASH_LOCK, &a->flags)) { in esas2r_fm_api()
1399 fi->status = FI_STAT_BUSY; in esas2r_fm_api()
1403 memcpy(&fc->sgc, sgc, sizeof(struct esas2r_sg_context)); in esas2r_fm_api()
1404 sgc = &fc->sgc; in esas2r_fm_api()
1405 fc->fi = fi; in esas2r_fm_api()
1406 fc->sgc_offset = sgc->cur_offset; in esas2r_fm_api()
1407 rq->req_stat = RS_SUCCESS; in esas2r_fm_api()
1408 rq->interrupt_cx = fc; in esas2r_fm_api()
1410 switch (fi->fi_version) { in esas2r_fm_api()
1412 fc->scratch = ((struct esas2r_flash_img *)fi)->scratch_buf; in esas2r_fm_api()
1413 fc->num_comps = FI_NUM_COMPS_V1; in esas2r_fm_api()
1414 fc->fi_hdr_len = sizeof(struct esas2r_flash_img); in esas2r_fm_api()
1421 if (test_bit(AF_DEGRADED_MODE, &a->flags)) in esas2r_fm_api()
1424 switch (fi->action) { in esas2r_fm_api()
1428 return complete_fmapi_req(a, rq, fi->status); in esas2r_fm_api()
1431 ch = &fi->cmp_hdr[CH_IT_BIOS]; in esas2r_fm_api()
1433 if (ch->length) in esas2r_fm_api()
1437 ch = &fi->cmp_hdr[CH_IT_EFI]; in esas2r_fm_api()
1439 if (ch->length) in esas2r_fm_api()
1447 fi->checksum = calc_fi_checksum(fc); in esas2r_fm_api()
1453 fc->task = FMTSK_ERASE_BOOT; in esas2r_fm_api()
1454 fc->func = VDA_FLASH_BEGINW; in esas2r_fm_api()
1455 fc->comp_typ = CH_IT_CFG; in esas2r_fm_api()
1456 fc->flsh_addr = FLS_OFFSET_BOOT; in esas2r_fm_api()
1457 fc->sgc.length = FLS_LENGTH_BOOT; in esas2r_fm_api()
1458 fc->sgc.cur_offset = NULL; in esas2r_fm_api()
1461 fc->interrupt_cb = fw_download_proc; in esas2r_fm_api()
1465 fi->adap_typ = get_fi_adap_type(a); in esas2r_fm_api()
1466 fi->flags = 0; in esas2r_fm_api()
1467 fi->num_comps = fc->num_comps; in esas2r_fm_api()
1468 fi->length = fc->fi_hdr_len; in esas2r_fm_api()
1471 memcpy(fi->rel_version, a->image_type, in esas2r_fm_api()
1472 sizeof(fi->rel_version)); in esas2r_fm_api()
1475 for (j = 0, ch = fi->cmp_hdr; in esas2r_fm_api()
1476 j < fi->num_comps; in esas2r_fm_api()
1477 j++, ch++) { in esas2r_fm_api()
1478 ch->img_type = j; in esas2r_fm_api()
1479 ch->status = CH_STAT_PENDING; in esas2r_fm_api()
1480 ch->length = 0; in esas2r_fm_api()
1481 ch->version = 0xffffffff; in esas2r_fm_api()
1482 ch->image_offset = 0; in esas2r_fm_api()
1483 ch->pad[0] = 0; in esas2r_fm_api()
1484 ch->pad[1] = 0; in esas2r_fm_api()
1487 if (a->flash_ver != 0) { in esas2r_fm_api()
1488 fi->cmp_hdr[CH_IT_BIOS].version = in esas2r_fm_api()
1489 fi->cmp_hdr[CH_IT_MAC].version = in esas2r_fm_api()
1490 fi->cmp_hdr[CH_IT_EFI].version = in esas2r_fm_api()
1491 fi->cmp_hdr[CH_IT_CFG].version in esas2r_fm_api()
1492 = a->flash_ver; in esas2r_fm_api()
1494 fi->cmp_hdr[CH_IT_BIOS].status = in esas2r_fm_api()
1495 fi->cmp_hdr[CH_IT_MAC].status = in esas2r_fm_api()
1496 fi->cmp_hdr[CH_IT_EFI].status = in esas2r_fm_api()
1497 fi->cmp_hdr[CH_IT_CFG].status = in esas2r_fm_api()