summaryrefslogtreecommitdiffstats
path: root/tools/cpu/sh/shgen.c
blob: c101388ad8e46e17c3c56642d1862d7cde69ded3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
 * Copyright (c) 1998-1999 Ralf Corsepius (corsepiu@faw.uni-ulm.de)
 *
 * See the file COPYING for copyright notice.
 */

#include <stdio.h>
#include <string.h>	/* strcmp, strerror */
#include <errno.h>
#include <getopt.h>

#include "sci.h"

static void usage( char *prog )
{
  fprintf( stderr, "usage: %s [options] driver\n", prog );
  fprintf( stderr, "options:\n" );
  fprintf( stderr, "\t-M Phi      .. processor frequency [MHz]\n" );
  fprintf( stderr, "\t-K Phi      .. processor frequency [KHz]\n" );
  fprintf( stderr, "\t-H Phi      .. processor frequency [Hz]\n" );
  fprintf( stderr, "\t\t..default 20MHz" );
  fprintf( stderr, "driver:\n" );
  fprintf( stderr, "\tsci .. bitrate table for sci\n" );
  exit ( 1 );
}

static void shgen_header( FILE *file )
{
  fprintf( file, 
    "/*\n * DO NOT EDIT - this file is automatically generated by shgen 0.3\n" );
  fprintf( file,
    " * Copyright (c) 1998-1999, Ralf Corsepius (corsepiu@faw.uni-ulm.de)\n */\n" );
  fprintf( file, 
    "\n/* This file is not copyrighted */\n\n" );
}

int main( int argc, char *argv[] )
{
  double 	Phi = 20.0 ;
  
  while ( ( optopt = getopt( argc, argv, "M:K:H:" ) ) > 0 )
  {
    switch ( optopt )
    {
    case 'M' :
      sscanf( optarg, "%lf", &Phi ); 
      Phi = Phi * 1000000.0;
      break ;
    case 'K' :
      sscanf( optarg, "%lf", &Phi ); 
      Phi = Phi * 1000.0;
      break ;
    case 'H' :
      sscanf( optarg, "%lf", &Phi ); 
      break ;
    default  :
      usage( argv[0] );
      break ;
    }
  }

  if ( argc - optind != 1 )
    usage( argv[0] );

  shgen_header( stdout );
      
  if ( strcmp( argv[optind], "sci" ) == 0 )
  {
    shgen_gensci( stdout, Phi );
  }
  else
    usage( argv[0] );
      
  return 0 ;
}