📄 i28f016.c
字号:
dBuffer++; dFlashPtr++; while (!(dFlashPtr[-1] & (WSM_READY)) && flMsecCounter < writeTimeout) ; } if (cLength > 0) goto lastWord; }/*donleo1121 ,back the value*/ vol.interleaving = iInterleaving;/**/ flashPtr -= length; bBuffer -= length; wordFlashPtr = (FlashWPTR)flashPtr; /*donleo for 16 bit wirte */ status = flOK; for (i = 0; i < vol.interleaving && i < length; i++) { if (flashPtr[i] & WSM_ERROR) { #ifdef DEBUG_PRINT DEBUG_PRINT("Debug: write failed for 8-bit Intel media.\n"); #endif status = (flashPtr[i] & WSM_VPP_ERROR) ? flVppFailure : flWriteFault; wordFlashPtr[i] = CLEAR_STATUS; /*donleo for 16 bit*/ } wordFlashPtr[i] = READ_ARRAY; /*donleo for 16 bit*/ } /* we need this to switch to the read window */ flashPtr = (FlashPTR) vol.map(&vol, address,length); /* ADDED */ /* verify the data */ if (status == flOK && tffscmp((void FAR0 *) flashPtr,buffer,length)) { #ifdef DEBUG_PRINT DEBUG_PRINT("Debug: write failed for 8-bit Intel media in verification.\n"); #endif status = flWriteFault; } sysFlashWriteDisable(); return status;}/*----------------------------------------------------------------------*//* i 2 8 f 0 1 6 E r a s e *//* *//* Erase one or more contiguous Flash erasable blocks *//* *//* This routine will be registered as the MTD vol.erase routine *//* *//* Parameters: *//* vol : Pointer identifying drive *//* firstErasableBlock : Number of first block to erase *//* numOfErasableBlocks: Number of blocks to erase *//* *//* Returns: *//* FLStatus : 0 on success, failed otherwise *//*----------------------------------------------------------------------*/static FLStatus i28f016Erase(FLFlash vol, int firstErasableBlock, int numOfErasableBlocks){ FLStatus status = flOK; /* unless proven otherwise */ int iBlock; sysFlashWriteEnable(); /*donleo1121,enable */ if (flWriteProtected(vol.socket)) return flWriteProtect;#ifdef SOCKET_12_VOLTS checkStatus(flNeedVpp(vol.socket));#endif for (iBlock = 0; iBlock < numOfErasableBlocks && status == flOK; iBlock++) { FlashWPTR currPtr; int i; FLBoolean finished; FlashWPTR flashPtr = (FlashWPTR) flMap(vol.socket,(firstErasableBlock + iBlock) * vol.erasableBlockSize); for (i = 0, currPtr = flashPtr; i < vol.interleaving; i += 2, currPtr++) { *currPtr = SETUP_ERASE; *currPtr = CONFIRM_ERASE; } do {#ifdef BACKGROUND while (flForeground(1) == BG_SUSPEND) { /* suspend */ for (i = 0, currPtr = flashPtr; i < vol.interleaving; i += 2, currPtr++) { *currPtr = READ_STATUS; if (!(both(*currPtr) & WSM_READY)) { *currPtr = SUSPEND_ERASE; *currPtr = READ_STATUS; while (!(both(*currPtr) & WSM_READY)) ; } *currPtr = READ_ARRAY; } }#endif finished = TRUE; for (i = 0, currPtr = flashPtr; i < vol.interleaving; i += 2, currPtr++) { *currPtr = READ_STATUS; if (any(*currPtr) & WSM_SUSPENDED) { *currPtr = RESUME_ERASE; finished = FALSE; } else if (!(both(*currPtr) & WSM_READY)) finished = FALSE; else { if (any(*currPtr) & WSM_ERROR) { #ifdef DEBUG_PRINT DEBUG_PRINT("Debug: erase failed for 16-bit Intel media.\n"); #endif status = (any(*currPtr) & WSM_VPP_ERROR) ? flVppFailure : flWriteFault; *currPtr = CLEAR_STATUS; } *currPtr = READ_ARRAY; } } } while (!finished); } sysFlashWriteDisable(); /*donleo*/#ifdef SOCKET_12_VOLTS flDontNeedVpp(vol.socket);#endif return status;}/*----------------------------------------------------------------------*//* i 2 8 f 0 1 6 I d e n t i f y *//* *//* Identifies media based on Intel 28F016 and registers as an MTD for *//* such. *//* *//* This routine will be placed on the MTD list in custom.h. It must be *//* an extern routine. *//* *//* On successful identification, the Flash structure is filled out and *//* the write and erase routines registered. *//* *//* Parameters: *//* vol : Pointer identifying drive *//* *//* Returns: *//* FLStatus : 0 on positive identificaion, failed otherwise *//*----------------------------------------------------------------------*/FLStatus i28f016Identify(FLFlash vol){ FlashWPTR flashPtr;#ifdef DEBUG_PRINT DEBUG_PRINT("Debug: entering 16-bit Intel media identification routine.\n");#endif sysFlashWriteEnable(); /*donleo*/ flSetWindowBusWidth(vol.socket,16);/* donleo:use 16-bits,bit related*/ flSetWindowSpeed(vol.socket,120); /* 120 nsec. */ flSetWindowSize(vol.socket,2); /*donleo:vol.window.size = (long) (sizeIn4KBunits) * 0x1000L;,but can be changed by simmSetWindow,will be flash size*/ flashPtr = (FlashWPTR) flMap(vol.socket,0); /*donleo:vol.window.base + address & (vol.window.size - 1),address will add per eraseable size*/ vol.noOfChips = 0; flashPtr[0] = READ_ID; if (flashPtr[0] == 0x0089) { /*donleo bit related, please get it by m and d*/ /* Word mode */ vol.type = I28F016_FLASH; vol.interleaving = 1; flashPtr[0] = READ_ARRAY; } else { /* Use standard identification routine to detect byte-mode */ flIntelIdentify(&vol, NULL,0); if (vol.interleaving == 1) vol.type = NOT_FLASH; /* We cannot handle byte-mode interleaving-1 */ } if (vol.type == I28F016_FLASH) { if(vol.socket->serialNo == 0) /* add by luhb 2007-03-16 */ vol.chipSize = TFFS_SIZE; /*donleo: FLASH_SIZE-NVRAM_SIZE*/ #if defined(FLASH_PARTITION2) && !defined(INCLUDE_FLASH_NO2) else if (vol.socket->serialNo == 1) vol.chipSize = TFFS_SIZE1; #endif /* defined(FLASH_PARTITION2) && !defined(INCLUDE_FLASH_NO2) by luhb 2007-03-23 */ #if !defined(FLASH_PARTITION2) && defined(INCLUDE_FLASH_NO2) else if (vol.socket->serialNo == 1) vol.chipSize = TFFS_SIZE_NO2; #endif /* !defined(FLASH_PARTITION2) && defined(INCLUDE_FLASH_NO2) by luhb 2007-03-23 */ #if defined(FLASH_PARTITION2) && defined(INCLUDE_FLASH_NO2) else if (vol.socket->serialNo == 1) vol.chipSize = TFFS_SIZE1; else if (vol.socket->serialNo == 2) vol.chipSize = TFFS_SIZE_NO2; #endif /* defined(FLASH_PARTITION2) && defined(INCLUDE_FLASH_NO2) by luhb 2007-03-21 */ vol.erasableBlockSize = 0x20000L; checkStatus(vol.interleaving == 1 ? i28f016WordSize(&vol) : flIntelSize(&vol, NULL,0)); /* Register our flash handlers */ vol.write = i28f016Write; vol.erase = i28f016Erase; #ifdef DEBUG_PRINT DEBUG_PRINT("Debug: identified 16-bit Intel media.\n"); #endif sysFlashWriteDisable(); return flOK; } else { #ifdef DEBUG_PRINT DEBUG_PRINT("Debug: failed to identify 16-bit Intel media.\n"); #endif return flUnknownMedia; /* not ours */ }}#if FALSE/*----------------------------------------------------------------------*//* f l R e g i s t e r I 2 8 F 0 1 6 *//* *//* Registers this MTD for use *//* *//* Parameters: *//* None *//* *//* Returns: *//* FLStatus : 0 on success, otherwise failure *//*----------------------------------------------------------------------*/FLStatus flRegisterI28F016(void){ if (noOfMTDs >= MTDS) return flTooManyComponents; mtdTable[noOfMTDs++] = i28f016Identify; return flOK;}#endif /* FALSE */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -