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