#include #include #include /* Turn this on/off to see how it would look like on 32 or 64 bit */ #define CONFIG_X86_64 #ifdef CONFIG_X86_64 #else #pragma pack(4) #endif #define __DEFINE_GUEST_HANDLE(name, type) \ typedef struct { type *p; } __guest_handle_ ## name #define DEFINE_GUEST_HANDLE_STRUCT(name) \ __DEFINE_GUEST_HANDLE(name, struct name) #define DEFINE_GUEST_HANDLE(name) __DEFINE_GUEST_HANDLE(name, name) #define GUEST_HANDLE(name) __guest_handle_ ## name struct xen_power_register { uint32_t space_id; uint32_t bit_width; uint32_t bit_offset; uint32_t access_size; uint64_t address; }; struct xen_processor_csd { uint32_t domain; /* domain number of one dependent group */ uint32_t coord_type; /* coordination type */ uint32_t num; /* number of processors in same domain */ }; DEFINE_GUEST_HANDLE_STRUCT(xen_processor_csd); struct xen_processor_cx { struct xen_power_register reg; /* GAS for Cx trigger register */ uint8_t type; /* cstate value, c0: 0, c1: 1, ... */ // FIX: Mega pad. No 64/32 bit problems. uint8_t _pad1[3]; uint32_t latency; /* worst latency (ms) to enter/exit this cstate */ uint32_t power; /* average power consumption(mW) */ uint32_t dpcnt; /* number of dependency entries */ GUEST_HANDLE(xen_processor_csd) dp; /* NULL if no dependency */ }; DEFINE_GUEST_HANDLE_STRUCT(xen_processor_cx); struct xen_processor_flags { uint32_t bm_control:1; uint32_t bm_check:1; uint32_t has_cst:1; uint32_t power_setup_done:1; uint32_t bm_rld_set:1; }; struct xen_processor_power { uint32_t count; /* number of C state entries in array below */ struct xen_processor_flags flags; /* global flags of this processor */ GUEST_HANDLE(xen_processor_cx) states; /* supported c states */ }; struct xen_pct_register { uint8_t descriptor; // FIX: Do not memcpy the (acpi_pct_register) as its packing is different */ uint8_t _pad1; /* ARGH */ uint16_t length; uint8_t space_id; uint8_t bit_width; uint8_t bit_offset; uint8_t reserved; uint64_t address; } __attribute__((__packed__)); struct xen_processor_px { uint64_t core_frequency; /* megahertz */ uint64_t power; /* milliWatts */ uint64_t transition_latency; /* microseconds */ uint64_t bus_master_latency; /* microseconds */ uint64_t control; /* control value */ uint64_t status; /* success indicator */ }; DEFINE_GUEST_HANDLE_STRUCT(xen_processor_px); struct xen_psd_package { uint64_t num_entries; uint64_t revision; uint64_t domain; uint64_t coord_type; uint64_t num_processors; } struct xen_processor_performance { uint32_t flags; /* flag for Px sub info type */ uint32_t platform_limit; /* Platform limitation on freq usage */ struct xen_pct_register control_register; struct xen_pct_register status_register; uint32_t state_count; /* total available performance states */ #ifndef CONFIG_X86_64 // FIX uint32_t pad1; #endif GUEST_HANDLE(xen_processor_px) states; struct xen_psd_package domain_info; uint32_t shared_type; /* coordination type of this processor */ #ifndef CONFIG_X86_64 // FIX uint32_t pad2; #endif }; int main(void) { printf("%d==104|96 %d==16 %d==40 %d==16 %d==48\n", sizeof(struct xen_processor_performance), /* 104 when 64, 96 when 32 */ sizeof(struct xen_pct_register), sizeof(struct xen_psd_package), sizeof(struct xen_processor_power), sizeof(struct xen_processor_cx)); printf("%d==0, %d==4, %d==10,%d==26 %d==40\n", offsetof(struct xen_processor_performance, flags), offsetof(struct xen_processor_performance, platform_limit), offsetof(struct xen_processor_performance, control_register.length), offsetof(struct xen_processor_performance, status_register.length), offsetof(struct xen_processor_performance, state_count)); printf("%d==48|44, %d==56|52 %d==96|92\n", offsetof(struct xen_processor_performance, states), offsetof(struct xen_processor_performance, domain_info), offsetof(struct xen_processor_performance, shared_type)); printf("%d==4, %d==8\n", offsetof(struct xen_processor_power, flags), offsetof(struct xen_processor_power, states)); printf("%d==0 %d==0 %d==4 %d==16 %d==24 %d==28 %d==32 %d==36\n", offsetof(struct xen_processor_cx, reg), offsetof(struct xen_processor_cx, reg.space_id), offsetof(struct xen_processor_cx, reg.bit_width), offsetof(struct xen_processor_cx, reg.address), offsetof(struct xen_processor_cx, type), // 16 offsetof(struct xen_processor_cx, latency), // 24 offsetof(struct xen_processor_cx, power), // 28 offsetof(struct xen_processor_cx, dpcnt), //32 offsetof(struct xen_processor_cx, dp)); //36 return 0; }