- Replaced all single pushf/popf inline assembler instructions with a macro

which doesn't change the stack layout.

svn path=/trunk/; revision=10236
This commit is contained in:
Hartmut Birr
2004-07-20 21:25:36 +00:00
parent 54ed416bfe
commit f8db6a5d2a
11 changed files with 108 additions and 222 deletions
+7 -24
View File
@@ -11,6 +11,7 @@
/* INCLUDES *****************************************************************/
#include <ddk/ntddk.h>
#include <hal.h>
#define NDEBUG
#include <internal/debug.h>
@@ -38,18 +39,12 @@ HalMakeBeep (
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 @@ HalMakeBeep (
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 @@ HalMakeBeep (
}
/* 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;
}
+7 -13
View File
@@ -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,18 +681,12 @@ HalDisplayString(IN PCH String)
pch = String;
pushfl(Flags);
#if defined(__GNUC__)
__asm__ ("cli\n\t");
#elif defined(_MSC_VER)
__asm cli
#else
#error Unknown compiler for inline assembler
#endif
KiAcquireSpinLock(&Lock);
Ki386SaveFlags(Flags);
Ki386DisableInterrupts();
#if 0
if (HalOwnsDisplay == FALSE)
{
@@ -753,8 +747,8 @@ HalDisplayString(IN PCH String)
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
+19
View File
@@ -76,5 +76,24 @@ HalReleaseDisplayOwnership();
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 */
-11
View File
@@ -423,17 +423,6 @@ typedef enum {
} 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 */
+9 -25
View File
@@ -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 @@ VOID HalpInitPICs(VOID)
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 @@ VOID HalpEndSystemInterrupt(KIRQL Irql)
* FUNCTION: Enable all irqs with higher priority.
*/
{
ULONG flags;
const USHORT mask[] =
{
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
@@ -126,26 +121,15 @@ VOID HalpEndSystemInterrupt(KIRQL Irql)
};
/* 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
+3 -14
View File
@@ -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 @@ HalProcessorIdle (VOID)
{
#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
+13 -36
View File
@@ -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 @@ static VOID IOAPICSetup(
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 @@ static VOID APICDumpBit(ULONG base)
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 @@ VOID APICSendIPI(
{
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 @@ VOID APICSendIPI(
/* Now, fire off the IPI */
APICWrite(APIC_ICR0, tmp);
popfl(flags);
Ki386RestoreFlags(flags);
}
@@ -1395,13 +1390,7 @@ VOID MpsTimerHandler(
* 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 @@ VOID MpsTimerHandler(
/*
* 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 @@ HalInitializeProcessor (
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 @@ HaliScanForMPConfigTable(
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 @@ HalpInitMPS(
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;
}
+5 -12
View File
@@ -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 @@ VOID HalpEndSystemInterrupt (KIRQL Irql)
* 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);
}
+4 -17
View File
@@ -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 @@ HalReboot (VOID)
((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 @@ HalReboot (VOID)
/* 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
}
+31 -37
View File
@@ -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 @@ HalpQueryCMOS(UCHAR Reg)
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 @@ HalpSetCMOS(UCHAR Reg,
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 @@ HalpQueryECMOS(USHORT Reg)
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 @@ HalpSetECMOS(USHORT Reg,
{
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);
}
+10 -33
View File
@@ -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 @@ VOID STDCALL KeStallExecutionProcessor(ULONG Microseconds)
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 @@ VOID STDCALL
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);
}