FreeNOS
|
#include <DeviceServer.h>
Public Member Functions | |
DeviceServer (const char *path) | |
Constructor. More... | |
virtual | ~DeviceServer () |
Destructor. More... | |
virtual FileSystem::Result | initialize () |
Initialize DeviceServer. More... | |
void | registerDevice (Device *dev, const char *path) |
Add a Device. More... | |
void | registerInterrupt (Device *dev, Size vector) |
Register an interrupt vector for the given device. More... | |
virtual void | interruptHandler (Size vector) |
Interrupt request handler. More... | |
Public Member Functions inherited from FileSystemServer | |
FileSystemServer (Directory *root, const char *path) | |
Constructor function. More... | |
virtual | ~FileSystemServer () |
Destructor function. More... | |
const char * | getMountPath () const |
Get mount path. More... | |
u32 | getNextInode () |
Get next unused inode. More... | |
FileSystem::Result | mount () |
Mount the FileSystem. More... | |
FileSystem::Result | registerFile (File *file, const char *path) |
Register a new File. More... | |
FileSystem::Result | registerDirectory (Directory *dir, const char *path) |
Register a new Directory. More... | |
FileSystem::Result | unregisterFile (const char *path) |
Remove a File from the FileSystemServer. More... | |
virtual File * | createFile (const FileSystem::FileType type) |
Create a new file. More... | |
void | pathHandler (FileSystemMessage *msg) |
Process an incoming filesystem request using a path. More... | |
void | mountHandler (FileSystemMessage *msg) |
Process a filesystem mount request message. More... | |
void | getFileSystemsHandler (FileSystemMessage *msg) |
Read the file system mounts table. More... | |
virtual bool | retryRequests () |
Retry any pending requests. More... | |
Public Member Functions inherited from ChannelServer< FileSystemServer, FileSystemMessage > | |
ChannelServer (FileSystemServer *inst) | |
Constructor function. More... | |
virtual | ~ChannelServer () |
Destructor function. More... | |
int | run () |
Enters an infinite loop, serving incoming requests. More... | |
void | setTimeout (const uint msec) |
Set a sleep timeout. More... | |
Private Attributes | |
Index< Device, MaximumDevices > | m_devices |
Contains all Devices served by this DeviceServer. More... | |
Index< List< Device * >, MaximumInterrupts > | m_interrupts |
Registers Devices using interrupts. More... | |
Static Private Attributes | |
static const Size | MaximumDevices = 32 |
Maximum number of Devices that can be registered. More... | |
static const Size | MaximumInterrupts = 256 |
Maximum number of interrupts that can be registered. More... | |
Additional Inherited Members | |
Public Types inherited from ChannelServer< FileSystemServer, FileSystemMessage > | |
enum | Result |
Result codes. More... | |
Protected Types inherited from ChannelServer< FileSystemServer, FileSystemMessage > | |
typedef void(FileSystemServer ::* | IPCHandlerFunction) (FileSystemMessage *) |
Member function pointer inside Base, to handle IPC messages. More... | |
typedef void(FileSystemServer ::* | IRQHandlerFunction) (Size) |
Member function pointer inside Base, to handle interrupts. More... | |
Protected Member Functions inherited from FileSystemServer | |
FileSystem::Result | processRequest (FileSystemRequest &req) |
Process a FileSystemRequest. More... | |
FileSystem::Result | inodeHandler (FileSystemRequest &req) |
Handle a request for a File specified by its inode. More... | |
FileSystem::Result | waitFileHandler (FileSystemRequest &req) |
Handle a WaitFile request. More... | |
void | sendResponse (FileSystemMessage *msg) const |
Send response for a FileSystemMessage. More... | |
bool | redirectRequest (const char *path, FileSystemMessage *msg) |
Try to forward the given FileSystemMessage to a mount file system. More... | |
void | setRoot (Directory *newRoot) |
Change the filesystem root directory. More... | |
Directory * | getParentDirectory (const char *path) |
Retrieve parent Directory for a file. More... | |
FileCache * | lookupFile (const FileSystemPath &path) |
Retrieve a File from storage. More... | |
FileCache * | findFileCache (const char *path) const |
Search the cache for an entry. More... | |
FileCache * | findFileCache (const String &path) const |
Search the cache for an entry. More... | |
FileCache * | findFileCache (const FileSystemPath &path) const |
Search the cache for an entry. More... | |
FileCache * | insertFileCache (File *file, const char *pathFormat) |
Inserts a file into the in-memory filesystem tree. More... | |
void | removeFileFromCache (FileCache *cache, File *file) |
Remove a File from the cache. More... | |
void | clearFileCache (FileCache *cache=ZERO) |
Cleans up the entire file cache (except opened file caches and root). More... | |
Protected Member Functions inherited from ChannelServer< FileSystemServer, FileSystemMessage > | |
void | addIPCHandler (const Size slot, IPCHandlerFunction h, const bool sendReply=true) |
Register a new IPC message action handler. More... | |
void | addIRQHandler (const Size slot, IRQHandlerFunction h) |
Register a new IRQ message vector handler. More... | |
virtual void | timeout () |
Called when sleep timeout is reached. More... | |
virtual void | onProcessTerminated (const ProcessID pid) |
Called whenever another Process is terminated. More... | |
void | retryAllRequests () |
Keep retrying requests until all served. More... | |
Protected Attributes inherited from FileSystemServer | |
const ProcessID | m_pid |
Process identifier. More... | |
FileCache * | m_root |
Root entry of the filesystem tree. More... | |
HashTable< u32, File * > | m_inodeMap |
Contains a mapping of inode number to file of all cached files. More... | |
const char * | m_mountPath |
Mount point path. More... | |
FileSystemMount * | m_mounts |
Table with mounted file systems (only used by the root file system). More... | |
List< FileSystemRequest * > * | m_requests |
Contains ongoing requests. More... | |
Protected Attributes inherited from ChannelServer< FileSystemServer, FileSystemMessage > | |
FileSystemServer * | m_instance |
Server object instance. More... | |
ChannelClient * | m_client |
Client for sending replies. More... | |
ChannelRegistry & | m_registry |
Contains registered channels. More... | |
MemoryChannel | m_kernelEvent |
Kernel event channel. More... | |
Index< MessageHandler< IPCHandlerFunction >, MaximumHandlerCount > | m_ipcHandlers |
IPC handler functions. More... | |
Index< MessageHandler< IRQHandlerFunction >, MaximumHandlerCount > | m_irqHandlers |
IRQ handler functions. More... | |
ProcessID | m_self |
ProcessID of ourselves. More... | |
Timer::Info | m_time |
System timer value. More... | |
Timer::Info | m_expiry |
System timer expiration value. More... | |
Device driver server.
Implements IPC handlers to communicate with the FileSystem using FileSystemMessages and invokes Device functions appropriately.
Definition at line 43 of file DeviceServer.h.
DeviceServer::DeviceServer | ( | const char * | path | ) |
Constructor.
Definition at line 21 of file DeviceServer.cpp.
|
virtual |
Destructor.
Definition at line 26 of file DeviceServer.cpp.
|
virtual |
Initialize DeviceServer.
Reimplemented in NetworkServer.
Definition at line 30 of file DeviceServer.cpp.
References Index< T, N >::count(), ERROR, Device::getIdentifier(), FileSystemServer::getNextInode(), Device::initialize(), m_devices, FileSystemServer::m_mountPath, FileSystemServer::mount(), FileSystemServer::registerFile(), FileSystem::Success, and ZERO.
Referenced by NetworkServer::initialize(), and main().
|
virtual |
Interrupt request handler.
Invokes the interrupt callback function of each Device registered for the interrupt vector.
vector | Interrupt number |
Definition at line 106 of file DeviceServer.cpp.
References Index< T, N >::get(), ListIterator< T >::hasCurrent(), m_interrupts, and ChannelServer< FileSystemServer, FileSystemMessage >::retryAllRequests().
Referenced by registerInterrupt().
void DeviceServer::registerDevice | ( | Device * | dev, |
const char * | path | ||
) |
Add a Device.
Adds an Device to the internal Vector of Devices, to be able to process requests for the Device later on.
dev | New device to add |
path | Path to the device |
Definition at line 67 of file DeviceServer.cpp.
References FATAL, Index< T, N >::insert(), m_devices, and FileSystemServer::registerFile().
Referenced by main(), and NetworkServer::registerNetworkDevice().
Register an interrupt vector for the given device.
Appends the given Device on the internal list used for interrupt processing in interruptHandler().
Definition at line 79 of file DeviceServer.cpp.
References ChannelServer< FileSystemServer, FileSystemMessage >::addIRQHandler(), EnableIRQ, ERROR, Index< T, N >::get(), Index< T, N >::insertAt(), interruptHandler(), m_interrupts, ProcessCtl(), SELF, API::Success, and WatchIRQ.
Referenced by main().
|
private |
Contains all Devices served by this DeviceServer.
Definition at line 112 of file DeviceServer.h.
Referenced by initialize(), and registerDevice().
|
private |
Registers Devices using interrupts.
An Index with Lists of Devices using the interrupt vector as index.
Definition at line 124 of file DeviceServer.h.
Referenced by interruptHandler(), and registerInterrupt().
|
staticprivate |
Maximum number of Devices that can be registered.
Definition at line 48 of file DeviceServer.h.
|
staticprivate |
Maximum number of interrupts that can be registered.
Definition at line 51 of file DeviceServer.h.