Revision dc333cd6
b/hw/ppc.h | ||
---|---|---|
46 | 46 |
#define FW_CFG_PPC_WIDTH (FW_CFG_ARCH_LOCAL + 0x00) |
47 | 47 |
#define FW_CFG_PPC_HEIGHT (FW_CFG_ARCH_LOCAL + 0x01) |
48 | 48 |
#define FW_CFG_PPC_DEPTH (FW_CFG_ARCH_LOCAL + 0x02) |
49 |
#define FW_CFG_PPC_TBFREQ (FW_CFG_ARCH_LOCAL + 0x03) |
|
49 | 50 |
|
50 | 51 |
#define PPC_SERIAL_MM_BAUDBASE 399193 |
b/hw/ppc_newworld.c | ||
---|---|---|
64 | 64 |
#include "loader.h" |
65 | 65 |
#include "elf.h" |
66 | 66 |
#include "kvm.h" |
67 |
#include "kvm_ppc.h" |
|
67 | 68 |
|
68 | 69 |
#define MAX_IDE_BUS 2 |
69 | 70 |
#define VGA_BIOS_SIZE 65536 |
... | ... | |
413 | 414 |
fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_HEIGHT, graphic_height); |
414 | 415 |
fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_DEPTH, graphic_depth); |
415 | 416 |
|
417 |
if (kvm_enabled()) { |
|
418 |
#ifdef CONFIG_KVM |
|
419 |
fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_TBFREQ, kvmppc_get_tbfreq()); |
|
420 |
#endif |
|
421 |
} else { |
|
422 |
fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_TBFREQ, get_ticks_per_sec()); |
|
423 |
} |
|
424 |
|
|
416 | 425 |
qemu_register_boot_set(fw_cfg_boot_set, fw_cfg); |
417 | 426 |
} |
418 | 427 |
|
b/hw/ppc_oldworld.c | ||
---|---|---|
40 | 40 |
#include "loader.h" |
41 | 41 |
#include "elf.h" |
42 | 42 |
#include "kvm.h" |
43 |
#include "kvm_ppc.h" |
|
43 | 44 |
|
44 | 45 |
#define MAX_IDE_BUS 2 |
45 | 46 |
#define VGA_BIOS_SIZE 65536 |
... | ... | |
401 | 402 |
fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_HEIGHT, graphic_height); |
402 | 403 |
fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_DEPTH, graphic_depth); |
403 | 404 |
|
405 |
if (kvm_enabled()) { |
|
406 |
#ifdef CONFIG_KVM |
|
407 |
fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_TBFREQ, kvmppc_get_tbfreq()); |
|
408 |
#endif |
|
409 |
} else { |
|
410 |
fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_TBFREQ, get_ticks_per_sec()); |
|
411 |
} |
|
412 |
|
|
404 | 413 |
qemu_register_boot_set(fw_cfg_boot_set, fw_cfg); |
405 | 414 |
} |
406 | 415 |
|
b/target-ppc/kvm.c | ||
---|---|---|
252 | 252 |
return ret; |
253 | 253 |
} |
254 | 254 |
|
255 |
static int read_cpuinfo(const char *field, char *value, int len) |
|
256 |
{ |
|
257 |
FILE *f; |
|
258 |
int ret = -1; |
|
259 |
int field_len = strlen(field); |
|
260 |
char line[512]; |
|
261 |
|
|
262 |
f = fopen("/proc/cpuinfo", "r"); |
|
263 |
if (!f) { |
|
264 |
return -1; |
|
265 |
} |
|
266 |
|
|
267 |
do { |
|
268 |
if(!fgets(line, sizeof(line), f)) { |
|
269 |
break; |
|
270 |
} |
|
271 |
if (!strncmp(line, field, field_len)) { |
|
272 |
strncpy(value, line, len); |
|
273 |
ret = 0; |
|
274 |
break; |
|
275 |
} |
|
276 |
} while(*line); |
|
277 |
|
|
278 |
fclose(f); |
|
279 |
|
|
280 |
return ret; |
|
281 |
} |
|
282 |
|
|
283 |
uint32_t kvmppc_get_tbfreq(void) |
|
284 |
{ |
|
285 |
char line[512]; |
|
286 |
char *ns; |
|
287 |
uint32_t retval = get_ticks_per_sec(); |
|
288 |
|
|
289 |
if (read_cpuinfo("timebase", line, sizeof(line))) { |
|
290 |
return retval; |
|
291 |
} |
|
292 |
|
|
293 |
if (!(ns = strchr(line, ':'))) { |
|
294 |
return retval; |
|
295 |
} |
|
296 |
|
|
297 |
ns++; |
|
298 |
|
|
299 |
retval = atoi(ns); |
|
300 |
return retval; |
|
301 |
} |
b/target-ppc/kvm_ppc.h | ||
---|---|---|
14 | 14 |
int kvmppc_read_host_property(const char *node_path, const char *prop, |
15 | 15 |
void *val, size_t len); |
16 | 16 |
|
17 |
uint32_t kvmppc_get_tbfreq(void); |
|
18 |
|
|
17 | 19 |
#endif /* __KVM_PPC_H__ */ |
Also available in: Unified diff