]>
Commit | Line | Data |
---|---|---|
6022e28c JJ |
1 | /** @file\r |
2 | CPU DXE Module.\r | |
3 | \r | |
4 | Copyright (c) 2008 - 2014, Intel Corporation. All rights reserved.<BR>\r | |
5 | This program and the accompanying materials\r | |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
13 | **/\r | |
14 | \r | |
15 | #include "CpuDxe.h"\r | |
16 | #include "CpuMp.h"\r | |
17 | \r | |
6a26a597 CF |
18 | UINTN gMaxLogicalProcessorNumber;\r |
19 | UINTN gApStackSize;\r | |
20 | \r | |
fab82c18 JJ |
21 | VOID *mCommonStack = 0;\r |
22 | VOID *mTopOfApCommonStack = 0;\r | |
6a26a597 | 23 | VOID *mApStackStart = 0;\r |
fab82c18 | 24 | \r |
6a26a597 | 25 | volatile UINTN mNumberOfProcessors;\r |
fab82c18 | 26 | \r |
1535c888 JJ |
27 | /**\r |
28 | Application Processor C code entry point.\r | |
29 | \r | |
30 | **/\r | |
31 | VOID\r | |
32 | EFIAPI\r | |
33 | ApEntryPointInC (\r | |
34 | VOID\r | |
35 | )\r | |
36 | {\r | |
6a26a597 | 37 | mNumberOfProcessors++;\r |
1535c888 JJ |
38 | }\r |
39 | \r | |
40 | \r | |
6022e28c JJ |
41 | /**\r |
42 | Initialize Multi-processor support.\r | |
43 | \r | |
44 | **/\r | |
45 | VOID\r | |
46 | InitializeMpSupport (\r | |
47 | VOID\r | |
48 | )\r | |
49 | {\r | |
6a26a597 CF |
50 | gMaxLogicalProcessorNumber = (UINTN) PcdGet32 (PcdCpuMaxLogicalProcessorNumber);\r |
51 | if (gMaxLogicalProcessorNumber < 1) {\r | |
52 | DEBUG ((DEBUG_ERROR, "Setting PcdCpuMaxLogicalProcessorNumber should be more than zero.\n"));\r | |
53 | return;\r | |
54 | }\r | |
55 | \r | |
56 | if (gMaxLogicalProcessorNumber == 1) {\r | |
57 | return;\r | |
58 | }\r | |
59 | \r | |
60 | gApStackSize = (UINTN) PcdGet32 (PcdCpuApStackSize);\r | |
61 | ASSERT ((gApStackSize & (SIZE_4KB - 1)) == 0);\r | |
62 | \r | |
63 | mApStackStart = AllocatePages (EFI_SIZE_TO_PAGES (gMaxLogicalProcessorNumber * gApStackSize));\r | |
64 | ASSERT (mApStackStart != NULL);\r | |
6022e28c | 65 | \r |
6a26a597 CF |
66 | //\r |
67 | // the first buffer of stack size used for common stack, when the amount of AP\r | |
68 | // more than 1, we should never free the common stack which maybe used for AP reset.\r | |
69 | //\r | |
70 | mCommonStack = mApStackStart;\r | |
71 | mTopOfApCommonStack = (UINT8*) mApStackStart + gApStackSize;\r | |
72 | mApStackStart = mTopOfApCommonStack;\r | |
73 | \r | |
74 | mNumberOfProcessors = 1;\r | |
75 | \r | |
76 | if (mNumberOfProcessors == 1) {\r | |
77 | FreePages (mCommonStack, EFI_SIZE_TO_PAGES (gMaxLogicalProcessorNumber * gApStackSize));\r | |
78 | return;\r | |
79 | }\r | |
80 | \r | |
81 | if (mNumberOfProcessors < gMaxLogicalProcessorNumber) {\r | |
82 | FreePages (mApStackStart, EFI_SIZE_TO_PAGES ((gMaxLogicalProcessorNumber - mNumberOfProcessors) *\r | |
83 | gApStackSize));\r | |
84 | }\r | |
85 | }\r |