mirror of
https://github.com/LIV2/lide.device.git
synced 2025-12-06 00:32:45 +00:00
ata: optimize read/write functions
Pass the src/dest pointers via registers rather than the stack
This commit is contained in:
parent
2c61c52e28
commit
4185bc5b8e
10
ata.c
10
ata.c
@ -248,7 +248,7 @@ static ULONG ata_bench(struct IDEUnit *unit, void *xfer_routine, void *buffer) {
|
||||
if (TimerBase->dd_Library.lib_Version < 36) return 0;
|
||||
|
||||
if (buffer) {
|
||||
void (*do_xfer)(void *source, void *destination) = xfer_routine;
|
||||
void (*do_xfer)(void *source asm("a0"), void *destination asm("a1")) = xfer_routine;
|
||||
if ((startTime = (struct EClockVal *)AllocMem(sizeof(struct EClockVal),MEMF_ANY|MEMF_CLEAR))) {
|
||||
if ((endTime = (struct EClockVal *)AllocMem(sizeof(struct EClockVal),MEMF_ANY|MEMF_CLEAR))) {
|
||||
ReadEClock(startTime);
|
||||
@ -552,7 +552,7 @@ BYTE ata_read(void *buffer, ULONG lba, ULONG count, struct IDEUnit *unit) {
|
||||
command = (unit->xferMultiple) ? ATA_CMD_READ_MULTIPLE : ATA_CMD_READ;
|
||||
}
|
||||
|
||||
void (*ata_xfer)(void *source, void *destination);
|
||||
void (*ata_xfer)(void *source asm("a0"), void *destination asm("a1"));
|
||||
|
||||
/* If the buffer is not word-aligned we need to use a slower routine */
|
||||
if (((ULONG)buffer) & 0x01) {
|
||||
@ -639,7 +639,7 @@ BYTE ata_write(void *buffer, ULONG lba, ULONG count, struct IDEUnit *unit) {
|
||||
command = (unit->xferMultiple) ? ATA_CMD_WRITE_MULTIPLE : ATA_CMD_WRITE;
|
||||
}
|
||||
|
||||
void (*ata_xfer)(void *source, void *destination);
|
||||
void (*ata_xfer)(void *source asm("a0"), void *destination asm("a1"));
|
||||
|
||||
/* If the buffer is not word-aligned we need to use a slower routine */
|
||||
if ((ULONG)buffer & 0x01) {
|
||||
@ -707,7 +707,7 @@ BYTE ata_write(void *buffer, ULONG lba, ULONG count, struct IDEUnit *unit) {
|
||||
* @param source Pointer to the drive data port
|
||||
* @param destination Pointer to the data buffer
|
||||
*/
|
||||
void ata_read_unaligned_long(void *source, void *destination) {
|
||||
void ata_read_unaligned_long(void *source asm("a0"), void *destination asm("a1")) {
|
||||
ULONG readLong;
|
||||
UBYTE *dest = (UBYTE *)destination;
|
||||
|
||||
@ -728,7 +728,7 @@ void ata_read_unaligned_long(void *source, void *destination) {
|
||||
* @param source Pointer to the data buffer
|
||||
* @param destination Pointer to the drive data port
|
||||
*/
|
||||
void ata_write_unaligned_long(void *source, void *destination) {
|
||||
void ata_write_unaligned_long(void *source asm("a0"), void *destination asm("a1")) {
|
||||
UBYTE *src = (UBYTE *)source;
|
||||
for (int i=0; i<(512/4); i++) { // Write (512 / 4) Long words to drive
|
||||
*(ULONG *)destination = (src[0] << 24 | src[1] << 16 | src[2] << 8 | src[3]);
|
||||
|
||||
4
ata.h
4
ata.h
@ -115,6 +115,6 @@ BYTE ata_write(void *buffer, ULONG lba, ULONG count, struct IDEUnit *unit);
|
||||
BYTE ata_set_pio(struct IDEUnit *unit, UBYTE pio);
|
||||
BYTE scsi_ata_passthrough( struct IDEUnit *unit, struct SCSICmd *cmd);
|
||||
|
||||
void ata_read_unaligned_long(void *source, void *destination);
|
||||
void ata_write_unaligned_long(void *source, void *destination);
|
||||
void ata_read_unaligned_long(void *source asm("a0"), void *destination asm("a1"));
|
||||
void ata_write_unaligned_long(void *source asm("a0"), void *destination asm("a1"));
|
||||
#endif
|
||||
@ -18,7 +18,7 @@
|
||||
* @param source Pointer to drive data port
|
||||
* @param destination Pointer to source buffer
|
||||
*/
|
||||
static inline void ata_read_long_movem (void *source, void *destination) {
|
||||
static inline void ata_read_long_movem (void *source asm("a0"), void *destination asm("a1")) {
|
||||
|
||||
asm volatile (
|
||||
"lea.l 460(%0),%0 \n\t"
|
||||
@ -46,7 +46,7 @@ static inline void ata_read_long_movem (void *source, void *destination) {
|
||||
* @param source Pointer to source buffer
|
||||
* @param destination Pointer to drive data port
|
||||
*/
|
||||
static inline void ata_write_long_movem (void *source, void *destination) {
|
||||
static inline void ata_write_long_movem (void *source asm("a0"), void *destination asm("a1")) {
|
||||
|
||||
asm volatile (
|
||||
".rep 9 \n\t"
|
||||
@ -67,7 +67,7 @@ static inline void ata_write_long_movem (void *source, void *destination) {
|
||||
* Read a sector using move - faster than movem on 68020+
|
||||
*
|
||||
*/
|
||||
static inline void ata_read_long_move (void *source, void *destination) {
|
||||
static inline void ata_read_long_move (void *source asm("a0"), void *destination asm("a1")) {
|
||||
asm volatile (
|
||||
"moveq.l #3,d0 \n\t"
|
||||
".l1: \n\t"
|
||||
@ -87,7 +87,7 @@ static inline void ata_read_long_move (void *source, void *destination) {
|
||||
* Write a sector using move - faster than movem on 68020+
|
||||
*
|
||||
*/
|
||||
static inline void ata_write_long_move (void *source, void *destination) {
|
||||
static inline void ata_write_long_move (void *source asm("a0"), void *destination asm("a1")) {
|
||||
asm volatile (
|
||||
"moveq.l #3,d0 \n\t"
|
||||
".l2: \n\t"
|
||||
|
||||
4
device.c
4
device.c
@ -29,10 +29,6 @@
|
||||
extern UBYTE bootblock, bootblock_end;
|
||||
#endif
|
||||
|
||||
// VSCode C/C++ extension doesn't like the asm("<reg>") syntax
|
||||
#ifdef __INTELLISENSE__
|
||||
#define asm(x)
|
||||
#endif
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
A library or device with a romtag should start with moveq #-1,d0 (to
|
||||
|
||||
13
device.h
13
device.h
@ -15,6 +15,11 @@
|
||||
|
||||
#define MAX_UNITS 4
|
||||
|
||||
// VSCode C/C++ extension doesn't like the asm("<reg>") syntax
|
||||
#ifdef __INTELLISENSE__
|
||||
#define asm(x)
|
||||
#endif
|
||||
|
||||
enum xfer {
|
||||
longword_movem,
|
||||
longword_move
|
||||
@ -44,10 +49,10 @@ struct IDEUnit {
|
||||
struct Drive drive;
|
||||
BYTE (*write_taskfile)(struct IDEUnit *, UBYTE, ULONG, UBYTE, UBYTE);
|
||||
enum xfer xferMethod;
|
||||
void (*read_fast)(void *, void *);
|
||||
void (*write_fast)(void *, void *);
|
||||
void (*read_unaligned)(void *, void *);
|
||||
void (*write_unaligned)(void *, void *);
|
||||
void (*read_fast)(void * asm("a0"), void * asm("a1"));
|
||||
void (*write_fast)(void * asm("a0"), void * asm("a1"));
|
||||
void (*read_unaligned)(void * asm("a0"), void * asm("a1"));
|
||||
void (*write_unaligned)(void * asm("a0"), void * asm("a1"));
|
||||
volatile UBYTE *shadowDevHead;
|
||||
volatile void *changeInt;
|
||||
volatile bool deferTUR;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user