2 Copyright © 2015, The AROS Development Team. All rights reserved.
6 #include <proto/kernel.h>
7 #include <proto/exec.h>
12 #include "exec_intern.h"
16 #if defined(__AROSEXEC_SMP__)
17 extern BOOL
Exec_InitETask(struct Task
*, struct ExecBase
*);
19 struct Task
*cpu_InitBootStrap(struct ExecBase
*SysBase
)
21 struct ExceptionContext
*bsctx
;
26 asm volatile (" mrc p15, 0, %0, c0, c0, 5 " : "=r" (tmp
));
28 if ((bstask
= AllocMem(sizeof(struct Task
), MEMF_PUBLIC
|MEMF_CLEAR
)) == NULL
)
30 bug("[KRN] CPU #%02d FATAL : Failed to allocate task for bootstrap", (tmp
& 0x3));
34 if ((ml
= AllocMem(sizeof(struct MemList
), MEMF_PUBLIC
|MEMF_CLEAR
)) == NULL
)
36 bug("[KRN] CPU #%02d FATAL : Failed to allocate memory for bootstrap task", (tmp
& 0x3));
37 FreeMem(bstask
, sizeof(struct Task
));
41 D(bug("[KRN] CPU #%02d Bootstrap task @ 0x%p\n", (tmp
& 0x3), bstask
));
43 if ((bsctx
= KrnCreateContext()) == NULL
)
45 bug("[KRN] CPU %d FATAL : Failed to create the boostrap task context\n", (tmp
& 0x3));
46 FreeMem(ml
, sizeof(struct MemList
));
47 FreeMem(bstask
, sizeof(struct Task
));
51 D(bug("[KRN] CPU #%02d cpu ctx @ 0x%p\n", (tmp
& 0x3), bsctx
));
53 NEWLIST(&bstask
->tc_MemEntry
);
55 if ((bstask
->tc_Node
.ln_Name
= AllocVec(20, MEMF_CLEAR
)) != NULL
)
57 sprintf(bstask
->tc_Node
.ln_Name
, "CPU #%02d Bootstrap", (tmp
& 0x3));
59 bstask
->tc_Node
.ln_Type
= NT_TASK
;
60 bstask
->tc_Node
.ln_Pri
= 0;
61 bstask
->tc_State
= TS_RUN
;
62 bstask
->tc_SigAlloc
= 0xFFFF;
64 /* Build bootstraps memory list */
65 ml
->ml_NumEntries
= 1;
66 ml
->ml_ME
[0].me_Addr
= bstask
;
67 ml
->ml_ME
[0].me_Length
= sizeof(struct Task
);
68 AddHead(&bstask
->tc_MemEntry
, &ml
->ml_Node
);
70 /* Create a ETask structure and attach CPU context */
71 if (!Exec_InitETask(bstask
, SysBase
))
73 bug("[KRN] CPU %d FATAL : Failed to initialize boostrap etask\n", (tmp
& 0x3));
74 FreeVec(bstask
->tc_Node
.ln_Name
);
75 FreeMem(ml
, sizeof(struct MemList
));
76 FreeMem(bstask
, sizeof(struct Task
));
79 bstask
->tc_UnionETask
.tc_ETask
->et_RegFrame
= bsctx
;
81 /* This Bootstrap task can run only on one of the available cores */
82 IntETask(bstask
->tc_UnionETask
.tc_ETask
)->iet_CpuNumber
= (tmp
& 0x3);
83 IntETask(bstask
->tc_UnionETask
.tc_ETask
)->iet_CpuAffinity
= 1 << (tmp
& 0x3);
88 void cpu_BootStrap(struct Task
*bstask
, struct ExecBase
*SysBase
)
90 SET_THIS_TASK(bstask
);