annotate 3rdparty/drivers/ide/ccide.asm @ 89:2727056db0d3

Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
author boisy
date Thu, 27 Jun 2002 18:10:41 +0000
parents 8b423669e5d2
children 16dc49e3a104
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
89
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1 * 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
2 * 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
3 * codes.
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
4 * 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
5 * 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
6 * 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
7 * 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
8 * 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
9 * time.
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
10 * 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
11 * 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
12 * _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
13 * 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
14 * 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
15 * 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
16 * 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
17 * 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
18 * EXAMPLE, ON MY MINISCRIBE 8051A:
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
19 * 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
20 * 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
21 * 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
22 * 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
23 * 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
24 * 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
25 * 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
26 * 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
27 * 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
28 * 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
29 * 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
30 * 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
31 * 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
32 * 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
33 * 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
34 * 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
35 * 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
36 * reports.
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
37 * 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
38 * 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
39 * 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
40 * 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
41 * 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
42 * 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
43 * 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
44 *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
45 * 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
46 * 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
47 * 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
48 * 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
49 * FLAG IF IT DOES NOT).
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
50 * 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
51 * 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
52 * 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
53 * TAKE CARE OF MULTIPLE CONTROLLERS.
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
54 * 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
55 * 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
56 * 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
57 * 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
58 * 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
59 * 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
60 * 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
61 * 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
62 * 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
63 * 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
64 * 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
65 * 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
66 ********************************************************************
89
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
67 * DO NOT FORGET TO SET H6309 FLAG IN DEFSFILE APPROPRIATELY FOR 6809 VS.
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
68 * 6309 CODE WHEN ASSEMBLING!!
36
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
69 * CCIDE - 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
70 *
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
71 * $Id$
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
72 *
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
73 * Driver originally from Jim Hathaway, originally 8-bit only
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
74 * Converted to 16 bit by Alan DeKok
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
75 * Disassembled (OK, so I didn't have the source version at first!)
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
76 * by Eddie Kuns, ATA specs followed carefully and sector buffering
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
77 * on writes handled more carefully
89
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
78 * This driver uses 16-bit transfers *only*
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
79 * Check with Glenside - can we switch to 16 bit only, so there is less to
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
80 * maintain? With the cacheing stuff, the speed is fairly decent, although
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
81 * some 6309 optomizations are still possible (cache copies, drive table
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
82 * copies, hardware divide for CHS translation, etc.)
36
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
83 *
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
84 * 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
85 * ------------------------------------------------------------------
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
86 * 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
87 * 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
88 * 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
89 * minor optimizations, added symbols
89
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
90 * 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
91 * 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
92 * better error reporting
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
93 * slightly optomized read
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
94 * 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
95 * 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
96 * 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
97 * 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
98 * 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
99 * 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
100 * Change)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
101 * 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
102 * Constants - change if needed
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
103 * 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
104 * 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
105 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
106 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
107 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
108
89
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
109 * New definitions in Device Descriptor
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
110 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
111
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
112 * Definitions for DD.DNS
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
113 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
114 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
115
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
116 * New GetStat/SetStat calls:
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
117 * 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
118 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
119 * 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
120 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
121
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
122 * 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
123 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
124 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
125 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
126 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
127 DoorLock equ $DE Lock drive
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
128 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
129 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
130
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
131 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
132
89
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
133 * IDE Status Register
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
134 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
135 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
136 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
137 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
138 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
139 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
140 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
141 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
142
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
143 * IDE hardware offsets
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
144 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
145 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
146 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
147 SectCnt equ 2 Sector count
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
148 SectNum equ 3 Sector #
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
149 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
150 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
151 DevHead equ 6 Device/Head
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
152 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
153 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
154 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
155
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
156 * 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
157 * DriveFlg,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
158 * 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
159 * 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
160 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
161 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
162 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
163 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
164 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
165 * 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
166 nam CCIDE
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
167 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
168
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
169 ifp1
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
170 use defsfile
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
171 endc
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
172
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
173 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
174 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
175 rev set $01
89
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
176 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
177
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
178 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
179
89
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
180 * 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
181 * 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
182
36
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
183 org 0
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
184 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
185 * 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
186 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
187 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
188 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
189 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
190 * 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
191 * 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
192 * 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
193 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
194 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
195 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
196 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
197
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
198 * 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
199 * 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
200 * 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
201 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
202
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
203 * 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
204 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
205 Cylinder rmb 2 Cylinder #
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
206 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
207 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
208
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
209 * Buffer/cache variables
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
210 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
211 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
212 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
213 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
214 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
215 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
216 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
217 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
218
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
219 * 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
220 * 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
221 * 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
222 * 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
223 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
224 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
225 size equ .
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
226
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
227 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
228
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
229 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
230 fcb edition module edition
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
231
89
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
232 * 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
233 * are 0.
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
234 * 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
235 * 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
236 * 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
237 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
238 leax DriveFlg,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
239 DrvFlgLp sta ,x+
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
240 decb
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
241 bne DrvFlgLp
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
242 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
243 ldd #$FF00+NUMDRIVE
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
244 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
245 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
246 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
247 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
248 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
249 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
250 decb Dec # of drives left
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
251 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
252 clrb No error & return
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
253 rts
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
254
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
255 * 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
256 * Entry: U=driver mem ptr
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
257 * Y=path descriptor
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
258 * B=Identify command
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
259 * 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
260 * 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
261 * 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
262 * 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
263 * point.
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
264 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
265 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
266 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
267 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
268 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
269 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
270 * 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
271 * 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
272 * 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
273 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
274 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
275 bmi NoErr Busy, drop counter
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
276 bita #ErrorFnd Error?
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
277 beq NoErr No, continue
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
278 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
279 bra BadIdent
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
280
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
281 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
282 beq GotIdent Yep, exit out
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
283 leax -1,x Drop timer
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
284 bne WaitIdnt Keep trying
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
285 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
286 BadIdent coma Flag error
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
287 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
288
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
289 GotIdent clrb No error
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
290 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
291
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
292 * 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
293 * table
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
294 * 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
295 * 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
296 * 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
297 * 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
298 * 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
299 * U=Ptr to driver memory
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
300 * X IS DESTROYED!
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
301 * 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
302 * & 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
303 * 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
304 * 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
305 * updated
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
306 * 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
307 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
308 ldb #Identify
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
309 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
310 bcc DoInfo Worked, Do info
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
311 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
312 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
313 ldb #PIIdent Try ATAPI identify
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
314 bsr Ident
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
315 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
316 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
317 * 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
318 * 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
319 * 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
320 * 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
321 * 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
322 * for our special flag table
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
323 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
324 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
325 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
326 stb Sect0Drv,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
327 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
328 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
329 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
330 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
331 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
332 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
333 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
334 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
335 beq ChkATAPI No
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
336 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
337 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
338 cmpb #PIIdent ATAPI?
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
339 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
340 ora #ATAPI Set ATAPI flag
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
341 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
342 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
343 beq LeavAlon No
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
344 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
345 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
346 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
347 sta b,x Save flags
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
348 pshs a Save for exit
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
349 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
350 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
351 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
352 puls a Restore flags byte
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
353 ExitIdnt rts No error, return
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
354
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
355 * Entry: U=driver memory ptr
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
356 * Y=path descriptor ptr
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
357 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
358 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
359 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
360 bne NextGet No, try next
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
361 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
362 beq GoodFunc
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
363 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
364 ifeq Level-2
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
365 ldb #E$IllArg
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
366 else
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
367 ldb #167
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
368 endc
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
369 ExitGet rts
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
370
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
371 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
372 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
373 bcc GotInfo Something wrong, return
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
374 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
375
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
376 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
377 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
378 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
379 exg a,b
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
380 std ,y++
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
381 leax -1,x
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
382 bne SwapLoop
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
383 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
384 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
385 ldd 116,y
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
386 stx 116,y
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
387 std 114,y
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
388 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
389 ldd 122,y
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
390 stx 122,y
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
391 std 120,y
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
392 ifeq Level-2
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
393 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
394 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
395 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
396 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
397 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
398 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
399 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
400 os9 F$Move
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
401 else
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
402 endc
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
403 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
404 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
405 rts
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
406
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
407 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
408 std R$Y,x
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
409 clrb Device type=ATA
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
410 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
411 cmpa #PIIdent ATAPI?
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
412 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
413 incb
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
414 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
415 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
416 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
417 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
418 clrb
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
419 rts
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
420
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
421 NextGet comb
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
422 ldb #E$UnkSvc
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
423 rts
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
424
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
425 SetStat clrb
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
426 rts
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
427
36
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
428 start lbra Init
89
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
429 lbra Read
36
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
430 lbra FWrite
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
431 lbra GetStat
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
432 lbra SetStat
89
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
433 clrb Term routine (does nothing)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
434 rts
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
435
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
436 NotBsy lda #$FF
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
437 sta drvrbusy,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
438 rts
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
439
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
440 * 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
441 * 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
442 * 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
443 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
444 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
445 beq NotBsy No, continue
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
446 deca
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
447 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
448 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
449 ldx #1
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
450 os9 F$Sleep
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
451 puls x
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
452 bra ChekBusy
36
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
453
89
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
454 * 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
455 * 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
456 * 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
457 * for CD ROM
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
458 * 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
459 * B:X=OS9 LSN
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
460 * Exit: B:X=OS9 LSN
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
461 * 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
462 * 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
463 * or not)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
464 * 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
465 * 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
466 * PhysDrv set to physical drive #
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
467 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
468 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
469 anda #PhysDriv
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
470 sta PhysDrv,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
471 clra Flag: LSN0
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
472 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
473 beq dox Could be LSN0
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
474 inca Not LSN0
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
475 dox stx OS9LSN+1,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
476 beq doPSN Is LSN0
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
477 inca Not LSN0
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
478 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
479 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
480 stx OS9PSN+1,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
481 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
482 ror OS9PSN+1,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
483 ror OS9PSN+2,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
484 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
485 * Subtract 1 from current LSN
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
486 ldd 1,s
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
487 subd #1
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
488 std 1,s
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
489 ldb ,s
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
490 sbcb #0
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
491 bra SaveExit
36
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
492
89
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
493 * Add 1 to current LSN
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
494 Even ldd 1,s
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
495 addd #1
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
496 std 1,s
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
497 ldb ,s
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
498 adcb #0
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
499 SaveExit ldx 1,s
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
500 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
501 stx TempHalf+1,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
502 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
503 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
504 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
505 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
506 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
507 ldb OS9LSN,u Restore LSN
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
508 ldx OS9LSN+1,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
509 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
510 rts
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
511
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
512 * READ
89
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
513 * 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
514 * 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
515 * 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
516 * 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
517 * 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
518 * 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
519 * or not).
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
520 * 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
521 * 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
522 * 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
523 * if new LSN0 is written).
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
524 * 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
525 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
526 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
527 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
528 * 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
529 * 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
530 * bita #Remove Removable media?
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
531 * 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
532
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
533 * LSN0 - 1st see if buffered
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
534 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
535 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
536 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
537 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
538 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
539 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
540 * 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
541 * 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
542 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
543 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
544
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
545 * 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
546 * Entry: B:X=LSN
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
547 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
548 bne PhysRead
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
549 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
550 bne PhysRead
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
551 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
552 cmpa HalfDrv,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
553 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
554 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
555 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
556 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
557 * 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
558 * 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
559 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
560 * 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
561 * 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
562 CopyBuff clrb 256 counter
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
563 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
564 CpyLoop lda ,x+ Copy it
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
565 sta ,y+
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
566 decb
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
567 bne CpyLoop
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
568 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
569 rts
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
570
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
571 * 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
572 * 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
573 * 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
574 * U=Driver mem
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
575 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
576 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
577 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
578 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
579 sta HalfDrv,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
580 lbra RprtErr
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
581
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
582 * Entry: Y=path dsc. ptr
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
583 * U=Driver mem ptr
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
584 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
585 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
586 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
587 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
588 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
589 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
590 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
591 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
592
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
593 * 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
594 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
595 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
596 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
597 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
598 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
599 bcc DoneRead No error, exit
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
600 lbra RprtErr Exit with error
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
601
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
602 * 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
603 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
604 std HalfSct,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
605 lda TempHalf+2,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
606 sta HalfSct+2,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
607 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
608 std HalfOfs,u Save it
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
609 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
610 sta HalfDrv,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
611 rts
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
612
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
613 * 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
614 * Y=ptr to path descriptor
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
615 * U=ptr to driver mem
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
616 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
617 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
618 bne GoodExit No, leave
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
619 * 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
620 * 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
621 * WITH THESE CHECKS!
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
622 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
623 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
624 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
625 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
626 clrb 256 counter
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
627 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
628 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
629 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
630 sta ,x+
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
631 decb
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
632 bne LSN0Loop
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
633 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
634 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
635 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
636 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
637 rts
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
638
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
639 * 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
640 * Entry: U=Driver mem ptr
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
641 * Y=Path dsc. ptr (?)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
642 * 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
643 * CC=1 if error
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
644 * B=Error code
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
645 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
646 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
647
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
648 * 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
649 * 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
650 * U=ptr to driver memory
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
651 * Exit: 256 bytes copied
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
652 * B is destroyed, A=0
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
653 * Y is preserved
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
654 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
655 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
656 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
657 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
658 ldb Latch,y times
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
659 std ,x
36
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
660 lda ,y
89
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
661 ldb Latch,y
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
662 std 2,x
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
663 lda ,y
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
664 ldb Latch,y
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
665 std 4,x
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
666 lda ,y
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
667 ldb Latch,y
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
668 std 6,x
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
669 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
670 dec ,s Done all bytes?
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
671 bne ReadLp No, keep going
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
672 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
673
89
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
674 * 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
675 * 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
676 * 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
677 * 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
678 * 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
679 * 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
680 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
681 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
682 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
683 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
684 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
685 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
686 cmpx HalfSct+1,u Same as LSW of buffered sector #?
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
687 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
688 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
689 cmpd TempOfs,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
690 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
691 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
692 cmpa HalfDrv,u Same 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 bne ChkLsn1 No, check is LSN1
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
694 * 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
695 * essary.
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
696 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
697 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
698 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
699
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
700 * 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
701 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
702 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
703 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
704 cmpx #1 LSN=1?
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
705 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
706 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
707 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
708 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
709 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
710 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
711 bne PreRead
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
712 * 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
713 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
714 bcc ContWrt1 Successful, continue
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
715 lbra RprtErr
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
716
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
717 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
718 bsr Write256 Write to IDE
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
719 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
720 bsr Write256 Write to IDE
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
721 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
722
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
723 * 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
724 * 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
725 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
726 bcc GotPreRd No problem, continue
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
727 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
728
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
729 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
730 lsra Odd or even sector?
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
731 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
732 * Odd write requested
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
733 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
734 lbsr Read256 Read it in
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
735 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
736 bra FinPre
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
737
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
738 * 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
739 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
740 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
741 lbsr Read256
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
742 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
743 bcc DonePre Good, continue
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
744 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
745
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
746 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
747 lbsr InitWrit Initialize Write command
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
748 bcs BadExit
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
749 * Now, onto the write
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
750 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
751 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
752 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
753 * 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
754 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
755 bsr Write256 Write to IDE
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
756 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
757 bsr Write256 Write to IDE
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
758 bra FinWrite
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
759
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
760 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
761 bsr Write256 Write to IDE
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
762 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
763 bsr Write256 Write to IDE
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
764 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
765 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
766 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
767
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
768 * 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
769 * 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
770 * U=driver mem ptr
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
771 * Exit: 256 bytes written
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
772 * B is destroyed, A=0
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
773 * X=end of buffer+1
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
774 * Y is preserved
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
775 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
776 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
777 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
778 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
779 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
780 sta ,y
89
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
781 ldd 2,x
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
782 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
783 sta ,y
89
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
784 ldd 4,x
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
785 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
786 sta ,y
89
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
787 ldd 6,x
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
788 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
789 sta ,y
89
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
790 leax 8,x
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
791 dec ,s
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
792 bne WritLp
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
793 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
794
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
795 * 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
796 * read even bytes)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
797 * Entry: U=driver memory ptr
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
798 * Y=Path descriptor ptr
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
799 * 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
800 * All regs preserved
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
801 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
802 ldb #$20 32 loops
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
803 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
804 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
805 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
806 lda ,x
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 decb
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
809 bne EatLp
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
810 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
811
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
812 * 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
813 * 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
814 * 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
815 * 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
816 * 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
817 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
818 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
819 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
820 lsrb Odd/Even?
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
821 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
822 * 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
823 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
824 rts
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
825
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
826 * 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
827 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
828 sta HalfDrv,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
829 ldd TempOfs,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
830 std HalfOfs,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
831 ldd OS9LSN,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
832 std HalfSct,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
833 lda OS9LSN+2,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
834 sta HalfSct+2,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
835 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
836 CachBuff clrb
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
837 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
838 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
839 sta ,x+ writes)
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
840 decb
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
841 bne CachLp
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
842 clr drvrbusy,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
843 rts
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
844
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
845 * 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
846 * then update drive table entry.
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
847 * Entry: U=drive mem ptr
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
848 * Y=path dsc. ptr
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
849 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
850 sta Sect0Drv,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
851 ldd TempOfs,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
852 std Sect0Ofs,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
853 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
854 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
855 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
856 clr drvrbusy,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
857 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
858
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
859 * Initialize Write sequence to IDE
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
860 * Entry: U=driver mem ptr
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
861 * Y=Ptr to path descriptor
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
862 * 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
863 * 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
864 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
865 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
866
36
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
867 * 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
868 * 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
869 * X=Ptr to hardware address
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
870 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
871 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
872 bmi WaitLp
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
873 lda #ErrorFnd Check Error flag
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
874 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
875 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
876 clrb No, exit without error
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
877 rts
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
878
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
879 * 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
880 RprtErr lsrb
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
881 bcc ChkTk0
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
882 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
883 bra ExitErr
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
884
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
885 ChkTk0 lsrb
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
886 bcc ChkMdChg
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
887 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
888 bra ExitErr
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
889
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
890 ChkMdChg lsrb
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
891 bcc ChkAbrt
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
892 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
893 bra ExitErr
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
894
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
895 ChkAbrt lsrb
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
896 bcc ChkIdnf
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
897 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
898 bra ExitErr
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
899
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
900 ChkIdnf lsrb
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
901 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
902 lsrb
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
903 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
904 lsrb
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
905 bcc ChkBBK
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
906 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
907 bra ExitErr
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
908
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
909 ChkBBK lsrb
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
910 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
911 * 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
912 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
913
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
914 ReadExit ldb #E$Read
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
915 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
916 coma Set carry & exit
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
917 rts
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
918
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
919 BadUnit ldb #E$Unit
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
920 bra ExitErr
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
921
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
922 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
923 bra RprtErr
36
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
924
89
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
925 * 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
926 * Entry: B = IDE command code
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
927 * Y = address of path descriptor
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
928 * 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
929 * trashes D and X
89
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
930 * 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
931 * 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
932 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
933 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
934 cmpb #NUMDRIVE Within range?
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
935 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
936 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
937 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
938 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
939 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
940 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
941 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
942 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
943 * Do CHS mode
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
944 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
945 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
946 rorb
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
947 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
948 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
949 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
950 bcs CmdErr Error calculating, exit
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
951 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
952 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
953 * 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
954 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
955 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
956 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
957 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
958 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
959 ora #%10100000 Set CHS mode
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
960 ora DrivMask,u Merge drive #
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
961 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
962 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
963 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
964 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
965 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
966 stb CylLow,y
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
967 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
968
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
969 * 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
970 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
971 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
972 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
973 * 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
974 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
975 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
976 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
977 clra
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
978 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
979 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
980 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
981 bhi SeekErr Yes, SEEK error
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
982 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
983 ora #%11100000 Set LBA mode
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
984 ora DrivMask,u Merge drive #
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
985 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
986 * 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
987 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
988 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
989 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
990 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
991 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
992 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
993 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
994 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
995 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
996 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
997 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
998 bne CmdDone Yes, exit
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
999 decb Dec counter
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1000 bne CmdLp Keep trying
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1001 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
1002 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
1003 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
1004 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
1005 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
1006 os9 F$Sleep
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1007 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
1008 bra CmdLp Try again
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1009
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1010 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
1011 puls y,pc
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1012
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1013 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
1014 bra ENotRdy
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
1015
89
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1016 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
1017 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
1018
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1019 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
1020 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
1021
89
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1022 * 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
1023 * Entry: Y=path dsc. ptr
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1024 * U=driver mem ptr
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1025 * 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
1026 * 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
1027 * 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
1028 * PRESERVES X&Y
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1029 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
1030 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
1031 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
1032 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
1033 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
1034 lsla
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 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
1038 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
1039 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
1040 bpl IDEReady No, return
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1041 leax -1,x Dec counter
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1042 bne RdyIni1 Try again
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1043 puls x,y Restore regs
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1044 ENotRdy clr drvrbusy,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1045 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
1046 ldb #E$NotRdy
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
1047 rts
89
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1048
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1049 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
1050 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
1051 rts
89
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1052
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1053 * 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
1054 * 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
1055 * Exit: X,D is destroyed
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1056 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
1057 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
1058 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
1059 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
1060 leay DRVBEG,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1061 leay d,y
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1062 lda #DD.SIZ
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1063 LSN0Cp ldb ,x+
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1064 stb ,y+
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1065 deca
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1066 bne LSN0Cp
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1067 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
1068
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1069 * 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
1070 * 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
1071 * 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
1072 * 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
1073 * 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
1074 * 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
1075 * 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
1076 * 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
1077 * 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
1078 * - Head,u - IDE head #
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1079 * - Cylinder,u - IDE Cylinder #
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1080 * - CHSSect,u - IDE sector (512) #
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1081 * - 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
1082
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1083 * 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
1084 org 0
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1085 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
1086 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
1087 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
1088 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
1089 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
1090 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
1091
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1092 * 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
1093 * Y=Ptr to path descriptor
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1094 * 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
1095 * 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
1096 * 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
1097 * Y=ptr to path descriptor
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1098 * X=Drive table ptr
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1099 * 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
1100 * 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
1101 * 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
1102 * 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
1103 * 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
1104 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
1105 ldb OS9PSN,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1106 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
1107 ldd OS9PSN+1,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1108 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
1109 ldd #$0000
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1110 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
1111 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
1112 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
1113 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
1114 bhs NotTrk0
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1115 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
1116 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
1117 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
1118 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
1119 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
1120 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
1121 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
1122 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
1123 deca less track 0
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1124 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
1125 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
1126 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
1127 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
1128 bhs NotCyl0
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1129 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
1130 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
1131 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
1132 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
1133 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
1134 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
1135 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
1136 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
1137 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
1138 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
1139 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
1140 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
1141 mul calculate scale amount MSBs
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1142 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
1143 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
1144 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
1145 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
1146 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
1147 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
1148 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
1149 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
1150 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
1151 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
1152 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
1153 bra DivLoop3
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1154
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1155 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
1156 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
1157 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
1158 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
1159 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
1160 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
1161 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
1162 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
1163 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
1164 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
1165 ror S.SclAmt+1,s
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1166 ror S.SclAmt+2,s
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1167 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
1168 ror S.SclPwr+1,s
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1169 bcc DivLoop
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1170 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
1171 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
1172 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
1173 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
1174 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
1175 bra NextHead
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1176
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1177 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
1178 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
1179 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
1180 std Cylinder,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1181 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
1182 inca IDE needs base 1
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1183 sta CHSSect,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1184 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
1185 stb Head,u
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1186 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
1187 clrb
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1188 rts
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1189
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1190 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
1191 LSNErr comb
2727056db0d3 Updated to Curtis Boyle's latest IDE driver, works with L1 and L2
boisy
parents: 36
diff changeset
1192 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
1193 rts
36
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
1194
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
1195 emod
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
1196 eom equ *
8b423669e5d2 Removed Boyle's IDE drivers for the time being... they don't seem to work
boisy
parents: 0
diff changeset
1197 end