revert between 56095 -> 55830 in arch
[AROS.git] / rom / exec / adddevice.c
blob20976e42f6204a937a8d14f31e3882226d360bb9
1 /*
2 Copyright © 1995-2017, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Add a device to the public list of devices.
6 Lang: english
7 */
8 #include <aros/debug.h>
9 #include <exec/execbase.h>
10 #include <exec/devices.h>
11 #include <aros/libcall.h>
12 #include <proto/exec.h>
14 #include "exec_intern.h"
15 #include "exec_debug.h"
16 #include "exec_locks.h"
18 /*****************************************************************************
20 NAME */
22 AROS_LH1(void, AddDevice,
24 /* SYNOPSIS */
25 AROS_LHA(struct Device *, device,A1),
27 /* LOCATION */
28 struct ExecBase *, SysBase, 72, Exec)
30 /* FUNCTION
31 Adds a given device to the system's device list after checksumming
32 the device vectors. This function is not for general use but
33 (of course) for building devices that don't use exec's MakeLibrary()
34 mechanism.
36 INPUTS
37 device - Pointer to a ready for use device structure.
39 RESULT
41 NOTES
43 EXAMPLE
45 BUGS
47 SEE ALSO
48 RemDevice(), OpenDevice(), CloseDevice()
50 INTERNALS
52 ******************************************************************************/
54 AROS_LIBFUNC_INIT
55 ASSERT_VALID_PTR(device);
57 /* Just in case the user forgot them */
58 device->dd_Library.lib_Node.ln_Type=NT_DEVICE;
59 device->dd_Library.lib_Flags|=LIBF_CHANGED;
61 /* Build checksum for device vectors */
62 SumLibrary(&device->dd_Library);
64 /* Arbitrate for the device list */
65 EXEC_LOCK_LIST_WRITE_AND_FORBID(&SysBase->DeviceList);
67 /* And add the device */
68 Enqueue(&SysBase->DeviceList,&device->dd_Library.lib_Node);
70 /* All done. */
71 EXEC_UNLOCK_LIST_AND_PERMIT(&SysBase->DeviceList);
73 AROS_LIBFUNC_EXIT
74 } /* AddDevice */