Beispiel #1
0
        /* We define a generic tysos keypress message of type ushort
         * The least significant byte is the key (see below)
         * The most significant byte is the modifiers for the key
         *
         * Modifiers:
         *
         * bit 0 - left ctrl pressed
         * bit 1 - alt pressed
         * bit 2 - alt gr pressed
         * bit 3 - right ctrl pressed
         *
         * keys: (k followed by another character refers to keys on the numeric keypad)
         *
         *       _0   _1   _2   _3   _4   _5   _6   _7   _8   _9   _A   _B   _C   _D   _E   _F
         *
         *  0_   err  esc  1    2    3    4    5    6    7    8    9    0    -    =    bksp tab
         *  1_   q    w    e    r    t    y    u    i    o    p    [    ]    ent       a    s
         *  2_   d    f    g    h    j    k    l    ;    '    `         \    z    x    c    v
         *  3_   b    n    m    ,    .    /         k*        spc       F1   F2   F3   F4   F5
         *  4_   F6   F7   F8   F9   F10            k7   k8   k9   k-   k4   k5   k6   k+   k1
         *  5_   k2   k3   k0   k.                  F11  F12
         *  6_
         *  7_
         *  8_   Q    W    E    R    T    Y    U    I    O    P    {    }
         *  9_   A    S    D    F    G    H    J    K    L    :    "    ¬
         *  A_   Z    X    C    V    B    N    M    <    >    ?
         *  B_   !    @    #    $    %    ^    &    *    (    )    _    +
         *  C_   |
         *  D_
         *  E_
         *  F_
         *
         * To generate a character from a keyboard key press, first the key press is translated from
         * the keyboard hardware scancode to a tysos scancode, then the tysos scancode is used to look
         * up the information on a keymap table
         */

        public static void Main(string[] args)
        {
            /* Wait for the gui to start up */
            tysos.Syscalls.DebugFunctions.DebugWrite("PS2K: awaiting gui startup\n");
            tysos.ProcessEvent e = new tysos.ProcessEvent();
            e.ProcessEventType = tysos.ProcessEvent.ProcessEventTypeKind.ReadyForMessages;
            e.ProcessName      = "gui";
            tysos.Syscalls.SchedulerFunctions.Block(e);

            /* Register ourselves with the gui */
            tysos.Syscalls.DebugFunctions.DebugWrite("PS2K: 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 = GuiMessageTypes.REGISTER_INPUT
            });

            /* Register our callback function */
            tysos.Syscalls.DebugFunctions.DebugWrite("PS2K: registering irq handler\n");
            _imap = tysos.Syscalls.InterruptFunctions.GetInterruptMap();
            //_imap.RegisterIRQHandler("Keyboard", new tysos.Interrupts.ISR(KeyboardHandler));

            /* Listen for shutdown messages */
            tysos.Syscalls.DebugFunctions.DebugWrite("PS2K: 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;
                        }
                    }

                    if (cont == false)
                    {
                        break;
                    }

                    tysos.Syscalls.SchedulerFunctions.Block();
                } while (msg != null);
            }
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            tysos.Process other = tysos.Syscalls.ProcessFunctions.GetProcessByName("TestProcess");
            if (other == null)
            {
                System.Diagnostics.Debugger.Log(0, null, "TestProcess not found\n");
                return;
            }

            tysos.IPCMessage msg = new tysos.IPCMessage {
                Message = "Hello from TestProcess2\n", Type = tysos.IPCMessage.TYPE_STRING
            };

            while (true)
            {
                tysos.Syscalls.IPCFunctions.SendMessage(other, msg);
            }
        }
Beispiel #3
0
        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();
            }
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            /* Add any specific startup code here */


            /* The main message loop */
            while (true)
            {
                tysos.IPCMessage msg = null;
                do
                {
                    msg = tysos.Syscalls.IPCFunctions.ReadMessage();

                    if (msg != null)
                    {
                        HandleMessage(msg);
                    }
                } while (msg != null);

                tysos.Syscalls.SchedulerFunctions.Block();
            }
        }
Beispiel #5
0
        static void Main(string[] args)
        {
            tysos.Syscalls.IPCFunctions.InitIPC();

            while (true)
            {
                tysos.IPCMessage msg = null;
                do
                {
                    msg = tysos.Syscalls.IPCFunctions.ReadMessage();

                    if (msg != null)
                    {
                        if (msg.Type == tysos.IPCMessage.TYPE_STRING)
                        {
                            System.Diagnostics.Debugger.Log(0, null, msg.Message as string);
                        }
                    }
                } while (msg != null);

                tysos.Syscalls.SchedulerFunctions.Block();
            }
        }
Beispiel #6
0
        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);
            }
        }
Beispiel #7
0
        private void handle_message(tysos.IPCMessage msg)
        {
            switch (msg.Type)
            {
            case vfsMessageTypes.READ:
            {
                vfsMessageTypes.ReadWriteMessage rwm = msg.Message as vfsMessageTypes.ReadWriteMessage;
                if (rwm != null)
                {
                    if (read_buffer.Count > 0)
                    {
                        int count_read = 0;
                        while ((read_buffer.Count > 0) && (count_read < rwm.count))
                        {
                            rwm.buf[rwm.buf_offset + count_read] = read_buffer[0];
                            read_buffer.RemoveAt(0);
                            count_read++;
                        }
                        rwm.count_read = count_read;
                        rwm.completed.Set();
                    }
                    else
                    {
                        pending_reads.Add(msg);
                    }
                }
            }
            break;

            case vfsMessageTypes.WRITE:
            {
                vfsMessageTypes.ReadWriteMessage rwm = msg.Message as vfsMessageTypes.ReadWriteMessage;
                if (rwm != null)
                {
                    _Write(rwm.buf, rwm.buf_offset, rwm.count);
                }
            }
            break;

            case vfsMessageTypes.PEEK:
            {
                vfsMessageTypes.ReadWriteMessage rwm = msg.Message as vfsMessageTypes.ReadWriteMessage;
                if (rwm != null)
                {
                    //lock (rwm.completed)
                    {
                        if (read_buffer.Count >= rwm.count)
                        {
                            rwm.count_read = rwm.count;
                            rwm.completed.Set();
                        }
                        else
                        {
                            pending_reads.Add(msg);
                        }
                    }
                }
            }
            break;

            case GuiMessageTypes.KEYPRESS_MESSAGE:
            {
                GuiMessageTypes.KeyPressMessage kpm = msg.Message as GuiMessageTypes.KeyPressMessage;
                if (kpm != null)
                {
                    read_buffer.Add((byte)kpm.key);
                    process_pending_reads();
                }
            }
            break;
            }
        }
Beispiel #8
0
        private void HandleMessage(tysos.IPCMessage msg)
        {
            switch (msg.Type)
            {
                #region VFS messages
            case vfsMessageTypes.GET_ATTRIBUTES:
            {
                vfsMessageTypes.FileAttributesMessage fam = msg.Message as vfsMessageTypes.FileAttributesMessage;
                if (fam != null)
                {
                    // Handle the message
                    //fam.attributes = _GetFileAttributes(ref fam.path);
                    fam.completed.Set();
                }
            }
            break;

            case vfsMessageTypes.GET_FILE_SYSTEM_ENTRIES:
            {
                vfsMessageTypes.FileSystemEntriesMessage fsem = msg.Message as vfsMessageTypes.FileSystemEntriesMessage;
                if (fsem != null)
                {
                    // Handle the message
                    //fsem.files = _GetFileSystemEntries(fsem.path, fsem.path_with_pattern, fsem.attrs, fsem.mask);
                    fsem.completed.Set();
                }
            }
            break;

            case vfsMessageTypes.OPEN:
            {
                vfsMessageTypes.OpenFileMessage ofm = msg.Message as vfsMessageTypes.OpenFileMessage;
                if (ofm != null)
                {
                    // Handle the message
                    //ofm.handle = _OpenFile(ofm.path, ofm.mode, ofm.access, ofm.share, ofm.options, out ofm.error, msg.Source.owning_process);
                    ofm.completed.Set();
                }
            }
            break;

            case vfsMessageTypes.CLOSE:
            {
                vfsMessageTypes.OpenFileMessage ofm = msg.Message as vfsMessageTypes.OpenFileMessage;
                if (ofm != null)
                {
                    // Handle the message
                    //_CloseFile(ofm.handle, out ofm.error, msg.Source.owning_process);
                    ofm.completed.Set();
                }
            }
            break;

            case vfsMessageTypes.MOUNT:
            {
                vfsMessageTypes.MountMessage mm = msg.Message as vfsMessageTypes.MountMessage;
                if (mm != null)
                {
                    // Handle the message
                    //_Mount(mm.mount_point, mm.device);
                    mm.completed.Set();
                }
            }
            break;
                #endregion

                #region Device Messages
            case deviceMessageTypes.INIT_DEVICE:
            {
                deviceMessageTypes.InitDeviceMessage idm = msg.Message as deviceMessageTypes.InitDeviceMessage;
                if (idm != null)
                {
                    // Handle the message
                    //_InitDevice(idm.Resources, idm.Node, ref idm.Device);
                    idm.completed.Set();
                }
            }
            break;
                #endregion
            }
        }