linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: dave.martin@linaro.org (Dave Martin)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCH 1/2] ARM: Add a generic macro for declaring proc_info structs
Date: Thu,  9 Jun 2011 18:21:51 +0100	[thread overview]
Message-ID: <1307640112-5360-2-git-send-email-dave.martin@linaro.org> (raw)
In-Reply-To: <1307640112-5360-1-git-send-email-dave.martin@linaro.org>

Using a macro allows the structure declarations to be more
readable and shorter, as well as enabling build-time checking
of the structure layout.

Signed-off-by: Dave Martin <dave.martin@linaro.org>
---
 arch/arm/mm/proc-macros.S |  141 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 141 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mm/proc-macros.S b/arch/arm/mm/proc-macros.S
index 34261f9..fe78f3b 100644
--- a/arch/arm/mm/proc-macros.S
+++ b/arch/arm/mm/proc-macros.S
@@ -254,3 +254,144 @@
 	mcr	p15, 0, r0, c7, c10, 1		@ clean L1 D line
 	mcr	p15, 0, ip, c7, c10, 4		@ data write barrier
 	.endm
+
+/*
+ * proc_info structure declaration macro
+ */
+	.macro proc_info name:req
+		.macro _proc_check_align fieldname:req, align:req
+			.if . - \name != (\align )
+				.error "Unexpected or misaligned proc_info field \fieldname"
+			.endif
+		.endm
+
+		.macro cpu_val value:req
+			_proc_check_align cpu_val, 0
+			.long \value
+		.endm
+
+		.macro cpu_mask value:req
+			_proc_check_align cpu_mask, 4
+			.long \value
+		.endm
+
+		/*
+		 * Normal memory MMU flags for CPUs with no SMP support.
+		 * For CPUs with SMP support, use __cpu_mm_mmu_flags_smp and
+		 * __cpu_mm_mmu_flags_up instead.
+		 */
+		.macro __cpu_mm_mmu_flags value:req
+			_proc_check_align __cpu_mm_mmu_flags, PROCINFO_MM_MMUFLAGS
+			.long \value
+		.endm
+
+		.macro __cpu_mm_mmu_flags_smp value:req
+			_proc_check_align __cpu_mm_mmu_flags_smp, PROCINFO_MM_MMUFLAGS
+ ALT_SMP(		.long \value	)
+		.endm
+
+		/*
+		 * __cpu_mm_mmu_flags_up must follow __cpu_mm_mmu_flags_smp,
+		 * so the assembly-time offset is actually PROCINFO_IO_MMUFLAGS.
+		 * This macro generates fixups, rather than direct output.
+		 */
+		.macro __cpu_mm_mmu_flags_up value:req
+			_proc_check_align __cpu_mm_mmu_flags_up, PROCINFO_IO_MMUFLAGS
+ ALT_UP(		.long \value	)
+		.endm
+
+		.macro __cpu_io_mmu_flags value:req
+			_proc_check_align __cpu_io_mmu_flags, PROCINFO_IO_MMUFLAGS
+			.long \value
+		.endm
+
+		.macro __cpu_flush insn:vararg
+			_proc_check_align __cpu_flush, PROCINFO_INITFUNC
+			\insn
+		.endm
+
+		.macro arch_name string:req
+			_proc_check_align arch_name, 0x14
+			.pushsection .rodata.str, "aMS", 1
+\name\()_arch_name:		.asciz "\string"
+				.size \name\()_arch_name, . - \name\()_arch_name
+				.type \name\()_arch_name, #object
+			.popsection
+			.long \name\()_arch_name
+		.endm
+
+		.macro elf_name string:req
+			_proc_check_align elf_name, 0x18
+			.pushsection .rodata.str, "aMS", 1
+\name\()_elf_name:		.asciz "\string"
+				.size \name\()_elf_name, . - \name\()_elf_name
+				.type \name\()_elf_name, #object
+			.popsection
+			.long \name\()_elf_name
+		.endm
+
+		.macro elf_hwcap value:req
+			_proc_check_align elf_hwcap, 0x1c
+			.long \value
+		.endm
+
+		.macro cpu_name string:req
+			_proc_check_align cpu_name, 0x20
+			.pushsection .rodata.str, "aMS", 1
+\name\()_cpu_name:	.asciz "\string"
+				.size \name\()_cpu_name, . - \name\()_cpu_name
+				.type \name\()_cpu_name, #object
+			.popsection
+			.long \name\()_cpu_name
+		.endm
+
+		.macro proc label:req
+			_proc_check_align proc, 0x24
+			.long \label
+		.endm
+
+		.macro tlb label:req
+			_proc_check_align tlb, 0x28
+			.long \label
+		.endm
+
+		.macro user label:req
+			_proc_check_align user, 0x2c
+			.long \label
+		.endm
+
+		.macro cache label:req
+			_proc_check_align cache, 0x30
+			.long \label
+		.endm
+
+		.macro end_proc_info
+			.if . - \name != PROC_INFO_SZ
+				.error "incorrect number of fields in proc_info"
+			.endif
+			.size \name , . - \name
+			.type \name , #object
+			.popsection
+			.purgem end_proc_info
+			.purgem _proc_check_align
+			.purgem cpu_val
+			.purgem cpu_mask
+			.purgem __cpu_mm_mmu_flags
+			.purgem __cpu_mm_mmu_flags_smp
+			.purgem __cpu_mm_mmu_flags_up
+			.purgem __cpu_io_mmu_flags
+			.purgem __cpu_flush
+			.purgem arch_name
+			.purgem elf_name
+			.purgem elf_hwcap
+			.purgem cpu_name
+			.purgem proc
+			.purgem tlb
+			.purgem user
+			.purgem cache
+		.endm
+
+		.pushsection .proc.info.init, #alloc, #execinstr
+		.align 2
+\name :
+	.endm
-- 
1.7.4.1

  reply	other threads:[~2011-06-09 17:21 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-09 17:21 [RFC PATCH 0/2] ARM: Add a generic macro for declaring proc_info structs Dave Martin
2011-06-09 17:21 ` Dave Martin [this message]
2011-06-09 17:21 ` [RFC PATCH 2/2] ARM: proc-v7: Use the new proc_info declaration macro Dave Martin
2011-06-09 17:38 ` [RFC PATCH 0/2] ARM: Add a generic macro for declaring proc_info structs Russell King - ARM Linux
2011-06-10  8:57   ` Dave Martin
2011-06-12  8:22     ` Russell King - ARM Linux
2011-06-12 15:14       ` Russell King - ARM Linux
2011-06-13 13:10         ` Dave Martin
2011-06-13 13:12           ` Russell King - ARM Linux
2011-06-13 13:48             ` Dave Martin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1307640112-5360-2-git-send-email-dave.martin@linaro.org \
    --to=dave.martin@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).