Index: lab5/Makefile
===================================================================
--- lab5/Makefile	(nonexistent)
+++ lab5/Makefile	(revision 95)
@@ -0,0 +1,16 @@
+# name of the program (Minix service)
+PROG=lab5
+
+# source code files to be compiled
+SRCS = lab5.c graphics.c
+
+# additional compilation flags
+# "-Wall -Wextra -Werror -I . -std=c11 -Wno-unused-parameter" are already set
+CFLAGS += -pedantic
+
+# list of library dependencies (for Lab 2, only LCF library)
+DPADD += ${LIBLCF}
+LDADD += -llcf
+
+# include LCOM's makefile that does all the "heavy lifting"
+.include <minix.lcom.mk>

Property changes on: lab5/Makefile
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: lab5/errors.h
===================================================================
--- lab5/errors.h	(nonexistent)
+++ lab5/errors.h	(revision 95)
@@ -0,0 +1,19 @@
+#ifndef ERRORS_H_INCLUDED
+#define ERRORS_H_INCLUDED
+
+enum errors {
+    SUCCESS = 0,        /* @brief Sucessful */
+    NULL_PTR,           /* @brief Null Pointer Error */
+    LCF_ERROR,          /* @brief Error originated on LCF */
+    SBCR_ERROR,         /* @brief Error on Subscribing Interrupt */
+    UNSBCR_ERROR,       /* @brief Error on Unsubscring Interrupt*/
+    READ_ERROR,         /* @brief Error on Reading from Port */
+    WRITE_ERROR,        /* @brief Error on Writing to Port */
+    TIMEOUT_ERROR,      /* @brief Timeout error */
+    INVALID_COMMAND,    /* @brief Invalid Command issued */
+    INVALID_STATE,      /* @brief State machine reached an invalid state */
+    BIOS_CALL_ERROR,    /* @brief Error upon BIOS call */
+    OTHER_ERROR         /* @brief Unspecified error */
+};
+
+#endif //ERRORS_H_INCLUDED

Property changes on: lab5/errors.h
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: lab5/graphics.c
===================================================================
--- lab5/graphics.c	(nonexistent)
+++ lab5/graphics.c	(revision 95)
@@ -0,0 +1,49 @@
+#include "graphics.h"
+#include "graphics_macros.h"
+#include "errors.h"
+
+#include <lcom/lcf.h>
+
+#include <stdio.h>
+
+static void *video_mem; /** @brief Frame-buffer VM address */
+static vbe_mode_info_t vbe_mem_info;
+//static mmap_t mem_map;
+
+int (set_graphics_mode)(uint16_t mode) {
+    int r;
+    struct minix_mem_range mmr;
+    mmr.mr_base =  0x0;
+    mmr.mr_limit = 0xFFFF;
+
+    //struct reg86 reg_86;
+
+    if ((r = sys_privctl(SELF, SYS_PRIV_ADD_MEM, &mmr)))
+        panic("sys_privctl (ADD MEM) failed: %d\n", r);
+
+    lm_init(true);
+//    lm_alloc(sizeof(vbe_mode_info_t), &mem_map);
+    if (vbe_get_mode_info(mode, &vbe_mem_info)) {
+        printf("vbe_get_mode_info: Failed to get VBE Mode Info for mode %x\n", mode);
+        return LCF_ERROR;
+    }
+    unsigned int vram_base = vbe_mem_info.PhysBasePtr;
+    unsigned int vram_size = vbe_mem_info.XResolution * vbe_mem_info.YResolution * (vbe_mem_info.BitsPerPixel >> 3);
+
+    // Allow memory mapping
+    mmr.mr_base =  vram_base;
+    mmr.mr_limit = vram_base + vram_size;
+
+    if ((r = sys_privctl(SELF, SYS_PRIV_ADD_MEM, &mmr)))
+        panic("sys_privctl (ADD MEM) failed: %d\n", r);
+
+    // Map memory
+
+    video_mem = vm_map_phys(SELF, (void *)mmr.mr_base, vram_size);
+
+    if (video_mem == MAP_FAILED)
+        panic("Error: couldn't map video memory.");
+
+//    lm_free(&mem_map);
+    return SUCCESS;
+}

Property changes on: lab5/graphics.c
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: lab5/graphics.h
===================================================================
--- lab5/graphics.h	(nonexistent)
+++ lab5/graphics.h	(revision 95)
@@ -0,0 +1,13 @@
+#ifndef GRAPHICS_H_INCLUDED
+#define GRAPHICS_H_INCLUDED
+
+#include <stdint.h>
+
+/**
+ * @brief
+ * @param mode
+ * @return
+ */
+int (set_graphics_mode)(uint16_t mode);
+
+#endif /* end of include guard: GRAPHICS_H_INCLUDED */

Property changes on: lab5/graphics.h
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: lab5/graphics_macros.h
===================================================================
--- lab5/graphics_macros.h	(nonexistent)
+++ lab5/graphics_macros.h	(revision 95)
@@ -0,0 +1,26 @@
+#ifndef GRAPHICS_MACROS_H_INCLUDED
+#define GRAPHICS_MACROS_H_INCLUDED
+
+#define VC_BIOS_SERV  0x10 /** @brief TODO */
+#define VBE_CALL      0x4F /** @brief TODO */
+
+// Graphics Functions
+#define VBE_CTRL_INFO       0x00 /** @brief Get VBE Controller Information */
+#define VBE_MD_INFO         0x01 /** @brief Get VBE Mode Information */
+#define SET_VBE_MD          0x02 /** @brief Set VBE Mode */
+
+// Error codes (AH)
+#define AH_SUCCESS          0x00
+#define AH_FUNC_CALL_FAIL   0x01
+#define AH_FUNC_NOT_SUPP    0x02
+#define AH_FUNC_INVALID     0x03
+
+// Graphics modes
+#define INDEXED_1024_768        0x105
+#define DIRECT_640_480          0x110
+#define DIRECT_800_600          0x115
+#define DIRECT_1280_1024        0x11A
+#define DIRECT_1152_864         0x14C
+#define LINEAR_FRAME_BUFFER_MD  BIT(14)
+
+#endif /* end of include guard: GRAPHICS_MACROS_H_INCLUDED */

Property changes on: lab5/graphics_macros.h
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
