From 526855741b6abb970024366316b941fb6b3d2cb6 Mon Sep 17 00:00:00 2001 From: Eric Biederman Date: Mon, 19 May 2003 19:16:21 +0000 Subject: - Cleanups on the romcc side including a pci interface that uses fewer registers, and is easier to hardcode. git-svn-id: svn://svn.coreboot.org/coreboot/trunk@838 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1 --- src/arch/i386/boot/linuxbios_table.c | 2 +- src/arch/i386/include/arch/romcc_io.h | 56 +++++++++++++++++++---------------- src/arch/i386/include/stdint.h | 19 ++++++++++++ src/arch/i386/lib/console.c | 25 ++++++++++++++-- 4 files changed, 73 insertions(+), 29 deletions(-) (limited to 'src/arch') diff --git a/src/arch/i386/boot/linuxbios_table.c b/src/arch/i386/boot/linuxbios_table.c index 1925f2ddb5..3b14488de8 100644 --- a/src/arch/i386/boot/linuxbios_table.c +++ b/src/arch/i386/boot/linuxbios_table.c @@ -115,7 +115,7 @@ void lb_strings(struct lb_header *header) { LB_TAG_LINKER, linuxbios_linker, }, { LB_TAG_ASSEMBLER, linuxbios_assembler, }, }; - int i; + unsigned int i; for(i = 0; i < sizeof(strings)/sizeof(strings[0]); i++) { struct lb_string *rec; size_t len; diff --git a/src/arch/i386/include/arch/romcc_io.h b/src/arch/i386/include/arch/romcc_io.h index 02cc272884..66e6dc07cd 100644 --- a/src/arch/i386/include/arch/romcc_io.h +++ b/src/arch/i386/include/arch/romcc_io.h @@ -35,50 +35,56 @@ static void hlt(void) __builtin_hlt(); } -static unsigned int config_cmd(unsigned char bus, unsigned devfn, unsigned where) +typedef __builtin_msr_t msr_t; + +static msr_t rdmsr(unsigned long index) { - return 0x80000000 | (bus << 16) | (devfn << 8) | (where & ~3); + return __builtin_rdmsr(index); } -static unsigned char pcibios_read_config_byte( - unsigned char bus, unsigned devfn, unsigned where) +static void wrmsr(unsigned long index, msr_t msr) { - outl(config_cmd(bus, devfn, where), 0xCF8); - return inb(0xCFC + (where & 3)); + __builtin_wrmsr(index, msr.lo, msr.hi); } -static unsigned short pcibios_read_config_word( - unsigned char bus, unsigned devfn, unsigned where) +#define PCI_ADDR(BUS, DEV, FN, WHERE) ( \ + (((BUS) & 0xFF) << 16) | \ + (((DEV) & 0x1f) << 11) | \ + (((FN) & 0x07) << 8) | \ + ((WHERE) & 0xFF)) + +static unsigned char pci_read_config8(unsigned addr) { - outl(config_cmd(bus, devfn, where), 0xCF8); - return inw(0xCFC + (where & 2)); + outl(0x80000000 | (addr & ~3), 0xCF8); + return inb(0xCFC + (addr & 3)); } -static unsigned int pcibios_read_config_dword( - unsigned char bus, unsigned devfn, unsigned where) +static unsigned short pci_read_config16(unsigned addr) { - outl(config_cmd(bus, devfn, where), 0xCF8); - return inl(0xCFC); + outl(0x80000000 | (addr & ~3), 0xCF8); + return inw(0xCFC + (addr & 2)); } +static unsigned int pci_read_config32(unsigned addr) +{ + outl(0x80000000 | (addr & ~3), 0xCF8); + return inl(0xCFC); +} -static void pcibios_write_config_byte( - unsigned char bus, unsigned devfn, unsigned where, unsigned char value) +static void pci_write_config8(unsigned addr, unsigned char value) { - outl(config_cmd(bus, devfn, where), 0xCF8); - outb(value, 0xCFC + (where & 3)); + outl(0x80000000 | (addr & ~3), 0xCF8); + outb(value, 0xCFC + (addr & 3)); } -static void pcibios_write_config_word( - unsigned char bus, unsigned devfn, unsigned where, unsigned short value) +static void pci_write_config16(unsigned addr, unsigned short value) { - outl(config_cmd(bus, devfn, where), 0xCF8); - outw(value, 0xCFC + (where & 2)); + outl(0x80000000 | (addr & ~3), 0xCF8); + outw(value, 0xCFC + (addr & 2)); } -static void pcibios_write_config_dword( - unsigned char bus, unsigned devfn, unsigned where, unsigned int value) +static void pci_write_config32(unsigned addr, unsigned int value) { - outl(config_cmd(bus, devfn, where), 0xCF8); + outl(0x80000000 | (addr & ~3), 0xCF8); outl(value, 0xCFC); } diff --git a/src/arch/i386/include/stdint.h b/src/arch/i386/include/stdint.h index 58d7519cde..0fc4346317 100644 --- a/src/arch/i386/include/stdint.h +++ b/src/arch/i386/include/stdint.h @@ -1,6 +1,12 @@ #ifndef I386_STDINT_H #define I386_STDINT_H +#if defined(__GNUC__) +#define __HAVE_LONG_LONG__ 1 +#else +#define __HAVE_LONG_LONG__ 0 +#endif + /* Exact integral types */ typedef unsigned char uint8_t; typedef signed char int8_t; @@ -11,8 +17,10 @@ typedef signed short int16_t; typedef unsigned int uint32_t; typedef signed int int32_t; +#if __HAVE_LONG_LONG__ typedef unsigned long long uint64_t; typedef signed long long int64_t; +#endif /* Small types */ typedef unsigned char uint_least8_t; @@ -24,8 +32,10 @@ typedef signed short int_least16_t; typedef unsigned int uint_least32_t; typedef signed int int_least32_t; +#if __HAVE_LONG_LONG__ typedef unsigned long long uint_least64_t; typedef signed long long int_least64_t; +#endif /* Fast Types */ typedef unsigned char uint_fast8_t; @@ -37,16 +47,25 @@ typedef signed int int_fast16_t; typedef unsigned int uint_fast32_t; typedef signed int int_fast32_t; +#if __HAVE_LONG_LONG__ typedef unsigned long long uint_fast64_t; typedef signed long long int_fast64_t; +#endif /* Types for `void *' pointers. */ typedef int intptr_t; typedef unsigned int uintptr_t; /* Largest integral types */ +#if __HAVE_LONG_LONG__ typedef long long int intmax_t; typedef unsigned long long uintmax_t; +#else +typedef long int intmax_t; +typedef unsigned long int uintmax_t; +#endif + +#undef __HAVE_LONG_LONG__ #endif /* I386_STDINT_H */ diff --git a/src/arch/i386/lib/console.c b/src/arch/i386/lib/console.c index 8c8eccdd2a..83502eafd9 100644 --- a/src/arch/i386/lib/console.c +++ b/src/arch/i386/lib/console.c @@ -22,11 +22,21 @@ static void __console_tx_char(int loglevel, unsigned char byte) } } -static void __console_tx_hex8(int loglevel, unsigned char byte) +static void __console_tx_hex8(int loglevel, unsigned char value) { if (ASM_CONSOLE_LOGLEVEL > loglevel) { - __console_tx_nibble(byte >> 4U); - __console_tx_nibble(byte & 0x0fU); + __console_tx_nibble((value >> 4U) & 0x0fU); + __console_tx_nibble(value & 0x0fU); + } +} + +static void __console_tx_hex16(int loglevel, unsigned short value) +{ + if (ASM_CONSOLE_LOGLEVEL > loglevel) { + __console_tx_nibble((value >> 12U) & 0x0fU); + __console_tx_nibble((value >> 8U) & 0x0fU); + __console_tx_nibble((value >> 4U) & 0x0fU); + __console_tx_nibble(value & 0x0fU); } } @@ -56,46 +66,55 @@ static void __console_tx_string(int loglevel, const char *str) static void print_emerg_char(unsigned char byte) { __console_tx_char(BIOS_EMERG, byte); } static void print_emerg_hex8(unsigned char value){ __console_tx_hex8(BIOS_EMERG, value); } +static void print_emerg_hex16(unsigned short value){ __console_tx_hex16(BIOS_EMERG, value); } static void print_emerg_hex32(unsigned int value) { __console_tx_hex32(BIOS_EMERG, value); } static void print_emerg(const char *str) { __console_tx_string(BIOS_EMERG, str); } static void print_alert_char(unsigned char byte) { __console_tx_char(BIOS_ALERT, byte); } static void print_alert_hex8(unsigned char value) { __console_tx_hex8(BIOS_ALERT, value); } +static void print_alert_hex16(unsigned short value){ __console_tx_hex16(BIOS_ALERT, value); } static void print_alert_hex32(unsigned int value) { __console_tx_hex32(BIOS_ALERT, value); } static void print_alert(const char *str) { __console_tx_string(BIOS_ALERT, str); } static void print_crit_char(unsigned char byte) { __console_tx_char(BIOS_CRIT, byte); } static void print_crit_hex8(unsigned char value) { __console_tx_hex8(BIOS_CRIT, value); } +static void print_crit_hex16(unsigned short value){ __console_tx_hex16(BIOS_CRIT, value); } static void print_crit_hex32(unsigned int value) { __console_tx_hex32(BIOS_CRIT, value); } static void print_crit(const char *str) { __console_tx_string(BIOS_CRIT, str); } static void print_err_char(unsigned char byte) { __console_tx_char(BIOS_ERR, byte); } static void print_err_hex8(unsigned char value) { __console_tx_hex8(BIOS_ERR, value); } +static void print_err_hex16(unsigned short value){ __console_tx_hex16(BIOS_ERR, value); } static void print_err_hex32(unsigned int value) { __console_tx_hex32(BIOS_ERR, value); } static void print_err(const char *str) { __console_tx_string(BIOS_ERR, str); } static void print_warning_char(unsigned char byte) { __console_tx_char(BIOS_WARNING, byte); } static void print_warning_hex8(unsigned char value) { __console_tx_hex8(BIOS_WARNING, value); } +static void print_warning_hex16(unsigned short value){ __console_tx_hex16(BIOS_WARNING, value); } static void print_warning_hex32(unsigned int value) { __console_tx_hex32(BIOS_WARNING, value); } static void print_warning(const char *str) { __console_tx_string(BIOS_WARNING, str); } static void print_notice_char(unsigned char byte) { __console_tx_char(BIOS_NOTICE, byte); } static void print_notice_hex8(unsigned char value) { __console_tx_hex8(BIOS_NOTICE, value); } +static void print_notice_hex16(unsigned short value){ __console_tx_hex16(BIOS_NOTICE, value); } static void print_notice_hex32(unsigned int value) { __console_tx_hex32(BIOS_NOTICE, value); } static void print_notice(const char *str) { __console_tx_string(BIOS_NOTICE, str); } static void print_info_char(unsigned char byte) { __console_tx_char(BIOS_INFO, byte); } static void print_info_hex8(unsigned char value) { __console_tx_hex8(BIOS_INFO, value); } +static void print_info_hex16(unsigned short value){ __console_tx_hex16(BIOS_INFO, value); } static void print_info_hex32(unsigned int value) { __console_tx_hex32(BIOS_INFO, value); } static void print_info(const char *str) { __console_tx_string(BIOS_INFO, str); } static void print_debug_char(unsigned char byte) { __console_tx_char(BIOS_DEBUG, byte); } static void print_debug_hex8(unsigned char value) { __console_tx_hex8(BIOS_DEBUG, value); } +static void print_debug_hex16(unsigned short value){ __console_tx_hex16(BIOS_DEBUG, value); } static void print_debug_hex32(unsigned int value) { __console_tx_hex32(BIOS_DEBUG, value); } static void print_debug(const char *str) { __console_tx_string(BIOS_DEBUG, str); } static void print_spew_char(unsigned char byte) { __console_tx_char(BIOS_SPEW, byte); } static void print_spew_hex8(unsigned char value) { __console_tx_hex8(BIOS_SPEW, value); } +static void print_spew_hex16(unsigned short value){ __console_tx_hex16(BIOS_SPEW, value); } static void print_spew_hex32(unsigned int value) { __console_tx_hex32(BIOS_SPEW, value); } static void print_spew(const char *str) { __console_tx_string(BIOS_SPEW, str); } -- cgit v1.2.3