Ignore:
Timestamp:
2025-04-18T13:45:46Z (4 days ago)
Author:
GitHub <noreply@…>
Children:
9fc15f9
Parents:
94abc30c (diff), 25fdb2d (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
Wayne Thornton <wmthornton-dev@…> (2025-04-18 13:45:46)
git-committer:
GitHub <noreply@…> (2025-04-18 13:45:46)
Message:

Merge branch 'HelenOS:master' into master

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/riscv64/src/drivers/ucb.c

    r94abc30c r6b03a3c  
    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 }
Note: See TracChangeset for help on using the changeset viewer.