~ubuntu-branches/ubuntu/oneiric/oss4/oneiric-proposed

« back to all changes in this revision

Viewing changes to setup/gen_driver_solaris.inc

  • Committer: Bazaar Package Importer
  • Author(s): Stefano Rivera
  • Date: 2011-06-16 20:37:48 UTC
  • mfrom: (5.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20110616203748-jbrxik6ql33z54co
Tags: 4.2-build2004-1ubuntu1
* Merge from Debian unstable.
  - Supports our current kernel (LP: #746048)
  Remaining changes:
  - debian/oss4-dkms.dkms.in: s/source/build/ in Kernel headers paths.
* ld-as-needed.patch: Re-order CC arguments to enable building with ld
  --as-needed (LP: #770972)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
static void
 
2
generate_driver (char *name, conf_t * conf, char *cfg_name, char *cfg_header,
 
3
                 char *dirname, char *topdir)
 
4
{
 
5
 
 
6
  /* Solaris version */
 
7
 
 
8
 
 
9
  FILE *f, *src;
 
10
  char tmp[256], line[256], *p, *s;
 
11
  int i, n = 0;
 
12
  char *options[MAXOPTS];
 
13
  int nopts = 0;
 
14
 
 
15
  sprintf (tmp, "%s/%s", dirname, cfg_name);
 
16
 
 
17
  if ((src = fopen (tmp, "w")) == NULL)
 
18
    {
 
19
      perror (tmp);
 
20
      exit (-1);
 
21
    }
 
22
 
 
23
  fprintf (src, "/*\n");
 
24
  fprintf (src, " * Automatically generated file - do not edit.\n");
 
25
  fprintf (src, " */\n");
 
26
 
 
27
/*
 
28
 * Handle driver specific configuration options
 
29
 */
 
30
  sprintf (tmp, "%s/.params", dirname);
 
31
  if ((f = fopen (tmp, "r")) != NULL)
 
32
    {
 
33
      while (fgets (line, sizeof (line) - 1, f) != NULL)
 
34
        {
 
35
          p = line + strlen (line) - 1;
 
36
          if (*p == '\n')
 
37
            *p = 0;
 
38
 
 
39
          fprintf (src, "%s\n", line);
 
40
          if (strncmp (line, "int ", 4) == 0)
 
41
            {
 
42
              char *s = line + 4, *p = s;
 
43
 
 
44
              while (*p && *p != '=' && *p != ';')
 
45
                p++;
 
46
              *p = 0;
 
47
              if (nopts >= MAXOPTS)
 
48
                {
 
49
                  fprintf (stderr, "Too many options for driver '%s' (%d)\n",
 
50
                           name, nopts);
 
51
                  exit (-1);
 
52
                }
 
53
 
 
54
              options[nopts++] = strdup (s);
 
55
            }
 
56
        }
 
57
 
 
58
      fclose (f);
 
59
    }
 
60
 
 
61
  fprintf (src, "\n");
 
62
  fprintf (src, "#include \"%s\"\n", cfg_header);
 
63
  fprintf (src, "\n");
 
64
 
 
65
#if 0
 
66
  /* Not needed for Solaris */
 
67
  fprintf (src, "oss_device_table_t %s_devid_list[]=\n", name);
 
68
  fprintf (src, "{\n");
 
69
 
 
70
  if ((f = fopen ("devices.list", "r")) == NULL)
 
71
    {
 
72
      perror ("devices.list");
 
73
      exit (-1);
 
74
    }
 
75
 
 
76
  while (fgets (line, sizeof (line) - 1, f) != NULL)
 
77
    {
 
78
      p = line + strlen (line) - 1;
 
79
      if (*p == '\n')
 
80
        *p = 0;
 
81
 
 
82
      p = line;
 
83
      while (*p && *p != '\t')
 
84
        p++;
 
85
      if (*p == '\t')
 
86
        *p++ = 0;
 
87
 
 
88
      if (strcmp (line, name) != 0)
 
89
        continue;
 
90
 
 
91
      n++;
 
92
 
 
93
      s = p;
 
94
      while (*p && *p != '\t')
 
95
        p++;
 
96
      if (*p == '\t')
 
97
        *p++ = 0;
 
98
 
 
99
      fprintf (src, "\t{\"%s\", \"%s\"},\n", s, p);
 
100
    }
 
101
 
 
102
  fclose (f);
 
103
 
 
104
  fprintf (src, "\t{NULL}\n");
 
105
  fprintf (src, "};\n");
 
106
#endif
 
107
 
 
108
/*
 
109
 * Create the driver specific option list
 
110
 */
 
111
  fprintf (src, "oss_option_map_t local_driver_options[] =\n");
 
112
  fprintf (src, "{\n");
 
113
  for (i = 0; i < nopts; i++)
 
114
    fprintf (src, "\t{\"%s\", &%s},\n", options[i], options[i]);
 
115
  fprintf (src, "\t{NULL, NULL}\n");
 
116
  fprintf (src, "};\n");
 
117
  fprintf (src, "\n");
 
118
 
 
119
  fprintf (src, "#include \"%s/%s/module.inc\"\n", topdir, this_os);
 
120
 
 
121
#if 0
 
122
  if (n == 0)
 
123
    {
 
124
      fprintf (stderr,
 
125
               "Warning: No device entries (devices.list) for driver %s\n",
 
126
               name);
 
127
    }
 
128
#endif
 
129
 
 
130
  fclose (src);
 
131
 
 
132
  sprintf (tmp, "%s/%s", dirname, cfg_header);
 
133
  if ((src = fopen (tmp, "w")) == NULL)
 
134
    {
 
135
      perror (tmp);
 
136
      exit (-1);
 
137
    }
 
138
 
 
139
  fprintf (src, "/*\n");
 
140
  fprintf (src, " * Automatically generated file - do not edit.\n");
 
141
  fprintf (src, " */\n");
 
142
 
 
143
  fprintf (src, "#include <oss_config.h>\n");
 
144
  fprintf (src, "\n");
 
145
 
 
146
  fprintf (src, "#define DRIVER_NAME\t%s\n", name);
 
147
  fprintf (src, "#define DRIVER_NICK\t\"%s\"\n", name);
 
148
  fprintf (src, "#define DRIVER_PURPOSE\t\"%s\"\n", conf->purpose);
 
149
  fprintf (src, "#define DRIVER_STR_INFO\t%s_str_info\n", name);
 
150
  fprintf (src, "#define DRIVER_ATTACH\t%s_attach\n", name);
 
151
  fprintf (src, "#define DRIVER_DETACH\t%s_detach\n", name);
 
152
  fprintf (src, "#define DRIVER_TYPE\tDRV_%s\n", conf->bus);
 
153
 
 
154
  if (conf->power_manage)
 
155
     {
 
156
        fprintf (src, "#define DRIVER_POWER\t%s_power\n", name);
 
157
        fprintf (src, "#define OSS_POWER_MANAGE\n");
 
158
     }
 
159
 
 
160
  if (conf->suspend_resume)
 
161
     {
 
162
        fprintf (src, "#define DRIVER_SUSPEND\t%s_suspend\n", name);
 
163
        fprintf (src, "#define DRIVER_RESUME\t%s_resume\n", name);
 
164
        fprintf (src, "#define OSS_SUSPEND_RESUME\n");
 
165
     }
 
166
 
 
167
  fprintf (src, "\n");
 
168
 
 
169
  fprintf (src, "extern int DRIVER_ATTACH(oss_device_t *ossdev);\n");
 
170
  fprintf (src, "extern int DRIVER_DETACH(oss_device_t *ossdev);\n");
 
171
  fprintf (src, "extern int DRIVER_POWER(oss_device_t *ossdev, int component, int level);\n");
 
172
 
 
173
  fclose (src);
 
174
}