blob: 11ad8e4b87bb1f3d9b51bedcf4232fa0baf270d3 [file] [log] [blame]
This software and ancillary information (herein called SOFTWARE )
called LinuxBIOS is made available under the terms described
here. The SOFTWARE has been approved for release with associated
LA-CC Number 00-34 . Unless otherwise indicated, this SOFTWARE has
been authored by an employee or employees of the University of
California, operator of the Los Alamos National Laboratory under
Contract No. W-7405-ENG-36 with the U.S. Department of Energy. The
U.S. Government has rights to use, reproduce, and distribute this
SOFTWARE. The public may copy, distribute, prepare derivative works
and publicly display this SOFTWARE without charge, provided that this
Notice and any statement of authorship are reproduced on all copies.
Neither the Government nor the University makes any warranty, express
or implied, or assumes any liability or responsibility for the use of
this SOFTWARE. If SOFTWARE is modified to produce derivative works,
such modified SOFTWARE should be clearly marked, so as not to confuse
it with the version available from LANL.
/* Copyright 2000, Ron Minnich, Advanced Computing Lab, LANL
* C Bootstrap code for the LinuxBIOS
#include <console/console.h>
#include <cpu/cpu.h>
#include <mem.h>
#include <version.h>
#include <smp/start_stop.h>
#include <boot/tables.h>
#include <part/sizeram.h>
#include <device/device.h>
#include <device/pci.h>
#include <device/chip.h>
#include <delay.h>
#if 0
#include <part/mainboard.h>
#include <part/hard_reset.h>
#include <smp/atomic.h>
#include <boot/elf.h>
/* 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);
void secondary_cpu_init(void)
struct mem_range *mem;
unsigned long id;
int index;
printk_debug(__FUNCTION__ "\n");
mem = get_ramsize();
id = cpu_initialize(mem);
index = processor_index(id);
printk_debug(__FUNCTION__ " %d/%u\n", index, id);
processor_map[index] = CPU_ENABLED;
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;
#warning "FIXME do I need a mainboard_cpu_fixup function?"
printk_debug("All AP CPUs stopped\n");
#else /* CONIFG_SMP */
#define wait_for_other_cpus() do {} while(0)
#endif /* CONFIG_SMP */
void hardwaremain(int boot_complete)
/* Processor ID of the BOOT cpu (i.e. the one running this code) */
unsigned long boot_cpu;
int boot_index;
/* the order here is a bit tricky. We don't want to do much of
* anything that uses config registers until after PciAllocateResources
* since that function also figures out what kind of config strategy
* 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 mem_range *mem, *tmem;
struct lb_memory *lb_mem;
unsigned long totalmem;
/* displayinit MUST PRECEDE ALL PRINTK! */
printk_notice("LinuxBIOS-%s%s %s %s...\n",
linuxbios_version, linuxbios_extra_version, linuxbios_build,
/* If we have already booted attempt a hard reboot */
if (boot_complete) {
init_timer(); /* needs to be moved into static configuration */
/* pick how to scan the bus. This is first so we can get at memory size. */
printk_info("Finding PCI configuration type.\n");
#if 0
/* Now do the real bus.
* We round the total ram up a lot for thing like the SISFB, which
* shares high memory with the CPU.
mem = get_ramsize();
totalmem = 0;
for(tmem = mem; tmem->sizek; tmem++) {
totalmem += tmem->sizek;
printk_info("totalram: %ldM\n",
(totalmem + 512) >> 10); /* Round to the nearest meg */
/* Fully initialize the cpu before configuring the bus */
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;
/* Now start the other cpus initializing
* The sooner they start the sooner they stop.
/* make certain we are the only cpu running in linuxBIOS */
/* Now that we have collected all of our information
* write our configuration tables.
lb_mem = write_tables(mem, processor_map);