forked from xt-sys/exectos
		
	KERNEL_STACK_SIZE should be expressed in bytes as the name suggests, calculate number of pages where needed
This commit is contained in:
		@@ -17,6 +17,6 @@
 | 
				
			|||||||
#define KSEG0_KERNEL_BASE                 0x0000000800000000
 | 
					#define KSEG0_KERNEL_BASE                 0x0000000800000000
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* XTOS Kernel stack size */
 | 
					/* XTOS Kernel stack size */
 | 
				
			||||||
#define KERNEL_STACK_SIZE                 8
 | 
					#define KERNEL_STACK_SIZE                 0x8000
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif /* __XTDK_AMD64_KETYPES_H */
 | 
					#endif /* __XTDK_AMD64_KETYPES_H */
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -17,6 +17,6 @@
 | 
				
			|||||||
#define KSEG0_KERNEL_BASE                 0x01800000
 | 
					#define KSEG0_KERNEL_BASE                 0x01800000
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* XTOS Kernel stack size */
 | 
					/* XTOS Kernel stack size */
 | 
				
			||||||
#define KERNEL_STACK_SIZE                 8
 | 
					#define KERNEL_STACK_SIZE                 0x4000
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif /* __XTDK_I686_KETYPES_H */
 | 
					#endif /* __XTDK_I686_KETYPES_H */
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -18,9 +18,9 @@ BlCreateStack(IN PVOID *StackPtr,
 | 
				
			|||||||
    PVOID StackEnd;
 | 
					    PVOID StackEnd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* Allocate pages for new stack and calculate its end */
 | 
					    /* Allocate pages for new stack and calculate its end */
 | 
				
			||||||
    BlEfiMemoryAllocatePages(StackSize, &Address);
 | 
					    BlEfiMemoryAllocatePages(EFI_SIZE_TO_PAGES(StackSize), &Address);
 | 
				
			||||||
    *StackPtr = (PVOID)(UINT_PTR)Address;
 | 
					    *StackPtr = (PVOID)(UINT_PTR)Address;
 | 
				
			||||||
    StackEnd = (PUINT8)*StackPtr + (StackSize * EFI_PAGE_SIZE) - EFI_PAGE_SIZE;
 | 
					    StackEnd = (PUINT8)*StackPtr + (StackSize - EFI_PAGE_SIZE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* Create new stack and switch to it immediatelly by calling callback function */
 | 
					    /* Create new stack and switch to it immediatelly by calling callback function */
 | 
				
			||||||
    asm volatile("mov %1, %%rax\n"
 | 
					    asm volatile("mov %1, %%rax\n"
 | 
				
			||||||
@@ -94,7 +94,7 @@ BlEnablePaging(IN PLIST_ENTRY MemoryMappings,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    /* Map the stack */
 | 
					    /* Map the stack */
 | 
				
			||||||
    BlGetStackPointer(&Stack);
 | 
					    BlGetStackPointer(&Stack);
 | 
				
			||||||
    Status = BlAddVirtualMemoryMapping(MemoryMappings, Stack, Stack, KERNEL_STACK_SIZE,
 | 
					    Status = BlAddVirtualMemoryMapping(MemoryMappings, Stack, Stack, EFI_SIZE_TO_PAGES(KERNEL_STACK_SIZE),
 | 
				
			||||||
                                       LoaderOsloaderStack);
 | 
					                                       LoaderOsloaderStack);
 | 
				
			||||||
    if(Status != STATUS_EFI_SUCCESS)
 | 
					    if(Status != STATUS_EFI_SUCCESS)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
@@ -104,8 +104,7 @@ BlEnablePaging(IN PLIST_ENTRY MemoryMappings,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    /* Map XTLDR code */
 | 
					    /* Map XTLDR code */
 | 
				
			||||||
    Status = BlAddVirtualMemoryMapping(MemoryMappings, ImageProtocol->ImageBase, ImageProtocol->ImageBase,
 | 
					    Status = BlAddVirtualMemoryMapping(MemoryMappings, ImageProtocol->ImageBase, ImageProtocol->ImageBase,
 | 
				
			||||||
                                                    EFI_SIZE_TO_PAGES(ImageProtocol->ImageSize),
 | 
					                                       EFI_SIZE_TO_PAGES(ImageProtocol->ImageSize), LoaderFirmwareTemporary);
 | 
				
			||||||
                                                    LoaderFirmwareTemporary);
 | 
					 | 
				
			||||||
    if(Status != STATUS_EFI_SUCCESS)
 | 
					    if(Status != STATUS_EFI_SUCCESS)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        /* Mapping the boot loader code failed */
 | 
					        /* Mapping the boot loader code failed */
 | 
				
			||||||
@@ -132,8 +131,7 @@ BlEnablePaging(IN PLIST_ENTRY MemoryMappings,
 | 
				
			|||||||
        {
 | 
					        {
 | 
				
			||||||
            /* Map memory */
 | 
					            /* Map memory */
 | 
				
			||||||
            Status = BlMapVirtualMemory(MemoryMappings, (UINT_PTR)Mapping->VirtualAddress,
 | 
					            Status = BlMapVirtualMemory(MemoryMappings, (UINT_PTR)Mapping->VirtualAddress,
 | 
				
			||||||
                                                     (UINT_PTR)Mapping->PhysicalAddress, Mapping->NumberOfPages,
 | 
					                                        (UINT_PTR)Mapping->PhysicalAddress, Mapping->NumberOfPages, FALSE, PtePointer);
 | 
				
			||||||
                                                     FALSE, PtePointer);
 | 
					 | 
				
			||||||
            if(Status != STATUS_EFI_SUCCESS)
 | 
					            if(Status != STATUS_EFI_SUCCESS)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                /* Memory mapping failed */
 | 
					                /* Memory mapping failed */
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -18,9 +18,9 @@ BlCreateStack(IN PVOID *StackPtr,
 | 
				
			|||||||
    PVOID StackEnd;
 | 
					    PVOID StackEnd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* Allocate pages for new stack and calculate its end */
 | 
					    /* Allocate pages for new stack and calculate its end */
 | 
				
			||||||
    BlEfiMemoryAllocatePages(StackSize, &Address);
 | 
					    BlEfiMemoryAllocatePages(EFI_SIZE_TO_PAGES(StackSize), &Address);
 | 
				
			||||||
    *StackPtr = (PVOID)(UINT_PTR)Address;
 | 
					    *StackPtr = (PVOID)(UINT_PTR)Address;
 | 
				
			||||||
    StackEnd = (PUINT8)*StackPtr + (StackSize * EFI_PAGE_SIZE) - EFI_PAGE_SIZE;
 | 
					    StackEnd = (PUINT8)*StackPtr + (StackSize - EFI_PAGE_SIZE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* Create new stack and switch to it immediatelly by calling callback function */
 | 
					    /* Create new stack and switch to it immediatelly by calling callback function */
 | 
				
			||||||
    asm volatile("mov %1, %%eax\n"
 | 
					    asm volatile("mov %1, %%eax\n"
 | 
				
			||||||
@@ -200,7 +200,7 @@ BlEnablePaging(IN PLIST_ENTRY MemoryMappings,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    /* Map the stack */
 | 
					    /* Map the stack */
 | 
				
			||||||
    BlGetStackPointer(&Stack);
 | 
					    BlGetStackPointer(&Stack);
 | 
				
			||||||
    Status = BlAddVirtualMemoryMapping(MemoryMappings, Stack, Stack, KERNEL_STACK_SIZE,
 | 
					    Status = BlAddVirtualMemoryMapping(MemoryMappings, Stack, Stack, EFI_SIZE_TO_PAGES(KERNEL_STACK_SIZE),
 | 
				
			||||||
                                       LoaderOsloaderStack);
 | 
					                                       LoaderOsloaderStack);
 | 
				
			||||||
    if(Status != STATUS_EFI_SUCCESS)
 | 
					    if(Status != STATUS_EFI_SUCCESS)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
@@ -210,8 +210,7 @@ BlEnablePaging(IN PLIST_ENTRY MemoryMappings,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    /* Map XTLDR code */
 | 
					    /* Map XTLDR code */
 | 
				
			||||||
    Status = BlAddVirtualMemoryMapping(MemoryMappings, ImageProtocol->ImageBase, ImageProtocol->ImageBase,
 | 
					    Status = BlAddVirtualMemoryMapping(MemoryMappings, ImageProtocol->ImageBase, ImageProtocol->ImageBase,
 | 
				
			||||||
                                                    EFI_SIZE_TO_PAGES(ImageProtocol->ImageSize),
 | 
					                                       EFI_SIZE_TO_PAGES(ImageProtocol->ImageSize), LoaderFirmwareTemporary);
 | 
				
			||||||
                                                    LoaderFirmwareTemporary);
 | 
					 | 
				
			||||||
    if(Status != STATUS_EFI_SUCCESS)
 | 
					    if(Status != STATUS_EFI_SUCCESS)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        /* Mapping the boot loader code failed */
 | 
					        /* Mapping the boot loader code failed */
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user