Mikrotik RB532 - single user mode.

Today I managed to get shell prompt on Mikrotik’s Routerboard 532. So now we have 3 platforms with single user mode for FreeBSD/mips, not very useful :) The last problem was getting high-level console interface working. I always fell lost when it comes to resource allocation and uart stuff. I should write a couple of posts on these subjects to memorize all details better.

December 1, 2007 · 1 min · 64 words · Oleksandr Tymoshenko

INTR_FAST and selwakeup

I stumbled over this problem a couple of years ago, ignored it, was punished for my carelessness, came out with hackerish solution and now I know “The Right Way” to solve this issue. So, the headache starts when you’re trying to wakeup userland application polling on a descriptor from INTR_FAST IRQ handler (for 7.X and later that would be interrupt filter). INTR_FAST/interrupt filter routines are usually used for timing-critical tasks and run in IRQ dispatcher context, so no operations that may cause context switch are allowed in this code. Unfortunately selwakeup(9) tries to acquire sellock that leads to a possible context switch and leaves us in a total mess. My solution was handmade kernel thread that has been running through list of channels and performed all dirty work, not the cleanest and easiest to maintain code. “Zaptel-bsd take 2” utilizes taskqueue(9) interface to work around IRQ handler limitations. There is handler routine: ...

November 25, 2007 · 1 min · 211 words · Oleksandr Tymoshenko

Module/kernel parameters

Sometimes it’s desirable to pass some arguments to module to customize its behavior, e.g.: to set/unset verbosity level of debug output, set operation mode etc… Linux modules can get this information from insmod utility, but kldload is not capable of doing such kind of things. What a pity. But don’t get desperate - tunables to the rescue! Just like an ordinary command shell (bash, csh, sh) kernel has its own environment, the set of <name, value> pairs. You can get, set, test, unset these variables using getenv, setenv, testenv, unsetenv functions in the kernel and kenv(2) syscall or kenv(1) command in userland. So if you want to set verbosity level for module, you would do something like this: ...

November 20, 2007 · 2 min · 286 words · Oleksandr Tymoshenko