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