mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-27 12:48:22 +00:00
spinlock: rename functions
This commit is contained in:
@@ -14,7 +14,7 @@ static inline void spinlock_acquire(spinlock_t *lock){
|
||||
while(!__sync_bool_compare_and_swap(lock, 0, 1)) asm("pause");
|
||||
}
|
||||
|
||||
static inline bool spinlock_acquireirqclear(spinlock_t *lock){
|
||||
static inline bool spinlock_acquire_irq_clear(spinlock_t *lock){
|
||||
bool ret = interrupt_set(false);
|
||||
spinlock_acquire(lock);
|
||||
return ret;
|
||||
@@ -28,18 +28,18 @@ static inline void spinlock_release(spinlock_t *lock){
|
||||
*lock = 0;
|
||||
}
|
||||
|
||||
static inline void spinlock_releaseirqrestore(spinlock_t *lock, bool irqstate){
|
||||
static inline void spinlock_release_irq_restore(spinlock_t *lock, bool irqstate){
|
||||
spinlock_release(lock);
|
||||
interrupt_set(irqstate);
|
||||
}
|
||||
|
||||
static inline long spinlock_acquireraiseipl(spinlock_t *lock, long ipl) {
|
||||
static inline long spinlock_acquire_raise_ipl(spinlock_t *lock, long ipl) {
|
||||
long ret = interrupt_raiseipl(ipl);
|
||||
spinlock_acquire(lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline void spinlock_releaseloweripl(spinlock_t *lock, long ipl) {
|
||||
static inline void spinlock_release_lower_ipl(spinlock_t *lock, long ipl) {
|
||||
spinlock_release(lock);
|
||||
interrupt_loweripl(ipl);
|
||||
}
|
||||
|
||||
@@ -379,12 +379,12 @@ static void acpi_dowork(struct acpi_workctx *ctx) {
|
||||
|
||||
struct acpi_work *work = NULL;
|
||||
|
||||
bool irqstate = spinlock_acquireirqclear(&ctx->queuelock);
|
||||
bool irqstate = spinlock_acquire_irq_clear(&ctx->queuelock);
|
||||
if (ctx->head) {
|
||||
work = ctx->head;
|
||||
ctx->head = work->next;
|
||||
}
|
||||
spinlock_releaseirqrestore(&ctx->queuelock, irqstate);
|
||||
spinlock_release_irq_restore(&ctx->queuelock, irqstate);
|
||||
|
||||
if (work == NULL)
|
||||
continue;
|
||||
@@ -439,10 +439,10 @@ uacpi_status uacpi_kernel_schedule_work(
|
||||
break;
|
||||
}
|
||||
|
||||
bool irqstate = spinlock_acquireirqclear(&workctx->queuelock);
|
||||
bool irqstate = spinlock_acquire_irq_clear(&workctx->queuelock);
|
||||
work->next = workctx->head;
|
||||
workctx->head = work;
|
||||
spinlock_releaseirqrestore(&workctx->queuelock, irqstate);
|
||||
spinlock_release_irq_restore(&workctx->queuelock, irqstate);
|
||||
|
||||
semaphore_signal(&workctx->sem);
|
||||
return UACPI_STATUS_OK;
|
||||
@@ -452,9 +452,9 @@ static void work_await(struct acpi_workctx *ctx) {
|
||||
for (;;) {
|
||||
bool empty;
|
||||
|
||||
bool irqstate = spinlock_acquireirqclear(&ctx->queuelock);
|
||||
bool irqstate = spinlock_acquire_irq_clear(&ctx->queuelock);
|
||||
empty = ctx->head == NULL;
|
||||
spinlock_releaseirqrestore(&ctx->queuelock, irqstate);
|
||||
spinlock_release_irq_restore(&ctx->queuelock, irqstate);
|
||||
|
||||
if (empty)
|
||||
return;
|
||||
@@ -567,9 +567,9 @@ void uacpi_kernel_free_spinlock(uacpi_handle lock) {
|
||||
}
|
||||
|
||||
uacpi_cpu_flags uacpi_kernel_lock_spinlock(uacpi_handle lock) {
|
||||
return spinlock_acquireirqclear(lock);
|
||||
return spinlock_acquire_irq_clear(lock);
|
||||
}
|
||||
|
||||
void uacpi_kernel_unlock_spinlock(uacpi_handle lock, uacpi_cpu_flags intstate) {
|
||||
spinlock_releaseirqrestore(lock, intstate);
|
||||
spinlock_release_irq_restore(lock, intstate);
|
||||
}
|
||||
|
||||
@@ -271,9 +271,9 @@ static int udp_recv(socket_t *socket, sockdesc_t *sockdesc) {
|
||||
size_t copycount;
|
||||
dataheader_t header;
|
||||
|
||||
long ipl = spinlock_acquireraiseipl(&udpsocket->ringbufferlock, IPL_DPC);
|
||||
long ipl = spinlock_acquire_raise_ipl(&udpsocket->ringbufferlock, IPL_DPC);
|
||||
__assert(ringbuffer_peek(&udpsocket->ringbuffer, &header, 0, sizeof(header)) == sizeof(header));
|
||||
spinlock_releaseloweripl(&udpsocket->ringbufferlock, ipl);
|
||||
spinlock_release_lower_ipl(&udpsocket->ringbufferlock, ipl);
|
||||
|
||||
copycount = min(header.length, sockdesc->count);
|
||||
|
||||
|
||||
@@ -154,10 +154,10 @@ bool semaphore_signal_limit(semaphore_t *sem, int limit) {
|
||||
}
|
||||
|
||||
void semaphore_reset(semaphore_t *sem) {
|
||||
bool intstate = spinlock_acquireirqclear(&sem->lock);
|
||||
bool intstate = spinlock_acquire_irq_clear(&sem->lock);
|
||||
__assert(sem->head == NULL);
|
||||
sem->i = 0;
|
||||
spinlock_releaseirqrestore(&sem->lock, intstate);
|
||||
spinlock_release_irq_restore(&sem->lock, intstate);
|
||||
}
|
||||
|
||||
bool semaphore_haswaiters(semaphore_t *sem) {
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
#include <arch/cpu.h>
|
||||
#include <kernel/init.h>
|
||||
#include <logging.h>
|
||||
#include <kernel/cmdline.h>
|
||||
#include <kernel/vfs.h>
|
||||
#include <kernel/devfs.h>
|
||||
#include <kernel/initrd.h>
|
||||
#include <kernel/scheduler.h>
|
||||
|
||||
static cpu_t bsp_cpu;
|
||||
|
||||
INIT_ROUTINE_DEFINE(bsp_early,
|
||||
INIT_ROUTINE_FLAGS_PHONY,
|
||||
NULL,
|
||||
alloc, term, cpu
|
||||
);
|
||||
|
||||
void kernel_entry() {
|
||||
cpu_set(&bsp_cpu);
|
||||
logging_sethook(arch_early_log);
|
||||
|
||||
init_run_routine(INIT_GET_ROUTINE(bsp_early));
|
||||
|
||||
cmdline_parse();
|
||||
|
||||
init_run_all_routines();
|
||||
|
||||
// kernel is fully up and running by now
|
||||
// mount root filesystem
|
||||
|
||||
char *root = cmdline_get("root");
|
||||
char *rootfs = cmdline_get("rootfs");
|
||||
|
||||
printf("entry: mounting %s (%s) on /\n", root == NULL ? "none" : root, rootfs);
|
||||
|
||||
vnode_t *backing;
|
||||
if (root) {
|
||||
__assert(devfs_getbyname(root, &backing) == 0);
|
||||
} else {
|
||||
backing = NULL;
|
||||
}
|
||||
|
||||
__assert(vfs_mount(backing, vfsroot, "/", rootfs, NULL) == 0);
|
||||
|
||||
if (backing) {
|
||||
VOP_RELEASE(backing);
|
||||
}
|
||||
|
||||
if (cmdline_get("initrd"))
|
||||
initrd_unpack();
|
||||
|
||||
// spawn init
|
||||
|
||||
proc_run_init();
|
||||
sched_threadexit();
|
||||
}
|
||||
|
||||
cpu_t *get_bsp(void) {
|
||||
return &bsp_cpu;
|
||||
}
|
||||
@@ -29,7 +29,7 @@ syscallret_t syscall_killthread(context_t *context, int pid, int tid, int signal
|
||||
}
|
||||
|
||||
bool ok = false;
|
||||
bool intstatus = spinlock_acquireirqclear(&target->threadlistlock);
|
||||
bool intstatus = spinlock_acquire_irq_clear(&target->threadlistlock);
|
||||
|
||||
thread_t *thread = target->threadlist;
|
||||
while (thread) {
|
||||
@@ -42,7 +42,7 @@ syscallret_t syscall_killthread(context_t *context, int pid, int tid, int signal
|
||||
thread = thread->procnext;
|
||||
}
|
||||
|
||||
spinlock_releaseirqrestore(&target->threadlistlock, intstatus);
|
||||
spinlock_release_irq_restore(&target->threadlistlock, intstatus);
|
||||
|
||||
if (ok == false) {
|
||||
ret.errno = ESRCH;
|
||||
|
||||
@@ -97,11 +97,11 @@ void timer_isr(timer_t *timer, context_t *context) {
|
||||
}
|
||||
|
||||
time_t timer_get_ticks(timer_t *timer) {
|
||||
long ipl = spinlock_acquireraiseipl(&timer->lock, IPL_TIMER);
|
||||
long ipl = spinlock_acquire_raise_ipl(&timer->lock, IPL_TIMER);
|
||||
|
||||
time_t ticks = timer->tickcurrent + timer->time_passed(timer);
|
||||
|
||||
spinlock_releaseloweripl(&timer->lock, ipl);
|
||||
spinlock_release_lower_ipl(&timer->lock, ipl);
|
||||
|
||||
return ticks;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ topology_node_t *topology_create_node(void) {
|
||||
}
|
||||
|
||||
void topology_insert(topology_node_t *node, topology_node_t *parent, int id, cpu_t *cpu) {
|
||||
long old_ipl = spinlock_acquireraiseipl(&tree_lock, IPL_MAX);
|
||||
long old_ipl = spinlock_acquire_raise_ipl(&tree_lock, IPL_MAX);
|
||||
|
||||
node->id = id;
|
||||
node->cpu = cpu;
|
||||
@@ -32,5 +32,5 @@ void topology_insert(topology_node_t *node, topology_node_t *parent, int id, cpu
|
||||
node->sibling = node->parent->children;
|
||||
node->parent->children = node;
|
||||
|
||||
spinlock_releaseloweripl(&tree_lock, old_ipl);
|
||||
spinlock_release_lower_ipl(&tree_lock, old_ipl);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user