X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/d9a64523371fa019c4575bb400cbbc3a50ac9903..HEAD:/bsd/dev/arm/sysctl.c diff --git a/bsd/dev/arm/sysctl.c b/bsd/dev/arm/sysctl.c index d97e80e21..c0105a0ca 100644 --- a/bsd/dev/arm/sysctl.c +++ b/bsd/dev/arm/sysctl.c @@ -12,18 +12,19 @@ #include #include -extern int trap_on_alignment_fault; -extern uint64_t wake_abstime; +extern int trap_on_alignment_fault; +extern uint64_t wake_abstime; +extern int lck_mtx_adaptive_spin_mode; static SYSCTL_INT(_machdep, OID_AUTO, alignmenttrap, - CTLFLAG_RW, &trap_on_alignment_fault, 0, - "trap on alignment faults (number of alignment faults per trap)"); + CTLFLAG_RW, &trap_on_alignment_fault, 0, + "trap on alignment faults (number of alignment faults per trap)"); static SYSCTL_QUAD(_machdep, OID_AUTO, wake_abstime, - CTLFLAG_RD | CTLFLAG_KERN, &wake_abstime, - "Absolute Time at the last wakeup"); + CTLFLAG_RD | CTLFLAG_KERN, &wake_abstime, + "Absolute Time at the last wakeup"); static int sysctl_time_since_reset SYSCTL_HANDLER_ARGS @@ -40,9 +41,9 @@ sysctl_time_since_reset SYSCTL_HANDLER_ARGS } SYSCTL_PROC(_machdep, OID_AUTO, time_since_reset, - CTLFLAG_RD | CTLTYPE_QUAD | CTLFLAG_LOCKED, - 0, 0, sysctl_time_since_reset, "I", - "Continuous time since last SOC boot/wake started"); + CTLFLAG_RD | CTLTYPE_QUAD | CTLFLAG_LOCKED, + 0, 0, sysctl_time_since_reset, "I", + "Continuous time since last SOC boot/wake started"); static int sysctl_wake_conttime SYSCTL_HANDLER_ARGS @@ -59,17 +60,17 @@ sysctl_wake_conttime SYSCTL_HANDLER_ARGS } SYSCTL_PROC(_machdep, OID_AUTO, wake_conttime, - CTLFLAG_RD | CTLTYPE_QUAD | CTLFLAG_LOCKED, - 0, 0, sysctl_wake_conttime, "I", - "Continuous Time at the last wakeup"); + CTLFLAG_RD | CTLTYPE_QUAD | CTLFLAG_LOCKED, + 0, 0, sysctl_wake_conttime, "I", + "Continuous Time at the last wakeup"); /* * For source compatibility, here's some machdep.cpu mibs that * use host_info() to simulate reasonable answers. */ -SYSCTL_NODE(_machdep, OID_AUTO, cpu, CTLFLAG_RW|CTLFLAG_LOCKED, 0, - "CPU info"); +SYSCTL_NODE(_machdep, OID_AUTO, cpu, CTLFLAG_RW | CTLFLAG_LOCKED, 0, + "CPU info"); static int arm_host_info SYSCTL_HANDLER_ARGS @@ -78,18 +79,20 @@ arm_host_info SYSCTL_HANDLER_ARGS host_basic_info_data_t hinfo; mach_msg_type_number_t count = HOST_BASIC_INFO_COUNT; -#define BSD_HOST 1 +#define BSD_HOST 1 kern_return_t kret = host_info((host_t)BSD_HOST, - HOST_BASIC_INFO, (host_info_t)&hinfo, &count); - if (KERN_SUCCESS != kret) - return (EINVAL); + HOST_BASIC_INFO, (host_info_t)&hinfo, &count); + if (KERN_SUCCESS != kret) { + return EINVAL; + } - if (sizeof (uint32_t) != arg2) + if (sizeof(uint32_t) != arg2) { panic("size mismatch"); + } - uintptr_t woffset = (uintptr_t)arg1 / sizeof (uint32_t); + uintptr_t woffset = (uintptr_t)arg1 / sizeof(uint32_t); uint32_t datum = *(uint32_t *)(((uint32_t *)&hinfo) + woffset); - return (SYSCTL_OUT(req, &datum, sizeof (datum))); + return SYSCTL_OUT(req, &datum, sizeof(datum)); } /* @@ -100,10 +103,10 @@ arm_host_info SYSCTL_HANDLER_ARGS */ static SYSCTL_PROC(_machdep_cpu, OID_AUTO, cores_per_package, - CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED, - (void *)offsetof(host_basic_info_data_t, physical_cpu_max), - sizeof (integer_t), - arm_host_info, "I", "CPU cores per package"); + CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED, + (void *)offsetof(host_basic_info_data_t, physical_cpu_max), + sizeof(integer_t), + arm_host_info, "I", "CPU cores per package"); /* * machdep.cpu.core_count @@ -113,10 +116,10 @@ SYSCTL_PROC(_machdep_cpu, OID_AUTO, cores_per_package, */ static SYSCTL_PROC(_machdep_cpu, OID_AUTO, core_count, - CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED, - (void *)offsetof(host_basic_info_data_t, physical_cpu), - sizeof (integer_t), - arm_host_info, "I", "Number of enabled cores per package"); + CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED, + (void *)offsetof(host_basic_info_data_t, physical_cpu), + sizeof(integer_t), + arm_host_info, "I", "Number of enabled cores per package"); /* * machdep.cpu.logical_per_package @@ -127,10 +130,10 @@ SYSCTL_PROC(_machdep_cpu, OID_AUTO, core_count, */ static SYSCTL_PROC(_machdep_cpu, OID_AUTO, logical_per_package, - CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED, - (void *)offsetof(host_basic_info_data_t, logical_cpu_max), - sizeof (integer_t), - arm_host_info, "I", "CPU logical cpus per package"); + CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED, + (void *)offsetof(host_basic_info_data_t, logical_cpu_max), + sizeof(integer_t), + arm_host_info, "I", "CPU logical cpus per package"); /* * machdep.cpu.thread_count @@ -140,10 +143,10 @@ SYSCTL_PROC(_machdep_cpu, OID_AUTO, logical_per_package, */ static SYSCTL_PROC(_machdep_cpu, OID_AUTO, thread_count, - CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED, - (void *)offsetof(host_basic_info_data_t, logical_cpu), - sizeof (integer_t), - arm_host_info, "I", "Number of enabled threads per package"); + CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED, + (void *)offsetof(host_basic_info_data_t, logical_cpu), + sizeof(integer_t), + arm_host_info, "I", "Number of enabled threads per package"); /* * machdep.cpu.brand_string @@ -174,10 +177,29 @@ make_brand_string SYSCTL_HANDLER_ARGS break; } char buf[80]; - snprintf(buf, sizeof (buf), "%s processor", impl); - return (SYSCTL_OUT(req, buf, strlen(buf) + 1)); + snprintf(buf, sizeof(buf), "%s processor", impl); + return SYSCTL_OUT(req, buf, strlen(buf) + 1); } SYSCTL_PROC(_machdep_cpu, OID_AUTO, brand_string, - CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_LOCKED, - 0, 0, make_brand_string, "A", "CPU brand string"); + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_LOCKED, + 0, 0, make_brand_string, "A", "CPU brand string"); + +static +SYSCTL_INT(_machdep, OID_AUTO, lck_mtx_adaptive_spin_mode, + CTLFLAG_RW, &lck_mtx_adaptive_spin_mode, 0, + "Enable adaptive spin behavior for kernel mutexes"); + +static int +virtual_address_size SYSCTL_HANDLER_ARGS +{ +#pragma unused(arg1, arg2, oidp) + int return_value = 32 - (TTBCR_N_SETUP & TTBCR_N_MASK); + return SYSCTL_OUT(req, &return_value, sizeof(return_value)); +} + +static +SYSCTL_PROC(_machdep, OID_AUTO, virtual_address_size, + CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED, + 0, 0, virtual_address_size, "I", + "Number of addressable bits in userspace virtual addresses");