↑ Back to main site.

EPOS

Experimental Protected-mode Operating System

ipc_thoth.h
/*
EPOS
http://www.atanaslaskov.com/epos/

FILE: ipc_thoth.h
DESCRIPTION:
Inter-Process Communication IPC in the style of Thoth OS
 
BSD LICENSE
Copyright (c) 2006, Atanas Laskov
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
   1. Redistributions of source code must retain the above copyright notice,
   this list of conditions and the following disclaimer.
   2. Redistributions in binary form must reproduce the above copyright notice,
   this list of conditions and the following disclaimer in the documentation
   and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL ATANAS LASKOV BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/


#ifndef IPC_THOTH_H
#define IPC_THOTH_H

//Parameters
#define THOTH_MSGSZ     8                   //Size of the message in bytes
#define THOTH_INBOXSZ   10                  //Max number of messages per inbox

//Flacs for the state of a process associated with an imbox
#define THOTH_IF_BLOCKED 0x1                //Blocked
#define THOTH_IF_FULL    0x2                //Waiting for free space in the inbox
#define THOTH_IF_EMPTY   0x4                //Waiting for a message in the inbox
#define THOTH_IF_REPLY   0x8                //Waiting for Reply

//Argument structure for the kernel calls
struct ThothMsg{
    unsigned char arData[THOTH_MSGSZ];      //Message
    PID pid;                                //id of the sender/receiver (depending on the call)
};

//Structure of the inbox
struct ThothInbox{
    struct ThothMsg arMsg[THOTH_INBOXSZ];   //Messages
    unsigned nMsgCnt;                       //Number of valid messagers

    unsigned char bFlags;                   //Flags
    struct ThothMsg *pMsgOverflow;          //Pointer storing an argument in the case of blocking
    PID pidOverflow;                        //Pointer storing the sender/receiver in the case of blocking
};

//Initialization of the subsystem
void k_thothInit();

//Functions implementing Thoth IPC
void thothSend(struct ThothMsg *pMsg);
void thothReceive(struct ThothMsg *pMsg);
void thothReply(struct ThothMsg *pMsg);

#endif //#ifndef IPC_THOTH_H