Documented GVF_SAVE_VAR alongside other flags, and removed a query/doubt
[AROS.git] / rom / usb / poseidon / usbromstartup.c
blobb5ba14cdbf4760e4c8bb16a2e55471efff1773e0
1 /* Very basic bootstrap for Poseidon in AROS kernel for enabling of USB booting and HID devices.
2 * PsdStackloader should be started during startup-sequence nonetheless */
4 #include <aros/asmcall.h>
5 #include <aros/debug.h>
6 #include <aros/symbolsets.h>
7 #include <exec/resident.h>
8 #include <proto/poseidon.h>
9 #include <proto/exec.h>
11 int __startup usbromstartup_entry(void)
13 return -1;
16 static const char name[];
17 static const char version[];
18 static const UBYTE endptr;
20 AROS_UFP3(static IPTR, usbromstartup_init,
21 AROS_UFHA(ULONG, dummy, D0),
22 AROS_UFHA(BPTR, seglist, A0),
23 AROS_UFHA(struct ExecBase *, SysBase, A6));
25 const struct Resident usbHook =
27 RTC_MATCHWORD,
28 (struct Resident *)&usbHook,
29 (APTR)&endptr,
30 RTF_COLDSTART,
31 41,
32 NT_TASK,
33 35,
34 name,
35 &version[5],
36 (APTR)usbromstartup_init
39 static const char name[] = "Poseidon ROM starter";
40 static const char version[] = "$VER:Poseidon ROM startup v41.1";
42 AROS_UFH3(static IPTR, usbromstartup_init,
43 AROS_UFHA(ULONG, dummy, D0),
44 AROS_UFHA(BPTR, seglist, A0),
45 AROS_UFHA(struct ExecBase *, SysBase, A6))
47 AROS_USERFUNC_INIT
49 struct Library *ps;
50 struct PsdHardware *phw;
51 ULONG cnt = 0;
53 D(bug("[USBROMStartup] Loading poseidon...\n"));
55 if((ps = OpenLibrary("poseidon.library", 4)))
57 APTR msdclass;
58 IPTR usecount = 0;
59 ULONG bootdelay = 4;
61 D(bug("[USBROMStartup] Adding classes...\n"));
63 psdAddClass("hub.class", 0);
64 if(!(psdAddClass("hid.class", 0)))
66 psdAddClass("bootmouse.class", 0);
67 psdAddClass("bootkeyboard.class", 0);
69 msdclass = psdAddClass("massstorage.class", 0);
71 /* now this finds all usb hardware pci cards */
72 while((phw = psdAddHardware("pciusb.device", cnt)))
74 D(bug("[USBROMStartup] Added pciusb.device unit %u\n", cnt));
76 psdEnumerateHardware(phw);
77 cnt++;
80 if (cnt == 0) {
81 /* now this finds all other usb hardware pci cards */
82 while((phw = psdAddHardware("ehci.device", cnt)))
84 D(bug("[USBROMStartup] Added ehci.device unit %u\n", cnt));
86 psdEnumerateHardware(phw);
87 cnt++;
89 cnt = 0;
90 while((phw = psdAddHardware("ohci.device", cnt)))
92 D(bug("[USBROMStartup] Added ohci.device unit %u\n", cnt));
94 psdEnumerateHardware(phw);
95 cnt++;
97 cnt = 0;
98 while((phw = psdAddHardware("uhci.device", cnt)))
100 D(bug("[USBROMStartup] Added uhci.device unit %u\n", cnt));
102 psdEnumerateHardware(phw);
103 cnt++;
107 D(bug("[USBROMStartup] Scanning classes...\n"));
108 psdClassScan();
110 if(msdclass)
112 psdDelayMS(1000); // wait for hubs to settle
113 psdGetAttrs(PGA_USBCLASS, msdclass, UCA_UseCount, &usecount, TAG_END);
114 if(usecount > 0)
116 psdAddErrorMsg(RETURN_OK, (STRPTR)name,
117 "Delaying further execution by %ld second(s) (boot delay).",
118 bootdelay);
119 if(bootdelay > 1)
121 psdDelayMS((bootdelay-1)*1000);
123 } else {
124 psdAddErrorMsg(RETURN_OK, (STRPTR)name, "Boot delay skipped, no mass storage devices found.");
128 CloseLibrary(ps);
130 return 0;
132 AROS_USERFUNC_EXIT
135 static const UBYTE endptr = 0;