- Removed unused HandleEvent method.
[AROS.git] / arch / m68k-all / dosboot / bootcode.c
blob0b55cd2e1d696fed8d0c1cd6f83bee12852179bf
1 #include <aros/debug.h>
2 #include <libraries/configvars.h>
3 #include <libraries/expansion.h>
4 #include <libraries/expansionbase.h>
5 #include <utility/tagitem.h>
6 #include <dos/filehandler.h>
8 #include <proto/exec.h>
11 * Execute the code in the boot block.
12 * This can be custom defined for your architecture.
14 * Returns 0 on success, or an error code
16 VOID_FUNC CallBootBlockCode(APTR bootcode, struct IOStdReq *io, struct ExpansionBase *ExpansionBase)
18 UBYTE oldflags = ExpansionBase->Flags & EBF_SILENTSTART;
19 LONG retval;
20 VOID_FUNC init;
22 D(bug("[Strap] Calling bootblock 0x%p!\n", bootcode));
24 ExpansionBase->Flags &= ~EBF_SILENTSTART;
26 /* Lovely. Double return values. What func. */
27 asm volatile (
28 "move.l %2,%%a1\n"
29 "move.l %4,%%a0\n"
30 "move.l %%a6,%%sp@-\n"
31 "move.l %3,%%a6\n"
32 "jsr.l (%%a0)\n"
33 "move.l %%sp@+,%%a6\n"
34 "move.l %%d0,%0\n"
35 "move.l %%a0,%1\n"
36 : "=m" (retval), "=m" (init)
37 : "m" (io), "r" (SysBase),
38 "m" (bootcode)
39 : "%d0", "%d1", "%a0", "%a1");
40 D(bug("bootblock: D0=0x%08x A0=%p\n", retval, init));
42 if (retval != 0)
44 D(bug("[Strap] Boot block failed to boot.\n"));
46 ExpansionBase->Flags |= oldflags;
47 return NULL;
50 return init;
53 /* BootPoint booting, as describe in the Amiga Devices Manual */
54 void dosboot_BootPoint(struct BootNode *bn)
56 struct DeviceNode *dn;
57 struct FileSysStartupMsg *fssm;
58 struct DosEnvec *de;
59 IPTR bootblocks;
61 dn = bn->bn_DeviceNode;
62 if (dn == NULL || dn->dn_Name == BNULL)
63 return;
65 fssm = BADDR(dn->dn_Startup);
66 if (fssm == NULL)
67 return;
69 de = BADDR(fssm->fssm_Environ);
70 if (de == NULL)
71 return;
73 bootblocks = (de->de_TableSize < DE_BOOTBLOCKS) ? 0 : de->de_BootBlocks;
75 /* BootPoint nodes */
76 if (bootblocks == 0 && bn->bn_Node.ln_Name != NULL)
78 struct ConfigDev *cd = (APTR)bn->bn_Node.ln_Name;
80 if (cd->cd_Rom.er_DiagArea != NULL)
82 struct DiagArea *da = cd->cd_Rom.er_DiagArea;
84 if (da->da_Config & DAC_CONFIGTIME)
86 /* Yes, it's actually a BootPoint node */
87 void *func = (APTR)(((IPTR)da) + da->da_BootPoint);
89 D(bug("dosboot_BootStrap: Calling %b BootPoint @%p\n", dn->dn_Name, func));
92 * Yet another crazy Amiga calling sequence.
93 * The ConfigDev is pushed on the stack, but
94 * the BootNode is in A2. Joy.
96 * Oh, and don't forget SysBase in A6!
98 asm volatile (
99 "move.l %0,%%a0\n"
100 "move.l %1,%%a1\n"
101 "move.l %2,%%a2\n"
102 "move.l %3,%%a6\n"
103 "move.l %%a1,%%sp@-\n"
104 "jsr %%a0@\n"
105 "addq.l #4,%%sp\n"
107 : "d" (func), "d" (cd), "d" (bn), "d" (SysBase)
108 : "d0", "d1", "a0", "a1", "a2", "a6"