Home
Old fashioned S010

http://www.s010.lv/  ]
userinfo  ]
calendar  ]
friends  ]

01 Jul 2009|11:09pm
Will answer on weekend, too busy/tired...
post comment

Mou KaKaLLIku <3 01 Jul 2009|11:19am

tnamed

Aka trivial name daemon. I can never remember what IP addresses comps on my LAN have, an obvious solution is to add ip->hostname mappings to /etc/hosts file. But wtf, the computer should make my life easier not add more problems. And then you'll have to use static IP addresses or tell DHCP server to always assign the same IPs for certain MACs.

When you run tnamed, it:

  1. acquires the list of IP address that the machine has
  2. for each of the IP addresses, it broadcasts to the subnet 255.255.255.0 a message telling that it's located at that IP address :D Makes no sense, right? Example: a machine has a hostname of "slowpoke" and IP addresses 192.168.0.1, 89.191.97.180, then it will broadcast a message "slowpoke@192.168.0.1" to every host in 192.168.0 and "slowpoke@89.191.97.180" to every host in 89.191.97
  3. It then broadcasts a request for other hosts to announce themselves to the subnets the computer is connected to
  4. Then it goes into an endless loop waiting for incoming messages; when it gets a request to announce self, it does (1); when it gets other host's announcment, it adds an entry to /etc/hosts file
    The hosts file may look something like this after tnamed:
    127.0.0.1 slowpoke # Following entries added by tnamed 192.168.0.11 x2 192.168.0.10 d400
  5. When you kill tnamed, it restores the original /etc/hosts file

tnamed is intended as a zero-configuration daemon, it doesn't need any conf files or command line options. To use it, simply run it from root, on all the participating machines.
Say, you have three machines on you LAN, "host1", "host2" and "host3". Run tnamed on each of the comps. And then, being logged in on one of these comps, you can address the other two by names, liek ping host2

http://s010.lv/files/tnamed.c -- current version is somewhere like 0.5, the code is a little rough and I have one other thing I want to add for great justice =)

On BSD, compile like cc -DBSD -o tnamed tnamed.c, on linux, simply cc -o tnamed tnamed.c

lstree

s@slowpoke:0:~/src/svn/my/utils$ ./lstree -h List files and directories in a fancy way. usage: lstree [-d] [-m ] [-t ] [path1 path2...] -z -- reverse sort order -d -- show directories first -m -- max depth (inf. by default) -t -- tabulation string (four spaces by default) -F -- display a char denoting file's type -g -- draw a compact pseudo-graphics tree (-d implied) -G -- draw a pseudo-graphics tree (-d implied)

Example output:
s@slowpoke:0:~/src/svn/my/utils$ ./lstree -g -F op op/ `-.svn/ | `-prop-base/ | `-props/ | `-text-base/ | | `-INSTALL.svn-base | | `-LICENSE.svn-base | | `-Makefile.in.svn-base | | `-README.svn-base | | `-configure.ac.svn-base | | `-op.conf_example.svn-base | `-tmp/ | | `-prop-base/ | | `-props/ | | `-text-base/ | `-entries | `-format `-src/ ...

http://s010.lv/files/lstree.c

shell2

Continuation of http://0x1392.livejournal.com/138681.html.

This is now a real command interpreter in that it actually parses the line entered, builds a parse tree and then executes the tree. Supported operators are

&&
AND operator, same as in common shells
||
OR operator, same as in common shells
;
execute mutliple commands in one line
&
execute in background
><
suppress any kind of output (stdout and stderr); liek stfu! ><
>
redirect stdout to file
^>
redirect stderr to file
>>
append stdout to file
<
redirect stdin from file
!
NOT operator, for use with AND and OR

Example run:
s:/home/s/src/svn/my/misc/shell$ ls asd && ls / AND EVAL ls asd EVAL ls / trav_tree(): pid=17910 trav_tree(): pid=17910 ls: asd: No such file or directory s:/home/s/src/svn/my/misc/shell$ ls asd || ls / OR EVAL ls asd EVAL ls / trav_tree(): pid=17910 trav_tree(): pid=17910 ls: asd: No such file or directory trav_tree(): pid=17910 altroot bin boot bsd bsd.rd dev etc home mnt root sbin stand sys tmp usr var s:/home/s/src/svn/my/misc/shell$

http://s010.lv/files/shell.c, compiles like cc -lreadline -lcurse -o shell shell.c

clock.sh

Sort of a screen saver for console. Displays a clock which moves around the screen and bumps off the walls. Most interesting feature -- written in shell.

Screenshot of an xterm window:
Free Image Hosting at www.ImageShack.us

http://s010.lv/files/clock.sh

4 comments|post comment

29 Jun 2009|10:35pm

Image Hosted by ImageShack.us

I think I'm very close to solving this mystery of why CardBus doesn't work as it should on my laptop.

Let's go over this again.

The PCI bus is a hierarchical bus. Child PCI busses may connect to parent PCI bus. And the PCI bus may connect to the host bus (the bus that interconnects CPU, memory and north bridge; although actual topology may greatly vary). The device which interconnects master bus and slave bus is called a PCI bridge. In order for the PCI bridge to function, that is to transport messages sent from master bus to devices located on the slave bus, it must be programmed with three bus numbers, which it uses to identify messages and decides whether to propagate them further or not. There are three such bus numbers that must be programmed into bridge: master bus, slave bus and subordinate bus number. Master and slave bus number are more or less clear I think, as for the subordinate bus number -- I'll explain on an example: if PCI bridge is programmed with master bus number of 1, slave bus number of 2 and subordinate bus number of 4, then when it sees a message for the second bus, it kinda takes it for itself, if it sees a message for bus 3 or 4, it propagates the message further down the hierarchy of busses, if it sees a message for a bus with number greater than 4, it doesn't take it for itself and doesn't propagate it further.

The problem with my laptop was that after the boot, the CardBus PCI bridge wasn't programmed with the correct bus numbers and so it didn't work. From the pcibios man page (see previous post), I found out that it's actually quite common and that OBSD has some measure against this. This meant that either this measure just didn't work on my laptop or it somehow wasn't activated.

After tinkering with OpenBSD's kernel source code for an hour or two, here's what I found out.
The measure OBSD has -- is simply renumbering the whole PCI hierarchy. The code to do this is part of the pcibios(4) driver and is located in http://www.openbsd.org/cgi-bin/cvsweb/src/sys/arch/i386/pci/pci_bus_fixup.c?rev=1.9. At first I thought that maybe it doesn't work, but later I discovered that when the bios(4) driver finds and "attaches" the acpi(4) it disables the "attachment" of pcibios driver, and because of that, the pci_bus_fixup() function is never executed and the CardBus bridge is never programmed properly. So for now, I made it so that pcibios is attached if it's found regardless of presence or absence of acpi.

Now the question is why does the kernel do that? Is it like if comp has acpi than acpi should've set everything up for the OS during POST? If so, then I may have a buggy acpi implementation in my laptop.

I think I've never posted dmesg from my laptop before, so here it is:

dmesg )
post comment

29 Jun 2009|01:30am

Haha, I should RTFM more often~

I think I found the answer to my question, about whether it was my laptop BIOS' fault or OpenBSD kernel's fault, that the CardBus bridge (~= the slot where you insert PCMCIA cards in your laptop) wasn't being assigned a correct parent bus, bus and subordinate bus numbers. It appears that they both are guilty.

From OpenBSD's pcibios(4) man page:

Ideally, the boot firmware of a machine (a.k.a. BIOS) should set up all PCI devices; assigning them I/O and memory addresses and interrupts. Alas, this does not always happen, so there is some PC specific code that can do the initialization when OpenBSD boots. ... 0x0002 Fixup PCI bus numbering; needed for many cardbus(4) bridges. Each PCI bus and CardBus should have a unique bus number. But some BIOS implementations don't assign a bus number for subordi- nate PCI buses. And many BIOS implementations don't assign a bus number for CardBuses ... Without this flag force assignment of bus numbers for all subor- dinate PCI buses and CardBuses.

So my BIOS is one of those who don't assign proper bus numbers to CardBus bridges. And OBSD's kernel seems to have a mechanism to solve this problem but it doesn't work on my laptop for some reason.

Seems like I won't be bored tomorrow evening.

You know, it's really fascinating. To be messing with an operating system's kernel. I think that writing/developing operating systems is one of the most interesting tasks out of all that there can be in programming.

1 comment|post comment

29 Jun 2009|12:03am
PRing for great justice and fascination!



More pics like this: http://darth-biomech.livejournal.com/189324.html#cutid1

Also, http://en.wikipedia.org/wiki/Life_After_People.
6 comments|post comment

Longpost 28 Jun 2009|02:17am

At first, Vista seemed to be a, hell, I'd even say a good OS, but as I used it more and more, I got completely disappointed in it. It's slow, resource-hungry, nothing works in it (64bit version at least) as it's supposed to (older software, like games), hard drive activity 24/7, and all this for the damn Aero interface, and the ability to search for files more easily? Pff. In the end, I installed Windows XP on the second drive, and stopped booting into Vista at all.

But recently, I've kinda been tending to unixen more. I dunno. I feel a bit uneasy in Windows.. And there's always something that distracts me (games xD). And to be honest, I don't see anything good in the future Windows world. Windows is becoming an increasingly more hostile environment for computer enthusiasts. I can't even log in under Administrator account on my Vista. What the fuck. In soviet Vista, computer administers you!

On the second hard drive, I also had OpenBSD 4.5 installed, and I wouldn't spend so much time in Windows if it wouldn't be for this one problem.

There is a so called "open source" driver for NVidia videocards for the X Window system, called nv, which is maintained by one of NVidia's employees. So called because this driver is basically made of standard X.org video driver code and magic numbers. See for yourself (G80InitHW()). NVidia doesn't provide any documentation for their chips. Which means that even though the driver is open source, you can't make any significant changes to it or add new device support because there's no documentation.
I have a motherboard based on GeForce 8300 chipset, with a built-in GPU (you should be able to work out the model), and guess what? It's not supported by the nv driver. It works fine with all the acceleration (XAA namely) turned off on a CRT, but it doesn't on LCD. I have an HD LCD monitor.

At first I thought that I'll be able to get my 1920x1080 panel working by modifying the "nv" driver. But after a brief poking, I understood that it's all useless, see above.

Then there is the "vesa" driver which is quite awesome btw! Because it provides good speed (try Option "NoAccel" True some time, you'll know what I'm talking about...) and works on all, even really old videocards.
But it would sets a resolution of 1280x720 (one of the standard VESA ones), and I've been tinkering with it's source code for a few days with no luck, because I just don't have all the required knowledge or perhaps because it's impossible.

So after a long battle, I gave up and installed Fedora Linux on my main comp.

I can't say I'm particularly fond of Linux, and I'm especially not fond of this "open source" kernel + binary drivers model, but hey! Everything's better than being forced to use Windows.

So now I have OpenBSD only on my laptop and my home server. Speaking of which, I recently upgraded my server, it's now a Pentium 3 866 on a i810, with 64 MB RAM and 20 GB hard drive. My mom's computer, lol. I assembled her a new one, more powerful (Celeron 1200 on i815, 256 RAM, Riva TNT 2 M64 32MB). I also bought a wireless card, and made the server into a free public Internet access point. If we all open up our access points, then we may live up to the day when Internet will be accessible anywhere, anytime and at no cost. And I also don't see any real point in closed access points. It doesn't increase security, I think. Only gives you a false feeling of security.

Proof screenshot:

Free Image Hosting at www.ImageShack.us

Btw check out the awesome software management program! Select software category, pick the programs you want and then just click apply. *snap* Simple as that.

29 comments|post comment

MISSION ACCOMPLISHED 24 Jun 2009|07:52pm
Finished Half-Life 2. Proofpic:
spoilers )

Overall, I liked it, but yeah, HL2 can beat the original game only in graphics. It's short, not as challenging, and it concentrates on the player. I think this is a big mistake. The game should't even pay attention to player, it should live by it's own laws, it should be self-sufficient, only then I think you can really submerge into that world and take it for reality.
The levels were good for the most part, especially the hover-craft ones in the beggining, but they were too, once again, player oriented. Kinda unrealistically convinient for the player, and too restricted in a really obvious manner.
8 comments|post comment

Better late than never... 22 Jun 2009|11:39pm
Whew! I'll probably have nightmares tonight because I just got out of Half-Life 2 after.. hell knows how many hours of playing o_O

For most people it's old news, but WTFOMGOMG look at the graphics, OMG that water is even better than the real one WTF! ><

Free Image Hosting at www.ImageShack.us Free Image Hosting at www.ImageShack.us Free Image Hosting at www.ImageShack.us

Free Image Hosting at www.ImageShack.us Free Image Hosting at www.ImageShack.us Free Image Hosting at www.ImageShack.us

Free Image Hosting at www.ImageShack.us Free Image Hosting at www.ImageShack.us Free Image Hosting at www.ImageShack.us

(Tsk, should've taken more photos screenshots of City 17, but I didn't know where the button was and I was too busy picking up my jaw from the floor every minute~)

HL2 is 5 years old, that's like a millenia in computer world, so I'm afraid to even imagine what current games look like...
Maybe I should buy some high-end video card just for lulz, to see how ridiculously realistic computer games have become.

And I think I'll really do it, somewhere in autumn, because of Operation Flashpoint: Dragon Rising. Although I'll be sure to play the demo first, because the game is being developed by Codemasters, not Bohemia Interactive, the makers of the original game.

I thought it was over with games for me, but no. It's not as exciting as it used to be, but I need to play games. I love playing games T___T

Btw, some time ago, I finished two games almost simultaneously: Max Payne and Call of Duty.
Also, I must be close to finishing GTA 3, I "opened" the third part of the city today ^_^

Max Payne: well, it's a really good game, fun to play (ITS' BULETT TIEM!!), and some of the levels are just pure genius! But I didn't quite like something about the style and atmosphere, not sure what. Although, now that I played Max Payne 2, I realize that I miss old Payne and actually like the first game very much.

Call of Duty: wow. Just WOW. This is the most cinematic game I've ever played, and it also has the best sound effects/environment (the only game I can think of which does that kind of effect on you with sound is Thief).
During some moments, the game just swallows you, it's like you're really there, on the battlefield... There are some things that add some bitterness to the taste of this game, but they're nothing compared to it's pluses. Awesome game.
13 comments|post comment

A small step for humanity and a huge leap forward for a man 17 Jun 2009|02:49am
indescribable

A remarkable thing just happened.

I fixed OpenBSD's kernel.

Here's the story.
Somewhere during the late Autumn, I bought a used laptop, DELL Latitude D400. It had a built-in (well, I mean a Mini-PCI) WiFi card, an Intel PRO/Wireless 2100. This card is a 802.11b card only, which is not very cool.
But I had another, PCMCIA WiFi card, left from my old laptop, a Ralink 2500 which is 802.11a/b/g. So naturally I decided to use it instead of the built-in one, but when I inserted the card, a message would appear in kernel's log, saying that 'CardBus support disabled'. At first I thought that it was the cards fault, but it worked fine in the old laptop (which as funny as it is was running OpenBSD too). Then I decided to look into the kernel's source code to try to figure out what's wrong. I did, but at that time I didn't understand much, and left it for better times.

The we had a course in university, Microprocessors and embedded systems, which influenced me quite a bit. Maybe I gained a critical mass of knowledge or smthn~
So a few days ago I decided that this is a delicious challenge. I must take it.
And I dived into the source code again. I read osdev.org's (btw this is a delicious site, you must visit it) wiki about PCI bus and some articles that it links to. I read about the autoconfiguration in BSD kernels in the book called The Design and Implementation of 4.4 BSD Operating System, finally I read kernel sources over and over again, until I finally got it.

The problem was that a PCI-to-CardBus bridge must be programmed with it's subordinate, secondary and primary bus numbers. This is done by writing the appropriate registers in the PCI configuration space.
During the autoconfiguration, the kernel would find the PCI-CardBus bridge, Texas Instruments 7510, and would see that it's subordinate, secondary and primary buses are all set to 0 which is invalid, so it would disable CardBus.
I'm still researching this whole PCI bus thing so I'm not sure who's fault this is exactly, the kernel's or the hardware's.
But I suspect that machines BIOS should ideally configure all the PCI devices and bridges during the boot, but for some reason, the BIOS doesn't program this CardBus bridge. Again, this is just a guess.

The trivial patch:
tmpreg = pci_conf_read(0, pa->pa_tag, 0); if (PCI_PRODUCT(tmpreg) == PCI_PRODUCT_TI_PCI7510_CB) { busreg = (pcireg_t) (0x20 << 24) | (0x2 << 16) | (0x2 << 8) | (0x1); pci_conf_write(0, pa->pa_tag, PCI_BUSNUM, busreg); }

In human language this reads:
if (we are dealing with TI 7510 PCI-CardBus bridge) {
program it with hard-coded values
}

A real, non trivial, correct patch will depend on who's fault this is hardware's or kernel's, which is what I'm going to find out.

post comment

Dreams coming true 16 Jun 2009|11:20am
inspired

Image Hosted by ImageShack.us

The moment I learned about the 80's 8-bit home computer era, I always wanted to acquire one of the computers of that time, to touch the history, feel what computing was like in the Golden Age.

There is a magical aura that surrounds that period of time. Computers were something new, unexplored, everything seemed possible. It was the beggining of something great, something that would eventually change the world as we know it. Using a computer, programming it, was more like an adventure, a journey into the unknown. I'm not saying computers aren't fun nowadays, but we're much more used to them now.

So yesterday I bought a Commodore 64 on eBay. Can you believe that? A. COMMODORE. SIXTY. FOUR. GAWD.
So in a few weeks, I will turn this machine on and see white characters on a blue background: **** COMMODORE BASIC V2.0 ****. Then I will write a Hello, world! program and after that, I will play games! v^_^

Btw, I believe that C64 makes you a better programmer just by owning it.

Wikipedia page
64 minute talk/article about C64 @ pagetable.com
Martin Galway - Comic Bakery, one of the most famous chiptunes of all time, came from C64
Image Hosted by ImageShack.us
Bender has (will have?) a 6502 installed as his brain, the same chip that C64 uses

14 comments|post comment

12 Jun 2009|05:39pm
Some time ago I threw away my crippled, old laptop. It had no display, had a badly damaged keyboard and motherboard (which is why the second RAM slot burnt out taking the RAM module out too and which is why the battery wouldn't charge anymore). But it was still perfectly usable with an external keyboard and monitor, and remotely, through SSH.
Tsk, it would be sooo useful to me right now to figure some things out...
post comment

11 Jun 2009|01:41pm

Some currency codes:

ALL - Albania AOK - Angola BSD - Bahamas CRC - Costa Rica CUP - Cuba DOP - Dominican Republic LUF - Luxembourg MAD - Morocco MNT - Mongolia MUR - Mauritius NIC - Nicaragua SIT - Slovenia SOS - Somalia TOP - Tonga


Matt Groening is quoted as saying, 'We're thrilled Futurama is coming back. We now have only 25,766 episodes to make before we catch up with Bender and Fry in the year 3000.'

LOL!

post comment

42 04 Jun 2009|07:41pm
It's everywhere. All of the docs on programming written in the past couple of years contain this number. I think it has become almost as much of a tradition as "Hello, world!".

It's a good number. Both of the digits are powers of two and 4*2 == 8, which is a power of two too (like it could've not been a power of two.. xD) and it is also the most common number of bits in a byte, and 2, 4, 8 are subsequent weights of three adjacent bits 1-3 (counting from 0) of a byte.

In Hitchhiker's Guide to Galaxy, 42 was presented as The Ultimate Answer. Seeing how strongly 42 is tied with computers -- we may conclude that the answer to life the universe and everything are actually computers.
5 comments|post comment

02 Jun 2009|04:02pm
ELECT * FROM ...
4 comments|post comment

27 May 2009|01:35pm
1. Promise that you won't lock the inner door, forget about it and lock it
2. Write a note with an apology
3. Forget about it and lock the door again
4. ....
5. FACEPALM!!!!
4 comments|post comment

NAMIUUUH xD 26 May 2009|09:19pm

ikorn updated.
Namie has a temporary blog, for the time of her BEST FICTION tour (which ends in a few weeks or so), called BEST non FICTION, which is only accessible through a (Japanese) mobile phone.

Some celebrities maintain a diet to be in shape... As for Namie, she loves grilled meat! xDD

Namie is so sweet, I want to kiss her on the cheek :3

BESTO non FICTION, translation by ikorn )
2 comments|post comment

25 May 2009|10:02pm
Vin Diesel has a facebook with a blog which he updates regularly.

The Internet is the greatest invention of 20th century IMO.
3 comments|post comment

gulp gulp gulp 24 May 2009|07:02pm
Image Hosted by ImageShack.us

I think I've become addicted to MacCoffee. Emptied 5 full cups yesterday and finished what was left of it today. I've no idea what they put in there, but it got me hooked up for sure. Got to replenish the supplies tommorow *shivers in a junkie manner*

7 comments|post comment

24 May 2009|04:35pm
I get tired of human company in 0.59365 seconds.

I wish I could become pure energy, dissolve in the environment, travel with the speed of light, be everywhere and nowhere at the same time.
4 comments|post comment

Do you C? 21 May 2009|11:21am

struct

Saw a cool way to initialize structs in C yesterday:

struct employee { char *name; char *surname; int age; }; struct employee emp = { .name = "John", .surname = "Smith", .age = 20 };

Invaluable when initializing large structures, where it is very easy to forget the correct order. Much more clear too.

I seriously need to get my hands on C's specs.

comma operator

The comma operator executes statements from it's left to right and yields the rightmost statement.

I've always used it in for loop to initialize more than one variable, like:

for (i = 0, j = 10; ...

But I never realized it's full potential. Recently, I saw such a use of it:

while (cin >> ival, !cin.eof()) ...

It has a very low precedance, I think it may even be in the very end of precedance table, so

i = printf("1\n"), printf("22\n"), printf("333\n"); printf("i=%i\n", i-1);

prints i=1, and

i = (printf("1\n"), printf("22\n"), printf("333\n")); printf("i=%i\n", i-1);

prints i=3.

UPD. More precisely, what happens here is that: the assignment operator has a higher precedence over the comma operator, and has a right to left associativity, so the i = printf("1\n") is executed first, then, the first comma operator is executed, and it yields printf("22\n"), then the second comma operator is excuted, which yields printf("333\n").

5 comments|post comment

navigation
[ viewing | most recent entries ]
[ go | earlier ]