10#define SLOT_WRITING 0xFE
11#define SLOT_DROPPED 0xFF
13#define CONSOLE_BUFFER_SIZE 2048
14#define CONSOLE_BUFFER_MASK (CONSOLE_BUFFER_SIZE - 1)
15#define SPIN_LIMIT 500000u
87 if (__atomic_compare_exchange_n(
89 __ATOMIC_ACQ_REL, __ATOMIC_RELAXED))
91 __asm__
volatile(
"pause");
105 while (__atomic_load_n(&entry->
len, __ATOMIC_ACQUIRE) !=
SLOT_EMPTY) {
111 __asm__
volatile(
"pause");
122 __atomic_store_n(&entry->
len,
len, __ATOMIC_RELEASE);
144 len = __atomic_load_n(&entry->
len, __ATOMIC_ACQUIRE);
151 __asm__
volatile(
"pause");
190 char* out = (
char*)
kalloc(65);
202 const char* digits =
"0123456789ABCDEF";
204 buf[i++] = digits[val %
base];
208 for (i = i - 1; i >= 0; i--)
218#define FLUSH_TEMP() \
220 put_into_buffer(temp, (uint8_t)tidx, fgcolor); \
233 char* s = __builtin_va_arg(args,
char*);
239 (slen > 128) ? 128 : (
uint8_t)slen;
262 __builtin_va_arg(args,
uint64_t), 10);
272 __builtin_va_arg(args,
uint64_t), 16);
282 __builtin_va_arg(args,
uint64_t), 2);
291 char c = (char)__builtin_va_arg(args,
int);
319 __builtin_va_list args;
320 __builtin_va_start(args, fmt);
322 __builtin_va_end(args);
358 int c = (n > 128) ? 128 : n;
360 for (
int i = 0; i < c; i++)
void console_chfg(uint32_t color)
static void do_scroll(void)
static spinlock_t __console_producer_lock
void console_add_space(int n)
void console_set_pos(int x, int y)
static void console_flush(void)
void console_vaprintf(const char *fmt, __builtin_va_list args)
static void vprintf_internal(const char *fmt, __builtin_va_list args)
void console_printf(const char *fmt,...)
void console_print(const char *str, uint64_t len)
int console_get_pos_x(void)
#define CONSOLE_BUFFER_SIZE
void console_newline(void)
static char * val_to_str(uint64_t val, uint64_t base)
static volatile unsigned char __console_flush_lock
static bool reserve_slot(uint32_t *out_idx)
static void put_char_raw(char c, uint32_t color)
void console_println(const char *str)
static console_ring_buffer_t __console_buffer
static void put_into_buffer(const char *str, uint8_t len, uint32_t color)
int console_get_pos_y(void)
static void advance_cursor(void)
#define CONSOLE_BUFFER_MASK
elf_section_map uintptr_t base
uint32_t screen_cols(void)
uint32_t screen_rows(void)
void putc(char c, int col, int row, uint32_t fg, uint32_t bg)
static void irq_restore(uintptr_t flags)
static uintptr_t irq_save(void)
void * kalloc(size_t size)
void spin_acquire(spinlock_t *lock)
void spin_release(spinlock_t *lock)
size_t strlen(const char *s)
kstring str(const char *str)
console_entry_t buffer[2048]