Subversion Repositories freemyipod

Rev

Rev 785 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 785 Rev 898
Line 1... Line 1...
1
//
1
//
2
//
2
//
3
//    Copyright 2011 user890104
3
//    Copyright 2013 user890104
4
//
4
//
5
//
5
//
6
//    This file is part of emCORE.
6
//    This file is part of emCORE.
7
//
7
//
8
//    emCORE is free software: you can redistribute it and/or
8
//    emCORE is free software: you can redistribute it and/or
Line 18... Line 18...
18
//    You should have received a copy of the GNU General Public License along
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/>.
19
//    with emCORE.  If not, see <http://www.gnu.org/licenses/>.
20
//
20
//
21
//
21
//
22
 
22
 
23
 
-
 
24
#ifndef __EMCORE_H__
23
#ifndef __EMCORE_H__
25
#define __EMCORE_H__
24
#define __EMCORE_H__
26
 
25
 
27
#include "global.h"
26
#include "global.h"
28
 
27
 
29
#define EMCORE_USB_VID 0xFFFF
28
#define EMCORE_USB_VID 0xFFFF
30
#define EMCORE_USB_PID 0xE000
29
#define EMCORE_USB_PID 0xE000
31
 
30
 
32
#define EMCORE_HEADER_SIZE 0x10
31
#define EMCORE_USB_INTERFACE_CLASS 0xFF
33
 
-
 
-
 
32
#define EMCORE_USB_INTERFACE_SUB_CLASS 0x00
-
 
33
#define EMCORE_USB_INTERFACE_PROTOCOL 0x00
34
 
34
 
35
struct emcore_usb_endpoints_addr
35
#define EMCORE_HEADER_SIZE 0x10
36
{
-
 
37
    uint8_t cout;
-
 
38
    uint8_t cin;
-
 
39
    uint8_t dout;
-
 
40
    uint8_t din;
-
 
41
};
-
 
42
 
-
 
43
struct emcore_usb_endpoints_max_packet_size
-
 
44
{
-
 
45
    uint16_t cout;
-
 
46
    uint16_t cin;
-
 
47
    uint32_t dout;
-
 
48
    uint32_t din;
-
 
49
};
-
 
50
 
36
 
51
struct emcore_dev_info
37
struct emcore_dev_info {
52
{
-
 
53
    uint32_t svn_revision;
38
    uint32_t svn_revision;
54
    uint8_t major, minor, patch, sw_type;
39
    uint8_t major, minor, patch, sw_type;
55
    uint32_t hw_type;
40
    uint32_t hw_type;
56
};
41
} __attribute__ ((packed));
57
 
42
 
58
struct emcore_user_mem_range
43
struct emcore_malloc_pool_bounds {
59
{
-
 
60
    uint32_t lower;
44
    uint32_t lower;
61
    uint32_t upper;
45
    uint32_t upper;
62
};
46
} __attribute__ ((packed));
63
 
47
 
64
struct emcore_dir_entry
48
struct emcore_dir_entry {
65
{
-
 
66
    char* name;
49
    char *name;
67
    uint32_t attributes;
50
    uint32_t attributes;
68
    uint32_t size;
51
    uint32_t size;
69
    uint32_t startcluster;
52
    uint32_t startcluster;
70
    uint16_t wrtdate;
53
    uint16_t wrtdate;
71
    uint16_t wrttime;
54
    uint16_t wrttime;
72
};
55
} __attribute__ ((packed));
73
 
56
 
74
enum emcore_error
57
enum emcore_error {
75
{
-
 
76
    EMCORE_SUCCESS,
58
    EMCORE_SUCCESS,
77
    EMCORE_ERROR_INVALID,
59
    EMCORE_ERROR_INVALID,
78
    EMCORE_ERROR_NOT_SUPPORTED,
60
    EMCORE_ERROR_NOT_SUPPORTED,
79
    EMCORE_ERROR_BUSY,
61
    EMCORE_ERROR_BUSY,
80
    EMCORE_ERROR_NO_DEVICE,
62
    EMCORE_ERROR_NO_DEVICE,
Line 83... Line 65...
83
    EMCORE_ERROR_NOT_IMPLEMENTED,
65
    EMCORE_ERROR_NOT_IMPLEMENTED,
84
    EMCORE_ERROR_NO_MORE_ENTRIES,
66
    EMCORE_ERROR_NO_MORE_ENTRIES,
85
    EMCORE_ERROR_IO,
67
    EMCORE_ERROR_IO,
86
};
68
};
87
 
69
 
88
int emcore_cout(const void* data, uint32_t length);
70
int32_t emcore_send(const void *data, uint32_t length);
89
int emcore_cin(void* data, uint32_t length);
71
int32_t emcore_receive(void *data, uint32_t length);
90
int emcore_dout(const void* data, uint32_t length);
-
 
91
int emcore_din(void* data, uint32_t length);
-
 
92
 
72
 
93
int emcore_monitor_command(const void* out, void* in, uint32_t send_length, uint32_t receive_length);
73
int32_t emcore_monitor_command(const void *out, void *in, uint32_t send_length, uint32_t receive_length);
94
 
74
 
95
int emcore_get_version(struct emcore_dev_info* dev_info);
75
int32_t emcore_get_version(struct emcore_dev_info *dev_info);
96
int emcore_get_packet_info(struct emcore_usb_endpoints_max_packet_size* max_packet_size);
-
 
97
int emcore_get_user_mem_range(struct emcore_user_mem_range* mem_range);
76
int32_t emcore_get_malloc_pool_bounds(struct emcore_malloc_pool_bounds *bounds);
98
int emcore_reset(uint8_t graceful);
77
int32_t emcore_reset(uint8_t graceful);
99
int emcore_poweroff(uint8_t graceful);
78
int32_t emcore_poweroff(uint8_t graceful);
100
int emcore_readmem(void* data, uint32_t addr, uint32_t size);
-
 
101
int emcore_writemem(const void* data, uint32_t addr, uint32_t size);
-
 
102
int emcore_readdma(void* data, uint32_t addr, uint32_t size);
79
int32_t emcore_read(void *data, uint32_t addr, uint32_t size);
103
int emcore_writedma(const void* data, uint32_t addr, uint32_t size);
80
int32_t emcore_write(const void *data, uint32_t addr, uint32_t size);
104
int emcore_readi2c(void* data, uint8_t bus, uint8_t slave, uint8_t addr, uint8_t size);
81
int32_t emcore_readi2c(void *data, uint8_t bus, uint8_t slave, uint8_t addr, uint8_t size);
105
int emcore_writei2c(const 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);
106
int emcore_file_open(uint32_t* handle, const char* pathname, int flags);
83
int32_t emcore_file_open(uint32_t *handle, const char *path, uint32_t flags);
107
int emcore_file_size(uint32_t* size, uint32_t handle);
84
int32_t emcore_file_size(uint32_t *size, uint32_t handle);
108
int emcore_file_read(uint32_t* nread, uint32_t handle, uint32_t addr, uint32_t size);
85
int32_t emcore_file_read(uint32_t *nread, uint32_t handle, uint32_t addr, uint32_t size);
109
int emcore_file_write(uint32_t* nwrite, 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);
110
int emcore_file_seek(uint32_t handle, uint32_t offset, uint32_t whence);
87
int32_t emcore_file_seek(uint32_t handle, uint32_t offset, uint32_t whence);
111
int emcore_file_truncate(uint32_t handle, uint32_t length);
88
int32_t emcore_file_truncate(uint32_t handle, uint32_t length);
112
int emcore_file_sync(uint32_t handle);
89
int32_t emcore_file_sync(uint32_t handle);
113
int emcore_file_close(uint32_t handle);
90
int32_t emcore_file_close(uint32_t handle);
114
int emcore_file_close_all(uint32_t* count);
91
int32_t emcore_file_close_all(uint32_t *count);
115
int emcore_file_kill_all(uint32_t volume);
92
int32_t emcore_file_kill_all(uint32_t volume);
116
int emcore_file_unlink(const char* name);
93
int32_t emcore_file_unlink(const char *path);
117
int emcore_file_rename(const char* path, const char* newpath);
94
int32_t emcore_file_rename(const char *path, const char *newpath);
118
int emcore_dir_open(uint32_t* handle, const char* name);
95
int32_t emcore_dir_open(uint32_t *handle, const char *name);
119
int emcore_dir_read(struct emcore_dir_entry* entry, uint32_t handle);
96
int32_t emcore_dir_read(struct emcore_dir_entry *entry, uint32_t handle);
120
int emcore_dir_close(uint32_t handle);
97
int32_t emcore_dir_close(uint32_t handle);
121
int emcore_dir_close_all(uint32_t* count);
98
int32_t emcore_dir_close_all(uint32_t *count);
122
int emcore_dir_create(const char* name);
99
int32_t emcore_dir_create(const char *name);
123
int emcore_dir_remove(const char* name);
100
int32_t emcore_dir_remove(const char *name);
124
int emcore_errno(uint32_t* emcore_errno_value);
101
int32_t emcore_errno(uint32_t *emcore_errno_value);
125
int emcore_malloc(uint32_t* ptr, uint32_t size);
102
int32_t emcore_malloc(uint32_t *ptr, uint32_t size);
126
int emcore_memalign(uint32_t* ptr, uint32_t align, uint32_t size);
103
int32_t emcore_memalign(uint32_t *ptr, uint32_t align, uint32_t size);
127
int emcore_realloc(uint32_t* new_ptr, uint32_t ptr, uint32_t size);
104
int32_t emcore_realloc(uint32_t *new_ptr, uint32_t ptr, uint32_t size);
128
int emcore_reownalloc(uint32_t ptr, uint32_t owner);
105
int32_t emcore_reownalloc(uint32_t ptr, uint32_t owner);
129
int emcore_free(uint32_t ptr);
106
int32_t emcore_free(uint32_t ptr);
130
int emcore_free_all(void);
107
int32_t emcore_free_all(void);
131
 
108
 
132
int emcore_read(void* data, uint32_t addr, uint32_t size);
-
 
133
int emcore_write(const void* data, uint32_t addr, uint32_t size);
-
 
134
int emcore_ls(uint32_t handle);
109
int32_t emcore_ls(uint32_t handle);
135
int emcore_test(void);
110
int32_t emcore_test(void);
136
 
111
 
137
#endif /* __EMCORE_H__ */
112
#endif /* __EMCORE_H__ */