I did a quick review of the MS x86_64 calling convention for floating

point and as far as I can tell it agrees with the UEFI spec.
The attached patch removes -mno-mmx and -mno-sse for x86_64 and adds
a new Print target, "%f", to print float and double types.

It seems to compile for ia32, although I'm not sure why - shouldn't
it be throwing errors because the new function FloatToStr() in print.c
accepts a float, yet I left -no-sse for ARCH=ia32? A better solution
might be to add -msoft-float for targets where the floating point
calling convention doesn't match the UEFI spec. As I'm not familiar
with UEFI on ia32, I didn't make any changes to it.

Signed-off-by: Nathan Blythe <nblythe@lgsinnovations.com>
Signed-off-by: Nigel Croxon <nigel.croxon@hpe.com>
This commit is contained in:
Nigel Croxon 2016-06-17 10:07:25 -04:00
parent 8118d08727
commit b2c4db065f
3 changed files with 52 additions and 1 deletions

View File

@ -111,7 +111,7 @@ ifeq ($(ARCH),x86_64)
CPPFLAGS += -DGNU_EFI_USE_MS_ABI -maccumulate-outgoing-args --std=c11 CPPFLAGS += -DGNU_EFI_USE_MS_ABI -maccumulate-outgoing-args --std=c11
endif endif
CFLAGS += -mno-red-zone -mno-mmx -mno-sse CFLAGS += -mno-red-zone
ifeq ($(HOSTARCH),ia32) ifeq ($(HOSTARCH),ia32)
ARCH3264 = -m64 ARCH3264 = -m64
endif endif

View File

@ -499,6 +499,13 @@ ValueToString (
IN INT64 v IN INT64 v
); );
VOID
FloatToString (
IN CHAR16 *Buffer,
IN BOOLEAN Comma,
IN double v
);
VOID VOID
TimeToString ( TimeToString (
OUT CHAR16 *Buffer, OUT CHAR16 *Buffer,

View File

@ -1000,6 +1000,7 @@ Routine Description:
x - hex value x - hex value
d - value as signed decimal d - value as signed decimal
u - value as unsigned decimal u - value as unsigned decimal
f - value as floating point
c - Unicode char c - Unicode char
t - EFI time structure t - EFI time structure
g - Pointer to GUID g - Pointer to GUID
@ -1163,6 +1164,15 @@ Returns:
); );
break; break;
case 'f':
Item.Item.pw = Item.Scratch;
FloatToString (
Item.Item.pw,
Item.Comma,
va_arg(ps->args, double)
);
break;
case 't': case 't':
Item.Item.pw = Item.Scratch; Item.Item.pw = Item.Scratch;
TimeToString (Item.Item.pw, va_arg(ps->args, EFI_TIME *)); TimeToString (Item.Item.pw, va_arg(ps->args, EFI_TIME *));
@ -1307,6 +1317,40 @@ ValueToString (
*p2 = 0; *p2 = 0;
} }
VOID
FloatToString (
IN CHAR16 *Buffer,
IN BOOLEAN Comma,
IN double v
)
{
/*
* Integer part.
*/
INTN i = (INTN)v;
ValueToString(Buffer, Comma, i);
/*
* Decimal point.
*/
UINTN x = StrLen(Buffer);
Buffer[x] = L'.';
/*
* Fractional part.
*/
float f = v - (float)i;
if (f < 0) f = -f;
while ((float)(INTN)f != f)
{
f *= 10;
}
ValueToString(Buffer + x + 1, FALSE, (INTN)f);
return;
}
VOID VOID
TimeToString ( TimeToString (
OUT CHAR16 *Buffer, OUT CHAR16 *Buffer,