add stubs for the ata trim/smart commands. make sysexplorer's ata and ahci modules...
[AROS.git] / rom / devs / ata / bootwait.c
blob08c8dc5a1f469ac0b6a3fb86a6071f55bc5afbee
1 /*
2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <aros/debug.h>
7 #include <proto/exec.h>
9 #include <aros/asmcall.h>
10 #include <exec/resident.h>
11 #include <libraries/expansionbase.h>
13 #include LC_LIBDEFS_FILE
15 #include "ata.h"
17 #if defined(__AROSPLATFORM_SMP__)
18 #include <aros/types/spinlock_s.h>
19 #include <proto/execlock.h>
20 #include <resources/execlock.h>
21 #endif
23 extern const char ata_LibName[];
24 extern const char ata_LibID[];
25 extern const int ata_End;
27 AROS_UFP3(static APTR, ata_Wait,
28 AROS_UFPA(void *, dummy, D0),
29 AROS_UFPA(BPTR, segList, A0),
30 AROS_UFPA(struct ExecBase *, SysBase, A6));
32 const struct Resident ata_BootWait =
34 RTC_MATCHWORD,
35 (struct Resident *)&ata_BootWait,
36 (void *)&ata_End,
37 RTF_COLDSTART,
38 VERSION_NUMBER,
39 NT_TASK,
40 -49, /* dosboot.resource is -50 */
41 "ATA boot wait",
42 &ata_LibID[6],
43 &ata_Wait,
47 * The purpose of this delay is to wait until device detection is done
48 * before boot sequence enters DOS bootstrap. Without this we reach the
49 * bootstrap earlier than devices are detected (and BootNodes inserted).
50 * As a result, we end up in unbootable system.
51 * Actually, i dislike this solution a bit. I think something else has
52 * to be implemented. However i do not know what. Even if we rewrite
53 * adding BootNodes, bootmenu still has to wait until all nodes are added.
54 * Making device detection synchronous is IMHO not a good option, it will
55 * increase booting time of our OS.
58 AROS_UFH3(static APTR, ata_Wait,
59 AROS_UFPA(void *, dummy, D0),
60 AROS_UFPA(BPTR, segList, A0),
61 AROS_UFPA(struct ExecBase *, SysBase, A6))
63 AROS_USERFUNC_INIT
65 struct ataBase *ATABase;
66 #if defined(__AROSPLATFORM_SMP__)
67 void *ExecLockBase = OpenResource("execlock.resource");
68 #endif
70 #if defined(__AROSPLATFORM_SMP__)
71 if (ExecLockBase)
72 ObtainSystemLock(&SysBase->DeviceList, SPINLOCK_MODE_READ, LOCKF_FORBID);
73 else
74 Forbid();
75 #else
76 Forbid();
77 #endif
79 /* We do not want to deal with IORequest and units, so just FindName() */
80 ATABase = (struct ataBase *)FindName(&SysBase->DeviceList, ata_LibName);
82 #if defined(__AROSPLATFORM_SMP__)
83 if (ExecLockBase)
84 ReleaseSystemLock(&SysBase->DeviceList, LOCKF_FORBID);
85 else
86 Permit();
87 #else
88 Permit();
89 #endif
91 if (ATABase)
93 D(bug("[ATA ] Waiting for device detection to complete...\n"));
94 ObtainSemaphore(&ATABase->DetectionSem);
95 ReleaseSemaphore(&ATABase->DetectionSem);
98 return NULL;
100 AROS_USERFUNC_EXIT