Exemplo n.º 1
0
Arquivo: int.c Projeto: 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);
}
Exemplo n.º 2
0
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);

   switch(a){
       case 0 : r = running->pid;     break;
       case 1 : r = do_ps();          break;
       case 2 : r = chname(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;

       case 9 : r = vfork();          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: color=running->pid+11;
                r =  putc(b);         break;       
       case 99: do_exit(b);           break;
       default: printf("invalid syscall # : %d\n", a); 
   }
   put_word(r, segment, offset + 2*AX);
}
Exemplo n.º 3
0
Arquivo: int.c Projeto: 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;

}