Skip to content

Commit

Permalink
This is the work by BigGun (Gunnar von Boehn) und Christoph Hoehne (c…
Browse files Browse the repository at this point in the history
…eaich). This is a refactoring of the ATA/IDE code to weed out all of the slowness and bugs.

This is a vastly improved driver.

Note: to simplify the development process, support for CDROM/FastIDE and other adaptors has been removed.  Once this driver has proven it is stable, this
can be re-introduced.
  • Loading branch information
ronybeck committed Apr 11, 2021
1 parent bf3e50c commit e2d9415
Show file tree
Hide file tree
Showing 17 changed files with 828 additions and 1,489 deletions.
400 changes: 200 additions & 200 deletions arch/m68k-amiga/devs/ata/ata_amiga.c

Large diffs are not rendered by default.

26 changes: 0 additions & 26 deletions arch/m68k-amiga/devs/ata/waitnano.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,35 +19,9 @@ BOOL ata_Calibrate(struct IORequest* tmr, struct ataBase *base)

static void busywait(UWORD cnt)
{
asm volatile (
"move.w %0,%%d0\n"
"lea 0xbfe001,%%a0\n"
"0:\n"
"tst.b (%%a0)\n"
"tst.b (%%a0)\n"
"tst.b (%%a0)\n"
"tst.b (%%a0)\n"
"dbf %%d0,0b\n"
: : "m" (cnt) : "d0", "a0");
}

/* Single CIA access = 1 E-clock */
void ata_WaitNano(ULONG ns, struct ataBase *base)
{
/*
We really need to review this code. The WaitNano is supposed to wait given number of *nanoseconds*
Each CIA access takes one E-clock which equals 1400 nanoseconds. It means, on Amiga hardware it is
hardly impossible to do a delay shorter than 1.4 microseconds.
For how we will shift the nanosecond count by 10 bits, effectively dividing it by 1024.
*/
ns /= 1024;
if (!(SysBase->AttnFlags & AFF_68020))
ns /= 2;
while (ns >= 65536 * 4) {
busywait(65535);
ns -= 65536 * 4;
}
if (ns >= 4)
busywait(ns / 4);
}
21 changes: 0 additions & 21 deletions arch/m68k-amiga/hidd/gayle_ata/ata_gayle.conf
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,3 @@ GetPIOInterface
Shutdown
##end methodlist

##begin class
##begin config
basename FASTATA
type hidd
superclass CLID_Hidd_ATABus
classptr_field FastATABusClass
classdatatype struct ATA_BusData
##end config

##begin methodlist
.interface Root
New
Dispose
Get
Set
.interface Hidd_ATABus
GetPIOInterface
SetXferMode
Shutdown
##end methodlist
##end class
164 changes: 0 additions & 164 deletions arch/m68k-amiga/hidd/gayle_ata/fastata_busclass.c

This file was deleted.

33 changes: 2 additions & 31 deletions arch/m68k-amiga/hidd/gayle_ata/gayleata_busclass.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,41 +52,13 @@ AROS_INTH1(IDE_Handler_A1200, struct ATA_BusData *, bus)
AROS_INTFUNC_EXIT
}

AROS_INTH1(IDE_Handler_A4000, struct ATA_BusData *, bus)
{
AROS_INTFUNC_INIT

/* A4000 interrupt clears when register is read */
volatile UWORD *irqbase = (UWORD*)bus->gayleirqbase;
UWORD irqmask = *irqbase;
if (irqmask & (GAYLE_IRQ_IDE << 8)) {
volatile UBYTE *port;
UBYTE status;

port = bus->gaylebase;
status = port[ata_Status * 4];
if (status & ATAF_BUSY) {
bug("[ATA:Gayle] ATA interrupt but BUSY flag set!?\n");
return FALSE;
}
bus->ata_HandleIRQ(status, bus->irqData);
return TRUE;
}
return FALSE;

AROS_INTFUNC_EXIT
}

static BOOL ata_CreateGayleInterrupt(struct ATA_BusData *bus, UBYTE num)
{
struct Interrupt *irq = &bus->ideint;

if (bus->bus->a4000) {
irq->is_Code = (APTR)IDE_Handler_A4000;
} else {
bus->gayleintbase = (UBYTE*)GAYLE_INT_1200;
irq->is_Code = (APTR)IDE_Handler_A1200;
}

irq->is_Node.ln_Pri = 20;
irq->is_Node.ln_Type = NT_INTERRUPT;
Expand Down Expand Up @@ -140,7 +112,7 @@ OOP_Object *GAYLEATA__Root__New(OOP_Class *cl, OOP_Object *o, struct pRoot_New *
data->bus->atapb_Node.ln_Succ = (struct Node *)-1;
data->gaylebase = data->bus->port;
data->gayleirqbase = data->bus->gayleirqbase;
ata_CreateGayleInterrupt(data, 0);
//ata_CreateGayleInterrupt(data, 0);

//mDispose = msg->mID - moRoot_New + moRoot_Dispose;
//OOP_DoSuperMethod(cl, o, &mDispose);
Expand Down Expand Up @@ -234,8 +206,7 @@ APTR GAYLEATA__Hidd_ATABus__GetPIOInterface(OOP_Class *cl, OOP_Object *o, OOP_Ms
* This shadow bank is for 16/32-bit data transfers, while the
* other one is much slower due to 8-bit transfers, only.
*/
if (!data->bus->a4000)
pio->dataport = (UBYTE*)(((ULONG)pio->port) + 0x2000);
pio->dataport = (UBYTE*)(((ULONG)pio->port) + 0x2000);
}

return pio;
Expand Down
19 changes: 8 additions & 11 deletions arch/m68k-amiga/hidd/gayle_ata/interface_pio.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ static void ata_out(struct pio_data *data, UBYTE val, UWORD offset)
{
volatile UBYTE *addr;
addr = data->port;
DIO(bug("%p REG %d <- %02X\n", addr, offset, val));
addr[offset * 4] = val;
}

Expand All @@ -27,7 +26,6 @@ static UBYTE ata_in(struct pio_data *data, UWORD offset)

addr = data->port;
v = addr[offset * 4];
DIO(bug("%p REG %d -> %02X\n", addr, offset, v));
return v;
}

Expand All @@ -36,11 +34,10 @@ static void ata_outsl(struct pio_data *data, APTR address, ULONG count)
{
volatile ULONG *addr = (ULONG*)data->dataport;

DDATA(bug("LOUT %p %p %d\n", addr, address, count));

asm volatile(
"1: move.l (%[address])+,(%[port]) \n"
" move.l (%[address])+,(%[port]) \n"
"1: move.l (%[address])+,(0xDA2000) \n"
" move.l (%[address])+,(0xDA2000) \n"
" subq.l #1,%[count] \n"
" bnes 1b \n"
::[count]"d"(count >> 3),[address]"a"(address),[port]"a"(addr));
Expand All @@ -51,14 +48,14 @@ static void ata_insl(struct pio_data *data, APTR address, ULONG count)
{
volatile ULONG *addr = (ULONG*)data->dataport;

DDATA(bug("LIN %p %p %d\n", addr, address, count));

asm volatile(
"1: move.l (%[port]),(%[address])+ \n"
" move.l (%[port]),(%[address])+ \n"
" subq.l #1,%[count] \n"
" bnes 1b \n"
::[count]"d"(count >> 3),[address]"a"(address),[port]"a"(addr));
" bra 2f \n"
"1: \n"
" move16 0x00da6000,(%[address])+ \n"
" move16 0x00da6000,(%[address])+ \n"
"2: dbra %[count],1b \n"
::[count]"d"(count >> 5),[address]"a"(address));
}

const APTR bus_FuncTable[] =
Expand Down
31 changes: 0 additions & 31 deletions arch/m68k-amiga/hidd/gayle_ata/interface_pio.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,37 +17,6 @@
#define GAYLE_IRQ_IDE 0x80
#define GAYLE_INT_IDE 0x80

/*
* Elbox FastATA Gayle Extensions
*/
#define GAYLE_BASE_FASTATA (GAYLE_BASE_1200 + 0x2000)
#define GAYLE_BASE_FASTATA_PIO0 (0x0) /* the different PIO modes are handled at different .. */
#define GAYLE_BASE_FASTATA_PIO3 (0x10000) /* .. register offsets - see below for register def's */
#define GAYLE_BASE_FASTATA_PIO4 (0x14000)
#define GAYLE_BASE_FASTATA_PIO5 (0x12000)
#define GAYLE_IRQ_FASTATA (GAYLE_IRQ_1200)

#define GAYLE_FASTATA_PORTSIZE 0x1000

#define GAYLE_FASTATA_PIO_DATA 0x0
#define GAYLE_FASTATA_PIO_ERR 0x4
#define GAYLE_FASTATA_PIO_NSECT 0x8
#define GAYLE_FASTATA_PIO_SECT 0xC
#define GAYLE_FASTATA_PIO_LOCYL 0x10
#define GAYLE_FASTATA_PIO_HICYL 0x14
#define GAYLE_FASTATA_PIO_SEL 0x18
#define GAYLE_FASTATA_PIO_STAT 0x1C

#define GAYLE_FASTATA_LONGDATA 0x0
#define GAYLE_FASTATA_ERR 0x200
#define GAYLE_FASTATA_DATA 0x208
#define GAYLE_FASTATA_NSECT 0x400
#define GAYLE_FASTATA_SECT 0x600
#define GAYLE_FASTATA_LOCYL 0x800
#define GAYLE_FASTATA_HICYL 0xA00
#define GAYLE_FASTATA_SEL 0xC00
#define GAYLE_FASTATA_STAT 0xE00

struct pio_data
{
UBYTE *dataport;
Expand Down
2 changes: 1 addition & 1 deletion arch/m68k-amiga/hidd/gayle_ata/mmakefile.src
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

include $(SRCDIR)/config/aros.cfg

FILES := class_init probe gayleata_busclass fastata_busclass interface_pio
FILES := class_init probe gayleata_busclass interface_pio

USER_CPPFLAGS := -D__OOP_NOMETHODBASES__ -D__OOP_NOATTRBASES__
#USER_CPPFLAGS += -DDEBUG
Expand Down

0 comments on commit e2d9415

Please sign in to comment.