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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
diff -r 40b1b7476e77 src/impl/vm_impl.cbc
--- a/src/impl/vm_impl.cbc Tue Jan 28 17:14:44 2020 +0900
+++ b/src/impl/vm_impl.cbc Sat Feb 01 14:28:28 2020 +0900
@@ -35,7 +35,7 @@
vm_impl->copyout_loopvm_impl = C_copyout_loopvm_impl;
vm_impl->switchuvm_check_pgdirvm_impl = C_switchuvm_check_pgdirvm_impl;
vm_impl->init_inituvm_check_sz = C_init_inituvm_check_sz;
- vm->void_ret = C_vm_void_ret;
+ vm->void_ret = C_void_retvm_impl;
vm->init_vmm = C_init_vmmvm_impl;
vm->kpt_freerange = C_kpt_freerangevm_impl;
vm->kpt_alloc = C_kpt_allocvm_impl;
@@ -149,6 +149,15 @@
goto paging_intvmvm_impl(vm, phy_low, phy_hi, next(...));
}
-__code vm_void_ret(struct vm_impl* vm) {
- return;
+
+__code void_retvm_impl(struct Context* cbc_context, struct vm_impl* vm, void (*return_func)(int, void*), int ret_val, void* cbc_env) {
+ goto return_func(ret_val, cbc_env);
}
+
+__code void_retvm_impl_stub(struct Context* cbc_context) {
+ vm_impl* vm = (vm_impl*)GearImpl(cbc_context, vm, vm);
+ void (*return_func)(int, void*);
+ return_func = Gearef(cbc_context, vm)->return_func;
+ void* cbc_env = Gearef(cbc_context, vm)->cbc_env;
+ goto void_retvm_impl(cbc_context, vm, return_func, cbc_env);
+}
diff -r 40b1b7476e77 src/interface/vm.h
--- a/src/interface/vm.h Tue Jan 28 17:14:44 2020 +0900
+++ b/src/interface/vm.h Sat Feb 01 14:28:28 2020 +0900
@@ -17,6 +17,8 @@
uint len;
uint phy_low;
uint phy_hi;
+ void* cbc_env;
+ void (*return_func)(int, void*);
__code init_vmm(Impl* vm, __code next(...));
__code kpt_freerange(Impl* vm, uint low, uint hi, __code next(...));
__code kpt_alloc(Impl* vm ,__code next(...));
@@ -29,6 +31,6 @@
__code uva2ka(Impl* vm, pde_t* pgdir, char* uva, __code next(...));
__code copyout(Impl* vm, pde_t* pgdir, uint va, void* pp, uint len, __code next(...));
__code paging_int(Impl* vm, uint phy_low, uint phy_hi, __code next(...));
- __code void_ret(Impl* vm);
+ __code void_ret(Impl* vm, void (*return_func)(int, void*), int ret_val, void* cbc_env);
__code next(...);
} vm;
diff -r 40b1b7476e77 src/proc.cbc
--- a/src/proc.cbc Tue Jan 28 17:14:44 2020 +0900
+++ b/src/proc.cbc Sat Feb 01 14:28:28 2020 +0900
@@ -117,16 +117,20 @@
//PAGEBREAK: 32
// hand-craft the first user process. We link initcode.S into the kernel
// as a binary, the linker will generate __binary_initcode_start/_size
-void dummy(struct proc *p, char _binary_initcode_start[], char _binary_initcode_size[])
+int dummy(struct proc *p, char _binary_initcode_start[], char _binary_initcode_size[])
{
// inituvm(p->pgdir, _binary_initcode_start, (int)_binary_initcode_size);
- goto cbc_init_vmm_dummy(&p->cbc_context, p, p->pgdir, _binary_initcode_start, (int)_binary_initcode_size);
+ void (*ret)(int, void*);
+ void *env;
+ ret = _CbC_return;
+ env = _CbC_environment;
+ goto cbc_init_vmm_dummy(&p->cbc_context, p, p->pgdir, _binary_initcode_start, (int)_binary_initcode_size, ret, env);
}
-__ncode cbc_init_vmm_dummy(struct Context* cbc_context, struct proc* p, pde_t* pgdir, char* init, uint sz){//:skip
+__ncode cbc_init_vmm_dummy(struct Context* cbc_context, struct proc* p, pde_t* pgdir, char* init, uint sz, void (*ret)(int, void*), void* env){//:skip
struct vm* vm = createvm_impl(cbc_context);
// goto vm->init_vmm(vm, pgdir, init, sz , vm->void_ret);
@@ -134,7 +138,9 @@
Gearef(cbc_context, vm)->pgdir = pgdir;
Gearef(cbc_context, vm)->init = init;
Gearef(cbc_context, vm)->sz = sz ;
- Gearef(cbc_context, vm)->next = C_vm_void_ret ;
+ Gearef(cbc_context, vm)->cbc_env = env;
+ Gearef(cbc_context, vm)->return_func = ret;
+ Gearef(cbc_context, vm)->next = C_void_retvm_impl;
goto meta(cbc_context, vm->init_inituvm);
}
@@ -152,6 +158,8 @@
panic("userinit: out of memory?");
}
+ void (*ret)(int, void*);
+ void *env;
dummy(p, _binary_initcode_start, _binary_initcode_size);
p->sz = PTE_SZ;
|