kernel: add basic console registration system and printk()

This commit is contained in:
2023-02-04 19:03:45 +00:00
parent d0a431c860
commit 31cb7aab8b
11 changed files with 186 additions and 31 deletions

View File

@@ -1,7 +1,29 @@
#ifndef SOCKS_CONSOLE_H_
#define SOCKS_CONSOLE_H_
extern void console_init(void);
extern void console_putchar(int c);
#include <socks/queue.h>
#include <socks/locks.h>
#include <socks/status.h>
typedef enum console_flags {
CON_BOOT = 0x01u,
} console_flags_t;
typedef struct console {
char c_name[16];
console_flags_t c_flags;
spin_lock_t c_lock;
void (*c_write)(struct console *, const char *, unsigned int);
int (*c_read)(struct console *, char *, unsigned int);
queue_entry_t c_list;
} console_t;
extern kern_status_t console_register(console_t *con);
extern kern_status_t console_unregister(console_t *con);
extern void console_write(console_t *con, const char *s, unsigned int len);
extern int console_read(console_t *con, char *s, unsigned int len);
#endif

View File

@@ -1,6 +1,9 @@
#ifndef SOCKS_PRINTK_H_
#define SOCKS_PRINTK_H_
#include <socks/console.h>
extern void early_printk_init(console_t *con);
extern int printk(const char *format, ...);
#endif

View File

@@ -3,7 +3,8 @@
typedef unsigned int kern_status_t;
#define KERN_OK (0)
#define KERN_ERR_UNIMPLEMENTED (1)
#define KERN_OK (0)
#define KERN_UNIMPLEMENTED (1)
#define KERN_NAME_EXISTS (2)
#endif