Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienux/blob/main/native/kernel/tests/fixtures/osc_unit/launch/l01.S # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienux / native / kernel / tests / fixtures / osc_unit / launch / l01.S` 143 lines ยท 3817 bytes Raw Blame History 1 // l01.S: hand-assembled TEST functions for the C3-3a task-launch gate. 2 // Every word is in the OSC-emitted subset (spec 8.4); admission re-checks it. 3 // x7 = OscRt *, x30 = the runtime return stub, args in x0..x5. 4 .text 5 .global _start 6 _start: 7 // fn 0 trap(code: u64) -> u64 : the real trap sequence (osc_cg.c trap_seq), code in x0 8 trap: 9 mov x1, x0 10 mov x0, x7 11 ldr x16, [x0, #16] 12 blr x16 13 brk #1 14 // fn 1 spin() -> u64 : never finishes (budget test) 15 spin: 16 b spin 17 // fn 2 peek0() -> u64 : read address 0 (unmapped): a CPU fault 18 peek0: 19 movz x0, #0 20 ldr x0, [x0] 21 ret 22 // fn 3 poke_rt() -> u64 : write the OscRt table (read-only to the unit): a CPU fault 23 poke_rt: 24 str x0, [x7] 25 ret 26 // fn 4 bare_brk() -> u64 : reaches a brk guard directly (spec 8.4: a fault, never TRAPPED) 27 bare_brk: 28 brk #3 29 // fn 5 exec_stack() -> u64 : write a `ret` into the stack and call it. W^X: must fault. 30 exec_stack: 31 sub sp, sp, #16 32 movz x1, #0x03c0 33 movk x1, #0xd65f, lsl #16 34 str x1, [sp] 35 add x0, sp, #0 36 blr x0 37 movz x0, #42 38 add sp, sp, #16 39 ret 40 // fn 6 overflow() -> u64 : grow the stack until it leaves the mapped stack 41 overflow: 42 sub sp, sp, #16 43 str x0, [sp] 44 b overflow 45 // fn 7 counter(ws: cells, n: u64) -> u64 : ws[0] += 1, return it (workspace persistence) 46 counter: 47 ldr x2, [x0] 48 add x2, x2, #1 49 str x2, [x0] 50 orr x0, xzr, x2 51 ret 52 // fn 8 peek_kernel(addr: u64) -> u64 : read a kernel virtual address (mapped EL1-only): a CPU fault 53 peek_kernel: 54 ldr x0, [x0] 55 ret 56 // fn 9 jump_ws(ws: cells, n: u64) -> u64 : call the code at x0 (the caller pre-loads a valid `ret` there); returns 42 57 // if that works, so only an execute-never workspace page makes this fault 58 jump_ws: 59 sub sp, sp, #16 60 str x30, [sp] 61 blr x0 62 ldr x30, [sp] 63 add sp, sp, #16 64 movz x0, #42 65 ret 66 // fn 10 jump_in(in: bytes, n: u64) -> u64 : same, into the input window (caller supplies the `ret` bytes) 67 jump_in: 68 sub sp, sp, #16 69 str x30, [sp] 70 blr x0 71 ldr x30, [sp] 72 add sp, sp, #16 73 movz x0, #42 74 ret 75 // fn 11 dirty() -> u64 : leave a nonzero value in x1..x29 (for the register-clearing check) 76 dirty: 77 movz x1, #0x1111 78 movz x2, #0x2222 79 movz x3, #0x3333 80 movz x4, #0x4444 81 movz x5, #0x5555 82 movz x6, #0x6666 83 movz x8, #0x8888 84 movz x9, #0x9999 85 movz x10, #0xaaaa 86 movz x11, #0xbbbb 87 movz x12, #0xcccc 88 movz x13, #0xdddd 89 movz x14, #0xeeee 90 movz x15, #0xffff 91 movz x16, #0x1616 92 movz x17, #0x1717 93 movz x18, #0x1818 94 movz x19, #0x1919 95 movz x20, #0x2020 96 movz x21, #0x2121 97 movz x22, #0x2222 98 movz x23, #0x2323 99 movz x24, #0x2424 100 movz x25, #0x2525 101 movz x26, #0x2626 102 movz x27, #0x2727 103 movz x28, #0x2828 104 movz x29, #0x2929 105 movz x0, #1 106 ret 107 // fn 12 regs_or() -> u64 : OR of x0..x29 as seen at entry, except x7 (the OscRt pointer, set by contract). 108 // Zero means every other register was cleared by the launcher. 109 regs_or: 110 orr x0, x0, x1 111 orr x0, x0, x2 112 orr x0, x0, x3 113 orr x0, x0, x4 114 orr x0, x0, x5 115 orr x0, x0, x6 116 orr x0, x0, x8 117 orr x0, x0, x9 118 orr x0, x0, x10 119 orr x0, x0, x11 120 orr x0, x0, x12 121 orr x0, x0, x13 122 orr x0, x0, x14 123 orr x0, x0, x15 124 orr x0, x0, x16 125 orr x0, x0, x17 126 orr x0, x0, x18 127 orr x0, x0, x19 128 orr x0, x0, x20 129 orr x0, x0, x21 130 orr x0, x0, x22 131 orr x0, x0, x23 132 orr x0, x0, x24 133 orr x0, x0, x25 134 orr x0, x0, x26 135 orr x0, x0, x27 136 orr x0, x0, x28 137 orr x0, x0, x29 138 ret 139 // fn 13 touch_past(ws: cells, n: u64) -> u64 : read the 8 bytes just after x0's cell. With x0 the last cell of 140 // the workspace this is the first byte past it (unmapped): a CPU fault. 141 touch_past: 142 ldr x0, [x0, #8] 143 ret