예제 #1
0
파일: int.c 프로젝트: vonderborch/CS460
/****************** syscall handler in C ***************************/
int kcinth()
{
   	int a,b,c,d, r;
//==> WRITE CODE TO GET get syscall parameters a,b,c,d from ustack 
    a = get_word(running->uss, running->usp + 18); // was 26
    b = get_word(running->uss, running->usp + 20); // was 28
    c = get_word(running->uss, running->usp + 22); // was 30
    d = get_word(running->uss, running->usp + 24); // was 32
	
   switch(a)
   {
       case 0 : r = kgetpid();        break;
       case 1 : r = kpd();            break;
       case 2 : r = kchname(b);       break;
       case 3 : r = kkfork();         break;
       case 4 : r = ktswitch();       break;
       case 5 : r = kkwait(b);        break;
       case 6 : r = kkexit(b);        break;
       
       case 12: r = getMyname(b);     break;
       case 20: r = hop(b);           break;

       case 90: r = getc();           break;
       case 91: r = putc(b);          break;
       case 99: kkexit(b);            break;
       default: printf("invalid syscall # : %d\n", a); 
   }

//==> WRITE CODE to let r be the return value to Umode
    put_word(r, running->uss, running->usp + 8); // was 16
    return r;
}
예제 #2
0
int kcinth()
{
   u16    segment, offset;
   int    a,b,c,d, r;
   segment = running->uss; 
   offset = running->usp;

//==> WRITE CODE TO GET get syscall parameters a,b,c,d from ustack 

   a = get_word(segment, offset + 2*PA);
   b = get_word(segment, offset + 2*PB);
   c = get_word(segment, offset + 2*PC);
   d = get_word(segment, offset + 2*PD);

   

   switch(a){
       case 0 : printf("hello in kernel a: %d cmd: %s\n", a, cmds[a]);r = kgetpid();        break;
       case 1 : printf("hello in kernel a: %d cmd: %s\n", a, cmds[a]);r = kps();            break;
       case 2 : printf("hello in kernel a: %d cmd: %s\n", a, cmds[a]);r = kchname(b);       break;
       case 3 : printf("hello in kernel a: %d cmd: %s\n", a, cmds[a]);r = kkfork();         break;
       case 4 : printf("hello in kernel a: %d cmd: %s\n", a, cmds[a]);r = ktswitch();       break;
       case 5 : printf("hello in kernel a: %d cmd: %s\n", a, cmds[a]);r = kkwait(b);        break;
       case 6 : printf("hello in kernel a: %d cmd: %s\n", a, cmds[a]);r = kkexit(b);        break;
       case 7 : printf("hello in kernel a: %d cmd: %s\n", a, cmds[a]);r = kexec(b);        break;

       case 99: kkexit(b);            break;
       default: printf("invalid syscall # : %d\n", a); 
   }

   put_word(r, segment, offset + 2*AX);
   return r;//this will be overwritten by the pop ax register when restoring back to uMode
}
예제 #3
0
파일: int.c 프로젝트: Cj-muse/Lab6
int kcinth()
{
   u16    segment, offset;
   int    a,b,c,d, r;

   segment = running->uss;
   offset = running->usp;

   a = get_word(segment, offset + 2*PA);
   b = get_word(segment, offset + 2*PB);
   c = get_word(segment, offset + 2*PC);
   d = get_word(segment, offset + 2*PD);
		
 	/*printf("interupthandler a = %d\n", a);
	printf("b = %d\n",     b);
	printf("string: %s\n", c);
	printf("n = %d\n",     d);*/
   switch(a){
       case 0 : r = running->pid;     break;
       case 1 : r = do_ps();          break;
       case 2 : r = kchname(b);        break;
       case 3 : r = kmode();          break;
       case 4 : r = tswitch();        break;
       case 5 : r = do_wait(b);       break;
       case 6 : r = do_exit(b);       break;
       case 7 : r = fork();           break;
       case 8 : r = exec(b);          break;

   /****** these are YOUR pipe functions ************/
   case 30 : r = kpipe(b); break;
   case 31 : r = read_pipe(b,c,d);  break;
   case 32 : r = write_pipe(b,c,d); break;
   case 33 : r = close_pipe(b);     break;
   case 34 : r = pfd();             break;
  /**************** end of pipe functions ***********/

       case 90: r =  getc();          break;
       case 91: color=running->pid+11;
                r =  putc(b);         break;
       case 99: do_exit(b);           break;
       default: printf("invalid syscall # : %d\n", a);
   }
   //printf("interupthandler r = %d\n", r);
   //getc();
   put_word(r, segment, offset + 2*AX);
}
예제 #4
0
파일: int.c 프로젝트: kurutoga/mtx_system
int kcinth() {
    
    u16 segment, offset;
    int a,b,c,d,r;

    segment = running->uss;
    offset  = running->usp;

    a = get_word(segment, offset + 2*PA);
    b = get_word(segment, offset + 2*(PA+1));
    c = get_word(segment, offset + 2*(PA+2));
    d = get_word(segment, offset + 2*(PA+3));

    switch(a) {

        case 0:
            r = getpid();
            break;
        case 1:
            r = kps();
            break;
        case 2:
            k = kchname();
            break;
        case 3:
            r = kkfork();
            break;
        case 4:
            r = kswitch();
            break;
        case 5:
            r = kwait(b);
            break;
        case 6:
            kexit();
            break;
        default:
            printf("invalid syscall %d\n", a);
    }

    put_word(r, segment, offset + 2*AX);

}
예제 #5
0
파일: int.c 프로젝트: konorati/cs460
/****************** syscall handler in C ***************************/
int kcinth()
{
   int a,b,c,d, r;

    //WRITE CODE TO GET get syscall parameters a,b,c,d from ustack 
    a = get_word(running->uss, running->usp + 26);
    b = get_word(running->uss, running->usp + 28);
    c = get_word(running->uss, running->usp + 30);
    d = get_word(running->uss, running->usp + 32);

   switch(a){
       case 0 : r = kgetpid();        break;
       case 1 : r = kps();            break;
       case 2 : r = kchname(b);       break;
       case 3 : r = kmode();         break;
       case 4 : r = tswitch();       break;
       case 5 : r = kkwait(b);        break;
       case 6 : r = kkexit(b);        break;
       case 7 : r = fork();           break;
       case 8 : r = kexec(b);         break;

       case 30: r = kpipe(b);         break;
       case 31: r = read_pipe(b,c,d); break;
       case 32: r = write_pipe(b,c,d);break;
       case 33: r = close_pipe(b);    break;
       case 34: r = pfd();            break;

       case 90: r = getc();           break;
       case 91: r = putc(b);          break;
       case 99: kkexit(b);            break;
       default: printf("invalid syscall # : %d\n", a); 
   }

    //WRITE CODE to let r be the return value to Umode
    put_word(r, running->uss, running->usp + 16);
    return r;

}