X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/bd504ef0e0b883cdd7917b73b3574eb9ce669905..39236c6e673c41db228275375ab7fdb0f837b292:/bsd/dev/dtrace/scripts/sched.d diff --git a/bsd/dev/dtrace/scripts/sched.d b/bsd/dev/dtrace/scripts/sched.d new file mode 100644 index 000000000..d86772554 --- /dev/null +++ b/bsd/dev/dtrace/scripts/sched.d @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2006-2008 Apple Computer, Inc. All Rights Reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +#pragma D depends_on library darwin.d +#pragma D depends_on module mach_kernel +#pragma D depends_on provider sched + +struct _processor_info { + int pi_state; /* processor state, see above */ + char pi_processor_type[32]; /* ASCII CPU type */ + char pi_fputypes[32]; /* ASCII FPU types */ + int pi_clock; /* CPU clock freq in MHz */ +}; + +typedef struct _processor_info _processor_info_t; + +typedef int chipid_t; +typedef int lgrp_id_t; + +struct cpuinfo { + processorid_t cpu_id; /* CPU identifier */ + psetid_t cpu_pset; /* processor set identifier */ + chipid_t cpu_chip; /* chip identifier */ + lgrp_id_t cpu_lgrp; /* locality group identifer */ + _processor_info_t cpu_info; /* CPU information */ +}; + +typedef struct cpuinfo cpuinfo_t; + +translator cpuinfo_t < processor_t P > { + cpu_id = P->cpu_id; + cpu_pset = -1; /* Darwin does not partition processors. */ + cpu_chip = P->cpu_id; /* XXX */ + cpu_lgrp = 0; /* XXX */ + cpu_info = *((_processor_info_t *)`dtrace_zero); /* ` */ /* XXX */ +}; + +inline cpuinfo_t *curcpu = xlate (curthread->last_processor); +#pragma D attributes Stable/Stable/Common curcpu +#pragma D binding "1.0" curcpu + +inline processorid_t cpu = curcpu->cpu_id; +#pragma D attributes Stable/Stable/Common cpu +#pragma D binding "1.0" cpu + +inline psetid_t pset = curcpu->cpu_pset; +#pragma D attributes Stable/Stable/Common pset +#pragma D binding "1.0" pset + +inline chipid_t chip = curcpu->cpu_chip; +#pragma D attributes Stable/Stable/Common chip +#pragma D binding "1.0" chip + +inline lgrp_id_t lgrp = curcpu->cpu_lgrp; +#pragma D attributes Stable/Stable/Common lgrp +#pragma D binding "1.0" lgrp +