2 Copyright © 2010-2017, The AROS Development Team. All rights reserved.
6 #include <aros/config.h>
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
;
33 ReadProcessorInformation(procInfo
);
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 };
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
);
58 for (cpuNo
= 0; cpuNo
< ProcessorBase
->cpucount
; cpuNo
++)
60 sysprocs
[cpuNo
] = AllocMem(sizeof(struct X86ProcessorInformation
), MEMF_CLEAR
);
63 #if !defined(__AROSEXEC_SMP__)
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
,
86 TASKTAG_PC
, Processor_QueryTask
,
87 TASKTAG_ARG1
, SysBase
,
88 TASKTAG_USERDATA
, sysprocs
[cpuNo
],
91 if (processorQueryTask
)
93 //AddTail(&processorQueryTask->tc_MemEntry, &ml->ml_Node);
96 FreeMem(ml
->ml_ME
[0].me_Addr
, 22);
97 FreeMem(ml
, sizeof(struct MemList
));
101 bug("[processor.x86] FATAL : Failed to allocate memory for processor query name");
102 FreeMem(ml
, sizeof(struct MemList
));
107 bug("[processor.x86] FATAL : Failed to allocate additional memory for processor query task");
113 ProcessorBase
->Private1
= sysprocs
;
118 ADD2INITLIB(Processor_Init
, 1);