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