<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
    <title>AquilaOS</title>
    <subtitle>A UNIX-like operating system: kernel, C library and system tools, built toward POSIX.</subtitle>
    <link rel="self" type="application/atom+xml" href="https://aquilaos.com/atom.xml"/>
    <link rel="alternate" type="text/html" href="https://aquilaos.com"/>
    <generator uri="https://www.getzola.org/">Zola</generator>
    <updated>2018-05-20T00:00:00+00:00</updated>
    <id>https://aquilaos.com/atom.xml</id>
    <entry xml:lang="en">
        <title>Hello mmap!</title>
        <published>2018-05-20T00:00:00+00:00</published>
        <updated>2018-05-20T00:00:00+00:00</updated>
        
        <author>
          <name>Unknown</name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://aquilaos.com/2018-05-20-hello-mmap/"/>
        <id>https://aquilaos.com/2018-05-20-hello-mmap/</id>
        
        <content type="html" xml:base="https://aquilaos.com/2018-05-20-hello-mmap/">&lt;p&gt;The moment I have been avoiding for way too long. Finally we have a very very modest implementation of POSIX &lt;code&gt;mmap&lt;/code&gt;, currently we only support &lt;code&gt;MAP_FIXED&lt;/code&gt; and only VESA fbdev implements mmap, but it&#39;s a good start.&lt;/p&gt;
&lt;p&gt;As a demonstration of it, fbterm now uses mmap instead of I/O functions, which should be a lot faster since it now writes to framebuffer directly instead of going through the kernel and I/O functions.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/img/blog/mmap.png&quot; alt=&quot;Image of mmap&quot; /&gt;&lt;/p&gt;
&lt;p&gt;The VMR covering region &lt;code&gt;0xB0000000&lt;/code&gt; to &lt;code&gt;0xB0300000&lt;/code&gt; is mapped to VESA framebuffer (using the normal MM API). Private maps will be a lot easier now, with load on demand and all the good stuff in our memory manager :)&lt;/p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Playing with NuklearUI</title>
        <published>2018-05-09T00:00:00+00:00</published>
        <updated>2018-05-09T00:00:00+00:00</updated>
        
        <author>
          <name>Unknown</name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://aquilaos.com/2018-05-09-playing-with-nuklear/"/>
        <id>https://aquilaos.com/2018-05-09-playing-with-nuklear/</id>
        
        <content type="html" xml:base="https://aquilaos.com/2018-05-09-playing-with-nuklear/">&lt;p&gt;About a month ago, I &lt;a href=&quot;/2018-04-09-nuklear-ui/&quot;&gt;posted about using Nuklear GUI library in AquilaOS&lt;/a&gt;. We also have a &lt;a rel=&quot;external&quot; href=&quot;https://youtu.be/ZnHjvPpFUbs&quot;&gt;video of NuklearUI with custom font, images and wallpaper&lt;/a&gt;. I have been trying to wrap my head around the code, understanding exactly how Nuklear works and how to convert it to client/server model instead of a single binary hosting all windows.&lt;/p&gt;
&lt;p&gt;I decided that the server would do the compositing and window decorations while each client would be responsible for drawing the window contents (widgets, canvas, etc). From my understanding of Nuklear, it uses a single context structure to do about everything, so in order to seperate window content from compositor, each window would have a seperate context structure and the compositor would have a single context structure.&lt;/p&gt;
&lt;h3 id=&quot;mouse-keyboard-in-nuklear&quot;&gt;Mouse &amp;amp; Keyboard in Nuklear&lt;/h3&gt;
&lt;p&gt;My first problem was how to integrate mouse &amp;amp; keyboard support into NuklearUI &lt;em&gt;properly&lt;/em&gt;. In the first trials and the video shown above, the application simply reads (blocking I/O) from &lt;code&gt;/dev/mouse&lt;/code&gt; and translates the packets at each iteration, but since the read was blocking, if the mouse doesn&#39;t move (buffer empty) the screen is not redrawn. Later on I decided to use a seperate thread that reads from &lt;code&gt;/dev/mouse&lt;/code&gt; and fills in an internal ring buffer, then the application would simply scan the ring buffer at each iteration and process input if any is available. I then used the same idea for keyboard, but instead of reading from &lt;code&gt;/dev/kbd&lt;/code&gt; directly (and go through scancode translation and processing) I decided to simply read from &lt;code&gt;stdin&lt;/code&gt; which is hooked to a terminal (we go into non-canonical mode and read input) the input is buffered to a ring just as in mouse. All in all, it works and here is an eye candy:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/img/blog/nkui/ss1.png&quot; alt=&quot;Initial NuklearUI trial&quot; /&gt;&lt;/p&gt;
&lt;h3 id=&quot;window-compositing&quot;&gt;Window Compositing&lt;/h3&gt;
&lt;p&gt;So we need a version of Nuklear that does compositing only. I stripped down Nuklear to the bare minimum required for compositing and window decorations (almost all widgets are removed) and used it to build a simple compositing application. In the application I created a simple window with no content, then I created a seperate Nuklear context and created a window in it that starts at the top left corner of the screen, has no borders or title bar and draws a single widget, a button. The context which has the window contents is then rendered to a back buffer and an &lt;code&gt;nk_image&lt;/code&gt; is exported. The compositor would then render the &lt;code&gt;nk_image&lt;/code&gt; inside the empty window created in it (using a custom command buffer command -- it just copies the &lt;code&gt;nk_image&lt;/code&gt; contents to the window buffer), and here is the result:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/img/blog/nkui/ss2.png&quot; alt=&quot;First compositor&quot; /&gt;&lt;/p&gt;
&lt;p&gt;The first thing you would notice is the two cursors, this is because the contents of the window is an entirely seperate Nuklear context (which has its own cursor), this was easily solved by hiding the cursor. But that is not the major problem, now since we have two different contexts, we must find a way to send input relevant to window contents to the other context.&lt;/p&gt;
&lt;h3 id=&quot;compositor-input-handling&quot;&gt;Compositor Input Handling&lt;/h3&gt;
&lt;p&gt;This is the part that need most attention to exactly how Nuklear works. Since the compositor keeps track of window position and bounds, we could easily check if mouse is in window region. Also we can check if window is active (by checking if its top-most window, i.e. &lt;code&gt;window == ctx-&amp;gt;end&lt;/code&gt;). We then get the bounds of the contents region (Nuklear people are generous enough to have a function for that) and then calculate the relative mouse offsets inside the window contents region. We then send the input event to the other context and make it redraw to back buffer.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/img/blog/nkui/ss3.png&quot; alt=&quot;Input passing&quot; /&gt;&lt;/p&gt;
&lt;p&gt;And since we also check if window is currently active, the input is only passed if the window actually has focus, so overlaying windows are handleled correctly, as shown.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/img/blog/nkui/ss4.png&quot; alt=&quot;Overlaying windows&quot; /&gt;&lt;/p&gt;
&lt;p&gt;This is all for now, I can say that I &lt;em&gt;believe&lt;/em&gt; this may actually work just fine. I still have to figure out many things but so far so good! Stay tuned for upcoming updates. Happy hacking ;)&lt;/p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Memory Management System Redesign</title>
        <published>2018-05-07T00:00:00+00:00</published>
        <updated>2018-05-07T00:00:00+00:00</updated>
        
        <author>
          <name>Unknown</name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://aquilaos.com/2018-05-07-memory-management-redesign/"/>
        <id>https://aquilaos.com/2018-05-07-memory-management-redesign/</id>
        
        <content type="html" xml:base="https://aquilaos.com/2018-05-07-memory-management-redesign/">&lt;p&gt;I won&#39;t lie, memory management is &lt;em&gt;the most&lt;/em&gt; frustrating thing in OS design for me. It takes the most time and debugging it is nevertheless exhausting. I have, however, redesigned it to be more generic than before and relax much more arch. dependent code.&lt;/p&gt;
&lt;h2 id=&quot;the-new-design&quot;&gt;The New Design&lt;/h2&gt;
&lt;h3 id=&quot;physical-memory-management&quot;&gt;Physical Memory Management&lt;/h3&gt;
&lt;p&gt;AquilaOS uses zoned buddy memory allocation technique, which is used in Linux and many *BSDs. Currently we only have two zones &lt;code&gt;ZONE_DMA&lt;/code&gt; and &lt;code&gt;ZONE_NORMAL&lt;/code&gt; which have identical functionality to that found in Linux.&lt;/p&gt;
&lt;h3 id=&quot;virtual-memory-management&quot;&gt;Virtual Memory Management&lt;/h3&gt;
&lt;p&gt;In the new design, the kernel deals with a one level of paging while the archticture handles the intermediate paging levels. Now each process has defined memory mapped regions wich is either lazily loaded from file, lazily allocated or lazily copied on fork. This allows for very efficient memory use (even the stack is allocated on demand). And finally, AquilaOS has no more memory leaks.&lt;/p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Nuklear based GUI</title>
        <published>2018-04-09T00:00:00+00:00</published>
        <updated>2018-04-09T00:00:00+00:00</updated>
        
        <author>
          <name>Unknown</name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://aquilaos.com/2018-04-09-nuklear-ui/"/>
        <id>https://aquilaos.com/2018-04-09-nuklear-ui/</id>
        
        <content type="html" xml:base="https://aquilaos.com/2018-04-09-nuklear-ui/">&lt;p&gt;I have been looking into various options of GUI/Windowing systems to implement in AquilaOS and here is what I found so far&lt;/p&gt;
&lt;h3 id=&quot;x&quot;&gt;X&lt;/h3&gt;
&lt;p&gt;While &lt;em&gt;X&lt;/em&gt; is the defacto when it comes to GUI, it is extremely heavy, mostly optimized for Linux and requires too much dependencies.&lt;/p&gt;
&lt;h3 id=&quot;wayland&quot;&gt;Wayland&lt;/h3&gt;
&lt;p&gt;Wayland is a little promising than &lt;em&gt;X&lt;/em&gt; due to its lightweight design, however it still makes certain assumptions about the underlying kernel that might not be very easy for everyone to support.&lt;/p&gt;
&lt;h3 id=&quot;picogui&quot;&gt;Picogui&lt;/h3&gt;
&lt;p&gt;That could have been a really promising project, only now it is deprecated and way out-of-sync.&lt;/p&gt;
&lt;h3 id=&quot;nuklear&quot;&gt;Nuklear&lt;/h3&gt;
&lt;p&gt;Well, first, Nuklear should have not been on this list, it is not a replacement for X server but it supports a few features that took my interest way too far:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Extrememly portable, doesn&#39;t even depend on libc!&lt;/li&gt;
&lt;li&gt;Entirely written in C with many bindings&lt;/li&gt;
&lt;li&gt;Has a basic windowing system and widgets&lt;/li&gt;
&lt;li&gt;Can be optimized to use HW acceleration for various targets easily&lt;/li&gt;
&lt;li&gt;It&#39;s design is simple and straightforward&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;All in all, Nuklear is an amazing GUI library, well done Micha Mettke!&lt;/p&gt;
&lt;p&gt;So, one could say that Nuklear is a replacement for GTK/X for example, only Nuklear is not based on a server/client model, all applications are hosted in the same binary and executed as a single program.&lt;/p&gt;
&lt;p&gt;However, that doesn&#39;t stop us from trying to make it work as a server/client model, I&#39;ve started project NuklearUI exactly for that, it should serve as a starting point for OSDevers willing to incorportate a GUI system in their OS with minimum requirements. My first idea is to use POSIX shared-memory for communication due to its simplicity, but we could think of other design patterns (like Nuklear would be fully contained in kernel space). I will try to make that decision on the developer side.&lt;/p&gt;
&lt;p&gt;Currently, there isn&#39;t much, other than some &quot;Hello, Nuklear!&quot; stuff. I just managed to implement a basic PS/2 Keyboard &amp;amp; Mouse drivers and Aquila framebuffer backend, it works as a standalone application and safetly returns to fbterm (and shell).&lt;/p&gt;
&lt;p&gt;Here is a screenshot of a demo of Nuklear running on AquilaOS
&lt;img src=&quot;/img/blog/nuklear.png&quot; alt=&quot;Image of Nuklear&quot; /&gt;&lt;/p&gt;
&lt;p&gt;And a video showing the switch between fbterm and Nuklear
&lt;a rel=&quot;external&quot; href=&quot;https://youtu.be/gfuRbHAGhl8&quot;&gt;https://youtu.be/gfuRbHAGhl8&lt;/a&gt;&lt;/p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>First post!</title>
        <published>2018-02-17T00:00:00+00:00</published>
        <updated>2018-02-17T00:00:00+00:00</updated>
        
        <author>
          <name>Unknown</name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://aquilaos.com/2018-02-17-hello-world/"/>
        <id>https://aquilaos.com/2018-02-17-hello-world/</id>
        
        <content type="html" xml:base="https://aquilaos.com/2018-02-17-hello-world/">&lt;p&gt;This is my first post, how exciting!&lt;/p&gt;
</content>
        
    </entry>
</feed>
