stdio kprintf working
This commit is contained in:
parent
a1f592c880
commit
7018424278
2 changed files with 38 additions and 0 deletions
20
kern/libkern/stdio.c
Normal file
20
kern/libkern/stdio.c
Normal file
|
@ -0,0 +1,20 @@
|
|||
#include <uart.h>
|
||||
#include <mini-printf.h>
|
||||
#include <stddef.h>
|
||||
|
||||
int stdout_puts(char *s, int len, void *unused) {
|
||||
(void)unused;
|
||||
// Example: UART write loop
|
||||
for (int i = 0; i < len; i++) {
|
||||
uart_putc(s[i]); // <-- your low-level "put char" routine
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
int kprintf(const char *restrict fmt, ...) {
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
int ret = mini_vpprintf(stdout_puts, NULL, fmt, ap);
|
||||
va_end(ap);
|
||||
return ret;
|
||||
}
|
18
kern/libkern/stdio.h
Normal file
18
kern/libkern/stdio.h
Normal file
|
@ -0,0 +1,18 @@
|
|||
#ifndef STDIO_H
|
||||
#define STDIO_H
|
||||
|
||||
int stdout_puts(char *s, int len, void *unused);
|
||||
int kprintf(const char *restrict format, ...);
|
||||
|
||||
// int fprintf(FILE *restrict stream, const char *restrict format, ...);
|
||||
// int dprintf(int fd, const char *restrict format, ...);
|
||||
// int sprintf(char *restrict str, const char *restrict format, ...);
|
||||
// int snprintf(char str[restrict.size], size_t size, const char *restrict format, ...);
|
||||
|
||||
// int vprintf(const char *restrict format, va_list ap);
|
||||
// int vfprintf(FILE *restrict stream, const char *restrict format, va_list ap);
|
||||
// int vdprintf(int fd, const char *restrict format, va_list ap);
|
||||
// int vsprintf(char *restrict str, const char *restrict format, va_list ap);
|
||||
// int vsnprintf(char str[restrict.size], size_t size, const char *restrict format, va_list ap);
|
||||
|
||||
#endif // STDIO_H
|
Loading…
Add table
Reference in a new issue