我需要你的帮助,我想改变xinu(os)的工作方式,所以它将接管中断128并控制SYS_CALL,例如,而不是调用send(pid,msg)我将调用sys_call(发送,pid,msg);. 在initiali.c我添加了
mapinit(INT80VEC,active80,INT80VEC);
在标题中,我做了
#ifndef hw4
#define hw4 256 //prevent rerun of the header file
#define INT80VEC 0x80
extern enum cmd{CHPRIO, GETPID, GETPRIO, KILL, RECEIVE,
RECVCLR, RESUME, SCOUNT, SCREATE, SDELETE,
SEND, SENDF, SENDN, SIGNAL, SIGNALN, SLEEP,
SLEEPT, SRESET, SUSPEND, WAIT, PCOUNT, PCREATE,last};
//last is just to find out how many arguments we have in the enum expression
extern SYSCALL sys_call(int sys_call_no, int parm1, int parm2);
extern int active80();
#endif
我得到的c文件:
#include <kernel.h>
#include <conf.h>
#include "my.h"
SYSCALL sys_call(int sys_call_no, int parm1, int parm2){
int ps;
int temp;
disable(ps);
if(sys_call_no<0 ||sys_call_no>=last){
restore(ps);
return SYSERR;
}
asm{ mov ax,sys_call_no
mov bx,parm1
mov cx,parm2
int 80h
mov temp,ax
}
restore(ps);
return temp;
}
INTPROC active80(){
int sys_call_no, parm1,parm2;
asm{ mov sys_call_no,ax
mov parm1,bx
mov parm2,cx
}
switch (sys_call_no) {
case CHPRIO:
chprio(parm1,parm2);
break;
case GETPID:
getpid();
break;
case GETPRIO:
getprio(parm1);
break;
case KILL:
kill(parm1);
break;
case RECEIVE:
receive();
break;
case RECVCLR:
recvclr();
break;
case RESUME:
resume(parm1);
break;
case SCOUNT:
scount(parm1);
break;
case SCREATE:
screate(parm1);
break;
case SDELETE:
sdelete(parm1);
break;
case SEND:
send(parm1, parm2);
break;
case SENDF:
sendf(parm1, parm2);
break;
case SENDN:
sendn(parm1, parm2);
break;
case SIGNAL:
signal(parm1);
break;
case SIGNALN:
signaln(parm1,parm2);
break;
case SLEEP:
sleep(parm1);
break;
case SLEEPT:
sleept(parm1);
break;
case SRESET:
sreset(parm1,parm2);
break;
case SUSPEND:
suspend(parm1);
break;
case WAIT:
wait(parm1);
break;
case PCOUNT:
pcount(parm1);
break;
case PCREATE:
pcreate(parm1);
break;
}
return OK;
}
某事不起作用......任何想法?
谢谢你!
答案 0 :(得分:0)
答案 1 :(得分:0)
您必须使用maprestore
功能恢复旧的isr。