Index: kernel/genarch/src/fb/fb.c
===================================================================
--- kernel/genarch/src/fb/fb.c	(revision e5a2ee82fb8b490768c6241be8d4c253e5f8c13b)
+++ kernel/genarch/src/fb/fb.c	(revision 800eaf58426ea62a441ee7c6cebc936221cbbe13)
@@ -98,10 +98,10 @@
 static void rgb_4byte(void *dst, int rgb)
 {
-	*(int *)dst = rgb;
+	*((int *) dst) = rgb;
 }
 
 static int byte4_rgb(void *src)
 {
-	return (*(int *)src) & 0xffffff;
+	return (*((int *) src)) & 0xffffff;
 }
 
@@ -134,5 +134,5 @@
 {
 	/* 5-bit, 6-bits, 5-bits */ 
-	*((uint16_t *)(dst)) = RED(rgb, 5) << 11 | GREEN(rgb, 6) << 5 | BLUE(rgb, 5);
+	*((uint16_t *) dst) = RED(rgb, 5) << 11 | GREEN(rgb, 6) << 5 | BLUE(rgb, 5);
 }
 
@@ -154,5 +154,5 @@
 static void rgb_1byte(void *dst, int rgb)
 {
-	*(uint8_t *)dst = RED(rgb, 3) << 5 | GREEN(rgb, 2) << 3 | BLUE(rgb, 3);
+	*((uint8_t *) dst) = RED(rgb, 3) << 5 | GREEN(rgb, 2) << 3 | BLUE(rgb, 3);
 }
 
@@ -169,9 +169,9 @@
 static void putpixel(unsigned int x, unsigned int y, int color)
 {
-	(*rgb2scr)(&fbaddress[POINTPOS(x,y)], COLOR(color));
+	(*rgb2scr)(&fbaddress[POINTPOS(x, y)], COLOR(color));
 
 	if (dbbuffer) {
 		int dline = (y + dboffset) % yres;
-		(*rgb2scr)(&dbbuffer[POINTPOS(x,dline)], COLOR(color));
+		(*rgb2scr)(&dbbuffer[POINTPOS(x, dline)], COLOR(color));
 	}
 }
@@ -182,7 +182,7 @@
 	if (dbbuffer) {
 		int dline = (y + dboffset) % yres;
-		return COLOR((*scr2rgb)(&dbbuffer[POINTPOS(x,dline)]));
-	}
-	return COLOR((*scr2rgb)(&fbaddress[POINTPOS(x,y)]));
+		return COLOR((*scr2rgb)(&dbbuffer[POINTPOS(x, dline)]));
+	}
+	return COLOR((*scr2rgb)(&fbaddress[POINTPOS(x, y)]));
 }
 
@@ -194,7 +194,7 @@
 
 	for (y = 0; y < yres; y++) {
-		memcpy(&fbaddress[scanline*y], blankline, xres*pixelbytes);
+		memcpy(&fbaddress[scanline * y], blankline, xres * pixelbytes);
 		if (dbbuffer)
-			memcpy(&dbbuffer[scanline*y], blankline, xres*pixelbytes);
+			memcpy(&dbbuffer[scanline * y], blankline, xres * pixelbytes);
 	}
 }
@@ -208,11 +208,11 @@
 
 	if (dbbuffer) {
-		memcpy(&dbbuffer[dboffset*scanline], blankline, FONT_SCANLINES*scanline);
+		memcpy(&dbbuffer[dboffset * scanline], blankline, FONT_SCANLINES * scanline);
 		
 		dboffset = (dboffset + FONT_SCANLINES) % yres;
-		firstsz = yres-dboffset;
-
-		memcpy(fbaddress, &dbbuffer[scanline*dboffset], firstsz*scanline);
-		memcpy(&fbaddress[firstsz*scanline], dbbuffer, dboffset*scanline);
+		firstsz = yres - dboffset;
+
+		memcpy(fbaddress, &dbbuffer[scanline * dboffset], firstsz * scanline);
+		memcpy(&fbaddress[firstsz * scanline], dbbuffer, dboffset * scanline);
 	} else {
 		memcpy((void *) fbaddress, (void *) &fbaddress[ROW_BYTES], scanline * yres - ROW_BYTES);
@@ -359,29 +359,29 @@
 {
 	switch (bpp) {
-	case 8:
-		rgb2scr = rgb_1byte;
-		scr2rgb = byte1_rgb;
-		pixelbytes = 1;
-		break;
-	case 16:
-		rgb2scr = rgb_2byte;
-		scr2rgb = byte2_rgb;
-		pixelbytes = 2;
-		break;
-	case 24:
-		rgb2scr = rgb_3byte;
-		scr2rgb = byte3_rgb;
-		if (align)
+		case 8:
+			rgb2scr = rgb_1byte;
+			scr2rgb = byte1_rgb;
+			pixelbytes = 1;
+			break;
+		case 16:
+			rgb2scr = rgb_2byte;
+			scr2rgb = byte2_rgb;
+			pixelbytes = 2;
+			break;
+		case 24:
+			rgb2scr = rgb_3byte;
+			scr2rgb = byte3_rgb;
+			if (align)
+				pixelbytes = 4;
+			else
+				pixelbytes = 3;
+			break;
+		case 32:
+			rgb2scr = rgb_4byte;
+			scr2rgb = byte4_rgb;
 			pixelbytes = 4;
-		else
-			pixelbytes = 3;
-		break;
-	case 32:
-		rgb2scr = rgb_4byte;
-		scr2rgb = byte4_rgb;
-		pixelbytes = 4;
-		break;
-	default:
-		panic("Unsupported bpp.\n");
+			break;
+		default:
+			panic("Unsupported bpp.\n");
 	}
 	
@@ -410,13 +410,6 @@
 
 	/* Allocate double buffer */
-	int totsize = scanline * yres;
-	int pages = SIZE2FRAMES(totsize);
-	int order;
-	if (pages == 1)
-		order = 0;
-	else
-		order = fnzb(pages - 1) + 1;
-
-	dbbuffer = frame_alloc(order, FRAME_ATOMIC | FRAME_KA);
+	unsigned int order = fnzb(SIZE2FRAMES(ALIGN_UP(fbsize, FRAME_SIZE))) + 1;
+	dbbuffer = (uint8_t * ) frame_alloc(order, FRAME_ATOMIC | FRAME_KA);
 	if (!dbbuffer)
 		printf("Failed to allocate scroll buffer.\n");
@@ -427,10 +420,8 @@
 	if (!blankline)
 		panic("Failed to allocate blank line for framebuffer.");
-	for (y=0; y < FONT_SCANLINES; y++) {
-		for (x=0; x < xres; x++) {
-			(*rgb2scr)(&blankline[POINTPOS(x,y)], COLOR(BGCOLOR));
-		}
-	}
-
+	for (y = 0; y < FONT_SCANLINES; y++)
+		for (x = 0; x < xres; x++)
+			(*rgb2scr)(&blankline[POINTPOS(x, y)], COLOR(BGCOLOR));
+	
 	clear_screen();
 
@@ -443,5 +434,4 @@
 	chardev_initialize("fb", &framebuffer, &fb_ops);
 	stdout = &framebuffer;
-	
 }
 
