Attempt to factor out serial stuff
* introduce a DebugUART baseclass, * rework 8250 and PL011 implementations from kallisti5 to inherit DebutUART, * each arch should override the IO methods to access registers. * on ARM registers are 32bit-aligned. * U-Boot still works for the verdex target. * rPi still compiles, needs testing. * Still some more consolidation needed to allow runtime choice of the UART type (as read from FDT blobs for ex.). * serial.cpp should probably mostly be made generic as well. * didn't touch x86 or ppc yet.
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright 2011-2012 Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Alexander von Gluck, [email protected]
|
||||
*/
|
||||
#ifndef __DEV_UART_PL011_H
|
||||
#define __DEV_UART_PL011_H
|
||||
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <SupportDefs.h>
|
||||
#include <arch/generic/debug_uart.h>
|
||||
|
||||
class ArchUARTPL011 : public DebugUART {
|
||||
public:
|
||||
ArchUARTPL011(addr_t base, int64 clock);
|
||||
~ArchUARTPL011();
|
||||
|
||||
void InitEarly();
|
||||
void InitPort(uint32 baud);
|
||||
|
||||
void Enable();
|
||||
void Disable();
|
||||
|
||||
int PutChar(char c);
|
||||
int GetChar(bool wait);
|
||||
|
||||
void FlushTx();
|
||||
void FlushRx();
|
||||
|
||||
private:
|
||||
void Out32(int reg, uint32 value);
|
||||
uint32 In32(int reg);
|
||||
virtual void Barrier();
|
||||
};
|
||||
|
||||
|
||||
ArchUARTPL011 *arch_get_uart_pl011(addr_t base, int64 clock);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright 2012 Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* François Revol, [email protected]
|
||||
*/
|
||||
#ifndef _KERNEL_ARCH_DEBUG_UART_H
|
||||
#define _KERNEL_ARCH_DEBUG_UART_H
|
||||
|
||||
|
||||
#include <SupportDefs.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
|
||||
class DebugUART {
|
||||
public:
|
||||
DebugUART(addr_t base, int64 clock)
|
||||
: fBase(base),
|
||||
fClock(clock),
|
||||
fEnabled(true) {};
|
||||
~DebugUART() {};
|
||||
|
||||
virtual void InitEarly() {};
|
||||
virtual void Init() {};
|
||||
virtual void InitPort(uint32 baud) {};
|
||||
|
||||
virtual void Enable() { fEnabled = true; }
|
||||
virtual void Disable() { fEnabled = false; }
|
||||
|
||||
virtual int PutChar(char c) = 0;
|
||||
virtual int GetChar(bool wait) = 0;
|
||||
|
||||
virtual void FlushTx() = 0;
|
||||
virtual void FlushRx() = 0;
|
||||
|
||||
addr_t Base() const { return fBase; }
|
||||
int64 Clock() const { return fClock; }
|
||||
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() {}
|
||||
|
||||
private:
|
||||
addr_t fBase;
|
||||
int64 fClock;
|
||||
bool fEnabled;
|
||||
};
|
||||
|
||||
|
||||
#endif /* _KERNEL_ARCH_DEBUG_UART_H */
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright 2012 Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* François Revol, [email protected]
|
||||
*/
|
||||
#ifndef _KERNEL_ARCH_DEBUG_UART_8250_H
|
||||
#define _KERNEL_ARCH_DEBUG_UART_8250_H
|
||||
|
||||
|
||||
#include <SupportDefs.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "debug_uart.h"
|
||||
|
||||
|
||||
class DebugUART8250 : public DebugUART {
|
||||
public:
|
||||
DebugUART8250(addr_t base, int64 clock);
|
||||
~DebugUART8250();
|
||||
|
||||
void InitEarly();
|
||||
void Init();
|
||||
void InitPort(uint32 baud);
|
||||
|
||||
int PutChar(char c);
|
||||
int GetChar(bool wait);
|
||||
|
||||
void FlushTx();
|
||||
void FlushRx();
|
||||
};
|
||||
|
||||
|
||||
extern DebugUART8250 *arch_get_uart_8250(addr_t base, int64 clock);
|
||||
|
||||
#endif /* _KERNEL_ARCH_DEBUG_UART_8250_H */
|
||||
Reference in New Issue
Block a user