yu.dong | c33b307 | 2024-08-21 23:14:49 -0700 | [diff] [blame^] | 1 | #!/usr/bin/perl |
| 2 | # |
| 3 | # Copyright Statement: |
| 4 | # -------------------- |
| 5 | # This software is protected by Copyright and the information contained |
| 6 | # herein is confidential. The software may not be copied and the information |
| 7 | # contained herein may not be used or disclosed except with the written |
| 8 | # permission of MediaTek Inc. (C) 2006 |
| 9 | # |
| 10 | # BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES |
| 11 | # THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") |
| 12 | # RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON |
| 13 | # AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, |
| 14 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF |
| 15 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. |
| 16 | # NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE |
| 17 | # SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR |
| 18 | # SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH |
| 19 | # THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO |
| 20 | # NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S |
| 21 | # SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. |
| 22 | # |
| 23 | # BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE |
| 24 | # LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, |
| 25 | # AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, |
| 26 | # OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO |
| 27 | # MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. |
| 28 | # |
| 29 | # THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE |
| 30 | # WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF |
| 31 | # LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND |
| 32 | # RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER |
| 33 | # THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). |
| 34 | # |
| 35 | #***************************************************************************** |
| 36 | |
| 37 | use strict; |
| 38 | BEGIN { push @INC, './common/tools/MemoryUtility/' } # add additional library path |
| 39 | use LinkerOutputParser; |
| 40 | use CommonUtility; |
| 41 | use FileInfoParser; |
| 42 | |
| 43 | package FreeRam_info; |
| 44 | |
| 45 | my @symbol_list = (["LOAD_VIEW_END",LinkerSymPostfix::ZILimit,0], |
| 46 | ["MCURO_HWRW", LinkerSymPostfix::Base,0], |
| 47 | ["CACHED_EXTSRAM_MCURO_HWRW", LinkerSymPostfix::ZILimit,1], |
| 48 | ["EXTSRAM",LinkerSymPostfix::Base,1], |
| 49 | ["CACHED_EXTSRAM_NVRAM_LTABLE", LinkerSymPostfix::ZILimit,2], |
| 50 | ["EXTSRAM_MCURW_HWRW", LinkerSymPostfix::Base,2], |
| 51 | ["CACHED_EXTSRAM_MCURW_HWRW", LinkerSymPostfix::ZILimit,3], |
| 52 | ["EXTSRAM_DSP_TX", LinkerSymPostfix::Base,3], |
| 53 | ["EXTSRAM_DSP_TX", LinkerSymPostfix::ZILimit,4], |
| 54 | ["EXTSRAM_DSP_RX", LinkerSymPostfix::Base,4], |
| 55 | ["EXTSRAM_DSP_RX", LinkerSymPostfix::ZILimit,5], |
| 56 | ["CACHED_EXTSRAM_IOCU2_MCURW_HWRW", LinkerSymPostfix::Base,5], |
| 57 | ["CACHED_EXTSRAM_IOCU2_MCURW_HWRW", LinkerSymPostfix::ZILimit,6], |
| 58 | ["CACHED_EXTSRAM_IOCU3_READ_ALLOC_MCURW_HWRW", LinkerSymPostfix::Base,6], |
| 59 | ["CACHED_EXTSRAM_IOCU3_READ_ALLOC_MCURW_HWRW", LinkerSymPostfix::ZILimit,7], |
| 60 | ["CACHED_EXTSRAM_L2CACHE_LOCK_DATA", LinkerSymPostfix::Base,7], |
| 61 | ["CACHED_EXTSRAM_L2CACHE_LOCK_DATA", LinkerSymPostfix::ZILimit,8], |
| 62 | ["DYNAMIC_SECTION_L2CACHE_LOCK_0", LinkerSymPostfix::Base,8], |
| 63 | ["DYNAMIC_SECTION_L2CACHE_LOCK_0", LinkerSymPostfix::ZILimit,9], |
| 64 | ["EXTSRAM_CORE0", LinkerSymPostfix::Base,9], |
| 65 | ["CACHED_EXTSRAM_CORE0", LinkerSymPostfix::ZILimit,10], |
| 66 | ["EXTSRAM_CORE1", LinkerSymPostfix::Base,10], |
| 67 | ["CACHED_EXTSRAM_CORE1", LinkerSymPostfix::ZILimit,11], |
| 68 | ["DRDI", LinkerSymPostfix::Base,11], |
| 69 | ["DRDI", LinkerSymPostfix::Limit,12], |
| 70 | ["EXTSRAM_L1DSP_ZI", LinkerSymPostfix::Base,12], |
| 71 | ["EXTSRAM_L1DSP_ZI", LinkerSymPostfix::ZILimit,13], |
| 72 | ["DUMMY_END", LinkerSymPostfix::Base,13]); |
| 73 | |
| 74 | |
| 75 | |
| 76 | #&GetFreeRamInfo(shift); |
| 77 | |
| 78 | |
| 79 | sub GetFreeRamInfo |
| 80 | { |
| 81 | my ($g_sym_file) = @_; |
| 82 | my $g_area_begin = 0; |
| 83 | my $g_area_end = 0; |
| 84 | my $g_area_length = 0; |
| 85 | my @freemem =([0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]); |
| 86 | |
| 87 | LinkerOutputParser::FileParse($g_sym_file) if(-e $g_sym_file) or die("Can't open symbol file: $g_sym_file\n"); |
| 88 | |
| 89 | for(my $i = 0 ; $i<$#symbol_list; $i = $i+2) { |
| 90 | $g_area_begin = hex(LinkerOutputParser::GetLinkerSymbolAddress($symbol_list[$i][0],$symbol_list[$i][1], 0)); |
| 91 | $g_area_begin &= 0x0fffffff if($g_area_begin > 0x10000000); |
| 92 | $g_area_begin &= 0x0fffffff if($g_area_begin > 0x10000000); |
| 93 | # Adjust Free area begin address to 64kB |
| 94 | $g_area_begin = ($g_area_begin + hex("ffff") >> 16) << 16; |
| 95 | $g_area_end = hex(LinkerOutputParser::GetLinkerSymbolAddress($symbol_list[$i+1][0],$symbol_list[$i+1][1], 0)); |
| 96 | $g_area_end &= 0x0fffffff if($g_area_end > 0x10000000); |
| 97 | $g_area_end &= 0x0fffffff if($g_area_end > 0x10000000); |
| 98 | |
| 99 | # Adjust Free area end address to 64kB |
| 100 | $g_area_end = ($g_area_end >> 16) << 16; |
| 101 | # Calculate length |
| 102 | $g_area_length = $g_area_end - $g_area_begin; |
| 103 | print $symbol_list[$i][0] . " Start: " .&CommonUtil::Dec2Hex($g_area_begin) . " ". $symbol_list[$i+1][0]. " Start: " .&CommonUtil::Dec2Hex($g_area_end) . " Length :$g_area_length\n"; |
| 104 | if ($g_area_length > 0) { |
| 105 | #Check that can we merge new free area to previous free area if not add as new free region |
| 106 | if (($freemem[-1][0]+$freemem[-1][1]) == $g_area_begin) { |
| 107 | print "Insert from ".&CommonUtil::Dec2Hex($g_area_begin)." Length ".&CommonUtil::Dec2Hex($g_area_length) . " to " . &CommonUtil::Dec2Hex($freemem[-1][0]+$freemem[-1][1]) ."\n"; |
| 108 | $freemem[-1][1]+=$g_area_length; |
| 109 | } else { |
| 110 | push @freemem,[$g_area_begin, $g_area_length]; |
| 111 | # print &CommonUtil::Dec2Hex($g_area_begin) . "\t(" . $g_area_begin . ")\t\t" . &CommonUtil::Dec2Hex($g_area_length) . "\t(" . $g_area_length . ")\n"; |
| 112 | } |
| 113 | } |
| 114 | } |
| 115 | foreach my $entry (@freemem) { |
| 116 | print &CommonUtil::Dec2Hex($entry->[0]) . "\t(" . $entry->[0] . ")\t\t" . &CommonUtil::Dec2Hex($entry->[1]) . "\t(" . $entry->[1] . ")\n"; |
| 117 | } |
| 118 | @freemem = sort {$b->[1] <=> $a->[1]} @freemem; |
| 119 | splice @freemem, 8; |
| 120 | return @freemem; |
| 121 | } |