Alex Ionescu <ionucu@videotron.ca>
Pass an ACPI flag from FreeLdr to the kernel and replace the usage of ACPI compile time option with it.
Modified: trunk/reactos/boot/freeldr/freeldr/arch/i386/hwacpi.c
Modified: trunk/reactos/boot/freeldr/freeldr/include/multiboot.h
Modified: trunk/reactos/boot/freeldr/freeldr/reactos/reactos.c
Modified: trunk/reactos/config
Modified: trunk/reactos/include/ntos/types.h
Modified: trunk/reactos/ntoskrnl/include/internal/po.h
Modified: trunk/reactos/ntoskrnl/io/device.c
Modified: trunk/reactos/ntoskrnl/ke/main.c
Modified: trunk/reactos/ntoskrnl/po/power.c
Modified: trunk/reactos/tools/config.mk

Modified: trunk/reactos/boot/freeldr/freeldr/arch/i386/hwacpi.c
--- trunk/reactos/boot/freeldr/freeldr/arch/i386/hwacpi.c	2005-03-12 00:23:38 UTC (rev 13944)
+++ trunk/reactos/boot/freeldr/freeldr/arch/i386/hwacpi.c	2005-03-12 00:49:18 UTC (rev 13945)
@@ -28,6 +28,7 @@
 #include "../../reactos/registry.h"
 #include "hardware.h"
 
+BOOLEAN AcpiPresent = FALSE;
 
 static BOOL
 FindAcpiBios(VOID)
@@ -63,6 +64,7 @@
 
   if (FindAcpiBios())
     {
+      AcpiPresent = TRUE;
       /* Create new bus key */
       sprintf(Buffer,
 	      "MultifunctionAdapter\\%u", *BusNumber);

Modified: trunk/reactos/boot/freeldr/freeldr/include/multiboot.h
--- trunk/reactos/boot/freeldr/freeldr/include/multiboot.h	2005-03-12 00:23:38 UTC (rev 13944)
+++ trunk/reactos/boot/freeldr/freeldr/include/multiboot.h	2005-03-12 00:49:18 UTC (rev 13945)
@@ -52,6 +52,7 @@
 #define MB_INFO_FLAG_BOOT_LOADER_NAME	0x00000200
 #define MB_INFO_FLAG_APM_TABLE			0x00000400
 #define MB_INFO_FLAG_GRAPHICS_TABLE		0x00000800
+#define MB_INFO_FLAG_ACPI_TABLE         0x00001000
 
 #ifndef ASM
 /* Do not include here in boot.S. */

Modified: trunk/reactos/boot/freeldr/freeldr/reactos/reactos.c
--- trunk/reactos/boot/freeldr/freeldr/reactos/reactos.c	2005-03-12 00:23:38 UTC (rev 13944)
+++ trunk/reactos/boot/freeldr/freeldr/reactos/reactos.c	2005-03-12 00:49:18 UTC (rev 13945)
@@ -580,6 +580,7 @@
  
     extern ULONG PageDirectoryStart;
     extern ULONG PageDirectoryEnd;
+    extern BOOLEAN AcpiPresent;
 
 	//
 	// Open the operating system section
@@ -596,8 +597,9 @@
 	 * Setup multiboot information structure
 	 */
 	LoaderBlock.Flags = MB_INFO_FLAG_MEM_SIZE | MB_INFO_FLAG_BOOT_DEVICE | MB_INFO_FLAG_COMMAND_LINE | MB_INFO_FLAG_MODULES;
-    LoaderBlock.PageDirectoryStart = (ULONG)&PageDirectoryStart;
-    LoaderBlock.PageDirectoryEnd = (ULONG)&PageDirectoryEnd;
+	if (AcpiPresent) LoaderBlock.Flags |= MB_INFO_FLAG_ACPI_TABLE;
+	LoaderBlock.PageDirectoryStart = (ULONG)&PageDirectoryStart;
+	LoaderBlock.PageDirectoryEnd = (ULONG)&PageDirectoryEnd;
 	LoaderBlock.BootDevice = 0xffffffff;
 	LoaderBlock.CommandLine = (unsigned long)multiboot_kernel_cmdline;
 	LoaderBlock.ModsCount = 0;

Modified: trunk/reactos/config
--- trunk/reactos/config	2005-03-12 00:23:38 UTC (rev 13944)
+++ trunk/reactos/config	2005-03-12 00:49:18 UTC (rev 13945)
@@ -38,11 +38,6 @@
 CONFIG_SMP := 0
 
 #
-# Whether to compile for ACPI compliant systems
-#
-ACPI := 0
-
-#
 # whether to use a 3GB User, 1GB Kernel memory map
 #
 3GB := 0

Modified: trunk/reactos/include/ntos/types.h
--- trunk/reactos/include/ntos/types.h	2005-03-12 00:23:38 UTC (rev 13944)
+++ trunk/reactos/include/ntos/types.h	2005-03-12 00:49:18 UTC (rev 13945)
@@ -492,6 +492,7 @@
 #define MB_FLAGS_BOOT_LOADER_NAME (0x200)
 #define MB_FLAGS_APM_TABLE        (0x400)
 #define MB_FLAGS_GRAPHICS_TABLE   (0x800)
+#define MB_FLAGS_ACPI_TABLE       (0x1000)
 
 typedef struct _LOADER_MODULE
 {

Modified: trunk/reactos/ntoskrnl/include/internal/po.h
--- trunk/reactos/ntoskrnl/include/internal/po.h	2005-03-12 00:23:38 UTC (rev 13944)
+++ trunk/reactos/ntoskrnl/include/internal/po.h	2005-03-12 00:49:18 UTC (rev 13945)
@@ -18,7 +18,7 @@
 extern PDEVICE_NODE PopSystemPowerDeviceNode;
 
 VOID
-PoInit(VOID);
+PoInit(PLOADER_PARAMETER_BLOCK LoaderBlock, BOOLEAN ForceAcpiDisable);
 
 NTSTATUS
 PopSetSystemPowerState(

Modified: trunk/reactos/ntoskrnl/io/device.c
--- trunk/reactos/ntoskrnl/io/device.c	2005-03-12 00:23:38 UTC (rev 13944)
+++ trunk/reactos/ntoskrnl/io/device.c	2005-03-12 00:49:18 UTC (rev 13945)
@@ -82,7 +82,6 @@
           return Status;
       }
 
-#ifdef ACPI
       if (Fdo->DeviceType == FILE_DEVICE_ACPI)
       {
          static BOOLEAN SystemPowerDeviceNodeCreated = FALSE;
@@ -94,7 +93,6 @@
             SystemPowerDeviceNodeCreated = TRUE;
          }
       }
-#endif /* ACPI */
 
       if (Fdo->DeviceType == FILE_DEVICE_BUS_EXTENDER ||
           Fdo->DeviceType == FILE_DEVICE_ACPI)

Modified: trunk/reactos/ntoskrnl/ke/main.c
--- trunk/reactos/ntoskrnl/ke/main.c	2005-03-12 00:23:38 UTC (rev 13944)
+++ trunk/reactos/ntoskrnl/ke/main.c	2005-03-12 00:49:18 UTC (rev 13945)
@@ -528,7 +528,7 @@
   ExInit3();
   KdInit1();
   IoInit();
-  PoInit();
+  PoInit(&KeLoaderBlock, FALSE);
   CmInitializeRegistry();
   MmInit3();
   CcInit();

Modified: trunk/reactos/ntoskrnl/po/power.c
--- trunk/reactos/ntoskrnl/po/power.c	2005-03-12 00:23:38 UTC (rev 13944)
+++ trunk/reactos/ntoskrnl/po/power.c	2005-03-12 00:49:18 UTC (rev 13945)
@@ -12,8 +12,8 @@
 #define NDEBUG
 #include <internal/debug.h>
 
-
 PDEVICE_NODE PopSystemPowerDeviceNode = NULL;
+BOOLEAN PopAcpiPresent = FALSE;
 
 /*
  * @implemented
@@ -133,10 +133,7 @@
 NTSTATUS
 PopSetSystemPowerState(
   SYSTEM_POWER_STATE PowerState)
-{
-
-#ifdef ACPI
-
+{    
   IO_STATUS_BLOCK IoStatusBlock;
   PDEVICE_OBJECT DeviceObject;
   PIO_STACK_LOCATION IrpSp;
@@ -144,6 +141,8 @@
   NTSTATUS Status;
   KEVENT Event;
   PIRP Irp;
+  
+  if (!PopAcpiPresent) return STATUS_NOT_IMPLEMENTED;
 
   Status = IopGetSystemPowerDeviceObject(&DeviceObject);
   if (!NT_SUCCESS(Status)) {
@@ -190,15 +189,18 @@
   ObDereferenceObject(Fdo);
 
   return Status;
-
-#endif /* ACPI */
-
-  return STATUS_NOT_IMPLEMENTED;
 }
 
-VOID INIT_FUNCTION
-PoInit(VOID)
+VOID 
+INIT_FUNCTION
+PoInit(PLOADER_PARAMETER_BLOCK LoaderBlock, 
+       BOOLEAN ForceAcpiDisable)
 {
+    /* Set the ACPI State to False if it's been forced that way */
+    if (ForceAcpiDisable) PopAcpiPresent = FALSE;
+    
+    /* Otherwise check the LoaderBlock's Flag */
+    PopAcpiPresent = LoaderBlock->Flags & MB_FLAGS_ACPI_TABLE;
 }
 
 /*

Modified: trunk/reactos/tools/config.mk
--- trunk/reactos/tools/config.mk	2005-03-12 00:23:38 UTC (rev 13944)
+++ trunk/reactos/tools/config.mk	2005-03-12 00:49:18 UTC (rev 13945)
@@ -19,10 +19,6 @@
 CONFIG += CONFIG_SMP
 endif
 
-ifeq ($(ACPI), 1)
-CONFIG += ACPI
-endif
-
 $(PATH_TO_TOP)/tools/mkconfig$(EXE_POSTFIX): $(PATH_TO_TOP)/tools/mkconfig.c
 	@$(HOST_CC) -g -o $(PATH_TO_TOP)/tools/mkconfig$(EXE_POSTFIX) $(PATH_TO_TOP)/tools/mkconfig.c