|
1 | | -#include <stdbigos/string.h> |
2 | 1 | #include <drivers/uart.h> |
| 2 | +#include <stdbigos/string.h> |
3 | 3 |
|
4 | | -#define ENTER 0xd |
5 | | -#define BACKSPACE 0x100 |
| 4 | +#define ENTER 0xd |
| 5 | +#define BACKSPACE 0x100 |
6 | 6 | #define BUFFER_SIZE 4096 |
7 | 7 |
|
8 | 8 | char console_buffer[BUFFER_SIZE]; |
9 | 9 |
|
10 | 10 | int readline(void) { |
11 | | - int console_read = 0; |
12 | | - int c; |
13 | | - while ((c = getc_uart()) != ENTER) { |
14 | | - if (c == -1) continue; |
| 11 | + int console_read = 0; |
| 12 | + int c; |
| 13 | + while ((c = getc_uart()) != ENTER) { |
| 14 | + if (c == -1) |
| 15 | + continue; |
15 | 16 |
|
16 | | - if (c == '\x7f' || c == 8) { |
17 | | - if (console_read != 0) { |
18 | | - puts_uart("\b \b"); |
19 | | - console_read--; |
20 | | - } |
21 | | - } |
22 | | - else if(console_read != BUFFER_SIZE - 1) { |
23 | | - if(console_read < 0 || console_read >= BUFFER_SIZE) |
24 | | - puts_uart("\nAssertion failed in readline!!\n"); |
| 17 | + if (c == '\x7f' || c == 8) { |
| 18 | + if (console_read != 0) { |
| 19 | + puts_uart("\b \b"); |
| 20 | + console_read--; |
| 21 | + } |
| 22 | + } else if (console_read != BUFFER_SIZE - 1) { |
| 23 | + if (console_read < 0 || console_read >= BUFFER_SIZE) |
| 24 | + puts_uart("\nAssertion failed in readline!!\n"); |
25 | 25 |
|
26 | | - console_buffer[console_read] = c; |
27 | | - console_read++; |
28 | | - putc_uart(c); |
29 | | - } |
30 | | - } |
31 | | - console_buffer[console_read] = '\0'; |
| 26 | + console_buffer[console_read] = c; |
| 27 | + console_read++; |
| 28 | + putc_uart(c); |
| 29 | + } |
| 30 | + } |
| 31 | + console_buffer[console_read] = '\0'; |
32 | 32 |
|
33 | | - return console_read; |
| 33 | + return console_read; |
34 | 34 | } |
35 | 35 |
|
36 | | -int process_command(char *comm) { |
37 | | - if (!strcmp(comm, "help")) { |
38 | | - puts_uart("\nIt's only this lousy command for now mate"); |
39 | | - } |
40 | | - else if (!strcmp(comm, "ping")) { |
41 | | - puts_uart("\npong"); |
42 | | - } |
43 | | - return 0; |
| 36 | +int process_command(char* comm) { |
| 37 | + if (!strcmp(comm, "help")) { |
| 38 | + puts_uart("\nIt's only this lousy command for now mate"); |
| 39 | + } else if (!strcmp(comm, "ping")) { |
| 40 | + puts_uart("\npong"); |
| 41 | + } |
| 42 | + return 0; |
44 | 43 | } |
0 commit comments