-
Notifications
You must be signed in to change notification settings - Fork 0
/
Utils.hpp
45 lines (44 loc) · 1.69 KB
/
Utils.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#pragma once
#include <Boot/Setup.hpp>
#include <Uefi.h>
#ifdef DEBUG
#define ERROR_RETURNS( Expression ) \
do \
{ \
EFI_STATUS Status { Expression }; \
if ( EFI_ERROR( Status ) ) \
{ \
return Status; \
} \
} while ( FALSE );
#else
#define ERR_RETS( Expression )
#endif
#ifdef DEBUG
#define ERROR_RETURN( Status ) \
{ \
if ( EFI_ERROR( Status ) ) \
{ \
return; \
} \
}
#else
#define ERR_RET( Status )
#endif
/* Get power number of unsigned types X^Y*/
using size_t = unsigned long;
namespace QuantumNEC::Boot {
bool PowerU64( UINT64 X, UINTN Y );
} // namespace QuantumNEC::Boot
VOID *operator new( size_t size ) noexcept;
VOID *operator new[]( size_t cb ) noexcept;
VOID *operator new( unsigned long int, VOID *address ) noexcept;
VOID operator delete( VOID *, size_t ) noexcept;
VOID operator delete( VOID *address ) noexcept;
VOID operator delete[]( VOID *address ) noexcept;
#define _cpuid( __func, __eax, __ebx, __ecx, __edx ) \
__asm__ __volatile__( "xchgq %%rbx,%q1\n" \
"cpuid\n" \
"xchgq %%rbx,%q1" \
: "=a"( __eax ), "=r"( __ebx ), "=c"( __ecx ), "=d"( __edx ) \
: "0"( __func ) : )