Index: proj/graphics.c
===================================================================
--- proj/graphics.c	(nonexistent)
+++ proj/graphics.c	(revision 146)
@@ -0,0 +1,238 @@
+#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 (get_permission)(unsigned int base_addr, unsigned int size) {
+    struct minix_mem_range mmr;
+    mmr.mr_base = base_addr;
+    mmr.mr_limit = base_addr + size;
+    return sys_privctl(SELF, SYS_PRIV_ADD_MEM, &mmr);
+}
+
+//int (get_permissions_first_mbyte)(void) {
+//    return get_permission(MBYTE_BASE, MBYTE_SIZE);
+//}
+
+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(struct reg86)); // reset struct
+
+    vbe_mode_info_t *virtual_addr = lm_alloc(sizeof(vbe_mode_info_t), &mem_map);
+
+    reg_86.intno = VC_BIOS_SERV;
+    reg_86.ah = VBE_CALL;
+    reg_86.al = VBE_MD_INFO;
+    reg_86.cx = mode;
+    reg_86.es = PB2BASE(mem_map.phys);
+    reg_86.di = PB2OFF(mem_map.phys);
+    // BIOS CALL
+    if (sys_int86(&reg_86) || reg_86.ah != AH_SUCCESS) {
+        printf("%s: sys_int86 failed\n", __func__);
+        if (free_memory_map()) {
+            printf("%s: lm_free failed\n", __func__);
+        }
+        return BIOS_CALL_ERROR;
+    }
+
+    memcpy((void*)&vbe_mem_info, (void*)virtual_addr, mem_map.size);
+    return SUCCESS;
+}
+
+int (vbe_get_controller_information)(vg_vbe_contr_info_t *info_p) {
+    memset(info_p, 0, sizeof(vg_vbe_contr_info_t)); // reset values
+
+    mmap_t controller_map;
+
+    struct reg86 reg_86;
+    memset(&reg_86, 0, sizeof(struct reg86)); // reset struct
+
+    VbeInfoBlock *virtual_addr = lm_alloc(sizeof(VbeInfoBlock), &controller_map);
+
+    uint32_t virtual_base = (uint32_t)(virtual_addr) - controller_map.phys;
+
+    virtual_addr->VbeSignature[0] = 'V';
+    virtual_addr->VbeSignature[1] = 'B';
+    virtual_addr->VbeSignature[2] = 'E';
+    virtual_addr->VbeSignature[3] = '2';
+
+
+    reg_86.intno = VC_BIOS_SERV;
+    reg_86.ah = VBE_CALL;
+    reg_86.al = VBE_CTRL_INFO;
+    reg_86.es = PB2BASE(controller_map.phys);
+    reg_86.di = PB2OFF(controller_map.phys);
+    // BIOS CALL
+    if (sys_int86(&reg_86) || reg_86.ah != AH_SUCCESS) {
+        printf("%s: sys_int86 failed\n", __func__);
+        if (!lm_free(&controller_map)) {
+            printf("%s: lm_free failed\n", __func__);
+        }
+        return BIOS_CALL_ERROR;
+    }
+
+    info_p->VBESignature[0] = virtual_addr->VbeSignature[0];
+    info_p->VBESignature[1] = virtual_addr->VbeSignature[1];
+    info_p->VBESignature[2] = virtual_addr->VbeSignature[2];
+    info_p->VBESignature[3] = virtual_addr->VbeSignature[3];
+
+    uint8_t lsb, msb;
+    util_get_LSB(virtual_addr->VbeVersion, &lsb);
+    util_get_MSB(virtual_addr->VbeVersion, &msb);
+    info_p->VBEVersion[0] = lsb;
+    info_p->VBEVersion[1] = msb;
+
+    info_p->TotalMemory = (virtual_addr->TotalMemory << 6);
+
+    // Convert Far Far Pointer to Virtual Address
+
+    uint32_t phys_ptr = FAR2PHYS(virtual_addr->OemStringPtr);
+    uint32_t virtual_ptr = phys_ptr + virtual_base;
+    info_p->OEMString = (char*)(virtual_ptr);
+
+    phys_ptr = FAR2PHYS(virtual_addr->VideoModePtr);
+    virtual_ptr = phys_ptr + virtual_base;
+    info_p->VideoModeList = (uint16_t*)(virtual_ptr);
+
+    phys_ptr = FAR2PHYS(virtual_addr->OemVendorNamePtr);
+    virtual_ptr = phys_ptr + virtual_base;
+    info_p->OEMVendorNamePtr = (char*)(virtual_ptr);
+
+    phys_ptr = FAR2PHYS(virtual_addr->OemProductNamePtr);
+    virtual_ptr = phys_ptr + virtual_base;
+    info_p->OEMProductNamePtr = (char*)(virtual_ptr);
+
+    phys_ptr = FAR2PHYS(virtual_addr->OemProductRevPtr);
+    virtual_ptr = phys_ptr + virtual_base;
+    info_p->OEMProductRevPtr = (char*)(virtual_ptr);
+
+    if (!lm_free(&controller_map)) {
+        printf("%s: lm_free failed\n", __func__);
+        return LCF_ERROR;
+    }
+
+    return SUCCESS;
+}
+
+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;
+}
+
+uint16_t get_bytes_pixel(void) {
+    return (vbe_mem_info.BitsPerPixel + 7) >> 3;
+}
+
+uint16_t get_RedMaskSize  (void){ return vbe_mem_info.RedMaskSize  ; }
+uint16_t get_GreenMaskSize(void){ return vbe_mem_info.GreenMaskSize; }
+uint16_t get_BlueMaskSize (void){ return vbe_mem_info.BlueMaskSize ; }
+
+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))) {
+        if (free_memory_map()) {
+            printf("%s: lm_free failed\n", __func__);
+        }
+        panic("%s: sys_privctl (ADD MEM) failed: %d\n", __func__, r);
+    }
+
+    video_mem = vm_map_phys(SELF, (void *)vram_base, vram_size);
+
+    if (video_mem == MAP_FAILED) {
+        if (free_memory_map()) {
+            printf("%s: lm_free failed\n", __func__);
+        }
+        panic("%s: couldn't map video memory.", __func__);
+    }
+
+    return SUCCESS;
+}
+
+int (free_memory_map)(void) {
+    return !lm_free(&mem_map);
+}
+
+int (set_graphics_mode)(uint16_t mode) {
+    struct reg86 reg_86;
+
+    memset(&reg_86, 0, sizeof(struct reg86)); // reset struct
+
+    // Set Reg86
+    reg_86.intno = VC_BIOS_SERV;
+    reg_86.ah = VBE_CALL;
+    reg_86.al = SET_VBE_MD;
+    reg_86.bx = mode | LINEAR_FRAME_BUFFER_MD;
+
+    // BIOS CALL
+    if (sys_int86(&reg_86) || reg_86.ah != AH_SUCCESS) {
+        printf("%s: sys_int86 failed\n", __func__);
+        return BIOS_CALL_ERROR;
+    }
+
+    return SUCCESS;
+}
+
+
+int (set_pixel)(uint16_t x, uint16_t y, uint32_t color) {
+    if (x >= vbe_mem_info.XResolution || y >= vbe_mem_info.YResolution) {
+        printf("%s: invalid pixel.\n", __func__);
+        return OUT_OF_RANGE;
+    }
+    unsigned int pos = (x + y * vbe_mem_info.XResolution) * get_bytes_pixel();
+    memcpy((void*)((unsigned int)video_mem + pos), &color, get_bytes_pixel());
+    return SUCCESS;
+}
+
+int (draw_hline)(uint16_t x, uint16_t y, uint16_t len, uint32_t color){
+    int r;
+    for (uint16_t i = 0; i < len; i++)
+        if ((r = set_pixel(x + i, y, color))) return r;
+    return SUCCESS;
+}
+int (vg_draw_hline)(uint16_t x, uint16_t y, uint16_t len, uint32_t color){
+    return draw_hline(x,y,len,color);
+}
+
+int (draw_rectangle)(uint16_t x, uint16_t y,uint16_t width, uint16_t height, uint32_t color)	{
+    int r;
+    for (uint16_t i = 0; i < height; i++)
+        if ((r = draw_hline(x, y + i, width, color))) return r;
+    return SUCCESS;
+}
+int (vg_draw_rectangle)(uint16_t x, uint16_t y,uint16_t width, uint16_t height, uint32_t color){
+    return draw_rectangle(x,y,width,height, color);
+}
+
+int paint_screen(uint32_t color){
+    return draw_rectangle(0,0,get_XRes(),get_YRes(),color);
+}
+
+int clear_screen(){
+    return paint_screen(BLACK);
+}

Property changes on: proj/graphics.c
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: proj/graphics.h
===================================================================
--- proj/graphics.h	(nonexistent)
+++ proj/graphics.h	(revision 146)
@@ -0,0 +1,81 @@
+#ifndef GRAPHICS_H_INCLUDED
+#define GRAPHICS_H_INCLUDED
+
+#include <lcom/lcf.h>
+#include <stdint.h>
+
+#define GET_RED(n)          (0xFF & ((n) >> 16))
+#define GET_GRE(n)          (0xFF & ((n) >>  8))
+#define GET_BLU(n)          (0xFF & (n      ))
+#define SET_RED(n)          (((n)&0xFF) << 16)
+#define SET_GRE(n)          (((n)&0xFF) <<  8)
+#define SET_BLU(n)          (((n)&0xFF)      )
+#define SET_COLOR(r,g,b)    (SET_RED(r) | SET_GRE(g) | SET_BLU(b))
+#define FAR2PHYS(n)         ((((n)>>12) & 0xFFFFFFF0) + ((n) & 0x0000FFFF))
+
+typedef struct __attribute__((packed)) {
+
+    char        VbeSignature[4]     ;
+    uint16_t    VbeVersion          ;
+    uint32_t    OemStringPtr        ;
+    uint8_t     Capabilities[4]     ;
+    uint32_t    VideoModePtr        ;
+    uint16_t    TotalMemory         ;
+
+    uint16_t    OemSoftwareRev      ;
+    uint32_t    OemVendorNamePtr    ;
+    uint32_t    OemProductNamePtr   ;
+    uint32_t    OemProductRevPtr    ;
+    char        Reserved[222]       ;
+
+    char        OemData[256]        ;
+} VbeInfoBlock;
+
+int (get_permission)(unsigned int base_addr, unsigned int size);
+
+//int (get_permissions_first_mbyte)(void);
+
+int (vbe_get_mode_information)(uint16_t mode);
+
+int (vbe_get_controller_information)(vg_vbe_contr_info_t *info_p);
+
+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);
+
+uint16_t get_bytes_pixel(void);
+
+uint16_t get_RedMaskSize(void);
+
+uint16_t get_GreenMaskSize(void);
+
+uint16_t get_BlueMaskSize(void);
+
+int (map_vram)(void);
+
+int (free_memory_map)(void);
+
+int (set_pixel)(uint16_t row, uint16_t col, uint32_t color);
+
+/**
+ * @brief
+ * @param mode
+ * @return
+ */
+int (set_graphics_mode)(uint16_t mode);
+
+int (draw_hline)(uint16_t x, uint16_t y, uint16_t len, uint32_t color);
+
+int (draw_rectangle)(uint16_t x, uint16_t y,uint16_t width, uint16_t height, uint32_t color);
+
+int (paint_screen)(uint32_t color);
+
+int (clear_screen)();
+
+#endif /* end of include guard: GRAPHICS_H_INCLUDED */

Property changes on: proj/graphics.h
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: proj/timer.c
===================================================================
--- proj/timer.c	(nonexistent)
+++ proj/timer.c	(revision 146)
@@ -0,0 +1,16 @@
+#include <lcom/lcf.h>
+
+#include "timer.h"
+
+#include "i8254.h"
+
+int (subscribe_timer_interrupt)(uint8_t interrupt_bit, int *interrupt_id) {
+    if (interrupt_id == NULL) return 1;
+    *interrupt_id = interrupt_bit;
+    return (sys_irqsetpolicy(TIMER0_IRQ, IRQ_REENABLE, interrupt_id));
+}
+
+uint32_t no_interrupts = 0;
+void (timer_int_handler)() {
+    no_interrupts++;
+}

Property changes on: proj/timer.c
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: proj/timer.h
===================================================================
--- proj/timer.h	(nonexistent)
+++ proj/timer.h	(revision 146)
@@ -0,0 +1,14 @@
+/**
+ * This file concerns everything related to the timer
+ */
+
+#ifndef TIMER_H_INCLUDED
+#define TIMER_H_INCLUDED
+
+#include <stdint.h>
+
+int (subscribe_timer_interrupt)(uint8_t interrupt_bit, int *interrupt_id);
+
+uint32_t no_interrupts;
+
+#endif //TIMER_H_INCLUDED

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