replace asm volatile("pause") with function
This commit is contained in:
+2
-1
@@ -6,6 +6,7 @@
|
||||
#include <zinnia/pmap.h>
|
||||
#include <zinnia/utils.h>
|
||||
#include <zinnia/vma.h>
|
||||
#include <arch/cpu.h>
|
||||
#include <stdint.h>
|
||||
#include <x86_64/apic.h>
|
||||
#include <x86_64/asm.h>
|
||||
@@ -129,7 +130,7 @@ void lapic_send_ipi(
|
||||
|
||||
if (lapic->xapic_regs) {
|
||||
while (mmio_field_get(APIC_ICR_DELIVERY_STATUS, lapic_read_icr(lapic)) == APIC_DELIVERY_STATUS_PENDING)
|
||||
asm volatile("pause");
|
||||
arch_cpu_pause();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
static inline void arch_cpu_pause() {
|
||||
asm volatile("pause");
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
#include <zinnia/console.h>
|
||||
#include <zinnia/init.h>
|
||||
#include <zinnia/initgraph.h>
|
||||
#include <arch/cpu.h>
|
||||
#include <stdint.h>
|
||||
#include <x86_64/asm.h>
|
||||
|
||||
@@ -13,7 +14,7 @@ static bool is_ready() {
|
||||
static void serial_write(struct console* con, const char* buf, size_t count) {
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
while (!is_ready())
|
||||
asm volatile("pause");
|
||||
arch_cpu_pause();
|
||||
|
||||
asm_outb(COM1_BASE, buf[i]);
|
||||
}
|
||||
|
||||
+2
-1
@@ -4,6 +4,7 @@
|
||||
#include <zinnia/compiler.h>
|
||||
#include <zinnia/print.h>
|
||||
#include <zinnia/spin.h>
|
||||
#include <arch/cpu.h>
|
||||
#include <stdint.h>
|
||||
|
||||
static struct clock* active_clock = nullptr;
|
||||
@@ -62,6 +63,6 @@ void clock_spin_ns(uint64_t ns) {
|
||||
|
||||
uint64_t target = clock_get_elapsed_ns() + ns;
|
||||
while (clock_get_elapsed_ns() < target) {
|
||||
// TODO: Maybe pause?
|
||||
arch_cpu_pause();
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -6,6 +6,7 @@
|
||||
#include <zinnia/pmap.h>
|
||||
#include <zinnia/spin.h>
|
||||
#include <zinnia/vma.h>
|
||||
#include <arch/cpu.h>
|
||||
#include <config.h>
|
||||
|
||||
// TODO: For now, we assume that we can do generic PTE lookups on every arch that has a MMU.
|
||||
@@ -231,7 +232,7 @@ void pmap_shootdown(struct pmap* pt) {
|
||||
const size_t req = atomic_load(percpu_ref_on(cpu, shootdown_req), ATOMIC_RELAXED);
|
||||
while ((ptrdiff_t)(req - atomic_load(percpu_ref_on(cpu, shootdown_ack), ATOMIC_ACQUIRE)) > 0) {
|
||||
pmap_shootdown_handle();
|
||||
asm volatile("pause");
|
||||
arch_cpu_pause();
|
||||
}
|
||||
}
|
||||
irq_unlock();
|
||||
|
||||
+1
-3
@@ -68,7 +68,7 @@ static struct module* find_locked(const char* name) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void module_init(struct boot_info*) {
|
||||
void module_init() {
|
||||
spin_init(&module_lock);
|
||||
tailq_init(&module_list);
|
||||
|
||||
@@ -77,8 +77,6 @@ void module_init(struct boot_info*) {
|
||||
assert(mod_status == 0, "Built-in entry point returned %i", mod_status);
|
||||
}
|
||||
}
|
||||
INIT_TASK(module_stage, "core.module", module_init);
|
||||
INIT_DEPENDS(module_stage, sched_stage, ksyms_stage);
|
||||
|
||||
static errno_t resolve_symbol(struct module* mod, uint32_t index, uintptr_t* out) {
|
||||
if (index >= mod->num_syms)
|
||||
|
||||
+2
-1
@@ -1,6 +1,7 @@
|
||||
#include <zinnia/atomic.h>
|
||||
#include <zinnia/irq.h>
|
||||
#include <zinnia/spin.h>
|
||||
#include <arch/cpu.h>
|
||||
|
||||
void spin_init(struct spinlock* spin) {
|
||||
spin->next = 0;
|
||||
@@ -12,7 +13,7 @@ void spin_lock(struct spinlock* spin) {
|
||||
uint32_t my = atomic_fetch_add(&spin->next, 1, ATOMIC_RELAXED);
|
||||
|
||||
while (atomic_load(&spin->owner, ATOMIC_ACQUIRE) != my) {
|
||||
asm volatile("pause");
|
||||
arch_cpu_pause();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#include <bits/cpu.h>
|
||||
Reference in New Issue
Block a user