The Pedigree Project  0.1
kernel/machine/arm_beagle/Serial.h
1 /*
2  * Copyright (c) 2008-2014, Pedigree Developers
3  *
4  * Please see the CONTRIB file in the root of the source tree for a full
5  * list of contributors.
6  *
7  * Permission to use, copy, modify, and distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 #ifndef MACHINE_ARM_BEAGLE_SERIAL_H
21 #define MACHINE_ARM_BEAGLE_SERIAL_H
22 
23 #include "pedigree/kernel/machine/Serial.h"
24 #include "pedigree/kernel/processor/InterruptManager.h"
25 #include "pedigree/kernel/processor/MemoryRegion.h"
26 
28 class ArmBeagleSerial : public Serial, public InterruptHandler
29 {
30  public:
32  virtual ~ArmBeagleSerial();
33 
34  virtual void setBase(uintptr_t nBaseAddr);
35  virtual char read();
36  virtual char readNonBlock();
37  virtual void write(char c);
38 
39  virtual void interrupt(size_t nInterruptNumber, InterruptState &state);
40 
41  private:
43  void softReset();
44 
46  bool setFifoDefaults();
47 
51  bool configureProtocol();
52 
54  bool disableFlowControl();
55 
56  enum RegisterOffsets
57  {
58  DLL_REG = 0x00, // R/W
59  RHR_REG = 0x00, // R
60  THR_REG = 0x00, // W
61  DLH_REG = 0x04, // R/W
62  IER_REG = 0x04, // R/W
63  IIR_REG = 0x08, // R
64  FCR_REG = 0x08, // W
65  EFR_REG = 0x08, // RW
66  LCR_REG = 0x0C, // RW
67  MCR_REG = 0x10, // RW
68  XON1_ADDR1_REG = 0x10, // RW
69  LSR_REG = 0x14, // R
70  XON2_ADDR2_REG = 0x14, // RW
71  MSR_REG = 0x18, // R
72  TCR_REG = 0x18, // RW
73  XOFF1_REG = 0x18, // RW
74  SPR_REG = 0x1C, // RW
75  TLR_REG = 0x1C, // RW
76  XOFF2_REG = 0x1C, // RW
77  MDR1_REG = 0x20, // RW
78  MDR2_REG = 0x24, // RW
79 
80  USAR_REG = 0x38, // R
81 
82  SCR_REG = 0x40, // RW
83  SSR_REG = 0x44, // R
84 
85  MVR_REG = 0x50, // R
86  SYSC_REG = 0x54, // RW
87  SYSS_REG = 0x58, // R
88  WER_REG = 0x5C, // RW
89  };
90 
92  volatile uint8_t *m_Base;
93 
96 };
97 
98 #endif
void softReset()
Perform a software reset of this UART.
virtual void interrupt(size_t nInterruptNumber, InterruptState &state)
Implements the UART interface on the BeagleBoard.
bool setFifoDefaults()
Reset the FIFOs and DMA to default values.
Special memory entity in the kernel's virtual address space.
Definition: MemoryRegion.h:35
virtual void setBase(uintptr_t nBaseAddr)
Abstract base class for interrupt-handlers.
bool disableFlowControl()
Disables hardware flow control on the UART.