Wanderer/Info: fix compilation
[AROS.git] / arch / all-native / bootconsole / common.c
blob83b805ec2c5c12f81bc237fe30d46d68ec0fb5ba
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Common console output functions.
6 */
8 #include <aros/multiboot.h>
10 #include <bootconsole.h>
11 #include <stdarg.h>
12 #include <string.h>
14 #include "console.h"
16 /* Screen type */
17 __attribute__((section(".data"))) unsigned char scr_Type = SCR_UNKNOWN;
19 __attribute__((section(".data"))) static unsigned char use_serial = 0;
21 void con_InitVESA(unsigned short version, struct vbe_mode *mode)
23 scr_FrameBuffer = (version >= 0x0200) ? (void *)(unsigned long)mode->phys_base : NULL;
25 if (mode->mode_attributes & VM_GRAPHICS)
27 unsigned int pitch;
29 scr_Type = SCR_GFX;
31 /* Use 3.0-specific field if available */
32 if ((mode->mode_attributes & VM_LINEAR_FB) && (version >= 0x0300))
33 pitch = mode->linear_bytes_per_scanline;
34 else
35 pitch = mode->bytes_per_scanline;
37 fb_Init(mode->x_resolution, mode->y_resolution, mode->bits_per_pixel, pitch);
39 else
41 scr_Type = SCR_TEXT;
42 scr_Width = mode->x_resolution;
43 scr_Height = mode->y_resolution;
45 /* CHECKME: is it correct? It should fall back to VGA buffer address for text modes */
46 if (!scr_FrameBuffer)
47 scr_FrameBuffer = (void *)((unsigned long)mode->win_b_segment << 16);
49 * QEmu in text mode (VBE number 0x03) is known to supply neither phys_base nor
50 * window segments (all three are NULLs). This is a workaround for this.
51 */
52 if (!scr_FrameBuffer)
53 scr_FrameBuffer = VGA_TEXT_ADDR;
55 txt_Clear();
58 /* We must have valid framebuffer address here */
59 if (!scr_FrameBuffer)
60 scr_Type = SCR_UNKNOWN;
63 void con_InitVGA(void)
65 scr_Type = SCR_TEXT;
66 scr_FrameBuffer = VGA_TEXT_ADDR;
67 scr_Width = VGA_TEXT_WIDTH;
68 scr_Height = VGA_TEXT_HEIGHT;
70 txt_Clear();
73 void con_InitSerial(char *cmdline)
75 char *opts = strstr(cmdline, "debug=serial");
77 if (opts)
79 use_serial = 1;
81 serial_Init(&opts[12]);
83 else
84 use_serial = 0;
87 void con_Putc(char c)
89 /* 0x03 character shuts off boot-time screen console */
90 if (c == 0x03)
92 scr_Type = SCR_UNKNOWN;
93 return;
96 if (use_serial)
97 serial_Putc(c);
99 switch (scr_Type)
101 case SCR_TEXT:
102 txt_Putc(c);
103 break;
105 case SCR_GFX:
106 fb_Putc(c);
107 break;