aboutsummaryrefslogtreecommitdiff
path: root/pu2/code/kernel.i2
diff options
context:
space:
mode:
authorGravatar Moon Flower <moon@coffin.ir> 2025-08-25 16:53:34 +0330
committerGravatar Moon Flower <moon@coffin.ir> 2025-08-25 16:53:34 +0330
commit8f73e9736317bd5d7951757357075504ea402d27 (patch)
treeb89acf08a72ab2d0195d033ce600134c78de663e /pu2/code/kernel.i2
parentfixed stack overflow bug (diff)
cool stuff, right? multi-process support with permission levels
Diffstat (limited to 'pu2/code/kernel.i2')
-rw-r--r--pu2/code/kernel.i246
1 files changed, 46 insertions, 0 deletions
diff --git a/pu2/code/kernel.i2 b/pu2/code/kernel.i2
new file mode 100644
index 0000000..2da075c
--- /dev/null
+++ b/pu2/code/kernel.i2
@@ -0,0 +1,46 @@
+import lib.i2;
+
+// test - write memory, spawn process, read memory
+
+macro spawn_sudo(3) {
+ @1 = 3; // authorized feature
+ @2 = 0; // spawn process
+
+ @10 = 1; // target ring = 1
+ @11 = /1/; // memory start
+ @12 = /2/; // memory length
+ @13 = 1; // can spawn procs
+ @14 = 1; // can make syscalls
+ @15 = /3/; // time slice limit
+
+ system(); // interrupt
+}
+
+macro read_pmem(4) {
+ @1 = 3; // authorized feature
+ @2 = 2; // read memory
+ @10 = /1/; // target pid
+ @11 = /2/; // address
+ @12 = /3/; // length
+ @13 = /4/; // target
+
+ system(); // interrupt
+}
+
+/* write the actual program */
+@1007 = 10;
+@1010 = 1; @1011 = 3; // a = 3;
+@1012 = 17; @1013 = 9; // m[3] = 9;
+@1014 = 0; @1015 = 0; // halt
+spawn_sudo([1000], [16], [5]);
+
+let output = @2;
+let pid = @3;
+let exit_code = @4;
+let finished = @5;
+
+let read_out = 0;
+read_pmem([pid], [3], [1], [&read_out]);
+
+read_out += '0';
+putchar([read_out]); \ No newline at end of file