1 | /*
|
---|
2 | * Copyright (c) 2011 Jakub Jermar
|
---|
3 | * All rights reserved.
|
---|
4 | *
|
---|
5 | * Redistribution and use in source and binary forms, with or without
|
---|
6 | * modification, are permitted provided that the following conditions
|
---|
7 | * are met:
|
---|
8 | *
|
---|
9 | * - Redistributions of source code must retain the above copyright
|
---|
10 | * notice, this list of conditions and the following disclaimer.
|
---|
11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
12 | * notice, this list of conditions and the following disclaimer in the
|
---|
13 | * documentation and/or other materials provided with the distribution.
|
---|
14 | * - The name of the author may not be used to endorse or promote products
|
---|
15 | * derived from this software without specific prior written permission.
|
---|
16 | *
|
---|
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
27 | */
|
---|
28 |
|
---|
29 | #ifndef BOOT_EFI_H_
|
---|
30 | #define BOOT_EFI_H_
|
---|
31 |
|
---|
32 | #include <arch/types.h>
|
---|
33 |
|
---|
34 | typedef struct {
|
---|
35 | uint64_t signature;
|
---|
36 | uint32_t revision;
|
---|
37 | uint32_t header_size;
|
---|
38 | uint32_t crc32;
|
---|
39 | uint32_t reserved;
|
---|
40 | } efi_table_header_t;
|
---|
41 |
|
---|
42 | #define SAL_SYSTEM_TABLE_GUID \
|
---|
43 | { \
|
---|
44 | { \
|
---|
45 | 0x32, 0x2d, 0x9d, 0xeb, 0x88, 0x2d, 0xd3, 0x11, \
|
---|
46 | 0x9a, 0x16, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d \
|
---|
47 | } \
|
---|
48 | }
|
---|
49 |
|
---|
50 | typedef union {
|
---|
51 | uint8_t bytes[16];
|
---|
52 | struct {
|
---|
53 | uint64_t low;
|
---|
54 | uint64_t high;
|
---|
55 | };
|
---|
56 | } efi_guid_t;
|
---|
57 |
|
---|
58 | typedef struct {
|
---|
59 | efi_guid_t guid;
|
---|
60 | void *table;
|
---|
61 | } efi_configuration_table_t;
|
---|
62 |
|
---|
63 | typedef struct {
|
---|
64 | efi_table_header_t hdr;
|
---|
65 | char *fw_vendor;
|
---|
66 | uint32_t fw_revision;
|
---|
67 | void *cons_in_handle;
|
---|
68 | void *cons_in;
|
---|
69 | void *cons_out_handle;
|
---|
70 | void *cons_out;
|
---|
71 | void *cons_err_handle;
|
---|
72 | void *cons_err;
|
---|
73 | void *runtime_services;
|
---|
74 | void *boot_services;
|
---|
75 | sysarg_t conf_table_entries;
|
---|
76 | efi_configuration_table_t *conf_table;
|
---|
77 | } efi_system_table_t;
|
---|
78 |
|
---|
79 | typedef enum {
|
---|
80 | EFI_RESERVED,
|
---|
81 | EFI_LOADER_CODE,
|
---|
82 | EFI_LOADER_DATA,
|
---|
83 | EFI_BOOT_SERVICES_CODE,
|
---|
84 | EFI_BOOT_SERVICES_DATA,
|
---|
85 | EFI_RUNTIME_SERVICES_CODE,
|
---|
86 | EFI_RUNTIME_SERVICES_DATA,
|
---|
87 | EFI_CONVENTIONAL_MEMORY,
|
---|
88 | EFI_UNUSABLE_MEMORY,
|
---|
89 | EFI_ACPI_RECLAIM_MEMORY,
|
---|
90 | EFI_ACPI_MEMORY_NVS,
|
---|
91 | EFI_MEMORY_MAPPED_IO,
|
---|
92 | EFI_MEMORY_MAPPED_IO_PORT_SPACE,
|
---|
93 | EFI_PAL_CODE
|
---|
94 | } efi_memory_type_t;
|
---|
95 |
|
---|
96 | typedef struct {
|
---|
97 | uint32_t type;
|
---|
98 | uint64_t phys_start;
|
---|
99 | uint64_t virt_start;
|
---|
100 | uint64_t pages;
|
---|
101 | uint64_t attribute;
|
---|
102 | } efi_v1_memdesc_t;
|
---|
103 |
|
---|
104 | #define EFI_PAGE_SIZE 4096
|
---|
105 |
|
---|
106 | extern void *efi_vendor_table_find(efi_system_table_t *, efi_guid_t);
|
---|
107 |
|
---|
108 | #endif
|
---|