Subversion Repositories freemyipod

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
770 user890104 1
//
2
//
3
//    Copyright 2011 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
 
24
#ifndef __EMCORE_H__
25
#define __EMCORE_H__
26
 
27
#include "global.h"
28
 
29
#define EMCORE_USB_VID 0xFFFF
30
#define EMCORE_USB_PID 0xE000
31
 
32
#define EMCORE_HEADER_SIZE 0x10
33
 
34
 
35
struct emcore_usb_endpoints_addr
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
 
51
struct emcore_dev_info
52
{
53
    uint32_t svn_revision;
54
    uint8_t major, minor, patch, sw_type;
55
    uint32_t hw_type;
56
};
57
 
58
struct emcore_user_mem_range
59
{
60
    uint32_t lower;
61
    uint32_t upper;
62
};
63
 
64
struct emcore_dir_entry
65
{
66
    char* name;
67
    uint32_t attributes;
68
    uint32_t size;
69
    uint32_t startcluster;
70
    uint16_t wrtdate;
71
    uint16_t wrttime;
72
};
73
 
74
enum emcore_error
75
{
76
    EMCORE_SUCCESS,
77
    EMCORE_ERROR_INVALID,
78
    EMCORE_ERROR_NOT_SUPPORTED,
79
    EMCORE_ERROR_BUSY,
80
    EMCORE_ERROR_NO_DEVICE,
81
    EMCORE_ERROR_INCOMPLETE,
82
    EMCORE_ERROR_OVERFLOW,
83
    EMCORE_ERROR_NOT_IMPLEMENTED,
84
    EMCORE_ERROR_NO_MORE_ENTRIES,
85
    EMCORE_ERROR_IO,
86
};
87
 
785 user890104 88
int emcore_cout(const void* data, uint32_t length);
89
int emcore_cin(void* data, uint32_t length);
90
int emcore_dout(const void* data, uint32_t length);
91
int emcore_din(void* data, uint32_t length);
770 user890104 92
 
785 user890104 93
int emcore_monitor_command(const void* out, void* in, uint32_t send_length, uint32_t receive_length);
770 user890104 94
 
95
int 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);
785 user890104 98
int emcore_reset(uint8_t graceful);
99
int 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);
103
int emcore_writedma(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);
105
int 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);
107
int 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);
109
int 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);
111
int emcore_file_truncate(uint32_t handle, uint32_t length);
112
int emcore_file_sync(uint32_t handle);
113
int emcore_file_close(uint32_t handle);
770 user890104 114
int emcore_file_close_all(uint32_t* count);
785 user890104 115
int emcore_file_kill_all(uint32_t volume);
770 user890104 116
int emcore_file_unlink(const char* name);
117
int emcore_file_rename(const char* path, const char* newpath);
118
int emcore_dir_open(uint32_t* handle, const char* name);
785 user890104 119
int emcore_dir_read(struct emcore_dir_entry* entry, uint32_t handle);
120
int emcore_dir_close(uint32_t handle);
770 user890104 121
int emcore_dir_close_all(uint32_t* count);
782 user890104 122
int emcore_dir_create(const char* name);
123
int emcore_dir_remove(const char* name);
770 user890104 124
int emcore_errno(uint32_t* emcore_errno_value);
785 user890104 125
int emcore_malloc(uint32_t* ptr, uint32_t size);
126
int 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);
128
int emcore_reownalloc(uint32_t ptr, uint32_t owner);
129
int emcore_free(uint32_t ptr);
770 user890104 130
int emcore_free_all(void);
131
 
785 user890104 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);
770 user890104 135
int emcore_test(void);
136
 
137
#endif /* __EMCORE_H__ */