11 modified files
reactos/hal/halx86/include
diff -u -r1.10 -r1.11
--- hal.h 23 Oct 2003 09:03:51 -0000 1.10
+++ hal.h 20 Jul 2004 21:25:36 -0000 1.11
@@ -76,5 +76,24 @@
BOOLEAN STDCALL
HalQueryDisplayOwnership();
+#if defined(__GNUC__)
+#define Ki386SaveFlags(x) __asm__ __volatile__("pushfl ; popl %0":"=g" (x): /* no input */)
+#define Ki386RestoreFlags(x) __asm__ __volatile__("pushl %0 ; popfl": /* no output */ :"g" (x):"memory")
+#define Ki386DisableInterrupts() __asm__ __volatile__("cli\n\t")
+#define Ki386EnableInterrupts() __asm__ __volatile__("sti\n\t")
+#define Ki386HaltProcessor() __asm__ __volatile__("hlt\n\t")
+#elif defined(_MSC_VER)
+#define Ki386SaveFlags(x) __asm pushfd __asm pop x;
+#define Ki386RestoreFlags(x) __asm push x __asm popfd;
+#define Ki386DisableInterrupts() __asm cli
+#define Ki386EnableInterrupts() __asm sti
+#define Ki386HaltProcessor() __asm hlt
+#else
+#error Unknown compiler for inline assembler
+#endif
+
+
+
+
#endif /* __INTERNAL_HAL_HAL_H */
reactos/hal/halx86/include
diff -u -r1.3 -r1.4
--- mps.h 28 Dec 2003 22:39:06 -0000 1.3
+++ mps.h 20 Jul 2004 21:25:36 -0000 1.4
@@ -423,17 +423,6 @@
} APIC_MODE;
-#if defined(__GNUC__)
-#define pushfl(x) __asm__ __volatile__("pushfl ; popl %0":"=g" (x): /* no input */)
-#define popfl(x) __asm__ __volatile__("pushl %0 ; popfl": /* no output */ :"g" (x):"memory")
-#elif defined(_MSC_VER)
-#define pushfl(x) __asm pushfd __asm pop x;
-#define popfl(x) __asm push x __asm popfd;
-#else
-#error Unknown compiler for inline assembler
-#endif
-
-
#define PIC_IRQS 16
/* Prototypes */
reactos/hal/halx86
diff -u -r1.4 -r1.5
--- beep.c 28 Dec 2003 22:38:09 -0000 1.4
+++ beep.c 20 Jul 2004 21:25:36 -0000 1.5
@@ -11,6 +11,7 @@
/* INCLUDES *****************************************************************/
#include <ddk/ntddk.h>
+#include <hal.h>
#define NDEBUG
#include <internal/debug.h>
@@ -38,18 +39,12 @@
ULONG Frequency
)
{
- UCHAR b;
+ UCHAR b;
+ ULONG flags;
/* save flags and disable interrupts */
-#if defined(__GNUC__)
- __asm__("pushf\n\t" \
- "cli\n\t");
-#elif defined(_MSC_VER)
- __asm pushfd
- __asm cli
-#else
-#error Unknown compiler for inline assembler
-#endif
+ Ki386SaveFlags(flags);
+ Ki386DisableInterrupts();
/* speaker off */
b = READ_PORT_UCHAR((PUCHAR)PORT_B);
@@ -62,13 +57,7 @@
if (Divider > 0x10000)
{
/* restore flags */
-#if defined(__GNUC__)
- __asm__("popf\n\t");
-#elif defined(_MSC_VER)
- __asm popfd
-#else
-#error Unknown compiler for inline assembler
-#endif
+ Ki386RestoreFlags(flags);
return FALSE;
}
@@ -83,13 +72,7 @@
}
/* restore flags */
-#if defined(__GNUC__)
- __asm__("popf\n\t");
-#elif defined(_MSC_VER)
- __asm popfd
-#else
-#error Unknown compiler for inline assembler
-#endif
+ Ki386RestoreFlags(flags);
return TRUE;
}
reactos/hal/halx86
diff -u -r1.14 -r1.15
--- display.c 16 Mar 2004 22:45:55 -0000 1.14
+++ display.c 20 Jul 2004 21:25:36 -0000 1.15
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: display.c,v 1.14 2004/03/16 22:45:55 dwelch Exp $
+/* $Id: display.c,v 1.15 2004/07/20 21:25:36 hbirr Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@@ -122,7 +122,7 @@
*/
#include <ddk/ntddk.h>
-#include <mps.h>
+#include <hal.h>
#define SCREEN_SYNCHRONIZATION
@@ -681,17 +681,11 @@
pch = String;
- pushfl(Flags);
+ KiAcquireSpinLock(&Lock);
-#if defined(__GNUC__)
- __asm__ ("cli\n\t");
-#elif defined(_MSC_VER)
- __asm cli
-#else
-#error Unknown compiler for inline assembler
-#endif
+ Ki386SaveFlags(Flags);
+ Ki386DisableInterrupts();
- KiAcquireSpinLock(&Lock);
#if 0
if (HalOwnsDisplay == FALSE)
@@ -753,8 +747,8 @@
WRITE_PORT_UCHAR((PUCHAR)VGA_CRTC_INDEX, CRTC_CURHI);
WRITE_PORT_UCHAR((PUCHAR)VGA_CRTC_DATA, (UCHAR)((offset >> 8) & 0xff));
#endif
+ Ki386RestoreFlags(Flags);
KiReleaseSpinLock(&Lock);
- popfl(Flags);
}
VOID STDCALL
reactos/hal/halx86
diff -u -r1.14 -r1.15
--- irql.c 28 Dec 2003 22:38:09 -0000 1.14
+++ irql.c 20 Jul 2004 21:25:36 -0000 1.15
@@ -1,4 +1,4 @@
-/* $Id: irql.c,v 1.14 2003/12/28 22:38:09 fireball Exp $
+/* $Id: irql.c,v 1.15 2004/07/20 21:25:36 hbirr Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@@ -10,9 +10,9 @@
/* INCLUDES *****************************************************************/
#include <ddk/ntddk.h>
-#include <internal/ke.h>
#include <internal/ps.h>
#include <ntos/minmax.h>
+#include <hal.h>
#define NDEBUG
#include <internal/debug.h>
@@ -103,13 +103,7 @@
WRITE_PORT_UCHAR((PUCHAR)0xa1, pic_mask.slave);
/* We can now enable interrupts */
-#if defined(__GNUC__)
- __asm__ __volatile__ ("sti\n\t");
-#elif defined(_MSC_VER)
- __asm sti
-#else
-#error Unknown compiler for inline assembler
-#endif
+ Ki386EnableInterrupts();
}
VOID HalpEndSystemInterrupt(KIRQL Irql)
@@ -117,6 +111,7 @@
* FUNCTION: Enable all irqs with higher priority.
*/
{
+ ULONG flags;
const USHORT mask[] =
{
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
@@ -126,26 +121,15 @@
};
/* Interrupts should be disable while enabling irqs of both pics */
-#if defined(__GNUC__)
- __asm__("pushf\n\t");
- __asm__("cli\n\t");
-#elif defined(_MSC_VER)
- __asm pushfd
- __asm cli
-#else
-#error Unknown compiler for inline assembler
-#endif
+ Ki386SaveFlags(flags);
+ Ki386DisableInterrupts();
pic_mask_intr.both &= mask[Irql];
WRITE_PORT_UCHAR((PUCHAR)0x21, (UCHAR)(pic_mask.master|pic_mask_intr.master));
WRITE_PORT_UCHAR((PUCHAR)0xa1, (UCHAR)(pic_mask.slave|pic_mask_intr.slave));
-#if defined(__GNUC__)
- __asm__("popf\n\t");
-#elif defined(_MSC_VER)
- __asm popfd
-#else
-#error Unknown compiler for inline assembler
-#endif
+
+ /* restore flags */
+ Ki386RestoreFlags(flags);
}
VOID STATIC
reactos/hal/halx86
diff -u -r1.4 -r1.5
--- misc.c 28 Dec 2003 22:38:09 -0000 1.4
+++ misc.c 20 Jul 2004 21:25:36 -0000 1.5
@@ -1,4 +1,4 @@
-/* $Id: misc.c,v 1.4 2003/12/28 22:38:09 fireball Exp $
+/* $Id: misc.c,v 1.5 2004/07/20 21:25:36 hbirr Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@@ -39,19 +39,8 @@
{
#if 1
-#if defined(__GNUC__)
-
- __asm__("sti\n\t" \
- "hlt\n\t");
-
-#elif defined(_MSC_VER)
-
- __asm sti
- __asm hlt
-
-#else
-#error Unknown compiler for inline assembler
-#endif
+ Ki386EnableInterrupts();
+ Ki386HaltProcessor();
#else
reactos/hal/halx86
diff -u -r1.9 -r1.10
--- mp.c 28 Dec 2003 22:38:09 -0000 1.9
+++ mp.c 20 Jul 2004 21:25:36 -0000 1.10
@@ -1,4 +1,4 @@
-/* $Id: mp.c,v 1.9 2003/12/28 22:38:09 fireball Exp $
+/* $Id: mp.c,v 1.10 2004/07/20 21:25:36 hbirr Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@@ -724,7 +724,7 @@
VOID IOAPICDump(VOID)
{
ULONG apic, i;
- ULONG reg0, reg1, reg2;
+ ULONG reg0, reg1, reg2=0;
DbgPrint("Number of MP IRQ sources: %d.\n", IRQCount);
for (i = 0; i < IOAPICCount; i++) {
@@ -1046,7 +1046,7 @@
DbgPrint("0123456789abcdef0123456789abcdef\n");
for (i = 0; i < 8; i++) {
- APICRead(base + i*0x10);
+ v = APICRead(base + i*0x10);
for (j = 0; j < 32; j++) {
if (v & (1<<j))
DbgPrint("1");
@@ -1292,14 +1292,9 @@
{
ULONG tmp, i, flags;
- pushfl(flags);
-#if defined(__GNUC__)
- __asm__ ("\n\tcli\n\t");
-#elif defined(_MSC_VER)
- __asm cli
-#else
-#error Unknown compiler for inline assembler
-#endif
+ /* save flags and disable interrupts */
+ Ki386SaveFlags(flags);
+ Ki386DisableInterrupts();
/* Wait up to 100ms for the APIC to become ready */
for (i = 0; i < 10000; i++) {
@@ -1336,7 +1331,7 @@
/* Now, fire off the IPI */
APICWrite(APIC_ICR0, tmp);
- popfl(flags);
+ Ki386RestoreFlags(flags);
}
@@ -1395,13 +1390,7 @@
* Enable interrupts
* NOTE: Only higher priority interrupts will get through
*/
-#if defined(__GNUC__)
- __asm__("sti\n\t");
-#elif defined(_MSC_VER)
- __asm sti
-#else
-#error Unknown compiler for inline assembler
-#endif
+ Ki386EnableInterrupts();
if (KeGetCurrentProcessorNumber() == 0)
{
@@ -1419,13 +1408,7 @@
/*
* Disable interrupts
*/
-#if defined(__GNUC__)
- __asm__("cli\n\t");
-#elif defined(_MSC_VER)
- __asm cli
-#else
-#error Unknown compiler for inline assembler
-#endif
+ Ki386DisableInterrupts();
DbgPrint("MpsTimerHandler() 0 IRQL 0x%.08x\n", OldIrql);
@@ -1633,8 +1616,8 @@
PCOMMON_AREA_INFO Common;
ULONG StartupCount;
- ULONG DeliveryStatus;
- ULONG AcceptStatus;
+ ULONG DeliveryStatus = 0;
+ ULONG AcceptStatus = 0;
ULONG CPU, i, j;
ULONG tmp, maxlvt;
@@ -2279,7 +2262,7 @@
if (mpf->Feature2 & FEATURE2_IMCRP) {
APICMode = amPIC;
- DPRINT("Running in IMCR and PIC compatibility mode.\n")
+ DPRINT("Running in IMCR and PIC compatibility mode.\n");
} else {
APICMode = amVWIRE;
DPRINT("Running in Virtual Wire compatibility mode.\n");
@@ -2415,13 +2398,7 @@
HalpCalibrateStallExecution();
/* We can now enable interrupts */
-#if defined(__GNUC__)
- __asm__ __volatile__ ("sti\n\t");
-#elif defined(_MSC_VER)
- __asm sti
-#else
-#error Unknown compiler for inline assembler
-#endif
+ Ki386EnableInterrupts();
NextCPU = 0;
}
reactos/hal/halx86
diff -u -r1.9 -r1.10
--- mpsirql.c 10 Jul 2004 21:58:35 -0000 1.9
+++ mpsirql.c 20 Jul 2004 21:25:36 -0000 1.10
@@ -15,6 +15,7 @@
#include <internal/ke.h>
#include <internal/ps.h>
#include <ntos/minmax.h>
+#include <hal.h>
#include <mps.h>
#define NDEBUG
@@ -76,20 +77,12 @@
* FUNCTION: Enable all irqs with higher priority.
*/
{
+ ULONG flags;
/* Interrupts should be disabled while enabling irqs */
-#if defined(__GNUC__)
- __asm__("pushf\n\t");
- __asm__("cli\n\t");
+ Ki386SaveFlags(flags);
+ Ki386DisableInterrupts();
APICWrite (APIC_TPR, IRQL2TPR (Irql) & APIC_TPR_PRI);
- __asm__("popf\n\t");
-#elif defined(_MSC_VER)
- __asm pushfd
- __asm cli
- APICWrite (APIC_TPR, IRQL2TPR (Irql) & APIC_TPR_PRI);
- __asm popfd
-#else
-#error Unknown compiler for inline assembler
-#endif
+ Ki386RestoreFlags(flags);
}
reactos/hal/halx86
diff -u -r1.6 -r1.7
--- reboot.c 18 Mar 2004 19:58:35 -0000 1.6
+++ reboot.c 20 Jul 2004 21:25:36 -0000 1.7
@@ -1,4 +1,4 @@
-/* $Id: reboot.c,v 1.6 2004/03/18 19:58:35 dwelch Exp $
+/* $Id: reboot.c,v 1.7 2004/07/20 21:25:36 hbirr Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@@ -25,13 +25,7 @@
((PUCHAR)HalpZeroPageMapping)[0x473] = 0x12;
/* disable interrupts */
-#if defined(__GNUC__)
- __asm__("cli\n");
-#elif defined(_MSC_VER)
- __asm cli
-#else
-#error Unknown compiler for inline assembler
-#endif
+ Ki386DisableInterrupts();
/* disable periodic interrupt (RTC) */
@@ -52,15 +46,8 @@
/* stop the processor */
#if 1
-#if defined(__GNUC__)
- __asm__("hlt\n");
-#elif defined(_MSC_VER)
- __asm hlt
-#else
-#error Unknown compiler for inline assembler
-#endif
-#else
- for(;;);
+ Ki386HaltProcessor();
+ for(;;);
#endif
}
reactos/hal/halx86
diff -u -r1.5 -r1.6
--- time.c 28 Dec 2003 22:38:09 -0000 1.5
+++ time.c 20 Jul 2004 21:25:36 -0000 1.6
@@ -10,7 +10,7 @@
#include <ddk/ntddk.h>
#include <string.h>
-#include <mps.h>
+#include <hal.h>
#include <bus.h>
#define NDEBUG
@@ -46,18 +46,17 @@
ULONG Flags;
Reg |= 0x80;
- pushfl(Flags);
-#if defined(__GNUC__)
- __asm__("cli\n"); // AP unsure as to whether to do this here
-#elif defined(_MSC_VER)
- __asm cli
-#else
-#error Unknown compiler for inline assembler
-#endif
+
+ /* save flags and disable interrupts */
+ Ki386SaveFlags(Flags);
+ Ki386DisableInterrupts();
+
WRITE_PORT_UCHAR((PUCHAR)0x70, Reg);
Val = READ_PORT_UCHAR((PUCHAR)0x71);
WRITE_PORT_UCHAR((PUCHAR)0x70, 0);
- popfl(Flags);
+
+ /* restore flags */
+ Ki386RestoreFlags(Flags);
return(Val);
}
@@ -70,18 +69,17 @@
ULONG Flags;
Reg |= 0x80;
- pushfl(Flags);
-#if defined(__GNUC__)
- __asm__("cli\n"); // AP unsure as to whether to do this here
-#elif defined(_MSC_VER)
- __asm cli
-#else
-#error Unknown compiler for inline assembler
-#endif
+
+ /* save flags and disable interrupts */
+ Ki386SaveFlags(Flags);
+ Ki386DisableInterrupts();
+
WRITE_PORT_UCHAR((PUCHAR)0x70, Reg);
WRITE_PORT_UCHAR((PUCHAR)0x71, Val);
WRITE_PORT_UCHAR((PUCHAR)0x70, 0);
- popfl(Flags);
+
+ /* restore flags */
+ Ki386RestoreFlags(Flags);
}
@@ -91,18 +89,16 @@
UCHAR Val;
ULONG Flags;
- pushfl(Flags);
-#if defined(__GNUC__)
- __asm__("cli\n"); // AP unsure as to whether to do this here
-#elif defined(_MSC_VER)
- __asm cli
-#else
-#error Unknown compiler for inline assembler
-#endif
+ /* save flags and disable interrupts */
+ Ki386SaveFlags(Flags);
+ Ki386DisableInterrupts();
+
WRITE_PORT_UCHAR((PUCHAR)0x74, (UCHAR)(Reg & 0x00FF));
WRITE_PORT_UCHAR((PUCHAR)0x75, (UCHAR)(Reg>>8));
Val = READ_PORT_UCHAR((PUCHAR)0x76);
- popfl(Flags);
+
+ /* restore flags */
+ Ki386RestoreFlags(Flags);
return(Val);
}
@@ -114,18 +110,16 @@
{
ULONG Flags;
- pushfl(Flags);
-#if defined(__GNUC__)
- __asm__("cli\n"); // AP unsure as to whether to do this here
-#elif defined(_MSC_VER)
- __asm cli
-#else
-#error Unknown compiler for inline assembler
-#endif
+ /* save flags and disable interrupts */
+ Ki386SaveFlags(Flags);
+ Ki386DisableInterrupts();
+
WRITE_PORT_UCHAR((PUCHAR)0x74, (UCHAR)(Reg & 0x00FF));
WRITE_PORT_UCHAR((PUCHAR)0x75, (UCHAR)(Reg>>8));
WRITE_PORT_UCHAR((PUCHAR)0x76, Val);
- popfl(Flags);
+
+ /* restore flags */
+ Ki386RestoreFlags(Flags);
}
reactos/hal/halx86
diff -u -r1.4 -r1.5
--- timer.c 10 May 2004 11:13:15 -0000 1.4
+++ timer.c 20 Jul 2004 21:25:36 -0000 1.5
@@ -20,7 +20,7 @@
* MA 02139, USA.
*
*/
-/* $Id: timer.c,v 1.4 2004/05/10 11:13:15 gvg Exp $
+/* $Id: timer.c,v 1.5 2004/07/20 21:25:36 hbirr Exp $
*
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/hal/x86/udelay.c
@@ -33,6 +33,7 @@
/* INCLUDES ***************************************************************/
#include <ddk/ntddk.h>
+#include <hal.h>
#define NDEBUG
#include <internal/debug.h>
@@ -132,30 +133,18 @@
static ULONG Read8254Timer(VOID)
{
ULONG Count;
+ ULONG flags;
/* save flags and disable interrupts */
-#if defined(__GNUC__)
- __asm__("pushf\n\t" \
- "cli\n\t");
-#elif defined(_MSC_VER)
- __asm pushfd
- __asm cli
-#else
-#error Unknown compiler for inline assembler
-#endif
+ Ki386SaveFlags(flags);
+ Ki386DisableInterrupts();
WRITE_PORT_UCHAR((PUCHAR) TMR_CTRL, TMR_SC0 | TMR_LATCH);
Count = READ_PORT_UCHAR((PUCHAR) TMR_CNT0);
Count |= READ_PORT_UCHAR((PUCHAR) TMR_CNT0) << 8;
/* restore flags */
-#if defined(__GNUC__)
- __asm__("popf\n\t");
-#elif defined(_MSC_VER)
- __asm popfd
-#else
-#error Unknown compiler for inline assembler
-#endif
+ Ki386RestoreFlags(flags);
return Count;
}
@@ -274,28 +263,16 @@
HalCalibratePerformanceCounter(ULONG Count)
{
ULONG i;
+ ULONG flags;
/* save flags and disable interrupts */
-#if defined(__GNUC__)
- __asm__("pushf\n\t" \
- "cli\n\t");
-#elif defined(_MSC_VER)
- __asm pushfd
- __asm cli
-#else
-#error Unknown compiler for inline assembler
-#endif
+ Ki386SaveFlags(flags);
+ Ki386DisableInterrupts();
for (i = 0; i < Count; i++);
/* restore flags */
-#if defined(__GNUC__)
- __asm__("popf\n\t");
-#elif defined(_MSC_VER)
- __asm popfd
-#else
-#error Unknown compiler for inline assembler
-#endif
+ Ki386RestoreFlags(flags);
}
CVSspam 0.2.8