Index: kernel/genarch/src/fb/fb.c
===================================================================
--- kernel/genarch/src/fb/fb.c	(revision f8ddd176406660da88b0e9d63695413731cd58ff)
+++ kernel/genarch/src/fb/fb.c	(revision 730376d1b21f93d17f9ba190a599809dcb0a13a7)
@@ -40,5 +40,4 @@
 #include <sysinfo/sysinfo.h>
 #include <mm/slab.h>
-#include <align.h>
 #include <panic.h>
 #include <memstr.h>
@@ -47,4 +46,6 @@
 #include <print.h>
 #include <ddi/ddi.h>
+#include <arch/types.h>
+#include <typedefs.h>
 
 #include "helenos.xbm"
@@ -57,6 +58,6 @@
 
 static uint8_t *blankline = NULL;
-static uint8_t *dbbuffer = NULL; /* Buffer for fast scrolling console */
-static int dboffset;
+static uint8_t *dbbuffer = NULL;	/* Buffer for fast scrolling console */
+static index_t dboffset;
 
 static unsigned int xres = 0;
@@ -111,5 +112,6 @@
 static void bgr_byte0888(void *dst, int rgb)
 {
-	*((uint32_t *) dst) = BLUE(rgb, 8) << 16 | GREEN(rgb, 8) << 8 | RED(rgb, 8);
+	*((uint32_t *) dst) = BLUE(rgb, 8) << 16 | GREEN(rgb, 8) << 8 |	RED(rgb,
+		8);
 }
 
@@ -117,5 +119,6 @@
 {
 	int color = *(uint32_t *)(src);
-	return ((color & 0xff) << 16) | (((color >> 8) & 0xff) << 8) | ((color >> 16) & 0xff);
+	return ((color & 0xff) << 16) | (((color >> 8) & 0xff) << 8) | ((color
+		>> 16) & 0xff);
 }
 
@@ -148,5 +151,6 @@
 {
 	/* 5-bit, 5-bits, 5-bits */ 
-	*((uint16_t *) dst) = RED(rgb, 5) << 10 | GREEN(rgb, 5) << 5 | BLUE(rgb, 5);
+	*((uint16_t *) dst) = RED(rgb, 5) << 10 | GREEN(rgb, 5) << 5 | BLUE(rgb,
+		5);
 }
 
@@ -155,5 +159,6 @@
 {
 	int color = *(uint16_t *)(src);
-	return (((color >> 10) & 0x1f) << (16 + 3)) | (((color >> 5) & 0x1f) << (8 + 3)) | ((color & 0x1f) << 3);
+	return (((color >> 10) & 0x1f) << (16 + 3)) | (((color >> 5) & 0x1f) <<
+		(8 + 3)) | ((color & 0x1f) << 3);
 }
 
@@ -162,5 +167,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);
 }
 
@@ -169,5 +174,6 @@
 {
 	int color = *(uint16_t *)(src);
-	return (((color >> 11) & 0x1f) << (16 + 3)) | (((color >> 5) & 0x3f) << (8 + 2)) | ((color & 0x1f) << 3);
+	return (((color >> 11) & 0x1f) << (16 + 3)) | (((color >> 5) & 0x3f) <<
+		(8 + 2)) | ((color & 0x1f) << 3);
 }
 
@@ -182,5 +188,6 @@
 static void rgb_byte8(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);
 }
 
@@ -192,5 +199,6 @@
 {
 	int color = *(uint8_t *)src;
-	return (((color >> 5) & 0x7) << (16 + 5)) | (((color >> 3) & 0x3) << (8 + 6)) | ((color & 0x7) << 5);
+	return (((color >> 5) & 0x7) << (16 + 5)) | (((color >> 3) & 0x3) << (8
+		+ 6)) | ((color & 0x7) << 5);
 }
 
@@ -224,5 +232,6 @@
 		memcpy(&fbaddress[scanline * y], blankline, xres * pixelbytes);
 		if (dbbuffer)
-			memcpy(&dbbuffer[scanline * y], blankline, xres * pixelbytes);
+			memcpy(&dbbuffer[scanline * y], blankline, xres *
+				pixelbytes);
 	}
 }
@@ -232,17 +241,21 @@
 static void scroll_screen(void)
 {
-	uint8_t *lastline = &fbaddress[(rows - 1) * ROW_BYTES];
-	int firstsz;
-
 	if (dbbuffer) {
+		count_t first;
+		
 		memcpy(&dbbuffer[dboffset * scanline], blankline, ROW_BYTES);
 		
 		dboffset = (dboffset + FONT_SCANLINES) % yres;
-		firstsz = yres - dboffset;
-
-		memcpy(fbaddress, &dbbuffer[scanline * dboffset], firstsz * scanline);
-		memcpy(&fbaddress[firstsz * scanline], dbbuffer, dboffset * scanline);
+		first = yres - dboffset;
+
+		memcpy(fbaddress, &dbbuffer[scanline * dboffset], first *
+			scanline);
+		memcpy(&fbaddress[first * scanline], dbbuffer, dboffset *
+			scanline);
 	} else {
-		memcpy((void *) fbaddress, (void *) &fbaddress[ROW_BYTES], scanline * yres - ROW_BYTES);
+		uint8_t *lastline = &fbaddress[(rows - 1) * ROW_BYTES];
+		
+		memcpy((void *) fbaddress, (void *) &fbaddress[ROW_BYTES],
+			scanline * yres - ROW_BYTES);
 		/* Clear last row */
 		memcpy((void *) lastline, (void *) blankline, ROW_BYTES);
@@ -278,5 +291,6 @@
 
 	for (y = 0; y < FONT_SCANLINES; y++)
-		draw_glyph_line(fb_font[glyph * FONT_SCANLINES + y], col * COL_WIDTH, row * FONT_SCANLINES + y);
+		draw_glyph_line(fb_font[glyph * FONT_SCANLINES + y], col *
+			COL_WIDTH, row * FONT_SCANLINES + y);
 }
 
@@ -289,5 +303,6 @@
 	for (x = 0; x < COL_WIDTH; x++)
 		for (y = 0; y < FONT_SCANLINES; y++)
-			invert_pixel(col * COL_WIDTH + x, row * FONT_SCANLINES + y);
+			invert_pixel(col * COL_WIDTH + x, row * FONT_SCANLINES +
+				y);
 }
 
@@ -312,5 +327,6 @@
 			byte >>= x % 8;
 			if (byte & 1)
-				putpixel(startx + x, starty + y, COLOR(LOGOCOLOR));
+				putpixel(startx + x, starty + y,
+					COLOR(LOGOCOLOR));
 		}
 }
@@ -384,5 +400,6 @@
  *
  */
-void fb_init(uintptr_t addr, unsigned int x, unsigned int y, unsigned int scan, unsigned int visual)
+void fb_init(uintptr_t addr, unsigned int x, unsigned int y, unsigned int scan,
+	unsigned int visual)
 {
 	switch (visual) {
@@ -456,6 +473,6 @@
 
 	/* Allocate double buffer */
-	unsigned int order = fnzb(SIZE2FRAMES(ALIGN_UP(fbsize, FRAME_SIZE))) + 1;
-	dbbuffer = (uint8_t * ) frame_alloc(order, FRAME_ATOMIC | FRAME_KA);
+	unsigned int order = fnzb(SIZE2FRAMES(fbsize) - 1) + 1;
+	dbbuffer = (uint8_t *) frame_alloc(order, FRAME_ATOMIC | FRAME_KA);
 	if (!dbbuffer)
 		printf("Failed to allocate scroll buffer.\n");
