]> code.delx.au - refind/blob - filesystems/fsw_base.h
2f6dc5ff3eefe5e75c87ec2521f8d7a9872747de
[refind] / filesystems / fsw_base.h
1 /**
2 * \file fsw_base.h
3 * Base definitions switch.
4 */
5
6 /*-
7 * This code is based on:
8 *
9 * Copyright (c) 2006 Christoph Pfisterer
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions are
13 * met:
14 *
15 * * Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 *
18 * * Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the
21 * distribution.
22 *
23 * * Neither the name of Christoph Pfisterer nor the names of the
24 * contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
26 *
27 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
30 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
32 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
34 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
35 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 */
39
40 #ifndef _FSW_BASE_H_
41 #define _FSW_BASE_H_
42
43 #ifdef HOST_EFI_EDK2
44 #define HOST_EFI
45 #endif
46
47 #ifdef HOST_EFI
48 #include "fsw_efi_base.h"
49 #endif
50
51 #ifdef HOST_POSIX
52 #include "test/fsw_posix_base.h"
53 #endif
54
55 #ifndef FSW_DEBUG_LEVEL
56 /**
57 * Global debugging level. Can be set locally for the scope of a single
58 * file by defining the macro before fsw_base.h is included.
59 */
60 #define FSW_DEBUG_LEVEL 1
61 #endif
62
63 // message printing
64
65 #if FSW_DEBUG_LEVEL >= 1
66 #define FSW_MSG_ASSERT(params) FSW_MSGFUNC params
67 #else
68 #define FSW_MSG_ASSERT(params)
69 #endif
70
71 #if FSW_DEBUG_LEVEL >= 2
72 #define FSW_MSG_DEBUG(params) FSW_MSGFUNC params
73 #else
74 #define FSW_MSG_DEBUG(params)
75 #endif
76
77 #if FSW_DEBUG_LEVEL >= 3
78 #define FSW_MSG_DEBUGV(params) FSW_MSGFUNC params
79 #else
80 #define FSW_MSG_DEBUGV(params)
81 #endif
82
83
84 // Documentation for system-dependent defines
85
86 /**
87 * \typedef fsw_s8
88 * Signed 8-bit integer.
89 */
90
91 /**
92 * \typedef fsw_u8
93 * Unsigned 8-bit integer.
94 */
95
96 /**
97 * \typedef fsw_s16
98 * Signed 16-bit integer.
99 */
100
101 /**
102 * \typedef fsw_u16
103 * Unsigned 16-bit integer.
104 */
105
106 /**
107 * \typedef fsw_s32
108 * Signed 32-bit integer.
109 */
110
111 /**
112 * \typedef fsw_u32
113 * Unsigned 32-bit integer.
114 */
115
116 /**
117 * \typedef fsw_s64
118 * Signed 64-bit integer.
119 */
120
121 /**
122 * \typedef fsw_u64
123 * Unsigned 64-bit integer.
124 */
125
126
127 /**
128 * \def fsw_alloc(size,ptrptr)
129 * Allocate memory on the heap. This function or macro allocates \a size
130 * bytes of memory using host-specific methods. The address of the
131 * allocated memory block is stored into the pointer variable pointed
132 * to by \a ptrptr. A status code is returned; FSW_SUCCESS if the block
133 * was allocated or FSW_OUT_OF_MEMORY if there is not enough memory
134 * to allocated the requested block.
135 */
136
137 /**
138 * \def fsw_free(ptr)
139 * Release allocated memory. This function or macro returns an allocated
140 * memory block to the heap for reuse. Does not return a status.
141 */
142
143 /**
144 * \def fsw_memcpy(dest,src,size)
145 * Copies a block of memory from \a src to \a dest. The two memory blocks
146 * must not overlap, or the result of the operation will be undefined.
147 * Does not return a status.
148 */
149
150 /**
151 * \def fsw_memeq(dest,src,size)
152 * Compares two blocks of memory for equality. Returns boolean true if the
153 * memory blocks are equal, boolean false if they are different.
154 */
155
156 /**
157 * \def fsw_memzero(dest,size)
158 * Initializes a block of memory with zeros. Does not return a status.
159 */
160
161
162 #endif