⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nand_if.txt

📁 STM32外部SRAM用作datamemery的程序 开发环境MDK
💻 TXT
📖 第 1 页 / 共 3 页
字号:
00000a  f899f899          LDRB     r0,[r9,#1]  ; Block_State
00000e  b08a              SUB      sp,sp,#0x28           ;391
000010  f64ff64f          MOV      r8,#0xffff
000014  f109f109          ADD      r7,r9,#0xc
000018  2800              CMP      r0,#0
00001a  d15e              BNE      |L6.218|
;;;396      {
;;;397        /* precopy old first pages */
;;;398        if (Initial_Page != 0)
00001c  f8b9f8b9          LDRH     r5,[r9,#0xa]  ; Initial_Page
000020  1dbe              ADDS     r6,r7,#6
000022  b1a5              CBZ      r5,|L6.78|
;;;399        {
;;;400          Page_Back = wAddress.Page;
000024  f8b7f8b7          LDRH     r10,[r7,#4]  ; wAddress
;;;401          fAddress.Page = wAddress.Page = 0;
000028  80bc              STRH     r4,[r7,#4]  ; wAddress
00002a  80b4              STRH     r4,[r6,#4]  ; fAddress
;;;402          NAND_Copy (wAddress, fAddress, Initial_Page);
00002c  2206              MOVS     r2,#6
00002e  4631              MOV      r1,r6
000030  a804              ADD      r0,sp,#0x10
000032  f7fff7ff          BL       __aeabi_memcpy
000036  2206              MOVS     r2,#6
000038  1fb1              SUBS     r1,r6,#6
00003a  a802              ADD      r0,sp,#8
00003c  f7fff7ff          BL       __aeabi_memcpy
000040  9500              STR      r5,[sp,#0]
000042  a802              ADD      r0,sp,#8
000044  c80f              LDM      r0,{r0-r3}
000046  f7fff7ff          BL       NAND_Copy
;;;403          wAddress.Page =  Page_Back ;
00004a  f8a7f8a7          STRH     r10,[r7,#4]  ; wAddress
                  |L6.78|
;;;404        }
;;;405    
;;;406        /* postcopy remaining pages */
;;;407        if ((NAND_BLOCK_SIZE - (wAddress.Page + 1)) != 0)
00004e  88b8              LDRH     r0,[r7,#4]  ; wAddress
000050  281f              CMP      r0,#0x1f
000052  d019              BEQ      |L6.136|
;;;408        {
;;;409          FSMC_NAND_AddressIncrement(&wAddress);
000054  482d              LDR      r0,|L6.268|
000056  300c              ADDS     r0,r0,#0xc
000058  f7fff7ff          BL       FSMC_NAND_AddressIncrement
;;;410          fAddress.Page = wAddress.Page;
;;;411          NAND_Copy (wAddress, fAddress, NAND_BLOCK_SIZE - wAddress.Page);
00005c  492b              LDR      r1,|L6.268|
00005e  88bd              LDRH     r5,[r7,#4]            ;410  ; wAddress
000060  80b5              STRH     r5,[r6,#4]            ;410  ; fAddress
000062  2206              MOVS     r2,#6
000064  3112              ADDS     r1,r1,#0x12
000066  a804              ADD      r0,sp,#0x10
000068  f7fff7ff          BL       __aeabi_memcpy
00006c  4927              LDR      r1,|L6.268|
00006e  2206              MOVS     r2,#6
000070  310c              ADDS     r1,r1,#0xc
000072  a802              ADD      r0,sp,#8
000074  f7fff7ff          BL       __aeabi_memcpy
000078  f1c5f1c5          RSB      r0,r5,#0x20
00007c  b283              UXTH     r3,r0
00007e  9300              STR      r3,[sp,#0]
000080  a802              ADD      r0,sp,#8
000082  c80f              LDM      r0,{r0-r3}
000084  f7fff7ff          BL       NAND_Copy
                  |L6.136|
;;;412        }
;;;413    
;;;414        /* assign logical address to new block */
;;;415        tempSpareArea [0] = LogAddress | USED_BLOCK ;
000088  f8b9f8b9          LDRH     r0,[r9,#8]  ; LogAddress
;;;416        tempSpareArea [1] = 0xFFFF;
;;;417        tempSpareArea [2] = 0xFFFF;
;;;418    
;;;419        fAddress.Page     = 0x00;
;;;420        FSMC_NAND_WriteSpareArea( (u8 *)tempSpareArea , fAddress , 1);
00008c  491f              LDR      r1,|L6.268|
00008e  f440f440          ORR      r0,r0,#0x8000         ;415
000092  f8adf8ad          STRH     r0,[sp,#0x18]         ;415
000096  f8adf8ad          STRH     r8,[sp,#0x1a]         ;416
00009a  f8adf8ad          STRH     r8,[sp,#0x1c]         ;417
00009e  80b4              STRH     r4,[r6,#4]            ;419  ; fAddress
0000a0  2206              MOVS     r2,#6
0000a2  3112              ADDS     r1,r1,#0x12
0000a4  a804              ADD      r0,sp,#0x10
0000a6  f7fff7ff          BL       __aeabi_memcpy
0000aa  e9dde9dd          LDRD     r1,r2,[sp,#0x10]
0000ae  2301              MOVS     r3,#1
0000b0  a806              ADD      r0,sp,#0x18
0000b2  f7fff7ff          BL       FSMC_NAND_WriteSpareArea
;;;421    
;;;422        /* erase old block */
;;;423        FSMC_NAND_EraseBlock(wAddress);
0000b6  4915              LDR      r1,|L6.268|
0000b8  2206              MOVS     r2,#6
0000ba  310c              ADDS     r1,r1,#0xc
0000bc  a804              ADD      r0,sp,#0x10
0000be  f7fff7ff          BL       __aeabi_memcpy
0000c2  e9dde9dd          LDRD     r0,r1,[sp,#0x10]
0000c6  f7fff7ff          BL       FSMC_NAND_EraseBlock
                  |L6.202|
;;;424        NAND_CleanLUT(wAddress.Zone);
;;;425      }
;;;426      else
;;;427      {/* unused block case */
;;;428        /* assign logical address to the new used block */
;;;429        tempSpareArea [0] = LogAddress | USED_BLOCK ;
;;;430        tempSpareArea [1] = 0xFFFF;
;;;431        tempSpareArea [2] = 0xFFFF;
;;;432    
;;;433        wAddress.Page     = 0x00;
;;;434        FSMC_NAND_WriteSpareArea((u8 *)tempSpareArea , wAddress, 1);
;;;435        NAND_CleanLUT(wAddress.Zone);
0000ca  8838              LDRH     r0,[r7,#0]  ; wAddress
0000cc  b2c0              UXTB     r0,r0
0000ce  f7fff7ff          BL       NAND_BuildLUT
;;;436      }
;;;437      return NAND_OK;
0000d2  2000              MOVS     r0,#0
;;;438    }
0000d4  b00a              ADD      sp,sp,#0x28
0000d6  e8bde8bd          POP      {r4-r10,pc}
                  |L6.218|
0000da  f8b9f8b9          LDRH     r0,[r9,#8]            ;429  ; LogAddress
0000de  490b              LDR      r1,|L6.268|
0000e0  f440f440          ORR      r0,r0,#0x8000         ;429
0000e4  f8adf8ad          STRH     r0,[sp,#0x18]         ;429
0000e8  f8adf8ad          STRH     r8,[sp,#0x1a]         ;430
0000ec  f8adf8ad          STRH     r8,[sp,#0x1c]         ;431
0000f0  80bc              STRH     r4,[r7,#4]            ;433  ; wAddress
0000f2  2206              MOVS     r2,#6                 ;434
0000f4  310c              ADDS     r1,r1,#0xc            ;434
0000f6  a804              ADD      r0,sp,#0x10           ;434
0000f8  f7fff7ff          BL       __aeabi_memcpy
0000fc  e9dde9dd          LDRD     r1,r2,[sp,#0x10]      ;434
000100  2301              MOVS     r3,#1                 ;434
000102  a806              ADD      r0,sp,#0x18           ;434
000104  f7fff7ff          BL       FSMC_NAND_WriteSpareArea
000108  e7df              B        |L6.202|
;;;439    
                          ENDP

00010a  0000              DCW      0x0000
                  |L6.268|
00010c  00000000          DCD      ||.data||

                          AREA ||i.NAND_GetAddress||, CODE, READONLY, ALIGN=1

                  NAND_GetAddress PROC
;;;288    static NAND_ADDRESS NAND_GetAddress (u32 Address)
;;;289    {
000000  b51c              PUSH     {r2-r4,lr}
;;;290      NAND_ADDRESS Address_t;
;;;291    
;;;292      Address_t.Page  = Address & (NAND_BLOCK_SIZE - 1);
000002  f001f001          AND      r2,r1,#0x1f
;;;293      Address_t.Block = Address / NAND_BLOCK_SIZE;
000006  0949              LSRS     r1,r1,#5
000008  f8adf8ad          STRH     r1,[sp,#2]
00000c  f8adf8ad          STRH     r2,[sp,#4]            ;292
;;;294      Address_t.Zone = 0;
000010  2100              MOVS     r1,#0
000012  f8adf8ad          STRH     r1,[sp,#0]
000016  f44ff44f          MOV      r2,#0x3e8
00001a  e008              B        |L7.46|
                  |L7.28|
;;;295    
;;;296      while (Address_t.Block >= MAX_LOG_BLOCKS_PER_ZONE)
;;;297      {
;;;298        Address_t.Block -= MAX_LOG_BLOCKS_PER_ZONE;
00001c  f5a1f5a1          SUB      r1,r1,#0x3e8
000020  f8adf8ad          STRH     r1,[sp,#2]
;;;299        Address_t.Zone++;
000024  f8bdf8bd          LDRH     r1,[sp,#0]
000028  1c49              ADDS     r1,r1,#1
00002a  f8adf8ad          STRH     r1,[sp,#0]
                  |L7.46|
00002e  f8bdf8bd          LDRH     r1,[sp,#2]            ;296
000032  4291              CMP      r1,r2                 ;296
000034  d2f2              BCS      |L7.28|
;;;300      }
;;;301      return Address_t;
000036  2206              MOVS     r2,#6
000038  4669              MOV      r1,sp
00003a  f7fff7ff          BL       __aeabi_memcpy
;;;302    }
00003e  bd1c              POP      {r2-r4,pc}
;;;303    
                          ENDP


                          AREA ||i.NAND_Write||, CODE, READONLY, ALIGN=2

                  NAND_Write PROC
;;;72     u16 NAND_Write(u32 Memory_Offset, u32 *Writebuff, u16 Transfer_Length)
;;;73     {
000000  e92de92d          PUSH     {r2-r10,lr}
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  485a              LDR      r0,|L8.372|
00000c  f7fff7ff          BL       NAND_GetAddress
;;;76     
;;;77       /*check Zone: if second zone is requested build second LUT*/
;;;78       if (wAddress.Zone != CurrentZone)
000010  4f58              LDR      r7,|L8.372|
000012  f1a7f1a7          SUB      r6,r7,#0xc
000016  8838              LDRH     r0,[r7,#0]  ; wAddress
000018  8871              LDRH     r1,[r6,#2]  ; CurrentZone
00001a  4288              CMP      r0,r1
00001c  d004              BEQ      |L8.40|
;;;79       {
;;;80         CurrentZone = wAddress.Zone;
00001e  8070              STRH     r0,[r6,#2]  ; CurrentZone
;;;81         NAND_BuildLUT(CurrentZone);
000020  b280              UXTH     r0,r0
000022  b2c0              UXTB     r0,r0
000024  f7fff7ff          BL       NAND_BuildLUT
                  |L8.40|
;;;82       }
;;;83     
;;;84       phBlock     = LUT[wAddress.Block]; /* Block Index + flags */
000028  8878              LDRH     r0,[r7,#2]  ; wAddress
00002a  4a53              LDR      r2,|L8.376|
;;;85       LogAddress  = wAddress.Block ; /* save logical block */
;;;86     
;;;87       /*  IDLE state  */
;;;88       /****************/
;;;89       if ( Write_State == WRITE_IDLE)
00002c  4c53              LDR      r4,|L8.380|
00002e  f832f832          LDRH     r1,[r2,r0,LSL #1]     ;84
000032  80f1              STRH     r1,[r6,#6]            ;84  ; phBlock
000034  8130              STRH     r0,[r6,#8]            ;85  ; LogAddress
000036  484f              LDR      r0,|L8.372|
000038  7831              LDRB     r1,[r6,#0]  ; Write_State
00003a  1d80              ADDS     r0,r0,#6
00003c  2500              MOVS     r5,#0
00003e  ea4fea4f          LSR      r8,r8,#9
000042  2900              CMP      r1,#0
000044  d14d              BNE      |L8.226|
;;;90       {/* Idle state */
;;;91     
;;;92         if (phBlock & USED_BLOCK)
000046  88f1              LDRH     r1,[r6,#6]  ; phBlock
000048  f04ff04f          MOV      r9,#4
00004c  040b              LSLS     r3,r1,#16
00004e  d52f              BPL      |L8.176|
;;;93         { /* USED BLOCK */
;;;94     
;;;95           Block_State = OLD_BLOCK;
000050  7075              STRB     r5,[r6,#1]  ; Block_State
000052  f8b2f8b2          LDRH     r1,[r2,#0x7d0]  ; LUT
;;;96           /* Get a free Block for swap */
;;;97           fAddress.Block = NAND_GetFreeBlock();
;;;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);
000056  2206              MOVS     r2,#6
000058  f421f421          BIC      r1,r1,#0xc000
00005c  8041              STRH     r1,[r0,#2]            ;97  ; fAddress
00005e  8839              LDRH     r1,[r7,#0]            ;98  ; wAddress
000060  8001              STRH     r1,[r0,#0]            ;98  ; fAddress
000062  88b9              LDRH     r1,[r7,#4]            ;99  ; wAddress
000064  8081              STRH     r1,[r0,#4]            ;99  ; fAddress
000066  8171              STRH     r1,[r6,#0xa]          ;99  ; Initial_Page
000068  4601              MOV      r1,r0
00006a  4668              MOV      r0,sp
00006c  f7fff7ff          BL       __aeabi_memcpy
000070  e9dde9dd          LDRD     r1,r2,[sp,#0]
000074  4643              MOV      r3,r8
000076  4650              MOV      r0,r10
000078  f7fff7ff          BL       FSMC_NAND_WriteSmallPage
;;;103          Written_Pages++;
00007c  88b0              LDRH     r0,[r6,#4]  ; Written_Pages
00007e  1c40              ADDS     r0,r0,#1
000080  b280              UXTH     r0,r0
000082  80b0              STRH     r0,[r6,#4]  ; Written_Pages
;;;104    
;;;105          /* get physical block */
;;;106          wAddress.Block = phBlock & 0x3FF;
000084  88f1              LDRH     r1,[r6,#6]  ; phBlock
000086  f3c1f3c1          UBFX     r1,r1,#0,#10
00008a  8079              STRH     r1,[r7,#2]  ; wAddress
;;;107    
;;;108    
;;;109          if (Written_Pages == SCSI_BlkLen)
00008c  6821              LDR      r1,[r4,#0]  ; SCSI_BlkLen
00008e  4288              CMP      r0,r1
000090  d104              BNE      |L8.156|
;;;110          {
;;;111            NAND_Write_Cleanup();
000092  bf00              NOP      
                  |L8.148|
000094  f7fff7ff          BL       NAND_Write_Cleanup
;;;112            Written_Pages = 0;
000098  80b5              STRH     r5,[r6,#4]  ; Written_Pages
;;;113            return NAND_OK;
00009a  e067              B        |L8.364|
                  |L8.156|
;;;114          }
;;;115          else
;;;116          {
;;;117            if (wAddress.Page == (NAND_BLOCK_SIZE - 1))
00009c  88b8              LDRH     r0,[r7,#4]  ; wAddress
00009e  281f              CMP      r0,#0x1f
0000a0  d103              BNE      |L8.170|
;;;118            {
;;;119              NAND_Write_Cleanup();
0000a2  bf00              NOP      
                  |L8.164|
0000a4  f7fff7ff          BL       NAND_Write_Cleanup
;;;120              return NAND_OK;
0000a8  e060              B        |L8.364|
                  |L8.170|
;;;121            }
;;;122            Write_State = WRITE_ONGOING;
0000aa  f886f886          STRB     r9,[r6,#0]  ; Write_State
;;;123            return NAND_OK;
0000ae  e05d              B        |L8.364|
                  |L8.176|
;;;124          }
;;;125        }
;;;126        else
;;;127        {/* UNUSED BLOCK */
;;;128    
;;;129          Block_State = UNUSED_BLOCK;
0000b0  2001              MOVS     r0,#1
0000b2  7070              STRB     r0,[r6,#1]  ; Block_State
;;;130          /* write the new page */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -