diff options
author | blogic <blogic@3c298f89-4303-0410-b956-a3cf2f4a3e73> | 2007-06-02 00:46:02 +0000 |
---|---|---|
committer | blogic <blogic@3c298f89-4303-0410-b956-a3cf2f4a3e73> | 2007-06-02 00:46:02 +0000 |
commit | 9b11307b07431bac96f8c8e4367a3747942d5751 (patch) | |
tree | d4161d76c676ff352e44294ba8819194d66356c4 /target/linux/etrax-2.6/image/e100boot/src/sbl/cconv | |
parent | 5bae61fcd1f9040dcc145d8d122e55430d29da12 (diff) |
add initial support for the crisarchitecture used on foxboards to openwrt
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@7439 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux/etrax-2.6/image/e100boot/src/sbl/cconv')
-rwxr-xr-x | target/linux/etrax-2.6/image/e100boot/src/sbl/cconv | 158 |
1 files changed, 158 insertions, 0 deletions
diff --git a/target/linux/etrax-2.6/image/e100boot/src/sbl/cconv b/target/linux/etrax-2.6/image/e100boot/src/sbl/cconv new file mode 100755 index 0000000000..ce5ab3d705 --- /dev/null +++ b/target/linux/etrax-2.6/image/e100boot/src/sbl/cconv @@ -0,0 +1,158 @@ +#!/usr/bin/perl +#! +#! FILE NAME : cconv +#! +#! PARAMETERS : Name of C program array variable. +#! +#! DESCRIPTION: Converts bytes of a binary file to C source code containing +#! char array initialized with the binary file data. +#! +#! SUBROUTINES: +#! +#!--------------------------------------------------------------------------- +#! HISTORY +#! +#! DATE NAME CHANGES +#! ---- ---- ------- +#! Dec 15 1997 Sven Ekstrom Initial version. Rewritten to Perl from C. +#! Dec 16 1997 Sven Ekstrom Fixed bug that generated truncated result. +#! +#!--------------------------------------------------------------------------- +#! +#! (C) Copyright 1997, Axis Communications AB, LUND, SWEDEN +#! +#!*************************************************************************** +# @(#) cconv 1.2 12/16/97 + +#********************** CONSTANT SECTION ************************************ + +$MyName = 'cconv'; + +# +# Number of bytes per line in the result. +# +$LineLength = 8; + +#********************** MAIN PROGRAM SECTION ******************************** + +# +# Make sure the command line contains the name of a C array. +# +if (scalar @ARGV != 1 || $ARGV[0] =~ /^-/) +{ + die "$MyName: Usage:\n", + "\n", + " Syntax\n", + " $MyName <name of C char array>\n", + "\n", + " <name of C char array> : This is the name of the char array where\n", + " the result is placed.\n", + "\n", + " Description\n", + "\n", + " Reads input from STDIN as binary data. Each byte of input data is\n", + " converted to C char data in hexadecimal form. The whole file read\n", + " from STDIN is converted and the result, C source code definition of\n", + " a char array, is printed on STDOUT.\n", + "\n"; +} + +# +# Start with the name and version of this program and the name of the array. +# +print "\n", + "/* $MyName 1.2 12/16/97, Copyright (C) 1997, Axis Communications AB */\n", + "\n", + "const char $ARGV[0]\[\] =\n", + "{"; + +# +# Read all bytes from STDIN, convert them to char data and print them on +# STDOUT. +# +$CurrentOffset = 0; +while (!eof(STDIN)) +{ + $Byte = ord(getc); + + if ($CurrentOffset % $LineLength == 0) + { + # + # Start of a new line. + # + if ($CurrentOffset != 0) + { + # + # This is not the first byte. + # + print ","; + } + # + # The new line is indented by 2 spaces. + # + print "\n", + " "; + } + else + { + # + # Continuing an old line. + # + print ", "; + } + + # + # Print the value of the byte as hex char data. + # + printf("'\\x%02x'", $Byte); + + $CurrentOffset++; +} + +if ($CurrentOffset == 0) +{ + # + # Initialize the array with a single byte of zero. + # + print "\n '\\x00'"; +} + +# +# End with the closing bracket and semicolon. +# +print "\n", + "};\n"; + +exit 0; + + +#********************** SUBROUTINE DEFINITION SECTION *********************** + +#**************************************************************************** +#* +#* SUBROUTINE : +#* +#* PARAMETERS : +#* +#* RETURNS : +#* +#* SIDE EFFECTS: +#* +#* DESCRIPTION : +#* +#*--------------------------------------------------------------------------- +#* HISTORY +#* +#* DATE NAME CHANGES +#* ---- ---- ------- +#* May 05, 1995 Sven Ekstrom Initial version +#* +#**************************************************************************** + +#sub NN +#{ +# local() = @_; +# +#} + +#************************ END OF FILE cconv ********************************* |