source: rtems/tools/cpu/sh/shgen.c @ d751cec

4.115
Last change on this file since d751cec was d751cec, checked in by Joel Sherrill <joel.sherrill@…>, on 05/17/11 at 20:39:40
  • tools/build/.cvsignore, tools/build/ChangeLog, tools/build/Makefile.am, tools/build/README, tools/build/binpatch.c, tools/build/cklength.c, tools/build/config.h.in, tools/build/configure.ac, tools/build/cvsignore-add.sh, tools/build/doxy-filter, tools/build/eolstrip.c, tools/build/install-if-change.in, tools/build/multigen, tools/build/packhex.c, tools/build/rtems-bin2c.c, tools/build/search-id.sh, tools/build/unhex.c, tools/cpu/.cvsignore, tools/cpu/ChangeLog, tools/cpu/Makefile.am, tools/cpu/configure.ac, tools/cpu/generic/.cvsignore, tools/cpu/generic/ChangeLog, tools/cpu/generic/Makefile.am, tools/cpu/generic/configure.ac, tools/cpu/generic/size_rtems.in, tools/cpu/nios2/.cvsignore, tools/cpu/nios2/ChangeLog, tools/cpu/nios2/Makefile.am, tools/cpu/nios2/README, tools/cpu/nios2/bridges.c, tools/cpu/nios2/bridges.h, tools/cpu/nios2/clocks.c, tools/cpu/nios2/clocks.h, tools/cpu/nios2/configure.ac, tools/cpu/nios2/devices.c, tools/cpu/nios2/devices.h, tools/cpu/nios2/linkcmds.c, tools/cpu/nios2/linkcmds.h, tools/cpu/nios2/memory.c, tools/cpu/nios2/memory.h, tools/cpu/nios2/nios2gen.c, tools/cpu/nios2/output.c, tools/cpu/nios2/output.h, tools/cpu/nios2/ptf.c, tools/cpu/nios2/ptf.h, tools/cpu/nios2/sample.ptf, tools/cpu/sh/.cvsignore, tools/cpu/sh/AUTHORS, tools/cpu/sh/COPYING, tools/cpu/sh/ChangeLog, tools/cpu/sh/Makefile.am, tools/cpu/sh/TODO, tools/cpu/sh/configure.ac, tools/cpu/sh/sci.c, tools/cpu/sh/sci.h, tools/cpu/sh/shgen.c: New files.
  • Property mode set to 100644
File size: 2.7 KB
Line 
1/*
2 * Copyright (c) 1998,1999,2000, 2006 Ralf Corsepius, Ulm Germany.
3 *
4 * See the file COPYING for copyright notice.
5 */
6
7#include <stdio.h>
8#include <string.h>     /* strcmp, strerror */
9#include <stdlib.h>     /* exit */
10#include <errno.h>
11#include <getopt.h>
12
13#include "sci.h"
14
15static void usage( FILE* ofile, char *prog )
16{
17  fprintf( ofile, "Usage: %s [options] driver\n", prog );
18  fprintf( ofile, "\nOptions:\n" );
19  fprintf( ofile, "Processor frequency (default 20MHz):\n") ;
20  fprintf( ofile, "\t-M Phi      .. processor frequency [MHz]\n" );
21  fprintf( ofile, "\t-K Phi      .. processor frequency [KHz]\n" );
22  fprintf( ofile, "\t-H Phi      .. processor frequency [Hz]\n" );
23  fprintf( ofile, "Driver:\n" );
24  fprintf( ofile, "\tsci         .. bitrate table for sci\n" );
25
26  fprintf( ofile, "\nWritten by Ralf Corsepius <corsepiu@faw.uni-ulm.de>\n" );
27  fprintf( ofile, "\nCopyright (c) 1998,1999,2000\tRalf Corsepius\n" );
28}
29
30#if HAVE_GETOPT_LONG
31#define NOARG   0
32#define HASARG  1
33#define OPTARG  2
34
35static struct option long_options[] =
36{
37  { "version",          NOARG,  NULL, 'v' },
38  { "help",             NOARG,  NULL, 'h' },
39  { "mega-hertz",       HASARG, NULL, 'M' },
40  { "kilo-hertz",       HASARG, NULL, 'K' },
41  { "hertz",            HASARG, NULL, 'H' },
42  { 0, 0, 0, 0 }
43};
44#endif
45
46static void shgen_header( FILE *file )
47{
48  fprintf( file,
49    "/*\n * DO NOT EDIT - this file is automatically generated by shgen %s\n",
50    VERSION );
51  fprintf( file,
52    " * Copyright (c) 1998,1999,2000 Ralf Corsepius (corsepiu@faw.uni-ulm.de)\n */\n" );
53  fprintf( file,
54    "\n/* This file is not copyrighted */\n\n" );
55}
56
57int main( int argc, char *argv[] )
58{
59  double        Phi = 20000000.0 ;
60
61#if HAVE_GETOPT_LONG
62  int option_index = 0 ;
63  while( ( optopt = getopt_long( argc, argv, "M:K:H:hv",
64      long_options, &option_index ) ) > 0 )
65#else
66  while ( ( optopt = getopt( argc, argv, "M:K:H:hv" ) ) > 0 )
67#endif
68  {
69    switch ( optopt )
70    {
71    case 'M' :
72      sscanf( optarg, "%lf", &Phi );
73      Phi = Phi * 1000000.0;
74      break ;
75    case 'K' :
76      sscanf( optarg, "%lf", &Phi );
77      Phi = Phi * 1000.0;
78      break ;
79    case 'H' :
80      sscanf( optarg, "%lf", &Phi );
81      break ;
82    case 'h' :
83      usage( stdout, argv[0] );
84      exit(0);
85    case 'v' :
86      fprintf( stdout, "%s version %s\n", argv[0], VERSION );
87      exit(0);
88    default  :
89      usage( stderr, argv[0] );
90      exit(1);
91      break ;
92    }
93  }
94
95  if ( argc - optind != 1 )
96  {
97    fprintf( stderr, "%s: Missing argument: driver\n", argv[0] );
98    exit(1);
99  }
100
101  shgen_header( stdout );
102
103  if ( strcmp( argv[optind], "sci" ) == 0 )
104  {
105    shgen_gensci( stdout, Phi );
106  }
107  else
108  {
109    fprintf( stderr, "%s: Invalid argument: driver\n", argv[0] );
110    exit(1);
111  }
112
113  return 0 ;
114}
Note: See TracBrowser for help on using the repository browser.