grub2: bring back build of aros-side grub2 tools
[AROS.git] / rom / exec / remdevice.c
blob42a683026b79a2ee6a87473bac71531b910e60ed
1 /*
2 Copyright © 1995-2007, 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 /*****************************************************************************
28 NAME */
30 AROS_LH1(void, RemDevice,
32 /* SYNOPSIS */
33 AROS_LHA(struct Device *, device,A1),
35 /* LOCATION */
36 struct ExecBase *, SysBase, 73, Exec)
38 /* FUNCTION
39 Calls the given device's expunge vector, thus trying to delete it.
40 The device may refuse to do so and still be open after this call.
42 INPUTS
43 device - Pointer to the device structure.
45 RESULT
47 NOTES
49 EXAMPLE
51 BUGS
53 SEE ALSO
54 AddDevice(), OpenDevice(), CloseDevice()
56 INTERNALS
58 ******************************************************************************/
60 AROS_LIBFUNC_INIT
61 BPTR seglist;
63 D(bug("RemDevice $%lx (\"%s\") by \"%s\"\n", device,
64 device ? device->dd_Library.lib_Node.ln_Name : "(null)",
65 GET_THIS_TASK->tc_Node.ln_Name));
67 /* Arbitrate for the device list */
68 Forbid();
70 /* Call expunge vector */
71 seglist = AROS_LVO_CALL1(BPTR,
72 AROS_LCA(struct Device *,device, D0),
73 struct Device *,device,3,
76 Normally you'd expect the device to be expunged if this returns
77 non-zero, but this is only exec which doesn't know anything about
78 seglists - therefore dos.library has to SetFunction() into this
79 vector for the additional functionality.
82 /* All done. */
83 Permit();
85 AROS_COMPAT_SETD0(seglist); /* For m68k compatibility */
86 AROS_LIBFUNC_EXIT
87 } /* RemDevice */