~ubuntu-branches/ubuntu/wily/hwinfo/wily

« back to all changes in this revision

Viewing changes to src/hd/prom.c

  • Committer: Bazaar Package Importer
  • Author(s): James Vega
  • Date: 2006-11-03 07:28:15 UTC
  • mfrom: (1.2.1 upstream) (3.1.7 edgy)
  • Revision ID: james.westby@ubuntu.com-20061103072815-7g9d6kzk0xn54159
Add cpu.c-alpha_bogo patch, which fixes a FTBFS on alpha because of an
undefined variable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <stdio.h>
 
2
#include <stdlib.h>
 
3
#include <string.h>
 
4
#include <unistd.h>
 
5
#include <dirent.h>
 
6
#include <sys/stat.h>
 
7
 
 
8
#include "hd.h"
 
9
#include "hd_int.h"
 
10
#include "hddb.h"
 
11
#include "prom.h"
 
12
 
 
13
/**
 
14
 * @defgroup PROMint PROM information (PowerPC)
 
15
 * @ingroup libhdINFOint
 
16
 * @brief PowerPC PROM information
 
17
 *
 
18
 * Note: make sure that hd_scan_sysfs_pci() has been run!
 
19
 *
 
20
 * @{
 
21
 */
 
22
 
 
23
#if defined(__PPC__)
 
24
 
 
25
static devtree_t *add_devtree_entry(devtree_t **devtree, devtree_t *new);
 
26
static devtree_t *new_devtree_entry(devtree_t *parent);
 
27
static void read_str(char *path, char *name, char **str);
 
28
static void read_mem(char *path, char *name, unsigned char **mem, unsigned len);
 
29
static void read_int(char *path, char *name, int *val);
 
30
static void read_devtree(hd_data_t *hd_data);
 
31
static void add_pci_prom_devices(hd_data_t *hd_data, hd_t *hd_parent, devtree_t *parent);
 
32
static void add_legacy_prom_devices(hd_data_t *hd_data, devtree_t *dt);
 
33
static int add_prom_display(hd_data_t *hd_data, devtree_t *dt);
 
34
static void add_devices(hd_data_t *hd_data);
 
35
static void dump_devtree_data(hd_data_t *hd_data);
 
36
 
 
37
static unsigned veth_cnt, vscsi_cnt;
 
38
 
 
39
int detect_smp_prom(hd_data_t *hd_data)
 
40
{
 
41
  unsigned cpus;
 
42
  devtree_t *devtree;
 
43
 
 
44
  if(!(devtree = hd_data->devtree)) return -1;  /* hd_scan_prom() not called */
 
45
 
 
46
  for(cpus = 0; devtree; devtree = devtree->next) {
 
47
    if(devtree->device_type && !strcmp(devtree->device_type, "cpu")) cpus++;
 
48
  }
 
49
 
 
50
  return cpus > 1 ? cpus : 0;
 
51
}
 
52
 
 
53
void hd_scan_prom(hd_data_t *hd_data)
 
54
{
 
55
  hd_t *hd;
 
56
  unsigned char buf[16];
 
57
  FILE *f;
 
58
  prom_info_t *pt;
 
59
 
 
60
  if(!hd_probe_feature(hd_data, pr_prom)) return;
 
61
 
 
62
  hd_data->module = mod_prom;
 
63
 
 
64
  /* some clean-up */
 
65
  remove_hd_entries(hd_data);
 
66
  hd_data->devtree = free_devtree(hd_data);
 
67
 
 
68
  veth_cnt = vscsi_cnt = 0;
 
69
 
 
70
  PROGRESS(1, 0, "devtree");
 
71
 
 
72
  read_devtree(hd_data);
 
73
  if(hd_data->debug) dump_devtree_data(hd_data);
 
74
  add_devices(hd_data);
 
75
 
 
76
  PROGRESS(2, 0, "color");
 
77
 
 
78
  hd = add_hd_entry(hd_data, __LINE__, 0);
 
79
  hd->base_class.id = bc_internal;
 
80
  hd->sub_class.id = sc_int_prom;
 
81
  hd->detail = new_mem(sizeof *hd->detail);
 
82
  hd->detail->type = hd_detail_prom;
 
83
  hd->detail->prom.data = pt = new_mem(sizeof *pt);
 
84
 
 
85
  if((f = fopen(PROC_PROM "/color-code", "r"))) {
 
86
    if(fread(buf, 1, 2, f) == 2) {
 
87
      pt->has_color = 1;
 
88
      pt->color = buf[1];
 
89
      hd_data->color_code = pt->color | 0x10000;
 
90
      ADD2LOG("color-code: 0x%04x\n", (buf[0] << 8) + buf[1]);
 
91
    }
 
92
 
 
93
    fclose(f);
 
94
  }
 
95
 
 
96
}
 
97
 
 
98
/* store a device tree entry */
 
99
devtree_t *add_devtree_entry(devtree_t **devtree, devtree_t *new)
 
100
{
 
101
  while(*devtree) devtree = &(*devtree)->next;
 
102
  return *devtree = new;
 
103
}
 
104
 
 
105
/* create a new device tree entry */
 
106
devtree_t *new_devtree_entry(devtree_t *parent)
 
107
{
 
108
  static unsigned idx = 0;
 
109
  devtree_t *devtree = new_mem(sizeof *devtree);
 
110
 
 
111
  if(!parent) idx = 0;
 
112
  devtree->idx = ++idx;
 
113
  devtree->parent = parent;
 
114
 
 
115
  devtree->interrupt = devtree->class_code =
 
116
  devtree->device_id = devtree->vendor_id =
 
117
  devtree->subdevice_id = devtree->subvendor_id =
 
118
  devtree->revision_id = -1;
 
119
 
 
120
  return devtree;
 
121
}
 
122
 
 
123
void read_str(char *path, char *name, char **str)
 
124
{
 
125
  char *s = NULL;
 
126
  str_list_t *sl;
 
127
 
 
128
  str_printf(&s, 0, "%s/%s", path, name);
 
129
  if((sl = read_file(s, 0, 1))) {
 
130
    *str = sl->str;
 
131
    sl->str = NULL;
 
132
    sl = free_str_list(sl);
 
133
  }
 
134
  free_mem(s);
 
135
}
 
136
 
 
137
void read_mem(char *path, char *name, unsigned char **mem, unsigned len)
 
138
{
 
139
  FILE *f;
 
140
  char *s = NULL;
 
141
  unsigned char *m = new_mem(len);
 
142
 
 
143
  str_printf(&s, 0, "%s/%s", path, name);
 
144
  if((f = fopen(s, "r"))) {
 
145
    if(fread(m, len, 1, f) == 1) {
 
146
      *mem = m;
 
147
      m = NULL;
 
148
    }
 
149
    fclose(f);
 
150
  }
 
151
  free_mem(s);
 
152
  free_mem(m);
 
153
}
 
154
 
 
155
void read_int(char *path, char *name, int *val)
 
156
{
 
157
  unsigned char *p = NULL;
 
158
 
 
159
  read_mem(path, name, &p, sizeof (int));
 
160
  if(p) memcpy(val, p, sizeof (int));
 
161
  free_mem(p);
 
162
}
 
163
 
 
164
void read_devtree_entry(hd_data_t *hd_data, devtree_t *parent, char *dirname)
 
165
{
 
166
  DIR *dir;
 
167
  struct dirent *de;
 
168
  struct stat sbuf;
 
169
  char *path, *s;
 
170
  devtree_t *devtree, *dt2;
 
171
 
 
172
  devtree = add_devtree_entry(&hd_data->devtree, new_devtree_entry(parent));
 
173
 
 
174
  devtree->filename = new_str(dirname);
 
175
 
 
176
  str_printf(&devtree->path, 0, "%s%s%s",
 
177
    parent ? parent->path : "", parent && *parent->path ? "/" : "", dirname
 
178
  );
 
179
 
 
180
  path = 0;
 
181
  str_printf(&path, 0, PROC_PROM "/%s", devtree->path);
 
182
 
 
183
  if((dir = opendir(path))) {
 
184
    while((de = readdir(dir))) {
 
185
      if(!strcmp(de->d_name, ".") || !strcmp(de->d_name, "..")) continue;
 
186
      s = NULL;
 
187
      str_printf(&s, 0, "%s/%s", path, de->d_name);
 
188
      if(!lstat(s, &sbuf)) {
 
189
        if(S_ISDIR(sbuf.st_mode)) {
 
190
          /* prom entries don't always have unique names, unfortunately... */
 
191
          for(dt2 = hd_data->devtree; dt2; dt2 = dt2->next) {
 
192
            if(
 
193
              dt2->parent == devtree &&
 
194
              !strcmp(dt2->filename, de->d_name)
 
195
            ) break;
 
196
          }
 
197
          if(!dt2) read_devtree_entry(hd_data, devtree, de->d_name);
 
198
        }
 
199
      }
 
200
      s = free_mem(s);
 
201
    }
 
202
    closedir(dir);
 
203
  }
 
204
 
 
205
  read_str(path, "name", &devtree->name);
 
206
  read_str(path, "model", &devtree->model);
 
207
  read_str(path, "device_type", &devtree->device_type);
 
208
  read_str(path, "compatible", &devtree->compatible);
 
209
 
 
210
  read_int(path, "interrupts", &devtree->interrupt);
 
211
  read_int(path, "AAPL,interrupts", &devtree->interrupt);
 
212
  read_int(path, "class-code", &devtree->class_code);
 
213
  read_int(path, "vendor-id", &devtree->vendor_id);
 
214
  read_int(path, "device-id", &devtree->device_id);
 
215
  read_int(path, "subsystem-vendor-id", &devtree->subvendor_id);
 
216
  read_int(path, "subsystem-id", &devtree->subdevice_id);
 
217
  read_int(path, "revision-id", &devtree->revision_id);
 
218
 
 
219
  read_mem(path, "EDID", &devtree->edid, 0x80);
 
220
  if(!devtree->edid) read_mem(path, "DFP,EDID", &devtree->edid, 0x80);
 
221
  if(!devtree->edid) read_mem(path, "LCD,EDID", &devtree->edid, 0x80);
 
222
 
 
223
  if(
 
224
    devtree->class_code != -1 && devtree->vendor_id != -1 &&
 
225
    devtree->device_id != -1
 
226
  ) {
 
227
    devtree->pci = 1;
 
228
  }
 
229
 
 
230
  path = free_mem(path);
 
231
}
 
232
 
 
233
void read_devtree(hd_data_t *hd_data)
 
234
{
 
235
  read_devtree_entry(hd_data, NULL, "");
 
236
 
 
237
}
 
238
 
 
239
void add_pci_prom_devices(hd_data_t *hd_data, hd_t *hd_parent, devtree_t *parent)
 
240
{
 
241
  hd_t *hd;
 
242
  hd_res_t *res;
 
243
  devtree_t *dt, *dt2;
 
244
  int irq, floppy_ctrl_idx;
 
245
  unsigned sound_ok = 0, net_ok = 0, scsi_ok = 0;
 
246
  unsigned id;
 
247
  char *s;
 
248
 
 
249
  for(dt = hd_data->devtree; dt; dt = dt->next) {
 
250
    if(
 
251
      dt->parent == parent ||
 
252
      (
 
253
        /* special magic to reach some sound chips */
 
254
        dt->parent &&
 
255
        dt->parent->parent == parent &&
 
256
        !dt->parent->pci
 
257
      )
 
258
    ) {
 
259
 
 
260
      if(
 
261
        dt->device_type &&
 
262
        (!strcmp(dt->device_type, "block") || !strcmp(dt->device_type, "swim3"))
 
263
      ) {
 
264
        /* block devices */
 
265
 
 
266
        s = dt->compatible ? dt->compatible : dt->name;
 
267
        id = 0;
 
268
 
 
269
        if(s) {
 
270
          if(strstr(s, "swim3")) {
 
271
            id = MAKE_ID(TAG_SPECIAL, 0x0040);
 
272
          }
 
273
        }
 
274
 
 
275
        if(id) {
 
276
          hd = add_hd_entry(hd_data, __LINE__, 0);
 
277
          hd->bus.id = bus_none;
 
278
          hd->base_class.id = bc_storage;
 
279
          hd->sub_class.id = sc_sto_floppy;
 
280
 
 
281
          hd->vendor.id = MAKE_ID(TAG_SPECIAL, 0x0401);
 
282
          hd->device.id = id;
 
283
          hd->attached_to = hd_parent->idx;
 
284
          hd->rom_id = new_str(dt->path);
 
285
          if(dt->interrupt) {
 
286
            res = add_res_entry(&hd->res, new_mem(sizeof *res));
 
287
            res->irq.type = res_irq;
 
288
            res->irq.enabled = 1;
 
289
            res->irq.base = dt->interrupt;
 
290
          }
 
291
          floppy_ctrl_idx = hd->idx;
 
292
 
 
293
          hd = add_hd_entry(hd_data, __LINE__, 0);
 
294
          hd->base_class.id = bc_storage_device;
 
295
          hd->sub_class.id = sc_sdev_floppy;
 
296
          hd->bus.id = bus_floppy;
 
297
          hd->unix_dev_name = new_str("/dev/fd0");
 
298
 
 
299
          res = add_res_entry(&hd->res, new_mem(sizeof *res));
 
300
          res->size.type = res_size;
 
301
          res->size.val1 = str2float("3.5", 2);
 
302
          res->size.unit = size_unit_cinch;
 
303
 
 
304
          res = add_res_entry(&hd->res, new_mem(sizeof *res));
 
305
          res->size.type = res_size;
 
306
          res->size.val1 = 2880;
 
307
          res->size.val2 = 0x200;
 
308
          res->size.unit = size_unit_sectors;
 
309
 
 
310
          hd->attached_to = floppy_ctrl_idx;
 
311
        }
 
312
      }
 
313
 
 
314
      if(
 
315
        !scsi_ok &&
 
316
        dt->device_type &&
 
317
        !strcmp(dt->device_type, "scsi")
 
318
      ) {
 
319
        /* scsi */
 
320
        scsi_ok = 1;    /* max. 1 controller */
 
321
 
 
322
        s = dt->compatible ? dt->compatible : dt->name;
 
323
        id = 0;
 
324
 
 
325
        if(s) {
 
326
          if(strstr(s, "mesh")) {       /* mesh || chrp,mesh0 */
 
327
            id = MAKE_ID(TAG_SPECIAL, 0x0030);
 
328
          }
 
329
          else if(!strcmp(s, "53c94")) {
 
330
            id = MAKE_ID(TAG_SPECIAL, 0x0031);
 
331
          }
 
332
        }
 
333
 
 
334
        if(id) {
 
335
          hd = add_hd_entry(hd_data, __LINE__, 0);
 
336
          hd->bus.id = bus_none;
 
337
          hd->base_class.id = bc_storage;
 
338
          hd->sub_class.id = sc_sto_scsi;
 
339
 
 
340
          hd->vendor.id = MAKE_ID(TAG_SPECIAL, 0x0401);
 
341
          hd->device.id = id;
 
342
          hd->attached_to = hd_parent->idx;
 
343
          hd->rom_id = new_str(dt->path);
 
344
          if(dt->interrupt) {
 
345
            res = add_res_entry(&hd->res, new_mem(sizeof *res));
 
346
            res->irq.type = res_irq;
 
347
            res->irq.enabled = 1;
 
348
            res->irq.base = dt->interrupt;
 
349
          }
 
350
        }
 
351
      }
 
352
 
 
353
      if(
 
354
        !net_ok &&
 
355
        dt->device_type &&
 
356
        !strcmp(dt->device_type, "network")
 
357
      ) {
 
358
        /* network */
 
359
        net_ok = 1;     /* max. 1 controller */
 
360
 
 
361
        s = dt->compatible ? dt->compatible : dt->name;
 
362
        id = 0;
 
363
 
 
364
        if(s) {
 
365
          if(!strcmp(s, "mace")) {
 
366
            id = MAKE_ID(TAG_SPECIAL, 0x0020);
 
367
          }
 
368
          else if(!strcmp(s, "bmac")) {
 
369
            id = MAKE_ID(TAG_SPECIAL, 0x0021);
 
370
          }
 
371
          else if(!strcmp(s, "bmac+")) {
 
372
            id = MAKE_ID(TAG_SPECIAL, 0x0022);
 
373
          }
 
374
        }
 
375
 
 
376
        if(id) {
 
377
          hd = add_hd_entry(hd_data, __LINE__, 0);
 
378
          hd->bus.id = bus_none;
 
379
          hd->base_class.id = bc_network;
 
380
          hd->sub_class.id = 0; /* ethernet */
 
381
 
 
382
          hd->vendor.id = MAKE_ID(TAG_SPECIAL, 0x0401);
 
383
          hd->device.id = id;
 
384
          hd->attached_to = hd_parent->idx;
 
385
          hd->rom_id = new_str(dt->path);
 
386
          if(dt->interrupt) {
 
387
            res = add_res_entry(&hd->res, new_mem(sizeof *res));
 
388
            res->irq.type = res_irq;
 
389
            res->irq.enabled = 1;
 
390
            res->irq.base = dt->interrupt;
 
391
          }
 
392
        }
 
393
      }
 
394
 
 
395
      if(
 
396
        !sound_ok &&
 
397
        dt->device_type &&
 
398
        strstr(dt->device_type, "sound") == dt->device_type
 
399
      ) {
 
400
        /* sound */
 
401
        sound_ok = 1;   /* max 1 controller */
 
402
 
 
403
        for(dt2 = dt; dt2; dt2 = dt2->next) {
 
404
          if(
 
405
            (
 
406
              dt2 == dt ||
 
407
              (dt2->parent && dt2->parent == dt)
 
408
            ) &&
 
409
            (
 
410
              !strcmp(dt2->device_type, "sound") ||
 
411
              !strcmp(dt2->device_type, "soundchip")
 
412
            )
 
413
          ) break;
 
414
        }
 
415
        if(!dt2) dt2 = dt;
 
416
 
 
417
        hd = add_hd_entry(hd_data, __LINE__, 0);
 
418
        hd->bus.id = bus_none;
 
419
        hd->base_class.id = bc_multimedia;
 
420
        hd->sub_class.id = sc_multi_audio;
 
421
        hd->attached_to = hd_parent->idx;
 
422
        hd->rom_id = new_str(dt2->path);
 
423
        irq = dt2->interrupt;
 
424
        if(irq <= 1 && dt2->parent && !dt2->parent->pci) {
 
425
          irq = dt2->parent->interrupt;
 
426
        }
 
427
        if(irq > 1) {
 
428
          res = add_res_entry(&hd->res, new_mem(sizeof *res));
 
429
          res->irq.type = res_irq;
 
430
          res->irq.enabled = 1;
 
431
          res->irq.base = irq;
 
432
        }
 
433
 
 
434
        hd->vendor.id = MAKE_ID(TAG_SPECIAL, 0x401);            /* Apple */
 
435
        hd->device.id = MAKE_ID(TAG_SPECIAL, 0x0010);
 
436
 
 
437
        if(dt2->compatible) {
 
438
          if(!strcmp(dt2->compatible, "screamer")) {
 
439
            hd->device.id = MAKE_ID(TAG_SPECIAL, 0x0011);
 
440
          }
 
441
          else if(!strcmp(dt2->compatible, "burgundy")) {
 
442
            hd->device.id = MAKE_ID(TAG_SPECIAL, 0x0012);
 
443
          }
 
444
          else if(!strcmp(dt2->compatible, "daca")) {
 
445
            hd->device.id = MAKE_ID(TAG_SPECIAL, 0x0013);
 
446
          }
 
447
          else if(!strcmp(dt2->compatible, "CRUS,CS4236B")) {
 
448
            hd->vendor.id = MAKE_ID(TAG_SPECIAL, 0x402);        /* IBM */
 
449
            hd->device.id = MAKE_ID(TAG_SPECIAL, 0x0014);
 
450
          }
 
451
        }
 
452
      }
 
453
    }
 
454
  }
 
455
}
 
456
 
 
457
 
 
458
void add_legacy_prom_devices(hd_data_t *hd_data, devtree_t *dt)
 
459
{
 
460
  if(dt->pci) return;
 
461
 
 
462
  if(add_prom_display(hd_data, dt)) return;
 
463
}
 
464
 
 
465
int add_prom_display(hd_data_t *hd_data, devtree_t *dt)
 
466
{
 
467
  hd_t *hd;
 
468
  hd_res_t *res;
 
469
  unsigned id;
 
470
 
 
471
  if(
 
472
    dt->device_type &&
 
473
    !strcmp(dt->device_type, "display")
 
474
  ) {
 
475
    /* display devices */
 
476
 
 
477
    id = 0;
 
478
 
 
479
    if(dt->name) {
 
480
      if(!strcmp(dt->name, "valkyrie")) {
 
481
        id = MAKE_ID(TAG_SPECIAL, 0x3000);
 
482
      }
 
483
      else if(!strcmp(dt->name, "platinum")) {
 
484
        id = MAKE_ID(TAG_SPECIAL, 0x3001);
 
485
      }
 
486
    }
 
487
 
 
488
    if(id) {
 
489
      hd = add_hd_entry(hd_data, __LINE__, 0);
 
490
      hd->bus.id = bus_none;
 
491
      hd->base_class.id = bc_display;
 
492
      hd->sub_class.id = sc_dis_other;
 
493
 
 
494
      hd->vendor.id = MAKE_ID(TAG_SPECIAL, 0x0401);
 
495
      hd->device.id = id;
 
496
      hd->rom_id = new_str(dt->path);
 
497
      if(dt->interrupt) {
 
498
        res = add_res_entry(&hd->res, new_mem(sizeof *res));
 
499
        res->irq.type = res_irq;
 
500
        res->irq.enabled = 1;
 
501
        res->irq.base = dt->interrupt;
 
502
      }
 
503
 
 
504
      return 1;
 
505
    }
 
506
  }
 
507
 
 
508
  return 0;
 
509
}
 
510
 
 
511
void add_devices(hd_data_t *hd_data)
 
512
{
 
513
  hd_t *hd;
 
514
  devtree_t *dt;
 
515
#if 0
 
516
  hd_res_t *res;
 
517
  unsigned pci_slot = 0, u;
 
518
#endif
 
519
 
 
520
  /* remove old assignments */
 
521
  for(hd = hd_data->hd; hd; hd = hd->next) {
 
522
    if(ID_TAG(hd->device.id) == TAG_PCI && ID_TAG(hd->vendor.id) == TAG_PCI) {
 
523
      hd->rom_id = free_mem(hd->rom_id);
 
524
      hd->detail = free_hd_detail(hd->detail);
 
525
    }
 
526
  }
 
527
 
 
528
  for(dt = hd_data->devtree; dt; dt = dt->next) {
 
529
    if(dt->pci) {
 
530
      for(hd = hd_data->hd; hd; hd = hd->next) {
 
531
        if(
 
532
          /* do *not* compare class ids */
 
533
          /* It would be better to check the slot numbers instead but
 
534
           * as they are not stored within /proc/device-tree in a consistent
 
535
           * way, we can't do that.
 
536
           */
 
537
          !hd->rom_id &&
 
538
          ID_TAG(hd->device.id) == TAG_PCI &&
 
539
          ID_TAG(hd->vendor.id) == TAG_PCI &&
 
540
          ID_VALUE(hd->device.id) == dt->device_id &&
 
541
          ID_VALUE(hd->vendor.id) == dt->vendor_id &&
 
542
          (dt->subvendor_id == -1 || ID_VALUE(hd->sub_vendor.id) == dt->subvendor_id) &&
 
543
          (dt->subdevice_id == -1 || ID_VALUE(hd->sub_device.id) == dt->subdevice_id) &&
 
544
          hd->revision.id == dt->revision_id
 
545
        ) break;
 
546
      }
 
547
 
 
548
      if(hd) {
 
549
        hd->rom_id = new_str(dt->path);
 
550
        hd->detail = new_mem(sizeof *hd->detail);
 
551
        hd->detail->type = hd_detail_devtree;
 
552
        hd->detail->devtree.data = dt;
 
553
        add_pci_prom_devices(hd_data, hd, dt);
 
554
      }
 
555
    }
 
556
    else {
 
557
      add_legacy_prom_devices(hd_data, dt);
 
558
    }
 
559
  }
 
560
}
 
561
 
 
562
void dump_devtree_data(hd_data_t *hd_data)
 
563
{
 
564
  unsigned u;
 
565
  devtree_t *devtree;
 
566
 
 
567
  devtree = hd_data->devtree;
 
568
  if(!devtree) return;
 
569
 
 
570
  ADD2LOG("----- /proc device tree -----\n");
 
571
 
 
572
  for(; devtree; devtree = devtree->next) {
 
573
    u = devtree->parent ? devtree->parent->idx : 0;
 
574
    ADD2LOG("  %02u @%02u  %s", devtree->idx, u, devtree->path);
 
575
    if(devtree->pci) ADD2LOG("  [pci]");
 
576
    ADD2LOG("\n");
 
577
 
 
578
    ADD2LOG(
 
579
      "    name \"%s\", model \"%s\", dtype \"%s\", compat \"%s\"\n",
 
580
      devtree->name ? devtree->name : "",
 
581
      devtree->model ? devtree->model : "",
 
582
      devtree->device_type ? devtree->device_type : "",
 
583
      devtree->compatible ? devtree->compatible : ""
 
584
    );
 
585
 
 
586
    if(
 
587
      devtree->class_code != -1 || devtree->vendor_id != -1 ||
 
588
      devtree->device_id != -1 || devtree->revision_id != -1 ||
 
589
      devtree->subdevice_id != -1 || devtree->subvendor_id != -1 ||
 
590
      devtree->interrupt != -1
 
591
    ) {
 
592
      ADD2LOG("  ");
 
593
      if(devtree->class_code != -1) ADD2LOG("  class 0x%06x", devtree->class_code);
 
594
      if(devtree->vendor_id != -1) ADD2LOG("  vend 0x%04x", devtree->vendor_id);
 
595
      if(devtree->device_id != -1) ADD2LOG("  dev 0x%04x", devtree->device_id);
 
596
      if(devtree->subvendor_id != -1) ADD2LOG("  svend 0x%04x", devtree->subvendor_id);
 
597
      if(devtree->subdevice_id != -1) ADD2LOG("  sdev 0x%04x", devtree->subdevice_id);
 
598
      if(devtree->revision_id != -1) ADD2LOG("  rev 0x%02x", devtree->revision_id);
 
599
      if(devtree->interrupt != -1) ADD2LOG("  irq %d", devtree->interrupt);
 
600
      ADD2LOG("\n");
 
601
    }
 
602
 
 
603
    if(devtree->edid) {
 
604
      ADD2LOG("    EDID record:\n");
 
605
      for(u = 0; u < 0x80; u += 0x10) {
 
606
        ADD2LOG("    %02x  ", u);
 
607
        hexdump(&hd_data->log, 1, 0x10, devtree->edid + u);
 
608
        ADD2LOG("\n");
 
609
      }
 
610
    }
 
611
 
 
612
    if(devtree->next) ADD2LOG("\n");
 
613
  }
 
614
 
 
615
  ADD2LOG("----- /proc device tree end -----\n");
 
616
}
 
617
 
 
618
#endif /* defined(__PPC__) */
 
619
 
 
620
/** @} */
 
621