| author | |
| committer | |
| log | 43cdfa275ad75097d80abf1c4091f0b506fcb1e3 |
| tree | dfe3f352e9ea5b9ff6ab45ff16f4f8c365d498ea |
| parent | 0082ed0ef1415d9c972348aae136b5684838c983 |
3 files changed, 34 insertions(+), 10 deletions(-)
std/os/index.zig+8| ... | ... | @@ -115,6 +115,14 @@ pub fn getRandomBytes(buf: []u8) !void { |
| 115 | 115 | }; |
| 116 | 116 | } |
| 117 | 117 | }, |
| 118 | Os.zen => { | |
| 119 | const randomness = []u8 {42, 1, 7, 12, 22, 17, 99, 16, 26, 87, 41, 45}; | |
| 120 | var i: usize = 0; | |
| 121 | while (i < buf.len) : (i += 1) { | |
| 122 | if (i > randomness.len) return error.Unknown; | |
| 123 | buf[i] = randomness[i]; | |
| 124 | } | |
| 125 | }, | |
| 118 | 126 | else => @compileError("Unsupported OS"), |
| 119 | 127 | } |
| 120 | 128 | } |
std/os/zen.zig+22-8| ... | ... | @@ -107,14 +107,17 @@ pub fn write(fd: i32, buf: &const u8, count: usize) usize { |
| 107 | 107 | /////////////////////////// |
| 108 | 108 | |
| 109 | 109 | pub const Syscall = enum(usize) { |
| 110 | exit = 0, | |
| 111 | createPort = 1, | |
| 112 | send = 2, | |
| 113 | receive = 3, | |
| 114 | subscribeIRQ = 4, | |
| 115 | inb = 5, | |
| 116 | map = 6, | |
| 117 | createThread = 7, | |
| 110 | exit = 0, | |
| 111 | createPort = 1, | |
| 112 | send = 2, | |
| 113 | receive = 3, | |
| 114 | subscribeIRQ = 4, | |
| 115 | inb = 5, | |
| 116 | map = 6, | |
| 117 | createThread = 7, | |
| 118 | createProcess = 8, | |
| 119 | wait = 9, | |
| 120 | portReady = 10, | |
| 118 | 121 | }; |
| 119 | 122 | |
| 120 | 123 | |
| ... | ... | @@ -158,6 +161,17 @@ pub fn createThread(function: fn()void) u16 { |
| 158 | 161 | return u16(syscall1(Syscall.createThread, @ptrToInt(function))); |
| 159 | 162 | } |
| 160 | 163 | |
| 164 | pub fn createProcess(elf_addr: usize) u16 { | |
| 165 | return u16(syscall1(Syscall.createProcess, elf_addr)); | |
| 166 | } | |
| 167 | ||
| 168 | pub fn wait(tid: u16) void { | |
| 169 | _ = syscall1(Syscall.wait, tid); | |
| 170 | } | |
| 171 | ||
| 172 | pub fn portReady(port: u16) bool { | |
| 173 | return syscall1(Syscall.portReady, port) != 0; | |
| 174 | } | |
| 161 | 175 | |
| 162 | 176 | ///////////////////////// |
| 163 | 177 | //// Syscall stubs //// |
std/special/bootstrap.zig+4-2| ... | ... | @@ -84,8 +84,10 @@ fn callMain() u8 { |
| 84 | 84 | builtin.TypeId.ErrorUnion => { |
| 85 | 85 | root.main() catch |err| { |
| 86 | 86 | std.debug.warn("error: {}\n", @errorName(err)); |
| 87 | if (@errorReturnTrace()) |trace| { | |
| 88 | std.debug.dumpStackTrace(trace); | |
| 87 | if (builtin.os != builtin.Os.zen) { | |
| 88 | if (@errorReturnTrace()) |trace| { | |
| 89 | std.debug.dumpStackTrace(trace); | |
| 90 | } | |
| 89 | 91 | } |
| 90 | 92 | return 1; |
| 91 | 93 | }; |