annotate 3rdparty/drivers/ide/ccide.asm @ 1570:a4b6825eeb72

ccdisk renamed to rb1773, added CC3 driver into source
author boisy
date Tue, 18 May 2004 01:26:19 +0000
parents 98b6eddbf729
children 80cff44f7e07
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1117
d26a93134e57 Fixed some minor source problems
boisy
parents: 613
diff changeset
1 ********************************************************************
d26a93134e57 Fixed some minor source problems
boisy
parents: 613
diff changeset
2 * CCIDE - IDE device driver for CoCo
d26a93134e57 Fixed some minor source problems
boisy
parents: 613
diff changeset
3 *
d26a93134e57 Fixed some minor source problems
boisy
parents: 613
diff changeset
4 * $Id$
d26a93134e57 Fixed some minor source problems
boisy
parents: 613
diff changeset
5 *
d26a93134e57 Fixed some minor source problems
boisy
parents: 613
diff changeset
6 * DO NOT FORGET TO SET H6309 FLAG IN DEFSFILE APPROPRIATELY FOR 6809 VS.
d26a93134e57 Fixed some minor source problems
boisy
parents: 613
diff changeset
7 * 6309 CODE WHEN ASSEMBLING!!
d26a93134e57 Fixed some minor source problems
boisy
parents: 613
diff changeset
8 *
d26a93134e57 Fixed some minor source problems
boisy
parents: 613
diff changeset
9 * Driver originally from Jim Hathaway, originally 8-bit only
d26a93134e57 Fixed some minor source problems
boisy
parents: 613
diff changeset
10 * Converted to 16 bit by Alan DeKok
d26a93134e57 Fixed some minor source problems
boisy
parents: 613
diff changeset
11 * Disassembled (OK, so I didn't have the source version at first!)
d26a93134e57 Fixed some minor source problems
boisy
parents: 613
diff changeset
12 * by Eddie Kuns, ATA specs followed carefully and sector buffering
d26a93134e57 Fixed some minor source problems
boisy
parents: 613
diff changeset
13 * on writes handled more carefully
d26a93134e57 Fixed some minor source problems
boisy
parents: 613
diff changeset
14 * This driver uses 16-bit transfers *only*
d26a93134e57 Fixed some minor source problems
boisy
parents: 613
diff changeset
15 * Check with Glenside - can we switch to 16 bit only, so there is less to
d26a93134e57 Fixed some minor source problems
boisy
parents: 613
diff changeset
16 * maintain? With the cacheing stuff, the speed is fairly decent, although
d26a93134e57 Fixed some minor source problems
boisy
parents: 613
diff changeset
17 * some 6309 optimizations are still possible (cache copies, drive table
d26a93134e57 Fixed some minor source problems
boisy
parents: 613
diff changeset
18 * copies, hardware divide for CHS translation, etc.)
d26a93134e57 Fixed some minor source problems
boisy
parents: 613
diff changeset
19 *
89
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
20 * NOTE: Currently, will return RAW error #'s from drive (see ATA bit flags
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
21 * in error register). After driver finalized, switch back to OS9 error
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
22 * codes.
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
23 * NOTE 2: drvrbusy checks are done even before hardware access, because
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
24 * some variables are shared in the driver memory, and if a 2nd request
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
25 * comes in in the middle of it, the vars might be changed at a dangerous
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
26 * time. Note if you have two IDE controllers: since they get separate driver
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
27 * memory from each other, that both controllers CAN be active at the same
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
28 * time.
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
29 * BIG NOTE ON OLDER ATA-1 DRIVES!!!
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
30 * SOME DRIVES (MY MINISCRIBE 8051A INCLUDED) HAVE A TRANSLATION MODE THAT
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
31 * _IS_BUILT_INTO_THE_IDE_ROM_ITSELF! THE BAD PART IS, THE "IDENTIFY DRIVE"
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
32 * COMMAND _DOES_NOT_ TAKE THIS INTO CONSIDERATION, BUT RETURNS THE "NATIVE"
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
33 * DRIVE SPECS FOR CYLINDERS, HEADS & SECTORS PER TRACK. TO GET THE FULL
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
34 * CAPACITY OF THE DRIVE, WITHOUT ERRORS, YOU _MUST_ SET YOUR DEVICE
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
35 * DESCRIPTOR BASED ON THE HARDWARE _TRANSLATED_ SETTINGS, _NOT_ THE _NATIVE_
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
36 * SETTINGS (DESCRIBED IN THE IDENTIFY DRIVE COMMAND)! AS A REAL WORLD
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
37 * EXAMPLE, ON MY MINISCRIBE 8051A:
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
38 * Drives "Native" mode (as well as the Identify Drive command) returns:
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
39 * 745 cylinders, 4 heads & 28 sectors/cylinder.
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
40 * HOWEVER, the "Translation" mode (which is checked off on the sticker on
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
41 * the drive itself from the manufacturer), says:
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
42 * Translated: 5 heads, 17 sectors. At this point, you will have to figure
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
43 * out the # of cylinders, by computing the # of sectors TOTAL for the
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
44 * drive in it's native mode (745*4*28 in the above example, or 83,440
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
45 * sectors), and then dividing that value by (# of sectors/track * # of
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
46 * heads) in the translation mode, and rounding down. In the above case,
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
47 * 83,440/(5*17)=981.647, so use 981 (which in hex is $03d5).
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
48 * Therefore, the proper device descriptor for this drive is:
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
49 * cyl=3d5 sid=5 sct=22 t0s=22 (Actually, t0s is ignored by CCIDE)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
50 * The sct=22 is because the value is hexidecimal (it means 34 sectors/
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
51 * track), and is double the 17 I mentioned above because OS9 sectors are
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
52 * half the size of IDE sectors (256 bytes vs. 512 bytes). If this drive
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
53 * had been shipped in "Native" mode, it would use the following:
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
54 * cyl=2E9 sid=4 sct=38 t0s=38, which is what the IDENTIFY DRIVE command
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
55 * reports.
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
56 * You can verify the highest cylinder # by setting the OFS in the descriptor
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
57 * to what you think is the highest cylinder # (total # of cylinders-1 ...
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
58 * remember that CHS cylinder numbers start at 0!), and then try to read
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
59 * enough sectors to cover the whole track. If you go one past that value,
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
60 * you should start getting errors if you have the right cylinder count.
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
61 * This is kind of a dumb system, but I assume it had something to do with
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
62 * IBM PC BIOS in the early days of IDE.
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
63 *A LITTLE LATER, WHEN THE DRIVER IS STABLE, MAY WANT TO ADD ANOTHER BIT FLAG
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
64 * TO DRIVEFLG, SET UP BY A FIRST TIME READ: 8 BIT ACCEPTED. THEN, USE THE 8
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
65 * BIT TRANSFER MODE IF POSSIBLE (LIKE I DID WITH LBA). THIS SHOULD ALLOW
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
66 * MUCH FASTER SECTOR ACCESS ON A NITROS9 SYSTEM, AND IT WOULD BE INTERESTING
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
67 * TO SEE HOW MANY DRIVES ACCEPT THAT MODE (SUPPOSED TO RETURN AN 'ABORTED'
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
68 * FLAG IF IT DOES NOT).
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
69 * NOTE: RBF WILL ASSIGN NEW DEVICE MEM (,U PTR) TO _EACH_ CONTROLLER ON IT'S
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
70 * OWN, BASED ON THE BASE ADDRESS FROM THE DEVICE DESCRIPTOR. THEREFORE,
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
71 * CCIDE SHOULD BE SET UP FOR _2_ DRIVES MAX (PER CONTROLLER), AND LET RBF
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
72 * TAKE CARE OF MULTIPLE CONTROLLERS.
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
73 * The exception to this is when using partitions; since they will have a
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
74 * separate descriptor for each partition, they will need a separate drive
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
75 * table entry. Each table entry is $26 (38) bytes each, so it is not a lot.
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
76 * Should make the device table fill up the rest of a 256 byte page (with
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
77 * all other variables allocated), since OS9 will force System RAM pages to
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
78 * even multiples of 256 anyways. Once full 8k block caching is implemented,
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
79 * some of the two 256 byte sector buffers currently in system RAM could be
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
80 * reused for more drive table entries as well. With current system RAM
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
81 * requirements in driver, this would allow 5 device table entries without
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
82 * taking any more system RAM then it is already. These can be shared in
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
83 * whatever combination you need for your (up to) 2 physical drives.
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
84 * ALSO, RBF CALLS THE INIT ROUTINE ONLY ONCE PER _DRIVER_, NOT DRIVE!
36
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
85 *
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
86 * Ed. Comments Who YY/MM/DD
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
87 * ------------------------------------------------------------------
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
88 * 5 Source as distributed by Glenside 99/05/02
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
89 * Added comments from 8 bit driver BGP 99/05/07
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
90 * 6 Driver now gets address from descriptor, made BGP 99/05/10
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
91 * minor optimizations, added symbols
89
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
92 * 7 Change to use real 16 bits LCB 99/09/06
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
93 * partitions (both LBA & CHS) to 99/10/31
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
94 * better error reporting
1117
d26a93134e57 Fixed some minor source problems
boisy
parents: 613
diff changeset
95 * slightly optimized read
89
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
96 * Half sector & LSN0 caches for current drive
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
97 * Auto-sense/run LBA & CHS modes
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
98 * Full CHS calculations (up to 4096 cylinders)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
99 * for ATA-1 old drive compatibility
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
100 * 8 Attempted to add support for removable media LCB 00/05/27
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
101 * commands (Door Lock/Unlock, Acknowledge Media to 00/??/??
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
102 * Change)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
103 * Attempt 'generic' ATA command system call
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
104 * Constants - change if needed
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
105 * NUMDRIVE is LOGICAL drives (partitions), NOT physical drives-use 5,11,etc
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
106 * 5=768 byte data area, 11=1024 byte data area
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
107 NUMDRIVE equ 11 Max. # of device descriptors per controller address
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
108 MAXWAIT equ 60*5 Max. # clock ticks to give up on read/write (5 sec)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
109 HDSclPwr equ 2048 Set to 2048 as start ^2 cylinder (CHS translate)
36
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
110
89
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
111 * New definitions in Device Descriptor
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
112 PartOfs equ $26 2 byte partition offset
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
113
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
114 * Definitions for DD.DNS
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
115 PhysDriv equ %00000001 Physical drive # (0=Master, 1=Slave)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
116 ForceCHS equ %00000010 Force driver to use CHS mode
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
117
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
118 * New GetStat/SetStat calls:
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
119 * SS.DrInf call shares call # with SS.ScInf from NitrOS9 WindInt (info)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
120 SS.DrInf equ $8f Drive info call (see routine for parms)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
121 * Subcall #'s fro SS.DrInf (Y register on entry)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
122 ATAIdent equ 0 ATA (handles ATAPI & plain ATA)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
123
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
124 * IDE & ATAPI Commands (ATAPI stuff not implemented yet, and LBA is mandatory)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
125 ReadRtry equ $20 Read sector with retry
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
126 WritRtry equ $30 Write sector with retry
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
127 Diagnost equ $90 Execute drive diagnostic
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
128 Identify equ $EC Identify drive command
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
129 DoorLock equ $DE Lock drive
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
130 DoorUnLk equ $DF Unlock (eject) drive
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
131 AckMdChg equ $DB Acknowledge media change
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
132
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
133 PIIdent equ $A1 Identify ATAPI drive command
36
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
134
89
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
135 * IDE Status Register
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
136 Busy equ %10000000 Drive busy (1=busy)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
137 DrvReady equ %01000000 Drive ready (1=ready to accept command)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
138 WriteFlt equ %00100000 Drive Write Fault (1=Write fault?)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
139 SeekDone equ %00010000 Seek Complete (1=Seek complete)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
140 DataReq equ %00001000 Data Request (1=drive ready for read/write data)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
141 CorrData equ %00000100 Corrected Data (1=correctable data error was done)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
142 Index equ %00000010 1=1 disk revolution completed
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
143 ErrorFnd equ %00000001 1=Error detected - see error register
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
144
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
145 * IDE hardware offsets
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
146 DataReg equ 0 Data (1st 8 bits, non-latched)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
147 Error equ 1 Error # when read
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
148 Features equ 1 Features when write
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
149 SectCnt equ 2 Sector count
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
150 SectNum equ 3 Sector #
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
151 CylLow equ 4 Low byte of cylinder
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
152 CylHigh equ 5 High byte of cylinder
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
153 DevHead equ 6 Device/Head
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
154 Status equ 7 Status when read
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
155 Command equ 7 Command when write
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
156 Latch equ 8 Latch (2nd 8 bits of 16 bit word)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
157
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
158 * Special flags (Mini extra drive table - 1 byte per drive) - starts at
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
159 * DriveFlg,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
160 * These are set by inquiring the drive, NOT from the descriptor
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
161 * Should add a GETSTAT to allow user to access these for any drive
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
162 Unused equ %10000000 Entry is un-initialized
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
163 DrvMode equ %00000001 0=CHS mode, 1=LBA mode
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
164 ATAPI equ %00000010 0=Device is ATA,1=Device is ATAPI
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
165 Remove equ %00000100 0=Fixed Drive, 1=Removable media
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
166 ReadOnly equ %00001000 0=Read & write allowed, 1=Read only (CD-ROM)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
167 * Could also use to write-protect hard drive
36
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
168 nam CCIDE
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
169 ttl IDE device driver for CoCo
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
170
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
171 ifp1
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
172 use defsfile
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
173 endc
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
174
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
175 tylg set Drivr+Objct
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
176 atrv set ReEnt+rev
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
177 rev set $01
89
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
178 edition equ 8
36
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
179
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
180 mod eom,name,tylg,atrv,start,size
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
181
89
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
182 * NOTE: OS9 WILL ALWAYS ASSIGN DRIVER MEM SPACE ON AN EVEN 256 BYTE PAGE,
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
183 * SO TAKE ADVANTAGE OF "EXTRA" SPACE!
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
184
36
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
185 org 0
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
186 rmb DRVBEG+(DRVMEM*NUMDRIVE)
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
187 * Start of driver-specific statics
89
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
188 SlpCntr rmb 2 # ticks left before we give up on a read/write
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
189 PhysDrv rmb 1 Physical drive # (for quick lookup)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
190 DriveFlg rmb NUMDRIVE 1 byte per drive (bit flags)
36
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
191 OS9LSN rmb 3 LSN of current OS-9 256-byte sector
89
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
192 * IDE spec can handle 28 bits (4 bits of 4th byte) for LBA mode. Since OS9
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
193 * can't get that high anyways, we only work with 3, and then use the offset
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
194 * partition value to bump it up beyond the 4 GB mark.
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
195 OS9PSN rmb 3 PSN of current OS9 sector (512 byte)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
196 DrivMask rmb 1 Drive # (0 or 1) for IDE (in proper bit position)
36
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
197 idecmd rmb 1 1 byte IDE command code
89
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
198 identcmd rmb 1 1 byte IDE Identify drive code
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
199
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
200 * Following flag is because the IDE interface can NOT access a 2nd drive
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
201 * while the 1st drive is completing a read or write. Because of shared
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
202 * device memory variables, this flag is set even on cached entries.
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
203 drvrbusy rmb 1 Driver busy flag (0=not busy)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
204
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
205 * Following for CHS mode drives only!
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
206 Head rmb 1 Head # (s/b base 0)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
207 Cylinder rmb 2 Cylinder #
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
208 CHSSect rmb 1 CHS mode sector #
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
209 CHSSPT rmb 2 CHS mode sectors/track
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
210
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
211 * Buffer/cache variables
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
212 LSN0Flag rmb 1 $FF=Not LSN0, $00=LSN0
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
213 Sect0Drv rmb 1 Drive # of LSN0 currently buffered ($FF=none)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
214 Sect0Ofs rmb 2 Offset value for current LSN0 buffered drive
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
215 TempHalf rmb 3 Temp spot to hold other half calculation
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
216 HalfDrv rmb 1 Drive # of HalfBuff buffered ($FF=none)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
217 HalfOfs rmb 2 Offset value for drive for current cached sector
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
218 HalfSct rmb 3 OS9 sector # of half sector not asked for
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
219 TempOfs rmb 2 Temporary copy of partition offset
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
220
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
221 * NOTE: When 8k block buffering is added, move both of these to that block.
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
222 * Of course, if removable media, re-read LSN0 physically every time. At that
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
223 * time, we should make tables here instead (32 entries per drive up to the
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
224 * maximum # of drives) of LSN #'s buffered (3 bytes/entry).
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
225 Sect0 rmb 256 Buffer for LSN0
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
226 HalfBuff rmb 256 Buffer for other half of 512 byte phys. sector
36
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
227 size equ .
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
228
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
229 fcb $FF mode byte
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
230
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
231 name fcs /CCIDE/ module name
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
232
89
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
233 * INIT - appears to only be called on 1ST try on ANY IDE device IF link counts
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
234 * are 0.
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
235 * Y = address of path descriptor (but
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
236 * U = address of driver memory (ie, of V.PAGE)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
237 * Inits the drive table, and the DriveFlg table
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
238 Init ldd #$8000+NUMDRIVE Flag that special drive flags are all unused
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
239 leax DriveFlg,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
240 DrvFlgLp sta ,x+
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
241 decb
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
242 bne DrvFlgLp
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
243 GoInit leax DRVBEG,u Point to start of drive tables
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
244 ldd #$FF00+NUMDRIVE
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
245 stb V.NDRV,u Max # of drives
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
246 sta Sect0Drv,u Flag that no LSN0 is buffered
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
247 sta HalfDrv,u Flag that we have no half sector buffered
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
248 NextDrv sta DD.TOT,x Set Total # of sectors to illegal value
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
249 sta V.TRAK,x Non 0, so 1st seek can read Track 0
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
250 leax DRVMEM,x Point to next drive
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
251 decb Dec # of drives left
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
252 bne NextDrv Still more, init them too
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
253 clrb No error & return
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
254 rts
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
255
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
256 * Do drive diagnostic (use CHS mode) - Do not worry about ATAPI at this point
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
257 * Entry: U=driver mem ptr
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
258 * Y=path descriptor
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
259 * B=Identify command
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
260 * Exit: CC clear - drive ready to send info
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
261 * CC set - error from drive, B contains raw error register
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
262 * TRASHES X - does timeout (CHECK - WILL SOME DRIVES TAKE TOO LONG?)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
263 * This is called by INIT, and should also be called by a GETSTAT at some
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
264 * point.
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
265 Ident pshs y Save path descriptor
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
266 stb identcmd,u Save which Ident we are doing
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
267 ldy V.PORT,u Get IDE controller address
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
268 DoIdent lda DrivMask,u Get drive # requested
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
269 ora #%10100000 Mask in head 0 & CHS mode
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
270 std DevHead,y Send drive/head to controller, and IDENTIFY
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
271 * Note, if person booting from ROM, drive may not have spun up yet. See if
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
272 * we can check some sort of status or error flag that indicates drive is
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
273 * still firing up, if this is a problem.
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
274 ldx #$a000 Arbitrary amount of time to give up
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
275 WaitIdnt lda Status,y Get Status register
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
276 bmi NoErr Busy, drop counter
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
277 bita #ErrorFnd Error?
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
278 beq NoErr No, continue
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
279 ldb Error,y Get error code
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
280 bra BadIdent
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
281
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
282 NoErr cmpa #DrvReady+SeekDone+DataReq Drive ready to send Identify data?
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
283 beq GotIdent Yep, exit out
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
284 leax -1,x Drop timer
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
285 bne WaitIdnt Keep trying
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
286 ldb #E$NotRdy Timed out, device not ready error
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
287 BadIdent coma Flag error
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
288 puls y,pc Restore path descriptor & return
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
289
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
290 GotIdent clrb No error
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
291 puls y,pc Restore path descriptor & return
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
292
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
293 * Send Identify drive command (ATA or ATAPI - see identcmd,u), update DriveFlg
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
294 * table
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
295 * PLEASE NOTE: The 2 identify commands are mutually exclusive; it will fail
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
296 * with an 'Aborted' error if the wrong Identify is used.
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
297 * UNLIKE A NORMAL READ OF A SECTOR, THE INFORMATION CONTAINED IN THE IDENTIFY
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
298 * DRIVE COMMAND IS ALL IN INTEL ORDER WORD (16 BITS)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
299 * Entry: Y=Ptr to path descriptor
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
300 * U=Ptr to driver memory
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
301 * X IS DESTROYED!
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
302 * Exit: CC=0 if DriveFlg properly updated
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
303 * & A=DriveFlg value from update entry in table
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
304 * CC=1, B=error if Identify Drive failed
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
305 * DriveFlg,u - the proper flags for the specified controller/drive are
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
306 * updated
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
307 * Sect0 contains 1st 256 bytes, HalfBuff contains 2nd half
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
308 IdentDrv lbsr WaitDrv Wait for IDE to be ready
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
309 ldb #Identify
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
310 bsr Ident Send identify drive command to controller
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
311 bcc DoInfo Worked, Do info
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
312 bitb #%00000100 Error, Aborted Flag set?
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
313 beq ExitIdnt No, exit with other error
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
314 ldb #PIIdent Try ATAPI identify
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
315 bsr Ident
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
316 bcs ExitIdnt That didn't work either, abort
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
317 DoInfo leax Sect0,u Point to buffer
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
318 * NOTE: INIT routine only gets called when the DRIVER is Initing...not every
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
319 * device. Hence, READ/WRITE must check the DriveFlg settings and make sure
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
320 * the hi bit is clear for the drive it is using, to indicate that it HAS
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
321 * been set properly from an Identify Drive command.
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
322 * Read in 1st 256 bytes of Identify Drive buffer, parse out info we need
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
323 * for our special flag table
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
324 lbsr Read256 Generic 256 byte copy from IDE routine
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
325 ldb #$FF Since we made it this far, flag that HalfBuff
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
326 stb HalfDrv,u & Sect0Drv are now bogus
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
327 stb Sect0Drv,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
328 clra Set current flags to all off
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
329 leax Sect0,u Point to start of buffer again
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
330 ldb ,x Get general config low byte
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
331 andb #%10000000 Removable cartridge bit set?
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
332 beq CheckLBA No, check LBA mode
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
333 ora #Remove Set removable media flag
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
334 CheckLBA ldb 99,x Get LBA mode byte
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
335 andb #%00000010 LBA allowed on this drive?
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
336 beq ChkATAPI No
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
337 ora #DrvMode Yes, set LBA flag
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
338 ChkATAPI ldb identcmd,u Get Identify drive command type
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
339 cmpb #PIIdent ATAPI?
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
340 bne SetFlg No, set drive flags
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
341 ora #ATAPI Set ATAPI flag
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
342 SetFlg ldb PD.DNS,y Get special settings flags
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
343 bitb #ForceCHS Force CHS mode on?
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
344 beq LeavAlon No
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
345 anda #^DrvMode Yes, force to CHS mode
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
346 LeavAlon ldb PD.DRV,y Get Logical drive #
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
347 leax DriveFlg,u Point to drive flags table
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
348 sta b,x Save flags
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
349 pshs a Save for exit
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
350 leax HalfBuff,u Point to 2nd buffer
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
351 lbsr Read256 Identify info part 2
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
352 lbsr WaitOK Make sure drive finished command
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
353 puls a Restore flags byte
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
354 ExitIdnt rts No error, return
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
355
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
356 * Entry: U=driver memory ptr
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
357 * Y=path descriptor ptr
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
358 GetStat ldx PD.RGS,y Get ptr to callers register stack
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
359 lda R$B,x Get function code
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
360 cmpa #SS.DrInf Drive info command?
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
361 bne NextGet No, try next
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
362 ldd R$Y,x Get sub-function type
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
363 beq GoodFunc
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
364 comb Only sub-functions 0 allowed for IDE
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
365 ifeq Level-2
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
366 ldb #E$IllArg
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
367 else
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
368 ldb #167
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
369 endc
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
370 ExitGet rts
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
371
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
372 GoodFunc pshs x,y,u Preserve regs
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
373 bsr IdentDrv Get either ATA or ATAPI Identify info
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
374 bcc GotInfo Something wrong, return
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
375 puls x,y,u,pc Restore regs, return with error
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
376
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
377 GotInfo leay Sect0,u Point to start of 512 byte buffer
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
378 ldx #256 # of two byte entries in buffer
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
379 SwapLoop ldd ,y Swap all words to Motorola order
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
380 exg a,b
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
381 std ,y++
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
382 leax -1,x
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
383 bne SwapLoop
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
384 leay Sect0,u Point to start of buffer again
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
385 ldx 114,y Get Current Capacity, swap to Motorola
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
386 ldd 116,y
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
387 stx 116,y
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
388 std 114,y
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
389 ldx 120,y Get LBA sector count, swap to Motorola
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
390 ldd 122,y
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
391 stx 122,y
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
392 std 120,y
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
393 ifeq Level-2
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
394 lda <D.SysTsk Get system task #
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
395 ldx <D.Proc Get user task ptr
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
396 ldb P$Task,x Get user's task #
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
397 leax Sect0,u Point to source buffer
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
398 ldu ,s Get ptr to PD.RGS
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
399 ldu R$X,u Get Destination ptr
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
400 ldy #512 Move 512 bytes to caller
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
401 os9 F$Move
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
402 else
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
403 endc
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
404 puls x,y,u Restore regs to normal
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
405 bcc SetUserR No error, set exit registers for caller
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
406 rts
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
407
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
408 SetUserR ldd #512 # of bytes returned=512 (Callers Y)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
409 std R$Y,x
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
410 clrb Device type=ATA
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
411 lda identcmd,u Get which Identify Drive command worked
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
412 cmpa #PIIdent ATAPI?
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
413 bne SaveType No, save ATA as type
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
414 incb
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
415 SaveType lda PD.DRV,y Get logical drive #
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
416 leay DriveFlg,u Point to drive flag table
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
417 lda a,y Get drive flags
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
418 std R$D,x Save drive flags & device type
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
419 clrb
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
420 rts
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
421
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
422 NextGet comb
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
423 ldb #E$UnkSvc
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
424 rts
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
425
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
426 SetStat clrb
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
427 rts
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
428
36
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
429 start lbra Init
89
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
430 lbra Read
36
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
431 lbra FWrite
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
432 lbra GetStat
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
433 lbra SetStat
89
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
434 clrb Term routine (does nothing)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
435 rts
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
436
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
437 NotBsy lda #$FF
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
438 sta drvrbusy,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
439 rts
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
440
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
441 * Checks if driver is busy, retries & possibly sleeps if it is.
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
442 * Set's driver to busy again when done.
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
443 * A reg is destroyed, all others are preserved
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
444 ChekBusy lda #64 # of fast retries for driver
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
445 BsyTst tst drvrbusy,u Is current driver/controller already in use?
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
446 beq NotBsy No, continue
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
447 deca
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
448 bne BsyTst Try up to 64 times
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
449 pshs x Otherwise, sleep a tick & try again
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
450 ldx #1
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
451 os9 F$Sleep
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
452 puls x
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
453 bra ChekBusy
36
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
454
89
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
455 * Save OS9 LSN & Physical PSN (not including any partition offset)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
456 * Also saves sector # of other half that is buffered
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
457 * Will have to add check later for ATAPI stuff, up to 2048 bytes/sector
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
458 * for CD ROM
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
459 * Entry: U=ptr to driver mem
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
460 * B:X=OS9 LSN
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
461 * Exit: B:X=OS9 LSN
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
462 * OS9PSN updated (512 byte Physical sector # that IDE needs)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
463 * TempHalf updated to cached LSN # (Use HalfDrv to figure out if legit
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
464 * or not)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
465 * TempOfs updated to current partition offset
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
466 * Zero flag set if LSN0 was requested (also saved at LSN0Flag,u)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
467 * PhysDrv set to physical drive #
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
468 SavLSN pshs b,x Save work copy of LSN
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
469 lda PD.DNS,y Make copy of physical drive #
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
470 anda #PhysDriv
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
471 sta PhysDrv,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
472 clra Flag: LSN0
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
473 stb OS9LSN,u Save OS-9 LSN
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
474 beq dox Could be LSN0
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
475 inca Not LSN0
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
476 dox stx OS9LSN+1,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
477 beq doPSN Is LSN0
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
478 inca Not LSN0
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
479 doPSN sta LSN0Flag,u Save LSN0 flag (0=Yes, anything else, no)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
480 stb OS9PSN,u Save OS-9 PSN
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
481 stx OS9PSN+1,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
482 lsr OS9PSN,u Divide LSN by 2 for PSN (512 bytes/sector)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
483 ror OS9PSN+1,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
484 ror OS9PSN+2,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
485 bcc Even Even sector requested, half will be odd (+1)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
486 * Subtract 1 from current LSN
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
487 ldd 1,s
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
488 subd #1
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
489 std 1,s
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
490 ldb ,s
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
491 sbcb #0
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
492 bra SaveExit
36
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
493
89
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
494 * Add 1 to current LSN
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
495 Even ldd 1,s
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
496 addd #1
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
497 std 1,s
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
498 ldb ,s
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
499 adcb #0
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
500 SaveExit ldx 1,s
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
501 stb TempHalf,u Save buffered sector #
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
502 stx TempHalf+1,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
503 leas 3,s Eat temp stack
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
504 ldx PD.DEV,y Get ptr to device table entry
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
505 ldx V$DESC,x Get device descriptor ptr
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
506 ldx PartOfs,x Get partition offset value
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
507 stx TempOfs,u Save copy of it
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
508 ldb OS9LSN,u Restore LSN
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
509 ldx OS9LSN+1,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
510 lda LSN0Flag,u Set CC bits for LSN0 compare
36
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
511 rts
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
512
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
513 * READ
89
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
514 * Entry: Y = address of path descriptor
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
515 * U = address of device memory (ie, of V.PAGE)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
516 * B = MSB of OS-9 disk LSN
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
517 * X = LSB of OS-9 disk LSN
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
518 * Eventually change LSN stuff to use a bit from descriptor as to whether
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
519 * buffered LSN0 or not. (After that, add in for general 8k block buffering
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
520 * or not).
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
521 * Later, add check for DriveFlg that sees if device has removable media. If
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
522 * not, and caching for each logical drive is done, keep PERMANENT copy of
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
523 * LSN0 at all times, and just copy it when requested (WRITE will update copy
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
524 * if new LSN0 is written).
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
525 * MAKE SURE WRITE ROUTINE UPDATES CACHING STUFF CORRECTLY!
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
526 Read lbsr ChekBusy Wait for driver to be unbusy
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
527 bsr SavLSN Save LSN/PSN, PartOfs & HalfSect info
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
528 bne NotLSN0 Not LSN0, skip ahead
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
529 * Theoretically, following REM'ed out lines will handle removable media:
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
530 * lda DriveFlg,u Get drive flag settings
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
531 * bita #Remove Removable media?
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
532 * bne NotLSN0 Yes, LSN0 may change from disk swap
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
533
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
534 * LSN0 - 1st see if buffered
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
535 lda PhysDrv,u Get requested physical drive #
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
536 cmpa Sect0Drv,u Same drive in LSN0 cache?
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
537 bne PhysRead No, go physically read off of drive
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
538 ldx TempOfs,u Get copy of partition offset
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
539 cmpx Sect0Ofs,u Same as cached LSN0 offset?
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
540 bne PhysRead No, physically read the sector
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
541 * LSN0 buffered goes here - later add check against DriveFlg with removable
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
542 * media bit - if non-removable, copy from cache, otherwise to physical read
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
543 leax Sect0,u Point to LSN0 cache
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
544 bra CopyBuff Copy to caller's PD.BUF, exit from there
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
545
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
546 * Not LSN0 - see if normal sector is currently cached.
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
547 * Entry: B:X=LSN
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
548 NotLSN0 cmpb HalfSct,u Same as cached sector?
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
549 bne PhysRead
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
550 cmpx HalfSct+1,u Same as cached sector?
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
551 bne PhysRead
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
552 lda PhysDrv,u Same drive as cached?
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
553 cmpa HalfDrv,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
554 bne PhysRead No, need physical read of sector
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
555 ldd TempOfs,u Get current request's Partition offset
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
556 cmpd HalfOfs,u Same as cached?
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
557 bne PhysRead No, physical read of sector
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
558 * Non-LSN0 sector is cached - if removable drive, force physical read unless
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
559 * we somehow monitor disk swaps (some media require Eject commands)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
560 leax HalfBuff,u Point to cached sector
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
561 * Copy sector from cache buffer to caller's buffer
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
562 * Entry: X=Ptr to cache buffer (either Sect0, or HalfBuff)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
563 CopyBuff clrb 256 counter
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
564 ldy PD.BUF,y Point to caller's buffer
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
565 CpyLoop lda ,x+ Copy it
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
566 sta ,y+
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
567 decb
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
568 bne CpyLoop
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
569 clr drvrbusy,u Flag driver not busy
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
570 rts
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
571
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
572 * Not buffered in any way - physical read required - update cache tags AFTER
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
573 * read, or flag with $FF if failed.
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
574 * Entry: Y=Ptr to path descriptor
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
575 * U=Driver mem
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
576 PhysRead lbsr InitRead Tell IDE to read sector
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
577 bcc DoRead No error, do read
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
578 FlagBad lda #$FF If IDE can't even initiate read, flag both
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
579 sta Sect0Drv,u LSN0 and HalfBuff as bad
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
580 sta HalfDrv,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
581 lbra RprtErr
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
582
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
583 * Entry: Y=path dsc. ptr
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
584 * U=Driver mem ptr
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
585 DoRead lda OS9LSN+2,u Get LSB of OS9 sector #
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
586 lsra Shift 1/2 512 sector flag out
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
587 bcs DoOdd Odd sector, buffer even one 1st
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
588 ldx PD.BUF,y Get pointer to caller's buffer
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
589 bsr Read256 Copy 1st half of HD sector there
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
590 leax HalfBuff,u Point to cache buffer
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
591 bsr Read256 Copy 2nd half of HD sector there
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
592 bra FinRead Finish the Read command on IDE
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
593
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
594 * Copy to cache 1st (Odd sector # request)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
595 DoOdd leax HalfBuff,u Point to cache buffer
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
596 bsr Read256 1st half goes there
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
597 ldx PD.BUF,y Get pointer to caller's buffer
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
598 bsr Read256 2nd half goes there
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
599 FinRead lbsr WaitOK Wait for drive to complete command
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
600 bcc DoneRead No error, exit
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
601 lbra RprtErr Exit with error
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
602
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
603 * Update HalfSct vars to whatever is in TempHalf
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
604 GoodCach ldd TempHalf,u Copy Buffered LSN to HalfSct
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
605 std HalfSct,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
606 lda TempHalf+2,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
607 sta HalfSct+2,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
608 ldd TempOfs,u Get partition offset
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
609 std HalfOfs,u Save it
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
610 lda PhysDrv,u Copy drive # to HalfDrv
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
611 sta HalfDrv,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
612 rts
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
613
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
614 * Entry: Read command complete on IDE.
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
615 * Y=ptr to path descriptor
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
616 * U=ptr to driver mem
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
617 DoneRead bsr GoodCach Update HalfSct stuff with Temp stuff
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
618 ldb LSN0Flag,u Was this LSN0?
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
619 bne GoodExit No, leave
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
620 * LSN0 just physically read - update drive table
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
621 * CHANGE EVENTUALLY TO CHECK IF NON-REMOVABLE MEDIA; IF IT IS, DON'T BOTHER
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
622 * WITH THESE CHECKS!
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
623 sta Sect0Drv,u Save which drive LSN0 is buffered
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
624 ldd TempOfs,u Restore partition offset again
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
625 std Sect0Ofs,u Save for LSN0
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
626 leax Sect0,u Point to LSN0 buffer
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
627 clrb 256 counter
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
628 pshs y Save path dsc. ptr
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
629 ldy PD.BUF,y Point to caller's buffer
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
630 LSN0Loop lda ,y+ Copy LSN0 from callers buffer to LSN0 cache
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
631 sta ,x+
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
632 decb
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
633 bne LSN0Loop
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
634 puls y Restore path dsc. ptr
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
635 leax Sect0,u Point to LSN0 cache again
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
636 CopyTbl1 lbsr CpyDrvTb Copy LSN0 stuff to drive table
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
637 GoodExit clr drvrbusy,u No error & return
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
638 rts
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
639
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
640 * Initiate the 512 byte READ sequence
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
641 * Entry: U=Driver mem ptr
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
642 * Y=Path dsc. ptr (?)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
643 * Exit: CC=0 if no error
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
644 * CC=1 if error
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
645 * B=Error code
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
646 InitRead ldb #ReadRtry Read sector (with retry) IDE command
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
647 lbra SetIDE Send to IDE, return from there (w or w/o err)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
648
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
649 * Copy 256 bytes of data from IDE controller (after READ, etc.)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
650 * Entry: X=ptr to 256 byte destination buffer
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
651 * U=ptr to driver memory
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
652 * Exit: 256 bytes copied
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
653 * B is destroyed, A=0
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
654 * Y is preserved
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
655 Read256 lda #$20 # of loops (of 8 bytes)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
656 pshs y,a Save y & counter
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
657 ldy V.PORT,u Get ptr to IDE controller for this drive
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
658 ReadLp lda ,y Get 16 bits of data, and save in buffer, 8
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
659 ldb Latch,y times
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
660 std ,x
36
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
661 lda ,y
89
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
662 ldb Latch,y
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
663 std 2,x
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
664 lda ,y
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
665 ldb Latch,y
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
666 std 4,x
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
667 lda ,y
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
668 ldb Latch,y
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
669 std 6,x
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
670 leax 8,x Bump ptr up
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
671 dec ,s Done all bytes?
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
672 bne ReadLp No, keep going
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
673 puls a,y,pc Restore Y & return
36
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
674
89
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
675 * WRITE - Can use cache data, or preread sector
36
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
676 * Y = address of path descriptor
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
677 * U = address of device memory (ie, of V.PAGE)
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
678 * B = MSB of OS-9 disk LSN
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
679 * X = LSB of OS-9 disk LSN
89
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
680 * 1st , see if other half is buffered in HalfBuff
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
681 FWrite lbsr ChekBusy Wait for driver to be unbusy
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
682 lbsr SavLSN Save LSN info, set LSN0Flag for later
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
683 ldb TempHalf,u Get OS9 LSN of 'other half' of 512 byte sector
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
684 cmpb HalfSct,u Same MSB of buffered sector #?
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
685 bne ChkLSN1 No, check if LSN1
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
686 ldx TempHalf+1,u LSW of 'other half'
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
687 cmpx HalfSct+1,u Same as LSW of buffered sector #?
1264
64a0273a846a Case fixes, etc.
boisy
parents: 1117
diff changeset
688 bne ChkLSN1 No, check if LSN1
89
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
689 ldd HalfOfs,u Same partition as buffered sector's drive?
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
690 cmpd TempOfs,u
1264
64a0273a846a Case fixes, etc.
boisy
parents: 1117
diff changeset
691 bne ChkLSN1 No, check if LSN1
89
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
692 lda PhysDrv,u Same physical drive as buffered sector's drive?
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
693 cmpa HalfDrv,u Same as buffered sector's drive?
1264
64a0273a846a Case fixes, etc.
boisy
parents: 1117
diff changeset
694 bne ChkLSN1 No, check is LSN1
89
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
695 * Buffered sector IS the other half of current write sector...no preread nec-
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
696 * essary.
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
697 lbsr InitWrit Send Write command to IDE, setup mode, etc.
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
698 bcc GoodWrit No problems, continue with Write
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
699 lbra FlagBad Flag caches as bad, exit with error
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
700
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
701 * See if request is for LSN1, in which case we may have LSN0 buffered
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
702 ChkLSN1 ldb OS9LSN,u Get MSB of sector to write
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
703 bne PreRead Not 0, need physical preread
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
704 ldx OS9LSN+1,u Get LSW of sector to write
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
705 cmpx #1 LSN=1?
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
706 bne PreRead Not LSN1, need to preread sector
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
707 lda PhysDrv,u Get physical drive #
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
708 cmpa Sect0Drv,u Same as buffered LSN0?
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
709 bne PreRead No, need physical preread
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
710 ldd TempOfs,u Get partition offset of requested sector
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
711 cmpd Sect0Ofs,u Same as buffered?
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
712 bne PreRead
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
713 * We have LSN0 buffered for an LSN1 write
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
714 lbsr InitWrit Send Write to IDE
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
715 bcc ContWrt1 Successful, continue
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
716 lbra RprtErr
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
717
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
718 ContWrt1 leax Sect0,u Point to buffered Sector 0
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
719 bsr Write256 Write to IDE
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
720 ldx PD.BUF,y Get ptr to caller's LSN1 buffer
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
721 bsr Write256 Write to IDE
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
722 bra FinWrite Complete the write command
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
723
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
724 * Nothing buffered, pre-read sector in so we have other half to write.
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
725 * Note that OS9PSN is already set to the correct physical sector.
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
726 PreRead lbsr InitRead Send Read command to IDE
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
727 bcc GotPreRd No problem, continue
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
728 lbra FlagBad Flag caches as bad; exit with error
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
729
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
730 GotPreRd lda OS9LSN+2,u Get least sig. byte of LSN to write
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
731 lsra Odd or even sector?
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
732 bcc ReadOdd Even write sector requested
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
733 * Odd write requested
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
734 leax HalfBuff,u Point to 1/2 sector cache
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
735 lbsr Read256 Read it in
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
736 bsr Eat256 Bleed off other half (not needed)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
737 bra FinPre
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
738
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
739 * Even sector to write - buffer odd one
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
740 ReadOdd bsr Eat256 Bleed 1st half
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
741 leax HalfBuff,u Read in 2nd half
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
742 lbsr Read256
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
743 FinPre lbsr WaitOK Get OK from controller
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
744 bcc DonePre Good, continue
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
745 BadExit lbra RprtErr Error, exit with it
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
746
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
747 DonePre lbsr GoodCach Update HalfSct stuff only
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
748 lbsr InitWrit Initialize Write command
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
749 bcs BadExit
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
750 * Now, onto the write
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
751 GoodWrit ldb OS9LSN+2,u Get least sig. byte of LSN
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
752 lsrb Odd or even sector to write?
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
753 bcs BuffWOdd Write fully buffered Odd
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
754 * We are writing even portion, odd is in cache
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
755 ldx PD.BUF,y Get ptr to caller's 256 byte buffer
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
756 bsr Write256 Write to IDE
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
757 leax HalfBuff,u Point to cached sector
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
758 bsr Write256 Write to IDE
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
759 bra FinWrite
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
760
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
761 BuffWOdd leax HalfBuff,u Point to cached sector
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
762 bsr Write256 Write to IDE
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
763 ldx PD.BUF,y Point to caller's 256 byte buffer
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
764 bsr Write256 Write to IDE
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
765 FinWrite lbsr WaitOK Wait for IDE to be done command
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
766 bcc DoneWrit No error, done writing
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
767 lbra RprtErr Error, exit with it
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
768
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
769 * Write 256 bytes from ,x to IDE
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
770 * Entry: X=ptr to 256 buffer to write
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
771 * U=driver mem ptr
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
772 * Exit: 256 bytes written
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
773 * B is destroyed, A=0
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
774 * X=end of buffer+1
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
775 * Y is preserved
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
776 Write256 lda #$20 # of 8 byte loops
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
777 pshs y,a Save Y & loop counter
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
778 ldy V.PORT,u Get IDE base address
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
779 WritLp ldd ,x Copy 256 bytes from buffer to IDE
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
780 stb Latch,y
36
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
781 sta ,y
89
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
782 ldd 2,x
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
783 stb Latch,y
36
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
784 sta ,y
89
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
785 ldd 4,x
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
786 stb Latch,y
36
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
787 sta ,y
89
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
788 ldd 6,x
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
789 stb Latch,y
36
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
790 sta ,y
89
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
791 leax 8,x
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
792 dec ,s
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
793 bne WritLp
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
794 puls a,y,pc Restore regs & return
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
795
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
796 * Eat 256 bytes from IDE (hopefully, triggering latch will skip having to
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
797 * read even bytes)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
798 * Entry: U=driver memory ptr
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
799 * Y=Path descriptor ptr
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
800 * Exit: 256 bytes bled off of sector buffer on IDE
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
801 * All regs preserved
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
802 Eat256 pshs d,x Save regs
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
803 ldb #$20 32 loops
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
804 ldx V.PORT,u Get pointer to IDE
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
805 EatLp lda ,x Read seems to be a pre-trigger
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
806 lda ,x Eat each 16 bit trigger byte
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
807 lda ,x
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
808 lda ,x
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
809 decb
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
810 bne EatLp
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
811 puls d,x,pc Restore regs & return
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
812
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
813 * Write command to IDE completed successfully
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
814 * Update cache (copy PD.BUF to Cache if even sector, so a sequential
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
815 * write will have the 1st half cached, or leave current cache alone if
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
816 * odd). Also, check if LSN0. If it is, copy to LSN0 cache, updating
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
817 * vars, and copy drive table info
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
818 DoneWrit ldb LSN0Flag,u Was it sector 0?
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
819 beq WritLSN0 Yes, special processing for that
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
820 ldb OS9LSN+2,u Get LSB of sector #
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
821 lsrb Odd/Even?
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
822 bcc CpyCache Even, copy to Cache
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
823 * Odd sector written, leave cache as is
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
824 clr drvrbusy,u Exit without error
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
825 rts
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
826
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
827 * Copy PD.BUF sector to HalfBuff cache, update cache tags
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
828 CpyCache lda PhysDrv,u Set cache vars for PD.BUF sector
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
829 sta HalfDrv,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
830 ldd TempOfs,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
831 std HalfOfs,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
832 ldd OS9LSN,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
833 std HalfSct,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
834 lda OS9LSN+2,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
835 sta HalfSct+2,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
836 leax HalfBuff,u Point to 1/2 sector cache
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
837 CachBuff clrb
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
838 ldy PD.BUF,y Get ptr to callers buffer
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
839 CachLp lda ,y+ Copy even sector to cache (in case of sequential
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
840 sta ,x+ writes)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
841 decb
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
842 bne CachLp
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
843 clr drvrbusy,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
844 rts
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
845
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
846 * We wrote LSN0 - 1st, update LSN0 cache tags, then copy PD.BUF to Sect0,
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
847 * then update drive table entry.
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
848 * Entry: U=drive mem ptr
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
849 * Y=path dsc. ptr
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
850 WritLSN0 lda PhysDrv,u Copy cache tag stuff for Sect0 cache
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
851 sta Sect0Drv,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
852 ldd TempOfs,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
853 std Sect0Ofs,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
854 leax Sect0,u Point to LSN0 cache
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
855 bsr CachBuff Copy from PD.BUF to Sect0 buff
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
856 leax Sect0,u Point to LSN0 cache again
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
857 clr drvrbusy,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
858 lbra CpyDrvTb Copy info to drive table, exit from there
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
859
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
860 * Initialize Write sequence to IDE
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
861 * Entry: U=driver mem ptr
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
862 * Y=Ptr to path descriptor
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
863 * Exits back to calling routine. CC=0 if command ready on controller
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
864 * CC=1, B=Raw IDE error code if command failed
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
865 InitWrit ldb #WritRtry IDE Write w/ Retry command
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
866 bra SetIDE Send to IDE, return from there w or w/o error
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
867
36
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
868 * After read or write, check drive status
89
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
869 * Exit: CC=0, command ok, CC=1, Error from IDE (B=Raw error code)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
870 * X=Ptr to hardware address
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
871 WaitOK ldx V.PORT,u Get status register
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
872 WaitLp tst Status,x Still busy, wait till unbusy
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
873 bmi WaitLp
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
874 lda #ErrorFnd Check Error flag
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
875 bita Status,x Error from controller?
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
876 bne RprtErr Yes, go get error
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
877 clrb No, exit without error
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
878 rts
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
879
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
880 * Entry: B=Error code from IDE
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
881 RprtErr lsrb
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
882 bcc ChkTk0
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
883 SctrExit ldb #E$Sect Bad sector # for Addres Mark Not Found
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
884 bra ExitErr
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
885
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
886 ChkTk0 lsrb
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
887 bcc ChkMdChg
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
888 SeekExit ldb #E$Seek Seek error for Track 0 not found
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
889 bra ExitErr
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
890
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
891 ChkMdChg lsrb
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
892 bcc ChkAbrt
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
893 MdChExit ldb #E$DIDC Media changed error
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
894 bra ExitErr
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
895
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
896 ChkAbrt lsrb
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
897 bcc ChkIdnf
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
898 ldb #E$UnkSvc Unknown service error for aborted command
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
899 bra ExitErr
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
900
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
901 ChkIdnf lsrb
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
902 bcs SctrExit Sector error for ID not found
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
903 lsrb
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
904 bcs MdChExit Media changed error for Media Change
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
905 lsrb
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
906 bcc ChkBBK
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
907 ldb #E$CRC CRC Error for Uncorrectable data
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
908 bra ExitErr
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
909
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
910 ChkBBK lsrb
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
911 bcs ReadExit Read error for Bad Block Detected
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
912 * Error flag set, but no error condition
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
913 lbra ENotRdy Assume drive not ready
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
914
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
915 ReadExit ldb #E$Read
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
916 ExitErr clr drvrbusy,u Flag driver not busy
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
917 coma Set carry & exit
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
918 rts
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
919
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
920 BadUnit ldb #E$Unit
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
921 bra ExitErr
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
922
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
923 CmdErr ldb Error,x Get Error register
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
924 bra RprtErr
36
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
925
89
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
926 * Send IDE command (read or write)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
927 * Entry: B = IDE command code
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
928 * Y = address of path descriptor
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
929 * U = address of device memory (ie, of V.PAGE)
36
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
930 * trashes D and X
89
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
931 * Exit: CC=0 if command exited with data ready on controller
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
932 * CC=1, B=error if problem.
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
933 SetIDE stb idecmd,u Save copy of IDE command
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
934 ldb PD.DRV,y Get logical drive #
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
935 cmpb #NUMDRIVE Within range?
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
936 bhs BadUnit No, exit with error
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
937 leax DriveFlg,u Point to special drive flags table
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
938 lda b,x Get flags for our drive
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
939 bpl TblReady Properly initialized, figure out mode
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
940 lbsr IdentDrv NOT Initialized, get mode info
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
941 bcs CmdErr Error doing IDENTIFY DRIVE command, exit
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
942 TblReady anda #DrvMode Just need CHS/LBA mode for now
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
943 bne DoLBA LBA mode, go do
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
944 * Do CHS mode
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
945 ldd PD.SCT,y Get # of OS9 (256) sectors/track
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
946 lsra Convert to 512 byte sectors/track
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
947 rorb
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
948 std CHSSPT,u Save for Calc routine
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
949 ldx PD.DTB,y Get pointer to device table
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
950 lbsr CalcCHS Go calculate cyl/head/sector stuff
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
951 bcs CmdErr Error calculating, exit
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
952 lbsr WaitDrv Go wait for the drive (preserves y)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
953 bcs CmdErr Error waiting for drive, exit
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
954 * Do sector #, then Drive/Head, then Cyl, then sector count, then command
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
955 pshs y Save path descriptor ptr
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
956 ldy V.PORT,u Get IDE hardware address
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
957 lda CHSSect,u Get IDE sector #
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
958 sta SectNum,y Save to controller
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
959 lda Head,u Get IDE head #
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
960 ora #%10100000 Set CHS mode
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
961 ora DrivMask,u Merge drive #
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
962 sta DevHead,y Save to controller
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
963 ldd Cylinder,u Get 16 bit cylinder # (4095 max)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
964 addd TempOfs,u Add partition offset cylinder
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
965 bcs SeekErr If it overflowed, SEEK error
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
966 sta CylHigh,y Save to controller
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
967 stb CylLow,y
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
968 bra SendCmd Send sector count & IDE command
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
969
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
970 * Do LBA mode IDE command here
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
971 DoLBA bsr WaitDrv Wait for controller to be ready
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
972 pshs y Save path descriptor ptr
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
973 ldy V.PORT,u Get IDE hardware address
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
974 * Copy LBA sector # to controller, including device/head (LBA 24-27)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
975 ldd OS9PSN+1,u Get bits 0-15 of PSN
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
976 stb SectNum,y Save bits 0-7
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
977 sta CylLow,y Save bit 8-15
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
978 clra
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
979 ldb OS9PSN,u D=PSN bits 16-23 (24 & up set to 0 for OS9)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
980 addd TempOfs,u Add partition offset cylinder
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
981 cmpa #$0f Overflow past LBA bits?
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
982 bhi SeekErr Yes, SEEK error
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
983 stb CylHigh,y Save bits 16-23
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
984 ora #%11100000 Set LBA mode
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
985 ora DrivMask,u Merge drive #
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
986 sta DevHead,y Save to controller
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
987 * Send sector count (1) & command to controller, get results
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
988 SendCmd ldx #MAXWAIT Get # 1/60th sec. ticks to wait on drive
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
989 stx SlpCntr,u Save it for sleep routine (if needed)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
990 ldd #$0140 Sector count to 1, fast retry to 64 tries
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
991 sta SectCnt,y Send to controller
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
992 lda idecmd,u Get command to send
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
993 sta Command,y Send to controller
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
994 CmdLp lda Status,y Get status of drive command
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
995 bmi CmdLp IDE still busy, no other bits are valid
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
996 bita #ErrorFnd Not busy anymore, is there an error?
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
997 bne TransErr Yes, figure out what (don't forget to PULS Y!)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
998 bita #DataReq Is data ready for us yet?
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
999 bne CmdDone Yes, exit
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1000 decb Dec counter
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1001 bne CmdLp Keep trying
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1002 ldx SlpCntr,u Get sleep tick counter
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1003 leax -1,x Drop it by one
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1004 beq NoWay Done count, give up with device not ready error
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1005 stx SlpCntr,u Save new sleep counter
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1006 ldx #1 Fast retry didn't work, sleep a tick
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1007 os9 F$Sleep
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1008 ldb #$40 64 fast retries again
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1009 bra CmdLp Try again
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1010
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1011 SeekErr lbsr SeekExit Seek error & exit
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1012 puls y,pc
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1013
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1014 NoWay puls y
36
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
1015 bra ENotRdy
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
1016
89
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1017 TransErr lbsr CmdErr Get error code
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1018 puls y,pc Exit with it, restore path dsc. ptr
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1019
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1020 CmdDone clrb Command complete, return with no error
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1021 puls y,pc Restore path dsc. ptr
36
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
1022
89
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1023 * Wait for IDE controller to be ready
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1024 * Entry: Y=path dsc. ptr
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1025 * U=driver mem ptr
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1026 * Exit: CC=0 - controller ready for command
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1027 * CC=1 - Error message in B
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1028 * DrivMask,u - contains drive # bit ready for IDE masking
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1029 * PRESERVES X&Y
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1030 WaitDrv pshs x,y Preserve regs
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1031 ldx #$A000 (1/2 to 1/3 second busy check)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1032 lda PD.DNS,y Get physical drive #
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1033 anda #PhysDriv No bad drive # possible
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1034 lsla Move drive # into proper bit for Drive/head
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1035 lsla
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1036 lsla
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1037 lsla
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1038 sta DrivMask,u Save drive mask for IDE
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1039 ldy V.PORT,u Get controller address for drive selected
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1040 RdyIni1 tst Status,y IDE busy?
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1041 bpl IDEReady No, return
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1042 leax -1,x Dec counter
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1043 bne RdyIni1 Try again
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1044 puls x,y Restore regs
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1045 ENotRdy clr drvrbusy,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1046 comb Tried too long; give up with error
36
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
1047 ldb #E$NotRdy
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
1048 rts
89
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1049
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1050 IDEReady puls x,y Restore regs
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1051 clrb IDE ready, return
36
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
1052 rts
89
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1053
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1054 * Copy LSN0 stuff into drive table
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1055 * Entry: X=ptr to 256 byte buffer containing LSN0 Sector.
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1056 * Exit: X,D is destroyed
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1057 CpyDrvTb pshs y Save path desc. ptr
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1058 ldb PD.DRV,y Get LOGICAL drive #
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1059 lda #DRVMEM Copy useful information to our LSN 0 buffer
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1060 mul Point to proper entry in drive table
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1061 leay DRVBEG,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1062 leay d,y
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1063 lda #DD.SIZ
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1064 LSN0Cp ldb ,x+
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1065 stb ,y+
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1066 deca
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1067 bne LSN0Cp
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1068 puls y,pc Restore path desc. ptr & return
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1069
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1070 * Notes: PhysSN is the physical sector number to send to the controller,
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1071 * not the LSN...so it must be translated from the LSN (for IDE, divide by
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1072 * 2, unless using ATAPI CDROM, in which case divide by 8).
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1073 * Note that the head returned from this routine is base 0, so that the
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1074 * lowest head # returned would be 0 (for the first head). This matches
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1075 * the IDE spec (which can also only go up to 16 heads).
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1076 * The cylinder returned is also base 0, same as IDE.
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1077 * The sector returned is base 0, but IDE needs base 1.
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1078 * Vars used from elsewhere - OS9PSN,u - Physical (IDE 512) sector #
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1079 * - Head,u - IDE head #
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1080 * - Cylinder,u - IDE Cylinder #
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1081 * - CHSSect,u - IDE sector (512) #
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1082 * - CHSSPT,u - IDE (512 byte) sctrs/track)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1083
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1084 * LSN division routine variable definitions: all on temp stack
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1085 org 0
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1086 S.SclPwr rmb 2 scale power
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1087 S.SclAmt rmb 3 scale amount
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1088 S.Cyl rmb 2 cylinder number
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1089 S.PSN rmb 3 physical sector number (work copy)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1090 S.Head rmb 1 head number
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1091 S.Frame equ . size of stack frame
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1092
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1093 * Entry: U=ptr to driver data area
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1094 * Y=Ptr to path descriptor
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1095 * X=Ptr to current drives' entry in drive table (DD.TOT, etc.)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1096 * OS9PSN,u- Three byte Physical (512 byte) sector #)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1097 * Exit: U=ptr to driver data area
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1098 * Y=ptr to path descriptor
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1099 * X=Drive table ptr
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1100 * Head,u=Head # in CHS mode
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1101 * Cylinder,u=Cylinder # in CHS mode
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1102 * CHSSect,u=Sector # in CHS mode
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1103 * CC=0, no error, above 3 vars. are legit
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1104 * CC=1, error, error return in B
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1105 CalcCHS leas -S.Frame,s make room for LSN division variables
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1106 ldb OS9PSN,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1107 stb S.PSN,s initialize PSN MSB
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1108 ldd OS9PSN+1,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1109 std S.PSN+1,s initialize PSN LSBs
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1110 ldd #$0000
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1111 sta S.Head,s initialize head number
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1112 std S.Cyl,s initialize cylinder number
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1113 ldd S.PSN+1,s get PSN LSBs
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1114 subd CHSSPT,u less sectors/track
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1115 bhs NotTrk0
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1116 tst S.PSN,s PSN MSB = 0?
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1117 beq DivDone yes, sector in track 0, go save info
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1118 dec S.PSN,s PSN MSB less 1
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1119 NotTrk0 std S.PSN+1,s save remaining PSN LSBs
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1120 inc S.Head,s set to next head (1)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1121 inc V.TRAK+1,x mark track as non-0 for SetUpWD
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1122 ldb CHSSPT+1,u get IDE sectors per track
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1123 lda PD.SID,y Get # of disk heads
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1124 deca less track 0
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1125 mul calculate sectors remaining in cylinder 0
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1126 std S.SclPwr,s save it temporarily
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1127 ldd S.PSN+1,s get remaining PSN LSBs
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1128 subd S.SclPwr,s less sectors remaining in cylinder 0
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1129 bhs NotCyl0
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1130 tst S.PSN,s remaining PSN MSB = 0?
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1131 beq CalcHead sector in cylinder 0, go get head number
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1132 dec S.PSN,s remaining PSN MSB less 1
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1133 NotCyl0 std S.PSN+1,s save remaining PSN LSBs
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1134 inc S.Cyl+1,s set cylinder to 1
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1135 clr S.Head,s reset head number to 0
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1136 lda PD.SID,y get disk sides
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1137 ldb CHSSPT+1,u get sectors per track
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1138 NrmlDiv clr S.SclAmt+2,s initialize scale amount LSB
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1139 lsla HD prescale = heads x 8
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1140 lsla This is the max we can do with a 16 head
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1141 lsla drive, using 8 bit MUL.
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1142 mul calculate scale amount MSBs
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1143 std S.SclAmt,s save scale amount MSBs
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1144 ldd #HDSclPwr Set hard drive scale power
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1145 std S.SclPwr,s save scale power
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1146 DivLoop lda S.PSN,s get remaining PSN MSB
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1147 cmpa S.SclAmt,s remaining PSN > scale amount?
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1148 blo DivLoop1 no, go set up next scale amount & power
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1149 bhi DivLoop2 yes, go do subtraction
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1150 ldd S.PSN+1,s get remaining PSN LSBs
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1151 subd S.SclAmt+1,s remaining PSN >= scale amount?
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1152 blo DivLoop1 no, go set up next scale amount & power
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1153 std S.PSN+1,s save remaining PSN LSBs
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1154 bra DivLoop3
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1155
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1156 DivLoop2 ldd S.PSN+1,s get remaining PSN LSBs
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1157 subd S.SclAmt+1,s less scale amount LSBs
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1158 std S.PSN+1,s save remaining PSN LSBs
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1159 DivLoop3 lda S.PSN,s get remaining PSN MSB
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1160 sbca S.SclAmt,s less scale amount MSB and borrow (if any)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1161 sta S.PSN,s save remaining PSN MSB
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1162 ldd S.Cyl,s get cylinder number
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1163 addd S.SclPwr,s add scale power
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1164 std S.Cyl,s save cylinder number
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1165 DivLoop1 lsr S.SclAmt,s * divide scale amount by two
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1166 ror S.SclAmt+1,s
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1167 ror S.SclAmt+2,s
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1168 lsr S.SclPwr,s * divide scale power by two
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1169 ror S.SclPwr+1,s
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1170 bcc DivLoop
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1171 CalcHead ldd S.PSN+1,s get remaining PSN LSBs
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1172 NextHead subd CHSSPT,u less sectors per track (head)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1173 blo DivDone underflow, go save info
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1174 std S.PSN+1,s save remaining PSN LSBs
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1175 inc S.Head,s increment head number
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1176 bra NextHead
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1177
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1178 DivDone ldd S.Cyl,s get cylinder number
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1179 cmpd PD.CYL,y cylinder number OK?
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1180 bhs LSNErrSF no, go return error
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1181 std Cylinder,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1182 lda S.PSN+2,s get sector number (remaining PSN LSB)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1183 inca IDE needs base 1
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1184 sta CHSSect,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1185 ldb S.Head,s get head number
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1186 stb Head,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1187 leas S.Frame,s restore stack pointer
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1188 clrb
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1189 rts
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1190
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1191 LSNErrSF leas S.Frame,s restore stack pointer
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1192 LSNErr comb
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1193 ldb #E$Sect Exit with Bad sector # error
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1194 rts
36
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
1195
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
1196 emod
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
1197 eom equ *
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
1198 end