Files
xen/tools/firmware/hvmloader/smp.c
T
Ian Campbell 443701ef0c Replace FSF street address with canonical URL
As recommended in http://www.gnu.org/licenses/gpl-howto.en.html.

This is the result of:
$ git grep -El Mass\|Temple\|Franklin | xargs ./fsf.pl

Where fsf.pl is:
    #!/usr/bin/perl -w -pi.bak -0777
    my $repl = 'If not, see <http://www.gnu.org/licenses/>.';
    my $br = qr/(?:\s*\n\s*(?:[\*\#]|\/\/|\.\\" )?\s*|\s+)/;

    my $inwt = qr/[Ii]f${br}not,${br}write${br}(?:to${br})?the${br}Free${br}Software${br}Foundation,(?:${br}Inc\.,)?/;

    my $mass = qr/675${br}Mass${br}Ave,?${br}Cambridge,?${br}MA${br}02139,?${br}USA,?\.?/;
    my $franklin = qr/51${br}Franklin${br}St(?:reet)?(?:,${br}| - )Fifth${br}Floor,?${br}Boston,?${br}MA,?${br}02110-1301,?${br}USA,?\.?/;
    my $temple = qr/59${br}Temple${br}Place(?:,${br}| - )Suite${br}330,?${br}Boston,?${br}MA,?${br}021110?-1307,?${br}USA,?\.?/;

    s|$inwt$br$mass|$repl|m;
    s|$inwt$br$franklin|$repl|m;
    s|$inwt$br$temple|$repl|m;

The only remaining mentions of these addresses are in COPYING files which I
haven't touched.

Some of the changed files are imports from elsewhere, however
filtering them out is tricky, I think it is tolerable to have these
files be modified here and then perhaps reverted on the next sync,
since it's only 1-2 lines and obvious what is going on.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
2015-07-29 11:14:07 +01:00

142 lines
4.1 KiB
C

/*
* smp.c: Secondary processor bringup and initialisation.
*
* Copyright (c) 2008, Citrix Systems, Inc.
*
* Authors:
* Keir Fraser <keir@xen.org>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; If not, see <http://www.gnu.org/licenses/>.
*/
#include "util.h"
#include "config.h"
#include "apic_regs.h"
#define AP_BOOT_EIP 0x1000
extern char ap_boot_start[], ap_boot_end[];
static int ap_callin, ap_cpuid;
asm (
" .text \n"
" .code16 \n"
"ap_boot_start: .code16 \n"
" mov %cs,%ax \n"
" mov %ax,%ds \n"
" lgdt gdt_desr-ap_boot_start\n"
" xor %ax, %ax \n"
" inc %ax \n"
" lmsw %ax \n"
" ljmpl $0x08,$1f \n"
"gdt_desr: \n"
" .word gdt_end - gdt - 1 \n"
" .long gdt \n"
"ap_boot_end: .code32 \n"
"1: mov $0x10,%eax \n"
" mov %eax,%ds \n"
" mov %eax,%es \n"
" mov %eax,%ss \n"
" movl $stack_top,%esp \n"
" movl %esp,%ebp \n"
" call ap_start \n"
"1: hlt \n"
" jmp 1b \n"
" \n"
" .align 8 \n"
"gdt: \n"
" .quad 0x0000000000000000 \n"
" .quad 0x00cf9a000000ffff \n" /* 0x08: Flat code segment */
" .quad 0x00cf92000000ffff \n" /* 0x10: Flat data segment */
"gdt_end: \n"
" \n"
" .bss \n"
" .align 8 \n"
"stack: \n"
" .skip 0x4000 \n"
"stack_top: \n"
" .text \n"
);
void ap_start(void); /* non-static avoids unused-function compiler warning */
/*static*/ void ap_start(void)
{
printf(" - CPU%d ... ", ap_cpuid);
cacheattr_init();
printf("done.\n");
wmb();
ap_callin = 1;
}
static void lapic_wait_ready(void)
{
while ( lapic_read(APIC_ICR) & APIC_ICR_BUSY )
cpu_relax();
}
static void boot_cpu(unsigned int cpu)
{
unsigned int icr2 = SET_APIC_DEST_FIELD(LAPIC_ID(cpu));
/* Initialise shared variables. */
ap_cpuid = cpu;
ap_callin = 0;
wmb();
/* Wake up the secondary processor: INIT-SIPI-SIPI... */
lapic_wait_ready();
lapic_write(APIC_ICR2, icr2);
lapic_write(APIC_ICR, APIC_DM_INIT);
lapic_wait_ready();
lapic_write(APIC_ICR2, icr2);
lapic_write(APIC_ICR, APIC_DM_STARTUP | (AP_BOOT_EIP >> 12));
lapic_wait_ready();
lapic_write(APIC_ICR2, icr2);
lapic_write(APIC_ICR, APIC_DM_STARTUP | (AP_BOOT_EIP >> 12));
lapic_wait_ready();
/*
* Wait for the secondary processor to complete initialisation.
* Do not touch shared resources meanwhile.
*/
while ( !ap_callin )
cpu_relax();
/* Take the secondary processor offline. */
lapic_write(APIC_ICR2, icr2);
lapic_write(APIC_ICR, APIC_DM_INIT);
lapic_wait_ready();
}
void smp_initialise(void)
{
unsigned int i, nr_cpus = hvm_info->nr_vcpus;
memcpy((void *)AP_BOOT_EIP, ap_boot_start, ap_boot_end - ap_boot_start);
printf("Multiprocessor initialisation:\n");
ap_start();
for ( i = 1; i < nr_cpus; i++ )
boot_cpu(i);
}
/*
* Local variables:
* mode: C
* c-file-style: "BSD"
* c-basic-offset: 4
* tab-width: 4
* indent-tabs-mode: nil
* End:
*/