clang-format in src/scsi/

This commit is contained in:
Jasmine Iwanek
2022-09-18 17:17:15 -04:00
parent 99893d1175
commit 97a7459fd4
11 changed files with 10144 additions and 10439 deletions

View File

@@ -42,37 +42,33 @@
#include <86box/scsi_pcscsi.h>
#include <86box/scsi_spock.h>
#ifdef WALTJE
# include "scsi_wd33c93.h"
# include "scsi_wd33c93.h"
#endif
int scsi_card_current[SCSI_BUS_MAX] = { 0, 0 };
int scsi_card_current[SCSI_BUS_MAX] = { 0, 0 };
static uint8_t next_scsi_bus = 0;
static uint8_t next_scsi_bus = 0;
static const device_t scsi_none_device = {
.name = "None",
.name = "None",
.internal_name = "none",
.flags = 0,
.local = 0,
.init = NULL,
.close = NULL,
.reset = NULL,
.flags = 0,
.local = 0,
.init = NULL,
.close = NULL,
.reset = NULL,
{ .available = NULL },
.speed_changed = NULL,
.force_redraw = NULL,
.config = NULL
.force_redraw = NULL,
.config = NULL
};
typedef const struct {
const device_t *device;
const device_t *device;
} SCSI_CARD;
static SCSI_CARD scsi_cards[] = {
// clang-format off
// clang-format off
{ &scsi_none_device, },
{ &aha154xa_device, },
{ &aha154xb_device, },
@@ -107,79 +103,72 @@ static SCSI_CARD scsi_cards[] = {
{ &buslogic_445s_device, },
{ &buslogic_445c_device, },
{ NULL, },
// clang-format on
// clang-format on
};
void
scsi_reset(void)
{
next_scsi_bus = 0;
}
uint8_t
scsi_get_bus(void)
{
uint8_t ret = next_scsi_bus;
if (next_scsi_bus >= SCSI_BUS_MAX)
return 0xff;
return 0xff;
next_scsi_bus++;
return ret;
}
int
scsi_card_available(int card)
{
if (scsi_cards[card].device)
return(device_available(scsi_cards[card].device));
return (device_available(scsi_cards[card].device));
return(1);
return (1);
}
const device_t *
scsi_card_getdevice(int card)
{
return(scsi_cards[card].device);
return (scsi_cards[card].device);
}
int
scsi_card_has_config(int card)
{
if (! scsi_cards[card].device) return(0);
if (!scsi_cards[card].device)
return (0);
return(device_has_config(scsi_cards[card].device) ? 1 : 0);
return (device_has_config(scsi_cards[card].device) ? 1 : 0);
}
char *
scsi_card_get_internal_name(int card)
{
return device_get_internal_name(scsi_cards[card].device);
}
int
scsi_card_get_from_internal_name(char *s)
{
int c = 0;
while (scsi_cards[c].device != NULL) {
if (!strcmp((char *) scsi_cards[c].device->internal_name, s))
return(c);
c++;
if (!strcmp((char *) scsi_cards[c].device->internal_name, s))
return (c);
c++;
}
return(0);
return (0);
}
void
scsi_card_init(void)
{
@@ -188,16 +177,16 @@ scsi_card_init(void)
/* On-board SCSI controllers get the first bus, so if one is present,
increase our instance number here. */
if (machine_has_flags(machine, MACHINE_SCSI))
max--;
max--;
/* Do not initialize any controllers if we have do not have any SCSI
/* Do not initialize any controllers if we have do not have any SCSI
bus left. */
if (max > 0) {
for (i = 0; i < max; i++) {
if (!scsi_cards[scsi_card_current[i]].device)
continue;
for (i = 0; i < max; i++) {
if (!scsi_cards[scsi_card_current[i]].device)
continue;
device_add_inst(scsi_cards[scsi_card_current[i]].device, i + 1);
}
device_add_inst(scsi_cards[scsi_card_current[i]].device, i + 1);
}
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -26,85 +26,76 @@
#include <86box/scsi.h>
#include <86box/scsi_device.h>
scsi_device_t scsi_devices[SCSI_BUS_MAX][SCSI_ID_MAX];
scsi_device_t scsi_devices[SCSI_BUS_MAX][SCSI_ID_MAX];
uint8_t scsi_null_device_sense[18] = { 0x70,0,SENSE_ILLEGAL_REQUEST,0,0,0,0,0,0,0,0,0,ASC_INV_LUN,0,0,0,0,0 };
uint8_t scsi_null_device_sense[18] = { 0x70, 0, SENSE_ILLEGAL_REQUEST, 0, 0, 0, 0, 0, 0, 0, 0, 0, ASC_INV_LUN, 0, 0, 0, 0, 0 };
static uint8_t
scsi_device_target_command(scsi_device_t *dev, uint8_t *cdb)
{
if (dev->command) {
dev->command(dev->sc, cdb);
dev->command(dev->sc, cdb);
if (dev->sc->status & ERR_STAT)
return SCSI_STATUS_CHECK_CONDITION;
else
return SCSI_STATUS_OK;
if (dev->sc->status & ERR_STAT)
return SCSI_STATUS_CHECK_CONDITION;
else
return SCSI_STATUS_OK;
} else
return SCSI_STATUS_CHECK_CONDITION;
return SCSI_STATUS_CHECK_CONDITION;
}
double
scsi_device_get_callback(scsi_device_t *dev)
{
if (dev->sc)
return dev->sc->callback;
return dev->sc->callback;
else
return -1.0;
return -1.0;
}
uint8_t *
scsi_device_sense(scsi_device_t *dev)
{
if (dev->sc)
return dev->sc->sense;
return dev->sc->sense;
else
return scsi_null_device_sense;
return scsi_null_device_sense;
}
void
scsi_device_request_sense(scsi_device_t *dev, uint8_t *buffer, uint8_t alloc_length)
{
if (dev->request_sense)
dev->request_sense(dev->sc, buffer, alloc_length);
dev->request_sense(dev->sc, buffer, alloc_length);
else
memcpy(buffer, scsi_null_device_sense, alloc_length);
memcpy(buffer, scsi_null_device_sense, alloc_length);
}
void
scsi_device_reset(scsi_device_t *dev)
{
if (dev->reset)
dev->reset(dev->sc);
dev->reset(dev->sc);
}
int
scsi_device_present(scsi_device_t *dev)
{
if (dev->type == SCSI_NONE)
return 0;
return 0;
else
return 1;
return 1;
}
int
scsi_device_valid(scsi_device_t *dev)
{
if (dev->sc)
return 1;
return 1;
else
return 0;
return 0;
}
int
scsi_device_cdb_length(scsi_device_t *dev)
{
@@ -112,95 +103,89 @@ scsi_device_cdb_length(scsi_device_t *dev)
return 12;
}
void
scsi_device_command_phase0(scsi_device_t *dev, uint8_t *cdb)
{
if (!dev->sc) {
dev->phase = SCSI_PHASE_STATUS;
dev->status = SCSI_STATUS_CHECK_CONDITION;
return;
dev->phase = SCSI_PHASE_STATUS;
dev->status = SCSI_STATUS_CHECK_CONDITION;
return;
}
/* Finally, execute the SCSI command immediately and get the transfer length. */
dev->phase = SCSI_PHASE_COMMAND;
dev->phase = SCSI_PHASE_COMMAND;
dev->status = scsi_device_target_command(dev, cdb);
}
void
scsi_device_command_stop(scsi_device_t *dev)
{
if (dev->command_stop) {
dev->command_stop(dev->sc);
dev->status = SCSI_STATUS_OK;
dev->command_stop(dev->sc);
dev->status = SCSI_STATUS_OK;
}
}
void
scsi_device_command_phase1(scsi_device_t *dev)
{
if (!dev->sc)
return;
return;
/* Call the second phase. */
if (dev->phase == SCSI_PHASE_DATA_OUT) {
if (dev->phase_data_out)
dev->phase_data_out(dev->sc);
if (dev->phase_data_out)
dev->phase_data_out(dev->sc);
} else
scsi_device_command_stop(dev);
scsi_device_command_stop(dev);
if (dev->sc->status & ERR_STAT)
dev->status = SCSI_STATUS_CHECK_CONDITION;
dev->status = SCSI_STATUS_CHECK_CONDITION;
else
dev->status = SCSI_STATUS_OK;
dev->status = SCSI_STATUS_OK;
}
/* When LUN is FF, there has been no IDENTIFY message, otherwise
there has been one. */
void
scsi_device_identify(scsi_device_t *dev, uint8_t lun)
{
if ((dev == NULL) || (dev->type == SCSI_NONE) || !dev->sc)
return;
return;
dev->sc->cur_lun = lun;
/* TODO: This should return a value, should IDENTIFY fail due to a
a LUN not supported by the target. */
a LUN not supported by the target. */
}
void
scsi_device_close_all(void)
{
int i, j;
int i, j;
scsi_device_t *dev;
for (i = 0; i < SCSI_BUS_MAX; i++) {
for (j = 0; j < SCSI_ID_MAX; j++) {
dev = &(scsi_devices[i][j]);
if (dev->command_stop && dev->sc)
dev->command_stop(dev->sc);
}
for (j = 0; j < SCSI_ID_MAX; j++) {
dev = &(scsi_devices[i][j]);
if (dev->command_stop && dev->sc)
dev->command_stop(dev->sc);
}
}
}
void
scsi_device_init(void)
{
int i, j;
int i, j;
scsi_device_t *dev;
for (i = 0; i < SCSI_BUS_MAX; i++) {
for (j = 0; j < SCSI_ID_MAX; j++) {
dev = &(scsi_devices[i][j]);
for (j = 0; j < SCSI_ID_MAX; j++) {
dev = &(scsi_devices[i][j]);
memset(dev, 0, sizeof(scsi_device_t));
dev->type = SCSI_NONE;
}
memset(dev, 0, sizeof(scsi_device_t));
dev->type = SCSI_NONE;
}
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff