Index: uspace/srv/hid/console/gcons.c
===================================================================
--- uspace/srv/hid/console/gcons.c	(revision 306061aed98cdcf0119a9e630f19df95fd68ccc0)
+++ uspace/srv/hid/console/gcons.c	(revision c6f087267a5341520c2f7f049eae7b1a387ecb14)
@@ -35,4 +35,5 @@
 #include <ipc/fb.h>
 #include <async.h>
+#include <async_obsolete.h>
 #include <stdio.h>
 #include <sys/mman.h>
@@ -40,7 +41,9 @@
 #include <align.h>
 #include <bool.h>
+#include <imgmap.h>
 
 #include "console.h"
 #include "gcons.h"
+#include "images.h"
 
 #define CONSOLE_TOP     66
@@ -57,30 +60,20 @@
 #define COLOR_BACKGROUND  0xffffff
 
-extern char _binary_gfx_helenos_ppm_start[0];
-extern int _binary_gfx_helenos_ppm_size;
-extern char _binary_gfx_nameic_ppm_start[0];
-extern int _binary_gfx_nameic_ppm_size;
-
-extern char _binary_gfx_anim_1_ppm_start[0];
-extern int _binary_gfx_anim_1_ppm_size;
-extern char _binary_gfx_anim_2_ppm_start[0];
-extern int _binary_gfx_anim_2_ppm_size;
-extern char _binary_gfx_anim_3_ppm_start[0];
-extern int _binary_gfx_anim_3_ppm_size;
-extern char _binary_gfx_anim_4_ppm_start[0];
-extern int _binary_gfx_anim_4_ppm_size;
-
-extern char _binary_gfx_cons_selected_ppm_start[0];
-extern int _binary_gfx_cons_selected_ppm_size;
-extern char _binary_gfx_cons_idle_ppm_start[0];
-extern int _binary_gfx_cons_idle_ppm_size;
-extern char _binary_gfx_cons_has_data_ppm_start[0];
-extern int _binary_gfx_cons_has_data_ppm_size;
-extern char _binary_gfx_cons_kernel_ppm_start[0];
-extern int _binary_gfx_cons_kernel_ppm_size;
-
 static bool use_gcons = false;
 static sysarg_t xres;
 static sysarg_t yres;
+
+static imgmap_t *helenos_img;
+static imgmap_t *nameic_img;
+
+static imgmap_t *anim_1_img;
+static imgmap_t *anim_2_img;
+static imgmap_t *anim_3_img;
+static imgmap_t *anim_4_img;
+
+static imgmap_t *cons_has_data_img;
+static imgmap_t *cons_idle_img;
+static imgmap_t *cons_kernel_img;
+static imgmap_t *cons_selected_img;
 
 enum butstate {
@@ -100,6 +93,6 @@
 static int fbphone;
 
-/** List of pixmaps identifying these icons */
-static int ic_pixmaps[CONS_LAST] = {-1, -1, -1, -1, -1, -1};
+/** List of image maps identifying these icons */
+static int ic_imgmaps[CONS_LAST] = {-1, -1, -1, -1, -1, -1};
 static int animation = -1;
 
@@ -115,5 +108,5 @@
 static void vp_switch(int vp)
 {
-	async_msg_1(fbphone, FB_VIEWPORT_SWITCH, vp);
+	async_obsolete_msg_1(fbphone, FB_VIEWPORT_SWITCH, vp);
 }
 
@@ -121,5 +114,5 @@
 static int vp_create(sysarg_t x, sysarg_t y, sysarg_t width, sysarg_t height)
 {
-	return async_req_2_0(fbphone, FB_VIEWPORT_CREATE, (x << 16) | y,
+	return async_obsolete_req_2_0(fbphone, FB_VIEWPORT_CREATE, (x << 16) | y,
 	    (width << 16) | height);
 }
@@ -127,10 +120,10 @@
 static void clear(void)
 {
-	async_msg_0(fbphone, FB_CLEAR);
+	async_obsolete_msg_0(fbphone, FB_CLEAR);
 }
 
 static void set_rgb_color(uint32_t fgcolor, uint32_t bgcolor)
 {
-	async_msg_2(fbphone, FB_SET_RGB_COLOR, fgcolor, bgcolor);
+	async_obsolete_msg_2(fbphone, FB_SET_RGB_COLOR, fgcolor, bgcolor);
 }
 
@@ -138,5 +131,5 @@
 static void tran_putch(wchar_t ch, sysarg_t col, sysarg_t row)
 {
-	async_msg_3(fbphone, FB_PUTCHAR, ch, col, row);
+	async_obsolete_msg_3(fbphone, FB_PUTCHAR, ch, col, row);
 }
 
@@ -148,7 +141,7 @@
 	enum butstate state = console_state[index];
 	
-	if (ic_pixmaps[state] != -1)
-		async_msg_2(fbphone, FB_VP_DRAW_PIXMAP, cstatus_vp[index],
-		    ic_pixmaps[state]);
+	if (ic_imgmaps[state] != -1)
+		async_obsolete_msg_2(fbphone, FB_VP_DRAW_IMGMAP, cstatus_vp[index],
+		    ic_imgmaps[state]);
 	
 	if ((state != CONS_DISCONNECTED) && (state != CONS_KERNEL)
@@ -167,6 +160,8 @@
 void gcons_change_console(size_t index)
 {
-	if (!use_gcons)
-		return;
+	if (!use_gcons) {
+		active_console = index;
+		return;
+	}
 	
 	if (active_console == KERNEL_CONSOLE) {
@@ -177,5 +172,5 @@
 		
 		if (animation != -1)
-			async_msg_1(fbphone, FB_ANIM_START, animation);
+			async_obsolete_msg_1(fbphone, FB_ANIM_START, animation);
 	} else {
 		if (console_state[active_console] == CONS_DISCONNECTED_SEL)
@@ -258,5 +253,5 @@
 {
 	if (animation != -1)
-		async_msg_1(fbphone, FB_ANIM_STOP, animation);
+		async_obsolete_msg_1(fbphone, FB_ANIM_STOP, animation);
 	
 	active_console = KERNEL_CONSOLE;
@@ -294,5 +289,5 @@
 	
 	if (active_console != KERNEL_CONSOLE)
-		async_msg_2(fbphone, FB_POINTER_MOVE, mouse_x, mouse_y);
+		async_obsolete_msg_2(fbphone, FB_POINTER_MOVE, mouse_x, mouse_y);
 }
 
@@ -355,41 +350,43 @@
 }
 
-/** Draw a PPM pixmap to framebuffer
- *
- * @param logo Pointer to PPM data
- * @param size Size of PPM data
- * @param x Coordinate of upper left corner
- * @param y Coordinate of upper left corner
- *
- */
-static void draw_pixmap(char *logo, size_t size, sysarg_t x, sysarg_t y)
-{
+/** Draw an image map to framebuffer
+ *
+ * @param img  Image map
+ * @param x    Coordinate of upper left corner
+ * @param y    Coordinate of upper left corner
+ *
+ */
+static void draw_imgmap(imgmap_t *img, sysarg_t x, sysarg_t y)
+{
+	if (img == NULL)
+		return;
+	
 	/* Create area */
-	char *shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED |
+	char *shm = mmap(NULL, img->size, PROTO_READ | PROTO_WRITE, MAP_SHARED |
 	    MAP_ANONYMOUS, 0, 0);
 	if (shm == MAP_FAILED)
 		return;
 	
-	memcpy(shm, logo, size);
+	memcpy(shm, img, img->size);
 	
 	/* Send area */
-	int rc = async_req_1_0(fbphone, FB_PREPARE_SHM, (sysarg_t) shm);
+	int rc = async_obsolete_req_1_0(fbphone, FB_PREPARE_SHM, (sysarg_t) shm);
 	if (rc)
 		goto exit;
 	
-	rc = async_share_out_start(fbphone, shm, PROTO_READ);
+	rc = async_obsolete_share_out_start(fbphone, shm, PROTO_READ);
 	if (rc)
 		goto drop;
 	
 	/* Draw logo */
-	async_msg_2(fbphone, FB_DRAW_PPM, x, y);
+	async_obsolete_msg_2(fbphone, FB_DRAW_IMGMAP, x, y);
 	
 drop:
 	/* Drop area */
-	async_msg_0(fbphone, FB_DROP_SHM);
+	async_obsolete_msg_0(fbphone, FB_DROP_SHM);
 	
 exit:
 	/* Remove area */
-	munmap(shm, size);
+	munmap(shm, img->size);
 }
 
@@ -403,8 +400,6 @@
 	set_rgb_color(COLOR_MAIN, COLOR_MAIN);
 	clear();
-	draw_pixmap(_binary_gfx_helenos_ppm_start,
-	    (size_t) &_binary_gfx_helenos_ppm_size, xres - 66, 2);
-	draw_pixmap(_binary_gfx_nameic_ppm_start,
-	    (size_t) &_binary_gfx_nameic_ppm_size, 5, 17);
+	draw_imgmap(helenos_img, xres - 66, 2);
+	draw_imgmap(nameic_img, 5, 17);
 	
 	unsigned int i;
@@ -415,75 +410,73 @@
 }
 
-/** Creates a pixmap on framebuffer
- *
- * @param data PPM data
- * @param size PPM data size
- *
- * @return Pixmap identification
- *
- */
-static int make_pixmap(char *data, size_t size)
-{
+/** Create an image map on framebuffer
+ *
+ * @param img Image map.
+ *
+ * @return Image map identification
+ *
+ */
+static int make_imgmap(imgmap_t *img)
+{
+	if (img == NULL)
+		return -1;
+	
 	/* Create area */
-	char *shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED |
-	    MAP_ANONYMOUS, 0, 0);
+	char *shm = mmap(NULL, img->size, PROTO_READ | PROTO_WRITE,
+	    MAP_SHARED | MAP_ANONYMOUS, 0, 0);
 	if (shm == MAP_FAILED)
 		return -1;
 	
-	memcpy(shm, data, size);
-	
-	int pxid = -1;
+	memcpy(shm, img, img->size);
+	
+	int id = -1;
 	
 	/* Send area */
-	int rc = async_req_1_0(fbphone, FB_PREPARE_SHM, (sysarg_t) shm);
+	int rc = async_obsolete_req_1_0(fbphone, FB_PREPARE_SHM, (sysarg_t) shm);
 	if (rc)
 		goto exit;
 	
-	rc = async_share_out_start(fbphone, shm, PROTO_READ);
+	rc = async_obsolete_share_out_start(fbphone, shm, PROTO_READ);
 	if (rc)
 		goto drop;
 	
-	/* Obtain pixmap */
-	rc = async_req_0_0(fbphone, FB_SHM2PIXMAP);
+	/* Obtain image map identifier */
+	rc = async_obsolete_req_0_0(fbphone, FB_SHM2IMGMAP);
 	if (rc < 0)
 		goto drop;
 	
-	pxid = rc;
+	id = rc;
 	
 drop:
 	/* Drop area */
-	async_msg_0(fbphone, FB_DROP_SHM);
+	async_obsolete_msg_0(fbphone, FB_DROP_SHM);
 	
 exit:
 	/* Remove area */
-	munmap(shm, size);
-	
-	return pxid;
+	munmap(shm, img->size);
+	
+	return id;
 }
 
 static void make_anim(void)
 {
-	int an = async_req_1_0(fbphone, FB_ANIM_CREATE,
+	int an = async_obsolete_req_1_0(fbphone, FB_ANIM_CREATE,
 	    cstatus_vp[KERNEL_CONSOLE]);
 	if (an < 0)
 		return;
 	
-	int pm = make_pixmap(_binary_gfx_anim_1_ppm_start,
-	    (size_t) &_binary_gfx_anim_1_ppm_size);
-	async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm);
-	
-	pm = make_pixmap(_binary_gfx_anim_2_ppm_start,
-	    (size_t) &_binary_gfx_anim_2_ppm_size);
-	async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm);
-	
-	pm = make_pixmap(_binary_gfx_anim_3_ppm_start,
-	    (size_t) &_binary_gfx_anim_3_ppm_size);
-	async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm);
-	
-	pm = make_pixmap(_binary_gfx_anim_4_ppm_start,
-	    (size_t) &_binary_gfx_anim_4_ppm_size);
-	async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm);
-	
-	async_msg_1(fbphone, FB_ANIM_START, an);
+	int pm = make_imgmap(anim_1_img);
+	async_obsolete_msg_2(fbphone, FB_ANIM_ADDIMGMAP, an, pm);
+	
+	pm = make_imgmap(anim_2_img);
+	async_obsolete_msg_2(fbphone, FB_ANIM_ADDIMGMAP, an, pm);
+	
+	pm = make_imgmap(anim_3_img);
+	async_obsolete_msg_2(fbphone, FB_ANIM_ADDIMGMAP, an, pm);
+	
+	pm = make_imgmap(anim_4_img);
+	async_obsolete_msg_2(fbphone, FB_ANIM_ADDIMGMAP, an, pm);
+	
+	async_obsolete_msg_1(fbphone, FB_ANIM_START, an);
 	
 	animation = an;
@@ -495,5 +488,5 @@
 	fbphone = phone;
 	
-	int rc = async_req_0_2(phone, FB_GET_RESOLUTION, &xres, &yres);
+	int rc = async_obsolete_req_0_2(phone, FB_GET_RESOLUTION, &xres, &yres);
 	if (rc)
 		return;
@@ -501,4 +494,28 @@
 	if ((xres < 800) || (yres < 600))
 		return;
+	
+	/* Create image maps */
+	helenos_img = imgmap_decode_tga((void *) helenos_tga,
+	    helenos_tga_size);
+	nameic_img = imgmap_decode_tga((void *) nameic_tga,
+	    nameic_tga_size);
+	
+	anim_1_img = imgmap_decode_tga((void *) anim_1_tga,
+	    anim_1_tga_size);
+	anim_2_img = imgmap_decode_tga((void *) anim_2_tga,
+	    anim_2_tga_size);
+	anim_3_img = imgmap_decode_tga((void *) anim_3_tga,
+	    anim_3_tga_size);
+	anim_4_img = imgmap_decode_tga((void *) anim_4_tga,
+	    anim_4_tga_size);
+	
+	cons_has_data_img = imgmap_decode_tga((void *) cons_has_data_tga,
+	    cons_has_data_tga_size);
+	cons_idle_img = imgmap_decode_tga((void *) cons_idle_tga,
+	    cons_idle_tga_size);
+	cons_kernel_img = imgmap_decode_tga((void *) cons_kernel_tga,
+	    cons_kernel_tga_size);
+	cons_selected_img = imgmap_decode_tga((void *) cons_selected_tga,
+	    cons_selected_tga_size);
 	
 	/* Create console viewport */
@@ -528,20 +545,10 @@
 	
 	/* Initialize icons */
-	ic_pixmaps[CONS_SELECTED] =
-	    make_pixmap(_binary_gfx_cons_selected_ppm_start,
-	    (size_t) &_binary_gfx_cons_selected_ppm_size);
-	ic_pixmaps[CONS_IDLE] =
-	    make_pixmap(_binary_gfx_cons_idle_ppm_start,
-	    (size_t) &_binary_gfx_cons_idle_ppm_size);
-	ic_pixmaps[CONS_HAS_DATA] =
-	    make_pixmap(_binary_gfx_cons_has_data_ppm_start,
-	    (size_t) &_binary_gfx_cons_has_data_ppm_size);
-	ic_pixmaps[CONS_DISCONNECTED] =
-	    make_pixmap(_binary_gfx_cons_idle_ppm_start,
-	    (size_t) &_binary_gfx_cons_idle_ppm_size);
-	ic_pixmaps[CONS_KERNEL] =
-	    make_pixmap(_binary_gfx_cons_kernel_ppm_start,
-	    (size_t) &_binary_gfx_cons_kernel_ppm_size);
-	ic_pixmaps[CONS_DISCONNECTED_SEL] = ic_pixmaps[CONS_SELECTED];
+	ic_imgmaps[CONS_SELECTED] = make_imgmap(cons_selected_img);
+	ic_imgmaps[CONS_IDLE] = make_imgmap(cons_idle_img);
+	ic_imgmaps[CONS_HAS_DATA] = make_imgmap(cons_has_data_img);
+	ic_imgmaps[CONS_DISCONNECTED] = make_imgmap(cons_idle_img);
+	ic_imgmaps[CONS_KERNEL] = make_imgmap(cons_kernel_img);
+	ic_imgmaps[CONS_DISCONNECTED_SEL] = ic_imgmaps[CONS_SELECTED];
 	
 	make_anim();
