本文整理汇总了C++中pcpu_find函数的典型用法代码示例。如果您正苦于以下问题:C++ pcpu_find函数的具体用法?C++ pcpu_find怎么用?C++ pcpu_find使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pcpu_find函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: bind_virq_to_irq
static int
bind_virq_to_irq(unsigned int virq, unsigned int cpu)
{
struct evtchn_bind_virq bind_virq;
int evtchn = 0, irq;
mtx_lock_spin(&irq_mapping_update_lock);
if ((irq = pcpu_find(cpu)->pc_virq_to_irq[virq]) == -1) {
if ((irq = find_unbound_irq()) < 0)
goto out;
bind_virq.virq = virq;
bind_virq.vcpu = cpu;
HYPERVISOR_event_channel_op(EVTCHNOP_bind_virq, &bind_virq);
evtchn = bind_virq.port;
evtchn_to_irq[evtchn] = irq;
irq_info[irq] = mk_irq_info(IRQT_VIRQ, virq, evtchn);
pcpu_find(cpu)->pc_virq_to_irq[virq] = irq;
bind_evtchn_to_cpu(evtchn, cpu);
}
irq_bindcount[irq]++;
unmask_evtchn(evtchn);
out:
mtx_unlock_spin(&irq_mapping_update_lock);
return irq;
}
开发者ID:DangerDexter,项目名称:FreeBSD-8.0-dyntick,代码行数:33,代码来源:evtchn.c
示例2: quiesce_cpus
/*
* Wait specified idle threads to switch once. This ensures that even
* preempted threads have cycled through the switch function once,
* exiting their codepaths. This allows us to change global pointers
* with no other synchronization.
*/
int
quiesce_cpus(cpuset_t map, const char *wmesg, int prio)
{
struct pcpu *pcpu;
u_int gen[MAXCPU];
int error;
int cpu;
error = 0;
for (cpu = 0; cpu <= mp_maxid; cpu++) {
if (!CPU_ISSET(cpu, &map) || CPU_ABSENT(cpu))
continue;
pcpu = pcpu_find(cpu);
gen[cpu] = pcpu->pc_idlethread->td_generation;
}
for (cpu = 0; cpu <= mp_maxid; cpu++) {
if (!CPU_ISSET(cpu, &map) || CPU_ABSENT(cpu))
continue;
pcpu = pcpu_find(cpu);
thread_lock(curthread);
sched_bind(curthread, cpu);
thread_unlock(curthread);
while (gen[cpu] == pcpu->pc_idlethread->td_generation) {
error = tsleep(quiesce_cpus, prio, wmesg, 1);
if (error)
goto out;
}
}
out:
thread_lock(curthread);
sched_unbind(curthread);
thread_unlock(curthread);
return (error);
}
开发者ID:vkhromov,项目名称:freebsd,代码行数:41,代码来源:subr_smp.c
示例3: bind_ipi_to_irq
int
bind_ipi_to_irq(unsigned int ipi, unsigned int cpu)
{
struct evtchn_bind_ipi bind_ipi;
int irq;
int evtchn = 0;
mtx_lock_spin(&irq_mapping_update_lock);
if ((irq = pcpu_find(cpu)->pc_ipi_to_irq[ipi]) == -1) {
if ((irq = find_unbound_irq()) < 0)
goto out;
bind_ipi.vcpu = cpu;
HYPERVISOR_event_channel_op(EVTCHNOP_bind_ipi, &bind_ipi);
evtchn = bind_ipi.port;
evtchn_to_irq[evtchn] = irq;
irq_info[irq] = mk_irq_info(IRQT_IPI, ipi, evtchn);
pcpu_find(cpu)->pc_ipi_to_irq[ipi] = irq;
bind_evtchn_to_cpu(evtchn, cpu);
}
irq_bindcount[irq]++;
unmask_evtchn(evtchn);
out:
mtx_unlock_spin(&irq_mapping_update_lock);
return irq;
}
开发者ID:DangerDexter,项目名称:FreeBSD-8.0-dyntick,代码行数:32,代码来源:evtchn.c
示例4: unbind_from_irq
static void
unbind_from_irq(int irq)
{
struct evtchn_close close;
int evtchn = evtchn_from_irq(irq);
int cpu;
mtx_lock_spin(&irq_mapping_update_lock);
if ((--irq_bindcount[irq] == 0) && VALID_EVTCHN(evtchn)) {
close.port = evtchn;
HYPERVISOR_event_channel_op(EVTCHNOP_close, &close);
switch (type_from_irq(irq)) {
case IRQT_VIRQ:
cpu = cpu_from_evtchn(evtchn);
pcpu_find(cpu)->pc_virq_to_irq[index_from_irq(irq)] = -1;
break;
case IRQT_IPI:
cpu = cpu_from_evtchn(evtchn);
pcpu_find(cpu)->pc_ipi_to_irq[index_from_irq(irq)] = -1;
break;
default:
break;
}
/* Closed ports are implicitly re-bound to VCPU0. */
bind_evtchn_to_cpu(evtchn, 0);
evtchn_to_irq[evtchn] = -1;
irq_info[irq] = IRQ_UNBOUND;
}
mtx_unlock_spin(&irq_mapping_update_lock);
}
开发者ID:DangerDexter,项目名称:FreeBSD-8.0-dyntick,代码行数:35,代码来源:evtchn.c
示例5: cpu_add_child
static device_t
cpu_add_child(device_t bus, u_int order, const char *name, int unit)
{
struct cpu_device *cd;
device_t child;
#ifndef __rtems__
struct pcpu *pc;
#endif /* __rtems__ */
if ((cd = malloc(sizeof(*cd), M_DEVBUF, M_NOWAIT | M_ZERO)) == NULL)
return (NULL);
resource_list_init(&cd->cd_rl);
#ifndef __rtems__
pc = pcpu_find(device_get_unit(bus));
cd->cd_pcpu = pc;
#endif /* __rtems__ */
child = device_add_child_ordered(bus, order, name, unit);
if (child != NULL) {
#ifndef __rtems__
pc->pc_device = child;
#endif /* __rtems__ */
device_set_ivars(child, cd);
} else
free(cd, M_DEVBUF);
return (child);
}
开发者ID:asuol,项目名称:rtems-libbsd,代码行数:28,代码来源:legacy.c
示例6: chrp_smp_topo
static struct cpu_group *
chrp_smp_topo(platform_t plat)
{
struct pcpu *pc, *last_pc;
int i, ncores, ncpus;
ncores = ncpus = 0;
last_pc = NULL;
for (i = 0; i <= mp_maxid; i++) {
pc = pcpu_find(i);
if (pc == NULL)
continue;
if (last_pc == NULL || pc->pc_hwref != last_pc->pc_hwref)
ncores++;
last_pc = pc;
ncpus++;
}
if (ncpus % ncores != 0) {
printf("WARNING: Irregular SMP topology. Performance may be "
"suboptimal (%d CPUS, %d cores)\n", ncpus, ncores);
return (smp_topo_none());
}
/* Don't do anything fancier for non-threaded SMP */
if (ncpus == ncores)
return (smp_topo_none());
return (smp_topo_1level(CG_SHARE_L1, ncpus / ncores, CG_FLAG_SMT));
}
开发者ID:OpenKod,项目名称:src,代码行数:30,代码来源:platform_chrp.c
示例7: srat_set_cpus
/*
* Setup per-CPU domain IDs.
*/
static void
srat_set_cpus(void *dummy)
{
struct cpu_info *cpu;
struct pcpu *pc;
u_int i;
if (srat_physaddr == 0)
return;
for (i = 0; i < MAXCPU; i++) {
if (CPU_ABSENT(i))
continue;
pc = pcpu_find(i);
KASSERT(pc != NULL, ("no pcpu data for CPU %u", i));
cpu = &cpus[pc->pc_apic_id];
if (!cpu->enabled)
panic("SRAT: CPU with APIC ID %u is not known",
pc->pc_apic_id);
pc->pc_domain = cpu->domain;
CPU_SET(i, &cpuset_domain[cpu->domain]);
if (bootverbose)
printf("SRAT: CPU %u has memory domain %d\n", i,
cpu->domain);
}
}
开发者ID:mulichao,项目名称:freebsd,代码行数:28,代码来源:srat.c
示例8: ipi_selected
/*
* send an IPI to a set of cpus.
*/
void
ipi_selected(u_int32_t cpus, u_int ipi)
{
struct pcpu *pcpu;
u_int cpuid, new_pending, old_pending;
CTR3(KTR_SMP, "%s: cpus: %x, ipi: %x\n", __func__, cpus, ipi);
while ((cpuid = ffs(cpus)) != 0) {
cpuid--;
cpus &= ~(1 << cpuid);
pcpu = pcpu_find(cpuid);
if (pcpu) {
do {
old_pending = pcpu->pc_pending_ipis;
new_pending = old_pending | ipi;
} while (!atomic_cmpset_int(&pcpu->pc_pending_ipis,
old_pending, new_pending));
if (old_pending)
continue;
mips_ipi_send (cpuid);
}
}
}
开发者ID:DangerDexter,项目名称:FreeBSD-8.0-dyntick,代码行数:30,代码来源:mp_machdep.c
示例9: acpi_pcpu_get_id
/*
* Find the nth present CPU and return its pc_cpuid as well as set the
* pc_acpi_id from the most reliable source.
*/
static int
acpi_pcpu_get_id(uint32_t idx, uint32_t *acpi_id, uint32_t *cpu_id)
{
struct pcpu *pcpu_data;
uint32_t i;
KASSERT(acpi_id != NULL, ("Null acpi_id"));
KASSERT(cpu_id != NULL, ("Null cpu_id"));
for (i = 0; i <= mp_maxid; i++) {
if (CPU_ABSENT(i))
continue;
pcpu_data = pcpu_find(i);
KASSERT(pcpu_data != NULL, ("no pcpu data for %d", i));
if (idx-- == 0) {
/*
* If pc_acpi_id was not initialized (e.g., a non-APIC UP box)
* override it with the value from the ASL. Otherwise, if the
* two don't match, prefer the MADT-derived value. Finally,
* return the pc_cpuid to reference this processor.
*/
if (pcpu_data->pc_acpi_id == 0xffffffff)
pcpu_data->pc_acpi_id = *acpi_id;
else if (pcpu_data->pc_acpi_id != *acpi_id)
*acpi_id = pcpu_data->pc_acpi_id;
*cpu_id = pcpu_data->pc_cpuid;
return (0);
}
}
return (ESRCH);
}
开发者ID:DangerDexter,项目名称:FreeBSD-8.0-dyntick,代码行数:35,代码来源:acpi_cpu.c
示例10: ipi_pcpu
/*
* Send an IPI from the current CPU to the destination CPU.
*/
void
ipi_pcpu(unsigned int cpu, int vector)
{
int irq;
irq = pcpu_find(cpu)->pc_ipi_to_irq[vector];
notify_remote_via_irq(irq);
}
开发者ID:DangerDexter,项目名称:FreeBSD-8.0-dyntick,代码行数:12,代码来源:evtchn.c
示例11: _rm_rlock_debug
int
_rm_rlock_debug(struct rmlock *rm, struct rm_priotracker *tracker,
int trylock, const char *file, int line)
{
if (SCHEDULER_STOPPED())
return (1);
#ifdef INVARIANTS
if (!(rm->lock_object.lo_flags & LO_RECURSABLE) && !trylock) {
critical_enter();
KASSERT(rm_trackers_present(pcpu_find(curcpu), rm,
curthread) == 0,
("rm_rlock: recursed on non-recursive rmlock %s @ %s:%d\n",
rm->lock_object.lo_name, file, line));
critical_exit();
}
#endif
KASSERT(kdb_active != 0 || !TD_IS_IDLETHREAD(curthread),
("rm_rlock() by idle thread %p on rmlock %s @ %s:%d",
curthread, rm->lock_object.lo_name, file, line));
KASSERT(!rm_destroyed(rm),
("rm_rlock() of destroyed rmlock @ %s:%d", file, line));
if (!trylock) {
KASSERT(!rm_wowned(rm),
("rm_rlock: wlock already held for %s @ %s:%d",
rm->lock_object.lo_name, file, line));
WITNESS_CHECKORDER(&rm->lock_object, LOP_NEWORDER, file, line,
NULL);
}
if (_rm_rlock(rm, tracker, trylock)) {
if (trylock)
LOCK_LOG_TRY("RMRLOCK", &rm->lock_object, 0, 1, file,
line);
else
LOCK_LOG_LOCK("RMRLOCK", &rm->lock_object, 0, 0, file,
line);
WITNESS_LOCK(&rm->lock_object, 0, file, line);
curthread->td_locks++;
return (1);
} else if (trylock)
LOCK_LOG_TRY("RMRLOCK", &rm->lock_object, 0, 0, file, line);
return (0);
}
开发者ID:Alkzndr,项目名称:freebsd,代码行数:48,代码来源:kern_rmlock.c
示例12: ofw_cpu_attach
static int
ofw_cpu_attach(device_t dev)
{
struct ofw_cpulist_softc *psc;
struct ofw_cpu_softc *sc;
phandle_t node;
pcell_t cell;
int rv;
sc = device_get_softc(dev);
psc = device_get_softc(device_get_parent(dev));
if (nitems(sc->sc_reg) < psc->sc_addr_cells) {
if (bootverbose)
device_printf(dev, "Too many address cells\n");
return (EINVAL);
}
node = ofw_bus_get_node(dev);
/* Read and validate the reg property for use later */
sc->sc_reg_valid = false;
rv = OF_getencprop(node, "reg", sc->sc_reg, sizeof(sc->sc_reg));
if (rv < 0)
device_printf(dev, "missing 'reg' property\n");
else if ((rv % 4) != 0) {
if (bootverbose)
device_printf(dev, "Malformed reg property\n");
} else if ((rv / 4) != psc->sc_addr_cells) {
if (bootverbose)
device_printf(dev, "Invalid reg size %u\n", rv);
} else
sc->sc_reg_valid = true;
sc->sc_cpu_pcpu = pcpu_find(device_get_unit(dev));
if (OF_getencprop(node, "clock-frequency", &cell, sizeof(cell)) < 0) {
if (bootverbose)
device_printf(dev,
"missing 'clock-frequency' property\n");
} else
sc->sc_nominal_mhz = cell / 1000000; /* convert to MHz */
bus_generic_probe(dev);
return (bus_generic_attach(dev));
}
开发者ID:2trill2spill,项目名称:freebsd,代码行数:46,代码来源:ofw_cpu.c
示例13: dpcpu_init
void
dpcpu_init(void *dpcpu, int cpuid)
{
struct pcpu *pcpu;
pcpu = pcpu_find(cpuid);
pcpu->pc_dynamic = (uintptr_t)dpcpu - DPCPU_START;
/*
* Initialize defaults from our linker section.
*/
memcpy(dpcpu, (void *)DPCPU_START, DPCPU_BYTES);
/*
* Place it in the global pcpu offset array.
*/
dpcpu_off[cpuid] = pcpu->pc_dynamic;
}
开发者ID:BlueFireworks,项目名称:rtems-libbsd,代码行数:18,代码来源:subr_pcpu.c
示例14: unlock_rm
static uintptr_t
unlock_rm(struct lock_object *lock)
{
struct thread *td;
struct pcpu *pc;
struct rmlock *rm;
struct rm_queue *queue;
struct rm_priotracker *tracker;
uintptr_t how;
rm = (struct rmlock *)lock;
tracker = NULL;
how = 0;
rm_assert(rm, RA_LOCKED | RA_NOTRECURSED);
if (rm_wowned(rm))
rm_wunlock(rm);
else {
/*
* Find the right rm_priotracker structure for curthread.
* The guarantee about its uniqueness is given by the fact
* we already asserted the lock wasn't recursively acquired.
*/
critical_enter();
td = curthread;
pc = pcpu_find(curcpu);
for (queue = pc->pc_rm_queue.rmq_next;
queue != &pc->pc_rm_queue; queue = queue->rmq_next) {
tracker = (struct rm_priotracker *)queue;
if ((tracker->rmp_rmlock == rm) &&
(tracker->rmp_thread == td)) {
how = (uintptr_t)tracker;
break;
}
}
KASSERT(tracker != NULL,
("rm_priotracker is non-NULL when lock held in read mode"));
critical_exit();
rm_runlock(rm, tracker);
}
return (how);
}
开发者ID:2asoft,项目名称:freebsd,代码行数:41,代码来源:kern_rmlock.c
示例15: rm_cleanIPI
static void
rm_cleanIPI(void *arg)
{
struct pcpu *pc;
struct rmlock *rm = arg;
struct rm_priotracker *tracker;
struct rm_queue *queue;
pc = pcpu_find(curcpu);
for (queue = pc->pc_rm_queue.rmq_next; queue != &pc->pc_rm_queue;
queue = queue->rmq_next) {
tracker = (struct rm_priotracker *)queue;
if (tracker->rmp_rmlock == rm && tracker->rmp_flags == 0) {
tracker->rmp_flags = RMPF_ONQUEUE;
mtx_lock_spin(&rm_spinlock);
LIST_INSERT_HEAD(&rm->rm_activeReaders, tracker,
rmp_qentry);
mtx_unlock_spin(&rm_spinlock);
}
}
}
开发者ID:2asoft,项目名称:freebsd,代码行数:21,代码来源:kern_rmlock.c
示例16: acpi_pxm_set_cpu_locality
/*
* Setup per-CPU domain IDs from information saved in 'cpus'.
*/
void
acpi_pxm_set_cpu_locality(void)
{
struct cpu_info *cpu;
struct pcpu *pc;
u_int i;
if (srat_physaddr == 0)
return;
for (i = 0; i < MAXCPU; i++) {
if (CPU_ABSENT(i))
continue;
pc = pcpu_find(i);
KASSERT(pc != NULL, ("no pcpu data for CPU %u", i));
cpu = cpu_get_info(pc);
pc->pc_domain = vm_ndomains > 1 ? cpu->domain : 0;
CPU_SET(i, &cpuset_domain[pc->pc_domain]);
if (bootverbose)
printf("SRAT: CPU %u has memory domain %d\n", i,
pc->pc_domain);
}
}
开发者ID:FreeBSDFoundation,项目名称:freebsd,代码行数:25,代码来源:acpi_pxm.c
示例17: ofw_cpu_attach
static int
ofw_cpu_attach(device_t dev)
{
struct ofw_cpu_softc *sc;
phandle_t node;
uint32_t cell;
sc = device_get_softc(dev);
node = ofw_bus_get_node(dev);
if (OF_getencprop(node, "reg", &cell, sizeof(cell)) < 0) {
cell = device_get_unit(dev);
device_printf(dev, "missing 'reg' property, using %u\n", cell);
}
sc->sc_cpu_pcpu = pcpu_find(cell);
if (OF_getencprop(node, "clock-frequency", &cell, sizeof(cell)) < 0) {
device_printf(dev, "missing 'clock-frequency' property\n");
return (ENXIO);
}
sc->sc_nominal_mhz = cell / 1000000; /* convert to MHz */
bus_generic_probe(dev);
return (bus_generic_attach(dev));
}
开发者ID:coyizumi,项目名称:cs111,代码行数:23,代码来源:ofw_cpu.c
示例18: acpi_cpu_attach
static int
acpi_cpu_attach(device_t dev)
{
ACPI_BUFFER buf;
ACPI_OBJECT arg, *obj;
ACPI_OBJECT_LIST arglist;
struct pcpu *pcpu_data;
struct acpi_cpu_softc *sc;
struct acpi_softc *acpi_sc;
ACPI_STATUS status;
u_int features;
int cpu_id, drv_count, i;
driver_t **drivers;
uint32_t cap_set[3];
/* UUID needed by _OSC evaluation */
static uint8_t cpu_oscuuid[16] = { 0x16, 0xA6, 0x77, 0x40, 0x0C, 0x29,
0xBE, 0x47, 0x9E, 0xBD, 0xD8, 0x70,
0x58, 0x71, 0x39, 0x53 };
ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
sc = device_get_softc(dev);
sc->cpu_dev = dev;
sc->cpu_handle = acpi_get_handle(dev);
cpu_id = (int)(intptr_t)acpi_get_private(dev);
cpu_softc[cpu_id] = sc;
pcpu_data = pcpu_find(cpu_id);
pcpu_data->pc_device = dev;
sc->cpu_pcpu = pcpu_data;
cpu_smi_cmd = AcpiGbl_FADT.SmiCommand;
cpu_cst_cnt = AcpiGbl_FADT.CstControl;
buf.Pointer = NULL;
buf.Length = ACPI_ALLOCATE_BUFFER;
status = AcpiEvaluateObject(sc->cpu_handle, NULL, NULL, &buf);
if (ACPI_FAILURE(status)) {
device_printf(dev, "attach failed to get Processor obj - %s\n",
AcpiFormatException(status));
return (ENXIO);
}
obj = (ACPI_OBJECT *)buf.Pointer;
sc->cpu_p_blk = obj->Processor.PblkAddress;
sc->cpu_p_blk_len = obj->Processor.PblkLength;
sc->cpu_acpi_id = obj->Processor.ProcId;
AcpiOsFree(obj);
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "acpi_cpu%d: P_BLK at %#x/%d\n",
device_get_unit(dev), sc->cpu_p_blk, sc->cpu_p_blk_len));
/*
* If this is the first cpu we attach, create and initialize the generic
* resources that will be used by all acpi cpu devices.
*/
if (device_get_unit(dev) == 0) {
/* Assume we won't be using generic Cx mode by default */
cpu_cx_generic = FALSE;
/* Install hw.acpi.cpu sysctl tree */
acpi_sc = acpi_device_get_parent_softc(dev);
sysctl_ctx_init(&cpu_sysctl_ctx);
cpu_sysctl_tree = SYSCTL_ADD_NODE(&cpu_sysctl_ctx,
SYSCTL_CHILDREN(acpi_sc->acpi_sysctl_tree), OID_AUTO, "cpu",
CTLFLAG_RD, 0, "node for CPU children");
}
/*
* Before calling any CPU methods, collect child driver feature hints
* and notify ACPI of them. We support unified SMP power control
* so advertise this ourselves. Note this is not the same as independent
* SMP control where each CPU can have different settings.
*/
sc->cpu_features = ACPI_CAP_SMP_SAME | ACPI_CAP_SMP_SAME_C3 |
ACPI_CAP_C1_IO_HALT;
#if defined(__i386__) || defined(__amd64__)
/*
* Ask for MWAIT modes if not disabled and interrupts work
* reasonable with MWAIT.
*/
if (!acpi_disabled("mwait") && cpu_mwait_usable())
sc->cpu_features |= ACPI_CAP_SMP_C1_NATIVE | ACPI_CAP_SMP_C3_NATIVE;
#endif
if (devclass_get_drivers(acpi_cpu_devclass, &drivers, &drv_count) == 0) {
for (i = 0; i < drv_count; i++) {
if (ACPI_GET_FEATURES(drivers[i], &features) == 0)
sc->cpu_features |= features;
}
free(drivers, M_TEMP);
}
/*
* CPU capabilities are specified in
* Intel Processor Vendor-Specific ACPI Interface Specification.
*/
if (sc->cpu_features) {
cap_set[1] = sc->cpu_features;
status = acpi_EvaluateOSC(sc->cpu_handle, cpu_oscuuid, 1, 2, cap_set,
cap_set, false);
if (ACPI_SUCCESS(status)) {
//.........这里部分代码省略.........
开发者ID:Digital-Chaos,项目名称:freebsd,代码行数:101,代码来源:acpi_cpu.c
示例19: dtrace_ioctl
//.........这里部分代码省略.........
break;
}
mutex_exit(&dtrace_lock);
if (copyout(buf, (void *) *paggdesc, dest - (uintptr_t)buf) != 0) {
kmem_free(buf, size);
return (EFAULT);
}
kmem_free(buf, size);
return (0);
}
case DTRACEIOC_AGGSNAP:
case DTRACEIOC_BUFSNAP: {
dtrace_bufdesc_t **pdesc = (dtrace_bufdesc_t **) addr;
dtrace_bufdesc_t desc;
caddr_t cached;
dtrace_buffer_t *buf;
dtrace_debug_output();
if (copyin((void *) *pdesc, &desc, sizeof (desc)) != 0)
return (EFAULT);
DTRACE_IOCTL_PRINTF("%s(%d): %s curcpu %d cpu %d\n",
__func__,__LINE__,
cmd == DTRACEIOC_AGGSNAP ?
"DTRACEIOC_AGGSNAP":"DTRACEIOC_BUFSNAP",
curcpu, desc.dtbd_cpu);
if (desc.dtbd_cpu < 0 || desc.dtbd_cpu >= NCPU)
return (ENOENT);
if (pcpu_find(desc.dtbd_cpu) == NULL)
return (ENOENT);
mutex_enter(&dtrace_lock);
if (cmd == DTRACEIOC_BUFSNAP) {
buf = &state->dts_buffer[desc.dtbd_cpu];
} else {
buf = &state->dts_aggbuffer[desc.dtbd_cpu];
}
if (buf->dtb_flags & (DTRACEBUF_RING | DTRACEBUF_FILL)) {
size_t sz = buf->dtb_offset;
if (state->dts_activity != DTRACE_ACTIVITY_STOPPED) {
mutex_exit(&dtrace_lock);
return (EBUSY);
}
/*
* If this buffer has already been consumed, we're
* going to indicate that there's nothing left here
* to consume.
*/
if (buf->dtb_flags & DTRACEBUF_CONSUMED) {
mutex_exit(&dtrace_lock);
desc.dtbd_size = 0;
desc.dtbd_drops = 0;
desc.dtbd_errors = 0;
desc.dtbd_oldest = 0;
sz = sizeof (desc);
开发者ID:AhmadTux,项目名称:freebsd,代码行数:66,代码来源:dtrace_ioctl.c
示例20: acpi_sleep_machdep
int
acpi_sleep_machdep(struct acpi_softc *sc, int state)
{
ACPI_STATUS status;
struct pcb *pcb;
#ifdef __amd64__
struct pcpu *pc;
int i;
#endif
if (sc->acpi_wakeaddr == 0ul)
return (-1); /* couldn't alloc wake memory */
#ifdef SMP
suspcpus = all_cpus;
CPU_CLR(PCPU_GET(cpuid), &suspcpus);
#endif
if (acpi_resume_beep != 0)
timer_spkr_acquire();
AcpiSetFirmwareWakingVector(sc->acpi_wakephys, 0);
intr_suspend();
pcb = &susppcbs[0]->sp_pcb;
if (savectx(pcb)) {
#ifdef __amd64__
fpususpend(susppcbs[0]->sp_fpususpend);
#else
npxsuspend(susppcbs[0]->sp_fpususpend);
#endif
#ifdef SMP
if (!CPU_EMPTY(&suspcpus) && suspend_cpus(suspcpus) == 0) {
device_printf(sc->acpi_dev, "Failed to suspend APs\n");
return (0); /* couldn't sleep */
}
#endif
#ifdef __amd64__
hw_ibrs_active = 0;
hw_ssb_active = 0;
cpu_stdext_feature3 = 0;
CPU_FOREACH(i) {
pc = pcpu_find(i);
pc->pc_ibpb_set = 0;
}
#endif
WAKECODE_FIXUP(resume_beep, uint8_t, (acpi_resume_beep != 0));
WAKECODE_FIXUP(reset_video, uint8_t, (acpi_reset_video != 0));
#ifdef __amd64__
WAKECODE_FIXUP(wakeup_efer, uint64_t, rdmsr(MSR_EFER) &
~(EFER_LMA));
#else
if ((amd_feature & AMDID_NX) != 0)
WAKECODE_FIXUP(wakeup_efer, uint64_t, rdmsr(MSR_EFER));
WAKECODE_FIXUP(wakeup_cr4, register_t, pcb->pcb_cr4);
#endif
WAKECODE_FIXUP(wakeup_pcb, struct pcb *, pcb);
WAKECODE_FIXUP(wakeup_gdt, uint16_t, pcb->pcb_gdt.rd_limit);
WAKECODE_FIXUP(wakeup_gdt + 2, uint64_t, pcb->pcb_gdt.rd_base);
#ifdef __i386__
/*
* Map some low memory with virt == phys for ACPI wakecode
* to use to jump to high memory after enabling paging. This
* is the same as for similar jump in locore, except the
* jump is a single instruction, and we know its address
* more precisely so only need a single PTD, and we have to
* be careful to use the kernel map (PTD[0] is for curthread
* which may be a user thread in deprecated APIs).
*/
pmap_remap_lowptdi(true);
#endif
/* Call ACPICA to enter the desired sleep state */
if (state == ACPI_STATE_S4 && sc->acpi_s4bios)
status = AcpiEnterSleepStateS4bios();
else
status = AcpiEnterSleepState(state);
if (ACPI_FAILURE(status)) {
device_printf(sc->acpi_dev,
"AcpiEnterSleepState failed - %s\n",
AcpiFormatException(status));
return (0); /* couldn't sleep */
}
if (acpi_susp_bounce)
resumectx(pcb);
for (;;)
ia32_pause();
} else {
开发者ID:FreeBSDFoundation,项目名称:freebsd,代码行数:94,代码来源:acpi_wakeup.c
注:本文中的pcpu_find函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论