Commit 28309db7 authored by Mathieu Maret's avatar Mathieu Maret

Add printf for debug: pr_devel

Taken from linux kernel
parent 4e050d53
#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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment