drivers/acpi/osi.c

Source file repositories/reference/linux-study-clean/drivers/acpi/osi.c

File Facts

System
Linux kernel
Corpus path
drivers/acpi/osi.c
Extension
.c
Size
12663 bytes
Lines
502
Domain
Driver Families
Bucket
drivers/acpi
Inferred role
Driver Families: exported/initcall integration point
Status
integration implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

struct acpi_osi_entry {
	char string[OSI_STRING_LENGTH_MAX];
	bool enable;
};

static struct acpi_osi_config {
	u8		default_disabling;
	unsigned int	linux_enable:1;
	unsigned int	linux_dmi:1;
	unsigned int	linux_cmdline:1;
	unsigned int	darwin_enable:1;
	unsigned int	darwin_dmi:1;
	unsigned int	darwin_cmdline:1;
} osi_config;

static struct acpi_osi_config osi_config;
static struct acpi_osi_entry
osi_setup_entries[OSI_STRING_ENTRIES_MAX] __initdata = {
	{"Module Device", true},
	{"Processor Device", true},
	{"Processor Aggregator Device", true},
};

static u32 acpi_osi_handler(acpi_string interface, u32 supported)
{
	if (!strcmp("Linux", interface)) {
		pr_notice_once(FW_BUG
			"BIOS _OSI(Linux) query %s%s\n",
			osi_config.linux_enable ? "honored" : "ignored",
			osi_config.linux_cmdline ? " via cmdline" :
			osi_config.linux_dmi ? " via DMI" : "");
	}
	if (!strcmp("Darwin", interface)) {
		pr_notice_once(
			"BIOS _OSI(Darwin) query %s%s\n",
			osi_config.darwin_enable ? "honored" : "ignored",
			osi_config.darwin_cmdline ? " via cmdline" :
			osi_config.darwin_dmi ? " via DMI" : "");
	}

	return supported;
}

void __init acpi_osi_setup(char *str)
{
	struct acpi_osi_entry *osi;
	bool enable = true;
	int i;

	if (!acpi_gbl_create_osi_method)
		return;

	if (str == NULL || *str == '\0') {
		pr_info("_OSI method disabled\n");
		acpi_gbl_create_osi_method = FALSE;
		return;
	}

	if (*str == '!') {
		str++;
		if (*str == '\0') {
			/* Do not override acpi_osi=!* */
			if (!osi_config.default_disabling)
				osi_config.default_disabling =
					ACPI_DISABLE_ALL_VENDOR_STRINGS;
			return;
		} else if (*str == '*') {
			osi_config.default_disabling = ACPI_DISABLE_ALL_STRINGS;
			for (i = 0; i < OSI_STRING_ENTRIES_MAX; i++) {
				osi = &osi_setup_entries[i];
				osi->enable = false;
			}
			return;
		} else if (*str == '!') {
			osi_config.default_disabling = 0;
			return;
		}
		enable = false;
	}

	for (i = 0; i < OSI_STRING_ENTRIES_MAX; i++) {
		osi = &osi_setup_entries[i];
		if (!strcmp(osi->string, str)) {
			osi->enable = enable;
			break;
		} else if (osi->string[0] == '\0') {
			osi->enable = enable;
			strscpy(osi->string, str, OSI_STRING_LENGTH_MAX);
			break;
		}

Annotation

Implementation Notes