FreeNOS
Public Member Functions | Private Attributes | Static Private Attributes
DeviceServer Class Reference

Device driver server. More...

#include <DeviceServer.h>

Inheritance diagram for DeviceServer:
FileSystemServer ChannelServer< FileSystemServer, FileSystemMessage > NetworkServer

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 FilecreateFile (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, MaximumDevicesm_devices
 Contains all Devices served by this DeviceServer. More...
 
Index< List< Device * >, MaximumInterruptsm_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...
 
DirectorygetParentDirectory (const char *path)
 Retrieve parent Directory for a file. More...
 
FileCachelookupFile (const FileSystemPath &path)
 Retrieve a File from storage. More...
 
FileCachefindFileCache (const char *path) const
 Search the cache for an entry. More...
 
FileCachefindFileCache (const String &path) const
 Search the cache for an entry. More...
 
FileCachefindFileCache (const FileSystemPath &path) const
 Search the cache for an entry. More...
 
FileCacheinsertFileCache (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...
 
FileCachem_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...
 
FileSystemMountm_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 >
FileSystemServerm_instance
 Server object instance. More...
 
ChannelClientm_client
 Client for sending replies. More...
 
ChannelRegistrym_registry
 Contains registered channels. More...
 
MemoryChannel m_kernelEvent
 Kernel event channel. More...
 
Index< MessageHandler< IPCHandlerFunction >, MaximumHandlerCountm_ipcHandlers
 IPC handler functions. More...
 
Index< MessageHandler< IRQHandlerFunction >, MaximumHandlerCountm_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...
 

Detailed Description

Device driver server.

Implements IPC handlers to communicate with the FileSystem using FileSystemMessages and invokes Device functions appropriately.

See also
Device
FileSystemServer
FileSystemMessage

Definition at line 43 of file DeviceServer.h.

Constructor & Destructor Documentation

◆ DeviceServer()

DeviceServer::DeviceServer ( const char *  path)

Constructor.

Definition at line 21 of file DeviceServer.cpp.

◆ ~DeviceServer()

DeviceServer::~DeviceServer ( )
virtual

Destructor.

Definition at line 26 of file DeviceServer.cpp.

Member Function Documentation

◆ initialize()

FileSystem::Result DeviceServer::initialize ( )
virtual

◆ interruptHandler()

void DeviceServer::interruptHandler ( Size  vector)
virtual

Interrupt request handler.

Invokes the interrupt callback function of each Device registered for the interrupt vector.

Parameters
vectorInterrupt number
See also
Device
Device::interrupt

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().

◆ registerDevice()

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.

Parameters
devNew device to add
pathPath 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().

◆ registerInterrupt()

void DeviceServer::registerInterrupt ( Device dev,
Size  vector 
)

Register an interrupt vector for the given device.

Appends the given Device on the internal list used for interrupt processing in interruptHandler().

Parameters
devPointer to the Device to wait interrupts for.
vectorVector number of the interrupt.
See also
Device
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().

Field Documentation

◆ m_devices

Index<Device, MaximumDevices> DeviceServer::m_devices
private

Contains all Devices served by this DeviceServer.

Definition at line 112 of file DeviceServer.h.

Referenced by initialize(), and registerDevice().

◆ m_interrupts

Index<List<Device *>, MaximumInterrupts> DeviceServer::m_interrupts
private

Registers Devices using interrupts.

An Index with Lists of Devices using the interrupt vector as index.

See also
Index
List
Device

Definition at line 124 of file DeviceServer.h.

Referenced by interruptHandler(), and registerInterrupt().

◆ MaximumDevices

const Size DeviceServer::MaximumDevices = 32
staticprivate

Maximum number of Devices that can be registered.

Definition at line 48 of file DeviceServer.h.

◆ MaximumInterrupts

const Size DeviceServer::MaximumInterrupts = 256
staticprivate

Maximum number of interrupts that can be registered.

Definition at line 51 of file DeviceServer.h.


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