Date: Wed, 25 Oct 2006 22:36:30 GMT From: Marcel Moolenaar <marcel@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 108446 for review Message-ID: <200610252236.k9PMaUOB001566@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=108446 Change 108446 by marcel@marcel_cluster on 2006/10/25 22:36:08 Sync with the EFI 1.10.14.62 sample implementation. Affected files ... .. //depot/projects/ia64/sys/boot/efi/include/i386/efibind.h#5 edit .. //depot/projects/ia64/sys/boot/efi/include/ia64/efibind.h#5 edit Differences ... ==== //depot/projects/ia64/sys/boot/efi/include/i386/efibind.h#5 (text+ko) ==== @@ -1,7 +1,14 @@ /* $FreeBSD: src/sys/boot/efi/include/i386/efibind.h,v 1.3 2005/03/07 15:38:37 stefanf Exp $ */ /*++ -Copyright (c) 1998 Intel Corporation +Copyright (c) 1999 - 2003 Intel Corporation. All rights reserved +This software and associated documentation (if any) is furnished +under a license and may only be used or copied in accordance +with the terms of the license. Except as permitted by such +license, no part of this software or documentation may be +reproduced, stored in a retrieval system, or transmitted in any +form or by any means without the express written consent of +Intel Corporation. Module Name: @@ -18,9 +25,65 @@ --*/ +#pragma pack() + + +#ifdef __FreeBSD__ #include <sys/stdint.h> +#else +// +// Basic int types of various widths +// + +#if (__STDC_VERSION__ < 199901L ) + + // No ANSI C 1999/2000 stdint.h integer width declarations + + #if _MSC_EXTENSIONS + + // Use Microsoft C compiler integer width declarations + + typedef unsigned __int64 uint64_t; + typedef __int64 int64_t; + typedef unsigned __int32 uint32_t; + typedef __int32 int32_t; + typedef unsigned short uint16_t; + typedef short int16_t; + typedef unsigned char uint8_t; + typedef char int8_t; + #else + #ifdef UNIX_LP64 + + // Use LP64 programming model from C_FLAGS for integer width declarations + + typedef unsigned long uint64_t; + typedef long int64_t; + typedef unsigned int uint32_t; + typedef int int32_t; + typedef unsigned short uint16_t; + typedef short int16_t; + typedef unsigned char uint8_t; + typedef char int8_t; + #else + + // Assume P64 programming model from C_FLAGS for integer width declarations + + typedef unsigned long long uint64_t; + typedef long long int64_t; + typedef unsigned int uint32_t; + typedef int int32_t; + typedef unsigned short uint16_t; + typedef short int16_t; + typedef unsigned char uint8_t; + typedef char int8_t; + #endif + #endif +#endif +#endif /* __FreeBSD__ */ -/* Basic EFI types of various widths. */ +// +// Basic EFI types of various widths +// typedef uint64_t UINT64; typedef int64_t INT64; @@ -61,15 +124,11 @@ #define BAD_POINTER 0xFBFBFBFB #define MAX_ADDRESS 0xFFFFFFFF -#ifdef EFI_NT_EMULATOR - #define BREAKPOINT() __asm { int 3 } -#else - #define BREAKPOINT() while (TRUE); -#endif +#define BREAKPOINT() __asm { int 3 } -/* - * Pointers must be aligned to these address to function - */ +// +// Pointers must be aligned to these address to function +// #define MIN_ALIGNMENT_SIZE 4 @@ -80,108 +139,125 @@ Value = (UINTN)Value + (UINTN)Adjustment -/* - * Define macros to build data structure signatures from characters. - */ +// +// Define macros to build data structure signatures from characters. +// #define EFI_SIGNATURE_16(A,B) ((A) | (B<<8)) #define EFI_SIGNATURE_32(A,B,C,D) (EFI_SIGNATURE_16(A,B) | (EFI_SIGNATURE_16(C,D) << 16)) #define EFI_SIGNATURE_64(A,B,C,D,E,F,G,H) (EFI_SIGNATURE_32(A,B,C,D) | ((UINT64)(EFI_SIGNATURE_32(E,F,G,H)) << 32)) -/* - * To export & import functions in the EFI emulator environment - */ +// +// EFIAPI - prototype calling convention for EFI function pointers +// BOOTSERVICE - prototype for implementation of a boot service interface +// RUNTIMESERVICE - prototype for implementation of a runtime service interface +// RUNTIMEFUNCTION - prototype for implementation of a runtime function that is not a service +// RUNTIME_CODE - pragma macro for declaring runtime code +// -#if EFI_NT_EMULATOR - #define EXPORTAPI __declspec( dllexport ) -#else - #define EXPORTAPI -#endif - - -/* - * EFIAPI - prototype calling convention for EFI function pointers - * BOOTSERVICE - prototype for implementation of a boot service interface - * RUNTIMESERVICE - prototype for implementation of a runtime service interface - * RUNTIMEFUNCTION - prototype for implementation of a runtime function that - * is not a service - * RUNTIME_CODE - pragma macro for declaring runtime code - */ - -/* Forces EFI calling conventions reguardless of compiler options */ -#ifndef EFIAPI +#ifndef EFIAPI // Forces EFI calling conventions reguardless of compiler options #if _MSC_EXTENSIONS - #define EFIAPI __cdecl + #define EFIAPI __cdecl // Force C calling convention for Microsoft C compiler #else - #define EFIAPI + #define EFIAPI // Substitute expresion to force C calling convention #endif #endif #define BOOTSERVICE +//#define RUNTIMESERVICE(proto,a) alloc_text("rtcode",a); proto a +//#define RUNTIMEFUNCTION(proto,a) alloc_text("rtcode",a); proto a #define RUNTIMESERVICE #define RUNTIMEFUNCTION #define RUNTIME_CODE(a) alloc_text("rtcode", a) #define BEGIN_RUNTIME_DATA() data_seg("rtdata") -#define END_RUNTIME_DATA() data_seg("") +#define END_RUNTIME_DATA() data_seg() #define VOLATILE volatile #define MEMORY_FENCE() +#ifdef EFI_NO_INTERFACE_DECL + #define EFI_FORWARD_DECLARATION(x) + #define EFI_INTERFACE_DECL(x) +#else + #define EFI_FORWARD_DECLARATION(x) typedef struct _##x x + #define EFI_INTERFACE_DECL(x) typedef struct x +#endif + #ifdef EFI_NT_EMULATOR -/* - * To help ensure proper coding of integrated drivers, they are - * compiled as DLLs. In NT they require a dll init entry pointer. - * The macro puts a stub entry point into the DLL so it will load. - */ +// +// To help ensure proper coding of integrated drivers, they are +// compiled as DLLs. In NT they require a dll init entry pointer. +// The macro puts a stub entry point into the DLL so it will load. +// -#define EFI_DRIVER_ENTRY_POINT(InitFunction) \ - UINTN \ - __stdcall \ - _DllMainCRTStartup ( \ - UINTN Inst, \ - UINTN reason_for_call, \ - VOID *rserved \ - ) \ - { \ - return 1; \ - } \ - \ - int \ - EXPORTAPI \ - __cdecl \ - InitializeDriver ( \ - void *ImageHandle, \ - void *SystemTable \ - ) \ - { \ - return InitFunction(ImageHandle, SystemTable); \ +#define EFI_DRIVER_ENTRY_POINT(InitFunction) \ + EFI_STATUS \ + InitFunction ( \ + EFI_HANDLE ImageHandle, \ + EFI_SYSTEM_TABLE *SystemTable \ + ); \ + \ + UINTN \ + __stdcall \ + _DllMainCRTStartup ( \ + UINTN Inst, \ + UINTN reason_for_call, \ + VOID *rserved \ + ) \ + { \ + return 1; \ + } \ + \ + int \ + __declspec( dllexport ) \ + __cdecl \ + InitializeDriver ( \ + void *ImageHandle, \ + void *SystemTable \ + ) \ + { \ + return InitFunction(ImageHandle, SystemTable); \ } #define LOAD_INTERNAL_DRIVER(_if, type, name, entry) \ (_if)->LoadInternal(type, name, NULL) -#else /* EFI_NT_EMULATOR */ +#else // EFI_NT_EMULATOR -/* - * When build similiar to FW, then link everything together as - * one big module. - */ +// +// When build similiar to FW, then link everything together as +// one big module. +// #define EFI_DRIVER_ENTRY_POINT(InitFunction) #define LOAD_INTERNAL_DRIVER(_if, type, name, entry) \ (_if)->LoadInternal(type, name, entry) -#endif /* EFI_FW_NT */ +#endif // EFI_FW_NT +#ifdef __FreeBSD__ #define INTERFACE_DECL(x) struct x +#else +// +// Some compilers don't support the forward reference construct: +// typedef struct XXXXX +// +// The following macro provide a workaround for such cases. +// +#ifdef NO_INTERFACE_DECL +#define INTERFACE_DECL(x) +#else +#define INTERFACE_DECL(x) typedef struct x +#endif +#endif /* __FreeBSD__ */ #if _MSC_EXTENSIONS -#pragma warning ( disable : 4731 ) +#pragma warning ( disable : 4731 ) // Suppress warnings about modification of EBP #endif ==== //depot/projects/ia64/sys/boot/efi/include/ia64/efibind.h#5 (text+ko) ==== @@ -1,7 +1,14 @@ /* $FreeBSD: src/sys/boot/efi/include/ia64/efibind.h,v 1.6 2005/03/07 15:38:37 stefanf Exp $ */ /*++ -Copyright (c) 1998 Intel Corporation +Copyright (c) 1999 - 2003 Intel Corporation. All rights reserved +This software and associated documentation (if any) is furnished +under a license and may only be used or copied in accordance +with the terms of the license. Except as permitted by such +license, no part of this software or documentation may be +reproduced, stored in a retrieval system, or transmitted in any +form or by any means without the express written consent of +Intel Corporation. Module Name: @@ -18,9 +25,66 @@ --*/ +#pragma pack() + + +#ifdef __FreeBSD__ #include <sys/stdint.h> +#else +// +// Basic int types of various widths +// + +#if (__STDC_VERSION__ < 199901L ) + + // No ANSI C 1999/2000 stdint.h integer width declarations + + #if _MSC_EXTENSIONS -/* Basic EFI types of various widths. */ + // Use Microsoft C compiler integer width declarations + + typedef unsigned __int64 uint64_t; + typedef __int64 int64_t; + typedef unsigned __int32 uint32_t; + typedef __int32 int32_t; + typedef unsigned __int16 uint16_t; + typedef __int16 int16_t; + typedef unsigned __int8 uint8_t; + typedef __int8 int8_t; + #else + #ifdef UNIX_LP64 + + // Use LP64 programming model from C_FLAGS for integer width declarations + + typedef unsigned long uint64_t; + typedef long int64_t; + typedef unsigned int uint32_t; + typedef int int32_t; + typedef unsigned short uint16_t; + typedef short int16_t; + typedef unsigned char uint8_t; + typedef char int8_t; + #else + + // Assume P64 programming model from C_FLAGS for integer width declarations + + typedef unsigned long long uint64_t; + typedef long long int64_t; + typedef unsigned int uint32_t; + typedef int int32_t; + typedef unsigned short uint16_t; + typedef short int16_t; + typedef unsigned char uint8_t; + typedef char int8_t; + #endif + #endif +#endif +#endif /* __FreeBSD__ */ + +// +// Basic EFI types of various widths +// + typedef uint64_t UINT64; typedef int64_t INT64; @@ -39,17 +103,22 @@ typedef int64_t INTN; typedef uint64_t UINTN; -/* - *XXX BugBug: Code to debug - */ +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +// BugBug: Code to debug +// #define BIT63 0x8000000000000000 -#define PLATFORM_IOBASE_ADDRESS (0xffffc000000 | BIT63) +#define PLATFORM_IOBASE_ADDRESS (0xffffc000000 | BIT63) #define PORT_TO_MEMD(_Port) (PLATFORM_IOBASE_ADDRESS | ( ( ( (_Port) & 0xfffc) << 10 ) | ( (_Port) & 0x0fff) ) ) - -/* Macro's with casts make this much easier to use and read. */ + +// +// Macro's with casts make this much easier to use and read. +// #define PORT_TO_MEM8D(_Port) (*(UINT8 *)(PORT_TO_MEMD(_Port))) #define POST_CODE(_Data) (PORT_TO_MEM8D(0x80) = (_Data)) +// +// BugBug: End Debug Code!!! +//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #define EFIERR(a) (0x8000000000000000 | a) #define EFI_ERROR_MASK 0x8000000000000000 @@ -58,12 +127,13 @@ #define BAD_POINTER 0xFBFBFBFBFBFBFBFB #define MAX_ADDRESS 0xFFFFFFFFFFFFFFFF -#define BREAKPOINT() while (TRUE) +#pragma intrinsic (__break) +#define BREAKPOINT() __break(0) -/* - * Pointers must be aligned to these address to function - * you will get an alignment fault if this value is less than 8 - */ +// +// Pointers must be aligned to these address to function +// you will get an alignment fault if this value is less than 8 +// #define MIN_ALIGNMENT_SIZE 8 #define ALIGN_VARIABLE(Value , Adjustment) \ @@ -72,34 +142,28 @@ (UINTN)Adjustment = MIN_ALIGNMENT_SIZE - ((UINTN)Value % MIN_ALIGNMENT_SIZE); \ Value = (UINTN)Value + (UINTN)Adjustment -/* - * Define macros to create data structure signatures. - */ +// +// Define macros to create data structure signatures. +// #define EFI_SIGNATURE_16(A,B) ((A) | (B<<8)) #define EFI_SIGNATURE_32(A,B,C,D) (EFI_SIGNATURE_16(A,B) | (EFI_SIGNATURE_16(C,D) << 16)) #define EFI_SIGNATURE_64(A,B,C,D,E,F,G,H) (EFI_SIGNATURE_32(A,B,C,D) | ((UINT64)(EFI_SIGNATURE_32(E,F,G,H)) << 32)) -/* - * To export & import functions in the EFI emulator environment - */ +// +// EFIAPI - prototype calling convention for EFI function pointers +// BOOTSERVICE - prototype for implementation of a boot service interface +// RUNTIMESERVICE - prototype for implementation of a runtime service interface +// RUNTIMEFUNCTION - prototype for implementation of a runtime function that is not a service +// RUNTIME_CODE - pragma macro for declaring runtime code +// -#define EXPORTAPI - -/* - * EFIAPI - prototype calling convention for EFI function pointers - * BOOTSERVICE - prototype for implementation of a boot service interface - * RUNTIMESERVICE - prototype for implementation of a runtime service interface - * RUNTIMEFUNCTION - prototype for implementation of a runtime function that is not a service - * RUNTIME_CODE - pragma macro for declaring runtime code - */ - -#ifndef EFIAPI /* Forces EFI calling conventions reguardless of compiler options */ -#if _MSC_EXTENSIONS -#define EFIAPI __cdecl -#else -#define EFIAPI -#endif +#ifndef EFIAPI // Forces EFI calling conventions reguardless of compiler options + #if _MSC_EXTENSIONS + #define EFIAPI __cdecl // Force C calling convention for Microsoft C compiler + #else + #define EFIAPI // Substitute expresion to force C calling convention + #endif #endif #define BOOTSERVICE @@ -108,27 +172,48 @@ #define RUNTIME_CODE(a) alloc_text("rtcode", a) #define BEGIN_RUNTIME_DATA() data_seg("rtdata") -#define END_RUNTIME_DATA() data_seg("") +#define END_RUNTIME_DATA() data_seg() #define VOLATILE volatile -/* - * XXX Need to find out if this is portable across compilers. - */ -void __mf (void); -#ifndef __GNUC__ -#pragma intrinsic (__mf) +// +// BugBug: Need to find out if this is portable accross compliers. +// +void __mfa (void); +#pragma intrinsic (__mfa) +#define MEMORY_FENCE() __mfa() + +#ifdef EFI_NO_INTERFACE_DECL + #define EFI_FORWARD_DECLARATION(x) + #define EFI_INTERFACE_DECL(x) +#else + #define EFI_FORWARD_DECLARATION(x) typedef struct _##x x + #define EFI_INTERFACE_DECL(x) typedef struct x #endif -#define MEMORY_FENCE() __mf() -/* - * When build similiar to FW, then link everything together as - * one big module. - */ +// +// When build similiar to FW, then link everything together as +// one big module. +// #define EFI_DRIVER_ENTRY_POINT(InitFunction) #define LOAD_INTERNAL_DRIVER(_if, type, name, entry) \ - (_if)->LoadInternal(type, name, entry) + (_if)->LoadInternal(type, name, entry) +// entry(NULL, ST) +#ifdef __FreeBSD__ #define INTERFACE_DECL(x) struct x +#else +// +// Some compilers don't support the forward reference construct: +// typedef struct XXXXX +// +// The following macro provide a workaround for such cases. +// +#ifdef NO_INTERFACE_DECL +#define INTERFACE_DECL(x) +#else +#define INTERFACE_DECL(x) typedef struct x +#endif +#endif
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200610252236.k9PMaUOB001566>