Copyright clean-up (part 1):
[AROS.git] / arch / arm-raspi / usb / poseidon / usbromstartup.c
blobce5acb0382850879fd6b91f7a5fbdffe235f08b9
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 /* Very basic bootstrap for Poseidon in AROS kernel for enabling of USB booting and HID devices.
7 * PsdStackloader should be started during startup-sequence nonetheless */
9 #define DEBUG 1
11 #include <aros/asmcall.h>
12 #include <aros/debug.h>
13 #include <aros/symbolsets.h>
14 #include <exec/resident.h>
15 #include <proto/poseidon.h>
16 #include <proto/exec.h>
18 int __startup usbromstartup_entry(void)
20 return -1;
23 static const char name[];
24 static const char version[];
25 static const UBYTE endptr;
27 AROS_UFP3(static IPTR, usbromstartup_init,
28 AROS_UFHA(ULONG, dummy, D0),
29 AROS_UFHA(BPTR, seglist, A0),
30 AROS_UFHA(struct ExecBase *, SysBase, A6));
32 const struct Resident usbHook =
34 RTC_MATCHWORD,
35 (struct Resident *)&usbHook,
36 (APTR)&endptr,
37 RTF_COLDSTART,
38 41,
39 NT_TASK,
40 35,
41 name,
42 &version[5],
43 (APTR)usbromstartup_init
46 static const char name[] = "Poseidon ROM starter";
47 static const char version[] = "$VER:Poseidon ROM startup v41.1";
49 AROS_UFH3(static IPTR, usbromstartup_init,
50 AROS_UFHA(ULONG, dummy, D0),
51 AROS_UFHA(BPTR, seglist, A0),
52 AROS_UFHA(struct ExecBase *, SysBase, A6))
54 AROS_USERFUNC_INIT
56 struct Library *ps;
57 struct PsdHardware *phw;
59 D(bug("[USBROMStartup] Loading poseidon...\n"));
61 if((ps = OpenLibrary("poseidon.library", 4)))
63 APTR msdclass;
64 IPTR usecount = 0;
65 ULONG bootdelay = 4;
67 D(bug("[USBROMStartup] Adding classes...\n"));
69 psdAddClass("hub.class", 0);
70 if(!(psdAddClass("hid.class", 0)))
72 psdAddClass("bootmouse.class", 0);
73 psdAddClass("bootkeyboard.class", 0);
75 msdclass = psdAddClass("massstorage.class", 0);
77 D(bug("[USBROMStartup] Added chipset drivers...\n"));
79 /* load the raspi usb hardware driver */
80 if ((phw = psdAddHardware("usb2otg.device", 0)))
82 D(bug("[USBROMStartup] Added usb2otg.device unit %u\n", 0));
84 psdEnumerateHardware(phw);
87 D(bug("[USBROMStartup] Scanning classes...\n"));
88 psdClassScan();
89 D(bug("[USBROMStartup] classes enumerated\n"));
91 if(msdclass)
93 D(bug("[USBROMStartup] waiting for hubs..\n"));
94 psdDelayMS(1000); // wait for hubs to settle
95 D(bug("[USBROMStartup] checking for massstorage devices..\n"));
96 psdGetAttrs(PGA_USBCLASS, msdclass, UCA_UseCount, &usecount, TAG_END);
97 D(bug("[USBROMStartup] %d masstorage devices found\n", usecount));
98 if(usecount > 0)
100 D(bug("[USBROMStartup] adding boot delay\n"));
102 psdAddErrorMsg(RETURN_OK, (STRPTR)name,
103 "Delaying further execution by %ld second(s) (boot delay).",
104 bootdelay);
105 if(bootdelay > 1)
107 psdDelayMS((bootdelay-1)*1000);
109 } else {
110 psdAddErrorMsg(RETURN_OK, (STRPTR)name, "Boot delay skipped, no mass storage devices found.");
114 D(bug("[USBROMStartup] cleaning up .. \n"));
115 CloseLibrary(ps);
117 D(bug("[USBROMStartup] Finished...\n"));
119 return 0;
121 AROS_USERFUNC_EXIT
124 static const UBYTE endptr = 0;