FreeNOS
|
Abstract Input/Output buffer. More...
#include <IOBuffer.h>
Public Member Functions | |
IOBuffer () | |
Default empty constructor. More... | |
IOBuffer (const FileSystemMessage *msg) | |
Constructor. More... | |
virtual | ~IOBuffer () |
Destructor. More... | |
Size | getCount () const |
Get byte count. More... | |
void | addCount (const Size bytes) |
Increment byte counter. More... | |
void | setMessage (const FileSystemMessage *msg) |
Set filesystem message. More... | |
const FileSystemMessage * | getMessage () const |
Get filesystem message. More... | |
u8 * | getBuffer () |
Get raw buffer. More... | |
FileSystem::Result | read (void *buffer, const Size size, const Size offset=ZERO) |
Read bytes from the I/O buffer. More... | |
FileSystem::Result | write (const void *buffer, const Size size, const Size offset=ZERO) |
Write bytes to the I/O buffer. More... | |
FileSystem::Result | bufferedRead () |
Buffered read bytes from the I/O buffer. More... | |
FileSystem::Result | bufferedWrite (const void *buffer, const Size size) |
Buffered write bytes to the I/O buffer. More... | |
FileSystem::Result | flushWrite () |
Flush write buffers. More... | |
u8 | operator[] (Size index) const |
Byte index operator. More... | |
Private Attributes | |
const FileSystemMessage * | m_message |
Current request being processed. More... | |
bool | m_directMapped |
True if using directly memory-mapped memory (unbuffered) More... | |
Memory::Range | m_directMapRange |
Contains the memory address range of the direct memory mapping. More... | |
u8 * | m_buffer |
Buffer for storing temporary data. More... | |
Size | m_size |
Buffer size. More... | |
Size | m_count |
Bytes written to the buffer. More... | |
Abstract Input/Output buffer.
Definition at line 37 of file IOBuffer.h.
IOBuffer::IOBuffer | ( | ) |
Default empty constructor.
Definition at line 24 of file IOBuffer.cpp.
IOBuffer::IOBuffer | ( | const FileSystemMessage * | msg | ) |
Constructor.
msg | Describes the request being processed. |
Definition at line 33 of file IOBuffer.cpp.
References setMessage().
|
virtual |
Destructor.
Definition at line 43 of file IOBuffer.cpp.
References ERROR, m_buffer, m_directMapped, m_directMapRange, SELF, API::Success, UnMap, and VMCtl().
void IOBuffer::addCount | ( | const Size | bytes | ) |
Increment byte counter.
bytes | Number of bytes to increment |
Definition at line 114 of file IOBuffer.cpp.
References assert, m_count, and m_size.
Referenced by LinnFile::read().
FileSystem::Result IOBuffer::bufferedRead | ( | ) |
Buffered read bytes from the I/O buffer.
Definition at line 130 of file IOBuffer.cpp.
References m_buffer, m_count, m_directMapped, m_message, read(), FileSystemMessage::size, and FileSystem::Success.
Referenced by FileSystemServer::inodeHandler().
FileSystem::Result IOBuffer::bufferedWrite | ( | const void * | buffer, |
const Size | size | ||
) |
Buffered write bytes to the I/O buffer.
buffer | Contains the bytes to write. |
size | Number of bytes to write. |
Definition at line 146 of file IOBuffer.cpp.
References MemoryBlock::copy(), m_buffer, m_count, m_size, and FileSystem::Success.
Referenced by i8250::read(), PL011::read(), NS16550::read(), ATAController::read(), and DeviceLog::write().
FileSystem::Result IOBuffer::flushWrite | ( | ) |
Flush write buffers.
Definition at line 204 of file IOBuffer.cpp.
References m_buffer, m_count, m_directMapped, FileSystem::Success, and write().
Referenced by FileSystemServer::inodeHandler().
u8 * IOBuffer::getBuffer | ( | ) |
Get raw buffer.
Definition at line 125 of file IOBuffer.cpp.
References m_buffer.
Referenced by LinnFile::read(), and VGA::write().
Size IOBuffer::getCount | ( | ) | const |
Get byte count.
Definition at line 109 of file IOBuffer.cpp.
References m_count.
Referenced by FileSystemServer::inodeHandler(), PL011::read(), and NS16550::read().
const FileSystemMessage * IOBuffer::getMessage | ( | ) | const |
Get filesystem message.
Definition at line 120 of file IOBuffer.cpp.
References m_message.
Referenced by UDPFactory::read(), ICMPFactory::read(), and UDPSocket::write().
Byte index operator.
index | Index value |
Definition at line 217 of file IOBuffer.cpp.
FileSystem::Result IOBuffer::read | ( | void * | buffer, |
const Size | size, | ||
const Size | offset = ZERO |
||
) |
Read bytes from the I/O buffer.
buffer | Copy bytes from the I/O buffer to this memory address. |
size | Number of bytes to copy. |
offset | The offset inside the I/O buffer to start reading. |
Definition at line 156 of file IOBuffer.cpp.
References FileSystemMessage::buffer, MemoryBlock::copy(), ERROR, ChannelMessage::from, FileSystem::IOError, m_buffer, m_count, m_directMapped, m_message, API::Read, FileSystem::Success, API::Success, and VMCopy().
Referenced by bufferedRead(), UDP::sendPacket(), FileSystemServer::waitFileHandler(), LogLevelFile::write(), IPV4Address::write(), ARPSocket::write(), PseudoFile::write(), UDPSocket::write(), and ICMPSocket::write().
void IOBuffer::setMessage | ( | const FileSystemMessage * | msg | ) |
Set filesystem message.
msg | FileSystemMessage pointer |
Definition at line 63 of file IOBuffer.cpp.
References Memory::Range::access, FileSystemMessage::action, assert, FileSystemMessage::buffer, ERROR, ChannelMessage::from, isKernel, LookupVirtual, m_buffer, m_count, m_directMapped, m_directMapRange, m_message, m_size, MapContiguous, NULL, PAGEMASK, Memory::Readable, FileSystem::ReadFile, SELF, FileSystemMessage::size, Memory::Range::size, API::Success, Memory::User, Memory::Range::virt, VMCtl(), Memory::Writable, FileSystem::WriteFile, and ZERO.
Referenced by FileSystemRequest::FileSystemRequest(), IOBuffer(), and UDPSocket::write().
FileSystem::Result IOBuffer::write | ( | const void * | buffer, |
const Size | size, | ||
const Size | offset = ZERO |
||
) |
Write bytes to the I/O buffer.
buffer | Contains the bytes to write. |
size | Number of bytes to write. |
offset | The offset inside the I/O buffer to start writing. |
Definition at line 180 of file IOBuffer.cpp.
References FileSystemMessage::buffer, MemoryBlock::copy(), ERROR, ChannelMessage::from, FileSystem::IOError, m_buffer, m_count, m_directMapped, m_message, FileSystem::Success, API::Success, VMCopy(), and API::Write.
Referenced by flushWrite(), LogLevelFile::read(), IPV4Address::read(), EthernetAddress::read(), UDPFactory::read(), ICMPFactory::read(), ARPSocket::read(), PseudoFile::read(), LinnDirectory::read(), UDPSocket::read(), ICMPSocket::read(), Keyboard::read(), Directory::read(), Time::read(), VGA::read(), and FileSystemServer::waitFileHandler().
|
private |
Buffer for storing temporary data.
Definition at line 177 of file IOBuffer.h.
Referenced by bufferedRead(), bufferedWrite(), flushWrite(), getBuffer(), operator[](), read(), setMessage(), write(), and ~IOBuffer().
|
private |
Bytes written to the buffer.
Definition at line 183 of file IOBuffer.h.
Referenced by addCount(), bufferedRead(), bufferedWrite(), flushWrite(), getCount(), read(), setMessage(), and write().
|
private |
True if using directly memory-mapped memory (unbuffered)
Definition at line 171 of file IOBuffer.h.
Referenced by bufferedRead(), flushWrite(), read(), setMessage(), write(), and ~IOBuffer().
|
private |
Contains the memory address range of the direct memory mapping.
Definition at line 174 of file IOBuffer.h.
Referenced by setMessage(), and ~IOBuffer().
|
private |
Current request being processed.
Read() and write() will use fields from the current request to fill in arguments for VMCopy().
Definition at line 168 of file IOBuffer.h.
Referenced by bufferedRead(), getMessage(), read(), setMessage(), and write().
|
private |
Buffer size.
Definition at line 180 of file IOBuffer.h.
Referenced by addCount(), bufferedWrite(), operator[](), and setMessage().