OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [tools/] [cpu/] [sh/] [shgen.c] - Blame information for rev 252

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
2
 * Copyright (c) 1998,1999,2000 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
 
14
static void usage( FILE* ofile, char *prog )
15
{
16
  fprintf( ofile, "Usage: %s [options] driver\n", prog );
17
  fprintf( ofile, "\nOptions:\n" );
18
  fprintf( ofile, "Processor frequency (default 20MHz):\n") ;
19
  fprintf( ofile, "\t-M Phi      .. processor frequency [MHz]\n" );
20
  fprintf( ofile, "\t-K Phi      .. processor frequency [KHz]\n" );
21
  fprintf( ofile, "\t-H Phi      .. processor frequency [Hz]\n" );
22
  fprintf( ofile, "Driver:\n" );
23
  fprintf( ofile, "\tsci         .. bitrate table for sci\n" );
24
 
25
  fprintf( ofile, "\nWritten by Ralf Corsepius <corsepiu@faw.uni-ulm.de>\n" );
26
  fprintf( ofile, "\nCopyright (c) 1998,1999,2000\tRalf Corsepius\n" );
27
}
28
 
29
#if HAVE_GETOPT_LONG
30
#define NOARG   0
31
#define HASARG  1
32
#define OPTARG  2
33
 
34
static struct option long_options[] =
35
{
36
  { "version",          NOARG,  NULL, 'v' },
37
  { "help",             NOARG,  NULL, 'h' },
38
  { "mega-hertz",       HASARG, NULL, 'M' },
39
  { "kilo-hertz",       HASARG, NULL, 'K' },
40
  { "hertz",            HASARG, NULL, 'H' },
41
  { 0, 0, 0, 0 }
42
};
43
#endif
44
 
45
static void shgen_header( FILE *file )
46
{
47
  fprintf( file,
48
    "/*\n * DO NOT EDIT - this file is automatically generated by shgen %s\n",
49
    VERSION );
50
  fprintf( file,
51
    " * Copyright (c) 1998,1999,2000 Ralf Corsepius (corsepiu@faw.uni-ulm.de)\n */\n" );
52
  fprintf( file,
53
    "\n/* This file is not copyrighted */\n\n" );
54
}
55
 
56
int main( int argc, char *argv[] )
57
{
58
  double        Phi = 20.0 ;
59
 
60
#if HAVE_GETOPT_LONG  
61
  int option_index = 0 ;
62
  while( ( optopt = getopt_long( argc, argv, "M:K:H:hv",
63
      long_options, &option_index ) ) > 0 )
64
#else
65
  while ( ( optopt = getopt( argc, argv, "M:K:H:hv" ) ) > 0 )
66
#endif
67
  {
68
    switch ( optopt )
69
    {
70
    case 'M' :
71
      sscanf( optarg, "%lf", &Phi );
72
      Phi = Phi * 1000000.0;
73
      break ;
74
    case 'K' :
75
      sscanf( optarg, "%lf", &Phi );
76
      Phi = Phi * 1000.0;
77
      break ;
78
    case 'H' :
79
      sscanf( optarg, "%lf", &Phi );
80
      break ;
81
    case 'h' :
82
      usage( stdout, argv[0] );
83
      exit(0);
84
    case 'v' :
85
      fprintf( stdout, "%s version %s\n", argv[0], VERSION );
86
      exit(0);
87
    default  :
88
      usage( stderr, argv[0] );
89
      exit(1);
90
      break ;
91
    }
92
  }
93
 
94
  if ( argc - optind != 1 )
95
  {
96
    fprintf( stderr, "%s: Missing argument: driver\n", argv[0] );
97
    exit(1);
98
  }
99
 
100
  shgen_header( stdout );
101
 
102
  if ( strcmp( argv[optind], "sci" ) == 0 )
103
  {
104
    shgen_gensci( stdout, Phi );
105
  }
106
  else
107
  {
108
    fprintf( stderr, "%s: Invalid argument: driver\n", argv[0] );
109
    exit(1);
110
  }
111
 
112
  return 0 ;
113
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.