Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 4613 → Rev 4614

/branches/sparc/kernel/arch/sparc64/include/asm.h
309,7 → 309,7
{
uintptr_t unbiased_sp;
asm volatile ("add %%sp, %1, %0\n" : "=r" (unbiased_sp) : "i" (STACK_BIAS));
asm volatile ("add %%sp, %1, %0\n" : "=&r" (unbiased_sp) : "i" (STACK_BIAS));
return ALIGN_DOWN(unbiased_sp, STACK_SIZE);
}
373,7 → 373,7
{
uint64_t v;
asm volatile ("ldxa [%1] %2, %0\n" : "=r" (v) : "r" (va), "i" ((unsigned) asi));
asm volatile ("ldxa [%1] %2, %0\n" : "=&r" (v) : "r" (va), "i" ((unsigned) asi));
return v;
}
/branches/sparc/kernel/arch/sparc64/src/sun4v/start.S
29,6 → 29,7
 
#include <arch/arch.h>
#include <arch/stack.h>
#include <arch/context_offset.h>
#include <arch/sun4v/regdef.h>
#include <arch/sun4v/hypercall.h>
#include <arch/sun4v/arch.h>
142,6 → 143,15
sethi %hi(trap_table), %g1
wrpr %g1, %lo(trap_table), %tba
 
/* Explicitly switch to hypervisor API 1.1. */
mov 1, %o0
mov 1, %o1
mov 1, %o2
mov 0, %o3
mov 0, %o4
mov 0, %o5
ta 0xff
nop
 
/*
* Take over the MMU.
184,13 → 194,6
set 1, %o2 ! context
set MMU_FLAG_DTLB | MMU_FLAG_ITLB, %o3 ! MMU flags
__HYPERCALL_FAST(MMU_DEMAP_CTX)
/*
* Save physmem_base for use by the mm subsystem.
* %l6 contains starting physical address
*/
sethi %hi(physmem_base), %l4
stx %l6, [%l4 + %lo(physmem_base)]
 
/*
* Set CPUID.
209,8 → 212,20
mov SCRATCHPAD_MMU_FSA, %g1
stxa %o0, [%g1] ASI_SCRATCHPAD ! remember MMU fault status area to speed up miss handler
__HYPERCALL_FAST(MMU_FAULT_AREA_CONF)
 
! on APs skip executing the following code
cmp %l7, 0
be 1f
nop
 
/*
* Save physmem_base for use by the mm subsystem.
* %l6 contains starting physical address
*/
sethi %hi(physmem_base), %l4
stx %l6, [%l4 + %lo(physmem_base)]
 
/*
* Store a template of a TTE Data entry for kernel mappings.
* This template will be used from the kernel MMU miss handler.
*/
246,6 → 261,41
ba 0b
nop
 
1:
 
#ifdef CONFIG_SMP
 
/*
* Configure stack for the AP.
* The AP is expected to use the stack saved
* in the ctx global variable.
*/
 
mov 1, %o0 ! MMU enable flag
set mmu_enabled, %o1
mov MMU_ENABLE, %o5 ! MMU enable HV call
ta 0x80 ! call HV
 
mmu_enabled:
 
/*
* Configure stack for the AP.
* The AP is expected to use the stack saved
* in the ctx global variable.
*/
set ctx, %g1
add %g1, OFFSET_SP, %g1
ldx [%g1], %o6
 
call main_ap
nop
#endif
 
/* Not reached. */
0:
ba 0b
nop
 
.section K_DATA_START, "aw", @progbits
 
#define INITIAL_STACK_SIZE 1024
/branches/sparc/kernel/arch/sparc64/src/smp/sun4v/smp.c
37,6 → 37,7
#include <genarch/ofw/ofw_tree.h>
#include <cpu.h>
#include <arch/cpu.h>
#include <arch/boot/boot.h>
#include <arch.h>
#include <config.h>
#include <macros.h>
44,12 → 45,27
#include <synch/synch.h>
#include <synch/waitq.h>
#include <print.h>
#include <arch/sun4v/hypercall.h>
#include <arch/sun4v/md.h>
#include <time/delay.h>
 
#define CPU_STATE_RUNNING 2
 
extern void kernel_image_start(void);
extern void *trap_table;
 
/** Determine number of processors. */
void smp_init(void)
{
// TODO: replace with a real # of CPUs as soon as the MD walkthrough is implemented
config.cpu_count = 1;
md_node_t node = md_get_root();
count_t cpu_count = 0;
 
/* walk through MD, find the current CPU node & its clock-frequency */
while(md_next_node(&node, "cpu")) {
cpu_count++;
}
 
config.cpu_count = cpu_count;
}
 
 
56,7 → 72,46
/** Wake application processors up. */
void kmp(void *arg)
{
// TODO: implement as soon as the MD walkthrough is implemented
(void) arg;
 
uint64_t myid;
__hypercall_fast_ret1(0, 0, 0, 0, 0, CPU_MYID, &myid);
 
/* stop the CPUs before making them execute our code */
uint64_t i;
for (i = 0; i < config.cpu_count; i++) {
if (i == myid)
continue;
 
if (__hypercall_fast1(CPU_STOP, i) != 0)
continue;
 
uint64_t state;
__hypercall_fast_ret1(i, 0, 0, 0, 0, CPU_STATE, &state);
while (state == CPU_STATE_RUNNING) {
__hypercall_fast_ret1(i, 0, 0, 0, 0, CPU_STATE, &state);
}
}
 
/* wake the processors up, one by one */
uint64_t state;
for (i = 1; i < config.cpu_count; i++) {
__hypercall_fast_ret1(i, 0, 0, 0, 0, CPU_STATE, &state);
printf("Starting CPU %d, error code = %d.\n", i, __hypercall_fast4(
CPU_START,
i,
(uint64_t) KA2PA(kernel_image_start),
KA2PA(trap_table),
bootinfo.physmem_start
));
 
if (waitq_sleep_timeout(&ap_completion_wq, 10000000, SYNCH_FLAGS_NONE) ==
ESYNCH_TIMEOUT)
printf("%s: waiting for processor (cpuid = %" PRIu32
") timed out\n", __func__, i);
}
 
}
 
/** @}