Copyright clean-up (part 1):
[AROS.git] / arch / i386-pc / kernel / kernel_debug.c
blob9c167bc2ca9cc11acd00d9ec23dc04c6f5cf2ccb
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <bootconsole.h>
7 #include <string.h>
9 #include "kernel_base.h"
10 #include "kernel_debug.h"
11 #include "kernel_intern.h"
13 #define __save_flags(x) __asm__ __volatile__("pushf ; pop %0":"=g" (x): /* no input */)
14 #define __restore_flags(x) __asm__ __volatile__("push %0 ; popf": /* no output */ :"g" (x):"memory", "cc")
15 #define __cli() __asm__ __volatile__("cli": : :"memory")
16 #define __sti() __asm__ __volatile__("sti": : :"memory")
18 __attribute__((section(".data"))) static unsigned int debug_y_resolution = 0;
19 __attribute__((section(".data"))) static void *debug_framebuffer = NULL;
21 int krnPutC(int c, struct KernelBase *KernelBase)
23 unsigned long flags;
25 __save_flags(flags);
28 * stegerg: Don't use Disable/Enable, because we want interrupt enabled flag
29 * to stay the same as it was before the Disable() call
31 __cli();
34 * If we got 0x03, this means graphics driver wants to take over the screen.
35 * If VESA hack is activated, it will use only upper half of the screen
36 * because y resolution was adjusted.
37 * In our turn, we need to switch over to lower half.
38 * VESA hack is supported only on graphical console of course. And do not
39 * expect it to work with native mode video driver. :)
41 if ((c == 0x03) && (scr_Type == SCR_GFX) && debug_framebuffer)
43 /* Reinitialize boot console with decreased height */
44 scr_FrameBuffer = debug_framebuffer;
45 fb_Resize(debug_y_resolution);
47 else
48 con_Putc(c);
51 * Interrupt flag is stored in flags - if it was enabled before,
52 * it will be renabled when the flags are restored
54 __restore_flags(flags);
56 return 1;
59 void vesahack_Init(char *cmdline, struct vbe_mode *vmode)
61 if (cmdline && vmode && vmode->phys_base && strstr(cmdline, "vesahack"))
63 bug("[Kernel] VESA debugging hack activated\n");
66 * VESA hack.
67 * It divides screen height by 2 and increments framebuffer pointer.
68 * This allows VESA driver to use only upper half of the screen, while
69 * lower half will still be used for debug output.
71 vmode->y_resolution >>= 1;
73 debug_y_resolution = vmode->y_resolution;
74 debug_framebuffer = (void *)(unsigned long)vmode->phys_base + vmode->y_resolution * vmode->bytes_per_scanline;