Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[prefix] Include diagnostic information within progress messages
Include some relevant diagnostic infomation within the progress
messages generated via DEBUG=libprefix.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
  • Loading branch information
mcb30 committed Dec 6, 2016
1 parent ce81601 commit 80c482c
Showing 1 changed file with 38 additions and 14 deletions.
52 changes: 38 additions & 14 deletions src/arch/x86/prefix/libprefix.S
Expand Up @@ -36,10 +36,24 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

/* Allow for DBG()-style messages within libprefix */
#ifdef NDEBUG
.macro progress message
.macro progress message, regs:vararg
.endm
#else
.macro progress message
.macro dumpreg reg, others:vararg
pushl %eax
movl \reg, %eax
pushw %di
xorw %di, %di
call print_space
call print_hex_dword
popw %di
popl %eax
.ifnb \others
dumpreg \others
.endif
.endm

.macro progress message, regs:vararg
pushfl
pushw %ds
pushw %si
Expand All @@ -51,6 +65,16 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
call print_message
popw %di
popw %si
.ifnb \regs
dumpreg \regs
.endif
pushw %di
pushw %ax
xorw %di, %di
movb $( '\n' ), %al
call print_character
popw %ax
popw %di
popw %ds
popfl
.section ".prefix.data", "aw", @progbits
Expand Down Expand Up @@ -659,7 +683,7 @@ hooked_bios_interrupts:
.code16
.globl install
install:
progress "install:\n"
progress "\ninstall:"
/* Preserve registers */
pushl %esi
pushl %edi
Expand Down Expand Up @@ -702,7 +726,7 @@ install:
.code16
.globl install_prealloc
install_prealloc:
progress "install_prealloc:\n"
progress "\ninstall_prealloc:", %eax, %ebx, %esi, %edi, %ebp
/* Save registers on external stack */
pushal
pushw %ds
Expand All @@ -726,7 +750,6 @@ install_prealloc:
pushl %edi

/* Install .text16.early and calculate %ecx as offset to next block */
progress " .text16.early\n"
pushl %esi
xorl %esi, %esi
movw %cs, %si
Expand All @@ -737,6 +760,7 @@ install_prealloc:
shll $4, %edi
movl $_text16_early_filesz, %ecx
movl $_text16_early_memsz, %edx
progress " .text16.early ", %esi, %edi, %ecx, %edx
call install_block /* .text16.early */
jc install_block_death
popl %ecx /* Calculate offset to next block */
Expand All @@ -750,7 +774,7 @@ install_prealloc:
* already have 4GB segment limits as a result of calling
* install_block.)
*/
progress " access_highmem\n"
progress " access_highmem"
pushw %cs
pushw $1f
pushw %ax
Expand All @@ -762,7 +786,7 @@ install_prealloc:
#endif

/* Open payload (which may not yet be in memory) */
progress " open_payload\n"
progress " open_payload ", %esi, %ecx
pushw %cs
pushw $1f
pushw %ax
Expand All @@ -779,16 +803,16 @@ install_prealloc:
1: addl %ecx, %esi

/* Install .text16.late and .data16 */
progress " .text16.late\n"
movl $_text16_late_filesz, %ecx
movl $_text16_late_memsz, %edx
progress " .text16.late ", %esi, %edi, %ecx, %edx
call install_block /* .text16.late */
jc install_block_death
progress " .data16\n"
movzwl %bx, %edi
shll $4, %edi
movl $_data16_filesz, %ecx
movl $_data16_filesz, %edx /* do not zero our temporary stack */
progress " .data16 ", %esi, %edi, %ecx, %edx
call install_block /* .data16 */
jc install_block_death

Expand Down Expand Up @@ -825,10 +849,10 @@ install_prealloc:
* prior to reading the E820 memory map and relocating
* properly.
*/
progress " .textdata\n"
pushl %edi
movl $_textdata_filesz, %ecx
movl $_textdata_memsz, %edx
progress " .textdata ", %esi, %edi, %ecx, %edx
call install_block
jc install_block_death
popl %edi
Expand All @@ -850,7 +874,7 @@ install_prealloc:
#ifndef KEEP_IT_REAL

/* Initialise librm at current location */
progress " init_librm\n"
progress " init_librm ", %eax, %ebx, %edi
movw %ax, (init_librm_vector+2)
lcall *init_librm_vector

Expand Down Expand Up @@ -881,7 +905,7 @@ install_prealloc:
.section ".prefix.install_prealloc", "awx", @progbits
1:
/* Copy code to new location */
progress " copy\n"
progress " copy ", %esi, %edi, %ecx
pushl %edi
pushw %bx
movw $copy_bytes, %bx
Expand All @@ -890,7 +914,7 @@ install_prealloc:
popl %edi

/* Initialise librm at new location */
progress " init_librm\n"
progress " init_librm ", %eax, %ebx, %edi
lcall *init_librm_vector

#else /* KEEP_IT_REAL */
Expand All @@ -902,7 +926,7 @@ install_prealloc:
#endif /* KEEP_IT_REAL */

/* Close access to payload */
progress " close_payload\n"
progress " close_payload"
movw %ax, (close_payload_vector+2)
lcall *close_payload_vector

Expand Down

0 comments on commit 80c482c

Please sign in to comment.