mirror of
				https://gitlab.com/qemu-project/ipxe.git
				synced 2025-11-03 07:59:06 +08:00 
			
		
		
		
	Compare commits
	
		
			67 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 19daabe383 | |||
| 25a3d3acab | |||
| 8ab9bdca4f | |||
| 12776acce5 | |||
| 367e022b5e | |||
| b9a60fb0b7 | |||
| a64764d10f | |||
| bc75bbaf17 | |||
| e7adf5701f | |||
| 92ab2de3a4 | |||
| 3184ff74eb | |||
| 9cb0a4b8ec | |||
| b0093571f8 | |||
| 6a7f560e60 | |||
| 5b43181436 | |||
| d2e1601cf4 | |||
| 95b8338f0d | |||
| 28184b7c22 | |||
| 3c214f0465 | |||
| ce2200d5fb | |||
| c4a8d90387 | |||
| 79d85e29aa | |||
| d27cd8196d | |||
| 03eea19c19 | |||
| 0bb0aea878 | |||
| f9beb20e99 | |||
| f93e6b712f | |||
| 22cc65535a | |||
| bd13697446 | |||
| 9fb28080d9 | |||
| 1e4c3789e9 | |||
| 0d04635ef0 | |||
| 1d1cf74a5e | |||
| aa368ba529 | |||
| 2c6a15d2a3 | |||
| 09e8a15408 | |||
| bf25e23d07 | |||
| 8f1c120119 | |||
| 54fcb7c29c | |||
| 9e1f7a3659 | |||
| e51e7bbad7 | |||
| 523788ccda | |||
| 96bb6ba441 | |||
| 33cb56cf1b | |||
| 60531ff6e2 | |||
| 04e60a278a | |||
| 471599dc77 | |||
| 7d71cf318a | |||
| 6625e49cea | |||
| 9f17d1116d | |||
| 2733c4763a | |||
| cff857461b | |||
| 6a004be0cc | |||
| cf9ad00afc | |||
| 76a286530a | |||
| 3c83843e11 | |||
| be8ecaf805 | |||
| 62a1d5c0f5 | |||
| 84cb774390 | |||
| bfa5262f0e | |||
| ef0a6f4792 | |||
| c6901792f0 | |||
| a2bed43939 | |||
| 7cc305f7b4 | |||
| dc16de3204 | |||
| 6c0335adf6 | |||
| 8450fa4a7b | 
							
								
								
									
										58
									
								
								.github/workflows/build.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										58
									
								
								.github/workflows/build.yml
									
									
									
									
										vendored
									
									
								
							@ -4,21 +4,53 @@ on: push
 | 
			
		||||
 | 
			
		||||
jobs:
 | 
			
		||||
 | 
			
		||||
  cache:
 | 
			
		||||
    name: Cache
 | 
			
		||||
    runs-on: ubuntu-22.04
 | 
			
		||||
    steps:
 | 
			
		||||
      - name: Cache permissions
 | 
			
		||||
        run: |
 | 
			
		||||
          sudo chown $(id -un) /var/cache/apt/archives
 | 
			
		||||
      - name: Cache packages
 | 
			
		||||
        uses: actions/cache@v3
 | 
			
		||||
        with:
 | 
			
		||||
          path: /var/cache/apt/archives/*.deb
 | 
			
		||||
          key: apt-cache-${{ github.run_id }}-${{ github.run_attempt }}
 | 
			
		||||
          restore-keys: |
 | 
			
		||||
            apt-cache-
 | 
			
		||||
      - name: Download packages
 | 
			
		||||
        run: |
 | 
			
		||||
          sudo apt update
 | 
			
		||||
          sudo apt install -y -d -o Acquire::Retries=50 \
 | 
			
		||||
                           mtools syslinux isolinux \
 | 
			
		||||
                           libc6-dev-i386 valgrind \
 | 
			
		||||
                           gcc-arm-none-eabi gcc-aarch64-linux-gnu
 | 
			
		||||
 | 
			
		||||
  x86:
 | 
			
		||||
    name: x86
 | 
			
		||||
    runs-on: ubuntu-20.04
 | 
			
		||||
    runs-on: ubuntu-22.04
 | 
			
		||||
    needs: cache
 | 
			
		||||
    steps:
 | 
			
		||||
      - name: Check out code
 | 
			
		||||
        uses: actions/checkout@v3
 | 
			
		||||
        with:
 | 
			
		||||
          fetch-depth: 0
 | 
			
		||||
      - name: Cache permissions
 | 
			
		||||
        run: |
 | 
			
		||||
          sudo chown $(id -un) /var/cache/apt/archives
 | 
			
		||||
      - name: Cache packages
 | 
			
		||||
        uses: actions/cache/restore@v3
 | 
			
		||||
        with:
 | 
			
		||||
          path: /var/cache/apt/archives/*.deb
 | 
			
		||||
          key: apt-cache-${{ github.run_id }}-${{ github.run_attempt }}
 | 
			
		||||
      - name: Install packages
 | 
			
		||||
        run: |
 | 
			
		||||
          sudo dpkg --add-architecture i386
 | 
			
		||||
          sudo apt update
 | 
			
		||||
          sudo apt install -y -o Acquire::Retries=50 \
 | 
			
		||||
                           mtools syslinux isolinux \
 | 
			
		||||
                           libc6-dev-i386 libc6-dbg:i386 valgrind
 | 
			
		||||
                           libc6-dev-i386 valgrind \
 | 
			
		||||
                           libgcc-s1:i386 libc6-dbg:i386
 | 
			
		||||
      - name: Build (BIOS)
 | 
			
		||||
        run: |
 | 
			
		||||
          make -j 4 -C src
 | 
			
		||||
@ -32,12 +64,21 @@ jobs:
 | 
			
		||||
 | 
			
		||||
  arm32:
 | 
			
		||||
    name: ARM32
 | 
			
		||||
    runs-on: ubuntu-20.04
 | 
			
		||||
    runs-on: ubuntu-22.04
 | 
			
		||||
    needs: cache
 | 
			
		||||
    steps:
 | 
			
		||||
      - name: Check out code
 | 
			
		||||
        uses: actions/checkout@v3
 | 
			
		||||
        with:
 | 
			
		||||
          fetch-depth: 0
 | 
			
		||||
      - name: Cache permissions
 | 
			
		||||
        run: |
 | 
			
		||||
          sudo chown $(id -un) /var/cache/apt/archives
 | 
			
		||||
      - name: Cache packages
 | 
			
		||||
        uses: actions/cache/restore@v3
 | 
			
		||||
        with:
 | 
			
		||||
          path: /var/cache/apt/archives/*.deb
 | 
			
		||||
          key: apt-cache-${{ github.run_id }}-${{ github.run_attempt }}
 | 
			
		||||
      - name: Install packages
 | 
			
		||||
        run: |
 | 
			
		||||
          sudo apt update
 | 
			
		||||
@ -52,12 +93,21 @@ jobs:
 | 
			
		||||
 | 
			
		||||
  arm64:
 | 
			
		||||
    name: ARM64
 | 
			
		||||
    runs-on: ubuntu-20.04
 | 
			
		||||
    runs-on: ubuntu-22.04
 | 
			
		||||
    needs: cache
 | 
			
		||||
    steps:
 | 
			
		||||
      - name: Check out code
 | 
			
		||||
        uses: actions/checkout@v3
 | 
			
		||||
        with:
 | 
			
		||||
          fetch-depth: 0
 | 
			
		||||
      - name: Cache permissions
 | 
			
		||||
        run: |
 | 
			
		||||
          sudo chown $(id -un) /var/cache/apt/archives
 | 
			
		||||
      - name: Cache packages
 | 
			
		||||
        uses: actions/cache/restore@v3
 | 
			
		||||
        with:
 | 
			
		||||
          path: /var/cache/apt/archives/*.deb
 | 
			
		||||
          key: apt-cache-${{ github.run_id }}-${{ github.run_attempt }}
 | 
			
		||||
      - name: Install packages
 | 
			
		||||
        run: |
 | 
			
		||||
          sudo apt update
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										2
									
								
								.github/workflows/coverity.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.github/workflows/coverity.yml
									
									
									
									
										vendored
									
									
								
							@ -8,7 +8,7 @@ on:
 | 
			
		||||
jobs:
 | 
			
		||||
  submit:
 | 
			
		||||
    name: Submit
 | 
			
		||||
    runs-on: ubuntu-20.04
 | 
			
		||||
    runs-on: ubuntu-22.04
 | 
			
		||||
    steps:
 | 
			
		||||
      - name: Check out code
 | 
			
		||||
        uses: actions/checkout@v3
 | 
			
		||||
 | 
			
		||||
@ -1,12 +0,0 @@
 | 
			
		||||
#ifndef _BITS_ENTROPY_H
 | 
			
		||||
#define _BITS_ENTROPY_H
 | 
			
		||||
 | 
			
		||||
/** @file
 | 
			
		||||
 *
 | 
			
		||||
 * ARM-specific entropy API implementations
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 | 
			
		||||
 | 
			
		||||
#endif /* _BITS_ENTROPY_H */
 | 
			
		||||
@ -9,6 +9,9 @@
 | 
			
		||||
 | 
			
		||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 | 
			
		||||
 | 
			
		||||
/** Page shift */
 | 
			
		||||
#define PAGE_SHIFT 12
 | 
			
		||||
 | 
			
		||||
#include <ipxe/arm_io.h>
 | 
			
		||||
 | 
			
		||||
#endif /* _BITS_IO_H */
 | 
			
		||||
 | 
			
		||||
@ -20,9 +20,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
/** Page shift */
 | 
			
		||||
#define PAGE_SHIFT 12
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Physical<->Bus address mappings
 | 
			
		||||
 *
 | 
			
		||||
 | 
			
		||||
@ -8,6 +8,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 | 
			
		||||
 | 
			
		||||
#ifndef ASSEMBLY
 | 
			
		||||
 | 
			
		||||
/** Unprefixed constant operand modifier */
 | 
			
		||||
#define ASM_NO_PREFIX "c"
 | 
			
		||||
 | 
			
		||||
#define __asmcall
 | 
			
		||||
#define __libgcc
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -8,6 +8,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 | 
			
		||||
 | 
			
		||||
#ifndef ASSEMBLY
 | 
			
		||||
 | 
			
		||||
/** Unprefixed constant operand modifier */
 | 
			
		||||
#define ASM_NO_PREFIX "c"
 | 
			
		||||
 | 
			
		||||
#define __asmcall
 | 
			
		||||
#define __libgcc
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -8,6 +8,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 | 
			
		||||
 | 
			
		||||
#ifndef ASSEMBLY
 | 
			
		||||
 | 
			
		||||
/** Unprefixed constant operand modifier */
 | 
			
		||||
#define ASM_NO_PREFIX "c"
 | 
			
		||||
 | 
			
		||||
/** Declare a function with standard calling conventions */
 | 
			
		||||
#define __asmcall __attribute__ (( cdecl, regparm(0) ))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										26
									
								
								src/arch/loong64/Makefile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								src/arch/loong64/Makefile
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,26 @@
 | 
			
		||||
# Assembler section type character
 | 
			
		||||
#
 | 
			
		||||
ASM_TCHAR	:= @
 | 
			
		||||
ASM_TCHAR_OPS	:= @
 | 
			
		||||
 | 
			
		||||
# LoongArch64-specific flags
 | 
			
		||||
#
 | 
			
		||||
CFLAGS		+= -fstrength-reduce -fomit-frame-pointer
 | 
			
		||||
CFLAGS		+= -falign-jumps=1 -falign-loops=1 -falign-functions=1
 | 
			
		||||
 | 
			
		||||
# Check if -mno-explicit-relocs is valid
 | 
			
		||||
ifeq ($(CCTYPE),gcc)
 | 
			
		||||
MNER_TEST = $(CC) -mno-explicit-relocs -x c -c /dev/null -o /dev/null >/dev/null 2>&1
 | 
			
		||||
MNER_FLAGS := $(shell $(MNER_TEST) && $(ECHO) '-mno-explicit-relocs')
 | 
			
		||||
WORKAROUND_CFLAGS += $(MNER_FLAGS)
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
# EFI requires -fshort-wchar, and nothing else currently uses wchar_t
 | 
			
		||||
CFLAGS		+= -fshort-wchar
 | 
			
		||||
 | 
			
		||||
# LoongArch64-specific directories containing source files
 | 
			
		||||
SRCDIRS		+= arch/loong64/core
 | 
			
		||||
 | 
			
		||||
# Include platform-specific Makefile
 | 
			
		||||
MAKEDEPS	+= arch/loong64/Makefile.$(PLATFORM)
 | 
			
		||||
include arch/loong64/Makefile.$(PLATFORM)
 | 
			
		||||
							
								
								
									
										10
									
								
								src/arch/loong64/Makefile.linux
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								src/arch/loong64/Makefile.linux
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,10 @@
 | 
			
		||||
# -*- makefile -*- : Force emacs to use Makefile mode
 | 
			
		||||
 | 
			
		||||
# Starting virtual address
 | 
			
		||||
#
 | 
			
		||||
LDFLAGS += -Ttext=0x120000000
 | 
			
		||||
 | 
			
		||||
# Include generic Linux Makefile
 | 
			
		||||
#
 | 
			
		||||
MAKEDEPS += Makefile.linux
 | 
			
		||||
include Makefile.linux
 | 
			
		||||
							
								
								
									
										120
									
								
								src/arch/loong64/core/loong64_bigint.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										120
									
								
								src/arch/loong64/core/loong64_bigint.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,120 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (C) 2012 Michael Brown <mbrown@fensystems.co.uk>.
 | 
			
		||||
 * Copyright (c) 2023, Xiaotian Wu <wuxiaotian@loongson.cn>
 | 
			
		||||
 *
 | 
			
		||||
 * This program is free software; you can redistribute it and/or
 | 
			
		||||
 * modify it under the terms of the GNU General Public License as
 | 
			
		||||
 * published by the Free Software Foundation; either version 2 of the
 | 
			
		||||
 * License, or any later version.
 | 
			
		||||
 *
 | 
			
		||||
 * This program 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
 | 
			
		||||
 * General Public License for more details.
 | 
			
		||||
 *
 | 
			
		||||
 * You should have received a copy of the GNU General Public License
 | 
			
		||||
 * along with this program; if not, write to the Free Software
 | 
			
		||||
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 | 
			
		||||
 * 02110-1301, USA.
 | 
			
		||||
 *
 | 
			
		||||
 * You can also choose to distribute this program under the terms of
 | 
			
		||||
 * the Unmodified Binary Distribution Licence (as given in the file
 | 
			
		||||
 * COPYING.UBDL), provided that you have satisfied its requirements.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 | 
			
		||||
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <ipxe/bigint.h>
 | 
			
		||||
 | 
			
		||||
/** @file
 | 
			
		||||
 *
 | 
			
		||||
 * Big integer support
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Multiply big integers
 | 
			
		||||
 *
 | 
			
		||||
 * @v multiplicand0	Element 0 of big integer to be multiplied
 | 
			
		||||
 * @v multiplier0	Element 0 of big integer to be multiplied
 | 
			
		||||
 * @v result0		Element 0 of big integer to hold result
 | 
			
		||||
 * @v size		Number of elements
 | 
			
		||||
 */
 | 
			
		||||
void bigint_multiply_raw ( const uint64_t *multiplicand0,
 | 
			
		||||
			   const uint64_t *multiplier0,
 | 
			
		||||
			   uint64_t *result0, unsigned int size ) {
 | 
			
		||||
	const bigint_t ( size ) __attribute__ (( may_alias )) *multiplicand =
 | 
			
		||||
		( ( const void * ) multiplicand0 );
 | 
			
		||||
	const bigint_t ( size ) __attribute__ (( may_alias )) *multiplier =
 | 
			
		||||
		( ( const void * ) multiplier0 );
 | 
			
		||||
	bigint_t ( size * 2 ) __attribute__ (( may_alias )) *result =
 | 
			
		||||
		( ( void * ) result0 );
 | 
			
		||||
	unsigned int i;
 | 
			
		||||
	unsigned int j;
 | 
			
		||||
	uint64_t multiplicand_element;
 | 
			
		||||
	uint64_t multiplier_element;
 | 
			
		||||
	uint64_t *result_elements;
 | 
			
		||||
	uint64_t discard_low;
 | 
			
		||||
	uint64_t discard_high;
 | 
			
		||||
	uint64_t discard_temp_low;
 | 
			
		||||
	uint64_t discard_temp_high;
 | 
			
		||||
 | 
			
		||||
	/* Zero result */
 | 
			
		||||
	memset ( result, 0, sizeof ( *result ) );
 | 
			
		||||
 | 
			
		||||
	/* Multiply integers one element at a time */
 | 
			
		||||
	for ( i = 0 ; i < size ; i++ ) {
 | 
			
		||||
		multiplicand_element = multiplicand->element[i];
 | 
			
		||||
		for ( j = 0 ; j < size ; j++ ) {
 | 
			
		||||
			multiplier_element = multiplier->element[j];
 | 
			
		||||
			result_elements = &result->element[ i + j ];
 | 
			
		||||
			/* Perform a single multiply, and add the
 | 
			
		||||
			 * resulting double-element into the result,
 | 
			
		||||
			 * carrying as necessary.  The carry can
 | 
			
		||||
			 * never overflow beyond the end of the
 | 
			
		||||
			 * result, since:
 | 
			
		||||
			 *
 | 
			
		||||
			 *     a < 2^{n}, b < 2^{n} => ab < 2^{2n}
 | 
			
		||||
			 */
 | 
			
		||||
			__asm__ __volatile__ ( "mul.d   %1, %6, %7\n\t"
 | 
			
		||||
					       "mulh.du %2, %6, %7\n\t"
 | 
			
		||||
 | 
			
		||||
					       "ld.d    %3, %0, 0\n\t"
 | 
			
		||||
					       "ld.d    %4, %0, 8\n\t"
 | 
			
		||||
 | 
			
		||||
					       "add.d   %3, %3, %1\n\t"
 | 
			
		||||
					       "sltu    $t0, %3, %1\n\t"
 | 
			
		||||
 | 
			
		||||
					       "add.d   %4, %4, %2\n\t"
 | 
			
		||||
					       "sltu    $t1, %4, %2\n\t"
 | 
			
		||||
 | 
			
		||||
					       "add.d   %4, %4, $t0\n\t"
 | 
			
		||||
					       "sltu    $t0, %4, $t0\n\t"
 | 
			
		||||
					       "or      $t0, $t0, $t1\n\t"
 | 
			
		||||
 | 
			
		||||
					       "st.d    %3,  %0, 0\n\t"
 | 
			
		||||
					       "st.d    %4,  %0, 8\n\t"
 | 
			
		||||
 | 
			
		||||
					       "addi.d  %0,  %0, 16\n\t"
 | 
			
		||||
					       "beqz    $t0, 2f\n"
 | 
			
		||||
					       "1:\n\t"
 | 
			
		||||
					       "ld.d    %3,  %0, 0\n\t"
 | 
			
		||||
					       "add.d   %3,  %3, $t0\n\t"
 | 
			
		||||
					       "sltu    $t0, %3, $t0\n\t"
 | 
			
		||||
					       "st.d    %3,  %0, 0\n\t"
 | 
			
		||||
					       "addi.d  %0, %0, 8\n\t"
 | 
			
		||||
					       "bnez    $t0, 1b\n"
 | 
			
		||||
					       "2:"
 | 
			
		||||
					       : "+r" ( result_elements ),
 | 
			
		||||
						 "=&r" ( discard_low ),
 | 
			
		||||
						 "=&r" ( discard_high ),
 | 
			
		||||
						 "=r" ( discard_temp_low ),
 | 
			
		||||
						 "=r" ( discard_temp_high ),
 | 
			
		||||
						 "+m" ( *result )
 | 
			
		||||
					       : "r" ( multiplicand_element ),
 | 
			
		||||
						 "r" ( multiplier_element )
 | 
			
		||||
					       : "t0", "t1" );
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										266
									
								
								src/arch/loong64/core/loong64_string.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										266
									
								
								src/arch/loong64/core/loong64_string.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,266 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (C) 2016 Michael Brown <mbrown@fensystems.co.uk>.
 | 
			
		||||
 * Copyright (c) 2023, Xiaotian Wu <wuxiaotian@loongson.cn>
 | 
			
		||||
 *
 | 
			
		||||
 * This program is free software; you can redistribute it and/or
 | 
			
		||||
 * modify it under the terms of the GNU General Public License as
 | 
			
		||||
 * published by the Free Software Foundation; either version 2 of the
 | 
			
		||||
 * License, or any later version.
 | 
			
		||||
 *
 | 
			
		||||
 * This program 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
 | 
			
		||||
 * General Public License for more details.
 | 
			
		||||
 *
 | 
			
		||||
 * You should have received a copy of the GNU General Public License
 | 
			
		||||
 * along with this program; if not, write to the Free Software
 | 
			
		||||
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 | 
			
		||||
 * 02110-1301, USA.
 | 
			
		||||
 *
 | 
			
		||||
 * You can also choose to distribute this program under the terms of
 | 
			
		||||
 * the Unmodified Binary Distribution Licence (as given in the file
 | 
			
		||||
 * COPYING.UBDL), provided that you have satisfied its requirements.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
/** @file
 | 
			
		||||
 *
 | 
			
		||||
 * Optimised string operations
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 | 
			
		||||
 | 
			
		||||
#include <string.h>
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Copy memory area
 | 
			
		||||
 *
 | 
			
		||||
 * @v dest		Destination address
 | 
			
		||||
 * @v src		Source address
 | 
			
		||||
 * @v len		Length
 | 
			
		||||
 * @ret dest		Destination address
 | 
			
		||||
 */
 | 
			
		||||
void loong64_memcpy ( void *dest, const void *src, size_t len ) {
 | 
			
		||||
	void *discard_dest;
 | 
			
		||||
	void *discard_end;
 | 
			
		||||
	const void *discard_src;
 | 
			
		||||
	size_t discard_offset;
 | 
			
		||||
	unsigned long discard_data;
 | 
			
		||||
	unsigned long discard_low;
 | 
			
		||||
	unsigned long discard_high;
 | 
			
		||||
 | 
			
		||||
	/* If length is too short, then just copy individual bytes.
 | 
			
		||||
	 */
 | 
			
		||||
	if ( len < 16 ) {
 | 
			
		||||
		__asm__ __volatile__ ( "beqz %0, 2f\n\t"
 | 
			
		||||
				       "\n1:\n\t"
 | 
			
		||||
				       "addi.d %0, %0, -1\n\t"
 | 
			
		||||
				       "ldx.b %1, %3, %0\n\t"
 | 
			
		||||
				       "stx.b %1, %2, %0\n\t"
 | 
			
		||||
				       "bnez %0, 1b\n\t"
 | 
			
		||||
				       "\n2:\n\t"
 | 
			
		||||
				       : "=&r" ( discard_offset ),
 | 
			
		||||
					 "=&r" ( discard_data )
 | 
			
		||||
				       : "r" ( dest ), "r" ( src ), "0" ( len )
 | 
			
		||||
				       : "memory", "t0" );
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* Copy 16 bytes at a time: one initial
 | 
			
		||||
	 * potentially unaligned access, multiple destination-aligned
 | 
			
		||||
	 * accesses, one final potentially unaligned access.
 | 
			
		||||
	 */
 | 
			
		||||
	__asm__ __volatile__ ( "ld.d %3, %1, 0\n\t"
 | 
			
		||||
			       "ld.d %4, %1, 8\n\t"
 | 
			
		||||
			       "addi.d %1, %1, 16\n\t"
 | 
			
		||||
			       "st.d %3, %0, 0\n\t"
 | 
			
		||||
			       "st.d %4, %0, 8\n\t"
 | 
			
		||||
			       "addi.d %0, %0, 16\n\t"
 | 
			
		||||
			       "andi %3, %0, 15\n\t"
 | 
			
		||||
			       "sub.d %0, %0, %3\n\t"
 | 
			
		||||
			       "sub.d %1, %1, %3\n\t"
 | 
			
		||||
			       "addi.d $t0, $zero, 0xf\n\t"
 | 
			
		||||
			       "andn %2, %5, $t0\n\t"
 | 
			
		||||
			       "b 2f\n\t"
 | 
			
		||||
			       "\n1:\n\t"
 | 
			
		||||
			       "ld.d %3, %1, 0\n\t"
 | 
			
		||||
			       "ld.d %4, %1, 8\n\t"
 | 
			
		||||
			       "addi.d %1, %1, 16\n\t"
 | 
			
		||||
			       "st.d %3, %0, 0\n\t"
 | 
			
		||||
			       "st.d %4, %0, 8\n\t"
 | 
			
		||||
			       "addi.d %0, %0, 16\n\t"
 | 
			
		||||
			       "\n2:\n\t"
 | 
			
		||||
			       "bne %0, %2, 1b\n\t"
 | 
			
		||||
			       "ld.d %3, %6, -16\n\t"
 | 
			
		||||
			       "ld.d %4, %6, -8\n\t"
 | 
			
		||||
			       "st.d %3, %5, -16\n\t"
 | 
			
		||||
			       "st.d %4, %5, -8\n\t"
 | 
			
		||||
			       : "=&r" ( discard_dest ),
 | 
			
		||||
				 "=&r" ( discard_src ),
 | 
			
		||||
				 "=&r" ( discard_end ),
 | 
			
		||||
				 "=&r" ( discard_low ),
 | 
			
		||||
				 "=&r" ( discard_high )
 | 
			
		||||
			       : "r" ( dest + len ), "r" ( src + len ),
 | 
			
		||||
				 "0" ( dest ), "1" ( src )
 | 
			
		||||
			       : "memory", "t0" );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Zero memory region
 | 
			
		||||
 *
 | 
			
		||||
 * @v dest		Destination region
 | 
			
		||||
 * @v len		Length
 | 
			
		||||
 */
 | 
			
		||||
void loong64_bzero ( void *dest, size_t len ) {
 | 
			
		||||
	size_t discard_offset;
 | 
			
		||||
	void *discard_dest;
 | 
			
		||||
	void *discard_end;
 | 
			
		||||
 | 
			
		||||
	/* If length is too short, then just zero individual bytes.
 | 
			
		||||
	 */
 | 
			
		||||
	if ( len < 16 ) {
 | 
			
		||||
		__asm__ __volatile__ ( "beqz %0, 2f\n\t"
 | 
			
		||||
				       "\n1:\n\t"
 | 
			
		||||
				       "addi.d %0, %0, -1\n\t"
 | 
			
		||||
				       "stx.b $zero, %1, %0\n\t"
 | 
			
		||||
				       "bnez %0, 1b\n\t"
 | 
			
		||||
				       "\n2:\n\t"
 | 
			
		||||
				       : "=&r" ( discard_offset )
 | 
			
		||||
				       : "r" ( dest ), "0" ( len )
 | 
			
		||||
				       : "memory" );
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* To zero 16 bytes at a time: one initial
 | 
			
		||||
	 * potentially unaligned access, multiple aligned accesses,
 | 
			
		||||
	 * one final potentially unaligned access.
 | 
			
		||||
	 */
 | 
			
		||||
 | 
			
		||||
	__asm__ __volatile__ ( "st.d $zero, %0, 0\n\t"
 | 
			
		||||
			       "st.d $zero, %0, 8\n\t"
 | 
			
		||||
			       "addi.d %0, %0, 16\n\t"
 | 
			
		||||
			       "addi.w $t0, $zero, 15\n\t"
 | 
			
		||||
			       "andn %0, %0, $t0\n\t"
 | 
			
		||||
			       "addi.w $t0, $zero, 15\n\t"
 | 
			
		||||
			       "andn %1, %2, $t0\n\t"
 | 
			
		||||
			       "b 2f\n\t"
 | 
			
		||||
			       "\n1:\n\t"
 | 
			
		||||
			       "st.d $zero, %0, 0\n\t"
 | 
			
		||||
			       "st.d $zero, %0, 8\n\t"
 | 
			
		||||
			       "addi.d %0, %0, 16\n\t"
 | 
			
		||||
			       "\n2:\n\t"
 | 
			
		||||
			       "bne %0, %1, 1b\n\t"
 | 
			
		||||
			       "st.d $zero, %2, -16\n\t"
 | 
			
		||||
			       "st.d $zero, %2, -8\n\t"
 | 
			
		||||
			       : "=&r" ( discard_dest ),
 | 
			
		||||
				 "=&r" ( discard_end )
 | 
			
		||||
			       : "r" ( dest + len ), "0" ( dest )
 | 
			
		||||
			       : "memory", "t0" );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Fill memory region
 | 
			
		||||
 *
 | 
			
		||||
 * @v dest		Destination region
 | 
			
		||||
 * @v len		Length
 | 
			
		||||
 * @v character		Fill character
 | 
			
		||||
 *
 | 
			
		||||
 * The unusual parameter order is to allow for more efficient
 | 
			
		||||
 * tail-calling to loong64_memset() when zeroing a region.
 | 
			
		||||
 */
 | 
			
		||||
void loong64_memset ( void *dest, size_t len, int character ) {
 | 
			
		||||
	size_t discard_offset;
 | 
			
		||||
 | 
			
		||||
	/* Use optimised zeroing code if applicable */
 | 
			
		||||
	if ( character == 0 ) {
 | 
			
		||||
		loong64_bzero ( dest, len );
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* Fill one byte at a time.  Calling memset() with a non-zero
 | 
			
		||||
	 * value is relatively rare and unlikely to be
 | 
			
		||||
	 * performance-critical.
 | 
			
		||||
	 */
 | 
			
		||||
	__asm__ __volatile__ ( "beqz %0, 2f\n\t"
 | 
			
		||||
			       "\n1:\n\t"
 | 
			
		||||
			       "addi.d %0, %0, -1\n\t"
 | 
			
		||||
			       "stx.b %2, %1, %0\n\t"
 | 
			
		||||
			       "bnez %0, 1b\n\t"
 | 
			
		||||
			       "\n2:\n\t"
 | 
			
		||||
			       : "=&r" ( discard_offset )
 | 
			
		||||
			       : "r" ( dest ), "r" ( character ), "0" ( len )
 | 
			
		||||
			       : "memory" );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Copy (possibly overlapping) memory region forwards
 | 
			
		||||
 *
 | 
			
		||||
 * @v dest		Destination region
 | 
			
		||||
 * @v src		Source region
 | 
			
		||||
 * @v len		Length
 | 
			
		||||
 */
 | 
			
		||||
void loong64_memmove_forwards ( void *dest, const void *src, size_t len ) {
 | 
			
		||||
	void *discard_dest;
 | 
			
		||||
	const void *discard_src;
 | 
			
		||||
	unsigned long discard_data;
 | 
			
		||||
 | 
			
		||||
	/* Assume memmove() is not performance-critical, and perform a
 | 
			
		||||
	 * bytewise copy for simplicity.
 | 
			
		||||
	 */
 | 
			
		||||
	__asm__ __volatile__ ( "b 2f\n\t"
 | 
			
		||||
			       "\n1:\n\t"
 | 
			
		||||
			       "ld.b %2, %1, 0\n\t"
 | 
			
		||||
			       "addi.d %1, %1, 1\n\t"
 | 
			
		||||
			       "st.b %2, %0, 0\n\t"
 | 
			
		||||
			       "addi.d %0, %0, 1\n\t"
 | 
			
		||||
			       "\n2:\n\t"
 | 
			
		||||
			       "bne %0, %3, 1b\n\t"
 | 
			
		||||
			       : "=&r" ( discard_dest ),
 | 
			
		||||
				 "=&r" ( discard_src ),
 | 
			
		||||
				 "=&r" ( discard_data )
 | 
			
		||||
			       : "r" ( dest + len ), "0" ( dest ), "1" ( src )
 | 
			
		||||
			       : "memory" );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Copy (possibly overlapping) memory region backwards
 | 
			
		||||
 *
 | 
			
		||||
 * @v dest		Destination region
 | 
			
		||||
 * @v src		Source region
 | 
			
		||||
 * @v len		Length
 | 
			
		||||
 */
 | 
			
		||||
void loong64_memmove_backwards ( void *dest, const void *src, size_t len ) {
 | 
			
		||||
	size_t discard_offset;
 | 
			
		||||
	unsigned long discard_data;
 | 
			
		||||
 | 
			
		||||
	/* Assume memmove() is not performance-critical, and perform a
 | 
			
		||||
	 * bytewise copy for simplicity.
 | 
			
		||||
	 */
 | 
			
		||||
	__asm__ __volatile__ ( "beqz %0, 2f\n\t"
 | 
			
		||||
			       "\n1:\n\t"
 | 
			
		||||
			       "addi.d %0, %0, -1\n\t"
 | 
			
		||||
			       "ldx.b %1, %3, %0\n\t"
 | 
			
		||||
			       "stx.b %1, %2, %0\n\t"
 | 
			
		||||
			       "bnez %0, 1b\n\t"
 | 
			
		||||
			       "\n2:\n\t"
 | 
			
		||||
			       : "=&r" ( discard_offset ),
 | 
			
		||||
				 "=&r" ( discard_data )
 | 
			
		||||
			       : "r" ( dest ), "r" ( src ), "0" ( len )
 | 
			
		||||
			       : "memory" );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Copy (possibly overlapping) memory region
 | 
			
		||||
 *
 | 
			
		||||
 * @v dest		Destination region
 | 
			
		||||
 * @v src		Source region
 | 
			
		||||
 * @v len		Length
 | 
			
		||||
 */
 | 
			
		||||
void loong64_memmove ( void *dest, const void *src, size_t len ) {
 | 
			
		||||
 | 
			
		||||
	if ( dest <= src ) {
 | 
			
		||||
		loong64_memmove_forwards ( dest, src, len );
 | 
			
		||||
	} else {
 | 
			
		||||
		loong64_memmove_backwards ( dest, src, len );
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										53
									
								
								src/arch/loong64/core/setjmp.S
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								src/arch/loong64/core/setjmp.S
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,53 @@
 | 
			
		||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
 | 
			
		||||
 | 
			
		||||
	.section ".note.GNU-stack", "", %progbits
 | 
			
		||||
	.text
 | 
			
		||||
/*
 | 
			
		||||
   int setjmp(jmp_buf env);
 | 
			
		||||
*/
 | 
			
		||||
	.globl	setjmp
 | 
			
		||||
	.type	setjmp, %function
 | 
			
		||||
setjmp:
 | 
			
		||||
	/* Store registers */
 | 
			
		||||
	st.d	$s0, $a0, 0x0
 | 
			
		||||
	st.d	$s1, $a0, 0x8
 | 
			
		||||
	st.d	$s2, $a0, 0x10
 | 
			
		||||
	st.d	$s3, $a0, 0x18
 | 
			
		||||
	st.d	$s4, $a0, 0x20
 | 
			
		||||
	st.d	$s5, $a0, 0x28
 | 
			
		||||
	st.d	$s6, $a0, 0x30
 | 
			
		||||
	st.d	$s7, $a0, 0x38
 | 
			
		||||
	st.d	$s8, $a0, 0x40
 | 
			
		||||
	st.d	$fp, $a0, 0x48
 | 
			
		||||
	st.d	$sp, $a0, 0x50
 | 
			
		||||
	st.d	$ra, $a0, 0x58
 | 
			
		||||
 | 
			
		||||
	move	$a0, $zero
 | 
			
		||||
	jirl	$zero, $ra, 0
 | 
			
		||||
	.size	setjmp, . - setjmp
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
   void longjmp(jmp_buf env, int val);
 | 
			
		||||
*/
 | 
			
		||||
	.globl	longjmp
 | 
			
		||||
	.type	longjmp, %function
 | 
			
		||||
longjmp:
 | 
			
		||||
	/* Restore registers */
 | 
			
		||||
	ld.d	$s0, $a0, 0x0
 | 
			
		||||
	ld.d	$s1, $a0, 0x8
 | 
			
		||||
	ld.d	$s2, $a0, 0x10
 | 
			
		||||
	ld.d	$s3, $a0, 0x18
 | 
			
		||||
	ld.d	$s4, $a0, 0x20
 | 
			
		||||
	ld.d	$s5, $a0, 0x28
 | 
			
		||||
	ld.d	$s6, $a0, 0x30
 | 
			
		||||
	ld.d	$s7, $a0, 0x38
 | 
			
		||||
	ld.d	$s8, $a0, 0x40
 | 
			
		||||
	ld.d	$fp, $a0, 0x48
 | 
			
		||||
	ld.d	$sp, $a0, 0x50
 | 
			
		||||
	ld.d	$ra, $a0, 0x58
 | 
			
		||||
	addi.d	$a0, $zero, 1    # a0 = 1
 | 
			
		||||
	beqz	$a1, .exit       # if (a1 == 0); goto L0
 | 
			
		||||
	move	$a0, $a1         # a0 = a1
 | 
			
		||||
.exit:
 | 
			
		||||
	jirl	$zero, $ra, 0
 | 
			
		||||
	.size	longjmp, . - longjmp
 | 
			
		||||
							
								
								
									
										12
									
								
								src/arch/loong64/include/bits/acpi.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								src/arch/loong64/include/bits/acpi.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,12 @@
 | 
			
		||||
#ifndef _BITS_ACPI_H
 | 
			
		||||
#define _BITS_ACPI_H
 | 
			
		||||
 | 
			
		||||
/** @file
 | 
			
		||||
 *
 | 
			
		||||
 * LoongArch64-specific ACPI API implementations
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 | 
			
		||||
 | 
			
		||||
#endif /* _BITS_ACPI_H */
 | 
			
		||||
							
								
								
									
										336
									
								
								src/arch/loong64/include/bits/bigint.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										336
									
								
								src/arch/loong64/include/bits/bigint.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,336 @@
 | 
			
		||||
#ifndef _BITS_BIGINT_H
 | 
			
		||||
#define _BITS_BIGINT_H
 | 
			
		||||
 | 
			
		||||
/** @file
 | 
			
		||||
 *
 | 
			
		||||
 * Big integer support
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 | 
			
		||||
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <strings.h>
 | 
			
		||||
 | 
			
		||||
/** Element of a big integer */
 | 
			
		||||
typedef uint64_t bigint_element_t;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Initialise big integer
 | 
			
		||||
 *
 | 
			
		||||
 * @v value0	Element 0 of big integer to initialise
 | 
			
		||||
 * @v size		Number of elements
 | 
			
		||||
 * @v data		Raw data
 | 
			
		||||
 * @v len		Length of raw data
 | 
			
		||||
 */
 | 
			
		||||
static inline __attribute__ (( always_inline )) void
 | 
			
		||||
bigint_init_raw ( uint64_t *value0, unsigned int size,
 | 
			
		||||
		  const void *data, size_t len ) {
 | 
			
		||||
	size_t pad_len = ( sizeof ( bigint_t ( size ) ) - len );
 | 
			
		||||
	uint8_t *value_byte = ( ( void * ) value0 );
 | 
			
		||||
	const uint8_t *data_byte = ( data + len );
 | 
			
		||||
 | 
			
		||||
	/* Copy raw data in reverse order, padding with zeros */
 | 
			
		||||
	while ( len-- )
 | 
			
		||||
		*(value_byte++) = *(--data_byte);
 | 
			
		||||
	while ( pad_len-- )
 | 
			
		||||
		*(value_byte++) = 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Add big integers
 | 
			
		||||
 *
 | 
			
		||||
 * @v addend0		Element 0 of big integer to add
 | 
			
		||||
 * @v value0		Element 0 of big integer to be added to
 | 
			
		||||
 * @v size		Number of elements
 | 
			
		||||
 */
 | 
			
		||||
static inline __attribute__ (( always_inline )) void
 | 
			
		||||
bigint_add_raw ( const uint64_t *addend0, uint64_t *value0,
 | 
			
		||||
		 unsigned int size ) {
 | 
			
		||||
	bigint_t ( size ) __attribute__ (( may_alias )) *value =
 | 
			
		||||
		( ( void * ) value0 );
 | 
			
		||||
	uint64_t *discard_addend;
 | 
			
		||||
	uint64_t *discard_value;
 | 
			
		||||
	uint64_t discard_addend_i;
 | 
			
		||||
	uint64_t discard_value_i;
 | 
			
		||||
	unsigned int discard_size;
 | 
			
		||||
	__asm__ __volatile__ ( "move   $t0, $zero\n"
 | 
			
		||||
			       "1:\n\t"
 | 
			
		||||
			       "ld.d   %3, %0, 0\n\t"
 | 
			
		||||
			       "addi.d %0, %0, 8\n\t"
 | 
			
		||||
			       "ld.d   %4, %1, 0\n\t"
 | 
			
		||||
 | 
			
		||||
			       "add.d  %4, %4, $t0\n\t"
 | 
			
		||||
			       "sltu   $t0, %4, $t0\n\t"
 | 
			
		||||
 | 
			
		||||
			       "add.d  %4, %4, %3\n\t"
 | 
			
		||||
			       "sltu   $t1, %4, %3\n\t"
 | 
			
		||||
 | 
			
		||||
			       "or     $t0, $t0, $t1\n\t"
 | 
			
		||||
			       "st.d   %4,  %1, 0\n\t"
 | 
			
		||||
			       "addi.d %1, %1, 8\n\t"
 | 
			
		||||
			       "addi.w %2, %2, -1\n\t"
 | 
			
		||||
			       "bnez   %2, 1b"
 | 
			
		||||
			       : "=r" ( discard_addend ),
 | 
			
		||||
				 "=r" ( discard_value ),
 | 
			
		||||
				 "=r" ( discard_size ),
 | 
			
		||||
				 "=r" ( discard_addend_i ),
 | 
			
		||||
				 "=r" ( discard_value_i ),
 | 
			
		||||
				 "+m" ( *value )
 | 
			
		||||
			       : "0" ( addend0 ),
 | 
			
		||||
				 "1" ( value0 ),
 | 
			
		||||
				 "2" ( size )
 | 
			
		||||
			       : "t0", "t1" );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Subtract big integers
 | 
			
		||||
 *
 | 
			
		||||
 * @v subtrahend0	Element 0 of big integer to subtract
 | 
			
		||||
 * @v value0		Element 0 of big integer to be subtracted from
 | 
			
		||||
 * @v size		Number of elements
 | 
			
		||||
 */
 | 
			
		||||
static inline __attribute__ (( always_inline )) void
 | 
			
		||||
bigint_subtract_raw ( const uint64_t *subtrahend0, uint64_t *value0,
 | 
			
		||||
		      unsigned int size ) {
 | 
			
		||||
	uint64_t *discard_subtrahend;
 | 
			
		||||
	uint64_t *discard_value;
 | 
			
		||||
	uint64_t discard_subtrahend_i;
 | 
			
		||||
	uint64_t discard_value_i;
 | 
			
		||||
	unsigned int discard_size;
 | 
			
		||||
	unsigned int flag = 0;
 | 
			
		||||
 | 
			
		||||
	discard_subtrahend = (uint64_t*) subtrahend0;
 | 
			
		||||
	discard_value = value0;
 | 
			
		||||
	discard_size = size;
 | 
			
		||||
 | 
			
		||||
	do {
 | 
			
		||||
		discard_subtrahend_i = *discard_subtrahend;
 | 
			
		||||
		discard_subtrahend++;
 | 
			
		||||
		discard_value_i = *discard_value;
 | 
			
		||||
 | 
			
		||||
		discard_value_i = discard_value_i - discard_subtrahend_i - flag;
 | 
			
		||||
 | 
			
		||||
		if ( *discard_value < (discard_subtrahend_i + flag)) {
 | 
			
		||||
			flag = 1;
 | 
			
		||||
		} else {
 | 
			
		||||
			flag = 0;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		*discard_value = discard_value_i;
 | 
			
		||||
 | 
			
		||||
		discard_value++;
 | 
			
		||||
		discard_size -= 1;
 | 
			
		||||
	} while (discard_size != 0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Rotate big integer left
 | 
			
		||||
 *
 | 
			
		||||
 * @v value0		Element 0 of big integer
 | 
			
		||||
 * @v size		Number of elements
 | 
			
		||||
 */
 | 
			
		||||
static inline __attribute__ (( always_inline )) void
 | 
			
		||||
bigint_rol_raw ( uint64_t *value0, unsigned int size ) {
 | 
			
		||||
	uint64_t *discard_value;
 | 
			
		||||
	uint64_t discard_value_i;
 | 
			
		||||
	unsigned int discard_size;
 | 
			
		||||
	uint64_t current_value_i;
 | 
			
		||||
	unsigned int flag = 0;
 | 
			
		||||
 | 
			
		||||
	discard_value = value0;
 | 
			
		||||
	discard_size = size;
 | 
			
		||||
	do {
 | 
			
		||||
		discard_value_i = *discard_value;
 | 
			
		||||
		current_value_i = discard_value_i;
 | 
			
		||||
 | 
			
		||||
		discard_value_i += discard_value_i + flag;
 | 
			
		||||
 | 
			
		||||
		if (discard_value_i < current_value_i) {
 | 
			
		||||
			flag = 1;
 | 
			
		||||
		} else {
 | 
			
		||||
			flag = 0;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		*discard_value = discard_value_i;
 | 
			
		||||
		discard_value++;
 | 
			
		||||
		discard_size -= 1;
 | 
			
		||||
	} while ( discard_size != 0 );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Rotate big integer right
 | 
			
		||||
 *
 | 
			
		||||
 * @v value0		Element 0 of big integer
 | 
			
		||||
 * @v size		Number of elements
 | 
			
		||||
 */
 | 
			
		||||
static inline __attribute__ (( always_inline )) void
 | 
			
		||||
bigint_ror_raw ( uint64_t *value0, unsigned int size ) {
 | 
			
		||||
	uint64_t *discard_value;
 | 
			
		||||
	uint64_t discard_value_i;
 | 
			
		||||
	uint64_t discard_value_j;
 | 
			
		||||
	unsigned int discard_size;
 | 
			
		||||
 | 
			
		||||
	discard_value = value0;
 | 
			
		||||
	discard_size = size;
 | 
			
		||||
 | 
			
		||||
	discard_value_j = 0;
 | 
			
		||||
 | 
			
		||||
	do {
 | 
			
		||||
		discard_size -= 1;
 | 
			
		||||
 | 
			
		||||
		discard_value_i = *(discard_value + discard_size);
 | 
			
		||||
 | 
			
		||||
		discard_value_j = (discard_value_j << 63) | (discard_value_i >> 1);
 | 
			
		||||
 | 
			
		||||
		*(discard_value + discard_size) = discard_value_j;
 | 
			
		||||
 | 
			
		||||
		discard_value_j = discard_value_i;
 | 
			
		||||
	} while ( discard_size > 0 );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Test if big integer is equal to zero
 | 
			
		||||
 *
 | 
			
		||||
 * @v value0		Element 0 of big integer
 | 
			
		||||
 * @v size		Number of elements
 | 
			
		||||
 * @ret is_zero		Big integer is equal to zero
 | 
			
		||||
 */
 | 
			
		||||
static inline __attribute__ (( always_inline, pure )) int
 | 
			
		||||
bigint_is_zero_raw ( const uint64_t *value0, unsigned int size ) {
 | 
			
		||||
	const uint64_t *value = value0;
 | 
			
		||||
	uint64_t value_i;
 | 
			
		||||
 | 
			
		||||
	do {
 | 
			
		||||
		value_i = *(value++);
 | 
			
		||||
		if ( value_i )
 | 
			
		||||
			break;
 | 
			
		||||
	} while ( --size );
 | 
			
		||||
 | 
			
		||||
	return ( value_i == 0 );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Compare big integers
 | 
			
		||||
 *
 | 
			
		||||
 * @v value0		Element 0 of big integer
 | 
			
		||||
 * @v reference0	Element 0 of reference big integer
 | 
			
		||||
 * @v size		Number of elements
 | 
			
		||||
 * @ret geq		Big integer is greater than or equal to the reference
 | 
			
		||||
 */
 | 
			
		||||
static inline __attribute__ (( always_inline, pure )) int
 | 
			
		||||
bigint_is_geq_raw ( const uint64_t *value0, const uint64_t *reference0,
 | 
			
		||||
		    unsigned int size ) {
 | 
			
		||||
	const uint64_t *value = ( value0 + size );
 | 
			
		||||
	const uint64_t *reference = ( reference0 + size );
 | 
			
		||||
	uint64_t value_i;
 | 
			
		||||
	uint64_t reference_i;
 | 
			
		||||
 | 
			
		||||
	do {
 | 
			
		||||
		value_i = *(--value);
 | 
			
		||||
		reference_i = *(--reference);
 | 
			
		||||
		if ( value_i != reference_i )
 | 
			
		||||
			break;
 | 
			
		||||
	} while ( --size );
 | 
			
		||||
 | 
			
		||||
	return ( value_i >= reference_i );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Test if bit is set in big integer
 | 
			
		||||
 *
 | 
			
		||||
 * @v value0		Element 0 of big integer
 | 
			
		||||
 * @v size		Number of elements
 | 
			
		||||
 * @v bit		Bit to test
 | 
			
		||||
 * @ret is_set		Bit is set
 | 
			
		||||
 */
 | 
			
		||||
static inline __attribute__ (( always_inline )) int
 | 
			
		||||
bigint_bit_is_set_raw ( const uint64_t *value0, unsigned int size,
 | 
			
		||||
			unsigned int bit ) {
 | 
			
		||||
	const bigint_t ( size ) __attribute__ (( may_alias )) *value =
 | 
			
		||||
		( ( const void * ) value0 );
 | 
			
		||||
	unsigned int index = ( bit / ( 8 * sizeof ( value->element[0] ) ) );
 | 
			
		||||
	unsigned int subindex = ( bit % ( 8 * sizeof ( value->element[0] ) ) );
 | 
			
		||||
 | 
			
		||||
	return ( !! ( value->element[index] & ( 1UL << subindex ) ) );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Find highest bit set in big integer
 | 
			
		||||
 *
 | 
			
		||||
 * @v value0		Element 0 of big integer
 | 
			
		||||
 * @v size		Number of elements
 | 
			
		||||
 * @ret max_bit		Highest bit set + 1 (or 0 if no bits set)
 | 
			
		||||
 */
 | 
			
		||||
static inline __attribute__ (( always_inline )) int
 | 
			
		||||
bigint_max_set_bit_raw ( const uint64_t *value0, unsigned int size ) {
 | 
			
		||||
	const uint64_t *value = ( value0 + size );
 | 
			
		||||
	int max_bit = ( 8 * sizeof ( bigint_t ( size ) ) );
 | 
			
		||||
	uint64_t value_i;
 | 
			
		||||
 | 
			
		||||
	do {
 | 
			
		||||
		value_i = *(--value);
 | 
			
		||||
		max_bit -= ( 64 - fls ( value_i ) );
 | 
			
		||||
		if ( value_i )
 | 
			
		||||
			break;
 | 
			
		||||
	} while ( --size );
 | 
			
		||||
 | 
			
		||||
	return max_bit;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Grow big integer
 | 
			
		||||
 *
 | 
			
		||||
 * @v source0		Element 0 of source big integer
 | 
			
		||||
 * @v source_size	Number of elements in source big integer
 | 
			
		||||
 * @v dest0		Element 0 of destination big integer
 | 
			
		||||
 * @v dest_size		Number of elements in destination big integer
 | 
			
		||||
 */
 | 
			
		||||
static inline __attribute__ (( always_inline )) void
 | 
			
		||||
bigint_grow_raw ( const uint64_t *source0, unsigned int source_size,
 | 
			
		||||
		  uint64_t *dest0, unsigned int dest_size ) {
 | 
			
		||||
	unsigned int pad_size = ( dest_size - source_size );
 | 
			
		||||
 | 
			
		||||
	memcpy ( dest0, source0, sizeof ( bigint_t ( source_size ) ) );
 | 
			
		||||
	memset ( ( dest0 + source_size ), 0, sizeof ( bigint_t ( pad_size ) ) );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Shrink big integer
 | 
			
		||||
 *
 | 
			
		||||
 * @v source0		Element 0 of source big integer
 | 
			
		||||
 * @v source_size	Number of elements in source big integer
 | 
			
		||||
 * @v dest0		Element 0 of destination big integer
 | 
			
		||||
 * @v dest_size		Number of elements in destination big integer
 | 
			
		||||
 */
 | 
			
		||||
static inline __attribute__ (( always_inline )) void
 | 
			
		||||
bigint_shrink_raw ( const uint64_t *source0, unsigned int source_size __unused,
 | 
			
		||||
		    uint64_t *dest0, unsigned int dest_size ) {
 | 
			
		||||
 | 
			
		||||
	memcpy ( dest0, source0, sizeof ( bigint_t ( dest_size ) ) );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Finalise big integer
 | 
			
		||||
 *
 | 
			
		||||
 * @v value0		Element 0 of big integer to finalise
 | 
			
		||||
 * @v size		Number of elements
 | 
			
		||||
 * @v out		Output buffer
 | 
			
		||||
 * @v len		Length of output buffer
 | 
			
		||||
 */
 | 
			
		||||
static inline __attribute__ (( always_inline )) void
 | 
			
		||||
bigint_done_raw ( const uint64_t *value0, unsigned int size __unused,
 | 
			
		||||
		  void *out, size_t len ) {
 | 
			
		||||
	const uint8_t *value_byte = ( ( const void * ) value0 );
 | 
			
		||||
	uint8_t *out_byte = ( out + len );
 | 
			
		||||
 | 
			
		||||
	/* Copy raw data in reverse order */
 | 
			
		||||
	while ( len-- )
 | 
			
		||||
		*(--out_byte) = *(value_byte++);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
extern void bigint_multiply_raw ( const uint64_t *multiplicand0,
 | 
			
		||||
				  const uint64_t *multiplier0,
 | 
			
		||||
				  uint64_t *value0, unsigned int size );
 | 
			
		||||
 | 
			
		||||
#endif /* _BITS_BIGINT_H */
 | 
			
		||||
							
								
								
									
										102
									
								
								src/arch/loong64/include/bits/bitops.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										102
									
								
								src/arch/loong64/include/bits/bitops.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,102 @@
 | 
			
		||||
#ifndef _BITS_BITOPS_H
 | 
			
		||||
#define _BITS_BITOPS_H
 | 
			
		||||
 | 
			
		||||
/** @file
 | 
			
		||||
 *
 | 
			
		||||
 * loongArch bit operations
 | 
			
		||||
 *
 | 
			
		||||
 * We perform atomic bit set and bit clear operations using "ll"
 | 
			
		||||
 * and "sc".  We use the output constraint to inform the
 | 
			
		||||
 * compiler that any memory from the start of the bit field up to and
 | 
			
		||||
 * including the byte containing the bit may be modified.  (This is
 | 
			
		||||
 * overkill but shouldn't matter in practice since we're unlikely to
 | 
			
		||||
 * subsequently read other bits from the same bit field.)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 | 
			
		||||
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Test and set bit atomically
 | 
			
		||||
 *
 | 
			
		||||
 * @v bit		Bit to set
 | 
			
		||||
 * @v bits		Bit field
 | 
			
		||||
 * @ret old		Old value of bit (zero or non-zero)
 | 
			
		||||
 */
 | 
			
		||||
static inline __attribute__ (( always_inline )) int
 | 
			
		||||
test_and_set_bit ( unsigned int bit, volatile void *bits ) {
 | 
			
		||||
	unsigned int index = ( bit / 64 );
 | 
			
		||||
	unsigned int offset = ( bit % 64 );
 | 
			
		||||
	volatile uint64_t *qword = ( ( ( volatile uint64_t * ) bits ) + index );
 | 
			
		||||
	uint64_t mask = ( 1UL << offset );
 | 
			
		||||
	uint64_t old;
 | 
			
		||||
	uint64_t new;
 | 
			
		||||
 | 
			
		||||
	__asm__ __volatile__ ( "1:				\n\t"
 | 
			
		||||
			       "ll.d %[old], %[qword]		\n\t"
 | 
			
		||||
			       "or   %[new], %[old], %[mask]	\n\t"
 | 
			
		||||
			       "sc.d %[new], %[qword]		\n\t"
 | 
			
		||||
			       "beqz %[new], 1b			\n\t"
 | 
			
		||||
			       : [old] "=&r" ( old ),
 | 
			
		||||
				 [new] "=&r" ( new ),
 | 
			
		||||
				 [qword] "+m" ( *qword )
 | 
			
		||||
			       : [mask] "r" ( mask )
 | 
			
		||||
			       : "cc", "memory");
 | 
			
		||||
	return ( !! ( old & mask ) );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Test and clear bit atomically
 | 
			
		||||
 *
 | 
			
		||||
 * @v bit		Bit to set
 | 
			
		||||
 * @v bits		Bit field
 | 
			
		||||
 * @ret old		Old value of bit (zero or non-zero)
 | 
			
		||||
 */
 | 
			
		||||
static inline __attribute__ (( always_inline )) int
 | 
			
		||||
test_and_clear_bit ( unsigned int bit, volatile void *bits ) {
 | 
			
		||||
	unsigned int index = ( bit / 64 );
 | 
			
		||||
	unsigned int offset = ( bit % 64 );
 | 
			
		||||
	volatile uint64_t *qword = ( ( ( volatile uint64_t * ) bits ) + index );
 | 
			
		||||
	uint64_t mask = ( 1UL << offset );
 | 
			
		||||
	uint64_t old;
 | 
			
		||||
	uint64_t new;
 | 
			
		||||
 | 
			
		||||
	__asm__ __volatile__ ( "1:				\n\t"
 | 
			
		||||
			       "ll.d %[old], %[qword]		\n\t"
 | 
			
		||||
			       "andn %[new], %[old], %[mask]	\n\t"
 | 
			
		||||
			       "sc.d %[new], %[qword]		\n\t"
 | 
			
		||||
			       "beqz %[new], 1b			\n\t"
 | 
			
		||||
			       : [old] "=&r" ( old ),
 | 
			
		||||
				 [new] "=&r" ( new ),
 | 
			
		||||
				 [qword] "+m" ( *qword )
 | 
			
		||||
			       : [mask] "r" ( mask )
 | 
			
		||||
			       : "cc", "memory");
 | 
			
		||||
	return ( !! ( old & mask ) );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Set bit atomically
 | 
			
		||||
 *
 | 
			
		||||
 * @v bit		Bit to set
 | 
			
		||||
 * @v bits		Bit field
 | 
			
		||||
 */
 | 
			
		||||
static inline __attribute__ (( always_inline )) void
 | 
			
		||||
set_bit ( unsigned int bit, volatile void *bits ) {
 | 
			
		||||
 | 
			
		||||
	test_and_set_bit ( bit, bits );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Clear bit atomically
 | 
			
		||||
 *
 | 
			
		||||
 * @v bit		Bit to set
 | 
			
		||||
 * @v bits		Bit field
 | 
			
		||||
 */
 | 
			
		||||
static inline __attribute__ (( always_inline )) void
 | 
			
		||||
clear_bit ( unsigned int bit, volatile void *bits ) {
 | 
			
		||||
 | 
			
		||||
	test_and_clear_bit ( bit, bits );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif /* _BITS_BITOPS_H */
 | 
			
		||||
							
								
								
									
										47
									
								
								src/arch/loong64/include/bits/byteswap.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										47
									
								
								src/arch/loong64/include/bits/byteswap.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,47 @@
 | 
			
		||||
#ifndef _BITS_BYTESWAP_H
 | 
			
		||||
#define _BITS_BYTESWAP_H
 | 
			
		||||
 | 
			
		||||
/** @file
 | 
			
		||||
 *
 | 
			
		||||
 * Byte-order swapping functions
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
 | 
			
		||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 | 
			
		||||
 | 
			
		||||
static inline __attribute__ (( always_inline, const )) uint16_t
 | 
			
		||||
__bswap_variable_16 ( uint16_t x ) {
 | 
			
		||||
	__asm__ ( "revb.2h %0, %1" : "=r" ( x ) : "r" ( x ) );
 | 
			
		||||
	return x;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static inline __attribute__ (( always_inline )) void
 | 
			
		||||
__bswap_16s ( uint16_t *x ) {
 | 
			
		||||
	*x = __bswap_variable_16 ( *x );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static inline __attribute__ (( always_inline, const )) uint32_t
 | 
			
		||||
__bswap_variable_32 ( uint32_t x ) {
 | 
			
		||||
	__asm__ ( "revb.2w %0, %1" : "=r" ( x ) : "r" ( x ) );
 | 
			
		||||
	return x;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static inline __attribute__ (( always_inline )) void
 | 
			
		||||
__bswap_32s ( uint32_t *x ) {
 | 
			
		||||
	*x = __bswap_variable_32 ( *x );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static inline __attribute__ (( always_inline, const )) uint64_t
 | 
			
		||||
__bswap_variable_64 ( uint64_t x ) {
 | 
			
		||||
	__asm__ ( "revb.d %0, %1" : "=r" ( x ) : "r" ( x ) );
 | 
			
		||||
	return x;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static inline __attribute__ (( always_inline )) void
 | 
			
		||||
__bswap_64s ( uint64_t *x ) {
 | 
			
		||||
	*x = __bswap_variable_64 ( *x );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										19
									
								
								src/arch/loong64/include/bits/compiler.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								src/arch/loong64/include/bits/compiler.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,19 @@
 | 
			
		||||
#ifndef _BITS_COMPILER_H
 | 
			
		||||
#define _BITS_COMPILER_H
 | 
			
		||||
 | 
			
		||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 | 
			
		||||
 | 
			
		||||
/** Dummy relocation type */
 | 
			
		||||
#define RELOC_TYPE_NONE R_LARCH_NONE
 | 
			
		||||
 | 
			
		||||
#ifndef ASSEMBLY
 | 
			
		||||
 | 
			
		||||
/** Unprefixed constant operand modifier */
 | 
			
		||||
#define ASM_NO_PREFIX "a"
 | 
			
		||||
 | 
			
		||||
#define __asmcall
 | 
			
		||||
#define __libgcc
 | 
			
		||||
 | 
			
		||||
#endif /* ASSEMBLY */
 | 
			
		||||
 | 
			
		||||
#endif /*_BITS_COMPILER_H */
 | 
			
		||||
							
								
								
									
										8
									
								
								src/arch/loong64/include/bits/endian.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								src/arch/loong64/include/bits/endian.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,8 @@
 | 
			
		||||
#ifndef _BITS_ENDIAN_H
 | 
			
		||||
#define _BITS_ENDIAN_H
 | 
			
		||||
 | 
			
		||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 | 
			
		||||
 | 
			
		||||
#define __BYTE_ORDER __LITTLE_ENDIAN
 | 
			
		||||
 | 
			
		||||
#endif /* _BITS_ENDIAN_H */
 | 
			
		||||
							
								
								
									
										19
									
								
								src/arch/loong64/include/bits/errfile.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								src/arch/loong64/include/bits/errfile.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,19 @@
 | 
			
		||||
#ifndef _BITS_ERRFILE_H
 | 
			
		||||
#define _BITS_ERRFILE_H
 | 
			
		||||
 | 
			
		||||
/** @file
 | 
			
		||||
 *
 | 
			
		||||
 * LoongArch64-specific error file identifiers
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @addtogroup errfile Error file identifiers
 | 
			
		||||
 * @{
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
/** @} */
 | 
			
		||||
 | 
			
		||||
#endif /* _BITS_ERRFILE_H */
 | 
			
		||||
							
								
								
									
										12
									
								
								src/arch/loong64/include/bits/hyperv.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								src/arch/loong64/include/bits/hyperv.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,12 @@
 | 
			
		||||
#ifndef _BITS_HYPERV_H
 | 
			
		||||
#define _BITS_HYPERV_H
 | 
			
		||||
 | 
			
		||||
/** @file
 | 
			
		||||
 *
 | 
			
		||||
 * Hyper-V interface
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 | 
			
		||||
 | 
			
		||||
#endif /* _BITS_HYPERV_H */
 | 
			
		||||
							
								
								
									
										15
									
								
								src/arch/loong64/include/bits/io.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								src/arch/loong64/include/bits/io.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,15 @@
 | 
			
		||||
#ifndef _BITS_IO_H
 | 
			
		||||
#define _BITS_IO_H
 | 
			
		||||
 | 
			
		||||
/** @file
 | 
			
		||||
 *
 | 
			
		||||
 * LoongArch64-specific I/O API implementations
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 | 
			
		||||
 | 
			
		||||
/** Page shift */
 | 
			
		||||
#define PAGE_SHIFT 12
 | 
			
		||||
 | 
			
		||||
#endif /* _BITS_IO_H */
 | 
			
		||||
							
								
								
									
										12
									
								
								src/arch/loong64/include/bits/iomap.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								src/arch/loong64/include/bits/iomap.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,12 @@
 | 
			
		||||
#ifndef _BITS_IOMAP_H
 | 
			
		||||
#define _BITS_IOMAP_H
 | 
			
		||||
 | 
			
		||||
/** @file
 | 
			
		||||
 *
 | 
			
		||||
 * LoongArch64-specific I/O mapping API implementations
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 | 
			
		||||
 | 
			
		||||
#endif /* _BITS_IOMAP_H */
 | 
			
		||||
							
								
								
									
										12
									
								
								src/arch/loong64/include/bits/nap.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								src/arch/loong64/include/bits/nap.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,12 @@
 | 
			
		||||
#ifndef _BITS_NAP_H
 | 
			
		||||
#define _BITS_NAP_H
 | 
			
		||||
 | 
			
		||||
/** @file
 | 
			
		||||
 *
 | 
			
		||||
 * LoongArch64-specific CPU sleeping API implementations
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 | 
			
		||||
 | 
			
		||||
#endif /* _BITS_MAP_H */
 | 
			
		||||
							
								
								
									
										12
									
								
								src/arch/loong64/include/bits/pci_io.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								src/arch/loong64/include/bits/pci_io.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,12 @@
 | 
			
		||||
#ifndef _BITS_PCI_IO_H
 | 
			
		||||
#define _BITS_PCI_IO_H
 | 
			
		||||
 | 
			
		||||
/** @file
 | 
			
		||||
 *
 | 
			
		||||
 * LoongArch64-specific PCI I/O API implementations
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 | 
			
		||||
 | 
			
		||||
#endif /* _BITS_PCI_IO_H */
 | 
			
		||||
							
								
								
									
										28
									
								
								src/arch/loong64/include/bits/profile.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								src/arch/loong64/include/bits/profile.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,28 @@
 | 
			
		||||
#ifndef _BITS_PROFILE_H
 | 
			
		||||
#define _BITS_PROFILE_H
 | 
			
		||||
 | 
			
		||||
/** @file
 | 
			
		||||
 *
 | 
			
		||||
 * Profiling
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 | 
			
		||||
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Get profiling timestamp
 | 
			
		||||
 *
 | 
			
		||||
 * @ret timestamp	Timestamp
 | 
			
		||||
 */
 | 
			
		||||
static inline __attribute__ (( always_inline )) uint64_t
 | 
			
		||||
profile_timestamp ( void ) {
 | 
			
		||||
	uint64_t cycles;
 | 
			
		||||
 | 
			
		||||
	/* Read cycle counter */
 | 
			
		||||
	__asm__ __volatile__ ( "rdtime.d %0, $zero\n\t" : "=r" ( cycles ) );
 | 
			
		||||
	return cycles;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif /* _BITS_PROFILE_H */
 | 
			
		||||
							
								
								
									
										12
									
								
								src/arch/loong64/include/bits/reboot.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								src/arch/loong64/include/bits/reboot.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,12 @@
 | 
			
		||||
#ifndef _BITS_REBOOT_H
 | 
			
		||||
#define _BITS_REBOOT_H
 | 
			
		||||
 | 
			
		||||
/** @file
 | 
			
		||||
 *
 | 
			
		||||
 * LoongArch64-specific reboot API implementations
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 | 
			
		||||
 | 
			
		||||
#endif /* _BITS_REBOOT_H */
 | 
			
		||||
							
								
								
									
										12
									
								
								src/arch/loong64/include/bits/sanboot.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								src/arch/loong64/include/bits/sanboot.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,12 @@
 | 
			
		||||
#ifndef _BITS_SANBOOT_H
 | 
			
		||||
#define _BITS_SANBOOT_H
 | 
			
		||||
 | 
			
		||||
/** @file
 | 
			
		||||
 *
 | 
			
		||||
 * LoongArch64-specific sanboot API implementations
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 | 
			
		||||
 | 
			
		||||
#endif /* _BITS_SANBOOT_H */
 | 
			
		||||
							
								
								
									
										12
									
								
								src/arch/loong64/include/bits/smbios.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								src/arch/loong64/include/bits/smbios.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,12 @@
 | 
			
		||||
#ifndef _BITS_SMBIOS_H
 | 
			
		||||
#define _BITS_SMBIOS_H
 | 
			
		||||
 | 
			
		||||
/** @file
 | 
			
		||||
 *
 | 
			
		||||
 * LoongArch64-specific SMBIOS API implementations
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 | 
			
		||||
 | 
			
		||||
#endif /* _BITS_SMBIOS_H */
 | 
			
		||||
							
								
								
									
										23
									
								
								src/arch/loong64/include/bits/stdint.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								src/arch/loong64/include/bits/stdint.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,23 @@
 | 
			
		||||
#ifndef _BITS_STDINT_H
 | 
			
		||||
#define _BITS_STDINT_H
 | 
			
		||||
 | 
			
		||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 | 
			
		||||
 | 
			
		||||
typedef __SIZE_TYPE__		size_t;
 | 
			
		||||
typedef signed long		ssize_t;
 | 
			
		||||
typedef signed long		off_t;
 | 
			
		||||
 | 
			
		||||
typedef unsigned char		uint8_t;
 | 
			
		||||
typedef unsigned short		uint16_t;
 | 
			
		||||
typedef unsigned int		uint32_t;
 | 
			
		||||
typedef unsigned long long	uint64_t;
 | 
			
		||||
 | 
			
		||||
typedef signed char		int8_t;
 | 
			
		||||
typedef signed short		int16_t;
 | 
			
		||||
typedef signed int		int32_t;
 | 
			
		||||
typedef signed long long	int64_t;
 | 
			
		||||
 | 
			
		||||
typedef unsigned long		physaddr_t;
 | 
			
		||||
typedef unsigned long		intptr_t;
 | 
			
		||||
 | 
			
		||||
#endif /* _BITS_STDINT_H */
 | 
			
		||||
							
								
								
									
										61
									
								
								src/arch/loong64/include/bits/string.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										61
									
								
								src/arch/loong64/include/bits/string.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,61 @@
 | 
			
		||||
#ifndef _BITS_STRING_H
 | 
			
		||||
#define _BITS_STRING_H
 | 
			
		||||
 | 
			
		||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 | 
			
		||||
 | 
			
		||||
/** @file
 | 
			
		||||
 *
 | 
			
		||||
 * String functions
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
extern void loong64_bzero ( void *dest, size_t len );
 | 
			
		||||
extern void loong64_memset ( void *dest, size_t len, int character );
 | 
			
		||||
extern void loong64_memcpy ( void *dest, const void *src, size_t len );
 | 
			
		||||
extern void loong64_memmove_forwards ( void *dest, const void *src, size_t len );
 | 
			
		||||
extern void loong64_memmove_backwards ( void *dest, const void *src, size_t len );
 | 
			
		||||
extern void loong64_memmove ( void *dest, const void *src, size_t len );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Fill memory region
 | 
			
		||||
 *
 | 
			
		||||
 * @v dest		Destination region
 | 
			
		||||
 * @v character		Fill character
 | 
			
		||||
 * @v len		Length
 | 
			
		||||
 * @ret dest		Destination region
 | 
			
		||||
 */
 | 
			
		||||
static inline __attribute__ (( always_inline )) void *
 | 
			
		||||
memset ( void *dest, int character, size_t len ) {
 | 
			
		||||
	loong64_memset ( dest, len, character );
 | 
			
		||||
	return dest;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Copy memory region
 | 
			
		||||
 *
 | 
			
		||||
 * @v dest		Destination region
 | 
			
		||||
 * @v src		Source region
 | 
			
		||||
 * @v len		Length
 | 
			
		||||
 * @ret dest		Destination region
 | 
			
		||||
 */
 | 
			
		||||
static inline __attribute__ (( always_inline )) void *
 | 
			
		||||
memcpy ( void *dest, const void *src, size_t len ) {
 | 
			
		||||
	loong64_memcpy ( dest, src, len );
 | 
			
		||||
	return dest;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Copy (possibly overlapping) memory region
 | 
			
		||||
 *
 | 
			
		||||
 * @v dest		Destination region
 | 
			
		||||
 * @v src		Source region
 | 
			
		||||
 * @v len		Length
 | 
			
		||||
 * @ret dest		Destination region
 | 
			
		||||
 */
 | 
			
		||||
static inline __attribute__ (( always_inline )) void *
 | 
			
		||||
memmove ( void *dest, const void *src, size_t len ) {
 | 
			
		||||
	loong64_memmove ( dest, src, len );
 | 
			
		||||
	return dest;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif /* _BITS_STRING_H */
 | 
			
		||||
							
								
								
									
										69
									
								
								src/arch/loong64/include/bits/strings.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										69
									
								
								src/arch/loong64/include/bits/strings.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,69 @@
 | 
			
		||||
#ifndef _BITS_STRINGS_H
 | 
			
		||||
#define _BITS_STRINGS_H
 | 
			
		||||
 | 
			
		||||
/** @file
 | 
			
		||||
 *
 | 
			
		||||
 * String functions
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Find first (i.e. least significant) set bit
 | 
			
		||||
 *
 | 
			
		||||
 * @v value		Value
 | 
			
		||||
 * @ret lsb		Least significant bit set in value (LSB=1), or zero
 | 
			
		||||
 */
 | 
			
		||||
static inline __attribute__ (( always_inline )) int __ffsll ( long long value ){
 | 
			
		||||
	unsigned long long bits = value;
 | 
			
		||||
	unsigned long long lsb;
 | 
			
		||||
	unsigned int lz;
 | 
			
		||||
 | 
			
		||||
	/* Extract least significant set bit */
 | 
			
		||||
	lsb = ( bits & -bits );
 | 
			
		||||
 | 
			
		||||
	/* Count number of leading zeroes before LSB */
 | 
			
		||||
	__asm__ ( "clz.d %0, %1" : "=r" ( lz ) : "r" ( lsb ) );
 | 
			
		||||
 | 
			
		||||
	return ( 64 - lz );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Find first (i.e. least significant) set bit
 | 
			
		||||
 *
 | 
			
		||||
 * @v value		Value
 | 
			
		||||
 * @ret lsb		Least significant bit set in value (LSB=1), or zero
 | 
			
		||||
 */
 | 
			
		||||
static inline __attribute__ (( always_inline )) int __ffsl ( long value ) {
 | 
			
		||||
 | 
			
		||||
	return __ffsll ( value );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Find last (i.e. most significant) set bit
 | 
			
		||||
 *
 | 
			
		||||
 * @v value		Value
 | 
			
		||||
 * @ret msb		Most significant bit set in value (LSB=1), or zero
 | 
			
		||||
 */
 | 
			
		||||
static inline __attribute__ (( always_inline )) int __flsll ( long long value ){
 | 
			
		||||
	unsigned int lz;
 | 
			
		||||
 | 
			
		||||
	/* Count number of leading zeroes */
 | 
			
		||||
	__asm__ ( "clz.d %0, %1" : "=r" ( lz ) : "r" ( value ) );
 | 
			
		||||
 | 
			
		||||
	return ( 64 - lz );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Find last (i.e. most significant) set bit
 | 
			
		||||
 *
 | 
			
		||||
 * @v value		Value
 | 
			
		||||
 * @ret msb		Most significant bit set in value (LSB=1), or zero
 | 
			
		||||
 */
 | 
			
		||||
static inline __attribute__ (( always_inline )) int __flsl ( long value ) {
 | 
			
		||||
 | 
			
		||||
	return __flsll ( value );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif /* _BITS_STRINGS_H */
 | 
			
		||||
							
								
								
									
										19
									
								
								src/arch/loong64/include/bits/tcpip.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								src/arch/loong64/include/bits/tcpip.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,19 @@
 | 
			
		||||
#ifndef _BITS_TCPIP_H
 | 
			
		||||
#define _BITS_TCPIP_H
 | 
			
		||||
 | 
			
		||||
/** @file
 | 
			
		||||
 *
 | 
			
		||||
 * Transport-network layer interface
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 | 
			
		||||
 | 
			
		||||
static inline __attribute__ (( always_inline )) uint16_t
 | 
			
		||||
tcpip_continue_chksum ( uint16_t partial, const void *data, size_t len ) {
 | 
			
		||||
 | 
			
		||||
	/* Not yet optimised */
 | 
			
		||||
	return generic_tcpip_continue_chksum ( partial, data, len );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif /* _BITS_TCPIP_H */
 | 
			
		||||
							
								
								
									
										12
									
								
								src/arch/loong64/include/bits/time.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								src/arch/loong64/include/bits/time.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,12 @@
 | 
			
		||||
#ifndef _BITS_TIME_H
 | 
			
		||||
#define _BITS_TIME_H
 | 
			
		||||
 | 
			
		||||
/** @file
 | 
			
		||||
 *
 | 
			
		||||
 * LoongArch64-specific time API implementations
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 | 
			
		||||
 | 
			
		||||
#endif /* _BITS_TIME_H */
 | 
			
		||||
							
								
								
									
										12
									
								
								src/arch/loong64/include/bits/uaccess.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								src/arch/loong64/include/bits/uaccess.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,12 @@
 | 
			
		||||
#ifndef _BITS_UACCESS_H
 | 
			
		||||
#define _BITS_UACCESS_H
 | 
			
		||||
 | 
			
		||||
/** @file
 | 
			
		||||
 *
 | 
			
		||||
 * LoongArch64-specific user access API implementations
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 | 
			
		||||
 | 
			
		||||
#endif /* _BITS_UACCESS_H */
 | 
			
		||||
							
								
								
									
										12
									
								
								src/arch/loong64/include/bits/uart.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								src/arch/loong64/include/bits/uart.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,12 @@
 | 
			
		||||
#ifndef _BITS_UART_H
 | 
			
		||||
#define _BITS_UART_H
 | 
			
		||||
 | 
			
		||||
/** @file
 | 
			
		||||
 *
 | 
			
		||||
 * 16550-compatible UART
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 | 
			
		||||
 | 
			
		||||
#endif /* _BITS_UART_H */
 | 
			
		||||
							
								
								
									
										12
									
								
								src/arch/loong64/include/bits/umalloc.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								src/arch/loong64/include/bits/umalloc.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,12 @@
 | 
			
		||||
#ifndef _BITS_UMALLOC_H
 | 
			
		||||
#define _BITS_UMALLOC_H
 | 
			
		||||
 | 
			
		||||
/** @file
 | 
			
		||||
 *
 | 
			
		||||
 * LoongArch64-specific user memory allocation API implementations
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 | 
			
		||||
 | 
			
		||||
#endif /* _BITS_UMALLOC_H */
 | 
			
		||||
							
								
								
									
										13
									
								
								src/arch/loong64/include/bits/xen.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								src/arch/loong64/include/bits/xen.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,13 @@
 | 
			
		||||
#ifndef _BITS_XEN_H
 | 
			
		||||
#define _BITS_XEN_H
 | 
			
		||||
 | 
			
		||||
/** @file
 | 
			
		||||
 *
 | 
			
		||||
 * Xen interface
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 | 
			
		||||
 | 
			
		||||
#include <ipxe/nonxen.h>
 | 
			
		||||
 | 
			
		||||
#endif /* _BITS_XEN_H */
 | 
			
		||||
							
								
								
									
										45
									
								
								src/arch/loong64/include/gdbmach.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								src/arch/loong64/include/gdbmach.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,45 @@
 | 
			
		||||
#ifndef GDBMACH_H
 | 
			
		||||
#define GDBMACH_H
 | 
			
		||||
 | 
			
		||||
/** @file
 | 
			
		||||
 *
 | 
			
		||||
 * GDB architecture specifics
 | 
			
		||||
 *
 | 
			
		||||
 * This file declares functions for manipulating the machine state and
 | 
			
		||||
 * debugging context.
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
 | 
			
		||||
typedef unsigned long gdbreg_t;
 | 
			
		||||
 | 
			
		||||
/* Register snapshot */
 | 
			
		||||
enum {
 | 
			
		||||
	/* Not yet implemented */
 | 
			
		||||
	GDBMACH_NREGS,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#define GDBMACH_SIZEOF_REGS ( GDBMACH_NREGS * sizeof ( gdbreg_t ) )
 | 
			
		||||
 | 
			
		||||
static inline void gdbmach_set_pc ( gdbreg_t *regs, gdbreg_t pc ) {
 | 
			
		||||
	/* Not yet implemented */
 | 
			
		||||
	( void ) regs;
 | 
			
		||||
	( void ) pc;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static inline void gdbmach_set_single_step ( gdbreg_t *regs, int step ) {
 | 
			
		||||
	/* Not yet implemented */
 | 
			
		||||
	( void ) regs;
 | 
			
		||||
	( void ) step;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static inline void gdbmach_breakpoint ( void ) {
 | 
			
		||||
	/* Not yet implemented */
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
extern int gdbmach_set_breakpoint ( int type, unsigned long addr, size_t len,
 | 
			
		||||
				    int enable );
 | 
			
		||||
extern void gdbmach_init ( void );
 | 
			
		||||
 | 
			
		||||
#endif /* GDBMACH_H */
 | 
			
		||||
							
								
								
									
										20
									
								
								src/arch/loong64/include/ipxe/efi/dhcparch.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								src/arch/loong64/include/ipxe/efi/dhcparch.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,20 @@
 | 
			
		||||
#ifndef _IPXE_EFI_DHCPARCH_H
 | 
			
		||||
#define _IPXE_EFI_DHCPARCH_H
 | 
			
		||||
 | 
			
		||||
/** @file
 | 
			
		||||
 *
 | 
			
		||||
 * DHCP client architecture definitions
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 | 
			
		||||
 | 
			
		||||
#include <ipxe/dhcp.h>
 | 
			
		||||
 | 
			
		||||
/** DHCP client architecture */
 | 
			
		||||
#define DHCP_ARCH_CLIENT_ARCHITECTURE DHCP_CLIENT_ARCHITECTURE_LOONG64
 | 
			
		||||
 | 
			
		||||
/** DHCP client network device interface */
 | 
			
		||||
#define DHCP_ARCH_CLIENT_NDI 1 /* UNDI */ , 3, 10 /* v3.10 */
 | 
			
		||||
 | 
			
		||||
#endif /* _IPXE_EFI_DHCPARCH_H */
 | 
			
		||||
							
								
								
									
										53
									
								
								src/arch/loong64/include/limits.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								src/arch/loong64/include/limits.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,53 @@
 | 
			
		||||
#ifndef LIMITS_H
 | 
			
		||||
#define LIMITS_H	1
 | 
			
		||||
 | 
			
		||||
/* Number of bits in a `char' */
 | 
			
		||||
#define CHAR_BIT	8
 | 
			
		||||
 | 
			
		||||
/* Minimum and maximum values a `signed char' can hold */
 | 
			
		||||
#define SCHAR_MIN	(-128)
 | 
			
		||||
#define SCHAR_MAX	127
 | 
			
		||||
 | 
			
		||||
/* Maximum value an `unsigned char' can hold. (Minimum is 0.) */
 | 
			
		||||
#define UCHAR_MAX	255
 | 
			
		||||
 | 
			
		||||
/* Minimum and maximum values a `char' can hold */
 | 
			
		||||
#define CHAR_MIN	SCHAR_MIN
 | 
			
		||||
#define CHAR_MAX	SCHAR_MAX
 | 
			
		||||
 | 
			
		||||
/* Minimum and maximum values a `signed short int' can hold */
 | 
			
		||||
#define SHRT_MIN	(-32768)
 | 
			
		||||
#define SHRT_MAX	32767
 | 
			
		||||
 | 
			
		||||
/* Maximum value an `unsigned short' can hold. (Minimum is 0.) */
 | 
			
		||||
#define USHRT_MAX	65535
 | 
			
		||||
 | 
			
		||||
/* Minimum and maximum values a `signed int' can hold */
 | 
			
		||||
#define INT_MIN		(-INT_MAX - 1)
 | 
			
		||||
#define INT_MAX		2147483647
 | 
			
		||||
 | 
			
		||||
/* Maximum value an `unsigned int' can hold. (Minimum is 0.) */
 | 
			
		||||
#define UINT_MAX	4294967295U
 | 
			
		||||
 | 
			
		||||
/* Minimum and maximum values a `signed int' can hold */
 | 
			
		||||
#define INT_MAX		2147483647
 | 
			
		||||
#define INT_MIN		(-INT_MAX - 1)
 | 
			
		||||
 | 
			
		||||
/* Maximum value an `unsigned int' can hold. (Minimum is 0.) */
 | 
			
		||||
#define UINT_MAX	4294967295U
 | 
			
		||||
 | 
			
		||||
/* Minimum and maximum values a `signed long' can hold */
 | 
			
		||||
#define LONG_MAX	9223372036854775807L
 | 
			
		||||
#define LONG_MIN	(-LONG_MAX - 1L)
 | 
			
		||||
 | 
			
		||||
/* Maximum value an `unsigned long' can hold. (Minimum is 0.) */
 | 
			
		||||
#define ULONG_MAX	18446744073709551615UL
 | 
			
		||||
 | 
			
		||||
/* Minimum and maximum values a `signed long long' can hold */
 | 
			
		||||
#define LLONG_MAX	9223372036854775807LL
 | 
			
		||||
#define LLONG_MIN	(-LONG_MAX - 1LL)
 | 
			
		||||
 | 
			
		||||
/* Maximum value an `unsigned long long' can hold. (Minimum is 0.) */
 | 
			
		||||
#define ULLONG_MAX	18446744073709551615ULL
 | 
			
		||||
 | 
			
		||||
#endif /* LIMITS_H */
 | 
			
		||||
							
								
								
									
										31
									
								
								src/arch/loong64/include/setjmp.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								src/arch/loong64/include/setjmp.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,31 @@
 | 
			
		||||
#ifndef _SETJMP_H
 | 
			
		||||
#define _SETJMP_H
 | 
			
		||||
 | 
			
		||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 | 
			
		||||
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
 | 
			
		||||
/** jump buffer env*/
 | 
			
		||||
typedef struct {
 | 
			
		||||
	uint64_t s0;
 | 
			
		||||
	uint64_t s1;
 | 
			
		||||
	uint64_t s2;
 | 
			
		||||
	uint64_t s3;
 | 
			
		||||
	uint64_t s4;
 | 
			
		||||
	uint64_t s5;
 | 
			
		||||
	uint64_t s6;
 | 
			
		||||
	uint64_t s7;
 | 
			
		||||
	uint64_t s8;
 | 
			
		||||
 | 
			
		||||
	uint64_t fp;
 | 
			
		||||
	uint64_t sp;
 | 
			
		||||
	uint64_t ra;
 | 
			
		||||
} jmp_buf[1];
 | 
			
		||||
 | 
			
		||||
extern int __asmcall __attribute__ (( returns_twice ))
 | 
			
		||||
setjmp ( jmp_buf env );
 | 
			
		||||
 | 
			
		||||
extern void __asmcall __attribute__ (( noreturn ))
 | 
			
		||||
longjmp ( jmp_buf env, int val );
 | 
			
		||||
 | 
			
		||||
#endif /* _SETJMP_H */
 | 
			
		||||
							
								
								
									
										103
									
								
								src/arch/x86/core/rdrand.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										103
									
								
								src/arch/x86/core/rdrand.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,103 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (C) 2023 Michael Brown <mbrown@fensystems.co.uk>.
 | 
			
		||||
 *
 | 
			
		||||
 * This program is free software; you can redistribute it and/or
 | 
			
		||||
 * modify it under the terms of the GNU General Public License as
 | 
			
		||||
 * published by the Free Software Foundation; either version 2 of the
 | 
			
		||||
 * License, or any later version.
 | 
			
		||||
 *
 | 
			
		||||
 * This program 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
 | 
			
		||||
 * General Public License for more details.
 | 
			
		||||
 *
 | 
			
		||||
 * You should have received a copy of the GNU General Public License
 | 
			
		||||
 * along with this program; if not, write to the Free Software
 | 
			
		||||
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 | 
			
		||||
 * 02110-1301, USA.
 | 
			
		||||
 *
 | 
			
		||||
 * You can also choose to distribute this program under the terms of
 | 
			
		||||
 * the Unmodified Binary Distribution Licence (as given in the file
 | 
			
		||||
 * COPYING.UBDL), provided that you have satisfied its requirements.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 | 
			
		||||
 | 
			
		||||
/** @file
 | 
			
		||||
 *
 | 
			
		||||
 * Hardware random number generator
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
#include <ipxe/cpuid.h>
 | 
			
		||||
#include <ipxe/entropy.h>
 | 
			
		||||
#include <ipxe/drbg.h>
 | 
			
		||||
 | 
			
		||||
struct entropy_source rdrand_entropy __entropy_source ( ENTROPY_PREFERRED );
 | 
			
		||||
 | 
			
		||||
/** Number of times to retry RDRAND instruction */
 | 
			
		||||
#define RDRAND_RETRY_COUNT 16
 | 
			
		||||
 | 
			
		||||
/** Colour for debug messages */
 | 
			
		||||
#define colour &rdrand_entropy
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Enable entropy gathering
 | 
			
		||||
 *
 | 
			
		||||
 * @ret rc		Return status code
 | 
			
		||||
 */
 | 
			
		||||
static int rdrand_entropy_enable ( void ) {
 | 
			
		||||
	struct x86_features features;
 | 
			
		||||
 | 
			
		||||
	/* Check that RDRAND is supported */
 | 
			
		||||
	x86_features ( &features );
 | 
			
		||||
	if ( ! ( features.intel.ecx & CPUID_FEATURES_INTEL_ECX_RDRAND ) ) {
 | 
			
		||||
		DBGC ( colour, "RDRAND not supported\n" );
 | 
			
		||||
		return -ENOTSUP;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* Data returned by RDRAND is theoretically full entropy, up
 | 
			
		||||
	 * to a security strength of 128 bits, so assume that each
 | 
			
		||||
	 * sample contains exactly 8 bits of entropy.
 | 
			
		||||
	 */
 | 
			
		||||
	if ( DRBG_SECURITY_STRENGTH > 128 )
 | 
			
		||||
		return -ENOTSUP;
 | 
			
		||||
	entropy_init ( &rdrand_entropy, MIN_ENTROPY ( 8.0 ) );
 | 
			
		||||
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Get noise sample
 | 
			
		||||
 *
 | 
			
		||||
 * @ret noise		Noise sample
 | 
			
		||||
 * @ret rc		Return status code
 | 
			
		||||
 */
 | 
			
		||||
static int rdrand_get_noise ( noise_sample_t *noise ) {
 | 
			
		||||
	unsigned int result;
 | 
			
		||||
	unsigned int discard_c;
 | 
			
		||||
	unsigned int ok;
 | 
			
		||||
 | 
			
		||||
	/* Issue RDRAND, retrying until CF is set */
 | 
			
		||||
	__asm__ ( "\n1:\n\t"
 | 
			
		||||
		  "rdrand %0\n\t"
 | 
			
		||||
		  "sbb %1, %1\n\t"
 | 
			
		||||
		  "loopz 1b\n\t"
 | 
			
		||||
		  : "=r" ( result ), "=r" ( ok ), "=c" ( discard_c )
 | 
			
		||||
		  : "2" ( RDRAND_RETRY_COUNT ) );
 | 
			
		||||
	if ( ! ok ) {
 | 
			
		||||
		DBGC ( colour, "RDRAND failed to become ready\n" );
 | 
			
		||||
		return -EBUSY;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	*noise = result;
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/** Hardware random number generator entropy source */
 | 
			
		||||
struct entropy_source rdrand_entropy __entropy_source ( ENTROPY_PREFERRED ) = {
 | 
			
		||||
	.name = "rdrand",
 | 
			
		||||
	.enable = rdrand_entropy_enable,
 | 
			
		||||
	.get_noise = rdrand_get_noise,
 | 
			
		||||
};
 | 
			
		||||
@ -247,19 +247,17 @@ static void bzimage_update_header ( struct image *image,
 | 
			
		||||
 *
 | 
			
		||||
 * @v image		bzImage file
 | 
			
		||||
 * @v bzimg		bzImage context
 | 
			
		||||
 * @v cmdline		Kernel command line
 | 
			
		||||
 * @ret rc		Return status code
 | 
			
		||||
 */
 | 
			
		||||
static int bzimage_parse_cmdline ( struct image *image,
 | 
			
		||||
				   struct bzimage_context *bzimg,
 | 
			
		||||
				   char *cmdline ) {
 | 
			
		||||
				   struct bzimage_context *bzimg ) {
 | 
			
		||||
	const char *vga;
 | 
			
		||||
	const char *mem;
 | 
			
		||||
	char *sep;
 | 
			
		||||
	char *vga;
 | 
			
		||||
	char *mem;
 | 
			
		||||
	char *end;
 | 
			
		||||
 | 
			
		||||
	/* Look for "vga=" */
 | 
			
		||||
	if ( ( vga = strstr ( cmdline, "vga=" ) ) ) {
 | 
			
		||||
		vga += 4;
 | 
			
		||||
	if ( ( vga = image_argument ( image, "vga=" ) ) ) {
 | 
			
		||||
		sep = strchr ( vga, ' ' );
 | 
			
		||||
		if ( sep )
 | 
			
		||||
			*sep = '\0';
 | 
			
		||||
@ -270,10 +268,10 @@ static int bzimage_parse_cmdline ( struct image *image,
 | 
			
		||||
		} else if ( strcmp ( vga, "ask" ) == 0 ) {
 | 
			
		||||
			bzimg->vid_mode = BZI_VID_MODE_ASK;
 | 
			
		||||
		} else {
 | 
			
		||||
			bzimg->vid_mode = strtoul ( vga, &vga, 0 );
 | 
			
		||||
			if ( *vga ) {
 | 
			
		||||
			bzimg->vid_mode = strtoul ( vga, &end, 0 );
 | 
			
		||||
			if ( *end ) {
 | 
			
		||||
				DBGC ( image, "bzImage %p strange \"vga=\" "
 | 
			
		||||
				       "terminator '%c'\n", image, *vga );
 | 
			
		||||
				       "terminator '%c'\n", image, *end );
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		if ( sep )
 | 
			
		||||
@ -281,10 +279,9 @@ static int bzimage_parse_cmdline ( struct image *image,
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* Look for "mem=" */
 | 
			
		||||
	if ( ( mem = strstr ( cmdline, "mem=" ) ) ) {
 | 
			
		||||
		mem += 4;
 | 
			
		||||
		bzimg->mem_limit = strtoul ( mem, &mem, 0 );
 | 
			
		||||
		switch ( *mem ) {
 | 
			
		||||
	if ( ( mem = image_argument ( image, "mem=" ) ) ) {
 | 
			
		||||
		bzimg->mem_limit = strtoul ( mem, &end, 0 );
 | 
			
		||||
		switch ( *end ) {
 | 
			
		||||
		case 'G':
 | 
			
		||||
		case 'g':
 | 
			
		||||
			bzimg->mem_limit <<= 10;
 | 
			
		||||
@ -302,7 +299,7 @@ static int bzimage_parse_cmdline ( struct image *image,
 | 
			
		||||
			break;
 | 
			
		||||
		default:
 | 
			
		||||
			DBGC ( image, "bzImage %p strange \"mem=\" "
 | 
			
		||||
			       "terminator '%c'\n", image, *mem );
 | 
			
		||||
			       "terminator '%c'\n", image, *end );
 | 
			
		||||
			break;
 | 
			
		||||
		}
 | 
			
		||||
		bzimg->mem_limit -= 1;
 | 
			
		||||
@ -316,11 +313,10 @@ static int bzimage_parse_cmdline ( struct image *image,
 | 
			
		||||
 *
 | 
			
		||||
 * @v image		bzImage image
 | 
			
		||||
 * @v bzimg		bzImage context
 | 
			
		||||
 * @v cmdline		Kernel command line
 | 
			
		||||
 */
 | 
			
		||||
static void bzimage_set_cmdline ( struct image *image,
 | 
			
		||||
				  struct bzimage_context *bzimg,
 | 
			
		||||
				  const char *cmdline ) {
 | 
			
		||||
				  struct bzimage_context *bzimg ) {
 | 
			
		||||
	const char *cmdline = ( image->cmdline ? image->cmdline : "" );
 | 
			
		||||
	size_t cmdline_len;
 | 
			
		||||
 | 
			
		||||
	/* Copy command line down to real-mode portion */
 | 
			
		||||
@ -359,8 +355,8 @@ static size_t bzimage_load_initrd ( struct image *image,
 | 
			
		||||
	size_t offset;
 | 
			
		||||
	size_t pad_len;
 | 
			
		||||
 | 
			
		||||
	/* Do not include kernel image itself as an initrd */
 | 
			
		||||
	if ( initrd == image )
 | 
			
		||||
	/* Skip hidden images */
 | 
			
		||||
	if ( initrd->flags & IMAGE_HIDDEN )
 | 
			
		||||
		return 0;
 | 
			
		||||
 | 
			
		||||
	/* Create cpio header for non-prebuilt images */
 | 
			
		||||
@ -410,10 +406,6 @@ static int bzimage_check_initrds ( struct image *image,
 | 
			
		||||
	/* Calculate total loaded length of initrds */
 | 
			
		||||
	for_each_image ( initrd ) {
 | 
			
		||||
 | 
			
		||||
		/* Skip kernel */
 | 
			
		||||
		if ( initrd == image )
 | 
			
		||||
			continue;
 | 
			
		||||
 | 
			
		||||
		/* Calculate length */
 | 
			
		||||
		len += bzimage_load_initrd ( image, initrd, UNULL );
 | 
			
		||||
		len = bzimage_align ( len );
 | 
			
		||||
@ -528,7 +520,6 @@ static void bzimage_load_initrds ( struct image *image,
 | 
			
		||||
 */
 | 
			
		||||
static int bzimage_exec ( struct image *image ) {
 | 
			
		||||
	struct bzimage_context bzimg;
 | 
			
		||||
	char *cmdline = ( image->cmdline ? image->cmdline : "" );
 | 
			
		||||
	int rc;
 | 
			
		||||
 | 
			
		||||
	/* Read and parse header from image */
 | 
			
		||||
@ -551,7 +542,7 @@ static int bzimage_exec ( struct image *image ) {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* Parse command line for bootloader parameters */
 | 
			
		||||
	if ( ( rc = bzimage_parse_cmdline ( image, &bzimg, cmdline ) ) != 0)
 | 
			
		||||
	if ( ( rc = bzimage_parse_cmdline ( image, &bzimg ) ) != 0)
 | 
			
		||||
		return rc;
 | 
			
		||||
 | 
			
		||||
	/* Check that initrds can be loaded */
 | 
			
		||||
@ -568,7 +559,7 @@ static int bzimage_exec ( struct image *image ) {
 | 
			
		||||
		      bzimg.rm_filesz, bzimg.pm_sz );
 | 
			
		||||
 | 
			
		||||
	/* Store command line */
 | 
			
		||||
	bzimage_set_cmdline ( image, &bzimg, cmdline );
 | 
			
		||||
	bzimage_set_cmdline ( image, &bzimg );
 | 
			
		||||
 | 
			
		||||
	/* Prepare for exiting.  Must do this before loading initrds,
 | 
			
		||||
	 * since loading the initrds will corrupt the external heap.
 | 
			
		||||
 | 
			
		||||
@ -204,8 +204,8 @@ static int multiboot_add_modules ( struct image *image, physaddr_t start,
 | 
			
		||||
			break;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		/* Do not include kernel image itself as a module */
 | 
			
		||||
		if ( module_image == image )
 | 
			
		||||
		/* Skip hidden images */
 | 
			
		||||
		if ( module_image->flags & IMAGE_HIDDEN )
 | 
			
		||||
			continue;
 | 
			
		||||
 | 
			
		||||
		/* Page-align the module */
 | 
			
		||||
 | 
			
		||||
@ -1,14 +0,0 @@
 | 
			
		||||
#ifndef _BITS_ENTROPY_H
 | 
			
		||||
#define _BITS_ENTROPY_H
 | 
			
		||||
 | 
			
		||||
/** @file
 | 
			
		||||
 *
 | 
			
		||||
 * x86-specific entropy API implementations
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 | 
			
		||||
 | 
			
		||||
#include <ipxe/rtc_entropy.h>
 | 
			
		||||
 | 
			
		||||
#endif /* _BITS_ENTROPY_H */
 | 
			
		||||
@ -28,6 +28,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 | 
			
		||||
#define ERRFILE_cpuid		( ERRFILE_ARCH | ERRFILE_CORE | 0x00110000 )
 | 
			
		||||
#define ERRFILE_rdtsc_timer	( ERRFILE_ARCH | ERRFILE_CORE | 0x00120000 )
 | 
			
		||||
#define ERRFILE_acpi_timer	( ERRFILE_ARCH | ERRFILE_CORE | 0x00130000 )
 | 
			
		||||
#define ERRFILE_rdrand		( ERRFILE_ARCH | ERRFILE_CORE | 0x00140000 )
 | 
			
		||||
 | 
			
		||||
#define ERRFILE_bootsector     ( ERRFILE_ARCH | ERRFILE_IMAGE | 0x00000000 )
 | 
			
		||||
#define ERRFILE_bzimage	       ( ERRFILE_ARCH | ERRFILE_IMAGE | 0x00010000 )
 | 
			
		||||
 | 
			
		||||
@ -9,6 +9,9 @@
 | 
			
		||||
 | 
			
		||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 | 
			
		||||
 | 
			
		||||
/** Page shift */
 | 
			
		||||
#define PAGE_SHIFT 12
 | 
			
		||||
 | 
			
		||||
#include <ipxe/x86_io.h>
 | 
			
		||||
 | 
			
		||||
#endif /* _BITS_IO_H */
 | 
			
		||||
 | 
			
		||||
@ -39,6 +39,9 @@ struct x86_features {
 | 
			
		||||
/** Get standard features */
 | 
			
		||||
#define CPUID_FEATURES 0x00000001UL
 | 
			
		||||
 | 
			
		||||
/** RDRAND instruction is supported */
 | 
			
		||||
#define CPUID_FEATURES_INTEL_ECX_RDRAND 0x40000000UL
 | 
			
		||||
 | 
			
		||||
/** Hypervisor is present */
 | 
			
		||||
#define CPUID_FEATURES_INTEL_ECX_HYPERVISOR 0x80000000UL
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,62 +0,0 @@
 | 
			
		||||
#ifndef _IPXE_RTC_ENTROPY_H
 | 
			
		||||
#define _IPXE_RTC_ENTROPY_H
 | 
			
		||||
 | 
			
		||||
/** @file
 | 
			
		||||
 *
 | 
			
		||||
 * RTC-based entropy source
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 | 
			
		||||
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
 | 
			
		||||
#ifdef ENTROPY_RTC
 | 
			
		||||
#define ENTROPY_PREFIX_rtc
 | 
			
		||||
#else
 | 
			
		||||
#define ENTROPY_PREFIX_rtc __rtc_
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * min-entropy per sample
 | 
			
		||||
 *
 | 
			
		||||
 * @ret min_entropy	min-entropy of each sample
 | 
			
		||||
 */
 | 
			
		||||
static inline __always_inline min_entropy_t
 | 
			
		||||
ENTROPY_INLINE ( rtc, min_entropy_per_sample ) ( void ) {
 | 
			
		||||
 | 
			
		||||
	/* The min-entropy has been measured on several platforms
 | 
			
		||||
	 * using the entropy_sample test code.  Modelling the samples
 | 
			
		||||
	 * as independent, and using a confidence level of 99.99%, the
 | 
			
		||||
	 * measurements were as follows:
 | 
			
		||||
	 *
 | 
			
		||||
	 *    qemu-kvm		: 7.38 bits
 | 
			
		||||
	 *    VMware		: 7.46 bits
 | 
			
		||||
	 *    Physical hardware	: 2.67 bits
 | 
			
		||||
	 *
 | 
			
		||||
	 * We choose the lowest of these (2.67 bits) and apply a 50%
 | 
			
		||||
	 * safety margin to allow for some potential non-independence
 | 
			
		||||
	 * of samples.
 | 
			
		||||
	 */
 | 
			
		||||
	return MIN_ENTROPY ( 1.3 );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
extern uint8_t rtc_sample ( void );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Get noise sample
 | 
			
		||||
 *
 | 
			
		||||
 * @ret noise		Noise sample
 | 
			
		||||
 * @ret rc		Return status code
 | 
			
		||||
 */
 | 
			
		||||
static inline __always_inline int
 | 
			
		||||
ENTROPY_INLINE ( rtc, get_noise ) ( noise_sample_t *noise ) {
 | 
			
		||||
 | 
			
		||||
	/* Get sample */
 | 
			
		||||
	*noise = rtc_sample();
 | 
			
		||||
 | 
			
		||||
	/* Always successful */
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif /* _IPXE_RTC_ENTROPY_H */
 | 
			
		||||
@ -28,9 +28,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
/** Page shift */
 | 
			
		||||
#define PAGE_SHIFT 12
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Physical<->Bus address mappings
 | 
			
		||||
 *
 | 
			
		||||
 | 
			
		||||
@ -39,9 +39,14 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 | 
			
		||||
#include <ipxe/cpuid.h>
 | 
			
		||||
#include <ipxe/entropy.h>
 | 
			
		||||
 | 
			
		||||
struct entropy_source rtc_entropy __entropy_source ( ENTROPY_NORMAL );
 | 
			
		||||
 | 
			
		||||
/** Maximum time to wait for an RTC interrupt, in milliseconds */
 | 
			
		||||
#define RTC_MAX_WAIT_MS 100
 | 
			
		||||
 | 
			
		||||
/** Number of RTC interrupts to check for */
 | 
			
		||||
#define RTC_CHECK_COUNT 3
 | 
			
		||||
 | 
			
		||||
/** RTC interrupt handler */
 | 
			
		||||
extern void rtc_isr ( void );
 | 
			
		||||
 | 
			
		||||
@ -145,6 +150,7 @@ static void rtc_disable_int ( void ) {
 | 
			
		||||
 * @ret rc		Return status code
 | 
			
		||||
 */
 | 
			
		||||
static int rtc_entropy_check ( void ) {
 | 
			
		||||
	unsigned int count = 0;
 | 
			
		||||
	unsigned int i;
 | 
			
		||||
 | 
			
		||||
	/* Check that RTC interrupts are working */
 | 
			
		||||
@ -158,14 +164,18 @@ static int rtc_entropy_check ( void ) {
 | 
			
		||||
				       "cli\n\t" );
 | 
			
		||||
 | 
			
		||||
		/* Check for RTC interrupt flag */
 | 
			
		||||
		if ( rtc_flag )
 | 
			
		||||
			return 0;
 | 
			
		||||
		if ( rtc_flag ) {
 | 
			
		||||
			rtc_flag = 0;
 | 
			
		||||
			if ( ++count >= RTC_CHECK_COUNT )
 | 
			
		||||
				return 0;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		/* Delay */
 | 
			
		||||
		mdelay ( 1 );
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	DBGC ( &rtc_flag, "RTC timed out waiting for interrupt\n" );
 | 
			
		||||
	DBGC ( &rtc_flag, "RTC timed out waiting for interrupt %d/%d\n",
 | 
			
		||||
	       ( count + 1 ), RTC_CHECK_COUNT );
 | 
			
		||||
	return -ETIMEDOUT;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -195,6 +205,21 @@ static int rtc_entropy_enable ( void ) {
 | 
			
		||||
	if ( ( rc = rtc_entropy_check() ) != 0 )
 | 
			
		||||
		goto err_check;
 | 
			
		||||
 | 
			
		||||
	/* The min-entropy has been measured on several platforms
 | 
			
		||||
	 * using the entropy_sample test code.  Modelling the samples
 | 
			
		||||
	 * as independent, and using a confidence level of 99.99%, the
 | 
			
		||||
	 * measurements were as follows:
 | 
			
		||||
	 *
 | 
			
		||||
	 *    qemu-kvm		: 7.38 bits
 | 
			
		||||
	 *    VMware		: 7.46 bits
 | 
			
		||||
	 *    Physical hardware	: 2.67 bits
 | 
			
		||||
	 *
 | 
			
		||||
	 * We choose the lowest of these (2.67 bits) and apply a 50%
 | 
			
		||||
	 * safety margin to allow for some potential non-independence
 | 
			
		||||
	 * of samples.
 | 
			
		||||
	 */
 | 
			
		||||
	entropy_init ( &rtc_entropy, MIN_ENTROPY ( 1.3 ) );
 | 
			
		||||
 | 
			
		||||
	return 0;
 | 
			
		||||
 | 
			
		||||
 err_check:
 | 
			
		||||
@ -218,11 +243,12 @@ static void rtc_entropy_disable ( void ) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Measure a single RTC tick
 | 
			
		||||
 * Get noise sample
 | 
			
		||||
 *
 | 
			
		||||
 * @ret delta		Length of RTC tick (in TSC units)
 | 
			
		||||
 * @ret noise		Noise sample
 | 
			
		||||
 * @ret rc		Return status code
 | 
			
		||||
 */
 | 
			
		||||
uint8_t rtc_sample ( void ) {
 | 
			
		||||
static int rtc_get_noise ( noise_sample_t *noise ) {
 | 
			
		||||
	uint32_t before;
 | 
			
		||||
	uint32_t after;
 | 
			
		||||
	uint32_t temp;
 | 
			
		||||
@ -257,10 +283,14 @@ uint8_t rtc_sample ( void ) {
 | 
			
		||||
		: "=a" ( after ), "=d" ( before ), "=Q" ( temp )
 | 
			
		||||
		: "2" ( 0 ) );
 | 
			
		||||
 | 
			
		||||
	return ( after - before );
 | 
			
		||||
	*noise = ( after - before );
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
PROVIDE_ENTROPY_INLINE ( rtc, min_entropy_per_sample );
 | 
			
		||||
PROVIDE_ENTROPY ( rtc, entropy_enable, rtc_entropy_enable );
 | 
			
		||||
PROVIDE_ENTROPY ( rtc, entropy_disable, rtc_entropy_disable );
 | 
			
		||||
PROVIDE_ENTROPY_INLINE ( rtc, get_noise );
 | 
			
		||||
/** RTC entropy source */
 | 
			
		||||
struct entropy_source rtc_entropy __entropy_source ( ENTROPY_NORMAL ) = {
 | 
			
		||||
	.name = "rtc",
 | 
			
		||||
	.enable = rtc_entropy_enable,
 | 
			
		||||
	.disable = rtc_entropy_disable,
 | 
			
		||||
	.get_noise = rtc_get_noise,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@ -8,6 +8,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 | 
			
		||||
 | 
			
		||||
#ifndef ASSEMBLY
 | 
			
		||||
 | 
			
		||||
/** Unprefixed constant operand modifier */
 | 
			
		||||
#define ASM_NO_PREFIX "c"
 | 
			
		||||
 | 
			
		||||
/** Declare a function with standard calling conventions */
 | 
			
		||||
#define __asmcall __attribute__ (( regparm(0) ))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -290,6 +290,9 @@ REQUIRE_OBJECT ( cert_cmd );
 | 
			
		||||
#ifdef IMAGE_MEM_CMD
 | 
			
		||||
REQUIRE_OBJECT ( image_mem_cmd );
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef SHIM_CMD
 | 
			
		||||
REQUIRE_OBJECT ( shim_cmd );
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Drag in miscellaneous objects
 | 
			
		||||
@ -352,6 +355,9 @@ REQUIRE_OBJECT ( vram_settings );
 | 
			
		||||
#ifdef ACPI_SETTINGS
 | 
			
		||||
REQUIRE_OBJECT ( acpi_settings );
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef EFI_SETTINGS
 | 
			
		||||
REQUIRE_OBJECT ( efi_settings );
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Drag in selected keyboard map
 | 
			
		||||
 | 
			
		||||
@ -1,10 +1,8 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (C) 2012 Michael Brown <mbrown@fensystems.co.uk>.
 | 
			
		||||
 *
 | 
			
		||||
 * This program is free software; you can redistribute it and/or
 | 
			
		||||
 * modify it under the terms of the GNU General Public License as
 | 
			
		||||
 * published by the Free Software Foundation; either version 2 of the
 | 
			
		||||
 * License, or any later version.
 | 
			
		||||
 * License, or (at your option) any later version.
 | 
			
		||||
 *
 | 
			
		||||
 * This program is distributed in the hope that it will be useful, but
 | 
			
		||||
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
@ -23,18 +21,31 @@
 | 
			
		||||
 | 
			
		||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 | 
			
		||||
 | 
			
		||||
#include <config/entropy.h>
 | 
			
		||||
 | 
			
		||||
/** @file
 | 
			
		||||
 *
 | 
			
		||||
 * Nonexistent entropy source
 | 
			
		||||
 * Entropy configuration options
 | 
			
		||||
 *
 | 
			
		||||
 *
 | 
			
		||||
 * This source provides no entropy and must NOT be used in a
 | 
			
		||||
 * security-sensitive environment.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include <ipxe/entropy.h>
 | 
			
		||||
PROVIDE_REQUIRING_SYMBOL();
 | 
			
		||||
 | 
			
		||||
PROVIDE_ENTROPY_INLINE ( null, min_entropy_per_sample );
 | 
			
		||||
PROVIDE_ENTROPY_INLINE ( null, entropy_enable );
 | 
			
		||||
PROVIDE_ENTROPY_INLINE ( null, entropy_disable );
 | 
			
		||||
PROVIDE_ENTROPY_INLINE ( null, get_noise );
 | 
			
		||||
/*
 | 
			
		||||
 * Drag in entropy sources
 | 
			
		||||
 */
 | 
			
		||||
#ifdef ENTROPY_RTC
 | 
			
		||||
REQUIRE_OBJECT ( rtc_entropy );
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef ENTROPY_EFITICK
 | 
			
		||||
REQUIRE_OBJECT ( efi_entropy );
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef ENTROPY_EFIRNG
 | 
			
		||||
REQUIRE_OBJECT ( efi_rng );
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef ENTROPY_LINUX
 | 
			
		||||
REQUIRE_OBJECT ( linux_entropy );
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef ENTROPY_RDRAND
 | 
			
		||||
REQUIRE_OBJECT ( rdrand );
 | 
			
		||||
#endif
 | 
			
		||||
@ -49,3 +49,6 @@ REQUIRE_OBJECT ( eth_slow );
 | 
			
		||||
#ifdef NET_PROTO_EAPOL
 | 
			
		||||
REQUIRE_OBJECT ( eapol );
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef NET_PROTO_LLDP
 | 
			
		||||
REQUIRE_OBJECT ( lldp );
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
@ -19,13 +19,15 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 | 
			
		||||
#define SMBIOS_EFI
 | 
			
		||||
#define SANBOOT_EFI
 | 
			
		||||
#define BOFM_EFI
 | 
			
		||||
#define ENTROPY_EFI
 | 
			
		||||
#define ENTROPY_EFITICK
 | 
			
		||||
#define ENTROPY_EFIRNG
 | 
			
		||||
#define TIME_EFI
 | 
			
		||||
#define REBOOT_EFI
 | 
			
		||||
#define ACPI_EFI
 | 
			
		||||
#define FDT_EFI
 | 
			
		||||
 | 
			
		||||
#define	NET_PROTO_IPV6		/* IPv6 protocol */
 | 
			
		||||
#define	NET_PROTO_LLDP		/* Link Layer Discovery protocol */
 | 
			
		||||
 | 
			
		||||
#define DOWNLOAD_PROTO_FILE	/* Local filesystem access */
 | 
			
		||||
 | 
			
		||||
@ -46,9 +48,12 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 | 
			
		||||
 | 
			
		||||
#define	REBOOT_CMD		/* Reboot command */
 | 
			
		||||
 | 
			
		||||
#define EFI_SETTINGS		/* EFI variable settings */
 | 
			
		||||
 | 
			
		||||
#if defined ( __i386__ ) || defined ( __x86_64__ )
 | 
			
		||||
#define IOAPI_X86
 | 
			
		||||
#define NAP_EFIX86
 | 
			
		||||
#define ENTROPY_RDRAND
 | 
			
		||||
#define	CPUID_CMD		/* x86 CPU feature detection command */
 | 
			
		||||
#define	UNSAFE_STD		/* Avoid setting direction flag */
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
@ -33,4 +33,8 @@ FILE_LICENCE ( GPL2_OR_LATER );
 | 
			
		||||
#define SANBOOT_PROTO_FCP
 | 
			
		||||
#define SANBOOT_PROTO_HTTP
 | 
			
		||||
 | 
			
		||||
#if defined ( __i386__ ) || defined ( __x86_64__ )
 | 
			
		||||
#define ENTROPY_RDRAND
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* CONFIG_DEFAULTS_LINUX_H */
 | 
			
		||||
 | 
			
		||||
@ -20,6 +20,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 | 
			
		||||
#define SMBIOS_PCBIOS
 | 
			
		||||
#define SANBOOT_PCBIOS
 | 
			
		||||
#define ENTROPY_RTC
 | 
			
		||||
#define ENTROPY_RDRAND
 | 
			
		||||
#define TIME_RTC
 | 
			
		||||
#define REBOOT_PCBIOS
 | 
			
		||||
#define ACPI_RSDP
 | 
			
		||||
 | 
			
		||||
@ -40,6 +40,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 | 
			
		||||
#define	NET_PROTO_STP		/* Spanning Tree protocol */
 | 
			
		||||
#define	NET_PROTO_LACP		/* Link Aggregation control protocol */
 | 
			
		||||
#define	NET_PROTO_EAPOL		/* EAP over LAN protocol */
 | 
			
		||||
//#define NET_PROTO_LLDP	/* Link Layer Discovery protocol */
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * PXE support
 | 
			
		||||
@ -149,7 +150,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 | 
			
		||||
//#define POWEROFF_CMD		/* Power off command */
 | 
			
		||||
//#define IMAGE_TRUST_CMD	/* Image trust management commands */
 | 
			
		||||
//#define PCI_CMD		/* PCI commands */
 | 
			
		||||
//#define PARAM_CMD		/* Form parameter commands */
 | 
			
		||||
//#define PARAM_CMD		/* Request parameter commands */
 | 
			
		||||
//#define NEIGHBOUR_CMD		/* Neighbour management commands */
 | 
			
		||||
//#define PING_CMD		/* Ping command */
 | 
			
		||||
//#define CONSOLE_CMD		/* Console command */
 | 
			
		||||
@ -159,6 +160,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 | 
			
		||||
//#define CERT_CMD		/* Certificate management commands */
 | 
			
		||||
//#define IMAGE_MEM_CMD		/* Read memory command */
 | 
			
		||||
#define IMAGE_ARCHIVE_CMD	/* Archive image management commands */
 | 
			
		||||
#define SHIM_CMD		/* EFI shim command (or dummy command) */
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * ROM-specific options
 | 
			
		||||
 | 
			
		||||
@ -9,6 +9,8 @@
 | 
			
		||||
 | 
			
		||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 | 
			
		||||
 | 
			
		||||
#include <config/defaults.h>
 | 
			
		||||
 | 
			
		||||
#define	PCI_SETTINGS	/* PCI device settings */
 | 
			
		||||
//#define	CPUID_SETTINGS	/* CPUID settings */
 | 
			
		||||
//#define	MEMMAP_SETTINGS	/* Memory map settings */
 | 
			
		||||
 | 
			
		||||
@ -77,17 +77,12 @@ size_t cpio_name_len ( struct image *image ) {
 | 
			
		||||
 */
 | 
			
		||||
static void cpio_parse_cmdline ( struct image *image,
 | 
			
		||||
				 struct cpio_header *cpio ) {
 | 
			
		||||
	const char *cmdline;
 | 
			
		||||
	char *arg;
 | 
			
		||||
	const char *arg;
 | 
			
		||||
	char *end;
 | 
			
		||||
	unsigned int mode;
 | 
			
		||||
 | 
			
		||||
	/* Skip image filename */
 | 
			
		||||
	cmdline = ( cpio_name ( image ) + cpio_name_len ( image ) );
 | 
			
		||||
 | 
			
		||||
	/* Look for "mode=" */
 | 
			
		||||
	if ( ( arg = strstr ( cmdline, "mode=" ) ) ) {
 | 
			
		||||
		arg += 5;
 | 
			
		||||
	if ( ( arg = image_argument ( image, "mode=" ) ) ) {
 | 
			
		||||
		mode = strtoul ( arg, &end, 8 /* Octal for file mode */ );
 | 
			
		||||
		if ( *end && ( *end != ' ' ) ) {
 | 
			
		||||
			DBGC ( image, "CPIO %p strange \"mode=\" "
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										114
									
								
								src/core/image.c
									
									
									
									
									
								
							
							
						
						
									
										114
									
								
								src/core/image.c
									
									
									
									
									
								
							@ -27,6 +27,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <ctype.h>
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
#include <assert.h>
 | 
			
		||||
#include <libgen.h>
 | 
			
		||||
@ -55,8 +56,15 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 | 
			
		||||
/** List of registered images */
 | 
			
		||||
struct list_head images = LIST_HEAD_INIT ( images );
 | 
			
		||||
 | 
			
		||||
/** Image selected for execution */
 | 
			
		||||
struct image_tag selected_image __image_tag = {
 | 
			
		||||
	.name = "SELECTED",
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** Currently-executing image */
 | 
			
		||||
struct image *current_image;
 | 
			
		||||
struct image_tag current_image __image_tag = {
 | 
			
		||||
	.name = "CURRENT",
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** Current image trust requirement */
 | 
			
		||||
static int require_trusted_images = 0;
 | 
			
		||||
@ -71,8 +79,13 @@ static int require_trusted_images_permanent = 0;
 | 
			
		||||
 */
 | 
			
		||||
static void free_image ( struct refcnt *refcnt ) {
 | 
			
		||||
	struct image *image = container_of ( refcnt, struct image, refcnt );
 | 
			
		||||
	struct image_tag *tag;
 | 
			
		||||
 | 
			
		||||
	DBGC ( image, "IMAGE %s freed\n", image->name );
 | 
			
		||||
	for_each_table_entry ( tag, IMAGE_TAGS ) {
 | 
			
		||||
		if ( tag->image == image )
 | 
			
		||||
			tag->image = NULL;
 | 
			
		||||
	}
 | 
			
		||||
	free ( image->name );
 | 
			
		||||
	free ( image->cmdline );
 | 
			
		||||
	uri_put ( image->uri );
 | 
			
		||||
@ -260,12 +273,6 @@ int register_image ( struct image *image ) {
 | 
			
		||||
			return rc;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* Avoid ending up with multiple "selected" images on
 | 
			
		||||
	 * re-registration
 | 
			
		||||
	 */
 | 
			
		||||
	if ( image_find_selected() )
 | 
			
		||||
		image->flags &= ~IMAGE_SELECTED;
 | 
			
		||||
 | 
			
		||||
	/* Add to image list */
 | 
			
		||||
	image_get ( image );
 | 
			
		||||
	image->flags |= IMAGE_REGISTERED;
 | 
			
		||||
@ -311,7 +318,7 @@ void unregister_image ( struct image *image ) {
 | 
			
		||||
struct image * find_image ( const char *name ) {
 | 
			
		||||
	struct image *image;
 | 
			
		||||
 | 
			
		||||
	list_for_each_entry ( image, &images, list ) {
 | 
			
		||||
	for_each_image ( image ) {
 | 
			
		||||
		if ( strcmp ( image->name, name ) == 0 )
 | 
			
		||||
			return image;
 | 
			
		||||
	}
 | 
			
		||||
@ -319,6 +326,23 @@ struct image * find_image ( const char *name ) {
 | 
			
		||||
	return NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Find image by tag
 | 
			
		||||
 *
 | 
			
		||||
 * @v tag		Image tag
 | 
			
		||||
 * @ret image		Executable image, or NULL
 | 
			
		||||
 */
 | 
			
		||||
struct image * find_image_tag ( struct image_tag *tag ) {
 | 
			
		||||
	struct image *image;
 | 
			
		||||
 | 
			
		||||
	for_each_image ( image ) {
 | 
			
		||||
		if ( tag->image == image )
 | 
			
		||||
			return image;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Execute image
 | 
			
		||||
 *
 | 
			
		||||
@ -345,14 +369,13 @@ int image_exec ( struct image *image ) {
 | 
			
		||||
	if ( image->uri )
 | 
			
		||||
		churi ( image->uri );
 | 
			
		||||
 | 
			
		||||
	/* Preserve record of any currently-running image */
 | 
			
		||||
	saved_current_image = current_image;
 | 
			
		||||
	/* Set as currently running image */
 | 
			
		||||
	saved_current_image = image_tag ( image, ¤t_image );
 | 
			
		||||
 | 
			
		||||
	/* Take out a temporary reference to the image.  This allows
 | 
			
		||||
	 * the image to unregister itself if necessary, without
 | 
			
		||||
	 * automatically freeing itself.
 | 
			
		||||
	/* Take out a temporary reference to the image, so that it
 | 
			
		||||
	 * does not get freed when temporarily unregistered.
 | 
			
		||||
	 */
 | 
			
		||||
	current_image = image_get ( image );
 | 
			
		||||
	image_get ( image );
 | 
			
		||||
 | 
			
		||||
	/* Check that this image can be executed */
 | 
			
		||||
	if ( ! ( image->type && image->type->exec ) ) {
 | 
			
		||||
@ -370,6 +393,9 @@ int image_exec ( struct image *image ) {
 | 
			
		||||
	/* Record boot attempt */
 | 
			
		||||
	syslog ( LOG_NOTICE, "Executing \"%s\"\n", image->name );
 | 
			
		||||
 | 
			
		||||
	/* Temporarily unregister the image during its execution */
 | 
			
		||||
	unregister_image ( image );
 | 
			
		||||
 | 
			
		||||
	/* Try executing the image */
 | 
			
		||||
	if ( ( rc = image->type->exec ( image ) ) != 0 ) {
 | 
			
		||||
		DBGC ( image, "IMAGE %s could not execute: %s\n",
 | 
			
		||||
@ -386,6 +412,10 @@ int image_exec ( struct image *image ) {
 | 
			
		||||
			 image->name, strerror ( rc ) );
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* Re-register image (unless due to be replaced) */
 | 
			
		||||
	if ( ! image->replacement )
 | 
			
		||||
		register_image ( image );
 | 
			
		||||
 | 
			
		||||
	/* Pick up replacement image before we drop the original
 | 
			
		||||
	 * image's temporary reference.  The replacement image must
 | 
			
		||||
	 * already be registered, so we don't need to hold a temporary
 | 
			
		||||
@ -412,7 +442,7 @@ int image_exec ( struct image *image ) {
 | 
			
		||||
	image_put ( image );
 | 
			
		||||
 | 
			
		||||
	/* Restore previous currently-running image */
 | 
			
		||||
	current_image = saved_current_image;
 | 
			
		||||
	image_tag ( saved_current_image, ¤t_image );
 | 
			
		||||
 | 
			
		||||
	/* Reset current working directory */
 | 
			
		||||
	churi ( old_cwuri );
 | 
			
		||||
@ -435,7 +465,7 @@ int image_exec ( struct image *image ) {
 | 
			
		||||
 * registered until the currently-executing image returns.
 | 
			
		||||
 */
 | 
			
		||||
int image_replace ( struct image *replacement ) {
 | 
			
		||||
	struct image *image = current_image;
 | 
			
		||||
	struct image *image = current_image.image;
 | 
			
		||||
	int rc;
 | 
			
		||||
 | 
			
		||||
	/* Sanity check */
 | 
			
		||||
@ -471,37 +501,17 @@ int image_replace ( struct image *replacement ) {
 | 
			
		||||
 * @ret rc		Return status code
 | 
			
		||||
 */
 | 
			
		||||
int image_select ( struct image *image ) {
 | 
			
		||||
	struct image *tmp;
 | 
			
		||||
 | 
			
		||||
	/* Unselect all other images */
 | 
			
		||||
	for_each_image ( tmp )
 | 
			
		||||
		tmp->flags &= ~IMAGE_SELECTED;
 | 
			
		||||
 | 
			
		||||
	/* Check that this image can be executed */
 | 
			
		||||
	if ( ! ( image->type && image->type->exec ) )
 | 
			
		||||
		return -ENOEXEC;
 | 
			
		||||
 | 
			
		||||
	/* Mark image as selected */
 | 
			
		||||
	image->flags |= IMAGE_SELECTED;
 | 
			
		||||
	image_tag ( image, &selected_image );
 | 
			
		||||
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Find selected image
 | 
			
		||||
 *
 | 
			
		||||
 * @ret image		Executable image, or NULL
 | 
			
		||||
 */
 | 
			
		||||
struct image * image_find_selected ( void ) {
 | 
			
		||||
	struct image *image;
 | 
			
		||||
 | 
			
		||||
	for_each_image ( image ) {
 | 
			
		||||
		if ( image->flags & IMAGE_SELECTED )
 | 
			
		||||
			return image;
 | 
			
		||||
	}
 | 
			
		||||
	return NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Change image trust requirement
 | 
			
		||||
 *
 | 
			
		||||
@ -569,3 +579,33 @@ struct image * image_memory ( const char *name, userptr_t data, size_t len ) {
 | 
			
		||||
 err_alloc_image:
 | 
			
		||||
	return NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Find argument within image command line
 | 
			
		||||
 *
 | 
			
		||||
 * @v image		Image
 | 
			
		||||
 * @v key		Argument search key (including trailing delimiter)
 | 
			
		||||
 * @ret value		Argument value, or NULL if not found
 | 
			
		||||
 */
 | 
			
		||||
const char * image_argument ( struct image *image, const char *key ) {
 | 
			
		||||
	const char *cmdline = image->cmdline;
 | 
			
		||||
	const char *search;
 | 
			
		||||
	const char *match;
 | 
			
		||||
	const char *next;
 | 
			
		||||
 | 
			
		||||
	/* Find argument */
 | 
			
		||||
	for ( search = cmdline ; search ; search = next ) {
 | 
			
		||||
 | 
			
		||||
		/* Find next occurrence, if any */
 | 
			
		||||
		match = strstr ( search, key );
 | 
			
		||||
		if ( ! match )
 | 
			
		||||
			break;
 | 
			
		||||
		next = ( match + strlen ( key ) );
 | 
			
		||||
 | 
			
		||||
		/* Check preceding delimiter, if any */
 | 
			
		||||
		if ( ( match == cmdline ) || isspace ( match[-1] ) )
 | 
			
		||||
			return next;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -25,7 +25,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 | 
			
		||||
 | 
			
		||||
/** @file
 | 
			
		||||
 *
 | 
			
		||||
 * Form parameters
 | 
			
		||||
 * Request parameters
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
@ -37,7 +37,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 | 
			
		||||
static LIST_HEAD ( parameters );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Free form parameter list
 | 
			
		||||
 * Free request parameter list
 | 
			
		||||
 *
 | 
			
		||||
 * @v refcnt		Reference count
 | 
			
		||||
 */
 | 
			
		||||
@ -60,7 +60,7 @@ static void free_parameters ( struct refcnt *refcnt ) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Find form parameter list by name
 | 
			
		||||
 * Find request parameter list by name
 | 
			
		||||
 *
 | 
			
		||||
 * @v name		Parameter list name (may be NULL)
 | 
			
		||||
 * @ret params		Parameter list, or NULL if not found
 | 
			
		||||
@ -78,7 +78,7 @@ struct parameters * find_parameters ( const char *name ) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Create form parameter list
 | 
			
		||||
 * Create request parameter list
 | 
			
		||||
 *
 | 
			
		||||
 * @v name		Parameter list name (may be NULL)
 | 
			
		||||
 * @ret params		Parameter list, or NULL on failure
 | 
			
		||||
@ -118,15 +118,17 @@ struct parameters * create_parameters ( const char *name ) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Add form parameter
 | 
			
		||||
 * Add request parameter
 | 
			
		||||
 *
 | 
			
		||||
 * @v params		Parameter list
 | 
			
		||||
 * @v key		Parameter key
 | 
			
		||||
 * @v value		Parameter value
 | 
			
		||||
 * @v flags		Parameter flags
 | 
			
		||||
 * @ret param		Parameter, or NULL on failure
 | 
			
		||||
 */
 | 
			
		||||
struct parameter * add_parameter ( struct parameters *params,
 | 
			
		||||
				   const char *key, const char *value ) {
 | 
			
		||||
				   const char *key, const char *value,
 | 
			
		||||
				   unsigned int flags ) {
 | 
			
		||||
	struct parameter *param;
 | 
			
		||||
	size_t key_len;
 | 
			
		||||
	size_t value_len;
 | 
			
		||||
@ -147,11 +149,14 @@ struct parameter * add_parameter ( struct parameters *params,
 | 
			
		||||
	param->key = key_copy;
 | 
			
		||||
	strcpy ( value_copy, value );
 | 
			
		||||
	param->value = value_copy;
 | 
			
		||||
	param->flags = flags;
 | 
			
		||||
 | 
			
		||||
	/* Add to list of parameters */
 | 
			
		||||
	list_add_tail ( ¶m->list, ¶ms->entries );
 | 
			
		||||
 | 
			
		||||
	DBGC ( params, "PARAMS \"%s\" added \"%s\"=\"%s\"\n",
 | 
			
		||||
	       params->name, param->key, param->value );
 | 
			
		||||
	DBGC ( params, "PARAMS \"%s\" added \"%s\"=\"%s\"%s%s\n",
 | 
			
		||||
	       params->name, param->key, param->value,
 | 
			
		||||
	       ( ( param->flags & PARAMETER_FORM ) ? " (form)" : "" ),
 | 
			
		||||
	       ( ( param->flags & PARAMETER_HEADER ) ? " (header)" : "" ) );
 | 
			
		||||
	return param;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -302,7 +302,7 @@ int parse_autovivified_setting ( char *text, struct named_setting *setting ) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Parse form parameter list name
 | 
			
		||||
 * Parse request parameter list name
 | 
			
		||||
 *
 | 
			
		||||
 * @v text		Text
 | 
			
		||||
 * @ret params		Parameter list
 | 
			
		||||
 | 
			
		||||
@ -589,6 +589,32 @@ int asn1_signature_algorithm ( const struct asn1_cursor *cursor,
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Check ASN.1 OID-identified algorithm
 | 
			
		||||
 *
 | 
			
		||||
 * @v cursor		ASN.1 object cursor
 | 
			
		||||
 * @v expected		Expected algorithm
 | 
			
		||||
 * @ret rc		Return status code
 | 
			
		||||
 */
 | 
			
		||||
int asn1_check_algorithm ( const struct asn1_cursor *cursor,
 | 
			
		||||
			   struct asn1_algorithm *expected ) {
 | 
			
		||||
	struct asn1_algorithm *actual;
 | 
			
		||||
	int rc;
 | 
			
		||||
 | 
			
		||||
	/* Parse algorithm */
 | 
			
		||||
	if ( ( rc = asn1_algorithm ( cursor, &actual ) ) != 0 )
 | 
			
		||||
		return rc;
 | 
			
		||||
 | 
			
		||||
	/* Check algorithm matches */
 | 
			
		||||
	if ( actual != expected ) {
 | 
			
		||||
		DBGC ( cursor, "ASN1 %p algorithm %s does not match %s\n",
 | 
			
		||||
		       cursor, actual->name, expected->name );
 | 
			
		||||
		return -ENOTTY_ALGORITHM;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Parse ASN.1 GeneralizedTime
 | 
			
		||||
 *
 | 
			
		||||
 | 
			
		||||
@ -51,59 +51,33 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 | 
			
		||||
	__einfo_uniqify ( EINFO_EPIPE, 0x02, "Adaptive proportion test failed" )
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Calculate cutoff value for the repetition count test
 | 
			
		||||
 * Initialise repetition count test
 | 
			
		||||
 *
 | 
			
		||||
 * @ret cutoff		Cutoff value
 | 
			
		||||
 *
 | 
			
		||||
 * This is the cutoff value for the Repetition Count Test defined in
 | 
			
		||||
 * ANS X9.82 Part 2 (October 2011 Draft) Section 8.5.2.1.2.
 | 
			
		||||
 * @v source		Entropy source
 | 
			
		||||
 */
 | 
			
		||||
static inline __attribute__ (( always_inline )) unsigned int
 | 
			
		||||
repetition_count_cutoff ( void ) {
 | 
			
		||||
	double max_repetitions;
 | 
			
		||||
	unsigned int cutoff;
 | 
			
		||||
static void repetition_count_test_init ( struct entropy_source *source ) {
 | 
			
		||||
	struct entropy_repetition_count_test *test =
 | 
			
		||||
		&source->repetition_count_test;
 | 
			
		||||
 | 
			
		||||
	/* The cutoff formula for the repetition test is:
 | 
			
		||||
	 *
 | 
			
		||||
	 *   C = ( 1 + ( -log2(W) / H_min ) )
 | 
			
		||||
	 *
 | 
			
		||||
	 * where W is set at 2^(-30) (in ANS X9.82 Part 2 (October
 | 
			
		||||
	 * 2011 Draft) Section 8.5.2.1.3.1).
 | 
			
		||||
	 */
 | 
			
		||||
	max_repetitions = ( 1 + ( MIN_ENTROPY ( 30 ) /
 | 
			
		||||
				  min_entropy_per_sample() ) );
 | 
			
		||||
 | 
			
		||||
	/* Round up to a whole number of repetitions.  We don't have
 | 
			
		||||
	 * the ceil() function available, so do the rounding by hand.
 | 
			
		||||
	 */
 | 
			
		||||
	cutoff = max_repetitions;
 | 
			
		||||
	if ( cutoff < max_repetitions )
 | 
			
		||||
		cutoff++;
 | 
			
		||||
	linker_assert ( ( cutoff >= max_repetitions ), rounding_error );
 | 
			
		||||
 | 
			
		||||
	/* Floating-point operations are not allowed in iPXE since we
 | 
			
		||||
	 * never set up a suitable environment.  Abort the build
 | 
			
		||||
	 * unless the calculated number of repetitions is a
 | 
			
		||||
	 * compile-time constant.
 | 
			
		||||
	 */
 | 
			
		||||
	linker_assert ( __builtin_constant_p ( cutoff ),
 | 
			
		||||
			repetition_count_cutoff_not_constant );
 | 
			
		||||
 | 
			
		||||
	return cutoff;
 | 
			
		||||
	/* Sanity checks */
 | 
			
		||||
	assert ( test->repetition_count == 0 );
 | 
			
		||||
	assert ( test->cutoff > 0 );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Perform repetition count test
 | 
			
		||||
 *
 | 
			
		||||
 * @v source		Entropy source
 | 
			
		||||
 * @v sample		Noise sample
 | 
			
		||||
 * @ret rc		Return status code
 | 
			
		||||
 *
 | 
			
		||||
 * This is the Repetition Count Test defined in ANS X9.82 Part 2
 | 
			
		||||
 * (October 2011 Draft) Section 8.5.2.1.2.
 | 
			
		||||
 */
 | 
			
		||||
static int repetition_count_test ( noise_sample_t sample ) {
 | 
			
		||||
	static noise_sample_t most_recent_sample;
 | 
			
		||||
	static unsigned int repetition_count = 0;
 | 
			
		||||
static int repetition_count_test ( struct entropy_source *source,
 | 
			
		||||
				   noise_sample_t sample ) {
 | 
			
		||||
	struct entropy_repetition_count_test *test =
 | 
			
		||||
		&source->repetition_count_test;
 | 
			
		||||
 | 
			
		||||
	/* A = the most recently seen sample value
 | 
			
		||||
	 * B = the number of times that value A has been seen in a row
 | 
			
		||||
@ -116,158 +90,71 @@ static int repetition_count_test ( noise_sample_t sample ) {
 | 
			
		||||
	 * the initial value of most_recent_sample is treated as being
 | 
			
		||||
	 * undefined.)
 | 
			
		||||
	 */
 | 
			
		||||
	if ( ( sample == most_recent_sample ) && ( repetition_count > 0 ) ) {
 | 
			
		||||
	if ( ( sample == test->most_recent_sample ) &&
 | 
			
		||||
	     ( test->repetition_count > 0 ) ) {
 | 
			
		||||
 | 
			
		||||
		/* a) If the new sample = A, then B is incremented by one. */
 | 
			
		||||
		repetition_count++;
 | 
			
		||||
		test->repetition_count++;
 | 
			
		||||
 | 
			
		||||
		/*    i.  If B >= C, then an error condition is raised
 | 
			
		||||
		 *        due to a failure of the test
 | 
			
		||||
		 */
 | 
			
		||||
		if ( repetition_count >= repetition_count_cutoff() )
 | 
			
		||||
		if ( test->repetition_count >= test->cutoff ) {
 | 
			
		||||
			DBGC ( source, "ENTROPY %s excessively repeated "
 | 
			
		||||
			       "value %d (%d/%d)\n", source->name, sample,
 | 
			
		||||
			       test->repetition_count, test->cutoff );
 | 
			
		||||
			return -EPIPE_REPETITION_COUNT_TEST;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	} else {
 | 
			
		||||
 | 
			
		||||
		/* b) Else:
 | 
			
		||||
		 *    i.  A = new sample
 | 
			
		||||
		 */
 | 
			
		||||
		most_recent_sample = sample;
 | 
			
		||||
		test->most_recent_sample = sample;
 | 
			
		||||
 | 
			
		||||
		/*    ii. B = 1 */
 | 
			
		||||
		repetition_count = 1;
 | 
			
		||||
		test->repetition_count = 1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Window size for the adaptive proportion test
 | 
			
		||||
 * Initialise adaptive proportion test
 | 
			
		||||
 *
 | 
			
		||||
 * ANS X9.82 Part 2 (October 2011 Draft) Section 8.5.2.1.3.1.1 allows
 | 
			
		||||
 * five possible window sizes: 16, 64, 256, 4096 and 65536.
 | 
			
		||||
 *
 | 
			
		||||
 * We expect to generate relatively few (<256) entropy samples during
 | 
			
		||||
 * a typical iPXE run; the use of a large window size would mean that
 | 
			
		||||
 * the test would never complete a single cycle.  We use a window size
 | 
			
		||||
 * of 64, which is the smallest window size that permits values of
 | 
			
		||||
 * H_min down to one bit per sample.
 | 
			
		||||
 * @v source		Entropy source
 | 
			
		||||
 */
 | 
			
		||||
#define ADAPTIVE_PROPORTION_WINDOW_SIZE 64
 | 
			
		||||
static void adaptive_proportion_test_init ( struct entropy_source *source ) {
 | 
			
		||||
	struct entropy_adaptive_proportion_test *test =
 | 
			
		||||
		&source->adaptive_proportion_test;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Combine adaptive proportion test window size and min-entropy
 | 
			
		||||
 *
 | 
			
		||||
 * @v n			N (window size)
 | 
			
		||||
 * @v h			H (min-entropy)
 | 
			
		||||
 * @ret n_h		(N,H) combined value
 | 
			
		||||
 */
 | 
			
		||||
#define APC_N_H( n, h ) ( ( (n) << 8 ) | (h) )
 | 
			
		||||
	/* Sanity checks */
 | 
			
		||||
	assert ( test->sample_count == 0 );
 | 
			
		||||
	assert ( test->repetition_count == 0 );
 | 
			
		||||
	assert ( test->cutoff > 0 );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Define a row of the adaptive proportion cutoff table
 | 
			
		||||
 *
 | 
			
		||||
 * @v h			H (min-entropy)
 | 
			
		||||
 * @v c16		Cutoff for N=16
 | 
			
		||||
 * @v c64		Cutoff for N=64
 | 
			
		||||
 * @v c256		Cutoff for N=256
 | 
			
		||||
 * @v c4096		Cutoff for N=4096
 | 
			
		||||
 * @v c65536		Cutoff for N=65536
 | 
			
		||||
 */
 | 
			
		||||
#define APC_TABLE_ROW( h, c16, c64, c256, c4096, c65536)	   \
 | 
			
		||||
	case APC_N_H ( 16, h ) :	return c16;		   \
 | 
			
		||||
	case APC_N_H ( 64, h ) :	return c64;   		   \
 | 
			
		||||
	case APC_N_H ( 256, h ) :	return c256;		   \
 | 
			
		||||
	case APC_N_H ( 4096, h ) :	return c4096;		   \
 | 
			
		||||
	case APC_N_H ( 65536, h ) :	return c65536;
 | 
			
		||||
 | 
			
		||||
/** Value used to represent "N/A" in adaptive proportion cutoff table */
 | 
			
		||||
#define APC_NA 0
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Look up value in adaptive proportion test cutoff table
 | 
			
		||||
 *
 | 
			
		||||
 * @v n			N (window size)
 | 
			
		||||
 * @v h			H (min-entropy)
 | 
			
		||||
 * @ret cutoff		Cutoff
 | 
			
		||||
 *
 | 
			
		||||
 * This is the table of cutoff values defined in ANS X9.82 Part 2
 | 
			
		||||
 * (October 2011 Draft) Section 8.5.2.1.3.1.2.
 | 
			
		||||
 */
 | 
			
		||||
static inline __attribute__ (( always_inline )) unsigned int
 | 
			
		||||
adaptive_proportion_cutoff_lookup ( unsigned int n, unsigned int h ) {
 | 
			
		||||
	switch ( APC_N_H ( n, h ) ) {
 | 
			
		||||
		APC_TABLE_ROW (  1, APC_NA,     51,    168,   2240,  33537 );
 | 
			
		||||
		APC_TABLE_ROW (  2, APC_NA,     35,    100,   1193,  17053 );
 | 
			
		||||
		APC_TABLE_ROW (  3,     10,     24,     61,    643,   8705 );
 | 
			
		||||
		APC_TABLE_ROW (  4,      8,     16,     38,    354,   4473 );
 | 
			
		||||
		APC_TABLE_ROW (  5,      6,     12,     25,    200,   2321 );
 | 
			
		||||
		APC_TABLE_ROW (  6,      5,      9,     17,    117,   1220 );
 | 
			
		||||
		APC_TABLE_ROW (  7,      4,      7,     15,     71,    653 );
 | 
			
		||||
		APC_TABLE_ROW (  8,      4,      5,      9,     45,    358 );
 | 
			
		||||
		APC_TABLE_ROW (  9,      3,      4,      7,     30,    202 );
 | 
			
		||||
		APC_TABLE_ROW ( 10,      3,      4,      5,     21,    118 );
 | 
			
		||||
		APC_TABLE_ROW ( 11,      2,      3,      4,     15,     71 );
 | 
			
		||||
		APC_TABLE_ROW ( 12,      2,      3,      4,     11,     45 );
 | 
			
		||||
		APC_TABLE_ROW ( 13,      2,      2,      3,      9,     30 );
 | 
			
		||||
		APC_TABLE_ROW ( 14,      2,      2,      3,      7,     21 );
 | 
			
		||||
		APC_TABLE_ROW ( 15,      1,      2,      2,      6,     15 );
 | 
			
		||||
		APC_TABLE_ROW ( 16,      1,      2,      2,      5,     11 );
 | 
			
		||||
		APC_TABLE_ROW ( 17,      1,      1,      2,      4,      9 );
 | 
			
		||||
		APC_TABLE_ROW ( 18,      1,      1,      2,      4,      7 );
 | 
			
		||||
		APC_TABLE_ROW ( 19,      1,      1,      1,      3,      6 );
 | 
			
		||||
		APC_TABLE_ROW ( 20,      1,      1,      1,      3,      5 );
 | 
			
		||||
	default:
 | 
			
		||||
		return APC_NA;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Calculate cutoff value for the adaptive proportion test
 | 
			
		||||
 *
 | 
			
		||||
 * @ret cutoff		Cutoff value
 | 
			
		||||
 *
 | 
			
		||||
 * This is the cutoff value for the Adaptive Proportion Test defined
 | 
			
		||||
 * in ANS X9.82 Part 2 (October 2011 Draft) Section 8.5.2.1.3.1.2.
 | 
			
		||||
 */
 | 
			
		||||
static inline __attribute__ (( always_inline )) unsigned int
 | 
			
		||||
adaptive_proportion_cutoff ( void ) {
 | 
			
		||||
	unsigned int h;
 | 
			
		||||
	unsigned int n;
 | 
			
		||||
	unsigned int cutoff;
 | 
			
		||||
 | 
			
		||||
	/* Look up cutoff value in cutoff table */
 | 
			
		||||
	n = ADAPTIVE_PROPORTION_WINDOW_SIZE;
 | 
			
		||||
	h = ( min_entropy_per_sample() / MIN_ENTROPY_SCALE );
 | 
			
		||||
	cutoff = adaptive_proportion_cutoff_lookup ( n, h );
 | 
			
		||||
 | 
			
		||||
	/* Fail unless cutoff value is a build-time constant */
 | 
			
		||||
	linker_assert ( __builtin_constant_p ( cutoff ),
 | 
			
		||||
			adaptive_proportion_cutoff_not_constant );
 | 
			
		||||
 | 
			
		||||
	/* Fail if cutoff value is N/A */
 | 
			
		||||
	linker_assert ( ( cutoff != APC_NA ),
 | 
			
		||||
			adaptive_proportion_cutoff_not_applicable );
 | 
			
		||||
 | 
			
		||||
	return cutoff;
 | 
			
		||||
	/* Ensure that a new test run starts immediately */
 | 
			
		||||
	test->sample_count = ADAPTIVE_PROPORTION_WINDOW_SIZE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Perform adaptive proportion test
 | 
			
		||||
 *
 | 
			
		||||
 * @v source		Entropy source
 | 
			
		||||
 * @v sample		Noise sample
 | 
			
		||||
 * @ret rc		Return status code
 | 
			
		||||
 *
 | 
			
		||||
 * This is the Adaptive Proportion Test for the Most Common Value
 | 
			
		||||
 * defined in ANS X9.82 Part 2 (October 2011 Draft) Section 8.5.2.1.3.
 | 
			
		||||
 */
 | 
			
		||||
static int adaptive_proportion_test ( noise_sample_t sample ) {
 | 
			
		||||
	static noise_sample_t current_counted_sample;
 | 
			
		||||
	static unsigned int sample_count = ADAPTIVE_PROPORTION_WINDOW_SIZE;
 | 
			
		||||
	static unsigned int repetition_count;
 | 
			
		||||
static int adaptive_proportion_test ( struct entropy_source *source,
 | 
			
		||||
				      noise_sample_t sample ) {
 | 
			
		||||
	struct entropy_adaptive_proportion_test *test =
 | 
			
		||||
		&source->adaptive_proportion_test;
 | 
			
		||||
 | 
			
		||||
	/* A = the sample value currently being counted
 | 
			
		||||
	 * B = the number of samples examined in this run of the test so far
 | 
			
		||||
	 * S = the number of samples examined in this run of the test so far
 | 
			
		||||
	 * N = the total number of samples that must be observed in
 | 
			
		||||
	 *     one run of the test, also known as the "window size" of
 | 
			
		||||
	 *     the test
 | 
			
		||||
@ -284,37 +171,41 @@ static int adaptive_proportion_test ( noise_sample_t sample ) {
 | 
			
		||||
	 */
 | 
			
		||||
 | 
			
		||||
	/* 2.  If S = N, then a new run of the test begins: */
 | 
			
		||||
	if ( sample_count == ADAPTIVE_PROPORTION_WINDOW_SIZE ) {
 | 
			
		||||
	if ( test->sample_count == ADAPTIVE_PROPORTION_WINDOW_SIZE ) {
 | 
			
		||||
 | 
			
		||||
		/* a.  A = the current sample */
 | 
			
		||||
		current_counted_sample = sample;
 | 
			
		||||
		test->current_counted_sample = sample;
 | 
			
		||||
 | 
			
		||||
		/* b.  S = 0 */
 | 
			
		||||
		sample_count = 0;
 | 
			
		||||
		test->sample_count = 0;
 | 
			
		||||
 | 
			
		||||
		/* c. B = 0 */
 | 
			
		||||
		repetition_count = 0;
 | 
			
		||||
		test->repetition_count = 0;
 | 
			
		||||
 | 
			
		||||
	} else {
 | 
			
		||||
 | 
			
		||||
		/* Else: (the test is already running)
 | 
			
		||||
		 * a.  S = S + 1
 | 
			
		||||
		 */
 | 
			
		||||
		sample_count++;
 | 
			
		||||
		test->sample_count++;
 | 
			
		||||
 | 
			
		||||
		/* b.  If A = the current sample, then: */
 | 
			
		||||
		if ( sample == current_counted_sample ) {
 | 
			
		||||
		if ( sample == test->current_counted_sample ) {
 | 
			
		||||
 | 
			
		||||
			/* i.   B = B + 1 */
 | 
			
		||||
			repetition_count++;
 | 
			
		||||
			test->repetition_count++;
 | 
			
		||||
 | 
			
		||||
			/* ii.  If S (sic) > C then raise an error
 | 
			
		||||
			 *      condition, because the test has
 | 
			
		||||
			 *      detected a failure
 | 
			
		||||
			 */
 | 
			
		||||
			if ( repetition_count > adaptive_proportion_cutoff() )
 | 
			
		||||
			if ( test->repetition_count > test->cutoff ) {
 | 
			
		||||
				DBGC ( source, "ENTROPY %s excessively "
 | 
			
		||||
				       "repeated value %d (%d/%d)\n",
 | 
			
		||||
				       source->name, sample,
 | 
			
		||||
				       test->repetition_count, test->cutoff );
 | 
			
		||||
				return -EPIPE_ADAPTIVE_PROPORTION_TEST;
 | 
			
		||||
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@ -324,62 +215,180 @@ static int adaptive_proportion_test ( noise_sample_t sample ) {
 | 
			
		||||
/**
 | 
			
		||||
 * Get entropy sample
 | 
			
		||||
 *
 | 
			
		||||
 * @v source		Entropy source
 | 
			
		||||
 * @ret entropy		Entropy sample
 | 
			
		||||
 * @ret rc		Return status code
 | 
			
		||||
 *
 | 
			
		||||
 * This is the GetEntropy function defined in ANS X9.82 Part 2
 | 
			
		||||
 * (October 2011 Draft) Section 6.5.1.
 | 
			
		||||
 */
 | 
			
		||||
static int get_entropy ( entropy_sample_t *entropy ) {
 | 
			
		||||
	static int rc = 0;
 | 
			
		||||
static int get_entropy ( struct entropy_source *source,
 | 
			
		||||
			 entropy_sample_t *entropy ) {
 | 
			
		||||
	noise_sample_t noise;
 | 
			
		||||
	int rc;
 | 
			
		||||
 | 
			
		||||
	/* Any failure is permanent */
 | 
			
		||||
	if ( rc != 0 )
 | 
			
		||||
		return rc;
 | 
			
		||||
	if ( ( rc = source->rc ) != 0 )
 | 
			
		||||
		goto err_broken;
 | 
			
		||||
 | 
			
		||||
	/* Get noise sample */
 | 
			
		||||
	if ( ( rc = get_noise ( &noise ) ) != 0 )
 | 
			
		||||
		return rc;
 | 
			
		||||
	if ( ( rc = get_noise ( source, &noise ) ) != 0 )
 | 
			
		||||
		goto err_get_noise;
 | 
			
		||||
 | 
			
		||||
	/* Perform Repetition Count Test and Adaptive Proportion Test
 | 
			
		||||
	 * as mandated by ANS X9.82 Part 2 (October 2011 Draft)
 | 
			
		||||
	 * Section 8.5.2.1.1.
 | 
			
		||||
	 */
 | 
			
		||||
	if ( ( rc = repetition_count_test ( noise ) ) != 0 )
 | 
			
		||||
		return rc;
 | 
			
		||||
	if ( ( rc = adaptive_proportion_test ( noise ) ) != 0 )
 | 
			
		||||
		return rc;
 | 
			
		||||
	if ( ( rc = repetition_count_test ( source, noise ) ) != 0 )
 | 
			
		||||
		goto err_repetition_count_test;
 | 
			
		||||
	if ( ( rc = adaptive_proportion_test ( source, noise ) ) != 0 )
 | 
			
		||||
		goto err_adaptive_proportion_test;
 | 
			
		||||
 | 
			
		||||
	/* We do not use any optional conditioning component */
 | 
			
		||||
	*entropy = noise;
 | 
			
		||||
 | 
			
		||||
	return 0;
 | 
			
		||||
 | 
			
		||||
 err_adaptive_proportion_test:
 | 
			
		||||
 err_repetition_count_test:
 | 
			
		||||
 err_get_noise:
 | 
			
		||||
	source->rc = rc;
 | 
			
		||||
 err_broken:
 | 
			
		||||
	return rc;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Calculate number of samples required for startup tests
 | 
			
		||||
 * Initialise startup test
 | 
			
		||||
 *
 | 
			
		||||
 * @ret num_samples	Number of samples required
 | 
			
		||||
 *
 | 
			
		||||
 * ANS X9.82 Part 2 (October 2011 Draft) Section 8.5.2.1.5 requires
 | 
			
		||||
 * that at least one full cycle of the continuous tests must be
 | 
			
		||||
 * performed at start-up.
 | 
			
		||||
 * @v source		Entropy source
 | 
			
		||||
 */
 | 
			
		||||
static inline __attribute__ (( always_inline )) unsigned int
 | 
			
		||||
startup_test_count ( void ) {
 | 
			
		||||
	unsigned int num_samples;
 | 
			
		||||
static void startup_test_init ( struct entropy_source *source ) {
 | 
			
		||||
	struct entropy_startup_test *test = &source->startup_test;
 | 
			
		||||
 | 
			
		||||
	/* At least max(N,C) samples shall be generated by the noise
 | 
			
		||||
	 * source for start-up testing.
 | 
			
		||||
	 */
 | 
			
		||||
	num_samples = repetition_count_cutoff();
 | 
			
		||||
	if ( num_samples < adaptive_proportion_cutoff() )
 | 
			
		||||
		num_samples = adaptive_proportion_cutoff();
 | 
			
		||||
	linker_assert ( __builtin_constant_p ( num_samples ),
 | 
			
		||||
			startup_test_count_not_constant );
 | 
			
		||||
	/* Sanity check */
 | 
			
		||||
	assert ( test->tested == 0 );
 | 
			
		||||
	assert ( test->count > 0 );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
	return num_samples;
 | 
			
		||||
/**
 | 
			
		||||
 * Perform startup test
 | 
			
		||||
 *
 | 
			
		||||
 * @v source		Entropy source
 | 
			
		||||
 * @ret rc		Return status code
 | 
			
		||||
 */
 | 
			
		||||
static int startup_test ( struct entropy_source *source ) {
 | 
			
		||||
	struct entropy_startup_test *test = &source->startup_test;
 | 
			
		||||
	entropy_sample_t sample;
 | 
			
		||||
	int rc;
 | 
			
		||||
 | 
			
		||||
	/* Perform mandatory number of startup tests */
 | 
			
		||||
	for ( ; test->tested < test->count ; test->tested++ ) {
 | 
			
		||||
		if ( ( rc = get_entropy ( source, &sample ) ) != 0 ) {
 | 
			
		||||
			DBGC ( source, "ENTROPY %s failed: %s\n",
 | 
			
		||||
			       source->name, strerror ( rc ) );
 | 
			
		||||
			return rc;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Enable entropy gathering
 | 
			
		||||
 *
 | 
			
		||||
 * @v source		Entropy source
 | 
			
		||||
 * @ret rc		Return status code
 | 
			
		||||
 */
 | 
			
		||||
int entropy_enable ( struct entropy_source *source ) {
 | 
			
		||||
	int rc;
 | 
			
		||||
 | 
			
		||||
	/* Refuse to enable a previously failed source */
 | 
			
		||||
	if ( ( rc = source->rc ) != 0 )
 | 
			
		||||
		return rc;
 | 
			
		||||
 | 
			
		||||
	/* Enable entropy source */
 | 
			
		||||
	if ( ( rc = source->enable() ) != 0 ) {
 | 
			
		||||
		DBGC ( source, "ENTROPY %s could not enable: %s\n",
 | 
			
		||||
		       source->name, strerror ( rc ) );
 | 
			
		||||
		source->rc = rc;
 | 
			
		||||
		return rc;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* Sanity check */
 | 
			
		||||
	assert ( source->min_entropy_per_sample > 0 );
 | 
			
		||||
 | 
			
		||||
	/* Initialise test state if this source has not previously been used */
 | 
			
		||||
	if ( source->startup_test.tested == 0 ) {
 | 
			
		||||
		repetition_count_test_init ( source );
 | 
			
		||||
		adaptive_proportion_test_init ( source );
 | 
			
		||||
		startup_test_init ( source );
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	DBGC ( source, "ENTROPY %s enabled\n", source->name );
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Enable and test entropy source
 | 
			
		||||
 *
 | 
			
		||||
 * @v source		Entropy source
 | 
			
		||||
 * @ret rc		Return status code
 | 
			
		||||
 */
 | 
			
		||||
static int entropy_enable_and_test ( struct entropy_source *source ) {
 | 
			
		||||
	int rc;
 | 
			
		||||
 | 
			
		||||
	/* Enable source */
 | 
			
		||||
	if ( ( rc = entropy_enable ( source ) ) != 0 )
 | 
			
		||||
		goto err_enable;
 | 
			
		||||
 | 
			
		||||
	/* Test source */
 | 
			
		||||
	if ( ( rc = startup_test ( source ) ) != 0 )
 | 
			
		||||
		goto err_test;
 | 
			
		||||
 | 
			
		||||
	DBGC ( source, "ENTROPY %s passed %d startup tests\n",
 | 
			
		||||
	       source->name, source->startup_test.count );
 | 
			
		||||
	return 0;
 | 
			
		||||
 | 
			
		||||
 err_test:
 | 
			
		||||
	entropy_disable ( source );
 | 
			
		||||
 err_enable:
 | 
			
		||||
	assert ( source->rc == rc );
 | 
			
		||||
	return rc;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Enable first working entropy source
 | 
			
		||||
 *
 | 
			
		||||
 * @v source		Entropy source to fill in
 | 
			
		||||
 * @ret rc		Return status code
 | 
			
		||||
 */
 | 
			
		||||
static int entropy_enable_working ( struct entropy_source **source ) {
 | 
			
		||||
	int rc;
 | 
			
		||||
 | 
			
		||||
	/* Find the first working source */
 | 
			
		||||
	rc = -ENOENT;
 | 
			
		||||
	for_each_table_entry ( *source, ENTROPY_SOURCES ) {
 | 
			
		||||
		if ( ( rc = entropy_enable_and_test ( *source ) ) == 0 )
 | 
			
		||||
			return 0;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	DBGC ( *source, "ENTROPY has no working sources: %s\n",
 | 
			
		||||
	       strerror ( rc ) );
 | 
			
		||||
	return rc;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Disable entropy gathering
 | 
			
		||||
 *
 | 
			
		||||
 * @v source		Entropy source
 | 
			
		||||
 */
 | 
			
		||||
void entropy_disable ( struct entropy_source *source ) {
 | 
			
		||||
 | 
			
		||||
	/* Disable entropy gathering, if applicable */
 | 
			
		||||
	if ( source->disable )
 | 
			
		||||
		source->disable();
 | 
			
		||||
 | 
			
		||||
	DBGC ( source, "ENTROPY %s disabled\n", source->name );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@ -402,7 +411,7 @@ static uint32_t make_next_nonce ( void ) {
 | 
			
		||||
/**
 | 
			
		||||
 * Obtain entropy input temporary buffer
 | 
			
		||||
 *
 | 
			
		||||
 * @v num_samples	Number of entropy samples
 | 
			
		||||
 * @v min_entropy	Min-entropy required
 | 
			
		||||
 * @v tmp		Temporary buffer
 | 
			
		||||
 * @v tmp_len		Length of temporary buffer
 | 
			
		||||
 * @ret rc		Return status code
 | 
			
		||||
@ -412,47 +421,41 @@ static uint32_t make_next_nonce ( void ) {
 | 
			
		||||
 * and condensing each entropy source output after each GetEntropy
 | 
			
		||||
 * call) as defined in ANS X9.82 Part 4 (April 2011 Draft) Section
 | 
			
		||||
 * 13.3.4.2.
 | 
			
		||||
 *
 | 
			
		||||
 * To minimise code size, the number of samples required is calculated
 | 
			
		||||
 * at compilation time.
 | 
			
		||||
 */
 | 
			
		||||
int get_entropy_input_tmp ( unsigned int num_samples, uint8_t *tmp,
 | 
			
		||||
int get_entropy_input_tmp ( min_entropy_t min_entropy, uint8_t *tmp,
 | 
			
		||||
			    size_t tmp_len ) {
 | 
			
		||||
	static unsigned int startup_tested = 0;
 | 
			
		||||
	struct entropy_source *source;
 | 
			
		||||
	struct {
 | 
			
		||||
		uint32_t nonce;
 | 
			
		||||
		entropy_sample_t sample;
 | 
			
		||||
	} __attribute__ (( packed )) data;;
 | 
			
		||||
	uint8_t df_buf[tmp_len];
 | 
			
		||||
	min_entropy_t entropy_total;
 | 
			
		||||
	unsigned int num_samples;
 | 
			
		||||
	unsigned int i;
 | 
			
		||||
	int rc;
 | 
			
		||||
 | 
			
		||||
	/* Enable entropy gathering */
 | 
			
		||||
	if ( ( rc = entropy_enable() ) != 0 )
 | 
			
		||||
		return rc;
 | 
			
		||||
	if ( ( rc = entropy_enable_working ( &source ) ) != 0 )
 | 
			
		||||
		goto err_enable_working;
 | 
			
		||||
 | 
			
		||||
	/* Perform mandatory startup tests, if not yet performed */
 | 
			
		||||
	for ( ; startup_tested < startup_test_count() ; startup_tested++ ) {
 | 
			
		||||
		if ( ( rc = get_entropy ( &data.sample ) ) != 0 )
 | 
			
		||||
			goto err_get_entropy;
 | 
			
		||||
	}
 | 
			
		||||
	/* Sanity checks */
 | 
			
		||||
	assert ( source->startup_test.count > 0 );
 | 
			
		||||
	assert ( source->startup_test.tested >= source->startup_test.count );
 | 
			
		||||
 | 
			
		||||
	/* 3.  entropy_total = 0
 | 
			
		||||
	 *
 | 
			
		||||
	 * (Nothing to do; the number of entropy samples required has
 | 
			
		||||
	 * already been precalculated.)
 | 
			
		||||
	 */
 | 
			
		||||
	/* 3.  entropy_total = 0 */
 | 
			
		||||
	entropy_total = MIN_ENTROPY ( 0 );
 | 
			
		||||
 | 
			
		||||
	/* 4.  tmp = a fixed n-bit value, such as 0^n */
 | 
			
		||||
	memset ( tmp, 0, tmp_len );
 | 
			
		||||
 | 
			
		||||
	/* 5.  While ( entropy_total < min_entropy ) */
 | 
			
		||||
	while ( num_samples-- ) {
 | 
			
		||||
	for ( num_samples = 0 ; entropy_total < min_entropy ; num_samples++ ) {
 | 
			
		||||
		/* 5.1.  ( status, entropy_bitstring, assessed_entropy )
 | 
			
		||||
		 *       = GetEntropy()
 | 
			
		||||
		 * 5.2.  If status indicates an error, return ( status, Null )
 | 
			
		||||
		 */
 | 
			
		||||
		if ( ( rc = get_entropy ( &data.sample ) ) != 0 )
 | 
			
		||||
		if ( ( rc = get_entropy ( source, &data.sample ) ) != 0 )
 | 
			
		||||
			goto err_get_entropy;
 | 
			
		||||
 | 
			
		||||
		/* 5.3.  nonce = MakeNextNonce() */
 | 
			
		||||
@ -466,19 +469,26 @@ int get_entropy_input_tmp ( unsigned int num_samples, uint8_t *tmp,
 | 
			
		||||
		for ( i = 0 ; i < tmp_len ; i++ )
 | 
			
		||||
			tmp[i] ^= df_buf[i];
 | 
			
		||||
 | 
			
		||||
		/* 5.5.  entropy_total = entropy_total + assessed_entropy
 | 
			
		||||
		 *
 | 
			
		||||
		 * (Nothing to do; the number of entropy samples
 | 
			
		||||
		 * required has already been precalculated.)
 | 
			
		||||
		 */
 | 
			
		||||
		/* 5.5.  entropy_total = entropy_total + assessed_entropy */
 | 
			
		||||
		entropy_total += source->min_entropy_per_sample;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* Disable entropy gathering */
 | 
			
		||||
	entropy_disable();
 | 
			
		||||
	entropy_disable ( source );
 | 
			
		||||
 | 
			
		||||
	DBGC ( source, "ENTROPY %s gathered %d bits in %d samples\n",
 | 
			
		||||
	       source->name, ( min_entropy / MIN_ENTROPY_SCALE ), num_samples );
 | 
			
		||||
	return 0;
 | 
			
		||||
 | 
			
		||||
 err_get_entropy:
 | 
			
		||||
	entropy_disable();
 | 
			
		||||
	entropy_disable ( source );
 | 
			
		||||
	assert ( source->rc == rc );
 | 
			
		||||
 err_enable_working:
 | 
			
		||||
	return rc;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* Drag in objects via entropy_enable */
 | 
			
		||||
REQUIRING_SYMBOL ( entropy_enable );
 | 
			
		||||
 | 
			
		||||
/* Drag in entropy configuration */
 | 
			
		||||
REQUIRE_OBJECT ( config_entropy );
 | 
			
		||||
 | 
			
		||||
@ -164,7 +164,7 @@ static int rsa_parse_mod_exp ( struct asn1_cursor *modulus,
 | 
			
		||||
	int is_private;
 | 
			
		||||
	int rc;
 | 
			
		||||
 | 
			
		||||
	/* Enter subjectPublicKeyInfo/RSAPrivateKey */
 | 
			
		||||
	/* Enter subjectPublicKeyInfo/privateKeyInfo/RSAPrivateKey */
 | 
			
		||||
	memcpy ( &cursor, raw, sizeof ( cursor ) );
 | 
			
		||||
	asn1_enter ( &cursor, ASN1_SEQUENCE );
 | 
			
		||||
 | 
			
		||||
@ -177,6 +177,23 @@ static int rsa_parse_mod_exp ( struct asn1_cursor *modulus,
 | 
			
		||||
		/* Skip version */
 | 
			
		||||
		asn1_skip_any ( &cursor );
 | 
			
		||||
 | 
			
		||||
		/* Enter privateKey, if present */
 | 
			
		||||
		if ( asn1_check_algorithm ( &cursor,
 | 
			
		||||
					    &rsa_encryption_algorithm ) == 0 ) {
 | 
			
		||||
 | 
			
		||||
			/* Skip privateKeyAlgorithm */
 | 
			
		||||
			asn1_skip_any ( &cursor );
 | 
			
		||||
 | 
			
		||||
			/* Enter privateKey */
 | 
			
		||||
			asn1_enter ( &cursor, ASN1_OCTET_STRING );
 | 
			
		||||
 | 
			
		||||
			/* Enter RSAPrivateKey */
 | 
			
		||||
			asn1_enter ( &cursor, ASN1_SEQUENCE );
 | 
			
		||||
 | 
			
		||||
			/* Skip version */
 | 
			
		||||
			asn1_skip ( &cursor, ASN1_INTEGER );
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	} else {
 | 
			
		||||
 | 
			
		||||
		/* Public key */
 | 
			
		||||
 | 
			
		||||
@ -609,6 +609,7 @@ static void scsicmd_read_capacity_cmd ( struct scsi_command *scsicmd,
 | 
			
		||||
 */
 | 
			
		||||
static void scsicmd_read_capacity_done ( struct scsi_command *scsicmd,
 | 
			
		||||
					 int rc ) {
 | 
			
		||||
	struct scsi_device *scsidev = scsicmd->scsidev;
 | 
			
		||||
	struct scsi_read_capacity_private *priv = scsicmd_priv ( scsicmd );
 | 
			
		||||
	struct scsi_capacity_16 *capacity16 = &priv->capacity.capacity16;
 | 
			
		||||
	struct scsi_capacity_10 *capacity10 = &priv->capacity.capacity10;
 | 
			
		||||
@ -645,6 +646,9 @@ static void scsicmd_read_capacity_done ( struct scsi_command *scsicmd,
 | 
			
		||||
	}
 | 
			
		||||
	capacity.max_count = -1U;
 | 
			
		||||
 | 
			
		||||
	/* Allow transport layer to update capacity */
 | 
			
		||||
	block_capacity ( &scsidev->scsi, &capacity );
 | 
			
		||||
 | 
			
		||||
	/* Return capacity to caller */
 | 
			
		||||
	block_capacity ( &scsicmd->block, &capacity );
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -98,8 +98,16 @@ static void eisa_remove ( struct eisa_device *eisa ) {
 | 
			
		||||
static int eisabus_probe ( struct root_device *rootdev ) {
 | 
			
		||||
	struct eisa_device *eisa = NULL;
 | 
			
		||||
	unsigned int slot;
 | 
			
		||||
	uint8_t system;
 | 
			
		||||
	int rc;
 | 
			
		||||
 | 
			
		||||
	/* Check for EISA system board */
 | 
			
		||||
	system = inb ( EISA_VENDOR_ID );
 | 
			
		||||
	if ( system & 0x80 ) {
 | 
			
		||||
		DBG ( "No EISA system board (read %02x)\n", system );
 | 
			
		||||
		return -ENODEV;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for ( slot = EISA_MIN_SLOT ; slot <= EISA_MAX_SLOT ; slot++ ) {
 | 
			
		||||
		/* Allocate struct eisa_device */
 | 
			
		||||
		if ( ! eisa )
 | 
			
		||||
 | 
			
		||||
@ -290,6 +290,18 @@ static int intel_reset ( struct intel_nic *intel ) {
 | 
			
		||||
		       pba, readl ( intel->regs + INTEL_PBA ) );
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* The Intel I210's packet buffer size registers reset only on
 | 
			
		||||
	 * power up.  If an operating system changes these but then
 | 
			
		||||
	 * the computer recieves a reset signal without losing power,
 | 
			
		||||
	 * the registers will stay the same (but be incompatible with
 | 
			
		||||
	 * other register defaults), thus making the device unable to
 | 
			
		||||
	 * pass traffic.
 | 
			
		||||
	 */
 | 
			
		||||
	if ( intel->flags & INTEL_PBSIZE_RST ) {
 | 
			
		||||
		writel ( INTEL_RXPBS_I210, intel->regs + INTEL_RXPBS );
 | 
			
		||||
		writel ( INTEL_TXPBS_I210, intel->regs + INTEL_TXPBS );
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* Always reset MAC.  Required to reset the TX and RX rings. */
 | 
			
		||||
	writel ( ( ctrl | INTEL_CTRL_RST ), intel->regs + INTEL_CTRL );
 | 
			
		||||
	mdelay ( INTEL_RESET_DELAY_MS );
 | 
			
		||||
@ -1139,7 +1151,7 @@ static struct pci_device_id intel_nics[] = {
 | 
			
		||||
	PCI_ROM ( 0x8086, 0x1525, "82567v-4", "82567V-4", 0 ),
 | 
			
		||||
	PCI_ROM ( 0x8086, 0x1526, "82576-5", "82576", 0 ),
 | 
			
		||||
	PCI_ROM ( 0x8086, 0x1527, "82580-f2", "82580 Fiber", 0 ),
 | 
			
		||||
	PCI_ROM ( 0x8086, 0x1533, "i210", "I210", 0 ),
 | 
			
		||||
	PCI_ROM ( 0x8086, 0x1533, "i210", "I210", INTEL_PBSIZE_RST ),
 | 
			
		||||
	PCI_ROM ( 0x8086, 0x1539, "i211", "I211", 0 ),
 | 
			
		||||
	PCI_ROM ( 0x8086, 0x153a, "i217lm", "I217-LM", INTEL_NO_PHY_RST ),
 | 
			
		||||
	PCI_ROM ( 0x8086, 0x153b, "i217v", "I217-V", 0 ),
 | 
			
		||||
@ -1147,7 +1159,7 @@ static struct pci_device_id intel_nics[] = {
 | 
			
		||||
	PCI_ROM ( 0x8086, 0x155a, "i218lm", "I218-LM", INTEL_NO_PHY_RST ),
 | 
			
		||||
	PCI_ROM ( 0x8086, 0x156f, "i219lm", "I219-LM", INTEL_I219 ),
 | 
			
		||||
	PCI_ROM ( 0x8086, 0x1570, "i219v", "I219-V", INTEL_I219 ),
 | 
			
		||||
	PCI_ROM ( 0x8086, 0x157b, "i210-2", "I210", 0 ),
 | 
			
		||||
	PCI_ROM ( 0x8086, 0x157b, "i210-2", "I210", INTEL_PBSIZE_RST ),
 | 
			
		||||
	PCI_ROM ( 0x8086, 0x15a0, "i218lm-2", "I218-LM", INTEL_NO_PHY_RST ),
 | 
			
		||||
	PCI_ROM ( 0x8086, 0x15a1, "i218v-2", "I218-V", 0 ),
 | 
			
		||||
	PCI_ROM ( 0x8086, 0x15a2, "i218lm-3", "I218-LM", INTEL_NO_PHY_RST ),
 | 
			
		||||
 | 
			
		||||
@ -138,6 +138,10 @@ struct intel_descriptor {
 | 
			
		||||
/** Packet Buffer Size */
 | 
			
		||||
#define INTEL_PBS 0x01008UL
 | 
			
		||||
 | 
			
		||||
/** Receive packet buffer size */
 | 
			
		||||
#define INTEL_RXPBS 0x02404UL
 | 
			
		||||
#define INTEL_RXPBS_I210	0x000000a2UL	/**< I210 power-up default */
 | 
			
		||||
 | 
			
		||||
/** Receive Descriptor register block */
 | 
			
		||||
#define INTEL_RD 0x02800UL
 | 
			
		||||
 | 
			
		||||
@ -154,6 +158,10 @@ struct intel_descriptor {
 | 
			
		||||
/** Receive buffer length */
 | 
			
		||||
#define INTEL_RX_MAX_LEN 2048
 | 
			
		||||
 | 
			
		||||
/** Transmit packet buffer size */
 | 
			
		||||
#define INTEL_TXPBS 0x03404UL
 | 
			
		||||
#define INTEL_TXPBS_I210	0x04000014UL	/**< I210 power-up default */
 | 
			
		||||
 | 
			
		||||
/** Transmit Descriptor register block */
 | 
			
		||||
#define INTEL_TD 0x03800UL
 | 
			
		||||
 | 
			
		||||
@ -319,6 +327,8 @@ enum intel_flags {
 | 
			
		||||
	INTEL_NO_ASDE = 0x0008,
 | 
			
		||||
	/** Reset may cause a complete device hang */
 | 
			
		||||
	INTEL_RST_HANG = 0x0010,
 | 
			
		||||
	/** PBSIZE registers must be explicitly reset */
 | 
			
		||||
	INTEL_PBSIZE_RST = 0x0020,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** The i219 has a seriously broken reset mechanism */
 | 
			
		||||
 | 
			
		||||
@ -473,6 +473,7 @@ static struct pci_device_id intelx_nics[] = {
 | 
			
		||||
	PCI_ROM ( 0x8086, 0x10f9, "82599-cx4", "82599 (CX4)", 0 ),
 | 
			
		||||
	PCI_ROM ( 0x8086, 0x10fb, "82599-sfp", "82599 (SFI/SFP+)", 0 ),
 | 
			
		||||
	PCI_ROM ( 0x8086, 0x10fc, "82599-xaui", "82599 (XAUI/BX4)", 0 ),
 | 
			
		||||
	PCI_ROM ( 0x8086, 0x151c, "82599-tn", "82599 (TN)", 0 ),
 | 
			
		||||
	PCI_ROM ( 0x8086, 0x1528, "x540t", "X540-AT2/X540-BT2", 0 ),
 | 
			
		||||
	PCI_ROM ( 0x8086, 0x154d, "82599-sfp-sf2", "82599 (SFI/SFP+)", 0 ),
 | 
			
		||||
	PCI_ROM ( 0x8086, 0x1557, "82599en-sfp", "82599 (Single Port SFI Only)", 0 ),
 | 
			
		||||
 | 
			
		||||
@ -129,7 +129,7 @@ static int imgsingle_exec ( int argc, char **argv,
 | 
			
		||||
					    &image ) ) != 0 )
 | 
			
		||||
			goto err_acquire;
 | 
			
		||||
	} else {
 | 
			
		||||
		image = image_find_selected();
 | 
			
		||||
		image = find_image_tag ( &selected_image );
 | 
			
		||||
		if ( ! image ) {
 | 
			
		||||
			printf ( "No image selected\n" );
 | 
			
		||||
			goto err_acquire;
 | 
			
		||||
 | 
			
		||||
@ -25,7 +25,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 | 
			
		||||
 | 
			
		||||
/** @file
 | 
			
		||||
 *
 | 
			
		||||
 * Form parameter commands
 | 
			
		||||
 * Request parameter commands
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
@ -90,12 +90,16 @@ static int params_exec ( int argc, char **argv ) {
 | 
			
		||||
struct param_options {
 | 
			
		||||
	/** Parameter list name */
 | 
			
		||||
	char *params;
 | 
			
		||||
	/** Parameter is a header */
 | 
			
		||||
	int header;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** "param" option list */
 | 
			
		||||
static struct option_descriptor param_opts[] = {
 | 
			
		||||
	OPTION_DESC ( "params", 'p', required_argument,
 | 
			
		||||
		      struct param_options, params, parse_string ),
 | 
			
		||||
	OPTION_DESC ( "header", 'H', no_argument,
 | 
			
		||||
		      struct param_options, header, parse_flag ),
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** "param" command descriptor */
 | 
			
		||||
@ -114,6 +118,7 @@ static int param_exec ( int argc, char **argv ) {
 | 
			
		||||
	struct param_options opts;
 | 
			
		||||
	char *key;
 | 
			
		||||
	char *value;
 | 
			
		||||
	unsigned int flags;
 | 
			
		||||
	struct parameters *params;
 | 
			
		||||
	struct parameter *param;
 | 
			
		||||
	int rc;
 | 
			
		||||
@ -132,12 +137,15 @@ static int param_exec ( int argc, char **argv ) {
 | 
			
		||||
		goto err_parse_value;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* Construct flags */
 | 
			
		||||
	flags = ( opts.header ? PARAMETER_HEADER : PARAMETER_FORM );
 | 
			
		||||
 | 
			
		||||
	/* Identify parameter list */
 | 
			
		||||
	if ( ( rc = parse_parameters ( opts.params, ¶ms ) ) != 0 )
 | 
			
		||||
		goto err_parse_parameters;
 | 
			
		||||
 | 
			
		||||
	/* Add parameter */
 | 
			
		||||
	param = add_parameter ( params, key, value );
 | 
			
		||||
	param = add_parameter ( params, key, value, flags );
 | 
			
		||||
	if ( ! param ) {
 | 
			
		||||
		rc = -ENOMEM;
 | 
			
		||||
		goto err_add_parameter;
 | 
			
		||||
@ -154,7 +162,7 @@ static int param_exec ( int argc, char **argv ) {
 | 
			
		||||
	return rc;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/** Form parameter commands */
 | 
			
		||||
/** Request parameter commands */
 | 
			
		||||
struct command param_commands[] __command = {
 | 
			
		||||
	{
 | 
			
		||||
		.name = "params",
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										131
									
								
								src/hci/commands/shim_cmd.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										131
									
								
								src/hci/commands/shim_cmd.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,131 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (C) 2023 Michael Brown <mbrown@fensystems.co.uk>.
 | 
			
		||||
 *
 | 
			
		||||
 * This program is free software; you can redistribute it and/or
 | 
			
		||||
 * modify it under the terms of the GNU General Public License as
 | 
			
		||||
 * published by the Free Software Foundation; either version 2 of the
 | 
			
		||||
 * License, or any later version.
 | 
			
		||||
 *
 | 
			
		||||
 * This program 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
 | 
			
		||||
 * General Public License for more details.
 | 
			
		||||
 *
 | 
			
		||||
 * You should have received a copy of the GNU General Public License
 | 
			
		||||
 * along with this program; if not, write to the Free Software
 | 
			
		||||
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 | 
			
		||||
 * 02110-1301, USA.
 | 
			
		||||
 *
 | 
			
		||||
 * You can also choose to distribute this program under the terms of
 | 
			
		||||
 * the Unmodified Binary Distribution Licence (as given in the file
 | 
			
		||||
 * COPYING.UBDL), provided that you have satisfied its requirements.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 | 
			
		||||
 | 
			
		||||
#include <getopt.h>
 | 
			
		||||
#include <ipxe/command.h>
 | 
			
		||||
#include <ipxe/parseopt.h>
 | 
			
		||||
#include <ipxe/efi/efi_image.h>
 | 
			
		||||
#include <usr/imgmgmt.h>
 | 
			
		||||
#include <usr/shimmgmt.h>
 | 
			
		||||
 | 
			
		||||
/** @file
 | 
			
		||||
 *
 | 
			
		||||
 * EFI shim command
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
/* Exist as a dummy command on non-EFI platforms */
 | 
			
		||||
#ifdef PLATFORM_efi
 | 
			
		||||
#define shim_dummy 0
 | 
			
		||||
#else
 | 
			
		||||
#define shim_dummy 1
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/** "shim" options */
 | 
			
		||||
struct shim_options {
 | 
			
		||||
	/** Download timeout */
 | 
			
		||||
	unsigned long timeout;
 | 
			
		||||
	/** Require third party loader */
 | 
			
		||||
	int require_loader;
 | 
			
		||||
	/** Allow PXE base code protocol */
 | 
			
		||||
	int allow_pxe;
 | 
			
		||||
	/** Allow SBAT variable access */
 | 
			
		||||
	int allow_sbat;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** "shim" option list */
 | 
			
		||||
static struct option_descriptor shim_opts[] = {
 | 
			
		||||
	OPTION_DESC ( "timeout", 't', required_argument,
 | 
			
		||||
		      struct shim_options, timeout, parse_timeout ),
 | 
			
		||||
	OPTION_DESC ( "require-loader", 'l', no_argument,
 | 
			
		||||
		      struct shim_options, require_loader, parse_flag ),
 | 
			
		||||
	OPTION_DESC ( "allow-pxe", 'p', no_argument,
 | 
			
		||||
		      struct shim_options, allow_pxe, parse_flag ),
 | 
			
		||||
	OPTION_DESC ( "allow-sbat", 's', no_argument,
 | 
			
		||||
		      struct shim_options, allow_sbat, parse_flag ),
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** "shim" command descriptor */
 | 
			
		||||
static struct command_descriptor shim_cmd =
 | 
			
		||||
	COMMAND_DESC ( struct shim_options, shim_opts, 0, 1, NULL );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * The "shim" command
 | 
			
		||||
 *
 | 
			
		||||
 * @v argc		Argument count
 | 
			
		||||
 * @v argv		Argument list
 | 
			
		||||
 * @ret rc		Return status code
 | 
			
		||||
 */
 | 
			
		||||
static int shim_exec ( int argc, char **argv ) {
 | 
			
		||||
	struct shim_options opts;
 | 
			
		||||
	struct image *image = NULL;
 | 
			
		||||
	struct image *kernel;
 | 
			
		||||
	char *name_uri;
 | 
			
		||||
	int download;
 | 
			
		||||
	int rc;
 | 
			
		||||
 | 
			
		||||
	/* Do absolutely nothing if this is a non-EFI platform */
 | 
			
		||||
	if ( shim_dummy ) {
 | 
			
		||||
		rc = 0;
 | 
			
		||||
		goto err_dummy;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* Parse options */
 | 
			
		||||
	if ( ( rc = parse_options ( argc, argv, &shim_cmd, &opts ) ) != 0 )
 | 
			
		||||
		goto err_parse;
 | 
			
		||||
 | 
			
		||||
	/* Decide whether or not to download images */
 | 
			
		||||
	kernel = find_image_tag ( &selected_image );
 | 
			
		||||
	download = ( ! ( kernel && efi_can_load ( kernel ) ) );
 | 
			
		||||
 | 
			
		||||
	/* Parse name/URI string */
 | 
			
		||||
	name_uri = argv[optind];
 | 
			
		||||
 | 
			
		||||
	/* Acquire image, if applicable */
 | 
			
		||||
	if ( download && name_uri &&
 | 
			
		||||
	     ( ( rc = imgacquire ( name_uri, opts.timeout,
 | 
			
		||||
				   &image ) ) != 0 ) ) {
 | 
			
		||||
		goto err_image;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* (Un)register as shim */
 | 
			
		||||
	if ( ( rc = shim ( image, opts.require_loader, opts.allow_pxe,
 | 
			
		||||
			   opts.allow_sbat ) ) != 0 )
 | 
			
		||||
		goto err_shim;
 | 
			
		||||
 | 
			
		||||
 err_shim:
 | 
			
		||||
 err_image:
 | 
			
		||||
 err_parse:
 | 
			
		||||
 err_dummy:
 | 
			
		||||
	return rc;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/** Shim commands */
 | 
			
		||||
struct command shim_commands[] __command = {
 | 
			
		||||
	{
 | 
			
		||||
		.name = "shim",
 | 
			
		||||
		.exec = shim_exec,
 | 
			
		||||
	},
 | 
			
		||||
};
 | 
			
		||||
@ -31,6 +31,8 @@ FILE_LICENCE ( GPL2_OR_LATER );
 | 
			
		||||
#include <ipxe/efi/efi_wrap.h>
 | 
			
		||||
#include <ipxe/efi/efi_pxe.h>
 | 
			
		||||
#include <ipxe/efi/efi_driver.h>
 | 
			
		||||
#include <ipxe/efi/efi_image.h>
 | 
			
		||||
#include <ipxe/efi/efi_shim.h>
 | 
			
		||||
#include <ipxe/image.h>
 | 
			
		||||
#include <ipxe/init.h>
 | 
			
		||||
#include <ipxe/features.h>
 | 
			
		||||
@ -109,18 +111,14 @@ efi_image_path ( struct image *image, EFI_DEVICE_PATH_PROTOCOL *parent ) {
 | 
			
		||||
 */
 | 
			
		||||
static wchar_t * efi_image_cmdline ( struct image *image ) {
 | 
			
		||||
	wchar_t *cmdline;
 | 
			
		||||
	size_t len;
 | 
			
		||||
 | 
			
		||||
	len = ( strlen ( image->name ) +
 | 
			
		||||
		( image->cmdline ?
 | 
			
		||||
		  ( 1 /* " " */ + strlen ( image->cmdline ) ) : 0 ) );
 | 
			
		||||
	cmdline = zalloc ( ( len + 1 /* NUL */ ) * sizeof ( wchar_t ) );
 | 
			
		||||
	if ( ! cmdline )
 | 
			
		||||
	/* Allocate and construct command line */
 | 
			
		||||
	if ( efi_asprintf ( &cmdline, "%s%s%s", image->name,
 | 
			
		||||
			    ( image->cmdline ? " " : "" ),
 | 
			
		||||
			    ( image->cmdline ? image->cmdline : "" ) ) < 0 ) {
 | 
			
		||||
		return NULL;
 | 
			
		||||
	efi_snprintf ( cmdline, ( len + 1 /* NUL */ ), "%s%s%s",
 | 
			
		||||
		       image->name,
 | 
			
		||||
		       ( image->cmdline ? " " : "" ),
 | 
			
		||||
		       ( image->cmdline ? image->cmdline : "" ) );
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return cmdline;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -138,47 +136,65 @@ static int efi_image_exec ( struct image *image ) {
 | 
			
		||||
		EFI_LOADED_IMAGE_PROTOCOL *image;
 | 
			
		||||
		void *interface;
 | 
			
		||||
	} loaded;
 | 
			
		||||
	struct image *shim;
 | 
			
		||||
	struct image *exec;
 | 
			
		||||
	EFI_HANDLE handle;
 | 
			
		||||
	EFI_MEMORY_TYPE type;
 | 
			
		||||
	wchar_t *cmdline;
 | 
			
		||||
	unsigned int toggle;
 | 
			
		||||
	EFI_STATUS efirc;
 | 
			
		||||
	int rc;
 | 
			
		||||
 | 
			
		||||
	/* Find an appropriate device handle to use */
 | 
			
		||||
	snpdev = last_opened_snpdev();
 | 
			
		||||
	if ( ! snpdev ) {
 | 
			
		||||
		DBGC ( image, "EFIIMAGE %p could not identify SNP device\n",
 | 
			
		||||
		       image );
 | 
			
		||||
		DBGC ( image, "EFIIMAGE %s could not identify SNP device\n",
 | 
			
		||||
		       image->name );
 | 
			
		||||
		rc = -ENODEV;
 | 
			
		||||
		goto err_no_snpdev;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* Use shim instead of directly executing image if applicable */
 | 
			
		||||
	shim = ( efi_can_load ( image ) ?
 | 
			
		||||
		 NULL : find_image_tag ( &efi_shim ) );
 | 
			
		||||
	exec = ( shim ? shim : image );
 | 
			
		||||
	if ( shim ) {
 | 
			
		||||
		DBGC ( image, "EFIIMAGE %s executing via %s\n",
 | 
			
		||||
		       image->name, shim->name );
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* Re-register as a hidden image to allow for access via file I/O */
 | 
			
		||||
	toggle = ( ~image->flags & IMAGE_HIDDEN );
 | 
			
		||||
	image->flags |= IMAGE_HIDDEN;
 | 
			
		||||
	if ( ( rc = register_image ( image ) ) != 0 )
 | 
			
		||||
		goto err_register_image;
 | 
			
		||||
 | 
			
		||||
	/* Install file I/O protocols */
 | 
			
		||||
	if ( ( rc = efi_file_install ( snpdev->handle ) ) != 0 ) {
 | 
			
		||||
		DBGC ( image, "EFIIMAGE %p could not install file protocol: "
 | 
			
		||||
		       "%s\n", image, strerror ( rc ) );
 | 
			
		||||
		DBGC ( image, "EFIIMAGE %s could not install file protocol: "
 | 
			
		||||
		       "%s\n", image->name, strerror ( rc ) );
 | 
			
		||||
		goto err_file_install;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* Install PXE base code protocol */
 | 
			
		||||
	if ( ( rc = efi_pxe_install ( snpdev->handle, snpdev->netdev ) ) != 0 ){
 | 
			
		||||
		DBGC ( image, "EFIIMAGE %p could not install PXE protocol: "
 | 
			
		||||
		       "%s\n", image, strerror ( rc ) );
 | 
			
		||||
		DBGC ( image, "EFIIMAGE %s could not install PXE protocol: "
 | 
			
		||||
		       "%s\n", image->name, strerror ( rc ) );
 | 
			
		||||
		goto err_pxe_install;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* Install iPXE download protocol */
 | 
			
		||||
	if ( ( rc = efi_download_install ( snpdev->handle ) ) != 0 ) {
 | 
			
		||||
		DBGC ( image, "EFIIMAGE %p could not install iPXE download "
 | 
			
		||||
		       "protocol: %s\n", image, strerror ( rc ) );
 | 
			
		||||
		DBGC ( image, "EFIIMAGE %s could not install iPXE download "
 | 
			
		||||
		       "protocol: %s\n", image->name, strerror ( rc ) );
 | 
			
		||||
		goto err_download_install;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* Create device path for image */
 | 
			
		||||
	path = efi_image_path ( image, snpdev->path );
 | 
			
		||||
	path = efi_image_path ( exec, snpdev->path );
 | 
			
		||||
	if ( ! path ) {
 | 
			
		||||
		DBGC ( image, "EFIIMAGE %p could not create device path\n",
 | 
			
		||||
		       image );
 | 
			
		||||
		DBGC ( image, "EFIIMAGE %s could not create device path\n",
 | 
			
		||||
		       image->name );
 | 
			
		||||
		rc = -ENOMEM;
 | 
			
		||||
		goto err_image_path;
 | 
			
		||||
	}
 | 
			
		||||
@ -186,21 +202,30 @@ static int efi_image_exec ( struct image *image ) {
 | 
			
		||||
	/* Create command line for image */
 | 
			
		||||
	cmdline = efi_image_cmdline ( image );
 | 
			
		||||
	if ( ! cmdline ) {
 | 
			
		||||
		DBGC ( image, "EFIIMAGE %p could not create command line\n",
 | 
			
		||||
		       image );
 | 
			
		||||
		DBGC ( image, "EFIIMAGE %s could not create command line\n",
 | 
			
		||||
		       image->name );
 | 
			
		||||
		rc = -ENOMEM;
 | 
			
		||||
		goto err_cmdline;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* Install shim special handling if applicable */
 | 
			
		||||
	if ( shim &&
 | 
			
		||||
	     ( ( rc = efi_shim_install ( shim, snpdev->handle,
 | 
			
		||||
					 &cmdline ) ) != 0 ) ){
 | 
			
		||||
		DBGC ( image, "EFIIMAGE %s could not install shim handling: "
 | 
			
		||||
		       "%s\n", image->name, strerror ( rc ) );
 | 
			
		||||
		goto err_shim_install;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* Attempt loading image */
 | 
			
		||||
	handle = NULL;
 | 
			
		||||
	if ( ( efirc = bs->LoadImage ( FALSE, efi_image_handle, path,
 | 
			
		||||
				       user_to_virt ( image->data, 0 ),
 | 
			
		||||
				       image->len, &handle ) ) != 0 ) {
 | 
			
		||||
				       user_to_virt ( exec->data, 0 ),
 | 
			
		||||
				       exec->len, &handle ) ) != 0 ) {
 | 
			
		||||
		/* Not an EFI image */
 | 
			
		||||
		rc = -EEFI_LOAD ( efirc );
 | 
			
		||||
		DBGC ( image, "EFIIMAGE %p could not load: %s\n",
 | 
			
		||||
		       image, strerror ( rc ) );
 | 
			
		||||
		DBGC ( image, "EFIIMAGE %s could not load: %s\n",
 | 
			
		||||
		       image->name, strerror ( rc ) );
 | 
			
		||||
		if ( efirc == EFI_SECURITY_VIOLATION ) {
 | 
			
		||||
			goto err_load_image_security_violation;
 | 
			
		||||
		} else {
 | 
			
		||||
@ -220,8 +245,8 @@ static int efi_image_exec ( struct image *image ) {
 | 
			
		||||
 | 
			
		||||
	/* Some EFI 1.10 implementations seem not to fill in DeviceHandle */
 | 
			
		||||
	if ( loaded.image->DeviceHandle == NULL ) {
 | 
			
		||||
		DBGC ( image, "EFIIMAGE %p filling in missing DeviceHandle\n",
 | 
			
		||||
		       image );
 | 
			
		||||
		DBGC ( image, "EFIIMAGE %s filling in missing DeviceHandle\n",
 | 
			
		||||
		       image->name );
 | 
			
		||||
		loaded.image->DeviceHandle = snpdev->handle;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@ -251,14 +276,14 @@ static int efi_image_exec ( struct image *image ) {
 | 
			
		||||
	/* Start the image */
 | 
			
		||||
	if ( ( efirc = bs->StartImage ( handle, NULL, NULL ) ) != 0 ) {
 | 
			
		||||
		rc = -EEFI_START ( efirc );
 | 
			
		||||
		DBGC ( image, "EFIIMAGE %p could not start (or returned with "
 | 
			
		||||
		       "error): %s\n", image, strerror ( rc ) );
 | 
			
		||||
		DBGC ( image, "EFIIMAGE %s could not start (or returned with "
 | 
			
		||||
		       "error): %s\n", image->name, strerror ( rc ) );
 | 
			
		||||
		goto err_start_image;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* If image was a driver, connect it up to anything available */
 | 
			
		||||
	if ( type == EfiBootServicesCode ) {
 | 
			
		||||
		DBGC ( image, "EFIIMAGE %p connecting drivers\n", image );
 | 
			
		||||
		DBGC ( image, "EFIIMAGE %s connecting drivers\n", image->name );
 | 
			
		||||
		efi_driver_reconnect_all();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@ -286,6 +311,9 @@ static int efi_image_exec ( struct image *image ) {
 | 
			
		||||
	if ( rc != 0 )
 | 
			
		||||
		bs->UnloadImage ( handle );
 | 
			
		||||
 err_load_image:
 | 
			
		||||
	if ( shim )
 | 
			
		||||
		efi_shim_uninstall();
 | 
			
		||||
 err_shim_install:
 | 
			
		||||
	free ( cmdline );
 | 
			
		||||
 err_cmdline:
 | 
			
		||||
	free ( path );
 | 
			
		||||
@ -296,6 +324,9 @@ static int efi_image_exec ( struct image *image ) {
 | 
			
		||||
 err_pxe_install:
 | 
			
		||||
	efi_file_uninstall ( snpdev->handle );
 | 
			
		||||
 err_file_install:
 | 
			
		||||
	unregister_image ( image );
 | 
			
		||||
 err_register_image:
 | 
			
		||||
	image->flags ^= toggle;
 | 
			
		||||
 err_no_snpdev:
 | 
			
		||||
	return rc;
 | 
			
		||||
}
 | 
			
		||||
@ -324,8 +355,8 @@ static int efi_image_probe ( struct image *image ) {
 | 
			
		||||
				       image->len, &handle ) ) != 0 ) {
 | 
			
		||||
		/* Not an EFI image */
 | 
			
		||||
		rc = -EEFI_LOAD ( efirc );
 | 
			
		||||
		DBGC ( image, "EFIIMAGE %p could not load: %s\n",
 | 
			
		||||
		       image, strerror ( rc ) );
 | 
			
		||||
		DBGC ( image, "EFIIMAGE %s could not load: %s\n",
 | 
			
		||||
		       image->name, strerror ( rc ) );
 | 
			
		||||
		if ( efirc == EFI_SECURITY_VIOLATION ) {
 | 
			
		||||
			goto err_load_image_security_violation;
 | 
			
		||||
		} else {
 | 
			
		||||
@ -346,9 +377,75 @@ static int efi_image_probe ( struct image *image ) {
 | 
			
		||||
	return rc;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/** EFI image type */
 | 
			
		||||
struct image_type efi_image_type __image_type ( PROBE_NORMAL ) = {
 | 
			
		||||
	.name = "EFI",
 | 
			
		||||
	.probe = efi_image_probe,
 | 
			
		||||
	.exec = efi_image_exec,
 | 
			
		||||
/**
 | 
			
		||||
 * Probe EFI PE image
 | 
			
		||||
 *
 | 
			
		||||
 * @v image		EFI file
 | 
			
		||||
 * @ret rc		Return status code
 | 
			
		||||
 *
 | 
			
		||||
 * The extremely broken UEFI Secure Boot model provides no way for us
 | 
			
		||||
 * to unambiguously determine that a valid EFI executable image was
 | 
			
		||||
 * rejected by LoadImage() because it failed signature verification.
 | 
			
		||||
 * We must therefore use heuristics to guess whether not an image that
 | 
			
		||||
 * was rejected by LoadImage() could still be loaded via a separate PE
 | 
			
		||||
 * loader such as the UEFI shim.
 | 
			
		||||
 */
 | 
			
		||||
static int efi_pe_image_probe ( struct image *image ) {
 | 
			
		||||
	const UINT16 magic = ( ( sizeof ( UINTN ) == sizeof ( uint32_t ) ) ?
 | 
			
		||||
			       EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC :
 | 
			
		||||
			       EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC );
 | 
			
		||||
	union {
 | 
			
		||||
		EFI_IMAGE_DOS_HEADER dos;
 | 
			
		||||
		EFI_IMAGE_OPTIONAL_HEADER_UNION pe;
 | 
			
		||||
	} u;
 | 
			
		||||
 | 
			
		||||
	/* Check for existence of DOS header */
 | 
			
		||||
	if ( image->len < sizeof ( u.dos ) ) {
 | 
			
		||||
		DBGC ( image, "EFIIMAGE %s too short for DOS header\n",
 | 
			
		||||
		       image->name );
 | 
			
		||||
		return -ENOEXEC;
 | 
			
		||||
	}
 | 
			
		||||
	copy_from_user ( &u.dos, image->data, 0, sizeof ( u.dos ) );
 | 
			
		||||
	if ( u.dos.e_magic != EFI_IMAGE_DOS_SIGNATURE ) {
 | 
			
		||||
		DBGC ( image, "EFIIMAGE %s missing MZ signature\n",
 | 
			
		||||
		       image->name );
 | 
			
		||||
		return -ENOEXEC;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* Check for existence of PE header */
 | 
			
		||||
	if ( ( image->len < u.dos.e_lfanew ) ||
 | 
			
		||||
	     ( ( image->len - u.dos.e_lfanew ) < sizeof ( u.pe ) ) ) {
 | 
			
		||||
		DBGC ( image, "EFIIMAGE %s too short for PE header\n",
 | 
			
		||||
		       image->name );
 | 
			
		||||
		return -ENOEXEC;
 | 
			
		||||
	}
 | 
			
		||||
	copy_from_user ( &u.pe, image->data, u.dos.e_lfanew, sizeof ( u.pe ) );
 | 
			
		||||
	if ( u.pe.Pe32.Signature != EFI_IMAGE_NT_SIGNATURE ) {
 | 
			
		||||
		DBGC ( image, "EFIIMAGE %s missing PE signature\n",
 | 
			
		||||
		       image->name );
 | 
			
		||||
		return -ENOEXEC;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* Check PE header magic */
 | 
			
		||||
	if ( u.pe.Pe32.OptionalHeader.Magic != magic ) {
 | 
			
		||||
		DBGC ( image, "EFIIMAGE %s incorrect magic %04x\n",
 | 
			
		||||
		       image->name, u.pe.Pe32.OptionalHeader.Magic );
 | 
			
		||||
		return -ENOEXEC;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/** EFI image types */
 | 
			
		||||
struct image_type efi_image_type[] __image_type ( PROBE_NORMAL ) = {
 | 
			
		||||
	{
 | 
			
		||||
		.name = "EFI",
 | 
			
		||||
		.probe = efi_image_probe,
 | 
			
		||||
		.exec = efi_image_exec,
 | 
			
		||||
	},
 | 
			
		||||
	{
 | 
			
		||||
		.name = "EFIPE",
 | 
			
		||||
		.probe = efi_pe_image_probe,
 | 
			
		||||
		.exec = efi_image_exec,
 | 
			
		||||
	},
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@ -197,11 +197,6 @@ static int script_exec ( struct image *image ) {
 | 
			
		||||
	size_t saved_offset;
 | 
			
		||||
	int rc;
 | 
			
		||||
 | 
			
		||||
	/* Temporarily de-register image, so that a "boot" command
 | 
			
		||||
	 * doesn't throw us into an execution loop.
 | 
			
		||||
	 */
 | 
			
		||||
	unregister_image ( image );
 | 
			
		||||
 | 
			
		||||
	/* Preserve state of any currently-running script */
 | 
			
		||||
	saved_offset = script_offset;
 | 
			
		||||
 | 
			
		||||
@ -212,10 +207,6 @@ static int script_exec ( struct image *image ) {
 | 
			
		||||
	/* Restore saved state */
 | 
			
		||||
	script_offset = saved_offset;
 | 
			
		||||
 | 
			
		||||
	/* Re-register image (unless we have been replaced) */
 | 
			
		||||
	if ( ! image->replacement )
 | 
			
		||||
		register_image ( image );
 | 
			
		||||
 | 
			
		||||
	return rc;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -320,6 +311,7 @@ static int terminate_on_label_found ( int rc ) {
 | 
			
		||||
 * @ret rc		Return status code
 | 
			
		||||
 */
 | 
			
		||||
static int goto_exec ( int argc, char **argv ) {
 | 
			
		||||
	struct image *image = current_image.image;
 | 
			
		||||
	struct goto_options opts;
 | 
			
		||||
	size_t saved_offset;
 | 
			
		||||
	int rc;
 | 
			
		||||
@ -329,7 +321,7 @@ static int goto_exec ( int argc, char **argv ) {
 | 
			
		||||
		return rc;
 | 
			
		||||
 | 
			
		||||
	/* Sanity check */
 | 
			
		||||
	if ( ! current_image ) {
 | 
			
		||||
	if ( ! image ) {
 | 
			
		||||
		rc = -ENOTTY;
 | 
			
		||||
		printf ( "Not in a script: %s\n", strerror ( rc ) );
 | 
			
		||||
		return rc;
 | 
			
		||||
@ -340,10 +332,10 @@ static int goto_exec ( int argc, char **argv ) {
 | 
			
		||||
 | 
			
		||||
	/* Find label */
 | 
			
		||||
	saved_offset = script_offset;
 | 
			
		||||
	if ( ( rc = process_script ( current_image, goto_find_label,
 | 
			
		||||
	if ( ( rc = process_script ( image, goto_find_label,
 | 
			
		||||
				     terminate_on_label_found ) ) != 0 ) {
 | 
			
		||||
		script_offset = saved_offset;
 | 
			
		||||
		DBGC ( current_image, "[%04zx] No such label :%s\n",
 | 
			
		||||
		DBGC ( image, "[%04zx] No such label :%s\n",
 | 
			
		||||
		       script_offset, goto_label );
 | 
			
		||||
		return rc;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@ -262,10 +262,10 @@ static inline void eplatform_discard ( int dummy __unused, ... ) {}
 | 
			
		||||
		  ".balign 8\n\t"					\
 | 
			
		||||
		  "\n1:\n\t"						\
 | 
			
		||||
		  ".long ( 4f - 1b )\n\t"				\
 | 
			
		||||
		  ".long %c0\n\t"					\
 | 
			
		||||
		  ".long %" ASM_NO_PREFIX "0\n\t"			\
 | 
			
		||||
		  ".long ( 2f - 1b )\n\t"				\
 | 
			
		||||
		  ".long ( 3f - 1b )\n\t"				\
 | 
			
		||||
		  ".long %c1\n\t"					\
 | 
			
		||||
		  ".long %" ASM_NO_PREFIX "1\n\t"			\
 | 
			
		||||
		  "\n2:\t.asciz \"" __einfo_desc ( einfo ) "\"\n\t"	\
 | 
			
		||||
		  "\n3:\t.asciz \"" __FILE__ "\"\n\t"			\
 | 
			
		||||
		  ".balign 8\n\t"					\
 | 
			
		||||
 | 
			
		||||
@ -424,6 +424,8 @@ extern int asn1_digest_algorithm ( const struct asn1_cursor *cursor,
 | 
			
		||||
				   struct asn1_algorithm **algorithm );
 | 
			
		||||
extern int asn1_signature_algorithm ( const struct asn1_cursor *cursor,
 | 
			
		||||
				      struct asn1_algorithm **algorithm );
 | 
			
		||||
extern int asn1_check_algorithm ( const struct asn1_cursor *cursor,
 | 
			
		||||
				  struct asn1_algorithm *expected );
 | 
			
		||||
extern int asn1_generalized_time ( const struct asn1_cursor *cursor,
 | 
			
		||||
				   time_t *time );
 | 
			
		||||
extern int asn1_grow ( struct asn1_builder *builder, size_t extra );
 | 
			
		||||
 | 
			
		||||
@ -188,6 +188,40 @@ typedef INT64 INTN;
 | 
			
		||||
#define GCC_ASM_IMPORT(func__)  \
 | 
			
		||||
         .extern  _CONCATENATE (__USER_LABEL_PREFIX__, func__)
 | 
			
		||||
 | 
			
		||||
  #if defined (__ARM_FEATURE_BTI_DEFAULT) && __ARM_FEATURE_BTI_DEFAULT == 1
 | 
			
		||||
#define AARCH64_BTI_NOTE()                                         \
 | 
			
		||||
    .ifndef       .Lgnu_bti_notesize                              ;\
 | 
			
		||||
    .pushsection  .note.gnu.property, "a"                         ;\
 | 
			
		||||
    .set          NT_GNU_PROPERTY_TYPE_0, 0x5                     ;\
 | 
			
		||||
    .set          GNU_PROPERTY_AARCH64_FEATURE_1_AND, 0xc0000000  ;\
 | 
			
		||||
    .set          GNU_PROPERTY_AARCH64_FEATURE_1_BTI, 0x1         ;\
 | 
			
		||||
    .align        3                                               ;\
 | 
			
		||||
    .long         .Lnamesize                                      ;\
 | 
			
		||||
    .long         .Lgnu_bti_notesize                              ;\
 | 
			
		||||
    .long         NT_GNU_PROPERTY_TYPE_0                          ;\
 | 
			
		||||
0:  .asciz        "GNU"                                           ;\
 | 
			
		||||
    .set          .Lnamesize, . - 0b                              ;\
 | 
			
		||||
    .align        3                                               ;\
 | 
			
		||||
1:  .long         GNU_PROPERTY_AARCH64_FEATURE_1_AND              ;\
 | 
			
		||||
    .long         .Lvalsize                                       ;\
 | 
			
		||||
2:  .long         GNU_PROPERTY_AARCH64_FEATURE_1_BTI              ;\
 | 
			
		||||
    .set          .Lvalsize, . - 2b                               ;\
 | 
			
		||||
    .align        3                                               ;\
 | 
			
		||||
    .set          .Lgnu_bti_notesize, . - 1b                      ;\
 | 
			
		||||
    .popsection                                                   ;\
 | 
			
		||||
    .endif
 | 
			
		||||
 | 
			
		||||
#define AARCH64_BTI(__type)                                        \
 | 
			
		||||
    AARCH64_BTI_NOTE()                                            ;\
 | 
			
		||||
    bti           __type
 | 
			
		||||
 | 
			
		||||
  #endif
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef AARCH64_BTI
 | 
			
		||||
#define AARCH64_BTI_NOTE()
 | 
			
		||||
#define AARCH64_BTI(__type)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 | 
			
		||||
@ -760,6 +760,40 @@ typedef UINTN *BASE_LIST;
 | 
			
		||||
#define OFFSET_OF(TYPE, Field)  ((UINTN) &(((TYPE *)0)->Field))
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Returns the alignment requirement of a type.
 | 
			
		||||
 | 
			
		||||
  @param   TYPE  The name of the type to retrieve the alignment requirement of.
 | 
			
		||||
 | 
			
		||||
  @return  Alignment requirement, in Bytes, of TYPE.
 | 
			
		||||
**/
 | 
			
		||||
#if defined (__cplusplus)
 | 
			
		||||
//
 | 
			
		||||
// Standard C++ operator.
 | 
			
		||||
//
 | 
			
		||||
#define ALIGNOF(TYPE)  alignof (TYPE)
 | 
			
		||||
#elif defined (__GNUC__) || defined (__clang__) || (defined (_MSC_VER) && _MSC_VER >= 1900)
 | 
			
		||||
//
 | 
			
		||||
// All supported versions of GCC and Clang, as well as MSVC 2015 and later,
 | 
			
		||||
// support the standard operator _Alignof.
 | 
			
		||||
//
 | 
			
		||||
#define ALIGNOF(TYPE)  _Alignof (TYPE)
 | 
			
		||||
#elif defined (_MSC_EXTENSIONS)
 | 
			
		||||
//
 | 
			
		||||
// Earlier versions of MSVC, at least MSVC 2008 and later, support the vendor
 | 
			
		||||
// extension __alignof.
 | 
			
		||||
//
 | 
			
		||||
#define ALIGNOF(TYPE)  __alignof (TYPE)
 | 
			
		||||
#else
 | 
			
		||||
//
 | 
			
		||||
// For compilers that do not support inbuilt alignof operators, use OFFSET_OF.
 | 
			
		||||
// CHAR8 is known to have both a size and an alignment requirement of 1 Byte.
 | 
			
		||||
// As such, A must be located exactly at the offset equal to its alignment
 | 
			
		||||
// requirement.
 | 
			
		||||
//
 | 
			
		||||
#define ALIGNOF(TYPE)  OFFSET_OF (struct { CHAR8 C; TYPE A; }, A)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Portable definition for compile time assertions.
 | 
			
		||||
  Equivalent to C11 static_assert macro from assert.h.
 | 
			
		||||
@ -795,12 +829,27 @@ STATIC_ASSERT (sizeof (CHAR16)  == 2, "sizeof (CHAR16) does not meet UEFI Specif
 | 
			
		||||
STATIC_ASSERT (sizeof (L'A')    == 2, "sizeof (L'A') does not meet UEFI Specification Data Type requirements");
 | 
			
		||||
STATIC_ASSERT (sizeof (L"A")    == 4, "sizeof (L\"A\") does not meet UEFI Specification Data Type requirements");
 | 
			
		||||
 | 
			
		||||
STATIC_ASSERT (ALIGNOF (BOOLEAN) == sizeof (BOOLEAN), "Alignment of BOOLEAN does not meet UEFI Specification Data Type requirements");
 | 
			
		||||
STATIC_ASSERT (ALIGNOF (INT8)    == sizeof (INT8), "Alignment of INT8 does not meet UEFI Specification Data Type requirements");
 | 
			
		||||
STATIC_ASSERT (ALIGNOF (UINT8)   == sizeof (UINT8), "Alignment of INT16 does not meet UEFI Specification Data Type requirements");
 | 
			
		||||
STATIC_ASSERT (ALIGNOF (INT16)   == sizeof (INT16), "Alignment of INT16 does not meet UEFI Specification Data Type requirements");
 | 
			
		||||
STATIC_ASSERT (ALIGNOF (UINT16)  == sizeof (UINT16), "Alignment of UINT16 does not meet UEFI Specification Data Type requirements");
 | 
			
		||||
STATIC_ASSERT (ALIGNOF (INT32)   == sizeof (INT32), "Alignment of INT32 does not meet UEFI Specification Data Type requirements");
 | 
			
		||||
STATIC_ASSERT (ALIGNOF (UINT32)  == sizeof (UINT32), "Alignment of UINT32 does not meet UEFI Specification Data Type requirements");
 | 
			
		||||
STATIC_ASSERT (ALIGNOF (INT64)   == sizeof (INT64), "Alignment of INT64 does not meet UEFI Specification Data Type requirements");
 | 
			
		||||
STATIC_ASSERT (ALIGNOF (UINT64)  == sizeof (UINT64), "Alignment of UINT64 does not meet UEFI Specification Data Type requirements");
 | 
			
		||||
STATIC_ASSERT (ALIGNOF (CHAR8)   == sizeof (CHAR8), "Alignment of CHAR8 does not meet UEFI Specification Data Type requirements");
 | 
			
		||||
STATIC_ASSERT (ALIGNOF (CHAR16)  == sizeof (CHAR16), "Alignment of CHAR16 does not meet UEFI Specification Data Type requirements");
 | 
			
		||||
STATIC_ASSERT (ALIGNOF (INTN)    == sizeof (INTN), "Alignment of INTN does not meet UEFI Specification Data Type requirements");
 | 
			
		||||
STATIC_ASSERT (ALIGNOF (UINTN)   == sizeof (UINTN), "Alignment of UINTN does not meet UEFI Specification Data Type requirements");
 | 
			
		||||
STATIC_ASSERT (ALIGNOF (VOID *)  == sizeof (VOID *), "Alignment of VOID * does not meet UEFI Specification Data Type requirements");
 | 
			
		||||
 | 
			
		||||
//
 | 
			
		||||
// The following three enum types are used to verify that the compiler
 | 
			
		||||
// configuration for enum types is compliant with Section 2.3.1 of the
 | 
			
		||||
// UEFI 2.3 Specification. These enum types and enum values are not
 | 
			
		||||
// intended to be used. A prefix of '__' is used avoid conflicts with
 | 
			
		||||
// other types.
 | 
			
		||||
// UEFI 2.3.1 Errata C Specification. These enum types and enum values
 | 
			
		||||
// are not intended to be used. A prefix of '__' is used avoid
 | 
			
		||||
// conflicts with other types.
 | 
			
		||||
//
 | 
			
		||||
typedef enum {
 | 
			
		||||
  __VerifyUint8EnumValue = 0xff
 | 
			
		||||
@ -811,12 +860,16 @@ typedef enum {
 | 
			
		||||
} __VERIFY_UINT16_ENUM_SIZE;
 | 
			
		||||
 | 
			
		||||
typedef enum {
 | 
			
		||||
  __VerifyUint32EnumValue = 0xffffffff
 | 
			
		||||
} __VERIFY_UINT32_ENUM_SIZE;
 | 
			
		||||
  __VerifyInt32EnumValue = 0x7fffffff
 | 
			
		||||
} __VERIFY_INT32_ENUM_SIZE;
 | 
			
		||||
 | 
			
		||||
STATIC_ASSERT (sizeof (__VERIFY_UINT8_ENUM_SIZE) == 4, "Size of enum does not meet UEFI Specification Data Type requirements");
 | 
			
		||||
STATIC_ASSERT (sizeof (__VERIFY_UINT16_ENUM_SIZE) == 4, "Size of enum does not meet UEFI Specification Data Type requirements");
 | 
			
		||||
STATIC_ASSERT (sizeof (__VERIFY_UINT32_ENUM_SIZE) == 4, "Size of enum does not meet UEFI Specification Data Type requirements");
 | 
			
		||||
STATIC_ASSERT (sizeof (__VERIFY_INT32_ENUM_SIZE) == 4, "Size of enum does not meet UEFI Specification Data Type requirements");
 | 
			
		||||
 | 
			
		||||
STATIC_ASSERT (ALIGNOF (__VERIFY_UINT8_ENUM_SIZE)  == sizeof (__VERIFY_UINT8_ENUM_SIZE), "Alignment of enum does not meet UEFI Specification Data Type requirements");
 | 
			
		||||
STATIC_ASSERT (ALIGNOF (__VERIFY_UINT16_ENUM_SIZE) == sizeof (__VERIFY_UINT16_ENUM_SIZE), "Alignment of enum does not meet UEFI Specification Data Type requirements");
 | 
			
		||||
STATIC_ASSERT (ALIGNOF (__VERIFY_INT32_ENUM_SIZE) == sizeof (__VERIFY_INT32_ENUM_SIZE), "Alignment of enum does not meet UEFI Specification Data Type requirements");
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Macro that returns a pointer to the data structure that contains a specified field of
 | 
			
		||||
@ -839,6 +892,49 @@ STATIC_ASSERT (sizeof (__VERIFY_UINT32_ENUM_SIZE) == 4, "Size of enum does not m
 | 
			
		||||
**/
 | 
			
		||||
#define BASE_CR(Record, TYPE, Field)  ((TYPE *) ((CHAR8 *) (Record) - OFFSET_OF (TYPE, Field)))
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Checks whether a value is a power of two.
 | 
			
		||||
 | 
			
		||||
  @param   Value  The value to check.
 | 
			
		||||
 | 
			
		||||
  @retval TRUE   Value is a power of two.
 | 
			
		||||
  @retval FALSE  Value is not a power of two.
 | 
			
		||||
**/
 | 
			
		||||
#define IS_POW2(Value)  ((Value) != 0U && ((Value) & ((Value) - 1U)) == 0U)
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Checks whether a value is aligned by a specified alignment.
 | 
			
		||||
 | 
			
		||||
  @param   Value      The value to check.
 | 
			
		||||
  @param   Alignment  The alignment boundary used to check against.
 | 
			
		||||
 | 
			
		||||
  @retval TRUE   Value is aligned by Alignment.
 | 
			
		||||
  @retval FALSE  Value is not aligned by Alignment.
 | 
			
		||||
**/
 | 
			
		||||
#define IS_ALIGNED(Value, Alignment)  (((Value) & ((Alignment) - 1U)) == 0U)
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Checks whether a pointer or address is aligned by a specified alignment.
 | 
			
		||||
 | 
			
		||||
  @param   Address    The pointer or address to check.
 | 
			
		||||
  @param   Alignment  The alignment boundary used to check against.
 | 
			
		||||
 | 
			
		||||
  @retval TRUE   Address is aligned by Alignment.
 | 
			
		||||
  @retval FALSE  Address is not aligned by Alignment.
 | 
			
		||||
**/
 | 
			
		||||
#define ADDRESS_IS_ALIGNED(Address, Alignment)  IS_ALIGNED ((UINTN) (Address), Alignment)
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Determines the addend to add to a value to round it up to the next boundary of
 | 
			
		||||
  a specified alignment.
 | 
			
		||||
 | 
			
		||||
  @param   Value      The value to round up.
 | 
			
		||||
  @param   Alignment  The alignment boundary used to return the addend.
 | 
			
		||||
 | 
			
		||||
  @return  Addend to round Value up to alignment boundary Alignment.
 | 
			
		||||
**/
 | 
			
		||||
#define ALIGN_VALUE_ADDEND(Value, Alignment)  (((Alignment) - (Value)) & ((Alignment) - 1U))
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Rounds a value up to the next boundary using a specified alignment.
 | 
			
		||||
 | 
			
		||||
@ -851,7 +947,7 @@ STATIC_ASSERT (sizeof (__VERIFY_UINT32_ENUM_SIZE) == 4, "Size of enum does not m
 | 
			
		||||
  @return  A value up to the next boundary.
 | 
			
		||||
 | 
			
		||||
**/
 | 
			
		||||
#define ALIGN_VALUE(Value, Alignment)  ((Value) + (((Alignment) - (Value)) & ((Alignment) - 1)))
 | 
			
		||||
#define ALIGN_VALUE(Value, Alignment)  ((Value) + ALIGN_VALUE_ADDEND (Value, Alignment))
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Adjust a pointer by adding the minimum offset required for it to be aligned on
 | 
			
		||||
 | 
			
		||||
@ -90,19 +90,15 @@ FILE_LICENCE ( BSD2_PATENT );
 | 
			
		||||
 | 
			
		||||
  #if defined (_MSC_VER) && _MSC_VER >= 1800
 | 
			
		||||
 | 
			
		||||
//
 | 
			
		||||
// Disable these warnings for VS2013.
 | 
			
		||||
//
 | 
			
		||||
 | 
			
		||||
//
 | 
			
		||||
// This warning is for potentially uninitialized local variable, and it may cause false
 | 
			
		||||
// positive issues in VS2013 and VS2015 build
 | 
			
		||||
// positive issues in VS2015 build
 | 
			
		||||
//
 | 
			
		||||
    #pragma warning ( disable : 4701 )
 | 
			
		||||
 | 
			
		||||
//
 | 
			
		||||
// This warning is for potentially uninitialized local pointer variable, and it may cause
 | 
			
		||||
// false positive issues in VS2013 and VS2015 build
 | 
			
		||||
// false positive issues in VS2015 build
 | 
			
		||||
//
 | 
			
		||||
    #pragma warning ( disable : 4703 )
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -103,6 +103,7 @@ typedef struct {
 | 
			
		||||
#define EFI_IMAGE_FILE_EXECUTABLE_IMAGE     BIT1     ///< 0x0002  File is executable  (i.e. no unresolved externel references).
 | 
			
		||||
#define EFI_IMAGE_FILE_LINE_NUMS_STRIPPED   BIT2     ///< 0x0004  Line numbers stripped from file.
 | 
			
		||||
#define EFI_IMAGE_FILE_LOCAL_SYMS_STRIPPED  BIT3     ///< 0x0008  Local symbols stripped from file.
 | 
			
		||||
#define EFI_IMAGE_FILE_LARGE_ADDRESS_AWARE  BIT5     ///< 0x0020  Supports addresses > 2-GB
 | 
			
		||||
#define EFI_IMAGE_FILE_BYTES_REVERSED_LO    BIT7     ///< 0x0080  Bytes of machine word are reversed.
 | 
			
		||||
#define EFI_IMAGE_FILE_32BIT_MACHINE        BIT8     ///< 0x0100  32 bit word machine.
 | 
			
		||||
#define EFI_IMAGE_FILE_DEBUG_STRIPPED       BIT9     ///< 0x0200  Debugging info stripped from file in .DBG file.
 | 
			
		||||
@ -579,6 +580,13 @@ typedef struct {
 | 
			
		||||
  UINT32    AddressOfNameOrdinals;
 | 
			
		||||
} EFI_IMAGE_EXPORT_DIRECTORY;
 | 
			
		||||
 | 
			
		||||
//
 | 
			
		||||
// Based export types.
 | 
			
		||||
//
 | 
			
		||||
#define EFI_IMAGE_EXPORT_ORDINAL_BASE  1
 | 
			
		||||
#define EFI_IMAGE_EXPORT_ADDR_SIZE     4
 | 
			
		||||
#define EFI_IMAGE_EXPORT_ORDINAL_SIZE  2
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// Hint/Name Table.
 | 
			
		||||
///
 | 
			
		||||
@ -627,7 +635,8 @@ typedef struct {
 | 
			
		||||
  UINT32    FileOffset;  ///< The file pointer to the debug data.
 | 
			
		||||
} EFI_IMAGE_DEBUG_DIRECTORY_ENTRY;
 | 
			
		||||
 | 
			
		||||
#define EFI_IMAGE_DEBUG_TYPE_CODEVIEW  2    ///< The Visual C++ debug information.
 | 
			
		||||
#define EFI_IMAGE_DEBUG_TYPE_CODEVIEW               2    ///< The Visual C++ debug information.
 | 
			
		||||
#define EFI_IMAGE_DEBUG_TYPE_EX_DLLCHARACTERISTICS  20
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// Debug Data Structure defined in Microsoft C++.
 | 
			
		||||
@ -671,6 +680,39 @@ typedef struct {
 | 
			
		||||
  //
 | 
			
		||||
} EFI_IMAGE_DEBUG_CODEVIEW_MTOC_ENTRY;
 | 
			
		||||
 | 
			
		||||
// avoid conflict with windows header files
 | 
			
		||||
#ifndef RUNTIME_FUNCTION_INDIRECT
 | 
			
		||||
 | 
			
		||||
//
 | 
			
		||||
// .pdata entries for X64
 | 
			
		||||
//
 | 
			
		||||
typedef struct {
 | 
			
		||||
  UINT32    FunctionStartAddress;
 | 
			
		||||
  UINT32    FunctionEndAddress;
 | 
			
		||||
  UINT32    UnwindInfoAddress;
 | 
			
		||||
} RUNTIME_FUNCTION;
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
typedef struct {
 | 
			
		||||
  UINT8    Version             : 3;
 | 
			
		||||
  UINT8    Flags               : 5;
 | 
			
		||||
  UINT8    SizeOfProlog;
 | 
			
		||||
  UINT8    CountOfUnwindCodes;
 | 
			
		||||
  UINT8    FrameRegister       : 4;
 | 
			
		||||
  UINT8    FrameRegisterOffset : 4;
 | 
			
		||||
} UNWIND_INFO;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// Extended DLL Characteristics
 | 
			
		||||
///
 | 
			
		||||
#define EFI_IMAGE_DLLCHARACTERISTICS_EX_CET_COMPAT          0x0001
 | 
			
		||||
#define EFI_IMAGE_DLLCHARACTERISTICS_EX_FORWARD_CFI_COMPAT  0x0040
 | 
			
		||||
 | 
			
		||||
typedef struct {
 | 
			
		||||
  UINT32    DllCharacteristicsEx;
 | 
			
		||||
} EFI_IMAGE_DEBUG_EX_DLLCHARACTERISTICS_ENTRY;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// Resource format.
 | 
			
		||||
///
 | 
			
		||||
 | 
			
		||||
@ -153,6 +153,56 @@ typedef struct {
 | 
			
		||||
 | 
			
		||||
#define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT  8
 | 
			
		||||
 | 
			
		||||
VOID
 | 
			
		||||
RiscVSetSupervisorScratch (
 | 
			
		||||
  IN UINT64
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
UINT64
 | 
			
		||||
RiscVGetSupervisorScratch (
 | 
			
		||||
  VOID
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
VOID
 | 
			
		||||
RiscVSetSupervisorStvec (
 | 
			
		||||
  IN UINT64
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
UINT64
 | 
			
		||||
RiscVGetSupervisorStvec (
 | 
			
		||||
  VOID
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
UINT64
 | 
			
		||||
RiscVGetSupervisorTrapCause (
 | 
			
		||||
  VOID
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
VOID
 | 
			
		||||
RiscVSetSupervisorAddressTranslationRegister (
 | 
			
		||||
  IN UINT64
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
UINT64
 | 
			
		||||
RiscVReadTimer (
 | 
			
		||||
  VOID
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
VOID
 | 
			
		||||
RiscVEnableTimerInterrupt (
 | 
			
		||||
  VOID
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
VOID
 | 
			
		||||
RiscVDisableTimerInterrupt (
 | 
			
		||||
  VOID
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
VOID
 | 
			
		||||
RiscVClearPendingTimerInterrupt (
 | 
			
		||||
  VOID
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
#endif // defined (MDE_CPU_RISCV64)
 | 
			
		||||
 | 
			
		||||
#if defined (MDE_CPU_LOONGARCH64)
 | 
			
		||||
 | 
			
		||||
@ -615,11 +615,34 @@ typedef struct {
 | 
			
		||||
#define EXCEPT_RISCV_STORE_AMO_ACCESS_FAULT        7
 | 
			
		||||
#define EXCEPT_RISCV_ENV_CALL_FROM_UMODE           8
 | 
			
		||||
#define EXCEPT_RISCV_ENV_CALL_FROM_SMODE           9
 | 
			
		||||
#define EXCEPT_RISCV_ENV_CALL_FROM_HMODE           10
 | 
			
		||||
#define EXCEPT_RISCV_ENV_CALL_FROM_VS_MODE         10
 | 
			
		||||
#define EXCEPT_RISCV_ENV_CALL_FROM_MMODE           11
 | 
			
		||||
#define EXCEPT_RISCV_INST_ACCESS_PAGE_FAULT        12
 | 
			
		||||
#define EXCEPT_RISCV_LOAD_ACCESS_PAGE_FAULT        13
 | 
			
		||||
#define EXCEPT_RISCV_14                            14
 | 
			
		||||
#define EXCEPT_RISCV_STORE_ACCESS_PAGE_FAULT       15
 | 
			
		||||
#define EXCEPT_RISCV_16                            16
 | 
			
		||||
#define EXCEPT_RISCV_17                            17
 | 
			
		||||
#define EXCEPT_RISCV_18                            18
 | 
			
		||||
#define EXCEPT_RISCV_19                            19
 | 
			
		||||
#define EXCEPT_RISCV_INST_GUEST_PAGE_FAULT         20
 | 
			
		||||
#define EXCEPT_RISCV_LOAD_GUEST_PAGE_FAULT         21
 | 
			
		||||
#define EXCEPT_RISCV_VIRTUAL_INSTRUCTION           22
 | 
			
		||||
#define EXCEPT_RISCV_STORE_GUEST_PAGE_FAULT        23
 | 
			
		||||
#define EXCEPT_RISCV_MAX_EXCEPTIONS                (EXCEPT_RISCV_STORE_GUEST_PAGE_FAULT)
 | 
			
		||||
 | 
			
		||||
#define EXCEPT_RISCV_SOFTWARE_INT  0x0
 | 
			
		||||
#define EXCEPT_RISCV_TIMER_INT     0x1
 | 
			
		||||
///
 | 
			
		||||
/// RISC-V processor exception types for interrupts.
 | 
			
		||||
///
 | 
			
		||||
#define EXCEPT_RISCV_IS_IRQ(x)     ((x & 0x8000000000000000UL) != 0)
 | 
			
		||||
#define EXCEPT_RISCV_IRQ_INDEX(x)  (x & 0x7FFFFFFFFFFFFFFFUL)
 | 
			
		||||
#define EXCEPT_RISCV_IRQ_0                 0x8000000000000000UL
 | 
			
		||||
#define EXCEPT_RISCV_IRQ_SOFT_FROM_SMODE   0x8000000000000001UL
 | 
			
		||||
#define EXCEPT_RISCV_IRQ_SOFT_FROM_VSMODE  0x8000000000000002UL
 | 
			
		||||
#define EXCEPT_RISCV_IRQ_SOFT_FROM_MMODE   0x8000000000000003UL
 | 
			
		||||
#define EXCEPT_RISCV_IRQ_4                 0x8000000000000004UL
 | 
			
		||||
#define EXCEPT_RISCV_IRQ_TIMER_FROM_SMODE  0x8000000000000005UL
 | 
			
		||||
#define EXCEPT_RISCV_MAX_IRQS              (EXCEPT_RISCV_IRQ_INDEX(EXCEPT_RISCV_IRQ_TIMER_FROM_SMODE))
 | 
			
		||||
 | 
			
		||||
typedef struct {
 | 
			
		||||
  UINT64    X0;
 | 
			
		||||
@ -654,6 +677,9 @@ typedef struct {
 | 
			
		||||
  UINT64    X29;
 | 
			
		||||
  UINT64    X30;
 | 
			
		||||
  UINT64    X31;
 | 
			
		||||
  UINT64    SEPC;
 | 
			
		||||
  UINT32    SSTATUS;
 | 
			
		||||
  UINT32    STVAL;
 | 
			
		||||
} EFI_SYSTEM_CONTEXT_RISCV64;
 | 
			
		||||
 | 
			
		||||
//
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										782
									
								
								src/include/ipxe/efi/Protocol/Dhcp6.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										782
									
								
								src/include/ipxe/efi/Protocol/Dhcp6.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,782 @@
 | 
			
		||||
/** @file
 | 
			
		||||
  UEFI Dynamic Host Configuration Protocol 6 Definition, which is used to get IPv6
 | 
			
		||||
  addresses and other configuration parameters from DHCPv6 servers.
 | 
			
		||||
 | 
			
		||||
  Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>
 | 
			
		||||
  SPDX-License-Identifier: BSD-2-Clause-Patent
 | 
			
		||||
 | 
			
		||||
  @par Revision Reference:
 | 
			
		||||
  This Protocol is introduced in UEFI Specification 2.2
 | 
			
		||||
 | 
			
		||||
**/
 | 
			
		||||
 | 
			
		||||
#ifndef __EFI_DHCP6_PROTOCOL_H__
 | 
			
		||||
#define __EFI_DHCP6_PROTOCOL_H__
 | 
			
		||||
 | 
			
		||||
FILE_LICENCE ( BSD2_PATENT );
 | 
			
		||||
 | 
			
		||||
#define EFI_DHCP6_PROTOCOL_GUID \
 | 
			
		||||
  { \
 | 
			
		||||
    0x87c8bad7, 0x595, 0x4053, {0x82, 0x97, 0xde, 0xde, 0x39, 0x5f, 0x5d, 0x5b } \
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
#define EFI_DHCP6_SERVICE_BINDING_PROTOCOL_GUID \
 | 
			
		||||
  { \
 | 
			
		||||
    0x9fb9a8a1, 0x2f4a, 0x43a6, {0x88, 0x9c, 0xd0, 0xf7, 0xb6, 0xc4, 0x7a, 0xd5 } \
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
typedef struct _EFI_DHCP6_PROTOCOL EFI_DHCP6_PROTOCOL;
 | 
			
		||||
 | 
			
		||||
typedef enum {
 | 
			
		||||
  ///
 | 
			
		||||
  /// The EFI DHCPv6 Protocol instance is configured, and start() needs
 | 
			
		||||
  /// to be called
 | 
			
		||||
  ///
 | 
			
		||||
  Dhcp6Init = 0x0,
 | 
			
		||||
  ///
 | 
			
		||||
  /// A Solicit packet is sent out to discover DHCPv6 server, and the EFI
 | 
			
		||||
  /// DHCPv6 Protocol instance is collecting Advertise packets.
 | 
			
		||||
  ///
 | 
			
		||||
  Dhcp6Selecting = 0x1,
 | 
			
		||||
  ///
 | 
			
		||||
  /// A Request is sent out to the DHCPv6 server, and the EFI DHCPv6
 | 
			
		||||
  /// Protocol instance is waiting for Reply packet.
 | 
			
		||||
  ///
 | 
			
		||||
  Dhcp6Requesting = 0x2,
 | 
			
		||||
  ///
 | 
			
		||||
  /// A Decline packet is sent out to indicate one or more addresses of the
 | 
			
		||||
  /// configured IA are in use by another node, and the EFI DHCPv6.
 | 
			
		||||
  /// Protocol instance is waiting for Reply packet.
 | 
			
		||||
  ///
 | 
			
		||||
  Dhcp6Declining = 0x3,
 | 
			
		||||
  ///
 | 
			
		||||
  /// A Confirm packet is sent out to confirm the IPv6 addresses of the
 | 
			
		||||
  /// configured IA, and the EFI DHCPv6 Protocol instance is waiting for Reply packet.
 | 
			
		||||
  ///
 | 
			
		||||
  Dhcp6Confirming = 0x4,
 | 
			
		||||
  ///
 | 
			
		||||
  /// A Release packet is sent out to release one or more IPv6 addresses of
 | 
			
		||||
  /// the configured IA, and the EFI DHCPv6 Protocol instance is waiting for Reply packet.
 | 
			
		||||
  ///
 | 
			
		||||
  Dhcp6Releasing = 0x5,
 | 
			
		||||
  ///
 | 
			
		||||
  /// The DHCPv6 S.A.R.R process is completed for the configured IA.
 | 
			
		||||
  ///
 | 
			
		||||
  Dhcp6Bound = 0x6,
 | 
			
		||||
  ///
 | 
			
		||||
  /// A Renew packet is sent out to extend lifetime for the IPv6 addresses of
 | 
			
		||||
  /// the configured IA, and the EFI DHCPv6 Protocol instance is waiting for Reply packet.
 | 
			
		||||
  ///
 | 
			
		||||
  Dhcp6Renewing = 0x7,
 | 
			
		||||
  ///
 | 
			
		||||
  /// A Rebind packet is sent out to extend lifetime for the IPv6 addresses of
 | 
			
		||||
  /// the configured IA, and the EFI DHCPv6 Protocol instance is waiting for Reply packet.
 | 
			
		||||
  ///
 | 
			
		||||
  Dhcp6Rebinding = 0x8
 | 
			
		||||
} EFI_DHCP6_STATE;
 | 
			
		||||
 | 
			
		||||
typedef enum {
 | 
			
		||||
  ///
 | 
			
		||||
  /// A Solicit packet is about to be sent. The packet is passed to Dhcp6Callback and
 | 
			
		||||
  /// can be modified or replaced in Dhcp6Callback.
 | 
			
		||||
  ///
 | 
			
		||||
  Dhcp6SendSolicit = 0x0,
 | 
			
		||||
  ///
 | 
			
		||||
  /// An Advertise packet is received and will be passed to Dhcp6Callback.
 | 
			
		||||
  ///
 | 
			
		||||
  Dhcp6RcvdAdvertise = 0x1,
 | 
			
		||||
  ///
 | 
			
		||||
  /// It is time for Dhcp6Callback to determine whether select the default Advertise
 | 
			
		||||
  /// packet by RFC 3315 policy, or overwrite it by specific user policy.
 | 
			
		||||
  ///
 | 
			
		||||
  Dhcp6SelectAdvertise = 0x2,
 | 
			
		||||
  ///
 | 
			
		||||
  /// A Request packet is about to be sent. The packet is passed to Dhcp6Callback and
 | 
			
		||||
  /// can be modified or replaced in Dhcp6Callback.
 | 
			
		||||
  ///
 | 
			
		||||
  Dhcp6SendRequest = 0x3,
 | 
			
		||||
  ///
 | 
			
		||||
  /// A Reply packet is received and will be passed to Dhcp6Callback.
 | 
			
		||||
  ///
 | 
			
		||||
  Dhcp6RcvdReply = 0x4,
 | 
			
		||||
  ///
 | 
			
		||||
  /// A Reconfigure packet is received and will be passed to Dhcp6Callback.
 | 
			
		||||
  ///
 | 
			
		||||
  Dhcp6RcvdReconfigure = 0x5,
 | 
			
		||||
  ///
 | 
			
		||||
  /// A Decline packet is about to be sent. The packet is passed to Dhcp6Callback and
 | 
			
		||||
  /// can be modified or replaced in Dhcp6Callback.
 | 
			
		||||
  ///
 | 
			
		||||
  Dhcp6SendDecline = 0x6,
 | 
			
		||||
  ///
 | 
			
		||||
  /// A Confirm packet is about to be sent. The packet is passed to Dhcp6Callback and
 | 
			
		||||
  /// can be modified or replaced in Dhcp6Callback.
 | 
			
		||||
  ///
 | 
			
		||||
  Dhcp6SendConfirm = 0x7,
 | 
			
		||||
  ///
 | 
			
		||||
  /// A Release packet is about to be sent. The packet is passed to Dhcp6Callback and
 | 
			
		||||
  /// can be modified or replaced in Dhcp6Callback.
 | 
			
		||||
  ///
 | 
			
		||||
  Dhcp6SendRelease = 0x8,
 | 
			
		||||
  ///
 | 
			
		||||
  /// A Renew packet is about to be sent. The packet is passed to Dhcp6Callback and
 | 
			
		||||
  /// can be modified or replaced in Dhcp6Callback.
 | 
			
		||||
  ///
 | 
			
		||||
  Dhcp6EnterRenewing = 0x9,
 | 
			
		||||
  ///
 | 
			
		||||
  /// A Rebind packet is about to be sent. The packet is passed to Dhcp6Callback and
 | 
			
		||||
  /// can be modified or replaced in Dhcp6Callback.
 | 
			
		||||
  ///
 | 
			
		||||
  Dhcp6EnterRebinding = 0xa
 | 
			
		||||
} EFI_DHCP6_EVENT;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// An IA which carries assigned not temporary address.
 | 
			
		||||
///
 | 
			
		||||
#define EFI_DHCP6_IA_TYPE_NA  3
 | 
			
		||||
///
 | 
			
		||||
/// An IA which carries assigned temporary address.
 | 
			
		||||
///
 | 
			
		||||
#define EFI_DHCP6_IA_TYPE_TA  4
 | 
			
		||||
 | 
			
		||||
#pragma pack(1)
 | 
			
		||||
///
 | 
			
		||||
/// EFI_DHCP6_PACKET_OPTION
 | 
			
		||||
/// defines the format of the DHCPv6 option, See RFC 3315 for more information.
 | 
			
		||||
/// This data structure is used to reference option data that is packed in the DHCPv6 packet.
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// The DHCPv6 option code, stored in network order.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT16    OpCode;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Length of the DHCPv6 option data, stored in network order.
 | 
			
		||||
  /// From the first byte to the last byte of the Data field.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT16    OpLen;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The data for the DHCPv6 option, stored in network order.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT8     Data[1];
 | 
			
		||||
} EFI_DHCP6_PACKET_OPTION;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_DHCP6_HEADER
 | 
			
		||||
/// defines the format of the DHCPv6 header. See RFC 3315 for more information.
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// The DHCPv6 transaction ID.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32    MessageType   : 8;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The DHCPv6 message type.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32    TransactionId : 24;
 | 
			
		||||
} EFI_DHCP6_HEADER;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_DHCP6_PACKET
 | 
			
		||||
/// defines the format of the DHCPv6 packet. See RFC 3315 for more information.
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// Size of the EFI_DHCP6_PACKET buffer.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32    Size;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Length of the EFI_DHCP6_PACKET from the first byte of the Header field to the last
 | 
			
		||||
  /// byte of the Option[] field.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32    Length;
 | 
			
		||||
  struct {
 | 
			
		||||
    ///
 | 
			
		||||
    /// The DHCPv6 packet header.
 | 
			
		||||
    ///
 | 
			
		||||
    EFI_DHCP6_HEADER    Header;
 | 
			
		||||
    ///
 | 
			
		||||
    /// Start of the DHCPv6 packed option data.
 | 
			
		||||
    ///
 | 
			
		||||
    UINT8               Option[1];
 | 
			
		||||
  } Dhcp6;
 | 
			
		||||
} EFI_DHCP6_PACKET;
 | 
			
		||||
 | 
			
		||||
#pragma pack()
 | 
			
		||||
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// Length of DUID in octects.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT16    Length;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Array of DUID octects.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT8     Duid[1];
 | 
			
		||||
} EFI_DHCP6_DUID;
 | 
			
		||||
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// Initial retransmission timeout.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32    Irt;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Maximum retransmission count for one packet. If Mrc is zero, there's no upper limit
 | 
			
		||||
  /// for retransmission count.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32    Mrc;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Maximum retransmission timeout for each retry. It's the upper bound of the number of
 | 
			
		||||
  /// retransmission timeout. If Mrt is zero, there is no upper limit for retransmission
 | 
			
		||||
  /// timeout.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32    Mrt;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Maximum retransmission duration for one packet. It's the upper bound of the numbers
 | 
			
		||||
  /// the client may retransmit a message. If Mrd is zero, there's no upper limit for
 | 
			
		||||
  /// retransmission duration.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32    Mrd;
 | 
			
		||||
} EFI_DHCP6_RETRANSMISSION;
 | 
			
		||||
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// The IPv6 address.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_IPv6_ADDRESS    IpAddress;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The preferred lifetime in unit of seconds for the IPv6 address.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32              PreferredLifetime;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The valid lifetime in unit of seconds for the IPv6 address.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32              ValidLifetime;
 | 
			
		||||
} EFI_DHCP6_IA_ADDRESS;
 | 
			
		||||
 | 
			
		||||
typedef struct {
 | 
			
		||||
  UINT16    Type;                    ///< Type for an IA.
 | 
			
		||||
  UINT32    IaId;                    ///< The identifier for an IA.
 | 
			
		||||
} EFI_DHCP6_IA_DESCRIPTOR;
 | 
			
		||||
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// The descriptor for IA.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_DHCP6_IA_DESCRIPTOR    Descriptor;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The state of the configured IA.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_DHCP6_STATE            State;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Pointer to the cached latest Reply packet. May be NULL if no packet is cached.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_DHCP6_PACKET           *ReplyPacket;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Number of IPv6 addresses of the configured IA.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32                     IaAddressCount;
 | 
			
		||||
  ///
 | 
			
		||||
  /// List of the IPv6 addresses of the configured IA. When the state of the configured IA is
 | 
			
		||||
  /// in Dhcp6Bound, Dhcp6Renewing and Dhcp6Rebinding, the IPv6 addresses are usable.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_DHCP6_IA_ADDRESS       IaAddress[1];
 | 
			
		||||
} EFI_DHCP6_IA;
 | 
			
		||||
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// Pointer to the DHCPv6 unique identifier. The caller is responsible for freeing this buffer.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_DHCP6_DUID    *ClientId;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Pointer to the configured IA of current instance. The caller can free this buffer after
 | 
			
		||||
  /// using it.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_DHCP6_IA      *Ia;
 | 
			
		||||
} EFI_DHCP6_MODE_DATA;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  EFI_DHCP6_CALLBACK is provided by the consumer of the EFI DHCPv6 Protocol instance to
 | 
			
		||||
  intercept events that occurs in the DHCPv6 S.A.R.R process.
 | 
			
		||||
 | 
			
		||||
  @param[in]  This              Pointer to the EFI_DHCP6_PROTOCOL instance that is used to configure this
 | 
			
		||||
                                callback function.
 | 
			
		||||
  @param[in]  Context           Pointer to the context that is initialized by EFI_DHCP6_PROTOCOL.Configure().
 | 
			
		||||
  @param[in]  CurrentState      The current state of the configured IA.
 | 
			
		||||
  @param[in]  Dhcp6Event        The event that occurs in the current state, which usually means a state transition.
 | 
			
		||||
  @param[in]  Packet            Pointer to the DHCPv6 packet that is about to be sent or has been received.
 | 
			
		||||
                                The EFI DHCPv6 Protocol instance is responsible for freeing the buffer.
 | 
			
		||||
  @param[out] NewPacket         Pointer to the new DHCPv6 packet to overwrite the Packet. NewPacket can not
 | 
			
		||||
                                share the buffer with Packet. If *NewPacket is not NULL, the EFI DHCPv6
 | 
			
		||||
                                Protocol instance is responsible for freeing the buffer.
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS           Tell the EFI DHCPv6 Protocol instance to continue the DHCPv6 S.A.R.R process.
 | 
			
		||||
  @retval EFI_ABORTED           Tell the EFI DHCPv6 Protocol instance to abort the DHCPv6 S.A.R.R process,
 | 
			
		||||
                                and the state of the configured IA will be transferred to Dhcp6Init.
 | 
			
		||||
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_DHCP6_CALLBACK)(
 | 
			
		||||
  IN EFI_DHCP6_PROTOCOL        *This,
 | 
			
		||||
  IN VOID                      *Context,
 | 
			
		||||
  IN EFI_DHCP6_STATE           CurrentState,
 | 
			
		||||
  IN EFI_DHCP6_EVENT           Dhcp6Event,
 | 
			
		||||
  IN EFI_DHCP6_PACKET          *Packet,
 | 
			
		||||
  OUT EFI_DHCP6_PACKET         **NewPacket OPTIONAL
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// The callback function is to intercept various events that occur in the DHCPv6 S.A.R.R
 | 
			
		||||
  /// process. Set to NULL to ignore all those events.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_DHCP6_CALLBACK          Dhcp6Callback;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Pointer to the context that will be passed to Dhcp6Callback.
 | 
			
		||||
  ///
 | 
			
		||||
  VOID                        *CallbackContext;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Number of the DHCPv6 options in the OptionList.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32                      OptionCount;
 | 
			
		||||
  ///
 | 
			
		||||
  /// List of the DHCPv6 options to be included in Solicit and Request packet. The buffer
 | 
			
		||||
  /// can be freed after EFI_DHCP6_PROTOCOL.Configure() returns. Ignored if
 | 
			
		||||
  /// OptionCount is zero. OptionList should not contain Client Identifier option
 | 
			
		||||
  /// and any IA option, which will be appended by EFI DHCPv6 Protocol instance
 | 
			
		||||
  /// automatically.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_DHCP6_PACKET_OPTION     **OptionList;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The descriptor for the IA of the EFI DHCPv6 Protocol instance.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_DHCP6_IA_DESCRIPTOR     IaDescriptor;
 | 
			
		||||
  ///
 | 
			
		||||
  /// If not NULL, the event will be signaled when any IPv6 address information of the
 | 
			
		||||
  /// configured IA is updated, including IPv6 address, preferred lifetime and valid
 | 
			
		||||
  /// lifetime, or the DHCPv6 S.A.R.R process fails. Otherwise, Start(),
 | 
			
		||||
  /// renewrebind(), decline(), release() and stop() will be blocking
 | 
			
		||||
  /// operations, and they will wait for the exchange process completion or failure.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_EVENT                   IaInfoEvent;
 | 
			
		||||
  ///
 | 
			
		||||
  /// If TRUE, the EFI DHCPv6 Protocol instance is willing to accept Reconfigure packet.
 | 
			
		||||
  /// Otherwise, it will ignore it. Reconfigure Accept option can not be specified through
 | 
			
		||||
  /// OptionList parameter.
 | 
			
		||||
  ///
 | 
			
		||||
  BOOLEAN                     ReconfigureAccept;
 | 
			
		||||
  ///
 | 
			
		||||
  /// If TRUE, the EFI DHCPv6 Protocol instance will send Solicit packet with Rapid
 | 
			
		||||
  /// Commit option. Otherwise, Rapid Commit option will not be included in Solicit
 | 
			
		||||
  /// packet. Rapid Commit option can not be specified through OptionList parameter.
 | 
			
		||||
  ///
 | 
			
		||||
  BOOLEAN                     RapidCommit;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Parameter to control Solicit packet retransmission behavior. The
 | 
			
		||||
  /// buffer can be freed after EFI_DHCP6_PROTOCOL.Configure() returns.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_DHCP6_RETRANSMISSION    *SolicitRetransmission;
 | 
			
		||||
} EFI_DHCP6_CONFIG_DATA;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  EFI_DHCP6_INFO_CALLBACK is provided by the consumer of the EFI DHCPv6 Protocol
 | 
			
		||||
  instance to intercept events that occurs in the DHCPv6 Information Request exchange process.
 | 
			
		||||
 | 
			
		||||
  @param[in]  This              Pointer to the EFI_DHCP6_PROTOCOL instance that is used to configure this
 | 
			
		||||
                                callback function.
 | 
			
		||||
  @param[in]  Context           Pointer to the context that is initialized in the EFI_DHCP6_PROTOCOL.InfoRequest().
 | 
			
		||||
  @param[in]  Packet            Pointer to Reply packet that has been received. The EFI DHCPv6 Protocol instance is
 | 
			
		||||
                                responsible for freeing the buffer.
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS           Tell the EFI DHCPv6 Protocol instance to finish Information Request exchange process.
 | 
			
		||||
  @retval EFI_NOT_READY         Tell the EFI DHCPv6 Protocol instance to continue Information Request exchange process.
 | 
			
		||||
  @retval EFI_ABORTED           Tell the EFI DHCPv6 Protocol instance to abort the Information Request exchange process.
 | 
			
		||||
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_DHCP6_INFO_CALLBACK)(
 | 
			
		||||
  IN EFI_DHCP6_PROTOCOL        *This,
 | 
			
		||||
  IN VOID                      *Context,
 | 
			
		||||
  IN EFI_DHCP6_PACKET          *Packet
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Retrieve the current operating mode data and configuration data for the EFI DHCPv6 Protocol instance.
 | 
			
		||||
 | 
			
		||||
  @param[in]  This              Pointer to the EFI_DHCP6_PROTOCOL instance.
 | 
			
		||||
  @param[out] Dhcp6ModeData     Pointer to the DHCPv6 mode data structure. The caller is responsible for freeing this
 | 
			
		||||
                                structure and each reference buffer.
 | 
			
		||||
  @param[out] Dhcp6ConfigData   Pointer to the DHCPv6 configuration data structure. The caller is responsible for
 | 
			
		||||
                                freeing this structure and each reference buffer.
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS           The mode data was returned.
 | 
			
		||||
  @retval EFI_ACCESS_DENIED     The EFI DHCPv6 Protocol instance has not been configured when Dhcp6ConfigData is not NULL.
 | 
			
		||||
  @retval EFI_INVALID_PARAMETER One or more following conditions are TRUE:
 | 
			
		||||
                                - This is NULL.
 | 
			
		||||
                                - Both Dhcp6ConfigData and Dhcp6ModeData are NULL.
 | 
			
		||||
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_DHCP6_GET_MODE_DATA)(
 | 
			
		||||
  IN EFI_DHCP6_PROTOCOL        *This,
 | 
			
		||||
  OUT EFI_DHCP6_MODE_DATA      *Dhcp6ModeData OPTIONAL,
 | 
			
		||||
  OUT EFI_DHCP6_CONFIG_DATA    *Dhcp6ConfigData OPTIONAL
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Initialize or clean up the configuration data for the EFI DHCPv6 Protocol instance.
 | 
			
		||||
 | 
			
		||||
  The Configure() function is used to initialize or clean up the configuration data of the EFI
 | 
			
		||||
  DHCPv6 Protocol instance.
 | 
			
		||||
  - When Dhcp6CfgData is not NULL and Configure() is called successfully, the
 | 
			
		||||
    configuration data will be initialized in the EFI DHCPv6 Protocol instance and the state of the
 | 
			
		||||
    configured IA will be transferred into Dhcp6Init.
 | 
			
		||||
  - When Dhcp6CfgData is NULL and Configure() is called successfully, the configuration
 | 
			
		||||
    data will be cleaned up and no IA will be associated with the EFI DHCPv6 Protocol instance.
 | 
			
		||||
 | 
			
		||||
  To update the configuration data for an EFI DCHPv6 Protocol instance, the original data must be
 | 
			
		||||
  cleaned up before setting the new configuration data.
 | 
			
		||||
 | 
			
		||||
  @param[in]  This              Pointer to the EFI_DHCP6_PROTOCOL instance.
 | 
			
		||||
  @param[in]  Dhcp6CfgData      Pointer to the DHCPv6 configuration data structure.
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS           The mode data was returned.
 | 
			
		||||
  @retval EFI_INVALID_PARAMETER One or more following conditions are TRUE
 | 
			
		||||
                                - This is NULL.
 | 
			
		||||
                                - OptionCount > 0 and OptionList is NULL.
 | 
			
		||||
                                - OptionList is not NULL, and Client Id option, Reconfigure Accept option,
 | 
			
		||||
                                  Rapid Commit option or any IA option is specified in the OptionList.
 | 
			
		||||
                                - IaDescriptor.Type is neither EFI_DHCP6_IA_TYPE_NA nor EFI_DHCP6_IA_TYPE_NA.
 | 
			
		||||
                                - IaDescriptor is not unique.
 | 
			
		||||
                                - Both IaInfoEvent and SolicitRetransimssion are NULL.
 | 
			
		||||
                                - SolicitRetransmission is not NULL, and both SolicitRetransimssion->Mrc and
 | 
			
		||||
                                  SolicitRetransmission->Mrd are zero.
 | 
			
		||||
  @retval EFI_ACCESS_DENIED     The EFI DHCPv6 Protocol instance has been already configured
 | 
			
		||||
                                when Dhcp6CfgData is not NULL.
 | 
			
		||||
                                The EFI DHCPv6 Protocol instance has already started the
 | 
			
		||||
                                DHCPv6 S.A.R.R when Dhcp6CfgData is NULL.
 | 
			
		||||
  @retval EFI_OUT_OF_RESOURCES  Required system resources could not be allocated.
 | 
			
		||||
  @retval EFI_DEVICE_ERROR      An unexpected system or network error occurred.
 | 
			
		||||
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_DHCP6_CONFIGURE)(
 | 
			
		||||
  IN EFI_DHCP6_PROTOCOL        *This,
 | 
			
		||||
  IN EFI_DHCP6_CONFIG_DATA     *Dhcp6CfgData OPTIONAL
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Start the DHCPv6 S.A.R.R process.
 | 
			
		||||
 | 
			
		||||
  The Start() function starts the DHCPv6 S.A.R.R process. This function can be called only when
 | 
			
		||||
  the state of the configured IA is in the Dhcp6Init state. If the DHCPv6 S.A.R.R process completes
 | 
			
		||||
  successfully, the state of the configured IA will be transferred through Dhcp6Selecting and
 | 
			
		||||
  Dhcp6Requesting to Dhcp6Bound state. The update of the IPv6 addresses will be notified through
 | 
			
		||||
  EFI_DHCP6_CONFIG_DATA.IaInfoEvent. At the time when each event occurs in this process, the
 | 
			
		||||
  callback function set by EFI_DHCP6_PROTOCOL.Configure() will be called and the user can take
 | 
			
		||||
  this opportunity to control the process. If EFI_DHCP6_CONFIG_DATA.IaInfoEvent is NULL, the
 | 
			
		||||
  Start() function call is a blocking operation. It will return after the DHCPv6 S.A.R.R process
 | 
			
		||||
  completes or aborted by users. If the process is aborted by system or network error, the state of
 | 
			
		||||
  the configured IA will be transferred to Dhcp6Init. The Start() function can be called again to
 | 
			
		||||
  restart the process.
 | 
			
		||||
 | 
			
		||||
  @param[in]  This              Pointer to the EFI_DHCP6_PROTOCOL instance.
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS           The DHCPv6 S.A.R.R process is completed and at least one IPv6
 | 
			
		||||
                                address has been bound to the configured IA when
 | 
			
		||||
                                EFI_DHCP6_CONFIG_DATA.IaInfoEvent is NULL.
 | 
			
		||||
                                The DHCPv6 S.A.R.R process is started when
 | 
			
		||||
                                EFI_DHCP6_CONFIG_DATA.IaInfoEvent is not NULL.
 | 
			
		||||
  @retval EFI_ACCESS_DENIED     The EFI DHCPv6 Child instance hasn't been configured.
 | 
			
		||||
  @retval EFI_INVALID_PARAMETER This is NULL.
 | 
			
		||||
  @retval EFI_OUT_OF_RESOURCES  Required system resources could not be allocated.
 | 
			
		||||
  @retval EFI_ALREADY_STARTED   The DHCPv6 S.A.R.R process has already started.
 | 
			
		||||
  @retval EFI_DEVICE_ERROR      An unexpected network or system error occurred.
 | 
			
		||||
  @retval EFI_NO_RESPONSE       The DHCPv6 S.A.R.R process failed because of no response.
 | 
			
		||||
  @retval EFI_NO_MAPPING        No IPv6 address has been bound to the configured IA after the
 | 
			
		||||
                                DHCPv6 S.A.R.R process.
 | 
			
		||||
  @retval EFI_ABORTED           The DHCPv6 S.A.R.R process aborted by user.
 | 
			
		||||
  @retval EFI_NO_MEDIA          There was a media error.
 | 
			
		||||
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_DHCP6_START)(
 | 
			
		||||
  IN EFI_DHCP6_PROTOCOL        *This
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Request configuration information without the assignment of any IA addresses of the client.
 | 
			
		||||
 | 
			
		||||
  The InfoRequest() function is used to request configuration information without the assignment
 | 
			
		||||
  of any IPv6 address of the client. Client sends out Information Request packet to obtain
 | 
			
		||||
  the required configuration information, and DHCPv6 server responds with Reply packet containing
 | 
			
		||||
  the information for the client. The received Reply packet will be passed to the user by
 | 
			
		||||
  ReplyCallback function. If user returns EFI_NOT_READY from ReplyCallback, the EFI DHCPv6
 | 
			
		||||
  Protocol instance will continue to receive other Reply packets unless timeout according to
 | 
			
		||||
  the Retransmission parameter. Otherwise, the Information Request exchange process will be
 | 
			
		||||
  finished successfully if user returns EFI_SUCCESS from ReplyCallback.
 | 
			
		||||
 | 
			
		||||
  @param[in]  This              Pointer to the EFI_DHCP6_PROTOCOL instance.
 | 
			
		||||
  @param[in]  SendClientId      If TRUE, the EFI DHCPv6 Protocol instance will build Client
 | 
			
		||||
                                Identifier option and include it into Information Request
 | 
			
		||||
                                packet. If FALSE, Client Identifier option will not be included.
 | 
			
		||||
                                Client Identifier option can not be specified through OptionList
 | 
			
		||||
                                parameter.
 | 
			
		||||
  @param[in]  OptionRequest     Pointer to the Option Request option in the Information Request
 | 
			
		||||
                                packet. Option Request option can not be specified through
 | 
			
		||||
                                OptionList parameter.
 | 
			
		||||
  @param[in]  OptionCount       Number of options in OptionList.
 | 
			
		||||
  @param[in]  OptionList        List of other DHCPv6 options. These options will be appended
 | 
			
		||||
                                to the Option Request option. The caller is responsible for
 | 
			
		||||
                                freeing this buffer. Type is defined in EFI_DHCP6_PROTOCOL.GetModeData().
 | 
			
		||||
  @param[in]  Retransmission    Parameter to control Information Request packet retransmission
 | 
			
		||||
                                behavior. The buffer can be freed after EFI_DHCP6_PROTOCOL.InfoRequest()
 | 
			
		||||
                                returns.
 | 
			
		||||
  @param[in]  TimeoutEvent      If not NULL, this event is signaled when the information request
 | 
			
		||||
                                exchange aborted because of no response. If NULL, the function
 | 
			
		||||
                                call is a blocking operation; and it will return after the
 | 
			
		||||
                                information-request exchange process finish or aborted by users.
 | 
			
		||||
  @param[in]  ReplyCallback     The callback function is to intercept various events that occur
 | 
			
		||||
                                in the Information Request exchange process. It should not be
 | 
			
		||||
                                set to NULL.
 | 
			
		||||
  @param[in]  CallbackContext   Pointer to the context that will be passed to ReplyCallback.
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS           The DHCPv6 S.A.R.R process is completed and at least one IPv6
 | 
			
		||||
  @retval EFI_SUCCESS           The DHCPv6 information request exchange process completed
 | 
			
		||||
                                when TimeoutEvent is NULL. Information Request packet has been
 | 
			
		||||
                                sent to DHCPv6 server when TimeoutEvent is not NULL.
 | 
			
		||||
  @retval EFI_INVALID_PARAMETER One or more following conditions are TRUE:
 | 
			
		||||
                                - This is NULL.
 | 
			
		||||
                                - OptionRequest is NULL or OptionRequest->OpCode is invalid.
 | 
			
		||||
                                - OptionCount > 0 and OptionList is NULL.
 | 
			
		||||
                                - OptionList is not NULL, and Client Identify option or
 | 
			
		||||
                                  Option Request option is specified in the OptionList.
 | 
			
		||||
                                - Retransimssion is NULL.
 | 
			
		||||
                                - Both Retransimssion->Mrc and Retransmission->Mrd are zero.
 | 
			
		||||
                                - ReplyCallback is NULL.
 | 
			
		||||
  @retval EFI_DEVICE_ERROR      An unexpected network or system error occurred.
 | 
			
		||||
  @retval EFI_NO_RESPONSE       The DHCPv6 information request exchange process failed
 | 
			
		||||
                                because of no response, or not all requested-options are
 | 
			
		||||
                                responded by DHCPv6 servers when Timeout happened.
 | 
			
		||||
  @retval EFI_ABORTED           The DHCPv6 information request exchange process aborted by user.
 | 
			
		||||
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_DHCP6_INFO_REQUEST)(
 | 
			
		||||
  IN EFI_DHCP6_PROTOCOL        *This,
 | 
			
		||||
  IN BOOLEAN                   SendClientId,
 | 
			
		||||
  IN EFI_DHCP6_PACKET_OPTION   *OptionRequest,
 | 
			
		||||
  IN UINT32                    OptionCount,
 | 
			
		||||
  IN EFI_DHCP6_PACKET_OPTION   *OptionList[] OPTIONAL,
 | 
			
		||||
  IN EFI_DHCP6_RETRANSMISSION  *Retransmission,
 | 
			
		||||
  IN EFI_EVENT                 TimeoutEvent OPTIONAL,
 | 
			
		||||
  IN EFI_DHCP6_INFO_CALLBACK   ReplyCallback,
 | 
			
		||||
  IN VOID                      *CallbackContext OPTIONAL
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Manually extend the valid and preferred lifetimes for the IPv6 addresses of the configured
 | 
			
		||||
  IA and update other configuration parameters by sending Renew or Rebind packet.
 | 
			
		||||
 | 
			
		||||
  The RenewRebind() function is used to manually extend the valid and preferred lifetimes for the
 | 
			
		||||
  IPv6 addresses of the configured IA and update other configuration parameters by sending Renew or
 | 
			
		||||
  Rebind packet.
 | 
			
		||||
  - When RebindRequest is FALSE and the state of the configured IA is Dhcp6Bound, it
 | 
			
		||||
  will send Renew packet to the previously DHCPv6 server and transfer the state of the configured
 | 
			
		||||
  IA to Dhcp6Renewing. If valid Reply packet received, the state transfers to Dhcp6Bound
 | 
			
		||||
  and the valid and preferred timer restarts. If fails, the state transfers to Dhcp6Bound but the
 | 
			
		||||
  timer continues.
 | 
			
		||||
  - When RebindRequest is TRUE and the state of the configured IA is Dhcp6Bound, it will
 | 
			
		||||
  send Rebind packet. If valid Reply packet received, the state transfers to Dhcp6Bound and the
 | 
			
		||||
  valid and preferred timer restarts. If fails, the state transfers to Dhcp6Init and the IA can't
 | 
			
		||||
  be used.
 | 
			
		||||
 | 
			
		||||
  @param[in]  This              Pointer to the EFI_DHCP4_PROTOCOL instance.
 | 
			
		||||
  @param[in]  RebindRequest     If TRUE, it will send Rebind packet and enter the Dhcp6Rebinding state.
 | 
			
		||||
                                Otherwise, it will send Renew packet and enter the Dhcp6Renewing state.
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS           The DHCPv6 renew/rebind exchange process has completed and at
 | 
			
		||||
                                least one IPv6 address of the configured IA has been bound again
 | 
			
		||||
                                when EFI_DHCP6_CONFIG_DATA.IaInfoEvent is NULL.
 | 
			
		||||
                                The EFI DHCPv6 Protocol instance has sent Renew or Rebind packet
 | 
			
		||||
                                when EFI_DHCP6_CONFIG_DATA.IaInfoEvent is not NULL.
 | 
			
		||||
  @retval EFI_ACCESS_DENIED     The EFI DHCPv6 Child instance hasn't been configured, or the state
 | 
			
		||||
                                of the configured IA is not in Dhcp6Bound.
 | 
			
		||||
  @retval EFI_ALREADY_STARTED   The state of the configured IA has already entered Dhcp6Renewing
 | 
			
		||||
                                when RebindRequest is FALSE.
 | 
			
		||||
                                The state of the configured IA has already entered Dhcp6Rebinding
 | 
			
		||||
                                when RebindRequest is TRUE.
 | 
			
		||||
  @retval EFI_INVALID_PARAMETER This is NULL.
 | 
			
		||||
  @retval EFI_DEVICE_ERROR      An unexpected system or system error occurred.
 | 
			
		||||
  @retval EFI_NO_RESPONSE       The DHCPv6 renew/rebind exchange process failed because of no response.
 | 
			
		||||
  @retval EFI_NO_MAPPING        No IPv6 address has been bound to the configured IA after the DHCPv6
 | 
			
		||||
                                renew/rebind exchange process.
 | 
			
		||||
  @retval EFI_ABORTED           The DHCPv6 renew/rebind exchange process aborted by user.
 | 
			
		||||
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_DHCP6_RENEW_REBIND)(
 | 
			
		||||
  IN EFI_DHCP6_PROTOCOL        *This,
 | 
			
		||||
  IN BOOLEAN                   RebindRequest
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Inform that one or more IPv6 addresses assigned by a server are already in use by
 | 
			
		||||
  another node.
 | 
			
		||||
 | 
			
		||||
  The Decline() function is used to manually decline the assignment of IPv6 addresses, which
 | 
			
		||||
  have been already used by another node. If all IPv6 addresses of the configured IA are declined
 | 
			
		||||
  through this function, the state of the IA will switch through Dhcp6Declining to Dhcp6Init,
 | 
			
		||||
  otherwise, the state of the IA will restore to Dhcp6Bound after the declining process. The
 | 
			
		||||
  Decline() can only be called when the IA is in Dhcp6Bound state. If the
 | 
			
		||||
  EFI_DHCP6_CONFIG_DATA.IaInfoEvent is NULL, this function is a blocking operation. It
 | 
			
		||||
  will return after the declining process finishes, or aborted by user.
 | 
			
		||||
 | 
			
		||||
  @param[in]  This              Pointer to the EFI_DHCP4_PROTOCOL instance.
 | 
			
		||||
  @param[in]  AddressCount      Number of declining IPv6 addresses.
 | 
			
		||||
  @param[in]  Addresses         Pointer to the buffer stored all the declining IPv6 addresses.
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS           The DHCPv6 decline exchange process has completed when
 | 
			
		||||
                                EFI_DHCP6_CONFIG_DATA.IaInfoEvent is NULL.
 | 
			
		||||
                                The EFI DHCPv6 Protocol instance has sent Decline packet when
 | 
			
		||||
                                EFI_DHCP6_CONFIG_DATA.IaInfoEvent is not NULL.
 | 
			
		||||
  @retval EFI_INVALID_PARAMETER One or more following conditions are TRUE
 | 
			
		||||
                                - This is NULL.
 | 
			
		||||
                                - AddressCount is zero or Addresses is NULL.
 | 
			
		||||
  @retval EFI_NOT_FOUND         Any specified IPv6 address is not correlated with the configured IA
 | 
			
		||||
                                for this instance.
 | 
			
		||||
  @retval EFI_ACCESS_DENIED     The EFI DHCPv6 Child instance hasn't been configured, or the
 | 
			
		||||
                                state of the configured IA is not in Dhcp6Bound.
 | 
			
		||||
  @retval EFI_DEVICE_ERROR      An unexpected network or system error occurred.
 | 
			
		||||
  @retval EFI_ABORTED           The DHCPv6 decline exchange process aborted by user.
 | 
			
		||||
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_DHCP6_DECLINE)(
 | 
			
		||||
  IN EFI_DHCP6_PROTOCOL        *This,
 | 
			
		||||
  IN UINT32                    AddressCount,
 | 
			
		||||
  IN EFI_IPv6_ADDRESS          *Addresses
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Release one or more IPv6 addresses associated with the configured IA for current instance.
 | 
			
		||||
 | 
			
		||||
  The Release() function is used to manually release the one or more IPv6 address. If AddressCount
 | 
			
		||||
  is zero, it will release all IPv6 addresses of the configured IA. If all IPv6 addresses of the IA
 | 
			
		||||
  are released through this function, the state of the IA will switch through Dhcp6Releasing to
 | 
			
		||||
  Dhcp6Init, otherwise, the state of the IA will restore to Dhcp6Bound after the releasing process.
 | 
			
		||||
  The Release() can only be called when the IA is in Dhcp6Bound state. If the
 | 
			
		||||
  EFI_DHCP6_CONFIG_DATA.IaInfoEvent is NULL, the function is a blocking operation. It will return
 | 
			
		||||
  after the releasing process finishes, or aborted by user.
 | 
			
		||||
 | 
			
		||||
  @param[in]  This              Pointer to the EFI_DHCP6_PROTOCOL instance.
 | 
			
		||||
  @param[in]  AddressCount      Number of releasing IPv6 addresses.
 | 
			
		||||
  @param[in]  Addresses         Pointer to the buffer stored all the releasing IPv6 addresses.
 | 
			
		||||
                                Ignored if AddressCount is zero.
 | 
			
		||||
  @retval EFI_SUCCESS           The DHCPv6 release exchange process has completed when
 | 
			
		||||
                                EFI_DHCP6_CONFIG_DATA.IaInfoEvent is NULL.
 | 
			
		||||
                                The EFI DHCPv6 Protocol instance has sent Release packet when
 | 
			
		||||
                                EFI_DHCP6_CONFIG_DATA.IaInfoEvent is not NULL.
 | 
			
		||||
  @retval EFI_INVALID_PARAMETER One or more following conditions are TRUE
 | 
			
		||||
                                - This is NULL.
 | 
			
		||||
                                - AddressCount is not zero or Addresses is NULL.
 | 
			
		||||
  @retval EFI_NOT_FOUND         Any specified IPv6 address is not correlated with the configured
 | 
			
		||||
                                IA for this instance.
 | 
			
		||||
  @retval EFI_ACCESS_DENIED     The EFI DHCPv6 Child instance hasn't been configured, or the
 | 
			
		||||
                                state of the configured IA is not in Dhcp6Bound.
 | 
			
		||||
  @retval EFI_DEVICE_ERROR      An unexpected network or system error occurred.
 | 
			
		||||
  @retval EFI_ABORTED           The DHCPv6 release exchange process aborted by user.
 | 
			
		||||
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_DHCP6_RELEASE)(
 | 
			
		||||
  IN EFI_DHCP6_PROTOCOL        *This,
 | 
			
		||||
  IN UINT32                    AddressCount,
 | 
			
		||||
  IN EFI_IPv6_ADDRESS          *Addresses
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Stop the DHCPv6 S.A.R.R process.
 | 
			
		||||
 | 
			
		||||
  The Stop() function is used to stop the DHCPv6 S.A.R.R process. If this function is called
 | 
			
		||||
  successfully, all the IPv6 addresses of the configured IA will be released and the state of
 | 
			
		||||
  the configured IA will be transferred to Dhcp6Init.
 | 
			
		||||
 | 
			
		||||
  @param[in]  This              Pointer to the EFI_DHCP6_PROTOCOL instance.
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS           The DHCPv6 S.A.R.R process has been stopped when
 | 
			
		||||
                                EFI_DHCP6_CONFIG_DATA.IaInfoEvent is NULL.
 | 
			
		||||
                                The EFI DHCPv6 Protocol instance has sent Release packet if
 | 
			
		||||
                                need release or has been stopped if needn't, when
 | 
			
		||||
                                EFI_DHCP6_CONFIG_DATA.IaInfoEvent is not NULL.
 | 
			
		||||
  @retval EFI_INVALID_PARAMETER This is NULL.
 | 
			
		||||
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_DHCP6_STOP)(
 | 
			
		||||
  IN EFI_DHCP6_PROTOCOL        *This
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Parse the option data in the DHCPv6 packet.
 | 
			
		||||
 | 
			
		||||
  The Parse() function is used to retrieve the option list in the DHCPv6 packet.
 | 
			
		||||
 | 
			
		||||
  @param[in]  This              Pointer to the EFI_DHCP6_PROTOCOL instance.
 | 
			
		||||
 | 
			
		||||
  @param[in]  Packet            Pointer to packet to be parsed.
 | 
			
		||||
  @param[in]  OptionCount       On input, the number of entries in the PacketOptionList.
 | 
			
		||||
                                On output, the number of DHCPv6 options in the Packet.
 | 
			
		||||
  @param[in]  PacketOptionList  List of pointers to the DHCPv6 options in the Packet.
 | 
			
		||||
                                The OpCode and OpLen in EFI_DHCP6_PACKET_OPTION are
 | 
			
		||||
                                both stored in network byte order.
 | 
			
		||||
  @retval EFI_SUCCESS           The packet was successfully parsed.
 | 
			
		||||
  @retval EFI_INVALID_PARAMETER One or more following conditions are TRUE
 | 
			
		||||
                                - This is NULL.
 | 
			
		||||
                                - Packet is NULL.
 | 
			
		||||
                                - Packet is not a well-formed DHCPv6 packet.
 | 
			
		||||
                                - OptionCount is NULL.
 | 
			
		||||
                                - *OptionCount is not zero and PacketOptionList is NULL.
 | 
			
		||||
  @retval EFI_BUFFER_TOO_SMALL  *OptionCount is smaller than the number of options that were
 | 
			
		||||
                                found in the Packet.
 | 
			
		||||
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_DHCP6_PARSE)(
 | 
			
		||||
  IN EFI_DHCP6_PROTOCOL        *This,
 | 
			
		||||
  IN EFI_DHCP6_PACKET          *Packet,
 | 
			
		||||
  IN OUT UINT32                *OptionCount,
 | 
			
		||||
  OUT EFI_DHCP6_PACKET_OPTION  *PacketOptionList[] OPTIONAL
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// The EFI DHCPv6 Protocol is used to get IPv6 addresses and other configuration parameters
 | 
			
		||||
/// from DHCPv6 servers.
 | 
			
		||||
///
 | 
			
		||||
struct _EFI_DHCP6_PROTOCOL {
 | 
			
		||||
  EFI_DHCP6_GET_MODE_DATA    GetModeData;
 | 
			
		||||
  EFI_DHCP6_CONFIGURE        Configure;
 | 
			
		||||
  EFI_DHCP6_START            Start;
 | 
			
		||||
  EFI_DHCP6_INFO_REQUEST     InfoRequest;
 | 
			
		||||
  EFI_DHCP6_RENEW_REBIND     RenewRebind;
 | 
			
		||||
  EFI_DHCP6_DECLINE          Decline;
 | 
			
		||||
  EFI_DHCP6_RELEASE          Release;
 | 
			
		||||
  EFI_DHCP6_STOP             Stop;
 | 
			
		||||
  EFI_DHCP6_PARSE            Parse;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
extern EFI_GUID  gEfiDhcp6ProtocolGuid;
 | 
			
		||||
extern EFI_GUID  gEfiDhcp6ServiceBindingProtocolGuid;
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										538
									
								
								src/include/ipxe/efi/Protocol/Dns4.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										538
									
								
								src/include/ipxe/efi/Protocol/Dns4.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,538 @@
 | 
			
		||||
/** @file
 | 
			
		||||
  This file defines the EFI Domain Name Service Binding Protocol interface. It is split
 | 
			
		||||
  into the following two main sections:
 | 
			
		||||
  DNSv4 Service Binding Protocol (DNSv4SB)
 | 
			
		||||
  DNSv4 Protocol (DNSv4)
 | 
			
		||||
 | 
			
		||||
  Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>
 | 
			
		||||
  SPDX-License-Identifier: BSD-2-Clause-Patent
 | 
			
		||||
 | 
			
		||||
  @par Revision Reference:
 | 
			
		||||
  This Protocol is introduced in UEFI Specification 2.5
 | 
			
		||||
 | 
			
		||||
**/
 | 
			
		||||
 | 
			
		||||
#ifndef __EFI_DNS4_PROTOCOL_H__
 | 
			
		||||
#define __EFI_DNS4_PROTOCOL_H__
 | 
			
		||||
 | 
			
		||||
FILE_LICENCE ( BSD2_PATENT );
 | 
			
		||||
 | 
			
		||||
#define EFI_DNS4_SERVICE_BINDING_PROTOCOL_GUID \
 | 
			
		||||
  { \
 | 
			
		||||
    0xb625b186, 0xe063, 0x44f7, {0x89, 0x5, 0x6a, 0x74, 0xdc, 0x6f, 0x52, 0xb4 } \
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
#define EFI_DNS4_PROTOCOL_GUID \
 | 
			
		||||
  { \
 | 
			
		||||
    0xae3d28cc, 0xe05b, 0x4fa1, {0xa0, 0x11, 0x7e, 0xb5, 0x5a, 0x3f, 0x14, 0x1 } \
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
typedef struct _EFI_DNS4_PROTOCOL EFI_DNS4_PROTOCOL;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_DNS4_CONFIG_DATA
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// Count of the DNS servers. When used with GetModeData(),
 | 
			
		||||
  /// this field is the count of originally configured servers when
 | 
			
		||||
  /// Configure() was called for this instance. When used with
 | 
			
		||||
  /// Configure() this is the count of caller-supplied servers. If the
 | 
			
		||||
  /// DnsServerListCount is zero, the DNS server configuration
 | 
			
		||||
  /// will be retrieved from DHCP server automatically.
 | 
			
		||||
  ///
 | 
			
		||||
  UINTN    DnsServerListCount;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Pointer to DNS server list containing DnsServerListCount entries or NULL
 | 
			
		||||
  /// if DnsServerListCountis 0. For Configure(), this will be NULL when there are
 | 
			
		||||
  /// no caller supplied server addresses, and, the DNS instance will retrieve
 | 
			
		||||
  /// DNS server from DHCP Server. The provided DNS server list is
 | 
			
		||||
  /// recommended to be filled up in the sequence of preference. When
 | 
			
		||||
  /// used with GetModeData(), the buffer containing the list will
 | 
			
		||||
  /// be allocated by the driver implementing this protocol and must be
 | 
			
		||||
  /// freed by the caller. When used with Configure(), the buffer
 | 
			
		||||
  /// containing the list will be allocated and released by the caller.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_IPv4_ADDRESS    *DnsServerList;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Set to TRUE to use the default IP address/subnet mask and default routing table.
 | 
			
		||||
  ///
 | 
			
		||||
  BOOLEAN             UseDefaultSetting;
 | 
			
		||||
  ///
 | 
			
		||||
  /// If TRUE, enable DNS cache function for this DNS instance. If FALSE, all DNS
 | 
			
		||||
  /// query will not lookup local DNS cache.
 | 
			
		||||
  ///
 | 
			
		||||
  BOOLEAN             EnableDnsCache;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Use the protocol number defined in "Links to UEFI-Related
 | 
			
		||||
  /// Documents"(http://uefi.org/uefi) under the heading "IANA
 | 
			
		||||
  /// Protocol Numbers". Only TCP or UDP are supported, and other
 | 
			
		||||
  /// protocol values are invalid. An implementation can choose to
 | 
			
		||||
  /// support only UDP, or both TCP and UDP.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT8               Protocol;
 | 
			
		||||
  ///
 | 
			
		||||
  /// If UseDefaultSetting is FALSE indicates the station address to use.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_IPv4_ADDRESS    StationIp;
 | 
			
		||||
  ///
 | 
			
		||||
  /// If UseDefaultSetting is FALSE indicates the subnet mask to use.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_IPv4_ADDRESS    SubnetMask;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Local port number. Set to zero to use the automatically assigned port number.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT16              LocalPort;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Retry number if no response received after RetryInterval.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32              RetryCount;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Minimum interval of retry is 2 second. If the retry interval is less than 2
 | 
			
		||||
  /// seconds, then use the 2 seconds.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32              RetryInterval;
 | 
			
		||||
} EFI_DNS4_CONFIG_DATA;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_DNS4_CACHE_ENTRY
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// Host name.
 | 
			
		||||
  ///
 | 
			
		||||
  CHAR16              *HostName;
 | 
			
		||||
  ///
 | 
			
		||||
  /// IP address of this host.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_IPv4_ADDRESS    *IpAddress;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Time in second unit that this entry will remain in DNS cache. A value of zero
 | 
			
		||||
  /// means that this entry is permanent. A nonzero value will override the existing
 | 
			
		||||
  /// one if this entry to be added is dynamic entry. Implementations may set its
 | 
			
		||||
  /// default timeout value for the dynamically created DNS cache entry after one DNS
 | 
			
		||||
  /// resolve succeeds.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32              Timeout;
 | 
			
		||||
} EFI_DNS4_CACHE_ENTRY;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_DNS4_MODE_DATA
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// The configuration data of this instance.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_DNS4_CONFIG_DATA    DnsConfigData;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Number of configured DNS server. Each DNS instance has its own DNS server
 | 
			
		||||
  /// configuration.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32                  DnsServerCount;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Pointer to common list of addresses of all configured DNS server
 | 
			
		||||
  /// used by EFI_DNS4_PROTOCOL instances. List will include
 | 
			
		||||
  /// DNS servers configured by this or any other EFI_DNS4_PROTOCOL instance.
 | 
			
		||||
  /// The storage for this list is allocated by the driver publishing this
 | 
			
		||||
  /// protocol, and must be freed by the caller.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_IPv4_ADDRESS        *DnsServerList;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Number of DNS Cache entries. The DNS Cache is shared among all DNS instances.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32                  DnsCacheCount;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Pointer to a buffer containing DnsCacheCount DNS Cache
 | 
			
		||||
  /// entry structures. The storage for this list is allocated by the driver
 | 
			
		||||
  /// publishing this protocol and must be freed by caller.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_DNS4_CACHE_ENTRY    *DnsCacheList;
 | 
			
		||||
} EFI_DNS4_MODE_DATA;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// DNS_HOST_TO_ADDR_DATA
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// Number of the returned IP addresses.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32              IpCount;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Pointer to the all the returned IP addresses.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_IPv4_ADDRESS    *IpList;
 | 
			
		||||
} DNS_HOST_TO_ADDR_DATA;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// DNS_ADDR_TO_HOST_DATA
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// Pointer to the primary name for this host address. It's the caller's
 | 
			
		||||
  /// responsibility to free the response memory.
 | 
			
		||||
  ///
 | 
			
		||||
  CHAR16    *HostName;
 | 
			
		||||
} DNS_ADDR_TO_HOST_DATA;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// DNS_RESOURCE_RECORD
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// The Owner name.
 | 
			
		||||
  ///
 | 
			
		||||
  CHAR8     *QName;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The Type Code of this RR.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT16    QType;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The CLASS code of this RR.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT16    QClass;
 | 
			
		||||
  ///
 | 
			
		||||
  /// 32 bit integer which specify the time interval that the resource record may be
 | 
			
		||||
  /// cached before the source of the information should again be consulted. Zero means
 | 
			
		||||
  /// this RR can not be cached.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32    TTL;
 | 
			
		||||
  ///
 | 
			
		||||
  /// 16 big integer which specify the length of RData.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT16    DataLength;
 | 
			
		||||
  ///
 | 
			
		||||
  /// A string of octets that describe the resource, the format of this information
 | 
			
		||||
  /// varies according to QType and QClass difference.
 | 
			
		||||
  ///
 | 
			
		||||
  CHAR8     *RData;
 | 
			
		||||
} DNS_RESOURCE_RECORD;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// DNS_GENERAL_LOOKUP_DATA
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// Number of returned matching RRs.
 | 
			
		||||
  ///
 | 
			
		||||
  UINTN                  RRCount;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Pointer to the all the returned matching RRs. It's caller responsibility to free
 | 
			
		||||
  /// the allocated memory to hold the returned RRs.
 | 
			
		||||
  ///
 | 
			
		||||
  DNS_RESOURCE_RECORD    *RRList;
 | 
			
		||||
} DNS_GENERAL_LOOKUP_DATA;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_DNS4_COMPLETION_TOKEN
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// This Event will be signaled after the Status field is updated by the EFI DNS
 | 
			
		||||
  /// protocol driver. The type of Event must be EFI_NOTIFY_SIGNAL.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_EVENT    Event;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Will be set to one of the following values:
 | 
			
		||||
  ///   EFI_SUCCESS:      The host name to address translation completed successfully.
 | 
			
		||||
  ///   EFI_NOT_FOUND:    No matching Resource Record (RR) is found.
 | 
			
		||||
  ///   EFI_TIMEOUT:      No DNS server reachable, or RetryCount was exhausted without
 | 
			
		||||
  ///                     response from all specified DNS servers.
 | 
			
		||||
  ///   EFI_DEVICE_ERROR: An unexpected system or network error occurred.
 | 
			
		||||
  ///   EFI_NO_MEDIA:     There was a media error.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_STATUS    Status;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Retry number if no response received after RetryInterval. If zero, use the
 | 
			
		||||
  /// parameter configured through Dns.Configure() interface.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32        RetryCount;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Minimum interval of retry is 2 second. If the retry interval is less than 2
 | 
			
		||||
  /// seconds, then use the 2 seconds. If zero, use the parameter configured through
 | 
			
		||||
  /// Dns.Configure() interface.
 | 
			
		||||
  UINT32        RetryInterval;
 | 
			
		||||
  ///
 | 
			
		||||
  /// DNSv4 completion token data
 | 
			
		||||
  ///
 | 
			
		||||
  union {
 | 
			
		||||
    ///
 | 
			
		||||
    /// When the Token is used for host name to address translation, H2AData is a pointer
 | 
			
		||||
    /// to the DNS_HOST_TO_ADDR_DATA.
 | 
			
		||||
    ///
 | 
			
		||||
    DNS_HOST_TO_ADDR_DATA      *H2AData;
 | 
			
		||||
    ///
 | 
			
		||||
    /// When the Token is used for host address to host name translation, A2HData is a
 | 
			
		||||
    /// pointer to the DNS_ADDR_TO_HOST_DATA.
 | 
			
		||||
    ///
 | 
			
		||||
    DNS_ADDR_TO_HOST_DATA      *A2HData;
 | 
			
		||||
    ///
 | 
			
		||||
    /// When the Token is used for a general lookup function, GLookupDATA is a pointer to
 | 
			
		||||
    /// the DNS_GENERAL_LOOKUP_DATA.
 | 
			
		||||
    ///
 | 
			
		||||
    DNS_GENERAL_LOOKUP_DATA    *GLookupData;
 | 
			
		||||
  } RspData;
 | 
			
		||||
} EFI_DNS4_COMPLETION_TOKEN;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Retrieve mode data of this DNS instance.
 | 
			
		||||
 | 
			
		||||
  This function is used to retrieve DNS mode data for this DNS instance.
 | 
			
		||||
 | 
			
		||||
  @param[in]   This               Pointer to EFI_DNS4_PROTOCOL instance.
 | 
			
		||||
  @param[out]  DnsModeData        Point to the mode data.
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS             The operation completed successfully.
 | 
			
		||||
  @retval EFI_NOT_STARTED         When DnsConfigData is queried, no configuration data
 | 
			
		||||
                                  is available because this instance has not been
 | 
			
		||||
                                  configured.
 | 
			
		||||
  @retval EFI_INVALID_PARAMETER   This is NULL or DnsModeData is NULL.
 | 
			
		||||
  @retval EFI_OUT_OF_RESOURCES    Failed to allocate needed resources.
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_DNS4_GET_MODE_DATA)(
 | 
			
		||||
  IN  EFI_DNS4_PROTOCOL          *This,
 | 
			
		||||
  OUT EFI_DNS4_MODE_DATA         *DnsModeData
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Configure this DNS instance.
 | 
			
		||||
 | 
			
		||||
  This function is used to configure DNS mode data for this DNS instance.
 | 
			
		||||
 | 
			
		||||
  @param[in]  This                Pointer to EFI_DNS4_PROTOCOL instance.
 | 
			
		||||
  @param[in]  DnsConfigData       Point to the Configuration data.
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS             The operation completed successfully.
 | 
			
		||||
  @retval EFI_UNSUPPORTED         The designated protocol is not supported.
 | 
			
		||||
  @retval EFI_INVALID_PARAMETER   This is NULL.
 | 
			
		||||
                                  The StationIp address provided in DnsConfigData is not a
 | 
			
		||||
                                  valid unicast.
 | 
			
		||||
                                  DnsServerList is NULL while DnsServerListCount
 | 
			
		||||
                                  is not ZERO.
 | 
			
		||||
                                  DnsServerListCount is ZERO while DnsServerList
 | 
			
		||||
                                  is not NULL
 | 
			
		||||
  @retval EFI_OUT_OF_RESOURCES    The DNS instance data or required space could not be
 | 
			
		||||
                                  allocated.
 | 
			
		||||
  @retval EFI_DEVICE_ERROR        An unexpected system or network error occurred. The
 | 
			
		||||
                                  EFI DNSv4 Protocol instance is not configured.
 | 
			
		||||
  @retval EFI_ALREADY_STARTED     Second call to Configure() with DnsConfigData. To
 | 
			
		||||
                                  reconfigure the instance the caller must call Configure()
 | 
			
		||||
                                  with NULL first to return driver to unconfigured state.
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_DNS4_CONFIGURE)(
 | 
			
		||||
  IN EFI_DNS4_PROTOCOL          *This,
 | 
			
		||||
  IN EFI_DNS4_CONFIG_DATA       *DnsConfigData
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Host name to host address translation.
 | 
			
		||||
 | 
			
		||||
  The HostNameToIp () function is used to translate the host name to host IP address. A
 | 
			
		||||
  type A query is used to get the one or more IP addresses for this host.
 | 
			
		||||
 | 
			
		||||
  @param[in]  This                Pointer to EFI_DNS4_PROTOCOL instance.
 | 
			
		||||
  @param[in]  HostName            Host name.
 | 
			
		||||
  @param[in]  Token               Point to the completion token to translate host name
 | 
			
		||||
                                  to host address.
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS             The operation completed successfully.
 | 
			
		||||
  @retval EFI_INVALID_PARAMETER   One or more of the following conditions is TRUE:
 | 
			
		||||
                                  This is NULL.
 | 
			
		||||
                                  Token is NULL.
 | 
			
		||||
                                  Token.Event is NULL.
 | 
			
		||||
                                  HostName is NULL. HostName string is unsupported format.
 | 
			
		||||
  @retval EFI_NO_MAPPING          There's no source address is available for use.
 | 
			
		||||
  @retval EFI_NOT_STARTED         This instance has not been started.
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_DNS4_HOST_NAME_TO_IP)(
 | 
			
		||||
  IN EFI_DNS4_PROTOCOL         *This,
 | 
			
		||||
  IN CHAR16                    *HostName,
 | 
			
		||||
  IN EFI_DNS4_COMPLETION_TOKEN *Token
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  IPv4 address to host name translation also known as Reverse DNS lookup.
 | 
			
		||||
 | 
			
		||||
  The IpToHostName() function is used to translate the host address to host name. A type PTR
 | 
			
		||||
  query is used to get the primary name of the host. Support of this function is optional.
 | 
			
		||||
 | 
			
		||||
  @param[in]  This                Pointer to EFI_DNS4_PROTOCOL instance.
 | 
			
		||||
  @param[in]  IpAddress           Ip Address.
 | 
			
		||||
  @param[in]  Token               Point to the completion token to translate host
 | 
			
		||||
                                  address to host name.
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS             The operation completed successfully.
 | 
			
		||||
  @retval EFI_UNSUPPORTED         This function is not supported.
 | 
			
		||||
  @retval EFI_INVALID_PARAMETER   One or more of the following conditions is TRUE:
 | 
			
		||||
                                  This is NULL.
 | 
			
		||||
                                  Token is NULL.
 | 
			
		||||
                                  Token.Event is NULL.
 | 
			
		||||
                                  IpAddress is not valid IP address .
 | 
			
		||||
  @retval EFI_NO_MAPPING          There's no source address is available for use.
 | 
			
		||||
  @retval EFI_ALREADY_STARTED     This Token is being used in another DNS session.
 | 
			
		||||
  @retval EFI_OUT_OF_RESOURCES    Failed to allocate needed resources.
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_DNS4_IP_TO_HOST_NAME)(
 | 
			
		||||
  IN EFI_DNS4_PROTOCOL         *This,
 | 
			
		||||
  IN EFI_IPv4_ADDRESS          IpAddress,
 | 
			
		||||
  IN EFI_DNS4_COMPLETION_TOKEN *Token
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Retrieve arbitrary information from the DNS server.
 | 
			
		||||
 | 
			
		||||
  This GeneralLookup() function retrieves arbitrary information from the DNS. The caller
 | 
			
		||||
  supplies a QNAME, QTYPE, and QCLASS, and all of the matching RRs are returned. All
 | 
			
		||||
  RR content (e.g., TTL) was returned. The caller need parse the returned RR to get
 | 
			
		||||
  required information. The function is optional.
 | 
			
		||||
 | 
			
		||||
  @param[in]  This                Pointer to EFI_DNS4_PROTOCOL instance.
 | 
			
		||||
  @param[in]  QName               Pointer to Query Name.
 | 
			
		||||
  @param[in]  QType               Query Type.
 | 
			
		||||
  @param[in]  QClass              Query Name.
 | 
			
		||||
  @param[in]  Token               Point to the completion token to retrieve arbitrary
 | 
			
		||||
                                  information.
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS             The operation completed successfully.
 | 
			
		||||
  @retval EFI_UNSUPPORTED         This function is not supported. Or the requested
 | 
			
		||||
                                  QType is not supported
 | 
			
		||||
  @retval EFI_INVALID_PARAMETER   One or more of the following conditions is TRUE:
 | 
			
		||||
                                  This is NULL.
 | 
			
		||||
                                  Token is NULL.
 | 
			
		||||
                                  Token.Event is NULL.
 | 
			
		||||
                                  QName is NULL.
 | 
			
		||||
  @retval EFI_NO_MAPPING          There's no source address is available for use.
 | 
			
		||||
  @retval EFI_ALREADY_STARTED     This Token is being used in another DNS session.
 | 
			
		||||
  @retval EFI_OUT_OF_RESOURCES    Failed to allocate needed resources.
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_DNS4_GENERAL_LOOKUP)(
 | 
			
		||||
  IN EFI_DNS4_PROTOCOL          *This,
 | 
			
		||||
  IN CHAR8                      *QName,
 | 
			
		||||
  IN UINT16                     QType,
 | 
			
		||||
  IN UINT16                     QClass,
 | 
			
		||||
  IN EFI_DNS4_COMPLETION_TOKEN  *Token
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  This function is to update the DNS Cache.
 | 
			
		||||
 | 
			
		||||
  The UpdateDnsCache() function is used to add/delete/modify DNS cache entry. DNS cache
 | 
			
		||||
  can be normally dynamically updated after the DNS resolve succeeds. This function
 | 
			
		||||
  provided capability to manually add/delete/modify the DNS cache.
 | 
			
		||||
 | 
			
		||||
  @param[in]  This                Pointer to EFI_DNS4_PROTOCOL instance.
 | 
			
		||||
  @param[in]  DeleteFlag          If FALSE, this function is to add one entry to the
 | 
			
		||||
                                  DNS Cahce. If TRUE, this function will delete
 | 
			
		||||
                                  matching DNS Cache entry.
 | 
			
		||||
  @param[in]  Override            If TRUE, the maching DNS cache entry will be
 | 
			
		||||
                                  overwritten with the supplied parameter. If FALSE,
 | 
			
		||||
                                  EFI_ACCESS_DENIED will be returned if the entry to
 | 
			
		||||
                                  be added is already existed.
 | 
			
		||||
  @param[in]  DnsCacheEntry       Pointer to DNS Cache entry.
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS             The operation completed successfully.
 | 
			
		||||
  @retval EFI_INVALID_PARAMETER   One or more of the following conditions is TRUE:
 | 
			
		||||
                                  This is NULL.
 | 
			
		||||
                                  DnsCacheEntry.HostName is NULL.
 | 
			
		||||
                                  DnsCacheEntry.IpAddress is NULL.
 | 
			
		||||
                                  DnsCacheEntry.Timeout is zero.
 | 
			
		||||
  @retval EFI_ACCESS_DENIED       The DNS cache entry already exists and Override is
 | 
			
		||||
                                  not TRUE.
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_DNS4_UPDATE_DNS_CACHE)(
 | 
			
		||||
  IN EFI_DNS4_PROTOCOL          *This,
 | 
			
		||||
  IN BOOLEAN                    DeleteFlag,
 | 
			
		||||
  IN BOOLEAN                    Override,
 | 
			
		||||
  IN EFI_DNS4_CACHE_ENTRY       DnsCacheEntry
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Polls for incoming data packets and processes outgoing data packets.
 | 
			
		||||
 | 
			
		||||
  The Poll() function can be used by network drivers and applications to increase the
 | 
			
		||||
  rate that data packets are moved between the communications device and the transmit
 | 
			
		||||
  and receive queues.
 | 
			
		||||
  In some systems, the periodic timer event in the managed network driver may not poll
 | 
			
		||||
  the underlying communications device fast enough to transmit and/or receive all data
 | 
			
		||||
  packets without missing incoming packets or dropping outgoing packets. Drivers and
 | 
			
		||||
  applications that are experiencing packet loss should try calling the Poll()
 | 
			
		||||
  function more often.
 | 
			
		||||
 | 
			
		||||
  @param[in]  This                Pointer to EFI_DNS4_PROTOCOL instance.
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS             Incoming or outgoing data was processed.
 | 
			
		||||
  @retval EFI_NOT_STARTED         This EFI DNS Protocol instance has not been started.
 | 
			
		||||
  @retval EFI_INVALID_PARAMETER   This is NULL.
 | 
			
		||||
  @retval EFI_DEVICE_ERROR        An unexpected system or network error occurred.
 | 
			
		||||
  @retval EFI_TIMEOUT             Data was dropped out of the transmit and/or receive
 | 
			
		||||
                                  queue. Consider increasing the polling rate.
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_DNS4_POLL)(
 | 
			
		||||
  IN  EFI_DNS4_PROTOCOL         *This
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Abort an asynchronous DNS operation, including translation between IP and Host, and
 | 
			
		||||
  general look up behavior.
 | 
			
		||||
 | 
			
		||||
  The Cancel() function is used to abort a pending resolution request. After calling
 | 
			
		||||
  this function, Token.Status will be set to EFI_ABORTED and then Token.Event will be
 | 
			
		||||
  signaled. If the token is not in one of the queues, which usually means that the
 | 
			
		||||
  asynchronous operation has completed, this function will not signal the token and
 | 
			
		||||
  EFI_NOT_FOUND is returned.
 | 
			
		||||
 | 
			
		||||
  @param[in]  This                Pointer to EFI_DNS4_PROTOCOL instance.
 | 
			
		||||
  @param[in]  Token               Pointer to a token that has been issued by
 | 
			
		||||
                                  EFI_DNS4_PROTOCOL.HostNameToIp (),
 | 
			
		||||
                                  EFI_DNS4_PROTOCOL.IpToHostName() or
 | 
			
		||||
                                  EFI_DNS4_PROTOCOL.GeneralLookup().
 | 
			
		||||
                                  If NULL, all pending tokens are aborted.
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS             Incoming or outgoing data was processed.
 | 
			
		||||
  @retval EFI_NOT_STARTED         This EFI DNS4 Protocol instance has not been started.
 | 
			
		||||
  @retval EFI_INVALID_PARAMETER   This is NULL.
 | 
			
		||||
  @retval EFI_NOT_FOUND           When Token is not NULL, and the asynchronous DNS
 | 
			
		||||
                                  operation was not found in the transmit queue. It
 | 
			
		||||
                                  was either completed or was not issued by
 | 
			
		||||
                                  HostNameToIp(), IpToHostName() or GeneralLookup().
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_DNS4_CANCEL)(
 | 
			
		||||
  IN  EFI_DNS4_PROTOCOL         *This,
 | 
			
		||||
  IN  EFI_DNS4_COMPLETION_TOKEN *Token
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// The EFI_DNS4_Protocol provides the function to get the host name and address
 | 
			
		||||
/// mapping, also provides pass through interface to retrieve arbitrary information
 | 
			
		||||
/// from DNS.
 | 
			
		||||
///
 | 
			
		||||
struct _EFI_DNS4_PROTOCOL {
 | 
			
		||||
  EFI_DNS4_GET_MODE_DATA       GetModeData;
 | 
			
		||||
  EFI_DNS4_CONFIGURE           Configure;
 | 
			
		||||
  EFI_DNS4_HOST_NAME_TO_IP     HostNameToIp;
 | 
			
		||||
  EFI_DNS4_IP_TO_HOST_NAME     IpToHostName;
 | 
			
		||||
  EFI_DNS4_GENERAL_LOOKUP      GeneralLookUp;
 | 
			
		||||
  EFI_DNS4_UPDATE_DNS_CACHE    UpdateDnsCache;
 | 
			
		||||
  EFI_DNS4_POLL                Poll;
 | 
			
		||||
  EFI_DNS4_CANCEL              Cancel;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
extern EFI_GUID  gEfiDns4ServiceBindingProtocolGuid;
 | 
			
		||||
extern EFI_GUID  gEfiDns4ProtocolGuid;
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										535
									
								
								src/include/ipxe/efi/Protocol/Dns6.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										535
									
								
								src/include/ipxe/efi/Protocol/Dns6.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,535 @@
 | 
			
		||||
/** @file
 | 
			
		||||
  This file defines the EFI DNSv6 (Domain Name Service version 6) Protocol. It is split
 | 
			
		||||
  into the following two main sections:
 | 
			
		||||
  DNSv6 Service Binding Protocol (DNSv6SB)
 | 
			
		||||
  DNSv6 Protocol (DNSv6)
 | 
			
		||||
 | 
			
		||||
  Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>
 | 
			
		||||
  SPDX-License-Identifier: BSD-2-Clause-Patent
 | 
			
		||||
 | 
			
		||||
  @par Revision Reference:
 | 
			
		||||
  This Protocol is introduced in UEFI Specification 2.5
 | 
			
		||||
 | 
			
		||||
**/
 | 
			
		||||
 | 
			
		||||
#ifndef __EFI_DNS6_PROTOCOL_H__
 | 
			
		||||
#define __EFI_DNS6_PROTOCOL_H__
 | 
			
		||||
 | 
			
		||||
FILE_LICENCE ( BSD2_PATENT );
 | 
			
		||||
 | 
			
		||||
#define EFI_DNS6_SERVICE_BINDING_PROTOCOL_GUID \
 | 
			
		||||
  { \
 | 
			
		||||
    0x7f1647c8, 0xb76e, 0x44b2, {0xa5, 0x65, 0xf7, 0xf, 0xf1, 0x9c, 0xd1, 0x9e } \
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
#define EFI_DNS6_PROTOCOL_GUID \
 | 
			
		||||
  { \
 | 
			
		||||
    0xca37bc1f, 0xa327, 0x4ae9, {0x82, 0x8a, 0x8c, 0x40, 0xd8, 0x50, 0x6a, 0x17 } \
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
typedef struct _EFI_DNS6_PROTOCOL EFI_DNS6_PROTOCOL;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_DNS6_CONFIG_DATA
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// If TRUE, enable DNS cache function for this DNS instance. If FALSE, all DNS query
 | 
			
		||||
  /// will not lookup local DNS cache.
 | 
			
		||||
  ///
 | 
			
		||||
  BOOLEAN             EnableDnsCache;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Use the protocol number defined in
 | 
			
		||||
  /// http://www.iana.org/assignments/protocol-numbers. Beside TCP/UDP, Other protocol
 | 
			
		||||
  /// is invalid value. An implementation can choose to support UDP, or both TCP and UDP.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT8               Protocol;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The local IP address to use. Set to zero to let the underlying IPv6
 | 
			
		||||
  /// driver choose a source address. If not zero it must be one of the
 | 
			
		||||
  /// configured IP addresses in the underlying IPv6 driver.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_IPv6_ADDRESS    StationIp;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Local port number. Set to zero to use the automatically assigned port number.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT16              LocalPort;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Count of the DNS servers. When used with GetModeData(),
 | 
			
		||||
  /// this field is the count of originally configured servers when
 | 
			
		||||
  /// Configure() was called for this instance. When used with
 | 
			
		||||
  /// Configure() this is the count of caller-supplied servers. If the
 | 
			
		||||
  /// DnsServerListCount is zero, the DNS server configuration
 | 
			
		||||
  /// will be retrieved from DHCP server automatically.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32    DnsServerCount;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Pointer to DNS server list containing DnsServerListCount
 | 
			
		||||
  /// entries or NULL if DnsServerListCount is 0. For Configure(),
 | 
			
		||||
  /// this will be NULL when there are no caller supplied server addresses
 | 
			
		||||
  /// and the DNS instance will retrieve DNS server from DHCP Server.
 | 
			
		||||
  /// The provided DNS server list is recommended to be filled up in the sequence
 | 
			
		||||
  /// of preference. When used with GetModeData(), the buffer containing the list
 | 
			
		||||
  /// will be allocated by the driver implementing this protocol and must be
 | 
			
		||||
  /// freed by the caller. When used with Configure(), the buffer
 | 
			
		||||
  /// containing the list will be allocated and released by the caller.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_IPv6_ADDRESS    *DnsServerList;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Retry number if no response received after RetryInterval.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32              RetryCount;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Minimum interval of retry is 2 second. If the retry interval is less than 2
 | 
			
		||||
  /// seconds, then use the 2 seconds.
 | 
			
		||||
  UINT32              RetryInterval;
 | 
			
		||||
} EFI_DNS6_CONFIG_DATA;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_DNS6_CACHE_ENTRY
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// Host name. This should be interpreted as Unicode characters.
 | 
			
		||||
  ///
 | 
			
		||||
  CHAR16              *HostName;
 | 
			
		||||
  ///
 | 
			
		||||
  /// IP address of this host.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_IPv6_ADDRESS    *IpAddress;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Time in second unit that this entry will remain in DNS cache. A value of zero means
 | 
			
		||||
  /// that this entry is permanent. A nonzero value will override the existing one if
 | 
			
		||||
  /// this entry to be added is dynamic entry. Implementations may set its default
 | 
			
		||||
  /// timeout value for the dynamically created DNS cache entry after one DNS resolve
 | 
			
		||||
  /// succeeds.
 | 
			
		||||
  UINT32              Timeout;
 | 
			
		||||
} EFI_DNS6_CACHE_ENTRY;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_DNS6_MODE_DATA
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// The configuration data of this instance.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_DNS6_CONFIG_DATA    DnsConfigData;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Number of configured DNS6 servers.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32                  DnsServerCount;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Pointer to common list of addresses of all configured DNS server used by EFI_DNS6_PROTOCOL
 | 
			
		||||
  /// instances. List will include DNS servers configured by this or any other EFI_DNS6_PROTOCOL
 | 
			
		||||
  /// instance. The storage for this list is allocated by the driver publishing this protocol,
 | 
			
		||||
  /// and must be freed by the caller.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_IPv6_ADDRESS        *DnsServerList;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Number of DNS Cache entries. The DNS Cache is shared among all DNS instances.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32                  DnsCacheCount;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Pointer to a buffer containing DnsCacheCount DNS Cache
 | 
			
		||||
  /// entry structures. The storage for thislist is allocated by the driver
 | 
			
		||||
  /// publishing this protocol and must be freed by caller.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_DNS6_CACHE_ENTRY    *DnsCacheList;
 | 
			
		||||
} EFI_DNS6_MODE_DATA;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// DNS6_HOST_TO_ADDR_DATA
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// Number of the returned IP address.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32              IpCount;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Pointer to the all the returned IP address.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_IPv6_ADDRESS    *IpList;
 | 
			
		||||
} DNS6_HOST_TO_ADDR_DATA;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// DNS6_ADDR_TO_HOST_DATA
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// Pointer to the primary name for this host address. It's the caller's
 | 
			
		||||
  /// responsibility to free the response memory.
 | 
			
		||||
  ///
 | 
			
		||||
  CHAR16    *HostName;
 | 
			
		||||
} DNS6_ADDR_TO_HOST_DATA;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// DNS6_RESOURCE_RECORD
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// The Owner name.
 | 
			
		||||
  ///
 | 
			
		||||
  CHAR8     *QName;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The Type Code of this RR.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT16    QType;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The CLASS code of this RR.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT16    QClass;
 | 
			
		||||
  ///
 | 
			
		||||
  /// 32 bit integer which specify the time interval that the resource record may be
 | 
			
		||||
  /// cached before the source of the information should again be consulted. Zero means
 | 
			
		||||
  /// this RR cannot be cached.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32    TTL;
 | 
			
		||||
  ///
 | 
			
		||||
  /// 16 big integer which specify the length of RData.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT16    DataLength;
 | 
			
		||||
  ///
 | 
			
		||||
  /// A string of octets that describe the resource, the format of this information
 | 
			
		||||
  /// varies according to QType and QClass difference.
 | 
			
		||||
  ///
 | 
			
		||||
  CHAR8     *RData;
 | 
			
		||||
} DNS6_RESOURCE_RECORD;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// DNS6_GENERAL_LOOKUP_DATA
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// Number of returned matching RRs.
 | 
			
		||||
  ///
 | 
			
		||||
  UINTN                   RRCount;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Pointer to the all the returned matching RRs. It's caller responsibility to free
 | 
			
		||||
  /// the allocated memory to hold the returned RRs.
 | 
			
		||||
  ///
 | 
			
		||||
  DNS6_RESOURCE_RECORD    *RRList;
 | 
			
		||||
} DNS6_GENERAL_LOOKUP_DATA;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_DNS6_COMPLETION_TOKEN
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// This Event will be signaled after the Status field is updated by the EFI DNSv6
 | 
			
		||||
  /// protocol driver. The type of Event must be EFI_NOTIFY_SIGNAL.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_EVENT    Event;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Will be set to one of the following values:
 | 
			
		||||
  ///   EFI_SUCCESS:      The host name to address translation completed successfully.
 | 
			
		||||
  ///   EFI_NOT_FOUND:    No matching Resource Record (RR) is found.
 | 
			
		||||
  ///   EFI_TIMEOUT:      No DNS server reachable, or RetryCount was exhausted without
 | 
			
		||||
  ///                     response from all specified DNS servers.
 | 
			
		||||
  ///   EFI_DEVICE_ERROR: An unexpected system or network error occurred.
 | 
			
		||||
  ///   EFI_NO_MEDIA:     There was a media error.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_STATUS    Status;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The parameter configured through DNSv6.Configure() interface. Retry number if no
 | 
			
		||||
  /// response received after RetryInterval.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32        RetryCount;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The parameter configured through DNSv6.Configure() interface. Minimum interval of
 | 
			
		||||
  /// retry is 2 seconds. If the retry interval is less than 2 seconds, then use the 2
 | 
			
		||||
  /// seconds.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32        RetryInterval;
 | 
			
		||||
  ///
 | 
			
		||||
  /// DNSv6 completion token data
 | 
			
		||||
  ///
 | 
			
		||||
  union {
 | 
			
		||||
    ///
 | 
			
		||||
    /// When the Token is used for host name to address translation, H2AData is a pointer
 | 
			
		||||
    /// to the DNS6_HOST_TO_ADDR_DATA.
 | 
			
		||||
    ///
 | 
			
		||||
    DNS6_HOST_TO_ADDR_DATA      *H2AData;
 | 
			
		||||
    ///
 | 
			
		||||
    /// When the Token is used for host address to host name translation, A2HData is a
 | 
			
		||||
    /// pointer to the DNS6_ADDR_TO_HOST_DATA.
 | 
			
		||||
    ///
 | 
			
		||||
    DNS6_ADDR_TO_HOST_DATA      *A2HData;
 | 
			
		||||
    ///
 | 
			
		||||
    /// When the Token is used for a general lookup function, GLookupDATA is a pointer to
 | 
			
		||||
    /// the DNS6_GENERAL_LOOKUP_DATA.
 | 
			
		||||
    ///
 | 
			
		||||
    DNS6_GENERAL_LOOKUP_DATA    *GLookupData;
 | 
			
		||||
  } RspData;
 | 
			
		||||
} EFI_DNS6_COMPLETION_TOKEN;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Retrieve mode data of this DNS instance.
 | 
			
		||||
 | 
			
		||||
  This function is used to retrieve DNS mode data for this DNS instance.
 | 
			
		||||
 | 
			
		||||
  @param[in]   This                Pointer to EFI_DNS6_PROTOCOL instance.
 | 
			
		||||
  @param[out]  DnsModeData         Pointer to the caller-allocated storage for the
 | 
			
		||||
                                   EFI_DNS6_MODE_DATA data.
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS             The operation completed successfully.
 | 
			
		||||
  @retval EFI_NOT_STARTED         When DnsConfigData is queried, no configuration data
 | 
			
		||||
                                  is available because this instance has not been
 | 
			
		||||
                                  configured.
 | 
			
		||||
  @retval EFI_INVALID_PARAMETER   This is NULL or DnsModeData is NULL.
 | 
			
		||||
  @retval EFI_OUT_OF_RESOURCE     Failed to allocate needed resources.
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_DNS6_GET_MODE_DATA)(
 | 
			
		||||
  IN  EFI_DNS6_PROTOCOL         *This,
 | 
			
		||||
  OUT EFI_DNS6_MODE_DATA        *DnsModeData
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Configure this DNS instance.
 | 
			
		||||
 | 
			
		||||
  The Configure() function is used to set and change the configuration data for this
 | 
			
		||||
  EFI DNSv6 Protocol driver instance. Reset the DNS instance if DnsConfigData is NULL.
 | 
			
		||||
 | 
			
		||||
  @param[in]  This                Pointer to EFI_DNS6_PROTOCOL instance.
 | 
			
		||||
  @param[in]  DnsConfigData       Pointer to the configuration data structure. All associated
 | 
			
		||||
                                  storage to be allocated and released by caller.
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS             The operation completed successfully.
 | 
			
		||||
  @retval EFI_INVALID_PARAMETER   This is NULL.
 | 
			
		||||
                                  The StationIp address provided in DnsConfigData is not zero and not a valid unicast.
 | 
			
		||||
                                  DnsServerList is NULL while DnsServerList Count is not ZERO.
 | 
			
		||||
                                  DnsServerList Count is ZERO while DnsServerList is not NULL.
 | 
			
		||||
  @retval EFI_OUT_OF_RESOURCES    The DNS instance data or required space could not be allocated.
 | 
			
		||||
  @retval EFI_DEVICE_ERROR        An unexpected system or network error occurred. The
 | 
			
		||||
                                  EFI DNSv6 Protocol instance is not configured.
 | 
			
		||||
  @retval EFI_UNSUPPORTED         The designated protocol is not supported.
 | 
			
		||||
  @retval EFI_ALREADY_STARTED     Second call to Configure() with DnsConfigData. To
 | 
			
		||||
                                  reconfigure the instance the caller must call Configure() with
 | 
			
		||||
                                  NULL first to return driver to unconfigured state.
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_DNS6_CONFIGURE)(
 | 
			
		||||
  IN EFI_DNS6_PROTOCOL          *This,
 | 
			
		||||
  IN EFI_DNS6_CONFIG_DATA       *DnsConfigData
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Host name to host address translation.
 | 
			
		||||
 | 
			
		||||
  The HostNameToIp () function is used to translate the host name to host IP address. A
 | 
			
		||||
  type AAAA query is used to get the one or more IPv6 addresses for this host.
 | 
			
		||||
 | 
			
		||||
  @param[in]  This                Pointer to EFI_DNS6_PROTOCOL instance.
 | 
			
		||||
  @param[in]  HostName            Host name.
 | 
			
		||||
  @param[in]  Token               Point to the completion token to translate host name
 | 
			
		||||
                                  to host address.
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS             The operation completed successfully.
 | 
			
		||||
  @retval EFI_INVALID_PARAMETER   One or more of the following conditions is TRUE:
 | 
			
		||||
                                  This is NULL.
 | 
			
		||||
                                  Token is NULL.
 | 
			
		||||
                                  Token.Event is NULL.
 | 
			
		||||
                                  HostName is NULL or buffer contained unsupported characters.
 | 
			
		||||
  @retval EFI_NO_MAPPING          There's no source address is available for use.
 | 
			
		||||
  @retval EFI_ALREADY_STARTED     This Token is being used in another DNS session.
 | 
			
		||||
  @retval EFI_NOT_STARTED         This instance has not been started.
 | 
			
		||||
  @retval EFI_OUT_OF_RESOURCES    Failed to allocate needed resources.
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_DNS6_HOST_NAME_TO_IP)(
 | 
			
		||||
  IN  EFI_DNS6_PROTOCOL         *This,
 | 
			
		||||
  IN  CHAR16                    *HostName,
 | 
			
		||||
  IN  EFI_DNS6_COMPLETION_TOKEN *Token
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Host address to host name translation.
 | 
			
		||||
 | 
			
		||||
  The IpToHostName () function is used to translate the host address to host name. A
 | 
			
		||||
  type PTR query is used to get the primary name of the host. Implementation can choose
 | 
			
		||||
  to support this function or not.
 | 
			
		||||
 | 
			
		||||
  @param[in]  This                Pointer to EFI_DNS6_PROTOCOL instance.
 | 
			
		||||
  @param[in]  IpAddress           Ip Address.
 | 
			
		||||
  @param[in]  Token               Point to the completion token to translate host
 | 
			
		||||
                                  address to host name.
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS             The operation completed successfully.
 | 
			
		||||
  @retval EFI_UNSUPPORTED         This function is not supported.
 | 
			
		||||
  @retval EFI_INVALID_PARAMETER   One or more of the following conditions is TRUE:
 | 
			
		||||
                                  This is NULL.
 | 
			
		||||
                                  Token is NULL.
 | 
			
		||||
                                  Token.Event is NULL.
 | 
			
		||||
                                  IpAddress is not valid IP address.
 | 
			
		||||
  @retval EFI_NO_MAPPING          There's no source address is available for use.
 | 
			
		||||
  @retval EFI_NOT_STARTED         This instance has not been started.
 | 
			
		||||
  @retval EFI_OUT_OF_RESOURCES    Failed to allocate needed resources.
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_DNS6_IP_TO_HOST_NAME)(
 | 
			
		||||
  IN  EFI_DNS6_PROTOCOL         *This,
 | 
			
		||||
  IN  EFI_IPv6_ADDRESS          IpAddress,
 | 
			
		||||
  IN  EFI_DNS6_COMPLETION_TOKEN *Token
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  This function provides capability to retrieve arbitrary information from the DNS
 | 
			
		||||
  server.
 | 
			
		||||
 | 
			
		||||
  This GeneralLookup() function retrieves arbitrary information from the DNS. The caller
 | 
			
		||||
  supplies a QNAME, QTYPE, and QCLASS, and all of the matching RRs are returned. All
 | 
			
		||||
  RR content (e.g., TTL) was returned. The caller need parse the returned RR to get
 | 
			
		||||
  required information. The function is optional. Implementation can choose to support
 | 
			
		||||
  it or not.
 | 
			
		||||
 | 
			
		||||
  @param[in]  This                Pointer to EFI_DNS6_PROTOCOL instance.
 | 
			
		||||
  @param[in]  QName               Pointer to Query Name.
 | 
			
		||||
  @param[in]  QType               Query Type.
 | 
			
		||||
  @param[in]  QClass              Query Name.
 | 
			
		||||
  @param[in]  Token               Point to the completion token to retrieve arbitrary
 | 
			
		||||
                                  information.
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS             The operation completed successfully.
 | 
			
		||||
  @retval EFI_UNSUPPORTED         This function is not supported. Or the requested
 | 
			
		||||
                                  QType is not supported
 | 
			
		||||
  @retval EFI_INVALID_PARAMETER   One or more of the following conditions is TRUE:
 | 
			
		||||
                                  This is NULL.
 | 
			
		||||
                                  Token is NULL.
 | 
			
		||||
                                  Token.Event is NULL.
 | 
			
		||||
                                  QName is NULL.
 | 
			
		||||
  @retval EFI_NO_MAPPING          There's no source address is available for use.
 | 
			
		||||
  @retval EFI_NOT_STARTED         This instance has not been started.
 | 
			
		||||
  @retval EFI_OUT_OF_RESOURCES    Failed to allocate needed resources.
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_DNS6_GENERAL_LOOKUP)(
 | 
			
		||||
  IN  EFI_DNS6_PROTOCOL         *This,
 | 
			
		||||
  IN  CHAR8                     *QName,
 | 
			
		||||
  IN  UINT16                    QType,
 | 
			
		||||
  IN  UINT16                    QClass,
 | 
			
		||||
  IN  EFI_DNS6_COMPLETION_TOKEN *Token
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  This function is to update the DNS Cache.
 | 
			
		||||
 | 
			
		||||
  The UpdateDnsCache() function is used to add/delete/modify DNS cache entry. DNS cache
 | 
			
		||||
  can be normally dynamically updated after the DNS resolve succeeds. This function
 | 
			
		||||
  provided capability to manually add/delete/modify the DNS cache.
 | 
			
		||||
 | 
			
		||||
  @param[in]  This                Pointer to EFI_DNS6_PROTOCOL instance.
 | 
			
		||||
  @param[in]  DeleteFlag          If FALSE, this function is to add one entry to the
 | 
			
		||||
                                  DNS Cahce. If TRUE, this function will delete
 | 
			
		||||
                                  matching DNS Cache entry.
 | 
			
		||||
  @param[in]  Override            If TRUE, the maching DNS cache entry will be
 | 
			
		||||
                                  overwritten with the supplied parameter. If FALSE,
 | 
			
		||||
                                  EFI_ACCESS_DENIED will be returned if the entry to
 | 
			
		||||
                                  be added is already existed.
 | 
			
		||||
  @param[in]  DnsCacheEntry       Pointer to DNS Cache entry.
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS             The operation completed successfully.
 | 
			
		||||
  @retval EFI_INVALID_PARAMETER   One or more of the following conditions is TRUE:
 | 
			
		||||
                                  This is NULL.
 | 
			
		||||
                                  DnsCacheEntry.HostName is NULL.
 | 
			
		||||
                                  DnsCacheEntry.IpAddress is NULL.
 | 
			
		||||
                                  DnsCacheEntry.Timeout is zero.
 | 
			
		||||
  @retval EFI_ACCESS_DENIED       The DNS cache entry already exists and Override is
 | 
			
		||||
                                  not TRUE.
 | 
			
		||||
  @retval EFI_OUT_OF_RESOURCE     Failed to allocate needed resources.
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_DNS6_UPDATE_DNS_CACHE)(
 | 
			
		||||
  IN EFI_DNS6_PROTOCOL          *This,
 | 
			
		||||
  IN BOOLEAN                    DeleteFlag,
 | 
			
		||||
  IN BOOLEAN                    Override,
 | 
			
		||||
  IN EFI_DNS6_CACHE_ENTRY       DnsCacheEntry
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Polls for incoming data packets and processes outgoing data packets.
 | 
			
		||||
 | 
			
		||||
  The Poll() function can be used by network drivers and applications to increase the
 | 
			
		||||
  rate that data packets are moved between the communications device and the transmit
 | 
			
		||||
  and receive queues.
 | 
			
		||||
 | 
			
		||||
  In some systems, the periodic timer event in the managed network driver may not poll
 | 
			
		||||
  the underlying communications device fast enough to transmit and/or receive all data
 | 
			
		||||
  packets without missing incoming packets or dropping outgoing packets. Drivers and
 | 
			
		||||
  applications that are experiencing packet loss should try calling the Poll()
 | 
			
		||||
  function more often.
 | 
			
		||||
 | 
			
		||||
  @param[in]  This                Pointer to EFI_DNS6_PROTOCOL instance.
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS             Incoming or outgoing data was processed.
 | 
			
		||||
  @retval EFI_NOT_STARTED         This EFI DNS Protocol instance has not been started.
 | 
			
		||||
  @retval EFI_INVALID_PARAMETER   This is NULL.
 | 
			
		||||
  @retval EFI_NO_MAPPING          There is no source address is available for use.
 | 
			
		||||
  @retval EFI_DEVICE_ERROR        An unexpected system or network error occurred.
 | 
			
		||||
  @retval EFI_TIMEOUT             Data was dropped out of the transmit and/or receive
 | 
			
		||||
                                  queue. Consider increasing the polling rate.
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_DNS6_POLL)(
 | 
			
		||||
  IN  EFI_DNS6_PROTOCOL         *This
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Abort an asynchronous DNS operation, including translation between IP and Host, and
 | 
			
		||||
  general look up behavior.
 | 
			
		||||
 | 
			
		||||
  The Cancel() function is used to abort a pending resolution request. After calling
 | 
			
		||||
  this function, Token.Status will be set to EFI_ABORTED and then Token.Event will be
 | 
			
		||||
  signaled. If the token is not in one of the queues, which usually means that the
 | 
			
		||||
  asynchronous operation has completed, this function will not signal the token and
 | 
			
		||||
  EFI_NOT_FOUND is returned.
 | 
			
		||||
 | 
			
		||||
  @param[in]  This                Pointer to EFI_DNS6_PROTOCOL instance.
 | 
			
		||||
  @param[in]  Token               Pointer to a token that has been issued by
 | 
			
		||||
                                  EFI_DNS6_PROTOCOL.HostNameToIp (),
 | 
			
		||||
                                  EFI_DNS6_PROTOCOL.IpToHostName() or
 | 
			
		||||
                                  EFI_DNS6_PROTOCOL.GeneralLookup().
 | 
			
		||||
                                  If NULL, all pending tokens are aborted.
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS             Incoming or outgoing data was processed.
 | 
			
		||||
  @retval EFI_NOT_STARTED         This EFI DNS6 Protocol instance has not been started.
 | 
			
		||||
  @retval EFI_INVALID_PARAMETER   This is NULL.
 | 
			
		||||
  @retval EFI_NO_MAPPING          There's no source address is available for use.
 | 
			
		||||
  @retval EFI_NOT_FOUND           When Token is not NULL, and the asynchronous DNS
 | 
			
		||||
                                  operation was not found in the transmit queue. It
 | 
			
		||||
                                  was either completed or was not issued by
 | 
			
		||||
                                  HostNameToIp(), IpToHostName() or GeneralLookup().
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_DNS6_CANCEL)(
 | 
			
		||||
  IN  EFI_DNS6_PROTOCOL         *This,
 | 
			
		||||
  IN  EFI_DNS6_COMPLETION_TOKEN *Token
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// The EFI_DNS6_PROTOCOL provides the function to get the host name and address
 | 
			
		||||
/// mapping, also provide pass through interface to retrieve arbitrary information from
 | 
			
		||||
/// DNSv6.
 | 
			
		||||
///
 | 
			
		||||
struct _EFI_DNS6_PROTOCOL {
 | 
			
		||||
  EFI_DNS6_GET_MODE_DATA       GetModeData;
 | 
			
		||||
  EFI_DNS6_CONFIGURE           Configure;
 | 
			
		||||
  EFI_DNS6_HOST_NAME_TO_IP     HostNameToIp;
 | 
			
		||||
  EFI_DNS6_IP_TO_HOST_NAME     IpToHostName;
 | 
			
		||||
  EFI_DNS6_GENERAL_LOOKUP      GeneralLookUp;
 | 
			
		||||
  EFI_DNS6_UPDATE_DNS_CACHE    UpdateDnsCache;
 | 
			
		||||
  EFI_DNS6_POLL                Poll;
 | 
			
		||||
  EFI_DNS6_CANCEL              Cancel;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
extern EFI_GUID  gEfiDns6ServiceBindingProtocolGuid;
 | 
			
		||||
extern EFI_GUID  gEfiDns6ProtocolGuid;
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										516
									
								
								src/include/ipxe/efi/Protocol/Http.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										516
									
								
								src/include/ipxe/efi/Protocol/Http.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,516 @@
 | 
			
		||||
/** @file
 | 
			
		||||
  This file defines the EFI HTTP Protocol interface. It is split into
 | 
			
		||||
  the following two main sections:
 | 
			
		||||
  HTTP Service Binding Protocol (HTTPSB)
 | 
			
		||||
  HTTP Protocol (HTTP)
 | 
			
		||||
 | 
			
		||||
  Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>
 | 
			
		||||
  (C) Copyright 2015-2017 Hewlett Packard Enterprise Development LP<BR>
 | 
			
		||||
  SPDX-License-Identifier: BSD-2-Clause-Patent
 | 
			
		||||
 | 
			
		||||
  @par Revision Reference:
 | 
			
		||||
  This Protocol is introduced in UEFI Specification 2.5
 | 
			
		||||
 | 
			
		||||
**/
 | 
			
		||||
 | 
			
		||||
#ifndef __EFI_HTTP_PROTOCOL_H__
 | 
			
		||||
#define __EFI_HTTP_PROTOCOL_H__
 | 
			
		||||
 | 
			
		||||
FILE_LICENCE ( BSD2_PATENT );
 | 
			
		||||
 | 
			
		||||
#define EFI_HTTP_SERVICE_BINDING_PROTOCOL_GUID \
 | 
			
		||||
  { \
 | 
			
		||||
    0xbdc8e6af, 0xd9bc, 0x4379, {0xa7, 0x2a, 0xe0, 0xc4, 0xe7, 0x5d, 0xae, 0x1c } \
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
#define EFI_HTTP_PROTOCOL_GUID \
 | 
			
		||||
  { \
 | 
			
		||||
    0x7a59b29b, 0x910b, 0x4171, {0x82, 0x42, 0xa8, 0x5a, 0x0d, 0xf2, 0x5b, 0x5b } \
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
typedef struct _EFI_HTTP_PROTOCOL EFI_HTTP_PROTOCOL;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_HTTP_VERSION
 | 
			
		||||
///
 | 
			
		||||
typedef enum {
 | 
			
		||||
  HttpVersion10,
 | 
			
		||||
  HttpVersion11,
 | 
			
		||||
  HttpVersionUnsupported
 | 
			
		||||
} EFI_HTTP_VERSION;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_HTTP_METHOD
 | 
			
		||||
///
 | 
			
		||||
typedef enum {
 | 
			
		||||
  HttpMethodGet,
 | 
			
		||||
  HttpMethodPost,
 | 
			
		||||
  HttpMethodPatch,
 | 
			
		||||
  HttpMethodOptions,
 | 
			
		||||
  HttpMethodConnect,
 | 
			
		||||
  HttpMethodHead,
 | 
			
		||||
  HttpMethodPut,
 | 
			
		||||
  HttpMethodDelete,
 | 
			
		||||
  HttpMethodTrace,
 | 
			
		||||
  HttpMethodMax
 | 
			
		||||
} EFI_HTTP_METHOD;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_HTTP_STATUS_CODE
 | 
			
		||||
///
 | 
			
		||||
typedef enum {
 | 
			
		||||
  HTTP_STATUS_UNSUPPORTED_STATUS = 0,
 | 
			
		||||
  HTTP_STATUS_100_CONTINUE,
 | 
			
		||||
  HTTP_STATUS_101_SWITCHING_PROTOCOLS,
 | 
			
		||||
  HTTP_STATUS_200_OK,
 | 
			
		||||
  HTTP_STATUS_201_CREATED,
 | 
			
		||||
  HTTP_STATUS_202_ACCEPTED,
 | 
			
		||||
  HTTP_STATUS_203_NON_AUTHORITATIVE_INFORMATION,
 | 
			
		||||
  HTTP_STATUS_204_NO_CONTENT,
 | 
			
		||||
  HTTP_STATUS_205_RESET_CONTENT,
 | 
			
		||||
  HTTP_STATUS_206_PARTIAL_CONTENT,
 | 
			
		||||
  HTTP_STATUS_300_MULTIPLE_CHOICES,
 | 
			
		||||
  HTTP_STATUS_301_MOVED_PERMANENTLY,
 | 
			
		||||
  HTTP_STATUS_302_FOUND,
 | 
			
		||||
  HTTP_STATUS_303_SEE_OTHER,
 | 
			
		||||
  HTTP_STATUS_304_NOT_MODIFIED,
 | 
			
		||||
  HTTP_STATUS_305_USE_PROXY,
 | 
			
		||||
  HTTP_STATUS_307_TEMPORARY_REDIRECT,
 | 
			
		||||
  HTTP_STATUS_400_BAD_REQUEST,
 | 
			
		||||
  HTTP_STATUS_401_UNAUTHORIZED,
 | 
			
		||||
  HTTP_STATUS_402_PAYMENT_REQUIRED,
 | 
			
		||||
  HTTP_STATUS_403_FORBIDDEN,
 | 
			
		||||
  HTTP_STATUS_404_NOT_FOUND,
 | 
			
		||||
  HTTP_STATUS_405_METHOD_NOT_ALLOWED,
 | 
			
		||||
  HTTP_STATUS_406_NOT_ACCEPTABLE,
 | 
			
		||||
  HTTP_STATUS_407_PROXY_AUTHENTICATION_REQUIRED,
 | 
			
		||||
  HTTP_STATUS_408_REQUEST_TIME_OUT,
 | 
			
		||||
  HTTP_STATUS_409_CONFLICT,
 | 
			
		||||
  HTTP_STATUS_410_GONE,
 | 
			
		||||
  HTTP_STATUS_411_LENGTH_REQUIRED,
 | 
			
		||||
  HTTP_STATUS_412_PRECONDITION_FAILED,
 | 
			
		||||
  HTTP_STATUS_413_REQUEST_ENTITY_TOO_LARGE,
 | 
			
		||||
  HTTP_STATUS_414_REQUEST_URI_TOO_LARGE,
 | 
			
		||||
  HTTP_STATUS_415_UNSUPPORTED_MEDIA_TYPE,
 | 
			
		||||
  HTTP_STATUS_416_REQUESTED_RANGE_NOT_SATISFIED,
 | 
			
		||||
  HTTP_STATUS_417_EXPECTATION_FAILED,
 | 
			
		||||
  HTTP_STATUS_500_INTERNAL_SERVER_ERROR,
 | 
			
		||||
  HTTP_STATUS_501_NOT_IMPLEMENTED,
 | 
			
		||||
  HTTP_STATUS_502_BAD_GATEWAY,
 | 
			
		||||
  HTTP_STATUS_503_SERVICE_UNAVAILABLE,
 | 
			
		||||
  HTTP_STATUS_504_GATEWAY_TIME_OUT,
 | 
			
		||||
  HTTP_STATUS_505_HTTP_VERSION_NOT_SUPPORTED,
 | 
			
		||||
  HTTP_STATUS_308_PERMANENT_REDIRECT
 | 
			
		||||
} EFI_HTTP_STATUS_CODE;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_HTTPv4_ACCESS_POINT
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// Set to TRUE to instruct the EFI HTTP instance to use the default address
 | 
			
		||||
  /// information in every TCP connection made by this instance. In addition, when set
 | 
			
		||||
  /// to TRUE, LocalAddress and LocalSubnet are ignored.
 | 
			
		||||
  ///
 | 
			
		||||
  BOOLEAN             UseDefaultAddress;
 | 
			
		||||
  ///
 | 
			
		||||
  /// If UseDefaultAddress is set to FALSE, this defines the local IP address to be
 | 
			
		||||
  /// used in every TCP connection opened by this instance.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_IPv4_ADDRESS    LocalAddress;
 | 
			
		||||
  ///
 | 
			
		||||
  /// If UseDefaultAddress is set to FALSE, this defines the local subnet to be used
 | 
			
		||||
  /// in every TCP connection opened by this instance.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_IPv4_ADDRESS    LocalSubnet;
 | 
			
		||||
  ///
 | 
			
		||||
  /// This defines the local port to be used in
 | 
			
		||||
  /// every TCP connection opened by this instance.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT16              LocalPort;
 | 
			
		||||
} EFI_HTTPv4_ACCESS_POINT;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_HTTPv6_ACCESS_POINT
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// Local IP address to be used in every TCP connection opened by this instance.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_IPv6_ADDRESS    LocalAddress;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Local port to be used in every TCP connection opened by this instance.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT16              LocalPort;
 | 
			
		||||
} EFI_HTTPv6_ACCESS_POINT;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_HTTP_CONFIG_DATA_ACCESS_POINT
 | 
			
		||||
///
 | 
			
		||||
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// HTTP version that this instance will support.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_HTTP_VERSION    HttpVersion;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Time out (in milliseconds) when blocking for requests.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32              TimeOutMillisec;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Defines behavior of EFI DNS and TCP protocols consumed by this instance. If
 | 
			
		||||
  /// FALSE, this instance will use EFI_DNS4_PROTOCOL and EFI_TCP4_PROTOCOL. If TRUE,
 | 
			
		||||
  /// this instance will use EFI_DNS6_PROTOCOL and EFI_TCP6_PROTOCOL.
 | 
			
		||||
  ///
 | 
			
		||||
  BOOLEAN             LocalAddressIsIPv6;
 | 
			
		||||
 | 
			
		||||
  union {
 | 
			
		||||
    ///
 | 
			
		||||
    /// When LocalAddressIsIPv6 is FALSE, this points to the local address, subnet, and
 | 
			
		||||
    /// port used by the underlying TCP protocol.
 | 
			
		||||
    ///
 | 
			
		||||
    EFI_HTTPv4_ACCESS_POINT    *IPv4Node;
 | 
			
		||||
    ///
 | 
			
		||||
    /// When LocalAddressIsIPv6 is TRUE, this points to the local IPv6 address and port
 | 
			
		||||
    /// used by the underlying TCP protocol.
 | 
			
		||||
    ///
 | 
			
		||||
    EFI_HTTPv6_ACCESS_POINT    *IPv6Node;
 | 
			
		||||
  } AccessPoint;
 | 
			
		||||
} EFI_HTTP_CONFIG_DATA;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_HTTP_REQUEST_DATA
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// The HTTP method (e.g. GET, POST) for this HTTP Request.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_HTTP_METHOD    Method;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The URI of a remote host. From the information in this field, the HTTP instance
 | 
			
		||||
  /// will be able to determine whether to use HTTP or HTTPS and will also be able to
 | 
			
		||||
  /// determine the port number to use. If no port number is specified, port 80 (HTTP)
 | 
			
		||||
  /// is assumed. See RFC 3986 for more details on URI syntax.
 | 
			
		||||
  ///
 | 
			
		||||
  CHAR16             *Url;
 | 
			
		||||
} EFI_HTTP_REQUEST_DATA;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_HTTP_RESPONSE_DATA
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// Response status code returned by the remote host.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_HTTP_STATUS_CODE    StatusCode;
 | 
			
		||||
} EFI_HTTP_RESPONSE_DATA;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_HTTP_HEADER
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// Null terminated string which describes a field name. See RFC 2616 Section 14 for
 | 
			
		||||
  /// detailed information about field names.
 | 
			
		||||
  ///
 | 
			
		||||
  CHAR8    *FieldName;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Null terminated string which describes the corresponding field value. See RFC 2616
 | 
			
		||||
  /// Section 14 for detailed information about field values.
 | 
			
		||||
  ///
 | 
			
		||||
  CHAR8    *FieldValue;
 | 
			
		||||
} EFI_HTTP_HEADER;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_HTTP_MESSAGE
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// HTTP message data.
 | 
			
		||||
  ///
 | 
			
		||||
  union {
 | 
			
		||||
    ///
 | 
			
		||||
    /// When the token is used to send a HTTP request, Request is a pointer to storage that
 | 
			
		||||
    /// contains such data as URL and HTTP method.
 | 
			
		||||
    ///
 | 
			
		||||
    EFI_HTTP_REQUEST_DATA     *Request;
 | 
			
		||||
    ///
 | 
			
		||||
    /// When used to await a response, Response points to storage containing HTTP response
 | 
			
		||||
    /// status code.
 | 
			
		||||
    ///
 | 
			
		||||
    EFI_HTTP_RESPONSE_DATA    *Response;
 | 
			
		||||
  } Data;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Number of HTTP header structures in Headers list. On request, this count is
 | 
			
		||||
  /// provided by the caller. On response, this count is provided by the HTTP driver.
 | 
			
		||||
  ///
 | 
			
		||||
  UINTN              HeaderCount;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Array containing list of HTTP headers. On request, this array is populated by the
 | 
			
		||||
  /// caller. On response, this array is allocated and populated by the HTTP driver. It
 | 
			
		||||
  /// is the responsibility of the caller to free this memory on both request and
 | 
			
		||||
  /// response.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_HTTP_HEADER    *Headers;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Length in bytes of the HTTP body. This can be zero depending on the HttpMethod type.
 | 
			
		||||
  ///
 | 
			
		||||
  UINTN              BodyLength;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Body associated with the HTTP request or response. This can be NULL depending on
 | 
			
		||||
  /// the HttpMethod type.
 | 
			
		||||
  ///
 | 
			
		||||
  VOID               *Body;
 | 
			
		||||
} EFI_HTTP_MESSAGE;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_HTTP_TOKEN
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// This Event will be signaled after the Status field is updated by the EFI HTTP
 | 
			
		||||
  /// Protocol driver. The type of Event must be EFI_NOTIFY_SIGNAL. The Task Priority
 | 
			
		||||
  /// Level (TPL) of Event must be lower than or equal to TPL_CALLBACK.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_EVENT    Event;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Status will be set to one of the following value if the HTTP request is
 | 
			
		||||
  /// successfully sent or if an unexpected error occurs:
 | 
			
		||||
  ///   EFI_SUCCESS:      The HTTP request was successfully sent to the remote host.
 | 
			
		||||
  ///   EFI_HTTP_ERROR:   The response message was successfully received but contains a
 | 
			
		||||
  ///                     HTTP error. The response status code is returned in token.
 | 
			
		||||
  ///   EFI_ABORTED:      The HTTP request was cancelled by the caller and removed from
 | 
			
		||||
  ///                     the transmit queue.
 | 
			
		||||
  ///   EFI_TIMEOUT:      The HTTP request timed out before reaching the remote host.
 | 
			
		||||
  ///   EFI_DEVICE_ERROR: An unexpected system or network error occurred.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_STATUS          Status;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Pointer to storage containing HTTP message data.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_HTTP_MESSAGE    *Message;
 | 
			
		||||
} EFI_HTTP_TOKEN;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Returns the operational parameters for the current HTTP child instance.
 | 
			
		||||
 | 
			
		||||
  The GetModeData() function is used to read the current mode data (operational
 | 
			
		||||
  parameters) for this HTTP protocol instance.
 | 
			
		||||
 | 
			
		||||
  @param[in]  This                Pointer to EFI_HTTP_PROTOCOL instance.
 | 
			
		||||
  @param[out] HttpConfigData      Point to buffer for operational parameters of this
 | 
			
		||||
                                  HTTP instance. It is the responsibility of the caller
 | 
			
		||||
                                  to allocate the memory for HttpConfigData and
 | 
			
		||||
                                  HttpConfigData->AccessPoint.IPv6Node/IPv4Node. In fact,
 | 
			
		||||
                                  it is recommended to allocate sufficient memory to record
 | 
			
		||||
                                  IPv6Node since it is big enough for all possibilities.
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS             Operation succeeded.
 | 
			
		||||
  @retval EFI_INVALID_PARAMETER   This is NULL.
 | 
			
		||||
                                  HttpConfigData is NULL.
 | 
			
		||||
                                  HttpConfigData->AccessPoint.IPv4Node or
 | 
			
		||||
                                  HttpConfigData->AccessPoint.IPv6Node is NULL.
 | 
			
		||||
  @retval EFI_NOT_STARTED         This EFI HTTP Protocol instance has not been started.
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_HTTP_GET_MODE_DATA)(
 | 
			
		||||
  IN  EFI_HTTP_PROTOCOL         *This,
 | 
			
		||||
  OUT EFI_HTTP_CONFIG_DATA      *HttpConfigData
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Initialize or brutally reset the operational parameters for this EFI HTTP instance.
 | 
			
		||||
 | 
			
		||||
  The Configure() function does the following:
 | 
			
		||||
  When HttpConfigData is not NULL Initialize this EFI HTTP instance by configuring
 | 
			
		||||
  timeout, local address, port, etc.
 | 
			
		||||
  When HttpConfigData is NULL, reset this EFI HTTP instance by closing all active
 | 
			
		||||
  connections with remote hosts, canceling all asynchronous tokens, and flush request
 | 
			
		||||
  and response buffers without informing the appropriate hosts.
 | 
			
		||||
 | 
			
		||||
  No other EFI HTTP function can be executed by this instance until the Configure()
 | 
			
		||||
  function is executed and returns successfully.
 | 
			
		||||
 | 
			
		||||
  @param[in]  This                Pointer to EFI_HTTP_PROTOCOL instance.
 | 
			
		||||
  @param[in]  HttpConfigData      Pointer to the configure data to configure the instance.
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS             Operation succeeded.
 | 
			
		||||
  @retval EFI_INVALID_PARAMETER   One or more of the following conditions is TRUE:
 | 
			
		||||
                                  This is NULL.
 | 
			
		||||
                                  HttpConfigData->LocalAddressIsIPv6 is FALSE and
 | 
			
		||||
                                  HttpConfigData->AccessPoint.IPv4Node is NULL.
 | 
			
		||||
                                  HttpConfigData->LocalAddressIsIPv6 is TRUE and
 | 
			
		||||
                                  HttpConfigData->AccessPoint.IPv6Node is NULL.
 | 
			
		||||
  @retval EFI_ALREADY_STARTED     Reinitialize this HTTP instance without calling
 | 
			
		||||
                                  Configure() with NULL to reset it.
 | 
			
		||||
  @retval EFI_DEVICE_ERROR        An unexpected system or network error occurred.
 | 
			
		||||
  @retval EFI_OUT_OF_RESOURCES    Could not allocate enough system resources when
 | 
			
		||||
                                  executing Configure().
 | 
			
		||||
  @retval EFI_UNSUPPORTED         One or more options in ConfigData are not supported
 | 
			
		||||
                                  in the implementation.
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_HTTP_CONFIGURE)(
 | 
			
		||||
  IN  EFI_HTTP_PROTOCOL         *This,
 | 
			
		||||
  IN  EFI_HTTP_CONFIG_DATA      *HttpConfigData OPTIONAL
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  The Request() function queues an HTTP request to this HTTP instance,
 | 
			
		||||
  similar to Transmit() function in the EFI TCP driver. When the HTTP request is sent
 | 
			
		||||
  successfully, or if there is an error, Status in token will be updated and Event will
 | 
			
		||||
  be signaled.
 | 
			
		||||
 | 
			
		||||
  @param[in]  This                Pointer to EFI_HTTP_PROTOCOL instance.
 | 
			
		||||
  @param[in]  Token               Pointer to storage containing HTTP request token.
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS             Outgoing data was processed.
 | 
			
		||||
  @retval EFI_NOT_STARTED         This EFI HTTP Protocol instance has not been started.
 | 
			
		||||
  @retval EFI_DEVICE_ERROR        An unexpected system or network error occurred.
 | 
			
		||||
  @retval EFI_TIMEOUT             Data was dropped out of the transmit or receive queue.
 | 
			
		||||
  @retval EFI_INVALID_PARAMETER   One or more of the following conditions is TRUE:
 | 
			
		||||
                                  This is NULL.
 | 
			
		||||
                                  Token is NULL.
 | 
			
		||||
                                  Token->Message is NULL.
 | 
			
		||||
                                  Token->Message->Body is not NULL,
 | 
			
		||||
                                  Token->Message->BodyLength is non-zero, and
 | 
			
		||||
                                  Token->Message->Data is NULL, but a previous call to
 | 
			
		||||
                                  Request()has not been completed successfully.
 | 
			
		||||
  @retval EFI_OUT_OF_RESOURCES    Could not allocate enough system resources.
 | 
			
		||||
  @retval EFI_UNSUPPORTED         The HTTP method is not supported in current implementation.
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_HTTP_REQUEST)(
 | 
			
		||||
  IN  EFI_HTTP_PROTOCOL         *This,
 | 
			
		||||
  IN  EFI_HTTP_TOKEN            *Token
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Abort an asynchronous HTTP request or response token.
 | 
			
		||||
 | 
			
		||||
  The Cancel() function aborts a pending HTTP request or response transaction. If
 | 
			
		||||
  Token is not NULL and the token is in transmit or receive queues when it is being
 | 
			
		||||
  cancelled, its Token->Status will be set to EFI_ABORTED and then Token->Event will
 | 
			
		||||
  be signaled. If the token is not in one of the queues, which usually means that the
 | 
			
		||||
  asynchronous operation has completed, EFI_NOT_FOUND is returned. If Token is NULL,
 | 
			
		||||
  all asynchronous tokens issued by Request() or Response() will be aborted.
 | 
			
		||||
 | 
			
		||||
  @param[in]  This                Pointer to EFI_HTTP_PROTOCOL instance.
 | 
			
		||||
  @param[in]  Token               Point to storage containing HTTP request or response
 | 
			
		||||
                                  token.
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS             Request and Response queues are successfully flushed.
 | 
			
		||||
  @retval EFI_INVALID_PARAMETER   This is NULL.
 | 
			
		||||
  @retval EFI_NOT_STARTED         This instance hasn't been configured.
 | 
			
		||||
  @retval EFI_NOT_FOUND           The asynchronous request or response token is not
 | 
			
		||||
                                  found.
 | 
			
		||||
  @retval EFI_UNSUPPORTED         The implementation does not support this function.
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_HTTP_CANCEL)(
 | 
			
		||||
  IN  EFI_HTTP_PROTOCOL         *This,
 | 
			
		||||
  IN  EFI_HTTP_TOKEN            *Token
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  The Response() function queues an HTTP response to this HTTP instance, similar to
 | 
			
		||||
  Receive() function in the EFI TCP driver. When the HTTP Response is received successfully,
 | 
			
		||||
  or if there is an error, Status in token will be updated and Event will be signaled.
 | 
			
		||||
 | 
			
		||||
  The HTTP driver will queue a receive token to the underlying TCP instance. When data
 | 
			
		||||
  is received in the underlying TCP instance, the data will be parsed and Token will
 | 
			
		||||
  be populated with the response data. If the data received from the remote host
 | 
			
		||||
  contains an incomplete or invalid HTTP header, the HTTP driver will continue waiting
 | 
			
		||||
  (asynchronously) for more data to be sent from the remote host before signaling
 | 
			
		||||
  Event in Token.
 | 
			
		||||
 | 
			
		||||
  It is the responsibility of the caller to allocate a buffer for Body and specify the
 | 
			
		||||
  size in BodyLength. If the remote host provides a response that contains a content
 | 
			
		||||
  body, up to BodyLength bytes will be copied from the receive buffer into Body and
 | 
			
		||||
  BodyLength will be updated with the amount of bytes received and copied to Body. This
 | 
			
		||||
  allows the client to download a large file in chunks instead of into one contiguous
 | 
			
		||||
  block of memory. Similar to HTTP request, if Body is not NULL and BodyLength is
 | 
			
		||||
  non-zero and all other fields are NULL or 0, the HTTP driver will queue a receive
 | 
			
		||||
  token to underlying TCP instance. If data arrives in the receive buffer, up to
 | 
			
		||||
  BodyLength bytes of data will be copied to Body. The HTTP driver will then update
 | 
			
		||||
  BodyLength with the amount of bytes received and copied to Body.
 | 
			
		||||
 | 
			
		||||
  If the HTTP driver does not have an open underlying TCP connection with the host
 | 
			
		||||
  specified in the response URL, Request() will return EFI_ACCESS_DENIED. This is
 | 
			
		||||
  consistent with RFC 2616 recommendation that HTTP clients should attempt to maintain
 | 
			
		||||
  an open TCP connection between client and host.
 | 
			
		||||
 | 
			
		||||
  @param[in]  This                Pointer to EFI_HTTP_PROTOCOL instance.
 | 
			
		||||
  @param[in]  Token               Pointer to storage containing HTTP response token.
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS             Allocation succeeded.
 | 
			
		||||
  @retval EFI_NOT_STARTED         This EFI HTTP Protocol instance has not been
 | 
			
		||||
                                  initialized.
 | 
			
		||||
  @retval EFI_INVALID_PARAMETER   One or more of the following conditions is TRUE:
 | 
			
		||||
                                  This is NULL.
 | 
			
		||||
                                  Token is NULL.
 | 
			
		||||
                                  Token->Message->Headers is NULL.
 | 
			
		||||
                                  Token->Message is NULL.
 | 
			
		||||
                                  Token->Message->Body is not NULL,
 | 
			
		||||
                                  Token->Message->BodyLength is non-zero, and
 | 
			
		||||
                                  Token->Message->Data is NULL, but a previous call to
 | 
			
		||||
                                  Response() has not been completed successfully.
 | 
			
		||||
  @retval EFI_OUT_OF_RESOURCES    Could not allocate enough system resources.
 | 
			
		||||
  @retval EFI_ACCESS_DENIED       An open TCP connection is not present with the host
 | 
			
		||||
                                  specified by response URL.
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_HTTP_RESPONSE)(
 | 
			
		||||
  IN  EFI_HTTP_PROTOCOL         *This,
 | 
			
		||||
  IN  EFI_HTTP_TOKEN            *Token
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  The Poll() function can be used by network drivers and applications to increase the
 | 
			
		||||
  rate that data packets are moved between the communication devices and the transmit
 | 
			
		||||
  and receive queues.
 | 
			
		||||
 | 
			
		||||
  In some systems, the periodic timer event in the managed network driver may not poll
 | 
			
		||||
  the underlying communications device fast enough to transmit and/or receive all data
 | 
			
		||||
  packets without missing incoming packets or dropping outgoing packets. Drivers and
 | 
			
		||||
  applications that are experiencing packet loss should try calling the Poll() function
 | 
			
		||||
  more often.
 | 
			
		||||
 | 
			
		||||
  @param[in]  This                Pointer to EFI_HTTP_PROTOCOL instance.
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS             Incoming or outgoing data was processed..
 | 
			
		||||
  @retval EFI_DEVICE_ERROR        An unexpected system or network error occurred
 | 
			
		||||
  @retval EFI_INVALID_PARAMETER   This is NULL.
 | 
			
		||||
  @retval EFI_NOT_READY           No incoming or outgoing data is processed.
 | 
			
		||||
  @retval EFI_NOT_STARTED         This EFI HTTP Protocol instance has not been started.
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_HTTP_POLL)(
 | 
			
		||||
  IN  EFI_HTTP_PROTOCOL         *This
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// The EFI HTTP protocol is designed to be used by EFI drivers and applications to
 | 
			
		||||
/// create and transmit HTTP Requests, as well as handle HTTP responses that are
 | 
			
		||||
/// returned by a remote host. This EFI protocol uses and relies on an underlying EFI
 | 
			
		||||
/// TCP protocol.
 | 
			
		||||
///
 | 
			
		||||
struct _EFI_HTTP_PROTOCOL {
 | 
			
		||||
  EFI_HTTP_GET_MODE_DATA    GetModeData;
 | 
			
		||||
  EFI_HTTP_CONFIGURE        Configure;
 | 
			
		||||
  EFI_HTTP_REQUEST          Request;
 | 
			
		||||
  EFI_HTTP_CANCEL           Cancel;
 | 
			
		||||
  EFI_HTTP_RESPONSE         Response;
 | 
			
		||||
  EFI_HTTP_POLL             Poll;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
extern EFI_GUID  gEfiHttpServiceBindingProtocolGuid;
 | 
			
		||||
extern EFI_GUID  gEfiHttpProtocolGuid;
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										318
									
								
								src/include/ipxe/efi/Protocol/Ip4Config2.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										318
									
								
								src/include/ipxe/efi/Protocol/Ip4Config2.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,318 @@
 | 
			
		||||
/** @file
 | 
			
		||||
  This file provides a definition of the EFI IPv4 Configuration II
 | 
			
		||||
  Protocol.
 | 
			
		||||
 | 
			
		||||
Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>
 | 
			
		||||
SPDX-License-Identifier: BSD-2-Clause-Patent
 | 
			
		||||
 | 
			
		||||
@par Revision Reference:
 | 
			
		||||
This Protocol is introduced in UEFI Specification 2.5
 | 
			
		||||
 | 
			
		||||
**/
 | 
			
		||||
 | 
			
		||||
#ifndef __EFI_IP4CONFIG2_PROTOCOL_H__
 | 
			
		||||
#define __EFI_IP4CONFIG2_PROTOCOL_H__
 | 
			
		||||
 | 
			
		||||
FILE_LICENCE ( BSD2_PATENT );
 | 
			
		||||
 | 
			
		||||
#include <ipxe/efi/Protocol/Ip4.h>
 | 
			
		||||
 | 
			
		||||
#define EFI_IP4_CONFIG2_PROTOCOL_GUID \
 | 
			
		||||
  { \
 | 
			
		||||
    0x5b446ed1, 0xe30b, 0x4faa, {0x87, 0x1a, 0x36, 0x54, 0xec, 0xa3, 0x60, 0x80 } \
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
typedef struct _EFI_IP4_CONFIG2_PROTOCOL EFI_IP4_CONFIG2_PROTOCOL;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_IP4_CONFIG2_DATA_TYPE
 | 
			
		||||
///
 | 
			
		||||
typedef enum {
 | 
			
		||||
  ///
 | 
			
		||||
  /// The interface information of the communication device this EFI
 | 
			
		||||
  /// IPv4 Configuration II Protocol instance manages. This type of
 | 
			
		||||
  /// data is read only. The corresponding Data is of type
 | 
			
		||||
  /// EFI_IP4_CONFIG2_INTERFACE_INFO.
 | 
			
		||||
  ///
 | 
			
		||||
  Ip4Config2DataTypeInterfaceInfo,
 | 
			
		||||
  ///
 | 
			
		||||
  /// The general configuration policy for the EFI IPv4 network stack
 | 
			
		||||
  /// running on the communication device this EFI IPv4
 | 
			
		||||
  /// Configuration II Protocol instance manages. The policy will
 | 
			
		||||
  /// affect other configuration settings. The corresponding Data is of
 | 
			
		||||
  /// type EFI_IP4_CONFIG2_POLICY.
 | 
			
		||||
  ///
 | 
			
		||||
  Ip4Config2DataTypePolicy,
 | 
			
		||||
  ///
 | 
			
		||||
  /// The station addresses set manually for the EFI IPv4 network
 | 
			
		||||
  /// stack. It is only configurable when the policy is
 | 
			
		||||
  /// Ip4Config2PolicyStatic. The corresponding Data is of
 | 
			
		||||
  /// type EFI_IP4_CONFIG2_MANUAL_ADDRESS. When DataSize
 | 
			
		||||
  /// is 0 and Data is NULL, the existing configuration is cleared
 | 
			
		||||
  /// from the EFI IPv4 Configuration II Protocol instance.
 | 
			
		||||
  ///
 | 
			
		||||
  Ip4Config2DataTypeManualAddress,
 | 
			
		||||
  ///
 | 
			
		||||
  /// The gateway addresses set manually for the EFI IPv4 network
 | 
			
		||||
  /// stack running on the communication device this EFI IPv4
 | 
			
		||||
  /// Configuration II Protocol manages. It is not configurable when
 | 
			
		||||
  /// the policy is Ip4Config2PolicyDhcp. The gateway
 | 
			
		||||
  /// addresses must be unicast IPv4 addresses. The corresponding
 | 
			
		||||
  /// Data is a pointer to an array of EFI_IPv4_ADDRESS instances.
 | 
			
		||||
  /// When DataSize is 0 and Data is NULL, the existing configuration
 | 
			
		||||
  /// is cleared from the EFI IPv4 Configuration II Protocol instance.
 | 
			
		||||
  ///
 | 
			
		||||
  Ip4Config2DataTypeGateway,
 | 
			
		||||
  ///
 | 
			
		||||
  /// The DNS server list for the EFI IPv4 network stack running on
 | 
			
		||||
  /// the communication device this EFI IPv4 Configuration II
 | 
			
		||||
  /// Protocol manages. It is not configurable when the policy is
 | 
			
		||||
  /// Ip4Config2PolicyDhcp. The DNS server addresses must be
 | 
			
		||||
  /// unicast IPv4 addresses. The corresponding Data is a pointer to
 | 
			
		||||
  /// an array of EFI_IPv4_ADDRESS instances. When DataSize
 | 
			
		||||
  /// is 0 and Data is NULL, the existing configuration is cleared
 | 
			
		||||
  /// from the EFI IPv4 Configuration II Protocol instance.
 | 
			
		||||
  ///
 | 
			
		||||
  Ip4Config2DataTypeDnsServer,
 | 
			
		||||
  Ip4Config2DataTypeMaximum
 | 
			
		||||
} EFI_IP4_CONFIG2_DATA_TYPE;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_IP4_CONFIG2_INTERFACE_INFO related definitions
 | 
			
		||||
///
 | 
			
		||||
#define EFI_IP4_CONFIG2_INTERFACE_INFO_NAME_SIZE  32
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_IP4_CONFIG2_INTERFACE_INFO
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// The name of the interface. It is a NULL-terminated Unicode string.
 | 
			
		||||
  ///
 | 
			
		||||
  CHAR16              Name[EFI_IP4_CONFIG2_INTERFACE_INFO_NAME_SIZE];
 | 
			
		||||
  ///
 | 
			
		||||
  /// The interface type of the network interface. See RFC 1700,
 | 
			
		||||
  /// section "Number Hardware Type".
 | 
			
		||||
  ///
 | 
			
		||||
  UINT8               IfType;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The size, in bytes, of the network interface's hardware address.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32              HwAddressSize;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The hardware address for the network interface.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_MAC_ADDRESS     HwAddress;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The station IPv4 address of this EFI IPv4 network stack.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_IPv4_ADDRESS    StationAddress;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The subnet address mask that is associated with the station address.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_IPv4_ADDRESS    SubnetMask;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Size of the following RouteTable, in bytes. May be zero.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32              RouteTableSize;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The route table of the IPv4 network stack runs on this interface.
 | 
			
		||||
  /// Set to NULL if RouteTableSize is zero. Type EFI_IP4_ROUTE_TABLE is defined in
 | 
			
		||||
  /// EFI_IP4_PROTOCOL.GetModeData().
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_IP4_ROUTE_TABLE   *RouteTable     OPTIONAL;
 | 
			
		||||
} EFI_IP4_CONFIG2_INTERFACE_INFO;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_IP4_CONFIG2_POLICY
 | 
			
		||||
///
 | 
			
		||||
typedef enum {
 | 
			
		||||
  ///
 | 
			
		||||
  /// Under this policy, the Ip4Config2DataTypeManualAddress,
 | 
			
		||||
  /// Ip4Config2DataTypeGateway and Ip4Config2DataTypeDnsServer configuration
 | 
			
		||||
  /// data are required to be set manually. The EFI IPv4 Protocol will get all
 | 
			
		||||
  /// required configuration such as IPv4 address, subnet mask and
 | 
			
		||||
  /// gateway settings from the EFI IPv4 Configuration II protocol.
 | 
			
		||||
  ///
 | 
			
		||||
  Ip4Config2PolicyStatic,
 | 
			
		||||
  ///
 | 
			
		||||
  /// Under this policy, the Ip4Config2DataTypeManualAddress,
 | 
			
		||||
  /// Ip4Config2DataTypeGateway and Ip4Config2DataTypeDnsServer configuration data are
 | 
			
		||||
  /// not allowed to set via SetData(). All of these configurations are retrieved from DHCP
 | 
			
		||||
  /// server or other auto-configuration mechanism.
 | 
			
		||||
  ///
 | 
			
		||||
  Ip4Config2PolicyDhcp,
 | 
			
		||||
  Ip4Config2PolicyMax
 | 
			
		||||
} EFI_IP4_CONFIG2_POLICY;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_IP4_CONFIG2_MANUAL_ADDRESS
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// The IPv4 unicast address.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_IPv4_ADDRESS    Address;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The subnet mask.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_IPv4_ADDRESS    SubnetMask;
 | 
			
		||||
} EFI_IP4_CONFIG2_MANUAL_ADDRESS;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Set the configuration for the EFI IPv4 network stack running on the communication device this EFI
 | 
			
		||||
  IPv4 Configuration II Protocol instance manages.
 | 
			
		||||
 | 
			
		||||
  This function is used to set the configuration data of type DataType for the EFI IPv4 network stack
 | 
			
		||||
  running on the communication device this EFI IPv4 Configuration II Protocol instance manages.
 | 
			
		||||
  The successfully configured data is valid after system reset or power-off.
 | 
			
		||||
  The DataSize is used to calculate the count of structure instances in the Data for some
 | 
			
		||||
  DataType that multiple structure instances are allowed.
 | 
			
		||||
  This function is always non-blocking. When setting some typeof configuration data, an
 | 
			
		||||
  asynchronous process is invoked to check the correctness of the data, such as doing address conflict
 | 
			
		||||
  detection on the manually set local IPv4 address. EFI_NOT_READY is returned immediately to
 | 
			
		||||
  indicate that such an asynchronous process is invoked and the process is not finished yet. The caller
 | 
			
		||||
  willing to get the result of the asynchronous process is required to call RegisterDataNotify()
 | 
			
		||||
  to register an event on the specified configuration data. Once the event is signaled, the caller can call
 | 
			
		||||
  GetData()to get back the configuration data in order to know the result. For other types of
 | 
			
		||||
  configuration data that do not require an asynchronous configuration process, the result of the
 | 
			
		||||
  operation is immediately returned.
 | 
			
		||||
 | 
			
		||||
  @param[in]   This               Pointer to the EFI_IP4_CONFIG2_PROTOCOL instance.
 | 
			
		||||
  @param[in]   DataType           The type of data to set.
 | 
			
		||||
  @param[in]   DataSize           Size of the buffer pointed to by Data in bytes.
 | 
			
		||||
  @param[in]   Data               The data buffer to set. The type ofthe data buffer is associated
 | 
			
		||||
                                  with the DataType.
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS             The specified configuration data for the EFI IPv4 network stack is set
 | 
			
		||||
                                  successfully.
 | 
			
		||||
  @retval EFI_INVALID_PARAMETER   One or more of the following are TRUE:
 | 
			
		||||
                                  This is NULL.
 | 
			
		||||
                                  One or more fields in Data and DataSize do not match the
 | 
			
		||||
                                  requirement of the data type indicated by DataType.
 | 
			
		||||
  @retval EFI_WRITE_PROTECTED     The specified configuration data is read-only or the specified configuration
 | 
			
		||||
                                  data can not be set under the current policy.
 | 
			
		||||
  @retval EFI_ACCESS_DENIED       Another set operation on the specified configuration data is already in process.
 | 
			
		||||
  @retval EFI_NOT_READY           An asynchronous process is invoked to set the specified configuration data and
 | 
			
		||||
                                  the process is not finished yet.
 | 
			
		||||
  @retval EFI_BAD_BUFFER_SIZE     The DataSize does not match the size of the type indicated by DataType.
 | 
			
		||||
  @retval EFI_UNSUPPORTED         This DataType is not supported.
 | 
			
		||||
  @retval EFI_OUT_OF_RESOURCES    Required system resources could not be allocated.
 | 
			
		||||
  @retval EFI_DEVICE_ERROR        An unexpected system error or network error occurred.
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_IP4_CONFIG2_SET_DATA)(
 | 
			
		||||
  IN EFI_IP4_CONFIG2_PROTOCOL   *This,
 | 
			
		||||
  IN EFI_IP4_CONFIG2_DATA_TYPE  DataType,
 | 
			
		||||
  IN UINTN                      DataSize,
 | 
			
		||||
  IN VOID                       *Data
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Get the configuration data for the EFI IPv4 network stack running on the communication device this
 | 
			
		||||
  EFI IPv4 Configuration II Protocol instance manages.
 | 
			
		||||
 | 
			
		||||
  This function returns the configuration data of type DataType for the EFI IPv4 network stack
 | 
			
		||||
  running on the communication device this EFI IPv4 Configuration II Protocol instance manages.
 | 
			
		||||
  The caller is responsible for allocating the buffer usedto return the specified configuration data and
 | 
			
		||||
  the required size will be returned to the caller if the size of the buffer is too small.
 | 
			
		||||
  EFI_NOT_READY is returned if the specified configuration data is not ready due to an already in
 | 
			
		||||
  progress asynchronous configuration process. The caller can call RegisterDataNotify() to
 | 
			
		||||
  register an event on the specified configuration data. Once the asynchronous configuration process is
 | 
			
		||||
  finished, the event will be signaled and a subsequent GetData() call will return the specified
 | 
			
		||||
  configuration data.
 | 
			
		||||
 | 
			
		||||
  @param[in]   This               Pointer to the EFI_IP4_CONFIG2_PROTOCOL instance.
 | 
			
		||||
  @param[in]   DataType           The type of data to get.
 | 
			
		||||
  @param[out]  DataSize           On input, in bytes, the size of Data. On output, in bytes, the size
 | 
			
		||||
                                  of buffer required to store the specified configuration data.
 | 
			
		||||
  @param[in]   Data               The data buffer in which the configuration data is returned. The
 | 
			
		||||
                                  type of the data buffer is associated with the DataType. Ignored
 | 
			
		||||
                                  if DataSize is 0.
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS             The specified configuration data is got successfully.
 | 
			
		||||
  @retval EFI_INVALID_PARAMETER   One or more of the followings are TRUE:
 | 
			
		||||
                                  This is NULL.
 | 
			
		||||
                                  DataSize is NULL.
 | 
			
		||||
                                  Data is NULL if *DataSizeis not zero.
 | 
			
		||||
  @retval EFI_BUFFER_TOO_SMALL    The size of Data is too small for the specified configuration data
 | 
			
		||||
                                  and the required size is returned in DataSize.
 | 
			
		||||
  @retval EFI_NOT_READY           The specified configuration data is not ready due to an already in
 | 
			
		||||
                                  progress asynchronous configuration process.
 | 
			
		||||
  @retval EFI_NOT_FOUND           The specified configuration data is not found.
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_IP4_CONFIG2_GET_DATA)(
 | 
			
		||||
  IN EFI_IP4_CONFIG2_PROTOCOL     *This,
 | 
			
		||||
  IN EFI_IP4_CONFIG2_DATA_TYPE    DataType,
 | 
			
		||||
  IN OUT UINTN                    *DataSize,
 | 
			
		||||
  IN VOID                         *Data        OPTIONAL
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Register an event that is to be signaled whenever a configuration process on the specified
 | 
			
		||||
  configuration data is done.
 | 
			
		||||
 | 
			
		||||
  This function registers an event that is to be signaled whenever a configuration process on the
 | 
			
		||||
  specified configuration data is done. An event can be registered for different DataType
 | 
			
		||||
  simultaneously and the caller is responsible for determining which type of configuration data causes
 | 
			
		||||
  the signaling of the event in such case.
 | 
			
		||||
 | 
			
		||||
  @param[in]   This               Pointer to the EFI_IP4_CONFIG2_PROTOCOL instance.
 | 
			
		||||
  @param[in]   DataType           The type of data to unregister the event for.
 | 
			
		||||
  @param[in]   Event              The event to register.
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS             The notification event for the specified configuration data is
 | 
			
		||||
                                  registered.
 | 
			
		||||
  @retval EFI_INVALID_PARAMETER   This is NULL or Event is NULL.
 | 
			
		||||
  @retval EFI_UNSUPPORTED         The configuration data type specified by DataType is not supported.
 | 
			
		||||
  @retval EFI_OUT_OF_RESOURCES    Required system resources could not be allocated.
 | 
			
		||||
  @retval EFI_ACCESS_DENIED       The Event is already registered for the DataType.
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_IP4_CONFIG2_REGISTER_NOTIFY)(
 | 
			
		||||
  IN EFI_IP4_CONFIG2_PROTOCOL     *This,
 | 
			
		||||
  IN EFI_IP4_CONFIG2_DATA_TYPE    DataType,
 | 
			
		||||
  IN EFI_EVENT                    Event
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Remove a previously registered event for the specified configuration data.
 | 
			
		||||
 | 
			
		||||
  This function removes a previously registeredevent for the specified configuration data.
 | 
			
		||||
 | 
			
		||||
  @param[in]   This               Pointer to the EFI_IP4_CONFIG2_PROTOCOL instance.
 | 
			
		||||
  @param[in]   DataType           The type of data to remove the previously registered event for.
 | 
			
		||||
  @param[in]   Event              The event to unregister.
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS             The event registered for the specified configuration data is removed.
 | 
			
		||||
  @retval EFI_INVALID_PARAMETER   This is NULL or Event is NULL.
 | 
			
		||||
  @retval EFI_NOT_FOUND           The Eventhas not been registered for the specified DataType.
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_IP4_CONFIG2_UNREGISTER_NOTIFY)(
 | 
			
		||||
  IN EFI_IP4_CONFIG2_PROTOCOL     *This,
 | 
			
		||||
  IN EFI_IP4_CONFIG2_DATA_TYPE    DataType,
 | 
			
		||||
  IN EFI_EVENT                    Event
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// The EFI_IP4_CONFIG2_PROTOCOL is designed to be the central repository for the common
 | 
			
		||||
/// configurations and the administrator configurable settings for the EFI IPv4 network stack.
 | 
			
		||||
/// An EFI IPv4 Configuration II Protocol instance will be installed on each communication device that
 | 
			
		||||
/// the EFI IPv4 network stack runs on.
 | 
			
		||||
///
 | 
			
		||||
struct _EFI_IP4_CONFIG2_PROTOCOL {
 | 
			
		||||
  EFI_IP4_CONFIG2_SET_DATA             SetData;
 | 
			
		||||
  EFI_IP4_CONFIG2_GET_DATA             GetData;
 | 
			
		||||
  EFI_IP4_CONFIG2_REGISTER_NOTIFY      RegisterDataNotify;
 | 
			
		||||
  EFI_IP4_CONFIG2_UNREGISTER_NOTIFY    UnregisterDataNotify;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
extern EFI_GUID  gEfiIp4Config2ProtocolGuid;
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										948
									
								
								src/include/ipxe/efi/Protocol/Ip6.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										948
									
								
								src/include/ipxe/efi/Protocol/Ip6.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,948 @@
 | 
			
		||||
/** @file
 | 
			
		||||
  This file defines the EFI IPv6 (Internet Protocol version 6)
 | 
			
		||||
  Protocol interface. It is split into the following three main
 | 
			
		||||
  sections:
 | 
			
		||||
  - EFI IPv6 Service Binding Protocol
 | 
			
		||||
  - EFI IPv6 Variable (deprecated in UEFI 2.4B)
 | 
			
		||||
  - EFI IPv6 Protocol
 | 
			
		||||
  The EFI IPv6 Protocol provides basic network IPv6 packet I/O services,
 | 
			
		||||
  which includes support for Neighbor Discovery Protocol (ND), Multicast
 | 
			
		||||
  Listener Discovery Protocol (MLD), and a subset of the Internet Control
 | 
			
		||||
  Message Protocol (ICMPv6).
 | 
			
		||||
 | 
			
		||||
  Copyright (c) 2008 - 2014, Intel Corporation. All rights reserved.<BR>
 | 
			
		||||
  SPDX-License-Identifier: BSD-2-Clause-Patent
 | 
			
		||||
 | 
			
		||||
  @par Revision Reference:
 | 
			
		||||
  This Protocol is introduced in UEFI Specification 2.2
 | 
			
		||||
 | 
			
		||||
**/
 | 
			
		||||
 | 
			
		||||
#ifndef __EFI_IP6_PROTOCOL_H__
 | 
			
		||||
#define __EFI_IP6_PROTOCOL_H__
 | 
			
		||||
 | 
			
		||||
FILE_LICENCE ( BSD2_PATENT );
 | 
			
		||||
 | 
			
		||||
#include <ipxe/efi/Protocol/ManagedNetwork.h>
 | 
			
		||||
 | 
			
		||||
#define EFI_IP6_SERVICE_BINDING_PROTOCOL_GUID \
 | 
			
		||||
  { \
 | 
			
		||||
    0xec835dd3, 0xfe0f, 0x617b, {0xa6, 0x21, 0xb3, 0x50, 0xc3, 0xe1, 0x33, 0x88 } \
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
#define EFI_IP6_PROTOCOL_GUID \
 | 
			
		||||
  { \
 | 
			
		||||
    0x2c8759d5, 0x5c2d, 0x66ef, {0x92, 0x5f, 0xb6, 0x6c, 0x10, 0x19, 0x57, 0xe2 } \
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
typedef struct _EFI_IP6_PROTOCOL EFI_IP6_PROTOCOL;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_IP6_ADDRESS_PAIR is deprecated in the UEFI 2.4B and should not be used any more.
 | 
			
		||||
/// The definition in here is only present to provide backwards compatability.
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// The EFI IPv6 Protocol instance handle that is using this address/prefix pair.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_HANDLE          InstanceHandle;
 | 
			
		||||
  ///
 | 
			
		||||
  /// IPv6 address in network byte order.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_IPv6_ADDRESS    Ip6Address;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The length of the prefix associated with the Ip6Address.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT8               PrefixLength;
 | 
			
		||||
} EFI_IP6_ADDRESS_PAIR;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_IP6_VARIABLE_DATA is deprecated in the UEFI 2.4B and should not be used any more.
 | 
			
		||||
/// The definition in here is only present to provide backwards compatability.
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// The handle of the driver that creates this entry.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_HANDLE              DriverHandle;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The number of IPv6 address pairs that follow this data structure.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32                  AddressCount;
 | 
			
		||||
  ///
 | 
			
		||||
  /// List of IPv6 address pairs that are currently in use.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_IP6_ADDRESS_PAIR    AddressPairs[1];
 | 
			
		||||
} EFI_IP6_VARIABLE_DATA;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// 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
 | 
			
		||||
///@}
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_IP6_CONFIG_DATA
 | 
			
		||||
/// is used to report and change IPv6 session parameters.
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// For the IPv6 packet to send and receive, this is the default value
 | 
			
		||||
  /// of the 'Next Header' field in the last IPv6 extension header or in
 | 
			
		||||
  /// the IPv6 header if there are no extension headers. Ignored when
 | 
			
		||||
  /// AcceptPromiscuous is TRUE.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT8               DefaultProtocol;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Set to TRUE to receive all IPv6 packets that get through the
 | 
			
		||||
  /// receive filters.
 | 
			
		||||
  /// Set to FALSE to receive only the DefaultProtocol IPv6
 | 
			
		||||
  /// packets that get through the receive filters. Ignored when
 | 
			
		||||
  /// AcceptPromiscuous is TRUE.
 | 
			
		||||
  ///
 | 
			
		||||
  BOOLEAN             AcceptAnyProtocol;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Set to TRUE to receive ICMP error report packets. Ignored when
 | 
			
		||||
  /// AcceptPromiscuous or AcceptAnyProtocol is TRUE.
 | 
			
		||||
  ///
 | 
			
		||||
  BOOLEAN             AcceptIcmpErrors;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Set to TRUE to receive all IPv6 packets that are sent to any
 | 
			
		||||
  /// hardware address or any protocol address. Set to FALSE to stop
 | 
			
		||||
  /// receiving all promiscuous IPv6 packets.
 | 
			
		||||
  ///
 | 
			
		||||
  BOOLEAN             AcceptPromiscuous;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The destination address of the packets that will be transmitted.
 | 
			
		||||
  /// Ignored if it is unspecified.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_IPv6_ADDRESS    DestinationAddress;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The station IPv6 address that will be assigned to this EFI IPv6
 | 
			
		||||
  /// Protocol instance. This field can be set and changed only when
 | 
			
		||||
  /// the EFI IPv6 driver is transitioning from the stopped to the started
 | 
			
		||||
  /// states. If the StationAddress is specified, the EFI IPv6 Protocol
 | 
			
		||||
  /// driver will deliver only incoming IPv6 packets whose destination
 | 
			
		||||
  /// matches this IPv6 address exactly. The StationAddress is required
 | 
			
		||||
  /// to be one of currently configured IPv6 addresses. An address
 | 
			
		||||
  /// containing all zeroes is also accepted as a special case. Under this
 | 
			
		||||
  /// situation, the IPv6 driver is responsible for binding a source
 | 
			
		||||
  /// address to this EFI IPv6 protocol instance according to the source
 | 
			
		||||
  /// address selection algorithm. Only incoming packets destined to
 | 
			
		||||
  /// the selected address will be delivered to the user.  And the
 | 
			
		||||
  /// selected station address can be retrieved through later
 | 
			
		||||
  /// GetModeData() call. If no address is available for selecting,
 | 
			
		||||
  /// EFI_NO_MAPPING will be returned, and the station address will
 | 
			
		||||
  /// only be successfully bound to this EFI IPv6 protocol instance
 | 
			
		||||
  /// after IP6ModeData.IsConfigured changed to TRUE.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_IPv6_ADDRESS    StationAddress;
 | 
			
		||||
  ///
 | 
			
		||||
  /// TrafficClass field in transmitted IPv6 packets. Default value
 | 
			
		||||
  /// is zero.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT8               TrafficClass;
 | 
			
		||||
  ///
 | 
			
		||||
  /// HopLimit field in transmitted IPv6 packets.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT8               HopLimit;
 | 
			
		||||
  ///
 | 
			
		||||
  /// FlowLabel field in transmitted IPv6 packets. Default value is
 | 
			
		||||
  /// zero.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32              FlowLabel;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The timer timeout value (number of microseconds) for the
 | 
			
		||||
  /// receive timeout event to be associated with each assembled
 | 
			
		||||
  /// packet. Zero means do not drop assembled packets.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32              ReceiveTimeout;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The timer timeout value (number of microseconds) for the
 | 
			
		||||
  /// transmit timeout event to be associated with each outgoing
 | 
			
		||||
  /// packet. Zero means do not drop outgoing packets.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32              TransmitTimeout;
 | 
			
		||||
} EFI_IP6_CONFIG_DATA;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_IP6_ADDRESS_INFO
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  EFI_IPv6_ADDRESS    Address;           ///< The IPv6 address.
 | 
			
		||||
  UINT8               PrefixLength;      ///< The length of the prefix associated with the Address.
 | 
			
		||||
} EFI_IP6_ADDRESS_INFO;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_IP6_ROUTE_TABLE
 | 
			
		||||
/// is the entry structure that is used in routing tables
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// The IPv6 address of the gateway to be used as the next hop for
 | 
			
		||||
  /// packets to this prefix. If the IPv6 address is all zeros, then the
 | 
			
		||||
  /// prefix is on-link.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_IPv6_ADDRESS    Gateway;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The destination prefix to be routed.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_IPv6_ADDRESS    Destination;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The length of the prefix associated with the Destination.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT8               PrefixLength;
 | 
			
		||||
} EFI_IP6_ROUTE_TABLE;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_IP6_NEIGHBOR_STATE
 | 
			
		||||
///
 | 
			
		||||
typedef enum {
 | 
			
		||||
  ///
 | 
			
		||||
  /// Address resolution is being performed on this entry. Specially,
 | 
			
		||||
  /// Neighbor Solicitation has been sent to the solicited-node
 | 
			
		||||
  /// multicast address of the target, but corresponding Neighbor
 | 
			
		||||
  /// Advertisement has not been received.
 | 
			
		||||
  ///
 | 
			
		||||
  EfiNeighborInComplete,
 | 
			
		||||
  ///
 | 
			
		||||
  /// Positive confirmation was received that the forward path to the
 | 
			
		||||
  /// neighbor was functioning properly.
 | 
			
		||||
  ///
 | 
			
		||||
  EfiNeighborReachable,
 | 
			
		||||
  ///
 | 
			
		||||
  /// Reachable Time has elapsed since the last positive confirmation
 | 
			
		||||
  /// was received. In this state, the forward path to the neighbor was
 | 
			
		||||
  /// functioning properly.
 | 
			
		||||
  ///
 | 
			
		||||
  EfiNeighborStale,
 | 
			
		||||
  ///
 | 
			
		||||
  /// This state is an optimization that gives upper-layer protocols
 | 
			
		||||
  /// additional time to provide reachability confirmation.
 | 
			
		||||
  ///
 | 
			
		||||
  EfiNeighborDelay,
 | 
			
		||||
  ///
 | 
			
		||||
  /// A reachability confirmation is actively sought by retransmitting
 | 
			
		||||
  /// Neighbor Solicitations every RetransTimer milliseconds until a
 | 
			
		||||
  /// reachability confirmation is received.
 | 
			
		||||
  ///
 | 
			
		||||
  EfiNeighborProbe
 | 
			
		||||
} EFI_IP6_NEIGHBOR_STATE;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_IP6_NEIGHBOR_CACHE
 | 
			
		||||
/// is the entry structure that is used in neighbor cache. It records a set
 | 
			
		||||
/// of entries about individual neighbors to which traffic has been sent recently.
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  EFI_IPv6_ADDRESS          Neighbor;    ///< The on-link unicast/anycast IP address of the neighbor.
 | 
			
		||||
  EFI_MAC_ADDRESS           LinkAddress; ///< Link-layer address of the neighbor.
 | 
			
		||||
  EFI_IP6_NEIGHBOR_STATE    State;       ///< State of this neighbor cache entry.
 | 
			
		||||
} EFI_IP6_NEIGHBOR_CACHE;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_IP6_ICMP_TYPE
 | 
			
		||||
/// is used to describe those ICMP messages that are supported by this EFI
 | 
			
		||||
/// IPv6 Protocol driver.
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  UINT8    Type;                  ///< The type of ICMP message.
 | 
			
		||||
  UINT8    Code;                  ///< The code of the ICMP message.
 | 
			
		||||
} EFI_IP6_ICMP_TYPE;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_IP6_MODE_DATA
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// Set to TRUE after this EFI IPv6 Protocol instance is started.
 | 
			
		||||
  /// All other fields in this structure are undefined until this field is TRUE.
 | 
			
		||||
  /// Set to FALSE when the EFI IPv6 Protocol instance is stopped.
 | 
			
		||||
  ///
 | 
			
		||||
  BOOLEAN                   IsStarted;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The maximum packet size, in bytes, of the packet which the upper layer driver could feed.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32                    MaxPacketSize;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Current configuration settings. Undefined until IsStarted is TRUE.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_IP6_CONFIG_DATA       ConfigData;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Set to TRUE when the EFI IPv6 Protocol instance is configured.
 | 
			
		||||
  /// The instance is configured when it has a station address and
 | 
			
		||||
  /// corresponding prefix length.
 | 
			
		||||
  /// Set to FALSE when the EFI IPv6 Protocol instance is not configured.
 | 
			
		||||
  ///
 | 
			
		||||
  BOOLEAN                   IsConfigured;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Number of configured IPv6 addresses on this interface.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32                    AddressCount;
 | 
			
		||||
  ///
 | 
			
		||||
  /// List of currently configured IPv6 addresses and corresponding
 | 
			
		||||
  /// prefix lengths assigned to this interface. It is caller's
 | 
			
		||||
  /// responsibility to free this buffer.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_IP6_ADDRESS_INFO      *AddressList;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Number of joined multicast groups. Undefined until
 | 
			
		||||
  /// IsConfigured is TRUE.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32                    GroupCount;
 | 
			
		||||
  ///
 | 
			
		||||
  /// List of joined multicast group addresses. It is caller's
 | 
			
		||||
  /// responsibility to free this buffer. Undefined until
 | 
			
		||||
  /// IsConfigured is TRUE.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_IPv6_ADDRESS          *GroupTable;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Number of entries in the routing table. Undefined until
 | 
			
		||||
  /// IsConfigured is TRUE.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32                    RouteCount;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Routing table entries. It is caller's responsibility to free this buffer.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_IP6_ROUTE_TABLE       *RouteTable;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Number of entries in the neighbor cache. Undefined until
 | 
			
		||||
  /// IsConfigured is TRUE.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32                    NeighborCount;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Neighbor cache entries. It is caller's responsibility to free this
 | 
			
		||||
  /// buffer. Undefined until IsConfigured is TRUE.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_IP6_NEIGHBOR_CACHE    *NeighborCache;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Number of entries in the prefix table. Undefined until
 | 
			
		||||
  /// IsConfigured is TRUE.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32                    PrefixCount;
 | 
			
		||||
  ///
 | 
			
		||||
  /// On-link Prefix table entries. It is caller's responsibility to free this
 | 
			
		||||
  /// buffer. Undefined until IsConfigured is TRUE.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_IP6_ADDRESS_INFO      *PrefixTable;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Number of entries in the supported ICMP types list.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32                    IcmpTypeCount;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Array of ICMP types and codes that are supported by this EFI
 | 
			
		||||
  /// IPv6 Protocol driver. It is caller's responsibility to free this
 | 
			
		||||
  /// buffer.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_IP6_ICMP_TYPE         *IcmpTypeList;
 | 
			
		||||
} EFI_IP6_MODE_DATA;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_IP6_HEADER
 | 
			
		||||
/// The fields in the IPv6 header structure are defined in the Internet
 | 
			
		||||
/// Protocol version6 specification.
 | 
			
		||||
///
 | 
			
		||||
#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()
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_IP6_FRAGMENT_DATA
 | 
			
		||||
/// describes the location and length of the IPv6 packet
 | 
			
		||||
/// fragment to transmit or that has been received.
 | 
			
		||||
///
 | 
			
		||||
typedef struct _EFI_IP6_FRAGMENT_DATA {
 | 
			
		||||
  UINT32    FragmentLength;                ///< Length of fragment data. This field may not be set to zero.
 | 
			
		||||
  VOID      *FragmentBuffer;               ///< Pointer to fragment data. This field may not be set to NULL.
 | 
			
		||||
} EFI_IP6_FRAGMENT_DATA;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_IP6_RECEIVE_DATA
 | 
			
		||||
///
 | 
			
		||||
typedef struct _EFI_IP6_RECEIVE_DATA {
 | 
			
		||||
  ///
 | 
			
		||||
  /// Time when the EFI IPv6 Protocol driver accepted the packet.
 | 
			
		||||
  /// Ignored if it is zero.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_TIME                 TimeStamp;
 | 
			
		||||
  ///
 | 
			
		||||
  /// After this event is signaled, the receive data structure is released
 | 
			
		||||
  /// and must not be referenced.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_EVENT                RecycleSignal;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Length of the IPv6 packet headers, including both the IPv6
 | 
			
		||||
  /// header and any extension headers.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32                   HeaderLength;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Pointer to the IPv6 packet header. If the IPv6 packet was
 | 
			
		||||
  /// fragmented, this argument is a pointer to the header in the first
 | 
			
		||||
  /// fragment.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_IP6_HEADER           *Header;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Sum of the lengths of IPv6 packet buffers in FragmentTable. May
 | 
			
		||||
  /// be zero.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32                   DataLength;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Number of IPv6 payload fragments. May be zero.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32                   FragmentCount;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Array of payload fragment lengths and buffer pointers.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_IP6_FRAGMENT_DATA    FragmentTable[1];
 | 
			
		||||
} EFI_IP6_RECEIVE_DATA;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_IP6_OVERRIDE_DATA
 | 
			
		||||
/// The information and flags in the override data structure will override
 | 
			
		||||
/// default parameters or settings for one Transmit() function call.
 | 
			
		||||
///
 | 
			
		||||
typedef struct _EFI_IP6_OVERRIDE_DATA {
 | 
			
		||||
  UINT8     Protocol;                 ///< Protocol type override.
 | 
			
		||||
  UINT8     HopLimit;                 ///< Hop-Limit override.
 | 
			
		||||
  UINT32    FlowLabel;                ///< Flow-Label override.
 | 
			
		||||
} EFI_IP6_OVERRIDE_DATA;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_IP6_TRANSMIT_DATA
 | 
			
		||||
///
 | 
			
		||||
typedef struct _EFI_IP6_TRANSMIT_DATA {
 | 
			
		||||
  ///
 | 
			
		||||
  /// The destination IPv6 address.  If it is unspecified,
 | 
			
		||||
  /// ConfigData.DestinationAddress will be used instead.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_IPv6_ADDRESS         DestinationAddress;
 | 
			
		||||
  ///
 | 
			
		||||
  /// If not NULL, the IPv6 transmission control override data.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_IP6_OVERRIDE_DATA    *OverrideData;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Total length in byte of the IPv6 extension headers specified in
 | 
			
		||||
  /// ExtHdrs.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32                   ExtHdrsLength;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Pointer to the IPv6 extension headers. The IP layer will append
 | 
			
		||||
  /// the required extension headers if they are not specified by
 | 
			
		||||
  /// ExtHdrs. Ignored if ExtHdrsLength is zero.
 | 
			
		||||
  ///
 | 
			
		||||
  VOID                     *ExtHdrs;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The protocol of first extension header in ExtHdrs. Ignored if
 | 
			
		||||
  /// ExtHdrsLength is zero.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT8                    NextHeader;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Total length in bytes of the FragmentTable data to transmit.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32                   DataLength;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Number of entries in the fragment data table.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32                   FragmentCount;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Start of the fragment data table.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_IP6_FRAGMENT_DATA    FragmentTable[1];
 | 
			
		||||
} EFI_IP6_TRANSMIT_DATA;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_IP6_COMPLETION_TOKEN
 | 
			
		||||
/// structures are used for both transmit and receive operations.
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// This Event will be signaled after the Status field is updated by
 | 
			
		||||
  /// the EFI IPv6 Protocol driver. The type of Event must be EFI_NOTIFY_SIGNAL.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_EVENT    Event;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Will be set to one of the following values:
 | 
			
		||||
  /// - EFI_SUCCESS:  The receive or transmit completed
 | 
			
		||||
  ///   successfully.
 | 
			
		||||
  /// - EFI_ABORTED:  The receive or transmit was aborted
 | 
			
		||||
  /// - EFI_TIMEOUT:  The transmit timeout expired.
 | 
			
		||||
  /// - EFI_ICMP_ERROR:  An ICMP error packet was received.
 | 
			
		||||
  /// - EFI_DEVICE_ERROR:  An unexpected system or network
 | 
			
		||||
  ///   error occurred.
 | 
			
		||||
  /// - EFI_SECURITY_VIOLATION: The transmit or receive was
 | 
			
		||||
  ///   failed because of an IPsec policy check.
 | 
			
		||||
  /// - EFI_NO_MEDIA: There was a media error.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_STATUS    Status;
 | 
			
		||||
  union {
 | 
			
		||||
    ///
 | 
			
		||||
    /// When the Token is used for receiving, RxData is a pointer to the EFI_IP6_RECEIVE_DATA.
 | 
			
		||||
    ///
 | 
			
		||||
    EFI_IP6_RECEIVE_DATA     *RxData;
 | 
			
		||||
    ///
 | 
			
		||||
    /// When the Token is used for transmitting, TxData is a pointer to the EFI_IP6_TRANSMIT_DATA.
 | 
			
		||||
    ///
 | 
			
		||||
    EFI_IP6_TRANSMIT_DATA    *TxData;
 | 
			
		||||
  } Packet;
 | 
			
		||||
} EFI_IP6_COMPLETION_TOKEN;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Gets the current operational settings for this instance of the EFI IPv6 Protocol driver.
 | 
			
		||||
 | 
			
		||||
  The GetModeData() function returns the current operational mode data for this driver instance.
 | 
			
		||||
  The data fields in EFI_IP6_MODE_DATA are read only. This function is used optionally to
 | 
			
		||||
  retrieve the operational mode data of underlying networks or drivers..
 | 
			
		||||
 | 
			
		||||
  @param[in]  This               Pointer to the EFI_IP6_PROTOCOL instance.
 | 
			
		||||
  @param[out] Ip6ModeData        Pointer to the EFI IPv6 Protocol mode data structure.
 | 
			
		||||
  @param[out] MnpConfigData      Pointer to the managed network configuration data structure.
 | 
			
		||||
  @param[out] SnpModeData        Pointer to the simple network mode data structure.
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS            The operation completed successfully.
 | 
			
		||||
  @retval EFI_INVALID_PARAMETER  This is NULL.
 | 
			
		||||
  @retval EFI_OUT_OF_RESOURCES   The required mode data could not be allocated.
 | 
			
		||||
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_IP6_GET_MODE_DATA)(
 | 
			
		||||
  IN EFI_IP6_PROTOCOL                 *This,
 | 
			
		||||
  OUT EFI_IP6_MODE_DATA               *Ip6ModeData     OPTIONAL,
 | 
			
		||||
  OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData   OPTIONAL,
 | 
			
		||||
  OUT EFI_SIMPLE_NETWORK_MODE         *SnpModeData     OPTIONAL
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Assigns an IPv6 address and subnet mask to this EFI IPv6 Protocol driver instance.
 | 
			
		||||
 | 
			
		||||
  The Configure() function is used to set, change, or reset the operational parameters and filter
 | 
			
		||||
  settings for this EFI IPv6 Protocol instance. Until these parameters have been set, no network traffic
 | 
			
		||||
  can be sent or received by this instance. Once the parameters have been reset (by calling this
 | 
			
		||||
  function with Ip6ConfigData set to NULL), no more traffic can be sent or received until these
 | 
			
		||||
  parameters have been set again. Each EFI IPv6 Protocol instance can be started and stopped
 | 
			
		||||
  independently of each other by enabling or disabling their receive filter settings with the
 | 
			
		||||
  Configure() function.
 | 
			
		||||
 | 
			
		||||
  If Ip6ConfigData.StationAddress is a valid non-zero IPv6 unicast address, it is required
 | 
			
		||||
  to be one of the currently configured IPv6 addresses list in the EFI IPv6 drivers, or else
 | 
			
		||||
  EFI_INVALID_PARAMETER will be returned. If Ip6ConfigData.StationAddress is
 | 
			
		||||
  unspecified, the IPv6 driver will bind a source address according to the source address selection
 | 
			
		||||
  algorithm. Clients could frequently call GetModeData() to check get currently configured IPv6
 | 
			
		||||
  address list in the EFI IPv6 driver. If both Ip6ConfigData.StationAddress and
 | 
			
		||||
  Ip6ConfigData.Destination are unspecified, when transmitting the packet afterwards, the
 | 
			
		||||
  source address filled in each outgoing IPv6 packet is decided based on the destination of this packet. .
 | 
			
		||||
 | 
			
		||||
  If operational parameters are reset or changed, any pending transmit and receive requests will be
 | 
			
		||||
  cancelled. Their completion token status will be set to EFI_ABORTED and their events will be
 | 
			
		||||
  signaled.
 | 
			
		||||
 | 
			
		||||
  @param[in]  This               Pointer to the EFI_IP6_PROTOCOL instance.
 | 
			
		||||
  @param[in]  Ip6ConfigData      Pointer to the EFI IPv6 Protocol configuration data structure.
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS            The driver instance was successfully opened.
 | 
			
		||||
  @retval EFI_INVALID_PARAMETER  One or more of the following conditions is TRUE:
 | 
			
		||||
                                 - This is NULL.
 | 
			
		||||
                                 - Ip6ConfigData.StationAddress is neither zero nor
 | 
			
		||||
                                   a unicast IPv6 address.
 | 
			
		||||
                                 - Ip6ConfigData.StationAddress is neither zero nor
 | 
			
		||||
                                   one of the configured IP addresses in the EFI IPv6 driver.
 | 
			
		||||
                                 - Ip6ConfigData.DefaultProtocol is illegal.
 | 
			
		||||
  @retval EFI_OUT_OF_RESOURCES   The EFI IPv6 Protocol driver instance data could not be allocated.
 | 
			
		||||
  @retval EFI_NO_MAPPING         The IPv6 driver was responsible for choosing a source address for
 | 
			
		||||
                                 this instance, but no source address was available for use.
 | 
			
		||||
  @retval EFI_ALREADY_STARTED    The interface is already open and must be stopped before the IPv6
 | 
			
		||||
                                 address or prefix length can be changed.
 | 
			
		||||
  @retval EFI_DEVICE_ERROR       An unexpected system or network error occurred. The EFI IPv6
 | 
			
		||||
                                 Protocol driver instance is not opened.
 | 
			
		||||
  @retval EFI_UNSUPPORTED        Default protocol specified through
 | 
			
		||||
                                 Ip6ConfigData.DefaulProtocol isn't supported.
 | 
			
		||||
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_IP6_CONFIGURE)(
 | 
			
		||||
  IN EFI_IP6_PROTOCOL            *This,
 | 
			
		||||
  IN EFI_IP6_CONFIG_DATA         *Ip6ConfigData OPTIONAL
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Joins and leaves multicast groups.
 | 
			
		||||
 | 
			
		||||
  The Groups() function is used to join and leave multicast group sessions. Joining a group will
 | 
			
		||||
  enable reception of matching multicast packets. Leaving a group will disable reception of matching
 | 
			
		||||
  multicast packets. Source-Specific Multicast isn't required to be supported.
 | 
			
		||||
 | 
			
		||||
  If JoinFlag is FALSE and GroupAddress is NULL, all joined groups will be left.
 | 
			
		||||
 | 
			
		||||
  @param[in]  This               Pointer to the EFI_IP6_PROTOCOL instance.
 | 
			
		||||
  @param[in]  JoinFlag           Set to TRUE to join the multicast group session and FALSE to leave.
 | 
			
		||||
  @param[in]  GroupAddress       Pointer to the IPv6 multicast address.
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS            The operation completed successfully.
 | 
			
		||||
  @retval EFI_INVALID_PARAMETER  One or more of the following is TRUE:
 | 
			
		||||
                                 - This is NULL.
 | 
			
		||||
                                 - JoinFlag is TRUE and GroupAddress is NULL.
 | 
			
		||||
                                 - GroupAddress is not NULL and *GroupAddress is
 | 
			
		||||
                                   not a multicast IPv6 address.
 | 
			
		||||
                                 - GroupAddress is not NULL and *GroupAddress is in the
 | 
			
		||||
                                   range of SSM destination address.
 | 
			
		||||
  @retval EFI_NOT_STARTED        This instance has not been started.
 | 
			
		||||
  @retval EFI_OUT_OF_RESOURCES   System resources could not be allocated.
 | 
			
		||||
  @retval EFI_UNSUPPORTED        This EFI IPv6 Protocol implementation does not support multicast groups.
 | 
			
		||||
  @retval EFI_ALREADY_STARTED    The group address is already in the group table (when
 | 
			
		||||
                                 JoinFlag is TRUE).
 | 
			
		||||
  @retval EFI_NOT_FOUND          The group address is not in the group table (when JoinFlag is FALSE).
 | 
			
		||||
  @retval EFI_DEVICE_ERROR       An unexpected system or network error occurred.
 | 
			
		||||
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_IP6_GROUPS)(
 | 
			
		||||
  IN EFI_IP6_PROTOCOL            *This,
 | 
			
		||||
  IN BOOLEAN                     JoinFlag,
 | 
			
		||||
  IN EFI_IPv6_ADDRESS            *GroupAddress  OPTIONAL
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Adds and deletes routing table entries.
 | 
			
		||||
 | 
			
		||||
  The Routes() function adds a route to or deletes a route from the routing table.
 | 
			
		||||
 | 
			
		||||
  Routes are determined by comparing the leftmost PrefixLength bits of Destination with
 | 
			
		||||
  the destination IPv6 address arithmetically. The gateway address must be on the same subnet as the
 | 
			
		||||
  configured station address.
 | 
			
		||||
 | 
			
		||||
  The default route is added with Destination and PrefixLegth both set to all zeros. The
 | 
			
		||||
  default route matches all destination IPv6 addresses that do not match any other routes.
 | 
			
		||||
 | 
			
		||||
  All EFI IPv6 Protocol instances share a routing table.
 | 
			
		||||
 | 
			
		||||
  @param[in]  This               Pointer to the EFI_IP6_PROTOCOL instance.
 | 
			
		||||
  @param[in]  DeleteRoute        Set to TRUE to delete this route from the routing table. Set to
 | 
			
		||||
                                 FALSE to add this route to the routing table. Destination,
 | 
			
		||||
                                 PrefixLength and Gateway are used as the key to each
 | 
			
		||||
                                 route entry.
 | 
			
		||||
  @param[in]  Destination        The address prefix of the subnet that needs to be routed.
 | 
			
		||||
  @param[in]  PrefixLength       The prefix length of Destination. Ignored if Destination
 | 
			
		||||
                                 is NULL.
 | 
			
		||||
  @param[in]  GatewayAddress     The unicast gateway IPv6 address for this route.
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS            The operation completed successfully.
 | 
			
		||||
  @retval EFI_NOT_STARTED        The driver instance has not been started.
 | 
			
		||||
  @retval EFI_INVALID_PARAMETER  One or more of the following conditions is TRUE:
 | 
			
		||||
                                 - This is NULL.
 | 
			
		||||
                                 - When DeleteRoute is TRUE, both Destination and
 | 
			
		||||
                                   GatewayAddress are NULL.
 | 
			
		||||
                                 - When DeleteRoute is FALSE, either Destination or
 | 
			
		||||
                                   GatewayAddress is NULL.
 | 
			
		||||
                                 - *GatewayAddress is not a valid unicast IPv6 address.
 | 
			
		||||
                                 - *GatewayAddress is one of the local configured IPv6
 | 
			
		||||
                                   addresses.
 | 
			
		||||
  @retval EFI_OUT_OF_RESOURCES   Could not add the entry to the routing table.
 | 
			
		||||
  @retval EFI_NOT_FOUND          This route is not in the routing table (when DeleteRoute is TRUE).
 | 
			
		||||
  @retval EFI_ACCESS_DENIED      The route is already defined in the routing table (when
 | 
			
		||||
                                 DeleteRoute is FALSE).
 | 
			
		||||
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_IP6_ROUTES)(
 | 
			
		||||
  IN EFI_IP6_PROTOCOL            *This,
 | 
			
		||||
  IN BOOLEAN                     DeleteRoute,
 | 
			
		||||
  IN EFI_IPv6_ADDRESS            *Destination OPTIONAL,
 | 
			
		||||
  IN UINT8                       PrefixLength,
 | 
			
		||||
  IN EFI_IPv6_ADDRESS            *GatewayAddress OPTIONAL
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Add or delete Neighbor cache entries.
 | 
			
		||||
 | 
			
		||||
  The Neighbors() function is used to add, update, or delete an entry from neighbor cache.
 | 
			
		||||
  IPv6 neighbor cache entries are typically inserted and updated by the network protocol driver as
 | 
			
		||||
  network traffic is processed. Most neighbor cache entries will time out and be deleted if the network
 | 
			
		||||
  traffic stops. Neighbor cache entries that were inserted by Neighbors() may be static (will not
 | 
			
		||||
  timeout) or dynamic (will time out).
 | 
			
		||||
 | 
			
		||||
  The implementation should follow the neighbor cache timeout mechanism which is defined in
 | 
			
		||||
  RFC4861. The default neighbor cache timeout value should be tuned for the expected network
 | 
			
		||||
  environment
 | 
			
		||||
 | 
			
		||||
  @param[in]  This               Pointer to the EFI_IP6_PROTOCOL instance.
 | 
			
		||||
  @param[in]  DeleteFlag         Set to TRUE to delete the specified cache entry, set to FALSE to
 | 
			
		||||
                                 add (or update, if it already exists and Override is TRUE) the
 | 
			
		||||
                                 specified cache entry. TargetIp6Address is used as the key
 | 
			
		||||
                                 to find the requested cache entry.
 | 
			
		||||
  @param[in]  TargetIp6Address   Pointer to Target IPv6 address.
 | 
			
		||||
  @param[in]  TargetLinkAddress  Pointer to link-layer address of the target. Ignored if NULL.
 | 
			
		||||
  @param[in]  Timeout            Time in 100-ns units that this entry will remain in the neighbor
 | 
			
		||||
                                 cache, it will be deleted after Timeout. A value of zero means that
 | 
			
		||||
                                 the entry is permanent. A non-zero value means that the entry is
 | 
			
		||||
                                 dynamic.
 | 
			
		||||
  @param[in]  Override           If TRUE, the cached link-layer address of the matching entry will
 | 
			
		||||
                                 be overridden and updated; if FALSE, EFI_ACCESS_DENIED
 | 
			
		||||
                                 will be returned if a corresponding cache entry already existed.
 | 
			
		||||
 | 
			
		||||
  @retval  EFI_SUCCESS           The data has been queued for transmission.
 | 
			
		||||
  @retval  EFI_NOT_STARTED       This instance has not been started.
 | 
			
		||||
  @retval  EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
 | 
			
		||||
                                 - This is NULL.
 | 
			
		||||
                                 - TargetIpAddress is NULL.
 | 
			
		||||
                                 - *TargetLinkAddress is invalid when not NULL.
 | 
			
		||||
                                 - *TargetIpAddress is not a valid unicast IPv6 address.
 | 
			
		||||
                                 - *TargetIpAddress is one of the local configured IPv6
 | 
			
		||||
                                   addresses.
 | 
			
		||||
  @retval  EFI_OUT_OF_RESOURCES  Could not add the entry to the neighbor cache.
 | 
			
		||||
  @retval  EFI_NOT_FOUND         This entry is not in the neighbor cache (when DeleteFlag  is
 | 
			
		||||
                                 TRUE or when DeleteFlag  is FALSE while
 | 
			
		||||
                                 TargetLinkAddress is NULL.).
 | 
			
		||||
  @retval  EFI_ACCESS_DENIED     The to-be-added entry is already defined in the neighbor cache,
 | 
			
		||||
                                 and that entry is tagged as un-overridden (when DeleteFlag
 | 
			
		||||
                                 is FALSE).
 | 
			
		||||
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_IP6_NEIGHBORS)(
 | 
			
		||||
  IN EFI_IP6_PROTOCOL            *This,
 | 
			
		||||
  IN BOOLEAN                     DeleteFlag,
 | 
			
		||||
  IN EFI_IPv6_ADDRESS            *TargetIp6Address,
 | 
			
		||||
  IN EFI_MAC_ADDRESS             *TargetLinkAddress,
 | 
			
		||||
  IN UINT32                      Timeout,
 | 
			
		||||
  IN BOOLEAN                     Override
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Places outgoing data packets into the transmit queue.
 | 
			
		||||
 | 
			
		||||
  The Transmit() function places a sending request in the transmit queue of this
 | 
			
		||||
  EFI IPv6 Protocol instance. Whenever the packet in the token is sent out or some
 | 
			
		||||
  errors occur, the event in the token will be signaled and the status is updated.
 | 
			
		||||
 | 
			
		||||
  @param[in]  This               Pointer to the EFI_IP6_PROTOCOL instance.
 | 
			
		||||
  @param[in]  Token              Pointer to the transmit token.
 | 
			
		||||
 | 
			
		||||
  @retval  EFI_SUCCESS           The data has been queued for transmission.
 | 
			
		||||
  @retval  EFI_NOT_STARTED       This instance has not been started.
 | 
			
		||||
  @retval  EFI_NO_MAPPING        The IPv6 driver was responsible for choosing a source address for
 | 
			
		||||
                                 this transmission, but no source address was available for use.
 | 
			
		||||
  @retval  EFI_INVALID_PARAMETER One or more of the following is TRUE:
 | 
			
		||||
                                 - This is NULL.
 | 
			
		||||
                                 - Token is NULL.
 | 
			
		||||
                                 - Token.Event is NULL.
 | 
			
		||||
                                 - Token.Packet.TxData is NULL.
 | 
			
		||||
                                 - Token.Packet.ExtHdrsLength is not zero and Token.Packet.ExtHdrs is NULL.
 | 
			
		||||
                                 - Token.Packet.FragmentCount is zero.
 | 
			
		||||
                                 - One or more of the Token.Packet.TxData.FragmentTable[].FragmentLength fields is zero.
 | 
			
		||||
                                 - One or more of the Token.Packet.TxData.FragmentTable[].FragmentBuffer fields is NULL.
 | 
			
		||||
                                 - Token.Packet.TxData.DataLength is zero or not equal to the sum of fragment lengths.
 | 
			
		||||
                                 - Token.Packet.TxData.DestinationAddress is non-zero when DestinationAddress is configured as
 | 
			
		||||
                                   non-zero when doing Configure() for this EFI IPv6 protocol instance.
 | 
			
		||||
                                 - Token.Packet.TxData.DestinationAddress is unspecified when DestinationAddress is unspecified
 | 
			
		||||
                                   when doing Configure() for this EFI IPv6 protocol instance.
 | 
			
		||||
  @retval  EFI_ACCESS_DENIED     The transmit completion token with the same Token.Event
 | 
			
		||||
                                 was already in the transmit queue.
 | 
			
		||||
  @retval  EFI_NOT_READY         The completion token could not be queued because the transmit
 | 
			
		||||
                                 queue is full.
 | 
			
		||||
  @retval  EFI_NOT_FOUND         Not route is found to destination address.
 | 
			
		||||
  @retval  EFI_OUT_OF_RESOURCES  Could not queue the transmit data.
 | 
			
		||||
  @retval  EFI_BUFFER_TOO_SMALL  Token.Packet.TxData.TotalDataLength is too
 | 
			
		||||
                                 short to transmit.
 | 
			
		||||
  @retval  EFI_BAD_BUFFER_SIZE   If Token.Packet.TxData.DataLength is beyond the
 | 
			
		||||
                                 maximum that which can be described through the Fragment Offset
 | 
			
		||||
                                 field in Fragment header when performing fragmentation.
 | 
			
		||||
  @retval EFI_DEVICE_ERROR       An unexpected system or network error occurred.
 | 
			
		||||
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_IP6_TRANSMIT)(
 | 
			
		||||
  IN EFI_IP6_PROTOCOL            *This,
 | 
			
		||||
  IN EFI_IP6_COMPLETION_TOKEN    *Token
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Places a receiving request into the receiving queue.
 | 
			
		||||
 | 
			
		||||
  The Receive() function places a completion token into the receive packet queue.
 | 
			
		||||
  This function is always asynchronous.
 | 
			
		||||
 | 
			
		||||
  The Token.Event field in the completion token must be filled in by the caller
 | 
			
		||||
  and cannot be NULL. When the receive operation completes, the EFI IPv6 Protocol
 | 
			
		||||
  driver updates the Token.Status and Token.Packet.RxData fields and the Token.Event
 | 
			
		||||
  is signaled.
 | 
			
		||||
 | 
			
		||||
  @param[in]  This               Pointer to the EFI_IP6_PROTOCOL instance.
 | 
			
		||||
  @param[in]  Token              Pointer to a token that is associated with the receive data descriptor.
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS            The receive completion token was cached.
 | 
			
		||||
  @retval EFI_NOT_STARTED        This EFI IPv6 Protocol instance has not been started.
 | 
			
		||||
  @retval EFI_NO_MAPPING         When IP6 driver responsible for binding source address to this instance,
 | 
			
		||||
                                 while no source address is available for use.
 | 
			
		||||
  @retval EFI_INVALID_PARAMETER  One or more of the following conditions is TRUE:
 | 
			
		||||
                                 - This is NULL.
 | 
			
		||||
                                 - Token is NULL.
 | 
			
		||||
                                 - Token.Event is NULL.
 | 
			
		||||
  @retval EFI_OUT_OF_RESOURCES   The receive completion token could not be queued due to a lack of system
 | 
			
		||||
                                 resources (usually memory).
 | 
			
		||||
  @retval EFI_DEVICE_ERROR       An unexpected system or network error occurred.
 | 
			
		||||
                                 The EFI IPv6 Protocol instance has been reset to startup defaults.
 | 
			
		||||
  @retval EFI_ACCESS_DENIED      The receive completion token with the same Token.Event was already
 | 
			
		||||
                                 in the receive queue.
 | 
			
		||||
  @retval EFI_NOT_READY          The receive request could not be queued because the receive queue is full.
 | 
			
		||||
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_IP6_RECEIVE)(
 | 
			
		||||
  IN EFI_IP6_PROTOCOL            *This,
 | 
			
		||||
  IN EFI_IP6_COMPLETION_TOKEN    *Token
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Abort an asynchronous transmit or receive request.
 | 
			
		||||
 | 
			
		||||
  The Cancel() function is used to abort a pending transmit or receive request.
 | 
			
		||||
  If the token is in the transmit or receive request queues, after calling this
 | 
			
		||||
  function, Token->Status will be set to EFI_ABORTED and then Token->Event will
 | 
			
		||||
  be signaled. If the token is not in one of the queues, which usually means the
 | 
			
		||||
  asynchronous operation has completed, this function will not signal the token
 | 
			
		||||
  and EFI_NOT_FOUND is returned.
 | 
			
		||||
 | 
			
		||||
  @param[in]  This               Pointer to the EFI_IP6_PROTOCOL instance.
 | 
			
		||||
  @param[in]  Token              Pointer to a token that has been issued by
 | 
			
		||||
                                 EFI_IP6_PROTOCOL.Transmit() or
 | 
			
		||||
                                 EFI_IP6_PROTOCOL.Receive(). If NULL, all pending
 | 
			
		||||
                                 tokens are aborted. Type EFI_IP6_COMPLETION_TOKEN is
 | 
			
		||||
                                 defined in EFI_IP6_PROTOCOL.Transmit().
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS            The asynchronous I/O request was aborted and
 | 
			
		||||
                                 Token->Event was signaled. When Token is NULL, all
 | 
			
		||||
                                 pending requests were aborted and their events were signaled.
 | 
			
		||||
  @retval EFI_INVALID_PARAMETER  This is NULL.
 | 
			
		||||
  @retval EFI_NOT_STARTED        This instance has not been started.
 | 
			
		||||
  @retval EFI_NOT_FOUND          When Token is not NULL, the asynchronous I/O request was
 | 
			
		||||
                                 not found in the transmit or receive queue. It has either completed
 | 
			
		||||
                                 or was not issued by Transmit() and Receive().
 | 
			
		||||
  @retval EFI_DEVICE_ERROR       An unexpected system or network error occurred.
 | 
			
		||||
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_IP6_CANCEL)(
 | 
			
		||||
  IN EFI_IP6_PROTOCOL            *This,
 | 
			
		||||
  IN EFI_IP6_COMPLETION_TOKEN    *Token    OPTIONAL
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Polls for incoming data packets and processes outgoing data packets.
 | 
			
		||||
 | 
			
		||||
  The Poll() function polls for incoming data packets and processes outgoing data
 | 
			
		||||
  packets. Network drivers and applications can call the EFI_IP6_PROTOCOL.Poll()
 | 
			
		||||
  function to increase the rate that data packets are moved between the communications
 | 
			
		||||
  device and the transmit and receive queues.
 | 
			
		||||
 | 
			
		||||
  In some systems the periodic timer event may not poll the underlying communications
 | 
			
		||||
  device fast enough to transmit and/or receive all data packets without missing
 | 
			
		||||
  incoming packets or dropping outgoing packets. Drivers and applications that are
 | 
			
		||||
  experiencing packet loss should try calling the EFI_IP6_PROTOCOL.Poll() function
 | 
			
		||||
  more often.
 | 
			
		||||
 | 
			
		||||
  @param[in]  This               Pointer to the EFI_IP6_PROTOCOL instance.
 | 
			
		||||
 | 
			
		||||
  @retval  EFI_SUCCESS           Incoming or outgoing data was processed.
 | 
			
		||||
  @retval  EFI_NOT_STARTED       This EFI IPv6 Protocol instance has not been started.
 | 
			
		||||
  @retval  EFI_INVALID_PARAMETER This is NULL.
 | 
			
		||||
  @retval  EFI_DEVICE_ERROR      An unexpected system or network error occurred.
 | 
			
		||||
  @retval  EFI_NOT_READY         No incoming or outgoing data is processed.
 | 
			
		||||
  @retval  EFI_TIMEOUT           Data was dropped out of the transmit and/or receive queue.
 | 
			
		||||
                                 Consider increasing the polling rate.
 | 
			
		||||
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_IP6_POLL)(
 | 
			
		||||
  IN EFI_IP6_PROTOCOL            *This
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// The EFI IPv6 Protocol implements a simple packet-oriented interface that can be
 | 
			
		||||
/// used by drivers, daemons, and applications to transmit and receive network packets.
 | 
			
		||||
///
 | 
			
		||||
struct _EFI_IP6_PROTOCOL {
 | 
			
		||||
  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;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
extern EFI_GUID  gEfiIp6ServiceBindingProtocolGuid;
 | 
			
		||||
extern EFI_GUID  gEfiIp6ProtocolGuid;
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										369
									
								
								src/include/ipxe/efi/Protocol/Ip6Config.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										369
									
								
								src/include/ipxe/efi/Protocol/Ip6Config.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,369 @@
 | 
			
		||||
/** @file
 | 
			
		||||
  This file provides a definition of the EFI IPv6 Configuration
 | 
			
		||||
  Protocol.
 | 
			
		||||
 | 
			
		||||
Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>
 | 
			
		||||
SPDX-License-Identifier: BSD-2-Clause-Patent
 | 
			
		||||
 | 
			
		||||
**/
 | 
			
		||||
 | 
			
		||||
#ifndef __EFI_IP6CONFIG_PROTOCOL_H__
 | 
			
		||||
#define __EFI_IP6CONFIG_PROTOCOL_H__
 | 
			
		||||
 | 
			
		||||
FILE_LICENCE ( BSD2_PATENT );
 | 
			
		||||
 | 
			
		||||
#include <ipxe/efi/Protocol/Ip6.h>
 | 
			
		||||
 | 
			
		||||
#define EFI_IP6_CONFIG_PROTOCOL_GUID \
 | 
			
		||||
  { \
 | 
			
		||||
    0x937fe521, 0x95ae, 0x4d1a, {0x89, 0x29, 0x48, 0xbc, 0xd9, 0x0a, 0xd3, 0x1a } \
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
typedef struct _EFI_IP6_CONFIG_PROTOCOL EFI_IP6_CONFIG_PROTOCOL;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_IP6_CONFIG_DATA_TYPE
 | 
			
		||||
///
 | 
			
		||||
typedef enum {
 | 
			
		||||
  ///
 | 
			
		||||
  /// The interface information of the communication
 | 
			
		||||
  /// device this EFI IPv6 Configuration Protocol instance manages.
 | 
			
		||||
  /// This type of data is read only.The corresponding Data is of type
 | 
			
		||||
  /// EFI_IP6_CONFIG_INTERFACE_INFO.
 | 
			
		||||
  ///
 | 
			
		||||
  Ip6ConfigDataTypeInterfaceInfo,
 | 
			
		||||
  ///
 | 
			
		||||
  /// The alternative interface ID for the
 | 
			
		||||
  /// communication device this EFI IPv6 Configuration Protocol
 | 
			
		||||
  /// instance manages if the link local IPv6 address generated from
 | 
			
		||||
  /// the interfaced ID based on the default source the EFI IPv6
 | 
			
		||||
  /// Protocol uses is a duplicate address. The length of the interface
 | 
			
		||||
  /// ID is 64 bit. The corresponding Data is of type
 | 
			
		||||
  /// EFI_IP6_CONFIG_INTERFACE_ID.
 | 
			
		||||
  ///
 | 
			
		||||
  Ip6ConfigDataTypeAltInterfaceId,
 | 
			
		||||
  ///
 | 
			
		||||
  /// The general configuration policy for the EFI IPv6 network
 | 
			
		||||
  /// stack running on the communication device this EFI IPv6
 | 
			
		||||
  /// Configuration Protocol instance manages. The policy will affect
 | 
			
		||||
  /// other configuration settings. The corresponding Data is of type
 | 
			
		||||
  /// EFI_IP6_CONFIG_POLICY.
 | 
			
		||||
  ///
 | 
			
		||||
  Ip6ConfigDataTypePolicy,
 | 
			
		||||
  ///
 | 
			
		||||
  /// The number of consecutive
 | 
			
		||||
  /// Neighbor Solicitation messages sent while performing Duplicate
 | 
			
		||||
  /// Address Detection on a tentative address. A value of zero
 | 
			
		||||
  /// indicates that Duplicate Address Detection will not be performed
 | 
			
		||||
  /// on tentative addresses. The corresponding Data is of type
 | 
			
		||||
  /// EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS.
 | 
			
		||||
  ///
 | 
			
		||||
  Ip6ConfigDataTypeDupAddrDetectTransmits,
 | 
			
		||||
  ///
 | 
			
		||||
  /// The station addresses set manually for the EFI
 | 
			
		||||
  /// IPv6 network stack. It is only configurable when the policy is
 | 
			
		||||
  /// Ip6ConfigPolicyManual. The corresponding Data is a
 | 
			
		||||
  /// pointer to an array of EFI_IPv6_ADDRESS instances. When
 | 
			
		||||
  /// DataSize is 0 and Data is NULL, the existing configuration
 | 
			
		||||
  /// is cleared from the EFI IPv6 Configuration Protocol instance.
 | 
			
		||||
  ///
 | 
			
		||||
  Ip6ConfigDataTypeManualAddress,
 | 
			
		||||
  ///
 | 
			
		||||
  /// The gateway addresses set manually for the EFI IPv6
 | 
			
		||||
  /// network stack running on the communication device this EFI
 | 
			
		||||
  /// IPv6 Configuration Protocol manages. It is not configurable when
 | 
			
		||||
  /// the policy is Ip6ConfigPolicyAutomatic. The gateway
 | 
			
		||||
  /// addresses must be unicast IPv6 addresses. The corresponding
 | 
			
		||||
  /// Data is a pointer to an array of EFI_IPv6_ADDRESS instances.
 | 
			
		||||
  /// When DataSize is 0 and Data is NULL, the existing configuration
 | 
			
		||||
  /// is cleared from the EFI IPv6 Configuration Protocol instance.
 | 
			
		||||
  ///
 | 
			
		||||
  Ip6ConfigDataTypeGateway,
 | 
			
		||||
  ///
 | 
			
		||||
  /// The DNS server list for the EFI IPv6 network stack
 | 
			
		||||
  /// running on the communication device this EFI IPv6
 | 
			
		||||
  /// Configuration Protocol manages. It is not configurable when the
 | 
			
		||||
  /// policy is Ip6ConfigPolicyAutomatic.The DNS server
 | 
			
		||||
  /// addresses must be unicast IPv6 addresses. The corresponding
 | 
			
		||||
  /// Data is a pointer to an array of EFI_IPv6_ADDRESS instances.
 | 
			
		||||
  /// When DataSize is 0 and Data is NULL, the existing configuration
 | 
			
		||||
  /// is cleared from the EFI IPv6 Configuration Protocol instance.
 | 
			
		||||
  ///
 | 
			
		||||
  Ip6ConfigDataTypeDnsServer,
 | 
			
		||||
  ///
 | 
			
		||||
  /// The number of this enumeration memebers.
 | 
			
		||||
  ///
 | 
			
		||||
  Ip6ConfigDataTypeMaximum
 | 
			
		||||
} EFI_IP6_CONFIG_DATA_TYPE;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_IP6_CONFIG_INTERFACE_INFO
 | 
			
		||||
/// describes the operational state of the interface this
 | 
			
		||||
/// EFI IPv6 Configuration Protocol instance manages.
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// The name of the interface. It is a NULL-terminated string.
 | 
			
		||||
  ///
 | 
			
		||||
  CHAR16                  Name[32];
 | 
			
		||||
  ///
 | 
			
		||||
  /// The interface type of the network interface.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT8                   IfType;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The size, in bytes, of the network interface's hardware address.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32                  HwAddressSize;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The hardware address for the network interface.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_MAC_ADDRESS         HwAddress;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Number of EFI_IP6_ADDRESS_INFO structures pointed to by AddressInfo.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32                  AddressInfoCount;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Pointer to an array of EFI_IP6_ADDRESS_INFO instances
 | 
			
		||||
  /// which contain the local IPv6 addresses and the corresponding
 | 
			
		||||
  /// prefix length information. Set to NULL if AddressInfoCount
 | 
			
		||||
  /// is zero.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_IP6_ADDRESS_INFO    *AddressInfo;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Number of route table entries in the following RouteTable.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32                  RouteCount;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The route table of the IPv6 network stack runs on this interface.
 | 
			
		||||
  /// Set to NULL if RouteCount is zero.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_IP6_ROUTE_TABLE     *RouteTable;
 | 
			
		||||
} EFI_IP6_CONFIG_INTERFACE_INFO;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_IP6_CONFIG_INTERFACE_ID
 | 
			
		||||
/// describes the 64-bit interface ID.
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  UINT8    Id[8];
 | 
			
		||||
} EFI_IP6_CONFIG_INTERFACE_ID;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_IP6_CONFIG_POLICY
 | 
			
		||||
/// defines the general configuration policy the EFI IPv6
 | 
			
		||||
/// Configuration Protocol supports.
 | 
			
		||||
///
 | 
			
		||||
typedef enum {
 | 
			
		||||
  ///
 | 
			
		||||
  /// Under this policy, the IpI6ConfigDataTypeManualAddress,
 | 
			
		||||
  /// Ip6ConfigDataTypeGateway and Ip6ConfigDataTypeDnsServer
 | 
			
		||||
  /// configuration data are required to be set manually.
 | 
			
		||||
  /// The EFI IPv6 Protocol will get all required configuration
 | 
			
		||||
  /// such as address, prefix and gateway settings from the EFI
 | 
			
		||||
  /// IPv6 Configuration protocol.
 | 
			
		||||
  ///
 | 
			
		||||
  Ip6ConfigPolicyManual,
 | 
			
		||||
  ///
 | 
			
		||||
  /// Under this policy, the IpI6ConfigDataTypeManualAddress,
 | 
			
		||||
  /// Ip6ConfigDataTypeGateway and Ip6ConfigDataTypeDnsServer
 | 
			
		||||
  /// configuration data are not allowed to set via SetData().
 | 
			
		||||
  /// All of these configurations are retrieved from some auto
 | 
			
		||||
  /// configuration mechanism.
 | 
			
		||||
  /// The EFI IPv6 Protocol will use the IPv6 stateless address
 | 
			
		||||
  /// autoconfiguration mechanism and/or the IPv6 stateful address
 | 
			
		||||
  /// autoconfiguration mechanism described in the related RFCs to
 | 
			
		||||
  /// get address and other configuration information
 | 
			
		||||
  ///
 | 
			
		||||
  Ip6ConfigPolicyAutomatic
 | 
			
		||||
} EFI_IP6_CONFIG_POLICY;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS
 | 
			
		||||
/// describes the number of consecutive Neighbor Solicitation messages sent
 | 
			
		||||
/// while performing Duplicate Address Detection on a tentative address.
 | 
			
		||||
/// The default value for a newly detected communication device is 1.
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  UINT32    DupAddrDetectTransmits;  ///< The number of consecutive Neighbor Solicitation messages sent.
 | 
			
		||||
} EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_IP6_CONFIG_MANUAL_ADDRESS
 | 
			
		||||
/// is used to set the station address information for the EFI IPv6 network
 | 
			
		||||
/// stack manually when the policy is Ip6ConfigPolicyManual.
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  EFI_IPv6_ADDRESS    Address;         ///< The IPv6 unicast address.
 | 
			
		||||
  BOOLEAN             IsAnycast;       ///< Set to TRUE if Address is anycast.
 | 
			
		||||
  UINT8               PrefixLength;    ///< The length, in bits, of the prefix associated with this Address.
 | 
			
		||||
} EFI_IP6_CONFIG_MANUAL_ADDRESS;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Set the configuration for the EFI IPv6 network stack running on the communication
 | 
			
		||||
  device this EFI IPv6 Configuration Protocol instance manages.
 | 
			
		||||
 | 
			
		||||
  This function is used to set the configuration data of type DataType for the EFI
 | 
			
		||||
  IPv6 network stack running on the communication device this EFI IPv6 Configuration
 | 
			
		||||
  Protocol instance manages.
 | 
			
		||||
 | 
			
		||||
  The DataSize is used to calculate the count of structure instances in the Data for
 | 
			
		||||
  some DataType that multiple structure instances are allowed.
 | 
			
		||||
 | 
			
		||||
  This function is always non-blocking. When setting some type of configuration data,
 | 
			
		||||
  an asynchronous process is invoked to check the correctness of the data, such as
 | 
			
		||||
  doing Duplicate Address Detection on the manually set local IPv6 addresses.
 | 
			
		||||
  EFI_NOT_READY is returned immediately to indicate that such an asynchronous process
 | 
			
		||||
  is invoked and the process is not finished yet. The caller willing to get the result
 | 
			
		||||
  of the asynchronous process is required to call RegisterDataNotify() to register an
 | 
			
		||||
  event on the specified configuration data. Once the event is signaled, the caller
 | 
			
		||||
  can call GetData() to get back the configuration data in order to know the result.
 | 
			
		||||
  For other types of configuration data that do not require an asynchronous configuration
 | 
			
		||||
  process, the result of the operation is immediately returned.
 | 
			
		||||
 | 
			
		||||
  @param[in]     This           Pointer to the EFI_IP6_CONFIG_PROTOCOL instance.
 | 
			
		||||
  @param[in]     DataType       The type of data to set.
 | 
			
		||||
  @param[in]     DataSize       Size of the buffer pointed to by Data in bytes.
 | 
			
		||||
  @param[in]     Data           The data buffer to set. The type of the data buffer is
 | 
			
		||||
                                associated with the DataType.
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS           The specified configuration data for the EFI IPv6
 | 
			
		||||
                                network stack is set successfully.
 | 
			
		||||
  @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:
 | 
			
		||||
                                - This is NULL.
 | 
			
		||||
                                - One or more fields in Data and DataSize do not match the
 | 
			
		||||
                                  requirement of the data type indicated by DataType.
 | 
			
		||||
  @retval EFI_WRITE_PROTECTED   The specified configuration data is read-only or the specified
 | 
			
		||||
                                configuration data can not be set under the current policy
 | 
			
		||||
  @retval EFI_ACCESS_DENIED     Another set operation on the specified configuration
 | 
			
		||||
                                data is already in process.
 | 
			
		||||
  @retval EFI_NOT_READY         An asynchronous process is invoked to set the specified
 | 
			
		||||
                                configuration data and the process is not finished yet.
 | 
			
		||||
  @retval EFI_BAD_BUFFER_SIZE   The DataSize does not match the size of the type
 | 
			
		||||
                                indicated by DataType.
 | 
			
		||||
  @retval EFI_UNSUPPORTED       This DataType is not supported.
 | 
			
		||||
  @retval EFI_OUT_OF_RESOURCES  Required system resources could not be allocated.
 | 
			
		||||
  @retval EFI_DEVICE_ERROR      An unexpected system error or network error occurred.
 | 
			
		||||
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_IP6_CONFIG_SET_DATA)(
 | 
			
		||||
  IN EFI_IP6_CONFIG_PROTOCOL    *This,
 | 
			
		||||
  IN EFI_IP6_CONFIG_DATA_TYPE   DataType,
 | 
			
		||||
  IN UINTN                      DataSize,
 | 
			
		||||
  IN VOID                       *Data
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Get the configuration data for the EFI IPv6 network stack running on the communication
 | 
			
		||||
  device this EFI IPv6 Configuration Protocol instance manages.
 | 
			
		||||
 | 
			
		||||
  This function returns the configuration data of type DataType for the EFI IPv6 network
 | 
			
		||||
  stack running on the communication device this EFI IPv6 Configuration Protocol instance
 | 
			
		||||
  manages.
 | 
			
		||||
 | 
			
		||||
  The caller is responsible for allocating the buffer used to return the specified
 | 
			
		||||
  configuration data and the required size will be returned to the caller if the size of
 | 
			
		||||
  the buffer is too small.
 | 
			
		||||
 | 
			
		||||
  EFI_NOT_READY is returned if the specified configuration data is not ready due to an
 | 
			
		||||
  already in progress asynchronous configuration process. The caller can call RegisterDataNotify()
 | 
			
		||||
  to register an event on the specified configuration data. Once the asynchronous configuration
 | 
			
		||||
  process is finished, the event will be signaled and a subsequent GetData() call will return
 | 
			
		||||
  the specified configuration data.
 | 
			
		||||
 | 
			
		||||
  @param[in]     This           Pointer to the EFI_IP6_CONFIG_PROTOCOL instance.
 | 
			
		||||
  @param[in]     DataType       The type of data to get.
 | 
			
		||||
  @param[in,out] DataSize       On input, in bytes, the size of Data. On output, in bytes, the
 | 
			
		||||
                                size of buffer required to store the specified configuration data.
 | 
			
		||||
  @param[in]     Data           The data buffer in which the configuration data is returned. The
 | 
			
		||||
                                type of the data buffer is associated with the DataType.
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS           The specified configuration data is got successfully.
 | 
			
		||||
  @retval EFI_INVALID_PARAMETER One or more of the followings are TRUE:
 | 
			
		||||
                                - This is NULL.
 | 
			
		||||
                                - DataSize is NULL.
 | 
			
		||||
                                - Data is NULL if *DataSize is not zero.
 | 
			
		||||
  @retval EFI_BUFFER_TOO_SMALL  The size of Data is too small for the specified configuration data
 | 
			
		||||
                                and the required size is returned in DataSize.
 | 
			
		||||
  @retval EFI_NOT_READY         The specified configuration data is not ready due to an already in
 | 
			
		||||
                                progress asynchronous configuration process.
 | 
			
		||||
  @retval EFI_NOT_FOUND         The specified configuration data is not found.
 | 
			
		||||
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_IP6_CONFIG_GET_DATA)(
 | 
			
		||||
  IN EFI_IP6_CONFIG_PROTOCOL    *This,
 | 
			
		||||
  IN EFI_IP6_CONFIG_DATA_TYPE   DataType,
 | 
			
		||||
  IN OUT UINTN                  *DataSize,
 | 
			
		||||
  IN VOID                       *Data   OPTIONAL
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Register an event that is to be signaled whenever a configuration process on the specified
 | 
			
		||||
  configuration data is done.
 | 
			
		||||
 | 
			
		||||
  This function registers an event that is to be signaled whenever a configuration process
 | 
			
		||||
  on the specified configuration data is done. An event can be registered for different DataType
 | 
			
		||||
  simultaneously and the caller is responsible for determining which type of configuration data
 | 
			
		||||
  causes the signaling of the event in such case.
 | 
			
		||||
 | 
			
		||||
  @param[in]     This           Pointer to the EFI_IP6_CONFIG_PROTOCOL instance.
 | 
			
		||||
  @param[in]     DataType       The type of data to unregister the event for.
 | 
			
		||||
  @param[in]     Event          The event to register.
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS           The notification event for the specified configuration data is
 | 
			
		||||
                                registered.
 | 
			
		||||
  @retval EFI_INVALID_PARAMETER This is NULL or Event is NULL.
 | 
			
		||||
  @retval EFI_UNSUPPORTED       The configuration data type specified by DataType is not
 | 
			
		||||
                                supported.
 | 
			
		||||
  @retval EFI_OUT_OF_RESOURCES  Required system resources could not be allocated.
 | 
			
		||||
  @retval EFI_ACCESS_DENIED     The Event is already registered for the DataType.
 | 
			
		||||
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_IP6_CONFIG_REGISTER_NOTIFY)(
 | 
			
		||||
  IN EFI_IP6_CONFIG_PROTOCOL    *This,
 | 
			
		||||
  IN EFI_IP6_CONFIG_DATA_TYPE   DataType,
 | 
			
		||||
  IN EFI_EVENT                  Event
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Remove a previously registered event for the specified configuration data.
 | 
			
		||||
 | 
			
		||||
  This function removes a previously registered event for the specified configuration data.
 | 
			
		||||
 | 
			
		||||
  @param[in]     This           Pointer to the EFI_IP6_CONFIG_PROTOCOL instance.
 | 
			
		||||
  @param[in]     DataType       The type of data to remove the previously registered event for.
 | 
			
		||||
  @param[in]     Event          The event to unregister.
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS           The event registered for the specified configuration data is removed.
 | 
			
		||||
  @retval EFI_INVALID_PARAMETER This is NULL or Event is NULL.
 | 
			
		||||
  @retval EFI_NOT_FOUND         The Event has not been registered for the specified
 | 
			
		||||
                                DataType.
 | 
			
		||||
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_IP6_CONFIG_UNREGISTER_NOTIFY)(
 | 
			
		||||
  IN EFI_IP6_CONFIG_PROTOCOL    *This,
 | 
			
		||||
  IN EFI_IP6_CONFIG_DATA_TYPE   DataType,
 | 
			
		||||
  IN EFI_EVENT                  Event
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// The EFI_IP6_CONFIG_PROTOCOL provides the mechanism to set and get various
 | 
			
		||||
/// types of configurations for the EFI IPv6 network stack.
 | 
			
		||||
///
 | 
			
		||||
struct _EFI_IP6_CONFIG_PROTOCOL {
 | 
			
		||||
  EFI_IP6_CONFIG_SET_DATA             SetData;
 | 
			
		||||
  EFI_IP6_CONFIG_GET_DATA             GetData;
 | 
			
		||||
  EFI_IP6_CONFIG_REGISTER_NOTIFY      RegisterDataNotify;
 | 
			
		||||
  EFI_IP6_CONFIG_UNREGISTER_NOTIFY    UnregisterDataNotify;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
extern EFI_GUID  gEfiIp6ConfigProtocolGuid;
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										820
									
								
								src/include/ipxe/efi/Protocol/Mtftp6.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										820
									
								
								src/include/ipxe/efi/Protocol/Mtftp6.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,820 @@
 | 
			
		||||
/** @file
 | 
			
		||||
  UEFI Multicast Trivial File Transfer Protocol v6 Definition, which is built upon
 | 
			
		||||
  the EFI UDPv6 Protocol and provides basic services for client-side unicast and/or
 | 
			
		||||
  multicast TFTP operations.
 | 
			
		||||
 | 
			
		||||
  Copyright (c) 2008 - 2011, Intel Corporation. All rights reserved.<BR>
 | 
			
		||||
  (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
 | 
			
		||||
 | 
			
		||||
  SPDX-License-Identifier: BSD-2-Clause-Patent
 | 
			
		||||
 | 
			
		||||
  @par Revision Reference:
 | 
			
		||||
  This Protocol is introduced in UEFI Specification 2.2
 | 
			
		||||
 | 
			
		||||
**/
 | 
			
		||||
 | 
			
		||||
#ifndef __EFI_MTFTP6_PROTOCOL_H__
 | 
			
		||||
#define __EFI_MTFTP6_PROTOCOL_H__
 | 
			
		||||
 | 
			
		||||
FILE_LICENCE ( BSD2_PATENT );
 | 
			
		||||
 | 
			
		||||
#define EFI_MTFTP6_SERVICE_BINDING_PROTOCOL_GUID \
 | 
			
		||||
  { \
 | 
			
		||||
    0xd9760ff3, 0x3cca, 0x4267, {0x80, 0xf9, 0x75, 0x27, 0xfa, 0xfa, 0x42, 0x23 } \
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
#define EFI_MTFTP6_PROTOCOL_GUID \
 | 
			
		||||
  { \
 | 
			
		||||
    0xbf0a78ba, 0xec29, 0x49cf, {0xa1, 0xc9, 0x7a, 0xe5, 0x4e, 0xab, 0x6a, 0x51 } \
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
typedef struct _EFI_MTFTP6_PROTOCOL  EFI_MTFTP6_PROTOCOL;
 | 
			
		||||
typedef struct _EFI_MTFTP6_TOKEN     EFI_MTFTP6_TOKEN;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// MTFTP Packet OpCodes
 | 
			
		||||
///@{
 | 
			
		||||
#define EFI_MTFTP6_OPCODE_RRQ    1   ///< The MTFTPv6 packet is a read request.
 | 
			
		||||
#define EFI_MTFTP6_OPCODE_WRQ    2   ///< The MTFTPv6 packet is a write request.
 | 
			
		||||
#define EFI_MTFTP6_OPCODE_DATA   3   ///< The MTFTPv6 packet is a data packet.
 | 
			
		||||
#define EFI_MTFTP6_OPCODE_ACK    4   ///< The MTFTPv6 packet is an acknowledgement packet.
 | 
			
		||||
#define EFI_MTFTP6_OPCODE_ERROR  5   ///< The MTFTPv6 packet is an error packet.
 | 
			
		||||
#define EFI_MTFTP6_OPCODE_OACK   6   ///< The MTFTPv6 packet is an option acknowledgement packet.
 | 
			
		||||
#define EFI_MTFTP6_OPCODE_DIR    7   ///< The MTFTPv6 packet is a directory query packet.
 | 
			
		||||
#define EFI_MTFTP6_OPCODE_DATA8  8   ///< The MTFTPv6 packet is a data packet with a big block number.
 | 
			
		||||
#define EFI_MTFTP6_OPCODE_ACK8   9   ///< The MTFTPv6 packet is an acknowledgement packet with a big block number.
 | 
			
		||||
///@}
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// MTFTP ERROR Packet ErrorCodes
 | 
			
		||||
///@{
 | 
			
		||||
///
 | 
			
		||||
/// The error code is not defined. See the error message in the packet (if any) for details.
 | 
			
		||||
///
 | 
			
		||||
#define EFI_MTFTP6_ERRORCODE_NOT_DEFINED  0
 | 
			
		||||
///
 | 
			
		||||
/// The file was not found.
 | 
			
		||||
///
 | 
			
		||||
#define EFI_MTFTP6_ERRORCODE_FILE_NOT_FOUND  1
 | 
			
		||||
///
 | 
			
		||||
/// There was an access violation.
 | 
			
		||||
///
 | 
			
		||||
#define EFI_MTFTP6_ERRORCODE_ACCESS_VIOLATION  2
 | 
			
		||||
///
 | 
			
		||||
/// The disk was full or its allocation was exceeded.
 | 
			
		||||
///
 | 
			
		||||
#define EFI_MTFTP6_ERRORCODE_DISK_FULL  3
 | 
			
		||||
///
 | 
			
		||||
/// The MTFTPv6 operation was illegal.
 | 
			
		||||
///
 | 
			
		||||
#define EFI_MTFTP6_ERRORCODE_ILLEGAL_OPERATION  4
 | 
			
		||||
///
 | 
			
		||||
/// The transfer ID is unknown.
 | 
			
		||||
///
 | 
			
		||||
#define EFI_MTFTP6_ERRORCODE_UNKNOWN_TRANSFER_ID  5
 | 
			
		||||
///
 | 
			
		||||
/// The file already exists.
 | 
			
		||||
///
 | 
			
		||||
#define EFI_MTFTP6_ERRORCODE_FILE_ALREADY_EXISTS  6
 | 
			
		||||
///
 | 
			
		||||
/// There is no such user.
 | 
			
		||||
///
 | 
			
		||||
#define EFI_MTFTP6_ERRORCODE_NO_SUCH_USER  7
 | 
			
		||||
///
 | 
			
		||||
/// The request has been denied due to option negotiation.
 | 
			
		||||
///
 | 
			
		||||
#define EFI_MTFTP6_ERRORCODE_REQUEST_DENIED  8
 | 
			
		||||
///@}
 | 
			
		||||
 | 
			
		||||
#pragma pack(1)
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_MTFTP6_REQ_HEADER
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// For this packet type, OpCode = EFI_MTFTP6_OPCODE_RRQ for a read request
 | 
			
		||||
  /// or OpCode = EFI_MTFTP6_OPCODE_WRQ for a write request.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT16    OpCode;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The file name to be downloaded or uploaded.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT8     Filename[1];
 | 
			
		||||
} EFI_MTFTP6_REQ_HEADER;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_MTFTP6_OACK_HEADER
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// For this packet type, OpCode = EFI_MTFTP6_OPCODE_OACK.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT16    OpCode;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The option strings in the option acknowledgement packet.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT8     Data[1];
 | 
			
		||||
} EFI_MTFTP6_OACK_HEADER;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_MTFTP6_DATA_HEADER
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// For this packet type, OpCode = EFI_MTFTP6_OPCODE_DATA.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT16    OpCode;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Block number of this data packet.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT16    Block;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The content of this data packet.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT8     Data[1];
 | 
			
		||||
} EFI_MTFTP6_DATA_HEADER;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_MTFTP6_ACK_HEADER
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// For this packet type, OpCode = EFI_MTFTP6_OPCODE_ACK.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT16    OpCode;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The block number of the data packet that is being acknowledged.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT16    Block[1];
 | 
			
		||||
} EFI_MTFTP6_ACK_HEADER;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_MTFTP6_DATA8_HEADER
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// For this packet type, OpCode = EFI_MTFTP6_OPCODE_DATA8.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT16    OpCode;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The block number of data packet.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT64    Block;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The content of this data packet.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT8     Data[1];
 | 
			
		||||
} EFI_MTFTP6_DATA8_HEADER;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_MTFTP6_ACK8_HEADER
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// For this packet type, OpCode = EFI_MTFTP6_OPCODE_ACK8.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT16    OpCode;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The block number of the data packet that is being acknowledged.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT64    Block[1];
 | 
			
		||||
} EFI_MTFTP6_ACK8_HEADER;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_MTFTP6_ERROR_HEADER
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// For this packet type, OpCode = EFI_MTFTP6_OPCODE_ERROR.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT16    OpCode;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The error number as defined by the MTFTPv6 packet error codes.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT16    ErrorCode;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Error message string.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT8     ErrorMessage[1];
 | 
			
		||||
} EFI_MTFTP6_ERROR_HEADER;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_MTFTP6_PACKET
 | 
			
		||||
///
 | 
			
		||||
typedef union {
 | 
			
		||||
  UINT16                     OpCode; ///< Type of packets as defined by the MTFTPv6 packet opcodes.
 | 
			
		||||
  EFI_MTFTP6_REQ_HEADER      Rrq;    ///< Read request packet header.
 | 
			
		||||
  EFI_MTFTP6_REQ_HEADER      Wrq;    ///< write request packet header.
 | 
			
		||||
  EFI_MTFTP6_OACK_HEADER     Oack;   ///< Option acknowledge packet header.
 | 
			
		||||
  EFI_MTFTP6_DATA_HEADER     Data;   ///< Data packet header.
 | 
			
		||||
  EFI_MTFTP6_ACK_HEADER      Ack;    ///< Acknowledgement packet header.
 | 
			
		||||
  EFI_MTFTP6_DATA8_HEADER    Data8;  ///< Data packet header with big block number.
 | 
			
		||||
  EFI_MTFTP6_ACK8_HEADER     Ack8;   ///< Acknowledgement header with big block number.
 | 
			
		||||
  EFI_MTFTP6_ERROR_HEADER    Error;  ///< Error packet header.
 | 
			
		||||
} EFI_MTFTP6_PACKET;
 | 
			
		||||
 | 
			
		||||
#pragma pack()
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_MTFTP6_CONFIG_DATA
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// The local IP address to use. Set to zero to let the underlying IPv6
 | 
			
		||||
  /// driver choose a source address. If not zero it must be one of the
 | 
			
		||||
  /// configured IP addresses in the underlying IPv6 driver.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_IPv6_ADDRESS    StationIp;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Local port number. Set to zero to use the automatically assigned port number.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT16              LocalPort;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The IP address of the MTFTPv6 server.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_IPv6_ADDRESS    ServerIp;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The initial MTFTPv6 server port number. Request packets are
 | 
			
		||||
  /// sent to this port. This number is almost always 69 and using zero
 | 
			
		||||
  /// defaults to 69.
 | 
			
		||||
  UINT16              InitialServerPort;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The number of times to transmit MTFTPv6 request packets and wait for a response.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT16              TryCount;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The number of seconds to wait for a response after sending the MTFTPv6 request packet.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT16              TimeoutValue;
 | 
			
		||||
} EFI_MTFTP6_CONFIG_DATA;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_MTFTP6_MODE_DATA
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// The configuration data of this instance.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_MTFTP6_CONFIG_DATA    ConfigData;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The number of option strings in the following SupportedOptions array.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT8                     SupportedOptionCount;
 | 
			
		||||
  ///
 | 
			
		||||
  /// An array of null-terminated ASCII option strings that are recognized and supported by
 | 
			
		||||
  /// this EFI MTFTPv6 Protocol driver implementation. The buffer is
 | 
			
		||||
  /// read only to the caller and the caller should NOT free the buffer.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT8                     **SupportedOptions;
 | 
			
		||||
} EFI_MTFTP6_MODE_DATA;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_MTFTP_OVERRIDE_DATA
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// IP address of the MTFTPv6 server. If set to all zero, the value that
 | 
			
		||||
  /// was set by the EFI_MTFTP6_PROTOCOL.Configure() function will be used.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_IPv6_ADDRESS    ServerIp;
 | 
			
		||||
  ///
 | 
			
		||||
  /// MTFTPv6 server port number. If set to zero, it will use the value
 | 
			
		||||
  /// that was set by the EFI_MTFTP6_PROTOCOL.Configure() function.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT16              ServerPort;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Number of times to transmit MTFTPv6 request packets and wait
 | 
			
		||||
  /// for a response. If set to zero, the value that was set by
 | 
			
		||||
  /// theEFI_MTFTP6_PROTOCOL.Configure() function will be used.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT16              TryCount;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Number of seconds to wait for a response after sending the
 | 
			
		||||
  /// MTFTPv6 request packet. If set to zero, the value that was set by
 | 
			
		||||
  /// the EFI_MTFTP6_PROTOCOL.Configure() function will be used.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT16              TimeoutValue;
 | 
			
		||||
} EFI_MTFTP6_OVERRIDE_DATA;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_MTFTP6_OPTION
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  UINT8    *OptionStr;               ///< Pointer to the null-terminated ASCII MTFTPv6 option string.
 | 
			
		||||
  UINT8    *ValueStr;                ///< Pointer to the null-terminated ASCII MTFTPv6 value string.
 | 
			
		||||
} EFI_MTFTP6_OPTION;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  EFI_MTFTP6_TIMEOUT_CALLBACK is a callback function that the caller provides to capture the
 | 
			
		||||
  timeout event in the EFI_MTFTP6_PROTOCOL.ReadFile(), EFI_MTFTP6_PROTOCOL.WriteFile() or
 | 
			
		||||
  EFI_MTFTP6_PROTOCOL.ReadDirectory() functions.
 | 
			
		||||
 | 
			
		||||
  Whenever a timeout occurs, the EFI MTFTPv6 Protocol driver will call the EFI_MTFTP6_TIMEOUT_CALLBACK
 | 
			
		||||
  function to notify the caller of the timeout event. Any status code other than EFI_SUCCESS
 | 
			
		||||
  that is returned from this function will abort the current download process.
 | 
			
		||||
 | 
			
		||||
  @param[in] This          Pointer to the EFI_MTFTP6_PROTOCOL instance.
 | 
			
		||||
  @param[in] Token         The token that the caller provided in the EFI_MTFTP6_PROTOCOl.ReadFile(),
 | 
			
		||||
                           WriteFile() or ReadDirectory() function.
 | 
			
		||||
  @param[in] PacketLen     Indicates the length of the packet.
 | 
			
		||||
  @param[in] Packet        Pointer to an MTFTPv6 packet.
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS      Operation success.
 | 
			
		||||
  @retval Others           Aborts session.
 | 
			
		||||
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_MTFTP6_CHECK_PACKET)(
 | 
			
		||||
  IN EFI_MTFTP6_PROTOCOL      *This,
 | 
			
		||||
  IN EFI_MTFTP6_TOKEN         *Token,
 | 
			
		||||
  IN UINT16                   PacketLen,
 | 
			
		||||
  IN EFI_MTFTP6_PACKET        *Packet
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  EFI_MTFTP6_TIMEOUT_CALLBACK is a callback function that the caller provides to capture the
 | 
			
		||||
  timeout event in the EFI_MTFTP6_PROTOCOL.ReadFile(), EFI_MTFTP6_PROTOCOL.WriteFile() or
 | 
			
		||||
  EFI_MTFTP6_PROTOCOL.ReadDirectory() functions.
 | 
			
		||||
 | 
			
		||||
  Whenever a timeout occurs, the EFI MTFTPv6 Protocol driver will call the EFI_MTFTP6_TIMEOUT_CALLBACK
 | 
			
		||||
  function to notify the caller of the timeout event. Any status code other than EFI_SUCCESS
 | 
			
		||||
  that is returned from this function will abort the current download process.
 | 
			
		||||
 | 
			
		||||
  @param[in]      This     Pointer to the EFI_MTFTP6_PROTOCOL instance.
 | 
			
		||||
  @param[in]      Token    The token that is provided in the EFI_MTFTP6_PROTOCOL.ReadFile() or
 | 
			
		||||
                           EFI_MTFTP6_PROTOCOL.WriteFile() or EFI_MTFTP6_PROTOCOL.ReadDirectory()
 | 
			
		||||
                           functions by the caller.
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS      Operation success.
 | 
			
		||||
  @retval Others           Aborts session.
 | 
			
		||||
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_MTFTP6_TIMEOUT_CALLBACK)(
 | 
			
		||||
  IN EFI_MTFTP6_PROTOCOL      *This,
 | 
			
		||||
  IN EFI_MTFTP6_TOKEN         *Token
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  EFI_MTFTP6_PACKET_NEEDED is a callback function that the caller provides to feed data to the
 | 
			
		||||
  EFI_MTFTP6_PROTOCOL.WriteFile() function.
 | 
			
		||||
 | 
			
		||||
  EFI_MTFTP6_PACKET_NEEDED provides another mechanism for the caller to provide data to upload
 | 
			
		||||
  other than a static buffer. The EFI MTFTP6 Protocol driver always calls EFI_MTFTP6_PACKET_NEEDED
 | 
			
		||||
  to get packet data from the caller if no static buffer was given in the initial call to
 | 
			
		||||
  EFI_MTFTP6_PROTOCOL.WriteFile() function. Setting *Length to zero signals the end of the session.
 | 
			
		||||
  Returning a status code other than EFI_SUCCESS aborts the session.
 | 
			
		||||
 | 
			
		||||
  @param[in]      This     Pointer to the EFI_MTFTP6_PROTOCOL instance.
 | 
			
		||||
  @param[in]      Token    The token provided in the EFI_MTFTP6_PROTOCOL.WriteFile() by the caller.
 | 
			
		||||
  @param[in, out] Length   Indicates the length of the raw data wanted on input, and the
 | 
			
		||||
                           length the data available on output.
 | 
			
		||||
  @param[out]     Buffer   Pointer to the buffer where the data is stored.
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS      Operation success.
 | 
			
		||||
  @retval Others           Aborts session.
 | 
			
		||||
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_MTFTP6_PACKET_NEEDED)(
 | 
			
		||||
  IN EFI_MTFTP6_PROTOCOL      *This,
 | 
			
		||||
  IN EFI_MTFTP6_TOKEN         *Token,
 | 
			
		||||
  IN OUT UINT16               *Length,
 | 
			
		||||
  OUT VOID                    **Buffer
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
struct _EFI_MTFTP6_TOKEN {
 | 
			
		||||
  ///
 | 
			
		||||
  /// The status that is returned to the caller at the end of the operation
 | 
			
		||||
  /// to indicate whether this operation completed successfully.
 | 
			
		||||
  /// Defined Status values are listed below.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_STATUS                     Status;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The event that will be signaled when the operation completes. If
 | 
			
		||||
  /// set to NULL, the corresponding function will wait until the read or
 | 
			
		||||
  /// write operation finishes. The type of Event must be EVT_NOTIFY_SIGNAL.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_EVENT                      Event;
 | 
			
		||||
  ///
 | 
			
		||||
  /// If not NULL, the data that will be used to override the existing
 | 
			
		||||
  /// configure data.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_MTFTP6_OVERRIDE_DATA       *OverrideData;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Pointer to the null-terminated ASCII file name string.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT8                          *Filename;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Pointer to the null-terminated ASCII mode string. If NULL, octet is used.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT8                          *ModeStr;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Number of option/value string pairs.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32                         OptionCount;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Pointer to an array of option/value string pairs. Ignored if
 | 
			
		||||
  /// OptionCount is zero. Both a remote server and this driver
 | 
			
		||||
  /// implementation should support these options. If one or more
 | 
			
		||||
  /// options are unrecognized by this implementation, it is sent to the
 | 
			
		||||
  /// remote server without being changed.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_MTFTP6_OPTION              *OptionList;
 | 
			
		||||
  ///
 | 
			
		||||
  /// On input, the size, in bytes, of Buffer. On output, the number
 | 
			
		||||
  /// of bytes transferred.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT64                         BufferSize;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Pointer to the data buffer. Data that is downloaded from the
 | 
			
		||||
  /// MTFTPv6 server is stored here. Data that is uploaded to the
 | 
			
		||||
  /// MTFTPv6 server is read from here. Ignored if BufferSize is zero.
 | 
			
		||||
  ///
 | 
			
		||||
  VOID                           *Buffer;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Pointer to the context that will be used by CheckPacket,
 | 
			
		||||
  /// TimeoutCallback and PacketNeeded.
 | 
			
		||||
  ///
 | 
			
		||||
  VOID                           *Context;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Pointer to the callback function to check the contents of the
 | 
			
		||||
  /// received packet.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_MTFTP6_CHECK_PACKET        CheckPacket;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Pointer to the function to be called when a timeout occurs.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_MTFTP6_TIMEOUT_CALLBACK    TimeoutCallback;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Pointer to the function to provide the needed packet contents.
 | 
			
		||||
  /// Only used in WriteFile() operation.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_MTFTP6_PACKET_NEEDED       PacketNeeded;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Read the current operational settings.
 | 
			
		||||
 | 
			
		||||
  The GetModeData() function reads the current operational settings of this EFI MTFTPv6
 | 
			
		||||
  Protocol driver instance.
 | 
			
		||||
 | 
			
		||||
  @param[in]  This               Pointer to the EFI_MTFTP6_PROTOCOL instance.
 | 
			
		||||
  @param[out] ModeData           The buffer in which the EFI MTFTPv6 Protocol driver mode
 | 
			
		||||
                                 data is returned.
 | 
			
		||||
 | 
			
		||||
  @retval  EFI_SUCCESS           The configuration data was successfully returned.
 | 
			
		||||
  @retval  EFI_OUT_OF_RESOURCES  The required mode data could not be allocated.
 | 
			
		||||
  @retval  EFI_INVALID_PARAMETER This is NULL or ModeData is NULL.
 | 
			
		||||
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_MTFTP6_GET_MODE_DATA)(
 | 
			
		||||
  IN EFI_MTFTP6_PROTOCOL      *This,
 | 
			
		||||
  OUT EFI_MTFTP6_MODE_DATA    *ModeData
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Initializes, changes, or resets the default operational setting for this EFI MTFTPv6
 | 
			
		||||
  Protocol driver instance.
 | 
			
		||||
 | 
			
		||||
  The Configure() function is used to set and change the configuration data for this EFI
 | 
			
		||||
  MTFTPv6 Protocol driver instance. The configuration data can be reset to startup defaults by calling
 | 
			
		||||
  Configure() with MtftpConfigData set to NULL. Whenever the instance is reset, any
 | 
			
		||||
  pending operation is aborted. By changing the EFI MTFTPv6 Protocol driver instance configuration
 | 
			
		||||
  data, the client can connect to different MTFTPv6 servers. The configuration parameters in
 | 
			
		||||
  MtftpConfigData are used as the default parameters in later MTFTPv6 operations and can be
 | 
			
		||||
  overridden in later operations.
 | 
			
		||||
 | 
			
		||||
  @param[in]  This               Pointer to the EFI_MTFTP6_PROTOCOL instance.
 | 
			
		||||
  @param[in]  MtftpConfigData    Pointer to the configuration data structure.
 | 
			
		||||
 | 
			
		||||
  @retval  EFI_SUCCESS           The EFI MTFTPv6 Protocol instance was configured successfully.
 | 
			
		||||
  @retval  EFI_INVALID_PARAMETER One or more following conditions are TRUE:
 | 
			
		||||
                                 - This is NULL.
 | 
			
		||||
                                 - MtftpConfigData.StationIp is neither zero nor one
 | 
			
		||||
                                   of the configured IP addresses in the underlying IPv6 driver.
 | 
			
		||||
                                 - MtftpCofigData.ServerIp is not a valid IPv6 unicast address.
 | 
			
		||||
  @retval  EFI_ACCESS_DENIED     - The configuration could not be changed at this time because there
 | 
			
		||||
                                   is some MTFTP background operation in progress.
 | 
			
		||||
                                 - MtftpCofigData.LocalPort is already in use.
 | 
			
		||||
  @retval  EFI_NO_MAPPING        The underlying IPv6 driver was responsible for choosing a source
 | 
			
		||||
                                 address for this instance, but no source address was available for use.
 | 
			
		||||
  @retval  EFI_OUT_OF_RESOURCES  The EFI MTFTPv6 Protocol driver instance data could not be
 | 
			
		||||
                                 allocated.
 | 
			
		||||
  @retval  EFI_DEVICE_ERROR      An unexpected system or network error occurred. The EFI
 | 
			
		||||
                                 MTFTPv6 Protocol driver instance is not configured.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_MTFTP6_CONFIGURE)(
 | 
			
		||||
  IN EFI_MTFTP6_PROTOCOL      *This,
 | 
			
		||||
  IN EFI_MTFTP6_CONFIG_DATA   *MtftpConfigData OPTIONAL
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Get information about a file from an MTFTPv6 server.
 | 
			
		||||
 | 
			
		||||
  The GetInfo() function assembles an MTFTPv6 request packet with options, sends it to the
 | 
			
		||||
  MTFTPv6 server, and may return an MTFTPv6 OACK, MTFTPv6 ERROR, or ICMP ERROR packet.
 | 
			
		||||
  Retries occur only if no response packets are received from the MTFTPv6 server before the
 | 
			
		||||
  timeout expires.
 | 
			
		||||
 | 
			
		||||
  @param[in]  This               Pointer to the EFI_MTFTP6_PROTOCOL instance.
 | 
			
		||||
  @param[in]  OverrideData       Data that is used to override the existing parameters. If NULL, the
 | 
			
		||||
                                 default parameters that were set in the EFI_MTFTP6_PROTOCOL.Configure()
 | 
			
		||||
                                 function are used.
 | 
			
		||||
  @param[in]  Filename           Pointer to null-terminated ASCII file name string.
 | 
			
		||||
  @param[in]  ModeStr            Pointer to null-terminated ASCII mode string. If NULL, octet will be used
 | 
			
		||||
  @param[in]  OptionCount        Number of option/value string pairs in OptionList.
 | 
			
		||||
  @param[in]  OptionList         Pointer to array of option/value string pairs. Ignored if
 | 
			
		||||
                                 OptionCount is zero.
 | 
			
		||||
  @param[out] PacketLength       The number of bytes in the returned packet.
 | 
			
		||||
  @param[out] Packet             The pointer to the received packet. This buffer must be freed by
 | 
			
		||||
                                 the caller.
 | 
			
		||||
 | 
			
		||||
  @retval  EFI_SUCCESS              An MTFTPv6 OACK packet was received and is in the Packet.
 | 
			
		||||
  @retval  EFI_INVALID_PARAMETER    One or more of the following conditions is TRUE:
 | 
			
		||||
                                    - This is NULL.
 | 
			
		||||
                                    - Filename is NULL
 | 
			
		||||
                                    - OptionCount is not zero and OptionList is NULL.
 | 
			
		||||
                                    - One or more options in OptionList have wrong format.
 | 
			
		||||
                                    - PacketLength is NULL.
 | 
			
		||||
                                    - OverrideData.ServerIp is not valid unicast IPv6 addresses.
 | 
			
		||||
  @retval  EFI_UNSUPPORTED          One or more options in the OptionList are unsupported by
 | 
			
		||||
                                    this implementation.
 | 
			
		||||
  @retval  EFI_NOT_STARTED          The EFI MTFTPv6 Protocol driver has not been started.
 | 
			
		||||
  @retval  EFI_NO_MAPPING           The underlying IPv6 driver was responsible for choosing a source
 | 
			
		||||
                                    address for this instance, but no source address was available for use.
 | 
			
		||||
  @retval  EFI_ACCESS_DENIED        The previous operation has not completed yet.
 | 
			
		||||
  @retval  EFI_OUT_OF_RESOURCES     Required system resources could not be allocated.
 | 
			
		||||
  @retval  EFI_TFTP_ERROR           An MTFTPv6 ERROR packet was received and is in the Packet.
 | 
			
		||||
  @retval  EFI_NETWORK_UNREACHABLE  An ICMP network unreachable error packet was received and the Packet is set to NULL.
 | 
			
		||||
  @retval  EFI_HOST_UNREACHABLE     An ICMP host unreachable error packet was received and the Packet is set to NULL.
 | 
			
		||||
  @retval  EFI_PROTOCOL_UNREACHABLE An ICMP protocol unreachable error packet was received and the Packet is set to NULL.
 | 
			
		||||
  @retval  EFI_PORT_UNREACHABLE     An ICMP port unreachable error packet was received and the Packet is set to NULL.
 | 
			
		||||
  @retval  EFI_ICMP_ERROR           Some other ICMP ERROR packet was received and the Packet is set to NULL.
 | 
			
		||||
  @retval  EFI_PROTOCOL_ERROR       An unexpected MTFTPv6 packet was received and is in the Packet.
 | 
			
		||||
  @retval  EFI_TIMEOUT              No responses were received from the MTFTPv6 server.
 | 
			
		||||
  @retval  EFI_DEVICE_ERROR         An unexpected network error or system error occurred.
 | 
			
		||||
  @retval  EFI_NO_MEDIA             There was a media error.
 | 
			
		||||
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_MTFTP6_GET_INFO)(
 | 
			
		||||
  IN EFI_MTFTP6_PROTOCOL      *This,
 | 
			
		||||
  IN EFI_MTFTP6_OVERRIDE_DATA *OverrideData OPTIONAL,
 | 
			
		||||
  IN UINT8                    *Filename,
 | 
			
		||||
  IN UINT8                    *ModeStr OPTIONAL,
 | 
			
		||||
  IN UINT8                    OptionCount,
 | 
			
		||||
  IN EFI_MTFTP6_OPTION        *OptionList OPTIONAL,
 | 
			
		||||
  OUT UINT32                  *PacketLength,
 | 
			
		||||
  OUT EFI_MTFTP6_PACKET       **Packet OPTIONAL
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Parse the options in an MTFTPv6 OACK packet.
 | 
			
		||||
 | 
			
		||||
  The ParseOptions() function parses the option fields in an MTFTPv6 OACK packet and
 | 
			
		||||
  returns the number of options that were found and optionally a list of pointers to
 | 
			
		||||
  the options in the packet.
 | 
			
		||||
  If one or more of the option fields are not valid, then EFI_PROTOCOL_ERROR is returned
 | 
			
		||||
  and *OptionCount and *OptionList stop at the last valid option.
 | 
			
		||||
 | 
			
		||||
  @param[in]  This               Pointer to the EFI_MTFTP6_PROTOCOL instance.
 | 
			
		||||
  @param[in]  PacketLen          Length of the OACK packet to be parsed.
 | 
			
		||||
  @param[in]  Packet             Pointer to the OACK packet to be parsed.
 | 
			
		||||
  @param[out] OptionCount        Pointer to the number of options in the following OptionList.
 | 
			
		||||
  @param[out] OptionList         Pointer to EFI_MTFTP6_OPTION storage. Each pointer in the
 | 
			
		||||
                                 OptionList points to the corresponding MTFTP option buffer
 | 
			
		||||
                                 in the Packet. Call the EFI Boot Service FreePool() to
 | 
			
		||||
                                 release the OptionList if the options in this OptionList
 | 
			
		||||
                                 are not needed any more.
 | 
			
		||||
 | 
			
		||||
  @retval  EFI_SUCCESS           The OACK packet was valid and the OptionCount and
 | 
			
		||||
                                 OptionList parameters have been updated.
 | 
			
		||||
  @retval  EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
 | 
			
		||||
                                 - PacketLen is 0.
 | 
			
		||||
                                 - Packet is NULL or Packet is not a valid MTFTPv6 packet.
 | 
			
		||||
                                 - OptionCount is NULL.
 | 
			
		||||
  @retval  EFI_NOT_FOUND         No options were found in the OACK packet.
 | 
			
		||||
  @retval  EFI_OUT_OF_RESOURCES  Storage for the OptionList array can not be allocated.
 | 
			
		||||
  @retval  EFI_PROTOCOL_ERROR    One or more of the option fields is invalid.
 | 
			
		||||
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_MTFTP6_PARSE_OPTIONS)(
 | 
			
		||||
  IN EFI_MTFTP6_PROTOCOL      *This,
 | 
			
		||||
  IN UINT32                   PacketLen,
 | 
			
		||||
  IN EFI_MTFTP6_PACKET        *Packet,
 | 
			
		||||
  OUT UINT32                  *OptionCount,
 | 
			
		||||
  OUT EFI_MTFTP6_OPTION       **OptionList OPTIONAL
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Download a file from an MTFTPv6 server.
 | 
			
		||||
 | 
			
		||||
  The ReadFile() function is used to initialize and start an MTFTPv6 download process and
 | 
			
		||||
  optionally wait for completion. When the download operation completes, whether successfully or
 | 
			
		||||
  not, the Token.Status field is updated by the EFI MTFTPv6 Protocol driver and then
 | 
			
		||||
  Token.Event is signaled if it is not NULL.
 | 
			
		||||
 | 
			
		||||
  Data can be downloaded from the MTFTPv6 server into either of the following locations:
 | 
			
		||||
  - A fixed buffer that is pointed to by Token.Buffer
 | 
			
		||||
  - A download service function that is pointed to by Token.CheckPacket
 | 
			
		||||
 | 
			
		||||
  If both Token.Buffer and Token.CheckPacket are used, then Token.CheckPacket
 | 
			
		||||
  will be called first. If the call is successful, the packet will be stored in Token.Buffer.
 | 
			
		||||
 | 
			
		||||
  @param[in]  This               Pointer to the EFI_MTFTP6_PROTOCOL instance.
 | 
			
		||||
  @param[in]  Token              Pointer to the token structure to provide the parameters that are
 | 
			
		||||
                                 used in this operation.
 | 
			
		||||
 | 
			
		||||
  @retval  EFI_SUCCESS              The data file has been transferred successfully.
 | 
			
		||||
  @retval  EFI_OUT_OF_RESOURCES     Required system resources could not be allocated.
 | 
			
		||||
  @retval  EFI_BUFFER_TOO_SMALL     BufferSize is not zero but not large enough to hold the
 | 
			
		||||
                                    downloaded data in downloading process.
 | 
			
		||||
  @retval  EFI_ABORTED              Current operation is aborted by user.
 | 
			
		||||
  @retval  EFI_NETWORK_UNREACHABLE  An ICMP network unreachable error packet was received.
 | 
			
		||||
  @retval  EFI_HOST_UNREACHABLE     An ICMP host unreachable error packet was received.
 | 
			
		||||
  @retval  EFI_PROTOCOL_UNREACHABLE An ICMP protocol unreachable error packet was received.
 | 
			
		||||
  @retval  EFI_PORT_UNREACHABLE     An ICMP port unreachable error packet was received.
 | 
			
		||||
  @retval  EFI_ICMP_ERROR           An ICMP ERROR packet was received.
 | 
			
		||||
  @retval  EFI_TIMEOUT              No responses were received from the MTFTPv6 server.
 | 
			
		||||
  @retval  EFI_TFTP_ERROR           An MTFTPv6 ERROR packet was received.
 | 
			
		||||
  @retval  EFI_DEVICE_ERROR         An unexpected network error or system error occurred.
 | 
			
		||||
  @retval  EFI_NO_MEDIA             There was a media error.
 | 
			
		||||
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_MTFTP6_READ_FILE)(
 | 
			
		||||
  IN EFI_MTFTP6_PROTOCOL      *This,
 | 
			
		||||
  IN EFI_MTFTP6_TOKEN         *Token
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Send a file to an MTFTPv6 server. May be unsupported in some implementations.
 | 
			
		||||
 | 
			
		||||
  The WriteFile() function is used to initialize an uploading operation with the given option list
 | 
			
		||||
  and optionally wait for completion. If one or more of the options is not supported by the server, the
 | 
			
		||||
  unsupported options are ignored and a standard TFTP process starts instead. When the upload
 | 
			
		||||
  process completes, whether successfully or not, Token.Event is signaled, and the EFI MTFTPv6
 | 
			
		||||
  Protocol driver updates Token.Status.
 | 
			
		||||
 | 
			
		||||
  The caller can supply the data to be uploaded in the following two modes:
 | 
			
		||||
  - Through the user-provided buffer
 | 
			
		||||
  - Through a callback function
 | 
			
		||||
 | 
			
		||||
  With the user-provided buffer, the Token.BufferSize field indicates the length of the buffer,
 | 
			
		||||
  and the driver will upload the data in the buffer. With an EFI_MTFTP6_PACKET_NEEDED
 | 
			
		||||
  callback function, the driver will call this callback function to get more data from the user to upload.
 | 
			
		||||
  See the definition of EFI_MTFTP6_PACKET_NEEDED for more information. These two modes
 | 
			
		||||
  cannot be used at the same time. The callback function will be ignored if the user provides the
 | 
			
		||||
  buffer.
 | 
			
		||||
 | 
			
		||||
  @param[in]  This               Pointer to the EFI_MTFTP6_PROTOCOL instance.
 | 
			
		||||
  @param[in]  Token              Pointer to the token structure to provide the parameters that are
 | 
			
		||||
                                 used in this operation.
 | 
			
		||||
 | 
			
		||||
  @retval  EFI_SUCCESS           The upload session has started.
 | 
			
		||||
  @retval  EFI_UNSUPPORTED       The operation is not supported by this implementation.
 | 
			
		||||
  @retval  EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
 | 
			
		||||
                                 - This is NULL.
 | 
			
		||||
                                 - Token is NULL.
 | 
			
		||||
                                 - Token.Filename is NULL.
 | 
			
		||||
                                 - Token.OptionCount is not zero and Token.OptionList is NULL.
 | 
			
		||||
                                 - One or more options in Token.OptionList have wrong format.
 | 
			
		||||
                                 - Token.Buffer and Token.PacketNeeded are both NULL.
 | 
			
		||||
                                 - Token.OverrideData.ServerIp is not valid unicast IPv6 addresses.
 | 
			
		||||
  @retval  EFI_UNSUPPORTED       One or more options in the Token.OptionList are not
 | 
			
		||||
                                 supported by this implementation.
 | 
			
		||||
  @retval  EFI_NOT_STARTED       The EFI MTFTPv6 Protocol driver has not been started.
 | 
			
		||||
  @retval  EFI_NO_MAPPING        The underlying IPv6 driver was responsible for choosing a source
 | 
			
		||||
                                 address for this instance, but no source address was available for use.
 | 
			
		||||
  @retval  EFI_ALREADY_STARTED   This Token is already being used in another MTFTPv6 session.
 | 
			
		||||
  @retval  EFI_OUT_OF_RESOURCES  Required system resources could not be allocated.
 | 
			
		||||
  @retval  EFI_ACCESS_DENIED     The previous operation has not completed yet.
 | 
			
		||||
  @retval  EFI_DEVICE_ERROR      An unexpected network error or system error occurred.
 | 
			
		||||
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_MTFTP6_WRITE_FILE)(
 | 
			
		||||
  IN EFI_MTFTP6_PROTOCOL      *This,
 | 
			
		||||
  IN EFI_MTFTP6_TOKEN         *Token
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Download a data file directory from an MTFTPv6 server. May be unsupported in some implementations.
 | 
			
		||||
 | 
			
		||||
  The ReadDirectory() function is used to return a list of files on the MTFTPv6 server that are
 | 
			
		||||
  logically (or operationally) related to Token.Filename. The directory request packet that is sent
 | 
			
		||||
  to the server is built with the option list that was provided by caller, if present.
 | 
			
		||||
 | 
			
		||||
  The file information that the server returns is put into either of the following locations:
 | 
			
		||||
  - A fixed buffer that is pointed to by Token.Buffer
 | 
			
		||||
  - A download service function that is pointed to by Token.CheckPacket
 | 
			
		||||
 | 
			
		||||
  If both Token.Buffer and Token.CheckPacket are used, then Token.CheckPacket
 | 
			
		||||
  will be called first. If the call is successful, the packet will be stored in Token.Buffer.
 | 
			
		||||
 | 
			
		||||
  The returned directory listing in the Token.Buffer or EFI_MTFTP6_PACKET consists of a list
 | 
			
		||||
  of two or three variable-length ASCII strings, each terminated by a null character, for each file in the
 | 
			
		||||
  directory. If the multicast option is involved, the first field of each directory entry is the static
 | 
			
		||||
  multicast IP address and UDP port number that is associated with the file name. The format of the
 | 
			
		||||
  field is ip:ip:ip:ip:port. If the multicast option is not involved, this field and its terminating
 | 
			
		||||
  null character are not present.
 | 
			
		||||
 | 
			
		||||
  The next field of each directory entry is the file name and the last field is the file information string.
 | 
			
		||||
  The information string contains the file size and the create/modify timestamp. The format of the
 | 
			
		||||
  information string is filesize yyyy-mm-dd hh:mm:ss:ffff. The timestamp is
 | 
			
		||||
  Coordinated Universal Time (UTC; also known as Greenwich Mean Time [GMT]).
 | 
			
		||||
 | 
			
		||||
  @param[in]  This               Pointer to the EFI_MTFTP6_PROTOCOL instance.
 | 
			
		||||
  @param[in]  Token              Pointer to the token structure to provide the parameters that are
 | 
			
		||||
                                 used in this operation.
 | 
			
		||||
 | 
			
		||||
  @retval  EFI_SUCCESS           The MTFTPv6 related file "directory" has been downloaded.
 | 
			
		||||
  @retval  EFI_UNSUPPORTED       The EFI MTFTPv6 Protocol driver does not support this function.
 | 
			
		||||
  @retval  EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
 | 
			
		||||
                                 - This is NULL.
 | 
			
		||||
                                 - Token is NULL.
 | 
			
		||||
                                 - Token.Filename is NULL.
 | 
			
		||||
                                 - Token.OptionCount is not zero and Token.OptionList is NULL.
 | 
			
		||||
                                 - One or more options in Token.OptionList have wrong format.
 | 
			
		||||
                                 - Token.Buffer and Token.CheckPacket are both NULL.
 | 
			
		||||
                                 - Token.OverrideData.ServerIp is not valid unicast IPv6 addresses.
 | 
			
		||||
  @retval  EFI_UNSUPPORTED       One or more options in the Token.OptionList are not
 | 
			
		||||
                                 supported by this implementation.
 | 
			
		||||
  @retval  EFI_NOT_STARTED       The EFI MTFTPv6 Protocol driver has not been started.
 | 
			
		||||
  @retval  EFI_NO_MAPPING        The underlying IPv6 driver was responsible for choosing a source
 | 
			
		||||
                                 address for this instance, but no source address was available for use.
 | 
			
		||||
  @retval  EFI_ALREADY_STARTED   This Token is already being used in another MTFTPv6 session.
 | 
			
		||||
  @retval  EFI_OUT_OF_RESOURCES  Required system resources could not be allocated.
 | 
			
		||||
  @retval  EFI_ACCESS_DENIED     The previous operation has not completed yet.
 | 
			
		||||
  @retval  EFI_DEVICE_ERROR      An unexpected network error or system error occurred.
 | 
			
		||||
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_MTFTP6_READ_DIRECTORY)(
 | 
			
		||||
  IN EFI_MTFTP6_PROTOCOL      *This,
 | 
			
		||||
  IN EFI_MTFTP6_TOKEN         *Token
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Polls for incoming data packets and processes outgoing data packets.
 | 
			
		||||
 | 
			
		||||
  The Poll() function can be used by network drivers and applications to increase the rate that data
 | 
			
		||||
  packets are moved between the communications device and the transmit and receive queues.
 | 
			
		||||
  In some systems, the periodic timer event in the managed network driver may not poll the
 | 
			
		||||
  underlying communications device fast enough to transmit and/or receive all data packets without
 | 
			
		||||
  missing incoming packets or dropping outgoing packets. Drivers and applications that are
 | 
			
		||||
  experiencing packet loss should try calling the Poll() function more often.
 | 
			
		||||
 | 
			
		||||
  @param[in]  This               Pointer to the EFI_MTFTP6_PROTOCOL instance.
 | 
			
		||||
 | 
			
		||||
  @retval  EFI_SUCCESS           Incoming or outgoing data was processed.
 | 
			
		||||
  @retval  EFI_NOT_STARTED       This EFI MTFTPv6 Protocol instance has not been started.
 | 
			
		||||
  @retval  EFI_INVALID_PARAMETER This is NULL.
 | 
			
		||||
  @retval  EFI_DEVICE_ERROR      An unexpected system or network error occurred.
 | 
			
		||||
  @retval  EFI_TIMEOUT           Data was dropped out of the transmit and/or receive queue.
 | 
			
		||||
                                 Consider increasing the polling rate.
 | 
			
		||||
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_MTFTP6_POLL)(
 | 
			
		||||
  IN EFI_MTFTP6_PROTOCOL      *This
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// The EFI_MTFTP6_PROTOCOL is designed to be used by UEFI drivers and applications to transmit
 | 
			
		||||
/// and receive data files. The EFI MTFTPv6 Protocol driver uses the underlying EFI UDPv6 Protocol
 | 
			
		||||
/// driver and EFI IPv6 Protocol driver.
 | 
			
		||||
///
 | 
			
		||||
struct _EFI_MTFTP6_PROTOCOL {
 | 
			
		||||
  EFI_MTFTP6_GET_MODE_DATA     GetModeData;
 | 
			
		||||
  EFI_MTFTP6_CONFIGURE         Configure;
 | 
			
		||||
  EFI_MTFTP6_GET_INFO          GetInfo;
 | 
			
		||||
  EFI_MTFTP6_PARSE_OPTIONS     ParseOptions;
 | 
			
		||||
  EFI_MTFTP6_READ_FILE         ReadFile;
 | 
			
		||||
  EFI_MTFTP6_WRITE_FILE        WriteFile;
 | 
			
		||||
  EFI_MTFTP6_READ_DIRECTORY    ReadDirectory;
 | 
			
		||||
  EFI_MTFTP6_POLL              Poll;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
extern EFI_GUID  gEfiMtftp6ServiceBindingProtocolGuid;
 | 
			
		||||
extern EFI_GUID  gEfiMtftp6ProtocolGuid;
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										31
									
								
								src/include/ipxe/efi/Protocol/ShimLock.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								src/include/ipxe/efi/Protocol/ShimLock.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,31 @@
 | 
			
		||||
#ifndef _IPXE_EFI_SHIM_LOCK_PROTOCOL_H
 | 
			
		||||
#define _IPXE_EFI_SHIM_LOCK_PROTOCOL_H
 | 
			
		||||
 | 
			
		||||
/** @file
 | 
			
		||||
 *
 | 
			
		||||
 * EFI "shim lock" protocol
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
FILE_LICENCE ( BSD3 );
 | 
			
		||||
 | 
			
		||||
#define EFI_SHIM_LOCK_PROTOCOL_GUID					\
 | 
			
		||||
	{ 0x605dab50, 0xe046, 0x4300,					\
 | 
			
		||||
	{ 0xab, 0xb6, 0x3d, 0xd8, 0x10, 0xdd, 0x8b, 0x23 } }
 | 
			
		||||
 | 
			
		||||
#define SHIMAPI __asmcall
 | 
			
		||||
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS SHIMAPI
 | 
			
		||||
(*EFI_SHIM_LOCK_VERIFY) (
 | 
			
		||||
  IN VOID *buffer,
 | 
			
		||||
  IN UINT32 size
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
typedef struct _EFI_SHIM_LOCK_PROTOCOL {
 | 
			
		||||
  EFI_SHIM_LOCK_VERIFY Verify;
 | 
			
		||||
  VOID *Reserved1;
 | 
			
		||||
  VOID *Reserved2;
 | 
			
		||||
} EFI_SHIM_LOCK_PROTOCOL;
 | 
			
		||||
 | 
			
		||||
#endif /*_IPXE_EFI_SHIM_LOCK_PROTOCOL_H */
 | 
			
		||||
							
								
								
									
										858
									
								
								src/include/ipxe/efi/Protocol/Tcp6.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										858
									
								
								src/include/ipxe/efi/Protocol/Tcp6.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,858 @@
 | 
			
		||||
/** @file
 | 
			
		||||
  EFI TCPv6(Transmission Control Protocol version 6) Protocol Definition
 | 
			
		||||
  The EFI TCPv6 Service Binding Protocol is used to locate EFI TCPv6 Protocol drivers to create
 | 
			
		||||
  and destroy child of the driver to communicate with other host using TCP protocol.
 | 
			
		||||
  The EFI TCPv6 Protocol provides services to send and receive data stream.
 | 
			
		||||
 | 
			
		||||
  Copyright (c) 2008 - 2014, Intel Corporation. All rights reserved.<BR>
 | 
			
		||||
  SPDX-License-Identifier: BSD-2-Clause-Patent
 | 
			
		||||
 | 
			
		||||
  @par Revision Reference:
 | 
			
		||||
  This Protocol is introduced in UEFI Specification 2.2
 | 
			
		||||
 | 
			
		||||
**/
 | 
			
		||||
 | 
			
		||||
#ifndef __EFI_TCP6_PROTOCOL_H__
 | 
			
		||||
#define __EFI_TCP6_PROTOCOL_H__
 | 
			
		||||
 | 
			
		||||
FILE_LICENCE ( BSD2_PATENT );
 | 
			
		||||
 | 
			
		||||
#include <ipxe/efi/Protocol/ManagedNetwork.h>
 | 
			
		||||
#include <ipxe/efi/Protocol/Ip6.h>
 | 
			
		||||
 | 
			
		||||
#define EFI_TCP6_SERVICE_BINDING_PROTOCOL_GUID \
 | 
			
		||||
  { \
 | 
			
		||||
    0xec20eb79, 0x6c1a, 0x4664, {0x9a, 0x0d, 0xd2, 0xe4, 0xcc, 0x16, 0xd6, 0x64 } \
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
#define EFI_TCP6_PROTOCOL_GUID \
 | 
			
		||||
  { \
 | 
			
		||||
    0x46e44855, 0xbd60, 0x4ab7, {0xab, 0x0d, 0xa6, 0x79, 0xb9, 0x44, 0x7d, 0x77 } \
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
typedef struct _EFI_TCP6_PROTOCOL EFI_TCP6_PROTOCOL;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_TCP6_SERVICE_POINT is deprecated in the UEFI 2.4B and should not be used any more.
 | 
			
		||||
/// The definition in here is only present to provide backwards compatability.
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// The EFI TCPv6 Protocol instance handle that is using this
 | 
			
		||||
  /// address/port pair.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_HANDLE          InstanceHandle;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The local IPv6 address to which this TCP instance is bound. Set
 | 
			
		||||
  /// to 0::/128, if this TCP instance is configured to listen on all
 | 
			
		||||
  /// available source addresses.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_IPv6_ADDRESS    LocalAddress;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The local port number in host byte order.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT16              LocalPort;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The remote IPv6 address. It may be 0::/128 if this TCP instance is
 | 
			
		||||
  /// not connected to any remote host.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_IPv6_ADDRESS    RemoteAddress;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The remote port number in host byte order. It may be zero if this
 | 
			
		||||
  /// TCP instance is not connected to any remote host.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT16              RemotePort;
 | 
			
		||||
} EFI_TCP6_SERVICE_POINT;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_TCP6_VARIABLE_DATA is deprecated in the UEFI 2.4B and should not be used any more.
 | 
			
		||||
/// The definition in here is only present to provide backwards compatability.
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  EFI_HANDLE                DriverHandle; ///< The handle of the driver that creates this entry.
 | 
			
		||||
  UINT32                    ServiceCount; ///< The number of address/port pairs following this data structure.
 | 
			
		||||
  EFI_TCP6_SERVICE_POINT    Services[1];  ///< List of address/port pairs that are currently in use.
 | 
			
		||||
} EFI_TCP6_VARIABLE_DATA;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_TCP6_ACCESS_POINT
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// The local IP address assigned to this TCP instance. The EFI
 | 
			
		||||
  /// TCPv6 driver will only deliver incoming packets whose
 | 
			
		||||
  /// destination addresses exactly match the IP address. Set to zero to
 | 
			
		||||
  /// let the underlying IPv6 driver choose a source address. If not zero
 | 
			
		||||
  /// it must be one of the configured IP addresses in the underlying
 | 
			
		||||
  /// IPv6 driver.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_IPv6_ADDRESS    StationAddress;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The local port number to which this EFI TCPv6 Protocol instance
 | 
			
		||||
  /// is bound. If the instance doesn't care the local port number, set
 | 
			
		||||
  /// StationPort to zero to use an ephemeral port.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT16              StationPort;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The remote IP address to which this EFI TCPv6 Protocol instance
 | 
			
		||||
  /// is connected. If ActiveFlag is FALSE (i.e. a passive TCPv6
 | 
			
		||||
  /// instance), the instance only accepts connections from the
 | 
			
		||||
  /// RemoteAddress. If ActiveFlag is TRUE the instance will
 | 
			
		||||
  /// connect to the RemoteAddress, i.e., outgoing segments will be
 | 
			
		||||
  /// sent to this address and only segments from this address will be
 | 
			
		||||
  /// delivered to the application. When ActiveFlag is FALSE, it
 | 
			
		||||
  /// can be set to zero and means that incoming connection requests
 | 
			
		||||
  /// from any address will be accepted.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_IPv6_ADDRESS    RemoteAddress;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The remote port to which this EFI TCPv6 Protocol instance
 | 
			
		||||
  /// connects or from which connection request will be accepted by
 | 
			
		||||
  /// this EFI TCPv6 Protocol instance. If ActiveFlag is FALSE it
 | 
			
		||||
  /// can be zero and means that incoming connection request from
 | 
			
		||||
  /// any port will be accepted. Its value can not be zero when
 | 
			
		||||
  /// ActiveFlag is TRUE.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT16     RemotePort;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Set it to TRUE to initiate an active open. Set it to FALSE to
 | 
			
		||||
  /// initiate a passive open to act as a server.
 | 
			
		||||
  ///
 | 
			
		||||
  BOOLEAN    ActiveFlag;
 | 
			
		||||
} EFI_TCP6_ACCESS_POINT;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_TCP6_OPTION
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// The size of the TCP receive buffer.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32    ReceiveBufferSize;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The size of the TCP send buffer.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32    SendBufferSize;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The length of incoming connect request queue for a passive
 | 
			
		||||
  /// instance. When set to zero, the value is implementation specific.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32    MaxSynBackLog;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The maximum seconds a TCP instance will wait for before a TCP
 | 
			
		||||
  /// connection established. When set to zero, the value is
 | 
			
		||||
  /// implementation specific.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32    ConnectionTimeout;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The number of times TCP will attempt to retransmit a packet on
 | 
			
		||||
  /// an established connection. When set to zero, the value is
 | 
			
		||||
  /// implementation specific.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32    DataRetries;
 | 
			
		||||
  ///
 | 
			
		||||
  /// How many seconds to wait in the FIN_WAIT_2 states for a final
 | 
			
		||||
  /// FIN flag before the TCP instance is closed. This timeout is in
 | 
			
		||||
  /// effective only if the application has called Close() to
 | 
			
		||||
  /// disconnect the connection completely. It is also called
 | 
			
		||||
  /// FIN_WAIT_2 timer in other implementations. When set to zero,
 | 
			
		||||
  /// it should be disabled because the FIN_WAIT_2 timer itself is
 | 
			
		||||
  /// against the standard. The default value is 60.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32     FinTimeout;
 | 
			
		||||
  ///
 | 
			
		||||
  /// How many seconds to wait in TIME_WAIT state before the TCP
 | 
			
		||||
  /// instance is closed. The timer is disabled completely to provide a
 | 
			
		||||
  /// method to close the TCP connection quickly if it is set to zero. It
 | 
			
		||||
  /// is against the related RFC documents.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32     TimeWaitTimeout;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The maximum number of TCP keep-alive probes to send before
 | 
			
		||||
  /// giving up and resetting the connection if no response from the
 | 
			
		||||
  /// other end. Set to zero to disable keep-alive probe.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32     KeepAliveProbes;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The number of seconds a connection needs to be idle before TCP
 | 
			
		||||
  /// sends out periodical keep-alive probes. When set to zero, the
 | 
			
		||||
  /// value is implementation specific. It should be ignored if keep-
 | 
			
		||||
  /// alive probe is disabled.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32     KeepAliveTime;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The number of seconds between TCP keep-alive probes after the
 | 
			
		||||
  /// periodical keep-alive probe if no response. When set to zero, the
 | 
			
		||||
  /// value is implementation specific. It should be ignored if keep-
 | 
			
		||||
  /// alive probe is disabled.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32     KeepAliveInterval;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Set it to TRUE to enable the Nagle algorithm as defined in
 | 
			
		||||
  /// RFC896. Set it to FALSE to disable it.
 | 
			
		||||
  ///
 | 
			
		||||
  BOOLEAN    EnableNagle;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Set it to TRUE to enable TCP timestamps option as defined in
 | 
			
		||||
  /// RFC1323. Set to FALSE to disable it.
 | 
			
		||||
  ///
 | 
			
		||||
  BOOLEAN    EnableTimeStamp;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Set it to TRUE to enable TCP window scale option as defined in
 | 
			
		||||
  /// RFC1323. Set it to FALSE to disable it.
 | 
			
		||||
  ///
 | 
			
		||||
  BOOLEAN    EnableWindowScaling;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Set it to TRUE to enable selective acknowledge mechanism
 | 
			
		||||
  /// described in RFC 2018. Set it to FALSE to disable it.
 | 
			
		||||
  /// Implementation that supports SACK can optionally support
 | 
			
		||||
  /// DSAK as defined in RFC 2883.
 | 
			
		||||
  ///
 | 
			
		||||
  BOOLEAN    EnableSelectiveAck;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Set it to TRUE to enable path MTU discovery as defined in
 | 
			
		||||
  /// RFC 1191. Set to FALSE to disable it.
 | 
			
		||||
  ///
 | 
			
		||||
  BOOLEAN    EnablePathMtuDiscovery;
 | 
			
		||||
} EFI_TCP6_OPTION;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_TCP6_CONFIG_DATA
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// TrafficClass field in transmitted IPv6 packets.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT8                    TrafficClass;
 | 
			
		||||
  ///
 | 
			
		||||
  /// HopLimit field in transmitted IPv6 packets.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT8                    HopLimit;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Used to specify TCP communication end settings for a TCP instance.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_TCP6_ACCESS_POINT    AccessPoint;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Used to configure the advance TCP option for a connection. If set
 | 
			
		||||
  /// to NULL, implementation specific options for TCP connection will be used.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_TCP6_OPTION          *ControlOption;
 | 
			
		||||
} EFI_TCP6_CONFIG_DATA;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_TCP6_CONNECTION_STATE
 | 
			
		||||
///
 | 
			
		||||
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;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_TCP6_COMPLETION_TOKEN
 | 
			
		||||
/// is used as a common header for various asynchronous tokens.
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// The Event to signal after request is finished and Status field is
 | 
			
		||||
  /// updated by the EFI TCPv6 Protocol driver.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_EVENT     Event;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The result of the completed operation.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_STATUS    Status;
 | 
			
		||||
} EFI_TCP6_COMPLETION_TOKEN;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_TCP6_CONNECTION_TOKEN
 | 
			
		||||
/// will be set if the active open succeeds or an unexpected
 | 
			
		||||
/// error happens.
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// The Status in the CompletionToken will be set to one of
 | 
			
		||||
  /// the following values if the active open succeeds or an unexpected
 | 
			
		||||
  /// error happens:
 | 
			
		||||
  /// EFI_SUCCESS:              The active open succeeds and the instance's
 | 
			
		||||
  ///                           state is Tcp6StateEstablished.
 | 
			
		||||
  /// EFI_CONNECTION_RESET:     The connect fails because the connection is reset
 | 
			
		||||
  ///                           either by instance itself or the communication peer.
 | 
			
		||||
  /// EFI_CONNECTION_REFUSED:   The receiving or transmission operation fails because this
 | 
			
		||||
  ///                           connection is refused.
 | 
			
		||||
  /// EFI_ABORTED:              The active open is aborted.
 | 
			
		||||
  /// EFI_TIMEOUT:              The connection establishment timer expires and
 | 
			
		||||
  ///                           no more specific information is available.
 | 
			
		||||
  /// EFI_NETWORK_UNREACHABLE:  The active open fails because
 | 
			
		||||
  ///                           an ICMP network unreachable error is received.
 | 
			
		||||
  /// EFI_HOST_UNREACHABLE:     The active open fails because an
 | 
			
		||||
  ///                           ICMP host unreachable error is received.
 | 
			
		||||
  /// EFI_PROTOCOL_UNREACHABLE: The active open fails
 | 
			
		||||
  ///                           because an ICMP protocol unreachable error is received.
 | 
			
		||||
  /// EFI_PORT_UNREACHABLE:     The connection establishment
 | 
			
		||||
  ///                           timer times out and an ICMP port unreachable error is received.
 | 
			
		||||
  /// EFI_ICMP_ERROR:           The connection establishment timer times
 | 
			
		||||
  ///                           out and some other ICMP error is received.
 | 
			
		||||
  /// EFI_DEVICE_ERROR:         An unexpected system or network error occurred.
 | 
			
		||||
  /// EFI_SECURITY_VIOLATION:   The active open was failed because of IPSec policy check.
 | 
			
		||||
  /// EFI_NO_MEDIA:             There was a media error.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_TCP6_COMPLETION_TOKEN    CompletionToken;
 | 
			
		||||
} EFI_TCP6_CONNECTION_TOKEN;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_TCP6_LISTEN_TOKEN
 | 
			
		||||
/// returns when list operation finishes.
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// The Status in CompletionToken will be set to the
 | 
			
		||||
  /// following value if accept finishes:
 | 
			
		||||
  /// EFI_SUCCESS:            A remote peer has successfully established a
 | 
			
		||||
  ///                         connection to this instance. A new TCP instance has also been
 | 
			
		||||
  ///                         created for the connection.
 | 
			
		||||
  /// EFI_CONNECTION_RESET:   The accept fails because the connection is reset either
 | 
			
		||||
  ///                         by instance itself or communication peer.
 | 
			
		||||
  /// EFI_ABORTED:            The accept request has been aborted.
 | 
			
		||||
  /// EFI_SECURITY_VIOLATION: The accept operation was failed because of IPSec policy check.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_TCP6_COMPLETION_TOKEN    CompletionToken;
 | 
			
		||||
  EFI_HANDLE                   NewChildHandle;
 | 
			
		||||
} EFI_TCP6_LISTEN_TOKEN;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_TCP6_FRAGMENT_DATA
 | 
			
		||||
/// allows multiple receive or transmit buffers to be specified. The
 | 
			
		||||
/// purpose of this structure is to provide scattered read and write.
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  UINT32    FragmentLength;  ///< Length of data buffer in the fragment.
 | 
			
		||||
  VOID      *FragmentBuffer; ///< Pointer to the data buffer in the fragment.
 | 
			
		||||
} EFI_TCP6_FRAGMENT_DATA;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_TCP6_RECEIVE_DATA
 | 
			
		||||
/// When TCPv6 driver wants to deliver received data to the application,
 | 
			
		||||
/// it will pick up the first queued receiving token, update its
 | 
			
		||||
/// Token->Packet.RxData then signal the Token->CompletionToken.Event.
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// Whether the data is urgent. When this flag is set, the instance is in
 | 
			
		||||
  /// urgent mode.
 | 
			
		||||
  ///
 | 
			
		||||
  BOOLEAN                   UrgentFlag;
 | 
			
		||||
  ///
 | 
			
		||||
  /// When calling Receive() function, it is the byte counts of all
 | 
			
		||||
  /// Fragmentbuffer in FragmentTable allocated by user.
 | 
			
		||||
  /// When the token is signaled by TCPv6 driver it is the length of
 | 
			
		||||
  /// received data in the fragments.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32                    DataLength;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Number of fragments.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32                    FragmentCount;
 | 
			
		||||
  ///
 | 
			
		||||
  /// An array of fragment descriptors.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_TCP6_FRAGMENT_DATA    FragmentTable[1];
 | 
			
		||||
} EFI_TCP6_RECEIVE_DATA;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_TCP6_TRANSMIT_DATA
 | 
			
		||||
/// The EFI TCPv6 Protocol user must fill this data structure before sending a packet.
 | 
			
		||||
/// The packet may contain multiple buffers in non-continuous memory locations.
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// Push If TRUE, data must be transmitted promptly, and the PUSH bit in
 | 
			
		||||
  /// the last TCP segment created will be set. If FALSE, data
 | 
			
		||||
  /// transmission may be delayed to combine with data from
 | 
			
		||||
  /// subsequent Transmit()s for efficiency.
 | 
			
		||||
  ///
 | 
			
		||||
  BOOLEAN                   Push;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The data in the fragment table are urgent and urgent point is in
 | 
			
		||||
  /// effect if TRUE. Otherwise those data are NOT considered urgent.
 | 
			
		||||
  ///
 | 
			
		||||
  BOOLEAN                   Urgent;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Length of the data in the fragments.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32                    DataLength;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Number of fragments.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32                    FragmentCount;
 | 
			
		||||
  ///
 | 
			
		||||
  /// An array of fragment descriptors.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_TCP6_FRAGMENT_DATA    FragmentTable[1];
 | 
			
		||||
} EFI_TCP6_TRANSMIT_DATA;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_TCP6_IO_TOKEN
 | 
			
		||||
/// returns When transmission finishes or meets any unexpected error.
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// When transmission finishes or meets any unexpected error it will
 | 
			
		||||
  /// be set to one of the following values:
 | 
			
		||||
  /// EFI_SUCCESS:              The receiving or transmission operation
 | 
			
		||||
  ///                           completes successfully.
 | 
			
		||||
  /// EFI_CONNECTION_FIN:       The receiving operation fails because the communication peer
 | 
			
		||||
  ///                           has closed the connection and there is no more data in the
 | 
			
		||||
  ///                           receive buffer of the instance.
 | 
			
		||||
  /// EFI_CONNECTION_RESET:     The receiving or transmission operation fails
 | 
			
		||||
  ///                           because this connection is reset either by instance
 | 
			
		||||
  ///                           itself or the communication peer.
 | 
			
		||||
  /// EFI_ABORTED:              The receiving or transmission is aborted.
 | 
			
		||||
  /// EFI_TIMEOUT:              The transmission timer expires and no more
 | 
			
		||||
  ///                           specific information is available.
 | 
			
		||||
  /// EFI_NETWORK_UNREACHABLE:  The transmission fails
 | 
			
		||||
  ///                           because an ICMP network unreachable error is received.
 | 
			
		||||
  /// EFI_HOST_UNREACHABLE:     The transmission fails because an
 | 
			
		||||
  ///                           ICMP host unreachable error is received.
 | 
			
		||||
  /// EFI_PROTOCOL_UNREACHABLE: The transmission fails
 | 
			
		||||
  ///                           because an ICMP protocol unreachable error is received.
 | 
			
		||||
  /// EFI_PORT_UNREACHABLE:     The transmission fails and an
 | 
			
		||||
  ///                           ICMP port unreachable error is received.
 | 
			
		||||
  /// EFI_ICMP_ERROR:           The transmission fails and some other
 | 
			
		||||
  ///                           ICMP error is received.
 | 
			
		||||
  /// EFI_DEVICE_ERROR:         An unexpected system or network error occurs.
 | 
			
		||||
  /// EFI_SECURITY_VIOLATION:   The receiving or transmission
 | 
			
		||||
  ///                           operation was failed because of IPSec policy check
 | 
			
		||||
  /// EFI_NO_MEDIA:             There was a media error.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_TCP6_COMPLETION_TOKEN    CompletionToken;
 | 
			
		||||
  union {
 | 
			
		||||
    ///
 | 
			
		||||
    /// When this token is used for receiving, RxData is a pointer to
 | 
			
		||||
    /// EFI_TCP6_RECEIVE_DATA.
 | 
			
		||||
    ///
 | 
			
		||||
    EFI_TCP6_RECEIVE_DATA     *RxData;
 | 
			
		||||
    ///
 | 
			
		||||
    /// When this token is used for transmitting, TxData is a pointer to
 | 
			
		||||
    /// EFI_TCP6_TRANSMIT_DATA.
 | 
			
		||||
    ///
 | 
			
		||||
    EFI_TCP6_TRANSMIT_DATA    *TxData;
 | 
			
		||||
  } Packet;
 | 
			
		||||
} EFI_TCP6_IO_TOKEN;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_TCP6_CLOSE_TOKEN
 | 
			
		||||
/// returns when close operation finishes.
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// When close finishes or meets any unexpected error it will be set
 | 
			
		||||
  /// to one of the following values:
 | 
			
		||||
  /// EFI_SUCCESS:            The close operation completes successfully.
 | 
			
		||||
  /// EFI_ABORTED:            User called configure with NULL without close stopping.
 | 
			
		||||
  /// EFI_SECURITY_VIOLATION: The close operation was failed because of IPSec policy check.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_TCP6_COMPLETION_TOKEN    CompletionToken;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Abort the TCP connection on close instead of the standard TCP
 | 
			
		||||
  /// close process when it is set to TRUE. This option can be used to
 | 
			
		||||
  /// satisfy a fast disconnect.
 | 
			
		||||
  ///
 | 
			
		||||
  BOOLEAN                      AbortOnClose;
 | 
			
		||||
} EFI_TCP6_CLOSE_TOKEN;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Get the current operational status.
 | 
			
		||||
 | 
			
		||||
  The GetModeData() function copies the current operational settings of this EFI TCPv6
 | 
			
		||||
  Protocol instance into user-supplied buffers. This function can also be used to retrieve
 | 
			
		||||
  the operational setting of underlying drivers such as IPv6, MNP, or SNP.
 | 
			
		||||
 | 
			
		||||
  @param[in]  This              Pointer to the EFI_TCP6_PROTOCOL instance.
 | 
			
		||||
  @param[out] Tcp6State         The buffer in which the current TCP state is returned.
 | 
			
		||||
  @param[out] Tcp6ConfigData    The buffer in which the current TCP configuration is returned.
 | 
			
		||||
  @param[out] Ip6ModeData       The buffer in which the current IPv6 configuration data used by
 | 
			
		||||
                                the TCP instance is returned.
 | 
			
		||||
  @param[out] MnpConfigData     The buffer in which the current MNP configuration data used
 | 
			
		||||
                                indirectly by the TCP instance is returned.
 | 
			
		||||
  @param[out] SnpModeData       The buffer in which the current SNP mode data used indirectly by
 | 
			
		||||
                                the TCP instance is returned.
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS           The mode data was read.
 | 
			
		||||
  @retval EFI_NOT_STARTED       No configuration data is available because this instance hasn't
 | 
			
		||||
                                been started.
 | 
			
		||||
  @retval EFI_INVALID_PARAMETER This is NULL.
 | 
			
		||||
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_TCP6_GET_MODE_DATA)(
 | 
			
		||||
  IN  EFI_TCP6_PROTOCOL                  *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
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Initialize or brutally reset the operational parameters for this EFI TCPv6 instance.
 | 
			
		||||
 | 
			
		||||
  The Configure() function does the following:
 | 
			
		||||
  - Initialize this TCP instance, i.e., initialize the communication end settings and
 | 
			
		||||
    specify active open or passive open for an instance.
 | 
			
		||||
  - Reset this TCP instance brutally, i.e., cancel all pending asynchronous tokens, flush
 | 
			
		||||
    transmission and receiving buffer directly without informing the communication peer.
 | 
			
		||||
 | 
			
		||||
  No other TCPv6 Protocol operation except Poll() can be executed by this instance until
 | 
			
		||||
  it is configured properly. For an active TCP instance, after a proper configuration it
 | 
			
		||||
  may call Connect() to initiates the three-way handshake. For a passive TCP instance,
 | 
			
		||||
  its state will transit to Tcp6StateListen after configuration, and Accept() may be
 | 
			
		||||
  called to listen the incoming TCP connection requests. If Tcp6ConfigData is set to NULL,
 | 
			
		||||
  the instance is reset. Resetting process will be done brutally, the state machine will
 | 
			
		||||
  be set to Tcp6StateClosed directly, the receive queue and transmit queue will be flushed,
 | 
			
		||||
  and no traffic is allowed through this instance.
 | 
			
		||||
 | 
			
		||||
  @param[in] This               Pointer to the EFI_TCP6_PROTOCOL instance.
 | 
			
		||||
  @param[in] Tcp6ConfigData     Pointer to the configure data to configure the instance.
 | 
			
		||||
                                If Tcp6ConfigData is set to NULL, the instance is reset.
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS           The operational settings are set, changed, or reset
 | 
			
		||||
                                successfully.
 | 
			
		||||
  @retval EFI_NO_MAPPING        The underlying IPv6 driver was responsible for choosing a source
 | 
			
		||||
                                address for this instance, but no source address was available for
 | 
			
		||||
                                use.
 | 
			
		||||
  @retval EFI_INVALID_PARAMETER One or more of the following conditions are TRUE:
 | 
			
		||||
                                - This is NULL.
 | 
			
		||||
                                - Tcp6ConfigData->AccessPoint.StationAddress is neither zero nor
 | 
			
		||||
                                  one of the configured IP addresses in the underlying IPv6 driver.
 | 
			
		||||
                                - Tcp6ConfigData->AccessPoint.RemoteAddress isn't a valid unicast
 | 
			
		||||
                                  IPv6 address.
 | 
			
		||||
                                - Tcp6ConfigData->AccessPoint.RemoteAddress is zero or
 | 
			
		||||
                                  Tcp6ConfigData->AccessPoint.RemotePort is zero when
 | 
			
		||||
                                  Tcp6ConfigData->AccessPoint.ActiveFlag is TRUE.
 | 
			
		||||
                                - A same access point has been configured in other TCP
 | 
			
		||||
                                  instance properly.
 | 
			
		||||
  @retval EFI_ACCESS_DENIED     Configuring TCP instance when it is configured without
 | 
			
		||||
                                calling Configure() with NULL to reset it.
 | 
			
		||||
  @retval EFI_UNSUPPORTED       One or more of the control options are not supported in
 | 
			
		||||
                                the implementation.
 | 
			
		||||
  @retval EFI_OUT_OF_RESOURCES  Could not allocate enough system resources when
 | 
			
		||||
                                executing Configure().
 | 
			
		||||
  @retval EFI_DEVICE_ERROR      An unexpected network or system error occurred.
 | 
			
		||||
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_TCP6_CONFIGURE)(
 | 
			
		||||
  IN EFI_TCP6_PROTOCOL        *This,
 | 
			
		||||
  IN EFI_TCP6_CONFIG_DATA     *Tcp6ConfigData OPTIONAL
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Initiate a nonblocking TCP connection request for an active TCP instance.
 | 
			
		||||
 | 
			
		||||
  The Connect() function will initiate an active open to the remote peer configured
 | 
			
		||||
  in current TCP instance if it is configured active. If the connection succeeds or
 | 
			
		||||
  fails due to any error, the ConnectionToken->CompletionToken.Event will be signaled
 | 
			
		||||
  and ConnectionToken->CompletionToken.Status will be updated accordingly. This
 | 
			
		||||
  function can only be called for the TCP instance in Tcp6StateClosed state. The
 | 
			
		||||
  instance will transfer into Tcp6StateSynSent if the function returns EFI_SUCCESS.
 | 
			
		||||
  If TCP three-way handshake succeeds, its state will become Tcp6StateEstablished,
 | 
			
		||||
  otherwise, the state will return to Tcp6StateClosed.
 | 
			
		||||
 | 
			
		||||
  @param[in] This                Pointer to the EFI_TCP6_PROTOCOL instance.
 | 
			
		||||
  @param[in] ConnectionToken     Pointer to the connection token to return when the TCP three
 | 
			
		||||
                                 way handshake finishes.
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS            The connection request is successfully initiated and the state of
 | 
			
		||||
                                 this TCP instance has been changed to Tcp6StateSynSent.
 | 
			
		||||
  @retval EFI_NOT_STARTED        This EFI TCPv6 Protocol instance has not been configured.
 | 
			
		||||
  @retval EFI_ACCESS_DENIED      One or more of the following conditions are TRUE:
 | 
			
		||||
                                 - This instance is not configured as an active one.
 | 
			
		||||
                                 - This instance is not in Tcp6StateClosed state.
 | 
			
		||||
  @retval EFI_INVALID_PARAMETER  One or more of the following are TRUE:
 | 
			
		||||
                                 - This is NULL.
 | 
			
		||||
                                 - ConnectionToken is NULL.
 | 
			
		||||
                                 - ConnectionToken->CompletionToken.Event is NULL.
 | 
			
		||||
  @retval EFI_OUT_OF_RESOURCES   The driver can't allocate enough resource to initiate the active open.
 | 
			
		||||
  @retval EFI_DEVICE_ERROR       An unexpected system or network error occurred.
 | 
			
		||||
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_TCP6_CONNECT)(
 | 
			
		||||
  IN EFI_TCP6_PROTOCOL           *This,
 | 
			
		||||
  IN EFI_TCP6_CONNECTION_TOKEN   *ConnectionToken
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Listen on the passive instance to accept an incoming connection request. This is a
 | 
			
		||||
  nonblocking operation.
 | 
			
		||||
 | 
			
		||||
  The Accept() function initiates an asynchronous accept request to wait for an incoming
 | 
			
		||||
  connection on the passive TCP instance. If a remote peer successfully establishes a
 | 
			
		||||
  connection with this instance, a new TCP instance will be created and its handle will
 | 
			
		||||
  be returned in ListenToken->NewChildHandle. The newly created instance is configured
 | 
			
		||||
  by inheriting the passive instance's configuration and is ready for use upon return.
 | 
			
		||||
  The new instance is in the Tcp6StateEstablished state.
 | 
			
		||||
 | 
			
		||||
  The ListenToken->CompletionToken.Event will be signaled when a new connection is
 | 
			
		||||
  accepted, user aborts the listen or connection is reset.
 | 
			
		||||
 | 
			
		||||
  This function only can be called when current TCP instance is in Tcp6StateListen state.
 | 
			
		||||
 | 
			
		||||
  @param[in] This                Pointer to the EFI_TCP6_PROTOCOL instance.
 | 
			
		||||
  @param[in] ListenToken         Pointer to the listen token to return when operation finishes.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS            The listen token has been queued successfully.
 | 
			
		||||
  @retval EFI_NOT_STARTED        This EFI TCPv6 Protocol instance has not been configured.
 | 
			
		||||
  @retval EFI_ACCESS_DENIED      One or more of the following are TRUE:
 | 
			
		||||
                                 - This instance is not a passive instance.
 | 
			
		||||
                                 - This instance is not in Tcp6StateListen state.
 | 
			
		||||
                                 - The same listen token has already existed in the listen
 | 
			
		||||
                                   token queue of this TCP instance.
 | 
			
		||||
  @retval EFI_INVALID_PARAMETER  One or more of the following are TRUE:
 | 
			
		||||
                                 - This is NULL.
 | 
			
		||||
                                 - ListenToken is NULL.
 | 
			
		||||
                                 - ListentToken->CompletionToken.Event is NULL.
 | 
			
		||||
  @retval EFI_OUT_OF_RESOURCES   Could not allocate enough resource to finish the operation.
 | 
			
		||||
  @retval EFI_DEVICE_ERROR       Any unexpected and not belonged to above category error.
 | 
			
		||||
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_TCP6_ACCEPT)(
 | 
			
		||||
  IN EFI_TCP6_PROTOCOL             *This,
 | 
			
		||||
  IN EFI_TCP6_LISTEN_TOKEN         *ListenToken
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Queues outgoing data into the transmit queue.
 | 
			
		||||
 | 
			
		||||
  The Transmit() function queues a sending request to this TCP instance along with the
 | 
			
		||||
  user data. The status of the token is updated and the event in the token will be
 | 
			
		||||
  signaled once the data is sent out or some error occurs.
 | 
			
		||||
 | 
			
		||||
  @param[in] This                 Pointer to the EFI_TCP6_PROTOCOL instance.
 | 
			
		||||
  @param[in] Token                Pointer to the completion token to queue to the transmit queue.
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS             The data has been queued for transmission.
 | 
			
		||||
  @retval EFI_NOT_STARTED         This EFI TCPv6 Protocol instance has not been configured.
 | 
			
		||||
  @retval EFI_NO_MAPPING          The underlying IPv6 driver was responsible for choosing a
 | 
			
		||||
                                  source address for this instance, but no source address was
 | 
			
		||||
                                  available for use.
 | 
			
		||||
  @retval EFI_INVALID_PARAMETER   One or more of the following are TRUE:
 | 
			
		||||
                                  - This is NULL.
 | 
			
		||||
                                  - Token is NULL.
 | 
			
		||||
                                  - Token->CompletionToken.Event is NULL.
 | 
			
		||||
                                  - Token->Packet.TxData is NULL.
 | 
			
		||||
                                  - Token->Packet.FragmentCount is zero.
 | 
			
		||||
                                  - Token->Packet.DataLength is not equal to the sum of fragment lengths.
 | 
			
		||||
  @retval EFI_ACCESS_DENIED       One or more of the following conditions are TRUE:
 | 
			
		||||
                                  - A transmit completion token with the same Token->
 | 
			
		||||
                                    CompletionToken.Event was already in the
 | 
			
		||||
                                    transmission queue.
 | 
			
		||||
                                  - The current instance is in Tcp6StateClosed state.
 | 
			
		||||
                                  - The current instance is a passive one and it is in
 | 
			
		||||
                                    Tcp6StateListen state.
 | 
			
		||||
                                  - User has called Close() to disconnect this connection.
 | 
			
		||||
  @retval EFI_NOT_READY           The completion token could not be queued because the
 | 
			
		||||
                                  transmit queue is full.
 | 
			
		||||
  @retval EFI_OUT_OF_RESOURCES    Could not queue the transmit data because of resource
 | 
			
		||||
                                  shortage.
 | 
			
		||||
  @retval EFI_NETWORK_UNREACHABLE There is no route to the destination network or address.
 | 
			
		||||
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_TCP6_TRANSMIT)(
 | 
			
		||||
  IN EFI_TCP6_PROTOCOL            *This,
 | 
			
		||||
  IN EFI_TCP6_IO_TOKEN            *Token
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Places an asynchronous receive request into the receiving queue.
 | 
			
		||||
 | 
			
		||||
  The Receive() function places a completion token into the receive packet queue. This
 | 
			
		||||
  function is always asynchronous. The caller must allocate the Token->CompletionToken.Event
 | 
			
		||||
  and the FragmentBuffer used to receive data. The caller also must fill the DataLength which
 | 
			
		||||
  represents the whole length of all FragmentBuffer. When the receive operation completes, the
 | 
			
		||||
  EFI TCPv6 Protocol driver updates the Token->CompletionToken.Status and Token->Packet.RxData
 | 
			
		||||
  fields and the Token->CompletionToken.Event is signaled. If got data the data and its length
 | 
			
		||||
  will be copied into the FragmentTable, at the same time the full length of received data will
 | 
			
		||||
  be recorded in the DataLength fields. Providing a proper notification function and context
 | 
			
		||||
  for the event will enable the user to receive the notification and receiving status. That
 | 
			
		||||
  notification function is guaranteed to not be re-entered.
 | 
			
		||||
 | 
			
		||||
  @param[in] This               Pointer to the EFI_TCP6_PROTOCOL instance.
 | 
			
		||||
  @param[in] Token              Pointer to a token that is associated with the receive data
 | 
			
		||||
                                descriptor.
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS            The receive completion token was cached.
 | 
			
		||||
  @retval EFI_NOT_STARTED        This EFI TCPv6 Protocol instance has not been configured.
 | 
			
		||||
  @retval EFI_NO_MAPPING         The underlying IPv6 driver was responsible for choosing a source
 | 
			
		||||
                                 address for this instance, but no source address was available for use.
 | 
			
		||||
  @retval EFI_INVALID_PARAMETER  One or more of the following conditions is TRUE:
 | 
			
		||||
                                 - This is NULL.
 | 
			
		||||
                                 - Token is NULL.
 | 
			
		||||
                                 - Token->CompletionToken.Event is NULL.
 | 
			
		||||
                                 - Token->Packet.RxData is NULL.
 | 
			
		||||
                                 - Token->Packet.RxData->DataLength is 0.
 | 
			
		||||
                                 - The Token->Packet.RxData->DataLength is not the
 | 
			
		||||
                                   sum of all FragmentBuffer length in FragmentTable.
 | 
			
		||||
  @retval EFI_OUT_OF_RESOURCES   The receive completion token could not be queued due to a lack of
 | 
			
		||||
                                 system resources (usually memory).
 | 
			
		||||
  @retval EFI_DEVICE_ERROR       An unexpected system or network error occurred.
 | 
			
		||||
                                 The EFI TCPv6 Protocol instance has been reset to startup defaults.
 | 
			
		||||
  @retval EFI_ACCESS_DENIED      One or more of the following conditions is TRUE:
 | 
			
		||||
                                 - A receive completion token with the same Token->CompletionToken.Event
 | 
			
		||||
                                   was already in the receive queue.
 | 
			
		||||
                                 - The current instance is in Tcp6StateClosed state.
 | 
			
		||||
                                 - The current instance is a passive one and it is in
 | 
			
		||||
                                   Tcp6StateListen state.
 | 
			
		||||
                                 - User has called Close() to disconnect this connection.
 | 
			
		||||
  @retval EFI_CONNECTION_FIN     The communication peer has closed the connection and there is no
 | 
			
		||||
                                 any buffered data in the receive buffer of this instance
 | 
			
		||||
  @retval EFI_NOT_READY          The receive request could not be queued because the receive queue is full.
 | 
			
		||||
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_TCP6_RECEIVE)(
 | 
			
		||||
  IN EFI_TCP6_PROTOCOL           *This,
 | 
			
		||||
  IN EFI_TCP6_IO_TOKEN           *Token
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Disconnecting a TCP connection gracefully or reset a TCP connection. This function is a
 | 
			
		||||
  nonblocking operation.
 | 
			
		||||
 | 
			
		||||
  Initiate an asynchronous close token to TCP driver. After Close() is called, any buffered
 | 
			
		||||
  transmission data will be sent by TCP driver and the current instance will have a graceful close
 | 
			
		||||
  working flow described as RFC 793 if AbortOnClose is set to FALSE, otherwise, a rest packet
 | 
			
		||||
  will be sent by TCP driver to fast disconnect this connection. When the close operation completes
 | 
			
		||||
  successfully the TCP instance is in Tcp6StateClosed state, all pending asynchronous
 | 
			
		||||
  operations are signaled and any buffers used for TCP network traffic are flushed.
 | 
			
		||||
 | 
			
		||||
  @param[in] This                Pointer to the EFI_TCP6_PROTOCOL instance.
 | 
			
		||||
  @param[in] CloseToken          Pointer to the close token to return when operation finishes.
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS            The Close() is called successfully.
 | 
			
		||||
  @retval EFI_NOT_STARTED        This EFI TCPv6 Protocol instance has not been configured.
 | 
			
		||||
  @retval EFI_ACCESS_DENIED      One or more of the following are TRUE:
 | 
			
		||||
                                 - CloseToken or CloseToken->CompletionToken.Event is already in use.
 | 
			
		||||
                                 - Previous Close() call on this instance has not finished.
 | 
			
		||||
  @retval EFI_INVALID_PARAMETER  One or more of the following are TRUE:
 | 
			
		||||
                                 - This is NULL.
 | 
			
		||||
                                 - CloseToken is NULL.
 | 
			
		||||
                                 - CloseToken->CompletionToken.Event is NULL.
 | 
			
		||||
  @retval EFI_OUT_OF_RESOURCES   Could not allocate enough resource to finish the operation.
 | 
			
		||||
  @retval EFI_DEVICE_ERROR       Any unexpected and not belonged to above category error.
 | 
			
		||||
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_TCP6_CLOSE)(
 | 
			
		||||
  IN EFI_TCP6_PROTOCOL           *This,
 | 
			
		||||
  IN EFI_TCP6_CLOSE_TOKEN        *CloseToken
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Abort an asynchronous connection, listen, transmission or receive request.
 | 
			
		||||
 | 
			
		||||
  The Cancel() function aborts a pending connection, listen, transmit or
 | 
			
		||||
  receive request.
 | 
			
		||||
 | 
			
		||||
  If Token is not NULL and the token is in the connection, listen, transmission
 | 
			
		||||
  or receive queue when it is being cancelled, its Token->Status will be set
 | 
			
		||||
  to EFI_ABORTED and then Token->Event will be signaled.
 | 
			
		||||
 | 
			
		||||
  If the token is not in one of the queues, which usually means that the
 | 
			
		||||
  asynchronous operation has completed, EFI_NOT_FOUND is returned.
 | 
			
		||||
 | 
			
		||||
  If Token is NULL all asynchronous token issued by Connect(), Accept(),
 | 
			
		||||
  Transmit() and Receive() will be aborted.
 | 
			
		||||
 | 
			
		||||
  @param[in] This                Pointer to the EFI_TCP6_PROTOCOL instance.
 | 
			
		||||
  @param[in] Token               Pointer to a token that has been issued by
 | 
			
		||||
                                 EFI_TCP6_PROTOCOL.Connect(),
 | 
			
		||||
                                 EFI_TCP6_PROTOCOL.Accept(),
 | 
			
		||||
                                 EFI_TCP6_PROTOCOL.Transmit() or
 | 
			
		||||
                                 EFI_TCP6_PROTOCOL.Receive(). If NULL, all pending
 | 
			
		||||
                                 tokens issued by above four functions will be aborted. Type
 | 
			
		||||
                                 EFI_TCP6_COMPLETION_TOKEN is defined in
 | 
			
		||||
                                 EFI_TCP_PROTOCOL.Connect().
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS            The asynchronous I/O request is aborted and Token->Event
 | 
			
		||||
                                 is signaled.
 | 
			
		||||
  @retval EFI_INVALID_PARAMETER  This is NULL.
 | 
			
		||||
  @retval EFI_NOT_STARTED        This instance hasn't been configured.
 | 
			
		||||
  @retval EFI_NOT_FOUND          The asynchronous I/O request isn't found in the transmission or
 | 
			
		||||
                                 receive queue. It has either completed or wasn't issued by
 | 
			
		||||
                                 Transmit() and Receive().
 | 
			
		||||
  @retval EFI_UNSUPPORTED        The implementation does not support this function.
 | 
			
		||||
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_TCP6_CANCEL)(
 | 
			
		||||
  IN EFI_TCP6_PROTOCOL           *This,
 | 
			
		||||
  IN EFI_TCP6_COMPLETION_TOKEN   *Token OPTIONAL
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Poll to receive incoming data and transmit outgoing segments.
 | 
			
		||||
 | 
			
		||||
  The Poll() function increases the rate that data is moved between the network
 | 
			
		||||
  and application and can be called when the TCP instance is created successfully.
 | 
			
		||||
  Its use is optional.
 | 
			
		||||
 | 
			
		||||
  @param[in] This                Pointer to the EFI_TCP6_PROTOCOL instance.
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS            Incoming or outgoing data was processed.
 | 
			
		||||
  @retval EFI_INVALID_PARAMETER  This is NULL.
 | 
			
		||||
  @retval EFI_DEVICE_ERROR       An unexpected system or network error occurred.
 | 
			
		||||
  @retval EFI_NOT_READY          No incoming or outgoing data is processed.
 | 
			
		||||
  @retval EFI_TIMEOUT            Data was dropped out of the transmission or receive queue.
 | 
			
		||||
                                 Consider increasing the polling rate.
 | 
			
		||||
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_TCP6_POLL)(
 | 
			
		||||
  IN EFI_TCP6_PROTOCOL        *This
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_TCP6_PROTOCOL
 | 
			
		||||
/// defines the EFI TCPv6 Protocol child to be used by any network drivers or
 | 
			
		||||
/// applications to send or receive data stream. It can either listen on a
 | 
			
		||||
/// specified port as a service or actively connect to remote peer as a client.
 | 
			
		||||
/// Each instance has its own independent settings.
 | 
			
		||||
///
 | 
			
		||||
struct _EFI_TCP6_PROTOCOL {
 | 
			
		||||
  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;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
extern EFI_GUID  gEfiTcp6ServiceBindingProtocolGuid;
 | 
			
		||||
extern EFI_GUID  gEfiTcp6ProtocolGuid;
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										576
									
								
								src/include/ipxe/efi/Protocol/Udp6.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										576
									
								
								src/include/ipxe/efi/Protocol/Udp6.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,576 @@
 | 
			
		||||
/** @file
 | 
			
		||||
  The EFI UDPv6 (User Datagram Protocol version 6) Protocol Definition, which is built upon
 | 
			
		||||
  the EFI IPv6 Protocol and provides simple packet-oriented services to transmit and receive
 | 
			
		||||
  UDP packets.
 | 
			
		||||
 | 
			
		||||
  Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>
 | 
			
		||||
  SPDX-License-Identifier: BSD-2-Clause-Patent
 | 
			
		||||
 | 
			
		||||
  @par Revision Reference:
 | 
			
		||||
  This Protocol is introduced in UEFI Specification 2.2
 | 
			
		||||
 | 
			
		||||
**/
 | 
			
		||||
 | 
			
		||||
#ifndef __EFI_UDP6_PROTOCOL_H__
 | 
			
		||||
#define __EFI_UDP6_PROTOCOL_H__
 | 
			
		||||
 | 
			
		||||
FILE_LICENCE ( BSD2_PATENT );
 | 
			
		||||
 | 
			
		||||
#include <ipxe/efi/Protocol/Ip6.h>
 | 
			
		||||
 | 
			
		||||
#define EFI_UDP6_SERVICE_BINDING_PROTOCOL_GUID \
 | 
			
		||||
  { \
 | 
			
		||||
    0x66ed4721, 0x3c98, 0x4d3e, {0x81, 0xe3, 0xd0, 0x3d, 0xd3, 0x9a, 0x72, 0x54 } \
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
#define EFI_UDP6_PROTOCOL_GUID \
 | 
			
		||||
  { \
 | 
			
		||||
    0x4f948815, 0xb4b9, 0x43cb, {0x8a, 0x33, 0x90, 0xe0, 0x60, 0xb3, 0x49, 0x55 } \
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_UDP6_SERVICE_POINT is deprecated in the UEFI 2.4B and should not be used any more.
 | 
			
		||||
/// The definition in here is only present to provide backwards compatability.
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// The EFI UDPv6 Protocol instance handle that is using this address/port pair.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_HANDLE          InstanceHandle;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The IPv6 address to which this instance of the EFI UDPv6 Protocol is bound.
 | 
			
		||||
  /// Set to 0::/128, if this instance is used to listen all packets from any
 | 
			
		||||
  /// source address.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_IPv6_ADDRESS    LocalAddress;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The port number in host byte order on which the service is listening.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT16              LocalPort;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The IPv6 address of the remote host. May be 0::/128 if it is not connected
 | 
			
		||||
  /// to any remote host or connected with more than one remote host.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_IPv6_ADDRESS    RemoteAddress;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The port number in host byte order on which the remote host is
 | 
			
		||||
  /// listening. Maybe zero if it is not connected to any remote host.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT16              RemotePort;
 | 
			
		||||
} EFI_UDP6_SERVICE_POINT;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_UDP6_VARIABLE_DATA is deprecated in the UEFI 2.4B and should not be used any more.
 | 
			
		||||
/// The definition in here is only present to provide backwards compatability.
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// The handle of the driver that creates this entry.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_HANDLE                DriverHandle;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The number of address/port pairs that follow this data structure.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32                    ServiceCount;
 | 
			
		||||
  ///
 | 
			
		||||
  /// List of address/port pairs that are currently in use.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_UDP6_SERVICE_POINT    Services[1];
 | 
			
		||||
} EFI_UDP6_VARIABLE_DATA;
 | 
			
		||||
 | 
			
		||||
typedef struct _EFI_UDP6_PROTOCOL EFI_UDP6_PROTOCOL;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_UDP6_FRAGMENT_DATA allows multiple receive or transmit buffers to be specified.
 | 
			
		||||
/// The purpose of this structure is to avoid copying the same packet multiple times.
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  UINT32    FragmentLength;      ///< Length of the fragment data buffer.
 | 
			
		||||
  VOID      *FragmentBuffer;     ///< Pointer to the fragment data buffer.
 | 
			
		||||
} EFI_UDP6_FRAGMENT_DATA;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// The EFI_UDP6_SESSION_DATA is used to retrieve the settings when receiving packets or
 | 
			
		||||
/// to override the existing settings (only DestinationAddress and DestinationPort can
 | 
			
		||||
/// be overridden) of this EFI UDPv6 Protocol instance when sending packets.
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// Address from which this packet is sent. This field should not be used when
 | 
			
		||||
  /// sending packets.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_IPv6_ADDRESS    SourceAddress;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Port from which this packet is sent. It is in host byte order. This field should
 | 
			
		||||
  /// not be used when sending packets.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT16              SourcePort;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Address to which this packet is sent. When sending packet, it'll be ignored
 | 
			
		||||
  /// if it is zero.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_IPv6_ADDRESS    DestinationAddress;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Port to which this packet is sent. When sending packet, it'll be
 | 
			
		||||
  /// ignored if it is zero.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT16              DestinationPort;
 | 
			
		||||
} EFI_UDP6_SESSION_DATA;
 | 
			
		||||
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// Set to TRUE to accept UDP packets that are sent to any address.
 | 
			
		||||
  ///
 | 
			
		||||
  BOOLEAN    AcceptPromiscuous;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Set to TRUE to accept UDP packets that are sent to any port.
 | 
			
		||||
  ///
 | 
			
		||||
  BOOLEAN    AcceptAnyPort;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Set to TRUE to allow this EFI UDPv6 Protocol child instance to open a port number
 | 
			
		||||
  /// that is already being used by another EFI UDPv6 Protocol child instance.
 | 
			
		||||
  ///
 | 
			
		||||
  BOOLEAN    AllowDuplicatePort;
 | 
			
		||||
  ///
 | 
			
		||||
  /// TrafficClass field in transmitted IPv6 packets.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT8      TrafficClass;
 | 
			
		||||
  ///
 | 
			
		||||
  /// HopLimit field in transmitted IPv6 packets.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT8      HopLimit;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The receive timeout value (number of microseconds) to be associated with each
 | 
			
		||||
  /// incoming packet. Zero means do not drop incoming packets.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32     ReceiveTimeout;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The transmit timeout value (number of microseconds) to be associated with each
 | 
			
		||||
  /// outgoing packet. Zero means do not drop outgoing packets.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32     TransmitTimeout;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The station IP address that will be assigned to this EFI UDPv6 Protocol instance.
 | 
			
		||||
  /// The EFI UDPv6 and EFI IPv6 Protocol drivers will only deliver incoming packets
 | 
			
		||||
  /// whose destination matches this IP address exactly. Address 0::/128 is also accepted
 | 
			
		||||
  /// as a special case. Under this situation, underlying IPv6 driver is responsible for
 | 
			
		||||
  /// binding a source address to this EFI IPv6 protocol instance according to source
 | 
			
		||||
  /// address selection algorithm. Only incoming packet from the selected source address
 | 
			
		||||
  /// is delivered. This field can be set and changed only when the EFI IPv6 driver is
 | 
			
		||||
  /// transitioning from the stopped to the started states. If no address is available
 | 
			
		||||
  /// for selecting, the EFI IPv6 Protocol driver will use EFI_IP6_CONFIG_PROTOCOL to
 | 
			
		||||
  /// retrieve the IPv6 address.
 | 
			
		||||
  EFI_IPv6_ADDRESS    StationAddress;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The port number to which this EFI UDPv6 Protocol instance is bound. If a client
 | 
			
		||||
  /// of the EFI UDPv6 Protocol does not care about the port number, set StationPort
 | 
			
		||||
  /// to zero. The EFI UDPv6 Protocol driver will assign a random port number to transmitted
 | 
			
		||||
  /// UDP packets. Ignored it if AcceptAnyPort is TRUE.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT16              StationPort;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The IP address of remote host to which this EFI UDPv6 Protocol instance is connecting.
 | 
			
		||||
  /// If RemoteAddress is not 0::/128, this EFI UDPv6 Protocol instance will be connected to
 | 
			
		||||
  /// RemoteAddress; i.e., outgoing packets of this EFI UDPv6 Protocol instance will be sent
 | 
			
		||||
  /// to this address by default and only incoming packets from this address will be delivered
 | 
			
		||||
  /// to client. Ignored for incoming filtering if AcceptPromiscuous is TRUE.
 | 
			
		||||
  EFI_IPv6_ADDRESS    RemoteAddress;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The port number of the remote host to which this EFI UDPv6 Protocol instance is connecting.
 | 
			
		||||
  /// If it is not zero, outgoing packets of this EFI UDPv6 Protocol instance will be sent to
 | 
			
		||||
  /// this port number by default and only incoming packets from this port will be delivered
 | 
			
		||||
  /// to client. Ignored if RemoteAddress is 0::/128 and ignored for incoming filtering if
 | 
			
		||||
  /// AcceptPromiscuous is TRUE.
 | 
			
		||||
  UINT16              RemotePort;
 | 
			
		||||
} EFI_UDP6_CONFIG_DATA;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// The EFI UDPv6 Protocol client must fill this data structure before sending a packet.
 | 
			
		||||
/// The packet may contain multiple buffers that may be not in a continuous memory location.
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// If not NULL, the data that is used to override the transmitting settings.Only the two
 | 
			
		||||
  /// filed UdpSessionData.DestinationAddress and UdpSessionData.DestionPort can be used as
 | 
			
		||||
  /// the transmitting setting filed.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_UDP6_SESSION_DATA     *UdpSessionData;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Sum of the fragment data length. Must not exceed the maximum UDP packet size.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32                    DataLength;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Number of fragments.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32                    FragmentCount;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Array of fragment descriptors.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_UDP6_FRAGMENT_DATA    FragmentTable[1];
 | 
			
		||||
} EFI_UDP6_TRANSMIT_DATA;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// EFI_UDP6_RECEIVE_DATA is filled by the EFI UDPv6 Protocol driver when this EFI UDPv6
 | 
			
		||||
/// Protocol instance receives an incoming packet. If there is a waiting token for incoming
 | 
			
		||||
/// packets, the CompletionToken.Packet.RxData field is updated to this incoming packet and
 | 
			
		||||
/// the CompletionToken.Event is signaled. The EFI UDPv6 Protocol client must signal the
 | 
			
		||||
/// RecycleSignal after processing the packet.
 | 
			
		||||
/// FragmentTable could contain multiple buffers that are not in the continuous memory locations.
 | 
			
		||||
/// The EFI UDPv6 Protocol client might need to combine two or more buffers in FragmentTable to
 | 
			
		||||
/// form their own protocol header.
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// Time when the EFI UDPv6 Protocol accepted the packet.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_TIME                  TimeStamp;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Indicates the event to signal when the received data has been processed.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_EVENT                 RecycleSignal;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The UDP session data including SourceAddress, SourcePort, DestinationAddress,
 | 
			
		||||
  /// and DestinationPort.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_UDP6_SESSION_DATA     UdpSession;
 | 
			
		||||
  ///
 | 
			
		||||
  /// The sum of the fragment data length.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32                    DataLength;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Number of fragments. Maybe zero.
 | 
			
		||||
  ///
 | 
			
		||||
  UINT32                    FragmentCount;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Array of fragment descriptors. Maybe zero.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_UDP6_FRAGMENT_DATA    FragmentTable[1];
 | 
			
		||||
} EFI_UDP6_RECEIVE_DATA;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// The EFI_UDP6_COMPLETION_TOKEN structures are used for both transmit and receive operations.
 | 
			
		||||
/// When used for transmitting, the Event and TxData fields must be filled in by the EFI UDPv6
 | 
			
		||||
/// Protocol client. After the transmit operation completes, the Status field is updated by the
 | 
			
		||||
/// EFI UDPv6 Protocol and the Event is signaled.
 | 
			
		||||
/// When used for receiving, only the Event field must be filled in by the EFI UDPv6 Protocol
 | 
			
		||||
/// client. After a packet is received, RxData and Status are filled in by the EFI UDPv6 Protocol
 | 
			
		||||
/// and the Event is signaled.
 | 
			
		||||
///
 | 
			
		||||
typedef struct {
 | 
			
		||||
  ///
 | 
			
		||||
  /// This Event will be signaled after the Status field is updated by the EFI UDPv6 Protocol
 | 
			
		||||
  /// driver. The type of Event must be EVT_NOTIFY_SIGNAL.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_EVENT    Event;
 | 
			
		||||
  ///
 | 
			
		||||
  /// Will be set to one of the following values:
 | 
			
		||||
  ///   - EFI_SUCCESS: The receive or transmit operation completed successfully.
 | 
			
		||||
  ///   - EFI_ABORTED: The receive or transmit was aborted.
 | 
			
		||||
  ///   - EFI_TIMEOUT: The transmit timeout expired.
 | 
			
		||||
  ///   - EFI_NETWORK_UNREACHABLE: The destination network is unreachable. RxData is set to
 | 
			
		||||
  ///     NULL in this situation.
 | 
			
		||||
  ///   - EFI_HOST_UNREACHABLE: The destination host is unreachable. RxData is set to NULL in
 | 
			
		||||
  ///     this situation.
 | 
			
		||||
  ///   - EFI_PROTOCOL_UNREACHABLE: The UDP protocol is unsupported in the remote system.
 | 
			
		||||
  ///     RxData is set to NULL in this situation.
 | 
			
		||||
  ///   - EFI_PORT_UNREACHABLE: No service is listening on the remote port. RxData is set to
 | 
			
		||||
  ///     NULL in this situation.
 | 
			
		||||
  ///   - EFI_ICMP_ERROR: Some other Internet Control Message Protocol (ICMP) error report was
 | 
			
		||||
  ///     received. For example, packets are being sent too fast for the destination to receive them
 | 
			
		||||
  ///     and the destination sent an ICMP source quench report. RxData is set to NULL in this situation.
 | 
			
		||||
  ///   - EFI_DEVICE_ERROR: An unexpected system or network error occurred.
 | 
			
		||||
  ///   - EFI_SECURITY_VIOLATION: The transmit or receive was failed because of IPsec policy check.
 | 
			
		||||
  ///   - EFI_NO_MEDIA: There was a media error.
 | 
			
		||||
  ///
 | 
			
		||||
  EFI_STATUS    Status;
 | 
			
		||||
  union {
 | 
			
		||||
    ///
 | 
			
		||||
    /// When this token is used for receiving, RxData is a pointer to EFI_UDP6_RECEIVE_DATA.
 | 
			
		||||
    ///
 | 
			
		||||
    EFI_UDP6_RECEIVE_DATA     *RxData;
 | 
			
		||||
    ///
 | 
			
		||||
    /// When this token is used for transmitting, TxData is a pointer to EFI_UDP6_TRANSMIT_DATA.
 | 
			
		||||
    ///
 | 
			
		||||
    EFI_UDP6_TRANSMIT_DATA    *TxData;
 | 
			
		||||
  } Packet;
 | 
			
		||||
} EFI_UDP6_COMPLETION_TOKEN;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Read the current operational settings.
 | 
			
		||||
 | 
			
		||||
  The GetModeData() function copies the current operational settings of this EFI UDPv6 Protocol
 | 
			
		||||
  instance into user-supplied buffers. This function is used optionally to retrieve the operational
 | 
			
		||||
  mode data of underlying networks or drivers.
 | 
			
		||||
 | 
			
		||||
  @param[in]   This             Pointer to the EFI_UDP6_PROTOCOL instance.
 | 
			
		||||
  @param[out]  Udp6ConfigData   The buffer in which the current UDP configuration data is returned.
 | 
			
		||||
  @param[out]  Ip6ModeData      The buffer in which the current EFI IPv6 Protocol mode data is returned.
 | 
			
		||||
  @param[out]  MnpConfigData    The buffer in which the current managed network configuration data is
 | 
			
		||||
                                returned.
 | 
			
		||||
  @param[out]  SnpModeData      The buffer in which the simple network mode data is returned.
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS           The mode data was read.
 | 
			
		||||
  @retval EFI_NOT_STARTED       When Udp6ConfigData is queried, no configuration data is available
 | 
			
		||||
                                because this instance has not been started.
 | 
			
		||||
  @retval EFI_INVALID_PARAMETER This is NULL.
 | 
			
		||||
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_UDP6_GET_MODE_DATA)(
 | 
			
		||||
  IN EFI_UDP6_PROTOCOL                 *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
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Initializes, changes, or resets the operational parameters for this instance of the EFI UDPv6
 | 
			
		||||
  Protocol.
 | 
			
		||||
 | 
			
		||||
  The Configure() function is used to do the following:
 | 
			
		||||
  - Initialize and start this instance of the EFI UDPv6 Protocol.
 | 
			
		||||
  - Change the filtering rules and operational parameters.
 | 
			
		||||
  - Reset this instance of the EFI UDPv6 Protocol.
 | 
			
		||||
 | 
			
		||||
  Until these parameters are initialized, no network traffic can be sent or received by this instance.
 | 
			
		||||
  This instance can be also reset by calling Configure() with UdpConfigData set to NULL.
 | 
			
		||||
  Once reset, the receiving queue and transmitting queue are flushed and no traffic is allowed through
 | 
			
		||||
  this instance.
 | 
			
		||||
 | 
			
		||||
  With different parameters in UdpConfigData, Configure() can be used to bind this instance to specified
 | 
			
		||||
  port.
 | 
			
		||||
 | 
			
		||||
  @param[in]   This             Pointer to the EFI_UDP6_PROTOCOL instance.
 | 
			
		||||
  @param[in]   UdpConfigData    Pointer to the buffer contained the configuration data.
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS           The configuration settings were set, changed, or reset successfully.
 | 
			
		||||
  @retval EFI_NO_MAPPING        The underlying IPv6 driver was responsible for choosing a source
 | 
			
		||||
                                address for this instance, but no source address was available for use.
 | 
			
		||||
  @retval EFI_INVALID_PARAMETER One or more following conditions are TRUE:
 | 
			
		||||
                                - This is NULL.
 | 
			
		||||
                                - UdpConfigData.StationAddress neither zero nor one of the configured IP
 | 
			
		||||
                                  addresses in the underlying IPv6 driver.
 | 
			
		||||
                                - UdpConfigData.RemoteAddress is not a valid unicast IPv6 address if it
 | 
			
		||||
                                  is not zero.
 | 
			
		||||
  @retval EFI_ALREADY_STARTED   The EFI UDPv6 Protocol instance is already started/configured and must be
 | 
			
		||||
                                stopped/reset before it can be reconfigured. Only TrafficClass, HopLimit,
 | 
			
		||||
                                ReceiveTimeout, and TransmitTimeout can be reconfigured without stopping
 | 
			
		||||
                                the current instance of the EFI UDPv6 Protocol.
 | 
			
		||||
  @retval EFI_ACCESS_DENIED     UdpConfigData.AllowDuplicatePort is FALSE and UdpConfigData.StationPort
 | 
			
		||||
                                is already used by other instance.
 | 
			
		||||
  @retval EFI_OUT_OF_RESOURCES  The EFI UDPv6 Protocol driver cannot allocate memory for this EFI UDPv6
 | 
			
		||||
                                Protocol instance.
 | 
			
		||||
  @retval EFI_DEVICE_ERROR      An unexpected network or system error occurred and this instance was not
 | 
			
		||||
                                opened.
 | 
			
		||||
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_UDP6_CONFIGURE)(
 | 
			
		||||
  IN EFI_UDP6_PROTOCOL     *This,
 | 
			
		||||
  IN EFI_UDP6_CONFIG_DATA  *UdpConfigData OPTIONAL
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Joins and leaves multicast groups.
 | 
			
		||||
 | 
			
		||||
  The Groups() function is used to join or leave one or more multicast group.
 | 
			
		||||
  If the JoinFlag is FALSE and the MulticastAddress is NULL, then all currently joined groups are left.
 | 
			
		||||
 | 
			
		||||
  @param[in]   This             Pointer to the EFI_UDP6_PROTOCOL instance.
 | 
			
		||||
  @param[in]   JoinFlag         Set to TRUE to join a multicast group. Set to FALSE to leave one
 | 
			
		||||
                                or all multicast groups.
 | 
			
		||||
  @param[in]   MulticastAddress Pointer to multicast group address to join or leave.
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS           The operation completed successfully.
 | 
			
		||||
  @retval EFI_NOT_STARTED       The EFI UDPv6 Protocol instance has not been started.
 | 
			
		||||
  @retval EFI_OUT_OF_RESOURCES  Could not allocate resources to join the group.
 | 
			
		||||
  @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
 | 
			
		||||
                                - This is NULL.
 | 
			
		||||
                                - JoinFlag is TRUE and MulticastAddress is NULL.
 | 
			
		||||
                                - JoinFlag is TRUE and *MulticastAddress is not a valid multicast address.
 | 
			
		||||
  @retval EFI_ALREADY_STARTED   The group address is already in the group table (when JoinFlag is TRUE).
 | 
			
		||||
  @retval EFI_NOT_FOUND         The group address is not in the group table (when JoinFlag is FALSE).
 | 
			
		||||
  @retval EFI_DEVICE_ERROR      An unexpected system or network error occurred.
 | 
			
		||||
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_UDP6_GROUPS)(
 | 
			
		||||
  IN EFI_UDP6_PROTOCOL  *This,
 | 
			
		||||
  IN BOOLEAN            JoinFlag,
 | 
			
		||||
  IN EFI_IPv6_ADDRESS   *MulticastAddress OPTIONAL
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Queues outgoing data packets into the transmit queue.
 | 
			
		||||
 | 
			
		||||
  The Transmit() function places a sending request to this instance of the EFI UDPv6 Protocol,
 | 
			
		||||
  alongside the transmit data that was filled by the user. Whenever the packet in the token is
 | 
			
		||||
  sent out or some errors occur, the Token.Event will be signaled and Token.Status is updated.
 | 
			
		||||
  Providing a proper notification function and context for the event will enable the user to
 | 
			
		||||
  receive the notification and transmitting status.
 | 
			
		||||
 | 
			
		||||
  @param[in]   This             Pointer to the EFI_UDP6_PROTOCOL instance.
 | 
			
		||||
  @param[in]   Token            Pointer to the completion token that will be placed into the
 | 
			
		||||
                                transmit queue.
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS           The data has been queued for transmission.
 | 
			
		||||
  @retval EFI_NOT_STARTED       This EFI UDPv6 Protocol instance has not been started.
 | 
			
		||||
  @retval EFI_NO_MAPPING        The underlying IPv6 driver was responsible for choosing a source
 | 
			
		||||
                                address for this instance, but no source address was available
 | 
			
		||||
                                for use.
 | 
			
		||||
  @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:
 | 
			
		||||
                                - This is NULL.
 | 
			
		||||
                                - Token is NULL.
 | 
			
		||||
                                - Token.Event is NULL.
 | 
			
		||||
                                - Token.Packet.TxData is NULL.
 | 
			
		||||
                                - Token.Packet.TxData.FragmentCount is zero.
 | 
			
		||||
                                - Token.Packet.TxData.DataLength is not equal to the sum of fragment
 | 
			
		||||
                                  lengths.
 | 
			
		||||
                                - One or more of the Token.Packet.TxData.FragmentTable[].FragmentLength
 | 
			
		||||
                                  fields is zero.
 | 
			
		||||
                                - One or more of the Token.Packet.TxData.FragmentTable[].FragmentBuffer
 | 
			
		||||
                                  fields is NULL.
 | 
			
		||||
                                - Token.Packet.TxData.UdpSessionData.DestinationAddress is not zero
 | 
			
		||||
                                  and is not valid unicast Ipv6 address if UdpSessionData is not NULL.
 | 
			
		||||
                                - Token.Packet.TxData.UdpSessionData is NULL and this instance's
 | 
			
		||||
                                  UdpConfigData.RemoteAddress is unspecified.
 | 
			
		||||
                                - Token.Packet.TxData.UdpSessionData.DestinationAddress is non-zero
 | 
			
		||||
                                  when DestinationAddress is configured as non-zero when doing Configure()
 | 
			
		||||
                                  for this EFI Udp6 protocol instance.
 | 
			
		||||
                                - Token.Packet.TxData.UdpSesionData.DestinationAddress is zero when
 | 
			
		||||
                                  DestinationAddress is unspecified when doing Configure() for this
 | 
			
		||||
                                  EFI Udp6 protocol instance.
 | 
			
		||||
  @retval EFI_ACCESS_DENIED     The transmit completion token with the same Token.Event was already
 | 
			
		||||
                                in the transmit queue.
 | 
			
		||||
  @retval EFI_NOT_READY         The completion token could not be queued because the transmit queue
 | 
			
		||||
                                is full.
 | 
			
		||||
  @retval EFI_OUT_OF_RESOURCES  Could not queue the transmit data.
 | 
			
		||||
  @retval EFI_NOT_FOUND         There is no route to the destination network or address.
 | 
			
		||||
  @retval EFI_BAD_BUFFER_SIZE   The data length is greater than the maximum UDP packet size.
 | 
			
		||||
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_UDP6_TRANSMIT)(
 | 
			
		||||
  IN EFI_UDP6_PROTOCOL          *This,
 | 
			
		||||
  IN EFI_UDP6_COMPLETION_TOKEN  *Token
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Places an asynchronous receive request into the receiving queue.
 | 
			
		||||
 | 
			
		||||
  The Receive() function places a completion token into the receive packet queue. This function is
 | 
			
		||||
  always asynchronous.
 | 
			
		||||
  The caller must fill in the Token.Event field in the completion token, and this field cannot be
 | 
			
		||||
  NULL. When the receive operation completes, the EFI UDPv6 Protocol driver updates the Token.Status
 | 
			
		||||
  and Token.Packet.RxData fields and the Token.Event is signaled.
 | 
			
		||||
  Providing a proper notification function and context for the event will enable the user to receive
 | 
			
		||||
  the notification and receiving status. That notification function is guaranteed to not be re-entered.
 | 
			
		||||
 | 
			
		||||
  @param[in]   This             Pointer to the EFI_UDP6_PROTOCOL instance.
 | 
			
		||||
  @param[in]   Token            Pointer to a token that is associated with the receive data descriptor.
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS           The receive completion token was cached.
 | 
			
		||||
  @retval EFI_NOT_STARTED       This EFI UDPv6 Protocol instance has not been started.
 | 
			
		||||
  @retval EFI_NO_MAPPING        The underlying IPv6 driver was responsible for choosing a source
 | 
			
		||||
                                address for this instance, but no source address was available
 | 
			
		||||
                                for use.
 | 
			
		||||
  @retval EFI_INVALID_PARAMETER One or more of the following is TRUE:
 | 
			
		||||
                                - This is NULL.
 | 
			
		||||
                                - Token is NULL.
 | 
			
		||||
                                - Token.Event is NULL.
 | 
			
		||||
  @retval EFI_OUT_OF_RESOURCES  The receive completion token could not be queued due to a lack of system
 | 
			
		||||
                                resources (usually memory).
 | 
			
		||||
  @retval EFI_DEVICE_ERROR      An unexpected system or network error occurred. The EFI UDPv6 Protocol
 | 
			
		||||
                                instance has been reset to startup defaults.
 | 
			
		||||
  @retval EFI_ACCESS_DENIED     A receive completion token with the same Token.Event was already in
 | 
			
		||||
                                the receive queue.
 | 
			
		||||
  @retval EFI_NOT_READY         The receive request could not be queued because the receive queue is full.
 | 
			
		||||
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_UDP6_RECEIVE)(
 | 
			
		||||
  IN EFI_UDP6_PROTOCOL          *This,
 | 
			
		||||
  IN EFI_UDP6_COMPLETION_TOKEN  *Token
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Aborts an asynchronous transmit or receive request.
 | 
			
		||||
 | 
			
		||||
  The Cancel() function is used to abort a pending transmit or receive request. If the token is in the
 | 
			
		||||
  transmit or receive request queues, after calling this function, Token.Status will be set to
 | 
			
		||||
  EFI_ABORTED and then Token.Event will be signaled. If the token is not in one of the queues,
 | 
			
		||||
  which usually means that the asynchronous operation has completed, this function will not signal the
 | 
			
		||||
  token and EFI_NOT_FOUND is returned.
 | 
			
		||||
 | 
			
		||||
  @param[in]   This             Pointer to the EFI_UDP6_PROTOCOL instance.
 | 
			
		||||
  @param[in]   Token            Pointer to a token that has been issued by EFI_UDP6_PROTOCOL.Transmit()
 | 
			
		||||
                                or EFI_UDP6_PROTOCOL.Receive().If NULL, all pending tokens are aborted.
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS           The asynchronous I/O request was aborted and Token.Event was signaled.
 | 
			
		||||
                                When Token is NULL, all pending requests are aborted and their events
 | 
			
		||||
                                are signaled.
 | 
			
		||||
  @retval EFI_INVALID_PARAMETER This is NULL.
 | 
			
		||||
  @retval EFI_NOT_STARTED       This instance has not been started.
 | 
			
		||||
  @retval EFI_NOT_FOUND         When Token is not NULL, the asynchronous I/O request was not found in
 | 
			
		||||
                                the transmit or receive queue. It has either completed or was not issued
 | 
			
		||||
                                by Transmit() and Receive().
 | 
			
		||||
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_UDP6_CANCEL)(
 | 
			
		||||
  IN EFI_UDP6_PROTOCOL          *This,
 | 
			
		||||
  IN EFI_UDP6_COMPLETION_TOKEN  *Token OPTIONAL
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  Polls for incoming data packets and processes outgoing data packets.
 | 
			
		||||
 | 
			
		||||
  The Poll() function can be used by network drivers and applications to increase the rate that data
 | 
			
		||||
  packets are moved between the communications device and the transmit and receive queues.
 | 
			
		||||
  In some systems, the periodic timer event in the managed network driver may not poll the underlying
 | 
			
		||||
  communications device fast enough to transmit and/or receive all data packets without missing incoming
 | 
			
		||||
  packets or dropping outgoing packets. Drivers and applications that are experiencing packet loss should
 | 
			
		||||
  try calling the Poll() function more often.
 | 
			
		||||
 | 
			
		||||
  @param[in]   This             Pointer to the EFI_UDP6_PROTOCOL instance.
 | 
			
		||||
 | 
			
		||||
  @retval EFI_SUCCESS           Incoming or outgoing data was processed.
 | 
			
		||||
  @retval EFI_INVALID_PARAMETER This is NULL.
 | 
			
		||||
  @retval EFI_DEVICE_ERROR      An unexpected system or network error occurred.
 | 
			
		||||
  @retval EFI_TIMEOUT           Data was dropped out of the transmit and/or receive queue.
 | 
			
		||||
                                Consider increasing the polling rate.
 | 
			
		||||
 | 
			
		||||
**/
 | 
			
		||||
typedef
 | 
			
		||||
EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_UDP6_POLL)(
 | 
			
		||||
  IN EFI_UDP6_PROTOCOL  *This
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// The EFI_UDP6_PROTOCOL defines an EFI UDPv6 Protocol session that can be used by any network drivers,
 | 
			
		||||
/// applications, or daemons to transmit or receive UDP packets. This protocol instance can either be
 | 
			
		||||
/// bound to a specified port as a service or connected to some remote peer as an active client.
 | 
			
		||||
/// Each instance has its own settings, such as group table, that are independent from each other.
 | 
			
		||||
///
 | 
			
		||||
struct _EFI_UDP6_PROTOCOL {
 | 
			
		||||
  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;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
extern EFI_GUID  gEfiUdp6ServiceBindingProtocolGuid;
 | 
			
		||||
extern EFI_GUID  gEfiUdp6ProtocolGuid;
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
@ -467,8 +467,8 @@ EFI_STATUS
 | 
			
		||||
(EFIAPI *EFI_CREATE_EVENT)(
 | 
			
		||||
  IN  UINT32                       Type,
 | 
			
		||||
  IN  EFI_TPL                      NotifyTpl,
 | 
			
		||||
  IN  EFI_EVENT_NOTIFY             NotifyFunction,
 | 
			
		||||
  IN  VOID                         *NotifyContext,
 | 
			
		||||
  IN  EFI_EVENT_NOTIFY             NotifyFunction OPTIONAL,
 | 
			
		||||
  IN  VOID                         *NotifyContext OPTIONAL,
 | 
			
		||||
  OUT EFI_EVENT                    *Event
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -23,20 +23,6 @@ FILE_LICENCE ( BSD2_PATENT );
 | 
			
		||||
  #pragma pack()
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if defined (__GNUC__) && defined (__pic__) && !defined (USING_LTO)  && !defined (__APPLE__)
 | 
			
		||||
//
 | 
			
		||||
// Mark all symbol declarations and references as hidden, meaning they will
 | 
			
		||||
// not be subject to symbol preemption. This allows the compiler to refer to
 | 
			
		||||
// symbols directly using relative references rather than via the GOT, which
 | 
			
		||||
// contains absolute symbol addresses that are subject to runtime relocation.
 | 
			
		||||
//
 | 
			
		||||
// The LTO linker will not emit GOT based relocations when all symbol
 | 
			
		||||
// references can be resolved locally, and so there is no need to set the
 | 
			
		||||
// pragma in that case (and doing so will cause other issues).
 | 
			
		||||
//
 | 
			
		||||
  #pragma GCC visibility push (hidden)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if defined (__INTEL_COMPILER)
 | 
			
		||||
//
 | 
			
		||||
// Disable ICC's remark #869: "Parameter" was never referenced warning.
 | 
			
		||||
@ -104,19 +90,15 @@ FILE_LICENCE ( BSD2_PATENT );
 | 
			
		||||
 | 
			
		||||
  #if defined (_MSC_VER) && _MSC_VER >= 1800
 | 
			
		||||
 | 
			
		||||
//
 | 
			
		||||
// Disable these warnings for VS2013.
 | 
			
		||||
//
 | 
			
		||||
 | 
			
		||||
//
 | 
			
		||||
// This warning is for potentially uninitialized local variable, and it may cause false
 | 
			
		||||
// positive issues in VS2013 and VS2015 build
 | 
			
		||||
// positive issues in VS2015 build
 | 
			
		||||
//
 | 
			
		||||
    #pragma warning ( disable : 4701 )
 | 
			
		||||
 | 
			
		||||
//
 | 
			
		||||
// This warning is for potentially uninitialized local pointer variable, and it may cause
 | 
			
		||||
// false positive issues in VS2013 and VS2015 build
 | 
			
		||||
// false positive issues in VS2015 build
 | 
			
		||||
//
 | 
			
		||||
    #pragma warning ( disable : 4703 )
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -43,10 +43,19 @@ FILE_LICENCE ( GPL2_OR_LATER );
 | 
			
		||||
 * checking somewhat useless.  Work around this bizarre sabotage
 | 
			
		||||
 * attempt by redefining EFI_HANDLE as a pointer to an anonymous
 | 
			
		||||
 * structure.
 | 
			
		||||
 *
 | 
			
		||||
 * EFI headers perform some ABI validation checks via _Static_assert()
 | 
			
		||||
 * that may fail when EFI headers are included on a non-EFI platform.
 | 
			
		||||
 * Temporarily disable static assertions to allow these headers to be
 | 
			
		||||
 * included.
 | 
			
		||||
 */
 | 
			
		||||
#define EFI_HANDLE STUPID_EFI_HANDLE
 | 
			
		||||
#ifndef PLATFORM_efi
 | 
			
		||||
#define _Static_assert(expr, msg)
 | 
			
		||||
#endif
 | 
			
		||||
#include <ipxe/efi/Uefi/UefiBaseType.h>
 | 
			
		||||
#undef EFI_HANDLE
 | 
			
		||||
#undef _Static_assert
 | 
			
		||||
typedef struct {} *EFI_HANDLE;
 | 
			
		||||
 | 
			
		||||
/* Include the top-level EFI header files */
 | 
			
		||||
@ -175,14 +184,26 @@ extern EFI_GUID efi_console_control_protocol_guid;
 | 
			
		||||
extern EFI_GUID efi_device_path_protocol_guid;
 | 
			
		||||
extern EFI_GUID efi_dhcp4_protocol_guid;
 | 
			
		||||
extern EFI_GUID efi_dhcp4_service_binding_protocol_guid;
 | 
			
		||||
extern EFI_GUID efi_dhcp6_protocol_guid;
 | 
			
		||||
extern EFI_GUID efi_dhcp6_service_binding_protocol_guid;
 | 
			
		||||
extern EFI_GUID efi_disk_io_protocol_guid;
 | 
			
		||||
extern EFI_GUID efi_dns4_protocol_guid;
 | 
			
		||||
extern EFI_GUID efi_dns4_service_binding_protocol_guid;
 | 
			
		||||
extern EFI_GUID efi_dns6_protocol_guid;
 | 
			
		||||
extern EFI_GUID efi_dns6_service_binding_protocol_guid;
 | 
			
		||||
extern EFI_GUID efi_driver_binding_protocol_guid;
 | 
			
		||||
extern EFI_GUID efi_graphics_output_protocol_guid;
 | 
			
		||||
extern EFI_GUID efi_hii_config_access_protocol_guid;
 | 
			
		||||
extern EFI_GUID efi_hii_font_protocol_guid;
 | 
			
		||||
extern EFI_GUID efi_http_protocol_guid;
 | 
			
		||||
extern EFI_GUID efi_http_service_binding_protocol_guid;
 | 
			
		||||
extern EFI_GUID efi_ip4_protocol_guid;
 | 
			
		||||
extern EFI_GUID efi_ip4_config_protocol_guid;
 | 
			
		||||
extern EFI_GUID efi_ip4_config2_protocol_guid;
 | 
			
		||||
extern EFI_GUID efi_ip4_service_binding_protocol_guid;
 | 
			
		||||
extern EFI_GUID efi_ip6_protocol_guid;
 | 
			
		||||
extern EFI_GUID efi_ip6_config_protocol_guid;
 | 
			
		||||
extern EFI_GUID efi_ip6_service_binding_protocol_guid;
 | 
			
		||||
extern EFI_GUID efi_load_file_protocol_guid;
 | 
			
		||||
extern EFI_GUID efi_load_file2_protocol_guid;
 | 
			
		||||
extern EFI_GUID efi_loaded_image_protocol_guid;
 | 
			
		||||
@ -191,12 +212,15 @@ extern EFI_GUID efi_managed_network_protocol_guid;
 | 
			
		||||
extern EFI_GUID efi_managed_network_service_binding_protocol_guid;
 | 
			
		||||
extern EFI_GUID efi_mtftp4_protocol_guid;
 | 
			
		||||
extern EFI_GUID efi_mtftp4_service_binding_protocol_guid;
 | 
			
		||||
extern EFI_GUID efi_mtftp6_protocol_guid;
 | 
			
		||||
extern EFI_GUID efi_mtftp6_service_binding_protocol_guid;
 | 
			
		||||
extern EFI_GUID efi_nii_protocol_guid;
 | 
			
		||||
extern EFI_GUID efi_nii31_protocol_guid;
 | 
			
		||||
extern EFI_GUID efi_pci_io_protocol_guid;
 | 
			
		||||
extern EFI_GUID efi_pci_root_bridge_io_protocol_guid;
 | 
			
		||||
extern EFI_GUID efi_pxe_base_code_protocol_guid;
 | 
			
		||||
extern EFI_GUID efi_serial_io_protocol_guid;
 | 
			
		||||
extern EFI_GUID efi_shim_lock_protocol_guid;
 | 
			
		||||
extern EFI_GUID efi_simple_file_system_protocol_guid;
 | 
			
		||||
extern EFI_GUID efi_simple_network_protocol_guid;
 | 
			
		||||
extern EFI_GUID efi_simple_pointer_protocol_guid;
 | 
			
		||||
@ -206,9 +230,13 @@ extern EFI_GUID efi_simple_text_output_protocol_guid;
 | 
			
		||||
extern EFI_GUID efi_tcg_protocol_guid;
 | 
			
		||||
extern EFI_GUID efi_tcp4_protocol_guid;
 | 
			
		||||
extern EFI_GUID efi_tcp4_service_binding_protocol_guid;
 | 
			
		||||
extern EFI_GUID efi_tcp6_protocol_guid;
 | 
			
		||||
extern EFI_GUID efi_tcp6_service_binding_protocol_guid;
 | 
			
		||||
extern EFI_GUID efi_tree_protocol_guid;
 | 
			
		||||
extern EFI_GUID efi_udp4_protocol_guid;
 | 
			
		||||
extern EFI_GUID efi_udp4_service_binding_protocol_guid;
 | 
			
		||||
extern EFI_GUID efi_udp6_protocol_guid;
 | 
			
		||||
extern EFI_GUID efi_udp6_service_binding_protocol_guid;
 | 
			
		||||
extern EFI_GUID efi_uga_draw_protocol_guid;
 | 
			
		||||
extern EFI_GUID efi_unicode_collation_protocol_guid;
 | 
			
		||||
extern EFI_GUID efi_usb_hc_protocol_guid;
 | 
			
		||||
@ -241,6 +269,7 @@ efi_handle_name ( EFI_HANDLE handle );
 | 
			
		||||
extern void dbg_efi_opener ( EFI_HANDLE handle, EFI_GUID *protocol,
 | 
			
		||||
			     EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *opener );
 | 
			
		||||
extern void dbg_efi_openers ( EFI_HANDLE handle, EFI_GUID *protocol );
 | 
			
		||||
extern void dbg_efi_protocol ( EFI_HANDLE handle, EFI_GUID *protocol );
 | 
			
		||||
extern void dbg_efi_protocols ( EFI_HANDLE handle );
 | 
			
		||||
 | 
			
		||||
#define DBG_EFI_OPENER_IF( level, handle, protocol,		\
 | 
			
		||||
@ -275,6 +304,12 @@ extern void dbg_efi_protocols ( EFI_HANDLE handle );
 | 
			
		||||
		DBG_DC_IF ( level );				\
 | 
			
		||||
	} while ( 0 )
 | 
			
		||||
 | 
			
		||||
#define DBGC_EFI_PROTOCOL_IF( level, id, ... ) do {		\
 | 
			
		||||
		DBG_AC_IF ( level, id );			\
 | 
			
		||||
		DBG_EFI_PROTOCOL_IF ( level, __VA_ARGS__ );	\
 | 
			
		||||
		DBG_DC_IF ( level );				\
 | 
			
		||||
	} while ( 0 )
 | 
			
		||||
 | 
			
		||||
#define DBGC_EFI_PROTOCOLS_IF( level, id, ... ) do {		\
 | 
			
		||||
		DBG_AC_IF ( level, id );			\
 | 
			
		||||
		DBG_EFI_PROTOCOLS_IF ( level, __VA_ARGS__ );	\
 | 
			
		||||
@ -285,6 +320,8 @@ extern void dbg_efi_protocols ( EFI_HANDLE handle );
 | 
			
		||||
	DBGC_EFI_OPENER_IF ( LOG, ##__VA_ARGS__ )
 | 
			
		||||
#define DBGC_EFI_OPENERS( ... )					\
 | 
			
		||||
	DBGC_EFI_OPENERS_IF ( LOG, ##__VA_ARGS__ )
 | 
			
		||||
#define DBGC_EFI_PROTOCOL( ... )				\
 | 
			
		||||
	DBGC_EFI_PROTOCOL_IF ( LOG, ##__VA_ARGS__ )
 | 
			
		||||
#define DBGC_EFI_PROTOCOLS( ... )				\
 | 
			
		||||
	DBGC_EFI_PROTOCOLS_IF ( LOG, ##__VA_ARGS__ )
 | 
			
		||||
 | 
			
		||||
@ -292,6 +329,8 @@ extern void dbg_efi_protocols ( EFI_HANDLE handle );
 | 
			
		||||
	DBGC_EFI_OPENER_IF ( EXTRA, ##__VA_ARGS__ )
 | 
			
		||||
#define DBGC2_EFI_OPENERS( ... )				\
 | 
			
		||||
	DBGC_EFI_OPENERS_IF ( EXTRA, ##__VA_ARGS__ )
 | 
			
		||||
#define DBGC2_EFI_PROTOCOL( ... )				\
 | 
			
		||||
	DBGC_EFI_PROTOCOL_IF ( EXTRA, ##__VA_ARGS__ )
 | 
			
		||||
#define DBGC2_EFI_PROTOCOLS( ... )				\
 | 
			
		||||
	DBGC_EFI_PROTOCOLS_IF ( EXTRA, ##__VA_ARGS__ )
 | 
			
		||||
 | 
			
		||||
@ -299,6 +338,8 @@ extern void dbg_efi_protocols ( EFI_HANDLE handle );
 | 
			
		||||
	DBGC_EFI_OPENER_IF ( PROFILE, ##__VA_ARGS__ )
 | 
			
		||||
#define DBGCP_EFI_OPENERS( ... )				\
 | 
			
		||||
	DBGC_EFI_OPENERS_IF ( PROFILE, ##__VA_ARGS__ )
 | 
			
		||||
#define DBGCP_EFI_PROTOCOL( ... )				\
 | 
			
		||||
	DBGC_EFI_PROTOCOL_IF ( PROFILE, ##__VA_ARGS__ )
 | 
			
		||||
#define DBGCP_EFI_PROTOCOLS( ... )				\
 | 
			
		||||
	DBGC_EFI_PROTOCOLS_IF ( PROFILE, ##__VA_ARGS__ )
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user