Subversion Repositories freemyipod

Rev

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

Rev 784 Rev 785
Line 29... Line 29...
29
 
29
 
30
 
30
 
31
struct emcore_usb_endpoints_addr emcore_usb_eps_addr;
31
struct emcore_usb_endpoints_addr emcore_usb_eps_addr;
32
struct emcore_usb_endpoints_max_packet_size emcore_usb_eps_mps;
32
struct emcore_usb_endpoints_max_packet_size emcore_usb_eps_mps;
33
 
33
 
34
int emcore_cout(const void* data, const uint32_t length)
34
int emcore_cout(const void* data, uint32_t length)
35
{
35
{
36
    return usb_bulk_transfer(emcore_usb_eps_addr.cout, (void*)data, length);
36
    return usb_bulk_transfer(emcore_usb_eps_addr.cout, (void*)data, length);
37
}
37
}
38
 
38
 
39
int emcore_cin(void* data, const uint32_t length)
39
int emcore_cin(void* data, uint32_t length)
40
{
40
{
41
    return usb_bulk_transfer(emcore_usb_eps_addr.cin, data, length);
41
    return usb_bulk_transfer(emcore_usb_eps_addr.cin, data, length);
42
}
42
}
43
 
43
 
44
int emcore_dout(const void* data, const uint32_t length)
44
int emcore_dout(const void* data, uint32_t length)
45
{
45
{
46
    return usb_bulk_transfer(emcore_usb_eps_addr.dout, (void*)data, length);
46
    return usb_bulk_transfer(emcore_usb_eps_addr.dout, (void*)data, length);
47
}
47
}
48
 
48
 
49
int emcore_din(void* data, const uint32_t length)
49
int emcore_din(void* data, uint32_t length)
50
{
50
{
51
    return usb_bulk_transfer(emcore_usb_eps_addr.din, data, length);
51
    return usb_bulk_transfer(emcore_usb_eps_addr.din, data, length);
52
}
52
}
53
 
53
 
54
int emcore_monitor_command(const void* out, void* in,
54
int emcore_monitor_command(const void* out, void* in,
55
    const uint32_t send_length, const uint32_t receive_length)
55
    uint32_t send_length, uint32_t receive_length)
56
{
56
{
57
    int res;
57
    int res;
58
    uint32_t status;
58
    uint32_t status;
59
 
59
 
60
#ifdef DEBUG_USB_PACKETS
60
#ifdef DEBUG_USB_PACKETS
Line 168... Line 168...
168
    memcpy(mem_range, &in[1], sizeof(*mem_range));
168
    memcpy(mem_range, &in[1], sizeof(*mem_range));
169
 
169
 
170
    return EMCORE_SUCCESS;
170
    return EMCORE_SUCCESS;
171
}
171
}
172
 
172
 
173
int emcore_reset(const uint8_t graceful)
173
int emcore_reset(uint8_t graceful)
174
{
174
{
175
    int res;
175
    int res;
176
    uint32_t out[4] = { 2, 0xdeadbeef, 0, 0 }, in[4];
176
    uint32_t out[4] = { 2, 0xdeadbeef, 0, 0 }, in[4];
177
 
177
 
178
    out[1] = graceful;
178
    out[1] = graceful;
Line 185... Line 185...
185
    }
185
    }
186
 
186
 
187
    return EMCORE_SUCCESS;
187
    return EMCORE_SUCCESS;
188
}
188
}
189
 
189
 
190
int emcore_poweroff(const uint8_t graceful)
190
int emcore_poweroff(uint8_t graceful)
191
{
191
{
192
    int res;
192
    int res;
193
    uint32_t out[4] = { 3, 0xdeadbeef, 0, 0 }, in[4];
193
    uint32_t out[4] = { 3, 0xdeadbeef, 0, 0 }, in[4];
194
 
194
 
195
    out[1] = graceful;
195
    out[1] = graceful;
Line 202... Line 202...
202
    }
202
    }
203
 
203
 
204
    return EMCORE_SUCCESS;
204
    return EMCORE_SUCCESS;
205
}
205
}
206
 
206
 
207
int emcore_readmem(void* data, const uint32_t addr, const uint32_t size)
207
int emcore_readmem(void* data, uint32_t addr, uint32_t size)
208
{
208
{
209
    int res;
209
    int res;
210
    uint32_t data_length, out[4] = { 4, 0xdeadbeef, 0xdeadbeef, 0 };
210
    uint32_t data_length, out[4] = { 4, 0xdeadbeef, 0xdeadbeef, 0 };
211
    void* in;
211
    void* in;
212
 
212
 
Line 231... Line 231...
231
    memcpy(data, in + EMCORE_HEADER_SIZE, size);
231
    memcpy(data, in + EMCORE_HEADER_SIZE, size);
232
 
232
 
233
    return EMCORE_SUCCESS;
233
    return EMCORE_SUCCESS;
234
}
234
}
235
 
235
 
236
int emcore_writemem(const void* data, const uint32_t addr, const uint32_t size)
236
int emcore_writemem(const void* data, uint32_t addr, uint32_t size)
237
{
237
{
238
    int res;
238
    int res;
239
    uint32_t data_length, in[4], *out;
239
    uint32_t data_length, in[4], *out;
240
 
240
 
241
    if (size + EMCORE_HEADER_SIZE > emcore_usb_eps_mps.cout)
241
    if (size + EMCORE_HEADER_SIZE > emcore_usb_eps_mps.cout)
Line 260... Line 260...
260
    }
260
    }
261
 
261
 
262
    return EMCORE_SUCCESS;
262
    return EMCORE_SUCCESS;
263
}
263
}
264
 
264
 
265
int emcore_readdma(void* data, const uint32_t addr, const uint32_t size)
265
int emcore_readdma(void* data, uint32_t addr, uint32_t size)
266
{
266
{
267
    int res;
267
    int res;
268
    uint32_t out[4] = { 6, 0xdeadbeef, 0xdeadbeef, 0 }, in[4];
268
    uint32_t out[4] = { 6, 0xdeadbeef, 0xdeadbeef, 0 }, in[4];
269
 
269
 
270
    out[1] = addr;
270
    out[1] = addr;
Line 285... Line 285...
285
    res = emcore_din(data, size);
285
    res = emcore_din(data, size);
286
 
286
 
287
    return EMCORE_SUCCESS;
287
    return EMCORE_SUCCESS;
288
}
288
}
289
 
289
 
290
int emcore_writedma(const void* data, const uint32_t addr, const uint32_t size)
290
int emcore_writedma(const void* data, uint32_t addr, uint32_t size)
291
{
291
{
292
    int res;
292
    int res;
293
    uint32_t out[4] = { 7, 0xdeadbeef, 0xdeadbeef, 0 }, in[4];
293
    uint32_t out[4] = { 7, 0xdeadbeef, 0xdeadbeef, 0 }, in[4];
294
 
294
 
295
    out[1] = addr;
295
    out[1] = addr;
Line 310... Line 310...
310
    res = emcore_dout(data, size);
310
    res = emcore_dout(data, size);
311
 
311
 
312
    return EMCORE_SUCCESS;
312
    return EMCORE_SUCCESS;
313
}
313
}
314
 
314
 
315
int emcore_readi2c(void* data, const uint8_t bus, const uint8_t slave, const uint8_t addr, const uint8_t size)
315
int emcore_readi2c(void* data, uint8_t bus, uint8_t slave, uint8_t addr, uint8_t size)
316
{
316
{
317
    int res;
317
    int res;
318
    uint32_t data_length, out[4] = { 8, 0xdeadbeef, 0, 0 };
318
    uint32_t data_length, out[4] = { 8, 0xdeadbeef, 0, 0 };
319
    void* in;
319
    void* in;
320
 
320
 
Line 338... Line 338...
338
    memcpy(data, in + 16, size);
338
    memcpy(data, in + 16, size);
339
 
339
 
340
    return EMCORE_SUCCESS;
340
    return EMCORE_SUCCESS;
341
}
341
}
342
 
342
 
343
int emcore_writei2c(const void* data, const uint8_t bus, const uint8_t slave, const uint8_t addr, const uint8_t size)
343
int emcore_writei2c(const void* data, uint8_t bus, uint8_t slave, uint8_t addr, uint8_t size)
344
{
344
{
345
    int res;
345
    int res;
346
    uint32_t data_length, in[4], *out;
346
    uint32_t data_length, in[4], *out;
347
 
347
 
348
    if (size + EMCORE_HEADER_SIZE > emcore_usb_eps_mps.cout)
348
    if (size + EMCORE_HEADER_SIZE > emcore_usb_eps_mps.cout)
Line 369... Line 369...
369
    }
369
    }
370
 
370
 
371
    return EMCORE_SUCCESS;
371
    return EMCORE_SUCCESS;
372
}
372
}
373
 
373
 
374
int emcore_file_open(uint32_t* handle, const char* path, const int flags)
374
int emcore_file_open(uint32_t* handle, const char* path, int flags)
375
{
375
{
376
    int res;
376
    int res;
377
    uint32_t str_length, data_length, in[4], *out;
377
    uint32_t str_length, data_length, in[4], *out;
378
    int flags_emcore = 0;
378
    int flags_emcore = 0;
379
    
379
    
Line 439... Line 439...
439
    *handle = in[1];
439
    *handle = in[1];
440
 
440
 
441
    return EMCORE_SUCCESS;
441
    return EMCORE_SUCCESS;
442
}
442
}
443
 
443
 
444
int emcore_file_size(uint32_t* size, const uint32_t handle)
444
int emcore_file_size(uint32_t* size, uint32_t handle)
445
{
445
{
446
    int res;
446
    int res;
447
    uint32_t out[4] = { 31, 0xdeadbeef, 0, 0 }, in[4];
447
    uint32_t out[4] = { 31, 0xdeadbeef, 0, 0 }, in[4];
448
    
448
    
449
    out[1] = handle;
449
    out[1] = handle;
Line 463... Line 463...
463
    *size = in[1];
463
    *size = in[1];
464
    
464
    
465
    return EMCORE_SUCCESS;
465
    return EMCORE_SUCCESS;
466
}
466
}
467
 
467
 
468
int emcore_file_read(uint32_t* nread, const uint32_t handle, const uint32_t addr, const uint32_t size)
468
int emcore_file_read(uint32_t* nread, uint32_t handle, uint32_t addr, uint32_t size)
469
{
469
{
470
    int res;
470
    int res;
471
    uint32_t out[4] = { 32, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef }, in[4];
471
    uint32_t out[4] = { 32, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef }, in[4];
472
    
472
    
473
    out[1] = handle;
473
    out[1] = handle;
Line 489... Line 489...
489
    *nread = in[1];
489
    *nread = in[1];
490
    
490
    
491
    return EMCORE_SUCCESS;
491
    return EMCORE_SUCCESS;
492
}
492
}
493
 
493
 
494
int emcore_file_write(uint32_t* nwrite, const uint32_t handle, const uint32_t addr, const uint32_t size)
494
int emcore_file_write(uint32_t* nwrite, uint32_t handle, uint32_t addr, uint32_t size)
495
{
495
{
496
    int res;
496
    int res;
497
    uint32_t out[4] = { 33, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef }, in[4];
497
    uint32_t out[4] = { 33, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef }, in[4];
498
    
498
    
499
    out[1] = handle;
499
    out[1] = handle;
Line 515... Line 515...
515
    *nwrite = in[1];
515
    *nwrite = in[1];
516
    
516
    
517
    return EMCORE_SUCCESS;
517
    return EMCORE_SUCCESS;
518
}
518
}
519
 
519
 
520
int emcore_file_seek(const uint32_t handle, const uint32_t offset, const uint32_t whence)
520
int emcore_file_seek(uint32_t handle, uint32_t offset, uint32_t whence)
521
{
521
{
522
    int res;
522
    int res;
523
    uint32_t out[4] = { 34, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef }, in[4];
523
    uint32_t out[4] = { 34, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef }, in[4];
524
    
524
    
525
    out[1] = handle;
525
    out[1] = handle;
Line 539... Line 539...
539
    }
539
    }
540
    
540
    
541
    return EMCORE_SUCCESS;
541
    return EMCORE_SUCCESS;
542
}
542
}
543
 
543
 
544
int emcore_file_truncate(const uint32_t handle, const uint32_t length)
544
int emcore_file_truncate(uint32_t handle, uint32_t length)
545
{
545
{
546
    int res;
546
    int res;
547
    uint32_t out[4] = { 35, 0xdeadbeef, 0xdeadbeef, 0 }, in[4];
547
    uint32_t out[4] = { 35, 0xdeadbeef, 0xdeadbeef, 0 }, in[4];
548
    
548
    
549
    out[1] = handle;
549
    out[1] = handle;
Line 562... Line 562...
562
    }
562
    }
563
    
563
    
564
    return EMCORE_SUCCESS;
564
    return EMCORE_SUCCESS;
565
}
565
}
566
 
566
 
567
int emcore_file_sync(const uint32_t handle)
567
int emcore_file_sync(uint32_t handle)
568
{
568
{
569
    int res;
569
    int res;
570
    uint32_t out[4] = { 36, 0xdeadbeef, 0, 0 }, in[4];
570
    uint32_t out[4] = { 36, 0xdeadbeef, 0, 0 }, in[4];
571
 
571
 
572
    out[1] = handle;
572
    out[1] = handle;
Line 584... Line 584...
584
    }
584
    }
585
    
585
    
586
    return EMCORE_SUCCESS;
586
    return EMCORE_SUCCESS;
587
}
587
}
588
 
588
 
589
int emcore_file_close(const uint32_t handle)
589
int emcore_file_close(uint32_t handle)
590
{
590
{
591
    int res;
591
    int res;
592
    uint32_t out[4] = { 37, 0xdeadbeef, 0, 0 }, in[4];
592
    uint32_t out[4] = { 37, 0xdeadbeef, 0, 0 }, in[4];
593
 
593
 
594
    out[1] = handle;
594
    out[1] = handle;
Line 628... Line 628...
628
    *count = in[1];
628
    *count = in[1];
629
 
629
 
630
    return EMCORE_SUCCESS;
630
    return EMCORE_SUCCESS;
631
}
631
}
632
 
632
 
633
int emcore_file_kill_all(const uint32_t volume)
633
int emcore_file_kill_all(uint32_t volume)
634
{
634
{
635
    int res;
635
    int res;
636
    uint32_t out[4] = { 39, 0xdeadbeef, 0, 0 }, in[4];
636
    uint32_t out[4] = { 39, 0xdeadbeef, 0, 0 }, in[4];
637
 
637
 
638
    out[1] = volume;
638
    out[1] = volume;
Line 749... Line 749...
749
    *handle = in[1];
749
    *handle = in[1];
750
 
750
 
751
    return EMCORE_SUCCESS;
751
    return EMCORE_SUCCESS;
752
}
752
}
753
 
753
 
754
int emcore_dir_read(struct emcore_dir_entry* entry, const uint32_t handle)
754
int emcore_dir_read(struct emcore_dir_entry* entry, uint32_t handle)
755
{
755
{
756
    int res;
756
    int res;
757
    uint32_t maxpath, ptr, dirent_size, emcore_errno_value, filename_buf_len,
757
    uint32_t maxpath, ptr, dirent_size, emcore_errno_value, filename_buf_len,
758
        out[4] = { 43, 0xdeadbeef, 0, 0 }, in[4];
758
        out[4] = { 43, 0xdeadbeef, 0, 0 }, in[4];
759
    void *buf;
759
    void *buf;
Line 823... Line 823...
823
        (unsigned long) fat_time_to_unix_ts(entry->wrttime, entry->wrtdate));
823
        (unsigned long) fat_time_to_unix_ts(entry->wrttime, entry->wrtdate));
824
#endif
824
#endif
825
    return EMCORE_SUCCESS;
825
    return EMCORE_SUCCESS;
826
}
826
}
827
 
827
 
828
int emcore_dir_close(const uint32_t handle)
828
int emcore_dir_close(uint32_t handle)
829
{
829
{
830
    int res;
830
    int res;
831
    uint32_t out[4] = { 44, 0xdeadbeef, 0, 0 }, in[4];
831
    uint32_t out[4] = { 44, 0xdeadbeef, 0, 0 }, in[4];
832
 
832
 
833
    out[1] = handle;
833
    out[1] = handle;
Line 952... Line 952...
952
    *emcore_errno_value = in[1];
952
    *emcore_errno_value = in[1];
953
 
953
 
954
    return EMCORE_SUCCESS;
954
    return EMCORE_SUCCESS;
955
}
955
}
956
 
956
 
957
int emcore_malloc(uint32_t* ptr, const uint32_t size)
957
int emcore_malloc(uint32_t* ptr, uint32_t size)
958
{
958
{
959
    int res;
959
    int res;
960
    uint32_t out[4] = { 52, 0xdeadbeef, 0, 0 }, in[4];
960
    uint32_t out[4] = { 52, 0xdeadbeef, 0, 0 }, in[4];
961
 
961
 
962
    out[1] = size;
962
    out[1] = size;
Line 971... Line 971...
971
    *ptr = in[1];
971
    *ptr = in[1];
972
 
972
 
973
    return EMCORE_SUCCESS;
973
    return EMCORE_SUCCESS;
974
}
974
}
975
 
975
 
976
int emcore_memalign(uint32_t* ptr, const uint32_t align, const uint32_t size)
976
int emcore_memalign(uint32_t* ptr, uint32_t align, uint32_t size)
977
{
977
{
978
    int res;
978
    int res;
979
    uint32_t out[4] = { 53, 0xdeadbeef, 0xdeadbeef, 0 }, in[4];
979
    uint32_t out[4] = { 53, 0xdeadbeef, 0xdeadbeef, 0 }, in[4];
980
 
980
 
981
    out[1] = align;
981
    out[1] = align;
Line 991... Line 991...
991
    *ptr = in[1];
991
    *ptr = in[1];
992
 
992
 
993
    return EMCORE_SUCCESS;
993
    return EMCORE_SUCCESS;
994
}
994
}
995
 
995
 
996
int emcore_realloc(uint32_t* new_ptr, const uint32_t ptr, const uint32_t size)
996
int emcore_realloc(uint32_t* new_ptr, uint32_t ptr, uint32_t size)
997
{
997
{
998
    int res;
998
    int res;
999
    uint32_t out[4] = { 54, 0xdeadbeef, 0xdeadbeef, 0 }, in[4];
999
    uint32_t out[4] = { 54, 0xdeadbeef, 0xdeadbeef, 0 }, in[4];
1000
 
1000
 
1001
    out[1] = ptr;
1001
    out[1] = ptr;
Line 1011... Line 1011...
1011
    *new_ptr = in[1];
1011
    *new_ptr = in[1];
1012
 
1012
 
1013
    return EMCORE_SUCCESS;
1013
    return EMCORE_SUCCESS;
1014
}
1014
}
1015
 
1015
 
1016
int emcore_reownalloc(const uint32_t ptr, const uint32_t owner)
1016
int emcore_reownalloc(uint32_t ptr, uint32_t owner)
1017
{
1017
{
1018
    uint32_t out[4] = { 55, 0xdeadbeef, 0xdeadbeef, 0 }, in[4];
1018
    uint32_t out[4] = { 55, 0xdeadbeef, 0xdeadbeef, 0 }, in[4];
1019
 
1019
 
1020
    out[1] = ptr;
1020
    out[1] = ptr;
1021
    out[2] = owner;
1021
    out[2] = owner;
1022
 
1022
 
1023
    return emcore_monitor_command(out, in, 16, 16);
1023
    return emcore_monitor_command(out, in, 16, 16);
1024
}
1024
}
1025
 
1025
 
1026
int emcore_free(const uint32_t ptr)
1026
int emcore_free(uint32_t ptr)
1027
{
1027
{
1028
    uint32_t out[4] = { 56, 0xdeadbeef, 0, 0 }, in[4];
1028
    uint32_t out[4] = { 56, 0xdeadbeef, 0, 0 }, in[4];
1029
 
1029
 
1030
    out[1] = ptr;
1030
    out[1] = ptr;
1031
 
1031
 
Line 1037... Line 1037...
1037
    uint32_t out[4] = { 57, 0, 0, 0 }, in[4];
1037
    uint32_t out[4] = { 57, 0, 0, 0 }, in[4];
1038
 
1038
 
1039
    return emcore_monitor_command(out, in, 16, 16);
1039
    return emcore_monitor_command(out, in, 16, 16);
1040
}
1040
}
1041
 
1041
 
1042
int emcore_read(void* data, const uint32_t addr, const uint32_t size)
1042
int emcore_read(void* data, uint32_t addr, uint32_t size)
1043
{
1043
{
1044
    int res;
1044
    int res;
1045
    struct alignsizes* sizes;
1045
    struct alignsizes* sizes;
1046
    uint32_t cin_maxsize, readsize, curraddr;
1046
    uint32_t cin_maxsize, readsize, curraddr;
1047
 
1047
 
Line 1105... Line 1105...
1105
    }
1105
    }
1106
 
1106
 
1107
    return EMCORE_SUCCESS;
1107
    return EMCORE_SUCCESS;
1108
}
1108
}
1109
 
1109
 
1110
int emcore_write(const void* data, const uint32_t addr, const uint32_t size)
1110
int emcore_write(const void* data, uint32_t addr, uint32_t size)
1111
{
1111
{
1112
    int res;
1112
    int res;
1113
    struct alignsizes* sizes;
1113
    struct alignsizes* sizes;
1114
    uint32_t cout_maxsize, writesize, curraddr;
1114
    uint32_t cout_maxsize, writesize, curraddr;
1115
 
1115
 
Line 1173... Line 1173...
1173
    }
1173
    }
1174
 
1174
 
1175
    return EMCORE_SUCCESS;
1175
    return EMCORE_SUCCESS;
1176
}
1176
}
1177
 
1177
 
1178
int emcore_ls(const uint32_t handle)
1178
int emcore_ls(uint32_t handle)
1179
{
1179
{
1180
    int res = 0;
1180
    int res = 0;
1181
    struct emcore_dir_entry entry;
1181
    struct emcore_dir_entry entry;
1182
 
1182
 
1183
    while (1)
1183
    while (1)