From b9c8e50e2054fc21c2029db309f813d03ccd6082 Mon Sep 17 00:00:00 2001 From: andrewfish Date: Thu, 22 Jul 2010 21:21:38 +0000 Subject: Port UnixPkg to also support X64. Currently only supports Unix x86_64 ABI. In the future we can make Sec support x86_64 ABI and the rest of the code support X64 EFI ABI. This will require assembly gaskets to fix the calling convention differences. I currently have noop gaskets in place for x86_64 ABI. This has only been tested on OS X 10.6. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10685 6f19259b-4bc3-4df7-8a09-765794883524 --- UnixPkg/Sec/UnixThunk.c | 53 ++++++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 25 deletions(-) (limited to 'UnixPkg/Sec/UnixThunk.c') diff --git a/UnixPkg/Sec/UnixThunk.c b/UnixPkg/Sec/UnixThunk.c index 252c7e62a4..08cdd62157 100644 --- a/UnixPkg/Sec/UnixThunk.c +++ b/UnixPkg/Sec/UnixThunk.c @@ -55,8 +55,14 @@ settimer_handler (int sig) - ((UINT64)settimer_timeval.tv_sec * 1000) - (settimer_timeval.tv_usec / 1000); settimer_timeval = timeval; - if (settimer_callback) - (*settimer_callback)(delta); + + if (settimer_callback) { +#ifdef __APPLE__ + ReverseGasketUint64 (settimer_callback, delta); +#else + (*settimer_callback)(delta); +#endif + } } VOID @@ -94,13 +100,18 @@ SetTimer (UINT64 PeriodMs, VOID (*CallBack)(UINT64 DeltaMs)) void msSleep (unsigned long Milliseconds) { - struct timespec ts; + struct timespec rq, rm; - ts.tv_sec = Milliseconds / 1000; - ts.tv_nsec = (Milliseconds % 1000) * 1000000; + rq.tv_sec = Milliseconds / 1000; + rq.tv_nsec = (Milliseconds % 1000) * 1000000; - while (nanosleep (&ts, &ts) != 0 && errno == EINTR) - ; + while (nanosleep (&rq, &rm) != -1) { + if (errno != EINTR) { + break; + } + rq = rm; + } + } void @@ -174,20 +185,20 @@ EFI_UNIX_THUNK_PROTOCOL mUnixThunkTable = { Gasketgmtime, GasketGetTimeZone, GasketGetDayLight, - (UnixPoll)Gasketpoll, - (UnixRead)Gasketread, - (UnixWrite)Gasketwrite, + Gasketpoll, + Gasketread, + Gasketwrite, Gasketgetenv, - (UnixOpen)Gasketopen, - (UnixSeek)Gasketlseek, - (UnixFtruncate)Gasketftruncate, + Gasketopen, + Gasketlseek, + Gasketftruncate, Gasketclose, Gasketmkdir, Gasketrmdir, Gasketunlink, GasketGetErrno, Gasketopendir, - (UnixRewindDir)Gasketrewinddir, + Gasketrewinddir, Gasketreaddir, Gasketclosedir, Gasketstat, @@ -206,14 +217,9 @@ EFI_UNIX_THUNK_PROTOCOL mUnixThunkTable = { Gasketcfsetospeed, Gaskettcgetattr, Gaskettcsetattr, - - dlopen, // Update me with a gasket - dlerror, // Update me with a gasket - dlsym, // Update me with a gasket - - SecPeCoffGetEntryPoint, // Update me with a gasket - SecPeCoffRelocateImageExtraAction, // Update me with a gasket - SecPeCoffLoaderUnloadImageExtraAction // Update me with a gasket + GasketUnixPeCoffGetEntryPoint, + GasketUnixPeCoffRelocateImageExtraAction, + GasketUnixPeCoffUnloadImageExtraAction #else msSleep, /* Sleep */ @@ -255,9 +261,6 @@ EFI_UNIX_THUNK_PROTOCOL mUnixThunkTable = { cfsetospeed, tcgetattr, tcsetattr, - dlopen, - dlerror, - dlsym, SecPeCoffGetEntryPoint, SecPeCoffRelocateImageExtraAction, SecPeCoffLoaderUnloadImageExtraAction -- cgit v1.2.3