private void Init() { tysos.Syscalls.DebugFunctions.DebugWrite("Console: acquiring Gui process\n"); gui = Gui.Gui.GetGUIProcess(); tysos.Syscalls.DebugFunctions.DebugWrite("Console: creating a window\n"); window = Gui.Window.CreateWindow(-1, -1, true); tysos.Syscalls.DebugFunctions.DebugWrite("Console: creating a backbuffer\n"); backbuffer = new Gui.Buffer(window.Graphics.Width, BUFFER_HEIGHT, window.Graphics.PixelFormat); tysos.Syscalls.DebugFunctions.DebugWrite("Console: starting shell\n"); tysos.Process shell_p = tysos.Syscalls.ProcessFunctions.ExecModule("shell", false); //shell_p.stderr = this; //shell_p.stdout = this; //shell_p.stdin = this; shell_p.startup_thread.do_profile = true; tysos.Syscalls.ProcessFunctions.StartProcess(shell_p); tysos.Syscalls.DebugFunctions.DebugWrite("Console: entering message loop\n"); tysos.Syscalls.IPCFunctions.InitIPC(); current_process = tysos.Syscalls.ProcessFunctions.GetCurrentProcess(); Initialized.Set(); bool cont = true; while (cont) { tysos.IPCMessage msg = null; do { msg = tysos.Syscalls.IPCFunctions.ReadMessage(); if (msg != null) { handle_message(msg); } } while (msg != null); tysos.Syscalls.SchedulerFunctions.Block(); } }
static void Main(string[] args) { /* Wait for the gui to start up */ tysos.Syscalls.DebugFunctions.DebugWrite("Vga: awaiting gui startup\n"); tysos.ProcessEvent e = new tysos.ProcessEvent(); e.ProcessEventType = tysos.ProcessEvent.ProcessEventTypeKind.ReadyForMessages; e.ProcessName = "gui"; tysos.Syscalls.SchedulerFunctions.Block(e); /* Create our back buffer */ va_vidmem = tysos.Syscalls.MemoryFunctions.MapPhysicalMemory(0xb8000, 0x1000, tysos.Syscalls.MemoryFunctions.CacheType.Uncacheable, true); back_buffer = new Gui.Buffer(80, 25, Gui.Buffer.PixelFormatType.PF_16_8CHAR_8IDX); /* Disable the kernel Vga driver */ tysos.Syscalls.DebugFunctions.DebugWrite("Vga: disabling kernel vga driver\n"); tysos.x86_64.Vga.Enabled = false; /* Move the hardware cursor beyond the end of the screen */ ushort position = 25 * 80; libsupcs.IoOperations.PortOut(0x3d4, (byte)0x0f); libsupcs.IoOperations.PortOut(0x3d5, (byte)(position & 0xff)); libsupcs.IoOperations.PortOut(0x3d4, (byte)0x0e); libsupcs.IoOperations.PortOut(0x3d5, (byte)((position >> 8) & 0xff)); /* Register ourselves with the gui */ tysos.Syscalls.DebugFunctions.DebugWrite("Vga: registering with gui\n"); gui = e.Process; if (gui == null) { throw new Exception("Unable to communicate with gui process"); } //tysos.Syscalls.IPCFunctions.SendMessage(gui, new tysos.IPCMessage { Type = Gui.GuiMessageTypes.REGISTER_OUTPUT, Message = new Gui.GuiMessageTypes.RegisterOutputMessage { buffer = back_buffer } }); /* Listen for shutdown messages */ tysos.Syscalls.DebugFunctions.DebugWrite("Vga: entering message loop\n"); tysos.Syscalls.IPCFunctions.InitIPC(); bool cont = true; while (cont) { tysos.IPCMessage msg = null; do { msg = tysos.Syscalls.IPCFunctions.ReadMessage(); if (msg != null) { switch (msg.Type) { case tysos.IPCMessage.TYPE_CLOSE: cont = false; break; /*case Gui.GuiMessageTypes.UPDATE_OUTPUT: * update_output(); * break;*/ } } if (cont == false) { break; } tysos.Syscalls.SchedulerFunctions.Block(); } while (msg != null); } }