Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
linux
Commits
81442037
Commit
81442037
authored
Jul 13, 2003
by
Andy Grover
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ACPI: Dynamically allocate SDT list (suggested by Andi Kleen)
parent
fbdebc89
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
45 deletions
+54
-45
drivers/acpi/tables.c
drivers/acpi/tables.c
+54
-45
No files found.
drivers/acpi/tables.c
View file @
81442037
...
...
@@ -33,6 +33,7 @@
#include <linux/irq.h>
#include <linux/errno.h>
#include <linux/acpi.h>
#include <linux/bootmem.h>
#define PREFIX "ACPI: "
...
...
@@ -61,16 +62,14 @@ static char *acpi_table_signatures[ACPI_TABLE_COUNT] = {
/* System Description Table (RSDT/XSDT) */
struct
acpi_table_sdt
{
unsigned
long
pa
;
/* Physical Address */
unsigned
long
count
;
/* Table count */
struct
{
unsigned
long
pa
;
enum
acpi_table_id
id
;
unsigned
long
size
;
}
entry
[
ACPI_MAX_TABLES
];
unsigned
long
pa
;
enum
acpi_table_id
id
;
unsigned
long
size
;
}
__attribute__
((
packed
));
static
struct
acpi_table_sdt
sdt
;
static
unsigned
long
sdt_pa
;
/* Physical Address */
static
unsigned
long
sdt_count
;
/* Table count */
static
struct
acpi_table_sdt
*
sdt_entry
;
void
acpi_table_print
(
...
...
@@ -236,11 +235,11 @@ acpi_get_table_header_early (
/* Locate the table. */
for
(
i
=
0
;
i
<
sdt
.
count
;
i
++
)
{
if
(
sdt
.
entry
[
i
].
id
!=
temp_id
)
for
(
i
=
0
;
i
<
sdt
_
count
;
i
++
)
{
if
(
sdt
_
entry
[
i
].
id
!=
temp_id
)
continue
;
*
header
=
(
void
*
)
__acpi_map_table
(
sdt
.
entry
[
i
].
pa
,
sdt
.
entry
[
i
].
size
);
__acpi_map_table
(
sdt
_entry
[
i
].
pa
,
sdt_
entry
[
i
].
size
);
if
(
!*
header
)
{
printk
(
KERN_WARNING
PREFIX
"Unable to map %s
\n
"
,
acpi_table_signatures
[
temp_id
]);
...
...
@@ -289,11 +288,11 @@ acpi_table_parse_madt_family (
/* Locate the MADT (if exists). There should only be one. */
for
(
i
=
0
;
i
<
sdt
.
count
;
i
++
)
{
if
(
sdt
.
entry
[
i
].
id
!=
id
)
for
(
i
=
0
;
i
<
sdt
_
count
;
i
++
)
{
if
(
sdt
_
entry
[
i
].
id
!=
id
)
continue
;
madt
=
(
void
*
)
__acpi_map_table
(
sdt
.
entry
[
i
].
pa
,
sdt
.
entry
[
i
].
size
);
__acpi_map_table
(
sdt
_entry
[
i
].
pa
,
sdt_
entry
[
i
].
size
);
if
(
!
madt
)
{
printk
(
KERN_WARNING
PREFIX
"Unable to map %s
\n
"
,
acpi_table_signatures
[
id
]);
...
...
@@ -308,7 +307,7 @@ acpi_table_parse_madt_family (
return
-
ENODEV
;
}
madt_end
=
(
unsigned
long
)
madt
+
sdt
.
entry
[
i
].
size
;
madt_end
=
(
unsigned
long
)
madt
+
sdt
_
entry
[
i
].
size
;
/* Parse all entries looking for a match. */
...
...
@@ -349,10 +348,10 @@ acpi_table_parse (
if
(
!
handler
)
return
-
EINVAL
;
for
(
i
=
0
;
i
<
sdt
.
count
;
i
++
)
{
if
(
sdt
.
entry
[
i
].
id
!=
id
)
for
(
i
=
0
;
i
<
sdt
_
count
;
i
++
)
{
if
(
sdt
_
entry
[
i
].
id
!=
id
)
continue
;
handler
(
sdt
.
entry
[
i
].
pa
,
sdt
.
entry
[
i
].
size
);
handler
(
sdt
_entry
[
i
].
pa
,
sdt_
entry
[
i
].
size
);
count
++
;
}
...
...
@@ -377,11 +376,11 @@ acpi_table_get_sdt (
struct
acpi_table_xsdt
*
mapped_xsdt
=
NULL
;
sdt
.
pa
=
((
struct
acpi20_table_rsdp
*
)
rsdp
)
->
xsdt_address
;
sdt
_
pa
=
((
struct
acpi20_table_rsdp
*
)
rsdp
)
->
xsdt_address
;
/* map in just the header */
header
=
(
struct
acpi_table_header
*
)
__acpi_map_table
(
sdt
.
pa
,
sizeof
(
struct
acpi_table_header
));
__acpi_map_table
(
sdt
_
pa
,
sizeof
(
struct
acpi_table_header
));
if
(
!
header
)
{
printk
(
KERN_WARNING
PREFIX
"Unable to map XSDT header
\n
"
);
...
...
@@ -390,7 +389,7 @@ acpi_table_get_sdt (
/* remap in the entire table before processing */
mapped_xsdt
=
(
struct
acpi_table_xsdt
*
)
__acpi_map_table
(
sdt
.
pa
,
header
->
length
);
__acpi_map_table
(
sdt
_
pa
,
header
->
length
);
if
(
!
mapped_xsdt
)
{
printk
(
KERN_WARNING
PREFIX
"Unable to map XSDT
\n
"
);
return
-
ENODEV
;
...
...
@@ -407,15 +406,21 @@ acpi_table_get_sdt (
return
-
ENODEV
;
}
sdt
.
count
=
(
header
->
length
-
sizeof
(
struct
acpi_table_header
))
>>
3
;
if
(
sdt
.
count
>
ACPI_MAX_TABLES
)
{
sdt
_
count
=
(
header
->
length
-
sizeof
(
struct
acpi_table_header
))
>>
3
;
if
(
sdt
_
count
>
ACPI_MAX_TABLES
)
{
printk
(
KERN_WARNING
PREFIX
"Truncated %lu XSDT entries
\n
"
,
(
sdt
.
count
-
ACPI_MAX_TABLES
));
sdt
.
count
=
ACPI_MAX_TABLES
;
(
sdt
_
count
-
ACPI_MAX_TABLES
));
sdt
_
count
=
ACPI_MAX_TABLES
;
}
for
(
i
=
0
;
i
<
sdt
.
count
;
i
++
)
sdt
.
entry
[
i
].
pa
=
(
unsigned
long
)
mapped_xsdt
->
entry
[
i
];
sdt_entry
=
alloc_bootmem
(
sdt_count
*
sizeof
(
struct
acpi_table_sdt
));
if
(
!
sdt_entry
)
{
printk
(
KERN_ERR
"ACPI: Could not allocate mem for SDT entries!
\n
"
);
return
-
ENOMEM
;
}
for
(
i
=
0
;
i
<
sdt_count
;
i
++
)
sdt_entry
[
i
].
pa
=
(
unsigned
long
)
mapped_xsdt
->
entry
[
i
];
}
/* Then check RSDT */
...
...
@@ -424,11 +429,11 @@ acpi_table_get_sdt (
struct
acpi_table_rsdt
*
mapped_rsdt
=
NULL
;
sdt
.
pa
=
rsdp
->
rsdt_address
;
sdt
_
pa
=
rsdp
->
rsdt_address
;
/* map in just the header */
header
=
(
struct
acpi_table_header
*
)
__acpi_map_table
(
sdt
.
pa
,
sizeof
(
struct
acpi_table_header
));
__acpi_map_table
(
sdt
_
pa
,
sizeof
(
struct
acpi_table_header
));
if
(
!
header
)
{
printk
(
KERN_WARNING
PREFIX
"Unable to map RSDT header
\n
"
);
return
-
ENODEV
;
...
...
@@ -436,7 +441,7 @@ acpi_table_get_sdt (
/* remap in the entire table before processing */
mapped_rsdt
=
(
struct
acpi_table_rsdt
*
)
__acpi_map_table
(
sdt
.
pa
,
header
->
length
);
__acpi_map_table
(
sdt
_
pa
,
header
->
length
);
if
(
!
mapped_rsdt
)
{
printk
(
KERN_WARNING
PREFIX
"Unable to map RSDT
\n
"
);
return
-
ENODEV
;
...
...
@@ -453,15 +458,21 @@ acpi_table_get_sdt (
return
-
ENODEV
;
}
sdt
.
count
=
(
header
->
length
-
sizeof
(
struct
acpi_table_header
))
>>
2
;
if
(
sdt
.
count
>
ACPI_MAX_TABLES
)
{
sdt
_
count
=
(
header
->
length
-
sizeof
(
struct
acpi_table_header
))
>>
2
;
if
(
sdt
_
count
>
ACPI_MAX_TABLES
)
{
printk
(
KERN_WARNING
PREFIX
"Truncated %lu RSDT entries
\n
"
,
(
sdt
.
count
-
ACPI_TABLE_COUNT
));
sdt
.
count
=
ACPI_MAX_TABLES
;
(
sdt
_count
-
ACPI_MAX_TABLES
));
sdt
_
count
=
ACPI_MAX_TABLES
;
}
for
(
i
=
0
;
i
<
sdt
.
count
;
i
++
)
sdt
.
entry
[
i
].
pa
=
(
unsigned
long
)
mapped_rsdt
->
entry
[
i
];
sdt_entry
=
alloc_bootmem
(
sdt_count
*
sizeof
(
struct
acpi_table_sdt
));
if
(
!
sdt_entry
)
{
printk
(
KERN_ERR
"ACPI: Could not allocate mem for SDT entries!
\n
"
);
return
-
ENOMEM
;
}
for
(
i
=
0
;
i
<
sdt_count
;
i
++
)
sdt_entry
[
i
].
pa
=
(
unsigned
long
)
mapped_rsdt
->
entry
[
i
];
}
else
{
...
...
@@ -469,38 +480,38 @@ acpi_table_get_sdt (
return
-
ENODEV
;
}
acpi_table_print
(
header
,
sdt
.
pa
);
acpi_table_print
(
header
,
sdt
_
pa
);
for
(
i
=
0
;
i
<
sdt
.
count
;
i
++
)
{
for
(
i
=
0
;
i
<
sdt
_
count
;
i
++
)
{
/* map in just the header */
header
=
(
struct
acpi_table_header
*
)
__acpi_map_table
(
sdt
.
entry
[
i
].
pa
,
__acpi_map_table
(
sdt
_
entry
[
i
].
pa
,
sizeof
(
struct
acpi_table_header
));
if
(
!
header
)
continue
;
/* remap in the entire table before processing */
header
=
(
struct
acpi_table_header
*
)
__acpi_map_table
(
sdt
.
entry
[
i
].
pa
,
__acpi_map_table
(
sdt
_
entry
[
i
].
pa
,
header
->
length
);
if
(
!
header
)
continue
;
acpi_table_print
(
header
,
sdt
.
entry
[
i
].
pa
);
acpi_table_print
(
header
,
sdt
_
entry
[
i
].
pa
);
if
(
acpi_table_compute_checksum
(
header
,
header
->
length
))
{
printk
(
KERN_WARNING
" >>> ERROR: Invalid checksum
\n
"
);
continue
;
}
sdt
.
entry
[
i
].
size
=
header
->
length
;
sdt
_
entry
[
i
].
size
=
header
->
length
;
for
(
id
=
0
;
id
<
ACPI_TABLE_COUNT
;
id
++
)
{
if
(
!
strncmp
((
char
*
)
&
header
->
signature
,
acpi_table_signatures
[
id
],
sizeof
(
header
->
signature
)))
{
sdt
.
entry
[
i
].
id
=
id
;
sdt
_
entry
[
i
].
id
=
id
;
}
}
}
...
...
@@ -525,8 +536,6 @@ acpi_table_init (void)
unsigned
long
rsdp_phys
=
0
;
int
result
=
0
;
memset
(
&
sdt
,
0
,
sizeof
(
struct
acpi_table_sdt
));
/* Locate and map the Root System Description Table (RSDP) */
rsdp_phys
=
acpi_find_rsdp
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment