Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/xen/x86 KNF a little
details: https://anonhg.NetBSD.org/src/rev/d047e9a2087a
branches: trunk
changeset: 349140:d047e9a2087a
user: maxv <maxv%NetBSD.org@localhost>
date: Fri Nov 25 12:20:03 2016 +0000
description:
KNF a little
diffstat:
sys/arch/xen/x86/cpu.c | 177 ++++++++++++++++++++++--------------------------
1 files changed, 83 insertions(+), 94 deletions(-)
diffs (truncated from 443 to 300 lines):
diff -r be5d72ae4787 -r d047e9a2087a sys/arch/xen/x86/cpu.c
--- a/sys/arch/xen/x86/cpu.c Fri Nov 25 12:14:49 2016 +0000
+++ b/sys/arch/xen/x86/cpu.c Fri Nov 25 12:20:03 2016 +0000
@@ -1,5 +1,4 @@
-/* $NetBSD: cpu.c,v 1.104 2016/07/07 06:55:40 msaitoh Exp $ */
-/* NetBSD: cpu.c,v 1.18 2004/02/20 17:35:01 yamt Exp */
+/* $NetBSD: cpu.c,v 1.105 2016/11/25 12:20:03 maxv Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -66,7 +65,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.104 2016/07/07 06:55:40 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.105 2016/11/25 12:20:03 maxv Exp $");
#include "opt_ddb.h"
#include "opt_multiprocessor.h"
@@ -294,8 +293,7 @@
if (strcmp(vcaa->vcaa_name, match->cf_name) == 0) {
error = HYPERVISOR_vcpu_op(VCPUOP_get_runstate_info,
- vcaa->vcaa_caa.cpu_number,
- &vcr);
+ vcaa->vcaa_caa.cpu_number, &vcr);
switch (error) {
case 0:
return 1;
@@ -341,7 +339,7 @@
cai = &ci->ci_cinfo[i];
tcolors = atop(cai->cai_totalsize);
- switch(cai->cai_associativity) {
+ switch (cai->cai_associativity) {
case 0xff:
tcolors = 1; /* fully associative */
break;
@@ -465,14 +463,12 @@
atomic_or_32(&ci->ci_flags, CPUF_SP);
cpu_identify(ci);
x86_cpu_idle_init();
-
break;
case CPU_ROLE_BP:
atomic_or_32(&ci->ci_flags, CPUF_BSP);
cpu_identify(ci);
x86_cpu_idle_init();
-
break;
case CPU_ROLE_AP:
@@ -521,9 +517,9 @@
l,
#ifdef i386
(void *)pcb->pcb_esp
-#else /* i386 */
+#else
(void *)pcb->pcb_rsp
-#endif /* i386 */
+#endif
);
}
@@ -695,7 +691,7 @@
xen_ipi_init();
xen_initclocks();
-
+
#ifdef __x86_64__
fpuinit(ci);
#endif
@@ -764,10 +760,8 @@
{
int i;
for (i = 0; i < roundup(entries, PAGE_SIZE) >> PAGE_SHIFT; i++) {
-
- frames[i] = ((paddr_t) xpmap_ptetomach(
- (pt_entry_t *) (base + (i << PAGE_SHIFT))))
- >> PAGE_SHIFT;
+ frames[i] = ((paddr_t)xpmap_ptetomach(
+ (pt_entry_t *)(base + (i << PAGE_SHIFT)))) >> PAGE_SHIFT;
/* Mark Read-only */
pmap_pte_clearbits(kvtopte(base + (i << PAGE_SHIFT)),
@@ -779,9 +773,8 @@
extern char *ldtstore;
static void
-xen_init_amd64_vcpuctxt(struct cpu_info *ci,
- struct vcpu_guest_context *initctx,
- void targetrip(struct cpu_info *))
+xen_init_amd64_vcpuctxt(struct cpu_info *ci, struct vcpu_guest_context *initctx,
+ void targetrip(struct cpu_info *))
{
/* page frames to point at GDT */
extern int gdt_size;
@@ -798,12 +791,12 @@
KASSERT(initctx != NULL);
KASSERT(targetrip != NULL);
- memset(initctx, 0, sizeof *initctx);
+ memset(initctx, 0, sizeof(*initctx));
gdt_ents = roundup(gdt_size, PAGE_SIZE) >> PAGE_SHIFT;
KASSERT(gdt_ents <= 16);
- gdt_prepframes(frames, (vaddr_t) ci->ci_gdt, gdt_ents);
+ gdt_prepframes(frames, (vaddr_t)ci->ci_gdt, gdt_ents);
/* Initialise the vcpu context: We use idle_loop()'s pcb context. */
@@ -842,11 +835,11 @@
initctx->user_regs.ds = GSEL(GDATA_SEL, SEL_KPL);
/* GDT */
- memcpy(initctx->gdt_frames, frames, sizeof frames);
+ memcpy(initctx->gdt_frames, frames, sizeof(frames));
initctx->gdt_ents = gdt_ents;
/* LDT */
- initctx->ldt_base = (unsigned long) ldtstore;
+ initctx->ldt_base = (unsigned long)ldtstore;
initctx->ldt_ents = LDT_SIZE >> 3;
/* Kernel context state */
@@ -854,19 +847,18 @@
initctx->kernel_sp = pcb->pcb_rsp0;
initctx->ctrlreg[0] = pcb->pcb_cr0;
initctx->ctrlreg[1] = 0; /* "resuming" from kernel - no User cr3. */
- initctx->ctrlreg[2] = (vaddr_t) targetrip;
- /*
+ initctx->ctrlreg[2] = (vaddr_t)targetrip;
+ /*
* Use pmap_kernel() L4 PD directly, until we setup the
* per-cpu L4 PD in pmap_cpu_init_late()
*/
initctx->ctrlreg[3] = xen_pfn_to_cr3(x86_btop(xpmap_ptom(ci->ci_kpm_pdirpa)));
initctx->ctrlreg[4] = CR4_PAE | CR4_OSFXSR | CR4_OSXMMEXCPT;
-
/* Xen callbacks */
- initctx->event_callback_eip = (unsigned long) hypervisor_callback;
- initctx->failsafe_callback_eip = (unsigned long) failsafe_callback;
- initctx->syscall_callback_eip = (unsigned long) Xsyscall;
+ initctx->event_callback_eip = (unsigned long)hypervisor_callback;
+ initctx->failsafe_callback_eip = (unsigned long)failsafe_callback;
+ initctx->syscall_callback_eip = (unsigned long)Xsyscall;
return;
}
@@ -875,9 +867,8 @@
extern void Xsyscall(void);
static void
-xen_init_i386_vcpuctxt(struct cpu_info *ci,
- struct vcpu_guest_context *initctx,
- void targeteip(struct cpu_info *))
+xen_init_i386_vcpuctxt(struct cpu_info *ci, struct vcpu_guest_context *initctx,
+ void targeteip(struct cpu_info *))
{
/* page frames to point at GDT */
extern int gdt_size;
@@ -894,12 +885,12 @@
KASSERT(initctx != NULL);
KASSERT(targeteip != NULL);
- memset(initctx, 0, sizeof *initctx);
+ memset(initctx, 0, sizeof(*initctx));
gdt_ents = roundup(gdt_size, PAGE_SIZE) >> PAGE_SHIFT;
KASSERT(gdt_ents <= 16);
- gdt_prepframes(frames, (vaddr_t) ci->ci_gdt, gdt_ents);
+ gdt_prepframes(frames, (vaddr_t)ci->ci_gdt, gdt_ents);
/*
* Initialise the vcpu context:
@@ -929,13 +920,13 @@
initctx->user_regs.esp = pcb->pcb_esp - 4; /* Leave word for
arg1 */
- { /* targeteip(ci); */
- uint32_t *arg = (uint32_t *) initctx->user_regs.esp;
- arg[1] = (uint32_t) ci; /* arg1 */
-
+ {
+ /* targeteip(ci); */
+ uint32_t *arg = (uint32_t *)initctx->user_regs.esp;
+ arg[1] = (uint32_t)ci; /* arg1 */
}
- initctx->user_regs.eip = (vaddr_t) targeteip;
+ initctx->user_regs.eip = (vaddr_t)targeteip;
initctx->user_regs.cs = GSEL(GCODE_SEL, SEL_KPL);
initctx->user_regs.eflags |= pcb->pcb_iopl;
@@ -946,11 +937,11 @@
initctx->user_regs.fs = GSEL(GDATA_SEL, SEL_KPL);
/* GDT */
- memcpy(initctx->gdt_frames, frames, sizeof frames);
+ memcpy(initctx->gdt_frames, frames, sizeof(frames));
initctx->gdt_ents = gdt_ents;
/* LDT */
- initctx->ldt_base = (unsigned long) ldt;
+ initctx->ldt_base = (unsigned long)ldt;
initctx->ldt_ents = NLDT;
/* Kernel context state */
@@ -958,19 +949,18 @@
initctx->kernel_sp = pcb->pcb_esp0;
initctx->ctrlreg[0] = pcb->pcb_cr0;
initctx->ctrlreg[1] = 0; /* "resuming" from kernel - no User cr3. */
- initctx->ctrlreg[2] = (vaddr_t) targeteip;
+ initctx->ctrlreg[2] = (vaddr_t)targeteip;
#ifdef PAE
initctx->ctrlreg[3] = xen_pfn_to_cr3(x86_btop(xpmap_ptom(ci->ci_pae_l3_pdirpa)));
-#else /* PAE */
+#else
initctx->ctrlreg[3] = xen_pfn_to_cr3(x86_btop(xpmap_ptom(pcb->pcb_cr3)));
-#endif /* PAE */
- initctx->ctrlreg[4] = /* CR4_PAE | */CR4_OSFXSR | CR4_OSXMMEXCPT;
-
+#endif
+ initctx->ctrlreg[4] = /* CR4_PAE | */CR4_OSFXSR | CR4_OSXMMEXCPT;
/* Xen callbacks */
- initctx->event_callback_eip = (unsigned long) hypervisor_callback;
+ initctx->event_callback_eip = (unsigned long)hypervisor_callback;
initctx->event_callback_cs = GSEL(GCODE_SEL, SEL_KPL);
- initctx->failsafe_callback_eip = (unsigned long) failsafe_callback;
+ initctx->failsafe_callback_eip = (unsigned long)failsafe_callback;
initctx->failsafe_callback_cs = GSEL(GCODE_SEL, SEL_KPL);
return;
@@ -980,7 +970,6 @@
int
mp_cpu_start(struct cpu_info *ci, vaddr_t target)
{
-
int hyperror;
struct vcpu_guest_context vcpuctx;
@@ -990,9 +979,9 @@
#ifdef __x86_64__
xen_init_amd64_vcpuctxt(ci, &vcpuctx, (void (*)(struct cpu_info *))target);
-#else /* i386 */
+#else
xen_init_i386_vcpuctxt(ci, &vcpuctx, (void (*)(struct cpu_info *))target);
-#endif /* __x86_64__ */
+#endif
/* Initialise the given vcpu to execute cpu_hatch(ci); */
if ((hyperror = HYPERVISOR_vcpu_op(VCPUOP_initialise, ci->ci_cpuid, &vcpuctx))) {
@@ -1026,11 +1015,9 @@
{
if (vcpu_is_up(ci)) {
aprint_debug_dev(ci->ci_dev, "is started.\n");
- }
- else {
+ } else {
aprint_error_dev(ci->ci_dev, "did not start up.\n");
}
-
}
void
@@ -1038,28 +1025,27 @@
{
#ifdef __x86_64__
if (full) {
- HYPERVISOR_set_segment_base (SEGBASE_FS, 0);
- HYPERVISOR_set_segment_base (SEGBASE_GS_KERNEL, (uint64_t) ci);
- HYPERVISOR_set_segment_base (SEGBASE_GS_USER, 0);
+ HYPERVISOR_set_segment_base(SEGBASE_FS, 0);
+ HYPERVISOR_set_segment_base(SEGBASE_GS_KERNEL, (uint64_t)ci);
+ HYPERVISOR_set_segment_base(SEGBASE_GS_USER, 0);
}
-#endif /* __x86_64__ */
+#endif
if (cpu_feature[2] & CPUID_NOX)
wrmsr(MSR_EFER, rdmsr(MSR_EFER) | EFER_NXE);
-
}
void
cpu_offline_md(void)
{
- int s;
+ int s;
- s = splhigh();
- fpusave_cpu(true);
- splx(s);
Home |
Main Index |
Thread Index |
Old Index