sys7.1-doc-wip/Libs/InterfaceSrcs/Power.a
2019-07-27 22:37:48 +08:00

202 lines
6.6 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

;
; File: Power.a
;
; Contains: Power Manager glue
;
; Written by: Dennis Hescox
;
; Copyright: © 1990-1992 by Apple Computer, Inc. All rights reserved.
;
; Change History (most recent first):
;
; <SM3> 11/6/92 SWC Rewrote all the routines (read: cleanup).
; <SM2> 10/28/92 SWC Changed INCLUDEs to a LOAD of StandardEqu.d.
; <6> 11/15/91 JL Changed MoveA.L RBuffer(A6) to MoveA.L PmgrRPtr(A0) after the
; trap call to put an address in A0 instead of data.
; <5> 11/12/91 JL stb: allocated receive buffers for BatteryStatus, ModemStatus,
; and GetWUTime.
; <4> 1/22/91 ag MSH: Moved Power Manager command equates directly into this file
; from PowerEqu.a to make them private.
; <3> 1/22/91 ag MSH - Moved Power Manager command equates directly into this
; file from PowerEqu.a to make them private.
;
LOAD 'StandardEqu.d'
; Power Manager command block
pmCommandRec RECORD 0,INCREMENT
pmCommand DS.W 1 ; command
pmLength DS.W 1 ; length of data to send
pmSBuffer DS.L 1 ; pointer to send buffer
pmRBuffer DS.L 1 ; pointer to receive buffer
pmData DS.L 1 ; data
pmBlkSize EQU *-pmCommandRec
ENDR
; commands for Power Manager parameter block
modemRead EQU $58 ; internal modem setup
batteryRead EQU $68 ; battery/charger level and status
setWakeUp EQU $80 ; set WakeUp timer
disableWakeUp EQU $82 ; disable WakeUp timer
readWakeUp EQU $88 ; read WakeUp timer
;_______________________________________________________________________________________
;
; FUNCTION DisableWUTime: OSErr
;
; This function will disable the wakeup timer on portable Macintoshes.
;
; on entry: 4(SP) - space for function result
; 0(SP) - return address
;_______________________________________________________________________________________
DisableWUTime PROC EXPORT
WITH pmCommandRec
CLR.L -(SP) ; pmRBuffer (none)
CLR.L -(SP) ; pmSBuffer (none)
CLR.W -(SP) ; pmLength (no data to send)
MOVE.W #disableWakeUp,-(SP) ; pmCommand
MOVEA.L SP,A0 ; point to the parameter block
_PMgrOp ; disable the timer
LEA pmRBuffer+4(SP),SP ; toss the parameter block
MOVE.W D0,4(SP) ; return the result
RTS
ENDP
;_______________________________________________________________________________________
;
; FUNCTION GetWUTime(VAR WUTime: LONGINT; VAR WUFlag: Byte): OSErr
;
; This function will return the current setting of the wakeup timer on portable
; Macintoshes. The time returned is the number of seconds since Jan 1, 1904.
;
; on entry: 12(SP) - space for function result
; 8(SP) - pointer to WUTime
; 4(SP) - pointer to WUFlag
; 0(SP) - return address
;_______________________________________________________________________________________
GetWUTime PROC EXPORT
WITH pmCommandRec
MOVEA.L (SP)+,A1 ; pop the return address
SUBQ.W #4+2,SP ; make space for wakeup time + flags
MOVE.L SP,-(SP) ; pmRBuffer
CLR.L -(SP) ; pmSBuffer (none)
CLR.W -(SP) ; pmLength (no data to send)
MOVE.W #readWakeUp,-(SP) ; pmCommand
MOVEA.L SP,A0 ; point to the parameter block
_PMgrOp ; read the timer
LEA pmRBuffer+4(SP),SP ; toss the parameter block
MOVE.L (SP)+,D1 ; get the timer setting
MOVE.B (SP)+,D2 ; and the flags
MOVEA.L (SP)+,A0 ; get the pointer to WUFlag
MOVE.B D2,(A0) ; and update it
MOVEA.L (SP)+,A0 ; get the pointer to WUTime
MOVE.L D1,(A0) ; and update it
MOVE.W D0,(SP) ; save the result
JMP (A1)
ENDP
;_______________________________________________________________________________________
;
; FUNCTION SetWUTime(WUTime: LONGINT): OSErr
;
; This function will set the wakeup timer on portable Macintoshes. The time passed
; is the number of seconds since Jan 1, 1904.
;
; on entry: 8(SP) - space for function result
; 4(SP) - WUTime
; 0(SP) - return address
;_______________________________________________________________________________________
SetWUTime PROC EXPORT
WITH pmCommandRec
MOVE.L (SP)+,A1 ; pop the return address
MOVE.L SP,-(SP) ; pmSBuffer (points to WUTime on the stack)
MOVE.W #4,-(SP) ; sending 4 bytes
MOVE.W #setWakeUp,-(SP) ; command
MOVEA.L SP,A0 ; point to the parameter block
_PMgrOp ; send the command
LEA pmRBuffer+4(SP),SP ; toss the parameter block
MOVE.W D0,(SP) ; stuff the function result
JMP (A1)
ENDP
;_______________________________________________________________________________________
;
; FUNCTION BatteryStatus(VAR status: Byte; VAR power: Byte): OSErr
;
; This function will return the current status of the battery on portable Macintoshes.
;
; on entry: 12(SP) - space for function result
; 8(SP) - pointer to status
; 4(SP) - pointer to power
; 0(SP) - return address
;_______________________________________________________________________________________
BatteryStatus PROC EXPORT
WITH pmCommandRec
MOVE.L (SP)+,A1 ; pop the return address
CLR.L -(SP) ; buffer for flags, power, temperature (, pad)
MOVE.L SP,-(SP) ; pmRBuffer
CLR.L -(SP) ; pmSBuffer (none)
CLR.W -(SP) ; pmLength (no data to send)
MOVE.W #batteryRead,-(SP) ; command
MOVEA.L SP,A0 ; point to the parameter block
_PMgrOp ; get battery info
LEA pmRBuffer+4(SP),SP ; toss the parameter block
MOVEA.L SP,A0 ; point to the buffer
MOVE.B (A0)+,D1 ; get the flags
MOVE.B (A0)+,D2 ; and battery power
ADDQ.W #4,SP ; toss the buffer
MOVEA.L (SP)+,A0 ; get the pointer to power
MOVE.B D2,(A0) ; and update it
MOVEA.L (SP)+,A0 ; get the pointer to status
MOVE.B D1,(A0) ; and update it
MOVE.W D0,(SP) ; save the result
JMP (A1)
ENDP
;_______________________________________________________________________________________
;
; FUNCTION ModemStatus(VAR status: Byte): OSErr
;
; This function will return the current setting of the modem on portable Macintoshes.
;
; on entry: 8(SP) - space for function result
; 4(SP) - pointer to status (receive buffer)
; 0(SP) - return address
;_______________________________________________________________________________________
ModemStatus PROC EXPORT
WITH pmCommandRec
MOVE.L (SP)+,A1 ; pop the return address
CLR.L -(SP) ; no send buffer
CLR.W -(SP) ; no data to send
MOVE.W #modemRead,-(SP) ; command
MOVEA.L SP,A0 ; point to the parameter block
_PMgrOp ; send the command
LEA pmRBuffer+4(SP),SP ; toss the parameter block
MOVE.W D0,(SP) ; stuff the function result
JMP (A1)
ENDP
END