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_pcscsi.h>
#include <86box/scsi_spock.h> #include <86box/scsi_spock.h>
#ifdef WALTJE #ifdef WALTJE
# include "scsi_wd33c93.h" # include "scsi_wd33c93.h"
#endif #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 = { static const device_t scsi_none_device = {
.name = "None", .name = "None",
.internal_name = "none", .internal_name = "none",
.flags = 0, .flags = 0,
.local = 0, .local = 0,
.init = NULL, .init = NULL,
.close = NULL, .close = NULL,
.reset = NULL, .reset = NULL,
{ .available = NULL }, { .available = NULL },
.speed_changed = NULL, .speed_changed = NULL,
.force_redraw = NULL, .force_redraw = NULL,
.config = NULL .config = NULL
}; };
typedef const struct { typedef const struct {
const device_t *device; const device_t *device;
} SCSI_CARD; } SCSI_CARD;
static SCSI_CARD scsi_cards[] = { static SCSI_CARD scsi_cards[] = {
// clang-format off // clang-format off
{ &scsi_none_device, }, { &scsi_none_device, },
{ &aha154xa_device, }, { &aha154xa_device, },
{ &aha154xb_device, }, { &aha154xb_device, },
@@ -107,79 +103,72 @@ static SCSI_CARD scsi_cards[] = {
{ &buslogic_445s_device, }, { &buslogic_445s_device, },
{ &buslogic_445c_device, }, { &buslogic_445c_device, },
{ NULL, }, { NULL, },
// clang-format on // clang-format on
}; };
void void
scsi_reset(void) scsi_reset(void)
{ {
next_scsi_bus = 0; next_scsi_bus = 0;
} }
uint8_t uint8_t
scsi_get_bus(void) scsi_get_bus(void)
{ {
uint8_t ret = next_scsi_bus; uint8_t ret = next_scsi_bus;
if (next_scsi_bus >= SCSI_BUS_MAX) if (next_scsi_bus >= SCSI_BUS_MAX)
return 0xff; return 0xff;
next_scsi_bus++; next_scsi_bus++;
return ret; return ret;
} }
int int
scsi_card_available(int card) scsi_card_available(int card)
{ {
if (scsi_cards[card].device) 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 * const device_t *
scsi_card_getdevice(int card) scsi_card_getdevice(int card)
{ {
return(scsi_cards[card].device); return (scsi_cards[card].device);
} }
int int
scsi_card_has_config(int card) 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 * char *
scsi_card_get_internal_name(int card) scsi_card_get_internal_name(int card)
{ {
return device_get_internal_name(scsi_cards[card].device); return device_get_internal_name(scsi_cards[card].device);
} }
int int
scsi_card_get_from_internal_name(char *s) scsi_card_get_from_internal_name(char *s)
{ {
int c = 0; int c = 0;
while (scsi_cards[c].device != NULL) { while (scsi_cards[c].device != NULL) {
if (!strcmp((char *) scsi_cards[c].device->internal_name, s)) if (!strcmp((char *) scsi_cards[c].device->internal_name, s))
return(c); return (c);
c++; c++;
} }
return(0); return (0);
} }
void void
scsi_card_init(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, /* On-board SCSI controllers get the first bus, so if one is present,
increase our instance number here. */ increase our instance number here. */
if (machine_has_flags(machine, MACHINE_SCSI)) 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. */ bus left. */
if (max > 0) { if (max > 0) {
for (i = 0; i < max; i++) { for (i = 0; i < max; i++) {
if (!scsi_cards[scsi_card_current[i]].device) if (!scsi_cards[scsi_card_current[i]].device)
continue; 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.h>
#include <86box/scsi_device.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 static uint8_t
scsi_device_target_command(scsi_device_t *dev, uint8_t *cdb) scsi_device_target_command(scsi_device_t *dev, uint8_t *cdb)
{ {
if (dev->command) { if (dev->command) {
dev->command(dev->sc, cdb); dev->command(dev->sc, cdb);
if (dev->sc->status & ERR_STAT) if (dev->sc->status & ERR_STAT)
return SCSI_STATUS_CHECK_CONDITION; return SCSI_STATUS_CHECK_CONDITION;
else else
return SCSI_STATUS_OK; return SCSI_STATUS_OK;
} else } else
return SCSI_STATUS_CHECK_CONDITION; return SCSI_STATUS_CHECK_CONDITION;
} }
double double
scsi_device_get_callback(scsi_device_t *dev) scsi_device_get_callback(scsi_device_t *dev)
{ {
if (dev->sc) if (dev->sc)
return dev->sc->callback; return dev->sc->callback;
else else
return -1.0; return -1.0;
} }
uint8_t * uint8_t *
scsi_device_sense(scsi_device_t *dev) scsi_device_sense(scsi_device_t *dev)
{ {
if (dev->sc) if (dev->sc)
return dev->sc->sense; return dev->sc->sense;
else else
return scsi_null_device_sense; return scsi_null_device_sense;
} }
void void
scsi_device_request_sense(scsi_device_t *dev, uint8_t *buffer, uint8_t alloc_length) scsi_device_request_sense(scsi_device_t *dev, uint8_t *buffer, uint8_t alloc_length)
{ {
if (dev->request_sense) if (dev->request_sense)
dev->request_sense(dev->sc, buffer, alloc_length); dev->request_sense(dev->sc, buffer, alloc_length);
else else
memcpy(buffer, scsi_null_device_sense, alloc_length); memcpy(buffer, scsi_null_device_sense, alloc_length);
} }
void void
scsi_device_reset(scsi_device_t *dev) scsi_device_reset(scsi_device_t *dev)
{ {
if (dev->reset) if (dev->reset)
dev->reset(dev->sc); dev->reset(dev->sc);
} }
int int
scsi_device_present(scsi_device_t *dev) scsi_device_present(scsi_device_t *dev)
{ {
if (dev->type == SCSI_NONE) if (dev->type == SCSI_NONE)
return 0; return 0;
else else
return 1; return 1;
} }
int int
scsi_device_valid(scsi_device_t *dev) scsi_device_valid(scsi_device_t *dev)
{ {
if (dev->sc) if (dev->sc)
return 1; return 1;
else else
return 0; return 0;
} }
int int
scsi_device_cdb_length(scsi_device_t *dev) scsi_device_cdb_length(scsi_device_t *dev)
{ {
@@ -112,95 +103,89 @@ scsi_device_cdb_length(scsi_device_t *dev)
return 12; return 12;
} }
void void
scsi_device_command_phase0(scsi_device_t *dev, uint8_t *cdb) scsi_device_command_phase0(scsi_device_t *dev, uint8_t *cdb)
{ {
if (!dev->sc) { if (!dev->sc) {
dev->phase = SCSI_PHASE_STATUS; dev->phase = SCSI_PHASE_STATUS;
dev->status = SCSI_STATUS_CHECK_CONDITION; dev->status = SCSI_STATUS_CHECK_CONDITION;
return; return;
} }
/* Finally, execute the SCSI command immediately and get the transfer length. */ /* 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); dev->status = scsi_device_target_command(dev, cdb);
} }
void void
scsi_device_command_stop(scsi_device_t *dev) scsi_device_command_stop(scsi_device_t *dev)
{ {
if (dev->command_stop) { if (dev->command_stop) {
dev->command_stop(dev->sc); dev->command_stop(dev->sc);
dev->status = SCSI_STATUS_OK; dev->status = SCSI_STATUS_OK;
} }
} }
void void
scsi_device_command_phase1(scsi_device_t *dev) scsi_device_command_phase1(scsi_device_t *dev)
{ {
if (!dev->sc) if (!dev->sc)
return; return;
/* Call the second phase. */ /* Call the second phase. */
if (dev->phase == SCSI_PHASE_DATA_OUT) { if (dev->phase == SCSI_PHASE_DATA_OUT) {
if (dev->phase_data_out) if (dev->phase_data_out)
dev->phase_data_out(dev->sc); dev->phase_data_out(dev->sc);
} else } else
scsi_device_command_stop(dev); scsi_device_command_stop(dev);
if (dev->sc->status & ERR_STAT) if (dev->sc->status & ERR_STAT)
dev->status = SCSI_STATUS_CHECK_CONDITION; dev->status = SCSI_STATUS_CHECK_CONDITION;
else else
dev->status = SCSI_STATUS_OK; dev->status = SCSI_STATUS_OK;
} }
/* When LUN is FF, there has been no IDENTIFY message, otherwise /* When LUN is FF, there has been no IDENTIFY message, otherwise
there has been one. */ there has been one. */
void void
scsi_device_identify(scsi_device_t *dev, uint8_t lun) scsi_device_identify(scsi_device_t *dev, uint8_t lun)
{ {
if ((dev == NULL) || (dev->type == SCSI_NONE) || !dev->sc) if ((dev == NULL) || (dev->type == SCSI_NONE) || !dev->sc)
return; return;
dev->sc->cur_lun = lun; dev->sc->cur_lun = lun;
/* TODO: This should return a value, should IDENTIFY fail due to a /* 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 void
scsi_device_close_all(void) scsi_device_close_all(void)
{ {
int i, j; int i, j;
scsi_device_t *dev; scsi_device_t *dev;
for (i = 0; i < SCSI_BUS_MAX; i++) { for (i = 0; i < SCSI_BUS_MAX; i++) {
for (j = 0; j < SCSI_ID_MAX; j++) { for (j = 0; j < SCSI_ID_MAX; j++) {
dev = &(scsi_devices[i][j]); dev = &(scsi_devices[i][j]);
if (dev->command_stop && dev->sc) if (dev->command_stop && dev->sc)
dev->command_stop(dev->sc); dev->command_stop(dev->sc);
} }
} }
} }
void void
scsi_device_init(void) scsi_device_init(void)
{ {
int i, j; int i, j;
scsi_device_t *dev; scsi_device_t *dev;
for (i = 0; i < SCSI_BUS_MAX; i++) { for (i = 0; i < SCSI_BUS_MAX; i++) {
for (j = 0; j < SCSI_ID_MAX; j++) { for (j = 0; j < SCSI_ID_MAX; j++) {
dev = &(scsi_devices[i][j]); dev = &(scsi_devices[i][j]);
memset(dev, 0, sizeof(scsi_device_t)); memset(dev, 0, sizeof(scsi_device_t));
dev->type = SCSI_NONE; 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