revert between 56095 -> 55830 in arch
[AROS.git] / arch / m68k-all / dosboot / bootcode.c
blob635094d19270cc29a33a96b300c17dc296bdb159
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <aros/debug.h>
7 #include <libraries/configvars.h>
8 #include <libraries/expansion.h>
9 #include <libraries/expansionbase.h>
10 #include <utility/tagitem.h>
11 #include <dos/filehandler.h>
13 #include <proto/exec.h>
16 * Execute the code in the boot block.
17 * This can be custom defined for your architecture.
19 * Returns 0 on success, or an error code
21 VOID_FUNC CallBootBlockCode(APTR bootcode, struct IOStdReq *io, struct ExpansionBase *ExpansionBase)
23 UBYTE oldflags = ExpansionBase->Flags & EBF_SILENTSTART;
24 LONG retval;
25 VOID_FUNC init;
27 D(bug("[Strap] Calling bootblock 0x%p!\n", bootcode));
29 ExpansionBase->Flags &= ~EBF_SILENTSTART;
31 /* Lovely. Double return values. What func. */
32 asm volatile (
33 "move.l %2,%%a1\n"
34 "move.l %4,%%a0\n"
35 "move.l %%a6,%%sp@-\n"
36 "move.l %3,%%a6\n"
37 "jsr.l (%%a0)\n"
38 "move.l %%sp@+,%%a6\n"
39 "move.l %%d0,%0\n"
40 "move.l %%a0,%1\n"
41 : "=m" (retval), "=m" (init)
42 : "m" (io), "r" (SysBase),
43 "m" (bootcode)
44 : "%d0", "%d1", "%a0", "%a1");
45 D(bug("bootblock: D0=0x%08x A0=%p\n", retval, init));
47 if (retval != 0)
49 D(bug("[Strap] Boot block failed to boot.\n"));
51 ExpansionBase->Flags |= oldflags;
52 return NULL;
55 return init;
58 /* BootPoint booting, as describe in the Amiga Devices Manual */
59 void dosboot_BootPoint(struct BootNode *bn)
61 struct DeviceNode *dn;
62 struct FileSysStartupMsg *fssm;
63 struct DosEnvec *de;
64 IPTR bootblocks;
66 dn = bn->bn_DeviceNode;
67 if (dn == NULL || dn->dn_Name == BNULL)
68 return;
70 fssm = BADDR(dn->dn_Startup);
71 if (fssm == NULL)
72 return;
74 de = BADDR(fssm->fssm_Environ);
75 if (de == NULL)
76 return;
78 bootblocks = (de->de_TableSize < DE_BOOTBLOCKS) ? 0 : de->de_BootBlocks;
80 /* BootPoint nodes */
81 if (bootblocks == 0 && bn->bn_Node.ln_Name != NULL)
83 struct ConfigDev *cd = (APTR)bn->bn_Node.ln_Name;
85 if (cd->cd_Rom.er_DiagArea != NULL)
87 struct DiagArea *da = cd->cd_Rom.er_DiagArea;
89 if (da->da_Config & DAC_CONFIGTIME)
91 /* Yes, it's actually a BootPoint node */
92 void *func = (APTR)(((IPTR)da) + da->da_BootPoint);
94 D(bug("dosboot_BootStrap: Calling %b BootPoint @%p\n", dn->dn_Name, func));
97 * Yet another crazy Amiga calling sequence.
98 * The ConfigDev is pushed on the stack, but
99 * the BootNode is in A2. Joy.
101 * Oh, and don't forget SysBase in A6!
103 asm volatile (
104 "move.l %0,%%a0\n"
105 "move.l %1,%%a1\n"
106 "move.l %2,%%a2\n"
107 "move.l %3,%%a6\n"
108 "move.l %%a1,%%sp@-\n"
109 "jsr %%a0@\n"
110 "addq.l #4,%%sp\n"
112 : "d" (func), "d" (cd), "d" (bn), "d" (SysBase)
113 : "d0", "d1", "a0", "a1", "a2", "a6"