2009年10月6日 星期二

Linux Kernel netconsole

[Server]
./netcat -u -l -p 6666 | tee /tmp/123.log

[Client]
ifconfig eth0 up
ifconfig eth0 192.168.19.183 netmask 255.255.255.0 up

insmode netconsole.ko netconsole=@/eth0,@192.168.19.43/

記錄一下下~~

2009年9月15日 星期二

Work with a git remote branch

git checkout --track -b my/master-dev2 origin/master-dev

Just keep a record~~

2009年8月8日 星期六

The GNU MP Bignum library

最近因為工作上客戶要求要做 RSA verify 的動作來確保 image 是沒被改動過的..
一開始是參考 openssl ..
在看 RSA 的部分..發現其實 RSA 主要是有一個 big number 的 libaray ..
然後做 big number 的運算..說實在並不是很複雜..
另外看了其它有關 RSA 的 libaray..也都是這樣子..
所以就打算放棄 porting openssl 這個功能超強的大怪物~~只拿 openssl 來當驗證用..
就找了 axTLS 這個 SSL library 來改..把 RSA 的 module 整個抽出來...
還算幸運..花了大概一天的時候把 RSA 的 code 整個抽出來..
然後驗證抽出來的 code 是沒問題的..另外再花了半天的時候把 code port 到我們的環境上...
不過對於 code size 上不是很滿意..目前 RSA 的部分花了大概是 6KB ..
很想把 code size 縮到 5KB 左右..看起來佔 code size 最多的就是 big number 的部分..
所以就上網找了一下..是不是其它的 libaray..
找到了 The GNU MP Bignum library
號稱是 the fastest bignum library on the planet!
不過是 GPL 的 code 就沒特別看了~~只是單純記錄一下下~~:)

2009年6月5日 星期五

IRQ and INT

IRQ 指的是 HW 連接至 PIC 上的 pin number
INT 指的是 interrupt vector 的 number


"软中断一般是指由指令int引起的“伪”中断动作——给CPU制造一个中断的假象;而硬中断则是实实在在由8259的连线触发的中断。因此,严格的讲,int与IRQ毫无关系,但二者均与中断向量有关系。int引起的中断,CPU是从指令中取得中断向量号;而IRQ引起的中断,CPU必须从数据线上取回中断号(硬件引发中断首先加到8259的某个IRQ引脚上,8259根据定义好的规则换算出相应的中断向量号,将其放在数据线上,然后通知CPU中断到来)。接下来CPU的工作就一样了:保护现场、根据中断号得到中断处理程序地址、执行中断处理、恢复现场继续执行被中断的指令。Windows驱动程序一般不能直接接管中断,中断是由内核的VPICD接管,驱动程序只是向VPICD注册中断服务,中断服务将由VPICD调用。这样可以有效的实现虚拟设备:虚拟不存在的设备或者改变已存在的物理设备的行为。"

-- from http://topic.csdn.net/t/20011227/16/445451.html#

2009年5月26日 星期二

Use git on your local computer

對於 git 的使用相當的陌生
但很喜歡的用 git diff 產生出來 patch 的 format

git 也可以用在自己 local 的電腦上..
下面是自己建立 local repo 的方法

1. mkdir -p /home/git
2. cd /home/git
3. tar xvfj linux.tar.bz2
4. cd linux
5. git init
6. git add .
7. git commit

當你需要 clone 一份 code 的時候..可以下
git clone /home/git/linux mylinux

之後當你在 mylinux 下修改檔案後
就可以用 git diff 來產生 patch 了~~

2009年5月16日 星期六

User space RCU library relicensed to LGPLv2.1

User space 也有 RCU (Read-Copy Update) 可以用了!
Userspace RCU library


雖然不太了解 RCU 的真正用途是什麼..是知道是可以讓 data share 給很多人同時使用...
機制不明..

What is RCU, Fundamentally?
這裡有說明..覺得還蠻有興趣..再找時間看看...
如果可以運用於 user space multithread 的程式上的話...
應該是很不錯的~~

另外這個 project hosted 在 LTTng 上 ..
因為 LTTng 要用~~

2009年5月7日 星期四

Fixup in the very early time

start_kernel(void)
{
...
setup_arch(&command_line);
-> early_quirks(); /* can do chipset fixup */
...
acpi_early_init(); /* Enable ACPI */
...
...
}

early_quirks() 這個點可以在很早的時候就 fixup 一些奇怪的 bug
大部分都是 chipset 相關的 ...
這個點在 ACPI enable 之前...
也比所有的 initcall 都還要早 .... (initcall 其實己經算是很後面的..)

2009年4月30日 星期四

2009年4月23日 星期四

Linux init call

[linux-2.6.28.3]
在 Linux kernel 中做 init call 的做法..很有趣..
在 link script 中加入幾個section..

include/asm-generic/vmlinux.lds.h
#define INITCALLS \
*(.initcallearly.init) \
VMLINUX_SYMBOL(__early_initcall_end) = .; \
*(.initcall0.init) \
*(.initcall0s.init) \
*(.initcall1.init) \
*(.initcall1s.init) \
*(.initcall2.init) \
*(.initcall2s.init) \
*(.initcall3.init) \
*(.initcall3s.init) \
*(.initcall4.init) \
*(.initcall4s.init) \
*(.initcall5.init) \
*(.initcall5s.init) \
*(.initcallrootfs.init) \
*(.initcall6.init) \
*(.initcall6s.init) \
*(.initcall7.init) \
*(.initcall7s.init)

arch/x86/kernel/vmlinux_32.lds.S
.initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) {
__initcall_start = .;
INITCALLS
__initcall_end = .;
}

include/linux/init.h
#define __define_initcall(level,fn,id) \
static initcall_t __initcall_##fn##id __used \
__attribute__((__section__(".initcall" level ".init"))) = fn

/*
* Early initcalls run before initializing SMP.
*
* Only for built-in code, not modules.
*/
#define early_initcall(fn) __define_initcall("early",fn,early)

/*
* A "pure" initcall has no dependencies on anything else, and purely
* initializes variables that couldn't be statically initialized.
*
* This only exists for built-in code, not for modules.
*/
#define pure_initcall(fn) __define_initcall("",fn,0)

#define core_initcall(fn) __define_initcall("1",fn,1)
#define core_initcall_sync(fn) __define_initcall("1s",fn,1s)
#define postcore_initcall(fn) __define_initcall("2",fn,2)
#define postcore_initcall_sync(fn) __define_initcall("2s",fn,2s)
#define arch_initcall(fn) __define_initcall("3",fn,3)
#define arch_initcall_sync(fn) __define_initcall("3s",fn,3s)
#define subsys_initcall(fn) __define_initcall("4",fn,4)
#define subsys_initcall_sync(fn) __define_initcall("4s",fn,4s)
#define fs_initcall(fn) __define_initcall("5",fn,5)
#define fs_initcall_sync(fn) __define_initcall("5s",fn,5s)
#define rootfs_initcall(fn) __define_initcall("rootfs",fn,rootfs)
#define device_initcall(fn) __define_initcall("6",fn,6)
#define device_initcall_sync(fn) __define_initcall("6s",fn,6s)
#define late_initcall(fn) __define_initcall("7",fn,7)
#define late_initcall_sync(fn) __define_initcall("7s",fn,7s)

init/main.c
static void __init do_initcalls(void)
{
initcall_t *call;

for (call = __early_initcall_end; call < __initcall_end; call++)
do_one_initcall(*call);

/* Make sure there is no pending stuff from the initcall sequence */
flush_scheduled_work();
}

static void __init do_pre_smp_initcalls(void)
{
initcall_t *call;

for (call = __initcall_start; call < __early_initcall_end; call++)
do_one_initcall(*call);
}


Bootchart

看 Linux 開機 flow 的好工具~~
Bootchart

當然還其它類似的工具..
如~
bootchart-lite
ubootchart

主要寫這個 blog 是每次我都會忘掉.. bootchart.jar 要怎麼產生~ @@

bash> ant jar

這樣子就行了..

記得要裝 Apache Ant

2009年4月13日 星期一

ACPI個鬼~~

最近比較常幫 Linux 那邊在試一些 power saving 的東西
在 PC 下.. 主要都是透過 ACPI 來做 power management
所以對 ACPI 又接觸了一些~~

Linux ACPI FAQ

有提到怎麼利用 Linux 下的 console 來 debug ASL code
我們也可以自己把 BIOS 的 DSDT 換掉..來做測試

ACPI 還蠻有趣的..不過 spec 大了點..
嗯..Revision 3.0a 有 624頁~~


2009年4月9日 星期四

2009年4月1日 星期三

Kernel Modesetting (KMS)

將原本 X server 設定 graphics mode 的工作(在 X server's DDX drivers 中)..搬到 kernel 來做..
還蠻有趣的.. 在 2.6.29 中己加入~~

下面是一些相關的link
Kernel Modesetting and Memory Management



2009年3月31日 星期二

libevent - an event notification library

libevent
一個聽說很好用的 library
可以吃 /dev/poll, kqueue(2), event ports, select(2), poll(2) and epoll(4). 這麼多種

Real World Benchmarks Of The EXT4 File-System

Phoronix 上給 EXT4 做的測試 ..
裡面提到一些 I/O testing 的工具..
可以做為參考...

[Phoronix] Real World Benchmarks Of The EXT4 File-System


2009年3月29日 星期日

PCI-E ASPM(Active State Power Management) 相關資料

PCI-E專欄:PCI Express省電模式剖析 行動平台決戰電池續航力
PCIE ASPM support - takes 3
Active State Power Management in Windows Vista

基本上 ASPM 是 hardware 自己做掉的...
software 最多需要的只是 configure 一下下~~

參加演唱會清單

把參加過的演唱會列出來..
ps: 應該是沒漏掉吧~:)



王菲x2
周杰倫x2
陶喆



Fort Minor - 2006/02/24 @ 台北-中山足球場
50 Cent - 2006/02/24 @ 台北-中山足球場
Black Eyed Peas - 2006/07/25 @ 台北-中山足球場
Jay-Z - 2006/10/21 @ 台北-小巨蛋
Boyz-II-Men - 2007/01/23 @ 台北-國父紀念館
Beyoncé - 2007/11/12 @ 台北-中山足球場
Babyface - 2008/11/14 @ Japan Osaka Billboard Live
Brain Mcknight - 2009/03/19 @ 苗票
Usher - 2010/07/04 @ 台北-南港展覽館
Boyz-II-Men - 2010/08/14 @ 台北-世貿二館

2009年3月17日 星期二

Rebuild Moblin v2 alpha1 kernel from src.rpm

http://repo.moblin.org/moblin/releases/test/alpha1/source/kernel-2.6.29.rc2-13.1.moblin2.src.rpm

# rpm -ivh kernel-2.6.29.rc2-13.1.moblin2.src.rpm
# cd /usr/src/redhat/SPECS
# vi kernel.spec

Add
%define netbook 1

# rpmbuild -bb --target i586 kernel.spec

ps: Moblin v2 Alpha 2 今天 release~
* The Alpha release is available at:
http://repo.moblin.org/moblin/releases/test/alpha2


alignment to xxx ~~~

有時候需要將一個值或是 address alignment 到一個 boundary , 最常見的就是 alignment to 4KB, 也就是一個 page 的 boundary.
Linux kernel 使用 PAGE_ALIGN(addr) 這個 macro 來處理

/* PAGE_SHIFT determines the page size */
#define PAGE_SHIFT 12
#define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT)
#define PAGE_MASK (~(PAGE_SIZE-1))

/* to align the pointer to the (next) page boundary */
#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)


可以小小改寫成
#define SIZE_ALIGN(addr, size) (((addr)+size-1)&(~(size-1)))

昨天就遇到一個問題..需要將一個值 alignment 到 32bit 的 boundary
就可以這樣子做

SIZE_ALIGN(addr, 32)

2009年3月16日 星期一

blogger的第一篇~~~

不喜歡外面 free 的 blog 是因為很多都不能改..而且還有備份的問題...
所以就自己架了一個..
有自己架的 blog 很方便... 想要記錄什麼..都可以...
想怎麼改都可以....但是~~~~
自從家裡的電費因為開 edjy 而增加很多之後.. edjy 就很少開了...
但是有時候又想要記錄些什麼的....
最後.....
還是在 blogger 上開了自己的 blog
要謝謝邵太太的幫忙..讓我的 blog 可以很快就弄好了...
謝謝邵太太..^+++^