[coreboot] [PATCH] Streamline CPU_ADDR_BITS usage

Uwe Hermann uwe at hermann-uwe.de
Tue Oct 5 00:57:49 CEST 2010


On Mon, Oct 04, 2010 at 01:19:07AM +0200, Peter Stuge wrote:
> Stefan Reinauer wrote:
> > > +config CPU_ADDR_BITS_MASK
> > 
> > Such stuff belongs into an include file, not into Kconfig.
> 
> Good point! I agree completely if it works in practise.

Are you guys suggesting something like this?

Index: src/include/cpu/cpu.h
===================================================================
--- src/include/cpu/cpu.h       (Revision 5909)
+++ src/include/cpu/cpu.h       (Arbeitskopie)
@@ -27,4 +27,21 @@
 /** end of compile time generated pci driver array */
 extern struct cpu_driver ecpu_drivers[];

+/*
+ * Map the number of address space bits supported by the CPU to the
+ * mask field value as it needs to be written into the upper 32 bits
+ * of the various MTRRphysMask_MSR MSRs.
+ */
+#if defined(CONFIG_CPU_ADDR_BITS) && (CONFIG_CPU_ADDR_BITS == 32)
+#define CONFIG_CPU_ADDR_BITS_MASK 0x00000000
+#elif defined(CONFIG_CPU_ADDR_BITS) && (CONFIG_CPU_ADDR_BITS == 36)
+#define CONFIG_CPU_ADDR_BITS_MASK 0x0000000f
+#elif defined(CONFIG_CPU_ADDR_BITS) && (CONFIG_CPU_ADDR_BITS == 40)
+#define CONFIG_CPU_ADDR_BITS_MASK 0x000000ff
+#elif defined(CONFIG_CPU_ADDR_BITS) && (CONFIG_CPU_ADDR_BITS == 48)
+#define CONFIG_CPU_ADDR_BITS_MASK 0x0000ffff
+#else
+#error No CPU_ADDR_BITS value was selected or an unknown value was selected
+#endif
+
 #endif /* CPU_CPU_H */

I guess that would work, but I'm not sure if that's really a better place for
the code or whether it looks more elegant than in a Kconfig file:

+config CPU_ADDR_BITS_MASK
+       hex
+       default 0x00000000 if CPU_ADDR_BITS_32
+       default 0x0000000f if CPU_ADDR_BITS_36
+       default 0x000000ff if CPU_ADDR_BITS_40
+       default 0x0000ffff if CPU_ADDR_BITS_48
+       help
+         Map the number of address space bits supported by the CPU to the
+         mask field value as it needs to be written into the upper 32 bits
+         of the various MTRRphysMask_MSR MSRs.

Also, if the variable is defined in a header file it should probably not have
the CONFIG_ prefix in the name right? I.e. CPU_ADDR_BITS_MASK, not
CONFIG_CPU_ADDR_BITS_MASK. Which IMHO is also a bit odd, as it _is_ indeed a
value derived from a (not user-visible) kconfig option.


Uwe.
-- 
http://hermann-uwe.de     | http://sigrok.org
http://randomprojects.org | http://unmaintained-free-software.org




More information about the coreboot mailing list