]> code.delx.au - refind/blob - filesystems/fsw_efi_base.h
The option flex_bg is free, since for reading, every block group correctly
[refind] / filesystems / fsw_efi_base.h
1 /* $Id: fsw_efi_base.h 29125 2010-05-06 09:43:05Z vboxsync $ */
2 /** @file
3 * fsw_efi_base.h - Base definitions for the EFI host environment.
4 */
5
6 /*
7 * Copyright (C) 2010 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18 /*-
19 * This code is based on:
20 *
21 * Copyright (c) 2006 Christoph Pfisterer
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions are
25 * met:
26 *
27 * * Redistributions of source code must retain the above copyright
28 * notice, this list of conditions and the following disclaimer.
29 *
30 * * Redistributions in binary form must reproduce the above copyright
31 * notice, this list of conditions and the following disclaimer in the
32 * documentation and/or other materials provided with the
33 * distribution.
34 *
35 * * Neither the name of Christoph Pfisterer nor the names of the
36 * contributors may be used to endorse or promote products derived
37 * from this software without specific prior written permission.
38 *
39 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
40 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
41 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
42 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
43 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
45 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
46 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
47 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
48 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
49 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
50 */
51
52 #ifndef _FSW_EFI_BASE_H_
53 #define _FSW_EFI_BASE_H_
54
55 // If its EDK2 EFI Toolkit
56 #ifdef HOST_EFI_EDK2
57 #include "fsw_efi_edk2_base.h"
58 #else
59 // Intel EFI Toolkit
60 #include <efi.h>
61 #include <efilib.h>
62 #define PROTO_NAME(x) x
63 #endif
64
65 #define FSW_LITTLE_ENDIAN (1)
66
67
68 // types, reuse EFI types
69
70 typedef INT8 fsw_s8;
71 typedef UINT8 fsw_u8;
72 typedef INT16 fsw_s16;
73 typedef UINT16 fsw_u16;
74 typedef INT32 fsw_s32;
75 typedef UINT32 fsw_u32;
76 typedef INT64 fsw_s64;
77 typedef UINT64 fsw_u64;
78
79
80 // allocation functions
81
82 #define fsw_alloc(size, ptrptr) (((*(ptrptr) = AllocatePool(size)) == NULL) ? FSW_OUT_OF_MEMORY : FSW_SUCCESS)
83 #define fsw_free(ptr) FreePool(ptr)
84
85 // memory functions
86
87 #define fsw_memzero(dest,size) ZeroMem(dest,size)
88 #define fsw_memcpy(dest,src,size) CopyMem(dest,src,size)
89 #define fsw_memeq(p1,p2,size) (CompareMem(p1,p2,size) == 0)
90
91 // message printing
92
93 #define FSW_MSGSTR(s) L##s
94 #define FSW_MSGFUNC Print
95
96 // 64-bit hooks
97
98 #define FSW_U64_SHR(val,shiftbits) RShiftU64((val), (shiftbits))
99 #define FSW_U64_DIV(val,divisor) DivU64x32((val), (divisor), NULL)
100
101
102 #endif