199767f8919635c4928607450d9e0abb932109ceToomas Soome/*-
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Copyright (c) 2004 Marcel Moolenaar
199767f8919635c4928607450d9e0abb932109ceToomas Soome * All rights reserved.
199767f8919635c4928607450d9e0abb932109ceToomas Soome *
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Redistribution and use in source and binary forms, with or without
199767f8919635c4928607450d9e0abb932109ceToomas Soome * modification, are permitted provided that the following conditions
199767f8919635c4928607450d9e0abb932109ceToomas Soome * are met:
199767f8919635c4928607450d9e0abb932109ceToomas Soome *
199767f8919635c4928607450d9e0abb932109ceToomas Soome * 1. Redistributions of source code must retain the above copyright
199767f8919635c4928607450d9e0abb932109ceToomas Soome * notice, this list of conditions and the following disclaimer.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * 2. Redistributions in binary form must reproduce the above copyright
199767f8919635c4928607450d9e0abb932109ceToomas Soome * notice, this list of conditions and the following disclaimer in the
199767f8919635c4928607450d9e0abb932109ceToomas Soome * documentation and/or other materials provided with the distribution.
199767f8919635c4928607450d9e0abb932109ceToomas Soome *
199767f8919635c4928607450d9e0abb932109ceToomas Soome * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
199767f8919635c4928607450d9e0abb932109ceToomas Soome * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
199767f8919635c4928607450d9e0abb932109ceToomas Soome * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
199767f8919635c4928607450d9e0abb932109ceToomas Soome * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
199767f8919635c4928607450d9e0abb932109ceToomas Soome * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
199767f8919635c4928607450d9e0abb932109ceToomas Soome * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
199767f8919635c4928607450d9e0abb932109ceToomas Soome * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
199767f8919635c4928607450d9e0abb932109ceToomas Soome * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
199767f8919635c4928607450d9e0abb932109ceToomas Soome * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
199767f8919635c4928607450d9e0abb932109ceToomas Soome *
199767f8919635c4928607450d9e0abb932109ceToomas Soome * $FreeBSD$
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef _SYS_EFI_H_
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define _SYS_EFI_H_
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#include <sys/uuid.h>
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define EFI_PAGE_SHIFT 12
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define EFI_PAGE_SIZE (1 << EFI_PAGE_SHIFT)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define EFI_PAGE_MASK (EFI_PAGE_SIZE - 1)
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define EFI_TABLE_ACPI20 \
199767f8919635c4928607450d9e0abb932109ceToomas Soome {0x8868e871,0xe4f1,0x11d3,0xbc,0x22,{0x00,0x80,0xc7,0x3c,0x88,0x81}}
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define EFI_TABLE_SAL \
199767f8919635c4928607450d9e0abb932109ceToomas Soome {0xeb9d2d32,0x2d88,0x11d3,0x9a,0x16,{0x00,0x90,0x27,0x3f,0xc1,0x4d}}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomeenum efi_reset {
199767f8919635c4928607450d9e0abb932109ceToomas Soome EFI_RESET_COLD,
199767f8919635c4928607450d9e0abb932109ceToomas Soome EFI_RESET_WARM
199767f8919635c4928607450d9e0abb932109ceToomas Soome};
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef uint16_t efi_char;
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef unsigned long efi_status;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomestruct efi_cfgtbl {
199767f8919635c4928607450d9e0abb932109ceToomas Soome struct uuid ct_uuid;
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint64_t ct_data;
199767f8919635c4928607450d9e0abb932109ceToomas Soome};
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomestruct efi_md {
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint32_t md_type;
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define EFI_MD_TYPE_NULL 0
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define EFI_MD_TYPE_CODE 1 /* Loader text. */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define EFI_MD_TYPE_DATA 2 /* Loader data. */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define EFI_MD_TYPE_BS_CODE 3 /* Boot services text. */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define EFI_MD_TYPE_BS_DATA 4 /* Boot services data. */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define EFI_MD_TYPE_RT_CODE 5 /* Runtime services text. */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define EFI_MD_TYPE_RT_DATA 6 /* Runtime services data. */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define EFI_MD_TYPE_FREE 7 /* Unused/free memory. */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define EFI_MD_TYPE_BAD 8 /* Bad memory */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define EFI_MD_TYPE_RECLAIM 9 /* ACPI reclaimable memory. */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define EFI_MD_TYPE_FIRMWARE 10 /* ACPI NV memory */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define EFI_MD_TYPE_IOMEM 11 /* Memory-mapped I/O. */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define EFI_MD_TYPE_IOPORT 12 /* I/O port space. */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define EFI_MD_TYPE_PALCODE 13 /* PAL */
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint32_t __pad;
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint64_t md_phys;
199767f8919635c4928607450d9e0abb932109ceToomas Soome void *md_virt;
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint64_t md_pages;
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint64_t md_attr;
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define EFI_MD_ATTR_UC 0x0000000000000001UL
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define EFI_MD_ATTR_WC 0x0000000000000002UL
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define EFI_MD_ATTR_WT 0x0000000000000004UL
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define EFI_MD_ATTR_WB 0x0000000000000008UL
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define EFI_MD_ATTR_UCE 0x0000000000000010UL
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define EFI_MD_ATTR_WP 0x0000000000001000UL
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define EFI_MD_ATTR_RP 0x0000000000002000UL
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define EFI_MD_ATTR_XP 0x0000000000004000UL
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define EFI_MD_ATTR_RT 0x8000000000000000UL
199767f8919635c4928607450d9e0abb932109ceToomas Soome};
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomestruct efi_tm {
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint16_t tm_year; /* 1998 - 20XX */
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint8_t tm_mon; /* 1 - 12 */
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint8_t tm_mday; /* 1 - 31 */
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint8_t tm_hour; /* 0 - 23 */
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint8_t tm_min; /* 0 - 59 */
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint8_t tm_sec; /* 0 - 59 */
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint8_t __pad1;
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint32_t tm_nsec; /* 0 - 999,999,999 */
199767f8919635c4928607450d9e0abb932109ceToomas Soome int16_t tm_tz; /* -1440 to 1440 or 2047 */
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint8_t tm_dst;
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint8_t __pad2;
199767f8919635c4928607450d9e0abb932109ceToomas Soome};
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomestruct efi_tmcap {
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint32_t tc_res; /* 1e-6 parts per million */
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint32_t tc_prec; /* hertz */
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint8_t tc_stz; /* Set clears sub-second time */
199767f8919635c4928607450d9e0abb932109ceToomas Soome};
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomestruct efi_tblhdr {
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint64_t th_sig;
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint32_t th_rev;
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint32_t th_hdrsz;
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint32_t th_crc32;
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint32_t __res;
199767f8919635c4928607450d9e0abb932109ceToomas Soome};
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomestruct efi_rt {
199767f8919635c4928607450d9e0abb932109ceToomas Soome struct efi_tblhdr rt_hdr;
199767f8919635c4928607450d9e0abb932109ceToomas Soome efi_status (*rt_gettime)(struct efi_tm *, struct efi_tmcap *);
199767f8919635c4928607450d9e0abb932109ceToomas Soome efi_status (*rt_settime)(struct efi_tm *);
199767f8919635c4928607450d9e0abb932109ceToomas Soome efi_status (*rt_getwaketime)(uint8_t *, uint8_t *,
199767f8919635c4928607450d9e0abb932109ceToomas Soome struct efi_tm *);
199767f8919635c4928607450d9e0abb932109ceToomas Soome efi_status (*rt_setwaketime)(uint8_t, struct efi_tm *);
199767f8919635c4928607450d9e0abb932109ceToomas Soome efi_status (*rt_setvirtual)(u_long, u_long, uint32_t,
199767f8919635c4928607450d9e0abb932109ceToomas Soome struct efi_md *);
199767f8919635c4928607450d9e0abb932109ceToomas Soome efi_status (*rt_cvtptr)(u_long, void **);
199767f8919635c4928607450d9e0abb932109ceToomas Soome efi_status (*rt_getvar)(efi_char *, struct uuid *, uint32_t *,
199767f8919635c4928607450d9e0abb932109ceToomas Soome u_long *, void *);
199767f8919635c4928607450d9e0abb932109ceToomas Soome efi_status (*rt_scanvar)(u_long *, efi_char *, struct uuid *);
199767f8919635c4928607450d9e0abb932109ceToomas Soome efi_status (*rt_setvar)(efi_char *, struct uuid *, uint32_t,
199767f8919635c4928607450d9e0abb932109ceToomas Soome u_long, void *);
199767f8919635c4928607450d9e0abb932109ceToomas Soome efi_status (*rt_gethicnt)(uint32_t *);
199767f8919635c4928607450d9e0abb932109ceToomas Soome efi_status (*rt_reset)(enum efi_reset, efi_status, u_long,
199767f8919635c4928607450d9e0abb932109ceToomas Soome efi_char *);
199767f8919635c4928607450d9e0abb932109ceToomas Soome};
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomestruct efi_systbl {
199767f8919635c4928607450d9e0abb932109ceToomas Soome struct efi_tblhdr st_hdr;
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define EFI_SYSTBL_SIG 0x5453595320494249UL
199767f8919635c4928607450d9e0abb932109ceToomas Soome efi_char *st_fwvendor;
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint32_t st_fwrev;
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint32_t __pad;
199767f8919635c4928607450d9e0abb932109ceToomas Soome void *st_cin;
199767f8919635c4928607450d9e0abb932109ceToomas Soome void *st_cinif;
199767f8919635c4928607450d9e0abb932109ceToomas Soome void *st_cout;
199767f8919635c4928607450d9e0abb932109ceToomas Soome void *st_coutif;
199767f8919635c4928607450d9e0abb932109ceToomas Soome void *st_cerr;
199767f8919635c4928607450d9e0abb932109ceToomas Soome void *st_cerrif;
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint64_t st_rt;
199767f8919635c4928607450d9e0abb932109ceToomas Soome void *st_bs;
199767f8919635c4928607450d9e0abb932109ceToomas Soome u_long st_entries;
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint64_t st_cfgtbl;
199767f8919635c4928607450d9e0abb932109ceToomas Soome};
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomeextern vm_paddr_t efi_systbl;
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif /* _SYS_EFI_H_ */