Index: proj/include/mouse.h
===================================================================
--- proj/include/mouse.h	(revision 277)
+++ proj/include/mouse.h	(nonexistent)
@@ -1,89 +0,0 @@
-#ifndef MOUSE_H_INCLUDED
-#define MOUSE_H_INCLUDED
-
-/**
- * @brief Subscribes Mouse Interrupts and disables Minix Default IH
- * @param interrupt_bit Bit of Interrupt Vector that will be set when Mouse Interrupt is pending
- * @param interrupt_id Mouse Interrupt ID to specify the Mouse Interrupt in other calls
- * @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
- * @see {_ERRORS_H_::errors}
- */
-int (subscribe_mouse_interrupt)(uint8_t interrupt_bit, int *interrupt_id);
-
-//These have to do with mouse_ih
-int got_error_mouse_ih;
-uint8_t packet_mouse_ih[3];
-int counter_mouse_ih;
-
-/**
- * @brief   Parse 3 bytes and returns it as a parsed, struct packet.
- * @param   packet_bytes    array of bytes to parse
- * @param   pp              Pointer to packet to store the information.
- */
-void (mouse_parse_packet)(const uint8_t *packet_bytes, struct packet *pp);
-
-/**
- * @brief Polls mouse for data. Blocks execution until a valid mouse packet is obtained.
- * @param   pp      pointer to packet struct in which the result will be stored
- * @param   period  time (in milliseconds) the poller should wait between pollings of bytes
- * @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
- */
-int mouse_poll(struct packet *pp, uint16_t period);
-
-/**
- * @brief Sets data report mode for mouse
- * @param   on  zero to disable data report, any other value to enable data report
- * @return  ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
- */
-int (mouse_set_data_report)(int on);
-
-/**
- * @brief Reads data byte from mouse
- * <summary>
- * Polls the mouse till data is available for reading
- * </summary>
- * @param data Pointer to variable where byte read from mouse will be stored
- * @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
- * @see {_ERRORS_H_::errors}
- */
-int (mouse_read_data)(uint8_t *data, uint16_t period);
-
-/**
- * @brief Issues command to mouse
- * <summary>
- * Issues command to mouse, returns error after two consecutive errors reported by the acknowledgment byte
- * </summary>
- * @param cmd Command to be issued
- * @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
- * @see {_ERRORS_H_::errors}
- */
-int (mouse_issue_cmd)(uint32_t cmd);
-
-/**
- * @brief Reads byte from mouse
- * <summary>
- * Reads byte from mouse, giving error if exceeds number of tries to read
- * </summary>
- * @param byte Pointer to variable where byte read from mouse will be stored
- * @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
- * @see {_ERRORS_H_::errors}
- */
-int (mouse_read_byte)(uint8_t *byte);
-
-/**
- * @brief Polls OUT_BUF for byte coming from mouse.
- * @param   byte    pointer to byte read from OUT_BUF
- * @param   period  time (in milliseconds) the poller should wait between pollings of bytes
- * @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
- */
-int (mouse_poll_byte)(uint8_t *byte, uint16_t period);
-
-/**
- * @brief Converts 9-bit number to 16-bit with sign extension
- * @param sign_bit  Sign bit identifiying the signal of the number
- * @param byte      Least significant byte that will be extended
- * @return Extended 9-bit number
- */
-int16_t (sign_extend_byte)(uint8_t sign_bit, uint8_t byte);
-
-#endif //MOUSE_H_INCLUDED

Property changes on: proj/include/mouse.h
___________________________________________________________________
Deleted: svn:executable
## -1 +0,0 ##
-*
\ No newline at end of property
Index: proj/include/kbc.h
===================================================================
--- proj/include/kbc.h	(revision 277)
+++ proj/include/kbc.h	(nonexistent)
@@ -1,107 +0,0 @@
-/**
- * This file concerns everything related to the KBC (KeyBoard Controller, which
- * actually also manages the mouse)
- */
-
-#ifndef KBC_H_INCLUDED
-#define KBC_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 */
-
-/**
- * @brief High-level function that reads the command byte of the KBC
- * @param cmd Pointer to variable where command byte read from KBC will be stored
- * @return 0 if operation was successful, 1 otherwise
- */
-int (kbc_read_cmd)(uint8_t *cmd);
-
-/**
- * @brief High-level function that changes the command byte of the KBC
- * @param cmd New value for command byte of KBC
- * @return 0 if operation was successful, 1 otherwise
- */
-int (kbc_change_cmd)(uint8_t cmd);
-
-/**
- * @brief High-level function that restores KBC to normal state
- * High-level function that restores KBC to normal state, because lcf_start
- * changes the command byte of KBC. If this function is not used, there is a
- * chance that the keyboard and keyboard interrupts remain disabled.
- * @return 0 if operation was successful, 1 otherwise
- */
-int (kbc_restore_keyboard)();
-
-/**
- * @brief Low-level function to issue a command to keyboard
- * @param cmd command to be issued
- * @return 0 if operation was successful, 1 otherwise
- */
-int (kbc_issue_cmd)(uint8_t cmd);
-
-/**
- * @brief Low-level function to issue an argument of a command
- * @param cmd argument to be issued
- * @return 0 if operation was successful, 1 otherwise
- */
-int (kbc_issue_arg)(uint8_t arg);
-
-/**
- * @brief Low-level function for reading byte from keyboard
- * Low-level function for reading byte from keyboard. Waits until output buffer
- * is full
- * @param value Pointer to variable where byte read from keyboard will be stored
- * @return 0 if operation was successful, 1 otherwise
- */
-int (kbc_read_byte)(uint8_t *byte);
-
-#endif //KBC_H_INCLUDED

Property changes on: proj/include/kbc.h
___________________________________________________________________
Deleted: svn:executable
## -1 +0,0 ##
-*
\ No newline at end of property
Index: proj/include/uart.h
===================================================================
--- proj/include/uart.h	(revision 277)
+++ proj/include/uart.h	(nonexistent)
@@ -1,52 +0,0 @@
-#ifndef UART_H_INCLUDED
-#define UART_H_INCLUDED
-
-#define COM1_ADDR           0x3F8
-#define COM2_ADDR           0x2F8
-#define COM1_IRQ            4
-#define COM2_IRQ            3
-#define COM1_VECTOR         0x0C
-#define COM2_VECTOR         0x0B
-
-typedef enum {
-    uart_parity_none = 0x0,
-    uart_parity_odd  = 0x1,
-    uart_parity_even = 0x3,
-    uart_parity_par1 = 0x5,
-    uart_parity_par0 = 0x7
-} uart_parity;
-
-typedef struct {
-    int     base_addr               ;
-    uint8_t lcr                     ;
-    uint8_t dll                     ;
-    uint8_t dlm                     ;
-    uint8_t bits_per_char           ;
-    uint8_t stop_bits               ;
-    uart_parity parity              ;
-    uint8_t break_control         :1;
-    uint8_t dlab                  :1;
-    uint16_t divisor_latch          ;
-    uint8_t ier                     ;
-    uint8_t received_data_int     :1;
-    uint8_t transmitter_empty_int :1;
-    uint8_t receiver_line_stat_int:1;
-    uint8_t modem_stat_int        :1;
-} uart_config;
-
-int (subscribe_uart_interrupt)(uint8_t interrupt_bit, int *interrupt_id);
-
-int uart_get_config(int base_addr, uart_config *config);
-void uart_print_config(uart_config config);
-
-int uart_set_bits_per_character(int base_addr, uint8_t     bits_per_char);
-int uart_set_stop_bits         (int base_addr, uint8_t     stop         );
-int uart_set_parity            (int base_addr, uart_parity par          );
-int uart_set_bit_rate          (int base_addr, float       bit_rate     );
-
-int uart_enable_int_rx (int base_addr);
-int uart_disable_int_rx(int base_addr);
-int uart_enable_int_tx (int base_addr);
-int uart_disable_int_tx(int base_addr);
-
-#endif //UART_H_INCLUDED

Property changes on: proj/include/uart.h
___________________________________________________________________
Deleted: svn:executable
## -1 +0,0 ##
-*
\ No newline at end of property
Index: proj/include/keyboard.h
===================================================================
--- proj/include/keyboard.h	(revision 277)
+++ proj/include/keyboard.h	(nonexistent)
@@ -1,28 +0,0 @@
-/**
- * This file concerns everything related to the keyboard
- */
-
-#ifndef KEYBOARD_H_INCLUDED
-#define KEYBOARD_H_INCLUDED
-
-#include "kbc.h"
-
-/**
- * @brief Subscribes Keyboard Interrupts and disables Minix Default IH
- * @param interrupt_bit Bit of Interrupt Vector that will be set when Keyboard Interrupt is pending
- * @param interrupt_id Keyboard Interrupt ID to specify the Keyboard Interrupt in other calls
- * @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
- * @see {_ERRORS_H_::errors}
- */
-int (subscribe_kbc_interrupt)(uint8_t interrupt_bit, int *interrupt_id);
-
-uint8_t scancode[2];
-int done;
-int sz;
-int got_error_keyboard;
-
-void (kbc_ih)(void);
-
-int (keyboard_poll)(uint8_t bytes[], uint8_t *size);
-
-#endif //KEYBOARD_H_INCLUDED

Property changes on: proj/include/keyboard.h
___________________________________________________________________
Deleted: svn:executable
## -1 +0,0 ##
-*
\ No newline at end of property
Index: proj/include/rtc.h
===================================================================
--- proj/include/rtc.h	(revision 277)
+++ proj/include/rtc.h	(nonexistent)
@@ -1,46 +0,0 @@
-#ifndef RTC_H_INCLUDED
-#define RTC_H_INCLUDED
-
-#include <stdint.h>
-
-/**
- * @brief Subscribes RTC Interrupts
- * @param interrupt_bit Bit of Interrupt Vector that will be set when RTC Interrupt is pending
- * @param interrupt_id RTC Interrupt ID to specify the RTC Interrupt in other calls
- * @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
- * @see {_ERRORS_H_::errors}
- */
-int (subscribe_rtc_interrupt)(uint8_t interrupt_bit, int *interrupt_id);
-
-int (rtc_read_register)(uint32_t reg, uint8_t *data);
-
-int (rtc_write_register)(uint32_t reg, uint8_t data);
-
-/**
- * @brief Checks if there's an update in progress.
- * @return  The value of the flag UIP, or ERROR_CODE if error occurs.
- */
-int (rtc_check_update)(void);
-
-/**
- * @brief Enables/Disables updates of time/date registers.
- * @param   on  zero to disable, any other value to enable
- * @return  ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
- */
-int (rtc_set_updates)(int on);
-
-/**
- * @brief Reads time from RTC.
- * @param   time  Pointer to array of 3 bytes to store the information about time (hours, minutes, seconds)
- * @return  ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
- */
-int (rtc_read_time)(uint8_t *time);
-
-/**
- * @brief Reads date from RTC.
- * @param   date  Pointer to array of 4 bytes to store the information about date (year, month, day, weekday)
- * @return  ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
- */
-int (rtc_read_date)(uint8_t *date);
-
-#endif /* end of include guard: RTC_H_INCLUDED */

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

Property changes on: proj/include/timer.h
___________________________________________________________________
Deleted: svn:executable
## -1 +0,0 ##
-*
\ No newline at end of property
Index: proj/include/list.h
===================================================================
--- proj/include/list.h	(revision 277)
+++ proj/include/list.h	(nonexistent)
@@ -1,28 +0,0 @@
-#ifndef LIST_H_INCLUDED
-#define LIST_H_INCLUDED
-
-struct list_node;
-typedef struct list_node list_node_t;
-
-list_node_t* (list_node_ctor)(list_node_t *p, list_node_t *n, void *val);
-void         (list_node_dtor)(list_node_t *p);
-list_node_t* (list_node_next)(const list_node_t *p);
-list_node_t* (list_node_prev)(const list_node_t *p);
-void**       (list_node_val )(list_node_t *p);
-
-struct list;
-typedef struct list list_t;
-
-list_t* (list_ctor)(void);
-int     (list_dtor)(list_t *l);
-list_node_t* (list_begin )(list_t *l);
-list_node_t* (list_end   )(list_t *l);
-size_t       (list_size  )(const list_t *l);
-int          (list_empty )(const list_t *l);
-list_node_t* (list_insert)(list_t *l, list_node_t *position, void *val);
-void*        (list_erase )(list_t *l, list_node_t *position);
-void         (list_push_back)(list_t *l, void *val);
-void**       (list_front)(list_t *l);
-void         (list_pop_front)(list_t *l);
-
-#endif //LIST_H_INCLUDED

Property changes on: proj/include/list.h
___________________________________________________________________
Deleted: svn:executable
## -1 +0,0 ##
-*
\ No newline at end of property
Index: proj/include/queue.h
===================================================================
--- proj/include/queue.h	(revision 277)
+++ proj/include/queue.h	(nonexistent)
@@ -1,17 +0,0 @@
-#ifndef QUEUE_H_INCLUDED
-#define QUEUE_H_INCLUDED
-
-struct queue;
-typedef struct queue queue_t;
-
-const size_t queue_max_size;
-
-queue_t* (queue_ctor )(void);
-int      (queue_dtor )(queue_t *q);
-size_t   (queue_size )(const queue_t *q);
-int      (queue_empty)(const queue_t *q);
-void     (queue_push )(queue_t *q, void *val);
-void*    (queue_top  )(const queue_t *q);
-void     (queue_pop  )(queue_t *q);
-
-#endif //QUEUE_H_INCLUDED

Property changes on: proj/include/queue.h
___________________________________________________________________
Deleted: svn:executable
## -1 +0,0 ##
-*
\ No newline at end of property
Index: proj/src/keyboard.c
===================================================================
--- proj/src/keyboard.c	(revision 277)
+++ proj/src/keyboard.c	(nonexistent)
@@ -1,60 +0,0 @@
-#include <lcom/lcf.h>
-
-#include "keyboard.h"
-
-#include "kbc.h"
-#include "utils.h"
-#include "errors.h"
-#include "proj_func.h"
-
-int (subscribe_kbc_interrupt)(uint8_t interrupt_bit, int *interrupt_id) {
-    if (interrupt_id == NULL) return NULL_PTR;
-    *interrupt_id = interrupt_bit;
-    if(sys_irqsetpolicy(KBC_IRQ, IRQ_REENABLE | IRQ_EXCLUSIVE, interrupt_id)) return SBCR_ERROR;
-    return SUCCESS;
-}
-
-int done = 1;
-int sz = 1;
-int got_error_keyboard = SUCCESS;
-
-void (kbc_ih)(void) {
-    if(done) { sz = 1; }
-    else     sz++;
-    uint8_t status = 0;
-    got_error_keyboard = SUCCESS;
-    if ((got_error_keyboard = util_sys_inb(STATUS_REG, &status))) return;
-    if (status & (TIME_OUT_REC | PARITY_ERROR)) {
-        got_error_keyboard = 1;
-        return;
-    }
-    if ((status & OUT_BUF_FUL) == 0 || (status & AUX_MOUSE) != 0) {
-        got_error_keyboard = READ_ERROR;
-        return;
-    }
-    uint8_t byte = 0;
-    if ((got_error_keyboard = util_sys_inb(OUTPUT_BUF, &byte))) return;
-
-    scancode[sz-1] = byte;
-    done = !(TWO_BYTE_CODE == byte);
-
-    if (done) update_key_presses();
-
-}
-
-int (keyboard_poll)(uint8_t bytes[], uint8_t *size){
-    int ret = 0;
-    if(bytes == NULL || size == NULL) return NULL_PTR;
-    uint8_t c;
-    if((ret = kbc_read_byte(&c))) return ret;
-    if(c == TWO_BYTE_CODE){
-        if((ret = kbc_read_byte(&bytes[1]))) return ret;
-        bytes[0] = c;
-        *size = 2;
-    }else{
-        bytes[1] = 0;
-        bytes[0] = c;
-        *size = 1;
-    }
-    return SUCCESS;
-}

Property changes on: proj/src/keyboard.c
___________________________________________________________________
Deleted: svn:executable
## -1 +0,0 ##
-*
\ No newline at end of property
Index: proj/src/rtc.c
===================================================================
--- proj/src/rtc.c	(revision 277)
+++ proj/src/rtc.c	(nonexistent)
@@ -1,159 +0,0 @@
-#include <lcom/lcf.h>
-
-#include "rtc.h"
-
-#include "utils.h"
-#include "errors.h"
-
-// RTC IRQ Line
-
-#define KBC_IRQ   8  /* @brief KBC IRQ Line */
-
-// RTC Ports
-
-#define RTC_ADDR_REG        0x70
-#define RTC_DATA_REG        0x71
-
-// RTC Registers (Byte)
-
-#define RTC_SEC             0
-#define RTC_SEC_ALARM       1
-#define RTC_MIN             2
-#define RTC_MIN_ALARM       3
-#define RTC_HOUR            4
-#define RTC_HOUR_ALARM      5
-#define RTC_WEEK_DAY        6
-#define RTC_MONTH_DAY       7
-#define RTC_MONTH           8
-#define RTC_YEAR            9
-#define RTC_REG_A           10
-#define RTC_REG_B           11
-#define RTC_REG_C           12
-#define RTC_REG_D           13
-
-// Register A
-
-#define RS0     BIT(0)  /** @brief Rate selector */
-#define RS1     BIT(1)  /** @brief Rate selector */
-#define RS2     BIT(2)  /** @brief Rate selector */
-#define RS3     BIT(3)  /** @brief Rate selector */
-#define UIP     BIT(7)  /** @brief Update in progress */
-
-// Register B
-
-#define DSE             BIT(0)  /** @brief Enable Daylight Saving Time */
-#define HOUR_FORM       BIT(1)  /** @brief Set to 1 for 24h format (0-23), 0 to 12h format (1-12) */
-#define DM              BIT(2)  /** @brief Set to 1 if registers are in binary, 0 if in BCD */
-#define SQWE            BIT(3)  /** @brief Enable square wave generation */
-#define UIE             BIT(4)  /** @brief Enable Update interrupts */
-#define AIE             BIT(5)  /** @brief Enable alarm interrupts */
-#define PIE             BIT(6)  /** @brief Enable periodic interrupts */
-#define SET             BIT(7)  /** @brief Set to 1 to inhibit updates of time/date registers */
-
-// Register C
-
-#define UF      BIT(4)  /** @brief Update Interrupt Pending */
-#define AF      BIT(5)  /** @brief Alarm Interrupt Pending */
-#define PF      BIT(6)  /** @brief Periodic Interrupt Pending */
-#define IRQF    BIT(7)  /** @brief IRQ Line Active */
-
-// Register D
-
-#define VRT     BIT(7)  /** @brief Valid RAM/time - If set to 0 RTC reading aren't valid */
-
-int (subscribe_rtc_interrupt)(uint8_t interrupt_bit, int *interrupt_id) {
-    if (interrupt_id == NULL) return NULL_PTR;
-    *interrupt_id = interrupt_bit;
-    if (sys_irqsetpolicy(KBC_IRQ, IRQ_REENABLE | IRQ_EXCLUSIVE, interrupt_id)) return SBCR_ERROR;
-    return SUCCESS;
-}
-
-int (rtc_read_register)(uint32_t reg, uint8_t *data) {
-    if (sys_outb(RTC_ADDR_REG, reg)) return WRITE_ERROR;
-
-    if (util_sys_inb(RTC_DATA_REG, data)) return READ_ERROR;
-
-    return SUCCESS;
-}
-
-int (rtc_write_register)(uint32_t reg, uint8_t data) {
-    if (sys_outb(RTC_ADDR_REG, reg)) return WRITE_ERROR;
-
-    if (sys_outb(RTC_DATA_REG, data)) return WRITE_ERROR;
-
-    return SUCCESS;
-}
-
-int (rtc_check_update)(void) {
-    uint8_t data;
-    int r;
-
-    if ((r = rtc_read_register(RTC_REG_A, &data))) return r;
-
-    return (data & UIP) != 0;
-}
-
-int (rtc_set_updates)(int on) {
-    uint8_t data;
-    int r;
-    if (on) {
-        if ((r = rtc_read_register(RTC_REG_B, &data))) return r;
-
-        data &= ~SET;
-
-        if ((r = rtc_write_register(RTC_REG_B, data))) return r;
-
-    } else {
-        while (rtc_check_update());
-
-        if ((r = rtc_read_register(RTC_REG_B, &data))) return r;
-
-        data |= SET;
-
-        if ((r = rtc_write_register(RTC_REG_B, data))) return r;
-    }
-    return SUCCESS;
-}
-
-int (rtc_read_time)(uint8_t *time) {
-
-    int r;
-    //if ((r = rtc_set_updates(false))) return r;
-    while (rtc_check_update());
-
-    uint8_t hour, min, sec;
-
-    if ((r = rtc_read_register(RTC_SEC, &sec)))    return r;
-    if ((r = rtc_read_register(RTC_MIN, &min)))    return r;
-    if ((r = rtc_read_register(RTC_HOUR, &hour)))  return r;
-
-    //if ((r = rtc_set_updates(true))) return r;
-
-    time[0] = BCD_FIRST(sec)*10   + BCD_SECOND(sec);
-    time[1] = BCD_FIRST(min)*10   + BCD_SECOND(min);
-    time[2] = BCD_FIRST(hour)*10  + BCD_SECOND(hour);
-
-    return SUCCESS;
-}
-
-int (rtc_read_date)(uint8_t *date) {
-    int r;
-    //if ((r = rtc_set_updates(false))) return r;
-    while (rtc_check_update());
-
-    uint8_t year, month, day, weekday;
-
-    if ((r = rtc_read_register(RTC_WEEK_DAY,    &weekday)))     return r;
-    if ((r = rtc_read_register(RTC_MONTH_DAY,   &day)))         return r;
-    if ((r = rtc_read_register(RTC_MONTH,       &month)))       return r;
-    if ((r = rtc_read_register(RTC_YEAR,        &year)))        return r;
-
-    //if ((r = rtc_set_updates(true))) return r;
-
-    date[0] = weekday;
-    date[1] = BCD_FIRST(day)*10     + BCD_SECOND(day);
-    date[2] = BCD_FIRST(month)*10   + BCD_SECOND(month);
-    date[3] = BCD_FIRST(year)*10    + BCD_SECOND(year);
-
-    return SUCCESS;
-}

Property changes on: proj/src/rtc.c
___________________________________________________________________
Deleted: svn:executable
## -1 +0,0 ##
-*
\ No newline at end of property
Index: proj/src/timer.c
===================================================================
--- proj/src/timer.c	(revision 277)
+++ proj/src/timer.c	(nonexistent)
@@ -1,18 +0,0 @@
-#include <lcom/lcf.h>
-
-#include "timer.h"
-#include "graph.h"
-#include "sprite.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/src/timer.c
___________________________________________________________________
Deleted: svn:executable
## -1 +0,0 ##
-*
\ No newline at end of property
Index: proj/src/list.c
===================================================================
--- proj/src/list.c	(revision 277)
+++ proj/src/list.c	(nonexistent)
@@ -1,79 +0,0 @@
-#include <lcom/lcf.h>
-
-#include "list.h"
-
-struct list_node{
-    list_node_t *p, *n;
-    void *val;
-};
-list_node_t* (list_node_ctor)(list_node_t *p, list_node_t *n, void *val){
-    list_node_t *ret = malloc(sizeof(list_node_t));
-    if(ret == NULL) return NULL;
-    ret->p = p;
-    ret->n = n;
-    ret->val = val;
-    return ret;
-}
-void (list_node_dtor)(list_node_t *p){
-    free(p);
-}
-list_node_t* (list_node_next)(const list_node_t *p){ return p->n; }
-list_node_t* (list_node_prev)(const list_node_t *p){ return p->p; }
-void**       (list_node_val )(list_node_t *p){ return &p->val; }
-
-struct list{
-    list_node_t *begin_;
-    list_node_t *end_;
-    size_t sz;
-};
-list_t* (list_ctor)(void){
-    list_t *ret = malloc(sizeof(list_t));
-    if(ret == NULL) return NULL;
-    ret->sz = 0;
-    ret->begin_ = NULL; ret->end_ = NULL;
-    ret->begin_ = list_node_ctor(NULL, NULL, NULL);
-    ret->end_   = list_node_ctor(NULL, NULL, NULL);
-    if(ret->begin_ == NULL || ret->end_ == NULL){
-        list_dtor(ret);
-        return NULL;
-    }
-    ret->begin_->n = ret->end_  ;
-    ret->end_  ->p = ret->begin_;
-    return ret;
-}
-int (list_dtor)(list_t *l){
-    if(l == NULL) return 0;
-    if(list_size(l) > 0) return 1;
-    list_node_dtor(l->begin_);
-    list_node_dtor(l->end_);
-    free(l);
-    return 0;
-}
-list_node_t* (list_begin )(      list_t *l){ return l->begin_->n; }
-list_node_t* (list_end   )(      list_t *l){ return l->end_; }
-size_t       (list_size  )(const list_t *l){ return l->sz; }
-int          (list_empty )(const list_t *l){ return !(l->sz); }
-list_node_t* (list_insert)(list_t *l, list_node_t *position, void *val){
-    list_node_t *node = list_node_ctor(position->p, position, val);
-    position->p->n = node;
-    position->p    = node;
-    ++l->sz;
-    return node;
-}
-void*        (list_erase )(list_t *l, list_node_t *position){
-    position->p->n = position->n;
-    position->n->p = position->p;
-    void *ret = position->val;
-    list_node_dtor(position);
-    --l->sz;
-    return ret;
-}
-void         (list_push_back)(list_t *l, void *val){
-    list_insert(l, list_end(l), val);
-}
-void**       (list_front)(list_t *l){
-    return list_node_val(list_begin(l));
-}
-void         (list_pop_front)(list_t *l){
-    list_erase(l, list_begin(l));
-}

Property changes on: proj/src/list.c
___________________________________________________________________
Deleted: svn:executable
## -1 +0,0 ##
-*
\ No newline at end of property
Index: proj/src/queue.c
===================================================================
--- proj/src/queue.c	(revision 277)
+++ proj/src/queue.c	(nonexistent)
@@ -1,34 +0,0 @@
-#include <lcom/lcf.h>
-
-#include "queue.h"
-
-#include "list.h"
-#include "errors.h"
-
-const size_t queue_max_size = UINT_MAX;
-
-struct queue{
-    list_t *l;
-};
-
-queue_t* (queue_ctor )(void){
-    queue_t *ret = malloc(sizeof(queue_t));
-    if(ret == NULL) return NULL;
-    ret->l = list_ctor();
-    if(ret->l == NULL){
-        queue_dtor(ret);
-        return NULL;
-    }
-    return ret;
-}
-int      (queue_dtor )(queue_t *q){
-    int r;
-    if((r = list_dtor(q->l))) return r;
-    free(q);
-    return SUCCESS;
-}
-size_t   (queue_size )(const queue_t *q           ){ return list_size (q->l); }
-int      (queue_empty)(const queue_t *q           ){ return list_empty(q->l); }
-void     (queue_push )(      queue_t *q, void *val){ list_push_back(q->l, val); }
-void*    (queue_top  )(const queue_t *q           ){ return *list_front(q->l); }
-void     (queue_pop  )(      queue_t *q           ){ list_pop_front(q->l); }

Property changes on: proj/src/queue.c
___________________________________________________________________
Deleted: svn:executable
## -1 +0,0 ##
-*
\ No newline at end of property
Index: proj/src/mouse.c
===================================================================
--- proj/src/mouse.c	(revision 277)
+++ proj/src/mouse.c	(nonexistent)
@@ -1,162 +0,0 @@
-#include <lcom/lcf.h>
-
-#include "mouse.h"
-
-#include "errors.h"
-#include "kbc.h"
-
-/* Mouse Data Packet */
-// Byte 0 - Button States
-#define LEFT_BUTTON     BIT(0) /* @brief Left button click event*/
-#define RIGHT_BUTTON    BIT(1) /* @brief Right button click event */
-#define MIDDLE_BUTTON   BIT(2) /* @brief Middle button click event */
-#define FIRST_BYTE_ID   BIT(3) /* @brief Identifier of first byte of packet CAREFUL: Not 100% accurate */
-#define MSB_X_DELTA     BIT(4) /* @brief Most significant bit of X delta */
-#define MSB_Y_DELTA     BIT(5) /* @brief Most significant bit of Y delta */
-#define X_OVERFLOW      BIT(6) /* @brief X delta overflowed */
-#define Y_OVERFLOW      BIT(7) /* @brief Y delta overflowed */
-// Byte 1 - X delta
-// Byte 2 - Y delta
-
-/* Mouse Commands */
-#define RESET           0xFF /* @brief Reset mouse */
-#define RESEND          0xFE /* @brief Resend command */
-#define DEFAULT         0xF6 /* @brief Set default values */
-#define DIS_DATA_REP    0xF5 /* @brief Disable Data Reporting */
-#define ENABLE_DATA_REP 0xF4 /* @brief Enable Data Reporting */
-#define SET_SAMPLE_RT   0xF3 /* @brief Sets state sampling rate */
-#define SET_REMOTE_MD   0xF0 /* @brief Sets Mouse on Remote Mode, data on request */
-#define READ_DATA       0xEB /* @brief Sends data packet request */
-#define SET_STREAM_MD   0xEA /* @brief Sets mouse on Stream Mode, data on events */
-#define STATUS_REQUEST  0xE9 /* @brief Get mouse configuration */
-#define SET_RESOLUTION  0xE8 /* @brief Sets resolution for mouse movement */
-#define SCALING_ACC_MD  0xE7 /* @brief Sets scaling on acceleration mode */
-#define SCALING_LIN_MD  0xE6 /* @brief Sets scaling on linear mode */
-
-/* Mouse Controller Responses */
-#define ACK_OK      0xFA /* @brief Operation sucessful */
-#define ACK_INVALID 0xFE /* @brief Invalid Byte, first occurence */
-#define ACK_ERROR   0xFC /* @brief Invalid Byte on resend */
-
-int (subscribe_mouse_interrupt)(uint8_t interrupt_bit, int *interrupt_id) {
-    if (interrupt_id == NULL) return NULL_PTR;
-    *interrupt_id = interrupt_bit;
-    if (sys_irqsetpolicy(MOUSE_IRQ, IRQ_REENABLE | IRQ_EXCLUSIVE, interrupt_id)) return SBCR_ERROR;
-    return SUCCESS;
-}
-
-int got_error_mouse_ih = 0;
-int counter_mouse_ih = 0;
-
-void (mouse_ih)(void) {
-    uint8_t status = 0;
-    got_error_mouse_ih = 0;
-    if(counter_mouse_ih >= 3) counter_mouse_ih = 0;
-
-    if ((got_error_mouse_ih = util_sys_inb(STATUS_REG, &status))) return;
-
-    if (status & (TIME_OUT_REC | PARITY_ERROR)) {
-        got_error_mouse_ih = OTHER_ERROR;
-        return;
-    }
-    if (((status & AUX_MOUSE) == 0) || ((status & OUT_BUF_FUL) == 0)) {
-        got_error_mouse_ih = READ_ERROR;
-        return;
-    }
-
-    uint8_t byte = 0;
-
-    if ((got_error_mouse_ih = util_sys_inb(OUTPUT_BUF, &byte))) return;
-
-    /// This does not run if: I was expecting the first one but what I get is definitely not the first byte
-    if((byte & FIRST_BYTE_ID)  || counter_mouse_ih){
-        packet_mouse_ih[counter_mouse_ih++] = byte;
-    }
-}
-
-void (mouse_parse_packet)(const uint8_t *packet_bytes, struct packet *pp){
-    pp->bytes[0] = packet_bytes[0];
-    pp->bytes[1] = packet_bytes[1];
-    pp->bytes[2] = packet_bytes[2];
-    pp->rb       = pp->bytes[0] & RIGHT_BUTTON;
-    pp->mb       = pp->bytes[0] & MIDDLE_BUTTON;
-    pp->lb       = pp->bytes[0] & LEFT_BUTTON;
-    pp->delta_x  = sign_extend_byte((packet_bytes[0] & MSB_X_DELTA) != 0, pp->bytes[1]);
-    pp->delta_y  = sign_extend_byte((packet_bytes[0] & MSB_Y_DELTA) != 0, pp->bytes[2]);
-    pp->x_ov     = pp->bytes[0] & X_OVERFLOW;
-    pp->y_ov     = pp->bytes[0] & Y_OVERFLOW;
-}
-
-int mouse_poll(struct packet *pp, uint16_t period){
-    int ret = 0;
-
-    uint8_t packet[3];
-    uint8_t byte;
-    if ((ret = mouse_issue_cmd(READ_DATA))) return ret;
-    for(unsigned i = 0; i < 3; ++i){
-        if((ret = mouse_poll_byte(&byte, period))) return ret;
-        packet[i] = byte;
-    }
-    mouse_parse_packet(packet, pp);
-    return SUCCESS;
-}
-
-int (mouse_set_data_report)(int on){
-    if(on) return mouse_issue_cmd(ENABLE_DATA_REP);
-    else   return mouse_issue_cmd(   DIS_DATA_REP);
-}
-
-int (mouse_read_data)(uint8_t *data, uint16_t period) {
-    int ret;
-    if ((ret = mouse_issue_cmd(READ_DATA))) return ret;
-    if ((ret = mouse_poll_byte(data, period))) return ret;
-    return SUCCESS;
-}
-
-int (mouse_issue_cmd)(uint32_t cmd) {
-    int ret;
-    uint8_t ack = 0;
-    for (unsigned int i = 0; i < KBC_NUM_TRIES; i++) {
-        if ((ret = kbc_issue_cmd(MOUSE_WRITE_B))) return ret;
-        if ((ret = kbc_issue_arg(cmd))) return ret;
-        if ((ret = mouse_read_byte(&ack))) return ret;
-
-        if (ack == ACK_OK) return SUCCESS;
-        if (ack == ACK_ERROR) return INVALID_COMMAND;
-        tickdelay(micros_to_ticks(DELAY));
-    }
-    return TIMEOUT_ERROR;
-}
-
-int (mouse_read_byte)(uint8_t *byte) {
-    int ret = 0;
-    uint8_t stat;
-    for(int i = 0; i < KBC_NUM_TRIES; ++i){
-        if((ret = util_sys_inb(STATUS_REG, &stat))) return ret;
-        if((stat&OUT_BUF_FUL) && (stat&AUX_MOUSE)) {
-            if(stat & (PARITY_ERROR | TIME_OUT_REC)) return OTHER_ERROR;
-            if((ret = util_sys_inb(OUTPUT_BUF, byte))) return ret;
-            else return SUCCESS;
-        }
-        tickdelay(micros_to_ticks(DELAY));
-    }
-    return TIMEOUT_ERROR;
-}
-
-int (mouse_poll_byte)(uint8_t *byte, uint16_t period) {
-    int ret = 0;
-    uint8_t stat;
-    while(true){
-        if((ret = util_sys_inb(STATUS_REG, &stat))) return ret;
-        if((stat&OUT_BUF_FUL) && (stat&AUX_MOUSE)) {
-            if(stat & (PARITY_ERROR | TIME_OUT_REC)) return OTHER_ERROR;
-            if((ret = util_sys_inb(OUTPUT_BUF, byte))) return ret;
-            else return SUCCESS;
-        }
-        tickdelay(micros_to_ticks(DELAY));
-    }
-}
-
-int16_t (sign_extend_byte)(uint8_t sign_bit, uint8_t byte) {
-    return (int16_t)(((0xFF * sign_bit)<<8) | byte);
-}

Property changes on: proj/src/mouse.c
___________________________________________________________________
Deleted: svn:executable
## -1 +0,0 ##
-*
\ No newline at end of property
Index: proj/src/kbc.c
===================================================================
--- proj/src/kbc.c	(revision 277)
+++ proj/src/kbc.c	(nonexistent)
@@ -1,73 +0,0 @@
-#include <lcom/lcf.h>
-
-#include "kbc.h"
-
-#include "utils.h"
-#include "errors.h"
-
-int (kbc_read_cmd)(uint8_t *cmd){
-    int ret = 0;
-    if((ret = kbc_issue_cmd(READ_KBC_CMD))) return ret;
-    if((ret = kbc_read_byte(cmd))) return ret;
-    return SUCCESS;
-}
-
-int (kbc_change_cmd)(uint8_t cmd){
-    int ret = 0;
-    if((ret = kbc_issue_cmd(WRITE_KBC_CMD))) return ret;
-    if((ret = kbc_issue_arg(cmd))) return ret;
-    return SUCCESS;
-}
-
-int (kbc_restore_kbd)(){
-    int ret = 0;
-    uint8_t cmd = 0;
-    if((ret = kbc_read_cmd(&cmd))) return ret;
-    cmd = (cmd | INT_KBD) & (~DIS_KBD);
-    if((ret = kbc_change_cmd(cmd))) return ret;
-    return SUCCESS;
-}
-
-int (kbc_issue_cmd)(uint8_t cmd){
-    int ret = 0;
-    uint8_t stat;
-    for(int i = 0; i < KBC_NUM_TRIES; ++i){
-        if((ret = util_sys_inb(STATUS_REG, &stat))) return ret;
-        if((stat&IN_BUF_FULL) == 0){
-            if(sys_outb(KBC_CMD, cmd)) return WRITE_ERROR;
-            return SUCCESS;
-        }
-        tickdelay(micros_to_ticks(DELAY));
-    }
-    return TIMEOUT_ERROR;
-}
-
-int (kbc_issue_arg)(uint8_t arg){
-    int ret = 0;
-    uint8_t stat;
-    for(int i = 0; i < KBC_NUM_TRIES; ++i){
-        if((ret = util_sys_inb(STATUS_REG, &stat))) return ret;
-        if((stat&IN_BUF_FULL) == 0){
-            if(sys_outb(KBC_CMD_ARG, arg)) return WRITE_ERROR;
-            return SUCCESS;
-        }
-        tickdelay(micros_to_ticks(DELAY));
-    }
-    return TIMEOUT_ERROR;
-}
-
-int (kbc_read_byte)(uint8_t *byte){
-    int ret = 0;
-    uint8_t stat;
-    for(int i = 0; i < KBC_NUM_TRIES; ++i){
-        if((ret = util_sys_inb(STATUS_REG, &stat))) return ret;
-        if((stat&OUT_BUF_FUL) && (stat&AUX_MOUSE)==0){
-            if(stat & (PARITY_ERROR | TIME_OUT_REC)) return OTHER_ERROR;
-            if((ret = util_sys_inb(OUTPUT_BUF, byte))) return ret;
-            else return SUCCESS;
-        }
-        tickdelay(micros_to_ticks(DELAY));
-    }
-    printf("Timing out\n");
-    return TIMEOUT_ERROR;
-}

Property changes on: proj/src/kbc.c
___________________________________________________________________
Deleted: svn:executable
## -1 +0,0 ##
-*
\ No newline at end of property
Index: proj/src/uart.c
===================================================================
--- proj/src/uart.c	(revision 277)
+++ proj/src/uart.c	(nonexistent)
@@ -1,377 +0,0 @@
-#include <lcom/lcf.h>
-
-#include "uart.h"
-
-#include "queue.h"
-#include "errors.h"
-
-#define UART_BITRATE                            115200
-#define UART_WAIT                               20 //microseconds
-
-#define UART_RBR                                0
-#define UART_THR                                0
-#define UART_IER                                1
-#define UART_IIR                                2
-#define UART_FCR                                2
-#define UART_LCR                                3
-#define UART_MCR                                4
-#define UART_LSR                                5
-#define UART_MSR                                6
-#define UART_SR                                 7
-
-#define UART_DLL                                0
-#define UART_DLM                                1
-
-/// LCR
-#define UART_BITS_PER_CHAR_POS                  0
-#define UART_STOP_BITS_POS                      2
-#define UART_PARITY_POS                         3
-#define UART_BREAK_CONTROL_POS                  6
-#define UART_DLAB_POS                           7
-
-#define UART_BITS_PER_CHAR                      (BIT(0) | BIT(1))
-#define UART_STOP_BITS                          (BIT(2))
-#define UART_PARITY                             (BIT(3) | BIT(4) | BIT(5))
-#define UART_BREAK_CONTROL                      (BIT(6))
-#define UART_DLAB                               (BIT(7))
-
-#define UART_GET_BITS_PER_CHAR(n)               (((n)&UART_BITS_PER_CHAR) + 5)
-#define UART_GET_STOP_BITS(n)                   (((n)&UART_STOP_BITS)? 2 : 1)
-#define UART_GET_PARITY(n)                      (((n)&UART_PARITY       )>>UART_PARITY_POS       )
-#define UART_GET_BREAK_CONTROL(n)               (((n)&UART_BREAK_CONTROL)>>UART_BREAK_CONTROL_POS)
-#define UART_GET_DLAB(n)                        (((n)&UART_DLAB         )>>UART_DLAB_POS         )
-#define UART_GET_DIV_LATCH(m,l)                 ((m)<<8 | (l))
-#define UART_GET_DLL(n)                         ((n)&0xFF)
-#define UART_GET_DLM(n)                         (((n)>>8)&0xFF)
-
-/// IER
-#define UART_INT_EN_RX_POS                      0
-#define UART_INT_EN_TX_POS                      1
-#define UART_INT_EN_RECEIVER_LINE_STAT_POS      2
-#define UART_INT_EN_MODEM_STAT_POS              3
-
-#define UART_INT_EN_RX                          (BIT(0))
-#define UART_INT_EN_TX                          (BIT(1))
-#define UART_INT_EN_RECEIVER_LINE_STAT          (BIT(2))
-#define UART_INT_EN_MODEM_STAT                  (BIT(3))
-
-#define UART_GET_INT_EN_RX(n)                   (((n)&UART_INT_EN_RX                )>>UART_INT_EN_RX_POS                )
-#define UART_GET_INT_EN_TX(n)                   (((n)&UART_INT_EN_TX                )>>UART_INT_EN_TX_POS                )
-#define UART_GET_INT_EN_RECEIVER_LINE_STAT(n)   (((n)&UART_INT_EN_RECEIVER_LINE_STAT)>>UART_INT_EN_RECEIVER_LINE_STAT_POS)
-#define UART_GET_INT_EN_MODEM_STAT(n)           (((n)&UART_INT_EN_MODEM_STAT        )>>UART_INT_EN_MODEM_STAT_POS        )
-
-/// LSR
-#define UART_RECEIVER_READY_POS                 0
-#define UART_OVERRUN_ERROR_POS                  1
-#define UART_PARITY_ERROR_POS                   2
-#define UART_FRAMING_ERROR_POS                  3
-#define UART_TRANSMITTER_EMPTY_POS              5
-
-#define UART_RECEIVER_READY                     (BIT(0))
-#define UART_OVERRUN_ERROR                      (BIT(1))
-#define UART_PARITY_ERROR                       (BIT(2))
-#define UART_FRAMING_ERROR                      (BIT(3))
-#define UART_TRANSMITTER_EMPTY                  (BIT(5))
-
-#define UART_GET_RECEIVER_READY(n)              (((n)&UART_RECEIVER_READY           )>>UART_RECEIVER_READY_POS           )
-#define UART_GET_OVERRUN_ERROR                  (((n)&UART_OVERRUN_ERROR            )>>UART_OVERRUN_ERROR_POS            )
-#define UART_GET_PARITY_ERROR                   (((n)&UART_PARITY_ERROR             )>>UART_PARITY_ERROR_POS             )
-#define UART_GET_FRAMING_ERROR                  (((n)&UART_FRAMING_ERROR            )>>UART_FRAMING_ERROR_POS            )
-#define UART_GET_TRANSMITTER_EMPTY(n)           (((n)&UART_TRANSMITTER_EMPTY        )>>UART_TRANSMITTER_EMPTY_POS        )
-
-/// IIR
-#define UART_INT_PEND_POS                       1
-
-#define UART_INT_PEND                           (BIT(3)|BIT(2)|BIT(1))
-
-#define UART_GET_IF_INT_PEND(n)                 (!((n)&1))
-typedef enum {
-    uart_int_receiver_line_stat = (         BIT(1) | BIT(0)),
-    uart_int_rx                 = (         BIT(1)         ),
-    uart_int_char_timeout_fifo  = (BIT(2) | BIT(1)         ),
-    uart_int_tx                 = (                  BIT(0)),
-    uart_int_modem_stat         = (0)
-} uart_int_code;
-#define UART_GET_INT_PEND(n)                    ((uart_int_code)(((n)&UART_INT_PEND)>>UART_INT_PEND_POS))
-
-int (subscribe_uart_interrupt)(uint8_t interrupt_bit, int *interrupt_id) {
-    if (interrupt_id == NULL) return 1;
-    *interrupt_id = interrupt_bit;
-    return (sys_irqsetpolicy(COM1_IRQ, IRQ_REENABLE | IRQ_EXCLUSIVE, interrupt_id));
-}
-
-static void uart_parse_config(uart_config *config){
-    /// LCR
-    config->bits_per_char          = UART_GET_BITS_PER_CHAR     (config->lcr);
-    config->stop_bits              = UART_GET_STOP_BITS         (config->lcr);
-    config->parity                 = UART_GET_PARITY            (config->lcr); if((config->parity & BIT(0)) == 0) config->parity = uart_parity_none;
-    config->break_control          = UART_GET_BREAK_CONTROL     (config->lcr);
-    config->dlab                   = UART_GET_DLAB              (config->lcr);
-    /// IER
-    config->received_data_int      = UART_GET_INT_EN_RX                (config->ier);
-    config->transmitter_empty_int  = UART_GET_INT_EN_TX                (config->ier);
-    config->receiver_line_stat_int = UART_GET_INT_EN_RECEIVER_LINE_STAT(config->ier);
-    config->modem_stat_int         = UART_GET_INT_EN_MODEM_STAT        (config->ier);
-    /// DIV LATCH
-    config->divisor_latch          = UART_GET_DIV_LATCH(config->dlm, config->dll);
-}
-
-static int uart_get_lcr(int base_addr, uint8_t *p){
-    return util_sys_inb(base_addr+UART_LCR, p);
-}
-static int uart_set_lcr(int base_addr, uint8_t config){
-    if(sys_outb(base_addr+UART_LCR, config)) return WRITE_ERROR;
-    return SUCCESS;
-}
-static int uart_get_lsr(int base_addr, uint8_t *p){
-    return util_sys_inb(base_addr+UART_LSR, p);
-}
-static int uart_get_iir(int base_addr, uint8_t *p){
-    return util_sys_inb(base_addr+UART_IIR, p);
-}
-
-static int uart_enable_divisor_latch(int base_addr){
-    int ret = SUCCESS;
-    uint8_t conf; if((ret = uart_get_lcr(base_addr, &conf))) return ret;
-    return uart_set_lcr(base_addr, conf | UART_DLAB);
-}
-static int uart_disable_divisor_latch(int base_addr){
-    int ret = SUCCESS;
-    uint8_t conf; if((ret = uart_get_lcr(base_addr, &conf))) return ret;
-    return uart_set_lcr(base_addr, conf & (~UART_DLAB));
-}
-
-static int uart_get_ier(int base_addr, uint8_t *p){
-    int ret;
-    if((ret = uart_disable_divisor_latch(base_addr))) return ret;
-    return util_sys_inb(base_addr+UART_IER, p);
-}
-static int uart_set_ier(int base_addr, uint8_t n){
-    int ret;
-    if((ret = uart_disable_divisor_latch(base_addr))) return ret;
-    if(sys_outb(base_addr+UART_IER, n)) return WRITE_ERROR;
-    return SUCCESS;
-}
-
-int uart_get_config(int base_addr, uart_config *config){
-    int ret = SUCCESS;
-
-    config->base_addr = base_addr;
-
-    if((ret = uart_get_lcr(base_addr, &config->lcr))) return ret;
-
-    if((ret = uart_get_ier(base_addr, &config->ier))) return ret;
-
-    if((ret = uart_enable_divisor_latch (base_addr))) return ret;
-    if((ret = util_sys_inb(base_addr+UART_DLL, &config->dll   ))) return ret;
-    if((ret = util_sys_inb(base_addr+UART_DLM, &config->dlm   ))) return ret;
-    if((ret = uart_disable_divisor_latch(base_addr))) return ret;
-
-    uart_parse_config(config);
-    return ret;
-}
-void uart_print_config(uart_config config){
-
-    printf("%s configuration:\n", (config.base_addr == COM1_ADDR ? "COM1" : "COM2"));
-    printf("\tLCR = 0x%X: %d bits per char\t %d stop bits\t", config.lcr, config.bits_per_char, config.stop_bits);
-    if((config.parity&BIT(0)) == 0) printf("NO parity\n");
-    else switch(config.parity){
-        case uart_parity_odd : printf("ODD parity\n"     ); break;
-        case uart_parity_even: printf("EVEN parity\n"    ); break;
-        case uart_parity_par1: printf("parity bit is 1\n"); break;
-        case uart_parity_par0: printf("parity bit is 0\n"); break;
-        default              : printf("invalid\n"        ); break;
-    }
-    printf("\tDLM = 0x%02X DLL=0x%02X: bitrate = %d bps\n", config.dlm, config.dll, UART_BITRATE/config.divisor_latch);
-    printf("\tIER = 0x%02X: Rx interrupts: %s\tTx interrupts: %s\n", config.ier,
-        (config.received_data_int     ? "ENABLED":"DISABLED"),
-        (config.transmitter_empty_int ? "ENABLED":"DISABLED"));
-}
-
-int uart_set_bits_per_character(int base_addr, uint8_t bits_per_char){
-    if(bits_per_char < 5 || bits_per_char > 8) return INVALID_ARG;
-    int ret = SUCCESS;
-    bits_per_char = (bits_per_char-5)&0x3;
-    uint8_t conf; if((ret = uart_get_lcr(base_addr, &conf))) return ret;
-    conf = (conf & (~UART_BITS_PER_CHAR)) | bits_per_char;
-    return uart_set_lcr(base_addr, conf);
-}
-int uart_set_stop_bits(int base_addr, uint8_t stop){
-    if(stop != 1 && stop != 2) return INVALID_ARG;
-    int ret = SUCCESS;
-    stop -= 1;
-    stop = (stop&1)<<2;
-    uint8_t conf; if((ret = uart_get_lcr(base_addr, &conf))) return ret;
-    conf = (conf & (~UART_STOP_BITS)) | stop;
-    return uart_set_lcr(base_addr, conf);
-}
-int uart_set_parity(int base_addr, uart_parity par){
-    int ret = SUCCESS;
-    uint8_t parity = par << 3;
-    uint8_t conf; if((ret = uart_get_lcr(base_addr, &conf))) return ret;
-    conf = (conf & (~UART_PARITY)) | parity;
-    return uart_set_lcr(base_addr, conf);
-}
-int uart_set_bit_rate(int base_addr, float bit_rate){
-    int ret = SUCCESS;
-    uint16_t latch = UART_BITRATE/bit_rate;
-    uint8_t dll = UART_GET_DLL(latch);
-    uint8_t dlm = UART_GET_DLM(latch);
-    if((ret = uart_enable_divisor_latch(base_addr))) return ret;
-    if(sys_outb(base_addr+UART_DLL, dll)) return WRITE_ERROR;
-    if(sys_outb(base_addr+UART_DLM, dlm)) return WRITE_ERROR;
-    if((ret = uart_disable_divisor_latch(base_addr))) return ret;
-    return SUCCESS;
-}
-
-static int uart_get_char(int base_addr, uint8_t *p){
-    int ret;
-    if((ret = uart_disable_divisor_latch(base_addr))) return ret;
-    return util_sys_inb(base_addr+UART_RBR, p);
-}
-static int uart_send_char(int base_addr, uint8_t c){
-    int ret;
-    if((ret = uart_disable_divisor_latch(base_addr))) return ret;
-    if(sys_outb(base_addr+UART_THR, c)) return WRITE_ERROR;
-    return SUCCESS;
-}
-static int uart_receiver_ready(int base_addr){
-    uint8_t lsr;
-    if(uart_get_lsr(base_addr, &lsr)) return false;
-    return UART_GET_RECEIVER_READY(lsr);
-}
-static int uart_transmitter_empty(int base_addr){
-    uint8_t lsr;
-    if(uart_get_lsr(base_addr, &lsr)) return false;
-    return UART_GET_TRANSMITTER_EMPTY(lsr);
-}
-
-int uart_enable_int_rx(int base_addr){
-    int ret;
-    uint8_t ier;
-    if((ret = uart_get_ier(base_addr, &ier))) return ret;
-    ier |= UART_INT_EN_RX;
-    return uart_set_ier(base_addr, ier);
-}
-int uart_disable_int_rx(int base_addr){
-    int ret;
-    uint8_t ier;
-    if((ret = uart_get_ier(base_addr, &ier))) return ret;
-    ier &= ~UART_INT_EN_RX;
-    return uart_set_ier(base_addr, ier);
-}
-int uart_enable_int_tx(int base_addr){
-    int ret;
-    uint8_t ier;
-    if((ret = uart_get_ier(base_addr, &ier))) return ret;
-    ier |= UART_INT_EN_TX;
-    return uart_set_ier(base_addr, ier);
-}
-int uart_disable_int_tx(int base_addr){
-    int ret;
-    uint8_t ier;
-    if((ret = uart_get_ier(base_addr, &ier))) return ret;
-    ier &= ~UART_INT_EN_TX;
-    return uart_set_ier(base_addr, ier);
-}
-
-#include "nctp.h"
-
-#define NCTP_START      0x80
-#define NCTP_END        0xFF
-#define NCTP_OK         0xFF
-#define NCTP_NOK        0x00
-
-queue_t *out = NULL;
-queue_t *in  = NULL;
-
-int nctp_init(void){
-    out = queue_ctor(); if(out == NULL) return NULL_PTR;
-    in  = queue_ctor(); if(in  == NULL) return NULL_PTR;
-    return SUCCESS;
-}
-int nctp_free(void){
-    while(!queue_empty(out)){
-        free(queue_top(out));
-        queue_pop(out);
-    }
-    while(!queue_empty(in)){
-        free(queue_top(in));
-        queue_pop(in);
-    }
-    return SUCCESS;
-}
-
-int nctp_send(size_t num, uint8_t* ptr[], size_t sz[]){
-    {
-        size_t cnt = 0;
-        for(size_t i = 0; i < num; ++i){
-            cnt += sz[i];
-            if(cnt > queue_max_size) return TRANS_REFUSED;
-        }
-    }
-    int ret;
-    uint8_t *tmp;
-    tmp = malloc(sizeof(uint8_t)); *tmp = NCTP_START; queue_push(out, tmp);
-    for(size_t i = 0; i < num; ++i){
-        uint8_t *p = ptr[i]; size_t s = sz[i];
-        for(size_t j = 0; j < s; ++j, ++p){
-            tmp = malloc(sizeof(uint8_t)); *tmp = *p; queue_push(out, tmp);
-        }
-    }
-    tmp = malloc(sizeof(uint8_t)); *tmp = NCTP_END; queue_push(out, tmp);
-    if(uart_transmitter_empty(COM1_ADDR)){
-        if((ret = uart_send_char(COM1_ADDR, *(uint8_t*)queue_top(out)))) return ret;
-        queue_pop(out);
-    }
-    return SUCCESS;
-}
-
-static int nctp_transmit(void){
-    if(!queue_empty(out)){
-        int ret = uart_send_char(COM1_ADDR, *(uint8_t*)queue_top(out));
-        queue_pop(out);
-        return ret;
-    }else return SUCCESS;
-}
-static void process(){
-    free(queue_top(in)); queue_pop(in);
-    while(*(uint8_t*)queue_top(in) != NCTP_END){
-        printf("%c", *(uint8_t*)queue_top(in));
-        free(queue_top(in)); queue_pop(in);
-    }
-    free(queue_top(in)); queue_pop(in);
-}
-static int nctp_receive(void){
-    int ret;
-    uint8_t c;
-    int num_ends = 0;
-    while(uart_receiver_ready(COM1_ADDR)){
-        if((ret = uart_get_char(COM1_ADDR, &c))) return ret;
-        uint8_t *tmp = malloc(sizeof(uint8_t)); *tmp = c;
-        queue_push(in, tmp);
-        if(c == NCTP_END) ++num_ends;
-    }
-    while(num_ends-- > 0) process();
-    return SUCCESS;
-}
-
-int nctp_ih_err = SUCCESS;
-void nctp_ih(void){
-    uint8_t iir;
-    if((nctp_ih_err = uart_get_iir(COM1_ADDR, &iir))) return;
-    if(UART_GET_IF_INT_PEND(iir)){
-        switch(UART_GET_INT_PEND(iir)){
-            case uart_int_rx: nctp_receive (); break;
-            case uart_int_tx: nctp_transmit(); break;
-            default: break;
-        }
-    }
-}
-
-/// HLTP
-int hltp_send_string(const char *p){
-    uint8_t* ptr[1]; ptr[0] = (uint8_t*)p;
-    size_t    sz[1]; sz[0] = strlen(p)+1;
-    return nctp_send(1, ptr, sz);
-}

Property changes on: proj/src/uart.c
___________________________________________________________________
Deleted: svn:executable
## -1 +0,0 ##
-*
\ No newline at end of property
Index: proj/libs/classes/include/list.h
===================================================================
--- proj/libs/classes/include/list.h	(nonexistent)
+++ proj/libs/classes/include/list.h	(revision 278)
@@ -0,0 +1,28 @@
+#ifndef LIST_H_INCLUDED
+#define LIST_H_INCLUDED
+
+struct list_node;
+typedef struct list_node list_node_t;
+
+list_node_t* (list_node_ctor)(list_node_t *p, list_node_t *n, void *val);
+void         (list_node_dtor)(list_node_t *p);
+list_node_t* (list_node_next)(const list_node_t *p);
+list_node_t* (list_node_prev)(const list_node_t *p);
+void**       (list_node_val )(list_node_t *p);
+
+struct list;
+typedef struct list list_t;
+
+list_t* (list_ctor)(void);
+int     (list_dtor)(list_t *l);
+list_node_t* (list_begin )(list_t *l);
+list_node_t* (list_end   )(list_t *l);
+size_t       (list_size  )(const list_t *l);
+int          (list_empty )(const list_t *l);
+list_node_t* (list_insert)(list_t *l, list_node_t *position, void *val);
+void*        (list_erase )(list_t *l, list_node_t *position);
+void         (list_push_back)(list_t *l, void *val);
+void**       (list_front)(list_t *l);
+void         (list_pop_front)(list_t *l);
+
+#endif //LIST_H_INCLUDED

Property changes on: proj/libs/classes/include/list.h
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: proj/libs/classes/include/queue.h
===================================================================
--- proj/libs/classes/include/queue.h	(nonexistent)
+++ proj/libs/classes/include/queue.h	(revision 278)
@@ -0,0 +1,17 @@
+#ifndef QUEUE_H_INCLUDED
+#define QUEUE_H_INCLUDED
+
+struct queue;
+typedef struct queue queue_t;
+
+const size_t queue_max_size;
+
+queue_t* (queue_ctor )(void);
+int      (queue_dtor )(queue_t *q);
+size_t   (queue_size )(const queue_t *q);
+int      (queue_empty)(const queue_t *q);
+void     (queue_push )(queue_t *q, void *val);
+void*    (queue_top  )(const queue_t *q);
+void     (queue_pop  )(queue_t *q);
+
+#endif //QUEUE_H_INCLUDED

Property changes on: proj/libs/classes/include/queue.h
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: proj/libs/classes/src/list.c
===================================================================
--- proj/libs/classes/src/list.c	(nonexistent)
+++ proj/libs/classes/src/list.c	(revision 278)
@@ -0,0 +1,79 @@
+#include <lcom/lcf.h>
+
+#include "list.h"
+
+struct list_node{
+    list_node_t *p, *n;
+    void *val;
+};
+list_node_t* (list_node_ctor)(list_node_t *p, list_node_t *n, void *val){
+    list_node_t *ret = malloc(sizeof(list_node_t));
+    if(ret == NULL) return NULL;
+    ret->p = p;
+    ret->n = n;
+    ret->val = val;
+    return ret;
+}
+void (list_node_dtor)(list_node_t *p){
+    free(p);
+}
+list_node_t* (list_node_next)(const list_node_t *p){ return p->n; }
+list_node_t* (list_node_prev)(const list_node_t *p){ return p->p; }
+void**       (list_node_val )(list_node_t *p){ return &p->val; }
+
+struct list{
+    list_node_t *begin_;
+    list_node_t *end_;
+    size_t sz;
+};
+list_t* (list_ctor)(void){
+    list_t *ret = malloc(sizeof(list_t));
+    if(ret == NULL) return NULL;
+    ret->sz = 0;
+    ret->begin_ = NULL; ret->end_ = NULL;
+    ret->begin_ = list_node_ctor(NULL, NULL, NULL);
+    ret->end_   = list_node_ctor(NULL, NULL, NULL);
+    if(ret->begin_ == NULL || ret->end_ == NULL){
+        list_dtor(ret);
+        return NULL;
+    }
+    ret->begin_->n = ret->end_  ;
+    ret->end_  ->p = ret->begin_;
+    return ret;
+}
+int (list_dtor)(list_t *l){
+    if(l == NULL) return 0;
+    if(list_size(l) > 0) return 1;
+    list_node_dtor(l->begin_);
+    list_node_dtor(l->end_);
+    free(l);
+    return 0;
+}
+list_node_t* (list_begin )(      list_t *l){ return l->begin_->n; }
+list_node_t* (list_end   )(      list_t *l){ return l->end_; }
+size_t       (list_size  )(const list_t *l){ return l->sz; }
+int          (list_empty )(const list_t *l){ return !(l->sz); }
+list_node_t* (list_insert)(list_t *l, list_node_t *position, void *val){
+    list_node_t *node = list_node_ctor(position->p, position, val);
+    position->p->n = node;
+    position->p    = node;
+    ++l->sz;
+    return node;
+}
+void*        (list_erase )(list_t *l, list_node_t *position){
+    position->p->n = position->n;
+    position->n->p = position->p;
+    void *ret = position->val;
+    list_node_dtor(position);
+    --l->sz;
+    return ret;
+}
+void         (list_push_back)(list_t *l, void *val){
+    list_insert(l, list_end(l), val);
+}
+void**       (list_front)(list_t *l){
+    return list_node_val(list_begin(l));
+}
+void         (list_pop_front)(list_t *l){
+    list_erase(l, list_begin(l));
+}

Property changes on: proj/libs/classes/src/list.c
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: proj/libs/classes/src/queue.c
===================================================================
--- proj/libs/classes/src/queue.c	(nonexistent)
+++ proj/libs/classes/src/queue.c	(revision 278)
@@ -0,0 +1,34 @@
+#include <lcom/lcf.h>
+
+#include "queue.h"
+
+#include "list.h"
+#include "errors.h"
+
+const size_t queue_max_size = UINT_MAX;
+
+struct queue{
+    list_t *l;
+};
+
+queue_t* (queue_ctor )(void){
+    queue_t *ret = malloc(sizeof(queue_t));
+    if(ret == NULL) return NULL;
+    ret->l = list_ctor();
+    if(ret->l == NULL){
+        queue_dtor(ret);
+        return NULL;
+    }
+    return ret;
+}
+int      (queue_dtor )(queue_t *q){
+    int r;
+    if((r = list_dtor(q->l))) return r;
+    free(q);
+    return SUCCESS;
+}
+size_t   (queue_size )(const queue_t *q           ){ return list_size (q->l); }
+int      (queue_empty)(const queue_t *q           ){ return list_empty(q->l); }
+void     (queue_push )(      queue_t *q, void *val){ list_push_back(q->l, val); }
+void*    (queue_top  )(const queue_t *q           ){ return *list_front(q->l); }
+void     (queue_pop  )(      queue_t *q           ){ list_pop_front(q->l); }

Property changes on: proj/libs/classes/src/queue.c
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: proj/libs/peripherals/include/kbc.h
===================================================================
--- proj/libs/peripherals/include/kbc.h	(nonexistent)
+++ proj/libs/peripherals/include/kbc.h	(revision 278)
@@ -0,0 +1,107 @@
+/**
+ * This file concerns everything related to the KBC (KeyBoard Controller, which
+ * actually also manages the mouse)
+ */
+
+#ifndef KBC_H_INCLUDED
+#define KBC_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 */
+
+/**
+ * @brief High-level function that reads the command byte of the KBC
+ * @param cmd Pointer to variable where command byte read from KBC will be stored
+ * @return 0 if operation was successful, 1 otherwise
+ */
+int (kbc_read_cmd)(uint8_t *cmd);
+
+/**
+ * @brief High-level function that changes the command byte of the KBC
+ * @param cmd New value for command byte of KBC
+ * @return 0 if operation was successful, 1 otherwise
+ */
+int (kbc_change_cmd)(uint8_t cmd);
+
+/**
+ * @brief High-level function that restores KBC to normal state
+ * High-level function that restores KBC to normal state, because lcf_start
+ * changes the command byte of KBC. If this function is not used, there is a
+ * chance that the keyboard and keyboard interrupts remain disabled.
+ * @return 0 if operation was successful, 1 otherwise
+ */
+int (kbc_restore_keyboard)();
+
+/**
+ * @brief Low-level function to issue a command to keyboard
+ * @param cmd command to be issued
+ * @return 0 if operation was successful, 1 otherwise
+ */
+int (kbc_issue_cmd)(uint8_t cmd);
+
+/**
+ * @brief Low-level function to issue an argument of a command
+ * @param cmd argument to be issued
+ * @return 0 if operation was successful, 1 otherwise
+ */
+int (kbc_issue_arg)(uint8_t arg);
+
+/**
+ * @brief Low-level function for reading byte from keyboard
+ * Low-level function for reading byte from keyboard. Waits until output buffer
+ * is full
+ * @param value Pointer to variable where byte read from keyboard will be stored
+ * @return 0 if operation was successful, 1 otherwise
+ */
+int (kbc_read_byte)(uint8_t *byte);
+
+#endif //KBC_H_INCLUDED

Property changes on: proj/libs/peripherals/include/kbc.h
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: proj/libs/peripherals/include/keyboard.h
===================================================================
--- proj/libs/peripherals/include/keyboard.h	(nonexistent)
+++ proj/libs/peripherals/include/keyboard.h	(revision 278)
@@ -0,0 +1,28 @@
+/**
+ * This file concerns everything related to the keyboard
+ */
+
+#ifndef KEYBOARD_H_INCLUDED
+#define KEYBOARD_H_INCLUDED
+
+#include "kbc.h"
+
+/**
+ * @brief Subscribes Keyboard Interrupts and disables Minix Default IH
+ * @param interrupt_bit Bit of Interrupt Vector that will be set when Keyboard Interrupt is pending
+ * @param interrupt_id Keyboard Interrupt ID to specify the Keyboard Interrupt in other calls
+ * @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
+ * @see {_ERRORS_H_::errors}
+ */
+int (subscribe_kbc_interrupt)(uint8_t interrupt_bit, int *interrupt_id);
+
+uint8_t scancode[2];
+int done;
+int sz;
+int got_error_keyboard;
+
+void (kbc_ih)(void);
+
+int (keyboard_poll)(uint8_t bytes[], uint8_t *size);
+
+#endif //KEYBOARD_H_INCLUDED

Property changes on: proj/libs/peripherals/include/keyboard.h
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: proj/libs/peripherals/include/mouse.h
===================================================================
--- proj/libs/peripherals/include/mouse.h	(nonexistent)
+++ proj/libs/peripherals/include/mouse.h	(revision 278)
@@ -0,0 +1,89 @@
+#ifndef MOUSE_H_INCLUDED
+#define MOUSE_H_INCLUDED
+
+/**
+ * @brief Subscribes Mouse Interrupts and disables Minix Default IH
+ * @param interrupt_bit Bit of Interrupt Vector that will be set when Mouse Interrupt is pending
+ * @param interrupt_id Mouse Interrupt ID to specify the Mouse Interrupt in other calls
+ * @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
+ * @see {_ERRORS_H_::errors}
+ */
+int (subscribe_mouse_interrupt)(uint8_t interrupt_bit, int *interrupt_id);
+
+//These have to do with mouse_ih
+int got_error_mouse_ih;
+uint8_t packet_mouse_ih[3];
+int counter_mouse_ih;
+
+/**
+ * @brief   Parse 3 bytes and returns it as a parsed, struct packet.
+ * @param   packet_bytes    array of bytes to parse
+ * @param   pp              Pointer to packet to store the information.
+ */
+void (mouse_parse_packet)(const uint8_t *packet_bytes, struct packet *pp);
+
+/**
+ * @brief Polls mouse for data. Blocks execution until a valid mouse packet is obtained.
+ * @param   pp      pointer to packet struct in which the result will be stored
+ * @param   period  time (in milliseconds) the poller should wait between pollings of bytes
+ * @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
+ */
+int mouse_poll(struct packet *pp, uint16_t period);
+
+/**
+ * @brief Sets data report mode for mouse
+ * @param   on  zero to disable data report, any other value to enable data report
+ * @return  ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
+ */
+int (mouse_set_data_report)(int on);
+
+/**
+ * @brief Reads data byte from mouse
+ * <summary>
+ * Polls the mouse till data is available for reading
+ * </summary>
+ * @param data Pointer to variable where byte read from mouse will be stored
+ * @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
+ * @see {_ERRORS_H_::errors}
+ */
+int (mouse_read_data)(uint8_t *data, uint16_t period);
+
+/**
+ * @brief Issues command to mouse
+ * <summary>
+ * Issues command to mouse, returns error after two consecutive errors reported by the acknowledgment byte
+ * </summary>
+ * @param cmd Command to be issued
+ * @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
+ * @see {_ERRORS_H_::errors}
+ */
+int (mouse_issue_cmd)(uint32_t cmd);
+
+/**
+ * @brief Reads byte from mouse
+ * <summary>
+ * Reads byte from mouse, giving error if exceeds number of tries to read
+ * </summary>
+ * @param byte Pointer to variable where byte read from mouse will be stored
+ * @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
+ * @see {_ERRORS_H_::errors}
+ */
+int (mouse_read_byte)(uint8_t *byte);
+
+/**
+ * @brief Polls OUT_BUF for byte coming from mouse.
+ * @param   byte    pointer to byte read from OUT_BUF
+ * @param   period  time (in milliseconds) the poller should wait between pollings of bytes
+ * @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
+ */
+int (mouse_poll_byte)(uint8_t *byte, uint16_t period);
+
+/**
+ * @brief Converts 9-bit number to 16-bit with sign extension
+ * @param sign_bit  Sign bit identifiying the signal of the number
+ * @param byte      Least significant byte that will be extended
+ * @return Extended 9-bit number
+ */
+int16_t (sign_extend_byte)(uint8_t sign_bit, uint8_t byte);
+
+#endif //MOUSE_H_INCLUDED

Property changes on: proj/libs/peripherals/include/mouse.h
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: proj/libs/peripherals/include/rtc.h
===================================================================
--- proj/libs/peripherals/include/rtc.h	(nonexistent)
+++ proj/libs/peripherals/include/rtc.h	(revision 278)
@@ -0,0 +1,46 @@
+#ifndef RTC_H_INCLUDED
+#define RTC_H_INCLUDED
+
+#include <stdint.h>
+
+/**
+ * @brief Subscribes RTC Interrupts
+ * @param interrupt_bit Bit of Interrupt Vector that will be set when RTC Interrupt is pending
+ * @param interrupt_id RTC Interrupt ID to specify the RTC Interrupt in other calls
+ * @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
+ * @see {_ERRORS_H_::errors}
+ */
+int (subscribe_rtc_interrupt)(uint8_t interrupt_bit, int *interrupt_id);
+
+int (rtc_read_register)(uint32_t reg, uint8_t *data);
+
+int (rtc_write_register)(uint32_t reg, uint8_t data);
+
+/**
+ * @brief Checks if there's an update in progress.
+ * @return  The value of the flag UIP, or ERROR_CODE if error occurs.
+ */
+int (rtc_check_update)(void);
+
+/**
+ * @brief Enables/Disables updates of time/date registers.
+ * @param   on  zero to disable, any other value to enable
+ * @return  ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
+ */
+int (rtc_set_updates)(int on);
+
+/**
+ * @brief Reads time from RTC.
+ * @param   time  Pointer to array of 3 bytes to store the information about time (hours, minutes, seconds)
+ * @return  ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
+ */
+int (rtc_read_time)(uint8_t *time);
+
+/**
+ * @brief Reads date from RTC.
+ * @param   date  Pointer to array of 4 bytes to store the information about date (year, month, day, weekday)
+ * @return  ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
+ */
+int (rtc_read_date)(uint8_t *date);
+
+#endif /* end of include guard: RTC_H_INCLUDED */

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

Property changes on: proj/libs/peripherals/include/timer.h
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: proj/libs/peripherals/include/uart.h
===================================================================
--- proj/libs/peripherals/include/uart.h	(nonexistent)
+++ proj/libs/peripherals/include/uart.h	(revision 278)
@@ -0,0 +1,52 @@
+#ifndef UART_H_INCLUDED
+#define UART_H_INCLUDED
+
+#define COM1_ADDR           0x3F8
+#define COM2_ADDR           0x2F8
+#define COM1_IRQ            4
+#define COM2_IRQ            3
+#define COM1_VECTOR         0x0C
+#define COM2_VECTOR         0x0B
+
+typedef enum {
+    uart_parity_none = 0x0,
+    uart_parity_odd  = 0x1,
+    uart_parity_even = 0x3,
+    uart_parity_par1 = 0x5,
+    uart_parity_par0 = 0x7
+} uart_parity;
+
+typedef struct {
+    int     base_addr               ;
+    uint8_t lcr                     ;
+    uint8_t dll                     ;
+    uint8_t dlm                     ;
+    uint8_t bits_per_char           ;
+    uint8_t stop_bits               ;
+    uart_parity parity              ;
+    uint8_t break_control         :1;
+    uint8_t dlab                  :1;
+    uint16_t divisor_latch          ;
+    uint8_t ier                     ;
+    uint8_t received_data_int     :1;
+    uint8_t transmitter_empty_int :1;
+    uint8_t receiver_line_stat_int:1;
+    uint8_t modem_stat_int        :1;
+} uart_config;
+
+int (subscribe_uart_interrupt)(uint8_t interrupt_bit, int *interrupt_id);
+
+int uart_get_config(int base_addr, uart_config *config);
+void uart_print_config(uart_config config);
+
+int uart_set_bits_per_character(int base_addr, uint8_t     bits_per_char);
+int uart_set_stop_bits         (int base_addr, uint8_t     stop         );
+int uart_set_parity            (int base_addr, uart_parity par          );
+int uart_set_bit_rate          (int base_addr, float       bit_rate     );
+
+int uart_enable_int_rx (int base_addr);
+int uart_disable_int_rx(int base_addr);
+int uart_enable_int_tx (int base_addr);
+int uart_disable_int_tx(int base_addr);
+
+#endif //UART_H_INCLUDED

Property changes on: proj/libs/peripherals/include/uart.h
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: proj/libs/peripherals/src/kbc.c
===================================================================
--- proj/libs/peripherals/src/kbc.c	(nonexistent)
+++ proj/libs/peripherals/src/kbc.c	(revision 278)
@@ -0,0 +1,73 @@
+#include <lcom/lcf.h>
+
+#include "kbc.h"
+
+#include "utils.h"
+#include "errors.h"
+
+int (kbc_read_cmd)(uint8_t *cmd){
+    int ret = 0;
+    if((ret = kbc_issue_cmd(READ_KBC_CMD))) return ret;
+    if((ret = kbc_read_byte(cmd))) return ret;
+    return SUCCESS;
+}
+
+int (kbc_change_cmd)(uint8_t cmd){
+    int ret = 0;
+    if((ret = kbc_issue_cmd(WRITE_KBC_CMD))) return ret;
+    if((ret = kbc_issue_arg(cmd))) return ret;
+    return SUCCESS;
+}
+
+int (kbc_restore_kbd)(){
+    int ret = 0;
+    uint8_t cmd = 0;
+    if((ret = kbc_read_cmd(&cmd))) return ret;
+    cmd = (cmd | INT_KBD) & (~DIS_KBD);
+    if((ret = kbc_change_cmd(cmd))) return ret;
+    return SUCCESS;
+}
+
+int (kbc_issue_cmd)(uint8_t cmd){
+    int ret = 0;
+    uint8_t stat;
+    for(int i = 0; i < KBC_NUM_TRIES; ++i){
+        if((ret = util_sys_inb(STATUS_REG, &stat))) return ret;
+        if((stat&IN_BUF_FULL) == 0){
+            if(sys_outb(KBC_CMD, cmd)) return WRITE_ERROR;
+            return SUCCESS;
+        }
+        tickdelay(micros_to_ticks(DELAY));
+    }
+    return TIMEOUT_ERROR;
+}
+
+int (kbc_issue_arg)(uint8_t arg){
+    int ret = 0;
+    uint8_t stat;
+    for(int i = 0; i < KBC_NUM_TRIES; ++i){
+        if((ret = util_sys_inb(STATUS_REG, &stat))) return ret;
+        if((stat&IN_BUF_FULL) == 0){
+            if(sys_outb(KBC_CMD_ARG, arg)) return WRITE_ERROR;
+            return SUCCESS;
+        }
+        tickdelay(micros_to_ticks(DELAY));
+    }
+    return TIMEOUT_ERROR;
+}
+
+int (kbc_read_byte)(uint8_t *byte){
+    int ret = 0;
+    uint8_t stat;
+    for(int i = 0; i < KBC_NUM_TRIES; ++i){
+        if((ret = util_sys_inb(STATUS_REG, &stat))) return ret;
+        if((stat&OUT_BUF_FUL) && (stat&AUX_MOUSE)==0){
+            if(stat & (PARITY_ERROR | TIME_OUT_REC)) return OTHER_ERROR;
+            if((ret = util_sys_inb(OUTPUT_BUF, byte))) return ret;
+            else return SUCCESS;
+        }
+        tickdelay(micros_to_ticks(DELAY));
+    }
+    printf("Timing out\n");
+    return TIMEOUT_ERROR;
+}

Property changes on: proj/libs/peripherals/src/kbc.c
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: proj/libs/peripherals/src/keyboard.c
===================================================================
--- proj/libs/peripherals/src/keyboard.c	(nonexistent)
+++ proj/libs/peripherals/src/keyboard.c	(revision 278)
@@ -0,0 +1,60 @@
+#include <lcom/lcf.h>
+
+#include "keyboard.h"
+
+#include "kbc.h"
+#include "utils.h"
+#include "errors.h"
+#include "proj_func.h"
+
+int (subscribe_kbc_interrupt)(uint8_t interrupt_bit, int *interrupt_id) {
+    if (interrupt_id == NULL) return NULL_PTR;
+    *interrupt_id = interrupt_bit;
+    if(sys_irqsetpolicy(KBC_IRQ, IRQ_REENABLE | IRQ_EXCLUSIVE, interrupt_id)) return SBCR_ERROR;
+    return SUCCESS;
+}
+
+int done = 1;
+int sz = 1;
+int got_error_keyboard = SUCCESS;
+
+void (kbc_ih)(void) {
+    if(done) { sz = 1; }
+    else     sz++;
+    uint8_t status = 0;
+    got_error_keyboard = SUCCESS;
+    if ((got_error_keyboard = util_sys_inb(STATUS_REG, &status))) return;
+    if (status & (TIME_OUT_REC | PARITY_ERROR)) {
+        got_error_keyboard = 1;
+        return;
+    }
+    if ((status & OUT_BUF_FUL) == 0 || (status & AUX_MOUSE) != 0) {
+        got_error_keyboard = READ_ERROR;
+        return;
+    }
+    uint8_t byte = 0;
+    if ((got_error_keyboard = util_sys_inb(OUTPUT_BUF, &byte))) return;
+
+    scancode[sz-1] = byte;
+    done = !(TWO_BYTE_CODE == byte);
+
+    if (done) update_key_presses();
+
+}
+
+int (keyboard_poll)(uint8_t bytes[], uint8_t *size){
+    int ret = 0;
+    if(bytes == NULL || size == NULL) return NULL_PTR;
+    uint8_t c;
+    if((ret = kbc_read_byte(&c))) return ret;
+    if(c == TWO_BYTE_CODE){
+        if((ret = kbc_read_byte(&bytes[1]))) return ret;
+        bytes[0] = c;
+        *size = 2;
+    }else{
+        bytes[1] = 0;
+        bytes[0] = c;
+        *size = 1;
+    }
+    return SUCCESS;
+}

Property changes on: proj/libs/peripherals/src/keyboard.c
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: proj/libs/peripherals/src/mouse.c
===================================================================
--- proj/libs/peripherals/src/mouse.c	(nonexistent)
+++ proj/libs/peripherals/src/mouse.c	(revision 278)
@@ -0,0 +1,162 @@
+#include <lcom/lcf.h>
+
+#include "mouse.h"
+
+#include "errors.h"
+#include "kbc.h"
+
+/* Mouse Data Packet */
+// Byte 0 - Button States
+#define LEFT_BUTTON     BIT(0) /* @brief Left button click event*/
+#define RIGHT_BUTTON    BIT(1) /* @brief Right button click event */
+#define MIDDLE_BUTTON   BIT(2) /* @brief Middle button click event */
+#define FIRST_BYTE_ID   BIT(3) /* @brief Identifier of first byte of packet CAREFUL: Not 100% accurate */
+#define MSB_X_DELTA     BIT(4) /* @brief Most significant bit of X delta */
+#define MSB_Y_DELTA     BIT(5) /* @brief Most significant bit of Y delta */
+#define X_OVERFLOW      BIT(6) /* @brief X delta overflowed */
+#define Y_OVERFLOW      BIT(7) /* @brief Y delta overflowed */
+// Byte 1 - X delta
+// Byte 2 - Y delta
+
+/* Mouse Commands */
+#define RESET           0xFF /* @brief Reset mouse */
+#define RESEND          0xFE /* @brief Resend command */
+#define DEFAULT         0xF6 /* @brief Set default values */
+#define DIS_DATA_REP    0xF5 /* @brief Disable Data Reporting */
+#define ENABLE_DATA_REP 0xF4 /* @brief Enable Data Reporting */
+#define SET_SAMPLE_RT   0xF3 /* @brief Sets state sampling rate */
+#define SET_REMOTE_MD   0xF0 /* @brief Sets Mouse on Remote Mode, data on request */
+#define READ_DATA       0xEB /* @brief Sends data packet request */
+#define SET_STREAM_MD   0xEA /* @brief Sets mouse on Stream Mode, data on events */
+#define STATUS_REQUEST  0xE9 /* @brief Get mouse configuration */
+#define SET_RESOLUTION  0xE8 /* @brief Sets resolution for mouse movement */
+#define SCALING_ACC_MD  0xE7 /* @brief Sets scaling on acceleration mode */
+#define SCALING_LIN_MD  0xE6 /* @brief Sets scaling on linear mode */
+
+/* Mouse Controller Responses */
+#define ACK_OK      0xFA /* @brief Operation sucessful */
+#define ACK_INVALID 0xFE /* @brief Invalid Byte, first occurence */
+#define ACK_ERROR   0xFC /* @brief Invalid Byte on resend */
+
+int (subscribe_mouse_interrupt)(uint8_t interrupt_bit, int *interrupt_id) {
+    if (interrupt_id == NULL) return NULL_PTR;
+    *interrupt_id = interrupt_bit;
+    if (sys_irqsetpolicy(MOUSE_IRQ, IRQ_REENABLE | IRQ_EXCLUSIVE, interrupt_id)) return SBCR_ERROR;
+    return SUCCESS;
+}
+
+int got_error_mouse_ih = 0;
+int counter_mouse_ih = 0;
+
+void (mouse_ih)(void) {
+    uint8_t status = 0;
+    got_error_mouse_ih = 0;
+    if(counter_mouse_ih >= 3) counter_mouse_ih = 0;
+
+    if ((got_error_mouse_ih = util_sys_inb(STATUS_REG, &status))) return;
+
+    if (status & (TIME_OUT_REC | PARITY_ERROR)) {
+        got_error_mouse_ih = OTHER_ERROR;
+        return;
+    }
+    if (((status & AUX_MOUSE) == 0) || ((status & OUT_BUF_FUL) == 0)) {
+        got_error_mouse_ih = READ_ERROR;
+        return;
+    }
+
+    uint8_t byte = 0;
+
+    if ((got_error_mouse_ih = util_sys_inb(OUTPUT_BUF, &byte))) return;
+
+    /// This does not run if: I was expecting the first one but what I get is definitely not the first byte
+    if((byte & FIRST_BYTE_ID)  || counter_mouse_ih){
+        packet_mouse_ih[counter_mouse_ih++] = byte;
+    }
+}
+
+void (mouse_parse_packet)(const uint8_t *packet_bytes, struct packet *pp){
+    pp->bytes[0] = packet_bytes[0];
+    pp->bytes[1] = packet_bytes[1];
+    pp->bytes[2] = packet_bytes[2];
+    pp->rb       = pp->bytes[0] & RIGHT_BUTTON;
+    pp->mb       = pp->bytes[0] & MIDDLE_BUTTON;
+    pp->lb       = pp->bytes[0] & LEFT_BUTTON;
+    pp->delta_x  = sign_extend_byte((packet_bytes[0] & MSB_X_DELTA) != 0, pp->bytes[1]);
+    pp->delta_y  = sign_extend_byte((packet_bytes[0] & MSB_Y_DELTA) != 0, pp->bytes[2]);
+    pp->x_ov     = pp->bytes[0] & X_OVERFLOW;
+    pp->y_ov     = pp->bytes[0] & Y_OVERFLOW;
+}
+
+int mouse_poll(struct packet *pp, uint16_t period){
+    int ret = 0;
+
+    uint8_t packet[3];
+    uint8_t byte;
+    if ((ret = mouse_issue_cmd(READ_DATA))) return ret;
+    for(unsigned i = 0; i < 3; ++i){
+        if((ret = mouse_poll_byte(&byte, period))) return ret;
+        packet[i] = byte;
+    }
+    mouse_parse_packet(packet, pp);
+    return SUCCESS;
+}
+
+int (mouse_set_data_report)(int on){
+    if(on) return mouse_issue_cmd(ENABLE_DATA_REP);
+    else   return mouse_issue_cmd(   DIS_DATA_REP);
+}
+
+int (mouse_read_data)(uint8_t *data, uint16_t period) {
+    int ret;
+    if ((ret = mouse_issue_cmd(READ_DATA))) return ret;
+    if ((ret = mouse_poll_byte(data, period))) return ret;
+    return SUCCESS;
+}
+
+int (mouse_issue_cmd)(uint32_t cmd) {
+    int ret;
+    uint8_t ack = 0;
+    for (unsigned int i = 0; i < KBC_NUM_TRIES; i++) {
+        if ((ret = kbc_issue_cmd(MOUSE_WRITE_B))) return ret;
+        if ((ret = kbc_issue_arg(cmd))) return ret;
+        if ((ret = mouse_read_byte(&ack))) return ret;
+
+        if (ack == ACK_OK) return SUCCESS;
+        if (ack == ACK_ERROR) return INVALID_COMMAND;
+        tickdelay(micros_to_ticks(DELAY));
+    }
+    return TIMEOUT_ERROR;
+}
+
+int (mouse_read_byte)(uint8_t *byte) {
+    int ret = 0;
+    uint8_t stat;
+    for(int i = 0; i < KBC_NUM_TRIES; ++i){
+        if((ret = util_sys_inb(STATUS_REG, &stat))) return ret;
+        if((stat&OUT_BUF_FUL) && (stat&AUX_MOUSE)) {
+            if(stat & (PARITY_ERROR | TIME_OUT_REC)) return OTHER_ERROR;
+            if((ret = util_sys_inb(OUTPUT_BUF, byte))) return ret;
+            else return SUCCESS;
+        }
+        tickdelay(micros_to_ticks(DELAY));
+    }
+    return TIMEOUT_ERROR;
+}
+
+int (mouse_poll_byte)(uint8_t *byte, uint16_t period) {
+    int ret = 0;
+    uint8_t stat;
+    while(true){
+        if((ret = util_sys_inb(STATUS_REG, &stat))) return ret;
+        if((stat&OUT_BUF_FUL) && (stat&AUX_MOUSE)) {
+            if(stat & (PARITY_ERROR | TIME_OUT_REC)) return OTHER_ERROR;
+            if((ret = util_sys_inb(OUTPUT_BUF, byte))) return ret;
+            else return SUCCESS;
+        }
+        tickdelay(micros_to_ticks(DELAY));
+    }
+}
+
+int16_t (sign_extend_byte)(uint8_t sign_bit, uint8_t byte) {
+    return (int16_t)(((0xFF * sign_bit)<<8) | byte);
+}

Property changes on: proj/libs/peripherals/src/mouse.c
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: proj/libs/peripherals/src/rtc.c
===================================================================
--- proj/libs/peripherals/src/rtc.c	(nonexistent)
+++ proj/libs/peripherals/src/rtc.c	(revision 278)
@@ -0,0 +1,159 @@
+#include <lcom/lcf.h>
+
+#include "rtc.h"
+
+#include "utils.h"
+#include "errors.h"
+
+// RTC IRQ Line
+
+#define KBC_IRQ   8  /* @brief KBC IRQ Line */
+
+// RTC Ports
+
+#define RTC_ADDR_REG        0x70
+#define RTC_DATA_REG        0x71
+
+// RTC Registers (Byte)
+
+#define RTC_SEC             0
+#define RTC_SEC_ALARM       1
+#define RTC_MIN             2
+#define RTC_MIN_ALARM       3
+#define RTC_HOUR            4
+#define RTC_HOUR_ALARM      5
+#define RTC_WEEK_DAY        6
+#define RTC_MONTH_DAY       7
+#define RTC_MONTH           8
+#define RTC_YEAR            9
+#define RTC_REG_A           10
+#define RTC_REG_B           11
+#define RTC_REG_C           12
+#define RTC_REG_D           13
+
+// Register A
+
+#define RS0     BIT(0)  /** @brief Rate selector */
+#define RS1     BIT(1)  /** @brief Rate selector */
+#define RS2     BIT(2)  /** @brief Rate selector */
+#define RS3     BIT(3)  /** @brief Rate selector */
+#define UIP     BIT(7)  /** @brief Update in progress */
+
+// Register B
+
+#define DSE             BIT(0)  /** @brief Enable Daylight Saving Time */
+#define HOUR_FORM       BIT(1)  /** @brief Set to 1 for 24h format (0-23), 0 to 12h format (1-12) */
+#define DM              BIT(2)  /** @brief Set to 1 if registers are in binary, 0 if in BCD */
+#define SQWE            BIT(3)  /** @brief Enable square wave generation */
+#define UIE             BIT(4)  /** @brief Enable Update interrupts */
+#define AIE             BIT(5)  /** @brief Enable alarm interrupts */
+#define PIE             BIT(6)  /** @brief Enable periodic interrupts */
+#define SET             BIT(7)  /** @brief Set to 1 to inhibit updates of time/date registers */
+
+// Register C
+
+#define UF      BIT(4)  /** @brief Update Interrupt Pending */
+#define AF      BIT(5)  /** @brief Alarm Interrupt Pending */
+#define PF      BIT(6)  /** @brief Periodic Interrupt Pending */
+#define IRQF    BIT(7)  /** @brief IRQ Line Active */
+
+// Register D
+
+#define VRT     BIT(7)  /** @brief Valid RAM/time - If set to 0 RTC reading aren't valid */
+
+int (subscribe_rtc_interrupt)(uint8_t interrupt_bit, int *interrupt_id) {
+    if (interrupt_id == NULL) return NULL_PTR;
+    *interrupt_id = interrupt_bit;
+    if (sys_irqsetpolicy(KBC_IRQ, IRQ_REENABLE | IRQ_EXCLUSIVE, interrupt_id)) return SBCR_ERROR;
+    return SUCCESS;
+}
+
+int (rtc_read_register)(uint32_t reg, uint8_t *data) {
+    if (sys_outb(RTC_ADDR_REG, reg)) return WRITE_ERROR;
+
+    if (util_sys_inb(RTC_DATA_REG, data)) return READ_ERROR;
+
+    return SUCCESS;
+}
+
+int (rtc_write_register)(uint32_t reg, uint8_t data) {
+    if (sys_outb(RTC_ADDR_REG, reg)) return WRITE_ERROR;
+
+    if (sys_outb(RTC_DATA_REG, data)) return WRITE_ERROR;
+
+    return SUCCESS;
+}
+
+int (rtc_check_update)(void) {
+    uint8_t data;
+    int r;
+
+    if ((r = rtc_read_register(RTC_REG_A, &data))) return r;
+
+    return (data & UIP) != 0;
+}
+
+int (rtc_set_updates)(int on) {
+    uint8_t data;
+    int r;
+    if (on) {
+        if ((r = rtc_read_register(RTC_REG_B, &data))) return r;
+
+        data &= ~SET;
+
+        if ((r = rtc_write_register(RTC_REG_B, data))) return r;
+
+    } else {
+        while (rtc_check_update());
+
+        if ((r = rtc_read_register(RTC_REG_B, &data))) return r;
+
+        data |= SET;
+
+        if ((r = rtc_write_register(RTC_REG_B, data))) return r;
+    }
+    return SUCCESS;
+}
+
+int (rtc_read_time)(uint8_t *time) {
+
+    int r;
+    //if ((r = rtc_set_updates(false))) return r;
+    while (rtc_check_update());
+
+    uint8_t hour, min, sec;
+
+    if ((r = rtc_read_register(RTC_SEC, &sec)))    return r;
+    if ((r = rtc_read_register(RTC_MIN, &min)))    return r;
+    if ((r = rtc_read_register(RTC_HOUR, &hour)))  return r;
+
+    //if ((r = rtc_set_updates(true))) return r;
+
+    time[0] = BCD_FIRST(sec)*10   + BCD_SECOND(sec);
+    time[1] = BCD_FIRST(min)*10   + BCD_SECOND(min);
+    time[2] = BCD_FIRST(hour)*10  + BCD_SECOND(hour);
+
+    return SUCCESS;
+}
+
+int (rtc_read_date)(uint8_t *date) {
+    int r;
+    //if ((r = rtc_set_updates(false))) return r;
+    while (rtc_check_update());
+
+    uint8_t year, month, day, weekday;
+
+    if ((r = rtc_read_register(RTC_WEEK_DAY,    &weekday)))     return r;
+    if ((r = rtc_read_register(RTC_MONTH_DAY,   &day)))         return r;
+    if ((r = rtc_read_register(RTC_MONTH,       &month)))       return r;
+    if ((r = rtc_read_register(RTC_YEAR,        &year)))        return r;
+
+    //if ((r = rtc_set_updates(true))) return r;
+
+    date[0] = weekday;
+    date[1] = BCD_FIRST(day)*10     + BCD_SECOND(day);
+    date[2] = BCD_FIRST(month)*10   + BCD_SECOND(month);
+    date[3] = BCD_FIRST(year)*10    + BCD_SECOND(year);
+
+    return SUCCESS;
+}

Property changes on: proj/libs/peripherals/src/rtc.c
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: proj/libs/peripherals/src/timer.c
===================================================================
--- proj/libs/peripherals/src/timer.c	(nonexistent)
+++ proj/libs/peripherals/src/timer.c	(revision 278)
@@ -0,0 +1,18 @@
+#include <lcom/lcf.h>
+
+#include "timer.h"
+#include "graph.h"
+#include "sprite.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/libs/peripherals/src/timer.c
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: proj/libs/peripherals/src/uart.c
===================================================================
--- proj/libs/peripherals/src/uart.c	(nonexistent)
+++ proj/libs/peripherals/src/uart.c	(revision 278)
@@ -0,0 +1,379 @@
+#include <lcom/lcf.h>
+
+#include "uart.h"
+
+#include "queue.h"
+#include "errors.h"
+
+#define UART_BITRATE                            115200
+#define UART_WAIT                               20 //microseconds
+
+#define UART_RBR                                0
+#define UART_THR                                0
+#define UART_IER                                1
+#define UART_IIR                                2
+#define UART_FCR                                2
+#define UART_LCR                                3
+#define UART_MCR                                4
+#define UART_LSR                                5
+#define UART_MSR                                6
+#define UART_SR                                 7
+
+#define UART_DLL                                0
+#define UART_DLM                                1
+
+/// LCR
+#define UART_BITS_PER_CHAR_POS                  0
+#define UART_STOP_BITS_POS                      2
+#define UART_PARITY_POS                         3
+#define UART_BREAK_CONTROL_POS                  6
+#define UART_DLAB_POS                           7
+
+#define UART_BITS_PER_CHAR                      (BIT(0) | BIT(1))
+#define UART_STOP_BITS                          (BIT(2))
+#define UART_PARITY                             (BIT(3) | BIT(4) | BIT(5))
+#define UART_BREAK_CONTROL                      (BIT(6))
+#define UART_DLAB                               (BIT(7))
+
+#define UART_GET_BITS_PER_CHAR(n)               (((n)&UART_BITS_PER_CHAR) + 5)
+#define UART_GET_STOP_BITS(n)                   (((n)&UART_STOP_BITS)? 2 : 1)
+#define UART_GET_PARITY(n)                      (((n)&UART_PARITY       )>>UART_PARITY_POS       )
+#define UART_GET_BREAK_CONTROL(n)               (((n)&UART_BREAK_CONTROL)>>UART_BREAK_CONTROL_POS)
+#define UART_GET_DLAB(n)                        (((n)&UART_DLAB         )>>UART_DLAB_POS         )
+#define UART_GET_DIV_LATCH(m,l)                 ((m)<<8 | (l))
+#define UART_GET_DLL(n)                         ((n)&0xFF)
+#define UART_GET_DLM(n)                         (((n)>>8)&0xFF)
+
+/// IER
+#define UART_INT_EN_RX_POS                      0
+#define UART_INT_EN_TX_POS                      1
+#define UART_INT_EN_RECEIVER_LINE_STAT_POS      2
+#define UART_INT_EN_MODEM_STAT_POS              3
+
+#define UART_INT_EN_RX                          (BIT(0))
+#define UART_INT_EN_TX                          (BIT(1))
+#define UART_INT_EN_RECEIVER_LINE_STAT          (BIT(2))
+#define UART_INT_EN_MODEM_STAT                  (BIT(3))
+
+#define UART_GET_INT_EN_RX(n)                   (((n)&UART_INT_EN_RX                )>>UART_INT_EN_RX_POS                )
+#define UART_GET_INT_EN_TX(n)                   (((n)&UART_INT_EN_TX                )>>UART_INT_EN_TX_POS                )
+#define UART_GET_INT_EN_RECEIVER_LINE_STAT(n)   (((n)&UART_INT_EN_RECEIVER_LINE_STAT)>>UART_INT_EN_RECEIVER_LINE_STAT_POS)
+#define UART_GET_INT_EN_MODEM_STAT(n)           (((n)&UART_INT_EN_MODEM_STAT        )>>UART_INT_EN_MODEM_STAT_POS        )
+
+/// LSR
+#define UART_RECEIVER_READY_POS                 0
+#define UART_OVERRUN_ERROR_POS                  1
+#define UART_PARITY_ERROR_POS                   2
+#define UART_FRAMING_ERROR_POS                  3
+#define UART_TRANSMITTER_EMPTY_POS              5
+
+#define UART_RECEIVER_READY                     (BIT(0))
+#define UART_OVERRUN_ERROR                      (BIT(1))
+#define UART_PARITY_ERROR                       (BIT(2))
+#define UART_FRAMING_ERROR                      (BIT(3))
+#define UART_TRANSMITTER_EMPTY                  (BIT(5))
+
+#define UART_GET_RECEIVER_READY(n)              (((n)&UART_RECEIVER_READY           )>>UART_RECEIVER_READY_POS           )
+#define UART_GET_OVERRUN_ERROR                  (((n)&UART_OVERRUN_ERROR            )>>UART_OVERRUN_ERROR_POS            )
+#define UART_GET_PARITY_ERROR                   (((n)&UART_PARITY_ERROR             )>>UART_PARITY_ERROR_POS             )
+#define UART_GET_FRAMING_ERROR                  (((n)&UART_FRAMING_ERROR            )>>UART_FRAMING_ERROR_POS            )
+#define UART_GET_TRANSMITTER_EMPTY(n)           (((n)&UART_TRANSMITTER_EMPTY        )>>UART_TRANSMITTER_EMPTY_POS        )
+
+/// IIR
+#define UART_INT_PEND_POS                       1
+
+#define UART_INT_PEND                           (BIT(3)|BIT(2)|BIT(1))
+
+#define UART_GET_IF_INT_PEND(n)                 (!((n)&1))
+typedef enum {
+    uart_int_receiver_line_stat = (         BIT(1) | BIT(0)),
+    uart_int_rx                 = (         BIT(1)         ),
+    uart_int_char_timeout_fifo  = (BIT(2) | BIT(1)         ),
+    uart_int_tx                 = (                  BIT(0)),
+    uart_int_modem_stat         = (0)
+} uart_int_code;
+#define UART_GET_INT_PEND(n)                    ((uart_int_code)(((n)&UART_INT_PEND)>>UART_INT_PEND_POS))
+
+int (subscribe_uart_interrupt)(uint8_t interrupt_bit, int *interrupt_id) {
+    if (interrupt_id == NULL) return 1;
+    *interrupt_id = interrupt_bit;
+    return (sys_irqsetpolicy(COM1_IRQ, IRQ_REENABLE | IRQ_EXCLUSIVE, interrupt_id));
+}
+
+static void uart_parse_config(uart_config *config){
+    /// LCR
+    config->bits_per_char          = UART_GET_BITS_PER_CHAR     (config->lcr);
+    config->stop_bits              = UART_GET_STOP_BITS         (config->lcr);
+    config->parity                 = UART_GET_PARITY            (config->lcr); if((config->parity & BIT(0)) == 0) config->parity = uart_parity_none;
+    config->break_control          = UART_GET_BREAK_CONTROL     (config->lcr);
+    config->dlab                   = UART_GET_DLAB              (config->lcr);
+    /// IER
+    config->received_data_int      = UART_GET_INT_EN_RX                (config->ier);
+    config->transmitter_empty_int  = UART_GET_INT_EN_TX                (config->ier);
+    config->receiver_line_stat_int = UART_GET_INT_EN_RECEIVER_LINE_STAT(config->ier);
+    config->modem_stat_int         = UART_GET_INT_EN_MODEM_STAT        (config->ier);
+    /// DIV LATCH
+    config->divisor_latch          = UART_GET_DIV_LATCH(config->dlm, config->dll);
+}
+
+static int uart_get_lcr(int base_addr, uint8_t *p){
+    return util_sys_inb(base_addr+UART_LCR, p);
+}
+static int uart_set_lcr(int base_addr, uint8_t config){
+    if(sys_outb(base_addr+UART_LCR, config)) return WRITE_ERROR;
+    return SUCCESS;
+}
+static int uart_get_lsr(int base_addr, uint8_t *p){
+    return util_sys_inb(base_addr+UART_LSR, p);
+}
+static int uart_get_iir(int base_addr, uint8_t *p){
+    return util_sys_inb(base_addr+UART_IIR, p);
+}
+
+static int uart_enable_divisor_latch(int base_addr){
+    int ret = SUCCESS;
+    uint8_t conf; if((ret = uart_get_lcr(base_addr, &conf))) return ret;
+    return uart_set_lcr(base_addr, conf | UART_DLAB);
+}
+static int uart_disable_divisor_latch(int base_addr){
+    int ret = SUCCESS;
+    uint8_t conf; if((ret = uart_get_lcr(base_addr, &conf))) return ret;
+    return uart_set_lcr(base_addr, conf & (~UART_DLAB));
+}
+
+static int uart_get_ier(int base_addr, uint8_t *p){
+    int ret;
+    if((ret = uart_disable_divisor_latch(base_addr))) return ret;
+    return util_sys_inb(base_addr+UART_IER, p);
+}
+static int uart_set_ier(int base_addr, uint8_t n){
+    int ret;
+    if((ret = uart_disable_divisor_latch(base_addr))) return ret;
+    if(sys_outb(base_addr+UART_IER, n)) return WRITE_ERROR;
+    return SUCCESS;
+}
+
+int uart_get_config(int base_addr, uart_config *config){
+    int ret = SUCCESS;
+
+    config->base_addr = base_addr;
+
+    if((ret = uart_get_lcr(base_addr, &config->lcr))) return ret;
+
+    if((ret = uart_get_ier(base_addr, &config->ier))) return ret;
+
+    if((ret = uart_enable_divisor_latch (base_addr))) return ret;
+    if((ret = util_sys_inb(base_addr+UART_DLL, &config->dll   ))) return ret;
+    if((ret = util_sys_inb(base_addr+UART_DLM, &config->dlm   ))) return ret;
+    if((ret = uart_disable_divisor_latch(base_addr))) return ret;
+
+    uart_parse_config(config);
+    return ret;
+}
+void uart_print_config(uart_config config){
+
+    printf("%s configuration:\n", (config.base_addr == COM1_ADDR ? "COM1" : "COM2"));
+    printf("\tLCR = 0x%X: %d bits per char\t %d stop bits\t", config.lcr, config.bits_per_char, config.stop_bits);
+    if((config.parity&BIT(0)) == 0) printf("NO parity\n");
+    else switch(config.parity){
+        case uart_parity_odd : printf("ODD parity\n"     ); break;
+        case uart_parity_even: printf("EVEN parity\n"    ); break;
+        case uart_parity_par1: printf("parity bit is 1\n"); break;
+        case uart_parity_par0: printf("parity bit is 0\n"); break;
+        default              : printf("invalid\n"        ); break;
+    }
+    printf("\tDLM = 0x%02X DLL=0x%02X: bitrate = %d bps\n", config.dlm, config.dll, UART_BITRATE/config.divisor_latch);
+    printf("\tIER = 0x%02X: Rx interrupts: %s\tTx interrupts: %s\n", config.ier,
+        (config.received_data_int     ? "ENABLED":"DISABLED"),
+        (config.transmitter_empty_int ? "ENABLED":"DISABLED"));
+}
+
+int uart_set_bits_per_character(int base_addr, uint8_t bits_per_char){
+    if(bits_per_char < 5 || bits_per_char > 8) return INVALID_ARG;
+    int ret = SUCCESS;
+    bits_per_char = (bits_per_char-5)&0x3;
+    uint8_t conf; if((ret = uart_get_lcr(base_addr, &conf))) return ret;
+    conf = (conf & (~UART_BITS_PER_CHAR)) | bits_per_char;
+    return uart_set_lcr(base_addr, conf);
+}
+int uart_set_stop_bits(int base_addr, uint8_t stop){
+    if(stop != 1 && stop != 2) return INVALID_ARG;
+    int ret = SUCCESS;
+    stop -= 1;
+    stop = (stop&1)<<2;
+    uint8_t conf; if((ret = uart_get_lcr(base_addr, &conf))) return ret;
+    conf = (conf & (~UART_STOP_BITS)) | stop;
+    return uart_set_lcr(base_addr, conf);
+}
+int uart_set_parity(int base_addr, uart_parity par){
+    int ret = SUCCESS;
+    uint8_t parity = par << 3;
+    uint8_t conf; if((ret = uart_get_lcr(base_addr, &conf))) return ret;
+    conf = (conf & (~UART_PARITY)) | parity;
+    return uart_set_lcr(base_addr, conf);
+}
+int uart_set_bit_rate(int base_addr, float bit_rate){
+    int ret = SUCCESS;
+    uint16_t latch = UART_BITRATE/bit_rate;
+    uint8_t dll = UART_GET_DLL(latch);
+    uint8_t dlm = UART_GET_DLM(latch);
+    if((ret = uart_enable_divisor_latch(base_addr))) return ret;
+    if(sys_outb(base_addr+UART_DLL, dll)) return WRITE_ERROR;
+    if(sys_outb(base_addr+UART_DLM, dlm)) return WRITE_ERROR;
+    if((ret = uart_disable_divisor_latch(base_addr))) return ret;
+    return SUCCESS;
+}
+
+static int uart_get_char(int base_addr, uint8_t *p){
+    int ret;
+    if((ret = uart_disable_divisor_latch(base_addr))) return ret;
+    return util_sys_inb(base_addr+UART_RBR, p);
+}
+static int uart_send_char(int base_addr, uint8_t c){
+    int ret;
+    if((ret = uart_disable_divisor_latch(base_addr))) return ret;
+    if(sys_outb(base_addr+UART_THR, c)) return WRITE_ERROR;
+    return SUCCESS;
+}
+static int uart_receiver_ready(int base_addr){
+    uint8_t lsr;
+    if(uart_get_lsr(base_addr, &lsr)) return false;
+    return UART_GET_RECEIVER_READY(lsr);
+}
+static int uart_transmitter_empty(int base_addr){
+    uint8_t lsr;
+    if(uart_get_lsr(base_addr, &lsr)) return false;
+    return UART_GET_TRANSMITTER_EMPTY(lsr);
+}
+
+int uart_enable_int_rx(int base_addr){
+    int ret;
+    uint8_t ier;
+    if((ret = uart_get_ier(base_addr, &ier))) return ret;
+    ier |= UART_INT_EN_RX;
+    return uart_set_ier(base_addr, ier);
+}
+int uart_disable_int_rx(int base_addr){
+    int ret;
+    uint8_t ier;
+    if((ret = uart_get_ier(base_addr, &ier))) return ret;
+    ier &= ~UART_INT_EN_RX;
+    return uart_set_ier(base_addr, ier);
+}
+int uart_enable_int_tx(int base_addr){
+    int ret;
+    uint8_t ier;
+    if((ret = uart_get_ier(base_addr, &ier))) return ret;
+    ier |= UART_INT_EN_TX;
+    return uart_set_ier(base_addr, ier);
+}
+int uart_disable_int_tx(int base_addr){
+    int ret;
+    uint8_t ier;
+    if((ret = uart_get_ier(base_addr, &ier))) return ret;
+    ier &= ~UART_INT_EN_TX;
+    return uart_set_ier(base_addr, ier);
+}
+
+#include "nctp.h"
+
+#define NCTP_START      0x80
+#define NCTP_END        0xFF
+#define NCTP_OK         0xFF
+#define NCTP_NOK        0x00
+
+queue_t *out = NULL;
+queue_t *in  = NULL;
+
+int nctp_init(void){
+    out = queue_ctor(); if(out == NULL) return NULL_PTR;
+    in  = queue_ctor(); if(in  == NULL) return NULL_PTR;
+    return SUCCESS;
+}
+int nctp_free(void){
+    while(!queue_empty(out)){
+        free(queue_top(out));
+        queue_pop(out);
+    }
+    while(!queue_empty(in)){
+        free(queue_top(in));
+        queue_pop(in);
+    }
+    return SUCCESS;
+}
+
+int nctp_send(size_t num, uint8_t* ptr[], size_t sz[]){
+    {
+        size_t cnt = 0;
+        for(size_t i = 0; i < num; ++i){
+            cnt += sz[i];
+            if(cnt > queue_max_size) return TRANS_REFUSED;
+        }
+    }
+    int ret;
+    uint8_t *tmp;
+    tmp = malloc(sizeof(uint8_t)); *tmp = NCTP_START; queue_push(out, tmp);
+    for(size_t i = 0; i < num; ++i){
+        uint8_t *p = ptr[i]; size_t s = sz[i];
+        for(size_t j = 0; j < s; ++j, ++p){
+            tmp = malloc(sizeof(uint8_t)); *tmp = *p; queue_push(out, tmp);
+        }
+    }
+    tmp = malloc(sizeof(uint8_t)); *tmp = NCTP_END; queue_push(out, tmp);
+    if(uart_transmitter_empty(COM1_ADDR)){
+        if((ret = uart_send_char(COM1_ADDR, *(uint8_t*)queue_top(out)))) return ret;
+        queue_pop(out);
+    }
+    return SUCCESS;
+}
+
+static int nctp_transmit(void){
+    if(!queue_empty(out)){
+        int ret = uart_send_char(COM1_ADDR, *(uint8_t*)queue_top(out));
+        queue_pop(out);
+        return ret;
+    }else return SUCCESS;
+}
+
+static void process(){
+    free(queue_top(in)); queue_pop(in);
+    while(*(uint8_t*)queue_top(in) != NCTP_END){
+        printf("%c", *(uint8_t*)queue_top(in));
+        free(queue_top(in)); queue_pop(in);
+    }
+    printf("\n");
+    free(queue_top(in)); queue_pop(in);
+}
+static int nctp_receive(void){
+    int ret;
+    uint8_t c;
+    int num_ends = 0;
+    while(uart_receiver_ready(COM1_ADDR)){
+        if((ret = uart_get_char(COM1_ADDR, &c))) return ret;
+        uint8_t *tmp = malloc(sizeof(uint8_t)); *tmp = c;
+        queue_push(in, tmp);
+        if(c == NCTP_END) ++num_ends;
+    }
+    while(num_ends-- > 0) process();
+    return SUCCESS;
+}
+
+int nctp_ih_err = SUCCESS;
+void nctp_ih(void){
+    uint8_t iir;
+    if((nctp_ih_err = uart_get_iir(COM1_ADDR, &iir))) return;
+    if(UART_GET_IF_INT_PEND(iir)){
+        switch(UART_GET_INT_PEND(iir)){
+            case uart_int_rx: nctp_receive (); break;
+            case uart_int_tx: nctp_transmit(); break;
+            default: break;
+        }
+    }
+}
+
+/// HLTP
+int hltp_send_string(const char *p){
+    uint8_t* ptr[1]; ptr[0] = (uint8_t*)p;
+    size_t    sz[1]; sz[0] = strlen(p)+1;
+    return nctp_send(1, ptr, sz);
+}

Property changes on: proj/libs/peripherals/src/uart.c
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: proj/DR.mk
===================================================================
--- proj/DR.mk	(revision 277)
+++ proj/DR.mk	(revision 278)
@@ -1,10 +1,13 @@
 PROG=proj
 
 .PATH: ${.CURDIR}/src
+.PATH: ${.CURDIR}/libs/peripherals/src
+.PATH: ${.CURDIR}/libs/classes/src
 
 SRCS= proj.c list.c queue.c graph.c kbc.c keyboard.c mouse.c utils.c timer.c interrupts_func.c proj_func.c fast_math.c rectangle.c font.c xpm_utils.c ent.c rtc.c uart.c hltp.c makecode_map.c
+IPATHS=-I./include -I./libs/peripherals/include -I./libs/classes/include -I./maps -I./media/xpm
 
-CPPFLAGS += -pedantic -I./include -I./maps -I./media/xpm -D LCOM_MACRO -D DIOGO #-D __LCOM_OPTIMIZED_
+CPPFLAGS += -pedantic ${IPATHS} -D LCOM_MACRO -D DIOGO #-D __LCOM_OPTIMIZED_
 
 DPADD += ${LIBLCF}
 LDADD += -llcf
