From b3e9b4a534dd83be87d01bba0ce4fdb0bcc82bfd Mon Sep 17 00:00:00 2001 From: Eric Biederman Date: Sat, 12 Jul 2003 01:37:33 +0000 Subject: - Implement division and rdtsc support for romcc git-svn-id: svn://svn.coreboot.org/coreboot/trunk@947 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1 --- src/arch/i386/include/arch/romcc_io.h | 46 +++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'src') 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) | \ -- cgit v1.2.3