-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathaaruremote.h
657 lines (606 loc) · 21.7 KB
/
aaruremote.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
/*
* This file is part of the Aaru Remote Server.
* Copyright (c) 2019-2025 Natalia Portillo.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef AARUREMOTE__AARUREMOTE_H_
#define AARUREMOTE__AARUREMOTE_H_
#ifdef GEKKO
#include <network.h>
#ifndef MSG_PEEK
#define MSG_PEEK 0x02 // TODO: Untested, may not work
#endif
#elif !defined(_WIN32)
#include <netinet/in.h>
#include <sys/socket.h>
#endif
#define AARUREMOTE_NAME "Aaru Remote Server"
#define AARUREMOTE_VERSION "0.99.195"
#define AARUREMOTE_PORT 6666
#define AARUREMOTE_REMOTE_ID 0x52434944 // "DICR"
#define AARUREMOTE_PACKET_ID 0x544B4350 // "PCKT"
#define AARUREMOTE_PACKET_VERSION 1
#define AARUREMOTE_PACKET_TYPE_NOP -1
#define AARUREMOTE_PACKET_TYPE_HELLO 1
#define AARUREMOTE_PACKET_TYPE_COMMAND_LIST_DEVICES 2
#define AARUREMOTE_PACKET_TYPE_RESPONSE_LIST_DEVICES 3
#define AARUREMOTE_PACKET_TYPE_COMMAND_OPEN_DEVICE 4
#define AARUREMOTE_PACKET_TYPE_COMMAND_SCSI 5
#define AARUREMOTE_PACKET_TYPE_RESPONSE_SCSI 6
#define AARUREMOTE_PACKET_TYPE_COMMAND_ATA_CHS 7
#define AARUREMOTE_PACKET_TYPE_RESPONSE_ATA_CHS 8
#define AARUREMOTE_PACKET_TYPE_COMMAND_ATA_LBA_28 9
#define AARUREMOTE_PACKET_TYPE_RESPONSE_ATA_LBA_28 10
#define AARUREMOTE_PACKET_TYPE_COMMAND_ATA_LBA_48 11
#define AARUREMOTE_PACKET_TYPE_RESPONSE_ATA_LBA_48 12
#define AARUREMOTE_PACKET_TYPE_COMMAND_SDHCI 13
#define AARUREMOTE_PACKET_TYPE_RESPONSE_SDHCI 14
#define AARUREMOTE_PACKET_TYPE_COMMAND_GET_DEVTYPE 15
#define AARUREMOTE_PACKET_TYPE_RESPONSE_GET_DEVTYPE 16
#define AARUREMOTE_PACKET_TYPE_COMMAND_GET_SDHCI_REGISTERS 17
#define AARUREMOTE_PACKET_TYPE_RESPONSE_GET_SDHCI_REGISTERS 18
#define AARUREMOTE_PACKET_TYPE_COMMAND_GET_USB_DATA 19
#define AARUREMOTE_PACKET_TYPE_RESPONSE_GET_USB_DATA 20
#define AARUREMOTE_PACKET_TYPE_COMMAND_GET_FIREWIRE_DATA 21
#define AARUREMOTE_PACKET_TYPE_RESPONSE_GET_FIREWIRE_DATA 22
#define AARUREMOTE_PACKET_TYPE_COMMAND_GET_PCMCIA_DATA 23
#define AARUREMOTE_PACKET_TYPE_RESPONSE_GET_PCMCIA_DATA 24
#define AARUREMOTE_PACKET_TYPE_COMMAND_CLOSE_DEVICE 25
#define AARUREMOTE_PACKET_TYPE_COMMAND_AM_I_ROOT 26
#define AARUREMOTE_PACKET_TYPE_RESPONSE_AM_I_ROOT 27
#define AARUREMOTE_PACKET_TYPE_MULTI_COMMAND_SDHCI 28
#define AARUREMOTE_PACKET_TYPE_RESPONSE_MULTI_SDHCI 29
#define AARUREMOTE_PACKET_TYPE_COMMAND_REOPEN 30
#define AARUREMOTE_PACKET_TYPE_COMMAND_OSREAD 31
#define AARUREMOTE_PACKET_TYPE_RESPONSE_OSREAD 32
#define AARUREMOTE_PROTOCOL_MAX 2
#define AARUREMOTE_PACKET_NOP_REASON_OOO 0
#define AARUREMOTE_PACKET_NOP_REASON_NOT_IMPLEMENTED 1
#define AARUREMOTE_PACKET_NOP_REASON_NOT_RECOGNIZED 2
#define AARUREMOTE_PACKET_NOP_REASON_ERROR_LIST_DEVICES 3
#define AARUREMOTE_PACKET_NOP_REASON_OPEN_OK 4
#define AARUREMOTE_PACKET_NOP_REASON_OPEN_ERROR 5
#define AARUREMOTE_PACKET_NOP_REASON_REOPEN_OK 6
#define AARUREMOTE_PACKET_NOP_REASON_CLOSE_ERROR 5
#define AARUREMOTE_DEVICE_TYPE_UNKNOWN -1
#define AARUREMOTE_DEVICE_TYPE_ATA 1
#define AARUREMOTE_DEVICE_TYPE_ATAPI 2
#define AARUREMOTE_DEVICE_TYPE_SCSI 3
#define AARUREMOTE_DEVICE_TYPE_SECURE_DIGITAL 4
#define AARUREMOTE_DEVICE_TYPE_MMC 5
#define AARUREMOTE_DEVICE_TYPE_NVME 6
#define AARUREMOTE_SCSI_DIRECTION_UNSPECIFIED -1
#define AARUREMOTE_SCSI_DIRECTION_NONE 0
#define AARUREMOTE_SCSI_DIRECTION_OUT 1
#define AARUREMOTE_SCSI_DIRECTION_IN 2
#define AARUREMOTE_SCSI_DIRECTION_INOUT 3
#define AARUREMOTE_ATA_PROTOCOL_HARD_RESET 0
#define AARUREMOTE_ATA_PROTOCOL_SOFT_RESET 1
#define AARUREMOTE_ATA_PROTOCOL_NO_DATA 3
#define AARUREMOTE_ATA_PROTOCOL_PIO_IN 4
#define AARUREMOTE_ATA_PROTOCOL_PIO_OUT 5
#define AARUREMOTE_ATA_PROTOCOL_DMA 6
#define AARUREMOTE_ATA_PROTOCOL_DMA_QUEUED 7
#define AARUREMOTE_ATA_PROTOCOL_DEVICE_DIAGNOSTIC 8
#define AARUREMOTE_ATA_PROTOCOL_DEVICE_RESET 9
#define AARUREMOTE_ATA_PROTOCOL_UDMA_IN 10
#define AARUREMOTE_ATA_PROTOCOL_UDMA_OUT 11
#define AARUREMOTE_ATA_PROTOCOL_FPDMA 12
#define AARUREMOTE_ATA_PROTOCOL_RETURN_RESPONSE 15
#define AARUREMOTE_ATA_TRANSFER_REGISTER_NONE 0
#define AARUREMOTE_ATA_TRANSFER_REGISTER_FEATURE 1
#define AARUREMOTE_ATA_TRANSFER_REGISTER_SECTOR_COUNT 2
#define AARUREMOTE_ATA_TRANSFER_REGISTER_SPTSIU 3
#define AARUREMOTE_MMC_RESPONSE_PRESENT (1 << 0)
#define AARUREMOTE_MMC_RESPONSE_136 (1 << 1)
#define AARUREMOTE_MMC_RESPONSE_CRC (1 << 2)
#define AARUREMOTE_MMC_RESPONSE_BUSY (1 << 3)
#define AARUREMOTE_MMC_RESPONSE_OPCODE (1 << 4)
#define AARUREMOTE_MMC_COMMAND_MASK (3 << 5)
#define AARUREMOTE_MMC_COMMAND_AC (0 << 5)
#define AARUREMOTE_MMC_COMMAND_ADTC (1 << 5)
#define AARUREMOTE_MMC_COMMAND_BC (2 << 5)
#define AARUREMOTE_MMC_COMMAND_BCR (3 << 5)
#define AARUREMOTE_MMC_RESPONSE_SPI_S1 (1 << 7)
#define AARUREMOTE_MMC_RESPONSE_SPI_S2 (1 << 8)
#define AARUREMOTE_MMC_RESPONSE_SPI_B4 (1 << 9)
#define AARUREMOTE_MMC_RESPONSE_SPI_BUSY (1 << 10)
#define AARUREMOTE_MMC_RESPONSE_NONE (0)
#define AARUREMOTE_MMC_RESPONSE_R1 \
AARUREMOTE_MMC_RESPONSE_PRESENT | AARUREMOTE_MMC_RESPONSE_CRC | AARUREMOTE_MMC_RESPONSE_OPCODE
#define AARUREMOTE_MMC_RESPONSE_R1B \
AARUREMOTE_MMC_RESPONSE_PRESENT | AARUREMOTE_MMC_RESPONSE_CRC | AARUREMOTE_MMC_RESPONSE_OPCODE | \
AARUREMOTE_MMC_RESPONSE_BUSY
#define AARUREMOTE_MMC_RESPONSE_R2 \
AARUREMOTE_MMC_RESPONSE_PRESENT | AARUREMOTE_MMC_RESPONSE_136 | AARUREMOTE_MMC_RESPONSE_CRC
#define AARUREMOTE_MMC_RESPONSE_R3 AARUREMOTE_MMC_RESPONSE_PRESENT
#define AARUREMOTE_MMC_RESPONSE_R4 AARUREMOTE_MMC_RESPONSE_PRESENT
#define AARUREMOTE_MMC_RESPONSE_R5 \
AARUREMOTE_MMC_RESPONSE_PRESENT | AARUREMOTE_MMC_RESPONSE_CRC | AARUREMOTE_MMC_RESPONSE_OPCODE
#define AARUREMOTE_MMC_RESPONSE_R6 \
AARUREMOTE_MMC_RESPONSE_PRESENT | AARUREMOTE_MMC_RESPONSE_CRC | AARUREMOTE_MMC_RESPONSE_OPCODE
#define AARUREMOTE_MMC_RESPONSE_R7 \
AARUREMOTE_MMC_RESPONSE_PRESENT | AARUREMOTE_MMC_RESPONSE_CRC | AARUREMOTE_MMC_RESPONSE_OPCODE
#define AARUREMOTE_MMC_RESPONSE_SPI_R1 AARUREMOTE_MMC_RESPONSE_SPI_S1
#define AARUREMOTE_MMC_RESPONSE_SPI_R1B AARUREMOTE_MMC_RESPONSE_SPI_S1 | AARUREMOTE_MMC_RESPONSE_SPI_BUSY
#define AARUREMOTE_MMC_RESPONSE_SPI_R2 AARUREMOTE_MMC_RESPONSE_SPI_S1 | AARUREMOTE_MMC_RESPONSE_SPI_S2
#define AARUREMOTE_MMC_RESPONSE_SPI_R3 AARUREMOTE_MMC_RESPONSE_SPI_S1 | AARUREMOTE_MMC_RESPONSE_SPI_B4
#define AARUREMOTE_MMC_RESPONSE_SPI_R4 AARUREMOTE_MMC_RESPONSE_SPI_S1 | AARUREMOTE_MMC_RESPONSE_SPI_B4
#define AARUREMOTE_MMC_RESPONSE_SPI_R5 AARUREMOTE_MMC_RESPONSE_SPI_S1 | AARUREMOTE_MMC_RESPONSE_SPI_S2
#define AARUREMOTE_MMC_RESPONSE_SPI_R7 AARUREMOTE_MMC_RESPONSE_SPI_S1 | AARUREMOTE_MMC_RESPONSE_SPI_B4
#pragma pack(push, 1)
typedef struct
{
uint32_t remote_id;
uint32_t packet_id;
uint32_t len;
uint8_t version;
int8_t packet_type;
char spare[2];
} AaruPacketHeader;
typedef struct
{
AaruPacketHeader hdr;
char application[128];
char version[64];
uint8_t max_protocol;
char spare[3];
char sysname[256];
char release[256];
char machine[256];
} AaruPacketHello;
typedef struct
{
AaruPacketHeader hdr;
} AaruPacketCmdListDevs;
typedef struct
{
AaruPacketHeader hdr;
uint16_t devices;
} AaruPacketResListDevs;
typedef struct
{
char path[1024];
char vendor[256];
char model[256];
char serial[256];
char bus[256];
uint8_t supported;
char padding[3];
} DeviceInfo;
typedef struct DeviceInfoList
{
struct DeviceInfoList* next;
DeviceInfo this;
} DeviceInfoList;
typedef struct
{
AaruPacketHeader hdr;
uint8_t reason_code;
char spare[3];
char reason[256];
int32_t error_no;
} AaruPacketNop;
typedef struct
{
AaruPacketHeader hdr;
char device_path[1024];
} AaruPacketCmdOpen;
typedef struct
{
AaruPacketHeader hdr;
uint32_t cdb_len;
uint32_t buf_len;
int32_t direction;
uint32_t timeout;
} AaruPacketCmdScsi;
typedef struct
{
AaruPacketHeader hdr;
uint32_t sense_len;
uint32_t buf_len;
uint32_t duration;
uint32_t sense;
uint32_t error_no;
} AaruPacketResScsi;
typedef struct
{
uint8_t feature;
uint8_t sector_count;
uint8_t sector;
uint8_t cylinder_low;
uint8_t cylinder_high;
uint8_t device_head;
uint8_t command;
} AtaRegistersChs;
typedef struct
{
uint8_t status;
uint8_t error;
uint8_t sector_count;
uint8_t sector;
uint8_t cylinder_low;
uint8_t cylinder_high;
uint8_t device_head;
} AtaErrorRegistersChs;
typedef struct
{
AaruPacketHeader hdr;
uint32_t buf_len;
AtaRegistersChs registers;
uint8_t protocol;
uint8_t transfer_register;
uint8_t transfer_blocks;
uint8_t spare;
uint32_t timeout;
} AaruPacketCmdAtaChs;
typedef struct
{
AaruPacketHeader hdr;
uint32_t buf_len;
AtaErrorRegistersChs registers;
uint32_t duration;
uint32_t sense;
uint32_t error_no;
} AaruPacketResAtaChs;
typedef struct
{
uint8_t feature;
uint8_t sector_count;
uint8_t lba_low;
uint8_t lba_mid;
uint8_t lba_high;
uint8_t device_head;
uint8_t command;
} AtaRegistersLba28;
typedef struct
{
uint8_t status;
uint8_t error;
uint8_t sector_count;
uint8_t lba_low;
uint8_t lba_mid;
uint8_t lba_high;
uint8_t device_head;
} AtaErrorRegistersLba28;
typedef struct
{
AaruPacketHeader hdr;
uint32_t buf_len;
AtaRegistersLba28 registers;
uint8_t protocol;
uint8_t transfer_register;
uint8_t transfer_blocks;
uint8_t spare;
uint32_t timeout;
} AaruPacketCmdAtaLba28;
typedef struct
{
AaruPacketHeader hdr;
uint32_t buf_len;
AtaErrorRegistersLba28 registers;
uint32_t duration;
uint32_t sense;
uint32_t error_no;
} AaruPacketResAtaLba28;
typedef struct
{
uint16_t feature;
uint16_t sector_count;
uint8_t lba_low_prev;
uint8_t lba_low_cur;
uint8_t lba_mid_prev;
uint8_t lba_mid_cur;
uint8_t lba_high_prev;
uint8_t lba_high_cur;
uint8_t device_head;
uint8_t command;
} AtaRegistersLba48;
typedef struct
{
uint8_t status;
uint8_t error;
uint16_t sector_count;
uint8_t lba_low_prev;
uint8_t lba_low_cur;
uint8_t lba_mid_prev;
uint8_t lba_mid_cur;
uint8_t lba_high_prev;
uint8_t lba_high_cur;
uint8_t device_head;
} AtaErrorRegistersLba48;
typedef struct
{
AaruPacketHeader hdr;
uint32_t buf_len;
AtaRegistersLba48 registers;
uint8_t protocol;
uint8_t transfer_register;
uint8_t transfer_blocks;
uint8_t spare;
uint32_t timeout;
} AaruPacketCmdAtaLba48;
typedef struct
{
AaruPacketHeader hdr;
uint32_t buf_len;
AtaErrorRegistersLba48 registers;
uint32_t duration;
uint32_t sense;
uint32_t error_no;
} AaruPacketResAtaLba48;
typedef struct
{
uint8_t command;
uint8_t write;
uint8_t application;
uint32_t flags;
uint32_t argument;
uint32_t block_size;
uint32_t blocks;
uint32_t buf_len;
uint32_t timeout;
} AaruCmdSdhci;
typedef struct
{
AaruPacketHeader hdr;
AaruCmdSdhci command;
} AaruPacketCmdSdhci;
typedef struct
{
uint32_t buf_len;
uint32_t response[4];
uint32_t duration;
uint32_t sense;
uint32_t error_no;
} AaruResSdhci;
typedef struct
{
AaruPacketHeader hdr;
AaruResSdhci res;
} AaruPacketResSdhci;
typedef struct
{
AaruPacketHeader hdr;
} AaruPacketCmdGetDeviceType;
typedef struct
{
AaruPacketHeader hdr;
int32_t device_type;
} AaruPacketResGetDeviceType;
typedef struct
{
AaruPacketHeader hdr;
} AaruPacketCmdGetSdhciRegisters;
typedef struct
{
AaruPacketHeader hdr;
uint8_t is_sdhci;
char csd[16];
char cid[16];
char ocr[4];
char scr[8];
uint32_t csd_len;
uint32_t cid_len;
uint32_t ocr_len;
uint32_t scr_len;
} AaruPacketResGetSdhciRegisters;
typedef struct
{
AaruPacketHeader hdr;
} AaruPacketCmdGetUsbData;
typedef struct
{
AaruPacketHeader hdr;
uint8_t is_usb;
uint16_t desc_len;
char descriptors[65536];
uint16_t id_vendor;
uint16_t id_product;
char manufacturer[256];
char product[256];
char serial[256];
} AaruPacketResGetUsbData;
typedef struct
{
AaruPacketHeader hdr;
} AaruPacketCmdGetFireWireData;
typedef struct
{
AaruPacketHeader hdr;
uint8_t is_firewire;
uint32_t id_model;
uint32_t id_vendor;
uint64_t guid;
char vendor[256];
char model[256];
} AaruPacketResGetFireWireData;
typedef struct
{
AaruPacketHeader hdr;
} AaruPacketCmdGetPcmciaData;
typedef struct
{
AaruPacketHeader hdr;
uint8_t is_pcmcia;
uint16_t cis_len;
char cis[65536];
} AaruPacketResGetPcmciaData;
typedef struct
{
AaruPacketHeader hdr;
} AaruPacketCmdClose;
typedef struct
{
AaruPacketHeader hdr;
} AaruPacketCmdAmIRoot;
typedef struct
{
AaruPacketHeader hdr;
uint32_t am_i_root;
} AaruPacketResAmIRoot;
typedef struct
{
AaruPacketHeader hdr;
uint64_t cmd_count;
AaruCmdSdhci commands[0];
} AaruPacketMultiCmdSdhci;
typedef struct
{
AaruPacketHeader hdr;
uint64_t cmd_count;
AaruResSdhci responses[0];
} AaruPacketMultiResSdhci;
typedef struct
{
AaruPacketHeader hdr;
} AaruPacketCmdReOpen;
typedef struct
{
AaruPacketHeader hdr;
uint64_t offset;
uint32_t length;
} AaruPacketCmdOsRead;
typedef struct
{
AaruPacketHeader hdr;
int32_t error_no;
uint32_t duration;
} AaruPacketResOsRead;
#pragma pack(pop)
typedef struct
{
uint32_t argument;
uint32_t blocks;
uint32_t block_size;
uint32_t buf_len;
char* buffer;
uint8_t command;
uint32_t flags;
uint8_t application;
uint32_t response[4];
uint8_t write;
} MmcSingleCommand;
DeviceInfoList* ListDevices();
void FreeDeviceInfoList(DeviceInfoList* start);
uint16_t DeviceInfoListCount(DeviceInfoList* start);
void* DeviceOpen(const char* device_path);
void DeviceClose(void* device_ctx);
int32_t GetDeviceType(void* device_ctx);
int32_t SendScsiCommand(void* device_ctx,
char* cdb,
char* buffer,
char** sense_buffer,
uint32_t timeout,
int32_t direction,
uint32_t* duration,
uint32_t* sense,
uint32_t cdb_len,
uint32_t* buf_len,
uint32_t* sense_len);
int Hexchr2Bin(const char hex, char* out);
size_t Hexs2Bin(const char* hex, unsigned char** out);
int32_t GetSdhciRegisters(void* device_ctx,
char** csd,
char** cid,
char** ocr,
char** scr,
uint32_t* csd_len,
uint32_t* cid_len,
uint32_t* ocr_len,
uint32_t* scr_len);
uint8_t GetUsbData(void* device_ctx,
uint16_t* desc_len,
char* descriptors,
uint16_t* id_vendor,
uint16_t* id_product,
char* manufacturer,
char* product,
char* serial);
uint8_t GetFireWireData(void* device_ctx,
uint32_t* id_model,
uint32_t* id_vendor,
uint64_t* guid,
char* vendor,
char* model);
uint8_t GetPcmciaData(void* device_ctx, uint16_t* cis_len, char* cis);
int32_t SendAtaChsCommand(void* device_ctx,
AtaRegistersChs registers,
AtaErrorRegistersChs* error_registers,
uint8_t protocol,
uint8_t transfer_register,
char* buffer,
uint32_t timeout,
uint8_t transfer_blocks,
uint32_t* duration,
uint32_t* sense,
uint32_t* buf_len);
int32_t SendAtaLba28Command(void* device_ctx,
AtaRegistersLba28 registers,
AtaErrorRegistersLba28* error_registers,
uint8_t protocol,
uint8_t transfer_register,
char* buffer,
uint32_t timeout,
uint8_t transfer_blocks,
uint32_t* duration,
uint32_t* sense,
uint32_t* buf_len);
int32_t SendAtaLba48Command(void* device_ctx,
AtaRegistersLba48 registers,
AtaErrorRegistersLba48* error_registers,
uint8_t protocol,
uint8_t transfer_register,
char* buffer,
uint32_t timeout,
uint8_t transfer_blocks,
uint32_t* duration,
uint32_t* sense,
uint32_t* buf_len);
int32_t SendSdhciCommand(void* device_ctx,
uint8_t command,
uint8_t write,
uint8_t application,
uint32_t flags,
uint32_t argument,
uint32_t block_size,
uint32_t blocks,
char* buffer,
uint32_t buf_len,
uint32_t timeout,
uint32_t* response,
uint32_t* duration,
uint32_t* sense);
int32_t SendMultiSdhciCommand(void* device_ctx,
uint64_t count,
MmcSingleCommand commands[],
uint32_t* duration,
uint32_t* sense);
int32_t OsRead(void* device_ctx, char* buffer, uint64_t offset, uint32_t length, uint32_t* duration);
AaruPacketHello* GetHello();
int PrintNetworkAddresses();
char* PrintIpv4Address(struct in_addr addr);
void* NetSocket(uint32_t domain, uint32_t type, uint32_t protocol);
int32_t NetBind(void* net_ctx, struct sockaddr* addr, socklen_t addrlen);
int32_t NetListen(void* net_ctx, uint32_t backlog);
void* NetAccept(void* net_ctx, struct sockaddr* addr, socklen_t* addrlen);
int32_t NetRecv(void* net_ctx, void* buf, int32_t len, uint32_t flags);
int32_t NetWrite(void* net_ctx, const void* buf, int32_t size);
int32_t NetClose(void* net_ctx);
void Initialize();
void PlatformLoop(AaruPacketHello* pkt_server_hello);
void* WorkingLoop(void* arguments);
uint8_t AmIRoot();
int32_t ReOpen(void* device_ctx, uint32_t* closeFailed);
#endif