system/uart: refactor debug_uart, fix arm uart
* Drop ArchUART8260 layer to reduce complexity. It's whole existance in life was to adjust the mmio alignment. * Fold architecture mmio alignment into DebugUart * We could potentially pass a Init(int mmioAlignment) arg in the future if the macros get too messy. * Move Barrier code back a layer into DebugUART * Fixes the arm uart and EFI build Change-Id: I0f127d902993e9f6e6a03cac8c7c37c0363134bf Reviewed-on: https://review.haiku-os.org/c/haiku/+/4422 Reviewed-by: Alex von Gluck IV <kallisti5@unixzen.com> Reviewed-by: waddlesplash <waddlesplash@gmail.com> Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
This commit is contained in:
parent
34fef46b06
commit
7068c45485
@ -40,12 +40,9 @@ public:
|
||||
bool Enabled() const { return fEnabled; }
|
||||
|
||||
protected:
|
||||
// default MMIO
|
||||
virtual void Out8(int reg, uint8 value)
|
||||
{ *((uint8 *)Base() + reg) = value; }
|
||||
virtual uint8 In8(int reg)
|
||||
{ return *((uint8 *)Base() + reg); }
|
||||
virtual void Barrier() {}
|
||||
virtual void Out8(int reg, uint8 value);
|
||||
virtual uint8 In8(int reg);
|
||||
virtual void Barrier();
|
||||
|
||||
private:
|
||||
addr_t fBase;
|
||||
|
@ -34,8 +34,6 @@ public:
|
||||
|
||||
void FlushTx();
|
||||
void FlushRx();
|
||||
|
||||
virtual void Barrier();
|
||||
};
|
||||
|
||||
|
||||
|
@ -17,7 +17,7 @@ local kernelLibArchObjects =
|
||||
|
||||
local kernelArchSources =
|
||||
arch_elf.cpp
|
||||
arch_uart_8250.cpp
|
||||
arch_uart_pl011.cpp
|
||||
;
|
||||
|
||||
local kernelDebugSources =
|
||||
@ -28,6 +28,7 @@ local kernelDebugSources =
|
||||
;
|
||||
|
||||
local kernelGenericDriverSources =
|
||||
debug_uart.cpp
|
||||
debug_uart_8250.cpp
|
||||
;
|
||||
|
||||
|
@ -6,14 +6,18 @@ local kernelLibArchObjects =
|
||||
<src!system!kernel!lib!arch!$(TARGET_ARCH)>memset.o
|
||||
;
|
||||
|
||||
local kernelGenericDriverSources =
|
||||
debug_uart.cpp
|
||||
debug_uart_8250.cpp
|
||||
;
|
||||
|
||||
local platform ;
|
||||
for platform in [ MultiBootSubDirSetup openfirmware ] {
|
||||
on $(platform) {
|
||||
DEFINES += _BOOT_MODE ;
|
||||
|
||||
BootMergeObject [ FGristFiles boot_arch_$(TARGET_KERNEL_ARCH).o ] :
|
||||
debug_uart_8250.cpp
|
||||
#arch_uart_8250.cpp
|
||||
$(kernelGenericDriverSources)
|
||||
arch_elf.cpp
|
||||
: # additional flags
|
||||
:
|
||||
@ -24,7 +28,7 @@ for platform in [ MultiBootSubDirSetup openfirmware ] {
|
||||
SEARCH on [ FGristFiles arch_elf.cpp arch_uart_8250.cpp ]
|
||||
= [ FDirName $(HAIKU_TOP) src system kernel arch $(TARGET_KERNEL_ARCH) ] ;
|
||||
|
||||
SEARCH on [ FGristFiles debug_uart_8250.cpp ]
|
||||
SEARCH on [ FGristFiles $(kernelGenericDriverSources) ]
|
||||
= [ FDirName $(HAIKU_TOP) src system kernel arch generic ] ;
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ local kernelArchDriverSources =
|
||||
;
|
||||
|
||||
local kernelGenericDriverSources =
|
||||
debug_uart.cpp
|
||||
debug_uart_8250.cpp
|
||||
;
|
||||
|
||||
|
@ -5,14 +5,18 @@ local kernelLibArchObjects =
|
||||
<src!system!kernel!lib!arch!$(TARGET_ARCH)>memset.o
|
||||
;
|
||||
|
||||
local kernelGenericDriverSources =
|
||||
debug_uart.cpp
|
||||
debug_uart_8250.cpp
|
||||
;
|
||||
|
||||
local platform ;
|
||||
for platform in [ MultiBootSubDirSetup openfirmware ] {
|
||||
on $(platform) {
|
||||
DEFINES += _BOOT_MODE ;
|
||||
|
||||
BootMergeObject [ FGristFiles boot_arch_$(TARGET_KERNEL_ARCH).o ] :
|
||||
debug_uart_8250.cpp
|
||||
#arch_uart_8250.cpp
|
||||
$(kernelGenericDriverSources)
|
||||
arch_elf.cpp
|
||||
: # additional flags
|
||||
:
|
||||
@ -23,7 +27,7 @@ for platform in [ MultiBootSubDirSetup openfirmware ] {
|
||||
SEARCH on [ FGristFiles arch_elf.cpp arch_uart_8250.cpp ]
|
||||
= [ FDirName $(HAIKU_TOP) src system kernel arch $(TARGET_KERNEL_ARCH) ] ;
|
||||
|
||||
SEARCH on [ FGristFiles debug_uart_8250.cpp ]
|
||||
SEARCH on [ FGristFiles $(kernelGenericDriverSources) ]
|
||||
= [ FDirName $(HAIKU_TOP) src system kernel arch generic ] ;
|
||||
}
|
||||
}
|
||||
|
@ -27,8 +27,8 @@ KernelMergeObject kernel_arch_arm.o :
|
||||
arch_asm.S
|
||||
|
||||
# Serial UART and drivers
|
||||
debug_uart.cpp
|
||||
debug_uart_8250.cpp
|
||||
arch_uart_8250.cpp
|
||||
arch_uart_8250_omap.cpp
|
||||
arch_uart_pl011.cpp
|
||||
|
||||
|
@ -1,82 +0,0 @@
|
||||
/*
|
||||
* Copyright 2011-2012 Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* François Revol, revol@free.fr
|
||||
*/
|
||||
|
||||
|
||||
#include <arch/arm/reg.h>
|
||||
#include <arch/generic/debug_uart_8250.h>
|
||||
#include <debug.h>
|
||||
#include <new>
|
||||
|
||||
|
||||
class ArchUART8250 : public DebugUART8250 {
|
||||
public:
|
||||
ArchUART8250(addr_t base, int64 clock);
|
||||
~ArchUART8250();
|
||||
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);
|
||||
};
|
||||
|
||||
|
||||
ArchUART8250::ArchUART8250(addr_t base, int64 clock)
|
||||
:
|
||||
DebugUART8250(base, clock)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
ArchUART8250::~ArchUART8250()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ArchUART8250::InitEarly()
|
||||
{
|
||||
// Perform special hardware UART configuration
|
||||
#warning TODO: Detect OMAP3 from fdt!
|
||||
#if BOARD_CPU_OMAP3
|
||||
/* UART1 */
|
||||
RMWREG32(CM_FCLKEN1_CORE, 13, 1, 1);
|
||||
RMWREG32(CM_ICLKEN1_CORE, 13, 1, 1);
|
||||
|
||||
/* UART2 */
|
||||
RMWREG32(CM_FCLKEN1_CORE, 14, 1, 1);
|
||||
RMWREG32(CM_ICLKEN1_CORE, 14, 1, 1);
|
||||
|
||||
/* UART3 */
|
||||
RMWREG32(CM_FCLKEN_PER, 11, 1, 1);
|
||||
RMWREG32(CM_ICLKEN_PER, 11, 1, 1);
|
||||
#else
|
||||
#warning INTITIALIZE UART!!!!!
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ArchUART8250::Out8(int reg, uint8 value)
|
||||
{
|
||||
*((uint8 *)Base() + reg * sizeof(uint32)) = value;
|
||||
}
|
||||
|
||||
|
||||
uint8
|
||||
ArchUART8250::In8(int reg)
|
||||
{
|
||||
return *((uint8 *)Base() + reg * sizeof(uint32));
|
||||
}
|
||||
|
||||
|
||||
DebugUART8250 *arch_get_uart_8250(addr_t base, int64 clock)
|
||||
{
|
||||
static char buffer[sizeof(ArchUART8250)];
|
||||
ArchUART8250 *uart = new(buffer) ArchUART8250(base, clock);
|
||||
return uart;
|
||||
}
|
43
src/system/kernel/arch/generic/debug_uart.cpp
Normal file
43
src/system/kernel/arch/generic/debug_uart.cpp
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright 2006-2021, Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include <arch/generic/debug_uart.h>
|
||||
|
||||
|
||||
void
|
||||
DebugUART::Out8(int reg, uint8 value)
|
||||
{
|
||||
#ifdef __ARM__
|
||||
// 32-bit aligned
|
||||
*((uint8 *)Base() + reg * sizeof(uint32)) = value;
|
||||
#else
|
||||
*((uint8 *)Base() + reg) = value;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
uint8
|
||||
DebugUART::In8(int reg)
|
||||
{
|
||||
#ifdef __ARM__
|
||||
// 32-bit aligned
|
||||
return *((uint8 *)Base() + reg * sizeof(uint32));
|
||||
#else
|
||||
return *((uint8 *)Base() + reg);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DebugUART::Barrier()
|
||||
{
|
||||
// Simple memory barriers
|
||||
#if defined(__POWERPC__)
|
||||
asm volatile("eieio; sync");
|
||||
#elif defined(__ARM__)
|
||||
asm volatile ("" : : : "memory");
|
||||
#endif
|
||||
}
|
@ -177,18 +177,6 @@ DebugUART8250::FlushRx()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DebugUART8250::Barrier()
|
||||
{
|
||||
// Simple memory barriers
|
||||
#if defined(__POWERPC__)
|
||||
asm volatile("eieio; sync");
|
||||
#elif defined(__ARM__)
|
||||
asm volatile ("" : : : "memory");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
DebugUART8250*
|
||||
arch_get_uart_8250(addr_t base, int64 clock)
|
||||
{
|
||||
|
@ -56,6 +56,7 @@ KernelMergeObject kernel_arch_ppc.o :
|
||||
arch_asm.S
|
||||
|
||||
# serial uart
|
||||
debug_uart.cpp
|
||||
debug_uart_8250.cpp
|
||||
|
||||
# paging
|
||||
|
@ -6,30 +6,32 @@ UsePrivateKernelHeaders ;
|
||||
SEARCH_SOURCE += [ FDirName $(SUBDIR) $(DOTDOT) generic ] ;
|
||||
|
||||
KernelMergeObject kernel_arch_riscv64.o :
|
||||
arch_asm.S
|
||||
arch_traps.S
|
||||
arch_commpage.cpp
|
||||
arch_cpu.cpp
|
||||
arch_debug.cpp
|
||||
arch_debug_console.cpp
|
||||
arch_elf.cpp
|
||||
arch_int.cpp
|
||||
arch_platform.cpp
|
||||
arch_real_time_clock.cpp
|
||||
arch_smp.cpp
|
||||
arch_system_info.cpp
|
||||
arch_timer.cpp
|
||||
arch_thread.cpp
|
||||
arch_user_debugger.cpp
|
||||
arch_vm.cpp
|
||||
arch_vm_translation_map.cpp
|
||||
RISCV64VMTranslationMap.cpp
|
||||
Htif.cpp
|
||||
sbi_syscalls.S
|
||||
arch_asm.S
|
||||
arch_traps.S
|
||||
arch_commpage.cpp
|
||||
arch_cpu.cpp
|
||||
arch_debug.cpp
|
||||
arch_debug_console.cpp
|
||||
arch_elf.cpp
|
||||
arch_int.cpp
|
||||
arch_platform.cpp
|
||||
arch_real_time_clock.cpp
|
||||
arch_smp.cpp
|
||||
arch_system_info.cpp
|
||||
arch_timer.cpp
|
||||
arch_thread.cpp
|
||||
arch_user_debugger.cpp
|
||||
arch_vm.cpp
|
||||
arch_vm_translation_map.cpp
|
||||
RISCV64VMTranslationMap.cpp
|
||||
Htif.cpp
|
||||
sbi_syscalls.S
|
||||
|
||||
debug_uart_8250.cpp
|
||||
arch_uart_sifive.cpp
|
||||
:
|
||||
$(TARGET_KERNEL_PIC_CCFLAGS) -Wno-unused
|
||||
:
|
||||
# Serial UART drivers
|
||||
debug_uart.cpp
|
||||
debug_uart_8250.cpp
|
||||
arch_uart_sifive.cpp
|
||||
:
|
||||
$(TARGET_KERNEL_PIC_CCFLAGS) -Wno-unused
|
||||
:
|
||||
;
|
||||
|
Loading…
Reference in New Issue
Block a user