haiku/headers/private/kernel/arch/riscv64/arch_uart_sifive.h
Alexander von Gluck IV 1648ab5277 kernel/uart: Clean up uarts, make calling convention consistent
Change-Id: I36ef92ef13edb0b006344db74e9d1b3ae52e0127
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4327
Reviewed-by: X512 <danger_mail@list.ru>
Reviewed-by: Jessica Hamilton <jessica.l.hamilton@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
2021-08-16 23:22:35 +00:00

103 lines
1.7 KiB
C++

/*
* Copyright 2021, Haiku, Inc. All rights reserved
* Distributed under the terms of the MIT License.
*/
#ifndef _ARCH_UART_SIFIVE_H_
#define _ARCH_UART_SIFIVE_H_
#include <arch/generic/debug_uart.h>
// UARTSifiveRegs.ie, ip
enum {
kUartSifiveTxwm = 1 << 0,
kUartSifiveRxwm = 1 << 1,
};
struct UARTSifiveRegs {
union Txdata {
struct {
uint32 data: 8;
uint32 reserved: 23;
uint32 isFull: 1;
};
uint32 val;
} txdata;
union Rxdata {
struct {
uint32 data: 8;
uint32 reserved: 23;
uint32 isEmpty: 1;
};
uint32 val;
} rxdata;
union Txctrl {
struct {
uint32 enable: 1;
uint32 nstop: 1;
uint32 reserved1: 14;
uint32 cnt: 3;
uint32 reserved2: 13;
};
uint32 val;
} txctrl;
union Rxctrl {
struct {
uint32 enable: 1;
uint32 reserved1: 15;
uint32 cnt: 3;
uint32 reserved2: 13;
};
uint32 val;
} rxctrl;
uint32 ie; // interrupt enable
uint32 ip; // interrupt pending
uint32 div;
uint32 unused;
};
class ArchUARTSifive : public DebugUART {
public:
ArchUARTSifive(addr_t base, int64 clock);
~ArchUARTSifive();
virtual void InitEarly();
virtual void Init();
virtual void InitPort(uint32 baud);
virtual void Enable();
virtual void Disable();
virtual int PutChar(char ch);
virtual int GetChar(bool wait);
virtual void FlushTx();
virtual void FlushRx();
protected:
virtual void Barrier();
inline volatile UARTSifiveRegs*
Regs();
};
volatile UARTSifiveRegs*
ArchUARTSifive::Regs()
{
return (volatile UARTSifiveRegs*)Base();
}
ArchUARTSifive* arch_get_uart_sifive(addr_t base, int64 clock);
#endif // _ARCH_UART_SIFIVE_H_