Go to the documentation of this file.
18 #ifndef __LIBIPC_CHANNELSERVER_H
19 #define __LIBIPC_CHANNELSERVER_H
21 #include <FreeNOS/User.h>
22 #include <FreeNOS/ProcessManager.h>
23 #include <FreeNOS/ProcessEvent.h>
24 #include <FreeNOS/ProcessShares.h>
135 FATAL(
"failed to get kernel event channel");
181 DEBUG(
"msec = " << msec);
185 ERROR(
"failed to retrieve system timer info");
288 DEBUG(
"EnterSleep returned: " << (
int)r);
295 ERROR(
"failed to retrieve system timer");
316 const bool hardReset =
true)
323 prodAddr = range.
virt;
329 consAddr = range.
virt;
378 ERROR(
"failed to recover share for PID " << i <<
": " << (
int)r);
429 ERROR(
"failed to unregister consumer for PID " <<
430 event.
number <<
": " << (
int)result);
436 ERROR(
"failed to unregister producer for PID " <<
437 event.
number <<
": " << (
int)result);
444 ERROR(
"failed to remove shares with VMShare for PID " <<
445 event.
number <<
": " << (
int)shareResult);
472 DEBUG(
m_self <<
": trying to receive from PID " << i.key());
485 ERROR(
m_self <<
": failed to process client response from PID " <<
486 msg.from <<
" with identifier " << msg.identifier);
503 ERROR(
m_self <<
": no producer channel found for PID: " << i.key());
507 ERROR(
m_self <<
": failed to send reply message to PID: " << i.key());
515 ERROR(
m_self <<
": invalid action " << (
int)msg.action <<
" from PID " << i.key());
Index< MessageHandler< IPCHandlerFunction >, MaximumHandlerCount > m_ipcHandlers
IPC handler functions.
Unidirectional point-to-point messaging channel.
Result readKernelEvents()
Read and process kernel events.
Size tagId
Share tag id is defined by the application.
virtual bool insertAt(const Size position, T *item)
Inserts the given item at the given position.
Result
Enumeration of generic kernel API result codes.
ProcessID pid
Remote process id for this share.
Result setVirtual(const Address data, const Address feedback, const bool hardReset=true)
Set memory pages by virtual address.
#define WARNING(msg)
Output a warning message.
Result accept(const ProcessID pid, const Memory::Range range, const bool hardReset=true)
Accept new channel connection.
virtual ~ChannelServer()
Destructor function.
void recoverChannels()
Read existing shares to recover MemoryChannels after restart.
ChannelServer(Base *inst)
Constructor function.
Iterate through a HashTable.
#define PAGESIZE
ARM uses 4K pages.
void sleepUntilWakeup()
Let this process sleep until more events are raised.
ChannelRegistry & m_registry
Contains registered channels.
Index is a N-sized array of pointers to items of type T.
void addIRQHandler(const Size slot, IRQHandlerFunction h)
Register a new IRQ message vector handler.
Message handler function (dummy) container.
u32 ProcessID
Process Identification Number.
void(Base::* IRQHandlerFunction)(Size)
Member function pointer inside Base, to handle interrupts.
unsigned long Address
A memory address.
Base
Numeral system base type.
int run()
Enters an infinite loop, serving incoming requests.
API::Result VMShare(const ProcessID pid, const API::Operation op, ProcessShares::MemoryShare *share)
Prototype for user applications.
virtual bool retryRequests()
Retry any pending requests.
Memory::Range range
Physical memory address range.
MessageHandler(const Func func, const bool reply)
Constructor function.
API::Result ProcessCtl(const ProcessID proc, const ProcessOperation op, const Address addr=0, const Address output=0)
Prototype for user applications.
Timer information structure.
const bool sendReply
Whether to send a reply or not.
void(Base::* IPCHandlerFunction)(MsgType *)
Member function pointer inside Base, to handle IPC messages.
Size coreId
CoreId for the other process.
Channel * getConsumer(const ProcessID pid)
Get one consumer.
Result registerConsumer(const ProcessID pid, Channel *channel)
Register consumer channel.
unsigned int uint
Unsigned integer number.
void deleteAll()
Removes and delete()'s all items.
virtual Result read(void *buffer)
Read a message.
const Func exec
Handler function.
ProcessID m_self
ProcessID of ourselves.
Base * m_instance
Server object instance.
#define FATAL(msg)
Output a critical message and terminate program immediatly.
#define DEBUG(msg)
Output a debug message to standard output.
Result readChannels()
Read each Channel for messages.
virtual Result write(const void *buffer)
Write a message.
Represents a process which may run on the host.
HashTable< ProcessID, Channel * > & getConsumers()
Get all consumers.
#define MAX_PROCS
Maximum number of processes.
virtual void timeout()
Called when sleep timeout is reached.
slong Error
Error code defined in Error.h.
#define NULL
NULL means zero.
unsigned int Size
Any sane size indicator cannot go negative.
void setTimeout(const uint msec)
Set a sleep timeout.
Unidirectional point-to-point channel using shared memory.
Result registerProducer(const ProcessID pid, Channel *channel)
Register producer channel.
Result unregisterProducer(const ProcessID pid)
Unregister producer channel.
MemoryChannel m_kernelEvent
Kernel event channel.
virtual T * get(const Size position) const
Returns the item at the given position.
virtual Result read(void *buffer)
Read a message.
ProcessShares::MemoryShare share
void retryAllRequests()
Keep retrying requests until all served.
Template class which serves incoming messages from Channels using MessageHandlers.
Client for using Channels on the local processor.
#define assert(exp)
Insert program diagnostics.
#define ERROR(msg)
Output an error message.
const bool operator!=(const struct MessageHandler< Func > &h) const
Timer::Info m_expiry
System timer expiration value.
ChannelClient * m_client
Client for sending replies.
Registration for Channels.
Timer::Info m_time
System timer value.
const bool operator==(const struct MessageHandler< Func > &h) const
void addIPCHandler(const Size slot, IPCHandlerFunction h, const bool sendReply=true)
Register a new IPC message action handler.
Address virt
Virtual address.
static const Size MaximumHandlerCount
Maximum number of IPC/IRQ handlers.
virtual bool hasCurrent() const
Check if there is a current item.
void processAll()
Process all current events and channels.
Channel * getProducer(const ProcessID pid)
Get one producer.
Result unregisterConsumer(const ProcessID pid)
Unregister consumer channel.
virtual void onProcessTerminated(const ProcessID pid)
Called whenever another Process is terminated.
Index< MessageHandler< IRQHandlerFunction >, MaximumHandlerCount > m_irqHandlers
IRQ handler functions.
virtual Result processResponse(const ProcessID pid, ChannelMessage *msg)
Process a response message.