This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to read/write an I/O port in aarch64?

Hello, I was trying to write one byte to an I/O port, but I am failing finding the correct instructions in the instruction set of arm64 aarch64 architecture. I failed to find the answer in previous posts of this forum too.

To be sure I posted the question correctly, please consider a NS16550 uart.

I want, basically, to use `outb` (or `inb`) instructions, but I do not find the correct syntax. An equivalent example in i386 is:

void dbg_io_write_8(uint16_t port, uint8_t val)
{
    asm volatile (
        "outb    %%al, %%dx;"
        /* Outputs  */ : /* None */
        /* Inputs   */ : "a" (val), "d" (port)
        /* Clobbers */ : /* None */
        );
}

And, the equivalent for reading:

uint8_t dbg_io_read_8(uint16_t port)
{
    uint8_t val;

    asm volatile (
        "inb     %%dx, %%al;"
        /* Outputs  */ : "=a" (val)
        /* Inputs   */ : "d" (port)
        /* Clobbers */ : /* None */
        );

    return val;
}


Thanks for helping!
Parents Reply Children
No data