Changeset e9bc927 in mainline


Ignore:
Timestamp:
2025-04-18T08:22:19Z (2 months ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
master
Children:
25fdb2d
Parents:
51949d0
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2025-04-18 07:18:03)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2025-04-18 08:22:19)
Message:

Update forgotten serial implementations

Location:
kernel
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/ia64/src/drivers/ski.c

    r51949d0 re9bc927  
    6060};
    6161
    62 static void ski_putuchar(outdev_t *, const char32_t);
     62static void ski_write(outdev_t *, const char *, size_t);
    6363
    6464static outdev_operations_t skidev_ops = {
    65         .write = ski_putuchar,
     65        .write = ski_write,
    6666        .redraw = NULL,
    6767        .scroll_up = NULL,
     
    182182}
    183183
    184 static void ski_do_putchar(char ch)
     184static void ski_do_putchar(uint8_t ch)
    185185{
    186186        asm volatile (
     
    203203 *
    204204 */
    205 static void ski_putuchar(outdev_t *dev, char32_t ch)
    206 {
     205static void ski_write(outdev_t *dev, const char *s, size_t n)
     206{
     207        /* If the userspace owns the console, do not output anything. */
    207208        if (ski_parea.mapped && !console_override)
    208209                return;
    209210
    210         if (ascii_check(ch)) {
    211                 if (ch == '\n')
     211        const char *top = s + n;
     212        assert(top >= s);
     213
     214        for (; s < top; s++) {
     215                if (*s == '\n')
    212216                        ski_do_putchar('\r');
    213217
    214                 ski_do_putchar(ch);
    215         } else {
    216                 ski_do_putchar('?');
     218                ski_do_putchar((uint8_t) *s);
    217219        }
    218220}
  • kernel/arch/riscv64/src/drivers/ucb.c

    r51949d0 re9bc927  
    4141static volatile uint64_t *fromhost;
    4242
    43 static outdev_operations_t htifdev_ops = {
    44         .write = htif_putuchar,
    45         .redraw = NULL,
    46         .scroll_up = NULL,
    47         .scroll_down = NULL
    48 };
    49 
    5043static void poll_fromhost()
    5144{
     
    5649        *fromhost = 0;
    5750}
     51
     52static void htif_cmd(uint8_t device, uint8_t cmd, uint64_t payload)
     53{
     54        uint64_t val = (((uint64_t) device) << 56) |
     55            (((uint64_t) cmd) << 48) |
     56            (payload & UINT64_C(0xffffffffffff));
     57
     58        while (*tohost)
     59                poll_fromhost();
     60
     61        *tohost = val;
     62}
     63
     64static void htif_write(outdev_t *dev, const char *s, size_t n)
     65{
     66        const char *top = s + n;
     67        assert(top >= s);
     68
     69        for (; s < top; s++) {
     70                if (*s == '\n')
     71                        htif_cmd(HTIF_DEVICE_CONSOLE, HTIF_CONSOLE_PUTC, '\r');
     72
     73                htif_cmd(HTIF_DEVICE_CONSOLE, HTIF_CONSOLE_PUTC, (uint8_t) *s);
     74        }
     75}
     76
     77static outdev_operations_t htifdev_ops = {
     78        .write = htif_write,
     79        .redraw = NULL,
     80        .scroll_up = NULL,
     81        .scroll_down = NULL
     82};
    5883
    5984void htif_init(volatile uint64_t *tohost_addr, volatile uint64_t *fromhost_addr)
     
    7297        return htifdev;
    7398}
    74 
    75 static void htif_cmd(uint8_t device, uint8_t cmd, uint64_t payload)
    76 {
    77         uint64_t val = (((uint64_t) device) << 56) |
    78             (((uint64_t) cmd) << 48) |
    79             (payload & UINT64_C(0xffffffffffff));
    80 
    81         while (*tohost)
    82                 poll_fromhost();
    83 
    84         *tohost = val;
    85 }
    86 
    87 void htif_putuchar(outdev_t *dev, const char32_t ch)
    88 {
    89         if (ascii_check(ch))
    90                 htif_cmd(HTIF_DEVICE_CONSOLE, HTIF_CONSOLE_PUTC, ch);
    91         else
    92                 htif_cmd(HTIF_DEVICE_CONSOLE, HTIF_CONSOLE_PUTC, U_SPECIAL);
    93 }
  • kernel/arch/sparc64/src/drivers/niagara.c

    r51949d0 re9bc927  
    5757static niagara_instance_t *instance = NULL;
    5858
    59 static void niagara_putuchar(outdev_t *, const char32_t);
     59static void niagara_write(outdev_t *, const char *, size_t);
    6060
    6161/** Character device operations */
    6262static outdev_operations_t niagara_ops = {
    63         .write = niagara_putuchar,
     63        .write = niagara_write,
    6464        .redraw = NULL,
    6565        .scroll_up = NULL,
     
    9595
    9696/** Write a single character to the standard output. */
    97 static inline void do_putchar(char c)
     97static inline void do_putchar(uint8_t c)
    9898{
    9999        /* Repeat until the buffer is non-full */
     
    102102}
    103103
    104 /** Write a single character to the standard output. */
    105 static void niagara_putuchar(outdev_t *dev, char32_t ch)
    106 {
    107         if ((!outbuf_parea.mapped) || (console_override)) {
    108                 if (ascii_check(ch)) {
    109                         do_putchar(ch);
    110                         if (ch == '\n')
    111                                 do_putchar('\r');
    112                 } else {
    113                         do_putchar('?');
    114                 }
     104static void niagara_write(outdev_t *dev, const char *s, size_t n)
     105{
     106        /* If the userspace owns the console, do not output anything. */
     107        if (outbuf_parea.mapped && !console_override)
     108                return;
     109
     110        const char *top = s + n;
     111        assert(top >= s);
     112
     113        for (; s < top; s++) {
     114                if (*s == '\n')
     115                        do_putchar('\r');
     116
     117                do_putchar((uint8_t) *s);
    115118        }
    116119}
  • kernel/genarch/src/drivers/dsrln/dsrlnout.c

    r51949d0 re9bc927  
    4949} dsrlnout_instance_t;
    5050
    51 static void dsrlnout_putuchar(outdev_t *dev, const char32_t ch)
     51static void dsrlnout_write(outdev_t *dev, const char *s, size_t n)
    5252{
    5353        dsrlnout_instance_t *instance = (dsrlnout_instance_t *) dev->data;
    5454
    55         if ((!instance->parea.mapped) || (console_override)) {
    56                 if (ascii_check(ch))
    57                         pio_write_8(instance->base, ch);
    58                 else
    59                         pio_write_8(instance->base, U_SPECIAL);
     55        if (instance->parea.mapped && !console_override)
     56                return;
     57
     58        const char *top = s + n;
     59        assert(top >= s);
     60
     61        for (; s < top; s++) {
     62                if (*s == '\n')
     63                        pio_write_8(instance->base, '\r');
     64
     65                pio_write_8(instance->base, (uint8_t) *s);
    6066        }
    6167}
    6268
    6369static outdev_operations_t dsrlndev_ops = {
    64         .write = dsrlnout_putuchar,
     70        .write = dsrlnout_write,
    6571        .redraw = NULL,
    6672        .scroll_up = NULL,
  • kernel/genarch/src/drivers/omap/uart.c

    r51949d0 re9bc927  
    4949}
    5050
    51 static void omap_uart_putuchar(outdev_t *dev, char32_t ch)
     51static void omap_uart_write(outdev_t *dev, const char *s, size_t n)
    5252{
    5353        omap_uart_t *uart = dev->data;
    54         if (!ascii_check(ch)) {
    55                 omap_uart_txb(uart, U_SPECIAL);
    56         } else {
    57                 if (ch == '\n')
     54
     55        const char *top = s + n;
     56        assert(top >= s);
     57
     58        for (; s < top; s++) {
     59                if (*s == '\n')
    5860                        omap_uart_txb(uart, '\r');
    59                 omap_uart_txb(uart, ch);
     61
     62                omap_uart_txb(uart, (uint8_t) *s);
    6063        }
    6164}
    6265
    6366static outdev_operations_t omap_uart_ops = {
    64         .write = omap_uart_putuchar,
     67        .write = omap_uart_write,
    6568        .redraw = NULL,
    6669        .scroll_up = NULL,
  • kernel/genarch/src/drivers/s3c24xx/uart.c

    r51949d0 re9bc927  
    4949#include <str.h>
    5050
    51 static void s3c24xx_uart_sendb(outdev_t *dev, uint8_t byte)
     51static void s3c24xx_uart_sendb(s3c24xx_uart_t *uart, uint8_t byte)
    5252{
    53         s3c24xx_uart_t *uart =
    54             (s3c24xx_uart_t *) dev->data;
    55 
    5653        /* Wait for space becoming available in Tx FIFO. */
    5754        while ((pio_read_32(&uart->io->ufstat) & S3C24XX_UFSTAT_TX_FULL) != 0)
     
    6158}
    6259
    63 static void s3c24xx_uart_putuchar(outdev_t *dev, char32_t ch)
     60static void s3c24xx_uart_write(outdev_t *dev, const char *s, size_t n)
    6461{
    65         s3c24xx_uart_t *uart =
    66             (s3c24xx_uart_t *) dev->data;
     62        s3c24xx_uart_t *uart = dev->data;
    6763
    68         if ((!uart->parea.mapped) || (console_override)) {
    69                 if (!ascii_check(ch)) {
    70                         s3c24xx_uart_sendb(dev, U_SPECIAL);
    71                 } else {
    72                         if (ch == '\n')
    73                                 s3c24xx_uart_sendb(dev, (uint8_t) '\r');
    74                         s3c24xx_uart_sendb(dev, (uint8_t) ch);
    75                 }
     64        /* If the userspace owns the console, do not output anything. */
     65        if (uart->parea.mapped && !console_override)
     66                return;
     67
     68        const char *top = s + n;
     69        assert(top >= s);
     70
     71        for (; s < top; s++) {
     72                if (*s == '\n')
     73                        s3c24xx_uart_sendb(uart, '\r');
     74
     75                s3c24xx_uart_sendb(uart, (uint8_t) *s);
    7676        }
    7777}
     
    9494
    9595static outdev_operations_t s3c24xx_uart_ops = {
    96         .write = s3c24xx_uart_putuchar,
     96        .write = s3c24xx_uart_write,
    9797        .redraw = NULL,
    9898        .scroll_up = NULL,
Note: See TracChangeset for help on using the changeset viewer.