Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


(no commit message)
[palacios.git] / palacios / scripts / mkuprog
1 #! /usr/bin/perl
2
3 # From a binary image containing a user program, generate
4 # C code initializing a User_Program struct.
5
6 # $Revision: 1.1.1.1 $
7
8 use strict qw(refs vars);
9 use FileHandle;
10
11 if ( scalar(@ARGV) != 3 ) {
12     print STDERR "usage: mkuprog <filename> <progname> <entry addr>\n";
13     exit 1;
14 }
15
16 my $filename = shift @ARGV;
17 my $progname = shift @ARGV;
18 my $entryAddr = shift @ARGV;
19
20 my $fh = new FileHandle("<$filename");
21 (defined $fh) || die "Couldn't open $filename: $!\n";
22 binmode $fh;
23
24 my $dataArrayName = $progname . "Data";
25 my $structName = $progname . "Prog";
26 print "const unsigned char $dataArrayName"."[] = {\n";
27
28 my $LINEWIDTH = 10;
29
30 my $buf = chr(0) x $LINEWIDTH;
31 my $n;
32 my $size = 0;
33 while ( ($n = read( $fh, $buf, $LINEWIDTH )) > 0 ) {
34     $size += $n;
35     my $i;
36     print "    ";
37     for ( $i = 0; $i < $n; $i++ ) {
38         my $c = ord( substr($buf, $i, 1) );
39         printf( "0x%x,", $c );
40     }
41     print "\n";
42 }
43
44 print "};\n";
45
46 $fh->close();
47
48 print << "END";
49 const struct User_Program $structName = {
50     "$progname",
51     $size,
52     $entryAddr,
53     $dataArrayName
54 };
55 END