diff options
author | Eric Biederman <ebiederm@xmission.com> | 2003-07-12 01:37:33 +0000 |
---|---|---|
committer | Eric Biederman <ebiederm@xmission.com> | 2003-07-12 01:37:33 +0000 |
commit | b3e9b4a534dd83be87d01bba0ce4fdb0bcc82bfd (patch) | |
tree | 41fac586634cd663c79acd8b6ebf7f497503ad8f /src | |
parent | 91b5ed107369bb0f65028ccc973183bf0dcb8ae7 (diff) |
- Implement division and rdtsc support for romcc
git-svn-id: svn://svn.coreboot.org/coreboot/trunk@947 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'src')
-rw-r--r-- | src/arch/i386/include/arch/romcc_io.h | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/arch/i386/include/arch/romcc_io.h b/src/arch/i386/include/arch/romcc_io.h index d67b3b60d6..f460a36f4d 100644 --- a/src/arch/i386/include/arch/romcc_io.h +++ b/src/arch/i386/include/arch/romcc_io.h @@ -35,6 +35,33 @@ static void hlt(void) __builtin_hlt(); } +typedef __builtin_div_t div_t; +typedef __builtin_ldiv_t ldiv_t; +typedef __builtin_udiv_t udiv_t; +typedef __builtin_uldiv_t uldiv_t; + +static div_t div(int numer, int denom) +{ + return __builtin_div(numer, denom); +} + +static ldiv_t ldiv(long numer, long denom) +{ + return __builtin_ldiv(numer, denom); +} + +static udiv_t udiv(unsigned numer, unsigned denom) +{ + return __builtin_udiv(numer, denom); +} + +static uldiv_t uldiv(unsigned long numer, unsigned long denom) +{ + return __builtin_uldiv(numer, denom); +} + + + int log2(int value) { /* __builtin_bsr is a exactly equivalent to the x86 machine @@ -59,6 +86,25 @@ static void wrmsr(unsigned long index, msr_t msr) __builtin_wrmsr(index, msr.lo, msr.hi); } + +struct tsc_struct { + unsigned lo; + unsigned hi; +}; +typedef struct tsc_struct tsc_t; + +static tsc_t rdtsc(void) +{ + tsc_t res; + asm ("rdtsc" + : "=a" (res.lo), "=d"(res.hi) /* outputs */ + : /* inputs */ + : /* Clobbers */ + ); + return res; +} + + #define PCI_ADDR(BUS, DEV, FN, WHERE) ( \ (((BUS) & 0xFF) << 16) | \ (((DEV) & 0x1f) << 11) | \ |