📄 nand_if.txt
字号:
;;;297 {
;;;298 Address_t.Block -= MAX_LOG_BLOCKS_PER_ZONE;
;;;299 Address_t.Zone++;
00001a e008 B |L5.46|
|L5.28|
00001c f5a1717a SUB r1,r1,#0x3e8 ;298
000020 f8ad1002 STRH r1,[sp,#2] ;298
000024 f8bd1000 LDRH r1,[sp,#0]
000028 1c49 ADDS r1,r1,#1
00002a f8ad1000 STRH r1,[sp,#0]
|L5.46|
00002e f8bd1002 LDRH r1,[sp,#2] ;296
000032 4291 CMP r1,r2 ;296
000034 d2f2 BCS |L5.28|
;;;300 }
;;;301 return Address_t;
000036 2206 MOVS r2,#6
000038 4669 MOV r1,sp
00003a f7fffffe BL __aeabi_memcpy
;;;302 }
00003e bd1c POP {r2-r4,pc}
;;;303
ENDP
AREA ||i.NAND_Init||, CODE, READONLY, ALIGN=2
NAND_Init PROC
;;;54 *******************************************************************************/
;;;55 u16 NAND_Init(void)
000000 b510 PUSH {r4,lr}
;;;56 {
;;;57 u16 Status = NAND_OK;
;;;58
;;;59 FSMC_NAND_Init();
000002 f7fffffe BL FSMC_NAND_Init
;;;60 Status = NAND_BuildLUT(0);
000006 2000 MOVS r0,#0
000008 f7fffffe BL NAND_BuildLUT
;;;61 Write_State = WRITE_IDLE;
00000c 4a01 LDR r2,|L6.20|
00000e 2100 MOVS r1,#0
000010 7011 STRB r1,[r2,#0]
;;;62 return Status;
;;;63 }
000012 bd10 POP {r4,pc}
;;;64
ENDP
|L6.20|
DCD ||.data||
AREA ||i.NAND_Read||, CODE, READONLY, ALIGN=2
NAND_Read PROC
;;;228 *******************************************************************************/
;;;229 u16 NAND_Read(u32 Memory_Offset, u32 *Readbuff, u16 Transfer_Length)
000000 b57c PUSH {r2-r6,lr}
;;;230 {
000002 460d MOV r5,r1
;;;231 NAND_ADDRESS phAddress;
;;;232
;;;233 phAddress = NAND_GetAddress(Memory_Offset / 512);
000004 0a41 LSRS r1,r0,#9
000006 4614 MOV r4,r2 ;230
000008 4668 MOV r0,sp
00000a f7fffffe BL NAND_GetAddress
;;;234
;;;235 if (phAddress.Zone != CurrentZone)
00000e 4910 LDR r1,|L7.80|
000010 f8bd0000 LDRH r0,[sp,#0]
000014 884a LDRH r2,[r1,#2] ; CurrentZone
000016 4290 CMP r0,r2
000018 d004 BEQ |L7.36|
;;;236 {
;;;237 CurrentZone = phAddress.Zone;
00001a 8048 STRH r0,[r1,#2]
;;;238 NAND_BuildLUT(CurrentZone);
00001c b280 UXTH r0,r0
00001e b2c0 UXTB r0,r0
000020 f7fffffe BL NAND_BuildLUT
|L7.36|
;;;239 }
;;;240
;;;241 if (LUT [phAddress.Block] & BAD_BLOCK)
000024 f8bd1002 LDRH r1,[sp,#2]
000028 480a LDR r0,|L7.84|
00002a f8300011 LDRH r0,[r0,r1,LSL #1]
00002e 0481 LSLS r1,r0,#18
000030 d501 BPL |L7.54|
;;;242 {
;;;243 return NAND_FAIL;
000032 2001 MOVS r0,#1
;;;244 }
;;;245 else
;;;246 {
;;;247 phAddress.Block = LUT [phAddress.Block] & ~ (USED_BLOCK | VALID_BLOCK);
;;;248 FSMC_NAND_ReadSmallPage ( (u8 *)Readbuff , phAddress, Transfer_Length / 512);
;;;249 }
;;;250 return NAND_OK;
;;;251 }
000034 bd7c POP {r2-r6,pc}
|L7.54|
000036 f4204040 BIC r0,r0,#0xc000 ;247
00003a f8ad0002 STRH r0,[sp,#2] ;247
00003e e9dd1200 LDRD r1,r2,[sp,#0] ;248
000042 0a63 LSRS r3,r4,#9 ;248
000044 4628 MOV r0,r5 ;248
000046 f7fffffe BL FSMC_NAND_ReadSmallPage
00004a 2000 MOVS r0,#0 ;250
00004c bd7c POP {r2-r6,pc}
;;;252
ENDP
00004e 0000 DCW 0x0000
|L7.80|
DCD ||.data||
|L7.84|
DCD ||.bss||
AREA ||i.NAND_Write||, CODE, READONLY, ALIGN=2
NAND_Write PROC
;;;71 *******************************************************************************/
;;;72 u16 NAND_Write(u32 Memory_Offset, u32 *Writebuff, u16 Transfer_Length)
000000 e92d47fc PUSH {r2-r10,lr}
;;;73 {
000004 468a MOV r10,r1
;;;74 /* check block status and calculate start and end addreses */
;;;75 wAddress = NAND_GetAddress(Memory_Offset / 512);
000006 0a41 LSRS r1,r0,#9
000008 4690 MOV r8,r2 ;73
00000a 4858 LDR r0,|L8.364|
00000c f7fffffe BL NAND_GetAddress
;;;76
;;;77 /*check Zone: if second zone is requested build second LUT*/
;;;78 if (wAddress.Zone != CurrentZone)
000010 4e56 LDR r6,|L8.364|
000012 f1a6050c SUB r5,r6,#0xc
000016 8830 LDRH r0,[r6,#0] ; wAddress
000018 8869 LDRH r1,[r5,#2] ; CurrentZone
00001a 4288 CMP r0,r1
00001c d004 BEQ |L8.40|
;;;79 {
;;;80 CurrentZone = wAddress.Zone;
00001e 8068 STRH r0,[r5,#2]
;;;81 NAND_BuildLUT(CurrentZone);
000020 b280 UXTH r0,r0
000022 b2c0 UXTB r0,r0
000024 f7fffffe BL NAND_BuildLUT
|L8.40|
;;;82 }
;;;83
;;;84 phBlock = LUT[wAddress.Block]; /* Block Index + flags */
000028 8871 LDRH r1,[r6,#2] ; wAddress
00002a 4851 LDR r0,|L8.368|
;;;85 LogAddress = wAddress.Block ; /* save logical block */
;;;86
;;;87 /* IDLE state */
;;;88 /****************/
;;;89 if ( Write_State == WRITE_IDLE)
;;;90 {/* Idle state */
;;;91
;;;92 if (phBlock & USED_BLOCK)
;;;93 { /* USED BLOCK */
;;;94
;;;95 Block_State = OLD_BLOCK;
;;;96 /* Get a free Block for swap */
;;;97 fAddress.Block = NAND_GetFreeBlock();
00002c 4b4f LDR r3,|L8.364|
00002e f8302011 LDRH r2,[r0,r1,LSL #1] ;84
000032 80ea STRH r2,[r5,#6] ;84
000034 8129 STRH r1,[r5,#8] ;85
000036 7829 LDRB r1,[r5,#0] ;89 ; Write_State
000038 1d9b ADDS r3,r3,#6
;;;98 fAddress.Zone = wAddress.Zone;
;;;99 Initial_Page = fAddress.Page = wAddress.Page;
;;;100
;;;101 /* write the new page */
;;;102 FSMC_NAND_WriteSmallPage((u8 *)Writebuff, fAddress, PAGE_TO_WRITE);
;;;103 Written_Pages++;
;;;104
;;;105 /* get physical block */
;;;106 wAddress.Block = phBlock & 0x3FF;
;;;107
;;;108
;;;109 if (Written_Pages == SCSI_BlkLen)
00003a 4c4e LDR r4,|L8.372|
00003c 2700 MOVS r7,#0 ;89
00003e ea4f2858 LSR r8,r8,#9 ;102
000042 2900 CMP r1,#0 ;89
000044 d14d BNE |L8.226|
000046 88e9 LDRH r1,[r5,#6] ;92 ; phBlock
;;;110 {
;;;111 NAND_Write_Cleanup();
;;;112 Written_Pages = 0;
;;;113 return NAND_OK;
;;;114 }
;;;115 else
;;;116 {
;;;117 if (wAddress.Page == (NAND_BLOCK_SIZE - 1))
;;;118 {
;;;119 NAND_Write_Cleanup();
;;;120 return NAND_OK;
;;;121 }
;;;122 Write_State = WRITE_ONGOING;
000048 f04f0904 MOV r9,#4
00004c 040a LSLS r2,r1,#16 ;92
00004e d52f BPL |L8.176|
000050 706f STRB r7,[r5,#1] ;95
000052 f8b007d0 LDRH r0,[r0,#0x7d0] ;95 ; LUT
000056 2206 MOVS r2,#6 ;102
000058 f4204040 BIC r0,r0,#0xc000 ;102
00005c 8058 STRH r0,[r3,#2] ;97
00005e 8830 LDRH r0,[r6,#0] ;98 ; wAddress
000060 8018 STRH r0,[r3,#0] ;98
000062 88b0 LDRH r0,[r6,#4] ;99 ; wAddress
000064 8098 STRH r0,[r3,#4] ;99
000066 8168 STRH r0,[r5,#0xa] ;99
000068 4619 MOV r1,r3 ;102
00006a 4668 MOV r0,sp ;102
00006c f7fffffe BL __aeabi_memcpy
000070 e9dd1200 LDRD r1,r2,[sp,#0] ;102
000074 4643 MOV r3,r8 ;102
000076 4650 MOV r0,r10 ;102
000078 f7fffffe BL FSMC_NAND_WriteSmallPage
00007c 88a8 LDRH r0,[r5,#4] ;103 ; Written_Pages
00007e 1c40 ADDS r0,r0,#1 ;103
000080 b280 UXTH r0,r0 ;103
000082 80a8 STRH r0,[r5,#4] ;103
000084 88e9 LDRH r1,[r5,#6] ;106 ; phBlock
000086 f3c10109 UBFX r1,r1,#0,#10 ;106
00008a 8071 STRH r1,[r6,#2] ;106
00008c 6821 LDR r1,[r4,#0] ;109 ; SCSI_BlkLen
00008e 4288 CMP r0,r1 ;109
000090 d104 BNE |L8.156|
000092 bf00 NOP ;111
|L8.148|
000094 f7fffffe BL NAND_Write_Cleanup
000098 80af STRH r7,[r5,#4] ;112
00009a e064 B |L8.358|
|L8.156|
00009c 88b0 LDRH r0,[r6,#4] ;117 ; wAddress
00009e 281f CMP r0,#0x1f ;117
0000a0 d103 BNE |L8.170|
0000a2 bf00 NOP ;119
|L8.164|
0000a4 f7fffffe BL NAND_Write_Cleanup
0000a8 e05d B |L8.358|
|L8.170|
0000aa f8859000 STRB r9,[r5,#0]
;;;123 return NAND_OK;
0000ae e05a B |L8.358|
|L8.176|
;;;124 }
;;;125 }
;;;126 else
;;;127 {/* UNUSED BLOCK */
;;;128
;;;129 Block_State = UNUSED_BLOCK;
0000b0 2001 MOVS r0,#1
0000b2 7068 STRB r0,[r5,#1]
;;;130 /* write the new page */
;;;131 wAddress.Block = phBlock & 0x3FF;
0000b4 f3c10009 UBFX r0,r1,#0,#10
0000b8 8070 STRH r0,[r6,#2]
;;;132 FSMC_NAND_WriteSmallPage( (u8 *)Writebuff , wAddress, PAGE_TO_WRITE);
0000ba 2206 MOVS r2,#6
0000bc 492b LDR r1,|L8.364|
0000be 4668 MOV r0,sp
0000c0 f7fffffe BL __aeabi_memcpy
0000c4 e9dd1200 LDRD r1,r2,[sp,#0]
0000c8 4643 MOV r3,r8
0000ca 4650 MOV r0,r10
0000cc f7fffffe BL FSMC_NAND_WriteSmallPage
;;;133
;;;134 Written_Pages++;
0000d0 88a8 LDRH r0,[r5,#4] ; Written_Pages
0000d2 1c40 ADDS r0,r0,#1
0000d4 b280 UXTH r0,r0
0000d6 80a8 STRH r0,[r5,#4]
;;;135 if (Written_Pages == SCSI_BlkLen)
0000d8 6821 LDR r1,[r4,#0] ; SCSI_BlkLen
0000da 4288 CMP r0,r1
0000dc d1e5 BNE |L8.170|
;;;136 {
;;;137 Written_Pages = 0;
0000de 80af STRH r7,[r5,#4]
;;;138 NAND_Write_Cleanup();
;;;139 return NAND_OK;
0000e0 e7e0 B |L8.164|
|L8.226|
;;;140 }
;;;141 else
;;;142 {
;;;143 Write_State = WRITE_ONGOING;
;;;144 return NAND_OK;
;;;145 }
;;;146 }
;;;147 }
;;;148 /* WRITE state */
;;;149 /***************/
;;;150 if ( Write_State == WRITE_ONGOING)
0000e2 2904 CMP r1,#4
0000e4 d13f BNE |L8.358|
;;;151 {/* Idle state */
;;;152 if (phBlock & USED_BLOCK)
0000e6 88e8 LDRH r0,[r5,#6] ; phBlock
0000e8 0401 LSLS r1,r0,#16
;;;153 { /* USED BLOCK */
;;;154
;;;155 wAddress.Block = phBlock & 0x3FF;
0000ea f3c00009 UBFX r0,r0,#0,#10
0000ee 8070 STRH r0,[r6,#2]
0000f0 d50f BPL |L8.274|
;;;156 Block_State = OLD_BLOCK;
0000f2 706f STRB r7,[r5,#1]
;;;157 fAddress.Page = wAddress.Page;
0000f4 88b0 LDRH r0,[r6,#4] ; wAddress
;;;158
;;;159 /* check if next pages are in next block */
;;;160 if (wAddress.Page == (NAND_BLOCK_SIZE - 1))
;;;161 {
;;;162 /* write Last page */
;;;163 FSMC_NAND_WriteSmallPage( (u8 *)Writebuff , fAddress, PAGE_TO_WRITE);
0000f6 491d LDR r1,|L8.364|
0000f8 8098 STRH r0,[r3,#4] ;157
0000fa 281f CMP r0,#0x1f ;160
0000fc f04f0206 MOV r2,#6
000100 f1010106 ADD r1,r1,#6
000104 d104 BNE |L8.272|
;;;164 Written_Pages++;
;;;165 if (Written_Pages == SCSI_BlkLen)
000106 e00a B |L8.286|
|L8.264|
;;;166 {
;;;167 Written_Pages = 0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -