arm: Add EARLY_PRINTF for ns8250 on arm/aarch64 platforms.
Reviewed by: adrian (previous version) MFC after: 3 weeks
This commit is contained in:
@@ -1016,3 +1016,7 @@ PRESERVE_EARLY_KENV opt_global.h
|
||||
|
||||
# Options for the Intel QuickAssist (QAT) driver
|
||||
QAT_DISABLE_SAFE_DC_MODE opt_qat.h
|
||||
|
||||
# EARLY_PRINTF specific options fo NS8250 uart
|
||||
UART_NS8250_EARLY_REG_IO_WIDTH opt_uart.h
|
||||
UART_NS8250_EARLY_REG_SHIFT opt_uart.h
|
||||
|
||||
@@ -89,9 +89,7 @@ SYSCTL_INT(_hw, OID_AUTO, uart_noise_threshold, CTLFLAG_RWTUN,
|
||||
* options EARLY_PRINTF=ns8250
|
||||
*/
|
||||
#if CHECK_EARLY_PRINTF(ns8250)
|
||||
#if !(defined(__amd64__) || defined(__i386__))
|
||||
#error ns8250 early putc is x86 specific as it uses inb/outb
|
||||
#endif
|
||||
#if (defined(__amd64__) || defined(__i386__))
|
||||
static void
|
||||
uart_ns8250_early_putc(int c)
|
||||
{
|
||||
@@ -103,7 +101,45 @@ uart_ns8250_early_putc(int c)
|
||||
continue;
|
||||
outb(tx, c);
|
||||
}
|
||||
#elif (defined(__arm__) || defined(__aarch64__))
|
||||
#ifndef UART_NS8250_EARLY_REG_IO_WIDTH
|
||||
#error Option 'UART_NS8250_EARLY_REG_IO_WIDTH' is missing.
|
||||
#endif
|
||||
#ifndef UART_NS8250_EARLY_REG_SHIFT
|
||||
#error Option 'UART_NS8250_EARLY_REG_SHIFT' is missing.
|
||||
#endif
|
||||
|
||||
#if UART_NS8250_EARLY_REG_IO_WIDTH == 1
|
||||
#define T uint8_t
|
||||
#elif UART_NS8250_EARLY_REG_IO_WIDTH == 2
|
||||
#define T uint16_t
|
||||
#elif UART_NS8250_EARLY_REG_IO_WIDTH == 4
|
||||
#define T uint32_t
|
||||
|
||||
#else
|
||||
#error Invalid/unsupported UART_NS8250_EARLY_REG_IO_WIDTH value
|
||||
#endif
|
||||
|
||||
#include <machine/machdep.h>
|
||||
|
||||
static void
|
||||
uart_ns8250_early_putc(int c)
|
||||
{
|
||||
volatile T *stat;
|
||||
volatile T *tx;
|
||||
|
||||
stat = (T *)(socdev_va + (REG_LSR << UART_NS8250_EARLY_REG_SHIFT));
|
||||
tx = (T *)(socdev_va + (REG_DATA << UART_NS8250_EARLY_REG_SHIFT));
|
||||
|
||||
while ((*stat & LSR_THRE) == 0)
|
||||
continue;
|
||||
*tx = c & 0xff;
|
||||
}
|
||||
#else
|
||||
#error ns8250 early putc is not implemented for current architecture
|
||||
#endif
|
||||
early_putc_t *early_putc = uart_ns8250_early_putc;
|
||||
#undef DTYPE
|
||||
#endif /* EARLY_PRINTF */
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user