Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/lib/libefivar/efi-osdep.h
39475 views
1
/*-
2
* Copyright (c) 2017 Netflix, Inc.
3
*
4
* Redistribution and use in source and binary forms, with or without
5
* modification, are permitted provided that the following conditions
6
* are met:
7
* 1. Redistributions of source code must retain the above copyright
8
* notice, this list of conditions and the following disclaimer.
9
* 2. Redistributions in binary form must reproduce the above copyright
10
* notice, this list of conditions and the following disclaimer in the
11
* documentation and/or other materials provided with the distribution.
12
*
13
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23
* SUCH DAMAGE.
24
*/
25
26
#ifndef _EFI_OSDEP_H_
27
#define _EFI_OSDEP_H_
28
29
/*
30
* Defines to adjust the types that EDK2 uses for FreeBSD so we can
31
* use the code and headers mostly unchanged. The headers are imported
32
* all into one directory to avoid case issues with filenames and
33
* included. The actual code is heavily modified since it has too many
34
* annoying dependencies that are difficult to satisfy.
35
*/
36
37
#include <sys/cdefs.h>
38
#include <stdlib.h>
39
#include <stdint.h>
40
#include <uuid.h>
41
42
typedef int8_t INT8;
43
typedef int16_t INT16;
44
typedef int32_t INT32;
45
typedef int64_t INT64;
46
typedef intptr_t INTN;
47
typedef uint8_t UINT8;
48
typedef uint16_t UINT16;
49
typedef uint32_t UINT32;
50
typedef uint64_t UINT64;
51
typedef uintptr_t UINTN;
52
//typedef uintptr_t EFI_PHYSICAL_ADDRESS;
53
//typedef uint32_t EFI_IPv4_ADDRESS;
54
//typedef uint8_t EFI_MAC_ADDRESS[6];
55
//typedef uint8_t EFI_IPv6_ADDRESS[16];
56
typedef uint8_t CHAR8;
57
typedef uint16_t CHAR16;
58
typedef UINT8 BOOLEAN;
59
typedef void VOID;
60
//typedef uuid_t GUID;
61
//typedef uuid_t EFI_GUID;
62
63
/* We can't actually call this stuff, so snip out API syntactic sugar */
64
#define INTERFACE_DECL(x)
65
#define EFIAPI
66
#define IN
67
#define OUT
68
#define CONST const
69
#define OPTIONAL
70
//#define TRUE 1
71
//#define FALSE 0
72
73
/*
74
* EDK2 has fine definitions for these, so let it define them.
75
*/
76
#undef NULL
77
#undef EFI_PAGE_SIZE
78
#undef EFI_PAGE_MASK
79
80
/*
81
* Note: the EDK2 code assumed #pragma packed works and PACKED is a
82
* workaround for some old toolchain issues for EDK2 that aren't
83
* relevent to FreeBSD.
84
*/
85
#define PACKED
86
87
/*
88
* Since we're not compiling for the UEFI boot time (which use ms abi
89
* conventions), tell EDK2 to define VA_START correctly. For the boot
90
* loader, this likely needs to be different.
91
*/
92
#define NO_MSABI_VA_FUNCS 1
93
94
/*
95
* Finally, we need to define the processor we are in EDK2 terms.
96
*/
97
#if defined(__i386__)
98
#define MDE_CPU_IA32
99
#elif defined(__amd64__)
100
#define MDE_CPU_X64
101
#elif defined(__arm__)
102
#define MDE_CPU_ARM
103
#elif defined(__aarch64__)
104
#define MDE_CPU_AARCH64
105
#elif defined(__riscv)
106
#define MDE_CPU_RISCV64
107
#endif
108
/* FreeBSD doesn't have/use MDE_CPU_EBC or MDE_CPU_IPF (ia64) */
109
110
#endif /* _EFI_OSDEP_H_ */
111
112