summaryrefslogtreecommitdiff
path: root/include/sbi/sbi_console.h
AgeCommit message (Collapse)AuthorFilesLines
2023-02-10lib: sbi: Add console_puts() callback in the console deviceAnup Patel1-0/+3
We add console_puts() callback in the console device which allows console drivers (such as semihosting) to implement a specialized way to output character string. Signed-off-by: Anup Patel <apatel@ventanamicro.com> Reviewed-by: Atish Patra <atishp@rivosinc.com> Reviewed-by: Xiang W <wxjstz@126.com> Reviewed-by: Bin Meng <bmeng@tinylab.org> Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
2023-02-09lib: sbi: Add sbi_ngets() functionAnup Patel1-0/+2
We add new sbi_ngets() which help us read characters into a physical memory location. Signed-off-by: Anup Patel <apatel@ventanamicro.com> Reviewed-by: Atish Patra <atishp@rivosinc.com> Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
2023-02-09lib: sbi: Add sbi_nputs() functionAnup Patel1-0/+2
We add new sbi_nputs() which help us print a fixed number of characters from a physical memory location. Signed-off-by: Anup Patel <apatel@ventanamicro.com> Reviewed-by: Atish Patra <atishp@rivosinc.com> Reviewed-by: Bin Meng <bmeng@tinylab.org> Reviewed-by: Xiang W <wxjstz@126.com>
2021-12-02lib: sbi: Improve fatal error handlingJessica Clarke1-18/+5
BUG and BUG_ON are not informative and are rather lazy interfaces, only telling the user that something went wrong in a given function, but not what, requiring the user to find the sources corresponding to their firmware (which may not be available) and figure out how that BUG(_ON) was hit. Even SBI_ASSERT in its current form, which does include the condition that triggered it in the output, isn't necessarily very informative. In some cases, the error may be fixable by the user, but they need to know the problem in order to have any hope of fixing it. It's also a nuisance for developers, whose development trees may have changed significantly since the release in question being used, and so line numbers can make it harder for them to understand which error case a user has hit. This patch introduces a new sbi_panic function which is printf-like, allowing detailed error messages to be printed to the console. BUG and BUG_ON are removed, since the former is just a worse form of sbi_panic and the latter is a worse version of SBI_ASSERT. Finally, SBI_ASSERT is augmented to take a set of arguments to pass to sbi_panic on failure, used like so (sbi_boot_print_hart's current error case, which currently manually calls sbi_printf and sbi_hart_hang): SBI_ASSERT(xlen >= 1, ("Error %d getting MISA XLEN\n", xlen)); The existing users of BUG are replaced with calls to sbi_panic along with informative error messages. BUG_ON and SBI_ASSERT were unused (and, in the case of SBI_ASSERT, remain unused). Many existing users of sbi_hart_hang should be converted to use either sbi_panic or SBI_ASSERT after this commit. Signed-off-by: Jessica Clarke <jrtc27@jrtc27.com> Reviewed-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Xiang W <wxjstz@126.com> Reviewed-by: Atish Patra <atishp@rivosinc.com>
2021-09-22lib: sbi: add some macros to detect BUG at runtimeXiang W1-0/+20
Three macros are added. One is called BUG, which is used to put in an unreachable branch. One is called BUG_ON, which is used to check bugs and assert conditions are opposite. One is called SBI_ASSERT, used for assertion checking. Signed-off-by: Xiang W <wxjstz@126.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2021-04-28lib: sbi: Simplify console platform operationsAnup Patel1-0/+15
Instead of having console_putc() and console_getc() callbacks in platform operations, it will be much simpler for console driver to directly register these operations as device to the sbi_console implementation. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Reviewed-by: Xiang W <wxjstz@126.com>
2020-03-28include: sbi_console: Remove scratch parameter from sbi_dprintf()Anup Patel1-3/+2
This patch removes scratch parameter from sbi_dprintf() function because sbi_dprintf() can use sbi_scratch_thishart_ptr() to get current HART scratch space. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2019-08-09lib: Introduce sbi_dprintf() APIAnup Patel1-0/+4
This patch introduces new sbi_dprintf() API for runtime debug prints. The sbi_dprintf() will print to console for a given HART only when SBI_SCRATCH_DEBUG_PRINTS option in enabled in sbi_scratch for this HART. We can now add debug prints using sbi_dprintf() at important places in OpenSBI sources. These debug prints will only show up when previous booting stage or compile time parameter sets the SBI_SCRATCH_DEBUG_PRINTS option in scratch space. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2019-04-24all: run clang-format and update checked-in filesOlof Johansson1-3/+2
Noisy commit, no functional changes. Generated with an current upstream clang-format and: clang-format -i $(find . -name \*.[ch]) Signed-off-by: Olof Johansson <olof@lixom.net>
2019-03-05lib:platform: Fix sbi_getc return type.Atish Patra1-1/+1
As per the current SBI specification, sbi_getc should return an int instead of char. In case of FIFO is empty, return -1 as per the specification. Reported-by: Sergi Granell <xerpi.g.12@gmail.com> Suggested-by:Thadeu Lima de Souza Cascardo <cascardo@cascardo.eti.br> Signed-off-by: Atish Patra <atish.patra@wdc.com>
2019-01-24all: Update copyright header in all filesAnup patel1-3/+3
This patch updates copyright header in all files as follows: 1. Makes "SPDX-License-Identifier: BSD-2-Clause" as first line 2. Change copyright year to 2019 for Western Digital Signed-off-by: Anup Patel <anup.patel@wdc.com>
2018-12-11Initial commit.Anup Patel1-0/+37
Signed-off-by: Anup Patel <anup.patel@wdc.com>