diff options
author | H. Peter Anvin <hpa@zytor.com> | 2009-05-24 19:01:02 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2009-05-24 19:01:02 -0700 |
commit | 04e7c2784dd3fd45090d1ddb31905dd7a9b921a3 (patch) | |
tree | fbe5e2df0e93dddcb4b34d44755d433d84663f38 /com32/include/sys | |
parent | 24ffb34fcff5b50b56d987e18dcf519e278c771e (diff) | |
download | syslinux-04e7c2784dd3fd45090d1ddb31905dd7a9b921a3.tar.gz |
com32: make com32 modules self-relocating (COM32R)
Introduce a new "COM32R" format, which is exactly like COM32 except
that they contain position-independent code. Therefore, the core can
load them at any sufficiently aligned address; by protocol select 4K
as the alignment.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'com32/include/sys')
-rw-r--r-- | com32/include/sys/cpu.h | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/com32/include/sys/cpu.h b/com32/include/sys/cpu.h index fcae2da1..b0a76036 100644 --- a/com32/include/sys/cpu.h +++ b/com32/include/sys/cpu.h @@ -23,41 +23,55 @@ static inline void cpuid_count(uint32_t op, uint32_t cnt, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx) { - asm("cpuid" - : "=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=d" (*edx) + asm("pushl %%ebx ; cpuid ; movl %%ebx,%0 ; popl %%ebx" + : "=a" (*eax), "=SD" (*ebx), "=c" (*ecx), "=d" (*edx) : "a" (op), "c" (cnt)); } + static inline void cpuid(uint32_t op, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx) { - cpuid_count(op, 0, eax, ebx, ecx, edx); + asm("pushl %%ebx ; cpuid ; movl %%ebx,%0 ; popl %%ebx" + : "=a" (*eax), "=SD" (*ebx), "=c" (*ecx), "=d" (*edx) + : "a" (op)); } + static inline __constfunc uint32_t cpuid_eax(uint32_t level) { uint32_t v; - asm("cpuid" : "=a" (v) : "a" (level) : "ebx", "ecx", "edx"); + asm("pushl %%ebx ; cpuid ; popl %%ebx" + : "=a" (v) + : "a" (level) + : "ecx", "edx"); return v; } static inline __constfunc uint32_t cpuid_ebx(uint32_t level) { uint32_t v; - asm("cpuid" : "=b" (v), "+a" (level) : : "ecx", "edx"); + asm("pushl %%ebx ; cpuid ; movl %%ebx,%0 ; popl %%ebx" + : "=a" (v) + : "a" (level) + : "ecx", "edx"); return v; } static inline __constfunc uint32_t cpuid_ecx(uint32_t level) { uint32_t v; - asm("cpuid" : "=c" (v), "+a" (level) : : "ebx", "edx"); + asm("pushl %%ebx ; cpuid ; popl %%ebx" + : "=c" (v), "+a" (level) + : : "edx"); return v; } static inline __constfunc uint32_t cpuid_edx(uint32_t level) { uint32_t v; - asm("cpuid" : "=d" (v), "+a" (level) : : "ebx", "ecx"); + asm("pushl %%ebx ; cpuid ; popl %%ebx" + : "=d" (v), "+a" (level) + : : "ecx"); return v; } |