diff options
Diffstat (limited to 'src/arch')
51 files changed, 334 insertions, 122 deletions
diff --git a/src/arch/arm/Makefile b/src/arch/arm/Makefile index 3cee5f3a..b6509dda 100644 --- a/src/arch/arm/Makefile +++ b/src/arch/arm/Makefile @@ -9,4 +9,5 @@ INCDIRS += arch/arm/include # ARM-specific directories containing source files # +SRCDIRS += arch/arm/core SRCDIRS += arch/arm/interface/efi diff --git a/src/arch/arm/core/arm_io.c b/src/arch/arm/core/arm_io.c index 1ef571fc..41b42389 100644 --- a/src/arch/arm/core/arm_io.c +++ b/src/arch/arm/core/arm_io.c @@ -46,7 +46,7 @@ union arm32_io_qword { * * 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 = container_of ( io_addr, union arm32_io_qword, qword ); 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. */ -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 = container_of ( io_addr, union arm32_io_qword, qword ); union arm32_io_qword tmp; @@ -82,7 +83,6 @@ PROVIDE_IOAPI_INLINE ( arm, readl ); PROVIDE_IOAPI_INLINE ( arm, writeb ); PROVIDE_IOAPI_INLINE ( arm, writew ); PROVIDE_IOAPI_INLINE ( arm, writel ); -PROVIDE_IOAPI_INLINE ( arm, iodelay ); PROVIDE_IOAPI_INLINE ( arm, mb ); #ifdef __aarch64__ PROVIDE_IOAPI_INLINE ( arm, readq ); @@ -91,3 +91,4 @@ PROVIDE_IOAPI_INLINE ( arm, writeq ); PROVIDE_IOAPI ( arm, readq, arm32_readq ); PROVIDE_IOAPI ( arm, writeq, arm32_writeq ); #endif +PROVIDE_DUMMY_PIO ( arm ); diff --git a/src/arch/arm/include/bits/pci_io.h b/src/arch/arm/include/bits/pci_io.h index fba0eb97..91f507a4 100644 --- a/src/arch/arm/include/bits/pci_io.h +++ b/src/arch/arm/include/bits/pci_io.h @@ -9,6 +9,4 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); -#include <ipxe/io.h> - #endif /* _BITS_PCI_IO_H */ diff --git a/src/arch/arm/include/ipxe/arm_io.h b/src/arch/arm/include/ipxe/arm_io.h index 046cbdb0..7ed38993 100644 --- a/src/arch/arm/include/ipxe/arm_io.h +++ b/src/arch/arm/include/ipxe/arm_io.h @@ -15,6 +15,8 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #define IOAPI_PREFIX_arm __arm_ #endif +#include <ipxe/dummy_pio.h> + /* * Memory space mappings * @@ -78,55 +80,6 @@ ARM_WRITEX ( l, uint32_t, "", "" ); #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 * */ @@ -140,4 +93,7 @@ IOAPI_INLINE ( arm, mb ) ( void ) { #endif } +/* Dummy PIO */ +DUMMY_PIO ( arm ); + #endif /* _IPXE_ARM_IO_H */ diff --git a/src/arch/arm64/core/setjmp.S b/src/arch/arm64/core/setjmp.S index fa47aa0a..c5c77c1f 100644 --- a/src/arch/arm64/core/setjmp.S +++ b/src/arch/arm64/core/setjmp.S @@ -1,5 +1,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ) + .section ".note.GNU-stack", "", %progbits .text /* Must match jmp_buf structure layout */ diff --git a/src/arch/i386/core/gdbidt.S b/src/arch/i386/core/gdbidt.S index 666ecce3..78945c62 100644 --- a/src/arch/i386/core/gdbidt.S +++ b/src/arch/i386/core/gdbidt.S @@ -9,6 +9,7 @@ * Interrupt handlers **************************************************************************** */ + .section ".note.GNU-stack", "", @progbits .section ".text", "ax", @progbits .code32 diff --git a/src/arch/i386/core/setjmp.S b/src/arch/i386/core/setjmp.S index 81d3b491..e0bbb7ef 100644 --- a/src/arch/i386/core/setjmp.S +++ b/src/arch/i386/core/setjmp.S @@ -1,5 +1,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ) + .section ".note.GNU-stack", "", @progbits .text .arch i386 .code32 diff --git a/src/arch/i386/tests/gdbstub_test.S b/src/arch/i386/tests/gdbstub_test.S index 739b0527..e0c9e6c9 100644 --- a/src/arch/i386/tests/gdbstub_test.S +++ b/src/arch/i386/tests/gdbstub_test.S @@ -1,3 +1,4 @@ + .section ".note.GNU-stack", "", @progbits .arch i386 .section ".data", "aw", @progbits diff --git a/src/arch/loong64/Makefile b/src/arch/loong64/Makefile index f2dfc76e..fd0bf137 100644 --- a/src/arch/loong64/Makefile +++ b/src/arch/loong64/Makefile @@ -20,6 +20,7 @@ CFLAGS += -fshort-wchar # LoongArch64-specific directories containing source files SRCDIRS += arch/loong64/core +SRCDIRS += arch/loong64/interface/efi # Include platform-specific Makefile MAKEDEPS += arch/loong64/Makefile.$(PLATFORM) diff --git a/src/arch/loong64/Makefile.efi b/src/arch/loong64/Makefile.efi new file mode 100644 index 00000000..1c51bcd6 --- /dev/null +++ b/src/arch/loong64/Makefile.efi @@ -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 diff --git a/src/arch/loong64/core/loong64_io.c b/src/arch/loong64/core/loong64_io.c new file mode 100644 index 00000000..6e2a78af --- /dev/null +++ b/src/arch/loong64/core/loong64_io.c @@ -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 ); diff --git a/src/arch/loong64/include/bits/io.h b/src/arch/loong64/include/bits/io.h index 20ca6a7b..e9bcf2ee 100644 --- a/src/arch/loong64/include/bits/io.h +++ b/src/arch/loong64/include/bits/io.h @@ -12,4 +12,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); /** Page shift */ #define PAGE_SHIFT 12 +#include <ipxe/loong64_io.h> + #endif /* _BITS_IO_H */ diff --git a/src/arch/loong64/include/bits/nap.h b/src/arch/loong64/include/bits/nap.h index 91e255d9..2deba355 100644 --- a/src/arch/loong64/include/bits/nap.h +++ b/src/arch/loong64/include/bits/nap.h @@ -9,4 +9,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); -#endif /* _BITS_MAP_H */ +#include <ipxe/efi/efiloong64_nap.h> + +#endif /* _BITS_NAP_H */ diff --git a/src/arch/loong64/include/ipxe/efi/efiloong64_nap.h b/src/arch/loong64/include/ipxe/efi/efiloong64_nap.h new file mode 100644 index 00000000..5c0d3863 --- /dev/null +++ b/src/arch/loong64/include/ipxe/efi/efiloong64_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 */ diff --git a/src/arch/loong64/include/ipxe/loong64_io.h b/src/arch/loong64/include/ipxe/loong64_io.h new file mode 100644 index 00000000..939fbf2b --- /dev/null +++ b/src/arch/loong64/include/ipxe/loong64_io.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 */ diff --git a/src/arch/loong64/interface/efi/efiloong64_nap.c b/src/arch/loong64/interface/efi/efiloong64_nap.c new file mode 100644 index 00000000..5cd1c1b9 --- /dev/null +++ b/src/arch/loong64/interface/efi/efiloong64_nap.c @@ -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 ); diff --git a/src/arch/x86/Makefile.pcbios b/src/arch/x86/Makefile.pcbios index ed8d554a..38dfa087 100644 --- a/src/arch/x86/Makefile.pcbios +++ b/src/arch/x86/Makefile.pcbios @@ -13,6 +13,13 @@ LDSCRIPT_PREFIX = arch/x86/scripts/prefixonly.lds # 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 += rom @@ -54,9 +61,15 @@ LIST_NAME_mrom := ROMS LIST_NAME_pcirom := ROMS LIST_NAME_isarom := ROMS -# ISO or FAT filesystem images +# ISO images 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] $@" $(Q)util/genfsimg -o $@ $< diff --git a/src/arch/x86/core/patch_cf.S b/src/arch/x86/core/patch_cf.S index 4365563f..63730c3f 100644 --- a/src/arch/x86/core/patch_cf.S +++ b/src/arch/x86/core/patch_cf.S @@ -22,6 +22,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ) + .section ".note.GNU-stack", "", @progbits .text .arch i386 .code16 diff --git a/src/arch/x86/core/stack.S b/src/arch/x86/core/stack.S index baa19ff8..49345347 100644 --- a/src/arch/x86/core/stack.S +++ b/src/arch/x86/core/stack.S @@ -1,5 +1,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ) + .section ".note.GNU-stack", "", @progbits .arch i386 #ifdef __x86_64__ diff --git a/src/arch/x86/core/stack16.S b/src/arch/x86/core/stack16.S index ad67e4f2..d3949a55 100644 --- a/src/arch/x86/core/stack16.S +++ b/src/arch/x86/core/stack16.S @@ -1,5 +1,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ) + .section ".note.GNU-stack", "", @progbits .arch i386 /**************************************************************************** diff --git a/src/arch/x86/drivers/net/undiisr.S b/src/arch/x86/drivers/net/undiisr.S index 2428d1f5..a1098b83 100644 --- a/src/arch/x86/drivers/net/undiisr.S +++ b/src/arch/x86/drivers/net/undiisr.S @@ -10,6 +10,7 @@ FILE_LICENCE ( GPL2_OR_LATER ) #define PIC1_ICR 0x20 #define PIC2_ICR 0xa0 + .section ".note.GNU-stack", "", @progbits .text .arch i386 .code16 diff --git a/src/arch/x86/image/bzimage.c b/src/arch/x86/image/bzimage.c index b15bd556..2c776147 100644 --- a/src/arch/x86/image/bzimage.c +++ b/src/arch/x86/image/bzimage.c @@ -355,6 +355,10 @@ static size_t bzimage_load_initrd ( struct image *image, size_t offset; size_t pad_len; + /* Skip hidden images */ + if ( initrd->flags & IMAGE_HIDDEN ) + return 0; + /* Create cpio header for non-prebuilt images */ offset = cpio_header ( initrd, &cpio ); diff --git a/src/arch/x86/image/multiboot.c b/src/arch/x86/image/multiboot.c index c1c63bc9..cada021a 100644 --- a/src/arch/x86/image/multiboot.c +++ b/src/arch/x86/image/multiboot.c @@ -204,6 +204,10 @@ static int multiboot_add_modules ( struct image *image, physaddr_t start, break; } + /* Skip hidden images */ + if ( module_image->flags & IMAGE_HIDDEN ) + continue; + /* Page-align the module */ start = ( ( start + 0xfff ) & ~0xfff ); diff --git a/src/arch/x86/include/librm.h b/src/arch/x86/include/librm.h index 5196d390..40f07543 100644 --- a/src/arch/x86/include/librm.h +++ b/src/arch/x86/include/librm.h @@ -250,8 +250,10 @@ extern void remove_user_from_rm_stack ( userptr_t data, size_t size ); /* CODE_DEFAULT: restore default .code32/.code64 directive */ #ifdef __x86_64__ #define CODE_DEFAULT ".code64" +#define STACK_DEFAULT "q" #else #define CODE_DEFAULT ".code32" +#define STACK_DEFAULT "l" #endif /* LINE_SYMBOL: declare a symbol for the current source code line */ @@ -268,7 +270,7 @@ extern void remove_user_from_rm_stack ( userptr_t data, size_t size ); /* REAL_CODE: declare a fragment of code that executes in real mode */ #define REAL_CODE( asm_code_str ) \ - "push $1f\n\t" \ + "push" STACK_DEFAULT " $1f\n\t" \ "call real_call\n\t" \ TEXT16_CODE ( "\n1:\n\t" \ asm_code_str \ @@ -277,7 +279,7 @@ extern void remove_user_from_rm_stack ( userptr_t data, size_t size ); /* PHYS_CODE: declare a fragment of code that executes in flat physical mode */ #define PHYS_CODE( asm_code_str ) \ - "push $1f\n\t" \ + "push" STACK_DEFAULT " $1f\n\t" \ "call phys_call\n\t" \ ".section \".text.phys\", \"ax\", @progbits\n\t"\ "\n" LINE_SYMBOL "\n\t" \ diff --git a/src/arch/x86/interface/pcbios/bios_console.c b/src/arch/x86/interface/pcbios/bios_console.c index 0220c856..7263eb71 100644 --- a/src/arch/x86/interface/pcbios/bios_console.c +++ b/src/arch/x86/interface/pcbios/bios_console.c @@ -290,29 +290,38 @@ static const char *bios_ansi_input = ""; struct bios_key { /** Scancode */ uint8_t scancode; - /** Key code */ - uint16_t key; + /** Relative key value */ + uint16_t rkey; } __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 */ static const struct bios_key bios_keys[] = { - { 0x53, KEY_DC }, - { 0x48, KEY_UP }, - { 0x50, KEY_DOWN }, - { 0x4b, KEY_LEFT }, - { 0x4d, KEY_RIGHT }, - { 0x47, KEY_HOME }, - { 0x4f, KEY_END }, - { 0x49, KEY_PPAGE }, - { 0x51, KEY_NPAGE }, - { 0x3f, KEY_F5 }, - { 0x40, KEY_F6 }, - { 0x41, KEY_F7 }, - { 0x42, KEY_F8 }, - { 0x43, KEY_F9 }, - { 0x44, KEY_F10 }, - { 0x85, KEY_F11 }, - { 0x86, KEY_F12 }, + BIOS_KEY ( 0x53, KEY_DC ), + BIOS_KEY ( 0x48, KEY_UP ), + BIOS_KEY ( 0x50, KEY_DOWN ), + BIOS_KEY ( 0x4b, KEY_LEFT ), + BIOS_KEY ( 0x4d, KEY_RIGHT ), + BIOS_KEY ( 0x47, KEY_HOME ), + BIOS_KEY ( 0x4f, KEY_END ), + BIOS_KEY ( 0x49, KEY_PPAGE ), + BIOS_KEY ( 0x51, KEY_NPAGE ), + BIOS_KEY ( 0x3f, KEY_F5 ), + BIOS_KEY ( 0x40, KEY_F6 ), + BIOS_KEY ( 0x41, KEY_F7 ), + BIOS_KEY ( 0x42, KEY_F8 ), + BIOS_KEY ( 0x43, KEY_F9 ), + BIOS_KEY ( 0x44, KEY_F10 ), + BIOS_KEY ( 0x85, KEY_F11 ), + 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 char buf[ 5 /* "[" + two digits + terminator + NUL */ ]; - unsigned int key; + unsigned int rkey; unsigned int terminator; unsigned int n; unsigned int i; @@ -338,9 +347,9 @@ static const char * bios_ansi_seq ( unsigned int scancode ) { continue; /* Construct escape sequence */ - key = bios_keys[i].key; - n = KEY_ANSI_N ( key ); - terminator = KEY_ANSI_TERMINATOR ( key ); + rkey = bios_keys[i].rkey; + n = KEY_ANSI_N ( rkey ); + terminator = KEY_ANSI_TERMINATOR ( rkey ); *(tmp++) = '['; if ( 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 ) { unsigned int discard_a; unsigned int scancode; + unsigned int rkey; unsigned int i; uint16_t keypress; int key; @@ -521,9 +531,10 @@ static __asmcall __used void bios_inject ( struct i386_all_regs *ix86 ) { /* Handle special keys */ if ( key >= KEY_MIN ) { + rkey = KEY_REL ( key ); for ( i = 0 ; i < ( sizeof ( bios_keys ) / sizeof ( bios_keys[0] ) ) ; i++ ) { - if ( bios_keys[i].key == key ) { + if ( bios_keys[i].rkey == rkey ) { scancode = bios_keys[i].scancode; keypress = ( scancode << 8 ); break; diff --git a/src/arch/x86/interface/pcbios/e820mangler.S b/src/arch/x86/interface/pcbios/e820mangler.S index 296a6488..46e1cab4 100644 --- a/src/arch/x86/interface/pcbios/e820mangler.S +++ b/src/arch/x86/interface/pcbios/e820mangler.S @@ -23,6 +23,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ) + .section ".note.GNU-stack", "", @progbits .text .arch i386 .code16 diff --git a/src/arch/x86/interface/pxe/pxe_call.c b/src/arch/x86/interface/pxe/pxe_call.c index 67118299..0e8d5c5a 100644 --- a/src/arch/x86/interface/pxe/pxe_call.c +++ b/src/arch/x86/interface/pxe/pxe_call.c @@ -375,9 +375,10 @@ int pxe_start_nbp ( void ) { * Notify BIOS of existence of network device * * @v netdev Network device + * @v priv Private data * @ret rc Return status code */ -static int pxe_notify ( struct net_device *netdev ) { +static int pxe_notify ( struct net_device *netdev, void *priv __unused ) { /* Do nothing if we already have a network device */ if ( pxe_netdev ) diff --git a/src/arch/x86/interface/pxe/pxe_entry.S b/src/arch/x86/interface/pxe/pxe_entry.S index 3a5a100e..354dd1b3 100644 --- a/src/arch/x86/interface/pxe/pxe_entry.S +++ b/src/arch/x86/interface/pxe/pxe_entry.S @@ -26,6 +26,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ) #include <librm.h> + .section ".note.GNU-stack", "", @progbits .arch i386 /**************************************************************************** diff --git a/src/arch/x86/interface/syslinux/com32_wrapper.S b/src/arch/x86/interface/syslinux/com32_wrapper.S index d59a3392..50191956 100644 --- a/src/arch/x86/interface/syslinux/com32_wrapper.S +++ b/src/arch/x86/interface/syslinux/com32_wrapper.S @@ -21,6 +21,7 @@ FILE_LICENCE ( GPL2_OR_LATER ) #include "librm.h" + .section ".note.GNU-stack", "", @progbits .text .code32 diff --git a/src/arch/x86/interface/vmware/guestinfo.c b/src/arch/x86/interface/vmware/guestinfo.c index a0530c8d..4134515c 100644 --- a/src/arch/x86/interface/vmware/guestinfo.c +++ b/src/arch/x86/interface/vmware/guestinfo.c @@ -207,65 +207,35 @@ struct init_fn guestinfo_init_fn __init_fn ( INIT_NORMAL ) = { * Create per-netdevice GuestInfo settings * * @v netdev Network device + * @v priv Private data * @ret rc Return status code */ -static int guestinfo_net_probe ( struct net_device *netdev ) { - struct settings *settings; +static int guestinfo_net_probe ( struct net_device *netdev, void *priv ) { + struct settings *settings = priv; int rc; /* Do nothing unless we have a GuestInfo channel available */ if ( guestinfo_channel < 0 ) return 0; - /* Allocate and initialise settings block */ - settings = zalloc ( sizeof ( *settings ) ); - if ( ! settings ) { - rc = -ENOMEM; - goto err_alloc; - } - settings_init ( settings, &guestinfo_settings_operations, NULL, NULL ); - - /* Register settings */ + /* Initialise and register settings */ + settings_init ( settings, &guestinfo_settings_operations, + &netdev->refcnt, NULL ); if ( ( rc = register_settings ( settings, netdev_settings ( netdev ), "vmware" ) ) != 0 ) { DBGC ( settings, "GuestInfo %p could not register for %s: %s\n", settings, netdev->name, strerror ( rc ) ); - goto err_register; + return rc; } DBGC ( settings, "GuestInfo %p registered for %s\n", settings, netdev->name ); return 0; - - err_register: - free ( settings ); - err_alloc: - return rc; -} - -/** - * Remove per-netdevice GuestInfo settings - * - * @v netdev Network device - */ -static void guestinfo_net_remove ( struct net_device *netdev ) { - struct settings *parent = netdev_settings ( netdev ); - struct settings *settings; - - list_for_each_entry ( settings, &parent->children, siblings ) { - if ( settings->op == &guestinfo_settings_operations ) { - DBGC ( settings, "GuestInfo %p unregistered for %s\n", - settings, netdev->name ); - unregister_settings ( settings ); - free ( settings ); - return; - } - } } /** GuestInfo per-netdevice driver */ struct net_driver guestinfo_net_driver __net_driver = { .name = "GuestInfo", + .priv_len = sizeof ( struct settings ), .probe = guestinfo_net_probe, - .remove = guestinfo_net_remove, }; diff --git a/src/arch/x86/prefix/bootpart.S b/src/arch/x86/prefix/bootpart.S index 6d0c6034..575cb1c0 100644 --- a/src/arch/x86/prefix/bootpart.S +++ b/src/arch/x86/prefix/bootpart.S @@ -5,6 +5,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ) #define STACK_SEG 0x0200 #define STACK_SIZE 0x2000 + .section ".note.GNU-stack", "", @progbits .text .arch i386 .section ".prefix", "awx", @progbits diff --git a/src/arch/x86/prefix/dskprefix.S b/src/arch/x86/prefix/dskprefix.S index 0503f113..bc194887 100644 --- a/src/arch/x86/prefix/dskprefix.S +++ b/src/arch/x86/prefix/dskprefix.S @@ -24,6 +24,7 @@ FILE_LICENCE ( GPL2_ONLY ) .equ SYSSEG, 0x1000 /* system loaded at SYSSEG<<4 */ + .section ".note.GNU-stack", "", @progbits .org 0 .arch i386 .text diff --git a/src/arch/x86/prefix/exeprefix.S b/src/arch/x86/prefix/exeprefix.S index 0eab8c12..5b2605e8 100644 --- a/src/arch/x86/prefix/exeprefix.S +++ b/src/arch/x86/prefix/exeprefix.S @@ -36,6 +36,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ) #define PSP_CMDLINE_LEN 0x80 #define PSP_CMDLINE_START 0x81 + .section ".note.GNU-stack", "", @progbits .text .arch i386 .org 0 diff --git a/src/arch/x86/prefix/hdprefix.S b/src/arch/x86/prefix/hdprefix.S index 28c8a532..fbf8d2e4 100644 --- a/src/arch/x86/prefix/hdprefix.S +++ b/src/arch/x86/prefix/hdprefix.S @@ -2,6 +2,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ) #include <librm.h> + .section ".note.GNU-stack", "", @progbits .text .arch i386 .section ".prefix", "awx", @progbits diff --git a/src/arch/x86/prefix/libprefix.S b/src/arch/x86/prefix/libprefix.S index d7f26195..380e471d 100644 --- a/src/arch/x86/prefix/libprefix.S +++ b/src/arch/x86/prefix/libprefix.S @@ -26,6 +26,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ) #include <librm.h> + .section ".note.GNU-stack", "", @progbits .arch i386 /* Image compression enabled */ diff --git a/src/arch/x86/prefix/lkrnprefix.S b/src/arch/x86/prefix/lkrnprefix.S index 922181f0..2c17f79d 100644 --- a/src/arch/x86/prefix/lkrnprefix.S +++ b/src/arch/x86/prefix/lkrnprefix.S @@ -4,6 +4,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ) #define BZI_LOAD_HIGH_ADDR 0x100000 + .section ".note.GNU-stack", "", @progbits .text .arch i386 .code16 diff --git a/src/arch/x86/prefix/mbr.S b/src/arch/x86/prefix/mbr.S index 032c0e77..928bb338 100644 --- a/src/arch/x86/prefix/mbr.S +++ b/src/arch/x86/prefix/mbr.S @@ -1,5 +1,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ) + .section ".note.GNU-stack", "", @progbits .text .arch i386 .section ".prefix", "awx", @progbits diff --git a/src/arch/x86/prefix/mromprefix.S b/src/arch/x86/prefix/mromprefix.S index d08284d7..5f3496b2 100644 --- a/src/arch/x86/prefix/mromprefix.S +++ b/src/arch/x86/prefix/mromprefix.S @@ -41,6 +41,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ) #define _pcirom_start _mrom_start #include "pciromprefix.S" + .section ".note.GNU-stack", "", @progbits .text .arch i386 .code16 diff --git a/src/arch/x86/prefix/nbiprefix.S b/src/arch/x86/prefix/nbiprefix.S index de38e4af..cae1009b 100644 --- a/src/arch/x86/prefix/nbiprefix.S +++ b/src/arch/x86/prefix/nbiprefix.S @@ -2,6 +2,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ) #include <librm.h> + .section ".note.GNU-stack", "", @progbits .text .arch i386 .code16 diff --git a/src/arch/x86/prefix/nullprefix.S b/src/arch/x86/prefix/nullprefix.S index bd0ff339..1568188d 100644 --- a/src/arch/x86/prefix/nullprefix.S +++ b/src/arch/x86/prefix/nullprefix.S @@ -1,5 +1,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ) + .section ".note.GNU-stack", "", @progbits .org 0 .text .arch i386 diff --git a/src/arch/x86/prefix/pxeprefix.S b/src/arch/x86/prefix/pxeprefix.S index 52ea1803..494fbc13 100644 --- a/src/arch/x86/prefix/pxeprefix.S +++ b/src/arch/x86/prefix/pxeprefix.S @@ -11,6 +11,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ) #define PXE_HACK_EB54 0x0001 + .section ".note.GNU-stack", "", @progbits .text .arch i386 .org 0 diff --git a/src/arch/x86/prefix/rawprefix.S b/src/arch/x86/prefix/rawprefix.S index 4cf5f391..4a3d3504 100644 --- a/src/arch/x86/prefix/rawprefix.S +++ b/src/arch/x86/prefix/rawprefix.S @@ -8,6 +8,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ) + .section ".note.GNU-stack", "", @progbits .text .arch i386 .org 0 diff --git a/src/arch/x86/prefix/romprefix.S b/src/arch/x86/prefix/romprefix.S index 4e8793c2..79fed2a3 100644 --- a/src/arch/x86/prefix/romprefix.S +++ b/src/arch/x86/prefix/romprefix.S @@ -54,6 +54,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ) #define BUSTYPE "PCIR" #endif + .section ".note.GNU-stack", "", @progbits .text .code16 .arch i386 diff --git a/src/arch/x86/prefix/undiloader.S b/src/arch/x86/prefix/undiloader.S index 1d77110e..e544d504 100644 --- a/src/arch/x86/prefix/undiloader.S +++ b/src/arch/x86/prefix/undiloader.S @@ -2,6 +2,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ) #include <librm.h> + .section ".note.GNU-stack", "", @progbits .text .code16 .arch i386 diff --git a/src/arch/x86/prefix/unlzma.S b/src/arch/x86/prefix/unlzma.S index 979f699e..f4bd81bd 100644 --- a/src/arch/x86/prefix/unlzma.S +++ b/src/arch/x86/prefix/unlzma.S @@ -43,6 +43,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); **************************************************************************** */ + .section ".note.GNU-stack", "", @progbits .text .arch i486 .section ".prefix.lib", "ax", @progbits diff --git a/src/arch/x86/prefix/usbdisk.S b/src/arch/x86/prefix/usbdisk.S index 977de6dd..461a0837 100644 --- a/src/arch/x86/prefix/usbdisk.S +++ b/src/arch/x86/prefix/usbdisk.S @@ -2,6 +2,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ) #include <config/console.h> + .section ".note.GNU-stack", "", @progbits .text .arch i386 .section ".prefix", "awx", @progbits diff --git a/src/arch/x86/transitions/liba20.S b/src/arch/x86/transitions/liba20.S index 57603353..6c1bac67 100644 --- a/src/arch/x86/transitions/liba20.S +++ b/src/arch/x86/transitions/liba20.S @@ -24,6 +24,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ) + .section ".note.GNU-stack", "", @progbits .arch i386 /**************************************************************************** diff --git a/src/arch/x86/transitions/libkir.S b/src/arch/x86/transitions/libkir.S index fa9459d5..af090b26 100644 --- a/src/arch/x86/transitions/libkir.S +++ b/src/arch/x86/transitions/libkir.S @@ -31,6 +31,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ) /* Breakpoint for when debugging under bochs */ #define BOCHSBP xchgw %bx, %bx + .section ".note.GNU-stack", "", @progbits .text .arch i386 .section ".text16", "awx", @progbits diff --git a/src/arch/x86/transitions/librm.S b/src/arch/x86/transitions/librm.S index 5dacb9b0..39431324 100644 --- a/src/arch/x86/transitions/librm.S +++ b/src/arch/x86/transitions/librm.S @@ -83,6 +83,8 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ) #define if64 if 0 #endif + .section ".note.GNU-stack", "", @progbits + /**************************************************************************** * Global descriptor table * diff --git a/src/arch/x86_64/core/gdbidt.S b/src/arch/x86_64/core/gdbidt.S index 89280bf8..477492b4 100644 --- a/src/arch/x86_64/core/gdbidt.S +++ b/src/arch/x86_64/core/gdbidt.S @@ -38,6 +38,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #define SIGFPE 8 #define SIGSTKFLT 16 + .section ".note.GNU-stack", "", @progbits .section ".text.gdbmach_interrupt", "ax", @progbits .code64 diff --git a/src/arch/x86_64/core/setjmp.S b/src/arch/x86_64/core/setjmp.S index e43200d7..5137a72c 100644 --- a/src/arch/x86_64/core/setjmp.S +++ b/src/arch/x86_64/core/setjmp.S @@ -1,5 +1,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ) + .section ".note.GNU-stack", "", @progbits .text .code64 |