Index: proj/Makefile
===================================================================
--- proj/Makefile	(nonexistent)
+++ proj/Makefile	(revision 144)
@@ -0,0 +1,10 @@
+PROG=proj
+
+SRCS= proj.c utils.c
+
+CPPFLAGS += -pedantic -D __LCOM_OPTIMIZED_
+
+DPADD += ${LIBLCF}
+LDADD += -llcf
+
+.include <minix.lcom.mk>

Property changes on: proj/Makefile
___________________________________________________________________
Added: svn:executable
Index: proj/errors.h
===================================================================
--- proj/errors.h	(nonexistent)
+++ proj/errors.h	(revision 144)
@@ -0,0 +1,20 @@
+#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 */
+    OUT_OF_RANGE,       /* @brief Accessing area out of range of memory */
+    OTHER_ERROR         /* @brief Unspecified error */
+};
+
+#endif //ERRORS_H_INCLUDED

Property changes on: proj/errors.h
___________________________________________________________________
Added: svn:executable
Index: proj/graphics_macros.h
===================================================================
--- proj/graphics_macros.h	(nonexistent)
+++ proj/graphics_macros.h	(revision 144)
@@ -0,0 +1,32 @@
+#ifndef GRAPHICS_MACROS_H_INCLUDED
+#define GRAPHICS_MACROS_H_INCLUDED
+
+#define VC_BIOS_SERV  0x10 /** @brief Interrupt service of video card */
+#define VBE_CALL      0x4F /** @brief VBE call function specifier */
+
+#define MBYTE_BASE  0x0         /** @brief Base address (zero address) */
+#define MBYTE_SIZE  0xFFFFF     /** @brief Size of a mebibyte */
+
+// 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    /** @brief Success code on BIOS call */
+#define AH_FUNC_CALL_FAIL   0x01    /** @brief Function call failed */
+#define AH_FUNC_NOT_SUPP    0x02    /** @brief Function call is not supported in current HW configuration */
+#define AH_FUNC_INVALID     0x03    /** @brief Invalid function in current video mode */
+
+// Graphics modes
+#define INDEXED_1024_768        0x105
+#define DIRECT_640_480          0x110
+#define DIRECT_800_600          0x115
+#define DIRECT_1280_1024_565    0x11A
+#define DIRECT_1280_1024_888    0x11B
+#define LINEAR_FRAME_BUFFER_MD  BIT(14)
+
+// Colors in RBG (8 bit)
+#define BLACK               0x000000
+
+#endif /* end of include guard: GRAPHICS_MACROS_H_INCLUDED */

Property changes on: proj/graphics_macros.h
___________________________________________________________________
Added: svn:executable
Index: proj/i8254.h
===================================================================
--- proj/i8254.h	(nonexistent)
+++ proj/i8254.h	(revision 144)
@@ -0,0 +1,64 @@
+#ifndef _LCOM_I8254_H_
+#define _LCOM_I8254_H_
+
+#include <lcom/lcf.h>
+
+/** @defgroup i8254 i8254
+ *
+ * Constants for programming the i8254 Timer. Needs to be completed.
+ */
+
+#define TIMER_FREQ     1193182                                                          /**< @brief clock frequency for timer in PC and AT */
+#define TIMER_MIN_FREQ (TIMER_FREQ/UINT16_MAX) + ((TIMER_FREQ % UINT16_MAX) ? 1 : 0)    /**< @brief mininum frequency for timer */
+#define TIMER0_IRQ     0                                                                /**< @brief Timer 0 IRQ line */
+
+/* I/O port addresses */
+
+#define TIMER_0    0x40         /**< @brief Timer 0 count register */
+#define TIMER_1    0x41         /**< @brief Timer 1 count register */
+#define TIMER_2    0x42         /**< @brief Timer 2 count register */
+#define TIMER_CTRL 0x43         /**< @brief Control register */
+
+#define SPEAKER_CTRL 0x61       /**< @brief Register for speaker control  */
+
+/* Timer control */
+
+/* Timer selection: bits 7 and 6 */
+
+#define TIMER_SEL0   0x00              /**< @brief Control Word for Timer 0 */
+#define TIMER_SEL1   BIT(6)            /**< @brief Control Word for Timer 1 */
+#define TIMER_SEL2   BIT(7)            /**< @brief Control Word for Timer 2 */
+#define TIMER_RB_CMD (BIT(7) | BIT(6)) /**< @brief Read Back Command */
+
+/* Register selection: bits 5 and 4 */
+
+#define TIMER_LSB     BIT(4)                    /**< @brief Initialize Counter LSB only */
+#define TIMER_MSB     BIT(5)                    /**< @brief Initialize Counter MSB only */
+#define TIMER_LSB_MSB (TIMER_LSB | TIMER_MSB)   /**< @brief Initialize LSB first and MSB afterwards */
+#define TIMER_INMODE_MASK 0x30                  /**< @brief Mask for Timer Counter Mode */
+#define TIMER_INMODE_POS  4                     /**< @brief Bit position of Timer Counter Mode */
+
+/* Operating mode: bits 3, 2 and 1 */
+
+#define TIMER_SQR_WAVE (BIT(2) | BIT(1)) /**< @brief Mode 3: square wave generator */
+#define TIMER_RATE_GEN BIT(2)            /**< @brief Mode 2: rate generator */
+#define TIMER_MODE_MASK 0x0E             /**< @brief Mask for mode */
+#define TIMER_MODE_POS  1                /**< @brief Position of smallest bit from mode */
+#define TIMER_MODE_2ALT 0x6              /**< @brief Alternative notation for mode 2 */
+#define TIMER_MODE_3ALT 0x7              /**< @brief Alternative notation for mode 3 */
+#define TIMER_MODE_RED2 0x03             /**< @brief Reduce 3-bit mode to 2-bit mode */
+
+/* Counting mode: bit 0 */
+
+#define TIMER_BCD 0x01 /**< @brief Count in BCD */
+#define TIMER_BIN 0x00 /**< @brief Count in binary */
+
+/* READ-BACK COMMAND FORMAT */
+
+#define TIMER_RB_COUNT_  BIT(5)         /**< @brief Read counter value on read-back (0 to activate) */
+#define TIMER_RB_STATUS_ BIT(4)         /**< @brief Read status value on read-back (0 to activate) */
+#define TIMER_RB_SEL(n)  BIT((n) + 1)   /**< @brief Select timer to read information from */
+
+/**@}*/
+
+#endif /* _LCOM_I8254_H */

Property changes on: proj/i8254.h
___________________________________________________________________
Added: svn:executable
Index: proj/kbc_macros.h
===================================================================
--- proj/kbc_macros.h	(nonexistent)
+++ proj/kbc_macros.h	(revision 144)
@@ -0,0 +1,56 @@
+#ifndef KBC_MACROS_H_INCLUDED
+#define KBC_MACROS_H_INCLUDED
+
+/* KBC IRQ Line */
+
+#define KBC_IRQ     1   /* @brief KBC Controller IRQ Line */
+#define MOUSE_IRQ   12  /* @brief Mouse IRQ Line */
+
+/* Delay for KBC */
+#define DELAY           20000 /* @brief KBC Response Delay */
+#define KBC_NUM_TRIES   20    /* @brief Number of tries to issue command before timeout */
+
+/* I/O Ports Addresses */
+
+#define KBC_CMD     0x64 /* @brief Address to send commands to KBC */
+#define KBC_CMD_ARG 0x60 /* @brief Address to write KBC Command Arguments */
+#define STATUS_REG  0x64 /* @brief KBC Status Register address */
+
+#define OUTPUT_BUF  0x60 /* @brief Address of Output Buffer of KBC */
+
+/* KBC Commands */
+#define READ_KBC_CMD    0x20 /* @brief Read KBC Command Byte */
+#define WRITE_KBC_CMD   0x60 /* @brief Write KBC Command Byte */
+#define KBC_SELF_TEST   0xAA /* @brief KBC Diagnostic Tests */
+#define KBC_INT_TEST    0xAB /* @brief Tests Keyboard Clock and Data lines */
+#define KBC_INT_DISABLE 0xAD /* @brief Disable KBC Interface */
+#define KBC_INT_ENABLE  0xAE /* @brief Enable KBC Interface */
+#define MOUSE_DISABLE   0xA7 /* @brief Disable Mouse */
+#define MOUSE_ENABLE    0xA8 /* @brief Enable Mouse */
+#define MOUSE_INT_TEST  0xA9 /* @brief Tests Mouse data line */
+#define MOUSE_WRITE_B   0xD4 /* @brief Write a byte directly to the mouse */
+
+/* Status Byte Masking */
+
+#define OUT_BUF_FUL     BIT(0) /* @brief Output Buffer State */
+#define IN_BUF_FULL     BIT(1) /* @brief Input Buffer State */
+#define SYS_FLAG        BIT(2) /* @brief System Flag */
+#define DATA_CMD_WRITE  BIT(3) /* @brief Identifier of type of byte in input buffer */
+#define INH_FLAG        BIT(4) /* @brief Keyboard inihibited */
+#define AUX_MOUSE       BIT(5) /* @brief Mouse Data */
+#define TIME_OUT_REC    BIT(6) /* @brief Time Out Error - Invalid Data */
+#define PARITY_ERROR    BIT(7) /* @brief Parity Error - Invalid Data */
+
+/* Scancode Constants */
+
+#define ESC_BREAK_CODE  0x81    /* @brief ESC Break Code */
+#define TWO_BYTE_CODE   0xE0    /* @brief First byte of a two byte Scancode */
+#define BREAK_CODE_BIT  BIT(7)  /* @brief Bit to distinguish between Make code and Break code */
+
+/* Command byte masks */
+#define INT_KBD         BIT(0)  /* @brief Enable Keyboard Interrupts */
+#define INT_MOU         BIT(1)  /* @brief Enable Mouse Interrupts */
+#define DIS_KBD         BIT(4)  /* @brief Disable Keyboard */
+#define DIS_MOU         BIT(5)  /* @brief Disable Mouse */
+
+#endif //KBC_MACROS_H_INCLUDED

Property changes on: proj/kbc_macros.h
___________________________________________________________________
Added: svn:executable
Index: proj/proj.c
===================================================================
--- proj/proj.c	(nonexistent)
+++ proj/proj.c	(revision 144)
@@ -0,0 +1,20 @@
+#include <lcom/lcf.h>
+#include <lcom/proj.h>
+#include <lcom/liblm.h>
+
+#include <stdint.h>
+
+int main(int argc, char* argv[]) {
+
+    lcf_set_language("EN-US");
+
+    //lcf_trace_calls("/home/lcom/labs/proj/trace.txt");
+
+    //lcf_log_output("/home/lcom/labs/proj/output.txt");
+
+    if (lcf_start(argc, argv)) return 1;
+
+    lcf_cleanup();
+
+    return 0;
+}

Property changes on: proj/proj.c
___________________________________________________________________
Added: svn:executable
Index: proj/temp_macros.h
===================================================================
--- proj/temp_macros.h	(nonexistent)
+++ proj/temp_macros.h	(revision 144)
@@ -0,0 +1,18 @@
+#ifndef TEMP_MACROS_H_INCLUDED
+#define TEMP_MACROS_H_INCLUDED
+
+// WASD Movement Keys
+#define W_MAKE_CODE     0x11    /* @brief W Make Code */
+#define W_BREAK_CODE    0x91    /* @brief W Make Code */
+#define A_MAKE_CODE     0x1E    /* @brief A Make Code */
+#define A_BREAK_CODE    0x9E    /* @brief A Make Code */
+#define S_MAKE_CODE     0x1F    /* @brief S Make Code */
+#define S_BREAK_CODE    0x9F    /* @brief S Make Code */
+#define D_MAKE_CODE     0x20    /* @brief D Make Code */
+#define D_BREAK_CODE    0xA0    /* @brief D Make Code */
+
+// Extra Keys
+#define ESC_MAKE_CODE   0x01    /* @brief ESC Make Code */
+#define ESC_BREAK_CODE  0x81    /* @brief ESC Break Code */
+
+#endif /* end of include guard: TEMP_MACROS_H_INCLUDED */

Property changes on: proj/temp_macros.h
___________________________________________________________________
Added: svn:executable
Index: proj/utils.c
===================================================================
--- proj/utils.c	(nonexistent)
+++ proj/utils.c	(revision 144)
@@ -0,0 +1,37 @@
+#include <lcom/lcf.h>
+
+#include "utils.h"
+
+#include <stdint.h>
+#include "errors.h"
+
+int(util_get_LSB)(uint16_t val, uint8_t *lsb) {
+    if (lsb == NULL) return NULL_PTR;
+    *lsb = val;
+    return SUCCESS;
+}
+
+int(util_get_MSB)(uint16_t val, uint8_t *msb) {
+    if (msb == NULL) return NULL_PTR;
+    *msb = (val >> 8);
+    return SUCCESS;
+}
+
+#ifdef LAB3
+    uint32_t sys_inb_counter = 0;
+#endif
+
+int (util_sys_inb)(int port, uint8_t *value) {
+    if(value == NULL) return NULL_PTR;
+    uint32_t n = 0;
+    if(sys_inb(port, &n)) return READ_ERROR;
+    *value = n;
+    return SUCCESS;
+}
+
+int16_t abs16(int16_t x) {
+    return (x >= 0) ? (int16_t)(x) : (int16_t)(-x);
+}
+
+int16_t min(int16_t a, int16_t b){ return (b < a ? b : a); }
+int16_t max(int16_t a, int16_t b){ return (a < b ? b : a); }

Property changes on: proj/utils.c
___________________________________________________________________
Added: svn:executable
Index: proj/utils.h
===================================================================
--- proj/utils.h	(nonexistent)
+++ proj/utils.h	(revision 144)
@@ -0,0 +1,45 @@
+#ifndef UTILS_H_INCLUDED
+#define UTILS_H_INCLUDED
+
+/**
+ * @brief Gets the least significant byte of a 16-bit variable
+ * @param val 16-bit variable
+ * @param lsb Pointer to a 8-bit variable to store the value of the LSB
+ * @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
+ */
+int(util_get_LSB)(uint16_t val, uint8_t *lsb);
+
+/**
+ * @brief Gets the most significant byte of a 16-bit variable
+ * @param val 16-bit variable
+ * @param lsb Pointer to a 8-bit variable to store the value of the MSB
+ * @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
+ */
+int(util_get_MSB)(uint16_t val, uint8_t *msb);
+
+/**
+ * @brief sys_inb wrapper
+ * @param port Port to read from
+ * @param value Pointer to byte to store value read
+ * @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
+ */
+int (util_sys_inb)(int port, uint8_t *value);
+
+/**
+ * @brief Gets the minimum value out of two values.
+ * @param a     First value
+ * @param b     Second value
+ * @return  The minimum of the two values
+ */
+int16_t min(int16_t a, int16_t b);
+
+/**
+ * @brief Gets the maximum value out of two values.
+ * @param a     First value
+ * @param b     Second value
+ * @return  The maximum of the two values
+ */
+int16_t max(int16_t a, int16_t b);
+
+
+#endif //UTILS_H_INCLUDED

Property changes on: proj/utils.h
___________________________________________________________________
Added: svn:executable
