[48674] | 1 | /* $Id: fsw_base.h 98103 2023-01-17 14:15:46Z vboxsync $ */
|
---|
| 2 | /** @file
|
---|
| 3 | * fsw_base.h - Base definitions switch.
|
---|
| 4 | */
|
---|
| 5 |
|
---|
| 6 | /*
|
---|
[98103] | 7 | * Copyright (C) 2010-2023 Oracle and/or its affiliates.
|
---|
[48674] | 8 | *
|
---|
[96407] | 9 | * This file is part of VirtualBox base platform packages, as
|
---|
| 10 | * available from https://www.virtualbox.org.
|
---|
[48674] | 11 | *
|
---|
[96407] | 12 | * This program is free software; you can redistribute it and/or
|
---|
| 13 | * modify it under the terms of the GNU General Public License
|
---|
| 14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
| 15 | * License.
|
---|
| 16 | *
|
---|
| 17 | * This program is distributed in the hope that it will be useful, but
|
---|
| 18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
| 20 | * General Public License for more details.
|
---|
| 21 | *
|
---|
| 22 | * You should have received a copy of the GNU General Public License
|
---|
| 23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
| 24 | *
|
---|
[48674] | 25 | * The contents of this file may alternatively be used under the terms
|
---|
| 26 | * of the Common Development and Distribution License Version 1.0
|
---|
[96407] | 27 | * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
|
---|
| 28 | * in the VirtualBox distribution, in which case the provisions of the
|
---|
[48674] | 29 | * CDDL are applicable instead of those of the GPL.
|
---|
| 30 | *
|
---|
| 31 | * You may elect to license modified versions of this file under the
|
---|
| 32 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
[96407] | 33 | *
|
---|
| 34 | * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
|
---|
[69498] | 35 | * ---------------------------------------------------------------------------
|
---|
[48674] | 36 | * This code is based on:
|
---|
| 37 | *
|
---|
| 38 | * Copyright (c) 2006 Christoph Pfisterer
|
---|
| 39 | *
|
---|
| 40 | * Redistribution and use in source and binary forms, with or without
|
---|
| 41 | * modification, are permitted provided that the following conditions are
|
---|
| 42 | * met:
|
---|
| 43 | *
|
---|
| 44 | * * Redistributions of source code must retain the above copyright
|
---|
| 45 | * notice, this list of conditions and the following disclaimer.
|
---|
| 46 | *
|
---|
| 47 | * * Redistributions in binary form must reproduce the above copyright
|
---|
| 48 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 49 | * documentation and/or other materials provided with the
|
---|
| 50 | * distribution.
|
---|
| 51 | *
|
---|
| 52 | * * Neither the name of Christoph Pfisterer nor the names of the
|
---|
| 53 | * contributors may be used to endorse or promote products derived
|
---|
| 54 | * from this software without specific prior written permission.
|
---|
| 55 | *
|
---|
| 56 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
---|
| 57 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
---|
| 58 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
---|
| 59 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
---|
| 60 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
---|
| 61 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
---|
| 62 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 63 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 64 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 65 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
---|
| 66 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 67 | */
|
---|
| 68 |
|
---|
| 69 | #ifndef _FSW_BASE_H_
|
---|
| 70 | #define _FSW_BASE_H_
|
---|
| 71 |
|
---|
| 72 | #ifdef VBOX
|
---|
| 73 | #include "VBoxFswParam.h"
|
---|
| 74 | #endif
|
---|
| 75 |
|
---|
| 76 | #ifndef FSW_DEBUG_LEVEL
|
---|
| 77 | /**
|
---|
| 78 | * Global debugging level. Can be set locally for the scope of a single
|
---|
| 79 | * file by defining the macro before fsw_base.h is included.
|
---|
| 80 | */
|
---|
| 81 | #define FSW_DEBUG_LEVEL 1
|
---|
| 82 | #endif
|
---|
| 83 |
|
---|
| 84 |
|
---|
| 85 | #ifdef HOST_EFI
|
---|
| 86 | #include "fsw_efi_base.h"
|
---|
| 87 | #endif
|
---|
| 88 |
|
---|
| 89 | #ifdef HOST_POSIX
|
---|
| 90 | #include "fsw_posix_base.h"
|
---|
| 91 | #endif
|
---|
| 92 |
|
---|
| 93 | // message printing
|
---|
| 94 |
|
---|
| 95 | #if FSW_DEBUG_LEVEL >= 1
|
---|
| 96 | #define FSW_MSG_ASSERT(params) FSW_MSGFUNC params
|
---|
| 97 | #else
|
---|
| 98 | #define FSW_MSG_ASSERT(params)
|
---|
| 99 | #endif
|
---|
| 100 |
|
---|
| 101 | #if FSW_DEBUG_LEVEL >= 2
|
---|
| 102 | #define FSW_MSG_DEBUG(params) FSW_MSGFUNC params
|
---|
| 103 | #else
|
---|
| 104 | #define FSW_MSG_DEBUG(params)
|
---|
| 105 | #endif
|
---|
| 106 |
|
---|
| 107 | #if FSW_DEBUG_LEVEL >= 3
|
---|
| 108 | #define FSW_MSG_DEBUGV(params) FSW_MSGFUNC params
|
---|
| 109 | #else
|
---|
| 110 | #define FSW_MSG_DEBUGV(params)
|
---|
| 111 | #endif
|
---|
| 112 |
|
---|
| 113 |
|
---|
| 114 | // Documentation for system-dependent defines
|
---|
| 115 |
|
---|
| 116 | /**
|
---|
| 117 | * \typedef fsw_s8
|
---|
| 118 | * Signed 8-bit integer.
|
---|
| 119 | */
|
---|
| 120 |
|
---|
| 121 | /**
|
---|
| 122 | * \typedef fsw_u8
|
---|
| 123 | * Unsigned 8-bit integer.
|
---|
| 124 | */
|
---|
| 125 |
|
---|
| 126 | /**
|
---|
| 127 | * \typedef fsw_s16
|
---|
| 128 | * Signed 16-bit integer.
|
---|
| 129 | */
|
---|
| 130 |
|
---|
| 131 | /**
|
---|
| 132 | * \typedef fsw_u16
|
---|
| 133 | * Unsigned 16-bit integer.
|
---|
| 134 | */
|
---|
| 135 |
|
---|
| 136 | /**
|
---|
| 137 | * \typedef fsw_s32
|
---|
| 138 | * Signed 32-bit integer.
|
---|
| 139 | */
|
---|
| 140 |
|
---|
| 141 | /**
|
---|
| 142 | * \typedef fsw_u32
|
---|
| 143 | * Unsigned 32-bit integer.
|
---|
| 144 | */
|
---|
| 145 |
|
---|
| 146 | /**
|
---|
| 147 | * \typedef fsw_s64
|
---|
| 148 | * Signed 64-bit integer.
|
---|
| 149 | */
|
---|
| 150 |
|
---|
| 151 | /**
|
---|
| 152 | * \typedef fsw_u64
|
---|
| 153 | * Unsigned 64-bit integer.
|
---|
| 154 | */
|
---|
| 155 |
|
---|
| 156 |
|
---|
| 157 | /**
|
---|
| 158 | * \def fsw_alloc(size,ptrptr)
|
---|
| 159 | * Allocate memory on the heap. This function or macro allocates \a size
|
---|
| 160 | * bytes of memory using host-specific methods. The address of the
|
---|
| 161 | * allocated memory block is stored into the pointer variable pointed
|
---|
| 162 | * to by \a ptrptr. A status code is returned; FSW_SUCCESS if the block
|
---|
| 163 | * was allocated or FSW_OUT_OF_MEMORY if there is not enough memory
|
---|
| 164 | * to allocated the requested block.
|
---|
| 165 | */
|
---|
| 166 |
|
---|
| 167 | /**
|
---|
| 168 | * \def fsw_free(ptr)
|
---|
| 169 | * Release allocated memory. This function or macro returns an allocated
|
---|
| 170 | * memory block to the heap for reuse. Does not return a status.
|
---|
| 171 | */
|
---|
| 172 |
|
---|
| 173 | /**
|
---|
| 174 | * \def fsw_memcpy(dest,src,size)
|
---|
| 175 | * Copies a block of memory from \a src to \a dest. The two memory blocks
|
---|
| 176 | * must not overlap, or the result of the operation will be undefined.
|
---|
| 177 | * Does not return a status.
|
---|
| 178 | */
|
---|
| 179 |
|
---|
| 180 | /**
|
---|
| 181 | * \def fsw_memeq(dest,src,size)
|
---|
| 182 | * Compares two blocks of memory for equality. Returns boolean true if the
|
---|
| 183 | * memory blocks are equal, boolean false if they are different.
|
---|
| 184 | */
|
---|
| 185 |
|
---|
| 186 | /**
|
---|
| 187 | * \def fsw_memzero(dest,size)
|
---|
| 188 | * Initializes a block of memory with zeros. Does not return a status.
|
---|
| 189 | */
|
---|
| 190 |
|
---|
| 191 |
|
---|
| 192 | #endif
|
---|