mirror of
https://github.com/aaru-dps/aaruremote.git
synced 2025-12-16 11:14:35 +00:00
Genera refactor and cleanup.
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
"name": "x64-Debug",
|
||||
"generator": "Ninja",
|
||||
"configurationType": "Debug",
|
||||
"inheritEnvironments": [ "msvc_x64_x64" ],
|
||||
"inheritEnvironments": ["msvc_x64_x64"],
|
||||
"buildRoot": "${projectDir}\\out\\build\\${name}",
|
||||
"installRoot": "${projectDir}\\out\\install\\${name}",
|
||||
"cmakeCommandArgs": "",
|
||||
@@ -21,7 +21,7 @@
|
||||
"cmakeCommandArgs": "",
|
||||
"buildCommandArgs": "-v",
|
||||
"ctestCommandArgs": "",
|
||||
"inheritEnvironments": [ "msvc_x86" ],
|
||||
"inheritEnvironments": ["msvc_x86"],
|
||||
"variables": []
|
||||
},
|
||||
{
|
||||
@@ -33,7 +33,7 @@
|
||||
"cmakeCommandArgs": "",
|
||||
"buildCommandArgs": "-v",
|
||||
"ctestCommandArgs": "",
|
||||
"inheritEnvironments": [ "msvc_arm" ],
|
||||
"inheritEnvironments": ["msvc_arm"],
|
||||
"variables": []
|
||||
},
|
||||
{
|
||||
@@ -45,7 +45,7 @@
|
||||
"cmakeCommandArgs": "",
|
||||
"buildCommandArgs": "-v",
|
||||
"ctestCommandArgs": "",
|
||||
"inheritEnvironments": [ "msvc_arm64" ],
|
||||
"inheritEnvironments": ["msvc_arm64"],
|
||||
"variables": []
|
||||
}
|
||||
]
|
||||
|
||||
23
README.md
23
README.md
@@ -1,19 +1,22 @@
|
||||
Aaru Remote
|
||||
====================
|
||||
|
||||
The Aaru Remote is a slim miniature application designed to receive device commands from a remote [Aaru](https://github.com/aaru-dps/Aaru)
|
||||
The Aaru Remote is a slim miniature application designed to receive device commands from a
|
||||
remote [Aaru](https://github.com/aaru-dps/Aaru)
|
||||
instance, sends it to a local device, and returns the data to the instance.
|
||||
|
||||
The main motivation for this is the desire to update Aaru to the latest and greatest features of .NET and C#.
|
||||
This creates a problem, as some people have old devices that do not work in modern Linux distributions.
|
||||
|
||||
This remote will be supported in older versions of Linux, and will in future versions be supported in FreeBSD, Windows, and possibly
|
||||
This remote will be supported in older versions of Linux, and will in future versions be supported in FreeBSD, Windows,
|
||||
and possibly
|
||||
network-enabled game consoles (like PSP, Wii, etc).
|
||||
|
||||
While some people will suggest porting the whole Aaru to C or C++, that won't happen, and for the only situation that
|
||||
would be needed (accessing devices where C# does not run) this slim is more than enough.
|
||||
|
||||
The usage is very simple, just run the remote and it will listen for a connection over TCP/IP in port 6666, and print you
|
||||
The usage is very simple, just run the remote and it will listen for a connection over TCP/IP in port 6666, and print
|
||||
you
|
||||
the available IPs. Running as non-root user only works with some SCSI devices, so better run as root.
|
||||
|
||||
On the other side, you can use the Aaru with the *remote* command and one of those IP addresses to test the
|
||||
@@ -25,12 +28,13 @@ All commands that support devices are supported, with a URI with the following s
|
||||
|
||||
Feature matrix
|
||||
==============
|
||||
| |Minimum OS<sup>*1</sup>| SCSI |CHS ATA |28-bit LBA ATA |48-bit LBA ATA |Secure Digital|MultiMediaCard|USB |FireWire |PCMCIA |Special<sup>*2</sup>|
|
||||
|------------|-----------------------|---------------|---------------|---------------|---------------|--------------|--------------|--------------------|--------------------|----------------|-------|
|
||||
|FreeBSD | 12 |Yes |Yes |Yes |Yes |Not yet |Not yet |Not yet<sup>*4</sup>|Not yet<sup>*4</sup>|No<sup>*5</sup> ||
|
||||
|Linux |2.6 |Yes |Yes |Yes |Yes |Yes |Yes |Yes |Yes |Yes<sup>*6</sup>||
|
||||
|Nintendo Wii|4.3 |No<sup>*3</sup>|No<sup>*3</sup>|No<sup>*3</sup>|No<sup>*3</sup>|Not yet |Not yet |Not yet |No<sup>*3</sup> |No<sup>*3</sup> |Not yet|
|
||||
|Windows NT | XP |Yes |Yes |Yes |Yes |Yes |Yes |Yes |Not yet<sup>*4</sup>|No<sup>*5</sup> ||
|
||||
|
||||
| | Minimum OS<sup>*1</sup> | SCSI | CHS ATA | 28-bit LBA ATA | 48-bit LBA ATA | Secure Digital | MultiMediaCard | USB | FireWire | PCMCIA | Special<sup>*2</sup> |
|
||||
|--------------|-------------------------|-----------------|-----------------|-----------------|-----------------|----------------|----------------|----------------------|----------------------|------------------|----------------------|
|
||||
| FreeBSD | 12 | Yes | Yes | Yes | Yes | Not yet | Not yet | Not yet<sup>*4</sup> | Not yet<sup>*4</sup> | No<sup>*5</sup> | |
|
||||
| Linux | 2.6 | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes<sup>*6</sup> | |
|
||||
| Nintendo Wii | 4.3 | No<sup>*3</sup> | No<sup>*3</sup> | No<sup>*3</sup> | No<sup>*3</sup> | Not yet | Not yet | Not yet | No<sup>*3</sup> | No<sup>*3</sup> | Not yet |
|
||||
| Windows NT | XP | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Not yet<sup>*4</sup> | No<sup>*5</sup> | |
|
||||
|
||||
1. Minimum operating system version where aaruremote has been tested. May work on early version.
|
||||
2. Special storage media only available on that environment.
|
||||
@@ -41,6 +45,7 @@ Feature matrix
|
||||
|
||||
TODO
|
||||
====
|
||||
|
||||
- More buffer overflow guards
|
||||
- Support PSP
|
||||
- Support Wii
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"projectId":"a013337c-1721-4682-9a63-b33e4a40f753","projectName":"aaruremote"}
|
||||
{"projectId": "a013337c-1721-4682-9a63-b33e4a40f753", "projectName": "aaruremote"}
|
||||
@@ -32,31 +32,27 @@ static u_int32_t AtaProtocolToCamFlags(uint8_t protocol)
|
||||
case AARUREMOTE_ATA_PROTOCOL_HARD_RESET:
|
||||
case AARUREMOTE_ATA_PROTOCOL_NO_DATA:
|
||||
case AARUREMOTE_ATA_PROTOCOL_SOFT_RESET:
|
||||
case AARUREMOTE_ATA_PROTOCOL_RETURN_RESPONSE: return CAM_DIR_NONE;
|
||||
case AARUREMOTE_ATA_PROTOCOL_RETURN_RESPONSE:
|
||||
return CAM_DIR_NONE;
|
||||
case AARUREMOTE_ATA_PROTOCOL_PIO_IN:
|
||||
case AARUREMOTE_ATA_PROTOCOL_UDMA_IN: return CAM_DIR_IN;
|
||||
case AARUREMOTE_ATA_PROTOCOL_UDMA_IN:
|
||||
return CAM_DIR_IN;
|
||||
case AARUREMOTE_ATA_PROTOCOL_PIO_OUT:
|
||||
case AARUREMOTE_ATA_PROTOCOL_UDMA_OUT: return CAM_DIR_OUT;
|
||||
default: return 0;
|
||||
case AARUREMOTE_ATA_PROTOCOL_UDMA_OUT:
|
||||
return CAM_DIR_OUT;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
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 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)
|
||||
{
|
||||
DeviceContext* ctx = device_ctx;
|
||||
DeviceContext *ctx = device_ctx;
|
||||
*duration = 0;
|
||||
*sense = false;
|
||||
union ccb* camccb;
|
||||
union ccb *camccb;
|
||||
int error;
|
||||
int clock_error;
|
||||
struct timespec start_tp;
|
||||
@@ -76,7 +72,7 @@ int32_t SendAtaChsCommand(void* device_ctx,
|
||||
camccb->ccb_h.retry_count = 1;
|
||||
camccb->ccb_h.cbfcnp = NULL;
|
||||
camccb->ccb_h.timeout = timeout;
|
||||
camccb->ataio.data_ptr = (u_int8_t*)buffer;
|
||||
camccb->ataio.data_ptr = (u_int8_t *)buffer;
|
||||
camccb->ataio.dxfer_len = *buf_len;
|
||||
camccb->ccb_h.flags |= CAM_DEV_QFRZDIS;
|
||||
camccb->ataio.cmd.flags = CAM_ATAIO_NEEDRESULT;
|
||||
@@ -86,8 +82,12 @@ int32_t SendAtaChsCommand(void* device_ctx,
|
||||
case AARUREMOTE_ATA_PROTOCOL_DMA:
|
||||
case AARUREMOTE_ATA_PROTOCOL_DMA_QUEUED:
|
||||
case AARUREMOTE_ATA_PROTOCOL_UDMA_IN:
|
||||
case AARUREMOTE_ATA_PROTOCOL_UDMA_OUT: camccb->ataio.cmd.flags |= CAM_ATAIO_DMA; break;
|
||||
case AARUREMOTE_ATA_PROTOCOL_FPDMA: camccb->ataio.cmd.flags |= CAM_ATAIO_FPDMA; break;
|
||||
case AARUREMOTE_ATA_PROTOCOL_UDMA_OUT:
|
||||
camccb->ataio.cmd.flags |= CAM_ATAIO_DMA;
|
||||
break;
|
||||
case AARUREMOTE_ATA_PROTOCOL_FPDMA:
|
||||
camccb->ataio.cmd.flags |= CAM_ATAIO_FPDMA;
|
||||
break;
|
||||
}
|
||||
|
||||
camccb->ataio.cmd.command = registers.command;
|
||||
@@ -142,22 +142,14 @@ int32_t SendAtaChsCommand(void* device_ctx,
|
||||
return error;
|
||||
}
|
||||
|
||||
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 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)
|
||||
{
|
||||
DeviceContext* ctx = device_ctx;
|
||||
DeviceContext *ctx = device_ctx;
|
||||
*duration = 0;
|
||||
*sense = false;
|
||||
union ccb* camccb;
|
||||
union ccb *camccb;
|
||||
int error;
|
||||
int clock_error;
|
||||
struct timespec start_tp;
|
||||
@@ -177,7 +169,7 @@ int32_t SendAtaLba28Command(void* device_ctx,
|
||||
camccb->ccb_h.retry_count = 1;
|
||||
camccb->ccb_h.cbfcnp = NULL;
|
||||
camccb->ccb_h.timeout = timeout;
|
||||
camccb->ataio.data_ptr = (u_int8_t*)buffer;
|
||||
camccb->ataio.data_ptr = (u_int8_t *)buffer;
|
||||
camccb->ataio.dxfer_len = *buf_len;
|
||||
camccb->ccb_h.flags |= CAM_DEV_QFRZDIS;
|
||||
camccb->ataio.cmd.flags = CAM_ATAIO_NEEDRESULT;
|
||||
@@ -187,8 +179,12 @@ int32_t SendAtaLba28Command(void* device_ctx,
|
||||
case AARUREMOTE_ATA_PROTOCOL_DMA:
|
||||
case AARUREMOTE_ATA_PROTOCOL_DMA_QUEUED:
|
||||
case AARUREMOTE_ATA_PROTOCOL_UDMA_IN:
|
||||
case AARUREMOTE_ATA_PROTOCOL_UDMA_OUT: camccb->ataio.cmd.flags |= CAM_ATAIO_DMA; break;
|
||||
case AARUREMOTE_ATA_PROTOCOL_FPDMA: camccb->ataio.cmd.flags |= CAM_ATAIO_FPDMA; break;
|
||||
case AARUREMOTE_ATA_PROTOCOL_UDMA_OUT:
|
||||
camccb->ataio.cmd.flags |= CAM_ATAIO_DMA;
|
||||
break;
|
||||
case AARUREMOTE_ATA_PROTOCOL_FPDMA:
|
||||
camccb->ataio.cmd.flags |= CAM_ATAIO_FPDMA;
|
||||
break;
|
||||
}
|
||||
|
||||
camccb->ataio.cmd.command = registers.command;
|
||||
@@ -243,22 +239,14 @@ int32_t SendAtaLba28Command(void* device_ctx,
|
||||
return error;
|
||||
}
|
||||
|
||||
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 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)
|
||||
{
|
||||
DeviceContext* ctx = device_ctx;
|
||||
DeviceContext *ctx = device_ctx;
|
||||
*duration = 0;
|
||||
*sense = false;
|
||||
union ccb* camccb;
|
||||
union ccb *camccb;
|
||||
int error;
|
||||
int clock_error;
|
||||
struct timespec start_tp;
|
||||
@@ -280,7 +268,7 @@ int32_t SendAtaLba48Command(void* device_ctx,
|
||||
camccb->ccb_h.retry_count = 1;
|
||||
camccb->ccb_h.cbfcnp = NULL;
|
||||
camccb->ccb_h.timeout = timeout;
|
||||
camccb->ataio.data_ptr = (u_int8_t*)buffer;
|
||||
camccb->ataio.data_ptr = (u_int8_t *)buffer;
|
||||
camccb->ataio.dxfer_len = *buf_len;
|
||||
camccb->ccb_h.flags |= CAM_DEV_QFRZDIS;
|
||||
camccb->ataio.cmd.flags = CAM_ATAIO_NEEDRESULT | CAM_ATAIO_48BIT;
|
||||
@@ -290,8 +278,12 @@ int32_t SendAtaLba48Command(void* device_ctx,
|
||||
case AARUREMOTE_ATA_PROTOCOL_DMA:
|
||||
case AARUREMOTE_ATA_PROTOCOL_DMA_QUEUED:
|
||||
case AARUREMOTE_ATA_PROTOCOL_UDMA_IN:
|
||||
case AARUREMOTE_ATA_PROTOCOL_UDMA_OUT: camccb->ataio.cmd.flags |= CAM_ATAIO_DMA; break;
|
||||
case AARUREMOTE_ATA_PROTOCOL_FPDMA: camccb->ataio.cmd.flags |= CAM_ATAIO_FPDMA; break;
|
||||
case AARUREMOTE_ATA_PROTOCOL_UDMA_OUT:
|
||||
camccb->ataio.cmd.flags |= CAM_ATAIO_DMA;
|
||||
break;
|
||||
case AARUREMOTE_ATA_PROTOCOL_FPDMA:
|
||||
camccb->ataio.cmd.flags |= CAM_ATAIO_FPDMA;
|
||||
break;
|
||||
}
|
||||
|
||||
camccb->ataio.cmd.command = registers.command;
|
||||
|
||||
@@ -25,9 +25,9 @@
|
||||
#include "../aaruremote.h"
|
||||
#include "freebsd.h"
|
||||
|
||||
void* DeviceOpen(const char* device_path)
|
||||
void *DeviceOpen(const char *device_path)
|
||||
{
|
||||
DeviceContext* ctx;
|
||||
DeviceContext *ctx;
|
||||
|
||||
ctx = malloc(sizeof(DeviceContext));
|
||||
|
||||
@@ -48,9 +48,9 @@ void* DeviceOpen(const char* device_path)
|
||||
return ctx;
|
||||
}
|
||||
|
||||
void DeviceClose(void* device_ctx)
|
||||
void DeviceClose(void *device_ctx)
|
||||
{
|
||||
DeviceContext* ctx = device_ctx;
|
||||
DeviceContext *ctx = device_ctx;
|
||||
|
||||
if(!ctx) return;
|
||||
|
||||
@@ -59,10 +59,10 @@ void DeviceClose(void* device_ctx)
|
||||
free(ctx);
|
||||
}
|
||||
|
||||
int32_t GetDeviceType(void* device_ctx)
|
||||
int32_t GetDeviceType(void *device_ctx)
|
||||
{
|
||||
DeviceContext* ctx = device_ctx;
|
||||
union ccb* camccb;
|
||||
DeviceContext *ctx = device_ctx;
|
||||
union ccb *camccb;
|
||||
int ret;
|
||||
int32_t device_type = AARUREMOTE_DEVICE_TYPE_UNKNOWN;
|
||||
|
||||
@@ -86,24 +86,34 @@ int32_t GetDeviceType(void* device_ctx)
|
||||
switch(camccb->cgd.protocol)
|
||||
{
|
||||
case PROTO_ATA:
|
||||
case PROTO_SATAPM: device_type = AARUREMOTE_DEVICE_TYPE_ATA; break;
|
||||
case PROTO_ATAPI: device_type = AARUREMOTE_DEVICE_TYPE_ATAPI; break;
|
||||
case PROTO_SCSI: device_type = AARUREMOTE_DEVICE_TYPE_SCSI; break;
|
||||
case PROTO_NVME: device_type = AARUREMOTE_DEVICE_TYPE_NVME; break;
|
||||
case PROTO_SATAPM:
|
||||
device_type = AARUREMOTE_DEVICE_TYPE_ATA;
|
||||
break;
|
||||
case PROTO_ATAPI:
|
||||
device_type = AARUREMOTE_DEVICE_TYPE_ATAPI;
|
||||
break;
|
||||
case PROTO_SCSI:
|
||||
device_type = AARUREMOTE_DEVICE_TYPE_SCSI;
|
||||
break;
|
||||
case PROTO_NVME:
|
||||
device_type = AARUREMOTE_DEVICE_TYPE_NVME;
|
||||
break;
|
||||
case PROTO_MMCSD:
|
||||
// TODO: MMC vs SD
|
||||
device_type = AARUREMOTE_DEVICE_TYPE_MMC;
|
||||
break;
|
||||
default: device_type = AARUREMOTE_DEVICE_TYPE_UNKNOWN; break;
|
||||
default:
|
||||
device_type = AARUREMOTE_DEVICE_TYPE_UNKNOWN;
|
||||
break;
|
||||
}
|
||||
|
||||
cam_freeccb(camccb);
|
||||
return device_type;
|
||||
}
|
||||
|
||||
int32_t ReOpen(void* device_ctx, uint32_t* closeFailed)
|
||||
int32_t ReOpen(void *device_ctx, uint32_t *closeFailed)
|
||||
{
|
||||
DeviceContext* ctx = device_ctx;
|
||||
DeviceContext *ctx = device_ctx;
|
||||
int ret;
|
||||
*closeFailed = 0;
|
||||
|
||||
@@ -116,9 +126,9 @@ int32_t ReOpen(void* device_ctx, uint32_t* closeFailed)
|
||||
return ctx->device == 0 ? errno : 0;
|
||||
}
|
||||
|
||||
int32_t OsRead(void* device_ctx, char* buffer, uint64_t offset, uint32_t length, uint32_t* duration)
|
||||
int32_t OsRead(void *device_ctx, char *buffer, uint64_t offset, uint32_t length, uint32_t *duration)
|
||||
{
|
||||
DeviceContext* ctx = device_ctx;
|
||||
DeviceContext *ctx = device_ctx;
|
||||
ssize_t ret;
|
||||
*duration = 0;
|
||||
off_t pos;
|
||||
@@ -131,7 +141,7 @@ int32_t OsRead(void* device_ctx, char* buffer, uint64_t offset, uint32_t length,
|
||||
if(pos < 0) return errno;
|
||||
|
||||
// TODO: Timing
|
||||
ret = read(ctx->device.fd, (void*)buffer, (size_t)length);
|
||||
ret = read(ctx->device.fd, (void *)buffer, (size_t)length);
|
||||
|
||||
return ret < 0 ? errno : 0;
|
||||
}
|
||||
@@ -28,7 +28,7 @@
|
||||
typedef struct
|
||||
{
|
||||
char device_path[4096];
|
||||
struct cam_device* device;
|
||||
struct cam_device *device;
|
||||
} DeviceContext;
|
||||
|
||||
#endif // AARUREMOTE_FREEBSD_FREEBSD_H_
|
||||
|
||||
@@ -19,12 +19,8 @@
|
||||
|
||||
#include "../aaruremote.h"
|
||||
|
||||
uint8_t GetFireWireData(void* device_ctx,
|
||||
uint32_t* id_model,
|
||||
uint32_t* id_vendor,
|
||||
uint64_t* guid,
|
||||
char* vendor,
|
||||
char* model)
|
||||
uint8_t GetFireWireData(void *device_ctx, uint32_t *id_model, uint32_t *id_vendor, uint64_t *guid, char *vendor,
|
||||
char *model)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -25,13 +25,13 @@
|
||||
#include "../aaruremote.h"
|
||||
#include "freebsd.h"
|
||||
|
||||
DeviceInfoList* ListDevices()
|
||||
DeviceInfoList *ListDevices()
|
||||
{
|
||||
DeviceInfoList * list_start = NULL, *list_current = NULL, *list_next = NULL;
|
||||
DIR* dir;
|
||||
struct dirent* dirent;
|
||||
struct cam_device* camdev;
|
||||
union ccb* camccb;
|
||||
DeviceInfoList *list_start = NULL, *list_current = NULL, *list_next = NULL;
|
||||
DIR *dir;
|
||||
struct dirent *dirent;
|
||||
struct cam_device *camdev;
|
||||
union ccb *camccb;
|
||||
int ret;
|
||||
int i;
|
||||
|
||||
@@ -89,7 +89,7 @@ DeviceInfoList* ListDevices()
|
||||
continue;
|
||||
}
|
||||
|
||||
strncpy(list_next->this.serial, (const char*)camdev->serial_num, camdev->serial_num_len);
|
||||
strncpy(list_next->this.serial, (const char *)camdev->serial_num, camdev->serial_num_len);
|
||||
|
||||
switch(camccb->cgd.protocol)
|
||||
{
|
||||
@@ -98,7 +98,7 @@ DeviceInfoList* ListDevices()
|
||||
case PROTO_SATAPM:
|
||||
// TODO: Split on space
|
||||
strncpy(list_next->this.vendor, "ATA", 3);
|
||||
strncpy(list_next->this.model, (const char*)camccb->cgd.ident_data.model, 40);
|
||||
strncpy(list_next->this.model, (const char *)camccb->cgd.ident_data.model, 40);
|
||||
|
||||
// Trim spaces
|
||||
for(i = 40; i > 0; i--)
|
||||
@@ -108,9 +108,10 @@ DeviceInfoList* ListDevices()
|
||||
list_next->this.model[i] = 0;
|
||||
}
|
||||
|
||||
strncpy(list_next->this.serial, (const char*)camccb->cgd.ident_data.serial, 20);
|
||||
strncpy(list_next->this.serial, (const char *)camccb->cgd.ident_data.serial, 20);
|
||||
|
||||
if(strncmp(camdev->sim_name, "ahcich", 6) == 0) strncpy(list_next->this.bus, "SATA", 5);
|
||||
if(strncmp(camdev->sim_name, "ahcich", 6) == 0)
|
||||
strncpy(list_next->this.bus, "SATA", 5);
|
||||
else
|
||||
strncpy(list_next->this.bus, "ATA", 4);
|
||||
|
||||
|
||||
@@ -19,4 +19,4 @@
|
||||
|
||||
#include "../aaruremote.h"
|
||||
|
||||
uint8_t GetPcmciaData(void* device_ctx, uint16_t* cis_len, char* cis) { return 0; }
|
||||
uint8_t GetPcmciaData(void *device_ctx, uint16_t *cis_len, char *cis) { return 0; }
|
||||
|
||||
@@ -25,24 +25,16 @@
|
||||
#include "../aaruremote.h"
|
||||
#include "freebsd.h"
|
||||
|
||||
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)
|
||||
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)
|
||||
{
|
||||
DeviceContext* ctx = device_ctx;
|
||||
DeviceContext *ctx = device_ctx;
|
||||
*sense_len = 0;
|
||||
*sense_buffer = NULL;
|
||||
*duration = 0;
|
||||
*sense = false;
|
||||
union ccb* camccb;
|
||||
union ccb *camccb;
|
||||
u_int32_t flags;
|
||||
int error;
|
||||
int clock_error;
|
||||
@@ -52,10 +44,18 @@ int32_t SendScsiCommand(void* device_ctx,
|
||||
|
||||
switch(direction)
|
||||
{
|
||||
case AARUREMOTE_SCSI_DIRECTION_NONE: flags = CAM_DIR_NONE; break;
|
||||
case AARUREMOTE_SCSI_DIRECTION_OUT: flags = CAM_DIR_OUT; break;
|
||||
case AARUREMOTE_SCSI_DIRECTION_IN: flags = CAM_DIR_IN; break;
|
||||
case AARUREMOTE_SCSI_DIRECTION_INOUT: flags = CAM_DIR_BOTH; break;
|
||||
case AARUREMOTE_SCSI_DIRECTION_NONE:
|
||||
flags = CAM_DIR_NONE;
|
||||
break;
|
||||
case AARUREMOTE_SCSI_DIRECTION_OUT:
|
||||
flags = CAM_DIR_OUT;
|
||||
break;
|
||||
case AARUREMOTE_SCSI_DIRECTION_IN:
|
||||
flags = CAM_DIR_IN;
|
||||
break;
|
||||
case AARUREMOTE_SCSI_DIRECTION_INOUT:
|
||||
flags = CAM_DIR_BOTH;
|
||||
break;
|
||||
}
|
||||
|
||||
if(!ctx) return -1;
|
||||
@@ -75,16 +75,17 @@ int32_t SendScsiCommand(void* device_ctx,
|
||||
camccb->ccb_h.retry_count = 1;
|
||||
camccb->ccb_h.cbfcnp = NULL;
|
||||
camccb->ccb_h.timeout = timeout;
|
||||
camccb->csio.data_ptr = (u_int8_t*)buffer;
|
||||
camccb->csio.data_ptr = (u_int8_t *)buffer;
|
||||
camccb->csio.dxfer_len = *buf_len;
|
||||
camccb->csio.sense_len = 32;
|
||||
camccb->csio.cdb_len = cdb_len;
|
||||
camccb->csio.tag_action = 0x20;
|
||||
|
||||
if(cdb_len <= CAM_MAX_CDBLEN) memcpy(camccb->csio.cdb_io.cdb_bytes, cdb, cdb_len);
|
||||
if(cdb_len <= CAM_MAX_CDBLEN)
|
||||
memcpy(camccb->csio.cdb_io.cdb_bytes, cdb, cdb_len);
|
||||
else
|
||||
{
|
||||
camccb->csio.cdb_io.cdb_ptr = (u_int8_t*)cdb;
|
||||
camccb->csio.cdb_io.cdb_ptr = (u_int8_t *)cdb;
|
||||
camccb->ccb_h.flags |= CAM_CDB_POINTER;
|
||||
}
|
||||
|
||||
@@ -127,8 +128,7 @@ int32_t SendScsiCommand(void* device_ctx,
|
||||
*sense = (camccb->ccb_h.status & CAM_STATUS_MASK) == CAM_SCSI_STATUS_ERROR;
|
||||
*sense_buffer = malloc(camccb->csio.sense_len - camccb->csio.sense_resid);
|
||||
(*sense_buffer)[0] = camccb->csio.sense_data.error_code;
|
||||
memcpy((*sense_buffer) + 1,
|
||||
camccb->csio.sense_data.sense_buf,
|
||||
memcpy((*sense_buffer) + 1, camccb->csio.sense_data.sense_buf,
|
||||
(camccb->csio.sense_len - camccb->csio.sense_resid) - 1);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,42 +19,21 @@
|
||||
|
||||
#include "../aaruremote.h"
|
||||
|
||||
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 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)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
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)
|
||||
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)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t SendMultiSdhciCommand(void* device_ctx,
|
||||
uint64_t count,
|
||||
MmcSingleCommand commands[],
|
||||
uint32_t* duration,
|
||||
uint32_t* sense)
|
||||
int32_t SendMultiSdhciCommand(void *device_ctx, uint64_t count, MmcSingleCommand commands[], uint32_t *duration,
|
||||
uint32_t *sense)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
@@ -19,14 +19,8 @@
|
||||
|
||||
#include "../aaruremote.h"
|
||||
|
||||
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 GetUsbData(void *device_ctx, uint16_t *desc_len, char *descriptors, uint16_t *id_vendor, uint16_t *id_product,
|
||||
char *manufacturer, char *product, char *serial)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
129
linux/ata.c
129
linux/ata.c
@@ -29,33 +29,29 @@ int32_t AtaProtocolToScsiDirection(uint8_t protocol)
|
||||
case AARUREMOTE_ATA_PROTOCOL_HARD_RESET:
|
||||
case AARUREMOTE_ATA_PROTOCOL_NO_DATA:
|
||||
case AARUREMOTE_ATA_PROTOCOL_SOFT_RESET:
|
||||
case AARUREMOTE_ATA_PROTOCOL_RETURN_RESPONSE: return AARUREMOTE_SCSI_DIRECTION_NONE;
|
||||
case AARUREMOTE_ATA_PROTOCOL_RETURN_RESPONSE:
|
||||
return AARUREMOTE_SCSI_DIRECTION_NONE;
|
||||
case AARUREMOTE_ATA_PROTOCOL_PIO_IN:
|
||||
case AARUREMOTE_ATA_PROTOCOL_UDMA_IN: return AARUREMOTE_SCSI_DIRECTION_IN;
|
||||
case AARUREMOTE_ATA_PROTOCOL_UDMA_IN:
|
||||
return AARUREMOTE_SCSI_DIRECTION_IN;
|
||||
case AARUREMOTE_ATA_PROTOCOL_PIO_OUT:
|
||||
case AARUREMOTE_ATA_PROTOCOL_UDMA_OUT: return AARUREMOTE_SCSI_DIRECTION_OUT;
|
||||
default: return AARUREMOTE_SCSI_DIRECTION_UNSPECIFIED;
|
||||
case AARUREMOTE_ATA_PROTOCOL_UDMA_OUT:
|
||||
return AARUREMOTE_SCSI_DIRECTION_OUT;
|
||||
default:
|
||||
return AARUREMOTE_SCSI_DIRECTION_UNSPECIFIED;
|
||||
}
|
||||
}
|
||||
|
||||
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 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)
|
||||
{
|
||||
*duration = 0;
|
||||
*sense = 0;
|
||||
unsigned char cdb[16];
|
||||
char* sense_buf;
|
||||
char *sense_buf;
|
||||
uint32_t sense_len;
|
||||
DeviceContext* ctx = device_ctx;
|
||||
DeviceContext *ctx = device_ctx;
|
||||
|
||||
if(!ctx) return -1;
|
||||
|
||||
@@ -68,8 +64,12 @@ int32_t SendAtaChsCommand(void* device_ctx,
|
||||
switch(protocol)
|
||||
{
|
||||
case AARUREMOTE_ATA_PROTOCOL_PIO_IN:
|
||||
case AARUREMOTE_ATA_PROTOCOL_UDMA_IN: cdb[2] = 0x08; break;
|
||||
default: cdb[2] = 0x00; break;
|
||||
case AARUREMOTE_ATA_PROTOCOL_UDMA_IN:
|
||||
cdb[2] = 0x08;
|
||||
break;
|
||||
default:
|
||||
cdb[2] = 0x00;
|
||||
break;
|
||||
}
|
||||
|
||||
if(transfer_blocks) cdb[2] |= 0x04;
|
||||
@@ -85,17 +85,8 @@ int32_t SendAtaChsCommand(void* device_ctx,
|
||||
cdb[13] = registers.device_head;
|
||||
cdb[14] = registers.command;
|
||||
|
||||
int error = SendScsiCommand(ctx,
|
||||
(char*)cdb,
|
||||
buffer,
|
||||
&sense_buf,
|
||||
timeout,
|
||||
AtaProtocolToScsiDirection(protocol),
|
||||
duration,
|
||||
sense,
|
||||
16,
|
||||
buf_len,
|
||||
&sense_len);
|
||||
int error = SendScsiCommand(ctx, (char *)cdb, buffer, &sense_buf, timeout, AtaProtocolToScsiDirection(protocol),
|
||||
duration, sense, 16, buf_len, &sense_len);
|
||||
|
||||
if(sense_len < 22 || (sense_buf[8] != 0x09 && sense_buf[9] != 0x0C)) return error;
|
||||
|
||||
@@ -113,24 +104,16 @@ int32_t SendAtaChsCommand(void* device_ctx,
|
||||
return error;
|
||||
}
|
||||
|
||||
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 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)
|
||||
{
|
||||
*duration = 0;
|
||||
*sense = 0;
|
||||
unsigned char cdb[16];
|
||||
char* sense_buf;
|
||||
char *sense_buf;
|
||||
uint32_t sense_len;
|
||||
DeviceContext* ctx = device_ctx;
|
||||
DeviceContext *ctx = device_ctx;
|
||||
|
||||
if(!ctx) return -1;
|
||||
|
||||
@@ -143,8 +126,12 @@ int32_t SendAtaLba28Command(void* device_ctx,
|
||||
switch(protocol)
|
||||
{
|
||||
case AARUREMOTE_ATA_PROTOCOL_PIO_IN:
|
||||
case AARUREMOTE_ATA_PROTOCOL_UDMA_IN: cdb[2] = 0x08; break;
|
||||
default: cdb[2] = 0x00; break;
|
||||
case AARUREMOTE_ATA_PROTOCOL_UDMA_IN:
|
||||
cdb[2] = 0x08;
|
||||
break;
|
||||
default:
|
||||
cdb[2] = 0x00;
|
||||
break;
|
||||
}
|
||||
|
||||
if(transfer_blocks) cdb[2] |= 0x04;
|
||||
@@ -162,17 +149,8 @@ int32_t SendAtaLba28Command(void* device_ctx,
|
||||
cdb[13] = registers.device_head;
|
||||
cdb[14] = registers.command;
|
||||
|
||||
int error = SendScsiCommand(ctx,
|
||||
(char*)cdb,
|
||||
buffer,
|
||||
&sense_buf,
|
||||
timeout,
|
||||
AtaProtocolToScsiDirection(protocol),
|
||||
duration,
|
||||
sense,
|
||||
16,
|
||||
buf_len,
|
||||
&sense_len);
|
||||
int error = SendScsiCommand(ctx, (char *)cdb, buffer, &sense_buf, timeout, AtaProtocolToScsiDirection(protocol),
|
||||
duration, sense, 16, buf_len, &sense_len);
|
||||
|
||||
if(sense_len < 22 || (sense_buf[8] != 0x09 && sense_buf[9] != 0x0C)) return error;
|
||||
|
||||
@@ -190,24 +168,16 @@ int32_t SendAtaLba28Command(void* device_ctx,
|
||||
return error;
|
||||
}
|
||||
|
||||
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 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)
|
||||
{
|
||||
*duration = 0;
|
||||
*sense = 0;
|
||||
unsigned char cdb[16];
|
||||
char* sense_buf;
|
||||
char *sense_buf;
|
||||
uint32_t sense_len;
|
||||
DeviceContext* ctx = device_ctx;
|
||||
DeviceContext *ctx = device_ctx;
|
||||
|
||||
if(!ctx) return -1;
|
||||
|
||||
@@ -221,8 +191,12 @@ int32_t SendAtaLba48Command(void* device_ctx,
|
||||
switch(protocol)
|
||||
{
|
||||
case AARUREMOTE_ATA_PROTOCOL_PIO_IN:
|
||||
case AARUREMOTE_ATA_PROTOCOL_UDMA_IN: cdb[2] = 0x08; break;
|
||||
default: cdb[2] = 0x00; break;
|
||||
case AARUREMOTE_ATA_PROTOCOL_UDMA_IN:
|
||||
cdb[2] = 0x08;
|
||||
break;
|
||||
default:
|
||||
cdb[2] = 0x00;
|
||||
break;
|
||||
}
|
||||
|
||||
if(transfer_blocks) cdb[2] |= 0x04;
|
||||
@@ -245,17 +219,8 @@ int32_t SendAtaLba48Command(void* device_ctx,
|
||||
cdb[13] = registers.device_head;
|
||||
cdb[14] = registers.command;
|
||||
|
||||
int error = SendScsiCommand(ctx,
|
||||
(char*)cdb,
|
||||
buffer,
|
||||
&sense_buf,
|
||||
timeout,
|
||||
AtaProtocolToScsiDirection(protocol),
|
||||
duration,
|
||||
sense,
|
||||
16,
|
||||
buf_len,
|
||||
&sense_len);
|
||||
int error = SendScsiCommand(ctx, (char *)cdb, buffer, &sense_buf, timeout, AtaProtocolToScsiDirection(protocol),
|
||||
duration, sense, 16, buf_len, &sense_len);
|
||||
|
||||
if(sense_len < 22 || (sense_buf[8] != 0x09 && sense_buf[9] != 0x0C)) return error;
|
||||
|
||||
|
||||
156
linux/device.c
156
linux/device.c
@@ -30,9 +30,9 @@
|
||||
#include "../aaruremote.h"
|
||||
#include "linux.h"
|
||||
|
||||
void* DeviceOpen(const char* device_path)
|
||||
void *DeviceOpen(const char *device_path)
|
||||
{
|
||||
DeviceContext* ctx;
|
||||
DeviceContext *ctx;
|
||||
|
||||
char *real_device_path = realpath(device_path, NULL);
|
||||
if(real_device_path != NULL)
|
||||
@@ -68,9 +68,9 @@ void* DeviceOpen(const char* device_path)
|
||||
return ctx;
|
||||
}
|
||||
|
||||
void DeviceClose(void* device_ctx)
|
||||
void DeviceClose(void *device_ctx)
|
||||
{
|
||||
DeviceContext* ctx = device_ctx;
|
||||
DeviceContext *ctx = device_ctx;
|
||||
|
||||
if(!ctx) return;
|
||||
|
||||
@@ -79,17 +79,17 @@ void DeviceClose(void* device_ctx)
|
||||
free(ctx);
|
||||
}
|
||||
|
||||
int32_t GetDeviceType(void* device_ctx)
|
||||
int32_t GetDeviceType(void *device_ctx)
|
||||
{
|
||||
DeviceContext* ctx = device_ctx;
|
||||
DeviceContext *ctx = device_ctx;
|
||||
|
||||
if(!ctx) return -1;
|
||||
|
||||
#ifdef HAS_UDEV
|
||||
struct udev* udev;
|
||||
struct udev_device* udev_device;
|
||||
const char* tmp_string;
|
||||
char* chrptr;
|
||||
struct udev *udev;
|
||||
struct udev_device *udev_device;
|
||||
const char *tmp_string;
|
||||
char *chrptr;
|
||||
int32_t device_type = AARUREMOTE_DEVICE_TYPE_UNKNOWN;
|
||||
|
||||
udev = udev_new();
|
||||
@@ -112,7 +112,7 @@ int32_t GetDeviceType(void* device_ctx)
|
||||
{
|
||||
device_type = AARUREMOTE_DEVICE_TYPE_ATA;
|
||||
|
||||
free((void*)tmp_string);
|
||||
free((void *)tmp_string);
|
||||
tmp_string = udev_device_get_property_value(udev_device, "ID_TYPE");
|
||||
|
||||
if(tmp_string)
|
||||
@@ -120,30 +120,30 @@ int32_t GetDeviceType(void* device_ctx)
|
||||
// TODO: ATAPI removable non optical disks
|
||||
if(strncmp(tmp_string, "cd", 2) == 0) { device_type = AARUREMOTE_DEVICE_TYPE_ATAPI; }
|
||||
|
||||
free((void*)tmp_string);
|
||||
free((void *)tmp_string);
|
||||
}
|
||||
}
|
||||
else if(strncmp(tmp_string, "mmc", 3) == 0)
|
||||
{
|
||||
free((void*)tmp_string);
|
||||
free((void *)tmp_string);
|
||||
tmp_string = malloc(1024);
|
||||
|
||||
device_type = AARUREMOTE_DEVICE_TYPE_MMC;
|
||||
|
||||
if(tmp_string)
|
||||
{
|
||||
memset((void*)tmp_string, 0, 1024);
|
||||
snprintf((char*)tmp_string, 1024, "/sys/block/%s/device/scr", chrptr);
|
||||
memset((void *)tmp_string, 0, 1024);
|
||||
snprintf((char *)tmp_string, 1024, "/sys/block/%s/device/scr", chrptr);
|
||||
|
||||
if(access(tmp_string, R_OK) == 0) device_type = AARUREMOTE_DEVICE_TYPE_SECURE_DIGITAL;
|
||||
|
||||
free((void*)tmp_string);
|
||||
free((void *)tmp_string);
|
||||
}
|
||||
}
|
||||
else if(strncmp(tmp_string, "scsi", 4) == 0 || strncmp(tmp_string, "ieee1394", 8) == 0 ||
|
||||
strncmp(tmp_string, "usb", 3) == 0)
|
||||
{
|
||||
free((void*)tmp_string);
|
||||
free((void *)tmp_string);
|
||||
tmp_string = udev_device_get_property_value(udev_device, "ID_TYPE");
|
||||
|
||||
if(tmp_string)
|
||||
@@ -152,12 +152,12 @@ int32_t GetDeviceType(void* device_ctx)
|
||||
strncmp(tmp_string, "optical", 7) == 0)
|
||||
device_type = AARUREMOTE_DEVICE_TYPE_SCSI;
|
||||
|
||||
free((void*)tmp_string);
|
||||
free((void *)tmp_string);
|
||||
}
|
||||
}
|
||||
else if(strncmp(tmp_string, "nvme", 4) == 0)
|
||||
{
|
||||
free((void*)tmp_string);
|
||||
free((void *)tmp_string);
|
||||
device_type = AARUREMOTE_DEVICE_TYPE_NVME;
|
||||
}
|
||||
}
|
||||
@@ -168,20 +168,20 @@ int32_t GetDeviceType(void* device_ctx)
|
||||
return device_type;
|
||||
#else
|
||||
int32_t dev_type = AARUREMOTE_DEVICE_TYPE_UNKNOWN;
|
||||
const char* dev_name;
|
||||
const char* sysfs_path;
|
||||
char* dev_path;
|
||||
char* dev_path2;
|
||||
char* host_no;
|
||||
char* scsi_path;
|
||||
char* iscsi_path;
|
||||
char* spi_path;
|
||||
char* fc_path;
|
||||
char* sas_path;
|
||||
const char *dev_name;
|
||||
const char *sysfs_path;
|
||||
char *dev_path;
|
||||
char *dev_path2;
|
||||
char *host_no;
|
||||
char *scsi_path;
|
||||
char *iscsi_path;
|
||||
char *spi_path;
|
||||
char *fc_path;
|
||||
char *sas_path;
|
||||
int ret;
|
||||
char* chrptr;
|
||||
char* sysfs_path_scr;
|
||||
FILE* file;
|
||||
char *chrptr;
|
||||
char *sysfs_path_scr;
|
||||
FILE *file;
|
||||
size_t len = 4096;
|
||||
|
||||
if(strlen(ctx->device_path) <= 5) return dev_type;
|
||||
@@ -219,40 +219,40 @@ int32_t GetDeviceType(void* device_ctx)
|
||||
|
||||
if(!sysfs_path || !dev_path || !host_no || !scsi_path || !iscsi_path || !spi_path || !fc_path || !sas_path)
|
||||
{
|
||||
free((void*)sysfs_path);
|
||||
free((void*)dev_path);
|
||||
free((void*)host_no);
|
||||
free((void*)iscsi_path);
|
||||
free((void*)scsi_path);
|
||||
free((void*)spi_path);
|
||||
free((void*)fc_path);
|
||||
free((void*)sas_path);
|
||||
free((void *)sysfs_path);
|
||||
free((void *)dev_path);
|
||||
free((void *)host_no);
|
||||
free((void *)iscsi_path);
|
||||
free((void *)scsi_path);
|
||||
free((void *)spi_path);
|
||||
free((void *)fc_path);
|
||||
free((void *)sas_path);
|
||||
return dev_type;
|
||||
}
|
||||
|
||||
memset((void*)sysfs_path, 0, len);
|
||||
memset((void*)dev_path, 0, len);
|
||||
memset((void*)host_no, 0, len);
|
||||
memset((void*)iscsi_path, 0, len);
|
||||
memset((void*)scsi_path, 0, len);
|
||||
memset((void*)spi_path, 0, len);
|
||||
memset((void*)fc_path, 0, len);
|
||||
memset((void*)sas_path, 0, len);
|
||||
memset((void *)sysfs_path, 0, len);
|
||||
memset((void *)dev_path, 0, len);
|
||||
memset((void *)host_no, 0, len);
|
||||
memset((void *)iscsi_path, 0, len);
|
||||
memset((void *)scsi_path, 0, len);
|
||||
memset((void *)spi_path, 0, len);
|
||||
memset((void *)fc_path, 0, len);
|
||||
memset((void *)sas_path, 0, len);
|
||||
|
||||
snprintf((char*)sysfs_path, len, "%s/%s/device", PATH_SYS_DEVBLOCK, dev_name);
|
||||
snprintf((char *)sysfs_path, len, "%s/%s/device", PATH_SYS_DEVBLOCK, dev_name);
|
||||
|
||||
ret = readlink(sysfs_path, dev_path, len);
|
||||
|
||||
if(ret <= 0)
|
||||
{
|
||||
free((void*)sysfs_path);
|
||||
free((void*)dev_path);
|
||||
free((void*)host_no);
|
||||
free((void*)iscsi_path);
|
||||
free((void*)scsi_path);
|
||||
free((void*)spi_path);
|
||||
free((void*)fc_path);
|
||||
free((void*)sas_path);
|
||||
free((void *)sysfs_path);
|
||||
free((void *)dev_path);
|
||||
free((void *)host_no);
|
||||
free((void *)iscsi_path);
|
||||
free((void *)scsi_path);
|
||||
free((void *)spi_path);
|
||||
free((void *)fc_path);
|
||||
free((void *)sas_path);
|
||||
return dev_type;
|
||||
}
|
||||
|
||||
@@ -275,14 +275,14 @@ int32_t GetDeviceType(void* device_ctx)
|
||||
|
||||
if(!chrptr)
|
||||
{
|
||||
free((void*)sysfs_path);
|
||||
free((void*)dev_path);
|
||||
free((void*)host_no);
|
||||
free((void*)iscsi_path);
|
||||
free((void*)scsi_path);
|
||||
free((void*)spi_path);
|
||||
free((void*)fc_path);
|
||||
free((void*)sas_path);
|
||||
free((void *)sysfs_path);
|
||||
free((void *)dev_path);
|
||||
free((void *)host_no);
|
||||
free((void *)iscsi_path);
|
||||
free((void *)scsi_path);
|
||||
free((void *)spi_path);
|
||||
free((void *)fc_path);
|
||||
free((void *)sas_path);
|
||||
return dev_type;
|
||||
}
|
||||
|
||||
@@ -339,22 +339,22 @@ int32_t GetDeviceType(void* device_ctx)
|
||||
}
|
||||
}
|
||||
|
||||
free((void*)sysfs_path);
|
||||
free((void*)dev_path);
|
||||
free((void*)host_no);
|
||||
free((void*)iscsi_path);
|
||||
free((void*)scsi_path);
|
||||
free((void*)spi_path);
|
||||
free((void*)fc_path);
|
||||
free((void*)sas_path);
|
||||
free((void *)sysfs_path);
|
||||
free((void *)dev_path);
|
||||
free((void *)host_no);
|
||||
free((void *)iscsi_path);
|
||||
free((void *)scsi_path);
|
||||
free((void *)spi_path);
|
||||
free((void *)fc_path);
|
||||
free((void *)sas_path);
|
||||
|
||||
return dev_type;
|
||||
#endif
|
||||
}
|
||||
|
||||
int32_t ReOpen(void* device_ctx, uint32_t* closeFailed)
|
||||
int32_t ReOpen(void *device_ctx, uint32_t *closeFailed)
|
||||
{
|
||||
DeviceContext* ctx = device_ctx;
|
||||
DeviceContext *ctx = device_ctx;
|
||||
int ret;
|
||||
*closeFailed = 0;
|
||||
|
||||
@@ -375,9 +375,9 @@ int32_t ReOpen(void* device_ctx, uint32_t* closeFailed)
|
||||
return ctx->fd <= 0 ? errno : 0;
|
||||
}
|
||||
|
||||
int32_t OsRead(void* device_ctx, char* buffer, uint64_t offset, uint32_t length, uint32_t* duration)
|
||||
int32_t OsRead(void *device_ctx, char *buffer, uint64_t offset, uint32_t length, uint32_t *duration)
|
||||
{
|
||||
DeviceContext* ctx = device_ctx;
|
||||
DeviceContext *ctx = device_ctx;
|
||||
ssize_t ret;
|
||||
*duration = 0;
|
||||
off_t pos;
|
||||
@@ -390,7 +390,7 @@ int32_t OsRead(void* device_ctx, char* buffer, uint64_t offset, uint32_t length,
|
||||
if(pos < 0) return errno;
|
||||
|
||||
// TODO: Timing
|
||||
ret = read(ctx->fd, (void*)buffer, (size_t)length);
|
||||
ret = read(ctx->fd, (void *)buffer, (size_t)length);
|
||||
|
||||
return ret < 0 ? errno : 0;
|
||||
}
|
||||
@@ -24,22 +24,18 @@
|
||||
#include "../aaruremote.h"
|
||||
#include "linux.h"
|
||||
|
||||
uint8_t GetFireWireData(void* device_ctx,
|
||||
uint32_t* id_model,
|
||||
uint32_t* id_vendor,
|
||||
uint64_t* guid,
|
||||
char* vendor,
|
||||
char* model)
|
||||
uint8_t GetFireWireData(void *device_ctx, uint32_t *id_model, uint32_t *id_vendor, uint64_t *guid, char *vendor,
|
||||
char *model)
|
||||
{
|
||||
DeviceContext* ctx = device_ctx;
|
||||
char* dev_path;
|
||||
DeviceContext *ctx = device_ctx;
|
||||
char *dev_path;
|
||||
char tmp_path[4096];
|
||||
char resolved_link[4096];
|
||||
struct stat sb;
|
||||
ssize_t len;
|
||||
char* rchr;
|
||||
char *rchr;
|
||||
int found;
|
||||
FILE* file;
|
||||
FILE *file;
|
||||
|
||||
if(!ctx) return 0;
|
||||
|
||||
@@ -53,7 +49,7 @@ uint8_t GetFireWireData(void* device_ctx,
|
||||
strncmp(ctx->device_path, "/dev/st", 7) != 0)
|
||||
return 0;
|
||||
|
||||
dev_path = (char*)ctx->device_path + 5;
|
||||
dev_path = (char *)ctx->device_path + 5;
|
||||
|
||||
snprintf(tmp_path, 4096, "/sys/block/%s", dev_path);
|
||||
|
||||
|
||||
@@ -31,21 +31,21 @@
|
||||
#include "../aaruremote.h"
|
||||
#include "linux.h"
|
||||
|
||||
DeviceInfoList* ListDevices()
|
||||
DeviceInfoList *ListDevices()
|
||||
{
|
||||
DIR* dir;
|
||||
struct dirent* dirent;
|
||||
DIR *dir;
|
||||
struct dirent *dirent;
|
||||
int i;
|
||||
DeviceInfoList *list_start = NULL, *list_current = NULL, *list_next = NULL;
|
||||
const char* tmp_string;
|
||||
FILE* file;
|
||||
char* line_str;
|
||||
const char *tmp_string;
|
||||
FILE *file;
|
||||
char *line_str;
|
||||
size_t n, ret;
|
||||
char* chrptr;
|
||||
char *chrptr;
|
||||
int has_udev = 0;
|
||||
#ifdef HAS_UDEV
|
||||
struct udev* udev;
|
||||
struct udev_device* udev_device;
|
||||
struct udev *udev;
|
||||
struct udev_device *udev_device;
|
||||
|
||||
udev = udev_new();
|
||||
has_udev = udev != 0;
|
||||
@@ -95,14 +95,14 @@ DeviceInfoList* ListDevices()
|
||||
if(tmp_string)
|
||||
{
|
||||
strncpy(list_next->this.vendor, tmp_string, 256);
|
||||
free((void*)tmp_string);
|
||||
free((void *)tmp_string);
|
||||
}
|
||||
|
||||
tmp_string = udev_device_get_property_value(udev_device, "ID_MODEL");
|
||||
if(tmp_string)
|
||||
{
|
||||
strncpy(list_next->this.model, tmp_string, 256);
|
||||
free((void*)tmp_string);
|
||||
free((void *)tmp_string);
|
||||
|
||||
for(i = 0; i < 256; i++)
|
||||
{
|
||||
@@ -116,7 +116,7 @@ DeviceInfoList* ListDevices()
|
||||
if(tmp_string)
|
||||
{
|
||||
strncpy(list_next->this.serial, tmp_string, 256);
|
||||
free((void*)tmp_string);
|
||||
free((void *)tmp_string);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -124,7 +124,7 @@ DeviceInfoList* ListDevices()
|
||||
if(tmp_string)
|
||||
{
|
||||
strncpy(list_next->this.serial, tmp_string, 256);
|
||||
free((void*)tmp_string);
|
||||
free((void *)tmp_string);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ DeviceInfoList* ListDevices()
|
||||
if(tmp_string)
|
||||
{
|
||||
strncpy(list_next->this.bus, tmp_string, 256);
|
||||
free((void*)tmp_string);
|
||||
free((void *)tmp_string);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -144,11 +144,19 @@ DeviceInfoList* ListDevices()
|
||||
|
||||
switch(GetDeviceType(&tmp_ctx))
|
||||
{
|
||||
case AARUREMOTE_DEVICE_TYPE_ATA: strncpy(list_next->this.bus, "ATA", 256); break;
|
||||
case AARUREMOTE_DEVICE_TYPE_ATAPI: strncpy(list_next->this.bus, "ATAPI", 256); break;
|
||||
case AARUREMOTE_DEVICE_TYPE_ATA:
|
||||
strncpy(list_next->this.bus, "ATA", 256);
|
||||
break;
|
||||
case AARUREMOTE_DEVICE_TYPE_ATAPI:
|
||||
strncpy(list_next->this.bus, "ATAPI", 256);
|
||||
break;
|
||||
case AARUREMOTE_DEVICE_TYPE_MMC:
|
||||
case AARUREMOTE_DEVICE_TYPE_SECURE_DIGITAL: strncpy(list_next->this.bus, "MMC/SD", 256); break;
|
||||
case AARUREMOTE_DEVICE_TYPE_NVME: strncpy(list_next->this.bus, "NVMe", 256); break;
|
||||
case AARUREMOTE_DEVICE_TYPE_SECURE_DIGITAL:
|
||||
strncpy(list_next->this.bus, "MMC/SD", 256);
|
||||
break;
|
||||
case AARUREMOTE_DEVICE_TYPE_NVME:
|
||||
strncpy(list_next->this.bus, "NVMe", 256);
|
||||
break;
|
||||
case AARUREMOTE_DEVICE_TYPE_SCSI:
|
||||
tmp_string = malloc(1024);
|
||||
memset((void*)tmp_string, 0, 1024);
|
||||
@@ -175,10 +183,10 @@ DeviceInfoList* ListDevices()
|
||||
chrptr--;
|
||||
}
|
||||
|
||||
memset((void*)tmp_string, 0, 1024);
|
||||
memcpy((void*)tmp_string, chrptr, ret);
|
||||
snprintf((char*)line_str, 1024, "/sys/class/scsi_host/host%s/proc_name", tmp_string);
|
||||
memset((void*)tmp_string, 0, 1024);
|
||||
memset((void *)tmp_string, 0, 1024);
|
||||
memcpy((void *)tmp_string, chrptr, ret);
|
||||
snprintf((char *)line_str, 1024, "/sys/class/scsi_host/host%s/proc_name", tmp_string);
|
||||
memset((void *)tmp_string, 0, 1024);
|
||||
|
||||
file = fopen(line_str, "r");
|
||||
if(file)
|
||||
@@ -188,7 +196,8 @@ DeviceInfoList* ListDevices()
|
||||
|
||||
if(ret > 0)
|
||||
{
|
||||
if(strncmp(line_str, "sbp2", 4) == 0) strncpy(list_next->this.bus, "FireWire", 256);
|
||||
if(strncmp(line_str, "sbp2", 4) == 0)
|
||||
strncpy(list_next->this.bus, "FireWire", 256);
|
||||
else if(strncmp(line_str, "usb-storage", 11) == 0)
|
||||
strncpy(list_next->this.bus, "USB", 256);
|
||||
else
|
||||
@@ -212,14 +221,16 @@ DeviceInfoList* ListDevices()
|
||||
|
||||
free((void*)tmp_string);
|
||||
break;
|
||||
default: memset(&list_next->this.bus, 0, 256); break;
|
||||
default:
|
||||
memset(&list_next->this.bus, 0, 256);
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
tmp_string = malloc(1024);
|
||||
memset((void*)tmp_string, 0, 1024);
|
||||
snprintf((char*)tmp_string, 1024, "%s/%s/device/vendor", PATH_SYS_DEVBLOCK, dirent->d_name);
|
||||
memset((void *)tmp_string, 0, 1024);
|
||||
snprintf((char *)tmp_string, 1024, "%s/%s/device/vendor", PATH_SYS_DEVBLOCK, dirent->d_name);
|
||||
|
||||
if(access(tmp_string, R_OK) == 0 && strlen(list_next->this.vendor) == 0)
|
||||
{
|
||||
@@ -237,7 +248,8 @@ DeviceInfoList* ListDevices()
|
||||
strncpy(list_next->this.vendor, line_str, 256);
|
||||
for(i = 255; i >= 0; i--)
|
||||
{
|
||||
if(list_next->this.vendor[i] == 0) continue;
|
||||
if(list_next->this.vendor[i] == 0)
|
||||
continue;
|
||||
|
||||
else if(list_next->this.vendor[i] == 0x0A || list_next->this.vendor[i] == 0x0D ||
|
||||
list_next->this.vendor[i] == ' ')
|
||||
@@ -251,15 +263,12 @@ DeviceInfoList* ListDevices()
|
||||
fclose(file);
|
||||
}
|
||||
}
|
||||
else if(strncmp(dirent->d_name, "loop", 4) == 0)
|
||||
{
|
||||
strncpy(list_next->this.vendor, "Linux", 256);
|
||||
}
|
||||
free((void*)tmp_string);
|
||||
else if(strncmp(dirent->d_name, "loop", 4) == 0) { strncpy(list_next->this.vendor, "Linux", 256); }
|
||||
free((void *)tmp_string);
|
||||
|
||||
tmp_string = malloc(1024);
|
||||
memset((void*)tmp_string, 0, 1024);
|
||||
snprintf((char*)tmp_string, 1024, "%s/%s/device/model", PATH_SYS_DEVBLOCK, dirent->d_name);
|
||||
memset((void *)tmp_string, 0, 1024);
|
||||
snprintf((char *)tmp_string, 1024, "%s/%s/device/model", PATH_SYS_DEVBLOCK, dirent->d_name);
|
||||
|
||||
if(access(tmp_string, R_OK) == 0 &&
|
||||
(strlen(list_next->this.model) == 0 || strncmp(list_next->this.bus, "ata", 3) == 0))
|
||||
@@ -278,7 +287,8 @@ DeviceInfoList* ListDevices()
|
||||
strncpy(list_next->this.model, line_str, 256);
|
||||
for(i = 255; i >= 0; i--)
|
||||
{
|
||||
if(list_next->this.model[i] == 0) continue;
|
||||
if(list_next->this.model[i] == 0)
|
||||
continue;
|
||||
|
||||
else if(list_next->this.model[i] == 0x0A || list_next->this.model[i] == 0x0D ||
|
||||
list_next->this.model[i] == ' ')
|
||||
@@ -292,15 +302,12 @@ DeviceInfoList* ListDevices()
|
||||
fclose(file);
|
||||
}
|
||||
}
|
||||
else if(strncmp(dirent->d_name, "loop", 4) == 0)
|
||||
{
|
||||
strncpy(list_next->this.model, "Linux", 256);
|
||||
}
|
||||
free((void*)tmp_string);
|
||||
else if(strncmp(dirent->d_name, "loop", 4) == 0) { strncpy(list_next->this.model, "Linux", 256); }
|
||||
free((void *)tmp_string);
|
||||
|
||||
tmp_string = malloc(1024);
|
||||
memset((void*)tmp_string, 0, 1024);
|
||||
snprintf((char*)tmp_string, 1024, "%s/%s/device/serial", PATH_SYS_DEVBLOCK, dirent->d_name);
|
||||
memset((void *)tmp_string, 0, 1024);
|
||||
snprintf((char *)tmp_string, 1024, "%s/%s/device/serial", PATH_SYS_DEVBLOCK, dirent->d_name);
|
||||
|
||||
if(access(tmp_string, R_OK) == 0 && (strlen(list_next->this.serial) == 0))
|
||||
{
|
||||
@@ -318,7 +325,8 @@ DeviceInfoList* ListDevices()
|
||||
strncpy(list_next->this.serial, line_str, 256);
|
||||
for(i = 255; i >= 0; i--)
|
||||
{
|
||||
if(list_next->this.serial[i] == 0) continue;
|
||||
if(list_next->this.serial[i] == 0)
|
||||
continue;
|
||||
|
||||
else if(list_next->this.serial[i] == 0x0A || list_next->this.serial[i] == 0x0D ||
|
||||
list_next->this.serial[i] == ' ')
|
||||
@@ -332,14 +340,14 @@ DeviceInfoList* ListDevices()
|
||||
fclose(file);
|
||||
}
|
||||
}
|
||||
free((void*)tmp_string);
|
||||
free((void *)tmp_string);
|
||||
|
||||
if(strlen(list_next->this.vendor) == 0 || strncmp(list_next->this.vendor, "ATA", 3) == 0)
|
||||
{
|
||||
if(strlen(list_next->this.model) > 0)
|
||||
{
|
||||
tmp_string = malloc(256);
|
||||
strncpy((void*)tmp_string, list_next->this.model, 256);
|
||||
strncpy((void *)tmp_string, list_next->this.model, 256);
|
||||
|
||||
chrptr = strchr(tmp_string, ' ');
|
||||
|
||||
@@ -351,14 +359,15 @@ DeviceInfoList* ListDevices()
|
||||
strncpy(list_next->this.model, chrptr + 1, 256 - (chrptr - tmp_string) - 1);
|
||||
}
|
||||
|
||||
free((void*)tmp_string);
|
||||
free((void *)tmp_string);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Get better device type from sysfs paths
|
||||
if(strlen(list_next->this.bus) == 0)
|
||||
{
|
||||
if(strncmp(dirent->d_name, "loop", 4) == 0) strncpy(list_next->this.bus, "loop", 4);
|
||||
if(strncmp(dirent->d_name, "loop", 4) == 0)
|
||||
strncpy(list_next->this.bus, "loop", 4);
|
||||
else if(strncmp(dirent->d_name, "nvme", 4) == 0)
|
||||
strncpy(list_next->this.bus, "NVMe", 4);
|
||||
else if(strncmp(dirent->d_name, "mmc", 3) == 0)
|
||||
|
||||
@@ -55,6 +55,7 @@ struct mmc_ioc_cmd
|
||||
/* DAT buffer */
|
||||
uint64_t data_ptr;
|
||||
};
|
||||
|
||||
#define mmc_ioc_cmd_set_data(ic, ptr) ic.data_ptr = (__u64)(unsigned long)ptr
|
||||
|
||||
/**
|
||||
|
||||
@@ -25,18 +25,18 @@
|
||||
#include "../aaruremote.h"
|
||||
#include "linux.h"
|
||||
|
||||
uint8_t GetPcmciaData(void* device_ctx, uint16_t* cis_len, char* cis)
|
||||
uint8_t GetPcmciaData(void *device_ctx, uint16_t *cis_len, char *cis)
|
||||
{
|
||||
DeviceContext* ctx = device_ctx;
|
||||
char* dev_path;
|
||||
DeviceContext *ctx = device_ctx;
|
||||
char *dev_path;
|
||||
char tmp_path[4096];
|
||||
char resolved_link[4096];
|
||||
struct stat sb;
|
||||
ssize_t len;
|
||||
char* rchr;
|
||||
FILE* file;
|
||||
DIR* dir;
|
||||
struct dirent* dent;
|
||||
char *rchr;
|
||||
FILE *file;
|
||||
DIR *dir;
|
||||
struct dirent *dent;
|
||||
*cis_len = 0;
|
||||
|
||||
if(!ctx) return 0;
|
||||
@@ -48,7 +48,7 @@ uint8_t GetPcmciaData(void* device_ctx, uint16_t* cis_len, char* cis)
|
||||
strncmp(ctx->device_path, "/dev/st", 7) != 0)
|
||||
return 0;
|
||||
|
||||
dev_path = (char*)ctx->device_path + 5;
|
||||
dev_path = (char *)ctx->device_path + 5;
|
||||
|
||||
snprintf(tmp_path, 4096, "/sys/block/%s", dev_path);
|
||||
|
||||
|
||||
36
linux/scsi.c
36
linux/scsi.c
@@ -24,19 +24,11 @@
|
||||
#include "../aaruremote.h"
|
||||
#include "linux.h"
|
||||
|
||||
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)
|
||||
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)
|
||||
{
|
||||
DeviceContext* ctx = device_ctx;
|
||||
DeviceContext *ctx = device_ctx;
|
||||
sg_io_hdr_t hdr;
|
||||
int dir, ret;
|
||||
*sense_len = 32;
|
||||
@@ -50,12 +42,20 @@ int32_t SendScsiCommand(void* device_ctx,
|
||||
|
||||
switch(direction)
|
||||
{
|
||||
case AARUREMOTE_SCSI_DIRECTION_IN: dir = SG_DXFER_FROM_DEV; break;
|
||||
case AARUREMOTE_SCSI_DIRECTION_OUT: dir = SG_DXFER_TO_DEV; break;
|
||||
case AARUREMOTE_SCSI_DIRECTION_IN:
|
||||
dir = SG_DXFER_FROM_DEV;
|
||||
break;
|
||||
case AARUREMOTE_SCSI_DIRECTION_OUT:
|
||||
dir = SG_DXFER_TO_DEV;
|
||||
break;
|
||||
case AARUREMOTE_SCSI_DIRECTION_INOUT:
|
||||
case AARUREMOTE_SCSI_DIRECTION_UNSPECIFIED: dir = SG_DXFER_TO_FROM_DEV; break;
|
||||
case AARUREMOTE_SCSI_DIRECTION_UNSPECIFIED:
|
||||
dir = SG_DXFER_TO_FROM_DEV;
|
||||
break;
|
||||
case AARUREMOTE_SCSI_DIRECTION_NONE:
|
||||
default: dir = SG_DXFER_NONE; break;
|
||||
default:
|
||||
dir = SG_DXFER_NONE;
|
||||
break;
|
||||
}
|
||||
|
||||
hdr.interface_id = 'S';
|
||||
@@ -64,8 +64,8 @@ int32_t SendScsiCommand(void* device_ctx,
|
||||
hdr.dxfer_direction = dir;
|
||||
hdr.dxfer_len = *buf_len;
|
||||
hdr.dxferp = buffer;
|
||||
hdr.cmdp = (unsigned char*)cdb;
|
||||
hdr.sbp = (unsigned char*)*sense_buffer;
|
||||
hdr.cmdp = (unsigned char *)cdb;
|
||||
hdr.sbp = (unsigned char *)*sense_buffer;
|
||||
hdr.timeout = timeout;
|
||||
hdr.flags = SG_FLAG_DIRECT_IO;
|
||||
|
||||
|
||||
@@ -27,22 +27,11 @@
|
||||
#include "linux.h"
|
||||
#include "mmc/ioctl.h"
|
||||
|
||||
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 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)
|
||||
{
|
||||
DeviceContext* ctx = device_ctx;
|
||||
DeviceContext *ctx = device_ctx;
|
||||
struct mmc_ioc_cmd mmc_ioc_cmd;
|
||||
int32_t error;
|
||||
*duration = 0;
|
||||
@@ -74,29 +63,22 @@ int32_t SendSdhciCommand(void* device_ctx,
|
||||
|
||||
*sense = error < 0;
|
||||
|
||||
memcpy((char*)response, (char*)&mmc_ioc_cmd.response, sizeof(uint32_t) * 4);
|
||||
memcpy((char *)response, (char *)&mmc_ioc_cmd.response, sizeof(uint32_t) * 4);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
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)
|
||||
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)
|
||||
{
|
||||
DeviceContext* ctx = device_ctx;
|
||||
char* tmp_string;
|
||||
char* sysfs_path_csd;
|
||||
char* sysfs_path_cid;
|
||||
char* sysfs_path_scr;
|
||||
char* sysfs_path_ocr;
|
||||
DeviceContext *ctx = device_ctx;
|
||||
char *tmp_string;
|
||||
char *sysfs_path_csd;
|
||||
char *sysfs_path_cid;
|
||||
char *sysfs_path_scr;
|
||||
char *sysfs_path_ocr;
|
||||
size_t len;
|
||||
FILE* file;
|
||||
FILE *file;
|
||||
*csd = NULL;
|
||||
*cid = NULL;
|
||||
*ocr = NULL;
|
||||
@@ -149,7 +131,7 @@ int32_t GetSdhciRegisters(void* device_ctx,
|
||||
len = getline(&tmp_string, &n, file);
|
||||
if(len > 0)
|
||||
{
|
||||
*csd_len = Hexs2Bin(tmp_string, (unsigned char**)csd);
|
||||
*csd_len = Hexs2Bin(tmp_string, (unsigned char **)csd);
|
||||
|
||||
if(*csd_len <= 0)
|
||||
{
|
||||
@@ -171,7 +153,7 @@ int32_t GetSdhciRegisters(void* device_ctx,
|
||||
len = getline(&tmp_string, &n, file);
|
||||
if(len > 0)
|
||||
{
|
||||
*cid_len = Hexs2Bin(tmp_string, (unsigned char**)cid);
|
||||
*cid_len = Hexs2Bin(tmp_string, (unsigned char **)cid);
|
||||
|
||||
if(*cid_len <= 0)
|
||||
{
|
||||
@@ -193,7 +175,7 @@ int32_t GetSdhciRegisters(void* device_ctx,
|
||||
len = getline(&tmp_string, &n, file);
|
||||
if(len > 0)
|
||||
{
|
||||
*scr_len = Hexs2Bin(tmp_string, (unsigned char**)scr);
|
||||
*scr_len = Hexs2Bin(tmp_string, (unsigned char **)scr);
|
||||
|
||||
if(*scr_len <= 0)
|
||||
{
|
||||
@@ -215,7 +197,7 @@ int32_t GetSdhciRegisters(void* device_ctx,
|
||||
len = getline(&tmp_string, &n, file);
|
||||
if(len > 0)
|
||||
{
|
||||
*ocr_len = Hexs2Bin(tmp_string, (unsigned char**)ocr);
|
||||
*ocr_len = Hexs2Bin(tmp_string, (unsigned char **)ocr);
|
||||
|
||||
if(*ocr_len <= 0)
|
||||
{
|
||||
@@ -237,16 +219,13 @@ int32_t GetSdhciRegisters(void* device_ctx,
|
||||
return csd_len != 0 || cid_len != 0 || scr_len != 0 || ocr_len != 0;
|
||||
}
|
||||
|
||||
int32_t SendMultiSdhciCommand(void* device_ctx,
|
||||
uint64_t count,
|
||||
MmcSingleCommand commands[],
|
||||
uint32_t* duration,
|
||||
uint32_t* sense)
|
||||
int32_t SendMultiSdhciCommand(void *device_ctx, uint64_t count, MmcSingleCommand commands[], uint32_t *duration,
|
||||
uint32_t *sense)
|
||||
{
|
||||
DeviceContext* ctx = device_ctx;
|
||||
DeviceContext *ctx = device_ctx;
|
||||
*duration = 0;
|
||||
*sense = 0;
|
||||
struct mmc_ioc_multi_cmd* mmc_ioc_multi_cmd;
|
||||
struct mmc_ioc_multi_cmd *mmc_ioc_multi_cmd;
|
||||
uint64_t i;
|
||||
int32_t error;
|
||||
if(!ctx) return -1;
|
||||
@@ -289,7 +268,7 @@ int32_t SendMultiSdhciCommand(void* device_ctx,
|
||||
*sense = error < 0;
|
||||
|
||||
for(i = 0; i < count; i++)
|
||||
memcpy((char*)commands[i].response, (char*)mmc_ioc_multi_cmd->cmds[i].response, sizeof(uint32_t) * 4);
|
||||
memcpy((char *)commands[i].response, (char *)mmc_ioc_multi_cmd->cmds[i].response, sizeof(uint32_t) * 4);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
20
linux/usb.c
20
linux/usb.c
@@ -24,24 +24,18 @@
|
||||
#include "../aaruremote.h"
|
||||
#include "linux.h"
|
||||
|
||||
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 GetUsbData(void *device_ctx, uint16_t *desc_len, char *descriptors, uint16_t *id_vendor, uint16_t *id_product,
|
||||
char *manufacturer, char *product, char *serial)
|
||||
{
|
||||
DeviceContext* ctx = device_ctx;
|
||||
char* dev_path;
|
||||
DeviceContext *ctx = device_ctx;
|
||||
char *dev_path;
|
||||
char tmp_path[4096];
|
||||
char resolved_link[4096];
|
||||
struct stat sb;
|
||||
ssize_t len;
|
||||
char* rchr;
|
||||
char *rchr;
|
||||
int found = 1;
|
||||
FILE* file;
|
||||
FILE *file;
|
||||
|
||||
if(!ctx) return -1;
|
||||
|
||||
@@ -55,7 +49,7 @@ uint8_t GetUsbData(void* device_ctx,
|
||||
strncmp(ctx->device_path, "/dev/st", 7) != 0)
|
||||
return 0;
|
||||
|
||||
dev_path = (char*)ctx->device_path + 5;
|
||||
dev_path = (char *)ctx->device_path + 5;
|
||||
|
||||
snprintf(tmp_path, 4096, "/sys/block/%s", dev_path);
|
||||
|
||||
|
||||
@@ -26,11 +26,11 @@
|
||||
#include "../aaruremote.h"
|
||||
#include "../endian.h"
|
||||
|
||||
AaruPacketHello* GetHello()
|
||||
AaruPacketHello *GetHello()
|
||||
{
|
||||
struct utsname utsname;
|
||||
int ret;
|
||||
AaruPacketHello* pkt_server_hello;
|
||||
AaruPacketHello *pkt_server_hello;
|
||||
|
||||
ret = uname(&utsname);
|
||||
|
||||
|
||||
@@ -28,8 +28,8 @@
|
||||
int PrintNetworkAddresses()
|
||||
{
|
||||
int ret;
|
||||
struct ifaddrs* ifa;
|
||||
struct ifaddrs* ifa_start;
|
||||
struct ifaddrs *ifa;
|
||||
struct ifaddrs *ifa_start;
|
||||
char ipv4_address[INET_ADDRSTRLEN];
|
||||
|
||||
ret = getifaddrs(&ifa);
|
||||
@@ -43,7 +43,7 @@ int PrintNetworkAddresses()
|
||||
{
|
||||
if(ifa->ifa_addr && ifa->ifa_addr->sa_family == AF_INET)
|
||||
{
|
||||
inet_ntop(AF_INET, &((struct sockaddr_in*)ifa->ifa_addr)->sin_addr, ipv4_address, INET_ADDRSTRLEN);
|
||||
inet_ntop(AF_INET, &((struct sockaddr_in *)ifa->ifa_addr)->sin_addr, ipv4_address, INET_ADDRSTRLEN);
|
||||
printf("%s port %d\n", ipv4_address, AARUREMOTE_PORT);
|
||||
}
|
||||
|
||||
@@ -55,11 +55,11 @@ int PrintNetworkAddresses()
|
||||
return 0;
|
||||
}
|
||||
|
||||
char* PrintIpv4Address(struct in_addr addr) { return inet_ntoa(addr); }
|
||||
char *PrintIpv4Address(struct in_addr addr) { return inet_ntoa(addr); }
|
||||
|
||||
void* NetSocket(uint32_t domain, uint32_t type, uint32_t protocol)
|
||||
void *NetSocket(uint32_t domain, uint32_t type, uint32_t protocol)
|
||||
{
|
||||
NetworkContext* ctx;
|
||||
NetworkContext *ctx;
|
||||
|
||||
ctx = malloc(sizeof(NetworkContext));
|
||||
|
||||
@@ -76,28 +76,28 @@ void* NetSocket(uint32_t domain, uint32_t type, uint32_t protocol)
|
||||
return ctx;
|
||||
}
|
||||
|
||||
int32_t NetBind(void* net_ctx, struct sockaddr* addr, socklen_t addrlen)
|
||||
int32_t NetBind(void *net_ctx, struct sockaddr *addr, socklen_t addrlen)
|
||||
{
|
||||
NetworkContext* ctx = net_ctx;
|
||||
NetworkContext *ctx = net_ctx;
|
||||
|
||||
if(!ctx) return -1;
|
||||
|
||||
return bind(ctx->fd, addr, addrlen);
|
||||
}
|
||||
|
||||
int32_t NetListen(void* net_ctx, uint32_t backlog)
|
||||
int32_t NetListen(void *net_ctx, uint32_t backlog)
|
||||
{
|
||||
NetworkContext* ctx = net_ctx;
|
||||
NetworkContext *ctx = net_ctx;
|
||||
|
||||
if(!ctx) return -1;
|
||||
|
||||
return listen(ctx->fd, backlog);
|
||||
}
|
||||
|
||||
void* NetAccept(void* net_ctx, struct sockaddr* addr, socklen_t* addrlen)
|
||||
void *NetAccept(void *net_ctx, struct sockaddr *addr, socklen_t *addrlen)
|
||||
{
|
||||
NetworkContext* ctx = net_ctx;
|
||||
NetworkContext* cli_ctx;
|
||||
NetworkContext *ctx = net_ctx;
|
||||
NetworkContext *cli_ctx;
|
||||
|
||||
if(!ctx) return NULL;
|
||||
|
||||
@@ -116,9 +116,9 @@ void* NetAccept(void* net_ctx, struct sockaddr* addr, socklen_t* addrlen)
|
||||
return cli_ctx;
|
||||
}
|
||||
|
||||
int32_t NetRecv(void* net_ctx, void* buf, int32_t len, uint32_t flags)
|
||||
int32_t NetRecv(void *net_ctx, void *buf, int32_t len, uint32_t flags)
|
||||
{
|
||||
NetworkContext* ctx = net_ctx;
|
||||
NetworkContext *ctx = net_ctx;
|
||||
|
||||
if(!ctx) return -1;
|
||||
|
||||
@@ -139,19 +139,19 @@ int32_t NetRecv(void* net_ctx, void* buf, int32_t len, uint32_t flags)
|
||||
return got_total;
|
||||
}
|
||||
|
||||
int32_t NetWrite(void* net_ctx, const void* buf, int32_t size)
|
||||
int32_t NetWrite(void *net_ctx, const void *buf, int32_t size)
|
||||
{
|
||||
NetworkContext* ctx = net_ctx;
|
||||
NetworkContext *ctx = net_ctx;
|
||||
|
||||
if(!ctx) return -1;
|
||||
|
||||
return write(ctx->fd, buf, size);
|
||||
}
|
||||
|
||||
int32_t NetClose(void* net_ctx)
|
||||
int32_t NetClose(void *net_ctx)
|
||||
{
|
||||
int ret;
|
||||
NetworkContext* ctx = net_ctx;
|
||||
NetworkContext *ctx = net_ctx;
|
||||
|
||||
if(!ctx) return -1;
|
||||
|
||||
|
||||
@@ -24,6 +24,6 @@ void Initialize()
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
void PlatformLoop(AaruPacketHello* pkt_server_hello) { WorkingLoop(pkt_server_hello); }
|
||||
void PlatformLoop(AaruPacketHello *pkt_server_hello) { WorkingLoop(pkt_server_hello); }
|
||||
|
||||
uint8_t AmIRoot() { return geteuid() == 0; }
|
||||
@@ -23,9 +23,9 @@
|
||||
#include "../aaruremote.h"
|
||||
#include "../endian.h"
|
||||
|
||||
AaruPacketHello* GetHello()
|
||||
AaruPacketHello *GetHello()
|
||||
{
|
||||
AaruPacketHello* pkt_server_hello;
|
||||
AaruPacketHello *pkt_server_hello;
|
||||
|
||||
pkt_server_hello = malloc(sizeof(AaruPacketHello));
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include "../aaruremote.h"
|
||||
#include "wii.h"
|
||||
|
||||
DeviceInfoList* ListDevices()
|
||||
DeviceInfoList *ListDevices()
|
||||
{
|
||||
DeviceInfoList *list_start = NULL, *list_current = NULL, *list_next = NULL;
|
||||
u32 deviceId = 0;
|
||||
|
||||
@@ -39,10 +39,11 @@ int PrintNetworkAddresses()
|
||||
return 0;
|
||||
}
|
||||
|
||||
char* PrintIpv4Address(struct in_addr addr) { return inet_ntoa(addr); }
|
||||
void* NetSocket(uint32_t domain, uint32_t type, uint32_t protocol)
|
||||
char *PrintIpv4Address(struct in_addr addr) { return inet_ntoa(addr); }
|
||||
|
||||
void *NetSocket(uint32_t domain, uint32_t type, uint32_t protocol)
|
||||
{
|
||||
NetworkContext* ctx;
|
||||
NetworkContext *ctx;
|
||||
|
||||
ctx = malloc(sizeof(NetworkContext));
|
||||
|
||||
@@ -59,28 +60,28 @@ void* NetSocket(uint32_t domain, uint32_t type, uint32_t protocol)
|
||||
return ctx;
|
||||
}
|
||||
|
||||
int32_t NetBind(void* net_ctx, struct sockaddr* addr, socklen_t addrlen)
|
||||
int32_t NetBind(void *net_ctx, struct sockaddr *addr, socklen_t addrlen)
|
||||
{
|
||||
NetworkContext* ctx = net_ctx;
|
||||
NetworkContext *ctx = net_ctx;
|
||||
|
||||
if(!ctx) return -1;
|
||||
|
||||
return net_bind(ctx->fd, addr, addrlen);
|
||||
}
|
||||
|
||||
int32_t NetListen(void* net_ctx, uint32_t backlog)
|
||||
int32_t NetListen(void *net_ctx, uint32_t backlog)
|
||||
{
|
||||
NetworkContext* ctx = net_ctx;
|
||||
NetworkContext *ctx = net_ctx;
|
||||
|
||||
if(!ctx) return -1;
|
||||
|
||||
return net_listen(ctx->fd, backlog);
|
||||
}
|
||||
|
||||
void* NetAccept(void* net_ctx, struct sockaddr* addr, socklen_t* addrlen)
|
||||
void *NetAccept(void *net_ctx, struct sockaddr *addr, socklen_t *addrlen)
|
||||
{
|
||||
NetworkContext* ctx = net_ctx;
|
||||
NetworkContext* cli_ctx;
|
||||
NetworkContext *ctx = net_ctx;
|
||||
NetworkContext *cli_ctx;
|
||||
|
||||
if(!ctx) return NULL;
|
||||
|
||||
@@ -99,9 +100,9 @@ void* NetAccept(void* net_ctx, struct sockaddr* addr, socklen_t* addrlen)
|
||||
return cli_ctx;
|
||||
}
|
||||
|
||||
int32_t NetRecv(void* net_ctx, void* buf, int32_t len, uint32_t flags)
|
||||
int32_t NetRecv(void *net_ctx, void *buf, int32_t len, uint32_t flags)
|
||||
{
|
||||
NetworkContext* ctx = net_ctx;
|
||||
NetworkContext *ctx = net_ctx;
|
||||
|
||||
if(!ctx) return -1;
|
||||
|
||||
@@ -122,19 +123,19 @@ int32_t NetRecv(void* net_ctx, void* buf, int32_t len, uint32_t flags)
|
||||
return got_total;
|
||||
}
|
||||
|
||||
int32_t NetWrite(void* net_ctx, const void* buf, int32_t size)
|
||||
int32_t NetWrite(void *net_ctx, const void *buf, int32_t size)
|
||||
{
|
||||
NetworkContext* ctx = net_ctx;
|
||||
NetworkContext *ctx = net_ctx;
|
||||
|
||||
if(!ctx) return -1;
|
||||
|
||||
return net_write(ctx->fd, buf, size);
|
||||
}
|
||||
|
||||
int32_t NetClose(void* net_ctx)
|
||||
int32_t NetClose(void *net_ctx)
|
||||
{
|
||||
int ret;
|
||||
NetworkContext* ctx = net_ctx;
|
||||
NetworkContext *ctx = net_ctx;
|
||||
|
||||
if(!ctx) return -1;
|
||||
|
||||
|
||||
@@ -19,56 +19,36 @@
|
||||
|
||||
// TODO
|
||||
|
||||
void* DeviceOpen(const char* device_path) { return NULL; }
|
||||
void *DeviceOpen(const char *device_path) { return NULL; }
|
||||
|
||||
void DeviceClose(void* device_ctx) {}
|
||||
void DeviceClose(void *device_ctx) {}
|
||||
|
||||
int32_t GetDeviceType(void* device_ctx) { return AARUREMOTE_DEVICE_TYPE_UNKNOWN; }
|
||||
int32_t GetDeviceType(void *device_ctx) { return AARUREMOTE_DEVICE_TYPE_UNKNOWN; }
|
||||
|
||||
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)
|
||||
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)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
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 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)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t SendMultiSdhciCommand(void* device_ctx,
|
||||
uint64_t count,
|
||||
MmcSingleCommand commands[],
|
||||
uint32_t* duration,
|
||||
uint32_t* sense)
|
||||
int32_t SendMultiSdhciCommand(void *device_ctx, uint64_t count, MmcSingleCommand commands[], uint32_t *duration,
|
||||
uint32_t *sense)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
int32_t ReOpen(void* device_ctx, uint32_t* closeFailed)
|
||||
|
||||
int32_t ReOpen(void *device_ctx, uint32_t *closeFailed)
|
||||
{
|
||||
*closeFailed = 1;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t OsRead(void* device_ctx, char* buffer, uint64_t offset, uint32_t length, uint32_t* duration) { return -1; }
|
||||
int32_t OsRead(void *device_ctx, char *buffer, uint64_t offset, uint32_t length, uint32_t *duration) { return -1; }
|
||||
@@ -17,86 +17,44 @@
|
||||
|
||||
#include "../aaruremote.h"
|
||||
|
||||
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 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)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
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 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)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
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 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)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
uint8_t GetFireWireData(void* device_ctx,
|
||||
uint32_t* id_model,
|
||||
uint32_t* id_vendor,
|
||||
uint64_t* guid,
|
||||
char* vendor,
|
||||
char* model)
|
||||
uint8_t GetFireWireData(void *device_ctx, uint32_t *id_model, uint32_t *id_vendor, uint64_t *guid, char *vendor,
|
||||
char *model)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t GetPcmciaData(void* device_ctx, uint16_t* cis_len, char* cis) { return 0; }
|
||||
uint8_t GetPcmciaData(void *device_ctx, uint16_t *cis_len, char *cis) { return 0; }
|
||||
|
||||
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)
|
||||
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)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
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 GetUsbData(void *device_ctx, uint16_t *desc_len, char *descriptors, uint16_t *id_vendor, uint16_t *id_product,
|
||||
char *manufacturer, char *product, char *serial)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
|
||||
void Initialize()
|
||||
{
|
||||
void* framebuffer;
|
||||
static GXRModeObj* rmode = NULL;
|
||||
void *framebuffer;
|
||||
static GXRModeObj *rmode = NULL;
|
||||
|
||||
VIDEO_Init();
|
||||
WPAD_Init();
|
||||
@@ -42,7 +42,7 @@ void Initialize()
|
||||
if(rmode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync();
|
||||
}
|
||||
|
||||
void PlatformLoop(AaruPacketHello* pkt_server_hello)
|
||||
void PlatformLoop(AaruPacketHello *pkt_server_hello)
|
||||
{
|
||||
static lwp_t worker = (lwp_t)NULL;
|
||||
int buttonsDown;
|
||||
|
||||
Reference in New Issue
Block a user