Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
6595 | serge | 1 | /* |
2 | * acpi_tables.c - ACPI Boot-Time Table Parsing |
||
3 | * |
||
4 | * Copyright (C) 2001 Paul Diefenbaugh |
||
5 | * |
||
6 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
||
7 | * |
||
8 | * This program is free software; you can redistribute it and/or modify |
||
9 | * it under the terms of the GNU General Public License as published by |
||
10 | * the Free Software Foundation; either version 2 of the License, or |
||
11 | * (at your option) any later version. |
||
12 | * |
||
13 | * This program is distributed in the hope that it will be useful, |
||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
16 | * GNU General Public License for more details. |
||
17 | * |
||
18 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
||
19 | * |
||
20 | */ |
||
21 | |||
22 | /* Uncomment next line to get verbose printout */ |
||
23 | /* #define DEBUG */ |
||
24 | #define pr_fmt(fmt) "ACPI: " fmt |
||
25 | |||
26 | #include |
||
27 | #include |
||
28 | #include |
||
29 | #include |
||
30 | #include |
||
31 | #include |
||
32 | |||
33 | #define ACPI_MAX_TABLES 128 |
||
34 | static struct acpi_table_desc initial_tables[ACPI_MAX_TABLES] __initdata; |
||
35 | |||
36 | static int acpi_apic_instance __initdata; |
||
37 | |||
38 | /* |
||
39 | * Disable table checksum verification for the early stage due to the size |
||
40 | * limitation of the current x86 early mapping implementation. |
||
41 | */ |
||
42 | static bool acpi_verify_table_checksum __initdata = false; |
||
43 | /** |
||
44 | * acpi_table_parse - find table with @id, run @handler on it |
||
45 | * @id: table id to find |
||
46 | * @handler: handler to run |
||
47 | * |
||
48 | * Scan the ACPI System Descriptor Table (STD) for a table matching @id, |
||
49 | * run @handler on it. |
||
50 | * |
||
51 | * Return 0 if table found, -errno if not. |
||
52 | */ |
||
53 | int __init acpi_table_parse(char *id, acpi_tbl_table_handler handler) |
||
54 | { |
||
55 | struct acpi_table_header *table = NULL; |
||
56 | acpi_size tbl_size; |
||
57 | |||
58 | if (acpi_disabled) |
||
59 | return -ENODEV; |
||
60 | |||
61 | if (!id || !handler) |
||
62 | return -EINVAL; |
||
63 | |||
64 | if (strncmp(id, ACPI_SIG_MADT, 4) == 0) |
||
65 | acpi_get_table_with_size(id, acpi_apic_instance, &table, &tbl_size); |
||
66 | else |
||
67 | acpi_get_table_with_size(id, 0, &table, &tbl_size); |
||
68 | |||
69 | if (table) { |
||
70 | handler(table); |
||
71 | early_acpi_os_unmap_memory(table, tbl_size); |
||
72 | return 0; |
||
73 | } else |
||
74 | return -ENODEV; |
||
75 | } |
||
76 | |||
77 | /* |
||
78 | * acpi_table_init() |
||
79 | * |
||
80 | * find RSDP, find and checksum SDT/XSDT. |
||
81 | * checksum all tables, print SDT/XSDT |
||
82 | * |
||
83 | * result: sdt_entry[] is initialized |
||
84 | */ |
||
85 | |||
86 | int __init acpi_table_init(void) |
||
87 | { |
||
88 | acpi_status status; |
||
89 | |||
90 | if (acpi_verify_table_checksum) { |
||
91 | pr_info("Early table checksum verification enabled\n"); |
||
92 | acpi_gbl_verify_table_checksum = TRUE; |
||
93 | } else { |
||
94 | pr_info("Early table checksum verification disabled\n"); |
||
95 | acpi_gbl_verify_table_checksum = FALSE; |
||
96 | } |
||
97 | |||
98 | status = acpi_initialize_tables(initial_tables, ACPI_MAX_TABLES, 0); |
||
99 | if (ACPI_FAILURE(status)) |
||
100 | return -EINVAL; |
||
101 | |||
102 | return 0; |
||
103 | } |