Wow. Fix those irq #defines for ARM and use the right one in power-c200_e200.c. How...
[kugel-rb.git] / firmware / ata_idle_notify.c
blobab2233da1f264f03c52019d49b4f1111bd01e823
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2006 Jonathan Gordon
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
19 #include <stdbool.h>
20 #include "system.h"
21 #include "ata.h"
22 #include "ata_idle_notify.h"
23 #include "kernel.h"
24 #include "string.h"
26 void register_ata_idle_func(ata_idle_notify function)
28 #if USING_ATA_CALLBACK
29 add_event(DISK_EVENT_SPINUP, true, function);
30 #else
31 function(); /* just call the function now */
32 /* this _may_ cause problems later if the calling function
33 sets a variable expecting the callback to unset it, because
34 the callback will be run before this function exits, so before the var is set */
35 #endif
38 #if USING_ATA_CALLBACK
39 void unregister_ata_idle_func(ata_idle_notify func, bool run)
41 remove_event(DISK_EVENT_SPINUP, func);
43 if (run)
44 func();
47 bool call_ata_idle_notifys(bool force)
49 static int lock_until = 0;
51 if (!force)
53 if (TIME_BEFORE(current_tick,lock_until) )
54 return false;
56 lock_until = current_tick + 30*HZ;
58 send_event(DISK_EVENT_SPINUP, NULL);
60 return true;
62 #endif