m1n1/src/uart.h
Vincent Duvert b15be6bcd7 Remove hardcoded UART/WDT addresses
The M1 Pro/Max Macs use a different base address for the UART and the
WDT than earlier models.

Remove hardcoded base addresses constants and replace them with loads
from the ADT.

- The base address of the WDT is already retrieved in wdt_disable; also
use this address when triggering a reboot.
- Retrieve the base address of uart0 in uart_init. If the operation
fails, the error will be signaled on the early uart (if not disabled).
- The early debug UART can’t use the ADT (or shouldn’t) so it is now
disabled by default. To enable it, add
-DEARLY_UART -DEARLY_UART_BASE=0xuart_address
to the CFLAGS.

Signed-off-by: Vincent Duvert <vincent@duvert.net>
2021-11-01 11:27:29 +09:00

29 lines
503 B
C

/* SPDX-License-Identifier: MIT */
#ifndef UART_H
#define UART_H
#include "types.h"
int uart_init(void);
void uart_putbyte(u8 c);
u8 uart_getbyte(void);
void uart_putchar(u8 c);
u8 uart_getchar(void);
void uart_write(const void *buf, size_t count);
size_t uart_read(void *buf, size_t count);
void uart_puts(const char *s);
void uart_setbaud(int baudrate);
void uart_flush(void);
void uart_clear_irqs(void);
int uart_printf(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
#endif