2011年4月14日 星期四

這就是我吧
總是期望越高  失望就越多
有時很隨和  無所謂
但是安靜下來  想很多
想做很多改變  但是三分鐘熱度

傻傻的很單純  以為這樣做就好
但是其實沒有思考的很周密
無法一次分心做兩件事

對於愛情  沒啥想法  也沒有很積極
不過愛上了就會想  努力對他好
但是時間久了  就會變懶
愛變成了習慣  會開始抱怨

想愛  但會怕  女朋友如果忽然半天沒消息
會擔心  但是又不想打電話  真矛盾
不喜歡把感受說出來  悶悶的
就不太愛說話

想妳嘴巴卻說不出來
唉~

2011年2月23日 星期三

什麼是vold

在Android系統中有個Native Service叫做vold,舊的版本叫做mountd。如果對mountd有興趣的話可以在Cupcake找到Source Code。在Donut以後的版本Mountd已經從目錄結構中移除了,只有在init.rc中可以看到註解掉的啟動腳本。vold位於User Space,任務是透過netlink接收從Kernel Space送上來的uevent。每一個送上來的uevent在vold的解析後有些會透過UNIX domain socket轉傳給Android Service,也就是MountService。由MountService決定接下來的動作。所以vold配合MountService的架構是用來偵測和處理Android系統中External Storage的掛載,其中External Storage可能是USB Mass Storage或者是SD Card。

00
從[Froyo Root]/system/vold/main.c我們可以發現vold的主要的運作流程。程式的最後會進入無窮迴圈用以分別監聽netlink以及UNIX domain socket,對上對下接收傳遞訊息。程式中會配置兩個Singleton Manager分別用來管理netlink的NetlinkManager以及管理每個External Storage的VolumeManager。另一個UNIX domain socket會藉由init.rc建造並且在程式啟動的時候透過環境變數傳進vold。整個流程也包含重置uevent,以解決vold還沒作用前External Storage就已經被置入的問題。

01

2011年1月23日 星期日

愛情觀

有時跟朋友聊起愛情觀

很多人的想法都不同

有的更是說的跟做的不同

但是他們至少有個機會可以珍惜

常常聽到的就是  愛變成理所當然

人生苦短  又何必太計較呢

勇敢去愛就對了~~

2011年1月2日 星期日

ACPI RTC WakeUp

The above indicates this system can wake from state S4 and that the wakeup time can be set.
The ACPI specifications defines the following so-called "global states" -- from Wikipedia ACPI
  • G1 Sleeping subdivides into the four states S1 through S4.
    • S1: The CPU(s) stop executing instructions.
    • S2: The CPU is powered off.
    • S3: Suspend to RAM.
    • S4: Suspend to disk or hibernate.
  • G2 (S5) Soft Off Almost the same as G3 but computer can "wake" from input from the keyboard, clock, modem, LAN, or USB device.
  • G3 Mechanical Off
Next, check your BIOS for the wakeup alarm function. This setting is likely found under a sub-menu of "Power Management Setup", "APM", or "Advanced" - you just need to poke around to find it. It will likely be called something like Wake From Alarm, Power-on by Alarm, Wake from RTC, RTC Resume, etc.

S3 (Suspend to RAM)

First, see the BIOS setup section above to confirm which powerdown states your computer's ACPI supports. Some computers are unable to wake up from S5 (Soft Off) by an RTC alarm set through ACPI. For example some HP Compaq desktop computers allow you to set wakeup from BIOS at a specific time and at specific week days, however it is ignored ACPI alarm. In this case you may want to try to see if it does wake up from S3 (Suspend to RAM) instead.
The following check needs pm-utils package to work. You may also want to turn off X windows, as quite a few drivers don't like suspend to RAM.
# Set the alarm to five minutes in the future 
 echo 0 > /sys/class/rtc/rtc0/wakealarm
 echo `date '+%s' -d '+ 5 minutes'` > /sys/class/rtc/rtc0/wakealarm

 /usr/sbin/pm-suspend

If the computer wakes up after 5 minutes, then congratulations.
Because "suspend to RAM" may not be very stable with the exotic hardware that a lot of mythTV users have, we want to reboot after we wake up from suspend. In fact we can add an init.d script that will suspend the computer just before it physically reboots, on wake up the computer will then do the actual reboot.




關於在 Linux 下做 RTC WakeUp 與自動排程
首先, 自動排程與 Cron or Crontab 有關, 可以參考http://linux.vbird.org/linux_basic/0430cron.php
RTC WakeUp 有兩種, 要先查看 RTC Alarm 是在哪裡
1. /proc/acpi/alarm
2. /sys/class/rtc/rtc0/wakealarm
所以設定 RTC Alarm 有兩種方法, 詳情可以參考以下兩篇文章:
摘錄如下:
1.
代表設定 40 秒之後發出 alarm,並且同時也會 enable ACPI
所以下面的命令就可以將系統 suspend to memory40 秒後 resume
# echo "+00-00-00 00:00:40" > /proc/acpi/alarm
# echo "mem" > /sys/power/state
2.
要查看支援哪些 suspend mode
# more /sys/power/state
standby mem disk
這個 RTC WakeUp 已經在 GF8100 platform with Ubnutu 8.04.01  測試 OK!!
我們可以透過 ACPI 提供的 interface,設置 RTC alarm,如此在 alarm 發出 IRQ 時,ACPI 就會 resume systemEPC 中的 genrtc module 並不支援 alarm interrupt。如果手動加入 rtc module,雖然它有支援 alarm interrupt,但是透過 rtc module 來設 alarm,與透過 ACPI interface 的差別就在於,ACPI 是否有 enable event
我們可以看看 kernel source 中,driver/acpi/sleep/proc.c
acpi_system_write_alarm 這個 function,設定 RTC alarm 之後,還會做這一行
acpi_enable_event(ACPI_EVENT_RTC, 0);
單獨透過 rtc module 是不會跑這行的。

要查看支援哪些 suspend mode
# more /sys/power/state
standby mem disk
它們分別代表 S1 S3 S4
這種方式可以用軟體來做 suspend-resume 的測試。它和 suspend 後按 power button resume 的原理不盡相同。因為 power button 的訊號是透過 GPIO 接到 EC,然後再透過 LPC 來通知南橋。RTC 本身就在南橋內了,並無透過 EC
kernel 2.6.22 之後,ACPI 改用另一個 interface 來取代 /proc/acpi/alarm。相關資訊,請參照
http://www.mythtv.org/wiki/index.php/ACPI_Wakeup

後來在網路上找到一篇有用的文章「ACPI Wakeup 」裡面有說明如何設定定時從S1/S3回來。 我是在SLES11上試了Suspend to RAM WakeAlarm Timer 的簡單方法, 參考裡面的範例把喚醒的時間設為1分鐘...試完之後結果真的可以呢~ 超高興, 系統會在時間到時自動的被叫起來 :D
echo 0 > /sys/class/rtc/rtc0/wakealarm
echo `date '+%s' -d '+ 1 minutes'` > /sys/class/rtc/rtc0/wakealarm
pm-suspend
12步驟主要是在歸零和設定定時, 進入S3 (Suspend to RAM) 主要是第3個命令, 如果要進入S1只要換這命令就好了, 1&2步不用動, 以這個script再配上shell loop 就可以做長時間的測試啦。
[*] Software Suspend (EXPERIMENTAL)  (y)
;
支援系統suspend(休眠),打開這項功能後, 可用swsusp或者shutdown -z 來掛起系統. 這樣系統會將你當前正在進行的工作(也就是當前記憶體中的內容)作成一個鏡象保存到你的交換分區中, 在你下一次啟動時使用啟動參數"resume=/dev/交換分區".內核就會將上一次的工作內核從鏡象檔中恢復到記憶體,這可以大大提高系統的啟動速 度. 當你不想恢復上次的工作時向內核傳遞參數“noresume".不過系統啟動後你的交換分區將不可以使用, 你可以使用mkswap命令來重新格式化你的交換分區. 這個功能不需要高級電源管理的支援.

Plurk