revert commit 56204.
[AROS.git] / arch / all-pc / processor / processor_init.c
blobf4478ada124980f5f29292f337fba31e50f37733
1 /*
2 Copyright © 2010-2017, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <aros/config.h>
8 #define DEBUG 0
9 #include <aros/debug.h>
11 #include <proto/exec.h>
12 #include <proto/kernel.h>
13 #include <aros/symbolsets.h>
15 #include <exec/tasks.h>
16 #include <exec/rawfmt.h>
18 #include "processor_intern.h"
19 #include "processor_arch_intern.h"
21 void Processor_QueryTask(struct ExecBase *SysBase)
23 struct X86ProcessorInformation *procInfo;
24 struct Task *thisTask;
26 D(bug("[processor.x86] %s()\n", __func__));
27 D(bug("[processor.x86] %s: SysBase @ 0x%p\n", __func__, SysBase));
29 thisTask = FindTask(NULL);
30 procInfo = thisTask->tc_UserData;
32 if (procInfo)
33 ReadProcessorInformation(procInfo);
34 else
35 bug("[processor.x86] %s: ERROR: procinfo missing!\n", __func__)
37 D(bug("[processor.x86] %s: Finished!\n", __func__));
40 LONG Processor_Init(struct ProcessorBase * ProcessorBase)
42 struct X86ProcessorInformation **sysprocs;
43 struct Task *processorQueryTask;
44 char *processorQueryTaskName;
45 IPTR cpuNameArg[] = { 0 };
46 struct MemList *ml;
47 unsigned int cpuNo;
48 BOOL retval = TRUE;
49 void *taskAffinity;
51 D(bug("[processor.x86] %s()\n", __func__));
52 D(bug("[processor.x86] %s: SysBase @ 0x%p, ProcessorBase @ 0x%p\n", __func__, SysBase, ProcessorBase));
54 sysprocs = AllocVec(ProcessorBase->cpucount * sizeof(APTR), MEMF_ANY | MEMF_CLEAR);
55 if (sysprocs == NULL)
56 return FALSE;
58 for (cpuNo = 0; cpuNo < ProcessorBase->cpucount; cpuNo++)
60 sysprocs[cpuNo] = AllocMem(sizeof(struct X86ProcessorInformation), MEMF_CLEAR);
61 if (sysprocs[cpuNo])
63 #if !defined(__AROSEXEC_SMP__)
64 if (cpuNo > 0)
65 continue;
66 #endif
67 cpuNameArg[0] = (IPTR)cpuNo + 1;
69 if ((ml = AllocMem(sizeof(struct MemList), MEMF_PUBLIC|MEMF_CLEAR)) != NULL)
71 ml->ml_NumEntries = 1;
73 ml->ml_ME[0].me_Length = 22;
74 if ((ml->ml_ME[0].me_Addr = AllocMem(22, MEMF_PUBLIC|MEMF_CLEAR)) != NULL)
76 processorQueryTaskName = (char *)ml->ml_ME[0].me_Addr;
78 RawDoFmt("Processor #%03u Query", (RAWARG)cpuNameArg, RAWFMTFUNC_STRING, processorQueryTaskName);
80 taskAffinity = KrnAllocCPUMask();
81 KrnGetCPUMask(cpuNo, taskAffinity);
83 processorQueryTask = NewCreateTask(TASKTAG_NAME , processorQueryTaskName,
84 TASKTAG_AFFINITY , taskAffinity,
85 TASKTAG_PRI , 100,
86 TASKTAG_PC , Processor_QueryTask,
87 TASKTAG_ARG1 , SysBase,
88 TASKTAG_USERDATA, sysprocs[cpuNo],
89 TAG_DONE);
91 if (processorQueryTask)
93 //AddTail(&processorQueryTask->tc_MemEntry, &ml->ml_Node);
94 continue;
96 FreeMem(ml->ml_ME[0].me_Addr, 22);
97 FreeMem(ml, sizeof(struct MemList));
99 else
101 bug("[processor.x86] FATAL : Failed to allocate memory for processor query name");
102 FreeMem(ml, sizeof(struct MemList));
105 else
107 bug("[processor.x86] FATAL : Failed to allocate additional memory for processor query task");
110 retval = FALSE;
113 ProcessorBase->Private1 = sysprocs;
115 return retval;
118 ADD2INITLIB(Processor_Init, 1);