<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-4388866233575924745</id><updated>2012-02-17T00:52:58.166+01:00</updated><category term='hub'/><category term='GRUB'/><category term='IPC'/><category term='OHCI'/><category term='HelenOS'/><category term='telnet'/><category term='keyboard'/><category term='HID'/><category term='QEMU'/><category term='cheatsheet'/><category term='NUMA'/><category term='networking'/><category term='USB'/><title type='text'>Vojta's blog</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://vhotspur.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4388866233575924745/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://vhotspur.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Vojta</name><uri>http://www.blogger.com/profile/05500449254861905111</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>9</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4388866233575924745.post-6838123139426704775</id><published>2012-01-13T19:30:00.000+01:00</published><updated>2012-01-13T19:30:06.361+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='telnet'/><category scheme='http://www.blogger.com/atom/ns#' term='HelenOS'/><category scheme='http://www.blogger.com/atom/ns#' term='networking'/><title type='text'>Telneting to HelenOS</title><content type='html'>&lt;p&gt;Not that long ago &lt;a href="http://trac.helenos.org/changeset/mainline%2C1319"&gt;TCP rewrite&lt;/a&gt; was merged into HelenOS mainline branch. As a proof of its functionality,  &lt;a href="http://trac.helenos.org/changeset/mainline%2C1356"&gt;webserver was improved&lt;/a&gt; recently. That encouraged me to implement "remote console" offering posibility to run applications on HelenOS remotely over the network... 
&lt;/p&gt;
&lt;a name='more'&gt;&lt;/a&gt;
&lt;p&gt;The screenshot below displays HelenOS running in Qemu with GNOME terminal in front with Telnet session to it.
&lt;/p&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/-XrjIA2LBru0/TxBK3PiqiVI/AAAAAAAABns/QWsvJJ9v9s4/s1600/helenos_telnet.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="181" src="http://1.bp.blogspot.com/-XrjIA2LBru0/TxBK3PiqiVI/AAAAAAAABns/QWsvJJ9v9s4/s320/helenos_telnet.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;If you want to try it, grab the branch &lt;a href="https://code.launchpad.net/%7Evojtech-horky/helenos/remote-console"&gt;lp:~vojtech-horky/helenos/remote-console&lt;/a&gt;
and compile it. Then start HelenOS and run &lt;code&gt;remcons&lt;/code&gt; from the console. If the networking is okay, the program shall display &lt;samp&gt;HelenOS remote console service&lt;/samp&gt; and wait for incoming connection. The program listens on port 2223 and you can connect to it with following command:
&lt;pre&gt;telnet &lt;i&gt;hostname&lt;/i&gt; 2223&lt;/pre&gt;
Do not forget to add port redirection when running in Qemu:
&lt;pre&gt;qemu ... -redir tcp:2223::2223&lt;/pre&gt;
&lt;/p&gt;
&lt;p&gt;
A few notes to the implementation. The program behaves as a console-protocol service and on accepting new network connection, it creates a virtual terminal and runs &lt;code&gt;getterm&lt;/code&gt; on it (with &lt;code&gt;bdsh&lt;/code&gt;). It then translates the incoming traffic to console events and writing to console to outgoing packets.
&lt;/p&gt;
&lt;p&gt;
Despite the title of this post, the server is far from being a standard-compliant &lt;a href="http://en.wikipedia.org/wiki/Telnet"&gt;Telnet server&lt;/a&gt;. It only sends Telnet commands for switching into character mode (for better interactivity) and then it sends only printable characters. It is also able to skip incoming Telnet commands but that is about all related with the protocol.
&lt;/p&gt;
&lt;p&gt;
The service is not able to handle special keys (the most special keys it handles more or less okay are backspace and tab) and also has no support for drawing. So, no playing Tetris remotely. And national characters are passed through in a very  &lt;a href="http://upload.wikimedia.org/wikipedia/commons/thumb/4/4c/Struthio-camelus-australis-grazing.jpg/800px-Struthio-camelus-australis-grazing.jpg?uselang=cs"&gt;ostrich&lt;/a&gt; way ;-).
&lt;/p&gt;

&lt;p&gt;
The biggest flaw of the server is caused by limitations of current TCP implementation in HelenOS. The problem is that when a fibril waits for &lt;code&gt;recv()&lt;/code&gt;, no other operation on any socket can occur because all network-related functions hold one global lock. That effectively means that you cannot have two remote sessions.
&lt;/p&gt;
&lt;p&gt;
Apart from the fun of it, this service can be useful for simpler copying of textual data between HelenOS (running in some simulator) and host system. It seems to me easier than mounting virtual harddisks and copying the data off-line.
&lt;/p&gt;
&lt;p&gt;
And that's all. I hope you like this new HelenOS toy ;-). 
&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4388866233575924745-6838123139426704775?l=vhotspur.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vhotspur.blogspot.com/feeds/6838123139426704775/comments/default' title='Komentáře k příspěvku'/><link rel='replies' type='text/html' href='http://vhotspur.blogspot.com/2012/01/telneting-to-helenos.html#comment-form' title='Počet komentářů: 0'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4388866233575924745/posts/default/6838123139426704775'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4388866233575924745/posts/default/6838123139426704775'/><link rel='alternate' type='text/html' href='http://vhotspur.blogspot.com/2012/01/telneting-to-helenos.html' title='Telneting to HelenOS'/><author><name>Vojta</name><uri>http://www.blogger.com/profile/05500449254861905111</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/-XrjIA2LBru0/TxBK3PiqiVI/AAAAAAAABns/QWsvJJ9v9s4/s72-c/helenos_telnet.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4388866233575924745.post-7181960925622874396</id><published>2011-05-11T21:54:00.000+02:00</published><updated>2011-05-13T22:42:41.527+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='HelenOS'/><category scheme='http://www.blogger.com/atom/ns#' term='HID'/><category scheme='http://www.blogger.com/atom/ns#' term='UHCI'/><category scheme='http://www.blogger.com/atom/ns#' term='QEMU'/><category scheme='http://www.blogger.com/atom/ns#' term='EHCI'/><category scheme='http://www.blogger.com/atom/ns#' term='OHCI'/><category scheme='http://www.blogger.com/atom/ns#' term='USB'/><title type='text'>Two days with HelenOS USB</title><content type='html'>&lt;p&gt;
We decided to have a coding weekend (the last one) due to approaching deadline for our USB project and I can (again) announce some good news.&lt;/p&gt;
&lt;a name='more'&gt;&lt;/a&gt;
&lt;p&gt;
First of all, JV fixed the problem of &lt;b&gt;accessing memory mapped registers in IRQ pseudo-code&lt;/b&gt; by using a simple hack. During the registration, address space of the caller is remembered and in the handler the address space is switched back. Of course, it is not optimal and I am not sure how this would behave on other architectures, but on Intel it works just fine.&lt;/p&gt;
&lt;p&gt;
JV also fixed some &lt;b&gt;initialization problems with EHCI&lt;/b&gt;. Actually, we do not support EHCI (that is host controller for USB 2.0) but we need to turn it off to allow UHCI and OHCI drivers take control. As a result, all machines we have access to are able to boot and work with our USB branch.&lt;/p&gt;
&lt;p&gt;
LS a MK again engaged in a fight with USB HID, discovered several problems and fixed a lot of bugs. The &lt;b&gt;support for multimedia keys&lt;/b&gt; is almost complete, pressing them shall write their names to the console. As a bonus, LS wrote a very small subdriver that converts &lt;b&gt;mouse wheel to arrows&lt;/b&gt; so now you can scroll in &lt;code&gt;edit&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;
MD was fixing some bugs concerning device initialization and proper device discovery of peripherals plugged at boot time. Unless I am mistaken, we have currently only 2 devices that refuses to get initialized when plugged directly into root hub. Both Microsoft-made mouses. Both not respecting standard Microsoft helped to write. Oh, well...&lt;/p&gt;
&lt;p&gt;
I did some refactoring of our virtual USB and revived the &lt;b&gt;virtual HID&lt;/b&gt;. I hope that the current state would allow to use it as a tester for the HID driver, especially for the HID parser. The HID specification is definitely becoming the most cursed part of our project - it allows almost any sequence of bytes to be a valid descriptor.&lt;/p&gt;
&lt;p&gt;
I also added a very simple &lt;b&gt;lsusb&lt;/b&gt; for listing attached USB devices. For more detailed information, we have &lt;code&gt;usbinfo&lt;/code&gt;. Today I fixed a bug in &lt;b&gt;mass storage stub&lt;/b&gt;. Tested three flash disks + the emulated in QEMU and all are able to report themselves correctly.&lt;/p&gt;
&lt;p&gt;
And together we discussed how our presentation shall look like and how we would ship our project to the committee. The deadline is dangerously close.&lt;/p&gt;
&lt;p&gt;
And that's all for tonight. Stay tuned.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4388866233575924745-7181960925622874396?l=vhotspur.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vhotspur.blogspot.com/feeds/7181960925622874396/comments/default' title='Komentáře k příspěvku'/><link rel='replies' type='text/html' href='http://vhotspur.blogspot.com/2011/05/two-days-with-helenos-usb.html#comment-form' title='Počet komentářů: 0'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4388866233575924745/posts/default/7181960925622874396'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4388866233575924745/posts/default/7181960925622874396'/><link rel='alternate' type='text/html' href='http://vhotspur.blogspot.com/2011/05/two-days-with-helenos-usb.html' title='Two days with HelenOS USB'/><author><name>Vojta</name><uri>http://www.blogger.com/profile/05500449254861905111</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4388866233575924745.post-6980956446219700880</id><published>2011-05-02T19:00:00.000+02:00</published><updated>2011-05-02T19:00:00.211+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='HelenOS'/><category scheme='http://www.blogger.com/atom/ns#' term='HID'/><category scheme='http://www.blogger.com/atom/ns#' term='QEMU'/><category scheme='http://www.blogger.com/atom/ns#' term='OHCI'/><category scheme='http://www.blogger.com/atom/ns#' term='USB'/><title type='text'>OHCI, HID parser and more</title><content type='html'>&lt;p&gt;
It has been a while since my last post about USB support for HelenOS.
But we have made some progress that I am proud to announce.&lt;/p&gt;
&lt;a name='more'&gt;&lt;/a&gt;
&lt;p&gt;
First of all, we have functional &lt;b&gt;OHCI driver&lt;/b&gt;. &lt;a href="http://en.wikipedia.org/wiki/OHCI"&gt;OHCI&lt;/a&gt; is a host controller
supporting USB 1.1 and, unlike UHCI, is not a PC-platform only product (OHCI is used in Macs as well).
However, we do our development on PC and we have not tried our driver on
anything else.
The driver is complete (except for support for isochronous transfers) and was
tested on real hardware.
It also work in VirtualBox and so now you are not limited to QEMU only for
trying HelenOS with USB support.&lt;/p&gt;
&lt;p&gt;
Since the beginning, our flagship was the &lt;b&gt;USB HID driver&lt;/b&gt; and a noticable
progress was made there as well.
First of all, the base skeleton is finished and I dare say that HelenOS can
be fully controlled by USB keyboard without any limitations.
Obviously, this does not include the kernel console but that is to be expected.
Huge progress was done with the HID parser that is almost completed now.&lt;/p&gt;
&lt;p&gt;
The &lt;b&gt;HID parser&lt;/b&gt; reminds me of regular expressions in Unix. There is a
problem inside another one that is of the same size as the outer one.
The concept and internals of the parser were already changed several times
because the specification does not give enough &lt;i&gt;practical&lt;/i&gt; (I really
mean practical, not the &lt;i&gt;kind reader will...&lt;/i&gt;) examples to create
good design from it alone.
More than once, we found a keyboard (or mouse) that used settings (i.e. the hardware configuration wired in the physical device) not described well by the
specification that forced us to rethink the design.
I am not well versed with the parser to elaborate more on its design but it
seems to me that HID specification was done purely by hardware vendors whose
main concern is to save a few bytes.
The rest can be done in software by some poor devils ;-).&lt;/p&gt;
&lt;p&gt;
To demonstrate the capabilites of the HID driver we decided to add a sample
&lt;b&gt;support for multimedia keys&lt;/b&gt;.
Probably, they will not do anything useful but print some message somewhere
but that shall be sufficient as a proof of concept.
The support for such special HID devices is created using something we
call a subdriver.
Such subdriver is a set of callback functions that are registered in the
generic HID driver and are called upon data retrieval.
Their thask is extract the special keys and control some specific DDF interface
to provide these events to client applications.
In the future, these so called subdrivers might become fully independent
drivers spawned by the generic HID driver.
Definitely, that would be task for someone else.&lt;/p&gt;
&lt;p&gt;
Next we created a simple stub for &lt;b&gt;mass storage driver&lt;/b&gt; to test that
bulk transfers work.
Because HelenOS lacks support for SCSI devices, the stub merely tries to
identify the device by sending &lt;a href="http://en.wikipedia.org/wiki/SCSI_Inquiry_Command"&gt;INQUIRY&lt;/a&gt; command.
For some devices it works, some stall the communication and some even do not
attempt to answer.
Probably there is some magic in the initial handshake.
However, mass storage support is not our goal and we will probably leave the
driver alone for now.
Someone else may carry on...&lt;/p&gt;
&lt;p&gt;
Last thing worth reporting is that JV found some awful bug in &lt;a href="https://bugs.launchpad.net/qemu/+bug/757654"&gt;QEMU&lt;/a&gt;
that causes that transfers ending with error are never reported as completed
by the simulated UHCI chip. Bad.
Although patch was provided, no action was taken yet.&lt;/p&gt;
&lt;p&gt;
As our &lt;b&gt;deadline is approaching&lt;/b&gt;, we need to focus on fixing bugs that
we &lt;a href="http://sourceforge.net/apps/trac/helenos-usb/report/10"&gt;know about&lt;/a&gt;, and writing the documentation - both Doxygen one and developers' one. Documentation can be found on-line &lt;a href="http://helenos-usb.sourceforge.net/"&gt;here&lt;/a&gt;. Also, we need to prepare some distribution CD that we can
ship to the project committee.
We also need to make a presentation and I hope that we would be able to
put something together before the next HelenOS Saturday meeting to present
our project there.
And maybe some refactoring and code beautification would be needed as well.&lt;/p&gt;
&lt;p&gt;
And that is all. We are planning to end in June so we have less than month
for finalization.
May the force, debugger and standard compliant devices be with us ;-).&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4388866233575924745-6980956446219700880?l=vhotspur.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vhotspur.blogspot.com/feeds/6980956446219700880/comments/default' title='Komentáře k příspěvku'/><link rel='replies' type='text/html' href='http://vhotspur.blogspot.com/2011/05/ohci-hid-parser-and-more.html#comment-form' title='Počet komentářů: 1'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4388866233575924745/posts/default/6980956446219700880'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4388866233575924745/posts/default/6980956446219700880'/><link rel='alternate' type='text/html' href='http://vhotspur.blogspot.com/2011/05/ohci-hid-parser-and-more.html' title='OHCI, HID parser and more'/><author><name>Vojta</name><uri>http://www.blogger.com/profile/05500449254861905111</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4388866233575924745.post-3879437933850602994</id><published>2011-02-28T11:58:00.001+01:00</published><updated>2011-03-02T12:09:10.301+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='HelenOS'/><category scheme='http://www.blogger.com/atom/ns#' term='GRUB'/><title type='text'>Adding HelenOS to existing GRUB</title><content type='html'>&lt;p&gt;
Last week we started testing our USB drivers on real hardware. That involves a lot of quick fixes, followed by burning the CD image (or creating bootable USB disk) and rebooting the computer. Not very comfortable. So I decided to polish my script for adding HelenOS to existing GRUB and make it available for everyone.&lt;/p&gt;
&lt;a name='more'&gt;&lt;/a&gt;
&lt;p&gt;
The script is intended for PC platform and all it does is that it copies HelenOS kernel image to directory where existing GRUB can find it (i.e. the GRUB that is used to boot on real hardware) and adds a menu entry to GRUB.&lt;/p&gt;
&lt;p&gt;
The usual disclaimer - the script is provided as is. I have used it on my PC and it worked. However, &lt;b&gt;it modifies boot loader files&lt;/b&gt; and double checking them before rebooting is more than recommended. Otherwise, you may end up with computer that &lt;b&gt;will not boot at all&lt;/b&gt;.&lt;/p&gt;
&lt;p&gt;
You can download the script &lt;a href="https://sites.google.com/site/vhotspur/helenos_add_to_grub.sh?attredirects=0&amp;d=1"&gt;here&lt;/a&gt;. I placed it in &lt;code&gt;/usr/local/sbin&lt;/code&gt; and created sudo entry for it (it needs root privilege to modify &lt;code&gt;/boot&lt;/code&gt; directory where GRUB usually resides).&lt;/p&gt;
&lt;p&gt;
The script can modify GRUB menu in two ways. First, it can append the HelenOS entry to it or replace existing HelenOS entry. I prefer the latter because I do not need to modify the menu file manually at all. In order to use the replacing version, you need to add following two lines to your GRUB menu (usually &lt;code&gt;/boot/grub/menu.lst&lt;/code&gt; or &lt;code&gt;/boot/grub/grub.conf&lt;/code&gt;). Configuration needed for booting HelenOS will be placed between them.&lt;/p&gt;
&lt;pre&gt;### HelenOS automatic install start
### HelenOS automatic install end&lt;/pre&gt;
&lt;p&gt;
Once you have done that, you can install HelenOS to it. Build HelenOS and run the script with &lt;code&gt;-h&lt;/code&gt; parameter. It will display quite verbose help together with guessed values of several important parameters. If the guesses looks okay, you can proceed to actual installation. I use following command:
&lt;pre&gt;sudo /usr/local/sbin/helenos_add_to_grub \
    -c -r -t "HelenOS (USB support)"&lt;/pre&gt;
This replaces existing entry in GRUB (&lt;code&gt;-r&lt;/code&gt;), removes files from previous install (&lt;code&gt;-c&lt;/code&gt;) and sets a nice title. The script produces following output informing about performed actions:
&lt;pre&gt;==&gt; Cleaning previous install ...
  --&gt; rm -rf /boot/helenos
==&gt; Creating GRUB HelenOS directory ...
  --&gt; mkdir -p /boot/helenos
==&gt; Installing HelenOS kernel and modules ...
  --&gt; cp -R &lt;i&gt;REPO-PATH&lt;/i&gt;/boot/distroot/boot /boot/helenos
==&gt; Updating HelenOS GRUB menu ...
==&gt; Backing-up current GRUB menu ...
  --&gt; cp /boot/grub/menu.lst /boot/grub/menu.lst.bak
==&gt; Replacing HelenOS entry in GRUB menu ...
==&gt; Adding HelenOS to GRUB completed.&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;
If you are not using standard locations of GRUB, you can use following parameters to change them:&lt;/p&gt;
&lt;dl&gt;
 &lt;dt&gt;&lt;code&gt;-g&lt;/code&gt;&lt;/dt&gt;
  &lt;dd&gt;Path to GRUB menu configuration file&lt;/dd&gt;
 &lt;dt&gt;&lt;code&gt;-d&lt;/code&gt;&lt;/dt&gt;
  &lt;dd&gt;GRUB device name where boot partition is (something like &lt;code&gt;(hd&lt;i&gt;n&lt;/i&gt;,&lt;i&gt;k&lt;/i&gt;)&lt;/code&gt;)&lt;/dd&gt;
 &lt;dt&gt;&lt;code&gt;-o&lt;/code&gt;&lt;/dt&gt;
  &lt;dd&gt;Directory where to copy HelenOS files (directory &lt;code&gt;/boot/helenos&lt;/code&gt; is used by default)&lt;/dd&gt;
 &lt;dt&gt;&lt;code&gt;-O&lt;/code&gt;&lt;/dt&gt;
  &lt;dd&gt;GRUB path to &lt;code&gt;-o&lt;/code&gt; directory (depending on your partition settings, it might be the same as &lt;code&gt;-o&lt;/code&gt; or without the &lt;code&gt;/boot&lt;/code&gt; prefix)&lt;/dd&gt;
 &lt;dt&gt;&lt;code&gt;-b&lt;/code&gt;&lt;/dt&gt;
  &lt;dd&gt;Where is the boot dir of HelenOS build (&lt;code&gt;&lt;i&gt;REPO_DIR&lt;/i&gt;/boot/distroot/boot&lt;/code&gt;)&lt;/dd&gt;
&lt;/dl&gt;
&lt;p&gt;
Ideas for improvements are welcomed. Patches with these improvements even more so.&lt;/p&gt;
&lt;p&gt;
&lt;b&gt;UPDATE:&lt;/b&gt; New version supporting GRUB2 can be downloaded &lt;a href="https://sites.google.com/site/vhotspur/helenos_add_to_grub_v2.sh?attredirects=0&amp;d=1"&gt;here&lt;/a&gt;. It also fixes bad usage of &lt;code&gt;getopt&lt;/code&gt;. Using it with GRUB2 is quite easy, difference is that as a GRUB configuration file is taken HelenOS file in &lt;code&gt;/etc/grub.d/&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;
I tested the updated script on Ubuntu in VirtualBox and adding following lines to Makefile in root directory of HelenOS (USB branch checkout) allowed me smooth install:&lt;/p&gt;
&lt;pre&gt;install-to-grub:
    [ -e "image.iso" ]
    sudo /usr/local/sbin/helenos_add_to_grub \
        --grub2 --title "HelenOS (USB)" \
        -g /etc/grub.d/35_helenos_usb \
        -o /boot/helenosusb -O /boot/helenosusb
    sudo update-grub&lt;/pre&gt;
&lt;p&gt;
Advantage of having GRUB2 is that you can have more entries and removal is pretty simple (just remove entry in &lt;code&gt;/etc/grub.d&lt;/code&gt; and run &lt;code&gt;update-grub&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;
Still, &lt;b&gt;be careful&lt;/b&gt;. Your GRUB installation may use slightly different settings. Verify that the &lt;code&gt;/etc/grub.d/35_helenos&lt;/code&gt; file looks okay, try to run it to see that it produces reasonable output before running &lt;code&gt;update-grub&lt;/code&gt;. Before rebooting double check &lt;code&gt;/boot/grub/grub.cfg&lt;/code&gt;.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4388866233575924745-3879437933850602994?l=vhotspur.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vhotspur.blogspot.com/feeds/3879437933850602994/comments/default' title='Komentáře k příspěvku'/><link rel='replies' type='text/html' href='http://vhotspur.blogspot.com/2011/02/adding-helenos-to-existing-grub.html#comment-form' title='Počet komentářů: 3'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4388866233575924745/posts/default/3879437933850602994'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4388866233575924745/posts/default/3879437933850602994'/><link rel='alternate' type='text/html' href='http://vhotspur.blogspot.com/2011/02/adding-helenos-to-existing-grub.html' title='Adding HelenOS to existing GRUB'/><author><name>Vojta</name><uri>http://www.blogger.com/profile/05500449254861905111</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4388866233575924745.post-6425007037917725590</id><published>2011-02-04T23:09:00.000+01:00</published><updated>2011-02-04T23:09:44.763+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='HelenOS'/><category scheme='http://www.blogger.com/atom/ns#' term='keyboard'/><category scheme='http://www.blogger.com/atom/ns#' term='USB'/><title type='text'>Hello from USB keyboard to HelenOS</title><content type='html'>&lt;p&gt;
I am proud to announce that today we were able to control HelenOS with plugged in USB keyboard. Although the abilities of the keyboard and host controller drivers are &lt;i&gt;very&lt;/i&gt; limited, it is a huge step forward in our project.&lt;/p&gt;
&lt;a name='more'&gt;&lt;/a&gt;
&lt;p&gt;
First, a bit about the limitations.
&lt;ul&gt;
&lt;li&gt;We have run it only in QEMU so far because the host controller driver is not yet in state where we can deploy it onto real hardware.&lt;/li&gt;
&lt;li&gt;The keyboard driver accepts only the boot protocol so far (the report protocols are really awful things to parse and process) and is not able to processes composed key sequences (e.g. &lt;code&gt;Shift+&amp;lt;key&amp;gt;&lt;/code&gt;) and has no knowledge of automatic key repeat etc.&lt;/li&gt;
&lt;/ul&gt;
&lt;/p&gt;
&lt;p&gt;
And before I forgot. We have problems with testing hub driver - we were not able to bridge real USB hubs to QEMU.&lt;/p&gt;
&lt;p&gt;Today, you can buy only hubs for USB 2.0 (or better) and although the hubs are backwards compatible (i.e. they support USB 1.1), QEMU refuses to connect them to its emulated UHCI because they are USB 2.0 hubs. And we do not know how to downgrade it. Thus we are looking for some older USB hub that supports only USB 1.1 (or some wizard who knows how to force QEMU to bridge host USB 2.0 hub through its UHCI controller). Doesn't anybody have such hub? Or the knowledge (we have quite a wide range of USB hubs to test with but they are 2.0)?&lt;/p&gt;
&lt;p&gt;
Now onto more positive stuff: if you want to try it out, get our branch
&lt;pre&gt;bzr branch bzr://helenos-usb.bzr.sourceforge.net/bzrroot/helenos-usb/development/ helenos-usb&lt;/pre&gt;
and compile it for &lt;code&gt;amd64&lt;/code&gt; or &lt;code&gt;ia32&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;
Running it is a bit trickier. Although one would expect that newer versions of some software are better than the old ones, this is quite not true with the QEMU emulator. Experimentally, we found out several differences between versions 0.13 and 0.11 and the version 0.11 came out better (the simulated keyboard is closer to the real hardware). So, if you want to try it with the emulated keyboard in QEMU, I recommend QEMU 0.11.1. If you trust us and want to try with real keyboard, it worked even with QEMU 0.13 (although I cannot confirm it now as I do not have a USB keyboard at home).&lt;/p&gt;
&lt;p&gt;
So, let's run it.
&lt;pre&gt;qemu-system-x86_64 -m 256 \
    -usb -usbdevice keyboard \
    -cdrom image.iso&lt;/pre&gt;
If you run it with QEMU 0.11.1, the AT keyboard is not disabled immediately but only after the USB one is properly initialized, so you can switch to virtual console 8 and watch what is going on. In QEMU 0.13, the AT keyboard is disabled once you leave GRUB, but you can switch the consoles with mouse. However, I recommend QEMU 0.11 (I experienced some very weird hung-ups with newer versions of QEMU).&lt;/p&gt;
&lt;p&gt;There is a lot of messages, but they should stop and you shall see image similar to the following:
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/_AiMVsO4Wllc/TUxxVU_2l4I/AAAAAAAABmQ/nScfRX6gd8c/s1600/helenos_usb.png" imageanchor="1" style="margin-left:1em; margin-right:1em"&gt;&lt;img border="0" height="250" width="320" src="http://2.bp.blogspot.com/_AiMVsO4Wllc/TUxxVU_2l4I/AAAAAAAABmQ/nScfRX6gd8c/s320/helenos_usb.png" /&gt;&lt;/a&gt;&lt;/div&gt;
If you see this, everything went fine and HelenOS is now controlled by the USB keyboard. Try pressing &lt;kbd&gt;F1&lt;/kbd&gt; to get into some free console and type &lt;code&gt;ls&amp;lt;Enter&amp;gt;&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;
You might encounter some problems described above, but on a very rough level, HelenOS is controllable by USB keyboard. Isn't that wonderful? &lt;i&gt;Of course it isn't&lt;/i&gt;, I hear you &lt;i&gt;there is still a lot of things to be done&lt;/i&gt; but, please, do not spoil this very special moment ;-).&lt;/p&gt;
&lt;p&gt;
Stay tunned for updates.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4388866233575924745-6425007037917725590?l=vhotspur.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vhotspur.blogspot.com/feeds/6425007037917725590/comments/default' title='Komentáře k příspěvku'/><link rel='replies' type='text/html' href='http://vhotspur.blogspot.com/2011/02/hello-from-usb-keyboard-to-helenos.html#comment-form' title='Počet komentářů: 0'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4388866233575924745/posts/default/6425007037917725590'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4388866233575924745/posts/default/6425007037917725590'/><link rel='alternate' type='text/html' href='http://vhotspur.blogspot.com/2011/02/hello-from-usb-keyboard-to-helenos.html' title='Hello from USB keyboard to HelenOS'/><author><name>Vojta</name><uri>http://www.blogger.com/profile/05500449254861905111</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_AiMVsO4Wllc/TUxxVU_2l4I/AAAAAAAABmQ/nScfRX6gd8c/s72-c/helenos_usb.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4388866233575924745.post-6756344091436535561</id><published>2011-01-06T01:04:00.000+01:00</published><updated>2011-01-06T01:04:12.871+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='HelenOS'/><category scheme='http://www.blogger.com/atom/ns#' term='IPC'/><category scheme='http://www.blogger.com/atom/ns#' term='cheatsheet'/><title type='text'>IPC cheatsheet for HelenOS</title><content type='html'>Sometimes as a last resort when debugging HelenOS you need to use the kernel console. If the problem has something to do with IPC, you will end deciphering the IPC communication with &lt;code&gt;ipc&lt;/code&gt; command. If you also do not remember that 1031 means request to VFS for file closing, you might find the following cheat sheet useful.
&lt;a name='more'&gt;&lt;/a&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/_AiMVsO4Wllc/TSUF0dMWQCI/AAAAAAAABmE/5HrT2auBlpk/s1600/cheatsheet_preview.png" imageanchor="1" style="margin-left:1em; margin-right:1em"&gt;&lt;img border="0" height="176" width="320" src="http://3.bp.blogspot.com/_AiMVsO4Wllc/TSUF0dMWQCI/AAAAAAAABmE/5HrT2auBlpk/s320/cheatsheet_preview.png" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;
In HelenOS, IPC methods are numbered and enums are used for these. That means that you cannot search the source code for particular number to find the method name. Thus, you would spent a lot of time counting what is the nth item to find out the name (to find out the corresponding handler). I had enough of that very soon. Thus I wanted to get a pencil and rewrite the names on a piece of paper. Well... I stopped even before writing down VFS methods because there are about 30 of them. So I decided to write a script for it...&lt;/p&gt;
&lt;p&gt;
The PDF I created can be downloaded &lt;a href="https://sites.google.com/site/vhotspur/ipc_cheatsheet.pdf?attredirects=0&amp;d=1"&gt;here&lt;/a&gt;. The list is definitely not complete but contains the methods I was dealing with.&lt;/p&gt;
&lt;p&gt;
If you think the cheat sheet might be useful to you to and you want to extend it, the &lt;a href="https://sites.google.com/site/vhotspur/cheatsheet.tar.gz?attredirects=0&amp;d=1"&gt;sources&lt;/a&gt; are available as well. I had them placed in &lt;code&gt;/contrib/tools&lt;/code&gt; but there is not strict rule about it. You only need to set the &lt;var&gt;PATH2ROOT&lt;/var&gt; variable in the Makefile when they are placed elsewhere.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4388866233575924745-6756344091436535561?l=vhotspur.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vhotspur.blogspot.com/feeds/6756344091436535561/comments/default' title='Komentáře k příspěvku'/><link rel='replies' type='text/html' href='http://vhotspur.blogspot.com/2011/01/ipc-cheatsheet-for-helenos.html#comment-form' title='Počet komentářů: 1'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4388866233575924745/posts/default/6756344091436535561'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4388866233575924745/posts/default/6756344091436535561'/><link rel='alternate' type='text/html' href='http://vhotspur.blogspot.com/2011/01/ipc-cheatsheet-for-helenos.html' title='IPC cheatsheet for HelenOS'/><author><name>Vojta</name><uri>http://www.blogger.com/profile/05500449254861905111</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_AiMVsO4Wllc/TSUF0dMWQCI/AAAAAAAABmE/5HrT2auBlpk/s72-c/cheatsheet_preview.png' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4388866233575924745.post-193368292148177780</id><published>2010-12-13T02:35:00.000+01:00</published><updated>2010-12-13T02:35:45.513+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='HelenOS'/><category scheme='http://www.blogger.com/atom/ns#' term='USB'/><category scheme='http://www.blogger.com/atom/ns#' term='hub'/><title type='text'>USB hub driver working</title><content type='html'>&lt;p&gt;
I would love to sing some ode right now because I just found a bug and get a working hub driver, but I am afraid that I would be dressed down by my father because it is half past 1am. So, hence this post to let the euphoria out ;-).&lt;/p&gt;
&lt;a name='more'&gt;&lt;/a&gt;
&lt;p&gt;
Today (well, yesterday) we had a "coding session" and our whole USB team worked on HelenOS/USB. As a result of this and previous meeting, we can announce some real progress.&lt;/p&gt;
&lt;p&gt;
First, we tried to tame the HID reports and tried to come up with compromise of simplicity vs. extensibility vs. finishability. Because of the complexity of HID reports in general, we ended (so far) with something very simple but it shall be sufficient for most USB keyboards (fingers crossed). We decided to simply search for the proper usage and usage page and ignore all the rest (see the incomprehensible USB HID specification for more details if you want to know what usage and usage page means). This shall work for keyboard but I am afraid that for rats this would be way to restrictive. We will see.&lt;/p&gt;
&lt;p&gt;
Next, actual work was started on the keyboard driver itself. So far, there was no use writing "blind" code when there was not possibility to connect the driver to some device. Writing the driver would also include hacking into console to enable more keyboards (simply, we can't allow to cut-off the standard keyboard). At first sight, it looks quite easy... Hopefully, the second sight would confirm that ;-).&lt;/p&gt;
&lt;p&gt;
And finally, we did quite a lot of work on the hub driver. That included hunting some bugs in the virtual host controller and studying USB specification (chapter 11) again and again to find out what is the correct behavior. Both virtual USB host controller and the hub driver needs some refactoring but they are able to communicate with each other, at least...&lt;/p&gt;
&lt;p&gt;
And if you plug in a virtual USB keyboard, the hub driver is actually able to detect the change on the port, enable the port and launch the proper driver. Applause expected ;-). All right, I know that after several months that is not that much but in the last weeks we are really accelerating and producing something that even works :-).&lt;/p&gt;
&lt;p&gt;
If you want to see it by yourself, you can try it. First, get sources from our development branch
&lt;/p&gt;&lt;pre&gt;bzr://helenos-usb.bzr.sourceforge.net/bzrroot/helenos-usb/development&lt;/pre&gt;
and compile it:
&lt;pre&gt;make HANDS_OFF=y PROFILE=ia32&lt;/pre&gt;
And then launch it in QEMU. And now be quick :-). Switch to console eight (&lt;code&gt;F8&lt;/code&gt;) and you will see &lt;code&gt;devman&lt;/code&gt; starting. You shall see that a driver called &lt;code&gt;vhc&lt;/code&gt; (for virtual host controller) is started. This driver immediately announces its child device, a root hub and assigns USB address 1 to it. And this root hub is driven by the hub driver.&lt;p&gt;&lt;/p&gt;
&lt;p&gt;
You will see that the hub driver first asks for hub configuration descriptors and then enables power on all ports (for testing, we reduced the number of ports to only 2). The VHC prints which USB transfers it processes and also status of the ports. You shall see that they start in &lt;code&gt;-&lt;/code&gt; (meaning not configured) and enters a disconnected state &lt;code&gt;X&lt;/code&gt;. The hub driver then periodically checks for the their change. It is time to plug in the virtual USB keyboard.&lt;/p&gt;
&lt;p&gt;
Switch to console one and type &lt;code&gt;ls /dev/devices&lt;/code&gt; to see also following lines, informing about existing virtual USB devices.
&lt;/p&gt;&lt;pre&gt;\virt
\virt\usbhc
\virt\usbhc\hub&lt;/pre&gt;
And now you can start the keyboard. Simply type &lt;code&gt;vuk&lt;/code&gt; (stands for virtual USB keyboard) and quickly get back into &lt;code&gt;devman&lt;/code&gt; console. You shall see that the port status of port 1 (yeah, ports are numbered starting at 1) changed to disabled (&lt;code&gt;D&lt;/code&gt;), quickly went through the resetting state (&lt;code&gt;R&lt;/code&gt;) and ended in enabled one (&lt;code&gt;E&lt;/code&gt;). Once it entered the enabled state, a new address was assigned to the device and device descriptors were queried to determine the device kind. It all ends with messages by &lt;code&gt;devman&lt;/code&gt;, announcing that new device was detected and that it searches for a proper driver.&lt;p&gt;&lt;/p&gt;
&lt;p&gt;
And driver is actually found and started. If you switch back to the console with &lt;code&gt;vuk&lt;/code&gt;, you will see that it reports some pressed keys and that the driver polls the device for its status. Isn't that great? And, of course, listing &lt;code&gt;/dev/devices&lt;/code&gt; reveals that a new device was added. The name is awful (something like &lt;code&gt;\virt\usbhc\hub\usb0x00017a00&lt;/code&gt;) but using device structure address was the simplest way to avoid name clashes...&lt;/p&gt;
&lt;p&gt;And that's all. Just do not look at the code ;-). It needs polishing. It needs a lot of polishing. Once we have done that I will definitely inform you about it and invite you to go through it ;-).&lt;/p&gt;
&lt;p&gt;
I hope the text makes at least some sense and that it is not full of grammatical and spelling mistakes. And I also hope that I have not offended anyone when writing &lt;i&gt;we&lt;/i&gt;...&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4388866233575924745-193368292148177780?l=vhotspur.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vhotspur.blogspot.com/feeds/193368292148177780/comments/default' title='Komentáře k příspěvku'/><link rel='replies' type='text/html' href='http://vhotspur.blogspot.com/2010/12/usb-hub-driver-working.html#comment-form' title='Počet komentářů: 0'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4388866233575924745/posts/default/193368292148177780'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4388866233575924745/posts/default/193368292148177780'/><link rel='alternate' type='text/html' href='http://vhotspur.blogspot.com/2010/12/usb-hub-driver-working.html' title='USB hub driver working'/><author><name>Vojta</name><uri>http://www.blogger.com/profile/05500449254861905111</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4388866233575924745.post-2688396642274613867</id><published>2010-11-29T01:04:00.000+01:00</published><updated>2010-11-29T01:04:47.574+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='HelenOS'/><category scheme='http://www.blogger.com/atom/ns#' term='USB'/><title type='text'>USB for HelenOS</title><content type='html'>&lt;p&gt;
Because I am also member of the team that wants to add support for USB to HelenOS and I have enough of programming, I decided to write few paragraphs about HelenOS/USB project...&lt;/p&gt;
&lt;a name='more'&gt;&lt;/a&gt;
&lt;p&gt;Disclaimer: text below is not an opinion of the whole team and shall not be taken literally. I am trying to make this post at least a bit fun to read ;-).
&lt;p&gt;
We are adding support for &lt;a href="http://www.usb.org"&gt;USB&lt;/a&gt; devices to &lt;a href="http://www.helenos.org"&gt;HelenOS&lt;/a&gt; as a part of &lt;a href="https://is.cuni.cz/studium/predmety/index.php?do=predmet&amp;kod=NPRG023"&gt;Software project subject&lt;/a&gt; and we officially started this month.&lt;/p&gt;
&lt;p&gt;
Because we just started, there is not much progress to report. Actually, we had first meeting several months ago, but it takes some time from first thoughts to written specification approved by the Software project committee.&lt;/p&gt;
&lt;p&gt;
However, we weren't refining the specification all the time. We were studying ahead the USB specifications to which our "product" must comply. Have you ever seen a USB specification? If no, then believe me that you have missed nothing. USB specifications consists of thousands of pages written in technical English by someone (actually, these specifications are always work of a group because solitary person would go crazy from writing it) with apparently no sense of humor. Not talking about different formatting conventions used in individual specifications.&lt;/p&gt;
&lt;p&gt;
Because of the huge scope of USB, our project goal is limited to USB&amp;nbsp;1.1 only and we are supposed to create a functional driver for USB keyboard (the official specification talks about HID keyboard but we all hope that it does not mean that we need to implement the whole HID specification which is very long and includes support for such items as gloves for virtual reality software). Also, priority is a static configuration (i.e. no hot unplug).&lt;/p&gt;
&lt;p&gt;
So, to sum it up, at the end we want to present HelenOS as an OS that is usable with keyboard attached by USB wire. This sounds that it is not much but because HelenOS has no support for USB at all, we are actually starting at zero and want to end with something that both developer and ordinary user can appreciate (well, for HelenOS, these are identical but that is not the point).&lt;/p&gt;
&lt;p&gt;
But back to our progress I promised to inform you about. In three words, "we are fighting". With what? Luckily, so far, not among ourselves. But there are couple of things we need to get familiar with.&lt;/p&gt;
&lt;p&gt;
First, we are fighting with &lt;a href="http://bazaar.canonical.com/"&gt;Bazaar&lt;/a&gt;: it is something different that &lt;a href="http://git-scm.com/"&gt;Git&lt;/a&gt; or &lt;a href="http://mercurial.selenic.com/"&gt;Mercurial&lt;/a&gt; and the worst thing is different terminology and different command naming.&lt;/p&gt;
&lt;p&gt;
Next, we are fighting with HelenOS itself. It is simply different system than Unix or Windows and getting used to it needs some time. The difference includes the microkernel design in general, asynchronous IPC or fibrils. Plus limited functionality of libraries.&lt;/p&gt;
&lt;p&gt;
And, of course, we need to unify our coding styles and start writing according to the conventions used in HelenOS. Currently, we are in the phase so common among programming enthusiasts (after all, why we have HelenOS ;-)?): "I do not want to read this (ugly) code, I can do it better by myself" and "my coding style supersedes everything written so far in this file". In this, I am the "enforcer" because I am already past that phase. I had to fight with that months ago when I started working on NUMA ;-).
&lt;p&gt;
We decided to use the device driver framework and currently we are fighting with it as well. I believe that using the DDF is a good step in general although right now we are a bit confused. I guess we all expected that it would do more (and that we would not need to touch it at all). We already encountered some problems that might be bugs in DDF. Or maybe we only botched-up something on our side. As soon as we find out where the problem actually is and if it is really in DDF, we will report to the mailing list.&lt;/p&gt;
&lt;p&gt;Okay, I hear you ;-). You want to know whether we actually wrote some code or we are only grunting and swearing. So here is our "coding" progress.
&lt;p&gt;
We have a very simple mini-framework for creating virtual USB devices to allow testing USB drivers. Currently, it pretends work of host controller with single hub and plugged-in keyboard.&lt;/p&gt;
&lt;p&gt;
We are now working on generic framework (built above DDF) for creating host controller and hub drivers that will first operate above the virtual host controller. Other efforts, running in parallel, are implementation of UHCI driver and keyboard driver with fixed (i.e. built into the source code, not read dynamically) descriptors. If you have no idea what descriptors I mean, lucky you. Descriptors are way how USB device for human input informs the host about the items it reports (e.g. whether it reports pressed keys or joystick button status or finger bend) and are very generic and the specification is simply awful (I guess it is in English by used prepositions but I am not 100% sure).&lt;/p&gt;
&lt;p&gt;
And last success is that we are getting used to having "programming sessions" each week where we meet and code together (and we are even having fun there).&lt;/p&gt;
&lt;p&gt;
And that's all. I hope I haven't omitted something and haven't insulted anyone. I will try to inform about our progress regularly. If this source is not enough (or you simply don't like my style of writing or whatever), you can follow our activities at our &lt;a href="https://sourceforge.net/apps/trac/helenos-usb/wiki"&gt;Trac&lt;/a&gt;...&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4388866233575924745-2688396642274613867?l=vhotspur.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vhotspur.blogspot.com/feeds/2688396642274613867/comments/default' title='Komentáře k příspěvku'/><link rel='replies' type='text/html' href='http://vhotspur.blogspot.com/2010/11/usb-for-helenos.html#comment-form' title='Počet komentářů: 2'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4388866233575924745/posts/default/2688396642274613867'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4388866233575924745/posts/default/2688396642274613867'/><link rel='alternate' type='text/html' href='http://vhotspur.blogspot.com/2010/11/usb-for-helenos.html' title='USB for HelenOS'/><author><name>Vojta</name><uri>http://www.blogger.com/profile/05500449254861905111</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4388866233575924745.post-7915366756221771287</id><published>2010-11-23T10:52:00.018+01:00</published><updated>2010-11-23T12:57:14.454+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='NUMA'/><category scheme='http://www.blogger.com/atom/ns#' term='HelenOS'/><title type='text'>Support for NUMA in HelenOS</title><content type='html'>&lt;p&gt;
Because it will be almost 6 months since I started flirting with the idea to base my thesis on HelenOS somehow, it is time to report some progress.&lt;/p&gt;
&lt;a name='more'&gt;&lt;/a&gt;
&lt;p&gt;
Actually, there are two reasons for this post. First, I think that something has been implemented and it is time to tell the community about it. And also I feel guilty after JS and JJ complained that they feel lack of communication from students participating on &lt;a href="http://www.helenos.org/"&gt;HelenOS&lt;/a&gt;. So here you have it ;-).&lt;/p&gt;
&lt;p&gt;
First about &lt;b&gt;intended goal&lt;/b&gt; and &lt;b&gt;target platform&lt;/b&gt;: my work is aimed at supporting &lt;a href="http://en.wikipedia.org/wiki/Non-Uniform_Memory_Access"&gt;ccNUMA&lt;/a&gt; (cache coherent NUMA) hardware on platform &lt;code&gt;amd64&lt;/code&gt; (this is represented e.g. by servers with Opteron processors on NUMA capable motherboard). More precisely, my work is targeted at such (hardware) NUMA configurations where HelenOS is able to run without any NUMA support at all. This means that the address space is continuous across individual nodes and the node boundary is transparent to the OS (i.e. information about memory distribution on the nodes is obtained through other channels and is not necessary for correct memory usage and management), the same for CPUs and also that the hardware does not require any special instructions to ensure cache coherency. And, of course, the main goal is to defend my diploma thesis about making HelenOS NUMA-aware. My supervisor for the thesis is Mr. Děcký.&lt;/p&gt;
&lt;p&gt;
Now, a few words about &lt;b&gt;simulators&lt;/b&gt; I use for development (so far I have not tried to run HelenOS on physical NUMA hardware). Most of the time, I use &lt;a href="http://qemu.org/"&gt;QEMU&lt;/a&gt; which is able to simulate NUMA machine, using the &lt;code&gt;-numa&lt;/code&gt; switch. Because it took me some time to understand the syntax of this switch, I post here example command that launches machine with 8 CPUs and 512M of memory, both CPU and memory distributed evenly on 4 nodes:
&lt;pre&gt;qemu-system-x86_64 -m 512 -smp 8 \
        -numa node,mem=128,cpus=0-1 \
        -numa node,mem=128,cpus=2-3 \
        -numa node,mem=128,cpus=4-5 \
        -numa node,mem=128,cpus=6-7 \
        -boot d -cdrom ./image.iso&lt;/pre&gt;
Second simulator I sometimes use is &lt;a href="http://developer.amd.com/simnow/"&gt;SimNow&lt;/a&gt; created by AMD which allows you to build interactively your own machine (including configuration of low level stuff such as northbridges and various other controllers) and run it. The downside is that the simulator is very precise (in the detail of the simulation) and thus extremely slow.&lt;/p&gt;
&lt;p&gt;
So, this was a bit of the background of the work and now about what was actually added to the source codes of HelenOS. My branch is registered at &lt;a href="https://code.launchpad.net/%7Evojtech-horky/helenos/numa"&gt;Launchpad&lt;/a&gt;, under HelenOS team as &lt;code&gt;numa&lt;/code&gt; branch:
&lt;pre&gt;bzr branch lp:~vojtech-horky/helenos/numa&lt;/pre&gt;
If you want to try it, go ahead: check out the branch and in the configure dialog select &lt;code&gt;amd64&lt;/code&gt; from the preconfigured defaults and do not forget to check the &lt;code&gt;NUMA support&lt;/code&gt; option (I added several other options which are useful for debugging, I will remove them later). However, do not be disappointed after the machine boots up. There is nothing shiny and new to be seen - all changes are quite low level and currently the only way to see them is to try the &lt;code&gt;numa&lt;/code&gt; application in &lt;code&gt;/app/&lt;/code&gt; directory.&lt;/p&gt;
&lt;p&gt;
That was the theoretical background. Now a brief summary about what is actually implemented.&lt;/p&gt;
&lt;p&gt;
First of all, the &lt;b&gt;hardware detection&lt;/b&gt; uses ACPI tables (&lt;code&gt;SRAT&lt;/code&gt; and &lt;code&gt;SLIT&lt;/code&gt;) and assigns to each CPU node id (node index). With memory, it is a bit more complicated. I decided not to add any other layer above existing zones (because that would mean changing a lot of code and, furthermore, each node is usually formed by single zone) and only split zones that run across node boundaries. On AMD64, this typically means that only on the first node is memory split into several zones (some of them are reserved) and all other nodes have only single zone. And that is actually all. There were several problems when to read the topology information from ACPI (I might write about it later), but it works now pretty well.&lt;/p&gt;
&lt;p&gt;
Next, I made some changes to kernel &lt;b&gt;slab allocator&lt;/b&gt;. Here, I decided to add extra layer to the &lt;a href="http://en.wikipedia.org/wiki/Slab_allocation"&gt;allocator&lt;/a&gt; (if you want to know the details of the implementation of the allocator, the one in HelenOS is very similar to the one introduced by Jeff Bonwick), that groups the magazines of CPUs of the same node. This is, of course, enabled only in NUMA build (&lt;code&gt;#ifdef&lt;/code&gt;s are used). So far, I have not done any benchmarking so I cannot report whether the change was worth the effort.&lt;/p&gt;
&lt;p&gt;
To allow more precise thread placement on nodes, I added support for &lt;b&gt;thread affinity&lt;/b&gt;. It is nothing extra: each thread has bitmap of CPUs where setting/clearing bit allows the thread to run on respective CPU. The load balancer respects this setting and when the scheduler finds out that it is supposed to schedule thread that cannot run on current CPU, it migrates it away. By default, the thread can run on all CPUs.&lt;/p&gt;
&lt;p&gt;
For address space areas, I added similar thing plus something that could be called &lt;b&gt;allocation policy&lt;/b&gt;. The affinity for AS areas determines from which nodes could be allocated frames that back the area. And the policy specifies how the allocation shall be done. So far, there is &lt;i&gt;first touch&lt;/i&gt; (default, allocate from node where is currently running the thread that caused the fault-in) and &lt;i&gt;interleave&lt;/i&gt; (allocate from all nodes in the affinity mask evenly, with precise ordering).&lt;/p&gt;
&lt;p&gt;
Last thing in kernel is &lt;b&gt;automatic page migration&lt;/b&gt; (by the way, this is something I am really looking forward to measure). What is it about in a few words? When a thread is migrated on UMA system, its distance to the memory is not changed. However, when it is migrated to different node on NUMA system, it suddenly has the memory much farer. So, obvious remedy is to migrate the memory as well. However, copying huge amount of memory takes some time and it also may not be the best solution for multi threaded programs. Thus, I implemented something that could be called lazy migration: the pages are simply marked as not present and when they are accessed, the are migrated if necessary. As I stated at the beginning of this paragraph, I am very itchy about this and I will definitely write about this more.&lt;/p&gt;
&lt;p&gt;
And that is all for the kernel side. Still is missing some better load balancing that respects the fact that it is more expensive to migrate thread to different node. And, of course, I need to do some benchmarking. That will be real fun because I do not have many ideas how to create fair benchmarks that would measure performance gains and losses when the difference between accessing local and remote memory is almost imperceptible.&lt;/p&gt;
&lt;p&gt;
For userspace, there is almost complete port of &lt;b&gt;libnuma API&lt;/b&gt; (&lt;a href="http://oss.sgi.com/projects/libnuma/"&gt;the one from Linux&lt;/a&gt;). The implementation was written from scratch, but the &lt;a href="http://manpages.ubuntu.com/manpages/intrepid/man3/numa.3.html"&gt;API&lt;/a&gt; shall be compatible with the Linux version. There are, of course, some changes due to fact that Linux expects process tree (i.e. the relation parent/child process is well defined and widely used) but the core works. If you want to see it, the already mentioned &lt;code&gt;numa&lt;/code&gt; application has several tests and samples to show what is ready. What is still missing is port of the &lt;code&gt;numactl(1)&lt;/code&gt; that is used to set policies and affinities of new tasks. The problem is again that it expects &lt;code&gt;fork()&lt;/code&gt;/&lt;code&gt;exec()&lt;/code&gt; style of launching new tasks. This will be probably solved by adding some optional methods to the loader.&lt;/p&gt;
&lt;p&gt;
Uff, that is all for now. I will try to write some kind of "progress report" on regular basis.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4388866233575924745-7915366756221771287?l=vhotspur.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vhotspur.blogspot.com/feeds/7915366756221771287/comments/default' title='Komentáře k příspěvku'/><link rel='replies' type='text/html' href='http://vhotspur.blogspot.com/2010/11/numa-support-for-helenos.html#comment-form' title='Počet komentářů: 1'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4388866233575924745/posts/default/7915366756221771287'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4388866233575924745/posts/default/7915366756221771287'/><link rel='alternate' type='text/html' href='http://vhotspur.blogspot.com/2010/11/numa-support-for-helenos.html' title='Support for NUMA in HelenOS'/><author><name>Vojta</name><uri>http://www.blogger.com/profile/05500449254861905111</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry></feed>
