2004-03-03 00:56:51 +01:00
|
|
|
// IA-32 (x86) specific code
|
|
|
|
// Copyright (c) 2003 Jan Wassenberg
|
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License as
|
|
|
|
// published by the Free Software Foundation; either version 2 of the
|
|
|
|
// License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful, but
|
|
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// General Public License for more details.
|
|
|
|
//
|
|
|
|
// Contact info:
|
|
|
|
// Jan.Wassenberg@stud.uni-karlsruhe.de
|
|
|
|
// http://www.stud.uni-karlsruhe.de/~urkt/
|
|
|
|
|
2005-01-31 00:07:55 +01:00
|
|
|
#ifndef IA32_H
|
|
|
|
#define IA32_H
|
|
|
|
|
2005-08-09 18:23:19 +02:00
|
|
|
#if !CPU_IA32
|
2005-09-13 01:37:52 +02:00
|
|
|
#error "including ia32.h without CPU_IA32=1"
|
2004-03-03 00:56:51 +01:00
|
|
|
#endif
|
|
|
|
|
2005-01-31 00:07:55 +01:00
|
|
|
#include "lib/types.h"
|
2004-03-03 00:56:51 +01:00
|
|
|
|
2005-09-13 06:00:41 +02:00
|
|
|
// some of these are implemented in asm, so make sure name mangling is
|
|
|
|
// disabled.
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2004-03-03 00:56:51 +01:00
|
|
|
|
|
|
|
extern double _ceil(double);
|
|
|
|
|
2005-01-23 18:45:25 +01:00
|
|
|
extern u64 rdtsc(void);
|
2004-03-03 00:56:51 +01:00
|
|
|
|
|
|
|
|
|
|
|
#ifndef _MCW_PC
|
|
|
|
#define _MCW_PC 0x0300 // Precision Control
|
|
|
|
#endif
|
|
|
|
#ifndef _PC_24
|
|
|
|
#define _PC_24 0x0000 // 24 bits
|
|
|
|
#endif
|
|
|
|
|
2005-01-31 00:07:55 +01:00
|
|
|
#define _control87 ia32_control87
|
2005-09-13 06:00:41 +02:00
|
|
|
extern uint ia32_control87(uint new_cw, uint mask); // asm
|
2004-03-03 00:56:51 +01:00
|
|
|
|
2005-01-23 18:45:25 +01:00
|
|
|
extern void ia32_debug_break(void);
|
2004-07-12 18:40:57 +02:00
|
|
|
|
2005-09-10 16:28:55 +02:00
|
|
|
extern void ia32_memcpy(void* dst, const void* src, size_t nbytes);
|
|
|
|
|
2004-07-12 18:40:57 +02:00
|
|
|
|
|
|
|
|
2004-06-21 16:17:48 +02:00
|
|
|
// CPU caps (128 bits)
|
2005-09-14 03:34:16 +02:00
|
|
|
// do not change the order!
|
2004-06-21 16:17:48 +02:00
|
|
|
enum CpuCap
|
2004-03-03 00:56:51 +01:00
|
|
|
{
|
2005-09-14 03:34:16 +02:00
|
|
|
// standard (ecx) - currently only defined by Intel
|
2005-09-14 18:58:10 +02:00
|
|
|
SSE3 = 0+0, // Streaming SIMD Extensions 3
|
|
|
|
EST = 0+7, // Enhanced Speedstep Technology
|
2004-06-21 16:17:48 +02:00
|
|
|
|
|
|
|
// standard (edx)
|
|
|
|
TSC = 32+4, // TimeStamp Counter
|
|
|
|
CMOV = 32+15, // Conditional MOVe
|
|
|
|
MMX = 32+23, // MultiMedia eXtensions
|
|
|
|
SSE = 32+25, // Streaming SIMD Extensions
|
|
|
|
SSE2 = 32+26, // Streaming SIMD Extensions 2
|
|
|
|
HT = 32+28, // HyperThreading
|
|
|
|
|
|
|
|
// extended (ecx)
|
|
|
|
|
2005-09-14 03:34:16 +02:00
|
|
|
// extended (edx) - currently only defined by AMD
|
|
|
|
AMD_MP = 96+19, // MultiProcessing capable; reserved on AMD64
|
|
|
|
AMD_3DNOW_PRO = 96+30,
|
|
|
|
AMD_3DNOW = 96+31
|
2004-03-03 00:56:51 +01:00
|
|
|
};
|
|
|
|
|
2004-06-21 18:29:47 +02:00
|
|
|
extern bool ia32_cap(CpuCap cap);
|
2004-03-03 00:56:51 +01:00
|
|
|
|
|
|
|
|
2005-01-23 18:45:25 +01:00
|
|
|
extern void ia32_get_cpu_info(void);
|
2004-03-03 00:56:51 +01:00
|
|
|
|
|
|
|
|
2005-09-13 06:00:41 +02:00
|
|
|
// internal use only
|
2005-09-14 03:34:16 +02:00
|
|
|
|
|
|
|
// order in which registers are stored in regs array
|
|
|
|
// (do not change! brand string relies on this ordering)
|
|
|
|
enum IA32Regs
|
|
|
|
{
|
|
|
|
EAX,
|
|
|
|
EBX,
|
|
|
|
ECX,
|
|
|
|
EDX
|
|
|
|
};
|
2005-09-15 02:51:59 +02:00
|
|
|
|
|
|
|
// try to call the specified CPUID sub-function. returns true on success or
|
|
|
|
// false on failure (i.e. CPUID or the specific function not supported).
|
|
|
|
// returns eax, ebx, ecx, edx registers in above order.
|
2005-09-14 03:34:16 +02:00
|
|
|
extern bool ia32_cpuid(u32 func, u32* regs);
|
2005-09-13 06:00:41 +02:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2004-03-03 00:56:51 +01:00
|
|
|
#endif // #ifndef IA32_H
|