A dedicated kernel for multi-threading applications.

Saturday, March 04, 2017

Example of Toro Virtual Filesystem

Hi folks! I have spent some time to write an example of the use of the toro virtual filesystem. After fixing a couple of bugs, I manage to get an example named TorowithFileSystem.pas. This example together with others is hosted in torokernel/tests. The example can be tested by following the instructions here. I also committed a small ext2 image named ToroFiles.img that contains the files to make it run. For the moment, I am providing the whole image. I hope to provide a tool to create ext2 images. The example is very simple, it opens a file name index.hml located in the ext2 image and then it listens on port 80. When a connection arrives, it sends the content of the file. Briefly speaking, it is a sort of webserver. The example is a slightly modification of the ToroHttp.pas example. The only difference is that this example read the content from a file. To illustrate, I highlighted the differences in code in read and green (see Figure 1).  

Figure1. Differences between ToroHttp.pas and TorowithFilesystem.pas
          
In red, we can see the initialization part in which the disk ata0 is dedicated to the core 0 (local cpu). By doing this, only core can access to this device. Once dedicated, we are able to mount the first partition, which is identified with the minor number 6, by using the ext2 drive. After this, we are able to open the file index.html and read it until EOF. Then, the content of this file is sent when a new connection arrives. Enjoy!

Matias

Saturday, February 18, 2017

Compiling and Running Tests by using Lazarus 1.6.2

Hi folks! I am spending some time working on Lazarus and making all tests examples to compile and run directly from Lazarus. For the moment, I am only working on Windows 10. So far I managed to:
1. Compile ToroHello.pas directly from the IDE thus avoiding to execute any make from command line:


2. Run on Qemu ToroHello.img: 


I illustrated by using ToroHello, however, this also applies to all the tests. The changes are not still in master, instead I am working on the branch https://github.com/MatiasVara/torokernel/tree/supportlazaruscompilation. Fell free to clone and try. This only needs to install Lazarus 1.6.2 and FreePascal 3.0.0.


Matias

Toro on Github

Hi folks! I moved toro repository to github, i.e., https://github.com/MatiasVara/torokernel. I am trying to be more organized in the TODO work so fell free to check Projects and Issue sections. I am looking forward to more collaborative work!

Matias

Wednesday, January 25, 2017

Toro kernel compiled with FPC 3.0.0!

Hi folks! I just fixed system.pas to compile Toro by using FPC 3.0.0. Most of the work has been done on the way that system.pas handles AnsiStrings. In addition, I moved the project to github, so fell free to participate. I tested the tests examples and they seem working. However, I only tested on Win 10. I will test in Linux in the following days. 

Matias 

Saturday, January 21, 2017

How compile and run Toro in Windows 10

Hi folks! This time I want to present how compile and run Toro in Windows 10. What am I going to explain? How to compile the example named ToroHello.pas and run it on a QEMU VM. In thw following, I explain this procedure in 7 steps. My environment is in a Windows 10 in a x86-64 architecture.

1) Install Git Bash for Windows:
I am using this as the command line to get the compilation on Windows. You can download it from https://git-for-windows.github.io/

2) Install Yasm:
Yasm is the compilator for assembler code. This is needed to compile the bootloader. You can download it from http://yasm.tortall.net/Download.html

3) Install FPC 2.6.4:
FPC is used to compile the code of toro. For the moment toro is based on FPC 2.6.4. You can download it from https://sourceforge.net/projects/freepascal/files/Win32/2.6.4/fpc-2.6.4.x86_64-win64.exe/download

4) Install QEMU:
QEMU is used to run the application compiled into Toro. You can download it from https://qemu.weilnetz.de/w64/

So far we have all the tools to compile and run ToroHello.pas. We need just to clone it and compile it.

5) Clone Toro code:
Go to the Git Bash for Windows and clone the toro code by doing:

git clone git@github.com:MatiasVara/torokernel.git

6) Compile the bootloader and tools:
Before compile any application with Toro we have to compile the bootloader and the tools to generate an image for the VM. To do so, just run Make in toro-code/test directory.

7) Compile ToroHello.pas
To do this, we rely on the script named CloudIt.sh. We have to run the following command in the toro-code/test directory:

./CloudIt.sh ToroHello

That's all folks! If everything goes well you will get a QEMU VM running ToroHello.pas. Please fell free to comment if any of the steps did not work for you. Matias





Wednesday, January 04, 2017

HTTP server by using socket multiplexing

Hi folks!
In this post I will show you part of the last experiments on sockets multiplexing. This has been added in Toro a couple or years ago, however, only now I could make an example that works. This is a simple example, i.e., a simple http server that prints a welcome message. To make it works, I spent the last month fixing bugs in the networking. Also, I fixed an important bug in the memory manager. In the following, I will show how socket multiplexing is used in the case of a http server. The code of the example can be found in tests/ToroHttp.pas. In this post, I am not going into details about how socket multiplexing works. I will try only to give a big picture.
Let's first discuss the code of ToroHttp.pas (see Figure 1). This is the main program. It defines the network handler, i.e., HttpHandler. Then, it sets the right methods, e.g., DoInit(), DoAccept().

Figure 1.

After that, the handler is registered by using SysRegisterNetworkService(). The kernel will execute the different methods. For example, the first method invoked will be HttpInit().


Figure 2.
The method creates a new socket that listens on local port 80. Then, when a new connection arrives, the kernel will invoke HttpAccept().


This method prints something and waits for new data from the remote host. When some data is received, the kernel executes HttpReceive().

Figure 3.
We implemented a simple Receiv method. It only reads all the data from the remote host, then it sends a welcome message, and finally it closes the connection. To tray the server, we use telnet to the IP of the guest. In the telnet client, we get:


In the Qemu VM, we see that the connection is received and then closed:


As I said before, I only explained some details about socket multiplexing. I used the http server as a running example. The whole example is hosted in toro repo so please fell free to clone it.

Matias Vara