From 7e78ce492add2fd4a3411d16591e26934dad76f1 Mon Sep 17 00:00:00 2001 From: "Ronald G. Minnich" Date: Tue, 12 Aug 2008 03:39:39 +0000 Subject: [PATCH] Make some things (die, mem*, resourcemap code, option code) SHARED. The option code is tricky as it is used by standalone code. If you include that file and you are standalone, you now have to define STANDALONE (is there a better way?) Change the cpuid to be a 24-byte string instead of 3 u32s. Make the CPUID usage PIC-safe by not using %ebx. Test building on two different geodes, tested to boot on dbe62 Signed-off-by: Ronald G. Minnich Acked-by: Carl-Daniel Hailfinger git-svn-id: svn://coreboot.org/repository/coreboot-v3@750 f3766cd6-281f-0410-b1cd-43a5c92072e9 --- include/arch/x86/amd/k8/k8.h | 16 ++++++++++++++++ include/arch/x86/amd/k8/sysconf.h | 2 +- include/arch/x86/cpu.h | 12 ++++++++---- include/console.h | 2 +- include/device/device.h | 2 +- include/lib.h | 1 + include/mc146818rtc.h | 8 +++++++- include/string.h | 9 +++++---- 8 files changed, 40 insertions(+), 12 deletions(-) diff --git a/include/arch/x86/amd/k8/k8.h b/include/arch/x86/amd/k8/k8.h index de0ed8eb75..1aca5fd578 100644 --- a/include/arch/x86/amd/k8/k8.h +++ b/include/arch/x86/amd/k8/k8.h @@ -422,4 +422,20 @@ struct sys_info { u32 sblk; u32 sbbusn; } __attribute__((packed)); + +/* dual core support */ +unsigned int read_nb_cfg_54(void); + +struct node_core_id { + unsigned nodeid; + unsigned coreid; +}; + +// it can be used to get unitid and coreid it running only +struct node_core_id get_node_core_id(unsigned int nb_cfg_54); + +struct device; +unsigned get_apicid_base(unsigned ioapic_num); +void amd_sibling_init(struct device *cpu); + #endif /* ! ASSEMBLY */ diff --git a/include/arch/x86/amd/k8/sysconf.h b/include/arch/x86/amd/k8/sysconf.h index 0017b6e126..6b8f13c1e7 100644 --- a/include/arch/x86/amd/k8/sysconf.h +++ b/include/arch/x86/amd/k8/sysconf.h @@ -42,6 +42,6 @@ struct amdk8_sysconf{ }; -extern struct amdk8_sysconf_t sysconf; +extern struct amdk8_sysconf sysconf; #endif diff --git a/include/arch/x86/cpu.h b/include/arch/x86/cpu.h index 8ab50fd553..51d2aa3630 100644 --- a/include/arch/x86/cpu.h +++ b/include/arch/x86/cpu.h @@ -99,9 +99,13 @@ static inline struct cpuid_result cpuid(u32 op) r.ecx = 0; /* ecx is often an input as well as an output. */ - __asm__("cpuid" + /* can't use ebx in PIC mode */ + __asm__("pushl %%ebx" + "\n\tcpuid" + "\n\tmovl %%ebx, %%esi" + "\n\tpopl %%ebx" : "=a" (r.eax), - "=b" (r.ebx), + "=S" (r.ebx), "=c" (r.ecx), "=d" (r.edx) : "0" (r.eax), "2" (r.ecx)); @@ -246,9 +250,9 @@ struct rmap { }; }; -void setup_resource_map_x_offset(const struct rmap *rm, u32 max, +SHARED(setup_resource_map_x_offset, void, const struct rmap *rm, u32 max, u32 offset_dev, u32 offset_pciio, u32 offset_io); -void setup_resource_map(const struct rmap *rm, u32 max); +SHARED(setup_resource_map, void, const struct rmap *rm, u32 max); #endif /* ARCH_X86_CPU_H */ diff --git a/include/console.h b/include/console.h index a755667199..0a23c0b114 100644 --- a/include/console.h +++ b/include/console.h @@ -37,7 +37,6 @@ void console_tx_byte(unsigned char byte, void *arg); void console_tx_flush(void); unsigned char console_rx_byte(void); int console_tst_byte(void); -void die(const char *msg); #ifdef CONFIG_CONSOLE_BUFFER void printk_buffer_init(void); void printk_buffer_move(void *newaddr, int newsize); @@ -64,5 +63,6 @@ SHARED_WITH_ATTRIBUTES(printk, int, __attribute__((format (printf, 2, 3))), int msg_level, const char *fmt, ...); SHARED(banner, void, int msg_level, const char *msg); SHARED(dump_mem_range, void, int msg_level, unsigned char *buf, int size); +SHARED(die, void, const char *msg); #endif /* CONSOLE_H */ diff --git a/include/device/device.h b/include/device/device.h index 028f5fe057..039d63c714 100644 --- a/include/device/device.h +++ b/include/device/device.h @@ -89,7 +89,7 @@ struct apic_cluster_id struct cpu_id { - u32 cpuid[3]; + u8 cpuid[24]; }; struct cpu_bus_id diff --git a/include/lib.h b/include/lib.h index 6d10604dd1..fd5cc8a793 100644 --- a/include/lib.h +++ b/include/lib.h @@ -20,6 +20,7 @@ #ifndef LIB_H #define LIB_H +#include /** * Return the size of a given array, no matter of which data type diff --git a/include/mc146818rtc.h b/include/mc146818rtc.h index 356a002fcc..e0fdee6e17 100644 --- a/include/mc146818rtc.h +++ b/include/mc146818rtc.h @@ -117,8 +117,14 @@ #define RTC_LAST_BOOT_FLAG_SET (1<<1) #define RTC_NORMAL_BOOT_FLAG_SET (1<<0) -void rtc_init(int invalid); +#ifdef STANDALONE /* standalone program using this file */ int get_option(void *dest, char *name); +#else +#include + +SHARED(get_option, int, void *dest, char *name); +#endif +void rtc_init(int invalid); int last_boot_normal(void); int check_normal_boot_flag(void); diff --git a/include/string.h b/include/string.h index 87212df4ba..5fdcd18bfc 100644 --- a/include/string.h +++ b/include/string.h @@ -22,6 +22,7 @@ #define STRING_H #include +#include /* lib/string.c */ size_t strnlen(const char *str, size_t maxlen); @@ -30,10 +31,10 @@ int strcmp(const char *s1, const char *s2); int strncmp(const char *s1, const char *s2, int maxlen); /* lib/mem.c */ -void *memcpy(void *dest, const void *src, size_t len); -void *memmove(void *dest, const void *src, size_t len); -void *memset(void *s, int c, size_t len); -int memcmp(const void *s1, const void *s2, size_t len); +SHARED(memcpy, void *, void *dest, const void *src, size_t len); +SHARED(memmove, void *, void *dest, const void *src, size_t len); +SHARED(memset, void *, void *s, int c, size_t len); +SHARED(memcmp, int , const void *s1, const void *s2, size_t len); /* console/vsprintf.c */ int sprintf(char *buf, const char *fmt, ...);