Add a way for the architecture to specify the calling ABI for methods

in the EFI Runtime Services Table.  On amd64, the calling conventions
are MS.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
This commit is contained in:
Konstantin Belousov 2016-09-21 10:35:44 +00:00
parent 67330db0bb
commit 559a7b209a
4 changed files with 131 additions and 11 deletions

42
sys/amd64/include/efi.h Normal file
View File

@ -0,0 +1,42 @@
/*-
* Copyright (c) 2016 The FreeBSD Foundation
* All rights reserved.
*
* This software was developed by Konstantin Belousov <kib@FreeBSD.org>
* under sponsorship from the FreeBSD Foundation.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
#ifndef __AMD64_INCLUDE_EFI_H_
#define __AMD64_INCLUDE_EFI_H_
/*
* XXX: from gcc 6.2 manual:
* Note, the ms_abi attribute for Microsoft Windows 64-bit targets
* currently requires the -maccumulate-outgoing-args option.
*/
#define EFIABI_ATTR __attribute__((ms_abi))
#endif /* __AMD64_INCLUDE_EFI_H_ */

37
sys/arm/include/efi.h Normal file
View File

@ -0,0 +1,37 @@
/*-
* Copyright (c) 2016 The FreeBSD Foundation
* All rights reserved.
*
* This software was developed by Konstantin Belousov <kib@FreeBSD.org>
* under sponsorship from the FreeBSD Foundation.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
#ifndef __ARM_INCLUDE_EFI_H_
#define __ARM_INCLUDE_EFI_H_
#define EFIABI_ATTR
#endif /* __ARM_INCLUDE_EFI_H_ */

37
sys/arm64/include/efi.h Normal file
View File

@ -0,0 +1,37 @@
/*-
* Copyright (c) 2016 The FreeBSD Foundation
* All rights reserved.
*
* This software was developed by Konstantin Belousov <kib@FreeBSD.org>
* under sponsorship from the FreeBSD Foundation.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
#ifndef __ARM64_INCLUDE_EFI_H_
#define __ARM64_INCLUDE_EFI_H_
#define EFIABI_ATTR
#endif /* __ARM64_INCLUDE_EFI_H_ */

View File

@ -30,6 +30,7 @@
#define _SYS_EFI_H_
#include <sys/uuid.h>
#include <machine/efi.h>
#define EFI_PAGE_SHIFT 12
#define EFI_PAGE_SIZE (1 << EFI_PAGE_SHIFT)
@ -123,22 +124,25 @@ struct efi_tblhdr {
struct efi_rt {
struct efi_tblhdr rt_hdr;
efi_status (*rt_gettime)(struct efi_tm *, struct efi_tmcap *);
efi_status (*rt_settime)(struct efi_tm *);
efi_status (*rt_gettime)(struct efi_tm *, struct efi_tmcap *)
EFIABI_ATTR;
efi_status (*rt_settime)(struct efi_tm *) EFIABI_ATTR;
efi_status (*rt_getwaketime)(uint8_t *, uint8_t *,
struct efi_tm *);
efi_status (*rt_setwaketime)(uint8_t, struct efi_tm *);
struct efi_tm *) EFIABI_ATTR;
efi_status (*rt_setwaketime)(uint8_t, struct efi_tm *)
EFIABI_ATTR;
efi_status (*rt_setvirtual)(u_long, u_long, uint32_t,
struct efi_md *);
efi_status (*rt_cvtptr)(u_long, void **);
struct efi_md *) EFIABI_ATTR;
efi_status (*rt_cvtptr)(u_long, void **) EFIABI_ATTR;
efi_status (*rt_getvar)(efi_char *, struct uuid *, uint32_t *,
u_long *, void *);
efi_status (*rt_scanvar)(u_long *, efi_char *, struct uuid *);
u_long *, void *) EFIABI_ATTR;
efi_status (*rt_scanvar)(u_long *, efi_char *, struct uuid *)
EFIABI_ATTR;
efi_status (*rt_setvar)(efi_char *, struct uuid *, uint32_t,
u_long, void *);
efi_status (*rt_gethicnt)(uint32_t *);
u_long, void *) EFIABI_ATTR;
efi_status (*rt_gethicnt)(uint32_t *) EFIABI_ATTR;
efi_status (*rt_reset)(enum efi_reset, efi_status, u_long,
efi_char *);
efi_char *) EFIABI_ATTR;
};
struct efi_systbl {