2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
5 Desc: Remove a device from the public list of devices.
8 #include <aros/config.h>
9 #include <exec/devices.h>
10 #include <exec/execbase.h>
11 #include <aros/libcall.h>
13 #include <proto/exec.h>
15 #include "exec_debug.h"
16 #ifndef DEBUG_RemDevice
17 # define DEBUG_RemDevice 0
23 #include <aros/debug.h>
26 #if (AROS_FLAVOUR & AROS_FLAVOUR_NATIVE)
29 # define NATIVE(x) /* eps */
32 /*****************************************************************************
36 AROS_LH1(void, RemDevice
,
39 AROS_LHA(struct Device
*, device
,A1
),
42 struct ExecBase
*, SysBase
, 73, Exec
)
45 Calls the given device's expunge vector, thus trying to delete it.
46 The device may refuse to do so and still be open after this call.
49 device - Pointer to the device structure.
60 AddDevice(), OpenDevice(), CloseDevice().
64 ******************************************************************************/
69 D(bug("RemDevice $%lx (\"%s\") by \"%s\"\n", device
,
70 device
? device
->dd_Library
.lib_Node
.ln_Name
: "(null)",
71 SysBase
->ThisTask
->tc_Node
.ln_Name
));
73 /* Arbitrate for the device list */
76 /* Call expunge vector */
77 NATIVE(seglist
=) AROS_LVO_CALL1(BPTR
,
78 AROS_LCA(struct Device
*,device
, D0
),
79 struct Device
*,device
,3,);
81 Normally you'd expect the device to be expunged if this returns
82 non-zero, but this is only exec which doesn't know anything about
83 seglists - therefore dos.library has to SetFunction() into this
84 vector for the additional functionality.
90 #if (AROS_FLAVOUR & AROS_FLAVOUR_NATIVE)
92 Kludge to force the seglist to register d0. Ramlib patches this
93 vector for seglist expunge capability and expects the seglist in
94 d0 after it has called the original (this) function.
95 Also see CloseDevice().
98 /* Put the library base in register d0 */
99 register BPTR ret
__asm("d0") = seglist
;
101 /* Make sure the above assignment isn't optimized away */
102 asm volatile("": : "r" (ret
));