Advertisement
Guest User

Untitled

a guest
Jan 24th, 2012
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.53 KB | None | 0 0
  1. Index: src/mess/machine/isa_aha1542.c
  2. ===================================================================
  3. --- src/mess/machine/isa_aha1542.c (revision 0)
  4. +++ src/mess/machine/isa_aha1542.c (revision 0)
  5. @@ -0,0 +1,266 @@
  6. +/**********************************************************************
  7. + *
  8. + * Adaptec AHA-1542{,C,CF} SCSI Controller
  9. + *
  10. + * Copyright MESS Team.
  11. + * Visit http://mamedev.org for licensing and usage restrictions.
  12. + *
  13. + **********************************************************************/
  14. +
  15. +/*
  16. + PCB layout
  17. + ----------
  18. + Floppy SCSI
  19. + +-----------+ +------------------+ +-
  20. + +-----+-----------+-+------------------+--+
  21. + | |
  22. + | DIPSW DS1 |\
  23. + | +-----+ | |
  24. + | | | Y1 +---+ TRM TRM | |
  25. + | | U3 | |U5 | |S|
  26. + | U8 +-----+ +---+ |C|
  27. + | +---+ +------+ +-------+ |S|
  28. + | |U13| |U15 | Y2 | | |I|
  29. + | +---+ +------+ | | | |
  30. + | |U16 | |U17 | | |
  31. + | +------+ +-------+ |/
  32. + +-----------------------------------------+
  33. + ||||||||| ||||||||||||||||||||||||| |
  34. +
  35. +
  36. + DIPSW sw1 - sw8
  37. + U3 Intel chip labelled "AHA-1542CF/552800-01 D/9346", probably FDC (82077)
  38. + U5 Z84C0010VEC
  39. + U8 EEPROM(?) labelled 545120A
  40. + U13 CXK5864CM-10LL (64kbit SRAM)
  41. + U15 M27C256B labelled "ADAPTEC INC/553801-00 C/MCODE 563D/(C) 1993"
  42. + U16 M27C256B labelled "ADAPTEC INC/553601-00 C/BIOS C38D/(C) 1993"
  43. + U17 AIC-7970Q
  44. + Y1 XTAL SRX4054 93-38
  45. + Y2 XTAL SRX4053 93-40
  46. + TRM Dallas DS2107AS (SCSI termination)
  47. + DS1 LED
  48. +
  49. +*/
  50. +
  51. +/*
  52. + * The PCB has a couple of DIP switches:
  53. + *
  54. + * sw1 on enable termination
  55. + * off software-controlled termination
  56. + *
  57. + * sw2 sw3 sw4 I/O Port
  58. + * off off off 0x330 - 0x333 (default)
  59. + * on off off 0x334 - 0x337
  60. + * off on off 0x230 - 0x233
  61. + * on on off 0x234 - 0x237
  62. + * off off on 0x130 - 0x133
  63. + * on off on 0x134 - 0x137
  64. + * off on on reserved
  65. + * on on on reserved
  66. + *
  67. + * sw5 on disable floppy interface
  68. + * off enable floppy interface
  69. + *
  70. + * sw6 sw7 sw8 BIOS base address
  71. + * off off off 0xdc000 (default)
  72. + * on off off 0xd8000
  73. + * off on off 0xd4000
  74. + * on on off 0xd0000
  75. + * off off on 0xcc000
  76. + * on off on 0xc8000
  77. + * off on on reserved
  78. + * on on on BIOS disabled
  79. + *
  80. + * source: http://download.adaptec.com/pdfs/installation_guides/1540cfig.pdf
  81. + */
  82. +
  83. +#include "machine/isa_aha1542.h"
  84. +#include "cpu/z80/z80.h"
  85. +
  86. +// I/O Port interface
  87. +// READ Port x+0: STATUS
  88. +// WRITE Port x+0: CONTROL
  89. +//
  90. +// READ Port x+1: DATA
  91. +// WRITE Port x+1: COMMAND
  92. +//
  93. +// READ Port x+2: INTERRUPT STATUS
  94. +// WRITE Port x+2: (undefined?)
  95. +//
  96. +// R/W Port x+3: (undefined)
  97. +
  98. +// READ STATUS flags
  99. +#define STAT_STST 0x80 // self-test in progress
  100. +#define STAT_DIAGF 0x40 // internal diagnostic failure
  101. +#define STAT_INIT 0x20 // mailbox initialization required
  102. +#define STAT_IDLE 0x10 // HBA is idle
  103. +#define STAT_CDFULL 0x08 // Command/Data output port is full
  104. +#define STAT_DFULL 0x04 // Data input port is full
  105. +#define STAT_INVCMD 0x01 // Invalid command
  106. +
  107. +// READ INTERRUPT STATUS flags
  108. +#define INTR_ANY 0x80 // any interrupt
  109. +#define INTR_SRCD 0x08 // SCSI reset detected
  110. +#define INTR_HACC 0x04 // HA command complete
  111. +#define INTR_MBOA 0x02 // MBO empty
  112. +#define INTR_MBIF 0x01 // MBI full
  113. +
  114. +// WRITE CONTROL commands
  115. +#define CTRL_HRST 0x80 // Hard reset
  116. +#define CTRL_SRST 0x40 // Soft reset
  117. +#define CTRL_IRST 0x20 // interrupt reset
  118. +#define CTRL_SCRST 0x10 // SCSI bus reset
  119. +
  120. +// READ/WRITE DATA commands
  121. +#define CMD_NOP 0x00 // No operation
  122. +#define CMD_MBINIT 0x01 // mailbox initialization
  123. +#define CMD_START_SCSI 0x02 // Start SCSI command
  124. +#define CMD_BIOSCMD 0x03 // undocumented BIOS conmmand (shadow RAM etc.)
  125. +#define CMD_INQUIRY 0x04 // Adapter inquiry
  126. +#define CMD_EMBOI 0x05 // enable Mailbox Out Interrupt
  127. +#define CMD_SELTIMEOUT 0x06 // Set SEL timeout
  128. +#define CMD_BUSON_TIME 0x07 // set bus-On time
  129. +#define CMD_BUSOFF_TIME 0x08 // set bus-off time
  130. +#define CMD_DMASPEED 0x09 // set ISA DMA speed
  131. +#define CMD_RETDEVS 0x0a // return installed devices
  132. +#define CMD_RETCONF 0x0b // return configuration data
  133. +#define CMD_TARGET 0x0c // set HBA to target mode
  134. +#define CMD_RETSETUP 0x0d // return setup data
  135. +#define CMD_ECHO 0x1f // ECHO command data (NetBSD says it is 0x1e)
  136. +
  137. +// these are for 1541C only:
  138. +#define CMD_RETDEVSHI 0x23 // return devices 8-15 (from NetBSD)
  139. +#define CMD_EXTBIOS 0x28 // return extended BIOS information
  140. +#define CMD_MBENABLE 0x29 // set mailbox interface enable
  141. +
  142. +const device_type AHA1542 = &device_creator<aha1542_device>;
  143. +
  144. +#define Z84C0010_TAG "u5"
  145. +
  146. +READ8_MEMBER( aha1542_device::aha1542_r )
  147. +{
  148. + switch(offset)
  149. + {
  150. + case 0: // READ STATUS
  151. + printf("aha1542: READ STATUS = %02x\n", aha_status);
  152. + return aha_status;
  153. + case 1: // READ DATA
  154. + printf("aha1542: READ DATA = %02x\n", aha_data);
  155. + return aha_data;
  156. + case 2: // READ INTSTATUS
  157. + //printf("aha1542: READ INTSTATUS = %02x\n", aha_intstatus);
  158. + return aha_intstatus;
  159. + default:
  160. + printf("aha1542_r(): unmapped read at pc=0x%08x offset=%d\n", (unsigned) cpu_get_reg(machine().firstcpu, STATE_GENPC), offset);
  161. + }
  162. + return 0xff;
  163. +}
  164. +
  165. +WRITE8_MEMBER( aha1542_device::aha1542_w )
  166. +{
  167. + switch(offset)
  168. + {
  169. + case 0: // WRITE CONTROL
  170. + aha_control = data;
  171. + // check if any reset signal is given
  172. + if (data & 0xf0)
  173. + {
  174. + printf("aha1542: RESET %s%s%s%s\n", data & CTRL_HRST ? "HARD " : "",
  175. + data & CTRL_SRST ? "SOFT " : "", data & CTRL_IRST ? "IRQ " : "",
  176. + data & CTRL_SCRST ? "SCSI " : "");
  177. + aha_status = STAT_STST; // not sure
  178. + control_timer->adjust(attotime::from_usec(50)); // Arbitrary value
  179. + }
  180. + break;
  181. + case 1: // WRITE COMMAND
  182. + printf("aha1542: WRITE DATA %02x\n", data);
  183. + aha_data = data;
  184. + break;
  185. + default:
  186. + printf("aha1542_w(): unmapped pc=0x%08x offset=%d data=0x%02x\n", (unsigned) cpu_get_reg(machine().firstcpu, STATE_GENPC), offset, data);
  187. + }
  188. +}
  189. +
  190. +//-------------------------------------------------
  191. +// ROM( aha1542 )
  192. +//-------------------------------------------------
  193. +
  194. +ROM_START( aha1542 )
  195. + ROM_REGION( 0x8000, "aha1542", 0 )
  196. + ROM_LOAD( "553601-00.u16", 0x0000, 0x8000, CRC(AB22FC02) SHA1(f9f783e0272fc14ba3de32316997f1f6cadc67d0) ) /* Adaptec 1540CF/1542CF BIOS v2.01 */
  197. +
  198. + ROM_REGION( 0x8000, Z84C0010_TAG, 0 )
  199. + ROM_LOAD( "553801-00.u15", 0x0000, 0x8000, CRC(7824397E) SHA1(35bc2c8fab31aad3190a478f2dc8f3a72958cf04) ) /* ADAPTEC, INC MCODE */
  200. +ROM_END
  201. +
  202. +static ADDRESS_MAP_START( z84c0010_mem, AS_PROGRAM, 8, aha1542_device )
  203. + AM_RANGE(0x0000, 0x7fff) AM_ROM AM_REGION(Z84C0010_TAG, 0)
  204. + AM_RANGE(0x8000, 0x800f) AM_NOP // something is mapped there
  205. + AM_RANGE(0x9000, 0xafff) AM_RAM // 2kb RAM chip
  206. + AM_RANGE(0xe000, 0xe0ff) AM_RAM // probably PC<->Z80 communication area
  207. + AM_RANGE(0xb000, 0xb000) AM_NOP // something?
  208. +ADDRESS_MAP_END
  209. +
  210. +static MACHINE_CONFIG_FRAGMENT( aha1542 )
  211. + MCFG_CPU_ADD(Z84C0010_TAG, Z80, XTAL_12MHz)
  212. + MCFG_CPU_PROGRAM_MAP( z84c0010_mem )
  213. +MACHINE_CONFIG_END
  214. +
  215. +
  216. +const rom_entry *aha1542_device::device_rom_region() const
  217. +{
  218. + return ROM_NAME( aha1542 );
  219. +}
  220. +
  221. +machine_config_constructor aha1542_device::device_mconfig_additions() const
  222. +{
  223. + return MACHINE_CONFIG_NAME( aha1542 );
  224. +}
  225. +
  226. +aha1542_device::aha1542_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
  227. + device_t(mconfig, AHA1542, "AHA1542", tag, owner, clock),
  228. + device_isa16_card_interface(mconfig, *this)
  229. +{
  230. + m_shortname="aha1542";
  231. +}
  232. +
  233. +void aha1542_device::device_start()
  234. +{
  235. + set_isa_device();
  236. + m_isa->install_rom(this, 0xdc000, 0xdffff, 0, 0, "aha1542", "aha1542");
  237. + m_isa->install_device(0x330, 0x333, 0, 0, read8_delegate(FUNC( aha1542_device::aha1542_r ), this),
  238. + write8_delegate(FUNC( aha1542_device::aha1542_w ), this) );
  239. +
  240. + aha_status = aha_intstatus = aha_data = 0;
  241. +
  242. + control_timer = machine().scheduler().timer_alloc(FUNC(control_callback), this);
  243. +}
  244. +
  245. +
  246. +void aha1542_device::device_reset()
  247. +{
  248. +}
  249. +
  250. +void aha1542_device::control_handler()
  251. +{
  252. + // handle control
  253. + if (aha_control & (CTRL_HRST | CTRL_SRST))
  254. + {
  255. + // reset the HBA
  256. + aha_intstatus = INTR_ANY | INTR_HACC;
  257. + aha_status = STAT_INIT | STAT_IDLE;
  258. + }
  259. + if (aha_control & CTRL_IRST)
  260. + {
  261. + aha_intstatus = 0;
  262. + }
  263. + // TODO: fire up IRQ?
  264. +}
  265. +
  266. +TIMER_CALLBACK(aha1542_device::control_callback)
  267. +{
  268. + // call back into our device
  269. + reinterpret_cast<aha1542_device *>(ptr)->control_handler();
  270. +}
  271. +
  272. Index: src/mess/machine/isa_aha1542.h
  273. ===================================================================
  274. --- src/mess/machine/isa_aha1542.h (revision 0)
  275. +++ src/mess/machine/isa_aha1542.h (revision 0)
  276. @@ -0,0 +1,71 @@
  277. +/**********************************************************************
  278. + *
  279. + * Adaptec AHA-1542{,C,CF} SCSI Controller
  280. + *
  281. + * Copyright MESS Team.
  282. + * Visit http://mamedev.org for licensing and usage restrictions.
  283. + *
  284. + **********************************************************************
  285. +
  286. +
  287. +
  288. + **********************************************************************/
  289. +
  290. +#pragma once
  291. +
  292. +#ifndef __AHA1542__
  293. +#define __AHA1542__
  294. +
  295. +#define ADDRESS_MAP_MODERN
  296. +
  297. +#include "emu.h"
  298. +#include "machine/isa.h"
  299. +#include "machine/scsibus.h"
  300. +
  301. +//*********************************************************************
  302. +// TYPE DEFINITIONS
  303. +//*********************************************************************
  304. +
  305. +// ====================> aha1542_device
  306. +
  307. +class aha1542_device : public device_t,
  308. + public device_isa16_card_interface
  309. +{
  310. +public:
  311. + // construction/destruction
  312. + aha1542_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
  313. +
  314. + // optional information overrides
  315. + virtual const rom_entry *device_rom_region() const;
  316. + virtual machine_config_constructor device_mconfig_additions() const;
  317. +
  318. + DECLARE_READ8_MEMBER( aha1542_r );
  319. + DECLARE_WRITE8_MEMBER( aha1542_w );
  320. +
  321. +protected:
  322. + // device-level overrides
  323. + virtual void device_start();
  324. + virtual void device_reset();
  325. + virtual void device_config_complete() { m_shortname = "aha1542"; }
  326. +
  327. + // device_isa16_card_interface
  328. +
  329. +private:
  330. + // internal state
  331. + unsigned char aha_status;
  332. + unsigned char aha_control;
  333. + unsigned char aha_intstatus;
  334. + unsigned char aha_data;
  335. + emu_timer *control_timer;
  336. +
  337. + static TIMER_CALLBACK(control_callback);
  338. +
  339. + void control_handler();
  340. +};
  341. +
  342. +// device type definition
  343. +
  344. +extern const device_type AHA1542;
  345. +
  346. +#endif
  347. +
  348. Index: src/mess/includes/at.h
  349. ===================================================================
  350. --- src/mess/includes/at.h (revision 14120)
  351. +++ src/mess/includes/at.h (working copy)
  352. @@ -48,6 +48,7 @@
  353. #include "machine/isa_gblaster.h"
  354. #include "machine/isa_hdc.h"
  355. #include "machine/isa_sblaster.h"
  356. +#include "machine/isa_aha1542.h"
  357. #include "machine/3c503.h"
  358. #include "machine/ne1000.h"
  359. #include "machine/ne2000.h"
  360. Index: src/mess/mess_dev.lst
  361. ===================================================================
  362. --- src/mess/mess_dev.lst (revision 14120)
  363. +++ src/mess/mess_dev.lst (working copy)
  364. @@ -93,6 +93,7 @@
  365. ISA8_MDA
  366. ISA8_EGA
  367. ISA8_HERCULES
  368. +AHA1542
  369. IBM_VGA
  370. IQ151_DISC2
  371. IQ151_MS151A
  372. Index: src/mess/mess.mak
  373. ===================================================================
  374. --- src/mess/mess.mak (revision 14120)
  375. +++ src/mess/mess.mak (working copy)
  376. @@ -1303,6 +1303,7 @@
  377. $(MESS_MACHINE)/isa_mpu401.o \
  378. $(MESS_MACHINE)/isa_sblaster.o \
  379. $(MESS_MACHINE)/isa_ide.o \
  380. + $(MESS_MACHINE)/isa_aha1542.o \
  381. $(MESS_VIDEO)/isa_mda.o \
  382. $(MESS_VIDEO)/crtc_ega.o \
  383. $(MESS_VIDEO)/isa_ega.o \
  384. Index: src/mess/drivers/at.c
  385. ===================================================================
  386. --- src/mess/drivers/at.c (revision 14120)
  387. +++ src/mess/drivers/at.c (working copy)
  388. @@ -360,6 +360,7 @@
  389. // ISA 16 bit
  390. SLOT_INTERFACE("ide", ISA16_IDE)
  391. SLOT_INTERFACE("ne2000", NE2000)
  392. + SLOT_INTERFACE("aha1542", AHA1542)
  393. SLOT_INTERFACE_END
  394.  
  395. static MACHINE_CONFIG_FRAGMENT( at_motherboard )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement