root / lab2 / utils.c @ 10
History | View | Annotate | Download (502 Bytes)
1 | 4 | up20180655 | #include <lcom/lcf.h> |
---|---|---|---|
2 | |||
3 | #include <stdint.h> |
||
4 | |||
5 | int(util_get_LSB)(uint16_t val, uint8_t *lsb) {
|
||
6 | 7 | up20180655 | if (lsb == NULL) |
7 | return 1; |
||
8 | 4 | up20180655 | |
9 | 7 | up20180655 | *lsb = val; |
10 | return 0; |
||
11 | 4 | up20180655 | } |
12 | |||
13 | int(util_get_MSB)(uint16_t val, uint8_t *msb) {
|
||
14 | 7 | up20180655 | if (*msb == NULL) |
15 | return 1; |
||
16 | *msb = val >> 8;
|
||
17 | return 0; |
||
18 | 4 | up20180655 | } |
19 | |||
20 | int (util_sys_inb)(int port, uint8_t *value) { |
||
21 | 5 | up20180642 | /* To be implemented by the students */
|
22 | 8 | up20180642 | if(value == NULL) return 1; |
23 | 5 | up20180642 | uint32_t n = 0;
|
24 | 9 | up20180642 | if(sys_inb(port, &n)) return 1; |
25 | 5 | up20180642 | *value = n; |
26 | 9 | up20180642 | return 0; |
27 | 4 | up20180655 | } |