Project

General

Profile

Statistics
| Revision:

root / lab2 / utils.h @ 9

History | View | Annotate | Download (1007 Bytes)

1
#pragma once
2

    
3
/** @defgroup utils utils
4
 * @{
5
 *
6
 * LCOM's utility functions
7
 */
8

    
9
#include <stdint.h>
10

    
11
#ifndef BIT
12
#  define BIT(n) (1 << (n))
13
#endif
14

    
15
/**
16
 * @brief Returns the LSB of a 2 byte integer
17
 *
18
 * @param val input 2 byte integer
19
 * @param lsb address of memory location to be updated with val's LSB
20
 * @return Return 0 upon success and non-zero otherwise
21
 */
22
int (util_get_LSB)(uint16_t val, uint8_t *lsb);
23

    
24
/**
25
 * @brief Returns the MSB of a 2 byte integer
26
 *
27
 * @param val input 2 byte integer
28
 * @param msb address of memory location to be updated with val's LSB
29
 * @return Return 0 upon success and non-zero otherwise
30
 */
31
int (util_get_MSB)(uint16_t val, uint8_t *msb);
32

    
33
/**
34
 * @brief Invokes sys_inb() system call but reads the value into a uint8_t variable.
35
 *
36
 * @param port the input port that is to be read
37
 * @param value address of 8-bit variable to be update with the value read
38
 * @return Return 0 upon success and non-zero otherwise
39
 */
40
int (util_sys_inb)(int port, uint8_t *value);