Added kernel module for starting the usb stack at boot time. It's not activated thoug...
[cake.git] / rom / dos / endnotify.c
blob85c71bc0d930f66a0da293c3df07c2d18820e983
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: English
7 */
9 #include "dos_intern.h"
10 #include <exec/lists.h>
11 #include <proto/exec.h>
13 /*****************************************************************************
15 NAME */
17 #include <dos/notify.h>
18 #include <proto/dos.h>
20 #include <string.h>
22 AROS_LH1(void, EndNotify,
24 /* SYNOPSIS */
25 AROS_LHA(struct NotifyRequest *, notify, D1),
27 /* LOCATION */
28 struct DosLibrary *, DOSBase, 149, Dos)
30 /* FUNCTION
32 End a notification (quit notifying for a request previously sent with
33 StartNotify()).
35 INPUTS
37 notify -- NotifyRequest used with StartNotify()
39 RESULT
41 NOTES
43 EXAMPLE
45 BUGS
47 SEE ALSO
49 StartNotify()
51 INTERNALS
53 *****************************************************************************/
55 AROS_LIBFUNC_INIT
57 struct IOFileSys iofs;
58 struct DevProc *dvp;
60 /* get the device pointer and dir lock. note that we don't just use
61 * nr_Handler here, because we also need to supply a unit pointer so
62 * packet.handler can get its mount context */
63 if ((dvp = GetDeviceProc(notify->nr_FullName, NULL)) == NULL)
64 return;
66 /* setup the call */
67 InitIOFS(&iofs, FSA_REMOVE_NOTIFY, DOSBase);
68 iofs.io_Union.io_NOTIFY.io_NotificationRequest = notify;
70 iofs.IOFS.io_Device = (struct Device *) dvp->dvp_Port;
72 /* take the root lock from either the doslist entry or from the devproc */
73 if (dvp->dvp_Lock == NULL)
74 iofs.IOFS.io_Unit = dvp->dvp_DevNode->dol_Ext.dol_AROS.dol_Unit;
75 else
76 iofs.IOFS.io_Unit = ((struct FileHandle *) BADDR(dvp->dvp_Lock))->fh_Unit;
78 FreeDeviceProc(dvp);
80 /* go */
81 do {
82 DosDoIO(&iofs.IOFS);
83 } while (iofs.io_DosError != 0 && ErrorReport(iofs.io_DosError, REPORT_LOCK, 0, dvp->dvp_Port) == DOSFALSE);
85 /* free fullname if it was built in StartNotify() */
86 if (notify->nr_FullName != notify->nr_Name)
87 FreeVec(notify->nr_FullName);
89 /* if the filesystem has outstanding messages, they need to be replied */
90 if (notify->nr_Flags & NRF_SEND_MESSAGE &&
91 (notify->nr_Flags & NRF_WAIT_REPLY || notify->nr_MsgCount > 0)) {
93 struct MsgPort *port = notify->nr_stuff.nr_Msg.nr_Port;
94 struct NotifyMessage *nm, *tmp;
96 notify->nr_Flags &= ~NRF_MAGIC;
98 /* protect access to the message list */
99 Disable();
101 /* loop over the messages */
102 ForeachNodeSafe(&port->mp_MsgList, nm, tmp) {
103 /* if its one of our notify messages */
104 if (nm->nm_Class == NOTIFY_CLASS &&
105 nm->nm_Code == NOTIFY_CODE &&
106 nm->nm_NReq == notify) {
108 /* remove and reply */
109 Remove((struct Node *) nm);
110 ReplyMsg((struct Message *) nm);
112 /* decrement the count. bail early if we've done them all */
113 notify->nr_MsgCount--;
114 if (notify->nr_MsgCount == 0)
115 break;
119 /* unlock the list */
120 Enable();
123 SetIoErr(iofs.io_DosError);
125 AROS_LIBFUNC_EXIT
126 } /* EndNotify */