Userspace ACPI parser debugging.
* grub-core/commands/acpihalt.c [GRUB_DSDT_TEST]: Include userspace headers and add relevant defines. Don't include standard headers. (main) [GRUB_DSDT_TEST]: New function. * include/grub/acpi.h [GRUB_DSDT_TEST]: Don't include standard headers. Don't declare functions.
This commit is contained in:
parent
fbfbeb394f
commit
c32b51c9f9
3 changed files with 75 additions and 0 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
2010-10-16 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Userspace ACPI parser debugging.
|
||||
|
||||
* grub-core/commands/acpihalt.c [GRUB_DSDT_TEST]: Include userspace
|
||||
headers and add relevant defines. Don't include standard headers.
|
||||
(main) [GRUB_DSDT_TEST]: New function.
|
||||
* include/grub/acpi.h [GRUB_DSDT_TEST]: Don't include standard headers.
|
||||
Don't declare functions.
|
||||
|
||||
2010-10-16 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Remove dead grub_efi_mm_fini.
|
||||
|
|
|
@ -16,9 +16,28 @@
|
|||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifdef GRUB_DSDT_TEST
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#define grub_dprintf(cond, args...) printf ( args )
|
||||
#define grub_printf printf
|
||||
typedef uint64_t grub_uint64_t;
|
||||
typedef uint32_t grub_uint32_t;
|
||||
typedef uint16_t grub_uint16_t;
|
||||
typedef uint8_t grub_uint8_t;
|
||||
|
||||
#endif
|
||||
|
||||
#include <grub/acpi.h>
|
||||
|
||||
#ifndef GRUB_DSDT_TEST
|
||||
#include <grub/misc.h>
|
||||
#include <grub/cpu/io.h>
|
||||
#endif
|
||||
|
||||
static inline grub_uint32_t
|
||||
decode_length (const grub_uint8_t *ptr, int *numlen)
|
||||
|
@ -208,6 +227,47 @@ get_sleep_type (grub_uint8_t *table, grub_uint8_t *end)
|
|||
return sleep_type;
|
||||
}
|
||||
|
||||
#ifdef GRUB_DSDT_TEST
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
FILE *f;
|
||||
size_t len;
|
||||
unsigned char *buf;
|
||||
if (argc < 2)
|
||||
printf ("Usage: %s FILE\n", argv[0]);
|
||||
f = fopen (argv[1], "rb");
|
||||
if (!f)
|
||||
{
|
||||
printf ("Couldn't open file\n");
|
||||
return 1;
|
||||
}
|
||||
fseek (f, 0, SEEK_END);
|
||||
len = ftell (f);
|
||||
fseek (f, 0, SEEK_SET);
|
||||
buf = malloc (len);
|
||||
if (!buf)
|
||||
{
|
||||
printf ("Couldn't malloc buffer\n");
|
||||
fclose (f);
|
||||
return 2;
|
||||
}
|
||||
if (fread (buf, 1, len, f) != len)
|
||||
{
|
||||
printf ("Read failed\n");
|
||||
free (buf);
|
||||
fclose (f);
|
||||
return 2;
|
||||
}
|
||||
|
||||
printf ("Sleep type = %d\n", get_sleep_type (buf, buf + len));
|
||||
free (buf);
|
||||
fclose (f);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void
|
||||
grub_acpi_halt (void)
|
||||
{
|
||||
|
@ -264,3 +324,4 @@ grub_acpi_halt (void)
|
|||
|
||||
grub_printf ("ACPI shutdown failed\n");
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -19,8 +19,10 @@
|
|||
#ifndef GRUB_ACPI_HEADER
|
||||
#define GRUB_ACPI_HEADER 1
|
||||
|
||||
#ifndef GRUB_DSDT_TEST
|
||||
#include <grub/types.h>
|
||||
#include <grub/err.h>
|
||||
#endif
|
||||
|
||||
struct grub_acpi_rsdp_v10
|
||||
{
|
||||
|
@ -139,6 +141,7 @@ enum
|
|||
GRUB_ACPI_MADT_ENTRY_SAPIC_FLAGS_ENABLED = 1
|
||||
};
|
||||
|
||||
#ifndef GRUB_DSDT_TEST
|
||||
struct grub_acpi_rsdp_v10 *grub_acpi_get_rsdpv1 (void);
|
||||
struct grub_acpi_rsdp_v20 *grub_acpi_get_rsdpv2 (void);
|
||||
struct grub_acpi_rsdp_v10 *grub_machine_acpi_get_rsdpv1 (void);
|
||||
|
@ -148,6 +151,7 @@ grub_uint8_t grub_byte_checksum (void *base, grub_size_t size);
|
|||
grub_err_t grub_acpi_create_ebda (void);
|
||||
|
||||
void grub_acpi_halt (void);
|
||||
#endif
|
||||
|
||||
#define GRUB_ACPI_SLP_EN (1 << 13)
|
||||
#define GRUB_ACPI_SLP_TYP_OFFSET 10
|
||||
|
|
Loading…
Reference in a new issue