|
|
@@ -4,18 +4,22 @@
|
|
|
* vga_cache_boot_fb(), which probes the GPU and maps BARs, and this code runs
|
|
|
* before mm_init/paging_init exist. It reads the boot framebuffer info block
|
|
|
* at 0x600 directly, exactly like paging.c does.
|
|
|
+ *
|
|
|
+ * The console uses the same 8x16 Terminus face and cell grid as the ring-3
|
|
|
+ * terminal, and starts at the top-left like the BIOS text console, so the
|
|
|
+ * loader -> kernel -> WM handoff does not change the text size or jump around
|
|
|
+ * the screen. A full screen scrolls instead of wrapping back to the top.
|
|
|
*/
|
|
|
#include "bootcon.h"
|
|
|
#include "bootinfo.h"
|
|
|
-#include "font_8x8.h"
|
|
|
+#include "font_8x16.h"
|
|
|
#include "mm.h"
|
|
|
#include "serial.h"
|
|
|
#include "vga.h"
|
|
|
|
|
|
-#define SCALE 2
|
|
|
-#define LINE_H (8 * SCALE + 2)
|
|
|
-#define LEFT 8
|
|
|
-#define TOP 8
|
|
|
+#define CELL_W 8
|
|
|
+#define CELL_H 16
|
|
|
+#define MARGIN 8
|
|
|
|
|
|
static unsigned int fb_w, fb_h, fb_pitch, fb_bpp;
|
|
|
static unsigned int fb_base;
|
|
|
@@ -23,11 +27,12 @@ static volatile unsigned char *fb_lfb;
|
|
|
static int fb_swap;
|
|
|
static int fb_ok;
|
|
|
static int enabled;
|
|
|
-static unsigned int cur_x, cur_y;
|
|
|
-static unsigned int home_x, home_y;
|
|
|
+static unsigned int con_x, con_y; /* console pixel origin */
|
|
|
+static unsigned int con_cols, con_rows;
|
|
|
+static unsigned int cur_col, cur_row;
|
|
|
|
|
|
/* Text log kept independently of the framebuffer: bootcon is disabled when
|
|
|
- * the WM starts, but the e1000e probe and later driver messages still go
|
|
|
+ * the WM attaches, but the e1000e probe and later driver messages still go
|
|
|
* through bootcon_puts(). The buffer is allocated from the frame allocator
|
|
|
* (see bootcon_log_init) so it does not move the kernel's _end past the low
|
|
|
* rootfs pack at 0x60000. */
|
|
|
@@ -59,36 +64,66 @@ static void fb_px(unsigned int x, unsigned int y, unsigned int r,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-/* Clear the band the next line will be drawn into, so a reused line (after
|
|
|
- * wrapping at the bottom) cannot leave parts of an older message behind. */
|
|
|
+/* Clear the band the current row will be drawn into, so a reused line
|
|
|
+ * cannot leave parts of an older message behind. */
|
|
|
static void clear_line(void)
|
|
|
{
|
|
|
unsigned int x, y;
|
|
|
+ unsigned int y0 = con_y + cur_row * CELL_H;
|
|
|
|
|
|
- for (y = 0; y < LINE_H; y++)
|
|
|
- for (x = 0; x < fb_w; x++)
|
|
|
- fb_px(x, cur_y + y, 0, 0, 0);
|
|
|
+ for (y = 0; y < CELL_H; y++)
|
|
|
+ for (x = 0; x < con_cols * CELL_W; x++)
|
|
|
+ fb_px(con_x + x, y0 + y, 0, 0, 0);
|
|
|
}
|
|
|
|
|
|
static void draw_char(unsigned int x, unsigned int y, unsigned char c)
|
|
|
{
|
|
|
- const unsigned char *g = &font_8x8[(unsigned int)c * 8];
|
|
|
+ const unsigned char *g = &font_8x16[(unsigned int)c * FONT_8X16_ROWS];
|
|
|
unsigned int row, col;
|
|
|
|
|
|
- for (row = 0; row < 8; row++) {
|
|
|
+ for (row = 0; row < FONT_8X16_ROWS; row++) {
|
|
|
unsigned char bits = g[row];
|
|
|
|
|
|
- for (col = 0; col < 8; col++) {
|
|
|
- if (bits & (0x80u >> col)) {
|
|
|
- unsigned int i, j;
|
|
|
+ for (col = 0; col < CELL_W; col++)
|
|
|
+ if (bits & (0x80u >> col))
|
|
|
+ fb_px(x + col, y + row, 255, 255, 255);
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
- for (i = 0; i < SCALE; i++)
|
|
|
- for (j = 0; j < SCALE; j++)
|
|
|
- fb_px(x + col * SCALE + i,
|
|
|
- y + row * SCALE + j,
|
|
|
- 255, 255, 255);
|
|
|
- }
|
|
|
- }
|
|
|
+/* Move the console up one text row: every row takes the pixels of the row
|
|
|
+ * below it and the last row is cleared. Only used when the cursor is on the
|
|
|
+ * last row, so a normal boot never pays for it.
|
|
|
+ *
|
|
|
+ * Every supported bpp puts a whole number of dwords on a scanline for CELL_W
|
|
|
+ * pixels, and the console origin is a multiple of 4 pixels, so no partial
|
|
|
+ * dword is left behind. Plain word loads/stores are used rather than
|
|
|
+ * `rep movsl`: the source is the LFB, not RAM. */
|
|
|
+static void scroll_up(void)
|
|
|
+{
|
|
|
+ unsigned int pb = fb_bpp / 8;
|
|
|
+ unsigned int dwords = (con_cols * CELL_W * pb) / 4;
|
|
|
+ unsigned char *base = (unsigned char *)fb_lfb +
|
|
|
+ (unsigned long)con_y * fb_pitch + con_x * pb;
|
|
|
+ unsigned int line, i;
|
|
|
+ unsigned int lines = con_rows * CELL_H;
|
|
|
+
|
|
|
+ /* Move every scanline below the first text row up by one cell. */
|
|
|
+ for (line = 0; line < lines - CELL_H; line++) {
|
|
|
+ unsigned int *dst = (unsigned int *)(base +
|
|
|
+ (unsigned long)line * fb_pitch);
|
|
|
+ const unsigned int *src = (const unsigned int *)(base +
|
|
|
+ (unsigned long)(line + CELL_H) * fb_pitch);
|
|
|
+
|
|
|
+ for (i = 0; i < dwords; i++)
|
|
|
+ dst[i] = src[i];
|
|
|
+ }
|
|
|
+ /* Clear the bottom cell. */
|
|
|
+ for (line = lines - CELL_H; line < lines; line++) {
|
|
|
+ unsigned int *dst = (unsigned int *)(base +
|
|
|
+ (unsigned long)line * fb_pitch);
|
|
|
+
|
|
|
+ for (i = 0; i < dwords; i++)
|
|
|
+ dst[i] = 0;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -101,8 +136,6 @@ void bootcon_init(void)
|
|
|
|
|
|
fb_ok = 0;
|
|
|
enabled = 0;
|
|
|
- cur_x = LEFT;
|
|
|
- cur_y = TOP;
|
|
|
if (!fb->valid || !fb->lfb_base)
|
|
|
return;
|
|
|
|
|
|
@@ -124,20 +157,19 @@ void bootcon_init(void)
|
|
|
if (!fb_w || !fb_h || !fb_pitch || !fb_lfb)
|
|
|
return;
|
|
|
|
|
|
+ con_x = MARGIN;
|
|
|
+ con_y = MARGIN;
|
|
|
+ if (fb_w <= con_x + CELL_W || fb_h <= con_y + CELL_H)
|
|
|
+ return;
|
|
|
+ con_cols = (fb_w - 2 * MARGIN) / CELL_W;
|
|
|
+ con_rows = (fb_h - 2 * MARGIN) / CELL_H;
|
|
|
+ if (!con_cols || !con_rows)
|
|
|
+ return;
|
|
|
+
|
|
|
fb_ok = 1;
|
|
|
enabled = 1;
|
|
|
- /* Start away from the very top-left: some VBIOSes centre a mode that
|
|
|
- * does not match the panel (e.g. 1280x1024 on a 1280x800 LVDS), which
|
|
|
- * crops the outer rows/columns. Starting at 1/8,1/4 keeps the log
|
|
|
- * inside the visible area in both the centred and the scaled case. */
|
|
|
- home_x = fb_w / 8;
|
|
|
- home_y = fb_h / 4;
|
|
|
- if (home_x < 8)
|
|
|
- home_x = 8;
|
|
|
- if (home_y < 8)
|
|
|
- home_y = 8;
|
|
|
- cur_x = home_x;
|
|
|
- cur_y = home_y;
|
|
|
+ cur_col = 0;
|
|
|
+ cur_row = 0;
|
|
|
clear_line();
|
|
|
}
|
|
|
|
|
|
@@ -155,10 +187,13 @@ void bootcon_set_enabled(int on)
|
|
|
|
|
|
static void newline(void)
|
|
|
{
|
|
|
- cur_x = home_x;
|
|
|
- cur_y += LINE_H;
|
|
|
- if (cur_y + 8 * SCALE > fb_h)
|
|
|
- cur_y = home_y;
|
|
|
+ cur_col = 0;
|
|
|
+ if (cur_row + 1 >= con_rows) {
|
|
|
+ scroll_up();
|
|
|
+ cur_row = con_rows - 1;
|
|
|
+ } else {
|
|
|
+ cur_row++;
|
|
|
+ }
|
|
|
clear_line();
|
|
|
}
|
|
|
|
|
|
@@ -197,17 +232,18 @@ void bootcon_puts(const char *s)
|
|
|
if (!fb_ok || !enabled)
|
|
|
continue;
|
|
|
if (c == '\r') {
|
|
|
- cur_x = LEFT;
|
|
|
+ cur_col = 0;
|
|
|
continue;
|
|
|
}
|
|
|
if (c == '\n') {
|
|
|
newline();
|
|
|
continue;
|
|
|
}
|
|
|
- if (cur_x + 8 * SCALE > fb_w)
|
|
|
+ if (cur_col >= con_cols)
|
|
|
newline();
|
|
|
- draw_char(cur_x, cur_y, c);
|
|
|
- cur_x += 8 * SCALE;
|
|
|
+ draw_char(con_x + cur_col * CELL_W,
|
|
|
+ con_y + cur_row * CELL_H, c);
|
|
|
+ cur_col++;
|
|
|
}
|
|
|
}
|
|
|
|