This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

DSPLINK Error Code lookup

I have been using notifies to pass error codes back from the DSP to the ARM and have generated a script that turns the error codes into switch statement entries so they can be printed to the screen! I find it useful and thought someone else out there might do also. In total I get 105 error codes, some of these are reserved, also some of the reserved codes are ignored. If anyone finds any missing codes please let me know. For reference I am using a OMAP 3530.

An example of the statements are shown below,

case DSP_SOK : printf("DSP_SOK : Generic success code ");break;
case DSP_SALREADYATTACHED : printf("DSP_SALREADYATTACHED : GPP is already attached to this DSP processor ");break;
case DSP_SENUMCOMPLETE : printf("DSP_SENUMCOMPLETE : This is the last object available for enumeration. ");break;

Execute as,

parseTiErrHeader.pl -h <addpath here>/dsplink/gpp/inc/usr/errbase.h

The script Code

#!/usr/bin/perl
##
use FindBin qw($Bin $RealBin);# get the path info
use lib "$Bin/modules"; # set the module directory
use Getopt::Long; # get the parser

## set defaults
my %hash;

$hash{SETUP}{HEADER}      = "";
$hash{SETUP}{SEARCH}      = 0;
$hash{SETUP}{GOTSTART}    = 0;
$hash{SETUP}{GOTEND}      = 0;
$hash{SETUP}{COMMENT}     = 0;
$hash{SETUP}{STARTSTRING} = "SUCCESS codes: Generic";

my $ptr = $hash{SETUP}; # all this does is create a local pointer
                        # to the hash, make things a bit more readable
                        # make sure the hash is initialised before you
                        # use this as it causes the hash pointer to go
                        # nuts if you use it before here!

##------------------------------------------------------------------------------
## process options
GetOptions(
"-header=s" =>\$ptr->{HEADER},
);
if ($ptr->{HEADER} eq ""){
    print("Error you need to supply a header file as an argument -header err.h\n");
    exit;
}

open (my $fptr, "$ptr->{HEADER}") or die "open_file---Cannot open $ptr->{HEADER}\n";
while(<$fptr>){
    # Assumptions for search:
    # 1: We look for comments single or multi line, store and if the next line is a define
    #    we print.
    # 2: We start looking when we see the string "SUCCESS codes: Generic", this gets us past
    #    all the initial defines that specify the base codes.

    if ($ptr->{SEARCH}){ # we can start looking, we are past the base defs
       
        if($ptr->{GOTEND}){ # we just got an end! is this line a #define?
            if(/\#define\s+(\S+)\s+/){
                if($1 !~ /_EBASE/){ # ignore the define if its a new base def!
                    print("case $1 : printf(\"$1 :");
                    $ptr->{COMMENT} =~ s/(?:\n|\*|\/|\")//g ; # remove comments and new lines!
                    $ptr->{COMMENT} =~ s/\s+/ /g ; # remove multi spaces!
                    print("$ptr->{COMMENT}\"\);break;\n");
                }
            }
            $ptr->{GOTSTART} = 0;# reset variables
            $ptr->{GOTEND} = 0;
            $ptr->{COMMENT}= "";
        }else{
            if($ptr->{GOTSTART}){ # we have a multiline comment
                $ptr->{COMMENT}= $ptr->{COMMENT}.$_;
                $ptr->{GOTEND} = 1 if(/\*\//);
            }else{
                if(/\/\*/){ # we found a comment
                    $ptr->{COMMENT}= $_;
                    $ptr->{GOTSTART}=1;
                    $ptr->{GOTEND} = 1 if(/\*\//);
                }else{
                    # ignore, this should be whitespace!
                }
            }
        }
    }else{
        $ptr->{SEARCH} = 1 if(/$ptr->{STARTSTRING}/);
    }
}
close($fptr);