mirror of
https://github.com/linuxboot/linuxboot
synced 2024-11-21 23:59:59 +00:00
Merge pull request #32 from osresearch/bds-pr
Replace Linux kernel BDS patch with `linuxboot.efi` BDS implementation
This commit is contained in:
commit
b60259c385
15
.circleci/config.yml
Normal file
15
.circleci/config.yml
Normal file
@ -0,0 +1,15 @@
|
||||
version: 2
|
||||
jobs:
|
||||
build:
|
||||
docker:
|
||||
- image: circleci/buld-image
|
||||
steps:
|
||||
- checkout
|
||||
- run: 'git clone https://github.com/osresearch/heads'
|
||||
- run: 'make BOARD=qemu-coreboot'
|
||||
- run: 'make BOARD=qemu-linuxboot'
|
||||
workflows:
|
||||
version: 2
|
||||
build_and_test:
|
||||
jobs:
|
||||
- build
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -88,3 +88,5 @@ boards/*/volume-*
|
||||
*.raw
|
||||
*.pad
|
||||
*.hop
|
||||
*.efi
|
||||
.*
|
||||
|
4
Makefile
4
Makefile
@ -129,6 +129,10 @@ $(patsubst %.fv,,$(FVS)): $(BUILD)/$(BOARD).txt
|
||||
$(dxe-files): $(BUILD)/$(BOARD).txt
|
||||
@true
|
||||
|
||||
# Any of the DXE modules are produced by running make in the dxe subdir
|
||||
dxe/%.ffs:
|
||||
$(MAKE) -C dxe $(notdir $@)
|
||||
|
||||
$(BUILD)/linuxboot.rom: $(FVS)
|
||||
|
||||
|
||||
|
@ -22,7 +22,7 @@ IntelCrystalRidgeGuid := 626967C7-071B-4D9A-9D0C-F112CF0836E9
|
||||
LpcSomethingGuid := 64021DFE-A62C-42A7-BF46-15078CDF9F89
|
||||
|
||||
Linux-guid := DECAFBAD-6548-6461-732d-2f2d4e455246
|
||||
Linux-depex := $(RuntimeArchProtocolGuid)
|
||||
Linux-type := APPLICATION
|
||||
|
||||
Initrd-type := FREEFORM
|
||||
Initrd-guid := 74696e69-6472-632e-7069-6f2f62696f73
|
||||
|
@ -39,4 +39,5 @@ $(BUILD)/dxe.vol: \
|
||||
$(BUILD)/PiSmmCore.ffs \
|
||||
$(BUILD)/Linux.ffs \
|
||||
$(BUILD)/Initrd.ffs \
|
||||
./dxe/linuxboot.ffs \
|
||||
$(dxe-files) \
|
||||
|
@ -41,6 +41,7 @@ $(BUILD)/dxe.vol: \
|
||||
$(BUILD)/DxeCore.ffs \
|
||||
$(BUILD)/PiSmmCore.ffs \
|
||||
$(dxe-files) \
|
||||
./dxe/linuxboot.ffs \
|
||||
$(BUILD)/Linux.ffs \
|
||||
$(BUILD)/Initrd.ffs \
|
||||
|
||||
|
@ -51,6 +51,7 @@ $(BUILD)/merged.vol: \
|
||||
$(BUILD)/dxe.vol: \
|
||||
$(BUILD)/DxeCore.ffs \
|
||||
$(dxe-files) \
|
||||
./dxe/linuxboot.ffs \
|
||||
$(BUILD)/Linux.ffs \
|
||||
$(BUILD)/Initrd.ffs \
|
||||
|
||||
@ -63,9 +64,10 @@ boards/$(BOARD)/$(BOARD).rom: edk2/.git
|
||||
|
||||
# We can also launch a qemu with the LinuxBoot kernel
|
||||
run: $(BUILD)/linuxboot.rom
|
||||
qemu-system-x86_64 \
|
||||
-qemu-system-x86_64 \
|
||||
-machine q35,smm=on \
|
||||
-global ICH9-LPC.disable_s3=1 \
|
||||
-global driver=cfi.pflash01,property=secure,value=on \
|
||||
--serial $(or $(SERIAL),/dev/tty) \
|
||||
--serial $(or $(SERIAL),stdio) \
|
||||
-drive if=pflash,format=raw,unit=0,file=$<
|
||||
stty sane
|
||||
|
@ -55,6 +55,7 @@ $(BUILD)/dxe.vol: \
|
||||
$(BUILD)/DxeCore.ffs \
|
||||
$(BUILD)/PiSmmCore.ffs \
|
||||
$(BUILD)/RuntimeDxe.ffs \
|
||||
./dxe/linuxboot.ffs \
|
||||
$(dxe-files) \
|
||||
$(BUILD)/PciBusDxe.ffs \
|
||||
$(BUILD)/PciHostBridgeDxe.ffs \
|
||||
|
@ -69,8 +69,7 @@ $(BUILD)/2mb.fv: dxe/hello.ffs
|
||||
$(BUILD)/dxe.vol: \
|
||||
$(BUILD)/DxeCore.ffs \
|
||||
$(BUILD)/PiSmmCore.ffs \
|
||||
dxe/fvloader.ffs \
|
||||
dxe/hello.ffs \
|
||||
./dxe/linuxboot.ffs \
|
||||
$(dxe-files) \
|
||||
|
||||
dxe/fvloader.ffs dxe/hello.ffs: dxe.intermediate
|
||||
|
@ -37,6 +37,7 @@ $(BUILD)/rom/0x01c00000.fv \
|
||||
$(BUILD)/dxe.vol: \
|
||||
$(BUILD)/DxeCore.ffs \
|
||||
$(BUILD)/PiSmmCore.ffs \
|
||||
./dxe/linuxboot.ffs \
|
||||
$(BUILD)/Linux.ffs \
|
||||
$(BUILD)/Initrd.ffs \
|
||||
$(dxe-files) \
|
||||
|
@ -38,6 +38,7 @@ $(BUILD)/rom/0x00f00000.fv \
|
||||
# and add in the Linux kernel / initrd
|
||||
$(BUILD)/dxe.vol: \
|
||||
$(dxe-files) \
|
||||
./dxe/linuxboot.ffs \
|
||||
$(BUILD)/Linux.ffs \
|
||||
$(BUILD)/Initrd.ffs \
|
||||
|
||||
|
80
dxe/Makefile
Normal file
80
dxe/Makefile
Normal file
@ -0,0 +1,80 @@
|
||||
KERNEL = $(shell uname -s)
|
||||
CC = $(CROSS)gcc
|
||||
BITS = 64
|
||||
EFI_ARCH = x86_64
|
||||
#BITS = 32
|
||||
#EFI_ARCH = x86
|
||||
|
||||
|
||||
#TARGETS += fvloader.ffs
|
||||
TARGETS += linuxboot.ffs
|
||||
#TARGETS += hello.ffs
|
||||
|
||||
all: $(TARGETS)
|
||||
|
||||
clean: FORCE
|
||||
$(RM) *.efi *.exe *.rom *.o .*.d $(TARGETS)
|
||||
|
||||
linuxboot.exe: linuxboot.o efifv.o
|
||||
hello.exe: hello.o
|
||||
|
||||
FORCE:
|
||||
|
||||
%.exe:
|
||||
$(CROSS)ld \
|
||||
$(LDFLAGS) \
|
||||
-T elf_x86_64_efi.lds \
|
||||
-o $@ \
|
||||
$^
|
||||
|
||||
%.efi: %.exe
|
||||
$(CROSS)objcopy \
|
||||
-j .text -j .sdata -j .data -j .dynamic \
|
||||
-j .dynsym -j .rel -j .rela -j .reloc \
|
||||
--subsystem efi-bsd \
|
||||
--target efi-app-$(EFI_ARCH) \
|
||||
$^ \
|
||||
$@
|
||||
# fixup the PE32 characteristic field to make DxeCore happy
|
||||
/usr/bin/printf '\x2E\x00' | dd of=$@ conv=notrunc bs=1 seek=150 status=none
|
||||
|
||||
%.ffs: %.efi
|
||||
../bin/create-ffs \
|
||||
-o $@ \
|
||||
--type DRIVER \
|
||||
--version 1.0 \
|
||||
--name "$(basename $@)" \
|
||||
--depex TRUE \
|
||||
$<
|
||||
|
||||
CFLAGS += \
|
||||
-std=c99 \
|
||||
-D__efi__ \
|
||||
-DGNU_EFI_USE_MS_ABI \
|
||||
-fshort-wchar \
|
||||
-mno-red-zone \
|
||||
-fno-stack-protector \
|
||||
-m$(BITS) \
|
||||
-fpic \
|
||||
-O3 \
|
||||
-W \
|
||||
-Wall \
|
||||
-I . \
|
||||
-I efi/x86_64 \
|
||||
-MMD \
|
||||
-MF .$(notdir $@).d \
|
||||
|
||||
LDFLAGS += \
|
||||
-nostdlib \
|
||||
-znocombreloc \
|
||||
-shared \
|
||||
-Bsymbolic \
|
||||
|
||||
NO_LFLAGS += \
|
||||
-T $(EFI_LDS) \
|
||||
-L $(EFILIB) \
|
||||
-L $(LIB) \
|
||||
$(EFI_CRT_OBJS) \
|
||||
|
||||
|
||||
-include .*.d
|
47
dxe/README.md
Normal file
47
dxe/README.md
Normal file
@ -0,0 +1,47 @@
|
||||
Overview
|
||||
===
|
||||
|
||||
These are small DXE modules that help bootstrap the LinuxBoot kernel.
|
||||
They depend on the gnu-efi-devel package for the headers.
|
||||
|
||||
Developing DXE
|
||||
===
|
||||
|
||||
Calling conventions
|
||||
---
|
||||
The EFI environment uses the Microsoft ABI, so gcc must be told which
|
||||
functions are called from or call into the EFI system. This is done
|
||||
with the `EFIAPI` macro, which annotates the functions with the gcc
|
||||
x86 extension [`__attribute__((ms_abi))`](https://gcc.gnu.org/onlinedocs/gcc/x86-Function-Attributes.html#x86-Function-Attributes)
|
||||
|
||||
The entry point into the DXE module must be named `efi_main()` and
|
||||
should have the prototype:
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
efi_main(
|
||||
EFI_HANDLE image,
|
||||
EFI_SYSTEM_TABLE * st
|
||||
);
|
||||
|
||||
Any callbacks that are registered, such as for the `ExitBootServices` event,
|
||||
must also be flagged with `EFIAPI`.
|
||||
|
||||
|
||||
Memory allocation
|
||||
---
|
||||
There are lots of pools of memory allocation during EFI, some of which are
|
||||
cleared when the OS starts, some of which stay resident, etc. In general
|
||||
you can request memory with:
|
||||
|
||||
void * buf;
|
||||
|
||||
if (gST->BootServices->AllocatePool(
|
||||
EfiBootServicesData,
|
||||
len,
|
||||
&buf
|
||||
) != 0) {
|
||||
// handle an error...
|
||||
}
|
||||
|
||||
|
62
dxe/efi/efi.h
Normal file
62
dxe/efi/efi.h
Normal file
@ -0,0 +1,62 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
efi.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Public EFI header files
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
|
||||
// Add a predefined macro to detect usage of the library
|
||||
#ifndef _GNU_EFI
|
||||
#define _GNU_EFI
|
||||
#endif
|
||||
|
||||
//
|
||||
// Build flags on input
|
||||
// EFI32
|
||||
// EFI_DEBUG - Enable debugging code
|
||||
// EFI_NT_EMULATOR - Building for running under NT
|
||||
//
|
||||
|
||||
|
||||
#ifndef _EFI_INCLUDE_
|
||||
#define _EFI_INCLUDE_
|
||||
|
||||
#define EFI_FIRMWARE_VENDOR L"INTEL"
|
||||
#define EFI_FIRMWARE_MAJOR_REVISION 12
|
||||
#define EFI_FIRMWARE_MINOR_REVISION 33
|
||||
#define EFI_FIRMWARE_REVISION ((EFI_FIRMWARE_MAJOR_REVISION <<16) | (EFI_FIRMWARE_MINOR_REVISION))
|
||||
|
||||
#include "efibind.h"
|
||||
#include "eficompiler.h"
|
||||
#include "efidef.h"
|
||||
#include "efidevp.h"
|
||||
#include "efipciio.h"
|
||||
#include "efiprot.h"
|
||||
//#include "eficon.h"
|
||||
//#include "efiser.h"
|
||||
//#include "efi_nii.h"
|
||||
//#include "efipxebc.h"
|
||||
//#include "efinet.h"
|
||||
#include "efiapi.h"
|
||||
//#include "efifs.h"
|
||||
#include "efierr.h"
|
||||
//#include "efiui.h"
|
||||
//#include "efiip.h"
|
||||
//#include "efiudp.h"
|
||||
//#include "efitcp.h"
|
||||
//#include "efipoint.h"
|
||||
//#include "efisetjmp.h"
|
||||
|
||||
#endif
|
970
dxe/efi/efiapi.h
Normal file
970
dxe/efi/efiapi.h
Normal file
@ -0,0 +1,970 @@
|
||||
#ifndef _EFI_API_H
|
||||
#define _EFI_API_H
|
||||
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
efiapi.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Global EFI runtime & boot service interfaces
|
||||
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
//
|
||||
// EFI Specification Revision
|
||||
//
|
||||
|
||||
#define EFI_SPECIFICATION_MAJOR_REVISION 1
|
||||
#define EFI_SPECIFICATION_MINOR_REVISION 02
|
||||
|
||||
//
|
||||
// Declare forward referenced data structures
|
||||
//
|
||||
|
||||
INTERFACE_DECL(_EFI_SYSTEM_TABLE);
|
||||
|
||||
//
|
||||
// EFI Memory
|
||||
//
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_ALLOCATE_PAGES) (
|
||||
IN EFI_ALLOCATE_TYPE Type,
|
||||
IN EFI_MEMORY_TYPE MemoryType,
|
||||
IN UINTN NoPages,
|
||||
OUT EFI_PHYSICAL_ADDRESS *Memory
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_FREE_PAGES) (
|
||||
IN EFI_PHYSICAL_ADDRESS Memory,
|
||||
IN UINTN NoPages
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_GET_MEMORY_MAP) (
|
||||
IN OUT UINTN *MemoryMapSize,
|
||||
IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap,
|
||||
OUT UINTN *MapKey,
|
||||
OUT UINTN *DescriptorSize,
|
||||
OUT UINT32 *DescriptorVersion
|
||||
);
|
||||
|
||||
#define NextMemoryDescriptor(Ptr,Size) ((EFI_MEMORY_DESCRIPTOR *) (((UINT8 *) Ptr) + Size))
|
||||
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_ALLOCATE_POOL) (
|
||||
IN EFI_MEMORY_TYPE PoolType,
|
||||
IN UINTN Size,
|
||||
OUT VOID **Buffer
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_FREE_POOL) (
|
||||
IN VOID *Buffer
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SET_VIRTUAL_ADDRESS_MAP) (
|
||||
IN UINTN MemoryMapSize,
|
||||
IN UINTN DescriptorSize,
|
||||
IN UINT32 DescriptorVersion,
|
||||
IN EFI_MEMORY_DESCRIPTOR *VirtualMap
|
||||
);
|
||||
|
||||
|
||||
#define EFI_OPTIONAL_PTR 0x00000001
|
||||
#define EFI_INTERNAL_FNC 0x00000002 // Pointer to internal runtime fnc
|
||||
#define EFI_INTERNAL_PTR 0x00000004 // Pointer to internal runtime data
|
||||
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_CONVERT_POINTER) (
|
||||
IN UINTN DebugDisposition,
|
||||
IN OUT VOID **Address
|
||||
);
|
||||
|
||||
|
||||
//
|
||||
// EFI Events
|
||||
//
|
||||
|
||||
#define EVT_TIMER 0x80000000
|
||||
#define EVT_RUNTIME 0x40000000
|
||||
#define EVT_RUNTIME_CONTEXT 0x20000000
|
||||
|
||||
#define EVT_NOTIFY_WAIT 0x00000100
|
||||
#define EVT_NOTIFY_SIGNAL 0x00000200
|
||||
|
||||
#define EVT_SIGNAL_EXIT_BOOT_SERVICES 0x00000201
|
||||
#define EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE 0x60000202
|
||||
|
||||
#define EVT_EFI_SIGNAL_MASK 0x000000FF
|
||||
#define EVT_EFI_SIGNAL_MAX 4
|
||||
|
||||
#define EFI_EVENT_TIMER EVT_TIMER
|
||||
#define EFI_EVENT_RUNTIME EVT_RUNTIME
|
||||
#define EFI_EVENT_RUNTIME_CONTEXT EVT_RUNTIME_CONTEXT
|
||||
#define EFI_EVENT_NOTIFY_WAIT EVT_NOTIFY_WAIT
|
||||
#define EFI_EVENT_NOTIFY_SIGNAL EVT_NOTIFY_SIGNAL
|
||||
#define EFI_EVENT_SIGNAL_EXIT_BOOT_SERVICES EVT_SIGNAL_EXIT_BOOT_SERVICES
|
||||
#define EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE
|
||||
#define EFI_EVENT_EFI_SIGNAL_MASK EVT_EFI_SIGNAL_MASK
|
||||
#define EFI_EVENT_EFI_SIGNAL_MAX EVT_EFI_SIGNAL_MAX
|
||||
|
||||
|
||||
typedef
|
||||
VOID
|
||||
(EFIAPI *EFI_EVENT_NOTIFY) (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_CREATE_EVENT) (
|
||||
IN UINT32 Type,
|
||||
IN EFI_TPL NotifyTpl,
|
||||
IN EFI_EVENT_NOTIFY NotifyFunction,
|
||||
IN VOID *NotifyContext,
|
||||
OUT EFI_EVENT *Event
|
||||
);
|
||||
|
||||
typedef enum {
|
||||
TimerCancel,
|
||||
TimerPeriodic,
|
||||
TimerRelative,
|
||||
TimerTypeMax
|
||||
} EFI_TIMER_DELAY;
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SET_TIMER) (
|
||||
IN EFI_EVENT Event,
|
||||
IN EFI_TIMER_DELAY Type,
|
||||
IN UINT64 TriggerTime
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SIGNAL_EVENT) (
|
||||
IN EFI_EVENT Event
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_WAIT_FOR_EVENT) (
|
||||
IN UINTN NumberOfEvents,
|
||||
IN EFI_EVENT *Event,
|
||||
OUT UINTN *Index
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_CLOSE_EVENT) (
|
||||
IN EFI_EVENT Event
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_CHECK_EVENT) (
|
||||
IN EFI_EVENT Event
|
||||
);
|
||||
|
||||
//
|
||||
// Task priority level
|
||||
//
|
||||
|
||||
#define TPL_APPLICATION 4
|
||||
#define TPL_CALLBACK 8
|
||||
#define TPL_NOTIFY 16
|
||||
#define TPL_HIGH_LEVEL 31
|
||||
#define EFI_TPL_APPLICATION TPL_APPLICATION
|
||||
#define EFI_TPL_CALLBACK TPL_CALLBACK
|
||||
#define EFI_TPL_NOTIFY TPL_NOTIFY
|
||||
#define EFI_TPL_HIGH_LEVEL TPL_HIGH_LEVEL
|
||||
typedef
|
||||
EFI_TPL
|
||||
(EFIAPI *EFI_RAISE_TPL) (
|
||||
IN EFI_TPL NewTpl
|
||||
);
|
||||
|
||||
typedef
|
||||
VOID
|
||||
(EFIAPI *EFI_RESTORE_TPL) (
|
||||
IN EFI_TPL OldTpl
|
||||
);
|
||||
|
||||
|
||||
//
|
||||
// EFI platform varibles
|
||||
//
|
||||
|
||||
#define EFI_GLOBAL_VARIABLE \
|
||||
{ 0x8BE4DF61, 0x93CA, 0x11d2, {0xAA, 0x0D, 0x00, 0xE0, 0x98, 0x03, 0x2B, 0x8C} }
|
||||
|
||||
// Variable attributes
|
||||
#define EFI_VARIABLE_NON_VOLATILE 0x00000001
|
||||
#define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x00000002
|
||||
#define EFI_VARIABLE_RUNTIME_ACCESS 0x00000004
|
||||
#define EFI_VARIABLE_HARDWARE_ERROR_RECORD 0x00000008
|
||||
#define EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS 0x00000010
|
||||
#define EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS 0x00000020
|
||||
#define EFI_VARIABLE_APPEND_WRITE 0x00000040
|
||||
|
||||
// Variable size limitation
|
||||
#define EFI_MAXIMUM_VARIABLE_SIZE 1024
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_GET_VARIABLE) (
|
||||
IN CHAR16 *VariableName,
|
||||
IN EFI_GUID *VendorGuid,
|
||||
OUT UINT32 *Attributes OPTIONAL,
|
||||
IN OUT UINTN *DataSize,
|
||||
OUT VOID *Data
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_GET_NEXT_VARIABLE_NAME) (
|
||||
IN OUT UINTN *VariableNameSize,
|
||||
IN OUT CHAR16 *VariableName,
|
||||
IN OUT EFI_GUID *VendorGuid
|
||||
);
|
||||
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SET_VARIABLE) (
|
||||
IN CHAR16 *VariableName,
|
||||
IN EFI_GUID *VendorGuid,
|
||||
IN UINT32 Attributes,
|
||||
IN UINTN DataSize,
|
||||
IN VOID *Data
|
||||
);
|
||||
|
||||
|
||||
//
|
||||
// EFI Time
|
||||
//
|
||||
|
||||
typedef struct {
|
||||
UINT32 Resolution; // 1e-6 parts per million
|
||||
UINT32 Accuracy; // hertz
|
||||
BOOLEAN SetsToZero; // Set clears sub-second time
|
||||
} EFI_TIME_CAPABILITIES;
|
||||
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_GET_TIME) (
|
||||
OUT EFI_TIME *Time,
|
||||
OUT EFI_TIME_CAPABILITIES *Capabilities OPTIONAL
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SET_TIME) (
|
||||
IN EFI_TIME *Time
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_GET_WAKEUP_TIME) (
|
||||
OUT BOOLEAN *Enabled,
|
||||
OUT BOOLEAN *Pending,
|
||||
OUT EFI_TIME *Time
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SET_WAKEUP_TIME) (
|
||||
IN BOOLEAN Enable,
|
||||
IN EFI_TIME *Time OPTIONAL
|
||||
);
|
||||
|
||||
|
||||
//
|
||||
// Image functions
|
||||
//
|
||||
|
||||
|
||||
// PE32+ Subsystem type for EFI images
|
||||
|
||||
#if !defined(IMAGE_SUBSYSTEM_EFI_APPLICATION)
|
||||
#define IMAGE_SUBSYSTEM_EFI_APPLICATION 10
|
||||
#define IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER 11
|
||||
#define IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER 12
|
||||
#endif
|
||||
|
||||
// PE32+ Machine type for EFI images
|
||||
|
||||
#if !defined(EFI_IMAGE_MACHINE_IA32)
|
||||
#define EFI_IMAGE_MACHINE_IA32 0x014c
|
||||
#endif
|
||||
|
||||
#if !defined(EFI_IMAGE_MACHINE_IA64)
|
||||
#define EFI_IMAGE_MACHINE_IA64 0x0200
|
||||
#endif
|
||||
|
||||
#if !defined(EFI_IMAGE_MACHINE_EBC)
|
||||
#define EFI_IMAGE_MACHINE_EBC 0x0EBC
|
||||
#endif
|
||||
|
||||
#if !defined(EFI_IMAGE_MACHINE_X64)
|
||||
#define EFI_IMAGE_MACHINE_X64 0x8664
|
||||
#endif
|
||||
|
||||
#if !defined(EFI_IMAGE_MACHINE_ARMTHUMB_MIXED)
|
||||
#define EFI_IMAGE_MACHINE_ARMTHUMB_MIXED 0x01C2
|
||||
#endif
|
||||
|
||||
#if !defined(EFI_IMAGE_MACHINE_AARCH64)
|
||||
#define EFI_IMAGE_MACHINE_AARCH64 0xAA64
|
||||
#endif
|
||||
|
||||
// Image Entry prototype
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_IMAGE_ENTRY_POINT) (
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN struct _EFI_SYSTEM_TABLE *SystemTable
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_IMAGE_LOAD) (
|
||||
IN BOOLEAN BootPolicy,
|
||||
IN EFI_HANDLE ParentImageHandle,
|
||||
IN EFI_DEVICE_PATH *FilePath,
|
||||
IN VOID *SourceBuffer OPTIONAL,
|
||||
IN UINTN SourceSize,
|
||||
OUT EFI_HANDLE *ImageHandle
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_IMAGE_START) (
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
OUT UINTN *ExitDataSize,
|
||||
OUT CHAR16 **ExitData OPTIONAL
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_EXIT) (
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_STATUS ExitStatus,
|
||||
IN UINTN ExitDataSize,
|
||||
IN CHAR16 *ExitData OPTIONAL
|
||||
);
|
||||
|
||||
|
||||
// Image handle
|
||||
/*#define LOADED_IMAGE_PROTOCOL \
|
||||
{ 0x5B1B31A1, 0x9562, 0x11d2, {0x8E, 0x3F, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B} }
|
||||
|
||||
#define EFI_IMAGE_INFORMATION_REVISION 0x1000
|
||||
typedef struct {
|
||||
UINT32 Revision;
|
||||
EFI_HANDLE ParentHandle;
|
||||
struct _EFI_SYSTEM_TABLE *SystemTable;
|
||||
|
||||
// Source location of image
|
||||
EFI_HANDLE DeviceHandle;
|
||||
EFI_DEVICE_PATH *FilePath;
|
||||
VOID *Reserved;
|
||||
|
||||
// Images load options
|
||||
UINT32 LoadOptionsSize;
|
||||
VOID *LoadOptions;
|
||||
|
||||
// Location of where image was loaded
|
||||
VOID *ImageBase;
|
||||
UINT64 ImageSize;
|
||||
EFI_MEMORY_TYPE ImageCodeType;
|
||||
EFI_MEMORY_TYPE ImageDataType;
|
||||
|
||||
// If the driver image supports a dynamic unload request
|
||||
EFI_IMAGE_UNLOAD Unload;
|
||||
|
||||
} EFI_LOADED_IMAGE;*/
|
||||
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_EXIT_BOOT_SERVICES) (
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN UINTN MapKey
|
||||
);
|
||||
|
||||
//
|
||||
// Misc
|
||||
//
|
||||
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_STALL) (
|
||||
IN UINTN Microseconds
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SET_WATCHDOG_TIMER) (
|
||||
IN UINTN Timeout,
|
||||
IN UINT64 WatchdogCode,
|
||||
IN UINTN DataSize,
|
||||
IN CHAR16 *WatchdogData OPTIONAL
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_CONNECT_CONTROLLER) (
|
||||
IN EFI_HANDLE ControllerHandle,
|
||||
IN EFI_HANDLE *DriverImageHandle OPTIONAL,
|
||||
IN EFI_DEVICE_PATH *RemainingDevicePath OPTIONAL,
|
||||
IN BOOLEAN Recursive
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_DISCONNECT_CONTROLLER) (
|
||||
IN EFI_HANDLE ControllerHandle,
|
||||
IN EFI_HANDLE DriverImageHandle OPTIONAL,
|
||||
IN EFI_HANDLE ChildHandle OPTIONAL
|
||||
);
|
||||
|
||||
#define EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL 0x00000001
|
||||
#define EFI_OPEN_PROTOCOL_GET_PROTOCOL 0x00000002
|
||||
#define EFI_OPEN_PROTOCOL_TEST_PROTOCOL 0x00000004
|
||||
#define EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER 0x00000008
|
||||
#define EFI_OPEN_PROTOCOL_BY_DRIVER 0x00000010
|
||||
#define EFI_OPEN_PROTOCOL_EXCLUSIVE 0x00000020
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_OPEN_PROTOCOL) (
|
||||
IN EFI_HANDLE Handle,
|
||||
IN EFI_GUID *Protocol,
|
||||
OUT VOID **Interface OPTIONAL,
|
||||
IN EFI_HANDLE AgentHandle,
|
||||
IN EFI_HANDLE ControllerHandle,
|
||||
IN UINT32 Attributes
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_CLOSE_PROTOCOL) (
|
||||
IN EFI_HANDLE Handle,
|
||||
IN EFI_GUID *Protocol,
|
||||
IN EFI_HANDLE AgentHandle,
|
||||
IN EFI_HANDLE ControllerHandle
|
||||
);
|
||||
|
||||
typedef struct {
|
||||
EFI_HANDLE AgentHandle;
|
||||
EFI_HANDLE ControllerHandle;
|
||||
UINT32 Attributes;
|
||||
UINT32 OpenCount;
|
||||
} EFI_OPEN_PROTOCOL_INFORMATION_ENTRY;
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_OPEN_PROTOCOL_INFORMATION) (
|
||||
IN EFI_HANDLE Handle,
|
||||
IN EFI_GUID *Protocol,
|
||||
OUT EFI_OPEN_PROTOCOL_INFORMATION_ENTRY **EntryBuffer,
|
||||
OUT UINTN *EntryCount
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_PROTOCOLS_PER_HANDLE) (
|
||||
IN EFI_HANDLE Handle,
|
||||
OUT EFI_GUID ***ProtocolBuffer,
|
||||
OUT UINTN *ProtocolBufferCount
|
||||
);
|
||||
|
||||
typedef enum {
|
||||
AllHandles,
|
||||
ByRegisterNotify,
|
||||
ByProtocol
|
||||
} EFI_LOCATE_SEARCH_TYPE;
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_LOCATE_HANDLE_BUFFER) (
|
||||
IN EFI_LOCATE_SEARCH_TYPE SearchType,
|
||||
IN EFI_GUID *Protocol OPTIONAL,
|
||||
IN VOID *SearchKey OPTIONAL,
|
||||
IN OUT UINTN *NoHandles,
|
||||
OUT EFI_HANDLE **Buffer
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_LOCATE_PROTOCOL) (
|
||||
IN EFI_GUID *Protocol,
|
||||
IN VOID *Registration OPTIONAL,
|
||||
OUT VOID **Interface
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES) (
|
||||
IN OUT EFI_HANDLE *Handle,
|
||||
...
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES) (
|
||||
IN OUT EFI_HANDLE Handle,
|
||||
...
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_CALCULATE_CRC32) (
|
||||
IN VOID *Data,
|
||||
IN UINTN DataSize,
|
||||
OUT UINT32 *Crc32
|
||||
);
|
||||
|
||||
typedef
|
||||
VOID
|
||||
(EFIAPI *EFI_COPY_MEM) (
|
||||
IN VOID *Destination,
|
||||
IN VOID *Source,
|
||||
IN UINTN Length
|
||||
);
|
||||
|
||||
typedef
|
||||
VOID
|
||||
(EFIAPI *EFI_SET_MEM) (
|
||||
IN VOID *Buffer,
|
||||
IN UINTN Size,
|
||||
IN UINT8 Value
|
||||
);
|
||||
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_CREATE_EVENT_EX) (
|
||||
IN UINT32 Type,
|
||||
IN EFI_TPL NotifyTpl,
|
||||
IN EFI_EVENT_NOTIFY NotifyFunction OPTIONAL,
|
||||
IN const VOID *NotifyContext OPTIONAL,
|
||||
IN const EFI_GUID *EventGroup OPTIONAL,
|
||||
OUT EFI_EVENT *Event
|
||||
);
|
||||
|
||||
typedef enum {
|
||||
EfiResetCold,
|
||||
EfiResetWarm,
|
||||
EfiResetShutdown
|
||||
} EFI_RESET_TYPE;
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_RESET_SYSTEM) (
|
||||
IN EFI_RESET_TYPE ResetType,
|
||||
IN EFI_STATUS ResetStatus,
|
||||
IN UINTN DataSize,
|
||||
IN CHAR16 *ResetData OPTIONAL
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_GET_NEXT_MONOTONIC_COUNT) (
|
||||
OUT UINT64 *Count
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_GET_NEXT_HIGH_MONO_COUNT) (
|
||||
OUT UINT32 *HighCount
|
||||
);
|
||||
|
||||
typedef struct {
|
||||
UINT64 Length;
|
||||
union {
|
||||
EFI_PHYSICAL_ADDRESS DataBlock;
|
||||
EFI_PHYSICAL_ADDRESS ContinuationPointer;
|
||||
} Union;
|
||||
} EFI_CAPSULE_BLOCK_DESCRIPTOR;
|
||||
|
||||
typedef struct {
|
||||
EFI_GUID CapsuleGuid;
|
||||
UINT32 HeaderSize;
|
||||
UINT32 Flags;
|
||||
UINT32 CapsuleImageSize;
|
||||
} EFI_CAPSULE_HEADER;
|
||||
|
||||
#define CAPSULE_FLAGS_PERSIST_ACROSS_RESET 0x00010000
|
||||
#define CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE 0x00020000
|
||||
#define CAPSULE_FLAGS_INITIATE_RESET 0x00040000
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_UPDATE_CAPSULE) (
|
||||
IN EFI_CAPSULE_HEADER **CapsuleHeaderArray,
|
||||
IN UINTN CapsuleCount,
|
||||
IN EFI_PHYSICAL_ADDRESS ScatterGatherList OPTIONAL
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_QUERY_CAPSULE_CAPABILITIES) (
|
||||
IN EFI_CAPSULE_HEADER **CapsuleHeaderArray,
|
||||
IN UINTN CapsuleCount,
|
||||
OUT UINT64 *MaximumCapsuleSize,
|
||||
OUT EFI_RESET_TYPE *ResetType
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_QUERY_VARIABLE_INFO) (
|
||||
IN UINT32 Attributes,
|
||||
OUT UINT64 *MaximumVariableStorageSize,
|
||||
OUT UINT64 *RemainingVariableStorageSize,
|
||||
OUT UINT64 *MaximumVariableSize
|
||||
);
|
||||
|
||||
//
|
||||
// Protocol handler functions
|
||||
//
|
||||
|
||||
typedef enum {
|
||||
EFI_NATIVE_INTERFACE,
|
||||
EFI_PCODE_INTERFACE
|
||||
} EFI_INTERFACE_TYPE;
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_INSTALL_PROTOCOL_INTERFACE) (
|
||||
IN OUT EFI_HANDLE *Handle,
|
||||
IN EFI_GUID *Protocol,
|
||||
IN EFI_INTERFACE_TYPE InterfaceType,
|
||||
IN VOID *Interface
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_REINSTALL_PROTOCOL_INTERFACE) (
|
||||
IN EFI_HANDLE Handle,
|
||||
IN EFI_GUID *Protocol,
|
||||
IN VOID *OldInterface,
|
||||
IN VOID *NewInterface
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_UNINSTALL_PROTOCOL_INTERFACE) (
|
||||
IN EFI_HANDLE Handle,
|
||||
IN EFI_GUID *Protocol,
|
||||
IN VOID *Interface
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_HANDLE_PROTOCOL) (
|
||||
IN EFI_HANDLE Handle,
|
||||
IN EFI_GUID *Protocol,
|
||||
OUT VOID **Interface
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_REGISTER_PROTOCOL_NOTIFY) (
|
||||
IN EFI_GUID *Protocol,
|
||||
IN EFI_EVENT Event,
|
||||
OUT VOID **Registration
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_LOCATE_HANDLE) (
|
||||
IN EFI_LOCATE_SEARCH_TYPE SearchType,
|
||||
IN EFI_GUID *Protocol OPTIONAL,
|
||||
IN VOID *SearchKey OPTIONAL,
|
||||
IN OUT UINTN *BufferSize,
|
||||
OUT EFI_HANDLE *Buffer
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_LOCATE_DEVICE_PATH) (
|
||||
IN EFI_GUID *Protocol,
|
||||
IN OUT EFI_DEVICE_PATH **DevicePath,
|
||||
OUT EFI_HANDLE *Device
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_INSTALL_CONFIGURATION_TABLE) (
|
||||
IN EFI_GUID *Guid,
|
||||
IN VOID *Table
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_RESERVED_SERVICE) (
|
||||
);
|
||||
|
||||
//
|
||||
// Standard EFI table header
|
||||
//
|
||||
|
||||
typedef struct _EFI_TABLE_HEADER {
|
||||
UINT64 Signature;
|
||||
UINT32 Revision;
|
||||
UINT32 HeaderSize;
|
||||
UINT32 CRC32;
|
||||
UINT32 Reserved;
|
||||
} EFI_TABLE_HEADER;
|
||||
|
||||
|
||||
//
|
||||
// EFI Runtime Serivces Table
|
||||
//
|
||||
|
||||
#define EFI_RUNTIME_SERVICES_SIGNATURE 0x56524553544e5552
|
||||
#define EFI_RUNTIME_SERVICES_REVISION (EFI_SPECIFICATION_MAJOR_REVISION<<16) | (EFI_SPECIFICATION_MINOR_REVISION)
|
||||
|
||||
typedef struct {
|
||||
EFI_TABLE_HEADER Hdr;
|
||||
|
||||
//
|
||||
// Time services
|
||||
//
|
||||
|
||||
EFI_GET_TIME GetTime;
|
||||
EFI_SET_TIME SetTime;
|
||||
EFI_GET_WAKEUP_TIME GetWakeupTime;
|
||||
EFI_SET_WAKEUP_TIME SetWakeupTime;
|
||||
|
||||
//
|
||||
// Virtual memory services
|
||||
//
|
||||
|
||||
EFI_SET_VIRTUAL_ADDRESS_MAP SetVirtualAddressMap;
|
||||
EFI_CONVERT_POINTER ConvertPointer;
|
||||
|
||||
//
|
||||
// Variable serviers
|
||||
//
|
||||
|
||||
EFI_GET_VARIABLE GetVariable;
|
||||
EFI_GET_NEXT_VARIABLE_NAME GetNextVariableName;
|
||||
EFI_SET_VARIABLE SetVariable;
|
||||
|
||||
//
|
||||
// Misc
|
||||
//
|
||||
|
||||
EFI_GET_NEXT_HIGH_MONO_COUNT GetNextHighMonotonicCount;
|
||||
EFI_RESET_SYSTEM ResetSystem;
|
||||
|
||||
EFI_UPDATE_CAPSULE UpdateCapsule;
|
||||
EFI_QUERY_CAPSULE_CAPABILITIES QueryCapsuleCapabilities;
|
||||
EFI_QUERY_VARIABLE_INFO QueryVariableInfo;
|
||||
} EFI_RUNTIME_SERVICES;
|
||||
|
||||
|
||||
//
|
||||
// EFI Boot Services Table
|
||||
//
|
||||
|
||||
#define EFI_BOOT_SERVICES_SIGNATURE 0x56524553544f4f42
|
||||
#define EFI_BOOT_SERVICES_REVISION (EFI_SPECIFICATION_MAJOR_REVISION<<16) | (EFI_SPECIFICATION_MINOR_REVISION)
|
||||
|
||||
typedef struct _EFI_BOOT_SERVICES {
|
||||
|
||||
EFI_TABLE_HEADER Hdr;
|
||||
|
||||
//
|
||||
// Task priority functions
|
||||
//
|
||||
|
||||
EFI_RAISE_TPL RaiseTPL;
|
||||
EFI_RESTORE_TPL RestoreTPL;
|
||||
|
||||
//
|
||||
// Memory functions
|
||||
//
|
||||
|
||||
EFI_ALLOCATE_PAGES AllocatePages;
|
||||
EFI_FREE_PAGES FreePages;
|
||||
EFI_GET_MEMORY_MAP GetMemoryMap;
|
||||
EFI_ALLOCATE_POOL AllocatePool;
|
||||
EFI_FREE_POOL FreePool;
|
||||
|
||||
//
|
||||
// Event & timer functions
|
||||
//
|
||||
|
||||
EFI_CREATE_EVENT CreateEvent;
|
||||
EFI_SET_TIMER SetTimer;
|
||||
EFI_WAIT_FOR_EVENT WaitForEvent;
|
||||
EFI_SIGNAL_EVENT SignalEvent;
|
||||
EFI_CLOSE_EVENT CloseEvent;
|
||||
EFI_CHECK_EVENT CheckEvent;
|
||||
|
||||
//
|
||||
// Protocol handler functions
|
||||
//
|
||||
|
||||
EFI_INSTALL_PROTOCOL_INTERFACE InstallProtocolInterface;
|
||||
EFI_REINSTALL_PROTOCOL_INTERFACE ReinstallProtocolInterface;
|
||||
EFI_UNINSTALL_PROTOCOL_INTERFACE UninstallProtocolInterface;
|
||||
EFI_HANDLE_PROTOCOL HandleProtocol;
|
||||
EFI_HANDLE_PROTOCOL PCHandleProtocol;
|
||||
EFI_REGISTER_PROTOCOL_NOTIFY RegisterProtocolNotify;
|
||||
EFI_LOCATE_HANDLE LocateHandle;
|
||||
EFI_LOCATE_DEVICE_PATH LocateDevicePath;
|
||||
EFI_INSTALL_CONFIGURATION_TABLE InstallConfigurationTable;
|
||||
|
||||
//
|
||||
// Image functions
|
||||
//
|
||||
|
||||
EFI_IMAGE_LOAD LoadImage;
|
||||
EFI_IMAGE_START StartImage;
|
||||
EFI_EXIT Exit;
|
||||
EFI_IMAGE_UNLOAD UnloadImage;
|
||||
EFI_EXIT_BOOT_SERVICES ExitBootServices;
|
||||
|
||||
//
|
||||
// Misc functions
|
||||
//
|
||||
|
||||
EFI_GET_NEXT_MONOTONIC_COUNT GetNextMonotonicCount;
|
||||
EFI_STALL Stall;
|
||||
EFI_SET_WATCHDOG_TIMER SetWatchdogTimer;
|
||||
|
||||
//
|
||||
// DriverSupport Services
|
||||
//
|
||||
|
||||
EFI_CONNECT_CONTROLLER ConnectController;
|
||||
EFI_DISCONNECT_CONTROLLER DisconnectController;
|
||||
|
||||
//
|
||||
// Open and Close Protocol Services
|
||||
//
|
||||
EFI_OPEN_PROTOCOL OpenProtocol;
|
||||
EFI_CLOSE_PROTOCOL CloseProtocol;
|
||||
EFI_OPEN_PROTOCOL_INFORMATION OpenProtocolInformation;
|
||||
|
||||
//
|
||||
// Library Services
|
||||
//
|
||||
EFI_PROTOCOLS_PER_HANDLE ProtocolsPerHandle;
|
||||
EFI_LOCATE_HANDLE_BUFFER LocateHandleBuffer;
|
||||
EFI_LOCATE_PROTOCOL LocateProtocol;
|
||||
EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES InstallMultipleProtocolInterfaces;
|
||||
EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES UninstallMultipleProtocolInterfaces;
|
||||
|
||||
//
|
||||
// 32-bit CRC Services
|
||||
//
|
||||
EFI_CALCULATE_CRC32 CalculateCrc32;
|
||||
|
||||
//
|
||||
// Misc Services
|
||||
//
|
||||
EFI_COPY_MEM CopyMem;
|
||||
EFI_SET_MEM SetMem;
|
||||
EFI_CREATE_EVENT_EX CreateEventEx;
|
||||
} EFI_BOOT_SERVICES;
|
||||
|
||||
|
||||
//
|
||||
// EFI Configuration Table and GUID definitions
|
||||
//
|
||||
|
||||
#define MPS_TABLE_GUID \
|
||||
{ 0xeb9d2d2f, 0x2d88, 0x11d3, {0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d} }
|
||||
|
||||
#define ACPI_TABLE_GUID \
|
||||
{ 0xeb9d2d30, 0x2d88, 0x11d3, {0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d} }
|
||||
|
||||
#define ACPI_20_TABLE_GUID \
|
||||
{ 0x8868e871, 0xe4f1, 0x11d3, {0xbc, 0x22, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81} }
|
||||
|
||||
#define SMBIOS_TABLE_GUID \
|
||||
{ 0xeb9d2d31, 0x2d88, 0x11d3, {0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d} }
|
||||
|
||||
#define SMBIOS3_TABLE_GUID \
|
||||
{ 0xf2fd1544, 0x9794, 0x4a2c, {0x99, 0x2e, 0xe5, 0xbb, 0xcf, 0x20, 0xe3, 0x94} }
|
||||
|
||||
#define SAL_SYSTEM_TABLE_GUID \
|
||||
{ 0xeb9d2d32, 0x2d88, 0x11d3, {0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d} }
|
||||
|
||||
|
||||
typedef struct _EFI_CONFIGURATION_TABLE {
|
||||
EFI_GUID VendorGuid;
|
||||
VOID *VendorTable;
|
||||
} EFI_CONFIGURATION_TABLE;
|
||||
|
||||
|
||||
//
|
||||
// EFI System Table
|
||||
//
|
||||
|
||||
|
||||
|
||||
|
||||
#define EFI_SYSTEM_TABLE_SIGNATURE 0x5453595320494249
|
||||
#define EFI_SYSTEM_TABLE_REVISION (EFI_SPECIFICATION_MAJOR_REVISION<<16) | (EFI_SPECIFICATION_MINOR_REVISION)
|
||||
|
||||
typedef struct _EFI_SYSTEM_TABLE {
|
||||
EFI_TABLE_HEADER Hdr;
|
||||
|
||||
CHAR16 *FirmwareVendor;
|
||||
UINT32 FirmwareRevision;
|
||||
|
||||
EFI_HANDLE ConsoleInHandle;
|
||||
//SIMPLE_INPUT_INTERFACE *ConIn;
|
||||
void *ConIn;
|
||||
|
||||
EFI_HANDLE ConsoleOutHandle;
|
||||
//SIMPLE_TEXT_OUTPUT_INTERFACE *ConOut;
|
||||
void *ConOut;
|
||||
|
||||
EFI_HANDLE StandardErrorHandle;
|
||||
//SIMPLE_TEXT_OUTPUT_INTERFACE *StdErr;
|
||||
void *StdErr;
|
||||
|
||||
EFI_RUNTIME_SERVICES *RuntimeServices;
|
||||
EFI_BOOT_SERVICES *BootServices;
|
||||
|
||||
UINTN NumberOfTableEntries;
|
||||
EFI_CONFIGURATION_TABLE *ConfigurationTable;
|
||||
|
||||
} EFI_SYSTEM_TABLE;
|
||||
|
||||
#endif
|
||||
|
30
dxe/efi/eficompiler.h
Normal file
30
dxe/efi/eficompiler.h
Normal file
@ -0,0 +1,30 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2016 Pete Batard <pete@akeo.ie>
|
||||
|
||||
Module Name:
|
||||
|
||||
eficompiler.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Compiler specific adjustments
|
||||
|
||||
--*/
|
||||
|
||||
#ifdef _MSC_EXTENSIONS
|
||||
#define EFI_UNUSED
|
||||
#else
|
||||
#define EFI_UNUSED __attribute__((__unused__))
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_EXTENSIONS
|
||||
#define ALIGN(x) __declspec(align(x))
|
||||
#else
|
||||
#define ALIGN(x) __attribute__((__aligned__(x)))
|
||||
#endif
|
||||
|
||||
/* Also add a catch-all on __attribute__() for MS compilers */
|
||||
#ifdef _MSC_EXTENSIONS
|
||||
#define __attribute__(x)
|
||||
#endif
|
220
dxe/efi/efidef.h
Normal file
220
dxe/efi/efidef.h
Normal file
@ -0,0 +1,220 @@
|
||||
#ifndef _EFI_DEF_H
|
||||
#define _EFI_DEF_H
|
||||
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
efidef.h
|
||||
|
||||
Abstract:
|
||||
|
||||
EFI definitions
|
||||
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
typedef UINT16 CHAR16;
|
||||
typedef UINT8 CHAR8;
|
||||
typedef UINT8 BOOLEAN;
|
||||
#ifndef CONST
|
||||
#define CONST const
|
||||
#endif
|
||||
#ifndef TRUE
|
||||
#define TRUE ((BOOLEAN) 1)
|
||||
#define FALSE ((BOOLEAN) 0)
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL ((VOID *) 0)
|
||||
#endif
|
||||
|
||||
typedef UINTN EFI_STATUS;
|
||||
typedef UINT64 EFI_LBA;
|
||||
typedef UINTN EFI_TPL;
|
||||
typedef VOID *EFI_HANDLE;
|
||||
typedef VOID *EFI_EVENT;
|
||||
|
||||
|
||||
//
|
||||
// Prototype argument decoration for EFI parameters to indicate
|
||||
// their direction
|
||||
//
|
||||
// IN - argument is passed into the function
|
||||
// OUT - argument (pointer) is returned from the function
|
||||
// OPTIONAL - argument is optional
|
||||
//
|
||||
|
||||
#ifndef IN
|
||||
#define IN
|
||||
#define OUT
|
||||
#define OPTIONAL
|
||||
#endif
|
||||
|
||||
|
||||
//
|
||||
// A GUID
|
||||
//
|
||||
|
||||
typedef struct {
|
||||
UINT32 Data1;
|
||||
UINT16 Data2;
|
||||
UINT16 Data3;
|
||||
UINT8 Data4[8];
|
||||
} EFI_GUID;
|
||||
|
||||
|
||||
//
|
||||
// Time
|
||||
//
|
||||
|
||||
typedef struct {
|
||||
UINT16 Year; // 1998 - 20XX
|
||||
UINT8 Month; // 1 - 12
|
||||
UINT8 Day; // 1 - 31
|
||||
UINT8 Hour; // 0 - 23
|
||||
UINT8 Minute; // 0 - 59
|
||||
UINT8 Second; // 0 - 59
|
||||
UINT8 Pad1;
|
||||
UINT32 Nanosecond; // 0 - 999,999,999
|
||||
INT16 TimeZone; // -1440 to 1440 or 2047
|
||||
UINT8 Daylight;
|
||||
UINT8 Pad2;
|
||||
} EFI_TIME;
|
||||
|
||||
// Bit definitions for EFI_TIME.Daylight
|
||||
#define EFI_TIME_ADJUST_DAYLIGHT 0x01
|
||||
#define EFI_TIME_IN_DAYLIGHT 0x02
|
||||
|
||||
// Value definition for EFI_TIME.TimeZone
|
||||
#define EFI_UNSPECIFIED_TIMEZONE 0x07FF
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Networking
|
||||
//
|
||||
|
||||
typedef struct {
|
||||
UINT8 Addr[4];
|
||||
} EFI_IPv4_ADDRESS;
|
||||
|
||||
typedef struct {
|
||||
UINT8 Addr[16];
|
||||
} EFI_IPv6_ADDRESS;
|
||||
|
||||
typedef struct {
|
||||
UINT8 Addr[32];
|
||||
} EFI_MAC_ADDRESS;
|
||||
|
||||
typedef struct {
|
||||
UINT32 ReceivedQueueTimeoutValue;
|
||||
UINT32 TransmitQueueTimeoutValue;
|
||||
UINT16 ProtocolTypeFilter;
|
||||
BOOLEAN EnableUnicastReceive;
|
||||
BOOLEAN EnableMulticastReceive;
|
||||
BOOLEAN EnableBroadcastReceive;
|
||||
BOOLEAN EnablePromiscuousReceive;
|
||||
BOOLEAN FlushQueuesOnReset;
|
||||
BOOLEAN EnableReceiveTimestamps;
|
||||
BOOLEAN DisableBackgroundPolling;
|
||||
} EFI_MANAGED_NETWORK_CONFIG_DATA;
|
||||
|
||||
//
|
||||
// Memory
|
||||
//
|
||||
|
||||
typedef UINT64 EFI_PHYSICAL_ADDRESS;
|
||||
typedef UINT64 EFI_VIRTUAL_ADDRESS;
|
||||
|
||||
typedef enum {
|
||||
AllocateAnyPages,
|
||||
AllocateMaxAddress,
|
||||
AllocateAddress,
|
||||
MaxAllocateType
|
||||
} EFI_ALLOCATE_TYPE;
|
||||
|
||||
//Preseve the attr on any range supplied.
|
||||
//ConventialMemory must have WB,SR,SW when supplied.
|
||||
//When allocating from ConventialMemory always make it WB,SR,SW
|
||||
//When returning to ConventialMemory always make it WB,SR,SW
|
||||
//When getting the memory map, or on RT for runtime types
|
||||
|
||||
|
||||
typedef enum {
|
||||
EfiReservedMemoryType,
|
||||
EfiLoaderCode,
|
||||
EfiLoaderData,
|
||||
EfiBootServicesCode,
|
||||
EfiBootServicesData,
|
||||
EfiRuntimeServicesCode,
|
||||
EfiRuntimeServicesData,
|
||||
EfiConventionalMemory,
|
||||
EfiUnusableMemory,
|
||||
EfiACPIReclaimMemory,
|
||||
EfiACPIMemoryNVS,
|
||||
EfiMemoryMappedIO,
|
||||
EfiMemoryMappedIOPortSpace,
|
||||
EfiPalCode,
|
||||
EfiMaxMemoryType
|
||||
} EFI_MEMORY_TYPE;
|
||||
|
||||
// possible caching types for the memory range
|
||||
#define EFI_MEMORY_UC 0x0000000000000001
|
||||
#define EFI_MEMORY_WC 0x0000000000000002
|
||||
#define EFI_MEMORY_WT 0x0000000000000004
|
||||
#define EFI_MEMORY_WB 0x0000000000000008
|
||||
#define EFI_MEMORY_UCE 0x0000000000000010
|
||||
|
||||
// physical memory protection on range
|
||||
#define EFI_MEMORY_WP 0x0000000000001000
|
||||
#define EFI_MEMORY_RP 0x0000000000002000
|
||||
#define EFI_MEMORY_XP 0x0000000000004000
|
||||
|
||||
// range requires a runtime mapping
|
||||
#define EFI_MEMORY_RUNTIME 0x8000000000000000
|
||||
|
||||
#define EFI_MEMORY_DESCRIPTOR_VERSION 1
|
||||
typedef struct {
|
||||
UINT32 Type; // Field size is 32 bits followed by 32 bit pad
|
||||
UINT32 Pad;
|
||||
EFI_PHYSICAL_ADDRESS PhysicalStart; // Field size is 64 bits
|
||||
EFI_VIRTUAL_ADDRESS VirtualStart; // Field size is 64 bits
|
||||
UINT64 NumberOfPages; // Field size is 64 bits
|
||||
UINT64 Attribute; // Field size is 64 bits
|
||||
} EFI_MEMORY_DESCRIPTOR;
|
||||
|
||||
//
|
||||
// International Language
|
||||
//
|
||||
|
||||
typedef UINT8 ISO_639_2;
|
||||
#define ISO_639_2_ENTRY_SIZE 3
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
#define EFI_PAGE_SIZE 4096
|
||||
#define EFI_PAGE_MASK 0xFFF
|
||||
#define EFI_PAGE_SHIFT 12
|
||||
|
||||
#define EFI_SIZE_TO_PAGES(a) \
|
||||
( ((a) >> EFI_PAGE_SHIFT) + ((a) & EFI_PAGE_MASK ? 1 : 0) )
|
||||
|
||||
#define EFI_OS_INDICATIONS_BOOT_TO_FW_UI 0x0000000000000001
|
||||
#define EFI_OS_INDICATIONS_TIMESTAMP_REVOCATION 0x0000000000000002
|
||||
#define EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED \
|
||||
0x0000000000000004
|
||||
#define EFI_OS_INDICATIONS_FMP_CAPSULE_SUPPORTED \
|
||||
0x0000000000000008
|
||||
#define EFI_OS_INDICATIONS_CAPSULE_RESULT_VAR_SUPPORTED \
|
||||
0x0000000000000010
|
||||
|
||||
#endif
|
582
dxe/efi/efidevp.h
Normal file
582
dxe/efi/efidevp.h
Normal file
@ -0,0 +1,582 @@
|
||||
#ifndef _DEVPATH_H
|
||||
#define _DEVPATH_H
|
||||
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
devpath.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Defines for parsing the EFI Device Path structures
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
//
|
||||
// Device Path structures - Section C
|
||||
//
|
||||
|
||||
typedef struct _EFI_DEVICE_PATH_PROTOCOL {
|
||||
UINT8 Type;
|
||||
UINT8 SubType;
|
||||
UINT8 Length[2];
|
||||
} EFI_DEVICE_PATH_PROTOCOL;
|
||||
|
||||
typedef struct _EFI_DEVICE_PATH_PROTOCOL _EFI_DEVICE_PATH;
|
||||
typedef EFI_DEVICE_PATH_PROTOCOL EFI_DEVICE_PATH;
|
||||
|
||||
#define EFI_DP_TYPE_MASK 0x7F
|
||||
#define EFI_DP_TYPE_UNPACKED 0x80
|
||||
|
||||
//#define END_DEVICE_PATH_TYPE 0xff
|
||||
#define END_DEVICE_PATH_TYPE 0x7f
|
||||
//#define END_DEVICE_PATH_TYPE_UNPACKED 0x7f
|
||||
|
||||
#define END_ENTIRE_DEVICE_PATH_SUBTYPE 0xff
|
||||
#define END_INSTANCE_DEVICE_PATH_SUBTYPE 0x01
|
||||
#define END_DEVICE_PATH_LENGTH (sizeof(EFI_DEVICE_PATH_PROTOCOL))
|
||||
|
||||
|
||||
#define DP_IS_END_TYPE(a)
|
||||
#define DP_IS_END_SUBTYPE(a) ( ((a)->SubType == END_ENTIRE_DEVICE_PATH_SUBTYPE )
|
||||
|
||||
#define DevicePathType(a) ( ((a)->Type) & EFI_DP_TYPE_MASK )
|
||||
#define DevicePathSubType(a) ( (a)->SubType )
|
||||
#define DevicePathNodeLength(a) ( ((a)->Length[0]) | ((a)->Length[1] << 8) )
|
||||
#define NextDevicePathNode(a) ( (EFI_DEVICE_PATH_PROTOCOL *) ( ((UINT8 *) (a)) + DevicePathNodeLength(a)))
|
||||
//#define IsDevicePathEndType(a) ( DevicePathType(a) == END_DEVICE_PATH_TYPE_UNPACKED )
|
||||
#define IsDevicePathEndType(a) ( DevicePathType(a) == END_DEVICE_PATH_TYPE )
|
||||
#define IsDevicePathEndSubType(a) ( (a)->SubType == END_ENTIRE_DEVICE_PATH_SUBTYPE )
|
||||
#define IsDevicePathEnd(a) ( IsDevicePathEndType(a) && IsDevicePathEndSubType(a) )
|
||||
#define IsDevicePathUnpacked(a) ( (a)->Type & EFI_DP_TYPE_UNPACKED )
|
||||
|
||||
|
||||
#define SetDevicePathNodeLength(a,l) { \
|
||||
(a)->Length[0] = (UINT8) (l); \
|
||||
(a)->Length[1] = (UINT8) ((l) >> 8); \
|
||||
}
|
||||
|
||||
#define SetDevicePathEndNode(a) { \
|
||||
(a)->Type = END_DEVICE_PATH_TYPE; \
|
||||
(a)->SubType = END_ENTIRE_DEVICE_PATH_SUBTYPE; \
|
||||
(a)->Length[0] = sizeof(EFI_DEVICE_PATH_PROTOCOL); \
|
||||
(a)->Length[1] = 0; \
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Hardware Device Path (UEFI 2.4 specification, version 2.4 § 9.3.2.)
|
||||
*/
|
||||
|
||||
#define HARDWARE_DEVICE_PATH 0x01
|
||||
|
||||
#define HW_PCI_DP 0x01
|
||||
typedef struct _PCI_DEVICE_PATH {
|
||||
EFI_DEVICE_PATH_PROTOCOL Header;
|
||||
UINT8 Function;
|
||||
UINT8 Device;
|
||||
} PCI_DEVICE_PATH;
|
||||
|
||||
#define HW_PCCARD_DP 0x02
|
||||
typedef struct _PCCARD_DEVICE_PATH {
|
||||
EFI_DEVICE_PATH_PROTOCOL Header;
|
||||
UINT8 FunctionNumber ;
|
||||
} PCCARD_DEVICE_PATH;
|
||||
|
||||
#define HW_MEMMAP_DP 0x03
|
||||
typedef struct _MEMMAP_DEVICE_PATH {
|
||||
EFI_DEVICE_PATH_PROTOCOL Header;
|
||||
UINT32 MemoryType;
|
||||
EFI_PHYSICAL_ADDRESS StartingAddress;
|
||||
EFI_PHYSICAL_ADDRESS EndingAddress;
|
||||
} MEMMAP_DEVICE_PATH;
|
||||
|
||||
#define HW_VENDOR_DP 0x04
|
||||
typedef struct _VENDOR_DEVICE_PATH {
|
||||
EFI_DEVICE_PATH_PROTOCOL Header;
|
||||
EFI_GUID Guid;
|
||||
} VENDOR_DEVICE_PATH;
|
||||
|
||||
#define UNKNOWN_DEVICE_GUID \
|
||||
{ 0xcf31fac5, 0xc24e, 0x11d2, {0x85, 0xf3, 0x0, 0xa0, 0xc9, 0x3e, 0xc9, 0x3b} }
|
||||
|
||||
typedef struct _UKNOWN_DEVICE_VENDOR_DP {
|
||||
VENDOR_DEVICE_PATH DevicePath;
|
||||
UINT8 LegacyDriveLetter;
|
||||
} UNKNOWN_DEVICE_VENDOR_DEVICE_PATH;
|
||||
|
||||
#define HW_CONTROLLER_DP 0x05
|
||||
typedef struct _CONTROLLER_DEVICE_PATH {
|
||||
EFI_DEVICE_PATH_PROTOCOL Header;
|
||||
UINT32 Controller;
|
||||
} CONTROLLER_DEVICE_PATH;
|
||||
|
||||
|
||||
/*
|
||||
* ACPI Device Path (UEFI 2.4 specification, version 2.4 § 9.3.3 and 9.3.4.)
|
||||
*/
|
||||
#define ACPI_DEVICE_PATH 0x02
|
||||
|
||||
#define ACPI_DP 0x01
|
||||
typedef struct _ACPI_HID_DEVICE_PATH {
|
||||
EFI_DEVICE_PATH_PROTOCOL Header;
|
||||
UINT32 HID;
|
||||
UINT32 UID;
|
||||
} ACPI_HID_DEVICE_PATH;
|
||||
|
||||
#define EXPANDED_ACPI_DP 0x02
|
||||
typedef struct _EXPANDED_ACPI_HID_DEVICE_PATH {
|
||||
EFI_DEVICE_PATH_PROTOCOL Header;
|
||||
UINT32 HID;
|
||||
UINT32 UID;
|
||||
UINT32 CID;
|
||||
UINT8 HidStr[1];
|
||||
} EXPANDED_ACPI_HID_DEVICE_PATH;
|
||||
|
||||
#define ACPI_ADR_DP 3
|
||||
typedef struct _ACPI_ADR_DEVICE_PATH {
|
||||
EFI_DEVICE_PATH_PROTOCOL Header ;
|
||||
UINT32 ADR ;
|
||||
} ACPI_ADR_DEVICE_PATH ;
|
||||
|
||||
//
|
||||
// EISA ID Macro
|
||||
// EISA ID Definition 32-bits
|
||||
// bits[15:0] - three character compressed ASCII EISA ID.
|
||||
// bits[31:16] - binary number
|
||||
// Compressed ASCII is 5 bits per character 0b00001 = 'A' 0b11010 = 'Z'
|
||||
//
|
||||
#define PNP_EISA_ID_CONST 0x41d0
|
||||
#define EISA_ID(_Name, _Num) ((UINT32) ((_Name) | (_Num) << 16))
|
||||
#define EISA_PNP_ID(_PNPId) (EISA_ID(PNP_EISA_ID_CONST, (_PNPId)))
|
||||
|
||||
#define PNP_EISA_ID_MASK 0xffff
|
||||
#define EISA_ID_TO_NUM(_Id) ((_Id) >> 16)
|
||||
|
||||
|
||||
/*
|
||||
* Messaging Device Path (UEFI 2.4 specification, version 2.4 § 9.3.5.)
|
||||
*/
|
||||
#define MESSAGING_DEVICE_PATH 0x03
|
||||
|
||||
#define MSG_ATAPI_DP 0x01
|
||||
typedef struct _ATAPI_DEVICE_PATH {
|
||||
EFI_DEVICE_PATH_PROTOCOL Header;
|
||||
UINT8 PrimarySecondary;
|
||||
UINT8 SlaveMaster;
|
||||
UINT16 Lun;
|
||||
} ATAPI_DEVICE_PATH;
|
||||
|
||||
#define MSG_SCSI_DP 0x02
|
||||
typedef struct _SCSI_DEVICE_PATH {
|
||||
EFI_DEVICE_PATH_PROTOCOL Header;
|
||||
UINT16 Pun;
|
||||
UINT16 Lun;
|
||||
} SCSI_DEVICE_PATH;
|
||||
|
||||
#define MSG_FIBRECHANNEL_DP 0x03
|
||||
typedef struct _FIBRECHANNEL_DEVICE_PATH {
|
||||
EFI_DEVICE_PATH_PROTOCOL Header;
|
||||
UINT32 Reserved;
|
||||
UINT64 WWN;
|
||||
UINT64 Lun;
|
||||
} FIBRECHANNEL_DEVICE_PATH;
|
||||
|
||||
/**
|
||||
* Fibre Channel Ex SubType.
|
||||
* UEFI 2.0 specification version 2.4 § 9.3.5.6.
|
||||
*/
|
||||
#define MSG_FIBRECHANNELEX_DP 21
|
||||
typedef struct _FIBRECHANNELEX_DEVICE_PATH {
|
||||
EFI_DEVICE_PATH_PROTOCOL Header ;
|
||||
UINT32 Reserved ;
|
||||
UINT8 WWN[ 8 ] ; /* World Wide Name */
|
||||
UINT8 Lun[ 8 ] ; /* Logical unit, T-10 SCSI Architecture Model 4 specification */
|
||||
} FIBRECHANNELEX_DEVICE_PATH ;
|
||||
|
||||
#define MSG_1394_DP 0x04
|
||||
typedef struct _F1394_DEVICE_PATH {
|
||||
EFI_DEVICE_PATH_PROTOCOL Header;
|
||||
UINT32 Reserved;
|
||||
UINT64 Guid;
|
||||
} F1394_DEVICE_PATH;
|
||||
|
||||
#define MSG_USB_DP 0x05
|
||||
typedef struct _USB_DEVICE_PATH {
|
||||
EFI_DEVICE_PATH_PROTOCOL Header;
|
||||
UINT8 Port;
|
||||
UINT8 Endpoint;
|
||||
} USB_DEVICE_PATH;
|
||||
|
||||
/**
|
||||
* SATA Device Path SubType.
|
||||
* UEFI 2.0 specification version 2.4 § 9.3.5.6.
|
||||
*/
|
||||
#define MSG_SATA_DP 18
|
||||
typedef struct _SATA_DEVICE_PATH {
|
||||
EFI_DEVICE_PATH_PROTOCOL Header ;
|
||||
UINT16 HBAPortNumber ;
|
||||
UINT16 PortMultiplierPortNumber ;
|
||||
UINT16 Lun ; /* Logical Unit Number */
|
||||
} SATA_DEVICE_PATH ;
|
||||
|
||||
/**
|
||||
* USB WWID Device Path SubType.
|
||||
* UEFI 2.0 specification version 2.4 § 9.3.5.7.
|
||||
*/
|
||||
#define MSG_USB_WWID_DP 16
|
||||
typedef struct _USB_WWID_DEVICE_PATH {
|
||||
EFI_DEVICE_PATH_PROTOCOL Header ;
|
||||
UINT16 InterfaceNumber ;
|
||||
UINT16 VendorId ;
|
||||
UINT16 ProductId ;
|
||||
CHAR16 SerialNumber[ 1 ] ; /* UTF-16 characters of the USB serial number */
|
||||
} USB_WWID_DEVICE_PATH ;
|
||||
|
||||
/**
|
||||
* Device Logical Unit SubType.
|
||||
* UEFI 2.0 specification version 2.4 § 9.3.5.8.
|
||||
*/
|
||||
#define MSG_DEVICE_LOGICAL_UNIT_DP 17
|
||||
typedef struct _DEVICE_LOGICAL_UNIT_DEVICE_PATH {
|
||||
EFI_DEVICE_PATH_PROTOCOL Header ;
|
||||
UINT8 Lun ; /* Logical Unit Number */
|
||||
} DEVICE_LOGICAL_UNIT_DEVICE_PATH ;
|
||||
|
||||
#define MSG_USB_CLASS_DP 0x0F
|
||||
typedef struct _USB_CLASS_DEVICE_PATH {
|
||||
EFI_DEVICE_PATH_PROTOCOL Header;
|
||||
UINT16 VendorId;
|
||||
UINT16 ProductId;
|
||||
UINT8 DeviceClass;
|
||||
UINT8 DeviceSubclass;
|
||||
UINT8 DeviceProtocol;
|
||||
} USB_CLASS_DEVICE_PATH;
|
||||
|
||||
#define MSG_I2O_DP 0x06
|
||||
typedef struct _I2O_DEVICE_PATH {
|
||||
EFI_DEVICE_PATH_PROTOCOL Header;
|
||||
UINT32 Tid;
|
||||
} I2O_DEVICE_PATH;
|
||||
|
||||
#define MSG_MAC_ADDR_DP 0x0b
|
||||
typedef struct _MAC_ADDR_DEVICE_PATH {
|
||||
EFI_DEVICE_PATH_PROTOCOL Header;
|
||||
EFI_MAC_ADDRESS MacAddress;
|
||||
UINT8 IfType;
|
||||
} MAC_ADDR_DEVICE_PATH;
|
||||
|
||||
#define MSG_IPv4_DP 0x0c
|
||||
typedef struct _IPv4_DEVICE_PATH {
|
||||
EFI_DEVICE_PATH_PROTOCOL Header;
|
||||
EFI_IPv4_ADDRESS LocalIpAddress;
|
||||
EFI_IPv4_ADDRESS RemoteIpAddress;
|
||||
UINT16 LocalPort;
|
||||
UINT16 RemotePort;
|
||||
UINT16 Protocol;
|
||||
BOOLEAN StaticIpAddress;
|
||||
/* new from UEFI version 2, code must check Length field in Header */
|
||||
EFI_IPv4_ADDRESS GatewayIpAddress ;
|
||||
EFI_IPv4_ADDRESS SubnetMask ;
|
||||
} IPv4_DEVICE_PATH;
|
||||
|
||||
#define MSG_IPv6_DP 0x0d
|
||||
typedef struct _IPv6_DEVICE_PATH {
|
||||
EFI_DEVICE_PATH_PROTOCOL Header;
|
||||
EFI_IPv6_ADDRESS LocalIpAddress;
|
||||
EFI_IPv6_ADDRESS RemoteIpAddress;
|
||||
UINT16 LocalPort;
|
||||
UINT16 RemotePort;
|
||||
UINT16 Protocol;
|
||||
BOOLEAN IPAddressOrigin ;
|
||||
/* new from UEFI version 2, code must check Length field in Header */
|
||||
UINT8 PrefixLength ;
|
||||
EFI_IPv6_ADDRESS GatewayIpAddress ;
|
||||
} IPv6_DEVICE_PATH;
|
||||
|
||||
|
||||
/**
|
||||
* Uniform Resource Identifiers SubType.
|
||||
* UEFI 2.0 specification version 2.4C § 9.3.5.23.
|
||||
*/
|
||||
#define MSG_URI_DP 24
|
||||
typedef struct _URI_DEVICE_PATH {
|
||||
EFI_DEVICE_PATH_PROTOCOL Header;
|
||||
CHAR8 Uri[1];
|
||||
} URI_DEVICE_PATH;
|
||||
|
||||
/**
|
||||
* Device Logical Unit SubType.
|
||||
* UEFI 2.0 specification version 2.4 § 9.3.5.8.
|
||||
*/
|
||||
#define MSG_VLAN_DP 20
|
||||
typedef struct _VLAN_DEVICE_PATH {
|
||||
EFI_DEVICE_PATH_PROTOCOL Header ;
|
||||
UINT16 VlanId ;
|
||||
} VLAN_DEVICE_PATH;
|
||||
|
||||
#define MSG_INFINIBAND_DP 0x09
|
||||
typedef struct _INFINIBAND_DEVICE_PATH {
|
||||
EFI_DEVICE_PATH_PROTOCOL Header;
|
||||
UINT32 ResourceFlags ;
|
||||
UINT64 PortGid ;
|
||||
UINT64 ServiceId ;
|
||||
UINT64 TargetPortId ;
|
||||
UINT64 DeviceId ;
|
||||
} INFINIBAND_DEVICE_PATH;
|
||||
|
||||
#define MSG_UART_DP 0x0e
|
||||
typedef struct _UART_DEVICE_PATH {
|
||||
EFI_DEVICE_PATH_PROTOCOL Header;
|
||||
UINT32 Reserved;
|
||||
UINT64 BaudRate;
|
||||
UINT8 DataBits;
|
||||
UINT8 Parity;
|
||||
UINT8 StopBits;
|
||||
} UART_DEVICE_PATH;
|
||||
|
||||
#define MSG_VENDOR_DP 0x0A
|
||||
/* Use VENDOR_DEVICE_PATH struct */
|
||||
|
||||
#define EFI_PC_ANSI_GUID \
|
||||
{ 0xe0c14753, 0xf9be, 0x11d2, {0x9a, 0x0c, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d} }
|
||||
#define DEVICE_PATH_MESSAGING_PC_ANSI EFI_PC_ANSI_GUID
|
||||
|
||||
#define EFI_VT_100_GUID \
|
||||
{ 0xdfa66065, 0xb419, 0x11d3, {0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d} }
|
||||
#define DEVICE_PATH_MESSAGING_VT_100 EFI_VT_100_GUID
|
||||
|
||||
#define EFI_VT_100_PLUS_GUID \
|
||||
{ 0x7baec70b, 0x57e0, 0x4c76, {0x8e, 0x87, 0x2f, 0x9e, 0x28, 0x08, 0x83, 0x43} }
|
||||
#define DEVICE_PATH_MESSAGING_VT_100_PLUS EFI_VT_100_PLUS_GUID
|
||||
|
||||
#define EFI_VT_UTF8_GUID \
|
||||
{ 0xad15a0d6, 0x8bec, 0x4acf, {0xa0, 0x73, 0xd0, 0x1d, 0xe7, 0x7e, 0x2d, 0x88} }
|
||||
#define DEVICE_PATH_MESSAGING_VT_UTF8 EFI_VT_UTF8_GUID
|
||||
|
||||
|
||||
/*
|
||||
* Media Device Path (UEFI 2.4 specification, version 2.4 § 9.3.6.)
|
||||
*/
|
||||
#define MEDIA_DEVICE_PATH 0x04
|
||||
|
||||
#define MEDIA_HARDDRIVE_DP 0x01
|
||||
typedef struct _HARDDRIVE_DEVICE_PATH {
|
||||
EFI_DEVICE_PATH_PROTOCOL Header;
|
||||
UINT32 PartitionNumber;
|
||||
UINT64 PartitionStart;
|
||||
UINT64 PartitionSize;
|
||||
UINT8 Signature[16];
|
||||
UINT8 MBRType;
|
||||
UINT8 SignatureType;
|
||||
} HARDDRIVE_DEVICE_PATH;
|
||||
|
||||
#define MBR_TYPE_PCAT 0x01
|
||||
#define MBR_TYPE_EFI_PARTITION_TABLE_HEADER 0x02
|
||||
|
||||
#define SIGNATURE_TYPE_MBR 0x01
|
||||
#define SIGNATURE_TYPE_GUID 0x02
|
||||
|
||||
#define MEDIA_CDROM_DP 0x02
|
||||
typedef struct _CDROM_DEVICE_PATH {
|
||||
EFI_DEVICE_PATH_PROTOCOL Header;
|
||||
UINT32 BootEntry;
|
||||
UINT64 PartitionStart;
|
||||
UINT64 PartitionSize;
|
||||
} CDROM_DEVICE_PATH;
|
||||
|
||||
#define MEDIA_VENDOR_DP 0x03
|
||||
/* Use VENDOR_DEVICE_PATH struct */
|
||||
|
||||
#define MEDIA_FILEPATH_DP 0x04
|
||||
typedef struct _FILEPATH_DEVICE_PATH {
|
||||
EFI_DEVICE_PATH_PROTOCOL Header;
|
||||
CHAR16 PathName[1];
|
||||
} FILEPATH_DEVICE_PATH;
|
||||
|
||||
#define SIZE_OF_FILEPATH_DEVICE_PATH EFI_FIELD_OFFSET(FILEPATH_DEVICE_PATH,PathName)
|
||||
|
||||
#define MEDIA_PROTOCOL_DP 0x05
|
||||
typedef struct _MEDIA_PROTOCOL_DEVICE_PATH {
|
||||
EFI_DEVICE_PATH_PROTOCOL Header;
|
||||
EFI_GUID Protocol;
|
||||
} MEDIA_PROTOCOL_DEVICE_PATH;
|
||||
|
||||
/**
|
||||
* PIWG Firmware File SubType.
|
||||
* UEFI 2.0 specification version 2.4 § 9.3.6.6.
|
||||
*/
|
||||
#define MEDIA_PIWG_FW_FILE_DP 6
|
||||
typedef struct _MEDIA_FW_VOL_FILEPATH_DEVICE_PATH {
|
||||
EFI_DEVICE_PATH_PROTOCOL Header ;
|
||||
EFI_GUID FvFileName ;
|
||||
} MEDIA_FW_VOL_FILEPATH_DEVICE_PATH ;
|
||||
|
||||
/**
|
||||
* PIWG Firmware Volume Device Path SubType.
|
||||
* UEFI 2.0 specification version 2.4 § 9.3.6.7.
|
||||
*/
|
||||
#define MEDIA_PIWG_FW_VOL_DP 7
|
||||
typedef struct _MEDIA_FW_VOL_DEVICE_PATH {
|
||||
EFI_DEVICE_PATH_PROTOCOL Header ;
|
||||
EFI_GUID FvName ;
|
||||
} MEDIA_FW_VOL_DEVICE_PATH ;
|
||||
|
||||
/**
|
||||
* Media relative offset range device path.
|
||||
* UEFI 2.0 specification version 2.4 § 9.3.6.8.
|
||||
*/
|
||||
#define MEDIA_RELATIVE_OFFSET_RANGE_DP 8
|
||||
typedef struct _MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH {
|
||||
EFI_DEVICE_PATH_PROTOCOL Header ;
|
||||
UINT32 Reserved ;
|
||||
UINT64 StartingOffset ;
|
||||
UINT64 EndingOffset ;
|
||||
} MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH ;
|
||||
|
||||
|
||||
/*
|
||||
* BIOS Boot Specification Device Path (UEFI 2.4 specification, version 2.4 § 9.3.7.)
|
||||
*/
|
||||
#define BBS_DEVICE_PATH 0x05
|
||||
|
||||
#define BBS_BBS_DP 0x01
|
||||
typedef struct _BBS_BBS_DEVICE_PATH {
|
||||
EFI_DEVICE_PATH_PROTOCOL Header;
|
||||
UINT16 DeviceType;
|
||||
UINT16 StatusFlag;
|
||||
CHAR8 String[1];
|
||||
} BBS_BBS_DEVICE_PATH;
|
||||
|
||||
/* DeviceType definitions - from BBS specification */
|
||||
#define BBS_TYPE_FLOPPY 0x01
|
||||
#define BBS_TYPE_HARDDRIVE 0x02
|
||||
#define BBS_TYPE_CDROM 0x03
|
||||
#define BBS_TYPE_PCMCIA 0x04
|
||||
#define BBS_TYPE_USB 0x05
|
||||
#define BBS_TYPE_EMBEDDED_NETWORK 0x06
|
||||
#define BBS_TYPE_DEV 0x80
|
||||
#define BBS_TYPE_UNKNOWN 0xFF
|
||||
|
||||
typedef union {
|
||||
EFI_DEVICE_PATH_PROTOCOL DevPath;
|
||||
PCI_DEVICE_PATH Pci;
|
||||
PCCARD_DEVICE_PATH PcCard;
|
||||
MEMMAP_DEVICE_PATH MemMap;
|
||||
VENDOR_DEVICE_PATH Vendor;
|
||||
UNKNOWN_DEVICE_VENDOR_DEVICE_PATH UnknownVendor;
|
||||
CONTROLLER_DEVICE_PATH Controller;
|
||||
ACPI_HID_DEVICE_PATH Acpi;
|
||||
|
||||
ATAPI_DEVICE_PATH Atapi;
|
||||
SCSI_DEVICE_PATH Scsi;
|
||||
FIBRECHANNEL_DEVICE_PATH FibreChannel;
|
||||
|
||||
F1394_DEVICE_PATH F1394;
|
||||
USB_DEVICE_PATH Usb;
|
||||
USB_CLASS_DEVICE_PATH UsbClass;
|
||||
I2O_DEVICE_PATH I2O;
|
||||
MAC_ADDR_DEVICE_PATH MacAddr;
|
||||
IPv4_DEVICE_PATH Ipv4;
|
||||
IPv6_DEVICE_PATH Ipv6;
|
||||
URI_DEVICE_PATH Uri;
|
||||
INFINIBAND_DEVICE_PATH InfiniBand;
|
||||
UART_DEVICE_PATH Uart;
|
||||
|
||||
HARDDRIVE_DEVICE_PATH HardDrive;
|
||||
CDROM_DEVICE_PATH CD;
|
||||
|
||||
FILEPATH_DEVICE_PATH FilePath;
|
||||
MEDIA_PROTOCOL_DEVICE_PATH MediaProtocol;
|
||||
|
||||
BBS_BBS_DEVICE_PATH Bbs;
|
||||
|
||||
} EFI_DEV_PATH;
|
||||
|
||||
typedef union {
|
||||
EFI_DEVICE_PATH_PROTOCOL *DevPath;
|
||||
PCI_DEVICE_PATH *Pci;
|
||||
PCCARD_DEVICE_PATH *PcCard;
|
||||
MEMMAP_DEVICE_PATH *MemMap;
|
||||
VENDOR_DEVICE_PATH *Vendor;
|
||||
UNKNOWN_DEVICE_VENDOR_DEVICE_PATH *UnknownVendor;
|
||||
CONTROLLER_DEVICE_PATH *Controller;
|
||||
ACPI_HID_DEVICE_PATH *Acpi;
|
||||
|
||||
ATAPI_DEVICE_PATH *Atapi;
|
||||
SCSI_DEVICE_PATH *Scsi;
|
||||
FIBRECHANNEL_DEVICE_PATH *FibreChannel;
|
||||
|
||||
F1394_DEVICE_PATH *F1394;
|
||||
USB_DEVICE_PATH *Usb;
|
||||
USB_CLASS_DEVICE_PATH *UsbClass;
|
||||
I2O_DEVICE_PATH *I2O;
|
||||
MAC_ADDR_DEVICE_PATH *MacAddr;
|
||||
IPv4_DEVICE_PATH *Ipv4;
|
||||
IPv6_DEVICE_PATH *Ipv6;
|
||||
URI_DEVICE_PATH *Uri;
|
||||
INFINIBAND_DEVICE_PATH *InfiniBand;
|
||||
UART_DEVICE_PATH *Uart;
|
||||
|
||||
HARDDRIVE_DEVICE_PATH *HardDrive;
|
||||
|
||||
FILEPATH_DEVICE_PATH *FilePath;
|
||||
MEDIA_PROTOCOL_DEVICE_PATH *MediaProtocol;
|
||||
|
||||
CDROM_DEVICE_PATH *CD;
|
||||
BBS_BBS_DEVICE_PATH *Bbs;
|
||||
|
||||
} EFI_DEV_PATH_PTR;
|
||||
|
||||
#define EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID \
|
||||
{ 0x8b843e20, 0x8132, 0x4852, {0x90, 0xcc, 0x55, 0x1a, 0x4e, 0x4a, 0x7f, 0x1c} }
|
||||
|
||||
typedef
|
||||
CHAR16*
|
||||
(EFIAPI *EFI_DEVICE_PATH_TO_TEXT_NODE) (
|
||||
IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode,
|
||||
IN BOOLEAN DisplayOnly,
|
||||
IN BOOLEAN AllowShortcuts
|
||||
);
|
||||
|
||||
typedef
|
||||
CHAR16*
|
||||
(EFIAPI *EFI_DEVICE_PATH_TO_TEXT_PATH) (
|
||||
IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
|
||||
IN BOOLEAN DisplayOnly,
|
||||
IN BOOLEAN AllowShortcuts
|
||||
);
|
||||
|
||||
typedef struct _EFI_DEVICE_PATH_TO_TEXT_PROTOCOL {
|
||||
EFI_DEVICE_PATH_TO_TEXT_NODE ConvertDeviceNodeToText;
|
||||
EFI_DEVICE_PATH_TO_TEXT_PATH ConvertDevicePathToText;
|
||||
} EFI_DEVICE_PATH_TO_TEXT_PROTOCOL;
|
||||
|
||||
#define EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL_GUID \
|
||||
{ 0x5c99a21, 0xc70f, 0x4ad2, {0x8a, 0x5f, 0x35, 0xdf, 0x33, 0x43, 0xf5, 0x1e} }
|
||||
|
||||
typedef
|
||||
EFI_DEVICE_PATH_PROTOCOL*
|
||||
(EFIAPI *EFI_DEVICE_PATH_FROM_TEXT_NODE) (
|
||||
IN CONST CHAR16 *TextDeviceNode
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_DEVICE_PATH_PROTOCOL*
|
||||
(EFIAPI *EFI_DEVICE_PATH_FROM_TEXT_PATH) (
|
||||
IN CONST CHAR16 *TextDevicePath
|
||||
);
|
||||
|
||||
typedef struct {
|
||||
EFI_DEVICE_PATH_FROM_TEXT_NODE ConvertTextToDeviceNode;
|
||||
EFI_DEVICE_PATH_FROM_TEXT_PATH ConvertTextToDevicePath;
|
||||
} EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL;
|
||||
|
||||
#endif
|
67
dxe/efi/efierr.h
Normal file
67
dxe/efi/efierr.h
Normal file
@ -0,0 +1,67 @@
|
||||
#ifndef _EFI_ERR_H
|
||||
#define _EFI_ERR_H
|
||||
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
efierr.h
|
||||
|
||||
Abstract:
|
||||
|
||||
EFI error codes
|
||||
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
|
||||
#define EFIWARN(a) (a)
|
||||
#define EFI_ERROR(a) (((INTN) a) < 0)
|
||||
|
||||
|
||||
#define EFI_SUCCESS 0
|
||||
#define EFI_LOAD_ERROR EFIERR(1)
|
||||
#define EFI_INVALID_PARAMETER EFIERR(2)
|
||||
#define EFI_UNSUPPORTED EFIERR(3)
|
||||
#define EFI_BAD_BUFFER_SIZE EFIERR(4)
|
||||
#define EFI_BUFFER_TOO_SMALL EFIERR(5)
|
||||
#define EFI_NOT_READY EFIERR(6)
|
||||
#define EFI_DEVICE_ERROR EFIERR(7)
|
||||
#define EFI_WRITE_PROTECTED EFIERR(8)
|
||||
#define EFI_OUT_OF_RESOURCES EFIERR(9)
|
||||
#define EFI_VOLUME_CORRUPTED EFIERR(10)
|
||||
#define EFI_VOLUME_FULL EFIERR(11)
|
||||
#define EFI_NO_MEDIA EFIERR(12)
|
||||
#define EFI_MEDIA_CHANGED EFIERR(13)
|
||||
#define EFI_NOT_FOUND EFIERR(14)
|
||||
#define EFI_ACCESS_DENIED EFIERR(15)
|
||||
#define EFI_NO_RESPONSE EFIERR(16)
|
||||
#define EFI_NO_MAPPING EFIERR(17)
|
||||
#define EFI_TIMEOUT EFIERR(18)
|
||||
#define EFI_NOT_STARTED EFIERR(19)
|
||||
#define EFI_ALREADY_STARTED EFIERR(20)
|
||||
#define EFI_ABORTED EFIERR(21)
|
||||
#define EFI_ICMP_ERROR EFIERR(22)
|
||||
#define EFI_TFTP_ERROR EFIERR(23)
|
||||
#define EFI_PROTOCOL_ERROR EFIERR(24)
|
||||
#define EFI_INCOMPATIBLE_VERSION EFIERR(25)
|
||||
#define EFI_SECURITY_VIOLATION EFIERR(26)
|
||||
#define EFI_CRC_ERROR EFIERR(27)
|
||||
#define EFI_END_OF_MEDIA EFIERR(28)
|
||||
#define EFI_END_OF_FILE EFIERR(31)
|
||||
#define EFI_INVALID_LANGUAGE EFIERR(32)
|
||||
#define EFI_COMPROMISED_DATA EFIERR(33)
|
||||
|
||||
#define EFI_WARN_UNKOWN_GLYPH EFIWARN(1)
|
||||
#define EFI_WARN_DELETE_FAILURE EFIWARN(2)
|
||||
#define EFI_WARN_WRITE_FAILURE EFIWARN(3)
|
||||
#define EFI_WARN_BUFFER_TOO_SMALL EFIWARN(4)
|
||||
|
||||
#endif
|
||||
|
399
dxe/efi/efipciio.h
Normal file
399
dxe/efi/efipciio.h
Normal file
@ -0,0 +1,399 @@
|
||||
#ifndef _EFI_PCI_IO_H
|
||||
#define _EFI_PCI_IO_H
|
||||
|
||||
#define EFI_PCI_IO_PROTOCOL_GUID \
|
||||
{ 0x4cf5b200, 0x68b8, 0x4ca5, {0x9e, 0xec, 0xb2, 0x3e, 0x3f, 0x50, 0x02, 0x9a} }
|
||||
|
||||
#define EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_GUID \
|
||||
{ 0x2f707ebb, 0x4a1a, 0x11d4, {0x9a, 0x38, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d} }
|
||||
|
||||
INTERFACE_DECL(_EFI_PCI_IO_PROTOCOL);
|
||||
INTERFACE_DECL(_EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL);
|
||||
|
||||
typedef enum {
|
||||
EfiPciIoWidthUint8,
|
||||
EfiPciIoWidthUint16,
|
||||
EfiPciIoWidthUint32,
|
||||
EfiPciIoWidthUint64,
|
||||
EfiPciIoWidthFifoUint8,
|
||||
EfiPciIoWidthFifoUint16,
|
||||
EfiPciIoWidthFifoUint32,
|
||||
EfiPciIoWidthFifoUint64,
|
||||
EfiPciIoWidthFillUint8,
|
||||
EfiPciIoWidthFillUint16,
|
||||
EfiPciIoWidthFillUint32,
|
||||
EfiPciIoWidthFillUint64,
|
||||
EfiPciIoWidthMaximum
|
||||
} EFI_PCI_IO_PROTOCOL_WIDTH, EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH;
|
||||
|
||||
#define EFI_PCI_IO_PASS_THROUGH_BAR 0xff
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_PCI_IO_PROTOCOL_POLL_IO_MEM) (
|
||||
IN struct _EFI_PCI_IO_PROTOCOL *This,
|
||||
IN EFI_PCI_IO_PROTOCOL_WIDTH Width,
|
||||
IN UINT8 BarIndex,
|
||||
IN UINT64 Offset,
|
||||
IN UINT64 Mask,
|
||||
IN UINT64 Value,
|
||||
IN UINT64 Delay,
|
||||
OUT UINT64 *Result
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_POLL_IO_MEM) (
|
||||
IN struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
|
||||
IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,
|
||||
IN UINT64 Address,
|
||||
IN UINT64 Mask,
|
||||
IN UINT64 Value,
|
||||
IN UINT64 Delay,
|
||||
OUT UINT64 *Result
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_PCI_IO_PROTOCOL_IO_MEM) (
|
||||
IN struct _EFI_PCI_IO_PROTOCOL *This,
|
||||
IN EFI_PCI_IO_PROTOCOL_WIDTH Width,
|
||||
IN UINT8 BarIndex,
|
||||
IN UINT64 Offset,
|
||||
IN UINTN Count,
|
||||
IN OUT VOID *Buffer
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_IO_MEM) (
|
||||
IN struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
|
||||
IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,
|
||||
IN UINT64 Address,
|
||||
IN UINTN Count,
|
||||
IN OUT VOID *Buffer
|
||||
);
|
||||
|
||||
typedef struct {
|
||||
EFI_PCI_IO_PROTOCOL_IO_MEM Read;
|
||||
EFI_PCI_IO_PROTOCOL_IO_MEM Write;
|
||||
} EFI_PCI_IO_PROTOCOL_ACCESS;
|
||||
|
||||
typedef struct {
|
||||
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_IO_MEM Read;
|
||||
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_IO_MEM Write;
|
||||
} EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ACCESS;
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_PCI_IO_PROTOCOL_CONFIG) (
|
||||
IN struct _EFI_PCI_IO_PROTOCOL *This,
|
||||
IN EFI_PCI_IO_PROTOCOL_WIDTH Width,
|
||||
IN UINT32 Offset,
|
||||
IN UINTN Count,
|
||||
IN OUT VOID *Buffer
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_CONFIGURATION) (
|
||||
IN struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
|
||||
OUT VOID **Resources
|
||||
);
|
||||
|
||||
typedef struct {
|
||||
EFI_PCI_IO_PROTOCOL_CONFIG Read;
|
||||
EFI_PCI_IO_PROTOCOL_CONFIG Write;
|
||||
} EFI_PCI_IO_PROTOCOL_CONFIG_ACCESS;
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_PCI_IO_PROTOCOL_COPY_MEM) (
|
||||
IN struct _EFI_PCI_IO_PROTOCOL *This,
|
||||
IN EFI_PCI_IO_PROTOCOL_WIDTH Width,
|
||||
IN UINT8 DestBarIndex,
|
||||
IN UINT64 DestOffset,
|
||||
IN UINT8 SrcBarIndex,
|
||||
IN UINT64 SrcOffset,
|
||||
IN UINTN Count
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_COPY_MEM) (
|
||||
IN struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
|
||||
IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,
|
||||
IN UINT64 DestAddress,
|
||||
IN UINT64 SrcAddress,
|
||||
IN UINTN Count
|
||||
);
|
||||
|
||||
typedef enum {
|
||||
EfiPciIoOperationBusMasterRead,
|
||||
EfiPciIoOperationBusMasterWrite,
|
||||
EfiPciIoOperationBusMasterCommonBuffer,
|
||||
EfiPciIoOperationMaximum
|
||||
} EFI_PCI_IO_PROTOCOL_OPERATION;
|
||||
|
||||
typedef enum {
|
||||
EfiPciOperationBusMasterRead,
|
||||
EfiPciOperationBusMasterWrite,
|
||||
EfiPciOperationBusMasterCommonBuffer,
|
||||
EfiPciOperationBusMasterRead64,
|
||||
EfiPciOperationBusMasterWrite64,
|
||||
EfiPciOperationBusMasterCommonBuffer64,
|
||||
EfiPciOperationMaximum
|
||||
} EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_OPERATION;
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_PCI_IO_PROTOCOL_MAP) (
|
||||
IN struct _EFI_PCI_IO_PROTOCOL *This,
|
||||
IN EFI_PCI_IO_PROTOCOL_OPERATION Operation,
|
||||
IN VOID *HostAddress,
|
||||
IN OUT UINTN *NumberOfBytes,
|
||||
OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,
|
||||
OUT VOID **Mapping
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_MAP) (
|
||||
IN struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
|
||||
IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_OPERATION Operation,
|
||||
IN VOID *HostAddress,
|
||||
IN OUT UINTN *NumberOfBytes,
|
||||
OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,
|
||||
OUT VOID **Mapping
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_PCI_IO_PROTOCOL_UNMAP) (
|
||||
IN struct _EFI_PCI_IO_PROTOCOL *This,
|
||||
IN VOID *Mapping
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_UNMAP) (
|
||||
IN struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
|
||||
IN VOID *Mapping
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_PCI_IO_PROTOCOL_ALLOCATE_BUFFER) (
|
||||
IN struct _EFI_PCI_IO_PROTOCOL *This,
|
||||
IN EFI_ALLOCATE_TYPE Type,
|
||||
IN EFI_MEMORY_TYPE MemoryType,
|
||||
IN UINTN Pages,
|
||||
OUT VOID **HostAddress,
|
||||
IN UINT64 Attributes
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ALLOCATE_BUFFER) (
|
||||
IN struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
|
||||
IN EFI_ALLOCATE_TYPE Type,
|
||||
IN EFI_MEMORY_TYPE MemoryType,
|
||||
IN UINTN Pages,
|
||||
IN OUT VOID **HostAddress,
|
||||
IN UINT64 Attributes
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_PCI_IO_PROTOCOL_FREE_BUFFER) (
|
||||
IN struct _EFI_PCI_IO_PROTOCOL *This,
|
||||
IN UINTN Pages,
|
||||
IN VOID *HostAddress
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_FREE_BUFFER) (
|
||||
IN struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
|
||||
IN UINTN Pages,
|
||||
IN VOID *HostAddress
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_PCI_IO_PROTOCOL_FLUSH) (
|
||||
IN struct _EFI_PCI_IO_PROTOCOL *This
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_FLUSH) (
|
||||
IN struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_PCI_IO_PROTOCOL_GET_LOCATION) (
|
||||
IN struct _EFI_PCI_IO_PROTOCOL *This,
|
||||
OUT UINTN *SegmentNumber,
|
||||
OUT UINTN *BusNumber,
|
||||
OUT UINTN *DeviceNumber,
|
||||
OUT UINTN *FunctionNumber
|
||||
);
|
||||
|
||||
#define EFI_PCI_ATTRIBUTE_ISA_MOTHERBOARD_IO 0x0001
|
||||
#define EFI_PCI_ATTRIBUTE_ISA_IO 0x0002
|
||||
#define EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO 0x0004
|
||||
#define EFI_PCI_ATTRIBUTE_VGA_MEMORY 0x0008
|
||||
#define EFI_PCI_ATTRIBUTE_VGA_IO 0x0010
|
||||
#define EFI_PCI_ATTRIBUTE_IDE_PRIMARY_IO 0x0020
|
||||
#define EFI_PCI_ATTRIBUTE_IDE_SECONDARY_IO 0x0040
|
||||
#define EFI_PCI_ATTRIBUTE_MEMORY_WRITE_COMBINE 0x0080
|
||||
#define EFI_PCI_ATTRIBUTE_IO 0x0100
|
||||
#define EFI_PCI_ATTRIBUTE_MEMORY 0x0200
|
||||
#define EFI_PCI_ATTRIBUTE_BUS_MASTER 0x0400
|
||||
#define EFI_PCI_ATTRIBUTE_MEMORY_CACHED 0x0800
|
||||
#define EFI_PCI_ATTRIBUTE_MEMORY_DISABLE 0x1000
|
||||
#define EFI_PCI_ATTRIBUTE_EMBEDDED_DEVICE 0x2000
|
||||
#define EFI_PCI_ATTRIBUTE_EMBEDDED_ROM 0x4000
|
||||
#define EFI_PCI_ATTRIBUTE_DUAL_ADDRESS_CYCLE 0x8000
|
||||
#define EFI_PCI_ATTRIBUTE_ISA_IO_16 0x10000
|
||||
#define EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO_16 0x20000
|
||||
#define EFI_PCI_ATTRIBUTE_VGA_IO_16 0x40000
|
||||
|
||||
#define EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO EFI_PCI_ATTRIBUTE_ISA_MOTHERBOARD_IO
|
||||
#define EFI_PCI_IO_ATTRIBUTE_ISA_IO EFI_PCI_ATTRIBUTE_ISA_IO
|
||||
#define EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO
|
||||
#define EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY EFI_PCI_ATTRIBUTE_VGA_MEMORY
|
||||
#define EFI_PCI_IO_ATTRIBUTE_VGA_IO EFI_PCI_ATTRIBUTE_VGA_IO
|
||||
#define EFI_PCI_IO_ATTRIBUTE_IDE_PRIMARY_IO EFI_PCI_ATTRIBUTE_IDE_PRIMARY_IO
|
||||
#define EFI_PCI_IO_ATTRIBUTE_IDE_SECONDARY_IO EFI_PCI_ATTRIBUTE_IDE_SECONDARY_IO
|
||||
#define EFI_PCI_IO_ATTRIBUTE_MEMORY_WRITE_COMBINE EFI_PCI_ATTRIBUTE_MEMORY_WRITE_COMBINE
|
||||
#define EFI_PCI_IO_ATTRIBUTE_IO EFI_PCI_ATTRIBUTE_IO
|
||||
#define EFI_PCI_IO_ATTRIBUTE_MEMORY EFI_PCI_ATTRIBUTE_MEMORY
|
||||
#define EFI_PCI_IO_ATTRIBUTE_BUS_MASTER EFI_PCI_ATTRIBUTE_BUS_MASTER
|
||||
#define EFI_PCI_IO_ATTRIBUTE_MEMORY_CACHED EFI_PCI_ATTRIBUTE_MEMORY_CACHED
|
||||
#define EFI_PCI_IO_ATTRIBUTE_MEMORY_DISABLE EFI_PCI_ATTRIBUTE_MEMORY_DISABLE
|
||||
#define EFI_PCI_IO_ATTRIBUTE_EMBEDDED_DEVICE EFI_PCI_ATTRIBUTE_EMBEDDED_DEVICE
|
||||
#define EFI_PCI_IO_ATTRIBUTE_EMBEDDED_ROM EFI_PCI_ATTRIBUTE_EMBEDDED_ROM
|
||||
#define EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE EFI_PCI_ATTRIBUTE_DUAL_ADDRESS_CYCLE
|
||||
#define EFI_PCI_IO_ATTRIBUTE_ISA_IO_16 EFI_PCI_ATTRIBUTE_ISA_IO_16
|
||||
#define EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO_16 EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO_16
|
||||
#define EFI_PCI_IO_ATTRIBUTE_VGA_IO_16 EFI_PCI_ATTRIBUTE_VGA_IO_16
|
||||
|
||||
#define EFI_PCI_ATTRIBUTE_VALID_FOR_ALLOCATE_BUFFER \
|
||||
(EFI_PCI_ATTRIBUTE_MEMORY_WRITE_COMBINE | EFI_PCI_ATTRIBUTE_MEMORY_CACHED | EFI_PCI_ATTRIBUTE_DUAL_ADDRESS_CYCLE)
|
||||
|
||||
#define EFI_PCI_ATTRIBUTE_INVALID_FOR_ALLOCATE_BUFFER \
|
||||
(~EFI_PCI_ATTRIBUTE_VALID_FOR_ALLOCATE_BUFFER)
|
||||
|
||||
typedef struct {
|
||||
UINT8 Register;
|
||||
UINT8 Function;
|
||||
UINT8 Device;
|
||||
UINT8 Bus;
|
||||
UINT32 ExtendedRegister;
|
||||
} EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS;
|
||||
|
||||
typedef enum {
|
||||
EfiPciIoAttributeOperationGet,
|
||||
EfiPciIoAttributeOperationSet,
|
||||
EfiPciIoAttributeOperationEnable,
|
||||
EfiPciIoAttributeOperationDisable,
|
||||
EfiPciIoAttributeOperationSupported,
|
||||
EfiPciIoAttributeOperationMaximum
|
||||
} EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION;
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_PCI_IO_PROTOCOL_ATTRIBUTES) (
|
||||
IN struct _EFI_PCI_IO_PROTOCOL *This,
|
||||
IN EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION Operation,
|
||||
IN UINT64 Attributes,
|
||||
OUT UINT64 *Result OPTIONAL
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_PCI_IO_PROTOCOL_GET_BAR_ATTRIBUTES) (
|
||||
IN struct _EFI_PCI_IO_PROTOCOL *This,
|
||||
IN UINT8 BarIndex,
|
||||
OUT UINT64 *Supports OPTIONAL,
|
||||
OUT VOID **Resources OPTIONAL
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_GET_ATTRIBUTES) (
|
||||
IN struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
|
||||
OUT UINT64 *Supports,
|
||||
OUT UINT64 *Attributes
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_PCI_IO_PROTOCOL_SET_BAR_ATTRIBUTES) (
|
||||
IN struct _EFI_PCI_IO_PROTOCOL *This,
|
||||
IN UINT64 Attributes,
|
||||
IN UINT8 BarIndex,
|
||||
IN OUT UINT64 *Offset,
|
||||
IN OUT UINT64 *Length
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_SET_ATTRIBUTES) (
|
||||
IN struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
|
||||
IN UINT64 Attributes,
|
||||
IN OUT UINT64 *ResourceBase,
|
||||
IN OUT UINT64 *ResourceLength
|
||||
);
|
||||
|
||||
typedef struct _EFI_PCI_IO_PROTOCOL {
|
||||
EFI_PCI_IO_PROTOCOL_POLL_IO_MEM PollMem;
|
||||
EFI_PCI_IO_PROTOCOL_POLL_IO_MEM PollIo;
|
||||
EFI_PCI_IO_PROTOCOL_ACCESS Mem;
|
||||
EFI_PCI_IO_PROTOCOL_ACCESS Io;
|
||||
EFI_PCI_IO_PROTOCOL_CONFIG_ACCESS Pci;
|
||||
EFI_PCI_IO_PROTOCOL_COPY_MEM CopyMem;
|
||||
EFI_PCI_IO_PROTOCOL_MAP Map;
|
||||
EFI_PCI_IO_PROTOCOL_UNMAP Unmap;
|
||||
EFI_PCI_IO_PROTOCOL_ALLOCATE_BUFFER AllocateBuffer;
|
||||
EFI_PCI_IO_PROTOCOL_FREE_BUFFER FreeBuffer;
|
||||
EFI_PCI_IO_PROTOCOL_FLUSH Flush;
|
||||
EFI_PCI_IO_PROTOCOL_GET_LOCATION GetLocation;
|
||||
EFI_PCI_IO_PROTOCOL_ATTRIBUTES Attributes;
|
||||
EFI_PCI_IO_PROTOCOL_GET_BAR_ATTRIBUTES GetBarAttributes;
|
||||
EFI_PCI_IO_PROTOCOL_SET_BAR_ATTRIBUTES SetBarAttributes;
|
||||
UINT64 RomSize;
|
||||
VOID *RomImage;
|
||||
} EFI_PCI_IO_PROTOCOL;
|
||||
|
||||
// Note: Because it conflicted with the EDK2 struct name, the
|
||||
// 'EFI_PCI_IO_PROTOCOL' GUID definition, from older versions
|
||||
// of gnu-efi, is now obsoleted.
|
||||
// Use 'EFI_PCI_IO_PROTOCOL_GUID' instead.
|
||||
|
||||
typedef struct _EFI_PCI_IO_PROTOCOL _EFI_PCI_IO;
|
||||
typedef EFI_PCI_IO_PROTOCOL EFI_PCI_IO;
|
||||
|
||||
typedef struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL {
|
||||
EFI_HANDLE ParentHandle;
|
||||
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_POLL_IO_MEM PollMem;
|
||||
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_POLL_IO_MEM PollIo;
|
||||
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ACCESS Mem;
|
||||
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ACCESS Io;
|
||||
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ACCESS Pci;
|
||||
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_COPY_MEM CopyMem;
|
||||
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_MAP Map;
|
||||
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_UNMAP Unmap;
|
||||
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ALLOCATE_BUFFER AllocateBuffer;
|
||||
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_FREE_BUFFER FreeBuffer;
|
||||
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_FLUSH Flush;
|
||||
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_GET_ATTRIBUTES GetAttributes;
|
||||
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_SET_ATTRIBUTES SetAttributes;
|
||||
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_CONFIGURATION Configuration;
|
||||
UINT32 SegmentNumber;
|
||||
} EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL;
|
||||
|
||||
#endif /* _EFI_PCI_IO_H */
|
1425
dxe/efi/efiprot.h
Normal file
1425
dxe/efi/efiprot.h
Normal file
File diff suppressed because it is too large
Load Diff
390
dxe/efi/x86_64/efibind.h
Normal file
390
dxe/efi/x86_64/efibind.h
Normal file
@ -0,0 +1,390 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
efefind.h
|
||||
|
||||
Abstract:
|
||||
|
||||
EFI to compile bindings
|
||||
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
#ifndef X86_64_EFI_BIND
|
||||
#define X86_64_EFI_BIND
|
||||
#ifndef __GNUC__
|
||||
#pragma pack()
|
||||
#endif
|
||||
|
||||
#if defined(GNU_EFI_USE_MS_ABI)
|
||||
#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7))
|
||||
#define HAVE_USE_MS_ABI 1
|
||||
#else
|
||||
#error Compiler is too old for GNU_EFI_USE_MS_ABI
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//
|
||||
// Basic int types of various widths
|
||||
//
|
||||
|
||||
#if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L )
|
||||
|
||||
// No ANSI C 1999/2000 stdint.h integer width declarations
|
||||
|
||||
#if defined(_MSC_EXTENSIONS)
|
||||
|
||||
// Use Microsoft C compiler integer width declarations
|
||||
|
||||
typedef unsigned __int64 uint64_t;
|
||||
typedef __int64 int64_t;
|
||||
typedef unsigned __int32 uint32_t;
|
||||
typedef __int32 int32_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef short int16_t;
|
||||
typedef unsigned char uint8_t;
|
||||
typedef char int8_t;
|
||||
#elif defined(__GNUC__)
|
||||
typedef int __attribute__((__mode__(__DI__))) int64_t;
|
||||
typedef unsigned int __attribute__((__mode__(__DI__))) uint64_t;
|
||||
typedef unsigned int uint32_t;
|
||||
typedef int int32_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef short int16_t;
|
||||
typedef unsigned char uint8_t;
|
||||
typedef signed char int8_t;
|
||||
#elif defined(UNIX_LP64)
|
||||
|
||||
/* Use LP64 programming model from C_FLAGS for integer width declarations */
|
||||
|
||||
typedef unsigned long uint64_t;
|
||||
typedef long int64_t;
|
||||
typedef unsigned int uint32_t;
|
||||
typedef int int32_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef short int16_t;
|
||||
typedef unsigned char uint8_t;
|
||||
typedef char int8_t;
|
||||
#else
|
||||
|
||||
/* Assume P64 programming model from C_FLAGS for integer width declarations */
|
||||
|
||||
typedef unsigned long long uint64_t __attribute__((aligned (8)));
|
||||
typedef long long int64_t __attribute__((aligned (8)));
|
||||
typedef unsigned int uint32_t;
|
||||
typedef int int32_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef short int16_t;
|
||||
typedef unsigned char uint8_t;
|
||||
typedef char int8_t;
|
||||
#endif
|
||||
#elif defined(__GNUC__)
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
//
|
||||
// Basic EFI types of various widths
|
||||
//
|
||||
|
||||
#ifndef __WCHAR_TYPE__
|
||||
# define __WCHAR_TYPE__ short
|
||||
#endif
|
||||
|
||||
typedef uint64_t UINT64;
|
||||
typedef int64_t INT64;
|
||||
|
||||
#ifndef _BASETSD_H_
|
||||
typedef uint32_t UINT32;
|
||||
typedef int32_t INT32;
|
||||
#endif
|
||||
|
||||
typedef uint16_t UINT16;
|
||||
typedef int16_t INT16;
|
||||
typedef uint8_t UINT8;
|
||||
typedef int8_t INT8;
|
||||
typedef __WCHAR_TYPE__ WCHAR;
|
||||
|
||||
#undef VOID
|
||||
#define VOID void
|
||||
|
||||
|
||||
typedef int64_t INTN;
|
||||
typedef uint64_t UINTN;
|
||||
|
||||
#ifdef EFI_NT_EMULATOR
|
||||
#define POST_CODE(_Data)
|
||||
#else
|
||||
#ifdef EFI_DEBUG
|
||||
#define POST_CODE(_Data) __asm mov eax,(_Data) __asm out 0x80,al
|
||||
#else
|
||||
#define POST_CODE(_Data)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define EFIERR(a) (0x8000000000000000 | a)
|
||||
#define EFI_ERROR_MASK 0x8000000000000000
|
||||
#define EFIERR_OEM(a) (0xc000000000000000 | a)
|
||||
|
||||
|
||||
#define BAD_POINTER 0xFBFBFBFBFBFBFBFB
|
||||
#define MAX_ADDRESS 0xFFFFFFFFFFFFFFFF
|
||||
|
||||
#ifdef EFI_NT_EMULATOR
|
||||
#define BREAKPOINT() __asm { int 3 }
|
||||
#else
|
||||
#define BREAKPOINT() while (TRUE); // Make it hang on Bios[Dbg]32
|
||||
#endif
|
||||
|
||||
//
|
||||
// Pointers must be aligned to these address to function
|
||||
//
|
||||
|
||||
#define MIN_ALIGNMENT_SIZE 4
|
||||
|
||||
#define ALIGN_VARIABLE(Value ,Adjustment) \
|
||||
(UINTN)Adjustment = 0; \
|
||||
if((UINTN)Value % MIN_ALIGNMENT_SIZE) \
|
||||
(UINTN)Adjustment = MIN_ALIGNMENT_SIZE - ((UINTN)Value % MIN_ALIGNMENT_SIZE); \
|
||||
Value = (UINTN)Value + (UINTN)Adjustment
|
||||
|
||||
|
||||
//
|
||||
// Define macros to build data structure signatures from characters.
|
||||
//
|
||||
|
||||
#define EFI_SIGNATURE_16(A,B) ((A) | (B<<8))
|
||||
#define EFI_SIGNATURE_32(A,B,C,D) (EFI_SIGNATURE_16(A,B) | (EFI_SIGNATURE_16(C,D) << 16))
|
||||
#define EFI_SIGNATURE_64(A,B,C,D,E,F,G,H) (EFI_SIGNATURE_32(A,B,C,D) | ((UINT64)(EFI_SIGNATURE_32(E,F,G,H)) << 32))
|
||||
//
|
||||
// To export & import functions in the EFI emulator environment
|
||||
//
|
||||
|
||||
#ifdef EFI_NT_EMULATOR
|
||||
#define EXPORTAPI __declspec( dllexport )
|
||||
#else
|
||||
#define EXPORTAPI
|
||||
#endif
|
||||
|
||||
|
||||
//
|
||||
// EFIAPI - prototype calling convention for EFI function pointers
|
||||
// BOOTSERVICE - prototype for implementation of a boot service interface
|
||||
// RUNTIMESERVICE - prototype for implementation of a runtime service interface
|
||||
// RUNTIMEFUNCTION - prototype for implementation of a runtime function that is not a service
|
||||
// RUNTIME_CODE - pragma macro for declaring runtime code
|
||||
//
|
||||
|
||||
#ifndef EFIAPI // Forces EFI calling conventions reguardless of compiler options
|
||||
#ifdef _MSC_EXTENSIONS
|
||||
#define EFIAPI __cdecl // Force C calling convention for Microsoft C compiler
|
||||
#elif defined(HAVE_USE_MS_ABI)
|
||||
// Force amd64/ms calling conventions.
|
||||
#define EFIAPI __attribute__((ms_abi))
|
||||
#else
|
||||
#define EFIAPI // Substitute expresion to force C calling convention
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define BOOTSERVICE
|
||||
//#define RUNTIMESERVICE(proto,a) alloc_text("rtcode",a); proto a
|
||||
//#define RUNTIMEFUNCTION(proto,a) alloc_text("rtcode",a); proto a
|
||||
#define RUNTIMESERVICE
|
||||
#define RUNTIMEFUNCTION
|
||||
|
||||
|
||||
#define RUNTIME_CODE(a) alloc_text("rtcode", a)
|
||||
#define BEGIN_RUNTIME_DATA() data_seg("rtdata")
|
||||
#define END_RUNTIME_DATA() data_seg("")
|
||||
|
||||
#define VOLATILE volatile
|
||||
|
||||
#define MEMORY_FENCE()
|
||||
|
||||
#ifdef EFI_NT_EMULATOR
|
||||
|
||||
//
|
||||
// To help ensure proper coding of integrated drivers, they are
|
||||
// compiled as DLLs. In NT they require a dll init entry pointer.
|
||||
// The macro puts a stub entry point into the DLL so it will load.
|
||||
//
|
||||
|
||||
#define EFI_DRIVER_ENTRY_POINT(InitFunction) \
|
||||
UINTN \
|
||||
__stdcall \
|
||||
_DllMainCRTStartup ( \
|
||||
UINTN Inst, \
|
||||
UINTN reason_for_call, \
|
||||
VOID *rserved \
|
||||
) \
|
||||
{ \
|
||||
return 1; \
|
||||
} \
|
||||
\
|
||||
int \
|
||||
EXPORTAPI \
|
||||
__cdecl \
|
||||
InitializeDriver ( \
|
||||
void *ImageHandle, \
|
||||
void *SystemTable \
|
||||
) \
|
||||
{ \
|
||||
return InitFunction(ImageHandle, SystemTable); \
|
||||
}
|
||||
|
||||
|
||||
#define LOAD_INTERNAL_DRIVER(_if, type, name, entry) \
|
||||
(_if)->LoadInternal(type, name, NULL)
|
||||
|
||||
#else // EFI_NT_EMULATOR
|
||||
|
||||
//
|
||||
// When build similiar to FW, then link everything together as
|
||||
// one big module. For the MSVC toolchain, we simply tell the
|
||||
// linker what our driver init function is using /ENTRY.
|
||||
//
|
||||
#if defined(_MSC_EXTENSIONS)
|
||||
#define EFI_DRIVER_ENTRY_POINT(InitFunction) \
|
||||
__pragma(comment(linker, "/ENTRY:" # InitFunction))
|
||||
#else
|
||||
#define EFI_DRIVER_ENTRY_POINT(InitFunction) \
|
||||
UINTN \
|
||||
InitializeDriver ( \
|
||||
VOID *ImageHandle, \
|
||||
VOID *SystemTable \
|
||||
) \
|
||||
{ \
|
||||
return InitFunction(ImageHandle, \
|
||||
SystemTable); \
|
||||
} \
|
||||
\
|
||||
EFI_STATUS efi_main( \
|
||||
EFI_HANDLE image, \
|
||||
EFI_SYSTEM_TABLE *systab \
|
||||
) __attribute__((weak, \
|
||||
alias ("InitializeDriver")));
|
||||
#endif
|
||||
|
||||
#define LOAD_INTERNAL_DRIVER(_if, type, name, entry) \
|
||||
(_if)->LoadInternal(type, name, entry)
|
||||
|
||||
#endif // EFI_NT_EMULATOR
|
||||
|
||||
//
|
||||
// Some compilers don't support the forward reference construct:
|
||||
// typedef struct XXXXX
|
||||
//
|
||||
// The following macro provide a workaround for such cases.
|
||||
//
|
||||
#ifdef NO_INTERFACE_DECL
|
||||
#define INTERFACE_DECL(x)
|
||||
#else
|
||||
#if defined(__GNUC__) || defined(_MSC_EXTENSIONS)
|
||||
#define INTERFACE_DECL(x) struct x
|
||||
#else
|
||||
#define INTERFACE_DECL(x) typedef struct x
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* for x86_64, EFI_FUNCTION_WRAPPER must be defined */
|
||||
#if defined(HAVE_USE_MS_ABI)
|
||||
#define uefi_call_wrapper(func, va_num, ...) func(__VA_ARGS__)
|
||||
#else
|
||||
/*
|
||||
Credits for macro-magic:
|
||||
https://groups.google.com/forum/?fromgroups#!topic/comp.std.c/d-6Mj5Lko_s
|
||||
http://efesx.com/2010/08/31/overloading-macros/
|
||||
*/
|
||||
#define __VA_NARG__(...) \
|
||||
__VA_NARG_(_0, ## __VA_ARGS__, __RSEQ_N())
|
||||
#define __VA_NARG_(...) \
|
||||
__VA_ARG_N(__VA_ARGS__)
|
||||
#define __VA_ARG_N( \
|
||||
_0,_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,N,...) N
|
||||
#define __RSEQ_N() \
|
||||
10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0
|
||||
|
||||
#define __VA_ARG_NSUFFIX__(prefix,...) \
|
||||
__VA_ARG_NSUFFIX_N(prefix, __VA_NARG__(__VA_ARGS__))
|
||||
#define __VA_ARG_NSUFFIX_N(prefix,nargs) \
|
||||
__VA_ARG_NSUFFIX_N_(prefix, nargs)
|
||||
#define __VA_ARG_NSUFFIX_N_(prefix,nargs) \
|
||||
prefix ## nargs
|
||||
|
||||
/* Prototypes of EFI cdecl -> stdcall trampolines */
|
||||
UINT64 efi_call0(void *func);
|
||||
UINT64 efi_call1(void *func, UINT64 arg1);
|
||||
UINT64 efi_call2(void *func, UINT64 arg1, UINT64 arg2);
|
||||
UINT64 efi_call3(void *func, UINT64 arg1, UINT64 arg2, UINT64 arg3);
|
||||
UINT64 efi_call4(void *func, UINT64 arg1, UINT64 arg2, UINT64 arg3,
|
||||
UINT64 arg4);
|
||||
UINT64 efi_call5(void *func, UINT64 arg1, UINT64 arg2, UINT64 arg3,
|
||||
UINT64 arg4, UINT64 arg5);
|
||||
UINT64 efi_call6(void *func, UINT64 arg1, UINT64 arg2, UINT64 arg3,
|
||||
UINT64 arg4, UINT64 arg5, UINT64 arg6);
|
||||
UINT64 efi_call7(void *func, UINT64 arg1, UINT64 arg2, UINT64 arg3,
|
||||
UINT64 arg4, UINT64 arg5, UINT64 arg6, UINT64 arg7);
|
||||
UINT64 efi_call8(void *func, UINT64 arg1, UINT64 arg2, UINT64 arg3,
|
||||
UINT64 arg4, UINT64 arg5, UINT64 arg6, UINT64 arg7,
|
||||
UINT64 arg8);
|
||||
UINT64 efi_call9(void *func, UINT64 arg1, UINT64 arg2, UINT64 arg3,
|
||||
UINT64 arg4, UINT64 arg5, UINT64 arg6, UINT64 arg7,
|
||||
UINT64 arg8, UINT64 arg9);
|
||||
UINT64 efi_call10(void *func, UINT64 arg1, UINT64 arg2, UINT64 arg3,
|
||||
UINT64 arg4, UINT64 arg5, UINT64 arg6, UINT64 arg7,
|
||||
UINT64 arg8, UINT64 arg9, UINT64 arg10);
|
||||
|
||||
/* Front-ends to efi_callX to avoid compiler warnings */
|
||||
#define _cast64_efi_call0(f) \
|
||||
efi_call0(f)
|
||||
#define _cast64_efi_call1(f,a1) \
|
||||
efi_call1(f, (UINT64)(a1))
|
||||
#define _cast64_efi_call2(f,a1,a2) \
|
||||
efi_call2(f, (UINT64)(a1), (UINT64)(a2))
|
||||
#define _cast64_efi_call3(f,a1,a2,a3) \
|
||||
efi_call3(f, (UINT64)(a1), (UINT64)(a2), (UINT64)(a3))
|
||||
#define _cast64_efi_call4(f,a1,a2,a3,a4) \
|
||||
efi_call4(f, (UINT64)(a1), (UINT64)(a2), (UINT64)(a3), (UINT64)(a4))
|
||||
#define _cast64_efi_call5(f,a1,a2,a3,a4,a5) \
|
||||
efi_call5(f, (UINT64)(a1), (UINT64)(a2), (UINT64)(a3), (UINT64)(a4), \
|
||||
(UINT64)(a5))
|
||||
#define _cast64_efi_call6(f,a1,a2,a3,a4,a5,a6) \
|
||||
efi_call6(f, (UINT64)(a1), (UINT64)(a2), (UINT64)(a3), (UINT64)(a4), \
|
||||
(UINT64)(a5), (UINT64)(a6))
|
||||
#define _cast64_efi_call7(f,a1,a2,a3,a4,a5,a6,a7) \
|
||||
efi_call7(f, (UINT64)(a1), (UINT64)(a2), (UINT64)(a3), (UINT64)(a4), \
|
||||
(UINT64)(a5), (UINT64)(a6), (UINT64)(a7))
|
||||
#define _cast64_efi_call8(f,a1,a2,a3,a4,a5,a6,a7,a8) \
|
||||
efi_call8(f, (UINT64)(a1), (UINT64)(a2), (UINT64)(a3), (UINT64)(a4), \
|
||||
(UINT64)(a5), (UINT64)(a6), (UINT64)(a7), (UINT64)(a8))
|
||||
#define _cast64_efi_call9(f,a1,a2,a3,a4,a5,a6,a7,a8,a9) \
|
||||
efi_call9(f, (UINT64)(a1), (UINT64)(a2), (UINT64)(a3), (UINT64)(a4), \
|
||||
(UINT64)(a5), (UINT64)(a6), (UINT64)(a7), (UINT64)(a8), \
|
||||
(UINT64)(a9))
|
||||
#define _cast64_efi_call10(f,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) \
|
||||
efi_call10(f, (UINT64)(a1), (UINT64)(a2), (UINT64)(a3), (UINT64)(a4), \
|
||||
(UINT64)(a5), (UINT64)(a6), (UINT64)(a7), (UINT64)(a8), \
|
||||
(UINT64)(a9), (UINT64)(a10))
|
||||
|
||||
/* main wrapper (va_num ignored) */
|
||||
#define uefi_call_wrapper(func,va_num,...) \
|
||||
__VA_ARG_NSUFFIX__(_cast64_efi_call, __VA_ARGS__) (func , ##__VA_ARGS__)
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_USE_MS_ABI) && !defined(_MSC_EXTENSIONS)
|
||||
#define EFI_FUNCTION __attribute__((ms_abi))
|
||||
#else
|
||||
#define EFI_FUNCTION
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_EXTENSIONS
|
||||
#pragma warning ( disable : 4731 ) // Suppress warnings about modification of EBP
|
||||
#endif
|
||||
|
||||
#endif
|
53
dxe/efidxe.h
Normal file
53
dxe/efidxe.h
Normal file
@ -0,0 +1,53 @@
|
||||
#ifndef __efi_h__
|
||||
#define __efi_h__
|
||||
|
||||
typedef struct {
|
||||
EFI_TABLE_HEADER Hdr;
|
||||
void* AddMemorySpace;
|
||||
void* AllocateMemorySpace;
|
||||
void* FreeMemorySpace;
|
||||
void* RemoveMemorySpace;
|
||||
void* GetMemorySpaceDescriptor;
|
||||
void* SetMemorySpaceAttributes;
|
||||
void* GetMemorySpaceMap;
|
||||
void* AddIoSpace;
|
||||
void* AllocateIoSpace;
|
||||
void* FreeIoSpace;
|
||||
void* RemoveIoSpace;
|
||||
void* GetIoSpaceDescriptor;
|
||||
void* GetIoSpaceMap;
|
||||
EFI_STATUS EFIAPI (*Dispatch)(void);
|
||||
void* Schedule;
|
||||
void* Trust;
|
||||
EFI_STATUS EFIAPI (*ProcessFirmwareVolume)(
|
||||
void * buffer,
|
||||
unsigned len,
|
||||
EFI_HANDLE * handle_out
|
||||
);
|
||||
} EFI_DXE_SERVICES;
|
||||
|
||||
|
||||
static inline void *
|
||||
efi_find_table(
|
||||
EFI_SYSTEM_TABLE * st,
|
||||
uint32_t search_guid
|
||||
)
|
||||
{
|
||||
const EFI_CONFIGURATION_TABLE * ct = st->ConfigurationTable;
|
||||
|
||||
serial_string("num tables=");
|
||||
serial_hex(st->NumberOfTableEntries, 4);
|
||||
|
||||
for(unsigned i = 0 ; i < st->NumberOfTableEntries ; i++)
|
||||
{
|
||||
const EFI_GUID * guid = &ct[i].VendorGuid;
|
||||
serial_hex(*(uint64_t*)guid, 16);
|
||||
if (guid->Data1 == search_guid)
|
||||
return ct[i].VendorTable;
|
||||
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif
|
117
dxe/efifv.c
Normal file
117
dxe/efifv.c
Normal file
@ -0,0 +1,117 @@
|
||||
#include "efifv.h"
|
||||
#include "serial.h"
|
||||
|
||||
/*
|
||||
* Locate a firmware file based on the GUID
|
||||
*/
|
||||
static EFI_FIRMWARE_VOLUME2_PROTOCOL *
|
||||
find_ffs(
|
||||
EFI_BOOT_SERVICES * gBS,
|
||||
EFI_GUID * guid
|
||||
)
|
||||
{
|
||||
EFI_STATUS status;
|
||||
EFI_HANDLE * handles = NULL;
|
||||
UINTN handle_count;
|
||||
EFI_GUID fv_proto = EFI_FIRMWARE_VOLUME2_PROTOCOL_GUID;
|
||||
|
||||
status = gBS->LocateHandleBuffer(
|
||||
ByProtocol,
|
||||
&fv_proto,
|
||||
NULL,
|
||||
&handle_count,
|
||||
&handles
|
||||
);
|
||||
|
||||
if (status != 0)
|
||||
{
|
||||
serial_string("LinuxBoot: locate_handle rc=");
|
||||
serial_hex(status, 8);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for(unsigned i = 0 ; i < handle_count ; i++)
|
||||
{
|
||||
EFI_FIRMWARE_VOLUME2_PROTOCOL * fv = NULL;
|
||||
|
||||
//serial_string("handle=");
|
||||
//serial_hex((unsigned long) handles[i], 16);
|
||||
|
||||
status = gBS->HandleProtocol(
|
||||
handles[i],
|
||||
&fv_proto,
|
||||
(void**) &fv
|
||||
);
|
||||
|
||||
if (status != 0)
|
||||
{
|
||||
serial_string("handle proto rc=");
|
||||
serial_hex(status, 8);
|
||||
continue;
|
||||
}
|
||||
|
||||
UINTN size;
|
||||
UINT32 auth_status;
|
||||
EFI_FV_FILETYPE type;
|
||||
EFI_FV_FILE_ATTRIBUTES attributes;
|
||||
|
||||
status = fv->ReadFile(
|
||||
fv,
|
||||
guid,
|
||||
NULL,
|
||||
&size,
|
||||
&type,
|
||||
&attributes,
|
||||
&auth_status
|
||||
);
|
||||
if (status != EFI_SUCCESS)
|
||||
continue;
|
||||
|
||||
//serial_string("LinuxBoot: fv=");
|
||||
//serial_hex((unsigned long) fv, 16);
|
||||
|
||||
return fv;
|
||||
}
|
||||
|
||||
// this leaks the handle buffer.
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
read_ffs(
|
||||
EFI_BOOT_SERVICES * gBS,
|
||||
EFI_GUID * guid,
|
||||
void ** buffer,
|
||||
UINTN * size,
|
||||
EFI_SECTION_TYPE section_type
|
||||
)
|
||||
{
|
||||
EFI_FIRMWARE_VOLUME2_PROTOCOL * fv = find_ffs(gBS, guid);
|
||||
if (!fv)
|
||||
return -1;
|
||||
|
||||
UINT32 auth_status;
|
||||
EFI_STATUS status = fv->ReadSection(
|
||||
fv,
|
||||
guid,
|
||||
section_type,
|
||||
0,
|
||||
buffer,
|
||||
size,
|
||||
&auth_status
|
||||
);
|
||||
if (status != 0)
|
||||
{
|
||||
serial_string("LinuxBoot: read section rc=");
|
||||
serial_hex(status, 8);
|
||||
return -1;
|
||||
}
|
||||
|
||||
serial_string("LinuxBoot: FFS buffer=");
|
||||
serial_hex((unsigned long) *buffer, 16);
|
||||
serial_string("LinuxBoot: FFS length=");
|
||||
serial_hex(*size, 8);
|
||||
|
||||
return 0;
|
||||
}
|
91
dxe/efifv.h
Normal file
91
dxe/efifv.h
Normal file
@ -0,0 +1,91 @@
|
||||
/**
|
||||
* \file
|
||||
* EFI Firmware Volume protocol.
|
||||
*
|
||||
*/
|
||||
#ifndef _efi_fv_h_
|
||||
#define _efi_fv_h_
|
||||
|
||||
#include <efi/efi.h>
|
||||
|
||||
#define EFI_FIRMWARE_VOLUME2_PROTOCOL_GUID ((EFI_GUID){ 0x220e73b6, 0x6bdb, 0x4413, { 0x84, 0x05, 0xb9, 0x74, 0xb1, 0x08, 0x61, 0x9a } })
|
||||
|
||||
typedef UINT8 EFI_FV_FILETYPE;
|
||||
#define EFI_FV_FILETYPE_RAW 0x01
|
||||
#define EFI_FV_FILETYPE_FREEFORM 0x02
|
||||
#define EFI_FV_FILETYPE_SECURITY_CORE 0x03
|
||||
#define EFI_FV_FILETYPE_PEI_CORE 0x04
|
||||
#define EFI_FV_FILETYPE_DXE_CORE 0x05
|
||||
#define EFI_FV_FILETYPE_PEIM 0x06
|
||||
#define EFI_FV_FILETYPE_DRIVER 0x07
|
||||
#define EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER 0x08
|
||||
#define EFI_FV_FILETYPE_APPLICATION 0x09
|
||||
#define EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE 0x0b
|
||||
#define EFI_FV_FILETYPE_FFS_PAD 0xf0
|
||||
|
||||
typedef UINT32 EFI_FV_FILE_ATTRIBUTES;
|
||||
#define EFI_FV_FILE_ATTRIB_ALIGNMENT 0x0000001F
|
||||
|
||||
typedef UINT8 EFI_SECTION_TYPE;
|
||||
#define EFI_SECTION_ALL 0x00
|
||||
#define EFI_SECTION_COMPRESSION 0x01
|
||||
#define EFI_SECTION_GUID_DEFINED 0x02
|
||||
#define EFI_SECTION_DISPOSABLE 0x03
|
||||
#define EFI_SECTION_PE32 0x10
|
||||
#define EFI_SECTION_PIC 0x11
|
||||
#define EFI_SECTION_DXE_DEPEX 0x13
|
||||
#define EFI_SECTION_COMPATIBILITY16 0x16
|
||||
#define EFI_SECTION_FIRMWARE_VOLUME_IMAGE 0x17
|
||||
#define EFI_SECTION_FREEFORM_SUBTYPE_GUID 0x18
|
||||
#define EFI_SECTION_RAW 0x19
|
||||
#define EFI_SECTION_PEI_DEPEX 0x1B
|
||||
|
||||
|
||||
typedef struct _EFI_FIRMWARE_VOLUME2_PROTOCOL EFI_FIRMWARE_VOLUME2_PROTOCOL;
|
||||
|
||||
typedef EFI_STATUS
|
||||
(EFIAPI * EFI_FV_READ_FILE) (
|
||||
IN EFI_FIRMWARE_VOLUME2_PROTOCOL *This,
|
||||
IN EFI_GUID *NameGuid,
|
||||
IN OUT VOID **Buffer,
|
||||
IN OUT UINTN *BufferSize,
|
||||
OUT EFI_FV_FILETYPE *FoundType,
|
||||
OUT EFI_FV_FILE_ATTRIBUTES *FileAttributes,
|
||||
OUT UINT32 *AuthenticationStatus
|
||||
);
|
||||
|
||||
typedef EFI_STATUS
|
||||
(EFIAPI * EFI_FV_READ_SECTION) (
|
||||
IN EFI_FIRMWARE_VOLUME2_PROTOCOL *This,
|
||||
IN EFI_GUID *NameGuid,
|
||||
IN EFI_SECTION_TYPE SectionType,
|
||||
IN UINTN SectionInstance,
|
||||
IN OUT VOID **Buffer,
|
||||
IN OUT UINTN *BufferSize,
|
||||
OUT UINT32 *AuthenticationStatus
|
||||
);
|
||||
|
||||
struct _EFI_FIRMWARE_VOLUME2_PROTOCOL {
|
||||
uint64_t GetVolumeAttributes;
|
||||
uint64_t SetVolumeAttributes;
|
||||
EFI_FV_READ_FILE ReadFile;
|
||||
EFI_FV_READ_SECTION ReadSection;
|
||||
uint64_t WriteFile;
|
||||
uint64_t GetNextFile;
|
||||
uint32_t KeySize;
|
||||
uint64_t ParentHandle;
|
||||
uint64_t GetInfo;
|
||||
uint64_t SetInfo;
|
||||
};
|
||||
|
||||
|
||||
int
|
||||
read_ffs(
|
||||
EFI_BOOT_SERVICES * gBS,
|
||||
EFI_GUID * guid,
|
||||
void ** buffer,
|
||||
UINTN * size,
|
||||
EFI_SECTION_TYPE section_type
|
||||
);
|
||||
|
||||
#endif
|
74
dxe/elf_x86_64_efi.lds
Normal file
74
dxe/elf_x86_64_efi.lds
Normal file
@ -0,0 +1,74 @@
|
||||
/* Same as elf_x86_64_fbsd_efi.lds, except for OUTPUT_FORMAT below - KEEP IN SYNC */
|
||||
OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64")
|
||||
OUTPUT_ARCH(i386:x86-64)
|
||||
ENTRY(efi_main)
|
||||
SECTIONS
|
||||
{
|
||||
. = 0;
|
||||
ImageBase = .;
|
||||
.hash : { *(.hash) } /* this MUST come first! */
|
||||
. = ALIGN(4096);
|
||||
.eh_frame :
|
||||
{
|
||||
*(.eh_frame)
|
||||
}
|
||||
. = ALIGN(4096);
|
||||
.text :
|
||||
{
|
||||
_text = .;
|
||||
*(.text)
|
||||
*(.text.*)
|
||||
*(.gnu.linkonce.t.*)
|
||||
. = ALIGN(16);
|
||||
}
|
||||
_etext = .;
|
||||
_text_size = . - _text;
|
||||
. = ALIGN(4096);
|
||||
.reloc :
|
||||
{
|
||||
*(.reloc)
|
||||
}
|
||||
. = ALIGN(4096);
|
||||
.data :
|
||||
{
|
||||
_data = .;
|
||||
*(.rodata*)
|
||||
*(.got.plt)
|
||||
*(.got)
|
||||
*(.data*)
|
||||
*(.sdata)
|
||||
/* the EFI loader doesn't seem to like a .bss section, so we stick
|
||||
it all into .data: */
|
||||
*(.sbss)
|
||||
*(.scommon)
|
||||
*(.dynbss)
|
||||
*(.bss)
|
||||
*(COMMON)
|
||||
*(.rel.local)
|
||||
}
|
||||
.note.gnu.build-id : { *(.note.gnu.build-id) }
|
||||
|
||||
_edata = .;
|
||||
_data_size = . - _etext;
|
||||
. = ALIGN(4096);
|
||||
.dynamic : { *(.dynamic) }
|
||||
. = ALIGN(4096);
|
||||
.rela :
|
||||
{
|
||||
*(.rela.data*)
|
||||
*(.rela.got)
|
||||
*(.rela.stab)
|
||||
}
|
||||
. = ALIGN(4096);
|
||||
.dynsym : { *(.dynsym) }
|
||||
. = ALIGN(4096);
|
||||
.dynstr : { *(.dynstr) }
|
||||
. = ALIGN(4096);
|
||||
.ignored.reloc :
|
||||
{
|
||||
*(.rela.reloc)
|
||||
*(.eh_frame)
|
||||
*(.note.GNU-stack)
|
||||
}
|
||||
.comment 0 : { *(.comment) }
|
||||
}
|
67
dxe/fvloader.c
Normal file
67
dxe/fvloader.c
Normal file
@ -0,0 +1,67 @@
|
||||
/** \file
|
||||
* Tell DxeCore about an alternate firmware volume in the ROM.
|
||||
*
|
||||
* This allows LinuxBoot to locate the Linux kernel and initrd
|
||||
* outside of the normal DXE volume, which is quite small on some
|
||||
* systems.
|
||||
*/
|
||||
// #define VOLUME_ADDRESS 0xFF840000 // Winterfell
|
||||
// #define VOLUME_LENGTH 0x20000
|
||||
|
||||
#define VOLUME_ADDRESS 0xFF500000
|
||||
#define VOLUME_LENGTH 0x00400000
|
||||
|
||||
#include "serial.h"
|
||||
//#include "efi.h"
|
||||
#include <efi/efi.h>
|
||||
#include "efidxe.h"
|
||||
|
||||
static void hexdump(uint64_t p, unsigned len)
|
||||
{
|
||||
for(unsigned i = 0 ; i < len ; i += 8)
|
||||
serial_hex(*(const uint64_t*)(p+i), 16);
|
||||
}
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
efi_main(
|
||||
EFI_HANDLE image,
|
||||
EFI_SYSTEM_TABLE * const st
|
||||
)
|
||||
{
|
||||
(void) image;
|
||||
|
||||
//gST = st;
|
||||
//gBS = gST->BootServices;
|
||||
//gRT = gST->RuntimeServices;
|
||||
|
||||
const EFI_DXE_SERVICES * dxe_services = efi_find_table(st, 0x5ad34ba);
|
||||
|
||||
if (!dxe_services)
|
||||
{
|
||||
serial_string("FvLoader: No DXE system table found...\r\n");
|
||||
return 0x80000001;
|
||||
}
|
||||
|
||||
serial_string("FvLoader: adding firmware volume 0x");
|
||||
serial_hex(VOLUME_ADDRESS, 8);
|
||||
|
||||
EFI_HANDLE handle;
|
||||
int rc = dxe_services->ProcessFirmwareVolume(
|
||||
(void*) VOLUME_ADDRESS,
|
||||
VOLUME_LENGTH,
|
||||
&handle
|
||||
);
|
||||
|
||||
if (rc == 0)
|
||||
{
|
||||
serial_string("FVLoader: mapped 0x");
|
||||
serial_hex(VOLUME_LENGTH, 8);
|
||||
} else {
|
||||
serial_string("FvLoader: error rc="); serial_hex(rc, 8);
|
||||
hexdump(VOLUME_ADDRESS, 128);
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
26
dxe/hello.c
Normal file
26
dxe/hello.c
Normal file
@ -0,0 +1,26 @@
|
||||
/** \file
|
||||
*/
|
||||
#include "serial.h"
|
||||
#include <efi/efi.h>
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
efi_main(
|
||||
EFI_HANDLE image,
|
||||
EFI_SYSTEM_TABLE * const st
|
||||
)
|
||||
{
|
||||
(void) image;
|
||||
(void) st;
|
||||
|
||||
serial_string("+---------------+\r\n");
|
||||
serial_string("| Hello, world! |\r\n");
|
||||
serial_string("+---------------+\r\n");
|
||||
serial_hex((uint64_t) image, 16);
|
||||
|
||||
if (st->ConOut)
|
||||
st->ConOut->OutputString(st->ConOut, L"hello: Console output\n");
|
||||
|
||||
return 0;
|
||||
}
|
383
dxe/linuxboot.c
Normal file
383
dxe/linuxboot.c
Normal file
@ -0,0 +1,383 @@
|
||||
/** \file
|
||||
* LinuxBoot BDS
|
||||
*
|
||||
* Locates the Linux kernel and initrd on a possible external volume,
|
||||
* finds the command line and uses the BootServices->StartImage()
|
||||
* to make it go.
|
||||
*
|
||||
* This allows LinuxBoot to locate the Linux kernel and initrd
|
||||
* outside of the normal DXE volume, which is quite small on some
|
||||
* systems.
|
||||
*
|
||||
*/
|
||||
// #define VOLUME_ADDRESS 0xFF840000 // Winterfell
|
||||
// #define VOLUME_LENGTH 0x20000
|
||||
|
||||
#define VOLUME_ADDRESS 0xFF500000
|
||||
#define VOLUME_LENGTH 0x00400000
|
||||
|
||||
#include "serial.h"
|
||||
#include <efi/efi.h>
|
||||
#include "efidxe.h"
|
||||
#include "efifv.h"
|
||||
#include <asm/bootparam.h>
|
||||
|
||||
EFI_HANDLE gImage;
|
||||
EFI_SYSTEM_TABLE * gST;
|
||||
EFI_BOOT_SERVICES * gBS;
|
||||
EFI_RUNTIME_SERVICES * gRT;
|
||||
EFI_DXE_SERVICES * gDXE;
|
||||
|
||||
|
||||
static void
|
||||
hexdump(uint64_t p, unsigned len)
|
||||
{
|
||||
for(unsigned i = 0 ; i < len ; i += 8)
|
||||
serial_hex(*(const uint64_t*)(p+i), 16);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
process_fv(
|
||||
const uintptr_t ptr,
|
||||
const unsigned len
|
||||
)
|
||||
{
|
||||
serial_string("FvLoader: adding firmware volume 0x");
|
||||
serial_hex(ptr, 8);
|
||||
|
||||
EFI_HANDLE handle;
|
||||
int rc = gDXE->ProcessFirmwareVolume(
|
||||
(void*) ptr,
|
||||
len,
|
||||
&handle
|
||||
);
|
||||
|
||||
if (rc == 0)
|
||||
{
|
||||
serial_string("FVLoader: mapped 0x");
|
||||
serial_hex(len, 8);
|
||||
} else {
|
||||
serial_string("FvLoader: error rc="); serial_hex(rc, 8);
|
||||
hexdump(ptr, 128);
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* The LinuxBoot kernel is invoked as a DXE driver that registers
|
||||
* the BDS (Boot Device Selector) protocol. Once all of the DXE
|
||||
* executables have run, the DxeCore dispatcher will jump into the
|
||||
* BDS to choose what kernel to run.
|
||||
*
|
||||
* In our case, it is this kernel. So we need to stash the config
|
||||
* for when we are re-invoked.
|
||||
*/
|
||||
static void EFIAPI
|
||||
empty_notify(void* unused1, void* unused2)
|
||||
{
|
||||
(void) unused1;
|
||||
(void) unused2;
|
||||
}
|
||||
|
||||
#define EFI_DXE_SERVICES_TABLE_GUID ((EFI_GUID){ 0x5ad34ba, 0x6f02, 0x4214, { 0x95, 0x2e, 0x4d, 0xa0, 0x39, 0x8e, 0x2b, 0xb9 } })
|
||||
|
||||
#define ROOT_BRIDGES_CONNECTED_EVENT_GROUP_GUID ((EFI_GUID){ 0x24a2d66f, 0xeedd, 0x4086, { 0x90, 0x42, 0xf2, 0x6e, 0x47, 0x97, 0xee, 0x69 } })
|
||||
|
||||
#define EFI_END_OF_DXE_EVENT_GROUP_GUID ((EFI_GUID){ 0x02ce967a, 0xdd7e, 0x4ffc, { 0x9e, 0xe7, 0x81, 0x0c, 0xf0, 0x47, 0x08, 0x80 } })
|
||||
|
||||
#define EFI_EVENT_GROUP_READY_TO_BOOT ((EFI_GUID){ 0x7ce88fb3, 0x4bd7, 0x4679, { 0x87, 0xa8, 0xa8, 0xd8, 0xde, 0xe5, 0x0d, 0x2b } })
|
||||
|
||||
#define EFI_DXE_SMM_READY_TO_LOCK_PROTOCOL_GUID ((EFI_GUID){ 0x60ff8964, 0xe906, 0x41d0, { 0xaf, 0xed, 0xf2, 0x41, 0xe9, 0x74, 0xe0, 0x8e } })
|
||||
|
||||
#define EFI_BDS_ARCH_PROTOCOL_GUID ((EFI_GUID){ 0x665E3FF6, 0x46CC, 0x11d4, { 0x9A, 0x38, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D } })
|
||||
|
||||
|
||||
static void
|
||||
efi_event_signal(
|
||||
EFI_GUID guid
|
||||
)
|
||||
{
|
||||
EFI_STATUS status;
|
||||
EFI_EVENT event;
|
||||
|
||||
status = gBS->CreateEventEx(
|
||||
EVT_NOTIFY_SIGNAL,
|
||||
EFI_TPL_CALLBACK,
|
||||
empty_notify,
|
||||
NULL,
|
||||
&guid,
|
||||
&event
|
||||
);
|
||||
if (status)
|
||||
serial_hex(status, 8);
|
||||
|
||||
status = gBS->SignalEvent(event);
|
||||
if (status)
|
||||
serial_hex(status, 8);
|
||||
|
||||
status = gBS->CloseEvent(event);
|
||||
if (status)
|
||||
serial_hex(status, 8);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
efi_visit_handles(
|
||||
EFI_GUID * protocol,
|
||||
void (EFIAPI *callback)(EFI_HANDLE, void*),
|
||||
void* priv
|
||||
)
|
||||
{
|
||||
serial_string("efi_visit_handles ");
|
||||
serial_hex(protocol ? *(uint32_t*) protocol : 0, 8);
|
||||
EFI_HANDLE * handle_buffer;
|
||||
UINTN handle_count;
|
||||
|
||||
EFI_STATUS status = gBS->LocateHandleBuffer(
|
||||
protocol ? ByProtocol : AllHandles,
|
||||
protocol,
|
||||
NULL,
|
||||
&handle_count,
|
||||
&handle_buffer
|
||||
);
|
||||
if (status != 0)
|
||||
{
|
||||
serial_string("status=");
|
||||
serial_hex(status, 8);
|
||||
return;
|
||||
}
|
||||
|
||||
serial_string("handle_count=");
|
||||
serial_hex(handle_count, 8);
|
||||
|
||||
for(unsigned i = 0 ; i < handle_count ; i++)
|
||||
{
|
||||
//serial_hex((uint64_t) handle_buffer[i], 16);
|
||||
callback(handle_buffer[i], priv);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void EFIAPI
|
||||
efi_connect_controllers(
|
||||
EFI_HANDLE handle,
|
||||
void * recursive_arg
|
||||
)
|
||||
{
|
||||
gBS->ConnectController(
|
||||
handle,
|
||||
NULL, // DriverImageHandle
|
||||
NULL, // RemainingDevicePath
|
||||
recursive_arg ? 1 : 0
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
efi_final_init(void)
|
||||
{
|
||||
// equivilant to PlatformBootManagerBeforeConsole
|
||||
|
||||
// connect all the pci root bridges
|
||||
serial_string("LinuxBoot: connect pci root brdiges\r\n");
|
||||
EFI_GUID pci_protocol = EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_GUID;
|
||||
efi_visit_handles(&pci_protocol, efi_connect_controllers, (void*) 0);
|
||||
|
||||
// signal the acpi platform driver that it can download the ACPI tables
|
||||
serial_string("LinuxBoot: signal root bridges connected\r\n");
|
||||
efi_event_signal(ROOT_BRIDGES_CONNECTED_EVENT_GROUP_GUID);
|
||||
|
||||
// signal that dxe is about to end
|
||||
serial_string("LinuxBoot: signal dxe end\r\n");
|
||||
efi_event_signal(EFI_END_OF_DXE_EVENT_GROUP_GUID);
|
||||
|
||||
// Prevent further changes to LockBoxes or SMRAM.
|
||||
// This should be a configurable option
|
||||
EFI_HANDLE handle = NULL;
|
||||
EFI_GUID smm_ready_to_lock = EFI_DXE_SMM_READY_TO_LOCK_PROTOCOL_GUID;
|
||||
serial_string("LinuxBoot: signal smm ready to lock\r\n");
|
||||
|
||||
gBS->InstallProtocolInterface(
|
||||
&handle,
|
||||
&smm_ready_to_lock,
|
||||
EFI_NATIVE_INTERFACE,
|
||||
NULL
|
||||
);
|
||||
|
||||
// connect all drivers their contorllers
|
||||
// this is copied from BmConnectAllDriversToAllControllers()
|
||||
// the DXE services table is buried in the configuration
|
||||
// table in the system table
|
||||
/**
|
||||
Connect all the drivers to all the controllers.
|
||||
|
||||
This function makes sure all the current system drivers manage the correspoinding
|
||||
controllers if have. And at the same time, makes sure all the system controllers
|
||||
have driver to manage it if have.
|
||||
**/
|
||||
do {
|
||||
efi_visit_handles(NULL, efi_connect_controllers, (void*) 1);
|
||||
serial_string("LinuxBoot: bds_main dispatch\r\n");
|
||||
} while(gDXE->Dispatch() == 0);
|
||||
|
||||
// signal that we're ready to boot, which will
|
||||
// cause additional drivers to be loaded
|
||||
serial_string("LinuxBoot: signal ready to boot\r\n");
|
||||
efi_event_signal(EFI_EVENT_GROUP_READY_TO_BOOT);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// code in MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
|
||||
static int
|
||||
linuxboot_start()
|
||||
{
|
||||
EFI_STATUS status;
|
||||
EFI_GUID bzimage_guid = { 0xDECAFBAD, 0x6548, 0x6461, { 0x73, 0x2d, 0x2f, 0x2d, 0x4e, 0x45, 0x52, 0x46 }};
|
||||
EFI_GUID initrd_guid = { 0x74696e69, 0x6472, 0x632e, { 0x70, 0x69, 0x6f, 0x2f, 0x62, 0x69, 0x6f, 0x73 }};
|
||||
|
||||
void * bzimage_buffer = NULL;
|
||||
UINTN bzimage_length = 0;
|
||||
serial_string("LinuxBoot: Looking for bzimage\r\n");
|
||||
if (read_ffs(gBS, &bzimage_guid, &bzimage_buffer, &bzimage_length, EFI_SECTION_PE32) < 0)
|
||||
return -1;
|
||||
|
||||
// convert the RAM image of the kernel into a loaded image
|
||||
EFI_HANDLE bzimage_handle = NULL;
|
||||
status = gBS->LoadImage(
|
||||
TRUE, // Boot
|
||||
gImage,
|
||||
NULL, // no device path
|
||||
bzimage_buffer,
|
||||
bzimage_length,
|
||||
&bzimage_handle
|
||||
);
|
||||
if (status != 0)
|
||||
{
|
||||
serial_string("LinuxBoot: unable to load bzImage image\r\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
EFI_GUID loaded_image_guid = LOADED_IMAGE_PROTOCOL;
|
||||
EFI_LOADED_IMAGE_PROTOCOL * loaded_image = NULL;
|
||||
status = gBS->HandleProtocol(
|
||||
bzimage_handle,
|
||||
&loaded_image_guid,
|
||||
(void**) &loaded_image
|
||||
);
|
||||
if (status != 0)
|
||||
{
|
||||
serial_string("LinuxBoot: unable to get LoadedImageProtocol\r\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
void * initrd_buffer = NULL;
|
||||
UINTN initrd_length = 0;
|
||||
serial_string("LinuxBoot: Looking for initrd\r\n");
|
||||
if (read_ffs(gBS, &initrd_guid, &initrd_buffer, &initrd_length, EFI_SECTION_RAW) < 0)
|
||||
{
|
||||
serial_string("LinuxBoot: no initrd found\r\n");
|
||||
} else {
|
||||
static uint16_t cmdline[] = L"found_initd";
|
||||
loaded_image->LoadOptions = cmdline;
|
||||
loaded_image->LoadOptionsSize = sizeof(cmdline);
|
||||
|
||||
uintptr_t hdr = (uintptr_t) loaded_image->ImageBase;
|
||||
*(uint32_t*)(hdr + 0x218) = (uint32_t)(uintptr_t) initrd_buffer;
|
||||
*(uint32_t*)(hdr + 0x21c) = (uint32_t)(uintptr_t) initrd_length;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// attempt to load the kernel
|
||||
UINTN exit_data_len = 0;
|
||||
CHAR16 * exit_data = NULL;
|
||||
|
||||
serial_string("LinuxBoot: Starting bzImage\r\n");
|
||||
status = gBS->StartImage(
|
||||
bzimage_handle,
|
||||
&exit_data_len,
|
||||
&exit_data
|
||||
);
|
||||
if (status != 0)
|
||||
{
|
||||
serial_string("LinuxBoot: Unable to start bzImage\r\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static EFI_STATUS EFIAPI
|
||||
efi_bds_main(void)
|
||||
{
|
||||
serial_string("LinuxBoot: BDS time has arrived\r\n");
|
||||
efi_final_init();
|
||||
|
||||
if (linuxboot_start() < 0)
|
||||
return 0;
|
||||
|
||||
serial_string("LinuxBoot: SOMETHING IS WRONG\r\n");
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
|
||||
static struct
|
||||
{
|
||||
EFI_STATUS (EFIAPI *bds_main)(void);
|
||||
} efi_bds_arch_protocol;
|
||||
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
efi_main(
|
||||
EFI_HANDLE image,
|
||||
EFI_SYSTEM_TABLE * const st
|
||||
)
|
||||
{
|
||||
serial_string("+--------------------+\r\n");
|
||||
serial_string("| |\r\n");
|
||||
serial_string("| Starting LinuxBoot |\r\n");
|
||||
serial_string("| |\r\n");
|
||||
serial_string("+--------------------+\r\n");
|
||||
|
||||
gImage = image;
|
||||
gST = st;
|
||||
gBS = gST->BootServices;
|
||||
gRT = gST->RuntimeServices;
|
||||
gDXE = efi_find_table(gST, 0x5ad34ba); // should use DXE table guid
|
||||
|
||||
if (!gDXE)
|
||||
{
|
||||
serial_string("LinuxBoot: No DXE system table found...\r\n");
|
||||
return EFI_LOAD_ERROR;
|
||||
}
|
||||
|
||||
// update the PCH to map the entire flashchip
|
||||
// BIOS_SEL1 and BIOS_SEL2
|
||||
|
||||
// create any new volumes
|
||||
if (VOLUME_ADDRESS)
|
||||
process_fv(VOLUME_ADDRESS, VOLUME_LENGTH);
|
||||
|
||||
// register the BDS callback
|
||||
efi_bds_arch_protocol.bds_main = efi_bds_main;
|
||||
EFI_GUID bds_guid = EFI_BDS_ARCH_PROTOCOL_GUID;
|
||||
|
||||
gBS->InstallProtocolInterface(
|
||||
&image,
|
||||
&bds_guid,
|
||||
EFI_NATIVE_INTERFACE,
|
||||
&efi_bds_arch_protocol
|
||||
);
|
||||
|
||||
serial_string("LinuxBoot: waiting for BDS callback\r\n");
|
||||
return 0;
|
||||
}
|
66
dxe/serial.h
Normal file
66
dxe/serial.h
Normal file
@ -0,0 +1,66 @@
|
||||
#ifndef __serial_h__
|
||||
#define __serial_h__
|
||||
|
||||
static __inline void
|
||||
outb (unsigned char __value, unsigned short int __port)
|
||||
{
|
||||
__asm__ __volatile__ ("outb %b0,%w1": :"a" (__value), "Nd" (__port));
|
||||
}
|
||||
|
||||
static __inline unsigned char
|
||||
inb (unsigned short int __port)
|
||||
{
|
||||
unsigned char _v;
|
||||
|
||||
__asm__ __volatile__ ("inb %w1,%0":"=a" (_v):"Nd" (__port));
|
||||
return _v;
|
||||
}
|
||||
|
||||
#define PORT 0x3f8 /* COM1 */
|
||||
|
||||
#define DLAB 0x80
|
||||
|
||||
#define TXR 0 /* Transmit register (WRITE) */
|
||||
#define RXR 0 /* Receive register (READ) */
|
||||
#define IER 1 /* Interrupt Enable */
|
||||
#define IIR 2 /* Interrupt ID */
|
||||
#define FCR 2 /* FIFO control */
|
||||
#define LCR 3 /* Line control */
|
||||
#define MCR 4 /* Modem control */
|
||||
#define LSR 5 /* Line Status */
|
||||
#define MSR 6 /* Modem Status */
|
||||
#define DLL 0 /* Divisor Latch Low */
|
||||
#define DLH 1 /* Divisor latch High */
|
||||
|
||||
static int is_transmit_empty()
|
||||
{
|
||||
return inb(PORT + 5) & 0x20;
|
||||
}
|
||||
|
||||
static void serial_char(char a) {
|
||||
outb(a, PORT);
|
||||
while (is_transmit_empty() == 0);
|
||||
}
|
||||
|
||||
static void serial_string(const char * s)
|
||||
{
|
||||
while(*s)
|
||||
serial_char(*s++);
|
||||
}
|
||||
|
||||
static void serial_hex(unsigned long x, unsigned digits)
|
||||
{
|
||||
while(digits-- > 0)
|
||||
{
|
||||
unsigned d = (x >> (digits * 4)) & 0xF;
|
||||
if (d >= 0xA)
|
||||
serial_char(d + 'A' - 0xA);
|
||||
else
|
||||
serial_char(d + '0');
|
||||
}
|
||||
serial_char('\r');
|
||||
serial_char('\n');
|
||||
}
|
||||
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user