Default output variable holds a generic writer, and any output that isn't really sure where to output to can just output there. Set by the system early in boot. Also made some changes to the makefile to support arguments in the "make run" or "make debug" subset of calls. For now, it's just VGA=1/0 or SERIAL=1/0 to enable/disable VGA/serial. Defaults are VGA=1, SERIAL=0.
26 lines
653 B
C
26 lines
653 B
C
/* io.h
|
|
* In/Out
|
|
*
|
|
* Common library for handling user i/o. Aims to be mechanic agnostic, and instead
|
|
* focus on implementing generic functions to format and manipulate data.
|
|
*/
|
|
#ifndef IO_H
|
|
#define IO_H
|
|
#include <stdint.h>
|
|
|
|
typedef struct char_writer_s char_writer_t;
|
|
struct char_writer_s {
|
|
int (*putChar)(void* ctx, char out);
|
|
void* ctx;
|
|
};
|
|
|
|
extern char_writer_t* default_output;
|
|
|
|
int putc(char_writer_t*, char);
|
|
int print(char_writer_t*, const char*);
|
|
int println(char_writer_t*, const char*);
|
|
int printhex(char_writer_t*, uint32_t);
|
|
int prindec(char_writer_t*, uint32_t out);
|
|
int printf(char_writer_t*, const char* fmt, ...);
|
|
|
|
#endif
|