rem: if (ka->fb.already_mapped) { console.fb = ka->fb.mapping.start; } else { vm_map_physical_memory(vm_get_kernel_aspace_id(), "vesa_fb", (void *)&console.fb, B_ANY_KERNEL_ADDRESS, ka->fb.mapping.size, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA, ka->fb.mapping.start); }
add: memset(&console, 0, sizeof(console));
context: fb_console_dev_init(kernel_args *ka){	if (ka->fb.enabled) {		int i;		dprintf("fb_console_dev_init: framebuffer found at 0x%lx, x %d, y %d, bit depth %d\n",			ka->fb.mapping.start, ka->fb.x_size, ka->fb.y_size, ka->fb.bit_depth);		memset(&console, 0, sizeof(console));		if (ka->fb.already_mapped) {			console.fb = ka->fb.mapping.start;		} else {			vm_map_physical_memory(vm_get_kernel_aspace_id(), "vesa_fb", (void *)&console.fb, B_ANY_KERNEL_ADDRESS,				ka->fb.mapping.size, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA, ka->fb.mapping.start);		}		console.fb_x = ka->fb.x_size;		console.fb_y = ka->fb.y_size;		console.fb_pixel_bytes = ka->fb.bit_depth / 8;		console.fb_size = ka->fb.mapping.size;		switch (console.fb_pixel_bytes) {			case 1:				console.render_line = &render_line8;				console.color = 0;		// black				console.bcolor = 63;	// white				break;			case 2:				console.render_line = &render_line16;				console.color = 0xffff;				console.bcolor = 0;				break;			case 4:				console.render_line = &render_line32;				console.color = 0x00ffffff;				console.bcolor = 0;				break;			default:				return 0;		}		dprintf("framebuffer mapped at 0x%lx\n", console.fb);		// figure out the number of rows/columns we have		console.rows = console.fb_y / CHAR_HEIGHT;		console.columns = console.fb_x / CHAR_WIDTH;		dprintf("%d rows %d columns\n", console.rows, console.columns);		console.x = 0;		console.y = 0;		console.saved_x = 0;		console.saved_y = 0;		dprintf("console %p\n", &console);		// allocate some memory for this		console.render_buf = malloc(console.fb_x * console.fb_pixel_bytes);		memset((void *)console.render_buf, console.bcolor, console.fb_x * console.fb_pixel_bytes);		console.buf = malloc(console.rows * (console.columns+1));		memset(console.buf, 0, console.rows * (console.columns+1));		console.lines = malloc(console.rows * sizeof(char *));		console.dirty_lines = malloc(console.rows);		// set up the line pointers		for (i = 0; i < console.rows; i++) {			console.lines[i] = (char *)((addr_t)console.buf + i*(console.columns+1));			console.dirty_lines[i] = 1;		}		console.num_lines = console.rows;		console.first_line = 0;		repaint();		mutex_init(&console.lock, "console_lock");		console.keyboard_fd = open("/dev/keyboard", O_RDONLY);		if (console.keyboard_fd < 0)			panic("fb_console_dev_init: error opening /dev/keyboard\n");		// create device node		devfs_publish_device("console", NULL, &fb_console_hooks);#if 0{	// displays the palette in 8 bit mode#define BAR_WIDTH 8	int x, y, i;	int width = (console.fb_x - BAR_WIDTH - 1) / BAR_WIDTH;	for (y = 0; y < console.fb_y; y++) {		for (i = 0; i < width; i++) {			uint8 field[BAR_WIDTH];			for (x = 0; x < BAR_WIDTH; x++) {				field[x] = i;			}			memcpy(console.fb + i*BAR_WIDTH + y*console.fb_x, field, BAR_WIDTH);		}	}}#endif#if 0{	int x, y;	for(y=0; y<console.fb_y; y++) {		uint16 row[console.fb_x];		for(x = 0; x<console.fb_x; x++) {			row[x] = x;		}		dprintf("%d\n", y);		memcpy(console.fb + y*console.fb_x*2, row, sizeof(row));	}	panic("foo\n");}#endif#if 0{		int i,j,k;		for(k=0;; k++) {			for(i=0; i<ka->fb.y_size; i++) {				uint16 row[ka->fb.x_size];				for(j=0; j<ka->fb.x_size; j++) {					uint8 byte = j+i+k;					row[j] = byte;				}				memcpy(console.fb + i*ka->fb.x_size*2, row, sizeof(row));			}		}}#endif	}	return 0;}