EmulatorPkg: Apply uncrustify changes
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737 Apply uncrustify changes to .c/.h files in the EmulatorPkg package Cc: Andrew Fish <afish@apple.com> Cc: Leif Lindholm <leif@nuviainc.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com> Reviewed-by: Ray Ni <ray.ni@intel.com>
This commit is contained in:
committed by
mergify[bot]
parent
e7108d0e96
commit
a550d468a6
@@ -18,43 +18,41 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#include "Host.h"
|
||||
|
||||
#ifdef __APPLE__
|
||||
#define DebugAssert _Mangle__DebugAssert
|
||||
#define DebugAssert _Mangle__DebugAssert
|
||||
|
||||
#include <assert.h>
|
||||
#include <CoreServices/CoreServices.h>
|
||||
#include <mach/mach.h>
|
||||
#include <mach/mach_time.h>
|
||||
#include <assert.h>
|
||||
#include <CoreServices/CoreServices.h>
|
||||
#include <mach/mach.h>
|
||||
#include <mach/mach_time.h>
|
||||
|
||||
#undef DebugAssert
|
||||
#undef DebugAssert
|
||||
#endif
|
||||
|
||||
int settimer_initialized;
|
||||
struct timeval settimer_timeval;
|
||||
UINTN settimer_callback = 0;
|
||||
|
||||
BOOLEAN gEmulatorInterruptEnabled = FALSE;
|
||||
int settimer_initialized;
|
||||
struct timeval settimer_timeval;
|
||||
UINTN settimer_callback = 0;
|
||||
|
||||
BOOLEAN gEmulatorInterruptEnabled = FALSE;
|
||||
|
||||
UINTN
|
||||
SecWriteStdErr (
|
||||
IN UINT8 *Buffer,
|
||||
IN UINTN NumberOfBytes
|
||||
IN UINT8 *Buffer,
|
||||
IN UINTN NumberOfBytes
|
||||
)
|
||||
{
|
||||
ssize_t Return;
|
||||
ssize_t Return;
|
||||
|
||||
Return = write (STDERR_FILENO, (const void *)Buffer, (size_t)NumberOfBytes);
|
||||
|
||||
return (Return == -1) ? 0 : Return;
|
||||
}
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
SecConfigStdIn (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
struct termios tty;
|
||||
struct termios tty;
|
||||
|
||||
//
|
||||
// Need to turn off line buffering, ECHO, and make it unbuffered.
|
||||
@@ -63,7 +61,7 @@ SecConfigStdIn (
|
||||
tty.c_lflag &= ~(ICANON | ECHO);
|
||||
tcsetattr (STDIN_FILENO, TCSANOW, &tty);
|
||||
|
||||
// setvbuf (STDIN_FILENO, NULL, _IONBF, 0);
|
||||
// setvbuf (STDIN_FILENO, NULL, _IONBF, 0);
|
||||
|
||||
// now ioctl FIONREAD will do what we need
|
||||
return EFI_SUCCESS;
|
||||
@@ -71,11 +69,11 @@ SecConfigStdIn (
|
||||
|
||||
UINTN
|
||||
SecWriteStdOut (
|
||||
IN UINT8 *Buffer,
|
||||
IN UINTN NumberOfBytes
|
||||
IN UINT8 *Buffer,
|
||||
IN UINTN NumberOfBytes
|
||||
)
|
||||
{
|
||||
ssize_t Return;
|
||||
ssize_t Return;
|
||||
|
||||
Return = write (STDOUT_FILENO, (const void *)Buffer, (size_t)NumberOfBytes);
|
||||
|
||||
@@ -84,11 +82,11 @@ SecWriteStdOut (
|
||||
|
||||
UINTN
|
||||
SecReadStdIn (
|
||||
IN UINT8 *Buffer,
|
||||
IN UINTN NumberOfBytes
|
||||
IN UINT8 *Buffer,
|
||||
IN UINTN NumberOfBytes
|
||||
)
|
||||
{
|
||||
ssize_t Return;
|
||||
ssize_t Return;
|
||||
|
||||
Return = read (STDIN_FILENO, Buffer, (size_t)NumberOfBytes);
|
||||
|
||||
@@ -100,8 +98,8 @@ SecPollStdIn (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
int Result;
|
||||
int Bytes;
|
||||
int Result;
|
||||
int Bytes;
|
||||
|
||||
Result = ioctl (STDIN_FILENO, FIONREAD, &Bytes);
|
||||
if (Result == -1) {
|
||||
@@ -111,10 +109,9 @@ SecPollStdIn (
|
||||
return (BOOLEAN)(Bytes > 0);
|
||||
}
|
||||
|
||||
|
||||
VOID *
|
||||
SecMalloc (
|
||||
IN UINTN Size
|
||||
IN UINTN Size
|
||||
)
|
||||
{
|
||||
return malloc ((size_t)Size);
|
||||
@@ -122,7 +119,7 @@ SecMalloc (
|
||||
|
||||
VOID *
|
||||
SecValloc (
|
||||
IN UINTN Size
|
||||
IN UINTN Size
|
||||
)
|
||||
{
|
||||
return valloc ((size_t)Size);
|
||||
@@ -130,7 +127,7 @@ SecValloc (
|
||||
|
||||
BOOLEAN
|
||||
SecFree (
|
||||
IN VOID *Ptr
|
||||
IN VOID *Ptr
|
||||
)
|
||||
{
|
||||
if (EfiSystemMemoryRange (Ptr)) {
|
||||
@@ -143,17 +140,18 @@ SecFree (
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
settimer_handler (int sig)
|
||||
settimer_handler (
|
||||
int sig
|
||||
)
|
||||
{
|
||||
struct timeval timeval;
|
||||
UINT64 delta;
|
||||
struct timeval timeval;
|
||||
UINT64 delta;
|
||||
|
||||
gettimeofday (&timeval, NULL);
|
||||
delta = ((UINT64)timeval.tv_sec * 1000) + (timeval.tv_usec / 1000)
|
||||
- ((UINT64)settimer_timeval.tv_sec * 1000)
|
||||
- (settimer_timeval.tv_usec / 1000);
|
||||
- ((UINT64)settimer_timeval.tv_sec * 1000)
|
||||
- (settimer_timeval.tv_usec / 1000);
|
||||
settimer_timeval = timeval;
|
||||
|
||||
if (settimer_callback) {
|
||||
@@ -167,37 +165,39 @@ SecSetTimer (
|
||||
IN EMU_SET_TIMER_CALLBACK CallBack
|
||||
)
|
||||
{
|
||||
struct itimerval timerval;
|
||||
UINT32 remainder;
|
||||
struct itimerval timerval;
|
||||
UINT32 remainder;
|
||||
|
||||
if (!settimer_initialized) {
|
||||
struct sigaction act;
|
||||
struct sigaction act;
|
||||
|
||||
settimer_initialized = 1;
|
||||
act.sa_handler = settimer_handler;
|
||||
act.sa_flags = 0;
|
||||
act.sa_handler = settimer_handler;
|
||||
act.sa_flags = 0;
|
||||
sigemptyset (&act.sa_mask);
|
||||
gEmulatorInterruptEnabled = TRUE;
|
||||
if (sigaction (SIGALRM, &act, NULL) != 0) {
|
||||
printf ("SetTimer: sigaction error %s\n", strerror (errno));
|
||||
}
|
||||
|
||||
if (gettimeofday (&settimer_timeval, NULL) != 0) {
|
||||
printf ("SetTimer: gettimeofday error %s\n", strerror (errno));
|
||||
}
|
||||
}
|
||||
timerval.it_value.tv_sec = DivU64x32(PeriodMs, 1000);
|
||||
DivU64x32Remainder(PeriodMs, 1000, &remainder);
|
||||
|
||||
timerval.it_value.tv_sec = DivU64x32 (PeriodMs, 1000);
|
||||
DivU64x32Remainder (PeriodMs, 1000, &remainder);
|
||||
timerval.it_value.tv_usec = remainder * 1000;
|
||||
timerval.it_value.tv_sec = DivU64x32(PeriodMs, 1000);
|
||||
timerval.it_interval = timerval.it_value;
|
||||
timerval.it_value.tv_sec = DivU64x32 (PeriodMs, 1000);
|
||||
timerval.it_interval = timerval.it_value;
|
||||
|
||||
if (setitimer (ITIMER_REAL, &timerval, NULL) != 0) {
|
||||
printf ("SetTimer: setitimer error %s\n", strerror (errno));
|
||||
}
|
||||
|
||||
settimer_callback = (UINTN)CallBack;
|
||||
}
|
||||
|
||||
|
||||
VOID
|
||||
SecEnableInterrupt (
|
||||
VOID
|
||||
@@ -213,7 +213,6 @@ SecEnableInterrupt (
|
||||
pthread_sigmask (SIG_UNBLOCK, &sigset, NULL);
|
||||
}
|
||||
|
||||
|
||||
VOID
|
||||
SecDisableInterrupt (
|
||||
VOID
|
||||
@@ -229,14 +228,14 @@ SecDisableInterrupt (
|
||||
gEmulatorInterruptEnabled = FALSE;
|
||||
}
|
||||
|
||||
|
||||
BOOLEAN
|
||||
SecInterruptEanbled (void)
|
||||
SecInterruptEanbled (
|
||||
void
|
||||
)
|
||||
{
|
||||
return gEmulatorInterruptEnabled;
|
||||
}
|
||||
|
||||
|
||||
UINT64
|
||||
QueryPerformanceFrequency (
|
||||
VOID
|
||||
@@ -251,10 +250,9 @@ QueryPerformanceCounter (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
#if __APPLE__
|
||||
UINT64 Start;
|
||||
static mach_timebase_info_data_t sTimebaseInfo;
|
||||
|
||||
#if __APPLE__
|
||||
UINT64 Start;
|
||||
static mach_timebase_info_data_t sTimebaseInfo;
|
||||
|
||||
Start = mach_absolute_time ();
|
||||
|
||||
@@ -266,29 +264,27 @@ QueryPerformanceCounter (
|
||||
// denominator is a fraction.
|
||||
|
||||
if ( sTimebaseInfo.denom == 0 ) {
|
||||
(void) mach_timebase_info(&sTimebaseInfo);
|
||||
(void)mach_timebase_info (&sTimebaseInfo);
|
||||
}
|
||||
|
||||
// Do the maths. We hope that the multiplication doesn't
|
||||
// overflow; the price you pay for working in fixed point.
|
||||
|
||||
return (Start * sTimebaseInfo.numer) / sTimebaseInfo.denom;
|
||||
#else
|
||||
#else
|
||||
// Need to figure out what to do for Linux?
|
||||
return 0;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
VOID
|
||||
SecSleep (
|
||||
IN UINT64 Nanoseconds
|
||||
IN UINT64 Nanoseconds
|
||||
)
|
||||
{
|
||||
struct timespec rq, rm;
|
||||
struct timeval start, end;
|
||||
unsigned long MicroSec;
|
||||
struct timespec rq, rm;
|
||||
struct timeval start, end;
|
||||
unsigned long MicroSec;
|
||||
|
||||
rq.tv_sec = DivU64x32 (Nanoseconds, 1000000000);
|
||||
rq.tv_nsec = ModU64x32 (Nanoseconds, 1000000000);
|
||||
@@ -299,7 +295,7 @@ SecSleep (
|
||||
//
|
||||
gettimeofday (&start, NULL);
|
||||
end.tv_sec = start.tv_sec + rq.tv_sec;
|
||||
MicroSec = (start.tv_usec + rq.tv_nsec/1000);
|
||||
MicroSec = (start.tv_usec + rq.tv_nsec/1000);
|
||||
end.tv_usec = MicroSec % 1000000;
|
||||
if (MicroSec > 1000000) {
|
||||
end.tv_sec++;
|
||||
@@ -309,23 +305,26 @@ SecSleep (
|
||||
if (errno != EINTR) {
|
||||
break;
|
||||
}
|
||||
|
||||
gettimeofday (&start, NULL);
|
||||
if (start.tv_sec > end.tv_sec) {
|
||||
break;
|
||||
} if ((start.tv_sec == end.tv_sec) && (start.tv_usec > end.tv_usec)) {
|
||||
}
|
||||
|
||||
if ((start.tv_sec == end.tv_sec) && (start.tv_usec > end.tv_usec)) {
|
||||
break;
|
||||
}
|
||||
|
||||
rq = rm;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
VOID
|
||||
SecCpuSleep (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
struct timespec rq, rm;
|
||||
struct timespec rq, rm;
|
||||
|
||||
// nanosleep gets interrupted by the timer tic
|
||||
rq.tv_sec = 1;
|
||||
@@ -334,51 +333,47 @@ SecCpuSleep (
|
||||
nanosleep (&rq, &rm);
|
||||
}
|
||||
|
||||
|
||||
VOID
|
||||
SecExit (
|
||||
UINTN Status
|
||||
UINTN Status
|
||||
)
|
||||
{
|
||||
exit (Status);
|
||||
}
|
||||
|
||||
|
||||
VOID
|
||||
SecGetTime (
|
||||
OUT EFI_TIME *Time,
|
||||
OUT EFI_TIME_CAPABILITIES *Capabilities OPTIONAL
|
||||
OUT EFI_TIME *Time,
|
||||
OUT EFI_TIME_CAPABILITIES *Capabilities OPTIONAL
|
||||
)
|
||||
{
|
||||
struct tm *tm;
|
||||
time_t t;
|
||||
struct tm *tm;
|
||||
time_t t;
|
||||
|
||||
t = time (NULL);
|
||||
t = time (NULL);
|
||||
tm = localtime (&t);
|
||||
|
||||
Time->Year = 1900 + tm->tm_year;
|
||||
Time->Month = tm->tm_mon + 1;
|
||||
Time->Day = tm->tm_mday;
|
||||
Time->Hour = tm->tm_hour;
|
||||
Time->Minute = tm->tm_min;
|
||||
Time->Second = tm->tm_sec;
|
||||
Time->Year = 1900 + tm->tm_year;
|
||||
Time->Month = tm->tm_mon + 1;
|
||||
Time->Day = tm->tm_mday;
|
||||
Time->Hour = tm->tm_hour;
|
||||
Time->Minute = tm->tm_min;
|
||||
Time->Second = tm->tm_sec;
|
||||
Time->Nanosecond = 0;
|
||||
Time->TimeZone = timezone / 60;
|
||||
Time->Daylight = (daylight ? EFI_TIME_ADJUST_DAYLIGHT : 0)
|
||||
| (tm->tm_isdst > 0 ? EFI_TIME_IN_DAYLIGHT : 0);
|
||||
Time->TimeZone = timezone / 60;
|
||||
Time->Daylight = (daylight ? EFI_TIME_ADJUST_DAYLIGHT : 0)
|
||||
| (tm->tm_isdst > 0 ? EFI_TIME_IN_DAYLIGHT : 0);
|
||||
|
||||
if (Capabilities != NULL) {
|
||||
Capabilities->Resolution = 1;
|
||||
Capabilities->Accuracy = 50000000;
|
||||
Capabilities->SetsToZero = FALSE;
|
||||
Capabilities->Resolution = 1;
|
||||
Capabilities->Accuracy = 50000000;
|
||||
Capabilities->SetsToZero = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
VOID
|
||||
SecSetTime (
|
||||
IN EFI_TIME *Time
|
||||
IN EFI_TIME *Time
|
||||
)
|
||||
{
|
||||
// Don't change the time on the system
|
||||
@@ -386,18 +381,16 @@ SecSetTime (
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
SecGetNextProtocol (
|
||||
IN BOOLEAN EmuBusDriver,
|
||||
OUT EMU_IO_THUNK_PROTOCOL **Instance OPTIONAL
|
||||
IN BOOLEAN EmuBusDriver,
|
||||
OUT EMU_IO_THUNK_PROTOCOL **Instance OPTIONAL
|
||||
)
|
||||
{
|
||||
return GetNextThunkProtocol (EmuBusDriver, Instance);
|
||||
}
|
||||
|
||||
|
||||
EMU_THUNK_PROTOCOL gEmuThunkProtocol = {
|
||||
EMU_THUNK_PROTOCOL gEmuThunkProtocol = {
|
||||
GasketSecWriteStdErr,
|
||||
GasketSecConfigStdIn,
|
||||
GasketSecWriteStdOut,
|
||||
@@ -422,7 +415,6 @@ EMU_THUNK_PROTOCOL gEmuThunkProtocol = {
|
||||
GasketSecGetNextProtocol
|
||||
};
|
||||
|
||||
|
||||
VOID
|
||||
SecInitThunkProtocol (
|
||||
VOID
|
||||
@@ -431,4 +423,3 @@ SecInitThunkProtocol (
|
||||
// timezone and daylight lib globals depend on tzset be called 1st.
|
||||
tzset ();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user