Skip to content
Snippets Groups Projects
syscall-handler.c 1.09 KiB
Newer Older
#include <syscall-handler.h>
#include <context-switch.h>
#include <priority-q.h>
#include <scheduler.h>
#include <bwio.h>
void handlerCreate(KernelStruct* Colonel) {
  return;
antnh6@gmail.com's avatar
antnh6@gmail.com committed
}

void Handle(KernelStruct* Colonel, int n) {
  register int Args asm("r1");
  register int * TaskSP asm("r2");
  Colonel->Active->sp = TaskSP;
  
  switch(n) {
  case SYS_Create:
    handlerCreate(Colonel); 
    break;
  case SYS_MyTid:
    (Colonel->Active)->RetVal = (Colonel->Active)->TaskID;
    pushToScheduler(Colonel,Colonel->Active);
    Colonel->Active = NULL;
    break;
  case SYS_ParentTid:
    (Colonel->Active)->RetVal = (Colonel->Active)->ParentID;
    pushToScheduler(Colonel,Colonel->Active);
    Colonel->Active = NULL;
    break;
  case SYS_Pass:
    pushToScheduler(Colonel,Colonel->Active);
    Colonel->Active = NULL;
    break;
  case SYS_Exit:
    (Colonel->Active)->TaskState = Zombie;
    break;
  }
int Activate(KernelStruct *Colonel,TD* Task, int RetVal) {
  Colonel->Active = Task;
  kerxit(Task->sp, RetVal);
  register int r0 asm("r0");
  bwprintf(COM2,"Back to activate, r=%d\n\r",r0);
  return r0;