source: rtems/tools/cpu/sh/shgen.c @ 0ab65474

4.104.114.84.95
Last change on this file since 0ab65474 was 0d523ca, checked in by Joel Sherrill <joel.sherrill@…>, on 11/17/99 at 15:36:57

Patch rtems-rc-19991105-2.diff from Ralf Corsepius <corsepiu@…>.
His comments follow:

This is a minor enhancement to shgen, which should not have any
side-effects.

  • Property mode set to 100644
File size: 1.7 KB
Line 
1/*
2 * Copyright (c) 1998-1999 Ralf Corsepius (corsepiu@faw.uni-ulm.de)
3 *
4 * See the file COPYING for copyright notice.
5 */
6
7#include <stdio.h>
8#include <string.h>     /* strcmp, strerror */
9#include <errno.h>
10#include <getopt.h>
11
12#include "sci.h"
13
14static void usage( char *prog )
15{
16  fprintf( stderr, "usage: %s [options] driver\n", prog );
17  fprintf( stderr, "options:\n" );
18  fprintf( stderr, "\t-M Phi      .. processor frequency [MHz]\n" );
19  fprintf( stderr, "\t-K Phi      .. processor frequency [KHz]\n" );
20  fprintf( stderr, "\t-H Phi      .. processor frequency [Hz]\n" );
21  fprintf( stderr, "\t\t..default 20MHz" );
22  fprintf( stderr, "driver:\n" );
23  fprintf( stderr, "\tsci .. bitrate table for sci\n" );
24  exit ( 1 );
25}
26
27static void shgen_header( FILE *file )
28{
29  fprintf( file,
30    "/*\n * DO NOT EDIT - this file is automatically generated by shgen 0.3\n" );
31  fprintf( file,
32    " * Copyright (c) 1998-1999, Ralf Corsepius (corsepiu@faw.uni-ulm.de)\n */\n" );
33  fprintf( file,
34    "\n/* This file is not copyrighted */\n\n" );
35}
36
37int main( int argc, char *argv[] )
38{
39  double        Phi = 20.0 ;
40 
41  while ( ( optopt = getopt( argc, argv, "M:K:H:" ) ) > 0 )
42  {
43    switch ( optopt )
44    {
45    case 'M' :
46      sscanf( optarg, "%lf", &Phi );
47      Phi = Phi * 1000000.0;
48      break ;
49    case 'K' :
50      sscanf( optarg, "%lf", &Phi );
51      Phi = Phi * 1000.0;
52      break ;
53    case 'H' :
54      sscanf( optarg, "%lf", &Phi );
55      break ;
56    default  :
57      usage( argv[0] );
58      break ;
59    }
60  }
61
62  if ( argc - optind != 1 )
63    usage( argv[0] );
64
65  shgen_header( stdout );
66     
67  if ( strcmp( argv[optind], "sci" ) == 0 )
68  {
69    shgen_gensci( stdout, Phi );
70  }
71  else
72    usage( argv[0] );
73     
74  return 0 ;
75}
Note: See TracBrowser for help on using the repository browser.