mirror of
https://github.com/ipxe/ipxe
synced 2026-01-30 04:58:12 +03:00
[riscv] Move prefix debug message printing to libprefix.S
Create a prefix library function print_message() to print text to the SBI debug console. Use the "write byte" SBI call (rather than "write string") so that the function remains usable even after enabling paging. Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -41,6 +41,68 @@ prefix_virt:
|
|||||||
.dword _prefix
|
.dword _prefix
|
||||||
.size prefix_virt, . - prefix_virt
|
.size prefix_virt, . - prefix_virt
|
||||||
|
|
||||||
|
/*****************************************************************************
|
||||||
|
*
|
||||||
|
* Print message to debug console
|
||||||
|
*
|
||||||
|
*****************************************************************************
|
||||||
|
*
|
||||||
|
* Print a NUL-terminated string to the debug console.
|
||||||
|
*
|
||||||
|
* This function prints one character at a time via the "write byte"
|
||||||
|
* call (rather than using "write string"), since this avoids any need
|
||||||
|
* to know the current virtual-physical address translation. It does
|
||||||
|
* not require a valid stack.
|
||||||
|
*
|
||||||
|
* Note that the parameter is passed in register t0 (rather than a0)
|
||||||
|
* and all non-temporary registers are preserved.
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
*
|
||||||
|
* t0 - Pointer to string
|
||||||
|
*
|
||||||
|
* Returns: none
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* SBI debug console extension */
|
||||||
|
#define SBI_DBCN ( ( 'D' << 24 ) | ( 'B' << 16 ) | ( 'C' << 8 ) | 'N' )
|
||||||
|
#define SBI_DBCN_WRITE_BYTE 0x02
|
||||||
|
|
||||||
|
.section ".prefix.print_message", "ax", @progbits
|
||||||
|
.globl print_message
|
||||||
|
print_message:
|
||||||
|
/* Register usage:
|
||||||
|
*
|
||||||
|
* t0 - character pointer
|
||||||
|
* a0 - current character
|
||||||
|
* t1 - preserved a0
|
||||||
|
* t2 - preserved a1
|
||||||
|
* t3 - preserved a6
|
||||||
|
* t4 - preserved a7
|
||||||
|
*/
|
||||||
|
mv t1, a0
|
||||||
|
mv t2, a1
|
||||||
|
mv t3, a6
|
||||||
|
mv t4, a7
|
||||||
|
|
||||||
|
1: /* Print each character in turn */
|
||||||
|
lbu a0, (t0)
|
||||||
|
addi t0, t0, 1
|
||||||
|
beqz a0, 2f
|
||||||
|
li a7, SBI_DBCN
|
||||||
|
li a6, SBI_DBCN_WRITE_BYTE
|
||||||
|
ecall
|
||||||
|
j 1b
|
||||||
|
2:
|
||||||
|
/* Restore registers and return */
|
||||||
|
mv a7, t4
|
||||||
|
mv a6, t3
|
||||||
|
mv a1, t2
|
||||||
|
mv a0, t1
|
||||||
|
ret
|
||||||
|
.size print_message, . - print_message
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
*
|
*
|
||||||
* Apply compressed relocation records
|
* Apply compressed relocation records
|
||||||
|
|||||||
@@ -32,10 +32,6 @@
|
|||||||
.section ".note.GNU-stack", "", @progbits
|
.section ".note.GNU-stack", "", @progbits
|
||||||
.text
|
.text
|
||||||
|
|
||||||
/* SBI debug console extension */
|
|
||||||
#define SBI_DBCN ( ( 'D' << 24 ) | ( 'B' << 16 ) | ( 'C' << 8 ) | 'N' )
|
|
||||||
#define SBI_DBCN_WRITE 0x00
|
|
||||||
|
|
||||||
/* SBI system reset extension */
|
/* SBI system reset extension */
|
||||||
#define SBI_SRST ( ( 'S' << 24 ) | ( 'R' << 16 ) | ( 'S' << 8 ) | 'T' )
|
#define SBI_SRST ( ( 'S' << 24 ) | ( 'R' << 16 ) | ( 'S' << 8 ) | 'T' )
|
||||||
#define SBI_SRST_SYSTEM_RESET 0x00
|
#define SBI_SRST_SYSTEM_RESET 0x00
|
||||||
@@ -51,16 +47,11 @@
|
|||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
.section ".rodata", "a", @progbits
|
.section ".rodata", "a", @progbits
|
||||||
progress_\@:
|
progress_\@:
|
||||||
.ascii "\message"
|
.asciz "\message"
|
||||||
.equ progress_\@_len, . - progress_\@
|
|
||||||
.size progress_\@, . - progress_\@
|
.size progress_\@, . - progress_\@
|
||||||
.previous
|
.previous
|
||||||
li a7, SBI_DBCN
|
la t0, progress_\@
|
||||||
li a6, SBI_DBCN_WRITE
|
call print_message
|
||||||
li a0, progress_\@_len
|
|
||||||
la a1, progress_\@
|
|
||||||
mv a2, zero
|
|
||||||
ecall
|
|
||||||
#endif
|
#endif
|
||||||
.endm
|
.endm
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user