1 |
|
/* |
2 |
|
* scsi_amiga.cpp - SCSI Manager, Amiga specific stuff |
3 |
|
* |
4 |
< |
* Basilisk II (C) 1997-1999 Christian Bauer |
4 |
> |
* Basilisk II (C) 1997-2001 Christian Bauer |
5 |
|
* |
6 |
|
* This program is free software; you can redistribute it and/or modify |
7 |
|
* it under the terms of the GNU General Public License as published by |
22 |
|
#include <exec/memory.h> |
23 |
|
#include <devices/trackdisk.h> |
24 |
|
#include <devices/scsidisk.h> |
25 |
+ |
#define __USE_SYSBASE |
26 |
|
#include <proto/exec.h> |
27 |
+ |
#include <inline/exec.h> |
28 |
|
|
29 |
|
#include "sysdeps.h" |
30 |
|
#include "main.h" |
46 |
|
|
47 |
|
static ULONG buffer_size; // Size of data buffer |
48 |
|
static UBYTE *buffer = NULL; // Pointer to data buffer |
49 |
+ |
static ULONG buffer_memf; // Buffer memory flags |
50 |
|
|
51 |
|
static UBYTE cmd_buffer[12]; // Buffer for SCSI command |
52 |
|
|
62 |
|
{ |
63 |
|
int id, lun; |
64 |
|
|
65 |
+ |
int memtype = PrefsFindInt32("scsimemtype"); |
66 |
+ |
switch (memtype) { |
67 |
+ |
case 1: |
68 |
+ |
buffer_memf = MEMF_24BITDMA | MEMF_PUBLIC; |
69 |
+ |
break; |
70 |
+ |
case 2: |
71 |
+ |
buffer_memf = MEMF_ANY | MEMF_PUBLIC; |
72 |
+ |
break; |
73 |
+ |
default: |
74 |
+ |
buffer_memf = MEMF_CHIP | MEMF_PUBLIC; |
75 |
+ |
break; |
76 |
+ |
} |
77 |
+ |
|
78 |
|
// Create port and buffers |
79 |
|
the_port = CreateMsgPort(); |
80 |
< |
buffer = (UBYTE *)AllocMem(buffer_size = 0x10000, MEMF_CHIP | MEMF_PUBLIC); |
80 |
> |
buffer = (UBYTE *)AllocMem(buffer_size = 0x10000, buffer_memf); |
81 |
|
sense_buffer = (UBYTE *)AllocMem(SENSE_LENGTH, MEMF_CHIP | MEMF_PUBLIC); |
82 |
|
if (the_port == NULL || buffer == NULL || sense_buffer == NULL) { |
83 |
< |
ErrorAlert(GetString(STR_NO_MEM_ERR)); |
83 |
> |
ErrorAlert(STR_NO_MEM_ERR); |
84 |
|
QuitEmulator(); |
85 |
|
} |
86 |
|
|
99 |
|
struct IOStdReq *io = (struct IOStdReq *)CreateIORequest(the_port, sizeof(struct IOStdReq)); |
100 |
|
if (io == NULL) |
101 |
|
continue; |
102 |
< |
if (OpenDevice((UBYTE *)dev_name, dev_unit + lun * 10, (struct IORequest *)io, 0)) { |
102 |
> |
if (OpenDevice((UBYTE *) dev_name, dev_unit + lun * 10, (struct IORequest *)io, 0)) { |
103 |
|
DeleteIORequest(io); |
104 |
|
continue; |
105 |
|
} |
158 |
|
if (size <= buffer_size) |
159 |
|
return true; |
160 |
|
|
161 |
< |
UBYTE *new_buffer = (UBYTE *)AllocMem(size, MEMF_CHIP | MEMF_PUBLIC); |
161 |
> |
UBYTE *new_buffer = (UBYTE *)AllocMem(size, buffer_memf); |
162 |
|
if (new_buffer == NULL) |
163 |
|
return false; |
164 |
|
FreeMem(buffer, buffer_size); |
257 |
|
} |
258 |
|
|
259 |
|
// Process S/G table when reading |
260 |
< |
if (res == 0) { |
260 |
> |
if (reading && res == 0) { |
261 |
|
D(bug(" reading from buffer\n")); |
262 |
|
uint8 *buffer_ptr = buffer; |
263 |
|
for (int i=0; i<sg_size; i++) { |