Subversion Repositories DevTools

Rev

Rev 5709 | Blame | Compare with Previous | Last modification | View Log | RSS feed

#! perl
########################################################################
# COPYRIGHT - VIX IP PTY LTD ("VIX"). ALL RIGHTS RESERVED.
#
# Module name   : jats.sh
# Module type   : Makefile system
# Compiler(s)   : n/a
# Environment(s): jats
#
# Description   : Dump MUG file information
#
#                 Primitive attempt to dump out the APMCFG and MASSAPMV files
#
#                 The APMCFG file works OK
#                 Th MASSAPMV needs to be processed (manually) with modcrc
#
#
# Usage:
#
# Version   Who      Date        Description
# 0.0.0.0   DDP      25-Jul-06   Initial Code
#
#......................................................................#

require 5.006_001;
use strict;
use warnings;
use Cwd;
use JatsError;


foreach my $file ( glob ('*@APMCFG*' ))
{
    Message("Processing $file" );
    open (DATA , "<", $file ) || Error ("Can't open $file" );
    binmode (DATA);

    my $data;
    read DATA, $data, 8;

    my ($systemVer, $numDevTypes) = unpack( 'H8 N', $data );

    print "SystemVer: $systemVer\n";
    print "numDevTypes: $numDevTypes\n";

    foreach my $dev ( 1 .. $numDevTypes )
    {
        my $device;
        read DATA, $device, 24;

        my ($devType, $Reserved, $Version, $Tier, $numMods, $deleteBitMap) =
            unpack( 'A9 A1 H8 H8 N H4', $device );
        print "Type; $devType, Version: $Version, Tier: $Tier, numMods: $numMods\n";

        foreach my $mnum ( 1 .. $numMods )
        {
            my $module;
            read DATA, $module, 20;
            my ($Tag, $mVersion, $Crc, $Size, $Type, $Special, $mReserved) =
                unpack ('A8 H4 H4 N H4', $module );

        print "     ($mnum) Tag: $Tag, Version: $mVersion, Size: $Size, Crc: $Crc, Type: $Type\n";

        #
        #   Sanity test
        #
        last if ( $mnum  > 1000 );
        }
    }
    close (DATA);
}


#
#   Process the MASSAPMV.CFG files
#   Note done yet: Note this a THX file with data embedded within that structure
#                  Its not a simple data structure.
#
#foreach my $file ( glob ('*MASSAPMV*' ))
foreach my $file ( glob ('bb.bin' ))
{
    Message("Processing $file" );
    open (DATA , "<", $file ) || Error ("Can't open $file" );
    binmode (DATA);

#    my $data;
#    read DATA, $data, 12;
#    my ($filename) =
#        unpack ('A12', $data );
#    print "Filename: $filename\n";
#
#    read DATA, $data, 20;
#    read DATA, $data, 8;
#
#
    my $data;

    #
    #   Skip the ModHeadData + Embedded data
    #   There is a variable length name string in here too
    #   Really need to process the ModHeadData properly
    #
    read DATA, $data, 16 * 4;             # Not too sure why

    read DATA, $data, 24;
    my ($devType, $Reserved, $Version, $Tier, $numMods, $deleteBitMap) =
        unpack( 'A9 A1 H8 H8 N H4', $data );
    print "Type; $devType, Version: $Version, Tier: $Tier, numMods: $numMods\n";

    $numMods = 1000;                    # Number of Modules is always zero.
    foreach my $mnum ( 1 .. $numMods )
    {

        #
        #   Documented but does not exist in the file
        #
#        read DATA, $data, 14;
#        my ( $isDownloaded, $cdFilename ) = unpack ('H2 A14', $data );
#        print "IsDnLoaded: $isDownloaded, cdFileName: $cdFilename\n";

        last if (read (DATA, $data, 20) != 20 );


#        my @hex = unpack ( 'H2' x 20, $data );
#        print "\n-- @hex\n";
        my ($Tag, $mVersion, $Crc, $Size, $Type, $Special, $mReserved) =
            unpack ('A8 H4 H4 N H4', $data );

    print "     ($mnum) Tag: $Tag, Version: $mVersion, Size: $Size, Crc: $Crc, Type: $Type\n";

    #
    #   Sanity test
    #
    last if ( $mnum  > 1000 );
    }

    close (DATA);
}