- First pass through with with device tree enhancement merge. Most of the mechanisms should
be in place but don't expect anything to quite work yet. git-svn-id: svn://svn.coreboot.org/coreboot/trunk@1662 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
This commit is contained in:
@ -5,6 +5,8 @@
|
|||||||
#include "linuxbios_table.h"
|
#include "linuxbios_table.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <version.h>
|
#include <version.h>
|
||||||
|
#include <device/device.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
|
||||||
struct lb_header *lb_table_init(unsigned long addr)
|
struct lb_header *lb_table_init(unsigned long addr)
|
||||||
@ -217,18 +219,75 @@ struct lb_memory *get_lb_mem(void)
|
|||||||
return mem_ranges;
|
return mem_ranges;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct mem_range *sizeram(void)
|
||||||
|
{
|
||||||
|
struct mem_range *mem, *rmem;
|
||||||
|
struct device *dev;
|
||||||
|
unsigned int count;
|
||||||
|
count = 0;
|
||||||
|
for(dev = all_devices; dev; dev = dev->next) {
|
||||||
|
struct resource *res, *last;
|
||||||
|
last = &dev->resource[dev->resources];
|
||||||
|
for(res = &dev->resource[0]; res < last; res++) {
|
||||||
|
if ((res->flags & IORESOURCE_MEM) &&
|
||||||
|
(res->flags & IORESOURCE_CACHEABLE))
|
||||||
|
{
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rmem = mem = malloc(sizeof(*mem) * (count + 1));
|
||||||
|
for(dev = all_devices; dev; dev = dev->next) {
|
||||||
|
struct resource *res, *last;
|
||||||
|
last = &dev->resource[dev->resources];
|
||||||
|
for(res = &dev->resource[0]; res < last; res++) {
|
||||||
|
if ((res->flags & IORESOURCE_MEM) &&
|
||||||
|
(res->flags & IORESOURCE_CACHEABLE))
|
||||||
|
{
|
||||||
|
mem->basek = res->base >> 10;
|
||||||
|
mem->sizek = res->size >> 10;
|
||||||
|
mem++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mem->basek = 0;
|
||||||
|
mem->sizek = 0;
|
||||||
|
#if 0
|
||||||
|
for(mem = rmem; mem->sizek; mem++) {
|
||||||
|
printk_debug("basek: %lu sizek: %lu\n",
|
||||||
|
mem->basek, mem->sizek);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return rmem;
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct mem_range *get_ramsize(void)
|
||||||
|
{
|
||||||
|
struct mem_range *mem = 0;
|
||||||
|
if (!mem) {
|
||||||
|
mem = sizeram();
|
||||||
|
}
|
||||||
|
if (!mem) {
|
||||||
|
printk_emerg("No memory size information!\n");
|
||||||
|
for(;;) {
|
||||||
|
/* Ensure this loop is not optimized away */
|
||||||
|
asm volatile("":/* outputs */:/*inputs */ :"memory");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return mem;
|
||||||
|
}
|
||||||
|
|
||||||
unsigned long write_linuxbios_table(
|
unsigned long write_linuxbios_table(
|
||||||
unsigned long *processor_map,
|
|
||||||
struct mem_range *ram,
|
|
||||||
unsigned long low_table_start, unsigned long low_table_end,
|
unsigned long low_table_start, unsigned long low_table_end,
|
||||||
unsigned long rom_table_startk, unsigned long rom_table_endk)
|
unsigned long rom_table_startk, unsigned long rom_table_endk)
|
||||||
{
|
{
|
||||||
unsigned long table_size;
|
unsigned long table_size;
|
||||||
struct mem_range *ramp;
|
struct mem_range *ram, *ramp;
|
||||||
struct lb_header *head;
|
struct lb_header *head;
|
||||||
struct lb_memory *mem;
|
struct lb_memory *mem;
|
||||||
struct lb_record *rec_dest, *rec_src;
|
struct lb_record *rec_dest, *rec_src;
|
||||||
|
|
||||||
|
ram = get_ramsize();
|
||||||
head = lb_table_init(low_table_end);
|
head = lb_table_init(low_table_end);
|
||||||
low_table_end = (unsigned long)head;
|
low_table_end = (unsigned long)head;
|
||||||
#if HAVE_OPTION_TABLE == 1
|
#if HAVE_OPTION_TABLE == 1
|
||||||
|
@ -3,12 +3,8 @@
|
|||||||
|
|
||||||
#include <boot/linuxbios_tables.h>
|
#include <boot/linuxbios_tables.h>
|
||||||
|
|
||||||
struct mem_range;
|
|
||||||
|
|
||||||
/* This file holds function prototypes for building the linuxbios table. */
|
/* This file holds function prototypes for building the linuxbios table. */
|
||||||
unsigned long write_linuxbios_table(
|
unsigned long write_linuxbios_table(
|
||||||
unsigned long *processor_map,
|
|
||||||
struct mem_range *ram,
|
|
||||||
unsigned long low_table_start, unsigned long low_table_end,
|
unsigned long low_table_start, unsigned long low_table_end,
|
||||||
unsigned long rom_table_start, unsigned long rom_table_end);
|
unsigned long rom_table_start, unsigned long rom_table_end);
|
||||||
|
|
||||||
|
@ -1,39 +1,13 @@
|
|||||||
#include <console/console.h>
|
#include <console/console.h>
|
||||||
#include <mem.h>
|
|
||||||
#include <cpu/cpu.h>
|
#include <cpu/cpu.h>
|
||||||
#include <boot/tables.h>
|
#include <boot/tables.h>
|
||||||
#include <boot/linuxbios_tables.h>
|
#include <boot/linuxbios_tables.h>
|
||||||
#include <arch/pirq_routing.h>
|
#include <arch/pirq_routing.h>
|
||||||
#include <arch/smp/mpspec.h>
|
#include <arch/smp/mpspec.h>
|
||||||
#include <arch/acpi.h>
|
#include <arch/acpi.h>
|
||||||
#include <pc80/mc146818rtc.h>
|
|
||||||
#include "linuxbios_table.h"
|
#include "linuxbios_table.h"
|
||||||
|
|
||||||
#if CONFIG_SMP && CONFIG_MAX_PHYSICAL_CPUS && (CONFIG_MAX_PHYSICAL_CPUS < CONFIG_MAX_CPUS)
|
struct lb_memory *write_tables(void)
|
||||||
static void remove_logical_cpus(unsigned long *processor_map)
|
|
||||||
{
|
|
||||||
/* To turn off hyperthreading just remove the logical
|
|
||||||
* cpus from the processor map.
|
|
||||||
*/
|
|
||||||
int disable_logical_cpus = !CONFIG_LOGICAL_CPUS;
|
|
||||||
if (get_option(&disable_logical_cpus,"hyper_threading")) {
|
|
||||||
disable_logical_cpus = !CONFIG_LOGICAL_CPUS;
|
|
||||||
}
|
|
||||||
if (disable_logical_cpus) {
|
|
||||||
/* disable logical cpus */
|
|
||||||
int cnt;
|
|
||||||
for(cnt=CONFIG_MAX_PHYSICAL_CPUS;cnt<CONFIG_MAX_CPUS;cnt++)
|
|
||||||
processor_map[cnt]=0;
|
|
||||||
printk_debug("logical cpus disabled\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
|
|
||||||
#define remove_logical_cpus(processor_map) do {} while(0)
|
|
||||||
|
|
||||||
#endif /* CONFIG_SMP && CONFIG_MAX_PHYSICAL_CPUS */
|
|
||||||
|
|
||||||
struct lb_memory *write_tables(struct mem_range *mem, unsigned long *processor_map)
|
|
||||||
{
|
{
|
||||||
unsigned long low_table_start, low_table_end;
|
unsigned long low_table_start, low_table_end;
|
||||||
unsigned long rom_table_start, rom_table_end;
|
unsigned long rom_table_start, rom_table_end;
|
||||||
@ -56,8 +30,7 @@ struct lb_memory *write_tables(struct mem_range *mem, unsigned long *processor_m
|
|||||||
post_code(0x96);
|
post_code(0x96);
|
||||||
|
|
||||||
/* The smp table must be in 0-1K, 639K-640K, or 960K-1M */
|
/* The smp table must be in 0-1K, 639K-640K, or 960K-1M */
|
||||||
remove_logical_cpus(processor_map);
|
low_table_end = write_smp_table(low_table_end);
|
||||||
low_table_end = write_smp_table(low_table_end, processor_map);
|
|
||||||
|
|
||||||
/* Write ACPI tables */
|
/* Write ACPI tables */
|
||||||
/* write them in the rom area because DSDT can be large (8K on epia-m) which
|
/* write them in the rom area because DSDT can be large (8K on epia-m) which
|
||||||
@ -73,7 +46,7 @@ struct lb_memory *write_tables(struct mem_range *mem, unsigned long *processor_m
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* The linuxbios table must be in 0-4K or 960K-1M */
|
/* The linuxbios table must be in 0-4K or 960K-1M */
|
||||||
write_linuxbios_table(processor_map, mem,
|
write_linuxbios_table(
|
||||||
low_table_start, low_table_end,
|
low_table_start, low_table_end,
|
||||||
rom_table_start >> 10, rom_table_end >> 10);
|
rom_table_start >> 10, rom_table_end >> 10);
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ static void hlt(void)
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#if defined(__GNUC__) && !defined(__ROMCC__)
|
||||||
static inline void hlt(void)
|
static inline void hlt(void)
|
||||||
{
|
{
|
||||||
asm("hlt");
|
asm("hlt");
|
||||||
|
@ -191,6 +191,11 @@ static inline void pnp_set_iobase(device_t dev, unsigned index, unsigned iobase)
|
|||||||
pnp_write_config(dev, index + 1, iobase & 0xff);
|
pnp_write_config(dev, index + 1, iobase & 0xff);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline uint16_t pnp_read_iobase(device_t dev, unsigned index)
|
||||||
|
{
|
||||||
|
return (uint16_t)((pnp_read_config(dev, index) << 8) | pnp_read_config(dev, index + 1));
|
||||||
|
}
|
||||||
|
|
||||||
static inline void pnp_set_irq(device_t dev, unsigned index, unsigned irq)
|
static inline void pnp_set_irq(device_t dev, unsigned index, unsigned irq)
|
||||||
{
|
{
|
||||||
pnp_write_config(dev, index, irq);
|
pnp_write_config(dev, index, irq);
|
||||||
|
@ -1,55 +0,0 @@
|
|||||||
#ifndef ARCH_SMP_LAPIC_H
|
|
||||||
#define ARCH_SMP_LAPIC_H
|
|
||||||
|
|
||||||
#include <cpu/p6/msr.h>
|
|
||||||
#include <cpu/p6/apic.h>
|
|
||||||
#include <arch/hlt.h>
|
|
||||||
|
|
||||||
static void enable_lapic(void)
|
|
||||||
{
|
|
||||||
|
|
||||||
msr_t msr;
|
|
||||||
msr = rdmsr(0x1b);
|
|
||||||
msr.hi &= 0xffffff00;
|
|
||||||
msr.lo &= 0x000007ff;
|
|
||||||
msr.lo |= APIC_DEFAULT_BASE | (1 << 11);
|
|
||||||
wrmsr(0x1b, msr);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void disable_lapic(void)
|
|
||||||
{
|
|
||||||
msr_t msr;
|
|
||||||
msr = rdmsr(0x1b);
|
|
||||||
msr.lo &= ~ (1 << 11);
|
|
||||||
wrmsr(0x1b, msr);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline unsigned long lapicid(void)
|
|
||||||
{
|
|
||||||
return apic_read(APIC_ID) >> 24;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void stop_this_cpu(void)
|
|
||||||
{
|
|
||||||
unsigned apicid;
|
|
||||||
apicid = lapicid();
|
|
||||||
|
|
||||||
/* Send an APIC INIT to myself */
|
|
||||||
apic_write(APIC_ICR2, SET_APIC_DEST_FIELD(apicid));
|
|
||||||
apic_write(APIC_ICR, APIC_INT_LEVELTRIG | APIC_INT_ASSERT | APIC_DM_INIT);
|
|
||||||
/* Wait for the ipi send to finish */
|
|
||||||
apic_wait_icr_idle();
|
|
||||||
|
|
||||||
/* Deassert the APIC INIT */
|
|
||||||
apic_write(APIC_ICR2, SET_APIC_DEST_FIELD(apicid));
|
|
||||||
apic_write(APIC_ICR, APIC_INT_LEVELTRIG | APIC_DM_INIT);
|
|
||||||
/* Wait for the ipi send to finish */
|
|
||||||
apic_wait_icr_idle();
|
|
||||||
|
|
||||||
/* If I haven't halted spin forever */
|
|
||||||
for(;;) {
|
|
||||||
hlt();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* ARCH_SMP_LAPIC_H */
|
|
@ -238,8 +238,7 @@ void smp_write_processor(struct mp_config_table *mc,
|
|||||||
unsigned char apicid, unsigned char apicver,
|
unsigned char apicid, unsigned char apicver,
|
||||||
unsigned char cpuflag, unsigned int cpufeature,
|
unsigned char cpuflag, unsigned int cpufeature,
|
||||||
unsigned int featureflag);
|
unsigned int featureflag);
|
||||||
void smp_write_processors(struct mp_config_table *mc,
|
void smp_write_processors(struct mp_config_table *mc);
|
||||||
unsigned long *processor_map);
|
|
||||||
void smp_write_bus(struct mp_config_table *mc,
|
void smp_write_bus(struct mp_config_table *mc,
|
||||||
unsigned char id, unsigned char *bustype);
|
unsigned char id, unsigned char *bustype);
|
||||||
void smp_write_ioapic(struct mp_config_table *mc,
|
void smp_write_ioapic(struct mp_config_table *mc,
|
||||||
@ -265,18 +264,15 @@ void smp_write_compatibility_address_space(struct mp_config_table *mc,
|
|||||||
unsigned int range_list);
|
unsigned int range_list);
|
||||||
unsigned char smp_compute_checksum(void *v, int len);
|
unsigned char smp_compute_checksum(void *v, int len);
|
||||||
void *smp_write_floating_table(unsigned long addr);
|
void *smp_write_floating_table(unsigned long addr);
|
||||||
unsigned long write_smp_table(unsigned long addr, unsigned long *processor_map);
|
unsigned long write_smp_table(unsigned long addr);
|
||||||
|
|
||||||
#else /* HAVE_MP_TABLE */
|
#else /* HAVE_MP_TABLE */
|
||||||
static inline
|
static inline
|
||||||
unsigned long write_smp_table(unsigned long addr, unsigned long *processor_map)
|
unsigned long write_smp_table(unsigned long addr);
|
||||||
{
|
{
|
||||||
return addr;
|
return addr;
|
||||||
}
|
}
|
||||||
#endif /* HAVE_MP_TABLE */
|
#endif /* HAVE_MP_TABLE */
|
||||||
|
|
||||||
/* A table (per mainboard) listing the initial apicid of each cpu. */
|
|
||||||
extern unsigned long initial_apicid[CONFIG_MAX_CPUS];
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -54,4 +54,10 @@ static inline void spin_unlock(spinlock_t *lock)
|
|||||||
:"=m" (lock->lock) : : "memory");
|
:"=m" (lock->lock) : : "memory");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* REP NOP (PAUSE) is a good thing to insert into busy-wait loops. */
|
||||||
|
static inline void cpu_relax(void)
|
||||||
|
{
|
||||||
|
__asm__ __volatile__("rep;nop": : :"memory");
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* ARCH_SMP_SPINLOCK_H */
|
#endif /* ARCH_SMP_SPINLOCK_H */
|
||||||
|
@ -8,7 +8,7 @@ typedef long ssize_t;
|
|||||||
typedef int wchar_t;
|
typedef int wchar_t;
|
||||||
typedef unsigned int wint_t;
|
typedef unsigned int wint_t;
|
||||||
|
|
||||||
#define NULL 0
|
#define NULL ((void *)0)
|
||||||
|
|
||||||
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
|
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef I386_STDINT_H
|
#ifndef I386_STDINT_H
|
||||||
#define I386_STDINT_H
|
#define I386_STDINT_H
|
||||||
|
|
||||||
#if defined(__GNUC__)
|
#if defined(__GNUC__) && !defined(__ROMCC__)
|
||||||
#define __HAVE_LONG_LONG__ 1
|
#define __HAVE_LONG_LONG__ 1
|
||||||
#else
|
#else
|
||||||
#define __HAVE_LONG_LONG__ 0
|
#define __HAVE_LONG_LONG__ 0
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
#include <arch/asm.h>
|
#include <arch/asm.h>
|
||||||
#include <arch/intel.h>
|
#include <arch/intel.h>
|
||||||
#if CONFIG_SMP==1
|
|
||||||
#include <cpu/p6/apic.h>
|
|
||||||
#endif
|
|
||||||
.section ".text"
|
.section ".text"
|
||||||
.code32
|
.code32
|
||||||
.globl _start
|
.globl _start
|
||||||
@ -39,27 +36,10 @@ _start:
|
|||||||
|
|
||||||
/* set new stack */
|
/* set new stack */
|
||||||
movl $_estack, %esp
|
movl $_estack, %esp
|
||||||
#if CONFIG_SMP==1
|
|
||||||
/* Get the cpu id */
|
|
||||||
movl $APIC_DEFAULT_BASE, %edi
|
|
||||||
movl APIC_ID(%edi), %eax
|
|
||||||
shrl $24, %eax
|
|
||||||
|
|
||||||
/* Get the cpu index (CONFIG_MAX_CPUS on error) */
|
/* Push the cpu index and struct cpu */
|
||||||
movl $-4, %ebx
|
pushl $0
|
||||||
1: addl $4, %ebx
|
pushl $0
|
||||||
cmpl $(CONFIG_MAX_CPUS << 2), %ebx
|
|
||||||
je 2
|
|
||||||
cmpl %eax, initial_apicid(%ebx)
|
|
||||||
jne 1b
|
|
||||||
2: shrl $2, %ebx
|
|
||||||
|
|
||||||
/* Now compute the appropriate stack */
|
|
||||||
movl %ebx, %eax
|
|
||||||
movl $STACK_SIZE, %ebx
|
|
||||||
mull %ebx
|
|
||||||
subl %eax, %esp
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* push the boot_complete flag */
|
/* push the boot_complete flag */
|
||||||
pushl %ebp
|
pushl %ebp
|
||||||
@ -74,7 +54,7 @@ _start:
|
|||||||
*/
|
*/
|
||||||
intel_chip_post_macro(0xfe) /* post fe */
|
intel_chip_post_macro(0xfe) /* post fe */
|
||||||
|
|
||||||
/* Resort the stack location */
|
/* Restore the stack location */
|
||||||
movl %ebp, %esp
|
movl %ebp, %esp
|
||||||
|
|
||||||
/* The boot_complete flag has already been pushed */
|
/* The boot_complete flag has already been pushed */
|
||||||
|
@ -118,21 +118,18 @@ static void print_spew_hex16(unsigned short value){ __console_tx_hex16(BIOS_SPEW
|
|||||||
static void print_spew_hex32(unsigned int value) { __console_tx_hex32(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); }
|
static void print_spew(const char *str) { __console_tx_string(BIOS_SPEW, str); }
|
||||||
|
|
||||||
#define __STR(X) #X
|
|
||||||
#define STR(X) __STR(X)
|
|
||||||
|
|
||||||
#ifndef LINUXBIOS_EXTRA_VERSION
|
#ifndef LINUXBIOS_EXTRA_VERSION
|
||||||
#define LINUXBIOS_EXTRA_VERSION
|
#define LINUXBIOS_EXTRA_VERSION ""
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void console_init(void)
|
static void console_init(void)
|
||||||
{
|
{
|
||||||
static const char console_test[] =
|
static const char console_test[] =
|
||||||
"\r\n\r\nLinuxBIOS-"
|
"\r\n\r\nLinuxBIOS-"
|
||||||
STR(LINUXBIOS_VERSION)
|
LINUXBIOS_VERSION
|
||||||
STR(LINUXBIOS_EXTRA_VERSION)
|
LINUXBIOS_EXTRA_VERSION
|
||||||
" "
|
" "
|
||||||
STR(LINUXBIOS_BUILD)
|
LINUXBIOS_BUILD
|
||||||
" starting...\r\n";
|
" starting...\r\n";
|
||||||
print_info(console_test);
|
print_info(console_test);
|
||||||
}
|
}
|
||||||
|
@ -2,11 +2,8 @@
|
|||||||
|
|
||||||
jmp console0
|
jmp console0
|
||||||
|
|
||||||
#define __STR(X) #X
|
|
||||||
#define STR(X) __STR(X)
|
|
||||||
|
|
||||||
#ifndef LINUXBIOS_EXTRA_VERSION
|
#ifndef LINUXBIOS_EXTRA_VERSION
|
||||||
#define LINUXBIOS_EXTRA_VERSION
|
#define LINUXBIOS_EXTRA_VERSION ""
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef ASM_CONSOLE_LOGLEVEL
|
#ifndef ASM_CONSOLE_LOGLEVEL
|
||||||
@ -14,13 +11,12 @@ jmp console0
|
|||||||
#endif
|
#endif
|
||||||
console_test:
|
console_test:
|
||||||
.ascii "\r\n\r\nLinuxBIOS-"
|
.ascii "\r\n\r\nLinuxBIOS-"
|
||||||
.ascii STR(LINUXBIOS_VERSION)
|
.ascii LINUXBIOS_VERSION
|
||||||
.ascii STR(LINUXBIOS_EXTRA_VERSION)
|
.ascii LINUXBIOS_EXTRA_VERSION
|
||||||
.ascii " "
|
.ascii " "
|
||||||
.ascii STR(LINUXBIOS_BUILD)
|
.ascii LINUXBIOS_BUILD
|
||||||
.asciz " starting...\r\n"
|
.asciz " starting...\r\n"
|
||||||
|
|
||||||
#undef STR
|
|
||||||
/* uses: ax, dx */
|
/* uses: ax, dx */
|
||||||
#if CONFIG_CONSOLE_SERIAL8250
|
#if CONFIG_CONSOLE_SERIAL8250
|
||||||
#define __CONSOLE_INLINE_TX_AL TTYS0_TX_AL
|
#define __CONSOLE_INLINE_TX_AL TTYS0_TX_AL
|
||||||
|
@ -1,147 +1,252 @@
|
|||||||
#include <console/console.h>
|
#include <console/console.h>
|
||||||
#include <cpu/cpu.h>
|
#include <cpu/cpu.h>
|
||||||
#include <mem.h>
|
|
||||||
#include <arch/io.h>
|
#include <arch/io.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <cpu/cpufixup.h>
|
#include <cpu/x86/mtrr.h>
|
||||||
#include <smp/start_stop.h>
|
#include <cpu/x86/msr.h>
|
||||||
#include <cpu/cpufixup.h>
|
#include <cpu/x86/lapic.h>
|
||||||
#include <cpu/p6/mtrr.h>
|
#include <arch/cpu.h>
|
||||||
#include <cpu/p6/msr.h>
|
#include <device/path.h>
|
||||||
#include <cpu/p6/apic.h>
|
#include <device/device.h>
|
||||||
#include <cpu/p5/cpuid.h>
|
#include <smp/spinlock.h>
|
||||||
#include <arch/smp/lapic.h>
|
|
||||||
#if 0
|
|
||||||
#include <cpu/l2_cache.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if CONFIG_SMP || CONFIG_IOAPIC
|
/* Standard macro to see if a specific flag is changeable */
|
||||||
#define APIC 1
|
static inline int flag_is_changeable_p(uint32_t flag)
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
static void cache_on(struct mem_range *mem)
|
|
||||||
{
|
{
|
||||||
post_code(0x60);
|
uint32_t f1, f2;
|
||||||
printk_info("Enabling cache...");
|
|
||||||
|
|
||||||
|
asm(
|
||||||
/* we need an #ifdef i586 here at some point ... */
|
"pushfl\n\t"
|
||||||
__asm__ __volatile__("mov %cr0, %eax\n\t"
|
"pushfl\n\t"
|
||||||
"and $0x9fffffff,%eax\n\t"
|
"popl %0\n\t"
|
||||||
"mov %eax, %cr0\n\t");
|
"movl %0,%1\n\t"
|
||||||
/* turns out cache isn't really on until you set MTRR registers on
|
"xorl %2,%0\n\t"
|
||||||
* 686 and later.
|
"pushl %0\n\t"
|
||||||
* NOTHING FANCY. Linux does a much better job anyway.
|
"popfl\n\t"
|
||||||
* so absolute minimum needed to get it going.
|
"pushfl\n\t"
|
||||||
*/
|
"popl %0\n\t"
|
||||||
/* OK, linux it turns out does nothing. We have to do it ... */
|
"popfl\n\t"
|
||||||
#if i686==1
|
: "=&r" (f1), "=&r" (f2)
|
||||||
// totalram here is in linux sizing, i.e. units of KB.
|
: "ir" (flag));
|
||||||
// set_mtrr is responsible for getting it into the right units!
|
return ((f1^f2) & flag) != 0;
|
||||||
setup_mtrrs(mem);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
post_code(0x6A);
|
|
||||||
printk_info("done.\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void interrupts_on()
|
|
||||||
|
/* Probe for the CPUID instruction */
|
||||||
|
static int have_cpuid_p(void)
|
||||||
{
|
{
|
||||||
/* this is so interrupts work. This is very limited scope --
|
return flag_is_changeable_p(X86_EFLAGS_ID);
|
||||||
* linux will do better later, we hope ...
|
|
||||||
*/
|
|
||||||
/* this is the first way we learned to do it. It fails on real SMP
|
|
||||||
* stuff. So we have to do things differently ...
|
|
||||||
* see the Intel mp1.4 spec, page A-3
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if defined(APIC)
|
|
||||||
/* Only Pentium Pro and later have those MSR stuff */
|
|
||||||
msr_t msr;
|
|
||||||
|
|
||||||
printk_info("Setting up local apic...");
|
|
||||||
|
|
||||||
/* Enable the local apic */
|
|
||||||
msr = rdmsr(APIC_BASE_MSR);
|
|
||||||
msr.lo |= APIC_BASE_MSR_ENABLE;
|
|
||||||
msr.lo &= ~APIC_BASE_MSR_ADDR_MASK;
|
|
||||||
msr.lo |= APIC_DEFAULT_BASE;
|
|
||||||
wrmsr(APIC_BASE_MSR, msr);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Set Task Priority to 'accept all'.
|
|
||||||
*/
|
|
||||||
apic_write_around(APIC_TASKPRI,
|
|
||||||
apic_read_around(APIC_TASKPRI) & ~APIC_TPRI_MASK);
|
|
||||||
|
|
||||||
/* Put the local apic in virtual wire mode */
|
|
||||||
apic_write_around(APIC_SPIV,
|
|
||||||
(apic_read_around(APIC_SPIV) & ~(APIC_VECTOR_MASK))
|
|
||||||
| APIC_SPIV_ENABLE);
|
|
||||||
apic_write_around(APIC_LVT0,
|
|
||||||
(apic_read_around(APIC_LVT0) &
|
|
||||||
~(APIC_LVT_MASKED | APIC_LVT_LEVEL_TRIGGER |
|
|
||||||
APIC_LVT_REMOTE_IRR | APIC_INPUT_POLARITY |
|
|
||||||
APIC_SEND_PENDING |APIC_LVT_RESERVED_1 |
|
|
||||||
APIC_DELIVERY_MODE_MASK))
|
|
||||||
| (APIC_LVT_REMOTE_IRR |APIC_SEND_PENDING |
|
|
||||||
APIC_DELIVERY_MODE_EXTINT)
|
|
||||||
);
|
|
||||||
apic_write_around(APIC_LVT1,
|
|
||||||
(apic_read_around(APIC_LVT1) &
|
|
||||||
~(APIC_LVT_MASKED | APIC_LVT_LEVEL_TRIGGER |
|
|
||||||
APIC_LVT_REMOTE_IRR | APIC_INPUT_POLARITY |
|
|
||||||
APIC_SEND_PENDING |APIC_LVT_RESERVED_1 |
|
|
||||||
APIC_DELIVERY_MODE_MASK))
|
|
||||||
| (APIC_LVT_REMOTE_IRR |APIC_SEND_PENDING |
|
|
||||||
APIC_DELIVERY_MODE_NMI)
|
|
||||||
);
|
|
||||||
|
|
||||||
printk_debug(" apic_id: %d ", lapicid());
|
|
||||||
|
|
||||||
#else /* APIC */
|
|
||||||
#if i686==1
|
|
||||||
/* Only Pentium Pro and later have those MSR stuff */
|
|
||||||
msr_t msr;
|
|
||||||
|
|
||||||
printk_info("Disabling local apic...");
|
|
||||||
|
|
||||||
msr = rdmsr(APIC_BASE_MSR);
|
|
||||||
msr.lo &= ~APIC_BASE_MSR_ENABLE;
|
|
||||||
wrmsr(APIC_BASE_MSR, msr);
|
|
||||||
#endif /* i686 */
|
|
||||||
#endif /* APIC */
|
|
||||||
printk_info("done.\n");
|
|
||||||
post_code(0x9b);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long cpu_initialize(struct mem_range *mem)
|
/*
|
||||||
|
* Cyrix CPUs without cpuid or with cpuid not yet enabled can be detected
|
||||||
|
* by the fact that they preserve the flags across the division of 5/2.
|
||||||
|
* PII and PPro exhibit this behavior too, but they have cpuid available.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Perform the Cyrix 5/2 test. A Cyrix won't change
|
||||||
|
* the flags, while other 486 chips will.
|
||||||
|
*/
|
||||||
|
static inline int test_cyrix_52div(void)
|
||||||
|
{
|
||||||
|
unsigned int test;
|
||||||
|
|
||||||
|
__asm__ __volatile__(
|
||||||
|
"sahf\n\t" /* clear flags (%eax = 0x0005) */
|
||||||
|
"div %b2\n\t" /* divide 5 by 2 */
|
||||||
|
"lahf" /* store flags into %ah */
|
||||||
|
: "=a" (test)
|
||||||
|
: "0" (5), "q" (2)
|
||||||
|
: "cc");
|
||||||
|
|
||||||
|
/* AH is 0x02 on Cyrix after the divide.. */
|
||||||
|
return (unsigned char) (test >> 8) == 0x02;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Detect a NexGen CPU running without BIOS hypercode new enough
|
||||||
|
* to have CPUID. (Thanks to Herbert Oppmann)
|
||||||
|
*/
|
||||||
|
|
||||||
|
static int deep_magic_nexgen_probe(void)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
__asm__ __volatile__ (
|
||||||
|
" movw $0x5555, %%ax\n"
|
||||||
|
" xorw %%dx,%%dx\n"
|
||||||
|
" movw $2, %%cx\n"
|
||||||
|
" divw %%cx\n"
|
||||||
|
" movl $0, %%eax\n"
|
||||||
|
" jnz 1f\n"
|
||||||
|
" movl $1, %%eax\n"
|
||||||
|
"1:\n"
|
||||||
|
: "=a" (ret) : : "cx", "dx" );
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* List of cpu vendor strings along with their normalized
|
||||||
|
* id values.
|
||||||
|
*/
|
||||||
|
static struct {
|
||||||
|
int vendor;
|
||||||
|
const char *name;
|
||||||
|
} x86_vendors[] = {
|
||||||
|
{ X86_VENDOR_INTEL, "GenuineIntel", },
|
||||||
|
{ X86_VENDOR_CYRIX, "CyrixInstead", },
|
||||||
|
{ X86_VENDOR_AMD, "AuthenticAMD", },
|
||||||
|
{ X86_VENDOR_UMC, "UMC UMC UMC ", },
|
||||||
|
{ X86_VENDOR_NEXGEN, "NexGenDriven", },
|
||||||
|
{ X86_VENDOR_CENTAUR, "CentaurHauls", },
|
||||||
|
{ X86_VENDOR_RISE, "RiseRiseRise", },
|
||||||
|
{ X86_VENDOR_TRANSMETA, "GenuineTMx86", },
|
||||||
|
{ X86_VENDOR_TRANSMETA, "TransmetaCPU", },
|
||||||
|
{ X86_VENDOR_NSC, "Geode by NSC", },
|
||||||
|
{ X86_VENDOR_SIS, "SiS SiS SiS ", },
|
||||||
|
};
|
||||||
|
|
||||||
|
static const char *x86_vendor_name[] = {
|
||||||
|
[X86_VENDOR_INTEL] = "Intel",
|
||||||
|
[X86_VENDOR_CYRIX] = "Cyrix",
|
||||||
|
[X86_VENDOR_AMD] = "AMD",
|
||||||
|
[X86_VENDOR_UMC] = "UMC",
|
||||||
|
[X86_VENDOR_NEXGEN] = "NexGen",
|
||||||
|
[X86_VENDOR_CENTAUR] = "Centaur",
|
||||||
|
[X86_VENDOR_RISE] = "Rise",
|
||||||
|
[X86_VENDOR_TRANSMETA] = "Transmeta",
|
||||||
|
[X86_VENDOR_NSC] = "NSC",
|
||||||
|
[X86_VENDOR_SIS] = "SiS",
|
||||||
|
};
|
||||||
|
|
||||||
|
static const char *cpu_vendor_name(int vendor)
|
||||||
|
{
|
||||||
|
const char *name;
|
||||||
|
name = "<invalid cpu vendor>";
|
||||||
|
if ((vendor < (sizeof(x86_vendor_name)/sizeof(x86_vendor_name[0]))) &&
|
||||||
|
(x86_vendor_name[vendor] != 0))
|
||||||
|
{
|
||||||
|
name = x86_vendor_name[vendor];
|
||||||
|
}
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void identify_cpu(struct device *cpu)
|
||||||
|
{
|
||||||
|
char vendor_name[16];
|
||||||
|
int cpuid_level;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
vendor_name[0] = '\0'; /* Unset */
|
||||||
|
cpuid_level = -1; /* Maximum supported CPUID level, -1=no CPUID */
|
||||||
|
|
||||||
|
/* Find the id and vendor_name */
|
||||||
|
if (!have_cpuid_p()) {
|
||||||
|
/* Its a 486 if we can modify the AC flag */
|
||||||
|
if (flag_is_changeable_p(X86_EFLAGS_AC)) {
|
||||||
|
cpu->device = 0x00000400; /* 486 */
|
||||||
|
} else {
|
||||||
|
cpu->device = 0x00000300; /* 386 */
|
||||||
|
}
|
||||||
|
if ((cpu->device == 0x00000400) && test_cyrix_52div()) {
|
||||||
|
memcpy(vendor_name, "CyrixInstead", 13);
|
||||||
|
/* If we ever care we can enable cpuid here */
|
||||||
|
}
|
||||||
|
/* Detect NexGen with old hypercode */
|
||||||
|
else if (deep_magic_nexgen_probe()) {
|
||||||
|
memcpy(vendor_name, "NexGenDriven", 13);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (have_cpuid_p()) {
|
||||||
|
struct cpuid_result result;
|
||||||
|
result = cpuid(0x00000000);
|
||||||
|
cpuid_level = result.eax;
|
||||||
|
vendor_name[ 0] = (result.ebx >> 0) & 0xff;
|
||||||
|
vendor_name[ 1] = (result.ebx >> 8) & 0xff;
|
||||||
|
vendor_name[ 2] = (result.ebx >> 16) & 0xff;
|
||||||
|
vendor_name[ 3] = (result.ebx >> 24) & 0xff;
|
||||||
|
vendor_name[ 4] = (result.edx >> 0) & 0xff;
|
||||||
|
vendor_name[ 5] = (result.edx >> 8) & 0xff;
|
||||||
|
vendor_name[ 6] = (result.edx >> 16) & 0xff;
|
||||||
|
vendor_name[ 7] = (result.edx >> 24) & 0xff;
|
||||||
|
vendor_name[ 8] = (result.ecx >> 0) & 0xff;
|
||||||
|
vendor_name[ 9] = (result.ecx >> 8) & 0xff;
|
||||||
|
vendor_name[10] = (result.ecx >> 16) & 0xff;
|
||||||
|
vendor_name[11] = (result.ecx >> 24) & 0xff;
|
||||||
|
vendor_name[12] = '\0';
|
||||||
|
|
||||||
|
/* Intel-defined flags: level 0x00000001 */
|
||||||
|
if (cpuid_level >= 0x00000001) {
|
||||||
|
cpu->device = cpuid_eax(0x00000001);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* Have CPUID level 0 only unheard of */
|
||||||
|
cpu->device = 0x00000400;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cpu->vendor = X86_VENDOR_UNKNOWN;
|
||||||
|
for(i = 0; i < sizeof(x86_vendors)/sizeof(x86_vendors[0]); i++) {
|
||||||
|
if (memcmp(vendor_name, x86_vendors[i].name, 12) == 0) {
|
||||||
|
cpu->vendor = x86_vendors[i].vendor;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void set_cpu_ops(struct device *cpu)
|
||||||
|
{
|
||||||
|
struct cpu_driver *driver;
|
||||||
|
cpu->ops = 0;
|
||||||
|
for (driver = cpu_drivers; driver < ecpu_drivers; driver++) {
|
||||||
|
struct cpu_device_id *id;
|
||||||
|
for(id = driver->id_table; id->vendor != X86_VENDOR_INVALID; id++) {
|
||||||
|
if ((cpu->vendor == id->vendor) &&
|
||||||
|
(cpu->device == id->device))
|
||||||
|
{
|
||||||
|
goto found;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
die("Unknown cpu");
|
||||||
|
return;
|
||||||
|
found:
|
||||||
|
cpu->ops = driver->ops;
|
||||||
|
}
|
||||||
|
|
||||||
|
void cpu_initialize(void)
|
||||||
{
|
{
|
||||||
/* Because we busy wait at the printk spinlock.
|
/* Because we busy wait at the printk spinlock.
|
||||||
* It is important to keep the number of printed messages
|
* It is important to keep the number of printed messages
|
||||||
* from secondary cpus to a minimum, when debugging is
|
* from secondary cpus to a minimum, when debugging is
|
||||||
* disabled.
|
* disabled.
|
||||||
*/
|
*/
|
||||||
unsigned long processor_id = this_processors_id();
|
struct device *cpu;
|
||||||
printk_notice("Initializing CPU #%d\n", processor_id);
|
struct cpu_info *info;
|
||||||
|
info = cpu_info();
|
||||||
|
|
||||||
/* Turn on caching if we haven't already */
|
printk_notice("Initializing CPU #%d\n", info->index);
|
||||||
cache_on(mem);
|
|
||||||
#if i586==1
|
|
||||||
display_cpuid();
|
|
||||||
#endif
|
|
||||||
#if i686==1
|
|
||||||
mtrr_check();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* some cpus need a fixup done. This is the hook for doing that. */
|
cpu = info->cpu;
|
||||||
cpufixup(mem);
|
if (!cpu) {
|
||||||
|
die("CPU: missing cpu device structure");
|
||||||
|
}
|
||||||
|
|
||||||
interrupts_on();
|
/* Find what type of cpu we are dealing with */
|
||||||
|
identify_cpu(cpu);
|
||||||
|
printk_debug("CPU: vendor %s device %x\n",
|
||||||
|
cpu_vendor_name(cpu->vendor), cpu->device);
|
||||||
|
|
||||||
processor_id = this_processors_id();
|
/* Lookup the cpu's operations */
|
||||||
printk_info("CPU #%d Initialized\n", processor_id);
|
set_cpu_ops(cpu);
|
||||||
return processor_id;
|
|
||||||
|
/* Initialize the cpu */
|
||||||
|
if (cpu->ops && cpu->ops->init) {
|
||||||
|
cpu->enabled = 1;
|
||||||
|
cpu->initialized = 1;
|
||||||
|
cpu->ops->init(cpu);
|
||||||
|
}
|
||||||
|
|
||||||
|
printk_info("CPU #%d Initialized\n", info->index);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,21 +1,16 @@
|
|||||||
.section ".id", "a", @progbits
|
|
||||||
|
|
||||||
#define __STR(X) #X
|
.section ".id", "a", @progbits
|
||||||
#define STR(X) __STR(X)
|
|
||||||
|
|
||||||
.globl __id_start
|
.globl __id_start
|
||||||
__id_start:
|
__id_start:
|
||||||
vendor:
|
vendor:
|
||||||
.asciz STR(MAINBOARD_VENDOR)
|
.asciz MAINBOARD_VENDOR
|
||||||
part:
|
part:
|
||||||
.asciz STR(MAINBOARD_PART_NUMBER)
|
.asciz MAINBOARD_PART_NUMBER
|
||||||
.long __id_end + 0x10 - vendor /* Reverse offset to the vendor id */
|
.long __id_end + 0x10 - vendor /* Reverse offset to the vendor id */
|
||||||
.long __id_end + 0x10 - part /* Reverse offset to the part number */
|
.long __id_end + 0x10 - part /* Reverse offset to the part number */
|
||||||
.long PAYLOAD_SIZE + ROM_IMAGE_SIZE /* Size of this romimage */
|
.long PAYLOAD_SIZE + ROM_IMAGE_SIZE /* Size of this romimage */
|
||||||
.globl __id_end
|
.globl __id_end
|
||||||
|
|
||||||
#undef __STR
|
|
||||||
#undef STR
|
|
||||||
|
|
||||||
__id_end:
|
__id_end:
|
||||||
.previous
|
.previous
|
||||||
|
@ -1,12 +1,8 @@
|
|||||||
uses HAVE_MP_TABLE
|
uses HAVE_MP_TABLE
|
||||||
uses CONFIG_SMP
|
|
||||||
|
|
||||||
if HAVE_MP_TABLE
|
if HAVE_MP_TABLE
|
||||||
object mpspec.o
|
object mpspec.o
|
||||||
end
|
end
|
||||||
#object ioapic.o CONFIG_IOAPIC
|
#object ioapic.o CONFIG_IOAPIC
|
||||||
if CONFIG_SMP
|
|
||||||
object start_stop.o
|
|
||||||
object secondary.S
|
|
||||||
end
|
|
||||||
|
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
#include <console/console.h>
|
#include <console/console.h>
|
||||||
#include <cpu/cpu.h>
|
#include <cpu/cpu.h>
|
||||||
#include <smp/start_stop.h>
|
|
||||||
#include <arch/smp/mpspec.h>
|
#include <arch/smp/mpspec.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <cpu/p5/cpuid.h>
|
#include <arch/cpu.h>
|
||||||
#include <cpu/p6/apic.h>
|
#include <cpu/x86/lapic.h>
|
||||||
|
|
||||||
unsigned char smp_compute_checksum(void *v, int len)
|
unsigned char smp_compute_checksum(void *v, int len)
|
||||||
{
|
{
|
||||||
@ -94,30 +93,33 @@ void smp_write_processor(struct mp_config_table *mc,
|
|||||||
* Having the proper apicid's in the table so the non-bootstrap
|
* Having the proper apicid's in the table so the non-bootstrap
|
||||||
* processors can be woken up should be enough.
|
* processors can be woken up should be enough.
|
||||||
*/
|
*/
|
||||||
void smp_write_processors(struct mp_config_table *mc,
|
void smp_write_processors(struct mp_config_table *mc)
|
||||||
unsigned long *processor_map)
|
|
||||||
{
|
{
|
||||||
int i;
|
int boot_apic_id;
|
||||||
int processor_id;
|
|
||||||
unsigned apic_version;
|
unsigned apic_version;
|
||||||
unsigned cpu_features;
|
unsigned cpu_features;
|
||||||
unsigned cpu_feature_flags;
|
unsigned cpu_feature_flags;
|
||||||
int eax, ebx, ecx, edx;
|
struct cpuid_result result;
|
||||||
processor_id = this_processors_id();
|
device_t cpu;
|
||||||
apic_version = apic_read(APIC_LVR) & 0xff;
|
boot_apic_id = lapicid();
|
||||||
cpuid(1, &eax, &ebx, &ecx, &edx);
|
apic_version = lapic_read(LAPIC_LVR) & 0xff;
|
||||||
cpu_features = eax;
|
result = cpuid(1);
|
||||||
cpu_feature_flags = edx;
|
cpu_features = result.eax;
|
||||||
for(i = 0; i < CONFIG_MAX_CPUS; i++) {
|
cpu_feature_flags = result.edx;
|
||||||
unsigned long cpu_apicid = initial_apicid[i];
|
for(cpu = dev_root.link[1].children; cpu; cpu = cpu->sibling) {
|
||||||
unsigned long cpu_flag;
|
unsigned long cpu_flag;
|
||||||
if(initial_apicid[i]==-1)
|
if (cpu->path.type != DEVICE_PATH_APIC) {
|
||||||
continue;
|
continue;
|
||||||
cpu_flag = MPC_CPU_ENABLED;
|
|
||||||
if (processor_map[i] & CPU_BOOTPROCESSOR) {
|
|
||||||
cpu_flag |= MPC_CPU_BOOTPROCESSOR;
|
|
||||||
}
|
}
|
||||||
smp_write_processor(mc, cpu_apicid, apic_version,
|
if (!cpu->enabled) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
cpu_flag = MPC_CPU_ENABLED;
|
||||||
|
if (boot_apic_id == cpu->path.u.apic.apic_id) {
|
||||||
|
cpu_flag = MPC_CPU_ENABLED;
|
||||||
|
}
|
||||||
|
smp_write_processor(mc,
|
||||||
|
cpu->path.u.apic.apic_id, apic_version,
|
||||||
cpu_flag, cpu_features, cpu_feature_flags
|
cpu_flag, cpu_features, cpu_feature_flags
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -136,8 +138,8 @@ void smp_write_bus(struct mp_config_table *mc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void smp_write_ioapic(struct mp_config_table *mc,
|
void smp_write_ioapic(struct mp_config_table *mc,
|
||||||
unsigned char id, unsigned char ver,
|
unsigned char id, unsigned char ver,
|
||||||
unsigned long apicaddr)
|
unsigned long apicaddr)
|
||||||
{
|
{
|
||||||
struct mpc_config_ioapic *mpc;
|
struct mpc_config_ioapic *mpc;
|
||||||
mpc = smp_next_mpc_entry(mc);
|
mpc = smp_next_mpc_entry(mc);
|
||||||
|
@ -1,76 +0,0 @@
|
|||||||
#include <arch/asm.h>
|
|
||||||
#include <arch/intel.h>
|
|
||||||
#include <cpu/p6/mtrr.h>
|
|
||||||
#include <cpu/p6/apic.h>
|
|
||||||
.text
|
|
||||||
.globl _secondary_start
|
|
||||||
.balign 4096
|
|
||||||
_secondary_start:
|
|
||||||
.code16
|
|
||||||
cli
|
|
||||||
xorl %eax, %eax
|
|
||||||
movl %eax, %cr3 /* Invalidate TLB*/
|
|
||||||
|
|
||||||
/* On hyper threaded cpus invalidating the cache here is
|
|
||||||
* very very bad. Don't.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* setup the data segment */
|
|
||||||
movw %cs, %ax
|
|
||||||
movw %ax, %ds
|
|
||||||
|
|
||||||
data32 lgdt gdtaddr - _secondary_start
|
|
||||||
|
|
||||||
movl %cr0, %eax
|
|
||||||
andl $0x7FFAFFD1, %eax /* PG,AM,WP,NE,TS,EM,MP = 0 */
|
|
||||||
orl $0x60000001, %eax /* CD, NW, PE = 1 */
|
|
||||||
movl %eax, %cr0
|
|
||||||
|
|
||||||
ljmpl $0x10, $1f
|
|
||||||
1:
|
|
||||||
.code32
|
|
||||||
movw $0x18, %ax
|
|
||||||
movw %ax, %ds
|
|
||||||
movw %ax, %es
|
|
||||||
movw %ax, %ss
|
|
||||||
movw %ax, %fs
|
|
||||||
movw %ax, %gs
|
|
||||||
|
|
||||||
/* Enable the local apic, and map it where we expext it */
|
|
||||||
movl $APIC_BASE_MSR, %ecx
|
|
||||||
rdmsr
|
|
||||||
orl $APIC_BASE_MSR_ENABLE, %eax
|
|
||||||
andl $(~APIC_BASE_MSR_ADDR_MASK), %eax
|
|
||||||
orl $APIC_DEFAULT_BASE, %eax
|
|
||||||
wrmsr
|
|
||||||
|
|
||||||
/* Get the apic_id */
|
|
||||||
movl (APIC_ID + APIC_DEFAULT_BASE), %edi
|
|
||||||
shrl $24, %edi
|
|
||||||
|
|
||||||
/* Get the cpu index (CONFIG_MAX_CPUS on error) */
|
|
||||||
movl $-4, %ebx
|
|
||||||
1: addl $4, %ebx
|
|
||||||
cmpl $(CONFIG_MAX_CPUS << 2), %ebx
|
|
||||||
je 2
|
|
||||||
cmpl %edi, initial_apicid(%ebx)
|
|
||||||
jne 1b
|
|
||||||
2: shrl $2, %ebx
|
|
||||||
|
|
||||||
/* set the stack pointer */
|
|
||||||
movl $_estack, %esp
|
|
||||||
movl %ebx, %eax
|
|
||||||
movl $STACK_SIZE, %ebx
|
|
||||||
mull %ebx
|
|
||||||
subl %eax, %esp
|
|
||||||
|
|
||||||
call secondary_cpu_init
|
|
||||||
1: hlt
|
|
||||||
jmp 1b
|
|
||||||
|
|
||||||
gdtaddr:
|
|
||||||
.word gdt_limit /* the table limit */
|
|
||||||
.long gdt /* we know the offset */
|
|
||||||
|
|
||||||
|
|
||||||
.code32
|
|
@ -1,240 +0,0 @@
|
|||||||
#include <smp/start_stop.h>
|
|
||||||
#include <arch/smp/mpspec.h>
|
|
||||||
#include <cpu/p6/apic.h>
|
|
||||||
#include <delay.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <console/console.h>
|
|
||||||
#include <arch/smp/lapic.h>
|
|
||||||
#include <arch/hlt.h>
|
|
||||||
|
|
||||||
|
|
||||||
unsigned long this_processors_id(void)
|
|
||||||
{
|
|
||||||
return lapicid();
|
|
||||||
}
|
|
||||||
|
|
||||||
int processor_index(unsigned long apicid)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
for(i = 0; i < CONFIG_MAX_CPUS; i++) {
|
|
||||||
if (initial_apicid[i] == apicid) {
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void stop_cpu(unsigned long apicid)
|
|
||||||
{
|
|
||||||
int timeout;
|
|
||||||
unsigned long send_status;
|
|
||||||
|
|
||||||
/* send an APIC INIT to myself */
|
|
||||||
apic_write_around(APIC_ICR2, SET_APIC_DEST_FIELD(apicid));
|
|
||||||
apic_write_around(APIC_ICR, APIC_INT_LEVELTRIG | APIC_INT_ASSERT | APIC_DM_INIT);
|
|
||||||
|
|
||||||
/* wait for the ipi send to finish */
|
|
||||||
printk_spew("Waiting for send to finish...\n");
|
|
||||||
timeout = 0;
|
|
||||||
do {
|
|
||||||
printk_spew("+");
|
|
||||||
udelay(100);
|
|
||||||
send_status = apic_read(APIC_ICR) & APIC_ICR_BUSY;
|
|
||||||
} while (send_status && (timeout++ < 1000));
|
|
||||||
if (timeout >= 1000) {
|
|
||||||
printk_err("timed out\n");
|
|
||||||
}
|
|
||||||
mdelay(10);
|
|
||||||
|
|
||||||
printk_spew("Deasserting INIT.\n");
|
|
||||||
/* Deassert the APIC INIT */
|
|
||||||
apic_write_around(APIC_ICR2, SET_APIC_DEST_FIELD(apicid));
|
|
||||||
apic_write_around(APIC_ICR, APIC_INT_LEVELTRIG | APIC_DM_INIT);
|
|
||||||
|
|
||||||
printk_spew("Waiting for send to finish...\n");
|
|
||||||
timeout = 0;
|
|
||||||
do {
|
|
||||||
printk_spew("+");
|
|
||||||
udelay(100);
|
|
||||||
send_status = apic_read(APIC_ICR) & APIC_ICR_BUSY;
|
|
||||||
} while (send_status && (timeout++ < 1000));
|
|
||||||
if (timeout >= 1000) {
|
|
||||||
printk_err("timed out\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
while(1) {
|
|
||||||
hlt();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* This is a lot more paranoid now, since Linux can NOT handle
|
|
||||||
* being told there is a CPU when none exists. So any errors
|
|
||||||
* will return 0, meaning no CPU.
|
|
||||||
*
|
|
||||||
* We actually handling that case by noting which cpus startup
|
|
||||||
* and not telling anyone about the ones that dont.
|
|
||||||
*/
|
|
||||||
int start_cpu(unsigned long apicid)
|
|
||||||
{
|
|
||||||
int timeout;
|
|
||||||
unsigned long send_status, accept_status, start_eip;
|
|
||||||
int j, num_starts, maxlvt;
|
|
||||||
extern char _secondary_start[];
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Starting actual IPI sequence...
|
|
||||||
*/
|
|
||||||
|
|
||||||
printk_spew("Asserting INIT.\n");
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Turn INIT on target chip
|
|
||||||
*/
|
|
||||||
apic_write_around(APIC_ICR2, SET_APIC_DEST_FIELD(apicid));
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Send IPI
|
|
||||||
*/
|
|
||||||
|
|
||||||
apic_write_around(APIC_ICR, APIC_INT_LEVELTRIG | APIC_INT_ASSERT
|
|
||||||
| APIC_DM_INIT);
|
|
||||||
|
|
||||||
printk_spew("Waiting for send to finish...\n");
|
|
||||||
timeout = 0;
|
|
||||||
do {
|
|
||||||
printk_spew("+");
|
|
||||||
udelay(100);
|
|
||||||
send_status = apic_read(APIC_ICR) & APIC_ICR_BUSY;
|
|
||||||
} while (send_status && (timeout++ < 1000));
|
|
||||||
if (timeout >= 1000) {
|
|
||||||
printk_err("CPU %d: First apic write timed out. Disabling\n",
|
|
||||||
apicid);
|
|
||||||
// too bad.
|
|
||||||
printk_err("ESR is 0x%x\n", apic_read(APIC_ESR));
|
|
||||||
if (apic_read(APIC_ESR)) {
|
|
||||||
printk_err("Try to reset ESR\n");
|
|
||||||
apic_write_around(APIC_ESR, 0);
|
|
||||||
printk_err("ESR is 0x%x\n", apic_read(APIC_ESR));
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
mdelay(10);
|
|
||||||
|
|
||||||
printk_spew("Deasserting INIT.\n");
|
|
||||||
|
|
||||||
/* Target chip */
|
|
||||||
apic_write_around(APIC_ICR2, SET_APIC_DEST_FIELD(apicid));
|
|
||||||
|
|
||||||
/* Send IPI */
|
|
||||||
apic_write_around(APIC_ICR, APIC_INT_LEVELTRIG | APIC_DM_INIT);
|
|
||||||
|
|
||||||
printk_spew("Waiting for send to finish...\n");
|
|
||||||
timeout = 0;
|
|
||||||
do {
|
|
||||||
printk_spew("+");
|
|
||||||
udelay(100);
|
|
||||||
send_status = apic_read(APIC_ICR) & APIC_ICR_BUSY;
|
|
||||||
} while (send_status && (timeout++ < 1000));
|
|
||||||
if (timeout >= 1000) {
|
|
||||||
printk_err("CPU %d: Second apic write timed out. Disabling\n",
|
|
||||||
apicid);
|
|
||||||
// too bad.
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
start_eip = (unsigned long)_secondary_start;
|
|
||||||
printk_spew("start_eip=0x%08lx\n", start_eip);
|
|
||||||
|
|
||||||
num_starts = 2;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Run STARTUP IPI loop.
|
|
||||||
*/
|
|
||||||
printk_spew("#startup loops: %d.\n", num_starts);
|
|
||||||
|
|
||||||
maxlvt = 4;
|
|
||||||
|
|
||||||
for (j = 1; j <= num_starts; j++) {
|
|
||||||
printk_spew("Sending STARTUP #%d to %u.\n", j, apicid);
|
|
||||||
apic_read_around(APIC_SPIV);
|
|
||||||
apic_write(APIC_ESR, 0);
|
|
||||||
apic_read(APIC_ESR);
|
|
||||||
printk_spew("After apic_write.\n");
|
|
||||||
|
|
||||||
/*
|
|
||||||
* STARTUP IPI
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Target chip */
|
|
||||||
apic_write_around(APIC_ICR2, SET_APIC_DEST_FIELD(apicid));
|
|
||||||
|
|
||||||
/* Boot on the stack */
|
|
||||||
/* Kick the second */
|
|
||||||
apic_write_around(APIC_ICR, APIC_DM_STARTUP
|
|
||||||
| (start_eip >> 12));
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Give the other CPU some time to accept the IPI.
|
|
||||||
*/
|
|
||||||
udelay(300);
|
|
||||||
|
|
||||||
printk_spew("Startup point 1.\n");
|
|
||||||
|
|
||||||
printk_spew("Waiting for send to finish...\n");
|
|
||||||
timeout = 0;
|
|
||||||
do {
|
|
||||||
printk_spew("+");
|
|
||||||
udelay(100);
|
|
||||||
send_status = apic_read(APIC_ICR) & APIC_ICR_BUSY;
|
|
||||||
} while (send_status && (timeout++ < 1000));
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Give the other CPU some time to accept the IPI.
|
|
||||||
*/
|
|
||||||
udelay(200);
|
|
||||||
/*
|
|
||||||
* Due to the Pentium erratum 3AP.
|
|
||||||
*/
|
|
||||||
if (maxlvt > 3) {
|
|
||||||
apic_read_around(APIC_SPIV);
|
|
||||||
apic_write(APIC_ESR, 0);
|
|
||||||
}
|
|
||||||
accept_status = (apic_read(APIC_ESR) & 0xEF);
|
|
||||||
if (send_status || accept_status)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
printk_spew("After Startup.\n");
|
|
||||||
if (send_status)
|
|
||||||
printk_warning("APIC never delivered???\n");
|
|
||||||
if (accept_status)
|
|
||||||
printk_warning("APIC delivery error (%lx).\n", accept_status);
|
|
||||||
if (send_status || accept_status)
|
|
||||||
return 0;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void startup_other_cpus(unsigned long *processor_map)
|
|
||||||
{
|
|
||||||
unsigned long apicid = this_processors_id();
|
|
||||||
int i;
|
|
||||||
|
|
||||||
/* Assume the cpus are densly packed by apicid */
|
|
||||||
for(i = 0; i < CONFIG_MAX_CPUS; i++) {
|
|
||||||
unsigned long cpu_apicid = initial_apicid[i];
|
|
||||||
if (cpu_apicid == -1) {
|
|
||||||
printk_err("CPU %d not found\n",i);
|
|
||||||
processor_map[i] = 0;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (cpu_apicid == apicid ) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (!start_cpu(cpu_apicid)) {
|
|
||||||
/* Put an error in processor_map[i]? */
|
|
||||||
printk_err("CPU %d/%u would not start!\n",
|
|
||||||
i, cpu_apicid);
|
|
||||||
processor_map[i] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -218,7 +218,6 @@ struct lb_memory *get_lb_mem(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsigned long write_linuxbios_table(
|
unsigned long write_linuxbios_table(
|
||||||
unsigned long *processor_map,
|
|
||||||
struct mem_range *ram,
|
struct mem_range *ram,
|
||||||
unsigned long low_table_start, unsigned long low_table_end,
|
unsigned long low_table_start, unsigned long low_table_end,
|
||||||
unsigned long rom_table_startk, unsigned long rom_table_endk)
|
unsigned long rom_table_startk, unsigned long rom_table_endk)
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
#include "linuxbios_table.h"
|
#include "linuxbios_table.h"
|
||||||
|
|
||||||
struct lb_memory *
|
struct lb_memory *
|
||||||
write_tables(struct mem_range *mem, unsigned long *processor_map)
|
write_tables(struct mem_range *mem)
|
||||||
{
|
{
|
||||||
unsigned long low_table_start, low_table_end;
|
unsigned long low_table_start, low_table_end;
|
||||||
unsigned long rom_table_start, rom_table_end;
|
unsigned long rom_table_start, rom_table_end;
|
||||||
@ -19,28 +19,10 @@ write_tables(struct mem_range *mem, unsigned long *processor_map)
|
|||||||
low_table_start = 0;
|
low_table_start = 0;
|
||||||
low_table_end = 16;
|
low_table_end = 16;
|
||||||
|
|
||||||
#if 0
|
|
||||||
post_code(0x9a);
|
|
||||||
check_pirq_routing_table();
|
|
||||||
/* This table must be betweeen 0xf0000 & 0x100000 */
|
|
||||||
rom_table_end = copy_pirq_routing_table(rom_table_end);
|
|
||||||
rom_table_end = (rom_table_end + 1023) & ~1023;
|
|
||||||
|
|
||||||
/* copy the smp block to address 0 */
|
|
||||||
post_code(0x96);
|
|
||||||
/* The smp table must be in 0-1K, 639K-640K, or 960K-1M */
|
|
||||||
remove_logical_cpus();
|
|
||||||
low_table_end = write_smp_table(low_table_end, processor_map);
|
|
||||||
|
|
||||||
/* Don't write anything in the traditional x86 BIOS data segment */
|
|
||||||
if (low_table_end < 0x500) {
|
|
||||||
low_table_end = 0x500;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
/* The linuxbios table must be in 0-4K or 960K-1M */
|
/* The linuxbios table must be in 0-4K or 960K-1M */
|
||||||
write_linuxbios_table(processor_map, mem,
|
write_linuxbios_table(mem,
|
||||||
low_table_start, low_table_end,
|
low_table_start, low_table_end,
|
||||||
rom_table_start >> 10, rom_table_end >> 10);
|
rom_table_start >> 10, rom_table_end >> 10);
|
||||||
|
|
||||||
return get_lb_mem();
|
return get_lb_mem();
|
||||||
}
|
}
|
||||||
|
@ -440,6 +440,12 @@ static int load_elf_segments(
|
|||||||
end = dest + ptr->s_memsz;
|
end = dest + ptr->s_memsz;
|
||||||
middle = dest + ptr->s_filesz;
|
middle = dest + ptr->s_filesz;
|
||||||
start_offset = ptr->s_offset;
|
start_offset = ptr->s_offset;
|
||||||
|
#if 1
|
||||||
|
if (ptr->s_filesz == 0) {
|
||||||
|
start_offset = offset;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
printk_spew("[ 0x%016lx, %016lx, 0x%016lx) <- %016lx\n",
|
printk_spew("[ 0x%016lx, %016lx, 0x%016lx) <- %016lx\n",
|
||||||
(unsigned long)dest,
|
(unsigned long)dest,
|
||||||
|
@ -27,129 +27,28 @@ it with the version available from LANL.
|
|||||||
|
|
||||||
|
|
||||||
#include <console/console.h>
|
#include <console/console.h>
|
||||||
#include <cpu/cpu.h>
|
|
||||||
#include <mem.h>
|
#include <mem.h>
|
||||||
#include <version.h>
|
#include <version.h>
|
||||||
#include <smp/start_stop.h>
|
|
||||||
#include <boot/tables.h>
|
#include <boot/tables.h>
|
||||||
#include <part/sizeram.h>
|
|
||||||
#include <device/device.h>
|
#include <device/device.h>
|
||||||
#include <device/pci.h>
|
#include <device/pci.h>
|
||||||
#include <device/chip.h>
|
#include <device/chip.h>
|
||||||
#include <delay.h>
|
#include <delay.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <part/hard_reset.h>
|
#include <part/hard_reset.h>
|
||||||
#include <smp/atomic.h>
|
|
||||||
#include <boot/elf.h>
|
#include <boot/elf.h>
|
||||||
|
|
||||||
|
|
||||||
#ifndef CONFIG_MAX_PHYSICAL_CPUS
|
|
||||||
#define CONFIG_MAX_PHYSICAL_CPUS CONFIG_MAX_CPUS
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if CONFIG_FS_STREAM == 1
|
|
||||||
extern int filo(struct lb_memory *);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* The processor map.
|
|
||||||
* Now that SMP is in linuxbios, and Linux counts on us
|
|
||||||
* giving accurate information about processors, we need a map
|
|
||||||
* of what processors are out there. This could be a bit mask,
|
|
||||||
* but we will be optimistic and hope we someday run on
|
|
||||||
* REALLY BIG SMPs. Also we may need more than one bit of
|
|
||||||
* info per processor at some point. I hope we don't need
|
|
||||||
* anything more complex than an int.
|
|
||||||
*/
|
|
||||||
static unsigned long processor_map[CONFIG_MAX_CPUS];
|
|
||||||
|
|
||||||
static struct mem_range *get_ramsize(void)
|
|
||||||
{
|
|
||||||
struct mem_range *mem = 0;
|
|
||||||
if (!mem) {
|
|
||||||
mem = sizeram();
|
|
||||||
}
|
|
||||||
if (!mem) {
|
|
||||||
printk_emerg("No memory size information!\n");
|
|
||||||
for(;;) {
|
|
||||||
/* Ensure this loop is not optimized away */
|
|
||||||
asm volatile("":/* outputs */:/*inputs */ :"memory");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return mem;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#if CONFIG_SMP == 1
|
|
||||||
/* Number of cpus that are currently running in linuxbios */
|
|
||||||
static atomic_t active_cpus = ATOMIC_INIT(1);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Initialize secondary processors.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @todo move this into a method of per cpu data structure.
|
|
||||||
*/
|
|
||||||
void secondary_cpu_init(void)
|
|
||||||
{
|
|
||||||
struct mem_range *mem;
|
|
||||||
unsigned long id;
|
|
||||||
int index;
|
|
||||||
|
|
||||||
atomic_inc(&active_cpus);
|
|
||||||
|
|
||||||
printk_debug("%s\n", __FUNCTION__);
|
|
||||||
mem = get_ramsize();
|
|
||||||
id = cpu_initialize(mem);
|
|
||||||
index = processor_index(id);
|
|
||||||
printk_debug("%s %d/%u\n", __FUNCTION__ , index, id);
|
|
||||||
processor_map[index] = CPU_ENABLED;
|
|
||||||
|
|
||||||
atomic_dec(&active_cpus);
|
|
||||||
stop_cpu(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void wait_for_other_cpus(void)
|
|
||||||
{
|
|
||||||
int old_active_count, active_count;
|
|
||||||
int i;
|
|
||||||
old_active_count = 1;
|
|
||||||
|
|
||||||
active_count = atomic_read(&active_cpus);
|
|
||||||
while (active_count > 1) {
|
|
||||||
if (active_count != old_active_count) {
|
|
||||||
printk_info("Waiting for %d CPUS to stop\n",
|
|
||||||
active_count);
|
|
||||||
old_active_count = active_count;
|
|
||||||
}
|
|
||||||
active_count = atomic_read(&active_cpus);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < CONFIG_MAX_CPUS; i++) {
|
|
||||||
if (!(processor_map[i] & CPU_ENABLED)) {
|
|
||||||
printk_err("CPU %d did not initialize!\n", i);
|
|
||||||
processor_map[i] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
printk_debug("All AP CPUs stopped\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
#else /* CONIFG_SMP */
|
|
||||||
#define wait_for_other_cpus() do {} while(0)
|
|
||||||
#endif /* CONFIG_SMP */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Main program of LinuxBIOS
|
|
||||||
*
|
|
||||||
* @param boot_complete
|
|
||||||
*/
|
|
||||||
void hardwaremain(int boot_complete)
|
void hardwaremain(int boot_complete)
|
||||||
{
|
{
|
||||||
/* Processor ID of the BOOT cpu (i.e. the one running this code) */
|
/* the order here is a bit tricky. We don't want to do much of
|
||||||
unsigned long boot_cpu;
|
* anything that uses config registers until after PciAllocateResources
|
||||||
int boot_index;
|
* since that function also figures out what kind of config strategy
|
||||||
struct mem_range *mem, *tmem;
|
* to use (type 1 or type 2).
|
||||||
|
* so we turn on cache, then worry about PCI setup, then do other
|
||||||
|
* things, so that the other work can use the PciRead* and PciWrite*
|
||||||
|
* functions.
|
||||||
|
*/
|
||||||
struct lb_memory *lb_mem;
|
struct lb_memory *lb_mem;
|
||||||
unsigned long totalmem;
|
|
||||||
|
|
||||||
post_code(0x80);
|
post_code(0x80);
|
||||||
|
|
||||||
@ -160,8 +59,8 @@ void hardwaremain(int boot_complete)
|
|||||||
|
|
||||||
post_code(0x39);
|
post_code(0x39);
|
||||||
printk_notice("LinuxBIOS-%s%s %s %s...\n",
|
printk_notice("LinuxBIOS-%s%s %s %s...\n",
|
||||||
linuxbios_version, linuxbios_extra_version,
|
linuxbios_version, linuxbios_extra_version, linuxbios_build,
|
||||||
linuxbios_build, (boot_complete)?"rebooting":"booting");
|
(boot_complete)?"rebooting":"booting");
|
||||||
|
|
||||||
post_code(0x40);
|
post_code(0x40);
|
||||||
|
|
||||||
@ -172,66 +71,31 @@ void hardwaremain(int boot_complete)
|
|||||||
|
|
||||||
CONFIGURE(CONF_PASS_PRE_PCI);
|
CONFIGURE(CONF_PASS_PRE_PCI);
|
||||||
|
|
||||||
/* determine how software can generate PCI configuration transactions
|
/* pick how to scan the bus. This is first so we can get at memory size. */
|
||||||
* in this system */
|
|
||||||
printk_info("Finding PCI configuration type.\n");
|
printk_info("Finding PCI configuration type.\n");
|
||||||
pci_set_method();
|
pci_set_method();
|
||||||
post_code(0x5f);
|
post_code(0x5f);
|
||||||
|
|
||||||
/* convert static device structures into dynamic device structures
|
|
||||||
* before probing dynamic devices. */
|
|
||||||
enumerate_static_devices();
|
enumerate_static_devices();
|
||||||
|
|
||||||
/* probe the existence of dynamic devices and construct the dynamic
|
|
||||||
* device tree. */
|
|
||||||
dev_enumerate();
|
dev_enumerate();
|
||||||
post_code(0x66);
|
post_code(0x66);
|
||||||
|
/* Now do the real bus.
|
||||||
/* probe and assign the resources required by the dynamic devices */
|
* We round the total ram up a lot for thing like the SISFB, which
|
||||||
|
* shares high memory with the CPU.
|
||||||
|
*/
|
||||||
dev_configure();
|
dev_configure();
|
||||||
post_code(0x88);
|
post_code(0x88);
|
||||||
|
|
||||||
/* enable the resources probed and assigned in dev_configure() */
|
|
||||||
dev_enable();
|
dev_enable();
|
||||||
|
|
||||||
/* do the device specific init in additional to simple resources
|
|
||||||
* allocation performed in dev_enable() */
|
|
||||||
dev_initialize();
|
dev_initialize();
|
||||||
post_code(0x89);
|
post_code(0x89);
|
||||||
|
|
||||||
CONFIGURE(CONF_PASS_POST_PCI);
|
CONFIGURE(CONF_PASS_POST_PCI);
|
||||||
|
|
||||||
/* this is done last because some devices may 'steal' memory from
|
/* Now that we have collected all of our information
|
||||||
* the system during device initialization. */
|
* write our configuration tables.
|
||||||
mem = get_ramsize();
|
*/
|
||||||
post_code(0x70);
|
lb_mem = write_tables();
|
||||||
for (totalmem = 0, tmem = mem; tmem->sizek; tmem++) {
|
|
||||||
totalmem += tmem->sizek;
|
|
||||||
}
|
|
||||||
/* Round to the nearest mega */
|
|
||||||
printk_info("totalram: %ldM\n", (totalmem + 512) >> 10);
|
|
||||||
|
|
||||||
/* fully initialize the boot processor */
|
|
||||||
boot_cpu = cpu_initialize(mem);
|
|
||||||
boot_index = processor_index(boot_cpu);
|
|
||||||
printk_spew("BOOT CPU is %d\n", boot_cpu);
|
|
||||||
processor_map[boot_index] = CPU_BOOTPROCESSOR|CPU_ENABLED;
|
|
||||||
|
|
||||||
/* start up other processors, it works like a pthread_create() or
|
|
||||||
* fork(), instead of running the initialization code for all devices
|
|
||||||
* as the boot processor, they start from secondary_cpu_init(), doing
|
|
||||||
* cpu initialization only. */
|
|
||||||
post_code(0x75);
|
|
||||||
startup_other_cpus(processor_map);
|
|
||||||
|
|
||||||
/* like pthread_join() or wait(), wait other processors finishing
|
|
||||||
* their execution of secondary_cpu_init() and make certain we are
|
|
||||||
* the only cpu running in LinuxBIOS */
|
|
||||||
wait_for_other_cpus();
|
|
||||||
|
|
||||||
/* Now that we have collected all of our information, write our
|
|
||||||
* configuration tables. */
|
|
||||||
lb_mem = write_tables(mem, processor_map);
|
|
||||||
|
|
||||||
CONFIGURE(CONF_PASS_PRE_BOOT);
|
CONFIGURE(CONF_PASS_PRE_BOOT);
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
uses HAVE_OPTION_TABLE
|
uses HAVE_OPTION_TABLE
|
||||||
|
|
||||||
makedefine CPP:= $(CC) -no-gcc -x assembler-with-cpp -DASSEMBLY -E
|
makedefine CPP:= $(CC) -x assembler-with-cpp -DASSEMBLY -E
|
||||||
makedefine LIBGCC_FILE_NAME := $(shell $(CC) -print-libgcc-file-name)
|
makedefine LIBGCC_FILE_NAME := $(shell $(CC) -print-libgcc-file-name)
|
||||||
makedefine GCC_INC_DIR := $(shell $(CC) -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp")
|
makedefine GCC_INC_DIR := $(shell $(CC) -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp")
|
||||||
|
|
||||||
|
@ -81,6 +81,11 @@ define i686
|
|||||||
export used
|
export used
|
||||||
comment "We're a 686"
|
comment "We're a 686"
|
||||||
end
|
end
|
||||||
|
define i786
|
||||||
|
default none
|
||||||
|
export used
|
||||||
|
comment "We're a 786"
|
||||||
|
end
|
||||||
define CPU_FIXUP
|
define CPU_FIXUP
|
||||||
default none
|
default none
|
||||||
export used
|
export used
|
||||||
@ -119,52 +124,62 @@ end
|
|||||||
define LINUXBIOS_VERSION
|
define LINUXBIOS_VERSION
|
||||||
default "1.1.6"
|
default "1.1.6"
|
||||||
export always
|
export always
|
||||||
|
format "\"%s\""
|
||||||
comment "LinuxBIOS version"
|
comment "LinuxBIOS version"
|
||||||
end
|
end
|
||||||
define LINUXBIOS_EXTRA_VERSION
|
define LINUXBIOS_EXTRA_VERSION
|
||||||
default ""
|
default ""
|
||||||
export used
|
export used
|
||||||
|
format "\"%s\""
|
||||||
comment "LinuxBIOS extra version"
|
comment "LinuxBIOS extra version"
|
||||||
end
|
end
|
||||||
define LINUXBIOS_BUILD
|
define LINUXBIOS_BUILD
|
||||||
default "$(shell date)"
|
default "$(shell date)"
|
||||||
export always
|
export always
|
||||||
|
format "\"%s\""
|
||||||
comment "Build date"
|
comment "Build date"
|
||||||
end
|
end
|
||||||
define LINUXBIOS_COMPILE_TIME
|
define LINUXBIOS_COMPILE_TIME
|
||||||
default "$(shell date +%T)"
|
default "$(shell date +%T)"
|
||||||
export always
|
export always
|
||||||
|
format "\"%s\""
|
||||||
comment "Build time"
|
comment "Build time"
|
||||||
end
|
end
|
||||||
define LINUXBIOS_COMPILE_BY
|
define LINUXBIOS_COMPILE_BY
|
||||||
default "$(shell whoami)"
|
default "$(shell whoami)"
|
||||||
export always
|
export always
|
||||||
|
format "\"%s\""
|
||||||
comment "Who build this image"
|
comment "Who build this image"
|
||||||
end
|
end
|
||||||
define LINUXBIOS_COMPILE_HOST
|
define LINUXBIOS_COMPILE_HOST
|
||||||
default "$(shell hostname)"
|
default "$(shell hostname)"
|
||||||
export always
|
export always
|
||||||
|
format "\"%s\""
|
||||||
comment "Build host"
|
comment "Build host"
|
||||||
end
|
end
|
||||||
|
|
||||||
define LINUXBIOS_COMPILE_DOMAIN
|
define LINUXBIOS_COMPILE_DOMAIN
|
||||||
default "$(shell dnsdomainname)"
|
default "$(shell dnsdomainname)"
|
||||||
export always
|
export always
|
||||||
|
format "\"%s\""
|
||||||
comment "Build domain name"
|
comment "Build domain name"
|
||||||
end
|
end
|
||||||
define LINUXBIOS_COMPILER
|
define LINUXBIOS_COMPILER
|
||||||
default "$(shell $(CC) $(CFLAGS) -v 2>&1 | tail -n 1)"
|
default "$(shell $(CC) $(CFLAGS) -v 2>&1 | tail -n 1)"
|
||||||
export always
|
export always
|
||||||
|
format "\"%s\""
|
||||||
comment "Build compiler"
|
comment "Build compiler"
|
||||||
end
|
end
|
||||||
define LINUXBIOS_LINKER
|
define LINUXBIOS_LINKER
|
||||||
default "$(shell $(CC) -Wl,-v 2>&1 | grep version | tail -n 1)"
|
default "$(shell $(CC) -Wl,-v 2>&1 | grep version | tail -n 1)"
|
||||||
export always
|
export always
|
||||||
|
format "\"%s\""
|
||||||
comment "Build linker"
|
comment "Build linker"
|
||||||
end
|
end
|
||||||
define LINUXBIOS_ASSEMBLER
|
define LINUXBIOS_ASSEMBLER
|
||||||
default "$(shell touch dummy.s ; $(CC) -c -Wa,-v dummy.s 2>&1; rm -f dummy.s dummy.o )"
|
default "$(shell touch dummy.s ; $(CC) -c -Wa,-v dummy.s 2>&1; rm -f dummy.s dummy.o )"
|
||||||
export always
|
export always
|
||||||
|
format "\"%s\""
|
||||||
comment "Build assembler"
|
comment "Build assembler"
|
||||||
end
|
end
|
||||||
define CONFIG_CHIP_CONFIGURE
|
define CONFIG_CHIP_CONFIGURE
|
||||||
@ -459,13 +474,26 @@ end
|
|||||||
define MAINBOARD_PART_NUMBER
|
define MAINBOARD_PART_NUMBER
|
||||||
default "Part_number_not_set"
|
default "Part_number_not_set"
|
||||||
export always
|
export always
|
||||||
|
format "\"%s\""
|
||||||
comment "Part number of mainboard"
|
comment "Part number of mainboard"
|
||||||
end
|
end
|
||||||
define MAINBOARD_VENDOR
|
define MAINBOARD_VENDOR
|
||||||
default "Vendor_not_set"
|
default "Vendor_not_set"
|
||||||
export always
|
export always
|
||||||
|
format "\"%s\""
|
||||||
comment "Vendor of mainboard"
|
comment "Vendor of mainboard"
|
||||||
end
|
end
|
||||||
|
define MAINBOARD_PCI_SUBSYSTEM_VENDOR_ID
|
||||||
|
default 0
|
||||||
|
export always
|
||||||
|
comment "PCI Vendor ID of mainboard manufacturer"
|
||||||
|
end
|
||||||
|
define MAINBOARD_PCI_SUBSYSTEM_DEVICE_ID
|
||||||
|
default 0
|
||||||
|
format "0x%x"
|
||||||
|
export always
|
||||||
|
comment "PCI susbsystem device id assigned my mainboard manufacturer"
|
||||||
|
end
|
||||||
define MAINBOARD_POWER_ON_AFTER_POWER_FAIL
|
define MAINBOARD_POWER_ON_AFTER_POWER_FAIL
|
||||||
default none
|
default none
|
||||||
export used
|
export used
|
||||||
@ -500,11 +528,6 @@ define CONFIG_MAX_CPUS
|
|||||||
export always
|
export always
|
||||||
comment "Maximum CPU count for this machine"
|
comment "Maximum CPU count for this machine"
|
||||||
end
|
end
|
||||||
define CONFIG_MAX_PHYSICAL_CPUS
|
|
||||||
default {CONFIG_MAX_CPUS}
|
|
||||||
export always
|
|
||||||
comment "Physical CPU count for this machine"
|
|
||||||
end
|
|
||||||
define CONFIG_LOGICAL_CPUS
|
define CONFIG_LOGICAL_CPUS
|
||||||
default 0
|
default 0
|
||||||
export always
|
export always
|
||||||
|
@ -48,6 +48,9 @@ SECTIONS
|
|||||||
pci_drivers = . ;
|
pci_drivers = . ;
|
||||||
*(.rodata.pci_driver)
|
*(.rodata.pci_driver)
|
||||||
epci_drivers = . ;
|
epci_drivers = . ;
|
||||||
|
cpu_drivers = . ;
|
||||||
|
*(.rodata.cpu_driver)
|
||||||
|
ecpu_drivers = . ;
|
||||||
*(.rodata)
|
*(.rodata)
|
||||||
*(.rodata.*)
|
*(.rodata.*)
|
||||||
/*
|
/*
|
||||||
@ -84,10 +87,11 @@ SECTIONS
|
|||||||
}
|
}
|
||||||
_ebss = .;
|
_ebss = .;
|
||||||
_end = .;
|
_end = .;
|
||||||
|
. = ALIGN(STACK_SIZE);
|
||||||
_stack = .;
|
_stack = .;
|
||||||
.stack . : {
|
.stack . : {
|
||||||
/* Reserve a stack for each possible cpu, +1 extra */
|
/* Reserve a stack for each possible cpu */
|
||||||
. = ((CONFIG_MAX_CPUS * STACK_SIZE) + STACK_SIZE) ;
|
. = (CONFIG_MAX_CPUS * STACK_SIZE) ;
|
||||||
}
|
}
|
||||||
_estack = .;
|
_estack = .;
|
||||||
_heap = .;
|
_heap = .;
|
||||||
@ -105,5 +109,6 @@ SECTIONS
|
|||||||
/DISCARD/ : {
|
/DISCARD/ : {
|
||||||
*(.comment)
|
*(.comment)
|
||||||
*(.note)
|
*(.note)
|
||||||
|
*(.note.*)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
1
src/cpu/simple_init/Config.lb
Normal file
1
src/cpu/simple_init/Config.lb
Normal file
@ -0,0 +1 @@
|
|||||||
|
object simple_cpu_init.o
|
26
src/cpu/simple_init/simple_cpu_init.c
Normal file
26
src/cpu/simple_init/simple_cpu_init.c
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#include <linux/console.h>
|
||||||
|
#include <device/device.h>
|
||||||
|
#include <device/path.h>
|
||||||
|
#include <device/cpu.h>
|
||||||
|
|
||||||
|
#if CONFIG_SMP
|
||||||
|
#error "This Configuration does not support SMP"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void initialize_cpus(device_t root)
|
||||||
|
{
|
||||||
|
struct device_path cpu_path;
|
||||||
|
struct cpu_info *info;
|
||||||
|
|
||||||
|
/* Find the info struct for this cpu */
|
||||||
|
info = cpu_info();
|
||||||
|
|
||||||
|
/* Get the device path of the boot cpu */
|
||||||
|
cpu_path.type = DEVICE_PATH_BOOT_CPU;
|
||||||
|
|
||||||
|
/* Find the device struct for the boot cpu */
|
||||||
|
info->cpu = alloc_find_dev(root->link[1], &cpu_path);
|
||||||
|
|
||||||
|
/* Initialize the bootstrap processor */
|
||||||
|
cpu_initialize();
|
||||||
|
}
|
@ -69,7 +69,7 @@ void chip_enumerate(struct chip *chip)
|
|||||||
printk_debug("Enumerating: %s\n", chip->control->name);
|
printk_debug("Enumerating: %s\n", chip->control->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < MAX_CHIP_PATHS; i++) {
|
for(i = 0; i < MAX_CHIP_PATHS; i++) {
|
||||||
int identical_paths;
|
int identical_paths;
|
||||||
identical_paths =
|
identical_paths =
|
||||||
(i > 0) &&
|
(i > 0) &&
|
||||||
@ -90,7 +90,7 @@ void chip_enumerate(struct chip *chip)
|
|||||||
device_t dev;
|
device_t dev;
|
||||||
int i = 1;
|
int i = 1;
|
||||||
dev = chip->dev;
|
dev = chip->dev;
|
||||||
while (dev && (i != bus)) {
|
while(dev && (i != bus)) {
|
||||||
dev = dev->next;
|
dev = dev->next;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
@ -103,21 +103,21 @@ void chip_enumerate(struct chip *chip)
|
|||||||
dev = alloc_dev(parent, &chip->path[i].path);
|
dev = alloc_dev(parent, &chip->path[i].path);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
link += 1;
|
link += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dev) {
|
if (dev) {
|
||||||
struct chip_resource *res, *res_limit;
|
struct chip_resource *res, *res_limit;
|
||||||
printk_spew("path (%p) %s %s",
|
printk_spew("path (%p) %s %s",
|
||||||
dev, dev_path(dev),
|
dev, dev_path(dev), identical_paths?"identical":"");
|
||||||
identical_paths?"identical":"");
|
|
||||||
printk_spew(" parent: (%p) %s\n",
|
printk_spew(" parent: (%p) %s\n",
|
||||||
dev->bus->dev, dev_path(dev->bus->dev));
|
dev->bus->dev, dev_path(dev->bus->dev));
|
||||||
dev->chip = chip;
|
dev->chip = chip;
|
||||||
dev->enabled = chip->path[i].enabled;
|
dev->enabled = chip->path[i].enabled;
|
||||||
dev->links = link + 1;
|
dev->links = link + 1;
|
||||||
for (child = chip->children; child; child = child->next) {
|
for(child = chip->children; child; child = child->next) {
|
||||||
if (!child->bus && child->link == i) {
|
if (!child->bus && child->link == i) {
|
||||||
child->bus = &dev->link[link];
|
child->bus = &dev->link[link];
|
||||||
}
|
}
|
||||||
@ -138,8 +138,10 @@ void chip_enumerate(struct chip *chip)
|
|||||||
chip->dev = dev;
|
chip->dev = dev;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (chip->children && !chip->dev) {
|
||||||
for (child = chip->children; child; child = child->next) {
|
die("No device but children?");
|
||||||
|
}
|
||||||
|
for(child = chip->children; child; child = child->next) {
|
||||||
if (!child->bus) {
|
if (!child->bus) {
|
||||||
child->bus = &chip->dev->link[0];
|
child->bus = &chip->dev->link[0];
|
||||||
}
|
}
|
||||||
@ -167,8 +169,7 @@ void chip_enumerate(struct chip *chip)
|
|||||||
static void enumerate_static_device_chain(struct chip *root)
|
static void enumerate_static_device_chain(struct chip *root)
|
||||||
{
|
{
|
||||||
struct chip *chip;
|
struct chip *chip;
|
||||||
|
for(chip = root; chip; chip = chip->next) {
|
||||||
for (chip = root; chip; chip = chip->next) {
|
|
||||||
void (*enumerate)(struct chip *chip);
|
void (*enumerate)(struct chip *chip);
|
||||||
enumerate = chip_enumerate;
|
enumerate = chip_enumerate;
|
||||||
if (chip->control && chip->control->enumerate) {
|
if (chip->control && chip->control->enumerate) {
|
||||||
@ -177,7 +178,7 @@ static void enumerate_static_device_chain(struct chip *root)
|
|||||||
enumerate(chip);
|
enumerate(chip);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (chip = root; chip; chip = chip->next) {
|
for(chip = root; chip; chip = chip->next) {
|
||||||
if (chip->children) {
|
if (chip->children) {
|
||||||
enumerate_static_device_chain(chip->children);
|
enumerate_static_device_chain(chip->children);
|
||||||
}
|
}
|
||||||
@ -208,5 +209,6 @@ static void enumerate_static_device_chain(struct chip *root)
|
|||||||
void enumerate_static_devices(void)
|
void enumerate_static_devices(void)
|
||||||
{
|
{
|
||||||
printk_info("Enumerating static devices...\n");
|
printk_info("Enumerating static devices...\n");
|
||||||
|
static_root.dev = &dev_root;
|
||||||
enumerate_static_device_chain(&static_root);
|
enumerate_static_device_chain(&static_root);
|
||||||
}
|
}
|
||||||
|
@ -54,10 +54,9 @@ device_t alloc_dev(struct bus *parent, struct device_path *path)
|
|||||||
int link;
|
int link;
|
||||||
|
|
||||||
/* Find the last child of our parent */
|
/* Find the last child of our parent */
|
||||||
for (child = parent->children; child && child->sibling; ) {
|
for(child = parent->children; child && child->sibling; ) {
|
||||||
child = child->sibling;
|
child = child->sibling;
|
||||||
}
|
}
|
||||||
|
|
||||||
dev = malloc(sizeof(*dev));
|
dev = malloc(sizeof(*dev));
|
||||||
if (dev == 0) {
|
if (dev == 0) {
|
||||||
die("DEV: out of memory.\n");
|
die("DEV: out of memory.\n");
|
||||||
@ -72,19 +71,18 @@ device_t alloc_dev(struct bus *parent, struct device_path *path)
|
|||||||
last_dev_p = &dev->next;
|
last_dev_p = &dev->next;
|
||||||
|
|
||||||
/* Initialize the back pointers in the link fields */
|
/* Initialize the back pointers in the link fields */
|
||||||
for (link = 0; link < MAX_LINKS; link++) {
|
for(link = 0; link < MAX_LINKS; link++) {
|
||||||
dev->link[link].dev = dev;
|
dev->link[link].dev = dev;
|
||||||
dev->link[link].link = link;
|
dev->link[link].link = link;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add the new device as a children of the bus. */
|
/* Add the new device to the list of children of the bus. */
|
||||||
dev->bus = parent;
|
dev->bus = parent;
|
||||||
if (child) {
|
if (child) {
|
||||||
child->sibling = dev;
|
child->sibling = dev;
|
||||||
} else {
|
} else {
|
||||||
parent->children = dev;
|
parent->children = dev;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we don't have any other information about a device enable it */
|
/* If we don't have any other information about a device enable it */
|
||||||
dev->enabled = 1;
|
dev->enabled = 1;
|
||||||
|
|
||||||
@ -125,7 +123,7 @@ static void read_resources(struct bus *bus)
|
|||||||
struct device *curdev;
|
struct device *curdev;
|
||||||
|
|
||||||
/* Walk through all of the devices and find which resources they need. */
|
/* Walk through all of the devices and find which resources they need. */
|
||||||
for (curdev = bus->children; curdev; curdev = curdev->sibling) {
|
for(curdev = bus->children; curdev; curdev = curdev->sibling) {
|
||||||
unsigned links;
|
unsigned links;
|
||||||
int i;
|
int i;
|
||||||
if (curdev->resources > 0) {
|
if (curdev->resources > 0) {
|
||||||
@ -133,22 +131,20 @@ static void read_resources(struct bus *bus)
|
|||||||
}
|
}
|
||||||
if (!curdev->ops || !curdev->ops->read_resources) {
|
if (!curdev->ops || !curdev->ops->read_resources) {
|
||||||
printk_err("%s missing read_resources\n",
|
printk_err("%s missing read_resources\n",
|
||||||
dev_path(curdev));
|
dev_path(curdev));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!curdev->enabled) {
|
if (!curdev->enabled) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
curdev->ops->read_resources(curdev);
|
curdev->ops->read_resources(curdev);
|
||||||
|
|
||||||
/* Read in subtractive resources behind the current device */
|
/* Read in subtractive resources behind the current device */
|
||||||
links = 0;
|
links = 0;
|
||||||
for (i = 0; i < curdev->resources; i++) {
|
for(i = 0; i < curdev->resources; i++) {
|
||||||
struct resource *resource;
|
struct resource *resource;
|
||||||
resource = &curdev->resource[i];
|
resource = &curdev->resource[i];
|
||||||
if ((resource->flags & IORESOURCE_SUBTRACTIVE) &&
|
if ((resource->flags & IORESOURCE_SUBTRACTIVE) &&
|
||||||
(!(links & (1 << resource->index))))
|
(!(links & (1 << resource->index))))
|
||||||
{
|
{
|
||||||
links |= (1 << resource->index);
|
links |= (1 << resource->index);
|
||||||
read_resources(&curdev->link[resource->index]);
|
read_resources(&curdev->link[resource->index]);
|
||||||
@ -166,7 +162,7 @@ struct pick_largest_state {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static void pick_largest_resource(struct pick_largest_state *state,
|
static void pick_largest_resource(struct pick_largest_state *state,
|
||||||
struct device *dev, struct resource *resource)
|
struct device *dev, struct resource *resource)
|
||||||
{
|
{
|
||||||
struct resource *last;
|
struct resource *last;
|
||||||
last = state->last;
|
last = state->last;
|
||||||
@ -175,33 +171,31 @@ static void pick_largest_resource(struct pick_largest_state *state,
|
|||||||
state->seen_last = 1;
|
state->seen_last = 1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (last &&
|
if (last && (
|
||||||
((last->align < resource->align) ||
|
(last->align < resource->align) ||
|
||||||
((last->align == resource->align) &&
|
((last->align == resource->align) &&
|
||||||
(last->size < resource->size)) ||
|
(last->size < resource->size)) ||
|
||||||
((last->align == resource->align) &&
|
((last->align == resource->align) &&
|
||||||
(last->size == resource->size) &&
|
(last->size == resource->size) &&
|
||||||
(!state->seen_last)))) {
|
(!state->seen_last)))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!state->result ||
|
if (!state->result ||
|
||||||
(state->result->align < resource->align) ||
|
(state->result->align < resource->align) ||
|
||||||
((state->result->align == resource->align) &&
|
((state->result->align == resource->align) &&
|
||||||
(state->result->size < resource->size))) {
|
(state->result->size < resource->size))) {
|
||||||
state->result_dev = dev;
|
state->result_dev = dev;
|
||||||
state->result = resource;
|
state->result = resource;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void find_largest_resource(struct pick_largest_state *state,
|
static void find_largest_resource(struct pick_largest_state *state,
|
||||||
struct bus *bus, unsigned long type_mask,
|
struct bus *bus, unsigned long type_mask, unsigned long type)
|
||||||
unsigned long type)
|
|
||||||
{
|
{
|
||||||
struct device *curdev;
|
struct device *curdev;
|
||||||
|
for(curdev = bus->children; curdev; curdev = curdev->sibling) {
|
||||||
for (curdev = bus->children; curdev; curdev = curdev->sibling) {
|
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < curdev->resources; i++) {
|
for(i = 0; i < curdev->resources; i++) {
|
||||||
struct resource *resource = &curdev->resource[i];
|
struct resource *resource = &curdev->resource[i];
|
||||||
/* If it isn't the right kind of resource ignore it */
|
/* If it isn't the right kind of resource ignore it */
|
||||||
if ((resource->flags & type_mask) != type) {
|
if ((resource->flags & type_mask) != type) {
|
||||||
@ -211,8 +205,7 @@ static void find_largest_resource(struct pick_largest_state *state,
|
|||||||
if (resource->flags & IORESOURCE_SUBTRACTIVE) {
|
if (resource->flags & IORESOURCE_SUBTRACTIVE) {
|
||||||
struct bus *subbus;
|
struct bus *subbus;
|
||||||
subbus = &curdev->link[resource->index];
|
subbus = &curdev->link[resource->index];
|
||||||
find_largest_resource(state, subbus,
|
find_largest_resource(state, subbus, type_mask, type);
|
||||||
type_mask, type);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
/* See if this is the largest resource */
|
/* See if this is the largest resource */
|
||||||
@ -281,12 +274,12 @@ void compute_allocate_resource(
|
|||||||
min_align = 0;
|
min_align = 0;
|
||||||
base = bridge->base;
|
base = bridge->base;
|
||||||
|
|
||||||
printk_spew("%s compute_allocate_%s: base: %08lx size: %08lx "
|
printk_spew("%s compute_allocate_%s: base: %08lx size: %08lx align: %d gran: %d\n",
|
||||||
"align: %d gran: %d\n",
|
dev_path(bus->dev),
|
||||||
dev_path(bus->dev),
|
(bridge->flags & IORESOURCE_IO)? "io":
|
||||||
(bridge->flags & IORESOURCE_IO)? "io":
|
(bridge->flags & IORESOURCE_PREFETCH)? "prefmem" : "mem",
|
||||||
(bridge->flags & IORESOURCE_PREFETCH)? "prefmem" : "mem",
|
base, bridge->size, bridge->align, bridge->gran);
|
||||||
base, bridge->size, bridge->align, bridge->gran);
|
|
||||||
|
|
||||||
/* We want different minimum alignments for different kinds of
|
/* We want different minimum alignments for different kinds of
|
||||||
* resources. These minimums are not device type specific
|
* resources. These minimums are not device type specific
|
||||||
@ -305,9 +298,10 @@ void compute_allocate_resource(
|
|||||||
/* Remember I haven't found anything yet. */
|
/* Remember I haven't found anything yet. */
|
||||||
resource = 0;
|
resource = 0;
|
||||||
|
|
||||||
/* Walk through all the devices on the current bus and compute the
|
/* Walk through all the devices on the current bus and
|
||||||
* addresses */
|
* compute the addresses.
|
||||||
while ((dev = largest_resource(bus, &resource, type_mask, type))) {
|
*/
|
||||||
|
while((dev = largest_resource(bus, &resource, type_mask, type))) {
|
||||||
unsigned long size;
|
unsigned long size;
|
||||||
/* Do NOT I repeat do not ignore resources which have zero size.
|
/* Do NOT I repeat do not ignore resources which have zero size.
|
||||||
* If they need to be ignored dev->read_resources should not even
|
* If they need to be ignored dev->read_resources should not even
|
||||||
@ -355,12 +349,13 @@ void compute_allocate_resource(
|
|||||||
resource->flags &= ~IORESOURCE_STORED;
|
resource->flags &= ~IORESOURCE_STORED;
|
||||||
base += size;
|
base += size;
|
||||||
|
|
||||||
printk_spew("%s %02x * [0x%08lx - 0x%08lx] %s\n",
|
printk_spew(
|
||||||
dev_path(dev),
|
"%s %02x * [0x%08lx - 0x%08lx] %s\n",
|
||||||
resource->index, resource->base,
|
dev_path(dev),
|
||||||
resource->base + resource->size - 1,
|
resource->index,
|
||||||
(resource->flags & IORESOURCE_IO)? "io":
|
resource->base, resource->base + resource->size - 1,
|
||||||
(resource->flags & IORESOURCE_PREFETCH)? "prefmem": "mem");
|
(resource->flags & IORESOURCE_IO)? "io":
|
||||||
|
(resource->flags & IORESOURCE_PREFETCH)? "prefmem": "mem");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* A pci bridge resource does not need to be a power
|
/* A pci bridge resource does not need to be a power
|
||||||
@ -372,10 +367,10 @@ void compute_allocate_resource(
|
|||||||
bridge->size = round(base, 1UL << bridge->gran) - bridge->base;
|
bridge->size = round(base, 1UL << bridge->gran) - bridge->base;
|
||||||
|
|
||||||
printk_spew("%s compute_allocate_%s: base: %08lx size: %08lx align: %d gran: %d done\n",
|
printk_spew("%s compute_allocate_%s: base: %08lx size: %08lx align: %d gran: %d done\n",
|
||||||
dev_path(dev),
|
dev_path(dev),
|
||||||
(bridge->flags & IORESOURCE_IO)? "io":
|
(bridge->flags & IORESOURCE_IO)? "io":
|
||||||
(bridge->flags & IORESOURCE_PREFETCH)? "prefmem" : "mem",
|
(bridge->flags & IORESOURCE_PREFETCH)? "prefmem" : "mem",
|
||||||
base, bridge->size, bridge->align, bridge->gran);
|
base, bridge->size, bridge->align, bridge->gran);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -386,14 +381,16 @@ static void allocate_vga_resource(void)
|
|||||||
#warning "This function knows to much about PCI stuff, it should be just a ietrator/visitor."
|
#warning "This function knows to much about PCI stuff, it should be just a ietrator/visitor."
|
||||||
|
|
||||||
/* FIXME handle the VGA pallette snooping */
|
/* FIXME handle the VGA pallette snooping */
|
||||||
struct device *dev, *vga = 0;
|
struct device *dev, *vga;
|
||||||
struct bus *bus = 0;
|
struct bus *bus;
|
||||||
|
bus = 0;
|
||||||
for (dev = all_devices; dev; dev = dev->next) {
|
vga = 0;
|
||||||
|
for(dev = all_devices; dev; dev = dev->next) {
|
||||||
if (((dev->class >> 16) == PCI_BASE_CLASS_DISPLAY) &&
|
if (((dev->class >> 16) == PCI_BASE_CLASS_DISPLAY) &&
|
||||||
((dev->class >> 8) != PCI_CLASS_DISPLAY_OTHER)) {
|
((dev->class >> 8) != PCI_CLASS_DISPLAY_OTHER)) {
|
||||||
if (!vga) {
|
if (!vga) {
|
||||||
printk_debug("Allocating VGA resource %s\n", dev_path(dev));
|
printk_debug("Allocating VGA resource %s\n",
|
||||||
|
dev_path(dev));
|
||||||
vga = dev;
|
vga = dev;
|
||||||
}
|
}
|
||||||
if (vga == dev) {
|
if (vga == dev) {
|
||||||
@ -408,9 +405,8 @@ static void allocate_vga_resource(void)
|
|||||||
if (vga) {
|
if (vga) {
|
||||||
bus = vga->bus;
|
bus = vga->bus;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now walk up the bridges setting the VGA enable */
|
/* Now walk up the bridges setting the VGA enable */
|
||||||
while (bus) {
|
while(bus) {
|
||||||
bus->bridge_ctrl |= PCI_BRIDGE_CTL_VGA;
|
bus->bridge_ctrl |= PCI_BRIDGE_CTL_VGA;
|
||||||
bus = (bus == bus->dev->bus)? 0 : bus->dev->bus;
|
bus = (bus == bus->dev->bus)? 0 : bus->dev->bus;
|
||||||
}
|
}
|
||||||
@ -432,7 +428,7 @@ void assign_resources(struct bus *bus)
|
|||||||
for (curdev = bus->children; curdev; curdev = curdev->sibling) {
|
for (curdev = bus->children; curdev; curdev = curdev->sibling) {
|
||||||
if (!curdev->ops || !curdev->ops->set_resources) {
|
if (!curdev->ops || !curdev->ops->set_resources) {
|
||||||
printk_err("%s missing set_resources\n",
|
printk_err("%s missing set_resources\n",
|
||||||
dev_path(curdev));
|
dev_path(curdev));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!curdev->enabled) {
|
if (!curdev->enabled) {
|
||||||
@ -474,25 +470,26 @@ void enable_resources(struct device *dev)
|
|||||||
* @brief Determine the existence of dynamic devices and construct dynamic
|
* @brief Determine the existence of dynamic devices and construct dynamic
|
||||||
* device tree.
|
* device tree.
|
||||||
*
|
*
|
||||||
* Start form the root device 'dev_root', scan the buses in the system
|
* Start from the root device 'dev_root', scan the buses in the system
|
||||||
* recursively, build the dynamic device tree according to the result
|
* recursively, build the dynamic device tree according to the result
|
||||||
* of the probe.
|
* of the probe.
|
||||||
*
|
*
|
||||||
* This function has no idea how to scan and probe buses and devices at all.
|
* This function has no idea how to scan and probe buses and devices at all.
|
||||||
* It depends on the bus/device specific scan_bus() method to do it. The
|
* It depends on the bus/device specific scan_bus() method to do it. The
|
||||||
* scan_bus() function also have to create the device structure and attach
|
* scan_bus() function also has to create the device structure and attach
|
||||||
* it to the device tree.
|
* it to the device tree.
|
||||||
*/
|
*/
|
||||||
void dev_enumerate(void)
|
void dev_enumerate(void)
|
||||||
{
|
{
|
||||||
struct device *root;
|
struct device *root;
|
||||||
unsigned subordinate;
|
unsigned subordinate;
|
||||||
|
|
||||||
printk_info("Enumerating buses...\n");
|
printk_info("Enumerating buses...\n");
|
||||||
|
|
||||||
root = &dev_root;
|
root = &dev_root;
|
||||||
|
if (!root->ops || !root->ops->scan_bus) {
|
||||||
|
printk_err("dev_root missing scan_bus operation");
|
||||||
|
return;
|
||||||
|
}
|
||||||
subordinate = root->ops->scan_bus(root, 0);
|
subordinate = root->ops->scan_bus(root, 0);
|
||||||
|
|
||||||
printk_info("done\n");
|
printk_info("done\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -510,29 +507,38 @@ void dev_enumerate(void)
|
|||||||
*/
|
*/
|
||||||
void dev_configure(void)
|
void dev_configure(void)
|
||||||
{
|
{
|
||||||
struct device *root = &dev_root;
|
struct device *root;
|
||||||
|
|
||||||
printk_info("Allocating resources...\n");
|
printk_info("Allocating resources...\n");
|
||||||
|
|
||||||
|
root = &dev_root;
|
||||||
|
if (!root->ops || !root->ops->read_resources) {
|
||||||
|
printk_err("dev_root missing read_resources\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!root->ops || !root->ops->set_resources) {
|
||||||
|
printk_err("dev_root missing set_resources\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
root->ops->read_resources(root);
|
root->ops->read_resources(root);
|
||||||
|
|
||||||
/* Make certain the io devices are allocated somewhere safe. */
|
/* Make certain the io devices are allocated somewhere safe. */
|
||||||
root->resource[0].base = DEVICE_IO_START;
|
root->resource[0].base = DEVICE_IO_START;
|
||||||
root->resource[0].flags |= IORESOURCE_ASSIGNED;
|
root->resource[0].flags |= IORESOURCE_ASSIGNED;
|
||||||
root->resource[0].flags &= ~IORESOURCE_STORED;
|
root->resource[0].flags &= ~IORESOURCE_STORED;
|
||||||
|
/* Now reallocate the pci resources memory with the
|
||||||
/* Now reallocate the pci resources memory with the highest
|
* highest addresses I can manage.
|
||||||
* addresses I can manage.*/
|
*/
|
||||||
root->resource[1].base =
|
root->resource[1].base =
|
||||||
round_down(DEVICE_MEM_HIGH - root->resource[1].size,
|
round_down(DEVICE_MEM_HIGH - root->resource[1].size,
|
||||||
1UL << root->resource[1].align);
|
1UL << root->resource[1].align);
|
||||||
root->resource[1].flags |= IORESOURCE_ASSIGNED;
|
root->resource[1].flags |= IORESOURCE_ASSIGNED;
|
||||||
root->resource[1].flags &= ~IORESOURCE_STORED;
|
root->resource[1].flags &= ~IORESOURCE_STORED;
|
||||||
|
|
||||||
/* Allocate the VGA I/O resource.. */
|
/* Allocate the VGA I/O resource.. */
|
||||||
allocate_vga_resource();
|
allocate_vga_resource();
|
||||||
|
|
||||||
/* now just set things into registers ... we hope ... */
|
/* Store the computed resource allocations into device registers ... */
|
||||||
root->ops->set_resources(root);
|
root->ops->set_resources(root);
|
||||||
|
|
||||||
printk_info("done.\n");
|
printk_info("done.\n");
|
||||||
@ -565,13 +571,11 @@ void dev_initialize(void)
|
|||||||
struct device *dev;
|
struct device *dev;
|
||||||
|
|
||||||
printk_info("Initializing devices...\n");
|
printk_info("Initializing devices...\n");
|
||||||
|
|
||||||
for (dev = all_devices; dev; dev = dev->next) {
|
for (dev = all_devices; dev; dev = dev->next) {
|
||||||
if (dev->enabled && dev->ops && dev->ops->init) {
|
if (dev->enabled && dev->ops && dev->ops->init) {
|
||||||
printk_debug("%s init\n", dev_path(dev));
|
printk_debug("%s init\n", dev_path(dev));
|
||||||
dev->ops->init(dev);
|
dev->ops->init(dev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
printk_info("Devices initialized\n");
|
printk_info("Devices initialized\n");
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
device_t alloc_find_dev(struct bus *parent, struct device_path *path)
|
device_t alloc_find_dev(struct bus *parent, struct device_path *path)
|
||||||
{
|
{
|
||||||
device_t child;
|
device_t child;
|
||||||
for (child = parent->children; child; child = child->sibling) {
|
for(child = parent->children; child; child = child->sibling) {
|
||||||
if (path_eq(path, &child->path)) {
|
if (path_eq(path, &child->path)) {
|
||||||
return child;
|
return child;
|
||||||
}
|
}
|
||||||
@ -184,7 +184,7 @@ struct resource *get_resource(device_t dev, unsigned index)
|
|||||||
|
|
||||||
/* See if there is a resource with the appropriate index */
|
/* See if there is a resource with the appropriate index */
|
||||||
resource = 0;
|
resource = 0;
|
||||||
for (i = 0; i < dev->resources; i++) {
|
for(i = 0; i < dev->resources; i++) {
|
||||||
if (dev->resource[i].index == index) {
|
if (dev->resource[i].index == index) {
|
||||||
resource = &dev->resource[i];
|
resource = &dev->resource[i];
|
||||||
break;
|
break;
|
||||||
|
@ -151,7 +151,7 @@ static void pci_read_bases(struct device *dev, unsigned int howmany)
|
|||||||
{
|
{
|
||||||
unsigned long index;
|
unsigned long index;
|
||||||
|
|
||||||
for (index = PCI_BASE_ADDRESS_0; (index < PCI_BASE_ADDRESS_0 + (howmany << 2)); ) {
|
for(index = PCI_BASE_ADDRESS_0; (index < PCI_BASE_ADDRESS_0 + (howmany << 2)); ) {
|
||||||
struct resource *resource;
|
struct resource *resource;
|
||||||
resource = pci_get_resource(dev, index);
|
resource = pci_get_resource(dev, index);
|
||||||
index += (resource->flags & IORESOURCE_PCI64)?8:4;
|
index += (resource->flags & IORESOURCE_PCI64)?8:4;
|
||||||
@ -173,7 +173,7 @@ static void pci_bridge_read_bases(struct device *dev)
|
|||||||
resource->limit = 0xffffUL;
|
resource->limit = 0xffffUL;
|
||||||
resource->flags |= IORESOURCE_IO | IORESOURCE_PCI_BRIDGE;
|
resource->flags |= IORESOURCE_IO | IORESOURCE_PCI_BRIDGE;
|
||||||
compute_allocate_resource(&dev->link[0], resource,
|
compute_allocate_resource(&dev->link[0], resource,
|
||||||
IORESOURCE_IO, IORESOURCE_IO);
|
IORESOURCE_IO, IORESOURCE_IO);
|
||||||
|
|
||||||
/* Initiliaze the prefetchable memory constraints on the current bus */
|
/* Initiliaze the prefetchable memory constraints on the current bus */
|
||||||
resource = get_resource(dev, PCI_PREF_MEMORY_BASE);
|
resource = get_resource(dev, PCI_PREF_MEMORY_BASE);
|
||||||
@ -184,8 +184,8 @@ static void pci_bridge_read_bases(struct device *dev)
|
|||||||
resource->flags = IORESOURCE_MEM | IORESOURCE_PREFETCH | IORESOURCE_PCI_BRIDGE;
|
resource->flags = IORESOURCE_MEM | IORESOURCE_PREFETCH | IORESOURCE_PCI_BRIDGE;
|
||||||
resource->index = PCI_PREF_MEMORY_BASE;
|
resource->index = PCI_PREF_MEMORY_BASE;
|
||||||
compute_allocate_resource(&dev->link[0], resource,
|
compute_allocate_resource(&dev->link[0], resource,
|
||||||
IORESOURCE_MEM | IORESOURCE_PREFETCH,
|
IORESOURCE_MEM | IORESOURCE_PREFETCH,
|
||||||
IORESOURCE_MEM | IORESOURCE_PREFETCH);
|
IORESOURCE_MEM | IORESOURCE_PREFETCH);
|
||||||
|
|
||||||
/* Initialize the memory resources on the current bus */
|
/* Initialize the memory resources on the current bus */
|
||||||
resource = get_resource(dev, PCI_MEMORY_BASE);
|
resource = get_resource(dev, PCI_MEMORY_BASE);
|
||||||
@ -195,8 +195,8 @@ static void pci_bridge_read_bases(struct device *dev)
|
|||||||
resource->limit = 0xffffffffUL;
|
resource->limit = 0xffffffffUL;
|
||||||
resource->flags = IORESOURCE_MEM | IORESOURCE_PCI_BRIDGE;
|
resource->flags = IORESOURCE_MEM | IORESOURCE_PCI_BRIDGE;
|
||||||
compute_allocate_resource(&dev->link[0], resource,
|
compute_allocate_resource(&dev->link[0], resource,
|
||||||
IORESOURCE_MEM | IORESOURCE_PREFETCH,
|
IORESOURCE_MEM | IORESOURCE_PREFETCH,
|
||||||
IORESOURCE_MEM);
|
IORESOURCE_MEM);
|
||||||
|
|
||||||
compact_resources(dev);
|
compact_resources(dev);
|
||||||
}
|
}
|
||||||
@ -223,18 +223,18 @@ void pci_bus_read_resources(struct device *dev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief round a number up to an alignment.
|
* @brief round a number up to the next multiple of gran
|
||||||
* @param val the starting value
|
* @param val the starting value
|
||||||
* @param roundup Alignment as a power of two
|
* @param gran granularity we are aligning the number to.
|
||||||
* @returns rounded up number
|
* @returns aligned value
|
||||||
*/
|
*/
|
||||||
static unsigned long round(unsigned long val, unsigned long roundup)
|
static unsigned long align(unsigned long val, unsigned long gran)
|
||||||
{
|
{
|
||||||
/* ROUNDUP MUST BE A POWER OF TWO. */
|
/* GRAN MUST BE A POWER OF TWO. */
|
||||||
unsigned long inverse;
|
unsigned long mask;
|
||||||
inverse = ~(roundup - 1);
|
mask = ~(gran - 1);
|
||||||
val += (roundup - 1);
|
val += (gran - 1);
|
||||||
val &= inverse;
|
val &= mask;
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -245,10 +245,9 @@ static void pci_set_resource(struct device *dev, struct resource *resource)
|
|||||||
unsigned long gran;
|
unsigned long gran;
|
||||||
|
|
||||||
/* Make certain the resource has actually been set */
|
/* Make certain the resource has actually been set */
|
||||||
|
|
||||||
if (!(resource->flags & IORESOURCE_ASSIGNED)) {
|
if (!(resource->flags & IORESOURCE_ASSIGNED)) {
|
||||||
printk_err("ERROR: %s %02x not allocated\n",
|
printk_err("ERROR: %s %02x not allocated\n",
|
||||||
dev_path(dev), resource->index);
|
dev_path(dev), resource->index);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -270,10 +269,8 @@ static void pci_set_resource(struct device *dev, struct resource *resource)
|
|||||||
if (resource->flags & IORESOURCE_PCI_BRIDGE) {
|
if (resource->flags & IORESOURCE_PCI_BRIDGE) {
|
||||||
dev->command |= PCI_COMMAND_MASTER;
|
dev->command |= PCI_COMMAND_MASTER;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the base address */
|
/* Get the base address */
|
||||||
base = resource->base;
|
base = resource->base;
|
||||||
|
|
||||||
/* Get the resource granularity */
|
/* Get the resource granularity */
|
||||||
gran = 1UL << resource->gran;
|
gran = 1UL << resource->gran;
|
||||||
|
|
||||||
@ -284,13 +281,15 @@ static void pci_set_resource(struct device *dev, struct resource *resource)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* Get the limit (rounded up) */
|
/* Get the limit (rounded up) */
|
||||||
limit = base + round(resource->size, gran) - 1UL;
|
limit = base + align(resource->size, gran) - 1UL;
|
||||||
|
|
||||||
/* Now store the resource */
|
/* Now store the resource */
|
||||||
resource->flags |= IORESOURCE_STORED;
|
resource->flags |= IORESOURCE_STORED;
|
||||||
if (!(resource->flags & IORESOURCE_PCI_BRIDGE)) {
|
if (!(resource->flags & IORESOURCE_PCI_BRIDGE)) {
|
||||||
/* some chipsets allow us to set/clear the IO bit.
|
/*
|
||||||
* (e.g. VIA 82c686a.) So set it to be safe) */
|
* some chipsets allow us to set/clear the IO bit.
|
||||||
|
* (e.g. VIA 82c686a.) So set it to be safe)
|
||||||
|
*/
|
||||||
limit = base + resource->size -1;
|
limit = base + resource->size -1;
|
||||||
if (resource->flags & IORESOURCE_IO) {
|
if (resource->flags & IORESOURCE_IO) {
|
||||||
base |= PCI_BASE_ADDRESS_SPACE_IO;
|
base |= PCI_BASE_ADDRESS_SPACE_IO;
|
||||||
@ -300,50 +299,58 @@ static void pci_set_resource(struct device *dev, struct resource *resource)
|
|||||||
/* FIXME handle real 64bit base addresses */
|
/* FIXME handle real 64bit base addresses */
|
||||||
pci_write_config32(dev, resource->index + 4, 0);
|
pci_write_config32(dev, resource->index + 4, 0);
|
||||||
}
|
}
|
||||||
} else if (resource->index == PCI_IO_BASE) {
|
}
|
||||||
|
else if (resource->index == PCI_IO_BASE) {
|
||||||
/* set the IO ranges
|
/* set the IO ranges
|
||||||
* WARNING: we don't really do 32-bit addressing for IO yet!
|
* WARNING: we don't really do 32-bit addressing for IO yet!
|
||||||
*/
|
*/
|
||||||
compute_allocate_resource(&dev->link[0], resource,
|
compute_allocate_resource(&dev->link[0], resource,
|
||||||
IORESOURCE_IO, IORESOURCE_IO);
|
IORESOURCE_IO, IORESOURCE_IO);
|
||||||
pci_write_config8(dev, PCI_IO_BASE, base >> 8);
|
pci_write_config8(dev, PCI_IO_BASE, base >> 8);
|
||||||
pci_write_config8(dev, PCI_IO_LIMIT, limit >> 8);
|
pci_write_config8(dev, PCI_IO_LIMIT, limit >> 8);
|
||||||
pci_write_config16(dev, PCI_IO_BASE_UPPER16, 0);
|
pci_write_config16(dev, PCI_IO_BASE_UPPER16, 0);
|
||||||
pci_write_config16(dev, PCI_IO_LIMIT_UPPER16, 0);
|
pci_write_config16(dev, PCI_IO_LIMIT_UPPER16, 0);
|
||||||
} else if (resource->index == PCI_MEMORY_BASE) {
|
}
|
||||||
/* set the memory range */
|
else if (resource->index == PCI_MEMORY_BASE) {
|
||||||
|
/* set the memory range
|
||||||
|
*/
|
||||||
compute_allocate_resource(&dev->link[0], resource,
|
compute_allocate_resource(&dev->link[0], resource,
|
||||||
IORESOURCE_MEM | IORESOURCE_PREFETCH,
|
IORESOURCE_MEM | IORESOURCE_PREFETCH,
|
||||||
IORESOURCE_MEM);
|
IORESOURCE_MEM);
|
||||||
pci_write_config16(dev, PCI_MEMORY_BASE, base >> 16);
|
pci_write_config16(dev, PCI_MEMORY_BASE, base >> 16);
|
||||||
pci_write_config16(dev, PCI_MEMORY_LIMIT, limit >> 16);
|
pci_write_config16(dev, PCI_MEMORY_LIMIT, limit >> 16);
|
||||||
} else if (resource->index == PCI_PREF_MEMORY_BASE) {
|
}
|
||||||
|
else if (resource->index == PCI_PREF_MEMORY_BASE) {
|
||||||
/* set the prefetchable memory range
|
/* set the prefetchable memory range
|
||||||
* WARNING: we don't really do 64-bit addressing for
|
* WARNING: we don't really do 64-bit addressing
|
||||||
* prefetchable memory yet! */
|
* for prefetchable memory yet!
|
||||||
|
*/
|
||||||
compute_allocate_resource(&dev->link[0], resource,
|
compute_allocate_resource(&dev->link[0], resource,
|
||||||
IORESOURCE_MEM | IORESOURCE_PREFETCH,
|
IORESOURCE_MEM | IORESOURCE_PREFETCH,
|
||||||
IORESOURCE_MEM | IORESOURCE_PREFETCH);
|
IORESOURCE_MEM | IORESOURCE_PREFETCH);
|
||||||
pci_write_config16(dev, PCI_PREF_MEMORY_BASE, base >> 16);
|
pci_write_config16(dev, PCI_PREF_MEMORY_BASE, base >> 16);
|
||||||
pci_write_config16(dev, PCI_PREF_MEMORY_LIMIT, limit >> 16);
|
pci_write_config16(dev, PCI_PREF_MEMORY_LIMIT, limit >> 16);
|
||||||
pci_write_config32(dev, PCI_PREF_BASE_UPPER32, 0);
|
pci_write_config32(dev, PCI_PREF_BASE_UPPER32, 0);
|
||||||
pci_write_config32(dev, PCI_PREF_LIMIT_UPPER32, 0);
|
pci_write_config32(dev, PCI_PREF_LIMIT_UPPER32, 0);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
/* Don't let me think I stored the resource */
|
/* Don't let me think I stored the resource */
|
||||||
resource->flags &= ~IORESOURCE_STORED;
|
resource->flags &= ~IORESOURCE_STORED;
|
||||||
printk_err("ERROR: invalid resource->index %x\n",
|
printk_err("ERROR: invalid resource->index %x\n",
|
||||||
resource->index);
|
resource->index);
|
||||||
}
|
}
|
||||||
|
|
||||||
buf[0] = '\0';
|
buf[0] = '\0';
|
||||||
if (resource->flags & IORESOURCE_PCI_BRIDGE) {
|
if (resource->flags & IORESOURCE_PCI_BRIDGE) {
|
||||||
sprintf(buf, "bus %d ", dev->link[0].secondary);
|
sprintf(buf, "bus %d ", dev->link[0].secondary);
|
||||||
}
|
}
|
||||||
printk_debug("%s %02x <- [0x%08lx - 0x%08lx] %s%s\n",
|
printk_debug(
|
||||||
dev_path(dev), resource->index, resource->base,
|
"%s %02x <- [0x%08lx - 0x%08lx] %s%s\n",
|
||||||
limit, buf,
|
dev_path(dev),
|
||||||
(resource->flags & IORESOURCE_IO)? "io":
|
resource->index,
|
||||||
(resource->flags & IORESOURCE_PREFETCH)? "prefmem": "mem");
|
(unsigned long)(resource->base), limit,
|
||||||
|
buf,
|
||||||
|
(resource->flags & IORESOURCE_IO)? "io":
|
||||||
|
(resource->flags & IORESOURCE_PREFETCH)? "prefmem": "mem");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -354,11 +361,11 @@ void pci_dev_set_resources(struct device *dev)
|
|||||||
uint8_t line;
|
uint8_t line;
|
||||||
|
|
||||||
last = &dev->resource[dev->resources];
|
last = &dev->resource[dev->resources];
|
||||||
for (resource = &dev->resource[0]; resource < last; resource++) {
|
|
||||||
|
for(resource = &dev->resource[0]; resource < last; resource++) {
|
||||||
pci_set_resource(dev, resource);
|
pci_set_resource(dev, resource);
|
||||||
}
|
}
|
||||||
|
for(link = 0; link < dev->links; link++) {
|
||||||
for (link = 0; link < dev->links; link++) {
|
|
||||||
struct bus *bus;
|
struct bus *bus;
|
||||||
bus = &dev->link[link];
|
bus = &dev->link[link];
|
||||||
if (bus->children) {
|
if (bus->children) {
|
||||||
@ -442,16 +449,17 @@ static void set_pci_ops(struct device *dev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Look through the list of setup drivers and find one for
|
/* Look through the list of setup drivers and find one for
|
||||||
* this pci device */
|
* this pci device
|
||||||
for (driver = &pci_drivers[0]; driver != &epci_drivers[0]; driver++) {
|
*/
|
||||||
|
for(driver = &pci_drivers[0]; driver != &epci_drivers[0]; driver++) {
|
||||||
if ((driver->vendor == dev->vendor) &&
|
if ((driver->vendor == dev->vendor) &&
|
||||||
(driver->device == dev->device)) {
|
(driver->device == dev->device))
|
||||||
|
{
|
||||||
dev->ops = driver->ops;
|
dev->ops = driver->ops;
|
||||||
|
printk_debug("%s [%04x/%04x] %sops\n",
|
||||||
printk_debug("%s [%04x/%04x] %sops\n", dev_path(dev),
|
dev_path(dev),
|
||||||
driver->vendor, driver->device,
|
driver->vendor, driver->device,
|
||||||
(driver->ops->scan_bus?"bus ":""));
|
(driver->ops->scan_bus?"bus ":""));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -483,10 +491,10 @@ static void set_pci_ops(struct device *dev)
|
|||||||
bad:
|
bad:
|
||||||
if (dev->enabled) {
|
if (dev->enabled) {
|
||||||
printk_err("%s [%04x/%04x/%06x] has unknown header "
|
printk_err("%s [%04x/%04x/%06x] has unknown header "
|
||||||
"type %02x, ignoring.\n",
|
"type %02x, ignoring.\n",
|
||||||
dev_path(dev),
|
dev_path(dev),
|
||||||
dev->vendor, dev->device,
|
dev->vendor, dev->device,
|
||||||
dev->class >> 8, dev->hdr_type);
|
dev->class >> 8, dev->hdr_type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -496,24 +504,25 @@ static void set_pci_ops(struct device *dev)
|
|||||||
* @brief Find a specific device structure on a list of device structures
|
* @brief Find a specific device structure on a list of device structures
|
||||||
*
|
*
|
||||||
* Given a linked list of PCI device structures and a devfn number, find the
|
* Given a linked list of PCI device structures and a devfn number, find the
|
||||||
* device structure correspond to the devfn.
|
* device structure correspond to the devfn, if present.
|
||||||
*
|
*
|
||||||
* @param list the device structure list
|
* @param list the device structure list
|
||||||
* @param devfn a device/function number
|
* @param devfn a device/function number
|
||||||
*
|
*
|
||||||
* @return pointer to the device structure found
|
* @return pointer to the device structure found or null of we have not allocated
|
||||||
|
* a device for this devfn yet.
|
||||||
*/
|
*/
|
||||||
static struct device *pci_scan_get_dev(struct device **list,
|
static struct device *pci_scan_get_dev(struct device **list, unsigned int devfn)
|
||||||
unsigned int devfn)
|
|
||||||
{
|
{
|
||||||
struct device *dev = 0;
|
struct device *dev;
|
||||||
|
|
||||||
printk_debug("%s, looking for devfn: %02x.%01x\n", __FUNCTION__,
|
printk_spew("%s, looking for devfn: %02x.%01x\n", __FUNCTION__,
|
||||||
devfn >> 3, devfn & 7);
|
devfn >> 3, devfn & 7);
|
||||||
for (; *list; list = &(*list)->sibling) {
|
dev = 0;
|
||||||
|
for(; *list; list = &(*list)->sibling) {
|
||||||
if ((*list)->path.type != DEVICE_PATH_PCI) {
|
if ((*list)->path.type != DEVICE_PATH_PCI) {
|
||||||
printk_err("child %s not a pci device\n",
|
printk_err("child %s not a pci device\n",
|
||||||
dev_path(*list));
|
dev_path(*list));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ((*list)->path.u.pci.devfn == devfn) {
|
if ((*list)->path.u.pci.devfn == devfn) {
|
||||||
@ -524,15 +533,16 @@ static struct device *pci_scan_get_dev(struct device **list,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* Just like alloc_dev add the device to the
|
||||||
printk_debug("%s, found dev %08x\n", __FUNCTION__, dev);
|
* list of device on the bus. When the list of devices was formed
|
||||||
|
* we removed all of the parents children, and now we are interleaving
|
||||||
/* FIXME: why are we doing this ? Isn't there some order between the
|
* static and dynamic devices in order on the bus.
|
||||||
* structures before ? */
|
*/
|
||||||
|
printk_spew("%s, found dev %08x\n", __FUNCTION__, dev);
|
||||||
if (dev) {
|
if (dev) {
|
||||||
device_t child;
|
device_t child;
|
||||||
/* Find the last child of our parent */
|
/* Find the last child of our parent */
|
||||||
for (child = dev->bus->children; child && child->sibling; ) {
|
for(child = dev->bus->children; child && child->sibling; ) {
|
||||||
child = child->sibling;
|
child = child->sibling;
|
||||||
}
|
}
|
||||||
/* Place the device on the list of children of it's parent. */
|
/* Place the device on the list of children of it's parent. */
|
||||||
@ -547,7 +557,7 @@ static struct device *pci_scan_get_dev(struct device **list,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Scan a PCI bus
|
* @brief Scan a PCI bus.
|
||||||
*
|
*
|
||||||
* Determine the existence of devices and bridges on a PCI bus. If there are
|
* Determine the existence of devices and bridges on a PCI bus. If there are
|
||||||
* bridges on the bus, recursively scan the buses behind the bridges.
|
* bridges on the bus, recursively scan the buses behind the bridges.
|
||||||
@ -562,8 +572,9 @@ static struct device *pci_scan_get_dev(struct device **list,
|
|||||||
*
|
*
|
||||||
* @return The maximum bus number found, after scanning all subordinate busses
|
* @return The maximum bus number found, after scanning all subordinate busses
|
||||||
*/
|
*/
|
||||||
unsigned int pci_scan_bus(struct bus *bus, unsigned min_devfn,
|
unsigned int pci_scan_bus(struct bus *bus,
|
||||||
unsigned max_devfn, unsigned int max)
|
unsigned min_devfn, unsigned max_devfn,
|
||||||
|
unsigned int max)
|
||||||
{
|
{
|
||||||
unsigned int devfn;
|
unsigned int devfn;
|
||||||
device_t dev;
|
device_t dev;
|
||||||
@ -578,7 +589,8 @@ unsigned int pci_scan_bus(struct bus *bus, unsigned min_devfn,
|
|||||||
post_code(0x24);
|
post_code(0x24);
|
||||||
|
|
||||||
/* probe all devices/functions on this bus with some optimization for
|
/* probe all devices/functions on this bus with some optimization for
|
||||||
* non-existence and single funcion devices */
|
* non-existence and single funcion devices
|
||||||
|
*/
|
||||||
for (devfn = min_devfn; devfn <= max_devfn; devfn++) {
|
for (devfn = min_devfn; devfn <= max_devfn; devfn++) {
|
||||||
uint32_t id, class;
|
uint32_t id, class;
|
||||||
uint8_t hdr_type;
|
uint8_t hdr_type;
|
||||||
@ -597,31 +609,39 @@ unsigned int pci_scan_bus(struct bus *bus, unsigned min_devfn,
|
|||||||
dummy.path.u.pci.devfn = devfn;
|
dummy.path.u.pci.devfn = devfn;
|
||||||
id = pci_read_config32(&dummy, PCI_VENDOR_ID);
|
id = pci_read_config32(&dummy, PCI_VENDOR_ID);
|
||||||
/* some broken boards return 0 if a slot is empty: */
|
/* some broken boards return 0 if a slot is empty: */
|
||||||
if ((id == 0xffffffff) || (id == 0x00000000) ||
|
if ( (id == 0xffffffff) || (id == 0x00000000) ||
|
||||||
(id == 0x0000ffff) || (id == 0xffff0000)) {
|
(id == 0x0000ffff) || (id == 0xffff0000))
|
||||||
printk_spew("PCI: devfn 0x%x, bad id 0x%x\n",
|
{
|
||||||
devfn, id);
|
printk_spew("PCI: devfn 0x%x, bad id 0x%x\n", devfn, id);
|
||||||
if (PCI_FUNC(devfn) == 0x00) {
|
if (PCI_FUNC(devfn) == 0x00) {
|
||||||
/* if this is a function 0 device and
|
/* if this is a function 0 device and
|
||||||
* it is not present, skip to next
|
* it is not present,
|
||||||
* device */
|
* skip to next device
|
||||||
|
*/
|
||||||
devfn += 0x07;
|
devfn += 0x07;
|
||||||
}
|
}
|
||||||
/* this function in a multi function device is
|
/* This function in a multi function device is
|
||||||
* not present, skip to next function */
|
* not present, skip to the next function.
|
||||||
|
*/
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
dev = alloc_dev(bus, &dummy.path);
|
dev = alloc_dev(bus, &dummy.path);
|
||||||
} else {
|
}
|
||||||
/* Run the magic enable/disable sequence for the
|
else {
|
||||||
* device */
|
/* If at all possible enable the device, if desired
|
||||||
/* FIXME: What happen if this PCI device listed as
|
* we will disable the device later, once we have
|
||||||
* static device but does not exist ? This calls
|
* found it's device specific operations.
|
||||||
* some arbitray code without any justification
|
*
|
||||||
* Also, it calls the enable function regardlessly
|
* This is geared toward devices that have subfunctions
|
||||||
* the value of dev->enabled */
|
* that do not show up by default.
|
||||||
if (dev->chip && dev->chip->control &&
|
*
|
||||||
dev->chip->control->enable_dev) {
|
* If a device is a stuff option on the motherboard
|
||||||
|
* it may be absent and enable_dev must cope.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
if ( dev->chip && dev->chip->control &&
|
||||||
|
dev->chip->control->enable_dev)
|
||||||
|
{
|
||||||
int enabled = dev->enabled;
|
int enabled = dev->enabled;
|
||||||
dev->enabled = 1;
|
dev->enabled = 1;
|
||||||
dev->chip->control->enable_dev(dev);
|
dev->chip->control->enable_dev(dev);
|
||||||
@ -650,15 +670,17 @@ unsigned int pci_scan_bus(struct bus *bus, unsigned min_devfn,
|
|||||||
/* Error if we don't have some pci operations for it */
|
/* Error if we don't have some pci operations for it */
|
||||||
if (!dev->ops) {
|
if (!dev->ops) {
|
||||||
printk_err("%s No device operations\n",
|
printk_err("%s No device operations\n",
|
||||||
dev_path(dev));
|
dev_path(dev));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now run the magic enable/disable sequence for the device */
|
/* Now run the magic enable/disable sequence for the device */
|
||||||
if (dev->ops && dev->ops->enable) {
|
if (dev->ops && dev->ops->enable) {
|
||||||
dev->ops->enable(dev);
|
dev->ops->enable(dev);
|
||||||
} else if (dev->chip && dev->chip->control &&
|
}
|
||||||
dev->chip->control->enable_dev) {
|
else if (dev->chip && dev->chip->control &&
|
||||||
|
dev->chip->control->enable_dev)
|
||||||
|
{
|
||||||
dev->chip->control->enable_dev(dev);
|
dev->chip->control->enable_dev(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -668,22 +690,23 @@ unsigned int pci_scan_bus(struct bus *bus, unsigned min_devfn,
|
|||||||
dev->enabled?"enabled": "disabled");
|
dev->enabled?"enabled": "disabled");
|
||||||
|
|
||||||
if (PCI_FUNC(devfn) == 0x00 && (hdr_type & 0x80) != 0x80) {
|
if (PCI_FUNC(devfn) == 0x00 && (hdr_type & 0x80) != 0x80) {
|
||||||
/* if this is not a multi function device, don't
|
/* if this is not a multi function device,
|
||||||
* waste time probe another function.
|
* don't waste time probing another function.
|
||||||
* Skip to next device. */
|
* Skip to next device.
|
||||||
|
*/
|
||||||
devfn += 0x07;
|
devfn += 0x07;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
post_code(0x25);
|
post_code(0x25);
|
||||||
|
|
||||||
/* if a child provides scan_bus(), for example a bridge, scan
|
/* For all children that implement scan_bus (i.e. bridges)
|
||||||
* buses behind that child */
|
* scan the bus behind that child.
|
||||||
for (child = bus->children; child; child = child->sibling) {
|
*/
|
||||||
// make sure that we have an ops structure
|
for(child = bus->children; child; child = child->sibling) {
|
||||||
if (!child->ops) {
|
if (!child->enabled ||
|
||||||
continue;
|
!child->ops ||
|
||||||
}
|
!child->ops->scan_bus)
|
||||||
if (!child->ops->scan_bus) {
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
max = child->ops->scan_bus(child, max);
|
max = child->ops->scan_bus(child, max);
|
||||||
@ -725,7 +748,8 @@ unsigned int pci_scan_bridge(struct device *dev, unsigned int max)
|
|||||||
|
|
||||||
/* Set up the primary, secondary and subordinate bus numbers. We have
|
/* Set up the primary, secondary and subordinate bus numbers. We have
|
||||||
* no idea how many buses are behind this bridge yet, so we set the
|
* no idea how many buses are behind this bridge yet, so we set the
|
||||||
* subordinate bus number to 0xff for the moment. */
|
* subordinate bus number to 0xff for the moment.
|
||||||
|
*/
|
||||||
bus->secondary = ++max;
|
bus->secondary = ++max;
|
||||||
bus->subordinate = 0xff;
|
bus->subordinate = 0xff;
|
||||||
|
|
||||||
@ -734,32 +758,37 @@ unsigned int pci_scan_bridge(struct device *dev, unsigned int max)
|
|||||||
pci_write_config16(dev, PCI_COMMAND, 0x0000);
|
pci_write_config16(dev, PCI_COMMAND, 0x0000);
|
||||||
pci_write_config16(dev, PCI_STATUS, 0xffff);
|
pci_write_config16(dev, PCI_STATUS, 0xffff);
|
||||||
|
|
||||||
/* Read the existing primary/secondary/subordinate bus
|
/*
|
||||||
* number configuration. */
|
* Read the existing primary/secondary/subordinate bus
|
||||||
|
* number configuration.
|
||||||
|
*/
|
||||||
buses = pci_read_config32(dev, PCI_PRIMARY_BUS);
|
buses = pci_read_config32(dev, PCI_PRIMARY_BUS);
|
||||||
|
|
||||||
/* Configure the bus numbers for this bridge: the configuration
|
/* Configure the bus numbers for this bridge: the configuration
|
||||||
* transactions will not be propagated by the bridge if it is not
|
* transactions will not be propagated by the bridge if it is not
|
||||||
* correctly configured */
|
* correctly configured.
|
||||||
|
*/
|
||||||
buses &= 0xff000000;
|
buses &= 0xff000000;
|
||||||
buses |= (((unsigned int) (dev->bus->secondary) << 0) |
|
buses |= (((unsigned int) (dev->bus->secondary) << 0) |
|
||||||
((unsigned int) (bus->secondary) << 8) |
|
((unsigned int) (bus->secondary) << 8) |
|
||||||
((unsigned int) (bus->subordinate) << 16));
|
((unsigned int) (bus->subordinate) << 16));
|
||||||
pci_write_config32(dev, PCI_PRIMARY_BUS, buses);
|
pci_write_config32(dev, PCI_PRIMARY_BUS, buses);
|
||||||
|
|
||||||
/* Now we can scan all subordinate buses i.e. the buses behind the
|
/* Now we can scan all subordinate buses
|
||||||
* bridge */
|
* i.e. the bus behind the bridge.
|
||||||
|
*/
|
||||||
max = pci_scan_bus(bus, 0x00, 0xff, max);
|
max = pci_scan_bus(bus, 0x00, 0xff, max);
|
||||||
|
|
||||||
/* We know the number of buses behind this bridge. Set the subordinate
|
/* We know the number of buses behind this bridge. Set the subordinate
|
||||||
* bus number to its real value */
|
* bus number to its real value.
|
||||||
|
*/
|
||||||
bus->subordinate = max;
|
bus->subordinate = max;
|
||||||
buses = (buses & 0xff00ffff) |
|
buses = (buses & 0xff00ffff) |
|
||||||
((unsigned int) (bus->subordinate) << 16);
|
((unsigned int) (bus->subordinate) << 16);
|
||||||
pci_write_config32(dev, PCI_PRIMARY_BUS, buses);
|
pci_write_config32(dev, PCI_PRIMARY_BUS, buses);
|
||||||
pci_write_config16(dev, PCI_COMMAND, cr);
|
pci_write_config16(dev, PCI_COMMAND, cr);
|
||||||
|
|
||||||
printk_spew("%s returns max %d\n", __FUNCTION__, max);
|
printk_spew("%s returns max %d\n", __func__, max);
|
||||||
return max;
|
return max;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -771,10 +800,18 @@ static void pci_level_irq(unsigned char intNum)
|
|||||||
{
|
{
|
||||||
unsigned short intBits = inb(0x4d0) | (((unsigned) inb(0x4d1)) << 8);
|
unsigned short intBits = inb(0x4d0) | (((unsigned) inb(0x4d1)) << 8);
|
||||||
|
|
||||||
|
<<<<<<< pci_device.c
|
||||||
|
printk_spew("%s: current ints are 0x%x\n", __func__, intBits);
|
||||||
|
=======
|
||||||
printk_debug("%s: current ints are 0x%x\n", __FUNCTION__, intBits);
|
printk_debug("%s: current ints are 0x%x\n", __FUNCTION__, intBits);
|
||||||
|
>>>>>>> 1.25
|
||||||
intBits |= (1 << intNum);
|
intBits |= (1 << intNum);
|
||||||
|
|
||||||
|
<<<<<<< pci_device.c
|
||||||
|
printk_spew("%s: try to set ints 0x%x\n", __func__, intBits);
|
||||||
|
=======
|
||||||
printk_debug("%s: try to set ints 0x%x\n", __FUNCTION__, intBits);
|
printk_debug("%s: try to set ints 0x%x\n", __FUNCTION__, intBits);
|
||||||
|
>>>>>>> 1.25
|
||||||
|
|
||||||
// Write new values
|
// Write new values
|
||||||
outb((unsigned char) intBits, 0x4d0);
|
outb((unsigned char) intBits, 0x4d0);
|
||||||
@ -784,11 +821,11 @@ static void pci_level_irq(unsigned char intNum)
|
|||||||
#if 1
|
#if 1
|
||||||
if (inb(0x4d0) != (intBits & 0xf)) {
|
if (inb(0x4d0) != (intBits & 0xf)) {
|
||||||
printk_err("%s: lower order bits are wrong: want 0x%x, got 0x%x\n",
|
printk_err("%s: lower order bits are wrong: want 0x%x, got 0x%x\n",
|
||||||
__FUNCTION__, intBits &0xf, inb(0x4d0));
|
__func__, intBits &0xf, inb(0x4d0));
|
||||||
}
|
}
|
||||||
if (inb(0x4d1) != ((intBits >> 8) & 0xf)) {
|
if (inb(0x4d1) != ((intBits >> 8) & 0xf)) {
|
||||||
printk_err("%s: lower order bits are wrong: want 0x%x, got 0x%x\n",
|
printk_err("%s: lower order bits are wrong: want 0x%x, got 0x%x\n",
|
||||||
__FUNCTION__, (intBits>>8) &0xf, inb(0x4d1));
|
__func__, (intBits>>8) &0xf, inb(0x4d1));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -76,25 +76,30 @@ static void pnp_set_resource(device_t dev, struct resource *resource)
|
|||||||
/* Now store the resource */
|
/* Now store the resource */
|
||||||
if (resource->flags & IORESOURCE_IO) {
|
if (resource->flags & IORESOURCE_IO) {
|
||||||
pnp_set_iobase(dev, resource->index, resource->base);
|
pnp_set_iobase(dev, resource->index, resource->base);
|
||||||
} else if (resource->flags & IORESOURCE_DRQ) {
|
}
|
||||||
|
else if (resource->flags & IORESOURCE_DRQ) {
|
||||||
pnp_set_drq(dev, resource->index, resource->base);
|
pnp_set_drq(dev, resource->index, resource->base);
|
||||||
} else if (resource->flags & IORESOURCE_IRQ) {
|
}
|
||||||
|
else if (resource->flags & IORESOURCE_IRQ) {
|
||||||
pnp_set_irq(dev, resource->index, resource->base);
|
pnp_set_irq(dev, resource->index, resource->base);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
printk_err("ERROR: %s %02x unknown resource type\n",
|
printk_err("ERROR: %s %02x unknown resource type\n",
|
||||||
dev_path(dev), resource->index);
|
dev_path(dev), resource->index);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
resource->flags |= IORESOURCE_STORED;
|
resource->flags |= IORESOURCE_STORED;
|
||||||
|
|
||||||
printk_debug("%s %02x <- [0x%08lx - 0x%08lx] %s\n", dev_path(dev),
|
printk_debug(
|
||||||
resource->index, resource->base,
|
"%s %02x <- [0x%08lx - 0x%08lx] %s\n",
|
||||||
resource->base + resource->size - 1,
|
dev_path(dev),
|
||||||
(resource->flags & IORESOURCE_IO)? "io":
|
resource->index,
|
||||||
(resource->flags & IORESOURCE_DRQ)? "drq":
|
resource->base, resource->base + resource->size - 1,
|
||||||
(resource->flags & IORESOURCE_IRQ)? "irq":
|
(resource->flags & IORESOURCE_IO)? "io":
|
||||||
(resource->flags & IORESOURCE_MEM)? "mem":
|
(resource->flags & IORESOURCE_DRQ)? "drq":
|
||||||
"???");
|
(resource->flags & IORESOURCE_IRQ)? "irq":
|
||||||
|
(resource->flags & IORESOURCE_MEM)? "mem":
|
||||||
|
"???");
|
||||||
}
|
}
|
||||||
|
|
||||||
void pnp_set_resources(device_t dev)
|
void pnp_set_resources(device_t dev)
|
||||||
@ -105,7 +110,7 @@ void pnp_set_resources(device_t dev)
|
|||||||
pnp_set_logical_device(dev);
|
pnp_set_logical_device(dev);
|
||||||
|
|
||||||
/* Paranoia says I should disable the device here... */
|
/* Paranoia says I should disable the device here... */
|
||||||
for (i = 0; i < dev->resources; i++) {
|
for(i = 0; i < dev->resources; i++) {
|
||||||
pnp_set_resource(dev, &dev->resource[i]);
|
pnp_set_resource(dev, &dev->resource[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -133,8 +138,7 @@ struct device_operations pnp_ops = {
|
|||||||
|
|
||||||
/* PNP chip opertations */
|
/* PNP chip opertations */
|
||||||
|
|
||||||
static void pnp_get_ioresource(device_t dev, unsigned index,
|
static void pnp_get_ioresource(device_t dev, unsigned index, struct io_info *info)
|
||||||
struct io_info *info)
|
|
||||||
{
|
{
|
||||||
struct resource *resource;
|
struct resource *resource;
|
||||||
uint32_t size;
|
uint32_t size;
|
||||||
@ -156,14 +160,18 @@ static void get_resources(device_t dev, struct pnp_info *info)
|
|||||||
{
|
{
|
||||||
struct resource *resource;
|
struct resource *resource;
|
||||||
|
|
||||||
// pnp_set_logical_device(dev); // coment out by LYH
|
|
||||||
|
|
||||||
if (info->flags & PNP_IO0) {
|
if (info->flags & PNP_IO0) {
|
||||||
pnp_get_ioresource(dev, PNP_IDX_IO0, &info->io0);
|
pnp_get_ioresource(dev, PNP_IDX_IO0, &info->io0);
|
||||||
}
|
}
|
||||||
if (info->flags & PNP_IO1) {
|
if (info->flags & PNP_IO1) {
|
||||||
pnp_get_ioresource(dev, PNP_IDX_IO1, &info->io1);
|
pnp_get_ioresource(dev, PNP_IDX_IO1, &info->io1);
|
||||||
}
|
}
|
||||||
|
if (info->flags & PNP_IO2) {
|
||||||
|
pnp_get_ioresource(dev, PNP_IDX_IO2, &info->io2);
|
||||||
|
}
|
||||||
|
if (info->flags & PNP_IO3) {
|
||||||
|
pnp_get_ioresource(dev, PNP_IDX_IO3, &info->io3);
|
||||||
|
}
|
||||||
if (info->flags & PNP_IRQ0) {
|
if (info->flags & PNP_IRQ0) {
|
||||||
resource = get_resource(dev, PNP_IDX_IRQ0);
|
resource = get_resource(dev, PNP_IDX_IRQ0);
|
||||||
resource->size = 1;
|
resource->size = 1;
|
||||||
@ -187,7 +195,7 @@ static void get_resources(device_t dev, struct pnp_info *info)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void pnp_enumerate(struct chip *chip, unsigned functions,
|
void pnp_enumerate(struct chip *chip, unsigned functions,
|
||||||
struct device_operations *ops, struct pnp_info *info)
|
struct device_operations *ops, struct pnp_info *info)
|
||||||
{
|
{
|
||||||
struct device_path path;
|
struct device_path path;
|
||||||
device_t dev;
|
device_t dev;
|
||||||
@ -199,9 +207,8 @@ void pnp_enumerate(struct chip *chip, unsigned functions,
|
|||||||
path.u.pnp.port = chip->dev->path.u.pnp.port;
|
path.u.pnp.port = chip->dev->path.u.pnp.port;
|
||||||
|
|
||||||
/* Setup the ops and resources on the newly allocated devices */
|
/* Setup the ops and resources on the newly allocated devices */
|
||||||
for (i = 0; i < functions; i++) {
|
for(i = 0; i < functions; i++) {
|
||||||
path.u.pnp.device = info[i].function;
|
path.u.pnp.device = info[i].function;
|
||||||
|
|
||||||
dev = alloc_find_dev(chip->bus, &path);
|
dev = alloc_find_dev(chip->bus, &path);
|
||||||
|
|
||||||
if (info[i].ops == 0) {
|
if (info[i].ops == 0) {
|
||||||
|
@ -11,7 +11,6 @@ void root_dev_read_resources(device_t root)
|
|||||||
{
|
{
|
||||||
int res = 0;
|
int res = 0;
|
||||||
|
|
||||||
printk_spew("%s . Root is %p\n", __FUNCTION__, dev_path(root));
|
|
||||||
/* Initialize the system wide io space constraints */
|
/* Initialize the system wide io space constraints */
|
||||||
root->resource[res].base = 0x400;
|
root->resource[res].base = 0x400;
|
||||||
root->resource[res].size = 0;
|
root->resource[res].size = 0;
|
||||||
@ -20,10 +19,8 @@ void root_dev_read_resources(device_t root)
|
|||||||
root->resource[res].limit = 0xffffUL;
|
root->resource[res].limit = 0xffffUL;
|
||||||
root->resource[res].flags = IORESOURCE_IO;
|
root->resource[res].flags = IORESOURCE_IO;
|
||||||
root->resource[res].index = 0;
|
root->resource[res].index = 0;
|
||||||
printk_spew("%s . link %p, resource %p\n", __FUNCTION__,
|
|
||||||
&root->link[0], &root->resource[res]);
|
|
||||||
compute_allocate_resource(&root->link[0], &root->resource[res],
|
compute_allocate_resource(&root->link[0], &root->resource[res],
|
||||||
IORESOURCE_IO, IORESOURCE_IO);
|
IORESOURCE_IO, IORESOURCE_IO);
|
||||||
res++;
|
res++;
|
||||||
|
|
||||||
/* Initialize the system wide memory resources constraints */
|
/* Initialize the system wide memory resources constraints */
|
||||||
@ -34,14 +31,12 @@ void root_dev_read_resources(device_t root)
|
|||||||
root->resource[res].limit = 0xffffffffUL;
|
root->resource[res].limit = 0xffffffffUL;
|
||||||
root->resource[res].flags = IORESOURCE_MEM;
|
root->resource[res].flags = IORESOURCE_MEM;
|
||||||
root->resource[res].index = 1;
|
root->resource[res].index = 1;
|
||||||
printk_spew("%s . link %p, resource %p\n", __FUNCTION__,
|
|
||||||
&root->link[0], &root->resource[res]);
|
|
||||||
compute_allocate_resource(&root->link[0], &root->resource[res],
|
compute_allocate_resource(&root->link[0], &root->resource[res],
|
||||||
IORESOURCE_MEM, IORESOURCE_MEM);
|
IORESOURCE_MEM, IORESOURCE_MEM);
|
||||||
res++;
|
res++;
|
||||||
|
|
||||||
root->resources = res;
|
root->resources = res;
|
||||||
printk_spew("%s DONE\n", __FUNCTION__);
|
printk_spew("%s DONE\n", __func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -51,12 +46,13 @@ void root_dev_read_resources(device_t root)
|
|||||||
*/
|
*/
|
||||||
void root_dev_set_resources(device_t root)
|
void root_dev_set_resources(device_t root)
|
||||||
{
|
{
|
||||||
struct bus *bus = &root->link[0];
|
struct bus *bus;
|
||||||
|
|
||||||
compute_allocate_resource(bus, &root->resource[0],
|
bus = &root->link[0];
|
||||||
IORESOURCE_IO, IORESOURCE_IO);
|
compute_allocate_resource(bus,
|
||||||
compute_allocate_resource(bus, &root->resource[1],
|
&root->resource[0], IORESOURCE_IO, IORESOURCE_IO);
|
||||||
IORESOURCE_MEM, IORESOURCE_MEM);
|
compute_allocate_resource(bus,
|
||||||
|
&root->resource[1], IORESOURCE_MEM, IORESOURCE_MEM);
|
||||||
assign_resources(bus);
|
assign_resources(bus);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,19 +77,20 @@ unsigned int scan_static_bus(device_t bus, unsigned int max)
|
|||||||
device_t child;
|
device_t child;
|
||||||
unsigned link;
|
unsigned link;
|
||||||
|
|
||||||
printk_debug("%s for %s\n", __FUNCTION__, dev_path(bus));
|
printk_debug("%s for %s\n", __func__, dev_path(bus));
|
||||||
|
|
||||||
for (link = 0; link < bus->links; link++) {
|
for(link = 0; link < bus->links; link++) {
|
||||||
for (child = bus->link[link].children; child; child = child->sibling) {
|
for(child = bus->link[link].children; child; child = child->sibling) {
|
||||||
if (child->ops && child->ops->enable) {
|
if (child->ops && child->ops->enable) {
|
||||||
child->ops->enable(child);
|
child->ops->enable(child);
|
||||||
}
|
}
|
||||||
printk_debug("%s %s\n", dev_path(child),
|
printk_debug("%s %s\n",
|
||||||
child->enabled?"enabled": "disabled");
|
dev_path(child),
|
||||||
|
child->enabled?"enabled": "disabled");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (link = 0; link < bus->links; link++) {
|
for(link = 0; link < bus->links; link++) {
|
||||||
for (child = bus->link[link].children; child; child = child->sibling) {
|
for(child = bus->link[link].children; child; child = child->sibling) {
|
||||||
if (!child->ops || !child->ops->scan_bus)
|
if (!child->ops || !child->ops->scan_bus)
|
||||||
continue;
|
continue;
|
||||||
printk_debug("%s scanning...\n", dev_path(child));
|
printk_debug("%s scanning...\n", dev_path(child));
|
||||||
@ -101,7 +98,7 @@ unsigned int scan_static_bus(device_t bus, unsigned int max)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
printk_debug("%s done\n", __FUNCTION__);
|
printk_debug("%s done\n", __func__);
|
||||||
|
|
||||||
return max;
|
return max;
|
||||||
}
|
}
|
||||||
@ -119,9 +116,9 @@ unsigned int scan_static_bus(device_t bus, unsigned int max)
|
|||||||
void enable_childrens_resources(device_t dev)
|
void enable_childrens_resources(device_t dev)
|
||||||
{
|
{
|
||||||
unsigned link;
|
unsigned link;
|
||||||
for (link = 0; link < dev->links; link++) {
|
for(link = 0; link < dev->links; link++) {
|
||||||
device_t child;
|
device_t child;
|
||||||
for (child = dev->link[link].children; child; child = child->sibling) {
|
for(child = dev->link[link].children; child; child = child->sibling) {
|
||||||
enable_resources(child);
|
enable_resources(child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -172,11 +169,11 @@ struct device dev_root = {
|
|||||||
.bus = &dev_root.link[0],
|
.bus = &dev_root.link[0],
|
||||||
.path = { .type = DEVICE_PATH_ROOT },
|
.path = { .type = DEVICE_PATH_ROOT },
|
||||||
.enabled = 1,
|
.enabled = 1,
|
||||||
.links = 1,
|
.links = 1,
|
||||||
.link = {
|
.link = {
|
||||||
[0] = {
|
[0] = {
|
||||||
.dev = &dev_root,
|
.dev = &dev_root,
|
||||||
.link = 0,
|
.link = 0,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -30,11 +30,11 @@
|
|||||||
#include "fbcon.h"
|
#include "fbcon.h"
|
||||||
|
|
||||||
struct aty_cmap_regs {
|
struct aty_cmap_regs {
|
||||||
u8 windex;
|
u8 windex;
|
||||||
u8 lut;
|
u8 lut;
|
||||||
u8 mask;
|
u8 mask;
|
||||||
u8 rindex;
|
u8 rindex;
|
||||||
u8 cntl;
|
u8 cntl;
|
||||||
};
|
};
|
||||||
|
|
||||||
#include <console/btext.h>
|
#include <console/btext.h>
|
||||||
@ -427,31 +427,29 @@ int default_blu[] = {0x00,0x00,0x00,0x00,0xaa,0xaa,0xaa,0xaa,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct fb_var_screeninfo default_var = {
|
struct fb_var_screeninfo default_var = {
|
||||||
/* 640x480, 60 Hz, Non-Interlaced (25.175 MHz dotclock) */
|
/* 640x480, 60 Hz, Non-Interlaced (25.175 MHz dotclock) */
|
||||||
640, 480, 640, 480, 0, 0, 8, 0,
|
640, 480, 640, 480, 0, 0, 8, 0,
|
||||||
{0, 8, 0}, {0, 8, 0}, {0, 8, 0}, {0, 0, 0},
|
{0, 8, 0}, {0, 8, 0}, {0, 8, 0}, {0, 0, 0},
|
||||||
0, 0, -1, -1, 0, 39722, 48, 16, 33, 10, 96, 2,
|
0, 0, -1, -1, 0, 39722, 48, 16, 33, 10, 96, 2,
|
||||||
0, FB_VMODE_NONINTERLACED
|
0, FB_VMODE_NONINTERLACED
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*CONFIG_CONSOLE_BTEXT*/
|
#endif /*CONFIG_CONSOLE_BTEXT*/
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
u16 pci_id, chip_type;
|
u16 pci_id, chip_type;
|
||||||
u8 rev_mask, rev_val;
|
u8 rev_mask, rev_val;
|
||||||
const char *name;
|
const char *name;
|
||||||
int pll, mclk, xclk;
|
int pll, mclk, xclk;
|
||||||
u32 features;
|
u32 features;
|
||||||
} aty_chips[] = {
|
} aty_chips[] = {
|
||||||
/* 3D RAGE XL PCI-66/BGA */
|
/* 3D RAGE XL PCI-66/BGA */
|
||||||
{ 0x474f, 0x474f, 0x00, 0x00, m64n_xl_66, 230, 83, 63, M64F_GT | M64F_INTEGRATED | M64F_RESET_3D | M64F_GTB_DSP | M64F_SDRAM_MAGIC_PLL | M64F_EXTRA_BRIGHT | M64F_XL_DLL | M64F_MFB_TIMES_4 },
|
{ 0x474f, 0x474f, 0x00, 0x00, m64n_xl_66, 230, 83, 63, M64F_GT | M64F_INTEGRATED | M64F_RESET_3D | M64F_GTB_DSP | M64F_SDRAM_MAGIC_PLL | M64F_EXTRA_BRIGHT | M64F_XL_DLL | M64F_MFB_TIMES_4 },
|
||||||
/* 3D RAGE XL PCI-33/BGA */
|
/* 3D RAGE XL PCI-33/BGA */
|
||||||
{ 0x4752, 0x4752, 0x00, 0x00, m64n_xl_33, 230, 83, 63, M64F_GT | M64F_INTEGRATED | M64F_RESET_3D | M64F_GTB_DSP | M64F_SDRAM_MAGIC_PLL | M64F_EXTRA_BRIGHT | M64F_XL_DLL | M64F_MFB_TIMES_4 },
|
{ 0x4752, 0x4752, 0x00, 0x00, m64n_xl_33, 230, 83, 63, M64F_GT | M64F_INTEGRATED | M64F_RESET_3D | M64F_GTB_DSP | M64F_SDRAM_MAGIC_PLL | M64F_EXTRA_BRIGHT | M64F_XL_DLL | M64F_MFB_TIMES_4 },
|
||||||
};
|
};
|
||||||
#if CONFIG_CONSOLE_BTEXT==1
|
#if CONFIG_CONSOLE_BTEXT==1
|
||||||
static void aty_calc_mem_refresh(struct fb_info_aty *info,
|
static void aty_calc_mem_refresh(struct fb_info_aty *info, u16 id, int xclk)
|
||||||
u16 id,
|
|
||||||
int xclk)
|
|
||||||
{
|
{
|
||||||
int i, size;
|
int i, size;
|
||||||
#if 0
|
#if 0
|
||||||
@ -484,7 +482,8 @@ static void aty_calc_mem_refresh(struct fb_info_aty *info,
|
|||||||
info->mem_refresh_rate = i;
|
info->mem_refresh_rate = i;
|
||||||
}
|
}
|
||||||
#endif /*CONFIG_CONSOLE_BTEXT */
|
#endif /*CONFIG_CONSOLE_BTEXT */
|
||||||
static void ati_ragexl_init(device_t dev) {
|
static void ati_ragexl_init(device_t dev)
|
||||||
|
{
|
||||||
u32 chip_id;
|
u32 chip_id;
|
||||||
u32 i;
|
u32 i;
|
||||||
int j;
|
int j;
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
#ifndef BOOT_TABLES_H
|
#ifndef BOOT_TABLES_H
|
||||||
#define BOOT_TABLES_H
|
#define BOOT_TABLES_H
|
||||||
|
|
||||||
#include <mem.h>
|
|
||||||
#include <boot/linuxbios_tables.h>
|
#include <boot/linuxbios_tables.h>
|
||||||
|
|
||||||
struct lb_memory *write_tables(struct mem_range *mem, unsigned long *processor_map);
|
struct lb_memory *write_tables(void);
|
||||||
|
|
||||||
#endif /* BOOT_TABLES_H */
|
#endif /* BOOT_TABLES_H */
|
||||||
|
@ -10,7 +10,7 @@ void console_tx_flush(void);
|
|||||||
unsigned char console_rx_byte(void);
|
unsigned char console_rx_byte(void);
|
||||||
int console_tst_byte(void);
|
int console_tst_byte(void);
|
||||||
void post_code(uint8_t value);
|
void post_code(uint8_t value);
|
||||||
void die(char *msg);
|
void die(const char *msg);
|
||||||
|
|
||||||
struct console_driver {
|
struct console_driver {
|
||||||
void (*init)(void);
|
void (*init)(void);
|
||||||
@ -20,7 +20,7 @@ struct console_driver {
|
|||||||
int (*tst_byte)(void);
|
int (*tst_byte)(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
#define __console __attribute__((unused, __section__ (".rodata.console_drivers")))
|
#define __console __attribute__((used, __section__ (".rodata.console_drivers")))
|
||||||
|
|
||||||
/* Defined by the linker... */
|
/* Defined by the linker... */
|
||||||
extern struct console_driver console_drivers[];
|
extern struct console_driver console_drivers[];
|
||||||
|
@ -42,8 +42,8 @@ struct device {
|
|||||||
device_t next; /* chain of all devices */
|
device_t next; /* chain of all devices */
|
||||||
|
|
||||||
struct device_path path;
|
struct device_path path;
|
||||||
unsigned short vendor;
|
unsigned vendor;
|
||||||
unsigned short device;
|
unsigned device;
|
||||||
unsigned int class; /* 3 bytes: (base,sub,prog-if) */
|
unsigned int class; /* 3 bytes: (base,sub,prog-if) */
|
||||||
unsigned int hdr_type; /* PCI header type */
|
unsigned int hdr_type; /* PCI header type */
|
||||||
unsigned int enabled : 1; /* set if we should enable the device */
|
unsigned int enabled : 1; /* set if we should enable the device */
|
||||||
|
@ -4,9 +4,11 @@
|
|||||||
enum device_path_type {
|
enum device_path_type {
|
||||||
DEVICE_PATH_NONE = 0,
|
DEVICE_PATH_NONE = 0,
|
||||||
DEVICE_PATH_ROOT,
|
DEVICE_PATH_ROOT,
|
||||||
|
DEVICE_PATH_DEFAULT_CPU,
|
||||||
DEVICE_PATH_PCI,
|
DEVICE_PATH_PCI,
|
||||||
DEVICE_PATH_PNP,
|
DEVICE_PATH_PNP,
|
||||||
DEVICE_PATH_I2C,
|
DEVICE_PATH_I2C,
|
||||||
|
DEVICE_PATH_APIC,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct pci_path
|
struct pci_path
|
||||||
@ -26,12 +28,18 @@ struct i2c_path
|
|||||||
unsigned device;
|
unsigned device;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct apic_path
|
||||||
|
{
|
||||||
|
unsigned apic_id;
|
||||||
|
};
|
||||||
|
|
||||||
struct device_path {
|
struct device_path {
|
||||||
enum device_path_type type;
|
enum device_path_type type;
|
||||||
union {
|
union {
|
||||||
struct pci_path pci;
|
struct pci_path pci;
|
||||||
struct pnp_path pnp;
|
struct pnp_path pnp;
|
||||||
struct i2c_path i2c;
|
struct i2c_path i2c;
|
||||||
|
struct apic_path apic;
|
||||||
} u;
|
} u;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -21,13 +21,18 @@
|
|||||||
#include <device/pci_ops.h>
|
#include <device/pci_ops.h>
|
||||||
|
|
||||||
|
|
||||||
|
/* Common pci operations without a standard interface */
|
||||||
|
struct pci_operations {
|
||||||
|
void (*set_subsystem)(device_t dev, unsigned vendor, unsigned device);
|
||||||
|
};
|
||||||
|
|
||||||
struct pci_driver {
|
struct pci_driver {
|
||||||
struct device_operations *ops;
|
struct device_operations *ops;
|
||||||
unsigned short vendor;
|
unsigned short vendor;
|
||||||
unsigned short device;
|
unsigned short device;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define __pci_driver __attribute__ ((unused,__section__(".rodata.pci_driver")))
|
#define __pci_driver __attribute__ ((used,__section__(".rodata.pci_driver")))
|
||||||
/** start of compile time generated pci driver array */
|
/** start of compile time generated pci driver array */
|
||||||
extern struct pci_driver pci_drivers[];
|
extern struct pci_driver pci_drivers[];
|
||||||
/** end of compile time generated pci driver array */
|
/** end of compile time generated pci driver array */
|
||||||
@ -37,7 +42,6 @@ extern struct pci_driver epci_drivers[];
|
|||||||
struct device_operations default_pci_ops_dev;
|
struct device_operations default_pci_ops_dev;
|
||||||
struct device_operations default_pci_ops_bus;
|
struct device_operations default_pci_ops_bus;
|
||||||
|
|
||||||
|
|
||||||
void pci_dev_read_resources(device_t dev);
|
void pci_dev_read_resources(device_t dev);
|
||||||
void pci_bus_read_resources(device_t dev);
|
void pci_bus_read_resources(device_t dev);
|
||||||
void pci_dev_set_resources(device_t dev);
|
void pci_dev_set_resources(device_t dev);
|
||||||
@ -45,8 +49,19 @@ void pci_dev_enable_resources(device_t dev);
|
|||||||
void pci_bus_enable_resources(device_t dev);
|
void pci_bus_enable_resources(device_t dev);
|
||||||
unsigned int pci_scan_bridge(device_t bus, unsigned int max);
|
unsigned int pci_scan_bridge(device_t bus, unsigned int max);
|
||||||
unsigned int pci_scan_bus(struct bus *bus, unsigned min_devfn, unsigned max_devfn, unsigned int max);
|
unsigned int pci_scan_bus(struct bus *bus, unsigned min_devfn, unsigned max_devfn, unsigned int max);
|
||||||
|
struct resource *pci_get_resource(struct device *dev, unsigned long index);
|
||||||
|
|
||||||
#define PCI_IO_BRIDGE_ALIGN 4096
|
#define PCI_IO_BRIDGE_ALIGN 4096
|
||||||
#define PCI_MEM_BRIDGE_ALIGN (1024*1024)
|
#define PCI_MEM_BRIDGE_ALIGN (1024*1024)
|
||||||
|
|
||||||
|
static inline struct pci_operations *ops_pci(device_t dev)
|
||||||
|
{
|
||||||
|
struct pci_operations *pops;
|
||||||
|
pops = 0;
|
||||||
|
if (dev && dev->ops) {
|
||||||
|
pops = dev->ops->ops_pci;
|
||||||
|
}
|
||||||
|
return pops;
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* PCI_H */
|
#endif /* PCI_H */
|
||||||
|
@ -1757,6 +1757,7 @@
|
|||||||
#define PCI_DEVICE_ID_INTEL_82801DB_7 0x24c7
|
#define PCI_DEVICE_ID_INTEL_82801DB_7 0x24c7
|
||||||
#define PCI_DEVICE_ID_INTEL_82801DB_11 0x24cb
|
#define PCI_DEVICE_ID_INTEL_82801DB_11 0x24cb
|
||||||
#define PCI_DEVICE_ID_INTEL_82801DB_13 0x24cd
|
#define PCI_DEVICE_ID_INTEL_82801DB_13 0x24cd
|
||||||
|
#define PCI_DEVICE_ID_INTEL_82801EB_0 0x24d0
|
||||||
#define PCI_DEVICE_ID_INTEL_80310 0x530d
|
#define PCI_DEVICE_ID_INTEL_80310 0x530d
|
||||||
#define PCI_DEVICE_ID_INTEL_82810_MC1 0x7120
|
#define PCI_DEVICE_ID_INTEL_82810_MC1 0x7120
|
||||||
#define PCI_DEVICE_ID_INTEL_82810_IG1 0x7121
|
#define PCI_DEVICE_ID_INTEL_82810_IG1 0x7121
|
||||||
|
@ -36,11 +36,13 @@ struct pnp_info {
|
|||||||
unsigned flags;
|
unsigned flags;
|
||||||
#define PNP_IO0 0x01
|
#define PNP_IO0 0x01
|
||||||
#define PNP_IO1 0x02
|
#define PNP_IO1 0x02
|
||||||
#define PNP_IRQ0 0x04
|
#define PNP_IO2 0x04
|
||||||
#define PNP_IRQ1 0x08
|
#define PNP_IO3 0x08
|
||||||
#define PNP_DRQ0 0x10
|
#define PNP_IRQ0 0x10
|
||||||
#define PNP_DRQ1 0x20
|
#define PNP_IRQ1 0x20
|
||||||
struct io_info io0, io1;
|
#define PNP_DRQ0 0x40
|
||||||
|
#define PNP_DRQ1 0x80
|
||||||
|
struct io_info io0, io1, io2, io3;
|
||||||
};
|
};
|
||||||
struct resource *pnp_get_resource(device_t dev, unsigned index);
|
struct resource *pnp_get_resource(device_t dev, unsigned index);
|
||||||
void pnp_enumerate(struct chip *chip, unsigned functions,
|
void pnp_enumerate(struct chip *chip, unsigned functions,
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
#define PNP_IDX_IO0 0x60
|
#define PNP_IDX_IO0 0x60
|
||||||
#define PNP_IDX_IO1 0x62
|
#define PNP_IDX_IO1 0x62
|
||||||
|
#define PNP_IDX_IO2 0x64
|
||||||
|
#define PNP_IDX_IO3 0x66
|
||||||
#define PNP_IDX_IRQ0 0x70
|
#define PNP_IDX_IRQ0 0x70
|
||||||
#define PNP_IDX_IRQ1 0x72
|
#define PNP_IDX_IRQ1 0x72
|
||||||
#define PNP_IDX_DRQ0 0x74
|
#define PNP_IDX_DRQ0 0x74
|
||||||
|
@ -31,6 +31,8 @@ uses LB_CKS_RANGE_END
|
|||||||
uses LB_CKS_LOC
|
uses LB_CKS_LOC
|
||||||
uses MAINBOARD_PART_NUMBER
|
uses MAINBOARD_PART_NUMBER
|
||||||
uses MAINBOARD_VENDOR
|
uses MAINBOARD_VENDOR
|
||||||
|
uses MAINBOARD_PCI_SUBSYSTEM_VENDOR_ID
|
||||||
|
uses MAINBOARD_PCI_SUBSYSTEM_DEVICE_ID
|
||||||
|
|
||||||
|
|
||||||
## ROM_SIZE is the size of boot ROM that this board will use.
|
## ROM_SIZE is the size of boot ROM that this board will use.
|
||||||
@ -95,6 +97,8 @@ default CONFIG_IOAPIC=1
|
|||||||
##
|
##
|
||||||
default MAINBOARD_PART_NUMBER="HDAMA"
|
default MAINBOARD_PART_NUMBER="HDAMA"
|
||||||
default MAINBOARD_VENDOR="ARIMA"
|
default MAINBOARD_VENDOR="ARIMA"
|
||||||
|
default MAINBOARD_PCI_SUBSYSTEM_VENDOR_ID=0x161f
|
||||||
|
default MAINBOARD_PCI_SUBSYSTEM_DEVICE_ID=0x3016
|
||||||
|
|
||||||
###
|
###
|
||||||
### LinuxBIOS layout values
|
### LinuxBIOS layout values
|
||||||
@ -109,9 +113,9 @@ default ROM_IMAGE_SIZE = 65536
|
|||||||
default STACK_SIZE=0x2000
|
default STACK_SIZE=0x2000
|
||||||
|
|
||||||
##
|
##
|
||||||
## Use a small 16K heap
|
## Use a small 32K heap
|
||||||
##
|
##
|
||||||
default HEAP_SIZE=0x4000
|
default HEAP_SIZE=0x8000
|
||||||
|
|
||||||
##
|
##
|
||||||
## Only use the option table in a normal image
|
## Only use the option table in a normal image
|
||||||
@ -158,7 +162,6 @@ default XIP_ROM_BASE = ( _ROMBASE + ROM_IMAGE_SIZE - XIP_ROM_SIZE )
|
|||||||
##
|
##
|
||||||
|
|
||||||
arch i386 end
|
arch i386 end
|
||||||
#cpu k8 end
|
|
||||||
|
|
||||||
##
|
##
|
||||||
## Build the objects we have code for in this directory.
|
## Build the objects we have code for in this directory.
|
||||||
@ -193,21 +196,20 @@ end
|
|||||||
##
|
##
|
||||||
## Build our 16 bit and 32 bit linuxBIOS entry code
|
## Build our 16 bit and 32 bit linuxBIOS entry code
|
||||||
##
|
##
|
||||||
mainboardinit cpu/i386/entry16.inc
|
mainboardinit cpu/x86/16bit/entry16.inc
|
||||||
mainboardinit cpu/i386/entry32.inc
|
mainboardinit cpu/x86/32bit/entry32.inc
|
||||||
mainboardinit cpu/i386/bist32.inc
|
ldscript /cpu/x86/16bit/entry16.lds
|
||||||
ldscript /cpu/i386/entry16.lds
|
ldscript /cpu/x86/32bit/entry32.lds
|
||||||
ldscript /cpu/i386/entry32.lds
|
|
||||||
|
|
||||||
##
|
##
|
||||||
## Build our reset vector (This is where linuxBIOS is entered)
|
## Build our reset vector (This is where linuxBIOS is entered)
|
||||||
##
|
##
|
||||||
if USE_FALLBACK_IMAGE
|
if USE_FALLBACK_IMAGE
|
||||||
mainboardinit cpu/i386/reset16.inc
|
mainboardinit cpu/x86/16bit/reset16.inc
|
||||||
ldscript /cpu/i386/reset16.lds
|
ldscript /cpu/x86/16bit/reset16.lds
|
||||||
else
|
else
|
||||||
mainboardinit cpu/i386/reset32.inc
|
mainboardinit cpu/x86/32bit/reset32.inc
|
||||||
ldscript /cpu/i386/reset32.lds
|
ldscript /cpu/x86/32bit/reset32.lds
|
||||||
end
|
end
|
||||||
|
|
||||||
### Should this be in the northbridge code?
|
### Should this be in the northbridge code?
|
||||||
@ -219,11 +221,6 @@ mainboardinit arch/i386/lib/cpu_reset.inc
|
|||||||
mainboardinit arch/i386/lib/id.inc
|
mainboardinit arch/i386/lib/id.inc
|
||||||
ldscript /arch/i386/lib/id.lds
|
ldscript /arch/i386/lib/id.lds
|
||||||
|
|
||||||
##
|
|
||||||
## Setup our mtrrs
|
|
||||||
##
|
|
||||||
mainboardinit cpu/k8/earlymtrr.inc
|
|
||||||
|
|
||||||
###
|
###
|
||||||
### This is the early phase of linuxBIOS startup
|
### This is the early phase of linuxBIOS startup
|
||||||
### Things are delicate and we test to see if we should
|
### Things are delicate and we test to see if we should
|
||||||
@ -241,9 +238,12 @@ end
|
|||||||
##
|
##
|
||||||
## Setup RAM
|
## Setup RAM
|
||||||
##
|
##
|
||||||
mainboardinit cpu/k8/enable_mmx_sse.inc
|
mainboardinit cpu/x86/fpu/enable_fpu.inc
|
||||||
|
mainboardinit cpu/x86/mmx/enable_mmx.inc
|
||||||
|
mainboardinit cpu/x86/sse/enable_sse.inc
|
||||||
mainboardinit ./auto.inc
|
mainboardinit ./auto.inc
|
||||||
mainboardinit cpu/k8/disable_mmx_sse.inc
|
mainboardinit cpu/x86/sse/disable_sse.inc
|
||||||
|
mainboardinit cpu/x86/mmx/disable_mmx.inc
|
||||||
|
|
||||||
##
|
##
|
||||||
## Include the secondary Configuration files
|
## Include the secondary Configuration files
|
||||||
@ -252,30 +252,25 @@ dir /pc80
|
|||||||
config chip.h
|
config chip.h
|
||||||
|
|
||||||
northbridge amd/amdk8 "mc0"
|
northbridge amd/amdk8 "mc0"
|
||||||
pci 0:18.0
|
pnp cf8.0
|
||||||
pci 0:18.0
|
northbridge amd/amdk8 "mc1" link 0
|
||||||
pci 0:18.0
|
pci 0:19.0
|
||||||
pci 0:18.1
|
pci 0:19.0
|
||||||
pci 0:18.2
|
pci 0:19.0
|
||||||
pci 0:18.3
|
pci 0:19.1
|
||||||
southbridge amd/amd8131 "amd8131" link 0
|
pci 0:19.2
|
||||||
|
pci 0:19.3
|
||||||
|
end
|
||||||
|
pci 1:18.0
|
||||||
|
southbridge amd/amd8131 "amd8131" link 1
|
||||||
pci 0:0.0
|
pci 0:0.0
|
||||||
pci 0:0.1
|
pci 0:0.1
|
||||||
pci 0:1.0
|
pci 0:1.0
|
||||||
pci 0:1.1
|
pci 0:1.1
|
||||||
end
|
end
|
||||||
southbridge amd/amd8111 "amd8111" link 0
|
southbridge amd/amd8111 "amd8111" link 1
|
||||||
pci 0:0.0
|
pci 0:0.0
|
||||||
pci 0:1.0 on
|
pci 0:1.0 on
|
||||||
pci 0:1.1 on
|
|
||||||
pci 0:1.2 on
|
|
||||||
pci 0:1.3 on
|
|
||||||
pci 0:1.5 off
|
|
||||||
pci 0:1.6 off
|
|
||||||
pci 1:0.0 on
|
|
||||||
pci 1:0.1 on
|
|
||||||
pci 1:0.2 on
|
|
||||||
pci 1:1.0 off
|
|
||||||
superio NSC/pc87360 link 1
|
superio NSC/pc87360 link 1
|
||||||
pnp 2e.0 off # Floppy
|
pnp 2e.0 off # Floppy
|
||||||
io 0x60 = 0x3f0
|
io 0x60 = 0x3f0
|
||||||
@ -301,29 +296,64 @@ northbridge amd/amdk8 "mc0"
|
|||||||
pnp 2e.9 off # FSCM
|
pnp 2e.9 off # FSCM
|
||||||
pnp 2e.a off # WDT
|
pnp 2e.a off # WDT
|
||||||
end
|
end
|
||||||
|
pci 0:1.1 on
|
||||||
|
pci 0:1.2 on
|
||||||
|
pci 0:1.3 on # ACPI/SMBUS
|
||||||
|
chip drivers/generic/generic link 4
|
||||||
|
#phillips pca9545 smbus mux
|
||||||
|
i2c 70
|
||||||
|
# analog_devices adm1026
|
||||||
|
chip drivers/generic/generic link 0
|
||||||
|
i2c 2c
|
||||||
|
end
|
||||||
|
i2c 70
|
||||||
|
i2c 70
|
||||||
|
i2c 70
|
||||||
|
end
|
||||||
|
chip drivers/generic/generic link 4 #dimm 0-0-0
|
||||||
|
i2c 50
|
||||||
|
end
|
||||||
|
chip drivers/generic/generic link 4 #dimm 0-0-1
|
||||||
|
i2c 51
|
||||||
|
end
|
||||||
|
chip drivers/generic/generic link 4 #dimm 0-1-0
|
||||||
|
i2c 52
|
||||||
|
end
|
||||||
|
chip drivers/generic/generic link 4 #dimm 0-1-1
|
||||||
|
i2c 53
|
||||||
|
end
|
||||||
|
chip drivers/generic/generic link 4 #dimm 1-0-0
|
||||||
|
i2c 54
|
||||||
|
end
|
||||||
|
chip drivers/generic/generic link 4 #dimm 1-0-1
|
||||||
|
i2c 55
|
||||||
|
end
|
||||||
|
chip drivers/generic/generic link 4 #dimm 1-1-0
|
||||||
|
i2c 56
|
||||||
|
end
|
||||||
|
chip drivers/generic/generic link 4 #dimm 1-1-1
|
||||||
|
i2c 57
|
||||||
|
end
|
||||||
|
pci 0:1.5 off
|
||||||
|
pci 0:1.6 off
|
||||||
|
pci 1:0.0 on
|
||||||
|
pci 1:0.1 on
|
||||||
|
pci 1:0.2 on
|
||||||
|
pci 1:1.0 off
|
||||||
end
|
end
|
||||||
|
pci 1:18.0
|
||||||
|
pci 1:18.0
|
||||||
|
pci 1:18.1
|
||||||
|
pci 1:18.2
|
||||||
|
pci 1:18.3
|
||||||
end
|
end
|
||||||
|
|
||||||
northbridge amd/amdk8 "mc1"
|
|
||||||
pci 0:19.0
|
cpu amd/socket_940 "cpu0" link 1
|
||||||
pci 0:19.0
|
apic 0
|
||||||
pci 0:19.0
|
|
||||||
pci 0:19.1
|
|
||||||
pci 0:19.2
|
|
||||||
pci 0:19.3
|
|
||||||
end
|
end
|
||||||
|
|
||||||
cpu k8 "cpu0"
|
cpu amd/socket_940 "cpu1" link 1
|
||||||
register "ldt0" = "{ .chip = &amd8131, .ht_width=16, .ht_speed=600 }"
|
apic 1
|
||||||
end
|
end
|
||||||
|
|
||||||
cpu k8 "cpu1"
|
|
||||||
end
|
|
||||||
|
|
||||||
##
|
|
||||||
## Include the old serial code for those few places that still need it.
|
|
||||||
##
|
|
||||||
mainboardinit pc80/serial.inc
|
|
||||||
mainboardinit arch/i386/lib/console.inc
|
|
||||||
mainboardinit cpu/i386/bist32_fail.inc
|
|
||||||
|
|
||||||
|
@ -4,7 +4,8 @@
|
|||||||
#include <arch/io.h>
|
#include <arch/io.h>
|
||||||
#include <device/pnp_def.h>
|
#include <device/pnp_def.h>
|
||||||
#include <arch/romcc_io.h>
|
#include <arch/romcc_io.h>
|
||||||
#include <arch/smp/lapic.h>
|
#include <cpu/x86/lapic.h>
|
||||||
|
#include <arch/cpu.h>
|
||||||
#include "option_table.h"
|
#include "option_table.h"
|
||||||
#include "pc80/mc146818rtc_early.c"
|
#include "pc80/mc146818rtc_early.c"
|
||||||
#include "pc80/serial.c"
|
#include "pc80/serial.c"
|
||||||
@ -13,13 +14,15 @@
|
|||||||
#include "northbridge/amd/amdk8/incoherent_ht.c"
|
#include "northbridge/amd/amdk8/incoherent_ht.c"
|
||||||
#include "southbridge/amd/amd8111/amd8111_early_smbus.c"
|
#include "southbridge/amd/amd8111/amd8111_early_smbus.c"
|
||||||
#include "northbridge/amd/amdk8/raminit.h"
|
#include "northbridge/amd/amdk8/raminit.h"
|
||||||
#include "cpu/k8/apic_timer.c"
|
#include "cpu/amd/model_fxx/apic_timer.c"
|
||||||
#include "lib/delay.c"
|
#include "lib/delay.c"
|
||||||
#include "cpu/p6/boot_cpu.c"
|
#include "cpu/x86/lapic/boot_cpu.c"
|
||||||
#include "northbridge/amd/amdk8/reset_test.c"
|
#include "northbridge/amd/amdk8/reset_test.c"
|
||||||
#include "northbridge/amd/amdk8/debug.c"
|
#include "northbridge/amd/amdk8/debug.c"
|
||||||
#include "northbridge/amd/amdk8/cpu_rev.c"
|
#include "northbridge/amd/amdk8/cpu_rev.c"
|
||||||
#include "superio/NSC/pc87360/pc87360_early_serial.c"
|
#include "superio/NSC/pc87360/pc87360_early_serial.c"
|
||||||
|
#include "cpu/amd/mtrr/amd_earlymtrr.c"
|
||||||
|
#include "cpu/x86/bist.h"
|
||||||
|
|
||||||
#define SERIAL_DEV PNP_DEV(0x2e, PC87360_SP1)
|
#define SERIAL_DEV PNP_DEV(0x2e, PC87360_SP1)
|
||||||
|
|
||||||
@ -50,7 +53,8 @@ static void memreset_setup(void)
|
|||||||
outb((0 << 7)|(0 << 6)|(0<<5)|(0<<4)|(1<<2)|(0<<0), SMBUS_IO_BASE + 0xc0 + 28);
|
outb((0 << 7)|(0 << 6)|(0<<5)|(0<<4)|(1<<2)|(0<<0), SMBUS_IO_BASE + 0xc0 + 28);
|
||||||
/* Ensure the BIOS has control of the memory lines */
|
/* Ensure the BIOS has control of the memory lines */
|
||||||
outb((0 << 7)|(0 << 6)|(0<<5)|(0<<4)|(1<<2)|(0<<0), SMBUS_IO_BASE + 0xc0 + 29);
|
outb((0 << 7)|(0 << 6)|(0<<5)|(0<<4)|(1<<2)|(0<<0), SMBUS_IO_BASE + 0xc0 + 29);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
/* Ensure the CPU has controll of the memory lines */
|
/* Ensure the CPU has controll of the memory lines */
|
||||||
outb((0 << 7)|(0 << 6)|(0<<5)|(0<<4)|(1<<2)|(1<<0), SMBUS_IO_BASE + 0xc0 + 29);
|
outb((0 << 7)|(0 << 6)|(0<<5)|(0<<4)|(1<<2)|(1<<0), SMBUS_IO_BASE + 0xc0 + 29);
|
||||||
}
|
}
|
||||||
@ -128,7 +132,7 @@ static inline int spd_read_byte(unsigned device, unsigned address)
|
|||||||
#define FIRST_CPU 1
|
#define FIRST_CPU 1
|
||||||
#define SECOND_CPU 1
|
#define SECOND_CPU 1
|
||||||
#define TOTAL_CPUS (FIRST_CPU + SECOND_CPU)
|
#define TOTAL_CPUS (FIRST_CPU + SECOND_CPU)
|
||||||
static void main(void)
|
static void main(unsigned long bist)
|
||||||
{
|
{
|
||||||
static const struct mem_controller cpu[] = {
|
static const struct mem_controller cpu[] = {
|
||||||
#if FIRST_CPU
|
#if FIRST_CPU
|
||||||
@ -156,25 +160,29 @@ static void main(void)
|
|||||||
};
|
};
|
||||||
|
|
||||||
int needs_reset;
|
int needs_reset;
|
||||||
enable_lapic();
|
if (bist == 0) {
|
||||||
init_timer();
|
/* Skip this if there was a built in self test failure */
|
||||||
|
amd_early_mtrr_init();
|
||||||
if (cpu_init_detected()) {
|
enable_lapic();
|
||||||
asm volatile ("jmp __cpu_reset");
|
init_timer();
|
||||||
|
if (cpu_init_detected()) {
|
||||||
|
asm volatile ("jmp __cpu_reset");
|
||||||
|
}
|
||||||
|
distinguish_cpu_resets();
|
||||||
|
if (!boot_cpu()) {
|
||||||
|
stop_this_cpu();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
/* Setup the console */
|
||||||
distinguish_cpu_resets();
|
|
||||||
if (!boot_cpu()) {
|
|
||||||
stop_this_cpu();
|
|
||||||
}
|
|
||||||
|
|
||||||
pc87360_enable_serial(SERIAL_DEV, TTYS0_BASE);
|
pc87360_enable_serial(SERIAL_DEV, TTYS0_BASE);
|
||||||
uart_init();
|
uart_init();
|
||||||
console_init();
|
console_init();
|
||||||
|
|
||||||
|
/* Halt if there was a built in self test failure */
|
||||||
|
report_bist_failure(bist);
|
||||||
|
|
||||||
setup_default_resource_map();
|
setup_default_resource_map();
|
||||||
needs_reset = setup_coherent_ht_domain();
|
needs_reset = setup_coherent_ht_domain();
|
||||||
/* Non-coherent HT is on LDT0 */
|
|
||||||
needs_reset |= ht_setup_chain(PCI_DEV(0, 0x18, 0), 0x80);
|
needs_reset |= ht_setup_chain(PCI_DEV(0, 0x18, 0), 0x80);
|
||||||
if (needs_reset) {
|
if (needs_reset) {
|
||||||
print_info("ht reset -\r\n");
|
print_info("ht reset -\r\n");
|
||||||
@ -184,9 +192,7 @@ static void main(void)
|
|||||||
#if 0
|
#if 0
|
||||||
print_pci_devices();
|
print_pci_devices();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
enable_smbus();
|
enable_smbus();
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
dump_spd_registers(&cpu[0]);
|
dump_spd_registers(&cpu[0]);
|
||||||
#endif
|
#endif
|
||||||
|
@ -41,6 +41,7 @@ entries
|
|||||||
432 8 h 0 boot_countdown
|
432 8 h 0 boot_countdown
|
||||||
440 4 e 9 slow_cpu
|
440 4 e 9 slow_cpu
|
||||||
444 1 e 1 nmi
|
444 1 e 1 nmi
|
||||||
|
445 1 e 1 iommu
|
||||||
728 256 h 0 user_data
|
728 256 h 0 user_data
|
||||||
984 16 h 0 check_sum
|
984 16 h 0 check_sum
|
||||||
# Reserve the extended AMD configuration registers
|
# Reserve the extended AMD configuration registers
|
||||||
|
@ -4,22 +4,15 @@
|
|||||||
#include <device/pci_ids.h>
|
#include <device/pci_ids.h>
|
||||||
#include <arch/io.h>
|
#include <arch/io.h>
|
||||||
#include <arch/romcc_io.h>
|
#include <arch/romcc_io.h>
|
||||||
#include <arch/smp/lapic.h>
|
#include <cpu/x86/lapic.h>
|
||||||
#include "pc80/mc146818rtc_early.c"
|
#include "pc80/mc146818rtc_early.c"
|
||||||
#include "southbridge/amd/amd8111/amd8111_enable_rom.c"
|
#include "southbridge/amd/amd8111/amd8111_enable_rom.c"
|
||||||
#include "northbridge/amd/amdk8/early_ht.c"
|
#include "northbridge/amd/amdk8/early_ht.c"
|
||||||
#include "cpu/p6/boot_cpu.c"
|
#include "cpu/x86/lapic/boot_cpu.c"
|
||||||
#include "northbridge/amd/amdk8/reset_test.c"
|
#include "northbridge/amd/amdk8/reset_test.c"
|
||||||
|
|
||||||
#define HAVE_REGPARM_SUPPORT 0
|
|
||||||
#if HAVE_REGPARM_SUPPORT
|
|
||||||
static unsigned long main(unsigned long bist)
|
static unsigned long main(unsigned long bist)
|
||||||
{
|
{
|
||||||
#else
|
|
||||||
static void main(void)
|
|
||||||
{
|
|
||||||
unsigned long bist = 0;
|
|
||||||
#endif
|
|
||||||
/* Make cerain my local apic is useable */
|
/* Make cerain my local apic is useable */
|
||||||
enable_lapic();
|
enable_lapic();
|
||||||
|
|
||||||
@ -72,9 +65,5 @@ static void main(void)
|
|||||||
: /* clobbers */
|
: /* clobbers */
|
||||||
);
|
);
|
||||||
fallback_image:
|
fallback_image:
|
||||||
#if HAVE_REGPARM_SUPPORT
|
|
||||||
return bist;
|
return bist;
|
||||||
#else
|
|
||||||
return;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
@ -3,145 +3,251 @@
|
|||||||
#include <device/pci.h>
|
#include <device/pci.h>
|
||||||
#include <device/pci_ids.h>
|
#include <device/pci_ids.h>
|
||||||
#include <device/pci_ops.h>
|
#include <device/pci_ops.h>
|
||||||
#include <cpu/p6/msr.h>
|
#include <cpu/x86/msr.h>
|
||||||
|
#include <part/hard_reset.h>
|
||||||
|
#include <device/smbus.h>
|
||||||
|
#include <delay.h>
|
||||||
|
|
||||||
#include <arch/io.h>
|
#include <arch/io.h>
|
||||||
#include <device/chip.h>
|
#include <device/chip.h>
|
||||||
#include "../../../northbridge/amd/amdk8/northbridge.h"
|
#include "../../../northbridge/amd/amdk8/northbridge.h"
|
||||||
|
#include "../../../northbridge/amd/amdk8/cpu_rev.c"
|
||||||
#include "chip.h"
|
#include "chip.h"
|
||||||
|
|
||||||
#include "pc80/mc146818rtc.h"
|
#include "pc80/mc146818rtc.h"
|
||||||
|
|
||||||
|
|
||||||
|
#undef DEBUG
|
||||||
unsigned long initial_apicid[CONFIG_MAX_CPUS] =
|
#define DEBUG 0
|
||||||
|
#if DEBUG
|
||||||
|
static void debug_init(device_t dev)
|
||||||
{
|
{
|
||||||
0, 1,
|
unsigned bus;
|
||||||
|
unsigned devfn;
|
||||||
|
#if 0
|
||||||
|
for(bus = 0; bus < 256; bus++) {
|
||||||
|
for(devfn = 0; devfn < 256; devfn++) {
|
||||||
|
int i;
|
||||||
|
dev = dev_find_slot(bus, devfn);
|
||||||
|
if (!dev) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!dev->enabled) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
printk_info("%02x:%02x.%0x aka %s\n",
|
||||||
|
bus, devfn >> 3, devfn & 7, dev_path(dev));
|
||||||
|
for(i = 0; i < 256; i++) {
|
||||||
|
if ((i & 0x0f) == 0) {
|
||||||
|
printk_info("%02x:", i);
|
||||||
|
}
|
||||||
|
printk_info(" %02x", pci_read_config8(dev, i));
|
||||||
|
if ((i & 0x0f) == 0xf) {
|
||||||
|
printk_info("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printk_info("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#if 0
|
||||||
|
msr_t msr;
|
||||||
|
unsigned index;
|
||||||
|
unsigned eax, ebx, ecx, edx;
|
||||||
|
index = 0x80000007;
|
||||||
|
printk_debug("calling cpuid 0x%08x\n", index);
|
||||||
|
asm volatile(
|
||||||
|
"cpuid"
|
||||||
|
: "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx)
|
||||||
|
: "a" (index)
|
||||||
|
);
|
||||||
|
printk_debug("cpuid[%08x]: %08x %08x %08x %08x\n",
|
||||||
|
index, eax, ebx, ecx, edx);
|
||||||
|
if (edx & (3 << 1)) {
|
||||||
|
index = 0xC0010042;
|
||||||
|
printk_debug("Reading msr: 0x%08x\n", index);
|
||||||
|
msr = rdmsr(index);
|
||||||
|
printk_debug("msr[0x%08x]: 0x%08x%08x\n",
|
||||||
|
index, msr.hi, msr.hi);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static void debug_noop(device_t dummy)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct device_operations debug_operations = {
|
||||||
|
.read_resources = debug_noop,
|
||||||
|
.set_resources = debug_noop,
|
||||||
|
.enable_resources = debug_noop,
|
||||||
|
.init = debug_init,
|
||||||
};
|
};
|
||||||
|
|
||||||
#define SMBGSTATUS 0xe0
|
static unsigned int scan_root_bus(device_t root, unsigned int max)
|
||||||
#define SMBGCTL 0xe2
|
|
||||||
#define SMBHSTADDR 0xe4
|
|
||||||
#define SMBHSTDAT 0xe6
|
|
||||||
#define SMBHSTCMD 0xe8
|
|
||||||
#define SMBHSTFIFO 0xe9
|
|
||||||
|
|
||||||
#define SMBUS_TIMEOUT (100*1000*10)
|
|
||||||
|
|
||||||
static inline void smbus_delay(void)
|
|
||||||
{
|
{
|
||||||
outb(0x80, 0x80);
|
struct device_path path;
|
||||||
|
device_t debug;
|
||||||
|
max = root_dev_scan_bus(root, max);
|
||||||
|
path.type = DEVICE_PATH_PNP;
|
||||||
|
path.u.pnp.port = 0;
|
||||||
|
path.u.pnp.device = 0;
|
||||||
|
debug = alloc_dev(&root->link[1], &path);
|
||||||
|
debug->ops = &debug_operations;
|
||||||
|
return max;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
static void handle_smbus_error(int value, const char *msg)
|
||||||
|
{
|
||||||
|
if (value >= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
switch(value) {
|
||||||
|
case SMBUS_WAIT_UNTIL_READY_TIMEOUT:
|
||||||
|
printk_emerg("SMBUS wait until ready timed out - resetting...");
|
||||||
|
hard_reset();
|
||||||
|
break;
|
||||||
|
case SMBUS_WAIT_UNTIL_DONE_TIMEOUT:
|
||||||
|
printk_emerg("SMBUS wait until done timed out - resetting...");
|
||||||
|
hard_reset();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
die(msg);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int smbus_wait_until_ready(unsigned smbus_io_base)
|
#define ADM1026_DEVICE 0x2c /* 0x2e or 0x2d */
|
||||||
|
#define ADM1026_REG_CONFIG1 0x00
|
||||||
|
#define CFG1_MONITOR 0x01
|
||||||
|
#define CFG1_INT_ENABLE 0x02
|
||||||
|
#define CFG1_INT_CLEAR 0x04
|
||||||
|
#define CFG1_AIN8_9 0x08
|
||||||
|
#define CFG1_THERM_HOT 0x10
|
||||||
|
#define CFT1_DAC_AFC 0x20
|
||||||
|
#define CFG1_PWM_AFC 0x40
|
||||||
|
#define CFG1_RESET 0x80
|
||||||
|
#define ADM1026_REG_CONFIG2 0x01
|
||||||
|
#define ADM1026_REG_CONFIG3 0x07
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define BILLION 1000000000UL
|
||||||
|
|
||||||
|
static void verify_cpu_voltage(const char *name,
|
||||||
|
device_t dev, unsigned int reg,
|
||||||
|
unsigned factor, unsigned cpu_volts, unsigned delta)
|
||||||
{
|
{
|
||||||
unsigned long loops;
|
unsigned nvolts_lo, nvolts_hi;
|
||||||
loops = SMBUS_TIMEOUT;
|
unsigned cpuvolts_hi, cpuvolts_lo;
|
||||||
|
int value;
|
||||||
|
int loops;
|
||||||
|
|
||||||
|
loops = 1000;
|
||||||
do {
|
do {
|
||||||
unsigned short val;
|
value = smbus_read_byte(dev, reg);
|
||||||
smbus_delay();
|
handle_smbus_error(value, "SMBUS read byte failed");
|
||||||
val = inw(smbus_io_base + SMBGSTATUS);
|
} while ((--loops > 0) && value == 0);
|
||||||
if ((val & 0x800) == 0) {
|
/* Convert the byte value to nanoVolts.
|
||||||
break;
|
* My accuracy is nowhere near that good but I don't
|
||||||
}
|
* have to round so the math is simple.
|
||||||
if(loops == (SMBUS_TIMEOUT / 2)) {
|
* I can only go up to about 4.2 Volts this way so my range is
|
||||||
outw(inw(smbus_io_base + SMBGSTATUS),
|
* limited.
|
||||||
smbus_io_base + SMBGSTATUS);
|
*/
|
||||||
}
|
nvolts_lo = ((unsigned)value * factor);
|
||||||
} while(--loops);
|
nvolts_hi = nvolts_lo + factor - 1;
|
||||||
return loops?0:-2;
|
/* Get the range of acceptable cpu voltage values */
|
||||||
|
cpuvolts_lo = cpu_volts - delta;
|
||||||
|
cpuvolts_hi = cpu_volts + delta;
|
||||||
|
if ((nvolts_lo < cpuvolts_lo) || (nvolts_hi > cpuvolts_hi)) {
|
||||||
|
printk_emerg("%s at (%u.%09u-%u.%09u)Volts expected %u.%09u+/-%u.%09uVolts\n",
|
||||||
|
name,
|
||||||
|
nvolts_lo/BILLION, nvolts_lo%BILLION,
|
||||||
|
nvolts_hi/BILLION, nvolts_hi%BILLION,
|
||||||
|
cpu_volts/BILLION, cpu_volts%BILLION,
|
||||||
|
delta/BILLION, delta%BILLION);
|
||||||
|
die("");
|
||||||
|
}
|
||||||
|
printk_info("%s at (%u.%09u-%u.%09u)Volts\n",
|
||||||
|
name,
|
||||||
|
nvolts_lo/BILLION, nvolts_lo%BILLION,
|
||||||
|
nvolts_hi/BILLION, nvolts_hi%BILLION);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int smbus_wait_until_done(unsigned smbus_io_base)
|
static void adm1026_enable_monitoring(device_t dev)
|
||||||
{
|
{
|
||||||
unsigned long loops;
|
int result;
|
||||||
loops = SMBUS_TIMEOUT;
|
result = smbus_read_byte(dev, ADM1026_REG_CONFIG1);
|
||||||
do {
|
handle_smbus_error(result, "ADM1026: cannot read config1");
|
||||||
unsigned short val;
|
|
||||||
smbus_delay();
|
|
||||||
|
|
||||||
val = inw(smbus_io_base + SMBGSTATUS);
|
result = (result | CFG1_MONITOR) & ~(CFG1_INT_CLEAR | CFG1_RESET);
|
||||||
if (((val & 0x8) == 0) | ((val & 0x437) != 0)) {
|
result = smbus_write_byte(dev, ADM1026_REG_CONFIG1, result);
|
||||||
break;
|
handle_smbus_error(result, "ADM1026: cannot write to config1");
|
||||||
}
|
|
||||||
} while(--loops);
|
result = smbus_read_byte(dev, ADM1026_REG_CONFIG1);
|
||||||
return loops?0:-3;
|
handle_smbus_error(result, "ADM1026: cannot reread config1");
|
||||||
|
if (!(result & CFG1_MONITOR)) {
|
||||||
|
die("ADM1026: monitoring would not enable");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int smbus_send_byte(unsigned smbus_io_base, unsigned device, unsigned value)
|
|
||||||
|
static unsigned k8_cpu_volts(void)
|
||||||
{
|
{
|
||||||
unsigned char global_status_register;
|
unsigned volts = ~0;
|
||||||
|
if (is_cpu_c0()) {
|
||||||
|
volts = 1500000000;
|
||||||
|
}
|
||||||
|
if (is_cpu_b3()) {
|
||||||
|
volts = 1550000000;
|
||||||
|
}
|
||||||
|
return volts;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void verify_cpu_voltages(device_t dev)
|
||||||
|
{
|
||||||
|
unsigned cpu_volts;
|
||||||
|
unsigned delta;
|
||||||
|
#if 0
|
||||||
|
delta = 50000000;
|
||||||
|
#else
|
||||||
|
delta = 75000000;
|
||||||
|
#endif
|
||||||
|
cpu_volts = k8_cpu_volts();
|
||||||
|
if (cpu_volts == ~0) {
|
||||||
|
printk_info("Required cpu voltage unknwon not checking\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
/* I need to read registers 0x37 == Ain7CPU1 core 0x2d == VcppCPU0 core */
|
||||||
|
/* CPU1 core
|
||||||
|
* The sensor has a range of 0-2.5V and reports in
|
||||||
|
* 256 distinct steps.
|
||||||
|
*/
|
||||||
|
verify_cpu_voltage("CPU1 Vcore", dev, 0x37, 9765625,
|
||||||
|
cpu_volts, delta);
|
||||||
|
/* CPU0 core
|
||||||
|
* The sensor has range of 0-3.0V and reports in
|
||||||
|
* 256 distinct steps.
|
||||||
|
*/
|
||||||
|
verify_cpu_voltage("CPU0 Vcore", dev, 0x2d, 11718750,
|
||||||
|
cpu_volts, delta);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define SMBUS_MUX 0x70
|
||||||
|
|
||||||
if (smbus_wait_until_ready(smbus_io_base) < 0) {
|
if (smbus_wait_until_ready(smbus_io_base) < 0) {
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* setup transaction */
|
/* Find the smbus mux */
|
||||||
/* disable interrupts */
|
mux_path.type = DEVICE_PATH_I2C;
|
||||||
outw(inw(smbus_io_base + SMBGCTL) & ~((1<<10)|(1<<9)|(1<<8)|(1<<4)), smbus_io_base + SMBGCTL);
|
mux_path.u.i2c.device = SMBUS_MUX;
|
||||||
/* set the device I'm talking too */
|
mux = find_dev_path(smbus_dev, &mux_path);
|
||||||
outw(((device & 0x7f) << 1) | 0, smbus_io_base + SMBHSTADDR);
|
if (!mux) {
|
||||||
/* set the command/address... */
|
die("SMBUS mux not found\n");
|
||||||
outb(0, smbus_io_base + SMBHSTCMD);
|
|
||||||
/* set up for a send byte */
|
|
||||||
outw((inw(smbus_io_base + SMBGCTL) & ~7) | (0x1), smbus_io_base + SMBGCTL);
|
|
||||||
|
|
||||||
/* clear any lingering errors, so the transaction will run */
|
|
||||||
/* Do I need to write the bits to a 1 to clear an error? */
|
|
||||||
outw(inw(smbus_io_base + SMBGSTATUS), smbus_io_base + SMBGSTATUS);
|
|
||||||
|
|
||||||
/* set the data word...*/
|
|
||||||
outw(value, smbus_io_base + SMBHSTDAT);
|
|
||||||
|
|
||||||
/* start the command */
|
|
||||||
outw((inw(smbus_io_base + SMBGCTL) | (1 << 3)), smbus_io_base + SMBGCTL);
|
|
||||||
|
|
||||||
|
|
||||||
/* poll for transaction completion */
|
|
||||||
if (smbus_wait_until_done(smbus_io_base) < 0) {
|
|
||||||
return -3;
|
|
||||||
}
|
|
||||||
global_status_register = inw(smbus_io_base + SMBGSTATUS);
|
|
||||||
|
|
||||||
if (global_status_register != (1 << 4)) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int smbus_recv_byte(unsigned smbus_io_base, unsigned device)
|
|
||||||
{
|
|
||||||
unsigned char global_status_register;
|
|
||||||
unsigned char byte;
|
|
||||||
|
|
||||||
if (smbus_wait_until_ready(smbus_io_base) < 0) {
|
|
||||||
return -2;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* setup transaction */
|
|
||||||
/* disable interrupts */
|
|
||||||
outw(inw(smbus_io_base + SMBGCTL) & ~((1<<10)|(1<<9)|(1<<8)|(1<<4)), smbus_io_base + SMBGCTL);
|
|
||||||
/* set the device I'm talking too */
|
|
||||||
outw(((device & 0x7f) << 1) | 1, smbus_io_base + SMBHSTADDR);
|
|
||||||
/* set the command/address... */
|
|
||||||
outb(0, smbus_io_base + SMBHSTCMD);
|
|
||||||
/* set up for a send byte */
|
|
||||||
outw((inw(smbus_io_base + SMBGCTL) & ~7) | (0x1), smbus_io_base + SMBGCTL);
|
|
||||||
|
|
||||||
/* clear any lingering errors, so the transaction will run */
|
|
||||||
/* Do I need to write the bits to a 1 to clear an error? */
|
|
||||||
outw(inw(smbus_io_base + SMBGSTATUS), smbus_io_base + SMBGSTATUS);
|
|
||||||
|
|
||||||
/* set the data word...*/
|
|
||||||
outw(0, smbus_io_base + SMBHSTDAT);
|
|
||||||
|
|
||||||
/* start the command */
|
|
||||||
outw((inw(smbus_io_base + SMBGCTL) | (1 << 3)), smbus_io_base + SMBGCTL);
|
|
||||||
|
|
||||||
|
|
||||||
/* poll for transaction completion */
|
|
||||||
if (smbus_wait_until_done(smbus_io_base) < 0) {
|
|
||||||
return -3;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
global_status_register = inw(smbus_io_base + SMBGSTATUS);
|
global_status_register = inw(smbus_io_base + SMBGSTATUS);
|
||||||
@ -165,119 +271,54 @@ static int smbus_read_byte(unsigned smbus_io_base, unsigned device, unsigned add
|
|||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* setup transaction */
|
/* Set the mux to see the temperature sensors */
|
||||||
/* disable interrupts */
|
mux_setting = 1;
|
||||||
outw(inw(smbus_io_base + SMBGCTL) & ~((1<<10)|(1<<9)|(1<<8)|(1<<4)), smbus_io_base + SMBGCTL);
|
result = smbus_send_byte(mux, mux_setting);
|
||||||
/* set the device I'm talking too */
|
handle_smbus_error(result, "SMBUS send byte failed\n");
|
||||||
outw(((device & 0x7f) << 1) | 1, smbus_io_base + SMBHSTADDR);
|
|
||||||
/* set the command/address... */
|
|
||||||
outb(address & 0xFF, smbus_io_base + SMBHSTCMD);
|
|
||||||
/* set up for a byte data read */
|
|
||||||
outw((inw(smbus_io_base + SMBGCTL) & ~7) | (0x2), smbus_io_base + SMBGCTL);
|
|
||||||
|
|
||||||
/* clear any lingering errors, so the transaction will run */
|
result = smbus_recv_byte(mux);
|
||||||
/* Do I need to write the bits to a 1 to clear an error? */
|
handle_smbus_error(result, "SMBUS recv byte failed\n");
|
||||||
outw(inw(smbus_io_base + SMBGSTATUS), smbus_io_base + SMBGSTATUS);
|
if (result != mux_setting) {
|
||||||
|
printk_emerg("SMBUS mux would not set to %d\n", mux_setting);
|
||||||
/* clear the data word...*/
|
die("");
|
||||||
outw(0, smbus_io_base + SMBHSTDAT);
|
|
||||||
|
|
||||||
/* start the command */
|
|
||||||
outw((inw(smbus_io_base + SMBGCTL) | (1 << 3)), smbus_io_base + SMBGCTL);
|
|
||||||
|
|
||||||
|
|
||||||
/* poll for transaction completion */
|
|
||||||
if (smbus_wait_until_done(smbus_io_base) < 0) {
|
|
||||||
return -3;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
global_status_register = inw(smbus_io_base + SMBGSTATUS);
|
adm1026_enable_monitoring(sensor);
|
||||||
|
|
||||||
/* read results of transaction */
|
/* It takes 11.38ms to read a new voltage sensor value */
|
||||||
byte = inw(smbus_io_base + SMBHSTDAT) & 0xff;
|
mdelay(12);
|
||||||
|
|
||||||
if (global_status_register != (1 << 4)) {
|
/* Read the cpu voltages and make certain everything looks sane */
|
||||||
return -1;
|
verify_cpu_voltages(sensor);
|
||||||
}
|
|
||||||
return byte;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int smbus_write_byte(unsigned smbus_io_base, unsigned device, unsigned address, unsigned char val)
|
|
||||||
{
|
|
||||||
if (smbus_wait_until_ready(smbus_io_base) < 0) {
|
|
||||||
return -2;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* setup transaction */
|
|
||||||
/* disable interrupts */
|
|
||||||
outw(inw(smbus_io_base + SMBGCTL) & ~((1<<10)|(1<<9)|(1<<8)|(1<<4)),
|
|
||||||
smbus_io_base + SMBGCTL);
|
|
||||||
/* set the device I'm talking too */
|
|
||||||
outw(((device & 0x7f) << 1) | 0, smbus_io_base + SMBHSTADDR);
|
|
||||||
outb(address & 0xFF, smbus_io_base + SMBHSTCMD);
|
|
||||||
/* set up for a byte data write */ /* FIXME */
|
|
||||||
outw((inw(smbus_io_base + SMBGCTL) & ~7) | (0x1), smbus_io_base + SMBGCTL);
|
|
||||||
/* clear any lingering errors, so the transaction will run */
|
|
||||||
/* Do I need to write the bits to a 1 to clear an error? */
|
|
||||||
outw(inw(smbus_io_base + SMBGSTATUS), smbus_io_base + SMBGSTATUS);
|
|
||||||
|
|
||||||
/* clear the data word...*/
|
|
||||||
outw(val, smbus_io_base + SMBHSTDAT);
|
|
||||||
|
|
||||||
/* start the command */
|
|
||||||
outw((inw(smbus_io_base + SMBGCTL) | (1 << 3)), smbus_io_base + SMBGCTL);
|
|
||||||
|
|
||||||
/* poll for transaction completion */
|
|
||||||
if (smbus_wait_until_done(smbus_io_base) < 0) {
|
|
||||||
return -3;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
#define do_verify_cpu_voltages() do {} while(0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define SMBUS_MUX 0x70
|
|
||||||
static void mainboard_init(device_t dev)
|
static void mainboard_init(device_t dev)
|
||||||
{
|
{
|
||||||
/* Set the mux to see the temperature sensors */
|
root_dev_init(dev);
|
||||||
dev = dev_find_device(0x1022, 0x746b, 0);
|
|
||||||
if (dev) {
|
|
||||||
unsigned smbus_io_base;
|
|
||||||
unsigned device;
|
|
||||||
int result;
|
|
||||||
int mux_setting;
|
|
||||||
device = SMBUS_MUX;
|
|
||||||
mux_setting = 1;
|
|
||||||
smbus_io_base = pci_read_config32(dev, 0x58) & ~1;;
|
|
||||||
result = smbus_send_byte(smbus_io_base, device, mux_setting);
|
|
||||||
if ((result < 0) ||
|
|
||||||
(smbus_recv_byte(smbus_io_base, device) != mux_setting)) {
|
|
||||||
printk_err("SMBUS mux would not set to %d\n", mux_setting);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
do_verify_cpu_voltages();
|
||||||
else {
|
|
||||||
printk_err("SMBUS_controller not found\n");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct device_operations mainboard_operations = {
|
static struct device_operations mainboard_operations = {
|
||||||
.read_resources = root_dev_read_resources,
|
.read_resources = root_dev_read_resources,
|
||||||
.set_resources = root_dev_set_resources,
|
.set_resources = root_dev_set_resources,
|
||||||
.enable_resources = enable_childrens_resources,
|
.enable_resources = root_dev_enable_resources,
|
||||||
.init = mainboard_init,
|
.init = mainboard_init,
|
||||||
.scan_bus = amdk8_scan_root_bus,
|
#if !DEBUG
|
||||||
|
.scan_bus = root_dev_scan_bus,
|
||||||
|
#else
|
||||||
|
.scan_bus = scan_root_bus,
|
||||||
|
#endif
|
||||||
.enable = 0,
|
.enable = 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void enumerate(struct chip *chip)
|
static void enumerate(struct chip *chip)
|
||||||
{
|
{
|
||||||
struct chip *child;
|
|
||||||
dev_root.ops = &mainboard_operations;
|
dev_root.ops = &mainboard_operations;
|
||||||
chip->dev = &dev_root;
|
chip_enumerate(chip);
|
||||||
chip->bus = 0;
|
|
||||||
for(child = chip->children; child; child = child->next) {
|
|
||||||
child->bus = &dev_root.link[0];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
struct chip_control mainboard_arima_hdama_control = {
|
struct chip_control mainboard_arima_hdama_control = {
|
||||||
.enumerate = enumerate,
|
.enumerate = enumerate,
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
void *smp_write_config_table(void *v, unsigned long * processor_map)
|
void *smp_write_config_table(void *v)
|
||||||
{
|
{
|
||||||
static const char sig[4] = "PCMP";
|
static const char sig[4] = "PCMP";
|
||||||
static const char oem[8] = "LNXI ";
|
static const char oem[8] = "LNXI ";
|
||||||
@ -33,7 +33,7 @@ void *smp_write_config_table(void *v, unsigned long * processor_map)
|
|||||||
mc->mpe_checksum = 0;
|
mc->mpe_checksum = 0;
|
||||||
mc->reserved = 0;
|
mc->reserved = 0;
|
||||||
|
|
||||||
smp_write_processors(mc, processor_map);
|
smp_write_processors(mc);
|
||||||
|
|
||||||
{
|
{
|
||||||
device_t dev;
|
device_t dev;
|
||||||
@ -44,7 +44,8 @@ void *smp_write_config_table(void *v, unsigned long * processor_map)
|
|||||||
bus_8111_1 = pci_read_config8(dev, PCI_SECONDARY_BUS);
|
bus_8111_1 = pci_read_config8(dev, PCI_SECONDARY_BUS);
|
||||||
bus_isa = pci_read_config8(dev, PCI_SUBORDINATE_BUS);
|
bus_isa = pci_read_config8(dev, PCI_SUBORDINATE_BUS);
|
||||||
bus_isa++;
|
bus_isa++;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
printk_debug("ERROR - could not find PCI 1:03.0, using defaults\n");
|
printk_debug("ERROR - could not find PCI 1:03.0, using defaults\n");
|
||||||
|
|
||||||
bus_8111_1 = 4;
|
bus_8111_1 = 4;
|
||||||
@ -54,15 +55,20 @@ void *smp_write_config_table(void *v, unsigned long * processor_map)
|
|||||||
dev = dev_find_slot(1, PCI_DEVFN(0x01,0));
|
dev = dev_find_slot(1, PCI_DEVFN(0x01,0));
|
||||||
if (dev) {
|
if (dev) {
|
||||||
bus_8131_1 = pci_read_config8(dev, PCI_SECONDARY_BUS);
|
bus_8131_1 = pci_read_config8(dev, PCI_SECONDARY_BUS);
|
||||||
} else {
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
printk_debug("ERROR - could not find PCI 1:01.0, using defaults\n");
|
printk_debug("ERROR - could not find PCI 1:01.0, using defaults\n");
|
||||||
|
|
||||||
bus_8131_1 = 2;
|
bus_8131_1 = 2;
|
||||||
}
|
}
|
||||||
/* 8131-2 */
|
/* 8131-2 */
|
||||||
dev = dev_find_slot(1, PCI_DEVFN(0x02,0));
|
dev = dev_find_slot(1, PCI_DEVFN(0x02,0));
|
||||||
if (dev) {
|
if (dev) {
|
||||||
bus_8131_2 = pci_read_config8(dev, PCI_SECONDARY_BUS);
|
bus_8131_2 = pci_read_config8(dev, PCI_SECONDARY_BUS);
|
||||||
} else {
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
printk_debug("ERROR - could not find PCI 1:02.0, using defaults\n");
|
printk_debug("ERROR - could not find PCI 1:02.0, using defaults\n");
|
||||||
|
|
||||||
bus_8131_2 = 3;
|
bus_8131_2 = 3;
|
||||||
@ -79,20 +85,22 @@ void *smp_write_config_table(void *v, unsigned long * processor_map)
|
|||||||
smp_write_ioapic(mc, 2, 0x11, 0xfec00000);
|
smp_write_ioapic(mc, 2, 0x11, 0xfec00000);
|
||||||
{
|
{
|
||||||
device_t dev;
|
device_t dev;
|
||||||
uint32_t base;
|
struct resource *res;
|
||||||
/* 8131-1 apic #3 */
|
/* 8131 apic 3 */
|
||||||
dev = dev_find_slot(1, PCI_DEVFN(0x01,1));
|
dev = dev_find_slot(1, PCI_DEVFN(0x01,1));
|
||||||
if (dev) {
|
if (dev) {
|
||||||
base = pci_read_config32(dev, PCI_BASE_ADDRESS_0);
|
res = find_resource(dev, PCI_BASE_ADDRESS_0);
|
||||||
base &= PCI_BASE_ADDRESS_MEM_MASK;
|
if (res) {
|
||||||
smp_write_ioapic(mc, 0x03, 0x11, base);
|
smp_write_ioapic(mc, 0x03, 0x11, res->base);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* 8131-2 apic #4 */
|
/* 8131 apic 4 */
|
||||||
dev = dev_find_slot(1, PCI_DEVFN(0x02,1));
|
dev = dev_find_slot(1, PCI_DEVFN(0x02,1));
|
||||||
if (dev) {
|
if (dev) {
|
||||||
base = pci_read_config32(dev, PCI_BASE_ADDRESS_0);
|
res = find_resource(dev, PCI_BASE_ADDRESS_0);
|
||||||
base &= PCI_BASE_ADDRESS_MEM_MASK;
|
if (res) {
|
||||||
smp_write_ioapic(mc, 0x04, 0x11, base);
|
smp_write_ioapic(mc, 0x04, 0x11, res->base);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,14 +201,14 @@ void *smp_write_config_table(void *v, unsigned long * processor_map)
|
|||||||
mc->mpe_checksum = smp_compute_checksum(smp_next_mpc_entry(mc), mc->mpe_length);
|
mc->mpe_checksum = smp_compute_checksum(smp_next_mpc_entry(mc), mc->mpe_length);
|
||||||
mc->mpc_checksum = smp_compute_checksum(mc, mc->mpc_length);
|
mc->mpc_checksum = smp_compute_checksum(mc, mc->mpc_length);
|
||||||
printk_debug("Wrote the mp table end at: %p - %p\n",
|
printk_debug("Wrote the mp table end at: %p - %p\n",
|
||||||
mc, smp_next_mpe_entry(mc));
|
mc, smp_next_mpe_entry(mc));
|
||||||
return smp_next_mpe_entry(mc);
|
return smp_next_mpe_entry(mc);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long write_smp_table(unsigned long addr, unsigned long *processor_map)
|
unsigned long write_smp_table(unsigned long addr)
|
||||||
{
|
{
|
||||||
void *v;
|
void *v;
|
||||||
v = smp_write_floating_table(addr);
|
v = smp_write_floating_table(addr);
|
||||||
return (unsigned long)smp_write_config_table(v, processor_map);
|
return (unsigned long)smp_write_config_table(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,30 +1,25 @@
|
|||||||
/* this is a shrunken cpuid. */
|
#include <arch/cpu.h>
|
||||||
|
|
||||||
static unsigned int cpuid(unsigned int op)
|
|
||||||
{
|
|
||||||
unsigned int ret;
|
|
||||||
unsigned dummy2,dummy3,dummy4;
|
|
||||||
|
|
||||||
asm volatile (
|
|
||||||
"cpuid"
|
|
||||||
: "=a" (ret), "=b" (dummy2), "=c" (dummy3), "=d" (dummy4)
|
|
||||||
: "a" (op)
|
|
||||||
);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int is_cpu_rev_a0(void)
|
static int is_cpu_rev_a0(void)
|
||||||
{
|
{
|
||||||
return (cpuid(1) & 0xffef) == 0x0f00;
|
return (cpuid_eax(1) & 0xffef) == 0x0f00;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int is_cpu_pre_c0(void)
|
static int is_cpu_pre_c0(void)
|
||||||
{
|
{
|
||||||
return (cpuid(1) & 0xffef) < 0x0f48;
|
return (cpuid_eax(1) & 0xffef) < 0x0f48;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int is_cpu_c0(void)
|
||||||
|
{
|
||||||
|
return (cpuid_eax(1) & 0xffef) == 0x0f48;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int is_cpu_pre_b3(void)
|
static int is_cpu_pre_b3(void)
|
||||||
{
|
{
|
||||||
return (cpuid(1) & 0xffef) < 0x0f41;
|
return (cpuid_eax(1) & 0xffef) < 0x0f41;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int is_cpu_b3(void)
|
||||||
|
{
|
||||||
|
return (cpuid_eax(1) & 0xffef) == 0x0f41;
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
#include <device/pci_ids.h>
|
#include <device/pci_ids.h>
|
||||||
#include <device/pci_ops.h>
|
#include <device/pci_ops.h>
|
||||||
#include <part/hard_reset.h>
|
#include <part/hard_reset.h>
|
||||||
|
#include <pc80/mc146818rtc.h>
|
||||||
|
#include <bitops.h>
|
||||||
#include "./cpu_rev.c"
|
#include "./cpu_rev.c"
|
||||||
#include "amdk8.h"
|
#include "amdk8.h"
|
||||||
|
|
||||||
@ -35,7 +37,7 @@
|
|||||||
static void mcf3_read_resources(device_t dev)
|
static void mcf3_read_resources(device_t dev)
|
||||||
{
|
{
|
||||||
struct resource *resource;
|
struct resource *resource;
|
||||||
|
unsigned char iommu;
|
||||||
/* Read the generic PCI resources */
|
/* Read the generic PCI resources */
|
||||||
pci_dev_read_resources(dev);
|
pci_dev_read_resources(dev);
|
||||||
|
|
||||||
@ -44,57 +46,59 @@ static void mcf3_read_resources(device_t dev)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add a Gart apeture resource */
|
iommu = 1;
|
||||||
if (dev->resources < MAX_RESOURCES) {
|
get_option(&iommu, "iommu");
|
||||||
resource = &dev->resource[dev->resources];
|
|
||||||
dev->resources++;
|
if (iommu) {
|
||||||
resource->base = 0;
|
/* Add a Gart apeture resource */
|
||||||
resource->size = AGP_APERTURE_SIZE;
|
resource = new_resource(dev, 0x94);
|
||||||
|
resource->size = iommu?AGP_APERTURE_SIZE:1;
|
||||||
resource->align = log2(resource->size);
|
resource->align = log2(resource->size);
|
||||||
resource->gran = log2(resource->size);
|
resource->gran = log2(resource->size);
|
||||||
resource->limit = 0xffffffff; /* 4G */
|
resource->limit = 0xffffffff; /* 4G */
|
||||||
resource->flags = IORESOURCE_MEM;
|
resource->flags = IORESOURCE_MEM;
|
||||||
resource->index = 0x94;
|
|
||||||
} else {
|
|
||||||
printk_err("%s Unexpeted resource shortage\n", dev_path(dev));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void set_agp_aperture(device_t dev, struct resource *resource)
|
static void set_agp_aperture(device_t dev)
|
||||||
{
|
{
|
||||||
device_t pdev;
|
struct resource *resource;
|
||||||
uint32_t base;
|
|
||||||
uint32_t size;
|
|
||||||
|
|
||||||
size = (0<<6)|(0<<5)|(0<<4)| ((log2(resource->size) - 25) << 1)|(0<<0);
|
resource = probe_resource(dev, 0x94);
|
||||||
base = ((resource->base) >> 25) & 0x00007fff;
|
if (resource) {
|
||||||
pdev = 0;
|
device_t pdev;
|
||||||
|
uint32_t gart_base, gart_acr;
|
||||||
|
/* Remember this resource has been stored */
|
||||||
|
resource->flags |= IORESOURCE_STORED;
|
||||||
|
|
||||||
/* A search for MISC Control device is neceressary */
|
/*Find the size of the GART aperture */
|
||||||
while (pdev = dev_find_device(PCI_VENDOR_ID_AMD, 0x1103, pdev)) {
|
gart_acr = (0<<6)|(0<<5)|(0<<4)| ((log2(resource->size) - 25) << 1)|(0<<0);
|
||||||
pci_write_config32(pdev, 0x90, size);
|
|
||||||
pci_write_config32(pdev, 0x94, base);
|
|
||||||
/* Don't set the GART Table base address */
|
|
||||||
pci_write_config32(pdev, 0x98, 0);
|
|
||||||
|
|
||||||
printk_debug("%s %02x <- [0x%08lx - 0x%08lx] mem <gart>\n",
|
/* Get the base address */
|
||||||
dev_path(pdev), resource->index, resource->base,
|
gart_base = ((resource->base) >> 25) & 0x00007fff;
|
||||||
resource->base + resource->size - 1);
|
|
||||||
|
/* Update the other northbriges */
|
||||||
|
pdev = 0;
|
||||||
|
while (pdev = dev_find_device(PCI_VENDOR_ID_AMD, 0x1103, pdev)) {
|
||||||
|
/* Store GART size but don't enable it */
|
||||||
|
pci_write_config32(pdev, 0x90, gart_acr);
|
||||||
|
|
||||||
|
/* Store the GART base address */
|
||||||
|
pci_write_config32(pdev, 0x94, gart_base);
|
||||||
|
|
||||||
|
/* Don't set the GART Table base address */
|
||||||
|
pci_write_config32(pdev, 0x98, 0);
|
||||||
|
|
||||||
|
/* Report the resource has been stored... */
|
||||||
|
report_resource_stored(pdev, resource, " <gart>");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* Remember this resource has been stored */
|
|
||||||
resource->flags |= IORESOURCE_STORED;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mcf3_set_resources(device_t dev)
|
static void mcf3_set_resources(device_t dev)
|
||||||
{
|
{
|
||||||
struct resource *resource, *last;
|
/* Set the gart apeture */
|
||||||
|
set_agp_aperture(dev);
|
||||||
last = &dev->resource[dev->resources];
|
|
||||||
for (resource = &dev->resource[0]; resource < last; resource++) {
|
|
||||||
if (resource->index == 0x94) {
|
|
||||||
set_agp_aperture(dev, resource);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set the generic PCI resources */
|
/* Set the generic PCI resources */
|
||||||
pci_dev_set_resources(dev);
|
pci_dev_set_resources(dev);
|
||||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user