Previous 15994 Revisions Next

r2732 Sunday 25th May, 2008 at 03:29:27 UTC by Barry Rodewald
[X68000] Minimal implementation of Rezero Unit, Specify, and Request Sense SASI commands. Commented out HD detection hack as a result.
[src/mess/drivers]x68k.c
[src/mess/machine]x68k_hdc.c x68k_hdc.h

src/mess/machine/x68k_hdc.c
r2731r2732
1717 
1818#include "x68k_hdc.h"
1919 
20static TIMER_CALLBACK( req_delay )
21{
22   sasi_ctrl_t* sasi = ptr;
23   sasi->req = 1;
24   sasi->status_port |= 0x01;
25}
26 
2027DEVICE_START( x68k_hdc )
2128{
2229   sasi_ctrl_t* sasi = device->token;
r2731r2732
2431   assert(device->machine != NULL);
2532 
2633   sasi->status = 0x00;
34   sasi->status_port = 0x00;
2735   sasi->phase = SASI_PHASE_BUSFREE;
2836}
2937 
3038WRITE16_DEVICE_HANDLER( x68k_hdc_w )
3139{
32   // SASI HDC - HDDs are not a required system component, so this is something to be done later
40   sasi_ctrl_t* sasi = device->token;
41 
42   switch(offset)
43   {
44   case 0x00:  // data I/O
45      if(sasi->phase == SASI_PHASE_WRITE)
46      {
47         if(sasi->transfer_byte_count == 0)
48         {
49            switch(sasi->command[0])
50            {
51            case SASI_CMD_SPECIFY:
52               sasi->transfer_byte_total = 10;
53               break;
54            default:
55               sasi->transfer_byte_total = 0x800;
56            }
57         }
58         // TODO: Do something with written data
59 
60         if(sasi->command[0] == SASI_CMD_SPECIFY)
61         {
62            logerror("SPECIFY: wrote 0x%02x\n",data);
63         }
64 
65         sasi->req = 0;
66         sasi->status_port &= ~0x01;
67         timer_set(ATTOTIME_IN_NSEC(450),sasi,0,req_delay);
68         sasi->transfer_byte_count++;
69         if(sasi->transfer_byte_count >= sasi->transfer_byte_total)
70         {
71            // End of transfer
72            sasi->phase = SASI_PHASE_STATUS;
73            sasi->io = 1;
74            sasi->status_port |= 0x04;
75            sasi->cd = 1;
76            sasi->status_port |= 0x08;
77            logerror("SASI: Write transfer complete\n");
78         }
79      }
80      if(sasi->phase == SASI_PHASE_COMMAND)
81      {
82         if(sasi->command_byte_count == 0)
83         {
84            // first command byte
85            sasi->current_command = data;
86            switch(data >> 5)  // high 3 bits determine command class, and therefore, length
87            {
88            case 0:
89               sasi->command_byte_total = 6;
90               break;
91            case 1:
92               sasi->command_byte_total = 10;
93               break;
94            case 2:
95               sasi->command_byte_total = 8;
96               break;
97            default:
98               sasi->command_byte_total = 6;
99            }
100         }
101         sasi->command[sasi->command_byte_count] = data;
102         // reset REQ temporarily
103         sasi->req = 0;
104         sasi->status_port &= ~0x01;
105         timer_set(ATTOTIME_IN_NSEC(450),sasi,0,req_delay);
106 
107         sasi->command_byte_count++;
108         if(sasi->command_byte_count >= sasi->command_byte_total)
109         {
110            // End of command
111            // TODO: Actually execute SASI command
112 
113            switch(sasi->command[0])
114            {
115            case SASI_CMD_REZERO_UNIT:
116               sasi->phase = SASI_PHASE_STATUS;
117               sasi->io = 1;  // Output
118               sasi->status_port |= 0x04;  // C/D remains the same
119               logerror("SASI: REZERO UNIT\n");
120               break;
121            case SASI_CMD_REQUEST_SENSE:
122               sasi->phase = SASI_PHASE_READ;
123               sasi->io = 1;
124               sasi->status_port |= 0x04;
125               sasi->cd = 0;
126               sasi->status_port &= ~0x08;
127               sasi->transfer_byte_count = 0;
128               sasi->transfer_byte_total = 0;
129               logerror("SASI: REQUEST SENSE\n");
130               break;
131            case SASI_CMD_SPECIFY:
132               sasi->phase = SASI_PHASE_WRITE;
133               sasi->io = 0;
134               sasi->status_port &= ~0x04;
135               sasi->cd = 0;  // Data
136               sasi->status_port &= ~0x08;
137               sasi->transfer_byte_count = 0;
138               sasi->transfer_byte_total = 0;
139               logerror("SASI: SPECIFY\n");
140               break;
141            default:
142               sasi->phase = SASI_PHASE_STATUS;
143               sasi->io = 1;  // Output
144               sasi->status_port |= 0x04;  // C/D remains the same
145               sasi->status = 0x02;
146               logerror("SASI: Invalid or unimplemented SASI command (0x%02x) recieved.\n",sasi->command[0]);
147            }
148         }
149      }
150      break;
151   case 0x01:
152      if(data == 0)
153      {
154         if(sasi->phase == SASI_PHASE_SELECTION)
155         {
156            // Go to Command phase
157            sasi->phase = SASI_PHASE_COMMAND;
158            sasi->cd = 1;   // data port expects a command or status
159            sasi->status_port |= 0x08;
160            sasi->command_byte_count = 0;
161            sasi->command_byte_total = 0;
162            timer_set(ATTOTIME_IN_NSEC(45),sasi,0,req_delay);
163         }
164      }
165      break;
166   case 0x02:
167      break;
168   case 0x03:
169      if(data != 0)
170      {
171         if(sasi->phase == SASI_PHASE_BUSFREE)
172         {
173            // Go to Selection phase
174            sasi->phase = SASI_PHASE_SELECTION;
175            sasi->bsy = 1;  // HDC is now busy
176            sasi->status_port |= 0x02;
177         }
178      }
179      break;
180   }
181 
33182   logerror("SASI: write to HDC, offset %04x, data %04x\n",offset,data);
34183}
35184 
36185READ16_DEVICE_HANDLER( x68k_hdc_r )
37186{
38   logerror("SASI: [%08x] read from HDC, offset %04x\n",activecpu_get_pc(),offset);
187   sasi_ctrl_t* sasi = device->token;
188   int retval;
189 
39190   switch(offset)
40191   {
41192   case 0x00:
193      if(sasi->phase == SASI_PHASE_MESSAGE)
194      {
195         sasi->phase = SASI_PHASE_BUSFREE;
196         sasi->msg = 0;
197         sasi->cd = 0;
198         sasi->io = 0;
199         sasi->bsy = 0;
200         sasi->req = 0;
201         sasi->status = 0;
202         sasi->status_port = 0;  // reset all status bits to 0
203         return 0x00;
204      }
205      if(sasi->phase == SASI_PHASE_STATUS)
206      {
207         sasi->phase = SASI_PHASE_MESSAGE;
208         sasi->msg = 1;
209         sasi->status_port |= 0x10;
210         // reset REQ temporarily
211         sasi->req = 0;
212         sasi->status_port &= ~0x01;
213         timer_set(ATTOTIME_IN_NSEC(450),sasi,0,req_delay);
214 
215         return sasi->status;
216      }
217      if(sasi->phase == SASI_PHASE_READ)
218      {
219         if(sasi->transfer_byte_count == 0)
220         {
221            switch(sasi->command[0])
222            {
223            case SASI_CMD_REQUEST_SENSE:
224               // set up sense bytes
225               sasi->sense[0] = 0x01;  // "No index signal"
226               sasi->sense[1] = 0;
227               sasi->sense[2] = 0;
228               sasi->sense[3] = 0;
229               if(sasi->command[3] == 0)
230                  sasi->transfer_byte_total = 4;
231               else
232                  sasi->transfer_byte_total = sasi->command[3];
233               break;
234            default:
235               sasi->transfer_byte_total = 0;
236            }
237         }
238         
239         switch(sasi->command[0])
240         {
241         case SASI_CMD_REQUEST_SENSE:
242            retval = sasi->sense[sasi->transfer_byte_count];
243            logerror("REQUEST SENSE: read value 0x%02x\n",retval);
244            break;
245         default:
246            retval = 0;
247         }
248 
249         sasi->req = 0;
250         sasi->status_port &= ~0x01;
251         timer_set(ATTOTIME_IN_NSEC(450),sasi,0,req_delay);
252         sasi->transfer_byte_count++;
253         if(sasi->transfer_byte_count >= sasi->transfer_byte_total)
254         {
255            // End of transfer
256            sasi->phase = SASI_PHASE_STATUS;
257            sasi->io = 1;
258            sasi->status_port |= 0x04;
259            sasi->cd = 1;
260            sasi->status_port |= 0x08;
261            logerror("SASI: Read transfer complete\n");
262         }
263 
264         return retval;
265      }
42266      return 0x00;
43267   case 0x01:
44      return 0x00;
268      logerror("SASI: [%08x] read from status port, read 0x%02x\n",activecpu_get_pc(),sasi->status_port);
269      return sasi->status_port;
45270   case 0x02:
46      return 0x00;
271      return 0xff;  // write-only
47272   case 0x03:
48      return 0x00;
273      return 0xff;  // write-only
49274   default:
50275      return 0xff;
51276   }
src/mess/machine/x68k_hdc.h
r2731r2732
1515   SASI_PHASE_COMMAND,
1616   SASI_PHASE_DATA,
1717   SASI_PHASE_STATUS,
18   SASI_PHASE_MESSAGE
18   SASI_PHASE_MESSAGE,
19   SASI_PHASE_READ,
20   SASI_PHASE_WRITE
1921};
2022 
23// SASI commands, based on the SASI standard
24enum
25{
26   // Class 0 (6-byte) commands
27   SASI_CMD_TEST_UNIT_READY = 0,
28   SASI_CMD_REZERO_UNIT,
29   SASI_CMD_RESERVED_02,
30   SASI_CMD_REQUEST_SENSE,
31   SASI_CMD_FORMAT_UNIT,
32   SASI_CMD_RESERVED_05,
33   SASI_CMD_RESERVED_06,
34   SASI_CMD_RESERVED_07,
35   SASI_CMD_READ,
36   SASI_CMD_RESERVED_09,
37   SASI_CMD_WRITE,
38   SASI_CMD_SEEK,
39   SASI_CMD_RESERVED_0C,
40   SASI_CMD_RESERVED_0D,
41   SASI_CMD_RESERVED_0E,
42   SASI_CMD_WRITE_FILE_MARK,
43   SASI_CMD_INVALID_10,
44   SASI_CMD_INVALID_11,
45   SASI_CMD_RESERVE_UNIT,
46   SASI_CMD_RELEASE_UNIT,
47   SASI_CMD_INVALID_14,
48   SASI_CMD_INVALID_15,
49   SASI_CMD_READ_CAPACITY,
50   SASI_CMD_INVALID_17,
51   SASI_CMD_INVALID_18,
52   SASI_CMD_INVALID_19,
53   SASI_CMD_READ_DIAGNOSTIC,
54   SASI_CMD_WRITE_DIAGNOSTIC,
55   SASI_CMD_INVALID_1C,
56   SASI_CMD_INVALID_1D,
57   SASI_CMD_INVALID_1E,
58   SASI_CMD_INQUIRY,
59   // Class 1 commands  (yes, just the one)
60   SASI_CMD_RESERVED_20,
61   SASI_CMD_RESERVED_21,
62   SASI_CMD_RESERVED_22,
63   SASI_CMD_SET_BLOCK_LIMITS = 0x28,
64   // Class 2 commands
65   SASI_CMD_EXTENDED_ADDRESS_READ = 0x48,
66   SASI_CMD_INVALID_49,
67   SASI_CMD_EXTENDED_ADDRESS_WRITE,
68   SASI_CMD_WRITE_AND_VERIFY = 0x54,
69   SASI_CMD_VERIFY,
70   SASI_CMD_INVALID_56,
71   SASI_CMD_SEARCH_DATA_HIGH,
72   SASI_CMD_SEARCH_DATA_EQUAL,
73   SASI_CMD_SEARCH_DATA_LOW,
74   // controller-specific commands
75   SASI_CMD_SPECIFY = 0xc2
76};
77 
2178typedef struct _sasi_ctrl_t sasi_ctrl_t;
2279struct _sasi_ctrl_t
2380{
r2731r2732
2683   unsigned char status;       // status phase output
2784   unsigned char message;
2885   unsigned char command[10];
86   unsigned char sense[4];
87   int command_byte_count;
88   int command_byte_total;
89   int current_command;
90   int transfer_byte_count;
91   int transfer_byte_total;
92   int msg;  // MSG
93   int cd;   // C/D (Command/Data)
94   int bsy;  // BSY
95   int io;   // I/O
96   int req;  // REQ
2997};
3098 
3199DEVICE_START( x68k_hdc );
src/mess/drivers/x68k.c
r2731r2732
139139#include "machine/x68k_hdc.h"
140140#include "includes/x68k.h"
141141
142//#define ENABLE_SASI
143
144142struct x68k_system sys;
145143
146144extern UINT16* gvram;  // Graphic VRAM
r2731r2732
12151213static READ16_HANDLER( x68k_sram_r )
12161214{
12171215   // HACKS!
1218#ifndef ENABLE_SASI
1219   if(offset == 0x5a/2)  // 0x5a should be 0 if no SASI HDs are present.
1220      return 0x0000;
1221#endif
1216//   if(offset == 0x5a/2)  // 0x5a should be 0 if no SASI HDs are present.
1217//      return 0x0000;
12221218   if(offset == 0x08/2)
12231219      return mess_ram_size >> 16;  // RAM size
12241220   /*if(offset == 0x46/2)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team