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 * $FreeBSD$ 26 */ 27 28#ifndef _EFI_OSDEP_H_ 29#define _EFI_OSDEP_H_ 30 31/* 32 * Defines to adjust the types that EDK2 uses for FreeBSD so we can 33 * use the code and headers mostly unchanged. The headers are imported 34 * all into one directory to avoid case issues with filenames and 35 * included. The actual code is heavily modified since it has too many 36 * annoying dependencies that are difficult to satisfy. 37 */ 38 39#include <sys/cdefs.h> 40#include <stdlib.h> 41#include <stdint.h> 42#include <uuid.h> 43 44typedef int8_t INT8; 45typedef int16_t INT16; 46typedef int32_t INT32; 47typedef int64_t INT64; 48typedef intptr_t INTN; 49typedef uint8_t UINT8; 50typedef uint16_t UINT16; 51typedef uint32_t UINT32; 52typedef uint64_t UINT64; 53typedef uintptr_t UINTN; 54//typedef uintptr_t EFI_PHYSICAL_ADDRESS; 55//typedef uint32_t EFI_IPv4_ADDRESS; 56//typedef uint8_t EFI_MAC_ADDRESS[6]; 57//typedef uint8_t EFI_IPv6_ADDRESS[16]; 58typedef uint8_t CHAR8; 59typedef uint16_t CHAR16; 60typedef UINT8 BOOLEAN; 61typedef void VOID; 62//typedef uuid_t GUID; 63//typedef uuid_t EFI_GUID; 64 65/* We can't actually call this stuff, so snip out API syntactic sugar */ 66#define INTERFACE_DECL(x) 67#define EFIAPI 68#define IN 69#define OUT 70#define CONST const 71#define OPTIONAL 72//#define TRUE 1 73//#define FALSE 0 74 75/* 76 * EDK2 has fine definitions for these, so let it define them. 77 */ 78#undef NULL 79#undef EFI_PAGE_SIZE 80#undef EFI_PAGE_MASK 81 82/* 83 * Note: the EDK2 code assumed #pragma packed works and PACKED is a 84 * workaround for some old toolchain issues for EDK2 that aren't 85 * relevent to FreeBSD. 86 */ 87#define PACKED 88 89/* 90 * Since we're not compiling for the UEFI boot time (which use ms abi 91 * conventions), tell EDK2 to define VA_START correctly. For the boot 92 * loader, this likely needs to be different. 93 */ 94#define NO_MSABI_VA_FUNCS 1 95 96/* 97 * Finally, we need to define the processor we are in EDK2 terms. 98 */ 99#if defined(__i386__) 100#define MDE_CPU_IA32 101#elif defined(__amd64__) 102#define MDE_CPU_X64 103#elif defined(__arm__) 104#define MDE_CPU_ARM 105#elif defined(__aarch64__) 106#define MDE_CPU_AARCH64 107#endif 108/* FreeBSD doesn't have/use MDE_CPU_EBC or MDE_CPU_IPF (ia64) */ 109 110#endif /* _EFI_OSDEP_H_ */ 111