Index: arch/ia32/include/vesa.h
===================================================================
--- arch/ia32/include/vesa.h	(revision 8d4f2ae28b90a5052081a15201d89975bcd7cb78)
+++ arch/ia32/include/vesa.h	(revision 5f0c6643967448c838890152eb1df49a68d76c45)
@@ -1,4 +1,4 @@
 /*
- * Copyright (C) 2006-2006 Jakub Vana
+ * Copyright (C) 2006 Jakub Vana
  * All rights reserved.
  *
@@ -30,8 +30,6 @@
 #define __VESA_H__
 
-
-int vesa_present(void);
-void vesa_init(void);
-
+extern int vesa_present(void);
+extern void vesa_init(void);
 
 #endif
Index: arch/ia32/src/drivers/vesa.c
===================================================================
--- arch/ia32/src/drivers/vesa.c	(revision 8d4f2ae28b90a5052081a15201d89975bcd7cb78)
+++ arch/ia32/src/drivers/vesa.c	(revision 5f0c6643967448c838890152eb1df49a68d76c45)
@@ -1,4 +1,4 @@
 /*
- * Copyright (C) 2006-2006 Jakub Vana
+ * Copyright (C) 2006 Jakub Vana
  * All rights reserved.
  *
@@ -37,7 +37,9 @@
 #include <arch/mm/page.h>
 #include <synch/spinlock.h>
+#include <arch/asm.h>
 #include <arch/types.h>
-#include <arch/asm.h>
+#include <typedefs.h>
 #include <memstr.h>
+#include <bitops.h>
 
 __u32 vesa_ph_addr;
@@ -47,21 +49,20 @@
 __u16 vesa_scanline;
 
-
 int vesa_present(void)
 {
-	if(vesa_width!=0xffff) return true;
-	if(vesa_height!=0xffff) return true;
+	if (vesa_width != 0xffff)
+		return true;
+	if (vesa_height != 0xffff)
+		return true;
 	return false;
 }
 
+static count_t vesa_frame_order(void)
+{
+	__u32 x = vesa_scanline*vesa_height;
+	if (x <= FRAME_SIZE)
+		return 1;
 
-static __u32 log2(__u32 x)
-{
-	__u32 l=2;
-	if(x<=PAGE_SIZE) return PAGE_WIDTH+1;
-	
-	x--;
-	while(x>>=1) l++;
-	return l;
+	return (fnzb32(x - 1) + 1) - FRAME_WIDTH;
 }
 
@@ -69,15 +70,13 @@
 {
 	int a;
+	__address vram_lin_addr;
 
-	__address videoram_lin_addr;
+	vram_lin_addr = PA2KA(PFN2ADDR(frame_alloc(vesa_frame_order(), FRAME_KA)));
+	/* Map videoram */
+	for (a = 0; a < ((vesa_scanline * vesa_height + PAGE_SIZE - 1) >> PAGE_WIDTH); a++)
+		page_mapping_insert(AS_KERNEL, vram_lin_addr+a*4096, vesa_ph_addr+a*4096, PAGE_NOT_CACHEABLE);
 
-	videoram_lin_addr=PA2KA(PFN2ADDR(frame_alloc( log2(vesa_scanline*vesa_height) -FRAME_WIDTH,FRAME_KA)));
-	/* Map videoram */
-	for(a=0;a<((vesa_scanline*vesa_height+PAGE_SIZE-1)>>PAGE_WIDTH);a++)
-	page_mapping_insert(AS_KERNEL, videoram_lin_addr+a*4096, vesa_ph_addr+a*4096, PAGE_NOT_CACHEABLE);
-	
-	fb_init( videoram_lin_addr,vesa_width,vesa_height,vesa_bpp,vesa_scanline);
+	fb_init(vram_lin_addr, vesa_width, vesa_height, vesa_bpp, vesa_scanline);
 }
 
 #endif
-
Index: generic/include/bitops.h
===================================================================
--- generic/include/bitops.h	(revision 8d4f2ae28b90a5052081a15201d89975bcd7cb78)
+++ generic/include/bitops.h	(revision 5f0c6643967448c838890152eb1df49a68d76c45)
@@ -33,5 +33,5 @@
 
 
-/** Return position of first non-zero bit from left.
+/** Return position of first non-zero bit from left (i.e. [log_2(arg)]).
  *
  * If number is zero, it returns 0
