📜 ⬆️ ⬇️

Interview with Serge

We bring to your attention the interview with Sergey Semenov aka Serge (on Habré ion2 ), one of the most productive developers in the KolibriOS project.

The interview was conducted by Sergei Kuzmin aka Wildwest (on Habré W__W )

Do you have a hobby?

Once I pasted ships and airplanes. Now the hobby has become programming iron, reading documentation and studying someone else's code.
')
How and when did you become interested in computers and programming? What books were helpful to you?

At first there were programmable calculators and the first articles in the journal "Science and Life". It was 1985. Before that, the home computer seemed to me as unreal as a flight to the moon. Then came the Spark 1080, in which I studied assembler 8080.
From the books “Simple and Clear about Borland C ++”, excellent “Learn Yourself Programming in Windows for 21 Days” by Charles Calvert, our “C Programming Language for Personal Computer” and “Using Turbo Assembler when developing programs”. Of course, “Programming at the hardware level” of Kulakov and two dozen other books, Straustrup among them. But the honorary place on the bookshelf is occupied by the three volumes of the IA-32 Intel Architecture Software Developer's Manual and the optimization guide. There was a time when Intel sent these bricks all over the world.
Hidden text
Warm lamp manuals to


and after the update


What OS did you try? What is your home, work and favorite OS?

DOS 3.0, 4.0, 5.0 and almost all of Windows: 3.1, 95, 95OSR2, 98, NT4.0, XP, Win7.
It is now worth 8.1. It suits me perfectly, but it was more convenient to reload into Hummingbirds from previous ones. I also used different Linux and settled on the Debian Jessie and KDE desktop.

What programming languages ​​do you know and why did you learn them? Which ones do you like more than others and why?

The courses at the university were introduced to PL / M , and the school was tortured with Yershol. The institute was an obligatory fortran, at work Clarion 2.0. I used Borland Pascal 7.0 for a while, but then I got tired of this terrible syntax and switched to C. Since then, 20 years have passed.

What can you say about your projects (previous and current) that are not related to KolibriOS?

Now there are no such.

How and when did you find KolibriOS? Did he immediately start developing for her? Why do you program for it?

In 2001, Computerra had a little note about MenuetOS . Probably they wrote about some other Menuet, because the freshly pumped 0.38 terribly slowed down and looked scary. From time to time I checked new versions, until in 2006 I came across a Hummingbird. The new system was much prettier in appearance and worked faster. Then I got to the forum and got into the discussion about processing IRQ. Someone was wrong again. So it sucked. I have always been interested in playing with iron. Hummingbirds are convenient because there are no complex HAL layers between the core and the iron. Everything is very simple, visual and the kernel is compiled and loaded instantly. This is important when doing it a hundred times.

What did you do and do in the KolibriOS project? Describe the current state of your projects and their history.

The first project was the sound subsystem. At Hummingbird, there was an ac97wav player by Ivan Poddubny , which worked directly with the controller and codec. The problem was that the program could not process interrupts from the controller and the sound went with clicks, and secondly it was the exclusive access to the hardware. It was necessary to make a downloadable driver and a system mixer, so that several programs could simultaneously produce sound. There were no special problems with the controller driver for the AC97, although it was stupid to burn headphones, but I had to test the code in unreal mode DOS, because the kernel had zero support for loadable drivers. It was impossible to allocate virtual memory in the kernel, zamapit physical page to the desired address, set the IRQ handler, etc. There was not even an internal function to download the file. I had to do it through a call to the kernel 0x40. As a result, I had to write page and virtual memory management, a driver loader, redo the IRQ processing, before the sound appeared in the Hummingbird.
The second big job, still unfinished, was overcoming the legacy of the “hard Finnish past.” First, in the Codex code, symbolic variable names were not used. In the early revisions, Hummingbirds had to wade through
mov eax, [0xFE00]
shr eax, 1
mov [0xFB0A], ax
mov eax, [0xFE04]
shr eax, 1
mov [0xFB0C], ax

or

mov edi, [0x3004]; the last process (number)
movzx esi, word [0xC400 + edi * 2]
shl esi, 5
add esi, window_data

Secondly, the “small assembler core” was eating memory in completely wild quantities. For a byte variable, typical allocation of a kilobyte was typical; for a buffer of tens of kilobytes, the addresses were absolute, so they were aligned to beautiful round values. It was all from poverty. If the kernel is not able to dynamically allocate memory, it remains to reserve statically and with a margin. Gradually, all absolute addresses were replaced by symbolic labels and the appetite of the kernel was reduced by about three times.
There were also a lot of small and not so much changes in the core and an endless epic with video cards. First there was an assembler driver for the ATI R100-R500, which included hardware cursors. Then AMD introduced radeonhd and in Kolibri it became possible to change the video mode. After a few months, the Linux kernel followed the Hummingbird :-) transferred to KMS and the new driver was ported again. At the end of '11, a driver for the i915 appeared, and after two years, the Mesa driver i965 and the first “iron” gears spun. At the same time, ffmpeg was ported and a video player based on it was made. + Ported several popular libraries: cairo , freetype , libpng , zlib , mesa . The last project was binutils : ar as ld objcopy strip, all you need to link directly to Kolibri.
Hidden text
FPlay video player


Demo Cairo


Built-in Kolibri font (left) vs Droid Sans Mono and FreeType 2.5


Tell me about the kernel kernels you are developing.

kolibri-acpi is more correct to call kolibri-next. Here the code is tested before being included in the main core.

Kolibri-process - improved support for multi-threaded applications. Changes are uploaded to the main core, the branch is removed as unnecessary.

kolibri_pe - history and motives better read on the forum. The initial part of the work was successfully completed. The kernel code in C and assembler was linked using ld in a PE DLL with a fixed base address. The kernel was loaded with GRUB, jumped from protected in real mode, showed our favorite blue boot screen with a choice of options, turned on the graphics mode and returned to the protected mode. The first nail in the project cover was hammered by AMD. A redonehd driver appeared, which I immediately switched to. The second nail was from CCP Games.

The results are presented on the project's FTP server , in a nightly build. Which of these projects was the most difficult?

Porting Doom. There was already a version for the Minuet, so the work seemed not too complicated, the main task was to add sound. But the damn program crashed after the download and it was completely incomprehensible what was the matter. I had to tinker with debugging for a week before it turned out that id Software and Open Watcom determine sizeof (bool) differently. Then everything went like clockwork.
Hidden text
Port doom


You programmed for devices from different companies, read the documentation. Were there any difficult moments when there was a limitation on the part of the iron or of the OS?

Hummingbirds do not have ACPI and Device Manager support. This creates many problems. For example, the kernel still handles interrupts in the prehistoric 8259A mode, and the BIOS often assigns common IRQ lines to different PCI devices. In theory, such a separation of lines should work, but in real life it is not. The kernel can work in the APIC mode, but this requires some preparatory actions from the user and, unfortunately, a positive result is not guaranteed.
The enumeration of devices on the PCI bus gives information about the resources used, but without ACPI it is incomplete. Sometimes devices (i915 Gen3 gpu) require an unoccupied range of physical addresses, and the kernel does not have enough data to back it up. And then there is the ancient SoundBlaster, capable of working only in the first 16Mb, and for it you have to statically reserve memory.

Drivers for sound and video cards, library porting, video player ... What's next?

Plans for 3D drivers for AMD Radeon and hardware video decoding in Fplay. Unfortunately, there are several obstacles along the way. Fplay uses ffmpeg, and its developers are not very friendly with the developers of VAAPI and libVA, probably because the latter have their own gstreamer. On the other hand, ffmpeg does everything perfectly with vdpau, so the decoder will work on the Radeon as soon as r600 and radeonsi are ready for Galluim3D. But they depend on llvm, and porting llvm instead of the expected code generates ... It is not known exactly what and how llvm generates, because tracing a twenty-megabyte binary is a bit difficult without a debugger with source code support.

Often, newbies come and ask about rewriting individual parts of the OS, porting to other hardware platforms. From time to time even forklung single developers appear, for example from mike.dld , art_zh , etc. How do you feel about this?

I am calm. I started the fork myself, and then I quit.

Is compatibility with hardware platforms or other operating systems important for KolibriOS?

Hummingbird assembly system for x86. It hardly makes sense to talk about other hardware platforms.

You basically write and port programs in C ++. What tools do you use in development?

We have a ghc -4.8.2 and binutils-2.24 based toolchain in Windows and Linux versions and a small set of necessary libraries, including libstdc ++.

Is it often necessary to edit the standard compiler libraries by adding missing functions? How fully is POSIX supported?

C / C ++ programs use newlib as a standard library. It all started with a video player based on ffpmeg. The first version had the minimum required number of functions. With each new project, I add the required functions to newlib. This is of course wrong, but porting the standard library is quite a tedious task. In menuetlibc POSIX is supported in a larger volume. In general, all the difficulties with POSIX are surmountable, it takes a little perseverance and patience.

Can you give any advice to aspiring programmers? What languages ​​should I try? What advise developers of new OS? How to start? What textbooks to read?

Previously, I would advise you to examine the assembler for the target platform in order to understand what your code will eventually turn into. And now everything is cross-platform, interpretable and unknown on what it will be executed. But for OS developers, there are a few tips:
  1. Join an existing project or find like-minded people. Three heads are four times better than one.
  2. You should not start development with a microkernel, especially alone. It will be harder for you to develop drivers and applications.
  3. When you come up with your “unique, unparalleled API,” think about POSIX. Sooner or later you will need compatibility.


Well, now I want to ask you, our readers, on what topics related to Hummingbird, would you like to see the articles?

Source: https://habr.com/ru/post/256405/


All Articles