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

« back to all changes in this revision

Viewing changes to .pc/0005-Read-BogoMIPS-from-proc-cpuinfo-as-well.patch/src/hd/cpu.c

  • Committer: Package Import Robot
  • Author(s): Sebastien Badia, Tomasz Buchert, Sebastien Badia
  • Date: 2015-03-05 15:03:04 UTC
  • mfrom: (1.1.16)
  • Revision ID: package-import@ubuntu.com-20150305150304-euatfbdijoyct4r7
Tags: 21.12-1
[ Tomasz Buchert ]
* d/patches: fix reproduciblity issues (Closes: #776717)

[ Sebastien Badia ]
* Imported Upstream version 21.12
* d/control: Fix vcs-browser URL (use cgit)

Show diffs side-by-side

added added

removed removed

Lines of Context:
121
121
  unsigned u;
122
122
  double bogo;
123
123
  char *t0, *t;
 
124
  int old_format;
124
125
#endif
125
126
 
126
127
#ifdef __PPC__
280
281
  *model_id = *system_id = *serial_number = 0;
281
282
  cpu_variation = cpu_revision = 0;
282
283
  ct = 0; bogo = 0;
 
284
  vendor_id = 0;
283
285
 
284
286
  hd_data->boot = boot_uboot;
285
287
 
286
288
  for(sl = hd_data->cpu; sl; sl = sl->next) {
287
 
    if(sscanf(sl->str, "Processor       : %79[^\n]", model_id) == 1) continue;
288
 
    if(sscanf(sl->str, "Hardware        : %79[^\n]", system_id) == 1) continue;
289
 
    if(sscanf(sl->str, "Features        : %1000[^\n]", features) == 1) continue;
290
 
    if(sscanf(sl->str, "CPU variant     : 0x%x", &cpu_variation) == 1) continue;
291
 
    if(sscanf(sl->str, "CPU implementer : 0x%x", &vendor_id) == 1) continue;
292
 
    if(sscanf(sl->str, "CPU revision    : %d", &cpu_revision) == 1) continue;
 
289
    if(sscanf(sl->str, "Processor       : %79[^\n]", model_id) == 1);
 
290
    if(sscanf(sl->str, "Hardware        : %79[^\n]", system_id) == 1);
 
291
    if(sscanf(sl->str, "Features        : %1000[^\n]", features) == 1);
 
292
    if(sscanf(sl->str, "CPU variant     : 0x%x", &cpu_variation) == 1);
 
293
    if(sscanf(sl->str, "CPU implementer : 0x%x", &vendor_id) == 1);
 
294
    if(sscanf(sl->str, "CPU revision    : %d", &cpu_revision) == 1);
293
295
    if(!bogo && sscanf(sl->str, "BogoMIPS        : %lg", &bogo) == 1);
294
 
    if(strstr(sl->str, "processor\t: ") == sl->str) cpus++;
295
 
  }
296
 
 
297
 
  /* if we didn't find any cpus, we might be running under qemu.
298
 
     So simulate just one CPU to make the rest happy. */
299
 
  if(!cpus) cpus = 1;
300
 
  for(u = 0; u < cpus; u++) {
301
 
    ct = new_mem(sizeof *ct);
302
 
    ct->architecture = arch_aarch64;
303
 
    ct->family = cpu_variation;
304
 
    ct->model = cpu_revision;
305
 
    ct->stepping = 0;
306
 
    ct->cache = 0;
307
 
    ct->clock = 0;
308
 
    ct->bogo = bogo;
309
 
    ct->platform = 0;
310
 
    if(*system_id) ct->platform = new_str(system_id);
311
 
    if(*model_id) ct->model_name = new_str(model_id);
312
 
 
313
 
    switch (vendor_id) {
314
 
    case 0x41: ct->vend_name = new_str("ARM Limited"); break;
315
 
    case 0x44: ct->vend_name = new_str("Digital Equipment Corporation"); break;
316
 
    case 0x4d: ct->vend_name = new_str("Motorola, Freescale Semiconductor Inc."); break;
317
 
    case 0x51: ct->vend_name = new_str("QUALCOMM Inc."); break;
318
 
    case 0x56: ct->vend_name = new_str("Marvell Semiconductor Inc."); break;
319
 
    case 0x69: ct->vend_name = new_str("Intel Corporation."); break;
320
 
    default:
321
 
     {
322
 
       char buf[80];
323
 
       sprintf(buf, "unknown (%x)", vendor_id);
324
 
       ct->vend_name = new_str(buf);
325
 
     }
326
 
    }
327
 
 
328
 
    if(*features) {
329
 
      for(t0 = features; (t = strsep(&t0, " ")); ) {
330
 
        add_str_list(&ct->features, t);
331
 
      }
332
 
    }
333
 
 
334
 
    hd = add_hd_entry(hd_data, __LINE__, 0);
335
 
    hd->base_class.id = bc_internal;
336
 
    hd->sub_class.id = sc_int_cpu;
337
 
    hd->slot = u;
338
 
    hd->detail = new_mem(sizeof *hd->detail);
339
 
    hd->detail->type = hd_detail_cpu;
340
 
    hd->detail->cpu.data = ct;
 
296
    if(strstr(sl->str, "processor") == sl->str || !sl->next) {          /* EOF */
 
297
      if (!vendor_id) { /* pre-3.19 format */
 
298
        cpus++;
 
299
        continue;
 
300
      }
 
301
      if (*model_id || vendor_id) {     /* at least one of those */
 
302
      loop:
 
303
        ct = new_mem(sizeof *ct);
 
304
        ct->architecture = arch_aarch64;
 
305
        ct->family = cpu_variation;
 
306
        ct->model = cpu_revision;
 
307
        ct->stepping = 0;
 
308
        ct->cache = 0;
 
309
        ct->clock = 0;
 
310
        ct->bogo = bogo;
 
311
        ct->platform = 0;
 
312
        if(*system_id) ct->platform = new_str(system_id);
 
313
        if(*model_id) ct->model_name = new_str(model_id);
 
314
        switch (vendor_id) {
 
315
        case 0x41: ct->vend_name = new_str("ARM Limited"); break;
 
316
        case 0x44: ct->vend_name = new_str("Digital Equipment Corporation"); break;
 
317
        case 0x4d: ct->vend_name = new_str("Motorola, Freescale Semiconductor Inc."); break;
 
318
        case 0x51: ct->vend_name = new_str("QUALCOMM Inc."); break;
 
319
        case 0x56: ct->vend_name = new_str("Marvell Semiconductor Inc."); break;
 
320
        case 0x69: ct->vend_name = new_str("Intel Corporation."); break;
 
321
        default:
 
322
          {
 
323
            char buf[80];
 
324
            sprintf(buf, "unknown (%x)", vendor_id);
 
325
            ct->vend_name = new_str(buf);
 
326
          }
 
327
        }
 
328
 
 
329
        if(*features) {
 
330
          for(t0 = features; (t = strsep(&t0, " ")); ) {
 
331
            add_str_list(&ct->features, t);
 
332
          }
 
333
        }
 
334
 
 
335
        hd = add_hd_entry(hd_data, __LINE__, 0);
 
336
        hd->base_class.id = bc_internal;
 
337
        hd->sub_class.id = sc_int_cpu;
 
338
        hd->slot = u;
 
339
        hd->detail = new_mem(sizeof *hd->detail);
 
340
        hd->detail->type = hd_detail_cpu;
 
341
        hd->detail->cpu.data = ct;
 
342
        if (*model_id && --cpus) goto loop; /* pre-3.19 format */
 
343
        cpus++;
 
344
      }
 
345
    }
341
346
  }
342
347
#endif  /* __aarch64__ */
343
348