From patchwork Mon Oct 4 22:57:49 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Streamline CPU_ADDR_BITS usage Date: Mon, 04 Oct 2010 22:57:49 -0000 From: Uwe Hermann X-Patchwork-Id: 2037 Message-Id: <20101004225748.GI3256@greenwood> To: coreboot@coreboot.org 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? 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. 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 */