コード例 #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.c プロジェクト: tymicruz/CuatroSeisZero
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 プロジェクト: 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);

}