mirror of
https://github.com/Fishwaldo/opensbi.git
synced 2025-03-15 19:31:32 +00:00
lib: sbi: Add sbi_ngets() function
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>
This commit is contained in:
parent
0ee3a86fed
commit
4e0572f57b
2 changed files with 17 additions and 0 deletions
|
@ -37,6 +37,8 @@ unsigned long sbi_nputs(const char *str, unsigned long len);
|
|||
|
||||
void sbi_gets(char *s, int maxwidth, char endchar);
|
||||
|
||||
unsigned long sbi_ngets(char *str, unsigned long len);
|
||||
|
||||
int __printf(2, 3) sbi_sprintf(char *out, const char *format, ...);
|
||||
|
||||
int __printf(3, 4) sbi_snprintf(char *out, u32 out_sz, const char *format, ...);
|
||||
|
|
|
@ -76,6 +76,21 @@ void sbi_gets(char *s, int maxwidth, char endchar)
|
|||
*retval = '\0';
|
||||
}
|
||||
|
||||
unsigned long sbi_ngets(char *str, unsigned long len)
|
||||
{
|
||||
int ch;
|
||||
unsigned long i;
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
ch = sbi_getc();
|
||||
if (ch < 0)
|
||||
break;
|
||||
str[i] = ch;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
#define PAD_RIGHT 1
|
||||
#define PAD_ZERO 2
|
||||
#define PAD_ALTERNATE 4
|
||||
|
|
Loading…
Add table
Reference in a new issue