ASSERT (BaseOfStack != 0);\r
\r
//\r
- // Compute the top of the stack we were allocated. Pre-allocate a 32 bytes\r
- // for x64 calling convention.\r
+ // Compute the top of the stack we were allocated, which is used to load X64 dxe core. \r
+ // Pre-allocate a 32 bytes which confroms to x64 calling convention.\r
//\r
// The first four parameters to a function are passed in rcx, rdx, r8 and r9. \r
// Any further parameters are pushed on the stack. Furthermore, space (4 * 8bytes) for the \r
//\r
TopOfStack = BaseOfStack + EFI_SIZE_TO_PAGES (STACK_SIZE) * EFI_PAGE_SIZE - 32;\r
\r
+ //\r
+ // X64 Calling Conventions requires that the stack must be aligned to 16 bytes\r
+ //\r
+ TopOfStack = ALIGN_POINTER (TopOfStack, 16);\r
+\r
//\r
// Add architecture-specifc HOBs (including the BspStore HOB)\r
//\r