diff --git a/drivers/vga.h b/drivers/vga.h index fd041fc..5c90649 100644 --- a/drivers/vga.h +++ b/drivers/vga.h @@ -1,5 +1,6 @@ #pragma once #include "stdarg.h" +#include "stdint.h" // https://wiki.osdev.org/Text_UI #define BLACK 0x00 @@ -16,6 +17,10 @@ #define VGA_WIDTH 80 #define VGA_HEIGHT 25 +#ifndef pr_fmt +#define pr_fmt(fmt) fmt +#endif + void vprintf(const char *format, va_list ap); void printf(const char *format, ...); int VGASetup(uint bgColor, uint color); @@ -31,3 +36,22 @@ void vgaScrollUp(void); void cursorEnable(uint8_t cursor_start, uint8_t cursor_end); void cursorDisable(void); void cursorMove(int x, int y); + +/* + * Dummy printk for disabled debugging statements to use whilst maintaining + * gcc's format checking. + */ +#define no_printf(fmt, ...) \ +({ \ + if (0) \ + printf(fmt, ##__VA_ARGS__); \ + 0; \ +}) + +#ifdef DEBUG +#define pr_devel(fmt, ...) \ + printf(pr_fmt(fmt), ##__VA_ARGS__) +#else +#define pr_devel(fmt, ...) \ + no_printf(pr_fmt(fmt), ##__VA_ARGS__) +#endif