ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
September 2015
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
17 participants
535 discussions
Start a n
N
ew thread
[tfaber] 69050: [PCI] - Better stub IRP_MJ_POWER handlers. Failing IRP_MN_SET_POWER is illegal! CORE-10117
by tfaber@svn.reactos.org
Author: tfaber Date: Sun Sep 6 08:54:20 2015 New Revision: 69050 URL:
http://svn.reactos.org/svn/reactos?rev=69050&view=rev
Log: [PCI] - Better stub IRP_MJ_POWER handlers. Failing IRP_MN_SET_POWER is illegal! CORE-10117 Modified: trunk/reactos/drivers/bus/pci/fdo.c trunk/reactos/drivers/bus/pci/pdo.c Modified: trunk/reactos/drivers/bus/pci/fdo.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/pci/fdo.c?rev=…
============================================================================== --- trunk/reactos/drivers/bus/pci/fdo.c [iso-8859-1] (original) +++ trunk/reactos/drivers/bus/pci/fdo.c [iso-8859-1] Sun Sep 6 08:54:20 2015 @@ -453,33 +453,6 @@ Irp->IoStatus.Information = 0; return STATUS_SUCCESS; -} - - -static NTSTATUS -FdoSetPower( - IN PDEVICE_OBJECT DeviceObject, - IN PIRP Irp, - PIO_STACK_LOCATION IrpSp) -{ - NTSTATUS Status; - - UNREFERENCED_PARAMETER(DeviceObject); - UNREFERENCED_PARAMETER(Irp); - - DPRINT("Called\n"); - - if (IrpSp->Parameters.Power.Type == DevicePowerState) - { - /* FIXME: Set device power state for the device */ - Status = STATUS_UNSUCCESSFUL; - } - else - { - Status = STATUS_UNSUCCESSFUL; - } - - return Status; } @@ -616,30 +589,16 @@ * Status */ { - PIO_STACK_LOCATION IrpSp; + PFDO_DEVICE_EXTENSION DeviceExtension; NTSTATUS Status; DPRINT("Called\n"); - IrpSp = IoGetCurrentIrpStackLocation(Irp); - - switch (IrpSp->MinorFunction) - { - case IRP_MN_SET_POWER: - Status = FdoSetPower(DeviceObject, Irp, IrpSp); - break; - - default: - DPRINT("Unknown IOCTL 0x%X\n", IrpSp->MinorFunction); - Status = STATUS_NOT_IMPLEMENTED; - break; - } - - if (Status != STATUS_PENDING) - { - Irp->IoStatus.Status = Status; - IoCompleteRequest(Irp, IO_NO_INCREMENT); - } + DeviceExtension = DeviceObject->DeviceExtension; + + PoStartNextPowerIrp(Irp); + IoSkipCurrentIrpStackLocation(Irp); + Status = PoCallDriver(DeviceExtension->Ldo, Irp); DPRINT("Leaving. Status 0x%X\n", Status); Modified: trunk/reactos/drivers/bus/pci/pdo.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/pci/pdo.c?rev=…
============================================================================== --- trunk/reactos/drivers/bus/pci/pdo.c [iso-8859-1] (original) +++ trunk/reactos/drivers/bus/pci/pdo.c [iso-8859-1] Sun Sep 6 08:54:20 2015 @@ -202,7 +202,7 @@ { ULONG Size; ULONG AllOnes; - + /* Read the original value */ Size = HalGetBusDataByOffset(PCIConfiguration, DeviceExtension->PciDevice->BusNumber, @@ -215,7 +215,7 @@ DPRINT1("Wrong size %lu\n", Size); return FALSE; } - + /* Write all ones to determine which bits are held to zero */ AllOnes = MAXULONG; Size = HalSetBusDataByOffset(PCIConfiguration, @@ -229,7 +229,7 @@ DPRINT1("Wrong size %lu\n", Size); return FALSE; } - + /* Get the range length */ Size = HalGetBusDataByOffset(PCIConfiguration, DeviceExtension->PciDevice->BusNumber, @@ -255,7 +255,7 @@ DPRINT1("Wrong size %lu\n", Size); return FALSE; } - + return TRUE; } @@ -283,13 +283,13 @@ ULONGLONG Bar; } NewValue; ULONG Offset; - + /* Compute the offset of this BAR in PCI config space */ Offset = 0x10 + Bar * 4; - + /* Assume this is a 32-bit BAR until we find wrong */ *NextBar = Bar + 1; - + /* Initialize BAR values to zero */ OriginalValue.Bar = 0ULL; NewValue.Bar = 0ULL; @@ -301,7 +301,7 @@ { return FALSE; } - + /* Check if this is a memory BAR */ if (!(OriginalValue.Bars.Bar0 & PCI_ADDRESS_IO_SPACE)) { @@ -321,13 +321,13 @@ *MaximumAddress = 0xFFFFFFFFFFFFFFFFULL; } } - + /* Check if this is a 64-bit BAR */ if ((OriginalValue.Bars.Bar0 & PCI_ADDRESS_MEMORY_TYPE_MASK) == PCI_TYPE_64BIT) { /* We've now consumed the next BAR too */ *NextBar = Bar + 2; - + /* Read the next BAR */ if (!PdoReadPciBar(DeviceExtension, Offset + 4, &OriginalValue.Bars.Bar1, @@ -354,7 +354,7 @@ *Flags = 0; return TRUE; } - + *Base = OriginalValue.Bar & PCI_ADDRESS_MEMORY_ADDRESS_MASK_64; *Length = ~((NewValue.Bar & PCI_ADDRESS_IO_SPACE) @@ -1490,36 +1490,6 @@ return STATUS_SUCCESS; } -static NTSTATUS -PdoSetPower( - IN PDEVICE_OBJECT DeviceObject, - IN PIRP Irp, - PIO_STACK_LOCATION IrpSp) -{ - NTSTATUS Status; - - UNREFERENCED_PARAMETER(DeviceObject); - UNREFERENCED_PARAMETER(Irp); - DPRINT("Called\n"); - - if (IrpSp->Parameters.Power.Type == DevicePowerState) - { - Status = STATUS_SUCCESS; - - switch (IrpSp->Parameters.Power.State.SystemState) - { - default: - Status = STATUS_UNSUCCESSFUL; - } - } - else - { - Status = STATUS_UNSUCCESSFUL; - } - - return Status; -} - /*** PUBLIC ******************************************************************/ @@ -1683,7 +1653,7 @@ */ { PIO_STACK_LOCATION IrpSp; - NTSTATUS Status; + NTSTATUS Status = Irp->IoStatus.Status; DPRINT("Called\n"); @@ -1691,21 +1661,15 @@ switch (IrpSp->MinorFunction) { + case IRP_MN_QUERY_POWER: case IRP_MN_SET_POWER: - Status = PdoSetPower(DeviceObject, Irp, IrpSp); - break; - - default: - DPRINT("Unknown IOCTL 0x%X\n", IrpSp->MinorFunction); - Status = STATUS_NOT_IMPLEMENTED; - break; - } - - if (Status != STATUS_PENDING) - { - Irp->IoStatus.Status = Status; - IoCompleteRequest(Irp, IO_NO_INCREMENT); - } + Status = STATUS_SUCCESS; + break; + } + + PoStartNextPowerIrp(Irp); + Irp->IoStatus.Status = Status; + IoCompleteRequest(Irp, IO_NO_INCREMENT); DPRINT("Leaving. Status 0x%X\n", Status);
9 years, 3 months
1
0
0
0
[tfaber] 69049: [DISPLAYS] - DrvEnableDriver does not need to be exported. Fixes MSVC warnings (LNK4216: Exported entry point _DrvEnableDriver@12)
by tfaber@svn.reactos.org
Author: tfaber Date: Sun Sep 6 08:35:01 2015 New Revision: 69049 URL:
http://svn.reactos.org/svn/reactos?rev=69049&view=rev
Log: [DISPLAYS] - DrvEnableDriver does not need to be exported. Fixes MSVC warnings (LNK4216: Exported entry point _DrvEnableDriver@12) Removed: trunk/reactos/win32ss/drivers/displays/framebuf/framebuf.spec trunk/reactos/win32ss/drivers/displays/framebuf_new/framebuf_new.spec trunk/reactos/win32ss/drivers/displays/framebufacc/framebufacc.spec trunk/reactos/win32ss/drivers/displays/vga/vgaddi.spec trunk/reactos/win32ss/drivers/displays/vga_new/vga_new.spec Modified: trunk/reactos/win32ss/drivers/displays/framebuf/CMakeLists.txt trunk/reactos/win32ss/drivers/displays/framebuf_new/CMakeLists.txt trunk/reactos/win32ss/drivers/displays/vga/CMakeLists.txt Modified: trunk/reactos/win32ss/drivers/displays/framebuf/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/drivers/displays/f…
============================================================================== --- trunk/reactos/win32ss/drivers/displays/framebuf/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/win32ss/drivers/displays/framebuf/CMakeLists.txt [iso-8859-1] Sun Sep 6 08:35:01 2015 @@ -1,5 +1,3 @@ - -spec2def(framebuf.dll framebuf.spec) list(APPEND SOURCE enable.c @@ -11,8 +9,7 @@ add_library(framebuf SHARED ${SOURCE} - framebuf.rc - ${CMAKE_CURRENT_BINARY_DIR}/framebuf.def) + framebuf.rc) set_module_type(framebuf kerneldll ENTRYPOINT DrvEnableDriver 12) add_pch(framebuf framebuf.h SOURCE) Removed: trunk/reactos/win32ss/drivers/displays/framebuf/framebuf.spec URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/drivers/displays/f…
============================================================================== --- trunk/reactos/win32ss/drivers/displays/framebuf/framebuf.spec [iso-8859-1] (original) +++ trunk/reactos/win32ss/drivers/displays/framebuf/framebuf.spec (removed) @@ -1 +0,0 @@ -@ stdcall DrvEnableDriver(long long ptr) Modified: trunk/reactos/win32ss/drivers/displays/framebuf_new/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/drivers/displays/f…
============================================================================== --- trunk/reactos/win32ss/drivers/displays/framebuf_new/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/win32ss/drivers/displays/framebuf_new/CMakeLists.txt [iso-8859-1] Sun Sep 6 08:35:01 2015 @@ -1,5 +1,3 @@ - -spec2def(framebuf_new.dll framebuf_new.spec) list(APPEND SOURCE debug.c @@ -11,8 +9,7 @@ add_library(framebuf_new SHARED ${SOURCE} - framebuf_new.rc - ${CMAKE_CURRENT_BINARY_DIR}/framebuf_new.def) + framebuf_new.rc) set_module_type(framebuf_new kerneldll ENTRYPOINT DrvEnableDriver 12) target_link_libraries(framebuf_new libcntpr) Removed: trunk/reactos/win32ss/drivers/displays/framebuf_new/framebuf_new.spec URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/drivers/displays/f…
============================================================================== --- trunk/reactos/win32ss/drivers/displays/framebuf_new/framebuf_new.spec [iso-8859-1] (original) +++ trunk/reactos/win32ss/drivers/displays/framebuf_new/framebuf_new.spec (removed) @@ -1 +0,0 @@ -@ stdcall DrvEnableDriver(long long ptr) Removed: trunk/reactos/win32ss/drivers/displays/framebufacc/framebufacc.spec URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/drivers/displays/f…
============================================================================== --- trunk/reactos/win32ss/drivers/displays/framebufacc/framebufacc.spec [iso-8859-1] (original) +++ trunk/reactos/win32ss/drivers/displays/framebufacc/framebufacc.spec (removed) @@ -1 +0,0 @@ -@ stdcall DrvEnableDriver(long long ptr) Modified: trunk/reactos/win32ss/drivers/displays/vga/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/drivers/displays/v…
============================================================================== --- trunk/reactos/win32ss/drivers/displays/vga/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/win32ss/drivers/displays/vga/CMakeLists.txt [iso-8859-1] Sun Sep 6 08:35:01 2015 @@ -1,5 +1,3 @@ - -spec2def(vgaddi.dll vgaddi.spec) list(APPEND SOURCE main/enable.c @@ -16,8 +14,7 @@ add_library(vgaddi SHARED ${SOURCE} - vgaddi.rc - ${CMAKE_CURRENT_BINARY_DIR}/vgaddi.def) + vgaddi.rc) set_module_type(vgaddi kerneldll ENTRYPOINT DrvEnableDriver 12) add_pch(vgaddi vgaddi.h SOURCE) Removed: trunk/reactos/win32ss/drivers/displays/vga/vgaddi.spec URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/drivers/displays/v…
============================================================================== --- trunk/reactos/win32ss/drivers/displays/vga/vgaddi.spec [iso-8859-1] (original) +++ trunk/reactos/win32ss/drivers/displays/vga/vgaddi.spec (removed) @@ -1 +0,0 @@ -@ stdcall DrvEnableDriver(long long ptr) Removed: trunk/reactos/win32ss/drivers/displays/vga_new/vga_new.spec URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/drivers/displays/v…
============================================================================== --- trunk/reactos/win32ss/drivers/displays/vga_new/vga_new.spec [iso-8859-1] (original) +++ trunk/reactos/win32ss/drivers/displays/vga_new/vga_new.spec (removed) @@ -1 +0,0 @@ -@ stdcall DrvEnableDriver(long long ptr)
9 years, 3 months
1
0
0
0
[tfaber] 69048: [SHELL32] - Initialize CNewMenu::m_pidlFolder. Fixes crash in com_apitest:shell32 CORE-10115 #resolve
by tfaber@svn.reactos.org
Author: tfaber Date: Sun Sep 6 08:16:57 2015 New Revision: 69048 URL:
http://svn.reactos.org/svn/reactos?rev=69048&view=rev
Log: [SHELL32] - Initialize CNewMenu::m_pidlFolder. Fixes crash in com_apitest:shell32 CORE-10115 #resolve Modified: trunk/reactos/dll/win32/shell32/CNewMenu.cpp Modified: trunk/reactos/dll/win32/shell32/CNewMenu.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/CNewMenu…
============================================================================== --- trunk/reactos/dll/win32/shell32/CNewMenu.cpp [iso-8859-1] (original) +++ trunk/reactos/dll/win32/shell32/CNewMenu.cpp [iso-8859-1] Sun Sep 6 08:16:57 2015 @@ -24,15 +24,16 @@ WINE_DEFAULT_DEBUG_CHANNEL(shell); -CNewMenu::CNewMenu() -{ - m_wszPath = NULL; - m_pItems = NULL; - m_pLinkItem = NULL; - m_pSite = NULL; - m_hiconFolder = NULL; - m_hiconLink = NULL; - m_idCmdFirst = 0; +CNewMenu::CNewMenu() : + m_pidlFolder(NULL), + m_wszPath(NULL), + m_pItems(NULL), + m_pLinkItem(NULL), + m_pSite(NULL), + m_hiconFolder(NULL), + m_hiconLink(NULL), + m_idCmdFirst(0) +{ } CNewMenu::~CNewMenu()
9 years, 3 months
1
0
0
0
[ion] 69047: [BOOTMGFW]: - Cleanup some bugs/issues in the memory map parsing code. - Implement creation of BL/NT-compatible memory descriptors based on UEFI descriptors. - Implement other remainin...
by ion@svn.reactos.org
Author: ion Date: Sun Sep 6 06:15:08 2015 New Revision: 69047 URL:
http://svn.reactos.org/svn/reactos?rev=69047&view=rev
Log: [BOOTMGFW]: - Cleanup some bugs/issues in the memory map parsing code. - Implement creation of BL/NT-compatible memory descriptors based on UEFI descriptors. - Implement other remaining parts of the page allocator initialization routine. - Last part missing is to implement routines for removing from a memory list, and for handling the boot manager's own descriptor. Modified: trunk/reactos/boot/environ/app/bootmgr/efiemu.c trunk/reactos/boot/environ/include/bl.h trunk/reactos/boot/environ/lib/firmware/efi/firmware.c trunk/reactos/boot/environ/lib/mm/descriptor.c trunk/reactos/boot/environ/lib/mm/mm.c trunk/reactos/boot/environ/lib/mm/pagealloc.c Modified: trunk/reactos/boot/environ/app/bootmgr/efiemu.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/app/bootmgr/e…
============================================================================== --- trunk/reactos/boot/environ/app/bootmgr/efiemu.c [iso-8859-1] (original) +++ trunk/reactos/boot/environ/app/bootmgr/efiemu.c [iso-8859-1] Sun Sep 6 06:15:08 2015 @@ -930,10 +930,10 @@ EfiInitScratch.MemoryDataOffset; EfiInitScratch.BootMemoryData.DescriptorSize = sizeof(BL_MEMORY_DESCRIPTOR); EfiInitScratch.BootMemoryData.DescriptorCount = 1; - EfiInitScratch.BootMemoryData.Unknown = 8; + EfiInitScratch.BootMemoryData.DescriptorOffset = FIELD_OFFSET(BL_MEMORY_DESCRIPTOR, BasePage); /* Build the memory entry descriptor for this image itself */ - EfiInitScratch.MemEntry.Flags = 8; + EfiInitScratch.MemEntry.Flags = BlMemoryWriteBack; EfiInitScratch.MemEntry.Type = BlLoaderMemory; EfiInitScratch.MemEntry.BasePage = EfiInitScratch.ImageBase >> PAGE_SHIFT; EfiInitScratch.MemEntry.PageCount = ALIGN_UP_BY(EfiInitScratch.ImageSize, PAGE_SIZE) >> PAGE_SHIFT; Modified: trunk/reactos/boot/environ/include/bl.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/include/bl.h?…
============================================================================== --- trunk/reactos/boot/environ/include/bl.h [iso-8859-1] (original) +++ trunk/reactos/boot/environ/include/bl.h [iso-8859-1] Sun Sep 6 06:15:08 2015 @@ -53,11 +53,22 @@ #define BL_CONTEXT_INTERRUPTS_ON 2 #define BL_MM_FLAG_USE_FIRMWARE_FOR_MEMORY_MAP_BUFFERS 0x01 -#define BL_MM_FLAG_UNKNOWN 0x02 +#define BL_MM_FLAG_REQUEST_COALESCING 0x02 + +#define BL_MM_ADD_DESCRIPTOR_COALESCE_FLAG 0x01 +#define BL_MM_ADD_DESCRIPTOR_TRUNCATE_FLAG 0x02 +#define BL_MM_ADD_DESCRIPTOR_NEVER_COALESCE_FLAG 0x10 +#define BL_MM_ADD_DESCRIPTOR_NEVER_TRUNCATE_FLAG 0x20 +#define BL_MM_ADD_DESCRIPTOR_UPDATE_LIST_POINTER_FLAG 0x2000 + +#define BL_MM_DESCRIPTOR_REQUIRES_COALESCING_FLAG 0x2000000 +#define BL_MM_DESCRIPTOR_REQUIRES_UPDATING_FLAG 0x4000000 #define BL_LIBRARY_FLAG_REINITIALIZE 0x02 #define BL_LIBRARY_FLAG_REINITIALIZE_ALL 0x04 #define BL_LIBRARY_FLAG_INITIALIZATION_COMPLETED 0x20 + +#define BL_MEMORY_CLASS_SHIFT 28 /* ENUMERATIONS **************************************************************/ @@ -222,7 +233,7 @@ ULONG MdListOffset; ULONG DescriptorCount; ULONG DescriptorSize; - ULONG Unknown; + ULONG DescriptorOffset; } BL_MEMORY_DATA, *PBL_MEMORY_DATA; typedef struct _BL_FIRMWARE_DESCRIPTOR @@ -518,10 +529,27 @@ _In_ PBL_MEMORY_DESCRIPTOR_LIST MdList ); +PBL_MEMORY_DESCRIPTOR +MmMdInitByteGranularDescriptor ( + _In_ ULONG Flags, + _In_ BL_MEMORY_TYPE Type, + _In_ ULONGLONG BasePage, + _In_ ULONGLONG VirtualPage, + _In_ ULONGLONG PageCount + ); + +NTSTATUS +MmMdAddDescriptorToList ( + _In_ PBL_MEMORY_DESCRIPTOR_LIST MdList, + _In_ PBL_MEMORY_DESCRIPTOR MemoryDescriptor, + _In_ ULONG Flags + ); + extern ULONG MmDescriptorCallTreeCount; extern ULONG BlpApplicationFlags; extern BL_LIBRARY_PARAMETERS BlpLibraryParameters; extern BL_TRANSLATION_TYPE MmTranslationType; extern PBL_ARCH_CONTEXT CurrentExecutionContext; +extern PBL_DEVICE_DESCRIPTOR BlpBootDevice; #endif Modified: trunk/reactos/boot/environ/lib/firmware/efi/firmware.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/firmware/…
============================================================================== --- trunk/reactos/boot/environ/lib/firmware/efi/firmware.c [iso-8859-1] (original) +++ trunk/reactos/boot/environ/lib/firmware/efi/firmware.c [iso-8859-1] Sun Sep 6 06:15:08 2015 @@ -371,7 +371,7 @@ ) { BL_LIBRARY_PARAMETERS LibraryParameters = BlpLibraryParameters; - BOOLEAN UseEfiBuffer; + BOOLEAN UseEfiBuffer, HaveRamDisk; NTSTATUS Status; ULONGLONG Pages, StartPage, EndPage; UINTN EfiMemoryMapSize, MapKey, DescriptorSize, DescriptorVersion; @@ -381,6 +381,11 @@ BL_ARCH_MODE OldMode; EFI_MEMORY_DESCRIPTOR EfiDescriptor; BL_MEMORY_TYPE MemoryType; + PBL_MEMORY_DESCRIPTOR Descriptor; + BL_MEMORY_ATTR Attribute; + + /* Initialize EFI memory map attributes */ + EfiMemoryMapSize = MapKey = DescriptorSize = DescriptorVersion = 0; /* Increment the nesting depth */ MmDescriptorCallTreeCount++; @@ -509,6 +514,21 @@ goto Quickie; } + /* Did we boot from a RAM disk? */ + if ((BlpBootDevice->DeviceType == LocalDevice) && + (BlpBootDevice->Local.Type == RamDiskDevice)) + { + /* We don't handle this yet */ + EarlyPrint(L"RAM boot not supported\n"); + Status = STATUS_NOT_IMPLEMENTED; + goto Quickie; + } + else + { + /* We didn't, so there won't be any need to find the memory descriptor */ + HaveRamDisk = FALSE; + } + /* Loop the EFI memory map */ EarlyPrint(L"UEFI MEMORY MAP\n\n"); EarlyPrint(L"TYPE START END ATTRIBUTES\n"); @@ -552,17 +572,136 @@ goto LoopAgain; } - EarlyPrint(L"%08X 0x%016I64X-0x%016I64X 0x%X\n", + EarlyPrint(L"%08X 0x%016I64X-0x%016I64X 0x%I64X\n", MemoryType, StartPage << PAGE_SHIFT, EndPage << PAGE_SHIFT, EfiDescriptor.Attribute); + /* Check for any range of memory below 1MB */ + if (StartPage < 0x100) + { + /* Does this range actually contain NULL? */ + if (StartPage == 0) + { + /* Manually create a reserved descriptof for this page */ + Attribute = MmFwpGetOsAttributeType(EfiDescriptor.Attribute); + Descriptor = MmMdInitByteGranularDescriptor(Attribute, + BlReservedMemory, + 0, + 0, + 1); + if (!Descriptor) + { + Status = STATUS_INSUFFICIENT_RESOURCES; + break; + } + + /* Add this descriptor into the list */ + Status = MmMdAddDescriptorToList(MemoryMap, + Descriptor, + BL_MM_ADD_DESCRIPTOR_TRUNCATE_FLAG); + if (!NT_SUCCESS(Status)) + { + EarlyPrint(L"Failed to add zero page descriptor: %lx\n", Status); + break; + } + + /* Now handle the rest of the range, unless this was it */ + StartPage = 1; + if (EndPage == 1) + { + goto LoopAgain; + } + } + + /* Does the range go beyond 1MB? */ + if (EndPage > 0x100) + { + /* Then create the descriptor for everything up until the megabyte */ + Attribute = MmFwpGetOsAttributeType(EfiDescriptor.Attribute); + Descriptor = MmMdInitByteGranularDescriptor(Attribute, + MemoryType, + StartPage, + 0, + 0x100 - StartPage); + if (!Descriptor) + { + Status = STATUS_INSUFFICIENT_RESOURCES; + break; + } + + /* Check if this region is currently free RAM */ + if (Descriptor->Type == BlConventionalMemory) + { + /* Set an unknown flag on the descriptor */ + Descriptor->Flags |= 0x80000; + } + + /* Add this descriptor into the list */ + Status = MmMdAddDescriptorToList(MemoryMap, + Descriptor, + BL_MM_ADD_DESCRIPTOR_TRUNCATE_FLAG); + if (!NT_SUCCESS(Status)) + { + EarlyPrint(L"Failed to add 1MB descriptor: %lx\n", Status); + break; + } + + /* Now handle the rest of the range above 1MB */ + StartPage = 0x100; + } + } + + /* Check if we loaded from a RAM disk */ + if (HaveRamDisk) + { + /* We don't handle this yet */ + EarlyPrint(L"RAM boot not supported\n"); + Status = STATUS_NOT_IMPLEMENTED; + goto Quickie; + } + + /* Create a descriptor for the current range */ + Attribute = MmFwpGetOsAttributeType(EfiDescriptor.Attribute); + Descriptor = MmMdInitByteGranularDescriptor(Attribute, + MemoryType, + StartPage, + 0, + EndPage - StartPage); + if (!Descriptor) + { + Status = STATUS_INSUFFICIENT_RESOURCES; + break; + } + + /* Check if this region is currently free RAM below 1MB */ + if ((Descriptor->Type == BlConventionalMemory) && (EndPage <= 0x100)) + { + /* Set an unknown flag on the descriptor */ + Descriptor->Flags |= 0x80000; + } + + /* Add the descriptor to the list, requesting coalescing as asked */ + Status = MmMdAddDescriptorToList(MemoryMap, + Descriptor, + BL_MM_ADD_DESCRIPTOR_TRUNCATE_FLAG | + (Flags & BL_MM_FLAG_REQUEST_COALESCING) ? + BL_MM_ADD_DESCRIPTOR_COALESCE_FLAG : 0); + if (!NT_SUCCESS(Status)) + { + EarlyPrint(L"Failed to add full descriptor: %lx\n", Status); + break; + } + +LoopAgain: /* Consume this descriptor, and move to the next one */ -LoopAgain: EfiMemoryMapSize -= DescriptorSize; EfiMemoryMap = (PVOID)((ULONG_PTR)EfiMemoryMap + DescriptorSize); } + + /* FIXME: @TODO: Mark the EfiBuffer as free, since we're about to free it */ + /* For now, just "leak" the 1-2 pages... */ Quickie: /* Free the EFI buffer, if we had one */ Modified: trunk/reactos/boot/environ/lib/mm/descriptor.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/mm/descri…
============================================================================== --- trunk/reactos/boot/environ/lib/mm/descriptor.c [iso-8859-1] (original) +++ trunk/reactos/boot/environ/lib/mm/descriptor.c [iso-8859-1] Sun Sep 6 06:15:08 2015 @@ -19,7 +19,130 @@ PBL_MEMORY_DESCRIPTOR MmDynamicMemoryDescriptors; ULONG MmDynamicMemoryDescriptorCount; +BL_MEMORY_TYPE MmPlatformMemoryTypePrecedence[] = +{ + BlReservedMemory, + BlUnusableMemory, + BlDeviceIoMemory, + BlDevicePortMemory, + BlPalMemory, + BlEfiRuntimeMemory, + BlAcpiNvsMemory, + BlAcpiReclaimMemory, + BlEfiBootMemory +}; + /* FUNCTIONS *****************************************************************/ + +/* The order is Conventional > Other > System > Loader > Application */ +BOOLEAN +MmMdpHasPrecedence ( + _In_ BL_MEMORY_TYPE Type1, + _In_ BL_MEMORY_TYPE Type2 + ) +{ + BL_MEMORY_CLASS Class1, Class2; + ULONG i, j; + + /* Descriptor is free RAM -- it preceeds */ + if (Type1 == BlConventionalMemory) + { + return TRUE; + } + + /* It isn't free RAM, but the comparator is -- it suceeds it */ + if (Type2 == BlConventionalMemory) + { + return FALSE; + } + + /* Descriptor is not system, application, or loader class -- it preceeds */ + Class1 = Type1 >> BL_MEMORY_CLASS_SHIFT; + if ((Class1 != BlSystemClass) && + (Class1 != BlApplicationClass) && + (Class1 != BlLoaderClass)) + { + return TRUE; + } + + /* It isn't one of those classes, but the comparator it -- it suceeds it */ + Class2 = Type2 >> BL_MEMORY_CLASS_SHIFT; + if ((Class2 != BlSystemClass) && + (Class2 != BlApplicationClass) && + (Class2 != BlLoaderClass)) + { + return FALSE; + } + + /* Descriptor is system class */ + if (Class1 == BlSystemClass) + { + /* And so is the other guy... */ + if (Class2 == BlSystemClass) + { + i = 0; + j = 0; + + /* Scan for the descriptor's system precedence index */ + do + { + if (MmPlatformMemoryTypePrecedence[j] == Type1) + { + break; + } + } while (++j < RTL_NUMBER_OF(MmPlatformMemoryTypePrecedence)); + + /* Use an invalid index if one wasn't found */ + if (j == RTL_NUMBER_OF(MmPlatformMemoryTypePrecedence)) + { + j = 0xFFFFFFFF; + } + + /* Now scan for the comparator's system precedence index */ + while (MmPlatformMemoryTypePrecedence[i] != Type2) + { + /* Use an invalid index if one wasn't found */ + if (++i >= RTL_NUMBER_OF(MmPlatformMemoryTypePrecedence)) + { + i = 0xFFFFFFFF; + break; + } + } + + /* Does the current have a valid index? */ + if (j != 0xFFFFFFFF) + { + /* Yes, what about the comparator? */ + if (i != 0xFFFFFFFF) + { + /* Let the indexes fight! */ + return i >= j; + } + + /* Succeed the comparator, its index is unknown */ + return FALSE; + } + } + + /* The comparator isn't system, so it preceeds it */ + return TRUE; + } + + /* Descriptor is not system class, but comparator is -- it suceeds it */ + if (Class2 == BlSystemClass) + { + return FALSE; + } + + /* Descriptor is loader class -- it preceeds */ + if (Class1 == BlLoaderClass) + { + return TRUE; + } + + /* It isn't loader class -- if the other guy is, suceed it */ + return Class2 != BlLoaderClass; +} VOID MmMdpSwitchToDynamicDescriptors ( @@ -113,6 +236,157 @@ } } +PBL_MEMORY_DESCRIPTOR +MmMdInitByteGranularDescriptor ( + _In_ ULONG Flags, + _In_ BL_MEMORY_TYPE Type, + _In_ ULONGLONG BasePage, + _In_ ULONGLONG VirtualPage, + _In_ ULONGLONG PageCount + ) +{ + PBL_MEMORY_DESCRIPTOR MemoryDescriptor; + + /* If we're out of descriptors, bail out */ + if (MmGlobalMemoryDescriptorsUsed >= MmGlobalMemoryDescriptorCount) + { + EarlyPrint(L"Out of descriptors!\n"); + return NULL; + } + + /* Take one of the available descriptors and fill it out */ + MemoryDescriptor = &MmGlobalMemoryDescriptors[MmGlobalMemoryDescriptorsUsed]; + MemoryDescriptor->BaseAddress = BasePage; + MemoryDescriptor->VirtualPage = VirtualPage; + MemoryDescriptor->PageCount = PageCount; + MemoryDescriptor->Flags = Flags; + MemoryDescriptor->Type = Type; + InitializeListHead(&MemoryDescriptor->ListEntry); + + /* Increment the count and return the descriptor */ + MmGlobalMemoryDescriptorsUsed++; + return MemoryDescriptor; +} + +NTSTATUS +MmMdAddDescriptorToList ( + _In_ PBL_MEMORY_DESCRIPTOR_LIST MdList, + _In_ PBL_MEMORY_DESCRIPTOR MemoryDescriptor, + _In_ ULONG Flags + ) +{ + PLIST_ENTRY ThisEntry, FirstEntry; + PBL_MEMORY_DESCRIPTOR ThisDescriptor; + + /* Arguments must be present */ + if (!(MdList) || !(MemoryDescriptor)) + { + return STATUS_INVALID_PARAMETER; + } + + /* Check if coalescing is forcefully disabled */ + if (Flags & BL_MM_ADD_DESCRIPTOR_NEVER_COALESCE_FLAG) + { + /* Then we won't be coalescing */ + Flags &= BL_MM_ADD_DESCRIPTOR_COALESCE_FLAG; + } + else + { + /* Coalesce if the descriptor requires it */ + if (MemoryDescriptor->Flags & BL_MM_DESCRIPTOR_REQUIRES_COALESCING_FLAG) + { + Flags |= BL_MM_ADD_DESCRIPTOR_COALESCE_FLAG; + } + } + + /* Check if truncation is forcefully disabled */ + if (Flags & BL_MM_ADD_DESCRIPTOR_NEVER_TRUNCATE_FLAG) + { + Flags &= ~BL_MM_ADD_DESCRIPTOR_TRUNCATE_FLAG; + } + + /* Update the current list pointer if the descriptor requires it */ + if (MemoryDescriptor->Flags & BL_MM_DESCRIPTOR_REQUIRES_UPDATING_FLAG) + { + Flags |= BL_MM_ADD_DESCRIPTOR_UPDATE_LIST_POINTER_FLAG; + } + + /* Get the current descriptor */ + ThisEntry = MdList->This; + ThisDescriptor = CONTAINING_RECORD(ThisEntry, BL_MEMORY_DESCRIPTOR, ListEntry); + + /* Also get the first descriptor */ + FirstEntry = MdList->First; + + /* Check if there's no current pointer, or if it's higher than the new one */ + if (!(ThisEntry) || + (MemoryDescriptor->BaseAddress <= ThisDescriptor->BaseAddress)) + { + /* Start at the first descriptor instead, since current is past us */ + ThisEntry = FirstEntry->Flink; + ThisDescriptor = CONTAINING_RECORD(ThisEntry, BL_MEMORY_DESCRIPTOR, ListEntry); + } + + /* Loop until we find the right location to insert */ + while (1) + { + /* Have we gotten back to the first entry? */ + if (ThisEntry == FirstEntry) + { + /* Then we didn't find a good match, so insert it right here */ + InsertTailList(FirstEntry, &MemoryDescriptor->ListEntry); + + /* Do we have to truncate? */ + if (Flags & BL_MM_ADD_DESCRIPTOR_TRUNCATE_FLAG) + { + /* Do it and then exit */ +#if 0 + if (MmMdpTruncateDescriptor(MdList, Flags)) + { + return STATUS_SUCCESS; + } +#endif + } + + /* Do we have to coalesce? */ + if (Flags & BL_MM_ADD_DESCRIPTOR_COALESCE_FLAG) + { + /* Do it and then exit */ +#if 0 + if (MmMdpCoalesceDescriptor(MdList)) + { + return STATUS_SUCCESS; + } +#endif + } + + /* Do we have to update the current pointer? */ + if (Flags & BL_MM_ADD_DESCRIPTOR_UPDATE_LIST_POINTER_FLAG) + { + /* Do it */ + MmMdpSaveCurrentListPointer(MdList, &MemoryDescriptor->ListEntry); + } + + /* We're done */ + return STATUS_SUCCESS; + } + + /* Is the new descriptor below this address, and has precedence over it? */ + if ((MemoryDescriptor->BaseAddress < ThisDescriptor->BaseAddress) && + (MmMdpHasPrecedence(MemoryDescriptor->Type, ThisDescriptor->Type))) + { + /* Then insert right here */ + InsertTailList(ThisEntry, &MemoryDescriptor->ListEntry); + return STATUS_SUCCESS; + } + + /* Try the next descriptor */ + ThisEntry = ThisEntry->Flink; + ThisDescriptor = CONTAINING_RECORD(ThisEntry, BL_MEMORY_DESCRIPTOR, ListEntry); + } +} + + VOID MmMdInitialize ( _In_ ULONG Phase, Modified: trunk/reactos/boot/environ/lib/mm/mm.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/mm/mm.c?r…
============================================================================== --- trunk/reactos/boot/environ/lib/mm/mm.c [iso-8859-1] (original) +++ trunk/reactos/boot/environ/lib/mm/mm.c [iso-8859-1] Sun Sep 6 06:15:08 2015 @@ -31,7 +31,8 @@ VOID ) { - return STATUS_NOT_IMPLEMENTED; + /* FIXME: Read BCD option to see what bad memory to remove */ + return STATUS_SUCCESS; } NTSTATUS Modified: trunk/reactos/boot/environ/lib/mm/pagealloc.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/mm/pageal…
============================================================================== --- trunk/reactos/boot/environ/lib/mm/pagealloc.c [iso-8859-1] (original) +++ trunk/reactos/boot/environ/lib/mm/pagealloc.c [iso-8859-1] Sun Sep 6 06:15:08 2015 @@ -16,6 +16,8 @@ ULONG PapMinimumAllocationCount; +BOOLEAN PapInitializationStatus; + BL_MEMORY_DESCRIPTOR_LIST MmMdlMappedAllocated; BL_MEMORY_DESCRIPTOR_LIST MmMdlMappedUnallocated; BL_MEMORY_DESCRIPTOR_LIST MmMdlFwAllocationTracker; @@ -32,12 +34,23 @@ /* FUNCTIONS *****************************************************************/ NTSTATUS +BlpMmInitializeConstraints ( + VOID + ) +{ + /* FIXME: Read BCD option 'avoidlowmemory' and 'truncatememory' */ + return STATUS_SUCCESS; +} + +NTSTATUS MmPaInitialize ( __in PBL_MEMORY_DATA BootMemoryData, __in ULONG MinimumAllocationCount ) { NTSTATUS Status; + ULONG ExistingDescriptors, FinalOffset; + PBL_MEMORY_DESCRIPTOR Descriptor; /* Initialize physical allocator variables */ PapMaximumPhysicalPage = 0xFFFFFFFFFFFFF; @@ -59,10 +72,56 @@ /* Get the BIOS memory map */ Status = MmFwGetMemoryMap(&MmMdlUnmappedUnallocated, BL_MM_FLAG_USE_FIRMWARE_FOR_MEMORY_MAP_BUFFERS | - BL_MM_FLAG_UNKNOWN); + BL_MM_FLAG_REQUEST_COALESCING); if (NT_SUCCESS(Status)) { - Status = STATUS_NOT_IMPLEMENTED; + PLIST_ENTRY listHead, nextEntry; + + /* Loop the NT firmware memory list */ + EarlyPrint(L"NT MEMORY MAP\n\n"); + listHead = &MmMdlUnmappedUnallocated.ListHead; + nextEntry = listHead->Flink; + while (listHead != nextEntry) + { + Descriptor = CONTAINING_RECORD(nextEntry, BL_MEMORY_DESCRIPTOR, ListEntry); + + EarlyPrint(L"Type: %lX Flags: %lX Start: 0x%I64X End: 0x%I64X\n", + Descriptor->Type, + Descriptor->Flags, + Descriptor->BasePage << PAGE_SHIFT, + (Descriptor->BasePage + Descriptor->PageCount) << PAGE_SHIFT); + + nextEntry = nextEntry->Flink; + } + + /* + * Because BL supports cross x86-x64 application launches and a LIST_ENTRY + * is of variable size, care must be taken here to ensure that we see a + * consistent view of descriptors. BL uses some offset magic to figure out + * where the data actually starts, since everything is ULONGLONG past the + * LIST_ENTRY itself + */ + FinalOffset = BootMemoryData->MdListOffset + BootMemoryData->DescriptorOffset; + Descriptor = (PBL_MEMORY_DESCRIPTOR)((ULONG_PTR)BootMemoryData + FinalOffset - + FIELD_OFFSET(BL_MEMORY_DESCRIPTOR, BasePage)); + + /* Scan all of them */ + ExistingDescriptors = BootMemoryData->DescriptorCount; + while (ExistingDescriptors != 0) + { + EarlyPrint(L"Existing migration of memory not supported\n"); + Status = STATUS_NOT_IMPLEMENTED; + break; + } + + /* We are done, so check for any RAM constraints which will make us truncate memory */ + Status = BlpMmInitializeConstraints(); + if (NT_SUCCESS(Status)) + { + /* The Page Allocator has initialized */ + PapInitializationStatus = TRUE; + Status = STATUS_SUCCESS; + } } /* Return status */
9 years, 3 months
1
0
0
0
[tfaber] 69046: [MSVCRT] - Properly ignore LNK4102 for libmsvcrt
by tfaber@svn.reactos.org
Author: tfaber Date: Sun Sep 6 05:20:26 2015 New Revision: 69046 URL:
http://svn.reactos.org/svn/reactos?rev=69046&view=rev
Log: [MSVCRT] - Properly ignore LNK4102 for libmsvcrt Modified: trunk/reactos/dll/win32/msvcrt/CMakeLists.txt Modified: trunk/reactos/dll/win32/msvcrt/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msvcrt/CMakeList…
============================================================================== --- trunk/reactos/dll/win32/msvcrt/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/dll/win32/msvcrt/CMakeLists.txt [iso-8859-1] Sun Sep 6 05:20:26 2015 @@ -27,7 +27,7 @@ if(MSVC) # export of deleting destructor "name" add_target_link_flags(msvcrt "/ignore:4102") - add_target_link_flags(libmsvcrt "/ignore:4102") + add_target_property(libmsvcrt STATIC_LIBRARY_FLAGS "/ignore:4102") endif() add_importlibs(msvcrt kernel32 ntdll)
9 years, 3 months
1
0
0
0
[ion] 69045: [BOOTMGFW]: - Start implementing the page allocator. Right now, we are able to obtain & dump the UEFI memory map.
by ion@svn.reactos.org
Author: ion Date: Sun Sep 6 04:53:49 2015 New Revision: 69045 URL:
http://svn.reactos.org/svn/reactos?rev=69045&view=rev
Log: [BOOTMGFW]: - Start implementing the page allocator. Right now, we are able to obtain & dump the UEFI memory map. Modified: trunk/reactos/boot/environ/include/bl.h trunk/reactos/boot/environ/lib/bootlib.c trunk/reactos/boot/environ/lib/firmware/efi/firmware.c trunk/reactos/boot/environ/lib/mm/descriptor.c trunk/reactos/boot/environ/lib/mm/pagealloc.c Modified: trunk/reactos/boot/environ/include/bl.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/include/bl.h?…
============================================================================== --- trunk/reactos/boot/environ/include/bl.h [iso-8859-1] (original) +++ trunk/reactos/boot/environ/include/bl.h [iso-8859-1] Sun Sep 6 04:53:49 2015 @@ -51,6 +51,13 @@ #define BL_CONTEXT_PAGING_ON 1 #define BL_CONTEXT_INTERRUPTS_ON 2 + +#define BL_MM_FLAG_USE_FIRMWARE_FOR_MEMORY_MAP_BUFFERS 0x01 +#define BL_MM_FLAG_UNKNOWN 0x02 + +#define BL_LIBRARY_FLAG_REINITIALIZE 0x02 +#define BL_LIBRARY_FLAG_REINITIALIZE_ALL 0x04 +#define BL_LIBRARY_FLAG_INITIALIZATION_COMPLETED 0x20 /* ENUMERATIONS **************************************************************/ @@ -152,6 +159,19 @@ BlPalMemory = 0xF000000C, } BL_MEMORY_TYPE; +typedef enum _BL_MEMORY_ATTR +{ + BlMemoryUncached = 1, + BlMemoryWriteCombined = 2, + BlMemoryWriteThrough = 4, + BlMemoryWriteBack = 8, + BlMemoryUncachedExported = 0x10, + BlMemoryWriteProtected = 0x100, + BlMemoryReadProtected = 0x200, + BlMemoryExecuteProtected = 0x400, + BlMemoryRuntime = 0x1000000 +} BL_MEMORY_ATTR; + /* DATA STRUCTURES ***********************************************************/ typedef struct _BL_LIBRARY_PARAMETERS @@ -357,6 +377,14 @@ BL_TRANSLATION_TYPE TranslationType; ULONG ContextFlags; } BL_ARCH_CONTEXT, *PBL_ARCH_CONTEXT; + +typedef struct _BL_MEMORY_DESCRIPTOR_LIST +{ + LIST_ENTRY ListHead; + PLIST_ENTRY First; + PLIST_ENTRY This; + ULONG Type; +} BL_MEMORY_DESCRIPTOR_LIST, *PBL_MEMORY_DESCRIPTOR_LIST; /* INLINE ROUTINES ***********************************************************/ @@ -382,6 +410,18 @@ RtlCopyMemory(LibraryParameters, &DefaultParameters, sizeof(*LibraryParameters)); } +FORCEINLINE +VOID +MmMdInitializeListHead ( + _In_ PBL_MEMORY_DESCRIPTOR_LIST List + ) +{ + /* Initialize the list */ + InitializeListHead(&List->ListHead); + List->First = &List->ListHead; + List->This = NULL; +} + /* INITIALIZATION ROUTINES ***************************************************/ NTSTATUS @@ -461,12 +501,24 @@ _In_ ULONG HeapAttributes ); -NTSTATUS +VOID MmMdInitialize ( _In_ ULONG Phase, _In_ PBL_LIBRARY_PARAMETERS LibraryParameters ); +NTSTATUS +MmFwGetMemoryMap ( + _Out_ PBL_MEMORY_DESCRIPTOR_LIST MemoryMap, + _In_ ULONG Flags + ); + +VOID +MmMdFreeList( + _In_ PBL_MEMORY_DESCRIPTOR_LIST MdList + ); + +extern ULONG MmDescriptorCallTreeCount; extern ULONG BlpApplicationFlags; extern BL_LIBRARY_PARAMETERS BlpLibraryParameters; extern BL_TRANSLATION_TYPE MmTranslationType; Modified: trunk/reactos/boot/environ/lib/bootlib.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/bootlib.c…
============================================================================== --- trunk/reactos/boot/environ/lib/bootlib.c [iso-8859-1] (original) +++ trunk/reactos/boot/environ/lib/bootlib.c [iso-8859-1] Sun Sep 6 04:53:49 2015 @@ -165,11 +165,11 @@ NTSTATUS Status; /* Are we re-initializing the library? */ - if (LibraryParameters->LibraryFlags & 2) + if (LibraryParameters->LibraryFlags & BL_LIBRARY_FLAG_REINITIALIZE) { /* From scratch? */ BlpLibraryParameters = *LibraryParameters; - if (LibraryParameters->LibraryFlags & 4) + if (LibraryParameters->LibraryFlags & BL_LIBRARY_FLAG_REINITIALIZE_ALL) { #if 0 /* Initialize all the core modules again */ Modified: trunk/reactos/boot/environ/lib/firmware/efi/firmware.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/firmware/…
============================================================================== --- trunk/reactos/boot/environ/lib/firmware/efi/firmware.c [iso-8859-1] (original) +++ trunk/reactos/boot/environ/lib/firmware/efi/firmware.c [iso-8859-1] Sun Sep 6 04:53:49 2015 @@ -152,6 +152,437 @@ } NTSTATUS +EfiGetMemoryMap ( + _Out_ UINTN* MemoryMapSize, + _Inout_ EFI_MEMORY_DESCRIPTOR *MemoryMap, + _Out_ UINTN* MapKey, + _Out_ UINTN* DescriptorSize, + _Out_ UINTN* DescriptorVersion + ) +{ + BL_ARCH_MODE OldMode; + EFI_STATUS EfiStatus; + + /* Are we in protected mode? */ + OldMode = CurrentExecutionContext->Mode; + if (OldMode != BlRealMode) + { + /* FIXME: Not yet implemented */ + return STATUS_NOT_IMPLEMENTED; + } + + /* Make the EFI call */ + EfiStatus = EfiBS->GetMemoryMap(MemoryMapSize, + MemoryMap, + MapKey, + DescriptorSize, + DescriptorVersion); + + /* Switch back to protected mode if we came from there */ + if (OldMode != BlRealMode) + { + BlpArchSwitchContext(OldMode); + } + + /* Convert the error to an NTSTATUS */ + return EfiGetNtStatusCode(EfiStatus); +} + +NTSTATUS +EfiFreePages ( + _In_ ULONG Pages, + _In_ EFI_PHYSICAL_ADDRESS PhysicalAddress + ) +{ + BL_ARCH_MODE OldMode; + EFI_STATUS EfiStatus; + + /* Are we in protected mode? */ + OldMode = CurrentExecutionContext->Mode; + if (OldMode != BlRealMode) + { + /* FIXME: Not yet implemented */ + return STATUS_NOT_IMPLEMENTED; + } + + /* Make the EFI call */ + EfiStatus = EfiBS->FreePages(PhysicalAddress, Pages); + + /* Switch back to protected mode if we came from there */ + if (OldMode != BlRealMode) + { + BlpArchSwitchContext(OldMode); + } + + /* Convert the error to an NTSTATUS */ + return EfiGetNtStatusCode(EfiStatus); +} + +NTSTATUS +EfiAllocatePages ( + _In_ ULONG Type, + _In_ ULONG Pages, + _Inout_ EFI_PHYSICAL_ADDRESS* Memory + ) +{ + BL_ARCH_MODE OldMode; + EFI_STATUS EfiStatus; + + /* Are we in protected mode? */ + OldMode = CurrentExecutionContext->Mode; + if (OldMode != BlRealMode) + { + /* FIXME: Not yet implemented */ + return STATUS_NOT_IMPLEMENTED; + } + + /* Make the EFI call */ + EfiStatus = EfiBS->AllocatePages(Type, EfiLoaderData, Pages, Memory); + + /* Switch back to protected mode if we came from there */ + if (OldMode != BlRealMode) + { + BlpArchSwitchContext(OldMode); + } + + /* Convert the error to an NTSTATUS */ + return EfiGetNtStatusCode(EfiStatus); +} + +BL_MEMORY_ATTR +MmFwpGetOsAttributeType ( + _In_ ULONGLONG Attribute + ) +{ + BL_MEMORY_ATTR OsAttribute = 0; + + if (Attribute & EFI_MEMORY_UC) + { + OsAttribute = BlMemoryUncached; + } + + if (Attribute & EFI_MEMORY_WC) + { + OsAttribute |= BlMemoryWriteCombined; + } + + if (Attribute & EFI_MEMORY_WT) + { + OsAttribute |= BlMemoryWriteThrough; + } + + if (Attribute & EFI_MEMORY_WB) + { + OsAttribute |= BlMemoryWriteBack; + } + + if (Attribute & EFI_MEMORY_UCE) + { + OsAttribute |= BlMemoryUncachedExported; + } + + if (Attribute & EFI_MEMORY_WP) + { + OsAttribute |= BlMemoryWriteProtected; + } + + if (Attribute & EFI_MEMORY_RP) + { + OsAttribute |= BlMemoryReadProtected; + } + + if (Attribute & EFI_MEMORY_XP) + { + OsAttribute |= BlMemoryExecuteProtected; + } + + if (Attribute & EFI_MEMORY_RUNTIME) + { + OsAttribute |= BlMemoryRuntime; + } + + return OsAttribute; +} + +BL_MEMORY_TYPE +MmFwpGetOsMemoryType ( + _In_ EFI_MEMORY_TYPE MemoryType + ) +{ + BL_MEMORY_TYPE OsType; + + switch (MemoryType) + { + case EfiLoaderCode: + case EfiLoaderData: + OsType = BlLoaderMemory; + break; + + case EfiBootServicesCode: + case EfiBootServicesData: + OsType = BlEfiBootMemory; + break; + + case EfiRuntimeServicesCode: + case EfiRuntimeServicesData: + OsType = BlEfiRuntimeMemory; + break; + + case EfiConventionalMemory: + OsType = BlConventionalMemory; + break; + + case EfiUnusableMemory: + OsType = BlUnusableMemory; + break; + + case EfiACPIReclaimMemory: + OsType = BlAcpiReclaimMemory; + break; + + case EfiACPIMemoryNVS: + OsType = BlAcpiNvsMemory; + break; + + case EfiMemoryMappedIO: + OsType = BlDeviceIoMemory; + break; + + case EfiMemoryMappedIOPortSpace: + OsType = BlDevicePortMemory; + break; + + case EfiPalCode: + OsType = BlPalMemory; + break; + + default: + OsType = BlReservedMemory; + break; + } + + return OsType; +} + +NTSTATUS +MmFwGetMemoryMap ( + _Out_ PBL_MEMORY_DESCRIPTOR_LIST MemoryMap, + _In_ ULONG Flags + ) +{ + BL_LIBRARY_PARAMETERS LibraryParameters = BlpLibraryParameters; + BOOLEAN UseEfiBuffer; + NTSTATUS Status; + ULONGLONG Pages, StartPage, EndPage; + UINTN EfiMemoryMapSize, MapKey, DescriptorSize, DescriptorVersion; + EFI_PHYSICAL_ADDRESS EfiBuffer; + EFI_MEMORY_DESCRIPTOR* EfiMemoryMap; + EFI_STATUS EfiStatus; + BL_ARCH_MODE OldMode; + EFI_MEMORY_DESCRIPTOR EfiDescriptor; + BL_MEMORY_TYPE MemoryType; + + /* Increment the nesting depth */ + MmDescriptorCallTreeCount++; + + /* Determine if we should use EFI or our own allocator at this point */ + UseEfiBuffer = Flags & BL_MM_FLAG_USE_FIRMWARE_FOR_MEMORY_MAP_BUFFERS; + if (!(LibraryParameters.LibraryFlags & BL_LIBRARY_FLAG_INITIALIZATION_COMPLETED)) + { + UseEfiBuffer = TRUE; + } + + /* Bail out if we don't have a list to use */ + if (MemoryMap == NULL) + { + Status = STATUS_INVALID_PARAMETER; + goto Quickie; + } + + /* Free the current descriptor list */ + MmMdFreeList(MemoryMap); + + /* Call into EFI to get the size of the memory map */ + Status = EfiGetMemoryMap(&EfiMemoryMapSize, + NULL, + &MapKey, + &DescriptorSize, + &DescriptorVersion); + if (Status != STATUS_BUFFER_TOO_SMALL) + { + /* This should've failed because our buffer was too small, nothing else */ + EarlyPrint(L"Got strange EFI status for memory map: %lx\n", Status); + if (NT_SUCCESS(Status)) + { + Status = STATUS_UNSUCCESSFUL; + } + goto Quickie; + } + + /* Add 4 more descriptors just in case things changed */ + EfiMemoryMapSize += (4 * DescriptorSize); + Pages = BYTES_TO_PAGES(EfiMemoryMapSize); + EarlyPrint(L"Memory map size: %lx bytes, %d pages\n", EfiMemoryMapSize, Pages); + + /* Should we use EFI to grab memory? */ + if (UseEfiBuffer) + { + /* Yes -- request one more page to align up correctly */ + Pages++; + + /* Grab the required pages */ + Status = EfiAllocatePages(AllocateAnyPages, + Pages, + &EfiBuffer); + if (!NT_SUCCESS(Status)) + { + EarlyPrint(L"EFI allocation failed: %lx\n", Status); + goto Quickie; + } + + /* Free the pages for now */ + Status = EfiFreePages(Pages, EfiBuffer); + if (!NT_SUCCESS(Status)) + { + EfiBuffer = 0; + goto Quickie; + } + + /* Now round to the actual buffer size, removing the extra page */ + EfiBuffer = ROUND_TO_PAGES(EfiBuffer); + Pages--; + Status = EfiAllocatePages(AllocateAddress, + Pages, + &EfiBuffer); + if (!NT_SUCCESS(Status)) + { + EfiBuffer = 0; + goto Quickie; + } + + /* Get the final aligned size and proper buffer */ + EfiMemoryMapSize = EFI_PAGES_TO_SIZE(Pages); + EfiMemoryMap = (EFI_MEMORY_DESCRIPTOR*)(ULONG_PTR)EfiBuffer; + + /* Switch to real mode if not already in it */ + OldMode = CurrentExecutionContext->Mode; + if (OldMode != BlRealMode) + { + BlpArchSwitchContext(BlRealMode); + } + + /* Call EFI to get the memory map */ + EfiStatus = EfiBS->GetMemoryMap(&EfiMemoryMapSize, + EfiMemoryMap, + &MapKey, + &DescriptorSize, + &DescriptorVersion); + + /* Switch back into the previous mode */ + if (OldMode != BlRealMode) + { + BlpArchSwitchContext(OldMode); + } + + /* Convert the result code */ + Status = EfiGetNtStatusCode(EfiStatus); + } + else + { + /* We don't support this path yet */ + Status = STATUS_NOT_IMPLEMENTED; + } + + /* So far so good? */ + if (!NT_SUCCESS(Status)) + { + EarlyPrint(L"Failed to get EFI memory map: %lx\n", Status); + goto Quickie; + } + + /* Did we get correct data from firmware? */ + if (((EfiMemoryMapSize % DescriptorSize)) || + (DescriptorSize < sizeof(EFI_MEMORY_DESCRIPTOR))) + { + EarlyPrint(L"Incorrect descriptor size\n"); + Status = STATUS_UNSUCCESSFUL; + goto Quickie; + } + + /* Loop the EFI memory map */ + EarlyPrint(L"UEFI MEMORY MAP\n\n"); + EarlyPrint(L"TYPE START END ATTRIBUTES\n"); + EarlyPrint(L"===============================================================\n"); + while (EfiMemoryMapSize != 0) + { + /* Check if this is an EFI buffer, but we're not in real mode */ + if ((UseEfiBuffer) && (OldMode != BlRealMode)) + { + BlpArchSwitchContext(BlRealMode); + } + + /* Capture it so we can go back to protected mode (if possible) */ + EfiDescriptor = *EfiMemoryMap; + + /* Go back to protected mode, if we had switched */ + if ((UseEfiBuffer) && (OldMode != BlRealMode)) + { + BlpArchSwitchContext(OldMode); + } + + /* Convert to OS memory type */ + MemoryType = MmFwpGetOsMemoryType(EfiDescriptor.Type); + + /* Round up or round down depending on where the memory is coming from */ + if (MemoryType == BlConventionalMemory) + { + StartPage = BYTES_TO_PAGES(EfiDescriptor.PhysicalStart); + } + else + { + StartPage = EfiDescriptor.PhysicalStart >> PAGE_SHIFT; + } + + /* Calculate the ending page */ + EndPage = StartPage + EfiDescriptor.NumberOfPages; + + /* If after rounding, we ended up with 0 pages, skip this */ + if (StartPage == EndPage) + { + goto LoopAgain; + } + + EarlyPrint(L"%08X 0x%016I64X-0x%016I64X 0x%X\n", + MemoryType, + StartPage << PAGE_SHIFT, + EndPage << PAGE_SHIFT, + EfiDescriptor.Attribute); + + /* Consume this descriptor, and move to the next one */ +LoopAgain: + EfiMemoryMapSize -= DescriptorSize; + EfiMemoryMap = (PVOID)((ULONG_PTR)EfiMemoryMap + DescriptorSize); + } + +Quickie: + /* Free the EFI buffer, if we had one */ + if (EfiBuffer != 0) + { + EfiFreePages(Pages, EfiBuffer); + } + + /* On failure, free the memory map if one was passed in */ + if (!NT_SUCCESS(Status) && (MemoryMap != NULL)) + { + MmMdFreeList(MemoryMap); + } + + /* Decrement the nesting depth and return */ + MmDescriptorCallTreeCount--; + return Status; +} + +NTSTATUS BlpFwInitialize ( _In_ ULONG Phase, _In_ PBL_FIRMWARE_DESCRIPTOR FirmwareData Modified: trunk/reactos/boot/environ/lib/mm/descriptor.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/mm/descri…
============================================================================== --- trunk/reactos/boot/environ/lib/mm/descriptor.c [iso-8859-1] (original) +++ trunk/reactos/boot/environ/lib/mm/descriptor.c [iso-8859-1] Sun Sep 6 04:53:49 2015 @@ -12,15 +12,128 @@ /* DATA VARIABLES ************************************************************/ +BL_MEMORY_DESCRIPTOR MmStaticMemoryDescriptors[512]; +ULONG MmGlobalMemoryDescriptorCount; +PBL_MEMORY_DESCRIPTOR MmGlobalMemoryDescriptors; +BOOLEAN MmGlobalMemoryDescriptorsUsed; +PBL_MEMORY_DESCRIPTOR MmDynamicMemoryDescriptors; +ULONG MmDynamicMemoryDescriptorCount; /* FUNCTIONS *****************************************************************/ +VOID +MmMdpSwitchToDynamicDescriptors ( + _In_ ULONG Count + ) +{ + EarlyPrint(L"NOT SUPPORTED!!!\n"); + while (1); +} + NTSTATUS +MmMdFreeDescriptor ( + _In_ PBL_MEMORY_DESCRIPTOR MemoryDescriptor + ) +{ + NTSTATUS Status; + + /* Check if this is a valid static descriptor */ + if (((MmDynamicMemoryDescriptors) && + (MemoryDescriptor >= MmDynamicMemoryDescriptors) && + (MemoryDescriptor < (MmDynamicMemoryDescriptors + MmDynamicMemoryDescriptorCount))) || + ((MemoryDescriptor >= MmStaticMemoryDescriptors) && (MemoryDescriptor < &MmStaticMemoryDescriptors[511]))) + { + /* It's a global/static descriptor, so just zero it */ + RtlZeroMemory(MemoryDescriptor, sizeof(BL_MEMORY_DESCRIPTOR)); + Status = STATUS_SUCCESS; + } + else + { + /* It's a dynamic descriptor, so free it */ + EarlyPrint(L"Dynamic descriptors not yet supported\n"); + Status = STATUS_NOT_IMPLEMENTED; + } + + /* Done */ + return Status; +} + +VOID +MmMdpSaveCurrentListPointer ( + _In_ PBL_MEMORY_DESCRIPTOR_LIST MdList, + _In_ PLIST_ENTRY Current + ) +{ + /* Make sure that this is not a global descriptor and not the first one */ + if (((Current < &MmGlobalMemoryDescriptors->ListEntry) || + (Current >= &MmGlobalMemoryDescriptors[MmGlobalMemoryDescriptorCount].ListEntry)) && + (Current != MdList->First)) + { + /* Save this as the current pointer */ + MdList->This = Current; + } +} + +VOID +MmMdRemoveDescriptorFromList ( + _In_ PBL_MEMORY_DESCRIPTOR_LIST MdList, + _In_ PBL_MEMORY_DESCRIPTOR Entry + ) +{ + /* Remove the entry */ + RemoveEntryList(&Entry->ListEntry); + + /* Check if this was the current link */ + if (MdList->This == &Entry->ListEntry) + { + /* Remove the current link and set the next one */ + MdList->This = NULL; + MmMdpSaveCurrentListPointer(MdList, Entry->ListEntry.Blink); + } +} + +VOID +MmMdFreeList( + _In_ PBL_MEMORY_DESCRIPTOR_LIST MdList + ) +{ + PLIST_ENTRY FirstEntry, NextEntry; + PBL_MEMORY_DESCRIPTOR Entry; + + /* Go over every descriptor from the top */ + FirstEntry = MdList->First; + NextEntry = FirstEntry->Flink; + while (NextEntry != FirstEntry) + { + /* Remove and free each one */ + Entry = CONTAINING_RECORD(NextEntry, BL_MEMORY_DESCRIPTOR, ListEntry); + NextEntry = NextEntry->Flink; + MmMdRemoveDescriptorFromList(MdList, Entry); + MmMdFreeDescriptor(Entry); + } +} + +VOID MmMdInitialize ( _In_ ULONG Phase, _In_ PBL_LIBRARY_PARAMETERS LibraryParameters ) { - EarlyPrint(L"Md init\n"); - return STATUS_NOT_IMPLEMENTED; + /* Are we in phase 1? */ + if (Phase != 0) + { + /* Switch to dynamic descriptors if we have too many */ + if (LibraryParameters->DescriptorCount > RTL_NUMBER_OF(MmStaticMemoryDescriptors)) + { + MmMdpSwitchToDynamicDescriptors(LibraryParameters->DescriptorCount); + } + } + else + { + /* In phase 0, start with a pool of 512 static descriptors */ + MmGlobalMemoryDescriptorCount = RTL_NUMBER_OF(MmStaticMemoryDescriptors); + MmGlobalMemoryDescriptors = MmStaticMemoryDescriptors; + RtlZeroMemory(MmStaticMemoryDescriptors, sizeof(MmStaticMemoryDescriptors)); + MmGlobalMemoryDescriptorsUsed = FALSE; + } } Modified: trunk/reactos/boot/environ/lib/mm/pagealloc.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/mm/pageal…
============================================================================== --- trunk/reactos/boot/environ/lib/mm/pagealloc.c [iso-8859-1] (original) +++ trunk/reactos/boot/environ/lib/mm/pagealloc.c [iso-8859-1] Sun Sep 6 04:53:49 2015 @@ -12,14 +12,61 @@ /* DATA VARIABLES ************************************************************/ +ULONGLONG PapMaximumPhysicalPage, PapMinimumPhysicalPage; + +ULONG PapMinimumAllocationCount; + +BL_MEMORY_DESCRIPTOR_LIST MmMdlMappedAllocated; +BL_MEMORY_DESCRIPTOR_LIST MmMdlMappedUnallocated; +BL_MEMORY_DESCRIPTOR_LIST MmMdlFwAllocationTracker; +BL_MEMORY_DESCRIPTOR_LIST MmMdlUnmappedAllocated; +BL_MEMORY_DESCRIPTOR_LIST MmMdlUnmappedUnallocated; +BL_MEMORY_DESCRIPTOR_LIST MmMdlReservedAllocated; +BL_MEMORY_DESCRIPTOR_LIST MmMdlBadMemory; +BL_MEMORY_DESCRIPTOR_LIST MmMdlTruncatedMemory; +BL_MEMORY_DESCRIPTOR_LIST MmMdlPersistentMemory; +BL_MEMORY_DESCRIPTOR_LIST MmMdlCompleteBadMemory; +BL_MEMORY_DESCRIPTOR_LIST MmMdlFreeVirtual; +BL_MEMORY_DESCRIPTOR_LIST MmMdlMappingTrackers; /* FUNCTIONS *****************************************************************/ NTSTATUS MmPaInitialize ( - _In_ PBL_MEMORY_DATA MemoryData, - _In_ ULONG MinimumPages + __in PBL_MEMORY_DATA BootMemoryData, + __in ULONG MinimumAllocationCount ) { - return STATUS_NOT_IMPLEMENTED; + NTSTATUS Status; + + /* Initialize physical allocator variables */ + PapMaximumPhysicalPage = 0xFFFFFFFFFFFFF; + PapMinimumAllocationCount = MinimumAllocationCount; + PapMinimumPhysicalPage = 0; + + /* Initialize all the lists */ + MmMdInitializeListHead(&MmMdlMappedAllocated); + MmMdInitializeListHead(&MmMdlMappedUnallocated); + MmMdInitializeListHead(&MmMdlFwAllocationTracker); + MmMdInitializeListHead(&MmMdlUnmappedAllocated); + MmMdInitializeListHead(&MmMdlReservedAllocated); + MmMdInitializeListHead(&MmMdlBadMemory); + MmMdInitializeListHead(&MmMdlTruncatedMemory); + MmMdInitializeListHead(&MmMdlPersistentMemory); + MmMdInitializeListHead(&MmMdlUnmappedUnallocated); + MmMdInitializeListHead(&MmMdlCompleteBadMemory); + + /* Get the BIOS memory map */ + Status = MmFwGetMemoryMap(&MmMdlUnmappedUnallocated, + BL_MM_FLAG_USE_FIRMWARE_FOR_MEMORY_MAP_BUFFERS | + BL_MM_FLAG_UNKNOWN); + if (NT_SUCCESS(Status)) + { + Status = STATUS_NOT_IMPLEMENTED; + } + + /* Return status */ + return Status; } + +
9 years, 3 months
1
0
0
0
[ion] 69044: [BOOTMGFW] - Begin carving out the rough edges of the memory manager. This will be the hardest part.
by ion@svn.reactos.org
Author: ion Date: Sun Sep 6 03:24:30 2015 New Revision: 69044 URL:
http://svn.reactos.org/svn/reactos?rev=69044&view=rev
Log: [BOOTMGFW] - Begin carving out the rough edges of the memory manager. This will be the hardest part. Added: trunk/reactos/boot/environ/lib/mm/blkalloc.c (with props) trunk/reactos/boot/environ/lib/mm/descriptor.c (with props) trunk/reactos/boot/environ/lib/mm/heapalloc.c (with props) trunk/reactos/boot/environ/lib/mm/i386/ (with props) trunk/reactos/boot/environ/lib/mm/i386/mmx86.c (with props) trunk/reactos/boot/environ/lib/mm/mm.c (with props) trunk/reactos/boot/environ/lib/mm/pagealloc.c (with props) Removed: trunk/reactos/boot/environ/lib/mm/foo.c Modified: trunk/reactos/boot/environ/CMakeLists.txt trunk/reactos/boot/environ/include/bl.h trunk/reactos/boot/environ/lib/bootlib.c Modified: trunk/reactos/boot/environ/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/CMakeLists.tx…
============================================================================== --- trunk/reactos/boot/environ/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/boot/environ/CMakeLists.txt [iso-8859-1] Sun Sep 6 03:24:30 2015 @@ -12,7 +12,12 @@ lib/bootlib.c lib/misc/bcd.c lib/misc/util.c - lib/firmware/efi/firmware.c) + lib/firmware/efi/firmware.c + lib/mm/mm.c + lib/mm/pagealloc.c + lib/mm/heapalloc.c + lib/mm/blkalloc.c + lib/mm/descriptor.c) if(ARCH STREQUAL "i386") list(APPEND BOOTLIB_ASM_SOURCE @@ -20,6 +25,7 @@ ) list(APPEND BOOTLIB_SOURCE lib/arch/i386/arch.c + lib/mm/i386/mmx86.c ) elseif(ARCH STREQUAL "amd64") list(APPEND BOOTLIB_ASM_SOURCE Modified: trunk/reactos/boot/environ/include/bl.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/include/bl.h?…
============================================================================== --- trunk/reactos/boot/environ/include/bl.h [iso-8859-1] (original) +++ trunk/reactos/boot/environ/include/bl.h [iso-8859-1] Sun Sep 6 03:24:30 2015 @@ -1,9 +1,9 @@ /* -* COPYRIGHT: See COPYING.ARM in the top level directory -* PROJECT: ReactOS UEFI Boot Library -* FILE: boot/environ/include/bl.h -* PURPOSE: Main Boot Library Header -* PROGRAMMER: Alex Ionescu (alex.ionescu(a)reactos.org) + * COPYRIGHT: See COPYING.ARM in the top level directory + * PROJECT: ReactOS UEFI Boot Library + * FILE: boot/environ/include/bl.h + * PURPOSE: Main Boot Library Header + * PROGRAMMER: Alex Ionescu (alex.ionescu(a)reactos.org) */ #ifndef _BL_H @@ -401,6 +401,13 @@ _In_ PBL_FIRMWARE_DESCRIPTOR FirmwareParameters ); +NTSTATUS +BlpMmInitialize ( + _In_ PBL_MEMORY_DATA MemoryData, + _In_ BL_TRANSLATION_TYPE TranslationType, + _In_ PBL_LIBRARY_PARAMETERS LibraryParameters + ); + /* UTILITY ROUTINES **********************************************************/ EFI_STATUS @@ -425,6 +432,39 @@ VOID BlpArchSwitchContext ( _In_ BL_ARCH_MODE NewMode + ); + +/* MEMORY MANAGER ROUTINES ***************************************************/ + +NTSTATUS +MmBaInitialize ( + VOID + ); + +NTSTATUS +MmPaInitialize ( + _In_ PBL_MEMORY_DATA MemoryData, + _In_ ULONG MinimumPages + ); + +NTSTATUS +MmArchInitialize ( + _In_ ULONG Phase, + _In_ PBL_MEMORY_DATA MemoryData, + _In_ BL_TRANSLATION_TYPE TranslationType, + _In_ BL_TRANSLATION_TYPE LibraryTranslationType + ); + +NTSTATUS +MmHaInitialize ( + _In_ ULONG HeapSize, + _In_ ULONG HeapAttributes + ); + +NTSTATUS +MmMdInitialize ( + _In_ ULONG Phase, + _In_ PBL_LIBRARY_PARAMETERS LibraryParameters ); extern ULONG BlpApplicationFlags; Modified: trunk/reactos/boot/environ/lib/bootlib.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/bootlib.c…
============================================================================== --- trunk/reactos/boot/environ/lib/bootlib.c [iso-8859-1] (original) +++ trunk/reactos/boot/environ/lib/bootlib.c [iso-8859-1] Sun Sep 6 03:24:30 2015 @@ -18,9 +18,6 @@ PBOOT_APPLICATION_PARAMETER_BLOCK BlpApplicationParameters; BL_APPLICATION_ENTRY BlpApplicationEntry; BOOLEAN BlpLibraryParametersInitialized; - -/* temp */ -BL_TRANSLATION_TYPE MmTranslationType; /* FUNCTIONS *****************************************************************/ @@ -68,7 +65,7 @@ ) { NTSTATUS Status; - //PBL_MEMORY_DATA MemoryData; + PBL_MEMORY_DATA MemoryData; PBL_APPLICATION_ENTRY AppEntry; PBL_FIRMWARE_DESCRIPTOR FirmwareDescriptor; ULONG_PTR ParamPointer = (ULONG_PTR)BootAppParameters; @@ -84,7 +81,7 @@ } /* Get sub-structures */ - //MemoryData = (PBL_MEMORY_DATA)(ParamPointer + BootAppParameters->MemoryDataOffset); + MemoryData = (PBL_MEMORY_DATA)(ParamPointer + BootAppParameters->MemoryDataOffset); FirmwareDescriptor = (PBL_FIRMWARE_DESCRIPTOR)(ParamPointer + BootAppParameters->FirmwareParametersOffset); AppEntry = (PBL_APPLICATION_ENTRY)(ParamPointer + BootAppParameters->AppEntryOffset); BlpBootDevice = (PBL_DEVICE_DESCRIPTOR)(ParamPointer + BootAppParameters->BootDeviceOffset); @@ -122,6 +119,16 @@ Status = BlpArchInitialize(0); if (!NT_SUCCESS(Status)) { + goto Quickie; + } + + /* Initialize the memory manager */ + Status = BlpMmInitialize(MemoryData, + BootAppParameters->MemoryTranslationType, + LibraryParameters); + if (!NT_SUCCESS(Status)) + { + EarlyPrint(L"MM init failed!\n"); goto Quickie; } Added: trunk/reactos/boot/environ/lib/mm/blkalloc.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/mm/blkall…
============================================================================== --- trunk/reactos/boot/environ/lib/mm/blkalloc.c (added) +++ trunk/reactos/boot/environ/lib/mm/blkalloc.c [iso-8859-1] Sun Sep 6 03:24:30 2015 @@ -0,0 +1,24 @@ +/* + * COPYRIGHT: See COPYING.ARM in the top level directory + * PROJECT: ReactOS UEFI Boot Library + * FILE: boot/environ/lib/mm/blkalloc.c + * PURPOSE: Boot Library Memory Manager Block Allocator + * PROGRAMMER: Alex Ionescu (alex.ionescu(a)reactos.org) +*/ + +/* INCLUDES ******************************************************************/ + +#include "bl.h" + +/* DATA VARIABLES ************************************************************/ + + +/* FUNCTIONS *****************************************************************/ + +NTSTATUS +MmBaInitialize ( + VOID + ) +{ + return STATUS_NOT_IMPLEMENTED; +} Propchange: trunk/reactos/boot/environ/lib/mm/blkalloc.c ------------------------------------------------------------------------------ svn:eol-style = native Added: trunk/reactos/boot/environ/lib/mm/descriptor.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/mm/descri…
============================================================================== --- trunk/reactos/boot/environ/lib/mm/descriptor.c (added) +++ trunk/reactos/boot/environ/lib/mm/descriptor.c [iso-8859-1] Sun Sep 6 03:24:30 2015 @@ -0,0 +1,26 @@ +/* + * COPYRIGHT: See COPYING.ARM in the top level directory + * PROJECT: ReactOS UEFI Boot Library + * FILE: boot/environ/lib/mm/descriptor.c + * PURPOSE: Boot Library Memory Manager Descriptor Manager + * PROGRAMMER: Alex Ionescu (alex.ionescu(a)reactos.org) +*/ + +/* INCLUDES ******************************************************************/ + +#include "bl.h" + +/* DATA VARIABLES ************************************************************/ + + +/* FUNCTIONS *****************************************************************/ + +NTSTATUS +MmMdInitialize ( + _In_ ULONG Phase, + _In_ PBL_LIBRARY_PARAMETERS LibraryParameters + ) +{ + EarlyPrint(L"Md init\n"); + return STATUS_NOT_IMPLEMENTED; +} Propchange: trunk/reactos/boot/environ/lib/mm/descriptor.c ------------------------------------------------------------------------------ svn:eol-style = native Removed: trunk/reactos/boot/environ/lib/mm/foo.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/mm/foo.c?…
============================================================================== (empty) Added: trunk/reactos/boot/environ/lib/mm/heapalloc.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/mm/heapal…
============================================================================== --- trunk/reactos/boot/environ/lib/mm/heapalloc.c (added) +++ trunk/reactos/boot/environ/lib/mm/heapalloc.c [iso-8859-1] Sun Sep 6 03:24:30 2015 @@ -0,0 +1,25 @@ +/* + * COPYRIGHT: See COPYING.ARM in the top level directory + * PROJECT: ReactOS UEFI Boot Library + * FILE: boot/environ/lib/mm/heapalloc.c + * PURPOSE: Boot Library Memory Manager Heap Allocator + * PROGRAMMER: Alex Ionescu (alex.ionescu(a)reactos.org) + */ + +/* INCLUDES ******************************************************************/ + +#include "bl.h" + +/* DATA VARIABLES ************************************************************/ + + +/* FUNCTIONS *****************************************************************/ + +NTSTATUS +MmHaInitialize ( + _In_ ULONG HeapSize, + _In_ ULONG HeapAttributes + ) +{ + return STATUS_NOT_IMPLEMENTED; +} Propchange: trunk/reactos/boot/environ/lib/mm/heapalloc.c ------------------------------------------------------------------------------ svn:eol-style = native Propchange: trunk/reactos/boot/environ/lib/mm/i386/ ------------------------------------------------------------------------------ --- bugtraq:logregex (added) +++ bugtraq:logregex Sun Sep 6 03:24:30 2015 @@ -0,0 +1 @@ +((CORE|ROSTESTS|ROSAPPS)-\d+)(,? ?((CORE|ROSTESTS|ROSAPPS)-\d+))*(,? ?(and |or )?((CORE|ROSTESTS|ROSAPPS)-\d+))? Propchange: trunk/reactos/boot/environ/lib/mm/i386/ ------------------------------------------------------------------------------ bugtraq:message = See issue %BUGID% for more details. Propchange: trunk/reactos/boot/environ/lib/mm/i386/ ------------------------------------------------------------------------------ bugtraq:url =
https://jira.reactos.org/browse/%BUGID%
Propchange: trunk/reactos/boot/environ/lib/mm/i386/ ------------------------------------------------------------------------------ tsvn:logminsize = 10 Added: trunk/reactos/boot/environ/lib/mm/i386/mmx86.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/mm/i386/m…
============================================================================== --- trunk/reactos/boot/environ/lib/mm/i386/mmx86.c (added) +++ trunk/reactos/boot/environ/lib/mm/i386/mmx86.c [iso-8859-1] Sun Sep 6 03:24:30 2015 @@ -0,0 +1,26 @@ +/* +* COPYRIGHT: See COPYING.ARM in the top level directory +* PROJECT: ReactOS UEFI Boot Library +* FILE: boot/environ/lib/mm/i386/mmx86.c +* PURPOSE: Boot Library Memory Manager x86-Specific Code +* PROGRAMMER: Alex Ionescu (alex.ionescu(a)reactos.org) +*/ + +/* INCLUDES ******************************************************************/ + +#include "bl.h" + +/* DATA VARIABLES ************************************************************/ + +/* FUNCTIONS *****************************************************************/ + +NTSTATUS +MmArchInitialize ( + _In_ ULONG Phase, + _In_ PBL_MEMORY_DATA MemoryData, + _In_ BL_TRANSLATION_TYPE TranslationType, + _In_ BL_TRANSLATION_TYPE LibraryTranslationType + ) +{ + return STATUS_NOT_IMPLEMENTED; +} Propchange: trunk/reactos/boot/environ/lib/mm/i386/mmx86.c ------------------------------------------------------------------------------ svn:eol-style = native Added: trunk/reactos/boot/environ/lib/mm/mm.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/mm/mm.c?r…
============================================================================== --- trunk/reactos/boot/environ/lib/mm/mm.c (added) +++ trunk/reactos/boot/environ/lib/mm/mm.c [iso-8859-1] Sun Sep 6 03:24:30 2015 @@ -0,0 +1,148 @@ +/* + * COPYRIGHT: See COPYING.ARM in the top level directory + * PROJECT: ReactOS UEFI Boot Library + * FILE: boot/environ/lib/mm/mm.c + * PURPOSE: Boot Library Memory Manager Core + * PROGRAMMER: Alex Ionescu (alex.ionescu(a)reactos.org) +*/ + +/* INCLUDES ******************************************************************/ + +#include "bl.h" + +/* DATA VARIABLES ************************************************************/ + +BL_TRANSLATION_TYPE MmTranslationType, MmOriginalTranslationType; +ULONG MmDescriptorCallTreeCount; + +/* FUNCTIONS *****************************************************************/ + +NTSTATUS +MmTrInitialize ( + VOID + ) +{ + return STATUS_NOT_IMPLEMENTED; +} + + +NTSTATUS +BlMmRemoveBadMemory ( + VOID + ) +{ + return STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS +BlpMmInitialize ( + _In_ PBL_MEMORY_DATA MemoryData, + _In_ BL_TRANSLATION_TYPE TranslationType, + _In_ PBL_LIBRARY_PARAMETERS LibraryParameters + ) +{ + NTSTATUS Status; + + /* Take a reference */ + MmDescriptorCallTreeCount = 1; + + /* Only support valid translation types */ + if ((TranslationType > BlPae) || (LibraryParameters->TranslationType > BlPae)) + { + /* Bail out */ + EarlyPrint(L"Invalid translation types present\n"); + Status = STATUS_INVALID_PARAMETER; + goto Quickie; + } + + /* Initialize memory descriptors */ + MmMdInitialize(0, LibraryParameters); + + /* Remember the page type we came in with */ + MmOriginalTranslationType = TranslationType; + + /* Initialize the physical page allocator */ + Status = MmPaInitialize(MemoryData, + LibraryParameters->MinimumAllocationCount); + if (!NT_SUCCESS(Status)) + { + goto Quickie; + } + + /* Initialize the memory tracker */ + Status = MmTrInitialize(); + if (!NT_SUCCESS(Status)) + { + //MmArchDestroy(); + //MmPaDestroy(1); + goto Quickie; + } + + /* Initialize paging, large pages, self-mapping, PAE, if needed */ + Status = MmArchInitialize(1, + MemoryData, + TranslationType, + LibraryParameters->TranslationType); + if (NT_SUCCESS(Status)) + { + /* Save the newly active transation type */ + MmTranslationType = LibraryParameters->TranslationType; + + /* Initialize the heap allocator now */ + Status = MmHaInitialize(LibraryParameters->MinimumHeapSize, + LibraryParameters->HeapAllocationAttributes); + } + + /* If Phase 1 init failed, bail out */ + if (!NT_SUCCESS(Status)) + { + /* Kill everything set setup so far */ + //MmPaDestroy(0); + //MmTrDestroy(); + //MmArchDestroy(); + //MmPaDestroy(1); + goto Quickie; + } + + /* Do we have too many descriptors? */ + if (LibraryParameters->DescriptorCount > 512) + { + /* Switch to using a dynamic buffer instead */ + //MmMdpSwitchToDynamicDescriptors(LibraryParameters->DescriptorCount); + } + + /* Remove memory that the BCD says is bad */ + BlMmRemoveBadMemory(); + + /* Now map all the memory regions as needed */ + Status = MmArchInitialize(2, + MemoryData, + TranslationType, + LibraryParameters->TranslationType); + if (NT_SUCCESS(Status)) + { + /* Initialize the block allocator */ + Status = MmBaInitialize(); + } + + /* Check if anything in phase 2 failed */ + if (!NT_SUCCESS(Status)) + { + /* Go back to static descriptors and kill the heap */ + //MmMdpSwitchToStaticDescriptors(); + //HapInitializationStatus = 0; + ++MmDescriptorCallTreeCount; + + /* Destroy the Phase 1 initialization */ + //MmPaDestroy(0); + //MmTrDestroy(); + //MmArchDestroy(); + //MmPaDestroy(1); + } + +Quickie: + /* Free the memory descriptors and return the initialization state */ + //MmMdFreeGlobalDescriptors(); + --MmDescriptorCallTreeCount; + return Status; +} Propchange: trunk/reactos/boot/environ/lib/mm/mm.c ------------------------------------------------------------------------------ svn:eol-style = native Added: trunk/reactos/boot/environ/lib/mm/pagealloc.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/mm/pageal…
============================================================================== --- trunk/reactos/boot/environ/lib/mm/pagealloc.c (added) +++ trunk/reactos/boot/environ/lib/mm/pagealloc.c [iso-8859-1] Sun Sep 6 03:24:30 2015 @@ -0,0 +1,25 @@ +/* + * COPYRIGHT: See COPYING.ARM in the top level directory + * PROJECT: ReactOS UEFI Boot Library + * FILE: boot/environ/lib/mm/pagealloc.c + * PURPOSE: Boot Library Memory Manager Page Allocator + * PROGRAMMER: Alex Ionescu (alex.ionescu(a)reactos.org) +*/ + +/* INCLUDES ******************************************************************/ + +#include "bl.h" + +/* DATA VARIABLES ************************************************************/ + + +/* FUNCTIONS *****************************************************************/ + +NTSTATUS +MmPaInitialize ( + _In_ PBL_MEMORY_DATA MemoryData, + _In_ ULONG MinimumPages + ) +{ + return STATUS_NOT_IMPLEMENTED; +} Propchange: trunk/reactos/boot/environ/lib/mm/pagealloc.c ------------------------------------------------------------------------------ svn:eol-style = native
9 years, 3 months
1
0
0
0
[ion] 69043: [BOOTMGFW]: - Use the right settings to make our CD UEFI compatible. The Internet says this is supposed to be 10000x harder, but it seems to work fine, at least in Virtual Box. - Imple...
by ion@svn.reactos.org
Author: ion Date: Sun Sep 6 03:02:56 2015 New Revision: 69043 URL:
http://svn.reactos.org/svn/reactos?rev=69043&view=rev
Log: [BOOTMGFW]: - Use the right settings to make our CD UEFI compatible. The Internet says this is supposed to be 10000x harder, but it seems to work fine, at least in Virtual Box. - Implement an EarlyPrint routine for early debugging/testing. - Using the above, fix a bunch of stupid bugs. The previously committed code now seems to work (so far). Modified: trunk/reactos/boot/environ/CMakeLists.txt trunk/reactos/boot/environ/app/bootmgr/bootmgr.c trunk/reactos/boot/environ/app/bootmgr/efiemu.c trunk/reactos/boot/environ/include/bl.h trunk/reactos/boot/environ/lib/bootlib.c Modified: trunk/reactos/boot/environ/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/CMakeLists.tx…
============================================================================== --- trunk/reactos/boot/environ/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/boot/environ/CMakeLists.txt [iso-8859-1] Sun Sep 6 03:02:56 2015 @@ -72,5 +72,5 @@ add_dependencies(bootmgfw asm bugcodes) -add_cd_file(TARGET bootmgfw FILE ${_bootmgfw_output_file} DESTINATION loader NO_CAB FOR bootcd regtest) +add_cd_file(TARGET bootmgfw FILE ${_bootmgfw_output_file} DESTINATION efi/boot NO_CAB FOR bootcd regtest NAME_ON_CD bootia32.efi) Modified: trunk/reactos/boot/environ/app/bootmgr/bootmgr.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/app/bootmgr/b…
============================================================================== --- trunk/reactos/boot/environ/app/bootmgr/bootmgr.c [iso-8859-1] (original) +++ trunk/reactos/boot/environ/app/bootmgr/bootmgr.c [iso-8859-1] Sun Sep 6 03:02:56 2015 @@ -9,6 +9,11 @@ /* INCLUDES ******************************************************************/ #include "bootmgr.h" + +/* DATA VARIABLES ************************************************************/ + +ULONGLONG ApplicationStartTime; +ULONGLONG PostTime; /* FUNCTIONS *****************************************************************/ @@ -33,8 +38,23 @@ NTSTATUS Status; BL_LIBRARY_PARAMETERS LibraryParameters; + EarlyPrint(L"ReactOS UEFI Boot Manager Initializing...\n"); + + /* Save the start/end-of-POST time */ + ApplicationStartTime = __rdtsc(); + PostTime = ApplicationStartTime; + + /* Setup the boot library parameters for this application */ + BlSetupDefaultParameters(&LibraryParameters); + LibraryParameters.TranslationType = BlNone; + LibraryParameters.LibraryFlags = 0x400 | 0x8; + LibraryParameters.MinimumAllocationCount = 16; + LibraryParameters.MinimumHeapSize = 512 * 1024; + + /* Initialize the boot library */ Status = BlInitializeLibrary(BootParameters, &LibraryParameters); + EarlyPrint(L"ReactOS UEFI Boot Manager Exiting: %lx\n", Status); return Status; } Modified: trunk/reactos/boot/environ/app/bootmgr/efiemu.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/app/bootmgr/e…
============================================================================== --- trunk/reactos/boot/environ/app/bootmgr/efiemu.c [iso-8859-1] (original) +++ trunk/reactos/boot/environ/app/bootmgr/efiemu.c [iso-8859-1] Sun Sep 6 03:02:56 2015 @@ -244,7 +244,7 @@ /* Get the length of the file path string, avoiding overflow */ StringLength = DevicePathNodeLength(FilePath) - FIELD_OFFSET(FILEPATH_DEVICE_PATH, PathName); - if (StringLength < FIELD_OFFSET(FILEPATH_DEVICE_PATH, PathName)) + if (StringLength < (ULONG)FIELD_OFFSET(FILEPATH_DEVICE_PATH, PathName)) { Status = STATUS_INTEGER_OVERFLOW; goto Quickie; @@ -285,7 +285,7 @@ if (PathString == StringEntry->String) { /* Then this option is empty */ - Option->Failed = TRUE; + Option->Empty = TRUE; } /* Set the final size of the option */ @@ -668,6 +668,7 @@ RemainingSize = MaximumLength; if (RemainingSize < sizeof(BL_APPLICATION_ENTRY)) { + EarlyPrint(L"Remaining size too small!\n"); Status = STATUS_INVALID_PARAMETER; goto Quickie; } @@ -711,7 +712,8 @@ if (!NT_SUCCESS(Status)) { /* We failed, so mark the option as such and return an empty one */ - Entry->BcdData.Failed = TRUE; + EarlyPrint(L"Failed to convert device path: %lx\n", Status); + Entry->BcdData.Empty = TRUE; TotalOptionSize = sizeof(BL_BCD_OPTION); goto Quickie; } @@ -732,6 +734,7 @@ { /* lol */ Status = STATUS_NOT_IMPLEMENTED; + EarlyPrint(L"UDP Boot not supported!\n"); } else { @@ -745,6 +748,7 @@ /* Bail out on failure */ if (!NT_SUCCESS(Status)) { + EarlyPrint(L"Failed to convert file path: %lx\n", Status); goto Quickie; } @@ -783,6 +787,7 @@ RemainingSize); if (!NT_SUCCESS(Status)) { + EarlyPrint(L"Failed to convert OS device path: %lx\n", Status); goto Quickie; } @@ -809,6 +814,7 @@ RemainingSize); if (!NT_SUCCESS(Status)) { + EarlyPrint(L"Failed to convert OS file path: %lx\n", Status); goto Quickie; } @@ -895,8 +901,7 @@ (VOID**)&LoadedImage); if (Status != EFI_SUCCESS) { - SystemTable->ConOut->OutputString(SystemTable->ConsoleOutHandle, - L"Loaded image failed\n"); + EarlyPrint(L"Loaded image failed: %lx\n", Status); return NULL; } @@ -905,13 +910,12 @@ EfiInitScratch.ImageSize = (ULONG)LoadedImage->ImageSize; /* Now grab our device path protocol, so we can convert the path later on */ - Status = BootServices->HandleProtocol(ImageHandle, + Status = BootServices->HandleProtocol(LoadedImage->DeviceHandle, &EfiDevicePathProtocol, (VOID**)&DevicePath); if (Status != EFI_SUCCESS) { - SystemTable->ConOut->OutputString(SystemTable->ConsoleOutHandle, - L"Device path failed\n"); + EarlyPrint(L"Device Path failed: %lx\n", Status); return NULL; } @@ -1011,6 +1015,7 @@ * *--*/ EFI_STATUS +EFIAPI EfiEntry ( _In_ EFI_HANDLE ImageHandle, _In_ EFI_SYSTEM_TABLE *SystemTable @@ -1018,22 +1023,22 @@ { NTSTATUS Status; PBOOT_APPLICATION_PARAMETER_BLOCK BootParameters; + extern EFI_SYSTEM_TABLE *g_SystemTable; /* Temporary debugging string */ - SystemTable->ConOut->OutputString(SystemTable->ConsoleOutHandle, L"Hello from EFI\n"); + g_SystemTable = SystemTable; /* Convert EFI parameters to Windows Boot Application parameters */ BootParameters = EfiInitCreateInputParametersEx(ImageHandle, SystemTable); if (BootParameters != NULL) { /* Conversion was good -- call the Boot Manager Entrypoint */ - SystemTable->ConOut->OutputString(SystemTable->ConsoleOutHandle, L"EFI input OK!\n"); Status = BmMain(BootParameters); } else { /* Conversion failed, bail out */ - SystemTable->ConOut->OutputString(SystemTable->ConsoleOutHandle, L"EFI input failed\n"); + EarlyPrint(L"EFI Input Conversion failed\n"); Status = STATUS_INVALID_PARAMETER; } Modified: trunk/reactos/boot/environ/include/bl.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/include/bl.h?…
============================================================================== --- trunk/reactos/boot/environ/include/bl.h [iso-8859-1] (original) +++ trunk/reactos/boot/environ/include/bl.h [iso-8859-1] Sun Sep 6 03:02:56 2015 @@ -26,6 +26,9 @@ #include <Uefi.h> #include <DevicePath.h> #include <LoadedImage.h> + +VOID +EarlyPrint(_In_ PWCHAR Format, ...); /* DEFINES *******************************************************************/ @@ -160,6 +163,7 @@ ULONG HeapAllocationAttributes; PWCHAR ApplicationBaseDirectory; ULONG DescriptorCount; + PWCHAR FontBaseDirectory; } BL_LIBRARY_PARAMETERS, *PBL_LIBRARY_PARAMETERS; /* This should eventually go into a more public header */ @@ -243,7 +247,7 @@ ULONG DataSize; ULONG ListOffset; ULONG NextEntryOffset; - ULONG Failed; + ULONG Empty; } BL_BCD_OPTION, *PBL_BCD_OPTION; typedef struct _BL_APPLICATION_ENTRY @@ -354,6 +358,30 @@ ULONG ContextFlags; } BL_ARCH_CONTEXT, *PBL_ARCH_CONTEXT; +/* INLINE ROUTINES ***********************************************************/ + +FORCEINLINE +VOID +BlSetupDefaultParameters ( + _Out_ PBL_LIBRARY_PARAMETERS LibraryParameters + ) +{ + BL_LIBRARY_PARAMETERS DefaultParameters = + { + 0x20, + BlVirtual, + 1024, + 2 * 1024 * 1024, + 0, + NULL, + 0, + NULL + }; + + /* Copy the defaults */ + RtlCopyMemory(LibraryParameters, &DefaultParameters, sizeof(*LibraryParameters)); +} + /* INITIALIZATION ROUTINES ***************************************************/ NTSTATUS Modified: trunk/reactos/boot/environ/lib/bootlib.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/bootlib.c…
============================================================================== --- trunk/reactos/boot/environ/lib/bootlib.c [iso-8859-1] (original) +++ trunk/reactos/boot/environ/lib/bootlib.c [iso-8859-1] Sun Sep 6 03:02:56 2015 @@ -23,6 +23,28 @@ BL_TRANSLATION_TYPE MmTranslationType; /* FUNCTIONS *****************************************************************/ + +/* HACKKKYYY */ +EFI_SYSTEM_TABLE* g_SystemTable; + +VOID +EarlyPrint(_In_ PWCHAR Format, ...) +{ + WCHAR buffer[1024]; + va_list args; + + va_start(args, Format); + + vswprintf(buffer, Format, args); + + g_SystemTable->ConOut->OutputString(g_SystemTable->ConOut, L"\r"); + g_SystemTable->ConOut->OutputString(g_SystemTable->ConOut, buffer); + + g_SystemTable->BootServices->Stall(1000000); + + va_end(args); +} +/* END HACKKKYYY */ /*++ * @name InitializeLibrary @@ -57,7 +79,8 @@ (BootAppParameters->Signature[1] != BOOT_APPLICATION_SIGNATURE_2) || (BootAppParameters->Size < sizeof(*BootAppParameters))) { - return STATUS_INVALID_PARAMETER; + Status = STATUS_INVALID_PARAMETER; + goto Quickie; } /* Get sub-structures */ @@ -78,6 +101,7 @@ if (strncmp(AppEntry->Signature, BL_APP_ENTRY_SIGNATURE, 7)) { Status = STATUS_INVALID_PARAMETER_9; + goto Quickie; } /* Read parameters */ @@ -101,9 +125,11 @@ goto Quickie; } + EarlyPrint(L"TODO!\n"); Status = STATUS_NOT_IMPLEMENTED; Quickie: + EarlyPrint(L"Exiting init: %lx\n", Status); return Status; }
9 years, 3 months
1
0
0
0
[sginsberg] 69042: - Silence some C4028 warnings in our code by fixing some mismatched const. - Also remove a misplaced INIT_FUNCTION and straggler RtlPrefetchMemoryNonTemporal.
by sginsberg@svn.reactos.org
Author: sginsberg Date: Sat Sep 5 20:50:51 2015 New Revision: 69042 URL:
http://svn.reactos.org/svn/reactos?rev=69042&view=rev
Log: - Silence some C4028 warnings in our code by fixing some mismatched const. - Also remove a misplaced INIT_FUNCTION and straggler RtlPrefetchMemoryNonTemporal. Modified: trunk/reactos/dll/opengl/mesa/main/buffers.h trunk/reactos/include/psdk/tapi.h trunk/reactos/lib/drivers/ip/transport/tcp/event.c trunk/reactos/lib/rtl/nls.c trunk/reactos/lib/rtl/powerpc/rtlmem.s Modified: trunk/reactos/dll/opengl/mesa/main/buffers.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/opengl/mesa/main/buffe…
============================================================================== --- trunk/reactos/dll/opengl/mesa/main/buffers.h [iso-8859-1] (original) +++ trunk/reactos/dll/opengl/mesa/main/buffers.h [iso-8859-1] Sat Sep 5 20:50:51 2015 @@ -41,7 +41,7 @@ _mesa_DrawBuffer( GLenum mode ); extern void -_mesa_drawbuffer(struct gl_context *ctx, const GLenum buffers, const GLbitfield destMask); +_mesa_drawbuffer(struct gl_context *ctx, const GLenum buffers, GLbitfield destMask); extern void _mesa_readbuffer(struct gl_context *ctx, GLenum buffer, GLint bufferIndex); Modified: trunk/reactos/include/psdk/tapi.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/psdk/tapi.h?rev=69…
============================================================================== --- trunk/reactos/include/psdk/tapi.h [iso-8859-1] (original) +++ trunk/reactos/include/psdk/tapi.h [iso-8859-1] Sat Sep 5 20:50:51 2015 @@ -956,7 +956,7 @@ DWORD WINAPI lineSetCallPrivilege(HCALL,DWORD); DWORD WINAPI lineSetCurrentLocation(HLINEAPP,DWORD); DWORD WINAPI lineSetDevConfig(DWORD,LPVOID,DWORD,LPCSTR); -DWORD WINAPI lineSetMediaControl(HLINE,DWORD,HCALL,DWORD,LPLINEMEDIACONTROLDIGIT,DWORD,LPLINEMEDIACONTROLMEDIA,DWORD,LPLINEMEDIACONTROLTONE,DWORD,LPLINEMEDIACONTROLCALLSTATE,DWORD); +DWORD WINAPI lineSetMediaControl(HLINE,DWORD,HCALL,DWORD,LPLINEMEDIACONTROLDIGIT const,DWORD,LPLINEMEDIACONTROLMEDIA const,DWORD,LPLINEMEDIACONTROLTONE const,DWORD,LPLINEMEDIACONTROLCALLSTATE const,DWORD); DWORD WINAPI lineSetMediaMode(HCALL,DWORD); DWORD WINAPI lineSetNumRings(HLINE,DWORD,DWORD); DWORD WINAPI lineSetStatusMessages(HLINE,DWORD,DWORD); Modified: trunk/reactos/lib/drivers/ip/transport/tcp/event.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/transport/t…
============================================================================== --- trunk/reactos/lib/drivers/ip/transport/tcp/event.c [iso-8859-1] (original) +++ trunk/reactos/lib/drivers/ip/transport/tcp/event.c [iso-8859-1] Sat Sep 5 20:50:51 2015 @@ -351,7 +351,7 @@ } VOID -TCPSendEventHandler(void *arg, u16_t space) +TCPSendEventHandler(void *arg, const u16_t space) { PCONNECTION_ENDPOINT Connection = (PCONNECTION_ENDPOINT)arg; PTDI_BUCKET Bucket; @@ -471,7 +471,7 @@ } VOID -TCPConnectEventHandler(void *arg, err_t err) +TCPConnectEventHandler(void *arg, const err_t err) { PCONNECTION_ENDPOINT Connection = (PCONNECTION_ENDPOINT)arg; PTDI_BUCKET Bucket; Modified: trunk/reactos/lib/rtl/nls.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/nls.c?rev=69042&r1…
============================================================================== --- trunk/reactos/lib/rtl/nls.c [iso-8859-1] (original) +++ trunk/reactos/lib/rtl/nls.c [iso-8859-1] Sat Sep 5 20:50:51 2015 @@ -36,8 +36,6 @@ USHORT NlsOemDefaultChar = '\0'; USHORT NlsUnicodeDefaultChar = 0; - -#define INIT_FUNCTION /* FUNCTIONS *****************************************************************/ Modified: trunk/reactos/lib/rtl/powerpc/rtlmem.s URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/powerpc/rtlmem.s?r…
============================================================================== --- trunk/reactos/lib/rtl/powerpc/rtlmem.s [iso-8859-1] (original) +++ trunk/reactos/lib/rtl/powerpc/rtlmem.s [iso-8859-1] Sat Sep 5 20:50:51 2015 @@ -9,7 +9,6 @@ .globl RtlFillMemoryUlonglong .globl RtlMoveMemory .globl RtlZeroMemory -.globl RtlPrefetchMemoryNonTemporal RtlCompareMemory: 1:
9 years, 3 months
1
0
0
0
[ion] 69041: [BOOTMGFW]: - Add very early EFI Firmware and x86 Context Management Support.
by ion@svn.reactos.org
Author: ion Date: Sat Sep 5 20:31:14 2015 New Revision: 69041 URL:
http://svn.reactos.org/svn/reactos?rev=69041&view=rev
Log: [BOOTMGFW]: - Add very early EFI Firmware and x86 Context Management Support. Added: trunk/reactos/boot/environ/lib/arch/i386/ (with props) trunk/reactos/boot/environ/lib/arch/i386/arch.c (with props) trunk/reactos/boot/environ/lib/firmware/efi/ (with props) trunk/reactos/boot/environ/lib/firmware/efi/firmware.c (with props) Modified: trunk/reactos/boot/environ/CMakeLists.txt trunk/reactos/boot/environ/app/bootmgr/efiemu.c trunk/reactos/boot/environ/include/bl.h trunk/reactos/boot/environ/lib/bootlib.c Modified: trunk/reactos/boot/environ/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/CMakeLists.tx…
============================================================================== --- trunk/reactos/boot/environ/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/boot/environ/CMakeLists.txt [iso-8859-1] Sat Sep 5 20:31:14 2015 @@ -11,14 +11,15 @@ app/bootmgr/bootmgr.h lib/bootlib.c lib/misc/bcd.c - lib/misc/util.c) + lib/misc/util.c + lib/firmware/efi/firmware.c) if(ARCH STREQUAL "i386") list(APPEND BOOTLIB_ASM_SOURCE #lib/arch/i386/foo.asm ) list(APPEND BOOTLIB_SOURCE - #lib/arch/i386/foo.c + lib/arch/i386/arch.c ) elseif(ARCH STREQUAL "amd64") list(APPEND BOOTLIB_ASM_SOURCE Modified: trunk/reactos/boot/environ/app/bootmgr/efiemu.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/app/bootmgr/e…
============================================================================== --- trunk/reactos/boot/environ/app/bootmgr/efiemu.c [iso-8859-1] (original) +++ trunk/reactos/boot/environ/app/bootmgr/efiemu.c [iso-8859-1] Sat Sep 5 20:31:14 2015 @@ -677,7 +677,7 @@ /* Zero out the header, and write down the signature */ RtlZeroMemory(Entry, sizeof(BL_APPLICATION_ENTRY)); - RtlCopyMemory(Entry->Signature, "BTAPENT", 7); + RtlCopyMemory(Entry->Signature, BL_APP_ENTRY_SIGNATURE, 7); /* Check if a BCD object was passed on the command-line */ ObjectString = wcsstr(CommandLine, L"BCDOBJECT="); Modified: trunk/reactos/boot/environ/include/bl.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/include/bl.h?…
============================================================================== --- trunk/reactos/boot/environ/include/bl.h [iso-8859-1] (original) +++ trunk/reactos/boot/environ/include/bl.h [iso-8859-1] Sat Sep 5 20:31:14 2015 @@ -19,6 +19,9 @@ /* NT Base Headers */ #include <ntifs.h> +/* NDK Headers */ +#include <ntndk.h> + /* UEFI Headers */ #include <Uefi.h> #include <DevicePath.h> @@ -28,6 +31,8 @@ #define BL_APPLICATION_FLAG_CONVERTED_FROM_EFI 0x01 +#define BL_APP_ENTRY_SIGNATURE "BTAPENT" + #define BOOT_APPLICATION_SIGNATURE_1 'TOOB' #define BOOT_APPLICATION_SIGNATURE_2 ' PPA' @@ -41,7 +46,24 @@ #define BL_APPLICATION_ENTRY_FLAG_NO_GUID 0x01 +#define BL_CONTEXT_PAGING_ON 1 +#define BL_CONTEXT_INTERRUPTS_ON 2 + /* ENUMERATIONS **************************************************************/ + +typedef enum _BL_TRANSLATION_TYPE +{ + BlNone, + BlVirtual, + BlPae, + BlMax +} BL_TRANSLATION_TYPE; + +typedef enum _BL_ARCH_MODE +{ + BlProtectedMode, + BlRealMode +} BL_ARCH_MODE; // // Boot Device Types @@ -325,6 +347,13 @@ WCHAR LoadOptions[ANYSIZE_ARRAY]; } BL_WINDOWS_LOAD_OPTIONS, *PBL_WINDOWS_LOAD_OPTIONS; +typedef struct _BL_ARCH_CONTEXT +{ + BL_ARCH_MODE Mode; + BL_TRANSLATION_TYPE TranslationType; + ULONG ContextFlags; +} BL_ARCH_CONTEXT, *PBL_ARCH_CONTEXT; + /* INITIALIZATION ROUTINES ***************************************************/ NTSTATUS @@ -333,6 +362,17 @@ _In_ PBL_LIBRARY_PARAMETERS LibraryParameters ); +NTSTATUS +BlpArchInitialize ( + _In_ ULONG Phase + ); + +NTSTATUS +BlpFwInitialize ( + _In_ ULONG Phase, + _In_ PBL_FIRMWARE_DESCRIPTOR FirmwareParameters + ); + /* UTILITY ROUTINES **********************************************************/ EFI_STATUS @@ -340,6 +380,11 @@ _In_ NTSTATUS Status ); +NTSTATUS +EfiGetNtStatusCode ( + _In_ EFI_STATUS EfiStatus + ); + /* BCD ROUTINES **************************************************************/ ULONG @@ -347,4 +392,16 @@ _In_ PBL_BCD_OPTION BcdOption ); +/* CONTEXT ROUTINES **********************************************************/ + +VOID +BlpArchSwitchContext ( + _In_ BL_ARCH_MODE NewMode + ); + +extern ULONG BlpApplicationFlags; +extern BL_LIBRARY_PARAMETERS BlpLibraryParameters; +extern BL_TRANSLATION_TYPE MmTranslationType; +extern PBL_ARCH_CONTEXT CurrentExecutionContext; + #endif Propchange: trunk/reactos/boot/environ/lib/arch/i386/ ------------------------------------------------------------------------------ --- bugtraq:logregex (added) +++ bugtraq:logregex Sat Sep 5 20:31:14 2015 @@ -0,0 +1 @@ +((CORE|ROSTESTS|ROSAPPS)-\d+)(,? ?((CORE|ROSTESTS|ROSAPPS)-\d+))*(,? ?(and |or )?((CORE|ROSTESTS|ROSAPPS)-\d+))? Propchange: trunk/reactos/boot/environ/lib/arch/i386/ ------------------------------------------------------------------------------ bugtraq:message = See issue %BUGID% for more details. Propchange: trunk/reactos/boot/environ/lib/arch/i386/ ------------------------------------------------------------------------------ bugtraq:url =
https://jira.reactos.org/browse/%BUGID%
Propchange: trunk/reactos/boot/environ/lib/arch/i386/ ------------------------------------------------------------------------------ tsvn:logminsize = 10 Added: trunk/reactos/boot/environ/lib/arch/i386/arch.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/arch/i386…
============================================================================== --- trunk/reactos/boot/environ/lib/arch/i386/arch.c (added) +++ trunk/reactos/boot/environ/lib/arch/i386/arch.c [iso-8859-1] Sat Sep 5 20:31:14 2015 @@ -0,0 +1,250 @@ +/* + * COPYRIGHT: See COPYING.ARM in the top level directory + * PROJECT: ReactOS UEFI Boot Library + * FILE: boot/environ/lib/arch/i386/arch.c + * PURPOSE: Boot Library Architectural Initialization for i386 + * PROGRAMMER: Alex Ionescu (alex.ionescu(a)reactos.org) + */ + +/* INCLUDES ******************************************************************/ + +#include "bl.h" + +/* DATA VARIABLES ************************************************************/ + +BL_ARCH_CONTEXT FirmwareExecutionContext; +BL_ARCH_CONTEXT ApplicationExecutionContext; +PBL_ARCH_CONTEXT CurrentExecutionContext; + +/* FUNCTIONS *****************************************************************/ + +VOID +//__declspec(naked) fixme: gcc +ArchTrapNoProcess ( + VOID + ) +{ + /* Do nothing, this is an unsupported debugging interrupt */ + // _asm { iret } FIXME: GCC +} + +VOID +ArchSwitchContext ( + _In_ PBL_ARCH_CONTEXT NewContext, + _In_ PBL_ARCH_CONTEXT OldContext + ) +{ + /* Are we switching to real mode? */ + if (NewContext->Mode == BlRealMode) + { + /* Disable paging */ + __writecr0(__readcr0() & ~CR0_PG); + + /* Are we coming from PAE mode? */ + if ((OldContext != NULL) && (OldContext->TranslationType == BlPae)) + { + /* Turn off PAE */ + __writecr4(__readcr4() & ~CR4_PAE); + } + + /* Enable interrupts */ + _enable(); + } + else + { + /* Switching to protected mode -- disable interrupts if needed */ + if (!(NewContext->ContextFlags & BL_CONTEXT_INTERRUPTS_ON)) + { + _disable(); + } + + /* Are we enabling paging for the first time? */ + if (NewContext->ContextFlags & BL_CONTEXT_PAGING_ON) + { + /* In PAE mode? */ + if (NewContext->TranslationType == BlPae) + { + /* Turn on PAE */ + __writecr4(__readcr4() | CR4_PAE); + } + + /* Turn on paging */ + __writecr0(__readcr0() | CR0_PG); + } + } +} + +NTSTATUS +ArchInitializeContext ( + _In_ PBL_ARCH_CONTEXT Context + ) +{ + NTSTATUS Status = STATUS_SUCCESS; + + /* Are we initializing real mode? */ + if (Context->Mode == BlRealMode) + { + /* Disable paging, enable interrupts */ + Context->ContextFlags &= ~BL_CONTEXT_PAGING_ON; + Context->ContextFlags |= BL_CONTEXT_INTERRUPTS_ON; + } + else if (!(BlpApplicationFlags & BL_APPLICATION_FLAG_CONVERTED_FROM_EFI) || + (BlpLibraryParameters.TranslationType != BlNone)) + { + /* Read the current translation type */ + Context->TranslationType = BlpLibraryParameters.TranslationType; + + /* Disable paging (it's already on), enable interrupts */ + Context->ContextFlags &= ~BL_CONTEXT_PAGING_ON; + Context->ContextFlags |= BL_CONTEXT_INTERRUPTS_ON; + + /* Enable FXSR support in the FPU */ + __writecr4(__readcr4() | CR4_FXSR); + } + else + { + /* Invalid context */ + Status = STATUS_NOT_SUPPORTED; + } + + /* Return context status */ + return Status; +} + +NTSTATUS +ArchInitializeContexts ( + VOID + ) +{ + PBL_ARCH_CONTEXT Context = NULL; + NTSTATUS EfiStatus, AppStatus; + + /* No current context */ + CurrentExecutionContext = NULL; + + /* Setup the EFI and Application modes respectively */ + FirmwareExecutionContext.Mode = BlRealMode; + ApplicationExecutionContext.Mode = BlProtectedMode; + + /* Initialize application mode */ + AppStatus = ArchInitializeContext(&ApplicationExecutionContext); + if (NT_SUCCESS(AppStatus)) + { + /* Set it as current if it worked */ + Context = &ApplicationExecutionContext; + CurrentExecutionContext = &ApplicationExecutionContext; + } + + /* Initialize EFI mode */ + EfiStatus = ArchInitializeContext(&FirmwareExecutionContext); + if (NT_SUCCESS(EfiStatus)) + { + /* Set it as current if application context failed */ + if (!NT_SUCCESS(AppStatus)) + { + Context = &FirmwareExecutionContext; + CurrentExecutionContext = &FirmwareExecutionContext; + } + + /* Switch to application mode, or EFI if that one failed */ + ArchSwitchContext(Context, NULL); + EfiStatus = STATUS_SUCCESS; + } + + /* Return initialization state */ + return EfiStatus; +} + +VOID +BlpArchSwitchContext ( + _In_ BL_ARCH_MODE NewMode + ) +{ + PBL_ARCH_CONTEXT Context; + + /* In real mode, use EFI, otherwise, use the application mode */ + Context = &FirmwareExecutionContext; + if (NewMode != BlProtectedMode) Context = &ApplicationExecutionContext; + + /* Are we in a different mode? */ + if (CurrentExecutionContext->Mode != NewMode) + { + /* Switch to the new one */ + ArchSwitchContext(Context, CurrentExecutionContext); + CurrentExecutionContext = Context; + } +} + +/*++ +* @name BlpArchInitialize +* +* The BlpArchInitialize function initializes the Boot Library. +* +* @param Phase +* Pointer to the Boot Application Parameter Block. +* +* @return NT_SUCCESS if the boot library was loaded correctly, relevant error +* otherwise. +* +*--*/ +NTSTATUS +BlpArchInitialize ( + _In_ ULONG Phase + ) +{ + KDESCRIPTOR Idtr; + USHORT CodeSegment; + NTSTATUS Status; + PKIDTENTRY IdtBase; + + /* Assume success */ + Status = STATUS_SUCCESS; + + /* Is this phase 1? */ + if (Phase != 0) + { + /* Get the IDT */ + __sidt(&Idtr); + IdtBase = (PKIDTENTRY)Idtr.Base; + + /* Get the Code Segment */ + // _asm { mov CodeSegment, cs } FIXME: GCC + CodeSegment = 8; // fix fix + + /* Set up INT 3, ASSERT, and SECURITY_ASSERT to be no-op (for Rtl) */ + IdtBase[3].Offset = (USHORT)(ULONG_PTR)ArchTrapNoProcess; + IdtBase[3].Selector = CodeSegment; + IdtBase[3].Access = 0x8E00u; + IdtBase[3].ExtendedOffset = (ULONG_PTR)ArchTrapNoProcess >> 16; + IdtBase[0x2C].Offset = (USHORT)(ULONG_PTR)ArchTrapNoProcess; + IdtBase[0x2C].Selector = CodeSegment; + IdtBase[0x2C].Access = 0x8E00u; + IdtBase[0x2C].ExtendedOffset = (ULONG_PTR)ArchTrapNoProcess >> 16; + IdtBase[0x2D].Offset = (USHORT)(ULONG_PTR)ArchTrapNoProcess; + IdtBase[0x2D].Selector = CodeSegment; + IdtBase[0x2D].Access = 0x8E00u; + IdtBase[0x2D].ExtendedOffset = (ULONG_PTR)ArchTrapNoProcess >> 16; + + /* Write the IDT back */ + Idtr.Base = (ULONG)IdtBase; + __lidt(&Idtr); + + /* Reset FPU state */ + // __asm { fninit } FIXME: GCC + } + else + { + /* Reset TSC if needed */ + if ((__readmsr(0x10) >> 32) & 0xFFC00000) + { + __writemsr(0x10, 0); + } + + /* Initialize all the contexts */ + Status = ArchInitializeContexts(); + } + + /* Return initialization state */ + return Status; +} + Propchange: trunk/reactos/boot/environ/lib/arch/i386/arch.c ------------------------------------------------------------------------------ svn:eol-style = native Modified: trunk/reactos/boot/environ/lib/bootlib.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/bootlib.c…
============================================================================== --- trunk/reactos/boot/environ/lib/bootlib.c [iso-8859-1] (original) +++ trunk/reactos/boot/environ/lib/bootlib.c [iso-8859-1] Sat Sep 5 20:31:14 2015 @@ -1,10 +1,10 @@ /* -* COPYRIGHT: See COPYING.ARM in the top level directory -* PROJECT: ReactOS UEFI Boot Library -* FILE: boot/environ/lib/bootlib.c -* PURPOSE: Boot Library Initialization -* PROGRAMMER: Alex Ionescu (alex.ionescu(a)reactos.org) -*/ + * COPYRIGHT: See COPYING.ARM in the top level directory + * PROJECT: ReactOS UEFI Boot Library + * FILE: boot/environ/lib/bootlib.c + * PURPOSE: Boot Library Initialization + * PROGRAMMER: Alex Ionescu (alex.ionescu(a)reactos.org) + */ /* INCLUDES ******************************************************************/ @@ -13,6 +13,14 @@ /* DATA VARIABLES ************************************************************/ BL_LIBRARY_PARAMETERS BlpLibraryParameters; +PBL_DEVICE_DESCRIPTOR BlpBootDevice; +PWCHAR BlpApplicationBaseDirectory; +PBOOT_APPLICATION_PARAMETER_BLOCK BlpApplicationParameters; +BL_APPLICATION_ENTRY BlpApplicationEntry; +BOOLEAN BlpLibraryParametersInitialized; + +/* temp */ +BL_TRANSLATION_TYPE MmTranslationType; /* FUNCTIONS *****************************************************************/ @@ -37,10 +45,66 @@ _In_ PBL_LIBRARY_PARAMETERS LibraryParameters ) { - DBG_UNREFERENCED_PARAMETER(BootAppParameters); - DBG_UNREFERENCED_PARAMETER(LibraryParameters); + NTSTATUS Status; + //PBL_MEMORY_DATA MemoryData; + PBL_APPLICATION_ENTRY AppEntry; + PBL_FIRMWARE_DESCRIPTOR FirmwareDescriptor; + ULONG_PTR ParamPointer = (ULONG_PTR)BootAppParameters; - return STATUS_NOT_IMPLEMENTED; + /* Validate correct Boot Application data */ + if (!(BootAppParameters) || + (BootAppParameters->Signature[0] != BOOT_APPLICATION_SIGNATURE_1) || + (BootAppParameters->Signature[1] != BOOT_APPLICATION_SIGNATURE_2) || + (BootAppParameters->Size < sizeof(*BootAppParameters))) + { + return STATUS_INVALID_PARAMETER; + } + + /* Get sub-structures */ + //MemoryData = (PBL_MEMORY_DATA)(ParamPointer + BootAppParameters->MemoryDataOffset); + FirmwareDescriptor = (PBL_FIRMWARE_DESCRIPTOR)(ParamPointer + BootAppParameters->FirmwareParametersOffset); + AppEntry = (PBL_APPLICATION_ENTRY)(ParamPointer + BootAppParameters->AppEntryOffset); + BlpBootDevice = (PBL_DEVICE_DESCRIPTOR)(ParamPointer + BootAppParameters->BootDeviceOffset); + BlpApplicationBaseDirectory = LibraryParameters->ApplicationBaseDirectory; + + /* Initialize the firmware table */ + Status = BlpFwInitialize(0, FirmwareDescriptor); + if (!NT_SUCCESS(Status)) + { + goto Quickie; + } + + /* Find boot application entry */ + if (strncmp(AppEntry->Signature, BL_APP_ENTRY_SIGNATURE, 7)) + { + Status = STATUS_INVALID_PARAMETER_9; + } + + /* Read parameters */ + BlpApplicationParameters = BootAppParameters; + BlpLibraryParameters = *LibraryParameters; + + /* Save the application entry */ + if (AppEntry->Flags & 2) + { + AppEntry->Flags = (AppEntry->Flags & ~0x2) | 0x80; + } + BlpApplicationEntry = *AppEntry; + + /* Everything has been captured */ + BlpLibraryParametersInitialized = TRUE; + + /* Initialize the architecture (PM or RM) switching */ + Status = BlpArchInitialize(0); + if (!NT_SUCCESS(Status)) + { + goto Quickie; + } + + Status = STATUS_NOT_IMPLEMENTED; + +Quickie: + return Status; } /*++ Propchange: trunk/reactos/boot/environ/lib/firmware/efi/ ------------------------------------------------------------------------------ --- bugtraq:logregex (added) +++ bugtraq:logregex Sat Sep 5 20:31:14 2015 @@ -0,0 +1 @@ +((CORE|ROSTESTS|ROSAPPS)-\d+)(,? ?((CORE|ROSTESTS|ROSAPPS)-\d+))*(,? ?(and |or )?((CORE|ROSTESTS|ROSAPPS)-\d+))? Propchange: trunk/reactos/boot/environ/lib/firmware/efi/ ------------------------------------------------------------------------------ bugtraq:message = See issue %BUGID% for more details. Propchange: trunk/reactos/boot/environ/lib/firmware/efi/ ------------------------------------------------------------------------------ bugtraq:url =
https://jira.reactos.org/browse/%BUGID%
Propchange: trunk/reactos/boot/environ/lib/firmware/efi/ ------------------------------------------------------------------------------ tsvn:logminsize = 10 Added: trunk/reactos/boot/environ/lib/firmware/efi/firmware.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/firmware/…
============================================================================== --- trunk/reactos/boot/environ/lib/firmware/efi/firmware.c (added) +++ trunk/reactos/boot/environ/lib/firmware/efi/firmware.c [iso-8859-1] Sat Sep 5 20:31:14 2015 @@ -0,0 +1,222 @@ +/* + * COPYRIGHT: See COPYING.ARM in the top level directory + * PROJECT: ReactOS UEFI Boot Library + * FILE: boot/environ/lib/firmware/efi/firmware.c + * PURPOSE: Boot Library Firmware Initialization for EFI + * PROGRAMMER: Alex Ionescu (alex.ionescu(a)reactos.org) + */ + +/* INCLUDES ******************************************************************/ + +#include "bl.h" + +/* DATA VARIABLES ************************************************************/ + +GUID EfiSimpleTextInputExProtocol = EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID; + +PBL_FIRMWARE_DESCRIPTOR EfiFirmwareParameters; +BL_FIRMWARE_DESCRIPTOR EfiFirmwareData; +EFI_HANDLE EfiImageHandle; +EFI_SYSTEM_TABLE* EfiSystemTable; + +EFI_SYSTEM_TABLE *EfiST; +EFI_BOOT_SERVICES *EfiBS; +EFI_RUNTIME_SERVICES *EfiRT; +EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *EfiConOut; +EFI_SIMPLE_TEXT_INPUT_PROTOCOL *EfiConIn; +EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *EfiConInEx; + +/* FUNCTIONS *****************************************************************/ + +NTSTATUS +EfiOpenProtocol ( + _In_ EFI_HANDLE Handle, + _In_ EFI_GUID *Protocol, + _Out_ PVOID* Interface + ) +{ + EFI_STATUS EfiStatus; + NTSTATUS Status; + BL_ARCH_MODE OldMode; + + /* Are we using virtual memory/ */ + if (MmTranslationType != BlNone) + { + /* We need complex tracking to make this work */ + //Status = EfiVmOpenProtocol(Handle, Protocol, Interface); + Status = STATUS_NOT_SUPPORTED; + } + else + { + /* Are we in protected mode? */ + OldMode = CurrentExecutionContext->Mode; + if (OldMode != BlRealMode) + { + /* FIXME: Not yet implemented */ + return STATUS_NOT_IMPLEMENTED; + } + + /* Are we on legacy 1.02? */ + if (EfiST->FirmwareRevision == EFI_1_02_SYSTEM_TABLE_REVISION) + { + /* Make the legacy call */ + EfiStatus = EfiBS->HandleProtocol(Handle, Protocol, Interface); + } + else + { + /* Use the UEFI version */ + EfiStatus = EfiBS->OpenProtocol(Handle, + Protocol, + Interface, + EfiImageHandle, + NULL, + EFI_OPEN_PROTOCOL_GET_PROTOCOL); + + /* Switch back to protected mode if we came from there */ + if (OldMode != BlRealMode) + { + BlpArchSwitchContext(OldMode); + } + } + + /* Convert the error to an NTSTATUS */ + Status = EfiGetNtStatusCode(EfiStatus); + } + + /* Clear the interface on failure, and return the status */ + if (!NT_SUCCESS(Status)) + { + *Interface = NULL; + } + + return Status; +} + +NTSTATUS +EfiConInExSetState ( + _In_ EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *ConInEx, + _In_ EFI_KEY_TOGGLE_STATE* KeyToggleState + ) +{ + BL_ARCH_MODE OldMode; + EFI_STATUS EfiStatus; + + /* Are we in protected mode? */ + OldMode = CurrentExecutionContext->Mode; + if (OldMode != BlRealMode) + { + /* FIXME: Not yet implemented */ + return STATUS_NOT_IMPLEMENTED; + } + + /* Make the EFI call */ + EfiStatus = ConInEx->SetState(ConInEx, KeyToggleState); + + /* Switch back to protected mode if we came from there */ + if (OldMode != BlRealMode) + { + BlpArchSwitchContext(OldMode); + } + + /* Convert the error to an NTSTATUS */ + return EfiGetNtStatusCode(EfiStatus); +} + +NTSTATUS +EfiSetWatchdogTimer ( + VOID + ) +{ + BL_ARCH_MODE OldMode; + EFI_STATUS EfiStatus; + + /* Are we in protected mode? */ + OldMode = CurrentExecutionContext->Mode; + if (OldMode != BlRealMode) + { + /* FIXME: Not yet implemented */ + return STATUS_NOT_IMPLEMENTED; + } + + /* Make the EFI call */ + EfiStatus = EfiBS->SetWatchdogTimer(0, 0, 0, NULL); + + /* Switch back to protected mode if we came from there */ + if (OldMode != BlRealMode) + { + BlpArchSwitchContext(OldMode); + } + + /* Convert the error to an NTSTATUS */ + return EfiGetNtStatusCode(EfiStatus); +} + +NTSTATUS +BlpFwInitialize ( + _In_ ULONG Phase, + _In_ PBL_FIRMWARE_DESCRIPTOR FirmwareData + ) +{ + NTSTATUS Status = STATUS_SUCCESS; + EFI_KEY_TOGGLE_STATE KeyToggleState; + + /* Check if we have vaild firmware data */ + if (!(FirmwareData) || !(FirmwareData->Version)) + { + return STATUS_INVALID_PARAMETER; + } + + /* Check which boot phase we're in */ + if (Phase != 0) + { + /* Memory manager is ready, open the extended input protocol */ + Status = EfiOpenProtocol(EfiST->ConsoleInHandle, + &EfiSimpleTextInputExProtocol, + (PVOID*)&EfiConInEx); + if (NT_SUCCESS(Status)) + { + /* Set the initial key toggle state */ + KeyToggleState = EFI_TOGGLE_STATE_VALID | 40; + EfiConInExSetState(EfiST->ConsoleInHandle, &KeyToggleState); + } + + /* Setup the watchdog timer */ + EfiSetWatchdogTimer(); + } + else + { + /* Make a copy of the parameters */ + EfiFirmwareParameters = &EfiFirmwareData; + + /* Check which version we received */ + if (FirmwareData->Version == 1) + { + /* FIXME: Not supported */ + Status = STATUS_NOT_SUPPORTED; + } + else if (FirmwareData->Version >= 2) + { + /* Version 2 -- save the data */ + EfiFirmwareData = *FirmwareData; + EfiSystemTable = FirmwareData->SystemTable; + EfiImageHandle = FirmwareData->ImageHandle; + + /* Set the EDK-II style variables as well */ + EfiST = EfiSystemTable; + EfiBS = EfiSystemTable->BootServices; + EfiRT = EfiSystemTable->RuntimeServices; + EfiConOut = EfiSystemTable->ConOut; + EfiConIn = EfiSystemTable->ConIn; + EfiConInEx = NULL; + } + else + { + /* Unknown version */ + Status = STATUS_NOT_SUPPORTED; + } + } + + /* Return the initialization state */ + return Status; +} + Propchange: trunk/reactos/boot/environ/lib/firmware/efi/firmware.c ------------------------------------------------------------------------------ svn:eol-style = native
9 years, 3 months
1
0
0
0
← Newer
1
...
35
36
37
38
39
40
41
...
54
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
Results per page:
10
25
50
100
200