std::string hw::PCI_Device::to_string() const { std::stringstream str; str << PCI::classcode_str(classcode()) << ", " << PCI::vendor_str((PCI::vendor_t)vendor_id()) << std::hex << " ("<< vendor_id() << " / " << product_id() << ")"; return str.str(); };
std::string hw::PCI_Device::to_string() const { char buffer[512]; int len = snprintf(buffer, sizeof(buffer), "%s %s (V %#x / P %#x)", PCI::classcode_str(classcode()), PCI::vendor_str((PCI::vendor_t)vendor_id()), vendor_id(), product_id()); return std::string(buffer, len); }
void update_device_identifiers(void) { device_identifiers_ = std::make_shared<device_identifiers>( vendor_id_.value_or(vendor_id(0)), product_id_.value_or(product_id(0)), is_keyboard_.value_or(false), is_pointing_device_.value_or(false)); }
/* EAX = 0000 0000 */ static void handle_std_base(struct cpu_regs_t *regs, struct cpuid_state_t *state) { char buf[13]; size_t i; state->curmax = regs->eax; printf("Maximum basic CPUID leaf: 0x%08x\n\n", state->curmax); *(uint32_t *)(&buf[0]) = regs->ebx; *(uint32_t *)(&buf[4]) = regs->edx; *(uint32_t *)(&buf[8]) = regs->ecx; buf[12] = 0; for (i = 0; i < sizeof(buf); i++) { /* End of vendor string */ if (buf[i] == 0) break; /* Character outside printable range */ if (buf[i] < 0x20 || buf[i] > 0x7E) buf[i] = '.'; } buf[12] = 0; printf("CPU vendor string: '%s'", buf); if (state->vendor == VENDOR_UNKNOWN ) { state->vendor = vendor_id(buf); } else { printf(" (overridden as '%s')", vendor_name(state->vendor)); } printf("\n\n"); }
PCI_Device::PCI_Device(const uint16_t pci_addr, const uint32_t device_id, const uint32_t devclass) : pci_addr_{pci_addr}, device_id_{device_id} { // set master, mem and io flags uint32_t cmd = read_dword(PCI_CMD_REG); cmd |= PCI_COMMAND_MASTER | PCI_COMMAND_MEM | PCI_COMMAND_IO; write_dword(PCI_CMD_REG, cmd); // device class info is coming from pci manager to save a PCI read this->devtype_.reg = devclass; INFO2("|"); switch (PCI::classcode(devtype_.classcode)) { case PCI::classcode::BRIDGE: INFO2("+--[ %s, %s, %s (0x%x) ]", PCI::classcode_str(classcode()), PCI::vendor_str(vendor_id()), bridge_subclasses[devtype_.subclass < SS_BR ? devtype_.subclass : SS_BR-1], devtype_.subclass); break; case PCI::classcode::NIC: INFO2("+--[ %s, %s, %s (0x%x) ]", PCI::classcode_str(devtype_.classcode), PCI::vendor_str(vendor_id()), nic_subclasses[devtype_.subclass < SS_NIC ? devtype_.subclass : SS_NIC-1], devtype_.subclass); break; default: INFO2("+--[ %s, %s ]", PCI::classcode_str(devtype_.classcode), PCI::vendor_str(vendor_id())); } //< switch (devtype_.classcode) // bridges are different from other PCI devices if (classcode() == PCI::classcode::BRIDGE) return; }
bool benchmark::write_test_data_csv( const char * file_name, const base::stats_data & stats, const float time, const int nframes, bool is_dummy) { FILE * pFile; pFile = fopen(file_name, "r+"); if (pFile == NULL){ pFile = fopen(file_name, "w"); if (pFile == NULL){ return false; } fputs( "test_name," "gpu_gl_name," "use_vbo," "tex_freq," "tex_mode," "mesh_size," "one_mesh," "frames," "render_time," "cpu_render_time (ms)," "gpu_render_time (ms)," "dc," "ntri (Mtri)," "nverts (Mvtx)," "buf_mem (MB)," "tex_mem (MB)," "gpu_vendor," "gpu_drv_ver," "gpu_vendor_id," "gpu_device_id," "gpu_rev_id," "test_status", pFile); } else{ fseek(pFile, 0, SEEK_END); } if (!is_dummy){ std::ostringstream oss; std::string vendor_id(""); std::string device_id(""); std::string rev_id(""); oss << std::hex << _renderer->get_vendor_id(); vendor_id = oss.str(); oss.str(""); oss << std::hex << _renderer->get_device_id(); device_id = oss.str(); oss.str(""); oss << std::hex << _renderer->get_rev_id(); rev_id = oss.str(); oss.str(""); fprintf( pFile, "\n%s,%s,%s,%i,%u,%i,%s,%u,%f,%f,%f,%u,%llu,%llu,%u,%u,%s,%s,%s,%s,%s,OK", this->get_test_name(), _renderer->get_gpu_str(), base::cfg().use_vbo ? "true" : "false", base::cfg().tex_freq, base::cfg().tex_mode, base::cfg().mesh_size*16, base::cfg().one_mesh ? "true" : "false", nframes, time, stats._cpu_time, stats._gpu_time, stats._ndrawcalls, stats._ntriangles, stats._nvertices, stats._buffer_mem >> 20, stats._texture_mem >> 20, _renderer->get_gpu_vendor_str(), _renderer->get_gpu_driver_str(), vendor_id.c_str(), device_id.c_str(), rev_id.c_str()); }
int main(int argc, char **argv) { const char *file = NULL; struct cpuid_state_t state; int c, ret = 0; int cpu_start = -2, cpu_end = -2; INIT_CPUID_STATE(&state); while (TRUE) { static struct option long_options[] = { {"version", no_argument, 0, 'v'}, {"help", no_argument, 0, 'h'}, {"sanity", no_argument, &do_sanity, 1}, {"dump", no_argument, &do_dump, 1}, {"cpu", required_argument, 0, 'c'}, {"kernel", no_argument, &do_kernel, 'k'}, {"ignore-vendor", no_argument, &ignore_vendor, 1}, {"vendor", required_argument, 0, 'V'}, {"parse", required_argument, 0, 'f'}, {"format", required_argument, 0, 'o'}, {"scan-to", required_argument, 0, 2}, {0, 0, 0, 0} }; int option_index = 0; c = getopt_long(argc, argv, "c:hdvV:o:f:", long_options, &option_index); if (c == -1) break; switch (c) { case 0: break; case 2: assert(optarg); if (sscanf(optarg, "0x%x", &scan_to) != 1) if (sscanf(optarg, "%u", &scan_to) != 1) if (sscanf(optarg, "%x", &scan_to) != 1) scan_to = 0; break; case 'c': assert(optarg); if (sscanf(optarg, "%d", &cpu_start) != 1) { printf("Option --cpu= requires an integer parameter.\n"); exit(1); } if (cpu_start < -1) { printf("Option --cpu= requires a value >= -1.\n"); exit(1); } break; case 'd': do_dump = 1; if (cpu_start == -2 && cpu_end == -2) cpu_start = -1; break; case 'f': file = optarg; break; case 'o': assert(optarg); for (c = 0; formats[c].name != NULL; c++) { if (0 == strcmp(optarg, formats[c].name)) { do_dump = 1; dump_format = formats[c].value; break; } } if (!formats[c].name) { printf("Unrecognized format: '%s'\n", optarg); exit(1); } break; case 'V': assert(optarg); state.vendor = vendor_id(optarg); break; case 'v': version(); /* falls through */ case 'h': case '?': default: usage(argv[0]); } } if (cpu_start == -2) cpu_start = cpu_end = 0; if (do_sanity && !file) { state.thread_bind(&state, 0); ret = sanity_run(&state); goto leave; } switch(dump_format) { case DUMP_FORMAT_DEFAULT: state.cpuid_print = cpuid_dump_normal; break; case DUMP_FORMAT_VMWARE: cpu_start = 0; state.cpuid_print = cpuid_dump_vmware; break; case DUMP_FORMAT_XEN: cpu_start = 0; state.cpuid_print = cpuid_dump_xen; printf("cpuid = [\n"); break; case DUMP_FORMAT_XEN_SXP: cpu_start = 0; state.cpuid_print = cpuid_dump_xen_sxp; printf("(\n"); break; case DUMP_FORMAT_ETALLEN: state.cpuid_print = cpuid_dump_etallen; break; } if (file) { cpuid_load_from_file(file, &state); state.cpuid_call = cpuid_stub; state.thread_init = thread_init_stub; state.thread_bind = thread_bind_stub; state.thread_count = thread_count_stub; #ifdef __linux__ } else if (do_kernel) { state.cpuid_call = cpuid_kernel; #endif } state.thread_init(); if (cpu_start == -1) { cpu_start = 0; cpu_end = state.thread_count(&state) - 1; #ifdef TARGET_OS_MACOSX /* Because thread_bind() doesn't work on Mac. Stupidest * operating system design ever. */ if (!file) { cpu_start = 0; cpu_end = 0; } #endif } else { cpu_end = cpu_start; } if ((uint32_t)cpu_start >= state.thread_count(&state)) { printf("CPU %d doesn't seem to exist.\n", cpu_start); exit(1); } for (c = cpu_start; c <= cpu_end; c++) { state.thread_bind(&state, c); switch(dump_format) { case DUMP_FORMAT_DEFAULT: case DUMP_FORMAT_ETALLEN: printf("CPU %d:\n", c); break; } run_cpuid(&state, do_dump); } switch (dump_format) { case DUMP_FORMAT_XEN: printf("]\n"); break; case DUMP_FORMAT_XEN_SXP: printf(")\n"); break; } leave: FREE_CPUID_STATE(&state); return ret; }