5 * Init the Socket and Node maps for Recovery mode.
7 * Create the Socket and Node maps just like normal boot,
8 * except that they only indicate the BSC is present.
10 * @xrefitem bom "File Content Label" "Release Content"
12 * @e sub-project: HyperTransport
13 * @e \$Revision: 44324 $ @e \$Date: 2010-12-22 02:16:51 -0700 (Wed, 22 Dec 2010) $
17 *****************************************************************************
19 * Copyright (C) 2012 Advanced Micro Devices, Inc.
20 * All rights reserved.
22 * Redistribution and use in source and binary forms, with or without
23 * modification, are permitted provided that the following conditions are met:
24 * * Redistributions of source code must retain the above copyright
25 * notice, this list of conditions and the following disclaimer.
26 * * Redistributions in binary form must reproduce the above copyright
27 * notice, this list of conditions and the following disclaimer in the
28 * documentation and/or other materials provided with the distribution.
29 * * Neither the name of Advanced Micro Devices, Inc. nor the names of
30 * its contributors may be used to endorse or promote products derived
31 * from this software without specific prior written permission.
33 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
34 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
35 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
36 * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
37 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
38 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
39 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
40 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
41 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
42 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
44 * ***************************************************************************
52 #include "heapManager.h"
57 #define FILECODE PROC_RECOVERY_HT_HTINITRECOVERY_FILECODE
61 IN AMD_CONFIG_PARAMS *StdHeader
64 /*----------------------------------------------------------------------------------------*/
66 * Get new Socket and Node Maps.
68 * Put the Socket Die Table and the Node Table in heap with known handles.
70 * @param[out] SocketDieToNodeMap The Socket, Module to Node info map
71 * @param[out] NodeToSocketDieMap The Node to Socket, Module map.
72 * @param[in] StdHeader Header for library and services.
76 NewNodeAndSocketTablesRecovery (
77 OUT SOCKET_DIE_TO_NODE_MAP *SocketDieToNodeMap,
78 OUT NODE_TO_SOCKET_DIE_MAP *NodeToSocketDieMap,
79 IN AMD_CONFIG_PARAMS *StdHeader
84 ALLOCATE_HEAP_PARAMS AllocHeapParams;
86 // Allocate heap for the table
87 AllocHeapParams.RequestedBufferSize = (((MAX_SOCKETS) * (MAX_DIES)) * sizeof (SOCKET_DIE_TO_NODE_ITEM));
88 AllocHeapParams.BufferHandle = SOCKET_DIE_MAP_HANDLE;
89 AllocHeapParams.Persist = HEAP_SYSTEM_MEM;
90 if (HeapAllocateBuffer (&AllocHeapParams, StdHeader) == AGESA_SUCCESS) {
91 // HeapAllocateBuffer must set BufferPtr to valid or NULL.
92 *SocketDieToNodeMap = (SOCKET_DIE_TO_NODE_MAP)AllocHeapParams.BufferPtr;
93 ASSERT (SocketDieToNodeMap != NULL);
94 // Initialize shared data structures
95 for (i = 0; i < MAX_SOCKETS; i++) {
96 for (j = 0; j < MAX_DIES; j++) {
97 (**SocketDieToNodeMap)[i][j].Node = HT_LIST_TERMINAL;
98 (**SocketDieToNodeMap)[i][j].LowCore = HT_LIST_TERMINAL;
99 (**SocketDieToNodeMap)[i][j].HighCore = HT_LIST_TERMINAL;
103 // Allocate heap for the table
104 AllocHeapParams.RequestedBufferSize = (MAX_NODES * sizeof (NODE_TO_SOCKET_DIE_ITEM));
105 AllocHeapParams.BufferHandle = NODE_ID_MAP_HANDLE;
106 AllocHeapParams.Persist = HEAP_SYSTEM_MEM;
107 if (HeapAllocateBuffer (&AllocHeapParams, StdHeader) == AGESA_SUCCESS) {
108 // HeapAllocateBuffer must set BufferPtr to valid or NULL.
109 *NodeToSocketDieMap = (NODE_TO_SOCKET_DIE_MAP)AllocHeapParams.BufferPtr;
110 ASSERT (NodeToSocketDieMap != NULL);
111 // Initialize shared data structures
112 for (i = 0; i < MAX_NODES; i++) {
113 (**NodeToSocketDieMap)[i].Socket = HT_LIST_TERMINAL;
114 (**NodeToSocketDieMap)[i].Die = HT_LIST_TERMINAL;
119 /*----------------------------------------------------------------------------------------*/
121 * Initialize the Node and Socket maps for an AP Core.
123 * In each core's local heap, create a Node to Socket map and a Socket/Module to Node map.
124 * The mapping is filled in by reading the AP Mailboxes from PCI config on each node.
126 * @param[in] StdHeader global state, input data
128 * @retval AGESA_SUCCESS Always succeeds.
132 IN AMD_CONFIG_PARAMS *StdHeader
135 AP_MAILBOXES NodeApMailBox;
136 ALLOCATE_HEAP_PARAMS AllocHeapParams;
137 SOCKET_DIE_TO_NODE_MAP SocketDieToNodeMap = NULL;
138 NODE_TO_SOCKET_DIE_MAP NodeToSocketDieMap = NULL;
140 NodeApMailBox.ApMailInfo.Info = 0;
141 NodeApMailBox.ApMailExtInfo.Info = 0;
143 // Allocate heap for caching the mailboxes
144 AllocHeapParams.RequestedBufferSize = sizeof (AP_MAILBOXES);
145 AllocHeapParams.BufferHandle = LOCAL_AP_MAIL_BOX_CACHE_HANDLE;
146 AllocHeapParams.Persist = HEAP_SYSTEM_MEM;
147 if (HeapAllocateBuffer (&AllocHeapParams, StdHeader) == AGESA_SUCCESS) {
148 *(AP_MAILBOXES *)AllocHeapParams.BufferPtr = NodeApMailBox;
151 NewNodeAndSocketTablesRecovery (&SocketDieToNodeMap, &NodeToSocketDieMap, StdHeader);
152 // HeapAllocateBuffer must set BufferPtr to valid or NULL, so the checks below are ok.
154 // There is no option to not have socket - node maps, if they aren't allocated that is a fatal bug.
155 ASSERT (SocketDieToNodeMap != NULL);
156 ASSERT (NodeToSocketDieMap != NULL);
158 (*SocketDieToNodeMap)[0][0].Node = 0;
159 (*SocketDieToNodeMap)[0][0].LowCore = 0;
160 (*SocketDieToNodeMap)[0][0].HighCore = 0;
162 // We lie about being Socket 0 and Module 0 always, it isn't necessarily true.
163 (*NodeToSocketDieMap)[0].Socket = (UINT8)0;
164 (*NodeToSocketDieMap)[0].Die = (UINT8)0;
166 return AGESA_SUCCESS;