jmemmgr.txt

来自「STM32F103ZET6+UCOSII+UCGUI源码」· 文本 代码 · 共 1,415 行 · 第 1/5 页

TXT
1,415
字号
;;;898      /* If freeing IMAGE pool, close any virtual arrays first */
;;;899      if (pool_id == JPOOL_IMAGE) {
;;;900        jvirt_sarray_ptr sptr;
;;;901        jvirt_barray_ptr bptr;
;;;902    
;;;903        for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) {
;;;904          if (sptr->b_s_open) {	/* there may be no backing store */
000020  f04f0900          MOV      r9,#0
000024  2f01              CMP      r7,#1                 ;899
000026  d120              BNE      |L9.106|
000028  46c8              MOV      r8,r9
00002a  6c6c              LDR      r4,[r5,#0x44]         ;903
00002c  e009              B        |L9.66|
                  |L9.46|
00002e  6aa0              LDR      r0,[r4,#0x28]
000030  b130              CBZ      r0,|L9.64|
;;;905    	sptr->b_s_open = FALSE;	/* prevent recursive close if error */
;;;906    	(*sptr->b_s_info.close_backing_store) (cinfo, & sptr->b_s_info);
000032  f8c48028          STR      r8,[r4,#0x28]
000036  6ba2              LDR      r2,[r4,#0x38]
000038  f1040130          ADD      r1,r4,#0x30
00003c  4630              MOV      r0,r6
00003e  4790              BLX      r2
                  |L9.64|
000040  6ae4              LDR      r4,[r4,#0x2c]         ;903
                  |L9.66|
000042  2c00              CMP      r4,#0                 ;903
000044  d1f3              BNE      |L9.46|
;;;907          }
;;;908        }
;;;909        mem->virt_sarray_list = NULL;
;;;910        for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) {
000046  f8c58044          STR      r8,[r5,#0x44]
00004a  6cac              LDR      r4,[r5,#0x48]
00004c  e009              B        |L9.98|
                  |L9.78|
;;;911          if (bptr->b_s_open) {	/* there may be no backing store */
00004e  6aa0              LDR      r0,[r4,#0x28]
000050  b130              CBZ      r0,|L9.96|
;;;912    	bptr->b_s_open = FALSE;	/* prevent recursive close if error */
;;;913    	(*bptr->b_s_info.close_backing_store) (cinfo, & bptr->b_s_info);
000052  f8c48028          STR      r8,[r4,#0x28]
000056  6ba2              LDR      r2,[r4,#0x38]
000058  f1040130          ADD      r1,r4,#0x30
00005c  4630              MOV      r0,r6
00005e  4790              BLX      r2
                  |L9.96|
000060  6ae4              LDR      r4,[r4,#0x2c]         ;910
                  |L9.98|
000062  2c00              CMP      r4,#0                 ;910
000064  d1f3              BNE      |L9.78|
;;;914          }
;;;915        }
;;;916        mem->virt_barray_list = NULL;
000066  f8c58048          STR      r8,[r5,#0x48]
                  |L9.106|
;;;917      }
;;;918    
;;;919      /* Release large objects */
;;;920      lhdr_ptr = mem->large_list[pool_id];
00006a  eb050087          ADD      r0,r5,r7,LSL #2
;;;921      mem->large_list[pool_id] = NULL;
00006e  6bc1              LDR      r1,[r0,#0x3c]
000070  4680              MOV      r8,r0                 ;920
;;;922    
;;;923      while (lhdr_ptr != NULL) {
000072  f8c0903c          STR      r9,[r0,#0x3c]
000076  e00c              B        |L9.146|
                  |L9.120|
;;;924        large_pool_ptr next_lhdr_ptr = lhdr_ptr->hdr.next;
;;;925        space_freed = lhdr_ptr->hdr.bytes_used +
000078  e9d10201          LDRD     r0,r2,[r1,#4]
00007c  1887              ADDS     r7,r0,r2
00007e  3710              ADDS     r7,r7,#0x10
;;;926    		  lhdr_ptr->hdr.bytes_left +
;;;927    		  SIZEOF(large_pool_hdr);
;;;928        jpeg_free_small/*RS: Changed from jpeg_free_large*/(cinfo, (void FAR *) lhdr_ptr, space_freed);
000080  463a              MOV      r2,r7
000082  4630              MOV      r0,r6
000084  680c              LDR      r4,[r1,#0]
000086  f7fffffe          BL       jpeg_free_small
;;;929        mem->total_space_allocated -= space_freed;
00008a  6ce8              LDR      r0,[r5,#0x4c]
;;;930        lhdr_ptr = next_lhdr_ptr;
00008c  4621              MOV      r1,r4
00008e  1bc0              SUBS     r0,r0,r7              ;929
000090  64e8              STR      r0,[r5,#0x4c]
                  |L9.146|
000092  2900              CMP      r1,#0                 ;923
000094  d1f0              BNE      |L9.120|
;;;931      }
;;;932    
;;;933      /* Release small objects */
;;;934      shdr_ptr = mem->small_list[pool_id];
;;;935      mem->small_list[pool_id] = NULL;
000096  f8d81034          LDR      r1,[r8,#0x34]
;;;936    
;;;937      while (shdr_ptr != NULL) {
00009a  f8c89034          STR      r9,[r8,#0x34]
00009e  e00c              B        |L9.186|
                  |L9.160|
;;;938        small_pool_ptr next_shdr_ptr = shdr_ptr->hdr.next;
;;;939        space_freed = shdr_ptr->hdr.bytes_used +
0000a0  e9d10201          LDRD     r0,r2,[r1,#4]
0000a4  1887              ADDS     r7,r0,r2
0000a6  3710              ADDS     r7,r7,#0x10
;;;940    		  shdr_ptr->hdr.bytes_left +
;;;941    		  SIZEOF(small_pool_hdr);
;;;942        jpeg_free_small(cinfo, (void *) shdr_ptr, space_freed);
0000a8  463a              MOV      r2,r7
0000aa  4630              MOV      r0,r6
0000ac  680c              LDR      r4,[r1,#0]
0000ae  f7fffffe          BL       jpeg_free_small
;;;943        mem->total_space_allocated -= space_freed;
0000b2  6ce8              LDR      r0,[r5,#0x4c]
;;;944        shdr_ptr = next_shdr_ptr;
0000b4  4621              MOV      r1,r4
0000b6  1bc0              SUBS     r0,r0,r7              ;943
0000b8  64e8              STR      r0,[r5,#0x4c]
                  |L9.186|
0000ba  2900              CMP      r1,#0                 ;937
0000bc  d1f0              BNE      |L9.160|
;;;945      }
;;;946    }
0000be  e8bd87f0          POP      {r4-r10,pc}
;;;947    
                          ENDP


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

                  jinit_memory_mgr PROC
;;;980    GLOBAL(void)
;;;981    jinit_memory_mgr (j_common_ptr cinfo)
000000  e92d41f0          PUSH     {r4-r8,lr}
;;;982    {
;;;983      my_mem_ptr mem;
;;;984      long max_to_use;
;;;985      int pool;
;;;986      size_t test_mac;
;;;987    
;;;988      cinfo->mem = NULL;		/* for safety if init fails */
000004  2600              MOVS     r6,#0
000006  4605              MOV      r5,r0                 ;982
;;;989    
;;;990      /* Check for configuration errors.
;;;991       * SIZEOF(ALIGN_TYPE) should be a power of 2; otherwise, it probably
;;;992       * doesn't reflect any real hardware alignment requirement.
;;;993       * The test is a little tricky: for X>0, X and X-1 have no one-bits
;;;994       * in common if and only if X is a power of 2, ie has only one one-bit.
;;;995       * Some compilers may give an "unreachable code" warning here; ignore it.
;;;996       */
;;;997      if ((SIZEOF(ALIGN_TYPE) & (SIZEOF(ALIGN_TYPE)-1)) != 0)
;;;998        ERREXIT(cinfo, JERR_BAD_ALIGN_TYPE);
;;;999      /* MAX_ALLOC_CHUNK must be representable as type size_t, and must be
;;;1000      * a multiple of SIZEOF(ALIGN_TYPE).
;;;1001      * Again, an "unreachable code" warning may be ignored here.
;;;1002      * But a "constant too large" warning means you need to fix MAX_ALLOC_CHUNK.
;;;1003      */
;;;1004     test_mac = (size_t) MAX_ALLOC_CHUNK;
000008  4f1e              LDR      r7,|L10.132|
;;;1005     if ((long) test_mac != MAX_ALLOC_CHUNK ||
;;;1006         (MAX_ALLOC_CHUNK % SIZEOF(ALIGN_TYPE)) != 0)
;;;1007       ERREXIT(cinfo, JERR_BAD_ALLOC_CHUNK);
;;;1008   
;;;1009     max_to_use = jpeg_mem_init(cinfo); /* system-dependent initialization */
00000a  6046              STR      r6,[r0,#4]
00000c  f7fffffe          BL       jpeg_mem_init
000010  4680              MOV      r8,r0
;;;1010   
;;;1011     /* Attempt to allocate memory manager's control block */
;;;1012     mem = (my_mem_ptr) jpeg_get_small(cinfo, SIZEOF(my_memory_mgr));
000012  2154              MOVS     r1,#0x54
000014  4628              MOV      r0,r5
000016  f7fffffe          BL       jpeg_get_small
00001a  0004              MOVS     r4,r0
;;;1013   
;;;1014     if (mem == NULL) {
00001c  d10b              BNE      |L10.54|
;;;1015       jpeg_mem_term(cinfo);	/* system-dependent cleanup */
00001e  4628              MOV      r0,r5
000020  f7fffffe          BL       jpeg_mem_term
;;;1016       ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 0);
000024  6829              LDR      r1,[r5,#0]
000026  2036              MOVS     r0,#0x36
000028  6148              STR      r0,[r1,#0x14]
00002a  6828              LDR      r0,[r5,#0]
00002c  6186              STR      r6,[r0,#0x18]
00002e  6828              LDR      r0,[r5,#0]
000030  6801              LDR      r1,[r0,#0]
000032  4628              MOV      r0,r5
000034  4788              BLX      r1
                  |L10.54|
;;;1017     }
;;;1018   
;;;1019     /* OK, fill in the method pointers */
;;;1020     mem->pub.alloc_small = alloc_small;
000036  4814              LDR      r0,|L10.136|
;;;1021     mem->pub.alloc_large = alloc_large;
000038  6020              STR      r0,[r4,#0]
00003a  4814              LDR      r0,|L10.140|
;;;1022     mem->pub.alloc_sarray = alloc_sarray;
00003c  6060              STR      r0,[r4,#4]
00003e  4814              LDR      r0,|L10.144|
;;;1023     mem->pub.alloc_barray = alloc_barray;
000040  60a0              STR      r0,[r4,#8]
000042  4814              LDR      r0,|L10.148|
;;;1024     mem->pub.request_virt_sarray = request_virt_sarray;
000044  60e0              STR      r0,[r4,#0xc]
000046  4814              LDR      r0,|L10.152|
;;;1025     mem->pub.request_virt_barray = request_virt_barray;
000048  6120              STR      r0,[r4,#0x10]
00004a  4814              LDR      r0,|L10.156|
;;;1026     mem->pub.realize_virt_arrays = realize_virt_arrays;
00004c  6160              STR      r0,[r4,#0x14]
00004e  4814              LDR      r0,|L10.160|
;;;1027     mem->pub.access_virt_sarray = access_virt_sarray;
000050  61a0              STR      r0,[r4,#0x18]
000052  4814              LDR      r0,|L10.164|
;;;1028     mem->pub.access_virt_barray = access_virt_barray;
000054  61e0              STR      r0,[r4,#0x1c]
000056  4814              LDR      r0,|L10.168|
;;;1029     mem->pub.free_pool = free_pool;
000058  6220              STR      r0,[r4,#0x20]
00005a  4814              LDR      r0,|L10.172|
;;;1030     mem->pub.self_destruct = self_destruct;
00005c  6260              STR      r0,[r4,#0x24]
;;;1031   
;;;1032     /* Make MAX_ALLOC_CHUNK accessible to other modules */
;;;1033     mem->pub.max_alloc_chunk = MAX_ALLOC_CHUNK;
;;;1034   
;;;1035     /* Initialize working state */
;;;1036     mem->pub.max_memory_to_use = max_to_use;
;;;1037   
;;;1038     for (pool = JPOOL_NUMPOOLS-1; pool >= JPOOL_PERMANENT; pool--) {
00005e  e9c4870b          STRD     r8,r7,[r4,#0x2c]
000062  4813              LDR      r0,|L10.176|
000064  62a0              STR      r0,[r4,#0x28]
000066  2001              MOVS     r0,#1
                  |L10.104|
;;;1039       mem->small_list[pool] = NULL;
000068  eb040180          ADD      r1,r4,r0,LSL #2
;;;1040       mem->large_list[pool] = NULL;
00006c  634e              STR      r6,[r1,#0x34]
00006e  63ce              STR      r6,[r1,#0x3c]         ;1038
000070  1e40              SUBS     r0,r0,#1              ;1038
000072  d5f9              BPL      |L10.104|
;;;1041     }
;;;1042     mem->virt_sarray_list = NULL;
;;;1043     mem->virt_barray_list = NULL;
000074  6466              STR      r6,[r4,#0x44]
;;;1044   
;;;1045     mem->total_space_allocated = SIZEOF(my_memory_mgr);
000076  2054              MOVS     r0,#0x54
;;;1046   
;;;1047     /* Declare ourselves open for business */
;;;1048     cinfo->mem = & mem->pub;
000078  e9c46012          STRD     r6,r0,[r4,#0x48]
;;;1049   
;;;1050     /* Check for an environment variable JPEGMEM; if found, override the
;;;1051      * default max_memory setting from jpeg_mem_init.  Note that the
;;;1052      * surrounding application may again override this value.
;;;1053      * If your system doesn't support getenv(), define NO_GETENV to disable
;;;1054      * this feature.
;;;1055      */
;;;1056   #if 0 /* RS ndef NO_GETENV */
;;;1057     { char * memenv;
;;;1058   
;;;1059       if ((memenv = getenv("JPEGMEM")) != NULL) {
;;;1060         char ch = 'x';
;;;1061   
;;;1062         if (sscanf(memenv, "%ld%c", &max_to_use, &ch) > 0) {
;;;1063   	if (ch == 'm' || ch == 'M')
;;;1064   	  max_to_use *= 1000L;
;;;1065   	mem->pub.max_memory_to_use = max_to_use * 1000L;
;;;1066         }
;;;1067       }
;;;1068     }
;;;1069   #endif
;;;1070   
;;;1071   }
00007c  606c              STR      r4,[r5,#4]
00007e  e8bd81f0          POP      {r4-r8,pc}

⌨️ 快捷键说明

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