<?xml version="1.0" encoding="utf-8"?>
<!-- generator="wordpress/1.5.1-alpha" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
>

<channel>
	<title>in the name of zero</title>
	<link>http://gnurbs.blogsome.com</link>
	<description>amerei's my blessed holy rants</description>
	<pubDate>Mon, 18 Aug 2008 06:00:36 +0000</pubDate>
	<generator>http://wordpress.org/?v=1.5.1-alpha</generator>
	<language>en</language>

		<item>
		<title>with yoo hee</title>
		<link>http://gnurbs.blogsome.com/2008/08/18/with-yoo-hee/</link>
		<comments>http://gnurbs.blogsome.com/2008/08/18/with-yoo-hee/#comments</comments>
		<pubDate>Mon, 18 Aug 2008 06:00:36 +0000</pubDate>
		<dc:creator>sleepy jenkins</dc:creator>
		
	<category>stuff i watch and stuff i listen to</category>
		<guid>http://gnurbs.blogsome.com/2008/08/18/with-yoo-hee/</guid>
		<description><![CDATA[	they could have gone all the way&#8230; but no&#8230; they mellowed down the ending into a mediocre open-ended love drama. THE NERVE! i hate the scriptwriters for messing with my heart like this!

]]></description>
			<content:encoded><![CDATA[	<p>they could have gone all the way&#8230; but no&#8230; they mellowed down the ending into a mediocre open-ended love drama. THE NERVE! i hate the scriptwriters for messing with my heart like this!
</p>
]]></content:encoded>
			<wfw:commentRss>http://gnurbs.blogsome.com/2008/08/18/with-yoo-hee/feed/</wfw:commentRss>
	</item>
		<item>
		<title>avatar, the last airbender</title>
		<link>http://gnurbs.blogsome.com/2008/08/10/avatar-the-last-airbender/</link>
		<comments>http://gnurbs.blogsome.com/2008/08/10/avatar-the-last-airbender/#comments</comments>
		<pubDate>Sun, 10 Aug 2008 08:15:55 +0000</pubDate>
		<dc:creator>sleepy jenkins</dc:creator>
		
	<category>easter eggs</category>
		<guid>http://gnurbs.blogsome.com/2008/08/10/avatar-the-last-airbender/</guid>
		<description><![CDATA[	.. i finished watching the last episode of book3 a while ago&#8230; rocks! at last, there is peace.

]]></description>
			<content:encoded><![CDATA[	<p>.. i finished watching the last episode of book3 a while ago&#8230; rocks! at last, there is peace.
</p>
]]></content:encoded>
			<wfw:commentRss>http://gnurbs.blogsome.com/2008/08/10/avatar-the-last-airbender/feed/</wfw:commentRss>
	</item>
		<item>
		<title>laptop love</title>
		<link>http://gnurbs.blogsome.com/2008/08/10/laptop-love/</link>
		<comments>http://gnurbs.blogsome.com/2008/08/10/laptop-love/#comments</comments>
		<pubDate>Sun, 10 Aug 2008 04:26:27 +0000</pubDate>
		<dc:creator>sleepy jenkins</dc:creator>
		
	<category>hermetic studies</category>
		<guid>http://gnurbs.blogsome.com/2008/08/10/laptop-love/</guid>
		<description><![CDATA[	i got annoyed because i have four extra keys on my laptop keyboard that doesn&#8217;t
work as expected when i&#8217;m in gentoo. i&#8217;m callin&#8217; them &#8220;compaq keys&#8221; coz i dont
know what they are called and its tiresome to know anyway&#8230;
	in windows vista:
	compaq key1: starts a program &#8216;dvdplay&#8217; i think&#8230;
compaq key2: toggles the volume on or off
compaq [...]]]></description>
			<content:encoded><![CDATA[	<p>i got annoyed because i have four extra keys on my laptop keyboard that doesn&#8217;t<br />
work as expected when i&#8217;m in gentoo. i&#8217;m callin&#8217; them &#8220;compaq keys&#8221; coz i dont<br />
know what they are called and its tiresome to know anyway&#8230;</p>
	<p>in windows vista:</p>
	<p>compaq key1: starts a program &#8216;dvdplay&#8217; i think&#8230;<br />
compaq key2: toggles the volume on or off<br />
compaq key3: lowers the volume<br />
compaw key4: does the opposite of key3</p>
	<p>so i modified my keymap settings so that compaq keys2-4 are mapped to function keys<br />
F13-F15 (i only have F1 to F12&#8230;)</p>
	<pre class="block">-- .Xmodmap --
keycode 160 = F13
keycode 174 = F14
keycode 176 = F15</pre>
	<p>and my corresponding .fluxbox/keys file</p>
	<pre class="block"> -- snip --
	
# windows key
Mod4 x  :maximize
Mod4 d  :ShowDesktop
Mod4 a :ExecCommand aterm +sb -tr -trsb -fg darkgray -fade 50%
Mod4 w :ExecCommand audacious
Mod4 e :ExecCommand /usr/bin/emelfm2
Mod4 b :ExecCommand /usr/bin/firefox
Mod4 y :ExecCommand /usr/bin/gaim
Mod4 m :ExecCommand /usr/bin/sylpheed
Mod4 v :ExecCommand /usr/bin/gvim
	
# laptop keymap
F13 :ExecCommand /bin/bash ~/.mykbd
F14 :ExecCommand /usr/bin/amixer sset PCM 5%-
F15 :ExecCommand /usr/bin/amixer sset PCM 5%+
	
 -- snip -- </pre>
	<p>now, volume on/off toggling presented a mild challenge mainly because i didn&#8217;t<br />
find implicit mute/unmute capability in amixer&#8217;s man page. so i did a little bash<br />
mojo to get the desired functionality i want.</p>
	<p>.mykdb</p>
	<pre class="block">#!/bin/bash
SYSMIX=`which amixer`
GET_SPKR_STAT=$SYSMIX
STATUS=`$GET_SPKR_STAT get Speaker | grep -i off`
	
if [[ -z $STATUS ]]; then
        $SYSMIX sset Speaker off 1> /dev/null
else
        $SYSMIX sset Speaker on 100% 1> /dev/null
fi  </pre>
	<p><b>it took me a whole goddamn 10 minutes to figure out that [[ ]] needs a space<br />
separator on its expression field.</b></p>
	<p>lesson learned. seriously, don&#8217;t do bash, brainfuck, and perl when you are sleep<br />
deprived.
</p>
]]></content:encoded>
			<wfw:commentRss>http://gnurbs.blogsome.com/2008/08/10/laptop-love/feed/</wfw:commentRss>
	</item>
		<item>
		<title>magic the gathering meme</title>
		<link>http://gnurbs.blogsome.com/2008/07/20/magic-the-gathering-meme/</link>
		<comments>http://gnurbs.blogsome.com/2008/07/20/magic-the-gathering-meme/#comments</comments>
		<pubDate>Sun, 20 Jul 2008 09:19:02 +0000</pubDate>
		<dc:creator>sleepy jenkins</dc:creator>
		
	<category>easter eggs</category>
		<guid>http://gnurbs.blogsome.com/2008/07/20/magic-the-gathering-meme/</guid>
		<description><![CDATA[	Take the Magic: The Gathering &#8216;What Color Are You?&#8217; Quiz.
]]></description>
			<content:encoded><![CDATA[	<p align="center" style="font-family: arial;"><a href="http://www.wizards.com/magic/playmagic/whatcolorareyou.asp" target="_blank"><img src="http://www.wizards.com/magic/images/whatcolor_isred.jpg" border="0"/><br /><b>Take the Magic: The Gathering &#8216;What Color Are You?&#8217; Quiz.</b></a></p>
]]></content:encoded>
			<wfw:commentRss>http://gnurbs.blogsome.com/2008/07/20/magic-the-gathering-meme/feed/</wfw:commentRss>
	</item>
		<item>
		<title>starbucks flirting</title>
		<link>http://gnurbs.blogsome.com/2008/07/13/starbucks-flirting/</link>
		<comments>http://gnurbs.blogsome.com/2008/07/13/starbucks-flirting/#comments</comments>
		<pubDate>Sun, 13 Jul 2008 04:13:10 +0000</pubDate>
		<dc:creator>sleepy jenkins</dc:creator>
		
	<category>easter eggs</category>
		<guid>http://gnurbs.blogsome.com/2008/07/13/starbucks-flirting/</guid>
		<description><![CDATA[	how come guys using a macbook at the local starbucks look cool? i&#8217;m running gentoo and accessing their wifi at virtual terminal two using iwconfig &#8230; but I don&#8217;t get any attention from the cute bartender &#8220;kaye&#8221;. sh* t&#8230; i must change my tactics and perhaps use vista  instead.

]]></description>
			<content:encoded><![CDATA[	<p>how come guys using a macbook at the local starbucks look cool? i&#8217;m running gentoo and accessing their wifi at virtual terminal two using iwconfig &#8230; but I don&#8217;t get any attention from the cute bartender &#8220;kaye&#8221;. sh* t&#8230; i must change my tactics and perhaps use vista  instead.
</p>
]]></content:encoded>
			<wfw:commentRss>http://gnurbs.blogsome.com/2008/07/13/starbucks-flirting/feed/</wfw:commentRss>
	</item>
		<item>
		<title>grainne2</title>
		<link>http://gnurbs.blogsome.com/2008/07/12/grainne2/</link>
		<comments>http://gnurbs.blogsome.com/2008/07/12/grainne2/#comments</comments>
		<pubDate>Sat, 12 Jul 2008 05:01:05 +0000</pubDate>
		<dc:creator>sleepy jenkins</dc:creator>
		
	<category>hermetic studies</category>
	<category>reverse engineering</category>
		<guid>http://gnurbs.blogsome.com/2008/07/12/grainne2/</guid>
		<description><![CDATA[	i know how how it feels like to have a burning hole in your heart that can only be
filled with a loved one. but sometimes, we have no choice but to accept our
fate. - kenshin himura
	it&#8217;s &#8220;grainne2&#8243;!! i decided to make it available here while i&#8217;m still waiting for the mods at crackmes.de to put [...]]]></description>
			<content:encoded><![CDATA[	<p><i>i know how how it feels like to have a burning hole in your heart that can only be<br />
filled with a loved one. but sometimes, we have no choice but to accept our<br />
fate. - kenshin himura</i></p>
	<p>it&#8217;s &#8220;grainne2&#8243;!! i decided to make it available <a href="http://www.esnips.com/doc/295d79f9-b32c-4f16-88da-b12499cf9953/grainne2">here</a> while i&#8217;m still waiting for the mods at crackmes.de to put it up. i&#8217;ll post a solution after a week or two..</p>
	<p><strong>update:</strong> <a href="http://crackmes.de">crackmes.de</a> page for &#8220;grainne2&#8243; <a href="http://crackmes.de/users/stefanie/grainne2/">here</a>. enjoy you guys..</p>
	<p>dedicated to Grainne C. Yap - the girl who broke my heart.
</p>
]]></content:encoded>
			<wfw:commentRss>http://gnurbs.blogsome.com/2008/07/12/grainne2/feed/</wfw:commentRss>
	</item>
		<item>
		<title>witch yoo hee</title>
		<link>http://gnurbs.blogsome.com/2008/06/29/witch-yoo-hee/</link>
		<comments>http://gnurbs.blogsome.com/2008/06/29/witch-yoo-hee/#comments</comments>
		<pubDate>Sun, 29 Jun 2008 07:35:19 +0000</pubDate>
		<dc:creator>sleepy jenkins</dc:creator>
		
	<category>hermetic studies</category>
	<category>easter eggs</category>
		<guid>http://gnurbs.blogsome.com/2008/06/29/witch-yoo-hee/</guid>
		<description><![CDATA[	i&#8217;m in love! 
	&#8230; but she&#8217;s married (in real life). this &#8220;koreanovela&#8221; is soo addicting!

]]></description>
			<content:encoded><![CDATA[	<p>i&#8217;m in love! </p>
	<p>&#8230; but <a href="http://bestuff.com/stuff/witch-yoo-hee">she&#8217;s</a> married (in real life). this &#8220;koreanovela&#8221; is soo addicting!
</p>
]]></content:encoded>
			<wfw:commentRss>http://gnurbs.blogsome.com/2008/06/29/witch-yoo-hee/feed/</wfw:commentRss>
	</item>
		<item>
		<title>linux raw spin locks</title>
		<link>http://gnurbs.blogsome.com/2008/06/28/linux-raw-spin-locks/</link>
		<comments>http://gnurbs.blogsome.com/2008/06/28/linux-raw-spin-locks/#comments</comments>
		<pubDate>Sat, 28 Jun 2008 04:04:28 +0000</pubDate>
		<dc:creator>sleepy jenkins</dc:creator>
		
	<category>hermetic studies</category>
		<guid>http://gnurbs.blogsome.com/2008/06/28/linux-raw-spin-locks/</guid>
		<description><![CDATA[	apparently, there are some issues with linux 2.6 and pearpc.. so i still cant
get the gentoo ppc to start properly. i thought i&#8217;d do some studying in the
meantime..
	typedef struct {
        volatile unsigned int slock;
} raw_spinlock_t;
	static inline void __raw_spin_lock(raw_spinlock_t *lock)
{        asm volatile(\"\n1:\t\"
 [...]]]></description>
			<content:encoded><![CDATA[	<p>apparently, there are some issues with linux 2.6 and pearpc.. so i still cant<br />
get the gentoo ppc to start properly. i thought i&#8217;d do some studying in the<br />
meantime..</p>
	<pre class="block">typedef struct {
        volatile unsigned int slock;
} raw_spinlock_t;</pre>
	<pre class="block">static inline void __raw_spin_lock(raw_spinlock_t *lock)
{        asm volatile(\"\n1:\t\"
                     LOCK_PREFIX \" ; decb %0\n\t\"
                     \"jns 3f\n\"
                     \"2:\t\"
                     \"rep;nop\n\t\"
                     \"cmpb $0,%0\n\t\"
                     \"jle 2b\n\t\"
                     \"jmp 1b\n\"
                     \"3:\n\t\"
                     : \"+m\" (lock->slock) : : \"memory\");
}</pre>
	<p>interpretation of the extended inline asm:</p>
	<p>1) : &#8220;+m&#8221; (locl->slock)<br />
        &#8220;+m&#8221; means that the memory operand &#8216;lock->slock&#8217; is both input and output.</p>
	<p>2) : &#8220;memory&#8221;<br />
        from gcc manual:<br />
                 If your assembler instructions access memory in an unpredictable<br />
        fashion, add `memory&#8217; to the list of clobbered registers.  This will<br />
        cause GCC to not keep memory values cached in registers across the<br />
        assembler instruction and not optimize stores or loads to that memory.</p>
	<p>3) LOCK_PREFIX is defined at /usr/src/linux/include/asm/alternative.h:</p>
	<pre class="block">#define LOCK_PREFIX \
                \".section .smp_locks,\\"a\\"\n\"   \   ; push current section and change section to .smp_locks
                \"  .align 4\n\"                  \   ; align to 4 bytes
                \"  .long 661f\n\" /* address */  \   ; create an entry in the up/smp alternative locking table
                \".previous\n\"                   \   ; pop back the old section
                \"661:\n\tlock; \"                    ; assert processor LOCK# signal</pre>
	<p>LOCK_PREFIX is supposed to be called within the context of a procedure (executable) which finds its way to a .text section.</p>
	<p>i haven&#8217;t digged down deep into the internals of &#8216;alternatives&#8217; yet, but a quick look at kernel/alternative.c :: alternatives_smp_unlock() shows that it&#8217;s employing a self modifying code that patches the &#8220;lock&#8221; instruction with an architecture specific NOP opcode.</p>
	<p>without all the extended asm semantics above, the asm roughly translates to:</p>
	<pre class="block">1:      lock       ; decrement atomically
        decb    %0 ; really decrement now..
        jns     3f ; successful in acquiring lock?
2:      rep        ; nothing
        nop        ; nothing
        cmpb    $0, %0 ; someone must release the lock first.
        jle     2b     ; busy wait...
        jmp     1b     ; lock available! try acquiring lock again.
3:     ; exit __raw_spin_lock()</pre>
	<p>and then comes the trylock variant</p>
	<pre class="block">static inline int __raw_spin_trylock(raw_spinlock_t *lock)
{
        char oldval;
        asm volatile(
                \"xchgb %b0,%1\"
                :\"=q\" (oldval), \"+m\" (lock->slock)
                :\"0\" (0) : \"memory\");
        return oldval > 0;
}</pre>
	<p>interpretation of the extended inline asm:</p>
	<p>1) : &#8220;=q&#8221; (oldval)<br />
        output oldval in any a,b,c or d register.</p>
	<p>2) : &#8220;+m&#8221; (locl->slock)<br />
        &#8220;+m&#8221; means that the memory operand &#8216;lock->slock&#8217; is both input and output.</p>
	<p>3) : &#8220;0&#8243; (0)<br />
        %0 matches the output register for oldval. initialize that with the value 0.</p>
	<p>4) : &#8220;memory&#8221;<br />
        from gcc manual:<br />
                 If your assembler instructions access memory in an unpredictable<br />
        fashion, add `memory&#8217; to the list of clobbered registers.  This will<br />
        cause GCC to not keep memory values cached in registers across the<br />
        assembler instruction and not optimize stores or loads to that memory.</p>
	<p>__raw_spin_trylock() basically exchanges the current value in raw_spinlock_t->slock with zero and returns true if locking was successful and false if acquiring of lock didn&#8217;t succeed.</p>
	<p>lastly, we have the raw unlock procedure:</p>
	<pre class="block">static inline void __raw_spin_unlock(raw_spinlock_t *lock)
{
        char oldval = 1;
	
        asm volatile(\"xchgb %b0, %1\"
                     : \"=q\" (oldval), \"+m\" (lock->slock)
                     : \"0\" (oldval) : \"memory\");
}</pre>
	<p>i haven&#8217;t been able to understand the significance of the &#8220;%b&#8221; in the assembler template but looking at the asm listing of the template with and without the %b yielded the same intructions, so could anyone shed some light on this one?</p>
	<p>basically looks like __raw_spin_trylock(), but the difference is that oldval is now initialized to 1 instead of 0.</p>
	<p>there are many variants stemming from the idea of this implementation. raw reader/writer locks which allows multiple readers but only one writer (with no concurrent readers). and then there&#8217;s the spinlock layer above the raw spinlock implementation.. but those are for another post.</p>
	<p>&#8217;til then.</p>
]]></content:encoded>
			<wfw:commentRss>http://gnurbs.blogsome.com/2008/06/28/linux-raw-spin-locks/feed/</wfw:commentRss>
	</item>
		<item>
		<title>on my own and moving on</title>
		<link>http://gnurbs.blogsome.com/2008/06/14/on-my-own-and-moving-on/</link>
		<comments>http://gnurbs.blogsome.com/2008/06/14/on-my-own-and-moving-on/#comments</comments>
		<pubDate>Sat, 14 Jun 2008 03:37:52 +0000</pubDate>
		<dc:creator>sleepy jenkins</dc:creator>
		
	<category>hermetic studies</category>
	<category>reverse engineering</category>
		<guid>http://gnurbs.blogsome.com/2008/06/14/on-my-own-and-moving-on/</guid>
		<description><![CDATA[	i&#8217;ve been puting off a lot of things lately. at the top of my list is to give some just attention to this little web space of mine. its not because i don&#8217;t have time anymore. its just that, i felt the need to explore some de-stressing activities other than writing my thoughts and rants [...]]]></description>
			<content:encoded><![CDATA[	<p>i&#8217;ve been puting off a lot of things lately. at the top of my list is to give some just attention to this little web space of mine. its not because i don&#8217;t have time anymore. its just that, i felt the need to explore some de-stressing activities other than writing my thoughts and rants down. i always found writing rather emotionally helpful, but during those carefree college days, i rarely<br />
did anything to the point of exhaustion.</p>
	<p>but im bringing my hiatus onto a peaceful end. good day! gentoo powerpc land!
</p>
]]></content:encoded>
			<wfw:commentRss>http://gnurbs.blogsome.com/2008/06/14/on-my-own-and-moving-on/feed/</wfw:commentRss>
	</item>
		<item>
		<title>happy anniversary</title>
		<link>http://gnurbs.blogsome.com/2008/06/09/happy-anniversary/</link>
		<comments>http://gnurbs.blogsome.com/2008/06/09/happy-anniversary/#comments</comments>
		<pubDate>Mon, 09 Jun 2008 07:06:17 +0000</pubDate>
		<dc:creator>sleepy jenkins</dc:creator>
		
	<category>life and school</category>
	<category>easter eggs</category>
		<guid>http://gnurbs.blogsome.com/2008/06/09/happy-anniversary/</guid>
		<description><![CDATA[	today&#8230; june 10, marks the first anniversary of my emancipation. it has been a challenging past year&#8230; 
	here&#8217;s hoping i can last another&#8230;

]]></description>
			<content:encoded><![CDATA[	<p>today&#8230; june 10, marks the first anniversary of my emancipation. it has been a challenging past year&#8230; </p>
	<p>here&#8217;s hoping i can last another&#8230;
</p>
]]></content:encoded>
			<wfw:commentRss>http://gnurbs.blogsome.com/2008/06/09/happy-anniversary/feed/</wfw:commentRss>
	</item>
	</channel>
</rss>
