Index: lab5/graphics.c
===================================================================
--- lab5/graphics.c	(revision 102)
+++ lab5/graphics.c	(revision 103)
@@ -7,7 +7,7 @@
 #include <stdio.h>
 
 static void *video_mem; /** @brief Frame-buffer VM address */
-//static vbe_mode_info_t vbe_mem_info;
+static vbe_mode_info_t vbe_mem_info;
 static mmap_t mem_map;
 
 int (get_permission)(unsigned int base_addr, unsigned int size) {
@@ -21,11 +21,11 @@
     return get_permission(MBYTE_BASE, MBYTE_SIZE);
 }
 
-int (vbe_get_mode_information)(uint16_t mode, vbe_mode_info_t *vmi_p) {
-    memset(vmi_p, 0, sizeof(vbe_mode_info_t)); // reset values
+int (vbe_get_mode_information)(uint16_t mode) {
+    memset(&vbe_mem_info, 0, sizeof(vbe_mode_info_t)); // reset values
 
     struct reg86 reg_86;
-    memset(&reg_86, 0, sizeof(reg_86)); // reset struct
+    memset(&reg_86, 0, sizeof(struct reg86)); // reset struct
 
     vbe_mode_info_t *virtual_addr = lm_alloc(sizeof(vbe_mode_info_t), &mem_map);
 
@@ -45,12 +45,34 @@
         return BIOS_CALL_ERROR;
     }
 
-    vmi_p = memcpy((void*)vmi_p, (void*)virtual_addr, mem_map.size);
+    memcpy((void*)&vbe_mem_info, (void*)virtual_addr, mem_map.size);
     return SUCCESS;
 }
 
-int (map_vram)(unsigned int vram_base, unsigned int vram_size) {
+phys_bytes get_phys_addr(void) {
+    return vbe_mem_info.PhysBasePtr;
+}
+
+unsigned int get_vram_size(void) {
+    return vbe_mem_info.XResolution * vbe_mem_info.YResolution * ((vbe_mem_info.BitsPerPixel + 7) >> 3);
+}
+
+uint16_t get_XRes(void) {
+    return vbe_mem_info.XResolution;
+}
+
+uint16_t get_YRes(void) {
+    return vbe_mem_info.YResolution;
+}
+
+uint16_t get_bits_pixel(void) {
+    return vbe_mem_info.BitsPerPixel;
+}
+
+int (map_vram)(void) {
     int r;
+    unsigned int vram_base = get_phys_addr();
+    unsigned int vram_size = get_vram_size();
     if ((r = get_permission(vram_base, vram_size)))
         panic("%s: sys_privctl (ADD MEM) failed: %d\n", __func__, r);
 
@@ -63,13 +85,13 @@
 }
 
 int (free_memory)(void) {
-    return lm_free(&mem_map);
+    return !lm_free(&mem_map);
 }
 
 int (set_graphics_mode)(uint16_t mode) {
     struct reg86 reg_86;
 
-    memset(&reg_86, 0, sizeof(reg_86)); // reset struct
+    memset(&reg_86, 0, sizeof(struct reg86)); // reset struct
 
     // Set Reg86
     reg_86.intno = VC_BIOS_SERV;
Index: lab5/graphics.h
===================================================================
--- lab5/graphics.h	(revision 102)
+++ lab5/graphics.h	(revision 103)
@@ -8,10 +8,20 @@
 
 int (get_permissions_first_mbyte)(void);
 
-int (vbe_get_mode_information)(uint16_t mode, vbe_mode_info_t *vmi_p);
+int (vbe_get_mode_information)(uint16_t mode);
 
-int (map_vram)(unsigned int vram_base, unsigned int vram_size);
+phys_bytes get_phys_addr(void);
 
+unsigned int get_vram_size(void);
+
+uint16_t get_XRes(void);
+
+uint16_t get_YRes(void);
+
+uint16_t get_bits_pixel(void);
+
+int (map_vram)(void);
+
 int (free_memory)(void);
 
 /**
Index: lab5/lab5.c
===================================================================
--- lab5/lab5.c	(revision 102)
+++ lab5/lab5.c	(revision 103)
@@ -37,35 +37,30 @@
 int(video_test_init)(uint16_t mode, uint8_t delay) {
     int r;
     if ((r = get_permissions_first_mbyte()))
-    panic("%s: sys_privctl (ADD MEM) failed: %d\n", __func__, r);
+        panic("%s: sys_privctl (ADD MEM) failed: %d\n", __func__, r);
 
     if (set_graphics_mode(mode)) {
         printf("%s: failed to set graphic mode %x.\n", __func__, mode);
         if (vg_exit())
-        printf("%s: vg_exit failed to exit to text mode.\n", __func__);
+            printf("%s: vg_exit failed to exit to text mode.\n", __func__);
         return 1;
     };
 
-    vbe_mode_info_t vbe_mem_info;
-
-    if (vbe_get_mode_information(mode, &vbe_mem_info)) {
+    if (vbe_get_mode_information(mode)) {
         printf("%s: failed to get information for mode %x.\n", __func__, mode);
         if (vg_exit())
-        printf("%s: vg_exit failed to exit to text mode.\n", __func__);
+            printf("%s: vg_exit failed to exit to text mode.\n", __func__);
         return 1;
     }
 
-    unsigned int vram_base = vbe_mem_info.PhysBasePtr;
-    unsigned int vram_size = vbe_mem_info.XResolution * vbe_mem_info.YResolution * ((vbe_mem_info.BitsPerPixel + 7) >> 3);
+    map_vram(); // if function fails it aborts program
 
-    map_vram(vram_base, vram_size); // if function fails it aborts program
-
     tickdelay(micros_to_ticks(delay*1e6));
 
     if (vg_exit()) {
         printf("%s: vg_exit failed to exit to text mode.\n", __func__);
         if (free_memory())
-        printf("%s: lm_free failed\n", __func__);
+            printf("%s: lm_free failed\n", __func__);
         return 1;
     }
 
@@ -73,6 +68,7 @@
         printf("%s: lm_free failed\n", __func__);
         return 1;
     }
+
     return 0;
 }
 
@@ -98,7 +94,11 @@
 }
 
 int(video_test_pattern)(uint16_t mode, uint8_t no_rectangles, uint32_t first, uint8_t step) {
-    return 0;
+  /* To be completed */
+  printf("%s(0x%03x, %u, 0x%08x, %d): under construction\n", __func__,
+         mode, no_rectangles, first, step);
+
+  return 1;
 }
 
 int(video_test_xpm)(xpm_map_t xpm, uint16_t x, uint16_t y) {
