diff options
Diffstat (limited to 'src/sys/io')
-rw-r--r-- | src/sys/io/cons/cons.c | 20 | ||||
-rw-r--r-- | src/sys/io/ic/ahci.c | 28 |
2 files changed, 34 insertions, 14 deletions
diff --git a/src/sys/io/cons/cons.c b/src/sys/io/cons/cons.c index a80644c..65d1f1b 100644 --- a/src/sys/io/cons/cons.c +++ b/src/sys/io/cons/cons.c @@ -37,6 +37,8 @@ #include <stdbool.h> #include <string.h> +#define TAB_WIDTH (FONT_WIDTH * 4) + /* kconf background color config */ #if defined(__CONS_BG) #define DEFAULT_BG __CONS_BG @@ -180,6 +182,21 @@ cons_backspace(struct cons_scr *scr) cons_draw_cursor(scr, false); } +static void +cons_tab(struct cons_scr *scr) +{ + cons_draw_cursor(scr, true); + scr->text_x += TAB_WIDTH; + scr->cursor_x += TAB_WIDTH; + + /* Wrap to next line if needed */ + if (scr->cursor_x >= scr->max_col) { + cons_newline(scr); + } + + cons_draw_cursor(scr, false); +} + /* * Fill a screen with a desired background * color @@ -224,6 +241,9 @@ cons_handle_spec(struct cons_scr *scr, int c) case ASCII_BS: cons_backspace(scr); return c; + case ASCII_HT: + cons_tab(scr); + return c; } return -1; diff --git a/src/sys/io/ic/ahci.c b/src/sys/io/ic/ahci.c index 383e531..f4b38d2 100644 --- a/src/sys/io/ic/ahci.c +++ b/src/sys/io/ic/ahci.c @@ -665,6 +665,7 @@ ahci_init_port(struct ahci_hba *hba, struct ahci_port *port) const uint16_t BSIZE = 512; volatile struct hba_port *regs; struct ahci_cmd_hdr *cmdlist; + struct ahci_port *port_cpy; uint32_t cmd, lo, hi; size_t clen; paddr_t pa; @@ -718,8 +719,14 @@ ahci_init_port(struct ahci_hba *hba, struct ahci_port *port) return error; } - TAILQ_INSERT_TAIL(&portlist, port, link); - ahci_identify(hba, port); + port_cpy = kalloc(sizeof(*port_cpy)); + if (port_cpy == NULL) { + return -ENOMEM; + } + + memcpy(port_cpy, port, sizeof(*port_cpy)); + TAILQ_INSERT_TAIL(&portlist, port_cpy, link); + ahci_identify(hba, port_cpy); return 0; } @@ -730,7 +737,7 @@ static int ahci_init_ports(struct ahci_hba *hba) { volatile struct hba_memspace *io = hba->io; - struct ahci_port *port; + struct ahci_port port; uint32_t pi, nbits; int error; @@ -743,20 +750,13 @@ ahci_init_ports(struct ahci_hba *hba) /* Allocate a new port descriptor */ dtrace("port %d implemented\n", i); - port = kalloc(sizeof(*port)); - if (port == NULL) { - dtrace("failed to allocate port\n"); - continue; - } - - port->io = &io->ports[i]; - port->portno = i; - port->parent = hba; + port.io = &io->ports[i]; + port.portno = i; + port.parent = hba; /* Initialize the port */ - error = ahci_init_port(hba, port); + error = ahci_init_port(hba, &port); if (error < 0) { - ahci_port_detach(port); dtrace("port init failed (error=%d)\n", error); continue; } |