diff --git a/src/arch/i386/prefix/libprefix.S b/src/arch/i386/prefix/libprefix.S index 406dac39..bf26358a 100644 --- a/src/arch/i386/prefix/libprefix.S +++ b/src/arch/i386/prefix/libprefix.S @@ -43,6 +43,114 @@ #define CR0_PE 1 +/***************************************************************************** + * Utility function: print character (with LF -> LF,CR translation) + * + * Parameters: + * %al : character to print + * Returns: + * Nothing + * Corrupts: + * %ax + ***************************************************************************** + */ + .section ".prefix.lib" + .code16 + .globl print_character +print_character: + /* Preserve registers */ + pushw %bx + pushw %bp + /* Print character */ + movw $0x0007, %bx /* page 0, attribute 7 (normal) */ + movb $0x0e, %ah /* write char, tty mode */ + cmpb $0x0a, %al /* '\n'? */ + jne 1f + int $0x10 + movb $0x0d, %al +1: int $0x10 + /* Restore registers and return */ + popw %bp + popw %bx + ret + .size print_character, . - print_character + +/***************************************************************************** + * Utility function: print a NUL-terminated string + * + * Parameters: + * %ds:si : string to print + * Returns: + * %ds:si : character after terminating NUL + ***************************************************************************** + */ + .section ".prefix.lib" + .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 + * Returns: + * Nothing + ***************************************************************************** + */ + .section ".prefix.lib" + .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 */ + 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 + /**************************************************************************** * pm_call (real-mode near call) * diff --git a/src/arch/i386/prefix/pxeprefix.S b/src/arch/i386/prefix/pxeprefix.S index 31b2102f..6a8aeb3a 100644 --- a/src/arch/i386/prefix/pxeprefix.S +++ b/src/arch/i386/prefix/pxeprefix.S @@ -320,112 +320,6 @@ print_free_basemem: finished: jmp run_etherboot -/***************************************************************************** - * Subroutine: print character (with LF -> LF,CR translation) - * - * Parameters: - * %al : character to print - * Returns: - * Nothing - ***************************************************************************** - */ -print_character: - /* Preserve registers */ - pushw %ax - pushw %bx - pushw %bp - /* Print character */ - movw $0x0007, %bx /* page 0, attribute 7 (normal) */ - movb $0x0e, %ah /* write char, tty mode */ - cmpb $0x0a, %al /* '\n'? */ - jne 1f - int $0x10 - movb $0x0d, %al -1: int $0x10 - /* Restore registers and return */ - popw %bp - popw %bx - popw %ax - ret - -/***************************************************************************** - * Subroutine: print a NUL-terminated string - * - * Parameters: - * %ds:%si : string to print - * Returns: - * Nothing - ***************************************************************************** - */ -print_message: - /* Preserve registers */ - pushw %ax - pushw %si - /* Print string */ -1: lodsb - testb %al, %al - je 2f - call print_character - jmp 1b -2: /* Restore registers and return */ - popw %si - popw %ax - ret - -/***************************************************************************** - * Subroutine: print hex digit - * - * Parameters: - * %al (low nibble) : digit to print - * Returns: - * Nothing - ***************************************************************************** - */ -print_hex_nibble: - /* Preserve registers */ - pushw %ax - /* Print digit (technique by Norbert Juffa */ - andb $0x0f, %al - cmpb $10, %al - sbbb $0x69, %al - das - call print_character - /* Restore registers and return */ - popw %ax - ret - -/***************************************************************************** - * Subroutine: print hex byte - * - * Parameters: - * %al : byte to print - * Returns: - * Nothing - ***************************************************************************** - */ -print_hex_byte: - rorb $4, %al - call print_hex_nibble - rorb $4, %al - call print_hex_nibble - ret - -/***************************************************************************** - * Subroutine: print hex word - * - * Parameters: - * %ax : word to print - * Returns: - * Nothing - ***************************************************************************** - */ -print_hex_word: - xchgb %al, %ah - call print_hex_byte - xchgb %al, %ah - call print_hex_byte - ret - /***************************************************************************** * Subroutine: print segment:offset address * diff --git a/src/arch/i386/prefix/romprefix.S b/src/arch/i386/prefix/romprefix.S index 86d76a5d..e67f476b 100644 --- a/src/arch/i386/prefix/romprefix.S +++ b/src/arch/i386/prefix/romprefix.S @@ -180,7 +180,8 @@ gotpmm: /* PMM allocation succeeded: copy ROM to PMM block */ /* Shrink ROM and update checksum */ xorw %bx, %bx xorw %si, %si - movb $_prefix_size_sect, romheader_size + movw $_prefix_size_sect, %cx + movb %cl, romheader_size shlw $9, %cx 1: lodsb addb %al, %bl @@ -213,7 +214,7 @@ init_message_pmm_failed: .asciz " (failed)" .size init_message_pmm_failed, . - init_message_pmm_failed init_message_crlf: - .asciz "\r\n" + .asciz "\n" .size init_message_crlf, . - init_message_crlf /* ROM image location @@ -309,7 +310,7 @@ exec: /* Set %ds = %cs */ .previous exec_message: - .asciz "gPXE starting boot\r\n" + .asciz "gPXE starting boot\n" .size exec_message, . - exec_message /* UNDI loader @@ -350,22 +351,3 @@ undiloader: popl %esi lret .size undiloader, . - undiloader - -/* Utility function: print string - */ -print_message: - pushw %ax - pushw %bx - pushw %bp - movw $0x0007, %bx -1: lodsb - testb %al, %al - je 2f - movb $0x0e, %ah /* write char, tty mode */ - int $0x10 - jmp 1b -2: popw %bp - popw %bx - popw %ax - ret - .size print_message, . - print_message