[futurebasic] Implementing PBXGetVolInfo in assembly

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : February 1998 : Group Archive : Group : All Groups

From: "Eric M. Bennett" <ericb@...>
Date: Sun, 8 Feb 1998 00:11:14 -0500
I'm try to write PBXGetVolInfo into my program with assembly.  I'm told
that this function will let me get correct info on HFS+ volumes
(PBGetVolInfo and the Get Volume Info statement in FutureBasic II return
incorrect info, which is IMO worse that returning an error message).

However, my code causes a system crash.  Since I know more or less nothing
about 68k assembler, I assume that the below function I've patched together
based on the examples in the FB Handbook is incorrect somewhere.

The information for PBXGetVolInfo, as taken from the "Large Volume Support"
chapter in Apple's documentation for the 7500/8500 series:

=====
pascal OSErr PBXGetVolInfo (XVolumeParam paramBlock,Boolean async);

paramBlock: A pointer to an extended volume parameter block.
async     : A Boolean value that specifies asynchronous (true) or synchronous
(false) execution.

Trap macro: _HFSDispatch
Selector:   $0012
=====

Poking through CodeWarrior header files reveals that _HFSDispatch is $A260.

The following is what I'm calling under MacOS 8.1 on a G3 (I do a Gestalt
check elsewhere, and it passes, as it should under 8.1):

LOCAL MODE
LOCAL FN PBXGetVolInfo(pbPtr&,async)
  ` SUBQ.L #2,sp
  ` MOVE.L ^pbPtr&,-(sp)
  ` MOVE.B ^async,-(sp)

  'PBXGetVolInfo selector; my first try was MOVE.W #$12,-(sp)
  'but this crashes as well.
  ` MOVE.W #$12,D0

  '_HFSDispatch trap
  ` DC.W   $A260

  ` MOVE.W (sp)+,D0
  ` EXT.L  D0
END FN

And this is the code that sets things up before calling FN PBXGetVolInfo,
with (hopefully) non-relevant stuff removed:

LOCAL FN GetVolumeInformation(errFlag%)
  DIM OldWindow%,oserr%,pbPtr&,dummy$
  DIM paramblock$,VolName$,gestaltAttrib&

  pbPtr& = @paramblock$

  pbPtr&.myioCompletion& = 0
  pbPtr&.myioResult%     = 0
  pbPtr&.myioNamePtr&    = @VolName$
  pbPtr&.myioVRefNum%    = 0
  pbPtr&.myioXVersion&   = 0
  pbPtr&.myioVolIndex%   = gVolumeIndex%
  STOP
  oserr% = FN PBXGetVolInfo(pbPtr&,0)
  STOP
END FN

The program reaches the first STOP statement OK, and does not reach the
second.  It drops into Macsbug with an Unimplemented Instruction error.

(Probably irrelevant note: the PBXGetVolInfo parameter block differs from
the PBGetVolInfo parameter block, which is why I defined a record
myXVolumeParam with all those fields whopse names start with 'my'.)


What did I do wrong?



--
Eric Bennett, ericb@..., Cornell University Biochemistry Department
http://www.pobox.com/~ericb (Follow "About Me" link for PGP public key.)

Bill Gates can dodge the law, but not the cream pies.
- www.stopgates.com