Did not call expunge vector with any params. So libbase was only
[tangerine.git] / rom / exec / remdevice.c
blob6e28ec5344fd86ee5e6707889f20de4af1882f8c
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Remove a device from the public list of devices.
6 Lang: english
7 */
8 #include <aros/config.h>
9 #include <exec/devices.h>
10 #include <exec/execbase.h>
11 #include <aros/libcall.h>
12 #include <dos/dos.h>
13 #include <proto/exec.h>
15 #include "exec_debug.h"
16 #ifndef DEBUG_RemDevice
17 # define DEBUG_RemDevice 0
18 #endif
19 #undef DEBUG
20 #if DEBUG_RemDevice
21 # define DEBUG 1
22 #endif
23 #include <aros/debug.h>
24 #undef kprintf
26 #if (AROS_FLAVOUR & AROS_FLAVOUR_NATIVE)
27 # define NATIVE(x) x
28 #else
29 # define NATIVE(x) /* eps */
30 #endif
32 /*****************************************************************************
34 NAME */
36 AROS_LH1(void, RemDevice,
38 /* SYNOPSIS */
39 AROS_LHA(struct Device *, device,A1),
41 /* LOCATION */
42 struct ExecBase *, SysBase, 73, Exec)
44 /* FUNCTION
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.
48 INPUTS
49 device - Pointer to the device structure.
51 RESULT
53 NOTES
55 EXAMPLE
57 BUGS
59 SEE ALSO
60 AddDevice(), OpenDevice(), CloseDevice().
62 INTERNALS
64 ******************************************************************************/
66 AROS_LIBFUNC_INIT
67 NATIVE(BPTR seglist;)
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 */
74 Forbid();
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.
87 /* All done. */
88 Permit();
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));
104 #endif
106 AROS_LIBFUNC_EXIT
107 } /* RemDevice */