1*199767f8SToomas Soome /*- 2*199767f8SToomas Soome * Copyright (c) 2004 Marcel Moolenaar 3*199767f8SToomas Soome * All rights reserved. 4*199767f8SToomas Soome * 5*199767f8SToomas Soome * Redistribution and use in source and binary forms, with or without 6*199767f8SToomas Soome * modification, are permitted provided that the following conditions 7*199767f8SToomas Soome * are met: 8*199767f8SToomas Soome * 9*199767f8SToomas Soome * 1. Redistributions of source code must retain the above copyright 10*199767f8SToomas Soome * notice, this list of conditions and the following disclaimer. 11*199767f8SToomas Soome * 2. Redistributions in binary form must reproduce the above copyright 12*199767f8SToomas Soome * notice, this list of conditions and the following disclaimer in the 13*199767f8SToomas Soome * documentation and/or other materials provided with the distribution. 14*199767f8SToomas Soome * 15*199767f8SToomas Soome * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16*199767f8SToomas Soome * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17*199767f8SToomas Soome * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18*199767f8SToomas Soome * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19*199767f8SToomas Soome * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20*199767f8SToomas Soome * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21*199767f8SToomas Soome * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22*199767f8SToomas Soome * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23*199767f8SToomas Soome * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24*199767f8SToomas Soome * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25*199767f8SToomas Soome * 26*199767f8SToomas Soome * $FreeBSD$ 27*199767f8SToomas Soome */ 28*199767f8SToomas Soome 29*199767f8SToomas Soome #ifndef _SYS_EFI_H_ 30*199767f8SToomas Soome #define _SYS_EFI_H_ 31*199767f8SToomas Soome 32*199767f8SToomas Soome #include <sys/uuid.h> 33*199767f8SToomas Soome 34*199767f8SToomas Soome #define EFI_PAGE_SHIFT 12 35*199767f8SToomas Soome #define EFI_PAGE_SIZE (1 << EFI_PAGE_SHIFT) 36*199767f8SToomas Soome #define EFI_PAGE_MASK (EFI_PAGE_SIZE - 1) 37*199767f8SToomas Soome 38*199767f8SToomas Soome #define EFI_TABLE_ACPI20 \ 39*199767f8SToomas Soome {0x8868e871,0xe4f1,0x11d3,0xbc,0x22,{0x00,0x80,0xc7,0x3c,0x88,0x81}} 40*199767f8SToomas Soome #define EFI_TABLE_SAL \ 41*199767f8SToomas Soome {0xeb9d2d32,0x2d88,0x11d3,0x9a,0x16,{0x00,0x90,0x27,0x3f,0xc1,0x4d}} 42*199767f8SToomas Soome 43*199767f8SToomas Soome enum efi_reset { 44*199767f8SToomas Soome EFI_RESET_COLD, 45*199767f8SToomas Soome EFI_RESET_WARM 46*199767f8SToomas Soome }; 47*199767f8SToomas Soome 48*199767f8SToomas Soome typedef uint16_t efi_char; 49*199767f8SToomas Soome typedef unsigned long efi_status; 50*199767f8SToomas Soome 51*199767f8SToomas Soome struct efi_cfgtbl { 52*199767f8SToomas Soome struct uuid ct_uuid; 53*199767f8SToomas Soome uint64_t ct_data; 54*199767f8SToomas Soome }; 55*199767f8SToomas Soome 56*199767f8SToomas Soome struct efi_md { 57*199767f8SToomas Soome uint32_t md_type; 58*199767f8SToomas Soome #define EFI_MD_TYPE_NULL 0 59*199767f8SToomas Soome #define EFI_MD_TYPE_CODE 1 /* Loader text. */ 60*199767f8SToomas Soome #define EFI_MD_TYPE_DATA 2 /* Loader data. */ 61*199767f8SToomas Soome #define EFI_MD_TYPE_BS_CODE 3 /* Boot services text. */ 62*199767f8SToomas Soome #define EFI_MD_TYPE_BS_DATA 4 /* Boot services data. */ 63*199767f8SToomas Soome #define EFI_MD_TYPE_RT_CODE 5 /* Runtime services text. */ 64*199767f8SToomas Soome #define EFI_MD_TYPE_RT_DATA 6 /* Runtime services data. */ 65*199767f8SToomas Soome #define EFI_MD_TYPE_FREE 7 /* Unused/free memory. */ 66*199767f8SToomas Soome #define EFI_MD_TYPE_BAD 8 /* Bad memory */ 67*199767f8SToomas Soome #define EFI_MD_TYPE_RECLAIM 9 /* ACPI reclaimable memory. */ 68*199767f8SToomas Soome #define EFI_MD_TYPE_FIRMWARE 10 /* ACPI NV memory */ 69*199767f8SToomas Soome #define EFI_MD_TYPE_IOMEM 11 /* Memory-mapped I/O. */ 70*199767f8SToomas Soome #define EFI_MD_TYPE_IOPORT 12 /* I/O port space. */ 71*199767f8SToomas Soome #define EFI_MD_TYPE_PALCODE 13 /* PAL */ 72*199767f8SToomas Soome uint32_t __pad; 73*199767f8SToomas Soome uint64_t md_phys; 74*199767f8SToomas Soome void *md_virt; 75*199767f8SToomas Soome uint64_t md_pages; 76*199767f8SToomas Soome uint64_t md_attr; 77*199767f8SToomas Soome #define EFI_MD_ATTR_UC 0x0000000000000001UL 78*199767f8SToomas Soome #define EFI_MD_ATTR_WC 0x0000000000000002UL 79*199767f8SToomas Soome #define EFI_MD_ATTR_WT 0x0000000000000004UL 80*199767f8SToomas Soome #define EFI_MD_ATTR_WB 0x0000000000000008UL 81*199767f8SToomas Soome #define EFI_MD_ATTR_UCE 0x0000000000000010UL 82*199767f8SToomas Soome #define EFI_MD_ATTR_WP 0x0000000000001000UL 83*199767f8SToomas Soome #define EFI_MD_ATTR_RP 0x0000000000002000UL 84*199767f8SToomas Soome #define EFI_MD_ATTR_XP 0x0000000000004000UL 85*199767f8SToomas Soome #define EFI_MD_ATTR_RT 0x8000000000000000UL 86*199767f8SToomas Soome }; 87*199767f8SToomas Soome 88*199767f8SToomas Soome struct efi_tm { 89*199767f8SToomas Soome uint16_t tm_year; /* 1998 - 20XX */ 90*199767f8SToomas Soome uint8_t tm_mon; /* 1 - 12 */ 91*199767f8SToomas Soome uint8_t tm_mday; /* 1 - 31 */ 92*199767f8SToomas Soome uint8_t tm_hour; /* 0 - 23 */ 93*199767f8SToomas Soome uint8_t tm_min; /* 0 - 59 */ 94*199767f8SToomas Soome uint8_t tm_sec; /* 0 - 59 */ 95*199767f8SToomas Soome uint8_t __pad1; 96*199767f8SToomas Soome uint32_t tm_nsec; /* 0 - 999,999,999 */ 97*199767f8SToomas Soome int16_t tm_tz; /* -1440 to 1440 or 2047 */ 98*199767f8SToomas Soome uint8_t tm_dst; 99*199767f8SToomas Soome uint8_t __pad2; 100*199767f8SToomas Soome }; 101*199767f8SToomas Soome 102*199767f8SToomas Soome struct efi_tmcap { 103*199767f8SToomas Soome uint32_t tc_res; /* 1e-6 parts per million */ 104*199767f8SToomas Soome uint32_t tc_prec; /* hertz */ 105*199767f8SToomas Soome uint8_t tc_stz; /* Set clears sub-second time */ 106*199767f8SToomas Soome }; 107*199767f8SToomas Soome 108*199767f8SToomas Soome struct efi_tblhdr { 109*199767f8SToomas Soome uint64_t th_sig; 110*199767f8SToomas Soome uint32_t th_rev; 111*199767f8SToomas Soome uint32_t th_hdrsz; 112*199767f8SToomas Soome uint32_t th_crc32; 113*199767f8SToomas Soome uint32_t __res; 114*199767f8SToomas Soome }; 115*199767f8SToomas Soome 116*199767f8SToomas Soome struct efi_rt { 117*199767f8SToomas Soome struct efi_tblhdr rt_hdr; 118*199767f8SToomas Soome efi_status (*rt_gettime)(struct efi_tm *, struct efi_tmcap *); 119*199767f8SToomas Soome efi_status (*rt_settime)(struct efi_tm *); 120*199767f8SToomas Soome efi_status (*rt_getwaketime)(uint8_t *, uint8_t *, 121*199767f8SToomas Soome struct efi_tm *); 122*199767f8SToomas Soome efi_status (*rt_setwaketime)(uint8_t, struct efi_tm *); 123*199767f8SToomas Soome efi_status (*rt_setvirtual)(u_long, u_long, uint32_t, 124*199767f8SToomas Soome struct efi_md *); 125*199767f8SToomas Soome efi_status (*rt_cvtptr)(u_long, void **); 126*199767f8SToomas Soome efi_status (*rt_getvar)(efi_char *, struct uuid *, uint32_t *, 127*199767f8SToomas Soome u_long *, void *); 128*199767f8SToomas Soome efi_status (*rt_scanvar)(u_long *, efi_char *, struct uuid *); 129*199767f8SToomas Soome efi_status (*rt_setvar)(efi_char *, struct uuid *, uint32_t, 130*199767f8SToomas Soome u_long, void *); 131*199767f8SToomas Soome efi_status (*rt_gethicnt)(uint32_t *); 132*199767f8SToomas Soome efi_status (*rt_reset)(enum efi_reset, efi_status, u_long, 133*199767f8SToomas Soome efi_char *); 134*199767f8SToomas Soome }; 135*199767f8SToomas Soome 136*199767f8SToomas Soome struct efi_systbl { 137*199767f8SToomas Soome struct efi_tblhdr st_hdr; 138*199767f8SToomas Soome #define EFI_SYSTBL_SIG 0x5453595320494249UL 139*199767f8SToomas Soome efi_char *st_fwvendor; 140*199767f8SToomas Soome uint32_t st_fwrev; 141*199767f8SToomas Soome uint32_t __pad; 142*199767f8SToomas Soome void *st_cin; 143*199767f8SToomas Soome void *st_cinif; 144*199767f8SToomas Soome void *st_cout; 145*199767f8SToomas Soome void *st_coutif; 146*199767f8SToomas Soome void *st_cerr; 147*199767f8SToomas Soome void *st_cerrif; 148*199767f8SToomas Soome uint64_t st_rt; 149*199767f8SToomas Soome void *st_bs; 150*199767f8SToomas Soome u_long st_entries; 151*199767f8SToomas Soome uint64_t st_cfgtbl; 152*199767f8SToomas Soome }; 153*199767f8SToomas Soome 154*199767f8SToomas Soome extern vm_paddr_t efi_systbl; 155*199767f8SToomas Soome #endif /* _SYS_EFI_H_ */ 156