[comp.sys.mac.programmer] device driver question

tracyn@dgp.toronto.edu (Tracy Narine) (10/10/90)

I am trying to write a device driver.  The problem I have run into is
globals variables are not allowed.  How do programmers get around this
barrier?  Will the suggestions of technote 256 -> 'globals in stand-alone
code' apply here?  (Is a driver stand-alone code? )  
Also, you can set a driver to wake up periodically.  Which one of the driver
interface routines is called everytime the driver wakes up?

mahendra
   

stevec@Apple.COM (Steve Christensen) (10/12/90)

tracyn@dgp.toronto.edu (Tracy Narine) writes:
>I am trying to write a device driver.  The problem I have run into is
>globals variables are not allowed.  How do programmers get around this
>barrier?  Will the suggestions of technote 256 -> 'globals in stand-alone
>code' apply here?  (Is a driver stand-alone code? )  
>Also, you can set a driver to wake up periodically.  Which one of the driver
>interface routines is called everytime the driver wakes up?

Yes, a driver is stand-alone code.  Actually, anything that's not an
application is stand-alone code.  Drivers can store a handle or pointer to a
block containing their global variables in the dCtlStorage field in their
driver's device control entry (DCE).  In assembly language, the pointer to the
DCE is passed to the driver in register A1.  If you're writing in C or Pascal,
you could have an assembly language header that pushes that pointer (plus the
parameter block pointer) on the stack and calls the various driver routines.
Driver wakeups are control calls with csCode=accRun (65).  You need to set the
dNeedTime bit in the driver flags word in the header in order to be called...

steve

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 whoami?     Steve Christensen
 snail:      Apple Computer, 20525 Mariani Ave, MS-81CS, Cupertino, CA  95014
 Internet:   stevec@goofy.apple.com
 AppleLink:  stevec
 CompuServe: 76174,1712