mirror of
https://github.com/ipxe/ipxe
synced 2026-04-16 03:00:10 +03:00
[riscv] Provide a millicode variant of print_message()
RISC-V has a millicode calling convention that allows for the use of an alternative link register x5/t0. With sufficient care, this allows for two levels of subroutine call even when no stack is available. Provide both standard and millicode entry points for print_message(), and use the millicode entry point to allow for printing debug messages from libprefix.S itself. Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -54,12 +54,12 @@ prefix_virt:
|
|||||||
* to know the current virtual-physical address translation. It does
|
* to know the current virtual-physical address translation. It does
|
||||||
* not require a valid stack.
|
* not require a valid stack.
|
||||||
*
|
*
|
||||||
* Note that the parameter is passed in register t0 (rather than a0)
|
* Note that the parameter is passed in register t1 (rather than a0)
|
||||||
* and all non-temporary registers are preserved.
|
* and all non-temporary registers are preserved.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
*
|
*
|
||||||
* t0 - Pointer to string
|
* t1 - Pointer to string
|
||||||
*
|
*
|
||||||
* Returns: none
|
* Returns: none
|
||||||
*
|
*
|
||||||
@@ -72,37 +72,55 @@ prefix_virt:
|
|||||||
.section ".prefix.print_message", "ax", @progbits
|
.section ".prefix.print_message", "ax", @progbits
|
||||||
.globl print_message
|
.globl print_message
|
||||||
print_message:
|
print_message:
|
||||||
|
/* Handle alternate link register */
|
||||||
|
mv t0, ra
|
||||||
|
print_message_alt:
|
||||||
/* Register usage:
|
/* Register usage:
|
||||||
*
|
*
|
||||||
* t0 - character pointer
|
* t0 - character pointer
|
||||||
* a0 - current character
|
* a0 - current character
|
||||||
* t1 - preserved a0
|
* t2 - preserved a0
|
||||||
* t2 - preserved a1
|
* t3 - preserved a1
|
||||||
* t3 - preserved a6
|
* t4 - preserved a6
|
||||||
* t4 - preserved a7
|
* t5 - preserved a7
|
||||||
*/
|
*/
|
||||||
mv t1, a0
|
mv t2, a0
|
||||||
mv t2, a1
|
mv t3, a1
|
||||||
mv t3, a6
|
mv t4, a6
|
||||||
mv t4, a7
|
mv t5, a7
|
||||||
|
|
||||||
1: /* Print each character in turn */
|
1: /* Print each character in turn */
|
||||||
lbu a0, (t0)
|
lbu a0, (t1)
|
||||||
addi t0, t0, 1
|
addi t1, t1, 1
|
||||||
beqz a0, 2f
|
beqz a0, 2f
|
||||||
li a7, SBI_DBCN
|
li a7, SBI_DBCN
|
||||||
li a6, SBI_DBCN_WRITE_BYTE
|
li a6, SBI_DBCN_WRITE_BYTE
|
||||||
ecall
|
ecall
|
||||||
j 1b
|
j 1b
|
||||||
2:
|
2:
|
||||||
/* Restore registers and return */
|
/* Restore registers and return (via alternate link register) */
|
||||||
mv a7, t4
|
mv a7, t5
|
||||||
mv a6, t3
|
mv a6, t4
|
||||||
mv a1, t2
|
mv a1, t3
|
||||||
mv a0, t1
|
mv a0, t2
|
||||||
ret
|
jr t0
|
||||||
.size print_message, . - print_message
|
.size print_message, . - print_message
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Display progress message (if debugging is enabled)
|
||||||
|
*/
|
||||||
|
.macro progress message
|
||||||
|
#ifndef NDEBUG
|
||||||
|
.section ".rodata.progress_\@", "a", @progbits
|
||||||
|
progress_\@:
|
||||||
|
.asciz "\message"
|
||||||
|
.size progress_\@, . - progress_\@
|
||||||
|
.previous
|
||||||
|
la t1, progress_\@
|
||||||
|
jal t0, print_message_alt
|
||||||
|
#endif
|
||||||
|
.endm
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
*
|
*
|
||||||
* Apply compressed relocation records
|
* Apply compressed relocation records
|
||||||
|
|||||||
@@ -45,12 +45,12 @@
|
|||||||
*/
|
*/
|
||||||
.macro progress message
|
.macro progress message
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
.section ".rodata", "a", @progbits
|
.section ".rodata.progress_\@", "a", @progbits
|
||||||
progress_\@:
|
progress_\@:
|
||||||
.asciz "\message"
|
.asciz "\message"
|
||||||
.size progress_\@, . - progress_\@
|
.size progress_\@, . - progress_\@
|
||||||
.previous
|
.previous
|
||||||
la t0, progress_\@
|
la t1, progress_\@
|
||||||
call print_message
|
call print_message
|
||||||
#endif
|
#endif
|
||||||
.endm
|
.endm
|
||||||
|
|||||||
Reference in New Issue
Block a user