Simplified RR, cleanup stream function params
This commit is contained in:
@@ -140,25 +140,25 @@ static void idt_init (void) {
|
||||
|
||||
/* Handle CPU exception and dump registers. If incoming CS has CPL3, kill the process. */
|
||||
static void intr_exception (struct saved_regs* regs) {
|
||||
DEBUG_NOLOCK ("cpu exception %lu (%lu)\n", regs->trap, regs->error);
|
||||
DEBUG ("cpu exception %lu (%lu)\n", regs->trap, regs->error);
|
||||
|
||||
uint64_t cr2;
|
||||
__asm__ volatile ("movq %%cr2, %0" : "=r"(cr2));
|
||||
uint64_t cr3;
|
||||
__asm__ volatile ("movq %%cr3, %0" : "=r"(cr3));
|
||||
|
||||
debugprintf_nolock ("r15=%016lx r14=%016lx r13=%016lx\n"
|
||||
"r12=%016lx r11=%016lx r10=%016lx\n"
|
||||
"r9 =%016lx r8 =%016lx rbp=%016lx\n"
|
||||
"rdi=%016lx rsi=%016lx rdx=%016lx\n"
|
||||
"rcx=%016lx rax=%016lx trp=%016lx\n"
|
||||
"err=%016lx rip=%016lx cs =%016lx\n"
|
||||
"rfl=%016lx rsp=%016lx ss =%016lx\n"
|
||||
"cr2=%016lx cr3=%016lx rbx=%016lx\n",
|
||||
regs->r15, regs->r14, regs->r13, regs->r12, regs->r11, regs->r10, regs->r9,
|
||||
regs->r8, regs->rbp, regs->rdi, regs->rsi, regs->rdx, regs->rcx, regs->rax,
|
||||
regs->trap, regs->error, regs->rip, regs->cs, regs->rflags, regs->rsp,
|
||||
regs->ss, cr2, cr3, regs->rbx);
|
||||
debugprintf ("r15=%016lx r14=%016lx r13=%016lx\n"
|
||||
"r12=%016lx r11=%016lx r10=%016lx\n"
|
||||
"r9 =%016lx r8 =%016lx rbp=%016lx\n"
|
||||
"rdi=%016lx rsi=%016lx rdx=%016lx\n"
|
||||
"rcx=%016lx rax=%016lx trp=%016lx\n"
|
||||
"err=%016lx rip=%016lx cs =%016lx\n"
|
||||
"rfl=%016lx rsp=%016lx ss =%016lx\n"
|
||||
"cr2=%016lx cr3=%016lx rbx=%016lx\n",
|
||||
regs->r15, regs->r14, regs->r13, regs->r12, regs->r11, regs->r10, regs->r9, regs->r8,
|
||||
regs->rbp, regs->rdi, regs->rsi, regs->rdx, regs->rcx, regs->rax, regs->trap,
|
||||
regs->error, regs->rip, regs->cs, regs->rflags, regs->rsp, regs->ss, cr2, cr3,
|
||||
regs->rbx);
|
||||
|
||||
if (regs->cs == (GDT_UCODE | 0x03)) {
|
||||
struct reschedule_ctx rctx;
|
||||
|
||||
@@ -49,6 +49,7 @@ struct proc* kproc_create (void) {
|
||||
|
||||
kproc->lock = SPIN_LOCK_INIT;
|
||||
kproc->flags |= PROC_KPROC;
|
||||
kproc->state = PROC_READY;
|
||||
kproc->pid = proc_alloc_pid ();
|
||||
|
||||
kproc->procgroup = procgroup_create ();
|
||||
@@ -58,7 +59,7 @@ struct proc* kproc_create (void) {
|
||||
|
||||
struct reschedule_ctx rctx;
|
||||
memset (&rctx, 0, sizeof (rctx));
|
||||
proc_register (kproc, NULL, &rctx);
|
||||
proc_register (kproc, thiscpu, &rctx);
|
||||
|
||||
return kproc;
|
||||
}
|
||||
@@ -228,24 +229,19 @@ void proc_register_partial (struct proc* proc) {
|
||||
static struct proc* proc_find_sched (struct cpu* cpu) {
|
||||
uint64_t fp;
|
||||
|
||||
struct list_node_link *current, *start;
|
||||
|
||||
if (!cpu->proc_run_q)
|
||||
return NULL;
|
||||
|
||||
struct list_node_link *current, *start;
|
||||
|
||||
if (cpu->proc_current && cpu->proc_current->cpu_run_q_link.next)
|
||||
current = cpu->proc_current->cpu_run_q_link.next;
|
||||
else
|
||||
current = cpu->proc_run_q;
|
||||
|
||||
if (!current)
|
||||
current = cpu->proc_run_q;
|
||||
|
||||
start = current;
|
||||
|
||||
bool wrap = false;
|
||||
|
||||
while (current) {
|
||||
do {
|
||||
struct proc* proc = list_entry (current, struct proc, cpu_run_q_link);
|
||||
|
||||
spin_lock (&proc->lock, &fp);
|
||||
@@ -261,14 +257,9 @@ static struct proc* proc_find_sched (struct cpu* cpu) {
|
||||
|
||||
current = current->next;
|
||||
|
||||
if (!current && !wrap) {
|
||||
if (!current)
|
||||
current = cpu->proc_run_q;
|
||||
wrap = true;
|
||||
}
|
||||
|
||||
if (wrap && current == start)
|
||||
break;
|
||||
}
|
||||
} while (current != start);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -7,8 +7,7 @@
|
||||
#include <proc/stream.h>
|
||||
#include <proc/suspension_q.h>
|
||||
|
||||
void proc_stream_write (struct proc* proc, struct proc_stream* stream, struct reschedule_ctx* rctx,
|
||||
void* data, size_t data_size) {
|
||||
void proc_stream_write (struct proc_stream* stream, void* data, size_t data_size) {
|
||||
uint64_t fr, fsq;
|
||||
|
||||
spin_lock (&stream->resource->lock, &fr);
|
||||
@@ -19,8 +18,7 @@ void proc_stream_write (struct proc* proc, struct proc_stream* stream, struct re
|
||||
spin_unlock (&stream->resource->lock, fr);
|
||||
}
|
||||
|
||||
size_t proc_stream_read (struct proc* proc, struct proc_stream* stream, struct reschedule_ctx* rctx,
|
||||
void* out_data, size_t data_size) {
|
||||
size_t proc_stream_read (struct proc_stream* stream, void* out_data, size_t data_size) {
|
||||
uint64_t fr;
|
||||
|
||||
size_t bytes = 0;
|
||||
|
||||
@@ -20,10 +20,8 @@ struct proc_stream {
|
||||
|
||||
void proc_cleanup_resource_stream (struct proc_resource* resource, struct reschedule_ctx* rctx);
|
||||
|
||||
void proc_stream_write (struct proc* proc, struct proc_stream* stream, struct reschedule_ctx* rctx,
|
||||
void* data, size_t data_size);
|
||||
void proc_stream_write (struct proc_stream* stream, void* data, size_t data_size);
|
||||
|
||||
size_t proc_stream_read (struct proc* proc, struct proc_stream* stream, struct reschedule_ctx* rctx,
|
||||
void* out_data, size_t data_size);
|
||||
size_t proc_stream_read (struct proc_stream* stream, void* out_data, size_t data_size);
|
||||
|
||||
#endif // _KERNEL_PROC_STREAM_H
|
||||
|
||||
@@ -1061,7 +1061,7 @@ DEFINE_SYSCALL (sys_stream_write) {
|
||||
if (stream_resource == NULL)
|
||||
return SYSRESULT (-ST_NOT_FOUND);
|
||||
|
||||
proc_stream_write (proc, &stream_resource->u.stream, rctx, buffer, buffer_size);
|
||||
proc_stream_write (&stream_resource->u.stream, buffer, buffer_size);
|
||||
|
||||
return SYSRESULT (ST_OK);
|
||||
}
|
||||
@@ -1094,7 +1094,7 @@ DEFINE_SYSCALL (sys_stream_read) {
|
||||
if (stream_resource == NULL)
|
||||
return SYSRESULT (-ST_NOT_FOUND);
|
||||
|
||||
return SYSRESULT (proc_stream_read (proc, &stream_resource->u.stream, rctx, buffer, buffer_size));
|
||||
return SYSRESULT (proc_stream_read (&stream_resource->u.stream, buffer, buffer_size));
|
||||
}
|
||||
|
||||
static syscall_handler_func_t handler_table[] = {
|
||||
|
||||
Reference in New Issue
Block a user