blob: 28096d55874d397972f8976fee064ea55035c9aa [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) 2012
#
# 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:
#* ---------
#* gencxifchksum.pl
#*
#* Project:
#* --------
#*
#*
#* Description:
#* ------------
#* This script is to generate verno.c/verno.h
#*
#* Author:
#* -------
#* Chi-Chun Lu (mtk09348)
#*
#*============================================================================
#* HISTORY
#* Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
#*------------------------------------------------------------------------------
#* $Revision$
#* $Modtime$
#* $Log$
#*
#* 08 27 2019 chi-chun.lu
#* [MOLY00428038] [MakeFile] [UMOLYE] [Modify Makefile Rules]cxif enhancement
#*
#* .
#*
#* 08 02 2019 chi-chun.lu
#* [MOLY00428038] [MakeFile] [UMOLYE] [Modify Makefile Rules]cxif enhancement
#* .
#*
#* 02 18 2019 gerry.liao
#* [MOLY00384186] [6297] CSIF checksum feature development
#* .
#*
#*------------------------------------------------------------------------------
#* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
#*============================================================================
#****************************************************************************/
#****************************************************************************
# Included Modules
#****************************************************************************
BEGIN { push @INC, './tools/CXIF/' }
use strict;
use CUIF_Structure_Check;
use CMIF_Structure_Check;
use CSIF_Structure_Check;
#****************************************************************************
# Input Parameters & Global Variables
#****************************************************************************
my $project_name = $ARGV[0];
my $flavor = $ARGV[1];
my $mtk_modem_arch = $ARGV[2];
my $gencxiffdr = $ARGV[3];
my $source_file = "cxifchksum.c";
my $header_file = "cxifchksum.h";
#****************************************************************************
# CXIF Variables Setting
#****************************************************************************
my $cxif_dir = "../common/interface/modem/$mtk_modem_arch";
my $cuif_inner_checksum = CUIF_Structure_Check::get_cuif_checksum_value(0, "$cxif_dir/CUIF");
my $cuif_brp_checksum = CUIF_Structure_Check::get_cuif_checksum_value(1, "$cxif_dir/CUIF");
my $cuif_fec_checksum = CUIF_Structure_Check::get_cuif_checksum_value(2, "$cxif_dir/CUIF");
my $cuif_speech_checksum = CUIF_Structure_Check::get_cuif_checksum_value(3, "$cxif_dir/CUIF");
my $cmif_checksum = CMIF_Structure_Check::get_cmif_checksum_value("$cxif_dir/CMIF");
#****************************************************************************
# CSIF Variables Setting
#****************************************************************************
my $csif_csif_checksum;
my $csif_slm_checksum;
my $csif_nl1fwk_checksum;
my $csif_ulsp_checksum;
my $csif_nl1tx_checksum;
if (($mtk_modem_arch ne "mt6293")&&($mtk_modem_arch ne "mt6295"))
{
my $check_result = CSIF_Structure_Check::xml_format_checker("$cxif_dir/CSIF/CSIF_chksum_list.xml");
if ($check_result == 1)
{
$csif_csif_checksum = CSIF_Structure_Check::get_csif_checksum_value(0, "$cxif_dir/CSIF", "$cxif_dir/CSIF/CSIF_chksum_list.xml");
$csif_slm_checksum = CSIF_Structure_Check::get_csif_checksum_value(1, "$cxif_dir/CSIF", "$cxif_dir/CSIF/CSIF_chksum_list.xml");
$csif_nl1fwk_checksum = CSIF_Structure_Check::get_csif_checksum_value(2, "$cxif_dir/CSIF", "$cxif_dir/CSIF/CSIF_chksum_list.xml");
$csif_ulsp_checksum = CSIF_Structure_Check::get_csif_checksum_value(3, "$cxif_dir/CSIF", "$cxif_dir/CSIF/CSIF_chksum_list.xml");
$csif_nl1tx_checksum = CSIF_Structure_Check::get_csif_checksum_value(4, "$cxif_dir/CSIF", "$cxif_dir/CSIF/CSIF_chksum_list.xml");
}
else
{
&error_handler("CSIF Structure Check Fail!", __FILE__, __LINE__);
}
}
#****************************************************************************
# subroutines
#****************************************************************************
#****************************************************************************
# Execute
#****************************************************************************
open (SRCFILE, ">$gencxiffdr/$source_file") or &error_handler("$gencxiffdr/$source_file : file error!", __FILE__, __LINE__);
if (($mtk_modem_arch ne "mt6293")&&($mtk_modem_arch ne "mt6295")){
print SRCFILE &gen_cxif_src_declare_97;
} else {
print SRCFILE &gen_cxif_src_declare;
}
print SRCFILE &gen_cxif_src_get_cuif_check_sum;
print SRCFILE &gen_cxif_src_get_cmif_check_sum;
print SRCFILE &gen_cxif_src_get_csif_check_sum if (($mtk_modem_arch ne "mt6293")&&($mtk_modem_arch ne "mt6295"));
close SRCFILE;
open (H_FILE, ">$gencxiffdr/$header_file") or &error_handler("$gencxiffdr/$header_file : file error!", __FILE__, __LINE__);
print H_FILE &gen_cxif_header_file;
close H_FILE;
#****************************************************************************
# subroutine: gencxif_cxif
#****************************************************************************
sub gencxif_cxif
{
return " v0.00 , initial version ";
}
#****************************************************************************
# subroutine: gen_cxif_header_file
#****************************************************************************
sub gen_cxif_header_file
{
my $template = <<"__TEMPLATE";
#define PROJECT_NAME_STR "$project_name"
#define PROJECT_FLAVOR_STR "$flavor"
__TEMPLATE
}
#****************************************************************************
# 1. subroutine: gen_cxif_src_declare
#****************************************************************************
sub gen_cxif_src_declare
{
my $template = <<"__TEMPLATE";
#include "kal_public_api.h"
#if defined(__MTK_TARGET__)
kal_uint32 CUIF_inner_checksum = $cuif_inner_checksum;
kal_uint32 CUIF_brp_checksum = $cuif_brp_checksum;
kal_uint32 CUIF_fec_checksum = $cuif_fec_checksum;
kal_uint32 CUIF_speech_checksum = $cuif_speech_checksum;
#endif
__TEMPLATE
}
#****************************************************************************
# 1. subroutine: gen_cxif_src_declare_97
#****************************************************************************
sub gen_cxif_src_declare_97
{
my $template = <<"__TEMPLATE";
#include "kal_public_api.h"
#if defined(__MTK_TARGET__)
kal_uint32 CUIF_inner_checksum = $cuif_inner_checksum;
kal_uint32 CUIF_brp_checksum = $cuif_brp_checksum;
kal_uint32 CUIF_fec_checksum = $cuif_fec_checksum;
kal_uint32 CUIF_speech_checksum = $cuif_speech_checksum;
kal_uint32 CSIF_csif_checksum = $csif_csif_checksum;
kal_uint32 CSIF_slm_checksum = $csif_slm_checksum;
kal_uint32 CSIF_nl1fwk_checksum = $csif_nl1fwk_checksum;
kal_uint32 CSIF_ulsp_checksum = $csif_ulsp_checksum;
kal_uint32 CSIF_nl1tx_checksum = $csif_nl1tx_checksum;
#endif
__TEMPLATE
}
#****************************************************************************
# 1. subroutine: gen_cxif_src_get_cuif_check_sum
#****************************************************************************
sub gen_cxif_src_get_cuif_check_sum
{
my $template = <<"__TEMPLATE";
kal_uint32 getCUIFStructureChecksum(int user) // 0: inner, 1:brp, 2:fec, 3:speech
{
#if defined(__MTK_TARGET__)
switch(user)
{
case 0:
return CUIF_inner_checksum;
case 1:
return CUIF_brp_checksum;
case 2:
return CUIF_fec_checksum;
case 3:
return CUIF_speech_checksum;
default: // incorrect user input
return 0;
}
#else
static kal_uint32 CUIF_inner_checksum = $cuif_inner_checksum;
static kal_uint32 CUIF_brp_checksum = $cuif_brp_checksum;
static kal_uint32 CUIF_fec_checksum = $cuif_fec_checksum;
static kal_uint32 CUIF_speech_checksum = $cuif_speech_checksum;
switch(user)
{
case 0:
return CUIF_inner_checksum;
case 1:
return CUIF_brp_checksum;
case 2:
return CUIF_fec_checksum;
case 3:
return CUIF_speech_checksum;
default: // incorrect user input
return 0;
}
#endif
}
__TEMPLATE
}
#****************************************************************************
# 2. subroutine: gen_cxif_src_get_cmif_check_sum
#****************************************************************************
sub gen_cxif_src_get_cmif_check_sum
{
my $template = <<"__TEMPLATE";
kal_uint32 getCMIFStructureChecksum(void)
{
static kal_uint32 CMIF_checksum = $cmif_checksum;
return CMIF_checksum;
}
__TEMPLATE
}
#****************************************************************************
# 3. subroutine: gen_cxif_src_get_csif_check_sum
#****************************************************************************
sub gen_cxif_src_get_csif_check_sum
{
my $template = <<"__TEMPLATE";
kal_uint32 getCSIFStructureChecksum(int user) // 0: csif, 1:slm, 2:nl1fwk, 3:ulsp, 4:nl1tx
{
#if defined(__MTK_TARGET__)
switch(user)
{
case 0:
return CSIF_csif_checksum;
case 1:
return CSIF_slm_checksum;
case 2:
return CSIF_nl1fwk_checksum;
case 3:
return CSIF_ulsp_checksum;
case 4:
return CSIF_nl1tx_checksum;
default: // incorrect user input
return 0;
}
#else
static kal_uint32 CSIF_csif_checksum = $csif_csif_checksum;
static kal_uint32 CSIF_slm_checksum = $csif_slm_checksum;
static kal_uint32 CSIF_nl1fwk_checksum = $csif_nl1fwk_checksum;
static kal_uint32 CSIF_ulsp_checksum = $csif_ulsp_checksum;
static kal_uint32 CSIF_nl1tx_checksum = $csif_nl1tx_checksum;
switch(user)
{
case 0:
return CSIF_csif_checksum;
case 1:
return CSIF_slm_checksum;
case 2:
return CSIF_nl1fwk_checksum;
case 3:
return CSIF_ulsp_checksum;
case 4:
return CSIF_nl1tx_checksum;
default: // incorrect user input
return 0;
}
#endif
}
__TEMPLATE
}
#****************************************************************************
# subroutine: error_handler
# input: $error_msg: error message
#****************************************************************************
sub error_handler
{
my ($error_msg, $file, $line_no) = @_;
my $final_error_msg = "GENCXIF CHECKSUM ERROR: $error_msg at $file line $line_no\n";
print $final_error_msg;
die $final_error_msg;
}