| 465 |
theseven |
1 |
//
|
|
|
2 |
//
|
|
|
3 |
// Copyright 2011 TheSeven
|
|
|
4 |
//
|
|
|
5 |
//
|
|
|
6 |
// This file is part of emCORE.
|
|
|
7 |
//
|
|
|
8 |
// emCORE is free software: you can redistribute it and/or
|
|
|
9 |
// modify it under the terms of the GNU General Public License as
|
|
|
10 |
// published by the Free Software Foundation, either version 2 of the
|
|
|
11 |
// License, or (at your option) any later version.
|
|
|
12 |
//
|
|
|
13 |
// emCORE is distributed in the hope that it will be useful,
|
|
|
14 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
15 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
16 |
// See the GNU General Public License for more details.
|
|
|
17 |
//
|
|
|
18 |
// You should have received a copy of the GNU General Public License along
|
|
|
19 |
// with emCORE. If not, see <http://www.gnu.org/licenses/>.
|
|
|
20 |
//
|
|
|
21 |
//
|
|
|
22 |
|
|
|
23 |
|
|
|
24 |
#ifndef __LIBRARY_H__
|
|
|
25 |
#define __LIBRARY_H__
|
|
|
26 |
|
|
|
27 |
|
|
|
28 |
#ifdef _TOOL
|
|
|
29 |
#include <stdint.h>
|
|
|
30 |
#else
|
|
|
31 |
#include "global.h"
|
|
|
32 |
#include "thread.h"
|
|
|
33 |
#endif
|
|
|
34 |
|
|
|
35 |
|
|
|
36 |
#define EMCORELIB_HEADER_VERSION 1
|
|
|
37 |
struct emcorelib_header
|
|
|
38 |
{
|
|
|
39 |
uint32_t headerversion;
|
|
|
40 |
uint32_t identifier;
|
|
|
41 |
uint32_t version;
|
|
|
42 |
int (*initfunc)();
|
|
|
43 |
int (*shutdownfunc)();
|
|
|
44 |
void* api;
|
|
|
45 |
};
|
|
|
46 |
|
|
|
47 |
struct library_handle
|
|
|
48 |
{
|
|
|
49 |
struct library_handle* next;
|
|
|
50 |
struct emcorelib_header* lib;
|
|
|
51 |
void* alloc;
|
|
|
52 |
void* users[16];
|
|
|
53 |
void** moreusers;
|
|
|
54 |
size_t moreusers_size;
|
|
|
55 |
};
|
|
|
56 |
|
|
|
57 |
enum library_sourcetype
|
|
|
58 |
{
|
|
|
59 |
LIBSOURCE_RAM_ALLOCED = 1,
|
|
|
60 |
LIBSOURCE_RAM_NEEDCOPY = 2,
|
|
|
61 |
LIBSOURCE_BOOTFLASH = 3,
|
|
|
62 |
LIBSOURCE_FILESYSTEM = 4
|
|
|
63 |
};
|
|
|
64 |
|
|
|
65 |
|
|
|
66 |
#ifndef _TOOL
|
|
|
67 |
struct library_handle* library_register(void* image, struct emcorelib_header* header);
|
|
|
68 |
int library_unload(struct library_handle* lib);
|
|
|
69 |
struct emcorelib_header* get_library(uint32_t identifier, uint32_t minversion, uint32_t maxversion,
|
|
|
70 |
enum library_sourcetype sourcetype, void* source);
|
|
|
71 |
struct emcorelib_header* get_library_ext(uint32_t identifier, uint32_t minversion,
|
|
|
72 |
uint32_t maxversion, enum library_sourcetype sourcetype,
|
|
|
73 |
void* source, struct scheduler_thread* owner);
|
|
|
74 |
int release_library(struct emcorelib_header* lib);
|
|
|
75 |
int release_library_ext(struct emcorelib_header* lib, struct scheduler_thread* owner);
|
|
|
76 |
int library_release_all_of_thread(struct scheduler_thread* thread);
|
|
|
77 |
#endif
|
|
|
78 |
|
|
|
79 |
|
|
|
80 |
#endif
|