Exemplo n.º 1
0
static size_t
show_section(struct mca_section_header *sh)
{
	static uuid_t uuid_cpu = MCA_UUID_CPU;
	static uuid_t uuid_memory = MCA_UUID_MEMORY;
	static uuid_t uuid_sel = MCA_UUID_SEL;
	static uuid_t uuid_pci_bus = MCA_UUID_PCI_BUS;
	static uuid_t uuid_smbios = MCA_UUID_SMBIOS;
	static uuid_t uuid_pci_dev = MCA_UUID_PCI_DEV;
	static uuid_t uuid_generic = MCA_UUID_GENERIC;

	printf("  <section>\n");
	show_value(4, "uuid", "%s", uuid(&sh->sh_uuid));
	show_value(4, "revision", "%d.%d", BCD(sh->sh_major),
	    BCD(sh->sh_minor));

	if (uuid_equal(&sh->sh_uuid, &uuid_cpu, NULL))
		show_cpu((void*)(sh + 1));
	else if (uuid_equal(&sh->sh_uuid, &uuid_memory, NULL))
		show_memory((void*)(sh + 1));
	else if (uuid_equal(&sh->sh_uuid, &uuid_sel, NULL))
		show_sel();
	else if (uuid_equal(&sh->sh_uuid, &uuid_pci_bus, NULL))
		show_pci_bus((void*)(sh + 1));
	else if (uuid_equal(&sh->sh_uuid, &uuid_smbios, NULL))
		show_smbios();
	else if (uuid_equal(&sh->sh_uuid, &uuid_pci_dev, NULL))
		show_pci_dev((void*)(sh + 1));
	else if (uuid_equal(&sh->sh_uuid, &uuid_generic, NULL))
		show_generic();

	printf("  </section>\n");
	return (sh->sh_length);
}
Exemplo n.º 2
0
static void
show_pci_dev(struct mca_pcidev_record *pcidev)
{
	printf("    <pci-dev>\n");

	if (pcidev->pcidev_flags & MCA_PCIDEV_FLAGS_STATUS)
		show_value(6, "status", "0x%016llx",
		    (long long)pcidev->pcidev_status);
	if (pcidev->pcidev_flags & MCA_PCIDEV_FLAGS_INFO) {
		show_value(6, "vendor", "0x%04x",
		    pcidev->pcidev_info.info_vendor);
		show_value(6, "device", "0x%04x",
		    pcidev->pcidev_info.info_device);
		show_value(6, "class", "0x%06x",
		    MCA_PCIDEV_INFO_CLASS(pcidev->pcidev_info.info_ccfn));
		show_value(6, "function", "0x%02x",
		    MCA_PCIDEV_INFO_FUNCTION(pcidev->pcidev_info.info_ccfn));
		show_value(6, "slot", "0x%02x", pcidev->pcidev_info.info_slot);
		show_value(6, "bus", "0x%04x", pcidev->pcidev_info.info_bus);
		show_value(6, "segment", "0x%04x",
		    pcidev->pcidev_info.info_segment);
	}
	/* TODO: dump registers */
	/* TODO: Dump OEM data */

	printf("    </pci-dev>\n");
}
Exemplo n.º 3
0
static void
show_cpu(struct mca_cpu_record *cpu)
{
	char var[16];
	struct mca_cpu_mod *mod;
	struct mca_cpu_cpuid *cpuid;
	struct mca_cpu_psi *psi;
	int i, n;

	printf("    <cpu>\n");

	if (cpu->cpu_flags & MCA_CPU_FLAGS_ERRMAP)
		show_value(6, "errmap", "0x%016llx",
		    (long long)cpu->cpu_errmap);
	if (cpu->cpu_flags & MCA_CPU_FLAGS_STATE)
		show_value(6, "state", "0x%016llx",
		    (long long)cpu->cpu_state);
	if (cpu->cpu_flags & MCA_CPU_FLAGS_CR_LID)
		show_value(6, "cr_lid", "0x%016llx",
		    (long long)cpu->cpu_cr_lid);

	mod = (struct mca_cpu_mod*)(cpu + 1);
	n = MCA_CPU_FLAGS_CACHE(cpu->cpu_flags);
	for (i = 0; i < n; i++)
		show_cpu_mod("cache", i, mod++);
	n = MCA_CPU_FLAGS_TLB(cpu->cpu_flags);
	for (i = 0; i < n; i++)
		show_cpu_mod("tlb", i, mod++);
	n = MCA_CPU_FLAGS_BUS(cpu->cpu_flags);
	for (i = 0; i < n; i++)
		show_cpu_mod("bus", i, mod++);
	n = MCA_CPU_FLAGS_REG(cpu->cpu_flags);
	for (i = 0; i < n; i++)
		show_cpu_mod("reg", i, mod++);
	n = MCA_CPU_FLAGS_MS(cpu->cpu_flags);
	for (i = 0; i < n; i++)
		show_cpu_mod("ms", i, mod++);

	cpuid = (struct mca_cpu_cpuid*)mod;
	for (i = 0; i < 6; i++) {
		sprintf(var, "cpuid-%d", i);
		show_value(6, var, "0x%016llx", (long long)cpuid->cpuid[i]);
	}

	psi = (struct mca_cpu_psi*)(cpuid + 1);
	/* TODO: Dump PSI */

	printf("    </cpu>\n");
}
Exemplo n.º 4
0
static void
show_cpu_mod(const char *what, int idx, struct mca_cpu_mod *cpu_mod)
{
	printf("      <%s-%d>\n", what, idx);
	if (cpu_mod->cpu_mod_flags & MCA_CPU_MOD_FLAGS_INFO)
		show_value(8, "info", "0x%016llx",
		    (long long)cpu_mod->cpu_mod_info);
	if (cpu_mod->cpu_mod_flags & MCA_CPU_MOD_FLAGS_REQID)
		show_value(8, "requester", "0x%016llx",
		    (long long)cpu_mod->cpu_mod_reqid);
	if (cpu_mod->cpu_mod_flags & MCA_CPU_MOD_FLAGS_RSPID)
		show_value(8, "responder", "0x%016llx",
		    (long long)cpu_mod->cpu_mod_rspid);
	if (cpu_mod->cpu_mod_flags & MCA_CPU_MOD_FLAGS_TGTID)
		show_value(8, "target", "0x%016llx",
		    (long long)cpu_mod->cpu_mod_tgtid);
	if (cpu_mod->cpu_mod_flags & MCA_CPU_MOD_FLAGS_IP)
		show_value(8, "ip", "0x%016llx",
		    (long long)cpu_mod->cpu_mod_ip);
	printf("      </%s-%d>\n", what, idx);
}
Exemplo n.º 5
0
void create_widget(const dictionary_t&  parameters, 
                   size_enum_t          size,
                   reveal_t*&           widget)
{
    std::string             name;
    std::string             alt_text;
    any_regular_t    show_value(true);
    theme_t          theme(implementation::size_to_theme(size));

    get_value(parameters, key_value_on, show_value);
    get_value(parameters, key_alt_text, alt_text);
    get_value(parameters, key_name, name);

    widget = new reveal_t(name, show_value, theme, alt_text);
}
Exemplo n.º 6
0
static void
show_pci_bus(struct mca_pcibus_record *pcibus)
{
	printf("    <pci-bus>\n");

	if (pcibus->pcibus_flags & MCA_PCIBUS_FLAGS_STATUS)
		show_value(6, "status", "0x%016llx",
		    (long long)pcibus->pcibus_status);
	if (pcibus->pcibus_flags & MCA_PCIBUS_FLAGS_ERROR)
		show_value(6, "error", "0x%04x", pcibus->pcibus_error);
	if (pcibus->pcibus_flags & MCA_PCIBUS_FLAGS_BUS)
		show_value(6, "bus", "0x%04x", pcibus->pcibus_bus);
	if (pcibus->pcibus_flags & MCA_PCIBUS_FLAGS_ADDR)
		show_value(6, "address", "0x%016llx",
		    (long long)pcibus->pcibus_addr);
	if (pcibus->pcibus_flags & MCA_PCIBUS_FLAGS_DATA)
		show_value(6, "data", "0x%016llx",
		    (long long)pcibus->pcibus_data);
	if (pcibus->pcibus_flags & MCA_PCIBUS_FLAGS_CMD)
		show_value(6, "cmd", "0x%016llx",
		    (long long)pcibus->pcibus_cmd);
	if (pcibus->pcibus_flags & MCA_PCIBUS_FLAGS_REQID)
		show_value(6, "requester", "0x%016llx",
		    (long long)pcibus->pcibus_reqid);
	if (pcibus->pcibus_flags & MCA_PCIBUS_FLAGS_RSPID)
		show_value(6, "responder", "0x%016llx",
		    (long long)pcibus->pcibus_rspid);
	if (pcibus->pcibus_flags & MCA_PCIBUS_FLAGS_TGTID)
		show_value(6, "target", "0x%016llx",
		    (long long)pcibus->pcibus_tgtid);
	if (pcibus->pcibus_flags & MCA_PCIBUS_FLAGS_OEM_ID)
		show_value(6, "oem", "%s", uuid(&pcibus->pcibus_oem_id));
	/* TODO: Dump OEM data */

	printf("    </pci-bus>\n");
}
Exemplo n.º 7
0
static void show_key(handle_t dest, memid_t key, bool full_path, bool recursive, uint16_t *indent)
  {
  char name[REG_NAME_MAX + 1];
  const char * path;
  if(full_path)
    path = get_full_path(key);
  else
    {
    reg_query_memid(key, 0, name, 0, 0);
    path = (char *)neutron_malloc(strlen(name)+1);
    strcpy((char *)path, name);
    }

  field_datatype type = 0;
  // must be 0 on first call
  memid_t child = 0;
  result_t result;

  while(succeeded(result = reg_enum_key(key, &type, 0, 0, REG_NAME_MAX + 1, name, &child)) && child != 0)
    {
    if (type > field_key)
      show_value(dest, key, type, name, indent, 0);

    // field_datatype has the field type, name is the child name
    type = 0;
    }

  type = field_key;
  child = 0;

  while(succeeded(result = reg_enum_key(key, &type, 0, 0, REG_NAME_MAX + 1, name, &child)))
    {
    do_indent(dest, *indent);
    stream_printf(dest, "dir    %s\r\n", name);
    *indent += 2;
    if(recursive)
      show_key(dest, child, false, true, indent);
    *indent -= 2;

    type = field_key;
    }

  }
Exemplo n.º 8
0
static size_t
show_header(struct mca_record_header *rh)
{

	printf("  <header>\n");
	show_value(4, "seqnr", "%lld", (long long)rh->rh_seqnr);
	show_value(4, "revision", "%d.%d", BCD(rh->rh_major),
	    BCD(rh->rh_minor));
	show_value(4, "severity", "%s", severity(rh->rh_error));
	show_value(4, "length", "%lld", (long long)rh->rh_length);
	show_value(4, "date", "%d%02d/%02d/%02d",
	    BCD(rh->rh_time[MCA_RH_TIME_CENT]),
	    BCD(rh->rh_time[MCA_RH_TIME_YEAR]),
	    BCD(rh->rh_time[MCA_RH_TIME_MON]),
	    BCD(rh->rh_time[MCA_RH_TIME_MDAY]));
	show_value(4, "time", "%02d:%02d:%02d",
	    BCD(rh->rh_time[MCA_RH_TIME_HOUR]),
	    BCD(rh->rh_time[MCA_RH_TIME_MIN]),
	    BCD(rh->rh_time[MCA_RH_TIME_SEC]));
	if (rh->rh_flags & MCA_RH_FLAGS_PLATFORM_ID)
		show_value(4, "platform", "%s", uuid(&rh->rh_platform));
	printf("  </header>\n");
	return (rh->rh_length);
}
Exemplo n.º 9
0
static void
show_memory(struct mca_mem_record *mem)
{
	printf("    <memory>\n");

	if (mem->mem_flags & MCA_MEM_FLAGS_STATUS)
		show_value(6, "status", "0x%016llx",
		    (long long)mem->mem_status);
	if (mem->mem_flags & MCA_MEM_FLAGS_ADDR)
		show_value(6, "address", "0x%016llx",
		    (long long)mem->mem_addr);
	if (mem->mem_flags & MCA_MEM_FLAGS_ADDRMASK)
		show_value(6, "mask", "0x%016llx",
		    (long long)mem->mem_addrmask);
	if (mem->mem_flags & MCA_MEM_FLAGS_NODE)
		show_value(6, "node", "0x%04x", mem->mem_node);
	if (mem->mem_flags & MCA_MEM_FLAGS_CARD)
		show_value(6, "card", "0x%04x", mem->mem_card);
	if (mem->mem_flags & MCA_MEM_FLAGS_MODULE)
		show_value(6, "module", "0x%04x", mem->mem_module);
	if (mem->mem_flags & MCA_MEM_FLAGS_BANK)
		show_value(6, "bank", "0x%04x", mem->mem_bank);
	if (mem->mem_flags & MCA_MEM_FLAGS_DEVICE)
		show_value(6, "device", "0x%04x", mem->mem_device);
	if (mem->mem_flags & MCA_MEM_FLAGS_ROW)
		show_value(6, "row", "0x%04x", mem->mem_row);
	if (mem->mem_flags & MCA_MEM_FLAGS_COLUMN)
		show_value(6, "column", "0x%04x", mem->mem_column);
	if (mem->mem_flags & MCA_MEM_FLAGS_BITPOS)
		show_value(6, "bit", "0x%04x", mem->mem_bitpos);
	if (mem->mem_flags & MCA_MEM_FLAGS_REQID)
		show_value(6, "requester", "0x%016llx",
		    (long long)mem->mem_reqid);
	if (mem->mem_flags & MCA_MEM_FLAGS_RSPID)
		show_value(6, "responder", "0x%016llx",
		    (long long)mem->mem_rspid);
	if (mem->mem_flags & MCA_MEM_FLAGS_TGTID)
		show_value(6, "target", "0x%016llx",
		    (long long)mem->mem_tgtid);
	if (mem->mem_flags & MCA_MEM_FLAGS_BUSDATA)
		show_value(6, "status", "0x%016llx",
		    (long long)mem->mem_busdata);
	if (mem->mem_flags & MCA_MEM_FLAGS_OEM_ID)
		show_value(6, "oem", "%s", uuid(&mem->mem_oem_id));
	/* TODO: Dump OEM data */

	printf("    </memory>\n");
}
Exemplo n.º 10
0
result_t ls_path_recursive_action(cli_t *context, const char * path)
  {
  uint16_t indent = 0;
  result_t result;
  memid_t key;
  handle_t matches = 0;

  bool recursive = strlen(context->tokens[2].token_buffer) != 0;

  if (strlen(path) == 0)
    {
    show_key(context->cfg.console_out, get_context(context), true, false, &indent);
    return s_ok;
    }

  // expand wildcards
  if (failed(result = match_path(context, path, true, &key, &matches)))
    return result;

  // work over each one.
  field_datatype dt = 0;
  memid_t child = 0;
  uint16_t i;
  char name[REG_NAME_MAX + 1];

  if (matches == 0)
    {
    // this is the case when a directory is given and no search
    show_key(context->cfg.console_out, key, false, recursive, &indent);
    }
  else
    {
    // decide what to do
    uint16_t len;
    if (failed(result = vector_count(matches, &len)))
      {
      kfree_split(matches);
      return result;
      }

    for (i = 0; i < len; i++)
      {
      const char * name;
      if (failed(result = vector_at(matches, i, &name)))
        {
        kfree_split(matches);
        return result;
        }

      if (failed(result = reg_query_child(key, name, &child, &dt, 0)))
        {
        if (result == e_not_found)
          continue;      // very weird!

        kfree_split(matches);
        return result;
        }

      if (dt > field_key)
        show_value(context->cfg.console_out, child, dt, name, &indent, 0);
      }

    bool needs_newline = true;

    // now the directories
    for (i = 0; i < len; i++)
      {
      const char * name;
      if (failed(result = vector_at(matches, i, &name)))
        {
        kfree_split(matches);
        return result;
        }

      if (failed(result = reg_query_child(key, name, &child, &dt, 0)))
        {
        if (result == e_not_found)
          continue;      // very weird!

        kfree_split(matches);
        return result;
        }

      if (dt == field_key)
        {
        if (needs_newline)
          {
          stream_puts(context->cfg.console_out, cr_lf);
          stream_printf(context->cfg.console_out, "dir %s\r\n", name);
          }
        indent += 2;
        show_key(context->cfg.console_out, child, false, recursive, &indent);
        }
      }

    kfree_split(matches);
    }
  return s_ok;
  }
Exemplo n.º 11
0
Arquivo: hfsdump.c Projeto: Shmuma/z
int dump_by_meta(const char *metafile)
{
	void 		*val;
	size_t		val_len;
	item_value_u 	val_history;
	hfs_trend_t  	val_trends;

	int fd, i;
	char *datafile = NULL;
	hfs_meta_t *meta = NULL;
	hfs_meta_item_t *ip = NULL;
	hfs_time_t ts;
	hfs_off_t ofs;

	if ((meta = read_metafile(metafile, NULL)) == NULL)
		return -1; // Somethig real bad happend :(

	if (meta->blocks == 0) {
		fprintf(stderr, "%s: No data!\n", metafile);
		free_meta(meta);
		return -1;
	}

	if (is_trend_type(meta->last_type)) {
		val = &val_trends;
		val_len = sizeof(val_trends);
	}
	else {
		val = &val_history;
		val_len = sizeof(val_history);
	}

	datafile = get_datafile(metafile);     

	if ((fd = open (datafile, O_RDONLY)) == -1) {
		fprintf(stderr, "%s: file open failed: %s\n", datafile, strerror(errno));
		free_meta(meta);
		free(datafile);
		return -1;
	}

	for (i = 0; i < meta->blocks; i++) {
		ip = meta->meta + i;
		ts = ip->start;

		if ((ofs = find_meta_ofs (ts, meta, NULL)) == -1) {
			fprintf(stderr, "%s: %d: unable to get offset in file\n",
				datafile, (int)ts);
			free_meta(meta);
			free(datafile);
			close(fd);
			return -1;
		}

		if (lseek (fd, ofs, SEEK_SET) == -1) {
			fprintf(stderr, "%s: unable to change file offset: %s\n",
				datafile, strerror(errno));
			free_meta(meta);
			free(datafile);
			close(fd);
			return -1;
		}

		while (read (fd, val, val_len) > 0) {

			if (!is_valid_val(val, val_len)) {
				ts += ip->delay;
				continue;
			}

			printf("time=%d\tdelay=%d\ttype=%d\t",
				(int)ts, ip->delay, ip->type);

			if (is_trend_type(ip->type)) {
				printf("count=%d\tmax=", val_trends.count);
				show_value(ip->type, val_trends.max);
				printf("\tmin=");
				show_value(ip->type, val_trends.min);
				printf("\tavg=");
				show_value(ip->type, val_trends.avg);
			}
			else {
				printf("value=");
				show_value(ip->type, val_history);
			}
			printf("\n");
			ts += ip->delay;

			if (ts > ip->end)
				break;
		}
	}

	free_meta(meta);
	free(datafile);
	close(fd);
	return 0;
}