source: trunk/packages/xen-3.1/xen-3.1/xen/arch/x86/sysctl.c @ 34

Last change on this file since 34 was 34, checked in by hartmans, 18 years ago

Add xen and xen-common

File size: 1.8 KB
Line 
1/******************************************************************************
2 * Arch-specific sysctl.c
3 *
4 * System management operations. For use by node control stack.
5 *
6 * Copyright (c) 2002-2006, K Fraser
7 */
8
9#include <xen/config.h>
10#include <xen/types.h>
11#include <xen/lib.h>
12#include <xen/mm.h>
13#include <xen/guest_access.h>
14#include <public/sysctl.h>
15#include <xen/sched.h>
16#include <xen/event.h>
17#include <xen/domain_page.h>
18#include <asm/msr.h>
19#include <xen/trace.h>
20#include <xen/console.h>
21#include <xen/iocap.h>
22#include <asm/irq.h>
23#include <asm/hvm/hvm.h>
24#include <asm/hvm/support.h>
25#include <asm/processor.h>
26
27long arch_do_sysctl(
28    struct xen_sysctl *sysctl, XEN_GUEST_HANDLE(xen_sysctl_t) u_sysctl)
29{
30    long ret = 0;
31
32    switch ( sysctl->cmd )
33    {
34
35    case XEN_SYSCTL_physinfo:
36    {
37        xen_sysctl_physinfo_t *pi = &sysctl->u.physinfo;
38
39        pi->threads_per_core =
40            cpus_weight(cpu_sibling_map[0]);
41        pi->cores_per_socket =
42            cpus_weight(cpu_core_map[0]) / pi->threads_per_core;
43        pi->sockets_per_node = 
44            num_online_cpus() / cpus_weight(cpu_core_map[0]);
45
46        pi->nr_nodes         = 1;
47        pi->total_pages      = total_pages;
48        pi->free_pages       = avail_domheap_pages();
49        pi->scrub_pages      = avail_scrub_pages();
50        pi->cpu_khz          = cpu_khz;
51        memset(pi->hw_cap, 0, sizeof(pi->hw_cap));
52        memcpy(pi->hw_cap, boot_cpu_data.x86_capability, NCAPINTS*4);
53        ret = 0;
54        if ( copy_to_guest(u_sysctl, sysctl, 1) )
55            ret = -EFAULT;
56    }
57    break;
58   
59
60    default:
61        ret = -ENOSYS;
62        break;
63    }
64
65    return ret;
66}
67
68/*
69 * Local variables:
70 * mode: C
71 * c-set-style: "BSD"
72 * c-basic-offset: 4
73 * tab-width: 4
74 * indent-tabs-mode: nil
75 * End:
76 */
Note: See TracBrowser for help on using the repository browser.