MPW IIGS Assembler - Ver 1.2 19-May-02 Page 1 Copyright Apple Computer, Inc. 1987-1990 Loc SLoc Object Code Addr T M Source Statement ;------------------------------------------------------------------------------- ; ; GS/OS CompactFlash driver for Rich Dreher's CFFA card. ; ;------------------------------------------------------------------------------- ; ; Driver description: ; ; --Supports up to 2 CFFA cards, even if their slots are not set to Your Card. ; --Four 32 MB partitions + 5th and 6th partitions of up to 1 GB. ; --NO hot-swapping of cards (this is a CFFA hardware limitation if we take ; the approach of putting the Compact Flash device into "true IDE mode") ; --Format call wipes the first 64K of data. ; --Device name description: .CFFA.sp.ModelName (s=1..7, p=A..F); ; model name is truncated before last 12 characters if needed; ; letters are uppercased, blanks and slashes and colons are changed ; to underscores, and nonprinting characters are ignored. ; --Might support ATA devices up to 128GB, but this hasn't been tested. ; ; Device-specific Status calls: $8000 = return pointer to IDENTIFY buffer ; ; Device-specific Control calls: None ; ; ; References ; ---------- ; SanDisk CF card manual ; Rich Dreher's CFFA firmware source ; Apple IIgs GS/OS Driver Reference ; ;------------------------------------------------------------------------------- ; ; REVISION HISTORY ; ; Sun 17-Feb-2002 by David A. Lyons (dlyons@lyons42.com) ; Initial coding. Started with the "SCSI Driver Shell" sample code, ; "SCSI Driver main" and "SCSIHD.equates" from the Apple IIgs 6.0 CD. ; After day 1, we have read-only single-partition support for a fixed- ; size CF card with the board in slot 2. Runs well at 1 MHz, gets ; random I/O errors at 2.8 MHz. ; ; Sat 23-Feb-2002 DAL ; Worked on this off and on during the week, and today. Now the slot ; scanning is done (though I only have one CFFA card to test it with). ; It's read/write, implements implied partitioning as four 32 MB partitions ; followed by a single partition with all the remaining space on the disk. ; Format zeroes the first 64K of a partition. ; ; Sun 24-Feb-2002 DAL ; Device names are now ".CFFA.sp.CardModelNumber", for example: ; .CFFA.3A.DELKIN_CFLS1VT1-128 ; .CFFA.2B.DELKIN_CFLS1VT1-192 ; .CFFA.7D.LEXAR_ATA_FLASH ; .CFFA.7E.SANDISK_SDCFB-16 ; The first digit is the slot number, and the letter A-E indicates the ; partition. Maximum device name length is 27 characters (plus the "."), ; because Finder 6.0.1 displays "Device: Unknown" if the name is longer. ; CFFA cards are supported even if their slot is not set to "Your Card" ; in the control panel. In this case, interrupts are disabled while card ; access is in progress. It even works in slot 3. The "." before the ; slot digit will be a "*" if the card does not indicate it supports LBA. ; ; Sat 9-Mar-2002 DAL ; Fixed bug where only the first CFFA card found was recognized. ; Implemented BlockOffset. ; Implemented GSOSDriverCompatibilityLevel byte check ($CnF5). ; ; ; Wed 13-Mar-2002 DAL ; Must hit ClearCSMask on any entry to driver where a DIB is already set up. ; Changed the partitioning scheme to allow 6 partitions per slot. The 5th ; and 6th partitions can be up to 1 GB. The maximum partition sizes are now ; entirely in the DIB data, not in the code. ; MPW IIGS Assembler - Ver 1.2 19-May-02 Page 2 Copyright Apple Computer, Inc. 1987-1990 Loc SLoc Object Code Addr T M Source Statement ; Sat 16-Mar-2002 DAL ; working on GS/OS Caching ; ; sometime in April 2002 DAL ; Finished GS/OS caching support. ; ; Sun 19-May-2002 DAL ; Updated CheckDevice logic to match Rich's shipping firmware. ; ;------------------------------------------------------------------------------- ;------------------------------------------------------------------------------- STRING ASIS BLANKS OFF PRINT NOGEN PRINT NOMDIR MACHINE M65816 ; ; Block offset -- first partition starts at this LBA on the Compact Flash card ; 0000 0000 BlockOffset equ 0 0000 0002 GSOSDriverCompatibilityLevel equ 2 ; highest $CnF5 value we recognize on a CFFA card 0000 0004 WAIT_100us EQU 4 0000 007C WAIT_40ms EQU 124 0000 00C5 WAIT_100ms EQU 197 ; ; Bit Location equates ; 0000 0000 null equ %0000000000000000 0000 0001 bit_0 equ %0000000000000001 0000 0002 bit_1 equ %0000000000000010 0000 0004 bit_2 equ %0000000000000100 0000 0008 bit_3 equ %0000000000001000 0000 0010 bit_4 equ %0000000000010000 0000 0020 bit_5 equ %0000000000100000 0000 0040 bit_6 equ %0000000001000000 0000 0080 bit_7 equ %0000000010000000 0000 0100 bit_8 equ %0000000100000000 0000 0200 bit_9 equ %0000001000000000 0000 0400 bit_10 equ %0000010000000000 0000 0800 bit_11 equ %0000100000000000 0000 1000 bit_12 equ %0001000000000000 0000 2000 bit_13 equ %0010000000000000 0000 4000 bit_14 equ %0100000000000000 0000 8000 bit_15 equ %1000000000000000 ; ; Booleans ; 0000 0001 true equ 1 0000 0000 false equ 0 0000 1000 drvr_vers equ $1000 ;Driver 1.0 final 0000 0000 cmd_start equ $0000 ;Driver Startup Call 0000 0001 cmd_open equ $0001 ;Driver Open Call 0000 0002 cmd_read equ $0002 ;Driver Read Call 0000 0003 cmd_write equ $0003 ;Driver Write Call 0000 0004 cmd_close equ $0004 ;Driver Close Call 0000 0005 cmd_status equ $0005 ;Driver Status Call 0000 0006 cmd_control equ $0006 ;Driver Control Call 0000 0007 cmd_flush equ $0007 ;Driver Flush Call 0000 0008 cmd_shutdown equ $0008 ;Driver Shutdown Call ;------------------------------------------------------------------------------- 0000 0200 block_size equ $200 0000 0001 cache_blks equ true ;------------------------------------------------------------------------------- MPW IIGS Assembler - Ver 1.2 19-May-02 Page 3 Copyright Apple Computer, Inc. 1987-1990 Loc SLoc Object Code Addr T M Source Statement 00E1 01D0 warm_cold_flag equ $e101d0 ;word: 0 = cold startup/shutdown (BIT 0 ONLY) ; 1 = warm startup/shutdown (BIT 0 ONLY) ; ; System Service Calls we need. ; ;-------------------------------------------------------------------------- ; ; ENTRY: move_info via 'jsl' ; ; LONGWORD - Source buffer pointer ; LONGWORD - Destination buffer pointer ; LONGWORD - Transfer length ; WORD - Source buffer pointer ; SP --> ; ; A Reg = Undefined ; X Reg = Undefined ; Y Reg = Undefined ; Bank Reg = Undefined ; Dir Reg = GS/OS Direct Page ; P Reg = N V M X D I Z C E ; x x 0 0 0 x x x 0 ; ; EXIT: move_info via 'rtl' ; ; A Reg = Error Code ; X Reg = Undefined ; Y Reg = Undefined ; Bank Reg = Undefined ; Dir Reg = GS/OS Direct Page ; P Reg = N V M X D I Z C E ; x x 0 0 0 x x 0 0 No Error ; x x 0 0 0 x x 1 0 Error ; ;-------------------------------------------------------------------------- 0001 FC70 move_info equ $01fc70 0000 0800 moveblkcmd equ $0800 ;Block Move Option 0000 0805 move_sinc_dinc equ $0805 ;Source Inc, Dest Inc 0000 0809 move_sinc_ddec equ $0809 ;Source Inc, Dest Dec 0000 0806 move_sdec_dinc equ $0806 ;Source Dec, Dest Inc 0000 080A move_sdec_ddec equ $080a ;Source Dec, Dest Dec 0000 0800 move_scon_dcon equ $0800 ;Source con, Dest con 0000 0801 move_sinc_dcon equ $0801 ;Source Inc, Dest con 0000 0802 move_sdec_dcon equ $0802 ;Source Dec, Dest con 0000 0804 move_scon_dinc equ $0804 ;Source con, Dest Inc 0000 0808 move_scon_ddec equ $0808 ;Source con, Dest Dec ;-------------------------------------------------------------------------- ; ; ENTRY: set_disksw via 'jsl' ; ; A Reg = Undefined ; X Reg = Undefined ; Y Reg = Undefined ; Bank Reg = Undefined ; Dir Reg = GS/OS Direct Page ; P Reg = N V M X D I Z C E ; x x 0 0 0 x x x 0 ; ; EXIT: set_disksw via 'rtl' ; ; A Reg = Undefined ; X Reg = Undefined ; Y Reg = Undefined ; Bank Reg = Undefined ; Dir Reg = GS/OS Direct Page ; P Reg = N V M X D I Z C E ; x x 0 0 0 x x 0 0 No Error MPW IIGS Assembler - Ver 1.2 19-May-02 Page 4 Copyright Apple Computer, Inc. 1987-1990 Loc SLoc Object Code Addr T M Source Statement ; ;-------------------------------------------------------------------------- 0001 FC04 cache_find_blk equ $01fc04 0001 FC08 cache_add_blk equ $01fc08 0001 FC14 cache_kil_blk equ $01fc14 0001 FC18 cache_del_vol equ $01fc18 0001 FC90 set_disksw equ $01fc90 0001 FCA4 s_dispatch equ $01fca4 0001 FCA8 install_driver equ $01fca8 ; ; Direct Page Addresses. ; 0000 0000 dev_num equ $0000 ;Device Number 0000 0002 call_num equ $0002 ;Call Number 0000 0004 buff_ptr equ $0004 ;Buffer Pointer 0000 0008 rqst_cnt equ $0008 ;Request Count 0000 000C trans_cnt equ $000C ;Transfer Count 0000 0010 block_num equ $0010 ;Block Number (Read/Write only) 0000 0014 blk_size equ $0014 ;Block Size 0000 0016 fst_num equ $0016 ;FST Number (Read/Write only) 0000 0016 stat_code equ $0016 ;Status Command Code 0000 0016 cont_code equ $0016 ;Control Command Code 0000 0018 volume_id equ $0018 ;Volume ID (Read/Write only) 0000 001A cache_prio equ $001A ;Cache Priority Value (Read/Write only) 0000 001C cache_ptr equ $001C ;Cache Pointer (Read/Write only) 0000 0020 dib_ptr equ $0020 ;DIB Pointer ; ; Memory attribute equates ; 0000 8000 attrlock equ bit_15 ;Block is locked down. 0000 4000 attrfixed equ bit_14 ;Block can't move in mem 0000 0100 attrpurg1 equ bit_8 ;Purge level 1 0000 0200 attrpurg2 equ bit_9 ;Purge level 2 0000 0300 attrpurg3 equ bit_8+bit_9 ;Purge level 3 0000 0010 attrnocross equ bit_4 ;May not cross banks 0000 0008 attrnospec equ bit_3 ;don't use special mem 0000 0004 attrpage equ bit_2 ;Page alligned 0000 0002 attraddr equ bit_1 ;Remain at fixed address 0000 0001 attrbank equ bit_0 ;Remain in fixed bank ; ; Device Characteristics. ; 0000 8000 ram_rom_disk equ bit_15 ;RAM or ROM Disk if Set 0000 4000 gened_drvr equ bit_14 ;Generated Driver if Set 0000 2000 linked_dvc equ bit_13 ;Linked Device if Set 0000 1000 call_active equ bit_12 ;Device Busy if Set 0000 0800 restartable equ bit_11 ;Restartable from ram if Set 0000 0000 mhz_1 equ null ;1 Mhz Device 0000 0100 mhz_2_6 equ bit_8 ;2.6 Mhz Device 0000 0200 mhz_gt_2_6 equ bit_9 ;>2.6 Mhz Device 0000 0300 speed_ind equ bit_8+bit_9 ;Device is speed independent 0000 0080 blk_device equ bit_7 ;Block Device if Set 0000 0040 write_allow equ bit_6 ;Write is Allowed if Set 0000 0020 read_allow equ bit_5 ;Read is Allowed if Set 0000 0008 format_allow equ bit_3 ;Format is Allowed if Set 0000 0004 removable equ bit_2 ;Removable Media if Set ; ; Error_Codes. ; 0000 0000 no_error equ $0000 0000 0011 bad_dev_number equ $0011 0000 0020 drvr_bad_req equ $0020 0000 0021 drvr_bad_code equ $0021 0000 0022 drvr_bad_parm equ $0022 MPW IIGS Assembler - Ver 1.2 19-May-02 Page 5 Copyright Apple Computer, Inc. 1987-1990 Loc SLoc Object Code Addr T M Source Statement 0000 0023 drvr_not_open equ $0023 0000 0024 drvr_prior_open equ $0024 0000 0027 drvr_io equ $0027 0000 0028 drvr_no_dev equ $0028 0000 0029 drvr_busy equ $0029 0000 002B drvr_wrt_prot equ $002b 0000 002C drvr_bad_cnt equ $002c 0000 002D drvr_bad_blk equ $002d 0000 002E drvr_dsk_swch equ $002e 0000 002F drvr_off_line equ $002f ; ; Apple IIgs Softswitches ; 0000 C02D SLOTREG equ $C02D ; internal/external ROM in slot 1, 2, 4, 5, 6, 7 0000 C00A SETINTC3ROM equ $C00A ; enable internal slot 3 ROM 0000 C00B SETSLOTC3ROM equ $C00B ; enable external slot 3 ROM 0000 C017 RDC3ROM equ $C017 ; bit 7 set if slot C3 space enabled ;------------------------------------------------------------------------- ; ; Tradtional DIB (GS/OS Device Driver Reference, p179) ; ;------------------------------------------------------------------------- 00000 0000 dib RECORD $0000 00000 0000 linkptr ds.l 1 ; DIB Link Pointer (LONG) 00000 0004 entry ds.l 1 ; Pointer to Drvrs Main Entry (LONG) 00000 0008 dvcchar ds.w 1 ; Device Characteristics (WORD) 00000 000A blkcnt ds.l 1 ; Block Count for this device (LONG) 00000 000E namelen ds.b 1 ; Length of Descriptive Name (PSTR) 00000 000F disname ds.b 31 ; Field for this devices Name (STR) 00000 002E slotnum ds.w 1 ; Device Slot Number from MGR. (WORD) 00000 0030 unitnum ds.w 1 ; Device Unit Number from MGR. (WORD) 00000 0032 versnum ds.w 1 ; Version Number for our Driver (WORD) 00000 0034 dvcid ds.w 1 ; ID of Device we talk to (WORD) 00000 0036 headlnk ds.w 1 ; Head Device Link (WORD) 00000 0038 fdvclnk ds.w 1 ; Forward Device Link (WORD) 00000 003A ext_ptr ds.l 1 ; Pointer to DIB Extension (LONG) 00000 003E devnum ds.w 1 ; DIB Device Number (WORD) 00000 0040 ;------------------------------------------------------------------------- 00000 0040 ; additional device-specific fields 00000 0040 ;------------------------------------------------------------------------- 00000 0040 MaxBlocks ds.l 1 ; maximum number of blocks in this partition 00000 0044 XForHardware ds.w 1 ; $0010 for slot 1 .. $0070 for slot 7 00000 0046 HWBlockOffset ds.l 1 ; hardware block number for this dev's block 0 00000 004A 004A end equ * 00000 004A ENDR ;------------------------------------------------------------------------- ; ; Identify Drive information (result of an ATA Identify Drive command) ; ;------------------------------------------------------------------------- 00000 0000 identifyDrive RECORD $0000 00000 0000 variousBits ds.w 1 ;word 0 00000 0002 defaultNumCyl ds.w 1 ;word 1 00000 0004 ds.w 1 ;word 2 (reserved) 00000 0006 defaultNumHeads ds.w 1 ;word 3 00000 0008 numUnfmtBytesPerTrk ds.w 1 ;word 4 00000 000A numUnfmtBytesPerSec ds.w 1 ;word 5 00000 000C defNumSecPerTrk ds.w 1 ;word 6 00000 000E numSecPerCard ds.w 2 ;word 7 = MSW, 8 = LSW 00000 0012 reserved2 ds.w 1 ;word 9 00000 0014 serialNumber ds.w 10 ;words 10..19 (ASCII, right justified) 00000 0028 bufferType ds.w 1 ;word 20 00000 002A bufferSizeInBlocks ds.w 1 ;word 21 (buffer size in 512-byte increments) 00000 002C numECCforRWLong ds.w 1 ;word 22 (# of ECC bytes passed on Read/Write Long command) 00000 002E firmwareRevString ds.w 4 ;words 23-26 (firmware revision in ASCII, each word big-endian) 00000 0036 modelString ds.w 20 ;words 27-46 (left justified, each word big-endian) 00000 005E maxSectorsForRWMultiple ds.w 1 ;word 47 00000 0060 doubleWordSupport ds.w 1 ;word 48 00000 0062 capabilities ds.w 1 ;word 49 (such as DMA = bit 8, LBA = bit 9) 00000 0064 ds.w 1 ;word 50 (reserved) MPW IIGS Assembler - Ver 1.2 19-May-02 Page 6 Copyright Apple Computer, Inc. 1987-1990 Loc SLoc Object Code Addr T M Source Statement 00000 0066 PIOTimingMode ds.w 1 ;word 51 00000 0068 DMATimingMode ds.w 1 ;word 52 00000 006A fieldValidity ds.w 1 ;word 53 00000 006C curNumCylinders ds.w 1 ;word 54 00000 006E curNumHeads ds.w 1 ;word 55 00000 0070 curSectorsPerTrack ds.w 1 ;word 56 00000 0072 currentSectorsInLBA ds.w 2 ;words 57-58 (57 = LSW, 58 = MSW) 00000 0076 multSectorValid ds.w 1 ;word 59 00000 0078 totalSectorsInLBA ds.w 2 ;words 60-61 00000 007C ds.w 2 ;words 62-63 (reserved) 00000 0080 advancedPIOSupport ds.w 1 ;word 64 00000 0082 ds.w 2 ;words 65-66 (reserved) 00000 0086 minPIOxferNoFlow ds.w 1 ;word 67 00000 0088 minPIOxferIORDYFlow ds.w 1 ;word 68 00000 008A ds.w 59 ;words 69-127 (reserved) 00000 0100 vendorUnique ds.w 32 ;words 128-159 00000 0140 ds.w 96 ;words 160-255 (reserved) 00000 0200 0200 end equ * 00000 0200 ENDR macro &lab DebugBreakIfCarrySet &lab bcc @ok brk @ok endm PRINT ON ;-------------------------------------------------------------------------- ; ; Header as required by the device dispatcher for drivers. ; ;-------------------------------------------------------------------------- 00000 0000 start PROC 00000 0000 0024 dc.w dib_1-start 00002 0002 000C dc.w 12 ;number of devices 00004 0004 001C dc.w ctrl_list-start ;offset to control list 1 00006 0006 001C dc.w ctrl_list-start ;offset to control list 2 00008 0008 001C dc.w ctrl_list-start ;offset to control list 3 0000A 000A 001C dc.w ctrl_list-start ;offset to control list 4 0000C 000C 001C dc.w ctrl_list-start ;offset to control list 5 0000E 000E 001C dc.w ctrl_list-start ;offset to control list 6 00010 0010 001C dc.w ctrl_list-start ;offset to control list 7 00012 0012 001C dc.w ctrl_list-start ;offset to control list 8 00014 0014 001C dc.w ctrl_list-start ;offset to control list 9 00016 0016 001C dc.w ctrl_list-start ;offset to control list 10 00018 0018 001C dc.w ctrl_list-start ;offset to control list 11 0001A 001A 001C dc.w ctrl_list-start ;offset to control list 12 0001C 001C 0001C 001C 00000000 ctrl_list dc.l null 00020 0020 00000000 dc.l null 00024 0024 00024 0024 ;-------------------------------------------------------------------------- 00024 0024 00024 0024 00000BE8 characteristics equ restartable++\ ;Restartable from ram if Set (WORD) speed_ind++\ ;Device is speed ind if Set blk_device++\ ;Block Device if Set write_allow++\ ;Write is Allowed if Set read_allow++\ ;Read is Allowed if Set format_allow ;Format is Allowed if Set 00024 0024 00024 0024 00000013 OurDeviceID equ $0013 ;generic hard drive (GS/OS Driver Ref, p.185) 00024 0024 00000006 OffsetForSlotDigit equ 6 ;how far into (lengthbyte)'CFFA.nn' to stuff slot# 00024 0024 00000007 OffsetForPartitionLetter equ 7 00024 0024 00000005 OffsetForSpecialCharacter equ 5 ;to indicate a special condition, name is 'CFFA*nn...' 00024 0024 ;------------------------------------------------------------------------- 00024 0024 ; 00024 0024 ; These twelve DIBs support 6 partitions for each of two CFFA boards, such 00024 0024 ; as 4 32-MB devices and one larger device. 00024 0024 ; 00024 0024 ; If you add or remove DIBs to support a different partition layout, be 00024 0024 ; sure to: update MaxDIBsPerSlot appropriately; keep Card2FirstDIB at the 00024 0024 ; appropriate spot; keep the DIBs in a linked list (DIB Link Pointer MPW IIGS Assembler - Ver 1.2 19-May-02 Page 7 Copyright Apple Computer, Inc. 1987-1990 Loc SLoc Object Code Addr T M Source Statement 00024 0024 ; field, 0 for last one); give each DIB an appropriate "Device Unit Number" 00024 0024 ; starting with 1 for each slot; set "Max block count" and "hardware 00024 0024 ; block number" fields appropriately. Always leave the "block count" 0! 00024 0024 ; It must get set up at driver startup time. 00024 0024 ; 00024 0024 ;------------------------------------------------------------------------- 00024 0024 00000006 MaxDIBsPerSlot equ 6 00024 0024 00024 0024 Card1FirstDIB 00024 0024 0000006E dib_1 dc.l dib_2 ; DIB Link Pointer (LONG) 00028 0028 0000039C dc.l drvr_main ; Pointer to Drvrs Main Entry (LONG) 0002C 002C 0BE8 dc.w characteristics 0002E 002E 00000000 dc.l $00000000 ; Block Count for this device (LONG) 00032 0032 07434646412E dc.b 7,'CFFA.nn ' ; 32-byte field: name w/ leading length byte 00052 0052 0000 dc.w $0000 ; Device Slot Number (WORD) 00054 0054 0001 dc.w $0001 ; Device Unit Number (WORD) 00056 0056 1000 dc.w drvr_vers ; Version Number for our Driver (WORD) 00058 0058 0013 dc.w OurDeviceID ; ID of Device we talk to (WORD) 0005A 005A 0000 dc.w $0000 ; Head Device Link (WORD) 0005C 005C 0000 dc.w $0000 ; Forward Device Link (WORD) 0005E 005E 00000064 dc.l @extended ; extendedDIBPtr 00062 0062 0000 dc.w $0000 ; DIB Device Number (WORD) 00064 0064 00010000 @extended dc.l $00010000 ; Max block count 00068 0068 0000 dc.w 0 ; X value for hardware access 0006A 006A 00000000 dc.l $00000000+BlockOffset ; hardware block number of this dev's block 0 0006E 006E 0006E 006E 000000B8 dib_2 dc.l dib_3 ; DIB Link Pointer (LONG) 00072 0072 0000039C dc.l drvr_main ; Pointer to Drvrs Main Entry (LONG) 00076 0076 0BE8 dc.w characteristics 00078 0078 00000000 dc.l $00000000 ; Block Count for this device (LONG) 0007C 007C 07434646412E dc.b 7,'CFFA.nn ' ; 32-byte field: name w/ leading length byte 0009C 009C 0000 dc.w $0000 ; Device Slot Number (WORD) 0009E 009E 0002 dc.w $0002 ; Device Unit Number (WORD) 000A0 00A0 1000 dc.w drvr_vers ; Version Number for our Driver (WORD) 000A2 00A2 0013 dc.w OurDeviceID ; ID of Device we talk to (WORD) 000A4 00A4 0000 dc.w $0000 ; Head Device Link (WORD) 000A6 00A6 0000 dc.w $0000 ; Forward Device Link (WORD) 000A8 00A8 000000AE dc.l @extended ; extendedDIBPtr 000AC 00AC 0000 dc.w $0000 ; DIB Device Number (WORD) 000AE 00AE 00010000 @extended dc.l $00010000 ; Max block count 000B2 00B2 0000 dc.w 0 ; X value for hardware access 000B4 00B4 00010000 dc.l $00010000+BlockOffset ; hardware block number of this dev's block 0 000B8 00B8 000B8 00B8 00000102 dib_3 dc.l dib_4 ; DIB Link Pointer (LONG) 000BC 00BC 0000039C dc.l drvr_main ; Pointer to Drvrs Main Entry (LONG) 000C0 00C0 0BE8 dc.w characteristics 000C2 00C2 00000000 dc.l $00000000 ; Block Count for this device (LONG) 000C6 00C6 07434646412E dc.b 7,'CFFA.nn ' ; 32-byte field: name w/ leading length byte 000E6 00E6 0000 dc.w $0000 ; Device Slot Number (WORD) 000E8 00E8 0003 dc.w $0003 ; Device Unit Number (WORD) 000EA 00EA 1000 dc.w drvr_vers ; Version Number for our Driver (WORD) 000EC 00EC 0013 dc.w OurDeviceID ; ID of Device we talk to (WORD) 000EE 00EE 0000 dc.w $0000 ; Head Device Link (WORD) 000F0 00F0 0000 dc.w $0000 ; Forward Device Link (WORD) 000F2 00F2 000000F8 dc.l @extended ; extendedDIBPtr 000F6 00F6 0000 dc.w $0000 ; DIB Device Number (WORD) 000F8 00F8 00010000 @extended dc.l $00010000 ; Max block count 000FC 00FC 0000 dc.w 0 ; X value for hardware access 000FE 00FE 00020000 dc.l $00020000+BlockOffset ; hardware block number of this dev's block 0 00102 0102 00102 0102 0000014C dib_4 dc.l dib_5 ; DIB Link Pointer (LONG) 00106 0106 0000039C dc.l drvr_main ; Pointer to Drvrs Main Entry (LONG) 0010A 010A 0BE8 dc.w characteristics 0010C 010C 00000000 dc.l $00000000 ; Block Count for this device (LONG) 00110 0110 07434646412E dc.b 7,'CFFA.nn ' ; 32-byte field: name w/ leading length byte 00130 0130 0000 dc.w $0000 ; Device Slot Number (WORD) 00132 0132 0004 dc.w $0004 ; Device Unit Number (WORD) 00134 0134 1000 dc.w drvr_vers ; Version Number for our Driver (WORD) 00136 0136 0013 dc.w OurDeviceID ; ID of Device we talk to (WORD) 00138 0138 0000 dc.w $0000 ; Head Device Link (WORD) 0013A 013A 0000 dc.w $0000 ; Forward Device Link (WORD) 0013C 013C 00000142 dc.l @extended ; extendedDIBPtr 00140 0140 0000 dc.w $0000 ; DIB Device Number (WORD) 00142 0142 00010000 @extended dc.l $00010000 ; Max block count MPW IIGS Assembler - Ver 1.2 19-May-02 Page 8 Copyright Apple Computer, Inc. 1987-1990 Loc SLoc Object Code Addr T M Source Statement 00146 0146 0000 dc.w 0 ; X value for hardware access 00148 0148 00030000 dc.l $00030000+BlockOffset ; hardware block number of this dev's block 0 0014C 014C 0014C 014C 00000196 dib_5 dc.l dib_6 ; DIB Link Pointer (LONG) 00150 0150 0000039C dc.l drvr_main ; Pointer to Drvrs Main Entry (LONG) 00154 0154 0BE8 dc.w characteristics 00156 0156 00000000 dc.l $00000000 ; Block Count for this device (LONG) 0015A 015A 07434646412E dc.b 7,'CFFA.nn ' ; 32-byte field: name w/ leading length byte 0017A 017A 0000 dc.w $0000 ; Device Slot Number (WORD) 0017C 017C 0005 dc.w $0005 ; Device Unit Number (WORD) 0017E 017E 1000 dc.w drvr_vers ; Version Number for our Driver (WORD) 00180 0180 0013 dc.w OurDeviceID ; ID of Device we talk to (WORD) 00182 0182 0000 dc.w $0000 ; Head Device Link (WORD) 00184 0184 0000 dc.w $0000 ; Forward Device Link (WORD) 00186 0186 0000018C dc.l @extended ; extendedDIBPtr 0018A 018A 0000 dc.w $0000 ; DIB Device Number (WORD) 0018C 018C 00200000 @extended dc.l $00200000 ; Max block count (1 GB) 00190 0190 0000 dc.w 0 ; X value for hardware access 00192 0192 00040000 dc.l $00040000+BlockOffset ; hardware block number of this dev's block 0 00196 0196 00196 0196 000001E0 dib_6 dc.l dib_7 ; DIB Link Pointer (LONG) 0019A 019A 0000039C dc.l drvr_main ; Pointer to Drvrs Main Entry (LONG) 0019E 019E 0BE8 dc.w characteristics 001A0 01A0 00000000 dc.l $00000000 ; Block Count for this device (LONG) 001A4 01A4 07434646412E dc.b 7,'CFFA.nn ' ; 32-byte field: name w/ leading length byte 001C4 01C4 0000 dc.w $0000 ; Device Slot Number (WORD) 001C6 01C6 0006 dc.w $0006 ; Device Unit Number (WORD) 001C8 01C8 1000 dc.w drvr_vers ; Version Number for our Driver (WORD) 001CA 01CA 0013 dc.w OurDeviceID ; ID of Device we talk to (WORD) 001CC 01CC 0000 dc.w $0000 ; Head Device Link (WORD) 001CE 01CE 0000 dc.w $0000 ; Forward Device Link (WORD) 001D0 01D0 000001D6 dc.l @extended ; extendedDIBPtr 001D4 01D4 0000 dc.w $0000 ; DIB Device Number (WORD) 001D6 01D6 00200000 @extended dc.l $00200000 ; Max block count (1 GB) 001DA 01DA 0000 dc.w 0 ; X value for hardware access 001DC 01DC 00240000 dc.l $00240000+BlockOffset ; hardware block number of this dev's block 0 001E0 01E0 001E0 01E0 Card2FirstDIB 001E0 01E0 0000022A dib_7 dc.l dib_8 ; DIB Link Pointer (LONG) 001E4 01E4 0000039C dc.l drvr_main ; Pointer to Drvrs Main Entry (LONG) 001E8 01E8 0BE8 dc.w characteristics 001EA 01EA 00000000 dc.l $00000000 ; Block Count for this device (LONG) 001EE 01EE 07434646412E dc.b 7,'CFFA.nn ' ; 32-byte field: name w/ leading length byte 0020E 020E 0000 dc.w $0000 ; Device Slot Number (WORD) 00210 0210 0001 dc.w $0001 ; Device Unit Number (WORD) 00212 0212 1000 dc.w drvr_vers ; Version Number for our Driver (WORD) 00214 0214 0013 dc.w OurDeviceID ; ID of Device we talk to (WORD) 00216 0216 0000 dc.w $0000 ; Head Device Link (WORD) 00218 0218 0000 dc.w $0000 ; Forward Device Link (WORD) 0021A 021A 00000220 dc.l @extended ; extendedDIBPtr 0021E 021E 0000 dc.w $0000 ; DIB Device Number (WORD) 00220 0220 00010000 @extended dc.l $00010000 ; Max block count 00224 0224 0000 dc.w 0 ; X value for hardware access 00226 0226 00000000 dc.l $00000000+BlockOffset ; hardware block number of this dev's block 0 0022A 022A 0022A 022A 00000274 dib_8 dc.l dib_9 ; DIB Link Pointer (LONG) 0022E 022E 0000039C dc.l drvr_main ; Pointer to Drvrs Main Entry (LONG) 00232 0232 0BE8 dc.w characteristics 00234 0234 00000000 dc.l $00000000 ; Block Count for this device (LONG) 00238 0238 07434646412E dc.b 7,'CFFA.nn ' ; 32-byte field: name w/ leading length byte 00258 0258 0000 dc.w $0000 ; Device Slot Number (WORD) 0025A 025A 0002 dc.w $0002 ; Device Unit Number (WORD) 0025C 025C 1000 dc.w drvr_vers ; Version Number for our Driver (WORD) 0025E 025E 0013 dc.w OurDeviceID ; ID of Device we talk to (WORD) 00260 0260 0000 dc.w $0000 ; Head Device Link (WORD) 00262 0262 0000 dc.w $0000 ; Forward Device Link (WORD) 00264 0264 0000026A dc.l @extended ; extendedDIBPtr 00268 0268 0000 dc.w $0000 ; DIB Device Number (WORD) 0026A 026A 00010000 @extended dc.l $00010000 ; Max block count 0026E 026E 0000 dc.w 0 ; X value for hardware access 00270 0270 00010000 dc.l $00010000+BlockOffset ; hardware block number of this dev's block 0 00274 0274 00274 0274 000002BE dib_9 dc.l dib_10 ; DIB Link Pointer (LONG) 00278 0278 0000039C dc.l drvr_main ; Pointer to Drvrs Main Entry (LONG) MPW IIGS Assembler - Ver 1.2 19-May-02 Page 9 Copyright Apple Computer, Inc. 1987-1990 Loc SLoc Object Code Addr T M Source Statement 0027C 027C 0BE8 dc.w characteristics 0027E 027E 00000000 dc.l $00000000 ; Block Count for this device (LONG) 00282 0282 07434646412E dc.b 7,'CFFA.nn ' ; 32-byte field: name w/ leading length byte 002A2 02A2 0000 dc.w $0000 ; Device Slot Number (WORD) 002A4 02A4 0003 dc.w $0003 ; Device Unit Number (WORD) 002A6 02A6 1000 dc.w drvr_vers ; Version Number for our Driver (WORD) 002A8 02A8 0013 dc.w OurDeviceID ; ID of Device we talk to (WORD) 002AA 02AA 0000 dc.w $0000 ; Head Device Link (WORD) 002AC 02AC 0000 dc.w $0000 ; Forward Device Link (WORD) 002AE 02AE 000002B4 dc.l @extended ; extendedDIBPtr 002B2 02B2 0000 dc.w $0000 ; DIB Device Number (WORD) 002B4 02B4 00010000 @extended dc.l $00010000 ; Max block count 002B8 02B8 0000 dc.w 0 ; X value for hardware access 002BA 02BA 00020000 dc.l $00020000+BlockOffset ; hardware block number of this dev's block 0 002BE 02BE 002BE 02BE 00000308 dib_10 dc.l dib_11 ; DIB Link Pointer (LONG) 002C2 02C2 0000039C dc.l drvr_main ; Pointer to Drvrs Main Entry (LONG) 002C6 02C6 0BE8 dc.w characteristics 002C8 02C8 00000000 dc.l $00000000 ; Block Count for this device (LONG) 002CC 02CC 07434646412E dc.b 7,'CFFA.nn ' ; 32-byte field: name w/ leading length byte 002EC 02EC 0000 dc.w $0000 ; Device Slot Number (WORD) 002EE 02EE 0004 dc.w $0004 ; Device Unit Number (WORD) 002F0 02F0 1000 dc.w drvr_vers ; Version Number for our Driver (WORD) 002F2 02F2 0013 dc.w OurDeviceID ; ID of Device we talk to (WORD) 002F4 02F4 0000 dc.w $0000 ; Head Device Link (WORD) 002F6 02F6 0000 dc.w $0000 ; Forward Device Link (WORD) 002F8 02F8 000002FE dc.l @extended ; extendedDIBPtr 002FC 02FC 0000 dc.w $0000 ; DIB Device Number (WORD) 002FE 02FE 00010000 @extended dc.l $00010000 ; Max block count 00302 0302 0000 dc.w 0 ; X value for hardware access 00304 0304 00030000 dc.l $00030000+BlockOffset ; hardware block number of this dev's block 0 00308 0308 00308 0308 00000352 dib_11 dc.l dib_12 ; DIB Link Pointer (LONG) 0030C 030C 0000039C dc.l drvr_main ; Pointer to Drvrs Main Entry (LONG) 00310 0310 0BE8 dc.w characteristics 00312 0312 00000000 dc.l $00000000 ; Block Count for this device (LONG) 00316 0316 07434646412E dc.b 7,'CFFA.nn ' ; 32-byte field: name w/ leading length byte 00336 0336 0000 dc.w $0000 ; Device Slot Number (WORD) 00338 0338 0005 dc.w $0005 ; Device Unit Number (WORD) 0033A 033A 1000 dc.w drvr_vers ; Version Number for our Driver (WORD) 0033C 033C 0013 dc.w OurDeviceID ; ID of Device we talk to (WORD) 0033E 033E 0000 dc.w $0000 ; Head Device Link (WORD) 00340 0340 0000 dc.w $0000 ; Forward Device Link (WORD) 00342 0342 00000348 dc.l @extended ; extendedDIBPtr 00346 0346 0000 dc.w $0000 ; DIB Device Number (WORD) 00348 0348 00200000 @extended dc.l $00200000 ; Max block count 0034C 034C 0000 dc.w 0 ; X value for hardware access 0034E 034E 00040000 dc.l $00040000+BlockOffset ; hardware block number of this dev's block 0 00352 0352 00352 0352 00000000 dib_12 dc.l $00000000 ; DIB Link Pointer (LONG) 00356 0356 0000039C dc.l drvr_main ; Pointer to Drvrs Main Entry (LONG) 0035A 035A 0BE8 dc.w characteristics 0035C 035C 00000000 dc.l $00000000 ; Block Count for this device (LONG) 00360 0360 07434646412E dc.b 7,'CFFA.nn ' ; 32-byte field: name w/ leading length byte 00380 0380 0000 dc.w $0000 ; Device Slot Number (WORD) 00382 0382 0006 dc.w $0006 ; Device Unit Number (WORD) 00384 0384 1000 dc.w drvr_vers ; Version Number for our Driver (WORD) 00386 0386 0013 dc.w OurDeviceID ; ID of Device we talk to (WORD) 00388 0388 0000 dc.w $0000 ; Head Device Link (WORD) 0038A 038A 0000 dc.w $0000 ; Forward Device Link (WORD) 0038C 038C 00000392 dc.l @extended ; extendedDIBPtr 00390 0390 0000 dc.w $0000 ; DIB Device Number (WORD) 00392 0392 00200000 @extended dc.l $00200000 ; Max block count 00396 0396 0000 dc.w 0 ; X value for hardware access 00398 0398 00240000 dc.l $00240000+BlockOffset ; hardware block number of this dev's block 0 0039C 039C 0039C 039C 0039C 039C ;-------------------------------------------------------------------------- 0039C 039C ; 0039C 039C ; Main entry to the driver. 0039C 039C ; State of the machine is: 0039C 039C ; 0039C 039C ; Acc = Call Number 0039C 039C ; $0000 = Startup MPW IIGS Assembler - Ver 1.2 19-May-02 Page 10 Copyright Apple Computer, Inc. 1987-1990 Loc SLoc Object Code Addr T M Source Statement 0039C 039C ; $0001 = Open 0039C 039C ; $0002 = Read 0039C 039C ; $0003 = Write 0039C 039C ; $0004 = Close 0039C 039C ; $0005 = Status 0039C 039C ; $0006 = Control 0039C 039C ; $0007 = Flush 0039C 039C ; $0008 = Shutdown 0039C 039C ; Y register = Unspecified 0039C 039C ; X register = Unspecified 0039C 039C ; P register = 0=M=X=e 0039C 039C ; Direct Page = GS/OS Direct Page 0039C 039C ; Data Bank = Unspecified 0039C 039C ; Stack Pointer = GS/OS Stack 0039C 039C ; System Speed = Fast 0039C 039C ; 0039C 039C ;-------------------------------------------------------------------------- 0039C 039C 0039C 039C 0000039C drvr_main equ * 0039C 039C 0039C 039C ;; sta >$dddddd ; enable when debugging with a logic analyzer 0039C 039C 0039C 039C C9 0009 3 cmp #(mainDispEnd-mainDispatch)/2 0039F 039F B0 24 003C5 2 bge @error 003A1 03A1 ; 003A1 03A1 ; Preserve caller's Data Bank and set ours 003A1 03A1 ; 003A1 03A1 8B 3 phb 003A2 03A2 4B 3 phk 003A3 03A3 AB 4 plb 003A4 03A4 0A 2 asl a 003A5 03A5 AA 2 tax 003A6 03A6 003A6 03A6 20 FFFF 003CA 6 jsr DisableInterruptsIfNeeded 003A9 03A9 003A9 03A9 DA 4 phx 003AA 03AA 20 FFFF 00A19 6 jsr SetupXForHardware 003AD 03AD F0 08 003B7 2 beq @noX 003AF 03AF shortm 003B1 03B1 BF 00C082 5 lda >ClearCSMask,x ;reset MASK bit in PLD for normal CS0 signaling 003B5 03B5 longm 003B7 03B7 FA 5 @noX plx 003B8 03B8 003B8 03B8 FC FFFF 8 jsr (mainDispatch,x) 003BB 03BB 20 FFFF 003F9 6 jsr RestoreInterruptsIfNeeded 003BE 03BE 003BE 03BE AB 4 plb 003BF 03BF B0 03 003C4 2 bcs @have_error 003C1 03C1 A9 0000 3 lda #0 003C4 03C4 6B 6 @have_error rtl 003C5 03C5 003C5 03C5 A9 0021 3 @error lda #drvr_bad_code 003C8 03C8 38 2 sec 003C9 03C9 6B 6 rtl 003CA 03CA 003CA 03CA 003CA 03CA ;-------------------------------------------------------------------------- 003CA 03CA ; 003CA 03CA ; DisableInterruptsIfNeeded 003CA 03CA ; 003CA 03CA ; Input: dib_ptr 003CA 03CA ; 003CA 03CA ; Output: X is preserved 003CA 03CA ; DisabledInts is meaningful 003CA 03CA ; 003CA 03CA ; If this device's DIB is flagged "hardware independent," that means it's 003CA 03CA ; not in a normally-swapped-in slot that GS/OS can see, so we have to go 003CA 03CA ; to special lengths to access it. 003CA 03CA ; 003CA 03CA ;-------------------------------------------------------------------------- 003CA 03CA 000003CA DisableInterruptsIfNeeded equ * 003CA 03CA 9C FFFF 00446 5 stz |DisabledInts 003CD 03CD A0 002E 3 ldy #dib.slotnum 003D0 03D0 B7 20 7 lda [SLOTREG 003E2 03E2 8D FFFF 00448 4 sta |OldSlotReg 003E5 03E5 AF 00C017 5 lda >RDC3ROM 003E9 03E9 8D FFFF 00449 4 sta |OldRDC3ROM 003EC 03EC 003EC 03EC A9 F6 2 lda #$F6 ; external slots 1, 2, 4, 5, 6, 7 003EE 03EE 8F 00C02D 5 sta >SLOTREG 003F2 03F2 8F 00C00B 5 sta >SETSLOTC3ROM ; external slot 3 003F6 03F6 longm 003F8 03F8 60 6 rts 003F9 03F9 003F9 03F9 ;-------------------------------------------------------------------------- 003F9 03F9 ; 003F9 03F9 ; RestoreInterruptsIfNeeded 003F9 03F9 ; 003F9 03F9 ; Must preserve A, Carry 003F9 03F9 ; 003F9 03F9 ;-------------------------------------------------------------------------- 003F9 03F9 000003F9 RestoreInterruptsIfNeeded equ * 003F9 03F9 AE FFFF 00446 5 ldx |DisabledInts 003FC 03FC F0 17 00415 2 beq @ok 003FE 03FE shortm 00400 0400 48 3 pha 00401 0401 AD FFFF 00448 4 lda |OldSlotReg 00404 0404 8F 00C02D 5 sta >SLOTREG 00408 0408 2C FFFF 00449 4 bit |OldRDC3ROM 0040B 040B 30 04 00411 2 bmi @keepC3 0040D 040D 8F 00C00A 5 sta >SETINTC3ROM 00411 0411 68 4 @keepC3 pla 00412 0412 longm 00414 0414 58 2 cli 00415 0415 60 6 @ok rts 00416 0416 00416 0416 ;-------------------------------------------------------------------------- 00416 0416 ; 00416 0416 ; TranslateToGSOSSlotNumber 00416 0416 ; 00416 0416 ; Input: A = slot number (1..7) 00416 0416 ; 00416 0416 ; Output: GS/OS slot number, 8..15 for an external slot, or 00416 0416 ; $8000 + 8..15 for an external slot that we must mark 00416 0416 ; as "independent of hardware" because it was supposed 00416 0416 ; to be invisible, and we want to handle the SLOTREG 00416 0416 ; diddling manually. 00416 0416 ; 00416 0416 ; When we turn on the $8000 bit, GS/OS skips trying to 00416 0416 ; call the SLOT_ARBITER to swap in our slot, which wouldn't 00416 0416 ; work because the SLOT_ARBITER doesn't implement any 00416 0416 ; slot switching. 00416 0416 ; 00416 0416 ;-------------------------------------------------------------------------- 00416 0416 00000416 TranslateToGSOSSlotNumber equ * 00416 0416 C9 0003 3 cmp #3 00419 0419 F0 17 00432 2 beq @slot3 0041B 041B AA 2 tax 0041C 041C 0041C 041C shortm 0041E 041E AD FFFF 00448 4 lda |OldSlotReg 00421 0421 3C FFFF 4 bit |SlotBitTable,x 00424 0424 longm 00426 0426 D0 05 0042D 2 bne @normal 00428 0428 8A 2 txa 00429 0429 09 8008 3 ora #$8008 ; independent of hardware, external slot 0042C 042C 60 6 rts 0042D 042D 8A 2 @normal txa MPW IIGS Assembler - Ver 1.2 19-May-02 Page 12 Copyright Apple Computer, Inc. 1987-1990 Loc SLoc Object Code Addr T M Source Statement 0042E 042E 09 0008 3 ora #$0008 ; just a regular external slot 00431 0431 60 6 rts 00432 0432 00432 0432 2C FFFF 00449 5 @slot3 bit |OldRDC3ROM 00435 0435 30 03 0043A 2 bmi @done 00437 0437 09 8000 3 @special ora #$8000 ; tell GS/OS "independent of hardware" 0043A 043A 09 0008 3 @done ora #$0008 ; external slot (not internal GS port) 0043D 043D 60 6 rts 0043E 043E 0043E 043E FF SlotBitTable dc.b $FF ;slot 0 bogus 0043F 043F 02 dc.b $02 ;slot 1 00440 0440 04 dc.b $04 ;slot 2 00441 0441 FF dc.b $FF ;slot 3 bogus 00442 0442 10 dc.b $10 ;slot 4 00443 0443 20 dc.b $20 ;slot 5 00444 0444 40 dc.b $40 ;slot 6 00445 0445 80 dc.b $80 ;slot 7 00446 0446 00446 0446 0000 DisabledInts dc.w 0 00448 0448 00 OldSlotReg dc.b 0 00449 0449 00 OldRDC3ROM dc.b 0 0044A 044A 0044A 044A ;-------------------------------------------------------------------------- 0044A 044A ; 0044A 044A ; Driver dispatch table 0044A 044A ; 0044A 044A ; These routines return with CLC for no error, or 0044A 044A ; SEC + A = error code. 0044A 044A ; 0044A 044A ;-------------------------------------------------------------------------- 0044A 044A 045C mainDispatch dc.w Startup 0044C 044C 068F dc.w Open 0044E 044E 0698 dc.w Read 00450 0450 06DA dc.w Write 00452 0452 068F dc.w Close 00454 0454 0736 dc.w Status 00456 0456 07D0 dc.w Control 00458 0458 0691 dc.w Flush 0045A 045A 0696 dc.w Shutdown 0045C 045C 0000045C mainDispEnd equ * 0045C 045C 0045C 045C ;-------------------------------------------------------------------------- 0045C 045C ; 0045C 045C ; Startup call 0045C 045C ; 0045C 045C ; Gets called once per DIB. Return no-error if we want GS/OS to use this 0045C 045C ; DIB. 0045C 045C ; 0045C 045C ; The first time we're called, scan the slots for CFFA boards & set up all 0045C 045C ; our DIBs depending on the block counts of the devices we find. 0045C 045C ; 0045C 045C ;-------------------------------------------------------------------------- 0045C 045C AD FFFF 00490 5 Startup lda |first_startup 0045F 045F F0 1A 0047B 2 beq @alreadyScanned 00461 0461 9C FFFF 00490 5 stz |first_startup 00464 0464 00464 0464 D4 06 6 pei $0000F6,X 004A6 04A6 C9 4643 3 cmp #$4643 ; the 'CF' 004A9 04A9 D0 28 004D3 2 bne @next 004AB 04AB BF 0000F8 6 lda >$0000F8,X 004AF 04AF C9 4146 3 cmp #$4146 ; the 'FA' 004B2 04B2 D0 1F 004D3 2 bne @next 004B4 04B4 004B4 04B4 BF 0000F5 6 lda >$0000F5,X ; make sure this card is compatible with us 004B8 04B8 29 00FF 3 and #$00ff 004BB 04BB C9 0003 3 cmp #GSOSDriverCompatibilityLevel+1 004BE 04BE B0 13 004D3 2 bcs @next ; skip it, just let GS/OS's generated SmartPort driver handle it 004C0 04C0 004C0 04C0 DA 4 phx 004C1 04C1 004C1 04C1 D4 20 6 pei ClearCSMask,x ;reset MASK bit in PLD for normal CS0 signaling 004F9 04F9 longm 004FB 04FB 004FB 04FB 20 FFFF 005EA 6 jsr ResetDriveFirstTime 004FE 04FE 004FE 04FE 20 FFFF 00AD0 6 jsr IdentifyDevice ; dib_ptr in, dib's blkcnt out 00501 0501 90 0D 00510 2 bcc @ok 00503 0503 00503 0503 A0 000A 3 ldy #dib.blkcnt ; error: make sure blkcnt is 0 00506 0506 A9 0000 3 lda #0 00509 0509 97 20 7 sta [ATADataHigh,x ;Clear high byte data latch 005F2 05F2 005F2 05F2 A9 06 2 lda #$06 ;Reset bit=1, Disable INTRQ=1 005F4 05F4 9F 00C086 5 sta >ATADevCtrl,x 005F8 05F8 longm 005FA 05FA ; 005FA 05FA ; Per ATA-6 spec, need to wait 5us minimum. Use a delay of 100us. 005FA 05FA ; Should cover accelerated Apples up to 20MHz (even if Wait doesn't 005FA 05FA ; account for the accleration). 005FA 05FA ; 005FA 05FA A9 0004 3 lda #WAIT_100us 005FD 05FD 20 FFFF 00AB6 6 jsr Wait 00600 0600 00600 0600 shortm 00602 0602 A9 02 2 lda #$02 ;Reset bit=0, Disable INTRQ=1 00604 0604 9F 00C086 5 sta >ATADevCtrl,x 00608 0608 longm 0060A 060A ; 0060A 060A ; Per ATA-6 spec, need to wait 2ms minimum. Use a delay of 40ms. 0060A 060A ; Should cover accelerated Apples up to 20MHz (even if Wait doesn't 0060A 060A ; account for the acceleration). 0060A 060A ; 0060A 060A A9 007C 3 lda #WAIT_40ms 0060D 060D 20 FFFF 00AB6 6 jsr Wait 00610 0610 ; 00610 0610 ; Per ATA-6 spec, wait for busy to clear, by calling IDEWaitReady 00610 0610 ; 00610 0610 20 FFFF 00A6F 6 jsr IDEWaitReady 00613 0613 60 6 rts 00614 0614 00614 0614 00614 0614 ;-------------------------------------------------------------------------- 00614 0614 ; 00614 0614 ; Find the CF card's model name in the Identify Drive data. Put a 00614 0614 ; trailing $00 at the last non-blank. Append as many characters as 00614 0614 ; will fit to the device name. 00614 0614 ; 00614 0614 ; The Finder's has a buffer that's too small, so we can't return a 00614 0614 ; full-length 31-character device name (Finder shows "Device: Unknown" 00614 0614 ; in Get Info if we return more than 27 characters). 00614 0614 ; 00614 0614 ; If our device name is too long, we truncate from near the middle, 00614 0614 ; keeping the last 12 characters. MPW IIGS Assembler - Ver 1.2 19-May-02 Page 17 Copyright Apple Computer, Inc. 1987-1990 Loc SLoc Object Code Addr T M Source Statement 00614 0614 ; 00614 0614 ;-------------------------------------------------------------------------- 00614 0614 00000614 AppendCFModelToDeviceName equ * 00614 0614 shortm 00616 0616 00616 0616 ; check for an empty modelString (drive returned all blanks) 00616 0616 AD FFFF 00B7E 4 lda IdentifyBuffer+IdentifyDrive.modelString 00619 0619 F0 19 00634 2 beq @done 0061B 061B 0061B 061B A9 2E 2 lda #'.' 0061D 061D 20 FFFF 00637 6 jsr AppendCharToDeviceName 00620 0620 00620 0620 A2 0036 3 ldx #IdentifyDrive.modelString 00623 0623 BD FFFF 4 @appendMore lda IdentifyBuffer,x 00626 0626 F0 0C 00634 2 beq @done 00628 0628 20 FFFF 0066C 6 jsr TranslateCharacter 0062B 062B 20 FFFF 00637 6 jsr AppendCharToDeviceName 0062E 062E E8 2 inx 0062F 062F E0 005E 3 cpx #IdentifyDrive.modelString+40 00632 0632 90 EF 00623 2 bcc @appendMore 00634 0634 @done longm 00636 0636 60 6 rts 00637 0637 00637 0637 00637 0637 ;-------------------------------------------------------------------------- 00637 0637 ; 00637 0637 ; AppendCharToDeviceName 00637 0637 ; 00637 0637 ; If the device name is too full, center-truncate so that we 00637 0637 ; keep the last 12 characters. 00637 0637 ; 00637 0637 ; CALLED WITH SHORT ACCUMULATOR 00637 0637 ; 00637 0637 ;-------------------------------------------------------------------------- 00637 0637 longa off 00637 0637 00000637 AppendCharToDeviceName equ * 00637 0637 C9 00 2 cmp #0 00639 0639 F0 18 00653 2 beq @done 0063B 063B 48 3 pha 0063C 063C 0063C 063C A0 000E 3 ldy #dib.nameLen 0063F 063F B7 20 6 lda [ ignored 00670 0670 C9 2F 2 cmp #'/' 00672 0672 F0 15 00689 2 beq @underscore 00674 0674 C9 3A 2 cmp #':' 00676 0676 F0 11 00689 2 beq @underscore 00678 0678 C9 20 2 cmp #' ' 0067A 067A F0 0D 00689 2 beq @underscore ;blank -> underscore 0067C 067C 90 0E 0068C 2 bcc @ignore ;control characters -> ignored 0067E 067E C9 61 2 cmp #'a' 00680 0680 90 09 0068B 2 bcc @ok 00682 0682 C9 7B 2 cmp #'z'+1 00684 0684 B0 05 0068B 2 bcs @ok 00686 0686 29 5F 2 and #$5F ;shift to uppercase 00688 0688 60 6 rts 00689 0689 A9 5F 2 @underscore lda #'_' 0068B 068B 60 6 @ok rts 0068C 068C A9 00 2 @ignore lda #0 0068E 068E 60 6 rts 0068F 068F longa on 0068F 068F 0068F 068F 0068F 068F ;-------------------------------------------------------------------------- 0068F 068F ; 0068F 068F ; Open call 0068F 068F ; Close call 0068F 068F ; 0068F 068F ; Open and Close apply to character devices only. 0068F 068F ; We just need to return no-error. 0068F 068F ; 0068F 068F ;-------------------------------------------------------------------------- 0068F 068F 0000068F Open equ * 0068F 068F 0000068F Close equ * 0068F 068F 18 2 clc 00690 0690 60 6 rts 00691 0691 00691 0691 ;-------------------------------------------------------------------------- 00691 0691 ; 00691 0691 ; Flush call 00691 0691 ; 00691 0691 ; Flush is for character devices only. Driver Ref 00691 0691 ; p. 252 says we should return error $20, drvr_bad_req. 00691 0691 ; 00691 0691 ;-------------------------------------------------------------------------- 00691 0691 A9 0020 3 Flush lda #drvr_bad_req 00694 0694 38 2 sec 00695 0695 60 6 rts 00696 0696 00696 0696 ;-------------------------------------------------------------------------- 00696 0696 ; 00696 0696 ; Shutdown call 00696 0696 ; 00696 0696 ; Shutdown doesn't need to do anything, either. 00696 0696 ; 00696 0696 ; Driver Ref p. 253 says "If more than one device is 00696 0696 ; associated with a single code segment, only the last 00696 0696 ; device to be shut down should return no error. Other MPW IIGS Assembler - Ver 1.2 19-May-02 Page 19 Copyright Apple Computer, Inc. 1987-1990 Loc SLoc Object Code Addr T M Source Statement 00696 0696 ; devices should return an I/O error to prevent the 00696 0696 ; segment from being purged before the last device is 00696 0696 ; shut down." 00696 0696 ; 00696 0696 ; I don't know if this means multiple DIBs, or something 00696 0696 ; more complex. 00696 0696 ; 00696 0696 ;-------------------------------------------------------------------------- 00696 0696 00000696 Shutdown equ * 00696 0696 18 2 clc 00697 0697 60 6 rts 00698 0698 00698 0698 ;-------------------------------------------------------------------------- 00698 0698 ; 00698 0698 ; Read call 00698 0698 ; 00698 0698 ; In: dib_ptr, block_num, rqst_cnt, buff_ptr, etc. 00698 0698 ; 00698 0698 ; Out: CLC for no error, or SEC + A = error 00698 0698 ; trans_cnt 00698 0698 ; 00698 0698 ;-------------------------------------------------------------------------- 00698 0698 20 FFFF 0071C 6 Read jsr VerifyRW 0069B 069B B0 3C 006D9 2 bcs @out 0069D 069D 0069D 069D D4 12 6 pei ATADataHigh,x ; clear the CFFA data latch 00898 0898 00898 0898 A9 20 2 lda #ATACRead 0089A 089A 9F 00C08F 5 sta >ATACommand,x 0089E 089E longm 008A0 08A0 008A0 08A0 20 FFFF 008CE 6 jsr Read512Bytes 008A3 08A3 B0 28 008CD 2 bcs @error 008A5 08A5 008A5 08A5 ; Add block to cache if requested 008A5 08A5 A5 1A 4 lda ATAStatus,x ; Check for error response from device 008D7 08D7 29 09 2 and #$09 008D9 08D9 C9 01 2 cmp #01 ; if DRQ=0 and ERR=1 a device error occured 008DB 08DB F0 60 0093D 2 beq @ioError 008DD 08DD 008DD 08DD longm 008DF 08DF ; 008DF 08DF ; Sector is ready to read 008DF 08DF ; 008DF 08DF A5 04 4 lda ATADataHigh,x ;Clear the high byte of the 16 bit interface data latch 0097F 097F longm 00981 0981 00981 0981 20 FFFF 00A6F 6 jsr IDEWaitReady 00984 0984 20 FFFF 00A20 6 jsr Block2LBA ;tell the device the block number 00987 0987 90 01 0098A 2 bcc @ok 00989 0989 60 6 rts 0098A 098A 0098A 098A @ok shortm ; 8-bit Accumulator 0098C 098C 0098C 098C A9 30 2 lda #ATACWrite 0098E 098E 9F 00C08F 5 sta >ATACommand,x ; Issue the read command to the drive 00992 0992 20 FFFF 00A6F 6 jsr IDEWaitReady ; Wait for BUSY flag to clear 00995 0995 00995 0995 shortm 00997 0997 BF 00C08F 5 lda >ATAStatus,x ; Check for error response from device 0099B 099B 29 09 2 and #$09 0099D 099D C9 01 2 cmp #01 ; if DRQ=0 and ERR=1 a device error occured 0099F 099F F0 71 00A12 2 beq @ioError 009A1 09A1 009A1 09A1 longm 009A3 09A3 ; 009A3 09A3 ; Sector is ready to WRITE 009A3 09A3 ; 009A3 09A3 A5 04 4 lda no error, and the CF card is pointed at the right block 00A20 0A20 ; SEC -> A = error code 00A20 0A20 ; 00A20 0A20 ; This function translates the block number sent in the PRODOS request 00A20 0A20 ; packet, into the Logical Block Address. 00A20 0A20 ; The least significant 16 bits becomes the ProDOS block#. 00A20 0A20 ; The most significant 16 becomes the ProDOS Drive # 00A20 0A20 ; 00A20 0A20 ; 00A20 0A20 ; A ProDOS block and a IDE sector are both 512 bytes typically. 00A20 0A20 ; 00A20 0A20 ; Logical Block Mode, the Logical Block Address is interpreted as follows: 00A20 0A20 ; LBA07-LBA00: Sector Number Register D7-D0. 00A20 0A20 ; LBA15-LBA08: Cylinder Low Register D7-D0. 00A20 0A20 ; LBA23-LBA16: Cylinder High Register D7-D0. 00A20 0A20 ; LBA27-LBA24: Drive/Head Register bits HS3-HS0. 00A20 0A20 ; 00A20 0A20 ;------------------------------------------------------------------------------ 00A20 0A20 00000A20 Block2LBA equ * 00A20 0A20 00A20 0A20 ; validate the block_num against [dib_ptr],dib.blkcnt 00A20 0A20 00A20 0A20 A0 000C 3 ldy #dib.blkcnt+2 00A23 0A23 A5 12 4 lda $0FFF.FFFF 00A4D 0A4D @ok 00A4D 0A4D shortm 00A4F 0A4F EB 3 xba 00A50 0A50 09 E0 2 ora #$E0 MPW IIGS Assembler - Ver 1.2 19-May-02 Page 33 Copyright Apple Computer, Inc. 1987-1990 Loc SLoc Object Code Addr T M Source Statement 00A52 0A52 9F 00C08E 5 sta >ATAHead,x ;1, (LBA), 1, (Drive), LBA 27-24; where LBA=1, Drive=0 00A56 0A56 EB 3 xba 00A57 0A57 9F 00C08D 5 sta >ATACylinderH,x ; LBA bits 23-16 00A5B 0A5B 68 4 pla 00A5C 0A5C 9F 00C08B 5 sta >ATASector,x ; LBA bits 7-0 00A60 0A60 68 4 pla 00A61 0A61 9F 00C08C 5 sta >ATACylinder,x ; LBA bits 15-8 00A65 0A65 A9 01 2 lda #1 00A67 0A67 9F 00C08A 5 sta >ATASectorCnt,x 00A6B 0A6B 00A6B 0A6B longm 00A6D 0A6D 18 2 clc 00A6E 0A6E 60 6 rts 00A6F 0A6F 00A6F 0A6F 00A6F 0A6F ;------------------------------------------------------------------------------ 00A6F 0A6F ; IDEWaitReady - Waits for BUSY flag to clear, and returns DRQ bit status 00A6F 0A6F ; 00A6F 0A6F ; Input: 00A6F 0A6F ; X = requested slot number in form $n0 where n = slot 1 to 7 00A6F 0A6F ; Ouput: 00A6F 0A6F ; Z flag = !DRQ status bit 00A6F 0A6F ; 00A6F 0A6F ; (In the firmware, this returned Carry flag = DRQ status bit; 00A6F 0A6F ; BCS becomes BNE; BCC becomes BEQ) 00A6F 0A6F ; 00A6F 0A6F ;------------------------------------------------------------------------------ 00A6F 0A6F 00000A6F IDEWaitReady equ * 00A6F 0A6F shortm 00A71 0A71 BF 00C086 5 lda >ATAAltStatus,x ;** ignore result ** make sure to wait long enough before reading 00A75 0A75 BF 00C08F 5 @loop lda >ATAStatus,x 00A79 0A79 30 FA 00A75 2 bmi @loop ;Wait for BUSY (bit 7) to be zero 00A7B 0A7B 89 08 2 bit #$08 00A7D 0A7D longm 00A7F 0A7F 60 6 rts 00A80 0A80 00A80 0A80 00A80 0A80 ;------------------------------------------------------------------------------ 00A80 0A80 ; CheckDevice - Check to see if a device is attached to the interface. 00A80 0A80 ; 00A80 0A80 ; Input: 00A80 0A80 ; X = requested slot number in form $n0 where n = slot 1 to 7 00A80 0A80 ; Output: 00A80 0A80 ; Carry flag: 0 = Device Present, 1 = Device Missing 00A80 0A80 ; 00A80 0A80 ; CPU Registers changed: A, P 00A80 0A80 ; 00A80 0A80 ; Checks to see if the drive status is readable and equal to $50 00A80 0A80 ; If so, return with the Carry clear, otherwise return with the carry set. 00A80 0A80 ; 00A80 0A80 ;------------------------------------------------------------------------------ 00A80 0A80 5A 4 CheckDevice phy 00A81 0A81 00A81 0A81 shortm 00A83 0A83 BF 00C082 5 lda >ClearCSMask,x ;reset MASK bit in PLD for normal CS0 signaling 00A87 0A87 A9 E0 2 lda #$E0 ;$E0 = [1, LBA, 1, Drive, LBA 27-24] where LBA=1, Drive= 00A89 0A89 9F 00C08E 5 sta >ATAHead,x ;Make sure ATA master drivce is accessed 00A8D 0A8D longm 00A8F 0A8F 00A8F 0A8F A0 0000 3 ldy #0 00A92 0A92 chkLoop shortm 00A94 0A94 BF 00C086 5 lda >ATAAltStatus,x 00A98 0A98 ;;; lda >ATAError,x 00A98 0A98 BF 00C08F 5 lda >ATAStatus,x 00A9C 0A9C 29 D0 2 and #%11010000 00A9E 0A9E C9 50 2 cmp #$50 ;if RDY=1 and DSC=1 00AA0 0AA0 longm 00AA2 0AA2 F0 0F 00AB3 2 beq DeviceFound 00AA4 0AA4 A9 00C5 3 lda #WAIT_100ms 00AA7 0AA7 20 FFFF 00AB6 6 jsr Wait ;Wait 100ms for device to be ready 00AAA 0AAA C8 2 iny 00AAB 0AAB C0 0064 3 cpy #100 ;Wait up to 10 seconds for drive to be ready 00AAE 0AAE D0 E2 00A92 2 bne chkLoop 00AB0 0AB0 MPW IIGS Assembler - Ver 1.2 19-May-02 Page 34 Copyright Apple Computer, Inc. 1987-1990 Loc SLoc Object Code Addr T M Source Statement 00AB0 0AB0 38 2 sec ;drive is not attached 00AB1 0AB1 7A 5 ply 00AB2 0AB2 60 6 rts 00AB3 0AB3 00AB3 0AB3 18 2 DeviceFound clc ;drive is attached 00AB4 0AB4 7A 5 ply 00AB5 0AB5 60 6 rts 00AB6 0AB6 00AB6 0AB6 ;----------------------------------------------------------------------------- 00AB6 0AB6 ; 00AB6 0AB6 ; Call the firmware WAIT routine ($FCA8) 00AB6 0AB6 ; 00AB6 0AB6 ; INPUT: A = time to wait 00AB6 0AB6 ; 00AB6 0AB6 ;----------------------------------------------------------------------------- 00AB6 0AB6 00000AB6 Wait equ * 00AB6 0AB6 DA 4 phx 00AB7 0AB7 5A 4 phy 00AB8 0AB8 00AB8 0AB8 48 4 pha ;space for P 00AB9 0AB9 48 4 pha ;space for A 00ABA 0ABA 48 4 pha ;space for X 00ABB 0ABB 48 4 pha ;space for Y 00ABC 0ABC 48 4 pha ; A value = time to wait 00ABD 0ABD 48 4 pha ; X value 00ABE 0ABE 48 4 pha ; Y value 00ABF 0ABF F4 FCA8 5 pea $FCA8 ; ROM_Wait routine 00AC2 0AC2 A2 2403 3 ldx #$2403 ;FWEntry 00AC5 0AC5 22 E10000 8 jsl $e10000 00AC9 0AC9 68 5 pla 00ACA 0ACA 68 5 pla 00ACB 0ACB 68 5 pla 00ACC 0ACC 68 5 pla 00ACD 0ACD 00ACD 0ACD 7A 5 ply 00ACE 0ACE FA 5 plx 00ACF 0ACF 60 6 rts 00AD0 0AD0 00AD0 0AD0 00AD0 0AD0 ;------------------------------------------------------------------------ 00AD0 0AD0 ; 00AD0 0AD0 ; IdentifyDevice 00AD0 0AD0 ; 00AD0 0AD0 ; Input: 00AD0 0AD0 ; dib_ptr 00AD0 0AD0 ; 00AD0 0AD0 ; Output: 00AD0 0AD0 ; Carry flag: 0 = Okay, 1 = Error 00AD0 0AD0 ; block_count is set up in the dib 00AD0 0AD0 ; 00AD0 0AD0 ;------------------------------------------------------------------------------ 00AD0 0AD0 20 0A19 00A19 6 IdentifyDevice jsr SetupXForHardware 00AD3 0AD3 20 0A80 00A80 6 jsr CheckDevice 00AD6 0AD6 90 01 00AD9 2 bcc sDriveOK 00AD8 0AD8 60 6 rts 00AD9 0AD9 00AD9 0AD9 sDriveOK shortm 00ADB 0ADB A9 00 2 lda #0 00ADD 0ADD 9F 00C080 5 sta >ATADataHigh,x ;clear high byte transfer latch 00AE1 0AE1 longm 00AE3 0AE3 00AE3 0AE3 20 0A6F 00A6F 6 jsr IDEWaitReady 00AE6 0AE6 00AE6 0AE6 shortm 00AE8 0AE8 A9 EC 2 lda #ATAIdentify 00AEA 0AEA 9F 00C08F 5 sta >ATACommand,x ; Issue the read command to the drive 00AEE 0AEE longm 00AF0 0AF0 00AF0 0AF0 D4 06 6 pei