Subversion Repositories HelenOS

Rev

Rev 4676 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
836 palkovsky 1
/*
3707 decky 2
 * Copyright (c) 2008 Martin Decky
2071 jermar 3
 * Copyright (c) 2006 Ondrej Palkovsky
836 palkovsky 4
 * All rights reserved.
5
 *
6
 * Redistribution and use in source and binary forms, with or without
7
 * modification, are permitted provided that the following conditions
8
 * are met:
9
 *
10
 * - Redistributions of source code must retain the above copyright
11
 *   notice, this list of conditions and the following disclaimer.
12
 * - Redistributions in binary form must reproduce the above copyright
13
 *   notice, this list of conditions and the following disclaimer in the
14
 *   documentation and/or other materials provided with the distribution.
15
 * - The name of the author may not be used to endorse or promote products
16
 *   derived from this software without specific prior written permission.
17
 *
18
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
 */
29
 
3707 decky 30
/** @addtogroup genarch
1702 cejka 31
 * @{
32
 */
33
/** @file
34
 */
35
 
837 palkovsky 36
#include <genarch/fb/font-8x16.h>
3710 decky 37
#include <genarch/fb/logo-196x66.h>
1993 decky 38
#include <genarch/fb/visuals.h>
837 palkovsky 39
#include <genarch/fb/fb.h>
836 palkovsky 40
#include <console/chardev.h>
41
#include <console/console.h>
1317 vana 42
#include <sysinfo/sysinfo.h>
1316 jermar 43
#include <mm/slab.h>
3707 decky 44
#include <align.h>
839 palkovsky 45
#include <panic.h>
896 jermar 46
#include <memstr.h>
1316 jermar 47
#include <config.h>
1682 palkovsky 48
#include <bitops.h>
49
#include <print.h>
4223 decky 50
#include <string.h>
2015 jermar 51
#include <ddi/ddi.h>
2054 jermar 52
#include <arch/types.h>
4676 jermar 53
#include <byteorder.h>
836 palkovsky 54
 
3707 decky 55
SPINLOCK_INITIALIZE(fb_lock);
862 palkovsky 56
 
3707 decky 57
static uint8_t *fb_addr;
4177 decky 58
static uint16_t *backbuf;
3707 decky 59
static uint8_t *glyphs;
3710 decky 60
static uint8_t *bgscan;
836 palkovsky 61
 
3707 decky 62
static unsigned int xres;
63
static unsigned int yres;
1316 jermar 64
 
3710 decky 65
static unsigned int ylogo;
66
static unsigned int ytrim;
67
static unsigned int rowtrim;
68
 
3707 decky 69
static unsigned int scanline;
70
static unsigned int glyphscanline;
836 palkovsky 71
 
3707 decky 72
static unsigned int pixelbytes;
73
static unsigned int glyphbytes;
3710 decky 74
static unsigned int bgscanbytes;
3707 decky 75
 
76
static unsigned int cols;
77
static unsigned int rows;
1135 decky 78
static unsigned int position = 0;
836 palkovsky 79
 
3707 decky 80
#define BG_COLOR     0x000080
81
#define FG_COLOR     0xffff00
4187 decky 82
#define INV_COLOR    0xaaaaaa
836 palkovsky 83
 
4676 jermar 84
#define RED(x, bits)         (((x) >> (8 + 8 + 8 - (bits))) & ((1 << (bits)) - 1))
85
#define GREEN(x, bits)       (((x) >> (8 + 8 - (bits))) & ((1 << (bits)) - 1))
86
#define BLUE(x, bits)        (((x) >> (8 - (bits))) & ((1 << (bits)) - 1))
1135 decky 87
 
3707 decky 88
#define COL2X(col)           ((col) * FONT_WIDTH)
89
#define ROW2Y(row)           ((row) * FONT_SCANLINES)
1135 decky 90
 
3707 decky 91
#define X2COL(x)             ((x) / FONT_WIDTH)
92
#define Y2ROW(y)             ((y) / FONT_SCANLINES)
838 palkovsky 93
 
3707 decky 94
#define FB_POS(x, y)         ((y) * scanline + (x) * pixelbytes)
95
#define BB_POS(col, row)     ((row) * cols + (col))
96
#define GLYPH_POS(glyph, y)  ((glyph) * glyphbytes + (y) * glyphscanline)
839 palkovsky 97
 
1875 jermar 98
 
3707 decky 99
static void (*rgb_conv)(void *, uint32_t);
836 palkovsky 100
 
4676 jermar 101
/*
102
 * RGB conversion functions.
3707 decky 103
 *
4676 jermar 104
 * These functions write an RGB value to some memory in some predefined format.
105
 * The naming convention corresponds to the format created by these functions.
106
 * The functions use the so called network order (i.e. big endian) with respect
107
 * to their names.
3707 decky 108
 */
4676 jermar 109
 
3707 decky 110
static void rgb_0888(void *dst, uint32_t rgb)
1994 decky 111
{
4676 jermar 112
	*((uint32_t *) dst) = host2uint32_t_be((0 << 24) |
113
	    (RED(rgb, 8) << 16) | (GREEN(rgb, 8) << 8) | (BLUE(rgb, 8)));
1994 decky 114
}
115
 
3707 decky 116
static void bgr_0888(void *dst, uint32_t rgb)
1994 decky 117
{
4676 jermar 118
	*((uint32_t *) dst) = host2uint32_t_be((0 << 24) |
119
	    (BLUE(rgb, 8) << 16) | (GREEN(rgb, 8) << 8) | (RED(rgb, 8)));
1994 decky 120
}
121
 
4669 pillai 122
static void rgb_8880(void *dst, uint32_t rgb)
123
{
4676 jermar 124
	*((uint32_t *) dst) = host2uint32_t_be((RED(rgb, 8) << 24) |
125
	    (GREEN(rgb,	8) << 16) | (BLUE(rgb, 8) << 8) | 0);
126
}
3707 decky 127
 
4676 jermar 128
static void bgr_8880(void *dst, uint32_t rgb)
129
{
130
	*((uint32_t *) dst) = host2uint32_t_be((BLUE(rgb, 8) << 24) |
131
	    (GREEN(rgb,	8) << 16) | (RED(rgb, 8) << 8) | 0);
4669 pillai 132
}
133
 
3707 decky 134
static void rgb_888(void *dst, uint32_t rgb)
839 palkovsky 135
{
4676 jermar 136
	((uint8_t *) dst)[0] = RED(rgb, 8);
3710 decky 137
	((uint8_t *) dst)[1] = GREEN(rgb, 8);
4676 jermar 138
	((uint8_t *) dst)[2] = BLUE(rgb, 8);
839 palkovsky 139
}
140
 
3876 decky 141
static void bgr_888(void *dst, uint32_t rgb)
142
{
4676 jermar 143
	((uint8_t *) dst)[0] = BLUE(rgb, 8);
3876 decky 144
	((uint8_t *) dst)[1] = GREEN(rgb, 8);
4676 jermar 145
	((uint8_t *) dst)[2] = RED(rgb, 8);
3876 decky 146
}
147
 
4685 jermar 148
static void rgb_555_be(void *dst, uint32_t rgb)
1993 decky 149
{
4685 jermar 150
	*((uint16_t *) dst) = host2uint16_t_be(RED(rgb, 5) << 10 |
151
	    GREEN(rgb, 5) << 5 | BLUE(rgb, 5));
1993 decky 152
}
153
 
4685 jermar 154
static void rgb_555_le(void *dst, uint32_t rgb)
839 palkovsky 155
{
4685 jermar 156
	*((uint16_t *) dst) = host2uint16_t_le(RED(rgb, 5) << 10 |
157
	    GREEN(rgb, 5) << 5 | BLUE(rgb, 5));
839 palkovsky 158
}
159
 
4685 jermar 160
static void rgb_565_be(void *dst, uint32_t rgb)
161
{
162
	*((uint16_t *) dst) = host2uint16_t_be(RED(rgb, 5) << 11 |
163
	    GREEN(rgb, 6) << 5 | BLUE(rgb, 5));
164
}
839 palkovsky 165
 
4685 jermar 166
static void rgb_565_le(void *dst, uint32_t rgb)
167
{
168
	*((uint16_t *) dst) = host2uint16_t_le(RED(rgb, 5) << 11 |
169
	    GREEN(rgb, 6) << 5 | BLUE(rgb, 5));
170
}
171
 
172
 
4676 jermar 173
/** BGR 3:2:3
1837 jermar 174
 *
175
 * Even though we try 3:2:3 color scheme here, an 8-bit framebuffer
176
 * will most likely use a color palette. The color appearance
177
 * will be pretty random and depend on the default installed
178
 * palette. This could be fixed by supporting custom palette
179
 * and setting it to simulate the 8-bit truecolor.
3692 rimsky 180
 *
3709 decky 181
 * Currently we set the palette on the ia32, amd64 and sparc64 port.
3692 rimsky 182
 *
183
 * Note that the byte is being inverted by this function. The reason is
184
 * that we would like to use a color palette where the white color code
3709 decky 185
 * is 0 and the black color code is 255, as some machines (Sun Blade 1500)
3692 rimsky 186
 * use these codes for black and white and prevent to set codes
187
 * 0 and 255 to other colors.
3709 decky 188
 *
1837 jermar 189
 */
4676 jermar 190
static void bgr_323(void *dst, uint32_t rgb)
839 palkovsky 191
{
3707 decky 192
	*((uint8_t *) dst)
193
	    = ~((RED(rgb, 3) << 5) | (GREEN(rgb, 2) << 3) | BLUE(rgb, 3));
1135 decky 194
}
839 palkovsky 195
 
3707 decky 196
 
3710 decky 197
/** Hide logo and refresh screen
198
 *
199
 */
3844 decky 200
static void logo_hide(bool silent)
3710 decky 201
{
202
	ylogo = 0;
203
	ytrim = yres;
204
	rowtrim = rows;
3844 decky 205
	if (!silent)
206
		fb_redraw();
3710 decky 207
}
208
 
209
 
3707 decky 210
/** Draw character at given position
1837 jermar 211
 *
212
 */
4223 decky 213
static void glyph_draw(uint16_t glyph, unsigned int col, unsigned int row, bool silent, bool overlay)
1135 decky 214
{
3707 decky 215
	unsigned int x = COL2X(col);
216
	unsigned int y = ROW2Y(row);
217
	unsigned int yd;
218
 
3710 decky 219
	if (y >= ytrim)
3844 decky 220
		logo_hide(silent);
3710 decky 221
 
4223 decky 222
	if (!overlay)
223
		backbuf[BB_POS(col, row)] = glyph;
3707 decky 224
 
3844 decky 225
	if (!silent) {
226
		for (yd = 0; yd < FONT_SCANLINES; yd++)
227
			memcpy(&fb_addr[FB_POS(x, y + yd + ylogo)],
228
			    &glyphs[GLYPH_POS(glyph, yd)], glyphscanline);
229
	}
839 palkovsky 230
}
231
 
1682 palkovsky 232
 
3707 decky 233
/** Scroll screen down by one row
234
 *
235
 *
236
 */
3844 decky 237
static void screen_scroll(bool silent)
838 palkovsky 238
{
3733 decky 239
	if (ylogo > 0) {
3844 decky 240
		logo_hide(silent);
3733 decky 241
		return;
242
	}
3710 decky 243
 
3844 decky 244
	if (!silent) {
245
		unsigned int row;
2054 jermar 246
 
3844 decky 247
		for (row = 0; row < rows; row++) {
248
			unsigned int y = ROW2Y(row);
249
			unsigned int yd;
3707 decky 250
 
3844 decky 251
			for (yd = 0; yd < FONT_SCANLINES; yd++) {
252
				unsigned int x;
253
				unsigned int col;
3707 decky 254
 
3844 decky 255
				for (col = 0, x = 0; col < cols; col++,
256
				    x += FONT_WIDTH) {
4177 decky 257
					uint16_t glyph;
3707 decky 258
 
3844 decky 259
					if (row < rows - 1) {
260
						if (backbuf[BB_POS(col, row)] ==
261
						    backbuf[BB_POS(col, row + 1)])
262
							continue;
263
 
264
						glyph = backbuf[BB_POS(col, row + 1)];
265
					} else
266
						glyph = 0;
267
 
268
					memcpy(&fb_addr[FB_POS(x, y + yd)],
269
					    &glyphs[GLYPH_POS(glyph, yd)],
270
					    glyphscanline);
271
				}
3707 decky 272
			}
2086 jermar 273
		}
1682 palkovsky 274
	}
3707 decky 275
 
4177 decky 276
	memmove(backbuf, &backbuf[BB_POS(0, 1)], cols * (rows - 1) * sizeof(uint16_t));
277
	memsetw(&backbuf[BB_POS(0, rows - 1)], cols, 0);
838 palkovsky 278
}
279
 
280
 
3844 decky 281
static void cursor_put(bool silent)
836 palkovsky 282
{
4223 decky 283
	unsigned int col = position % cols;
284
	unsigned int row = position / cols;
285
 
286
	glyph_draw(fb_font_glyph(U_CURSOR), col, row, silent, true);
836 palkovsky 287
}
288
 
289
 
3844 decky 290
static void cursor_remove(bool silent)
836 palkovsky 291
{
4223 decky 292
	unsigned int col = position % cols;
293
	unsigned int row = position / cols;
294
 
295
	glyph_draw(backbuf[BB_POS(col, row)], col, row, silent, true);
836 palkovsky 296
}
297
 
838 palkovsky 298
 
836 palkovsky 299
/** Print character to screen
300
 *
3707 decky 301
 * Emulate basic terminal commands.
302
 *
836 palkovsky 303
 */
4177 decky 304
static void fb_putchar(outdev_t *dev, wchar_t ch, bool silent)
836 palkovsky 305
{
1287 vana 306
	spinlock_lock(&fb_lock);
1135 decky 307
 
308
	switch (ch) {
1888 jermar 309
	case '\n':
3844 decky 310
		cursor_remove(silent);
3707 decky 311
		position += cols;
312
		position -= position % cols;
1888 jermar 313
		break;
314
	case '\r':
3844 decky 315
		cursor_remove(silent);
3707 decky 316
		position -= position % cols;
1888 jermar 317
		break;
318
	case '\b':
3844 decky 319
		cursor_remove(silent);
3707 decky 320
		if (position % cols)
1888 jermar 321
			position--;
322
		break;
323
	case '\t':
3844 decky 324
		cursor_remove(silent);
1888 jermar 325
		do {
4177 decky 326
			glyph_draw(fb_font_glyph(' '), position % cols,
4223 decky 327
			    position / cols, silent, false);
838 palkovsky 328
			position++;
3707 decky 329
		} while ((position % 8) && (position < cols * rows));
1888 jermar 330
		break;
331
	default:
4177 decky 332
		glyph_draw(fb_font_glyph(ch), position % cols,
4223 decky 333
		    position / cols, silent, false);
1888 jermar 334
		position++;
836 palkovsky 335
	}
1135 decky 336
 
3707 decky 337
	if (position >= cols * rows) {
338
		position -= cols;
3844 decky 339
		screen_scroll(silent);
836 palkovsky 340
	}
1135 decky 341
 
3844 decky 342
	cursor_put(silent);
1135 decky 343
 
1287 vana 344
	spinlock_unlock(&fb_lock);
836 palkovsky 345
}
346
 
4093 decky 347
static outdev_t fb_console;
348
static outdev_operations_t fb_ops = {
349
	.write = fb_putchar
836 palkovsky 350
};
351
 
352
 
3707 decky 353
/** Render glyphs
354
 *
355
 * Convert glyphs from device independent font
356
 * description to current visual representation.
357
 *
358
 */
3710 decky 359
static void glyphs_render(void)
3707 decky 360
{
3710 decky 361
	/* Prerender glyphs */
4177 decky 362
	uint16_t glyph;
3707 decky 363
 
364
	for (glyph = 0; glyph < FONT_GLYPHS; glyph++) {
4187 decky 365
		uint32_t fg_color;
366
 
367
		if (glyph == FONT_GLYPHS - 1)
368
			fg_color = INV_COLOR;
369
		else
370
			fg_color = FG_COLOR;
371
 
3707 decky 372
		unsigned int y;
373
 
374
		for (y = 0; y < FONT_SCANLINES; y++) {
375
			unsigned int x;
376
 
3741 jermar 377
			for (x = 0; x < FONT_WIDTH; x++) {
378
				void *dst = &glyphs[GLYPH_POS(glyph, y) +
379
				    x * pixelbytes];
4177 decky 380
				uint32_t rgb = (fb_font[glyph][y] &
4187 decky 381
				    (1 << (7 - x))) ? fg_color : BG_COLOR;
3741 jermar 382
				rgb_conv(dst, rgb);
383
			}
3707 decky 384
		}
385
	}
386
 
3710 decky 387
	/* Prerender background scanline */
388
	unsigned int x;
389
 
390
	for (x = 0; x < xres; x++)
391
		rgb_conv(&bgscan[x * pixelbytes], BG_COLOR);
3707 decky 392
}
393
 
394
 
395
/** Refresh the screen
396
 *
397
 */
398
void fb_redraw(void)
399
{
3710 decky 400
	if (ylogo > 0) {
401
		unsigned int y;
402
 
403
		for (y = 0; y < LOGO_HEIGHT; y++) {
404
			unsigned int x;
405
 
406
			for (x = 0; x < xres; x++)
407
				rgb_conv(&fb_addr[FB_POS(x, y)],
3741 jermar 408
				    (x < LOGO_WIDTH) ?
409
				    fb_logo[y * LOGO_WIDTH + x] :
410
				    LOGO_COLOR);
3710 decky 411
		}
412
	}
413
 
3707 decky 414
	unsigned int row;
415
 
3710 decky 416
	for (row = 0; row < rowtrim; row++) {
417
		unsigned int y = ylogo + ROW2Y(row);
3707 decky 418
		unsigned int yd;
419
 
420
		for (yd = 0; yd < FONT_SCANLINES; yd++) {
421
			unsigned int x;
422
			unsigned int col;
423
 
3741 jermar 424
			for (col = 0, x = 0; col < cols;
425
			    col++, x += FONT_WIDTH) {
4177 decky 426
				uint16_t glyph = backbuf[BB_POS(col, row)];
427
				void *dst = &fb_addr[FB_POS(x, y + yd)];
428
				void *src = &glyphs[GLYPH_POS(glyph, yd)];
429
				memcpy(dst, src, glyphscanline);
3741 jermar 430
			}
3707 decky 431
		}
432
	}
433
 
434
	if (COL2X(cols) < xres) {
435
		unsigned int y;
3710 decky 436
		unsigned int size = (xres - COL2X(cols)) * pixelbytes;
3707 decky 437
 
3710 decky 438
		for (y = ylogo; y < yres; y++)
439
			memcpy(&fb_addr[FB_POS(COL2X(cols), y)], bgscan, size);
3707 decky 440
	}
441
 
3733 decky 442
	if (ROW2Y(rowtrim) + ylogo < yres) {
3707 decky 443
		unsigned int y;
444
 
3733 decky 445
		for (y = ROW2Y(rowtrim) + ylogo; y < yres; y++)
3710 decky 446
			memcpy(&fb_addr[FB_POS(0, y)], bgscan, bgscanbytes);
3707 decky 447
	}
448
}
449
 
450
 
4093 decky 451
/** Initialize framebuffer as a output character device
836 palkovsky 452
 *
3707 decky 453
 * @param addr   Physical address of the framebuffer
454
 * @param x      Screen width in pixels
455
 * @param y      Screen height in pixels
456
 * @param scan   Bytes per one scanline
457
 * @param visual Color model
458
 *
836 palkovsky 459
 */
3672 jermar 460
void fb_init(fb_properties_t *props)
836 palkovsky 461
{
3672 jermar 462
	switch (props->visual) {
1993 decky 463
	case VISUAL_INDIRECT_8:
4676 jermar 464
		rgb_conv = bgr_323;
1991 jermar 465
		pixelbytes = 1;
466
		break;
4685 jermar 467
	case VISUAL_RGB_5_5_5_LE:
468
		rgb_conv = rgb_555_le;
1991 jermar 469
		pixelbytes = 2;
470
		break;
4685 jermar 471
	case VISUAL_RGB_5_5_5_BE:
472
		rgb_conv = rgb_555_be;
1993 decky 473
		pixelbytes = 2;
1991 jermar 474
		break;
4685 jermar 475
	case VISUAL_RGB_5_6_5_LE:
476
		rgb_conv = rgb_565_le;
477
		pixelbytes = 2;
478
		break;
479
	case VISUAL_RGB_5_6_5_BE:
480
		rgb_conv = rgb_565_be;
481
		pixelbytes = 2;
482
		break;
1993 decky 483
	case VISUAL_RGB_8_8_8:
3707 decky 484
		rgb_conv = rgb_888;
1993 decky 485
		pixelbytes = 3;
486
		break;
3876 decky 487
	case VISUAL_BGR_8_8_8:
488
		rgb_conv = bgr_888;
489
		pixelbytes = 3;
490
		break;
1993 decky 491
	case VISUAL_RGB_8_8_8_0:
4669 pillai 492
		rgb_conv = rgb_8880;
1991 jermar 493
		pixelbytes = 4;
494
		break;
1993 decky 495
	case VISUAL_RGB_0_8_8_8:
3707 decky 496
		rgb_conv = rgb_0888;
1993 decky 497
		pixelbytes = 4;
498
		break;
1994 decky 499
	case VISUAL_BGR_0_8_8_8:
3707 decky 500
		rgb_conv = bgr_0888;
1994 decky 501
		pixelbytes = 4;
502
		break;
4676 jermar 503
	case VISUAL_BGR_8_8_8_0:
504
		rgb_conv = bgr_8880;
505
		pixelbytes = 4;
506
		break;
1991 jermar 507
	default:
3790 svoboda 508
		panic("Unsupported visual.");
839 palkovsky 509
	}
1371 decky 510
 
3672 jermar 511
	xres = props->x;
512
	yres = props->y;
513
	scanline = props->scan;
836 palkovsky 514
 
3710 decky 515
	cols = X2COL(xres);
516
	rows = Y2ROW(yres);
3707 decky 517
 
3710 decky 518
	if (yres > ylogo) {
519
		ylogo = LOGO_HEIGHT;
520
		rowtrim = rows - Y2ROW(ylogo);
521
		if (ylogo % FONT_SCANLINES > 0)
522
			rowtrim--;
523
		ytrim = ROW2Y(rowtrim);
524
	} else {
525
		ylogo = 0;
526
		ytrim = yres;
527
		rowtrim = rows;
528
	}
529
 
3707 decky 530
	glyphscanline = FONT_WIDTH * pixelbytes;
3710 decky 531
	glyphbytes = ROW2Y(glyphscanline);
532
	bgscanbytes = xres * pixelbytes;
3707 decky 533
 
4177 decky 534
	size_t fbsize = scanline * yres;
535
	size_t bbsize = cols * rows * sizeof(uint16_t);
536
	size_t glyphsize = FONT_GLYPHS * glyphbytes;
3707 decky 537
 
4177 decky 538
	backbuf = (uint16_t *) malloc(bbsize, 0);
3707 decky 539
	if (!backbuf)
3790 svoboda 540
		panic("Unable to allocate backbuffer.");
3707 decky 541
 
542
	glyphs = (uint8_t *) malloc(glyphsize, 0);
543
	if (!glyphs)
3790 svoboda 544
		panic("Unable to allocate glyphs.");
3707 decky 545
 
3710 decky 546
	bgscan = malloc(bgscanbytes, 0);
547
	if (!bgscan)
3790 svoboda 548
		panic("Unable to allocate background pixel.");
3707 decky 549
 
4177 decky 550
	memsetw(backbuf, cols * rows, 0);
3707 decky 551
 
3710 decky 552
	glyphs_render();
3707 decky 553
 
554
	fb_addr = (uint8_t *) hw_map((uintptr_t) props->addr, fbsize);
555
 
1690 palkovsky 556
	sysinfo_set_item_val("fb", NULL, true);
557
	sysinfo_set_item_val("fb.kind", NULL, 1);
558
	sysinfo_set_item_val("fb.width", NULL, xres);
559
	sysinfo_set_item_val("fb.height", NULL, yres);
3707 decky 560
	sysinfo_set_item_val("fb.scanline", NULL, scanline);
3672 jermar 561
	sysinfo_set_item_val("fb.visual", NULL, props->visual);
562
	sysinfo_set_item_val("fb.address.physical", NULL, props->addr);
1990 decky 563
 
3707 decky 564
	fb_redraw();
565
 
4093 decky 566
	outdev_initialize("fb", &fb_console, &fb_ops);
567
	stdout = &fb_console;
836 palkovsky 568
}
1702 cejka 569
 
1790 jermar 570
/** @}
1702 cejka 571
 */