| 770 |
user890104 |
1 |
//
|
|
|
2 |
//
|
| 898 |
user890104 |
3 |
// Copyright 2013 user890104
|
| 770 |
user890104 |
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 |
#ifndef __EMCORE_H__
|
|
|
24 |
#define __EMCORE_H__
|
|
|
25 |
|
|
|
26 |
#include "global.h"
|
|
|
27 |
|
|
|
28 |
#define EMCORE_USB_VID 0xFFFF
|
|
|
29 |
#define EMCORE_USB_PID 0xE000
|
|
|
30 |
|
| 898 |
user890104 |
31 |
#define EMCORE_USB_INTERFACE_CLASS 0xFF
|
|
|
32 |
#define EMCORE_USB_INTERFACE_SUB_CLASS 0x00
|
|
|
33 |
#define EMCORE_USB_INTERFACE_PROTOCOL 0x00
|
|
|
34 |
|
| 770 |
user890104 |
35 |
#define EMCORE_HEADER_SIZE 0x10
|
|
|
36 |
|
| 898 |
user890104 |
37 |
struct emcore_dev_info {
|
| 770 |
user890104 |
38 |
uint32_t svn_revision;
|
|
|
39 |
uint8_t major, minor, patch, sw_type;
|
|
|
40 |
uint32_t hw_type;
|
| 898 |
user890104 |
41 |
} __attribute__ ((packed));
|
| 770 |
user890104 |
42 |
|
| 898 |
user890104 |
43 |
struct emcore_malloc_pool_bounds {
|
| 770 |
user890104 |
44 |
uint32_t lower;
|
|
|
45 |
uint32_t upper;
|
| 898 |
user890104 |
46 |
} __attribute__ ((packed));
|
| 770 |
user890104 |
47 |
|
| 898 |
user890104 |
48 |
struct emcore_dir_entry {
|
|
|
49 |
char *name;
|
| 770 |
user890104 |
50 |
uint32_t attributes;
|
|
|
51 |
uint32_t size;
|
|
|
52 |
uint32_t startcluster;
|
|
|
53 |
uint16_t wrtdate;
|
|
|
54 |
uint16_t wrttime;
|
| 898 |
user890104 |
55 |
} __attribute__ ((packed));
|
| 770 |
user890104 |
56 |
|
| 898 |
user890104 |
57 |
enum emcore_error {
|
| 770 |
user890104 |
58 |
EMCORE_SUCCESS,
|
|
|
59 |
EMCORE_ERROR_INVALID,
|
|
|
60 |
EMCORE_ERROR_NOT_SUPPORTED,
|
|
|
61 |
EMCORE_ERROR_BUSY,
|
|
|
62 |
EMCORE_ERROR_NO_DEVICE,
|
|
|
63 |
EMCORE_ERROR_INCOMPLETE,
|
|
|
64 |
EMCORE_ERROR_OVERFLOW,
|
|
|
65 |
EMCORE_ERROR_NOT_IMPLEMENTED,
|
|
|
66 |
EMCORE_ERROR_NO_MORE_ENTRIES,
|
|
|
67 |
EMCORE_ERROR_IO,
|
|
|
68 |
};
|
|
|
69 |
|
| 898 |
user890104 |
70 |
int32_t emcore_send(const void *data, uint32_t length);
|
|
|
71 |
int32_t emcore_receive(void *data, uint32_t length);
|
| 770 |
user890104 |
72 |
|
| 898 |
user890104 |
73 |
int32_t emcore_monitor_command(const void *out, void *in, uint32_t send_length, uint32_t receive_length);
|
| 770 |
user890104 |
74 |
|
| 898 |
user890104 |
75 |
int32_t emcore_get_version(struct emcore_dev_info *dev_info);
|
|
|
76 |
int32_t emcore_get_malloc_pool_bounds(struct emcore_malloc_pool_bounds *bounds);
|
|
|
77 |
int32_t emcore_reset(uint8_t graceful);
|
|
|
78 |
int32_t emcore_poweroff(uint8_t graceful);
|
|
|
79 |
int32_t emcore_read(void *data, uint32_t addr, uint32_t size);
|
|
|
80 |
int32_t emcore_write(const void *data, uint32_t addr, uint32_t size);
|
|
|
81 |
int32_t emcore_readi2c(void *data, uint8_t bus, uint8_t slave, uint8_t addr, uint8_t size);
|
|
|
82 |
int32_t emcore_writei2c(const void *data, uint8_t bus, uint8_t slave, uint8_t addr, uint8_t size);
|
|
|
83 |
int32_t emcore_file_open(uint32_t *handle, const char *path, uint32_t flags);
|
|
|
84 |
int32_t emcore_file_size(uint32_t *size, uint32_t handle);
|
|
|
85 |
int32_t emcore_file_read(uint32_t *nread, uint32_t handle, uint32_t addr, uint32_t size);
|
|
|
86 |
int32_t emcore_file_write(uint32_t *nwrite, uint32_t handle, uint32_t addr, uint32_t size);
|
|
|
87 |
int32_t emcore_file_seek(uint32_t handle, uint32_t offset, uint32_t whence);
|
|
|
88 |
int32_t emcore_file_truncate(uint32_t handle, uint32_t length);
|
|
|
89 |
int32_t emcore_file_sync(uint32_t handle);
|
|
|
90 |
int32_t emcore_file_close(uint32_t handle);
|
|
|
91 |
int32_t emcore_file_close_all(uint32_t *count);
|
|
|
92 |
int32_t emcore_file_kill_all(uint32_t volume);
|
|
|
93 |
int32_t emcore_file_unlink(const char *path);
|
|
|
94 |
int32_t emcore_file_rename(const char *path, const char *newpath);
|
|
|
95 |
int32_t emcore_dir_open(uint32_t *handle, const char *name);
|
|
|
96 |
int32_t emcore_dir_read(struct emcore_dir_entry *entry, uint32_t handle);
|
|
|
97 |
int32_t emcore_dir_close(uint32_t handle);
|
|
|
98 |
int32_t emcore_dir_close_all(uint32_t *count);
|
|
|
99 |
int32_t emcore_dir_create(const char *name);
|
|
|
100 |
int32_t emcore_dir_remove(const char *name);
|
|
|
101 |
int32_t emcore_errno(uint32_t *emcore_errno_value);
|
|
|
102 |
int32_t emcore_malloc(uint32_t *ptr, uint32_t size);
|
|
|
103 |
int32_t emcore_memalign(uint32_t *ptr, uint32_t align, uint32_t size);
|
|
|
104 |
int32_t emcore_realloc(uint32_t *new_ptr, uint32_t ptr, uint32_t size);
|
|
|
105 |
int32_t emcore_reownalloc(uint32_t ptr, uint32_t owner);
|
|
|
106 |
int32_t emcore_free(uint32_t ptr);
|
|
|
107 |
int32_t emcore_free_all(void);
|
| 770 |
user890104 |
108 |
|
| 898 |
user890104 |
109 |
int32_t emcore_ls(uint32_t handle);
|
|
|
110 |
int32_t emcore_test(void);
|
| 770 |
user890104 |
111 |
|
|
|
112 |
#endif /* __EMCORE_H__ */
|