FreeNOS
Public Member Functions | Private Types
PL011 Class Reference

The PL011 is a commonly available UART device frequently found in ARM systems. More...

#include <PL011.h>

Inheritance diagram for PL011:
SerialDevice Device AbstractFactory< SerialDevice > File

Public Member Functions

 PL011 (const u32 irq)
 Constructor. More...
 
virtual FileSystem::Result initialize ()
 Initializes the UART. More...
 
virtual FileSystem::Result interrupt (const Size vector)
 Called when an interrupt has been triggered for this device. More...
 
virtual FileSystem::Result read (IOBuffer &buffer, Size &size, const Size offset)
 Read bytes from the device. More...
 
virtual FileSystem::Result write (IOBuffer &buffer, Size &size, const Size offset)
 Write bytes to the device. More...
 
- Public Member Functions inherited from SerialDevice
 SerialDevice (const u32 irq)
 Constructor. More...
 
u32 getIrq () const
 Get interrupt vector. More...
 
- Public Member Functions inherited from Device
 Device (const u32 inode, const FileSystem::FileType type)
 Constructor. More...
 
virtual ~Device ()
 Destructor. More...
 
virtual const StringgetIdentifier () const
 Get unique device identifier. More...
 
- Public Member Functions inherited from File
 File (const u32 inode, const FileSystem::FileType type=FileSystem::RegularFile, const UserID uid=ZERO, const GroupID gid=ZERO)
 Constructor function. More...
 
virtual ~File ()
 Destructor function. More...
 
u32 getInode () const
 Get inode number. More...
 
FileSystem::FileType getType () const
 Retrieve our filetype. More...
 
virtual FileSystem::Result status (FileSystem::FileStat &st)
 Retrieve file statistics. More...
 
virtual bool canRead () const
 Check if the File has data ready for reading. More...
 
virtual bool canWrite () const
 Check if the File can be written to. More...
 

Private Types

enum  {
  PL011_DR = (0x00), PL011_RSRECR = (0x04), PL011_FR = (0x18), PL011_FR_RXFE = (1 << 4),
  PL011_FR_TXFE = (1 << 7), PL011_ILPR = (0x20), PL011_IBRD = (0x24), PL011_FBRD = (0x28),
  PL011_LCRH = (0x2C), PL011_LCRH_WLEN_8BIT = (0b11<<5), PL011_CR = (0x30), PL011_IFLS = (0x34),
  PL011_IMSC = (0x38), PL011_IMSC_RXIM = (1 << 4), PL011_IMSC_TXIM = (1 << 5), PL011_RIS = (0x3C),
  PL011_MIS = (0x40), PL011_MIS_RXMIS = (1 << 4), PL011_MIS_TXMIS = (1 << 5), PL011_ICR = (0x44),
  PL011_ICR_TXIC = (1 << 5), PL011_ICR_RXIC = (1 << 4), PL011_DMACR = (0x48), PL011_ITCR = (0x80),
  PL011_ITIP = (0x84), PL011_ITOP = (0x88), PL011_TDR = (0x8C)
}
 The offsets and flags for each register in the UART. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from AbstractFactory< SerialDevice >
static SerialDevicecreate ()
 Abstract function to create an instance of T. More...
 
- Static Public Attributes inherited from SerialDevice
static u32 inodeNumber = 2
 Keeps track of inode number for SerialDevices. More...
 
- Protected Attributes inherited from SerialDevice
const u32 m_irq
 interrupt vector More...
 
Arch::IO m_io
 I/O instance. More...
 
- Protected Attributes inherited from Device
String m_identifier
 Unique identifier for this Device. More...
 
- Protected Attributes inherited from File
const u32 m_inode
 Inode number. More...
 
const FileSystem::FileType m_type
 Type of this file. More...
 
UserID m_uid
 Owner of the file. More...
 
GroupID m_gid
 Group of the file. More...
 
FileSystem::FileModes m_access
 Access permissions. More...
 
Size m_size
 Size of the file, in bytes. More...
 

Detailed Description

The PL011 is a commonly available UART device frequently found in ARM systems.

See also
ARM

Definition at line 39 of file PL011.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private

The offsets and flags for each register in the UART.

Enumerator
PL011_DR 
PL011_RSRECR 
PL011_FR 
PL011_FR_RXFE 
PL011_FR_TXFE 
PL011_ILPR 
PL011_IBRD 
PL011_FBRD 
PL011_LCRH 
PL011_LCRH_WLEN_8BIT 
PL011_CR 
PL011_IFLS 
PL011_IMSC 
PL011_IMSC_RXIM 
PL011_IMSC_TXIM 
PL011_RIS 
PL011_MIS 
PL011_MIS_RXMIS 
PL011_MIS_TXMIS 
PL011_ICR 
PL011_ICR_TXIC 
PL011_ICR_RXIC 
PL011_DMACR 
PL011_ITCR 
PL011_ITIP 
PL011_ITOP 
PL011_TDR 

Definition at line 46 of file PL011.h.

Constructor & Destructor Documentation

◆ PL011()

PL011::PL011 ( const u32  irq)

Constructor.

Definition at line 28 of file PL011.cpp.

References Device::m_identifier.

Member Function Documentation

◆ initialize()

FileSystem::Result PL011::initialize ( )
virtual

◆ interrupt()

FileSystem::Result PL011::interrupt ( const Size  vector)
virtual

Called when an interrupt has been triggered for this device.

Parameters
vectorVector number of the interrupt.
Returns
Result code

Reimplemented from Device.

Definition at line 87 of file PL011.cpp.

References EnableIRQ, isKernel, SerialDevice::m_io, SerialDevice::m_irq, PL011_ICR, PL011_ICR_RXIC, PL011_ICR_TXIC, PL011_MIS, PL011_MIS_RXMIS, PL011_MIS_TXMIS, ProcessCtl(), ARMIO::read(), SELF, FileSystem::Success, and ARMIO::write().

◆ read()

FileSystem::Result PL011::read ( IOBuffer buffer,
Size size,
const Size  offset 
)
virtual

Read bytes from the device.

Parameters
bufferInput/Output buffer to output bytes to.
sizeMaximum number of bytes to read on input. On output, the actual number of bytes read.
offsetOffset inside the file to start reading.
Returns
Result code

Reimplemented from File.

Definition at line 108 of file PL011.cpp.

References IOBuffer::bufferedWrite(), IOBuffer::getCount(), SerialDevice::m_io, PL011_DR, PL011_FR, PL011_FR_RXFE, PL011_ICR, PL011_ICR_RXIC, PL011_MIS, PL011_MIS_RXMIS, ARMIO::read(), FileSystem::RetryAgain, FileSystem::Success, and ARMIO::write().

◆ write()

FileSystem::Result PL011::write ( IOBuffer buffer,
Size size,
const Size  offset 
)
virtual

Write bytes to the device.

Parameters
bufferInput/Output buffer to input bytes from.
sizeMaximum number of bytes to write on input. On output, the actual number of bytes written.
offsetOffset inside the file to start writing.
Returns
Result code

Reimplemented from File.

Definition at line 139 of file PL011.cpp.

References SerialDevice::m_io, PL011_DR, PL011_FR, PL011_FR_TXFE, PL011_ICR, PL011_ICR_TXIC, PL011_MIS, PL011_MIS_TXMIS, ARMIO::read(), FileSystem::RetryAgain, FileSystem::Success, and ARMIO::write().


The documentation for this class was generated from the following files: