From 22fea378b4b6a9f01b87c0a641662666fb3c8945 Mon Sep 17 00:00:00 2001 From: xamidev Date: Sun, 15 Mar 2026 09:53:29 +0100 Subject: [PATCH] comments --- src/io/term/term.c | 21 +++++++++++++++++++-- src/sched/spinlock.c | 15 +++++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/io/term/term.c b/src/io/term/term.c index f6b5ab7..20aa132 100644 --- a/src/io/term/term.c +++ b/src/io/term/term.c @@ -34,7 +34,7 @@ struct spinlock_t term_lock = {0}; extern int panic_count; /* - * _putchar - Writes a character to terminal + * _putchar - Writes a character to terminal (DEPRECATED) * @character: character to write */ void _putchar(char character) @@ -43,6 +43,14 @@ void _putchar(char character) flanterm_write(ft_ctx, &character, 1); } +/* + * internal_putc - Internal putchar function + * @c: char to print + * @_: (unused, for nanoprintf) + * + * Prints a character to the terminal if it's ready, + * and also to the serial interface if it's ready. + */ void internal_putc(int c, void *_) { (void)_; @@ -58,7 +66,6 @@ void internal_putc(int c, void *_) } } - if (init.serial) { if (ch == '\n') { skputc('\r'); @@ -67,6 +74,16 @@ void internal_putc(int c, void *_) } } +/* + * printf - Fromatted printing + * @fmt: format string + * @...: variadic arguments + * + * Wrapper for nanoprintf + * + * Return: + * - number of characters sent to the callback + */ int printf(const char* fmt, ...) { va_list args; diff --git a/src/sched/spinlock.c b/src/sched/spinlock.c index 5ae6fa1..2a50ecd 100644 --- a/src/sched/spinlock.c +++ b/src/sched/spinlock.c @@ -9,6 +9,13 @@ #include "kernel.h" #include "spinlock.h" +/* + * spinlock_acquire - Lock a lock + * @lock: pointer to desired spinlock + * + * Saves the RFLAGS register, then acquires a lock. + * Pause instruction is used to ease the CPU. + */ void spinlock_acquire(struct spinlock_t* lock) { uint64_t rflags; @@ -21,6 +28,14 @@ void spinlock_acquire(struct spinlock_t* lock) lock->rflags = rflags; } +/* + * spinlock_release - Unlock a lock + * @lock: pointer to desired spinlock + * + * Gets saved RFLAGS register from the lock and + * unlocks it (clears locked state). + * RFLAGS is then restored. + */ void spinlock_release(struct spinlock_t* lock) { uint64_t rflags = lock->rflags;