fixed a couple of small bugs
This commit is contained in:
parent
9008aa4d78
commit
f75963f7bb
@ -8,10 +8,10 @@
|
||||
|
||||
void write_mtimecmp(unsigned long long int mtimecmp)
|
||||
{
|
||||
unsigned int lo = mtimecmp;
|
||||
unsigned int lo = mtimecmp & 0xffffffff;
|
||||
unsigned int hi = mtimecmp >> 32;
|
||||
|
||||
__asm__ (
|
||||
__asm__ volatile(
|
||||
"li t0, %0\n"
|
||||
"sw %1, 0(t0)\n"
|
||||
"sw %2, 4(t0)" ::
|
||||
@ -23,10 +23,10 @@ void write_mtimecmp(unsigned long long int mtimecmp)
|
||||
|
||||
void write_mtimecmp(unsigned long long int mtimecmp)
|
||||
{
|
||||
unsigned int lower = mtimecmp;
|
||||
unsigned int lower = mtimecmp & 0xffffffff;
|
||||
unsigned int higher = mtimecmp >> 32;
|
||||
|
||||
__asm__ (
|
||||
__asm__ volatile(
|
||||
"csrw %0, %2\n"
|
||||
"csrw %1, %3" ::
|
||||
"I"(CSR_MTIMECMP),"I"(CSR_MTIMECMPH),
|
||||
|
@ -41,7 +41,7 @@ inline __attribute__((always_inline)) unsigned long long int read_time()
|
||||
{
|
||||
unsigned int lower, higher;
|
||||
|
||||
__asm__ (
|
||||
__asm__ volatile(
|
||||
"csrr %0, %2\n"
|
||||
"csrr %1, %3\n"
|
||||
: "=r"(lower), "=r"(higher)
|
||||
|
@ -131,8 +131,8 @@ void trap_handle_ecall()
|
||||
// run the corresponding ecall handler
|
||||
optional_int handler_result = ecall_table[code](®s[REG_A0], pcb);
|
||||
// populate registers with return value and error
|
||||
regs[REG_A0] = handler_result.value;
|
||||
regs[REG_A0 + 1] = handler_result.error;
|
||||
regs[REG_A0] = handler_result.error;
|
||||
regs[REG_A0 + 1] = handler_result.value;
|
||||
}
|
||||
|
||||
// increment pc of this process to move past ecall instruction
|
||||
|
@ -124,6 +124,10 @@ struct voidptr_stack {
|
||||
int size;
|
||||
};
|
||||
|
||||
inline void* voidptr_stack_pop(struct voidptr_stack* stack) __attribute__((always_inline));
|
||||
inline int voidptr_stack_push(struct voidptr_stack* stack, void* ptr) __attribute__((always_inline));
|
||||
inline void voidptr_stack_new(struct voidptr_stack* stack, void** data, int size) __attribute__((always_inline));
|
||||
|
||||
inline void* voidptr_stack_pop(struct voidptr_stack* stack)
|
||||
{
|
||||
if (stack->pos == -1)
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "../kernel.h"
|
||||
#include "ktypes.h"
|
||||
#include "malloc.h"
|
||||
#include "ecall.h"
|
||||
#include "io.h"
|
||||
|
@ -95,8 +95,8 @@ struct process_control_block* scheduler_select_free()
|
||||
if (pcb->waiting_for_process != NULL &&
|
||||
pcb->waiting_for_process->status == PROC_DEAD) {
|
||||
// the requested process exited, so we can set the status code and
|
||||
pcb->regs[REG_A0] = pcb->waiting_for_process->exit_code;
|
||||
pcb->regs[REG_A0 + 1] = 0;
|
||||
pcb->regs[REG_A0] = 0;
|
||||
pcb->regs[REG_A0 + 1] = pcb->waiting_for_process->exit_code;
|
||||
pcb->status = PROC_RDY;
|
||||
return pcb;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user