Forgotten changes that should have been part of the r45368 64-bit fix.
[AROS.git] / rom / usb / poseidon / usbromstartup.c
blob93ca4ad6210f2666c515f8eae4d34f281af2c462
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 D(bug("[USBROMStartup] Scanning classes...\n"));
81 psdClassScan();
83 if(msdclass)
85 psdDelayMS(1000); // wait for hubs to settle
86 psdGetAttrs(PGA_USBCLASS, msdclass, UCA_UseCount, &usecount, TAG_END);
87 if(usecount > 0)
89 psdAddErrorMsg(RETURN_OK, (STRPTR)name,
90 "Delaying further execution by %ld second(s) (boot delay).",
91 bootdelay);
92 if(bootdelay > 1)
94 psdDelayMS((bootdelay-1)*1000);
96 } else {
97 psdAddErrorMsg(RETURN_OK, (STRPTR)name, "Boot delay skipped, no mass storage devices found.");
101 CloseLibrary(ps);
103 return 0;
105 AROS_USERFUNC_EXIT
108 static const UBYTE endptr = 0;