Skip to contentSkip to conversation

x86: io-apic - define names for redirection table entry fields

PATCH Applied Cyrill Gorcunov 2 participants 4 messages Jun 7, 2008 – Jun 10, 2008 1 message not in the archive x86

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/2 x86: io-apic - define names for redirection table entry fields

Each I/O APIC redirection table entry has a number of fields. Define names for them to eliminate reference by hard coded numbers.

---

include/asm-x86/io_apic.h +9 -0
Index: linux-2.6.git/include/asm-x86/io_apic.h
====================================================================
@@ -11,6 +11,15 @@
  * Copyright (C) 1997, 1998, 1999, 2000 Ingo Molnar
  */
 
+/* I/O Unit Redirection Table */
+#define IO_APIC_REDIR_VECTOR_MASK	0x000FF
+#define IO_APIC_REDIR_DEST_LOGICAL	0x00800
+#define IO_APIC_REDIR_DEST_PHYSICAL	0x00000
+#define IO_APIC_REDIR_SEND_PENDING	(1 << 12)
+#define IO_APIC_REDIR_REMOTE_IRR	(1 << 14)
+#define IO_APIC_REDIR_LEVEL_TRIGGER	(1 << 15)
+#define IO_APIC_REDIR_MASKED		(1 << 16)
+
 /*
  * The structure of the IO-APIC:
  */
Applied
#2 lore raw
Quoted 2 lines · Cyrill Gorcunov

Each I/O APIC redirection table entry has a number of fields. Define names for them to eliminate reference by hard coded numbers.

applied to tip/x86/apic, thanks Cyrill.

Ingo

#3 lore raw

PATCH 2/2 x86: io-apic - use predefined names instead of numeric constants

In reply to a message not in the archive

This patch replaces some hard-coded numbers
with predefined names.

---

The patch was checked to _not_ introduce any finctional change - compiled text sections remains the same.

arch/x86/kernel/io_apic_64.c +7 -6
Index: linux-2.6.git/arch/x86/kernel/io_apic_64.c
====================================================================
@@ -183,7 +183,7 @@ static bool io_apic_level_ack_pending(un
 			break;
 		reg = io_apic_read(entry->apic, 0x10 + pin*2);
 		/* Is the remote IRR bit set? */
-		if ((reg >> 14) & 1) {
+		if (reg & IO_APIC_REDIR_REMOTE_IRR) {
 			spin_unlock_irqrestore(&ioapic_lock, flags);
 			return true;
 		}
@@ -298,7 +298,7 @@ static void __target_IO_APIC_irq(unsigne
 			break;
 		io_apic_write(apic, 0x11 + pin*2, dest);
 		reg = io_apic_read(apic, 0x10 + pin*2);
-		reg &= ~0x000000ff;
+		reg &= ~IO_APIC_REDIR_VECTOR_MASK;
 		reg |= vector;
 		io_apic_modify(apic, reg);
 		if (!entry->next)
@@ -366,10 +366,11 @@ static void add_pin_to_irq(unsigned int 
 	static void name##_IO_APIC_irq (unsigned int irq)		\
 	__DO_ACTION(R, ACTION, FINAL)
 
-DO_ACTION( __mask,             0, |= 0x00010000, io_apic_sync(entry->apic) )
-						/* mask = 1 */
-DO_ACTION( __unmask,           0, &= 0xfffeffff, )
-						/* mask = 0 */
+/* mask = 1 */
+DO_ACTION(__mask,	0, |= IO_APIC_REDIR_MASKED, io_apic_sync(entry->apic))
+
+/* mask = 0 */
+DO_ACTION(__unmask,	0, &= ~IO_APIC_REDIR_MASKED, )
 
 static void mask_IO_APIC_irq (unsigned int irq)
 {
arch/x86/kernel/io_apic_32.c +6 -4
Index: linux-2.6.git/arch/x86/kernel/io_apic_32.c
====================================================================
@@ -261,25 +261,27 @@ static void __modify_IO_APIC_irq (unsign
 /* mask = 1 */
 static void __mask_IO_APIC_irq (unsigned int irq)
 {
-	__modify_IO_APIC_irq(irq, 0x00010000, 0);
+	__modify_IO_APIC_irq(irq, IO_APIC_REDIR_MASKED, 0);
 }
 
 /* mask = 0 */
 static void __unmask_IO_APIC_irq (unsigned int irq)
 {
-	__modify_IO_APIC_irq(irq, 0, 0x00010000);
+	__modify_IO_APIC_irq(irq, 0, IO_APIC_REDIR_MASKED);
 }
 
 /* mask = 1, trigger = 0 */
 static void __mask_and_edge_IO_APIC_irq (unsigned int irq)
 {
-	__modify_IO_APIC_irq(irq, 0x00010000, 0x00008000);
+	__modify_IO_APIC_irq(irq, IO_APIC_REDIR_MASKED,
+				IO_APIC_REDIR_LEVEL_TRIGGER);
 }
 
 /* mask = 0, trigger = 1 */
 static void __unmask_and_level_IO_APIC_irq (unsigned int irq)
 {
-	__modify_IO_APIC_irq(irq, 0x00008000, 0x00010000);
+	__modify_IO_APIC_irq(irq, IO_APIC_REDIR_LEVEL_TRIGGER,
+				IO_APIC_REDIR_MASKED);
 }
 
 static void mask_IO_APIC_irq (unsigned int irq)
Applied
#4 lore raw

Re: [patch 2/2] x86: io-apic - use predefined names instead of numeric constants

Quoted 1 line · Cyrill Gorcunov

This patch replaces some hard-coded numbers with predefined names.

applied to tip/x86/apic, thanks.

Ingo