gord@spycal.UUCP (Gordon Delaney) (04/09/89)
I have a requirement to directly access the disk hardware on my A1000 and wanted to do it in an "acceptable" way. I have the original C-A RKM (for V1.1?) which glosses over the resources facilities very vaguely. I am looking for other references to using the resources properly and possibly some sample code using the disk and misc resources. Any help will be appreciated. Gord D. -- Gord Delaney Guest at: UNISYS Canada Inc. Calgary, Alberta, Canada ...ihnp4!alberta!calgary!spycal!gord gord@spycal.UUCP
jesup@cbmvax.UUCP (Randell Jesup) (04/12/89)
In article <268@spycal.UUCP> gord@spycal.UUCP (Gordon Delaney) writes: >I have a requirement to directly access the disk hardware on my A1000 >and wanted to do it in an "acceptable" way. I have the original C-A >RKM (for V1.1?) which glosses over the resources facilities very >vaguely. I am looking for other references to using the resources >properly and possibly some sample code using the disk and misc >resources. Read resources/disk.h AND .i. Read the autodocs. Now, having done that, here's the way to use it: if AllocUnit fails, then you can still use GetUnit/GiveUnit. However, the trackdisk will probably have control of the hardware whenever you don't. Make sure you put your name in the ln_Name of DiscResourceUnit, and fill in the IS_CODE and IS_DATA of any interrupts you plan to turn on. Also, for good measure, set ln_Type of the Interrupt structure to NT_INTERRUPT. If GetUnit succeeds, you have control of the hardware. Make sure you've restored things as shown in the autodoc before GiveUnit, and make certain you've turned off AND cleared any interrupts you turned on. Your interrupt routines will be called with A1 == your IS_DATA. restore all but D0/D1/A0/A1. If trackdisk is also using the unit, it is HIGHLY advisable to return the head to the same track when finished if a disk is in the drive, since trackdisk will assume it's still on the same track, and gets very confused if it isn't. You can find out the current track by reading the track and looking at the track number in the sector headers. Another thing to note: 1.2/1.3 disk resource doesn't check if you own the unit when you do a GiveUnit. Unfortunately, 1.2/1.3 trackdisk has a bug that causes it to (rarely) do this when there are empty drives in the system. 1.3.1 SetPatch (soon to be available, don't ask for dates - I don't know them) has a fix for this. Last note: the disk resource is tough to use from C, since there are no entries in amiga.lib for it (stubs). With lattice 4.0 or later, you can make pragma files for it. Your interrupt code should probably be in ASM. Good luck (you'll need it) -- Randell Jesup, Commodore Engineering {uunet|rutgers|allegra}!cbmvax!jesup