[chore] Use gnu-efi as a part of project
This commit is contained in:
@@ -1,3 +0,0 @@
|
||||
[submodule "gnu-efi"]
|
||||
path = gnu-efi
|
||||
url = https://github.com/ncroxon/gnu-efi.git
|
||||
@@ -1,33 +1,31 @@
|
||||
# Sylva OS — Agent Guide
|
||||
|
||||
x86_64 UEFI hobby OS kernel. C17 boot → C++17 kernel, ELF64 → PE32+ via objcopy.
|
||||
x86_64 UEFI hobby OS. C17 boot (`.c`) → C++17 kernel (`.cpp`), ELF64 → PE32+ via objcopy.
|
||||
|
||||
## Build & Run
|
||||
|
||||
| Command | What |
|
||||
|---------|------|
|
||||
| `make` | Build `build/BOOTX64.EFI` |
|
||||
| `make run` | QEMU + OVMF, serial → `serial.log`, paused for GDB (`-s -S`) |
|
||||
| `make clean` | **Always before commit** — gnu-efi produces untracked files |
|
||||
| `make run` | QEMU + OVMF, serial port 1 → `serial.log`, serial port 2 → stdio, paused for GDB (`-s -S`) |
|
||||
| `make clean` | **Always before commit** — gnu-efi build produces untracked files outside `build/` |
|
||||
|
||||
## Architecture
|
||||
|
||||
- `boot.c` — UEFI entrypoint (`efi_main`), calls `kernel_main()`
|
||||
- `kernel/main.cpp` — `extern "C" kernel_main()`: init GOP → serial → PMM → heap → idle loop (`hlt`)
|
||||
- `boot.c` — UEFI entrypoint (`efi_main` → `kernel_main()`)
|
||||
- `kernel/main.cpp` — `extern "C" kernel_main()`: init GOP → serial → PMM → heap → idle (`hlt`)
|
||||
- `kernel/serial.cpp` — UEFI serial protocol wrapper
|
||||
- `kernel/memory/pmm.cpp` — bitmap + free-list physical page allocator
|
||||
- `kernel/memory/heap.cpp` — kmalloc/kfree/kcalloc/krealloc (first-fit, coalescing)
|
||||
- `graphics/` — GOP framebuffer pixel drawing
|
||||
- `fonts/` — Hankaku 8×16 pixel font renderer
|
||||
- `gnu-efi/` — git submodule (https://github.com/ncroxon/gnu-efi.git)
|
||||
- `graphics/` — GOP framebuffer pixel drawing, `fonts/` — Hankaku 8×16 font renderer
|
||||
- `efi/` — bundled gnu-efi source; `gnu-efi/` is an unregistered submodule reference
|
||||
|
||||
## Quirks
|
||||
|
||||
- **`uefi_call_wrapper` required for all UEFI protocol calls or kernel page-faults**
|
||||
- **`uefi_call_wrapper` required for all UEFI protocol calls** — omitting it causes page-faults (see `kernel/main.cpp:49`)
|
||||
- `kernel_main` must be `extern "C"` (C→C++ linkage)
|
||||
- QEMU starts paused — connect GDB to :1234 to proceed
|
||||
- No tests, no CI, no lint/formatter config
|
||||
- C17 (`boot.c`), C++17 (`kernel/`)
|
||||
- Standards: `-ffreestanding -fno-stack-protector -fshort-wchar -mno-red-zone`
|
||||
- QEMU starts paused — connect GDB to `:1234` to proceed
|
||||
- Compiler standards: C17 (`boot.c`), C++17 (`kernel/`), `-ffreestanding -fno-stack-protector -fshort-wchar -mno-red-zone`
|
||||
- `#define ASM asm volatile` in `include/common.h`
|
||||
- `BUILD_INFOS.h` is a placeholder for CI
|
||||
- `BUILD_INFOS.h` — placeholder for CI; `.github/` is empty
|
||||
- No tests, no CI, no lint/formatter config
|
||||
|
||||
@@ -1,30 +1,74 @@
|
||||
CFLAGS = -Iinclude -Ignu-efi/inc -ffreestanding -fno-stack-protector -fno-stack-check -fshort-wchar -mno-red-zone -std=c17 -Wwrite-strings
|
||||
CXXFLAGS = -Iinclude -Ignu-efi/inc -ffreestanding -fno-stack-protector -fno-stack-check -fshort-wchar -mno-red-zone -maccumulate-outgoing-args -std=c++17 -Wwrite-strings
|
||||
LDFLAGS = -shared -Bsymbolic -Lgnu-efi/x86_64/lib -Lgnu-efi/x86_64/gnuefi -Tgnu-efi/gnuefi/elf_x86_64_efi.lds
|
||||
LDLIBS = -lgnuefi -lefi --no-undefined
|
||||
CFLAGS = -Iinclude -Iefi/inc -ffreestanding -fno-stack-protector -fno-stack-check -fshort-wchar -mno-red-zone -std=c17 -Wwrite-strings
|
||||
CXXFLAGS = -Iinclude -Iefi/inc -ffreestanding -fno-stack-protector -fno-stack-check -fshort-wchar -mno-red-zone -maccumulate-outgoing-args -std=c++17 -Wwrite-strings
|
||||
LDFLAGS = -shared -Bsymbolic -Tefi/gnuefi/elf_x86_64_efi.lds
|
||||
LDLIBS = --no-undefined
|
||||
|
||||
EFI_CFLAGS = -Iefi/inc -Iefi/inc/x86_64 -Iefi/inc/protocol \
|
||||
-ffreestanding -fno-stack-protector -fno-stack-check \
|
||||
-fshort-wchar -mno-red-zone -maccumulate-outgoing-args \
|
||||
-fPIC -fno-strict-aliasing -Wall -Wextra -Wstrict-prototypes \
|
||||
-DGNU_EFI_USE_MS_ABI -DCONFIG_x86_64 -std=c11 -O2 -g
|
||||
|
||||
SRC_C = $(wildcard *.c)
|
||||
SRC_CPP = $(wildcard */*.cpp) $(wildcard */*/*.cpp)
|
||||
OBJ = $(SRC_C:%.c=build/%.o) $(SRC_CPP:%.cpp=build/%.o)
|
||||
|
||||
_bd:
|
||||
@mkdir -p build/graphics build/kernel build/fonts build/kernel/memory
|
||||
EFI_TOP_C = $(wildcard efi/lib/*.c)
|
||||
EFI_TOP_S = $(wildcard efi/lib/*.S)
|
||||
EFI_X86_C = $(wildcard efi/lib/x86_64/*.c)
|
||||
EFI_X86_S = $(wildcard efi/lib/x86_64/*.S)
|
||||
EFI_RT_C = $(wildcard efi/lib/runtime/*.c)
|
||||
|
||||
gnu-efi/x86_64/gnuefi/crt0-efi-x86_64.o:
|
||||
@echo "* Building gnu-efi..."
|
||||
@$(MAKE) -C gnu-efi ARCH=x86_64
|
||||
EFI_CRT0_OBJ = build/efi/gnuefi/crt0-efi-x86_64.o
|
||||
EFI_RELOC_OBJ = build/efi/gnuefi/reloc_x86_64.o
|
||||
EFI_TOP_OBJ = $(EFI_TOP_C:efi/lib/%.c=build/efi/lib/%.o) $(EFI_TOP_S:efi/lib/%.S=build/efi/lib/%.o)
|
||||
EFI_X86_OBJ = $(EFI_X86_C:efi/lib/x86_64/%.c=build/efi/lib/x86_64/%.o) $(EFI_X86_S:efi/lib/x86_64/%.S=build/efi/lib/x86_64/%.o)
|
||||
EFI_RT_OBJ = $(EFI_RT_C:efi/lib/runtime/%.c=build/efi/lib/runtime/%.o)
|
||||
EFI_OBJ = $(EFI_CRT0_OBJ) $(EFI_RELOC_OBJ) $(EFI_TOP_OBJ) $(EFI_X86_OBJ) $(EFI_RT_OBJ)
|
||||
|
||||
all: _bd gnu-efi/x86_64/gnuefi/crt0-efi-x86_64.o $(OBJ)
|
||||
all: _bd $(EFI_OBJ) $(OBJ)
|
||||
@echo "* Linking EFI..."
|
||||
@ld $(LDFLAGS) gnu-efi/x86_64/gnuefi/crt0-efi-x86_64.o $(OBJ) -o build/boot.so $(LDLIBS)
|
||||
@ld $(LDFLAGS) $(EFI_OBJ) $(OBJ) -o build/boot.so $(LDLIBS)
|
||||
@objcopy -j .text -j .sdata -j .data -j .rodata -j .dynamic -j .dynsym -j .rel -j .rela -j .rel.* -j .rela.* -j .reloc --output-target efi-app-x86_64 --subsystem=10 build/boot.so build/BOOTX64.EFI
|
||||
|
||||
_bd:
|
||||
@mkdir -p build/graphics build/kernel build/fonts build/kernel/memory \
|
||||
build/efi/lib build/efi/lib/x86_64 build/efi/lib/runtime build/efi/gnuefi
|
||||
|
||||
$(EFI_CRT0_OBJ): efi/gnuefi/crt0-efi-x86_64.S | _bd
|
||||
@echo "Compile AS $<"
|
||||
@gcc $(EFI_CFLAGS) -c $< -o $@
|
||||
|
||||
$(EFI_RELOC_OBJ): efi/gnuefi/reloc_x86_64.c | _bd
|
||||
@echo "Compile C $<"
|
||||
@gcc $(EFI_CFLAGS) -c $< -o $@
|
||||
|
||||
build/efi/lib/%.o: efi/lib/%.c | _bd
|
||||
@echo "Compile C $<"
|
||||
@gcc $(EFI_CFLAGS) -c $< -o $@
|
||||
|
||||
build/efi/lib/%.o: efi/lib/%.S | _bd
|
||||
@echo "Compile AS $<"
|
||||
@gcc $(EFI_CFLAGS) -c $< -o $@
|
||||
|
||||
build/efi/lib/x86_64/%.o: efi/lib/x86_64/%.c | _bd
|
||||
@echo "Compile C $<"
|
||||
@gcc $(EFI_CFLAGS) -c $< -o $@
|
||||
|
||||
build/efi/lib/x86_64/%.o: efi/lib/x86_64/%.S | _bd
|
||||
@echo "Compile AS $<"
|
||||
@gcc $(EFI_CFLAGS) -c $< -o $@
|
||||
|
||||
build/efi/lib/runtime/%.o: efi/lib/runtime/%.c | _bd
|
||||
@echo "Compile C $<"
|
||||
@gcc $(EFI_CFLAGS) -c $< -o $@
|
||||
|
||||
build/%.o: %.c
|
||||
@echo "Compile C File $< to $@"
|
||||
@echo "Compile C $<"
|
||||
@gcc $(CFLAGS) -c $< -o $@
|
||||
|
||||
build/%.o: %.cpp
|
||||
@echo "Compile CPP File $< to $@"
|
||||
@echo "Compile CPP $<"
|
||||
@g++ $(CXXFLAGS) -c $< -o $@
|
||||
|
||||
vdir: all
|
||||
@@ -38,6 +82,5 @@ run: vdir
|
||||
clean:
|
||||
@echo "Cleaning old files"
|
||||
@rm -rf build vdir
|
||||
@$(MAKE) -C gnu-efi clean 2>/dev/null || true
|
||||
|
||||
.PHONY: all vdir run clean _bd
|
||||
@@ -0,0 +1,81 @@
|
||||
/* crt0-efi-x86_64.S - x86_64 EFI startup code.
|
||||
Copyright (C) 1999 Hewlett-Packard Co.
|
||||
Contributed by David Mosberger <davidm@hpl.hp.com>.
|
||||
Copyright (C) 2005 Intel Co.
|
||||
Contributed by Fenghua Yu <fenghua.yu@intel.com>.
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials
|
||||
provided with the distribution.
|
||||
* Neither the name of Hewlett-Packard Co. nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
BE LIABLE FOR ANYDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
||||
THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
*/
|
||||
.text
|
||||
.align 4
|
||||
|
||||
.globl _start
|
||||
.type _start,%function
|
||||
_start:
|
||||
subq $8, %rsp
|
||||
pushq %rcx
|
||||
pushq %rdx
|
||||
|
||||
0:
|
||||
lea ImageBase(%rip), %rdi
|
||||
lea _DYNAMIC(%rip), %rsi
|
||||
|
||||
popq %rcx
|
||||
popq %rdx
|
||||
pushq %rcx
|
||||
pushq %rdx
|
||||
call _relocate
|
||||
|
||||
popq %rdi
|
||||
popq %rsi
|
||||
|
||||
call _entry
|
||||
addq $8, %rsp
|
||||
|
||||
.L_exit:
|
||||
ret
|
||||
|
||||
// hand-craft a dummy .reloc section so EFI knows it's a relocatable executable:
|
||||
|
||||
.data
|
||||
dummy0: .4byte 0
|
||||
dummy1: .4byte 0
|
||||
|
||||
#define IMAGE_REL_ABSOLUTE 0
|
||||
.section .reloc, "a", %progbits
|
||||
.4byte dummy1 - dummy0 // Page RVA
|
||||
.4byte 12 // Block Size (2*4+2*2), must be aligned by 32 Bits
|
||||
.2byte (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy
|
||||
.2byte (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy
|
||||
|
||||
#if defined(__ELF__) && defined(__linux__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
@@ -0,0 +1,114 @@
|
||||
/* 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(_start)
|
||||
SECTIONS
|
||||
{
|
||||
. = 0;
|
||||
ImageBase = .;
|
||||
/* .hash and/or .gnu.hash MUST come first! */
|
||||
.hash : { *(.hash) }
|
||||
.gnu.hash : { *(.gnu.hash) }
|
||||
. = ALIGN(4096);
|
||||
.eh_frame : { *(.eh_frame) }
|
||||
.eh_frame_hdr : { *(.eh_frame_hdr) }
|
||||
.gcc_except_table : { *(.gcc_except_table*) }
|
||||
. = ALIGN(4096);
|
||||
.text :
|
||||
{
|
||||
_text = .;
|
||||
*(.text)
|
||||
*(.text.*)
|
||||
*(.gnu.linkonce.t.*)
|
||||
*(.plt)
|
||||
. = ALIGN(16);
|
||||
}
|
||||
_etext = .;
|
||||
_text_size = _etext - _text;
|
||||
|
||||
. = ALIGN(4096);
|
||||
.data :
|
||||
{
|
||||
_data = .;
|
||||
*(.got.plt)
|
||||
*(.got)
|
||||
*(.data*)
|
||||
*(.sdata)
|
||||
|
||||
/*
|
||||
* Note that these aren't the using the GNU "CONSTRUCTOR" output section
|
||||
* command, so they don't start with a size. Because of p2align and the
|
||||
* end/END definitions, and the fact that they're mergeable, they can also
|
||||
* have NULLs which aren't guaranteed to be at the end.
|
||||
*/
|
||||
. = ALIGN(16);
|
||||
__init_array_start = .;
|
||||
*(SORT(.init_array.*))
|
||||
*(.init_array)
|
||||
__init_array_end = .;
|
||||
. = ALIGN(16);
|
||||
__CTOR_LIST__ = .;
|
||||
*(SORT(.ctors.*))
|
||||
*(.ctors)
|
||||
__CTOR_END__ = .;
|
||||
. = ALIGN(16);
|
||||
__DTOR_LIST__ = .;
|
||||
*(SORT(.dtors.*))
|
||||
*(.dtors)
|
||||
__DTOR_END__ = .;
|
||||
. = ALIGN(16);
|
||||
__fini_array_start = .;
|
||||
*(SORT(.fini_array.*))
|
||||
*(.fini_array)
|
||||
__fini_array_end = .;
|
||||
|
||||
/* 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 = _edata - _etext;
|
||||
. = ALIGN(4096);
|
||||
.reloc :
|
||||
{
|
||||
KEEP (*(.reloc))
|
||||
}
|
||||
. = ALIGN(4096);
|
||||
_DYNAMIC = .;
|
||||
.dynamic : { *(.dynamic) }
|
||||
. = ALIGN(4096);
|
||||
.rela :
|
||||
{
|
||||
*(.rela.text*)
|
||||
*(.rela.data*)
|
||||
*(.rela.got)
|
||||
*(.rela.dyn)
|
||||
*(.rela.stab)
|
||||
*(.rela.init_array*)
|
||||
*(.rela.fini_array*)
|
||||
*(.rela.ctors*)
|
||||
*(.rela.dtors*)
|
||||
}
|
||||
. = ALIGN(4096);
|
||||
.rela.plt : { *(.rela.plt) }
|
||||
. = ALIGN(4096);
|
||||
.rodata : { *(.rodata*) }
|
||||
. = ALIGN(4096);
|
||||
.dynsym : { *(.dynsym) }
|
||||
. = ALIGN(4096);
|
||||
.dynstr : { *(.dynstr) }
|
||||
. = ALIGN(4096);
|
||||
.ignored.reloc :
|
||||
{
|
||||
*(.rela.reloc)
|
||||
*(.note.GNU-stack)
|
||||
}
|
||||
.comment 0 : { *(.comment) }
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
/* reloc_x86_64.c - position independent x86_64 ELF shared object relocator
|
||||
Copyright (C) 1999 Hewlett-Packard Co.
|
||||
Contributed by David Mosberger <davidm@hpl.hp.com>.
|
||||
Copyright (C) 2005 Intel Co.
|
||||
Contributed by Fenghua Yu <fenghua.yu@intel.com>.
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials
|
||||
provided with the distribution.
|
||||
* Neither the name of Hewlett-Packard Co. nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
BE LIABLE FOR ANYDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
||||
THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <efi.h>
|
||||
#include <efilib.h>
|
||||
|
||||
#include "subst/elf.h"
|
||||
|
||||
EFI_STATUS _relocate (long ldbase, Elf64_Dyn *dyn,
|
||||
EFI_HANDLE image EFI_UNUSED,
|
||||
EFI_SYSTEM_TABLE *systab EFI_UNUSED)
|
||||
{
|
||||
long relsz = 0, relent = 0;
|
||||
Elf64_Rela *rel = 0;
|
||||
unsigned long *addr;
|
||||
int i;
|
||||
|
||||
for (i = 0; dyn[i].d_tag != DT_NULL; ++i) {
|
||||
switch (dyn[i].d_tag) {
|
||||
case DT_RELA:
|
||||
rel = (Elf64_Rela*)
|
||||
((unsigned long)dyn[i].d_un.d_ptr
|
||||
+ ldbase);
|
||||
break;
|
||||
|
||||
case DT_RELASZ:
|
||||
relsz = dyn[i].d_un.d_val;
|
||||
break;
|
||||
|
||||
case DT_RELAENT:
|
||||
relent = dyn[i].d_un.d_val;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!rel && relent == 0)
|
||||
return EFI_SUCCESS;
|
||||
|
||||
if (!rel || relent == 0)
|
||||
return EFI_LOAD_ERROR;
|
||||
|
||||
while (relsz > 0) {
|
||||
/* apply the relocs */
|
||||
switch (ELF64_R_TYPE (rel->r_info)) {
|
||||
case R_X86_64_NONE:
|
||||
break;
|
||||
|
||||
case R_X86_64_RELATIVE:
|
||||
addr = (unsigned long *)
|
||||
(ldbase + rel->r_offset);
|
||||
*addr = ldbase + rel->r_addend;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
rel = (Elf64_Rela*) ((char *) rel + relent);
|
||||
relsz -= relent;
|
||||
}
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
efi.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Public EFI header files
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
//
|
||||
// Build flags on input
|
||||
// EFI32
|
||||
// EFI_DEBUG - Enable debugging code
|
||||
// EFI_NT_EMULATOR - Building for running under NT
|
||||
//
|
||||
|
||||
|
||||
#ifndef _EFI_INCLUDE_
|
||||
#define _EFI_INCLUDE_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#error "Mach-O toolchain isn't supported; please compile with an ELF toolchain from Homebrew"
|
||||
#endif
|
||||
|
||||
// Add a predefined macro to detect usage of the library
|
||||
#define _GNU_EFI
|
||||
#define _GNU_EFI_4_0
|
||||
|
||||
#define EFI_FIRMWARE_VENDOR u"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))
|
||||
|
||||
#if defined(_M_X64) || defined(__x86_64__) || defined(__amd64__)
|
||||
#include "x86_64/efibind.h"
|
||||
#elif defined(_M_IX86) || defined(__i386__)
|
||||
#include "ia32/efibind.h"
|
||||
#elif defined(_M_IA64) || defined(__ia64__)
|
||||
#include "ia64/efibind.h"
|
||||
#elif defined (_M_ARM64) || defined(__aarch64__)
|
||||
#include "aarch64/efibind.h"
|
||||
#elif defined (_M_ARM) || defined(__arm__)
|
||||
#include "arm/efibind.h"
|
||||
#elif defined (_M_MIPS64) || defined(__mips64__) || defined(__mips64)
|
||||
#include "mips64el/efibind.h"
|
||||
#elif defined (__riscv) && __riscv_xlen == 64
|
||||
#include "riscv64/efibind.h"
|
||||
#elif defined (__loongarch64)
|
||||
#include "loongarch64/efibind.h"
|
||||
#else
|
||||
#error Usupported architecture
|
||||
#endif
|
||||
|
||||
#include "eficompiler.h"
|
||||
#include "efidef.h"
|
||||
#include "efidevp.h"
|
||||
#include "efipciio.h"
|
||||
#include "efiprot.h"
|
||||
#include "eficon.h"
|
||||
#include "eficonex.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 "efimp.h"
|
||||
#include "efiip.h"
|
||||
#include "efiudp.h"
|
||||
#include "efitcp.h"
|
||||
#include "efipoint.h"
|
||||
#include "efishell.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,78 @@
|
||||
#ifndef _EFI_NII_H
|
||||
#define _EFI_NII_H
|
||||
|
||||
/*++
|
||||
Copyright (c) 2000 Intel Corporation
|
||||
|
||||
Module name:
|
||||
efi_nii.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Revision history:
|
||||
2000-Feb-18 M(f)J GUID updated.
|
||||
Structure order changed for machine word alignment.
|
||||
Added StringId[4] to structure.
|
||||
|
||||
2000-Feb-14 M(f)J Genesis.
|
||||
--*/
|
||||
|
||||
#define EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_GUID \
|
||||
{ 0xE18541CD, 0xF755, 0x4f73, {0x92, 0x8D, 0x64, 0x3C, 0x8A, 0x79, 0xB2, 0x29} }
|
||||
|
||||
#define EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_REVISION 0x00010000
|
||||
#define EFI_NETWORK_INTERFACE_IDENTIFIER_INTERFACE_REVISION EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_REVISION
|
||||
|
||||
typedef enum {
|
||||
EfiNetworkInterfaceUndi = 1
|
||||
} EFI_NETWORK_INTERFACE_TYPE;
|
||||
|
||||
typedef struct _EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL {
|
||||
|
||||
UINT64 Revision;
|
||||
// Revision of the network interface identifier protocol interface.
|
||||
|
||||
UINT64 ID;
|
||||
// Address of the first byte of the identifying structure for this
|
||||
// network interface. This is set to zero if there is no structure.
|
||||
//
|
||||
// For PXE/UNDI this is the first byte of the !PXE structure.
|
||||
|
||||
UINT64 ImageAddr;
|
||||
// Address of the UNrelocated driver/ROM image. This is set
|
||||
// to zero if there is no driver/ROM image.
|
||||
//
|
||||
// For 16-bit UNDI, this is the first byte of the option ROM in
|
||||
// upper memory.
|
||||
//
|
||||
// For 32/64-bit S/W UNDI, this is the first byte of the EFI ROM
|
||||
// image.
|
||||
//
|
||||
// For H/W UNDI, this is set to zero.
|
||||
|
||||
UINT32 ImageSize;
|
||||
// Size of the UNrelocated driver/ROM image of this network interface.
|
||||
// This is set to zero if there is no driver/ROM image.
|
||||
|
||||
CHAR8 StringId[4];
|
||||
// 4 char ASCII string to go in class identifier (option 60) in DHCP
|
||||
// and Boot Server discover packets.
|
||||
// For EfiNetworkInterfaceUndi this field is "UNDI".
|
||||
// For EfiNetworkInterfaceSnp this field is "SNPN".
|
||||
|
||||
UINT8 Type;
|
||||
UINT8 MajorVer;
|
||||
UINT8 MinorVer;
|
||||
// Information to be placed into the PXE DHCP and Discover packets.
|
||||
// This is the network interface type and version number that will
|
||||
// be placed into DHCP option 94 (client network interface identifier).
|
||||
BOOLEAN Ipv6Supported;
|
||||
UINT8 IfNum; // interface number to be used with pxeid structure
|
||||
} EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL, EFI_NETWORK_INTERFACE_IDENTIFIER_INTERFACE;
|
||||
|
||||
// Note: Because it conflicted with the EDK2 struct name, the
|
||||
// 'EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL' GUID definition,
|
||||
// from older versions of gnu-efi, is now obsoleted.
|
||||
// Use 'EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_GUID' instead.
|
||||
|
||||
#endif // _EFI_NII_H
|
||||
+1743
File diff suppressed because it is too large
Load Diff
+1105
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,77 @@
|
||||
#ifndef _EFICOMPILER_H_
|
||||
#define _EFICOMPILER_H_
|
||||
|
||||
/*++
|
||||
|
||||
Copyright (c) 2016-2024 Pete Batard <pete@akeo.ie>
|
||||
|
||||
Module Name:
|
||||
|
||||
eficompiler.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Compiler specific adjustments
|
||||
|
||||
--*/
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#define EFI_UNUSED __attribute__((__unused__))
|
||||
#else
|
||||
#define EFI_UNUSED
|
||||
#endif
|
||||
|
||||
#if defined(__clang__)
|
||||
#define EFI_NO_TAIL_CALL __attribute__((disable_tail_calls))
|
||||
#elif defined(__GNUC__)
|
||||
#define EFI_NO_TAIL_CALL __attribute__((optimize("no-optimize-sibling-calls")))
|
||||
#else
|
||||
#define EFI_NO_TAIL_CALL
|
||||
#endif
|
||||
|
||||
#if defined(__clang__)
|
||||
#define EFI_OPTNONE __attribute__((optnone))
|
||||
#elif defined(__GNUC__)
|
||||
#define EFI_OPTNONE __attribute__((__optimize__("0")))
|
||||
#else
|
||||
#define EFI_OPTNONE
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#define EFI_ALIGN(x) __attribute__((__aligned__(x)))
|
||||
#elif defined(_MSC_VER)
|
||||
#define EFI_ALIGN(x) __declspec(align(x))
|
||||
#else
|
||||
// Not being able to align is likely to break executables, so report it
|
||||
#error "No alignement directive is defined for this platform"
|
||||
#endif
|
||||
|
||||
#if !defined(ALIGN)
|
||||
#define ALIGN(x) EFI_ALIGN(x)
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#define EFI_NORETURN __attribute__((noreturn))
|
||||
#elif defined(_MSC_VER)
|
||||
#define EFI_NORETURN __declspec(noreturn)
|
||||
#else
|
||||
#define EFI_NORETURN
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#define EFI_NOINLINE __attribute__((noinline))
|
||||
#elif defined(_MSC_VER)
|
||||
#define EFI_NOINLINE __declspec(noinline)
|
||||
#else
|
||||
#define EFI_NOINLINE
|
||||
#endif
|
||||
|
||||
#define EFI_INLINE inline
|
||||
#define EFI_INTERNAL STATIC EFI_INLINE
|
||||
|
||||
/* Also add a catch-all on __attribute__() for MS compilers */
|
||||
#if defined(_MSC_VER)
|
||||
#define __attribute__(x)
|
||||
#endif
|
||||
|
||||
#endif /* _EFICOMPILER_H_ */
|
||||
@@ -0,0 +1,306 @@
|
||||
#ifndef _EFI_CON_H
|
||||
#define _EFI_CON_H
|
||||
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
eficon.h
|
||||
|
||||
Abstract:
|
||||
|
||||
EFI console protocols
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
//
|
||||
// Text output protocol
|
||||
//
|
||||
|
||||
#define EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL_GUID \
|
||||
{ 0x387477c2, 0x69c7, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} }
|
||||
#define SIMPLE_TEXT_OUTPUT_PROTOCOL EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL_GUID
|
||||
|
||||
INTERFACE_DECL(_SIMPLE_TEXT_OUTPUT_INTERFACE);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_TEXT_RESET) (
|
||||
IN struct _SIMPLE_TEXT_OUTPUT_INTERFACE *This,
|
||||
IN BOOLEAN ExtendedVerification
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_TEXT_OUTPUT_STRING) (
|
||||
IN struct _SIMPLE_TEXT_OUTPUT_INTERFACE *This,
|
||||
IN CHAR16 *String
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_TEXT_TEST_STRING) (
|
||||
IN struct _SIMPLE_TEXT_OUTPUT_INTERFACE *This,
|
||||
IN CHAR16 *String
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_TEXT_QUERY_MODE) (
|
||||
IN struct _SIMPLE_TEXT_OUTPUT_INTERFACE *This,
|
||||
IN UINTN ModeNumber,
|
||||
OUT UINTN *Columns,
|
||||
OUT UINTN *Rows
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_TEXT_SET_MODE) (
|
||||
IN struct _SIMPLE_TEXT_OUTPUT_INTERFACE *This,
|
||||
IN UINTN ModeNumber
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_TEXT_SET_ATTRIBUTE) (
|
||||
IN struct _SIMPLE_TEXT_OUTPUT_INTERFACE *This,
|
||||
IN UINTN Attribute
|
||||
);
|
||||
|
||||
#define EFI_BLACK 0x00
|
||||
#define EFI_BLUE 0x01
|
||||
#define EFI_GREEN 0x02
|
||||
#define EFI_CYAN (EFI_BLUE | EFI_GREEN)
|
||||
#define EFI_RED 0x04
|
||||
#define EFI_MAGENTA (EFI_BLUE | EFI_RED)
|
||||
#define EFI_BROWN (EFI_GREEN | EFI_RED)
|
||||
#define EFI_LIGHTGRAY (EFI_BLUE | EFI_GREEN | EFI_RED)
|
||||
#define EFI_BRIGHT 0x08
|
||||
#define EFI_DARKGRAY (EFI_BRIGHT)
|
||||
#define EFI_LIGHTBLUE (EFI_BLUE | EFI_BRIGHT)
|
||||
#define EFI_LIGHTGREEN (EFI_GREEN | EFI_BRIGHT)
|
||||
#define EFI_LIGHTCYAN (EFI_CYAN | EFI_BRIGHT)
|
||||
#define EFI_LIGHTRED (EFI_RED | EFI_BRIGHT)
|
||||
#define EFI_LIGHTMAGENTA (EFI_MAGENTA | EFI_BRIGHT)
|
||||
#define EFI_YELLOW (EFI_BROWN | EFI_BRIGHT)
|
||||
#define EFI_WHITE (EFI_BLUE | EFI_GREEN | EFI_RED | EFI_BRIGHT)
|
||||
|
||||
#define EFI_TEXT_ATTR(f,b) ((f) | ((b) << 4))
|
||||
|
||||
#define EFI_BACKGROUND_BLACK 0x00
|
||||
#define EFI_BACKGROUND_BLUE 0x10
|
||||
#define EFI_BACKGROUND_GREEN 0x20
|
||||
#define EFI_BACKGROUND_CYAN (EFI_BACKGROUND_BLUE | EFI_BACKGROUND_GREEN)
|
||||
#define EFI_BACKGROUND_RED 0x40
|
||||
#define EFI_BACKGROUND_MAGENTA (EFI_BACKGROUND_BLUE | EFI_BACKGROUND_RED)
|
||||
#define EFI_BACKGROUND_BROWN (EFI_BACKGROUND_GREEN | EFI_BACKGROUND_RED)
|
||||
#define EFI_BACKGROUND_LIGHTGRAY (EFI_BACKGROUND_BLUE | EFI_BACKGROUND_GREEN | EFI_BACKGROUND_RED)
|
||||
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_TEXT_CLEAR_SCREEN) (
|
||||
IN struct _SIMPLE_TEXT_OUTPUT_INTERFACE *This
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_TEXT_SET_CURSOR_POSITION) (
|
||||
IN struct _SIMPLE_TEXT_OUTPUT_INTERFACE *This,
|
||||
IN UINTN Column,
|
||||
IN UINTN Row
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_TEXT_ENABLE_CURSOR) (
|
||||
IN struct _SIMPLE_TEXT_OUTPUT_INTERFACE *This,
|
||||
IN BOOLEAN Enable
|
||||
);
|
||||
|
||||
typedef struct {
|
||||
INT32 MaxMode;
|
||||
// current settings
|
||||
INT32 Mode;
|
||||
INT32 Attribute;
|
||||
INT32 CursorColumn;
|
||||
INT32 CursorRow;
|
||||
BOOLEAN CursorVisible;
|
||||
} SIMPLE_TEXT_OUTPUT_MODE;
|
||||
|
||||
typedef struct _SIMPLE_TEXT_OUTPUT_INTERFACE {
|
||||
EFI_TEXT_RESET Reset;
|
||||
|
||||
EFI_TEXT_OUTPUT_STRING OutputString;
|
||||
EFI_TEXT_TEST_STRING TestString;
|
||||
|
||||
EFI_TEXT_QUERY_MODE QueryMode;
|
||||
EFI_TEXT_SET_MODE SetMode;
|
||||
EFI_TEXT_SET_ATTRIBUTE SetAttribute;
|
||||
|
||||
EFI_TEXT_CLEAR_SCREEN ClearScreen;
|
||||
EFI_TEXT_SET_CURSOR_POSITION SetCursorPosition;
|
||||
EFI_TEXT_ENABLE_CURSOR EnableCursor;
|
||||
|
||||
// Current mode
|
||||
SIMPLE_TEXT_OUTPUT_MODE *Mode;
|
||||
} SIMPLE_TEXT_OUTPUT_INTERFACE, EFI_SIMPLE_TEXT_OUT_PROTOCOL;
|
||||
|
||||
//
|
||||
// Define's for required EFI Unicode Box Draw character
|
||||
//
|
||||
|
||||
#define BOXDRAW_HORIZONTAL 0x2500
|
||||
#define BOXDRAW_VERTICAL 0x2502
|
||||
#define BOXDRAW_DOWN_RIGHT 0x250c
|
||||
#define BOXDRAW_DOWN_LEFT 0x2510
|
||||
#define BOXDRAW_UP_RIGHT 0x2514
|
||||
#define BOXDRAW_UP_LEFT 0x2518
|
||||
#define BOXDRAW_VERTICAL_RIGHT 0x251c
|
||||
#define BOXDRAW_VERTICAL_LEFT 0x2524
|
||||
#define BOXDRAW_DOWN_HORIZONTAL 0x252c
|
||||
#define BOXDRAW_UP_HORIZONTAL 0x2534
|
||||
#define BOXDRAW_VERTICAL_HORIZONTAL 0x253c
|
||||
|
||||
#define BOXDRAW_DOUBLE_HORIZONTAL 0x2550
|
||||
#define BOXDRAW_DOUBLE_VERTICAL 0x2551
|
||||
#define BOXDRAW_DOWN_RIGHT_DOUBLE 0x2552
|
||||
#define BOXDRAW_DOWN_DOUBLE_RIGHT 0x2553
|
||||
#define BOXDRAW_DOUBLE_DOWN_RIGHT 0x2554
|
||||
|
||||
#define BOXDRAW_DOWN_LEFT_DOUBLE 0x2555
|
||||
#define BOXDRAW_DOWN_DOUBLE_LEFT 0x2556
|
||||
#define BOXDRAW_DOUBLE_DOWN_LEFT 0x2557
|
||||
|
||||
#define BOXDRAW_UP_RIGHT_DOUBLE 0x2558
|
||||
#define BOXDRAW_UP_DOUBLE_RIGHT 0x2559
|
||||
#define BOXDRAW_DOUBLE_UP_RIGHT 0x255a
|
||||
|
||||
#define BOXDRAW_UP_LEFT_DOUBLE 0x255b
|
||||
#define BOXDRAW_UP_DOUBLE_LEFT 0x255c
|
||||
#define BOXDRAW_DOUBLE_UP_LEFT 0x255d
|
||||
|
||||
#define BOXDRAW_VERTICAL_RIGHT_DOUBLE 0x255e
|
||||
#define BOXDRAW_VERTICAL_DOUBLE_RIGHT 0x255f
|
||||
#define BOXDRAW_DOUBLE_VERTICAL_RIGHT 0x2560
|
||||
|
||||
#define BOXDRAW_VERTICAL_LEFT_DOUBLE 0x2561
|
||||
#define BOXDRAW_VERTICAL_DOUBLE_LEFT 0x2562
|
||||
#define BOXDRAW_DOUBLE_VERTICAL_LEFT 0x2563
|
||||
|
||||
#define BOXDRAW_DOWN_HORIZONTAL_DOUBLE 0x2564
|
||||
#define BOXDRAW_DOWN_DOUBLE_HORIZONTAL 0x2565
|
||||
#define BOXDRAW_DOUBLE_DOWN_HORIZONTAL 0x2566
|
||||
|
||||
#define BOXDRAW_UP_HORIZONTAL_DOUBLE 0x2567
|
||||
#define BOXDRAW_UP_DOUBLE_HORIZONTAL 0x2568
|
||||
#define BOXDRAW_DOUBLE_UP_HORIZONTAL 0x2569
|
||||
|
||||
#define BOXDRAW_VERTICAL_HORIZONTAL_DOUBLE 0x256a
|
||||
#define BOXDRAW_VERTICAL_DOUBLE_HORIZONTAL 0x256b
|
||||
#define BOXDRAW_DOUBLE_VERTICAL_HORIZONTAL 0x256c
|
||||
|
||||
//
|
||||
// EFI Required Block Elements Code Chart
|
||||
//
|
||||
|
||||
#define BLOCKELEMENT_FULL_BLOCK 0x2588
|
||||
#define BLOCKELEMENT_LIGHT_SHADE 0x2591
|
||||
//
|
||||
// EFI Required Geometric Shapes Code Chart
|
||||
//
|
||||
|
||||
#define GEOMETRICSHAPE_UP_TRIANGLE 0x25b2
|
||||
#define GEOMETRICSHAPE_RIGHT_TRIANGLE 0x25ba
|
||||
#define GEOMETRICSHAPE_DOWN_TRIANGLE 0x25bc
|
||||
#define GEOMETRICSHAPE_LEFT_TRIANGLE 0x25c4
|
||||
|
||||
//
|
||||
// EFI Required Arrow shapes
|
||||
//
|
||||
|
||||
#define ARROW_UP 0x2191
|
||||
#define ARROW_DOWN 0x2193
|
||||
|
||||
//
|
||||
// Text input protocol
|
||||
//
|
||||
|
||||
#define EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID \
|
||||
{ 0x387477c1, 0x69c7, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} }
|
||||
#define SIMPLE_TEXT_INPUT_PROTOCOL EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID
|
||||
|
||||
INTERFACE_DECL(_SIMPLE_INPUT_INTERFACE);
|
||||
|
||||
typedef struct {
|
||||
UINT16 ScanCode;
|
||||
CHAR16 UnicodeChar;
|
||||
} EFI_INPUT_KEY;
|
||||
|
||||
//
|
||||
// Baseline unicode control chars
|
||||
//
|
||||
|
||||
#define CHAR_NULL 0x0000
|
||||
#define CHAR_BACKSPACE 0x0008
|
||||
#define CHAR_TAB 0x0009
|
||||
#define CHAR_LINEFEED 0x000A
|
||||
#define CHAR_CARRIAGE_RETURN 0x000D
|
||||
|
||||
//
|
||||
// Scan codes for base line keys
|
||||
//
|
||||
|
||||
#define SCAN_NULL 0x0000
|
||||
#define SCAN_UP 0x0001
|
||||
#define SCAN_DOWN 0x0002
|
||||
#define SCAN_RIGHT 0x0003
|
||||
#define SCAN_LEFT 0x0004
|
||||
#define SCAN_HOME 0x0005
|
||||
#define SCAN_END 0x0006
|
||||
#define SCAN_INSERT 0x0007
|
||||
#define SCAN_DELETE 0x0008
|
||||
#define SCAN_PAGE_UP 0x0009
|
||||
#define SCAN_PAGE_DOWN 0x000A
|
||||
#define SCAN_F1 0x000B
|
||||
#define SCAN_F2 0x000C
|
||||
#define SCAN_F3 0x000D
|
||||
#define SCAN_F4 0x000E
|
||||
#define SCAN_F5 0x000F
|
||||
#define SCAN_F6 0x0010
|
||||
#define SCAN_F7 0x0011
|
||||
#define SCAN_F8 0x0012
|
||||
#define SCAN_F9 0x0013
|
||||
#define SCAN_F10 0x0014
|
||||
#define SCAN_F11 0x0015
|
||||
#define SCAN_F12 0x0016
|
||||
#define SCAN_ESC 0x0017
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_INPUT_RESET) (
|
||||
IN struct _SIMPLE_INPUT_INTERFACE *This,
|
||||
IN BOOLEAN ExtendedVerification
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_INPUT_READ_KEY) (
|
||||
IN struct _SIMPLE_INPUT_INTERFACE *This,
|
||||
OUT EFI_INPUT_KEY *Key
|
||||
);
|
||||
|
||||
typedef struct _SIMPLE_INPUT_INTERFACE {
|
||||
EFI_INPUT_RESET Reset;
|
||||
EFI_INPUT_READ_KEY ReadKeyStroke;
|
||||
EFI_EVENT WaitForKey;
|
||||
} SIMPLE_INPUT_INTERFACE, EFI_SIMPLE_TEXT_IN_PROTOCOL;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
#ifndef _EFI_CONEX_H
|
||||
#define _EFI_CONEX_H
|
||||
|
||||
/*++
|
||||
|
||||
Copyright (c) 2020 Kagurazaka Kotori <kagurazakakotori@gmail.com>
|
||||
|
||||
Module Name:
|
||||
|
||||
eficonex.h
|
||||
|
||||
Abstract:
|
||||
|
||||
EFI console extension protocols
|
||||
|
||||
--*/
|
||||
|
||||
//
|
||||
// Simple Text Input Ex Protocol
|
||||
//
|
||||
|
||||
#define EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID \
|
||||
{ 0xdd9e7534, 0x7762, 0x4698, {0x8c, 0x14, 0xf5, 0x85, 0x17, 0xa6, 0x25, 0xaa} }
|
||||
|
||||
INTERFACE_DECL(_EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL);
|
||||
|
||||
typedef UINT8 EFI_KEY_TOGGLE_STATE;
|
||||
|
||||
typedef struct EFI_KEY_STATE {
|
||||
UINT32 KeyShiftState;
|
||||
EFI_KEY_TOGGLE_STATE KeyToggleState;
|
||||
} EFI_KEY_STATE;
|
||||
|
||||
typedef struct {
|
||||
EFI_INPUT_KEY Key;
|
||||
EFI_KEY_STATE KeyState;
|
||||
} EFI_KEY_DATA;
|
||||
|
||||
// Shift states
|
||||
#define EFI_SHIFT_STATE_VALID 0x80000000
|
||||
#define EFI_RIGHT_SHIFT_PRESSED 0x00000001
|
||||
#define EFI_LEFT_SHIFT_PRESSED 0x00000002
|
||||
#define EFI_RIGHT_CONTROL_PRESSED 0x00000004
|
||||
#define EFI_LEFT_CONTROL_PRESSED 0x00000008
|
||||
#define EFI_RIGHT_ALT_PRESSED 0x00000010
|
||||
#define EFI_LEFT_ALT_PRESSED 0x00000020
|
||||
#define EFI_RIGHT_LOGO_PRESSED 0x00000040
|
||||
#define EFI_LEFT_LOGO_PRESSED 0x00000080
|
||||
#define EFI_MENU_KEY_PRESSED 0x00000100
|
||||
#define EFI_SYS_REQ_PRESSED 0x00000200
|
||||
|
||||
// Toggle states
|
||||
#define EFI_TOGGLE_STATE_VALID 0x80
|
||||
#define EFI_KEY_STATE_EXPOSED 0x40
|
||||
#define EFI_SCROLL_LOCK_ACTIVE 0x01
|
||||
#define EFI_NUM_LOCK_ACTIVE 0x02
|
||||
#define EFI_CAPS_LOCK_ACTIVE 0x04
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_INPUT_RESET_EX) (
|
||||
IN struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
|
||||
IN BOOLEAN ExtendedVerification
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_INPUT_READ_KEY_EX) (
|
||||
IN struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
|
||||
OUT EFI_KEY_DATA *KeyData
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SET_STATE) (
|
||||
IN struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
|
||||
IN EFI_KEY_TOGGLE_STATE *KeyToggleState
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_KEY_NOTIFY_FUNCTION) (
|
||||
IN EFI_KEY_DATA *KeyData
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_REGISTER_KEYSTROKE_NOTIFY) (
|
||||
IN struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
|
||||
IN EFI_KEY_DATA *KeyData,
|
||||
IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction,
|
||||
OUT VOID **NotifyHandle
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_UNREGISTER_KEYSTROKE_NOTIFY) (
|
||||
IN struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
|
||||
IN VOID *NotificationHandle
|
||||
);
|
||||
|
||||
typedef struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL{
|
||||
EFI_INPUT_RESET_EX Reset;
|
||||
EFI_INPUT_READ_KEY_EX ReadKeyStrokeEx;
|
||||
EFI_EVENT WaitForKeyEx;
|
||||
EFI_SET_STATE SetState;
|
||||
EFI_REGISTER_KEYSTROKE_NOTIFY RegisterKeyNotify;
|
||||
EFI_UNREGISTER_KEYSTROKE_NOTIFY UnregisterKeyNotify;
|
||||
} EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL;
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,620 @@
|
||||
#ifndef _EFI_DEBUG_H
|
||||
#define _EFI_DEBUG_H
|
||||
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
efidebug.h
|
||||
|
||||
Abstract:
|
||||
|
||||
EFI library debug functions
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
extern UINTN EFIDebug;
|
||||
|
||||
#if EFI_DEBUG
|
||||
|
||||
#define DBGASSERT(a) DbgAssert(__FILE__, __LINE__, #a)
|
||||
#define DEBUG(a) DbgPrint a
|
||||
|
||||
#else
|
||||
|
||||
#define DBGASSERT(a)
|
||||
#define DEBUG(a)
|
||||
|
||||
#endif
|
||||
|
||||
#if EFI_DEBUG_CLEAR_MEMORY
|
||||
|
||||
#define DBGSETMEM(a,l) SetMem(a,l,(CHAR8)BAD_POINTER)
|
||||
|
||||
#else
|
||||
|
||||
#define DBGSETMEM(a,l)
|
||||
|
||||
#endif
|
||||
|
||||
#define D_INIT 0x00000001 // Initialization style messages
|
||||
#define D_WARN 0x00000002 // Warnings
|
||||
#define D_LOAD 0x00000004 // Load events
|
||||
#define D_FS 0x00000008 // EFI File system
|
||||
#define D_POOL 0x00000010 // Alloc & Free's
|
||||
#define D_PAGE 0x00000020 // Alloc & Free's
|
||||
#define D_INFO 0x00000040 // Verbose
|
||||
#define D_VAR 0x00000100 // Variable
|
||||
#define D_PARSE 0x00000200 // Command parsing
|
||||
#define D_BM 0x00000400 // Boot manager
|
||||
#define D_BLKIO 0x00001000 // BlkIo Driver
|
||||
#define D_BLKIO_ULTRA 0x00002000 // BlkIo Driver
|
||||
#define D_NET 0x00004000 // SNI Driver
|
||||
#define D_NET_ULTRA 0x00008000 // SNI Driver
|
||||
#define D_TXTIN 0x00010000 // Simple Input Driver
|
||||
#define D_TXTOUT 0x00020000 // Simple Text Output Driver
|
||||
#define D_ERROR_ATA 0x00040000 // ATA error messages
|
||||
#define D_ERROR 0x80000000 // Error
|
||||
|
||||
#define D_RESERVED 0x7fffC880 // Bits not reserved above
|
||||
|
||||
//
|
||||
// Current Debug level of the system, value of EFIDebug
|
||||
//
|
||||
//#define EFI_DBUG_MASK (D_ERROR | D_WARN | D_LOAD | D_BLKIO | D_INIT)
|
||||
#define EFI_DBUG_MASK (D_ERROR)
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
#if EFI_DEBUG
|
||||
|
||||
#define ASSERT(a) if(!(a)) DBGASSERT(a)
|
||||
#define ASSERT_LOCKED(l) if(!(l)->Lock) DBGASSERT(l not locked)
|
||||
#define ASSERT_STRUCT(p,t) DBGASSERT(t not structure), p
|
||||
|
||||
#else
|
||||
|
||||
#define ASSERT(a)
|
||||
#define ASSERT_LOCKED(l)
|
||||
#define ASSERT_STRUCT(p,t)
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// Prototypes
|
||||
//
|
||||
|
||||
INTN
|
||||
DbgAssert (
|
||||
CONST CHAR8 *file,
|
||||
INTN lineno,
|
||||
CONST CHAR8 *string
|
||||
);
|
||||
|
||||
INTN
|
||||
DbgPrint (
|
||||
INTN mask,
|
||||
CONST CHAR8 *format,
|
||||
...
|
||||
);
|
||||
|
||||
//
|
||||
// Instruction Set Architectures definitions for debuggers
|
||||
//
|
||||
|
||||
typedef INTN EFI_EXCEPTION_TYPE;
|
||||
|
||||
// IA32
|
||||
#define EXCEPT_IA32_DIVIDE_ERROR 0
|
||||
#define EXCEPT_IA32_DEBUG 1
|
||||
#define EXCEPT_IA32_NMI 2
|
||||
#define EXCEPT_IA32_BREAKPOINT 3
|
||||
#define EXCEPT_IA32_OVERFLOW 4
|
||||
#define EXCEPT_IA32_BOUND 5
|
||||
#define EXCEPT_IA32_INVALID_OPCODE 6
|
||||
#define EXCEPT_IA32_DOUBLE_FAULT 8
|
||||
#define EXCEPT_IA32_INVALID_TSS 10
|
||||
#define EXCEPT_IA32_SEG_NOT_PRESENT 11
|
||||
#define EXCEPT_IA32_STACK_FAULT 12
|
||||
#define EXCEPT_IA32_GP_FAULT 13
|
||||
#define EXCEPT_IA32_PAGE_FAULT 14
|
||||
#define EXCEPT_IA32_FP_ERROR 16
|
||||
#define EXCEPT_IA32_ALIGNMENT_CHECK 17
|
||||
#define EXCEPT_IA32_MACHINE_CHECK 18
|
||||
#define EXCEPT_IA32_SIMD 19
|
||||
|
||||
typedef struct {
|
||||
UINT16 Fcw;
|
||||
UINT16 Fsw;
|
||||
UINT16 Ftw;
|
||||
UINT16 Opcode;
|
||||
UINT32 Eip;
|
||||
UINT16 Cs;
|
||||
UINT16 Reserved1;
|
||||
UINT32 DataOffset;
|
||||
UINT16 Ds;
|
||||
UINT8 Reserved2[10];
|
||||
UINT8 St0Mm0[10], Reserved3[6];
|
||||
UINT8 St1Mm1[10], Reserved4[6];
|
||||
UINT8 St2Mm2[10], Reserved5[6];
|
||||
UINT8 St3Mm3[10], Reserved6[6];
|
||||
UINT8 St4Mm4[10], Reserved7[6];
|
||||
UINT8 St5Mm5[10], Reserved8[6];
|
||||
UINT8 St6Mm6[10], Reserved9[6];
|
||||
UINT8 St7Mm7[10], Reserved10[6];
|
||||
UINT8 Xmm0[16];
|
||||
UINT8 Xmm1[16];
|
||||
UINT8 Xmm2[16];
|
||||
UINT8 Xmm3[16];
|
||||
UINT8 Xmm4[16];
|
||||
UINT8 Xmm5[16];
|
||||
UINT8 Xmm6[16];
|
||||
UINT8 Xmm7[16];
|
||||
UINT8 Reserved11[14 * 16];
|
||||
} EFI_FX_SAVE_STATE_IA32;
|
||||
|
||||
typedef struct {
|
||||
UINT32 ExceptionData;
|
||||
EFI_FX_SAVE_STATE_IA32 FxSaveState;
|
||||
UINT32 Dr0;
|
||||
UINT32 Dr1;
|
||||
UINT32 Dr2;
|
||||
UINT32 Dr3;
|
||||
UINT32 Dr6;
|
||||
UINT32 Dr7;
|
||||
UINT32 Cr0;
|
||||
UINT32 Cr1;
|
||||
UINT32 Cr2;
|
||||
UINT32 Cr3;
|
||||
UINT32 Cr4;
|
||||
UINT32 Eflags;
|
||||
UINT32 Ldtr;
|
||||
UINT32 Tr;
|
||||
UINT32 Gdtr[2];
|
||||
UINT32 Idtr[2];
|
||||
UINT32 Eip;
|
||||
UINT32 Gs;
|
||||
UINT32 Fs;
|
||||
UINT32 Es;
|
||||
UINT32 Ds;
|
||||
UINT32 Cs;
|
||||
UINT32 Ss;
|
||||
UINT32 Edi;
|
||||
UINT32 Esi;
|
||||
UINT32 Ebp;
|
||||
UINT32 Esp;
|
||||
UINT32 Ebx;
|
||||
UINT32 Edx;
|
||||
UINT32 Ecx;
|
||||
UINT32 Eax;
|
||||
} EFI_SYSTEM_CONTEXT_IA32;
|
||||
|
||||
// X64
|
||||
#define EXCEPT_X64_DIVIDE_ERROR 0
|
||||
#define EXCEPT_X64_DEBUG 1
|
||||
#define EXCEPT_X64_NMI 2
|
||||
#define EXCEPT_X64_BREAKPOINT 3
|
||||
#define EXCEPT_X64_OVERFLOW 4
|
||||
#define EXCEPT_X64_BOUND 5
|
||||
#define EXCEPT_X64_INVALID_OPCODE 6
|
||||
#define EXCEPT_X64_DOUBLE_FAULT 8
|
||||
#define EXCEPT_X64_INVALID_TSS 10
|
||||
#define EXCEPT_X64_SEG_NOT_PRESENT 11
|
||||
#define EXCEPT_X64_STACK_FAULT 12
|
||||
#define EXCEPT_X64_GP_FAULT 13
|
||||
#define EXCEPT_X64_PAGE_FAULT 14
|
||||
#define EXCEPT_X64_FP_ERROR 16
|
||||
#define EXCEPT_X64_ALIGNMENT_CHECK 17
|
||||
#define EXCEPT_X64_MACHINE_CHECK 18
|
||||
#define EXCEPT_X64_SIMD 19
|
||||
|
||||
typedef struct {
|
||||
UINT16 Fcw;
|
||||
UINT16 Fsw;
|
||||
UINT16 Ftw;
|
||||
UINT16 Opcode;
|
||||
UINT64 Rip;
|
||||
UINT64 DataOffset;
|
||||
UINT8 Reserved1[8];
|
||||
UINT8 St0Mm0[10], Reserved2[6];
|
||||
UINT8 St1Mm1[10], Reserved3[6];
|
||||
UINT8 St2Mm2[10], Reserved4[6];
|
||||
UINT8 St3Mm3[10], Reserved5[6];
|
||||
UINT8 St4Mm4[10], Reserved6[6];
|
||||
UINT8 St5Mm5[10], Reserved7[6];
|
||||
UINT8 St6Mm6[10], Reserved8[6];
|
||||
UINT8 St7Mm7[10], Reserved9[6];
|
||||
UINT8 Xmm0[16];
|
||||
UINT8 Xmm1[16];
|
||||
UINT8 Xmm2[16];
|
||||
UINT8 Xmm3[16];
|
||||
UINT8 Xmm4[16];
|
||||
UINT8 Xmm5[16];
|
||||
UINT8 Xmm6[16];
|
||||
UINT8 Xmm7[16];
|
||||
UINT8 Reserved11[14 * 16];
|
||||
} EFI_FX_SAVE_STATE_X64;
|
||||
|
||||
typedef struct {
|
||||
UINT64 ExceptionData;
|
||||
EFI_FX_SAVE_STATE_X64 FxSaveState;
|
||||
UINT64 Dr0;
|
||||
UINT64 Dr1;
|
||||
UINT64 Dr2;
|
||||
UINT64 Dr3;
|
||||
UINT64 Dr6;
|
||||
UINT64 Dr7;
|
||||
UINT64 Cr0;
|
||||
UINT64 Cr1;
|
||||
UINT64 Cr2;
|
||||
UINT64 Cr3;
|
||||
UINT64 Cr4;
|
||||
UINT64 Cr8;
|
||||
UINT64 Rflags;
|
||||
UINT64 Ldtr;
|
||||
UINT64 Tr;
|
||||
UINT64 Gdtr[2];
|
||||
UINT64 Idtr[2];
|
||||
UINT64 Rip;
|
||||
UINT64 Gs;
|
||||
UINT64 Fs;
|
||||
UINT64 Es;
|
||||
UINT64 Ds;
|
||||
UINT64 Cs;
|
||||
UINT64 Ss;
|
||||
UINT64 Rdi;
|
||||
UINT64 Rsi;
|
||||
UINT64 Rbp;
|
||||
UINT64 Rsp;
|
||||
UINT64 Rbx;
|
||||
UINT64 Rdx;
|
||||
UINT64 Rcx;
|
||||
UINT64 Rax;
|
||||
UINT64 R8;
|
||||
UINT64 R9;
|
||||
UINT64 R10;
|
||||
UINT64 R11;
|
||||
UINT64 R12;
|
||||
UINT64 R13;
|
||||
UINT64 R14;
|
||||
UINT64 R15;
|
||||
} EFI_SYSTEM_CONTEXT_X64;
|
||||
|
||||
/// IA64
|
||||
#define EXCEPT_IPF_VHTP_TRANSLATION 0
|
||||
#define EXCEPT_IPF_INSTRUCTION_TLB 1
|
||||
#define EXCEPT_IPF_DATA_TLB 2
|
||||
#define EXCEPT_IPF_ALT_INSTRUCTION_TLB 3
|
||||
#define EXCEPT_IPF_ALT_DATA_TLB 4
|
||||
#define EXCEPT_IPF_DATA_NESTED_TLB 5
|
||||
#define EXCEPT_IPF_INSTRUCTION_KEY_MISSED 6
|
||||
#define EXCEPT_IPF_DATA_KEY_MISSED 7
|
||||
#define EXCEPT_IPF_DIRTY_BIT 8
|
||||
#define EXCEPT_IPF_INSTRUCTION_ACCESS_BIT 9
|
||||
#define EXCEPT_IPF_DATA_ACCESS_BIT 10
|
||||
#define EXCEPT_IPF_BREAKPOINT 11
|
||||
#define EXCEPT_IPF_EXTERNAL_INTERRUPT 12
|
||||
#define EXCEPT_IPF_PAGE_NOT_PRESENT 20
|
||||
#define EXCEPT_IPF_KEY_PERMISSION 21
|
||||
#define EXCEPT_IPF_INSTRUCTION_ACCESS_RIGHTS 22
|
||||
#define EXCEPT_IPF_DATA_ACCESS_RIGHTS 23
|
||||
#define EXCEPT_IPF_GENERAL_EXCEPTION 24
|
||||
#define EXCEPT_IPF_DISABLED_FP_REGISTER 25
|
||||
#define EXCEPT_IPF_NAT_CONSUMPTION 26
|
||||
#define EXCEPT_IPF_SPECULATION 27
|
||||
#define EXCEPT_IPF_DEBUG 29
|
||||
#define EXCEPT_IPF_UNALIGNED_REFERENCE 30
|
||||
#define EXCEPT_IPF_UNSUPPORTED_DATA_REFERENCE 31
|
||||
#define EXCEPT_IPF_FP_FAULT 32
|
||||
#define EXCEPT_IPF_FP_TRAP 33
|
||||
#define EXCEPT_IPF_LOWER_PRIVILEGE_TRANSFER_TRAP 34
|
||||
#define EXCEPT_IPF_TAKEN_BRANCH 35
|
||||
#define EXCEPT_IPF_SINGLE_STEP 36
|
||||
#define EXCEPT_IPF_IA32_EXCEPTION 45
|
||||
#define EXCEPT_IPF_IA32_INTERCEPT 46
|
||||
#define EXCEPT_IPF_IA32_INTERRUPT 47
|
||||
|
||||
typedef struct {
|
||||
UINT64 Reserved;
|
||||
UINT64 R1;
|
||||
UINT64 R2;
|
||||
UINT64 R3;
|
||||
UINT64 R4;
|
||||
UINT64 R5;
|
||||
UINT64 R6;
|
||||
UINT64 R7;
|
||||
UINT64 R8;
|
||||
UINT64 R9;
|
||||
UINT64 R10;
|
||||
UINT64 R11;
|
||||
UINT64 R12;
|
||||
UINT64 R13;
|
||||
UINT64 R14;
|
||||
UINT64 R15;
|
||||
UINT64 R16;
|
||||
UINT64 R17;
|
||||
UINT64 R18;
|
||||
UINT64 R19;
|
||||
UINT64 R20;
|
||||
UINT64 R21;
|
||||
UINT64 R22;
|
||||
UINT64 R23;
|
||||
UINT64 R24;
|
||||
UINT64 R25;
|
||||
UINT64 R26;
|
||||
UINT64 R27;
|
||||
UINT64 R28;
|
||||
UINT64 R29;
|
||||
UINT64 R30;
|
||||
UINT64 R31;
|
||||
UINT64 F2[2];
|
||||
UINT64 F3[2];
|
||||
UINT64 F4[2];
|
||||
UINT64 F5[2];
|
||||
UINT64 F6[2];
|
||||
UINT64 F7[2];
|
||||
UINT64 F8[2];
|
||||
UINT64 F9[2];
|
||||
UINT64 F10[2];
|
||||
UINT64 F11[2];
|
||||
UINT64 F12[2];
|
||||
UINT64 F13[2];
|
||||
UINT64 F14[2];
|
||||
UINT64 F15[2];
|
||||
UINT64 F16[2];
|
||||
UINT64 F17[2];
|
||||
UINT64 F18[2];
|
||||
UINT64 F19[2];
|
||||
UINT64 F20[2];
|
||||
UINT64 F21[2];
|
||||
UINT64 F22[2];
|
||||
UINT64 F23[2];
|
||||
UINT64 F24[2];
|
||||
UINT64 F25[2];
|
||||
UINT64 F26[2];
|
||||
UINT64 F27[2];
|
||||
UINT64 F28[2];
|
||||
UINT64 F29[2];
|
||||
UINT64 F30[2];
|
||||
UINT64 F31[2];
|
||||
UINT64 Pr;
|
||||
UINT64 B0;
|
||||
UINT64 B1;
|
||||
UINT64 B2;
|
||||
UINT64 B3;
|
||||
UINT64 B4;
|
||||
UINT64 B5;
|
||||
UINT64 B6;
|
||||
UINT64 B7;
|
||||
UINT64 ArRsc;
|
||||
UINT64 ArBsp;
|
||||
UINT64 ArBspstore;
|
||||
UINT64 ArRnat;
|
||||
UINT64 ArFcr;
|
||||
UINT64 ArEflag;
|
||||
UINT64 ArCsd;
|
||||
UINT64 ArSsd;
|
||||
UINT64 ArCflg;
|
||||
UINT64 ArFsr;
|
||||
UINT64 ArFir;
|
||||
UINT64 ArFdr;
|
||||
UINT64 ArCcv;
|
||||
UINT64 ArUnat;
|
||||
UINT64 ArFpsr;
|
||||
UINT64 ArPfs;
|
||||
UINT64 ArLc;
|
||||
UINT64 ArEc;
|
||||
UINT64 CrDcr;
|
||||
UINT64 CrItm;
|
||||
UINT64 CrIva;
|
||||
UINT64 CrPta;
|
||||
UINT64 CrIpsr;
|
||||
UINT64 CrIsr;
|
||||
UINT64 CrIip;
|
||||
UINT64 CrIfa;
|
||||
UINT64 CrItir;
|
||||
UINT64 CrIipa;
|
||||
UINT64 CrIfs;
|
||||
UINT64 CrIim;
|
||||
UINT64 CrIha;
|
||||
UINT64 Dbr0;
|
||||
UINT64 Dbr1;
|
||||
UINT64 Dbr2;
|
||||
UINT64 Dbr3;
|
||||
UINT64 Dbr4;
|
||||
UINT64 Dbr5;
|
||||
UINT64 Dbr6;
|
||||
UINT64 Dbr7;
|
||||
UINT64 Ibr0;
|
||||
UINT64 Ibr1;
|
||||
UINT64 Ibr2;
|
||||
UINT64 Ibr3;
|
||||
UINT64 Ibr4;
|
||||
UINT64 Ibr5;
|
||||
UINT64 Ibr6;
|
||||
UINT64 Ibr7;
|
||||
UINT64 IntNat;
|
||||
} EFI_SYSTEM_CONTEXT_IPF;
|
||||
|
||||
// EBC
|
||||
#define EXCEPT_EBC_UNDEFINED 0
|
||||
#define EXCEPT_EBC_DIVIDE_ERROR 1
|
||||
#define EXCEPT_EBC_DEBUG 2
|
||||
#define EXCEPT_EBC_BREAKPOINT 3
|
||||
#define EXCEPT_EBC_OVERFLOW 4
|
||||
#define EXCEPT_EBC_INVALID_OPCODE 5
|
||||
#define EXCEPT_EBC_STACK_FAULT 6
|
||||
#define EXCEPT_EBC_ALIGNMENT_CHECK 7
|
||||
#define EXCEPT_EBC_INSTRUCTION_ENCODING 8
|
||||
#define EXCEPT_EBC_BAD_BREAK 9
|
||||
#define EXCEPT_EBC_STEP 10
|
||||
#define MAX_EBC_EXCEPTION EXCEPT_EBC_STEP
|
||||
|
||||
typedef struct {
|
||||
UINT64 R0;
|
||||
UINT64 R1;
|
||||
UINT64 R2;
|
||||
UINT64 R3;
|
||||
UINT64 R4;
|
||||
UINT64 R5;
|
||||
UINT64 R6;
|
||||
UINT64 R7;
|
||||
UINT64 Flags;
|
||||
UINT64 ControlFlags;
|
||||
UINT64 Ip;
|
||||
} EFI_SYSTEM_CONTEXT_EBC;
|
||||
|
||||
// ARM
|
||||
#define EXCEPT_ARM_RESET 0
|
||||
#define EXCEPT_ARM_UNDEFINED_INSTRUCTION 1
|
||||
#define EXCEPT_ARM_SOFTWARE_INTERRUPT 2
|
||||
#define EXCEPT_ARM_PREFETCH_ABORT 3
|
||||
#define EXCEPT_ARM_DATA_ABORT 4
|
||||
#define EXCEPT_ARM_RESERVED 5
|
||||
#define EXCEPT_ARM_IRQ 6
|
||||
#define EXCEPT_ARM_FIQ 7
|
||||
#define MAX_ARM_EXCEPTION EXCEPT_ARM_FIQ
|
||||
|
||||
typedef struct {
|
||||
UINT32 R0;
|
||||
UINT32 R1;
|
||||
UINT32 R2;
|
||||
UINT32 R3;
|
||||
UINT32 R4;
|
||||
UINT32 R5;
|
||||
UINT32 R6;
|
||||
UINT32 R7;
|
||||
UINT32 R8;
|
||||
UINT32 R9;
|
||||
UINT32 R10;
|
||||
UINT32 R11;
|
||||
UINT32 R12;
|
||||
UINT32 SP;
|
||||
UINT32 LR;
|
||||
UINT32 PC;
|
||||
UINT32 CPSR;
|
||||
UINT32 DFSR;
|
||||
UINT32 DFAR;
|
||||
UINT32 IFSR;
|
||||
UINT32 IFAR;
|
||||
} EFI_SYSTEM_CONTEXT_ARM;
|
||||
|
||||
|
||||
typedef union {
|
||||
EFI_SYSTEM_CONTEXT_EBC *SystemContextEbc;
|
||||
EFI_SYSTEM_CONTEXT_IA32 *SystemContextIa32;
|
||||
EFI_SYSTEM_CONTEXT_X64 *SystemContextX64;
|
||||
EFI_SYSTEM_CONTEXT_IPF *SystemContextIpf;
|
||||
EFI_SYSTEM_CONTEXT_ARM *SystemContextArm;
|
||||
} EFI_SYSTEM_CONTEXT;
|
||||
|
||||
typedef
|
||||
VOID
|
||||
(EFIAPI *EFI_EXCEPTION_CALLBACK)(
|
||||
IN EFI_EXCEPTION_TYPE ExceptionType,
|
||||
IN OUT EFI_SYSTEM_CONTEXT SystemContext);
|
||||
|
||||
typedef
|
||||
VOID
|
||||
(EFIAPI *EFI_PERIODIC_CALLBACK)(
|
||||
IN OUT EFI_SYSTEM_CONTEXT SystemContext);
|
||||
|
||||
typedef enum {
|
||||
IsaIa32 = EFI_IMAGE_MACHINE_IA32,
|
||||
IsaX64 = EFI_IMAGE_MACHINE_X64,
|
||||
IsaIpf = EFI_IMAGE_MACHINE_IA64,
|
||||
IsaEbc = EFI_IMAGE_MACHINE_EBC,
|
||||
IsaArm = EFI_IMAGE_MACHINE_ARMTHUMB_MIXED,
|
||||
// IsaArm64 = EFI_IMAGE_MACHINE_AARCH64
|
||||
} EFI_INSTRUCTION_SET_ARCHITECTURE;
|
||||
|
||||
//
|
||||
// DEBUG_IMAGE_INFO
|
||||
//
|
||||
|
||||
#define EFI_DEBUG_IMAGE_INFO_TABLE_GUID \
|
||||
{ 0x49152e77, 0x1ada, 0x4764, {0xb7, 0xa2, 0x7a, 0xfe, 0xfe, 0xd9, 0x5e, 0x8b} }
|
||||
|
||||
#define EFI_DEBUG_IMAGE_INFO_UPDATE_IN_PROGRESS 0x01
|
||||
#define EFI_DEBUG_IMAGE_INFO_TABLE_MODIFIED 0x02
|
||||
#define EFI_DEBUG_IMAGE_INFO_INITIAL_SIZE (EFI_PAGE_SIZE / sizeof (UINTN))
|
||||
#define EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL 0x01
|
||||
|
||||
typedef struct {
|
||||
UINT64 Signature;
|
||||
EFI_PHYSICAL_ADDRESS EfiSystemTableBase;
|
||||
UINT32 Crc32;
|
||||
} EFI_SYSTEM_TABLE_POINTER;
|
||||
|
||||
typedef struct {
|
||||
UINT32 ImageInfoType;
|
||||
EFI_LOADED_IMAGE_PROTOCOL *LoadedImageProtocolInstance;
|
||||
EFI_HANDLE *ImageHandle;
|
||||
} EFI_DEBUG_IMAGE_INFO_NORMAL;
|
||||
|
||||
typedef union {
|
||||
UINT32 *ImageInfoType;
|
||||
EFI_DEBUG_IMAGE_INFO_NORMAL *NormalImage;
|
||||
} EFI_DEBUG_IMAGE_INFO;
|
||||
|
||||
typedef struct {
|
||||
volatile UINT32 UpdateStatus;
|
||||
UINT32 TableSize;
|
||||
EFI_DEBUG_IMAGE_INFO *EfiDebugImageInfoTable;
|
||||
} EFI_DEBUG_IMAGE_INFO_TABLE_HEADER;
|
||||
|
||||
//
|
||||
// EFI_DEBUGGER_PROTOCOL
|
||||
//
|
||||
|
||||
#define EFI_DEBUG_SUPPORT_PROTOCOL_GUID \
|
||||
{ 0x2755590c, 0x6f3c, 0x42fa, {0x9e, 0xa4, 0xa3, 0xba, 0x54, 0x3c, 0xda, 0x25} }
|
||||
|
||||
INTERFACE_DECL(_EFI_DEBUG_SUPPORT_PROTOCOL);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_GET_MAXIMUM_PROCESSOR_INDEX)(
|
||||
IN struct _EFI_DEBUG_SUPPORT_PROTOCOL *This,
|
||||
OUT UINTN *MaxProcessorIndex);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_REGISTER_PERIODIC_CALLBACK)(
|
||||
IN struct _EFI_DEBUG_SUPPORT_PROTOCOL *This,
|
||||
IN UINTN ProcessorIndex,
|
||||
IN EFI_PERIODIC_CALLBACK PeriodicCallback);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_REGISTER_EXCEPTION_CALLBACK)(
|
||||
IN struct _EFI_DEBUG_SUPPORT_PROTOCOL *This,
|
||||
IN UINTN ProcessorIndex,
|
||||
IN EFI_EXCEPTION_CALLBACK ExceptionCallback,
|
||||
IN EFI_EXCEPTION_TYPE ExceptionType);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_INVALIDATE_INSTRUCTION_CACHE)(
|
||||
IN struct _EFI_DEBUG_SUPPORT_PROTOCOL *This,
|
||||
IN UINTN ProcessorIndex,
|
||||
IN VOID *Start,
|
||||
IN UINT64 Length);
|
||||
|
||||
typedef struct _EFI_DEBUG_SUPPORT_PROTOCOL {
|
||||
EFI_INSTRUCTION_SET_ARCHITECTURE Isa;
|
||||
EFI_GET_MAXIMUM_PROCESSOR_INDEX GetMaximumProcessorIndex;
|
||||
EFI_REGISTER_PERIODIC_CALLBACK RegisterPeriodicCallback;
|
||||
EFI_REGISTER_EXCEPTION_CALLBACK RegisterExceptionCallback;
|
||||
EFI_INVALIDATE_INSTRUCTION_CACHE InvalidateInstructionCache;
|
||||
} EFI_DEBUG_SUPPORT_PROTOCOL;
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,266 @@
|
||||
#ifndef _EFI_DEF_H
|
||||
#define _EFI_DEF_H
|
||||
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
efidef.h
|
||||
|
||||
Abstract:
|
||||
|
||||
EFI definitions
|
||||
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
#if !defined(__cplusplus)
|
||||
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
|
||||
typedef _Bool BOOLEAN;
|
||||
#else
|
||||
typedef unsigned char BOOLEAN;
|
||||
#endif
|
||||
#else
|
||||
typedef bool BOOLEAN;
|
||||
#endif
|
||||
|
||||
#ifndef CONST
|
||||
#define CONST const
|
||||
#endif
|
||||
#ifndef TRUE
|
||||
#if defined(__cplusplus) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L)
|
||||
#if defined(_MSC_VER)
|
||||
#include <stdbool.h>
|
||||
#endif
|
||||
#define TRUE true
|
||||
#define FALSE false
|
||||
#else
|
||||
#define TRUE ((BOOLEAN) 1)
|
||||
#define FALSE ((BOOLEAN) 0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
#if (defined(__cplusplus) && __cplusplus >= 201103L) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L)
|
||||
#define NULL nullptr
|
||||
#else
|
||||
#if !defined(__cplusplus)
|
||||
#define NULL ((VOID *) 0)
|
||||
#else
|
||||
#define NULL 0
|
||||
#endif
|
||||
#endif
|
||||
#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
|
||||
|
||||
// STATIC - Name is internal to the module
|
||||
#define STATIC static
|
||||
|
||||
|
||||
|
||||
//
|
||||
// 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,
|
||||
EfiPersistentMemory,
|
||||
EfiUnacceptedMemoryType,
|
||||
EfiMaxMemoryType
|
||||
} EFI_MEMORY_TYPE;
|
||||
|
||||
|
||||
// Memory cacheability attribute
|
||||
#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 attribute
|
||||
#define EFI_MEMORY_WP 0x0000000000001000
|
||||
#define EFI_MEMORY_RP 0x0000000000002000
|
||||
#define EFI_MEMORY_XP 0x0000000000004000
|
||||
#define EFI_MEMORY_RO 0x0000000000020000
|
||||
|
||||
// Runtime memory attribute
|
||||
#define EFI_MEMORY_NV 0x0000000000008000
|
||||
#define EFI_MEMORY_RUNTIME 0x8000000000000000
|
||||
|
||||
// Other memory attribute
|
||||
#define EFI_MEMORY_MORE_RELIABLE 0x0000000000010000
|
||||
#define EFI_MEMORY_SP 0x0000000000040000
|
||||
#define EFI_MEMORY_CPU_CRYPTO 0x0000000000080000
|
||||
#define EFI_MEMORY_HOT_PLUGGABLE 0x0000000000100000
|
||||
#define EFI_MEMORY_ISA_VALID 0x4000000000000000
|
||||
#define EFI_MEMORY_ISA_MASK 0x0FFFF00000000000
|
||||
|
||||
|
||||
#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 CHAR8 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
|
||||
#define EFI_OS_INDICATIONS_START_OS_RECOVERY 0x0000000000000020
|
||||
#define EFI_OS_INDICATIONS_START_PLATFORM_RECOVERY \
|
||||
0x0000000000000040
|
||||
#define EFI_OS_INDICATIONS_JSON_CONFIG_DATA_REFRESH \
|
||||
0x0000000000000080
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,650 @@
|
||||
#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;
|
||||
UINT8 PortGid[16];
|
||||
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;
|
||||
|
||||
#define EFI_DEVICE_PATH_UTILITIES_PROTOCOL_GUID \
|
||||
{ 0x379be4e, 0xd706, 0x437d, {0xb0, 0x37, 0xed, 0xb8, 0x2f, 0xb7, 0x72, 0xa4} }
|
||||
|
||||
typedef
|
||||
UINTN
|
||||
(EFIAPI *EFI_DEVICE_PATH_UTILS_GET_DEVICE_PATH_SIZE) (
|
||||
IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_DEVICE_PATH_PROTOCOL*
|
||||
(EFIAPI *EFI_DEVICE_PATH_UTILS_DUP_DEVICE_PATH) (
|
||||
IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_DEVICE_PATH_PROTOCOL*
|
||||
(EFIAPI *EFI_DEVICE_PATH_UTILS_APPEND_PATH) (
|
||||
IN CONST EFI_DEVICE_PATH_PROTOCOL *Src1,
|
||||
IN CONST EFI_DEVICE_PATH_PROTOCOL *Src2
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_DEVICE_PATH_PROTOCOL*
|
||||
(EFIAPI *EFI_DEVICE_PATH_UTILS_APPEND_NODE) (
|
||||
IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
|
||||
IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_DEVICE_PATH_PROTOCOL*
|
||||
(EFIAPI *EFI_DEVICE_PATH_UTILS_APPEND_INSTANCE) (
|
||||
IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
|
||||
IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathInstance
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_DEVICE_PATH_PROTOCOL*
|
||||
(EFIAPI *EFI_DEVICE_PATH_UTILS_GET_NEXT_INSTANCE) (
|
||||
IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathInstance,
|
||||
OUT UINTN *DevicePathInstanceSize OPTIONAL
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_DEVICE_PATH_PROTOCOL*
|
||||
(EFIAPI *EFI_DEVICE_PATH_UTILS_CREATE_NODE) (
|
||||
IN UINT8 NodeType,
|
||||
IN UINT8 NodeSubType,
|
||||
IN UINT16 NodeLength
|
||||
);
|
||||
|
||||
typedef
|
||||
BOOLEAN
|
||||
(EFIAPI *EFI_DEVICE_PATH_UTILS_IS_MULTI_INSTANCE) (
|
||||
IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
||||
);
|
||||
|
||||
typedef struct _EFI_DEVICE_PATH_UTILITIES_PROTOCOL {
|
||||
EFI_DEVICE_PATH_UTILS_GET_DEVICE_PATH_SIZE GetDevicePathSize;
|
||||
EFI_DEVICE_PATH_UTILS_DUP_DEVICE_PATH DuplicateDevicePath;
|
||||
EFI_DEVICE_PATH_UTILS_APPEND_PATH AppendDevicePath;
|
||||
EFI_DEVICE_PATH_UTILS_APPEND_NODE AppendDeviceNode;
|
||||
EFI_DEVICE_PATH_UTILS_APPEND_INSTANCE AppendDevicePathInstance;
|
||||
EFI_DEVICE_PATH_UTILS_GET_NEXT_INSTANCE GetNextDevicePathInstance;
|
||||
EFI_DEVICE_PATH_UTILS_IS_MULTI_INSTANCE IsDevicePathMultiInstance;
|
||||
EFI_DEVICE_PATH_UTILS_CREATE_NODE CreateDeviceNode;
|
||||
} EFI_DEVICE_PATH_UTILITIES_PROTOCOL;
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,73 @@
|
||||
#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_IP_ADDRESS_CONFLICT EFIERR(34)
|
||||
#define EFI_HTTP_ERROR EFIERR(35)
|
||||
|
||||
#define EFI_WARN_UNKOWN_GLYPH EFIWARN(1)
|
||||
#define EFI_WARN_UNKNOWN_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)
|
||||
#define EFI_WARN_STALE_DATA EFIWARN(5)
|
||||
#define EFI_WARN_FILE_SYSTEM EFIWARN(6)
|
||||
#define EFI_WARN_RESET_REQUIRED EFIWARN(7)
|
||||
|
||||
#endif
|
||||
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
#ifndef _EFI_FS_H
|
||||
#define _EFI_FS_H
|
||||
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
efifs.h
|
||||
|
||||
Abstract:
|
||||
|
||||
EFI File System structures
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
|
||||
//
|
||||
// EFI Partition header (normaly starts in LBA 1)
|
||||
//
|
||||
|
||||
#define EFI_PARTITION_SIGNATURE 0x5053595320494249
|
||||
#define EFI_PARTITION_REVISION 0x00010001
|
||||
#define MIN_EFI_PARTITION_BLOCK_SIZE 512
|
||||
#define EFI_PARTITION_LBA 1
|
||||
|
||||
typedef struct _EFI_PARTITION_HEADER {
|
||||
EFI_TABLE_HEADER Hdr;
|
||||
UINT32 DirectoryAllocationNumber;
|
||||
UINT32 BlockSize;
|
||||
EFI_LBA FirstUsableLba;
|
||||
EFI_LBA LastUsableLba;
|
||||
EFI_LBA UnusableSpace;
|
||||
EFI_LBA FreeSpace;
|
||||
EFI_LBA RootFile;
|
||||
EFI_LBA SecutiryFile;
|
||||
} EFI_PARTITION_HEADER;
|
||||
|
||||
|
||||
//
|
||||
// File header
|
||||
//
|
||||
|
||||
#define EFI_FILE_HEADER_SIGNATURE 0x454c494620494249
|
||||
#define EFI_FILE_HEADER_REVISION 0x00010000
|
||||
#define EFI_FILE_STRING_SIZE 260
|
||||
|
||||
typedef struct _EFI_FILE_HEADER {
|
||||
EFI_TABLE_HEADER Hdr;
|
||||
UINT32 Class;
|
||||
UINT32 LBALOffset;
|
||||
EFI_LBA Parent;
|
||||
UINT64 FileSize;
|
||||
UINT64 FileAttributes;
|
||||
EFI_TIME FileCreateTime;
|
||||
EFI_TIME FileModificationTime;
|
||||
EFI_GUID VendorGuid;
|
||||
CHAR16 FileString[EFI_FILE_STRING_SIZE];
|
||||
} EFI_FILE_HEADER;
|
||||
|
||||
|
||||
//
|
||||
// Return the file's first LBAL which is in the same
|
||||
// logical block as the file header
|
||||
//
|
||||
|
||||
#define EFI_FILE_LBAL(a) ((EFI_LBAL *) (((CHAR8 *) (a)) + (a)->LBALOffset))
|
||||
|
||||
#define EFI_FILE_CLASS_FREE_SPACE 1
|
||||
#define EFI_FILE_CLASS_EMPTY 2
|
||||
#define EFI_FILE_CLASS_NORMAL 3
|
||||
|
||||
|
||||
//
|
||||
// Logical Block Address List - the fundemental block
|
||||
// description structure
|
||||
//
|
||||
|
||||
#define EFI_LBAL_SIGNATURE 0x4c41424c20494249
|
||||
#define EFI_LBAL_REVISION 0x00010000
|
||||
|
||||
typedef struct _EFI_LBAL {
|
||||
EFI_TABLE_HEADER Hdr;
|
||||
UINT32 Class;
|
||||
EFI_LBA Parent;
|
||||
EFI_LBA Next;
|
||||
UINT32 ArraySize;
|
||||
UINT32 ArrayCount;
|
||||
} EFI_LBAL;
|
||||
|
||||
// Array size
|
||||
#define EFI_LBAL_ARRAY_SIZE(lbal,offs,blks) \
|
||||
(((blks) - (offs) - (lbal)->Hdr.HeaderSize) / sizeof(EFI_RL))
|
||||
|
||||
//
|
||||
// Logical Block run-length
|
||||
//
|
||||
|
||||
typedef struct {
|
||||
EFI_LBA Start;
|
||||
UINT64 Length;
|
||||
} EFI_RL;
|
||||
|
||||
//
|
||||
// Return the run-length structure from an LBAL header
|
||||
//
|
||||
|
||||
#define EFI_LBAL_RL(a) ((EFI_RL*) (((CHAR8 *) (a)) + (a)->Hdr.HeaderSize))
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
#ifndef _EFI_GPT_H
|
||||
#define _EFI_GPT_H
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
EfiGpt.h
|
||||
|
||||
Abstract:
|
||||
Include file for EFI partitioning scheme
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
#define PRIMARY_PART_HEADER_LBA 1
|
||||
|
||||
typedef struct {
|
||||
EFI_TABLE_HEADER Header;
|
||||
EFI_LBA MyLBA;
|
||||
EFI_LBA AlternateLBA;
|
||||
EFI_LBA FirstUsableLBA;
|
||||
EFI_LBA LastUsableLBA;
|
||||
EFI_GUID DiskGUID;
|
||||
EFI_LBA PartitionEntryLBA;
|
||||
UINT32 NumberOfPartitionEntries;
|
||||
UINT32 SizeOfPartitionEntry;
|
||||
UINT32 PartitionEntryArrayCRC32;
|
||||
} EFI_PARTITION_TABLE_HEADER;
|
||||
|
||||
#define EFI_PTAB_HEADER_ID "EFI PART"
|
||||
|
||||
typedef struct {
|
||||
EFI_GUID PartitionTypeGUID;
|
||||
EFI_GUID UniquePartitionGUID;
|
||||
EFI_LBA StartingLBA;
|
||||
EFI_LBA EndingLBA;
|
||||
UINT64 Attributes;
|
||||
CHAR16 PartitionName[36];
|
||||
} EFI_PARTITION_ENTRY;
|
||||
|
||||
//
|
||||
// EFI Partition Attributes
|
||||
//
|
||||
#define EFI_PART_USED_BY_EFI 0x0000000000000001
|
||||
#define EFI_PART_REQUIRED_TO_FUNCTION 0x0000000000000002
|
||||
#define EFI_PART_USED_BY_OS 0x0000000000000004
|
||||
#define EFI_PART_REQUIRED_BY_OS 0x0000000000000008
|
||||
#define EFI_PART_BACKUP_REQUIRED 0x0000000000000010
|
||||
#define EFI_PART_USER_DATA 0x0000000000000020
|
||||
#define EFI_PART_CRITICAL_USER_DATA 0x0000000000000040
|
||||
#define EFI_PART_REDUNDANT_PARTITION 0x0000000000000080
|
||||
|
||||
#define EFI_PART_TYPE_UNUSED_GUID \
|
||||
{ 0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} }
|
||||
|
||||
#define EFI_PART_TYPE_EFI_SYSTEM_PART_GUID \
|
||||
{ 0xc12a7328, 0xf81f, 0x11d2, {0xba, 0x4b, 0x00, 0xa0, 0xc9, 0x3e, 0xc9, 0x3b} }
|
||||
|
||||
#define EFI_PART_TYPE_LEGACY_MBR_GUID \
|
||||
{ 0x024dee41, 0x33e7, 0x11d3, {0x9d, 0x69, 0x00, 0x08, 0xc7, 0x81, 0xf3, 0x9f} }
|
||||
|
||||
#endif
|
||||
|
||||
+459
@@ -0,0 +1,459 @@
|
||||
#ifndef _EFI_IP_H
|
||||
#define _EFI_IP_H
|
||||
|
||||
/*++
|
||||
Copyright (c) 2013 Intel Corporation
|
||||
|
||||
--*/
|
||||
|
||||
#define EFI_IP4_SERVICE_BINDING_PROTOCOL \
|
||||
{0xc51711e7,0xb4bf,0x404a,{0xbf,0xb8,0x0a,0x04, 0x8e,0xf1,0xff,0xe4}}
|
||||
|
||||
#define EFI_IP4_PROTOCOL \
|
||||
{0x41d94cd2,0x35b6,0x455a,{0x82,0x58,0xd4,0xe5,0x13,0x34,0xaa,0xdd}}
|
||||
|
||||
#define EFI_IP6_SERVICE_BINDING_PROTOCOL \
|
||||
{0xec835dd3,0xfe0f,0x617b,{0xa6,0x21,0xb3,0x50,0xc3,0xe1,0x33,0x88}}
|
||||
|
||||
#define EFI_IP6_PROTOCOL \
|
||||
{0x2c8759d5,0x5c2d,0x66ef,{0x92,0x5f,0xb6,0x6c,0x10,0x19,0x57,0xe2}}
|
||||
|
||||
INTERFACE_DECL(_EFI_IP4);
|
||||
INTERFACE_DECL(_EFI_IP6);
|
||||
|
||||
typedef struct {
|
||||
EFI_HANDLE InstanceHandle;
|
||||
EFI_IPv4_ADDRESS Ip4Address;
|
||||
EFI_IPv4_ADDRESS SubnetMask;
|
||||
} EFI_IP4_ADDRESS_PAIR;
|
||||
|
||||
typedef struct {
|
||||
EFI_HANDLE DriverHandle;
|
||||
UINT32 AddressCount;
|
||||
EFI_IP4_ADDRESS_PAIR AddressPairs[1];
|
||||
} EFI_IP4_VARIABLE_DATA;
|
||||
|
||||
typedef struct {
|
||||
UINT8 DefaultProtocol;
|
||||
BOOLEAN AcceptAnyProtocol;
|
||||
BOOLEAN AcceptIcmpErrors;
|
||||
BOOLEAN AcceptBroadcast;
|
||||
BOOLEAN AcceptPromiscuous;
|
||||
BOOLEAN UseDefaultAddress;
|
||||
EFI_IPv4_ADDRESS StationAddress;
|
||||
EFI_IPv4_ADDRESS SubnetMask;
|
||||
UINT8 TypeOfService;
|
||||
UINT8 TimeToLive;
|
||||
BOOLEAN DoNotFragment;
|
||||
BOOLEAN RawData;
|
||||
UINT32 ReceiveTimeout;
|
||||
UINT32 TransmitTimeout;
|
||||
} EFI_IP4_CONFIG_DATA;
|
||||
|
||||
typedef struct {
|
||||
EFI_IPv4_ADDRESS SubnetAddress;
|
||||
EFI_IPv4_ADDRESS SubnetMask;
|
||||
EFI_IPv4_ADDRESS GatewayAddress;
|
||||
} EFI_IP4_ROUTE_TABLE;
|
||||
|
||||
typedef struct {
|
||||
UINT8 Type;
|
||||
UINT8 Code;
|
||||
} EFI_IP4_ICMP_TYPE;
|
||||
|
||||
typedef struct {
|
||||
BOOLEAN IsStarted;
|
||||
UINT32 MaxPacketSize;
|
||||
EFI_IP4_CONFIG_DATA ConfigData;
|
||||
BOOLEAN IsConfigured;
|
||||
UINT32 GroupCount;
|
||||
EFI_IPv4_ADDRESS *GroupTable;
|
||||
UINT32 RouteCount;
|
||||
EFI_IP4_ROUTE_TABLE *RouteTable;
|
||||
UINT32 IcmpTypeCount;
|
||||
EFI_IP4_ICMP_TYPE *IcmpTypeList;
|
||||
} EFI_IP4_MODE_DATA;
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_IP4_GET_MODE_DATA) (
|
||||
IN struct _EFI_IP4 *This,
|
||||
OUT EFI_IP4_MODE_DATA *Ip4ModeData OPTIONAL,
|
||||
OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,
|
||||
OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_IP4_CONFIGURE) (
|
||||
IN struct _EFI_IP4 *This,
|
||||
IN EFI_IP4_CONFIG_DATA *IpConfigData OPTIONAL
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_IP4_GROUPS) (
|
||||
IN struct _EFI_IP4 *This,
|
||||
IN BOOLEAN JoinFlag,
|
||||
IN EFI_IPv4_ADDRESS *GroupAddress OPTIONAL
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_IP4_ROUTES) (
|
||||
IN struct _EFI_IP4 *This,
|
||||
IN BOOLEAN DeleteRoute,
|
||||
IN EFI_IPv4_ADDRESS *SubnetAddress,
|
||||
IN EFI_IPv4_ADDRESS *SubnetMask,
|
||||
IN EFI_IPv4_ADDRESS *GatewayAddress
|
||||
);
|
||||
|
||||
#pragma pack(1)
|
||||
typedef struct {
|
||||
UINT8 HeaderLength:4;
|
||||
UINT8 Version:4;
|
||||
UINT8 TypeOfService;
|
||||
UINT16 TotalLength;
|
||||
UINT16 Identification;
|
||||
UINT16 Fragmentation;
|
||||
UINT8 TimeToLive;
|
||||
UINT8 Protocol;
|
||||
UINT16 Checksum;
|
||||
EFI_IPv4_ADDRESS SourceAddress;
|
||||
EFI_IPv4_ADDRESS DestinationAddress;
|
||||
} EFI_IP4_HEADER;
|
||||
#pragma pack()
|
||||
|
||||
typedef struct {
|
||||
UINT32 FragmentLength;
|
||||
VOID *FragmentBuffer;
|
||||
} EFI_IP4_FRAGMENT_DATA;
|
||||
|
||||
typedef struct {
|
||||
EFI_TIME TimeStamp;
|
||||
EFI_EVENT RecycleSignal;
|
||||
UINT32 HeaderLength;
|
||||
EFI_IP4_HEADER *Header;
|
||||
UINT32 OptionsLength;
|
||||
VOID *Options;
|
||||
UINT32 DataLength;
|
||||
UINT32 FragmentCount;
|
||||
EFI_IP4_FRAGMENT_DATA FragmentTable[1];
|
||||
} EFI_IP4_RECEIVE_DATA;
|
||||
|
||||
typedef struct {
|
||||
EFI_IPv4_ADDRESS SourceAddress;
|
||||
EFI_IPv4_ADDRESS GatewayAddress;
|
||||
UINT8 Protocol;
|
||||
UINT8 TypeOfService;
|
||||
UINT8 TimeToLive;
|
||||
BOOLEAN DoNotFragment;
|
||||
} EFI_IP4_OVERRIDE_DATA;
|
||||
|
||||
typedef struct {
|
||||
EFI_IPv4_ADDRESS DestinationAddress;
|
||||
EFI_IP4_OVERRIDE_DATA *OverrideData;
|
||||
UINT32 OptionsLength;
|
||||
VOID *OptionsBuffer;
|
||||
UINT32 TotalDataLength;
|
||||
UINT32 FragmentCount;
|
||||
EFI_IP4_FRAGMENT_DATA FragmentTable[1];
|
||||
} EFI_IP4_TRANSMIT_DATA;
|
||||
|
||||
typedef struct {
|
||||
EFI_EVENT Event;
|
||||
EFI_STATUS Status;
|
||||
union {
|
||||
EFI_IP4_RECEIVE_DATA *RxData;
|
||||
EFI_IP4_TRANSMIT_DATA *TxData;
|
||||
} Packet;
|
||||
} EFI_IP4_COMPLETION_TOKEN;
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_IP4_TRANSMIT) (
|
||||
IN struct _EFI_IP4 *This,
|
||||
IN EFI_IP4_COMPLETION_TOKEN *Token
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_IP4_RECEIVE) (
|
||||
IN struct _EFI_IP4 *This,
|
||||
IN EFI_IP4_COMPLETION_TOKEN *Token
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_IP4_CANCEL)(
|
||||
IN struct _EFI_IP4 *This,
|
||||
IN EFI_IP4_COMPLETION_TOKEN *Token OPTIONAL
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_IP4_POLL) (
|
||||
IN struct _EFI_IP4 *This
|
||||
);
|
||||
|
||||
typedef struct _EFI_IP4 {
|
||||
EFI_IP4_GET_MODE_DATA GetModeData;
|
||||
EFI_IP4_CONFIGURE Configure;
|
||||
EFI_IP4_GROUPS Groups;
|
||||
EFI_IP4_ROUTES Routes;
|
||||
EFI_IP4_TRANSMIT Transmit;
|
||||
EFI_IP4_RECEIVE Receive;
|
||||
EFI_IP4_CANCEL Cancel;
|
||||
EFI_IP4_POLL Poll;
|
||||
} EFI_IP4;
|
||||
|
||||
typedef struct {
|
||||
UINT8 DefaultProtocol;
|
||||
BOOLEAN AcceptAnyProtocol;
|
||||
BOOLEAN AcceptIcmpErrors;
|
||||
BOOLEAN AcceptPromiscuous;
|
||||
EFI_IPv6_ADDRESS DestinationAddress;
|
||||
EFI_IPv6_ADDRESS StationAddress;
|
||||
UINT8 TrafficClass;
|
||||
UINT8 HopLimit;
|
||||
UINT32 FlowLabel;
|
||||
UINT32 ReceiveTimeout;
|
||||
UINT32 TransmitTimeout;
|
||||
} EFI_IP6_CONFIG_DATA;
|
||||
|
||||
typedef struct {
|
||||
EFI_IPv6_ADDRESS Address;
|
||||
UINT8 PrefixLength;
|
||||
} EFI_IP6_ADDRESS_INFO;
|
||||
|
||||
typedef struct {
|
||||
EFI_IPv6_ADDRESS Gateway;
|
||||
EFI_IPv6_ADDRESS Destination;
|
||||
UINT8 PrefixLength;
|
||||
} EFI_IP6_ROUTE_TABLE;
|
||||
|
||||
typedef enum {
|
||||
EfiNeighborInComplete,
|
||||
EfiNeighborReachable,
|
||||
EfiNeighborStale,
|
||||
EfiNeighborDelay,
|
||||
EfiNeighborProbe
|
||||
} EFI_IP6_NEIGHBOR_STATE;
|
||||
|
||||
typedef struct {
|
||||
EFI_IPv6_ADDRESS Neighbor;
|
||||
EFI_MAC_ADDRESS LinkAddress;
|
||||
EFI_IP6_NEIGHBOR_STATE State;
|
||||
} EFI_IP6_NEIGHBOR_CACHE;
|
||||
|
||||
typedef struct {
|
||||
UINT8 Type;
|
||||
UINT8 Code;
|
||||
} EFI_IP6_ICMP_TYPE;
|
||||
|
||||
//***********************************************************
|
||||
// ICMPv6 type definitions for error messages
|
||||
//***********************************************************
|
||||
#define ICMP_V6_DEST_UNREACHABLE 0x1
|
||||
#define ICMP_V6_PACKET_TOO_BIG 0x2
|
||||
#define ICMP_V6_TIME_EXCEEDED 0x3
|
||||
#define ICMP_V6_PARAMETER_PROBLEM 0x4
|
||||
|
||||
//***********************************************************
|
||||
// ICMPv6 type definition for informational messages
|
||||
//***********************************************************
|
||||
#define ICMP_V6_ECHO_REQUEST 0x80
|
||||
#define ICMP_V6_ECHO_REPLY 0x81
|
||||
#define ICMP_V6_LISTENER_QUERY 0x82
|
||||
#define ICMP_V6_LISTENER_REPORT 0x83
|
||||
#define ICMP_V6_LISTENER_DONE 0x84
|
||||
#define ICMP_V6_ROUTER_SOLICIT 0x85
|
||||
#define ICMP_V6_ROUTER_ADVERTISE 0x86
|
||||
#define ICMP_V6_NEIGHBOR_SOLICIT 0x87
|
||||
#define ICMP_V6_NEIGHBOR_ADVERTISE 0x88
|
||||
#define ICMP_V6_REDIRECT 0x89
|
||||
#define ICMP_V6_LISTENER_REPORT_2 0x8F
|
||||
|
||||
//***********************************************************
|
||||
// ICMPv6 code definitions for ICMP_V6_DEST_UNREACHABLE
|
||||
//***********************************************************
|
||||
#define ICMP_V6_NO_ROUTE_TO_DEST 0x0
|
||||
#define ICMP_V6_COMM_PROHIBITED 0x1
|
||||
#define ICMP_V6_BEYOND_SCOPE 0x2
|
||||
#define ICMP_V6_ADDR_UNREACHABLE 0x3
|
||||
#define ICMP_V6_PORT_UNREACHABLE 0x4
|
||||
#define ICMP_V6_SOURCE_ADDR_FAILED 0x5
|
||||
#define ICMP_V6_ROUTE_REJECTED 0x6
|
||||
|
||||
//***********************************************************
|
||||
// ICMPv6 code definitions for ICMP_V6_TIME_EXCEEDED
|
||||
//***********************************************************
|
||||
#define ICMP_V6_TIMEOUT_HOP_LIMIT 0x0
|
||||
#define ICMP_V6_TIMEOUT_REASSEMBLE 0x1
|
||||
|
||||
//***********************************************************
|
||||
// ICMPv6 code definitions for ICMP_V6_PARAMETER_PROBLEM
|
||||
//***********************************************************
|
||||
#define ICMP_V6_ERRONEOUS_HEADER 0x0
|
||||
#define ICMP_V6_UNRECOGNIZE_NEXT_HDR 0x1
|
||||
#define ICMP_V6_UNRECOGNIZE_OPTION 0x2
|
||||
|
||||
typedef struct {
|
||||
BOOLEAN IsStarted;
|
||||
UINT32 MaxPacketSize;
|
||||
EFI_IP6_CONFIG_DATA ConfigData;
|
||||
BOOLEAN IsConfigured;
|
||||
UINT32 AddressCount;
|
||||
EFI_IP6_ADDRESS_INFO *AddressList;
|
||||
UINT32 GroupCount;
|
||||
EFI_IPv6_ADDRESS *GroupTable;
|
||||
UINT32 RouteCount;
|
||||
EFI_IP6_ROUTE_TABLE *RouteTable;
|
||||
UINT32 NeighborCount;
|
||||
EFI_IP6_NEIGHBOR_CACHE *NeighborCache;
|
||||
UINT32 PrefixCount;
|
||||
EFI_IP6_ADDRESS_INFO *PrefixTable;
|
||||
UINT32 IcmpTypeCount;
|
||||
EFI_IP6_ICMP_TYPE *IcmpTypeList;
|
||||
} EFI_IP6_MODE_DATA;
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_IP6_GET_MODE_DATA) (
|
||||
IN struct _EFI_IP6 *This,
|
||||
OUT EFI_IP6_MODE_DATA *Ip6ModeData OPTIONAL,
|
||||
OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,
|
||||
OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_IP6_CONFIGURE) (
|
||||
IN struct _EFI_IP6 *This,
|
||||
IN EFI_IP6_CONFIG_DATA *Ip6ConfigData OPTIONAL
|
||||
);
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_IP6_GROUPS) (
|
||||
IN struct _EFI_IP6 *This,
|
||||
IN BOOLEAN JoinFlag,
|
||||
IN EFI_IPv6_ADDRESS *GroupAddress OPTIONAL
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_IP6_ROUTES) (
|
||||
IN struct _EFI_IP6 *This,
|
||||
IN BOOLEAN DeleteRoute,
|
||||
IN EFI_IPv6_ADDRESS *Destination OPTIONAL,
|
||||
IN UINT8 PrefixLength,
|
||||
IN EFI_IPv6_ADDRESS *GatewayAddress OPTIONAL
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_IP6_NEIGHBORS) (
|
||||
IN struct _EFI_IP6 *This,
|
||||
IN BOOLEAN DeleteFlag,
|
||||
IN EFI_IPv6_ADDRESS *TargetIp6Address,
|
||||
IN EFI_MAC_ADDRESS *TargetLinkAddress OPTIONAL,
|
||||
IN UINT32 Timeout,
|
||||
IN BOOLEAN Override
|
||||
);
|
||||
|
||||
typedef struct _EFI_IP6_FRAGMENT_DATA {
|
||||
UINT32 FragmentLength;
|
||||
VOID *FragmentBuffer;
|
||||
} EFI_IP6_FRAGMENT_DATA;
|
||||
|
||||
typedef struct _EFI_IP6_OVERRIDE_DATA {
|
||||
UINT8 Protocol;
|
||||
UINT8 HopLimit;
|
||||
UINT32 FlowLabel;
|
||||
} EFI_IP6_OVERRIDE_DATA;
|
||||
|
||||
typedef struct _EFI_IP6_TRANSMIT_DATA {
|
||||
EFI_IPv6_ADDRESS DestinationAddress;
|
||||
EFI_IP6_OVERRIDE_DATA *OverrideData;
|
||||
UINT32 ExtHdrsLength;
|
||||
VOID *ExtHdrs;
|
||||
UINT8 NextHeader;
|
||||
UINT32 DataLength;
|
||||
UINT32 FragmentCount;
|
||||
EFI_IP6_FRAGMENT_DATA FragmentTable[1];
|
||||
} EFI_IP6_TRANSMIT_DATA;
|
||||
|
||||
#pragma pack(1)
|
||||
typedef struct _EFI_IP6_HEADER {
|
||||
UINT8 TrafficClassH:4;
|
||||
UINT8 Version:4;
|
||||
UINT8 FlowLabelH:4;
|
||||
UINT8 TrafficClassL:4;
|
||||
UINT16 FlowLabelL;
|
||||
UINT16 PayloadLength;
|
||||
UINT8 NextHeader;
|
||||
UINT8 HopLimit;
|
||||
EFI_IPv6_ADDRESS SourceAddress;
|
||||
EFI_IPv6_ADDRESS DestinationAddress;
|
||||
} EFI_IP6_HEADER;
|
||||
#pragma pack()
|
||||
|
||||
typedef struct _EFI_IP6_RECEIVE_DATA {
|
||||
EFI_TIME TimeStamp;
|
||||
EFI_EVENT RecycleSignal;
|
||||
UINT32 HeaderLength;
|
||||
EFI_IP6_HEADER *Header;
|
||||
UINT32 DataLength;
|
||||
UINT32 FragmentCount;
|
||||
EFI_IP6_FRAGMENT_DATA FragmentTable[1];
|
||||
} EFI_IP6_RECEIVE_DATA;
|
||||
|
||||
typedef struct {
|
||||
EFI_EVENT Event;
|
||||
EFI_STATUS Status;
|
||||
union {
|
||||
EFI_IP6_RECEIVE_DATA *RxData;
|
||||
EFI_IP6_TRANSMIT_DATA *TxData;
|
||||
} Packet;
|
||||
} EFI_IP6_COMPLETION_TOKEN;
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_IP6_TRANSMIT) (
|
||||
IN struct _EFI_IP6 *This,
|
||||
IN EFI_IP6_COMPLETION_TOKEN *Token
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_IP6_RECEIVE) (
|
||||
IN struct _EFI_IP6 *This,
|
||||
IN EFI_IP6_COMPLETION_TOKEN *Token
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_IP6_CANCEL)(
|
||||
IN struct _EFI_IP6 *This,
|
||||
IN EFI_IP6_COMPLETION_TOKEN *Token OPTIONAL
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_IP6_POLL) (
|
||||
IN struct _EFI_IP6 *This
|
||||
);
|
||||
|
||||
typedef struct _EFI_IP6 {
|
||||
EFI_IP6_GET_MODE_DATA GetModeData;
|
||||
EFI_IP6_CONFIGURE Configure;
|
||||
EFI_IP6_GROUPS Groups;
|
||||
EFI_IP6_ROUTES Routes;
|
||||
EFI_IP6_NEIGHBORS Neighbors;
|
||||
EFI_IP6_TRANSMIT Transmit;
|
||||
EFI_IP6_RECEIVE Receive;
|
||||
EFI_IP6_CANCEL Cancel;
|
||||
EFI_IP6_POLL Poll;
|
||||
} EFI_IP6;
|
||||
|
||||
#endif /* _EFI_IP_H */
|
||||
+1209
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,182 @@
|
||||
#ifndef _EFI_LINK_H
|
||||
#define _EFI_LINK_H
|
||||
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
link.h (renamed efilink.h to avoid conflicts)
|
||||
|
||||
Abstract:
|
||||
|
||||
EFI link list macro's
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
#ifndef EFI_NT_EMUL
|
||||
|
||||
//
|
||||
// List entry - doubly linked list
|
||||
//
|
||||
|
||||
typedef struct _LIST_ENTRY {
|
||||
struct _LIST_ENTRY *Flink;
|
||||
struct _LIST_ENTRY *Blink;
|
||||
} LIST_ENTRY, EFI_LIST_ENTRY;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
//
|
||||
// VOID
|
||||
// InitializeListHead(
|
||||
// LIST_ENTRY *ListHead
|
||||
// );
|
||||
//
|
||||
|
||||
#define InitializeListHead(ListHead) \
|
||||
(ListHead)->Flink = ListHead; \
|
||||
(ListHead)->Blink = ListHead;
|
||||
|
||||
//
|
||||
// BOOLEAN
|
||||
// IsListEmpty(
|
||||
// PLIST_ENTRY ListHead
|
||||
// );
|
||||
//
|
||||
|
||||
#define IsListEmpty(ListHead) \
|
||||
((ListHead)->Flink == (ListHead))
|
||||
|
||||
//
|
||||
// VOID
|
||||
// RemoveEntryList(
|
||||
// PLIST_ENTRY Entry
|
||||
// );
|
||||
//
|
||||
|
||||
#define _RemoveEntryList(Entry) { \
|
||||
LIST_ENTRY *_Blink, *_Flink; \
|
||||
_Flink = (Entry)->Flink; \
|
||||
_Blink = (Entry)->Blink; \
|
||||
_Blink->Flink = _Flink; \
|
||||
_Flink->Blink = _Blink; \
|
||||
}
|
||||
|
||||
#if EFI_DEBUG
|
||||
#define RemoveEntryList(Entry) \
|
||||
_RemoveEntryList(Entry); \
|
||||
(Entry)->Flink = (LIST_ENTRY *) BAD_POINTER; \
|
||||
(Entry)->Blink = (LIST_ENTRY *) BAD_POINTER;
|
||||
#else
|
||||
#define RemoveEntryList(Entry) \
|
||||
_RemoveEntryList(Entry);
|
||||
#endif
|
||||
|
||||
//
|
||||
// VOID
|
||||
// InsertTailList(
|
||||
// PLIST_ENTRY ListHead,
|
||||
// PLIST_ENTRY Entry
|
||||
// );
|
||||
//
|
||||
|
||||
#define InsertTailList(ListHead,Entry) {\
|
||||
LIST_ENTRY *_ListHead, *_Blink; \
|
||||
_ListHead = (ListHead); \
|
||||
_Blink = _ListHead->Blink; \
|
||||
(Entry)->Flink = _ListHead; \
|
||||
(Entry)->Blink = _Blink; \
|
||||
_Blink->Flink = (Entry); \
|
||||
_ListHead->Blink = (Entry); \
|
||||
}
|
||||
|
||||
//
|
||||
// VOID
|
||||
// InsertHeadList(
|
||||
// PLIST_ENTRY ListHead,
|
||||
// PLIST_ENTRY Entry
|
||||
// );
|
||||
//
|
||||
|
||||
#define InsertHeadList(ListHead,Entry) {\
|
||||
LIST_ENTRY *_ListHead, *_Flink; \
|
||||
_ListHead = (ListHead); \
|
||||
_Flink = _ListHead->Flink; \
|
||||
(Entry)->Flink = _Flink; \
|
||||
(Entry)->Blink = _ListHead; \
|
||||
_Flink->Blink = (Entry); \
|
||||
_ListHead->Flink = (Entry); \
|
||||
}
|
||||
|
||||
// VOID
|
||||
// SwapListEntries(
|
||||
// PLIST_ENTRY Entry1,
|
||||
// PLIST_ENTRY Entry2
|
||||
// );
|
||||
//
|
||||
// Put Entry2 before Entry1
|
||||
//
|
||||
#define SwapListEntries(Entry1,Entry2) {\
|
||||
LIST_ENTRY *Entry1Flink, *Entry1Blink; \
|
||||
LIST_ENTRY *Entry2Flink, *Entry2Blink; \
|
||||
Entry2Flink = (Entry2)->Flink; \
|
||||
Entry2Blink = (Entry2)->Blink; \
|
||||
Entry1Flink = (Entry1)->Flink; \
|
||||
Entry1Blink = (Entry1)->Blink; \
|
||||
Entry2Blink->Flink = Entry2Flink; \
|
||||
Entry2Flink->Blink = Entry2Blink; \
|
||||
(Entry2)->Flink = Entry1; \
|
||||
(Entry2)->Blink = Entry1Blink; \
|
||||
Entry1Blink->Flink = (Entry2); \
|
||||
(Entry1)->Blink = (Entry2); \
|
||||
}
|
||||
|
||||
//
|
||||
// EFI_FIELD_OFFSET - returns the byte offset to a field within a structure
|
||||
//
|
||||
|
||||
#define EFI_FIELD_OFFSET(TYPE,Field) ((UINTN)(intptr_t)(&(((TYPE *) 0)->Field)))
|
||||
|
||||
//
|
||||
// CONTAINING_RECORD - returns a pointer to the structure
|
||||
// from one of it's elements.
|
||||
//
|
||||
|
||||
#define _CR(Record, TYPE, Field) \
|
||||
((TYPE *) ( (CHAR8 *)(Record) - (CHAR8 *) &(((TYPE *) 0)->Field)))
|
||||
|
||||
//
|
||||
// EDK2 uses BASE_CR for the above
|
||||
//
|
||||
#define BASE_CR _CR
|
||||
|
||||
#if EFI_DEBUG
|
||||
#define CR(Record, TYPE, Field, Sig) \
|
||||
_CR(Record, TYPE, Field)->Signature != Sig ? \
|
||||
(TYPE *) ASSERT_STRUCT(_CR(Record, TYPE, Field), Record) : \
|
||||
_CR(Record, TYPE, Field)
|
||||
#else
|
||||
#define CR(Record, TYPE, Field, Signature) \
|
||||
_CR(Record, TYPE, Field)
|
||||
#endif
|
||||
|
||||
|
||||
//
|
||||
// A lock structure
|
||||
//
|
||||
|
||||
typedef struct _FLOCK {
|
||||
EFI_TPL Tpl;
|
||||
EFI_TPL OwnerTpl;
|
||||
UINTN Lock;
|
||||
} FLOCK;
|
||||
|
||||
#endif
|
||||
|
||||
+137
@@ -0,0 +1,137 @@
|
||||
#ifndef _EFI_MP_H
|
||||
#define _EFI_MP_H
|
||||
|
||||
|
||||
|
||||
#define EFI_MP_SERVICES_PROTOCOL_GUID \
|
||||
{ 0x3fdda605, 0xa76e, 0x4f46, {0xad, 0x29, 0x12, 0xf4, 0x53, 0x1b, 0x3d, 0x08} }
|
||||
|
||||
#define PROCESSOR_AS_BSP_BIT (1 << 0)
|
||||
#define PROCESSOR_ENABLED_BIT (1 << 1)
|
||||
#define PROCESSOR_HEALTH_STATUS_BIT (1 << 2)
|
||||
|
||||
INTERFACE_DECL(_EFI_MP_SERVICES_PROTOCOL);
|
||||
|
||||
|
||||
typedef
|
||||
struct {
|
||||
UINT32 Package;
|
||||
UINT32 Core;
|
||||
UINT32 Thread;
|
||||
} EFI_CPU_PHYSICAL_LOCATION;
|
||||
|
||||
typedef
|
||||
struct {
|
||||
UINT32 Package;
|
||||
UINT32 Module;
|
||||
UINT32 Tile;
|
||||
UINT32 Die;
|
||||
UINT32 Core;
|
||||
UINT32 Thread;
|
||||
} EFI_CPU_PHYSICAL_LOCATION2;
|
||||
|
||||
typedef
|
||||
union {
|
||||
EFI_CPU_PHYSICAL_LOCATION2 Location2;
|
||||
} EXTENDED_PROCESSOR_INFORMATION;
|
||||
|
||||
|
||||
typedef
|
||||
struct {
|
||||
UINT64 ProcessorId;
|
||||
UINT32 StatusFlag;
|
||||
EFI_CPU_PHYSICAL_LOCATION Location;
|
||||
EXTENDED_PROCESSOR_INFORMATION ExtendedInformation;
|
||||
} EFI_PROCESSOR_INFORMATION;
|
||||
|
||||
|
||||
typedef
|
||||
VOID
|
||||
(EFIAPI *EFI_AP_PROCEDURE) (
|
||||
IN VOID *ProcedureArgument
|
||||
);
|
||||
|
||||
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_MP_SERVICES_GET_NUMBER_OF_PROCESSORS) (
|
||||
IN struct _EFI_MP_SERVICES_PROTOCOL *This,
|
||||
OUT UINTN *NumberOfProcessors,
|
||||
OUT UINTN *NumberOfEnabledProcessors
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_MP_SERVICES_GET_PROCESSOR_INFO) (
|
||||
IN struct _EFI_MP_SERVICES_PROTOCOL *This,
|
||||
IN UINTN ProcessorNumber,
|
||||
OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_MP_SERVICES_STARTUP_ALL_APS) (
|
||||
IN struct _EFI_MP_SERVICES_PROTOCOL *This,
|
||||
IN EFI_AP_PROCEDURE Procedure,
|
||||
IN BOOLEAN SingleThread,
|
||||
IN EFI_EVENT WaitEvent OPTIONAL,
|
||||
IN UINTN TimeoutInMicroseconds,
|
||||
IN VOID *ProcedureArgument OPTIONAL,
|
||||
OUT UINTN **FailedCpuList OPTIONAL
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_MP_SERVICES_STARTUP_THIS_AP) (
|
||||
IN struct _EFI_MP_SERVICES_PROTOCOL *This,
|
||||
IN EFI_AP_PROCEDURE Procedure,
|
||||
IN UINTN ProcessorNumber,
|
||||
IN EFI_EVENT WaitEvent OPTIONAL,
|
||||
IN UINTN TimeoutInMicroseconds,
|
||||
IN VOID *ProcedureArgument OPTIONAL,
|
||||
OUT BOOLEAN *Finished OPTIONAL
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_MP_SERVICES_SWITCH_BSP) (
|
||||
IN struct _EFI_MP_SERVICES_PROTOCOL *This,
|
||||
IN UINTN ProcessorNumber,
|
||||
IN BOOLEAN EnableOldBSP
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_MP_SERVICES_ENABLEDISABLEAP) (
|
||||
IN struct _EFI_MP_SERVICES_PROTOCOL *This,
|
||||
IN UINTN ProcessorNumber,
|
||||
IN BOOLEAN EnableAP,
|
||||
IN UINT32 *HealthFlag OPTIONAL
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_MP_SERVICES_WHOAMI) (
|
||||
IN struct _EFI_MP_SERVICES_PROTOCOL *This,
|
||||
OUT UINTN *ProcessorNumber
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* The primary protocol structure for MP service methods.
|
||||
*/
|
||||
typedef
|
||||
struct _EFI_MP_SERVICES_PROTOCOL {
|
||||
EFI_MP_SERVICES_GET_NUMBER_OF_PROCESSORS GetNumberOfProcessors;
|
||||
EFI_MP_SERVICES_GET_PROCESSOR_INFO GetProcessorInfo;
|
||||
EFI_MP_SERVICES_STARTUP_ALL_APS StartupAllAPs;
|
||||
EFI_MP_SERVICES_STARTUP_THIS_AP StartupThisAP;
|
||||
EFI_MP_SERVICES_SWITCH_BSP SwitchBSP;
|
||||
EFI_MP_SERVICES_ENABLEDISABLEAP EnableDisableAP;
|
||||
EFI_MP_SERVICES_WHOAMI WhoAmI;
|
||||
} EFI_MP_SERVICES_PROTOCOL;
|
||||
|
||||
|
||||
|
||||
#endif /* _EFI_MP_H */
|
||||
@@ -0,0 +1,348 @@
|
||||
#ifndef _EFINET_H
|
||||
#define _EFINET_H
|
||||
|
||||
|
||||
/*++
|
||||
Copyright (c) 1999 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
efinet.h
|
||||
|
||||
Abstract:
|
||||
EFI Simple Network protocol
|
||||
|
||||
Revision History
|
||||
--*/
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Simple Network Protocol
|
||||
//
|
||||
|
||||
#define EFI_SIMPLE_NETWORK_PROTOCOL_GUID \
|
||||
{ 0xA19832B9, 0xAC25, 0x11D3, {0x9A, 0x2D, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D} }
|
||||
|
||||
INTERFACE_DECL(_EFI_SIMPLE_NETWORK_PROTOCOL);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
||||
typedef struct {
|
||||
//
|
||||
// Total number of frames received. Includes frames with errors and
|
||||
// dropped frames.
|
||||
//
|
||||
UINT64 RxTotalFrames;
|
||||
|
||||
//
|
||||
// Number of valid frames received and copied into receive buffers.
|
||||
//
|
||||
UINT64 RxGoodFrames;
|
||||
|
||||
//
|
||||
// Number of frames below the minimum length for the media.
|
||||
// This would be <64 for ethernet.
|
||||
//
|
||||
UINT64 RxUndersizeFrames;
|
||||
|
||||
//
|
||||
// Number of frames longer than the maxminum length for the
|
||||
// media. This would be >1500 for ethernet.
|
||||
//
|
||||
UINT64 RxOversizeFrames;
|
||||
|
||||
//
|
||||
// Valid frames that were dropped because receive buffers were full.
|
||||
//
|
||||
UINT64 RxDroppedFrames;
|
||||
|
||||
//
|
||||
// Number of valid unicast frames received and not dropped.
|
||||
//
|
||||
UINT64 RxUnicastFrames;
|
||||
|
||||
//
|
||||
// Number of valid broadcast frames received and not dropped.
|
||||
//
|
||||
UINT64 RxBroadcastFrames;
|
||||
|
||||
//
|
||||
// Number of valid mutlicast frames received and not dropped.
|
||||
//
|
||||
UINT64 RxMulticastFrames;
|
||||
|
||||
//
|
||||
// Number of frames w/ CRC or alignment errors.
|
||||
//
|
||||
UINT64 RxCrcErrorFrames;
|
||||
|
||||
//
|
||||
// Total number of bytes received. Includes frames with errors
|
||||
// and dropped frames.
|
||||
//
|
||||
UINT64 RxTotalBytes;
|
||||
|
||||
//
|
||||
// Transmit statistics.
|
||||
//
|
||||
UINT64 TxTotalFrames;
|
||||
UINT64 TxGoodFrames;
|
||||
UINT64 TxUndersizeFrames;
|
||||
UINT64 TxOversizeFrames;
|
||||
UINT64 TxDroppedFrames;
|
||||
UINT64 TxUnicastFrames;
|
||||
UINT64 TxBroadcastFrames;
|
||||
UINT64 TxMulticastFrames;
|
||||
UINT64 TxCrcErrorFrames;
|
||||
UINT64 TxTotalBytes;
|
||||
|
||||
//
|
||||
// Number of collisions detection on this subnet.
|
||||
//
|
||||
UINT64 Collisions;
|
||||
|
||||
//
|
||||
// Number of frames destined for unsupported protocol.
|
||||
//
|
||||
UINT64 UnsupportedProtocol;
|
||||
|
||||
} EFI_NETWORK_STATISTICS;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
||||
typedef enum {
|
||||
EfiSimpleNetworkStopped,
|
||||
EfiSimpleNetworkStarted,
|
||||
EfiSimpleNetworkInitialized,
|
||||
EfiSimpleNetworkMaxState
|
||||
} EFI_SIMPLE_NETWORK_STATE;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
||||
#define EFI_SIMPLE_NETWORK_RECEIVE_UNICAST 0x01
|
||||
#define EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST 0x02
|
||||
#define EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST 0x04
|
||||
#define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS 0x08
|
||||
#define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST 0x10
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
||||
#define EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT 0x01
|
||||
#define EFI_SIMPLE_NETWORK_TRANSMIT_INTERRUPT 0x02
|
||||
#define EFI_SIMPLE_NETWORK_COMMAND_INTERRUPT 0x04
|
||||
#define EFI_SIMPLE_NETWORK_SOFTWARE_INTERRUPT 0x08
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
#define MAX_MCAST_FILTER_CNT 16
|
||||
typedef struct {
|
||||
UINT32 State;
|
||||
UINT32 HwAddressSize;
|
||||
UINT32 MediaHeaderSize;
|
||||
UINT32 MaxPacketSize;
|
||||
UINT32 NvRamSize;
|
||||
UINT32 NvRamAccessSize;
|
||||
UINT32 ReceiveFilterMask;
|
||||
UINT32 ReceiveFilterSetting;
|
||||
UINT32 MaxMCastFilterCount;
|
||||
UINT32 MCastFilterCount;
|
||||
EFI_MAC_ADDRESS MCastFilter[MAX_MCAST_FILTER_CNT];
|
||||
EFI_MAC_ADDRESS CurrentAddress;
|
||||
EFI_MAC_ADDRESS BroadcastAddress;
|
||||
EFI_MAC_ADDRESS PermanentAddress;
|
||||
UINT8 IfType;
|
||||
BOOLEAN MacAddressChangeable;
|
||||
BOOLEAN MultipleTxSupported;
|
||||
BOOLEAN MediaPresentSupported;
|
||||
BOOLEAN MediaPresent;
|
||||
} EFI_SIMPLE_NETWORK_MODE;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SIMPLE_NETWORK_START) (
|
||||
IN struct _EFI_SIMPLE_NETWORK_PROTOCOL *This
|
||||
);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SIMPLE_NETWORK_STOP) (
|
||||
IN struct _EFI_SIMPLE_NETWORK_PROTOCOL *This
|
||||
);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SIMPLE_NETWORK_INITIALIZE) (
|
||||
IN struct _EFI_SIMPLE_NETWORK_PROTOCOL *This,
|
||||
IN UINTN ExtraRxBufferSize OPTIONAL,
|
||||
IN UINTN ExtraTxBufferSize OPTIONAL
|
||||
);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SIMPLE_NETWORK_RESET) (
|
||||
IN struct _EFI_SIMPLE_NETWORK_PROTOCOL *This,
|
||||
IN BOOLEAN ExtendedVerification
|
||||
);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SIMPLE_NETWORK_SHUTDOWN) (
|
||||
IN struct _EFI_SIMPLE_NETWORK_PROTOCOL *This
|
||||
);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SIMPLE_NETWORK_RECEIVE_FILTERS) (
|
||||
IN struct _EFI_SIMPLE_NETWORK_PROTOCOL *This,
|
||||
IN UINT32 Enable,
|
||||
IN UINT32 Disable,
|
||||
IN BOOLEAN ResetMCastFilter,
|
||||
IN UINTN MCastFilterCnt OPTIONAL,
|
||||
IN EFI_MAC_ADDRESS *MCastFilter OPTIONAL
|
||||
);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SIMPLE_NETWORK_STATION_ADDRESS) (
|
||||
IN struct _EFI_SIMPLE_NETWORK_PROTOCOL *This,
|
||||
IN BOOLEAN Reset,
|
||||
IN EFI_MAC_ADDRESS *New OPTIONAL
|
||||
);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SIMPLE_NETWORK_STATISTICS) (
|
||||
IN struct _EFI_SIMPLE_NETWORK_PROTOCOL *This,
|
||||
IN BOOLEAN Reset,
|
||||
IN OUT UINTN *StatisticsSize OPTIONAL,
|
||||
OUT EFI_NETWORK_STATISTICS *StatisticsTable OPTIONAL
|
||||
);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SIMPLE_NETWORK_MCAST_IP_TO_MAC) (
|
||||
IN struct _EFI_SIMPLE_NETWORK_PROTOCOL *This,
|
||||
IN BOOLEAN IPv6,
|
||||
IN EFI_IP_ADDRESS *IP,
|
||||
OUT EFI_MAC_ADDRESS *MAC
|
||||
);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SIMPLE_NETWORK_NVDATA) (
|
||||
IN struct _EFI_SIMPLE_NETWORK_PROTOCOL *This,
|
||||
IN BOOLEAN ReadWrite,
|
||||
IN UINTN Offset,
|
||||
IN UINTN BufferSize,
|
||||
IN OUT VOID *Buffer
|
||||
);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SIMPLE_NETWORK_GET_STATUS) (
|
||||
IN struct _EFI_SIMPLE_NETWORK_PROTOCOL *This,
|
||||
OUT UINT32 *InterruptStatus OPTIONAL,
|
||||
OUT VOID **TxBuf OPTIONAL
|
||||
);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SIMPLE_NETWORK_TRANSMIT) (
|
||||
IN struct _EFI_SIMPLE_NETWORK_PROTOCOL *This,
|
||||
IN UINTN HeaderSize,
|
||||
IN UINTN BufferSize,
|
||||
IN VOID *Buffer,
|
||||
IN EFI_MAC_ADDRESS *SrcAddr OPTIONAL,
|
||||
IN EFI_MAC_ADDRESS *DestAddr OPTIONAL,
|
||||
IN UINT16 *Protocol OPTIONAL
|
||||
);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SIMPLE_NETWORK_RECEIVE) (
|
||||
IN struct _EFI_SIMPLE_NETWORK_PROTOCOL *This,
|
||||
OUT UINTN *HeaderSize OPTIONAL,
|
||||
IN OUT UINTN *BufferSize,
|
||||
OUT VOID *Buffer,
|
||||
OUT EFI_MAC_ADDRESS *SrcAddr OPTIONAL,
|
||||
OUT EFI_MAC_ADDRESS *DestAddr OPTIONAL,
|
||||
OUT UINT16 *Protocol OPTIONAL
|
||||
);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
||||
#define EFI_SIMPLE_NETWORK_PROTOCOL_REVISION 0x00010000
|
||||
#define EFI_SIMPLE_NETWORK_INTERFACE_REVISION EFI_SIMPLE_NETWORK_PROTOCOL_REVISION
|
||||
|
||||
typedef struct _EFI_SIMPLE_NETWORK_PROTOCOL {
|
||||
UINT64 Revision;
|
||||
EFI_SIMPLE_NETWORK_START Start;
|
||||
EFI_SIMPLE_NETWORK_STOP Stop;
|
||||
EFI_SIMPLE_NETWORK_INITIALIZE Initialize;
|
||||
EFI_SIMPLE_NETWORK_RESET Reset;
|
||||
EFI_SIMPLE_NETWORK_SHUTDOWN Shutdown;
|
||||
EFI_SIMPLE_NETWORK_RECEIVE_FILTERS ReceiveFilters;
|
||||
EFI_SIMPLE_NETWORK_STATION_ADDRESS StationAddress;
|
||||
EFI_SIMPLE_NETWORK_STATISTICS Statistics;
|
||||
EFI_SIMPLE_NETWORK_MCAST_IP_TO_MAC MCastIpToMac;
|
||||
EFI_SIMPLE_NETWORK_NVDATA NvData;
|
||||
EFI_SIMPLE_NETWORK_GET_STATUS GetStatus;
|
||||
EFI_SIMPLE_NETWORK_TRANSMIT Transmit;
|
||||
EFI_SIMPLE_NETWORK_RECEIVE Receive;
|
||||
EFI_EVENT WaitForPacket;
|
||||
EFI_SIMPLE_NETWORK_MODE *Mode;
|
||||
} EFI_SIMPLE_NETWORK_PROTOCOL;
|
||||
|
||||
// Note: Because it conflicted with the EDK2 struct name, the
|
||||
// 'EFI_SIMPLE_NETWORK_PROTOCOL' GUID definition, from older
|
||||
// versions of gnu-efi, is now obsoleted.
|
||||
// Use 'EFI_SIMPLE_NETWORK_PROTOCOL_GUID' instead.
|
||||
|
||||
typedef struct _EFI_SIMPLE_NETWORK_PROTOCOL _EFI_SIMPLE_NETWORK;
|
||||
typedef EFI_SIMPLE_NETWORK_PROTOCOL EFI_SIMPLE_NETWORK;
|
||||
|
||||
#endif /* _EFINET_H */
|
||||
@@ -0,0 +1,61 @@
|
||||
#ifndef _EFI_PART_H
|
||||
#define _EFI_PART_H
|
||||
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
efipart.h
|
||||
|
||||
Abstract:
|
||||
Info about disk partitions and Master Boot Records
|
||||
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
#define EFI_PARTITION 0xef
|
||||
#define MBR_SIZE 512
|
||||
|
||||
#pragma pack(1)
|
||||
|
||||
typedef struct {
|
||||
UINT8 BootIndicator;
|
||||
UINT8 StartHead;
|
||||
UINT8 StartSector;
|
||||
UINT8 StartTrack;
|
||||
UINT8 OSIndicator;
|
||||
UINT8 EndHead;
|
||||
UINT8 EndSector;
|
||||
UINT8 EndTrack;
|
||||
UINT8 StartingLBA[4];
|
||||
UINT8 SizeInLBA[4];
|
||||
} MBR_PARTITION_RECORD;
|
||||
|
||||
#define EXTRACT_UINT32(D) (UINT32)(D[0] | (D[1] << 8) | (D[2] << 16) | (D[3] << 24))
|
||||
|
||||
#define MBR_SIGNATURE 0xaa55
|
||||
#define MIN_MBR_DEVICE_SIZE 0x80000
|
||||
#define MBR_ERRATA_PAD 0x40000 // 128 MB
|
||||
|
||||
#define MAX_MBR_PARTITIONS 4
|
||||
typedef struct {
|
||||
UINT8 BootStrapCode[440];
|
||||
UINT8 UniqueMbrSignature[4];
|
||||
UINT8 Unknown[2];
|
||||
MBR_PARTITION_RECORD Partition[MAX_MBR_PARTITIONS];
|
||||
UINT16 Signature;
|
||||
} MASTER_BOOT_RECORD;
|
||||
#pragma pack()
|
||||
|
||||
|
||||
#endif
|
||||
@@ -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 */
|
||||
@@ -0,0 +1,115 @@
|
||||
/* Copyright (C) 2014 by John Cronin
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _EFI_POINT_H
|
||||
#define _EFI_POINT_H
|
||||
|
||||
#define EFI_SIMPLE_POINTER_PROTOCOL_GUID \
|
||||
{ 0x31878c87, 0xb75, 0x11d5, { 0x9a, 0x4f, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } }
|
||||
|
||||
INTERFACE_DECL(_EFI_SIMPLE_POINTER);
|
||||
|
||||
typedef struct {
|
||||
INT32 RelativeMovementX;
|
||||
INT32 RelativeMovementY;
|
||||
INT32 RelativeMovementZ;
|
||||
BOOLEAN LeftButton;
|
||||
BOOLEAN RightButton;
|
||||
} EFI_SIMPLE_POINTER_STATE;
|
||||
|
||||
typedef struct {
|
||||
UINT64 ResolutionX;
|
||||
UINT64 ResolutionY;
|
||||
UINT64 ResolutionZ;
|
||||
BOOLEAN LeftButton;
|
||||
BOOLEAN RightButton;
|
||||
} EFI_SIMPLE_POINTER_MODE;
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SIMPLE_POINTER_RESET) (
|
||||
IN struct _EFI_SIMPLE_POINTER *This,
|
||||
IN BOOLEAN ExtendedVerification
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SIMPLE_POINTER_GET_STATE) (
|
||||
IN struct _EFI_SIMPLE_POINTER *This,
|
||||
IN OUT EFI_SIMPLE_POINTER_STATE *State
|
||||
);
|
||||
|
||||
typedef struct _EFI_SIMPLE_POINTER {
|
||||
EFI_SIMPLE_POINTER_RESET Reset;
|
||||
EFI_SIMPLE_POINTER_GET_STATE GetState;
|
||||
EFI_EVENT WaitForInput;
|
||||
EFI_SIMPLE_POINTER_MODE *Mode;
|
||||
} EFI_SIMPLE_POINTER_PROTOCOL;
|
||||
|
||||
#define EFI_ABSOLUTE_POINTER_PROTOCOL_GUID \
|
||||
{ 0x8D59D32B, 0xC655, 0x4AE9, { 0x9B, 0x15, 0xF2, 0x59, 0x04, 0x99, 0x2A, 0x43 } }
|
||||
|
||||
INTERFACE_DECL(_EFI_ABSOLUTE_POINTER_PROTOCOL);
|
||||
|
||||
typedef struct {
|
||||
UINT64 AbsoluteMinX;
|
||||
UINT64 AbsoluteMinY;
|
||||
UINT64 AbsoluteMinZ;
|
||||
UINT64 AbsoluteMaxX;
|
||||
UINT64 AbsoluteMaxY;
|
||||
UINT64 AbsoluteMaxZ;
|
||||
UINT32 Attributes;
|
||||
} EFI_ABSOLUTE_POINTER_MODE;
|
||||
|
||||
typedef struct {
|
||||
UINT64 CurrentX;
|
||||
UINT64 CurrentY;
|
||||
UINT64 CurrentZ;
|
||||
UINT32 ActiveButtons;
|
||||
} EFI_ABSOLUTE_POINTER_STATE;
|
||||
|
||||
#define EFI_ABSP_SupportsAltActive 0x00000001
|
||||
#define EFI_ABSP_SupportsPressureAsZ 0x00000002
|
||||
#define EFI_ABSP_TouchActive 0x00000001
|
||||
#define EFI_ABS_AltActive 0x00000002
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_ABSOLUTE_POINTER_RESET) (
|
||||
IN struct _EFI_ABSOLUTE_POINTER_PROTOCOL *This,
|
||||
IN BOOLEAN ExtendedVerification
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_ABSOLUTE_POINTER_GET_STATE) (
|
||||
IN struct _EFI_ABSOLUTE_POINTER_PROTOCOL *This,
|
||||
IN OUT EFI_ABSOLUTE_POINTER_STATE *State
|
||||
);
|
||||
|
||||
typedef struct _EFI_ABSOLUTE_POINTER_PROTOCOL {
|
||||
EFI_ABSOLUTE_POINTER_RESET Reset;
|
||||
EFI_ABSOLUTE_POINTER_GET_STATE GetState;
|
||||
EFI_EVENT WaitForInput;
|
||||
EFI_ABSOLUTE_POINTER_MODE *Mode;
|
||||
} EFI_ABSOLUTE_POINTER_PROTOCOL;
|
||||
|
||||
#endif
|
||||
+1529
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,482 @@
|
||||
#ifndef _EFIPXEBC_H
|
||||
#define _EFIPXEBC_H
|
||||
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
efipxebc.h
|
||||
|
||||
Abstract:
|
||||
|
||||
EFI PXE Base Code Protocol
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
//
|
||||
// PXE Base Code protocol
|
||||
//
|
||||
|
||||
#define EFI_PXE_BASE_CODE_PROTOCOL_GUID \
|
||||
{ 0x03c4e603, 0xac28, 0x11d3, {0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d} }
|
||||
|
||||
INTERFACE_DECL(_EFI_PXE_BASE_CODE_PROTOCOL);
|
||||
|
||||
#define DEFAULT_TTL 4
|
||||
#define DEFAULT_ToS 0
|
||||
//
|
||||
// Address definitions
|
||||
//
|
||||
|
||||
typedef union {
|
||||
UINT32 Addr[4];
|
||||
EFI_IPv4_ADDRESS v4;
|
||||
EFI_IPv6_ADDRESS v6;
|
||||
} EFI_IP_ADDRESS;
|
||||
|
||||
typedef UINT16 EFI_PXE_BASE_CODE_UDP_PORT;
|
||||
|
||||
//
|
||||
// Packet definitions
|
||||
//
|
||||
|
||||
typedef struct {
|
||||
UINT8 BootpOpcode;
|
||||
UINT8 BootpHwType;
|
||||
UINT8 BootpHwAddrLen;
|
||||
UINT8 BootpGateHops;
|
||||
UINT32 BootpIdent;
|
||||
UINT16 BootpSeconds;
|
||||
UINT16 BootpFlags;
|
||||
UINT8 BootpCiAddr[4];
|
||||
UINT8 BootpYiAddr[4];
|
||||
UINT8 BootpSiAddr[4];
|
||||
UINT8 BootpGiAddr[4];
|
||||
UINT8 BootpHwAddr[16];
|
||||
UINT8 BootpSrvName[64];
|
||||
UINT8 BootpBootFile[128];
|
||||
UINT32 DhcpMagik;
|
||||
UINT8 DhcpOptions[56];
|
||||
} EFI_PXE_BASE_CODE_DHCPV4_PACKET;
|
||||
|
||||
typedef struct {
|
||||
UINT32 MessageType:8;
|
||||
UINT32 TransactionId:24;
|
||||
UINT8 DhcpOptions[1024];
|
||||
} EFI_PXE_BASE_CODE_DHCPV6_PACKET;
|
||||
|
||||
typedef union {
|
||||
UINT8 Raw[1472];
|
||||
EFI_PXE_BASE_CODE_DHCPV4_PACKET Dhcpv4;
|
||||
EFI_PXE_BASE_CODE_DHCPV6_PACKET Dhcpv6;
|
||||
} EFI_PXE_BASE_CODE_PACKET;
|
||||
|
||||
typedef struct {
|
||||
UINT8 Type;
|
||||
UINT8 Code;
|
||||
UINT16 Checksum;
|
||||
union {
|
||||
UINT32 reserved;
|
||||
UINT32 Mtu;
|
||||
UINT32 Pointer;
|
||||
struct {
|
||||
UINT16 Identifier;
|
||||
UINT16 Sequence;
|
||||
} Echo;
|
||||
} u;
|
||||
UINT8 Data[494];
|
||||
} EFI_PXE_BASE_CODE_ICMP_ERROR;
|
||||
|
||||
typedef struct {
|
||||
UINT8 ErrorCode;
|
||||
CHAR8 ErrorString[127];
|
||||
} EFI_PXE_BASE_CODE_TFTP_ERROR;
|
||||
|
||||
//
|
||||
// IP Receive Filter definitions
|
||||
//
|
||||
#define EFI_PXE_BASE_CODE_MAX_IPCNT 8
|
||||
typedef struct {
|
||||
UINT8 Filters;
|
||||
UINT8 IpCnt;
|
||||
UINT16 reserved;
|
||||
EFI_IP_ADDRESS IpList[EFI_PXE_BASE_CODE_MAX_IPCNT];
|
||||
} EFI_PXE_BASE_CODE_IP_FILTER;
|
||||
|
||||
#define EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP 0x0001
|
||||
#define EFI_PXE_BASE_CODE_IP_FILTER_BROADCAST 0x0002
|
||||
#define EFI_PXE_BASE_CODE_IP_FILTER_PROMISCUOUS 0x0004
|
||||
#define EFI_PXE_BASE_CODE_IP_FILTER_PROMISCUOUS_MULTICAST 0x0008
|
||||
|
||||
//
|
||||
// ARP Cache definitions
|
||||
//
|
||||
|
||||
typedef struct {
|
||||
EFI_IP_ADDRESS IpAddr;
|
||||
EFI_MAC_ADDRESS MacAddr;
|
||||
} EFI_PXE_BASE_CODE_ARP_ENTRY;
|
||||
|
||||
typedef struct {
|
||||
EFI_IP_ADDRESS IpAddr;
|
||||
EFI_IP_ADDRESS SubnetMask;
|
||||
EFI_IP_ADDRESS GwAddr;
|
||||
} EFI_PXE_BASE_CODE_ROUTE_ENTRY;
|
||||
|
||||
//
|
||||
// UDP definitions
|
||||
//
|
||||
|
||||
#define EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_IP 0x0001
|
||||
#define EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_PORT 0x0002
|
||||
#define EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_DEST_IP 0x0004
|
||||
#define EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_DEST_PORT 0x0008
|
||||
#define EFI_PXE_BASE_CODE_UDP_OPFLAGS_USE_FILTER 0x0010
|
||||
#define EFI_PXE_BASE_CODE_UDP_OPFLAGS_MAY_FRAGMENT 0x0020
|
||||
|
||||
//
|
||||
// Discover() definitions
|
||||
//
|
||||
|
||||
#define EFI_PXE_BASE_CODE_BOOT_TYPE_BOOTSTRAP 0
|
||||
#define EFI_PXE_BASE_CODE_BOOT_TYPE_MS_WINNT_RIS 1
|
||||
#define EFI_PXE_BASE_CODE_BOOT_TYPE_INTEL_LCM 2
|
||||
#define EFI_PXE_BASE_CODE_BOOT_TYPE_DOSUNDI 3
|
||||
#define EFI_PXE_BASE_CODE_BOOT_TYPE_NEC_ESMPRO 4
|
||||
#define EFI_PXE_BASE_CODE_BOOT_TYPE_IBM_WSoD 5
|
||||
#define EFI_PXE_BASE_CODE_BOOT_TYPE_IBM_LCCM 6
|
||||
#define EFI_PXE_BASE_CODE_BOOT_TYPE_CA_UNICENTER_TNG 7
|
||||
#define EFI_PXE_BASE_CODE_BOOT_TYPE_HP_OPENVIEW 8
|
||||
#define EFI_PXE_BASE_CODE_BOOT_TYPE_ALTIRIS_9 9
|
||||
#define EFI_PXE_BASE_CODE_BOOT_TYPE_ALTIRIS_10 10
|
||||
#define EFI_PXE_BASE_CODE_BOOT_TYPE_ALTIRIS_11 11
|
||||
#define EFI_PXE_BASE_CODE_BOOT_TYPE_NOT_USED_12 12
|
||||
#define EFI_PXE_BASE_CODE_BOOT_TYPE_REDHAT_INSTALL 13
|
||||
#define EFI_PXE_BASE_CODE_BOOT_TYPE_REDHAT_BOOT 14
|
||||
#define EFI_PXE_BASE_CODE_BOOT_TYPE_REMBO 15
|
||||
#define EFI_PXE_BASE_CODE_BOOT_TYPE_BEOBOOT 16
|
||||
//
|
||||
// 17 through 32767 are reserved
|
||||
// 32768 through 65279 are for vendor use
|
||||
// 65280 through 65534 are reserved
|
||||
//
|
||||
#define EFI_PXE_BASE_CODE_BOOT_TYPE_PXETEST 65535
|
||||
|
||||
#define EFI_PXE_BASE_CODE_BOOT_LAYER_MASK 0x7FFF
|
||||
#define EFI_PXE_BASE_CODE_BOOT_LAYER_INITIAL 0x0000
|
||||
|
||||
|
||||
typedef struct {
|
||||
UINT16 Type;
|
||||
BOOLEAN AcceptAnyResponse;
|
||||
UINT8 Reserved;
|
||||
EFI_IP_ADDRESS IpAddr;
|
||||
} EFI_PXE_BASE_CODE_SRVLIST;
|
||||
|
||||
typedef struct {
|
||||
BOOLEAN UseMCast;
|
||||
BOOLEAN UseBCast;
|
||||
BOOLEAN UseUCast;
|
||||
BOOLEAN MustUseList;
|
||||
EFI_IP_ADDRESS ServerMCastIp;
|
||||
UINT16 IpCnt;
|
||||
EFI_PXE_BASE_CODE_SRVLIST SrvList[1];
|
||||
} EFI_PXE_BASE_CODE_DISCOVER_INFO;
|
||||
|
||||
//
|
||||
// Mtftp() definitions
|
||||
//
|
||||
|
||||
typedef enum {
|
||||
EFI_PXE_BASE_CODE_TFTP_FIRST,
|
||||
EFI_PXE_BASE_CODE_TFTP_GET_FILE_SIZE,
|
||||
EFI_PXE_BASE_CODE_TFTP_READ_FILE,
|
||||
EFI_PXE_BASE_CODE_TFTP_WRITE_FILE,
|
||||
EFI_PXE_BASE_CODE_TFTP_READ_DIRECTORY,
|
||||
EFI_PXE_BASE_CODE_MTFTP_GET_FILE_SIZE,
|
||||
EFI_PXE_BASE_CODE_MTFTP_READ_FILE,
|
||||
EFI_PXE_BASE_CODE_MTFTP_READ_DIRECTORY,
|
||||
EFI_PXE_BASE_CODE_MTFTP_LAST
|
||||
} EFI_PXE_BASE_CODE_TFTP_OPCODE;
|
||||
|
||||
typedef struct {
|
||||
EFI_IP_ADDRESS MCastIp;
|
||||
EFI_PXE_BASE_CODE_UDP_PORT CPort;
|
||||
EFI_PXE_BASE_CODE_UDP_PORT SPort;
|
||||
UINT16 ListenTimeout;
|
||||
UINT16 TransmitTimeout;
|
||||
} EFI_PXE_BASE_CODE_MTFTP_INFO;
|
||||
|
||||
//
|
||||
// PXE Base Code Mode structure
|
||||
//
|
||||
|
||||
#define EFI_PXE_BASE_CODE_MAX_ARP_ENTRIES 8
|
||||
#define EFI_PXE_BASE_CODE_MAX_ROUTE_ENTRIES 8
|
||||
|
||||
typedef struct {
|
||||
BOOLEAN Started;
|
||||
BOOLEAN Ipv6Available;
|
||||
BOOLEAN Ipv6Supported;
|
||||
BOOLEAN UsingIpv6;
|
||||
BOOLEAN BisSupported;
|
||||
BOOLEAN BisDetected;
|
||||
BOOLEAN AutoArp;
|
||||
BOOLEAN SendGUID;
|
||||
BOOLEAN DhcpDiscoverValid;
|
||||
BOOLEAN DhcpAckReceived;
|
||||
BOOLEAN ProxyOfferReceived;
|
||||
BOOLEAN PxeDiscoverValid;
|
||||
BOOLEAN PxeReplyReceived;
|
||||
BOOLEAN PxeBisReplyReceived;
|
||||
BOOLEAN IcmpErrorReceived;
|
||||
BOOLEAN TftpErrorReceived;
|
||||
BOOLEAN MakeCallbacks;
|
||||
UINT8 TTL;
|
||||
UINT8 ToS;
|
||||
EFI_IP_ADDRESS StationIp;
|
||||
EFI_IP_ADDRESS SubnetMask;
|
||||
EFI_PXE_BASE_CODE_PACKET DhcpDiscover;
|
||||
EFI_PXE_BASE_CODE_PACKET DhcpAck;
|
||||
EFI_PXE_BASE_CODE_PACKET ProxyOffer;
|
||||
EFI_PXE_BASE_CODE_PACKET PxeDiscover;
|
||||
EFI_PXE_BASE_CODE_PACKET PxeReply;
|
||||
EFI_PXE_BASE_CODE_PACKET PxeBisReply;
|
||||
EFI_PXE_BASE_CODE_IP_FILTER IpFilter;
|
||||
UINT32 ArpCacheEntries;
|
||||
EFI_PXE_BASE_CODE_ARP_ENTRY ArpCache[EFI_PXE_BASE_CODE_MAX_ARP_ENTRIES];
|
||||
UINT32 RouteTableEntries;
|
||||
EFI_PXE_BASE_CODE_ROUTE_ENTRY RouteTable[EFI_PXE_BASE_CODE_MAX_ROUTE_ENTRIES];
|
||||
EFI_PXE_BASE_CODE_ICMP_ERROR IcmpError;
|
||||
EFI_PXE_BASE_CODE_TFTP_ERROR TftpError;
|
||||
} EFI_PXE_BASE_CODE_MODE;
|
||||
|
||||
//
|
||||
// PXE Base Code Interface Function definitions
|
||||
//
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_PXE_BASE_CODE_START) (
|
||||
IN struct _EFI_PXE_BASE_CODE_PROTOCOL *This,
|
||||
IN BOOLEAN UseIpv6
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_PXE_BASE_CODE_STOP) (
|
||||
IN struct _EFI_PXE_BASE_CODE_PROTOCOL *This
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_PXE_BASE_CODE_DHCP) (
|
||||
IN struct _EFI_PXE_BASE_CODE_PROTOCOL *This,
|
||||
IN BOOLEAN SortOffers
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_PXE_BASE_CODE_DISCOVER) (
|
||||
IN struct _EFI_PXE_BASE_CODE_PROTOCOL *This,
|
||||
IN UINT16 Type,
|
||||
IN UINT16 *Layer,
|
||||
IN BOOLEAN UseBis,
|
||||
IN OUT EFI_PXE_BASE_CODE_DISCOVER_INFO *Info OPTIONAL
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_PXE_BASE_CODE_MTFTP) (
|
||||
IN struct _EFI_PXE_BASE_CODE_PROTOCOL *This,
|
||||
IN EFI_PXE_BASE_CODE_TFTP_OPCODE Operation,
|
||||
IN OUT VOID *BufferPtr OPTIONAL,
|
||||
IN BOOLEAN Overwrite,
|
||||
IN OUT UINT64 *BufferSize,
|
||||
IN UINTN *BlockSize OPTIONAL,
|
||||
IN EFI_IP_ADDRESS *ServerIp,
|
||||
IN UINT8 *Filename,
|
||||
IN EFI_PXE_BASE_CODE_MTFTP_INFO *Info OPTIONAL,
|
||||
IN BOOLEAN DontUseBuffer
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_PXE_BASE_CODE_UDP_WRITE) (
|
||||
IN struct _EFI_PXE_BASE_CODE_PROTOCOL *This,
|
||||
IN UINT16 OpFlags,
|
||||
IN EFI_IP_ADDRESS *DestIp,
|
||||
IN EFI_PXE_BASE_CODE_UDP_PORT *DestPort,
|
||||
IN EFI_IP_ADDRESS *GatewayIp, OPTIONAL
|
||||
IN EFI_IP_ADDRESS *SrcIp, OPTIONAL
|
||||
IN OUT EFI_PXE_BASE_CODE_UDP_PORT *SrcPort, OPTIONAL
|
||||
IN UINTN *HeaderSize, OPTIONAL
|
||||
IN VOID *HeaderPtr, OPTIONAL
|
||||
IN UINTN *BufferSize,
|
||||
IN VOID *BufferPtr
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_PXE_BASE_CODE_UDP_READ) (
|
||||
IN struct _EFI_PXE_BASE_CODE_PROTOCOL *This,
|
||||
IN UINT16 OpFlags,
|
||||
IN OUT EFI_IP_ADDRESS *DestIp, OPTIONAL
|
||||
IN OUT EFI_PXE_BASE_CODE_UDP_PORT *DestPort, OPTIONAL
|
||||
IN OUT EFI_IP_ADDRESS *SrcIp, OPTIONAL
|
||||
IN OUT EFI_PXE_BASE_CODE_UDP_PORT *SrcPort, OPTIONAL
|
||||
IN UINTN *HeaderSize, OPTIONAL
|
||||
IN VOID *HeaderPtr, OPTIONAL
|
||||
IN OUT UINTN *BufferSize,
|
||||
IN VOID *BufferPtr
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_PXE_BASE_CODE_SET_IP_FILTER) (
|
||||
IN struct _EFI_PXE_BASE_CODE_PROTOCOL *This,
|
||||
IN EFI_PXE_BASE_CODE_IP_FILTER *NewFilter
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_PXE_BASE_CODE_ARP) (
|
||||
IN struct _EFI_PXE_BASE_CODE_PROTOCOL *This,
|
||||
IN EFI_IP_ADDRESS *IpAddr,
|
||||
IN EFI_MAC_ADDRESS *MacAddr OPTIONAL
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_PXE_BASE_CODE_SET_PARAMETERS) (
|
||||
IN struct _EFI_PXE_BASE_CODE_PROTOCOL *This,
|
||||
IN BOOLEAN *NewAutoArp, OPTIONAL
|
||||
IN BOOLEAN *NewSendGUID, OPTIONAL
|
||||
IN UINT8 *NewTTL, OPTIONAL
|
||||
IN UINT8 *NewToS, OPTIONAL
|
||||
IN BOOLEAN *NewMakeCallback OPTIONAL
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_PXE_BASE_CODE_SET_STATION_IP) (
|
||||
IN struct _EFI_PXE_BASE_CODE_PROTOCOL *This,
|
||||
IN EFI_IP_ADDRESS *NewStationIp, OPTIONAL
|
||||
IN EFI_IP_ADDRESS *NewSubnetMask OPTIONAL
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_PXE_BASE_CODE_SET_PACKETS) (
|
||||
IN struct _EFI_PXE_BASE_CODE_PROTOCOL *This,
|
||||
BOOLEAN *NewDhcpDiscoverValid, OPTIONAL
|
||||
BOOLEAN *NewDhcpAckReceived, OPTIONAL
|
||||
BOOLEAN *NewProxyOfferReceived, OPTIONAL
|
||||
BOOLEAN *NewPxeDiscoverValid, OPTIONAL
|
||||
BOOLEAN *NewPxeReplyReceived, OPTIONAL
|
||||
BOOLEAN *NewPxeBisReplyReceived,OPTIONAL
|
||||
IN EFI_PXE_BASE_CODE_PACKET *NewDhcpDiscover, OPTIONAL
|
||||
IN EFI_PXE_BASE_CODE_PACKET *NewDhcpAck, OPTIONAL
|
||||
IN EFI_PXE_BASE_CODE_PACKET *NewProxyOffer, OPTIONAL
|
||||
IN EFI_PXE_BASE_CODE_PACKET *NewPxeDiscover, OPTIONAL
|
||||
IN EFI_PXE_BASE_CODE_PACKET *NewPxeReply, OPTIONAL
|
||||
IN EFI_PXE_BASE_CODE_PACKET *NewPxeBisReply OPTIONAL
|
||||
);
|
||||
|
||||
//
|
||||
// PXE Base Code Protocol structure
|
||||
//
|
||||
|
||||
#define EFI_PXE_BASE_CODE_PROTOCOL_REVISION 0x00010000
|
||||
#define EFI_PXE_BASE_CODE_INTERFACE_REVISION EFI_PXE_BASE_CODE_PROTOCOL_REVISION
|
||||
|
||||
typedef struct _EFI_PXE_BASE_CODE_PROTOCOL {
|
||||
UINT64 Revision;
|
||||
EFI_PXE_BASE_CODE_START Start;
|
||||
EFI_PXE_BASE_CODE_STOP Stop;
|
||||
EFI_PXE_BASE_CODE_DHCP Dhcp;
|
||||
EFI_PXE_BASE_CODE_DISCOVER Discover;
|
||||
EFI_PXE_BASE_CODE_MTFTP Mtftp;
|
||||
EFI_PXE_BASE_CODE_UDP_WRITE UdpWrite;
|
||||
EFI_PXE_BASE_CODE_UDP_READ UdpRead;
|
||||
EFI_PXE_BASE_CODE_SET_IP_FILTER SetIpFilter;
|
||||
EFI_PXE_BASE_CODE_ARP Arp;
|
||||
EFI_PXE_BASE_CODE_SET_PARAMETERS SetParameters;
|
||||
EFI_PXE_BASE_CODE_SET_STATION_IP SetStationIp;
|
||||
EFI_PXE_BASE_CODE_SET_PACKETS SetPackets;
|
||||
EFI_PXE_BASE_CODE_MODE *Mode;
|
||||
} EFI_PXE_BASE_CODE_PROTOCOL;
|
||||
|
||||
// Note: Because it conflicted with the EDK2 struct name, the
|
||||
// 'EFI_PXE_BASE_CODE_PROTOCOL' GUID definition, from older
|
||||
// versions of gnu-efi, is now obsoleted.
|
||||
// Use 'EFI_PXE_BASE_CODE_PROTOCOL_GUID' instead.
|
||||
|
||||
typedef struct _EFI_PXE_BASE_CODE_PROTOCOL _EFI_PXE_BASE_CODE;
|
||||
typedef struct _EFI_PXE_BASE_CODE_PROTOCOL EFI_PXE_BASE_CODE;
|
||||
|
||||
//
|
||||
// Call Back Definitions
|
||||
//
|
||||
|
||||
#define EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL_GUID \
|
||||
{ 0x245dca21, 0xfb7b, 0x11d3, {0x8f, 0x01, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b} }
|
||||
|
||||
//
|
||||
// Revision Number
|
||||
//
|
||||
|
||||
#define EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL_REVISION 0x00010000
|
||||
#define EFI_PXE_BASE_CODE_CALLBACK_INTERFACE_REVISION EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL_REVISION
|
||||
|
||||
INTERFACE_DECL(_EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL);
|
||||
|
||||
typedef enum {
|
||||
EFI_PXE_BASE_CODE_FUNCTION_FIRST,
|
||||
EFI_PXE_BASE_CODE_FUNCTION_DHCP,
|
||||
EFI_PXE_BASE_CODE_FUNCTION_DISCOVER,
|
||||
EFI_PXE_BASE_CODE_FUNCTION_MTFTP,
|
||||
EFI_PXE_BASE_CODE_FUNCTION_UDP_WRITE,
|
||||
EFI_PXE_BASE_CODE_FUNCTION_UDP_READ,
|
||||
EFI_PXE_BASE_CODE_FUNCTION_ARP,
|
||||
EFI_PXE_BASE_CODE_FUNCTION_IGMP,
|
||||
EFI_PXE_BASE_CODE_PXE_FUNCTION_LAST
|
||||
} EFI_PXE_BASE_CODE_FUNCTION;
|
||||
|
||||
typedef enum {
|
||||
EFI_PXE_BASE_CODE_CALLBACK_STATUS_FIRST,
|
||||
EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE,
|
||||
EFI_PXE_BASE_CODE_CALLBACK_STATUS_ABORT,
|
||||
EFI_PXE_BASE_CODE_CALLBACK_STATUS_LAST
|
||||
} EFI_PXE_BASE_CODE_CALLBACK_STATUS;
|
||||
|
||||
typedef
|
||||
EFI_PXE_BASE_CODE_CALLBACK_STATUS
|
||||
(EFIAPI *EFI_PXE_CALLBACK) (
|
||||
IN struct _EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL *This,
|
||||
IN EFI_PXE_BASE_CODE_FUNCTION Function,
|
||||
IN BOOLEAN Received,
|
||||
IN UINT32 PacketLen,
|
||||
IN EFI_PXE_BASE_CODE_PACKET *Packet OPTIONAL
|
||||
);
|
||||
|
||||
typedef struct _EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL {
|
||||
UINT64 Revision;
|
||||
EFI_PXE_CALLBACK Callback;
|
||||
} EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL;
|
||||
|
||||
// Note: Because it conflicted with the EDK2 struct name, the
|
||||
// 'EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL' GUID definition, from
|
||||
// older versions of gnu-efi, is now obsoleted.
|
||||
// Use 'EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL_GUID' instead.
|
||||
|
||||
typedef struct _EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL _EFI_PXE_BASE_CODE_CALLBACK;
|
||||
typedef EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL EFI_PXE_BASE_CODE_CALLBACK;
|
||||
|
||||
#endif /* _EFIPXEBC_H */
|
||||
@@ -0,0 +1,212 @@
|
||||
#ifndef _EFI_RT_LIB_INCLUDE_
|
||||
#define _EFI_RT_LIB_INCLUDE_
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
efilib.h
|
||||
|
||||
Abstract:
|
||||
|
||||
EFI Runtime library functions
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
#include "efidebug.h"
|
||||
#include "efipart.h"
|
||||
#if defined(_M_X64) || defined(__x86_64__) || defined(__amd64__)
|
||||
#include "x86_64/efilibplat.h"
|
||||
#elif defined(_M_IX86) || defined(__i386__)
|
||||
#include "ia32/efilibplat.h"
|
||||
#elif defined(_M_IA64) || defined(__ia64__)
|
||||
#include "ia64/efilibplat.h"
|
||||
#elif defined (_M_ARM64) || defined(__aarch64__)
|
||||
#include "aarch64/efilibplat.h"
|
||||
#elif defined (_M_ARM) || defined(__arm__)
|
||||
#include "arm/efilibplat.h"
|
||||
#elif defined (_M_MIPS64) || defined(__mips64__) || defined(__mips64)
|
||||
#include "mips64el/efilibplat.h"
|
||||
#elif defined (__riscv) && __riscv_xlen == 64
|
||||
#include "riscv64/efilibplat.h"
|
||||
#endif
|
||||
|
||||
|
||||
VOID
|
||||
RUNTIMEFUNCTION
|
||||
RtZeroMem (
|
||||
IN VOID *Buffer,
|
||||
IN UINTN Size
|
||||
);
|
||||
|
||||
VOID
|
||||
EFIAPI
|
||||
RUNTIMEFUNCTION
|
||||
RtSetMem (
|
||||
IN VOID *Buffer,
|
||||
IN UINTN Size,
|
||||
IN UINT8 Value
|
||||
);
|
||||
|
||||
VOID
|
||||
EFIAPI
|
||||
RUNTIMEFUNCTION
|
||||
RtCopyMem (
|
||||
IN VOID *Dest,
|
||||
IN VOID *Src,
|
||||
IN UINTN len
|
||||
);
|
||||
|
||||
VOID
|
||||
EFIAPI
|
||||
RUNTIMEFUNCTION
|
||||
RtCopyMemC (
|
||||
IN VOID *Dest,
|
||||
IN CONST VOID *Src,
|
||||
IN UINTN len
|
||||
);
|
||||
|
||||
INTN
|
||||
RUNTIMEFUNCTION
|
||||
RtCompareMem (
|
||||
IN CONST VOID *Dest,
|
||||
IN CONST VOID *Src,
|
||||
IN UINTN len
|
||||
);
|
||||
|
||||
INTN
|
||||
RUNTIMEFUNCTION
|
||||
RtStrCmp (
|
||||
IN CONST CHAR16 *s1,
|
||||
IN CONST CHAR16 *s2
|
||||
);
|
||||
|
||||
|
||||
VOID
|
||||
RUNTIMEFUNCTION
|
||||
RtStrCpy (
|
||||
IN CHAR16 *Dest,
|
||||
IN CONST CHAR16 *Src
|
||||
);
|
||||
|
||||
VOID
|
||||
RUNTIMEFUNCTION
|
||||
RtStrnCpy (
|
||||
IN CHAR16 *Dest,
|
||||
IN CONST CHAR16 *Src,
|
||||
IN UINTN Len
|
||||
);
|
||||
|
||||
CHAR16 *
|
||||
RUNTIMEFUNCTION
|
||||
RtStpCpy (
|
||||
IN CHAR16 *Dest,
|
||||
IN CONST CHAR16 *Src
|
||||
);
|
||||
|
||||
CHAR16 *
|
||||
RUNTIMEFUNCTION
|
||||
RtStpnCpy (
|
||||
IN CHAR16 *Dest,
|
||||
IN CONST CHAR16 *Src,
|
||||
IN UINTN Len
|
||||
);
|
||||
|
||||
VOID
|
||||
RUNTIMEFUNCTION
|
||||
RtStrCat (
|
||||
IN CHAR16 *Dest,
|
||||
IN CONST CHAR16 *Src
|
||||
);
|
||||
|
||||
VOID
|
||||
RUNTIMEFUNCTION
|
||||
RtStrnCat (
|
||||
IN CHAR16 *Dest,
|
||||
IN CONST CHAR16 *Src,
|
||||
IN UINTN Len
|
||||
);
|
||||
|
||||
UINTN
|
||||
RUNTIMEFUNCTION
|
||||
RtStrLen (
|
||||
IN CONST CHAR16 *s1
|
||||
);
|
||||
|
||||
UINTN
|
||||
RUNTIMEFUNCTION
|
||||
RtStrnLen (
|
||||
IN CONST CHAR16 *s1,
|
||||
IN UINTN Len
|
||||
);
|
||||
|
||||
UINTN
|
||||
RUNTIMEFUNCTION
|
||||
RtStrSize (
|
||||
IN CONST CHAR16 *s1
|
||||
);
|
||||
|
||||
BOOLEAN
|
||||
EFIAPI
|
||||
RUNTIMEFUNCTION
|
||||
RtCompareGuid (
|
||||
IN CONST EFI_GUID *Guid1,
|
||||
IN CONST EFI_GUID *Guid2
|
||||
);
|
||||
|
||||
BOOLEAN
|
||||
EFIAPI
|
||||
RUNTIMEFUNCTION
|
||||
RtIsZeroGuid (
|
||||
IN CONST EFI_GUID *Guid1
|
||||
);
|
||||
|
||||
UINT8
|
||||
RUNTIMEFUNCTION
|
||||
RtDecimaltoBCD(
|
||||
IN UINT8 BcdValue
|
||||
);
|
||||
|
||||
UINT8
|
||||
RUNTIMEFUNCTION
|
||||
RtBCDtoDecimal(
|
||||
IN UINT8 BcdValue
|
||||
);
|
||||
|
||||
//
|
||||
// Virtual mapping transition support. (Only used during
|
||||
// the virtual address change transisition)
|
||||
//
|
||||
|
||||
VOID
|
||||
RUNTIMEFUNCTION
|
||||
RtLibEnableVirtualMappings (
|
||||
VOID
|
||||
);
|
||||
|
||||
VOID
|
||||
RUNTIMEFUNCTION
|
||||
RtConvertList (
|
||||
IN UINTN DebugDisposition,
|
||||
IN OUT LIST_ENTRY *ListHead
|
||||
);
|
||||
|
||||
VOID
|
||||
RUNTIMEFUNCTION
|
||||
RtAcquireLock (
|
||||
IN FLOCK *Lock
|
||||
);
|
||||
|
||||
VOID
|
||||
RUNTIMEFUNCTION
|
||||
RtReleaseLock (
|
||||
IN FLOCK *Lock
|
||||
);
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,136 @@
|
||||
#ifndef _EFI_SER_H
|
||||
#define _EFI_SER_H
|
||||
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
efiser.h
|
||||
|
||||
Abstract:
|
||||
|
||||
EFI serial protocol
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
//
|
||||
// Serial protocol
|
||||
//
|
||||
|
||||
#define EFI_SERIAL_IO_PROTOCOL_GUID \
|
||||
{ 0xBB25CF6F, 0xF1D4, 0x11D2, {0x9A, 0x0C, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0xFD} }
|
||||
#define SERIAL_IO_PROTOCOL EFI_SERIAL_IO_PROTOCOL_GUID
|
||||
|
||||
INTERFACE_DECL(_EFI_SERIAL_IO_PROTOCOL);
|
||||
|
||||
typedef enum {
|
||||
DefaultParity,
|
||||
NoParity,
|
||||
EvenParity,
|
||||
OddParity,
|
||||
MarkParity,
|
||||
SpaceParity
|
||||
} EFI_PARITY_TYPE;
|
||||
|
||||
typedef enum {
|
||||
DefaultStopBits,
|
||||
OneStopBit, // 1 stop bit
|
||||
OneFiveStopBits, // 1.5 stop bits
|
||||
TwoStopBits // 2 stop bits
|
||||
} EFI_STOP_BITS_TYPE;
|
||||
|
||||
#define EFI_SERIAL_CLEAR_TO_SEND 0x0010 // RO
|
||||
#define EFI_SERIAL_DATA_SET_READY 0x0020 // RO
|
||||
#define EFI_SERIAL_RING_INDICATE 0x0040 // RO
|
||||
#define EFI_SERIAL_CARRIER_DETECT 0x0080 // RO
|
||||
#define EFI_SERIAL_REQUEST_TO_SEND 0x0002 // WO
|
||||
#define EFI_SERIAL_DATA_TERMINAL_READY 0x0001 // WO
|
||||
#define EFI_SERIAL_INPUT_BUFFER_EMPTY 0x0100 // RO
|
||||
#define EFI_SERIAL_OUTPUT_BUFFER_EMPTY 0x0200 // RO
|
||||
#define EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE 0x1000 // RW
|
||||
#define EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE 0x2000 // RW
|
||||
#define EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE 0x4000 // RW
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SERIAL_RESET) (
|
||||
IN struct _EFI_SERIAL_IO_PROTOCOL *This
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SERIAL_SET_ATTRIBUTES) (
|
||||
IN struct _EFI_SERIAL_IO_PROTOCOL *This,
|
||||
IN UINT64 BaudRate,
|
||||
IN UINT32 ReceiveFifoDepth,
|
||||
IN UINT32 Timeout,
|
||||
IN EFI_PARITY_TYPE Parity,
|
||||
IN UINT8 DataBits,
|
||||
IN EFI_STOP_BITS_TYPE StopBits
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SERIAL_SET_CONTROL_BITS) (
|
||||
IN struct _EFI_SERIAL_IO_PROTOCOL *This,
|
||||
IN UINT32 Control
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SERIAL_GET_CONTROL_BITS) (
|
||||
IN struct _EFI_SERIAL_IO_PROTOCOL *This,
|
||||
OUT UINT32 *Control
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SERIAL_WRITE) (
|
||||
IN struct _EFI_SERIAL_IO_PROTOCOL *This,
|
||||
IN OUT UINTN *BufferSize,
|
||||
IN VOID *Buffer
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SERIAL_READ) (
|
||||
IN struct _EFI_SERIAL_IO_PROTOCOL *This,
|
||||
IN OUT UINTN *BufferSize,
|
||||
OUT VOID *Buffer
|
||||
);
|
||||
|
||||
typedef struct {
|
||||
UINT32 ControlMask;
|
||||
|
||||
// current Attributes
|
||||
UINT32 Timeout;
|
||||
UINT64 BaudRate;
|
||||
UINT32 ReceiveFifoDepth;
|
||||
UINT32 DataBits;
|
||||
UINT32 Parity;
|
||||
UINT32 StopBits;
|
||||
} SERIAL_IO_MODE;
|
||||
|
||||
#define SERIAL_IO_INTERFACE_REVISION 0x00010000
|
||||
|
||||
typedef struct _EFI_SERIAL_IO_PROTOCOL {
|
||||
UINT32 Revision;
|
||||
EFI_SERIAL_RESET Reset;
|
||||
EFI_SERIAL_SET_ATTRIBUTES SetAttributes;
|
||||
EFI_SERIAL_SET_CONTROL_BITS SetControl;
|
||||
EFI_SERIAL_GET_CONTROL_BITS GetControl;
|
||||
EFI_SERIAL_WRITE Write;
|
||||
EFI_SERIAL_READ Read;
|
||||
|
||||
SERIAL_IO_MODE *Mode;
|
||||
} EFI_SERIAL_IO_PROTOCOL;
|
||||
|
||||
typedef struct _EFI_SERIAL_IO_PROTOCOL _SERIAL_IO_INTERFACE;
|
||||
typedef EFI_SERIAL_IO_PROTOCOL SERIAL_IO_INTERFACE;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
#ifndef GNU_EFI_SETJMP_H
|
||||
#define GNU_EFI_SETJMP_H
|
||||
|
||||
#if !defined(_MSC_VER)
|
||||
|
||||
#include "eficompiler.h"
|
||||
#include "efisetjmp_arch.h"
|
||||
|
||||
extern UINTN base_setjmp(jmp_buf env) __attribute__((returns_twice));
|
||||
extern VOID base_longjmp(jmp_buf env, UINTN value) EFI_NORETURN;
|
||||
|
||||
#define setjmp(env) (int)base_setjmp(env)
|
||||
#define longjmp(env, value) base_longjmp(env, (UINTN)value)
|
||||
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
#endif /* GNU_EFI_SETJMP_H */
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
#ifndef GNU_EFI_SETJMP_ARCH_H
|
||||
#define GNU_EFI_SETJMP_ARCH_H
|
||||
|
||||
#if defined(__x86_64__)
|
||||
#include "x86_64/efisetjmp_arch.h"
|
||||
#elif defined(__aarch64__)
|
||||
#include "aarch64/efisetjmp_arch.h"
|
||||
#elif defined(__riscv) && __riscv_xlen == 64
|
||||
#include "riscv64/efisetjmp_arch.h"
|
||||
#elif defined(__i386__)
|
||||
#include "ia32/efisetjmp_arch.h"
|
||||
#elif defined(__ia64__)
|
||||
#include "ia64/efisetjmp_arch.h"
|
||||
#elif defined(__loongarch64)
|
||||
#include "loongarch64/efisetjmp_arch.h"
|
||||
#elif defined(__mips64__)
|
||||
#include "mips64el/efisetjmp_arch.h"
|
||||
#elif defined(__arm__)
|
||||
#include "arm/efisetjmp_arch.h"
|
||||
#endif
|
||||
|
||||
#endif /* GNU_EFI_SETJMP_ARCH_H */
|
||||
@@ -0,0 +1,449 @@
|
||||
/**
|
||||
EFI Shell protocol as defined in the UEFI Shell Specification 2.2.
|
||||
|
||||
(C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>
|
||||
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
This file is based on MdePkg/Include/Protocol/Shell.h from EDK2
|
||||
Ported to gnu-efi by Jiaqing Zhao <jiaqing.zhao@intel.com>
|
||||
**/
|
||||
|
||||
#ifndef _EFI_SHELL_H
|
||||
#define _EFI_SHELL_H
|
||||
|
||||
#include "efilink.h"
|
||||
|
||||
#define EFI_SHELL_PROTOCOL_GUID \
|
||||
{ 0x6302d008, 0x7f9b, 0x4f30, { 0x87, 0xac, 0x60, 0xc9, 0xfe, 0xf5, 0xda, 0x4e } }
|
||||
|
||||
INTERFACE_DECL(_EFI_SHELL_PROTOCOL);
|
||||
|
||||
typedef enum {
|
||||
SHELL_SUCCESS = 0,
|
||||
SHELL_LOAD_ERROR = 1,
|
||||
SHELL_INVALID_PARAMETER = 2,
|
||||
SHELL_UNSUPPORTED = 3,
|
||||
SHELL_BAD_BUFFER_SIZE = 4,
|
||||
SHELL_BUFFER_TOO_SMALL = 5,
|
||||
SHELL_NOT_READY = 6,
|
||||
SHELL_DEVICE_ERROR = 7,
|
||||
SHELL_WRITE_PROTECTED = 8,
|
||||
SHELL_OUT_OF_RESOURCES = 9,
|
||||
SHELL_VOLUME_CORRUPTED = 10,
|
||||
SHELL_VOLUME_FULL = 11,
|
||||
SHELL_NO_MEDIA = 12,
|
||||
SHELL_MEDIA_CHANGED = 13,
|
||||
SHELL_NOT_FOUND = 14,
|
||||
SHELL_ACCESS_DENIED = 15,
|
||||
SHELL_TIMEOUT = 18,
|
||||
SHELL_NOT_STARTED = 19,
|
||||
SHELL_ALREADY_STARTED = 20,
|
||||
SHELL_ABORTED = 21,
|
||||
SHELL_INCOMPATIBLE_VERSION = 25,
|
||||
SHELL_SECURITY_VIOLATION = 26,
|
||||
SHELL_NOT_EQUAL = 27
|
||||
} SHELL_STATUS;
|
||||
|
||||
typedef VOID *SHELL_FILE_HANDLE;
|
||||
|
||||
typedef struct {
|
||||
EFI_LIST_ENTRY Link;
|
||||
EFI_STATUS Status;
|
||||
CONST CHAR16 *FullName;
|
||||
CONST CHAR16 *FileName;
|
||||
SHELL_FILE_HANDLE Handle;
|
||||
EFI_FILE_INFO *Info;
|
||||
} EFI_SHELL_FILE_INFO;
|
||||
|
||||
typedef
|
||||
BOOLEAN
|
||||
(EFIAPI *EFI_SHELL_BATCH_IS_ACTIVE) (
|
||||
VOID
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SHELL_CLOSE_FILE) (
|
||||
IN SHELL_FILE_HANDLE FileHandle
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SHELL_CREATE_FILE) (
|
||||
IN CONST CHAR16 *FileName,
|
||||
IN UINT64 FileAttribs,
|
||||
OUT SHELL_FILE_HANDLE *FileHandle
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SHELL_DELETE_FILE) (
|
||||
IN SHELL_FILE_HANDLE FileHandle
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SHELL_DELETE_FILE_BY_NAME) (
|
||||
IN CONST CHAR16 *FileName
|
||||
);
|
||||
|
||||
typedef
|
||||
VOID
|
||||
(EFIAPI *EFI_SHELL_DISABLE_PAGE_BREAK) (
|
||||
VOID
|
||||
);
|
||||
|
||||
typedef
|
||||
VOID
|
||||
(EFIAPI *EFI_SHELL_ENABLE_PAGE_BREAK) (
|
||||
VOID
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SHELL_EXECUTE) (
|
||||
IN EFI_HANDLE *ParentImageHandle,
|
||||
IN CHAR16 *CommandLine OPTIONAL,
|
||||
IN CHAR16 **Environment OPTIONAL,
|
||||
OUT EFI_STATUS *StatusCode OPTIONAL
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SHELL_FIND_FILES) (
|
||||
IN CONST CHAR16 *FilePattern,
|
||||
OUT EFI_SHELL_FILE_INFO **FileList
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SHELL_FIND_FILES_IN_DIR) (
|
||||
IN SHELL_FILE_HANDLE FileDirHandle,
|
||||
OUT EFI_SHELL_FILE_INFO **FileList
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SHELL_FLUSH_FILE) (
|
||||
IN SHELL_FILE_HANDLE FileHandle
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SHELL_FREE_FILE_LIST) (
|
||||
IN EFI_SHELL_FILE_INFO **FileList
|
||||
);
|
||||
|
||||
typedef
|
||||
CONST CHAR16 *
|
||||
(EFIAPI *EFI_SHELL_GET_ALIAS) (
|
||||
IN CONST CHAR16 *Alias,
|
||||
OUT BOOLEAN *Volatile OPTIONAL
|
||||
);
|
||||
|
||||
typedef
|
||||
CONST CHAR16 *
|
||||
(EFIAPI *EFI_SHELL_GET_CUR_DIR) (
|
||||
IN CONST CHAR16 *FileSystemMapping OPTIONAL
|
||||
);
|
||||
|
||||
typedef UINT32 EFI_SHELL_DEVICE_NAME_FLAGS;
|
||||
#define EFI_DEVICE_NAME_USE_COMPONENT_NAME 0x00000001
|
||||
#define EFI_DEVICE_NAME_USE_DEVICE_PATH 0x00000002
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SHELL_GET_DEVICE_NAME) (
|
||||
IN EFI_HANDLE DeviceHandle,
|
||||
IN EFI_SHELL_DEVICE_NAME_FLAGS Flags,
|
||||
IN CHAR8 *Language,
|
||||
OUT CHAR16 **BestDeviceName
|
||||
);
|
||||
|
||||
typedef
|
||||
CONST EFI_DEVICE_PATH_PROTOCOL *
|
||||
(EFIAPI *EFI_SHELL_GET_DEVICE_PATH_FROM_MAP) (
|
||||
IN CONST CHAR16 *Mapping
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_DEVICE_PATH_PROTOCOL *
|
||||
(EFIAPI *EFI_SHELL_GET_DEVICE_PATH_FROM_FILE_PATH) (
|
||||
IN CONST CHAR16 *Path
|
||||
);
|
||||
|
||||
typedef
|
||||
CONST CHAR16 *
|
||||
(EFIAPI *EFI_SHELL_GET_ENV) (
|
||||
IN CONST CHAR16 *Name
|
||||
);
|
||||
|
||||
typedef
|
||||
CONST CHAR16 *
|
||||
(EFIAPI *EFI_SHELL_GET_ENV_EX) (
|
||||
IN CONST CHAR16 *Name,
|
||||
OUT UINT32 *Attributes OPTIONAL
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_FILE_INFO *
|
||||
(EFIAPI *EFI_SHELL_GET_FILE_INFO) (
|
||||
IN SHELL_FILE_HANDLE FileHandle
|
||||
);
|
||||
|
||||
typedef
|
||||
CHAR16 *
|
||||
(EFIAPI *EFI_SHELL_GET_FILE_PATH_FROM_DEVICE_PATH) (
|
||||
IN CONST EFI_DEVICE_PATH_PROTOCOL *Path
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SHELL_GET_FILE_POSITION) (
|
||||
IN SHELL_FILE_HANDLE FileHandle,
|
||||
OUT UINT64 *Position
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SHELL_GET_FILE_SIZE) (
|
||||
IN SHELL_FILE_HANDLE FileHandle,
|
||||
OUT UINT64 *Size
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SHELL_GET_GUID_FROM_NAME) (
|
||||
IN CONST CHAR16 *GuidName,
|
||||
OUT EFI_GUID *Guid
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SHELL_GET_GUID_NAME)(
|
||||
IN CONST EFI_GUID *Guid,
|
||||
OUT CONST CHAR16 **GuidName
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SHELL_GET_HELP_TEXT) (
|
||||
IN CONST CHAR16 *Command,
|
||||
IN CONST CHAR16 *Sections,
|
||||
OUT CHAR16 **HelpText
|
||||
);
|
||||
|
||||
typedef
|
||||
CONST CHAR16 *
|
||||
(EFIAPI *EFI_SHELL_GET_MAP_FROM_DEVICE_PATH) (
|
||||
IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
|
||||
);
|
||||
|
||||
typedef
|
||||
BOOLEAN
|
||||
(EFIAPI *EFI_SHELL_GET_PAGE_BREAK) (
|
||||
VOID
|
||||
);
|
||||
|
||||
typedef
|
||||
BOOLEAN
|
||||
(EFIAPI *EFI_SHELL_IS_ROOT_SHELL) (
|
||||
VOID
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SHELL_OPEN_FILE_BY_NAME) (
|
||||
IN CONST CHAR16 *FileName,
|
||||
OUT SHELL_FILE_HANDLE *FileHandle,
|
||||
IN UINT64 OpenMode
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SHELL_OPEN_FILE_LIST) (
|
||||
IN CHAR16 *Path,
|
||||
IN UINT64 OpenMode,
|
||||
IN OUT EFI_SHELL_FILE_INFO **FileList
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SHELL_OPEN_ROOT) (
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
|
||||
OUT SHELL_FILE_HANDLE *FileHandle
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SHELL_OPEN_ROOT_BY_HANDLE) (
|
||||
IN EFI_HANDLE DeviceHandle,
|
||||
OUT SHELL_FILE_HANDLE *FileHandle
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SHELL_READ_FILE) (
|
||||
IN SHELL_FILE_HANDLE FileHandle,
|
||||
IN OUT UINTN *ReadSize,
|
||||
IN OUT VOID *Buffer
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SHELL_REGISTER_GUID_NAME) (
|
||||
IN CONST EFI_GUID *Guid,
|
||||
IN CONST CHAR16 *GuidName
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SHELL_REMOVE_DUP_IN_FILE_LIST) (
|
||||
IN EFI_SHELL_FILE_INFO **FileList
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SHELL_SET_ALIAS) (
|
||||
IN CONST CHAR16 *Command,
|
||||
IN CONST CHAR16 *Alias,
|
||||
IN BOOLEAN Replace,
|
||||
IN BOOLEAN Volatile
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SHELL_SET_CUR_DIR) (
|
||||
IN CONST CHAR16 *FileSystem OPTIONAL,
|
||||
IN CONST CHAR16 *Dir
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SHELL_SET_ENV) (
|
||||
IN CONST CHAR16 *Name,
|
||||
IN CONST CHAR16 *Value,
|
||||
IN BOOLEAN Volatile
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SHELL_SET_FILE_INFO) (
|
||||
IN SHELL_FILE_HANDLE FileHandle,
|
||||
IN CONST EFI_FILE_INFO *FileInfo
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SHELL_SET_FILE_POSITION) (
|
||||
IN SHELL_FILE_HANDLE FileHandle,
|
||||
IN UINT64 Position
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SHELL_SET_MAP) (
|
||||
IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
|
||||
IN CONST CHAR16 *Mapping
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SHELL_WRITE_FILE) (
|
||||
IN SHELL_FILE_HANDLE FileHandle,
|
||||
IN OUT UINTN *BufferSize,
|
||||
IN VOID *Buffer
|
||||
);
|
||||
|
||||
typedef struct _EFI_SHELL_PROTOCOL {
|
||||
EFI_SHELL_EXECUTE Execute;
|
||||
EFI_SHELL_GET_ENV GetEnv;
|
||||
EFI_SHELL_SET_ENV SetEnv;
|
||||
EFI_SHELL_GET_ALIAS GetAlias;
|
||||
EFI_SHELL_SET_ALIAS SetAlias;
|
||||
EFI_SHELL_GET_HELP_TEXT GetHelpText;
|
||||
EFI_SHELL_GET_DEVICE_PATH_FROM_MAP GetDevicePathFromMap;
|
||||
EFI_SHELL_GET_MAP_FROM_DEVICE_PATH GetMapFromDevicePath;
|
||||
EFI_SHELL_GET_DEVICE_PATH_FROM_FILE_PATH GetDevicePathFromFilePath;
|
||||
EFI_SHELL_GET_FILE_PATH_FROM_DEVICE_PATH GetFilePathFromDevicePath;
|
||||
EFI_SHELL_SET_MAP SetMap;
|
||||
EFI_SHELL_GET_CUR_DIR GetCurDir;
|
||||
EFI_SHELL_SET_CUR_DIR SetCurDir;
|
||||
EFI_SHELL_OPEN_FILE_LIST OpenFileList;
|
||||
EFI_SHELL_FREE_FILE_LIST FreeFileList;
|
||||
EFI_SHELL_REMOVE_DUP_IN_FILE_LIST RemoveDupInFileList;
|
||||
EFI_SHELL_BATCH_IS_ACTIVE BatchIsActive;
|
||||
EFI_SHELL_IS_ROOT_SHELL IsRootShell;
|
||||
EFI_SHELL_ENABLE_PAGE_BREAK EnablePageBreak;
|
||||
EFI_SHELL_DISABLE_PAGE_BREAK DisablePageBreak;
|
||||
EFI_SHELL_GET_PAGE_BREAK GetPageBreak;
|
||||
EFI_SHELL_GET_DEVICE_NAME GetDeviceName;
|
||||
EFI_SHELL_GET_FILE_INFO GetFileInfo;
|
||||
EFI_SHELL_SET_FILE_INFO SetFileInfo;
|
||||
EFI_SHELL_OPEN_FILE_BY_NAME OpenFileByName;
|
||||
EFI_SHELL_CLOSE_FILE CloseFile;
|
||||
EFI_SHELL_CREATE_FILE CreateFile;
|
||||
EFI_SHELL_READ_FILE ReadFile;
|
||||
EFI_SHELL_WRITE_FILE WriteFile;
|
||||
EFI_SHELL_DELETE_FILE DeleteFile;
|
||||
EFI_SHELL_DELETE_FILE_BY_NAME DeleteFileByName;
|
||||
EFI_SHELL_GET_FILE_POSITION GetFilePosition;
|
||||
EFI_SHELL_SET_FILE_POSITION SetFilePosition;
|
||||
EFI_SHELL_FLUSH_FILE FlushFile;
|
||||
EFI_SHELL_FIND_FILES FindFiles;
|
||||
EFI_SHELL_FIND_FILES_IN_DIR FindFilesInDir;
|
||||
EFI_SHELL_GET_FILE_SIZE GetFileSize;
|
||||
EFI_SHELL_OPEN_ROOT OpenRoot;
|
||||
EFI_SHELL_OPEN_ROOT_BY_HANDLE OpenRootByHandle;
|
||||
EFI_EVENT ExecutionBreak;
|
||||
UINT32 MajorVersion;
|
||||
UINT32 MinorVersion;
|
||||
// Added for Shell 2.1
|
||||
EFI_SHELL_REGISTER_GUID_NAME RegisterGuidName;
|
||||
EFI_SHELL_GET_GUID_NAME GetGuidName;
|
||||
EFI_SHELL_GET_GUID_FROM_NAME GetGuidFromName;
|
||||
EFI_SHELL_GET_ENV_EX GetEnvEx;
|
||||
} EFI_SHELL_PROTOCOL;
|
||||
|
||||
#define EFI_SHELL_PARAMETERS_PROTOCOL_GUID \
|
||||
{ 0x752f3136, 0x4e16, 0x4fdc, { 0xa2, 0x2a, 0xe5, 0xf4, 0x68, 0x12, 0xf4, 0xca } }
|
||||
|
||||
INTERFACE_DECL(_EFI_SHELL_PARAMETERS_PROTOCOL);
|
||||
|
||||
typedef struct _EFI_SHELL_PARAMETERS_PROTOCOL {
|
||||
CHAR16 **Argv;
|
||||
UINTN Argc;
|
||||
SHELL_FILE_HANDLE StdIn;
|
||||
SHELL_FILE_HANDLE StdOut;
|
||||
SHELL_FILE_HANDLE StdErr;
|
||||
} EFI_SHELL_PARAMETERS_PROTOCOL;
|
||||
|
||||
#define EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL_GUID \
|
||||
{ 0x3c7200e9, 0x005f, 0x4ea4, { 0x87, 0xde, 0xa3, 0xdf, 0xac, 0x8a, 0x27, 0xc3 } }
|
||||
|
||||
INTERFACE_DECL(_EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL);
|
||||
|
||||
typedef
|
||||
SHELL_STATUS
|
||||
(EFIAPI *SHELL_COMMAND_HANDLER)(
|
||||
IN struct _EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable,
|
||||
IN EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,
|
||||
IN EFI_SHELL_PROTOCOL *Shell
|
||||
);
|
||||
|
||||
typedef
|
||||
CHAR16*
|
||||
(EFIAPI *SHELL_COMMAND_GETHELP)(
|
||||
IN struct _EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,
|
||||
IN CONST CHAR8 *Language
|
||||
);
|
||||
|
||||
typedef struct _EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL {
|
||||
CONST CHAR16 *CommandName;
|
||||
SHELL_COMMAND_HANDLER Handler;
|
||||
SHELL_COMMAND_GETHELP GetHelp;
|
||||
} EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL;
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,94 @@
|
||||
/** @file
|
||||
SHELL_INTERFACE_PROTOCOL from EDK shell (no spec).
|
||||
|
||||
Shell Interface - additional information (over image_info) provided
|
||||
to an application started by the shell.
|
||||
|
||||
ConIo provides a file-style interface to the console.
|
||||
|
||||
The shell interface's and data (including ConIo) are only valid during
|
||||
the applications Entry Point. Once the application returns from it's
|
||||
entry point the data is freed by the invoking shell.
|
||||
|
||||
Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
/*
|
||||
* This is based on ShellPkg/Include/Protocol/EfiShellInterface.h from EDK II.
|
||||
*/
|
||||
|
||||
#ifndef _SHELLINTERFACE_H_
|
||||
#define _SHELLINTERFACE_H_
|
||||
|
||||
|
||||
#define SHELL_INTERFACE_PROTOCOL_GUID \
|
||||
{ \
|
||||
0x47c7b223, 0xc42a, 0x11d2, {0x8e, 0x57, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} \
|
||||
}
|
||||
|
||||
///
|
||||
/// Bit definitions for EFI_SHELL_ARG_INFO
|
||||
///
|
||||
typedef enum {
|
||||
ARG_NO_ATTRIB = 0x0,
|
||||
ARG_IS_QUOTED = 1<<0,
|
||||
ARG_PARTIALLY_QUOTED = 1<<1,
|
||||
ARG_FIRST_HALF_QUOTED = 1<<2,
|
||||
ARG_FIRST_CHAR_IS_ESC = 1<<3
|
||||
} EFI_SHELL_ARG_INFO_TYPES;
|
||||
|
||||
///
|
||||
/// Attributes for an argument.
|
||||
///
|
||||
typedef struct _EFI_SHELL_ARG_INFO {
|
||||
UINT32 Attributes;
|
||||
} EFI_SHELL_ARG_INFO;
|
||||
|
||||
///
|
||||
/// This protocol provides access to additional information about a shell application.
|
||||
///
|
||||
typedef struct {
|
||||
///
|
||||
/// Handle back to original image handle & image information.
|
||||
///
|
||||
EFI_HANDLE ImageHandle;
|
||||
EFI_LOADED_IMAGE *Info;
|
||||
|
||||
///
|
||||
/// Parsed arg list converted more C-like format.
|
||||
///
|
||||
CHAR16 **Argv;
|
||||
UINTN Argc;
|
||||
|
||||
///
|
||||
/// Storage for file redirection args after parsing.
|
||||
///
|
||||
CHAR16 **RedirArgv;
|
||||
UINTN RedirArgc;
|
||||
|
||||
///
|
||||
/// A file style handle for console io.
|
||||
///
|
||||
EFI_FILE *StdIn;
|
||||
EFI_FILE *StdOut;
|
||||
EFI_FILE *StdErr;
|
||||
|
||||
///
|
||||
/// List of attributes for each argument.
|
||||
///
|
||||
EFI_SHELL_ARG_INFO *ArgInfo;
|
||||
|
||||
///
|
||||
/// Whether we are echoing.
|
||||
///
|
||||
BOOLEAN EchoOn;
|
||||
} EFI_SHELL_INTERFACE;
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,68 @@
|
||||
#ifndef _EFISTDARG_H_
|
||||
#define _EFISTDARG_H_
|
||||
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
devpath.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Defines for parsing the EFI Device Path structures
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
/* Use somebody else's definitions */
|
||||
#if defined(GNU_EFI_USE_EXTERNAL_STDARG)
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
|
||||
/* MSVC */
|
||||
#if defined(_MSC_VER)
|
||||
#include <stdarg.h>
|
||||
typedef va_list ms_va_list;
|
||||
#define ms_va_start(v,l) va_start(v,l)
|
||||
#define ms_va_end(v) va_end(v)
|
||||
#define ms_va_arg(v,l) va_arg(v,l)
|
||||
#define ms_va_copy(d,s) va_copy(d,s)
|
||||
#endif
|
||||
|
||||
/* GCC x86_64 */
|
||||
#if !defined(_MSC_VER) && defined(__x86_64__)
|
||||
typedef __builtin_va_list va_list;
|
||||
#define va_start(v,l) __builtin_va_start(v,l)
|
||||
#define va_end(v) __builtin_va_end(v)
|
||||
#define va_arg(v,l) __builtin_va_arg(v,l)
|
||||
#define va_copy(d,s) __builtin_va_copy(d,s)
|
||||
typedef __builtin_ms_va_list ms_va_list;
|
||||
#define ms_va_start(v,l) __builtin_ms_va_start(v,l)
|
||||
#define ms_va_end(v) __builtin_ms_va_end(v)
|
||||
#define ms_va_arg(v,l) __builtin_va_arg(v,l) /* There is no __builtin_ms_va_arg */
|
||||
#define ms_va_copy(d,s) __builtin_ms_va_copy(d,s)
|
||||
#endif
|
||||
|
||||
/* GCC non-x86_64 */
|
||||
#if !defined(_MSC_VER) && !defined(__x86_64__)
|
||||
typedef __builtin_va_list va_list;
|
||||
#define va_start(v,l) __builtin_va_start(v,l)
|
||||
#define va_end(v) __builtin_va_end(v)
|
||||
#define va_arg(v,l) __builtin_va_arg(v,l)
|
||||
#define va_copy(d,s) __builtin_va_copy(d,s)
|
||||
typedef __builtin_va_list ms_va_list;
|
||||
#define ms_va_start(v,l) __builtin_va_start(v,l)
|
||||
#define ms_va_end(v) __builtin_va_end(v)
|
||||
#define ms_va_arg(v,l) __builtin_va_arg(v,l)
|
||||
#define ms_va_copy(d,s) __builtin_va_copy(d,s)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,391 @@
|
||||
#ifndef _EFI_TCP_H
|
||||
#define _EFI_TCP_H
|
||||
|
||||
/*++
|
||||
Copyright (c) 2013 Intel Corporation
|
||||
|
||||
--*/
|
||||
|
||||
#define EFI_TCP4_SERVICE_BINDING_PROTOCOL \
|
||||
{ 0x00720665, 0x67eb, 0x4a99, {0xba, 0xf7, 0xd3, 0xc3, 0x3a, 0x1c,0x7c, 0xc9}}
|
||||
|
||||
#define EFI_TCP4_PROTOCOL \
|
||||
{ 0x65530bc7, 0xa359, 0x410f, {0xb0, 0x10, 0x5a, 0xad, 0xc7, 0xec, 0x2b, 0x62}}
|
||||
|
||||
#define EFI_TCP6_SERVICE_BINDING_PROTOCOL \
|
||||
{ 0xec20eb79, 0x6c1a, 0x4664, {0x9a, 0xd, 0xd2, 0xe4, 0xcc, 0x16, 0xd6, 0x64}}
|
||||
|
||||
#define EFI_TCP6_PROTOCOL \
|
||||
{ 0x46e44855, 0xbd60, 0x4ab7, {0xab, 0xd, 0xa6, 0x79, 0xb9, 0x44, 0x7d, 0x77}}
|
||||
|
||||
INTERFACE_DECL(_EFI_TCP4);
|
||||
INTERFACE_DECL(_EFI_TCP6);
|
||||
|
||||
typedef struct {
|
||||
BOOLEAN UseDefaultAddress;
|
||||
EFI_IPv4_ADDRESS StationAddress;
|
||||
EFI_IPv4_ADDRESS SubnetMask;
|
||||
UINT16 StationPort;
|
||||
EFI_IPv4_ADDRESS RemoteAddress;
|
||||
UINT16 RemotePort;
|
||||
BOOLEAN ActiveFlag;
|
||||
} EFI_TCP4_ACCESS_POINT;
|
||||
|
||||
typedef struct {
|
||||
UINT32 ReceiveBufferSize;
|
||||
UINT32 SendBufferSize;
|
||||
UINT32 MaxSynBackLog;
|
||||
UINT32 ConnectionTimeout;
|
||||
UINT32 DataRetries;
|
||||
UINT32 FinTimeout;
|
||||
UINT32 TimeWaitTimeout;
|
||||
UINT32 KeepAliveProbes;
|
||||
UINT32 KeepAliveTime;
|
||||
UINT32 KeepAliveInterval;
|
||||
BOOLEAN EnableNagle;
|
||||
BOOLEAN EnableTimeStamp;
|
||||
BOOLEAN EnableWindowScaling;
|
||||
BOOLEAN EnableSelectiveAck;
|
||||
BOOLEAN EnablePAthMtuDiscovery;
|
||||
} EFI_TCP4_OPTION;
|
||||
|
||||
typedef struct {
|
||||
// Receiving Filters
|
||||
// I/O parameters
|
||||
UINT8 TypeOfService;
|
||||
UINT8 TimeToLive;
|
||||
|
||||
// Access Point
|
||||
EFI_TCP4_ACCESS_POINT AccessPoint;
|
||||
|
||||
// TCP Control Options
|
||||
EFI_TCP4_OPTION *ControlOption;
|
||||
} EFI_TCP4_CONFIG_DATA;
|
||||
|
||||
typedef enum {
|
||||
Tcp4StateClosed = 0,
|
||||
Tcp4StateListen = 1,
|
||||
Tcp4StateSynSent = 2,
|
||||
Tcp4StateSynReceived = 3,
|
||||
Tcp4StateEstablished = 4,
|
||||
Tcp4StateFinWait1 = 5,
|
||||
Tcp4StateFinWait2 = 6,
|
||||
Tcp4StateClosing = 7,
|
||||
Tcp4StateTimeWait = 8,
|
||||
Tcp4StateCloseWait = 9,
|
||||
Tcp4StateLastAck = 10
|
||||
} EFI_TCP4_CONNECTION_STATE;
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_TCP4_GET_MODE_DATA) (
|
||||
IN struct _EFI_TCP4 *This,
|
||||
OUT EFI_TCP4_CONNECTION_STATE *Tcp4State OPTIONAL,
|
||||
OUT EFI_TCP4_CONFIG_DATA *Tcp4ConfigData OPTIONAL,
|
||||
OUT EFI_IP4_MODE_DATA *Ip4ModeData OPTIONAL,
|
||||
OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,
|
||||
OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_TCP4_CONFIGURE) (
|
||||
IN struct _EFI_TCP4 *This,
|
||||
IN EFI_TCP4_CONFIG_DATA *TcpConfigData OPTIONAL
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_TCP4_ROUTES) (
|
||||
IN struct _EFI_TCP4 *This,
|
||||
IN BOOLEAN DeleteRoute,
|
||||
IN EFI_IPv4_ADDRESS *SubnetAddress,
|
||||
IN EFI_IPv4_ADDRESS *SubnetMask,
|
||||
IN EFI_IPv4_ADDRESS *GatewayAddress
|
||||
);
|
||||
|
||||
typedef struct {
|
||||
EFI_EVENT Event;
|
||||
EFI_STATUS Status;
|
||||
} EFI_TCP4_COMPLETION_TOKEN;
|
||||
|
||||
typedef struct {
|
||||
EFI_TCP4_COMPLETION_TOKEN CompletionToken;
|
||||
} EFI_TCP4_CONNECTION_TOKEN;
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_TCP4_CONNECT) (
|
||||
IN struct _EFI_TCP4 *This,
|
||||
IN EFI_TCP4_CONNECTION_TOKEN *ConnectionToken
|
||||
);
|
||||
|
||||
typedef struct {
|
||||
EFI_TCP4_COMPLETION_TOKEN CompletionToken;
|
||||
EFI_HANDLE NewChildHandle;
|
||||
} EFI_TCP4_LISTEN_TOKEN;
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_TCP4_ACCEPT) (
|
||||
IN struct _EFI_TCP4 *This,
|
||||
IN EFI_TCP4_LISTEN_TOKEN *ListenToken
|
||||
);
|
||||
|
||||
#define EFI_CONNECTION_FIN EFIERR(104)
|
||||
#define EFI_CONNECTION_RESET EFIERR(105)
|
||||
#define EFI_CONNECTION_REFUSED EFIERR(106)
|
||||
|
||||
typedef struct {
|
||||
UINT32 FragmentLength;
|
||||
VOID *FragmentBuffer;
|
||||
} EFI_TCP4_FRAGMENT_DATA;
|
||||
|
||||
typedef struct {
|
||||
BOOLEAN UrgentFlag;
|
||||
UINT32 DataLength;
|
||||
UINT32 FragmentCount;
|
||||
EFI_TCP4_FRAGMENT_DATA FragmentTable[1];
|
||||
} EFI_TCP4_RECEIVE_DATA;
|
||||
|
||||
typedef struct {
|
||||
BOOLEAN Push;
|
||||
BOOLEAN Urgent;
|
||||
UINT32 DataLength;
|
||||
UINT32 FragmentCount;
|
||||
EFI_TCP4_FRAGMENT_DATA FragmentTable[1];
|
||||
} EFI_TCP4_TRANSMIT_DATA;
|
||||
|
||||
typedef struct {
|
||||
EFI_TCP4_COMPLETION_TOKEN CompletionToken;
|
||||
union {
|
||||
EFI_TCP4_RECEIVE_DATA *RxData;
|
||||
EFI_TCP4_TRANSMIT_DATA *TxData;
|
||||
} Packet;
|
||||
} EFI_TCP4_IO_TOKEN;
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_TCP4_TRANSMIT) (
|
||||
IN struct _EFI_TCP4 *This,
|
||||
IN EFI_TCP4_IO_TOKEN *Token
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_TCP4_RECEIVE) (
|
||||
IN struct _EFI_TCP4 *This,
|
||||
IN EFI_TCP4_IO_TOKEN *Token
|
||||
);
|
||||
|
||||
typedef struct {
|
||||
EFI_TCP4_COMPLETION_TOKEN CompletionToken;
|
||||
BOOLEAN AbortOnClose;
|
||||
} EFI_TCP4_CLOSE_TOKEN;
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_TCP4_CLOSE)(
|
||||
IN struct _EFI_TCP4 *This,
|
||||
IN EFI_TCP4_CLOSE_TOKEN *CloseToken
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_TCP4_CANCEL)(
|
||||
IN struct _EFI_TCP4 *This,
|
||||
IN EFI_TCP4_COMPLETION_TOKEN *Token OPTIONAL
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_TCP4_POLL) (
|
||||
IN struct _EFI_TCP4 *This
|
||||
);
|
||||
|
||||
typedef struct _EFI_TCP4 {
|
||||
EFI_TCP4_GET_MODE_DATA GetModeData;
|
||||
EFI_TCP4_CONFIGURE Configure;
|
||||
EFI_TCP4_ROUTES Routes;
|
||||
EFI_TCP4_CONNECT Connect;
|
||||
EFI_TCP4_ACCEPT Accept;
|
||||
EFI_TCP4_TRANSMIT Transmit;
|
||||
EFI_TCP4_RECEIVE Receive;
|
||||
EFI_TCP4_CLOSE Close;
|
||||
EFI_TCP4_CANCEL Cancel;
|
||||
EFI_TCP4_POLL Poll;
|
||||
} EFI_TCP4;
|
||||
|
||||
typedef enum {
|
||||
Tcp6StateClosed = 0,
|
||||
Tcp6StateListen = 1,
|
||||
Tcp6StateSynSent = 2,
|
||||
Tcp6StateSynReceived = 3,
|
||||
Tcp6StateEstablished = 4,
|
||||
Tcp6StateFinWait1 = 5,
|
||||
Tcp6StateFinWait2 = 6,
|
||||
Tcp6StateClosing = 7,
|
||||
Tcp6StateTimeWait = 8,
|
||||
Tcp6StateCloseWait = 9,
|
||||
Tcp6StateLastAck = 10
|
||||
} EFI_TCP6_CONNECTION_STATE;
|
||||
|
||||
typedef struct {
|
||||
EFI_IPv6_ADDRESS StationAddress;
|
||||
UINT16 StationPort;
|
||||
EFI_IPv6_ADDRESS RemoteAddress;
|
||||
UINT16 RemotePort;
|
||||
BOOLEAN ActiveFlag;
|
||||
} EFI_TCP6_ACCESS_POINT;
|
||||
|
||||
typedef struct {
|
||||
UINT32 ReceiveBufferSize;
|
||||
UINT32 SendBufferSize;
|
||||
UINT32 MaxSynBackLog;
|
||||
UINT32 ConnectionTimeout;
|
||||
UINT32 DataRetries;
|
||||
UINT32 FinTimeout;
|
||||
UINT32 TimeWaitTimeout;
|
||||
UINT32 KeepAliveProbes;
|
||||
UINT32 KeepAliveTime;
|
||||
UINT32 KeepAliveInterval;
|
||||
BOOLEAN EnableNagle;
|
||||
BOOLEAN EnableTimeStamp;
|
||||
BOOLEAN EnableWindbowScaling;
|
||||
BOOLEAN EnableSelectiveAck;
|
||||
BOOLEAN EnablePathMtuDiscovery;
|
||||
} EFI_TCP6_OPTION;
|
||||
|
||||
typedef struct {
|
||||
UINT8 TrafficClass;
|
||||
UINT8 HopLimit;
|
||||
EFI_TCP6_ACCESS_POINT AccessPoint;
|
||||
EFI_TCP6_OPTION *ControlOption;
|
||||
} EFI_TCP6_CONFIG_DATA;
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_TCP6_GET_MODE_DATA) (
|
||||
IN struct _EFI_TCP6 *This,
|
||||
OUT EFI_TCP6_CONNECTION_STATE *Tcp6State OPTIONAL,
|
||||
OUT EFI_TCP6_CONFIG_DATA *Tcp6ConfigData OPTIONAL,
|
||||
OUT EFI_IP6_MODE_DATA *Ip6ModeData OPTIONAL,
|
||||
OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,
|
||||
OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_TCP6_CONFIGURE) (
|
||||
IN struct _EFI_TCP6 *This,
|
||||
IN EFI_TCP6_CONFIG_DATA *Tcp6ConfigData OPTIONAL
|
||||
);
|
||||
|
||||
typedef struct {
|
||||
EFI_EVENT Event;
|
||||
EFI_STATUS Status;
|
||||
} EFI_TCP6_COMPLETION_TOKEN;
|
||||
|
||||
typedef struct {
|
||||
EFI_TCP6_COMPLETION_TOKEN CompletionToken;
|
||||
} EFI_TCP6_CONNECTION_TOKEN;
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_TCP6_CONNECT) (
|
||||
IN struct _EFI_TCP6 *This,
|
||||
IN EFI_TCP6_CONNECTION_TOKEN *ConnectionToken
|
||||
);
|
||||
|
||||
typedef struct {
|
||||
EFI_TCP6_COMPLETION_TOKEN CompletionToken;
|
||||
EFI_HANDLE NewChildHandle;
|
||||
} EFI_TCP6_LISTEN_TOKEN;
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_TCP6_ACCEPT) (
|
||||
IN struct _EFI_TCP6 *This,
|
||||
IN EFI_TCP6_LISTEN_TOKEN *ListenToken
|
||||
);
|
||||
|
||||
typedef struct {
|
||||
UINT32 FragmentLength;
|
||||
VOID *FragmentBuffer;
|
||||
} EFI_TCP6_FRAGMENT_DATA;
|
||||
|
||||
typedef struct {
|
||||
BOOLEAN UrgentFlag;
|
||||
UINT32 DataLength;
|
||||
UINT32 FragmentCount;
|
||||
EFI_TCP6_FRAGMENT_DATA FragmentTable[1];
|
||||
} EFI_TCP6_RECEIVE_DATA;
|
||||
|
||||
typedef struct {
|
||||
BOOLEAN Push;
|
||||
BOOLEAN Urgent;
|
||||
UINT32 DataLength;
|
||||
UINT32 FragmentCount;
|
||||
EFI_TCP6_FRAGMENT_DATA FragmentTable[1];
|
||||
} EFI_TCP6_TRANSMIT_DATA;
|
||||
|
||||
typedef struct {
|
||||
EFI_TCP6_COMPLETION_TOKEN CompletionToken;
|
||||
union {
|
||||
EFI_TCP6_RECEIVE_DATA *RxData;
|
||||
EFI_TCP6_TRANSMIT_DATA *TxData;
|
||||
} Packet;
|
||||
} EFI_TCP6_IO_TOKEN;
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_TCP6_TRANSMIT) (
|
||||
IN struct _EFI_TCP6 *This,
|
||||
IN EFI_TCP6_IO_TOKEN *Token
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_TCP6_RECEIVE) (
|
||||
IN struct _EFI_TCP6 *This,
|
||||
IN EFI_TCP6_IO_TOKEN *Token
|
||||
);
|
||||
|
||||
typedef struct {
|
||||
EFI_TCP6_COMPLETION_TOKEN CompletionToken;
|
||||
BOOLEAN AbortOnClose;
|
||||
} EFI_TCP6_CLOSE_TOKEN;
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_TCP6_CLOSE)(
|
||||
IN struct _EFI_TCP6 *This,
|
||||
IN EFI_TCP6_CLOSE_TOKEN *CloseToken
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_TCP6_CANCEL)(
|
||||
IN struct _EFI_TCP6 *This,
|
||||
IN EFI_TCP6_COMPLETION_TOKEN *Token OPTIONAL
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_TCP6_POLL) (
|
||||
IN struct _EFI_TCP6 *This
|
||||
);
|
||||
|
||||
typedef struct _EFI_TCP6 {
|
||||
EFI_TCP6_GET_MODE_DATA GetModeData;
|
||||
EFI_TCP6_CONFIGURE Configure;
|
||||
EFI_TCP6_CONNECT Connect;
|
||||
EFI_TCP6_ACCEPT Accept;
|
||||
EFI_TCP6_TRANSMIT Transmit;
|
||||
EFI_TCP6_RECEIVE Receive;
|
||||
EFI_TCP6_CLOSE Close;
|
||||
EFI_TCP6_CANCEL Cancel;
|
||||
EFI_TCP6_POLL Poll;
|
||||
} EFI_TCP6;
|
||||
|
||||
#endif /* _EFI_TCP_H */
|
||||
@@ -0,0 +1,272 @@
|
||||
#ifndef _EFI_UDP_H
|
||||
#define _EFI_UDP_H
|
||||
|
||||
|
||||
/*++
|
||||
Copyright (c) 2013 Intel Corporation
|
||||
|
||||
--*/
|
||||
|
||||
#define EFI_UDP4_SERVICE_BINDING_PROTOCOL \
|
||||
{ 0x83f01464, 0x99bd, 0x45e5, {0xb3, 0x83, 0xaf, 0x63, 0x05, 0xd8, 0xe9, 0xe6} }
|
||||
|
||||
#define EFI_UDP4_PROTOCOL \
|
||||
{ 0x3ad9df29, 0x4501, 0x478d, {0xb1, 0xf8, 0x7f, 0x7f, 0xe7, 0x0e, 0x50, 0xf3} }
|
||||
|
||||
#define EFI_UDP6_SERVICE_BINDING_PROTOCOL \
|
||||
{ 0x66ed4721, 0x3c98, 0x4d3e, {0x81, 0xe3, 0xd0, 0x3d, 0xd3, 0x9a, 0x72, 0x54} }
|
||||
|
||||
#define EFI_UDP6_PROTOCOL \
|
||||
{ 0x4f948815, 0xb4b9, 0x43cb, {0x8a, 0x33, 0x90, 0xe0, 0x60, 0xb3,0x49, 0x55} }
|
||||
|
||||
INTERFACE_DECL(_EFI_UDP4);
|
||||
INTERFACE_DECL(_EFI_UDP6);
|
||||
|
||||
typedef struct {
|
||||
BOOLEAN AcceptBroadcast;
|
||||
BOOLEAN AcceptPromiscuous;
|
||||
BOOLEAN AcceptAnyPort;
|
||||
BOOLEAN AllowDuplicatePort;
|
||||
UINT8 TypeOfService;
|
||||
UINT8 TimeToLive;
|
||||
BOOLEAN DoNotFragment;
|
||||
UINT32 ReceiveTimeout;
|
||||
UINT32 TransmitTimeout;
|
||||
BOOLEAN UseDefaultAddress;
|
||||
EFI_IPv4_ADDRESS StationAddress;
|
||||
EFI_IPv4_ADDRESS SubnetMask;
|
||||
UINT16 StationPort;
|
||||
EFI_IPv4_ADDRESS RemoteAddress;
|
||||
UINT16 RemotePort;
|
||||
} EFI_UDP4_CONFIG_DATA;
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_UDP4_GET_MODE_DATA) (
|
||||
IN struct _EFI_UDP4 *This,
|
||||
OUT EFI_UDP4_CONFIG_DATA *Udp4ConfigData OPTIONAL,
|
||||
OUT EFI_IP4_MODE_DATA *Ip4ModeData OPTIONAL,
|
||||
OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,
|
||||
OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_UDP4_CONFIGURE) (
|
||||
IN struct _EFI_UDP4 *This,
|
||||
IN EFI_UDP4_CONFIG_DATA *UdpConfigData OPTIONAL
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_UDP4_GROUPS) (
|
||||
IN struct _EFI_UDP4 *This,
|
||||
IN BOOLEAN JoinFlag,
|
||||
IN EFI_IPv4_ADDRESS *MulticastAddress OPTIONAL
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_UDP4_ROUTES) (
|
||||
IN struct _EFI_UDP4 *This,
|
||||
IN BOOLEAN DeleteRoute,
|
||||
IN EFI_IPv4_ADDRESS *SubnetAddress,
|
||||
IN EFI_IPv4_ADDRESS *SubnetMask,
|
||||
IN EFI_IPv4_ADDRESS *GatewayAddress
|
||||
);
|
||||
|
||||
#define EFI_NETWORK_UNREACHABLE EFIERR(100)
|
||||
#define EFI_HOST_UNREACHABLE EFIERR(101)
|
||||
#define EFI_PROTOCOL_UNREACHABLE EFIERR(102)
|
||||
#define EFI_PORT_UNREACHABLE EFIERR(103)
|
||||
|
||||
typedef struct {
|
||||
EFI_IPv4_ADDRESS SourceAddress;
|
||||
UINT16 SourcePort;
|
||||
EFI_IPv4_ADDRESS DestinationAddress;
|
||||
UINT16 DestinationPort;
|
||||
} EFI_UDP4_SESSION_DATA;
|
||||
|
||||
typedef struct {
|
||||
UINT32 FragmentLength;
|
||||
VOID *FragmentBuffer;
|
||||
} EFI_UDP4_FRAGMENT_DATA;
|
||||
|
||||
typedef struct {
|
||||
EFI_TIME TimeStamp;
|
||||
EFI_EVENT RecycleSignal;
|
||||
EFI_UDP4_SESSION_DATA UdpSession;
|
||||
UINT32 DataLength;
|
||||
UINT32 FragmentCount;
|
||||
EFI_UDP4_FRAGMENT_DATA FragmentTable[1];
|
||||
} EFI_UDP4_RECEIVE_DATA;
|
||||
|
||||
typedef struct {
|
||||
EFI_UDP4_SESSION_DATA *UdpSessionData;
|
||||
EFI_IPv4_ADDRESS *GatewayAddress;
|
||||
UINT32 DataLength;
|
||||
UINT32 FragmentCount;
|
||||
EFI_UDP4_FRAGMENT_DATA FragmentTable[1];
|
||||
} EFI_UDP4_TRANSMIT_DATA;
|
||||
|
||||
typedef struct {
|
||||
EFI_EVENT Event;
|
||||
EFI_STATUS Status;
|
||||
union {
|
||||
EFI_UDP4_RECEIVE_DATA *RxData;
|
||||
EFI_UDP4_TRANSMIT_DATA *TxData;
|
||||
} Packet;
|
||||
} EFI_UDP4_COMPLETION_TOKEN;
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_UDP4_TRANSMIT) (
|
||||
IN struct _EFI_UDP4 *This,
|
||||
IN EFI_UDP4_COMPLETION_TOKEN *Token
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_UDP4_RECEIVE) (
|
||||
IN struct _EFI_UDP4 *This,
|
||||
IN EFI_UDP4_COMPLETION_TOKEN *Token
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_UDP4_CANCEL)(
|
||||
IN struct _EFI_UDP4 *This,
|
||||
IN EFI_UDP4_COMPLETION_TOKEN *Token OPTIONAL
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_UDP4_POLL) (
|
||||
IN struct _EFI_UDP4 *This
|
||||
);
|
||||
|
||||
typedef struct _EFI_UDP4 {
|
||||
EFI_UDP4_GET_MODE_DATA GetModeData;
|
||||
EFI_UDP4_CONFIGURE Configure;
|
||||
EFI_UDP4_GROUPS Groups;
|
||||
EFI_UDP4_ROUTES Routes;
|
||||
EFI_UDP4_TRANSMIT Transmit;
|
||||
EFI_UDP4_RECEIVE Receive;
|
||||
EFI_UDP4_CANCEL Cancel;
|
||||
EFI_UDP4_POLL Poll;
|
||||
} EFI_UDP4;
|
||||
|
||||
typedef struct {
|
||||
BOOLEAN AcceptPromiscuous;
|
||||
BOOLEAN AcceptAnyPort;
|
||||
BOOLEAN AllowDuplicatePort;
|
||||
UINT8 TrafficClass;
|
||||
UINT8 HopLimit;
|
||||
UINT32 ReceiveTimeout;
|
||||
UINT32 TransmitTimeout;
|
||||
EFI_IPv6_ADDRESS StationAddress;
|
||||
UINT16 StationPort;
|
||||
EFI_IPv6_ADDRESS RemoteAddress;
|
||||
UINT16 RemotePort;
|
||||
} EFI_UDP6_CONFIG_DATA;
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_UDP6_GET_MODE_DATA) (
|
||||
IN struct _EFI_UDP6 *This,
|
||||
OUT EFI_UDP6_CONFIG_DATA *Udp6ConfigData OPTIONAL,
|
||||
OUT EFI_IP6_MODE_DATA *Ip6ModeData OPTIONAL,
|
||||
OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,
|
||||
OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_UDP6_CONFIGURE) (
|
||||
IN struct _EFI_UDP6 *This,
|
||||
IN EFI_UDP6_CONFIG_DATA *UdpConfigData OPTIONAL
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_UDP6_GROUPS) (
|
||||
IN struct _EFI_UDP6 *This,
|
||||
IN BOOLEAN JoinFlag,
|
||||
IN EFI_IPv6_ADDRESS *MulticastAddress OPTIONAL
|
||||
);
|
||||
|
||||
typedef struct {
|
||||
EFI_IPv6_ADDRESS SourceAddress;
|
||||
UINT16 SourcePort;
|
||||
EFI_IPv6_ADDRESS DestinationAddress;
|
||||
UINT16 DestinationPort;
|
||||
} EFI_UDP6_SESSION_DATA;
|
||||
|
||||
typedef struct {
|
||||
UINT32 FragmentLength;
|
||||
VOID *FragmentBuffer;
|
||||
} EFI_UDP6_FRAGMENT_DATA;
|
||||
|
||||
typedef struct {
|
||||
EFI_TIME TimeStamp;
|
||||
EFI_EVENT RecycleSignal;
|
||||
EFI_UDP6_SESSION_DATA UdpSession;
|
||||
UINT32 DataLength;
|
||||
UINT32 FragmentCount;
|
||||
EFI_UDP6_FRAGMENT_DATA FragmentTable[1];
|
||||
} EFI_UDP6_RECEIVE_DATA;
|
||||
|
||||
typedef struct {
|
||||
EFI_UDP6_SESSION_DATA *UdpSessionData;
|
||||
UINT32 DataLength;
|
||||
UINT32 FragmentCount;
|
||||
EFI_UDP6_FRAGMENT_DATA FragmentTable[1];
|
||||
} EFI_UDP6_TRANSMIT_DATA;
|
||||
|
||||
typedef struct {
|
||||
EFI_EVENT Event;
|
||||
EFI_STATUS Status;
|
||||
union {
|
||||
EFI_UDP6_RECEIVE_DATA *RxData;
|
||||
EFI_UDP6_TRANSMIT_DATA *TxData;
|
||||
} Packet;
|
||||
} EFI_UDP6_COMPLETION_TOKEN;
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_UDP6_TRANSMIT) (
|
||||
IN struct _EFI_UDP6 *This,
|
||||
IN EFI_UDP6_COMPLETION_TOKEN *Token
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_UDP6_RECEIVE) (
|
||||
IN struct _EFI_UDP6 *This,
|
||||
IN EFI_UDP6_COMPLETION_TOKEN *Token
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_UDP6_CANCEL)(
|
||||
IN struct _EFI_UDP6 *This,
|
||||
IN EFI_UDP6_COMPLETION_TOKEN *Token OPTIONAL
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_UDP6_POLL) (
|
||||
IN struct _EFI_UDP6 *This
|
||||
);
|
||||
|
||||
typedef struct _EFI_UDP6 {
|
||||
EFI_UDP6_GET_MODE_DATA GetModeData;
|
||||
EFI_UDP6_CONFIGURE Configure;
|
||||
EFI_UDP6_GROUPS Groups;
|
||||
EFI_UDP6_TRANSMIT Transmit;
|
||||
EFI_UDP6_RECEIVE Receive;
|
||||
EFI_UDP6_CANCEL Cancel;
|
||||
EFI_UDP6_POLL Poll;
|
||||
} EFI_UDP6;
|
||||
|
||||
#endif /* _EFI_UDP_H */
|
||||
@@ -0,0 +1,58 @@
|
||||
#ifndef _EFI_UI_H
|
||||
#define _EFI_UI_H
|
||||
|
||||
/*++
|
||||
|
||||
Copyright (c) 200 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
EfiUi.h
|
||||
|
||||
Abstract:
|
||||
Protocol used to build User Interface (UI) stuff.
|
||||
|
||||
This protocol is just data. It is a multi dimentional array.
|
||||
For each string there is an array of UI_STRING_ENTRY. Each string
|
||||
is for a different language translation of the same string. The list
|
||||
is terminated by a NULL UiString. There can be any number of
|
||||
UI_STRING_ENTRY arrays. A NULL array terminates the list. A NULL array
|
||||
entry contains all zeros.
|
||||
|
||||
Thus the shortest possible EFI_UI_PROTOCOL has three UI_STRING_ENTRY.
|
||||
The String, it's NULL terminator, and the NULL terminator for the entire
|
||||
thing.
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
#define EFI_UI_INTERFACE_PROTOCOL_GUID \
|
||||
{ 0x32dd7981, 0x2d27, 0x11d4, {0xbc, 0x8b, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81} }
|
||||
#define EFI_UI_PROTOCOL EFI_UI_INTERFACE_PROTOCOL_GUID
|
||||
|
||||
|
||||
typedef enum {
|
||||
UiDeviceString,
|
||||
UiVendorString,
|
||||
UiMaxString
|
||||
} UI_STRING_TYPE;
|
||||
|
||||
typedef struct {
|
||||
ISO_639_2 *LangCode;
|
||||
CHAR16 *UiString;
|
||||
} UI_STRING_ENTRY;
|
||||
|
||||
#define EFI_UI_INTERFACE_PROTOCOL_VERSION 0x00010000
|
||||
#define EFI_UI_VERSION EFI_UI_INTERFACE_PROTOCOL_VERSION
|
||||
|
||||
typedef struct _EFI_UI_INTERFACE_PROTOCOL {
|
||||
UINT32 Version;
|
||||
UI_STRING_ENTRY *Entry;
|
||||
} EFI_UI_INTERFACE_PROTOCOL;
|
||||
|
||||
typedef struct _EFI_UI_INTERFACE_PROTOCOL _UI_INTERFACE;
|
||||
typedef EFI_UI_INTERFACE_PROTOCOL UI_INTERFACE;
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,105 @@
|
||||
#if !defined(__GNU_EFI_INTERNAL_PRINT)
|
||||
#define __GNU_EFI_INTERNAL_PRINT
|
||||
|
||||
//
|
||||
// Internal fucntions
|
||||
//
|
||||
|
||||
//
|
||||
// Declare runtime functions
|
||||
//
|
||||
|
||||
#ifdef RUNTIME_CODE
|
||||
#ifndef __GNUC__
|
||||
|
||||
// For debugging..
|
||||
|
||||
/*
|
||||
#pragma RUNTIME_CODE(PGETC)
|
||||
*/
|
||||
|
||||
#endif /* !defined(__GNUC__) */
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
BOOLEAN Ascii;
|
||||
UINTN Index;
|
||||
union {
|
||||
CONST CHAR16 *pw;
|
||||
CONST CHAR8 *pc;
|
||||
} un;
|
||||
} POINTER;
|
||||
|
||||
EFI_INTERNAL
|
||||
CHAR16
|
||||
PGETC (
|
||||
IN POINTER *p
|
||||
);
|
||||
|
||||
#define PRINT_STRING_LEN 200
|
||||
#define PRINT_ITEM_BUFFER_LEN 100
|
||||
|
||||
#define pw un.pw
|
||||
#define pc un.pc
|
||||
|
||||
typedef struct _pitem {
|
||||
|
||||
POINTER Item;
|
||||
CHAR16 Scratch[PRINT_ITEM_BUFFER_LEN];
|
||||
UINTN Width;
|
||||
UINTN FieldWidth;
|
||||
UINTN *WidthParse;
|
||||
CHAR16 Pad;
|
||||
BOOLEAN PadBefore;
|
||||
BOOLEAN Comma;
|
||||
BOOLEAN Long;
|
||||
} PRINT_ITEM;
|
||||
|
||||
EFI_INTERNAL
|
||||
CHAR16
|
||||
PGETC (
|
||||
IN POINTER *p
|
||||
)
|
||||
{
|
||||
CHAR16 c;
|
||||
|
||||
c = p->Ascii ? p->pc[p->Index] : p->pw[p->Index];
|
||||
p->Index += 1;
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
INTN EFIAPI
|
||||
_SPrint (
|
||||
IN VOID *Context,
|
||||
IN CHAR16 *Buffer
|
||||
);
|
||||
|
||||
INTN EFIAPI
|
||||
_PoolPrint (
|
||||
IN VOID *Context,
|
||||
IN CHAR16 *Buffer
|
||||
);
|
||||
|
||||
INTN EFIAPI
|
||||
_DbgOut (
|
||||
IN VOID *Context,
|
||||
IN CHAR16 *Buffer
|
||||
);
|
||||
|
||||
EFI_INTERNAL
|
||||
INTN
|
||||
IsLocalPrint(void *func)
|
||||
{
|
||||
if (func == _DbgOut || func == _SPrint || func == _PoolPrint)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
@@ -0,0 +1,547 @@
|
||||
|
||||
#if !defined(__GNU_EFI_INTERNAL_VA_PRINT)
|
||||
#define __GNU_EFI_INTERNAL_VA_PRINT
|
||||
|
||||
#include <efistdarg.h>
|
||||
#include "print.h"
|
||||
|
||||
#if defined(__GNU_EFI_INTERNAL_USE_MS_VA_ABI)
|
||||
typedef ms_va_list VA_LIST;
|
||||
#define VA_START(a,b) ms_va_start(a,b)
|
||||
#define VA_COPY(a,b) ms_va_copy(a,b)
|
||||
#define VA_END(a) ms_va_end(a)
|
||||
#define VA_ARG(a,b) ms_va_arg(a,b)
|
||||
#else
|
||||
typedef va_list VA_LIST;
|
||||
#define VA_START(a,b) va_start(a,b)
|
||||
#define VA_COPY(a,b) va_copy(a,b)
|
||||
#define VA_END(a) va_end(a)
|
||||
#define VA_ARG(a,b) va_arg(a,b)
|
||||
#endif
|
||||
|
||||
#if defined(__GNU_EFI_INTERNAL_USE_MS_VA_ABI)
|
||||
#define FUNCTION_NAME(a) MS_ ## a
|
||||
#define CALL_CONV EFIAPI
|
||||
#else
|
||||
#define FUNCTION_NAME(a) a
|
||||
#define CALL_CONV
|
||||
#endif
|
||||
|
||||
//
|
||||
// Declare runtime functions
|
||||
//
|
||||
|
||||
#ifdef RUNTIME_CODE
|
||||
#ifndef __GNUC__
|
||||
|
||||
// For debugging..
|
||||
|
||||
/*
|
||||
#pragma RUNTIME_CODE(FUNCTION_NAME(_Print))
|
||||
#pragma RUNTIME_CODE(FUNCTION_NAME(PFLUSH))
|
||||
#pragma RUNTIME_CODE(FUNCTION_NAME(PSETATTR))
|
||||
#pragma RUNTIME_CODE(FUNCTION_NAME(PPUTC))
|
||||
#pragma RUNTIME_CODE(FUNCTION_NAME(PITEM))
|
||||
*/
|
||||
|
||||
#endif /* !defined(__GNUC__) */
|
||||
#endif
|
||||
|
||||
typedef struct FUNCTION_NAME(_pstate) {
|
||||
// Input
|
||||
POINTER fmt;
|
||||
VA_LIST args;
|
||||
|
||||
// Output
|
||||
CHAR16 *Buffer;
|
||||
CHAR16 *End;
|
||||
CHAR16 *Pos;
|
||||
UINTN Len;
|
||||
|
||||
UINTN Attr;
|
||||
UINTN RestoreAttr;
|
||||
|
||||
UINTN AttrNorm;
|
||||
UINTN AttrHighlight;
|
||||
UINTN AttrError;
|
||||
|
||||
INTN (EFIAPI *Output)(VOID *context, CHAR16 *str);
|
||||
INTN (EFIAPI *SetAttr)(VOID *context, UINTN attr);
|
||||
VOID *Context;
|
||||
|
||||
// Current item being formatted
|
||||
struct _pitem *Item;
|
||||
} FUNCTION_NAME(PRINT_STATE);
|
||||
|
||||
EFI_INTERNAL
|
||||
UINTN
|
||||
CALL_CONV
|
||||
FUNCTION_NAME(_Print) (
|
||||
IN FUNCTION_NAME(PRINT_STATE) *ps
|
||||
);
|
||||
|
||||
UINTN
|
||||
CALL_CONV
|
||||
FUNCTION_NAME(_IPrint) (
|
||||
IN UINTN Column,
|
||||
IN UINTN Row,
|
||||
IN SIMPLE_TEXT_OUTPUT_INTERFACE *Out,
|
||||
IN CONST CHAR16 *fmt,
|
||||
IN CONST CHAR8 *fmta,
|
||||
IN VA_LIST args
|
||||
);
|
||||
|
||||
EFI_INTERNAL
|
||||
VOID
|
||||
CALL_CONV
|
||||
FUNCTION_NAME(PFLUSH) (
|
||||
IN OUT FUNCTION_NAME(PRINT_STATE) *ps
|
||||
);
|
||||
|
||||
EFI_INTERNAL
|
||||
VOID
|
||||
CALL_CONV
|
||||
FUNCTION_NAME(PPUTC) (
|
||||
IN OUT FUNCTION_NAME(PRINT_STATE) *ps,
|
||||
IN CHAR16 c
|
||||
);
|
||||
|
||||
|
||||
EFI_INTERNAL
|
||||
VOID
|
||||
CALL_CONV
|
||||
FUNCTION_NAME(PITEM) (
|
||||
IN OUT FUNCTION_NAME(PRINT_STATE) *ps
|
||||
);
|
||||
|
||||
EFI_INTERNAL
|
||||
VOID
|
||||
CALL_CONV
|
||||
FUNCTION_NAME(PSETATTR) (
|
||||
IN OUT FUNCTION_NAME(PRINT_STATE) *ps,
|
||||
IN UINTN Attr
|
||||
);
|
||||
|
||||
EFI_INTERNAL
|
||||
VOID
|
||||
CALL_CONV
|
||||
FUNCTION_NAME(PFLUSH) (
|
||||
IN OUT FUNCTION_NAME(PRINT_STATE) *ps
|
||||
)
|
||||
{
|
||||
*ps->Pos = 0;
|
||||
if (IsLocalPrint(ps->Output))
|
||||
ps->Output(ps->Context, ps->Buffer);
|
||||
else
|
||||
uefi_call_wrapper(ps->Output, 2, ps->Context, ps->Buffer);
|
||||
ps->Pos = ps->Buffer;
|
||||
}
|
||||
|
||||
EFI_INTERNAL
|
||||
VOID
|
||||
CALL_CONV
|
||||
FUNCTION_NAME(PSETATTR) (
|
||||
IN OUT FUNCTION_NAME(PRINT_STATE) *ps,
|
||||
IN UINTN Attr
|
||||
)
|
||||
{
|
||||
FUNCTION_NAME(PFLUSH) (ps);
|
||||
|
||||
ps->RestoreAttr = ps->Attr;
|
||||
if (ps->SetAttr) {
|
||||
uefi_call_wrapper(ps->SetAttr, 2, ps->Context, Attr);
|
||||
}
|
||||
|
||||
ps->Attr = Attr;
|
||||
}
|
||||
|
||||
EFI_INTERNAL
|
||||
VOID
|
||||
CALL_CONV
|
||||
FUNCTION_NAME(PPUTC) (
|
||||
IN OUT FUNCTION_NAME(PRINT_STATE) *ps,
|
||||
IN CHAR16 c
|
||||
)
|
||||
{
|
||||
// if this is a newline, add a carriage return
|
||||
CHAR16 last_char = (ps->Len > 0) ? *(ps->Pos - 1) : '\0';
|
||||
if (c == '\n' && last_char != '\r') {
|
||||
FUNCTION_NAME(PPUTC) (ps, '\r');
|
||||
}
|
||||
|
||||
*ps->Pos = c;
|
||||
ps->Pos += 1;
|
||||
ps->Len += 1;
|
||||
|
||||
// if at the end of the buffer, flush it
|
||||
if (ps->Pos >= ps->End) {
|
||||
FUNCTION_NAME(PFLUSH)(ps);
|
||||
}
|
||||
}
|
||||
|
||||
EFI_INTERNAL
|
||||
VOID
|
||||
CALL_CONV
|
||||
FUNCTION_NAME(PITEM) (
|
||||
IN OUT FUNCTION_NAME(PRINT_STATE) *ps
|
||||
)
|
||||
{
|
||||
UINTN Len, i;
|
||||
PRINT_ITEM *Item;
|
||||
CHAR16 c;
|
||||
|
||||
// Get the length of the item
|
||||
Item = ps->Item;
|
||||
Item->Item.Index = 0;
|
||||
while (Item->Item.Index < Item->FieldWidth) {
|
||||
c = PGETC(&Item->Item);
|
||||
if (!c) {
|
||||
Item->Item.Index -= 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
Len = Item->Item.Index;
|
||||
|
||||
// if there is no item field width, use the items width
|
||||
if (Item->FieldWidth == (UINTN) -1) {
|
||||
Item->FieldWidth = Len;
|
||||
}
|
||||
|
||||
// if item is larger then width, update width
|
||||
if (Len > Item->Width) {
|
||||
Item->Width = Len;
|
||||
}
|
||||
|
||||
|
||||
// if pad field before, add pad char
|
||||
if (Item->PadBefore) {
|
||||
for (i=Item->Width; i < Item->FieldWidth; i+=1) {
|
||||
FUNCTION_NAME(PPUTC) (ps, ' ');
|
||||
}
|
||||
}
|
||||
|
||||
// pad item
|
||||
for (i=Len; i < Item->Width; i++) {
|
||||
FUNCTION_NAME(PPUTC) (ps, Item->Pad);
|
||||
}
|
||||
|
||||
// add the item
|
||||
Item->Item.Index=0;
|
||||
while (Item->Item.Index < Len) {
|
||||
FUNCTION_NAME(PPUTC) (ps, PGETC(&Item->Item));
|
||||
}
|
||||
|
||||
// If pad at the end, add pad char
|
||||
if (!Item->PadBefore) {
|
||||
for (i=Item->Width; i < Item->FieldWidth; i+=1) {
|
||||
FUNCTION_NAME(PPUTC) (ps, ' ');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EFI_INTERNAL
|
||||
UINTN
|
||||
CALL_CONV
|
||||
FUNCTION_NAME(_Print) (
|
||||
IN FUNCTION_NAME(PRINT_STATE) *ps
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
%w.lF - w = width
|
||||
l = field width
|
||||
F = format of arg
|
||||
|
||||
Args F:
|
||||
0 - pad with zeros
|
||||
- - justify on left (default is on right)
|
||||
, - add comma's to field
|
||||
* - width provided on stack
|
||||
n - Set output attribute to normal (for this field only)
|
||||
h - Set output attribute to highlight (for this field only)
|
||||
e - Set output attribute to error (for this field only)
|
||||
l - Value is 64 bits
|
||||
|
||||
a - ascii string
|
||||
s - unicode string
|
||||
X - fixed 8 byte value in hex
|
||||
x - hex value
|
||||
d - value as signed decimal
|
||||
u - value as unsigned decimal
|
||||
f - value as floating point
|
||||
c - Unicode char
|
||||
t - EFI time structure
|
||||
g - Pointer to GUID
|
||||
r - EFI status code (result code)
|
||||
D - pointer to Device Path with normal ending.
|
||||
|
||||
N - Set output attribute to normal
|
||||
H - Set output attribute to highlight
|
||||
E - Set output attribute to error
|
||||
% - Print a %
|
||||
|
||||
Arguments:
|
||||
|
||||
SystemTable - The system table
|
||||
|
||||
Returns:
|
||||
|
||||
Number of charactors written
|
||||
|
||||
--*/
|
||||
{
|
||||
CHAR16 c;
|
||||
UINTN Attr;
|
||||
PRINT_ITEM Item;
|
||||
CHAR16 Buffer[PRINT_STRING_LEN];
|
||||
|
||||
ps->Len = 0;
|
||||
ps->Buffer = Buffer;
|
||||
ps->Pos = Buffer;
|
||||
ps->End = Buffer + PRINT_STRING_LEN - 1;
|
||||
ps->Item = &Item;
|
||||
|
||||
ps->fmt.Index = 0;
|
||||
while ((c = PGETC(&ps->fmt))) {
|
||||
|
||||
if (c != '%') {
|
||||
FUNCTION_NAME(PPUTC) ( ps, c );
|
||||
continue;
|
||||
}
|
||||
|
||||
// setup for new item
|
||||
Item.FieldWidth = (UINTN) -1;
|
||||
Item.Width = 0;
|
||||
Item.WidthParse = &Item.Width;
|
||||
Item.Pad = ' ';
|
||||
Item.PadBefore = TRUE;
|
||||
Item.Comma = FALSE;
|
||||
Item.Long = FALSE;
|
||||
Item.Item.Ascii = FALSE;
|
||||
Item.Item.pw = NULL;
|
||||
ps->RestoreAttr = 0;
|
||||
Attr = 0;
|
||||
|
||||
while ((c = PGETC(&ps->fmt))) {
|
||||
|
||||
switch (c) {
|
||||
|
||||
case '%':
|
||||
//
|
||||
// %% -> %
|
||||
//
|
||||
Item.Scratch[0] = '%';
|
||||
Item.Scratch[1] = 0;
|
||||
Item.Item.pw = Item.Scratch;
|
||||
break;
|
||||
|
||||
case ',':
|
||||
Item.Comma = TRUE;
|
||||
break;
|
||||
|
||||
case '-':
|
||||
Item.PadBefore = FALSE;
|
||||
break;
|
||||
|
||||
case '*':
|
||||
*Item.WidthParse = VA_ARG(ps->args, UINTN);
|
||||
break;
|
||||
|
||||
case '.':
|
||||
Item.WidthParse = &Item.FieldWidth;
|
||||
break;
|
||||
|
||||
case '0':
|
||||
Item.Pad = '0';
|
||||
break;
|
||||
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
*Item.WidthParse = 0;
|
||||
do {
|
||||
*Item.WidthParse = *Item.WidthParse * 10 + c - '0';
|
||||
c = PGETC(&ps->fmt);
|
||||
} while (c >= '0' && c <= '9') ;
|
||||
ps->fmt.Index -= 1;
|
||||
break;
|
||||
|
||||
case 'a':
|
||||
Item.Item.pc = VA_ARG(ps->args, CHAR8 *);
|
||||
Item.Item.Ascii = TRUE;
|
||||
if (!Item.Item.pc) {
|
||||
Item.Item.pc = (CHAR8 *)"(null)";
|
||||
}
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
Item.Scratch[0] = (CHAR16) VA_ARG(ps->args, UINTN);
|
||||
Item.Scratch[1] = 0;
|
||||
Item.Item.pw = Item.Scratch;
|
||||
break;
|
||||
|
||||
case 'D':
|
||||
{
|
||||
EFI_DEVICE_PATH *dp = VA_ARG(ps->args, EFI_DEVICE_PATH *);
|
||||
CHAR16 *dpstr = DevicePathToStr(dp);
|
||||
StrnCpy(Item.Scratch, dpstr, PRINT_ITEM_BUFFER_LEN);
|
||||
Item.Scratch[PRINT_ITEM_BUFFER_LEN-1] = u'\0';
|
||||
FreePool(dpstr);
|
||||
|
||||
Item.Item.pw = Item.Scratch;
|
||||
break;
|
||||
}
|
||||
|
||||
case 'd':
|
||||
ValueToString (
|
||||
Item.Scratch,
|
||||
Item.Comma,
|
||||
Item.Long ? VA_ARG(ps->args, INT64) : VA_ARG(ps->args, INT32)
|
||||
);
|
||||
Item.Item.pw = Item.Scratch;
|
||||
break;
|
||||
|
||||
case 'E':
|
||||
Attr = ps->AttrError;
|
||||
break;
|
||||
|
||||
case 'e':
|
||||
FUNCTION_NAME(PSETATTR)(ps, ps->AttrError);
|
||||
break;
|
||||
|
||||
case 'f':
|
||||
FloatToString (
|
||||
Item.Scratch,
|
||||
Item.Comma,
|
||||
VA_ARG(ps->args, double)
|
||||
);
|
||||
Item.Item.pw = Item.Scratch;
|
||||
break;
|
||||
|
||||
case 'g':
|
||||
GuidToString (Item.Scratch, VA_ARG(ps->args, EFI_GUID *));
|
||||
Item.Item.pw = Item.Scratch;
|
||||
break;
|
||||
|
||||
case 'H':
|
||||
Attr = ps->AttrHighlight;
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
FUNCTION_NAME(PSETATTR)(ps, ps->AttrHighlight);
|
||||
break;
|
||||
|
||||
case 'l':
|
||||
Item.Long = TRUE;
|
||||
break;
|
||||
|
||||
case 'N':
|
||||
Attr = ps->AttrNorm;
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
FUNCTION_NAME(PSETATTR)(ps, ps->AttrNorm);
|
||||
break;
|
||||
|
||||
case 'p':
|
||||
Item.Width = sizeof(void *) == (8 ? 16 : 8) + 2;
|
||||
Item.Pad = '0';
|
||||
Item.Scratch[0] = ' ';
|
||||
Item.Scratch[1] = ' ';
|
||||
ValueToHex (
|
||||
Item.Scratch+2,
|
||||
Item.Long ? VA_ARG(ps->args, UINT64) : VA_ARG(ps->args, UINT32)
|
||||
);
|
||||
Item.Scratch[0] = '0';
|
||||
Item.Scratch[1] = 'x';
|
||||
Item.Item.pw = Item.Scratch;
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
StatusToString (Item.Scratch, VA_ARG(ps->args, EFI_STATUS));
|
||||
Item.Item.pw = Item.Scratch;
|
||||
break;
|
||||
|
||||
case 's':
|
||||
Item.Item.pw = VA_ARG(ps->args, CHAR16 *);
|
||||
if (!Item.Item.pw) {
|
||||
Item.Item.pw = u"(null)";
|
||||
}
|
||||
break;
|
||||
|
||||
case 't':
|
||||
TimeToString (Item.Scratch, VA_ARG(ps->args, EFI_TIME *));
|
||||
Item.Item.pw = Item.Scratch;
|
||||
break;
|
||||
|
||||
case 'u':
|
||||
ValueToString (
|
||||
Item.Scratch,
|
||||
Item.Comma,
|
||||
Item.Long ? VA_ARG(ps->args, UINT64) : VA_ARG(ps->args, UINT32)
|
||||
);
|
||||
Item.Item.pw = Item.Scratch;
|
||||
break;
|
||||
|
||||
case 'X':
|
||||
Item.Width = Item.Long ? 16 : 8;
|
||||
Item.Pad = '0';
|
||||
#if __GNUC__ >= 7
|
||||
__attribute__ ((fallthrough));
|
||||
#endif
|
||||
case 'x':
|
||||
ValueToHex (
|
||||
Item.Scratch,
|
||||
Item.Long ? VA_ARG(ps->args, UINT64) : VA_ARG(ps->args, UINT32)
|
||||
);
|
||||
Item.Item.pw = Item.Scratch;
|
||||
break;
|
||||
|
||||
default:
|
||||
Item.Scratch[0] = '?';
|
||||
Item.Scratch[1] = 0;
|
||||
Item.Item.pw = Item.Scratch;
|
||||
break;
|
||||
}
|
||||
|
||||
// if we have an Item
|
||||
if (Item.Item.pw) {
|
||||
FUNCTION_NAME(PITEM) (ps);
|
||||
break;
|
||||
}
|
||||
|
||||
// if we have an Attr set
|
||||
if (Attr) {
|
||||
FUNCTION_NAME(PSETATTR)(ps, Attr);
|
||||
ps->RestoreAttr = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ps->RestoreAttr) {
|
||||
FUNCTION_NAME(PSETATTR)(ps, ps->RestoreAttr);
|
||||
}
|
||||
}
|
||||
|
||||
// Flush buffer
|
||||
FUNCTION_NAME(PFLUSH) (ps);
|
||||
return ps->Len;
|
||||
}
|
||||
|
||||
VOID
|
||||
CALL_CONV
|
||||
FUNCTION_NAME(_PoolCatPrint) (
|
||||
IN CONST CHAR16 *fmt,
|
||||
IN VA_LIST args,
|
||||
IN OUT POOL_PRINT *spc,
|
||||
IN INTN (EFIAPI *Output)(VOID *context, CHAR16 *str)
|
||||
);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,103 @@
|
||||
#ifndef _EFI_LEGACY_EFILIB_H
|
||||
#define _EFI_LEGACY_EFILIB_H
|
||||
|
||||
/*
|
||||
ABIs:
|
||||
Default ABI will be highest number
|
||||
Older versions can be selected via compiler defines
|
||||
*/
|
||||
|
||||
/* Option to set all compat to GNU-EFI 3.0
|
||||
To keep existing apps working without change
|
||||
Default to current ABI
|
||||
*/
|
||||
#ifdef GNU_EFI_3_0_COMPAT
|
||||
#define GNU_EFI_USE_REALLOCATEPOOL_ABI 0
|
||||
#define GNU_EFI_USE_COPYMEM_ABI 0
|
||||
#define GNU_EFI_USE_COMPAREGUID_ABI 0
|
||||
#endif
|
||||
|
||||
/* ReallocatePool */
|
||||
#ifndef GNU_EFI_USE_REALLOCATEPOOL_ABI
|
||||
#define GNU_EFI_USE_REALLOCATEPOOL_ABI 1
|
||||
#endif
|
||||
|
||||
#if GNU_EFI_USE_REALLOCATEPOOL_ABI == 0
|
||||
#define ReallocatePool(a,b,c) ReallocatePool_0(a,b,c)
|
||||
#else
|
||||
#define ReallocatePool(a,b,c) ReallocatePool_1(a,b,c)
|
||||
#endif
|
||||
|
||||
/* prevent circular headers */
|
||||
VOID *
|
||||
EFIAPI
|
||||
ReallocatePool_1 (
|
||||
IN UINTN OldSize,
|
||||
IN UINTN NewSize,
|
||||
IN VOID *OldPool OPTIONAL
|
||||
);
|
||||
|
||||
EFI_INTERNAL
|
||||
VOID *
|
||||
EFIAPI
|
||||
ReallocatePool_0 (
|
||||
IN VOID *OldPool,
|
||||
IN UINTN OldSize,
|
||||
IN UINTN NewSize
|
||||
)
|
||||
{
|
||||
return ReallocatePool_1(OldSize, NewSize, OldPool);
|
||||
}
|
||||
|
||||
/* end ReallocatePool */
|
||||
|
||||
/* CopyMem */
|
||||
/* CopyMemC isn't deprecated - serves different purpose to CopyMem */
|
||||
|
||||
#ifndef GNU_EFI_USE_COPYMEM_ABI
|
||||
#define GNU_EFI_USE_COPYMEM_ABI 1
|
||||
#endif
|
||||
|
||||
#if GNU_EFI_USE_COPYMEM_ABI == 0
|
||||
#define CopyMem(a,b,c) CopyMemC(a,b,c)
|
||||
#else
|
||||
#define CopyMem(a,b,c) CopyMem_1(a,b,c)
|
||||
#endif
|
||||
|
||||
/* end CopyMem */
|
||||
|
||||
/* CompareGuid */
|
||||
|
||||
#ifndef GNU_EFI_USE_COMPAREGUID_ABI
|
||||
#define GNU_EFI_USE_COMPAREGUID_ABI 1
|
||||
#endif
|
||||
|
||||
#if GNU_EFI_USE_COMPAREGUID_ABI == 0
|
||||
#define CompareGuid(a,b) CompareGuid_0(a,b)
|
||||
#else
|
||||
#define CompareGuid(a,b) CompareGuid_1(a,b)
|
||||
#endif
|
||||
|
||||
/* prevent circular headers */
|
||||
BOOLEAN
|
||||
EFIAPI
|
||||
CompareGuid_1 (
|
||||
IN CONST EFI_GUID *Guid1,
|
||||
IN CONST EFI_GUID *Guid2
|
||||
);
|
||||
|
||||
EFI_INTERNAL
|
||||
INTN
|
||||
EFIAPI
|
||||
CompareGuid_0 (
|
||||
IN EFI_GUID *Guid1,
|
||||
IN EFI_GUID *Guid2)
|
||||
{
|
||||
if (CompareGuid_1(Guid1, Guid2)) {
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,92 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
lib.h
|
||||
|
||||
Abstract:
|
||||
|
||||
EFI library header files
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC visibility push(hidden)
|
||||
#endif
|
||||
|
||||
#include "efi.h"
|
||||
#include "efilib.h"
|
||||
#include "efirtlib.h"
|
||||
|
||||
//
|
||||
// Include non architectural protocols
|
||||
//
|
||||
#include "protocol/efivar.h"
|
||||
#include "protocol/legacyboot.h"
|
||||
#include "protocol/intload.h"
|
||||
#include "protocol/vgaclass.h"
|
||||
#include "protocol/eficonsplit.h"
|
||||
#include "protocol/adapterdebug.h"
|
||||
#include "protocol/intload.h"
|
||||
|
||||
#include "efigpt.h"
|
||||
#include "libsmbios.h"
|
||||
|
||||
//
|
||||
// Prototypes
|
||||
//
|
||||
|
||||
VOID
|
||||
InitializeGuid (
|
||||
VOID
|
||||
);
|
||||
|
||||
INTN EFIAPI
|
||||
LibStubStriCmp (
|
||||
IN EFI_UNICODE_COLLATION_INTERFACE *This,
|
||||
IN CHAR16 *S1,
|
||||
IN CHAR16 *S2
|
||||
);
|
||||
|
||||
BOOLEAN EFIAPI
|
||||
LibStubMetaiMatch (
|
||||
IN EFI_UNICODE_COLLATION_INTERFACE *This,
|
||||
IN CHAR16 *String,
|
||||
IN CHAR16 *Pattern
|
||||
);
|
||||
|
||||
VOID EFIAPI
|
||||
LibStubStrLwrUpr (
|
||||
IN EFI_UNICODE_COLLATION_INTERFACE *This,
|
||||
IN CHAR16 *Str
|
||||
);
|
||||
|
||||
BOOLEAN
|
||||
LibMatchDevicePaths (
|
||||
IN EFI_DEVICE_PATH *Multi,
|
||||
IN EFI_DEVICE_PATH *Single
|
||||
);
|
||||
|
||||
EFI_DEVICE_PATH *
|
||||
LibDuplicateDevicePathInstance (
|
||||
IN EFI_DEVICE_PATH *DevPath
|
||||
);
|
||||
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
extern BOOLEAN LibInitialized;
|
||||
extern BOOLEAN LibFwInstance;
|
||||
extern EFI_HANDLE LibImageHandle;
|
||||
extern SIMPLE_TEXT_OUTPUT_INTERFACE *LibRuntimeDebugOut;
|
||||
extern EFI_UNICODE_COLLATION_INTERFACE *UnicodeInterface;
|
||||
extern EFI_UNICODE_COLLATION_INTERFACE LibStubUnicodeInterface;
|
||||
extern EFI_RAISE_TPL LibRuntimeRaiseTPL;
|
||||
extern EFI_RESTORE_TPL LibRuntimeRestoreTPL;
|
||||
@@ -0,0 +1,149 @@
|
||||
#ifndef _LIB_SMBIOS_H
|
||||
#define _LIB_SMBIOS_H
|
||||
/*++
|
||||
|
||||
Copyright (c) 2000 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
LibSmbios.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Lib include for SMBIOS services. Used to get system serial number and GUID
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
//
|
||||
// Define SMBIOS tables.
|
||||
//
|
||||
#pragma pack(1)
|
||||
typedef struct {
|
||||
UINT8 AnchorString[4];
|
||||
UINT8 EntryPointStructureChecksum;
|
||||
UINT8 EntryPointLength;
|
||||
UINT8 MajorVersion;
|
||||
UINT8 MinorVersion;
|
||||
UINT16 MaxStructureSize;
|
||||
UINT8 EntryPointRevision;
|
||||
UINT8 FormattedArea[5];
|
||||
UINT8 IntermediateAnchorString[5];
|
||||
UINT8 IntermediateChecksum;
|
||||
UINT16 TableLength;
|
||||
UINT32 TableAddress;
|
||||
UINT16 NumberOfSmbiosStructures;
|
||||
UINT8 SmbiosBcdRevision;
|
||||
} SMBIOS_TABLE_ENTRY_POINT;
|
||||
|
||||
#define SMBIOS_STRUCTURE_TABLE SMBIOS_TABLE_ENTRY_POINT
|
||||
|
||||
typedef struct {
|
||||
UINT8 AnchorString[5];
|
||||
UINT8 EntryPointStructureChecksum;
|
||||
UINT8 EntryPointLength;
|
||||
UINT8 MajorVersion;
|
||||
UINT8 MinorVersion;
|
||||
UINT8 DocRev;
|
||||
UINT8 EntryPointRevision;
|
||||
UINT8 Reserved;
|
||||
UINT32 TableMaximumSize;
|
||||
UINT64 TableAddress;
|
||||
} SMBIOS_TABLE_3_0_ENTRY_POINT;
|
||||
|
||||
#define SMBIOS3_STRUCTURE_TABLE SMBIOS_TABLE_3_0_ENTRY_POINT
|
||||
|
||||
//
|
||||
// Please note that SMBIOS structures can be odd byte aligned since the
|
||||
// unformated section of each record is a set of arbitrary size strings.
|
||||
//
|
||||
|
||||
typedef struct {
|
||||
UINT8 Type;
|
||||
UINT8 Length;
|
||||
UINT8 Handle[2];
|
||||
} SMBIOS_STRUCTURE;
|
||||
|
||||
#define SMBIOS_HEADER SMBIOS_STRUCTURE
|
||||
|
||||
typedef UINT8 SMBIOS_STRING;
|
||||
|
||||
typedef struct {
|
||||
SMBIOS_HEADER Hdr;
|
||||
SMBIOS_STRING Vendor;
|
||||
SMBIOS_STRING BiosVersion;
|
||||
UINT8 BiosSegment[2];
|
||||
SMBIOS_STRING BiosReleaseDate;
|
||||
UINT8 BiosSize;
|
||||
UINT8 BiosCharacteristics[8];
|
||||
} SMBIOS_TYPE0;
|
||||
|
||||
typedef struct {
|
||||
SMBIOS_HEADER Hdr;
|
||||
SMBIOS_STRING Manufacturer;
|
||||
SMBIOS_STRING ProductName;
|
||||
SMBIOS_STRING Version;
|
||||
SMBIOS_STRING SerialNumber;
|
||||
|
||||
//
|
||||
// always byte copy this data to prevent alignment faults!
|
||||
//
|
||||
EFI_GUID Uuid;
|
||||
|
||||
UINT8 WakeUpType;
|
||||
} SMBIOS_TYPE1;
|
||||
|
||||
typedef struct {
|
||||
SMBIOS_HEADER Hdr;
|
||||
SMBIOS_STRING Manufacturer;
|
||||
SMBIOS_STRING ProductName;
|
||||
SMBIOS_STRING Version;
|
||||
SMBIOS_STRING SerialNumber;
|
||||
} SMBIOS_TYPE2;
|
||||
|
||||
typedef struct {
|
||||
SMBIOS_HEADER Hdr;
|
||||
SMBIOS_STRING Manufacturer;
|
||||
UINT8 Type;
|
||||
SMBIOS_STRING Version;
|
||||
SMBIOS_STRING SerialNumber;
|
||||
SMBIOS_STRING AssetTag;
|
||||
UINT8 BootupState;
|
||||
UINT8 PowerSupplyState;
|
||||
UINT8 ThermalState;
|
||||
UINT8 SecurityStatus;
|
||||
UINT8 OemDefined[4];
|
||||
} SMBIOS_TYPE3;
|
||||
|
||||
typedef struct {
|
||||
SMBIOS_HEADER Hdr;
|
||||
UINT8 Socket;
|
||||
UINT8 ProcessorType;
|
||||
UINT8 ProcessorFamily;
|
||||
SMBIOS_STRING ProcessorManufacture;
|
||||
UINT8 ProcessorId[8];
|
||||
SMBIOS_STRING ProcessorVersion;
|
||||
UINT8 Voltage;
|
||||
UINT8 ExternalClock[2];
|
||||
UINT8 MaxSpeed[2];
|
||||
UINT8 CurrentSpeed[2];
|
||||
UINT8 Status;
|
||||
UINT8 ProcessorUpgrade;
|
||||
UINT8 L1CacheHandle[2];
|
||||
UINT8 L2CacheHandle[2];
|
||||
UINT8 L3CacheHandle[2];
|
||||
} SMBIOS_TYPE4;
|
||||
|
||||
typedef union {
|
||||
SMBIOS_HEADER *Hdr;
|
||||
SMBIOS_TYPE0 *Type0;
|
||||
SMBIOS_TYPE1 *Type1;
|
||||
SMBIOS_TYPE2 *Type2;
|
||||
SMBIOS_TYPE3 *Type3;
|
||||
SMBIOS_TYPE4 *Type4;
|
||||
UINT8 *Raw;
|
||||
} SMBIOS_STRUCTURE_POINTER;
|
||||
#pragma pack()
|
||||
|
||||
#endif
|
||||
+193
@@ -0,0 +1,193 @@
|
||||
#ifndef _PCI22_H
|
||||
#define _PCI22_H
|
||||
|
||||
/*++
|
||||
|
||||
Copyright (c) 1999 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
pci22.h
|
||||
|
||||
Abstract:
|
||||
Support for PCI 2.2 standard.
|
||||
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
#ifdef SOFT_SDV
|
||||
#define PCI_MAX_BUS 1
|
||||
#else
|
||||
#define PCI_MAX_BUS 255
|
||||
#endif
|
||||
|
||||
#define PCI_MAX_DEVICE 31
|
||||
#define PCI_MAX_FUNC 7
|
||||
|
||||
//
|
||||
// Command
|
||||
//
|
||||
#define PCI_VGA_PALETTE_SNOOP_DISABLED 0x20
|
||||
|
||||
#pragma pack(1)
|
||||
typedef struct {
|
||||
UINT16 VendorId;
|
||||
UINT16 DeviceId;
|
||||
UINT16 Command;
|
||||
UINT16 Status;
|
||||
UINT8 RevisionID;
|
||||
UINT8 ClassCode[3];
|
||||
UINT8 CacheLineSize;
|
||||
UINT8 LaytencyTimer;
|
||||
UINT8 HeaderType;
|
||||
UINT8 BIST;
|
||||
} PCI_DEVICE_INDEPENDENT_REGION;
|
||||
|
||||
typedef struct {
|
||||
UINT32 Bar[6];
|
||||
UINT32 CISPtr;
|
||||
UINT16 SubsystemVendorID;
|
||||
UINT16 SubsystemID;
|
||||
UINT32 ExpansionRomBar;
|
||||
UINT32 Reserved[2];
|
||||
UINT8 InterruptLine;
|
||||
UINT8 InterruptPin;
|
||||
UINT8 MinGnt;
|
||||
UINT8 MaxLat;
|
||||
} PCI_DEVICE_HEADER_TYPE_REGION;
|
||||
|
||||
typedef struct {
|
||||
PCI_DEVICE_INDEPENDENT_REGION Hdr;
|
||||
PCI_DEVICE_HEADER_TYPE_REGION Device;
|
||||
} PCI_TYPE00;
|
||||
|
||||
typedef struct {
|
||||
UINT32 Bar[2];
|
||||
UINT8 PrimaryBus;
|
||||
UINT8 SecondaryBus;
|
||||
UINT8 SubordinateBus;
|
||||
UINT8 SecondaryLatencyTimer;
|
||||
UINT8 IoBase;
|
||||
UINT8 IoLimit;
|
||||
UINT16 SecondaryStatus;
|
||||
UINT16 MemoryBase;
|
||||
UINT16 MemoryLimit;
|
||||
UINT16 PrefetchableMemoryBase;
|
||||
UINT16 PrefetchableMemoryLimit;
|
||||
UINT32 PrefetchableBaseUpper32;
|
||||
UINT32 PrefetchableLimitUpper32;
|
||||
UINT16 IoBaseUpper16;
|
||||
UINT16 IoLimitUpper16;
|
||||
UINT32 Reserved;
|
||||
UINT32 ExpansionRomBAR;
|
||||
UINT8 InterruptLine;
|
||||
UINT8 InterruptPin;
|
||||
UINT16 BridgeControl;
|
||||
} PCI_BRIDGE_CONTROL_REGISTER;
|
||||
|
||||
#define PCI_CLASS_DISPLAY_CTRL 0x03
|
||||
#define PCI_CLASS_VGA 0x00
|
||||
|
||||
#define PCI_CLASS_BRIDGE 0x06
|
||||
#define PCI_CLASS_ISA 0x01
|
||||
#define PCI_CLASS_ISA_POSITIVE_DECODE 0x80
|
||||
|
||||
#define PCI_CLASS_NETWORK 0x02
|
||||
#define PCI_CLASS_ETHERNET 0x00
|
||||
|
||||
#define HEADER_TYPE_DEVICE 0x00
|
||||
#define HEADER_TYPE_PCI_TO_PCI_BRIDGE 0x01
|
||||
#define HEADER_TYPE_MULTI_FUNCTION 0x80
|
||||
#define HEADER_LAYOUT_CODE 0x7f
|
||||
|
||||
#define IS_PCI_BRIDGE(_p) ((((_p)->Hdr.HeaderType) & HEADER_LAYOUT_CODE) == HEADER_TYPE_PCI_TO_PCI_BRIDGE)
|
||||
#define IS_PCI_MULTI_FUNC(_p) (((_p)->Hdr.HeaderType) & HEADER_TYPE_MULTI_FUNCTION)
|
||||
|
||||
typedef struct {
|
||||
PCI_DEVICE_INDEPENDENT_REGION Hdr;
|
||||
PCI_BRIDGE_CONTROL_REGISTER Bridge;
|
||||
} PCI_TYPE01;
|
||||
|
||||
typedef struct {
|
||||
UINT8 Register;
|
||||
UINT8 Function;
|
||||
UINT8 Device;
|
||||
UINT8 Bus;
|
||||
UINT8 Reserved[4];
|
||||
} DEFIO_PCI_ADDR;
|
||||
|
||||
typedef struct {
|
||||
UINT32 Reg : 8;
|
||||
UINT32 Func : 3;
|
||||
UINT32 Dev : 5;
|
||||
UINT32 Bus : 8;
|
||||
UINT32 Reserved: 7;
|
||||
UINT32 Enable : 1;
|
||||
} PCI_CONFIG_ACCESS_CF8;
|
||||
|
||||
#pragma pack()
|
||||
|
||||
#define EFI_ROOT_BRIDGE_LIST 'eprb'
|
||||
typedef struct {
|
||||
UINTN Signature;
|
||||
|
||||
UINT16 BridgeNumber;
|
||||
UINT16 PrimaryBus;
|
||||
UINT16 SubordinateBus;
|
||||
|
||||
EFI_DEVICE_PATH *DevicePath;
|
||||
|
||||
LIST_ENTRY Link;
|
||||
} PCI_ROOT_BRIDGE_ENTRY;
|
||||
|
||||
|
||||
#define PCI_EXPANSION_ROM_HEADER_SIGNATURE 0xaa55
|
||||
#define EFI_PCI_EXPANSION_ROM_HEADER_EFISIGNATURE 0x0EF1
|
||||
#define PCI_DATA_STRUCTURE_SIGNATURE EFI_SIGNATURE_32('P','C','I','R')
|
||||
|
||||
#pragma pack(1)
|
||||
typedef struct {
|
||||
UINT16 Signature; // 0xaa55
|
||||
UINT8 Reserved[0x16];
|
||||
UINT16 PcirOffset;
|
||||
} PCI_EXPANSION_ROM_HEADER;
|
||||
|
||||
|
||||
typedef struct {
|
||||
UINT16 Signature; // 0xaa55
|
||||
UINT16 InitializationSize;
|
||||
UINT16 EfiSignature; // 0x0EF1
|
||||
UINT16 EfiSubsystem;
|
||||
UINT16 EfiMachineType;
|
||||
UINT8 Reserved[0x0A];
|
||||
UINT16 EfiImageHeaderOffset;
|
||||
UINT16 PcirOffset;
|
||||
} EFI_PCI_EXPANSION_ROM_HEADER;
|
||||
|
||||
typedef struct {
|
||||
UINT32 Signature; // "PCIR"
|
||||
UINT16 VendorId;
|
||||
UINT16 DeviceId;
|
||||
UINT16 Reserved0;
|
||||
UINT16 Length;
|
||||
UINT8 Revision;
|
||||
UINT8 ClassCode[3];
|
||||
UINT16 ImageLength;
|
||||
UINT16 CodeRevision;
|
||||
UINT8 CodeType;
|
||||
UINT8 Indicator;
|
||||
UINT16 Reserved1;
|
||||
} PCI_DATA_STRUCTURE;
|
||||
#pragma pack()
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
#ifndef _ADAPTER_DEBUG_H
|
||||
#define _ADAPTER_DEBUG_H
|
||||
|
||||
/*++
|
||||
|
||||
Copyright (c) 1999 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
AdapterDebug.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Protocol to debug the EDD 3.0 enablement of BIOS option ROMs
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
// {82F86881-282B-11d4-BC7D-0080C73C8881}
|
||||
#define ADAPTER_DEBUG_PROTOCOL \
|
||||
{ 0x82f86881, 0x282b, 0x11d4, {0xbc, 0x7d, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81} }
|
||||
|
||||
//
|
||||
// This protocol points to the BIOS_LEGACY_DRIVE data structure
|
||||
// see edd.h for more details
|
||||
//
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
#ifndef _EFI_CONFORK_H
|
||||
#define _EFI_CONFORK_H
|
||||
/*++
|
||||
|
||||
Copyright (c) 1999 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
Abstract:
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
|
||||
|
||||
//
|
||||
// ConOut Forker Protocol
|
||||
//
|
||||
|
||||
#define TEXT_OUT_SPLITER_PROTOCOL \
|
||||
{ 0x56d830a0, 0x7e7a, 0x11d3, {0xbb, 0xa0, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} }
|
||||
|
||||
#define ERROR_OUT_SPLITER_PROTOCOL \
|
||||
{ 0xf0ba9039, 0x68f1, 0x425e, {0xaa, 0x7f, 0xd9, 0xaa, 0xf9, 0x1b, 0x82, 0xa1}}
|
||||
|
||||
#define TEXT_IN_SPLITER_PROTOCOL \
|
||||
{ 0xf9a3c550, 0x7fb5, 0x11d3, {0xbb, 0xa0, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} }
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,210 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2000
|
||||
* Intel Corporation.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
*
|
||||
* This product includes software developed by Intel Corporation and
|
||||
* its contributors.
|
||||
*
|
||||
* 4. Neither the name of Intel Corporation or its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION AND CONTRIBUTORS ``AS IS''
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _EFIDBG_H_
|
||||
#define _EFIDBG_H_
|
||||
|
||||
#include "eficontext.h"
|
||||
#include "efiser.h"
|
||||
|
||||
typedef struct _DEBUGPORT_16550_CONFIG_DATA {
|
||||
UINT32 PortAddress;
|
||||
UINT64 BaudRate;
|
||||
UINT32 ReceiveFifoDepth;
|
||||
UINT32 Timeout;
|
||||
UINT8 Parity;
|
||||
UINT8 DataBits;
|
||||
UINT8 StopBits;
|
||||
UINT32 ControlMask;
|
||||
BOOLEAN RtsCtsEnable; // RTS, CTS control
|
||||
} DEBUGPORT_16550_CONFIG_DATA;
|
||||
|
||||
typedef struct _DEBUGPORT_16550_DEVICE_PATH {
|
||||
EFI_DEVICE_PATH Header;
|
||||
DEBUGPORT_16550_CONFIG_DATA ConfigData;
|
||||
} DEBUGPORT_16550_DEVICE_PATH;
|
||||
|
||||
typedef union {
|
||||
EFI_DEVICE_PATH DevPath;
|
||||
DEBUGPORT_16550_DEVICE_PATH Uart;
|
||||
// add new types of debugport device paths to this union...
|
||||
} DEBUGPORT_DEV_PATH;
|
||||
|
||||
|
||||
//
|
||||
// Debug Support protocol {2755590C-6F3C-42FA-9EA4-A3BA543CDA25}
|
||||
//
|
||||
|
||||
#define DEBUG_SUPPORT_PROTOCOL \
|
||||
{ 0x2755590C, 0x6F3C, 0x42fa, 0x9E, 0xA4, 0xA3, 0xBA, 0x54, 0x3C, 0xDA, 0x25 }
|
||||
|
||||
|
||||
typedef UINTN EXCEPTION_TYPE;
|
||||
|
||||
typedef
|
||||
VOID
|
||||
(*EXCEPTION_HANDLER) (
|
||||
IN EXCEPTION_TYPE ExceptionType,
|
||||
IN SYSTEM_CONTEXT *SystemContext
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_REGISTER_TIMER_TICK_CALLBACK) (
|
||||
IN struct _EFI_DEBUG_SUPPORT_INTERFACE *This,
|
||||
IN EXCEPTION_HANDLER TimerTickCallback
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_REGISTER_EXCEPTION_HANDLER) (
|
||||
IN struct _EFI_DEBUG_SUPPORT_INTERFACE *This,
|
||||
IN EXCEPTION_HANDLER ExceptionHandler,
|
||||
IN EXCEPTION_TYPE ExceptionType
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_IP_CALL_TRACE) (
|
||||
IN struct _EFI_DEBUG_SUPPORT_INTERFACE *This
|
||||
);
|
||||
|
||||
|
||||
#define EFI_DEBUG_SUPPORT_INTERFACE_REVISION 0x00010000
|
||||
|
||||
typedef struct _EFI_DEBUG_SUPPORT_INTERFACE {
|
||||
UINT32 Revision;
|
||||
EFI_REGISTER_TIMER_TICK_CALLBACK RegisterTimerTickCallback;
|
||||
EFI_REGISTER_EXCEPTION_HANDLER RegisterExceptionHandler;
|
||||
EFI_IP_CALL_TRACE IpCallTrace;
|
||||
} EFI_DEBUG_SUPPORT_INTERFACE;
|
||||
|
||||
|
||||
//
|
||||
// Debugport io protocol {EBA4E8D2-3858-41EC-A281-2647BA9660D0}
|
||||
//
|
||||
|
||||
#define DEBUGPORT_IO_PROTOCOL \
|
||||
{ 0XEBA4E8D2, 0X3858, 0X41EC, 0XA2, 0X81, 0X26, 0X47, 0XBA, 0X96, 0X60, 0XD0 }
|
||||
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_DEBUGPORT_IO_RESET) (
|
||||
IN struct _EFI_DEBUGPORT_IO_INTERFACE *This
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_DEBUGPORT_IO_READ) (
|
||||
IN struct _EFI_DEBUGPORT_IO_INTERFACE *This,
|
||||
IN OUT UINTN *BufferSize,
|
||||
OUT VOID *Buffer
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_DEBUGPORT_IO_WRITE) (
|
||||
IN struct _EFI_DEBUGPORT_IO_INTERFACE *This,
|
||||
IN OUT UINTN *BufferSize,
|
||||
IN VOID *Buffer
|
||||
);
|
||||
|
||||
#define EFI_DEBUGPORT_IO_INTERFACE_REVISION 0x00010000
|
||||
|
||||
typedef struct _EFI_DEBUGPORT_IO_INTERFACE {
|
||||
UINT32 Revision;
|
||||
EFI_DEBUGPORT_IO_READ Read;
|
||||
EFI_DEBUGPORT_IO_WRITE Write;
|
||||
EFI_DEBUGPORT_IO_RESET Reset;
|
||||
} EFI_DEBUGPORT_IO_INTERFACE;
|
||||
|
||||
|
||||
//
|
||||
// Debugport UART16550 control protocol {628EA978-4C26-4605-BC02-A42A496917DD}
|
||||
//
|
||||
|
||||
#define DEBUGPORT_UART16550_CONTROL_PROTOCOL \
|
||||
{ 0X628EA978, 0X4C26, 0X4605, 0XBC, 0X2, 0XA4, 0X2A, 0X49, 0X69, 0X17, 0XDD }
|
||||
|
||||
// Note: The definitions for EFI_PARITY_TYPE, EFI_STOP_BITS_TYPE, and
|
||||
// SERIAL_IO_MODE are included from efiser.h
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_UART16550_SET_ATTRIBUTES) (
|
||||
IN struct _EFI_DEBUGPORT_UART16550_CONTROL_INTERFACE *This,
|
||||
IN UINT64 BaudRate,
|
||||
IN UINT32 ReceiveFifoDepth,
|
||||
IN UINT32 Timeout,
|
||||
IN EFI_PARITY_TYPE Parity,
|
||||
IN UINT8 DataBits,
|
||||
IN EFI_STOP_BITS_TYPE StopBits
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_UART16550_SET_CONTROL_BITS) (
|
||||
IN struct _EFI_DEBUGPORT_UART16550_CONTROL_INTERFACE *This,
|
||||
IN UINT32 Control
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_UART16550_GET_CONTROL_BITS) (
|
||||
IN struct _EFI_DEBUGPORT_UART16550_CONTROL_INTERFACE *This,
|
||||
OUT UINT32 *Control
|
||||
);
|
||||
|
||||
#define EFI_DEBUGPORT_UART16550_CONTROL_INTERFACE_REVISION 0x00010000
|
||||
|
||||
typedef struct _EFI_DEBUGPORT_UART16550_CONTROL_INTERFACE {
|
||||
UINT32 Revision;
|
||||
EFI_UART16550_SET_ATTRIBUTES SetAttributes;
|
||||
EFI_UART16550_SET_CONTROL_BITS SetControl;
|
||||
EFI_UART16550_GET_CONTROL_BITS GetControl;
|
||||
DEBUGPORT_16550_CONFIG_DATA *Mode;
|
||||
} EFI_DEBUGPORT_UART16550_CONTROL_INTERFACE;
|
||||
|
||||
|
||||
#define DEVICE_PATH_DEBUGPORT DEBUGPORT_IO_PROTOCOL
|
||||
|
||||
#endif /* _EFIDBG_H_ */
|
||||
@@ -0,0 +1,133 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
Abstract:
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
|
||||
|
||||
//
|
||||
// The variable store protocol interface is specific to the reference
|
||||
// implementation. The initialization code adds variable store devices
|
||||
// to the system, and the FW connects to the devices to provide the
|
||||
// variable store interfaces through these devices.
|
||||
//
|
||||
|
||||
//
|
||||
// Variable Store Device protocol
|
||||
//
|
||||
|
||||
#define VARIABLE_STORE_PROTOCOL \
|
||||
{ 0xf088cd91, 0xa046, 0x11d2, {0x8e, 0x42, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} }
|
||||
|
||||
INTERFACE_DECL(_EFI_VARIABLE_STORE);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_STORE_CLEAR) (
|
||||
IN struct _EFI_VARIABLE_STORE *This,
|
||||
IN UINTN BankNo,
|
||||
IN OUT VOID *Scratch
|
||||
);
|
||||
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_STORE_READ) (
|
||||
IN struct _EFI_VARIABLE_STORE *This,
|
||||
IN UINTN BankNo,
|
||||
IN UINTN Offset,
|
||||
IN UINTN BufferSize,
|
||||
OUT VOID *Buffer
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_STORE_UPDATE) (
|
||||
IN struct _EFI_VARIABLE_STORE *This,
|
||||
IN UINTN BankNo,
|
||||
IN UINTN Offset,
|
||||
IN UINTN BufferSize,
|
||||
IN VOID *Buffer
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_STORE_SIZE) (
|
||||
IN struct _EFI_VARIABLE_STORE *This,
|
||||
IN UINTN NoBanks
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_TRANSACTION_UPDATE) (
|
||||
IN struct _EFI_VARIABLE_STORE *This,
|
||||
IN UINTN BankNo,
|
||||
IN VOID *NewContents
|
||||
);
|
||||
|
||||
typedef struct _EFI_VARIABLE_STORE {
|
||||
|
||||
//
|
||||
// Number of banks and bank size
|
||||
//
|
||||
|
||||
UINT32 Attributes;
|
||||
UINT32 BankSize;
|
||||
UINT32 NoBanks;
|
||||
|
||||
//
|
||||
// Functions to access the storage banks
|
||||
//
|
||||
|
||||
EFI_STORE_CLEAR ClearStore;
|
||||
EFI_STORE_READ ReadStore;
|
||||
EFI_STORE_UPDATE UpdateStore;
|
||||
EFI_STORE_SIZE SizeStore OPTIONAL;
|
||||
EFI_TRANSACTION_UPDATE TransactionUpdate OPTIONAL;
|
||||
|
||||
} EFI_VARIABLE_STORE;
|
||||
|
||||
|
||||
//
|
||||
//
|
||||
// ClearStore() - A function to clear the requested storage bank. A cleared
|
||||
// bank contains all "on" bits.
|
||||
//
|
||||
// ReadStore() - Read data from the requested store.
|
||||
//
|
||||
// UpdateStore() - Updates data on the requested store. The FW will only
|
||||
// ever issue updates to clear bits in the store. Updates must be
|
||||
// performed in LSb to MSb order of the update buffer.
|
||||
//
|
||||
// SizeStore() - An optional function for non-runtime stores that can be
|
||||
// dynamically sized. The FW will only ever increase or decrease the store
|
||||
// by 1 banksize at a time, and it is always adding or removing a bank from
|
||||
// the end of the store.
|
||||
//
|
||||
// By default the FW will update variables and storage banks in an
|
||||
// "atomic" manner by keeping 1 old copy of the data during an update,
|
||||
// and recovering appropiately if the power is lost during the middle
|
||||
// of an operation. To do this the FW needs to have multiple banks
|
||||
// of storage dedicated to its use. If that's not possible, the driver
|
||||
// can implement an atomic bank update function and the FW will allow
|
||||
// 1 bank in this case. (It will allow any number of banks,
|
||||
// but it won't require an "extra" bank to provide its bank transaction
|
||||
// function).
|
||||
//
|
||||
// TransactionUpdate() - An optional function that can clear & update an
|
||||
// entire bank in an "atomic" fashion. If the operation fails in the
|
||||
// middle the driver is responsible for having either the previous copy
|
||||
// of the bank's data or the new copy. A copy that's partially written
|
||||
// is not valid as internal data settings may get lost. Supply this
|
||||
// function only when needed.
|
||||
//
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 1999 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
intload
|
||||
|
||||
Abstract:
|
||||
|
||||
EFI support for loading internally linked in apps
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
#ifndef _INTERNAL_LOAD_INCLUDE_
|
||||
#define _INTERNAL_LOAD_INCLUDE_
|
||||
|
||||
// {D65A6B8C-71E5-4df0-A909-F0D2992B5AA9}
|
||||
#define INTERNAL_SHELL_GUID \
|
||||
{ 0xd65a6b8c, 0x71e5, 0x4df0, {0xa9, 0x09, 0xf0, 0xd2, 0x99, 0x2b, 0x5a, 0xa9} }
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,119 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 1999 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
legacyboot
|
||||
|
||||
Abstract:
|
||||
|
||||
EFI support for legacy boot
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
#ifndef _LEGACY_BOOT_INCLUDE_
|
||||
#define _LEGACY_BOOT_INCLUDE_
|
||||
|
||||
#define LEGACY_BOOT_PROTOCOL \
|
||||
{ 0x376e5eb2, 0x30e4, 0x11d3, { 0xba, 0xe5, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } }
|
||||
|
||||
#pragma pack(1)
|
||||
|
||||
//
|
||||
// BBS 1.01 (See Appendix A) IPL and BCV Table Entry Data structure.
|
||||
// Seg:Off pointers have been converted to EFI pointers in this data structure
|
||||
// This is the structure that also maps to the EFI device path for the boot selection
|
||||
//
|
||||
typedef struct {
|
||||
UINT16 DeviceType;
|
||||
UINT16 StatusFlag;
|
||||
UINT32 Reserved;
|
||||
VOID *BootHandler; // Not an EFI entry point
|
||||
CHAR8 *DescString;
|
||||
} BBS_TABLE_ENTRY;
|
||||
#pragma pack()
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *LEGACY_BOOT_CALL) (
|
||||
IN EFI_DEVICE_PATH *DevicePath
|
||||
);
|
||||
|
||||
|
||||
//
|
||||
// BBS support functions
|
||||
// PnP Call numbers and BiosSelector hidden in implementation
|
||||
//
|
||||
|
||||
typedef enum {
|
||||
IplRelative,
|
||||
BcvRelative
|
||||
} BBS_TYPE;
|
||||
|
||||
INTERFACE_DECL(_LEGACY_BOOT_INTERFACE);
|
||||
|
||||
//
|
||||
// == PnP Function 0x60 then BbsVersion == 0x0101 if this call fails then BbsVersion == 0x0000
|
||||
//
|
||||
|
||||
//
|
||||
// == PnP Function 0x61
|
||||
//
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *GET_DEVICE_COUNT) (
|
||||
IN struct _LEGACY_BOOT_INTERFACE *This,
|
||||
IN BBS_TYPE *TableType,
|
||||
OUT UINTN *DeviceCount,
|
||||
OUT UINTN *MaxCount
|
||||
);
|
||||
|
||||
//
|
||||
// == PnP Function 0x62
|
||||
//
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *GET_PRIORITY_AND_TABLE) (
|
||||
IN struct _LEGACY_BOOT_INTERFACE *This,
|
||||
IN BBS_TYPE *TableType,
|
||||
IN OUT UINTN *PrioritySize, // MaxCount * sizeof(UINT8)
|
||||
OUT UINTN *Priority,
|
||||
IN OUT UINTN *TableSize, // MaxCount * sizeof(BBS_TABLE_ENTRY)
|
||||
OUT BBS_TABLE_ENTRY *TableEntrySize
|
||||
);
|
||||
|
||||
//
|
||||
// == PnP Function 0x63
|
||||
//
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *SET_PRIORITY) (
|
||||
IN struct _LEGACY_BOOT_INTERFACE *This,
|
||||
IN BBS_TYPE *TableType,
|
||||
IN OUT UINTN *PrioritySize,
|
||||
OUT UINTN *Priority
|
||||
);
|
||||
|
||||
typedef struct _LEGACY_BOOT_INTERFACE {
|
||||
LEGACY_BOOT_CALL BootIt;
|
||||
|
||||
//
|
||||
// New functions to allow BBS booting to be configured from EFI
|
||||
//
|
||||
UINTN BbsVersion; // Currently 0x0101
|
||||
GET_DEVICE_COUNT GetDeviceCount;
|
||||
GET_PRIORITY_AND_TABLE GetPriorityAndTable;
|
||||
SET_PRIORITY SetPriority;
|
||||
} LEGACY_BOOT_INTERFACE;
|
||||
|
||||
EFI_STATUS
|
||||
PlInitializeLegacyBoot (
|
||||
VOID
|
||||
);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,121 @@
|
||||
#ifndef _PIFLASH64_H
|
||||
#define _PIFLASH64_H
|
||||
|
||||
/*++
|
||||
|
||||
Copyright (c) 1999 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
PIflash64.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Iflash64.efi protocol to abstract iflash from
|
||||
the system.
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
//
|
||||
// Guid that identifies the IFLASH protocol
|
||||
//
|
||||
#define IFLASH64_PROTOCOL_PROTOCOL \
|
||||
{ 0x65cba110, 0x74ab, 0x11d3, 0xbb, 0x89, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 };
|
||||
|
||||
//
|
||||
// Unlock FLASH from StartAddress to EndAddress and return a LockKey
|
||||
//
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *UNLOCK_FLASH_API)(
|
||||
IN struct _IFLASH64_PROTOCOL_INTERFACE *This
|
||||
);
|
||||
|
||||
//
|
||||
// Lock the flash represented by the LockKey
|
||||
//
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *LOCK_FLASH_API)(
|
||||
IN struct _IFLASH64_PROTOCOL_INTERFACE *This
|
||||
);
|
||||
|
||||
//
|
||||
// Status callback for a utility like IFLASH64
|
||||
//
|
||||
// Token would map to a list like Ted proposed. The utility has no idea what
|
||||
// happens on the other side.
|
||||
// ErrorStatus - Level of Error or success. Independent of Token. If you
|
||||
// don't know the token you will at least know pass or fail.
|
||||
// String - Optional extra information about the error. Could be used for
|
||||
// debug or future expansion
|
||||
//
|
||||
// Attributes - Options screen attributes for String. Could allow the string to be different colors.
|
||||
//
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *UTILITY_PROGRESS_API)(
|
||||
IN struct _IFLASH64_PROTOCOL_INTERFACE *This,
|
||||
IN UINTN Token,
|
||||
IN EFI_STATUS ErrorStatus,
|
||||
IN CHAR16 *String, OPTIONAL
|
||||
IN UINTN *Attributes OPTIONAL
|
||||
);
|
||||
|
||||
//
|
||||
// Token Values
|
||||
//
|
||||
// IFlash64 Token Codes
|
||||
#define IFLASH_TOKEN_IFLASHSTART 0xB0 // IFlash64 has started
|
||||
#define IFLASH_TOKEN_READINGFILE 0xB1 // Reading File
|
||||
#define IFLASH_TOKEN_INITVPP 0xB2 // Initializing Vpp
|
||||
#define IFLASH_TOKEN_DISABLEVPP 0x10 // Disable Vpp
|
||||
#define IFLASH_TOKEN_FLASHUNLOCK 0xB3 // Unlocking FLASH Devices
|
||||
#define IFLASH_TOKEN_FLASHERASE 0xB4 // Erasing FLASH Devices
|
||||
#define IFLASH_TOKEN_FLASHPROGRAM 0xB5 // Programming FLASH
|
||||
#define IFLASH_TOKEN_FLASHVERIFY 0xB6 // Verifying FLASH
|
||||
#define IFLASH_TOKEN_UPDATESUCCES 0xB7 // FLASH Updage Success!
|
||||
|
||||
#define IFLASH_TOKEN_PROGRESS_READINGFILE 0x11 // % Reading File
|
||||
#define IFLASH_TOKEN_PROGRESS_FLASHUNLOCK 0x13 // % Unlocking FLASH Devices
|
||||
#define IFLASH_TOKEN_PROGRESS_FLASHERASE 0x14 // % Erasing FLASH Devices
|
||||
#define IFLASH_TOKEN_PROGRESS_FLASHPROGRAM 0x15 // % Programming FLASH
|
||||
#define IFLASH_TOKEN_PROGRESS_FLASHVERIFY 0x16 // % Verifying FLASH
|
||||
|
||||
#define IFLASH_TOKEN_READINGFILE_ER 0xB8 // File Read Error
|
||||
#define IFLASH_TOKEN_INITVPP_ER 0xB9 // Initialization of IFB Error
|
||||
#define IFLASH_TOKEN_FLASHUNLOCK_ER 0xBA // FLASH Unlock Error
|
||||
#define IFLASH_TOKEN_FLASHERASE_ER 0xBB // FLASH Erase Error
|
||||
#define IFLASH_TOKEN_FLASHVERIFY_ER 0xBC // FLASH Verify Error
|
||||
#define IFLASH_TOKEN_FLASHPROG_ER 0xBD // FLASH Program Error
|
||||
|
||||
#define IFLASH_TABLE_END 0x00
|
||||
|
||||
//
|
||||
// If this number changes one of the existing API's has changes
|
||||
//
|
||||
#define IFLASH_PI_MAJOR_VERSION 0x01
|
||||
|
||||
//
|
||||
// This number changes when new APIs or data variables get added to the end
|
||||
// of the data structure
|
||||
//
|
||||
#define IFLASH_PI_MINOR_VERSION 0x01
|
||||
|
||||
typedef struct _IFLASH64_PROTOCOL_INTERFACE {
|
||||
UINT32 MajorVersion;
|
||||
UINT32 MinorVersion;
|
||||
UNLOCK_FLASH_API UnlockFlash;
|
||||
LOCK_FLASH_API LockFlash;
|
||||
UTILITY_PROGRESS_API Progress;
|
||||
|
||||
//
|
||||
// Future expansion goes here
|
||||
//
|
||||
|
||||
} IFLASH64_PROTOCOL_INTERFACE;
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,95 @@
|
||||
#ifndef _VGA_CLASS_H
|
||||
#define _VGA_CLASS_H
|
||||
|
||||
/*++
|
||||
|
||||
Copyright (c) 1999 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
VgaClass.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Vga Mini port binding to Vga Class protocol
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
//
|
||||
// VGA Device Structure
|
||||
//
|
||||
|
||||
// {0E3D6310-6FE4-11d3-BB81-0080C73C8881}
|
||||
#define VGA_CLASS_DRIVER_PROTOCOL \
|
||||
{ 0xe3d6310, 0x6fe4, 0x11d3, {0xbb, 0x81, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81} }
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(* INIT_VGA_CARD) (
|
||||
IN UINTN VgaMode,
|
||||
IN VOID *Context
|
||||
);
|
||||
|
||||
typedef struct {
|
||||
UINTN MaxColumns;
|
||||
UINTN MaxRows;
|
||||
} MAX_CONSOLE_GEOMETRY;
|
||||
|
||||
#define VGA_CON_OUT_DEV_SIGNATURE EFI_SIGNATURE_32('c','v','g','a')
|
||||
typedef struct {
|
||||
UINTN Signature;
|
||||
|
||||
EFI_HANDLE Handle;
|
||||
SIMPLE_TEXT_OUTPUT_INTERFACE ConOut;
|
||||
SIMPLE_TEXT_OUTPUT_MODE ConOutMode;
|
||||
EFI_DEVICE_PATH *DevicePath;
|
||||
|
||||
UINT8 *Buffer;
|
||||
EFI_DEVICE_IO_INTERFACE *DeviceIo;
|
||||
|
||||
//
|
||||
// Video Card Context
|
||||
//
|
||||
INIT_VGA_CARD InitVgaCard;
|
||||
VOID *VgaCardContext;
|
||||
MAX_CONSOLE_GEOMETRY *Geometry;
|
||||
//
|
||||
// Video buffer normally 0xb8000
|
||||
//
|
||||
UINT64 VideoBuffer;
|
||||
|
||||
//
|
||||
// Clear Screen & Default Attribute
|
||||
//
|
||||
UINT32 Attribute;
|
||||
|
||||
//
|
||||
// -1 means search for active VGA device
|
||||
//
|
||||
EFI_PCI_ADDRESS_UNION Pci;
|
||||
} VGA_CON_OUT_DEV;
|
||||
|
||||
#define VGA_CON_OUT_DEV_FROM_THIS(a) CR(a, VGA_CON_OUT_DEV, ConOut, VGA_CON_OUT_DEV_SIGNATURE)
|
||||
|
||||
//
|
||||
// Vga Class Driver Protocol.
|
||||
// GUID defined in EFI Lib
|
||||
//
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *INSTALL_VGA_DRIVER) (
|
||||
IN VGA_CON_OUT_DEV *ConOutDev
|
||||
);
|
||||
|
||||
typedef struct {
|
||||
UINT32 Version;
|
||||
INSTALL_VGA_DRIVER InstallGenericVgaDriver;
|
||||
} INSTALL_VGA_DRIVER_INTERFACE;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
#ifndef _EFI_ROMLOAD_H
|
||||
#define _EFI_ROMLOAD_H
|
||||
|
||||
#define ROM_SIGNATURE 0xaa55
|
||||
#define PCIDS_SIGNATURE "PCIR"
|
||||
#pragma pack(push)
|
||||
#pragma pack(1)
|
||||
typedef struct
|
||||
{
|
||||
UINT8 Pcids_Sig[4];
|
||||
UINT16 VendId;
|
||||
UINT16 DevId;
|
||||
UINT16 Vpd_Off;
|
||||
UINT16 Size;
|
||||
UINT8 Rev;
|
||||
UINT8 Class_Code[3];
|
||||
UINT16 Image_Len;
|
||||
UINT16 Rev_Lvl;
|
||||
UINT8 Code_Type;
|
||||
UINT8 Indi;
|
||||
UINT16 Rsvd;
|
||||
}PciDataStructure;
|
||||
typedef struct
|
||||
{
|
||||
UINT16 Size;
|
||||
UINT32 Header_Sig;
|
||||
UINT16 SubSystem;
|
||||
UINT16 MachineType;
|
||||
UINT8 Resvd[10];
|
||||
UINT16 EfiOffset;
|
||||
}ArchData;
|
||||
typedef struct
|
||||
{
|
||||
UINT16 Rom_Sig;
|
||||
ArchData Arch_Data;
|
||||
UINT16 Pcids_Off;
|
||||
UINT8 resvd[38];
|
||||
}RomHeader;
|
||||
#pragma pack(pop)
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,84 @@
|
||||
/* Copyright (C) 2024 GNU-EFI Contributors
|
||||
|
||||
This library is free software;
|
||||
you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation;
|
||||
either version 2.1 of the License, or (at your option) any later version.
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
See the GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License along with this library;
|
||||
if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#if !defined(__GNU_EFI_NO_GLIBC)
|
||||
#include <elf.h>
|
||||
|
||||
#else
|
||||
|
||||
typedef uint32_t Elf32_Addr;
|
||||
typedef int32_t Elf32_Sword;
|
||||
typedef uint32_t Elf32_Word;
|
||||
|
||||
typedef uint64_t Elf64_Addr;
|
||||
typedef int64_t Elf64_Sxword;
|
||||
typedef uint64_t Elf64_Xword;
|
||||
|
||||
|
||||
typedef struct {
|
||||
Elf32_Addr r_offset;
|
||||
Elf32_Word r_info;
|
||||
} Elf32_Rel;
|
||||
|
||||
typedef struct {
|
||||
Elf64_Addr r_offset;
|
||||
Elf64_Xword r_info;
|
||||
Elf64_Sxword r_addend;
|
||||
} Elf64_Rela;
|
||||
|
||||
typedef struct {
|
||||
Elf32_Sword d_tag;
|
||||
union {
|
||||
Elf32_Word d_val;
|
||||
Elf32_Addr d_ptr;
|
||||
} d_un;
|
||||
} Elf32_Dyn;
|
||||
|
||||
typedef struct {
|
||||
Elf64_Sxword d_tag;
|
||||
union {
|
||||
Elf64_Xword d_val;
|
||||
Elf64_Addr d_ptr;
|
||||
} d_un;
|
||||
} Elf64_Dyn;
|
||||
|
||||
#define ELF32_R_TYPE(val) ((val) & 0xff)
|
||||
#define ELF64_R_TYPE(i) ((i) & 0xffffffff)
|
||||
|
||||
#define DT_NULL 0
|
||||
#define DT_REL 17
|
||||
#define DT_RELSZ 18
|
||||
#define DT_RELENT 19
|
||||
#define DT_RELA 7
|
||||
#define DT_RELASZ 8
|
||||
#define DT_RELAENT 9
|
||||
#define DT_PLTGOT 3
|
||||
|
||||
|
||||
#define R_AARCH64_NONE 0
|
||||
#define R_AARCH64_RELATIVE 1027
|
||||
#define R_RISCV_RELATIVE 3
|
||||
#define R_LARCH_NONE 0
|
||||
#define R_LARCH_RELATIVE 3
|
||||
#define R_X86_64_NONE 0
|
||||
#define R_X86_64_RELATIVE 8
|
||||
#define R_ARM_NONE 0
|
||||
#define R_ARM_RELATIVE 23
|
||||
#define R_386_NONE 0
|
||||
#define R_386_RELATIVE 8
|
||||
#define R_MIPS_NONE 0
|
||||
#define R_MIPS_64 18
|
||||
#define R_MIPS_REL32 3
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,396 @@
|
||||
/*++
|
||||
|
||||
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(_MSC_VER)
|
||||
#define HAVE_USE_MS_ABI 1
|
||||
#elif defined(GNU_EFI_USE_MS_ABI)
|
||||
#if (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)))||(defined(__clang__) && (__clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 2)))
|
||||
#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 )) && !defined(__cplusplus)
|
||||
|
||||
// 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
|
||||
typedef uint64_t uintptr_t;
|
||||
typedef int64_t intptr_t;
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
//
|
||||
// Basic EFI types of various widths
|
||||
//
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
typedef uint16_t CHAR16;
|
||||
#define WCHAR CHAR16
|
||||
|
||||
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 unsigned char CHAR8;
|
||||
typedef int8_t INT8;
|
||||
|
||||
#undef VOID
|
||||
typedef 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
|
||||
@@ -0,0 +1,26 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
efilibplat.h
|
||||
|
||||
Abstract:
|
||||
|
||||
EFI to compile bindings
|
||||
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
VOID
|
||||
InitializeLibPlatform (
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
);
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
#ifndef GNU_EFI_X86_64_SETJMP_H
|
||||
#define GNU_EFI_X86_64_SETJMP_H
|
||||
|
||||
#define JMPBUF_ALIGN 8
|
||||
|
||||
typedef struct {
|
||||
UINT64 Rbx;
|
||||
UINT64 Rsp;
|
||||
UINT64 Rbp;
|
||||
|
||||
UINT64 Rdi;
|
||||
UINT64 Rsi;
|
||||
UINT64 R12;
|
||||
UINT64 R13;
|
||||
UINT64 R14;
|
||||
UINT64 R15;
|
||||
UINT64 Rip;
|
||||
UINT64 MxCsr;
|
||||
UINT8 XmmBuffer[160]; // XMM6 - XMM15
|
||||
} EFI_ALIGN(JMPBUF_ALIGN) jmp_buf[1];
|
||||
|
||||
#endif /* GNU_EFI_X86_64_SETJMP_H */
|
||||
@@ -0,0 +1,595 @@
|
||||
/*
|
||||
PE32+ header file
|
||||
*/
|
||||
#ifndef _PE_H
|
||||
#define _PE_H
|
||||
|
||||
#define IMAGE_DOS_SIGNATURE 0x5A4D // MZ
|
||||
#define IMAGE_OS2_SIGNATURE 0x454E // NE
|
||||
#define IMAGE_OS2_SIGNATURE_LE 0x454C // LE
|
||||
#define IMAGE_NT_SIGNATURE 0x00004550 // PE00
|
||||
#define IMAGE_EDOS_SIGNATURE 0x44454550 // PEED
|
||||
|
||||
|
||||
typedef struct _IMAGE_DOS_HEADER { // DOS .EXE header
|
||||
UINT16 e_magic; // Magic number
|
||||
UINT16 e_cblp; // Bytes on last page of file
|
||||
UINT16 e_cp; // Pages in file
|
||||
UINT16 e_crlc; // Relocations
|
||||
UINT16 e_cparhdr; // Size of header in paragraphs
|
||||
UINT16 e_minalloc; // Minimum extra paragraphs needed
|
||||
UINT16 e_maxalloc; // Maximum extra paragraphs needed
|
||||
UINT16 e_ss; // Initial (relative) SS value
|
||||
UINT16 e_sp; // Initial SP value
|
||||
UINT16 e_csum; // Checksum
|
||||
UINT16 e_ip; // Initial IP value
|
||||
UINT16 e_cs; // Initial (relative) CS value
|
||||
UINT16 e_lfarlc; // File address of relocation table
|
||||
UINT16 e_ovno; // Overlay number
|
||||
UINT16 e_res[4]; // Reserved words
|
||||
UINT16 e_oemid; // OEM identifier (for e_oeminfo)
|
||||
UINT16 e_oeminfo; // OEM information; e_oemid specific
|
||||
UINT16 e_res2[10]; // Reserved words
|
||||
UINT32 e_lfanew; // File address of new exe header
|
||||
} IMAGE_DOS_HEADER, *PIMAGE_DOS_HEADER;
|
||||
|
||||
typedef struct _IMAGE_OS2_HEADER { // OS/2 .EXE header
|
||||
UINT16 ne_magic; // Magic number
|
||||
UINT8 ne_ver; // Version number
|
||||
UINT8 ne_rev; // Revision number
|
||||
UINT16 ne_enttab; // Offset of Entry Table
|
||||
UINT16 ne_cbenttab; // Number of bytes in Entry Table
|
||||
UINT32 ne_crc; // Checksum of whole file
|
||||
UINT16 ne_flags; // Flag UINT16
|
||||
UINT16 ne_autodata; // Automatic data segment number
|
||||
UINT16 ne_heap; // Initial heap allocation
|
||||
UINT16 ne_stack; // Initial stack allocation
|
||||
UINT32 ne_csip; // Initial CS:IP setting
|
||||
UINT32 ne_sssp; // Initial SS:SP setting
|
||||
UINT16 ne_cseg; // Count of file segments
|
||||
UINT16 ne_cmod; // Entries in Module Reference Table
|
||||
UINT16 ne_cbnrestab; // Size of non-resident name table
|
||||
UINT16 ne_segtab; // Offset of Segment Table
|
||||
UINT16 ne_rsrctab; // Offset of Resource Table
|
||||
UINT16 ne_restab; // Offset of resident name table
|
||||
UINT16 ne_modtab; // Offset of Module Reference Table
|
||||
UINT16 ne_imptab; // Offset of Imported Names Table
|
||||
UINT32 ne_nrestab; // Offset of Non-resident Names Table
|
||||
UINT16 ne_cmovent; // Count of movable entries
|
||||
UINT16 ne_align; // Segment alignment shift count
|
||||
UINT16 ne_cres; // Count of resource segments
|
||||
UINT8 ne_exetyp; // Target Operating system
|
||||
UINT8 ne_flagsothers; // Other .EXE flags
|
||||
UINT16 ne_pretthunks; // offset to return thunks
|
||||
UINT16 ne_psegrefbytes; // offset to segment ref. bytes
|
||||
UINT16 ne_swaparea; // Minimum code swap area size
|
||||
UINT16 ne_expver; // Expected Windows version number
|
||||
} IMAGE_OS2_HEADER, *PIMAGE_OS2_HEADER;
|
||||
|
||||
//
|
||||
// File header format.
|
||||
//
|
||||
|
||||
typedef struct _IMAGE_FILE_HEADER {
|
||||
UINT16 Machine;
|
||||
UINT16 NumberOfSections;
|
||||
UINT32 TimeDateStamp;
|
||||
UINT32 PointerToSymbolTable;
|
||||
UINT32 NumberOfSymbols;
|
||||
UINT16 SizeOfOptionalHeader;
|
||||
UINT16 Characteristics;
|
||||
} IMAGE_FILE_HEADER, *PIMAGE_FILE_HEADER;
|
||||
|
||||
#define IMAGE_SIZEOF_FILE_HEADER 20
|
||||
|
||||
#define IMAGE_FILE_RELOCS_STRIPPED 0x0001 // Relocation info stripped from file.
|
||||
#define IMAGE_FILE_EXECUTABLE_IMAGE 0x0002 // File is executable (i.e. no unresolved externel references).
|
||||
#define IMAGE_FILE_LINE_NUMS_STRIPPED 0x0004 // Line nunbers stripped from file.
|
||||
#define IMAGE_FILE_LOCAL_SYMS_STRIPPED 0x0008 // Local symbols stripped from file.
|
||||
#define IMAGE_FILE_BYTES_REVERSED_LO 0x0080 // Bytes of machine word are reversed.
|
||||
#define IMAGE_FILE_32BIT_MACHINE 0x0100 // 32 bit word machine.
|
||||
#define IMAGE_FILE_DEBUG_STRIPPED 0x0200 // Debugging info stripped from file in .DBG file
|
||||
#define IMAGE_FILE_SYSTEM 0x1000 // System File.
|
||||
#define IMAGE_FILE_DLL 0x2000 // File is a DLL.
|
||||
#define IMAGE_FILE_BYTES_REVERSED_HI 0x8000 // Bytes of machine word are reversed.
|
||||
|
||||
#define IMAGE_FILE_MACHINE_UNKNOWN 0
|
||||
#define IMAGE_FILE_MACHINE_I386 0x14c // Intel 386.
|
||||
#define IMAGE_FILE_MACHINE_R3000 0x162 // MIPS little-endian, 0540 big-endian
|
||||
#define IMAGE_FILE_MACHINE_R4000 0x166 // MIPS little-endian
|
||||
#define IMAGE_FILE_MACHINE_ALPHA 0x184 // Alpha_AXP
|
||||
#define IMAGE_FILE_MACHINE_ARMTHUMB_MIXED 0x1c2 // Arm/Thumb
|
||||
#define IMAGE_FILE_MACHINE_POWERPC 0x1F0 // IBM PowerPC Little-Endian
|
||||
#define IMAGE_FILE_MACHINE_IA64 0x200 // IA-64
|
||||
#define IMAGE_FILE_MACHINE_TAHOE 0x7cc // Intel EM machine
|
||||
#define IMAGE_FILE_MACHINE_EBC 0xebc // EFI Byte Code
|
||||
#define IMAGE_FILE_MACHINE_X64 0x8664 // x86_64
|
||||
//
|
||||
// Directory format.
|
||||
//
|
||||
|
||||
typedef struct _IMAGE_DATA_DIRECTORY {
|
||||
UINT32 VirtualAddress;
|
||||
UINT32 Size;
|
||||
} IMAGE_DATA_DIRECTORY, *PIMAGE_DATA_DIRECTORY;
|
||||
|
||||
#define IMAGE_NUMBEROF_DIRECTORY_ENTRIES 16
|
||||
|
||||
//
|
||||
// Optional header format.
|
||||
//
|
||||
|
||||
typedef struct _IMAGE_OPTIONAL_HEADER {
|
||||
//
|
||||
// Standard fields.
|
||||
//
|
||||
|
||||
UINT16 Magic;
|
||||
UINT8 MajorLinkerVersion;
|
||||
UINT8 MinorLinkerVersion;
|
||||
UINT32 SizeOfCode;
|
||||
UINT32 SizeOfInitializedData;
|
||||
UINT32 SizeOfUninitializedData;
|
||||
UINT32 AddressOfEntryPoint;
|
||||
UINT32 BaseOfCode;
|
||||
UINT32 BaseOfData;
|
||||
|
||||
//
|
||||
// NT additional fields.
|
||||
//
|
||||
|
||||
UINT32 ImageBase;
|
||||
UINT32 SectionAlignment;
|
||||
UINT32 FileAlignment;
|
||||
UINT16 MajorOperatingSystemVersion;
|
||||
UINT16 MinorOperatingSystemVersion;
|
||||
UINT16 MajorImageVersion;
|
||||
UINT16 MinorImageVersion;
|
||||
UINT16 MajorSubsystemVersion;
|
||||
UINT16 MinorSubsystemVersion;
|
||||
UINT32 Reserved1;
|
||||
UINT32 SizeOfImage;
|
||||
UINT32 SizeOfHeaders;
|
||||
UINT32 CheckSum;
|
||||
UINT16 Subsystem;
|
||||
UINT16 DllCharacteristics;
|
||||
UINT32 SizeOfStackReserve;
|
||||
UINT32 SizeOfStackCommit;
|
||||
UINT32 SizeOfHeapReserve;
|
||||
UINT32 SizeOfHeapCommit;
|
||||
UINT32 LoaderFlags;
|
||||
UINT32 NumberOfRvaAndSizes;
|
||||
IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES];
|
||||
} IMAGE_OPTIONAL_HEADER, *PIMAGE_OPTIONAL_HEADER;
|
||||
|
||||
typedef struct _IMAGE_ROM_OPTIONAL_HEADER {
|
||||
UINT16 Magic;
|
||||
UINT8 MajorLinkerVersion;
|
||||
UINT8 MinorLinkerVersion;
|
||||
UINT32 SizeOfCode;
|
||||
UINT32 SizeOfInitializedData;
|
||||
UINT32 SizeOfUninitializedData;
|
||||
UINT32 AddressOfEntryPoint;
|
||||
UINT32 BaseOfCode;
|
||||
UINT32 BaseOfData;
|
||||
UINT32 BaseOfBss;
|
||||
UINT32 GprMask;
|
||||
UINT32 CprMask[4];
|
||||
UINT32 GpValue;
|
||||
} IMAGE_ROM_OPTIONAL_HEADER, *PIMAGE_ROM_OPTIONAL_HEADER;
|
||||
|
||||
#define IMAGE_SIZEOF_ROM_OPTIONAL_HEADER 56
|
||||
#define IMAGE_SIZEOF_STD_OPTIONAL_HEADER 28
|
||||
#define IMAGE_SIZEOF_NT_OPTIONAL_HEADER 224
|
||||
|
||||
#define IMAGE_NT_OPTIONAL_HDR_MAGIC 0x10b
|
||||
#define IMAGE_ROM_OPTIONAL_HDR_MAGIC 0x107
|
||||
|
||||
typedef struct _IMAGE_NT_HEADERS {
|
||||
UINT32 Signature;
|
||||
IMAGE_FILE_HEADER FileHeader;
|
||||
IMAGE_OPTIONAL_HEADER OptionalHeader;
|
||||
} IMAGE_NT_HEADERS, *PIMAGE_NT_HEADERS;
|
||||
|
||||
typedef struct _IMAGE_ROM_HEADERS {
|
||||
IMAGE_FILE_HEADER FileHeader;
|
||||
IMAGE_ROM_OPTIONAL_HEADER OptionalHeader;
|
||||
} IMAGE_ROM_HEADERS, *PIMAGE_ROM_HEADERS;
|
||||
|
||||
#define IMAGE_FIRST_SECTION( ntheader ) ((PIMAGE_SECTION_HEADER) \
|
||||
((UINT32)ntheader + \
|
||||
FIELD_OFFSET( IMAGE_NT_HEADERS, OptionalHeader ) + \
|
||||
((PIMAGE_NT_HEADERS)(ntheader))->FileHeader.SizeOfOptionalHeader \
|
||||
))
|
||||
|
||||
|
||||
// Subsystem Values
|
||||
|
||||
#define IMAGE_SUBSYSTEM_UNKNOWN 0 // Unknown subsystem.
|
||||
#define IMAGE_SUBSYSTEM_NATIVE 1 // Image doesn't require a subsystem.
|
||||
#define IMAGE_SUBSYSTEM_WINDOWS_GUI 2 // Image runs in the Windows GUI subsystem.
|
||||
#define IMAGE_SUBSYSTEM_WINDOWS_CUI 3 // Image runs in the Windows character subsystem.
|
||||
#define IMAGE_SUBSYSTEM_OS2_CUI 5 // image runs in the OS/2 character subsystem.
|
||||
#define IMAGE_SUBSYSTEM_POSIX_CUI 7 // image run in the Posix character subsystem.
|
||||
|
||||
|
||||
// Directory Entries
|
||||
|
||||
#define IMAGE_DIRECTORY_ENTRY_EXPORT 0 // Export Directory
|
||||
#define IMAGE_DIRECTORY_ENTRY_IMPORT 1 // Import Directory
|
||||
#define IMAGE_DIRECTORY_ENTRY_RESOURCE 2 // Resource Directory
|
||||
#define IMAGE_DIRECTORY_ENTRY_EXCEPTION 3 // Exception Directory
|
||||
#define IMAGE_DIRECTORY_ENTRY_SECURITY 4 // Security Directory
|
||||
#define IMAGE_DIRECTORY_ENTRY_BASERELOC 5 // Base Relocation Table
|
||||
#define IMAGE_DIRECTORY_ENTRY_DEBUG 6 // Debug Directory
|
||||
#define IMAGE_DIRECTORY_ENTRY_COPYRIGHT 7 // Description String
|
||||
#define IMAGE_DIRECTORY_ENTRY_GLOBALPTR 8 // Machine Value (MIPS GP)
|
||||
#define IMAGE_DIRECTORY_ENTRY_TLS 9 // TLS Directory
|
||||
#define IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG 10 // Load Configuration Directory
|
||||
|
||||
//
|
||||
// Section header format.
|
||||
//
|
||||
|
||||
#define IMAGE_SIZEOF_SHORT_NAME 8
|
||||
|
||||
typedef struct _IMAGE_SECTION_HEADER {
|
||||
UINT8 Name[IMAGE_SIZEOF_SHORT_NAME];
|
||||
union {
|
||||
UINT32 PhysicalAddress;
|
||||
UINT32 VirtualSize;
|
||||
} Misc;
|
||||
UINT32 VirtualAddress;
|
||||
UINT32 SizeOfRawData;
|
||||
UINT32 PointerToRawData;
|
||||
UINT32 PointerToRelocations;
|
||||
UINT32 PointerToLinenumbers;
|
||||
UINT16 NumberOfRelocations;
|
||||
UINT16 NumberOfLinenumbers;
|
||||
UINT32 Characteristics;
|
||||
} IMAGE_SECTION_HEADER, *PIMAGE_SECTION_HEADER;
|
||||
|
||||
#define IMAGE_SIZEOF_SECTION_HEADER 40
|
||||
|
||||
#define IMAGE_SCN_TYPE_NO_PAD 0x00000008 // Reserved.
|
||||
|
||||
#define IMAGE_SCN_CNT_CODE 0x00000020 // Section contains code.
|
||||
#define IMAGE_SCN_CNT_INITIALIZED_DATA 0x00000040 // Section contains initialized data.
|
||||
#define IMAGE_SCN_CNT_UNINITIALIZED_DATA 0x00000080 // Section contains uninitialized data.
|
||||
|
||||
#define IMAGE_SCN_LNK_OTHER 0x00000100 // Reserved.
|
||||
#define IMAGE_SCN_LNK_INFO 0x00000200 // Section contains comments or some other type of information.
|
||||
#define IMAGE_SCN_LNK_REMOVE 0x00000800 // Section contents will not become part of image.
|
||||
#define IMAGE_SCN_LNK_COMDAT 0x00001000 // Section contents comdat.
|
||||
|
||||
#define IMAGE_SCN_ALIGN_1BYTES 0x00100000 //
|
||||
#define IMAGE_SCN_ALIGN_2BYTES 0x00200000 //
|
||||
#define IMAGE_SCN_ALIGN_4BYTES 0x00300000 //
|
||||
#define IMAGE_SCN_ALIGN_8BYTES 0x00400000 //
|
||||
#define IMAGE_SCN_ALIGN_16BYTES 0x00500000 // Default alignment if no others are specified.
|
||||
#define IMAGE_SCN_ALIGN_32BYTES 0x00600000 //
|
||||
#define IMAGE_SCN_ALIGN_64BYTES 0x00700000 //
|
||||
|
||||
#define IMAGE_SCN_MEM_DISCARDABLE 0x02000000 // Section can be discarded.
|
||||
#define IMAGE_SCN_MEM_NOT_CACHED 0x04000000 // Section is not cachable.
|
||||
#define IMAGE_SCN_MEM_NOT_PAGED 0x08000000 // Section is not pageable.
|
||||
#define IMAGE_SCN_MEM_SHARED 0x10000000 // Section is shareable.
|
||||
#define IMAGE_SCN_MEM_EXECUTE 0x20000000 // Section is executable.
|
||||
#define IMAGE_SCN_MEM_READ 0x40000000 // Section is readable.
|
||||
#define IMAGE_SCN_MEM_WRITE 0x80000000 // Section is writeable.
|
||||
|
||||
//
|
||||
// Symbol format.
|
||||
//
|
||||
|
||||
|
||||
#define IMAGE_SIZEOF_SYMBOL 18
|
||||
|
||||
//
|
||||
// Section values.
|
||||
//
|
||||
// Symbols have a section number of the section in which they are
|
||||
// defined. Otherwise, section numbers have the following meanings:
|
||||
//
|
||||
|
||||
#define IMAGE_SYM_UNDEFINED (UINT16)0 // Symbol is undefined or is common.
|
||||
#define IMAGE_SYM_ABSOLUTE (UINT16)-1 // Symbol is an absolute value.
|
||||
#define IMAGE_SYM_DEBUG (UINT16)-2 // Symbol is a special debug item.
|
||||
|
||||
//
|
||||
// Type (fundamental) values.
|
||||
//
|
||||
|
||||
#define IMAGE_SYM_TYPE_NULL 0 // no type.
|
||||
#define IMAGE_SYM_TYPE_VOID 1 //
|
||||
#define IMAGE_SYM_TYPE_CHAR 2 // type character.
|
||||
#define IMAGE_SYM_TYPE_SHORT 3 // type short integer.
|
||||
#define IMAGE_SYM_TYPE_INT 4 //
|
||||
#define IMAGE_SYM_TYPE_LONG 5 //
|
||||
#define IMAGE_SYM_TYPE_FLOAT 6 //
|
||||
#define IMAGE_SYM_TYPE_DOUBLE 7 //
|
||||
#define IMAGE_SYM_TYPE_STRUCT 8 //
|
||||
#define IMAGE_SYM_TYPE_UNION 9 //
|
||||
#define IMAGE_SYM_TYPE_ENUM 10 // enumeration.
|
||||
#define IMAGE_SYM_TYPE_MOE 11 // member of enumeration.
|
||||
#define IMAGE_SYM_TYPE_BYTE 12 //
|
||||
#define IMAGE_SYM_TYPE_WORD 13 //
|
||||
#define IMAGE_SYM_TYPE_UINT 14 //
|
||||
#define IMAGE_SYM_TYPE_DWORD 15 //
|
||||
|
||||
//
|
||||
// Type (derived) values.
|
||||
//
|
||||
|
||||
#define IMAGE_SYM_DTYPE_NULL 0 // no derived type.
|
||||
#define IMAGE_SYM_DTYPE_POINTER 1 // pointer.
|
||||
#define IMAGE_SYM_DTYPE_FUNCTION 2 // function.
|
||||
#define IMAGE_SYM_DTYPE_ARRAY 3 // array.
|
||||
|
||||
//
|
||||
// Storage classes.
|
||||
//
|
||||
|
||||
#define IMAGE_SYM_CLASS_END_OF_FUNCTION (BYTE )-1
|
||||
#define IMAGE_SYM_CLASS_NULL 0
|
||||
#define IMAGE_SYM_CLASS_AUTOMATIC 1
|
||||
#define IMAGE_SYM_CLASS_EXTERNAL 2
|
||||
#define IMAGE_SYM_CLASS_STATIC 3
|
||||
#define IMAGE_SYM_CLASS_REGISTER 4
|
||||
#define IMAGE_SYM_CLASS_EXTERNAL_DEF 5
|
||||
#define IMAGE_SYM_CLASS_LABEL 6
|
||||
#define IMAGE_SYM_CLASS_UNDEFINED_LABEL 7
|
||||
#define IMAGE_SYM_CLASS_MEMBER_OF_STRUCT 8
|
||||
#define IMAGE_SYM_CLASS_ARGUMENT 9
|
||||
#define IMAGE_SYM_CLASS_STRUCT_TAG 10
|
||||
#define IMAGE_SYM_CLASS_MEMBER_OF_UNION 11
|
||||
#define IMAGE_SYM_CLASS_UNION_TAG 12
|
||||
#define IMAGE_SYM_CLASS_TYPE_DEFINITION 13
|
||||
#define IMAGE_SYM_CLASS_UNDEFINED_STATIC 14
|
||||
#define IMAGE_SYM_CLASS_ENUM_TAG 15
|
||||
#define IMAGE_SYM_CLASS_MEMBER_OF_ENUM 16
|
||||
#define IMAGE_SYM_CLASS_REGISTER_PARAM 17
|
||||
#define IMAGE_SYM_CLASS_BIT_FIELD 18
|
||||
#define IMAGE_SYM_CLASS_BLOCK 100
|
||||
#define IMAGE_SYM_CLASS_FUNCTION 101
|
||||
#define IMAGE_SYM_CLASS_END_OF_STRUCT 102
|
||||
#define IMAGE_SYM_CLASS_FILE 103
|
||||
// new
|
||||
#define IMAGE_SYM_CLASS_SECTION 104
|
||||
#define IMAGE_SYM_CLASS_WEAK_EXTERNAL 105
|
||||
|
||||
// type packing constants
|
||||
|
||||
#define N_BTMASK 017
|
||||
#define N_TMASK 060
|
||||
#define N_TMASK1 0300
|
||||
#define N_TMASK2 0360
|
||||
#define N_BTSHFT 4
|
||||
#define N_TSHIFT 2
|
||||
|
||||
// MACROS
|
||||
|
||||
//
|
||||
// Communal selection types.
|
||||
//
|
||||
|
||||
#define IMAGE_COMDAT_SELECT_NODUPLICATES 1
|
||||
#define IMAGE_COMDAT_SELECT_ANY 2
|
||||
#define IMAGE_COMDAT_SELECT_SAME_SIZE 3
|
||||
#define IMAGE_COMDAT_SELECT_EXACT_MATCH 4
|
||||
#define IMAGE_COMDAT_SELECT_ASSOCIATIVE 5
|
||||
|
||||
#define IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY 1
|
||||
#define IMAGE_WEAK_EXTERN_SEARCH_LIBRARY 2
|
||||
#define IMAGE_WEAK_EXTERN_SEARCH_ALIAS 3
|
||||
|
||||
|
||||
//
|
||||
// Relocation format.
|
||||
//
|
||||
|
||||
typedef struct _IMAGE_RELOCATION {
|
||||
UINT32 VirtualAddress;
|
||||
UINT32 SymbolTableIndex;
|
||||
UINT16 Type;
|
||||
} IMAGE_RELOCATION;
|
||||
|
||||
#define IMAGE_SIZEOF_RELOCATION 10
|
||||
|
||||
//
|
||||
// I386 relocation types.
|
||||
//
|
||||
|
||||
#define IMAGE_REL_I386_ABSOLUTE 0 // Reference is absolute, no relocation is necessary
|
||||
#define IMAGE_REL_I386_DIR16 01 // Direct 16-bit reference to the symbols virtual address
|
||||
#define IMAGE_REL_I386_REL16 02 // PC-relative 16-bit reference to the symbols virtual address
|
||||
#define IMAGE_REL_I386_DIR32 06 // Direct 32-bit reference to the symbols virtual address
|
||||
#define IMAGE_REL_I386_DIR32NB 07 // Direct 32-bit reference to the symbols virtual address, base not included
|
||||
#define IMAGE_REL_I386_SEG12 011 // Direct 16-bit reference to the segment-selector bits of a 32-bit virtual address
|
||||
#define IMAGE_REL_I386_SECTION 012
|
||||
#define IMAGE_REL_I386_SECREL 013
|
||||
#define IMAGE_REL_I386_REL32 024 // PC-relative 32-bit reference to the symbols virtual address
|
||||
|
||||
//
|
||||
// MIPS relocation types.
|
||||
//
|
||||
|
||||
#define IMAGE_REL_MIPS_ABSOLUTE 0 // Reference is absolute, no relocation is necessary
|
||||
#define IMAGE_REL_MIPS_REFHALF 01
|
||||
#define IMAGE_REL_MIPS_REFWORD 02
|
||||
#define IMAGE_REL_MIPS_JMPADDR 03
|
||||
#define IMAGE_REL_MIPS_REFHI 04
|
||||
#define IMAGE_REL_MIPS_REFLO 05
|
||||
#define IMAGE_REL_MIPS_GPREL 06
|
||||
#define IMAGE_REL_MIPS_LITERAL 07
|
||||
#define IMAGE_REL_MIPS_SECTION 012
|
||||
#define IMAGE_REL_MIPS_SECREL 013
|
||||
#define IMAGE_REL_MIPS_REFWORDNB 042
|
||||
#define IMAGE_REL_MIPS_PAIR 045
|
||||
|
||||
//
|
||||
// Alpha Relocation types.
|
||||
//
|
||||
|
||||
#define IMAGE_REL_ALPHA_ABSOLUTE 0x0
|
||||
#define IMAGE_REL_ALPHA_REFLONG 0x1
|
||||
#define IMAGE_REL_ALPHA_REFQUAD 0x2
|
||||
#define IMAGE_REL_ALPHA_GPREL32 0x3
|
||||
#define IMAGE_REL_ALPHA_LITERAL 0x4
|
||||
#define IMAGE_REL_ALPHA_LITUSE 0x5
|
||||
#define IMAGE_REL_ALPHA_GPDISP 0x6
|
||||
#define IMAGE_REL_ALPHA_BRADDR 0x7
|
||||
#define IMAGE_REL_ALPHA_HINT 0x8
|
||||
#define IMAGE_REL_ALPHA_INLINE_REFLONG 0x9
|
||||
#define IMAGE_REL_ALPHA_REFHI 0xA
|
||||
#define IMAGE_REL_ALPHA_REFLO 0xB
|
||||
#define IMAGE_REL_ALPHA_PAIR 0xC
|
||||
#define IMAGE_REL_ALPHA_MATCH 0xD
|
||||
#define IMAGE_REL_ALPHA_SECTION 0xE
|
||||
#define IMAGE_REL_ALPHA_SECREL 0xF
|
||||
#define IMAGE_REL_ALPHA_REFLONGNB 0x10
|
||||
|
||||
//
|
||||
// IBM PowerPC relocation types.
|
||||
//
|
||||
|
||||
#define IMAGE_REL_PPC_ABSOLUTE 0x0000 // NOP
|
||||
#define IMAGE_REL_PPC_ADDR64 0x0001 // 64-bit address
|
||||
#define IMAGE_REL_PPC_ADDR32 0x0002 // 32-bit address
|
||||
#define IMAGE_REL_PPC_ADDR24 0x0003 // 26-bit address, shifted left 2 (branch absolute)
|
||||
#define IMAGE_REL_PPC_ADDR16 0x0004 // 16-bit address
|
||||
#define IMAGE_REL_PPC_ADDR14 0x0005 // 16-bit address, shifted left 2 (load doubleword)
|
||||
#define IMAGE_REL_PPC_REL24 0x0006 // 26-bit PC-relative offset, shifted left 2 (branch relative)
|
||||
#define IMAGE_REL_PPC_REL14 0x0007 // 16-bit PC-relative offset, shifted left 2 (br cond relative)
|
||||
#define IMAGE_REL_PPC_TOCREL16 0x0008 // 16-bit offset from TOC base
|
||||
#define IMAGE_REL_PPC_TOCREL14 0x0009 // 16-bit offset from TOC base, shifted left 2 (load doubleword)
|
||||
|
||||
#define IMAGE_REL_PPC_ADDR32NB 0x000A // 32-bit addr w/o image base
|
||||
#define IMAGE_REL_PPC_SECREL 0x000B // va of containing section (as in an image sectionhdr)
|
||||
#define IMAGE_REL_PPC_SECTION 0x000C // sectionheader number
|
||||
#define IMAGE_REL_PPC_IFGLUE 0x000D // substitute TOC restore instruction iff symbol is glue code
|
||||
#define IMAGE_REL_PPC_IMGLUE 0x000E // symbol is glue code; virtual address is TOC restore instruction
|
||||
|
||||
#define IMAGE_REL_PPC_TYPEMASK 0x00FF // mask to isolate above values in IMAGE_RELOCATION.Type
|
||||
|
||||
// Flag bits in IMAGE_RELOCATION.TYPE
|
||||
|
||||
#define IMAGE_REL_PPC_NEG 0x0100 // subtract reloc value rather than adding it
|
||||
#define IMAGE_REL_PPC_BRTAKEN 0x0200 // fix branch prediction bit to predict branch taken
|
||||
#define IMAGE_REL_PPC_BRNTAKEN 0x0400 // fix branch prediction bit to predict branch not taken
|
||||
#define IMAGE_REL_PPC_TOCDEFN 0x0800 // toc slot defined in file (or, data in toc)
|
||||
|
||||
//
|
||||
// Based relocation format.
|
||||
//
|
||||
|
||||
typedef struct _IMAGE_BASE_RELOCATION {
|
||||
UINT32 VirtualAddress;
|
||||
UINT32 SizeOfBlock;
|
||||
// UINT16 TypeOffset[1];
|
||||
} IMAGE_BASE_RELOCATION, *PIMAGE_BASE_RELOCATION;
|
||||
|
||||
#define IMAGE_SIZEOF_BASE_RELOCATION 8
|
||||
|
||||
//
|
||||
// Based relocation types.
|
||||
//
|
||||
|
||||
#define IMAGE_REL_BASED_ABSOLUTE 0
|
||||
#define IMAGE_REL_BASED_HIGH 1
|
||||
#define IMAGE_REL_BASED_LOW 2
|
||||
#define IMAGE_REL_BASED_HIGHLOW 3
|
||||
#define IMAGE_REL_BASED_HIGHADJ 4
|
||||
#define IMAGE_REL_BASED_MIPS_JMPADDR 5
|
||||
#define IMAGE_REL_BASED_IA64_IMM64 9
|
||||
#define IMAGE_REL_BASED_DIR64 10
|
||||
|
||||
//
|
||||
// Line number format.
|
||||
//
|
||||
|
||||
typedef struct _IMAGE_LINENUMBER {
|
||||
union {
|
||||
UINT32 SymbolTableIndex; // Symbol table index of function name if Linenumber is 0.
|
||||
UINT32 VirtualAddress; // Virtual address of line number.
|
||||
} Type;
|
||||
UINT16 Linenumber; // Line number.
|
||||
} IMAGE_LINENUMBER;
|
||||
|
||||
#define IMAGE_SIZEOF_LINENUMBER 6
|
||||
|
||||
//
|
||||
// Archive format.
|
||||
//
|
||||
|
||||
#define IMAGE_ARCHIVE_START_SIZE 8
|
||||
#define IMAGE_ARCHIVE_START "!<arch>\n"
|
||||
#define IMAGE_ARCHIVE_END "`\n"
|
||||
#define IMAGE_ARCHIVE_PAD "\n"
|
||||
#define IMAGE_ARCHIVE_LINKER_MEMBER "/ "
|
||||
#define IMAGE_ARCHIVE_LONGNAMES_MEMBER "// "
|
||||
|
||||
typedef struct _IMAGE_ARCHIVE_MEMBER_HEADER {
|
||||
UINT8 Name[16]; // File member name - `/' terminated.
|
||||
UINT8 Date[12]; // File member date - decimal.
|
||||
UINT8 UserID[6]; // File member user id - decimal.
|
||||
UINT8 GroupID[6]; // File member group id - decimal.
|
||||
UINT8 Mode[8]; // File member mode - octal.
|
||||
UINT8 Size[10]; // File member size - decimal.
|
||||
UINT8 EndHeader[2]; // String to end header.
|
||||
} IMAGE_ARCHIVE_MEMBER_HEADER, *PIMAGE_ARCHIVE_MEMBER_HEADER;
|
||||
|
||||
#define IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR 60
|
||||
|
||||
//
|
||||
// DLL support.
|
||||
//
|
||||
|
||||
//
|
||||
// Export Format
|
||||
//
|
||||
|
||||
typedef struct _IMAGE_EXPORT_DIRECTORY {
|
||||
UINT32 Characteristics;
|
||||
UINT32 TimeDateStamp;
|
||||
UINT16 MajorVersion;
|
||||
UINT16 MinorVersion;
|
||||
UINT32 Name;
|
||||
UINT32 Base;
|
||||
UINT32 NumberOfFunctions;
|
||||
UINT32 NumberOfNames;
|
||||
UINT32 *AddressOfFunctions;
|
||||
UINT32 *AddressOfNames;
|
||||
UINT32 *AddressOfNameOrdinals;
|
||||
} IMAGE_EXPORT_DIRECTORY, *PIMAGE_EXPORT_DIRECTORY;
|
||||
|
||||
//
|
||||
// Import Format
|
||||
//
|
||||
|
||||
typedef struct _IMAGE_IMPORT_BY_NAME {
|
||||
UINT16 Hint;
|
||||
UINT8 Name[1];
|
||||
} IMAGE_IMPORT_BY_NAME, *PIMAGE_IMPORT_BY_NAME;
|
||||
|
||||
typedef struct _IMAGE_THUNK_DATA {
|
||||
union {
|
||||
UINT32 Function;
|
||||
UINT32 Ordinal;
|
||||
PIMAGE_IMPORT_BY_NAME AddressOfData;
|
||||
} u1;
|
||||
} IMAGE_THUNK_DATA, *PIMAGE_THUNK_DATA;
|
||||
|
||||
#define IMAGE_ORDINAL_FLAG 0x80000000
|
||||
#define IMAGE_SNAP_BY_ORDINAL(Ordinal) ((Ordinal & IMAGE_ORDINAL_FLAG) != 0)
|
||||
#define IMAGE_ORDINAL(Ordinal) (Ordinal & 0xffff)
|
||||
|
||||
typedef struct _IMAGE_IMPORT_DESCRIPTOR {
|
||||
UINT32 Characteristics;
|
||||
UINT32 TimeDateStamp;
|
||||
UINT32 ForwarderChain;
|
||||
UINT32 Name;
|
||||
PIMAGE_THUNK_DATA FirstThunk;
|
||||
} IMAGE_IMPORT_DESCRIPTOR, *PIMAGE_IMPORT_DESCRIPTOR;
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,173 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
BoxDraw.c
|
||||
|
||||
Abstract:
|
||||
Lib functions to support Box Draw Unicode code pages.
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
#include "lib.h"
|
||||
|
||||
typedef struct {
|
||||
CHAR16 Unicode;
|
||||
CHAR8 PcAnsi;
|
||||
CHAR8 Ascii;
|
||||
} UNICODE_TO_CHAR;
|
||||
|
||||
|
||||
//
|
||||
// This list is used to define the valid extend chars.
|
||||
// It also provides a mapping from Unicode to PCANSI or
|
||||
// ASCII. The ASCII mapping we just made up.
|
||||
//
|
||||
//
|
||||
|
||||
STATIC UNICODE_TO_CHAR UnicodeToPcAnsiOrAscii[] = {
|
||||
{ BOXDRAW_HORIZONTAL, 0xc4, u'-'},
|
||||
{ BOXDRAW_VERTICAL, 0xb3, u'|'},
|
||||
{ BOXDRAW_DOWN_RIGHT, 0xda, u'/'},
|
||||
{ BOXDRAW_DOWN_LEFT, 0xbf, u'\\'},
|
||||
{ BOXDRAW_UP_RIGHT, 0xc0, u'\\'},
|
||||
{ BOXDRAW_UP_LEFT, 0xd9, u'/'},
|
||||
{ BOXDRAW_VERTICAL_RIGHT, 0xc3, u'|'},
|
||||
{ BOXDRAW_VERTICAL_LEFT, 0xb4, u'|'},
|
||||
{ BOXDRAW_DOWN_HORIZONTAL, 0xc2, u'+'},
|
||||
{ BOXDRAW_UP_HORIZONTAL, 0xc1, u'+'},
|
||||
{ BOXDRAW_VERTICAL_HORIZONTAL, 0xc5, u'+'},
|
||||
{ BOXDRAW_DOUBLE_HORIZONTAL, 0xcd, u'-'},
|
||||
{ BOXDRAW_DOUBLE_VERTICAL, 0xba, u'|'},
|
||||
{ BOXDRAW_DOWN_RIGHT_DOUBLE, 0xd5, u'/'},
|
||||
{ BOXDRAW_DOWN_DOUBLE_RIGHT, 0xd6, u'/'},
|
||||
{ BOXDRAW_DOUBLE_DOWN_RIGHT, 0xc9, u'/'},
|
||||
{ BOXDRAW_DOWN_LEFT_DOUBLE, 0xb8, u'\\'},
|
||||
{ BOXDRAW_DOWN_DOUBLE_LEFT, 0xb7, u'\\'},
|
||||
{ BOXDRAW_DOUBLE_DOWN_LEFT, 0xbb, u'\\'},
|
||||
{ BOXDRAW_UP_RIGHT_DOUBLE, 0xd4, u'\\'},
|
||||
{ BOXDRAW_UP_DOUBLE_RIGHT, 0xd3, u'\\'},
|
||||
{ BOXDRAW_DOUBLE_UP_RIGHT, 0xc8, u'\\'},
|
||||
{ BOXDRAW_UP_LEFT_DOUBLE, 0xbe, u'/'},
|
||||
{ BOXDRAW_UP_DOUBLE_LEFT, 0xbd, u'/'},
|
||||
{ BOXDRAW_DOUBLE_UP_LEFT, 0xbc, u'/'},
|
||||
{ BOXDRAW_VERTICAL_RIGHT_DOUBLE, 0xc6, u'|'},
|
||||
{ BOXDRAW_VERTICAL_DOUBLE_RIGHT, 0xc7, u'|'},
|
||||
{ BOXDRAW_DOUBLE_VERTICAL_RIGHT, 0xcc, u'|'},
|
||||
{ BOXDRAW_VERTICAL_LEFT_DOUBLE, 0xb5, u'|'},
|
||||
{ BOXDRAW_VERTICAL_DOUBLE_LEFT, 0xb6, u'|'},
|
||||
{ BOXDRAW_DOUBLE_VERTICAL_LEFT, 0xb9, u'|'},
|
||||
{ BOXDRAW_DOWN_HORIZONTAL_DOUBLE, 0xd1, u'+'},
|
||||
{ BOXDRAW_DOWN_DOUBLE_HORIZONTAL, 0xd2, u'+'},
|
||||
{ BOXDRAW_DOUBLE_DOWN_HORIZONTAL, 0xcb, u'+'},
|
||||
{ BOXDRAW_UP_HORIZONTAL_DOUBLE, 0xcf, u'+'},
|
||||
{ BOXDRAW_UP_DOUBLE_HORIZONTAL, 0xd0, u'+'},
|
||||
{ BOXDRAW_DOUBLE_UP_HORIZONTAL, 0xca, u'+'},
|
||||
{ BOXDRAW_VERTICAL_HORIZONTAL_DOUBLE, 0xd8, u'+'},
|
||||
{ BOXDRAW_VERTICAL_DOUBLE_HORIZONTAL, 0xd7, u'+'},
|
||||
{ BOXDRAW_DOUBLE_VERTICAL_HORIZONTAL, 0xce, u'+'},
|
||||
|
||||
{ BLOCKELEMENT_FULL_BLOCK, 0xdb, u'*'},
|
||||
{ BLOCKELEMENT_LIGHT_SHADE, 0xb0, u'+'},
|
||||
|
||||
{ GEOMETRICSHAPE_UP_TRIANGLE, 0x1e, u'^'},
|
||||
{ GEOMETRICSHAPE_RIGHT_TRIANGLE, 0x10, u'>'},
|
||||
{ GEOMETRICSHAPE_DOWN_TRIANGLE, 0x1f, u'v'},
|
||||
{ GEOMETRICSHAPE_LEFT_TRIANGLE, 0x11, u'<'},
|
||||
|
||||
/* BugBug: Left Arrow is an ESC. We can not make it print
|
||||
on a PCANSI terminal. If we can make left arrow
|
||||
come out on PC ANSI we can add it back.
|
||||
|
||||
{ ARROW_LEFT, 0x1b, u'<'},
|
||||
*/
|
||||
|
||||
{ ARROW_UP, 0x18, u'^'},
|
||||
|
||||
/* BugBut: Took out left arrow so right has to go too.
|
||||
{ ARROW_RIGHT, 0x1a, u'>'},
|
||||
*/
|
||||
{ ARROW_DOWN, 0x19, u'v'},
|
||||
|
||||
{ 0x0000, 0x00, u'\0' }
|
||||
};
|
||||
|
||||
|
||||
BOOLEAN
|
||||
LibIsValidTextGraphics (
|
||||
IN CHAR16 Graphic,
|
||||
OUT CHAR8 *PcAnsi, OPTIONAL
|
||||
OUT CHAR8 *Ascii OPTIONAL
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Detects if a Unicode char is for Box Drawing text graphics.
|
||||
|
||||
Arguments:
|
||||
|
||||
Grphic - Unicode char to test.
|
||||
|
||||
PcAnsi - Optional pointer to return PCANSI equivalent of Graphic.
|
||||
|
||||
Asci - Optional pointer to return Ascii equivalent of Graphic.
|
||||
|
||||
Returns:
|
||||
|
||||
TRUE if Gpaphic is a supported Unicode Box Drawing character.
|
||||
|
||||
--*/{
|
||||
UNICODE_TO_CHAR *Table;
|
||||
|
||||
if ((((Graphic & 0xff00) != 0x2500) && ((Graphic & 0xff00) != 0x2100))) {
|
||||
|
||||
//
|
||||
// Unicode drawing code charts are all in the 0x25xx range,
|
||||
// arrows are 0x21xx
|
||||
//
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
for (Table = UnicodeToPcAnsiOrAscii; Table->Unicode != 0x0000; Table++) {
|
||||
if (Graphic == Table->Unicode) {
|
||||
if (PcAnsi) {
|
||||
*PcAnsi = Table->PcAnsi;
|
||||
}
|
||||
if (Ascii) {
|
||||
*Ascii = Table->Ascii;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
IsValidAscii (
|
||||
IN CHAR16 Ascii
|
||||
)
|
||||
{
|
||||
if ((Ascii >= 0x20) && (Ascii <= 0x7f)) {
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
IsValidEfiCntlChar (
|
||||
IN CHAR16 c
|
||||
)
|
||||
{
|
||||
if (c == CHAR_NULL || c == CHAR_BACKSPACE || c == CHAR_LINEFEED || c == CHAR_CARRIAGE_RETURN) {
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
#include "lib.h"
|
||||
|
||||
#include "efiprot.h"
|
||||
#include "efishell.h"
|
||||
#include "efishellintf.h"
|
||||
|
||||
#ifndef MAX_ARGV_CONTENTS_SIZE
|
||||
# define MAX_CMDLINE_SIZE 1024
|
||||
#endif
|
||||
#ifndef MAX_ARGC
|
||||
# define MAX_CMDLINE_ARGC 32
|
||||
#endif
|
||||
|
||||
/*
|
||||
Parse LoadedImage options area, called only in case the regular
|
||||
shell protos are not available.
|
||||
|
||||
Format of LoadedImage->LoadOptions appears to be a
|
||||
single-space-separated list of args (looks like the shell already
|
||||
pre-parses the input, it apparently folds several consecutive spaces
|
||||
into one):
|
||||
argv[0] space argv[1] (etc.) argv[N] space \0 cwd \0 other data
|
||||
For safety, we support the trailing \0 without a space before, as
|
||||
well as several consecutive spaces (-> several args).
|
||||
*/
|
||||
static
|
||||
INTN
|
||||
GetShellArgcArgvFromLoadedImage(
|
||||
EFI_HANDLE ImageHandle,
|
||||
CHAR16 **ResultArgv[]
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
void *LoadedImage = NULL;
|
||||
static CHAR16 ArgvContents[MAX_CMDLINE_SIZE];
|
||||
static CHAR16 *Argv[MAX_CMDLINE_ARGC], *ArgStart, *c;
|
||||
UINTN Argc = 0, BufLen;
|
||||
|
||||
Status = uefi_call_wrapper(BS->OpenProtocol, 6,
|
||||
ImageHandle,
|
||||
&LoadedImageProtocol,
|
||||
&LoadedImage,
|
||||
ImageHandle,
|
||||
NULL,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
);
|
||||
if (EFI_ERROR(Status))
|
||||
return -1;
|
||||
|
||||
BufLen = ((EFI_LOADED_IMAGE *)LoadedImage)->LoadOptionsSize;
|
||||
if (BufLen < 2) /* We are expecting at least a \0 */
|
||||
return -1;
|
||||
else if (BufLen > sizeof(ArgvContents))
|
||||
BufLen = sizeof(ArgvContents);
|
||||
|
||||
CopyMem(ArgvContents, ((EFI_LOADED_IMAGE *)LoadedImage)->LoadOptions, BufLen);
|
||||
ArgvContents[MAX_CMDLINE_SIZE - 1] = u'\0';
|
||||
|
||||
for (c = ArgStart = ArgvContents ; *c != u'\0' ; ++c) {
|
||||
if (*c == u' ') {
|
||||
*c = u'\0';
|
||||
if (Argc < MAX_CMDLINE_ARGC) Argv[Argc++] = ArgStart;
|
||||
ArgStart = c + 1;
|
||||
}
|
||||
}
|
||||
|
||||
if ((*ArgStart != u'\0') && (Argc < MAX_CMDLINE_ARGC))
|
||||
Argv[Argc++] = ArgStart;
|
||||
|
||||
// Print(u"Got argc/argv from loaded image proto\n");
|
||||
*ResultArgv = Argv;
|
||||
return Argc;
|
||||
}
|
||||
|
||||
INTN GetShellArgcArgv(EFI_HANDLE ImageHandle, CHAR16 **Argv[])
|
||||
{
|
||||
// Code inspired from EDK2's
|
||||
// ShellPkg/Library/UefiShellCEntryLib/UefiShellCEntryLib.c (BSD)
|
||||
EFI_STATUS Status;
|
||||
static const EFI_GUID ShellInterfaceProtocolGuid
|
||||
= SHELL_INTERFACE_PROTOCOL_GUID;
|
||||
EFI_SHELL_PARAMETERS_PROTOCOL *EfiShellParametersProtocol = NULL;
|
||||
EFI_SHELL_INTERFACE *EfiShellInterfaceProtocol = NULL;
|
||||
|
||||
Status = uefi_call_wrapper(BS->OpenProtocol, 6,
|
||||
ImageHandle,
|
||||
(EFI_GUID*)&ShellParametersProtocolGuid,
|
||||
(VOID **)&EfiShellParametersProtocol,
|
||||
ImageHandle,
|
||||
NULL,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
);
|
||||
if (!EFI_ERROR(Status))
|
||||
{
|
||||
// use shell 2.0 interface
|
||||
// Print(u"Got argc/argv from shell intf proto\n");
|
||||
*Argv = EfiShellParametersProtocol->Argv;
|
||||
return EfiShellParametersProtocol->Argc;
|
||||
}
|
||||
|
||||
// try to get shell 1.0 interface instead.
|
||||
Status = uefi_call_wrapper(BS->OpenProtocol, 6,
|
||||
ImageHandle,
|
||||
(EFI_GUID*)&ShellInterfaceProtocolGuid,
|
||||
(VOID **)&EfiShellInterfaceProtocol,
|
||||
ImageHandle,
|
||||
NULL,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
);
|
||||
if (!EFI_ERROR(Status))
|
||||
{
|
||||
// Print(u"Got argc/argv from shell params proto\n");
|
||||
*Argv = EfiShellInterfaceProtocol->Argv;
|
||||
return EfiShellInterfaceProtocol->Argc;
|
||||
}
|
||||
|
||||
// shell 1.0 and 2.0 interfaces failed
|
||||
return GetShellArgcArgvFromLoadedImage(ImageHandle, Argv);
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
console.c
|
||||
|
||||
Abstract:
|
||||
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
#include "lib.h"
|
||||
|
||||
|
||||
|
||||
VOID
|
||||
Output (
|
||||
IN CHAR16 *Str
|
||||
)
|
||||
// Write a string to the console at the current cursor location
|
||||
{
|
||||
uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, Str);
|
||||
}
|
||||
|
||||
|
||||
VOID
|
||||
Input (
|
||||
IN CHAR16 *Prompt OPTIONAL,
|
||||
OUT CHAR16 *InStr,
|
||||
IN UINTN StrLen
|
||||
)
|
||||
// Input a string at the current cursor location, for StrLen
|
||||
{
|
||||
IInput (
|
||||
ST->ConOut,
|
||||
ST->ConIn,
|
||||
Prompt,
|
||||
InStr,
|
||||
StrLen
|
||||
);
|
||||
}
|
||||
|
||||
VOID
|
||||
IInput (
|
||||
IN SIMPLE_TEXT_OUTPUT_INTERFACE *ConOut,
|
||||
IN SIMPLE_INPUT_INTERFACE *ConIn,
|
||||
IN CHAR16 *Prompt OPTIONAL,
|
||||
OUT CHAR16 *InStr,
|
||||
IN UINTN StrLen
|
||||
)
|
||||
// Input a string at the current cursor location, for StrLen
|
||||
{
|
||||
EFI_INPUT_KEY Key;
|
||||
EFI_STATUS Status;
|
||||
UINTN Len;
|
||||
|
||||
if (Prompt) {
|
||||
ConOut->OutputString (ConOut, Prompt);
|
||||
}
|
||||
|
||||
Len = 0;
|
||||
for (; ;) {
|
||||
WaitForSingleEvent (ConIn->WaitForKey, 0);
|
||||
|
||||
Status = uefi_call_wrapper(ConIn->ReadKeyStroke, 2, ConIn, &Key);
|
||||
if (EFI_ERROR(Status)) {
|
||||
DEBUG((D_ERROR, "Input: error return from ReadKey %x\n", Status));
|
||||
break;
|
||||
}
|
||||
|
||||
if (Key.UnicodeChar == '\n' ||
|
||||
Key.UnicodeChar == '\r') {
|
||||
break;
|
||||
}
|
||||
|
||||
if (Key.UnicodeChar == '\b') {
|
||||
if (Len) {
|
||||
uefi_call_wrapper(ConOut->OutputString, 2, ConOut, u"\b \b");
|
||||
Len -= 1;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Key.UnicodeChar >= ' ') {
|
||||
if (Len < StrLen-1) {
|
||||
InStr[Len] = Key.UnicodeChar;
|
||||
|
||||
InStr[Len+1] = 0;
|
||||
uefi_call_wrapper(ConOut->OutputString, 2, ConOut, &InStr[Len]);
|
||||
|
||||
Len += 1;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
InStr[Len] = 0;
|
||||
}
|
||||
+218
@@ -0,0 +1,218 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
crc.c
|
||||
|
||||
Abstract:
|
||||
|
||||
CRC32 functions
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
#include "lib.h"
|
||||
|
||||
|
||||
UINT32 CRCTable[256] = {
|
||||
0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F,
|
||||
0xE963A535, 0x9E6495A3, 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988,
|
||||
0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, 0x1DB71064, 0x6AB020F2,
|
||||
0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7,
|
||||
0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9,
|
||||
0xFA0F3D63, 0x8D080DF5, 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172,
|
||||
0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, 0x35B5A8FA, 0x42B2986C,
|
||||
0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59,
|
||||
0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423,
|
||||
0xCFBA9599, 0xB8BDA50F, 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924,
|
||||
0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, 0x76DC4190, 0x01DB7106,
|
||||
0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433,
|
||||
0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D,
|
||||
0x91646C97, 0xE6635C01, 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E,
|
||||
0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, 0x65B0D9C6, 0x12B7E950,
|
||||
0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65,
|
||||
0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7,
|
||||
0xA4D1C46D, 0xD3D6F4FB, 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0,
|
||||
0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, 0x5005713C, 0x270241AA,
|
||||
0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F,
|
||||
0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81,
|
||||
0xB7BD5C3B, 0xC0BA6CAD, 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A,
|
||||
0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, 0xE3630B12, 0x94643B84,
|
||||
0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1,
|
||||
0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB,
|
||||
0x196C3671, 0x6E6B06E7, 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC,
|
||||
0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, 0xD6D6A3E8, 0xA1D1937E,
|
||||
0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B,
|
||||
0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55,
|
||||
0x316E8EEF, 0x4669BE79, 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236,
|
||||
0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, 0xC5BA3BBE, 0xB2BD0B28,
|
||||
0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D,
|
||||
0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F,
|
||||
0x72076785, 0x05005713, 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38,
|
||||
0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, 0x86D3D2D4, 0xF1D4E242,
|
||||
0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777,
|
||||
0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69,
|
||||
0x616BFFD3, 0x166CCF45, 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2,
|
||||
0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, 0xAED16A4A, 0xD9D65ADC,
|
||||
0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9,
|
||||
0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693,
|
||||
0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94,
|
||||
0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D
|
||||
};
|
||||
|
||||
|
||||
|
||||
VOID
|
||||
SetCrc (
|
||||
IN OUT EFI_TABLE_HEADER *Hdr
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Updates the CRC32 value in the table header
|
||||
|
||||
Arguments:
|
||||
|
||||
Hdr - The table to update
|
||||
|
||||
Returns:
|
||||
|
||||
None
|
||||
|
||||
--*/
|
||||
{
|
||||
SetCrcAltSize (Hdr->HeaderSize, Hdr);
|
||||
}
|
||||
|
||||
VOID
|
||||
SetCrcAltSize (
|
||||
IN UINTN Size,
|
||||
IN OUT EFI_TABLE_HEADER *Hdr
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Updates the CRC32 value in the table header
|
||||
|
||||
Arguments:
|
||||
|
||||
Hdr - The table to update
|
||||
|
||||
Returns:
|
||||
|
||||
None
|
||||
|
||||
--*/
|
||||
{
|
||||
Hdr->CRC32 = 0;
|
||||
Hdr->CRC32 = CalculateCrc((UINT8 *)Hdr, Size);
|
||||
}
|
||||
|
||||
|
||||
BOOLEAN
|
||||
CheckCrc (
|
||||
IN UINTN MaxSize,
|
||||
IN OUT EFI_TABLE_HEADER *Hdr
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Checks the CRC32 value in the table header
|
||||
|
||||
Arguments:
|
||||
|
||||
Hdr - The table to check
|
||||
|
||||
Returns:
|
||||
|
||||
TRUE if the CRC is OK in the table
|
||||
|
||||
--*/
|
||||
{
|
||||
return CheckCrcAltSize (MaxSize, Hdr->HeaderSize, Hdr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
BOOLEAN
|
||||
CheckCrcAltSize (
|
||||
IN UINTN MaxSize,
|
||||
IN UINTN Size,
|
||||
IN OUT EFI_TABLE_HEADER *Hdr
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Checks the CRC32 value in the table header
|
||||
|
||||
Arguments:
|
||||
|
||||
Hdr - The table to check
|
||||
|
||||
Returns:
|
||||
|
||||
TRUE if the CRC is OK in the table
|
||||
|
||||
--*/
|
||||
{
|
||||
UINT32 Crc;
|
||||
UINT32 OrgCrc;
|
||||
BOOLEAN f;
|
||||
|
||||
if (Size == 0) {
|
||||
//
|
||||
// If header size is 0 CRC will pass so return FALSE here
|
||||
//
|
||||
return FALSE;
|
||||
}
|
||||
if (MaxSize && Size > MaxSize) {
|
||||
DEBUG((D_ERROR, "CheckCrc32: Size > MaxSize\n"));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// clear old crc from header
|
||||
OrgCrc = Hdr->CRC32;
|
||||
Hdr->CRC32 = 0;
|
||||
Crc = CalculateCrc((UINT8 *)Hdr, Size);
|
||||
|
||||
// set restults
|
||||
Hdr->CRC32 = OrgCrc;
|
||||
|
||||
// return status
|
||||
f = OrgCrc == (UINT32) Crc;
|
||||
if (!f) {
|
||||
DEBUG((D_ERROR, "CheckCrc32: Crc check failed\n"));
|
||||
}
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
|
||||
UINT32
|
||||
CalculateCrc (
|
||||
UINT8 *pt,
|
||||
UINTN Size
|
||||
)
|
||||
{
|
||||
UINTN Crc;
|
||||
|
||||
// compute crc
|
||||
Crc = 0xffffffff;
|
||||
while (Size) {
|
||||
Crc = (Crc >> 8) ^ CRCTable[(UINT8) Crc ^ *pt];
|
||||
pt += 1;
|
||||
Size -= 1;
|
||||
}
|
||||
Crc = Crc ^ 0xffffffff;
|
||||
return (UINT32)Crc;
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Try to define the minimal empty init/ctor/dtor/fini_arrays so building with
|
||||
* older or out-of-tree linker scripts will still work.
|
||||
*/
|
||||
/*
|
||||
* Note that these aren't using the GNU "CONSTRUCTOR" output section
|
||||
* command, so they don't start with a size. Because of p2align and the
|
||||
* end/END definitions, and the fact that they're mergeable, they can also
|
||||
* have NULLs which aren't guaranteed to be at the end.
|
||||
*/
|
||||
#if defined(__ELF__)
|
||||
.section .init_array,"aw",%init_array
|
||||
#else
|
||||
.section .init_array,"aw"
|
||||
#endif
|
||||
.p2align 4, 0
|
||||
.globl __init_array_start
|
||||
__init_array_start:
|
||||
.globl __init_array_end
|
||||
__init_array_end:
|
||||
#if defined(__ELF__)
|
||||
.section .ctors,"aw",%progbits
|
||||
#else
|
||||
.section .ctors,"aw"
|
||||
#endif
|
||||
.p2align 4, 0
|
||||
.globl __CTOR_LIST__
|
||||
__CTOR_LIST__:
|
||||
.globl __CTOR_END__
|
||||
__CTOR_END__:
|
||||
#if defined(__ELF__)
|
||||
.section .dtors,"aw",%progbits
|
||||
#else
|
||||
.section .dtors,"aw"
|
||||
#endif
|
||||
.p2align 4, 0
|
||||
.globl __DTOR_LIST__
|
||||
__DTOR_LIST__:
|
||||
.globl __DTOR_END__
|
||||
__DTOR_END__:
|
||||
#if defined(__ELF__)
|
||||
.section .fini_array,"aw",%fini_array
|
||||
#else
|
||||
.section .fini_array,"aw"
|
||||
#endif
|
||||
.p2align 4, 0
|
||||
.globl __fini_array_start
|
||||
__fini_array_start:
|
||||
.globl __fini_array_end
|
||||
__fini_array_end:
|
||||
|
||||
#if defined(__ELF__) && defined(__linux__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
+226
@@ -0,0 +1,226 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
data.c
|
||||
|
||||
Abstract:
|
||||
|
||||
EFI library global data
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
#include "lib.h"
|
||||
|
||||
//
|
||||
// LibInitialized - TRUE once InitializeLib() is called for the first time
|
||||
//
|
||||
|
||||
BOOLEAN LibInitialized = FALSE;
|
||||
|
||||
//
|
||||
// ImageHandle - Current ImageHandle, as passed to InitializeLib
|
||||
//
|
||||
EFI_HANDLE LibImageHandle;
|
||||
|
||||
//
|
||||
// ST - pointer to the EFI system table
|
||||
//
|
||||
|
||||
EFI_SYSTEM_TABLE *ST;
|
||||
|
||||
//
|
||||
// BS - pointer to the boot services table
|
||||
//
|
||||
|
||||
EFI_BOOT_SERVICES *BS;
|
||||
|
||||
|
||||
//
|
||||
// Default pool allocation type
|
||||
//
|
||||
|
||||
EFI_MEMORY_TYPE PoolAllocationType = EfiBootServicesData;
|
||||
|
||||
//
|
||||
// Unicode collation functions that are in use
|
||||
//
|
||||
|
||||
EFI_UNICODE_COLLATION_INTERFACE LibStubUnicodeInterface = {
|
||||
LibStubStriCmp,
|
||||
LibStubMetaiMatch,
|
||||
LibStubStrLwrUpr,
|
||||
LibStubStrLwrUpr,
|
||||
NULL, // FatToStr
|
||||
NULL, // StrToFat
|
||||
NULL // SupportedLanguages
|
||||
};
|
||||
|
||||
EFI_UNICODE_COLLATION_INTERFACE *UnicodeInterface = &LibStubUnicodeInterface;
|
||||
|
||||
//
|
||||
// Root device path
|
||||
//
|
||||
|
||||
EFI_DEVICE_PATH RootDevicePath[] = {
|
||||
{END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, {END_DEVICE_PATH_LENGTH,0}}
|
||||
};
|
||||
|
||||
EFI_DEVICE_PATH EndDevicePath[] = {
|
||||
{END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, {END_DEVICE_PATH_LENGTH, 0}}
|
||||
};
|
||||
|
||||
EFI_DEVICE_PATH EndInstanceDevicePath[] = {
|
||||
{END_DEVICE_PATH_TYPE, END_INSTANCE_DEVICE_PATH_SUBTYPE, {END_DEVICE_PATH_LENGTH, 0}}
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// EFI IDs
|
||||
//
|
||||
|
||||
EFI_GUID gEfiGlobalVariableGuid = EFI_GLOBAL_VARIABLE;
|
||||
EFI_GUID gZeroGuid = EFI_ZERO_GUID;
|
||||
|
||||
//
|
||||
// Protocol IDs
|
||||
//
|
||||
|
||||
EFI_GUID gEfiDevicePathProtocolGuid = EFI_DEVICE_PATH_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiDevicePathToTextProtocolGuid = EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiDevicePathFromTextProtocolGuid = EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiDevicePathUtilitiesProtocolGuid = EFI_DEVICE_PATH_UTILITIES_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiLoadedImageProtocolGuid = EFI_LOADED_IMAGE_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiSimpleTextInProtocolGuid = EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiSimpleTextOutProtocolGuid = EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiBlockIoProtocolGuid = EFI_BLOCK_IO_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiBlockIo2ProtocolGuid = EFI_BLOCK_IO2_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiDiskIoProtocolGuid = EFI_DISK_IO_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiDiskIo2ProtocolGuid = EFI_DISK_IO2_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiDxeServicesTableGuid = DXE_SERVICES_TABLE_GUID;
|
||||
EFI_GUID gEfiSimpleFileSystemProtocolGuid = EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiLoadedImageDevicePathProtocolGuid = EFI_LOADED_IMAGE_DEVICE_PATH_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiLoadFileProtocolGuid = EFI_LOAD_FILE_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiLoadFile2ProtocolGuid = EFI_LOAD_FILE2_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiDeviceIoProtocolGuid = EFI_DEVICE_IO_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiUnicodeCollationProtocolGuid = EFI_UNICODE_COLLATION_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiSerialIoProtocolGuid = EFI_SERIAL_IO_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiSimpleNetworkProtocolGuid = EFI_SIMPLE_NETWORK_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiPxeBaseCodeProtocolGuid = EFI_PXE_BASE_CODE_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiPxeBaseCodeCallbackProtocolGuid = EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiNetworkInterfaceIdentifierProtocolGuid = EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_GUID;
|
||||
EFI_GUID gEFiUiInterfaceProtocolGuid = EFI_UI_INTERFACE_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiPciIoProtocolGuid = EFI_PCI_IO_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiPciRootBridgeIoProtocolGuid = EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiDriverBindingProtocolGuid = EFI_DRIVER_BINDING_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiComponentNameProtocolGuid = EFI_COMPONENT_NAME_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiComponentName2ProtocolGuid = EFI_COMPONENT_NAME2_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiHashProtocolGuid = EFI_HASH_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiPlatformDriverOverrideProtocolGuid = EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiBusSpecificDriverOverrideProtocolGuid = EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiDriverFamilyOverrideProtocolGuid = EFI_DRIVER_FAMILY_OVERRIDE_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiEbcProtocolGuid = EFI_EBC_PROTOCOL_GUID;
|
||||
|
||||
//
|
||||
// File system information IDs
|
||||
//
|
||||
|
||||
EFI_GUID gEfiFileInfoGuid = EFI_FILE_INFO_ID;
|
||||
EFI_GUID gEfiFileSystemInfoGuid = EFI_FILE_SYSTEM_INFO_ID;
|
||||
EFI_GUID gEfiFileSystemVolumeLabelInfoIdGuid = EFI_FILE_SYSTEM_VOLUME_LABEL_ID;
|
||||
|
||||
//
|
||||
// Multi-Processing protocol IDs.
|
||||
//
|
||||
EFI_GUID gEfiMpServicesProtocolGuid = EFI_MP_SERVICES_PROTOCOL_GUID;
|
||||
|
||||
//
|
||||
// Reference implementation public protocol IDs
|
||||
//
|
||||
|
||||
EFI_GUID InternalShellProtocol = INTERNAL_SHELL_GUID;
|
||||
EFI_GUID VariableStoreProtocol = VARIABLE_STORE_PROTOCOL;
|
||||
EFI_GUID LegacyBootProtocol = LEGACY_BOOT_PROTOCOL;
|
||||
EFI_GUID VgaClassProtocol = VGA_CLASS_DRIVER_PROTOCOL;
|
||||
|
||||
EFI_GUID TextOutSpliterProtocol = TEXT_OUT_SPLITER_PROTOCOL;
|
||||
EFI_GUID ErrorOutSpliterProtocol = ERROR_OUT_SPLITER_PROTOCOL;
|
||||
EFI_GUID TextInSpliterProtocol = TEXT_IN_SPLITER_PROTOCOL;
|
||||
/* Added for GOP support */
|
||||
EFI_GUID gEfiGraphicsOutputProtocolGuid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiEdidDiscoveredProtocolGuid = EFI_EDID_DISCOVERED_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiEdidActiveProtocolGuid = EFI_EDID_ACTIVE_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiEdidOverrideProtocolGuid = EFI_EDID_OVERRIDE_PROTOCOL_GUID;
|
||||
|
||||
EFI_GUID AdapterDebugProtocol = ADAPTER_DEBUG_PROTOCOL;
|
||||
|
||||
//
|
||||
// Device path media protocol IDs
|
||||
//
|
||||
EFI_GUID gEfiPcAnsiGuid = EFI_PC_ANSI_GUID;
|
||||
EFI_GUID gEfiVT100Guid = EFI_VT_100_GUID;
|
||||
EFI_GUID gEfiVT100PlusGuid = EFI_VT_100_PLUS_GUID;
|
||||
EFI_GUID gEfiVTUTF8Guid = EFI_VT_UTF8_GUID;
|
||||
|
||||
//
|
||||
// EFI GPT Partition Type GUIDs
|
||||
//
|
||||
EFI_GUID EfiPartTypeSystemPartitionGuid = EFI_PART_TYPE_EFI_SYSTEM_PART_GUID;
|
||||
EFI_GUID EfiPartTypeLegacyMbrGuid = EFI_PART_TYPE_LEGACY_MBR_GUID;
|
||||
|
||||
|
||||
//
|
||||
// Reference implementation Vendor Device Path Guids
|
||||
//
|
||||
EFI_GUID UnknownDevice = UNKNOWN_DEVICE_GUID;
|
||||
|
||||
//
|
||||
// Configuration Table GUIDs
|
||||
//
|
||||
|
||||
EFI_GUID MpsTableGuid = MPS_TABLE_GUID;
|
||||
EFI_GUID AcpiTableGuid = ACPI_TABLE_GUID;
|
||||
EFI_GUID gEfiSmbiosTableGuid = SMBIOS_TABLE_GUID;
|
||||
EFI_GUID gEfiSmbios3TableGuid = SMBIOS3_TABLE_GUID;
|
||||
EFI_GUID SalSystemTableGuid = SAL_SYSTEM_TABLE_GUID;
|
||||
EFI_GUID EfiDtbTableGuid = EFI_DTB_TABLE_GUID;
|
||||
|
||||
//
|
||||
// Network protocol GUIDs
|
||||
//
|
||||
EFI_GUID Ip4ServiceBindingProtocol = EFI_IP4_SERVICE_BINDING_PROTOCOL;
|
||||
EFI_GUID Ip4Protocol = EFI_IP4_PROTOCOL;
|
||||
EFI_GUID Udp4ServiceBindingProtocol = EFI_UDP4_SERVICE_BINDING_PROTOCOL;
|
||||
EFI_GUID Udp4Protocol = EFI_UDP4_PROTOCOL;
|
||||
EFI_GUID Tcp4ServiceBindingProtocol = EFI_TCP4_SERVICE_BINDING_PROTOCOL;
|
||||
EFI_GUID Tcp4Protocol = EFI_TCP4_PROTOCOL;
|
||||
|
||||
//
|
||||
// Pointer protocol GUIDs
|
||||
//
|
||||
EFI_GUID SimplePointerProtocol = EFI_SIMPLE_POINTER_PROTOCOL_GUID;
|
||||
EFI_GUID AbsolutePointerProtocol = EFI_ABSOLUTE_POINTER_PROTOCOL_GUID;
|
||||
|
||||
//
|
||||
// Debugger protocol GUIDs
|
||||
//
|
||||
EFI_GUID gEfiDebugImageInfoTableGuid = EFI_DEBUG_IMAGE_INFO_TABLE_GUID;
|
||||
EFI_GUID gEfiDebugSupportProtocolGuid = EFI_DEBUG_SUPPORT_PROTOCOL_GUID;
|
||||
|
||||
//
|
||||
// Console extension protocol GUIDs
|
||||
//
|
||||
EFI_GUID SimpleTextInputExProtocol = EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID;
|
||||
|
||||
//
|
||||
// Shell protocol GUIDs
|
||||
//
|
||||
EFI_GUID ShellProtocolGuid = EFI_SHELL_PROTOCOL_GUID;
|
||||
EFI_GUID ShellParametersProtocolGuid = EFI_SHELL_PARAMETERS_PROTOCOL_GUID;
|
||||
EFI_GUID ShellDynamicCommandProtocolGuid = EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL_GUID;
|
||||
@@ -0,0 +1,43 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
debug.c
|
||||
|
||||
Abstract:
|
||||
|
||||
Debug library functions
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
#include "lib.h"
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Declare runtime functions
|
||||
//
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
INTN
|
||||
DbgAssert (
|
||||
IN CONST CHAR8 *FileName,
|
||||
IN INTN LineNo,
|
||||
IN CONST CHAR8 *Description
|
||||
)
|
||||
{
|
||||
DbgPrint (D_ERROR, (CHAR8 *)"%EASSERT FAILED: %a(%d): %a%N\n", FileName, LineNo, Description);
|
||||
|
||||
BREAKPOINT();
|
||||
return 0;
|
||||
}
|
||||
|
||||
+1263
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* ctors.c
|
||||
* Copyright 2019 Peter Jones <pjones@redhat.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#include <efi.h>
|
||||
#include <efilib.h>
|
||||
|
||||
typedef void (*funcp)(void);
|
||||
|
||||
/*
|
||||
* Note that these aren't the using the GNU "CONSTRUCTOR" output section
|
||||
* command, so they don't start with a size. Because of p2align and the
|
||||
* end/END definitions, and the fact that they're mergeable, they can also
|
||||
* have NULLs which aren't guaranteed to be at the end.
|
||||
*/
|
||||
extern funcp __init_array_start[], __init_array_end[];
|
||||
extern funcp __CTOR_LIST__[], __CTOR_END__[];
|
||||
extern funcp __fini_array_start[], __fini_array_end[];
|
||||
extern funcp __DTOR_LIST__[], __DTOR_END__[];
|
||||
|
||||
static void ctors(void)
|
||||
{
|
||||
size_t __init_array_length = __init_array_end - __init_array_start;
|
||||
for (size_t i = 0; i < __init_array_length; i++) {
|
||||
funcp func = __init_array_start[i];
|
||||
if (func != NULL)
|
||||
func();
|
||||
}
|
||||
|
||||
size_t __CTOR_length = __CTOR_END__ - __CTOR_LIST__;
|
||||
for (size_t i = 0; i < __CTOR_length; i++) {
|
||||
size_t current = __CTOR_length - i - 1;
|
||||
funcp func = __CTOR_LIST__[current];
|
||||
if (func != NULL)
|
||||
func();
|
||||
}
|
||||
}
|
||||
|
||||
static void dtors(void)
|
||||
{
|
||||
size_t __DTOR_length = __DTOR_END__ - __DTOR_LIST__;
|
||||
for (size_t i = 0; i < __DTOR_length; i++) {
|
||||
funcp func = __DTOR_LIST__[i];
|
||||
if (func != NULL)
|
||||
func();
|
||||
}
|
||||
|
||||
size_t __fini_array_length = __fini_array_end - __fini_array_start;
|
||||
for (size_t i = 0; i < __fini_array_length; i++) {
|
||||
size_t current = __fini_array_length - i - 1;
|
||||
funcp func = __fini_array_start[current];
|
||||
if (func != NULL)
|
||||
func();
|
||||
}
|
||||
}
|
||||
|
||||
extern EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *systab);
|
||||
|
||||
EFI_STATUS _entry(EFI_HANDLE image, EFI_SYSTEM_TABLE *systab)
|
||||
{
|
||||
EFI_STATUS status;
|
||||
InitializeLib(image, systab);
|
||||
|
||||
ctors();
|
||||
status = efi_main(image, systab);
|
||||
dtors();
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
// vim:fenc=utf-8:tw=75:noet
|
||||
@@ -0,0 +1,89 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
error.c
|
||||
|
||||
Abstract:
|
||||
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
#include "lib.h"
|
||||
|
||||
|
||||
typedef struct {
|
||||
EFI_STATUS Code;
|
||||
WCHAR *Desc;
|
||||
} ErrorCodeTable_Type;
|
||||
ErrorCodeTable_Type ErrorCodeTable[] = {
|
||||
{ EFI_SUCCESS, u"Success"},
|
||||
{ EFI_LOAD_ERROR, u"Load Error"},
|
||||
{ EFI_INVALID_PARAMETER, u"Invalid Parameter"},
|
||||
{ EFI_UNSUPPORTED, u"Unsupported"},
|
||||
{ EFI_BAD_BUFFER_SIZE, u"Bad Buffer Size"},
|
||||
{ EFI_BUFFER_TOO_SMALL, u"Buffer Too Small"},
|
||||
{ EFI_NOT_READY, u"Not Ready"},
|
||||
{ EFI_DEVICE_ERROR, u"Device Error"},
|
||||
{ EFI_WRITE_PROTECTED, u"Write Protected"},
|
||||
{ EFI_OUT_OF_RESOURCES, u"Out of Resources"},
|
||||
{ EFI_VOLUME_CORRUPTED, u"Volume Corrupt"},
|
||||
{ EFI_VOLUME_FULL, u"Volume Full"},
|
||||
{ EFI_NO_MEDIA, u"No Media"},
|
||||
{ EFI_MEDIA_CHANGED, u"Media changed"},
|
||||
{ EFI_NOT_FOUND, u"Not Found"},
|
||||
{ EFI_ACCESS_DENIED, u"Access Denied"},
|
||||
{ EFI_NO_RESPONSE, u"No Response"},
|
||||
{ EFI_NO_MAPPING, u"No mapping"},
|
||||
{ EFI_TIMEOUT, u"Time out"},
|
||||
{ EFI_NOT_STARTED, u"Not started"},
|
||||
{ EFI_ALREADY_STARTED, u"Already started"},
|
||||
{ EFI_ABORTED, u"Aborted"},
|
||||
{ EFI_ICMP_ERROR, u"ICMP Error"},
|
||||
{ EFI_TFTP_ERROR, u"TFTP Error"},
|
||||
{ EFI_PROTOCOL_ERROR, u"Protocol Error"},
|
||||
{ EFI_INCOMPATIBLE_VERSION, u"Incompatible Version"},
|
||||
{ EFI_SECURITY_VIOLATION, u"Security Policy Violation"},
|
||||
{ EFI_CRC_ERROR, u"CRC Error"},
|
||||
{ EFI_END_OF_MEDIA, u"End of Media"},
|
||||
{ EFI_END_OF_FILE, u"End of File"},
|
||||
{ EFI_INVALID_LANGUAGE, u"Invalid Languages"},
|
||||
{ EFI_COMPROMISED_DATA, u"Compromised Data"},
|
||||
{ EFI_IP_ADDRESS_CONFLICT, u"IP Address Conflict"},
|
||||
{ EFI_HTTP_ERROR, u"HTTP Error"},
|
||||
|
||||
// warnings
|
||||
{ EFI_WARN_UNKNOWN_GLYPH, u"Warning Unknown Glyph"},
|
||||
{ EFI_WARN_DELETE_FAILURE, u"Warning Delete Failure"},
|
||||
{ EFI_WARN_WRITE_FAILURE, u"Warning Write Failure"},
|
||||
{ EFI_WARN_BUFFER_TOO_SMALL, u"Warning Buffer Too Small"},
|
||||
{ EFI_WARN_STALE_DATA, u"Warning Stale Data"},
|
||||
{ EFI_WARN_FILE_SYSTEM, u"Warning File System"},
|
||||
{ EFI_WARN_RESET_REQUIRED, u"Warning Reset Required"},
|
||||
{ 0, NULL}
|
||||
} ;
|
||||
|
||||
|
||||
VOID
|
||||
StatusToString (
|
||||
OUT CHAR16 *Buffer,
|
||||
IN EFI_STATUS Status
|
||||
)
|
||||
{
|
||||
UINTN Index;
|
||||
|
||||
for (Index = 0; ErrorCodeTable[Index].Desc; Index +=1) {
|
||||
if (ErrorCodeTable[Index].Code == Status) {
|
||||
StrCpy (Buffer, ErrorCodeTable[Index].Desc);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
UnicodeSPrint (Buffer, 0, u"%X", Status);
|
||||
}
|
||||
+154
@@ -0,0 +1,154 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
event.c
|
||||
|
||||
Abstract:
|
||||
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
#include "lib.h"
|
||||
|
||||
|
||||
EFI_EVENT
|
||||
LibCreateProtocolNotifyEvent (
|
||||
IN EFI_GUID *ProtocolGuid,
|
||||
IN EFI_TPL NotifyTpl,
|
||||
IN EFI_EVENT_NOTIFY NotifyFunction,
|
||||
IN VOID *NotifyContext,
|
||||
OUT VOID *Registration
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_EVENT Event;
|
||||
|
||||
//
|
||||
// Create the event
|
||||
//
|
||||
|
||||
Status = uefi_call_wrapper(
|
||||
BS->CreateEvent,
|
||||
5,
|
||||
EVT_NOTIFY_SIGNAL,
|
||||
NotifyTpl,
|
||||
NotifyFunction,
|
||||
NotifyContext,
|
||||
&Event
|
||||
);
|
||||
if ( EFI_ERROR( Status ) ) return NULL ;
|
||||
ASSERT (!EFI_ERROR(Status));
|
||||
|
||||
//
|
||||
// Register for protocol notifactions on this event
|
||||
//
|
||||
|
||||
Status = uefi_call_wrapper(
|
||||
BS->RegisterProtocolNotify,
|
||||
3,
|
||||
ProtocolGuid,
|
||||
Event,
|
||||
Registration
|
||||
);
|
||||
if ( EFI_ERROR( Status ) ) return NULL ;
|
||||
ASSERT (!EFI_ERROR(Status));
|
||||
|
||||
//
|
||||
// Kick the event so we will perform an initial pass of
|
||||
// current installed drivers
|
||||
//
|
||||
|
||||
uefi_call_wrapper(BS->SignalEvent, 1, Event);
|
||||
return Event;
|
||||
}
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
WaitForSingleEvent (
|
||||
IN EFI_EVENT Event,
|
||||
IN UINT64 Timeout OPTIONAL
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINTN Index;
|
||||
EFI_EVENT TimerEvent;
|
||||
EFI_EVENT WaitList[2];
|
||||
|
||||
if (Timeout) {
|
||||
//
|
||||
// Create a timer event
|
||||
//
|
||||
|
||||
Status = uefi_call_wrapper(BS->CreateEvent, 5, EVT_TIMER, 0, NULL, NULL, &TimerEvent);
|
||||
if (!EFI_ERROR(Status)) {
|
||||
|
||||
//
|
||||
// Set the timer event
|
||||
//
|
||||
|
||||
uefi_call_wrapper(BS->SetTimer, 3, TimerEvent, TimerRelative, Timeout);
|
||||
|
||||
//
|
||||
// Wait for the original event or the timer
|
||||
//
|
||||
|
||||
WaitList[0] = Event;
|
||||
WaitList[1] = TimerEvent;
|
||||
Status = uefi_call_wrapper(BS->WaitForEvent, 3, 2, WaitList, &Index);
|
||||
uefi_call_wrapper(BS->CloseEvent, 1, TimerEvent);
|
||||
|
||||
//
|
||||
// If the timer expired, change the return to timed out
|
||||
//
|
||||
|
||||
if (!EFI_ERROR(Status) && Index == 1) {
|
||||
Status = EFI_TIMEOUT;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
//
|
||||
// No timeout... just wait on the event
|
||||
//
|
||||
|
||||
Status = uefi_call_wrapper(BS->WaitForEvent, 3, 1, &Event, &Index);
|
||||
ASSERT (!EFI_ERROR(Status));
|
||||
ASSERT (Index == 0);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
VOID
|
||||
WaitForEventWithTimeout (
|
||||
IN EFI_EVENT Event,
|
||||
IN UINTN Timeout,
|
||||
IN UINTN Row,
|
||||
IN UINTN Column,
|
||||
IN CHAR16 *String,
|
||||
IN EFI_INPUT_KEY TimeoutKey,
|
||||
OUT EFI_INPUT_KEY *Key
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
do {
|
||||
PrintAt (Column, Row, String, Timeout);
|
||||
Status = WaitForSingleEvent (Event, 10000000);
|
||||
if (Status == EFI_SUCCESS) {
|
||||
if (!EFI_ERROR(uefi_call_wrapper(ST->ConIn->ReadKeyStroke, 2, ST->ConIn, Key))) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
} while (Timeout > 0);
|
||||
CopyMem(Key, &TimeoutKey, sizeof(EFI_INPUT_KEY));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
#include "lib.h"
|
||||
|
||||
VOID
|
||||
Exit(
|
||||
IN EFI_STATUS ExitStatus,
|
||||
IN UINTN ExitDataSize,
|
||||
IN CHAR16 *ExitData OPTIONAL
|
||||
)
|
||||
{
|
||||
uefi_call_wrapper(BS->Exit,
|
||||
4,
|
||||
LibImageHandle,
|
||||
ExitStatus,
|
||||
ExitDataSize,
|
||||
ExitData);
|
||||
|
||||
// Uh oh, Exit() returned?!
|
||||
for (;;) { }
|
||||
}
|
||||
+191
@@ -0,0 +1,191 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
misc.c
|
||||
|
||||
Abstract:
|
||||
|
||||
Misc EFI support functions
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
#include "lib.h"
|
||||
|
||||
|
||||
//
|
||||
// Additional Known guids
|
||||
//
|
||||
|
||||
#define SHELL_INTERFACE_PROTOCOL \
|
||||
{ 0x47c7b223, 0xc42a, 0x11d2, {0x8e, 0x57, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} }
|
||||
|
||||
#define ENVIRONMENT_VARIABLE_ID \
|
||||
{ 0x47c7b224, 0xc42a, 0x11d2, {0x8e, 0x57, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} }
|
||||
|
||||
#define DEVICE_PATH_MAPPING_ID \
|
||||
{ 0x47c7b225, 0xc42a, 0x11d2, {0x8e, 0x57, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} }
|
||||
|
||||
#define PROTOCOL_ID_ID \
|
||||
{ 0x47c7b226, 0xc42a, 0x11d2, {0x8e, 0x57, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} }
|
||||
|
||||
#define ALIAS_ID \
|
||||
{ 0x47c7b227, 0xc42a, 0x11d2, {0x8e, 0x57, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} }
|
||||
|
||||
static EFI_GUID ShellInterfaceProtocol = SHELL_INTERFACE_PROTOCOL;
|
||||
static EFI_GUID SEnvId = ENVIRONMENT_VARIABLE_ID;
|
||||
static EFI_GUID SMapId = DEVICE_PATH_MAPPING_ID;
|
||||
static EFI_GUID SProtId = PROTOCOL_ID_ID;
|
||||
static EFI_GUID SAliasId = ALIAS_ID;
|
||||
|
||||
static struct {
|
||||
EFI_GUID *Guid;
|
||||
WCHAR *GuidName;
|
||||
} KnownGuids[] = {
|
||||
{ &gZeroGuid, u"NullGuid" },
|
||||
{ &gEfiGlobalVariableGuid, u"EfiVar" },
|
||||
|
||||
{ &VariableStoreProtocol, u"VarStore" },
|
||||
{ &gEfiDevicePathProtocolGuid, u"DevPath" },
|
||||
{ &gEfiLoadedImageProtocolGuid, u"LdImg" },
|
||||
{ &gEfiSimpleTextInProtocolGuid, u"TxtIn" },
|
||||
{ &gEfiSimpleTextOutProtocolGuid, u"TxtOut" },
|
||||
{ &gEfiBlockIoProtocolGuid, u"BlkIo" },
|
||||
{ &gEfiBlockIo2ProtocolGuid, u"BlkIo2" },
|
||||
{ &gEfiDiskIoProtocolGuid, u"DskIo" },
|
||||
{ &gEfiDiskIo2ProtocolGuid, u"DskIo2" },
|
||||
{ &gEfiSimpleFileSystemProtocolGuid, u"Fs" },
|
||||
{ &gEfiLoadFileProtocolGuid, u"LdFile" },
|
||||
{ &gEfiDeviceIoProtocolGuid, u"DevIo" },
|
||||
{ &gEfiComponentNameProtocolGuid, u"CName" },
|
||||
{ &gEfiComponentName2ProtocolGuid, u"CName2" },
|
||||
|
||||
{ &gEfiMpServicesProtocolGuid, u"Mp" },
|
||||
|
||||
{ &gEfiFileInfoGuid, u"FileInfo" },
|
||||
{ &gEfiFileSystemInfoGuid, u"FsInfo" },
|
||||
{ &gEfiFileSystemVolumeLabelInfoIdGuid, u"FsVolInfo" },
|
||||
|
||||
{ &gEfiUnicodeCollationProtocolGuid, u"Unicode" },
|
||||
{ &LegacyBootProtocol, u"LegacyBoot" },
|
||||
{ &gEfiSerialIoProtocolGuid, u"SerIo" },
|
||||
{ &VgaClassProtocol, u"VgaClass"},
|
||||
{ &gEfiSimpleNetworkProtocolGuid, u"Net" },
|
||||
{ &gEfiNetworkInterfaceIdentifierProtocolGuid, u"Nii" },
|
||||
{ &gEfiPxeBaseCodeProtocolGuid, u"Pxe" },
|
||||
{ &gEfiPxeBaseCodeCallbackProtocolGuid, u"PxeCb" },
|
||||
|
||||
{ &TextOutSpliterProtocol, u"TxtOutSplit" },
|
||||
{ &ErrorOutSpliterProtocol, u"ErrOutSplit" },
|
||||
{ &TextInSpliterProtocol, u"TxtInSplit" },
|
||||
{ &gEfiPcAnsiGuid, u"PcAnsi" },
|
||||
{ &gEfiVT100Guid, u"Vt100" },
|
||||
{ &gEfiVT100PlusGuid, u"Vt100Plus" },
|
||||
{ &gEfiVTUTF8Guid, u"VtUtf8" },
|
||||
{ &UnknownDevice, u"UnknownDev" },
|
||||
|
||||
{ &EfiPartTypeSystemPartitionGuid, u"ESP" },
|
||||
{ &EfiPartTypeLegacyMbrGuid, u"GPT MBR" },
|
||||
|
||||
{ &ShellInterfaceProtocol, u"ShellInt" },
|
||||
{ &SEnvId, u"SEnv" },
|
||||
{ &SProtId, u"ShellProtId" },
|
||||
{ &SMapId, u"ShellDevPathMap" },
|
||||
{ &SAliasId, u"ShellAlias" },
|
||||
|
||||
{ NULL, u"" }
|
||||
};
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
LIST_ENTRY GuidList;
|
||||
|
||||
|
||||
VOID
|
||||
InitializeGuid (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
EFIAPI
|
||||
CompareGuid_1 (
|
||||
IN CONST EFI_GUID *Guid1,
|
||||
IN CONST EFI_GUID *Guid2
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Compares to GUIDs
|
||||
|
||||
Arguments:
|
||||
|
||||
Guid1 - guid to compare
|
||||
Guid2 - guid to compare
|
||||
|
||||
Returns:
|
||||
= 1 if Guid1 == Guid2
|
||||
|
||||
--*/
|
||||
{
|
||||
return RtCompareGuid (Guid1, Guid2);
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
EFIAPI
|
||||
IsZeroGuid (
|
||||
IN CONST EFI_GUID *Guid1
|
||||
)
|
||||
{
|
||||
return RtIsZeroGuid(Guid1);
|
||||
}
|
||||
|
||||
|
||||
VOID
|
||||
GuidToString (
|
||||
OUT CHAR16 *Buffer,
|
||||
IN EFI_GUID *Guid
|
||||
)
|
||||
{
|
||||
|
||||
UINTN Index;
|
||||
|
||||
//
|
||||
// Else, (for now) use additional internal function for mapping guids
|
||||
//
|
||||
|
||||
for (Index=0; KnownGuids[Index].Guid; Index++) {
|
||||
if (CompareGuid(Guid, KnownGuids[Index].Guid)) {
|
||||
UnicodeSPrint (Buffer, 0, KnownGuids[Index].GuidName);
|
||||
return ;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Else dump it
|
||||
//
|
||||
|
||||
UnicodeSPrint (Buffer, 0, u"%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
|
||||
Guid->Data1,
|
||||
Guid->Data2,
|
||||
Guid->Data3,
|
||||
Guid->Data4[0],
|
||||
Guid->Data4[1],
|
||||
Guid->Data4[2],
|
||||
Guid->Data4[3],
|
||||
Guid->Data4[4],
|
||||
Guid->Data4[5],
|
||||
Guid->Data4[6],
|
||||
Guid->Data4[7]
|
||||
);
|
||||
}
|
||||
+641
@@ -0,0 +1,641 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
hand.c
|
||||
|
||||
Abstract:
|
||||
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
#include "lib.h"
|
||||
#include "efistdarg.h" // !!!
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
LibLocateProtocol (
|
||||
IN EFI_GUID *ProtocolGuid,
|
||||
OUT VOID **Interface
|
||||
)
|
||||
//
|
||||
// Find the first instance of this Protocol in the system and return it's interface
|
||||
//
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINTN NumberHandles, Index;
|
||||
EFI_HANDLE *Handles;
|
||||
|
||||
|
||||
*Interface = NULL;
|
||||
Status = LibLocateHandle (ByProtocol, ProtocolGuid, NULL, &NumberHandles, &Handles);
|
||||
if (EFI_ERROR(Status)) {
|
||||
DEBUG((D_INFO, "LibLocateProtocol: Handle not found\n"));
|
||||
return Status;
|
||||
}
|
||||
|
||||
for (Index=0; Index < NumberHandles; Index++) {
|
||||
Status = uefi_call_wrapper(BS->HandleProtocol, 3, Handles[Index], ProtocolGuid, Interface);
|
||||
if (!EFI_ERROR(Status)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (Handles) {
|
||||
FreePool (Handles);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
LibLocateHandle (
|
||||
IN EFI_LOCATE_SEARCH_TYPE SearchType,
|
||||
IN EFI_GUID *Protocol OPTIONAL,
|
||||
IN VOID *SearchKey OPTIONAL,
|
||||
IN OUT UINTN *NoHandles,
|
||||
OUT EFI_HANDLE **Buffer
|
||||
)
|
||||
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINTN BufferSize;
|
||||
|
||||
//
|
||||
// Initialize for GrowBuffer loop
|
||||
//
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
*Buffer = NULL;
|
||||
BufferSize = 50 * sizeof(EFI_HANDLE);
|
||||
|
||||
//
|
||||
// Call the real function
|
||||
//
|
||||
|
||||
while (GrowBuffer (&Status, (VOID **) Buffer, BufferSize)) {
|
||||
|
||||
Status = uefi_call_wrapper(
|
||||
BS->LocateHandle,
|
||||
5,
|
||||
SearchType,
|
||||
Protocol,
|
||||
SearchKey,
|
||||
&BufferSize,
|
||||
*Buffer
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
*NoHandles = BufferSize / sizeof (EFI_HANDLE);
|
||||
if (EFI_ERROR(Status)) {
|
||||
*NoHandles = 0;
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
LibLocateHandleByDiskSignature (
|
||||
IN UINT8 MBRType,
|
||||
IN UINT8 SignatureType,
|
||||
IN VOID *Signature,
|
||||
IN OUT UINTN *NoHandles,
|
||||
OUT EFI_HANDLE **Buffer
|
||||
)
|
||||
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINTN BufferSize;
|
||||
UINTN NoBlockIoHandles;
|
||||
EFI_HANDLE *BlockIoBuffer;
|
||||
EFI_DEVICE_PATH *DevicePath;
|
||||
UINTN Index;
|
||||
EFI_DEVICE_PATH *Next, *DevPath;
|
||||
HARDDRIVE_DEVICE_PATH *HardDriveDevicePath;
|
||||
BOOLEAN Match;
|
||||
BOOLEAN PreviousNodeIsHardDriveDevicePath;
|
||||
|
||||
//
|
||||
// Initialize for GrowBuffer loop
|
||||
//
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
BlockIoBuffer = NULL;
|
||||
BufferSize = 50 * sizeof(EFI_HANDLE);
|
||||
|
||||
//
|
||||
// Call the real function
|
||||
//
|
||||
|
||||
while (GrowBuffer (&Status, (VOID **)&BlockIoBuffer, BufferSize)) {
|
||||
|
||||
//
|
||||
// Get list of device handles that support the BLOCK_IO Protocol.
|
||||
//
|
||||
|
||||
Status = uefi_call_wrapper(
|
||||
BS->LocateHandle,
|
||||
5,
|
||||
ByProtocol,
|
||||
&BlockIoProtocol,
|
||||
NULL,
|
||||
&BufferSize,
|
||||
BlockIoBuffer
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
NoBlockIoHandles = BufferSize / sizeof (EFI_HANDLE);
|
||||
if (EFI_ERROR(Status)) {
|
||||
NoBlockIoHandles = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// If there was an error or there are no device handles that support
|
||||
// the BLOCK_IO Protocol, then return.
|
||||
//
|
||||
|
||||
if (NoBlockIoHandles == 0) {
|
||||
FreePool(BlockIoBuffer);
|
||||
*NoHandles = 0;
|
||||
*Buffer = NULL;
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Loop through all the device handles that support the BLOCK_IO Protocol
|
||||
//
|
||||
|
||||
*NoHandles = 0;
|
||||
|
||||
for(Index=0;Index<NoBlockIoHandles;Index++) {
|
||||
|
||||
Status = uefi_call_wrapper(
|
||||
BS->HandleProtocol,
|
||||
3,
|
||||
BlockIoBuffer[Index],
|
||||
&DevicePathProtocol,
|
||||
(VOID*)&DevicePath
|
||||
);
|
||||
|
||||
//
|
||||
// Search DevicePath for a Hard Drive Media Device Path node.
|
||||
// If one is found, then see if it matches the signature that was
|
||||
// passed in. If it does match, and the next node is the End of the
|
||||
// device path, and the previous node is not a Hard Drive Media Device
|
||||
// Path, then we have found a match.
|
||||
//
|
||||
|
||||
Match = FALSE;
|
||||
|
||||
if (DevicePath != NULL) {
|
||||
|
||||
PreviousNodeIsHardDriveDevicePath = FALSE;
|
||||
|
||||
DevPath = DevicePath;
|
||||
|
||||
//
|
||||
// Check for end of device path type
|
||||
//
|
||||
|
||||
for (; ;) {
|
||||
|
||||
if ((DevicePathType(DevPath) == MEDIA_DEVICE_PATH) &&
|
||||
(DevicePathSubType(DevPath) == MEDIA_HARDDRIVE_DP)) {
|
||||
|
||||
HardDriveDevicePath = (HARDDRIVE_DEVICE_PATH *)(DevPath);
|
||||
|
||||
if (PreviousNodeIsHardDriveDevicePath == FALSE) {
|
||||
|
||||
Next = NextDevicePathNode(DevPath);
|
||||
if (IsDevicePathEndType(Next)) {
|
||||
if ((HardDriveDevicePath->MBRType == MBRType) &&
|
||||
(HardDriveDevicePath->SignatureType == SignatureType)) {
|
||||
switch(SignatureType) {
|
||||
case SIGNATURE_TYPE_MBR:
|
||||
if (*((UINT32 *)(Signature)) == *(UINT32 *)(&(HardDriveDevicePath->Signature[0]))) {
|
||||
Match = TRUE;
|
||||
}
|
||||
break;
|
||||
case SIGNATURE_TYPE_GUID:
|
||||
if (CompareGuid((EFI_GUID *)Signature,(EFI_GUID *)(&(HardDriveDevicePath->Signature[0])))) {
|
||||
Match = TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
PreviousNodeIsHardDriveDevicePath = TRUE;
|
||||
} else {
|
||||
PreviousNodeIsHardDriveDevicePath = FALSE;
|
||||
}
|
||||
|
||||
if (IsDevicePathEnd(DevPath)) {
|
||||
break;
|
||||
}
|
||||
|
||||
DevPath = NextDevicePathNode(DevPath);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (Match == FALSE) {
|
||||
BlockIoBuffer[Index] = NULL;
|
||||
} else {
|
||||
*NoHandles = *NoHandles + 1;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// If there are no matches, then return
|
||||
//
|
||||
|
||||
if (*NoHandles == 0) {
|
||||
FreePool(BlockIoBuffer);
|
||||
*NoHandles = 0;
|
||||
*Buffer = NULL;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
//
|
||||
// Allocate space for the return buffer of device handles.
|
||||
//
|
||||
|
||||
*Buffer = AllocatePool(*NoHandles * sizeof(EFI_HANDLE));
|
||||
|
||||
if (*Buffer == NULL) {
|
||||
FreePool(BlockIoBuffer);
|
||||
*NoHandles = 0;
|
||||
*Buffer = NULL;
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
//
|
||||
// Build list of matching device handles.
|
||||
//
|
||||
|
||||
*NoHandles = 0;
|
||||
for(Index=0;Index<NoBlockIoHandles;Index++) {
|
||||
if (BlockIoBuffer[Index] != NULL) {
|
||||
(*Buffer)[*NoHandles] = BlockIoBuffer[Index];
|
||||
*NoHandles = *NoHandles + 1;
|
||||
}
|
||||
}
|
||||
|
||||
FreePool(BlockIoBuffer);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
EFI_FILE_HANDLE
|
||||
LibOpenRoot (
|
||||
IN EFI_HANDLE DeviceHandle
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_FILE_IO_INTERFACE *Volume;
|
||||
EFI_FILE_HANDLE File;
|
||||
|
||||
|
||||
//
|
||||
// File the file system interface to the device
|
||||
//
|
||||
|
||||
Status = uefi_call_wrapper(BS->HandleProtocol, 3, DeviceHandle, &FileSystemProtocol, (VOID*)&Volume);
|
||||
|
||||
//
|
||||
// Open the root directory of the volume
|
||||
//
|
||||
|
||||
if (!EFI_ERROR(Status)) {
|
||||
Status = uefi_call_wrapper(Volume->OpenVolume, 2, Volume, &File);
|
||||
}
|
||||
|
||||
//
|
||||
// Done
|
||||
//
|
||||
|
||||
return EFI_ERROR(Status) ? NULL : File;
|
||||
}
|
||||
|
||||
EFI_FILE_INFO *
|
||||
LibFileInfo (
|
||||
IN EFI_FILE_HANDLE FHand
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_FILE_INFO *Buffer;
|
||||
UINTN BufferSize;
|
||||
|
||||
//
|
||||
// Initialize for GrowBuffer loop
|
||||
//
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
Buffer = NULL;
|
||||
BufferSize = SIZE_OF_EFI_FILE_INFO + 200;
|
||||
|
||||
//
|
||||
// Call the real function
|
||||
//
|
||||
|
||||
while (GrowBuffer (&Status, (VOID **) &Buffer, BufferSize)) {
|
||||
Status = uefi_call_wrapper(
|
||||
FHand->GetInfo,
|
||||
4,
|
||||
FHand,
|
||||
&GenericFileInfo,
|
||||
&BufferSize,
|
||||
Buffer
|
||||
);
|
||||
}
|
||||
|
||||
return Buffer;
|
||||
}
|
||||
|
||||
|
||||
EFI_FILE_SYSTEM_INFO *
|
||||
LibFileSystemInfo (
|
||||
IN EFI_FILE_HANDLE FHand
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_FILE_SYSTEM_INFO *Buffer;
|
||||
UINTN BufferSize;
|
||||
|
||||
//
|
||||
// Initialize for GrowBuffer loop
|
||||
//
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
Buffer = NULL;
|
||||
BufferSize = SIZE_OF_EFI_FILE_SYSTEM_INFO + 200;
|
||||
|
||||
//
|
||||
// Call the real function
|
||||
//
|
||||
|
||||
while (GrowBuffer (&Status, (VOID **) &Buffer, BufferSize)) {
|
||||
Status = uefi_call_wrapper(
|
||||
FHand->GetInfo,
|
||||
4,
|
||||
FHand,
|
||||
&FileSystemInfo,
|
||||
&BufferSize,
|
||||
Buffer
|
||||
);
|
||||
}
|
||||
|
||||
return Buffer;
|
||||
}
|
||||
|
||||
EFI_FILE_SYSTEM_VOLUME_LABEL_INFO *
|
||||
LibFileSystemVolumeLabelInfo (
|
||||
IN EFI_FILE_HANDLE FHand
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_FILE_SYSTEM_VOLUME_LABEL_INFO *Buffer;
|
||||
UINTN BufferSize;
|
||||
|
||||
//
|
||||
// Initialize for GrowBuffer loop
|
||||
//
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
Buffer = NULL;
|
||||
BufferSize = SIZE_OF_EFI_FILE_SYSTEM_VOLUME_LABEL_INFO + 200;
|
||||
|
||||
//
|
||||
// Call the real function
|
||||
//
|
||||
|
||||
while (GrowBuffer (&Status, (VOID **) &Buffer, BufferSize)) {
|
||||
Status = uefi_call_wrapper(
|
||||
FHand->GetInfo,
|
||||
4,
|
||||
FHand,
|
||||
&FileSystemVolumeLabelInfo,
|
||||
&BufferSize,
|
||||
Buffer
|
||||
);
|
||||
}
|
||||
|
||||
return Buffer;
|
||||
}
|
||||
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
LibInstallProtocolInterfaces (
|
||||
IN OUT EFI_HANDLE *Handle,
|
||||
...
|
||||
)
|
||||
{
|
||||
va_list args;
|
||||
EFI_STATUS Status;
|
||||
EFI_GUID *Protocol;
|
||||
VOID *Interface;
|
||||
EFI_TPL OldTpl;
|
||||
UINTN Index;
|
||||
EFI_HANDLE OldHandle;
|
||||
|
||||
//
|
||||
// Syncronize with notifcations
|
||||
//
|
||||
|
||||
OldTpl = uefi_call_wrapper(BS->RaiseTPL, 1, TPL_NOTIFY);
|
||||
OldHandle = *Handle;
|
||||
|
||||
//
|
||||
// Install the protocol interfaces
|
||||
//
|
||||
|
||||
Index = 0;
|
||||
Status = EFI_SUCCESS;
|
||||
va_start (args, Handle);
|
||||
|
||||
while (!EFI_ERROR(Status)) {
|
||||
|
||||
//
|
||||
// If protocol is NULL, then it's the end of the list
|
||||
//
|
||||
|
||||
Protocol = va_arg(args, EFI_GUID *);
|
||||
if (!Protocol) {
|
||||
break;
|
||||
}
|
||||
|
||||
Interface = va_arg(args, VOID *);
|
||||
|
||||
//
|
||||
// Install it
|
||||
//
|
||||
|
||||
DEBUG((D_INFO, "LibInstallProtocolInterface: %d %x\n", Protocol, Interface));
|
||||
Status = uefi_call_wrapper(BS->InstallProtocolInterface, 4, Handle, Protocol, EFI_NATIVE_INTERFACE, Interface);
|
||||
if (EFI_ERROR(Status)) {
|
||||
break;
|
||||
}
|
||||
|
||||
Index += 1;
|
||||
}
|
||||
va_end (args);
|
||||
|
||||
//
|
||||
// If there was an error, remove all the interfaces that were
|
||||
// installed without any errors
|
||||
//
|
||||
|
||||
if (EFI_ERROR(Status)) {
|
||||
va_start (args, Handle);
|
||||
while (Index) {
|
||||
|
||||
Protocol = va_arg(args, EFI_GUID *);
|
||||
Interface = va_arg(args, VOID *);
|
||||
uefi_call_wrapper(BS->UninstallProtocolInterface, 3, *Handle, Protocol, Interface);
|
||||
|
||||
Index -= 1;
|
||||
}
|
||||
|
||||
*Handle = OldHandle;
|
||||
va_end (args);
|
||||
}
|
||||
|
||||
//
|
||||
// Done
|
||||
//
|
||||
|
||||
uefi_call_wrapper(BS->RestoreTPL, 1, OldTpl);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
VOID
|
||||
LibUninstallProtocolInterfaces (
|
||||
IN EFI_HANDLE Handle,
|
||||
...
|
||||
)
|
||||
{
|
||||
va_list args;
|
||||
EFI_STATUS Status;
|
||||
EFI_GUID *Protocol;
|
||||
VOID *Interface;
|
||||
|
||||
|
||||
va_start (args, Handle);
|
||||
for (; ;) {
|
||||
|
||||
//
|
||||
// If protocol is NULL, then it's the end of the list
|
||||
//
|
||||
|
||||
Protocol = va_arg(args, EFI_GUID *);
|
||||
if (!Protocol) {
|
||||
break;
|
||||
}
|
||||
|
||||
Interface = va_arg(args, VOID *);
|
||||
|
||||
//
|
||||
// Uninstall it
|
||||
//
|
||||
|
||||
Status = uefi_call_wrapper(BS->UninstallProtocolInterface, 3, Handle, Protocol, Interface);
|
||||
if (EFI_ERROR(Status)) {
|
||||
DEBUG((D_ERROR, "LibUninstallProtocolInterfaces: failed %g, %r\n", Protocol, Handle));
|
||||
}
|
||||
}
|
||||
va_end (args);
|
||||
}
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
LibReinstallProtocolInterfaces (
|
||||
IN OUT EFI_HANDLE *Handle,
|
||||
...
|
||||
)
|
||||
{
|
||||
va_list args;
|
||||
EFI_STATUS Status;
|
||||
EFI_GUID *Protocol;
|
||||
VOID *OldInterface, *NewInterface;
|
||||
EFI_TPL OldTpl;
|
||||
UINTN Index;
|
||||
|
||||
//
|
||||
// Syncronize with notifcations
|
||||
//
|
||||
|
||||
OldTpl = uefi_call_wrapper(BS->RaiseTPL, 1, TPL_NOTIFY);
|
||||
|
||||
//
|
||||
// Install the protocol interfaces
|
||||
//
|
||||
|
||||
Index = 0;
|
||||
Status = EFI_SUCCESS;
|
||||
va_start (args, Handle);
|
||||
|
||||
while (!EFI_ERROR(Status)) {
|
||||
|
||||
//
|
||||
// If protocol is NULL, then it's the end of the list
|
||||
//
|
||||
|
||||
Protocol = va_arg(args, EFI_GUID *);
|
||||
if (!Protocol) {
|
||||
break;
|
||||
}
|
||||
|
||||
OldInterface = va_arg(args, VOID *);
|
||||
NewInterface = va_arg(args, VOID *);
|
||||
|
||||
//
|
||||
// Reinstall it
|
||||
//
|
||||
|
||||
Status = uefi_call_wrapper(BS->ReinstallProtocolInterface, 4, Handle, Protocol, OldInterface, NewInterface);
|
||||
if (EFI_ERROR(Status)) {
|
||||
break;
|
||||
}
|
||||
|
||||
Index += 1;
|
||||
}
|
||||
va_end (args);
|
||||
|
||||
//
|
||||
// If there was an error, undo all the interfaces that were
|
||||
// reinstalled without any errors
|
||||
//
|
||||
|
||||
if (EFI_ERROR(Status)) {
|
||||
va_start (args, Handle);
|
||||
while (Index) {
|
||||
|
||||
Protocol = va_arg(args, EFI_GUID *);
|
||||
OldInterface = va_arg(args, VOID *);
|
||||
NewInterface = va_arg(args, VOID *);
|
||||
|
||||
uefi_call_wrapper(BS->ReinstallProtocolInterface, 4, Handle, Protocol, NewInterface, OldInterface);
|
||||
|
||||
Index -= 1;
|
||||
}
|
||||
va_end (args);
|
||||
}
|
||||
|
||||
//
|
||||
// Done
|
||||
//
|
||||
|
||||
uefi_call_wrapper(BS->RestoreTPL, 1, OldTpl);
|
||||
return Status;
|
||||
}
|
||||
+132
@@ -0,0 +1,132 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
hw.c
|
||||
|
||||
Abstract:
|
||||
|
||||
Debug library functions for Hardware IO access
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
#include "lib.h"
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
InitializeGlobalIoDevice (
|
||||
IN EFI_DEVICE_PATH *DevicePath,
|
||||
IN EFI_GUID *Protocol,
|
||||
IN CHAR8 *ErrorStr EFI_UNUSED,
|
||||
OUT EFI_DEVICE_IO_INTERFACE **GlobalIoFncs
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Check to see if DevicePath exists for a given Protocol. Return Error if it
|
||||
exists. Return GlobalIoFuncs set match the DevicePath
|
||||
|
||||
Arguments:
|
||||
|
||||
DevicePath - to operate on
|
||||
Protocol - to check the DevicePath against
|
||||
ErrorStr - ASCII string to display on error
|
||||
GlobalIoFncs - Returned with DeviceIoProtocol for the DevicePath
|
||||
|
||||
Returns:
|
||||
|
||||
Pass or Fail based on wether GlobalIoFncs where found
|
||||
|
||||
--*/
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_HANDLE Handle;
|
||||
|
||||
//
|
||||
// Check to see if this device path already has Protocol on it.
|
||||
// if so we are loading recursivly and should exit with an error
|
||||
//
|
||||
Status = uefi_call_wrapper(BS->LocateDevicePath, 3, Protocol, &DevicePath, &Handle);
|
||||
if (!EFI_ERROR(Status)) {
|
||||
DEBUG ((D_INIT, "Device Already Loaded for %a device\n", ErrorStr));
|
||||
return EFI_LOAD_ERROR;
|
||||
}
|
||||
|
||||
Status = uefi_call_wrapper(BS->LocateDevicePath, 3, &DeviceIoProtocol, &DevicePath, &Handle);
|
||||
if (!EFI_ERROR(Status)) {
|
||||
Status = uefi_call_wrapper(BS->HandleProtocol, 3, Handle, &DeviceIoProtocol, (VOID*)GlobalIoFncs);
|
||||
}
|
||||
|
||||
ASSERT (!EFI_ERROR(Status));
|
||||
return Status;
|
||||
}
|
||||
|
||||
UINT32
|
||||
ReadPort (
|
||||
IN EFI_DEVICE_IO_INTERFACE *GlobalIoFncs,
|
||||
IN EFI_IO_WIDTH Width,
|
||||
IN UINTN Port
|
||||
)
|
||||
{
|
||||
UINT32 Data;
|
||||
EFI_STATUS Status EFI_UNUSED;
|
||||
|
||||
Status = uefi_call_wrapper(GlobalIoFncs->Io.Read, 5, GlobalIoFncs, Width, (UINT64)Port, 1, &Data);
|
||||
ASSERT(!EFI_ERROR(Status));
|
||||
return Data;
|
||||
}
|
||||
|
||||
UINT32
|
||||
WritePort (
|
||||
IN EFI_DEVICE_IO_INTERFACE *GlobalIoFncs,
|
||||
IN EFI_IO_WIDTH Width,
|
||||
IN UINTN Port,
|
||||
IN UINTN Data
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status EFI_UNUSED;
|
||||
|
||||
Status = uefi_call_wrapper(GlobalIoFncs->Io.Write, 5, GlobalIoFncs, Width, (UINT64)Port, 1, &Data);
|
||||
ASSERT(!EFI_ERROR(Status));
|
||||
return (UINT32)Data;
|
||||
}
|
||||
|
||||
UINT32
|
||||
ReadPciConfig (
|
||||
IN EFI_DEVICE_IO_INTERFACE *GlobalIoFncs,
|
||||
IN EFI_IO_WIDTH Width,
|
||||
IN UINTN Address
|
||||
)
|
||||
{
|
||||
UINT32 Data;
|
||||
EFI_STATUS Status EFI_UNUSED;
|
||||
|
||||
Status = uefi_call_wrapper(GlobalIoFncs->Pci.Read, 5, GlobalIoFncs, Width, (UINT64)Address, 1, &Data);
|
||||
ASSERT(!EFI_ERROR(Status));
|
||||
return Data;
|
||||
}
|
||||
|
||||
UINT32
|
||||
WritePciConfig (
|
||||
IN EFI_DEVICE_IO_INTERFACE *GlobalIoFncs,
|
||||
IN EFI_IO_WIDTH Width,
|
||||
IN UINTN Address,
|
||||
IN UINTN Data
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status EFI_UNUSED;
|
||||
|
||||
Status = uefi_call_wrapper(GlobalIoFncs->Pci.Write, 5, GlobalIoFncs, Width, (UINT64)Address, 1, &Data);
|
||||
ASSERT(!EFI_ERROR(Status));
|
||||
return (UINT32)Data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+209
@@ -0,0 +1,209 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
|
||||
Abstract:
|
||||
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
#include "lib.h"
|
||||
|
||||
VOID
|
||||
EFIDebugVariable (
|
||||
VOID
|
||||
);
|
||||
|
||||
VOID
|
||||
InitializeLib (
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Initializes EFI library for use
|
||||
|
||||
Arguments:
|
||||
|
||||
Firmware's EFI system table
|
||||
|
||||
Returns:
|
||||
|
||||
None
|
||||
|
||||
--*/
|
||||
{
|
||||
EFI_LOADED_IMAGE *LoadedImage;
|
||||
EFI_STATUS Status;
|
||||
CHAR8 *LangCode;
|
||||
|
||||
if (LibInitialized)
|
||||
return;
|
||||
|
||||
LibInitialized = TRUE;
|
||||
LibFwInstance = FALSE;
|
||||
LibImageHandle = ImageHandle;
|
||||
|
||||
//
|
||||
// Set up global pointer to the system table, boot services table,
|
||||
// and runtime services table
|
||||
//
|
||||
|
||||
ST = SystemTable;
|
||||
BS = SystemTable->BootServices;
|
||||
RT = SystemTable->RuntimeServices;
|
||||
// ASSERT (CheckCrc(0, &ST->Hdr));
|
||||
// ASSERT (CheckCrc(0, &BS->Hdr));
|
||||
// ASSERT (CheckCrc(0, &RT->Hdr));
|
||||
|
||||
//
|
||||
// Initialize pool allocation type
|
||||
//
|
||||
|
||||
if (ImageHandle) {
|
||||
Status = uefi_call_wrapper(
|
||||
BS->HandleProtocol,
|
||||
3,
|
||||
ImageHandle,
|
||||
&LoadedImageProtocol,
|
||||
(VOID*)&LoadedImage
|
||||
);
|
||||
|
||||
if (!EFI_ERROR(Status)) {
|
||||
PoolAllocationType = LoadedImage->ImageDataType;
|
||||
}
|
||||
EFIDebugVariable ();
|
||||
}
|
||||
|
||||
//
|
||||
// Initialize Guid table
|
||||
//
|
||||
|
||||
InitializeGuid();
|
||||
|
||||
InitializeLibPlatform(ImageHandle,SystemTable);
|
||||
|
||||
if (ImageHandle && UnicodeInterface == &LibStubUnicodeInterface) {
|
||||
LangCode = LibGetVariable (VarLanguage, &EfiGlobalVariable);
|
||||
InitializeUnicodeSupport (LangCode);
|
||||
if (LangCode) {
|
||||
FreePool (LangCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
VOID
|
||||
InitializeUnicodeSupport (
|
||||
CHAR8 *LangCode
|
||||
)
|
||||
{
|
||||
EFI_UNICODE_COLLATION_INTERFACE *Ui;
|
||||
EFI_STATUS Status;
|
||||
CHAR8 *Languages;
|
||||
UINTN Index, Position, Length;
|
||||
UINTN NoHandles;
|
||||
EFI_HANDLE *Handles;
|
||||
|
||||
//
|
||||
// If we don't know it, lookup the current language code
|
||||
//
|
||||
|
||||
LibLocateHandle (ByProtocol, &UnicodeCollationProtocol, NULL, &NoHandles, &Handles);
|
||||
if (!LangCode || !NoHandles) {
|
||||
goto Done;
|
||||
}
|
||||
|
||||
//
|
||||
// Check all driver's for a matching language code
|
||||
//
|
||||
|
||||
for (Index=0; Index < NoHandles; Index++) {
|
||||
Status = uefi_call_wrapper(BS->HandleProtocol, 3, Handles[Index], &UnicodeCollationProtocol, (VOID*)&Ui);
|
||||
if (EFI_ERROR(Status)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Check for a matching language code
|
||||
//
|
||||
|
||||
Languages = Ui->SupportedLanguages;
|
||||
Length = strlena(Languages);
|
||||
for (Position=0; Position < Length; Position += ISO_639_2_ENTRY_SIZE) {
|
||||
|
||||
//
|
||||
// If this code matches, use this driver
|
||||
//
|
||||
|
||||
if (CompareMem (Languages+Position, LangCode, ISO_639_2_ENTRY_SIZE) == 0) {
|
||||
UnicodeInterface = Ui;
|
||||
goto Done;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Done:
|
||||
//
|
||||
// Cleanup
|
||||
//
|
||||
|
||||
if (Handles) {
|
||||
FreePool (Handles);
|
||||
}
|
||||
}
|
||||
|
||||
VOID
|
||||
EFIDebugVariable (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINT32 Attributes;
|
||||
UINTN DataSize;
|
||||
UINTN NewEFIDebug;
|
||||
|
||||
DataSize = sizeof(EFIDebug);
|
||||
Status = uefi_call_wrapper(RT->GetVariable, 5, u"EFIDebug", &EfiGlobalVariable, &Attributes, &DataSize, &NewEFIDebug);
|
||||
if (!EFI_ERROR(Status)) {
|
||||
EFIDebug = NewEFIDebug;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Calls to memset/memcpy may be emitted implicitly by GCC or MSVC
|
||||
* even when -ffreestanding or /NODEFAULTLIB are in effect.
|
||||
*/
|
||||
|
||||
#ifndef __SIZE_TYPE__
|
||||
#define __SIZE_TYPE__ UINTN
|
||||
#endif
|
||||
|
||||
void *memset(void *s, int c, __SIZE_TYPE__ n)
|
||||
{
|
||||
unsigned char *p = s;
|
||||
|
||||
while (n--)
|
||||
*p++ = c;
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
void *memcpy(void *dest, const void *src, __SIZE_TYPE__ n)
|
||||
{
|
||||
const unsigned char *q = src;
|
||||
unsigned char *p = dest;
|
||||
|
||||
while (n--)
|
||||
*p++ = *q++;
|
||||
|
||||
return dest;
|
||||
}
|
||||
+107
@@ -0,0 +1,107 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
lock.c
|
||||
|
||||
Abstract:
|
||||
|
||||
Implements FLOCK
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
|
||||
#include "lib.h"
|
||||
|
||||
|
||||
VOID
|
||||
InitializeLock (
|
||||
IN OUT FLOCK *Lock,
|
||||
IN EFI_TPL Priority
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Initialize a basic mutual exclusion lock. Each lock
|
||||
provides mutual exclusion access at it's task priority
|
||||
level. Since there is no-premption (at any TPL) or
|
||||
multiprocessor support, acquiring the lock only consists
|
||||
of raising to the locks TPL.
|
||||
|
||||
Note on a debug build the lock is acquired and released
|
||||
to help ensure proper usage.
|
||||
|
||||
Arguments:
|
||||
|
||||
Lock - The FLOCK structure to initialize
|
||||
|
||||
Priority - The task priority level of the lock
|
||||
|
||||
|
||||
Returns:
|
||||
|
||||
An initialized F Lock structure.
|
||||
|
||||
--*/
|
||||
{
|
||||
Lock->Tpl = Priority;
|
||||
Lock->OwnerTpl = 0;
|
||||
Lock->Lock = 0;
|
||||
}
|
||||
|
||||
|
||||
VOID
|
||||
AcquireLock (
|
||||
IN FLOCK *Lock
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Raising to the task priority level of the mutual exclusion
|
||||
lock, and then acquires ownership of the lock.
|
||||
|
||||
Arguments:
|
||||
|
||||
Lock - The lock to acquire
|
||||
|
||||
Returns:
|
||||
|
||||
Lock owned
|
||||
|
||||
--*/
|
||||
{
|
||||
RtAcquireLock (Lock);
|
||||
}
|
||||
|
||||
|
||||
VOID
|
||||
ReleaseLock (
|
||||
IN FLOCK *Lock
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Releases ownership of the mutual exclusion lock, and
|
||||
restores the previous task priority level.
|
||||
|
||||
Arguments:
|
||||
|
||||
Lock - The lock to release
|
||||
|
||||
Returns:
|
||||
|
||||
Lock unowned
|
||||
|
||||
--*/
|
||||
{
|
||||
RtReleaseLock (Lock);
|
||||
}
|
||||
+574
@@ -0,0 +1,574 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
misc.c
|
||||
|
||||
Abstract:
|
||||
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
#include "lib.h"
|
||||
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
VOID *
|
||||
AllocatePool (
|
||||
IN UINTN Size
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
VOID *p;
|
||||
|
||||
Status = uefi_call_wrapper(BS->AllocatePool, 3, PoolAllocationType, Size, &p);
|
||||
if (EFI_ERROR(Status)) {
|
||||
DEBUG((D_ERROR, "AllocatePool: out of pool %x\n", Status));
|
||||
p = NULL;
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
VOID *
|
||||
AllocateZeroPool (
|
||||
IN UINTN Size
|
||||
)
|
||||
{
|
||||
VOID *p;
|
||||
|
||||
p = AllocatePool (Size);
|
||||
if (p) {
|
||||
ZeroMem (p, Size);
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
VOID *
|
||||
EFIAPI
|
||||
ReallocatePool_1 (
|
||||
IN UINTN OldSize,
|
||||
IN UINTN NewSize,
|
||||
IN VOID *OldPool OPTIONAL
|
||||
)
|
||||
{
|
||||
VOID *NewPool;
|
||||
|
||||
NewPool = NULL;
|
||||
if (NewSize) {
|
||||
NewPool = AllocatePool (NewSize);
|
||||
}
|
||||
|
||||
if (OldPool) {
|
||||
if (NewPool) {
|
||||
CopyMem (NewPool, OldPool, OldSize < NewSize ? OldSize : NewSize);
|
||||
}
|
||||
|
||||
FreePool (OldPool);
|
||||
}
|
||||
|
||||
return NewPool;
|
||||
}
|
||||
|
||||
|
||||
VOID
|
||||
FreePool (
|
||||
IN VOID *Buffer
|
||||
)
|
||||
{
|
||||
uefi_call_wrapper(BS->FreePool, 1, Buffer);
|
||||
}
|
||||
|
||||
|
||||
|
||||
VOID
|
||||
ZeroMem (
|
||||
IN VOID *Buffer,
|
||||
IN UINTN Size
|
||||
)
|
||||
{
|
||||
RtZeroMem (Buffer, Size);
|
||||
}
|
||||
|
||||
VOID EFIAPI
|
||||
SetMem (
|
||||
IN VOID *Buffer,
|
||||
IN UINTN Size,
|
||||
IN UINT8 Value
|
||||
)
|
||||
{
|
||||
RtSetMem (Buffer, Size, Value);
|
||||
}
|
||||
|
||||
VOID EFIAPI
|
||||
CopyMem_1 (
|
||||
IN VOID *Dest,
|
||||
IN VOID *Src,
|
||||
IN UINTN len
|
||||
)
|
||||
{
|
||||
RtCopyMem (Dest, Src, len);
|
||||
}
|
||||
|
||||
VOID EFIAPI
|
||||
CopyMemC (
|
||||
IN VOID *Dest,
|
||||
IN CONST VOID *Src,
|
||||
IN UINTN len
|
||||
)
|
||||
{
|
||||
RtCopyMemC (Dest, Src, len);
|
||||
}
|
||||
|
||||
INTN
|
||||
CompareMem (
|
||||
IN CONST VOID *Dest,
|
||||
IN CONST VOID *Src,
|
||||
IN UINTN len
|
||||
)
|
||||
{
|
||||
return RtCompareMem (Dest, Src, len);
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
GrowBuffer(
|
||||
IN OUT EFI_STATUS *Status,
|
||||
IN OUT VOID **Buffer,
|
||||
IN UINTN BufferSize
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Helper function called as part of the code needed
|
||||
to allocate the proper sized buffer for various
|
||||
EFI interfaces.
|
||||
|
||||
Arguments:
|
||||
|
||||
Status - Current status
|
||||
|
||||
Buffer - Current allocated buffer, or NULL
|
||||
|
||||
BufferSize - Current buffer size needed
|
||||
|
||||
Returns:
|
||||
|
||||
TRUE - if the buffer was reallocated and the caller
|
||||
should try the API again.
|
||||
|
||||
--*/
|
||||
{
|
||||
BOOLEAN TryAgain;
|
||||
|
||||
//
|
||||
// If this is an initial request, buffer will be null with a new buffer size
|
||||
//
|
||||
|
||||
if (!*Buffer && BufferSize) {
|
||||
*Status = EFI_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
//
|
||||
// If the status code is "buffer too small", resize the buffer
|
||||
//
|
||||
|
||||
TryAgain = FALSE;
|
||||
if (*Status == EFI_BUFFER_TOO_SMALL) {
|
||||
|
||||
if (*Buffer) {
|
||||
FreePool (*Buffer);
|
||||
}
|
||||
|
||||
*Buffer = AllocatePool (BufferSize);
|
||||
|
||||
if (*Buffer) {
|
||||
TryAgain = TRUE;
|
||||
} else {
|
||||
*Status = EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// If there's an error, free the buffer
|
||||
//
|
||||
|
||||
if (!TryAgain && EFI_ERROR(*Status) && *Buffer) {
|
||||
FreePool (*Buffer);
|
||||
*Buffer = NULL;
|
||||
}
|
||||
|
||||
return TryAgain;
|
||||
}
|
||||
|
||||
|
||||
EFI_MEMORY_DESCRIPTOR *
|
||||
LibMemoryMap (
|
||||
OUT UINTN *NoEntries,
|
||||
OUT UINTN *MapKey,
|
||||
OUT UINTN *DescriptorSize,
|
||||
OUT UINT32 *DescriptorVersion
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_MEMORY_DESCRIPTOR *Buffer;
|
||||
UINTN BufferSize;
|
||||
|
||||
//
|
||||
// Initialize for GrowBuffer loop
|
||||
//
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
Buffer = NULL;
|
||||
BufferSize = sizeof(EFI_MEMORY_DESCRIPTOR);
|
||||
|
||||
//
|
||||
// Call the real function
|
||||
//
|
||||
|
||||
while (GrowBuffer (&Status, (VOID **) &Buffer, BufferSize)) {
|
||||
Status = uefi_call_wrapper(BS->GetMemoryMap, 5, &BufferSize, Buffer, MapKey, DescriptorSize, DescriptorVersion);
|
||||
}
|
||||
|
||||
//
|
||||
// Convert buffer size to NoEntries
|
||||
//
|
||||
|
||||
if (!EFI_ERROR(Status)) {
|
||||
*NoEntries = BufferSize / *DescriptorSize;
|
||||
}
|
||||
|
||||
return Buffer;
|
||||
}
|
||||
|
||||
VOID *
|
||||
LibGetVariableAndSize (
|
||||
IN CHAR16 *Name,
|
||||
IN EFI_GUID *VendorGuid,
|
||||
OUT UINTN *VarSize
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status = EFI_SUCCESS;
|
||||
VOID *Buffer;
|
||||
UINTN BufferSize;
|
||||
|
||||
//
|
||||
// Initialize for GrowBuffer loop
|
||||
//
|
||||
|
||||
Buffer = NULL;
|
||||
BufferSize = 100;
|
||||
|
||||
//
|
||||
// Call the real function
|
||||
//
|
||||
|
||||
while (GrowBuffer (&Status, &Buffer, BufferSize)) {
|
||||
Status = uefi_call_wrapper(
|
||||
RT->GetVariable,
|
||||
5,
|
||||
Name,
|
||||
VendorGuid,
|
||||
NULL,
|
||||
&BufferSize,
|
||||
Buffer
|
||||
);
|
||||
}
|
||||
if (Buffer) {
|
||||
*VarSize = BufferSize;
|
||||
} else {
|
||||
*VarSize = 0;
|
||||
}
|
||||
return Buffer;
|
||||
}
|
||||
|
||||
VOID *
|
||||
LibGetVariable (
|
||||
IN CHAR16 *Name,
|
||||
IN EFI_GUID *VendorGuid
|
||||
)
|
||||
{
|
||||
UINTN VarSize;
|
||||
|
||||
return LibGetVariableAndSize (Name, VendorGuid, &VarSize);
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
LibDeleteVariable (
|
||||
IN CHAR16 *VarName,
|
||||
IN EFI_GUID *VarGuid
|
||||
)
|
||||
{
|
||||
VOID *VarBuf;
|
||||
EFI_STATUS Status;
|
||||
|
||||
VarBuf = LibGetVariable(VarName,VarGuid);
|
||||
|
||||
Status = EFI_NOT_FOUND;
|
||||
|
||||
if (VarBuf) {
|
||||
//
|
||||
// Delete variable from Storage
|
||||
//
|
||||
Status = uefi_call_wrapper(
|
||||
RT->SetVariable,
|
||||
5,
|
||||
VarName, VarGuid,
|
||||
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
|
||||
0, NULL
|
||||
);
|
||||
ASSERT (!EFI_ERROR(Status));
|
||||
FreePool(VarBuf);
|
||||
}
|
||||
|
||||
return (Status);
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
LibSetNVVariable (
|
||||
IN CHAR16 *VarName,
|
||||
IN EFI_GUID *VarGuid,
|
||||
IN UINTN DataSize,
|
||||
IN VOID *Data
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
Status = uefi_call_wrapper(
|
||||
RT->SetVariable,
|
||||
5,
|
||||
VarName, VarGuid,
|
||||
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
|
||||
DataSize, Data
|
||||
);
|
||||
ASSERT (!EFI_ERROR(Status));
|
||||
return (Status);
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
LibSetVariable (
|
||||
IN CHAR16 *VarName,
|
||||
IN EFI_GUID *VarGuid,
|
||||
IN UINTN DataSize,
|
||||
IN VOID *Data
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
Status = uefi_call_wrapper(
|
||||
RT->SetVariable,
|
||||
5,
|
||||
VarName, VarGuid,
|
||||
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
|
||||
DataSize, Data
|
||||
);
|
||||
ASSERT (!EFI_ERROR(Status));
|
||||
return (Status);
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
LibInsertToTailOfBootOrder (
|
||||
IN UINT16 BootOption,
|
||||
IN BOOLEAN OnlyInsertIfEmpty
|
||||
)
|
||||
{
|
||||
UINT16 *BootOptionArray;
|
||||
UINT16 *NewBootOptionArray;
|
||||
UINTN VarSize;
|
||||
UINTN Index;
|
||||
EFI_STATUS Status;
|
||||
|
||||
BootOptionArray = LibGetVariableAndSize (VarBootOrder, &EfiGlobalVariable, &VarSize);
|
||||
if (VarSize != 0 && OnlyInsertIfEmpty) {
|
||||
if (BootOptionArray) {
|
||||
FreePool (BootOptionArray);
|
||||
}
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
VarSize += sizeof(UINT16);
|
||||
NewBootOptionArray = AllocatePool (VarSize);
|
||||
if (!NewBootOptionArray)
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
|
||||
for (Index = 0; Index < ((VarSize/sizeof(UINT16)) - 1); Index++) {
|
||||
NewBootOptionArray[Index] = BootOptionArray[Index];
|
||||
}
|
||||
//
|
||||
// Insert in the tail of the array
|
||||
//
|
||||
NewBootOptionArray[Index] = BootOption;
|
||||
|
||||
Status = uefi_call_wrapper(
|
||||
RT->SetVariable,
|
||||
5,
|
||||
VarBootOrder, &EfiGlobalVariable,
|
||||
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
|
||||
VarSize, (VOID*) NewBootOptionArray
|
||||
);
|
||||
|
||||
FreePool (NewBootOptionArray);
|
||||
if (BootOptionArray) {
|
||||
FreePool (BootOptionArray);
|
||||
}
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
BOOLEAN
|
||||
ValidMBR(
|
||||
IN MASTER_BOOT_RECORD *Mbr,
|
||||
IN EFI_BLOCK_IO *BlkIo
|
||||
)
|
||||
{
|
||||
UINT32 StartingLBA, EndingLBA;
|
||||
UINT32 NewEndingLBA;
|
||||
INTN i, j;
|
||||
BOOLEAN ValidMbr;
|
||||
|
||||
if (Mbr->Signature != MBR_SIGNATURE) {
|
||||
//
|
||||
// The BPB also has this signature, so it can not be used alone.
|
||||
//
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ValidMbr = FALSE;
|
||||
for (i=0; i<MAX_MBR_PARTITIONS; i++) {
|
||||
if ( Mbr->Partition[i].OSIndicator == 0x00 || EXTRACT_UINT32(Mbr->Partition[i].SizeInLBA) == 0 ) {
|
||||
continue;
|
||||
}
|
||||
ValidMbr = TRUE;
|
||||
StartingLBA = EXTRACT_UINT32(Mbr->Partition[i].StartingLBA);
|
||||
EndingLBA = StartingLBA + EXTRACT_UINT32(Mbr->Partition[i].SizeInLBA) - 1;
|
||||
if (EndingLBA > BlkIo->Media->LastBlock) {
|
||||
//
|
||||
// Compatability Errata:
|
||||
// Some systems try to hide drive space with thier INT 13h driver
|
||||
// This does not hide space from the OS driver. This means the MBR
|
||||
// that gets created from DOS is smaller than the MBR created from
|
||||
// a real OS (NT & Win98). This leads to BlkIo->LastBlock being
|
||||
// wrong on some systems FDISKed by the OS.
|
||||
//
|
||||
//
|
||||
if (BlkIo->Media->LastBlock < MIN_MBR_DEVICE_SIZE) {
|
||||
//
|
||||
// If this is a very small device then trust the BlkIo->LastBlock
|
||||
//
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (EndingLBA > (BlkIo->Media->LastBlock + MBR_ERRATA_PAD)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
}
|
||||
for (j=i+1; j<MAX_MBR_PARTITIONS; j++) {
|
||||
if (Mbr->Partition[j].OSIndicator == 0x00 || EXTRACT_UINT32(Mbr->Partition[j].SizeInLBA) == 0) {
|
||||
continue;
|
||||
}
|
||||
if ( EXTRACT_UINT32(Mbr->Partition[j].StartingLBA) >= StartingLBA &&
|
||||
EXTRACT_UINT32(Mbr->Partition[j].StartingLBA) <= EndingLBA ) {
|
||||
//
|
||||
// The Start of this region overlaps with the i'th region
|
||||
//
|
||||
return FALSE;
|
||||
}
|
||||
NewEndingLBA = EXTRACT_UINT32(Mbr->Partition[j].StartingLBA) + EXTRACT_UINT32(Mbr->Partition[j].SizeInLBA) - 1;
|
||||
if ( NewEndingLBA >= StartingLBA && NewEndingLBA <= EndingLBA ) {
|
||||
//
|
||||
// The End of this region overlaps with the i'th region
|
||||
//
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
//
|
||||
// Non of the regions overlapped so MBR is O.K.
|
||||
//
|
||||
return ValidMbr;
|
||||
}
|
||||
|
||||
|
||||
UINT8
|
||||
DecimaltoBCD(
|
||||
IN UINT8 DecValue
|
||||
)
|
||||
{
|
||||
return RtDecimaltoBCD (DecValue);
|
||||
}
|
||||
|
||||
|
||||
UINT8
|
||||
BCDtoDecimal(
|
||||
IN UINT8 BcdValue
|
||||
)
|
||||
{
|
||||
return RtBCDtoDecimal (BcdValue);
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
LibGetSystemConfigurationTable(
|
||||
IN EFI_GUID *TableGuid,
|
||||
IN OUT VOID **Table
|
||||
)
|
||||
|
||||
{
|
||||
UINTN Index;
|
||||
|
||||
for(Index=0;Index<ST->NumberOfTableEntries;Index++) {
|
||||
if (CompareGuid(TableGuid,&(ST->ConfigurationTable[Index].VendorGuid))) {
|
||||
*Table = ST->ConfigurationTable[Index].VendorTable;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
}
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
|
||||
CHAR16 *
|
||||
LibGetUiString (
|
||||
IN EFI_HANDLE Handle,
|
||||
IN UI_STRING_TYPE StringType,
|
||||
IN ISO_639_2 *LangCode,
|
||||
IN BOOLEAN ReturnDevicePathStrOnMismatch
|
||||
)
|
||||
{
|
||||
UI_INTERFACE *Ui;
|
||||
UI_STRING_TYPE Index;
|
||||
UI_STRING_ENTRY *Array;
|
||||
EFI_STATUS Status;
|
||||
|
||||
Status = uefi_call_wrapper(BS->HandleProtocol, 3, Handle, &UiProtocol, (VOID *)&Ui);
|
||||
if (EFI_ERROR(Status)) {
|
||||
return (ReturnDevicePathStrOnMismatch) ? DevicePathToStr(DevicePathFromHandle(Handle)) : NULL;
|
||||
}
|
||||
|
||||
//
|
||||
// Skip the first strings
|
||||
//
|
||||
for (Index = UiDeviceString, Array = Ui->Entry; Index < StringType; Index++, Array++) {
|
||||
while (Array->LangCode) {
|
||||
Array++;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Search for the match
|
||||
//
|
||||
while (Array->LangCode) {
|
||||
if (strcmpa (Array->LangCode, LangCode) == 0) {
|
||||
return Array->UiString;
|
||||
}
|
||||
}
|
||||
return (ReturnDevicePathStrOnMismatch) ? DevicePathToStr(DevicePathFromHandle(Handle)) : NULL;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
#include "lib.h"
|
||||
|
||||
VOID
|
||||
Pause(
|
||||
VOID
|
||||
)
|
||||
// Pause until any key is pressed
|
||||
{
|
||||
EFI_INPUT_KEY Key;
|
||||
EFI_STATUS Status EFI_UNUSED;
|
||||
|
||||
WaitForSingleEvent(ST->ConIn->WaitForKey, 0);
|
||||
Status = uefi_call_wrapper(ST->ConIn->ReadKeyStroke, 2, ST->ConIn, &Key);
|
||||
ASSERT(!EFI_ERROR(Status));
|
||||
}
|
||||
+805
@@ -0,0 +1,805 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
print.c
|
||||
|
||||
Abstract:
|
||||
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
#include "lib.h"
|
||||
#include "internal/print.h"
|
||||
#include "internal/va_print.h"
|
||||
|
||||
|
||||
/* VA types/functions can be used if used internally so we can use default va_list always here */
|
||||
|
||||
|
||||
//
|
||||
// Declare runtime functions
|
||||
//
|
||||
|
||||
#ifdef RUNTIME_CODE
|
||||
#ifndef __GNUC__
|
||||
#pragma RUNTIME_CODE(DbgPrint)
|
||||
|
||||
// For debugging..
|
||||
|
||||
/*
|
||||
#pragma RUNTIME_CODE(ValueToHex)
|
||||
#pragma RUNTIME_CODE(ValueToString)
|
||||
#pragma RUNTIME_CODE(TimeToString)
|
||||
*/
|
||||
|
||||
#endif /* !defined(__GNUC__) */
|
||||
#endif
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
INTN
|
||||
DbgPrint (
|
||||
IN INTN mask,
|
||||
IN CONST CHAR8 *fmt,
|
||||
...
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Prints a formatted unicode string to the default StandardError console
|
||||
|
||||
Arguments:
|
||||
|
||||
mask - Bit mask of debug string. If a bit is set in the
|
||||
mask that is also set in EFIDebug the string is
|
||||
printed; otherwise, the string is not printed
|
||||
|
||||
fmt - Format string
|
||||
|
||||
Returns:
|
||||
|
||||
Length of string printed to the StandardError console
|
||||
|
||||
--*/
|
||||
{
|
||||
SIMPLE_TEXT_OUTPUT_INTERFACE *DbgOut;
|
||||
PRINT_STATE ps;
|
||||
va_list args;
|
||||
UINTN back;
|
||||
UINTN attr;
|
||||
UINTN SavedAttribute;
|
||||
|
||||
|
||||
if (!(EFIDebug & mask)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
va_start (args, fmt);
|
||||
ZeroMem (&ps, sizeof(ps));
|
||||
|
||||
ps.Output = _DbgOut;
|
||||
ps.fmt.Ascii = TRUE;
|
||||
ps.fmt.pc = fmt;
|
||||
va_copy(ps.args, args);
|
||||
ps.Attr = EFI_TEXT_ATTR(EFI_LIGHTGRAY, EFI_RED);
|
||||
|
||||
DbgOut = LibRuntimeDebugOut;
|
||||
|
||||
if (!DbgOut) {
|
||||
DbgOut = ST->StdErr;
|
||||
}
|
||||
|
||||
if (DbgOut) {
|
||||
ps.Attr = DbgOut->Mode->Attribute;
|
||||
ps.Context = DbgOut;
|
||||
ps.SetAttr = (INTN (EFIAPI *)(VOID *, UINTN)) DbgOut->SetAttribute;
|
||||
}
|
||||
|
||||
SavedAttribute = ps.Attr;
|
||||
|
||||
back = (ps.Attr >> 4) & 0xf;
|
||||
ps.AttrNorm = EFI_TEXT_ATTR(EFI_LIGHTGRAY, back);
|
||||
ps.AttrHighlight = EFI_TEXT_ATTR(EFI_WHITE, back);
|
||||
ps.AttrError = EFI_TEXT_ATTR(EFI_YELLOW, back);
|
||||
|
||||
attr = ps.AttrNorm;
|
||||
|
||||
if (mask & D_WARN) {
|
||||
attr = ps.AttrHighlight;
|
||||
}
|
||||
|
||||
if (mask & D_ERROR) {
|
||||
attr = ps.AttrError;
|
||||
}
|
||||
|
||||
if (ps.SetAttr) {
|
||||
ps.Attr = attr;
|
||||
uefi_call_wrapper(ps.SetAttr, 2, ps.Context, attr);
|
||||
}
|
||||
|
||||
_Print (&ps);
|
||||
|
||||
va_end (ps.args);
|
||||
va_end (args);
|
||||
|
||||
//
|
||||
// Restore original attributes
|
||||
//
|
||||
|
||||
if (ps.SetAttr) {
|
||||
uefi_call_wrapper(ps.SetAttr, 2, ps.Context, SavedAttribute);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
INTN EFIAPI
|
||||
_DbgOut (
|
||||
IN VOID *Context,
|
||||
IN CHAR16 *Buffer
|
||||
)
|
||||
// Append string worker for DbgPrint
|
||||
{
|
||||
SIMPLE_TEXT_OUTPUT_INTERFACE *DbgOut;
|
||||
|
||||
DbgOut = Context;
|
||||
// if (!DbgOut && ST && ST->ConOut) {
|
||||
// DbgOut = ST->ConOut;
|
||||
// }
|
||||
|
||||
if (DbgOut) {
|
||||
if (IsLocalPrint(DbgOut->OutputString))
|
||||
DbgOut->OutputString(DbgOut, Buffer);
|
||||
else
|
||||
uefi_call_wrapper(DbgOut->OutputString, 2, DbgOut, Buffer);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
INTN EFIAPI
|
||||
_SPrint (
|
||||
IN VOID *Context,
|
||||
IN CHAR16 *Buffer
|
||||
)
|
||||
// Append string worker for UnicodeSPrint, PoolPrint and CatPrint
|
||||
{
|
||||
UINTN len;
|
||||
POOL_PRINT *spc;
|
||||
|
||||
spc = Context;
|
||||
len = StrLen(Buffer);
|
||||
|
||||
//
|
||||
// Is the string is over the max truncate it
|
||||
//
|
||||
|
||||
if (spc->len + len > spc->maxlen) {
|
||||
len = spc->maxlen - spc->len;
|
||||
}
|
||||
|
||||
//
|
||||
// Append the new text
|
||||
//
|
||||
|
||||
CopyMem (spc->str + spc->len, Buffer, len * sizeof(CHAR16));
|
||||
spc->len += len;
|
||||
|
||||
//
|
||||
// Null terminate it
|
||||
//
|
||||
|
||||
if (spc->len < spc->maxlen) {
|
||||
spc->str[spc->len] = 0;
|
||||
} else if (spc->maxlen) {
|
||||
spc->str[spc->maxlen] = 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
INTN EFIAPI
|
||||
_PoolPrint (
|
||||
IN VOID *Context,
|
||||
IN CHAR16 *Buffer
|
||||
)
|
||||
// Append string worker for PoolPrint and CatPrint
|
||||
{
|
||||
UINTN newlen;
|
||||
POOL_PRINT *spc;
|
||||
|
||||
spc = Context;
|
||||
newlen = spc->len + StrLen(Buffer) + 1;
|
||||
|
||||
//
|
||||
// Is the string is over the max, grow the buffer
|
||||
//
|
||||
|
||||
if (newlen > spc->maxlen) {
|
||||
|
||||
//
|
||||
// Grow the pool buffer
|
||||
//
|
||||
|
||||
newlen += PRINT_STRING_LEN;
|
||||
spc->maxlen = newlen;
|
||||
spc->str = ReallocatePool (
|
||||
spc->len * sizeof(CHAR16),
|
||||
spc->maxlen * sizeof(CHAR16),
|
||||
spc->str
|
||||
);
|
||||
|
||||
if (!spc->str) {
|
||||
spc->len = 0;
|
||||
spc->maxlen = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Append the new text
|
||||
//
|
||||
|
||||
return _SPrint (Context, Buffer);
|
||||
}
|
||||
|
||||
UINTN
|
||||
UnicodeSPrint (
|
||||
OUT CHAR16 *Str,
|
||||
IN UINTN StrSize,
|
||||
IN CONST CHAR16 *fmt,
|
||||
...
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Prints a formatted unicode string to a buffer
|
||||
|
||||
Arguments:
|
||||
|
||||
Str - Output buffer to print the formatted string into
|
||||
|
||||
StrSize - Size of Str. String is truncated to this size.
|
||||
A size of 0 means there is no limit
|
||||
|
||||
fmt - The format string
|
||||
|
||||
Returns:
|
||||
|
||||
String length returned in buffer
|
||||
|
||||
--*/
|
||||
{
|
||||
va_list args;
|
||||
UINTN len;
|
||||
|
||||
va_start (args, fmt);
|
||||
len = UnicodeVSPrint(Str, StrSize, fmt, args);
|
||||
va_end (args);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
UINTN
|
||||
AsciiSPrint (
|
||||
OUT CHAR8 *Str,
|
||||
IN UINTN StrSize,
|
||||
IN CONST CHAR8 *fmt,
|
||||
...
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Prints a formatted unicode string to a buffer
|
||||
|
||||
Arguments:
|
||||
|
||||
Str - Output buffer to print the formatted string into
|
||||
|
||||
StrSize - Size of Str. String is truncated to this size.
|
||||
A size of 0 means there is no limit
|
||||
|
||||
fmt - The format string
|
||||
|
||||
Returns:
|
||||
|
||||
String length returned in buffer
|
||||
|
||||
--*/
|
||||
{
|
||||
va_list args;
|
||||
UINTN len;
|
||||
|
||||
va_start (args, fmt);
|
||||
len = AsciiVSPrint(Str, StrSize, fmt, args);
|
||||
va_end (args);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
CHAR16 *
|
||||
PoolPrint (
|
||||
IN CONST CHAR16 *fmt,
|
||||
...
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Prints a formatted unicode string to allocated pool. The caller
|
||||
must free the resulting buffer.
|
||||
|
||||
Arguments:
|
||||
|
||||
fmt - The format string
|
||||
|
||||
Returns:
|
||||
|
||||
Allocated buffer with the formatted string printed in it.
|
||||
The caller must free the allocated buffer. The buffer
|
||||
allocation is not packed.
|
||||
|
||||
--*/
|
||||
{
|
||||
va_list args;
|
||||
CHAR16 *pool;
|
||||
va_start (args, fmt);
|
||||
pool = VPoolPrint(fmt, args);
|
||||
va_end (args);
|
||||
return pool;
|
||||
}
|
||||
|
||||
CHAR16 *
|
||||
CatPrint (
|
||||
IN OUT POOL_PRINT *Str,
|
||||
IN CONST CHAR16 *fmt,
|
||||
...
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Concatenates a formatted unicode string to allocated pool.
|
||||
The caller must free the resulting buffer.
|
||||
|
||||
Arguments:
|
||||
|
||||
Str - Tracks the allocated pool, size in use, and
|
||||
amount of pool allocated.
|
||||
|
||||
fmt - The format string
|
||||
|
||||
Returns:
|
||||
|
||||
Allocated buffer with the formatted string printed in it.
|
||||
The caller must free the allocated buffer. The buffer
|
||||
allocation is not packed.
|
||||
|
||||
--*/
|
||||
{
|
||||
va_list args;
|
||||
|
||||
va_start (args, fmt);
|
||||
_PoolCatPrint (fmt, args, Str, _PoolPrint);
|
||||
va_end (args);
|
||||
return Str->str;
|
||||
}
|
||||
|
||||
|
||||
|
||||
UINTN
|
||||
Print (
|
||||
IN CONST CHAR16 *fmt,
|
||||
...
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Prints a formatted unicode string to the default console
|
||||
|
||||
Arguments:
|
||||
|
||||
fmt - Format string
|
||||
|
||||
Returns:
|
||||
|
||||
Length of string printed to the console
|
||||
|
||||
--*/
|
||||
{
|
||||
va_list args;
|
||||
UINTN back;
|
||||
|
||||
va_start (args, fmt);
|
||||
back = _IPrint ((UINTN) -1, (UINTN) -1, ST->ConOut, fmt, NULL, args);
|
||||
va_end (args);
|
||||
return back;
|
||||
}
|
||||
|
||||
|
||||
UINTN
|
||||
PrintAt (
|
||||
IN UINTN Column,
|
||||
IN UINTN Row,
|
||||
IN CONST CHAR16 *fmt,
|
||||
...
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Prints a formatted unicode string to the default console, at
|
||||
the supplied cursor position
|
||||
|
||||
Arguments:
|
||||
|
||||
Column, Row - The cursor position to print the string at
|
||||
|
||||
fmt - Format string
|
||||
|
||||
Returns:
|
||||
|
||||
Length of string printed to the console
|
||||
|
||||
--*/
|
||||
{
|
||||
va_list args;
|
||||
UINTN back;
|
||||
|
||||
va_start (args, fmt);
|
||||
back = _IPrint (Column, Row, ST->ConOut, fmt, NULL, args);
|
||||
va_end (args);
|
||||
return back;
|
||||
}
|
||||
|
||||
|
||||
UINTN
|
||||
IPrint (
|
||||
IN SIMPLE_TEXT_OUTPUT_INTERFACE *Out,
|
||||
IN CONST CHAR16 *fmt,
|
||||
...
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Prints a formatted unicode string to the specified console
|
||||
|
||||
Arguments:
|
||||
|
||||
Out - The console to print the string too
|
||||
|
||||
fmt - Format string
|
||||
|
||||
Returns:
|
||||
|
||||
Length of string printed to the console
|
||||
|
||||
--*/
|
||||
{
|
||||
va_list args;
|
||||
UINTN back;
|
||||
|
||||
va_start (args, fmt);
|
||||
back = _IPrint ((UINTN) -1, (UINTN) -1, Out, fmt, NULL, args);
|
||||
va_end (args);
|
||||
return back;
|
||||
}
|
||||
|
||||
|
||||
UINTN
|
||||
IPrintAt (
|
||||
IN SIMPLE_TEXT_OUTPUT_INTERFACE *Out,
|
||||
IN UINTN Column,
|
||||
IN UINTN Row,
|
||||
IN CONST CHAR16 *fmt,
|
||||
...
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Prints a formatted unicode string to the specified console, at
|
||||
the supplied cursor position
|
||||
|
||||
Arguments:
|
||||
|
||||
Out - The console to print the string to
|
||||
|
||||
Column, Row - The cursor position to print the string at
|
||||
|
||||
fmt - Format string
|
||||
|
||||
Returns:
|
||||
|
||||
Length of string printed to the console
|
||||
|
||||
--*/
|
||||
{
|
||||
va_list args;
|
||||
UINTN back;
|
||||
|
||||
va_start (args, fmt);
|
||||
back = _IPrint (Column, Row, Out, fmt, NULL, args);
|
||||
va_end (args);
|
||||
return back;
|
||||
}
|
||||
|
||||
|
||||
UINTN
|
||||
AsciiPrint (
|
||||
IN CONST CHAR8 *fmt,
|
||||
...
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
For those whom really can't deal with unicode, a print
|
||||
function that takes an ascii format string
|
||||
|
||||
Arguments:
|
||||
|
||||
fmt - ascii format string
|
||||
|
||||
Returns:
|
||||
|
||||
Length of string printed to the console
|
||||
|
||||
--*/
|
||||
|
||||
{
|
||||
va_list args;
|
||||
UINTN back;
|
||||
|
||||
va_start (args, fmt);
|
||||
back = _IPrint ((UINTN) -1, (UINTN) -1, ST->ConOut, NULL, fmt, args);
|
||||
va_end (args);
|
||||
return back;
|
||||
}
|
||||
|
||||
|
||||
STATIC CHAR8 Hex[] = {'0','1','2','3','4','5','6','7',
|
||||
'8','9','A','B','C','D','E','F'};
|
||||
|
||||
VOID
|
||||
ValueToHex (
|
||||
IN CHAR16 *Buffer,
|
||||
IN UINT64 v
|
||||
)
|
||||
{
|
||||
CHAR8 str[30], *p1;
|
||||
CHAR16 *p2;
|
||||
|
||||
if (!v) {
|
||||
Buffer[0] = '0';
|
||||
Buffer[1] = 0;
|
||||
return ;
|
||||
}
|
||||
|
||||
p1 = str;
|
||||
p2 = Buffer;
|
||||
|
||||
while (v) {
|
||||
// Without the cast, the MSVC compiler may insert a reference to __allmull
|
||||
*(p1++) = Hex[(UINTN)(v & 0xf)];
|
||||
v = RShiftU64 (v, 4);
|
||||
}
|
||||
|
||||
while (p1 != str) {
|
||||
*(p2++) = *(--p1);
|
||||
}
|
||||
*p2 = 0;
|
||||
}
|
||||
|
||||
|
||||
VOID
|
||||
ValueToString (
|
||||
IN CHAR16 *Buffer,
|
||||
IN BOOLEAN Comma,
|
||||
IN INT64 v
|
||||
)
|
||||
{
|
||||
STATIC CHAR8 ca[] = { 3, 1, 2 };
|
||||
CHAR8 str[40], *p1;
|
||||
CHAR16 *p2;
|
||||
UINTN c, r;
|
||||
|
||||
if (!v) {
|
||||
Buffer[0] = '0';
|
||||
Buffer[1] = 0;
|
||||
return ;
|
||||
}
|
||||
|
||||
p1 = str;
|
||||
p2 = Buffer;
|
||||
|
||||
if (v < 0) {
|
||||
*(p2++) = '-';
|
||||
v = -v;
|
||||
}
|
||||
|
||||
while (v) {
|
||||
v = (INT64)DivU64x32 ((UINT64)v, 10, &r);
|
||||
*(p1++) = (CHAR8)r + '0';
|
||||
}
|
||||
|
||||
c = (UINTN) (Comma ? ca[(p1 - str) % 3] : 999) + 1;
|
||||
while (p1 != str) {
|
||||
|
||||
c -= 1;
|
||||
if (!c) {
|
||||
*(p2++) = ',';
|
||||
c = 3;
|
||||
}
|
||||
|
||||
*(p2++) = *(--p1);
|
||||
}
|
||||
*p2 = 0;
|
||||
}
|
||||
|
||||
// Having this call inlined by VS2022 on Release builds produces an
|
||||
// "Undefined OpCode Exception" on ARM32 whenever Print() is invoked,
|
||||
// even when no part of the code below is actually being executed...
|
||||
// For safety, add an explicit clause to prevent inlining on all platforms.
|
||||
EFI_NOINLINE
|
||||
VOID
|
||||
FloatToString (
|
||||
IN CHAR16 *Buffer,
|
||||
IN BOOLEAN Comma,
|
||||
IN double v
|
||||
)
|
||||
{
|
||||
/*
|
||||
* Integer part.
|
||||
*/
|
||||
INTN i = (INTN)v;
|
||||
ValueToString(Buffer, Comma, i);
|
||||
|
||||
|
||||
/*
|
||||
* Decimal point.
|
||||
*/
|
||||
UINTN x = StrLen(Buffer);
|
||||
Buffer[x] = u'.';
|
||||
x++;
|
||||
|
||||
|
||||
/*
|
||||
* Keep fractional part.
|
||||
*/
|
||||
float f = (float)(v - i);
|
||||
if (f < 0) f = -f;
|
||||
|
||||
|
||||
/*
|
||||
* Leading fractional zeroes.
|
||||
*/
|
||||
f *= 10.0;
|
||||
while ( (f != 0)
|
||||
&& ((INTN)f == 0))
|
||||
{
|
||||
Buffer[x] = u'0';
|
||||
x++;
|
||||
f *= 10.0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Fractional digits.
|
||||
*/
|
||||
while ((float)(INTN)f != f)
|
||||
{
|
||||
f *= 10;
|
||||
}
|
||||
ValueToString(Buffer + x, FALSE, (INTN)f);
|
||||
return;
|
||||
}
|
||||
|
||||
VOID
|
||||
TimeToString (
|
||||
OUT CHAR16 *Buffer,
|
||||
IN EFI_TIME *Time
|
||||
)
|
||||
{
|
||||
UINTN Hour, Year;
|
||||
CHAR16 AmPm;
|
||||
|
||||
AmPm = 'a';
|
||||
Hour = Time->Hour;
|
||||
if (Time->Hour == 0) {
|
||||
Hour = 12;
|
||||
} else if (Time->Hour >= 12) {
|
||||
AmPm = 'p';
|
||||
if (Time->Hour >= 13) {
|
||||
Hour -= 12;
|
||||
}
|
||||
}
|
||||
|
||||
Year = Time->Year % 100;
|
||||
|
||||
// bugbug: for now just print it any old way
|
||||
UnicodeSPrint (Buffer, 0, u"%02d/%02d/%02d %02d:%02d%c",
|
||||
Time->Month,
|
||||
Time->Day,
|
||||
Year,
|
||||
Hour,
|
||||
Time->Minute,
|
||||
AmPm
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
VOID
|
||||
DumpHex (
|
||||
IN UINTN Indent,
|
||||
IN UINTN Offset,
|
||||
IN UINTN DataSize,
|
||||
IN VOID *UserData
|
||||
)
|
||||
{
|
||||
CHAR8 *Data, Val[50], Str[20], c;
|
||||
UINTN Size, Index;
|
||||
|
||||
UINTN ScreenCount;
|
||||
UINTN TempColumn;
|
||||
UINTN ScreenSize;
|
||||
CHAR16 ReturnStr[1];
|
||||
|
||||
|
||||
uefi_call_wrapper(ST->ConOut->QueryMode, 4, ST->ConOut, ST->ConOut->Mode->Mode, &TempColumn, &ScreenSize);
|
||||
ScreenCount = 0;
|
||||
ScreenSize -= 2;
|
||||
|
||||
Data = UserData;
|
||||
while (DataSize) {
|
||||
Size = 16;
|
||||
if (Size > DataSize) {
|
||||
Size = DataSize;
|
||||
}
|
||||
|
||||
for (Index=0; Index < Size; Index += 1) {
|
||||
c = Data[Index];
|
||||
Val[Index*3+0] = Hex[c>>4];
|
||||
Val[Index*3+1] = Hex[c&0xF];
|
||||
Val[Index*3+2] = (Index == 7)?'-':' ';
|
||||
Str[Index] = (c < ' ' || c > 'z') ? '.' : c;
|
||||
}
|
||||
|
||||
Val[Index*3] = 0;
|
||||
Str[Index] = 0;
|
||||
Print (u"%*a%X: %-.48a *%a*\n", Indent, "", Offset, Val, Str);
|
||||
|
||||
Data += Size;
|
||||
Offset += Size;
|
||||
DataSize -= Size;
|
||||
|
||||
ScreenCount++;
|
||||
if (ScreenCount >= ScreenSize && ScreenSize != 0) {
|
||||
//
|
||||
// If ScreenSize == 0 we have the console redirected so don't
|
||||
// block updates
|
||||
//
|
||||
ScreenCount = 0;
|
||||
Print (u"Press Enter to continue :");
|
||||
Input (u"", ReturnStr, sizeof(ReturnStr)/sizeof(CHAR16));
|
||||
Print (u"\n");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,203 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 1999 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
EfiRtLib.h
|
||||
|
||||
Abstract:
|
||||
|
||||
EFI Runtime library functions
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
#include "efi.h"
|
||||
#include "efilib.h"
|
||||
#include "efirtlib.h"
|
||||
|
||||
#ifndef __GNUC__
|
||||
#pragma RUNTIME_CODE(RtZeroMem)
|
||||
#endif
|
||||
VOID
|
||||
RUNTIMEFUNCTION
|
||||
RtZeroMem (
|
||||
IN VOID *Buffer,
|
||||
IN UINTN Size
|
||||
)
|
||||
{
|
||||
UINT8 *pt;
|
||||
|
||||
pt = Buffer;
|
||||
while (Size--) {
|
||||
*(pt++) = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef __GNUC__
|
||||
#pragma RUNTIME_CODE(RtSetMem)
|
||||
#endif
|
||||
VOID
|
||||
EFIAPI
|
||||
RUNTIMEFUNCTION
|
||||
RtSetMem (
|
||||
IN VOID *Buffer,
|
||||
IN UINTN Size,
|
||||
IN UINT8 Value
|
||||
)
|
||||
{
|
||||
UINT8 *pt;
|
||||
|
||||
pt = Buffer;
|
||||
while (Size--) {
|
||||
*(pt++) = Value;
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef __GNUC__
|
||||
#pragma RUNTIME_CODE(RtCopyMem)
|
||||
#endif
|
||||
VOID
|
||||
EFIAPI
|
||||
RUNTIMEFUNCTION
|
||||
RtCopyMem (
|
||||
IN VOID *Dest,
|
||||
IN VOID *Src,
|
||||
IN UINTN len
|
||||
)
|
||||
{
|
||||
UINT8 *d, *s;
|
||||
|
||||
d = Dest;
|
||||
s = Src;
|
||||
|
||||
if (d == NULL || s == NULL || s == d)
|
||||
return;
|
||||
|
||||
// If the beginning of the destination range overlaps with the end of
|
||||
// the source range, make sure to start the copy from the end so that
|
||||
// we don't end up overwriting source data that we need for the copy.
|
||||
if ((d > s) && (d < s + len)) {
|
||||
for (d += len, s += len; len--; )
|
||||
*--d = *--s;
|
||||
} else {
|
||||
while (len--)
|
||||
*d++ = *s++;
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef __GNUC__
|
||||
#pragma RUNTIME_CODE(RtCopyMemC)
|
||||
#endif
|
||||
VOID
|
||||
EFIAPI
|
||||
RUNTIMEFUNCTION
|
||||
RtCopyMemC (
|
||||
IN VOID *Dest,
|
||||
IN CONST VOID *Src,
|
||||
IN UINTN len
|
||||
)
|
||||
{
|
||||
/* CopyMem matches ISO C apart from the change to NON-CONST Src
|
||||
Overwriting Src is an intended outcome if overlapping occurs (per memmove)
|
||||
This function is useful to avoid GCC dying in changing pointer setup
|
||||
*/
|
||||
RtCopyMem(Dest, (VOID*)Src, len);
|
||||
}
|
||||
|
||||
#ifndef __GNUC__
|
||||
#pragma RUNTIME_CODE(RtCompareMem)
|
||||
#endif
|
||||
INTN
|
||||
RUNTIMEFUNCTION
|
||||
RtCompareMem (
|
||||
IN CONST VOID *Dest,
|
||||
IN CONST VOID *Src,
|
||||
IN UINTN len
|
||||
)
|
||||
{
|
||||
CONST UINT8 *d, *s;
|
||||
|
||||
d = Dest;
|
||||
s = Src;
|
||||
|
||||
while (len--) {
|
||||
if (*d != *s) {
|
||||
return *d - *s;
|
||||
}
|
||||
|
||||
d += 1;
|
||||
s += 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
typedef UINT32 QUAD_UINT32[4]; /* EFI_GUID is 128 bits so 32 x 4 */
|
||||
|
||||
#ifndef __GNUC__
|
||||
#pragma RUNTIME_CODE(RtCompareGuid)
|
||||
#endif
|
||||
BOOLEAN
|
||||
EFIAPI
|
||||
RUNTIMEFUNCTION
|
||||
RtCompareGuid (
|
||||
IN CONST EFI_GUID *Guid1,
|
||||
IN CONST EFI_GUID *Guid2
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Compares two GUIDs
|
||||
|
||||
Arguments:
|
||||
|
||||
Guid1 - guid to compare
|
||||
Guid2 - guid to compare
|
||||
|
||||
Returns:
|
||||
= 1 if Guid1 == Guid2
|
||||
|
||||
--*/
|
||||
{
|
||||
CONST QUAD_UINT32 *g1, *g2;
|
||||
UINT32 r;
|
||||
|
||||
//
|
||||
// Compare 32 bits at a time
|
||||
//
|
||||
|
||||
g1 = (CONST QUAD_UINT32*)Guid1;
|
||||
g2 = (CONST QUAD_UINT32*)Guid2;
|
||||
|
||||
r = (*g1)[0] - (*g2)[0];
|
||||
r |= (*g1)[1] - (*g2)[1];
|
||||
r |= (*g1)[2] - (*g2)[2];
|
||||
r |= (*g1)[3] - (*g2)[3];
|
||||
|
||||
if (r==0) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef __GNUC__
|
||||
#pragma RUNTIME_CODE(RtIsZeroGuid)
|
||||
#endif
|
||||
BOOLEAN
|
||||
EFIAPI
|
||||
RUNTIMEFUNCTION
|
||||
RtIsZeroGuid (
|
||||
IN CONST EFI_GUID *Guid1
|
||||
)
|
||||
{
|
||||
return RtCompareGuid(Guid1, &gZeroGuid);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
data.c
|
||||
|
||||
Abstract:
|
||||
|
||||
EFI library global data
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
#include "lib.h"
|
||||
|
||||
|
||||
//
|
||||
// These globals are runtime globals
|
||||
//
|
||||
// N.B. The Microsoft C compiler will only put the data in the
|
||||
// right data section if it is explicitly initialized..
|
||||
//
|
||||
|
||||
#ifndef __GNUC__
|
||||
#pragma BEGIN_RUNTIME_DATA()
|
||||
#endif
|
||||
|
||||
//
|
||||
// RT - pointer to the runtime table
|
||||
//
|
||||
|
||||
EFI_RUNTIME_SERVICES *RT;
|
||||
|
||||
//
|
||||
// LibStandalone - TRUE if lib is linked in as part of the firmware.
|
||||
// N.B. The EFI fw sets this value directly
|
||||
//
|
||||
|
||||
BOOLEAN LibFwInstance;
|
||||
|
||||
//
|
||||
// EFIDebug - Debug mask
|
||||
//
|
||||
|
||||
UINTN EFIDebug = EFI_DBUG_MASK;
|
||||
|
||||
//
|
||||
// LibRuntimeDebugOut - Runtime Debug Output device
|
||||
//
|
||||
|
||||
SIMPLE_TEXT_OUTPUT_INTERFACE *LibRuntimeDebugOut;
|
||||
|
||||
//
|
||||
// LibRuntimeRaiseTPL, LibRuntimeRestoreTPL - pointers to Runtime functions from the
|
||||
// Boot Services Table
|
||||
//
|
||||
|
||||
EFI_RAISE_TPL LibRuntimeRaiseTPL = NULL;
|
||||
EFI_RESTORE_TPL LibRuntimeRestoreTPL = NULL;
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
lock.c
|
||||
|
||||
Abstract:
|
||||
|
||||
Implements FLOCK
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
|
||||
#include "lib.h"
|
||||
|
||||
|
||||
|
||||
#ifndef __GNUC__
|
||||
#pragma RUNTIME_CODE(RtAcquireLock)
|
||||
#endif
|
||||
VOID
|
||||
RtAcquireLock (
|
||||
IN FLOCK *Lock
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Raising to the task priority level of the mutual exclusion
|
||||
lock, and then acquires ownership of the lock.
|
||||
|
||||
Arguments:
|
||||
|
||||
Lock - The lock to acquire
|
||||
|
||||
Returns:
|
||||
|
||||
Lock owned
|
||||
|
||||
--*/
|
||||
{
|
||||
if (BS) {
|
||||
if (BS->RaiseTPL != NULL) {
|
||||
Lock->OwnerTpl = uefi_call_wrapper(BS->RaiseTPL, 1, Lock->Tpl);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (LibRuntimeRaiseTPL != NULL) {
|
||||
Lock->OwnerTpl = LibRuntimeRaiseTPL(Lock->Tpl);
|
||||
}
|
||||
}
|
||||
Lock->Lock += 1;
|
||||
ASSERT (Lock->Lock == 1);
|
||||
}
|
||||
|
||||
|
||||
#ifndef __GNUC__
|
||||
#pragma RUNTIME_CODE(RtAcquireLock)
|
||||
#endif
|
||||
VOID
|
||||
RtReleaseLock (
|
||||
IN FLOCK *Lock
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Releases ownership of the mutual exclusion lock, and
|
||||
restores the previous task priority level.
|
||||
|
||||
Arguments:
|
||||
|
||||
Lock - The lock to release
|
||||
|
||||
Returns:
|
||||
|
||||
Lock unowned
|
||||
|
||||
--*/
|
||||
{
|
||||
EFI_TPL Tpl;
|
||||
|
||||
Tpl = Lock->OwnerTpl;
|
||||
ASSERT(Lock->Lock == 1);
|
||||
Lock->Lock -= 1;
|
||||
if (BS) {
|
||||
if (BS->RestoreTPL != NULL) {
|
||||
uefi_call_wrapper(BS->RestoreTPL, 1, Tpl);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (LibRuntimeRestoreTPL != NULL) {
|
||||
LibRuntimeRestoreTPL(Tpl);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,233 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
str.c
|
||||
|
||||
Abstract:
|
||||
|
||||
String runtime functions
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
#include "lib.h"
|
||||
|
||||
#ifndef __GNUC__
|
||||
#pragma RUNTIME_CODE(RtStrCmp)
|
||||
#endif
|
||||
INTN
|
||||
RUNTIMEFUNCTION
|
||||
RtStrCmp (
|
||||
IN CONST CHAR16 *s1,
|
||||
IN CONST CHAR16 *s2
|
||||
)
|
||||
// compare strings
|
||||
{
|
||||
while (*s1) {
|
||||
if (*s1 != *s2) {
|
||||
break;
|
||||
}
|
||||
|
||||
s1 += 1;
|
||||
s2 += 1;
|
||||
}
|
||||
|
||||
return *s1 - *s2;
|
||||
}
|
||||
|
||||
#ifndef __GNUC__
|
||||
#pragma RUNTIME_CODE(RtStrCpy)
|
||||
#endif
|
||||
VOID
|
||||
RUNTIMEFUNCTION
|
||||
RtStrCpy (
|
||||
IN CHAR16 *Dest,
|
||||
IN CONST CHAR16 *Src
|
||||
)
|
||||
// copy strings
|
||||
{
|
||||
while (*Src) {
|
||||
*(Dest++) = *(Src++);
|
||||
}
|
||||
*Dest = 0;
|
||||
}
|
||||
|
||||
#ifndef __GNUC__
|
||||
#pragma RUNTIME_CODE(RtStrnCpy)
|
||||
#endif
|
||||
VOID
|
||||
RUNTIMEFUNCTION
|
||||
RtStrnCpy (
|
||||
IN CHAR16 *Dest,
|
||||
IN CONST CHAR16 *Src,
|
||||
IN UINTN Len
|
||||
)
|
||||
// copy strings
|
||||
{
|
||||
|
||||
UINTN Size = RtStrnLen(Src, Len);
|
||||
if (Size != Len)
|
||||
RtSetMem(Dest + Size, (Len - Size) * sizeof(CHAR16), '\0');
|
||||
RtCopyMemC(Dest, Src, Size * sizeof(CHAR16));
|
||||
}
|
||||
|
||||
#ifndef __GNUC__
|
||||
#pragma RUNTIME_CODE(RtStpCpy)
|
||||
#endif
|
||||
CHAR16 *
|
||||
RUNTIMEFUNCTION
|
||||
RtStpCpy (
|
||||
IN CHAR16 *Dest,
|
||||
IN CONST CHAR16 *Src
|
||||
)
|
||||
// copy strings
|
||||
{
|
||||
while (*Src) {
|
||||
*(Dest++) = *(Src++);
|
||||
}
|
||||
*Dest = 0;
|
||||
return Dest;
|
||||
}
|
||||
|
||||
#ifndef __GNUC__
|
||||
#pragma RUNTIME_CODE(RtStpnCpy)
|
||||
#endif
|
||||
CHAR16 *
|
||||
RUNTIMEFUNCTION
|
||||
RtStpnCpy (
|
||||
IN CHAR16 *Dest,
|
||||
IN CONST CHAR16 *Src,
|
||||
IN UINTN Len
|
||||
)
|
||||
// copy strings
|
||||
{
|
||||
|
||||
UINTN Size = RtStrnLen(Src, Len);
|
||||
if (Size != Len)
|
||||
RtSetMem(Dest + Size, (Len - Size) * sizeof(CHAR16), '\0');
|
||||
RtCopyMemC(Dest, Src, Size * sizeof(CHAR16));
|
||||
return Dest + Size;
|
||||
}
|
||||
|
||||
#ifndef __GNUC__
|
||||
#pragma RUNTIME_CODE(RtStrCat)
|
||||
#endif
|
||||
VOID
|
||||
RUNTIMEFUNCTION
|
||||
RtStrCat (
|
||||
IN CHAR16 *Dest,
|
||||
IN CONST CHAR16 *Src
|
||||
)
|
||||
{
|
||||
RtStrCpy(Dest+RtStrLen(Dest), Src);
|
||||
}
|
||||
|
||||
#ifndef __GNUC__
|
||||
#pragma RUNTIME_CODE(RtStrnCat)
|
||||
#endif
|
||||
VOID
|
||||
RUNTIMEFUNCTION
|
||||
RtStrnCat (
|
||||
IN CHAR16 *Dest,
|
||||
IN CONST CHAR16 *Src,
|
||||
IN UINTN Len
|
||||
)
|
||||
{
|
||||
UINTN DestSize, Size;
|
||||
|
||||
DestSize = RtStrLen(Dest);
|
||||
Size = RtStrnLen(Src, Len);
|
||||
RtCopyMemC(Dest + DestSize, Src, Size * sizeof(CHAR16));
|
||||
Dest[DestSize + Size] = '\0';
|
||||
}
|
||||
|
||||
#ifndef __GNUC__
|
||||
#pragma RUNTIME_CODE(RtStrLen)
|
||||
#endif
|
||||
UINTN
|
||||
RUNTIMEFUNCTION
|
||||
RtStrLen (
|
||||
IN CONST CHAR16 *s1
|
||||
)
|
||||
// string length
|
||||
{
|
||||
UINTN len;
|
||||
|
||||
for (len=0; *s1; s1+=1, len+=1) ;
|
||||
return len;
|
||||
}
|
||||
|
||||
#ifndef __GNUC__
|
||||
#pragma RUNTIME_CODE(RtStrnLen)
|
||||
#endif
|
||||
UINTN
|
||||
RUNTIMEFUNCTION
|
||||
RtStrnLen (
|
||||
IN CONST CHAR16 *s1,
|
||||
IN UINTN Len
|
||||
)
|
||||
// string length
|
||||
{
|
||||
UINTN i;
|
||||
for (i = 0; *s1 && i < Len; i++)
|
||||
s1++;
|
||||
return i;
|
||||
}
|
||||
|
||||
#ifndef __GNUC__
|
||||
#pragma RUNTIME_CODE(RtStrSize)
|
||||
#endif
|
||||
UINTN
|
||||
RUNTIMEFUNCTION
|
||||
RtStrSize (
|
||||
IN CONST CHAR16 *s1
|
||||
)
|
||||
// string size
|
||||
{
|
||||
UINTN len;
|
||||
|
||||
for (len=0; *s1; s1+=1, len+=1) ;
|
||||
return (len + 1) * sizeof(CHAR16);
|
||||
}
|
||||
|
||||
#ifndef __GNUC__
|
||||
#pragma RUNTIME_CODE(RtBCDtoDecimal)
|
||||
#endif
|
||||
UINT8
|
||||
RUNTIMEFUNCTION
|
||||
RtBCDtoDecimal(
|
||||
IN UINT8 BcdValue
|
||||
)
|
||||
{
|
||||
UINTN High, Low;
|
||||
|
||||
High = BcdValue >> 4;
|
||||
Low = BcdValue - (High << 4);
|
||||
|
||||
return ((UINT8)(Low + (High * 10)));
|
||||
}
|
||||
|
||||
|
||||
#ifndef __GNUC__
|
||||
#pragma RUNTIME_CODE(RtDecimaltoBCD)
|
||||
#endif
|
||||
UINT8
|
||||
RUNTIMEFUNCTION
|
||||
RtDecimaltoBCD (
|
||||
IN UINT8 DecValue
|
||||
)
|
||||
{
|
||||
UINTN High, Low;
|
||||
|
||||
High = DecValue / 10;
|
||||
Low = DecValue - (High * 10);
|
||||
|
||||
return ((UINT8)(Low + (High << 4)));
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
vm.c
|
||||
|
||||
Abstract:
|
||||
|
||||
EFI Hell to remap runtime address into the new virual address space
|
||||
that was registered by the OS for RT calls.
|
||||
|
||||
So the code image needs to be relocated. All pointers need to be
|
||||
manually fixed up since the address map changes.
|
||||
|
||||
GOOD LUCK NOT HAVING BUGS IN YOUR CODE! PLEASE TEST A LOT. MAKE SURE
|
||||
EXIT BOOTSERVICES OVER WRITES ALL BOOTSERVICE MEMORY & DATA SPACES WHEN
|
||||
YOU TEST.
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
#include "lib.h"
|
||||
|
||||
#ifndef __GNUC__
|
||||
#pragma RUNTIME_CODE(RtLibEnableVirtualMappings)
|
||||
#endif
|
||||
VOID
|
||||
RUNTIMEFUNCTION
|
||||
RtLibEnableVirtualMappings (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
EFI_CONVERT_POINTER ConvertPointer;
|
||||
|
||||
//
|
||||
// If this copy of the lib is linked into the firmware, then
|
||||
// do not update the pointers yet.
|
||||
//
|
||||
|
||||
if (!LibFwInstance) {
|
||||
|
||||
//
|
||||
// Different components are updating to the new virtual
|
||||
// mappings at differnt times. The only function that
|
||||
// is safe to call at this notification is ConvertAddress
|
||||
//
|
||||
|
||||
ConvertPointer = RT->ConvertPointer;
|
||||
|
||||
//
|
||||
// Fix any pointers that the lib created, that may be needed
|
||||
// during runtime.
|
||||
//
|
||||
|
||||
ConvertPointer (EFI_INTERNAL_PTR, (VOID **)&RT);
|
||||
ConvertPointer (EFI_OPTIONAL_PTR, (VOID **)&LibRuntimeDebugOut);
|
||||
|
||||
ConvertPointer (EFI_INTERNAL_PTR, (VOID **)&LibRuntimeRaiseTPL);
|
||||
ConvertPointer (EFI_INTERNAL_PTR, (VOID **)&LibRuntimeRestoreTPL);
|
||||
|
||||
// that was it :^)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifndef __GNUC__
|
||||
#pragma RUNTIME_CODE(RtConvertList)
|
||||
#endif
|
||||
VOID
|
||||
RUNTIMEFUNCTION
|
||||
RtConvertList (
|
||||
IN UINTN DebugDisposition,
|
||||
IN OUT LIST_ENTRY *ListHead
|
||||
)
|
||||
{
|
||||
LIST_ENTRY *Link;
|
||||
LIST_ENTRY *NextLink;
|
||||
EFI_CONVERT_POINTER ConvertPointer;
|
||||
|
||||
ConvertPointer = RT->ConvertPointer;
|
||||
|
||||
//
|
||||
// Convert all the Flink & Blink pointers in the list
|
||||
//
|
||||
|
||||
Link = ListHead;
|
||||
do {
|
||||
NextLink = Link->Flink;
|
||||
|
||||
ConvertPointer (
|
||||
Link->Flink == ListHead ? DebugDisposition : 0,
|
||||
(VOID **)&Link->Flink
|
||||
);
|
||||
|
||||
ConvertPointer (
|
||||
Link->Blink == ListHead ? DebugDisposition : 0,
|
||||
(VOID **)&Link->Blink
|
||||
);
|
||||
|
||||
Link = NextLink;
|
||||
} while (Link != ListHead);
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2000 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
Smbios.c
|
||||
|
||||
Abstract:
|
||||
|
||||
Lib fucntions for SMBIOS. Used to get system serial number and GUID
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
#include "lib.h"
|
||||
|
||||
/*
|
||||
* We convert 32 bit values to pointers. In 64 bit mode the compiler will issue a
|
||||
* warning stating that the value is too small for the pointer:
|
||||
* "warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]"
|
||||
* we can safely ignore them here.
|
||||
*/
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic ignored "-Wint-to-pointer-cast"
|
||||
#endif
|
||||
|
||||
EFI_STATUS
|
||||
LibGetSmbiosSystemGuidAndSerialNumber (
|
||||
IN EFI_GUID *SystemGuid,
|
||||
OUT CHAR8 **SystemSerialNumber
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
SMBIOS_STRUCTURE_TABLE *SmbiosTable;
|
||||
SMBIOS_STRUCTURE_POINTER Smbios;
|
||||
SMBIOS_STRUCTURE_POINTER SmbiosEnd;
|
||||
UINT16 Index;
|
||||
|
||||
Status = LibGetSystemConfigurationTable(&SMBIOSTableGuid, (VOID**)&SmbiosTable);
|
||||
if (EFI_ERROR(Status)) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
Smbios.Hdr = (SMBIOS_HEADER *)SmbiosTable->TableAddress;
|
||||
SmbiosEnd.Raw = (UINT8 *)((UINTN)SmbiosTable->TableAddress + SmbiosTable->TableLength);
|
||||
for (Index = 0; Index < SmbiosTable->TableLength ; Index++) {
|
||||
if (Smbios.Hdr->Type == 1) {
|
||||
if (Smbios.Hdr->Length < 0x19) {
|
||||
//
|
||||
// Older version did not support Guid and Serial number
|
||||
//
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// SMBIOS tables are byte packed so we need to do a byte copy to
|
||||
// prevend alignment faults on IA-64.
|
||||
|
||||
CopyMem (SystemGuid, &Smbios.Type1->Uuid, sizeof(EFI_GUID));
|
||||
*SystemSerialNumber = LibGetSmbiosString(&Smbios, Smbios.Type1->SerialNumber);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
//
|
||||
// Make Smbios point to the next record
|
||||
//
|
||||
LibGetSmbiosString (&Smbios, -1);
|
||||
|
||||
if (Smbios.Raw >= SmbiosEnd.Raw) {
|
||||
//
|
||||
// SMBIOS 2.1 incorrectly stated the length of SmbiosTable as 0x1e.
|
||||
// given this we must double check against the lenght of
|
||||
/// the structure. My home PC has this bug.ruthard
|
||||
//
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
CHAR8*
|
||||
LibGetSmbiosString (
|
||||
IN SMBIOS_STRUCTURE_POINTER *Smbios,
|
||||
IN UINT16 StringNumber
|
||||
)
|
||||
/*++
|
||||
|
||||
Return SMBIOS string given the string number.
|
||||
|
||||
Arguments:
|
||||
Smbios - Pointer to SMBIOS structure
|
||||
StringNumber - String number to return. -1 is used to skip all strings and
|
||||
point to the next SMBIOS structure.
|
||||
|
||||
Returns:
|
||||
Pointer to string, or pointer to next SMBIOS strcuture if StringNumber == -1
|
||||
--*/
|
||||
{
|
||||
UINT16 Index;
|
||||
CHAR8 *String;
|
||||
|
||||
//
|
||||
// Skip over formatted section
|
||||
//
|
||||
String = (CHAR8 *)(Smbios->Raw + Smbios->Hdr->Length);
|
||||
|
||||
//
|
||||
// Look through unformated section
|
||||
//
|
||||
for (Index = 1; Index <= StringNumber; Index++) {
|
||||
if (StringNumber == Index) {
|
||||
return String;
|
||||
}
|
||||
|
||||
//
|
||||
// Skip string
|
||||
//
|
||||
for (; *String != 0; String++);
|
||||
String++;
|
||||
|
||||
if (*String == 0) {
|
||||
//
|
||||
// If double NULL then we are done.
|
||||
// Retrun pointer to next structure in Smbios.
|
||||
// if you pass in a -1 you will always get here
|
||||
//
|
||||
Smbios->Raw = (UINT8 *)++String;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
+358
@@ -0,0 +1,358 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
sread.c
|
||||
|
||||
Abstract:
|
||||
|
||||
Simple read file access
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
#include "lib.h"
|
||||
|
||||
#define SIMPLE_READ_SIGNATURE EFI_SIGNATURE_32('s','r','d','r')
|
||||
typedef struct _SIMPLE_READ_FILE {
|
||||
UINTN Signature;
|
||||
BOOLEAN FreeBuffer;
|
||||
VOID *Source;
|
||||
UINTN SourceSize;
|
||||
EFI_FILE_HANDLE FileHandle;
|
||||
} SIMPLE_READ_HANDLE;
|
||||
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
OpenSimpleReadFile (
|
||||
IN BOOLEAN BootPolicy,
|
||||
IN VOID *SourceBuffer OPTIONAL,
|
||||
IN UINTN SourceSize,
|
||||
IN OUT EFI_DEVICE_PATH **FilePath,
|
||||
OUT EFI_HANDLE *DeviceHandle,
|
||||
OUT SIMPLE_READ_FILE *SimpleReadHandle
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Opens a file for (simple) reading. The simple read abstraction
|
||||
will access the file either from a memory copy, from a file
|
||||
system interface, or from the load file interface.
|
||||
|
||||
Arguments:
|
||||
|
||||
Returns:
|
||||
|
||||
A handle to access the file
|
||||
|
||||
--*/
|
||||
{
|
||||
SIMPLE_READ_HANDLE *FHand;
|
||||
EFI_DEVICE_PATH *UserFilePath;
|
||||
EFI_DEVICE_PATH *TempFilePath;
|
||||
EFI_DEVICE_PATH *TempFilePathPtr;
|
||||
FILEPATH_DEVICE_PATH *FilePathNode;
|
||||
EFI_FILE_HANDLE FileHandle, LastHandle;
|
||||
EFI_STATUS Status;
|
||||
EFI_LOAD_FILE_INTERFACE *LoadFile;
|
||||
|
||||
FHand = NULL;
|
||||
UserFilePath = *FilePath;
|
||||
|
||||
//
|
||||
// Allocate a new simple read handle structure
|
||||
//
|
||||
|
||||
FHand = AllocateZeroPool (sizeof(SIMPLE_READ_HANDLE));
|
||||
if (!FHand) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto Done;
|
||||
}
|
||||
|
||||
*SimpleReadHandle = (SIMPLE_READ_FILE) FHand;
|
||||
FHand->Signature = SIMPLE_READ_SIGNATURE;
|
||||
|
||||
//
|
||||
// If the caller passed a copy of the file, then just use it
|
||||
//
|
||||
|
||||
if (SourceBuffer) {
|
||||
FHand->Source = SourceBuffer;
|
||||
FHand->SourceSize = SourceSize;
|
||||
*DeviceHandle = NULL;
|
||||
Status = EFI_SUCCESS;
|
||||
goto Done;
|
||||
}
|
||||
|
||||
//
|
||||
// Attempt to access the file via a file system interface
|
||||
//
|
||||
|
||||
FileHandle = NULL;
|
||||
Status = uefi_call_wrapper(BS->LocateDevicePath, 3, &FileSystemProtocol, FilePath, DeviceHandle);
|
||||
if (!EFI_ERROR(Status)) {
|
||||
FileHandle = LibOpenRoot (*DeviceHandle);
|
||||
}
|
||||
|
||||
Status = FileHandle ? EFI_SUCCESS : EFI_UNSUPPORTED;
|
||||
|
||||
//
|
||||
// To access as a filesystem, the filepath should only
|
||||
// contain filepath components. Follow the filepath nodes
|
||||
// and find the target file
|
||||
//
|
||||
|
||||
FilePathNode = (FILEPATH_DEVICE_PATH *) *FilePath;
|
||||
while (!IsDevicePathEnd(&FilePathNode->Header)) {
|
||||
|
||||
//
|
||||
// For filesystem access each node should be a filepath component
|
||||
//
|
||||
|
||||
if (DevicePathType(&FilePathNode->Header) != MEDIA_DEVICE_PATH ||
|
||||
DevicePathSubType(&FilePathNode->Header) != MEDIA_FILEPATH_DP) {
|
||||
Status = EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
//
|
||||
// If there's been an error, stop
|
||||
//
|
||||
|
||||
if (EFI_ERROR(Status)) {
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// Open this file path node
|
||||
//
|
||||
|
||||
LastHandle = FileHandle;
|
||||
FileHandle = NULL;
|
||||
|
||||
Status = uefi_call_wrapper(
|
||||
LastHandle->Open,
|
||||
5,
|
||||
LastHandle,
|
||||
&FileHandle,
|
||||
FilePathNode->PathName,
|
||||
EFI_FILE_MODE_READ,
|
||||
0
|
||||
);
|
||||
|
||||
//
|
||||
// Close the last node
|
||||
//
|
||||
|
||||
uefi_call_wrapper(LastHandle->Close, 1, LastHandle);
|
||||
|
||||
//
|
||||
// Get the next node
|
||||
//
|
||||
|
||||
FilePathNode = (FILEPATH_DEVICE_PATH *) NextDevicePathNode(&FilePathNode->Header);
|
||||
}
|
||||
|
||||
//
|
||||
// If success, return the FHand
|
||||
//
|
||||
|
||||
if (!EFI_ERROR(Status)) {
|
||||
ASSERT(FileHandle);
|
||||
FHand->FileHandle = FileHandle;
|
||||
goto Done;
|
||||
}
|
||||
|
||||
//
|
||||
// Cleanup from filesystem access
|
||||
//
|
||||
|
||||
if (FileHandle) {
|
||||
uefi_call_wrapper(FileHandle->Close, 1, FileHandle);
|
||||
FileHandle = NULL;
|
||||
*FilePath = UserFilePath;
|
||||
}
|
||||
|
||||
//
|
||||
// If the error is something other then unsupported, return it
|
||||
//
|
||||
|
||||
if (Status != EFI_UNSUPPORTED) {
|
||||
goto Done;
|
||||
}
|
||||
|
||||
//
|
||||
// Attempt to access the file via the load file protocol
|
||||
//
|
||||
|
||||
Status = LibDevicePathToInterface (&LoadFileProtocol, *FilePath, (VOID*)&LoadFile);
|
||||
if (!EFI_ERROR(Status)) {
|
||||
|
||||
TempFilePath = DuplicateDevicePath (*FilePath);
|
||||
|
||||
TempFilePathPtr = TempFilePath;
|
||||
|
||||
Status = uefi_call_wrapper(BS->LocateDevicePath, 3, &LoadFileProtocol, &TempFilePath, DeviceHandle);
|
||||
|
||||
FreePool (TempFilePathPtr);
|
||||
|
||||
//
|
||||
// Determine the size of buffer needed to hold the file
|
||||
//
|
||||
|
||||
SourceSize = 0;
|
||||
Status = uefi_call_wrapper(
|
||||
LoadFile->LoadFile,
|
||||
5,
|
||||
LoadFile,
|
||||
*FilePath,
|
||||
BootPolicy,
|
||||
&SourceSize,
|
||||
NULL
|
||||
);
|
||||
|
||||
//
|
||||
// We expect a buffer too small error to inform us
|
||||
// of the buffer size needed
|
||||
//
|
||||
|
||||
if (Status == EFI_BUFFER_TOO_SMALL) {
|
||||
SourceBuffer = AllocatePool (SourceSize);
|
||||
|
||||
if (SourceBuffer) {
|
||||
FHand->FreeBuffer = TRUE;
|
||||
FHand->Source = SourceBuffer;
|
||||
FHand->SourceSize = SourceSize;
|
||||
|
||||
Status = uefi_call_wrapper(
|
||||
LoadFile->LoadFile,
|
||||
5,
|
||||
LoadFile,
|
||||
*FilePath,
|
||||
BootPolicy,
|
||||
&SourceSize,
|
||||
SourceBuffer
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// If success, return FHand
|
||||
//
|
||||
|
||||
if (!EFI_ERROR(Status) || Status == EFI_ALREADY_STARTED) {
|
||||
goto Done;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Nothing else to try
|
||||
//
|
||||
|
||||
DEBUG ((D_LOAD|D_WARN, "OpenSimpleReadFile: Device did not support a known load protocol\n"));
|
||||
Status = EFI_UNSUPPORTED;
|
||||
|
||||
Done:
|
||||
|
||||
//
|
||||
// If the file was not accessed, clean up
|
||||
//
|
||||
if (EFI_ERROR(Status) && (Status != EFI_ALREADY_STARTED)) {
|
||||
if (FHand) {
|
||||
if (FHand->FreeBuffer) {
|
||||
FreePool (FHand->Source);
|
||||
}
|
||||
|
||||
FreePool (FHand);
|
||||
}
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
ReadSimpleReadFile (
|
||||
IN SIMPLE_READ_FILE UserHandle,
|
||||
IN UINTN Offset,
|
||||
IN OUT UINTN *ReadSize,
|
||||
OUT VOID *Buffer
|
||||
)
|
||||
{
|
||||
UINTN EndPos;
|
||||
SIMPLE_READ_HANDLE *FHand;
|
||||
EFI_STATUS Status;
|
||||
|
||||
FHand = UserHandle;
|
||||
ASSERT (FHand->Signature == SIMPLE_READ_SIGNATURE);
|
||||
if (FHand->Source) {
|
||||
|
||||
//
|
||||
// Move data from our local copy of the file
|
||||
//
|
||||
|
||||
EndPos = Offset + *ReadSize;
|
||||
if (EndPos > FHand->SourceSize) {
|
||||
*ReadSize = FHand->SourceSize - Offset;
|
||||
if (Offset >= FHand->SourceSize) {
|
||||
*ReadSize = 0;
|
||||
}
|
||||
}
|
||||
|
||||
CopyMem (Buffer, (CHAR8 *) FHand->Source + Offset, *ReadSize);
|
||||
Status = EFI_SUCCESS;
|
||||
|
||||
} else {
|
||||
|
||||
//
|
||||
// Read data from the file
|
||||
//
|
||||
|
||||
Status = uefi_call_wrapper(FHand->FileHandle->SetPosition, 2, FHand->FileHandle, Offset);
|
||||
|
||||
if (!EFI_ERROR(Status)) {
|
||||
Status = uefi_call_wrapper(FHand->FileHandle->Read, 3, FHand->FileHandle, ReadSize, Buffer);
|
||||
}
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
VOID
|
||||
CloseSimpleReadFile (
|
||||
IN SIMPLE_READ_FILE UserHandle
|
||||
)
|
||||
{
|
||||
SIMPLE_READ_HANDLE *FHand;
|
||||
|
||||
FHand = UserHandle;
|
||||
ASSERT (FHand->Signature == SIMPLE_READ_SIGNATURE);
|
||||
|
||||
//
|
||||
// Free any file handle we opened
|
||||
//
|
||||
|
||||
if (FHand->FileHandle) {
|
||||
uefi_call_wrapper(FHand->FileHandle->Close, 1, FHand->FileHandle);
|
||||
}
|
||||
|
||||
//
|
||||
// If we allocated the Source buffer, free it
|
||||
//
|
||||
|
||||
if (FHand->FreeBuffer) {
|
||||
FreePool (FHand->Source);
|
||||
}
|
||||
|
||||
//
|
||||
// Done with this simple read file handle
|
||||
//
|
||||
|
||||
FreePool (FHand);
|
||||
}
|
||||
+432
@@ -0,0 +1,432 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
str.c
|
||||
|
||||
Abstract:
|
||||
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
#include "lib.h"
|
||||
|
||||
|
||||
INTN
|
||||
StrCmp (
|
||||
IN CONST CHAR16 *s1,
|
||||
IN CONST CHAR16 *s2
|
||||
)
|
||||
// compare strings
|
||||
{
|
||||
return RtStrCmp(s1, s2);
|
||||
}
|
||||
|
||||
INTN
|
||||
StrnCmp (
|
||||
IN CONST CHAR16 *s1,
|
||||
IN CONST CHAR16 *s2,
|
||||
IN UINTN len
|
||||
)
|
||||
// compare strings
|
||||
{
|
||||
while (*s1 && len) {
|
||||
if (*s1 != *s2) {
|
||||
break;
|
||||
}
|
||||
|
||||
s1 += 1;
|
||||
s2 += 1;
|
||||
len -= 1;
|
||||
}
|
||||
|
||||
return len ? *s1 - *s2 : 0;
|
||||
}
|
||||
|
||||
|
||||
INTN EFIAPI
|
||||
LibStubStriCmp (
|
||||
IN EFI_UNICODE_COLLATION_INTERFACE *This EFI_UNUSED,
|
||||
IN CHAR16 *s1,
|
||||
IN CHAR16 *s2
|
||||
)
|
||||
{
|
||||
return StrCmp (s1, s2);
|
||||
}
|
||||
|
||||
VOID EFIAPI
|
||||
LibStubStrLwrUpr (
|
||||
IN EFI_UNICODE_COLLATION_INTERFACE *This EFI_UNUSED,
|
||||
IN CHAR16 *Str EFI_UNUSED
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
INTN
|
||||
StriCmp (
|
||||
IN CONST CHAR16 *s1,
|
||||
IN CONST CHAR16 *s2
|
||||
)
|
||||
// compare strings
|
||||
{
|
||||
if (UnicodeInterface == &LibStubUnicodeInterface)
|
||||
return UnicodeInterface->StriColl(UnicodeInterface, (CHAR16 *)s1, (CHAR16 *)s2);
|
||||
else
|
||||
return uefi_call_wrapper(UnicodeInterface->StriColl, 3, UnicodeInterface, (CHAR16 *)s1, (CHAR16 *)s2);
|
||||
}
|
||||
|
||||
VOID
|
||||
StrLwr (
|
||||
IN CHAR16 *Str
|
||||
)
|
||||
// lwoer case string
|
||||
{
|
||||
if (UnicodeInterface == &LibStubUnicodeInterface)
|
||||
UnicodeInterface->StrLwr(UnicodeInterface, Str);
|
||||
else uefi_call_wrapper(UnicodeInterface->StrLwr, 2, UnicodeInterface, Str);
|
||||
}
|
||||
|
||||
VOID
|
||||
StrUpr (
|
||||
IN CHAR16 *Str
|
||||
)
|
||||
// upper case string
|
||||
{
|
||||
if (UnicodeInterface == &LibStubUnicodeInterface)
|
||||
UnicodeInterface->StrUpr(UnicodeInterface, Str);
|
||||
else uefi_call_wrapper(UnicodeInterface->StrUpr, 2, UnicodeInterface, Str);
|
||||
}
|
||||
|
||||
VOID
|
||||
StrCpy (
|
||||
IN CHAR16 *Dest,
|
||||
IN CONST CHAR16 *Src
|
||||
)
|
||||
// copy strings
|
||||
{
|
||||
RtStrCpy (Dest, Src);
|
||||
}
|
||||
|
||||
VOID
|
||||
StrnCpy (
|
||||
IN CHAR16 *Dest,
|
||||
IN CONST CHAR16 *Src,
|
||||
IN UINTN Len
|
||||
)
|
||||
// copy strings
|
||||
{
|
||||
RtStrnCpy (Dest, Src, Len);
|
||||
}
|
||||
|
||||
CHAR16 *
|
||||
StpCpy (
|
||||
IN CHAR16 *Dest,
|
||||
IN CONST CHAR16 *Src
|
||||
)
|
||||
// copy strings
|
||||
{
|
||||
return RtStpCpy (Dest, Src);
|
||||
}
|
||||
|
||||
CHAR16 *
|
||||
StpnCpy (
|
||||
IN CHAR16 *Dest,
|
||||
IN CONST CHAR16 *Src,
|
||||
IN UINTN Len
|
||||
)
|
||||
// copy strings
|
||||
{
|
||||
return RtStpnCpy (Dest, Src, Len);
|
||||
}
|
||||
|
||||
VOID
|
||||
StrCat (
|
||||
IN CHAR16 *Dest,
|
||||
IN CONST CHAR16 *Src
|
||||
)
|
||||
{
|
||||
RtStrCat(Dest, Src);
|
||||
}
|
||||
|
||||
VOID
|
||||
StrnCat (
|
||||
IN CHAR16 *Dest,
|
||||
IN CONST CHAR16 *Src,
|
||||
IN UINTN Len
|
||||
)
|
||||
{
|
||||
RtStrnCat(Dest, Src, Len);
|
||||
}
|
||||
|
||||
|
||||
UINTN
|
||||
StrnLen (
|
||||
IN CONST CHAR16 *s1,
|
||||
IN UINTN Len
|
||||
)
|
||||
// string length
|
||||
{
|
||||
return RtStrnLen(s1, Len);
|
||||
}
|
||||
|
||||
UINTN
|
||||
StrLen (
|
||||
IN CONST CHAR16 *s1
|
||||
)
|
||||
// string length
|
||||
{
|
||||
return RtStrLen(s1);
|
||||
}
|
||||
|
||||
UINTN
|
||||
StrSize (
|
||||
IN CONST CHAR16 *s1
|
||||
)
|
||||
// string size
|
||||
{
|
||||
return RtStrSize(s1);
|
||||
}
|
||||
|
||||
CHAR16 *
|
||||
StrDuplicate (
|
||||
IN CONST CHAR16 *Src
|
||||
)
|
||||
// duplicate a string
|
||||
{
|
||||
CHAR16 *Dest;
|
||||
UINTN Size;
|
||||
|
||||
Size = StrSize(Src);
|
||||
Dest = AllocatePool (Size);
|
||||
if (Dest) {
|
||||
CopyMemC (Dest, Src, Size);
|
||||
}
|
||||
return Dest;
|
||||
}
|
||||
|
||||
UINTN
|
||||
AsciiStrLen (
|
||||
IN CONST CHAR8 *s1
|
||||
)
|
||||
// string length
|
||||
{
|
||||
UINTN len;
|
||||
|
||||
for (len=0; *s1; s1+=1, len+=1) ;
|
||||
return len;
|
||||
}
|
||||
|
||||
UINTN
|
||||
AsciiStrCmp (
|
||||
IN CONST CHAR8 *s1,
|
||||
IN CONST CHAR8 *s2
|
||||
)
|
||||
// compare strings
|
||||
{
|
||||
while (*s1) {
|
||||
if (*s1 != *s2) {
|
||||
break;
|
||||
}
|
||||
|
||||
s1 += 1;
|
||||
s2 += 1;
|
||||
}
|
||||
|
||||
return *s1 - *s2;
|
||||
}
|
||||
|
||||
UINTN
|
||||
AsciiStrnCmp (
|
||||
IN CONST CHAR8 *s1,
|
||||
IN CONST CHAR8 *s2,
|
||||
IN UINTN len
|
||||
)
|
||||
// compare strings
|
||||
{
|
||||
while (*s1 && len) {
|
||||
if (*s1 != *s2) {
|
||||
break;
|
||||
}
|
||||
|
||||
s1 += 1;
|
||||
s2 += 1;
|
||||
len -= 1;
|
||||
}
|
||||
|
||||
return len ? *s1 - *s2 : 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
UINTN
|
||||
xtoi (
|
||||
CONST CHAR16 *str
|
||||
)
|
||||
// convert hex string to uint
|
||||
{
|
||||
UINTN u;
|
||||
CHAR16 c;
|
||||
|
||||
// skip preceeding white space
|
||||
while (*str == ' ') {
|
||||
str += 1;
|
||||
}
|
||||
|
||||
// convert hex digits
|
||||
u = 0;
|
||||
while ((c = *(str++))) {
|
||||
if (c >= 'a' && c <= 'f') {
|
||||
c -= 'a' - 'A';
|
||||
}
|
||||
|
||||
if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F')) {
|
||||
u = (u << 4) | ((UINTN)c - (c >= 'A' ? 'A'-10 : '0'));
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return u;
|
||||
}
|
||||
|
||||
UINTN
|
||||
Atoi (
|
||||
CONST CHAR16 *str
|
||||
)
|
||||
// convert hex string to uint
|
||||
{
|
||||
UINTN u;
|
||||
CHAR16 c;
|
||||
|
||||
// skip preceeding white space
|
||||
while (*str == ' ') {
|
||||
str += 1;
|
||||
}
|
||||
|
||||
// convert digits
|
||||
u = 0;
|
||||
while ((c = *(str++))) {
|
||||
if (c >= '0' && c <= '9') {
|
||||
u = (u * 10) + c - '0';
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return u;
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
MetaMatch (
|
||||
IN CHAR16 *String,
|
||||
IN CHAR16 *Pattern
|
||||
)
|
||||
{
|
||||
CHAR16 c, p, l;
|
||||
|
||||
for (; ;) {
|
||||
p = *Pattern;
|
||||
Pattern += 1;
|
||||
|
||||
switch (p) {
|
||||
case 0:
|
||||
// End of pattern. If end of string, TRUE match
|
||||
return *String ? FALSE : TRUE;
|
||||
|
||||
case '*':
|
||||
// Match zero or more chars
|
||||
while (*String) {
|
||||
if (MetaMatch (String, Pattern)) {
|
||||
return TRUE;
|
||||
}
|
||||
String += 1;
|
||||
}
|
||||
return MetaMatch (String, Pattern);
|
||||
|
||||
case '?':
|
||||
// Match any one char
|
||||
if (!*String) {
|
||||
return FALSE;
|
||||
}
|
||||
String += 1;
|
||||
break;
|
||||
|
||||
case '[':
|
||||
// Match char set
|
||||
c = *String;
|
||||
if (!c) {
|
||||
return FALSE; // syntax problem
|
||||
}
|
||||
|
||||
l = 0;
|
||||
while ((p = *Pattern++)) {
|
||||
if (p == ']') {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (p == '-') { // if range of chars,
|
||||
p = *Pattern; // get high range
|
||||
if (p == 0 || p == ']') {
|
||||
return FALSE; // syntax problem
|
||||
}
|
||||
|
||||
if (c >= l && c <= p) { // if in range,
|
||||
break; // it's a match
|
||||
}
|
||||
}
|
||||
|
||||
l = p;
|
||||
if (c == p) { // if char matches
|
||||
break; // move on
|
||||
}
|
||||
}
|
||||
|
||||
// skip to end of match char set
|
||||
while (p && p != ']') {
|
||||
p = *Pattern;
|
||||
Pattern += 1;
|
||||
}
|
||||
|
||||
String += 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
c = *String;
|
||||
if (c != p) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
String += 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BOOLEAN EFIAPI
|
||||
LibStubMetaiMatch (
|
||||
IN EFI_UNICODE_COLLATION_INTERFACE *This EFI_UNUSED,
|
||||
IN CHAR16 *String,
|
||||
IN CHAR16 *Pattern
|
||||
)
|
||||
{
|
||||
return MetaMatch (String, Pattern);
|
||||
}
|
||||
|
||||
|
||||
BOOLEAN
|
||||
MetaiMatch (
|
||||
IN CHAR16 *String,
|
||||
IN CHAR16 *Pattern
|
||||
)
|
||||
{
|
||||
if (UnicodeInterface == &LibStubUnicodeInterface)
|
||||
return UnicodeInterface->MetaiMatch(UnicodeInterface, String, Pattern);
|
||||
else return uefi_call_wrapper(UnicodeInterface->MetaiMatch, 3, UnicodeInterface, String, Pattern);
|
||||
}
|
||||
@@ -0,0 +1,227 @@
|
||||
|
||||
#include "lib.h"
|
||||
#include "internal/print.h"
|
||||
#include "internal/va_print.h"
|
||||
|
||||
VOID
|
||||
CALL_CONV
|
||||
FUNCTION_NAME(_PoolCatPrint) (
|
||||
IN CONST CHAR16 *fmt,
|
||||
IN VA_LIST args,
|
||||
IN OUT POOL_PRINT *spc,
|
||||
IN INTN (EFIAPI *Output)(VOID *context, CHAR16 *str)
|
||||
)
|
||||
// Dispatch function for UnicodeSPrint, PoolPrint, and CatPrint
|
||||
{
|
||||
FUNCTION_NAME(PRINT_STATE) ps;
|
||||
|
||||
ZeroMem (&ps, sizeof(ps));
|
||||
ps.Output = Output;
|
||||
ps.Context = spc;
|
||||
ps.fmt.pw = fmt;
|
||||
VA_COPY(ps.args, args);
|
||||
FUNCTION_NAME(_Print) (&ps);
|
||||
VA_END(ps.args);
|
||||
}
|
||||
|
||||
UINTN
|
||||
CALL_CONV
|
||||
FUNCTION_NAME(UnicodeVSPrint) (
|
||||
OUT CHAR16 *Str,
|
||||
IN UINTN StrSize,
|
||||
IN CONST CHAR16 *fmt,
|
||||
VA_LIST args
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Prints a formatted unicode string to a buffer using a VA_LIST
|
||||
|
||||
Arguments:
|
||||
|
||||
Str - Output buffer to print the formatted string into
|
||||
|
||||
StrSize - Size of Str (in bytes). String is truncated to this size.
|
||||
A size of 0 means there is no limit
|
||||
|
||||
fmt - The format string
|
||||
|
||||
args - VA_LIST
|
||||
|
||||
|
||||
Returns:
|
||||
|
||||
String length returned in buffer
|
||||
|
||||
--*/
|
||||
{
|
||||
POOL_PRINT spc;
|
||||
|
||||
spc.str = Str;
|
||||
spc.maxlen = StrSize / sizeof(CHAR16) - 1;
|
||||
spc.len = 0;
|
||||
|
||||
FUNCTION_NAME(_PoolCatPrint) (fmt, args, &spc, _SPrint);
|
||||
|
||||
return spc.len;
|
||||
}
|
||||
|
||||
CHAR16 *
|
||||
CALL_CONV
|
||||
FUNCTION_NAME(VPoolPrint) (
|
||||
IN CONST CHAR16 *fmt,
|
||||
VA_LIST args
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Prints a formatted unicode string to allocated pool using VA_LIST argument.
|
||||
The caller must free the resulting buffer.
|
||||
|
||||
Arguments:
|
||||
|
||||
fmt - The format string
|
||||
args - The arguments in VA_LIST form
|
||||
|
||||
Returns:
|
||||
|
||||
Allocated buffer with the formatted string printed in it.
|
||||
The caller must free the allocated buffer. The buffer
|
||||
allocation is not packed.
|
||||
|
||||
--*/
|
||||
{
|
||||
POOL_PRINT spc;
|
||||
ZeroMem (&spc, sizeof(spc));
|
||||
FUNCTION_NAME(_PoolCatPrint) (fmt, args, &spc, _PoolPrint);
|
||||
return spc.str;
|
||||
}
|
||||
|
||||
UINTN
|
||||
CALL_CONV
|
||||
FUNCTION_NAME(VPrint) (
|
||||
IN CONST CHAR16 *fmt,
|
||||
VA_LIST args
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Prints a formatted unicode string to the default console using a VA_LIST
|
||||
|
||||
Arguments:
|
||||
|
||||
fmt - Format string
|
||||
args - VA_LIST
|
||||
Returns:
|
||||
|
||||
Length of string printed to the console
|
||||
|
||||
--*/
|
||||
{
|
||||
return FUNCTION_NAME(_IPrint) ((UINTN) -1, (UINTN) -1, ST->ConOut, fmt, NULL, args);
|
||||
}
|
||||
|
||||
UINTN
|
||||
CALL_CONV
|
||||
FUNCTION_NAME(_IPrint) (
|
||||
IN UINTN Column,
|
||||
IN UINTN Row,
|
||||
IN SIMPLE_TEXT_OUTPUT_INTERFACE *Out,
|
||||
IN CONST CHAR16 *fmt,
|
||||
IN CONST CHAR8 *fmta,
|
||||
IN VA_LIST args
|
||||
)
|
||||
// Display string worker for: Print, PrintAt, IPrint, IPrintAt
|
||||
{
|
||||
FUNCTION_NAME(PRINT_STATE) ps;
|
||||
UINTN back;
|
||||
|
||||
ZeroMem (&ps, sizeof(ps));
|
||||
ps.Context = Out;
|
||||
ps.Output = (INTN (EFIAPI *)(VOID *, CHAR16 *)) Out->OutputString;
|
||||
ps.SetAttr = (INTN (EFIAPI *)(VOID *, UINTN)) Out->SetAttribute;
|
||||
ps.Attr = Out->Mode->Attribute;
|
||||
|
||||
back = (ps.Attr >> 4) & 0xF;
|
||||
ps.AttrNorm = EFI_TEXT_ATTR(EFI_LIGHTGRAY, back);
|
||||
ps.AttrHighlight = EFI_TEXT_ATTR(EFI_WHITE, back);
|
||||
ps.AttrError = EFI_TEXT_ATTR(EFI_YELLOW, back);
|
||||
|
||||
if (fmt) {
|
||||
ps.fmt.pw = fmt;
|
||||
} else {
|
||||
ps.fmt.Ascii = TRUE;
|
||||
ps.fmt.pc = fmta;
|
||||
}
|
||||
|
||||
VA_COPY(ps.args, args);
|
||||
|
||||
if (Column != (UINTN) -1) {
|
||||
uefi_call_wrapper(Out->SetCursorPosition, 3, Out, Column, Row);
|
||||
}
|
||||
|
||||
back = FUNCTION_NAME(_Print) (&ps);
|
||||
VA_END(ps.args);
|
||||
return back;
|
||||
}
|
||||
|
||||
UINTN
|
||||
CALL_CONV
|
||||
FUNCTION_NAME(AsciiVSPrint) (
|
||||
OUT CHAR8 *Str,
|
||||
IN UINTN StrSize,
|
||||
IN CONST CHAR8 *fmt,
|
||||
VA_LIST args
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Prints a formatted ascii string to a buffer using a VA_LIST
|
||||
|
||||
Arguments:
|
||||
|
||||
Str - Output buffer to print the formatted string into
|
||||
|
||||
StrSize - Size of Str (in bytes). String is truncated to this size.
|
||||
A size of 0 means there is no limit
|
||||
|
||||
fmt - The format string
|
||||
|
||||
args - VA_LIST
|
||||
|
||||
|
||||
Returns:
|
||||
|
||||
String length returned in buffer
|
||||
|
||||
--*/
|
||||
// Use FUNCTION_NAME(UnicodeVSPrint)() and convert back to ASCII
|
||||
{
|
||||
CHAR16 *UnicodeStr, *UnicodeFmt;
|
||||
UINTN i, Len;
|
||||
|
||||
UnicodeStr = AllocatePool(StrSize * sizeof(CHAR16));
|
||||
if (!UnicodeStr)
|
||||
return 0;
|
||||
|
||||
UnicodeFmt = PoolPrint(u"%a", fmt);
|
||||
if (!UnicodeFmt) {
|
||||
FreePool(UnicodeStr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Len = FUNCTION_NAME(UnicodeVSPrint)(UnicodeStr, StrSize * sizeof(CHAR16), UnicodeFmt, args);
|
||||
FreePool(UnicodeFmt);
|
||||
|
||||
// The strings are ASCII so just do a plain Unicode conversion
|
||||
for (i = 0; i < Len; i++)
|
||||
Str[i] = (CHAR8)UnicodeStr[i];
|
||||
Str[Len] = 0;
|
||||
FreePool(UnicodeStr);
|
||||
|
||||
return Len;
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Convert SysV calling convention to EFI x86_64 calling convention
|
||||
*
|
||||
* Copyright (C) 2007-2010 Intel Corp
|
||||
* Bibo Mao <bibo.mao@intel.com>
|
||||
* Chandramouli Narayanan<mouli@linux.intel.com>
|
||||
* Huang Ying <ying.huang@intel.com>
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
* - Neither the name of Hewlett-Packard Co. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANYDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
||||
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/* uefi_call_wrapper() is a macro in efibind.h */
|
||||
@@ -0,0 +1,193 @@
|
||||
/*
|
||||
* Function calling ABI conversion from Linux to EFI for x86_64
|
||||
*
|
||||
* Copyright (C) 2007 Intel Corp
|
||||
* Bibo Mao <bibo.mao@intel.com>
|
||||
* Huang Ying <ying.huang@intel.com>
|
||||
* Copyright (C) 2012 Felipe Contreras <felipe.contreras@gmail.com>
|
||||
*/
|
||||
|
||||
#if !defined(HAVE_USE_MS_ABI)
|
||||
/*
|
||||
* EFI calling conventions are documented at:
|
||||
* http://msdn.microsoft.com/en-us/library/ms235286%28v=vs.80%29.aspx
|
||||
* ELF calling conventions are documented at:
|
||||
* http://www.x86-64.org/documentation/abi.pdf
|
||||
*
|
||||
* Basically here are the conversion rules:
|
||||
* a) our function pointer is in %rdi
|
||||
* b) rsi through r8 (elf) aka rcx through r9 (ms) require stack space
|
||||
* on the MS side even though it's not getting used at all.
|
||||
* c) 8(%rsp) is always aligned to 16 in ELF, so %rsp is shifted 8 bytes extra
|
||||
* d) arguments are as follows: (elf -> ms)
|
||||
* 1) rdi -> rcx (32 saved)
|
||||
* 2) rsi -> rdx (32 saved)
|
||||
* 3) rdx -> r8 (32 saved)
|
||||
* 4) rcx -> r9 (32 saved)
|
||||
* 5) r8 -> 32(%rsp) (32 saved)
|
||||
* 6) r9 -> 40(%rsp) (48 saved)
|
||||
* 7) 8(%rsp) -> 48(%rsp) (48 saved)
|
||||
* 8) 16(%rsp) -> 56(%rsp) (64 saved)
|
||||
* 9) 24(%rsp) -> 64(%rsp) (64 saved)
|
||||
* 10) 32(%rsp) -> 72(%rsp) (80 saved)
|
||||
* e) because the first argument we recieve in a thunker is actually the
|
||||
* function to be called, arguments are offset as such:
|
||||
* 0) rdi -> caller
|
||||
* 1) rsi -> rcx (32 saved)
|
||||
* 2) rdx -> rdx (32 saved)
|
||||
* 3) rcx -> r8 (32 saved)
|
||||
* 4) r8 -> r9 (32 saved)
|
||||
* 5) r9 -> 32(%rsp) (32 saved)
|
||||
* 6) 8(%rsp) -> 40(%rsp) (48 saved)
|
||||
* 7) 16(%rsp) -> 48(%rsp) (48 saved)
|
||||
* 8) 24(%rsp) -> 56(%rsp) (64 saved)
|
||||
* 9) 32(%rsp) -> 64(%rsp) (64 saved)
|
||||
* 10) 40(%rsp) -> 72(%rsp) (80 saved)
|
||||
* f) arguments need to be moved in opposite order to avoid clobbering
|
||||
*/
|
||||
|
||||
#define ENTRY(name) \
|
||||
.globl name; \
|
||||
name:
|
||||
|
||||
ENTRY(efi_call0)
|
||||
subq $40, %rsp
|
||||
call *%rdi
|
||||
addq $40, %rsp
|
||||
ret
|
||||
|
||||
ENTRY(efi_call1)
|
||||
subq $40, %rsp
|
||||
mov %rsi, %rcx
|
||||
call *%rdi
|
||||
addq $40, %rsp
|
||||
ret
|
||||
|
||||
ENTRY(efi_call2)
|
||||
subq $40, %rsp
|
||||
/* mov %rdx, %rdx */
|
||||
mov %rsi, %rcx
|
||||
call *%rdi
|
||||
addq $40, %rsp
|
||||
ret
|
||||
|
||||
ENTRY(efi_call3)
|
||||
subq $40, %rsp
|
||||
mov %rcx, %r8
|
||||
/* mov %rdx, %rdx */
|
||||
mov %rsi, %rcx
|
||||
call *%rdi
|
||||
addq $40, %rsp
|
||||
ret
|
||||
|
||||
ENTRY(efi_call4)
|
||||
subq $40, %rsp
|
||||
mov %r8, %r9
|
||||
mov %rcx, %r8
|
||||
/* mov %rdx, %rdx */
|
||||
mov %rsi, %rcx
|
||||
call *%rdi
|
||||
addq $40, %rsp
|
||||
ret
|
||||
|
||||
ENTRY(efi_call5)
|
||||
subq $40, %rsp
|
||||
mov %r9, 32(%rsp)
|
||||
mov %r8, %r9
|
||||
mov %rcx, %r8
|
||||
/* mov %rdx, %rdx */
|
||||
mov %rsi, %rcx
|
||||
call *%rdi
|
||||
addq $40, %rsp
|
||||
ret
|
||||
|
||||
ENTRY(efi_call6)
|
||||
subq $56, %rsp
|
||||
mov 56+8(%rsp), %rax
|
||||
mov %rax, 40(%rsp)
|
||||
mov %r9, 32(%rsp)
|
||||
mov %r8, %r9
|
||||
mov %rcx, %r8
|
||||
/* mov %rdx, %rdx */
|
||||
mov %rsi, %rcx
|
||||
call *%rdi
|
||||
addq $56, %rsp
|
||||
ret
|
||||
|
||||
ENTRY(efi_call7)
|
||||
subq $56, %rsp
|
||||
mov 56+16(%rsp), %rax
|
||||
mov %rax, 48(%rsp)
|
||||
mov 56+8(%rsp), %rax
|
||||
mov %rax, 40(%rsp)
|
||||
mov %r9, 32(%rsp)
|
||||
mov %r8, %r9
|
||||
mov %rcx, %r8
|
||||
/* mov %rdx, %rdx */
|
||||
mov %rsi, %rcx
|
||||
call *%rdi
|
||||
addq $56, %rsp
|
||||
ret
|
||||
|
||||
ENTRY(efi_call8)
|
||||
subq $72, %rsp
|
||||
mov 72+24(%rsp), %rax
|
||||
mov %rax, 56(%rsp)
|
||||
mov 72+16(%rsp), %rax
|
||||
mov %rax, 48(%rsp)
|
||||
mov 72+8(%rsp), %rax
|
||||
mov %rax, 40(%rsp)
|
||||
mov %r9, 32(%rsp)
|
||||
mov %r8, %r9
|
||||
mov %rcx, %r8
|
||||
/* mov %rdx, %rdx */
|
||||
mov %rsi, %rcx
|
||||
call *%rdi
|
||||
addq $72, %rsp
|
||||
ret
|
||||
|
||||
ENTRY(efi_call9)
|
||||
subq $72, %rsp
|
||||
mov 72+32(%rsp), %rax
|
||||
mov %rax, 64(%rsp)
|
||||
mov 72+24(%rsp), %rax
|
||||
mov %rax, 56(%rsp)
|
||||
mov 72+16(%rsp), %rax
|
||||
mov %rax, 48(%rsp)
|
||||
mov 72+8(%rsp), %rax
|
||||
mov %rax, 40(%rsp)
|
||||
mov %r9, 32(%rsp)
|
||||
mov %r8, %r9
|
||||
mov %rcx, %r8
|
||||
/* mov %rdx, %rdx */
|
||||
mov %rsi, %rcx
|
||||
call *%rdi
|
||||
addq $72, %rsp
|
||||
ret
|
||||
|
||||
ENTRY(efi_call10)
|
||||
subq $88, %rsp
|
||||
mov 88+40(%rsp), %rax
|
||||
mov %rax, 72(%rsp)
|
||||
mov 88+32(%rsp), %rax
|
||||
mov %rax, 64(%rsp)
|
||||
mov 88+24(%rsp), %rax
|
||||
mov %rax, 56(%rsp)
|
||||
mov 88+16(%rsp), %rax
|
||||
mov %rax, 48(%rsp)
|
||||
mov 88+8(%rsp), %rax
|
||||
mov %rax, 40(%rsp)
|
||||
mov %r9, 32(%rsp)
|
||||
mov %r8, %r9
|
||||
mov %rcx, %r8
|
||||
/* mov %rdx, %rdx */
|
||||
mov %rsi, %rcx
|
||||
call *%rdi
|
||||
addq $88, %rsp
|
||||
ret
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(__ELF__) && defined(__linux__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
@@ -0,0 +1,27 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
initplat.c
|
||||
|
||||
Abstract:
|
||||
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
#include "lib.h"
|
||||
|
||||
VOID
|
||||
InitializeLibPlatform (
|
||||
IN EFI_HANDLE ImageHandle EFI_UNUSED,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable EFI_UNUSED
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -0,0 +1,181 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
math.c
|
||||
|
||||
Abstract:
|
||||
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
#include "lib.h"
|
||||
|
||||
|
||||
//
|
||||
// Declare runtime functions
|
||||
//
|
||||
|
||||
#ifdef RUNTIME_CODE
|
||||
#ifndef __GNUC__
|
||||
#pragma RUNTIME_CODE(LShiftU64)
|
||||
#pragma RUNTIME_CODE(RShiftU64)
|
||||
#pragma RUNTIME_CODE(MultU64x32)
|
||||
#pragma RUNTIME_CODE(DivU64x32)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
UINT64
|
||||
LShiftU64 (
|
||||
IN UINT64 Operand,
|
||||
IN UINTN Count
|
||||
)
|
||||
// Left shift 64bit by 32bit and get a 64bit result
|
||||
{
|
||||
#if defined(__GNUC__) || defined(_MSC_EXTENSIONS)
|
||||
return Operand << Count;
|
||||
#else
|
||||
UINT64 Result;
|
||||
_asm {
|
||||
mov eax, dword ptr Operand[0]
|
||||
mov edx, dword ptr Operand[4]
|
||||
mov ecx, Count
|
||||
and ecx, 63
|
||||
|
||||
shld edx, eax, cl
|
||||
shl eax, cl
|
||||
|
||||
cmp ecx, 32
|
||||
jc short ls10
|
||||
|
||||
mov edx, eax
|
||||
xor eax, eax
|
||||
|
||||
ls10:
|
||||
mov dword ptr Result[0], eax
|
||||
mov dword ptr Result[4], edx
|
||||
}
|
||||
|
||||
return Result;
|
||||
#endif
|
||||
}
|
||||
|
||||
UINT64
|
||||
RShiftU64 (
|
||||
IN UINT64 Operand,
|
||||
IN UINTN Count
|
||||
)
|
||||
// Right shift 64bit by 32bit and get a 64bit result
|
||||
{
|
||||
#if defined(__GNUC__) || defined(_MSC_EXTENSIONS)
|
||||
return Operand >> Count;
|
||||
#else
|
||||
UINT64 Result;
|
||||
_asm {
|
||||
mov eax, dword ptr Operand[0]
|
||||
mov edx, dword ptr Operand[4]
|
||||
mov ecx, Count
|
||||
and ecx, 63
|
||||
|
||||
shrd eax, edx, cl
|
||||
shr edx, cl
|
||||
|
||||
cmp ecx, 32
|
||||
jc short rs10
|
||||
|
||||
mov eax, edx
|
||||
xor edx, edx
|
||||
|
||||
rs10:
|
||||
mov dword ptr Result[0], eax
|
||||
mov dword ptr Result[4], edx
|
||||
}
|
||||
|
||||
return Result;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
UINT64
|
||||
MultU64x32 (
|
||||
IN UINT64 Multiplicand,
|
||||
IN UINTN Multiplier
|
||||
)
|
||||
// Multiple 64bit by 32bit and get a 64bit result
|
||||
{
|
||||
#if defined(__GNUC__) || defined(_MSC_EXTENSIONS)
|
||||
return Multiplicand * Multiplier;
|
||||
#else
|
||||
UINT64 Result;
|
||||
_asm {
|
||||
mov eax, dword ptr Multiplicand[0]
|
||||
mul Multiplier
|
||||
mov dword ptr Result[0], eax
|
||||
mov dword ptr Result[4], edx
|
||||
mov eax, dword ptr Multiplicand[4]
|
||||
mul Multiplier
|
||||
add dword ptr Result[4], eax
|
||||
}
|
||||
|
||||
return Result;
|
||||
#endif
|
||||
}
|
||||
|
||||
UINT64
|
||||
DivU64x32 (
|
||||
IN UINT64 Dividend,
|
||||
IN UINTN Divisor,
|
||||
OUT UINTN *Remainder OPTIONAL
|
||||
)
|
||||
// divide 64bit by 32bit and get a 64bit result
|
||||
// N.B. only works for 31bit divisors!!
|
||||
{
|
||||
#if defined(__GNUC__) || defined(_MSC_EXTENSIONS)
|
||||
if (Remainder)
|
||||
*Remainder = Dividend % Divisor;
|
||||
return Dividend / Divisor;
|
||||
#else
|
||||
UINT32 Rem;
|
||||
UINT32 bit;
|
||||
|
||||
ASSERT (Divisor != 0);
|
||||
ASSERT ((Divisor >> 31) == 0);
|
||||
|
||||
//
|
||||
// For each bit in the dividend
|
||||
//
|
||||
|
||||
Rem = 0;
|
||||
for (bit=0; bit < 64; bit++) {
|
||||
_asm {
|
||||
shl dword ptr Dividend[0], 1 ; shift rem:dividend left one
|
||||
rcl dword ptr Dividend[4], 1
|
||||
rcl dword ptr Rem, 1
|
||||
|
||||
mov eax, Rem
|
||||
cmp eax, Divisor ; Is Rem >= Divisor?
|
||||
cmc ; No - do nothing
|
||||
sbb eax, eax ; Else,
|
||||
sub dword ptr Dividend[0], eax ; set low bit in dividen
|
||||
and eax, Divisor ; and
|
||||
sub Rem, eax ; subtract divisor
|
||||
}
|
||||
}
|
||||
|
||||
if (Remainder) {
|
||||
*Remainder = Rem;
|
||||
}
|
||||
|
||||
return Dividend;
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
.text
|
||||
.globl base_setjmp
|
||||
#ifndef __MINGW32__
|
||||
.type base_setjmp, @function
|
||||
#else
|
||||
.def base_setjmp; .scl 2; .type 32; .endef
|
||||
#endif
|
||||
base_setjmp:
|
||||
pop %rsi
|
||||
movq %rbx,0x00(%rdi)
|
||||
movq %rsp,0x08(%rdi)
|
||||
push %rsi
|
||||
movq %rbp,0x10(%rdi)
|
||||
movq %r12,0x18(%rdi)
|
||||
movq %r13,0x20(%rdi)
|
||||
movq %r14,0x28(%rdi)
|
||||
movq %r15,0x30(%rdi)
|
||||
movq %rsi,0x38(%rdi)
|
||||
xor %rax,%rax
|
||||
ret
|
||||
|
||||
.globl base_longjmp
|
||||
#ifndef __MINGW32__
|
||||
.type base_longjmp, @function
|
||||
#else
|
||||
.def base_longjmp; .scl 2; .type 32; .endef
|
||||
#endif
|
||||
base_longjmp:
|
||||
movl %esi, %eax
|
||||
movq 0x00(%rdi), %rbx
|
||||
movq 0x08(%rdi), %rsp
|
||||
movq 0x10(%rdi), %rbp
|
||||
movq 0x18(%rdi), %r12
|
||||
movq 0x20(%rdi), %r13
|
||||
movq 0x28(%rdi), %r14
|
||||
movq 0x30(%rdi), %r15
|
||||
xor %rdx,%rdx
|
||||
mov $1,%rcx
|
||||
cmp %rax,%rdx
|
||||
cmove %rcx,%rax
|
||||
jmp *0x38(%rdi)
|
||||
|
||||
#if defined(__ELF__) && defined(__linux__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
-1
Submodule gnu-efi deleted from 8a45cdb08c
Reference in New Issue
Block a user