1 /* 2 * Copyright 2012 Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * François Revol, revol@free.fr 7 */ 8 #ifndef _KERNEL_ARCH_DEBUG_UART_H 9 #define _KERNEL_ARCH_DEBUG_UART_H 10 11 12 #include <sys/types.h> 13 14 #include <SupportDefs.h> 15 16 17 class DebugUART { 18 public: 19 DebugUART(addr_t base, int64 clock) 20 : fBase(base), 21 fClock(clock), 22 fEnabled(true) {}; 23 ~DebugUART() {}; 24 25 virtual void InitEarly() {}; 26 virtual void Init() {}; 27 virtual void InitPort(uint32 baud) {}; 28 29 virtual void Enable() { fEnabled = true; } 30 virtual void Disable() { fEnabled = false; } 31 32 virtual int PutChar(char c) = 0; 33 virtual int GetChar(bool wait) = 0; 34 35 virtual void FlushTx() = 0; 36 virtual void FlushRx() = 0; 37 38 addr_t Base() const { return fBase; } 39 int64 Clock() const { return fClock; } 40 bool Enabled() const { return fEnabled; } 41 42 protected: 43 virtual void Out8(int reg, uint8 value); 44 virtual uint8 In8(int reg); 45 virtual void Barrier(); 46 47 private: 48 addr_t fBase; 49 int64 fClock; 50 bool fEnabled; 51 }; 52 53 54 #endif /* _KERNEL_ARCH_DEBUG_UART_H */ 55