mirror of
https://github.com/ivoszbg/uniLoader.git
synced 2024-11-21 19:40:07 +00:00
lib: Move debug print function into a separate file
Signed-off-by: Ivaylo Ivanov <ivo.ivanov.ivanov1@gmail.com>
This commit is contained in:
parent
0ac15a9da6
commit
c038c7839c
12
include/lib/debug.h
Normal file
12
include/lib/debug.h
Normal file
@ -0,0 +1,12 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
/*
|
||||
* Copyright (c) 2022, Ivaylo Ivanov <ivo.ivanov.ivanov1@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef DEBUG_H_ /* Include guard */
|
||||
#define DEBUG_H_
|
||||
|
||||
extern void draw_text(volatile char *fb, char *text, int textX, int textY, int width, int stride);
|
||||
long int debug_linecount = 0;
|
||||
|
||||
#endif
|
@ -11,8 +11,7 @@ extern void load_kernel(void* dtb, void* x1, void* x2, void* x3, void* kernel);
|
||||
extern void soc_init(void);
|
||||
extern void board_init(void);
|
||||
|
||||
extern void draw_text(volatile char *fb, char *text, int textX, int textY);
|
||||
extern void debug_printfb(volatile char *fb, char *text, int textX, int width, int stride);
|
||||
extern void printk(char *text);
|
||||
|
||||
/* Define our own 128 bit memcpy */
|
||||
void memcpy(void *dest, void *src, int size)
|
||||
|
@ -1 +1,2 @@
|
||||
lib-$(CONFIG_SIMPLE_FB) += simplefb/simplefb.o
|
||||
lib-y += debug/debug.o
|
||||
|
18
lib/debug/debug.c
Normal file
18
lib/debug/debug.c
Normal file
@ -0,0 +1,18 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
/*
|
||||
* Copyright (c) 2022, Ivaylo Ivanov <ivo.ivanov.ivanov1@gmail.com>
|
||||
*/
|
||||
#include <lib/debug.h>
|
||||
|
||||
void printk(char *text) {
|
||||
#ifdef CONFIG_SIMPLE_FB
|
||||
/* IMPORTANT: Limit the linecount */
|
||||
if(debug_linecount > 100 || debug_linecount < 0)
|
||||
debug_linecount = 0;
|
||||
|
||||
draw_text((char*)CONFIG_FRAMEBUFFER_BASE, "[uniLoader] ", 0, (20 + (debug_linecount * 30)), CONFIG_FRAMEBUFFER_WIDTH, CONFIG_FRAMEBUFFER_STRIDE);
|
||||
draw_text((char*)CONFIG_FRAMEBUFFER_BASE, text, 0 + (12 * 8), (20 + (debug_linecount * 30)), CONFIG_FRAMEBUFFER_WIDTH, CONFIG_FRAMEBUFFER_STRIDE);
|
||||
|
||||
debug_linecount++;
|
||||
#endif
|
||||
}
|
@ -8,8 +8,6 @@
|
||||
#include <lib/simplefb.h>
|
||||
#include <lib/font.h>
|
||||
|
||||
int debug_linecount = 0;
|
||||
|
||||
void clean_fb(volatile char *fb, char *text, int width, int height, int stride) {
|
||||
for (volatile char *addr = fb; addr < fb + (width * height * stride); addr += stride)
|
||||
*(int*) (addr) = 0x0;
|
||||
@ -61,17 +59,6 @@ void draw_text(volatile char *fb, char *text, int textX, int textY, int width, i
|
||||
}
|
||||
}
|
||||
|
||||
void debug_printfb(volatile char *fb, char *text, int textX, int width, int stride) {
|
||||
/* IMPORTANT: Limit the linecount */
|
||||
if(debug_linecount > 100 || debug_linecount < 0)
|
||||
debug_linecount = 0;
|
||||
|
||||
draw_text(fb, "[uniLoader] ", textX, (20 + (debug_linecount * 30)), width, stride);
|
||||
draw_text(fb, text, textX + 96, (20 + (debug_linecount * 30)), width, stride);
|
||||
|
||||
debug_linecount++;
|
||||
}
|
||||
|
||||
/* Helper functions */
|
||||
font_params get_font_params() {
|
||||
font_params params = {.width=FONTW, .height=FONTH};
|
||||
|
12
main/main.c
12
main/main.c
@ -10,19 +10,13 @@ void main(void* dt, void* kernel) {
|
||||
|
||||
/* Initialize SoC and Board specific peripherals/quirks */
|
||||
soc_init();
|
||||
#ifdef CONFIG_SIMPLE_FB
|
||||
debug_printfb((char*)CONFIG_FRAMEBUFFER_BASE, "soc_init() passed!", 0, CONFIG_FRAMEBUFFER_WIDTH, CONFIG_FRAMEBUFFER_STRIDE);
|
||||
#endif
|
||||
printk("soc_init() passed!");
|
||||
|
||||
board_init();
|
||||
#ifdef CONFIG_SIMPLE_FB
|
||||
debug_printfb((char*)CONFIG_FRAMEBUFFER_BASE, "board_init() passed!", 0, CONFIG_FRAMEBUFFER_WIDTH, CONFIG_FRAMEBUFFER_STRIDE);
|
||||
#endif
|
||||
printk("board_init() passed!");
|
||||
|
||||
/* Copy kernel to memory and boot */
|
||||
#ifdef CONFIG_SIMPLE_FB
|
||||
debug_printfb((char*)CONFIG_FRAMEBUFFER_BASE, "Booting linux...", 0, CONFIG_FRAMEBUFFER_WIDTH, CONFIG_FRAMEBUFFER_STRIDE);
|
||||
#endif
|
||||
printk("Booting linux...");
|
||||
memcpy((void*)CONFIG_PAYLOAD_ENTRY, kernel, (unsigned long) &kernel_size);
|
||||
load_kernel(dt, 0, 0, 0, (void*)CONFIG_PAYLOAD_ENTRY);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user