2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
8 #include <aros/config.h>
9 #include <exec/execbase.h>
11 #include <exec/devices.h>
13 #include <aros/libcall.h>
14 #include <proto/exec.h>
16 #include "exec_debug.h"
17 #ifndef DEBUG_CloseDevice
18 # define DEBUG_CloseDevice 0
24 #include <aros/debug.h>
27 #if (AROS_FLAVOUR & AROS_FLAVOUR_NATIVE)
30 # define NATIVE(x) /* eps */
33 /*****************************************************************************
37 AROS_LH1(void, CloseDevice
,
40 AROS_LHA(struct IORequest
*, iORequest
, A1
),
43 struct ExecBase
*, SysBase
, 75, Exec
)
46 Closes a previously opened device. Any outstanding I/O requests must
47 be finished. It is safe to call CloseDevice with a cleared iorequest
48 structure or one that failed to open.
51 iORequest - Pointer to iorequest structure.
66 ******************************************************************************/
71 D(bug("CloseDevice $%lx $%lx (\"%s\") by \"%s\"\n", iORequest
, iORequest
->io_Device
,
72 iORequest
->io_Device
? iORequest
->io_Device
->dd_Library
.lib_Node
.ln_Name
: "(null)",
73 SysBase
->ThisTask
->tc_Node
.ln_Name
));
75 /* Single-thread the close routine. */
78 /* Something to do? */
79 if(iORequest
->io_Device
!=NULL
)
81 NATIVE(dc_ret
=) AROS_LVO_CALL1(BPTR
,
82 AROS_LCA(struct IORequest
*,iORequest
, A1
),
83 struct Device
*,iORequest
->io_Device
,2,
86 Normally you'd expect the device to be expunged if this returns
87 non-zero, but this is only exec which doesn't know anything about
88 seglists - therefore dos.library has to SetFunction() into this
89 vector for the additional functionality.
92 /* Trash device field */
93 iORequest
->io_Device
=(struct Device
*)-1;
95 #if (AROS_FLAVOUR & AROS_FLAVOUR_NATIVE)
98 /* local vars not guaranteed to be initialised to 0 */
106 #if (AROS_FLAVOUR & AROS_FLAVOUR_NATIVE)
108 Kludge to force the seglist to register d0. Ramlib patches this
109 vector for seglist expunge capability and expects the seglist in
110 d0 after it has called the original (this) function.
111 Also see CloseLibrary().
114 /* Put the library base in register d0 */
115 register BPTR ret
__asm("d0") = dc_ret
;
117 /* Make sure the above assignment isn't optimized away */
118 asm volatile("": : "r" (ret
));