FreeNOS
|
The PL011 is a commonly available UART device frequently found in ARM systems. More...
#include <PL011.h>
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 String & | getIdentifier () 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 SerialDevice * | create () |
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... | |
|
private |
The offsets and flags for each register in the UART.
PL011::PL011 | ( | const u32 | irq | ) |
|
virtual |
Initializes the UART.
Reimplemented from Device.
Definition at line 34 of file PL011.cpp.
References Memory::Device, DisableIRQ, EnableIRQ, FileSystem::IOError, isKernel, SerialDevice::m_io, SerialDevice::m_irq, IO::map(), PAGESIZE, PL011_CR, PL011_FBRD, PL011_IBRD, PL011_ICR, PL011_IMSC, PL011_IMSC_RXIM, PL011_LCRH, PL011_LCRH_WLEN_8BIT, ProcessCtl(), Memory::Readable, SELF, IO::setBase(), IO::Success, FileSystem::Success, Memory::User, Memory::Writable, and ARMIO::write().
Referenced by kernel_main().
|
virtual |
Called when an interrupt has been triggered for this device.
vector | Vector number of the interrupt. |
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().
|
virtual |
Read bytes from the device.
buffer | Input/Output buffer to output bytes to. |
size | Maximum number of bytes to read on input. On output, the actual number of bytes read. |
offset | Offset inside the file to start reading. |
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().
|
virtual |
Write bytes to the device.
buffer | Input/Output buffer to input bytes from. |
size | Maximum number of bytes to write on input. On output, the actual number of bytes written. |
offset | Offset inside the file to start writing. |
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().