102 lines
2.4 KiB
C
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/** @file
Copyright (C) 2016 - 2018, The HermitCrabs Lab. All rights reserved.
All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#ifndef OC_MISC_LIB_H
#define OC_MISC_LIB_H
#include <Uefi.h>
#include <Library/OcStringLib.h>
/**
The size, in Bits, of one Byte.
**/
#define OC_CHAR_BIT 8
/**
Convert seconds to microseconds for use in e.g. gBS->Stall.
**/
#define SECONDS_TO_MICROSECONDS(x) ((x)*1000000)
INT32
FindPattern (
IN CONST UINT8 *Pattern,
IN CONST UINT8 *PatternMask OPTIONAL,
IN CONST UINT32 PatternSize,
IN CONST UINT8 *Data,
IN UINT32 DataSize,
IN INT32 DataOff
);
UINT32
ApplyPatch (
IN CONST UINT8 *Pattern,
IN CONST UINT8 *PatternMask OPTIONAL,
IN CONST UINT32 PatternSize,
IN CONST UINT8 *Replace,
IN CONST UINT8 *ReplaceMask OPTIONAL,
IN UINT8 *Data,
IN UINT32 DataSize,
IN UINT32 Count,
IN UINT32 Skip
);
/**
@param[in] Protocol The published unique identifier of the protocol. It is the callers responsibility to pass in
a valid GUID.
@retval EFI_SUCCESS on success.
**/
EFI_STATUS
UninstallAllProtocolInstances (
EFI_GUID *Protocol
);
/**
Release UEFI ownership from USB controllers at booting.
**/
EFI_STATUS
ReleaseUsbOwnership (
VOID
);
/**
Perform cold reboot directly bypassing UEFI services. Does not return.
Supposed to work in any modern physical or virtual environment.
**/
VOID
DirectRestCold (
VOID
);
/**
Return the result of (Multiplicand * Multiplier / Divisor).
@param Multiplicand A 64-bit unsigned value.
@param Multiplier A 64-bit unsigned value.
@param Divisor A 32-bit unsigned value.
@param Remainder A pointer to a 32-bit unsigned value. This parameter is
optional and may be NULL.
@return Multiplicand * Multiplier / Divisor.
**/
UINT64
MultThenDivU64x64x32 (
IN UINT64 Multiplicand,
IN UINT64 Multiplier,
IN UINT32 Divisor,
OUT UINT32 *Remainder OPTIONAL
);
#endif // OC_MISC_LIB_H