MOS Source Code
Loading...
Searching...
No Matches
uart_driver.c
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-3.0-or-later
2
4
5#include "mos/device/serial.h"
6
7#include <mos/types.h>
8
10{
11 volatile u8 *const ptr = dev->driver_data;
12 return READ_ONCE(ptr[reg]);
13}
14
16{
17 volatile u8 *const ptr = dev->driver_data;
18 ptr[reg] = value;
19}
20
22{
23 volatile u8 *const ptr = dev->driver_data;
24 return ptr[0];
25}
26
28{
29 volatile u8 *const ptr = dev->driver_data;
30 ptr[0] = data;
31}
32
34 .read_data = riscv64_serial_read_data,
35 .write_data = riscv64_serial_write_data,
36 .read_register = riscv64_serial_read_register,
37 .write_register = riscv64_serial_write_register,
38};
#define READ_ONCE(x)
Definition mos_global.h:85
serial_register_t
Definition serial.h:8
void * driver_data
Definition serial.h:83
unsigned char u8
Definition types.h:19
static void riscv64_serial_write_data(serial_device_t *dev, u8 data)
Definition uart_driver.c:27
static void riscv64_serial_write_register(serial_device_t *dev, serial_register_t reg, u8 value)
Definition uart_driver.c:15
const serial_driver_t riscv64_uart_driver
Definition uart_driver.c:33
static u8 riscv64_serial_read_register(serial_device_t *dev, serial_register_t reg)
Definition uart_driver.c:9
static u8 riscv64_serial_read_data(serial_device_t *dev)
Definition uart_driver.c:21