diff options
Diffstat (limited to 'src/arch')
| -rw-r--r-- | src/arch/arm64/Makefile.efi | 4 | ||||
| -rw-r--r-- | src/arch/x86/core/x86_string.c | 14 | ||||
| -rw-r--r-- | src/arch/x86/image/com32.c | 2 | ||||
| -rw-r--r-- | src/arch/x86/include/bits/bigint.h | 25 | ||||
| -rw-r--r-- | src/arch/x86/interface/pcbios/memtop_umalloc.c | 8 | ||||
| -rw-r--r-- | src/arch/x86/prefix/usbdisk.S | 64 |
6 files changed, 85 insertions, 32 deletions
diff --git a/src/arch/arm64/Makefile.efi b/src/arch/arm64/Makefile.efi index 998a64d03..eb04c0e2f 100644 --- a/src/arch/arm64/Makefile.efi +++ b/src/arch/arm64/Makefile.efi @@ -1,5 +1,9 @@ # -*- makefile -*- : Force emacs to use Makefile mode +# Avoid untranslatable relocations +# +CFLAGS += -fno-pic + # Specify EFI image builder # ELF2EFI = $(ELF2EFI64) diff --git a/src/arch/x86/core/x86_string.c b/src/arch/x86/core/x86_string.c index 7d5e4a5f1..1a1e79dac 100644 --- a/src/arch/x86/core/x86_string.c +++ b/src/arch/x86/core/x86_string.c @@ -30,6 +30,14 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include <string.h> +#include <config/defaults.h> + +/* Use generic_memcpy_reverse() if we cannot safely set the direction flag */ +#ifdef UNSAFE_STD +#define USE_GENERIC_MEMCPY_REVERSE 1 +#else +#define USE_GENERIC_MEMCPY_REVERSE 0 +#endif /** * Copy memory area @@ -77,6 +85,12 @@ void * __attribute__ (( noinline )) __memcpy_reverse ( void *dest, const void *esi = ( src + len - 1 ); int discard_ecx; + /* Use unoptimised version if we are not permitted to modify + * the direction flag. + */ + if ( USE_GENERIC_MEMCPY_REVERSE ) + return generic_memcpy_reverse ( dest, src, len ); + /* Assume memmove() is not performance-critical, and perform a * bytewise copy for simplicity. */ diff --git a/src/arch/x86/image/com32.c b/src/arch/x86/image/com32.c index 016652877..6f0e66041 100644 --- a/src/arch/x86/image/com32.c +++ b/src/arch/x86/image/com32.c @@ -110,7 +110,7 @@ static int com32_exec_loop ( struct image *image ) { /* Disable interrupts */ "cli\n\t" /* Restore stack pointer */ - "movl 24(%%esp), %%esp\n\t" + "movl 28(%%esp), %%esp\n\t" /* Restore registers */ "popal\n\t" ) : diff --git a/src/arch/x86/include/bits/bigint.h b/src/arch/x86/include/bits/bigint.h index c9bb6ea45..4f1bc87ff 100644 --- a/src/arch/x86/include/bits/bigint.h +++ b/src/arch/x86/include/bits/bigint.h @@ -167,28 +167,19 @@ bigint_is_zero_raw ( const uint32_t *value0, unsigned int size ) { static inline __attribute__ (( always_inline, pure )) int bigint_is_geq_raw ( const uint32_t *value0, const uint32_t *reference0, unsigned int size ) { - const bigint_t ( size ) __attribute__ (( may_alias )) *value = - ( ( const void * ) value0 ); - const bigint_t ( size ) __attribute__ (( may_alias )) *reference = - ( ( const void * ) reference0 ); - void *discard_S; - void *discard_D; long discard_c; + long discard_tmp; int result; - __asm__ __volatile__ ( "std\n\t" - "\n1:\n\t" - "lodsl\n\t" - "scasl\n\t" + __asm__ __volatile__ ( "\n1:\n\t" + "movl -4(%3, %1, 4), %k2\n\t" + "cmpl -4(%4, %1, 4), %k2\n\t" "loope 1b\n\t" "setae %b0\n\t" - "cld\n\t" - : "=q" ( result ), "=&S" ( discard_S ), - "=&D" ( discard_D ), "=&c" ( discard_c ) - : "0" ( 0 ), "1" ( &value->element[ size - 1 ] ), - "2" ( &reference->element[ size - 1 ] ), - "3" ( size ) - : "eax" ); + : "=q" ( result ), "=&c" ( discard_c ), + "=&r" ( discard_tmp ) + : "r" ( value0 ), "r" ( reference0 ), + "0" ( 0 ), "1" ( size ) ); return result; } diff --git a/src/arch/x86/interface/pcbios/memtop_umalloc.c b/src/arch/x86/interface/pcbios/memtop_umalloc.c index f1ab73e29..1d3f40a1c 100644 --- a/src/arch/x86/interface/pcbios/memtop_umalloc.c +++ b/src/arch/x86/interface/pcbios/memtop_umalloc.c @@ -190,14 +190,14 @@ static userptr_t memtop_urealloc ( userptr_t ptr, size_t new_size ) { /* Expand/shrink block if possible */ if ( ptr == bottom ) { /* Update block */ - if ( new_size > ( heap_size - extmem.size ) ) { - DBG ( "EXTMEM out of space\n" ); - return UNULL; - } new = userptr_add ( ptr, - ( new_size - extmem.size ) ); align = ( user_to_phys ( new, 0 ) & ( EM_ALIGN - 1 ) ); new_size += align; new = userptr_add ( new, -align ); + if ( new_size > ( heap_size + extmem.size ) ) { + DBG ( "EXTMEM out of space\n" ); + return UNULL; + } DBG ( "EXTMEM expanding [%lx,%lx) to [%lx,%lx)\n", user_to_phys ( ptr, 0 ), user_to_phys ( ptr, extmem.size ), diff --git a/src/arch/x86/prefix/usbdisk.S b/src/arch/x86/prefix/usbdisk.S index 9676406e2..977de6dd6 100644 --- a/src/arch/x86/prefix/usbdisk.S +++ b/src/arch/x86/prefix/usbdisk.S @@ -1,5 +1,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ) +#include <config/console.h> + .text .arch i386 .section ".prefix", "awx", @progbits @@ -9,26 +11,68 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ) #include "mbr.S" /* Partition table: 64 heads, 32 sectors/track (ZIP-drive compatible) */ +#define HEADS 64 +#define SECTORS 32 +#define CYLADDR(cyl) ((((cyl) * HEADS + (((cyl) == 0) & 1)) * SECTORS) * 512) + +#ifdef CONSOLE_INT13 +#define LOGPART 1 +#define LOGSTART 0 +#define LOGCOUNT 1 +#define BOOTSTART 1 +#define BOOTCOUNT 2 +#else /* CONSOLE_INT13 */ +#define LOGPART 0 +#define BOOTSTART 0 +#define BOOTCOUNT 2 +#endif /* CONSOLE_INT13 */ + + /* Construct a C/H/S address */ + .macro chs cylinder, head, sector + .byte \head + .byte (((\cylinder & 0x300) >> 2) | \sector) + .byte (\cylinder & 0x0ff) + .endm + + /* Construct a linear address */ + .macro linear cylinders, heads, sectors + .long ((((\cylinders * HEADS) + \heads) * SECTORS) + \sectors - 1) + .endm + + /* Construct a partition table entry */ + .macro partition bootflag, type, start, count + .byte \bootflag + chs \start, ((\start == 0) & 1), 1 + .byte \type + chs (\start + \count - 1), (HEADS - 1), SECTORS + linear \start, ((\start == 0) & 1), 1 + linear \count, 0, (1 - (((\start == 0) & 1) * SECTORS)) + .endm + + /* Partition table */ .org 446 .space 16 .space 16 + /* Partition 3: log partition (for CONSOLE_INT13) */ - .byte 0x00, 0x01, 0x01, 0x00 - .byte 0xe0, 0x3f, 0x20, 0x00 - .long 0x00000020 - .long 0x000007e0 + .if LOGPART + partition 0x00, 0xe0, LOGSTART, LOGCOUNT + .else + .space 16 + .endif + /* Partition 4: boot partition */ - .byte 0x80, 0x00, 0x01, 0x01 - .byte 0xeb, 0x3f, 0x20, 0x02 - .long 0x00000800 - .long 0x00001000 + partition 0x80, 0xeb, BOOTSTART, BOOTCOUNT + /* Disk signature */ .org 510 .byte 0x55, 0xaa /* Skip to start of log partition */ - .org 32 * 512 + .if LOGPART + .org CYLADDR(LOGSTART) .ascii "iPXE LOG\n\n" + .endif /* Skip to start of boot partition */ - .org 2048 * 512 + .org CYLADDR(BOOTSTART) |
