supermario/base/SuperMarioProj.1994-02-09/Libs/InterfaceSrcs/DEVICES.a

201 lines
6.0 KiB
Plaintext
Raw Permalink Normal View History

2019-06-29 15:17:50 +00:00
include 'macintosh.a'
; devices.a
;
; Implements the C interface for device manager register based traps.
; Note: routines appear in same order as "Inside Macintosh"
;
; Copyright Apple Computer, Inc. 1984-1988
; All rights reserved.
; Written by Dan Smith 9-Nov-84 (converted version of the pascal interface)
;
; Modifications:
; 12 Jun 87 KLH GetDCtlEntry fixed in Interface.o
; *** MPW 3.0d2 ***
; 11 Feb 88 KLH Changed C headers to work with new C compiler:
; Changed to using standard glue in Interface.o, so
; much glue removed from CInterface.o.
; *** MPW 3.0d4 ***
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;
; High-level Routines
;
; Interface for device functions which do not require a parameter block
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;
; OSErr opendriver(name,refNum)
; short *refNum;
; char *name;
;
BLANKS ON
STRING ASIS
opendriver func EXPORT
import p2cstr ; p2cstr(s) char *s;
import c2pstr ; c2pstr(s) char *s;
move.l 4(sp),-(sp) ; address of name
jsr c2pstr ; convert to pascal string
addq #4,sp ; pop parameter
move.l 4(sp),a0 ; get a pointer to the name
move.l 8(sp),a1 ; address of refNum
moveq #(IOQELSIZE/2)-1,d0
@1 clr.w -(sp)
dbra d0,@1
move.l a0,IOFileName(sp) ; set up name
clr.b IOPermssn(sp) ; open for read/write
move.l sp,a0 ; point to it
_Open ; open the driver
move.w IORefNum(sp),(a1) ; set the refNum
add #IOQELSIZE,sp ; pop off command buffer
move.w d0,-(sp) ; save result
move.l 6(sp),-(sp) ; address of name
jsr p2cstr ; convert to C string
addq #4,sp ; pop paramter
move.w (sp)+,d0 ; restore result
ext.l d0 ; sign extend error code
rts
;-------------------------------------------------------------------------------
;
; OSErr CloseDriver(refNum)
; short refNum;
;
;
;;CloseDriver proc EXPORT
;;
;; move.w 6(sp),d0 ; get the refNum
;; sub #IOQELSIZE,sp ; get space for param block
;; move.w d0,IORefNum(sp) ; set up refNum
;; move.l sp,a0
;; _Close ; close it!
;; add #IOQELSIZE,sp ; pop off param block
;; ext.l d0 ; sign extend error code
;; rts
;;
;-------------------------------------------------------------------------------
;
; OSErr Control(refNum,csCode,csParam)
; short refNum,csCode;
; Ptr csParam;
;
;;Control func EXPORT
;;
;; link a6,#-IOQELSIZE ; make room on stack for cmd block
;; lea -IOQELSIZE(a6),a0 ; address of cmd block
;;
;; move.w 10(a6),IORefNum(a0) ; refnum
;; move.w 14(a6),CSCode(a0) ; the control operation to be performed
;; tst.l 16(a6) ; see if there is a parameter block
;; beq.s @1 ; if not, don't bother copying one
;; lea CSParam(a0),a1 ; dest address of op specific params
;; move.l 16(a6),a0 ; src address of op specific params
;; moveq #22,d0 ; max number of bytes to be moved
;; _BlockMove ; copy the op specific params
;; lea -IOQELSIZE(a6),a0 ; put cmd block addr back into a0
;;
;;@1 _Control
;;
;; ext.l d0 ; sign extend error code
;; unlk a6
;; rts
;;
;-------------------------------------------------------------------------------
;
; OSErr Status(refNum,csCode,csParam)
; short refNum,csCode;
; Ptr csParam;
;
;;Status func EXPORT ; analogous to MacControl but returns
;; ; opParams rather than expecting it
;; ; as arg
;;
;; link a6,#-IOQELSIZE ; make room on stack for cmd block
;; lea -IOQELSIZE(a6),a0 ; address of cmd block
;;
;; move.w 10(a6),IORefNum(a0) ; refnum
;; move.w 14(a6),CSCode(a0) ; the control operation to be performed
;; _Status
;;
;; move.w d0,-(sp) ; save result
;; lea CSParam-IOQELSIZE(a6),a0 ; ptr to the status information
;; move.l 16(a6),a1 ; ptr to where to put this information
;; moveq #22,d0 ; max number of bytes to be moved
;; _BlockMove ; copy the op specific params
;;
;; move.w (sp)+,d0 ; get Status result
;; ext.l d0 ; sign extend error code
;; unlk a6
;; rts
;;
;-------------------------------------------------------------------------------
;
; OSErr KillIO(refNum)
; short refNum;
;
;;KillIO func EXPORT
;;
;; link a6,#-32 ; get space for control p-block
;; lea -32(a6),a0 ; point a0 at the block
;; move.w 10(a6),IORefNum(a0) ; refnum
;; _KillIO ; make the control call
;;
;; ext.l d0 ; sign extend error code
;; unlk a6
;; rts
;;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;
; Low-Level Routines
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; OSErr PBControl (paramBlock,async) CntrlParam *paramBlock; Boolean async;
; OSErr PBStatus (paramBlock,async) CntrlParam *paramBlock; Boolean async;
; OSErr PBKillIO (paramBlock,async) CntrlParam *paramBlock; Boolean async;
;;PBControl proc EXPORT
;; OsCall _Control
;;
;;PBStatus proc EXPORT
;; OsCall _Status
;;
;;PBKillIO proc EXPORT
;; OsCall _KillIO
;;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;
; Accessing a Driver's I/O Queue
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;
; This was corrected in Interface.o, so now the c header file uses that
; corrected glue. 12 Jun 87 - KLH
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; DCtlHandle GetDCtlEntry(refNum)
; short refNum;
;
; does status 1 call to get the DCEHandle
;
;GetDCtlEntry func EXPORT
;
; link a6,#-IOQELSIZE ; make room on stack for cmd block
; lea -IOQELSIZE(a6),a0 ; address of cmd block
;
; move.w 10(a6),IORefNum(a0) ; drive number
; move.w #1,CSCode(a0) ; code to get DCE handle
; _Status
; move.l CSParam(a0),d0 ; return the DCE Handle
;
; unlk a6
; rts
;
END