Mogotu

Mogotu is a toy operating system based on xv6, a reimplementation of Unix Version 6 written in C for x86 architectures. xv6 is a teaching operating system developed by MIT to serve its Operating Systems Engineering (6.828) course.

Mogotu enhanced xv6 in the following aspects:

  • Graphical system
  • PS/2 mouse support

Mogotu Desktop

The graphical system of Mogotu was based on VESA BIOS Extensions (VBE). We implemented a simple graphics library to support drawing basic shapes such as rectangles and ellipses. To draw shapes on the screen, we first wrote data to a dedicated memory area called device context (DC). Then the data were copied to the video buffer. This design had yielded better performance than modifying the video buffer directly.

The PS/2 mouse driver was based on controlling the 0x60 and 0x64 I/O ports. Specific device contexts were used to draw the mouse on the screen.

A window in Mogotu is called a world. Each user-level GUI application can have one or more worlds. A typical GUI application in Mogotu is as follows. We modified the Process Control Block (PCB) in xv6 to provide each process with a message queue. It is the responsibility of the programmer to handle different types of system messages. A device context is binded to each world. The programmer can draw on the device context and then call invalidate() to refresh the area. All of the operations above form the Mogotu API.

int main()
{
    Message msg;
    HWorld hWorld = createWorld(..., proc, ...);

    while(getMessage(hWorld, &msg) == 0)
        dispatchMessage(&msg);
    exit();
}

int proc(Message *pMsg)
{
    switch(pMsg->type)
    {
    case WM_CREATE:
        /* ... */
        break;
    case WM_PAINT:
        /* ... */
        break;
    case WM_MOUSE_MOVE:
        /* ... */
        break;
    /* user defined message types */
    }
    return defProc(pMsg);
}

Here are some of the user-level applications we embedded in Mogotu to demonstrate its capability.

  • mFile (a file browser)
  • mBound (an app visualizing the bounding ball of a set of 3D points)
  • mPaint (a painting tool)
  • mView (a picture viewer to view BMP images)

The user can also turn off GUI mode to run shell applications such as mBubble (a console version of the Bubble Breaker game).

Mogotu mFile

Mogotu mBound

Mogotu mPaint

Mogotu mBubble

We had successfully run Mogotu on the QEMU emulator. We had also run Mogotu on a laptop, namely Lenovo ThinkPad E40 05785KC. We used GRUB as the boot loader.

Mogotu was a course project for Modern Operating System (Course Number: 34100053) at Tsinghua University in spring 2012. The team members of Mogotu are: Jinghong Situ, Heran Lin, Haowei Huang, Yuqi Wang, and Qi Guo.