blob: f938f2872571681633a8f33a13e2f0e508c808a7 [file] [log] [blame]
#!/usr/bin/perl
#
# Copyright Statement:
# --------------------
# This software is protected by Copyright and the information contained
# herein is confidential. The software may not be copied and the information
# contained herein may not be used or disclosed except with the written
# permission of MediaTek Inc. (C) 2006
#
# BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
# THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
# RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
# AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
# NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
# SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
# SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
# THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
# NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
# SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
#
# BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
# LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
# AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
# OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
# MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
#
# THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
# WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
# LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
# RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
# THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
#
#****************************************************************************
#*
#* Filename:
#* ---------
#* emigenMD.pl
#*
#* Project:
#* --------
#*
#*
#* Description:
#* ------------
#* generate emi/flash configuration files
#*
#* Author:
#* -------
#* Guo-Huei Chang (mtk04123)
#* Way Chen (mtk54483)
#****************************************************************************
#****************************************************************************
# Included Modules
#****************************************************************************
use strict;
use warnings;
use Class::Struct ();
use File::Basename ();
use File::Copy ();
use File::Spec ();
use POSIX ();
use Storable ();
push @INC, ("tools/perl",".");
require Spreadsheet::ParseExcel;
local $| = 1; #auto flush 'print' function
my $EMIGEN_VERNO = "v10.001";
#v10.001, by Holmes at 2019/08/01, modify for MT6297
# v9.008, by Guo-Huei at 2014/04/15, Update EMIGEN to generate SmartPhone's DRAM Size by MDL
# v9.007, by Guo-Huei at 2014/01/08, Update EMIGEN for SmartPhone project
# v9.006, by Guo-Huei at 2013/12/09, Update custom_EMI for MT6595
# v9.005, by Way at 2013/11/15, Optimal EMIGEN Flash Part Code for ROME.
# v9.004, by Guo-Huei at 2013/11/06, update emigen for MT6595 build pass
# v9.003, by Way at 2013/10/24, Support MP Level MDL
# v9.002, by Guo-Huei at 2013/08/07, 1. remove lagacy code. 2. auto-generate header file according MDL content 3. Add combo memory support 4. error check for combo memory configuration.
# v9.001, by Guo-Huei at 2013/08/05, 1. remove lagacy code. 2. re-arch emigen flow. 3. remove WIN32 OLE related code. 4. use warnings
# v8.276, by Way at 2013/06/24, 1. remove lagacy code; 2. Re-arch EMIGEN flow; 3. Implement combo flash part auto gen flow; 4. Add combo_nfi_config.h for enhance NAND flash flow of mT6290.
# v8.275, by Way at 2013/06/7, enable auto emigen flash part.
# v8.274, by Way at 2013/05/23, change checking smart phone method without flash.
# v8.273, by Guo-Huei at 2013/05/15, change checking smart phone method without emi.
# v8.272, by Guo-Huei at 2013/05/02, add emigen to support combo memory.
# v8.271, by Guo-Huei at 2013/04/12, update emigen to auto-gen custom_EMI_INFO.h
# v8.270, by Guo-Huei at 2013/03/27, update emigen to support parsing flash.
# v8.269, by Guo-Huei at 2013/03/22, update emigen to auto-generate emi related output files.
# v8.268, by Guo-Huei at 2013/03/19, update custom_EMI function and cfggen EMI part
# v8.267, by Guo-Huei at 2013/02/05, rename emigen from MT7208 to MT6290
# v8.266, by Marvin at 2012/11/01 , autogen support MT6290
my $DebugPrint = 0; # 1 for debug; 0 for non-debug
my $BOOL_EMI_CLEAN = $ARGV[0]; # FALSE
my $CUSTOM_MEMORY_DEVICE_HDR = $ARGV[1]; # ./work/custom/TK6291E1_SUPER_HOSTED/system/custom_MemoryDevice.h
my $THEMF = $ARGV[2]; # ./work/custom/TK6291E1_SUPER_HOSTED/build/customer_feature_option
my $BOOL_MD_INFO = $ARGV[3]; # FALSE
my $INSIDE_MTK = $ARGV[4]; # 1
my $LOAD_TMP_PATH = $ARGV[5]; # ./out/tmp/TK6291E1_SUPER_HOSTED
my $CUSTOM_SYSTEM_DIR = File::Basename::dirname($CUSTOM_MEMORY_DEVICE_HDR);
my $CUSTOM_FEATURE_CONFIG_HDR = File::Spec->catfile($CUSTOM_SYSTEM_DIR, "custom_FeatureConfig.h");
# to align error message file name format
$CUSTOM_MEMORY_DEVICE_HDR =~ s/^.\\|^\\//;
$THEMF =~ s/^.\\|^\\//;
# global parameters
my %PART_NUMBER;
my $emi_clk_config;
my $sfi_clk_config;
my %BBtbl_SFI_FAST_CLK = ( 'MT6291' => 78 );
my %BBtbl_SFI_SLOW_CLK = ( 'MT6291' => 13 );
my $NOR_FLASH_BASE_ADDRESS_VAL;
my $NOR_ALLOCATED_FAT_SPACE_VAL;
my $LPSDRAM_CHIP_SELECT = 0xFF;
my $emi_is_existed = 1;
my @MCP_LIST; # list of PART_NUMBER hash references
my @MDL_INFO_LIST; # list of MEM_DEV_LIST_INFO has references
my %COMM_MDL_INFO; # common MDL info, obtained from MDL_INFO_LIST.
my %MAKEFILE_OPTIONS; #list of makefile option
my %CUSTOM_MEM_DEV_OPTIONS; #list of custom_memory_device option
my %CUSTOM_FEATURE_CFG_OPTIONS;
my $MEMORY_DEVICE_LIST_XLS; #CORRECT MDL FILE
my $MEMORY_DEVICE_LIST_INT_XLS; #INTERNAL MDL FILE
print "os environment: $^O\n";
print "load temp path: $LOAD_TMP_PATH\n";
print "custom memory device: $CUSTOM_MEMORY_DEVICE_HDR\n";
print "makefile: $THEMF\n";
print "inside_mtk: $INSIDE_MTK\n";
require "tools/emigenemi.pl";
require "tools/emigenflash.pl";
#****************************************************************************
# parse makefile
#****************************************************************************
&Parse_Makefile();
if ($MAKEFILE_OPTIONS{'platform'} =~ '^MT629[1235]$') {
$MAKEFILE_OPTIONS{'platform'} = 'MT6291';
} elsif ($MAKEFILE_OPTIONS{'platform'} =~ '^MT629[78]$') {
$MAKEFILE_OPTIONS{'platform'} = 'MT6297';
} else {
&error_handler("not support platform, ".$MAKEFILE_OPTIONS{'platform'}, __FILE__, __LINE__);
}
#****************************************************************************
# generated file list
#****************************************************************************
printf "\n%s#%d: %s\n", __FILE__, __LINE__, "generated file list";
Class::Struct::struct(GEN_FLS_S => {name => '$', owner => '$', path => '$', exist => '$', description => '$'});
my %GEN_FLS = (
custom_emi_h => GEN_FLS_S->new(name => (($MAKEFILE_OPTIONS{'platform'} eq 'MT6291')? "custom_EMI.h": "custom_emi.h"), owner => "holmes.lin (mtk09097)", description => "This Module defines the EMI (external memory interface) related setting."),
custom_emi_info_c => GEN_FLS_S->new(name => "custom_EMI_INFO.c", owner => "holmes.lin (mtk09097)", description => "This Module defines the EMI (external memory interface) related setting."),
custom_emi_release_h => GEN_FLS_S->new(name => "custom_EMI_release.h", owner => "holmes.lin (mtk09097)", description => "This Module defines the EMI (external memory interface) related setting."),
#custom_emi_c => GEN_FLS_S->new(name => "custom_EMI.c", owner => "holmes.lin (mtk09097)", description => ""),
#custom_sfi_h => GEN_FLS_S->new(name => "custom_SFI.h", owner => "way.chen (mtk54483)", description => ""),
custom_flash_h => GEN_FLS_S->new(name => "custom_flash.h", owner => "way.chen (mtk54483)", description => "This Module defines flash related settings."),
flash_opt_gen_h => GEN_FLS_S->new(name => "flash_opt_gen.h", owner => "way.chen (mtk54483)", description => "NOR flash related options."),
custom_flash_norfdm5_h => GEN_FLS_S->new(name => "custom_flash_norfdm5.h", owner => "way.chen (mtk54483)", description => "defines prototypes and data structure which will be used in NOR FDM 5.0"),
combo_flash_config_h => GEN_FLS_S->new(name => "combo_flash_config.h", owner => "way.chen (mtk54483)", description => "This Module defines the Flash configurations for Combo Memory."),
combo_flash_id_h => GEN_FLS_S->new(name => "combo_flash_id.h", owner => "way.chen (mtk54483)", description => "This Module defines the Flash ID table for Combo Memory."),
#combo_sfi_config_h => GEN_FLS_S->new(name => "combo_sfi_config.h", owner => "way.chen (mtk54483)", description => ""),
combo_sfi_defs_h => GEN_FLS_S->new(name => "combo_sfi_defs.h", owner => "way.chen (mtk54483)", description => "defines flash ID table"),
#custom_sfi_clock_h => GEN_FLS_S->new(name => "custom_sfi_clock.h", owner => "way.chen (mtk54483)", description => ""),
combo_nfi_config_h => GEN_FLS_S->new(name => "combo_nfi_config.h", owner => "way.chen (mtk54483)", description => "gen NAND Flash Related Configuration and Table"),
);
map {$GEN_FLS{$_}->path(File::Spec->catfile($CUSTOM_SYSTEM_DIR, $GEN_FLS{$_}->name))} keys(%GEN_FLS);
print "output file: ", join(", ", map {$GEN_FLS{$_}->path} sort(keys(%GEN_FLS))), "\n";
#****************************************************************************
# emiclean
#****************************************************************************
printf "\n%s#%d: %s\n", __FILE__, __LINE__, "emiclean";
my @gen_depends = ("tools/emigenMD.pl", "tools/emigenSP.pl", "tools/emigenemi.pl", "tools/emigenflash.pl", "tools/emigenSF.pl", $THEMF, $CUSTOM_MEMORY_DEVICE_HDR, $MEMORY_DEVICE_LIST_XLS, $MEMORY_DEVICE_LIST_INT_XLS, $CUSTOM_FEATURE_CONFIG_HDR);
if ($BOOL_EMI_CLEAN eq 'TRUE') {
map {&Check_ManualCheckIn($GEN_FLS{$_}->path, "TRUE", @gen_depends)} keys(%GEN_FLS);
exit;
} else {
map {&Check_ManualCheckIn($GEN_FLS{$_}->path, "FALSE", @gen_depends)} keys(%GEN_FLS);
}
map {$GEN_FLS{$_}->exist((-e $GEN_FLS{$_}->path)? 1: 0)} keys(%GEN_FLS);
#****************************************************************************
# find the correct EMI database
#****************************************************************************
&Find_MDL();
#****************************************************************************
# parse custom_MemoryDevice.h to extract MEMORY_DEVICE_TYPE & PART_NUMBER
#****************************************************************************
&Parse_Memory_Device();
#****************************************************************************
# parse custom_FeatureConfig.h to extract feature-related configurations
#****************************************************************************
&Parse_custom_FeatureConfig();
#****************************************************************************
# Check EMI exist
#****************************************************************************
if ($CUSTOM_MEM_DEV_OPTIONS{MEMORY_DEVICE_TYPE} eq 'NONE')
{
require "tools/emiGenSP.pl";
$emi_is_existed = 0;
}
#****************************************************************************
# parse EMI database to get EMI settings
#****************************************************************************
&Parse_MDL();
#****************************************************************************
# Check Combo Memory configuration validity
#****************************************************************************
my $nor_size_Mb;
&CheckConfigValid();
#****************************************************************************
# check consistency among FEATURE, MEMORY_DEVICE_TYPE, PLATFORM, MCU_CLOCK and MemoryDeviceList data
#****************************************************************************
$sfi_clk_config = $BBtbl_SFI_FAST_CLK{$MAKEFILE_OPTIONS{'platform'}};
&Decide_MemClockSpeed();
#****************************************************************************
# get common MDL information from a list of MDL information for Combo Memory
#****************************************************************************
printf "\n%s#%d: %s\n", __FILE__, __LINE__, "get_common_MDL_info";
&get_common_MDL_info(\@MDL_INFO_LIST, \%CUSTOM_MEM_DEV_OPTIONS, \%COMM_MDL_INFO,\%MAKEFILE_OPTIONS, $LPSDRAM_CHIP_SELECT, $CUSTOM_MEMORY_DEVICE_HDR, $emi_is_existed);
if ($DebugPrint == 1)
{
print "COMM_MDL_INFO: Flash Size = $COMM_MDL_INFO{0}->{'Flash Size'}, NAND Block Size(KB) = $COMM_MDL_INFO{0}->{'NAND Block Size(KB)'}, Small Block Start = $COMM_MDL_INFO{0}->{'Small Block Start'}, Default FAT Base = $COMM_MDL_INFO{0}->{'Default FAT Base'}, Default FAT Size = $COMM_MDL_INFO{0}->{'Default FAT Size'}\n";
#print "RAM \"Size (Mb)\" = $COMM_MDL_INFO{1}->{'Size (Mb)'}, \"CS0 ADMUX\" = $COMM_MDL_INFO{0}->{'ADMUX'}, \"CS1 ADMUX\" = $COMM_MDL_INFO{1}->{'ADMUX'}, \"DRAM\" = $COMM_MDL_INFO{1}->{'DRAM'}, \"CS0 Comm. Series\" = $COMM_MDL_INFO{0}->{'Comm. Series'}, \"CS1 Comm. Series\" = $COMM_MDL_INFO{1}->{'Comm. Series'}, \"Bank\" = $COMM_MDL_INFO{0}->{'Bank'}, \"PBP->Y / N\" = $COMM_MDL_INFO{0}->{'PBP'}->{'Y / N'}, \"PBP->Size(W)\" = $COMM_MDL_INFO{0}->{'PBP'}->{'Size(W)'}\n";
}
#****************************************************************************
# PROJECT EXPECTED CONFIGURE
#****************************************************************************
my $physical_ram_density;
my $project_expected_ram_limit_common = (exists $MAKEFILE_OPTIONS{'nand_flash_booting'} and $MAKEFILE_OPTIONS{'nand_flash_booting'} ne 'NONE') ? $CUSTOM_FEATURE_CFG_OPTIONS{PROJECT_EXPECTED_RAM_LIMIT_NFB} : $CUSTOM_FEATURE_CFG_OPTIONS{PROJECT_EXPECTED_RAM_LIMIT};
if (defined $project_expected_ram_limit_common)
{
#ensure practical
&error_handler("$CUSTOM_MEMORY_DEVICE_HDR: Cannot configure expected RAMSIZE larger than physical RAM size!", __FILE__, __LINE__)
if ( hex($project_expected_ram_limit_common) > ($COMM_MDL_INFO{1}->{'Size (Mb)'} * 1024 * 1024 / 8) );
#ensure 2^n
my $i;
for( $i = 1 ; $i < hex($project_expected_ram_limit_common) ; $i *= 2 ){1;}
if ( $i < ($COMM_MDL_INFO{1}->{'Size (Mb)'} * 1024 * 1024 / 8) )
{
$physical_ram_density = "// PHYSICAL RAM DENSITY $COMM_MDL_INFO{1}->{'Size (Mb)'} Mb\n";
$COMM_MDL_INFO{1}->{'Size (Mb)'} = $i * 8 / ( 1024 * 1024);
}
}
chomp $physical_ram_density if (defined $physical_ram_density);
#****************************************************************************
# get common entire geometry information for Combo Memory
#****************************************************************************
my (@entire_region_info_size_list, @entire_region_info_count_list, @entire_bank_info_size_list, @entire_bank_info_count_list);
my (@entire_block_info_start_list, @entire_block_info_size_list);
if ($MAKEFILE_OPTIONS{'serial_flash_support'} eq 'TRUE')
{
printf "\n%s#%d: %s\n", __FILE__, __LINE__, "get_common_MDL_Geo_info, convert_regions_to_blocks";
&get_common_MDL_Geo_info(\@MDL_INFO_LIST, $CUSTOM_MEM_DEV_OPTIONS{COMBO_MEM_ENTRY_COUNT}, $CUSTOM_MEM_DEV_OPTIONS{MEMORY_DEVICE_TYPE}, 0, $COMM_MDL_INFO{0}->{'Flash Size'}, \@entire_region_info_size_list, \@entire_region_info_count_list, \@entire_bank_info_size_list, \@entire_bank_info_count_list);
&convert_regions_to_blocks(0, \@entire_region_info_size_list, \@entire_region_info_count_list, \@entire_block_info_start_list, \@entire_block_info_size_list);
}
#NAND Flash Also need to check FAT for MT6290, we may use NAND FAT Infomation
printf "\n%s#%d: %s\n", __FILE__, __LINE__, "Calculate_FAT_Info";
&Calculate_FAT_Info(\%MAKEFILE_OPTIONS, \%CUSTOM_MEM_DEV_OPTIONS, \%COMM_MDL_INFO, \@MDL_INFO_LIST, \$NOR_FLASH_BASE_ADDRESS_VAL, \$NOR_ALLOCATED_FAT_SPACE_VAL, $nor_size_Mb, \%CUSTOM_FEATURE_CFG_OPTIONS, \@entire_block_info_start_list, \@entire_block_info_size_list);
#****************************************************************************
# get common FS geometry information for Combo Memory
#****************************************************************************
my (@fs_region_info_size_list, @fs_region_info_count_list, @fs_bank_info_size_list, @fs_bank_info_count_list);
my (@fs_block_info_start_list, @fs_block_info_size_list);
if ($MAKEFILE_OPTIONS{'serial_flash_support'} eq 'TRUE')
{
printf "\n%s#%d: %s\n", __FILE__, __LINE__, "get_common_MDL_Geo_info; convert_regions_to_blocks";
&get_common_MDL_Geo_info(\@MDL_INFO_LIST, $CUSTOM_MEM_DEV_OPTIONS{COMBO_MEM_ENTRY_COUNT}, $CUSTOM_MEM_DEV_OPTIONS{MEMORY_DEVICE_TYPE}, $NOR_FLASH_BASE_ADDRESS_VAL, $NOR_FLASH_BASE_ADDRESS_VAL+$NOR_ALLOCATED_FAT_SPACE_VAL, \@fs_region_info_size_list, \@fs_region_info_count_list, \@fs_bank_info_size_list, \@fs_bank_info_count_list);
&convert_regions_to_blocks($NOR_FLASH_BASE_ADDRESS_VAL, \@fs_region_info_size_list, \@fs_region_info_count_list, \@fs_block_info_start_list, \@fs_block_info_size_list);
if ($DebugPrint == 1)
{
print "Entire RegionInfo: ";
for (0..$#entire_region_info_size_list)
{
print "\{$entire_region_info_size_list[$_], $entire_region_info_count_list[$_]\}, ";
}
print "\nEntire BankInfo: ";
for (0..$#entire_bank_info_size_list)
{
print "\{$entire_bank_info_size_list[$_], $entire_bank_info_count_list[$_]\}, ";
}
print "\nEntire BlockInfo: ";
for (0..$#entire_block_info_start_list)
{
print "\{$entire_block_info_start_list[$_], $entire_block_info_size_list[$_]\}, ";
}
print "\nFS RegionInfo: ";
for (0..$#fs_region_info_size_list)
{
print "\{$fs_region_info_size_list[$_], $fs_region_info_count_list[$_]\}, ";
}
print "\nFS BankInfo: ";
for (0..$#fs_bank_info_size_list)
{
print "\{$fs_bank_info_size_list[$_], $fs_bank_info_count_list[$_]\}, ";
}
print "\nFS BlockInfo: ";
for (0..$#fs_block_info_start_list)
{
print "\{$fs_block_info_start_list[$_], $fs_block_info_size_list[$_]\}, ";
}
print "\n";
}
}
### Validate FAT and NOR Raw disk overlapping case
printf "\n%s#%d: %s\n", __FILE__, __LINE__, "Validate_FAT_NORRAWDISK_OVERLAP; Calculate_NORRAWDISK_Region_Info";
&Validate_FAT_NORRAWDISK_OVERLAP(\%CUSTOM_MEM_DEV_OPTIONS, \%COMM_MDL_INFO, \$NOR_FLASH_BASE_ADDRESS_VAL, \$NOR_ALLOCATED_FAT_SPACE_VAL, $CUSTOM_MEMORY_DEVICE_HDR);
### Calculate NOR Raw disk Region Info
&Calculate_NORRAWDISK_Region_Info(\%CUSTOM_MEM_DEV_OPTIONS);
### Check CODE setting validity
my $expected_code_limit;
if (defined $CUSTOM_FEATURE_CFG_OPTIONS{PROJECT_EXPECTED_CODE_LIMIT})
{
#ensure practical
&error_handler("$CUSTOM_FEATURE_CONFIG_HDR: Cannot configure expected CODESIZE larger than (physical NOR flash size - FAT space)!", __FILE__, __LINE__)
if ( hex($CUSTOM_FEATURE_CFG_OPTIONS{PROJECT_EXPECTED_CODE_LIMIT}) > $NOR_FLASH_BASE_ADDRESS_VAL );
}
#****************************************************************************
# generate custom_EMI.h
#****************************************************************************
if (($GEN_FLS{custom_emi_h}->exist == 0) and
($MAKEFILE_OPTIONS{'platform'} =~ 'MT629[17]'))
{
printf "\n%s#%d: %s\n", __FILE__, __LINE__, "custom_emi_h";
my $gf = $GEN_FLS{custom_emi_h};
open (GFH, ">", $gf->path) or &error_handler($gf->path.": $!", __FILE__, __LINE__);
print GFH &copyright_file_header();
print GFH &description_file_header($gf->name, $gf->description, $gf->owner);
if ($emi_is_existed == 0) {
print GFH &custom_EMI_h_file_body_for_sp($MAKEFILE_OPTIONS{'platform'});
} elsif ($MAKEFILE_OPTIONS{'platform'} eq 'MT6291') {
print GFH &custom_EMI_h_file_body_for_91(\%MAKEFILE_OPTIONS,\%CUSTOM_MEM_DEV_OPTIONS,\@MDL_INFO_LIST, \%COMM_MDL_INFO, \%PART_NUMBER, $CUSTOM_MEMORY_DEVICE_HDR, $LPSDRAM_CHIP_SELECT, $emi_clk_config);
} else {
print GFH &custom_emi_h_file_body_for_97(\%MAKEFILE_OPTIONS,\@MDL_INFO_LIST);
}
close GFH or &error_handler($gf->path.": $!", __FILE__, __LINE__);
print $gf->path, " is generated\n";
}
#****************************************************************************
# generate custom_EMI_INFO.c
#****************************************************************************
if (($GEN_FLS{custom_emi_info_c}->exist == 0) and
($MAKEFILE_OPTIONS{'platform'} eq 'MT6291'))
{
printf "\n%s#%d: %s\n", __FILE__, __LINE__, "custom_emi_info_c";
my $gf = $GEN_FLS{custom_emi_info_c};
open (GFH, ">", $gf->path) or &error_handler($gf->path.": $!", __FILE__, __LINE__);
print GFH &copyright_file_header();
print GFH &description_file_header($gf->name, $gf->description, $gf->owner);
if ($emi_is_existed == 0) {
print GFH &custom_EMI_info_h_file_body_for_sp($MAKEFILE_OPTIONS{'platform'});
} else {
print GFH &custom_EMI_info_c_file_body_for_91(\%MAKEFILE_OPTIONS,\%CUSTOM_MEM_DEV_OPTIONS,\@MDL_INFO_LIST, \%COMM_MDL_INFO, \%PART_NUMBER, $CUSTOM_MEMORY_DEVICE_HDR, $LPSDRAM_CHIP_SELECT, $emi_clk_config);
}
close GFH or &error_handler($gf->path.": $!", __FILE__, __LINE__);
print $gf->path, " is generated\n";
}
#****************************************************************************
# generate custom_EMI_release.h
#****************************************************************************
if (($GEN_FLS{custom_emi_release_h}->exist == 0) and
($MAKEFILE_OPTIONS{'platform'} eq 'MT6291'))
{
printf "\n%s#%d: %s\n", __FILE__, __LINE__, "custom_emi_release_h";
my $gf = $GEN_FLS{custom_emi_release_h};
open (GFH, ">", $gf->path) or &error_handler($gf->path.": $!", __FILE__, __LINE__);
print GFH &copyright_file_header();
print GFH &description_file_header($gf->name, $gf->description, $gf->owner);
if ($emi_is_existed == 0) {
print GFH &custom_EMI_release_h_file_body_for_sp(\%MAKEFILE_OPTIONS,\%CUSTOM_MEM_DEV_OPTIONS,\@MDL_INFO_LIST, \%COMM_MDL_INFO, $LPSDRAM_CHIP_SELECT, $emi_clk_config);
} else {
print GFH &custom_EMI_release_h_file_body_for_91(\%MAKEFILE_OPTIONS,\%CUSTOM_MEM_DEV_OPTIONS,\@MDL_INFO_LIST, \%COMM_MDL_INFO, $LPSDRAM_CHIP_SELECT, $emi_clk_config);
}
close GFH or &error_handler($gf->path.": $!", __FILE__, __LINE__);
print $gf->path, " is generated\n";
}
#****************************************************************************
# generate flash_opt_gen.h
#****************************************************************************
if ($GEN_FLS{flash_opt_gen_h}->exist == 0)
{
printf "\n%s#%d: %s\n", __FILE__, __LINE__, "flash_opt_gen_h";
my $gf = $GEN_FLS{flash_opt_gen_h};
open (GFH, ">", $gf->path) or &error_handler($gf->path.": $!", __FILE__, __LINE__);
print GFH &copyright_file_header();
print GFH &description_file_header($gf->name, $gf->description, $gf->owner);
print GFH &flash_opt_gen_h_file_body(\%MAKEFILE_OPTIONS,\%CUSTOM_MEM_DEV_OPTIONS,\@MDL_INFO_LIST, \%COMM_MDL_INFO, $CUSTOM_MEMORY_DEVICE_HDR, $THEMF, \@entire_bank_info_size_list, \@entire_bank_info_count_list, \@entire_block_info_start_list, \@entire_block_info_size_list, \@entire_region_info_size_list, \@entire_region_info_count_list);
close GFH or &error_handler($gf->path.": $!", __FILE__, __LINE__);
print $gf->path, " is generated\n";
}
#****************************************************************************
# generate custom_flash.h
#****************************************************************************
if ($GEN_FLS{custom_flash_h}->exist == 0)
{
printf "\n%s#%d: %s\n", __FILE__, __LINE__, "custom_flash_h";
my $gf = $GEN_FLS{custom_flash_h};
open (GFH, ">", $gf->path) or &error_handler($gf->path.": $!", __FILE__, __LINE__);
print GFH &copyright_file_header();
print GFH &description_file_header($gf->name, $gf->description, $gf->owner);
print GFH &custom_flash_h_file_body(\%MAKEFILE_OPTIONS,\%CUSTOM_MEM_DEV_OPTIONS, \@MDL_INFO_LIST, \%COMM_MDL_INFO, \@MCP_LIST, $NOR_FLASH_BASE_ADDRESS_VAL, $NOR_ALLOCATED_FAT_SPACE_VAL, $LPSDRAM_CHIP_SELECT, $CUSTOM_MEMORY_DEVICE_HDR, $nor_size_Mb, \@entire_bank_info_size_list, \@entire_bank_info_count_list, \@entire_block_info_start_list, \@entire_block_info_size_list,\@fs_region_info_size_list, \@fs_region_info_count_list, \@entire_region_info_size_list, \@entire_region_info_count_list);
close GFH or &error_handler($gf->path.": $!", __FILE__, __LINE__);
print $gf->path, " is generated\n";
}
#****************************************************************************
# generate custom_flash_norfdm5.h
#****************************************************************************
if (($GEN_FLS{custom_flash_norfdm5_h}->exist == 0) and
(defined $CUSTOM_MEM_DEV_OPTIONS{__NOR_FDM5__})) ##Only __NOR_FDM5__ defined will gen custom_flash_norfdm5.h
{
printf "\n%s#%d: %s\n", __FILE__, __LINE__, "custom_flash_norfdm5_h";
my $gf = $GEN_FLS{custom_flash_norfdm5_h};
open (GFH, ">", $gf->path) or &error_handler($gf->path.": $!", __FILE__, __LINE__);
print GFH &copyright_file_header();
print GFH &description_file_header($gf->name, $gf->description, $gf->owner);
print GFH &custom_flash_norfdm5_h_file_body(\%MAKEFILE_OPTIONS, \%CUSTOM_MEM_DEV_OPTIONS, \@MDL_INFO_LIST, \%COMM_MDL_INFO, $NOR_FLASH_BASE_ADDRESS_VAL, $NOR_ALLOCATED_FAT_SPACE_VAL,\@entire_bank_info_size_list, \@entire_bank_info_count_list);
close GFH or &error_handler($gf->path.": $!", __FILE__, __LINE__);
print $gf->path, " is generated\n";
}
#****************************************************************************
# generate combo_flash_config.h
#****************************************************************************
if ($GEN_FLS{combo_flash_config_h}->exist == 0)
{
printf "\n%s#%d: %s\n", __FILE__, __LINE__, "combo_flash_config_h";
my $gf = $GEN_FLS{combo_flash_config_h};
open (GFH, ">", $gf->path) or &error_handler($gf->path.": $!", __FILE__, __LINE__);
print GFH &copyright_file_header();
print GFH &description_file_header($gf->name, $gf->description, $gf->owner);
print GFH &combo_flash_config_h_file_body(\%MAKEFILE_OPTIONS, \%CUSTOM_MEM_DEV_OPTIONS, \@MDL_INFO_LIST, \%COMM_MDL_INFO);
close GFH or &error_handler($gf->path.": $!", __FILE__, __LINE__);
print $gf->path, " is generated\n";
}
#****************************************************************************
# generate combo_flash_id.h
#****************************************************************************
if ($GEN_FLS{combo_flash_id_h}->exist == 0)
{
printf "\n%s#%d: %s\n", __FILE__, __LINE__, "combo_flash_id_h";
my $gf = $GEN_FLS{combo_flash_id_h};
open (GFH, ">", $gf->path) or &error_handler($gf->path.": $!", __FILE__, __LINE__);
print GFH &copyright_file_header();
print GFH &description_file_header($gf->name, $gf->description, $gf->owner);
print GFH &combo_flash_id_h_file_body(\%MAKEFILE_OPTIONS, \%CUSTOM_MEM_DEV_OPTIONS, \@MDL_INFO_LIST, \%COMM_MDL_INFO);
close GFH or &error_handler($gf->path.": $!", __FILE__, __LINE__);
print $gf->path, " is generated\n";
}
#****************************************************************************
# generate combo_nfi_config.h
#****************************************************************************
if (($GEN_FLS{combo_nfi_config_h}->exist == 0) and
($MAKEFILE_OPTIONS{'nand_support'} eq 'TRUE') and
($MAKEFILE_OPTIONS{'platform'} =~ /MT629[17]/))
{
printf "\n%s#%d: %s\n", __FILE__, __LINE__, "combo_nfi_config_h";
my $gf = $GEN_FLS{combo_nfi_config_h};
open (GFH, ">", $gf->path) or &error_handler($gf->path.": $!", __FILE__, __LINE__);
print GFH &copyright_file_header();
print GFH &description_file_header($gf->name, $gf->description, $gf->owner);
print GFH &combo_nfi_config_h_file_body(\%MAKEFILE_OPTIONS, \%CUSTOM_MEM_DEV_OPTIONS, \@MDL_INFO_LIST, \%COMM_MDL_INFO);
close GFH or &error_handler($gf->path.": $!", __FILE__, __LINE__);
print $gf->path, " is generated\n";
}
#****************************************************************************
# generate combo_sfi_defs.h
#****************************************************************************
if (($GEN_FLS{combo_sfi_defs_h}->exist == 0) and
($MAKEFILE_OPTIONS{'serial_flash_support'} eq 'TRUE') and
($MAKEFILE_OPTIONS{'platform'} =~ 'MT629[17]'))
{
printf "\n%s#%d: %s\n", __FILE__, __LINE__, "combo_sfi_defs_h";
my $gf = $GEN_FLS{combo_sfi_defs_h};
open (GFH, ">", $gf->path) or &error_handler($gf->path.": $!", __FILE__, __LINE__);
print GFH &copyright_file_header();
print GFH &description_file_header($gf->name, $gf->description, $gf->owner);
print GFH &combo_sfi_defs_h_file_body(\%MAKEFILE_OPTIONS, \%CUSTOM_MEM_DEV_OPTIONS, \@MDL_INFO_LIST, \%COMM_MDL_INFO);
close GFH or &error_handler($gf->path.": $!", __FILE__, __LINE__);
print $gf->path, " is generated\n";
}
exit;
#****************************************************************************
# find the correct EMI database
#****************************************************************************
sub Find_MDL
{
print("\n", (caller(0))[3], "\n");
my $MDL_DIR = "tools/MemoryDeviceList/";
my $platform = $MAKEFILE_OPTIONS{'platform'};
my $ver = 0000;
$MEMORY_DEVICE_LIST_XLS = "";
$MEMORY_DEVICE_LIST_INT_XLS = "";
opendir(DIR, $MDL_DIR) or &error_handler("$MDL_DIR: $!", __FILE__, __LINE__);;
if (defined($MAKEFILE_OPTIONS{'ram_support_type'}) && $MAKEFILE_OPTIONS{'ram_support_type'} eq 'NONE') {
$platform = $MAKEFILE_OPTIONS{'ram_support_type'};
}
while (my $mdl = readdir(DIR)) {
if ($mdl =~ /MemoryDeviceList_$platform\_SinceW(\w+)\.xls/) {
if ($1 > $ver) {
$ver = $1;
$MEMORY_DEVICE_LIST_XLS = $MDL_DIR . $mdl;
}
} elsif ($mdl =~ /MemoryDeviceList_$platform\_Internal\.xls/) {
$MEMORY_DEVICE_LIST_INT_XLS = $MDL_DIR . $mdl;
}
}
close(DIR);
if ((! -e $MEMORY_DEVICE_LIST_XLS) && (! -e $MEMORY_DEVICE_LIST_INT_XLS)) {
&error_handler("MDL Excel is not exist for platform '$platform':$MEMORY_DEVICE_LIST_XLS and $MEMORY_DEVICE_LIST_INT_XLS", __FILE__, __LINE__);
}
if ($DebugPrint == 1) {
print "custom memory device header file: $CUSTOM_MEMORY_DEVICE_HDR\n";
print "MDL Excel: $MEMORY_DEVICE_LIST_XLS, Internal MDL Excel: $MEMORY_DEVICE_LIST_INT_XLS\n";
print "Makefile: $THEMF\n";
}
}
#****************************************************************************
# parse Project Makefile
#****************************************************************************
sub Parse_Makefile
{
print("\n", (caller(0))[3], "\n");
my @filelist = ($THEMF, undef);
my $keyname;
foreach my $filename (@filelist) {
print "filename: $filename\n" if ($DebugPrint == 1);
open (FILE_HANDLE, "<$filename") or &error_handler("$filename: $!", __FILE__, __LINE__);
while (<FILE_HANDLE>) {
if (/^(\w+)\s*=\s*(\S+)/) {
$keyname = lc($1);
defined($MAKEFILE_OPTIONS{$keyname}) && warn "$1 redefined in $THEMF!\n";
$MAKEFILE_OPTIONS{$keyname} = $2;
if ($keyname eq 'internal_feature_option') {
($filelist[1] = $2) =~ s/\$WORKDIR/$ENV{WORKDIR}/;
}
print "$1 = $2\n" if ($DebugPrint == 1);
}
}
close (FILE_HANDLE);
}
$MAKEFILE_OPTIONS{'platform'} = $MAKEFILE_OPTIONS{'platform_chip'} || 'MT6291';
}
#****************************************************************************
# parse Memory Device
#****************************************************************************
sub Parse_Memory_Device
{
print("\n", (caller(0))[3], "\n");
open CUSTOM_MEMORY_DEVICE_HDR, "<$CUSTOM_MEMORY_DEVICE_HDR" or &error_handler("$CUSTOM_MEMORY_DEVICE_HDR: $!", __FILE__, __LINE__);
while (<CUSTOM_MEMORY_DEVICE_HDR>)
{
# error-checking
if ((/^#if|^#ifdef|^#ifndef|^#elif|^#else/) and !(/^#ifndef\s+__CUSTOM_MEMORYDEVICE__/))
{
&error_handler("$CUSTOM_MEMORY_DEVICE_HDR: Not allowed to set conditional keywords $_ in custom_MemoryDevice.h!", __FILE__, __LINE__);
}
if (/^#define\s+(\w+)\s+\(?([\w|\-]*)\)?/)
{
&error_handler("$CUSTOM_MEMORY_DEVICE_HDR: $1 redefined in custom_MemoryDevice.h!", __FILE__, __LINE__) if defined($CUSTOM_MEM_DEV_OPTIONS{$1});
$CUSTOM_MEM_DEV_OPTIONS{$1} = ((!defined $2) or ($2 eq ''))? 'TRUE': $2;
my $option = $1;
my $content = $2;
if ($option =~ /COMBO_MEM(\d+)_CS(\d+)_PART_NUMBER/)
{
next if ((!defined $MAKEFILE_OPTIONS{'combo_memory_support'}) or ($MAKEFILE_OPTIONS{'combo_memory_support'} eq 'FALSE'));
print "$option = $content\n" if ($DebugPrint == 1);
&error_handler("$CUSTOM_MEMORY_DEVICE_HDR: COMBO_MEM_ENTRY_COUNT needs to be defined when COMBO_MEMORY_SUPPORT is turned on!", __FILE__, __LINE__) if (!defined $CUSTOM_MEM_DEV_OPTIONS{COMBO_MEM_ENTRY_COUNT});
my %TMP_PART_NUMBER;
my $mcp_idx = $1;
my $cs = $2;
$LPSDRAM_CHIP_SELECT = $cs;
&error_handler("$CUSTOM_MEMORY_DEVICE_HDR: Only COMBO_MEM0n_CS0 or COMBO_MEM0n_CS1 is allowed!", __FILE__, __LINE__) if (($LPSDRAM_CHIP_SELECT != 0) && ($LPSDRAM_CHIP_SELECT != 1));
$TMP_PART_NUMBER{$cs} = $content;
if (defined $MCP_LIST[$mcp_idx])
{
if (defined $MCP_LIST[$mcp_idx]->{$cs})
{
&error_handler("$CUSTOM_MEMORY_DEVICE_HDR: COMBO_MEM$mcp_idx\_CS$cs\_PART_NUMBER multiply defined!", __FILE__, __LINE__);
}
else
{
$MCP_LIST[$mcp_idx]->{$cs} = $TMP_PART_NUMBER{$cs};
}
}
else
{
$MCP_LIST[$mcp_idx] = \%TMP_PART_NUMBER;
}
}
elsif ($option =~ /CS(\d+)_PART_NUMBER/)
{
next if ($MAKEFILE_OPTIONS{'combo_memory_support'} eq 'TRUE'); # when COMBO_MEMORY_SUPPORT is turned on, CSx_PART_NUMBER is ignored
print "$option = $content\n" if ($DebugPrint == 1);
my $cs = $1;
$LPSDRAM_CHIP_SELECT = $cs;
&error_handler("$CUSTOM_MEMORY_DEVICE_HDR: Only COMBO_MEM0n_CS0 or COMBO_MEM0n_CS1 is allowed!", __FILE__, __LINE__) if (($LPSDRAM_CHIP_SELECT != 0) && ($LPSDRAM_CHIP_SELECT != 1));
$PART_NUMBER{$cs} = $content;
}
}
}
close CUSTOM_MEMORY_DEVICE_HDR;
$CUSTOM_MEM_DEV_OPTIONS{NOR_FDM4_ESB_PARAMETER_ERASE_QUEUE_SIZE} = (defined $CUSTOM_MEM_DEV_OPTIONS{NOR_FDM4_ESB_PARAMETER_ERASE_QUEUE_SIZE}) ? $CUSTOM_MEM_DEV_OPTIONS{NOR_FDM4_ESB_PARAMETER_ERASE_QUEUE_SIZE} : 5;
$CUSTOM_MEM_DEV_OPTIONS{NOR_PARAMETER_SYSTEM_DRIVE_RESERVED_BLOCK} = (defined $CUSTOM_MEM_DEV_OPTIONS{NOR_PARAMETER_SYSTEM_DRIVE_RESERVED_BLOCK}) ? $CUSTOM_MEM_DEV_OPTIONS{NOR_PARAMETER_SYSTEM_DRIVE_RESERVED_BLOCK} : 3;
# No Combo MCP case
if ($MAKEFILE_OPTIONS{'combo_memory_support'} ne 'TRUE')
{
$MCP_LIST[1] = \%PART_NUMBER;
$CUSTOM_MEM_DEV_OPTIONS{COMBO_MEM_ENTRY_COUNT} = 1;
}
# COMBO_MEM_ENTRY_COUNT and the number of COMBO_MEMxx_CSx_PART_NUMBER does not match
if ($CUSTOM_MEM_DEV_OPTIONS{COMBO_MEM_ENTRY_COUNT} != $#MCP_LIST)
{
&error_handler("$CUSTOM_MEMORY_DEVICE_HDR: COMBO_MEM_ENTRY_COUNT and the number of COMBO_MEMxx_CSx_PART_NUMBER does not match!", __FILE__, __LINE__);
}
###Check MEMORY_DEVICE_TYPE correction
if (($CUSTOM_MEM_DEV_OPTIONS{MEMORY_DEVICE_TYPE} !~ /$MAKEFILE_OPTIONS{'ram_support_type'}/) ||
(($MAKEFILE_OPTIONS{'ram_support_type'} =~ /DDR$/) && ($CUSTOM_MEM_DEV_OPTIONS{MEMORY_DEVICE_TYPE} =~ /DDR\d+/))) {
&error_handler("$CUSTOM_MEMORY_DEVICE_HDR: ram type of MEMORY_DEVICE_TYPE ($CUSTOM_MEM_DEV_OPTIONS{MEMORY_DEVICE_TYPE}) and ram_support_type ($MAKEFILE_OPTIONS{'ram_support_type'}) should be the same", __FILE__, __LINE__);
}
}
#****************************************************************************
# parse EMI database to get EMI settings
#****************************************************************************
sub Parse_MDL
{
print("\n", (caller(0))[3], "\n");
my $result;
my %tmp_hash;
&error_handler("$CUSTOM_MEMORY_DEVICE_HDR: Incorrect memory device type!", __FILE__, __LINE__) unless $CUSTOM_MEM_DEV_OPTIONS{MEMORY_DEVICE_TYPE};
##Parse DRAM Parameters
my $dram_sheet = $CUSTOM_MEM_DEV_OPTIONS{MEMORY_DEVICE_TYPE};
if ($MAKEFILE_OPTIONS{'sip_ram_size'} ne 'NONE') {
$dram_sheet = 'SIP_' . $dram_sheet;
}
if ($emi_is_existed == 1) {
for (1..$CUSTOM_MEM_DEV_OPTIONS{COMBO_MEM_ENTRY_COUNT})
{
$result = &get_info($MEMORY_DEVICE_LIST_XLS, $dram_sheet, $MCP_LIST[$_], \%tmp_hash);
if ($result ne 'TRUE')
{
print "INTERNAL FIND part number: $MCP_LIST[$_]->{0}, $MCP_LIST[$_]->{1}\n";
$result = &get_info($MEMORY_DEVICE_LIST_INT_XLS, $dram_sheet, $MCP_LIST[$_], \%tmp_hash);
}
&error_handler("$CUSTOM_MEMORY_DEVICE_HDR: Part Number $MCP_LIST[$_]->{0} not found!", __FILE__, __LINE__) if ($result ne 'TRUE');
$MDL_INFO_LIST[$_] = Storable::dclone(\%tmp_hash);
}
} else {
for (1..$CUSTOM_MEM_DEV_OPTIONS{COMBO_MEM_ENTRY_COUNT})
{
$result = &get_info($MEMORY_DEVICE_LIST_XLS, 'RAM', $MCP_LIST[$_], \%tmp_hash);
if ($result ne 'TRUE')
{
print "INTERNAL FIND part number: $MCP_LIST[$_]->{0}, $MCP_LIST[$_]->{1}\n";
$result = &get_info($MEMORY_DEVICE_LIST_INT_XLS, 'RAM', $MCP_LIST[$_], \%tmp_hash);
}
&error_handler("Cannot find $MAKEFILE_OPTIONS{'platform'} in MDL!", __FILE__, __LINE__) if ($result ne 'TRUE');
$MDL_INFO_LIST[$_] = Storable::dclone(\%tmp_hash);
}
}
undef %tmp_hash;
##Parse Flash Parameters
###disctete type should parse flash info sheet
if (($CUSTOM_MEM_DEV_OPTIONS{MEMORY_DEVICE_TYPE} !~ /\w+_\w+_MCP/) && (($MAKEFILE_OPTIONS{'serial_flash_support'} eq 'TRUE') || ($MAKEFILE_OPTIONS{'nand_support'} eq 'TRUE')))
{
###Parse Flash MDL info
my $flash_sheet = '';
if($MAKEFILE_OPTIONS{'serial_flash_support'} eq 'TRUE')#sheet "SERIAL_FLASH" in MDL
{
$flash_sheet = 'SERIAL_FLASH';
}
elsif($MAKEFILE_OPTIONS{'nand_support'} eq 'TRUE')
{
$flash_sheet = 'NAND_FLASH';
}
for (1..$CUSTOM_MEM_DEV_OPTIONS{COMBO_MEM_ENTRY_COUNT})
{
print "part number: $MCP_LIST[$_]->{0}, $MCP_LIST[$_]->{1}\n";
$result = &get_info($MEMORY_DEVICE_LIST_XLS, $flash_sheet, $MCP_LIST[$_], \%tmp_hash);
if ($result ne 'TRUE')
{
print "INTERNAL FIND part number: $MCP_LIST[$_]->{0}, $MCP_LIST[$_]->{1}\n";
$result = &get_info($MEMORY_DEVICE_LIST_INT_XLS, $flash_sheet, $MCP_LIST[$_], \%tmp_hash);
}
&error_handler("$CUSTOM_MEMORY_DEVICE_HDR: $flash_sheet Part Number $MCP_LIST[$_]->{1} not found!", __FILE__, __LINE__) if ($result ne 'TRUE');
$MDL_INFO_LIST[$_]->{1} = Storable::dclone($tmp_hash{1});
}
}
for (1..$CUSTOM_MEM_DEV_OPTIONS{COMBO_MEM_ENTRY_COUNT})
{
&dump_mdl_info($MDL_INFO_LIST[$_], "\$MDL_INFO_LIST[$_]->");
}
}
#****************************************************************************
# check emi clock driving config
#****************************************************************************
sub check_emi_clk_driving_cfg
{
my ($emi_clk_driving, $bb_chip) = @_;
if ($bb_chip eq 'MT6290')
{
if (($emi_clk_driving->{'DRAMC_ACTIM0_VAL'} !~ /0x[0-9a-fA-F]{8,8}/) || ($emi_clk_driving->{'DRAMC_DRVCTL0_VAL'} !~ /0x[0-9a-fA-F]{8,8}/) || ($emi_clk_driving->{'DRAMC_DRVCTL1_VAL'} !~ /0x[0-9a-fA-F]{8,8}/))
{
return 0;
}
}
elsif ($bb_chip eq 'MT6291')
{
if (($emi_clk_driving->{'DRAMC_ACTIM0_VAL'} !~ /0x[0-9a-fA-F]{8,8}/) || ($emi_clk_driving->{'DRAMC_IODRV8_VAL'} !~ /0x[0-9a-fA-F]{8,8}/) || ($emi_clk_driving->{'DRAMC_DRVCTL1_VAL'} !~ /0x[0-9a-fA-F]{8,8}/))
{
return 0;
}
}
return 1;
}
#****************************************************************************
# check consistency among FEATURE, MEMORY_DEVICE_TYPE, PLATFORM, MCU_CLOCK and MemoryDeviceList data
#****************************************************************************
sub Decide_MemClockSpeed
{
print("\n", (caller(0))[3], "\n");
my $emi_force_clk = 0;
my $sfi_force_clk = 0;
if ((defined $CUSTOM_MEM_DEV_OPTIONS{EMI_CLK}) and $CUSTOM_MEM_DEV_OPTIONS{EMI_CLK} ne 'DEFAULT')
{
$emi_clk_config = $emi_force_clk = $CUSTOM_MEM_DEV_OPTIONS{EMI_CLK};
}
if ((defined $CUSTOM_MEM_DEV_OPTIONS{SFI_CLK}) and $CUSTOM_MEM_DEV_OPTIONS{SFI_CLK}ne 'DEFAULT')
{
if ($CUSTOM_MEM_DEV_OPTIONS{SFI_CLK} eq '104M')
{
&error_handler("$CUSTOM_MEMORY_DEVICE_HDR: $MAKEFILE_OPTIONS{'platform'} does not support SFI clock as 104MHz! Please configure SFI_CLK as DEFAULT!", __FILE__, __LINE__) if ($BBtbl_SFI_FAST_CLK{$MAKEFILE_OPTIONS{'platform'}} != 104);
$sfi_clk_config = $sfi_force_clk = 104;
}
elsif ($CUSTOM_MEM_DEV_OPTIONS{SFI_CLK} eq '78M')
{
$sfi_clk_config = $sfi_force_clk = 78;
}
else
{
&error_handler("$CUSTOM_MEMORY_DEVICE_HDR: Please configure SFI_CLK as 104M, 78M, or DEFAULT!", __FILE__, __LINE__);
}
}
if($MAKEFILE_OPTIONS{'serial_flash_support'} eq 'TRUE')
{
my $sfi_104_support = 1; # assume all devices can support 104; set as 0 if found not support
my $sfi_78_support = 1; # assume all devices can support 78; set as 0 if found not support
#print "test $CUSTOM_MEM_DEV_OPTIONS{MEMORY_DEVICE_TYPE}\n";
### Check if all devices can support the required clock
if ($sfi_force_clk != 0) # force specific clock
{
for (1..$CUSTOM_MEM_DEV_OPTIONS{COMBO_MEM_ENTRY_COUNT})
{
if ((!defined &Lookup_SFI_setting_by_IDX_CLK_BB_REG($_, $sfi_clk_config, $MAKEFILE_OPTIONS{'platform'}, 'SF_CTL', \@MDL_INFO_LIST)) or (&Lookup_SFI_setting_by_IDX_CLK_BB_REG($_, $sfi_clk_config, $MAKEFILE_OPTIONS{'platform'}, 'DRIVING', \@MDL_INFO_LIST) eq 'x') or (&Lookup_SFI_setting_by_IDX_CLK_BB_REG($_, $sfi_clk_config, $MAKEFILE_OPTIONS{'platform'}, 'DRIVING', \@MDL_INFO_LIST) eq ' ')) # unable to find the specified clock setting
{
&error_handler("$CUSTOM_MEMORY_DEVICE_HDR: Device $_ not support $sfi_clk_config MHz settings!", __FILE__, __LINE__);
}
}
}
else
{
for (1..$CUSTOM_MEM_DEV_OPTIONS{COMBO_MEM_ENTRY_COUNT})
{
#if ((!defined &Lookup_SFI_setting_by_IDX_CLK_BB_REG($_, 104, $MAKEFILE_OPTIONS{'platform'}, 'SF_CTL', \@MDL_INFO_LIST)) or (&Lookup_SFI_setting_by_IDX_CLK_BB_REG($_, 104, $MAKEFILE_OPTIONS{'platform'}, 'SFI_MAC_CTL', \@MDL_INFO_LIST) eq 'x') or (&Lookup_SFI_setting_by_IDX_CLK_BB_REG($_, 104, $MAKEFILE_OPTIONS{'platform'}, 'SFI_MAC_CTL', \@MDL_INFO_LIST) eq ' ')) # unable to find 104MHz clock setting
if (!defined &Lookup_SFI_setting_by_IDX_CLK_BB_REG($_, 104, $MAKEFILE_OPTIONS{'platform'}, 'SF_CTL', \@MDL_INFO_LIST))
{
$sfi_104_support = 0;
}
#if ((!defined &Lookup_SFI_setting_by_IDX_CLK_BB_REG($_, 78, $MAKEFILE_OPTIONS{'platform'}, 'SF_CTL', \@MDL_INFO_LIST)) or (&Lookup_SFI_setting_by_IDX_CLK_BB_REG($_, 78, $MAKEFILE_OPTIONS{'platform'}, 'SFI_MAC_CTL', \@MDL_INFO_LIST) eq 'x') or (&Lookup_SFI_setting_by_IDX_CLK_BB_REG($_, 78, $MAKEFILE_OPTIONS{'platform'}, 'SFI_MAC_CTL', \@MDL_INFO_LIST) eq ' ')) # unable to find 104MHz clock setting
if (!defined &Lookup_SFI_setting_by_IDX_CLK_BB_REG($_, 78, $MAKEFILE_OPTIONS{'platform'}, 'SF_CTL', \@MDL_INFO_LIST))
{
$sfi_78_support = 0;
}
if (($sfi_104_support == 0) and ($sfi_78_support == 0))
{
&error_handler("$CUSTOM_MEMORY_DEVICE_HDR: Unable to find valid SFI settings!", __FILE__, __LINE__);
}
elsif ($sfi_104_support != 0)
{
$sfi_clk_config = 104;
}
else # sfi_104_support == 0 and sfi_78_support != 0
{
$sfi_clk_config = 78;
}
}
}
print "SFI_CLK configured as $sfi_clk_config\n" if ($DebugPrint == 1);
}
if (($emi_is_existed == 1) and ($MAKEFILE_OPTIONS{'platform'} eq 'MT6291')) {
### Check if all devices can support the required clock
if ($emi_force_clk != 0) # force specific clock
{
for (1..$CUSTOM_MEM_DEV_OPTIONS{COMBO_MEM_ENTRY_COUNT})
{
my $mhz_emi_driving = $emi_clk_config . 'MHZ EMI Driving';
my $emi_clk_driving = $MDL_INFO_LIST[$_]->{0}->{$MAKEFILE_OPTIONS{'platform'}}->{$mhz_emi_driving};
if (&check_emi_clk_driving_cfg($emi_clk_driving, $MAKEFILE_OPTIONS{'platform'}) == 0)
{
&error_handler("$CUSTOM_MEMORY_DEVICE_HDR: Device $_ not support $emi_clk_config MHz settings!", __FILE__, __LINE__);
}
}
}
else
{
my %emi_clk;
for (1..$CUSTOM_MEM_DEV_OPTIONS{COMBO_MEM_ENTRY_COUNT})
{
my $mdl_info_platform = $MDL_INFO_LIST[$_]->{0}->{$MAKEFILE_OPTIONS{'platform'}};
foreach my $mdl_info_content (sort keys %{$mdl_info_platform})
{
if ($mdl_info_content =~ /(\d+)MHZ EMI Driving/)
{
if (!defined $emi_clk{$1})
{
$emi_clk{$1} = 'TRUE';
}
my $emi_clk_driving = $mdl_info_platform->{$mdl_info_content};
if (&check_emi_clk_driving_cfg($emi_clk_driving, $MAKEFILE_OPTIONS{'platform'}) == 0)
{
$emi_clk{$1} = 'FALSE';
}
}
}
}
undef $emi_clk_config;
while( (my $clk_speed, my $value) = each %emi_clk)
{
if ($value eq 'TRUE')
{
next if ((defined $emi_clk_config) && ($emi_clk_config >= $clk_speed));
$emi_clk_config = $clk_speed;
}
}
if (!defined $emi_clk_config) {
&error_handler("$CUSTOM_MEMORY_DEVICE_HDR: Device $_ not support $emi_clk_config MHz settings!", __FILE__, __LINE__);
}
}
print "EMI_CLK configured as $emi_clk_config\n" if ($DebugPrint == 1);
}
}
#****************************************************************************
# subroutine: dump_mdl_info
# return: none
# input: $mdl_ref: MDL hash reference
# $pre_string: to print prefix string
#****************************************************************************
sub dump_mdl_info
{
my ($mdl_ref, $pre_string) = @_;
my $prefix_string;
foreach my $key (keys %{$mdl_ref})
{
$prefix_string = $pre_string if (defined $pre_string);
$prefix_string = $prefix_string . "{$key}";
if (ref $mdl_ref->{$key} eq 'HASH')
{
&dump_mdl_info($mdl_ref->{$key}, "$prefix_string->");
}
else
{
print "$prefix_string = " . $mdl_ref->{$key} . "\n";
}
}
}
#****************************************************************************
# subroutine: fs_read_excel
# return: hash of matching rows and indexing rows
# input: $file: excel file to be read
# $sheet: sheet to open
# $target_href: the target patterns to be searched
#****************************************************************************
sub fs_read_excel
{
my ($file, $sheet, $target_href, $BACKUP_MDL_PATH) = @_;
my %mdl_list;
my $copied_file;
my $curr_time_str = &get_CurrTime_str();
my $WorkSheet;
my $Excel;
my $Book;
my $parser;
my $workbook;
my ($row_min, $row_max);
my ($col_min, $col_max);
if (! -e $file) {
return %mdl_list;
}
### copy and rename the current excel file to prevent concurrency build problem
# remove ^.\ or ^\
$BACKUP_MDL_PATH =~ s/^.\\|^\\//;
if($BACKUP_MDL_PATH =~ /out/)
{
print "BAKCUP_MDL_PATH match with /build/ PREMATCH:$`, MATCH:$&, POSTMATCH:$'\n";
$BACKUP_MDL_PATH = $& . $';
}
print "file is $file\n";
if($file =~ /^(\w+.*?)\.xls$/)
{
if($1 =~ /^(\w*.*?)tools(\w*.*?)MemoryDeviceList_(\w+)$/)
{
print "1:$1,2:$2,3:$3\n";
$copied_file = $1 . $BACKUP_MDL_PATH . "\/". "MemoryDeviceList_" . $3;
}
}
$copied_file = $copied_file . "_" . $sheet . "_" . $curr_time_str . $$ . ".xls";
File::Copy::copy($file, $copied_file);
$file = $copied_file;
$parser = Spreadsheet::ParseExcel->new();
$workbook = $parser->parse($file) or &error_handler("$file: $!", __FILE__, __LINE__);;
$WorkSheet = $workbook->worksheet($sheet);
($row_min, $row_max) = $WorkSheet->row_range();
($col_min, $col_max) = $WorkSheet->col_range();
# get the sheet name
my $name = $WorkSheet->get_name();
print "sheetname: $name, row: {$row_min, $row_max}, col: {$col_min, $col_max}\n";
my $xls_content_row_start;
my $xls_content_num;
for my $col ($col_min..$col_max)
{
my @mdl_each_col_content = undef;
my $array_content_row_start = undef;
foreach my $row ($row_min..$row_max)
{
if (($col == 0) && (!defined $WorkSheet->get_cell($row, $col)->is_merged()) && (!defined $xls_content_row_start))
{
$xls_content_row_start = $row;
$xls_content_num = $row_max - $xls_content_row_start + 1;
}
if (((defined $xls_content_row_start) && ($row >= $xls_content_row_start)) || (!defined $mdl_each_col_content[-1]) || ($mdl_each_col_content[-1] ne &xls_cell_value($WorkSheet, $row, $col)))
{
push(@mdl_each_col_content, &xls_cell_value($WorkSheet, $row, $col));
}
if ((defined $xls_content_row_start) && ($row == $xls_content_row_start))
{
$array_content_row_start = $#mdl_each_col_content;
}
}
my @hash_tail_array;
my $hash_pointer;
for (1..$xls_content_num)
{
push(@hash_tail_array, \%{$mdl_list{$_}});
}
print "col" if ($DebugPrint == 1);
foreach my $idx (1..$array_content_row_start-1)
{
my $data = $mdl_each_col_content[$idx];
print "{$data}" if ($DebugPrint == 1);
for my $content_idx (1..$xls_content_num)
{
$hash_pointer = shift(@hash_tail_array);
if ($idx != $array_content_row_start-1)
{
print "->" if ($content_idx == 1) && ($DebugPrint == 1);
if (!defined $hash_pointer->{$data})
{
$hash_pointer->{$data} = {};
}
$hash_pointer = $hash_pointer->{$data};
#print "[$idx][$content_idx]hash_pointer:$hash_pointer\n";
}
push(@hash_tail_array, $hash_pointer);
}
}
print "=" if ($DebugPrint == 1);
foreach my $idx ($array_content_row_start..$#mdl_each_col_content)
{
my $mdl_idx = $idx - $array_content_row_start + 1;
my $data = $mdl_each_col_content[$idx];
$hash_pointer = shift(@hash_tail_array);
$hash_pointer->{$mdl_each_col_content[$array_content_row_start-1]} = $data;
print "$mdl_idx:$data" if ($DebugPrint == 1);
if ($idx != $#mdl_each_col_content)
{
print ", " if ($DebugPrint == 1);
}
}
print "\n" if ($DebugPrint == 1);
}
return %mdl_list;
}
#****************************************************************************
# subroutine: get_info
# input: $file: file path
# $sheet: sheet to open
# $target_href: the target patterns to be searched
# $href: output matching hash reference
#****************************************************************************
sub get_info
{
my ($file, $sheet, $target_href, $href) = @_;
my %mdl_list;
%mdl_list = &fs_read_excel($file, $sheet, $target_href, $LOAD_TMP_PATH);
if (keys(%mdl_list) == 0)
{
print "get_info return FALSE!\n" if ($DebugPrint == 1);
return "FALSE";
}
foreach my $idx (keys %mdl_list)
{
if ($sheet =~ /\w+_\w+_MCP/)
{
if ($target_href->{0} eq $mdl_list{$idx}->{'Part Number'})
{
$href->{0} = $mdl_list{$idx}->{'DRAM Parameters'};
$href->{1} = $mdl_list{$idx}->{'Flash Parameters'};
for my $keys (keys %{$mdl_list{$idx}})
{
if (($keys ne 'DRAM Parameters') && ($keys ne 'Flash Parameters'))
{
for (0..1)
{
$href->{$_}->{$keys} = $mdl_list{$idx}->{$keys};
}
}
}
}
}
else
{
my $tgt = 0;
$tgt = $tgt + 1 if ($sheet =~ /\w+_FLASH/);
if ($target_href->{$tgt} eq $mdl_list{$idx}->{'Part Number'})
{
$href->{$tgt} = $mdl_list{$idx};
}
}
}
&dump_mdl_info($href, "\$href->") if ($DebugPrint == 1);
if (keys(%{$href}) == 0)
{
return "FALSE";
}
return "TRUE";
}
#****************************************************************************
# subroutine: xls_cell_value
# return: excel cell value no matter it's in merge area or not
# input: $sheet: specified Excel Sheet
# $row: specified row number
# $col: specified column number
#****************************************************************************
sub xls_cell_value
{
my ($sheet, $row, $col) = @_;
my $cell = $sheet->get_cell($row, $col);
if ($cell)
{
if ((defined $cell->is_merged()) && ($cell->is_merged() == 1))
{
my $mareas =$sheet->get_merged_areas();
# get merged areas' value if cell is merged
for (0..$#$mareas)
{
if(($row >= $mareas->[$_]->[0] && $row <= $mareas->[$_]->[2]) && ($col >= $mareas->[$_]->[1] && $col <= $mareas->[$_]->[3]))
{
return $sheet->get_cell($mareas->[$_]->[0], $mareas->[$_]->[1])->value();
}
}
} else {
# cell is not merged cell => get cell value
return $cell->value();
}
} else {
my $value;
return $value;
}
}
#****************************************************************************
# subroutine: dependency check
# return: None
#****************************************************************************
sub Check_ManualCheckIn
{
my ($target, $force_del_new_file, @depends) = @_;
return unless (-e $target);
## Now check if the $target file check-in or auto-gen
## Read whole file ##
open SRC_FILE_R, "<$target" or &error_handler("$target: file error!", __FILE__, __LINE__);
local $/;
my $reading = <SRC_FILE_R>;
close SRC_FILE_R;
## Look for check-in pattern ##
if ($reading =~ /MANUAL-CHECKIN/i)
{
print "$target: Check-in message is found. No need to update.\n";
return;
}
unlink $target if (-e $target);
return;
}
#****************************************************************************
# subroutine: CheckConfigValid
# return: None
#****************************************************************************
sub CheckConfigValid
{
print("\n", (caller(0))[3], "\n");
my $dram_size = eval($MDL_INFO_LIST[1]->{0}->{'Density (Mb)'});
###Check DRAM Size
for (1..$CUSTOM_MEM_DEV_OPTIONS{COMBO_MEM_ENTRY_COUNT})
{
if ($emi_is_existed == 1)
{
&error_handler("$CUSTOM_MEMORY_DEVICE_HDR: Please select correct dram! dram_size is $dram_size.", __FILE__, __LINE__) if ((!defined $dram_size) || ($dram_size <= 0));
&error_handler("$CUSTOM_MEMORY_DEVICE_HDR: Please select dram with the same size ($dram_size vs. $MDL_INFO_LIST[$_]->{0}->{'Density (Mb)'}) when COMBO_MEMORY_SUPPORT is enabled!", __FILE__, __LINE__) if ($dram_size ne eval($MDL_INFO_LIST[$_]->{0}->{'Density (Mb)'}));
}
}
###Check Combo Memory Supporting
if($MAKEFILE_OPTIONS{'combo_memory_support'} eq 'TRUE')
{
my @combo_mem_part_number;
&error_handler("$CUSTOM_MEMORY_DEVICE_HDR: MEMORY_DEVICE_TYPE supports only XXX_MCP when COMBO_MEMORY_SUPPORT is enabled!", __FILE__, __LINE__) if ((($CUSTOM_MEM_DEV_OPTIONS{MEMORY_DEVICE_TYPE} !~ /\w+_MCP/) && ($CUSTOM_MEM_DEV_OPTIONS{MEMORY_DEVICE_TYPE} ne 'NONE')) && ($MAKEFILE_OPTIONS{'sip_ram_size'} eq "NONE"));
for (1..$CUSTOM_MEM_DEV_OPTIONS{COMBO_MEM_ENTRY_COUNT})
{
&error_handler("$CUSTOM_MEMORY_DEVICE_HDR: COMBO MEM Part Number ($MCP_LIST[$_]->{0}) of DRAM should be the same that ($MCP_LIST[$_]->{1}) of Flash!", __FILE__, __LINE__) if (($MCP_LIST[$_]->{0} ne $MCP_LIST[$_]->{1}) && ($MAKEFILE_OPTIONS{'sip_ram_size'} eq "NONE"));
for my $combo_mem_idx (0..$#combo_mem_part_number)
{
&error_handler("$CUSTOM_MEMORY_DEVICE_HDR: Each COMBO MEM Part Number should be difference ($combo_mem_part_number[$combo_mem_idx]:COMBO_MEM0$combo_mem_idx and COMBO_MEM0$_)!", __FILE__, __LINE__) if ($MCP_LIST[$_]->{1} eq $combo_mem_part_number[$combo_mem_idx]);
}
push(@combo_mem_part_number, $MCP_LIST[$_]->{1});
}
}
###Combo Flash Size Should be same
if($MAKEFILE_OPTIONS{'combo_memory_support'} eq 'TRUE')
{
if($MAKEFILE_OPTIONS{'serial_flash_support'} eq 'TRUE')
{
for (1..$CUSTOM_MEM_DEV_OPTIONS{COMBO_MEM_ENTRY_COUNT})
{
my $cur_nor_size_Mb;
$cur_nor_size_Mb = $MDL_INFO_LIST[$_]->{1}->{'Size (Mb)'};
if (!defined $nor_size_Mb)
{
$nor_size_Mb = $cur_nor_size_Mb;
}
else
{
&error_handler("$CUSTOM_MEMORY_DEVICE_HDR: Please select flash with the same size when COMBO_MEMORY_SUPPORT is enabled!", __FILE__, __LINE__) if ($nor_size_Mb != $cur_nor_size_Mb);
}
}
}
elsif($MAKEFILE_OPTIONS{'nand_support'} eq 'TRUE')
{
my $nand_size_Mb;
my $nand_block_size;
for (1..$CUSTOM_MEM_DEV_OPTIONS{COMBO_MEM_ENTRY_COUNT})
{
my $cur_nand_size_Mb;
my $cur_nand_block_size;
$cur_nand_size_Mb = $MDL_INFO_LIST[$_]->{1}->{'NAND Size(MB)'};
$cur_nand_block_size = $MDL_INFO_LIST[$_]->{1}->{'NAND Block Size(KB)'};
if (!defined $nand_size_Mb)
{
$nand_size_Mb = $cur_nand_size_Mb;
$nand_block_size = $cur_nand_block_size;
}
else
{
&error_handler("$CUSTOM_MEMORY_DEVICE_HDR: Please select flash with the same size when COMBO_MEMORY_SUPPORT is enabled!", __FILE__, __LINE__) if ($nand_size_Mb != $cur_nand_size_Mb);
&error_handler("$CUSTOM_MEMORY_DEVICE_HDR: Please select flash with the same block size when COMBO_MEMORY_SUPPORT is enabled!", __FILE__, __LINE__) if ($nand_block_size != $cur_nand_block_size);
}
}
}
}
###Serail Flash Support and NAND Support Should Not be TRUE at the same time
if(($MAKEFILE_OPTIONS{'serial_flash_support'} eq 'TRUE') and ($MAKEFILE_OPTIONS{'nand_support'} eq 'TRUE'))
{
&error_handler("Serial Flash and NAND Flash Support at the same time, please check makefile setting!!", __FILE__, __LINE__);
}
###The Flash Name max length is 64
if($MAKEFILE_OPTIONS{'nand_support'} eq 'TRUE')
{
for (1..$CUSTOM_MEM_DEV_OPTIONS{COMBO_MEM_ENTRY_COUNT})
{
my $vendor = uc($MDL_INFO_LIST[$_]->{1}->{'Vendor'});
my $PartNumber = $MDL_INFO_LIST[$_]->{1}->{'Part Number'};
my $flash_name .= "$vendor " if (defined $vendor);
$flash_name .= "$PartNumber" if (defined $PartNumber);
my $name_length = length($flash_name);
if($name_length > 64)
{
&error_handler("Flash Name is too long, DA Support Max Length is 64 byte!!", __FILE__, __LINE__);
}
}
}
return;
}
#****************************************************************************
# subroutine: error_handler
# input: $error_msg: error message
#****************************************************************************
sub error_handler
{
my ($error_msg, $file, $line_no) = @_;
my $final_error_msg = "EMIGEN ERROR: $error_msg at $file line $line_no\n";
print $final_error_msg;
die $final_error_msg;
}
#****************************************************************************
# subroutine: copyright_file_header
# return: file header -- copyright
#****************************************************************************
sub copyright_file_header
{
my $template = <<"__TEMPLATE";
/*****************************************************************************
* Copyright Statement:
* --------------------
* This software is protected by Copyright and the information contained
* herein is confidential. The software may not be copied and the information
* contained herein may not be used or disclosed except with the written
* permission of MediaTek Inc. (C) 2019
*
* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
*
* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
*
* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
*
*****************************************************************************/
__TEMPLATE
return $template;
}
#****************************************************************************
# subroutine: description_file_header
# return: file header -- description
# input: $filename: filename
# input: $description: one line description
# input: $author: optional
#****************************************************************************
sub description_file_header
{
my ($filename, $description, $author) = @_;
my $src_file = (-e $MEMORY_DEVICE_LIST_XLS)? $MEMORY_DEVICE_LIST_XLS:
(-e $MEMORY_DEVICE_LIST_INT_XLS)? $MEMORY_DEVICE_LIST_INT_XLS:
__FILE__;
my $datetime = POSIX::strftime("%Y/%m/%d_%H:%M:%S", localtime((stat $src_file)[9]));
my $template = <<"__TEMPLATE";
/*****************************************************************************
*
* Filename:
* ---------
* $filename
*
* Project:
* --------
* MOLY
*
* Description:
* ------------
* $description
*
* Author:
* -------
* $author by emigen $EMIGEN_VERNO
*
* Memory Device database last modified on $datetime
*
*============================================================================
* HISTORY
* Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*------------------------------------------------------------------------------
* \$Revision\$
* \$Modtime\$
* \$Log\$
*
*------------------------------------------------------------------------------
* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*============================================================================
****************************************************************************/
__TEMPLATE
return $template;
}
#******************************************************************************
# subroutine: get_CurrTime_str
# return: string of the current time
# input: None
#******************************************************************************
sub get_CurrTime_str
{
my($sec, $min, $hour, $mday, $mon, $year) = localtime(time);
return (sprintf "%04d_%02d_%02d_%02d_%02d_%02d", $year+1900, $mon+1, $mday, $hour, $min, $sec);
}
#****************************************************************************
# subroutine: SCHEME Configure Routines :: Query :: MD Information
#****************************************************************************
sub query_MD_INFO
{
my ($MAKEFILE_OPTIONS_LOCAL,$CUSTOM_MEM_DEV_OPTIONS_LOCAL,$COMM_MDL_INFO_LOCAL) = @_;
open write_file, ">", "MD_INFO.txt" or &error_handler("MD_INFO.txt: $!", __FILE__, __LINE__);
#if(($CUSTOM_MEM_DEV_OPTIONS{'MEMORY_DEVICE_TYPE'} = 'LPDDR') || ($CUSTOM_MEM_DEV_OPTIONS{'MEMORY_DEVICE_TYPE'} = 'LPDDR2') || ($CUSTOM_MEM_DEV_OPTIONS{'MEMORY_DEVICE_TYPE'} = 'LPSDRAM'))
#{
#if(defined $MAKEFILE_OPTIONS{'sip_ram_size'})
#{
#print write_file "Memory device type:$CUSTOM_MEM_DEV_OPTIONS{'MEMORY_DEVICE_TYPE'}";
#print write_file "size:$COMM_MDL_INFO{1}->{'Size (Mb)'}"
#}
#else
#{
#print write_file "Memory device type:$CUSTOM_MEM_DEV_OPTIONS{'MEMORY_DEVICE_TYPE'}";
#print write_file "size:$COMM_MDL_INFO{1}->{'Size (Mb)'}"
#}
#}
#else
#{
#if(defined $MAKEFILE_OPTIONS{'sip_ram_size'})
#{
#print write_file "Memory device type:$CUSTOM_MEM_DEV_OPTIONS{'MEMORY_DEVICE_TYPE'}";
#print write_file "size:$COMM_MDL_INFO{1}->{'Size (Mb)'}"
#}
#else
#{
#print write_file "Memory device type:$CUSTOM_MEM_DEV_OPTIONS{'MEMORY_DEVICE_TYPE'}";
#print write_file "size:$COMM_MDL_INFO{1}->{'Size (Mb)'}"
#}
#}
print write_file "Memory device type:$CUSTOM_MEM_DEV_OPTIONS{'MEMORY_DEVICE_TYPE'}\n";
print write_file "size:$COMM_MDL_INFO{1}->{'Size (Mb)'}\n";
close(write_file);
}
#****************************************************************************
# subroutine: Parse Custom Feature Configuration
#****************************************************************************
sub Parse_custom_FeatureConfig
{
print("\n", (caller(0))[3], "\n");
open CUSTOM_FEATURE_CONFIG_HDR, "<$CUSTOM_FEATURE_CONFIG_HDR" or &error_handler("$CUSTOM_FEATURE_CONFIG_HDR: $!", __FILE__, __LINE__);
while (<CUSTOM_FEATURE_CONFIG_HDR>)
{
# error-checking
if ((/^#if|^#ifdef|^#ifndef|^#elif|^#else/) && !(/^#ifndef\s+__CUSTOM_FEATURECONFIG_H__/))
{
&error_handler("$CUSTOM_FEATURE_CONFIG_HDR: Not allowed to set conditional keywords $_ in custom_FeatureConfig.h!", __FILE__, __LINE__);
}
if (/^#define\s+(\w+)\s+\(?([\w|\-]*)\)?/)
{
&error_handler("$CUSTOM_FEATURE_CONFIG_HDR: $1 redefined in custom_FeatureConfig.h!", __FILE__, __LINE__) if defined($CUSTOM_FEATURE_CFG_OPTIONS{$1});
$CUSTOM_FEATURE_CFG_OPTIONS{$1} = ((!defined $2) or ($2 eq ''))? 'TRUE': $2;
}
}
close CUSTOM_FEATURE_CONFIG_HDR;
}
return 1;