See patch.
Uwe.
Uwe Hermann wrote:
-static inline struct cpuid_result cpuid(int op) +static inline struct cpuid_result cpuid(u32 op) {
- struct cpuid_result result;
- asm volatile(
"cpuid"
: "=a" (result.eax),
"=b" (result.ebx),
"=c" (result.ecx),
"=d" (result.edx)
: "0" (op));
- return result;
- struct cpuid_result r;
- _cpuid(op, &r.eax, &r.ebx, %r.ecx, &r.edx);
- return r;
}
+/**
- Generic CPUID function.
- Clear %ecx since some CPUs (Cyrix MII) do not set or clear %ecx,
- resulting in stale register contents being returned.
- */
+static inline void _cpuid(u32 op, u32 *eax, u32 *ebx, u32 *ecx, u32 *edx) +{
- *eax = op;
- *ecx = 0;
- native_cpuid(eax, ebx, ecx, edx);
+}
Is there any reason not to combine these two functions? Maybe it's just me, but I don't like seeing one function call another, make some menial changes then call a third, all with the exact same variables, and to complete one task. And, uh, does this build okay? I don't see a forward declaration of _cpuid, but it might be in the rest of the file or somewhere else.
-Corey
On Wed, Jun 27, 2007 at 07:06:12AM -0400, Corey Osgood wrote:
Is there any reason not to combine these two functions? Maybe it's just me, but I don't like seeing one function call another, make some menial changes then call a third, all with the exact same variables, and to complete one task.
Good point. The Linux file is a lot more generic (there's also a cpuid_count() function which is a bit different and uses the generic function), but all of this is not needed in LinuxBIOS, I guess.
New patch attached. The code is now even shorter and simpler.
Uwe.
* Uwe Hermann uwe@hermann-uwe.de [070630 17:17]:
Bring the file cpu.h in sync with the current version of the code in the Linux kernel (as far as possible). The code is a lot simpler and shorter now.
Also, add cpu_relax() (which is also part of the Linux file) which could be useful for busy-loops (but is currently not used). Drop the cpu_relax() from spinlock.h as it's not spinlock related in any way.
The code builds, but is otherwise untested.
Signed-off-by: Uwe Hermann uwe@hermann-uwe.de
Can you test with qemu?
Otherwise Acked-by: Stefan Reinauer stepan@coresystems.de
On Sat, Jun 30, 2007 at 05:30:53PM +0200, Stefan Reinauer wrote:
- Uwe Hermann uwe@hermann-uwe.de [070630 17:17]:
Bring the file cpu.h in sync with the current version of the code in the Linux kernel (as far as possible). The code is a lot simpler and shorter now.
Also, add cpu_relax() (which is also part of the Linux file) which could be useful for busy-loops (but is currently not used). Drop the cpu_relax() from spinlock.h as it's not spinlock related in any way.
The code builds, but is otherwise untested.
Signed-off-by: Uwe Hermann uwe@hermann-uwe.de
Can you test with qemu?
Otherwise Acked-by: Stefan Reinauer stepan@coresystems.de
r423.
Tested in QEMU, but that's probably not enough, as we don't use the cpuid() function at the moment, I think.
Uwe.