CbCからアセンブラを呼ぶ

CbCからアセンブラを呼ぶ

  • アセンブラで書かれているルーチンを__codeexternする
    • そこにgotoするだけ
1
2
3
4
5
extern __code swtch(struct context **old, struct context *new);

 __ncode cbc_trap_return(){
    goto swtch(&proc->context, cpu->scheduler);
 }

# xv6

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
typedef struct Syscall<Type, Impl> {
    __code syscall();
}



__code dispatch() {
    struct Context* kernel = kernel_context;
    struct proc* proc1 = Gearef(kernel_context, proc)->now;
    int num  = Gearef(proc1, trapframe)->zero;
    goto kernel->syscall[num](proc1);
}



__code cbc_read_stub(struc Context* cbc_context) {
    struct Read* read = Gearef(cbc_context, read)->read;
    struct Cotnext* kernel = cbc_context->kernel_context;


    if(argfd(0, 0, &read->f) < 0 || argint(2, &read->n) < 0 || argptr(1, &read->p, read->n) < 0) {
        goto kernel->err_ret();
    }

    goto fileread(cbc_context, kernel,  f, n, p, kernel->ret);
}




__code fileread(struct file* f, int n, char*p, __code next(...)) {

}


__code fileread(Context* cbc_context, Context* kernel, struct file* f, int n, char* p, enum Code next) {

}
Licensed under CC BY-NC-SA 4.0
comments powered by Disqus
Built with Hugo
Theme Stack designed by Jimmy