forked from Hay1tsme/segatools
amex: Use iobuf_write() instead of pointer casts
This commit is contained in:
parent
bbbb6d08b0
commit
6bdd1f90bc
29
amex/ds.c
29
amex/ds.c
@ -149,26 +149,25 @@ static HRESULT ds_handle_ioctl(struct irp *irp)
|
||||
|
||||
static HRESULT ds_ioctl_get_geometry(struct irp *irp)
|
||||
{
|
||||
DISK_GEOMETRY *out;
|
||||
|
||||
if (irp->read.nbytes < sizeof(*out)) {
|
||||
dprintf("DS: Invalid ioctl response buffer size\n");
|
||||
|
||||
return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
|
||||
}
|
||||
DISK_GEOMETRY out;
|
||||
HRESULT hr;
|
||||
|
||||
dprintf("DS: Get geometry\n");
|
||||
|
||||
out = (DISK_GEOMETRY *) irp->read.bytes;
|
||||
out->Cylinders.QuadPart = 1;
|
||||
out->MediaType = 0;
|
||||
out->TracksPerCylinder = 1;
|
||||
out->SectorsPerTrack = 2;
|
||||
out->BytesPerSector = 32;
|
||||
memset(&out, 0, sizeof(out));
|
||||
out.Cylinders.QuadPart = 1;
|
||||
out.MediaType = 0;
|
||||
out.TracksPerCylinder = 1;
|
||||
out.SectorsPerTrack = 2;
|
||||
out.BytesPerSector = 32;
|
||||
|
||||
irp->read.pos = sizeof(*out);
|
||||
hr = iobuf_write(&irp->read, &out, sizeof(out));
|
||||
|
||||
return S_OK;
|
||||
if (FAILED(hr)) {
|
||||
dprintf("DS: Get geometry failed: %08x\n", (int) hr);
|
||||
}
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
static HRESULT ds_ioctl_setup(struct irp *irp)
|
||||
|
@ -118,28 +118,27 @@ static HRESULT eeprom_handle_ioctl(struct irp *irp)
|
||||
|
||||
static HRESULT eeprom_ioctl_get_geometry(struct irp *irp)
|
||||
{
|
||||
DISK_GEOMETRY *out;
|
||||
|
||||
if (irp->read.nbytes < sizeof(*out)) {
|
||||
dprintf("EEPROM: Invalid ioctl response buffer size\n");
|
||||
|
||||
return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
|
||||
}
|
||||
DISK_GEOMETRY out;
|
||||
HRESULT hr;
|
||||
|
||||
dprintf("EEPROM: Get geometry\n");
|
||||
|
||||
/* Not the real values, just bullshitting something for now */
|
||||
|
||||
out = (DISK_GEOMETRY *) irp->read.bytes;
|
||||
out->Cylinders.QuadPart = 0x800;
|
||||
out->MediaType = 0;
|
||||
out->TracksPerCylinder = 1;
|
||||
out->SectorsPerTrack = 2;
|
||||
out->BytesPerSector = 4;
|
||||
memset(&out, 0, sizeof(out));
|
||||
out.Cylinders.QuadPart = 0x800;
|
||||
out.MediaType = 0;
|
||||
out.TracksPerCylinder = 1;
|
||||
out.SectorsPerTrack = 2;
|
||||
out.BytesPerSector = 4;
|
||||
|
||||
irp->read.pos = sizeof(*out);
|
||||
hr = iobuf_write(&irp->read, &out, sizeof(out));
|
||||
|
||||
return S_OK;
|
||||
if (FAILED(hr)) {
|
||||
dprintf("EEPROM: Get geometry failed: %08x\n", (int) hr);
|
||||
}
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
static HRESULT eeprom_handle_read(struct irp *irp)
|
||||
|
13
amex/gpio.c
13
amex/gpio.c
@ -205,18 +205,17 @@ static HRESULT gpio_ioctl_get_psw(struct irp *irp)
|
||||
|
||||
static HRESULT gpio_ioctl_describe(struct irp *irp)
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
dprintf("GPIO: Describe GPIO ports\n");
|
||||
|
||||
if (irp->read.nbytes < sizeof(gpio_ports)) {
|
||||
dprintf("GPIO: Descriptor read buffer too small\n");
|
||||
hr = iobuf_write(&irp->read, &gpio_ports, sizeof(gpio_ports));
|
||||
|
||||
return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
|
||||
if (FAILED(hr)) {
|
||||
dprintf("GPIO: Describe GPIO ports failed: %08x\n", (int) hr);
|
||||
}
|
||||
|
||||
memcpy(irp->read.bytes, &gpio_ports, sizeof(gpio_ports));
|
||||
irp->read.pos = sizeof(gpio_ports);
|
||||
|
||||
return S_OK;
|
||||
return hr;
|
||||
}
|
||||
|
||||
static HRESULT gpio_ioctl_set_leds(struct irp *irp)
|
||||
|
29
amex/sram.c
29
amex/sram.c
@ -114,24 +114,23 @@ static HRESULT sram_handle_ioctl(struct irp *irp)
|
||||
|
||||
static HRESULT sram_ioctl_get_geometry(struct irp *irp)
|
||||
{
|
||||
DISK_GEOMETRY *out;
|
||||
|
||||
if (irp->read.nbytes < sizeof(*out)) {
|
||||
dprintf("SRAM: Invalid ioctl response buffer size\n");
|
||||
|
||||
return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
|
||||
}
|
||||
DISK_GEOMETRY out;
|
||||
HRESULT hr;
|
||||
|
||||
dprintf("SRAM: Get geometry\n");
|
||||
|
||||
out = (DISK_GEOMETRY *) irp->read.bytes;
|
||||
out->Cylinders.QuadPart = 0x20000;
|
||||
out->MediaType = 0;
|
||||
out->TracksPerCylinder = 1;
|
||||
out->SectorsPerTrack = 1;
|
||||
out->BytesPerSector = 4;
|
||||
memset(&out, 0, sizeof(out));
|
||||
out.Cylinders.QuadPart = 0x20000;
|
||||
out.MediaType = 0;
|
||||
out.TracksPerCylinder = 1;
|
||||
out.SectorsPerTrack = 1;
|
||||
out.BytesPerSector = 4;
|
||||
|
||||
irp->read.pos = sizeof(*out);
|
||||
hr = iobuf_write(&irp->read, &out, sizeof(out));
|
||||
|
||||
return S_OK;
|
||||
if (FAILED(hr)) {
|
||||
dprintf("SRAM: Get geometry failed: %08x\n", (int) hr);
|
||||
}
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user