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 <[email protected]>
Reviewed-by: Jessica Hamilton <[email protected]>
Tested-by: Commit checker robot <[email protected]>
This commit is contained in:
Alexander von Gluck IV
2021-08-16 23:22:35 +00:00
committed by Alex von Gluck IV
parent c39da9b7a0
commit 1648ab5277
9 changed files with 71 additions and 58 deletions
@@ -0,0 +1,36 @@
/*
* Copyright 2012-2021 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* François Revol, [email protected]
* Alexander von Gluck IV, [email protected]
*/
#ifndef _KERNEL_ARCH_DEBUG_UART_8250_OMAP_H
#define _KERNEL_ARCH_DEBUG_UART_8250_OMAP_H
#include <sys/types.h>
#include <SupportDefs.h>
#include <arch/generic/debug_uart_8250.h>
#include "debug_uart.h"
class ArchUART8250Omap : public DebugUART8250 {
public:
ArchUART8250Omap(addr_t base, int64 clock);
~ArchUART8250Omap();
void InitEarly();
// ARM MMIO: on ARM the UART regs are aligned on 32bit
virtual void Out8(int reg, uint8 value);
virtual uint8 In8(int reg);
};
DebugUART8250* arch_get_uart_8250_omap(addr_t base, int64 clock);
#endif /* _KERNEL_ARCH_DEBUG_UART_8250_OMAP_H */
@@ -1,5 +1,5 @@
/* /*
* Copyright 2012 Haiku, Inc. All rights reserved. * Copyright 2012-2021 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -33,8 +33,7 @@ public:
}; };
extern DebugUART8250 *arch_get_uart_8250(addr_t base, int64 clock); DebugUART8250* arch_get_uart_8250(addr_t base, int64 clock);
extern DebugUART8250 *arch_get_uart_8250_omap(addr_t base, int64 clock);
#endif /* _KERNEL_ARCH_DEBUG_UART_8250_H */ #endif /* _KERNEL_ARCH_DEBUG_UART_8250_H */
@@ -1,8 +1,7 @@
/* /*
* Copyright 2021, Haiku, Inc. * Copyright 2021, Haiku, Inc. All rights reserved
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#ifndef _ARCH_UART_SIFIVE_H_ #ifndef _ARCH_UART_SIFIVE_H_
#define _ARCH_UART_SIFIVE_H_ #define _ARCH_UART_SIFIVE_H_
@@ -97,4 +96,7 @@ ArchUARTSifive::Regs()
} }
ArchUARTSifive* arch_get_uart_sifive(addr_t base, int64 clock);
#endif // _ARCH_UART_SIFIVE_H_ #endif // _ARCH_UART_SIFIVE_H_
-18
View File
@@ -40,24 +40,6 @@ static addr_range sClint = {0};
static ArchUart sUart = {.kind = kUartKindNone}; static ArchUart sUart = {.kind = kUartKindNone};
DebugUART8250*
arch_get_uart_8250(addr_t base, int64 clock)
{
static char buffer[sizeof(DebugUART8250)];
DebugUART8250* uart = new(buffer) DebugUART8250(base, clock);
return uart;
}
ArchUARTSifive*
arch_get_uart_sifive(addr_t base, int64 clock)
{
static char buffer[sizeof(ArchUARTSifive)];
ArchUARTSifive* uart = new(buffer) ArchUARTSifive(base, clock);
return uart;
}
static void WriteString(const char *str) {dprintf("%s", str);} static void WriteString(const char *str) {dprintf("%s", str);}
static void WriteLn() {dprintf("\n");} static void WriteLn() {dprintf("\n");}
static void WriteHex(uint64_t val, int n) {dprintf("%08" B_PRIx64, val);} static void WriteHex(uint64_t val, int n) {dprintf("%08" B_PRIx64, val);}
@@ -8,24 +8,12 @@
#include <arch/arm/reg.h> #include <arch/arm/reg.h>
#include <arch/generic/debug_uart_8250.h> #include <arch/arm/debug_uart_8250_omap.h>
#include <debug.h> #include <debug.h>
#include <omap3.h> #include <omap3.h>
#include <new> #include <new>
class ArchUART8250Omap : public DebugUART8250 {
public:
ArchUART8250Omap(addr_t base, int64 clock);
~ArchUART8250Omap();
void InitEarly();
// ARM MMIO: on ARM the UART regs are aligned on 32bit
virtual void Out8(int reg, uint8 value);
virtual uint8 In8(int reg);
};
ArchUART8250Omap::ArchUART8250Omap(addr_t base, int64 clock) ArchUART8250Omap::ArchUART8250Omap(addr_t base, int64 clock)
: :
DebugUART8250(base, clock) DebugUART8250(base, clock)
@@ -70,9 +58,10 @@ ArchUART8250Omap::In8(int reg)
} }
DebugUART8250 *arch_get_uart_8250_omap(addr_t base, int64 clock) DebugUART8250*
arch_get_uart_8250_omap(addr_t base, int64 clock)
{ {
static char buffer[sizeof(ArchUART8250Omap)]; static char buffer[sizeof(ArchUART8250Omap)];
ArchUART8250Omap *uart = new(buffer) ArchUART8250Omap(base, clock); ArchUART8250Omap* uart = new(buffer) ArchUART8250Omap(base, clock);
return uart; return uart;
} }
@@ -319,7 +319,8 @@ ArchUARTPL011::FlushRx()
} }
ArchUARTPL011 *arch_get_uart_pl011(addr_t base, int64 clock) ArchUARTPL011*
arch_get_uart_pl011(addr_t base, int64 clock)
{ {
static char buffer[sizeof(ArchUARTPL011)]; static char buffer[sizeof(ArchUARTPL011)];
ArchUARTPL011 *uart = new(buffer) ArchUARTPL011(base, clock); ArchUARTPL011 *uart = new(buffer) ArchUARTPL011(base, clock);
@@ -22,8 +22,9 @@
*/ */
#include <debug.h>
#include <arch/generic/debug_uart_8250.h> #include <arch/generic/debug_uart_8250.h>
#include <debug.h>
#include <new>
DebugUART8250::DebugUART8250(addr_t base, int64 clock) DebugUART8250::DebugUART8250(addr_t base, int64 clock)
@@ -174,3 +175,13 @@ DebugUART8250::FlushRx()
(void)c; (void)c;
} }
} }
DebugUART8250*
arch_get_uart_8250(addr_t base, int64 clock)
{
static char buffer[sizeof(DebugUART8250)];
DebugUART8250* uart = new(buffer) DebugUART8250(base, clock);
return uart;
}
@@ -22,24 +22,6 @@
static DebugUART* sArchDebugUART = NULL; static DebugUART* sArchDebugUART = NULL;
DebugUART8250*
arch_get_uart_8250(addr_t base, int64 clock)
{
static char buffer[sizeof(DebugUART8250)];
DebugUART8250* uart = new(buffer) DebugUART8250(base, clock);
return uart;
}
ArchUARTSifive*
arch_get_uart_sifive(addr_t base, int64 clock)
{
static char buffer[sizeof(ArchUARTSifive)];
ArchUARTSifive* uart = new(buffer) ArchUARTSifive(base, clock);
return uart;
}
void void
arch_debug_remove_interrupt_handler(uint32 line) arch_debug_remove_interrupt_handler(uint32 line)
{ {
@@ -3,7 +3,9 @@
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#include <arch/riscv64/arch_uart_sifive.h> #include <arch/riscv64/arch_uart_sifive.h>
#include <new>
ArchUARTSifive::ArchUARTSifive(addr_t base, int64 clock) ArchUARTSifive::ArchUARTSifive(addr_t base, int64 clock)
@@ -104,3 +106,12 @@ ArchUARTSifive::Barrier()
{ {
asm volatile ("" : : : "memory"); asm volatile ("" : : : "memory");
} }
ArchUARTSifive*
arch_get_uart_sifive(addr_t base, int64 clock)
{
static char buffer[sizeof(ArchUARTSifive)];
ArchUARTSifive* uart = new(buffer) ArchUARTSifive(base, clock);
return uart;
}