root / lab4 / .minix-src / include / lcom / utils.h @ 13
History | View | Annotate | Download (947 Bytes)
1 | 13 | up20180614 | #pragma once
|
---|---|---|---|
2 | |||
3 | #include <stdint.h> |
||
4 | |||
5 | #ifndef BIT
|
||
6 | # define BIT(n) (1 << (n)) |
||
7 | #endif
|
||
8 | |||
9 | /**
|
||
10 | * @brief Returns the LSB of a 2 byte integer
|
||
11 | *
|
||
12 | * @param val input 2 byte integer
|
||
13 | * @param lsb address of memory location to be updated with val's LSB
|
||
14 | * @return Return 0 upon success and non-zero otherwise
|
||
15 | */
|
||
16 | int (util_get_LSB)(uint16_t val, uint8_t *lsb);
|
||
17 | |||
18 | /**
|
||
19 | * @brief Returns the MSB of a 2 byte integer
|
||
20 | *
|
||
21 | * @param val input 2 byte integer
|
||
22 | * @param msb address of memory location to be updated with val's LSB
|
||
23 | * @return Return 0 upon success and non-zero otherwise
|
||
24 | */
|
||
25 | int (util_get_MSB)(uint16_t val, uint8_t *msb);
|
||
26 | |||
27 | /**
|
||
28 | * @brief Invokes sys_inb() system call but reads the value into a uint8_t variable.
|
||
29 | *
|
||
30 | * @param port the input port that is to be read
|
||
31 | * @param value a pointer to the variable that is to be update with the value read
|
||
32 | * @return Return 0 upon success and non-zero otherwise
|
||
33 | */
|
||
34 | int (util_sys_inb)(int port, uint8_t *value); |