aboutsummaryrefslogtreecommitdiffstats
path: root/efi/efi.h
blob: 14164882d62e5814850f5d375150a109b62d59c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#ifndef _SYSLINUX_EFI_H
#define _SYSLINUX_EFI_H

#include <syslinux/config.h>
#include <core.h>
#include <sys/types.h>	/* needed for off_t */
//#include <syslinux/version.h> /* avoid redefinition of __STDC_VERSION__ */

/*
 * gnu-efi >= 3.0s enables GNU_EFI_USE_MS_ABI by default, which means
 * that we must also enable it if supported by the compiler. Note that
 * failing to enable GNU_EFI_USE_MS_ABI if gnu-efi was compiled with
 * it on will result in undefined references to uefi_call_wrapper().
 *
 * The reason we don't attempt to check the version of gnu-efi we're
 * building against is because there's no harm in turning it on for
 * older versions - it will just be ignored.
 */
#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7))
  #define GNU_EFI_USE_MS_ABI 1
#endif

#include <efi.h>
#include <efilib.h>
#include <efistdarg.h>

/* Delay for 100 ms */
#define EFI_NOMAP_PRINT_DELAY	100
/* We should keep EFI_NOMAP_PRINT_COUNT at 10 to limit flooding the console */
#define EFI_NOMAP_PRINT_COUNT	10

struct efi_disk_private {
	EFI_HANDLE dev_handle;
	EFI_BLOCK_IO *bio;
	EFI_DISK_IO *dio;
};

struct efi_binding {
    EFI_SERVICE_BINDING *binding;
    EFI_HANDLE parent;
    EFI_HANDLE child;
    EFI_HANDLE this;
};

extern EFI_HANDLE image_handle, pxe_handle;

struct screen_info;
extern void setup_screen(struct screen_info *);

extern void efi_write_char(uint8_t, uint8_t);

enum heap;
extern void *efi_malloc(size_t, enum heap, size_t);
extern void *efi_realloc(void *, size_t);
extern void efi_free(void *);

extern struct efi_binding *efi_create_binding(EFI_GUID *, EFI_GUID *);
extern void efi_destroy_binding(struct efi_binding *, EFI_GUID *);

static inline EFI_STATUS
efi_setup_event(EFI_EVENT *ev, EFI_EVENT_NOTIFY func, void *ctx)
{
    EFI_STATUS status;

    status = uefi_call_wrapper(BS->CreateEvent, 5, EVT_NOTIFY_SIGNAL,
			       TPL_CALLBACK, func, ctx, ev);
    return status;
}

extern void efi_derivative(enum syslinux_filesystem fs);

struct boot_params;
typedef void (handover_func_t)(void *, EFI_SYSTEM_TABLE *,
			       struct boot_params *, unsigned long);

handover_func_t efi_handover_32;
handover_func_t efi_handover_64;
handover_func_t efi_handover;

extern void efi_console_save(void);
extern void efi_console_restore(void);

#endif /* _SYSLINUX_EFI_H */