2009-10-26 18:03:29 +01:00
|
|
|
/***************************************************************************************************
|
|
|
|
* Copyright (C) Vasiliy Kosenko (vkos), 2009 *
|
|
|
|
* This program is free software: you can redistribute it and/or modify it under the terms of the *
|
|
|
|
* GNU General Public License as published by the Free Software Foundation, either version 3 *
|
|
|
|
* of the License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; *
|
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See *
|
|
|
|
* the GNU General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License along with this program. *
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>. *
|
|
|
|
***************************************************************************************************/
|
|
|
|
|
2009-11-25 19:23:48 +01:00
|
|
|
#ifndef _IPC_H_
|
|
|
|
#define _IPC_H_
|
2009-10-26 18:03:29 +01:00
|
|
|
|
2009-11-25 19:23:48 +01:00
|
|
|
#include "defs.h"
|
2009-10-26 18:03:29 +01:00
|
|
|
|
2009-11-25 19:23:48 +01:00
|
|
|
#define IPC_BUFFER_SIZE 0x1000
|
|
|
|
|
|
|
|
#define IPC_MAX_ERRORS 10
|
|
|
|
|
|
|
|
#define IPC_NO_MEMORY 1
|
|
|
|
#define IPC_CANNOT_SET_MASK 2
|
|
|
|
|
|
|
|
#define IPC_NO_AREA 1
|
|
|
|
#define IPC_BUFFER_LOCKED 2
|
|
|
|
#define IPC_OVERFLOW 3
|
|
|
|
#define IPC_NO_TID 4
|
2009-10-26 18:03:29 +01:00
|
|
|
|
|
|
|
/*
|
2009-11-25 19:23:48 +01:00
|
|
|
* Data types
|
2009-10-26 18:03:29 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
//
|
2009-11-25 19:23:48 +01:00
|
|
|
typedef struct kolibri_IPC_area {
|
2009-10-26 18:03:29 +01:00
|
|
|
unsigned long lock;
|
|
|
|
unsigned long size;
|
2009-11-25 19:23:48 +01:00
|
|
|
} IPCArea;
|
2009-10-26 18:03:29 +01:00
|
|
|
|
|
|
|
typedef struct kolibri_IPC_area kolibri_IPC_area_t;
|
|
|
|
|
|
|
|
//
|
2009-11-25 19:23:48 +01:00
|
|
|
typedef struct kolibri_IPC_message {
|
2009-10-26 18:03:29 +01:00
|
|
|
unsigned long tid;
|
|
|
|
unsigned long length;
|
2009-11-25 19:23:48 +01:00
|
|
|
} Message;
|
2009-10-26 18:03:29 +01:00
|
|
|
|
|
|
|
typedef struct kolibri_IPC_message kolibri_IPC_message_t;
|
|
|
|
|
2009-11-25 19:23:48 +01:00
|
|
|
/*
|
|
|
|
* High level IPC functions
|
|
|
|
*/
|
2009-10-26 18:03:29 +01:00
|
|
|
|
2009-11-25 19:23:48 +01:00
|
|
|
extern IPCArea *ipc_area;
|
2009-10-26 18:03:29 +01:00
|
|
|
|
2009-11-25 19:23:48 +01:00
|
|
|
int IPCInit(void);
|
|
|
|
|
|
|
|
int IPCSend(int tid, void *message, int length);
|
|
|
|
|
|
|
|
bool IPCCheck(void);
|
|
|
|
|
|
|
|
bool IPCCheckWait(int time);
|
|
|
|
|
|
|
|
Message *IPCGetNextMessage(void);
|
|
|
|
|
|
|
|
Message *IPCWaitMessage(int time);
|
|
|
|
|
|
|
|
void IPCLock(void);
|
|
|
|
|
|
|
|
void IPCUnlock(void);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Kolibri IPC functions & data
|
|
|
|
*/
|
2009-10-26 18:03:29 +01:00
|
|
|
|
|
|
|
extern kolibri_IPC_area_t *kolibri_IPC_area;
|
|
|
|
|
|
|
|
int kolibri_IPC_set_area(void *area, int size);
|
2009-11-25 19:23:48 +01:00
|
|
|
|
2009-10-26 18:03:29 +01:00
|
|
|
int kolibri_IPC_send(int tid, void *msg, int length);
|
2009-11-25 19:23:48 +01:00
|
|
|
|
2009-10-26 18:03:29 +01:00
|
|
|
void kolibri_IPC_unlock();
|
2009-11-25 19:23:48 +01:00
|
|
|
|
2009-10-26 18:03:29 +01:00
|
|
|
void kolibri_IPC_lock();
|
|
|
|
|
2009-11-25 19:23:48 +01:00
|
|
|
int kolibri_IPC_init(void *area, int size);
|
2009-10-26 18:03:29 +01:00
|
|
|
|
2009-11-25 19:23:48 +01:00
|
|
|
kolibri_IPC_message_t *kolibri_IPC_get_next_message();
|
2009-10-26 18:03:29 +01:00
|
|
|
|
2009-11-25 19:23:48 +01:00
|
|
|
// void kolibri_IPC_clear_buff();
|
2009-10-26 18:03:29 +01:00
|
|
|
|
|
|
|
#endif
|