Changeset e9bc927 in mainline for kernel/arch


Ignore:
Timestamp:
2025-04-18T08:22:19Z (3 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/arch
Files:
3 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}
Note: See TracChangeset for help on using the changeset viewer.