Add printf for debug: pr_devel

Taken from linux kernel
This commit is contained in:
Mathieu Maret 2019-04-11 22:32:50 +02:00
parent 4e050d5364
commit 28309db7b9
1 changed files with 24 additions and 0 deletions

View File

@ -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