Files
haiku-beta6/headers/private/kernel/arch/generic/debug_uart.h
T

58 lines
1.2 KiB
C++
Raw Normal View History

2012-05-17 04:03:16 +02:00
/*
* 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 <sys/types.h>
2012-05-17 03:31:02 -05:00
#include <SupportDefs.h>
2012-05-17 04:03:16 +02:00
class DebugUART {
public:
DebugUART(addr_t base, int64 clock)
: fBase(base),
fClock(clock),
fEnabled(true) {};
~DebugUART() {};
2012-05-17 03:31:02 -05:00
virtual void InitEarly() {};
virtual void Init() {};
virtual void InitPort(uint32 baud) {};
2012-05-17 04:03:16 +02:00
2012-05-17 03:31:02 -05:00
virtual void Enable() { fEnabled = true; }
virtual void Disable() { fEnabled = false; }
2012-05-17 04:03:16 +02:00
2012-05-17 03:31:02 -05:00
virtual int PutChar(char c) = 0;
virtual int GetChar(bool wait) = 0;
2012-05-17 04:03:16 +02:00
2012-05-17 03:31:02 -05:00
virtual void FlushTx() = 0;
virtual void FlushRx() = 0;
2012-05-17 04:03:16 +02:00
2012-05-17 03:31:02 -05:00
addr_t Base() const { return fBase; }
int64 Clock() const { return fClock; }
bool Enabled() const { return fEnabled; }
2012-05-17 04:03:16 +02:00
protected:
// default MMIO
2012-05-17 03:31:02 -05:00
virtual void Out8(int reg, uint8 value)
2012-05-17 04:03:16 +02:00
{ *((uint8 *)Base() + reg) = value; }
2012-05-17 03:31:02 -05:00
virtual uint8 In8(int reg)
2012-05-17 04:03:16 +02:00
{ return *((uint8 *)Base() + reg); }
2012-05-17 03:31:02 -05:00
virtual void Barrier() {}
2012-05-17 04:03:16 +02:00
private:
2012-05-17 03:31:02 -05:00
addr_t fBase;
int64 fClock;
bool fEnabled;
2012-05-17 04:03:16 +02:00
};
#endif /* _KERNEL_ARCH_DEBUG_UART_H */