示例#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);
            }
        }
示例#2
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);
            }
        }