summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAnup Patel <[email protected]>2023-01-04 17:36:29 +0530
committerAnup Patel <[email protected]>2023-02-09 22:30:06 +0530
commit4e0572f57bc832b13f6e813dcdaebb1bf4d1172a (patch)
treec1297293a92b4bcd7f116dec10da41795e966f5c /lib
parent0ee3a86fedafccaa5f57df86b07547747920972e (diff)
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 <[email protected]> Reviewed-by: Atish Patra <[email protected]> Reviewed-by: Andrew Jones <[email protected]>
Diffstat (limited to 'lib')
-rw-r--r--lib/sbi/sbi_console.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/sbi/sbi_console.c b/lib/sbi/sbi_console.c
index 2f83a26c..c734bc0a 100644
--- a/lib/sbi/sbi_console.c
+++ b/lib/sbi/sbi_console.c
@@ -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