/*-1* Copyright (c) 2015 Eric McCorkle2* All rights reserved.3*4* Redistribution and use in source and binary forms, with or without5* modification, are permitted provided that the following conditions6* are met:7* 1. Redistributions of source code must retain the above copyright8* notice, this list of conditions and the following disclaimer.9* 2. Redistributions in binary form must reproduce the above copyright10* notice, this list of conditions and the following disclaimer in the11* documentation and/or other materials provided with the distribution.12*13* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND14* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE15* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE16* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE17* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL18* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS19* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)20* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT21* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY22* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF23* SUCH DAMAGE.24*/2526#ifndef _BOOT_MODULE_H_27#define _BOOT_MODULE_H_2829#include <stdbool.h>3031#include <efi.h>32#include <efilib.h>33#include <eficonsctl.h>3435#ifdef EFI_DEBUG36#define DPRINTF(fmt, args...) printf(fmt, ##args)37#define DSTALL(d) BS->Stall(d)38#else39#define DPRINTF(fmt, ...) {}40#define DSTALL(d) {}41#endif4243/* EFI device info */44typedef struct dev_info45{46EFI_BLOCK_IO *dev;47EFI_DEVICE_PATH *devpath;48EFI_HANDLE devhandle;49void *devdata;50uint64_t partoff;51int preferred;52struct dev_info *next;53} dev_info_t;5455/*56* A boot loader module.57*58* This is a standard interface for filesystem modules in the EFI system.59*/60typedef struct boot_module_t61{62const char *name;6364/* init is the optional initialiser for the module. */65void (*init)(void);6667/*68* probe checks to see if the module can handle dev.69*70* Return codes:71* EFI_SUCCESS = The module can handle the device.72* EFI_NOT_FOUND = The module can not handle the device.73* Other = The module encountered an error.74*/75EFI_STATUS (*probe)(dev_info_t* dev);7677/*78* load should select the best out of a set of devices that probe79* indicated were loadable and load the specified file.80*81* Return codes:82* EFI_SUCCESS = The module can handle the device.83* EFI_NOT_FOUND = The module can not handle the device.84* Other = The module encountered an error.85*/86EFI_STATUS (*load)(const char *filepath, dev_info_t *devinfo,87void **buf, size_t *bufsize);8889/* status outputs information about the probed devices. */90void (*status)(void);9192/* valid devices as found by probe. */93dev_info_t *(*devices)(void);9495/* return any environment variables to pass to next stage */96const char *(*extra_env)(void);97} boot_module_t;9899extern const boot_module_t *boot_modules[];100extern const UINTN num_boot_modules;101102/* Standard boot modules. */103#ifdef EFI_UFS_BOOT104extern const boot_module_t ufs_module;105#endif106#ifdef EFI_ZFS_BOOT107extern const boot_module_t zfs_module;108#endif109110/* Functions available to modules. */111extern void add_device(dev_info_t **devinfop, dev_info_t *devinfo);112#endif113114115