add place-holder directory for the a3000 wd533c93 scsi controller implementation.
[AROS.git] / rom / devs / scsi / bootwait.c
blob1b62a50013db5e500a38429f339af02e4115bd0a
1 /*
2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
3 $Id: bootwait.c 55802 2019-03-08 21:47:59Z wawa $
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 "scsi.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 scsi_LibName[];
24 extern const char scsi_LibID[];
25 extern const int scsi_End;
27 AROS_UFP3(static APTR, scsi_Wait,
28 AROS_UFPA(void *, dummy, D0),
29 AROS_UFPA(BPTR, segList, A0),
30 AROS_UFPA(struct ExecBase *, SysBase, A6));
32 const struct Resident scsi_BootWait =
34 RTC_MATCHWORD,
35 (struct Resident *)&scsi_BootWait,
36 (void *)&scsi_End,
37 RTF_COLDSTART,
38 VERSION_NUMBER,
39 NT_TASK,
40 -49, /* dosboot.resource is -50 */
41 "SCSI boot wait",
42 &scsi_LibID[6],
43 &scsi_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, scsi_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 scsiBase *SCSIBase;
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 SCSIBase = (struct scsiBase *)FindName(&SysBase->DeviceList, scsi_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 (SCSIBase)
93 D(bug("[SCSI ] Waiting for device detection to complete...\n"));
94 ObtainSemaphore(&SCSIBase->DetectionSem);
95 ReleaseSemaphore(&SCSIBase->DetectionSem);
98 return NULL;
100 AROS_USERFUNC_EXIT