Changed several char arrays all around the code to const char pointers, debloats the executable file from 8.7 MB to 5.6 MB;
Replaced the Cirrus Logic code with the latest code from TheCollector1995 - the CL-GD 5428 is now fully working, as is the CL-GD 5429; Minor clean-up in the AHA/BusLogic BIOS commands code; Slightly rewritten mem_readb_phys_dma() and mem_writeb_phys_dma().
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Handling of the SCSI controllers.
|
||||
*
|
||||
* Version: @(#)scsi.c 1.0.14 2018/01/21
|
||||
* Version: @(#)scsi.c 1.0.15 2018/02/18
|
||||
*
|
||||
* Authors: Miran Grca, <mgrca8@gmail.com>
|
||||
* Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
@@ -57,8 +57,8 @@ mutex_t *scsiMutex;
|
||||
|
||||
|
||||
typedef struct {
|
||||
char name[64];
|
||||
char internal_name[32];
|
||||
const char *name;
|
||||
const char *internal_name;
|
||||
device_t *device;
|
||||
void (*reset)(void *p);
|
||||
} SCSI_CARD;
|
||||
@@ -98,7 +98,7 @@ int scsi_card_available(int card)
|
||||
|
||||
char *scsi_card_getname(int card)
|
||||
{
|
||||
return(scsi_cards[card].name);
|
||||
return((char *) scsi_cards[card].name);
|
||||
}
|
||||
|
||||
|
||||
@@ -118,7 +118,7 @@ int scsi_card_has_config(int card)
|
||||
|
||||
char *scsi_card_get_internal_name(int card)
|
||||
{
|
||||
return(scsi_cards[card].internal_name);
|
||||
return((char *) scsi_cards[card].internal_name);
|
||||
}
|
||||
|
||||
|
||||
@@ -126,8 +126,8 @@ int scsi_card_get_from_internal_name(char *s)
|
||||
{
|
||||
int c = 0;
|
||||
|
||||
while (strlen(scsi_cards[c].internal_name)) {
|
||||
if (!strcmp(scsi_cards[c].internal_name, s))
|
||||
while (strlen((char *) scsi_cards[c].internal_name)) {
|
||||
if (!strcmp((char *) scsi_cards[c].internal_name, s))
|
||||
return(c);
|
||||
c++;
|
||||
}
|
||||
|
||||
@@ -10,12 +10,12 @@
|
||||
* made by Adaptec, Inc. These controllers were designed for
|
||||
* the ISA bus.
|
||||
*
|
||||
* Version: @(#)scsi_aha154x.c 1.0.36 2017/12/09
|
||||
* Version: @(#)scsi_aha154x.c 1.0.37 2018/02/17
|
||||
*
|
||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Original Buslogic version by SA1988 and Miran Grca.
|
||||
*
|
||||
* Copyright 2017 Fred N. van Kempen.
|
||||
* Copyright 2017,2018 Fred N. van Kempen.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
@@ -36,6 +36,7 @@
|
||||
#include "../timer.h"
|
||||
#include "../device.h"
|
||||
#include "../plat.h"
|
||||
#include "../cpu/cpu.h"
|
||||
#include "scsi.h"
|
||||
#include "scsi_aha154x.h"
|
||||
#include "scsi_x54x.h"
|
||||
@@ -91,6 +92,7 @@ aha_log(const char *fmt, ...)
|
||||
va_list ap;
|
||||
|
||||
if (aha_do_log) {
|
||||
pclog("In %s mode: ",(msw&1)?((eflags&VM_FLAG)?"V86":"protected"):"real");
|
||||
va_start(ap, fmt);
|
||||
pclog_ex(fmt, ap);
|
||||
va_end(ap);
|
||||
@@ -782,7 +784,7 @@ aha_init(device_t *info)
|
||||
switch(dev->Base) {
|
||||
case 0x0330:
|
||||
dev->bios_path =
|
||||
L"roms/scsi/adaptec/aha1540b320_330.bin";
|
||||
L"roms/scsi/adaptec/aha1540b310.bin";
|
||||
break;
|
||||
|
||||
case 0x0334:
|
||||
@@ -790,9 +792,12 @@ aha_init(device_t *info)
|
||||
L"roms/scsi/adaptec/aha1540b320_334.bin";
|
||||
break;
|
||||
}
|
||||
dev->fw_rev = "A001";
|
||||
dev->fw_rev = "A005"; /* The 3.2 microcode says A012. */
|
||||
/* This is configurable from the configuration for the 154xB, the rest of the controllers read it from the EEPROM. */
|
||||
dev->HostID = device_get_config_int("hostid");
|
||||
dev->int_geom_writable = 2;
|
||||
dev->rom_shram = 0x3F80; /* shadow RAM address base */
|
||||
dev->rom_shramsz = 128; /* size of shadow RAM */
|
||||
break;
|
||||
|
||||
case AHA_154xC:
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* The generic SCSI device command handler.
|
||||
*
|
||||
* Version: @(#)scsi_device.c 1.0.11 2018/01/21
|
||||
* Version: @(#)scsi_device.c 1.0.12 2018/02/17
|
||||
*
|
||||
* Authors: Miran Grca, <mgrca8@gmail.com>
|
||||
* Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
@@ -284,20 +284,6 @@ int scsi_device_cdb_length(uint8_t scsi_id, uint8_t scsi_lun)
|
||||
}
|
||||
|
||||
|
||||
int scsi_device_block_shift(uint8_t scsi_id, uint8_t scsi_lun)
|
||||
{
|
||||
uint8_t lun_type = SCSIDevices[scsi_id][scsi_lun].LunType;
|
||||
|
||||
switch (lun_type)
|
||||
{
|
||||
case SCSI_CDROM:
|
||||
return 11; /* 2048 bytes per block */
|
||||
default:
|
||||
return 9; /* 512 bytes per block */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void scsi_device_command_phase0(uint8_t scsi_id, uint8_t scsi_lun, int cdb_len, uint8_t *cdb)
|
||||
{
|
||||
uint8_t lun_type = SCSIDevices[scsi_id][scsi_lun].LunType;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Definitions for the generic SCSI device command handler.
|
||||
*
|
||||
* Version: @(#)scsi_device.h 1.0.4 2017/10/10
|
||||
* Version: @(#)scsi_device.h 1.0.5 2018/02/17
|
||||
*
|
||||
* Authors: Miran Grca, <mgrca8@gmail.com>
|
||||
* Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
@@ -44,7 +44,6 @@ extern int scsi_device_read_capacity(uint8_t id, uint8_t lun,
|
||||
extern int scsi_device_present(uint8_t id, uint8_t lun);
|
||||
extern int scsi_device_valid(uint8_t id, uint8_t lun);
|
||||
extern int scsi_device_cdb_length(uint8_t id, uint8_t lun);
|
||||
extern int scsi_device_block_shift(uint8_t id, uint8_t lun);
|
||||
extern void scsi_device_command(uint8_t id, uint8_t lun, int cdb_len,
|
||||
uint8_t *cdb);
|
||||
extern void scsi_device_command_phase0(uint8_t scsi_id, uint8_t scsi_lun,
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
* series of SCSI Host Adapters made by Mylex.
|
||||
* These controllers were designed for various buses.
|
||||
*
|
||||
* Version: @(#)scsi_x54x.c 1.0.12 2018/02/15
|
||||
* Version: @(#)scsi_x54x.c 1.0.13 2018/02/17
|
||||
*
|
||||
* Authors: TheCollector1995, <mariogplayer@gmail.com>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
@@ -39,6 +39,7 @@
|
||||
#include "../device.h"
|
||||
#include "../timer.h"
|
||||
#include "../plat.h"
|
||||
#include "../cpu/cpu.h"
|
||||
#include "scsi.h"
|
||||
#include "scsi_device.h"
|
||||
#include "scsi_aha154x.h"
|
||||
@@ -81,6 +82,7 @@ x54x_log(const char *fmt, ...)
|
||||
va_list ap;
|
||||
|
||||
if (x54x_do_log) {
|
||||
pclog("In %s mode: ",(msw&1)?((eflags&VM_FLAG)?"V86":"protected"):"real");
|
||||
va_start(ap, fmt);
|
||||
pclog_ex(fmt, ap);
|
||||
va_end(ap);
|
||||
@@ -303,7 +305,6 @@ x54x_bios_command(x54x_t *x54x, uint8_t max_id, BIOSCMD *cmd, int8_t islba)
|
||||
uint32_t dma_address;
|
||||
uint32_t lba;
|
||||
int sector_len = cmd->secount;
|
||||
int block_shift;
|
||||
uint8_t ret;
|
||||
|
||||
if (islba)
|
||||
@@ -345,8 +346,6 @@ x54x_bios_command(x54x_t *x54x, uint8_t max_id, BIOSCMD *cmd, int8_t islba)
|
||||
dev->CmdBuffer = NULL;
|
||||
}
|
||||
|
||||
block_shift = scsi_device_block_shift(cmd->id, cmd->lun);
|
||||
|
||||
switch(cmd->command) {
|
||||
case 0x00: /* Reset Disk System, in practice it's a nop */
|
||||
return(0);
|
||||
@@ -380,9 +379,7 @@ x54x_bios_command(x54x_t *x54x, uint8_t max_id, BIOSCMD *cmd, int8_t islba)
|
||||
case 0x02: /* Read Desired Sectors to Memory */
|
||||
target_check(cmd->id, cmd->lun);
|
||||
|
||||
dev->BufferLength = sector_len << block_shift;
|
||||
dev->CmdBuffer = (uint8_t *)malloc(dev->BufferLength);
|
||||
memset(dev->CmdBuffer, 0x00, dev->BufferLength);
|
||||
dev->BufferLength = -1;
|
||||
|
||||
cdb[0] = GPCMD_READ_10;
|
||||
cdb[1] = (cmd->lun & 7) << 5;
|
||||
@@ -390,8 +387,8 @@ x54x_bios_command(x54x_t *x54x, uint8_t max_id, BIOSCMD *cmd, int8_t islba)
|
||||
cdb[3] = (lba >> 16) & 0xff;
|
||||
cdb[4] = (lba >> 8) & 0xff;
|
||||
cdb[5] = lba & 0xff;
|
||||
cdb[7] = (sector_len >> 8) & 0xff;
|
||||
cdb[8] = sector_len & 0xff;
|
||||
cdb[7] = 0;
|
||||
cdb[8] = sector_len;
|
||||
#if 0
|
||||
x54x_log("BIOS CMD(READ, %08lx, %d)\n", lba, cmd->secount);
|
||||
#endif
|
||||
@@ -401,6 +398,8 @@ x54x_bios_command(x54x_t *x54x, uint8_t max_id, BIOSCMD *cmd, int8_t islba)
|
||||
if (dev->Phase == SCSI_PHASE_STATUS)
|
||||
goto skip_read_phase1;
|
||||
|
||||
dev->CmdBuffer = (uint8_t *)malloc(dev->BufferLength);
|
||||
|
||||
scsi_device_command_phase1(cmd->id, cmd->lun);
|
||||
if (sector_len > 0) {
|
||||
x54x_log("BIOS DMA: Reading %i bytes at %08X\n",
|
||||
@@ -420,9 +419,7 @@ skip_read_phase1:
|
||||
case 0x03: /* Write Desired Sectors from Memory */
|
||||
target_check(cmd->id, cmd->lun);
|
||||
|
||||
dev->BufferLength = sector_len << block_shift;
|
||||
dev->CmdBuffer = (uint8_t *)malloc(dev->BufferLength);
|
||||
memset(dev->CmdBuffer, 0x00, dev->BufferLength);
|
||||
dev->BufferLength = -1;
|
||||
|
||||
cdb[0] = GPCMD_WRITE_10;
|
||||
cdb[1] = (cmd->lun & 7) << 5;
|
||||
@@ -430,8 +427,8 @@ skip_read_phase1:
|
||||
cdb[3] = (lba >> 16) & 0xff;
|
||||
cdb[4] = (lba >> 8) & 0xff;
|
||||
cdb[5] = lba & 0xff;
|
||||
cdb[7] = (sector_len >> 8) & 0xff;
|
||||
cdb[8] = sector_len & 0xff;
|
||||
cdb[7] = 0;
|
||||
cdb[8] = sector_len;
|
||||
#if 0
|
||||
x54x_log("BIOS CMD(WRITE, %08lx, %d)\n", lba, cmd->secount);
|
||||
#endif
|
||||
@@ -441,6 +438,8 @@ skip_read_phase1:
|
||||
if (dev->Phase == SCSI_PHASE_STATUS)
|
||||
goto skip_write_phase1;
|
||||
|
||||
dev->CmdBuffer = (uint8_t *)malloc(dev->BufferLength);
|
||||
|
||||
if (sector_len > 0) {
|
||||
x54x_log("BIOS DMA: Reading %i bytes at %08X\n",
|
||||
dev->BufferLength, dma_address);
|
||||
@@ -467,8 +466,8 @@ skip_write_phase1:
|
||||
cdb[3] = (lba >> 16) & 0xff;
|
||||
cdb[4] = (lba >> 8) & 0xff;
|
||||
cdb[5] = lba & 0xff;
|
||||
cdb[7] = (sector_len >> 8) & 0xff;
|
||||
cdb[8] = sector_len & 0xff;
|
||||
cdb[7] = 0;
|
||||
cdb[8] = sector_len;
|
||||
|
||||
scsi_device_command_phase0(cmd->id, cmd->lun, 12, cdb);
|
||||
|
||||
@@ -503,7 +502,7 @@ skip_write_phase1:
|
||||
|
||||
x54x_log("BIOS DMA: Reading 6 bytes at %08X\n", dma_address);
|
||||
DMAPageWrite(dma_address,
|
||||
dev->CmdBuffer, dev->BufferLength);
|
||||
dev->CmdBuffer, 4 /* dev->BufferLength */);
|
||||
|
||||
if (dev->CmdBuffer != NULL) {
|
||||
free(dev->CmdBuffer);
|
||||
@@ -569,7 +568,7 @@ skip_write_phase1:
|
||||
|
||||
x54x_log("BIOS DMA: Reading 6 bytes at %08X\n", dma_address);
|
||||
DMAPageWrite(dma_address,
|
||||
dev->CmdBuffer, dev->BufferLength);
|
||||
dev->CmdBuffer, 4 /* dev->BufferLength */);
|
||||
|
||||
if (dev->CmdBuffer != NULL) {
|
||||
free(dev->CmdBuffer);
|
||||
@@ -1290,6 +1289,7 @@ x54x_cmd_thread(void *priv)
|
||||
if ((dev->Status & STAT_INIT) || (!dev->MailboxInit && !dev->BIOSMailboxInit) || (!dev->MailboxReq && !dev->BIOSMailboxReq)) {
|
||||
/* If we did not get anything, wait a while. */
|
||||
thread_wait_event((event_t *) wait_evt, 10);
|
||||
thread_reset_event((event_t *) wait_evt);
|
||||
|
||||
scsi_mutex_wait(0);
|
||||
continue;
|
||||
@@ -1443,11 +1443,10 @@ static void
|
||||
x54x_reset(x54x_t *dev)
|
||||
{
|
||||
clear_irq(dev);
|
||||
if (dev->int_geom_writable)
|
||||
if (dev->int_geom_writable == 1)
|
||||
dev->Geometry = 0x80;
|
||||
else
|
||||
dev->Geometry = 0x00;
|
||||
dev->Geometry = 0x00;
|
||||
dev->Command = 0xFF;
|
||||
dev->CmdParam = 0;
|
||||
dev->CmdParamLeft = 0;
|
||||
@@ -1800,7 +1799,7 @@ x54x_out(uint16_t port, uint8_t val, void *priv)
|
||||
break;
|
||||
|
||||
case 3:
|
||||
if (dev->int_geom_writable)
|
||||
if (dev->int_geom_writable == 1)
|
||||
dev->Geometry = val;
|
||||
break;
|
||||
}
|
||||
@@ -1964,6 +1963,7 @@ x54x_init(device_t *info)
|
||||
|
||||
x54x_thread_start(dev);
|
||||
thread_wait_event((event_t *) thread_started, -1);
|
||||
thread_reset_event((event_t *) thread_started);
|
||||
|
||||
return(dev);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user