예제 #1
0
파일: machine.c 프로젝트: fgaud/Miniprof
void get_available_msr(void) {
   if(available_msrs)
      return;

   int i;
   unsigned int family = get_processor_family();

   switch(family) {
   case 0x100f00: /* AMD fam10h, see AMD BKDG 10h, section 2.16.1 */
      msr_count = 4;
      available_msrs = malloc(msr_count * sizeof(*available_msrs));
      available_msr_usage = malloc(msr_count * sizeof(*available_msr_usage));
      for(i = 0; i < msr_count; i++) {
         available_msrs[i].id = i;
         available_msrs[i].select =  0xC0010000 + i;
         available_msrs[i].value =  0xC0010000 + i + 4;
         available_msrs[i].can_be_used = can_be_used_10h;
         available_msr_usage[i] = calloc(ncpus, sizeof(*available_msr_usage[i]));
      }
      break;
   case 0x600f00: /* 15h */
      msr_count = 10;
      available_msrs = malloc(msr_count * sizeof(*available_msrs));
      available_msr_usage = malloc(msr_count * sizeof(*available_msr_usage));
      for(i = 0; i < 6; i++) {
         available_msrs[i].id = i;
         available_msrs[i].select =  0xC0010200 + 2 * i;
         available_msrs[i].value =  0xC0010200 + 2 * i + 1;
         available_msrs[i].can_be_used = can_be_used_15h;
         available_msr_usage[i] = calloc(ncpus, sizeof(*available_msr_usage[i]));
      }
      for(i = 6; i < msr_count; i++) {
         available_msrs[i].id = i;
         available_msrs[i].select =  0xC0010240 + 2 * (i - 6);
         available_msrs[i].value =  0xC0010240 + 2 * (i - 6) + 1;
         available_msrs[i].can_be_used = can_be_used_15h;
         available_msr_usage[i] = calloc(ncpus, sizeof(*available_msr_usage[i]));
      }
      break;
   default:
      die("Unsupported processor family (%d)\n", family);
   }
}
예제 #2
0
파일: processor.c 프로젝트: adrianomelo/ldc
void set_processor_device(struct device *device)
{
	if (device == NULL)
		return;

	int processors_count = get_processors_count();	//returns at least 1;
	struct device *processors[processors_count];

	int i;
	for (i = 0; i < processors_count; i++) {
		processors[i] = new_device("Processor");
		add_info(processors[i], get_processor_family(i));
		add_info(processors[i], get_processor_version(i));
		add_info(processors[i], get_processor_socket_designation(i));
		add_info(processors[i], get_processor_manufacturer(i));
		add_info(processors[i], get_processor_id(i));
		add_info(processors[i], get_processor_voltage(i));
		add_info(processors[i], get_processor_external_clock(i));
		set_child(device, processors[i]);
	}

	set_caches(processors, processors_count);
	set_cores(processors, processors_count);
}
예제 #3
0
static CMPIrc hostprocessor_set_properties(provider_resource *resource, 
                                    xen_host_record *host_rec, 
                                    CMPIInstance *inst)
{
    char buf[MAX_INSTANCEID_LEN];
    xen_host_cpu_record *cpu_rec = (xen_host_cpu_record *)resource->ctx;
    _CMPICreateNewDeviceInstanceID(buf, sizeof(buf), host_rec->uuid, cpu_rec->uuid);
    CMSetProperty(inst, "DeviceID",(CMPIValue *)buf, CMPI_chars);
    CMSetProperty(inst, "SystemCreationClassName",(CMPIValue *)"Xen_HostComputerSystem", CMPI_chars);
    CMSetProperty(inst, "SystemName",(CMPIValue *)host_rec->uuid, CMPI_chars);
    CMSetProperty(inst, "CreationClassName",(CMPIValue *)"Xen_HostProcessor", CMPI_chars);

    /* Populate the instance's properties with the backend data */
    //CMPIArray *arr = CMNewArray(_BROKER, 1, CMPI_uint16, NULL);
    //CMSetArrayElementAt(arr, 0, (CMPIValue *)&<value>, CMPI_uint16);
    //CMSetProperty(inst, "AdditionalAvailability",(CMPIValue *)&arr, CMPI_uint16A);
    //CMSetProperty(inst, "AddressWidth",(CMPIValue *)&<value>, CMPI_uint16);
    DMTF_Availability avail = DMTF_Availability_Running_Full_Power;
    CPUStatus cpuStatus =  CPUStatus_CPU_Enabled;
    DMTF_EnabledState eState = DMTF_EnabledState_Enabled;
    if(!host_rec->enabled)
    {
        avail = DMTF_Availability_Off_Line;
        cpuStatus = CPUStatus_Other;
        eState = DMTF_EnabledState_Disabled;
    }

    CMSetProperty(inst, "Availability",(CMPIValue *)&avail, CMPI_uint16);
    CMSetProperty(inst, "Caption",(CMPIValue *)"Xen Host Processor", CMPI_chars);
    CMSetProperty(inst, "CPUStatus",(CMPIValue *)&cpuStatus, CMPI_uint16);
    CMSetProperty(inst, "CurrentClockSpeed",(CMPIValue *)&cpu_rec->speed, CMPI_uint32);
    //CMSetProperty(inst, "DataWidth",(CMPIValue *)&<value>, CMPI_uint16);
    CMSetProperty(inst, "Description",(CMPIValue *)cpu_rec->modelname, CMPI_chars);
    char model[4];

#if XENAPI_VERSION > 400
    sprintf(model, "%3" PRId64, cpu_rec->model);
#endif
    CMSetProperty(inst, "ElementName",(CMPIValue *)cpu_rec->vendor, CMPI_chars);
    DMTF_EnabledDefault eDefault = DMTF_EnabledDefault_Enabled;
    CMSetProperty(inst, "EnabledDefault",(CMPIValue *)&eDefault, CMPI_uint16);
    CMSetProperty(inst, "EnabledState",(CMPIValue *)&eState, CMPI_uint16);
    //CMSetProperty(inst, "ErrorCleared",(CMPIValue *)&<value>, CMPI_boolean);
    //CMSetProperty(inst, "ErrorDescription",(CMPIValue *)<value>, CMPI_chars);

#if XENAPI_VERSION > 400
    Family family = get_processor_family(cpu_rec->family, cpu_rec->vendor, cpu_rec->modelname);
    CMSetProperty(inst, "Family",(CMPIValue *)&family, CMPI_uint16);
#endif
    DMTF_HealthState hState = DMTF_HealthState_OK;
    CMSetProperty(inst, "HealthState",(CMPIValue *)&hState, CMPI_uint16);
    //CMPIArray *arr = CMNewArray(_BROKER, 1, CMPI_chars, NULL);
    //CMSetArrayElementAt(arr, 0, (CMPIValue *)<value>, CMPI_chars);
    //CMSetProperty(inst, "IdentifyingDescriptions",(CMPIValue *)&arr, CMPI_charsA);
    //CMPIDateTime *date_time = xen_utils_time_t_to_CMPIDateTime(_BROKER, &<time_value>);
    //CMSetProperty(inst, "InstallDate",(CMPIValue *)&date_time, CMPI_dateTime);
    //CMSetProperty(inst, "LastErrorCode",(CMPIValue *)&<value>, CMPI_uint32);
    int load_percentage = cpu_rec->utilisation * 100;
    CMSetProperty(inst, "LoadPercentage", (CMPIValue *) &load_percentage, CMPI_uint16);
    CMSetProperty(inst, "MaxClockSpeed",(CMPIValue *)&cpu_rec->speed, CMPI_uint32);
    //CMSetProperty(inst, "MaxQuiesceTime",(CMPIValue *)&<value>, CMPI_uint64);
    CMSetProperty(inst, "Name",(CMPIValue *)cpu_rec->vendor, CMPI_chars);
    //CMPIArray *arr = CMNewArray(_BROKER, 1, CMPI_uint16, NULL);
    //CMSetArrayElementAt(arr, 0, (CMPIValue *)&<value>, CMPI_uint16);
    //CMSetProperty(inst, "OperationalStatus",(CMPIValue *)&arr, CMPI_uint16A);
    //CMSetProperty(inst, "OtherEnabledState",(CMPIValue *)<value>, CMPI_chars);
    //CMSetProperty(inst, "OtherFamilyDescription",(CMPIValue *)<value>, CMPI_chars);
    //CMPIArray *arr = CMNewArray(_BROKER, 1, CMPI_chars, NULL);
    //CMSetArrayElementAt(arr, 0, (CMPIValue *)<value>, CMPI_chars);
    //CMSetProperty(inst, "OtherIdentifyingInfo",(CMPIValue *)&arr, CMPI_charsA);
    //CMPIArray *arr = CMNewArray(_BROKER, 1, CMPI_uint16, NULL);
    //CMSetArrayElementAt(arr, 0, (CMPIValue *)&<value>, CMPI_uint16);
    //CMSetProperty(inst, "PowerManagementCapabilities",(CMPIValue *)&arr, CMPI_uint16A);
    //CMSetProperty(inst, "PowerManagementSupported",(CMPIValue *)&<value>, CMPI_boolean);
    //CMSetProperty(inst, "PowerOnHours",(CMPIValue *)&<value>, CMPI_uint64);
    //CMSetProperty(inst, "RequestedState",(CMPIValue *)&<value>, CMPI_uint16);
    //CMSetProperty(inst, "Role",(CMPIValue *)<value>, CMPI_chars);
    CMSetProperty(inst, "Status",(CMPIValue *)DMTF_Status_OK, CMPI_chars);
    //CMPIArray *arr = CMNewArray(_BROKER, 1, CMPI_chars, NULL);
    //CMSetArrayElementAt(arr, 0, (CMPIValue *)<value>, CMPI_chars);
    //CMSetProperty(inst, "StatusDescriptions",(CMPIValue *)&arr, CMPI_charsA);
    //CMSetProperty(inst, "StatusInfo",(CMPIValue *)&<value>, CMPI_uint16);
    CMSetProperty(inst, "Stepping",(CMPIValue *)cpu_rec->stepping, CMPI_chars);
    //CMPIDateTime *date_time = xen_utils_time_t_to_CMPIDateTime(_BROKER, &<time_value>);
    //CMSetProperty(inst, "TimeOfLastStateChange",(CMPIValue *)&date_time, CMPI_dateTime);
    //CMSetProperty(inst, "TotalPowerOnHours",(CMPIValue *)&<value>, CMPI_uint64);
    CMSetProperty(inst, "UniqueID",(CMPIValue *)cpu_rec->uuid, CMPI_chars);
    //CMSetProperty(inst, "UpgradeMethod",(CMPIValue *)&<value>, CMPI_uint16);

    if(!cpu_rec->host->is_record)
        xen_host_record_free(host_rec);

    return CMPI_RC_OK;
}