FreeNOS
Public Member Functions | Private Types
i8250 Class Reference

i8250 serial UART. More...

#include <i8250.h>

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

Public Member Functions

 i8250 (const u32 irq, const u16 base)
 Constructor function. More...
 
virtual FileSystem::Result initialize ()
 Initializes the i8250 serial 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  Constants {
  TRANSMIT = 0, RECEIVE = 0, DIVISORLOW = 0, DIVISORHIGH = 1,
  RXREADY = 1, IRQCONTROL = 1, IRQSTATUS = 2, FIFOCONTROL = 2,
  LINECONTROL = 3, MODEMCONTROL = 4, LINESTATUS = 5, TXREADY = 0x20,
  DLAB = 0x80, BAUDRATE = 9600
}
 Constants used to communicate with 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

i8250 serial UART.

Definition at line 36 of file i8250.h.

Member Enumeration Documentation

◆ Constants

enum i8250::Constants
private

Constants used to communicate with the UART.

Enumerator
TRANSMIT 
RECEIVE 
DIVISORLOW 
DIVISORHIGH 
RXREADY 
IRQCONTROL 
IRQSTATUS 
FIFOCONTROL 
LINECONTROL 
MODEMCONTROL 
LINESTATUS 
TXREADY 
DLAB 
BAUDRATE 

Definition at line 43 of file i8250.h.

Constructor & Destructor Documentation

◆ i8250()

i8250::i8250 ( const u32  irq,
const u16  base 
)

Constructor function.

Parameters
irqInterrupt vector
baseI/O base port

Definition at line 29 of file i8250.cpp.

References Device::m_identifier, and SerialDevice::m_io.

Member Function Documentation

◆ initialize()

FileSystem::Result i8250::initialize ( )
virtual

Initializes the i8250 serial UART.

Returns
Result code

Reimplemented from Device.

Definition at line 36 of file i8250.cpp.

References BAUDRATE, DisableIRQ, DIVISORHIGH, DIVISORLOW, DLAB, EnableIRQ, FIFOCONTROL, IRQCONTROL, isKernel, LINECONTROL, SerialDevice::m_io, SerialDevice::m_irq, MODEMCONTROL, ProcessCtl(), SELF, and FileSystem::Success.

Referenced by kernel_main().

◆ interrupt()

FileSystem::Result i8250::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 72 of file i8250.cpp.

References EnableIRQ, SerialDevice::m_irq, ProcessCtl(), SELF, and FileSystem::Success.

◆ read()

FileSystem::Result i8250::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 78 of file i8250.cpp.

References IOBuffer::bufferedWrite(), LINESTATUS, SerialDevice::m_io, RECEIVE, FileSystem::RetryAgain, RXREADY, and FileSystem::Success.

◆ write()

FileSystem::Result i8250::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 104 of file i8250.cpp.

References LINESTATUS, SerialDevice::m_io, FileSystem::RetryAgain, FileSystem::Success, TRANSMIT, and TXREADY.


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