You've already forked slimbootloader
mirror of
https://github.com/Dasharo/slimbootloader.git
synced 2026-03-06 15:26:20 -08:00
Convert the line endings stored for all text files in the repository to LF. The majority previously used DOS-style CRLF line endings. Add a .gitattributes file to enforce this and treat certain extensions as never being text files. Update PatchCheck.py to insist on LF line endings rather than CRLF. However, its other checks fail on this commit due to lots of pre-existing complaints that it only notices because the line endings have changed. Silicon/QemuSocPkg/FspBin/Patches/0001-Build-QEMU-FSP-2.0-binaries.patch needs to be treated as binary since it contains a mixture of line endings. This change has implications depending on the client platform you are using the repository from: * Windows The usual configuration for Git on Windows means that text files will be checked out to the work tree with DOS-style CRLF line endings. If that's not the case then you can configure Git to do so for the entire machine with: git config --global core.autocrlf true or for just the repository with: git config core.autocrlf true Line endings will be normalised to LF when they are committed to the repository. If you commit a text file with only LF line endings then it will be converted to CRLF line endings in your work tree. * Linux, MacOS and other Unices The usual configuration for Git on such platforms is to check files out of the repository with LF line endings. This is probably the right thing for you. In the unlikely even that you are using Git on Unix but editing or compiling on Windows for some reason then you may need to tweak your configuration to force the use of CRLF line endings as described above. * General For more information see https://docs.github.com/en/get-started/getting-started-with-git/configuring-git-to-handle-line-endings . Fixes: https://github.com/slimbootloader/slimbootloader/issues/1400 Signed-off-by: Mike Crowe <mac@mcrowe.com>
233 lines
5.7 KiB
C
233 lines
5.7 KiB
C
/** @file
|
|
|
|
Copyright (c) 2017 - 2021, Intel Corporation. All rights reserved.<BR>
|
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
|
|
**/
|
|
|
|
#ifndef _PAGING_LIB_H_
|
|
#define _PAGING_LIB_H_
|
|
|
|
#define IA32_PG_P BIT0
|
|
#define IA32_PG_RW BIT1
|
|
#define IA32_PG_AC BIT5
|
|
#define IA32_PG_D BIT6
|
|
#define IA32_PG_PD BIT7
|
|
|
|
typedef struct {
|
|
UINTN Start;
|
|
UINTN Limit;
|
|
UINTN Mapping;
|
|
UINT32 PageSize;
|
|
} MAP_RANGE;
|
|
|
|
/**
|
|
This function returns page tables memory size.
|
|
|
|
@param[in] IsX64Mode Determine to build page table for x64 mode or not.
|
|
|
|
@retval Page table memory size required.
|
|
|
|
**/
|
|
UINT32
|
|
EFIAPI
|
|
GetPageTablesMemorySize (
|
|
IN BOOLEAN IsX64Mode
|
|
);
|
|
|
|
/**
|
|
This function dumps the current PageTables
|
|
|
|
@param None
|
|
|
|
@retval None
|
|
**/
|
|
|
|
VOID
|
|
EFIAPI
|
|
DumpPageTables (
|
|
VOID
|
|
);
|
|
|
|
/**
|
|
Allocates and fills in the Page Directory and Page Table Entries to
|
|
establish a 1:1 Virtual to Physical mapping.
|
|
|
|
@param[in] PageBuffer Page table root pointer. The buffer size needs
|
|
to be at least GetPageTablesMemorySize().
|
|
@param[in] IsX64Mode Determine to build page table for x64 mode or not.
|
|
|
|
@retval EFI_SUCCESS Page table was created successfully.
|
|
@retval EFI_INVALID_PARAMETER Invalid PageBuffer.
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
EFIAPI
|
|
Create4GbPageTables (
|
|
IN VOID *PageBuffer,
|
|
IN BOOLEAN IsX64Mode
|
|
);
|
|
|
|
/**
|
|
Map a memory range from the current paging table.
|
|
|
|
@param[in] Ranges Memory range info to map.
|
|
@param[in] PageBuffer Page table root pointer.
|
|
|
|
@retval EFI_SUCCESS Map completed successfully.
|
|
@retval EFI_INVALID_PARAMETER Invalid PageBuffer or Ranges.
|
|
|
|
**/
|
|
EFI_STATUS
|
|
EFIAPI
|
|
MapMemoryRange (
|
|
IN MAP_RANGE Ranges[1],
|
|
IN VOID *PageBuffer
|
|
);
|
|
|
|
/**
|
|
Unmap a memory range from the current paging table.
|
|
|
|
@param[in] Ranges Memory range info to un map.
|
|
@param[in] PageBuffer Page table root pointer.
|
|
|
|
@retval EFI_SUCCESS Unmap completed successfully.
|
|
@retval EFI_INVALID_PARAMETER Invalid PageBuffer or Ranges.
|
|
|
|
**/
|
|
EFI_STATUS
|
|
EFIAPI
|
|
UnmapMemoryRange (
|
|
IN MAP_RANGE Ranges[1],
|
|
IN VOID *PageBuffer
|
|
);
|
|
|
|
/**
|
|
Allocates and fills in the Page Directory and Page Table Entries to
|
|
establish a 1:1 Virtual to Physical mapping.
|
|
|
|
@param[in] RequestedAddressBits If RequestedAddressBits is in valid range
|
|
(MIN_ADDR_BITS < RequestedAddressBits < PhysicalAddressBits),
|
|
paging table will cover the requested physical address range only.
|
|
When RequestedAddressBits is 0, it will build the address range
|
|
that the CPU can support.
|
|
|
|
@retval EFI_SUCCESS Page table was created successfully.
|
|
@retval EFI_OUT_OF_RESOURCES Failed to allocate page buffer
|
|
|
|
**/
|
|
EFI_STATUS
|
|
EFIAPI
|
|
CreateIdentityMappingPageTables (
|
|
IN UINT8 RequestedAddressBits
|
|
);
|
|
|
|
/**
|
|
ASM inline function Paging32.nasm - Enable Paging
|
|
Set Page Global Enable (Set PGE in CR4)
|
|
loads Pdpe to CR3 and Set PG bit in CR0.
|
|
|
|
@param [in] Pdpe pointer to Page Directory and Page Table Entries
|
|
**/
|
|
VOID
|
|
EFIAPI
|
|
EnablePaging32 (
|
|
IN UINT32 *Pdpe
|
|
);
|
|
|
|
/**
|
|
ASM inline function Paging32.nasm - Disable Paging (Clear PG bit in CR0).
|
|
**/
|
|
VOID
|
|
EFIAPI
|
|
DisablePaging32 (
|
|
VOID
|
|
);
|
|
|
|
/**
|
|
Create 64-bit pagetables, enable long mode and jump to 64-bit entrypoint.
|
|
|
|
Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
|
|
must be properly initialized prior to calling this service. This function
|
|
assumes the current execution mode is 32-bit protected mode with flat
|
|
descriptors. This function is only available on IA-32. After the 64-bit
|
|
paging mode is enabled, control is transferred to the function specified by
|
|
EntryPoint using the new stack specified by NewStack and passing in the
|
|
parameters specified by Context1 and Context2. Context1 and Context2 are
|
|
optional and may be 0. The function EntryPoint must never return.
|
|
|
|
If the current execution mode is not 32-bit protected mode with flat
|
|
descriptors, then ASSERT().
|
|
If EntryPoint is 0, then ASSERT().
|
|
If NewStack is 0, then ASSERT().
|
|
|
|
@param[in] EntryPoint The 64-bit virtual address of the function to call
|
|
with the new stack after paging is enabled.
|
|
@param[in] Context1 The 64-bit virtual address of the context to pass into
|
|
the EntryPoint function as the first parameter after
|
|
paging is enabled.
|
|
@param[in] Context2 The 64-bit virtual address of the context to pass into
|
|
the EntryPoint function as the second parameter after
|
|
paging is enabled.
|
|
@param[in] NewStack The 64-bit virtual address of the new stack to use for
|
|
the EntryPoint function after paging is enabled.
|
|
|
|
**/
|
|
VOID
|
|
EFIAPI
|
|
JumpToLongMode (
|
|
IN UINT64 EntryPoint,
|
|
IN UINT64 Context1, OPTIONAL
|
|
IN UINT64 Context2, OPTIONAL
|
|
IN UINT64 NewStack
|
|
);
|
|
|
|
/**
|
|
Load page table for long mode.
|
|
|
|
**/
|
|
VOID
|
|
EFIAPI
|
|
LoadPageTableForLongMode (
|
|
VOID
|
|
);
|
|
|
|
/**
|
|
Whether 64-bit long mode is enabled or not.
|
|
|
|
@return TRUE if long mode has already been enabled, otherwise FALSE
|
|
|
|
**/
|
|
BOOLEAN
|
|
EFIAPI
|
|
IsLongModeEnabled (
|
|
VOID
|
|
);
|
|
|
|
/**
|
|
Whether processor supports 64-bit long mode or not.
|
|
|
|
@return TRUE if processor supports 64-bit long mode, otherwise FALSE
|
|
|
|
**/
|
|
BOOLEAN
|
|
EFIAPI
|
|
IsLongModeSupported (
|
|
VOID
|
|
);
|
|
|
|
/**
|
|
Get physical address bits.
|
|
|
|
@return Physical address bits.
|
|
|
|
**/
|
|
UINT8
|
|
EFIAPI
|
|
GetPhysicalAddressBits (
|
|
VOID
|
|
);
|
|
|
|
#endif
|