forked from KolibriOS/kolibrios
1) First commit of libIPC
2) Kobra (0.1.1) uses libIPC, compilation changed, files with non-kobra functions moved to framework git-svn-id: svn://kolibrios.org@1286 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
27
programs/develop/libraries/framework/trunk/include/defs.h
Normal file
27
programs/develop/libraries/framework/trunk/include/defs.h
Normal file
@@ -0,0 +1,27 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (C) 2009 Vasiliy Kosenko *
|
||||
* *
|
||||
* 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, write to the Free Software *
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef _DEFS_H_
|
||||
#define _DEFS_H_
|
||||
|
||||
#define NULL 0
|
||||
#define bool int
|
||||
#define true 1
|
||||
#define false 0
|
||||
|
||||
#endif
|
46
programs/develop/libraries/framework/trunk/include/heap.h
Normal file
46
programs/develop/libraries/framework/trunk/include/heap.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (C) 2009 Vasiliy Kosenko *
|
||||
* *
|
||||
* 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, write to the Free Software *
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef _HEAP_H_
|
||||
#define _HEAP_H_
|
||||
|
||||
#include "defs.h"
|
||||
|
||||
#define PAGE_SIZE 0x1000
|
||||
|
||||
typedef struct MemBlock {
|
||||
struct MemBlock *next;
|
||||
struct MemBlock *previos;
|
||||
unsigned long nblocks;
|
||||
unsigned long align;
|
||||
} MemBlock;
|
||||
|
||||
typedef struct Heap {
|
||||
struct MemBlock *free;
|
||||
struct MemBlock *allocated;
|
||||
void *(*alloc)(struct Heap *heap, int nbytes);
|
||||
} Heap;
|
||||
|
||||
void *halMemAlloc(Heap *wheap, unsigned long n);
|
||||
void halMemFree(Heap *wheap, void *addr);
|
||||
MemBlock *halMemBlockAdd(MemBlock *heap, MemBlock *unit, bool optimize);
|
||||
MemBlock *halMemBlockRemove(MemBlock *unit);
|
||||
|
||||
void halMemHeapInit(Heap *wheap, void *(*alloc)(Heap *heap, int nbytes), void *st_addr, int size);
|
||||
|
||||
#endif
|
94
programs/develop/libraries/framework/trunk/include/ipc.h
Normal file
94
programs/develop/libraries/framework/trunk/include/ipc.h
Normal file
@@ -0,0 +1,94 @@
|
||||
/***************************************************************************************************
|
||||
* 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/>. *
|
||||
***************************************************************************************************/
|
||||
|
||||
#ifndef _IPC_H_
|
||||
#define _IPC_H_
|
||||
|
||||
#include "defs.h"
|
||||
|
||||
#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
|
||||
|
||||
/*
|
||||
* Data types
|
||||
*/
|
||||
|
||||
//
|
||||
typedef struct kolibri_IPC_area {
|
||||
unsigned long lock;
|
||||
unsigned long size;
|
||||
} IPCArea;
|
||||
|
||||
typedef struct kolibri_IPC_area kolibri_IPC_area_t;
|
||||
|
||||
//
|
||||
typedef struct kolibri_IPC_message {
|
||||
unsigned long tid;
|
||||
unsigned long length;
|
||||
} Message;
|
||||
|
||||
typedef struct kolibri_IPC_message kolibri_IPC_message_t;
|
||||
|
||||
/*
|
||||
* High level IPC functions
|
||||
*/
|
||||
|
||||
extern IPCArea *ipc_area;
|
||||
|
||||
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
|
||||
*/
|
||||
|
||||
extern kolibri_IPC_area_t *kolibri_IPC_area;
|
||||
|
||||
int kolibri_IPC_set_area(void *area, int size);
|
||||
|
||||
int kolibri_IPC_send(int tid, void *msg, int length);
|
||||
|
||||
void kolibri_IPC_unlock();
|
||||
|
||||
void kolibri_IPC_lock();
|
||||
|
||||
int kolibri_IPC_init(void *area, int size);
|
||||
|
||||
kolibri_IPC_message_t *kolibri_IPC_get_next_message();
|
||||
|
||||
// void kolibri_IPC_clear_buff();
|
||||
|
||||
#endif
|
87
programs/develop/libraries/framework/trunk/include/kolibri.h
Normal file
87
programs/develop/libraries/framework/trunk/include/kolibri.h
Normal file
@@ -0,0 +1,87 @@
|
||||
/***************************************************************************************************
|
||||
* 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/>. *
|
||||
***************************************************************************************************/
|
||||
|
||||
#ifndef _KOLIBRI_H_
|
||||
#define _KOLIBRI_H_
|
||||
|
||||
#define KOLIBRI_ACCESS_READ 0x0
|
||||
#define KOLIBRI_CREATE 0x8
|
||||
|
||||
#define KOLIBRI_EVENT_IPC_MASK 0x40
|
||||
#define KOLIBRI_EVENT_IPC 0x7
|
||||
|
||||
//
|
||||
struct kolibri_memarea {
|
||||
void *addr;
|
||||
int error; // or size
|
||||
char *name;
|
||||
};
|
||||
|
||||
typedef struct kolibri_memarea kolibri_memarea_t;
|
||||
|
||||
//
|
||||
#pragma pack(push,1)
|
||||
struct kolibri_process_info {
|
||||
long cpu_using; // +0
|
||||
short window_position; // +4
|
||||
short window_position_slot; // +6
|
||||
short reserved_0; // +8
|
||||
char name[11]; // +10
|
||||
char reserved_const_0; // +21
|
||||
unsigned long addr; // +22
|
||||
long mem_using; // +26
|
||||
long tid; // +30
|
||||
long window_x;
|
||||
long window_y;
|
||||
long window_width;
|
||||
long window_height;
|
||||
short state;
|
||||
short reserved_const_1;
|
||||
long window_client_x;
|
||||
long window_client_y;
|
||||
long window_client_width;
|
||||
long window_client_height;
|
||||
char window_state;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
typedef struct kolibri_process_info kolibri_process_info_t;
|
||||
|
||||
//
|
||||
//extern kolibri_IPC_area_t *kolibri_IPC_area;
|
||||
|
||||
// //
|
||||
// int kolibri_IPC_set_area(void *area, int size);
|
||||
// int kolibri_IPC_send(int tid, void *msg, int length);
|
||||
// void kolibri_IPC_unlock();
|
||||
// void kolibri_IPC_lock();
|
||||
// int kolibri_IPC_init(void *area, int size);
|
||||
// kolibri_IPC_message_t *kolibri_IPC_get_next_message();
|
||||
// void kolibri_IPC_clear_buff();
|
||||
int kolibri_event_wait();
|
||||
|
||||
/*
|
||||
* Memory functions
|
||||
*/
|
||||
|
||||
kolibri_memarea_t kolibri_new_named_memory(char *name, int size, int flags);
|
||||
int kolibri_heap_init();
|
||||
void *kolibri_malloc(int nbytes);
|
||||
|
||||
/*
|
||||
* Events functions
|
||||
*/
|
||||
void kolibri_set_event_mask(int mask);
|
||||
|
||||
#endif
|
31
programs/develop/libraries/framework/trunk/include/malloc.h
Normal file
31
programs/develop/libraries/framework/trunk/include/malloc.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/***************************************************************************************************
|
||||
* 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/>. *
|
||||
***************************************************************************************************/
|
||||
|
||||
/***************************************************************************************************
|
||||
* malloc.c - realisation of malloc & free functions based on heap.c *
|
||||
***************************************************************************************************/
|
||||
|
||||
#ifndef _MALLOC_H_
|
||||
#define _MALLOC_H_
|
||||
|
||||
#include "heap.h"
|
||||
|
||||
extern Heap malloc_heap;
|
||||
|
||||
void malloc_init();
|
||||
void *heap_alloc(Heap *wheap, int nbytes);
|
||||
void *malloc(int nbytes);
|
||||
void free(void *addr);
|
||||
|
||||
#endif
|
24
programs/develop/libraries/framework/trunk/include/stdlib.h
Normal file
24
programs/develop/libraries/framework/trunk/include/stdlib.h
Normal file
@@ -0,0 +1,24 @@
|
||||
/***************************************************************************************************
|
||||
* Copyright (C) Vasiliy Kosenko (vkos), 2009 *
|
||||
* Kobra 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. *
|
||||
* *
|
||||
* Kobra 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 Kobra. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************************************/
|
||||
|
||||
#ifndef _MEMCPY_H_
|
||||
#define _MEMCPY_H_
|
||||
|
||||
void *memcpy(void *dst, void *src, int length);
|
||||
|
||||
char strcmp(char *s1, char *s2);
|
||||
int strlen(char *s);
|
||||
char *strcpy(char *dest, char *src);
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user