Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5db83a1da6 | ||
|
|
c30b71ee9c | ||
|
|
f3036fc213 | ||
|
|
59d065c9ac | ||
|
|
48ae5d5361 | ||
|
|
6701d91c50 | ||
|
|
b5b60ea33d | ||
|
|
8244410690 | ||
|
|
daa9e54ab8 | ||
|
|
3ef4f7e2ef | ||
|
|
cc07ed7c7e | ||
|
|
6f57d91935 | ||
|
|
e17568ad06 | ||
|
|
2524a60550 | ||
|
|
280942a92a | ||
|
|
6d98e0ca47 | ||
|
|
0c67a3632d | ||
|
|
c57887bfc8 | ||
|
|
18af669701 | ||
|
|
cfe65aa826 |
+5
-1
@@ -50,6 +50,10 @@ $(BIN)/efidrv.cab : $(BIN)/alldrv.efis # $(ALL_drv.efi) is not yet defined
|
|||||||
$(QM)$(ECHO) " [CAB] $@"
|
$(QM)$(ECHO) " [CAB] $@"
|
||||||
$(Q)$(LCAB) -n -q $(ALL_drv.efi) $@
|
$(Q)$(LCAB) -n -q $(ALL_drv.efi) $@
|
||||||
|
|
||||||
$(BIN)/%.iso $(BIN)/%.usb : $(BIN)/%.efi util/genfsimg
|
$(BIN)/%.iso : $(BIN)/%.efi util/genfsimg
|
||||||
|
$(QM)$(ECHO) " [GENFSIMG] $@"
|
||||||
|
$(Q)util/genfsimg -o $@ $<
|
||||||
|
|
||||||
|
$(BIN)/%.usb : $(BIN)/%.efi util/genfsimg
|
||||||
$(QM)$(ECHO) " [GENFSIMG] $@"
|
$(QM)$(ECHO) " [GENFSIMG] $@"
|
||||||
$(Q)util/genfsimg -o $@ $<
|
$(Q)util/genfsimg -o $@ $<
|
||||||
|
|||||||
@@ -502,6 +502,13 @@ LDFLAGS += --gc-sections
|
|||||||
#
|
#
|
||||||
LDFLAGS += -static
|
LDFLAGS += -static
|
||||||
|
|
||||||
|
# Use separate code segment if supported by linker
|
||||||
|
#
|
||||||
|
ZSC_TEST = $(LD) -z separate-code --version 2>&1 > /dev/null
|
||||||
|
ZSC_FLAGS := $(shell [ -z "`$(ZSC_TEST)`" ] && \
|
||||||
|
$(ECHO) '-z separate-code -z max-page-size=4096')
|
||||||
|
LDFLAGS += $(ZSC_FLAGS)
|
||||||
|
|
||||||
# compiler.h is needed for our linking and debugging system
|
# compiler.h is needed for our linking and debugging system
|
||||||
#
|
#
|
||||||
CFLAGS += -include include/compiler.h
|
CFLAGS += -include include/compiler.h
|
||||||
@@ -1002,6 +1009,7 @@ endif
|
|||||||
# Device ID tables (using IDs from ROM definition file)
|
# Device ID tables (using IDs from ROM definition file)
|
||||||
#
|
#
|
||||||
define obj_pci_id_asm
|
define obj_pci_id_asm
|
||||||
|
.section ".note.GNU-stack", "", $(ASM_TCHAR)progbits
|
||||||
.section ".pci_devlist.$(1)", "a", $(ASM_TCHAR)progbits
|
.section ".pci_devlist.$(1)", "a", $(ASM_TCHAR)progbits
|
||||||
.globl pci_devlist_$(1)
|
.globl pci_devlist_$(1)
|
||||||
pci_devlist_$(1):
|
pci_devlist_$(1):
|
||||||
@@ -1171,7 +1179,7 @@ BLIB = $(BIN)/blib.a
|
|||||||
$(BLIB) : $(BLIB_OBJS) $(BLIB_LIST) $(MAKEDEPS)
|
$(BLIB) : $(BLIB_OBJS) $(BLIB_LIST) $(MAKEDEPS)
|
||||||
$(Q)$(RM) $(BLIB)
|
$(Q)$(RM) $(BLIB)
|
||||||
$(QM)$(ECHO) " [AR] $@"
|
$(QM)$(ECHO) " [AR] $@"
|
||||||
$(Q)$(AR) rD $@ $(sort $(BLIB_OBJS))
|
$(Q)$(AR) rcD $@ $(sort $(BLIB_OBJS))
|
||||||
$(Q)$(OBJCOPY) --enable-deterministic-archives \
|
$(Q)$(OBJCOPY) --enable-deterministic-archives \
|
||||||
--prefix-symbols=$(SYMBOL_PREFIX) $@
|
--prefix-symbols=$(SYMBOL_PREFIX) $@
|
||||||
$(Q)$(RANLIB) -D $@
|
$(Q)$(RANLIB) -D $@
|
||||||
|
|||||||
@@ -9,4 +9,5 @@ INCDIRS += arch/arm/include
|
|||||||
|
|
||||||
# ARM-specific directories containing source files
|
# ARM-specific directories containing source files
|
||||||
#
|
#
|
||||||
|
SRCDIRS += arch/arm/core
|
||||||
SRCDIRS += arch/arm/interface/efi
|
SRCDIRS += arch/arm/interface/efi
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ union arm32_io_qword {
|
|||||||
*
|
*
|
||||||
* This is not atomic for ARM32.
|
* This is not atomic for ARM32.
|
||||||
*/
|
*/
|
||||||
static uint64_t arm32_readq ( volatile uint64_t *io_addr ) {
|
static __unused uint64_t arm32_readq ( volatile uint64_t *io_addr ) {
|
||||||
volatile union arm32_io_qword *ptr =
|
volatile union arm32_io_qword *ptr =
|
||||||
container_of ( io_addr, union arm32_io_qword, qword );
|
container_of ( io_addr, union arm32_io_qword, qword );
|
||||||
union arm32_io_qword tmp;
|
union arm32_io_qword tmp;
|
||||||
@@ -64,7 +64,8 @@ static uint64_t arm32_readq ( volatile uint64_t *io_addr ) {
|
|||||||
*
|
*
|
||||||
* This is not atomic for ARM32.
|
* This is not atomic for ARM32.
|
||||||
*/
|
*/
|
||||||
static void arm32_writeq ( uint64_t data, volatile uint64_t *io_addr ) {
|
static __unused void arm32_writeq ( uint64_t data,
|
||||||
|
volatile uint64_t *io_addr ) {
|
||||||
volatile union arm32_io_qword *ptr =
|
volatile union arm32_io_qword *ptr =
|
||||||
container_of ( io_addr, union arm32_io_qword, qword );
|
container_of ( io_addr, union arm32_io_qword, qword );
|
||||||
union arm32_io_qword tmp;
|
union arm32_io_qword tmp;
|
||||||
@@ -82,7 +83,6 @@ PROVIDE_IOAPI_INLINE ( arm, readl );
|
|||||||
PROVIDE_IOAPI_INLINE ( arm, writeb );
|
PROVIDE_IOAPI_INLINE ( arm, writeb );
|
||||||
PROVIDE_IOAPI_INLINE ( arm, writew );
|
PROVIDE_IOAPI_INLINE ( arm, writew );
|
||||||
PROVIDE_IOAPI_INLINE ( arm, writel );
|
PROVIDE_IOAPI_INLINE ( arm, writel );
|
||||||
PROVIDE_IOAPI_INLINE ( arm, iodelay );
|
|
||||||
PROVIDE_IOAPI_INLINE ( arm, mb );
|
PROVIDE_IOAPI_INLINE ( arm, mb );
|
||||||
#ifdef __aarch64__
|
#ifdef __aarch64__
|
||||||
PROVIDE_IOAPI_INLINE ( arm, readq );
|
PROVIDE_IOAPI_INLINE ( arm, readq );
|
||||||
@@ -91,3 +91,4 @@ PROVIDE_IOAPI_INLINE ( arm, writeq );
|
|||||||
PROVIDE_IOAPI ( arm, readq, arm32_readq );
|
PROVIDE_IOAPI ( arm, readq, arm32_readq );
|
||||||
PROVIDE_IOAPI ( arm, writeq, arm32_writeq );
|
PROVIDE_IOAPI ( arm, writeq, arm32_writeq );
|
||||||
#endif
|
#endif
|
||||||
|
PROVIDE_DUMMY_PIO ( arm );
|
||||||
|
|||||||
@@ -9,6 +9,4 @@
|
|||||||
|
|
||||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||||
|
|
||||||
#include <ipxe/io.h>
|
|
||||||
|
|
||||||
#endif /* _BITS_PCI_IO_H */
|
#endif /* _BITS_PCI_IO_H */
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
|||||||
#define IOAPI_PREFIX_arm __arm_
|
#define IOAPI_PREFIX_arm __arm_
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <ipxe/dummy_pio.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Memory space mappings
|
* Memory space mappings
|
||||||
*
|
*
|
||||||
@@ -77,55 +79,6 @@ ARM_WRITEX ( w, uint16_t, "h", "" );
|
|||||||
ARM_WRITEX ( l, uint32_t, "", "" );
|
ARM_WRITEX ( l, uint32_t, "", "" );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
|
||||||
* Dummy PIO reads and writes up to 32 bits
|
|
||||||
*
|
|
||||||
* There is no common standard for I/O-space access for ARM, and
|
|
||||||
* non-MMIO peripherals are vanishingly rare. Provide dummy
|
|
||||||
* implementations that will allow code to link and should cause
|
|
||||||
* drivers to simply fail to detect hardware at runtime.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define ARM_INX( _suffix, _type ) \
|
|
||||||
static inline __always_inline _type \
|
|
||||||
IOAPI_INLINE ( arm, in ## _suffix ) ( volatile _type *io_addr __unused) { \
|
|
||||||
return ~( (_type) 0 ); \
|
|
||||||
} \
|
|
||||||
static inline __always_inline void \
|
|
||||||
IOAPI_INLINE ( arm, ins ## _suffix ) ( volatile _type *io_addr __unused, \
|
|
||||||
_type *data, unsigned int count ) { \
|
|
||||||
memset ( data, 0xff, count * sizeof ( *data ) ); \
|
|
||||||
}
|
|
||||||
ARM_INX ( b, uint8_t );
|
|
||||||
ARM_INX ( w, uint16_t );
|
|
||||||
ARM_INX ( l, uint32_t );
|
|
||||||
|
|
||||||
#define ARM_OUTX( _suffix, _type ) \
|
|
||||||
static inline __always_inline void \
|
|
||||||
IOAPI_INLINE ( arm, out ## _suffix ) ( _type data __unused, \
|
|
||||||
volatile _type *io_addr __unused ) { \
|
|
||||||
/* Do nothing */ \
|
|
||||||
} \
|
|
||||||
static inline __always_inline void \
|
|
||||||
IOAPI_INLINE ( arm, outs ## _suffix ) ( volatile _type *io_addr __unused, \
|
|
||||||
const _type *data __unused, \
|
|
||||||
unsigned int count __unused ) { \
|
|
||||||
/* Do nothing */ \
|
|
||||||
}
|
|
||||||
ARM_OUTX ( b, uint8_t );
|
|
||||||
ARM_OUTX ( w, uint16_t );
|
|
||||||
ARM_OUTX ( l, uint32_t );
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Slow down I/O
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
static inline __always_inline void
|
|
||||||
IOAPI_INLINE ( arm, iodelay ) ( void ) {
|
|
||||||
/* Nothing to do */
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Memory barrier
|
* Memory barrier
|
||||||
*
|
*
|
||||||
@@ -140,4 +93,7 @@ IOAPI_INLINE ( arm, mb ) ( void ) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Dummy PIO */
|
||||||
|
DUMMY_PIO ( arm );
|
||||||
|
|
||||||
#endif /* _IPXE_ARM_IO_H */
|
#endif /* _IPXE_ARM_IO_H */
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||||
|
|
||||||
|
.section ".note.GNU-stack", "", %progbits
|
||||||
.text
|
.text
|
||||||
|
|
||||||
/* Must match jmp_buf structure layout */
|
/* Must match jmp_buf structure layout */
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
* Interrupt handlers
|
* Interrupt handlers
|
||||||
****************************************************************************
|
****************************************************************************
|
||||||
*/
|
*/
|
||||||
|
.section ".note.GNU-stack", "", @progbits
|
||||||
.section ".text", "ax", @progbits
|
.section ".text", "ax", @progbits
|
||||||
.code32
|
.code32
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||||
|
|
||||||
|
.section ".note.GNU-stack", "", @progbits
|
||||||
.text
|
.text
|
||||||
.arch i386
|
.arch i386
|
||||||
.code32
|
.code32
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
.section ".note.GNU-stack", "", @progbits
|
||||||
.arch i386
|
.arch i386
|
||||||
|
|
||||||
.section ".data", "aw", @progbits
|
.section ".data", "aw", @progbits
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ CFLAGS += -fshort-wchar
|
|||||||
|
|
||||||
# LoongArch64-specific directories containing source files
|
# LoongArch64-specific directories containing source files
|
||||||
SRCDIRS += arch/loong64/core
|
SRCDIRS += arch/loong64/core
|
||||||
|
SRCDIRS += arch/loong64/interface/efi
|
||||||
|
|
||||||
# Include platform-specific Makefile
|
# Include platform-specific Makefile
|
||||||
MAKEDEPS += arch/loong64/Makefile.$(PLATFORM)
|
MAKEDEPS += arch/loong64/Makefile.$(PLATFORM)
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
# -*- makefile -*- : Force emacs to use Makefile mode
|
||||||
|
|
||||||
|
# Specify EFI image builder
|
||||||
|
#
|
||||||
|
ELF2EFI = $(ELF2EFI64)
|
||||||
|
|
||||||
|
# Specify EFI boot file
|
||||||
|
#
|
||||||
|
EFI_BOOT_FILE = bootloongarch64.efi
|
||||||
|
|
||||||
|
# Include generic EFI Makefile
|
||||||
|
#
|
||||||
|
MAKEDEPS += Makefile.efi
|
||||||
|
include Makefile.efi
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* 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 <ipxe/io.h>
|
||||||
|
#include <ipxe/loong64_io.h>
|
||||||
|
|
||||||
|
/** @file
|
||||||
|
*
|
||||||
|
* iPXE I/O API for LoongArch64
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
PROVIDE_IOAPI_INLINE ( loong64, phys_to_bus );
|
||||||
|
PROVIDE_IOAPI_INLINE ( loong64, bus_to_phys );
|
||||||
|
PROVIDE_IOAPI_INLINE ( loong64, readb );
|
||||||
|
PROVIDE_IOAPI_INLINE ( loong64, readw );
|
||||||
|
PROVIDE_IOAPI_INLINE ( loong64, readl );
|
||||||
|
PROVIDE_IOAPI_INLINE ( loong64, readq );
|
||||||
|
PROVIDE_IOAPI_INLINE ( loong64, writeb );
|
||||||
|
PROVIDE_IOAPI_INLINE ( loong64, writew );
|
||||||
|
PROVIDE_IOAPI_INLINE ( loong64, writel );
|
||||||
|
PROVIDE_IOAPI_INLINE ( loong64, writeq );
|
||||||
|
PROVIDE_IOAPI_INLINE ( loong64, mb );
|
||||||
|
PROVIDE_DUMMY_PIO ( loong64 );
|
||||||
@@ -12,4 +12,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
|||||||
/** Page shift */
|
/** Page shift */
|
||||||
#define PAGE_SHIFT 12
|
#define PAGE_SHIFT 12
|
||||||
|
|
||||||
|
#include <ipxe/loong64_io.h>
|
||||||
|
|
||||||
#endif /* _BITS_IO_H */
|
#endif /* _BITS_IO_H */
|
||||||
|
|||||||
@@ -9,4 +9,6 @@
|
|||||||
|
|
||||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||||
|
|
||||||
#endif /* _BITS_MAP_H */
|
#include <ipxe/efi/efiloong64_nap.h>
|
||||||
|
|
||||||
|
#endif /* _BITS_NAP_H */
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
#ifndef _IPXE_EFILOONG64_NAP_H
|
||||||
|
#define _IPXE_EFILOONG64_NAP_H
|
||||||
|
|
||||||
|
/** @file
|
||||||
|
*
|
||||||
|
* EFI CPU sleeping
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||||
|
|
||||||
|
#ifdef NAP_EFILOONG64
|
||||||
|
#define NAP_PREFIX_efiloong64
|
||||||
|
#else
|
||||||
|
#define NAP_PREFIX_efiloong64 __efiloong64_
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _IPXE_EFILOONG64_NAP_H */
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
#ifndef _IPXE_LOONG64_IO_H
|
||||||
|
#define _IPXE_LOONG64_IO_H
|
||||||
|
|
||||||
|
/** @file
|
||||||
|
*
|
||||||
|
* iPXE I/O API for LoongArch64
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||||
|
|
||||||
|
#ifdef IOAPI_LOONG64
|
||||||
|
#define IOAPI_PREFIX_loong64
|
||||||
|
#else
|
||||||
|
#define IOAPI_PREFIX_loong64 __loong64_
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <ipxe/dummy_pio.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Memory space mappings
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Physical<->Bus address mappings
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
static inline __always_inline unsigned long
|
||||||
|
IOAPI_INLINE ( loong64, phys_to_bus ) ( unsigned long phys_addr ) {
|
||||||
|
return phys_addr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline __always_inline unsigned long
|
||||||
|
IOAPI_INLINE ( loong64, bus_to_phys ) ( unsigned long bus_addr ) {
|
||||||
|
return bus_addr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* MMIO reads and writes up to native word size
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define LOONG64_READX( _suffix, _type, _insn_suffix ) \
|
||||||
|
static inline __always_inline _type \
|
||||||
|
IOAPI_INLINE ( loong64, read ## _suffix ) ( volatile _type *io_addr ) { \
|
||||||
|
_type data; \
|
||||||
|
__asm__ __volatile__ ( "ld." _insn_suffix " %0, %1" \
|
||||||
|
: "=r" ( data ) : "m" ( *io_addr ) ); \
|
||||||
|
return data; \
|
||||||
|
}
|
||||||
|
LOONG64_READX ( b, uint8_t, "bu");
|
||||||
|
LOONG64_READX ( w, uint16_t, "hu");
|
||||||
|
LOONG64_READX ( l, uint32_t, "wu");
|
||||||
|
LOONG64_READX ( q, uint64_t, "d");
|
||||||
|
|
||||||
|
#define LOONG64_WRITEX( _suffix, _type, _insn_suffix ) \
|
||||||
|
static inline __always_inline void \
|
||||||
|
IOAPI_INLINE ( loong64, write ## _suffix ) ( _type data, \
|
||||||
|
volatile _type *io_addr ) { \
|
||||||
|
__asm__ __volatile__ ( "st." _insn_suffix " %0, %1" \
|
||||||
|
: : "r" ( data ), "m" ( *io_addr ) ); \
|
||||||
|
}
|
||||||
|
LOONG64_WRITEX ( b, uint8_t, "b");
|
||||||
|
LOONG64_WRITEX ( w, uint16_t, "h");
|
||||||
|
LOONG64_WRITEX ( l, uint32_t, "w" );
|
||||||
|
LOONG64_WRITEX ( q, uint64_t, "d");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Memory barrier
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
static inline __always_inline void
|
||||||
|
IOAPI_INLINE ( loong64, mb ) ( void ) {
|
||||||
|
__asm__ __volatile__ ( "dbar 0" );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Dummy PIO */
|
||||||
|
DUMMY_PIO ( loong64 );
|
||||||
|
|
||||||
|
#endif /* _IPXE_LOONG64_IO_H */
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* 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 <ipxe/nap.h>
|
||||||
|
#include <ipxe/efi/efi.h>
|
||||||
|
|
||||||
|
/** @file
|
||||||
|
*
|
||||||
|
* iPXE CPU sleeping API for EFI
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sleep until next interrupt
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
static void efiloong64_cpu_nap ( void ) {
|
||||||
|
/*
|
||||||
|
* I can't find any EFI API that allows us to put the CPU to
|
||||||
|
* sleep. The CpuSleep() function is defined in CpuLib.h, but
|
||||||
|
* isn't part of any exposed protocol so we have no way to
|
||||||
|
* call it.
|
||||||
|
*
|
||||||
|
* The EFI shell doesn't seem to bother sleeping the CPU; it
|
||||||
|
* just sits there idly burning power.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
__asm__ __volatile__ ( "idle 0" );
|
||||||
|
}
|
||||||
|
|
||||||
|
PROVIDE_NAP ( efiloong64, cpu_nap, efiloong64_cpu_nap );
|
||||||
@@ -13,6 +13,13 @@ LDSCRIPT_PREFIX = arch/x86/scripts/prefixonly.lds
|
|||||||
#
|
#
|
||||||
LDFLAGS += -N --no-check-sections
|
LDFLAGS += -N --no-check-sections
|
||||||
|
|
||||||
|
# Do not warn about RWX segments (required by most prefixes)
|
||||||
|
#
|
||||||
|
WRWX_TEST = $(LD) --warn-rwx-segments --version 2>&1 > /dev/null
|
||||||
|
WRWX_FLAGS := $(shell [ -z "`$(WRWX_TEST)`" ] && \
|
||||||
|
$(ECHO) '--no-warn-rwx-segments')
|
||||||
|
LDFLAGS += $(WRWX_FLAGS)
|
||||||
|
|
||||||
# Media types.
|
# Media types.
|
||||||
#
|
#
|
||||||
MEDIA += rom
|
MEDIA += rom
|
||||||
@@ -54,9 +61,15 @@ LIST_NAME_mrom := ROMS
|
|||||||
LIST_NAME_pcirom := ROMS
|
LIST_NAME_pcirom := ROMS
|
||||||
LIST_NAME_isarom := ROMS
|
LIST_NAME_isarom := ROMS
|
||||||
|
|
||||||
# ISO or FAT filesystem images
|
# ISO images
|
||||||
NON_AUTO_MEDIA += iso
|
NON_AUTO_MEDIA += iso
|
||||||
$(BIN)/%.iso $(BIN)/%.sdsk: $(BIN)/%.lkrn util/genfsimg
|
$(BIN)/%.iso : $(BIN)/%.lkrn util/genfsimg
|
||||||
|
$(QM)$(ECHO) " [GENFSIMG] $@"
|
||||||
|
$(Q)util/genfsimg -o $@ $<
|
||||||
|
|
||||||
|
# FAT filesystem images (via syslinux)
|
||||||
|
NON_AUTO_MEDIA += sdsk
|
||||||
|
$(BIN)/%.sdsk : $(BIN)/%.lkrn util/genfsimg
|
||||||
$(QM)$(ECHO) " [GENFSIMG] $@"
|
$(QM)$(ECHO) " [GENFSIMG] $@"
|
||||||
$(Q)util/genfsimg -o $@ $<
|
$(Q)util/genfsimg -o $@ $<
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||||
|
|
||||||
|
.section ".note.GNU-stack", "", @progbits
|
||||||
.text
|
.text
|
||||||
.arch i386
|
.arch i386
|
||||||
.code16
|
.code16
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||||
|
|
||||||
|
.section ".note.GNU-stack", "", @progbits
|
||||||
.arch i386
|
.arch i386
|
||||||
|
|
||||||
#ifdef __x86_64__
|
#ifdef __x86_64__
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||||
|
|
||||||
|
.section ".note.GNU-stack", "", @progbits
|
||||||
.arch i386
|
.arch i386
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ FILE_LICENCE ( GPL2_OR_LATER )
|
|||||||
#define PIC1_ICR 0x20
|
#define PIC1_ICR 0x20
|
||||||
#define PIC2_ICR 0xa0
|
#define PIC2_ICR 0xa0
|
||||||
|
|
||||||
|
.section ".note.GNU-stack", "", @progbits
|
||||||
.text
|
.text
|
||||||
.arch i386
|
.arch i386
|
||||||
.code16
|
.code16
|
||||||
|
|||||||
@@ -290,29 +290,38 @@ static const char *bios_ansi_input = "";
|
|||||||
struct bios_key {
|
struct bios_key {
|
||||||
/** Scancode */
|
/** Scancode */
|
||||||
uint8_t scancode;
|
uint8_t scancode;
|
||||||
/** Key code */
|
/** Relative key value */
|
||||||
uint16_t key;
|
uint16_t rkey;
|
||||||
} __attribute__ (( packed ));
|
} __attribute__ (( packed ));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define a BIOS key mapping
|
||||||
|
*
|
||||||
|
* @v scancode Scancode
|
||||||
|
* @v key iPXE key code
|
||||||
|
* @v bioskey BIOS key mapping
|
||||||
|
*/
|
||||||
|
#define BIOS_KEY( scancode, key ) { scancode, KEY_REL ( key ) }
|
||||||
|
|
||||||
/** Mapping from BIOS scan codes to iPXE key codes */
|
/** Mapping from BIOS scan codes to iPXE key codes */
|
||||||
static const struct bios_key bios_keys[] = {
|
static const struct bios_key bios_keys[] = {
|
||||||
{ 0x53, KEY_DC },
|
BIOS_KEY ( 0x53, KEY_DC ),
|
||||||
{ 0x48, KEY_UP },
|
BIOS_KEY ( 0x48, KEY_UP ),
|
||||||
{ 0x50, KEY_DOWN },
|
BIOS_KEY ( 0x50, KEY_DOWN ),
|
||||||
{ 0x4b, KEY_LEFT },
|
BIOS_KEY ( 0x4b, KEY_LEFT ),
|
||||||
{ 0x4d, KEY_RIGHT },
|
BIOS_KEY ( 0x4d, KEY_RIGHT ),
|
||||||
{ 0x47, KEY_HOME },
|
BIOS_KEY ( 0x47, KEY_HOME ),
|
||||||
{ 0x4f, KEY_END },
|
BIOS_KEY ( 0x4f, KEY_END ),
|
||||||
{ 0x49, KEY_PPAGE },
|
BIOS_KEY ( 0x49, KEY_PPAGE ),
|
||||||
{ 0x51, KEY_NPAGE },
|
BIOS_KEY ( 0x51, KEY_NPAGE ),
|
||||||
{ 0x3f, KEY_F5 },
|
BIOS_KEY ( 0x3f, KEY_F5 ),
|
||||||
{ 0x40, KEY_F6 },
|
BIOS_KEY ( 0x40, KEY_F6 ),
|
||||||
{ 0x41, KEY_F7 },
|
BIOS_KEY ( 0x41, KEY_F7 ),
|
||||||
{ 0x42, KEY_F8 },
|
BIOS_KEY ( 0x42, KEY_F8 ),
|
||||||
{ 0x43, KEY_F9 },
|
BIOS_KEY ( 0x43, KEY_F9 ),
|
||||||
{ 0x44, KEY_F10 },
|
BIOS_KEY ( 0x44, KEY_F10 ),
|
||||||
{ 0x85, KEY_F11 },
|
BIOS_KEY ( 0x85, KEY_F11 ),
|
||||||
{ 0x86, KEY_F12 },
|
BIOS_KEY ( 0x86, KEY_F12 ),
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -323,7 +332,7 @@ static const struct bios_key bios_keys[] = {
|
|||||||
*/
|
*/
|
||||||
static const char * bios_ansi_seq ( unsigned int scancode ) {
|
static const char * bios_ansi_seq ( unsigned int scancode ) {
|
||||||
static char buf[ 5 /* "[" + two digits + terminator + NUL */ ];
|
static char buf[ 5 /* "[" + two digits + terminator + NUL */ ];
|
||||||
unsigned int key;
|
unsigned int rkey;
|
||||||
unsigned int terminator;
|
unsigned int terminator;
|
||||||
unsigned int n;
|
unsigned int n;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
@@ -338,9 +347,9 @@ static const char * bios_ansi_seq ( unsigned int scancode ) {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Construct escape sequence */
|
/* Construct escape sequence */
|
||||||
key = bios_keys[i].key;
|
rkey = bios_keys[i].rkey;
|
||||||
n = KEY_ANSI_N ( key );
|
n = KEY_ANSI_N ( rkey );
|
||||||
terminator = KEY_ANSI_TERMINATOR ( key );
|
terminator = KEY_ANSI_TERMINATOR ( rkey );
|
||||||
*(tmp++) = '[';
|
*(tmp++) = '[';
|
||||||
if ( n )
|
if ( n )
|
||||||
tmp += sprintf ( tmp, "%d", n );
|
tmp += sprintf ( tmp, "%d", n );
|
||||||
@@ -479,6 +488,7 @@ struct console_driver bios_console __console_driver = {
|
|||||||
static __asmcall __used void bios_inject ( struct i386_all_regs *ix86 ) {
|
static __asmcall __used void bios_inject ( struct i386_all_regs *ix86 ) {
|
||||||
unsigned int discard_a;
|
unsigned int discard_a;
|
||||||
unsigned int scancode;
|
unsigned int scancode;
|
||||||
|
unsigned int rkey;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
uint16_t keypress;
|
uint16_t keypress;
|
||||||
int key;
|
int key;
|
||||||
@@ -521,9 +531,10 @@ static __asmcall __used void bios_inject ( struct i386_all_regs *ix86 ) {
|
|||||||
|
|
||||||
/* Handle special keys */
|
/* Handle special keys */
|
||||||
if ( key >= KEY_MIN ) {
|
if ( key >= KEY_MIN ) {
|
||||||
|
rkey = KEY_REL ( key );
|
||||||
for ( i = 0 ; i < ( sizeof ( bios_keys ) /
|
for ( i = 0 ; i < ( sizeof ( bios_keys ) /
|
||||||
sizeof ( bios_keys[0] ) ) ; i++ ) {
|
sizeof ( bios_keys[0] ) ) ; i++ ) {
|
||||||
if ( bios_keys[i].key == key ) {
|
if ( bios_keys[i].rkey == rkey ) {
|
||||||
scancode = bios_keys[i].scancode;
|
scancode = bios_keys[i].scancode;
|
||||||
keypress = ( scancode << 8 );
|
keypress = ( scancode << 8 );
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||||
|
|
||||||
|
.section ".note.GNU-stack", "", @progbits
|
||||||
.text
|
.text
|
||||||
.arch i386
|
.arch i386
|
||||||
.code16
|
.code16
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
|||||||
|
|
||||||
#include <librm.h>
|
#include <librm.h>
|
||||||
|
|
||||||
|
.section ".note.GNU-stack", "", @progbits
|
||||||
.arch i386
|
.arch i386
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ FILE_LICENCE ( GPL2_OR_LATER )
|
|||||||
|
|
||||||
#include "librm.h"
|
#include "librm.h"
|
||||||
|
|
||||||
|
.section ".note.GNU-stack", "", @progbits
|
||||||
.text
|
.text
|
||||||
|
|
||||||
.code32
|
.code32
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
|||||||
#define STACK_SEG 0x0200
|
#define STACK_SEG 0x0200
|
||||||
#define STACK_SIZE 0x2000
|
#define STACK_SIZE 0x2000
|
||||||
|
|
||||||
|
.section ".note.GNU-stack", "", @progbits
|
||||||
.text
|
.text
|
||||||
.arch i386
|
.arch i386
|
||||||
.section ".prefix", "awx", @progbits
|
.section ".prefix", "awx", @progbits
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ FILE_LICENCE ( GPL2_ONLY )
|
|||||||
|
|
||||||
.equ SYSSEG, 0x1000 /* system loaded at SYSSEG<<4 */
|
.equ SYSSEG, 0x1000 /* system loaded at SYSSEG<<4 */
|
||||||
|
|
||||||
|
.section ".note.GNU-stack", "", @progbits
|
||||||
.org 0
|
.org 0
|
||||||
.arch i386
|
.arch i386
|
||||||
.text
|
.text
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
|||||||
#define PSP_CMDLINE_LEN 0x80
|
#define PSP_CMDLINE_LEN 0x80
|
||||||
#define PSP_CMDLINE_START 0x81
|
#define PSP_CMDLINE_START 0x81
|
||||||
|
|
||||||
|
.section ".note.GNU-stack", "", @progbits
|
||||||
.text
|
.text
|
||||||
.arch i386
|
.arch i386
|
||||||
.org 0
|
.org 0
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
|||||||
|
|
||||||
#include <librm.h>
|
#include <librm.h>
|
||||||
|
|
||||||
|
.section ".note.GNU-stack", "", @progbits
|
||||||
.text
|
.text
|
||||||
.arch i386
|
.arch i386
|
||||||
.section ".prefix", "awx", @progbits
|
.section ".prefix", "awx", @progbits
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
|||||||
|
|
||||||
#include <librm.h>
|
#include <librm.h>
|
||||||
|
|
||||||
|
.section ".note.GNU-stack", "", @progbits
|
||||||
.arch i386
|
.arch i386
|
||||||
|
|
||||||
/* Image compression enabled */
|
/* Image compression enabled */
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
|||||||
|
|
||||||
#define BZI_LOAD_HIGH_ADDR 0x100000
|
#define BZI_LOAD_HIGH_ADDR 0x100000
|
||||||
|
|
||||||
|
.section ".note.GNU-stack", "", @progbits
|
||||||
.text
|
.text
|
||||||
.arch i386
|
.arch i386
|
||||||
.code16
|
.code16
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||||
|
|
||||||
|
.section ".note.GNU-stack", "", @progbits
|
||||||
.text
|
.text
|
||||||
.arch i386
|
.arch i386
|
||||||
.section ".prefix", "awx", @progbits
|
.section ".prefix", "awx", @progbits
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
|||||||
#define _pcirom_start _mrom_start
|
#define _pcirom_start _mrom_start
|
||||||
#include "pciromprefix.S"
|
#include "pciromprefix.S"
|
||||||
|
|
||||||
|
.section ".note.GNU-stack", "", @progbits
|
||||||
.text
|
.text
|
||||||
.arch i386
|
.arch i386
|
||||||
.code16
|
.code16
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
|||||||
|
|
||||||
#include <librm.h>
|
#include <librm.h>
|
||||||
|
|
||||||
|
.section ".note.GNU-stack", "", @progbits
|
||||||
.text
|
.text
|
||||||
.arch i386
|
.arch i386
|
||||||
.code16
|
.code16
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||||
|
|
||||||
|
.section ".note.GNU-stack", "", @progbits
|
||||||
.org 0
|
.org 0
|
||||||
.text
|
.text
|
||||||
.arch i386
|
.arch i386
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
|||||||
|
|
||||||
#define PXE_HACK_EB54 0x0001
|
#define PXE_HACK_EB54 0x0001
|
||||||
|
|
||||||
|
.section ".note.GNU-stack", "", @progbits
|
||||||
.text
|
.text
|
||||||
.arch i386
|
.arch i386
|
||||||
.org 0
|
.org 0
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||||
|
|
||||||
|
.section ".note.GNU-stack", "", @progbits
|
||||||
.text
|
.text
|
||||||
.arch i386
|
.arch i386
|
||||||
.org 0
|
.org 0
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
|||||||
#define BUSTYPE "PCIR"
|
#define BUSTYPE "PCIR"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
.section ".note.GNU-stack", "", @progbits
|
||||||
.text
|
.text
|
||||||
.code16
|
.code16
|
||||||
.arch i386
|
.arch i386
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
|||||||
|
|
||||||
#include <librm.h>
|
#include <librm.h>
|
||||||
|
|
||||||
|
.section ".note.GNU-stack", "", @progbits
|
||||||
.text
|
.text
|
||||||
.code16
|
.code16
|
||||||
.arch i386
|
.arch i386
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
|||||||
****************************************************************************
|
****************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
.section ".note.GNU-stack", "", @progbits
|
||||||
.text
|
.text
|
||||||
.arch i486
|
.arch i486
|
||||||
.section ".prefix.lib", "ax", @progbits
|
.section ".prefix.lib", "ax", @progbits
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
|||||||
|
|
||||||
#include <config/console.h>
|
#include <config/console.h>
|
||||||
|
|
||||||
|
.section ".note.GNU-stack", "", @progbits
|
||||||
.text
|
.text
|
||||||
.arch i386
|
.arch i386
|
||||||
.section ".prefix", "awx", @progbits
|
.section ".prefix", "awx", @progbits
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||||
|
|
||||||
|
.section ".note.GNU-stack", "", @progbits
|
||||||
.arch i386
|
.arch i386
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
|||||||
/* Breakpoint for when debugging under bochs */
|
/* Breakpoint for when debugging under bochs */
|
||||||
#define BOCHSBP xchgw %bx, %bx
|
#define BOCHSBP xchgw %bx, %bx
|
||||||
|
|
||||||
|
.section ".note.GNU-stack", "", @progbits
|
||||||
.text
|
.text
|
||||||
.arch i386
|
.arch i386
|
||||||
.section ".text16", "awx", @progbits
|
.section ".text16", "awx", @progbits
|
||||||
|
|||||||
@@ -83,6 +83,8 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
|||||||
#define if64 if 0
|
#define if64 if 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
.section ".note.GNU-stack", "", @progbits
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Global descriptor table
|
* Global descriptor table
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
|||||||
#define SIGFPE 8
|
#define SIGFPE 8
|
||||||
#define SIGSTKFLT 16
|
#define SIGSTKFLT 16
|
||||||
|
|
||||||
|
.section ".note.GNU-stack", "", @progbits
|
||||||
.section ".text.gdbmach_interrupt", "ax", @progbits
|
.section ".text.gdbmach_interrupt", "ax", @progbits
|
||||||
.code64
|
.code64
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||||
|
|
||||||
|
.section ".note.GNU-stack", "", @progbits
|
||||||
.text
|
.text
|
||||||
.code64
|
.code64
|
||||||
|
|
||||||
|
|||||||
@@ -67,4 +67,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
|||||||
#define IMAGE_GZIP /* GZIP image support */
|
#define IMAGE_GZIP /* GZIP image support */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined ( __loongarch__ )
|
||||||
|
#define IOAPI_LOONG64
|
||||||
|
#define NAP_EFILOONG64
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* CONFIG_DEFAULTS_EFI_H */
|
#endif /* CONFIG_DEFAULTS_EFI_H */
|
||||||
|
|||||||
@@ -285,6 +285,7 @@ void intf_shutdown ( struct interface *intf, int rc ) {
|
|||||||
intf_nullify ( intf );
|
intf_nullify ( intf );
|
||||||
|
|
||||||
/* Transfer destination to temporary interface */
|
/* Transfer destination to temporary interface */
|
||||||
|
intf_temp_init ( &tmp, intf );
|
||||||
tmp.dest = intf->dest;
|
tmp.dest = intf->dest;
|
||||||
intf->dest = &null_intf;
|
intf->dest = &null_intf;
|
||||||
|
|
||||||
|
|||||||
+14
-1
@@ -28,6 +28,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <ipxe/netdevice.h>
|
#include <ipxe/netdevice.h>
|
||||||
@@ -35,6 +36,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
|||||||
#include <ipxe/settings.h>
|
#include <ipxe/settings.h>
|
||||||
#include <ipxe/params.h>
|
#include <ipxe/params.h>
|
||||||
#include <ipxe/timer.h>
|
#include <ipxe/timer.h>
|
||||||
|
#include <ipxe/keys.h>
|
||||||
#include <ipxe/parseopt.h>
|
#include <ipxe/parseopt.h>
|
||||||
#include <config/branding.h>
|
#include <config/branding.h>
|
||||||
|
|
||||||
@@ -213,6 +215,7 @@ int parse_flag ( char *text __unused, int *flag ) {
|
|||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
int parse_key ( char *text, unsigned int *key ) {
|
int parse_key ( char *text, unsigned int *key ) {
|
||||||
|
int rc;
|
||||||
|
|
||||||
/* Interpret single characters as being a literal key character */
|
/* Interpret single characters as being a literal key character */
|
||||||
if ( text[0] && ! text[1] ) {
|
if ( text[0] && ! text[1] ) {
|
||||||
@@ -221,7 +224,17 @@ int parse_key ( char *text, unsigned int *key ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Otherwise, interpret as an integer */
|
/* Otherwise, interpret as an integer */
|
||||||
return parse_integer ( text, key );
|
if ( ( rc = parse_integer ( text, key ) ) < 0 )
|
||||||
|
return rc;
|
||||||
|
|
||||||
|
/* For backwards compatibility with existing scripts, treat
|
||||||
|
* integers between the ASCII range and special key range as
|
||||||
|
* being relative special key values.
|
||||||
|
*/
|
||||||
|
if ( ( ! isascii ( *key ) ) && ( *key < KEY_MIN ) )
|
||||||
|
*key += KEY_MIN;
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+2
-1
@@ -60,7 +60,7 @@ static struct xfer_metadata dummy_metadata;
|
|||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
int xfer_vredirect ( struct interface *intf, int type, va_list args ) {
|
int xfer_vredirect ( struct interface *intf, int type, va_list args ) {
|
||||||
struct interface tmp = INTF_INIT ( null_intf_desc );
|
struct interface tmp;
|
||||||
struct interface *dest;
|
struct interface *dest;
|
||||||
xfer_vredirect_TYPE ( void * ) *op =
|
xfer_vredirect_TYPE ( void * ) *op =
|
||||||
intf_get_dest_op_no_passthru ( intf, xfer_vredirect, &dest );
|
intf_get_dest_op_no_passthru ( intf, xfer_vredirect, &dest );
|
||||||
@@ -85,6 +85,7 @@ int xfer_vredirect ( struct interface *intf, int type, va_list args ) {
|
|||||||
* If redirection fails, then send intf_close() to the
|
* If redirection fails, then send intf_close() to the
|
||||||
* parent interface.
|
* parent interface.
|
||||||
*/
|
*/
|
||||||
|
intf_temp_init ( &tmp, intf );
|
||||||
intf_plug ( &tmp, dest );
|
intf_plug ( &tmp, dest );
|
||||||
rc = xfer_vreopen ( dest, type, args );
|
rc = xfer_vreopen ( dest, type, args );
|
||||||
if ( rc == 0 ) {
|
if ( rc == 0 ) {
|
||||||
|
|||||||
@@ -300,9 +300,9 @@ static int af_packet_nic_probe ( struct linux_device *device,
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err_settings:
|
|
||||||
unregister_netdev(netdev);
|
unregister_netdev(netdev);
|
||||||
err_register:
|
err_register:
|
||||||
|
err_settings:
|
||||||
netdev_nullify(netdev);
|
netdev_nullify(netdev);
|
||||||
netdev_put(netdev);
|
netdev_put(netdev);
|
||||||
return rc;
|
return rc;
|
||||||
|
|||||||
@@ -56,6 +56,10 @@ struct tap_nic {
|
|||||||
int fd;
|
int fd;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** Default MAC address */
|
||||||
|
static const uint8_t tap_default_mac[ETH_ALEN] =
|
||||||
|
{ 0x52, 0x54, 0x00, 0x12, 0x34, 0x56 };
|
||||||
|
|
||||||
/** Open the TAP device */
|
/** Open the TAP device */
|
||||||
static int tap_open(struct net_device * netdev)
|
static int tap_open(struct net_device * netdev)
|
||||||
{
|
{
|
||||||
@@ -202,6 +206,7 @@ static int tap_probe(struct linux_device *device, struct linux_device_request *r
|
|||||||
nic = netdev->priv;
|
nic = netdev->priv;
|
||||||
linux_set_drvdata(device, netdev);
|
linux_set_drvdata(device, netdev);
|
||||||
netdev->dev = &device->dev;
|
netdev->dev = &device->dev;
|
||||||
|
memcpy ( netdev->hw_addr, tap_default_mac, ETH_ALEN );
|
||||||
memset(nic, 0, sizeof(*nic));
|
memset(nic, 0, sizeof(*nic));
|
||||||
|
|
||||||
/* Look for the mandatory if setting */
|
/* Look for the mandatory if setting */
|
||||||
@@ -231,9 +236,9 @@ static int tap_probe(struct linux_device *device, struct linux_device_request *r
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err_settings:
|
|
||||||
unregister_netdev(netdev);
|
unregister_netdev(netdev);
|
||||||
err_register:
|
err_register:
|
||||||
|
err_settings:
|
||||||
netdev_nullify(netdev);
|
netdev_nullify(netdev);
|
||||||
netdev_put(netdev);
|
netdev_put(netdev);
|
||||||
return rc;
|
return rc;
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ static unsigned int usbkbd_map ( unsigned int keycode, unsigned int modifiers,
|
|||||||
}
|
}
|
||||||
} else if ( keycode <= USBKBD_KEY_UP ) {
|
} else if ( keycode <= USBKBD_KEY_UP ) {
|
||||||
/* Special keys */
|
/* Special keys */
|
||||||
static const uint16_t special[] = {
|
static const unsigned int special[] = {
|
||||||
0, 0, 0, 0, 0, KEY_F5, KEY_F6, KEY_F7, KEY_F8, KEY_F9,
|
0, 0, 0, 0, 0, KEY_F5, KEY_F6, KEY_F7, KEY_F8, KEY_F9,
|
||||||
KEY_F10, KEY_F11, KEY_F12, 0, 0, 0, KEY_IC, KEY_HOME,
|
KEY_F10, KEY_F11, KEY_F12, 0, 0, 0, KEY_IC, KEY_HOME,
|
||||||
KEY_PPAGE, KEY_DC, KEY_END, KEY_NPAGE, KEY_RIGHT,
|
KEY_PPAGE, KEY_DC, KEY_END, KEY_NPAGE, KEY_RIGHT,
|
||||||
@@ -110,7 +110,7 @@ static unsigned int usbkbd_map ( unsigned int keycode, unsigned int modifiers,
|
|||||||
if ( leds & USBKBD_LED_NUM_LOCK ) {
|
if ( leds & USBKBD_LED_NUM_LOCK ) {
|
||||||
key = "1234567890." [ keycode - USBKBD_KEY_PAD_1 ];
|
key = "1234567890." [ keycode - USBKBD_KEY_PAD_1 ];
|
||||||
} else {
|
} else {
|
||||||
static const uint16_t keypad[] = {
|
static const unsigned int keypad[] = {
|
||||||
KEY_END, KEY_DOWN, KEY_NPAGE, KEY_LEFT, 0,
|
KEY_END, KEY_DOWN, KEY_NPAGE, KEY_LEFT, 0,
|
||||||
KEY_RIGHT, KEY_HOME, KEY_UP, KEY_PPAGE,
|
KEY_RIGHT, KEY_HOME, KEY_UP, KEY_PPAGE,
|
||||||
KEY_IC, KEY_DC
|
KEY_IC, KEY_DC
|
||||||
|
|||||||
@@ -9,6 +9,17 @@
|
|||||||
|
|
||||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if character is ASCII
|
||||||
|
*
|
||||||
|
* @v character Character
|
||||||
|
* @ret is_ascii Character is an ASCII character
|
||||||
|
*/
|
||||||
|
static inline int isascii ( int character ) {
|
||||||
|
|
||||||
|
return ( character <= '\x7f' );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if character is a decimal digit
|
* Check if character is a decimal digit
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -0,0 +1,64 @@
|
|||||||
|
#ifndef _IPXE_DUMMY_PIO_H
|
||||||
|
#define _IPXE_DUMMY_PIO_H
|
||||||
|
|
||||||
|
/** @file
|
||||||
|
*
|
||||||
|
* Dummy PIO reads and writes up to 32 bits
|
||||||
|
*
|
||||||
|
* There is no common standard for I/O-space access for non-x86 CPU
|
||||||
|
* families, and non-MMIO peripherals are vanishingly rare. Provide
|
||||||
|
* dummy implementations that will allow code to link and should cause
|
||||||
|
* drivers to simply fail to detect hardware at runtime.
|
||||||
|
*/
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||||
|
|
||||||
|
#define DUMMY_INX( _prefix, _suffix, _type ) \
|
||||||
|
static inline __always_inline _type \
|
||||||
|
IOAPI_INLINE ( _prefix, in ## _suffix ) ( volatile _type *io_addr __unused) { \
|
||||||
|
return ~( (_type) 0 ); \
|
||||||
|
} \
|
||||||
|
static inline __always_inline void \
|
||||||
|
IOAPI_INLINE ( _prefix, ins ## _suffix ) ( volatile _type *io_addr __unused, \
|
||||||
|
_type *data, unsigned int count ) {\
|
||||||
|
memset ( data, 0xff, count * sizeof ( *data ) ); \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define DUMMY_OUTX( _prefix, _suffix, _type ) \
|
||||||
|
static inline __always_inline void \
|
||||||
|
IOAPI_INLINE ( _prefix, out ## _suffix ) ( _type data __unused, \
|
||||||
|
volatile _type *io_addr __unused ){\
|
||||||
|
/* Do nothing */ \
|
||||||
|
} \
|
||||||
|
static inline __always_inline void \
|
||||||
|
IOAPI_INLINE ( _prefix, outs ## _suffix ) ( volatile _type *io_addr __unused, \
|
||||||
|
const _type *data __unused, \
|
||||||
|
unsigned int count __unused ) { \
|
||||||
|
/* Do nothing */ \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define DUMMY_IODELAY( _prefix ) \
|
||||||
|
static inline __always_inline void \
|
||||||
|
IOAPI_INLINE ( _prefix, iodelay ) ( void ) { \
|
||||||
|
/* Nothing to do */ \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define DUMMY_PIO( _prefix ) \
|
||||||
|
DUMMY_INX ( _prefix, b, uint8_t ); \
|
||||||
|
DUMMY_INX ( _prefix, w, uint16_t ); \
|
||||||
|
DUMMY_INX ( _prefix, l, uint32_t ); \
|
||||||
|
DUMMY_OUTX ( _prefix, b, uint8_t ); \
|
||||||
|
DUMMY_OUTX ( _prefix, w, uint16_t ); \
|
||||||
|
DUMMY_OUTX ( _prefix, l, uint32_t ); \
|
||||||
|
DUMMY_IODELAY ( _prefix );
|
||||||
|
|
||||||
|
#define PROVIDE_DUMMY_PIO( _prefix ) \
|
||||||
|
PROVIDE_IOAPI_INLINE ( _prefix, inb ); \
|
||||||
|
PROVIDE_IOAPI_INLINE ( _prefix, inw ); \
|
||||||
|
PROVIDE_IOAPI_INLINE ( _prefix, inl ); \
|
||||||
|
PROVIDE_IOAPI_INLINE ( _prefix, outb ); \
|
||||||
|
PROVIDE_IOAPI_INLINE ( _prefix, outw ); \
|
||||||
|
PROVIDE_IOAPI_INLINE ( _prefix, outl ); \
|
||||||
|
PROVIDE_IOAPI_INLINE ( _prefix, iodelay );
|
||||||
|
|
||||||
|
#endif /* _IPXE_DUMMY_PIO_H */
|
||||||
@@ -133,17 +133,30 @@ struct interface {
|
|||||||
struct interface *dest;
|
struct interface *dest;
|
||||||
/** Reference counter
|
/** Reference counter
|
||||||
*
|
*
|
||||||
* If this interface is not part of a reference-counted
|
* If this interface is not part of a reference-counted object
|
||||||
* object, this field may be NULL.
|
* then this field is NULL.
|
||||||
*/
|
*/
|
||||||
struct refcnt *refcnt;
|
struct refcnt *refcnt;
|
||||||
/** Interface descriptor */
|
/** Interface descriptor
|
||||||
struct interface_descriptor *desc;
|
|
||||||
/** Original interface descriptor
|
|
||||||
*
|
*
|
||||||
* Used by intf_reinit().
|
* If this is a temporary outbound-only interface created by
|
||||||
|
* intf_temp_init() then this field is NULL.
|
||||||
*/
|
*/
|
||||||
struct interface_descriptor *original;
|
struct interface_descriptor *desc;
|
||||||
|
/** Original interface properties */
|
||||||
|
union {
|
||||||
|
/** Original interface descriptor
|
||||||
|
*
|
||||||
|
* Used by intf_reinit().
|
||||||
|
*/
|
||||||
|
struct interface_descriptor *desc;
|
||||||
|
/** Original interface
|
||||||
|
*
|
||||||
|
* Used for temporary outbound-only interfaces created
|
||||||
|
* by intf_temp_init().
|
||||||
|
*/
|
||||||
|
struct interface *intf;
|
||||||
|
} original;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern void intf_plug ( struct interface *intf, struct interface *dest );
|
extern void intf_plug ( struct interface *intf, struct interface *dest );
|
||||||
@@ -193,7 +206,7 @@ static inline void intf_init ( struct interface *intf,
|
|||||||
intf->dest = &null_intf;
|
intf->dest = &null_intf;
|
||||||
intf->refcnt = refcnt;
|
intf->refcnt = refcnt;
|
||||||
intf->desc = desc;
|
intf->desc = desc;
|
||||||
intf->original = desc;
|
intf->original.desc = desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -201,13 +214,38 @@ static inline void intf_init ( struct interface *intf,
|
|||||||
*
|
*
|
||||||
* @v descriptor Object interface descriptor
|
* @v descriptor Object interface descriptor
|
||||||
*/
|
*/
|
||||||
#define INTF_INIT( descriptor ) { \
|
#define INTF_INIT( descriptor ) { \
|
||||||
.dest = &null_intf, \
|
.dest = &null_intf, \
|
||||||
.refcnt = NULL, \
|
.refcnt = NULL, \
|
||||||
.desc = &(descriptor), \
|
.desc = &(descriptor), \
|
||||||
.original = &(descriptor), \
|
.original = { \
|
||||||
|
.desc = &(descriptor), \
|
||||||
|
}, \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialise a temporary outbound-only object interface
|
||||||
|
*
|
||||||
|
* @v intf Temporary outbound-only object interface
|
||||||
|
* @v original Original object interface
|
||||||
|
*/
|
||||||
|
static inline void intf_temp_init ( struct interface *intf,
|
||||||
|
struct interface *original ) {
|
||||||
|
intf->dest = &null_intf;
|
||||||
|
intf->desc = NULL;
|
||||||
|
intf->original.intf = original;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get original interface
|
||||||
|
*
|
||||||
|
* @v intf Object interface (possibly a temporary interface)
|
||||||
|
* @ret intf Original object interface
|
||||||
|
*/
|
||||||
|
static inline struct interface * intf_origin ( struct interface *intf ) {
|
||||||
|
return ( intf->desc ? intf : intf->original.intf );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get object interface destination and operation method (without pass-through)
|
* Get object interface destination and operation method (without pass-through)
|
||||||
*
|
*
|
||||||
@@ -240,7 +278,7 @@ static inline void intf_init ( struct interface *intf,
|
|||||||
*
|
*
|
||||||
* Use as the first argument to DBGC() or equivalent macro.
|
* Use as the first argument to DBGC() or equivalent macro.
|
||||||
*/
|
*/
|
||||||
#define INTF_COL( intf ) intf_object ( intf )
|
#define INTF_COL( intf ) intf_object ( intf_origin ( intf ) )
|
||||||
|
|
||||||
/** printf() format string for INTF_DBG() */
|
/** printf() format string for INTF_DBG() */
|
||||||
#define INTF_FMT "%p+%zx"
|
#define INTF_FMT "%p+%zx"
|
||||||
@@ -251,7 +289,9 @@ static inline void intf_init ( struct interface *intf,
|
|||||||
* @v intf Object interface
|
* @v intf Object interface
|
||||||
* @ret args printf() argument list corresponding to INTF_FMT
|
* @ret args printf() argument list corresponding to INTF_FMT
|
||||||
*/
|
*/
|
||||||
#define INTF_DBG( intf ) intf_object ( intf ), (intf)->desc->offset
|
#define INTF_DBG( intf ) \
|
||||||
|
intf_object ( intf_origin ( intf ) ), \
|
||||||
|
intf_origin ( intf )->desc->offset
|
||||||
|
|
||||||
/** printf() format string for INTF_INTF_DBG() */
|
/** printf() format string for INTF_INTF_DBG() */
|
||||||
#define INTF_INTF_FMT INTF_FMT "->" INTF_FMT
|
#define INTF_INTF_FMT INTF_FMT "->" INTF_FMT
|
||||||
@@ -273,7 +313,7 @@ static inline void intf_init ( struct interface *intf,
|
|||||||
static inline void intf_reinit ( struct interface *intf ) {
|
static inline void intf_reinit ( struct interface *intf ) {
|
||||||
|
|
||||||
/* Restore original interface descriptor */
|
/* Restore original interface descriptor */
|
||||||
intf->desc = intf->original;
|
intf->desc = intf->original.desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* _IPXE_INTERFACE_H */
|
#endif /* _IPXE_INTERFACE_H */
|
||||||
|
|||||||
@@ -52,10 +52,10 @@ struct keymap {
|
|||||||
#define KEYMAP_PSEUDO 0x80
|
#define KEYMAP_PSEUDO 0x80
|
||||||
|
|
||||||
/** Ctrl key flag */
|
/** Ctrl key flag */
|
||||||
#define KEYMAP_CTRL 0x0100
|
#define KEYMAP_CTRL 0x01000000
|
||||||
|
|
||||||
/** CapsLock key flag */
|
/** CapsLock key flag */
|
||||||
#define KEYMAP_CAPSLOCK 0x0200
|
#define KEYMAP_CAPSLOCK 0x02000000
|
||||||
|
|
||||||
/** Undo CapsLock key flag
|
/** Undo CapsLock key flag
|
||||||
*
|
*
|
||||||
@@ -64,13 +64,13 @@ struct keymap {
|
|||||||
* in order to correctly handle keyboard mappings that swap alphabetic
|
* in order to correctly handle keyboard mappings that swap alphabetic
|
||||||
* and non-alphabetic keys.
|
* and non-alphabetic keys.
|
||||||
*/
|
*/
|
||||||
#define KEYMAP_CAPSLOCK_UNDO 0x0400
|
#define KEYMAP_CAPSLOCK_UNDO 0x04000000
|
||||||
|
|
||||||
/** Undo and redo CapsLock key flags */
|
/** Undo and redo CapsLock key flags */
|
||||||
#define KEYMAP_CAPSLOCK_REDO ( KEYMAP_CAPSLOCK | KEYMAP_CAPSLOCK_UNDO )
|
#define KEYMAP_CAPSLOCK_REDO ( KEYMAP_CAPSLOCK | KEYMAP_CAPSLOCK_UNDO )
|
||||||
|
|
||||||
/** AltGr key flag */
|
/** AltGr key flag */
|
||||||
#define KEYMAP_ALTGR 0x0800
|
#define KEYMAP_ALTGR 0x08000000
|
||||||
|
|
||||||
extern unsigned int key_remap ( unsigned int character );
|
extern unsigned int key_remap ( unsigned int character );
|
||||||
extern struct keymap * keymap_find ( const char *name );
|
extern struct keymap * keymap_find ( const char *name );
|
||||||
|
|||||||
+44
-5
@@ -49,19 +49,58 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
|||||||
#define ESC 0x1b
|
#define ESC 0x1b
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Special keys outside the normal ASCII range
|
* Special keys outside the normal Unicode range
|
||||||
*
|
|
||||||
*
|
*
|
||||||
* The names are chosen to match those used by curses. The values are
|
* The names are chosen to match those used by curses. The values are
|
||||||
* chosen to facilitate easy conversion from a received ANSI escape
|
* chosen to facilitate easy conversion from a received ANSI escape
|
||||||
* sequence to a KEY_XXX constant.
|
* sequence to a KEY_XXX constant.
|
||||||
|
*
|
||||||
|
* Note that the values are exposed to iPXE commands via parse_key()
|
||||||
|
* and therefore may not be changed without breaking existing scripts.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define KEY_ANSI( n, terminator ) ( 0x100 * ( (n) + 1 ) + (terminator) )
|
/**
|
||||||
#define KEY_ANSI_N( key ) ( ( (key) / 0x100 ) - 1 )
|
* Minimum value for special keypresses
|
||||||
|
*
|
||||||
|
* This value is chosen to lie above the maximum Unicode code point
|
||||||
|
* value 0x10ffff.
|
||||||
|
*/
|
||||||
|
#define KEY_MIN 0x110000
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct relative key value for special key
|
||||||
|
*
|
||||||
|
* @v key Key value
|
||||||
|
* @ret rkey Relative key value
|
||||||
|
*/
|
||||||
|
#define KEY_REL( key ) ( (key) - KEY_MIN )
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct ANSI escape sequence key value
|
||||||
|
*
|
||||||
|
* @v n ANSI escape sequence numeric portion, or 0 for none
|
||||||
|
* @v terminator ANSI escape sequence terminating character
|
||||||
|
* @ret key Key value
|
||||||
|
*/
|
||||||
|
#define KEY_ANSI( n, terminator ) \
|
||||||
|
( KEY_MIN + ( ( (n) + 1 ) << 8 ) + (terminator) )
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract ANSI escape sequence numeric portion
|
||||||
|
*
|
||||||
|
* @v key Key value (or relative key value)
|
||||||
|
* @ret n ANSI escape sequence numeric portion, or 0 for none
|
||||||
|
*/
|
||||||
|
#define KEY_ANSI_N( key ) ( ( ( (key) >> 8 ) & 0xff ) - 1 )
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract ANSI escape sequence terminating character
|
||||||
|
*
|
||||||
|
* @v key Key value (or relative key value)
|
||||||
|
* @ret terminator ANSI escape sequence terminating character
|
||||||
|
*/
|
||||||
#define KEY_ANSI_TERMINATOR( key ) ( (key) & 0xff )
|
#define KEY_ANSI_TERMINATOR( key ) ( (key) & 0xff )
|
||||||
|
|
||||||
#define KEY_MIN 0x101
|
|
||||||
#define KEY_UP KEY_ANSI ( 0, 'A' ) /**< Up arrow */
|
#define KEY_UP KEY_ANSI ( 0, 'A' ) /**< Up arrow */
|
||||||
#define KEY_DOWN KEY_ANSI ( 0, 'B' ) /**< Down arrow */
|
#define KEY_DOWN KEY_ANSI ( 0, 'B' ) /**< Down arrow */
|
||||||
#define KEY_RIGHT KEY_ANSI ( 0, 'C' ) /**< Right arrow */
|
#define KEY_RIGHT KEY_ANSI ( 0, 'C' ) /**< Right arrow */
|
||||||
|
|||||||
+202
-270
@@ -37,82 +37,73 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** A driver veto */
|
/** A driver veto candidate */
|
||||||
struct efi_veto {
|
struct efi_veto_candidate {
|
||||||
/** Veto name (for debugging) */
|
/** Veto name (for debugging) */
|
||||||
const char *name;
|
const char *name;
|
||||||
/**
|
/**
|
||||||
* Check if driver is vetoed
|
* Check if driver is vetoed
|
||||||
*
|
*
|
||||||
|
* @v binding Driver binding protocol
|
||||||
|
* @v loaded Loaded image protocol
|
||||||
|
* @v wtf Component name protocol, if present
|
||||||
* @v manufacturer Manufacturer name, if present
|
* @v manufacturer Manufacturer name, if present
|
||||||
* @v name Driver name (in "eng" language), if present
|
* @v name Driver name (in "eng" language), if present
|
||||||
* @ret vetoed Driver is to be vetoed
|
* @ret vetoed Driver is to be vetoed
|
||||||
*/
|
*/
|
||||||
int ( * veto ) ( const char *manufacturer, const CHAR16 *name );
|
int ( * veto ) ( EFI_DRIVER_BINDING_PROTOCOL *binding,
|
||||||
|
EFI_LOADED_IMAGE_PROTOCOL *loaded,
|
||||||
|
EFI_COMPONENT_NAME_PROTOCOL *wtf,
|
||||||
|
const char *manufacturer, const CHAR16 *name );
|
||||||
|
};
|
||||||
|
|
||||||
|
/** A driver veto */
|
||||||
|
struct efi_veto {
|
||||||
|
/** Driver binding handle */
|
||||||
|
EFI_HANDLE driver;
|
||||||
|
/** Driving binding protocol */
|
||||||
|
EFI_DRIVER_BINDING_PROTOCOL *binding;
|
||||||
|
/** Image handle */
|
||||||
|
EFI_HANDLE image;
|
||||||
|
/** Loaded image protocol */
|
||||||
|
EFI_LOADED_IMAGE_PROTOCOL *loaded;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unload an EFI driver
|
* Unload an EFI driver
|
||||||
*
|
*
|
||||||
* @v driver Driver binding handle
|
* @v veto Driver veto
|
||||||
* @v image Image handle to fill in on failure
|
|
||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
static int efi_veto_unload ( EFI_HANDLE driver, EFI_HANDLE *image ) {
|
static int efi_veto_unload ( struct efi_veto *veto ) {
|
||||||
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
||||||
union {
|
EFI_HANDLE driver = veto->driver;
|
||||||
EFI_DRIVER_BINDING_PROTOCOL *binding;
|
EFI_HANDLE image = veto->image;
|
||||||
void *interface;
|
|
||||||
} binding;
|
|
||||||
EFI_STATUS efirc;
|
EFI_STATUS efirc;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
/* Clear image handle */
|
|
||||||
*image = NULL;
|
|
||||||
|
|
||||||
/* Open driver binding protocol */
|
|
||||||
if ( ( efirc = bs->OpenProtocol (
|
|
||||||
driver, &efi_driver_binding_protocol_guid,
|
|
||||||
&binding.interface, efi_image_handle, driver,
|
|
||||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) {
|
|
||||||
rc = -EEFI ( efirc );
|
|
||||||
DBGC ( driver, "EFIVETO %s could not open driver binding "
|
|
||||||
"protocol: %s\n", efi_handle_name ( driver ),
|
|
||||||
strerror ( rc ) );
|
|
||||||
goto err_binding;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Identify image handle */
|
|
||||||
*image = binding.binding->ImageHandle;
|
|
||||||
|
|
||||||
/* Unload the driver */
|
/* Unload the driver */
|
||||||
if ( ( efirc = bs->UnloadImage ( *image ) ) != 0 ) {
|
if ( ( efirc = bs->UnloadImage ( image ) ) != 0 ) {
|
||||||
rc = -EEFI ( efirc );
|
rc = -EEFI ( efirc );
|
||||||
DBGC ( driver, "EFIVETO %s could not unload",
|
DBGC ( driver, "EFIVETO %s could not unload",
|
||||||
efi_handle_name ( driver ) );
|
efi_handle_name ( driver ) );
|
||||||
DBGC ( driver, " %s: %s\n",
|
DBGC ( driver, " %s: %s\n", efi_handle_name ( image ),
|
||||||
efi_handle_name ( *image ), strerror ( rc ) );
|
strerror ( rc ) );
|
||||||
goto err_unload;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Invalidate now-unloaded image handle */
|
return 0;
|
||||||
*image = NULL;
|
|
||||||
|
|
||||||
err_unload:
|
|
||||||
bs->CloseProtocol ( driver, &efi_driver_binding_protocol_guid,
|
|
||||||
efi_image_handle, driver );
|
|
||||||
err_binding:
|
|
||||||
return rc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disconnect an EFI driver from all handles
|
* Disconnect an EFI driver from all handles
|
||||||
*
|
*
|
||||||
* @v driver Driver binding handle
|
* @v veto Driver veto
|
||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
static int efi_veto_disconnect ( EFI_HANDLE driver ) {
|
static int efi_veto_disconnect ( struct efi_veto *veto ) {
|
||||||
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
||||||
|
EFI_HANDLE driver = veto->driver;
|
||||||
EFI_HANDLE *handles;
|
EFI_HANDLE *handles;
|
||||||
EFI_HANDLE handle;
|
EFI_HANDLE handle;
|
||||||
UINTN count;
|
UINTN count;
|
||||||
@@ -155,79 +146,66 @@ static int efi_veto_disconnect ( EFI_HANDLE driver ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uninstall an EFI protocol
|
* Uninstall an EFI driver binding protocol
|
||||||
*
|
*
|
||||||
* @v agent Agent handle
|
* @v veto Driver veto
|
||||||
* @v loaded Loaded image protocol filter, or NULL
|
|
||||||
* @v handle Potentially opened handle
|
|
||||||
* @v protocol Installed protocol
|
|
||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
static int efi_veto_uninstall ( EFI_HANDLE agent,
|
static int efi_veto_uninstall ( struct efi_veto *veto ) {
|
||||||
EFI_LOADED_IMAGE_PROTOCOL *loaded,
|
|
||||||
EFI_HANDLE handle, EFI_GUID *protocol ) {
|
|
||||||
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
||||||
void *interface;
|
EFI_HANDLE driver = veto->driver;
|
||||||
void *method;
|
union {
|
||||||
size_t offset;
|
EFI_DRIVER_BINDING_PROTOCOL *binding;
|
||||||
|
void *interface;
|
||||||
|
} binding;
|
||||||
EFI_STATUS efirc;
|
EFI_STATUS efirc;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
/* Open protocol */
|
/* Open driver binding protocol */
|
||||||
if ( ( efirc = bs->OpenProtocol (
|
if ( ( efirc = bs->OpenProtocol (
|
||||||
handle, protocol, &interface, efi_image_handle, agent,
|
driver, &efi_driver_binding_protocol_guid,
|
||||||
|
&binding.interface, efi_image_handle, driver,
|
||||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) {
|
EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) {
|
||||||
rc = -EEFI ( efirc );
|
rc = -EEFI ( efirc );
|
||||||
DBGC ( agent, "EFIVETO %s could not open %s",
|
DBGC ( driver, "EFIVETO %s could not open driver binding "
|
||||||
efi_handle_name ( agent ), efi_guid_ntoa ( protocol ) );
|
"protocol: %s\n", efi_handle_name ( driver ),
|
||||||
DBGC ( agent, " on %s: %s\n",
|
strerror ( rc ) );
|
||||||
efi_handle_name ( handle ), strerror ( rc ) );
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get representative method pointer, if known */
|
/* Close driver binding protocol */
|
||||||
method = efi_veto_method ( protocol, interface );
|
bs->CloseProtocol ( driver, &efi_driver_binding_protocol_guid,
|
||||||
|
efi_image_handle, driver );
|
||||||
|
|
||||||
/* Close protocol */
|
/* Uninstall driver binding protocol */
|
||||||
bs->CloseProtocol ( handle, protocol, efi_image_handle, agent );
|
|
||||||
|
|
||||||
/* Do nothing if method does not match filter */
|
|
||||||
if ( loaded ) {
|
|
||||||
offset = ( method - loaded->ImageBase );
|
|
||||||
if ( offset > loaded->ImageSize )
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Print debug message before potential invalidation of handle */
|
|
||||||
DBGC2 ( agent, "EFIVETO %s uninstalling %s",
|
|
||||||
efi_handle_name ( agent ), efi_guid_ntoa ( protocol ) );
|
|
||||||
DBGC2 ( agent, " from %s\n", efi_handle_name ( handle ) );
|
|
||||||
|
|
||||||
/* Uninstall protocol */
|
|
||||||
if ( ( efirc = bs->UninstallMultipleProtocolInterfaces (
|
if ( ( efirc = bs->UninstallMultipleProtocolInterfaces (
|
||||||
handle, protocol, interface, NULL ) ) != 0 ) {
|
driver, &efi_driver_binding_protocol_guid,
|
||||||
|
binding.binding, NULL ) ) != 0 ) {
|
||||||
rc = -EEFI ( efirc );
|
rc = -EEFI ( efirc );
|
||||||
DBGC ( agent, "EFIVETO %s could not uninstall %s",
|
DBGC ( driver, "EFIVETO %s could not uninstall driver "
|
||||||
efi_handle_name ( agent ), efi_guid_ntoa ( protocol ) );
|
"binding protocol: %s\n",
|
||||||
DBGC ( agent, " from %s: %s\n",
|
efi_handle_name ( driver ), strerror ( rc ) );
|
||||||
efi_handle_name ( handle ), strerror ( rc ) );
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DBGC2 ( driver, "EFIVETO %s uninstalled driver binding protocol\n",
|
||||||
|
efi_handle_name ( driver ) );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Close protocol on handle potentially opened by an EFI driver
|
* Close protocol on handle potentially opened by an EFI driver
|
||||||
*
|
*
|
||||||
* @v agent Agent handle
|
* @v veto Driver veto
|
||||||
* @v handle Potentially opened handle
|
* @v handle Potentially opened handle
|
||||||
* @v protocol Opened protocol
|
* @v protocol Opened protocol
|
||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
static int efi_veto_close ( EFI_HANDLE agent, EFI_HANDLE handle,
|
static int efi_veto_close_protocol ( struct efi_veto *veto, EFI_HANDLE handle,
|
||||||
EFI_GUID *protocol ) {
|
EFI_GUID *protocol ) {
|
||||||
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
||||||
|
EFI_HANDLE driver = veto->driver;
|
||||||
|
EFI_HANDLE image = veto->image;
|
||||||
EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *openers;
|
EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *openers;
|
||||||
EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *opener;
|
EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *opener;
|
||||||
EFI_HANDLE controller;
|
EFI_HANDLE controller;
|
||||||
@@ -240,9 +218,9 @@ static int efi_veto_close ( EFI_HANDLE agent, EFI_HANDLE handle,
|
|||||||
if ( ( efirc = bs->OpenProtocolInformation ( handle, protocol, &openers,
|
if ( ( efirc = bs->OpenProtocolInformation ( handle, protocol, &openers,
|
||||||
&count ) ) != 0 ) {
|
&count ) ) != 0 ) {
|
||||||
rc = -EEFI ( efirc );
|
rc = -EEFI ( efirc );
|
||||||
DBGC ( agent, "EFIVETO %s could not retrieve openers",
|
DBGC ( driver, "EFIVETO %s could not retrieve openers",
|
||||||
efi_handle_name ( agent ) );
|
efi_handle_name ( driver ) );
|
||||||
DBGC ( agent, " of %s %s: %s", efi_handle_name ( handle ),
|
DBGC ( driver, " of %s %s: %s", efi_handle_name ( handle ),
|
||||||
efi_guid_ntoa ( protocol ), strerror ( rc ) );
|
efi_guid_ntoa ( protocol ), strerror ( rc ) );
|
||||||
goto err_list;
|
goto err_list;
|
||||||
}
|
}
|
||||||
@@ -250,18 +228,19 @@ static int efi_veto_close ( EFI_HANDLE agent, EFI_HANDLE handle,
|
|||||||
/* Close anything opened by this driver */
|
/* Close anything opened by this driver */
|
||||||
for ( i = 0 ; i < count ; i++ ) {
|
for ( i = 0 ; i < count ; i++ ) {
|
||||||
opener = &openers[ count - i - 1 ];
|
opener = &openers[ count - i - 1 ];
|
||||||
if ( opener->AgentHandle != agent )
|
if ( ( opener->AgentHandle != driver ) &&
|
||||||
|
( opener->AgentHandle != image ) ) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
controller = opener->ControllerHandle;
|
controller = opener->ControllerHandle;
|
||||||
DBGC_EFI_OPENER ( agent, handle, protocol, opener );
|
DBGC_EFI_OPENER ( driver, handle, protocol, opener );
|
||||||
if ( ( efirc = bs->CloseProtocol ( handle, protocol, agent,
|
if ( ( efirc = bs->CloseProtocol ( handle, protocol, driver,
|
||||||
controller ) ) != 0 ) {
|
controller ) ) != 0 ) {
|
||||||
rc = -EEFI ( efirc );
|
rc = -EEFI ( efirc );
|
||||||
DBGC ( agent, "EFIVETO %s could not close stray open",
|
DBGC ( driver, "EFIVETO %s could not close stray open",
|
||||||
efi_handle_name ( agent ) );
|
efi_handle_name ( driver ) );
|
||||||
DBGC ( agent, " of %s %s: %s\n",
|
DBGC ( driver, " of %s: %s\n",
|
||||||
efi_handle_name ( handle ),
|
efi_handle_name ( handle ), strerror ( rc ) );
|
||||||
efi_guid_ntoa ( protocol ), strerror ( rc ) );
|
|
||||||
goto err_close;
|
goto err_close;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -276,17 +255,15 @@ static int efi_veto_close ( EFI_HANDLE agent, EFI_HANDLE handle,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Close/uninstall handle potentially used by an EFI driver
|
* Close handle potentially opened by an EFI driver
|
||||||
*
|
*
|
||||||
* @v agent Agent handle
|
* @v veto Driver veto
|
||||||
* @v loaded Loaded image protocol for uninstallation, or NULL
|
|
||||||
* @v handle Potentially opened handle
|
* @v handle Potentially opened handle
|
||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
static int efi_veto_handle ( EFI_HANDLE agent,
|
static int efi_veto_close_handle ( struct efi_veto *veto, EFI_HANDLE handle ) {
|
||||||
EFI_LOADED_IMAGE_PROTOCOL *loaded,
|
|
||||||
EFI_HANDLE handle ) {
|
|
||||||
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
||||||
|
EFI_HANDLE driver = veto->driver;
|
||||||
EFI_GUID **protocols;
|
EFI_GUID **protocols;
|
||||||
EFI_GUID *protocol;
|
EFI_GUID *protocol;
|
||||||
UINTN count;
|
UINTN count;
|
||||||
@@ -298,9 +275,9 @@ static int efi_veto_handle ( EFI_HANDLE agent,
|
|||||||
if ( ( efirc = bs->ProtocolsPerHandle ( handle, &protocols,
|
if ( ( efirc = bs->ProtocolsPerHandle ( handle, &protocols,
|
||||||
&count ) ) != 0 ) {
|
&count ) ) != 0 ) {
|
||||||
rc = -EEFI ( efirc );
|
rc = -EEFI ( efirc );
|
||||||
DBGC ( agent, "EFIVETO %s could not retrieve protocols",
|
DBGC ( driver, "EFIVETO %s could not retrieve protocols",
|
||||||
efi_handle_name ( agent ) );
|
efi_handle_name ( driver ) );
|
||||||
DBGC ( agent, " for %s: %s\n",
|
DBGC ( driver, " for %s: %s\n",
|
||||||
efi_handle_name ( handle ), strerror ( rc ) );
|
efi_handle_name ( handle ), strerror ( rc ) );
|
||||||
goto err_list;
|
goto err_list;
|
||||||
}
|
}
|
||||||
@@ -308,24 +285,14 @@ static int efi_veto_handle ( EFI_HANDLE agent,
|
|||||||
/* Close each protocol */
|
/* Close each protocol */
|
||||||
for ( i = 0 ; i < count ; i++ ) {
|
for ( i = 0 ; i < count ; i++ ) {
|
||||||
protocol = protocols[ count - i - 1];
|
protocol = protocols[ count - i - 1];
|
||||||
if ( ( rc = efi_veto_close ( agent, handle, protocol ) ) != 0 )
|
if ( ( rc = efi_veto_close_protocol ( veto, handle,
|
||||||
|
protocol ) ) != 0 )
|
||||||
goto err_close;
|
goto err_close;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Uninstall each protocol, if applicable */
|
|
||||||
if ( loaded ) {
|
|
||||||
for ( i = 0 ; i < count ; i++ ) {
|
|
||||||
protocol = protocols[ count - i - 1];
|
|
||||||
if ( ( rc = efi_veto_uninstall ( agent, loaded, handle,
|
|
||||||
protocol ) ) != 0 )
|
|
||||||
goto err_uninstall;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Success */
|
/* Success */
|
||||||
rc = 0;
|
rc = 0;
|
||||||
|
|
||||||
err_uninstall:
|
|
||||||
err_close:
|
err_close:
|
||||||
bs->FreePool ( protocols );
|
bs->FreePool ( protocols );
|
||||||
err_list:
|
err_list:
|
||||||
@@ -333,15 +300,14 @@ static int efi_veto_handle ( EFI_HANDLE agent,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Close/uninstall all remaining handles used by an EFI driver
|
* Close all remaining handles opened by an EFI driver
|
||||||
*
|
*
|
||||||
* @v agent Agent handle
|
* @v veto Driver veto
|
||||||
* @v loaded Loaded image protocol for uninstallation, or NULL
|
|
||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
static int efi_veto_handles ( EFI_HANDLE agent,
|
static int efi_veto_close ( struct efi_veto *veto ) {
|
||||||
EFI_LOADED_IMAGE_PROTOCOL *loaded ) {
|
|
||||||
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
||||||
|
EFI_HANDLE driver = veto->driver;
|
||||||
EFI_HANDLE *handles;
|
EFI_HANDLE *handles;
|
||||||
EFI_HANDLE handle;
|
EFI_HANDLE handle;
|
||||||
UINTN count;
|
UINTN count;
|
||||||
@@ -353,25 +319,24 @@ static int efi_veto_handles ( EFI_HANDLE agent,
|
|||||||
if ( ( efirc = bs->LocateHandleBuffer ( AllHandles, NULL, NULL,
|
if ( ( efirc = bs->LocateHandleBuffer ( AllHandles, NULL, NULL,
|
||||||
&count, &handles ) ) != 0 ) {
|
&count, &handles ) ) != 0 ) {
|
||||||
rc = -EEFI ( efirc );
|
rc = -EEFI ( efirc );
|
||||||
DBGC ( agent, "EFIVETO %s could not enumerate handles: %s\n",
|
DBGC ( driver, "EFIVETO %s could not enumerate handles: %s\n",
|
||||||
efi_handle_name ( agent ), strerror ( rc ) );
|
efi_handle_name ( driver ), strerror ( rc ) );
|
||||||
goto err_list;
|
goto err_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Close and/or uninstall each handle */
|
/* Close each handle */
|
||||||
for ( i = 0 ; i < count ; i++ ) {
|
for ( i = 0 ; i < count ; i++ ) {
|
||||||
handle = handles[ count - i - 1 ];
|
handle = handles[ count - i - 1 ];
|
||||||
if ( ( rc = efi_veto_handle ( agent, loaded, handle ) ) != 0 )
|
if ( ( rc = efi_veto_close_handle ( veto, handle ) ) != 0 )
|
||||||
goto err_handle;
|
goto err_close;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Success */
|
/* Success */
|
||||||
rc = 0;
|
rc = 0;
|
||||||
DBGC2 ( agent, "EFIVETO %s closed%s all remaining handles\n",
|
DBGC2 ( driver, "EFIVETO %s closed all remaining handles\n",
|
||||||
efi_handle_name ( agent ),
|
efi_handle_name ( driver ) );
|
||||||
( loaded ? " and uninstalled" : "" ) );
|
|
||||||
|
|
||||||
err_handle:
|
err_close:
|
||||||
bs->FreePool ( handles );
|
bs->FreePool ( handles );
|
||||||
err_list:
|
err_list:
|
||||||
return rc;
|
return rc;
|
||||||
@@ -380,103 +345,65 @@ static int efi_veto_handles ( EFI_HANDLE agent,
|
|||||||
/**
|
/**
|
||||||
* Terminate an EFI driver with extreme prejudice
|
* Terminate an EFI driver with extreme prejudice
|
||||||
*
|
*
|
||||||
* @v driver Driver handle
|
* @v veto Driver veto
|
||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
static int efi_veto_destroy ( EFI_HANDLE driver ) {
|
static int efi_veto_destroy ( struct efi_veto *veto ) {
|
||||||
EFI_GUID *binding = &efi_driver_binding_protocol_guid;
|
EFI_HANDLE driver = veto->driver;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
/* Disconnect driver from all handles */
|
/* Disconnect driver from all handles */
|
||||||
if ( ( rc = efi_veto_disconnect ( driver ) ) != 0 )
|
if ( ( rc = efi_veto_disconnect ( veto ) ) != 0 )
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
/* Uninstall driver binding protocol */
|
/* Uninstall driver binding protocol */
|
||||||
if ( ( rc = efi_veto_uninstall ( driver, NULL, driver,
|
if ( ( rc = efi_veto_uninstall ( veto ) ) != 0 )
|
||||||
binding ) ) != 0 )
|
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
/* Close any remaining opened handles */
|
/* Close any remaining opened handles */
|
||||||
if ( ( rc = efi_veto_handles ( driver, NULL ) ) != 0 )
|
if ( ( rc = efi_veto_close ( veto ) ) != 0 )
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
DBGC ( driver, "EFIVETO %s forcibly removed driver\n",
|
DBGC ( driver, "EFIVETO %s forcibly removed\n",
|
||||||
efi_handle_name ( driver ) );
|
efi_handle_name ( driver ) );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Veto an EFI driver handle
|
* Veto an EFI driver
|
||||||
*
|
*
|
||||||
* @v driver Driver handle
|
* @v veto Driver veto
|
||||||
* @ret image Image handle, if still present after veto attempt
|
|
||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
static int efi_veto_driver ( EFI_HANDLE driver, EFI_HANDLE *image ) {
|
static int efi_veto_driver ( struct efi_veto *veto ) {
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
/* Try gracefully unloading the underlying image */
|
/* Try gracefully unloading the driver */
|
||||||
if ( ( rc = efi_veto_unload ( driver, image ) ) == 0 )
|
if ( ( rc = efi_veto_unload ( veto ) ) == 0 )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* If that fails, use a hammer */
|
/* If that fails, use a hammer */
|
||||||
if ( ( rc = efi_veto_destroy ( driver ) ) == 0 )
|
if ( ( rc = efi_veto_destroy ( veto ) ) == 0 )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
DBGC ( driver, "EFIVETO %s could not veto driver: %s\n",
|
|
||||||
efi_handle_name ( driver ), strerror ( rc ) );
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Veto an EFI image handle
|
|
||||||
*
|
|
||||||
* @v image Image handle
|
|
||||||
* @ret rc Return status code
|
|
||||||
*/
|
|
||||||
static int efi_veto_image ( EFI_HANDLE image ) {
|
|
||||||
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
|
||||||
union {
|
|
||||||
EFI_LOADED_IMAGE_PROTOCOL *loaded;
|
|
||||||
void *interface;
|
|
||||||
} loaded;
|
|
||||||
EFI_STATUS efirc;
|
|
||||||
int rc;
|
|
||||||
|
|
||||||
/* Open loaded image protocol */
|
|
||||||
if ( ( efirc = bs->OpenProtocol (
|
|
||||||
image, &efi_loaded_image_protocol_guid,
|
|
||||||
&loaded.interface, efi_image_handle, image,
|
|
||||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) {
|
|
||||||
rc = -EEFI ( efirc );
|
|
||||||
DBGC ( image, "EFIVETO %s could not open loaded image "
|
|
||||||
"protocol: %s\n", efi_handle_name ( image ),
|
|
||||||
strerror ( rc ) );
|
|
||||||
goto err_loaded;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Close and uninstall any remaining handles */
|
|
||||||
if ( ( rc = efi_veto_handles ( image, loaded.loaded ) ) != 0 )
|
|
||||||
return rc;
|
|
||||||
|
|
||||||
DBGC ( image, "EFIVETO %s forcibly removed image\n",
|
|
||||||
efi_handle_name ( image ) );
|
|
||||||
|
|
||||||
bs->CloseProtocol ( image, &efi_loaded_image_protocol_guid,
|
|
||||||
efi_image_handle, image );
|
|
||||||
err_loaded:
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Veto Ip4ConfigDxe driver on some platforms
|
* Veto Ip4ConfigDxe driver on some platforms
|
||||||
*
|
*
|
||||||
|
* @v binding Driver binding protocol
|
||||||
|
* @v loaded Loaded image protocol
|
||||||
|
* @v wtf Component name protocol, if present
|
||||||
* @v manufacturer Manufacturer name, if present
|
* @v manufacturer Manufacturer name, if present
|
||||||
* @v name Driver name, if present
|
* @v name Driver name, if present
|
||||||
* @ret vetoed Driver is to be vetoed
|
* @ret vetoed Driver is to be vetoed
|
||||||
*/
|
*/
|
||||||
static int efi_veto_ip4config ( const char *manufacturer,
|
static int
|
||||||
const CHAR16 *name ) {
|
efi_veto_ip4config ( EFI_DRIVER_BINDING_PROTOCOL *binding __unused,
|
||||||
|
EFI_LOADED_IMAGE_PROTOCOL *loaded __unused,
|
||||||
|
EFI_COMPONENT_NAME_PROTOCOL *wtf __unused,
|
||||||
|
const char *manufacturer, const CHAR16 *name ) {
|
||||||
static const CHAR16 ip4cfg[] = L"IP4 CONFIG Network Service Driver";
|
static const CHAR16 ip4cfg[] = L"IP4 CONFIG Network Service Driver";
|
||||||
static const char *dell = "Dell Inc.";
|
static const char *dell = "Dell Inc.";
|
||||||
static const char *itautec = "Itautec S.A.";
|
static const char *itautec = "Itautec S.A.";
|
||||||
@@ -498,11 +425,18 @@ static int efi_veto_ip4config ( const char *manufacturer,
|
|||||||
/**
|
/**
|
||||||
* Veto HP XhciDxe driver
|
* Veto HP XhciDxe driver
|
||||||
*
|
*
|
||||||
|
* @v binding Driver binding protocol
|
||||||
|
* @v loaded Loaded image protocol
|
||||||
|
* @v wtf Component name protocol, if present
|
||||||
* @v manufacturer Manufacturer name, if present
|
* @v manufacturer Manufacturer name, if present
|
||||||
* @v name Driver name, if present
|
* @v name Driver name, if present
|
||||||
* @ret vetoed Driver is to be vetoed
|
* @ret vetoed Driver is to be vetoed
|
||||||
*/
|
*/
|
||||||
static int efi_veto_hp_xhci ( const char *manufacturer, const CHAR16 *name ) {
|
static int
|
||||||
|
efi_veto_hp_xhci ( EFI_DRIVER_BINDING_PROTOCOL *binding __unused,
|
||||||
|
EFI_LOADED_IMAGE_PROTOCOL *loaded __unused,
|
||||||
|
EFI_COMPONENT_NAME_PROTOCOL *wtf __unused,
|
||||||
|
const char *manufacturer, const CHAR16 *name ) {
|
||||||
static const CHAR16 xhci[] = L"Usb Xhci Driver";
|
static const CHAR16 xhci[] = L"Usb Xhci Driver";
|
||||||
static const char *hp = "HP";
|
static const char *hp = "HP";
|
||||||
struct pci_driver *driver;
|
struct pci_driver *driver;
|
||||||
@@ -533,13 +467,17 @@ static int efi_veto_hp_xhci ( const char *manufacturer, const CHAR16 *name ) {
|
|||||||
* Veto VMware UefiPxeBcDxe driver
|
* Veto VMware UefiPxeBcDxe driver
|
||||||
*
|
*
|
||||||
* @v binding Driver binding protocol
|
* @v binding Driver binding protocol
|
||||||
|
* @v loaded Loaded image protocol
|
||||||
* @v wtf Component name protocol, if present
|
* @v wtf Component name protocol, if present
|
||||||
* @v manufacturer Manufacturer name, if present
|
* @v manufacturer Manufacturer name, if present
|
||||||
* @v name Driver name, if present
|
* @v name Driver name, if present
|
||||||
* @ret vetoed Driver is to be vetoed
|
* @ret vetoed Driver is to be vetoed
|
||||||
*/
|
*/
|
||||||
static int efi_veto_vmware_uefipxebc ( const char *manufacturer,
|
static int
|
||||||
const CHAR16 *name ) {
|
efi_veto_vmware_uefipxebc ( EFI_DRIVER_BINDING_PROTOCOL *binding __unused,
|
||||||
|
EFI_LOADED_IMAGE_PROTOCOL *loaded __unused,
|
||||||
|
EFI_COMPONENT_NAME_PROTOCOL *wtf __unused,
|
||||||
|
const char *manufacturer, const CHAR16 *name ) {
|
||||||
static const CHAR16 uefipxebc[] = L"UEFI PXE Base Code Driver";
|
static const CHAR16 uefipxebc[] = L"UEFI PXE Base Code Driver";
|
||||||
static const char *vmware = "VMware, Inc.";
|
static const char *vmware = "VMware, Inc.";
|
||||||
|
|
||||||
@@ -556,33 +494,8 @@ static int efi_veto_vmware_uefipxebc ( const char *manufacturer,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Veto VirtualBox E1kNetDxe driver
|
|
||||||
*
|
|
||||||
* @v manufacturer Manufacturer name, if present
|
|
||||||
* @v name Driver name, if present
|
|
||||||
* @ret vetoed Driver is to be vetoed
|
|
||||||
*/
|
|
||||||
static int efi_veto_vbox_e1knet ( const char *manufacturer,
|
|
||||||
const CHAR16 *name ) {
|
|
||||||
static const CHAR16 e1knet[] = L"E1000 network interface card Driver";
|
|
||||||
static const char *vbox = "innotek GmbH";
|
|
||||||
|
|
||||||
/* Check manufacturer and driver name */
|
|
||||||
if ( ! manufacturer )
|
|
||||||
return 0;
|
|
||||||
if ( ! name )
|
|
||||||
return 0;
|
|
||||||
if ( strcmp ( manufacturer, vbox ) != 0 )
|
|
||||||
return 0;
|
|
||||||
if ( memcmp ( name, e1knet, sizeof ( e1knet ) ) != 0 )
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Driver vetoes */
|
/** Driver vetoes */
|
||||||
static struct efi_veto efi_vetoes[] = {
|
static struct efi_veto_candidate efi_vetoes[] = {
|
||||||
{
|
{
|
||||||
.name = "Ip4Config",
|
.name = "Ip4Config",
|
||||||
.veto = efi_veto_ip4config,
|
.veto = efi_veto_ip4config,
|
||||||
@@ -595,10 +508,6 @@ static struct efi_veto efi_vetoes[] = {
|
|||||||
.name = "VMware UefiPxeBc",
|
.name = "VMware UefiPxeBc",
|
||||||
.veto = efi_veto_vmware_uefipxebc,
|
.veto = efi_veto_vmware_uefipxebc,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
.name = "VirtualBox E1kNetDxe",
|
|
||||||
.veto = efi_veto_vbox_e1knet,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -610,21 +519,57 @@ static struct efi_veto efi_vetoes[] = {
|
|||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
static int efi_veto_find ( EFI_HANDLE driver, const char *manufacturer,
|
static int efi_veto_find ( EFI_HANDLE driver, const char *manufacturer,
|
||||||
struct efi_veto **veto ) {
|
struct efi_veto *veto ) {
|
||||||
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
||||||
|
union {
|
||||||
|
EFI_DRIVER_BINDING_PROTOCOL *binding;
|
||||||
|
void *interface;
|
||||||
|
} binding;
|
||||||
|
union {
|
||||||
|
EFI_LOADED_IMAGE_PROTOCOL *loaded;
|
||||||
|
void *interface;
|
||||||
|
} loaded;
|
||||||
union {
|
union {
|
||||||
EFI_COMPONENT_NAME_PROTOCOL *wtf;
|
EFI_COMPONENT_NAME_PROTOCOL *wtf;
|
||||||
void *interface;
|
void *interface;
|
||||||
} wtf;
|
} wtf;
|
||||||
CHAR16 *name;
|
CHAR16 *name;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
EFI_HANDLE image;
|
||||||
EFI_STATUS efirc;
|
EFI_STATUS efirc;
|
||||||
|
int rc;
|
||||||
|
|
||||||
DBGC2 ( &efi_vetoes, "EFIVETO checking %s\n",
|
DBGC2 ( &efi_vetoes, "EFIVETO checking %s\n",
|
||||||
efi_handle_name ( driver ) );
|
efi_handle_name ( driver ) );
|
||||||
|
|
||||||
/* Mark as not vetoed */
|
/* Mark as not vetoed */
|
||||||
*veto = NULL;
|
memset ( veto, 0, sizeof ( *veto ) );
|
||||||
|
|
||||||
|
/* Open driver binding protocol */
|
||||||
|
if ( ( efirc = bs->OpenProtocol (
|
||||||
|
driver, &efi_driver_binding_protocol_guid,
|
||||||
|
&binding.interface, efi_image_handle, driver,
|
||||||
|
EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) {
|
||||||
|
rc = -EEFI ( efirc );
|
||||||
|
DBGC ( driver, "EFIVETO %s could not open driver binding "
|
||||||
|
"protocol: %s\n", efi_handle_name ( driver ),
|
||||||
|
strerror ( rc ) );
|
||||||
|
goto err_binding;
|
||||||
|
}
|
||||||
|
image = binding.binding->ImageHandle;
|
||||||
|
|
||||||
|
/* Open loaded image protocol */
|
||||||
|
if ( ( efirc = bs->OpenProtocol (
|
||||||
|
image, &efi_loaded_image_protocol_guid,
|
||||||
|
&loaded.interface, efi_image_handle, image,
|
||||||
|
EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) {
|
||||||
|
rc = -EEFI ( efirc );
|
||||||
|
DBGC ( driver, "EFIVETO %s could not open",
|
||||||
|
efi_handle_name ( driver ) );
|
||||||
|
DBGC ( driver, " %s loaded image protocol: %s\n",
|
||||||
|
efi_handle_name ( image ), strerror ( rc ) );
|
||||||
|
goto err_loaded;
|
||||||
|
}
|
||||||
|
|
||||||
/* Open component name protocol, if present*/
|
/* Open component name protocol, if present*/
|
||||||
if ( ( efirc = bs->OpenProtocol (
|
if ( ( efirc = bs->OpenProtocol (
|
||||||
@@ -648,25 +593,34 @@ static int efi_veto_find ( EFI_HANDLE driver, const char *manufacturer,
|
|||||||
/* Check vetoes */
|
/* Check vetoes */
|
||||||
for ( i = 0 ; i < ( sizeof ( efi_vetoes ) /
|
for ( i = 0 ; i < ( sizeof ( efi_vetoes ) /
|
||||||
sizeof ( efi_vetoes[0] ) ) ; i++ ) {
|
sizeof ( efi_vetoes[0] ) ) ; i++ ) {
|
||||||
|
if ( efi_vetoes[i].veto ( binding.binding, loaded.loaded,
|
||||||
/* Check if this veto applies */
|
wtf.wtf, manufacturer, name ) ) {
|
||||||
if ( ! efi_vetoes[i].veto ( manufacturer, name ) )
|
DBGC ( driver, "EFIVETO %s is vetoed (%s)\n",
|
||||||
continue;
|
efi_handle_name ( driver ),
|
||||||
|
efi_vetoes[i].name );
|
||||||
DBGC ( driver, "EFIVETO %s is vetoed (%s)\n",
|
veto->driver = driver;
|
||||||
efi_handle_name ( driver ), efi_vetoes[i].name );
|
veto->binding = binding.binding;
|
||||||
*veto = &efi_vetoes[i];
|
veto->image = image;
|
||||||
|
veto->loaded = loaded.loaded;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Success */
|
||||||
|
rc = 0;
|
||||||
|
|
||||||
/* Close protocols */
|
/* Close protocols */
|
||||||
if ( wtf.wtf ) {
|
if ( wtf.wtf ) {
|
||||||
bs->CloseProtocol ( driver, &efi_component_name_protocol_guid,
|
bs->CloseProtocol ( driver, &efi_component_name_protocol_guid,
|
||||||
efi_image_handle, driver );
|
efi_image_handle, driver );
|
||||||
}
|
}
|
||||||
|
bs->CloseProtocol ( image, &efi_loaded_image_protocol_guid,
|
||||||
return 0;
|
efi_image_handle, image );
|
||||||
|
err_loaded:
|
||||||
|
bs->CloseProtocol ( driver, &efi_driver_binding_protocol_guid,
|
||||||
|
efi_image_handle, driver );
|
||||||
|
err_binding:
|
||||||
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -675,10 +629,9 @@ static int efi_veto_find ( EFI_HANDLE driver, const char *manufacturer,
|
|||||||
*/
|
*/
|
||||||
void efi_veto ( void ) {
|
void efi_veto ( void ) {
|
||||||
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
||||||
struct efi_veto *veto;
|
struct efi_veto veto;
|
||||||
EFI_HANDLE *targets;
|
EFI_HANDLE *drivers;
|
||||||
EFI_HANDLE driver;
|
EFI_HANDLE driver;
|
||||||
EFI_HANDLE image;
|
|
||||||
UINTN count;
|
UINTN count;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
char *manufacturer;
|
char *manufacturer;
|
||||||
@@ -688,7 +641,7 @@ void efi_veto ( void ) {
|
|||||||
/* Locate all driver binding protocol handles */
|
/* Locate all driver binding protocol handles */
|
||||||
if ( ( efirc = bs->LocateHandleBuffer (
|
if ( ( efirc = bs->LocateHandleBuffer (
|
||||||
ByProtocol, &efi_driver_binding_protocol_guid,
|
ByProtocol, &efi_driver_binding_protocol_guid,
|
||||||
NULL, &count, &targets ) ) != 0 ) {
|
NULL, &count, &drivers ) ) != 0 ) {
|
||||||
rc = -EEFI ( efirc );
|
rc = -EEFI ( efirc );
|
||||||
DBGC ( &efi_vetoes, "EFIVETO could not list all drivers: "
|
DBGC ( &efi_vetoes, "EFIVETO could not list all drivers: "
|
||||||
"%s\n", strerror ( rc ) );
|
"%s\n", strerror ( rc ) );
|
||||||
@@ -700,14 +653,9 @@ void efi_veto ( void ) {
|
|||||||
&manufacturer );
|
&manufacturer );
|
||||||
DBGC ( &efi_vetoes, "EFIVETO manufacturer is \"%s\"\n", manufacturer );
|
DBGC ( &efi_vetoes, "EFIVETO manufacturer is \"%s\"\n", manufacturer );
|
||||||
|
|
||||||
/* Identify any vetoed drivers and veto the driver handles */
|
/* Unload any vetoed drivers */
|
||||||
for ( i = 0 ; i < count ; i++ ) {
|
for ( i = 0 ; i < count ; i++ ) {
|
||||||
|
driver = drivers[ count - i - 1 ];
|
||||||
/* Consume driver handle from target list */
|
|
||||||
driver = targets[ count - i - 1 ];
|
|
||||||
targets[ count - i - 1 ] = NULL;
|
|
||||||
|
|
||||||
/* Check if this driver is vetoed */
|
|
||||||
if ( ( rc = efi_veto_find ( driver, manufacturer,
|
if ( ( rc = efi_veto_find ( driver, manufacturer,
|
||||||
&veto ) ) != 0 ) {
|
&veto ) ) != 0 ) {
|
||||||
DBGC ( driver, "EFIVETO %s could not determine "
|
DBGC ( driver, "EFIVETO %s could not determine "
|
||||||
@@ -715,33 +663,17 @@ void efi_veto ( void ) {
|
|||||||
efi_handle_name ( driver ), strerror ( rc ) );
|
efi_handle_name ( driver ), strerror ( rc ) );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ( ! veto )
|
if ( ! veto.driver )
|
||||||
continue;
|
|
||||||
|
|
||||||
/* Veto driver handle */
|
|
||||||
if ( ( rc = efi_veto_driver ( driver, &image ) ) != 0 )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
/* Record image handle (if still present) as a target */
|
|
||||||
targets[ count - i - 1 ] = image;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Veto any remaining image handles */
|
|
||||||
for ( i = 0 ; i < count ; i++ ) {
|
|
||||||
|
|
||||||
/* Consume image handle from target list */
|
|
||||||
image = targets[ count - i - 1 ];
|
|
||||||
if ( ! image )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
/* Veto image handle */
|
|
||||||
if ( ( rc = efi_veto_image ( image ) ) != 0 )
|
|
||||||
continue;
|
continue;
|
||||||
|
if ( ( rc = efi_veto_driver ( &veto ) ) != 0 ) {
|
||||||
|
DBGC ( driver, "EFIVETO %s could not veto: %s\n",
|
||||||
|
efi_handle_name ( driver ), strerror ( rc ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free manufacturer name */
|
/* Free manufacturer name */
|
||||||
free ( manufacturer );
|
free ( manufacturer );
|
||||||
|
|
||||||
/* Free handle list */
|
/* Free handle list */
|
||||||
bs->FreePool ( targets );
|
bs->FreePool ( drivers );
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-1
@@ -656,7 +656,7 @@ static void free_netdev ( struct refcnt *refcnt ) {
|
|||||||
struct net_device *netdev =
|
struct net_device *netdev =
|
||||||
container_of ( refcnt, struct net_device, refcnt );
|
container_of ( refcnt, struct net_device, refcnt );
|
||||||
|
|
||||||
stop_timer ( &netdev->link_block );
|
assert ( ! timer_running ( &netdev->link_block ) );
|
||||||
netdev_tx_flush ( netdev );
|
netdev_tx_flush ( netdev );
|
||||||
netdev_rx_flush ( netdev );
|
netdev_rx_flush ( netdev );
|
||||||
clear_settings ( netdev_settings ( netdev ) );
|
clear_settings ( netdev_settings ( netdev ) );
|
||||||
@@ -879,6 +879,9 @@ void netdev_close ( struct net_device *netdev ) {
|
|||||||
/* Close the device */
|
/* Close the device */
|
||||||
netdev->op->close ( netdev );
|
netdev->op->close ( netdev );
|
||||||
|
|
||||||
|
/* Stop link block timer */
|
||||||
|
stop_timer ( &netdev->link_block );
|
||||||
|
|
||||||
/* Flush TX and RX queues */
|
/* Flush TX and RX queues */
|
||||||
netdev_tx_flush ( netdev );
|
netdev_tx_flush ( netdev );
|
||||||
netdev_rx_flush ( netdev );
|
netdev_rx_flush ( netdev );
|
||||||
|
|||||||
+85
-26
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
set -u
|
set -u
|
||||||
|
set -x
|
||||||
|
|
||||||
# Print usage message
|
# Print usage message
|
||||||
#
|
#
|
||||||
@@ -17,28 +18,58 @@ help() {
|
|||||||
echo " -s SCRIPT use executable script"
|
echo " -s SCRIPT use executable script"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Get big-endian hex value from binary file
|
||||||
|
#
|
||||||
|
get_be() {
|
||||||
|
local FILENAME
|
||||||
|
local OFFSET
|
||||||
|
local LEN
|
||||||
|
|
||||||
|
FILENAME="${1}"
|
||||||
|
OFFSET="${2}"
|
||||||
|
LEN="${3}"
|
||||||
|
|
||||||
|
od -j "${OFFSET}" -N "${LEN}" -A n -t x1 -- "${FILENAME}" | tr -d " "
|
||||||
|
}
|
||||||
|
|
||||||
|
# Get little-endian hex value from binary file
|
||||||
|
#
|
||||||
|
get_le() {
|
||||||
|
local FILENAME
|
||||||
|
local OFFSET
|
||||||
|
local LEN
|
||||||
|
local BYTE
|
||||||
|
local VALUE
|
||||||
|
|
||||||
|
FILENAME="${1}"
|
||||||
|
OFFSET="${2}"
|
||||||
|
LEN="${3}"
|
||||||
|
|
||||||
|
VALUE=""
|
||||||
|
while [ "${LEN}" -gt 0 ] ; do
|
||||||
|
LEN=$(( "${LEN}" - 1 ))
|
||||||
|
BYTE=$(get_be "${FILENAME}" $(( "${OFFSET}" + "${LEN}" )) 1)
|
||||||
|
VALUE="${VALUE}${BYTE}"
|
||||||
|
done
|
||||||
|
echo "${VALUE}"
|
||||||
|
}
|
||||||
|
|
||||||
# Get hex byte from binary file
|
# Get hex byte from binary file
|
||||||
#
|
#
|
||||||
get_byte() {
|
get_byte() {
|
||||||
local FILENAME
|
get_be "${1}" "${2}" 1
|
||||||
local OFFSET
|
|
||||||
|
|
||||||
FILENAME="${1}"
|
|
||||||
OFFSET="${2}"
|
|
||||||
|
|
||||||
od -j "${OFFSET}" -N 1 -A n -t x1 -- "${FILENAME}" | tr -d " "
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Get hex word from binary file
|
# Get little-endian hex word from binary file
|
||||||
#
|
#
|
||||||
get_word() {
|
get_word() {
|
||||||
local FILENAME
|
get_le "${1}" "${2}" 2
|
||||||
local OFFSET
|
}
|
||||||
|
|
||||||
FILENAME="${1}"
|
# Get little-endian hex dword from binary file
|
||||||
OFFSET="${2}"
|
#
|
||||||
|
get_dword() {
|
||||||
od -j "${OFFSET}" -N 2 -A n -t x1 -- "${FILENAME}" | tr -d " "
|
get_le "${1}" "${2}" 4
|
||||||
}
|
}
|
||||||
|
|
||||||
# Get appropriate EFI boot filename for CPU architecture
|
# Get appropriate EFI boot filename for CPU architecture
|
||||||
@@ -51,31 +82,31 @@ efi_boot_name() {
|
|||||||
FILENAME="${1}"
|
FILENAME="${1}"
|
||||||
|
|
||||||
MZSIG=$(get_word "${FILENAME}" 0)
|
MZSIG=$(get_word "${FILENAME}" 0)
|
||||||
if [ "${MZSIG}" != "4d5a" ] ; then
|
if [ "${MZSIG}" != "5a4d" ] ; then
|
||||||
echo "${FILENAME}: invalid MZ header" >&2
|
echo "${FILENAME}: invalid MZ header" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
PEOFF=$(get_byte "${FILENAME}" 0x3c)
|
PEOFF=$(get_byte "${FILENAME}" 0x3c)
|
||||||
PESIG=$(get_word "${FILENAME}" 0x${PEOFF})
|
PESIG=$(get_word "${FILENAME}" 0x${PEOFF})
|
||||||
if [ "${PESIG}" != "5045" ] ; then
|
if [ "${PESIG}" != "4550" ] ; then
|
||||||
echo "${FILENAME}: invalid PE header" >&2
|
echo "${FILENAME}: invalid PE header" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
ARCH=$(get_word "${FILENAME}" $(( 0x${PEOFF} + 4 )) )
|
ARCH=$(get_word "${FILENAME}" $(( 0x${PEOFF} + 4 )) )
|
||||||
case "${ARCH}" in
|
case "${ARCH}" in
|
||||||
"4c01" )
|
"014c" )
|
||||||
echo "BOOTIA32.EFI"
|
echo "BOOTIA32.EFI"
|
||||||
;;
|
;;
|
||||||
"6486" )
|
"8664" )
|
||||||
echo "BOOTX64.EFI"
|
echo "BOOTX64.EFI"
|
||||||
;;
|
;;
|
||||||
"c201" )
|
"01c2" )
|
||||||
echo "BOOTARM.EFI"
|
echo "BOOTARM.EFI"
|
||||||
;;
|
;;
|
||||||
"6462" )
|
"6264" )
|
||||||
echo "BOOTLOONGARCH64.EFI"
|
echo "BOOTLOONGARCH64.EFI"
|
||||||
;;
|
;;
|
||||||
"64aa" )
|
"aa64" )
|
||||||
echo "BOOTAA64.EFI"
|
echo "BOOTAA64.EFI"
|
||||||
;;
|
;;
|
||||||
* )
|
* )
|
||||||
@@ -117,6 +148,28 @@ copy_syslinux_file() {
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Create EFI boot partition
|
||||||
|
#
|
||||||
|
create_esp() {
|
||||||
|
local FILENAME
|
||||||
|
local BOOTCAT
|
||||||
|
local PLATFORM
|
||||||
|
local START
|
||||||
|
local COUNT
|
||||||
|
|
||||||
|
FILENAME="${1}"
|
||||||
|
|
||||||
|
BOOTCAT=$(( 0x$(get_dword "${FILENAME}" 0x8847) * 0x800 ))
|
||||||
|
PLATFORM=$(get_byte "${FILENAME}" $(( ${BOOTCAT} + 0x01 )) )
|
||||||
|
if [ "${PLATFORM}" != "ef" ] ; then
|
||||||
|
echo "${FILENAME}: missing EFI boot catalog" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
START=$(( 0x$(get_dword "${FILENAME}" $(( ${BOOTCAT} + 0x28 )) ) * 4 ))
|
||||||
|
COUNT=$(( 0x$(get_word "${FILENAME}" $(( ${BOOTCAT} + 0x26 )) ) * 4 ))
|
||||||
|
echo "${START},${COUNT},0xef;" | sfdisk -f -w never "${FILENAME}"
|
||||||
|
}
|
||||||
|
|
||||||
# Parse command-line options
|
# Parse command-line options
|
||||||
#
|
#
|
||||||
OUTFILE=
|
OUTFILE=
|
||||||
@@ -234,12 +287,17 @@ done
|
|||||||
#
|
#
|
||||||
if [ -n "${ISOIMG}" ] ; then
|
if [ -n "${ISOIMG}" ] ; then
|
||||||
ISOARGS="-J -R -l"
|
ISOARGS="-J -R -l"
|
||||||
copy_syslinux_file "isolinux.bin" "${ISODIR}"
|
if [ -n "${LKRN}" ] ; then
|
||||||
copy_syslinux_file "ldlinux.c32" "${ISODIR}" 2>/dev/null || true
|
copy_syslinux_file "isolinux.bin" "${ISODIR}"
|
||||||
ISOARGS="${ISOARGS} -no-emul-boot -eltorito-boot isolinux.bin"
|
copy_syslinux_file "ldlinux.c32" "${ISODIR}" 2>/dev/null || true
|
||||||
ISOARGS="${ISOARGS} -boot-load-size 4 -boot-info-table"
|
ISOARGS="${ISOARGS} -no-emul-boot -eltorito-boot isolinux.bin"
|
||||||
|
ISOARGS="${ISOARGS} -boot-load-size 4 -boot-info-table"
|
||||||
|
fi
|
||||||
|
if [ -n "${LKRN}" -a -n "${EFI}" ] ; then
|
||||||
|
ISOARGS="${ISOARGS} -eltorito-alt-boot"
|
||||||
|
fi
|
||||||
if [ -n "${EFI}" ] ; then
|
if [ -n "${EFI}" ] ; then
|
||||||
ISOARGS="${ISOARGS} -eltorito-alt-boot -no-emul-boot -e esp.img"
|
ISOARGS="${ISOARGS} -no-emul-boot -e esp.img"
|
||||||
else
|
else
|
||||||
FATIMG=
|
FATIMG=
|
||||||
fi
|
fi
|
||||||
@@ -309,6 +367,7 @@ if [ -n "${ISOIMG}" ] ; then
|
|||||||
-appid "iPXE - Open Source Network Boot Firmware" \
|
-appid "iPXE - Open Source Network Boot Firmware" \
|
||||||
-publisher "ipxe.org" -sysid "iPXE" -o "${ISOIMG}" \
|
-publisher "ipxe.org" -sysid "iPXE" -o "${ISOIMG}" \
|
||||||
${ISOARGS} "${ISODIR}"
|
${ISOARGS} "${ISODIR}"
|
||||||
|
create_esp "${ISOIMG}"
|
||||||
if isohybrid --version >/dev/null 2>&1 ; then
|
if isohybrid --version >/dev/null 2>&1 ; then
|
||||||
ISOHYBRIDARGS=
|
ISOHYBRIDARGS=
|
||||||
if [ -n "${EFI}" ] ; then
|
if [ -n "${EFI}" ] ; then
|
||||||
|
|||||||
Reference in New Issue
Block a user