blob: 3ec1b105106cad166227f59a4f4e52c7186f493a [file] [log] [blame]
rjw6c1fd8f2022-11-30 14:33:01 +08001#!/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#* Filename:
38#* ---------
39#* scatFrame.pm
40#*
41#* Project:
42#* --------
43#*
44#*
45#* Description:
46#* ------------
47#* This script is to generate the frame of memory layout
48#* and provides the flow of generation
49#*
50#* Author:
51#* -------
52#* Qmei Yang (mtk03726)
53#*
54#****************************************************************************/
55#****************************************************************************
56# Included Modules
57#****************************************************************************
58use strict;
59BEGIN { push @INC, './pcore/tools/' } # add additional library path
60use sysGenUtility;
61use FileInfoParser;
62package scatFrame;
63#****************************************************************************
64# oo >>> Finished
65#****************************************************************************
66return 1;
67
68#****************************************************************************
69# scatFrame Version
70#****************************************************************************
71sub scatFrame_verno
72{
73 return " m0.01";
74 # m0.01 , 20120528 by mei, Support path and filename case sensitive on Linux
75 # v0.02 , 20120519 by mei, support Read BB folder first to get config input
76 # v0.01 , 20120513 by mei, initial version
77}
78#****************************************************************************
79# Constants
80#****************************************************************************
81#****************************************************************************
82# Global Variables
83#****************************************************************************
84#****************************************************************************
85# Input Parameters
86#****************************************************************************
87use constant InputSections => 0;
88#SCAT Type
89use constant MAIN => 0;
90use constant BL => 1;
91use constant EXT_BL => 2;
92use constant FOTA => 3;
93#****************************************************************************
94# subroutines
95#****************************************************************************
96#scatFrame::GetPath("ROM", scatFrame::InputSections)
97sub GetPath
98{
99 my ($strKey, $nType) = @_;
100 my $strPath = undef;
101 my $strMAINConfig = "scat_config/";
102 my %PathMap = ("InputSections" => "InputSections/",
103 );
104 if($nType == InputSections)
105 {
106 $strPath = $strMAINConfig . $PathMap{InputSections}.$strKey."/";
107 }
108 else
109 {
110 &scatFrame_die("[GetPath]Unsupport Type", __FILE__, __LINE__);
111 }
112 return $strPath;
113}
114
115sub GetConfigInput
116{
117 my ($RegionName, $strFileName, $nType, $bb_folder) = @_;
118 my $strFile = &GetPath($RegionName, $nType) . $strFileName;
119 my $strCustomFolder = $bb_folder . "/";
120 my $strDefaultFolder = "pcore/custom/system/Template/";
121 my $strInput = $strDefaultFolder . $strFile;
122 $strInput = $strCustomFolder.$strFile if(-e $strCustomFolder.$strFile);
123 return $strInput;
124}
125
126sub GenInputSections
127{
128 my ($InputSection_aref, $Indef_href) = @_;
129 my $strContent;
130 foreach my $item (@$InputSection_aref)
131 {
132 my $strModuleName = $item->[$Indef_href->{ModuleName}];
133 my $strAttribute = $item->[$Indef_href->{Attribute}];
134 $strModuleName =~ s/\s//g;
135 next if($strModuleName eq "");
136 my @AttrTemp = split(/\s+/, $strAttribute);
137 if($strModuleName =~ /.lib$|.a$/ and $strModuleName !~ /^\*|\;/)
138 {
139 $strModuleName = "*".$strModuleName;
140 }
141 my @Attr;
142 foreach my $strAttr (@AttrTemp)
143 {
144 if($strAttr =~ /^RO$|^RW$|^ZI$|^RO-CODE$|^RO-DATA$/)
145 {
146 $strAttr = "+".$strAttr;
147 }
148 push @Attr, $strAttr;
149 }
150 $strContent .= ' 'x8 . $strModuleName . " (". join(", ", @Attr) . ")\n";
151 }
152 return $strContent;
153}
154
155
156#****************************************************************************
157# subroutine: scatFrame_die
158# sample code: (message, __FILE__, __LINE__)
159# input: $error_msg, $file, $line_no
160#****************************************************************************
161sub scatFrame_die
162{
163 my ($error_msg, $file, $line_no) = (@_);
164 &sysUtil::error_handler($error_msg, $file, $line_no, 'scatFrame');
165}