2006-05-01 22:35:19 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2006 Michael Brown <mbrown@fensystems.co.uk>.
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
|
* published by the Free Software Foundation; either version 2 of the
|
|
|
|
|
* License, or any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
* General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
2012-07-20 19:55:45 +01:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
|
|
|
* 02110-1301, USA.
|
2006-05-01 22:35:19 +00:00
|
|
|
*
|
|
|
|
|
*/
|
2006-05-01 21:26:44 +00:00
|
|
|
|
2009-05-01 15:41:06 +01:00
|
|
|
FILE_LICENCE ( GPL2_OR_LATER )
|
|
|
|
|
|
2008-03-09 22:13:07 +00:00
|
|
|
.arch i386
|
|
|
|
|
|
2007-07-16 16:58:38 +01:00
|
|
|
/* Image compression enabled */
|
|
|
|
|
#define COMPRESS 1
|
|
|
|
|
|
2011-01-26 23:04:43 +00:00
|
|
|
/* Protected mode flag */
|
|
|
|
|
#define CR0_PE 1
|
|
|
|
|
|
2011-03-01 14:49:25 +00:00
|
|
|
/* Allow for DBG()-style messages within libprefix */
|
|
|
|
|
#ifdef NDEBUG
|
|
|
|
|
.macro progress message
|
|
|
|
|
.endm
|
|
|
|
|
#else
|
|
|
|
|
.macro progress message
|
|
|
|
|
pushfl
|
|
|
|
|
pushw %ds
|
|
|
|
|
pushw %si
|
|
|
|
|
pushw %di
|
|
|
|
|
pushw %cs
|
|
|
|
|
popw %ds
|
|
|
|
|
xorw %di, %di
|
|
|
|
|
movw $progress_\@, %si
|
|
|
|
|
call print_message
|
|
|
|
|
popw %di
|
|
|
|
|
popw %si
|
|
|
|
|
popw %ds
|
|
|
|
|
popfl
|
|
|
|
|
.section ".prefix.data", "aw", @progbits
|
|
|
|
|
progress_\@:
|
|
|
|
|
.asciz "\message"
|
2012-02-10 14:12:04 +00:00
|
|
|
.size progress_\@, . - progress_\@
|
2011-03-01 14:49:25 +00:00
|
|
|
.previous
|
|
|
|
|
.endm
|
|
|
|
|
#endif
|
|
|
|
|
|
2008-03-11 11:32:19 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
|
* Utility function: print character (with LF -> LF,CR translation)
|
|
|
|
|
*
|
|
|
|
|
* Parameters:
|
|
|
|
|
* %al : character to print
|
2008-05-21 18:43:58 +01:00
|
|
|
* %ds:di : output buffer (or %di=0 to print to console)
|
2008-03-11 11:32:19 +00:00
|
|
|
* Returns:
|
2008-05-21 18:43:58 +01:00
|
|
|
* %ds:di : next character in output buffer (if applicable)
|
2008-03-11 11:32:19 +00:00
|
|
|
*****************************************************************************
|
|
|
|
|
*/
|
[i386] Add explicit flags and type on all .section declarations
Try to avoid future problems caused by implicit section flags and/or
type information by instituting a policy that all .section
declarations must explicitly state the flags and type.
Most of this change was achieved using
perl -pi \
-e 's/".text"$/".text", "ax", \@progbits/ ; ' \
-e 's/".text16"$/".text16", "ax", \@progbits/ ; ' \
-e 's/".text16.null"$/".text16.null", "ax", \@progbits/ ; ' \
-e 's/".text16.data"$/".text16.data", "aw", \@progbits/ ; ' \
-e 's/".data"$/".data", "aw", \@progbits/ ; ' \
-e 's/".data16"$/".data16", "aw", \@progbits/ ; ' \
-e 's/".bss"$/".bss", "aw", \@nobits/ ; ' \
-e 's/".bss16"$/".bss16", "aw", \@nobits/ ; ' \
-e 's/".prefix"$/".prefix", "ax", \@progbits/ ; ' \
-e 's/".prefix.lib"$/".prefix.lib", "awx", \@progbits/ ; ' \
-e 's/".prefix.data"$/".prefix.data", "aw", \@progbits/ ; ' \
-e 's/".weak"$/".weak", "a", \@nobits/ ; ' \
`git grep -l '\.section'`
2009-02-15 10:54:52 +00:00
|
|
|
.section ".prefix.lib", "awx", @progbits
|
2008-03-11 11:32:19 +00:00
|
|
|
.code16
|
|
|
|
|
.globl print_character
|
|
|
|
|
print_character:
|
|
|
|
|
/* Preserve registers */
|
2008-05-21 18:43:58 +01:00
|
|
|
pushw %ax
|
2008-03-11 11:32:19 +00:00
|
|
|
pushw %bx
|
|
|
|
|
pushw %bp
|
2008-05-21 18:43:58 +01:00
|
|
|
/* If %di is non-zero, write character to buffer and exit */
|
|
|
|
|
testw %di, %di
|
|
|
|
|
jz 1f
|
|
|
|
|
movb %al, %ds:(%di)
|
|
|
|
|
incw %di
|
|
|
|
|
jmp 3f
|
|
|
|
|
1: /* Print character */
|
2008-03-11 11:32:19 +00:00
|
|
|
movw $0x0007, %bx /* page 0, attribute 7 (normal) */
|
|
|
|
|
movb $0x0e, %ah /* write char, tty mode */
|
|
|
|
|
cmpb $0x0a, %al /* '\n'? */
|
2008-05-21 18:43:58 +01:00
|
|
|
jne 2f
|
2008-03-11 11:32:19 +00:00
|
|
|
int $0x10
|
|
|
|
|
movb $0x0d, %al
|
2008-05-21 18:43:58 +01:00
|
|
|
2: int $0x10
|
2008-03-11 11:32:19 +00:00
|
|
|
/* Restore registers and return */
|
2008-05-21 18:43:58 +01:00
|
|
|
3: popw %bp
|
2008-03-11 11:32:19 +00:00
|
|
|
popw %bx
|
2008-05-21 18:43:58 +01:00
|
|
|
popw %ax
|
2008-03-11 11:32:19 +00:00
|
|
|
ret
|
|
|
|
|
.size print_character, . - print_character
|
|
|
|
|
|
2014-08-21 16:34:26 +01:00
|
|
|
/*****************************************************************************
|
|
|
|
|
* Utility function: print space
|
|
|
|
|
*
|
|
|
|
|
* Parameters:
|
|
|
|
|
* %ds:di : output buffer (or %di=0 to print to console)
|
|
|
|
|
* Returns:
|
|
|
|
|
* %ds:di : next character in output buffer (if applicable)
|
|
|
|
|
*****************************************************************************
|
|
|
|
|
*/
|
|
|
|
|
.section ".prefix.lib", "awx", @progbits
|
|
|
|
|
.code16
|
|
|
|
|
.globl print_space
|
|
|
|
|
print_space:
|
|
|
|
|
/* Preserve registers */
|
|
|
|
|
pushw %ax
|
|
|
|
|
/* Print space */
|
|
|
|
|
movb $( ' ' ), %al
|
|
|
|
|
call print_character
|
|
|
|
|
/* Restore registers and return */
|
|
|
|
|
popw %ax
|
|
|
|
|
ret
|
|
|
|
|
.size print_space, . - print_space
|
|
|
|
|
|
2008-03-11 11:32:19 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
|
* Utility function: print a NUL-terminated string
|
|
|
|
|
*
|
|
|
|
|
* Parameters:
|
|
|
|
|
* %ds:si : string to print
|
2008-05-21 18:43:58 +01:00
|
|
|
* %ds:di : output buffer (or %di=0 to print to console)
|
2008-03-11 11:32:19 +00:00
|
|
|
* Returns:
|
|
|
|
|
* %ds:si : character after terminating NUL
|
2008-05-21 18:43:58 +01:00
|
|
|
* %ds:di : next character in output buffer (if applicable)
|
2008-03-11 11:32:19 +00:00
|
|
|
*****************************************************************************
|
|
|
|
|
*/
|
[i386] Add explicit flags and type on all .section declarations
Try to avoid future problems caused by implicit section flags and/or
type information by instituting a policy that all .section
declarations must explicitly state the flags and type.
Most of this change was achieved using
perl -pi \
-e 's/".text"$/".text", "ax", \@progbits/ ; ' \
-e 's/".text16"$/".text16", "ax", \@progbits/ ; ' \
-e 's/".text16.null"$/".text16.null", "ax", \@progbits/ ; ' \
-e 's/".text16.data"$/".text16.data", "aw", \@progbits/ ; ' \
-e 's/".data"$/".data", "aw", \@progbits/ ; ' \
-e 's/".data16"$/".data16", "aw", \@progbits/ ; ' \
-e 's/".bss"$/".bss", "aw", \@nobits/ ; ' \
-e 's/".bss16"$/".bss16", "aw", \@nobits/ ; ' \
-e 's/".prefix"$/".prefix", "ax", \@progbits/ ; ' \
-e 's/".prefix.lib"$/".prefix.lib", "awx", \@progbits/ ; ' \
-e 's/".prefix.data"$/".prefix.data", "aw", \@progbits/ ; ' \
-e 's/".weak"$/".weak", "a", \@nobits/ ; ' \
`git grep -l '\.section'`
2009-02-15 10:54:52 +00:00
|
|
|
.section ".prefix.lib", "awx", @progbits
|
2008-03-11 11:32:19 +00:00
|
|
|
.code16
|
|
|
|
|
.globl print_message
|
|
|
|
|
print_message:
|
|
|
|
|
/* Preserve registers */
|
|
|
|
|
pushw %ax
|
|
|
|
|
/* Print string */
|
|
|
|
|
1: lodsb
|
|
|
|
|
testb %al, %al
|
|
|
|
|
je 2f
|
|
|
|
|
call print_character
|
|
|
|
|
jmp 1b
|
|
|
|
|
2: /* Restore registers and return */
|
|
|
|
|
popw %ax
|
|
|
|
|
ret
|
|
|
|
|
.size print_message, . - print_message
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
|
* Utility functions: print hex digit/byte/word/dword
|
|
|
|
|
*
|
|
|
|
|
* Parameters:
|
|
|
|
|
* %al (low nibble) : digit to print
|
|
|
|
|
* %al : byte to print
|
|
|
|
|
* %ax : word to print
|
|
|
|
|
* %eax : dword to print
|
2008-05-21 18:43:58 +01:00
|
|
|
* %ds:di : output buffer (or %di=0 to print to console)
|
2008-03-11 11:32:19 +00:00
|
|
|
* Returns:
|
2008-05-21 18:43:58 +01:00
|
|
|
* %ds:di : next character in output buffer (if applicable)
|
2008-03-11 11:32:19 +00:00
|
|
|
*****************************************************************************
|
|
|
|
|
*/
|
[i386] Add explicit flags and type on all .section declarations
Try to avoid future problems caused by implicit section flags and/or
type information by instituting a policy that all .section
declarations must explicitly state the flags and type.
Most of this change was achieved using
perl -pi \
-e 's/".text"$/".text", "ax", \@progbits/ ; ' \
-e 's/".text16"$/".text16", "ax", \@progbits/ ; ' \
-e 's/".text16.null"$/".text16.null", "ax", \@progbits/ ; ' \
-e 's/".text16.data"$/".text16.data", "aw", \@progbits/ ; ' \
-e 's/".data"$/".data", "aw", \@progbits/ ; ' \
-e 's/".data16"$/".data16", "aw", \@progbits/ ; ' \
-e 's/".bss"$/".bss", "aw", \@nobits/ ; ' \
-e 's/".bss16"$/".bss16", "aw", \@nobits/ ; ' \
-e 's/".prefix"$/".prefix", "ax", \@progbits/ ; ' \
-e 's/".prefix.lib"$/".prefix.lib", "awx", \@progbits/ ; ' \
-e 's/".prefix.data"$/".prefix.data", "aw", \@progbits/ ; ' \
-e 's/".weak"$/".weak", "a", \@nobits/ ; ' \
`git grep -l '\.section'`
2009-02-15 10:54:52 +00:00
|
|
|
.section ".prefix.lib", "awx", @progbits
|
2008-03-11 11:32:19 +00:00
|
|
|
.code16
|
|
|
|
|
.globl print_hex_dword
|
|
|
|
|
print_hex_dword:
|
|
|
|
|
rorl $16, %eax
|
|
|
|
|
call print_hex_word
|
|
|
|
|
rorl $16, %eax
|
|
|
|
|
/* Fall through */
|
|
|
|
|
.size print_hex_dword, . - print_hex_dword
|
|
|
|
|
.globl print_hex_word
|
|
|
|
|
print_hex_word:
|
|
|
|
|
xchgb %al, %ah
|
|
|
|
|
call print_hex_byte
|
|
|
|
|
xchgb %al, %ah
|
|
|
|
|
/* Fall through */
|
|
|
|
|
.size print_hex_word, . - print_hex_word
|
|
|
|
|
.globl print_hex_byte
|
|
|
|
|
print_hex_byte:
|
|
|
|
|
rorb $4, %al
|
|
|
|
|
call print_hex_nibble
|
|
|
|
|
rorb $4, %al
|
|
|
|
|
/* Fall through */
|
|
|
|
|
.size print_hex_byte, . - print_hex_byte
|
|
|
|
|
.globl print_hex_nibble
|
|
|
|
|
print_hex_nibble:
|
|
|
|
|
/* Preserve registers */
|
|
|
|
|
pushw %ax
|
|
|
|
|
/* Print digit (technique by Norbert Juffa <norbert.juffa@amd.com> */
|
|
|
|
|
andb $0x0f, %al
|
|
|
|
|
cmpb $10, %al
|
|
|
|
|
sbbb $0x69, %al
|
|
|
|
|
das
|
|
|
|
|
call print_character
|
|
|
|
|
/* Restore registers and return */
|
|
|
|
|
popw %ax
|
|
|
|
|
ret
|
|
|
|
|
.size print_hex_nibble, . - print_hex_nibble
|
|
|
|
|
|
2008-05-21 18:43:58 +01:00
|
|
|
/*****************************************************************************
|
|
|
|
|
* Utility function: print PCI bus:dev.fn
|
|
|
|
|
*
|
|
|
|
|
* Parameters:
|
|
|
|
|
* %ax : PCI bus:dev.fn to print
|
|
|
|
|
* %ds:di : output buffer (or %di=0 to print to console)
|
|
|
|
|
* Returns:
|
|
|
|
|
* %ds:di : next character in output buffer (if applicable)
|
|
|
|
|
*****************************************************************************
|
|
|
|
|
*/
|
[i386] Add explicit flags and type on all .section declarations
Try to avoid future problems caused by implicit section flags and/or
type information by instituting a policy that all .section
declarations must explicitly state the flags and type.
Most of this change was achieved using
perl -pi \
-e 's/".text"$/".text", "ax", \@progbits/ ; ' \
-e 's/".text16"$/".text16", "ax", \@progbits/ ; ' \
-e 's/".text16.null"$/".text16.null", "ax", \@progbits/ ; ' \
-e 's/".text16.data"$/".text16.data", "aw", \@progbits/ ; ' \
-e 's/".data"$/".data", "aw", \@progbits/ ; ' \
-e 's/".data16"$/".data16", "aw", \@progbits/ ; ' \
-e 's/".bss"$/".bss", "aw", \@nobits/ ; ' \
-e 's/".bss16"$/".bss16", "aw", \@nobits/ ; ' \
-e 's/".prefix"$/".prefix", "ax", \@progbits/ ; ' \
-e 's/".prefix.lib"$/".prefix.lib", "awx", \@progbits/ ; ' \
-e 's/".prefix.data"$/".prefix.data", "aw", \@progbits/ ; ' \
-e 's/".weak"$/".weak", "a", \@nobits/ ; ' \
`git grep -l '\.section'`
2009-02-15 10:54:52 +00:00
|
|
|
.section ".prefix.lib", "awx", @progbits
|
2008-05-21 18:43:58 +01:00
|
|
|
.code16
|
|
|
|
|
.globl print_pci_busdevfn
|
|
|
|
|
print_pci_busdevfn:
|
|
|
|
|
/* Preserve registers */
|
|
|
|
|
pushw %ax
|
|
|
|
|
/* Print bus */
|
|
|
|
|
xchgb %al, %ah
|
|
|
|
|
call print_hex_byte
|
|
|
|
|
/* Print ":" */
|
2009-02-16 03:53:25 +00:00
|
|
|
movb $( ':' ), %al
|
2008-05-21 18:43:58 +01:00
|
|
|
call print_character
|
|
|
|
|
/* Print device */
|
|
|
|
|
movb %ah, %al
|
|
|
|
|
shrb $3, %al
|
|
|
|
|
call print_hex_byte
|
|
|
|
|
/* Print "." */
|
2009-02-16 03:53:25 +00:00
|
|
|
movb $( '.' ), %al
|
2008-05-21 18:43:58 +01:00
|
|
|
call print_character
|
|
|
|
|
/* Print function */
|
|
|
|
|
movb %ah, %al
|
|
|
|
|
andb $0x07, %al
|
|
|
|
|
call print_hex_nibble
|
|
|
|
|
/* Restore registers and return */
|
|
|
|
|
popw %ax
|
|
|
|
|
ret
|
|
|
|
|
.size print_pci_busdevfn, . - print_pci_busdevfn
|
|
|
|
|
|
2008-10-31 19:10:28 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
|
* Utility function: clear current line
|
|
|
|
|
*
|
|
|
|
|
* Parameters:
|
|
|
|
|
* %ds:di : output buffer (or %di=0 to print to console)
|
|
|
|
|
* Returns:
|
|
|
|
|
* %ds:di : next character in output buffer (if applicable)
|
|
|
|
|
*****************************************************************************
|
|
|
|
|
*/
|
[i386] Add explicit flags and type on all .section declarations
Try to avoid future problems caused by implicit section flags and/or
type information by instituting a policy that all .section
declarations must explicitly state the flags and type.
Most of this change was achieved using
perl -pi \
-e 's/".text"$/".text", "ax", \@progbits/ ; ' \
-e 's/".text16"$/".text16", "ax", \@progbits/ ; ' \
-e 's/".text16.null"$/".text16.null", "ax", \@progbits/ ; ' \
-e 's/".text16.data"$/".text16.data", "aw", \@progbits/ ; ' \
-e 's/".data"$/".data", "aw", \@progbits/ ; ' \
-e 's/".data16"$/".data16", "aw", \@progbits/ ; ' \
-e 's/".bss"$/".bss", "aw", \@nobits/ ; ' \
-e 's/".bss16"$/".bss16", "aw", \@nobits/ ; ' \
-e 's/".prefix"$/".prefix", "ax", \@progbits/ ; ' \
-e 's/".prefix.lib"$/".prefix.lib", "awx", \@progbits/ ; ' \
-e 's/".prefix.data"$/".prefix.data", "aw", \@progbits/ ; ' \
-e 's/".weak"$/".weak", "a", \@nobits/ ; ' \
`git grep -l '\.section'`
2009-02-15 10:54:52 +00:00
|
|
|
.section ".prefix.lib", "awx", @progbits
|
2008-10-31 19:10:28 +00:00
|
|
|
.code16
|
|
|
|
|
.globl print_kill_line
|
|
|
|
|
print_kill_line:
|
|
|
|
|
/* Preserve registers */
|
|
|
|
|
pushw %ax
|
|
|
|
|
pushw %cx
|
|
|
|
|
/* Print CR */
|
2009-02-16 03:53:25 +00:00
|
|
|
movb $( '\r' ), %al
|
2008-10-31 19:10:28 +00:00
|
|
|
call print_character
|
|
|
|
|
/* Print 79 spaces */
|
|
|
|
|
movw $79, %cx
|
2014-08-21 16:34:26 +01:00
|
|
|
1: call print_space
|
2008-10-31 19:10:28 +00:00
|
|
|
loop 1b
|
|
|
|
|
/* Print CR */
|
|
|
|
|
call print_character
|
|
|
|
|
/* Restore registers and return */
|
|
|
|
|
popw %cx
|
|
|
|
|
popw %ax
|
|
|
|
|
ret
|
|
|
|
|
.size print_kill_line, . - print_kill_line
|
|
|
|
|
|
2007-09-25 18:01:15 +01:00
|
|
|
/****************************************************************************
|
2010-04-19 22:22:11 +01:00
|
|
|
* copy_bytes
|
2007-09-25 18:01:15 +01:00
|
|
|
*
|
|
|
|
|
* Copy bytes
|
|
|
|
|
*
|
|
|
|
|
* Parameters:
|
|
|
|
|
* %ds:esi : source address
|
|
|
|
|
* %es:edi : destination address
|
|
|
|
|
* %ecx : length
|
|
|
|
|
* Returns:
|
|
|
|
|
* %ds:esi : next source address
|
2008-03-11 13:26:46 +00:00
|
|
|
* %es:edi : next destination address
|
2007-09-25 18:01:15 +01:00
|
|
|
* Corrupts:
|
|
|
|
|
* None
|
|
|
|
|
****************************************************************************
|
|
|
|
|
*/
|
[i386] Add explicit flags and type on all .section declarations
Try to avoid future problems caused by implicit section flags and/or
type information by instituting a policy that all .section
declarations must explicitly state the flags and type.
Most of this change was achieved using
perl -pi \
-e 's/".text"$/".text", "ax", \@progbits/ ; ' \
-e 's/".text16"$/".text16", "ax", \@progbits/ ; ' \
-e 's/".text16.null"$/".text16.null", "ax", \@progbits/ ; ' \
-e 's/".text16.data"$/".text16.data", "aw", \@progbits/ ; ' \
-e 's/".data"$/".data", "aw", \@progbits/ ; ' \
-e 's/".data16"$/".data16", "aw", \@progbits/ ; ' \
-e 's/".bss"$/".bss", "aw", \@nobits/ ; ' \
-e 's/".bss16"$/".bss16", "aw", \@nobits/ ; ' \
-e 's/".prefix"$/".prefix", "ax", \@progbits/ ; ' \
-e 's/".prefix.lib"$/".prefix.lib", "awx", \@progbits/ ; ' \
-e 's/".prefix.data"$/".prefix.data", "aw", \@progbits/ ; ' \
-e 's/".weak"$/".weak", "a", \@nobits/ ; ' \
`git grep -l '\.section'`
2009-02-15 10:54:52 +00:00
|
|
|
.section ".prefix.lib", "awx", @progbits
|
2007-09-25 18:01:15 +01:00
|
|
|
.code16
|
|
|
|
|
copy_bytes:
|
2011-01-26 23:04:43 +00:00
|
|
|
pushl %ecx
|
2007-09-25 18:01:15 +01:00
|
|
|
rep addr32 movsb
|
2011-01-26 23:04:43 +00:00
|
|
|
popl %ecx
|
2007-09-25 18:01:15 +01:00
|
|
|
ret
|
2011-01-26 23:04:43 +00:00
|
|
|
.size copy_bytes, . - copy_bytes
|
2007-09-25 18:01:15 +01:00
|
|
|
|
|
|
|
|
/****************************************************************************
|
2011-01-26 23:04:43 +00:00
|
|
|
* zero_bytes
|
2006-05-01 21:26:44 +00:00
|
|
|
*
|
2011-01-26 23:04:43 +00:00
|
|
|
* Zero bytes
|
2006-05-01 21:26:44 +00:00
|
|
|
*
|
2006-05-01 22:35:19 +00:00
|
|
|
* Parameters:
|
2011-01-26 23:04:43 +00:00
|
|
|
* %ds:esi : source address
|
|
|
|
|
* %es:edi : destination address
|
|
|
|
|
* %ecx : length
|
2006-05-01 21:26:44 +00:00
|
|
|
* Returns:
|
2011-01-26 23:04:43 +00:00
|
|
|
* %ds:esi : next source address
|
|
|
|
|
* %es:edi : next destination address
|
2006-05-01 22:35:19 +00:00
|
|
|
* Corrupts:
|
2011-01-26 23:04:43 +00:00
|
|
|
* None
|
2006-05-01 21:26:44 +00:00
|
|
|
****************************************************************************
|
|
|
|
|
*/
|
[i386] Add explicit flags and type on all .section declarations
Try to avoid future problems caused by implicit section flags and/or
type information by instituting a policy that all .section
declarations must explicitly state the flags and type.
Most of this change was achieved using
perl -pi \
-e 's/".text"$/".text", "ax", \@progbits/ ; ' \
-e 's/".text16"$/".text16", "ax", \@progbits/ ; ' \
-e 's/".text16.null"$/".text16.null", "ax", \@progbits/ ; ' \
-e 's/".text16.data"$/".text16.data", "aw", \@progbits/ ; ' \
-e 's/".data"$/".data", "aw", \@progbits/ ; ' \
-e 's/".data16"$/".data16", "aw", \@progbits/ ; ' \
-e 's/".bss"$/".bss", "aw", \@nobits/ ; ' \
-e 's/".bss16"$/".bss16", "aw", \@nobits/ ; ' \
-e 's/".prefix"$/".prefix", "ax", \@progbits/ ; ' \
-e 's/".prefix.lib"$/".prefix.lib", "awx", \@progbits/ ; ' \
-e 's/".prefix.data"$/".prefix.data", "aw", \@progbits/ ; ' \
-e 's/".weak"$/".weak", "a", \@nobits/ ; ' \
`git grep -l '\.section'`
2009-02-15 10:54:52 +00:00
|
|
|
.section ".prefix.lib", "awx", @progbits
|
2006-05-01 21:26:44 +00:00
|
|
|
.code16
|
2011-01-26 23:04:43 +00:00
|
|
|
zero_bytes:
|
|
|
|
|
pushl %ecx
|
|
|
|
|
pushw %ax
|
|
|
|
|
xorw %ax, %ax
|
|
|
|
|
rep addr32 stosb
|
|
|
|
|
popw %ax
|
|
|
|
|
popl %ecx
|
|
|
|
|
ret
|
|
|
|
|
.size zero_bytes, . - zero_bytes
|
|
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
|
* process_bytes
|
|
|
|
|
*
|
|
|
|
|
* Call memcpy()-like function
|
|
|
|
|
*
|
|
|
|
|
* Parameters:
|
|
|
|
|
* %esi : source physical address
|
|
|
|
|
* %edi : destination physical address
|
|
|
|
|
* %ecx : length
|
|
|
|
|
* %bx : memcpy()-like function to call, passing parameters:
|
|
|
|
|
* %ds:esi : source address
|
|
|
|
|
* %es:edi : destination address
|
|
|
|
|
* %ecx : length
|
|
|
|
|
* and returning:
|
|
|
|
|
* %ds:esi : next source address
|
|
|
|
|
* %es:edi : next destination address
|
|
|
|
|
* Returns:
|
|
|
|
|
* %esi : next source physical address
|
|
|
|
|
* %edi : next destination physical address
|
|
|
|
|
* Corrupts:
|
|
|
|
|
* None
|
|
|
|
|
****************************************************************************
|
|
|
|
|
*/
|
|
|
|
|
.section ".prefix.lib", "awx", @progbits
|
|
|
|
|
.code16
|
|
|
|
|
process_bytes:
|
|
|
|
|
|
|
|
|
|
#ifndef KEEP_IT_REAL
|
|
|
|
|
|
2008-03-09 22:13:07 +00:00
|
|
|
/* Preserve registers */
|
2011-01-26 23:04:43 +00:00
|
|
|
pushl %eax
|
|
|
|
|
pushl %ebp
|
|
|
|
|
|
|
|
|
|
/* Construct GDT on stack (since .prefix may not be writable) */
|
|
|
|
|
.equ PM_DS, 0x18 /* Flat data segment */
|
2011-03-01 16:03:44 +00:00
|
|
|
pushl $0x00cf9300
|
2011-01-26 23:04:43 +00:00
|
|
|
pushl $0x0000ffff
|
|
|
|
|
.equ PM_SS, 0x10 /* Stack segment based at %ss:0000 */
|
|
|
|
|
pushl $0x008f0930
|
|
|
|
|
pushw %ss
|
|
|
|
|
pushw $0xffff
|
|
|
|
|
.equ PM_CS, 0x08 /* Code segment based at %cs:0000 */
|
|
|
|
|
pushl $0x008f09b0
|
|
|
|
|
pushw %cs
|
|
|
|
|
pushw $0xffff
|
|
|
|
|
pushl $0 /* Base and length */
|
|
|
|
|
pushw %ss
|
|
|
|
|
pushw $0x1f
|
|
|
|
|
movzwl %sp, %ebp
|
|
|
|
|
shll $4, 0x02(%bp)
|
|
|
|
|
addl %ebp, 0x02(%bp)
|
|
|
|
|
shll $4, 0x0a(%bp)
|
|
|
|
|
shll $4, 0x12(%bp)
|
|
|
|
|
subw $8, %sp
|
|
|
|
|
sgdt -8(%bp)
|
|
|
|
|
|
|
|
|
|
/* Switch to protected mode */
|
|
|
|
|
pushw %gs
|
|
|
|
|
pushw %fs
|
|
|
|
|
pushw %es
|
|
|
|
|
pushw %ds
|
|
|
|
|
pushw %ss
|
|
|
|
|
pushw %cs
|
|
|
|
|
pushw $2f
|
|
|
|
|
cli
|
|
|
|
|
data32 lgdt (%bp)
|
|
|
|
|
movl %cr0, %eax
|
|
|
|
|
orb $CR0_PE, %al
|
|
|
|
|
movl %eax, %cr0
|
|
|
|
|
ljmp $PM_CS, $1f
|
|
|
|
|
1: movw $PM_SS, %ax
|
|
|
|
|
movw %ax, %ss
|
|
|
|
|
movw $PM_DS, %ax
|
|
|
|
|
movw %ax, %ds
|
|
|
|
|
movw %ax, %es
|
|
|
|
|
movw %ax, %fs
|
|
|
|
|
movw %ax, %gs
|
|
|
|
|
|
|
|
|
|
/* Call memcpy()-like function */
|
|
|
|
|
call *%bx
|
|
|
|
|
|
|
|
|
|
/* Return to (flat) real mode */
|
|
|
|
|
movl %cr0, %eax
|
|
|
|
|
andb $0!CR0_PE, %al
|
|
|
|
|
movl %eax, %cr0
|
|
|
|
|
lret
|
|
|
|
|
2: /* lret will ljmp to here */
|
|
|
|
|
popw %ss
|
|
|
|
|
popw %ds
|
|
|
|
|
popw %es
|
|
|
|
|
popw %fs
|
|
|
|
|
popw %gs
|
|
|
|
|
|
|
|
|
|
/* Restore GDT */
|
|
|
|
|
data32 lgdt -8(%bp)
|
|
|
|
|
addw $( 8 /* saved GDT */ + ( PM_DS + 8 ) /* GDT on stack */ ), %sp
|
|
|
|
|
|
|
|
|
|
/* Restore registers and return */
|
|
|
|
|
popl %ebp
|
|
|
|
|
popl %eax
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
#else /* KEEP_IT_REAL */
|
|
|
|
|
|
|
|
|
|
/* Preserve registers */
|
|
|
|
|
pushl %eax
|
2008-03-11 13:26:46 +00:00
|
|
|
pushw %ds
|
|
|
|
|
pushw %es
|
2008-03-09 22:13:07 +00:00
|
|
|
|
2010-04-19 22:22:11 +01:00
|
|
|
/* Convert %esi and %edi to %ds:esi and %es:edi */
|
2008-03-11 13:26:46 +00:00
|
|
|
shrl $4, %esi
|
|
|
|
|
movw %si, %ds
|
|
|
|
|
xorw %si, %si
|
2010-04-19 22:22:11 +01:00
|
|
|
shll $4, %esi
|
2008-03-11 13:26:46 +00:00
|
|
|
shrl $4, %edi
|
|
|
|
|
movw %di, %es
|
|
|
|
|
xorw %di, %di
|
2010-04-19 22:22:11 +01:00
|
|
|
shll $4, %edi
|
2008-03-11 13:26:46 +00:00
|
|
|
|
2011-01-26 23:04:43 +00:00
|
|
|
/* Call memcpy()-like function */
|
|
|
|
|
call *%bx
|
|
|
|
|
|
|
|
|
|
/* Convert %ds:esi and %es:edi back to physical addresses */
|
|
|
|
|
xorl %eax, %eax
|
|
|
|
|
movw %ds, %cx
|
|
|
|
|
shll $4, %eax
|
|
|
|
|
addl %eax, %esi
|
|
|
|
|
xorl %eax, %eax
|
|
|
|
|
movw %es, %cx
|
|
|
|
|
shll $4, %eax
|
|
|
|
|
addl %eax, %edi
|
|
|
|
|
|
|
|
|
|
/* Restore registers and return */
|
|
|
|
|
popw %es
|
|
|
|
|
popw %ds
|
|
|
|
|
popl %eax
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
#endif /* KEEP_IT_REAL */
|
|
|
|
|
|
|
|
|
|
.size process_bytes, . - process_bytes
|
|
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
|
* install_block
|
|
|
|
|
*
|
|
|
|
|
* Install block to specified address
|
|
|
|
|
*
|
|
|
|
|
* Parameters:
|
|
|
|
|
* %esi : source physical address (must be a multiple of 16)
|
|
|
|
|
* %edi : destination physical address (must be a multiple of 16)
|
|
|
|
|
* %ecx : length of (decompressed) data
|
|
|
|
|
* %edx : total length of block (including any uninitialised data portion)
|
|
|
|
|
* Returns:
|
|
|
|
|
* %esi : next source physical address (will be a multiple of 16)
|
|
|
|
|
* %edi : next destination physical address (will be a multiple of 16)
|
|
|
|
|
* Corrupts:
|
|
|
|
|
* none
|
|
|
|
|
****************************************************************************
|
|
|
|
|
*/
|
|
|
|
|
.section ".prefix.lib", "awx", @progbits
|
|
|
|
|
.code16
|
|
|
|
|
install_block:
|
|
|
|
|
/* Preserve registers */
|
|
|
|
|
pushl %ecx
|
|
|
|
|
pushw %bx
|
|
|
|
|
|
|
|
|
|
/* Decompress (or copy) source to destination */
|
2007-07-16 16:58:38 +01:00
|
|
|
#if COMPRESS
|
2011-01-26 23:04:43 +00:00
|
|
|
movw $decompress16, %bx
|
2007-07-16 16:58:38 +01:00
|
|
|
#else
|
2011-01-26 23:04:43 +00:00
|
|
|
movw $copy_bytes, %bx
|
2007-07-16 16:58:38 +01:00
|
|
|
#endif
|
2011-01-26 23:04:43 +00:00
|
|
|
call process_bytes
|
2006-05-02 20:51:07 +00:00
|
|
|
|
2007-09-25 18:01:15 +01:00
|
|
|
/* Zero .bss portion */
|
|
|
|
|
negl %ecx
|
|
|
|
|
addl %edx, %ecx
|
2011-01-26 23:04:43 +00:00
|
|
|
movw $zero_bytes, %bx
|
|
|
|
|
call process_bytes
|
2006-05-01 22:35:19 +00:00
|
|
|
|
2010-04-20 11:05:53 +01:00
|
|
|
/* Round up %esi and %edi to start of next blocks */
|
2007-07-15 02:52:02 +01:00
|
|
|
addl $0xf, %esi
|
|
|
|
|
andl $~0xf, %esi
|
2010-04-20 11:05:53 +01:00
|
|
|
addl $0xf, %edi
|
|
|
|
|
andl $~0xf, %edi
|
2007-07-15 02:52:02 +01:00
|
|
|
|
2010-04-19 22:22:11 +01:00
|
|
|
/* Restore registers and return */
|
2011-01-26 23:04:43 +00:00
|
|
|
popw %bx
|
2008-03-11 13:26:46 +00:00
|
|
|
popl %ecx
|
2006-05-01 22:35:19 +00:00
|
|
|
ret
|
|
|
|
|
.size install_block, . - install_block
|
2010-04-19 22:22:11 +01:00
|
|
|
|
2006-05-01 22:35:19 +00:00
|
|
|
/****************************************************************************
|
2010-04-19 22:22:11 +01:00
|
|
|
* alloc_basemem
|
2006-05-01 22:35:19 +00:00
|
|
|
*
|
|
|
|
|
* Allocate space for .text16 and .data16 from top of base memory.
|
|
|
|
|
* Memory is allocated using the BIOS free base memory counter at
|
|
|
|
|
* 0x40:13.
|
|
|
|
|
*
|
|
|
|
|
* Parameters:
|
|
|
|
|
* none
|
|
|
|
|
* Returns:
|
|
|
|
|
* %ax : .text16 segment address
|
|
|
|
|
* %bx : .data16 segment address
|
|
|
|
|
* Corrupts:
|
|
|
|
|
* none
|
|
|
|
|
****************************************************************************
|
|
|
|
|
*/
|
[i386] Add explicit flags and type on all .section declarations
Try to avoid future problems caused by implicit section flags and/or
type information by instituting a policy that all .section
declarations must explicitly state the flags and type.
Most of this change was achieved using
perl -pi \
-e 's/".text"$/".text", "ax", \@progbits/ ; ' \
-e 's/".text16"$/".text16", "ax", \@progbits/ ; ' \
-e 's/".text16.null"$/".text16.null", "ax", \@progbits/ ; ' \
-e 's/".text16.data"$/".text16.data", "aw", \@progbits/ ; ' \
-e 's/".data"$/".data", "aw", \@progbits/ ; ' \
-e 's/".data16"$/".data16", "aw", \@progbits/ ; ' \
-e 's/".bss"$/".bss", "aw", \@nobits/ ; ' \
-e 's/".bss16"$/".bss16", "aw", \@nobits/ ; ' \
-e 's/".prefix"$/".prefix", "ax", \@progbits/ ; ' \
-e 's/".prefix.lib"$/".prefix.lib", "awx", \@progbits/ ; ' \
-e 's/".prefix.data"$/".prefix.data", "aw", \@progbits/ ; ' \
-e 's/".weak"$/".weak", "a", \@nobits/ ; ' \
`git grep -l '\.section'`
2009-02-15 10:54:52 +00:00
|
|
|
.section ".prefix.lib", "awx", @progbits
|
2006-05-01 22:35:19 +00:00
|
|
|
.code16
|
2008-03-09 22:13:07 +00:00
|
|
|
.globl alloc_basemem
|
2006-05-01 22:35:19 +00:00
|
|
|
alloc_basemem:
|
2008-11-18 19:43:13 +00:00
|
|
|
/* Preserve registers */
|
|
|
|
|
pushw %fs
|
|
|
|
|
|
2006-05-01 22:35:19 +00:00
|
|
|
/* FBMS => %ax as segment address */
|
2008-11-18 19:43:13 +00:00
|
|
|
pushw $0x40
|
|
|
|
|
popw %fs
|
2006-05-01 21:26:44 +00:00
|
|
|
movw %fs:0x13, %ax
|
|
|
|
|
shlw $6, %ax
|
|
|
|
|
|
2008-11-18 19:43:13 +00:00
|
|
|
/* Calculate .data16 segment address */
|
2008-10-09 22:22:01 +01:00
|
|
|
subw $_data16_memsz_pgh, %ax
|
2006-05-01 22:35:19 +00:00
|
|
|
pushw %ax
|
|
|
|
|
|
2014-05-02 13:18:55 +01:00
|
|
|
/* Calculate .text16 segment address. Round down to ensure
|
|
|
|
|
* low bits are zero, to speed up mode transitions under KVM.
|
|
|
|
|
*/
|
2008-10-09 22:22:01 +01:00
|
|
|
subw $_text16_memsz_pgh, %ax
|
2014-05-02 13:18:55 +01:00
|
|
|
andb $~0x03, %al
|
2006-05-01 22:35:19 +00:00
|
|
|
pushw %ax
|
|
|
|
|
|
|
|
|
|
/* Update FBMS */
|
|
|
|
|
shrw $6, %ax
|
|
|
|
|
movw %ax, %fs:0x13
|
|
|
|
|
|
2008-11-18 19:43:13 +00:00
|
|
|
/* Retrieve .text16 and .data16 segment addresses */
|
2006-05-01 21:26:44 +00:00
|
|
|
popw %ax
|
2006-05-01 22:35:19 +00:00
|
|
|
popw %bx
|
2008-11-18 19:43:13 +00:00
|
|
|
|
|
|
|
|
/* Restore registers and return */
|
|
|
|
|
popw %fs
|
2006-05-01 21:26:44 +00:00
|
|
|
ret
|
2006-05-01 22:35:19 +00:00
|
|
|
.size alloc_basemem, . - alloc_basemem
|
2006-05-01 21:26:44 +00:00
|
|
|
|
2008-11-18 19:43:13 +00:00
|
|
|
/****************************************************************************
|
2010-04-19 22:22:11 +01:00
|
|
|
* free_basemem
|
2008-11-18 19:43:13 +00:00
|
|
|
*
|
|
|
|
|
* Free space allocated with alloc_basemem.
|
|
|
|
|
*
|
|
|
|
|
* Parameters:
|
2013-03-08 13:26:22 +00:00
|
|
|
* none (.text16 segment address is implicit in %cs)
|
2008-11-18 19:43:13 +00:00
|
|
|
* Returns:
|
|
|
|
|
* %ax : 0 if successfully freed
|
|
|
|
|
* Corrupts:
|
|
|
|
|
* none
|
|
|
|
|
****************************************************************************
|
|
|
|
|
*/
|
[i386] Add explicit flags and type on all .section declarations
Try to avoid future problems caused by implicit section flags and/or
type information by instituting a policy that all .section
declarations must explicitly state the flags and type.
Most of this change was achieved using
perl -pi \
-e 's/".text"$/".text", "ax", \@progbits/ ; ' \
-e 's/".text16"$/".text16", "ax", \@progbits/ ; ' \
-e 's/".text16.null"$/".text16.null", "ax", \@progbits/ ; ' \
-e 's/".text16.data"$/".text16.data", "aw", \@progbits/ ; ' \
-e 's/".data"$/".data", "aw", \@progbits/ ; ' \
-e 's/".data16"$/".data16", "aw", \@progbits/ ; ' \
-e 's/".bss"$/".bss", "aw", \@nobits/ ; ' \
-e 's/".bss16"$/".bss16", "aw", \@nobits/ ; ' \
-e 's/".prefix"$/".prefix", "ax", \@progbits/ ; ' \
-e 's/".prefix.lib"$/".prefix.lib", "awx", \@progbits/ ; ' \
-e 's/".prefix.data"$/".prefix.data", "aw", \@progbits/ ; ' \
-e 's/".weak"$/".weak", "a", \@nobits/ ; ' \
`git grep -l '\.section'`
2009-02-15 10:54:52 +00:00
|
|
|
.section ".text16", "ax", @progbits
|
2008-11-18 19:43:13 +00:00
|
|
|
.code16
|
|
|
|
|
.globl free_basemem
|
|
|
|
|
free_basemem:
|
|
|
|
|
/* Preserve registers */
|
|
|
|
|
pushw %fs
|
2013-03-08 13:26:22 +00:00
|
|
|
pushw %ax
|
2008-11-18 19:43:13 +00:00
|
|
|
|
|
|
|
|
/* Check FBMS counter */
|
2013-03-08 13:26:22 +00:00
|
|
|
movw %cs, %ax
|
2008-11-18 19:43:13 +00:00
|
|
|
shrw $6, %ax
|
|
|
|
|
pushw $0x40
|
|
|
|
|
popw %fs
|
|
|
|
|
cmpw %ax, %fs:0x13
|
|
|
|
|
jne 1f
|
|
|
|
|
|
|
|
|
|
/* Check hooked interrupt count */
|
|
|
|
|
cmpw $0, %cs:hooked_bios_interrupts
|
|
|
|
|
jne 1f
|
|
|
|
|
|
|
|
|
|
/* OK to free memory */
|
2013-03-08 13:26:22 +00:00
|
|
|
movw %cs, %ax
|
2008-11-18 19:43:13 +00:00
|
|
|
addw $_text16_memsz_pgh, %ax
|
|
|
|
|
addw $_data16_memsz_pgh, %ax
|
|
|
|
|
shrw $6, %ax
|
|
|
|
|
movw %ax, %fs:0x13
|
|
|
|
|
xorw %ax, %ax
|
|
|
|
|
|
|
|
|
|
1: /* Restore registers and return */
|
2013-03-08 13:26:22 +00:00
|
|
|
popw %ax
|
2008-11-18 19:43:13 +00:00
|
|
|
popw %fs
|
|
|
|
|
ret
|
|
|
|
|
.size free_basemem, . - free_basemem
|
|
|
|
|
|
[i386] Add explicit flags and type on all .section declarations
Try to avoid future problems caused by implicit section flags and/or
type information by instituting a policy that all .section
declarations must explicitly state the flags and type.
Most of this change was achieved using
perl -pi \
-e 's/".text"$/".text", "ax", \@progbits/ ; ' \
-e 's/".text16"$/".text16", "ax", \@progbits/ ; ' \
-e 's/".text16.null"$/".text16.null", "ax", \@progbits/ ; ' \
-e 's/".text16.data"$/".text16.data", "aw", \@progbits/ ; ' \
-e 's/".data"$/".data", "aw", \@progbits/ ; ' \
-e 's/".data16"$/".data16", "aw", \@progbits/ ; ' \
-e 's/".bss"$/".bss", "aw", \@nobits/ ; ' \
-e 's/".bss16"$/".bss16", "aw", \@nobits/ ; ' \
-e 's/".prefix"$/".prefix", "ax", \@progbits/ ; ' \
-e 's/".prefix.lib"$/".prefix.lib", "awx", \@progbits/ ; ' \
-e 's/".prefix.data"$/".prefix.data", "aw", \@progbits/ ; ' \
-e 's/".weak"$/".weak", "a", \@nobits/ ; ' \
`git grep -l '\.section'`
2009-02-15 10:54:52 +00:00
|
|
|
.section ".text16.data", "aw", @progbits
|
2008-11-18 19:43:13 +00:00
|
|
|
.globl hooked_bios_interrupts
|
|
|
|
|
hooked_bios_interrupts:
|
|
|
|
|
.word 0
|
|
|
|
|
.size hooked_bios_interrupts, . - hooked_bios_interrupts
|
|
|
|
|
|
2006-05-02 20:51:07 +00:00
|
|
|
/****************************************************************************
|
2010-04-19 22:22:11 +01:00
|
|
|
* install
|
2006-05-02 20:51:07 +00:00
|
|
|
*
|
|
|
|
|
* Install all text and data segments.
|
|
|
|
|
*
|
|
|
|
|
* Parameters:
|
2008-03-09 22:13:07 +00:00
|
|
|
* none
|
2006-05-02 20:51:07 +00:00
|
|
|
* Returns:
|
2008-03-09 22:13:07 +00:00
|
|
|
* %ax : .text16 segment address
|
|
|
|
|
* %bx : .data16 segment address
|
2006-05-02 20:51:07 +00:00
|
|
|
* Corrupts:
|
|
|
|
|
* none
|
|
|
|
|
****************************************************************************
|
|
|
|
|
*/
|
[i386] Add explicit flags and type on all .section declarations
Try to avoid future problems caused by implicit section flags and/or
type information by instituting a policy that all .section
declarations must explicitly state the flags and type.
Most of this change was achieved using
perl -pi \
-e 's/".text"$/".text", "ax", \@progbits/ ; ' \
-e 's/".text16"$/".text16", "ax", \@progbits/ ; ' \
-e 's/".text16.null"$/".text16.null", "ax", \@progbits/ ; ' \
-e 's/".text16.data"$/".text16.data", "aw", \@progbits/ ; ' \
-e 's/".data"$/".data", "aw", \@progbits/ ; ' \
-e 's/".data16"$/".data16", "aw", \@progbits/ ; ' \
-e 's/".bss"$/".bss", "aw", \@nobits/ ; ' \
-e 's/".bss16"$/".bss16", "aw", \@nobits/ ; ' \
-e 's/".prefix"$/".prefix", "ax", \@progbits/ ; ' \
-e 's/".prefix.lib"$/".prefix.lib", "awx", \@progbits/ ; ' \
-e 's/".prefix.data"$/".prefix.data", "aw", \@progbits/ ; ' \
-e 's/".weak"$/".weak", "a", \@nobits/ ; ' \
`git grep -l '\.section'`
2009-02-15 10:54:52 +00:00
|
|
|
.section ".prefix.lib", "awx", @progbits
|
2006-05-02 20:51:07 +00:00
|
|
|
.code16
|
|
|
|
|
.globl install
|
|
|
|
|
install:
|
2011-03-01 14:49:25 +00:00
|
|
|
progress "install:\n"
|
2008-03-09 22:13:07 +00:00
|
|
|
/* Preserve registers */
|
|
|
|
|
pushl %esi
|
|
|
|
|
pushl %edi
|
2011-11-11 23:20:28 +00:00
|
|
|
pushl %ebp
|
2006-05-02 20:51:07 +00:00
|
|
|
/* Allocate space for .text16 and .data16 */
|
|
|
|
|
call alloc_basemem
|
2008-03-09 22:13:07 +00:00
|
|
|
/* Image source = %cs:0000 */
|
|
|
|
|
xorl %esi, %esi
|
2010-04-24 22:22:54 +01:00
|
|
|
/* Image destination = default */
|
|
|
|
|
xorl %edi, %edi
|
2011-11-11 23:20:28 +00:00
|
|
|
/* Allow arbitrary relocation */
|
[pcbios] Inhibit all calls to INT 15,e820 and INT 15,e801 during POST
Many BIOSes do not construct the full system memory map until after
calling the option ROM initialisation entry points. For several
years, we have added sanity checks and workarounds to accommodate
charming quirks such as BIOSes which report the entire 32-bit address
space (including all memory-mapped PCI BARs) as being usable RAM.
The IBM x3650 takes quirky behaviour to a new extreme. Calling either
INT 15,e820 or INT 15,e801 during POST doesn't just get you invalid
data. We could cope with invalid data. Instead, these nominally
read-only API calls manage to trash some internal BIOS state, with the
result that the system memory map is _never_ constructed. This tends
to confuse subsequent bootloaders and operating systems.
[ GRUB 0.97 fails in a particularly amusing way. Someone thought it
would be a good idea for memcpy() to check that the destination memory
region is a valid part of the system memory map; if not, then memcpy()
will sulk, fail, and return NULL. This breaks pretty much every use
of memcpy() including, for example, those inserted implicitly by gcc
to copy non-const initialisers. Debugging is _fun_ when a simple call
to printf() manages to create an infinite recursion, exhaust the
available stack space, and shut down the CPU. ]
Fix by completely inhibiting calls to INT 15,e820 and INT 15,e801
during POST.
We do now allow relocation during POST up to the maximum address
returned by INT 15,88 (which seems so far to always be safe). This
allows us to continue to have a reasonable size of external heap, even
if the PMM allocation is close to the 1MB mark.
The downside of allowing relocation during POST is that we may
overwrite PMM-allocated memory in use by other option ROMs. However,
the downside of inhibiting relocation, when combined with also
inhibiting calls to INT 15,e820 and INT 15,e801, would be that we
might have no external heap available: this would make booting an OS
impossible and could prevent some devices from even completing
initialisation.
On balance, the lesser evil is probably to allow relocation during
POST (up to the limit provided by INT 15,88). Entering iPXE during
POST is a rare operation; on the even rarer systems where doing so
happens to overwrite a PMM-allocated region, then there exists a
fairly simple workaround: if the user enters iPXE during POST and
wishes to exit iPXE, then the user must reboot. This is an acceptable
cost, given the rarity of the situation and the simplicity of the
workaround.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-03-11 00:50:52 +00:00
|
|
|
orl $0xffffffff, %ebp
|
2008-03-09 22:13:07 +00:00
|
|
|
/* Install text and data segments */
|
|
|
|
|
call install_prealloc
|
|
|
|
|
/* Restore registers and return */
|
2011-11-11 23:20:28 +00:00
|
|
|
popl %ebp
|
2008-03-09 22:13:07 +00:00
|
|
|
popl %edi
|
|
|
|
|
popl %esi
|
|
|
|
|
ret
|
2006-05-02 20:51:07 +00:00
|
|
|
.size install, . - install
|
2008-03-09 22:13:07 +00:00
|
|
|
|
|
|
|
|
/****************************************************************************
|
2010-04-19 22:22:11 +01:00
|
|
|
* install_prealloc
|
2008-03-09 22:13:07 +00:00
|
|
|
*
|
|
|
|
|
* Install all text and data segments.
|
|
|
|
|
*
|
|
|
|
|
* Parameters:
|
|
|
|
|
* %ax : .text16 segment address
|
|
|
|
|
* %bx : .data16 segment address
|
|
|
|
|
* %esi : Image source physical address (or zero for %cs:0000)
|
2010-04-24 22:22:54 +01:00
|
|
|
* %edi : Decompression temporary area physical address (or zero for default)
|
[pcbios] Inhibit all calls to INT 15,e820 and INT 15,e801 during POST
Many BIOSes do not construct the full system memory map until after
calling the option ROM initialisation entry points. For several
years, we have added sanity checks and workarounds to accommodate
charming quirks such as BIOSes which report the entire 32-bit address
space (including all memory-mapped PCI BARs) as being usable RAM.
The IBM x3650 takes quirky behaviour to a new extreme. Calling either
INT 15,e820 or INT 15,e801 during POST doesn't just get you invalid
data. We could cope with invalid data. Instead, these nominally
read-only API calls manage to trash some internal BIOS state, with the
result that the system memory map is _never_ constructed. This tends
to confuse subsequent bootloaders and operating systems.
[ GRUB 0.97 fails in a particularly amusing way. Someone thought it
would be a good idea for memcpy() to check that the destination memory
region is a valid part of the system memory map; if not, then memcpy()
will sulk, fail, and return NULL. This breaks pretty much every use
of memcpy() including, for example, those inserted implicitly by gcc
to copy non-const initialisers. Debugging is _fun_ when a simple call
to printf() manages to create an infinite recursion, exhaust the
available stack space, and shut down the CPU. ]
Fix by completely inhibiting calls to INT 15,e820 and INT 15,e801
during POST.
We do now allow relocation during POST up to the maximum address
returned by INT 15,88 (which seems so far to always be safe). This
allows us to continue to have a reasonable size of external heap, even
if the PMM allocation is close to the 1MB mark.
The downside of allowing relocation during POST is that we may
overwrite PMM-allocated memory in use by other option ROMs. However,
the downside of inhibiting relocation, when combined with also
inhibiting calls to INT 15,e820 and INT 15,e801, would be that we
might have no external heap available: this would make booting an OS
impossible and could prevent some devices from even completing
initialisation.
On balance, the lesser evil is probably to allow relocation during
POST (up to the limit provided by INT 15,88). Entering iPXE during
POST is a rare operation; on the even rarer systems where doing so
happens to overwrite a PMM-allocated region, then there exists a
fairly simple workaround: if the user enters iPXE during POST and
wishes to exit iPXE, then the user must reboot. This is an acceptable
cost, given the rarity of the situation and the simplicity of the
workaround.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-03-11 00:50:52 +00:00
|
|
|
* %ebp : Maximum end address for relocation
|
|
|
|
|
* - 0xffffffff for no maximum
|
|
|
|
|
* - 0x00000000 to inhibit use of INT 15,e820 and INT 15,e801
|
2008-03-09 22:13:07 +00:00
|
|
|
* Corrupts:
|
|
|
|
|
* none
|
|
|
|
|
****************************************************************************
|
|
|
|
|
*/
|
[i386] Add explicit flags and type on all .section declarations
Try to avoid future problems caused by implicit section flags and/or
type information by instituting a policy that all .section
declarations must explicitly state the flags and type.
Most of this change was achieved using
perl -pi \
-e 's/".text"$/".text", "ax", \@progbits/ ; ' \
-e 's/".text16"$/".text16", "ax", \@progbits/ ; ' \
-e 's/".text16.null"$/".text16.null", "ax", \@progbits/ ; ' \
-e 's/".text16.data"$/".text16.data", "aw", \@progbits/ ; ' \
-e 's/".data"$/".data", "aw", \@progbits/ ; ' \
-e 's/".data16"$/".data16", "aw", \@progbits/ ; ' \
-e 's/".bss"$/".bss", "aw", \@nobits/ ; ' \
-e 's/".bss16"$/".bss16", "aw", \@nobits/ ; ' \
-e 's/".prefix"$/".prefix", "ax", \@progbits/ ; ' \
-e 's/".prefix.lib"$/".prefix.lib", "awx", \@progbits/ ; ' \
-e 's/".prefix.data"$/".prefix.data", "aw", \@progbits/ ; ' \
-e 's/".weak"$/".weak", "a", \@nobits/ ; ' \
`git grep -l '\.section'`
2009-02-15 10:54:52 +00:00
|
|
|
.section ".prefix.lib", "awx", @progbits
|
2008-03-09 22:13:07 +00:00
|
|
|
.code16
|
2006-05-02 20:51:07 +00:00
|
|
|
.globl install_prealloc
|
|
|
|
|
install_prealloc:
|
2011-03-01 14:49:25 +00:00
|
|
|
progress "install_prealloc:\n"
|
2007-07-15 02:52:02 +01:00
|
|
|
/* Save registers */
|
2008-03-09 22:13:07 +00:00
|
|
|
pushal
|
2007-09-25 18:01:15 +01:00
|
|
|
pushw %ds
|
2007-09-25 19:06:38 +01:00
|
|
|
pushw %es
|
2010-04-25 01:37:25 +01:00
|
|
|
cld /* Sanity: clear the direction flag asap */
|
2007-09-25 18:01:15 +01:00
|
|
|
|
2010-04-25 15:57:00 +01:00
|
|
|
/* Set up %ds for (read-only) access to .prefix */
|
|
|
|
|
pushw %cs
|
|
|
|
|
popw %ds
|
|
|
|
|
|
2011-11-11 22:23:13 +00:00
|
|
|
/* Save decompression temporary area physical address */
|
|
|
|
|
pushl %edi
|
2010-04-20 11:05:53 +01:00
|
|
|
|
2012-06-10 18:25:26 +01:00
|
|
|
/* Install .text16.early and calculate %ecx as offset to next block */
|
2011-03-01 14:49:25 +00:00
|
|
|
progress " .text16.early\n"
|
2010-04-20 11:05:53 +01:00
|
|
|
pushl %esi
|
|
|
|
|
xorl %esi, %esi
|
|
|
|
|
movw %cs, %si
|
|
|
|
|
shll $4, %esi
|
2012-06-10 18:25:26 +01:00
|
|
|
pushl %esi /* Save original %cs:0000 */
|
2010-04-20 11:05:53 +01:00
|
|
|
addl $_text16_early_lma, %esi
|
|
|
|
|
movzwl %ax, %edi
|
|
|
|
|
shll $4, %edi
|
|
|
|
|
movl $_text16_early_filesz, %ecx
|
|
|
|
|
movl $_text16_early_memsz, %edx
|
|
|
|
|
call install_block /* .text16.early */
|
2012-06-10 18:25:26 +01:00
|
|
|
popl %ecx /* Calculate offset to next block */
|
|
|
|
|
subl %esi, %ecx
|
|
|
|
|
negl %ecx
|
2010-04-20 11:05:53 +01:00
|
|
|
popl %esi
|
|
|
|
|
|
2010-04-19 22:22:11 +01:00
|
|
|
#ifndef KEEP_IT_REAL
|
2011-01-26 23:20:48 +00:00
|
|
|
/* Access high memory by enabling the A20 gate. (We will
|
|
|
|
|
* already have 4GB segment limits as a result of calling
|
|
|
|
|
* install_block.)
|
|
|
|
|
*/
|
2011-03-01 14:49:25 +00:00
|
|
|
progress " access_highmem\n"
|
2010-04-20 12:59:48 +01:00
|
|
|
pushw %cs
|
|
|
|
|
pushw $1f
|
|
|
|
|
pushw %ax
|
2010-04-20 18:49:43 +01:00
|
|
|
pushw $access_highmem
|
2010-04-20 12:59:48 +01:00
|
|
|
lret
|
2010-04-20 18:49:43 +01:00
|
|
|
1: /* Die if we could not access high memory */
|
|
|
|
|
jnc 3f
|
|
|
|
|
movw $a20_death_message, %si
|
|
|
|
|
xorw %di, %di
|
|
|
|
|
call print_message
|
|
|
|
|
2: jmp 2b
|
|
|
|
|
.section ".prefix.data", "aw", @progbits
|
|
|
|
|
a20_death_message:
|
2010-04-25 15:57:00 +01:00
|
|
|
.asciz "\nHigh memory inaccessible - cannot continue\n"
|
2010-04-20 18:49:43 +01:00
|
|
|
.size a20_death_message, . - a20_death_message
|
|
|
|
|
.previous
|
|
|
|
|
3:
|
2010-04-19 22:22:11 +01:00
|
|
|
#endif
|
|
|
|
|
|
2010-04-25 15:57:00 +01:00
|
|
|
/* Open payload (which may not yet be in memory) */
|
2011-03-01 14:49:25 +00:00
|
|
|
progress " open_payload\n"
|
2010-04-25 15:57:00 +01:00
|
|
|
pushw %cs
|
|
|
|
|
pushw $1f
|
|
|
|
|
pushw %ax
|
|
|
|
|
pushw $open_payload
|
|
|
|
|
lret
|
|
|
|
|
1: /* Die if we could not access the payload */
|
|
|
|
|
jnc 3f
|
|
|
|
|
xorw %di, %di
|
|
|
|
|
movl %esi, %eax
|
|
|
|
|
call print_hex_dword
|
2014-08-26 14:53:46 +01:00
|
|
|
call print_space
|
|
|
|
|
movl %ecx, %eax
|
|
|
|
|
call print_hex_dword
|
2010-04-25 15:57:00 +01:00
|
|
|
movw $payload_death_message, %si
|
|
|
|
|
call print_message
|
2014-08-26 14:46:14 +01:00
|
|
|
2: /* Halt system */
|
|
|
|
|
cli
|
|
|
|
|
hlt
|
|
|
|
|
jmp 2b
|
2010-04-25 15:57:00 +01:00
|
|
|
.section ".prefix.data", "aw", @progbits
|
|
|
|
|
payload_death_message:
|
|
|
|
|
.asciz "\nPayload inaccessible - cannot continue\n"
|
|
|
|
|
.size payload_death_message, . - payload_death_message
|
|
|
|
|
.previous
|
|
|
|
|
3:
|
|
|
|
|
|
2007-09-25 18:01:15 +01:00
|
|
|
/* Calculate physical address of payload (i.e. first source) */
|
2008-03-09 22:13:07 +00:00
|
|
|
testl %esi, %esi
|
|
|
|
|
jnz 1f
|
2007-09-25 18:01:15 +01:00
|
|
|
movw %cs, %si
|
|
|
|
|
shll $4, %esi
|
2012-06-10 18:25:26 +01:00
|
|
|
1: addl %ecx, %esi
|
2007-09-25 18:01:15 +01:00
|
|
|
|
2010-04-20 11:05:53 +01:00
|
|
|
/* Install .text16.late and .data16 */
|
2011-03-01 14:49:25 +00:00
|
|
|
progress " .text16.late\n"
|
2010-04-20 11:05:53 +01:00
|
|
|
movl $_text16_late_filesz, %ecx
|
|
|
|
|
movl $_text16_late_memsz, %edx
|
|
|
|
|
call install_block /* .text16.late */
|
2011-03-01 14:49:25 +00:00
|
|
|
progress " .data16\n"
|
2008-03-11 13:26:46 +00:00
|
|
|
movzwl %bx, %edi
|
|
|
|
|
shll $4, %edi
|
2008-10-09 22:22:01 +01:00
|
|
|
movl $_data16_filesz, %ecx
|
|
|
|
|
movl $_data16_memsz, %edx
|
2008-03-11 13:26:46 +00:00
|
|
|
call install_block /* .data16 */
|
2006-05-02 20:51:07 +00:00
|
|
|
|
2007-09-25 18:01:15 +01:00
|
|
|
/* Set up %ds for access to .data16 */
|
2006-08-24 13:18:05 +00:00
|
|
|
movw %bx, %ds
|
2007-09-25 18:01:15 +01:00
|
|
|
|
2011-11-11 22:23:13 +00:00
|
|
|
/* Restore decompression temporary area physical address */
|
|
|
|
|
popl %edi
|
|
|
|
|
|
2007-09-25 18:01:15 +01:00
|
|
|
#ifdef KEEP_IT_REAL
|
|
|
|
|
/* Initialise libkir */
|
2006-08-24 13:18:05 +00:00
|
|
|
movw %ax, (init_libkir_vector+2)
|
|
|
|
|
lcall *init_libkir_vector
|
|
|
|
|
#else
|
2010-04-24 22:22:54 +01:00
|
|
|
/* Find a suitable decompression temporary area, if none specified */
|
2011-03-28 00:55:15 +01:00
|
|
|
pushl %eax
|
2011-11-11 22:23:13 +00:00
|
|
|
testl %edi, %edi
|
2010-04-24 22:22:54 +01:00
|
|
|
jnz 1f
|
|
|
|
|
/* Use INT 15,88 to find the highest available address via INT
|
|
|
|
|
* 15,88. This limits us to around 64MB, which should avoid
|
|
|
|
|
* all of the POST-time memory map failure modes.
|
|
|
|
|
*/
|
|
|
|
|
movb $0x88, %ah
|
|
|
|
|
int $0x15
|
2011-11-11 22:23:13 +00:00
|
|
|
movw %ax, %di
|
|
|
|
|
addl $0x400, %edi
|
|
|
|
|
subl $_textdata_memsz_kb, %edi
|
|
|
|
|
shll $10, %edi
|
2011-03-28 00:55:15 +01:00
|
|
|
/* Sanity check: if we have ended up below 1MB, use 1MB */
|
2011-11-11 22:23:13 +00:00
|
|
|
cmpl $0x100000, %edi
|
2011-03-28 00:55:15 +01:00
|
|
|
jae 1f
|
2011-11-11 22:23:13 +00:00
|
|
|
movl $0x100000, %edi
|
2011-03-28 00:55:15 +01:00
|
|
|
1: popl %eax
|
|
|
|
|
|
2007-01-13 01:48:12 +00:00
|
|
|
/* Install .text and .data to temporary area in high memory,
|
|
|
|
|
* prior to reading the E820 memory map and relocating
|
|
|
|
|
* properly.
|
2006-05-02 20:51:07 +00:00
|
|
|
*/
|
2011-03-01 14:49:25 +00:00
|
|
|
progress " .textdata\n"
|
2011-11-11 22:23:13 +00:00
|
|
|
pushl %edi
|
2008-10-09 22:22:01 +01:00
|
|
|
movl $_textdata_filesz, %ecx
|
|
|
|
|
movl $_textdata_memsz, %edx
|
2008-03-11 13:26:46 +00:00
|
|
|
call install_block
|
2011-11-11 22:23:13 +00:00
|
|
|
popl %edi
|
2006-05-02 20:51:07 +00:00
|
|
|
|
2007-09-25 18:01:15 +01:00
|
|
|
/* Initialise librm at current location */
|
2011-03-01 14:49:25 +00:00
|
|
|
progress " init_librm\n"
|
2007-09-25 18:01:15 +01:00
|
|
|
movw %ax, (init_librm_vector+2)
|
|
|
|
|
lcall *init_librm_vector
|
|
|
|
|
|
[pcbios] Inhibit all calls to INT 15,e820 and INT 15,e801 during POST
Many BIOSes do not construct the full system memory map until after
calling the option ROM initialisation entry points. For several
years, we have added sanity checks and workarounds to accommodate
charming quirks such as BIOSes which report the entire 32-bit address
space (including all memory-mapped PCI BARs) as being usable RAM.
The IBM x3650 takes quirky behaviour to a new extreme. Calling either
INT 15,e820 or INT 15,e801 during POST doesn't just get you invalid
data. We could cope with invalid data. Instead, these nominally
read-only API calls manage to trash some internal BIOS state, with the
result that the system memory map is _never_ constructed. This tends
to confuse subsequent bootloaders and operating systems.
[ GRUB 0.97 fails in a particularly amusing way. Someone thought it
would be a good idea for memcpy() to check that the destination memory
region is a valid part of the system memory map; if not, then memcpy()
will sulk, fail, and return NULL. This breaks pretty much every use
of memcpy() including, for example, those inserted implicitly by gcc
to copy non-const initialisers. Debugging is _fun_ when a simple call
to printf() manages to create an infinite recursion, exhaust the
available stack space, and shut down the CPU. ]
Fix by completely inhibiting calls to INT 15,e820 and INT 15,e801
during POST.
We do now allow relocation during POST up to the maximum address
returned by INT 15,88 (which seems so far to always be safe). This
allows us to continue to have a reasonable size of external heap, even
if the PMM allocation is close to the 1MB mark.
The downside of allowing relocation during POST is that we may
overwrite PMM-allocated memory in use by other option ROMs. However,
the downside of inhibiting relocation, when combined with also
inhibiting calls to INT 15,e820 and INT 15,e801, would be that we
might have no external heap available: this would make booting an OS
impossible and could prevent some devices from even completing
initialisation.
On balance, the lesser evil is probably to allow relocation during
POST (up to the limit provided by INT 15,88). Entering iPXE during
POST is a rare operation; on the even rarer systems where doing so
happens to overwrite a PMM-allocated region, then there exists a
fairly simple workaround: if the user enters iPXE during POST and
wishes to exit iPXE, then the user must reboot. This is an acceptable
cost, given the rarity of the situation and the simplicity of the
workaround.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-03-11 00:50:52 +00:00
|
|
|
/* Inhibit INT 15,e820 and INT 15,e801 if applicable */
|
|
|
|
|
testl %ebp, %ebp
|
|
|
|
|
jnz 1f
|
|
|
|
|
incb memmap_post
|
|
|
|
|
decl %ebp
|
|
|
|
|
1:
|
|
|
|
|
|
2007-09-25 18:01:15 +01:00
|
|
|
/* Call relocate() to determine target address for relocation.
|
2006-05-25 00:06:45 +00:00
|
|
|
* relocate() will return with %esi, %edi and %ecx set up
|
|
|
|
|
* ready for the copy to the new location.
|
|
|
|
|
*/
|
2011-03-01 14:49:25 +00:00
|
|
|
progress " relocate\n"
|
2007-09-25 18:01:15 +01:00
|
|
|
movw %ax, (prot_call_vector+2)
|
2006-05-02 20:51:07 +00:00
|
|
|
pushl $relocate
|
2006-05-25 00:06:45 +00:00
|
|
|
lcall *prot_call_vector
|
2007-09-25 19:06:38 +01:00
|
|
|
popl %edx /* discard */
|
2006-05-02 20:51:07 +00:00
|
|
|
|
2007-09-25 18:01:15 +01:00
|
|
|
/* Copy code to new location */
|
2011-03-01 14:49:25 +00:00
|
|
|
progress " copy\n"
|
2010-04-20 18:49:43 +01:00
|
|
|
pushl %edi
|
2011-01-26 23:04:43 +00:00
|
|
|
pushw %bx
|
|
|
|
|
movw $copy_bytes, %bx
|
|
|
|
|
call process_bytes
|
|
|
|
|
popw %bx
|
2010-04-20 18:49:43 +01:00
|
|
|
popl %edi
|
2007-01-14 00:53:56 +00:00
|
|
|
|
2007-09-25 18:01:15 +01:00
|
|
|
/* Initialise librm at new location */
|
2011-03-01 14:49:25 +00:00
|
|
|
progress " init_librm\n"
|
2007-09-25 18:01:15 +01:00
|
|
|
lcall *init_librm_vector
|
2007-09-25 19:06:38 +01:00
|
|
|
#endif
|
2010-04-19 22:22:11 +01:00
|
|
|
|
2010-04-25 15:57:00 +01:00
|
|
|
/* Close access to payload */
|
2011-03-01 14:49:25 +00:00
|
|
|
progress " close_payload\n"
|
2010-04-25 15:57:00 +01:00
|
|
|
movw %ax, (close_payload_vector+2)
|
|
|
|
|
lcall *close_payload_vector
|
|
|
|
|
|
2007-09-25 18:01:15 +01:00
|
|
|
/* Restore registers */
|
2007-09-25 19:06:38 +01:00
|
|
|
popw %es
|
2007-09-25 18:01:15 +01:00
|
|
|
popw %ds
|
2008-03-09 22:13:07 +00:00
|
|
|
popal
|
2006-05-02 20:51:07 +00:00
|
|
|
ret
|
|
|
|
|
.size install_prealloc, . - install_prealloc
|
2006-05-25 00:06:45 +00:00
|
|
|
|
2010-04-19 22:22:11 +01:00
|
|
|
/* Vectors for far calls to .text16 functions. Must be in
|
|
|
|
|
* .data16, since .prefix may not be writable.
|
|
|
|
|
*/
|
[i386] Add explicit flags and type on all .section declarations
Try to avoid future problems caused by implicit section flags and/or
type information by instituting a policy that all .section
declarations must explicitly state the flags and type.
Most of this change was achieved using
perl -pi \
-e 's/".text"$/".text", "ax", \@progbits/ ; ' \
-e 's/".text16"$/".text16", "ax", \@progbits/ ; ' \
-e 's/".text16.null"$/".text16.null", "ax", \@progbits/ ; ' \
-e 's/".text16.data"$/".text16.data", "aw", \@progbits/ ; ' \
-e 's/".data"$/".data", "aw", \@progbits/ ; ' \
-e 's/".data16"$/".data16", "aw", \@progbits/ ; ' \
-e 's/".bss"$/".bss", "aw", \@nobits/ ; ' \
-e 's/".bss16"$/".bss16", "aw", \@nobits/ ; ' \
-e 's/".prefix"$/".prefix", "ax", \@progbits/ ; ' \
-e 's/".prefix.lib"$/".prefix.lib", "awx", \@progbits/ ; ' \
-e 's/".prefix.data"$/".prefix.data", "aw", \@progbits/ ; ' \
-e 's/".weak"$/".weak", "a", \@nobits/ ; ' \
`git grep -l '\.section'`
2009-02-15 10:54:52 +00:00
|
|
|
.section ".data16", "aw", @progbits
|
2006-08-24 13:18:05 +00:00
|
|
|
#ifdef KEEP_IT_REAL
|
|
|
|
|
init_libkir_vector:
|
|
|
|
|
.word init_libkir
|
|
|
|
|
.word 0
|
|
|
|
|
.size init_libkir_vector, . - init_libkir_vector
|
|
|
|
|
#else
|
2006-05-25 00:06:45 +00:00
|
|
|
init_librm_vector:
|
|
|
|
|
.word init_librm
|
|
|
|
|
.word 0
|
|
|
|
|
.size init_librm_vector, . - init_librm_vector
|
|
|
|
|
prot_call_vector:
|
|
|
|
|
.word prot_call
|
|
|
|
|
.word 0
|
|
|
|
|
.size prot_call_vector, . - prot_call_vector
|
|
|
|
|
#endif
|
2010-04-25 15:57:00 +01:00
|
|
|
close_payload_vector:
|
|
|
|
|
.word close_payload
|
|
|
|
|
.word 0
|
|
|
|
|
.size close_payload_vector, . - close_payload_vector
|
2007-07-17 12:52:54 +01:00
|
|
|
|
2010-04-25 15:57:00 +01:00
|
|
|
/* Dummy routines to open and close payload */
|
|
|
|
|
.section ".text16.early.data", "aw", @progbits
|
|
|
|
|
.weak open_payload
|
|
|
|
|
.weak close_payload
|
|
|
|
|
open_payload:
|
|
|
|
|
close_payload:
|
|
|
|
|
clc
|
|
|
|
|
lret
|
|
|
|
|
.size open_payload, . - open_payload
|
|
|
|
|
.size close_payload, . - close_payload
|
|
|
|
|
|
2008-11-18 19:43:13 +00:00
|
|
|
/****************************************************************************
|
2010-04-19 22:22:11 +01:00
|
|
|
* uninstall
|
2008-11-18 19:43:13 +00:00
|
|
|
*
|
|
|
|
|
* Uninstall all text and data segments.
|
|
|
|
|
*
|
|
|
|
|
* Parameters:
|
2013-03-08 13:26:22 +00:00
|
|
|
* none (.text16 segment address is implicit in %cs)
|
2008-11-18 19:43:13 +00:00
|
|
|
* Returns:
|
|
|
|
|
* none
|
|
|
|
|
* Corrupts:
|
|
|
|
|
* none
|
|
|
|
|
****************************************************************************
|
|
|
|
|
*/
|
[i386] Add explicit flags and type on all .section declarations
Try to avoid future problems caused by implicit section flags and/or
type information by instituting a policy that all .section
declarations must explicitly state the flags and type.
Most of this change was achieved using
perl -pi \
-e 's/".text"$/".text", "ax", \@progbits/ ; ' \
-e 's/".text16"$/".text16", "ax", \@progbits/ ; ' \
-e 's/".text16.null"$/".text16.null", "ax", \@progbits/ ; ' \
-e 's/".text16.data"$/".text16.data", "aw", \@progbits/ ; ' \
-e 's/".data"$/".data", "aw", \@progbits/ ; ' \
-e 's/".data16"$/".data16", "aw", \@progbits/ ; ' \
-e 's/".bss"$/".bss", "aw", \@nobits/ ; ' \
-e 's/".bss16"$/".bss16", "aw", \@nobits/ ; ' \
-e 's/".prefix"$/".prefix", "ax", \@progbits/ ; ' \
-e 's/".prefix.lib"$/".prefix.lib", "awx", \@progbits/ ; ' \
-e 's/".prefix.data"$/".prefix.data", "aw", \@progbits/ ; ' \
-e 's/".weak"$/".weak", "a", \@nobits/ ; ' \
`git grep -l '\.section'`
2009-02-15 10:54:52 +00:00
|
|
|
.section ".text16", "ax", @progbits
|
2008-11-18 19:43:13 +00:00
|
|
|
.code16
|
|
|
|
|
.globl uninstall
|
|
|
|
|
uninstall:
|
|
|
|
|
call free_basemem
|
|
|
|
|
ret
|
|
|
|
|
.size uninstall, . - uninstall
|
|
|
|
|
|
|
|
|
|
|
2007-07-17 12:52:54 +01:00
|
|
|
|
|
|
|
|
/* File split information for the compressor */
|
|
|
|
|
#if COMPRESS
|
2010-04-20 11:05:53 +01:00
|
|
|
#define PACK_OR_COPY "PACK"
|
|
|
|
|
#else
|
|
|
|
|
#define PACK_OR_COPY "COPY"
|
|
|
|
|
#endif
|
2008-10-16 20:39:48 -04:00
|
|
|
.section ".zinfo", "a", @progbits
|
2007-07-17 12:52:54 +01:00
|
|
|
.ascii "COPY"
|
2008-10-09 22:22:01 +01:00
|
|
|
.long _prefix_lma
|
|
|
|
|
.long _prefix_filesz
|
2007-07-17 12:52:54 +01:00
|
|
|
.long _max_align
|
2010-04-20 11:05:53 +01:00
|
|
|
.ascii PACK_OR_COPY
|
|
|
|
|
.long _text16_early_lma
|
|
|
|
|
.long _text16_early_filesz
|
2007-07-17 12:52:54 +01:00
|
|
|
.long _max_align
|
2010-04-20 11:05:53 +01:00
|
|
|
.ascii "PAYL"
|
|
|
|
|
.long 0
|
|
|
|
|
.long 0
|
2012-06-10 18:25:26 +01:00
|
|
|
.long _payload_align
|
|
|
|
|
.ascii "COPY"
|
|
|
|
|
.long _pprefix_lma
|
|
|
|
|
.long _pprefix_filesz
|
2010-04-20 11:05:53 +01:00
|
|
|
.long _max_align
|
|
|
|
|
.ascii PACK_OR_COPY
|
|
|
|
|
.long _text16_late_lma
|
|
|
|
|
.long _text16_late_filesz
|
|
|
|
|
.long _max_align
|
|
|
|
|
.ascii PACK_OR_COPY
|
2008-10-09 22:22:01 +01:00
|
|
|
.long _data16_lma
|
|
|
|
|
.long _data16_filesz
|
2007-07-17 12:52:54 +01:00
|
|
|
.long _max_align
|
2010-04-20 11:05:53 +01:00
|
|
|
.ascii PACK_OR_COPY
|
2008-10-09 22:22:01 +01:00
|
|
|
.long _textdata_lma
|
|
|
|
|
.long _textdata_filesz
|
2007-07-17 12:52:54 +01:00
|
|
|
.long _max_align
|
2012-06-10 18:25:26 +01:00
|
|
|
|
|
|
|
|
.weak _payload_align
|
|
|
|
|
.equ _payload_align, 1
|