在linux 平台上回返回2,不要用OSI 区分window和linux,osiwindow


在linux 平台上回返回2,不要用OSI 区分window和linux

当在bios中调用_OSI("Windows 2001") 来确实当前系统是否是window时,这个用法是错误的。但是linux中对OSI的实现函数如下:
acpi_status acpi_ut_osi_implementation(struct acpi_walk_state *walk_state)
{
	/* Lookup the interface in the global _OSI list */
	#可以看到这里会遍历当前OSI list ,检查是否支持Windows 2001 这个list
	interface_info = acpi_ut_get_interface(string_desc->string.pointer);
	if (interface_info && !(interface_info->flags & ACPI_OSI_INVALID)) {
		/*
		 * The interface is supported.
		 * Update the osi_data if necessary. We keep track of the latest
		 * version of Windows that has been requested by the BIOS.
		 */
		if (interface_info->value > acpi_gbl_osi_data) {
			acpi_gbl_osi_data = interface_info->value;
		}

		return_value = ACPI_UINT64_MAX;
	}
}
acpi_ut_get_interface的实现如下:
struct acpi_interface_info *acpi_ut_get_interface(acpi_string interface_name)
{
	struct acpi_interface_info *next_interface;
	#linux中所有保存所有OSI list的header是acpi_gbl_supported_interfaces,所以这里会遍历整个list
	next_interface = acpi_gbl_supported_interfaces;
	while (next_interface) {
		#找到的表示是字符串相等
		if (!strcmp(interface_name, next_interface->name)) {
			return (next_interface);
		}

		next_interface = next_interface->next;
	}

	return (NULL);
}
其中acpi_gbl_supported_interfaces 是在下面的函数中赋值
acpi_status acpi_ut_initialize_interfaces(void)
{
		acpi_gbl_supported_interfaces = acpi_default_supported_interfaces;
}
static struct acpi_interface_info acpi_default_supported_interfaces[] = {
	/* Operating System Vendor Strings */

	{"Windows 2000", NULL, 0, ACPI_OSI_WIN_2000},	/* Windows 2000 */
	{"Windows 2001", NULL, 0, ACPI_OSI_WIN_XP},	/* Windows XP */
}

#define ACPI_OSI_WIN_2000               0x01
#define ACPI_OSI_WIN_XP                 0x02

这里看到如果bios 通过_OSI("Windows 2001")来查询是否是window 2001时即使在linux 平台上依然会返回0x02

相关内容