public static int Read(int helper_pid, int fd, Pointer buf, int count, ref uint pos) { SetMR(0, (int)Type.EXPRESSOS_OP_VFS_READ); SetMR(1, helper_pid); SetMR(2, fd); SetMR(3, count); SetMR(4, pos); var tag = new Msgtag((int)IPCTag.EXPRESSOS_IPC, 5, 0, 0); var res = l4_stub_ipc_call(ArchGlobals.LinuxServerTid, tag, Timeout.Never); if (l4_stub_ipc_error(res) != 0) { return(-1); } var readBytes = GetMR(1); var new_pos = GetMR(2); if (readBytes > ArchGlobals.LinuxIPCBuffer.Length) { return(-1); } var src = ArchGlobals.LinuxIPCBuffer.Slice(0, readBytes); var b = new ByteBufferRef(buf.ToIntPtr(), count); b.CopyFrom(0, src); pos = (uint)new_pos; return(readBytes); }
public OpenFileCompletion(Thread current, GenericINode.INodeKind fileKind, ByteBufferRef buf, int flags, int mode) : base(current, Kind.OpenFileCompletionKind, buf) { this.fileKind = fileKind; this.flags = flags; this.mode = mode; }
public IOCompletion(Thread current, Type type, UserPtr userBuf, int len, File file, ByteBufferRef buf) : base(current, Kind.IOCompletionKind, buf) { this.type = type; this.userBuf = userBuf; this.len = len; this.posToUpdate = file; }
internal int WriteImpl(Thread current, ByteBufferRef buf, int len, ref uint pos) { for (var i = 0; i < len; ++i) Arch.Console.Write((char)buf[i]); Arch.Console.Flush(); return len; }
internal int WriteImpl(Thread current, ByteBufferRef buf, int len, ref uint pos) { for (var i = 0; i < len; ++i) { Arch.Console.Write((char)buf[i]); } Arch.Console.Flush(); return(len); }
public int ReadImpl(ByteBufferRef buffer, int offset, int count, ref uint pos) { var max_length = buffer.Length - offset > count ? count : buffer.Length - offset; if (max_length < 0) { pos = 0; return -ErrorCode.EINVAL; } int ret = IPCStubs.Read(helperPid, fd, new Pointer(buffer.Location + offset), count, ref pos); return ret; }
public static void Initialize(ref BootParam param) { LinuxMainMemoryStart = param.LinuxMainMemoryStart; LinuxMainMemorySize = param.LinuxMainMemorySize; LinuxIPCBuffer = new ByteBufferRef(param.SyncIPCBufferBase.ToIntPtr(), param.SyncIPCBufferSize); if (param.SyncIPCBufferSize < MinimumIPCBufferSize) { ArchDefinition.Panic(); } LinuxServerTid = param.LinuxServerTid; }
public int ReadImpl(ByteBufferRef buffer, int offset, int count, ref uint pos) { var max_length = buffer.Length - offset > count ? count : buffer.Length - offset; if (max_length < 0) { pos = 0; return(-ErrorCode.EINVAL); } int ret = IPCStubs.Read(helperPid, fd, new Pointer(buffer.Location + offset), count, ref pos); return(ret); }
internal int ArchWrite(Thread current, ref ExceptionRegisters regs, ref ByteBufferRef buf, int len, uint pos, File file) { if (!Globals.CompletionQueueAllocator.Contains(buf)) { Arch.Console.WriteLine("inode-write: unimplemented"); Arch.ArchDefinition.Panic(); } var iocp = IOCompletion.CreateWriteIOCP(current, file, buf); var r = IPCStubs.WriteAsync(current.Parent.helperPid, current.impl._value.thread._value, new Pointer(buf.Location), fd, len, pos); if (r < 0) { iocp.Dispose(); return(r); } Globals.CompletionQueue.Enqueue(iocp); current.SaveState(ref regs); current.AsyncReturn = true; // Take the buffer buf = ByteBufferRef.Empty; return(0); }
public BridgeCompletion(Thread current, ByteBufferRef buf) : base(current, Kind.BridgeCompletionKind, buf) { }
internal BinderCompletion(Thread current, UserPtr userBwrBuf, sys_binder_write_desc desc, ByteBufferRef buf) : base(current, Kind.BinderCompletionKind, buf) { this.userBwrBuf = userBwrBuf; this.desc = desc; }
internal static IOCompletion CreateWriteIOCP(Thread current, File file, ByteBufferRef buf) { return(new IOCompletion(current, Type.Write, UserPtr.Zero, 0, file, buf)); }
internal static IOCompletion CreateReadIOCP(Thread current, UserPtr userBuf, int len, File file, ByteBufferRef buf) { return(new IOCompletion(current, Type.Read, userBuf, len, file, buf)); }
public static int Read(int helper_pid, int fd, Pointer buf, int count, ref uint pos) { SetMR(0, (int)Type.EXPRESSOS_OP_VFS_READ); SetMR(1, helper_pid); SetMR(2, fd); SetMR(3, count); SetMR(4, pos); var tag = new Msgtag((int)IPCTag.EXPRESSOS_IPC, 5, 0, 0); var res = l4_stub_ipc_call(ArchGlobals.LinuxServerTid, tag, Timeout.Never); if (l4_stub_ipc_error(res) != 0) return -1; var readBytes = GetMR(1); var new_pos = GetMR(2); if (readBytes > ArchGlobals.LinuxIPCBuffer.Length) return -1; var src = ArchGlobals.LinuxIPCBuffer.Slice(0, readBytes); var b = new ByteBufferRef(buf.ToIntPtr(), count); b.CopyFrom(0, src); pos = (uint)new_pos; return readBytes; }
internal static IOCompletion CreateWriteIOCP(Thread current, File file, ByteBufferRef buf) { return new IOCompletion(current, Type.Write, UserPtr.Zero, 0, file, buf); }
internal static IOCompletion CreateReadIOCP(Thread current, UserPtr userBuf, int len, File file, ByteBufferRef buf) { return new IOCompletion(current, Type.Read, userBuf, len, file, buf); }
public int Read(ByteBufferRef buffer, int offset, int count, ref uint pos) { switch (kind) { case INodeKind.ArchINodeKind: return ArchINode.ReadImpl(buffer, offset, count, ref pos); } return -ErrorCode.EINVAL; }
/* * Write a segment buffer. * * The buffer itself is passed as a reference, because some inode might take the ownership * of the buffer and put it as a part of its completion. In this case the buf is set to empty */ internal int Write(Thread current, ref Arch.ExceptionRegisters regs, ref ByteBufferRef buf, int len, uint pos, File file) { switch (kind) { case INodeKind.ConsoleINodeKind: { uint dummy = 0; return ConsoleINode.WriteImpl(current, buf, len, ref dummy); } case INodeKind.ArchINodeKind: case INodeKind.SocketINodeKind: return ArchINode.ArchWrite(current, ref regs, ref buf, len, pos, file); case INodeKind.SecureFSINodeKind: return SFSINode.SFSWrite(current, ref regs, buf, len, pos, file); } return -ErrorCode.EINVAL; }
internal int ArchWrite(Thread current, ref ExceptionRegisters regs, ref ByteBufferRef buf, int len, uint pos, File file) { if (!Globals.CompletionQueueAllocator.Contains(buf)) { Arch.Console.WriteLine("inode-write: unimplemented"); Arch.ArchDefinition.Panic(); } var iocp = IOCompletion.CreateWriteIOCP(current, file, buf); var r = IPCStubs.WriteAsync(current.Parent.helperPid, current.impl._value.thread._value, new Pointer(buf.Location), fd, len, pos); if (r < 0) { iocp.Dispose(); return r; } Globals.CompletionQueue.Enqueue(iocp); current.SaveState(ref regs); current.AsyncReturn = true; // Take the buffer buf = ByteBufferRef.Empty; return 0; }